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

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

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

$header = $a['login'];
include_once ('core/head.php');

echo '<div class="b"><center><div style="position: relative; width: 350px;">';

switch($_GET['action']){

default:

//Скин
$skin='/images/skins/'.$a['skin'].'.gif';
$avatar='/images/skins/'.$a['skin'].'_big.png';

$_GET['up'] = fl($_GET['up']);
$_GET['party'] = fl($_GET['party']);
$_GET['clan'] = fl($_GET['clan']);
$_GET['friend'] = fl($_GET['friend']);

if($_GET['clan'] == 'go'){
	if($uclan){
		if($u['clan_rank'] == 4){
			if($a['id'] != $u['id']){
				if($a['clan'] == 0){
					$invitations = $base  -> query('SELECT * FROM `clan_invitation` WHERE `user` = "'.$u['id'].'" AND `invitee_user` = "'.$a['id'].'"') -> num_rows;
					if(!$invitations){
						if($a['level'] > 4){
							$members = $base  -> query('SELECT * FROM `users` WHERE `clan` = "'.$uclan['id'].'"') -> num_rows;
							if(($members + 1) <= $uclan['max_members']){
								$base -> query('INSERT INTO `clan_invitation` SET
									`user` = "'.$u['id'].'",
									`invitee_user` = "'.$a['id'].'"');
								$_SESSION['message'] = 'Приглашение отправлено.';
							}else{
								$_SESSION['message'] = 'В клане нет места.';
							}
						}else{
							$_SESSION['message'] = 'Игрок ниже 5 уровня.';
						}
					}else{
						$_SESSION['message'] = 'Вы уже отправляли приглашение этому игроку.';
					}
				}else{
					$_SESSION['message'] = ''.$a['login'].' уже состоит в клане.';
				}
			}else{
				$_SESSION['message'] = 'Ошибка.';
			}
		}else{
			$_SESSION['message'] = 'Приглашать в клан может только лидер.';
		}
	}else{
		$_SESSION['message'] = 'Вы не состоите в клане.';
	}
	header('Location: /user/'.$a['id'].'/');
	exit;
}

if($_GET['party'] == 'go'){
	if($a['id'] != $u['id']){
		$aparty = $base -> query("SELECT * FROM `party` WHERE `first_user` = '".$a['id']."' OR `second_user` = '".$a['id']."' OR `third_user` = '".$a['id']."' LIMIT 1") -> num_rows;
		if($aparty == 0){
			$invitations = $base  -> query('SELECT * FROM `party_invitation` WHERE `user` = "'.$u['id'].'" AND `invitee_user` = "'.$a['id'].'"') -> num_rows;
			if(!$invitations){
				if($uparty['third_user'] == 0 AND $uparty['first_user'] == $u['id']){
					if($a['world'] == $u['world'] AND $a['x'] == $u['x'] AND $a['y'] == $u['y']){
						$base -> query('INSERT INTO `party_invitation` SET
							`user` = "'.$u['id'].'",
							`invitee_user` = "'.$a['id'].'"');
						$_SESSION['message'] = 'Приглашение отправлено.';
					}else{
						$_SESSION['message'] = 'Вы должны стоять вместе, на одной локации.';
					}
				}else{
					$_SESSION['message'] = 'В команде недостаточно мест.';
				}
			}
		}else{
			$_SESSION['message'] = ''.$a['login'].' уже состоит в команде.';
		}
	}else{
		$_SESSION['message'] = 'Ошибка.';
	}
	header('Location: /user/'.$a['id'].'/');
	exit;
}

if($_GET['friend'] == 'go'){
	if($a['id'] != $u['id']){
		$friend = $base -> query('SELECT * FROM `friends` WHERE `user` = "'.$u['id'].'" AND `friend` = "'.$a['id'].'"') -> num_rows;
		if(!$friend){
			$base -> query('INSERT INTO `friends` SET
				`user` = "'.$u['id'].'",
				`friend` = "'.$a['id'].'"');
			$_SESSION['message'] = 'Игрок добавлен в ваш список друзей.';
			header('Location: /user/'.$a['id'].'/');
			exit;
		}else{
			$_SESSION['message'] = 'Игрок уже в вашем списке друзей.';
			header('Location: /user/'.$a['id'].'/');
			exit;
		}
	}else{
		$_SESSION['message'] = 'Ошибка.';
		header('Location: /user/'.$a['id'].'/');
		exit;
	}
}

if($_GET['up']){
	if($u['character_points'] > 0){
		if($_GET['up'] == 'endurance'){
			$base -> query('UPDATE `users` SET `endurance` = `endurance` + "1", `max_hp` = `max_hp` + "20", `character_points` = `character_points` - "1" WHERE `id` = "'.$u['id'].'" LIMIT 1');
			$_SESSION['message'] = 'Выносливость успешно улучшена.';
			header('Location: /user/'.$u['id'].'/');
			exit;
		}
		if($_GET['up'] == 'intellect'){
			$base -> query('UPDATE `users` SET `intellect` = `intellect` + "1", `max_mp` = `max_mp` + "20", `character_points` = `character_points` - "1" WHERE `id` = "'.$u['id'].'" LIMIT 1');
			$_SESSION['message'] = 'Интеллект успешно улучшен.';
			header('Location: /user/'.$u['id'].'/');
			exit;
		}
		if($_GET['up'] == 'agility'){
			$base -> query('UPDATE `users` SET `agility` = `agility` + "1", `character_points` = `character_points` - "1" WHERE `id` = "'.$u['id'].'" LIMIT 1');
			$_SESSION['message'] = 'Ловкость успешно улучшена.';
			header('Location: /user/'.$u['id'].'/');
			exit;
		}
		if($_GET['up'] == 'skill'){
			$base -> query('UPDATE `users` SET `skill` = `skill` + "1", `character_points` = `character_points` - "1" WHERE `id` = "'.$u['id'].'" LIMIT 1');
			$_SESSION['message'] = 'Мастерство успешно улучшено.';
			header('Location: /user/'.$u['id'].'/');
			exit;
		}
	}else{
		$_SESSION['message'] = 'Недостаточно очков характеристик.';
		header('Location: /user/'.$u['id'].'/');
		exit;
	}
}

if($a['background']=='standard'){
	$background='/images/locations/backgrounds/ellerton_grass.png';
}else{
	$background='/images/locations/backgrounds/'.$a['background'].'.png';
}

if($a['tester'] == 1) $beta = '<img src="/images/icons/beta.png">';

echo '<div class="title">'.$beta.' '.nolinkname($a['id']).' '.$beta.'</div>';

echo '<div class="event"><center>'.$a['status'].'</center></div>';

//if($a['tester'] == 1) echo '<div class="event"><center><img src="/images/icons/beta.png"><img src="/images/icons/beta.png"></center></div>';

echo '<div class="border" style="box-sizing: border-box;">';
echo '<div style="background: url('.$background.') no-repeat center; display: block;">';
echo '<table cellpadding="5" cellspacing="3" align="center"><tr>';
echo '<td style="vertical-align:top; padding-right: 35px;">';

$item = $base -> query("SELECT * FROM `users_items` WHERE `user` = '".$a['id']."' AND `equip` = 'yes' AND `type` = 'right' LIMIT 1") -> fetch_assoc();
echo '<div style="padding-bottom: 2px;">';
if($item) echo ''.profile_item($item['id']).'';
else echo '<center><img src="/images/empty.png" width="40px" style="border: 1px solid #DDDDDD;"><br><small><font style="text-shadow: black 1px 1px 1px; color: #DDDDDD;" size="1"><b>[пусто]</b></font></small></center>';
echo '</div>';

$item = $base -> query("SELECT * FROM `users_items` WHERE `user` = '".$a['id']."' AND `equip` = 'yes' AND `type` = 'head' LIMIT 1") -> fetch_assoc();
echo '<div style="padding-bottom: 2px;">';
if($item) echo ''.profile_item($item['id']).'';
else echo '<center><img src="/images/empty.png" width="40px" style="border: 1px solid #DDDDDD;"><br><small><font style="text-shadow: black 1px 1px 1px; color: #DDDDDD;" size="1"><b>[пусто]</b></font></small></center>';
echo '</div>';

$item = $base -> query("SELECT * FROM `users_items` WHERE `user` = '".$a['id']."' AND `equip` = 'yes' AND `type` = 'hands' LIMIT 1") -> fetch_assoc();
echo '<div style="padding-bottom: 2px;">';
if($item) echo ''.profile_item($item['id']).'';
else echo '<center><img src="/images/empty.png" width="40px" style="border: 1px solid #DDDDDD;"><br><small><font style="text-shadow: black 1px 1px 1px; color: #DDDDDD;" size="1"><b>[пусто]</b></font></small></center>';
echo '</div>';

$item = $base -> query("SELECT * FROM `users_items` WHERE `user` = '".$a['id']."' AND `equip` = 'yes' AND `type` = 'necklace' LIMIT 1") -> fetch_assoc();
echo '<div style="padding-bottom: 2px;">';
if($item) echo ''.profile_item($item['id']).'';
else echo '<center><img src="/images/empty.png" width="40px" style="border: 1px solid #DDDDDD;"><br><small><font style="text-shadow: black 1px 1px 1px; color: #DDDDDD;" size="1"><b>[пусто]</b></font></small></center>';
echo '</div>';

echo '</td>';


echo '<td>';
echo '<center><font style="text-shadow: black 1px 1px 1px; color: '.$a['login_color'].';">'.$a['login'].'</font><br/><img src="'.$skin.'"></center>';
echo '</td>';


echo '<td style="vertical-align:top; padding-left: 35px;">';

$item = $base -> query("SELECT * FROM `users_items` WHERE `user` = '".$a['id']."' AND `equip` = 'yes' AND `type` = 'left' LIMIT 1") -> fetch_assoc();
echo '<div style="padding-bottom: 2px;">';
if($item) echo ''.profile_item($item['id']).'';
else echo '<center><img src="/images/empty.png" width="40px" style="border: 1px solid #DDDDDD;"><br><small><font style="text-shadow: black 1px 1px 1px; color: #DDDDDD;" size="1"><b>[пусто]</b></font></small></center>';
echo '</div>';

$item = $base -> query("SELECT * FROM `users_items` WHERE `user` = '".$a['id']."' AND `equip` = 'yes' AND `type` = 'body' LIMIT 1") -> fetch_assoc();
echo '<div style="padding-bottom: 2px;">';
if($item) echo ''.profile_item($item['id']).'';
else echo '<center><img src="/images/empty.png" width="40px" style="border: 1px solid #DDDDDD;"><br><small><font style="text-shadow: black 1px 1px 1px; color: #DDDDDD;" size="1"><b>[пусто]</font></small></center>';
echo '</div>';

$item = $base -> query("SELECT * FROM `users_items` WHERE `user` = '".$a['id']."' AND `equip` = 'yes' AND `type` = 'foot' LIMIT 1") -> fetch_assoc();
echo '<div style="padding-bottom: 2px;">';
if($item) echo ''.profile_item($item['id']).'';
else echo '<center><img src="/images/empty.png" width="40px" style="border: 1px solid #DDDDDD;"><br><small><font style="text-shadow: black 1px 1px 1px; color: #DDDDDD;" size="1"><b>[пусто]</b></font></small></center>';
echo '</div>';

$item = $base -> query("SELECT * FROM `users_items` WHERE `user` = '".$a['id']."' AND `equip` = 'yes' AND `type` = 'ring' LIMIT 1") -> fetch_assoc();
echo '<div style="padding-bottom: 2px;">';
if($item) echo ''.profile_item($item['id']).'';
else echo '<center><img src="/images/empty.png" width="40px" style="border: 1px solid #DDDDDD;"><br><small><font style="text-shadow: black 1px 1px 1px; color: #DDDDDD;" size="1"><b>[пусто]</b></font></small></center>';
echo '</div>';

echo '</td>';
echo '</tr></table></div></div>';

$aban = $base -> query("SELECT * FROM `ban` WHERE `id_user` = '".$a['id']."' AND `time_ban` > '".time()."' ORDER BY `id` DESC LIMIT 1") -> fetch_assoc();
if($aban['id']){
	if($aban['blocked'] == 'all') $banned = 'заблокирован';
	else $banned = 'заткнут';
	echo '<div class="event">';
	echo '<center><font color="red"><b>Игрок '.$banned.' за нарушение правил игры.</b></font></center>';
	echo '<font color="#B1B1B1">Окончание:</font> '.tm($aban['time_ban']).' <br/>';
	echo '<font color="#B1B1B1">Заблокировал(а):</font> '.name($aban['id_ban']).' <br/>';
	echo '<font color="#B1B1B1">Причина:</font> '.fl($aban['reason']).'';
	echo '</div>';
}

//Пояс и умения
if($u['training_step'] == 11){
	if($u['belt_slot_1'] == 0) echo '<div style="position: absolute; bottom: -3%; left: 18%; z-index: 9000;"><img src="/images/cursor.gif"></div>';
	if($u['belt_slot_1'] != 0 AND $u['belt_slot_2'] == 0) echo '<div style="position: absolute; bottom: -3%; left: 30%; z-index: 9000;"><img src="/images/cursor.gif"></div>';
	if($u['belt_slot_1'] != 0 AND $u['belt_slot_2'] != 0){
		header('Location: /training/next/');
		exit;
	}
}
echo '<center><table style="width: 100%; max-width: 303px;" cellspacing="3px"><tr>';
echo '<td class="event" width="50%">';
if($a['belt_slot_1'] > 0){
		$bs = $base -> query("SELECT * FROM `users_items` WHERE `id` = '".$a['belt_slot_1']."' LIMIT 1") -> fetch_assoc();
		if($bs['mark'] == '0') $border_color = 'B1B1B1';
		if($bs['mark'] == '1') $border_color = '30C030';
		if($bs['mark'] == '2') $border_color = '68A8F9';
		if($bs['mark'] == '3') $border_color = 'D8CD32';
		if($bs['mark'] == '4') $border_color = 'DD4FFF';
		if($a['id'] == $u['id']) $href = '/beltslot/1/';
		else $href = '/res/'.$bs['id'].'/';
		echo '<a class="potion" style="width: 42px; height: 42px; border: 1px solid #'.$border_color.';" href="'.$href.'"><div style="background: url(/images/items/resource/'.$bs['image'].'.png) no-repeat center; background-size: 100%; display: inline-block; width: 42; height: 42px;">
			<div style="padding-top: 70%; padding-right: 3px;"><font style="text-shadow: black 1px 1px 1px; color: #e0e0e0; font-size: 10px; float: right;">'.$bs['amount'].'</font></div></div></a>';
	}else{
		echo '<a class="potion" href="/beltslot/1/" style="border: 1px solid gray; height: 31px; width: 42px;font-size: 13px; padding-top: 11px; display: inline-block; color: gray;">пусто</a>';
	}
if($a['belt_slot_2'] > 0){
		$bs = $base -> query("SELECT * FROM `users_items` WHERE `id` = '".$a['belt_slot_2']."' LIMIT 1") -> fetch_assoc();
		if($bs['mark'] == '0') $border_color = 'B1B1B1';
		if($bs['mark'] == '1') $border_color = '30C030';
		if($bs['mark'] == '2') $border_color = '68A8F9';
		if($bs['mark'] == '3') $border_color = 'D8CD32';
		if($bs['mark'] == '4') $border_color = 'DD4FFF';
		if($a['id'] == $u['id']) $href = '/beltslot/2/';
		else $href = '/res/'.$bs['id'].'/';
		echo '<a class="potion" style="width: 42px; height: 42px; border: 1px solid #'.$border_color.';" href="'.$href.'"><div style="background: url(/images/items/resource/'.$bs['image'].'.png) no-repeat center; background-size: 100%; display: inline-block; width: 42; height: 42px;">
			<div style="padding-top: 70%; padding-right: 3px;"><font style="text-shadow: black 1px 1px 1px; color: #e0e0e0; font-size: 10px; float: right;">'.$bs['amount'].'</font></div></div></a>';
	}else{
		echo '<a class="potion" href="/beltslot/2/" style="border: 1px solid gray; height: 31px; width: 42px;font-size: 13px; padding-top: 11px; display: inline-block; color: gray;">пусто</a>';
	}
if($a['belt_slot_3'] > 0){
		$bs = $base -> query("SELECT * FROM `users_items` WHERE `id` = '".$a['belt_slot_3']."' LIMIT 1") -> fetch_assoc();
		if($bs['mark'] == '0') $border_color = 'B1B1B1';
		if($bs['mark'] == '1') $border_color = '30C030';
		if($bs['mark'] == '2') $border_color = '68A8F9';
		if($bs['mark'] == '3') $border_color = 'D8CD32';
		if($bs['mark'] == '4') $border_color = 'DD4FFF';
		if($a['id'] == $u['id']) $href = '/beltslot/3/';
		else $href = '/res/'.$bs['id'].'/';
		echo '<a class="potion" style="width: 42px; height: 42px; border: 1px solid #'.$border_color.';" href="'.$href.'"><div style="background: url(/images/items/resource/'.$bs['image'].'.png) no-repeat center; background-size: 100%; display: inline-block; width: 42; height: 42px;">
			<div style="padding-top: 70%; padding-right: 3px;"><font style="text-shadow: black 1px 1px 1px; color: #e0e0e0; font-size: 10px; float: right;">'.$bs['amount'].'</font></div></div></a>';
	}else{
		echo '<a class="potion" href="/beltslot/3/" style="border: 1px solid gray; height: 31px; width: 42px;font-size: 13px; padding-top: 11px; display: inline-block; color: gray;">пусто</a>';
	}
echo '</td>';
echo '<td class="event" width="50%">';
if($a['skill_slot_1'] > 0){
		$ss = $base -> query("SELECT * FROM `users_skills` WHERE `id` = '".$a['skill_slot_1']."' LIMIT 1") -> fetch_assoc();
		if($ss['book'] == 'fire') $border_color = 'orangered';
		if($ss['book'] == 'earth') $border_color = 'limegreen';
		if($ss['book'] == 'water') $border_color = 'dodgerblue';
		if($a['id'] == $u['id']) $href = '/skillslot/1/';
		else $href = '/uskill/'.$ss['id'].'/';
		echo '<a class="skill" style="width: 42px; height: 42px; border: 1px solid '.$border_color.';" href="'.$href.'"><div style="background: url(/images/skills/'.$ss['image'].'.png) no-repeat center; background-size: 100%; display: inline-block; width: 42; height: 42px;"></div></a>';
	}else{
		echo '<a class="skill" href="/skillslot/1/" style="border: 1px solid gray; height: 31px; width: 42px;font-size: 13px; padding-top: 11px; display: inline-block; color: gray;">пусто</a>';
	}
if($a['skill_slot_2'] > 0){
		$ss = $base -> query("SELECT * FROM `users_skills` WHERE `id` = '".$a['skill_slot_2']."' LIMIT 1") -> fetch_assoc();
		if($ss['book'] == 'fire') $border_color = 'orangered';
		if($ss['book'] == 'earth') $border_color = 'limegreen';
		if($ss['book'] == 'water') $border_color = 'dodgerblue';
		if($a['id'] == $u['id']) $href = '/skillslot/2/';
		else $href = '/uskill/'.$ss['id'].'/';
		echo '<a class="skill" style="width: 42px; height: 42px; border: 1px solid '.$border_color.';" href="'.$href.'"><div style="background: url(/images/skills/'.$ss['image'].'.png) no-repeat center; background-size: 100%; display: inline-block; width: 42; height: 42px;"></div></a>';
	}else{
		echo '<a class="skill" href="/skillslot/2/" style="border: 1px solid gray; height: 31px; width: 42px;font-size: 13px; padding-top: 11px; display: inline-block; color: gray;">пусто</a>';
	}
if($a['skill_slot_3'] > 0){
		$ss = $base -> query("SELECT * FROM `users_skills` WHERE `id` = '".$a['skill_slot_3']."' LIMIT 1") -> fetch_assoc();
		if($ss['book'] == 'fire') $border_color = 'orangered';
		if($ss['book'] == 'earth') $border_color = 'limegreen';
		if($ss['book'] == 'water') $border_color = 'dodgerblue';
		if($a['id'] == $u['id']) $href = '/skillslot/3/';
		else $href = '/uskill/'.$ss['id'].'/';
		echo '<a class="skill" style="width: 42px; height: 42px; border: 1px solid '.$border_color.';" href="'.$href.'"><div style="background: url(/images/skills/'.$ss['image'].'.png) no-repeat center; background-size: 100%; display: inline-block; width: 42; height: 42px;"></div></a>';
	}else{
		echo '<a class="skill" href="/skillslot/3/" style="border: 1px solid gray; height: 31px; width: 42px;font-size: 13px; padding-top: 11px; display: inline-block; color: gray;">пусто</a>';
	}
echo '</td>';
echo '</tr></table></center>';

echo '</div></center>';

if($a['clan'] != 0){
	$aclan = $base -> query('SELECT * FROM `clans` WHERE `id` = "'.$a['clan'].'" LIMIT 1') -> fetch_assoc();
	$clendurance = '<font color="#B1B1B1"><small>+'.n_f($aclan['earth_altar']).'</small></font>';
	$clintellect = '<font color="#B1B1B1"><small>+'.n_f($aclan['water_altar']).'</small></font>';
	$clagility = '<font color="#B1B1B1"><small>+'.n_f($aclan['wind_altar']).'</small></font>';
	$clskill = '<font color="#B1B1B1"><small>+'.n_f($aclan['fire_altar']).'</small></font>';
	echo '<div class="title">Клан</div>';
	echo ''.clan_no_exp($a['clan']).'';
}

echo '<div class="title">Информация</div>';
if($u['admin'] == 3) echo '<div class="event"><center><img src="/images/icons/silver.png">'.n_f($a['silver']).' <img src="/images/icons/gold.png">'.n_f($a['gold']).' <img src="/images/icons/character_points.png">'.n_f($a['character_points']).' <img src="/images/icons/skill_points.png">'.n_f($a['skill_points']).'<br/>
	'.$a['email'].'</center></div>';
$alexp = $base -> query("SELECT * FROM `level` WHERE `id` = '".$a['level']."' LIMIT 1") -> fetch_assoc();
echo '<table class="table table-common" style="margin-top: 5px; border-collapse: collapse; text-align: left; font-size: 12px;">';
echo '<tr><td rowspan="3" width="20%"><center><img src="'.$avatar.'" width="100%"></center></td><td><img src="/images/icons/fearrow.png" width="16px"> Имя</td><td><center>'.$a['name'].'</center></td>';
echo '<tr><td><img src="/images/icons/fearrow.png" width="16px"> Страна</td><td><center>'.$a['country'].'</center></td></tr>';
if($a['sex'] == 1) $s = '';
else $s = 'а';
echo '<tr><td><img src="/images/icons/time.png" width="16px"> Был'.$s.' в сети</td><td><center>'.tm($a['date_online']).'</center></td></tr>';
echo '</table>';

echo '<div class="title" style="padding-bottom: 3px;">Характеристики <a href="/help/stats/"><img src="/images/icons/info.png"></a></div>';

if($a['id'] == $u['id']){
if($u['character_points'] > 0){
	$up_endurance = '<a href="/user/up_endurance/"><img src="/images/icons/up.png"></a>';
	$up_intellect = '<a href="/user/up_intellect/"><img src="/images/icons/up.png"></a>';
	$up_agility = '<a href="/user/up_agility/"><img src="/images/icons/up.png"></a>';
	$up_skill = '<a href="/user/up_skill/"><img src="/images/icons/up.png"></a>';
	echo '<center>Очки характеристик: <img src="/images/icons/character_points.png" width="20px"> <font color="orange"><b>'.$u['character_points'].'</b></font></center>';
}
}

echo '<table class="table table-common" style="margin-top: 5px; border-collapse: collapse; text-align: left; font-size: 13px;">';
echo '<tr><td><img src="/images/icons/p_att.png"> Физ. Атака</td><td><center>'.n_f($a['p_att']).'</center></td><td><img src="/images/icons/endurance.png"> Выносливость'.$up_endurance.'</td><td><center>'.$a['endurance'].''.$clendurance.'</center></td></tr>';
echo '<tr><td><img src="/images/icons/p_def.png"> Физ. Защита</td><td><center>'.n_f($a['p_def']).'</center></td><td><img src="/images/icons/intellect.png"> Интеллект'.$up_intellect.'</td><td><center>'.$a['intellect'].''.$clintellect.'</center></td></tr>';
echo '<tr><td><img src="/images/icons/m_att.png"> Маг. Атака</td><td><center>'.n_f($a['m_att']).'</center></td><td><img src="/images/icons/agility.png"> Ловкость'.$up_agility.'</td><td><center>'.$a['agility'].''.$clagility.'</center></td></tr>';
echo '<tr><td><img src="/images/icons/m_def.png"> Маг. Защита</td><td><center>'.n_f($a['m_def']).'</center></td><td><img src="/images/icons/skill.png"> Мастерство'.$up_skill.'</td><td><center>'.$a['skill'].''.$clskill.'</center></td></tr>';
echo '</table>';

echo '<div class="title">Статистика</div>';

$stats = $a['p_att'] + $a['p_def'] + $a['m_att'] + $a['m_def'] + $a['endurance'] + $a['intellect'] + $a['agility'] + $a['skill'];

echo '<table class="table table-common" style="margin-top: 5px; border-collapse: collapse; text-align: left; font-size: 13px;">';
echo '<tr><td><img src="/images/icons/skull.png"> Убито существ</td><td><center>'.n_f($a['kills']).'</center></td><td><img src="/images/icons/duel.png"> Дуэли</td><td><center><font color="lime">'.n_f($a['duel_wins']).'</font> | <font color="red">'.n_f($a['duel_loses']).'</font></center></td></tr>';
echo '<tr><td><img src="/images/icons/skeleton.png"> Убито боссов</td><td><center>'.n_f($a['boss_kills']).'</center></td><td><img src="/images/icons/stats.png"> Общая сила</td><td><center>'.n_f($stats).'</center></td></tr>';
echo '</table>';

if($a['id'] == $u['id']){
	if($u['skill_points'] > 0) $skillpoints = ' <img src="/images/icons/skill_points.png"><b><font color="violet">'.$u['skill_points'].'</font></b>';
	echo '<table width="100%"><tr>';
	echo '<td width="50%">';
	echo '<a class="btn" href="/equipment/"><img src="/images/icons/bag.png" width="24px"> Снаряжение</a>';
	echo '<a class="btn" href="/skills/"><img src="/images/icons/skills.png"> Умения'.$skillpoints.'</a>';
	echo '<a class="btn" href="/diary/"><img src="/images/icons/diary.png"> Дневник</a>';
	echo '<a class="btn" href="/mail/"><img src="/images/icons/mail.png"> Почта</a>';
	echo '<a class="btn" href="/skins/"><img src="/images/icons/user.png"> Образы</a>';
	echo '</td><td width="50%" valign="top">';
	if($uclan) echo '<a class="btn" href="/clan/"><img src="/images/icons/cross.png"> Клан</a>';
	echo '<a class="btn" href="/party/"><img src="/images/icons/party.png"> Команда</a>';
	echo '<a class="btn" href="/friends/"><img src="/images/icons/friend.png"> Друзья</a>';
	echo '<a class="btn" href="/settings/"><img src="/images/icons/settings.png"> Настройки</a>';
	echo '</td></tr></table>';
} else {
	echo '<a class="btn" href="/newmsg/'.$id.'/"><img src="/images/icons/mail.png"> Отправить сообщение</a>';
	if($u['level'] >= 10) echo '<a class="btn" href="/user/'.$a['id'].'/send/silver/"><img src="/images/icons/silver_24.png"> Передать серебро</a>';
	//if($u['level'] >= 5) echo '<a class="btn" href="/user/'.$a['id'].'/send/gold/"><img src="/images/icons/gold_24.png"> Передать золото</a>';
	$friend = $base -> query('SELECT * FROM `friends` WHERE `user` = "'.$u['id'].'" AND `friend` = "'.$a['id'].'"') -> num_rows;
	if(!$friend) echo '<a class="btn" href="/friend/'.$id.'/"><img src="/images/icons/friend.png"> Добавить в друзья</a>';
	if(isset($uclan) AND $a['clan'] == '0'){
		if($u['clan_rank'] == 4) echo '<a class="btn" href="/clan/invite/'.$a['id'].'/"><img src="/images/icons/cross.png"> Пригласить в клан</a>';
	}
	if($uparty['first_user'] == $u['id'] AND $uparty['second_user'] != $a['id'] AND $uparty['third_user'] != $a['id']) echo '<a class="btn" href="/party/'.$a['id'].'/"><img src="/images/icons/party.png"> Пригласить в команду</a>';
	if($u['admin'] > 1) echo '<a class="btn" href="/panel/banned/block/'.$a['id'].'/"><img src="/images/icons/no.png"> Заблокировать</a>';
}

break;

case 'send_silver':

if($u['level'] < 10){
	$_SESSION['message'] = 'Передавать серебро можно с 10 уровня.';
	header('Location: /user/'.$a['id'].'/');
	exit;
}

$_POST['sum'] = fl($_POST['sum']);

if($_POST['sum'] > 0 AND $_POST['sum'] < 1000000){
	if($u['silver'] < $_POST['sum']){
		$_SESSION['message'] = 'Недостаточно серебра.';
		header('Location: /user/'.$a['id'].'/send/silver/');
		exit;
	}else{
		$base -> query('UPDATE `users` SET `silver` = `silver` + "'.$_POST['sum'].'" WHERE `id` = "'.$a['id'].'" LIMIT 1');
		$base -> query('UPDATE `users` SET `silver` = `silver` - "'.$_POST['sum'].'" WHERE `id` = "'.$u['id'].'" LIMIT 1');
		//Отправляем сообщение
		$c = $base -> query('SELECT * FROM `message_c` WHERE `kto` = "'.$a['id'].'" AND `kogo` = "1"') -> num_rows;
		if($c == 0){
		$base -> query('INSERT INTO `message_c` SET `kto` = "'.$a['id'].'", `kogo` = "1", `time` = "'.time().'"');
		}
		$base -> query('INSERT INTO `message` SET
		`kto` = "1",
		`komy` = "'.$a['id'].'",
		`text` = "'.$u['login'].' передал вам '.n_f($_POST['sum']).' серебра.",
		`time` = "'.time().'"');
		$_SESSION['message'] = 'Передача серебра прошла успешно.';
		header('Location: /user/'.$a['id'].'/');
		exit;
	}
}

echo '<div class="title">Передача серебра</div>';
echo '<center>';
echo '<form action="" method="POST">';
echo '<input type="text" name="sum" placeholder="Введите количество." /> <br/>';
echo '<input type="submit" name="send" value="Передать">';
echo '</form>';
echo '</center>';
echo '<br/><a class="btn" href="javascript:history.go(-1)"><img src="/images/icons/back.png"> Назад</a>';

break;

/*case 'send_gold':

if($u['level'] < 5){
	$_SESSION['message'] = 'Передавать золото можно с 5 уровня.';
	header('Location: /user/'.$a['id'].'/');
	exit;
}

$_POST['sum'] = fl($_POST['sum']);

if($_POST['sum'] > 0 AND $_POST['sum'] < 1000000){
	if($u['gold'] < $_POST['sum']){
		$_SESSION['message'] = 'Недостаточно золота.';
		header('Location: /user/'.$a['id'].'/send/gold/');
		exit;
	}else{
		$base -> query('UPDATE `users` SET `gold` = `gold` + "'.$_POST['sum'].'" WHERE `id` = "'.$a['id'].'"');
		$base -> query('UPDATE `users` SET `gold` = `gold` - "'.$_POST['sum'].'" WHERE `id` = "'.$u['id'].'"');
		//Отправляем сообщение
		$c = $base -> query('SELECT * FROM `message_c` WHERE `kto` = "'.$a['id'].'" AND `kogo` = "1"') -> num_rows;
		if($c == 0){
		$base -> query('INSERT INTO `message_c` SET `kto` = "'.$a['id'].'", `kogo` = "1", `time` = "'.time().'"');
		}
		$base -> query('INSERT INTO `message` SET
		`kto` = "1",
		`komy` = "'.$a['id'].'",
		`text` = "'.$u['login'].' передал вам '.n_f($_POST['sum']).' золота.",
		`time` = "'.time().'"');
		$_SESSION['message'] = 'Передача золота прошла успешно.';
		header('Location: /user/'.$a['id'].'/');
		exit;
	}
}

echo '<div class="title">Передача золота</div>';
echo '<center>';
echo '<form action="" method="POST">';
echo '<input type="text" name="sum" placeholder="Введите количество." /> <br/>';
echo '<input type="submit" name="send" value="Передать">';
echo '</form>';
echo '</center>';
echo '<br/><a class="btn" href="javascript:history.go(-1)"><img src="/images/icons/back.png"> Назад</a>';

break;*/

}

echo '</div>';

/*echo '<div class="title">Информация</div>
	<div class="txt">
	<img src="/images/icons/star.png"> Опыт: <font color="#FFF">'.n_f($a['exp']).'/'.n_f($lexp['exp']).'</font> ('.$progress.'%)<br/>
	<img src="/images/icons/arrow.png"> Регистрация: <font color="#FFF">'.tm($a['date_registr']).'</font><br/>
	<img src="/images/icons/arrow.png"> Был в сети: <font color="#FFF">'.tm($a['date_online']).'</font><br/>
	</div>
</div>
<div class="line"></div>';*/

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