<?
ob_start();
require'sys/head.php';
require'sys/conf.php';
require'sys/sess.php';
require'otsev.php';
 if(!empty($_GET['map'])){$map = $_GET['map'];} else {$map= '';}
 switch($map){
default:
echo"<br><a href=maps.php?map=2&der=$key&str=>Карта Мира</a>";
echo'<FORM ACTION="maps.php?der='.$key.'&map=1" METHOD="POST">';?>
Страна1:<br/>
<input format='*N' name='str1'/><br/>
Страна2:<br/>
<input format='*N' name='str2'/><br/>
<input type="submit" value="Вперёд">
</FORM><?
echo'<br/><a href="game.php?der='.$key.'">В страну</a><br/>';
break;
case 1:
$g1=$_POST['str1'];$g2=$_POST['str2'];
$id1=mysql_fetch_array(qw("SELECT datareg FROM gos WHERE strana='$g1'"));
$id2=mysql_fetch_array(qw("SELECT datareg FROM gos WHERE strana='$g2'"));
$idd1=$id1['datareg'];$idd2=$id2['datareg'];

$in1=mysql_fetch_row(qw("SELECT COUNT(*)  FROM gos WHERE datareg<'$idd1' LIMIT 0,1"));$nu1=$in1[0];
$in2=mysql_fetch_row(qw("SELECT COUNT(*)  FROM gos WHERE datareg<'$idd2' LIMIT 0,1"));$nu2=$in2[0];
if($nu1<=0){$nu1=1;}else{}
if($nu2<=0){$nu2=1;}else{}
$nu3=$nu1-$nu2;
if($nu3<0){$nu3=-$nu3;
echo"Страна <u>$g1</u> находится через <u>$nu3</u> гос. западней страны <u>$g2</u><br/>";}else{
echo"Страна <u>$g1</u> находится через <u>$nu3</u> гос. восточней страны <u>$g2</u><br/>";}
echo'<a href="game.php?der='.$key.'">В страну</a><br/>';
break;
case 2:
 $res1 = qw("SELECT COUNT(*) FROM gos ");
  $row = mysql_fetch_array($res1);{
 $total = $row[0];
}
echo"<u><b>Карта мира</b>(стран<b>$total</b>)</u><br/>";
$idd=$re1['datareg'];
$in=mysql_fetch_row(qw("SELECT COUNT(*)  FROM gos WHERE datareg<'$idd'"));$num=$in[0]+1;
echo"<b>ВАШ ИНДЕКС НА КАРТЕ - $num</b><br/>";
/////////////////////////////////////////////////////////////////////////////////////////////
$sum = 20; // число записей на странице
$result = qw("SELECT count(*) as a from gos"); 
$arr = mysql_fetch_row($result);$rec = $arr[0];
if(!isset($_GET['str'])){$str = 0;}else
{$str = $_GET['str'];}$start = $str * $sum;
$v=0;
$s1=$sum*$str;$v=$v+$s1;
$fn=round(((1+$num)/$sum)-1);if($fn<0){$fn=0;}else{}
 echo "<a href=maps.php?map=2&str=$fn&der=$key><b>Ваше гос-во</b></a><br/>";
$r = qw("SELECT * FROM gos order by `datareg` asc LIMIT $start, $sum");
$n = mysql_num_rows($r);for ($i = 0; $i < $n; $i++){
////////////////вывод
$m= mysql_fetch_array($r);	$v++;		   
echo"<b>$v. </b>$m[strana]<br/>";
////////////////
}
///////////////навигация

if ($str > 0){$p = $str - 1;
echo "<a href=maps.php?map=2&der=$key&str=$p>На запад</a>";}
$str++;if($start + $n < $rec)
echo"<b>||</b>";
echo "<a href=maps.php?map=2&der=$key&str=$str>На восток</a>"; 
$go=round($rec/$sum);

echo"<br/>-------";

echo "<br><a href=maps.php?map=2&der=$key&str=>начало запада</a>";
echo "<br><a href=maps.php?map=2&der=$key&str=$go>конец востока</a>"; 

//////////////	   

echo'<br/><a href="game.php?der='.$key.'">В страну</a><br/>';
break;
}
echo'</div><div class="knews"><a href="out.php?der='.$key.'">Выход</a><br/>';
require'sys/foot.php';
?>
