Файл: moduls/cron/moneyback.php
Строк: 18
<?php
require ($_SERVER['DOCUMENT_ROOT'].'/core/sys.php');
$all = $db->prepare("SELECT * FROM `users` WHERE `moneyback` != ? AND `moneyback_t` <= ? ORDER BY `id`");
$all -> execute(['off',time()]);
$all = $all -> fetchAll();
if(is_array($all)){
foreach($all as $us){
$all = $db->prepare("SELECT * FROM `platform` WHERE `user` = ? AND `money` > ? ORDER BY `id`");
$all -> execute([$us['id'],'0']);
$all = $all -> fetchAll();
foreach($all as $row){
$moneyback = array(
'day' => [
'time' => 86400,
],
'week' => [
'time' => (86400 * 7),
],
'month' => [
'time' => (86400 * 30),
],
);
$update = $db->prepare("UPDATE `users` SET `money` = `money` + ?,`moneyback_t` = ? WHERE `id` = ?");
$update -> execute([$row['money'],(time() + $moneyback[$us['moneyback']]['time'] ),$us['id']]);
money_log($us['id'],$row['money'],'Автовывод с площадки №'.$row['id']);
$drop = $db->prepare('UPDATE `platform` SET `money` = `money` - ? WHERE `id` = ?');
$drop -> execute([$row['money'],$row['id']]);
}
}
}
##Cron на очистку истории авторизации##
$all = $db->prepare("SELECT * FROM `history_logs` WHERE `time` < ? ORDER BY `id` DESC");
$all -> execute([(time + (86400 * 90))]);
$all = $all -> fetchAll();
foreach($all as $row){
$del = $db->prepare("DELETE FROM `history_logs` WHERE `id` = ?");
$del -> execute([$row['id']]);
}