<?
require("../config.php");
require("../func.php");
head();
aut();
ban();
$room = num($_GET['room']);
$room_info = mysql_fetch_assoc(mysql_query("SELECT * FROM `room` WHERE `id` = '".$room."'"));

####################Запись онлайна##################
mysql_query("UPDATE `profile` SET `online` = '".$room."' WHERE `id` = '".$id_session."'");
####################################################

if ( empty ( $room_info['id'] ) ) {
    echo "<div class=\"head\">Ошибка</div><div class=\"main\">";
    echo 'Комната не найдена';
    navig();
    foot();
    exit();
}

if ( $config['status_chat'] == 0) {
    echo "<div class=\"head\">Чат</div><div class=\"main\">";
    echo link1 . 'Чат отключен' . div;
    navig();
    foot();
    exit();
}

echo "<div class=\"head\">Кто где</div>";

$room_kol = mysql_result(mysql_query("SELECT count(*) FROM `room`"), 0);
if($room_kol>0)
{
$result = mysql_query("SELECT * FROM room");
while($room = mysql_fetch_assoc($result)){
    
    $rid = $room['id'];
    $query = mysql_query("SELECT COUNT(*) FROM `profile` WHERE `online` = 'room".$rid."' AND `time` > '".(time()-600)."' ORDER BY `time`");
    $inroom = mysql_result($query, 0);
    
echo link1 . "<a href=\"chat.php?room=".$room['id']."&vhod=1\">".$room['room']."</a> (".$inroom.")" . div;

///////////////////////////////////
$online = mysql_result(mysql_query("SELECT count(*) FROM `profile` WHERE `online` = 'room".$room['id']."' AND `time` > '".(time()-600)."' ORDER BY `time`"), 0);
if ( $online == 0 ) {
    echo link2 . 'Пусто' . div;
} else {
    
    $res = mysql_query("SELECT * FROM `profile` WHERE `online` = 'room".$room['id']."' AND `time` > '".(time()-600)."' ORDER BY `time`");
echo link2;
while($user = mysql_fetch_assoc($res)){
    
    echo user($user['id']) .', ';
    
    }
echo div;
}
///////////////////////////////////
}


} else { 
    
    echo 'Комнат нет...';
    
}


navig();
foot();
?>