Файл: ubiznes.mobi/_crone/_firms_top_month.php
Строк: 33
<?php
$time=time();
include_once'../sys/sess.php';
include_once'../sys/functions.php';
echo "<pre>";
$top_bonus = array(
1000,
500,
200
);
$NEW_TOP = array();
$query = mysql_query("SELECT * FROM `firms` ORDER BY `month_exp` DESC LIMIT 3");
while($result = mysql_fetch_object($query))
{
if(is_null($NEW_TOP['one'])) {
$NEW_TOP['one'] = array('id' => intval($result->id), 'exp' => intval($result->month_exp));
if($result->month_exp > 0)
mysql_query("UPDATE `firms` SET `baks` = `baks` + '" . $top_bonus[0] . "' WHERE `id` = '" . $result->id . "'");
} else if(is_null($NEW_TOP['two'])) {
$NEW_TOP['two'] = array('id' => intval($result->id), 'exp' => intval($result->month_exp));
if($result->month_exp > 0)
mysql_query("UPDATE `firms` SET `baks` = `baks` + '" . $top_bonus[1] . "' WHERE `id` = '" . $result->id . "'");
} else {
$NEW_TOP['three'] = array('id' => intval($result->id), 'exp' => intval($result->month_exp));
if($result->month_exp > 0)
mysql_query("UPDATE `firms` SET `baks` = `baks` + '" . $top_bonus[2] . "' WHERE `id` = '" . $result->id . "'");
}
}
mysql_query("INSERT INTO `firms_top`(`one`, `one_exp`, `two`, `two_exp`, `three`, `three_exp`) VALUES ('" . $NEW_TOP['one']['id'] . "', '" . $NEW_TOP['one']['exp'] . "', '" . $NEW_TOP['two']['id'] . "', '" . $NEW_TOP['two']['exp'] . "', '" . $NEW_TOP['three']['id'] . "', '" . $NEW_TOP['three']['exp'] . "')");
mysql_query("UPDATE `firms` SET `month_exp` = '0'");