<?php
if(!isset($hard_process)){
	$q=mysql_query("SELECT * FROM `cron` WHERE `id` = 'everyday'");

if(mysql_num_rows($q)==0){
	mysql_query("INSERT INTO `cron` (`id`, `time`) VALUES ('everyday', '".$time."')");
	}

$everyday = mysql_fetch_array($q);

if($everyday==NULL || $everyday['time']<time()-60*60*24){
	$hard_process=true;

if(function_exists('set_time_limit')){
	set_time_limit(600);
	}

mysql_query("UPDATE `cron` SET `time` = '".$time."' WHERE `id` = 'everyday'");
mysql_query("DELETE FROM `guests` WHERE `date_last` < '".($time-600)."'");
mysql_query("DELETE FROM `chat_post` WHERE `time` < '".($time-60*60*24)."'");
mysql_query("DELETE FROM `user` WHERE `activation` != null AND `time_reg` < '".($time-60*60*24)."'");
$tab=mysql_query('SHOW TABLES FROM '.$set['mysql_db_name']);

for($i=0;$i<mysql_num_rows($tab);$i++){
	mysql_query("OPTIMIZE TABLE `".mysql_tablename($tab,$i)."`");
	}
	}
	}
?>