Example #1
0
function SendMapPart($map_entry, $map_part_name)
{
    global $config;
    // fail the download if the hard bandwidth cap would be reached
    $state = LoadState();
    $use_hard_limit = $config->map_server->bandwidth_cap_hard > 0;
    if ($use_hard_limit && $state->server_bandwidth->bandwidth_used + 1024576 > $config->map_server->bandwidth_cap_hard) {
        header("HTTP/1.0 404 Not Found");
        return;
    }
    // execution should continue until the bandwidth state has been updated
    $user_abort_orig = ignore_user_abort();
    ignore_user_abort(true);
    $data_sent = TransferFile($map_entry->map_parts_path . "/" . $map_part_name);
    // update web bandwidth state
    $state = LoadState();
    $state->server_bandwidth->bandwidth_used += $data_sent;
    SaveState($state);
    ignore_user_abort($user_abort_orig);
}
Example #2
0
    foreach ($completed["email"] as $item) {
        $sql = "UPDATE `task_to_user` SET email_sended = 1 " . "WHERE task_id = '" . $item["task_id"] . "' AND user_id = '" . $item["user_id"] . "'; ";
        $db->query($sql);
    }
    foreach ($completed["phone"] as $item) {
        $sql = "UPDATE `task_to_user` SET phone_sended = 1 " . "WHERE task_id = '" . $item["task_id"] . "' AND user_id = '" . $item["user_id"] . "'; ";
        $db->query($sql);
    }
}
//получаем список тех, кому нужно сообщить о таске
$task_list = GetTaskList($db);
//отправляем
$completed = array("email" => array(), "phone" => array());
foreach ($task_list as $item) {
    //если нужно отправить email
    if ($item["email_notify"] == 1) {
        if (SendEmail($item)) {
            //добавить в $completed
            array_push($completed["email"], $item);
        }
    }
    if ($item["phone_notify"] == 1) {
        if (SendSms($task)) {
            //добавить в $completed
            array_push($completed["phone"], $item);
        }
    }
}
//Saving send state
SaveState($completed, $db);