<?php
	
	require_once '../includes/start.php';
	require_once '../includes/function.php';
	require_once '../includes/header1.php';
	if($game==0 OR $level==0 OR $ban!=0){
   		echo "<title>Доступ закрыт!!!</title>";
	 	echo "<script type=\"text/javascript\">createPopup().show( 0, 0, 0, 0, 0 );</script>";
	 	echo "<body oncontextmenu=\"return false;\"><body onselectstart='return false' oncopy='return false'><body onselectstart=\"return false\" oncopy=\"return false\"><body onload=\"digitalWatch()\">";
		echo '<div class="blok3"><img src="/images/errors.png" width="200px"/></div><div class="blok3"><b>Вы не авторизованный или заблокированный пользователь или вы не достигли условий для доступа на страницу!!!</b><br/><a href="/?sign_in=1"><font color="#4EEE94"><b>Авторизуйтесь</font></a></b> или <a href="/reg.php"><font color="#4EEE94"><b>Зарегистрируйтесь</b></font></a></div>';

}else{
	switch ($act) {
	default:
	echo "<title>Карта</title>"; 
	echo "<script type=\"text/javascript\">createPopup().show( 0, 0, 0, 0, 0 );</script>";
	echo "<body oncontextmenu=\"return false;\"><body onselectstart='return false' oncopy='return false'><body onselectstart=\"return false\" oncopy=\"return false\"><body onload=\"digitalWatch()\">";
	echo '<div class="razd"></div>';
	div('<b>Карта</b>','top-nav1');
	echo '<div class="razd"></div>';
	echo '<div class="top-nav1"><a href="?act=portal"><b>Ваши порталы</b></a></div>';
	echo '<div class="razd"></div>';
	$x12=$_GET['x'];
	$y12=$_GET['y'];
	$x2 = mysql_result(mysql_query("SELECT MAX(x) FROM `sector_loc`;"), 0);
	$y2 = mysql_result(mysql_query("SELECT MAX(y) FROM `sector_loc`;"), 0);
			if(!$_POST)
	{

$mm = mysql_query("SELECT * FROM `sector_loc` WHERE `x`='".$x12."' AND `y`='".$y12."' LIMIT 1");
$map = mysql_fetch_array($mm);  
$x1=$x12-3;
$y1=$y12+3;
$wave=1;
$table=1;
echo '<div class="window" align="center"><table cellspacing="0" cellpadding="0">';
while($wave<='49'){
if($table=='8'){
$table='1';
$x1=$x1-'7';
$y1=$y1-'1';}
$mm1 = mysql_query("SELECT * FROM `sector_loc` WHERE `x`='".$x1."' and `y`='".$y1."' ORDER BY `loc` DESC LIMIT 1");
$map1 = mysql_fetch_array($mm1);


if($table=='1')echo'<tr border="0" HEIGHT="18">';
echo'<td BGCOLOR="black">';
$sp=rand(1,10);
if($map1['loc']==7)echo '<img src="../images/space/sun.jpg" alt="" />';
if($map1['loc']==6)echo '<img src="../images/space/zellnaga.jpg" alt="" />';
if($map1['loc']==5)echo '<img src="../images/space/teleport.jpg" alt="" />';
if($map1['loc']==4)echo '<img src="../images/space/moon'.$map1['type'].'.jpg" alt="" />';
if($map1['loc']==3)echo '<img src="../images/space/l'.$map1['type'].'.jpg" alt="" />';
if($map1['loc']==2)echo '<a href="/game/planet.php?act=pl&p=1"><img src="../images/planet/'.$map1['type'].'.jpg" width="50px" alt="" /></a>';
if($map1['loc']==1)echo ''.otr($map1['type'], $map1['fr_id'], $fr_id, $map1['uid'], $use_id).'';
if($map1['loc']=='')echo '<img src="../images/space/space'.$sp.'.jpg" width="45px" alt="image" />';
echo'</td>';
if($table=='7')echo'</tr>';

$wave++;
$table++;
$x1++;
}

	echo '</table></div><div class="blok">';
	echo '<div class="razd"></div>';
	echo '<a href="?x='. ($x12-1) .'&amp;y='. $y12 .'"><img src="../images/left.png" alt="image" /></a>';
	echo '<a href="?x='. ($x12+1) .'&amp;y='. $y12 .'"><img src="../images/right.png" alt="image" /></a><br/>';
	echo '<div class="razd"></div>';
	echo '<a href="?y='. ($y12+1) .'&amp;x='. $x12 .'"><img src="../images/up.png" alt="image" /></a>';
	echo '<a href="?y='. ($y12-1) .'&amp;x='. $x12 .'"><img src="../images/down.png" alt="image" /></a><br/>';
	echo '<div class="razd"></div>';
	echo '</div>'; 

			echo '<center><div class="ch"><div class="razd"></div><form action="" method="POST">x <input type="text" value="'.check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($x12))))))).'" size="2" name="x" />y<input type="text" value="'.check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($y12))))))).'" size="2" name="y" /><input type="submit" name="submit" value="Посмотреть"/></form><div class="razd"></div></div></center>';
	}
	else
	{
	$xx = check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($_POST['x'])))))));
	$yy = check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($_POST['y'])))))));
	if($xx>$x2 or $yy>$y2 or $xx<=0 or $yy<=0){echo '<div class="blok3">Такой локации не существует!<br/><a href="?x='.$x12.'&amp;y='.$y12.'"></div><div class="blok"><b>Назад</b></a></div>';}else{
	header("Location: sector.php?&x=$xx&y=$yy");}
	}
	
	
break;
case 'portal':
echo "<title>Ваши порталы</title>"; 
echo "<script type=\"text/javascript\">createPopup().show( 0, 0, 0, 0, 0 );</script>";
echo "<body oncontextmenu=\"return false;\"><body onselectstart='return false' oncopy='return false'><body onselectstart=\"return false\" oncopy=\"return false\"><body onload=\"digitalWatch()\">";	
echo '<div class="razd"></div>';
div('<b>Ваши порталы</b>','top-nav1');
echo '<div class="razd"></div>';
			$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `sector_loc` WHERE `loc`=5 AND `uid`='".$use_id."';"), 0);
			$PAGINGS = new PAGINGS($elem, "SELECT * FROM `sector_loc` WHERE `loc`=5 AND `uid`='".$use_id."' ORDER BY `id` DESC");
			if($PAGINGS->count_get > 0)
			{
				while($row = mysql_fetch_array($PAGINGS->get))
				{
					echo '<div class="conts">';
					echo '<img src="../images/space/teleport.jpg" alt="" /> <a href="sector.php?x='.$row['x'].'&amp;y='.$row['y'].'">Портал</a> [x:'.$row['x'].' y:'.$row['y'].']';

					echo '</div>'; 

					++$i;
				}
				if($count>$elem)echo $PAGINGS->Links('?');
			}
			else
			{
				div('<center><b>Нет порталов под вашим контролем</b></center>','window');
			}
echo '<div class="razd"></div><div class="blok"><a href="sector.php?x='.$xnum.'&y='.($ynum+3).'"><b>Назад</b></a></div>';
break;
}
}
	echo '<div class="razd"></div>';
	echo '<center><div class="blok2"><a href="../"><b>На Главную</b></a></div></center>';
	echo '<div class="razd"></div>';
	require_once '../includes/footer1.php';
?>