<?php

require_once('conf/dbc.php');
require_once('conf/session_start.php');
require_once('conf/ban.php');
if ((!isset($_SESSION['id'])) or (!isset($_SESSION['nick'])))  {
?>
<script type="text/javascript">
  document.location.href = "reg.php?err_login=1";
</script>
<?php
}
$page_title = 'Торговец ';
require_once('conf/head.php');
require_once('conf/top.php');
$user_id = abs(intval($_SESSION['id']));
  $query = "Select lvl,money, habar from users where id = '$user_id'";
  $result = mysqli_query($dbc, $query) or die ('Ошибка передачи запроса к БД');
  $row = mysqli_fetch_array($result);
  $money = $row['money'];
  $habar = $row['habar'];
  $lvl = $row['lvl'];
$type = abs(intval($_GET['type']));
//Панель заготовок:)

$usid=abs(intval($_SESSION['id']));
$usst=$dbc->query("SELECT * FROM `users` WHERE`id`='$usid' LIMIT 1")->fetch_assoc();

if($usst['admin']==0 or $usst['admin']==3 or $usst['admin']==2 or $usst['admin']==-1 or $usst['admin']==5) {
	
echo '<center><p class="name2">Торговец Борода</p></center>';
echo '<img src="img/ico/boroda.png"/>';
echo '</p><span class="red">Извини, но это место временно не доступно</span>';
require_once('conf/navig.php');
require_once('conf/foot.php');
exit();
}
  if ($type <> 1 and $type <> 2 and $type <> 3 and $type <> 4) {
    if ($lvl >=25) {$type = 3;}
    if ($lvl <25) {$type = 2;}
    if ($lvl <16) {$type = 1;}
  }
?>
<div style="border-left:1px solid #444e4f;border-right:1px solid #444e4f;">
<div id="main">
  <div class="stats">
    <p class="name">Торговец</p>
 </div>
<p class="link">Борода</p>
 
  <div class="stats">
    <p><img src="img/ico/boroda.png"/></p>
    <p class="net"> - Приветствую вас STALKER. Как жизнь на зоне? А вы за артефактами... Смотрите - выбирайте...</p>
  </div>
  <div class="stats"><p>[<a <?php if ($type == 1) {?>class="white"<?php }?> href="sales.php?type=1">Сел</a>] [<a <?php if ($type == 2) {?>class="white"<?php }?> href="sales.php?type=2">Быв</a>] [<a <?php if ($type == 3) {?>class="white"<?php }?> href="sales.php?type=3">Вет</a>] [<a <?php if ($type == 4) {?>class="white"<?php }?> href="sales.php?type=4">Лег</a>]</p>
  </div>
  <?php 
  ?>
  <div class="stats">
    <p>[<img src="img/ico/money.png" width="12" height="12"/> <span class="white"><?php echo "$money"; ?></span>] [<img src="img/ico/materials.png" width="12" height="12"/> <span class="white"><?php echo "$habar"; ?></span>]</p>
 <div class="zx">
	<p class="bonus">Советы:</p>
<p class="clothes"><span class="bonus"><img src="img/ico/money.png" width="12" height="12"/> Нет у тебя RUB ? [<a href="payment.php">пополни счет</a>]</span></p>

   <div class="stats">
  <p class="podmenu"><?php
 
  if ($type == 1) {?><img src="img/ico/class1.png" width="12" height="12"/> Новичок<?php }
  if ($type == 2) {?><img src="img/ico/class2.png" width="12" height="12"/> Бывалый<?php }
  if ($type == 3) {?><img src="img/ico/class3.png" width="12" height="12"/> Ветеран<?php }
  if ($type == 4) {?><img src="img/ico/class4.png" width="12" height="12"/> Легенда<?php }?>
  </p>
  </div>
  </div>
<div class="stats">
<p class="white" style="background-color:#1e2833;"><b>[Артефакты]</b></p>
<?php

	$query_c = "Select name,artefact_id,price, price_hab,lvl_need,screen,klass from artefact where klass = '$type'  order by hp ASC";
$result_c = mysqli_query($dbc, $query_c) or die ('Ошибка передачи запроса к БД');
while ($row_cl=mysqli_fetch_array($result_c)) {?>
	<div class="zx">
	<p class="clothes">
		<?php
		if ($row_cl['klass'] == 1) {?><img src="img/ico/class1.png" width="12" height="12"/><?php }
		if ($row_cl['klass'] == 2) {?><img src="img/ico/class2.png" width="12" height="12"/><?php }
		if ($row_cl['klass'] == 3) {?><img src="img/ico/class3.png" width="12" height="12"/><?php }
		if ($row_cl['klass'] == 4) {?><img src="img/ico/class4.png" width="12" height="12"/><?php }
		?><a class="white" href="sales_thing.php?thing=<?php echo $row_cl['artefact_id'];?>&type=1"><?php echo $row_cl['name'];?></a></p>
<img src="img/artefact/<?php echo $row_cl['screen'];?>" alt="Слот №1" /></td>
<div class="clothes">
<p><span class="white"><?php echo $row_cl['lvl_need'];?></span> ур, новый</p>
<p>Цена:
<?php $pr=0; if ($row_cl['price_hab'] >=0) { $pr=1;?>
[<img src="img/ico/materials.png" width="12" height="12"/>
<span class="white"><?php echo $row_cl['price_hab'];?></span>]<br /><?php }?>
<?php if ($row_cl['price'] >=0) {$pr=1;?>
[<img src="img/ico/money.png" width="12" height="12"/>
<span class="white"><?php echo $row_cl['price'];?></span>]<?php }?>
<?php 
if ($pr==0) {?>[не продаётся]<?php }?></p>
</div>
</div>
	<?php
	}
    ?>
	</div>	
</div>
<?php
require_once('conf/navig.php');
require_once('conf/foot.php');
mysqli_close($dbc);
?>

</body>
</html>