O.k., here goes:
Note: You need the chat_global.php from the sigma chat hack provided by sigmachat.
1. Create a new file called chat_cache.php or something else, and paste this into it:
PHP Code:
<?php
// replace with actual path to your forum main directory, no trailing slash
chdir("/path/to/forum");
require_once("./global.php");
require_once("./chat_global.php");
error_reporting(E_ALL & ~E_NOTICE);
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT','chat_online');
$globaltemplates = array("sigmachat_chatting",);
$SIGMACHAT_CP_PASSWORD_MD5 = md5($SIGMACHAT_CP_PASSWORD);
$womurl = "http://$SIGMACHAT_SERVER/vbwho.pl?id=$SIGMACHAT_CHAT_ROOM_ID&pw=$SIGMACHAT_CP_PASSWORD_MD5";
$users = array();
$user_count = -1;
$wom_hits_remaining = 0;
$wom_message = '';
if($womh = fopen($womurl, 'r'))
{
while(!feof($womh))
{
$womcontent = fgets($womh, 1048576);
if($user_count == -1)
{
$wom_hits_remaining = $womcontent;
$user_count++;
}
else if( ($user_count == 0) && ($wom_hits_remaining < 0) )
{
die;
}
else
{
if($womcontent != '')
$users[] = rtrim($womcontent);
$user_count++;
}
}
fclose($womh);
}
else
{
die;
}
$SIGMACHAT_CHATTING_COUNT = $user_count;
if ($SIGMACHAT_CHATTING_COUNT > 0) $SIGMACHAT_CHATTING_COUNT = "Chatting: " . $SIGMACHAT_CHATTING_COUNT;
else $SIGMACHAT_CHATTING_COUNT = "";
foreach($users as $username)
{
$SIGMACHAT_USERNAME = "$username";
if ($bbuserinfo = $DB_site->query_first('SELECT userid, usergroupid, username, salt FROM ' . TABLE_PREFIX . 'user WHERE username = "' . addslashes(htmlspecialchars_uni($username)) . '"'))
{
$SIGMACHAT_USERNAME = "<a href=\"member.php?u=" . $bbuserinfo[userid] . "\">" . $bbuserinfo[username] . "";
}
$chat_names .= "<a href=\"member.php?u=" . $bbuserinfo[userid] . "\">" . $bbuserinfo[username] . "" . ", ";
}
$chat_names = addslashes($chat_names);
$DB_site->query("UPDATE " . TABLE_PREFIX . "template SET template=\"$SIGMACHAT_CHATTING_COUNT\", template_un=\"$SIGMACHAT_CHATTING_COUNT\" WHERE title='sigmachat_chatting_cache_bit'");
$DB_site->query("UPDATE " . TABLE_PREFIX . "template SET template=\"$chat_names\", template_un=\"$chat_names\" WHERE title='sigmachat_chatting_cache'");
?>
2. Update the first line in the code above with the right path to your forum home dir on your server.
3. Create two empty templates: sigmachat_chatting_cache_bit and sigmachat_chatting_cache
4. Edit index.php
Find:
Add after:
PHP Code:
'sigmachat_chatting_cache',
'sigmachat_chatting_cache_bit',
Find:
PHP Code:
$today = vbdate('Y-m-d', TIMENOW, false, false);
Add after:
PHP Code:
$sigmachat_chatting = $templatecache['sigmachat_chatting_cache'];
$sigmachat_chatting_bit = $templatecache['sigmachat_chatting_cache_bit'];
5. Use $sigmachat_chatting_bit and $sigmachat_chatting in your FORUMHOME template. The first has the number of members in the chat room, and the second has the list of the members and their profile links.
6. Add a cron job to your server, ever 10 minutes. Example:
*/10 * * * * /usr/bin/php /path/to/forum/chat_cache.php > /dev/null 2>&1
7. If you have a problem, feel free to ask, but keep in mind that you need to back up your files and templates in case it doesn't work for you.