Файл: soc-set/moduls/chat/who.php
Строк: 40
<?php
require_once('../../core/start.php');
check_auth();
switch ($select) {
default:
head('Чат: Кто где');
panel();
$all = DB::$dbs->querySingle("SELECT COUNT(`id`) FROM ".CHAT_ROOM."");
if (empty($all)) {
echo DIV_BLOCK . 'Комнат нет' . CLOSE_DIV;
} else {
$sql = DB::$dbs->query("SELECT * FROM ".CHAT_ROOM." ORDER BY `id` DESC");
while($room = $sql -> fetch()) {
echo DIV_BLOCK;
$online = DB::$dbs->querySingle("SELECT COUNT(`user_id`) FROM ".USERS." WHERE `location` LIKE '%Комната: ".$room['name']."%' AND `last_time` > ?", array(time() - 300));
echo '<a href="'.HOME.'/chat/'.$room['id'].'/">'.$room['name'].'</a> [<b>' . $online . '</b> чел.]<br />';
if (empty($online)) {
echo 'В комнате никого нет...<br />';
} else {
$sql2 = DB::$dbs->query("SELECT `user_id` FROM ".USERS." WHERE `location` LIKE '%Комната: ".$room['name']."%' AND `last_time` > ?", array((time() - 300)));
while($ank = $sql2 -> fetch()) {
echo userLink($ank['user_id']) . ', ';
}
}
echo CLOSE_DIV;
}
}
echo DIV_GO . '<a href="'.HOME.'/">Главная</a> / <a href="'.HOME.'/chat/">Чат</a> / <b>Кто где</b>' . CLOSE_DIV;
break;
case 'room':
$room = DB::$dbs->queryFetch("SELECT * FROM ".CHAT_ROOM." WHERE `id` = ? ",array(num($_GET['room'])));
if (empty($room)) {
header("Location: ".HOME."");
}
head('Чат: Кто в комнате '.$room['name'].'');
panel();
echo DIV_BLOCK;
$online = DB::$dbs->querySingle("SELECT COUNT(`user_id`) FROM ".USERS." WHERE `location` LIKE '%Комната: ".$room['name']."%' AND `last_time` > ?", array((time() - 300)));
echo '<a href="'.HOME.'/chat/'.$room['id'].'/">'.$room['name'].'</a> [<b>' . $online . '</b> чел.]<br />';
if (empty($online)) {
echo 'В комнате никого нет...<br />';
} else {
$sql2 = DB::$dbs->query("SELECT `user_id` FROM ".USERS." WHERE `location` LIKE '%Комната: ".$room['name']."%'");
while($ank = $sql2 -> fetch()) {
echo userLink($ank['user_id']) . ', ';
}
}
echo CLOSE_DIV;
echo DIV_GO . '<a href="'.HOME.'/">Главная</a> / <a href="'.HOME.'/chat/">Чат</a> / <a href="'.HOME.'/chat/'.$room['id'].'/">'.$room['name'].'</a> / <b>Кто в комнате</b>' . CLOSE_DIV;
break;
}
require_once('../../core/stop.php');
?>