<?php

require_once 'core/system.php';


head('Таверна');





reg();  

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




if ($quest['user']==0){


$dbc->query("INSERT INTO `my_kvest` SET `user` = '".$user['id']."'");}



$one = 0;
$ever = 0;

?><center><img src="img/que.jpg" width="100%" height="120" alt="*"></center><?



?>

<div class="b_tabs font-small mt10">

<div class="b_tabs">
<table cellpadding="0" cellspacing="0" width="100%" border="0">
<tbody style="vertical-align: bottom;"><?


if($_SESSION['option']==0){



?>

<tr>
<td>
<span class="tab first active">
Ежедневные
</span>
</td><td>
<a href="/tavern.php?one" class="tab last">
Разовые

</a>
</td>
</tr><?


}elseif($_SESSION['option']==1){

    
    
  ?>  
    <tr>
<td>
<a href="/tavern.php?ever" class="tab first">
Ежедневные

</a>
</td><td>
<span class="tab last active">
Разовые

</span>
</td>
</tr><?


}






?>
</tbody>
</table>
</div>

</div>




<?

if($_SESSION['option']==0){
if($quest['q_1']==0){
$ever = 1;

?><a class="link-panel" href="/quest.php?id=1">

<span class="">Леса Страданий</span>
<span class=" fright">15 ур.</span>

<div class="clearer"></div>
</a><?

}

if($quest['q_2']==0){
$ever = 1;

?><a class="link-panel" href="/quest.php?id=2">

<span class="">Вожак Стаи</span>

<span class=" fright">20 ур.</span>
<div class="clearer"></div>
</a><?

} 
if($quest['q_3']==0){
$ever = 1;

?><a class="link-panel" href="/quest.php?id=3">

<span class="">Призраки Тумана</span>


<span class=" fright">22 ур.</span>
<div class="clearer"></div>
</a><?

}  
if($quest['q_4']==0){
$ever = 1;

?><a class="link-panel" href="/quest.php?id=4">

<span class="">Источник Зла</span>

<span class=" fright">25 ур.</span>
<div class="clearer"></div>
</a><?

}
if($quest['q_5']==0){
$ever = 1;

?><a class="link-panel" href="/quest.php?id=5">

<span class="">Восставшие мертвецы</span>

<span class=" fright">30 ур.</span>
<div class="clearer"></div>
</a><?

} 
if($quest['q_7']==0){
$ever = 1;

?><a class="link-panel" href="/quest.php?id=7">

<span class="">Некромант Наследие..</span>

<span class=" fright">35 ур.</span>
<div class="clearer"></div>
</a><?

}  
if($quest['q_8']==0){
$ever = 1;

?><a class="link-panel" href="/quest.php?id=8">

<span class="">Врата Ада</span>

<span class=" fright">40 ур.</span>
<div class="clearer"></div>
</a><?

}  


if($quest['q_9']==0){
$ever = 1;

?><a class="link-panel" href="/quest.php?id=9">

<span class="">Адская Чума</span>

<span class=" fright">45 ур.</span>
<div class="clearer"></div>
</a><?

} 



if($quest['q_10']==0){
$ever = 1;

?><a class="link-panel" href="/quest.php?id=10">

<span class="">Сердце Тьмы.. начало</span>

<span class=" fright">50 ур.</span>
<div class="clearer"></div>
</a><?

}  


if($quest['q_11']==0){
$ever = 1;

?><a class="link-panel" href="/quest.php?id=11">

<span class="">Сердце Тьмы.. истина близка</span>

<span class=" fright">55 ур.</span>

<div class="clearer"></div>
</a><?

}   









    
}


if($_SESSION['option']==1){


if($quest['q_6']==0){
$one = 1;

?><a class="link-panel" href="/quest.php?id=6">

<span class="">Надежный Спутник</span>
<span class=" fright">15 ур.</span>

<div class="clearer"></div>
</a><? 

}

if($quest['q_12']==0){
$one = 1;

?><a class="link-panel" href="/quest.php?id=12">

<span class="">Темные Стражи</span>
<span class=" fright">50 ур.</span>

<div class="clearer"></div>
</a><? 

} 

if($quest['q_13']==0){
$one = 1;

?><a class="link-panel" href="/quest.php?id=13">

<span class="">Темные Стражию. Возвращение Маркуса</span>
<span class=" fright">60 ур.</span>

<div class="clearer"></div>
</a><? 

} 




}



if(isset($_GET['ever'])){
    
$_SESSION['option']=0;




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

    
}

if(isset($_GET['one'])){
    
$_SESSION['option']=1;





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

}


if($_SESSION['option']==0 and $ever==0){?><center>нет доступных заданий</center><? }
if($_SESSION['option']==1 and $one==0){?><center>нет доступных заданий</center><? }




$deyo = int($_SESSION['np']);



if($quest['priz']>0){

$test = $dbc->query("SELECT * FROM `quest` WHERE `id`='".$deyo."' LIMIT 1")->fetch_assoc(); 


?><div class="b-panel-new brown-panel rewards-panel mt2"><span class="iLegendary">Награда:</span></br><?=$test['nagrada']?>    <img src="/img/res/med.png">3 <img src="img/money/rubin.png">10</div><? 


  ?><center><a href="tavern.php?nag"><input class="btn big" type="submit" value="Получить Награду"></a></center><? }
if(isset($_GET['nag'])){


if($quest['priz']<1){ header('location:index.php');exit;}
if($quest['priz']==1){ $dbc->query("update `users` set `gold`=`gold`+5 where `id`='".$user['id']."'");} 


if($quest['priz']==7){ $dbc->query("update `users` set `gold`=`gold`+10 where `id`='".$user['id']."'"); } 


if($quest['priz']==8){ $dbc->query("update `users` set `rub`=`rub`+100 where `id`='".$user['id']."'"); }  

if($quest['priz']==9){ $dbc->query("update `users` set `rub`=`rub`+200 where `id`='".$user['id']."'"); } 

if($quest['priz']==10){ $dbc->query("update `users` set `gold`=`gold`+15 where `id`='".$user['id']."'"); } 

if($quest['priz']==11){ $dbc->query("update `users` set `gold`=`gold`+25 where `id`='".$user['id']."'"); }  
if($quest['priz']==12){ $dbc->query("update `users` set `gold`=`gold`+500 where `id`='".$user['id']."'"); }  

if($quest['priz']==13){ $dbc->query("update `users` set `gold`=`gold`+1000 where `id`='".$user['id']."'"); }  
  

if($quest['priz']==2){ $dbc->query("update `users` set `serebro`=`serebro`+20000 where `id`='".$user['id']."'"); }


if($quest['priz']==3){
$dbc->query("update `dop` set `boi`=`boi`+1 where `user`='".$user['id']."' "); }

if($quest['priz']==4){

$dbc->query("update `dop` set `boi`=`boi`+2 where `user`='".$user['id']."' "); }

if($quest['priz']==6){ $dbc->query("update `users` set `leg`=`leg`+50 where `id`='".$user['id']."'"); } 
if($quest['priz']==5 and $user['spet']==0){




$pet_buy = $dbc->query("SELECT * FROM `pets_tj` WHERE `id` = '1'")->fetch_assoc();  

$dbc->query("INSERT INTO `user_pets` SET 

`id_user` = '$user[id]', 
`id_pets` = '$pet_buy[id]', 
`name` = '$pet_buy[name]',
`str` = '$pet_buy[str]',
`vit` = '$pet_buy[vit]',
`def` = '$pet_buy[def]',
`img` = '$pet_buy[img]',
`level` = '1',
`arena_battle` = '10'");


$dbc->query("UPDATE `users` SET 

`s_pet` =  '1'
 WHERE `id` = '$user[id]'"); 





 }

$_SESSION['np']=null;

$dbc->query("update `my_kvest` set `priz`=0 where `user`='".$user['id']."'");


$dbc->query("update `users` set `rub`=`rub`+10 where `id`='".$user['id']."'");

$_SESSION['message']='Награда Получена';
header('location:?');exit;


} 


    







foot();
