Joywork/cron/mailForTestEndAndPay_test.php

99 lines
2.6 KiB
PHP
Raw Normal View History

2026-05-22 20:21:54 +02:00
<?php
set_time_limit(0);
require_once($_SERVER['DOCUMENT_ROOT']."/config.php");
require_once($_SERVER['DOCUMENT_ROOT']."/engine/functions.php");
//ini_set('display_errors', 1);
//error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE);
$sql="SELECT * FROM users WHERE (id_tarif = 5 or id_tarif = 7) and blocked != 1";
$rez = mysql_query($sql);
$f1=file("https://joywork.ru/template_mail/endoftest.html");
$text = implode("",$f1);
while($user = mysql_fetch_assoc($rez)) {
$id_tarif = $user['id_tarif'];
$date_tarif = $user['date_tarif'];
$tarif = new Tarif;
$tarif->get($id_tarif);
$date_tarif = strtotime($date_tarif);
$date_end = $date_tarif + $tarif->period * 3600 * 24;
$dney = ceil(($date_end - time()) / 24 / 3600);
if ($dney == 4) {
$text4 = str_replace("<%num_day%>", "4 дня", $text);
$text4 = str_replace("<%fio%>", trim($user['last_name'] . ' ' . $user['first_name'] . ' ' . $user['middle_name']), $text4);
echo $text4;
}
if ($dney == 2) {
$text2 = str_replace("<%num_day%>", "2 дня", $text);
$text2 = str_replace("<%fio%>", trim($user['last_name'] . ' ' . $user['first_name'] . ' ' . $user['middle_name']), $text2);
echo $text2;
}
if ($dney == 1) {
$text1 = str_replace("<%num_day%>", "1 день", $text);
$text1 = str_replace("<%fio%>", trim($user['last_name'] . ' ' . $user['first_name'] . ' ' . $user['middle_name']), $text1);
echo $text1;
}
}
$sql="SELECT * FROM users WHERE id_tarif > 0 and blocked != 1";
$rez = mysql_query($sql);
$f1=file("https://joywork.ru/template_mail/rememberofpay.html");
$text = implode("",$f1);
while($user = mysql_fetch_assoc($rez)) {
$id_tarif = $user['id_tarif'];
$date_tarif = $user['date_tarif'];
$tarif = new Tarif;
$tarif->get($id_tarif);
$date_tarif = strtotime($date_tarif);
$date_end = $date_tarif + $tarif->period * 3600 * 24;
$dney = ceil(($date_end - time()) / 24 / 3600);
if ($dney == 0) {
$text2 = str_replace("<%fio%>", trim($user['last_name'] . ' ' . $user['first_name'] . ' ' . $user['middle_name']), $text);
echo $text2;
}
}
$sql="SELECT * FROM users WHERE blocked != 1";
$rez = mysql_query($sql);
$f1=file("https://joywork.ru/template_mail/remembermail.html");
$text = implode("",$f1);
while($user = mysql_fetch_assoc($rez)) {
$dney = ceil((time() - strtotime($user['last_auth'])) / 24 / 3600);
if ($dney == 10) {
$text2 = str_replace("<%fio%>", trim($user['last_name'] . ' ' . $user['first_name'] . ' ' . $user['middle_name']), $text);
echo $text2;
}
}