<?php

define('NTOP', 1);
require_once ('../system/connect.php');
require_once ('../system/core.php');
require_once ('../system/function.php');
$prefix = "top_";
mysqli_query($mysqli,"UPDATE `".$prefix."sait` SET `hosts` = '0', `hits` = '0', `in` = '0', `out` = '0'");
$saits = mysqli_query($mysqli,"SELECT * FROM `".$prefix."sait`");
mysqli_query($mysqli,"TRUNCATE TABLE `".$prefix."online`");
$time = time()-(23*3600);
//echo date("d.m.y h:i", $time);
mysqli_query($mysqli,"DELETE FROM `".$prefix."hosts` WHERE `time` < '$time'");
mysqli_query($mysqli,"DELETE FROM `".$prefix."hits` WHERE `time` < '$time'");
mysqli_query($mysqli,"DELETE FROM `".$prefix."go` WHERE `time` < '$time'");//UPDATE
mysqli_query($mysqli,"TRUNCATE TABLE `top_inhost`");
//mysqli_query($mysqli,"DELETE FROM `".$prefix."sait` WHERE `all_hosts` < 1 AND `status` = 1");
mysqli_query($mysqli,"UPDATE `".$prefix."sait` SET `newsait` = '1' WHERE `all_in` > '".$set['newsait']."'");
mysqli_query($mysqli,"TRUNCATE TABLE `".$prefix."sait_online`");
mysqli_query($mysqli,"TRUNCATE TABLE `counter`");
mysqli_query($mysqli,"OPTIMIZE TABLE  `counter`");
mysqli_query($mysqli,"OPTIMIZE TABLE  `".$prefix."online`");
mysqli_query($mysqli,"OPTIMIZE TABLE  `".$prefix."sait_online`");
mysqli_query($mysqli,"OPTIMIZE TABLE  `".$prefix."cat`");
mysqli_query($mysqli,"OPTIMIZE TABLE  `".$prefix."go`");
mysqli_query($mysqli,"OPTIMIZE TABLE  `".$prefix."hits`");
mysqli_query($mysqli,"OPTIMIZE TABLE  `".$prefix."hosts`");
mysqli_query($mysqli,"OPTIMIZE TABLE  `".$prefix."images`");
mysqli_query($mysqli,"OPTIMIZE TABLE  `".$prefix."ip`");
mysqli_query($mysqli,"OPTIMIZE TABLE  `".$prefix."ip_name`");
mysqli_query($mysqli,"OPTIMIZE TABLE  `".$prefix."news`");
mysqli_query($mysqli,"OPTIMIZE TABLE  `".$prefix."news_comments`");
mysqli_query($mysqli,"OPTIMIZE TABLE  `".$prefix."reputation`");
mysqli_query($mysqli,"OPTIMIZE TABLE  `".$prefix."sait_comments`");
mysqli_query($mysqli,"OPTIMIZE TABLE  `".$prefix."sait`");
mysqli_query($mysqli,"OPTIMIZE TABLE  `".$prefix."settings`");
mysqli_query($mysqli,"OPTIMIZE TABLE  `".$prefix."users`");
while($row = mysqli_fetch_array($saits))
	{
		$pr=getpr($row['url']);
		$up = mysqli_query($mysqli,"UPDATE `".$prefix."sait` SET `cy`='".$cy."' WHERE `id` = '".$row['id']."'");
	}


?>
