Файл: bonus.php
Строк: 48
<?
require_once 'core/system.php';
$header = 'Бонус';
require_once 'core/head.php';
$gift = mysql_fetch_assoc(mysql_query("SELECT * FROM `user_podarok` WHERE `user_id` = '$user[id]' order by `last_auth` desc limit 1"));
$time = $gift['last_auth'] + 3600;
$now = time();
echo "<table class='post'>";
if(isset($_GET['take'])){
if ($time < $now) {
echo "<br /><center><b>Поздравляем вы получили 5<img width='16' height='16' src='images/icon/gold.png' alt='o'>!</b></center></br>";
mysql_query("UPDATE `user` SET `gold` = `gold` + '5' WHERE `id` = '$user[id]'");
$helk = $user['max_health'] - $user['health'];
mysql_query("UPDATE `user` SET `health` = `health` + '0' WHERE `id` = '$user[id]'");
$mank = $user['max_mana'] - $user['mana'];
mysql_query("UPDATE `user` SET `mana` = `mana` + '0' WHERE `id` = '$user[id]'");
if(mysql_result(mysql_query("SELECT count(user_id) from `user_podarok` where `user_id` = '".$user['id']."'"),0) == 0){
mysql_query("INSERT INTO `user_podarok` SET `last_auth` = '$now', `stage` = '1', `user_id` = '$user[id]'");
}else{
mysql_query("UPDATE `user_podarok` SET `last_auth` = '$now', `stage` = `stage` + '1' WHERE `user_id` = '$user[id]'");
}
} else {
echo "</br></br>";
}
}
if ($time < $now) {
echo "<br><center><b>Один раз в <span class='red'>час</span>, у вас есть возможность получить бонус,<br> в размере 5 <img width='16' height='16' src='images/icon/gold.png' alt='o'><span class='green'></span><span class='red'></span><br /><br /></b>
<form action='bonus.php?take' method='post'><br/>
<input type='submit' class='button' name='take' value='Забрать'/>
</form></center>";
} else {
$hour_t = ceil(($time - $now) / 3600);
$min = ceil(($time - $now) / 60);
if ($hour_t == 1 or $hour_t == 21) {
$hour = 'час';
} elseif ($hour_t >= 2 and $hour_t <= 4 or $hour_t >= 22 and $hour_t <= 24) {
$hour = 'часа';
} elseif ($hour_t >= 5 and $hour_t <= 20) {
$hour = 'часов';
}
echo "<center><b>Вы уже получали сегодня подарок.</br>Приходите через: <b><span class='green'>$min </span></b>мин.</b></centet><br><br>";
}
echo "</table>";
include_once 'core/foot.php';
?>