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

reg();
head('Лавка');
if(isset($_GET['complete'])){


//if($user['ob']>4){ header('location:magaz_red.php');exit;}


if($user['gold']<25){ header('location:magaz_red.php');exit;}



$tes =$dbc->query("SELECT * FROM `uart` WHERE `class`='".$user['pers']."' and `lite`='iSuperior' LIMIT 5");


while($bau=$tes->fetch_assoc()){


$dbc->query("INSERT INTO `artefact` (user_id,status,nik,strong,hp,prot,crit,regen,level,tip,class,lite,coin,img) values('".$user['id']."','".$bau['status']."','".$bau['nik']."','".$bau['strong']."','".$bau['hp']."','".$bau['prot']."','".$bau['crit']."','".$bau['regen']."','".$bau['level']."','".$bau['tip']."','".$bau['class']."','".$bau['lite']."','".$bau['coin']."','".$bau['img']."')");}


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


$_SESSION['message']='Теперь можно одеть эти вещи'; 



header('location:bag');exit;











}


$sql =$dbc->query("SELECT * FROM `uart` WHERE `class`='".$user['pers']."' and `lite`='iSuperior'");



$totall =$dbc->query("SELECT `id` FROM `uart` where `class` ='".$user['pers']."'and `lite`='iSuperior' "); $total=$totall->num_rows;


//?><a class="btn" href="magaz_red.php?complete">Купить весь комплект за 25 золота.</a><?




while($inf=$sql->fetch_assoc()){ if($inf['class']==1){ $class='Воин';}else{$class='Маг';}
if($inf['tip']==1){$tip='Голова';}elseif($inf['tip']==2){$tip='Плечи';}elseif($inf['tip']==3){$tip='Тело';}elseif($inf['tip']==4){$tip='Оружие';}elseif($inf['tip']==5){$tip='Защита';}
?><div class="lblue-panel">
<div class="panel-inner-2">

<div class="el-img">
<span><img src="/img/items/<?=$inf['img']?>.png"></span>
</div>
<div class="margin-from-image">
<div class="el-name c-simple">
<a href="items.php?ids=<?=$inf['id']?>" class="<?=$inf['lite']?>"><?=$inf['nik']?></a>


</div>
<span><?=$tip?> <?=$inf['level']?> ур.,<span><?=$class?></span>


<div class="mt10">
<a href="magaz_red.php?id=<?=$inf['id']?><??>&amp;ok">Купить</a> за  <span class="va-m c-sel"><nobr><img src="img/money/money.png"><?=$inf['coin']?></nobr></span>



</div>
</div>
</div>
</div>

<?
if(isset($_GET['ok']) and !empty($_GET['id'])){
    $buy_item = int($_GET['id']);
$buy = $dbc->query("SELECT * FROM `uart` WHERE `id`='".$buy_item."' LIMIT 1")->fetch_assoc();

if(!$buy){

        header("Location: magaz_red.php");
        exit;
        }        if($buy['class']!=$user['pers']){        header("Location: magaz_red.php");

        exit; }
if($user['gold']<$buy['coin']){  $_SESSION['messege']='У вас не достаточно средст!';      header("Location: magaz_red.php");
        exit; }
$dbc->query("update `users` set `gold`=`gold`-'".$buy['coin']."' where `id`='".$user['id']."'");
$dbc->query("INSERT INTO `artefact` (user_id,status,nik,strong,hp,prot,crit,regen,level,tip,class,lite,coin,img) values('".$user['id']."','".$buy['status']."','".$buy['nik']."','".$buy['strong']."','".$buy['hp']."','".$buy['prot']."','".$buy['crit']."','".$buy['regen']."','".$buy['level']."','".$buy['tip']."','".$buy['class']."','".$buy['lite']."','".$buy['coin']."','".$buy['img']."')");


$_SESSION['message']='Вещь успешно куплена!'; header('Location: magaz_red.php?');exit();



}
}







if($total > $set['str']){			pages($page, $total, 'up?', $set['str']);}
foot();
?>
