<?php

require_once('conf/dbc.php');
require_once('conf/session_start.php');
require_once('conf/ban.php');
$page_title = 'Вещь';
require_once('conf/head.php');
if ((isset($_SESSION['id'])) or (isset($_SESSION['nick'])))  {
  require_once('conf/top.php');
}
$thing= abs(intval($_GET['thing']));
$user_id = abs(intval($_SESSION['id']));
if (empty($thing)) {
  ?>
  <script type="text/javascript">
  document.location.href = "thingnotfound.php";
  </script>
  <?php
  exit();
}
$query = "Select * from things where thing_id='$thing' limit 1";
$result = mysqli_query($dbc, $query) or die ('Ошибка передачи запроса к БД2');
$total = mysqli_num_rows($result);
if ($total == 0) {
  ?>
  <script type="text/javascript">
  document.location.href = "thingnotfound.php";
  </script>
  <?php
  exit();
}
$row=mysqli_fetch_array($result);
$user_set = $row['user_id'];
$query_user = "Select nick,last_active,gruppa from users where id='$user_set' limit 1";
$result_user = mysqli_query($dbc, $query_user) or die ('Ошибка передачи запроса к БД2');
$row_user=mysqli_fetch_array($result_user);
$inf_cl = $row['inf_id'];
$type = $row['type'];
$last_active = $row_user['last_active'];
$last_active = strtotime("$last_active");
$now = (date("Y-m-d H:i:s"));
$now = strtotime("$now");
$razn_last_act = ($now - $last_active);
if ($type == 1) {
  $query_inf = "Select name,screen,klass,price from clothes where clothes_id = '$inf_cl' limit 1";
  $result_inf = mysqli_query($dbc, $query_inf) or die ('Ошибка передачи запроса к БД');
  $row_inf = mysqli_fetch_array($result_inf);
}//Название брони
if ($type == 2) {
  $query_inf = "Select name,screen,klass,price from pistols where pistols_id = '$inf_cl' limit 1";
  $result_inf = mysqli_query($dbc, $query_inf) or die ('Ошибка передачи запроса к БД');
  $row_inf = mysqli_fetch_array($result_inf);
}//Название Пистолета
if ($type== 3) {
  $query_inf = "Select name,screen,klass,price from weapons where weapons_id = '$inf_cl' limit 1";
  $result_inf = mysqli_query($dbc, $query_inf) or die ('Ошибка передачи запроса к БД');
  $row_inf = mysqli_fetch_array($result_inf);
}//Название оружия
if ($type == 4) {
  $query_inf = "Select name,screen,klass,price from shlem where shlem_id = '$inf_cl' limit 1";
  $result_inf = mysqli_query($dbc, $query_inf) or die ('Ошибка передачи запроса к БД');
  $row_inf = mysqli_fetch_array($result_inf);
}//Название шлема
?>
<div id="main">
<div class="stats">
<p class="podmenu"><?php echo $row_inf['name'];?></p>
</div>
<?php
///////////////////\
$err=abs(intval($_GET['err']));
if ($row['place']<>2 and $user_set == $user_id and !empty($_GET['lot']) and $row['place']<>3) {
if (!empty($_POST['send'])) {

if ($row_inf['price'] < 0 and $row_inf['klass']==1) {
  $price1 = 2000;
}
else {
  $price1 = $row_inf['price'];
}
if ($row_inf['price'] < 0 and $row_inf['klass']==2) {
  $price1 = 2000;
}
else {
  $price1 = $row_inf['price'];
}
if ($row_inf['price'] < 0 and $row_inf['klass']==3) {
  $price1 = 2000;
}
else {
  $price1 = $row_inf['price'];
}
if ($row_inf['price'] < 0 and $row_inf['klass']==4) {
  $price1 = 3500;
}
else {
  $price1 = $row_inf['price'];
}

$price_now= filter($_POST['price_now']);
$price= filter($_POST['price']);
  $sgn = '#[1-9]#';
  if ($price_now>=$price) { $err=5;}
  if ($price_now<=20) { $err = 6; }
  if ($price<=20) {$err = 7; }
  if ($price1 > $price_now) { $err=11;}
  if (!preg_match($sgn, $price)) { $err=8; }
  if (!preg_match($sgn, $price_now)) { $err=8; }
$user_id=abs(intval($_SESSION['id']));
  $query_isset = "Select money from users where id='$user_id' limit 1";
  $result_isset = mysqli_query($dbc, $query_isset) or die ('Ошибка передачи запроса к БД');
  $row_isset = mysqli_fetch_array($result_isset);
  if ($row_isset['money'] < 5) {$err=9; }
  if ($err == 0) {
    $query_isset = "update users set money=money-5 where id='$user_id' limit 1";
    $result_isset = mysqli_query($dbc, $query_isset) or die ('Ошибка передачи запроса к БД');
	$query_isset = "update things set place=3 where thing_id='$thing' limit 1";
    $result_isset = mysqli_query($dbc, $query_isset) or die ('Ошибка передачи запроса к БД');
	$query_isset = "insert into auction (`thing_id`, `type`, `date`, `price`, `price_now`, `price_user`) values ('$thing', '$type', NOW(), '$price', '$price_now', '0')";
    $result_isset = mysqli_query($dbc, $query_isset) or die ('Ошибка передачи запроса к БД');
    ?>
	<div class="stats">
    <p><img src="img/ico/shield.png" width="12" height="12"/> <a href="clothes.php?id=<?php echo "$user_id";?>">Моё снаряжение</a></p>
    </div>
	<div class="stats"><p class="bonus">Эта вещь успешно выставлена на аукцион</p></div><?php
	require_once('conf/navig.php');
    require_once('conf/foot.php');
	exit();
  }
}
}
//////////////////
?>
<div class="stats">
<p><img src="img/ico/shield.png" width="12" height="12"/> <a href="clothes.php?id=<?php echo "$user_id";?>">Моё снаряжение</a></p>
</div>
<?php
if (!empty($err)) {
?>
<div id="error">
<?php
if ($err == 1) {echo 'Снаряжение и так целое';}
if ($err == 2) {echo 'Недостаточно хабара для ремонта';}
if ($err == 3) {echo '<p class="bonus">Снаряжение удачно отремонтировано</span>';}
if ($err == 4) { ?><span class="bonus"><?php echo 'Вы успешно приобрели эту вещь';?></span><?php }
if ($err == 5) { echo 'Стартовая цена должна быть меньше выкупа'; }
if ($err == 6) { echo 'Стартовая цена должна быть больше 20'; }
if ($err == 7) { echo 'Выкуп должен быть больше 20'; }
if ($err == 8) { echo 'Введите число'; }
if ($err == 9) { echo 'Недостаточно средств'; }
if ($err == 10) { echo 'Стартовая цена должна быть меньше выкупа'; }
if ($err == 11) { echo 'Ставка на данный лот должна быть не менее' . " $price1 RUB"; }
?>
</div>
<?php
}
?>
<div class="slot">
<?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_inf['screen'];?>" alt="Слот №1" width="80" height="100"/></td>
      <td width="136" valign="top">
  </div>
	  </td>
      </tr>
      </tbody>
      </table>
	  <div class="clothes">

	    <p><?php
		if ($row_inf['klass'] == 1) {?><img src="img/ico/class1.png" width="12" height="12"/><?php }
		if ($row_inf['klass'] == 2) {?><img src="img/ico/class2.png" width="12" height="12"/><?php }
		if ($row_inf['klass'] == 3) {?><img src="img/ico/class3.png" width="12" height="12"/><?php }
		if ($row_inf['klass'] == 4) {?><img src="img/ico/class4.png" width="12" height="12"/><?php }
		?><span class="white"><?php echo $row_inf['name']; ?></span>(
		<span class="bonus"><?php echo $row['need_lvl'];?> ур,</span><?php if ($row['privat'] == 0) { echo " новый";}
	if ($row['privat'] == 1) { echo " личный";}?>)</p>
        <p><img src="img/ico/shield.png" alt="н" width="12" height="12"/><?php
		if ($row['upgrade_stat2'] == 1) {?><span class="bonus">(<img src="img/ico/class1.png" width="12" height="12"/>+15%)</span><?php }
		if ($row['upgrade_stat2'] == 2) {?><span class="bonus">(<img src="img/ico/class2.png" width="12" height="12"/>+25%)</span><?php }
		if ($row['upgrade_stat2'] == 3) {?><span class="bonus">(<img src="img/ico/class3.png" width="12" height="12"/>+50%)</span><?php }
		if ($row['upgrade_stat2'] >= 4) {?><span class="bonus">(<img src="img/ico/class4.png" width="12" height="12"/>+75%)</span><?php }
		?> Броня: <span class="white"><?php echo $row['stat2'];?></span></p>
        <p> <img src="img/ico/life.png" alt="н" width="12" height="12"/><?php
		if ($row['upgrade_stat1'] == 1) {?><span class="bonus">(<img src="img/ico/class1.png" width="12" height="12"/>+15%)</span><?php }
		if ($row['upgrade_stat1'] == 2) {?><span class="bonus">(<img src="img/ico/class2.png" width="12" height="12"/>+25%)</span><?php }
		if ($row['upgrade_stat1'] == 3) {?><span class="bonus">(<img src="img/ico/class3.png" width="12" height="12"/>+50%)</span><?php }
		if ($row['upgrade_stat1'] >= 4) {?><span class="bonus">(<img src="img/ico/class4.png" width="12" height="12"/>+75%)</span><?php }
		?>Здоровье: <span class="white"><?php echo $row['stat1'];?></span></p>
      
	  <p><img src="img/ico/shield.png" alt="н" width="12" height="12"/><?php
		if ($row['upgrade_stat3'] == 1) {?><span class="bonus">(<img src="img/ico/class1.png" width="12" height="12"/>+15%)</span><?php }
		if ($row['upgrade_stat3'] == 2) {?><span class="bonus">(<img src="img/ico/class2.png" width="12" height="12"/>+25%)</span><?php }
		if ($row['upgrade_stat3'] == 3) {?><span class="bonus">(<img src="img/ico/class3.png" width="12" height="12"/>+50%)</span><?php }
		if ($row['upgrade_stat3'] >= 4) {?><span class="bonus">(<img src="img/ico/class4.png" width="12" height="12"/>+75%)</span><?php }
		?> Прочность: <span class="white"><?php echo $row['stat3'];?></span></p>
	  <p><img src="img/ico/goodrad.png" alt="н"/><?php
		if ($row['upgrade_speed'] == 1) {?><span class="bonus">(<img src="img/ico/class1.png" width="12" height="12"/>+15%)</span><?php }
		if ($row['upgrade_speed'] == 2) {?><span class="bonus">(<img src="img/ico/class2.png" width="12" height="12"/>+25%)</span><?php }
		if ($row['upgrade_speed'] == 3) {?><span class="bonus">(<img src="img/ico/class3.png" width="12" height="12"/>+50%)</span><?php }
		if ($row['upgrade_speed'] >= 4) {?><span class="bonus">(<img src="img/ico/class4.png" width="12" height="12"/>+75%)</span><?php }
		?> Рад.защита: <span class="white"><?php echo $row['speed'];?></span></p>
	  </div>
	  <div class="zx">
	<div class="clothes">
      <p>Состояние: <span class="white"><?php echo $row['sost'];?>/8</span></p>
	  </div>
	  <p><img src="img/ico/profile.png" alt="н"/>Владелец: <span class="white">
	  <?php 
  if ($row_user['gruppa'] == 'svoboda') {if ($razn_last_act < 300 ) {?><img src="img/ico/on.png" width="12" height="12" alt="н"/><img src="img/ico/svobodaon.png" width="12" height="12" alt="н"/><?php } else {?><img src="img/ico/off.png" width="12" height="12" alt="н"/><img src="img/ico/svobodaon.png" width="12" height="12" alt="н"/><?php }}
	  if ($row_user['gruppa'] == 'dolg') {if ($razn_last_act < 300 ) {?><img src="img/ico/on.png" width="12" height="12" alt="н"/><img src="img/ico/dolgon.png" width="12" height="12" alt="н"/><?php } else {?><img src="img/ico/off.png" width="12" height="12" alt="н"/><img src="img/ico/dolgon.png" width="12" height="12" alt="н"/><?php }}
	  if ($row_user['gruppa'] == 'naemniki') {if ($razn_last_act < 300 ) {?><img src="img/ico/on.png" width="12" height="12" alt="н"/><img src="img/ico/naemniki.png" width="12" height="12" alt="н"/><?php } else {?><img src="img/ico/off.png" width="12" height="12" alt="н"/><img src="img/ico/naemniki.png" width="12" height="12" alt="н"/><?php }}
          if ($row_user['gruppa'] == 'renegat') {if ($razn_last_act < 300 ) {?><img src="img/ico/on.png" width="12" height="12" alt="н"/><img src="img/ico/renegat.png" width="12" height="12" alt="н"/><?php } else {?><img src="img/ico/off.png" width="12" height="12" alt="н"/><img src="img/ico/renegat.png" width="12" height="12" alt="н"/><?php }}
	  if ($row_user['gruppa'] == 'chistoenebo') {if ($razn_last_act < 300 ) {?><img src="img/ico/on.png" width="12" height="12" alt="н"/><img src="img/ico/chistoenebo.png" width="12" height="12" alt="н"/><?php } else {?><img src="img/ico/off.png" width="12" height="12" alt="н"/><img src="img/ico/chistoenebo.png" width="12" height="12" alt="н"/><?php }}?>
	  <a  class="white" href="user.php?id=<?php echo "$user_set"?>"><?php echo $row_user['nick'];?></a></span></p>
	  </div>
<?php
/////////////////////Если это моя шмотка
  if ($user_set == $user_id) {
  ?><div class="zx"><?php
	 if ($row['sost'] == 0) {?><p><a href="fix.php?thing=<?php echo "$thing";?>">Починить за <img src="img/ico/materials.png" width="12" height="12"/>1000</a></p>
	  <?php }
	   if ($row['sost'] == 1) {?><p><a href="fix.php?thing=<?php echo "$thing";?>">Починить за <img src="img/ico/materials.png" width="12" height="12"/>800</a></p><?php }  
	   if ($row['sost'] == 2) {?><p><a href="fix.php?thing=<?php echo "$thing";?>">Починить за <img src="img/ico/materials.png" width="12" height="12"/>180</a></p><?php } 
	   if ($row['sost'] == 3) {?><p><a href="fix.php?thing=<?php echo "$thing";?>">Починить за <img src="img/ico/materials.png" width="12" height="12"/>150</a></p><?php } 
	   if ($row['sost']== 4) {?><p><a href="fix.php?thing=<?php echo "$thing";?>">Починить за <img src="img/ico/materials.png" width="12" height="12"/>120</a></p><?php } 
	   if ($row['sost'] == 5) {?><p><a href="fix.php?thing=<?php echo "$thing";?>">Починить за <img src="img/ico/materials.png" width="12" height="12"/>90</a></p><?php }
	   if ($row['sost'] == 6) {?><p><a href="fix.php?thing=<?php echo "$thing";?>">Починить за <img src="img/ico/materials.png" width="12" height="12"/>60</a></p><?php }  
	   if ($row['sost']== 7) {?><p><a href="fix.php?thing=<?php echo "$thing";?>">Починить за <img src="img/ico/materials.png" width="12" height="12"/>30</a></p><?php }
	  ?>
	  <p><img src="img/ico/upgrade.png" width="12" height="12"/><a href="upgrade.php?thing=<?php echo "$thing";?>">Улучшить у мастера</a></p>
	  <?php if ($row['privat'] < 2) {?>
	  <p><img src="img/ico/point.png" width="12" height="12"/><a href="thing.php?thing=<?php echo "$thing";?>&lot=1">Выставить на аукцион</a></p>
	  <?php }?>
	  </div>
	  </div>
	<?php
  } else {
  ?><p><img src="img/ico/upgrade.png" width="12" height="12"/><a href="upgrade.php?thing=<?php echo "$thing";?>">Список улучшений</a></p><?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_inf['screen'];?>" alt="Слот №1" /></td>
      <td width="136" valign="top">
  </div>
	  </td>
      </tr>
      </tbody>
      </table>
	  <div class="clothes">
	    <p><?php
		if ($row_inf['klass'] == 1) {?><img src="img/ico/class1.png" width="12" height="12"/><?php }
		if ($row_inf['klass'] == 2) {?><img src="img/ico/class2.png" width="12" height="12"/><?php }
		if ($row_inf['klass'] == 3) {?><img src="img/ico/class3.png" width="12" height="12"/><?php }
		if ($row_inf['klass'] == 4) {?><img src="img/ico/class4.png" width="12" height="12"/><?php }
		?><span class="white"><?php echo $row_inf['name']; ?></span> (<span class="bonus"><?php echo $row['need_lvl'];?> ур,</span><?php if ($row['privat'] == 0) { echo " новый";}
	if ($row['privat'] == 1) { echo " личный";}?>)</p>
        <p> <img src="img/ico/to4nost.png" alt="н"/><?php

		if ($row['upgrade_stat1'] == 1) {?><span class="bonus">(<img src="img/ico/class1.png" width="12" height="12"/>+15%)</span><?php }
		if ($row['upgrade_stat1'] == 2) {?><span class="bonus">(<img src="img/ico/class2.png" width="12" height="12"/>+25%)</span><?php }
		if ($row['upgrade_stat1'] == 3) {?><span class="bonus">(<img src="img/ico/class3.png" width="12" height="12"/>+50%)</span><?php }
		if ($row['upgrade_stat1'] >= 4) {?><span class="bonus">(<img src="img/ico/class4.png" width="12" height="12"/>+75%)</span><?php }
		?>Урон: <span class="white"><?php echo $row['stat1'];?></span></p>
        <p><img src="img/ico/to4nost.png" alt="н"/><?php
		if ($row['upgrade_stat2'] == 1) {?><span class="bonus">(<img src="img/ico/class1.png" width="12" height="12"/>+15%)</span><?php }
		if ($row['upgrade_stat2'] == 2) {?><span class="bonus">(<img src="img/ico/class2.png" width="12" height="12"/>+25%)</span><?php }
		if ($row['upgrade_stat2'] == 3) {?><span class="bonus">(<img src="img/ico/class3.png" width="12" height="12"/>+50%)</span><?php }
		if ($row['upgrade_stat2'] >= 4) {?><span class="bonus">(<img src="img/ico/class4.png" width="12" height="12"/>+75%)</span><?php }
		?> Точность: <span class="white"><?php echo $row['stat2'];?></span></p>
      </div>
	  </td>
      </tr>
      </tbody>
      </table>
	  <div class="clothes">
	  		<p><img src="img/ico/to4nost.png" alt="н"/><?php
		if ($row['upgrade_stat3'] == 1) {?><span class="bonus">(<img src="img/ico/class1.png" width="12" height="12"/>+15%)</span><?php }
		if ($row['upgrade_stat3'] == 2) {?><span class="bonus">(<img src="img/ico/class2.png" width="12" height="12"/>+25%)</span><?php }
		if ($row['upgrade_stat3'] == 3) {?><span class="bonus">(<img src="img/ico/class3.png" width="12" height="12"/>+50%)</span><?php }
		if ($row['upgrade_stat3'] >= 4) {?><span class="bonus">(<img src="img/ico/class4.png" width="12" height="12"/>+75%)</span><?php }
		?> Надёжность: <span class="white"><?php echo $row['stat3'];?></span></p>
			<p><img src="img/ico/speed.png" alt="н"/><?php
		if ($row['upgrade_speed'] == 1) {?><span class="bonus">(<img src="img/ico/class1.png" width="12" height="12"/>-1сек)</span><?php }
		if ($row['upgrade_speed'] == 2) {?><span class="bonus">(<img src="img/ico/class2.png" width="12" height="12"/>-2сек)</span><?php }
		if ($row['upgrade_speed'] == 3) {?><span class="bonus">(<img src="img/ico/class3.png" width="12" height="12"/>-3сек)</span><?php }
		if ($row['upgrade_speed'] >= 4) {?><span class="bonus">(<img src="img/ico/class4.png" width="12" height="12"/>-4сек)</span><?php }
		?> Перезарядка: <span class="white"><?php echo $row['speed'];?>сек</span></p>
	</div>
	  <div class="zx">
	<div class="clothes">
      <p>Состояние: <span class="white"><?php echo $row['sost'];?>/8</span></p>
	  </div>
	  <p><img src="img/ico/profile.png" alt="н"/>Владелец: <span class="white">
	  <?php 
  if ($row_user['gruppa'] == 'svoboda') {if ($razn_last_act < 300 ) {?><img src="img/ico/on.png" width="12" height="12" alt="н"/><img src="img/ico/svobodaon.png" width="12" height="12" alt="н"/><?php } else {?><img src="img/ico/off.png" width="12" height="12" alt="н"/><img src="img/ico/svobodaon.png" width="12" height="12" alt="н"/><?php }}
	  if ($row_user['gruppa'] == 'dolg') {if ($razn_last_act < 300 ) {?><img src="img/ico/on.png" width="12" height="12" alt="н"/><img src="img/ico/dolgon.png" width="12" height="12" alt="н"/><?php } else {?><img src="img/ico/off.png" width="12" height="12" alt="н"/><img src="img/ico/dolgon.png" width="12" height="12" alt="н"/><?php }}
		  if ($row_user['gruppa'] == 'naemniki') {if ($razn_last_act < 300 ) {?><img src="img/ico/on.png" width="12" height="12" alt="н"/><img src="img/ico/naemniki.png" width="12" height="12" alt="н"/><?php } else {?><img src="img/ico/off.png" width="12" height="12" alt="н"/><img src="img/ico/naemniki.png" width="12" height="12" alt="н"/><?php }}
          if ($row_user['gruppa'] == 'renegat') {if ($razn_last_act < 300 ) {?><img src="img/ico/on.png" width="12" height="12" alt="н"/><img src="img/ico/renegat.png" width="12" height="12" alt="н"/><?php } else {?><img src="img/ico/off.png" width="12" height="12" alt="н"/><img src="img/ico/renegat.png" width="12" height="12" alt="н"/><?php }}
	  if ($row_user['gruppa'] == 'chistoenebo') {if ($razn_last_act < 300 ) {?><img src="img/ico/on.png" width="12" height="12" alt="н"/><img src="img/ico/chistoenebo.png" width="12" height="12" alt="н"/><?php } else {?><img src="img/ico/off.png" width="12" height="12" alt="н"/><img src="img/ico/chistoenebo.png" width="12" height="12" alt="н"/><?php }}
?>	  <a  class="white" href="profile.php?id=<?php echo "$user_set"?>"><?php echo $row_user['nick'];?></a></span></p>
	  </div>

<?php
/////////////////////Если это моя шмотка
  if ($user_set == $user_id) {
  ?><div class="zx"><?php
	 if ($row['sost'] == 0) {?><p><a href="fix.php?thing=<?php echo "$thing";?>">Починить за <img src="img/ico/materials.png" width="12" height="12"/>1000</a></p>
	  <?php }
	   if ($row['sost'] == 1) {?><p><a href="fix.php?thing=<?php echo "$thing";?>">Починить за <img src="img/ico/materials.png" width="12" height="12"/>800</a></p><?php }  
	   if ($row['sost'] == 2) {?><p><a href="fix.php?thing=<?php echo "$thing";?>">Починить за <img src="img/ico/materials.png" width="12" height="12"/>180</a></p><?php } 
	   if ($row['sost'] == 3) {?><p><a href="fix.php?thing=<?php echo "$thing";?>">Починить за <img src="img/ico/materials.png" width="12" height="12"/>150</a></p><?php } 
	   if ($row['sost']== 4) {?><p><a href="fix.php?thing=<?php echo "$thing";?>">Починить за <img src="img/ico/materials.png" width="12" height="12"/>120</a></p><?php } 
	   if ($row['sost'] == 5) {?><p><a href="fix.php?thing=<?php echo "$thing";?>">Починить за <img src="img/ico/materials.png" width="12" height="12"/>90</a></p><?php }
	   if ($row['sost'] == 6) {?><p><a href="fix.php?thing=<?php echo "$thing";?>">Починить за <img src="img/ico/materials.png" width="12" height="12"/>60</a></p><?php }  
	   if ($row['sost']== 7) {?><p><a href="fix.php?thing=<?php echo "$thing";?>">Починить за <img src="img/ico/materials.png" width="12" height="12"/>30</a></p><?php }
	  ?>
	  <p><img src="img/ico/upgrade.png" width="12" height="12"/><a href="upgrade.php?thing=<?php echo "$thing";?>">Улучшить у мастера</a></p>
	  <?php if ($row['privat'] < 2) {?>
	  <p><img src="img/ico/point.png" width="12" height="12"/><a href="thing.php?thing=<?php echo "$thing";?>&lot=1">Выставить на аукцион</a></p>
	  <?php }?>
	  </div>
	  </div>
	<?php
  } else {
  ?><p><img src="img/ico/upgrade.png" width="12" height="12"/><a href="upgrade.php?thing=<?php echo "$thing";?>">Список улучшений</a></p><?php
}
////////////////////////
}
/////////////////////////////////////Конец пистолета

////////////////////////Автомат НАЧАЛО!!!
if ($type == 3) {
?>	
	<div class="clothes">
	
<img src="img/weapons/<?php echo $row_inf['screen'];?>" alt="Слот №3" width="145" height="50"/>
   <p><?php
		if ($row_inf['klass'] == 1) {?><img src="img/ico/class1.png" width="12" height="12"/><?php }
		if ($row_inf['klass'] == 2) {?><img src="img/ico/class2.png" width="12" height="12"/><?php }
		if ($row_inf['klass'] == 3) {?><img src="img/ico/class3.png" width="12" height="12"/><?php }
		if ($row_inf['klass'] == 4) {?><img src="img/ico/class4.png" width="12" height="12"/><?php }
		?><span class="white"><?php echo $row_inf['name']; ?></span> (<span class="bonus"> <?php echo $row ['need_lvl'];?> ур,</span><?php if ($row['privat'] == 0) { echo " новый";}
	if ($row['privat'] == 1) { echo " личный";}?>)</p>
    <p><img src="img/ico/to4nost.png" alt="н"/><?php
		if ($row['upgrade_stat1'] == 1) {?><span class="bonus">(<img src="img/ico/class1.png" width="12" height="12"/>+15%)</span><?php }
		if ($row['upgrade_stat1'] == 2) {?><span class="bonus">(<img src="img/ico/class2.png" width="12" height="12"/>+25%)</span><?php }
		if ($row['upgrade_stat1'] == 3) {?><span class="bonus">(<img src="img/ico/class3.png" width="12" height="12"/>+50%)</span><?php }
		if ($row['upgrade_stat1'] >= 4) {?><span class="bonus">(<img src="img/ico/class4.png" width="12" height="12"/>+75%)</span><?php }
		?> Урон: <span class="white"><?php echo $row['stat1'];?></span></p>
    <p> <img src="img/ico/to4nost.png" alt="н"/><?php
		if ($row['upgrade_stat2'] == 1) {?><span class="bonus">(<img src="img/ico/class1.png" width="12" height="12"/>+15%)</span><?php }
		if ($row['upgrade_stat2'] == 2) {?><span class="bonus">(<img src="img/ico/class2.png" width="12" height="12"/>+25%)</span><?php }
		if ($row['upgrade_stat2'] == 3) {?><span class="bonus">(<img src="img/ico/class3.png" width="12" height="12"/>+50%)</span><?php }
		if ($row['upgrade_stat2'] >= 4) {?><span class="bonus">(<img src="img/ico/class4.png" width="12" height="12"/>+75%)</span><?php }
		?>Точность: <span class="white"><?php echo $row['stat2'];?></span></p>
	<p><img src="img/ico/to4nost.png" alt="н"/><?php
		if ($row['upgrade_stat3'] == 1) {?><span class="bonus">(<img src="img/ico/class1.png" width="12" height="12"/>+15%)</span><?php }
		if ($row['upgrade_stat3'] == 2) {?><span class="bonus">(<img src="img/ico/class2.png" width="12" height="12"/>+25%)</span><?php }
		if ($row['upgrade_stat3'] == 3) {?><span class="bonus">(<img src="img/ico/class3.png" width="12" height="12"/>+50%)</span><?php }
		if ($row['upgrade_stat3'] >= 4) {?><span class="bonus">(<img src="img/ico/class4.png" width="12" height="12"/>+75%)</span><?php }
		?> Надёжность: <span class="white"><?php echo $row['stat3'];?></span></p>
    <p><?php
		if ($row['upgrade_speed'] == 1) {?><span class="bonus">(<img src="img/ico/class1.png" width="12" height="12"/>-15%)</span><?php }
		if ($row['upgrade_speed'] == 2) {?><span class="bonus">(<img src="img/ico/class2.png" width="12" height="12"/>-25%)</span><?php }
		if ($row['upgrade_speed'] == 3) {?><span class="bonus">(<img src="img/ico/class3.png" width="12" height="12"/>-50%)</span><?php }
		if ($row['upgrade_speed'] >= 4) {?><span class="bonus">(<img src="img/ico/class4.png" width="12" height="12"/>-75%)</span><?php }
		?><img src="img/ico/speed.png" alt="н"/> Перезарядка: <span class="white"><?php echo $row['speed'];?>сек</span></p>
	   <p> - - - - - -</p>
     <p>Состояние: <span class="white"><?php echo $row['sost'];?>/8</span></p>
	 </div>
	 <p><img src="img/ico/profile.png" alt="н"/>Владелец: <span class="white">
	  <?php 
  if ($row_user['gruppa'] == 'svoboda') {if ($razn_last_act < 300 ) {?><img src="img/ico/on.png" width="12" height="12" alt="н"/><img src="img/ico/svobodaon.png" width="12" height="12" alt="н"/><?php } else {?><img src="img/ico/off.png" width="12" height="12" alt="н"/><img src="img/ico/svobodaon.png" width="12" height="12" alt="н"/><?php }}
	  if ($row_user['gruppa'] == 'dolg') {if ($razn_last_act < 300 ) {?><img src="img/ico/on.png" width="12" height="12" alt="н"/><img src="img/ico/dolgon.png" width="12" height="12" alt="н"/><?php } else {?><img src="img/ico/off.png" width="12" height="12" alt="н"/><img src="img/ico/dolgon.png" width="12" height="12" alt="н"/><?php }}
		  if ($row_user['gruppa'] == 'naemniki') {if ($razn_last_act < 300 ) {?><img src="img/ico/on.png" width="12" height="12" alt="н"/><img src="img/ico/naemniki.png" width="12" height="12" alt="н"/><?php } else {?><img src="img/ico/off.png" width="12" height="12" alt="н"/><img src="img/ico/naemniki.png" width="12" height="12" alt="н"/><?php }}
          if ($row_user['gruppa'] == 'renegat') {if ($razn_last_act < 300 ) {?><img src="img/ico/on.png" width="12" height="12" alt="н"/><img src="img/ico/renegat.png" width="12" height="12" alt="н"/><?php } else {?><img src="img/ico/off.png" width="12" height="12" alt="н"/><img src="img/ico/renegat.png" width="12" height="12" alt="н"/><?php }}
	  if ($row_user['gruppa'] == 'chistoenebo') {if ($razn_last_act < 300 ) {?><img src="img/ico/on.png" width="12" height="12" alt="н"/><img src="img/ico/chistoenebo.png" width="12" height="12" alt="н"/><?php } else {?><img src="img/ico/off.png" width="12" height="12" alt="н"/><img src="img/ico/chistoenebo.png" width="12" height="12" alt="н"/><?php }}
	  ?><a  class="white" href="profile.php?id=<?php echo "$user_set"?>"><?php echo $row_user['nick'];?></a></span></p>
	  <?php
	  /////////////////////Если это моя шмотка
  if ($user_set == $user_id) {
  ?><div class="zx"><?php
	 if ($row['sost'] == 0) {?><p><a href="fix.php?thing=<?php echo "$thing";?>">Починить за <img src="img/ico/materials.png" width="12" height="12"/>1000</a></p>
	  <?php }
	   if ($row['sost'] == 1) {?><p><a href="fix.php?thing=<?php echo "$thing";?>">Починить за <img src="img/ico/materials.png" width="12" height="12"/>800</a></p><?php }  
	   if ($row['sost'] == 2) {?><p><a href="fix.php?thing=<?php echo "$thing";?>">Починить за <img src="img/ico/materials.png" width="12" height="12"/>180</a></p><?php } 
	   if ($row['sost'] == 3) {?><p><a href="fix.php?thing=<?php echo "$thing";?>">Починить за <img src="img/ico/materials.png" width="12" height="12"/>150</a></p><?php } 
	   if ($row['sost']== 4) {?><p><a href="fix.php?thing=<?php echo "$thing";?>">Починить за <img src="img/ico/materials.png" width="12" height="12"/>120</a></p><?php } 
	   if ($row['sost'] == 5) {?><p><a href="fix.php?thing=<?php echo "$thing";?>">Починить за <img src="img/ico/materials.png" width="12" height="12"/>90</a></p><?php }
	   if ($row['sost'] == 6) {?><p><a href="fix.php?thing=<?php echo "$thing";?>">Починить за <img src="img/ico/materials.png" width="12" height="12"/>60</a></p><?php }  
	   if ($row['sost']== 7) {?><p><a href="fix.php?thing=<?php echo "$thing";?>">Починить за <img src="img/ico/materials.png" width="12" height="12"/>30</a></p><?php }
	 ?>
	  <p><img src="img/ico/upgrade.png" width="12" height="12"/><a href="upgrade.php?thing=<?php echo "$thing";?>">Улучшить у мастера</a></p>
	  <?php if ($row['privat'] < 2) {?>
	  <p><img src="img/ico/point.png" width="12" height="12"/><a href="thing.php?thing=<?php echo "$thing";?>&lot=1">Выставить на аукцион</a></p>
	  <?php }?>
	  </div>
	  </div>
	<?php
  } else {
  ?><p><img src="img/ico/upgrade.png" width="12" height="12"/><a href="upgrade.php?thing=<?php echo "$thing";?>">Список улучшений</a></p><?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_inf['screen'];?>" alt="Слот №4" width="55" height="55"/></td>
      <td width="136" valign="top">
  </div>
	  </td>
      </tr>
      </tbody>
      </table>
	  <div class="clothes">

	    <p><?php
		if ($row_inf['klass'] == 1) {?><img src="img/ico/class1.png" width="12" height="12"/><?php }
		if ($row_inf['klass'] == 2) {?><img src="img/ico/class2.png" width="12" height="12"/><?php }
		if ($row_inf['klass'] == 3) {?><img src="img/ico/class3.png" width="12" height="12"/><?php }
		if ($row_inf['klass'] == 4) {?><img src="img/ico/class4.png" width="12" height="12"/><?php }
		?><span class="white"><?php echo $row_inf['name']; ?></span>(
		<span class="bonus"><?php echo $row['need_lvl'];?> ур,</span><?php if ($row['privat'] == 0) { echo " новый";}
	if ($row['privat'] == 1) { echo " личный";}?>)</p>
        <p><img src="img/ico/shield.png" alt="н" width="12" height="12"/><?php
		if ($row['upgrade_stat2'] == 1) {?><span class="bonus">(<img src="img/ico/class1.png" width="12" height="12"/>+15%)</span><?php }
		if ($row['upgrade_stat2'] == 2) {?><span class="bonus">(<img src="img/ico/class2.png" width="12" height="12"/>+25%)</span><?php }
		if ($row['upgrade_stat2'] == 3) {?><span class="bonus">(<img src="img/ico/class3.png" width="12" height="12"/>+50%)</span><?php }
		if ($row['upgrade_stat2'] >= 4) {?><span class="bonus">(<img src="img/ico/class4.png" width="12" height="12"/>+75%)</span><?php }
		?> Броня: <span class="white"><?php echo $row['stat2'];?></span></p>
        <p> <img src="img/ico/life.png" alt="н" width="12" height="12"/><?php
		if ($row['upgrade_stat1'] == 1) {?><span class="bonus">(<img src="img/ico/class1.png" width="12" height="12"/>+15%)</span><?php }
		if ($row['upgrade_stat1'] == 2) {?><span class="bonus">(<img src="img/ico/class2.png" width="12" height="12"/>+25%)</span><?php }
		if ($row['upgrade_stat1'] == 3) {?><span class="bonus">(<img src="img/ico/class3.png" width="12" height="12"/>+50%)</span><?php }
		if ($row['upgrade_stat1'] >= 4) {?><span class="bonus">(<img src="img/ico/class4.png" width="12" height="12"/>+75%)</span><?php }
		?>Здоровье: <span class="white"><?php echo $row['stat1'];?></span></p>
      
	  <p><img src="img/ico/shield.png" alt="н" width="12" height="12"/><?php
		if ($row['upgrade_stat3'] == 1) {?><span class="bonus">(<img src="img/ico/class1.png" width="12" height="12"/>+15%)</span><?php }
		if ($row['upgrade_stat3'] == 2) {?><span class="bonus">(<img src="img/ico/class2.png" width="12" height="12"/>+25%)</span><?php }
		if ($row['upgrade_stat3'] == 3) {?><span class="bonus">(<img src="img/ico/class3.png" width="12" height="12"/>+50%)</span><?php }
		if ($row['upgrade_stat3'] >= 4) {?><span class="bonus">(<img src="img/ico/class4.png" width="12" height="12"/>+75%)</span><?php }
		?> Прочность: <span class="white"><?php echo $row['stat3'];?></span></p>
	  <p><img src="img/ico/goodrad.png" alt="н"/><?php
		if ($row['upgrade_speed'] == 1) {?><span class="bonus">(<img src="img/ico/class1.png" width="12" height="12"/>+15%)</span><?php }
		if ($row['upgrade_speed'] == 2) {?><span class="bonus">(<img src="img/ico/class2.png" width="12" height="12"/>+25%)</span><?php }
		if ($row['upgrade_speed'] == 3) {?><span class="bonus">(<img src="img/ico/class3.png" width="12" height="12"/>+50%)</span><?php }
		if ($row['upgrade_speed'] >= 4) {?><span class="bonus">(<img src="img/ico/class4.png" width="12" height="12"/>+75%)</span><?php }
		?> Рад.защита: <span class="white"><?php echo $row['speed'];?></span></p>
	  </div>
	  <div class="zx">
	<div class="clothes">
      <p>Состояние: <span class="white"><?php echo $row['sost'];?>/8</span></p>
	  </div>
	  <p><img src="img/ico/profile.png" alt="н"/>Владелец: <span class="white">
	  <?php 
  if ($row_user['gruppa'] == 'svoboda') {if ($razn_last_act < 300 ) {?><img src="img/ico/on.png" width="12" height="12" alt="н"/><img src="img/ico/svobodaon.png" width="12" height="12" alt="н"/><?php } else {?><img src="img/ico/off.png" width="12" height="12" alt="н"/><img src="img/ico/svobodaon.png" width="12" height="12" alt="н"/><?php }}
	  if ($row_user['gruppa'] == 'dolg') {if ($razn_last_act < 300 ) {?><img src="img/ico/on.png" width="12" height="12" alt="н"/><img src="img/ico/dolgon.png" width="12" height="12" alt="н"/><?php } else {?><img src="img/ico/off.png" width="12" height="12" alt="н"/><img src="img/ico/dolgon.png" width="12" height="12" alt="н"/><?php }}
		  if ($row_user['gruppa'] == 'naemniki') {if ($razn_last_act < 300 ) {?><img src="img/ico/on.png" width="12" height="12" alt="н"/><img src="img/ico/naemniki.png" width="12" height="12" alt="н"/><?php } else {?><img src="img/ico/off.png" width="12" height="12" alt="н"/><img src="img/ico/naemniki.png" width="12" height="12" alt="н"/><?php }}
          if ($row_user['gruppa'] == 'renegat') {if ($razn_last_act < 300 ) {?><img src="img/ico/on.png" width="12" height="12" alt="н"/><img src="img/ico/renegat.png" width="12" height="12" alt="н"/><?php } else {?><img src="img/ico/off.png" width="12" height="12" alt="н"/><img src="img/ico/renegat.png" width="12" height="12" alt="н"/><?php }}
	  if ($row_user['gruppa'] == 'chistoenebo') {if ($razn_last_act < 300 ) {?><img src="img/ico/on.png" width="12" height="12" alt="н"/><img src="img/ico/chistoenebo.png" width="12" height="12" alt="н"/><?php } else {?><img src="img/ico/off.png" width="12" height="12" alt="н"/><img src="img/ico/chistoenebo.png" width="12" height="12" alt="н"/><?php }}
	  ?><a  class="white" href="profile.php?id=<?php echo "$user_set"?>"><?php echo $row_user['nick'];?></a></span></p>
	  </div>
<?php
/////////////////////Если это моя шмотка
  if ($user_set == $user_id) {
  ?><div class="zx"><?php
	 if ($row['sost'] == 0) {?><p><a href="fix.php?thing=<?php echo "$thing";?>">Починить за <img src="img/ico/materials.png" width="12" height="12"/>1000</a></p>
	  <?php }
	   if ($row['sost'] == 1) {?><p><a href="fix.php?thing=<?php echo "$thing";?>">Починить за <img src="img/ico/materials.png" width="12" height="12"/>800</a></p><?php }  
	   if ($row['sost'] == 2) {?><p><a href="fix.php?thing=<?php echo "$thing";?>">Починить за <img src="img/ico/materials.png" width="12" height="12"/>180</a></p><?php } 
	   if ($row['sost'] == 3) {?><p><a href="fix.php?thing=<?php echo "$thing";?>">Починить за <img src="img/ico/materials.png" width="12" height="12"/>150</a></p><?php } 
	   if ($row['sost']== 4) {?><p><a href="fix.php?thing=<?php echo "$thing";?>">Починить за <img src="img/ico/materials.png" width="12" height="12"/>120</a></p><?php } 
	   if ($row['sost'] == 5) {?><p><a href="fix.php?thing=<?php echo "$thing";?>">Починить за <img src="img/ico/materials.png" width="12" height="12"/>90</a></p><?php }
	   if ($row['sost'] == 6) {?><p><a href="fix.php?thing=<?php echo "$thing";?>">Починить за <img src="img/ico/materials.png" width="12" height="12"/>60</a></p><?php }  
	   if ($row['sost']== 7) {?><p><a href="fix.php?thing=<?php echo "$thing";?>">Починить за <img src="img/ico/materials.png" width="12" height="12"/>30</a></p><?php }
	  ?>
	  <p><img src="img/ico/upgrade.png" width="12" height="12"/><a href="upgrade.php?thing=<?php echo "$thing";?>">Улучшить у мастера</a></p>
	  <?php if ($row['privat'] < 2) {?>
	  <p><img src="img/ico/point.png" width="12" height="12"/><a href="thing.php?thing=<?php echo "$thing";?>&lot=1">Выставить на аукцион</a></p>
	  <?php }?>
	  </div>
	  </div>
	<?php
  } else {
  ?><p><img src="img/ico/upgrade.png" width="12" height="12"/><a href="upgrade.php?thing=<?php echo "$thing";?>">Список улучшений</a></p><?php
}
////////////////////////
}
//////////////////////////////////////Конец шлема

$phpself= filter($_SERVER['PHP_SELF']);
if ($row['place'] <> 2 and $user_set == $user_id and !empty($_GET['lot'])) {
?><div class="stats">
<p class="bonus"><b>Выставить лот на аукцион</b></p>
<form enctype="multipart/form-data" method="post" action="<? echo "$phpself"; ?>?thing=<?php echo "$thing"?>&lot=1">
<?php 
if ($row_inf['price'] < 0 and $row_inf['klass']==1) {
  $price = 2000;
}
else {
  $price = $row_inf['price'];
}
if ($row_inf['price'] < 0 and $row_inf['klass']==2) {
  $price = 2000;
}
else {
  $price = $row_inf['price'];
}
if ($row_inf['price'] < 0 and $row_inf['klass']==3) {
  $price = 2000;
}
else {
  $price = $row_inf['price'];
}
if ($row_inf['price'] < 0 and $row_inf['klass']==4) {
  $price = 3500;
}
else {
  $price = $row_inf['price'];
}
$price_buy=$price+500;
?>
<p class="white">Начальная ставка: <img src="img/ico/money.png" width="12" height="12"/> <input type="text" class="input" name="price_now" value="<?php echo "$price"; ?>" style="width:50px;"/></p>
<p class="white">Выкуп: <img src="img/ico/money.png" width="12" height="12"/> <input type="text" class="input" name="price" value="<?php echo "$price_buy"; ?>" style="width:50px;"/></p><br />
<input type="submit" style="width:70px;" class="input" value="Выставить" name="send"/>
</form>
[Стоимость: <img src="img/ico/money.png" width="12" height="12"/>5 RUB]
</div>
<?php
}
require_once('conf/navig.php');
require_once('conf/foot.php');
mysqli_close($dbc);
?>

</body>
</html>