header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
include_once('inc/common.php');
ChatServer::purgeExpired(); function numusers( $room = "" )
{
if($room) {
$stmt = new Statement("SELECT COUNT(*) AS numb FROM {$GLOBALS['fc_config']['db']['pref']}connections WHERE userid IS NOT NULL AND roomid=?");
$rs = $stmt->process($room);
} else {
$stmt = new Statement("SELECT COUNT(*) AS numb FROM {$GLOBALS['fc_config']['db']['pref']}connections,{$GLOBALS['fc_config']['db']['pref']}rooms
WHERE userid IS NOT NULL AND ispublic IS NOT NULL
AND {$GLOBALS['fc_config']['db']['pref']}connections.roomid = {$GLOBALS['fc_config']['db']['pref']}rooms.id");
$rs = $stmt->process();
}
$rec = $rs->next();
return $rec?$rec['numb']:0;
}
function usersinroom( $room = "" )
{
$cms = $GLOBALS['fc_config']['cms'];
$list = array();
if($room) {
$stmt = new Statement("SELECT userid, state, color, lang, roomid FROM {$GLOBALS['fc_config']['db']['pref']}connections WHERE userid IS NOT NULL AND roomid=?");
$rs = $stmt->process($room);
} else {
$stmt = new Statement("SELECT userid, state, color, lang, roomid FROM {$GLOBALS['fc_config']['db']['pref']}connections WHERE userid IS NOT NULL");
$rs = $stmt->process();
}
while($rec = $rs->next()) $list[] = array_merge($cms->getUser($rec['userid']), $rec);
return $list;
}
function roomlist()
{
$list = array();
$stmt = new Statement("SELECT * FROM {$GLOBALS['fc_config']['db']['pref']}rooms WHERE ispublic IS NOT NULL order by ispermanent");
$rs = $stmt->process(); while($rec = $rs->next()) $list[] = $rec;
return $list;
}
$rooms = roomlist();
$roomnumb = sizeof($rooms);
$usernumb = numusers();
$body = <<<EOF
<BR>><a href="/threads/chat/flashchat.php" target="_blank">Chatroom</a> (<?= $usernumb ?> user<? if ($usernumb != 1) echo "s" ?> in <?=$roomnumb ?> room<? if ($roomnumb != 1) echo "s"; ?>)
<ul id="roomList">
<?php if($roomnumb) { ?>
<?php foreach($rooms as $room) { ?>
<li><strong><a href="#" onclick="javascript:toggleUserList('room_<?=$room[id]?>')"><?=$room[name]?> (<?= numusers($room[id]) ?>)</a></strong>
<?php
$users = usersinroom($room[id]);
if ($users) {
echo "<ul class="userList" id="room_".$room[id]."">";
foreach( $users as $user ) {
echo "<li>".$user[login] . "</li>";
}
echo "</ul>";
}
?> </li>
<?php } ?>
<?php } ?>
</ul>
EOF;