<?php
include_once ('core/base.php');
falseauth();
$header = 'Помощь по игре';
include_once ('core/head.php');

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

echo '<div class="title">'.$uloc['name'].'</div>';

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

//Ищем игроков
$loc_users_q = $base -> query('SELECT * FROM `users` WHERE `world` = "'.$u['world'].'" AND `x` = "'.$u['x'].'" AND `y` = "'.$u['y'].'" AND `id` != "'.$u['id'].'" AND `date_online` > "'.(time()-600).'" ORDER BY `level` DESC');
$loc_users_nr = $loc_users_q -> num_rows;
//Ищем предметы
$loc_items = $base -> query('SELECT * FROM `locations_items` WHERE `world` = "'.$u['world'].'" AND `x` = "'.$u['x'].'" AND `y` = "'.$u['y'].'" ORDER BY `id` DESC');
$loc_items_nr = $loc_items -> num_rows;


switch($_GET['action']){

default:

echo '<center>';
echo '<div class="btn_small_pressed"><small>Игроки ('.$loc_users_nr.')</small></div> ';
echo '<a class="btn_small" href="/explore/items/"><small>Предметы ('.$loc_items_nr.')</small></a> ';
echo '</center><br/>';

//Игроки
$loc_users_q = $base -> query('SELECT * FROM `users` WHERE `world` = "'.$u['world'].'" AND `x` = "'.$u['x'].'" AND `y` = "'.$u['y'].'" AND `id` != "'.$u['id'].'" AND `date_online` > "'.(time()-600).'" ORDER BY `level` DESC');
$loc_users_nr = $loc_users_q -> num_rows;

if($loc_users_nr > 0){
	while($loc_user = $loc_users_q -> fetch_assoc()){
		$avatar='/images/skins/'.$loc_user['skin'].'_big.png';
		if($uloc['arena'] > 0){
		echo '<table width="100%" style="margin-top: 5px; border-spacing: 0px;"><tr><td style="padding: 0px; margin-right: 25px;" width="89%"><a class = "btn_table" href="/user/'.$loc_user['id'].'/"><img src="'.$avatar.'" width="24px"> '.nolinkname($loc_user['id']).'</a></td>
		<td width="1%"></td><td style="padding: 0px;" width="10%"><a class = "btn_table" href="/location/pvp/'.$loc_user['id'].'/"><img src="/images/icons/sword.png"></a></td></tr></table>';
		}else{
			echo '<a class="btn" href="/user/'.$loc_user['id'].'/"><img src="'.$avatar.'" width="24px"> '.nolinkname($loc_user['id']).'</a>';
		}
	}
}else{
	echo '<center>Здесь никого нет...</center>';
}

break;

case 'items':

echo '<center>';
echo '<a class="btn_small" href="/explore/"><small>Игроки ('.$loc_users_nr.')</small></a> ';
echo '<div class="btn_small_pressed"><small>Предметы ('.$loc_items_nr.')</small></div> ';
echo '</center><br/>';

//Если есть предметы на локации
if($loc_items_nr > 0){
	while($loc_item = $loc_items -> fetch_assoc()){
		if($loc_item['mark'] == '0') $color = 'B1B1B1';
		if($loc_item['mark'] == '1') $color = '30C030';
		if($loc_item['mark'] == '2') $color = '68A8F9';
		if($loc_item['mark'] == '3') $color = 'D8CD32';
		if($loc_item['mark'] == '4') $color = 'DD4FFF';
		if($loc_item['what'] == 'clothing') echo '<a class = "btn" href="/take/'.$loc_item['id'].'/"><img src="/images/items/'.$loc_item['type'].'/'.$loc_item['image'].'.png" width="24px" style="border: 1px solid #'.$color.';"> Поднять <font color="#'.$color.'">'.$loc_item['name'].'</font></a>';
		else echo '<a class = "btn" href="/take/'.$loc_item['id'].'/"><img src="/images/items/resource/'.$loc_item['image'].'.png" width="24px" style="border: 1px solid #'.$color.';"> Поднять <font color="#'.$color.'">'.$loc_item['name'].'</font> '.$loc_item['amount'].'шт.</a>';
	}
}else{
	echo '<center>Здесь ничего нет...</center>';
}

break;

}

echo '<br/><a class="btn" href="/location/"><img src="/images/icons/back.png"> Назад</a>';

echo '</div>';

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