<?php
$t = 'Ежедневный бонус';
require_once 'wcore/core.php';
require_once 'wcore/head.php';
iank();

echo '<center><div class="titles">Ежедневный бонус</div></center>';

echo '<style>.game { background: url("/img/ny_fireworkerbg.png"); background-size: 100%; }</style>';

if($ank['level'] < 26) { $exp = ($ank['level']*100); $gold = ($ank['level']*3200); $diamond = 1; }
elseif($ank['level'] < 51){ $exp = ($ank['level']*400); $gold = ($ank['level']*4000); $diamond = 2; }
elseif($ank['level'] < 76){ $exp = ($ank['level']*1600); $gold = ($ank['level']*4600); $diamond = 3; }
elseif($ank['level'] < 101){ $exp = ($ank['level']*3200); $gold = ($ank['level']*5400); $diamond = 4; }
elseif($ank['level'] < 126){ $exp = ($ank['level']*6400); $gold = ($ank['level']*8000); $diamond = 5; }
elseif($ank['level'] < 160){ $exp = ($ank['level']*20000); $gold = ($ank['level']*11800); $diamond = 8; }

	echo $_SESSION['msg'];
	$_SESSION['msg'] = NULL;
	
	$time = ($ank['time_bonus'] - time());
	
	if(isset($_GET['give']) && $ank['time_bonus'] < time()){
		mysqli_query($mysqli,"UPDATE `users` SET `time_bonus` = '". (time()+86400) ."', `exp` = '". ($exp+$ank['exp']) ."', `gold` = '". ($gold+$ank['gold']) ."', `diamond` = '". ($diamond+$ank['diamond']) ."' WHERE `id` = '". $ank['id'] ."'");
		$_SESSION['msg'] = $sd . 'Ежедневный бонус был собран!' . $_sd;
		header('Location: dbonus.php');
		exit;
	}
	
	if($ank['time_bonus'] >= time()){
		
		echo '<center><br>До следующего ежедневного бонуса осталось ' . cunter_day_unix(time()+$time) . '<br><br>';
		echo '<a href="/" class="button">Назад</a><br></center>';
		
	}else{
		echo '<center><img src="/img/buy.png"></center>';
		echo '<center><font size="6px">Награда</font><br><br><font size="4px"><img src="/img/icons/200164.png" width="18px"> ' . $gold . ' золота<br><img src="/img/icons/200135.png" width="18px"> '. $diamond .' алмазов<br>' . $exp . ' опыта</font>';
		echo '<br><a href="?give" class="button">Получить</a><br>';
		echo '<a href="/" class="button">Назад</a><br></center>';
		
	}

require_once 'wcore/foot.php';
?>