

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

head('Кузница');

reg();
$sql = mysql_query("SELECT * FROM `artefact` WHERE `user_id`='".$user['id']."' AND `status` = 1  ");
$total = mysql_num_rows(mysql_query("SELECT `id` FROM `artefact` where `user_id` ='".$user['id']."' AND `status` = 1 "));
if($total==0){
echo '<div class="main"><div class="block_zero center">В Рюкзаке ничего нет</div></div>';
foot();
exit;
}
while($row = mysql_fetch_assoc($sql)){
?><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">


</td><td><div><a href="/info_art.php?ids=<?=$row['id']?>" class="<?=$row['lite']?>"><center><?=$row['nik']?></a></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></tr></table></div></div><?




echo' </div>';
if(isset($_GET['ok']) and !empty($_GET['id'])){
    $pet_id = int($_GET['id']);
$pet = mysql_fetch_assoc(mysql_query("SELECT * FROM `artefact` WHERE `id`='".$pet_id."' AND `user_id`='".$user['id']."' LIMIT 1"));
if(!$pet){
        header("Location: bag");
        exit;
        }
        if($user['level']<$pet['level']){
$_SESSION['err'] = 'Этот Артефакт доступен с '.$pet['name'].' Уровня';
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){ $_SESSION['err'] = 'Сначала снимите то что на вас!';
header('Location: bag?');exit();}
        if($pet['tip']==2 and $user['plesh']==1){ $_SESSION['err'] = 'Сначала снимите то что на вас!';
header('Location: bag?');exit();}
        if($pet['tip']==3 and $user['armor']==1){ $_SESSION['err'] = 'Сначала снимите то что на вас!';header('Location: bag?');exit();}
        if($pet['tip']==4 and $user['weapon']==1){ $_SESSION['err'] = 'Сначала снимите то что на вас!';header('Location: bag?');exit();}
        if($pet['tip']==5 and $user['zashita']==1){ $_SESSION['err'] = 'Сначала снимите то что на вас!';header('Location: bag?');exit();}
        if($pet['tip']==6 and $user['kolco']==1){ $_SESSION['err'] = 'Сначала снимите то что на вас!';header('Location: bag?');exit();}
        
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 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 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 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 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 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 WHERE `id`='".$user['id']."'");}
$dbc->query("UPDATE `artefact` SET `status`=2 WHERE `id`='".$pet_id."'");
$_SESSION['message'] = 'Вы одели '.$pet[nik].'';
header('Location: bag?');exit();
        foot();
}
}
foot();
?> 
