Ejemplo n.º 1
0
function send_tracks($data)
{
    global $API, $CONFIG;
    $accounts = $API->DB->query_return("SELECT tracks.*,accounts.email,accounts.email_notifications,accounts.safari_push_notifications,accounts.push_notifications FROM tracks LEFT JOIN accounts ON tracks.account_id=accounts.id WHERE tracks.trackid={$data['trackid']}");
    $link = $API->SEO->make_link('view', 'trackid', $data['trackid']);
    if ($accounts) {
        foreach ($accounts as $a) {
            $email_notifications = explode(',', $a['email_notifications']);
            $safari_push_notificaions = explode(',', $a['safari_push_notifications']);
            $push_notificaions = explode(',', $a['push_notifications']);
            if ($push_notifications[0] != 'none' || !$push_notifications[0] || in_array('tracks', $push_notifications)) {
                $push_accounts[] = $a['account_id'];
            }
            if ($email_notifications[0] != 'none' || !$email_notifications[0] || in_array('tracks', $email_notifications)) {
                $body = "{$API->LANG->_to($a['account_id'], 'Hello')}!<br/>\n        {$API->LANG->_to($a['account_id'], 'App "%s", that you are tracking has been updated to version %s', $data['name'], $data['version'])}.<br/>\n        {$API->LANG->_to($a['account_id'], 'You can download app here')}:<br/>\n        {$link}\n        <br/><br/>\n        --<br/>\n        {$API->LANG->_to($a['account_id'], 'Best regards, team of')} {$CONFIG['sitename']}.";
                //$API->send_mail($a['email'], $CONFIG['sitename'], $CONFIG['siteemail'], $API->LANG->_to($a['account_id'], "App that you are tracking has been updated to v.%s!", $data['version']), $body);
            }
            if ($safari_push_notificaions[0] != 'none' || !$safari_push_notificaions[0] || in_array('tracks', $safari_push_notificaions)) {
                send_push_safari($API->LANG->_to($a['account_id'], 'Notification'), $API->LANG->_to($a['account_id'], "App that you are tracking has been updated to v.%s!", $data['version']), $link, $a['account_id']);
            }
        }
        if ($push_accounts) {
            $devices = $API->DB->query_return("SELECT push.udid,accounts.id FROM push LEFT JOIN accounts ON push.account_id=accounts.id WHERE account_id IN(" . $API->DB->sqlesc(implode(',', $push_accounts)) . ")");
            if ($devices) {
                foreach ($devices as $d) {
                    $udidslang[$API->LANG->getlang($d['id'])][] = $d['udid'];
                }
                $json = json_encode(array('id' => $data['trackid']));
                foreach ($udidslang as $lang => $udids) {
                    send_push($API->LANG->_translate($lang, "App %s has been updated", $data['name']), 3, $json, implode(',', $udids));
                }
            }
        }
    }
}
Ejemplo n.º 2
0
    } else {
        $API->TPL->display('acp-push.tpl');
        die;
    }
} elseif ($action == 'message') {
    $API->auth(array('is_moderator' => 1));
    $msg = htmlspecialchars($API->getval('msg'));
    $a = $API->DB->query_row("SELECT accounts.email, accounts.id,accounts.safari_push_notifications,accounts.email_notifications,accounts.push_notifications FROM accounts WHERE accounts.id={$id}");
    if ($a) {
        $email_notifications = explode(',', $a['email_notifications']);
        $safari_push_notificaions = explode(',', $a['safari_push_notifications']);
        $push_notificaions = explode(',', $a['push_notifications']);
        if ($push_notificaions[0] != 'none' || !$push_notificaions[0] || in_array('moderator', $push_notificaions)) {
            $pushes = $API->DB->query_row("SELECT GROUP_CONCAT(udid) AS udids FROM push RIGHT JOIN accounts ON push.account_id=accounts.id WHERE account_id={$id}");
            if ($pushes['udids']) {
                send_push($API->LANG->_to($a['id'], "You received message from moderator, check your email"), 0, '', $pushes['udids']);
            }
        }
        if ($email_notifications[0] != 'none' || !$email_notifications[0] || in_array('moderator', $email_notifications)) {
            $body = "{$API->LANG->_to($a['id'], 'Hello')}!<br/>\n{$API->LANG->_to($a['id'], 'Moderator has useful short message for you, that can speed up approving your apps in future')}:<br/>\n<strong>{$msg}</strong><br/>\n{$API->LANG->_to($a['id'], 'Please review this message and take appropriate action')}.\n<br/><br/>\n--<br/>\n{$API->LANG->_to($a['id'], 'Best regards, team of')} {$CONFIG['sitename']}";
            $API->send_mail($a['email'], $CONFIG['sitename'], $CONFIG['siteemail'], $API->LANG->_to($a['id'], "Important message from moderator"), $body);
        }
        if ($safari_push_notificaions[0] != 'none' || !$safari_push_notificaions[0] || in_array('moderator', $safari_push_notificaions)) {
            send_push_safari($API->LANG->_to($id, "Notification"), "You received message from moderator, check your email", $CONFIG['defaultbaseurl'], $id);
        }
        die('Message sent');
    } else {
        die('Error: no such account');
    }
} elseif ($action == 'logs') {
    $API->auth(array('view_logs' => 1));
Ejemplo n.º 3
0
    $slim->render('profiles/passcode.php');
})->name("new_passcode_profile");
$slim->post('/profiles/:profile_id', function ($profile_id) use($slim) {
    if ($_POST["type"] == "passcode") {
        $values = passcode_profile_array($_POST);
        // TODO: update my profile
    }
})->name("update_profile")->conditions(array('profile_id' => '\\d+'));
$slim->post('/profiles/new', function () use($slim) {
    // TODO: save this - do we have to save each profile type individually?
    if ($_POST["type"] == "passcode") {
        $values = passcode_profile_array($_POST);
        // TODO: create a new profile
    }
})->name("create_profile");
/**
Device pages
*/
$slim->get('/device/all', function () use($slim) {
    $devices = all_devices();
    $slim->render('devices/all.php', array("devices" => $devices));
})->name("devices");
$slim->get('/device/:udid', function ($udid) use($slim) {
})->name("device_detail");
$slim->get('/device/:udid/lock', function ($udid) use($slim) {
    $device = find_device($udid);
    $command = create_device_lock();
    add_command($device, $command);
    send_push($device);
})->name("device_lock");
$slim->run();
Ejemplo n.º 4
0
    if (!$link) {
        die($API->LANG->_('Error'));
    }
    /*
     * LINK GET CODE, used in APPGW too
     */
    //in appgw: get_signservice_link,get_directinsaller_link; signservice, directinstaller
    $link = get_directinstaller_link($link);
    //die($link);
    if (!$link) {
        $API->error($API->LANG->_('Something went wrong. Sorry for inconvenience.') . " <a href=\"{$API->SEO->make_link('report', 'id', $id, 'reason', 'Directinstaller failture')}\">{$API->LANG->_('Report broken link')}</a>");
    }
    $link = $API->SEO->make_link('plist', 'b', urlencode($app['bundle_id']), 'i', urlencode($app['image']), 'n', urlencode($app['name']), 'l', urlencode($link));
    $link = generate_short_link($link);
    //die($link);
    send_push("{$API->LANG->_('Install')} {$app['name']}", 7, json_encode(array('url' => $link)), $udid);
    //send_push('test',7,'','4297c9148fcd0894fe6447e31d296c1fc01f55c3');
    die($API->LANG->_('Install request has been sent. Please wait a little.'));
}
$API->TPL->assign('appdata', $app);
$API->TPL->assign('headeradd', '
    <link rel="stylesheet" type="text/css" href="./css/tracks.css">
<script>
function report(id) {
var report = prompt("' . str_replace('"', '\\"', $API->LANG->_('REPORT_WARNING')) . '");
	
	if (!report) {
		alert("' . str_replace('"', '\\"', $API->LANG->_('You must provide reason of report')) . '");
		return false;
	}
	
function send_toast($device_url, $title, $message, $priority = 2)
{
    $msg = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" . "<wp:Notification xmlns:wp=\"WPNotification\">" . "<wp:Toast>" . "<wp:Text1>" . $title . "</wp:Text1>" . "<wp:Text2>" . $message . "</wp:Text2>" . "<wp:Param></wp:Param>" . "</wp:Toast>" . "</wp:Notification>";
    $result = send_push($device_url, array('X-WindowsPhone-Target: toast', 'X-NotificationClass: ' . $priority), $msg);
    return $result;
}