<?PHP


require("./optimize/optinize.php");

$user=$_SESSION["username"];
if($update_file_stats+600 < time()){
$DATA_ARRAY = mysql_query("SELECT
(SELECT COUNT(id) FROM seelf_task WHERE credits>0 AND active='1') crezd,
(SELECT COUNT(id) FROM seelf_task WHERE credits>1 AND active='0') crerzd,
(SELECT COUNT(id) FROM seelf_task_pay WHERE tipo='good') goodzd,
(SELECT COUNT(id) FROM seelf_task_pay WHERE tipo='') gdwaitzd,
(SELECT COUNT(id) FROM seelf_task_ban WHERE nameuser='".$user."') namezd,
(SELECT COUNT(id) FROM seelf_task_pay WHERE tipo='bad') badzd,
(SELECT sum(amount) FROM tb_history WHERE tipo='reklama') amountzd,
(SELECT sum(pay) FROM seelf_task_pay WHERE tipo='good') payzd,
(SELECT sum(pay) FROM seelf_task_pay WHERE nameuser='".$user."' and tipo='good') payuserzd,
(SELECT COUNT(id) FROM seelf_task_pay WHERE namep='".$user."' and tipo='') waitza,
(SELECT sum(reyt_user) FROM seelf_task_pay WHERE nameuser='".$user."') reyt_userza,
(SELECT valuta FROM tb_site WHERE id='1') valuta,
(SELECT sum(amount) FROM tb_history WHERE user='".$user."' and tipo='reklama') amountuserzd

") or die(mysql_error()); $wel++;


$DATA_ARRAY = mysql_fetch_array($DATA_ARRAY);
$optimize_crezd = $DATA_ARRAY["crezd"];
$optimize_crerzd = $DATA_ARRAY["crerzd"];
$optimize_goodzd = $DATA_ARRAY["goodzd"];
$optimize_gdwaitzd = $DATA_ARRAY["gdwaitzd"];
$optimize_namezd = $DATA_ARRAY["namezd"];
$optimize_badzd = $DATA_ARRAY["badzd"];
$optimize_amountzd = $DATA_ARRAY["amountzd"];
$optimize_payzd = $DATA_ARRAY["payzd"];
$optimize_payuserzd = $DATA_ARRAY["payuserzd"];
$optimize_amountuserzd = $DATA_ARRAY["amountuserzd"];
$optimize_waitza = $DATA_ARRAY["waitza"];
$optimize_reyt_userza = $DATA_ARRAY["reyt_userza"];
$optimize_VALYUTA = $DATA_ARRAY["valuta"];

$update_file_stats = time();
$content_stats = "<?PHP \n
\$update_file_stats = {$update_file_stats}; \n
\$optimize_userazd = {$optimize_userazd}; \n
\$optimize_crezd = {$optimize_crezd}; \n
\$optimize_crerzd = {$optimize_crerzd}; \n
\$optimize_goodzd = {$optimize_goodzd}; \n
\$optimize_gdwaitzd = {$optimize_gdwaitzd}; \n
\$optimize_namezd = {$optimize_namezd}; \n
\$optimize_badzd = {$optimize_badzd}; \n
\$optimize_amountzd = {$optimize_amountzd}; \n
\$optimize_payzd = {$optimize_payzd}; \n
\$optimize_payuserzd = {$optimize_payuserzd}; \n
\$optimize_amountuserzd = {$optimize_amountuserzd}; \n
\$optimize_waitza = {$optimize_waitza}; \n
\$optimize_reyt_userza = {$optimize_reyt_userza}; \n
\$optimize_VALYUTA = '{$optimize_VALYUTA}'; \n
?>";
$fstats = @fopen("./optimize/stop_optimize.php","w+");
@fwrite($fstats,$content_stats);
@fclose($fstats);
}
?>