Example #1
0
<?php

$nowday = $_GET[k] * 1;
$quant = $_GET[q] * 1;
$mashine = $_GET[m] * 1;
$today = strtotime("today");
if ($nowday < $today) {
    redirect("index.php");
}
$part_long = read_setting("part_long") * 60;
$plan = read_plan_day($nowday);
$days = read_setting("days");
if ($plan === null && $nowday > strtotime("+{$days} days", $today)) {
    redirect("index.php");
}
if ($plan === null) {
    $dayofweek = date("N", $nowday) - 1;
    $timenow = read_setting("start_time_" . $dayofweek) + $nowday;
    $quants = read_setting("parts_" . $dayofweek);
    if ($quants < $quant || $mashine > read_setting("mashines")) {
        redirect("index.php");
    }
    for ($j = 0; $j < $quant; $j++) {
        $timenow += $part_long;
    }
    $totime = $timenow + read_setting("part_long") * 60;
} else {
    $tonowday = $nowday + 3600 * 24;
    $ok = array();
    foreach ($plan as $k => $v) {
        if ($k < $nowday) {
Example #2
0
function buy_sms($userID, $nowday, $quant, $mashine, $remembers)
{
    $user = read_user("userID", $userID);
    $prices = array(0, 100, 200, 300, 400);
    $ok = array();
    $plan = read_plan_day($nowday);
    $tonowday = $nowday + 3600 * 24;
    foreach ($plan as $k => $v) {
        if ($k < $nowday) {
            continue;
        }
        if ($k > $tonowday) {
            break;
        }
        if ($v[$mashine]) {
            $ok[] = $v[$mashine];
        }
    }
    foreach ($remembers as $rem) {
        $ch = curl_init("http://sms.ru/sms/send");
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_TIMEOUT, 30);
        curl_setopt($ch, CURLOPT_POSTFIELDS, array("api_id" => "1cf27b49-8e99-6e44-45e7-b982dd8e5280", "to" => $user[phone], "text" => iconv("windows-1251", "utf-8", "Стирка " . ($rem[before] == 1 ? "начинается" : "заканчивается") . " через " . $rem[min] . " минут. " . date("d.m.Y H:i", $rem[before] == 1 ? $ok[$quant][fromtime] : $ok[$quant][totime])), "time" => ($rem[before] == 1 ? $ok[$quant][fromtime] : $ok[$quant][totime]) - $rem[min] * 60, "from" => "Stiralka1", "partner_id" => 5932));
        $body = curl_exec($ch);
        curl_close($ch);
    }
    user_pay($userID, -$prices[count($remembers)], "Оплата СМС оповещений для кванта времени с " . date("d.m.Y H:i:s", $ok[$quant][fromtime]) . " по " . date("d.m.Y H:i:s", $ok[$quant][totime]));
}