<?

header("Cache-Control: no-cache");
if ($ver=="wml")header ("Content-type:text/vnd.wap.wml; charset=utf-8");
else header("Content-Type:text/html; charset=UTF-8");

$ref=rand(10000,1000000);
require("inc.php");
$link = connect_db();

if ($ver=="wml"){
echo $xml;
echo $dtd;
echo "<wml>";
echo "<head><meta http-equiv=\"Cache-Control\" content=\"no-cache\" forua=\"true\"/></head>";
echo "<card id=\"who\" title=\"Кто-Где?\">";
echo "<do type=\"prev\" label=\"Назад\"><prev/></do>";
echo "<p align=\"center\">";
}else{
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">";
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css.css\"/>";
echo "<title>Кто-Где?</title>";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/></head><body>";
echo "<div align=\"center\">";
}
echo "<small>";
$tm = time()-300;
$ingame = "";
$outgame = "";
$res = @mysql_query ("Select * from room23 WHERE id > '".$tm."' group by usid order by id desc");
$kol = mysql_affected_rows(); 
$roommaf = @mysql_fetch_array(@mysql_query ("Select name from rooms where rm='23' LIMIT 1;"));
echo "".$roommaf[0]."(".$kol."):<br/>\n";
echo "<b>В игре:</b><br/>\n";
for ($k = 0; $k < $kol; $k++){    
$lines = mysql_fetch_array ($res);
$user = $lines["who"];
$user_id = $lines["usid"];
$r = mysql_query("select * from ingame1 WHERE gamer_id = '".$user_id."'"); 
$a = mysql_fetch_array($r);
$id_in_game = $a["id_in_game"];
if (mysql_affected_rows()!=0) $ingame = $ingame."$user($id_in_game), "; 
else $outgame = $outgame."$user, ";
}      
unset($lines);
echo "$ingame<br/>\n";
echo "<b>Вне игры:</b><br/>\n";
echo "$outgame<br/>\n";
echo $divide;

for ($num = 13; $num <= 22; $num++)
{
$room = "room".$num;
$tm = time()-300;
$res = @mysql_query ("Select who,hid from $room WHERE id > '".$tm."' group by who order by id desc");
echo " ".mysql_error()." ";
$kol = mysql_affected_rows();
$kol_all += ($kol);
}
echo "<b>Посольства</b>(".$kol_all.")<br/>";
echo $divide;
for ($num = 0; $num <= 12; $num++){
$room = "room".$num;
$tm = time()-300;
$res = @mysql_query ("Select who,hid from $room WHERE id > '".$tm."' group by who order by id desc");
echo " ".mysql_error()." ";
$kol = mysql_affected_rows();
$kol_all += ($kol);
$roomselect = @mysql_query ("Select name from rooms where rm=$num");
$rooms = @mysql_fetch_array($roomselect);
$roomname=$rooms["name"];
echo "<b>$roomname</b>(".($kol)."):<br/>";
	
for ($k = 0; $k < $kol; $k++){
$lines = mysql_fetch_array ($res);
$user = $lines["who"];
$hd = $lines["hid"];
if ($hd != 1)echo "$user";
else if ($row["level"] > 6) echo "$user(invisible)";
if (($k+1) != $kol) print ', ';
}
if($kol>0) echo "<br/>";
unset($lines);
}
echo $divide;
echo "<b>Всего: ".$kol_all."</b><br/>";
echo $divide;
print "<a href=\"reg.php?ver=$ver&amp;mod=reghelp\">Регистрация</a><br/>";
print "<a href=\"index.php?ver=$ver\">&#8592; Назад</a><br/>";
echo "</small>";
if ($ver=="wml")echo "</p></card></wml>";
else echo "</div></body></html>";
mysql_close ($link);
?>