<?php
require_once ('connect.php');

$golos_za = mysql_result(mysql_query("SELECT SUM(`plus`) FROM `".$prefix."sait`"), 0);
$pers = mysql_num_rows(mysql_query("SELECT * FROM `".$prefix."users`"));
$platform = mysql_num_rows(mysql_query("SELECT * FROM `".$prefix."sait`"));
$online = mysql_num_rows(mysql_query("SELECT * FROM `".$prefix."sait_online`"));
$ban = mysql_num_rows(mysql_query("SELECT * FROM `".$prefix."sait` WHERE `ban` = '1'"));
$golos_protiv = mysql_result(mysql_query("SELECT SUM(`minus`) FROM `".$prefix."sait`"), 0);
$day_host = mysql_result(mysql_query("SELECT SUM(`hosts`) FROM `".$prefix."sait` WHERE `status` = '1' AND `ban` = '0' AND `hosts` > '0'"), 0);
$day_hit = mysql_result(mysql_query("SELECT SUM(`hits`) FROM `".$prefix."sait` WHERE `status` = '1' AND `ban` = '0' AND `hosts` > '0'"), 0);
$yday_host = mysql_result(mysql_query("SELECT SUM(`of_hosts`) FROM `".$prefix."sait` WHERE `status` = '1' AND `ban` = '0' AND `hosts` > '0'"), 0);
$yday_hit = mysql_result(mysql_query("SELECT SUM(`of_hits`) FROM `".$prefix."sait` WHERE `status` = '1' AND `ban` = '0' AND `hosts` > '0'"), 0);
$all_host = mysql_result(mysql_query("SELECT SUM(`all_hosts`) FROM `".$prefix."sait` WHERE `status` = '1' AND `ban` = '0' AND `hosts` > '0'"), 0);
$all_hit = mysql_result(mysql_query("SELECT SUM(`all_hits`) FROM `".$prefix."sait` WHERE `status` = '1' AND `ban` = '0' AND `hosts` > '0'"), 0);
$day_in = mysql_result(mysql_query("SELECT SUM(`in`) FROM `".$prefix."sait` WHERE `status` = '1' AND `ban` = '0' AND `hosts` > '0'"), 0);
$day_out = mysql_result(mysql_query("SELECT SUM(`out`) FROM `".$prefix."sait` WHERE `status` = '1' AND `ban` = '0' AND `hosts` > '0'"), 0);
$yday_in = mysql_result(mysql_query("SELECT SUM(`of_in`) FROM `".$prefix."sait` WHERE `status` = '1' AND `ban` = '0' AND `hosts` > '0'"), 0);
$yday_out = mysql_result(mysql_query("SELECT SUM(`of_out`) FROM `".$prefix."sait` WHERE `status` = '1' AND `ban` = '0' AND `hosts` > '0'"), 0);
$all_in = mysql_result(mysql_query("SELECT SUM(`all_in`) FROM `".$prefix."sait` WHERE `status` = '1' AND `ban` = '0' AND `hosts` > '0'"), 0);
$all_out = mysql_result(mysql_query("SELECT SUM(`all_out`) FROM `".$prefix."sait` WHERE `status` = '1' AND `ban` = '0' AND `hosts` > '0'"), 0);

mysql_query("TRUNCATE TABLE `".$prefix."stat`");
mysql_query("INSERT INTO `".$prefix."stat` SET `hits` = '".$day_hit."', `hosts` = '".$day_host."', `go` = '".$day_in."', `out` = '".$day_out."', `hit` = '".$yday_hit."', `host` = '".$yday_host."', `goy` = '".$yday_in."', `outtop` = '".$yday_out."', `hits_30` = '".$all_hit."', `hosts_30` = '".$all_host."', `go_30` = '".$all_in."', `out_30` = '".$all_out."', `za` = '".$golos_za."', `protiv` = '".$golos_protiv."', `ban` = '".$ban."', `platform` = '".$platform."', `pers` = '".$pers."', `online` = '".$online."'");

?>