<?

$title = 'Экипировка';
$load=array("avatar","weapon");
$paginate=1;
include_once 'protected/sys.php';
if (!$user)
{
	header("Location:/");
	exit;
}
	if(isset($_GET['withdraw']) AND isset($_GET['id_weapon'])){
		$weap=$db->fetch("SELECT * FROM `weapons` WHERE `id`=?",array(intval($_GET['id_weapon'])));
		if($user[$weap['type']]==$weap['id'] and $weap['id_user']==$user['id']){
		$str=$user['str']-$weap['str'];
			$def=$user['def']-$weap['def'];
			$hp=$user['max_hp']-$weap['hp'];
			$set=$db->query("UPDATE `users` SET `str`=?, `def`=?, `max_hp`=?, `".$weap['type']."`=? WHERE `id`=?",array($str,$def,$hp,0,$user['id']));
			$set=$db->query("UPDATE `weapons` SET `status`=? WHERE `id`=?",array("no",$weap['id']));

	} 
	}



echo "<div class='menu'>";

echo "</div>";
$types = array("w_head","w_shoulders","w_torso","w_mittens","w_weapon","w_pants","w_boots","w_shield");
foreach ($types as $type){
  $weaponID=$db->fetch("SELECT `$type` FROM `users` WHERE `id`=?",array($idData));
	if($weaponID[$type]!=0){
	echo "<div class='menu'>";
	$weap=new weap($db);
	$weap->view($weaponID[$type],$user,"no","weapons");
		echo "<a href='?withdraw&id_weapon=".$weaponID[$type]."'>Снять</a>";
	
	echo "</div>";		
	} else {

	}
}







include_once $config['root'].'/protected/footermain.php';