<?php
require_once '../core/system.php';
echo only_reg();
$header = 'Заточка вещей';
require_once '../core/head.php';

if(isset($_GET['tov'])){
$infor3 = mysql_fetch_assoc(mysql_query("SELECT id_komp from `kompl_us` where `id` = '".abs(intval($_GET['tov']))."' and `id_us` = '".$user['id']."' limit 1"));
}
if($user[gold] < 100){
header('Location: ?');
$_SESSION['err'] = 'Нужно больше золота!';
exit();
}
if(isset($_GET['odet'])){
$up = mysql_fetch_assoc(mysql_query("SELECT * FROM `kompl_us` where `id_us` = '".$user['id']."' and `id` = '".abs(intval($_GET['odet']))."' limit 1"));
if(empty($up['id'])){
header('location:/'); exit;
}else{
$up2 = mysql_fetch_assoc(mysql_query("SELECT stats from `kompl` where `id` = '".$up['id_komp']."' limit 1"));
$stat2 = explode(';',$up2['stats']);

if($up['act'] == '0'){
mysql_query("UPDATE `user` SET `gold` = '".($user['gold']-100)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `molot` = '".($user['molot']+1)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `sila` = '".($user['sila']+10)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `sila` = '".($user['lovk']+10)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `sila` = '".($user['health']+10)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `sila` = '".($user['zashit']+10)."' WHERE `id` = '$user[id]' LIMIT 1");
echo'Успешно заточено<br/>';

$act = 1;


}else{
mysql_query("UPDATE `user` SET `sila` = '".($user['sila']+10)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `gold` = '".($user['gold']-100)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `molot` = '".($user['molot']+1)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `sila` = '".($user['lovk']+10)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `sila` = '".($user['health']+10)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `sila` = '".($user['zashit']+10)."' WHERE `id` = '$user[id]' LIMIT 1");

echo'Успешно заточено<br/>';$act=0;}
mysql_query("UPDATE `kompl_us` set `act` = '".$act."' where `id` = '".abs(intval($_GET['odet']))."'");
}
}
$kompls = mysql_query("SELECT * from `kompl_us` where `id_us` = '".$user['id']."' order by `id` desc");
if(mysql_num_rows($kompls) == 0){
echo'У вас нет предметов!<br/>';
}

while($komp2 = mysql_fetch_assoc($kompls)){
$komp = mysql_fetch_assoc(mysql_query("SELECT * FROM `kompl` where `id` = '".$komp2['id_komp']."' limit 1"));
$stat = explode(';',$komp['stats']);
echo '<div class="player"><div class="float-left">
<img style="margin-right:10px;margin-top:3px;" width="50" height="50" src="'.$komp['url'].'">
  </div>
  <img src="/images/icon/equip.png">
<span class="yellow">'.$komp['name'].'</a></span>
  <br>




  <br>
  Тип: '.$komp['type'].'
  <div style="clear:both;"></div>
</div>';
echo'<div class="player center">
<a class="btn" href="/user/molot.php?odet='.$komp2['id'].'">
    <span class="end">
      <span class="label">
'.($komp2['act'] == 0?'Заточить за <img src="/images/icon/gold.png"> 100':'Заточить за <img src="/images/icon/gold.png"> 100').'
      </span>
    </span>
</a>
</div>';
}
echo'</body>
</html>';
echo "</div>";
require_once '../core/foot.php';
?>