<?php
include_once ('core/base.php');
falseauth();

$id = fl($_GET['id']);

if(!$id) $id = $u['id'];

$us = $base -> query("SELECT * FROM `users` WHERE `id` = '".$id."' LIMIT 1") -> fetch_assoc();
if($us == 0) header('Location: /');

$header = 'Снаряжение '.$us['login'].'';
include_once ('core/head.php');

echo '<div class="b"><div class="title">Снаряжение</div>';

//Снимаем вещь
$unequip = fl($_GET['unequip']);
if($unequip){
	$unequipitem = $base -> query('SELECT * FROM `users_items` WHERE `id` = "'.$unequip.'" AND `user` = "'.$u['id'].'" AND `what` = "clothing" AND `equip` = "yes" LIMIT 1') -> fetch_assoc();
	if($unequipitem != 0){
		if($uclan){
		$u['endurance'] = $u['endurance'] - $uclan['earth_altar'];
		$u['intellect'] = $u['intellect'] - $uclan['water_altar'];
		$u['agility'] = $u['agility'] - $uclan['wind_altar'];
		$u['skill'] = $u['skill'] - $uclan['fire_altar'];
		}
		$base -> query('UPDATE `users` SET
		`p_att` = "'.($u['p_att']-$unequipitem['p_att']).'",
		`p_def` = "'.($u['p_def']-$unequipitem['p_def']).'",
		`m_att` = "'.($u['m_att']-$unequipitem['m_att']).'",
		`m_def` = "'.($u['m_def']-$unequipitem['m_def']).'",
		`endurance` = "'.($u['endurance']-$unequipitem['endurance']).'",
		`intellect` = "'.($u['intellect']-$unequipitem['intellect']).'",
		`agility` = "'.($u['agility']-$unequipitem['agility']).'",
		`skill` = "'.($u['skill']-$unequipitem['skill']).'",
		`equip_'.$unequipitem['type'].'` = "0" WHERE `id` = "'.$u['id'].'" LIMIT 1');
		$base -> query('UPDATE `users_items` SET `equip` = "no" WHERE `user` = "'.$u['id'].'" AND `id` = "'.$unequipitem['id'].'" LIMIT 1');
		$_SESSION['message'] = 'Вещь снята';
		header('Location: /equipment/'.$id.'');
	}else{
		$_SESSION['message'] = 'Ошибка';
		header('Location: /');
	}
}

if($us['equip_right'] == 0){
	echo '<div class="event_item">
	<table cellpadding="0" cellspacing="0"><tr>
	<td><img src="/images/empty.png" width="50px"></td>
	<td valign="top" style="padding-left: 5px;"><font color="#B1B1B1">Правая рука</font></tr></table></div>';
}else{
	echo ''.equipment_item($us['equip_right']).'';
}
if($us['equip_left'] == 0){
	echo '<div class="event_item">
	<table cellpadding="0" cellspacing="0"><tr>
	<td><img src="/images/empty.png" width="50px"></td>
	<td valign="top" style="padding-left: 5px;"><font color="#B1B1B1">Левая рука</font></tr></table></div>';
}else{
	echo ''.equipment_item($us['equip_left']).'';
}
if($us['equip_head'] == 0){
	echo '<div class="event_item">
	<table cellpadding="0" cellspacing="0"><tr>
	<td><img src="/images/empty.png" width="50px"></td>
	<td valign="top" style="padding-left: 5px;"><font color="#B1B1B1">Голова</font></tr></table></div>';
}else{
	echo ''.equipment_item($us['equip_head']).'';
}
if($us['equip_body'] == 0){
	echo '<div class="event_item">
	<table cellpadding="0" cellspacing="0"><tr>
	<td><img src="/images/empty.png" width="50px"></td>
	<td valign="top" style="padding-left: 5px;"><font color="#B1B1B1">Торс</font></tr></table></div>';
}else{
	echo ''.equipment_item($us['equip_body']).'';
}
if($us['equip_hands'] == 0){
	echo '<div class="event_item">
	<table cellpadding="0" cellspacing="0"><tr>
	<td><img src="/images/empty.png" width="50px"></td>
	<td valign="top" style="padding-left: 5px;"><font color="#B1B1B1">Руки</font></tr></table></div>';
}else{
	echo ''.equipment_item($us['equip_hands']).'';
}
if($us['equip_foot'] == 0){
	echo '<div class="event_item">
	<table cellpadding="0" cellspacing="0"><tr>
	<td><img src="/images/empty.png" width="50px"></td>
	<td valign="top" style="padding-left: 5px;"><font color="#B1B1B1">Обувь</font></tr></table></div>';
}else{
	echo ''.equipment_item($us['equip_foot']).'';
}
if($us['equip_necklace'] == 0){
	echo '<div class="event_item">
	<table cellpadding="0" cellspacing="0"><tr>
	<td><img src="/images/empty.png" width="50px"></td>
	<td valign="top" style="padding-left: 5px;"><font color="#B1B1B1">Бижутерия</font></tr></table></div>';
}else{
	echo ''.equipment_item($us['equip_necklace']).'';
}
if($us['equip_ring'] == 0){
	echo '<div class="event_item">
	<table cellpadding="0" cellspacing="0"><tr>
	<td><img src="/images/empty.png" width="50px"></td>
	<td valign="top" style="padding-left: 5px;"><font color="#B1B1B1">Кольцо</font></tr></table></div>';
}else{
	echo ''.equipment_item($us['equip_ring']).'';
}

echo '<br/><a class="btn" href="javascript:history.go(-1)"><img src="/images/icons/back.png"> Назад</a>';

echo '</div>';

include_once ('core/foot.php');
?>