<?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');
$type = abs(intval($_GET['type']));
$thing_id = abs(intval($_GET['thing']));
if (empty($thing_id) or empty($type)) {
  ?>
  <script type="text/javascript">
  document.location.href = "syslov.php?mod=snr";
  </script>
  <?php
  exit();
}
if ($type <> 1 and $type <> 2 and $type <> 3 and $type <> 4) {
  ?>
  <script type="text/javascript">
  document.location.href = "syslov.php?mod=snr";
  </script>
  <?php
  exit();
}
if ($type == 1) {
  $query_c = "Select * from clothes where clothes_id = '$thing_id' limit 1";
  $result_c = mysqli_query($dbc, $query_c) or die ('Ошибка передачи запроса к БД');
  $row_cl = mysqli_fetch_array($result_c);
}
if ($type == 2) {
  $query_c = "Select * from pistols where pistols_id = '$thing_id' limit 1";
  $result_c = mysqli_query($dbc, $query_c) or die ('Ошибка передачи запроса к БД');
  $row_cl = mysqli_fetch_array($result_c);
}
if ($type == 3) {
  $query_c = "Select * from weapons where weapons_id = '$thing_id' limit 1";
  $result_c = mysqli_query($dbc, $query_c) or die ('Ошибка передачи запроса к БД');
  $row_cl = mysqli_fetch_array($result_c);
}
if ($type == 4) {
  $query_c = "Select * from shlem where shlem_id = '$thing_id' limit 1";
  $result_c = mysqli_query($dbc, $query_c) or die ('Ошибка передачи запроса к БД');
  $row_cl = mysqli_fetch_array($result_c);
}
if ($row_cl == 0) {
  ?>
  <script type="text/javascript">
  document.location.href = "syslov.php?mod=snr";
  </script>
  <?php
  exit();
}
?><br/>
<div id="main">
  <div class="stats">
    <p class="podmenu">Товар</p>
  </div>
  <div class="stats">
    <p><center><img src="img/ico/left.png" /> <a href="syslov.php?mod=snr">Назад к Лами</a></center></p>
  </div>
  <?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'];
  ?>
  <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>
  <?php
$err = abs(intval($_GET['err']));
  if (!empty($err)) {?>
  <div id="error">
  <?php if ($err == 1) {echo 'У вас недостаточно средств';}?>
  </div>
  <?php
  }
  if ($row['lvl'] < $row_cl['lvl_need']) {
  ?>
  <div id="error">
  <p>Если вы купите эту вещь - вы не сможете её одеть пока не достигните <?php echo $row_cl['lvl_need'];?> уровня или выше</p>
  </div>
  <?php
  }
  ?>
  <div class="stats">
  <?php
  if ($type == 1) {
  ?>
 <table width="190" border="0" cellpadding="0" cellspacing="0">
      <tbody>
      <tr>
         <td width="54" valign="top"><img src="img/clothes/<?php echo $row_cl['screen'];?>" width="80" height="100"/></td>
      <td width="136" valign="top">
  </div>
	  </td>
      </tr>
      </tbody>
      </table>
	  <div class="clothes">
		<p><?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 }
		?><span class="white"><?php echo $row_cl['name'];?></span>(
        <span class="bonus"><?php echo $row_cl['lvl_need'];?> ур,</span> новый)</p>
		<p><img src="img/ico/shield.png" alt="н" width="12" height="12"/>Броня: <span class="white"><?php echo $row_cl['max_stats_bronya'] .'-'. $row_cl['min_stats_bronya'];?></span> </p>
        <p><img src="img/ico/life.png" alt="н" width="12" height="12"/>Здоровье: <span class="white"><?php echo $row_cl['max_stats_hp'] .'-'. $row_cl['min_stats_hp'];?></span> </p>
    
	
	  <p><img src="img/ico/shield.png" alt="н" width="12" height="12"/>Прочность: <span class="white"><?php echo $row_cl['max_stats_razriv'] .'-'. $row_cl['min_stats_razriv'];?></span></p>
	  <p><img src="img/ico/goodrad.png" alt="н" width="12" height="12"/>Яд защита: <span class="white"><?php echo $row_cl['max_stats_rad'] .'-'. $row_cl['min_stats_rad'];?></span> </p>
	  <p>- - - - - - - - - - - -</p>
	  <p>Состояние:  <span class="white">8/8</span></p>
	  </div>
	  <div class="zx"><?php if ($row_cl['price_hab'] >=0) {
	  ?>[<a href="buy_thing.php?thing=<?php echo "$thing_id";?>&type=1&money=1">Купить за <img src="img/ico/materials.png" width="12" height="12"/> <span class="white"><?php echo $row_cl['price_hab'];?></span></a>] <br /><?php }  else {?><p class="clothes"><span class="bonus">[Mожно получить на <a href="monsters.php">Сарум</a> или приобрести на <a href="auction.php">Странника</a>]</span></p>
	  <?php }
	  if ($row_cl['price'] >=0) {
	  ?>[<a href="buy_thing.php?thing=<?php echo "$thing_id";?>&type=1&money=2">Купить за <img src="img/ico/money.png" width="12" height="12"/> <span class="white"><?php echo $row_cl['price'];?></span></a>]<?php }
	  ?></p>
	  </div>
	  <?php
  }
  if ($type == 2) {
  ?>
  <table width="190" border="0" cellpadding="0" cellspacing="0">
      <tbody>
      <tr>
     <td width="54" valign="top"><img src="img/weapons/<?php echo $row_cl['screen'];?>" alt="Слот №1" /></td>
      <td width="136" valign="top">
  </div>
	  </td>
      </tr>
      </tbody>
      </table>
	  <div class="clothes">
	    <p><?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 }
		?><span class="white"><?php echo $row_cl['name'];?></span>
        (<span class="bonus"><?php echo $row_cl['lvl_need'];?> ур,</span> новый)</p>
		<p><img src="img/ico/to4nost.png" alt="н"/>Урон: <span class="white"><?php echo $row_cl['max_stats_yron'] .'-'. $row_cl['min_stats_yron'];?></span> </p>
        <p><img src="img/ico/to4nost.png" alt="н"/>Точность: <span class="white"><?php echo $row_cl['max_stats_tochn'] .'-'. $row_cl['min_stats_tochn'];?></span> </p>
   
	  <p><img src="img/ico/to4nost.png" alt="н"/>Надёжность: <span class="white"><?php echo $row_cl['max_stats_safety'] .'-'. $row_cl['min_stats_safety'];?></span></p>
	  <p><img src="img/ico/speed.png" alt="н"/>Скорость атаки: <span class="white"><?php echo $row_cl['speed'];?> сек</span> </p>
	  <p>- - - - - - - - - - - -</p>
	  <p>Состояние:  <span class="white">8/8</span></p>
	  </div>
	  <div class="zx"><?php if ($row_cl['price_hab'] >=0) {
	  ?>[<a href="buy_thing.php?thing=<?php echo "$thing_id";?>&type=2&money=1">Купить за <img src="img/ico/materials.png" width="12" height="12"/> <span class="white"><?php echo $row_cl['price_hab'] %50;?></span></a>] <br /><?php }    else {?><p class="clothes"><span class="bonus">[Mожно получить на <a href="monsters.php">Сарум</a>  или приобрести на <a href="auction.php">Странника</a>]</span></p>
	  <?php }
	  if ($row_cl['price'] >=0) {
	  ?>[<a href="buy_thing.php?thing=<?php echo "$thing_id";?>&type=2&money=2">Купить за <img src="img/ico/money.png" width="12" height="12"/> <span class="white"><?php echo $row_cl['price'];?></span></a>]<?php }
	  ?></p>
	  </div>
	  <?php
  }
  if ($type == 3) {
  ?>
  <img src="img/weapons/<?php echo $row_cl['screen'];?>" alt="Слот №1" />
	  <div class="clothes">
	    <p>
		<?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 }
		?><span class="white"><?php echo $row_cl['name'];?></span>
        (<span class="bonus"><?php echo $row_cl['lvl_need'];?>ур, </span> новый)</p>
		<p><img src="img/ico/to4nost.png" alt="н"/>Урон: <span class="white"><?php echo $row_cl['max_stats_yron'] .'-'. $row_cl['min_stats_yron'];?></span> </p>
        <p><img src="img/ico/to4nost.png" alt="н"/>Точность: <span class="white"><?php echo $row_cl['max_stats_tochn'] .'-'. $row_cl['min_stats_tochn'];?></span> </p>
      </div>
	  <div class="clothes">
	  <p><img src="img/ico/to4nost.png" alt="н"/>Надёжность: <span class="white"><?php echo $row_cl['max_stats_safety'] .'-'. $row_cl['min_stats_safety'];?></span></p>
	  <p><img src="img/ico/speed.png" alt="н"/>Скорость атаки: <span class="white"><?php echo $row_cl['speed'];?> сек</span> </p>
	  <p>- - - - - - - - - - - -</p>
	  <p>Состояние:  <span class="white">8/8</span></p>
	  </div>
    <div class="zx"><?php if ($row_cl['price_hab'] >=0) {
	  ?>[<a href="buy_thing.php?thing=<?php echo "$thing_id";?>&type=3&money=1">Купить за <img src="img/ico/materials.png" width="12" height="12"/> <span class="white"><?php echo $row_cl['price_hab'];?></span></a>] <br /><?php }    else {?><p class="clothes"><span class="bonus">[Mожно получить на <a href="monsters.php">Сарум</a>  или приобрести на <a href="auction.php">Странника</a>]</span></p>
    <?php }
	  if ($row_cl['price'] >=0) {
	  ?>[<a href="buy_thing.php?thing=<?php echo "$thing_id";?>&type=3&money=2">Купить за <img src="img/ico/money.png" width="12" height="12"/> <span class="white"><?php echo $row_cl['price'];?></span></a>]<?php }
	  ?></p>
    </div>
	  <?php
}
   if ($type == 4) {
  ?>
 <table width="190" border="0" cellpadding="0" cellspacing="0">
      <tbody>
      <tr>
         <td width="54" valign="top"><img src="img/shlem/<?php echo $row_cl['screen'];?>" width="55" height="55"/></td>
      <td width="136" valign="top">
  </div>
	  </td>
      </tr>
      </tbody>
      </table>
	  <div class="clothes">
		<p><?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 }
		?><span class="white"><?php echo $row_cl['name'];?></span>(
        <span class="bonus"><?php echo $row_cl['lvl_need'];?> ур,</span> новый)</p>
		<p><img src="img/ico/shield.png" alt="н" width="12" height="12"/>Броня: <span class="white"><?php echo $row_cl['max_stats_bronya'] .'-'. $row_cl['min_stats_bronya'];?></span> </p>
        <p><img src="img/ico/life.png" alt="н" width="12" height="12"/>Здоровье: <span class="white"><?php echo $row_cl['max_stats_hp'] .'-'. $row_cl['min_stats_hp'];?></span> </p>
    
	 <p><img src="img/ico/shield.png" alt="н" width="12" height="12"/>Прочность: <span class="white"><?php echo $row_cl['max_stats_razriv'] .'-'. $row_cl['min_stats_razriv'];?></span></p>
	  <p><img src="img/ico/goodrad.png" alt="н" width="12" height="12"/>Яд защита: <span class="white"><?php echo $row_cl['max_stats_rad'] .'-'. $row_cl['min_stats_rad'];?></span> </p>
	  <p>- - - - - - - - - - - -</p>
	  <p>Состояние:  <span class="white">8/8</span></p>
	  </div>
	 
	  <div class="zx"><?php if ($row_cl['price_hab'] >=0) {
	  ?>[<a href="buy_thing.php?thing=<?php echo "$thing_id";?>&type=4&money=1">Купить за <img src="img/ico/materials.png" width="12" height="12"/> <span class="white"><?php echo $row_cl['price_hab'];?></span></a>] <br /><?php }  else {?><p class="clothes"><span class="bonus">[Mожно получить на <a href="monsters.php">Сарум</a> или приобрести на <a href="auction.php">Странника</a>]</span></p>
	  <?php }
	  if ($row_cl['price'] >=0) {
	  ?>[<a href="buy_thing.php?thing=<?php echo "$thing_id";?>&type=4&money=2">Купить за <img src="img/ico/money.png" width="12" height="12"/> <span class="white"><?php echo $row_cl['price'];?></span></a>]<?php }
	  ?></p>
	  </div>
	  <?php
  }
  ?>
</div>
<div class="stats">
<p class="bonus" style="font-size:13px;">Вся статистика представлена в виде (max-min) и может выпасть только в этом интервале.</p>
</div>
</div>
<?php
require_once('conf/navig.php');
require_once('conf/foot.php');
mysqli_close($dbc);
?>

</body>
</html>