<?

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");
if(isset($HTTP_GET_VARS['rm'])) {$rm = $HTTP_GET_VARS['rm'];}
if (!ctype_digit($rm)) { header("Location: index.php"); die; }
$rm = mysql_escape_string($rm);
if ($rm!=23){

if($rm==10) $takep="&amp;pwd=$pwd&amp;ref=$ref";
else if($mod=="privat") $takep="&amp;mod=$mod&amp;ref=$ref";
else $takep="&amp;ref=$ref";

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

$room = "room".$rm;
$tm = time()-300;
$res = @mysql_query ("Select who,hid from $room WHERE id > '".$tm."' group by who order by id desc");
if (mysql_affected_rows() == 0) {
echo "Никого нет. Пропали безвести (:<br/>";
} else {
$kol = mysql_affected_rows();


$roomselect = @mysql_query ("Select name from rooms where rm=$rm");
$rooms = @mysql_fetch_array($roomselect);
$roomname=$rooms["name"];

echo "<a href=\"chat.php?$ses&amp;rm=$rm$takep\">$roomname(".($kol)."):</a><br/>---<br/>";
echo "<b>В общей:</b><br/>";
for ($k = 0; $k < $kol; $k++){
$lines = mysql_fetch_array ($res);
$user = $lines["who"];
$hd = $lines["hid"];

$res1 = @mysql_query ("Select id from users WHERE user='".$user."'");
$lines1 = mysql_fetch_array ($res1);
$nk = $lines1["id"];
		
if ($hd != 1) echo "<a href=\"inside.php?$ses&amp;rm=$rm&amp;nk=$nk&amp;ref=$ref\">$user</a>";
else if ($row["level"] > 6) echo "<a href=\"inside.php?$ses&amp;rm=$rm&amp;nk=$nk&amp;ref=$ref\">$user(!)</a>";
if (($k+1) != $kol) print ', ';
}
if($kol>0)echo "<br/>";
unset($lines);
unset($lines1);
}
echo $divide;
if (isset($rm)) echo "<a href=\"chat.php?$ses&amp;rm=$rm&amp;ref=$ref\">В чат</a><br/>";
echo "<a href=\"enter.php?$ses&amp;ref=$ref\">Прихожая</a><br/>";
echo $fsize2;
if ($ver=="wml")echo "</p></card></wml>";
else echo "</div></body></html>"; 
}else{
if ($ver=="wml"){
echo $xml;
echo $dtd;
echo "<wml>\n";
echo "<head><meta http-equiv=\"Cache-Control\" content=\"no-cache\" forua=\"true\"/></head>\n";
echo "<card id=\"who\" title=\"Кто тут?\">\n";
echo "<p>\n";                          
}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;
$rmaf = "room".$rm;
$ringame = "ingame".$rm;
$tm = time()-300;
$ingame = "";
$outgame = "";
$res = @mysql_query ("Select * from $rmaf WHERE id > '".$tm."' group by usid order by id desc");
$kol = mysql_affected_rows();
//if($num!=0)echo "<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 $ringame 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/>";
echo $divide;
echo "<a href=\"chat.php?$ses&amp;rm=$rm&amp;ref=$ref\">В игру</a><br/>\n";
echo $fsize2;
if ($ver=="wml")echo "</p></card></wml>";
else echo "</div></body></html>";
}
mysql_close ($link);
?>