Файл: vkolhoze.com/mail_cron.php
Строк: 37
<?php
$t=microtime(1);
$time=time();
require_once'inc/start_sess.php';
mysql_query("DELETE FROM `kolhoz_zags` WHERE `time` < '".($time-(3600*6))."' AND (`status`='0' OR `status`='1' OR `status`='3') ");
mysql_query("DELETE FROM `kolhoz_mail` WHERE `time` < '".($time-(3600*24*15))."'");
mysql_query("DELETE FROM `kolhoz_ticket` WHERE `time` < '".($time-(3600*24*3))."'");
mysql_query("DELETE FROM `kolhoz_ticket_otvet` WHERE `time` < '".($time-(3600*24*3))."'");
mysql_query("DELETE FROM `kolhoz_joirnal` WHERE `time` < '".($time-(3600*24*2))."'");
mysql_query("DELETE FROM `kolhoz_warehouse` WHERE `count` = '0' AND `tachka`='0'");
////Арена рейтинг (снижение)
$q = mysql_query("SELECT `arena_rating`,`id` FROM `kolhoz_user` WHERE `arena_rating`>'1010'");
While($row=mysql_fetch_array($q)){
$rat=floor($row['arena_rating']-($row['arena_rating']/100));
mysql_query("UPDATE `kolhoz_user` SET `arena_rating` = '$rat' WHERE `id` = '$row[id]' LIMIT 1");
}
/////Акции
$kol_act=4;
$row=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_action` "));
if($row['time']<=time()+3600){
$actions=rand(1,$kol_act);
While($row['id_action']==$actions){$actions=rand(1,$kol_act);}
$day_rand = rand(3,5);
$day=date("j",time());
$month=date("n",time());
$year=date("Y",time());
$newtime=mktime(0, 0, 1, $month, $day, $year)+$day_rand*86400;
mysql_query("UPDATE `kolhoz_action` SET `id_action`='$actions',`time`='$newtime'");
mysql_query("UPDATE `kolhoz_user` SET `action_time`='0'");
}
/////Рейт за неделю
if(date("D", time())=='Mon')mysql_query("UPDATE `kolhoz_collective_user` SET `rating_week`='0',`rubies_week`='0'");
/////
$at = mysql_query('SHOW TABLES'); //получим список таблиц
while ($tables = mysql_fetch_assoc($at))
{foreach ($tables as $bd => $table) {
mysql_query('OPTIMIZE TABLE `'.trim($table).'`')or die(mysql_error());}}
echo '<br/> '.number_format(microtime(1)-$t,3).' сек.';
?>