<?php
require_once('conf/dbc.php');
require_once('conf/session_start.php');
require_once('conf/ban.php');

if((!isset($_SESSION['id'])) and (!isset($_SESSION['nick'])))  {
?>  <script type="text/javascript">  document.location.href = "login.php";  </script><?php
}$page_title = 'Ежедневный бонус';
require_once('conf/head.php');
require_once('conf/top.php');
echo'<br/><p class="name">Ежедневный бонус</p>';
$user_id=abs(intval($_SESSION['id']));
$user=$dbc->query("SELECT * FROM `users` WHERE`id`='$usid' LIMIT 1")->fetch_assoc();

$day = 60*60*24;
$bonus_t = $user['bonus_time'] + $day;
if($bonus_t < time()){
$rand_money = rand(100,300);
$habar = rand(3000,6000);
$rand_all= rand(1,3);
if($rand_all==1){
echo '<center><div class="r6">
<div style=color:#126478;font-size:15px;margin:12px;>Вам начислено:<br>
Золото: <img src="img/ico/money.png" width="12" height="12"/> '.$rand_money.'<br></div></div>';
$dbc->query("UPDATE `users` SET 
`money`=`money`+".$rand_money.",
`bonus_time`=".time()."
WHERE `id`='$user_id'");
}elseif($rand_all==2){
echo '<center><div class="r6">
<div style=color:#126478;font-size:15px;margin:12px;>Вам начислено:<br>
Серебро: <img src="img/ico/materials.png" width="12" height="12"/> '.$habar.'<br></div></div>';
$dbc->query("UPDATE `users` SET 
`habar`=`habar`+".$habar.",
`bonus_time`=".time()."
WHERE `id`='$user_id'");
}else{
echo '<center><div class="r6">
<div style=color:#126478;font-size:15px;margin:12px;>Вам начислено:<br>
Золото: <img src="img/ico/money.png" width="12" height="12"/> '.$rand_money.'<br>
Серебро: <img src="img/ico/materials.png" width="12" height="12"/> '.$habar.'<br></div></div>';
$dbc->query("UPDATE `users` SET 
`money`=`money`+".$rand_money.",
`habar`=`habar`+".$habar.",
`bonus_time`=".time()."
WHERE `id`='$user_id'");
}
}else{
echo '<center><div class="r6"><div style=color:red;font-size:15px;margin:12px;>Вы уже получали бонус за эти сутки!</div></div></center>';
}
require_once('conf/navig.php');
require_once('conf/foot.php');
mysqli_close($dbc);
?>