<?php
include 'core/system.php';

head('Рюкзак');
reg();
  if (isset($_SESSION['bag'])){?><div style="clear:both;"></div><div class="b-notice trsmgr"><div class="notify-inner"><?=$_SESSION['bag']?></div></div><?   $_SESSION['bag']=NULL; }


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

  $dop=$dbc->query("SELECT * FROM `dop`where `user`= '".$user['id']."' ")->fetch_assoc();

$fyu  = $dop['box1']+$dop['box2']+$dop['box3']+$dop['box4'];
if($dop['tal_cuz']>0){ $sera_dop = 5*$dop['tal_cuz']; $exp_dop = 1*$dop['tal_cuz']; }else{ $sera_dop=0; $exp_dop=0; }


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

<div class="b_tabs">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tbody style="vertical-align: bottom;">
<tr>
<td>
<span class="tab first active">
Рюкзак
</span>
</td><td>
<a href="/bag_pet.php?" class="tab last">
Вещи для Питомца

</a>
</td>
</tr></tbody>
</table>
</div>

</div><?

  $razbor=$dbc->query("SELECT * FROM `razbor`where `level`= '".$dop['razbor_lvl']."' ")->fetch_assoc();

$sql = $dbc->query("SELECT * FROM `artefact` WHERE `user_id`='".$user['id']."' AND `status` = 1  ");

$total = $dbc->query("SELECT `id` FROM `artefact` where `user_id` ='".$user['id']."' AND `status` = 1 "); $total =$total->num_rows;

if($total==0 and $fyu == 0){


echo '<div class="main"><div class="block_zero center">В Рюкзаке ничего нет</div></div>';
}
if(isset($_GET['go']) and !empty($_GET['open'])){ 



    $open = int($_GET['open']); 

if($open==1){


if($dop['box1']<=0){ header('location:bag?');exit;}


$silver = mt_rand(200,500);

$rubin = mt_rand(5,10);

$silver = $silver*$user['level'];     



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


$dbc->query("update `dop` set `box1`=`box1`-1 where `user`='".$user['id']."' ");     



$frag = mt_rand(10,15);  






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

    



$_SESSION['bag']='<center>Серебряный сундук открыт</br><img src=img/money/rubin.png>'.$rubin.' <img src=img/stat/sera.png>'.$silver.' Фрагменты +'.$frag.'</center>';



}


if($open==2){


if($dop['box2']<=0){ header('location:bag?');exit;}



$silver = mt_rand(700,1200);

$rubin = mt_rand(15,20);

$silver = $silver*$user['level'];


$gold = mt_rand(5,10);     



$dbc->query("update `users` set `serebro`=`serebro`+'".$silver."' , `rub`=`rub`+'".$rubin."' , `gold`=`gold`+'".$gold."' where `id`='".$user['id']."' ");     


$dbc->query("update `dop` set `box2`=`box2`-1 where `user`='".$user['id']."' ");     




$frag = mt_rand(30,45);  






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

    


$_SESSION['bag']='<center>Золотой сундук открыт</br><img src=img/money/money.png>'.$gold.'<img src=img/money/rubin.png>'.$rubin.'<img src=img/stat/sera.png>'.$silver.' Фрагменты +'.$frag.'</center>';



}



if($open==3){


if($dop['box3']<=0){ header('location:bag?');exit;}



$silver = mt_rand(1500,2000);

$rubin = mt_rand(30,50);

$silver = $silver*$user['level'];


$gold = mt_rand(10,15); 


$svitok = mt_rand(1,2);    



$dbc->query("update `users` set `serebro`=`serebro`+'".$silver."' , `rub`=`rub`+'".$rubin."' , `gold`=`gold`+'".$gold."' where `id`='".$user['id']."' "); 

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

$dbc->query("update `dop` set `box3`=`box3`-1 where `user`='".$user['id']."' ");     




$frag = mt_rand(60,90);  






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

    


$_SESSION['bag']='<center>Магический сундук открыт</br><img src=img/money/money.png>'.$gold.'<img src=img/money/rubin.png>'.$rubin.'<img src=img/stat/sera.png>'.$silver.'</br><span class=iLegendary>найден Свиток Охотника('.$svitok.')</span> Фрагменты +'.$frag.'</center>';




}


if($open==4){


if($dop['box4']<=0){ header('location:bag?');exit;}



$silver = mt_rand(2500,3000);

$rubin = mt_rand(80,100);

$silver = $silver*$user['level'];


$gold = mt_rand(20,25); 






$dbc->query("update `users` set `serebro`=`serebro`+'".$silver."' , `rub`=`rub`+'".$rubin."' , `gold`=`gold`+'".$gold."' where `id`='".$user['id']."' "); 

    


$dbc->query("update `dop` set `box4`=`box4`-1 where `user`='".$user['id']."' ");     


$bonus=$dbc->query("SELECT * FROM `baza_bonus` where `sunduk`= 1 ORDER BY RAND() LIMIT 1 ")->fetch_assoc();   


$bylol = ("INSERT INTO `bag_bonus` (user_id,nik,tip,img,dop,lite,time) values('".$user['id']."','".$bonus['nik']."','".$bonus['tip']."','".$bonus['img']."','".$bonus['dop']."','".$bonus['lite']."','".$bonus['time']."')"); 



$dbc->query($bylol);




$_SESSION['bag']='<center>Легендарный сундук открыт</br><img src=img/money/money.png>'.$gold.'<img src=img/money/rubin.png>'.$rubin.'<img src=img/stat/sera.png>'.$silver.'</center>';





$_SESSION['message']='<center>Вы нашли <span
class='.$bonus['lite'].'>




'.$bonus['nik'].'</span></center>';





}












header('location:?');exit;
}

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

    $get = int($_SESSION['idss']);



$pot =$dbc->query("SELECT * FROM `artefact` WHERE `id`='".$get."' AND `user_id`='".$user['id']."' LIMIT 1")->fetch_assoc();
?><div class="b-panel-new dblue-panel bordered mt2"><div class="panel-inner-2"><div class="font-small text-italic c-verygray">Вы уверены что хотите разобрать:</div></div></div><?




?><div class="sblue-panel"><div class="panel-inner-3"><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="37" style="vertical-align: top;"><img width="32"height="32" src="img/items/<?=$pot['img']?>.png" alt="."border="0"></td><td><div><a href="/info_art.php?ids=<?=$pot['id']?>" class="<?=$pot['lite']?>"><center><?=$pot['nik']?></a></center></div><span class="nowrap"></span> <span class="nowrap"></span><span class="clearer"></span></td><td width="60"><a href="/bag?go=<?=$pot['id']?><??>&amp;razbor" class="gr-btn center"><span>Разобрать</span></a></td>  <td width="60"><a href="/bag?" class="gr-btn center"><span>Отменить</span></td></tr></table></div></div><?





foot();

exit();


}
if(isset($_GET['allep'])){


$totalll2 = $dbc->query("SELECT (id) FROM `artefact` where `user_id` =  '".$user['id']."' and `status` = 1 and `lite` = 'iEpic'");
$totals2= $totalll2->num_rows; 

if($totals2<=0){ header("Location: bag?");exit;}

$sera=2000; $exp=40;



$sera=$sera+$sera_dop; $exp=$exp+$exp_dop; 

$sera = $sera*$totals2;

$exp = $exp*$totals2;




$dbc->query("UPDATE `users` SET `serebro`=`serebro`+'".$sera."' WHERE `id`='".$user['id']."'");
$dbc->query("UPDATE `dop` SET `razbor_exp`=`razbor_exp`+'".$exp."' WHERE `user`='".$user['id']."'");
$dbc->query("delete from `artefact` where `user_id`='".$user['id']."' and `status` = 1 and `lite`= 'iEpic'");


  $new_dop=$dbc->query("SELECT * FROM `dop`where `user`= '".$user['id']."' ")->fetch_assoc();
if($new_dop['razbor_exp']>=$razbor['exp']){

$dbc->query("UPDATE `users` SET `max_health`=`max_health`+50, `strength`=`strength`+10, `defense`=`defense`+10, `gold`=`gold`+100 WHERE `id`='".$user['id']."'");

$dbc->query("UPDATE `dop` SET `razbor_lvl`=`razbor_lvl`+1 , `razbor_exp`=0 WHERE `user`='".$user['id']."'");
$_SESSION['bag'] = 'Уровень Разбора Повышен! получено 100 золота';

}
$_SESSION['message'] = 'Вещи Разобраны  <img src="img/stat/sera.png">'.$sera.' Опыт разбора: '.$exp.'';




header('location: bag?');exit();  }

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


$totalll = $dbc->query("SELECT (id) FROM `artefact` where `user_id` =  '".$user['id']."' and `status` = 1 and `lite` = 'iSuperior'");
$totals= $totalll->num_rows; 

if($totals<=0){ header("Location: bag?");exit;}

$sera=500; $exp=10;


$sera=$sera+$sera_dop; $exp=$exp+$exp_dop; 

$sera = $sera*$totals;
$exp = $exp*$totals;



$dbc->query("UPDATE `users` SET `serebro`=`serebro`+'".$sera."' WHERE `id`='".$user['id']."'");
$dbc->query("UPDATE `dop` SET `razbor_exp`=`razbor_exp`+'".$exp."' WHERE `user`='".$user['id']."'");
$dbc->query("delete from `artefact` where `user_id`='".$user['id']."' and `status` = 1 and `lite`= 'iSuperior'");


  $new_dop=$dbc->query("SELECT * FROM `dop`where `user`= '".$user['id']."' ")->fetch_assoc();
if($new_dop['razbor_exp']>=$razbor['exp']){

$dbc->query("UPDATE `users` SET `max_health`=`max_health`+50, `strength`=`strength`+10, `defense`=`defense`+10, `gold`=`gold`+100 WHERE `id`='".$user['id']."'");

$dbc->query("UPDATE `dop` SET `razbor_lvl`=`razbor_lvl`+1 , `razbor_exp`=0 WHERE `user`='".$user['id']."'");
$_SESSION['bag'] = 'Уровень Разбора Повышен! получено 100 золота';

}
$_SESSION['message'] = 'Вещи Разобраны  <img src="img/stat/sera.png">'.$sera.' Опыт разбора: '.$exp.'';




header('location: bag?');exit();  }


if(isset($_GET['razbor']) and !empty($_GET['go'])){    
$it = int($_GET['go']);

$pet = $dbc->query("SELECT * FROM `artefact` WHERE `id`='".$it."' AND `user_id`='".$user['id']."' LIMIT 1")->fetch_assoc();

    if(!$pet){    header("Location: bag"); exit;}


            if($pet['status']==2){    header("Location: index.php");exit; }
if($pet['lite']==iLegendary){ $sera=10000; $exp=80;} if($pet['lite']==iSuperior){ $sera=500; $exp=10;} if($pet['lite']==iEpic){ $sera=2000; $exp=40;}

$sera=$sera+$sera_dop; $exp=$exp+$exp_dop;


$dbc->query("UPDATE `users` SET `serebro`=`serebro`+'".$sera."' WHERE `id`='".$user['id']."'");
$dbc->query("UPDATE `dop` SET `razbor_exp`=`razbor_exp`+'".$exp."' WHERE `user`='".$user['id']."'");
if($pet['craft']>0){


$ci =0;
$gg = 0;

$array = array();

for ($i = 1; $i <= $pet['craft']; $i++) {

    
$ges  = 2000*$i;


    array_push($array, $ges);


} 

$pi =  array_sum($array); 

if($pet['craft']>30){
$ar = array();

$lise = $pet['craft']-30;


for ($i = 1; $i <= $lise; $i++) {

    
$man  = 200*$i+800;



    array_push($ar, $man); }


$cant = $pet['craft'] -30; 


 $gg = 120000*$cant;

$ci =  array_sum($ar); } 

$pi = $pi+$gg;

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

$_SESSION['craft']='Ресурсы Кузнеца <img src=img/stat/sera.png>'.$pi.' <img src=img/money/rubin.png>'.$ci.'';




}

$dbc->query("delete from `artefact` where `id`='".$pet['id']."'");

$dbc->query("update `stone_bag` set `status`=1, `id_item`=0 where `id_item`='".$pet['id']."' ");     


  $new_dop=$dbc->query("SELECT * FROM `dop`where `user`= '".$user['id']."' ")->fetch_assoc();
if($new_dop['razbor_exp']>=$razbor['exp']){

$dbc->query("UPDATE `users` SET `max_health`=`max_health`+50, `strength`=`strength`+10, `defense`=`defense`+10, `gold`=`gold`+100 WHERE `id`='".$user['id']."'");

$dbc->query("UPDATE `dop` SET `razbor_lvl`=`razbor_lvl`+1 , `razbor_exp`=0 WHERE `user`='".$user['id']."'");
$_SESSION['bag'] = 'Уровень Разбора Повышен! получено 100 золота';

}
$_SESSION['message'] = 'Вещь разобрана  <img src="img/stat/sera.png">'.$sera.' Опыт разбора: '.$exp.'';


header('location: bag?');exit();

}

if(isset($_GET['sel']) and !empty($_GET['ids'])){


    $_SESSION['idss'] = int($_GET['ids']);


header('location:bag?sell');exit;


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

if(!$pet){
        header("Location: bag");
        exit;
        }
        if($user['level']<$pet['level']){
$_SESSION['message'] = 'Эта вещь доступна с '.$pet['level'].' Уровня';
header("Location: bag?");  exit();
            
            
        }
        if($pet['status']==2){
        header("Location: index.php");
        exit;
        }
if($pet['class']!=$user['pers']){ $_SESSION['err'] = 'Эта вещь для другого класса!';
header('Location: bag?');exit();}

        if($pet['tip']==1 and $user['helmet']==1){ 

$prov= $dbc->query("SELECT * FROM `artefact` WHERE `tip`=1 AND `status`=2 AND `user_id`='".$user['id']."' LIMIT 1")->fetch_assoc(); 

$dbc->query("UPDATE `users` SET `strength`=`strength`-'".$prov['strong']."',`max_health`=`max_health`-'".$prov['hp']."',`defense`=`defense`-'".$prov['prot']."',`regen`=`regen`-'".$prov['regen']."',`crit`=`crit`-'".$prov['crit']."',`helmet`=0 ,`vampir`=`vampir`-'".$prov['vamp']."',`sokru`=`sokru`-'".$prov['sok']."' WHERE `id`='".$user['id']."'");


    $dbc->query("UPDATE `artefact` SET `status`=1 WHERE `id`='".$prov['id']."'"); }
        if($pet['tip']==2 and $user['plesh']==1){ $prov= $dbc->query("SELECT * FROM `artefact` WHERE `tip`=2 AND `status`=2 AND `user_id`='".$user['id']."' LIMIT 1")->fetch_assoc(); 

$dbc->query("UPDATE `users` SET `strength`=`strength`-'".$prov['strong']."',`max_health`=`max_health`-'".$prov['hp']."',`defense`=`defense`-'".$prov['prot']."',`regen`=`regen`-'".$prov['regen']."',`crit`=`crit`-'".$prov['crit']."',`plesh`=0 ,`vampir`=`vampir`-'".$prov['vamp']."',`sokru`=`sokru`-'".$prov['sok']."' WHERE `id`='".$user['id']."'");


    $dbc->query("UPDATE `artefact` SET `status`=1 WHERE `id`='".$prov['id']."'"); }

        if($pet['tip']==3 and $user['armor']==1){ $prov= $dbc->query("SELECT * FROM `artefact` WHERE `tip`=3 AND `status`=2 AND `user_id`='".$user['id']."' LIMIT 1")->fetch_assoc(); 

$dbc->query("UPDATE `users` SET `strength`=`strength`-'".$prov['strong']."',`max_health`=`max_health`-'".$prov['hp']."',`defense`=`defense`-'".$prov['prot']."',`regen`=`regen`-'".$prov['regen']."',`crit`=`crit`-'".$prov['crit']."',`armor`=0 ,`vampir`=`vampir`-'".$prov['vamp']."',`sokru`=`sokru`-'".$prov['sok']."' WHERE `id`='".$user['id']."'");


    $dbc->query("UPDATE `artefact` SET `status`=1 WHERE `id`='".$prov['id']."'"); }

        if($pet['tip']==4 and $user['weapon']==1){ $prov= $dbc->query("SELECT * FROM `artefact` WHERE `tip`=4 AND `status`=2 AND `user_id`='".$user['id']."' LIMIT 1")->fetch_assoc(); 

$dbc->query("UPDATE `users` SET `strength`=`strength`-'".$prov['strong']."',`max_health`=`max_health`-'".$prov['hp']."',`defense`=`defense`-'".$prov['prot']."',`regen`=`regen`-'".$prov['regen']."',`crit`=`crit`-'".$prov['crit']."',`weapon`=0 ,`vampir`=`vampir`-'".$prov['vamp']."',`sokru`=`sokru`-'".$prov['sok']."' WHERE `id`='".$user['id']."'");


    $dbc->query("UPDATE `artefact` SET `status`=1 WHERE `id`='".$prov['id']."'"); }

        if($pet['tip']==5 and $user['zashita']==1){ $prov= $dbc->query("SELECT * FROM `artefact` WHERE `tip`=5 AND `status`=2 AND `user_id`='".$user['id']."' LIMIT 1")->fetch_assoc(); 

$dbc->query("UPDATE `users` SET `strength`=`strength`-'".$prov['strong']."',`max_health`=`max_health`-'".$prov['hp']."',`defense`=`defense`-'".$prov['prot']."',`regen`=`regen`-'".$prov['regen']."',`crit`=`crit`-'".$prov['crit']."',`zashita`=0 ,`vampir`=`vampir`-'".$prov['vamp']."',`sokru`=`sokru`-'".$prov['sok']."' WHERE `id`='".$user['id']."'");


    $dbc->query("UPDATE `artefact` SET `status`=1 WHERE `id`='".$prov['id']."'"); }
        if($pet['tip']==6 and $user['kolco']==1){ $prov= $dbc->query("SELECT * FROM `artefact` WHERE `tip`=6 AND `status`=2 AND `user_id`='".$user['id']."' LIMIT 1")->fetch_assoc(); 

$dbc->query("UPDATE `users` SET `strength`=`strength`-'".$prov['strong']."',`max_health`=`max_health`-'".$prov['hp']."',`defense`=`defense`-'".$prov['prot']."',`regen`=`regen`-'".$prov['regen']."',`crit`=`crit`-'".$prov['crit']."',`kolco`=0 ,`vampir`=`vampir`-'".$prov['vamp']."',`sokru`=`sokru`-'".$prov['sok']."' WHERE `id`='".$user['id']."'");


    $dbc->query("UPDATE `artefact` SET `status`=1 WHERE `id`='".$prov['id']."'"); }
        
if($pet['tip']==7 and $user['pos']==1){ $prov= $dbc->query("SELECT * FROM `artefact` WHERE `tip`=7 AND `status`=2 AND `user_id`='".$user['id']."' LIMIT 1")->fetch_assoc(); 

$dbc->query("UPDATE `users` SET `strength`=`strength`-'".$prov['strong']."',`max_health`=`max_health`-'".$prov['hp']."',`defense`=`defense`-'".$prov['prot']."',`regen`=`regen`-'".$prov['regen']."',`crit`=`crit`-'".$prov['crit']."',`pos`=0 ,`vampir`=`vampir`-'".$prov['vamp']."',`sokru`=`sokru`-'".$prov['sok']."' WHERE `id`='".$user['id']."'"); 
    $dbc->query("UPDATE `artefact` SET `status`=1 WHERE `id`='".$prov['id']."'"); } 

if($pet['tip']==8 and $user['she']==1){ $prov= $dbc->query("SELECT * FROM `artefact` WHERE `tip`=8 AND `status`=2 AND `user_id`='".$user['id']."' LIMIT 1")->fetch_assoc(); 

$dbc->query("UPDATE `users` SET `strength`=`strength`-'".$prov['strong']."',`max_health`=`max_health`-'".$prov['hp']."',`defense`=`defense`-'".$prov['prot']."',`regen`=`regen`-'".$prov['regen']."',`crit`=`crit`-'".$prov['crit']."',`she`=0 ,`vampir`=`vampir`-'".$prov['vamp']."',`sokru`=`sokru`-'".$prov['sok']."' WHERE `id`='".$user['id']."'"); }


if($pet['tip']==9 and $user['art']==1){ $prov= $dbc->query("SELECT * FROM `artefact` WHERE `tip`=9 AND `status`=2 AND `user_id`='".$user['id']."' LIMIT 1")->fetch_assoc(); 

$dbc->query("UPDATE `users` SET `strength`=`strength`-'".$prov['strong']."',`max_health`=`max_health`-'".$prov['hp']."',`defense`=`defense`-'".$prov['prot']."',`regen`=`regen`-'".$prov['regen']."',`crit`=`crit`-'".$prov['crit']."',`art`=0 ,`vampir`=`vampir`-'".$prov['vamp']."',`sokru`=`sokru`-'".$prov['sok']."' WHERE `id`='".$user['id']."'"); }



    $dbc->query("UPDATE `artefact` SET `status`=1 WHERE `id`='".$prov['id']."'"); 




if($pet['tip']==1){    $dbc->query("UPDATE `users` SET `strength`=`strength`+'".$pet['strong']."',`max_health`=`max_health`+'".$pet['hp']."',`defense`=`defense`+'".$pet['prot']."',`regen`=`regen`+'".$pet['regen']."',`crit`=`crit`+'".$pet['crit']."',`helmet`=1 ,`vampir`=`vampir`+'".$pet['vamp']."',`sokru`=`sokru`+'".$pet['sok']."' WHERE `id`='".$user['id']."'");}

if($pet['tip']==2){    $dbc->query("UPDATE `users` SET `strength`=`strength`+'".$pet['strong']."',`max_health`=`max_health`+'".$pet['hp']."',`defense`=`defense`+'".$pet['prot']."',`regen`=`regen`+'".$pet['regen']."',`crit`=`crit`+'".$pet['crit']."',`plesh`=1 ,`vampir`=`vampir`+'".$pet['vamp']."',`sokru`=`sokru`+'".$pet['sok']."' WHERE `id`='".$user['id']."'");}

if($pet['tip']==3){    $dbc->query("UPDATE `users` SET `strength`=`strength`+'".$pet['strong']."',`max_health`=`max_health`+'".$pet['hp']."',`defense`=`defense`+'".$pet['prot']."',`regen`=`regen`+'".$pet['regen']."',`crit`=`crit`+'".$pet['crit']."',`armor`=1 ,`vampir`=`vampir`+'".$pet['vamp']."',`sokru`=`sokru`+'".$pet['sok']."' WHERE `id`='".$user['id']."'");}

if($pet['tip']==4){    $dbc->query("UPDATE `users` SET `strength`=`strength`+'".$pet['strong']."',`max_health`=`max_health`+'".$pet['hp']."',`defense`=`defense`+'".$pet['prot']."',`regen`=`regen`+'".$pet['regen']."',`crit`=`crit`+'".$pet['crit']."',`weapon`=1 ,`vampir`=`vampir`+'".$pet['vamp']."',`sokru`=`sokru`+'".$pet['sok']."' WHERE `id`='".$user['id']."'");}

if($pet['tip']==5){    $dbc->query("UPDATE `users` SET `strength`=`strength`+'".$pet['strong']."',`max_health`=`max_health`+'".$pet['hp']."',`defense`=`defense`+'".$pet['prot']."',`regen`=`regen`+'".$pet['regen']."',`crit`=`crit`+'".$pet['crit']."',`zashita`=1 ,`vampir`=`vampir`+'".$pet['vamp']."',`sokru`=`sokru`+'".$pet['sok']."' WHERE `id`='".$user['id']."'");}

if($pet['tip']==6){    $dbc->query("UPDATE `users` SET `strength`=`strength`+'".$pet['strong']."',`max_health`=`max_health`+'".$pet['hp']."',`defense`=`defense`+'".$pet['prot']."',`regen`=`regen`+'".$pet['regen']."',`crit`=`crit`+'".$pet['crit']."',`kolco`=1 ,`vampir`=`vampir`+'".$pet['vamp']."',`sokru`=`sokru`+'".$pet['sok']."' WHERE `id`='".$user['id']."'");}
if($pet['tip']==7){    $dbc->query("UPDATE `users` SET `strength`=`strength`+'".$pet['strong']."',`max_health`=`max_health`+'".$pet['hp']."',`defense`=`defense`+'".$pet['prot']."',`regen`=`regen`+'".$pet['regen']."',`crit`=`crit`+'".$pet['crit']."',`pos`=1 ,`vampir`=`vampir`+'".$pet['vamp']."',`sokru`=`sokru`+'".$pet['sok']."' WHERE `id`='".$user['id']."'");} 



if($pet['tip']==8){    $dbc->query("UPDATE `users` SET `strength`=`strength`+'".$pet['strong']."',`max_health`=`max_health`+'".$pet['hp']."',`defense`=`defense`+'".$pet['prot']."',`regen`=`regen`+'".$pet['regen']."',`crit`=`crit`+'".$pet['crit']."',`she`=1 ,`vampir`=`vampir`+'".$pet['vamp']."',`sokru`=`sokru`+'".$pet['sok']."' WHERE `id`='".$user['id']."'");} 
if($pet['tip']==9){    $dbc->query("UPDATE `users` SET `strength`=`strength`+'".$pet['strong']."',`max_health`=`max_health`+'".$pet['hp']."',`defense`=`defense`+'".$pet['prot']."',`regen`=`regen`+'".$pet['regen']."',`crit`=`crit`+'".$pet['crit']."',`art`=1 ,`vampir`=`vampir`+'".$pet['vamp']."',`sokru`=`sokru`+'".$pet['sok']."' WHERE `id`='".$user['id']."'");}  

$dbc->query("UPDATE `artefact` SET `status`=2 WHERE `id`='".$pet_id."'");
if($user['ob']<5){
$dbc->query("UPDATE `users` SET `ob`=`ob`+1 WHERE `id`='".$user['id']."'");}
$_SESSION['message'] = 'Вы надели '.$pet[nik].'';

header('Location: bag?');exit();
        foot();
}




if($dop['box4']>0){

?><div class="sblue-panel"><div class="panel-inner-3"><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="37" style="vertical-align: top;"><img width="32"height="32" src="img/ivent/4.png" alt="."border="0"





</td><td><div><a href="/box_info.php?ids=4" class="iLegendary"><center>Легендарный Сундук</a>(<?=$dop['box4']?>)</center></div><span class="nowrap"></span> <span class="nowrap"></span><span class="clearer"></span></td><td width="60"><a href="/bag?open=4<??>&amp;go" class="gr-btn center"><span>Открыть</span></a></td></span></td></tr></table></div></div><? }





if($dop['box3']>0){

?><div class="sblue-panel"><div class="panel-inner-3"><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="37" style="vertical-align: top;"><img width="32"height="32" src="img/ivent/3.png" alt="."border="0"



</td><td><div><a href="/box_info.php?ids=1" class="iEpic"><center>Магический  Сундук</a>(<?=$dop['box3']?>)</center></div><span class="nowrap"></span> <span class="nowrap"></span><span class="clearer"></span></td><td width="60"><a href="/bag?open=3<??>&amp;go" class="gr-btn center"><span>Открыть</span></a></td></span></td></tr></table></div></div><? }




if($dop['box2']>0){

?><div class="sblue-panel"><div class="panel-inner-3"><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="37" style="vertical-align: top;"><img width="32"height="32" src="img/ivent/2.png" alt="."border="0"



</td><td><div><a href="/box_info.php?ids=2" class="iLegendary"><center>Золотой Сундук</a>(<?=$dop['box2']?>)</center></div><span class="nowrap"></span> <span class="nowrap"></span><span class="clearer"></span></td><td width="60"><a href="/bag?open=2<??>&amp;go" class="gr-btn center"><span>Открыть</span></a></td></span></td></tr></table></div></div><? }







if($dop['box1']>0){

?><div class="sblue-panel"><div class="panel-inner-3"><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="37" style="vertical-align: top;"><img width="32"height="32" src="img/ivent/1.png" alt="."border="0"



</td><td><div><a href="/box_info.php?ids=1" class="iSuperior"><center>Серебряный Сундук</a>(<?=$dop['box1']?>)</center></div><span class="nowrap"></span> <span class="nowrap"></span><span class="clearer"></span></td><td width="60"><a href="/bag?open=1<??>&amp;go" class="gr-btn center"><span>Открыть</span></a></td></span></td></tr></table></div></div><? }




















while($row = $sql->fetch_assoc()){

if($row['mag']==1){ $mag =' style="box-shadow: 0px 0px 20px blue; margin: 2px;">';}




elseif($row['mag']==2){ $mag =' style="box-shadow: 0px 0px 20px violet; margin: 2px;">';}




elseif($row['mag']==3){ $mag =' style="box-shadow: 0px 0px 20px gold; margin: 2px;">';}

elseif($row['mag']==4){ $mag =' style="box-shadow: 0px 0px 20px #780A00; margin: 2px;">';}

elseif($row['mag']==0){ $mag ='>';}
if($row['craft']>0){ $fla = '<span class="info">+'.$row['craft'].''; }else{ $fla = '';}  


?><div class="sblue-panel"><div class="panel-inner-3"><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="37" style="vertical-align: top;"><img width="32"height="32" src="img/items/<?=$row['img']?>.png" alt="."border="0" <?=$mag?>


<?


?></td><td><div><a href="/info_art.php?ids=<?=$row['id']?>" class="<?=$row['lite']?>">

    <center><?=$row['nik']?></a><?=$fla?></center></div><span class="nowrap"></span> <span class="nowrap"></span><span class="clearer"></span></td><td width="60">
    
    <?

    ?>
 <a href="bag?id=<?=$row['id']?>&amp;ok" class="gr-btn center"><span>Надеть</span></a></td>  




<? 

?>


<td width="60"><a href="/bag?ids=<?=$row['id']?>&amp;sel" class="gr-btn center"><span>Разбор</span></td></tr></table></div></div><?




if(isset($_GET['sel']) and !empty($_GET['ids'])){


    $_SESSION['idss'] = int($_GET['ids']);


header('location:bag?sell');exit;


}
?></div><?
}
$totalll = $dbc->query("SELECT (id) FROM `artefact` where `user_id` =  '".$user['id']."' and `status` = 1 and `lite` = 'iSuperior'");
$totals= $totalll->num_rows; 


if($totals>0 and $user['level'] >24){


?><a class="btn" href="bag.php?all">Продать Все Редкие Вещи</a><?}



$totallli = $dbc->query("SELECT (id) FROM `artefact` where `user_id` =  '".$user['id']."' and `status` = 1 and `lite` = 'iEpic'");


$totalsi= $totallli->num_rows; 





if($totalsi>0 and $user['level'] >=45){





?><a class="btn" href="bag.php?allep">Продать Все Эпические Вещи</a><?}



?><a class="btn" href="stone_bag.php">Камни</a><?

?><a class="btn" href="bag_scroll.php">Свитки</a><? 








foot();
?>