<?php

require_once 'core/system.php';








head('Лес Тьмы');



reg();



















  if (isset($_SESSION['fos'])){?><div style="clear:both;"></div><div class="b-notice trsmgr"><div class="notify-inner"><?=$_SESSION[fos]?></div></div><?   $_SESSION['fos']=NULL; } 

  if (isset($_SESSION['snow'])){?><div style="clear:both;"></div><div class="b-notice trsmgr"><div class="notify-inner"><?=$_SESSION[snow]?></div></div><?   $_SESSION['snow']=NULL; } 


$sys = $dbc->query("SELECT `hp_snow` FROM `aluko` ORDER BY `id` LIMIT 1")->fetch_assoc(); 



if($sys['hp_snow']>0){ $in ='<span class="info">(+)</span>'; }else{ $in = '<font color="red">(Мёртв)</font>';} 



$dopi=$dbc->query("SELECT `lab`,`otr`,`otr_lim` FROM `dop` where `user`= '".$user['id']."' ")->fetch_assoc(); 




$dostup = $dopi['lab'] -time(); 


if($dopi['lab'] > time()){ $info  = 'Вы отдыхаете после прошлого сражения '.Sec2Time($dostup).' '; }else{ $info  = '<span class=info>Доступно'; }







$aluko = $dbc->query("SELECT `id` FROM `monster` WHERE `user`='".$user['id']."' LIMIT 1")->fetch_assoc();
if($aluko){ header('location:battle.php');exit; }

if($user['level']<15){ $store = 1; $limit = 5; }elseif($user['level']>=15){ $store = 2; $limit= 10; }

if(isset($_GET['day'])){  

if($user['level']<40){ header('location:fost.php');exit;}


if($dopi['otr']<$user['level']){ header('location:fost.php');exit;}

if($dopi['otr_lim']>=3){ header('location:fost.php');exit;}


$nag  = mt_rand(1,2);


if($nag==1){ ;

$ggm = 15*$user['level'];
$dbc->query("UPDATE `users` SET `rub`=`rub`+'".$ggm."' WHERE `id`='".$user['id']."'");


$_SESSION['message']='Ваша Награда <img src=/img/money/rubin.png>'.$ggm.'';}




if($nag==2){ ;

$ggk = 1000*$user['level'];


$dbc->query("UPDATE `users` SET `serebro`=`serebro`+'".$ggk."' WHERE `id`='".$user['id']."'");



$_SESSION['message']='Ваша Награда <img src=/img/stat/sera.png>'.$ggk.'';}



$dbc->query("UPDATE `dop` SET `otr`=0 , `otr_lim`=`otr_lim`+1 WHERE `user`='".$user['id']."'");


header('location:fost.php');exit;}

if(isset($_GET['labg'])){  

if ($dopi['lab'] > time()) { header('location:fost.php');exit;}
$lab = $dbc->query("SELECT * FROM `lab` WHERE `user` = '".$user['id']."' LIMIT 1")->fetch_assoc(); 

if($lab){ header('location:lab.php');exit; }
if(!$lab){





$ho = 2500;
$log = 'Заблудший Стражник';



$dbc->query("INSERT INTO `lab` (user,etap,health,max_health,za,name) values('".$user['id']."',1,'".$ho."','".$ho."',1,'".$log."')");


    $until = 900 + TIME;


$dbc->query("update `lab` set `time` = ".$until." where user = '".$user['id']."'");





header('location:lab.php');exit; }







}

if(isset($_GET['lab'])){ 

if ($dopi['lab'] > time()) { header('location:fost.php');exit;}
$lab = $dbc->query("SELECT * FROM `lab` WHERE `user` = '".$user['id']."' LIMIT 1")->fetch_assoc(); 
if($lab){ header('location:lab.php');exit; }



if(!$lab){ 


?><a class="btn" href="fost.php?labg">Начать Бой</a><? 

}else {

  if($dopi['lab'] > time()){   



?><span class="info"><center>Вы отдыхаете после прошлого сражения <?=Sec2Time($dostup)?><span></center><?


}}



 




foot();exit;

}

if($user['level']<15){ $store = 1; $limit = 10; }elseif($user['level']>=15){ $store = 2; $limit= 20; }
if($user['level']>=25){ $store = 3; $limit = 30; }
if($user['level']>=45){ $store = 4; $limit = 40; }
if($user['level']>=55){ $store = 5; $limit = 50; }
if($user['level']>=65){ $store = 6; $limit = 60; }
if($user['level']>=75){ $store = 7; $limit = 70; }
if($user['level']>=85){ $store = 8; $limit = 80; }
if($user['level']>=95){ $store = 9; $limit = 100; }




$limit   = $limit*1;





	$stor = array ('...','Волчий Вой','Призраки Тумана','Восставшие Мертвецы','Врата Ада','Стражи Адских Врат','Вторжение Демонов','Рука Тьмы','Сердце Тьмы');






?><div class="cito-name"><?=$stor[$store]?></div><?

?><center><img src="img/fores/<?=$store?>.png" width="100%" height="70" alt="*"></center><?











































$we = '<img src="img/at/os.png">';


if($user['level']>=40 and $dopi['otr_lim']<3){

?><div class="b-notice trsmgr"><span class="info"><?=$we?> <?=$user['login']?>, Убивай Проклятых Монстров в лесу и получай ценные награды, ты убил <img src="img/log/8.png"><?=$dopi['otr']?>/<?=$user['level']?>











</span></div><?






if($dopi['otr']>=$user['level']){ ?><center><a href="fost.php?day">Получить Награду</a></center><?}



}








$gogom = $dbc->query("SELECT * FROM `monster` WHERE `store`='".$store."' ORDER BY `health` DESC LIMIT 8");







while($namf=$gogom->fetch_assoc()){

$mn  = ($namf['otrava']==3) ? 8 : 2;

$sic = ($namf['otrava']==3) ? '#8ffe09' : '#991199';
$spec='';
if($namf['spec']>0){ $spec='<span class=iLegendary>**</span>';}

$time = $namf['time'] - time();

if(Sec2Time($time)>0){



$kao ='<span class=info>в бою с '.$namf['login'].'</span>'; }else{ $kao ='';}



if($namf['health']>0){ $hps='<img src="img/stat/hp.png">'.$namf['health'].'/'.$namf['max_health'].'';}else{ $hps=' <font color=red> Мёртв</font>'; }




?><a class="link-panel no-arr" href="fost_way.php?id=<?=$namf['id']?>"><img src="img/log/<?=$mn?>.png" ><span style="color: <?=$sic?>; font-weight: bold;text-shadow: 1px 0 8px #99114;"><?=$namf['name']?><?=$spec?></span> <?=$hps?> <?=$kao?></a></div></div><?






}

$bon = $dbc->query("SELECT * FROM `bonus` WHERE `user` = '".$user['id']."' LIMIT 1")->fetch_assoc(); 


if($bon['kris']==1){




$limit = $limit+20; }
?><center><span class="info">Сегодня в Лесу можно найти : <img src="img/money/money.png"><?=$user['lim']?>/<?=$limit?><span></center><?
$namf = $dbc->query("SELECT * FROM `clan` WHERE `les`=1 LIMIT 1")->fetch_assoc();


if($namf){
?><center>Лес под контролем:<a href="/clan.php?clan=<?=$namf['id']?>"><img src="img/clan_s/<?=$namf['storona']?>.png" width="14" height="14" alt="*"><?=$namf['name']?></a>(<img src="img/stat/sera.png"><?=$namf['s_l']?>)</center><? }




?><span class=iLegendary>**</span> - возможность найти вещь для вашего питомца<?

















if(isset($_GET['at']) and !empty($_GET['id'])){
    $pet_id = int($_GET['id']);
$pet = $dbc->query("SELECT * FROM `monster` WHERE `id`='".$pet_id."' LIMIT 1")->fetch_assoc();

if(!$pet){
        header("Location: fost.php");
        exit;        }


$time = $pet['time'] - time();

 if($pet['store']!=$store){       header("Location: fost.php");exit; }

 if(Sec2Time($time)>0){       header("Location: fost.php");exit; }

 if($pet['health']<=0){       header("Location: fost.php");exit; }
    $until = 120 + TIME;
$dbc->query("update `monster` set `time` = ".$until." where id = '".$pet_id."'");


$dbc->query("update `monster` set `user` = '".$user['id']."',`login`='".$user['login']."' where id = '".$pet_id."'");


header('location:battle.php');exit;





}





?> <div class="b-panel-new dblue-panel bordered mt2">
<div class="panel-inner-2"><a href="fost.php?lab"><img src="../imaga/labirint.png" alt=""style="border-radius:1px;height:20px;width:100px;"/></a>(<?=$info?>)</div></div><?








foot();

?>
