- Code: Select all
<?php
require_once dirname(__FILE__)."/src/phpfreechat.class.php";
$params["serverid"] = md5("cebronx_chat.php"); // calculate a unique id for this chat
$params["title"] = "Whois online demo channel";
$pfc_config =& pfcGlobalConfig::Instance( $params );
?>
<?php
require_once dirname(__FILE__)."/src/pfcinfo.class.php";
$info = new pfcInfo( md5("Whois online demo") );
// NULL is used to get all the connected users, but you can specify
// a channel name to get only the connected user on a specific channel
$users = $info->getOnlineNick(NULL);
echo "<h1>A demo which explains how to get the connected users list</h1>";
echo '<div style="margin: auto; width: 70%; border: 1px solid red; background-color: #FDD; padding: 1em;">';
$info = "";
$nb_users = count($users);
if ($nb_users <= 1)
$info = "<strong>%d</strong> user is connected to the server !";
else
$info = "<strong>%d</strong> users are connected to the server !";
echo "<p>".sprintf($info, $nb_users)."</p>";
echo "<p>Here is the nicknames' list:</p>";
echo "<ul>";
foreach($users as $u)
{
echo "<li>".$u."</li>";
}
echo "</ul>";
echo "</div>";
?>
But some reason it always tells me that there is no one online when there is. Another thing when I go to my data/private/chat/ All I see there are folders with a lot of numbers is it possible to have probably the name of the file on those folders so I will understand them a little bit better. and Im saying this because I tried using this code to get the nicknames and what it gave me was the codes of the files instead of the nicknames.
- Code: Select all
<?
$minute=10;
$chat_dir="data/private/chat/s_81c54ef162a9cc6a34d20135e16f1fe2/nicknames/";
$users = array();
$dir_handle = opendir($chat_dir);
while (false !== ($file = readdir($dir_handle)))
{
if ($file == "." || $file == "..") continue; // skip . and .. generic files
if (time() > (filemtime($chat_dir.$file)+($minute *60))) continue; // do not count if older than specified time
$x=urldecode(base64_decode($file));
$users[] = urldecode(base64_decode($file));
}
$nd_users = count($users);
if ($nd_users==0)
{
echo "There is NOBODY in the Chatroom right now<br>";
}
else
{
echo "<table class=tbl border=1 cellspacing=0 cellpadding=3>";
echo "<tr><td class=row1>Users in the Chatroom<br>in the last $minute minutes</td></tr>";
for ($i=0; $i<$nd_users; $i++)
{
$x=$users[$i];
echo "<tr><td class=row2>$x</td><tr>";
}
echo "</table>";
}
?>
Found this code on one of your threads. Can anyone help me. I would like to announce who is in the chatroom in my index page that way the users will know if to go in and expect anyone to be in there or not. Thanks in advance for the help.