<?

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");

require("inc.php"); 
$link = connect_db();
list($row, $id, $ps, $fsize1, $fsize2) = check_login($link);
require("version.php");

for ($n = 0; $n <= 22; $n++){
$room = "room".$n;
$tm = time()-300;
$r = @mysql_query ("Select who from $room WHERE id > '".$tm."' group by who order by id desc;");
$asnum = mysql_affected_rows();
$siz[$n] = $asnum;
@$kol = $kol + $asnum;
$kolp=$siz[13]+$siz[14]+$siz[15]+$siz[16]+$siz[17]+$siz[18]+$siz[19]+$siz[20]+$siz[21]+$siz[22];
}

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 "<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=\"left\">";
}
echo $fsize1;

for ($s = 0; $s <= 12; $s++){
$room = "room".$s;
$tmr = time()-300;
$pr = @mysql_query ("Select who from $room WHERE id > '".$tmr."' group by who order by id desc;");
$asnums = mysql_affected_rows();
$sizn[$s] = $asnums;
@$kolp = $kolp + $asnums;
}
echo "<a href=\"enter.php?$ses&amp;ref=$ref\">Основные комнаты($kolp):</a><br/>";
echo $divide;
echo "<u>Посольства:</u><br/>";
echo $divide;

$roomselect = @mysql_query ("Select name,rm from rooms order by pos limit 13,22;");
while($rooms = @mysql_fetch_array($roomselect)) {
$roomname=$rooms["name"];
$rm=$rooms["rm"];
$room="room".$rm;
$tm = time()-300;
$res = @mysql_query ("Select who from $room WHERE id > '".$tm."' group by who order by id desc;");
echo " ".mysql_error()." ";
$kol = mysql_affected_rows();
$siz[$rm] = $kol;
echo "<a href=\"chat.php?$ses&amp;rm=$rm&amp;ref=$ref\">$roomname($siz[$rm]):</a><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);
}
$tm = time()-300;
$res = @mysql_query ("Select * from room23 WHERE id > '".$tm."' group by usid order by id desc");
$kol = mysql_affected_rows(); 
@$kolm = $kolm + $kol;
$lines = mysql_fetch_array ($res);
echo $divide;
$roommaf = @mysql_fetch_array(@mysql_query ("Select name from rooms where rm='23' LIMIT 1;"));
echo "<a href=\"chat.php?$ses&amp;rm=23&amp;ref=$ref\">".$roommaf[0]."(".$kolm."):</a><br/>\n";
echo $divide;
$vsego = $kolp + $kol_all + $kolm;
echo "<b>Всего: ".$vsego."</b><br/>";
echo $divide;
if (isset ($rm)) echo "<a href=\"chat.php?$ses&amp;rm=$rm&amp;ref=$ref\">&#8592; В чат</a><br/>";
echo "<a href=\"enter.php?$ses&amp;ref=$ref\">&#8592; Прихожая</a><br/>";
echo $fsize2;
if ($ver=="wml")echo "</p></card></wml>";
else echo "</div></body></html>";
mysql_close ($link);
?>