Файл: cron.php
Строк: 45
<?php
error_reporting(2047|2048);
//error_reporting(0);
include 'config.php';
class_exists('config') or die('Error load config class');
$config = new config(0, 0, 0);
$mysql = mysql_connect($config->mysql['host'], $config->mysql['user'], $config->mysql['pass']) or die();
mysql_select_db($config->mysql['db'], $mysql) or die();
if($config->conf['ref'] != 'off')
{
$q = mysql_query("SELECT `id`, `is1`, `ic1`, `it1`, `ref` FROM `users` WHERE `ref` > '0';", $mysql);
$n = @mysql_num_rows($q) or $n = 0;
$r = array();
for($i=1; $i<=$n; $i++)
{
$d = mysql_fetch_array($q);
$cr = $d['is1']+$d['ic1']+$d['it1'];
if($cr >= 1) $r[$d['ref']][$d['id']] = $cr;
}
foreach($r as $id => $ref)
{
if(count($ref) <= 0) continue;
$refs = '';
$crs = 0;
foreach($ref as $rid => $cr)
{
if($rid == $id) continue;
$refs .= $rid.'; ';
$crs += $cr;
}
$refs = substr($refs, 0, -2);
$crs = intval($crs/(100/15));
$mes = 'Вам начислено '.$crs.' кредитов по Вашим партнёрам.'."n";
$mes .= 'ID: '.$refs."n";
$mes .= '-----'."n";
$mes .= 'It is added you '.$crs.' credits on Your partners.'."n";
$mes .= 'ID: '.$refs."n";
if($crs > 0 && strlen($refs) > 0)
{
mysql_query("UPDATE `users` SET `bank` = `bank`+$crs WHERE `id` = '$id';", $mysql);
mysql_query("INSERT INTO `pochta` VALUES('0', '$id', '1', 'Реф. программа/Ref. program', '".$mes."', '1', '".time()."', '1');", $mysql);
}
}
}
mysql_query("UPDATE `users` SET `is2` = `is1`, `is1` = '0', `ic2` = `ic1`, `ic1` = '0', `it2` = `it1`, `it1` = '0', `ms2` = `ms1`, `ms1` = '0', `mc2` = `mc1`, `mc1` = '0', `mt2` = `mt1`, `mt1` = '0';", $mysql) or print mysql_error();
mysql_query("UPDATE `banners` SET `s2` = `s1`, `s1` = '0', `c2` = `c1`, `c1` = '0';", $mysql) or print mysql_error();
mysql_query("DELETE FROM `clicks`;", $mysql) or print mysql_error();
mysql_query("DELETE FROM `forum_ban` WHERE `time` < '".time()."';", $mysql) or print mysql_error();
mysql_close($mysql);
?>