Файл: x1update.php
Строк: 57
<?
###############################################
# by MaZaFaKa #
# ICQ: 449-559 #
# E-mail: Dimonnet@inbox.ru #
# Потраченное время: Около 2х недель #
###############################################
error_reporting(7);
////////////////////////////////
$time = microtime(true);
require 'includes/config';
////////////////////////////////////
$month = file_get_contents(ROOTPATH."/tmp/date/month");
$date = file_get_contents(ROOTPATH."/tmp/date/date");
//MONTH UPDATE
if(($month) && date("m") != $month)
{
mysql_unbuffered_query("UPDATE `".USERS."` SET `month_hosts` = 0, `month_hits` = 0;");
$fp = fopen(ROOTPATH."/tmp/date/month", "w");
fwrite($fp, date("m"));
fclose($fp);
}
//DATE UPDATE
$fp = fopen(ROOTPATH."/tmp/date/date", "w");
fwrite($fp, date("j"));
fclose($fp);
//DAY_STATS
$sql = mysql_query("SELECT `id`, `hosts`, `hits` FROM `".USERS."` WHERE `status` IN('user', 'vip');") or print(mysql_error());
if(mysql_affected_rows() > 0)
{
while($update = mysql_fetch_assoc($sql)) $q = mysql_unbuffered_query("INSERT INTO `".STATS_DAY_2009."` SET `id` = ".$update['id'].", `hosts` = ".$update['hosts'].", `hits` = ".$update['hits'].", `date` = '".date("Y-m-d")."';");
}
//END DAY STATS
//NO ACTIVE
$sql = mysql_unbuffered_query("UPDATE `".USERS."` SET `days` = (`days` +1) WHERE `hosts` = 0 AND `hits` = 0 AND `status` != 'locked';") or print(mysql_error());
$no_active = mysql_affected_rows();
$sql = mysql_unbuffered_query("UPDATE `".USERS."` SET `days` = 0 WHERE `status` IN('user', 'vip') AND `hosts` > 0 AND `hits` > 0;") or print(mysql_error());
$active = mysql_affected_rows();
//DELETE
$sql = mysql_query("UPDATE `".USERS."` SET `status` = 'delete' WHERE `days` > 10;");
$delete = mysql_affected_rows();
//Statistic
$sql = mysql_query("SELECT COUNT(*) FROM `".USERS."`;") or print(mysql_error());
$all_users = mysql_result($sql, 0);
$sql = mysql_query("SELECT SUM(`hosts`) FROM `".USERS."`;") or print(mysql_error());
$hosts = mysql_result($sql, 0);
$sql = mysql_query("SELECT SUM(`hits`) FROM `".USERS."`;") or print(mysql_error());
$hits = mysql_result($sql, 0);
//STAT UPDATE
$sql = mysql_unbuffered_query("UPDATE `".USERS."` SET `yday_hosts` = `hosts`, `yday_hits` = `hits`, `hosts` = 0, `hits` = 0, `in` = 0, `out` = 0;") or print(mysql_error());
mysql_unbuffered_query("TRUNCATE TABLE `".SHOWS."`;") or print(mysql_error());
mysql_unbuffered_query("OPTIMIZE TABLE `".ONLINE."`;") or print(mysql_error());
$logs = "Date: ".date("Y-m-d")."rn".
"All users: ".$all_users."rn".
"NEW Today active: ".$active."rn".
"No active: ".intval($no_active)."rn".
"Delete users: ".intval($delete)."rn".
"-----rn".
"Statistic:rn".
"Today hosts: ".intval($hosts)."rn".
"Today hits: ".intval($hits)."rn".
"-----rn".
"Generate time: ".(microtime(true) - $time)." secrn";
echo($logs);
$fp = fopen(ROOTPATH."/tmp/logs/".$date."-".$month."-".date('Y'), "w");
fwrite($fp, $logs);
fclose($fp);
//DIE
exit;
?>