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

head('Артефакты');
reg();
$stone = int($_SESSION['stone']);
$ston = $dbc->query("SELECT * FROM `stone_bag` WHERE `id`='".$stone."' LIMIT 1")->fetch_assoc();

$sql = $dbc->query("SELECT * FROM `artefact` WHERE `user_id`='".$user['id']."' AND `status` = 2 ORDER by `art_id` ");
$total = $dbc->query("SELECT `id` FROM `artefact` where `user_id` ='".$user['id']."' AND `status` = 2 "); $total = $total->num_rows;

if($total==0){
echo '<div class="main"><div class="block_zero center">Нет подходящих вещей</div></div>';

    foot();
    exit;
}

if($ston['status'] == 2){ header('location:index.php');exit;}

if($ston['user_id'] != $user['id']){ header('location:index.php');exit;}
if(!$ston){ header('location:index.php');exit;}

?><div class="lblue-panel"><div class="panel-inner">

Вы выбрали камень<table style="border-spacing: 0
0; width:100%; border-collapse:
collapse; table-layout: fixed;
display: table;"><tbody><tr><td style="width:38px; vertical-align:top;text-align:left; padding-
top:4px; padding-bottom:2px;">
<img width="32"height="32" src="
img/stone/<?=$ston['img']?>.png" alt="."

border="0"></a>
</td><td valign="top" style="padding-bottom:3px;"><div><span
class="<?=$ston['lite']?>">


<?=$ston['name']?></span></div><div class="minor"></span> <span

class=""><span

class=""></span><br></div></td></tr></tbody></table></div><div class="panel-inner"><div><span><div><img src="img/stat/AKulak.png
" alt="." width="12" height="12">
Сила: <strong class=""><?=$ston['strong']?></strong>



</div>
<div>
<img src="

img/stat/hp.png" alt="."

width="12" height="12">
Живучесть: <strong
class=""><?=$ston['hp']?></strong>
</div>
<div>
<img src="

images/icons/armor.png" alt="."
width="12" height="12">
Защита: <strong class=""><?=$ston['prot']?></strong>

</div>
</span>
<div>
</div></div></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 = '';} 

if($row['up']>0){ $flas = '<span class="info">*'.$row['up'].''; }else{ $flas = '';} 

?><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?><?=$flas?></center></div><span class="nowrap"></span> <span class="nowrap"></span><span class="clearer"></span></td><td width="60"><a href="/stone_in.php?id=<?=$row['id']?><??>&amp;st" class="gr-btn center"><span>Вставить</span></a></td></tr></table></div></div><?













echo' </div>';
if(isset($_GET['st']) 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: stone_in.php");

        exit;
        }
        if($pet['status']==1){
        header("Location: stone_in.php");

        exit;
        }


if($pet['stone']>=3){ header('location:stone_in.php');exit;}





$dbc->query("UPDATE `users` SET `strength`=`strength`+'".$ston['strong']."',`max_health`=`max_health`+'".$ston['hp']."',`defense`=`defense`+'".$ston['prot']."' WHERE `id`='".$user['id']."'"); 






$dbc->query("UPDATE `artefact` SET `strong`=`strong`+'".$ston['strong']."',`hp`=`hp`+'".$ston['hp']."',`prot`=`prot`+'".$ston['prot']."' WHERE `id`='".$pet_id."'"); 












        
    $dbc->query("UPDATE `stone_bag` SET `status`=2 ,`id_item`='".$pet_id."' WHERE `id`='".$ston['id']."'");


$dbc->query("UPDATE `artefact` SET `stone`=`stone`+1 WHERE `id`='".$pet_id."'");



$_SESSION['message'] = 'Вы вставили камень в '.$pet[nik].'';

header('Location: info_art.php?ids='.$pet_id.'');exit();

        foot();
}
}
foot();
?> 
