<?
require_once ('system/func.php');
$title = 'Еежедневный подарок';
require_once ('system/header.php');
auth(); // Закроем от гостей
$title = 'Ежедневный подарок';
include './system/h.php';
$gift = mysql_fetch_assoc(mysql_query("SELECT * FROM `user_podarok` WHERE `user_id` = '$user[id]' order by `last_auth` desc limit 1"));
?><style>.example table th {
border: 1px solid black;
}
.example table, .example table td, .example table th {
border: 1px solid black;
}
</style><?
$time = $gift['last_auth'] + 86400;
$now = time();
if(isset($_GET['take'])){
if ($time < $now) {
echo "<div class='block'><center><b>Поздравляем вы получили подарок <br><span class='green'>Приятной игры</span></center></div>";
mysql_query("UPDATE `users` SET `gold` = `gold` + '150' WHERE `id` = '$user[id]'");
mysql_query("UPDATE `users` SET `silver` = `silver` + '1000' WHERE `id` = '$user[id]'");
mysql_query("UPDATE `users` SET `trava` = `trava` + '5' WHERE `id` = '$user[id]'");
mysql_query("UPDATE `users` SET `kamen` = `kamen` + '5' WHERE `id` = '$user[id]'");
mysql_query("UPDATE `user` SET `health` = `health` + '0' WHERE `id` = '$user[id]'");
mysql_query("UPDATE `users` SET `key` = `key` + '2' 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 "<div class='block'>
<center>
<table caption='Название таблицы' border='1'>
<tr>
<th> золото</th>
<th> серебро</th>
<th> ключи</th><th> трава</th><th> камень</th>
</tr>
<tr>
<td><img src='/images/icons/gold.png' width='20px' alt='*'> 150</td>
<td><img src='/images/icons/silver.png' width='20px' alt='*'> 1000</td>
<td><img src='/images/icon/key.png' width='20px' alt='*'> 2</td><td><img src='/images/icons/trava.png' width='20px' alt='*'> 5</td><td><img src='/images/icons/kamen.png' width='20px' alt='*'> 5</td>
</tr>
</table></br>Вы можете забрать подарок только один раз в день.</center>
<form action='podarok.php?take' method='post'><br/>
<center><span class='end'><input class='label' type='submit' 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 "<div class='block'><center><b>Вы уже получали сегодня свой подарок.</br>Приходите через: <span class='green'>$min</span></b> мин.</b></centet></div>";
}
echo "</table></div>";
require_once ('system/footer.php')
?>