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

head('Сердце Тьмы');
reg();
$sql = $dbc->query("SELECT * FROM `art_pet` WHERE `user_id`='".$user['id']."' AND `status` = 2 ORDER by `art_id` ");

$total = $dbc->query("SELECT `id` FROM `art_pet` 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;
}
while($row = $sql->fetch_assoc()){
if($row['craft']>0){ $fla = '<span class="info">+'.$row['craft'].''; }else{ $fla = '';}





$sia = $row['craft']+1;

$limit  = 200;


$po  = 50;

$last  = 250*$sia; 

if($last>=700000){ $last   = 700000;}



 

































?><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/item_pet/<?=$row['img']?>.png" alt="."border="0"></td><td><div><a href="/info_it.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><?





if($row['craft']<$limit){
?><td width="40"><a href="/craft_pet.php?id=<?=$row['id']?><??>&amp;craft" class="gr-btn center"><span>Заточить за <img src="img/money/rubin.png"><?=$last?> </span></a></td><? 







}      ?></tr></table></div></div><?









echo' </div>';
if(isset($_GET['craft']) and !empty($_GET['id'])){

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



if(!$pet){
        header("Location: craft_pet.php");


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


        exit;
        }
$sia = $pet['craft']+1;


$limit  = 200;



$last = 250*$sia;



if($last>=700000){ $last   = 700000;}

































if($user['rub']<$last){ $_SESSION['message']='не достаточно Рубинов'; header('location: craft_pet.php');exit; 




}if($pet['craft']>=$limit){ header('location: craft_pet.php');exit; }







$dbc->query("UPDATE `user_pets` SET `str`=`str`+1,`vit`=`vit`+5,`def`=`def`+1 WHERE `id_user`='".$user['id']."'");



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






        
$dbc->query("UPDATE `art_pet` SET `strong`=`strong`+1,`hp`=`hp`+5,`prot`=`prot`+1, `craft`=`craft`+1 WHERE `id`='".$pet['id']."'");











        







        




$_SESSION['message'] = 'Заточка + 1 на '.$pet[nik].'';

header('Location: craft_pet.php?');exit();


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