PDA

View Full Version : phpMyChat - # of users in CHAT


jamoss
04-18-2002, 10:00 PM
Below is a hack I modified to show the number of users in your integrated phpMyChat.

Requirements:
phpMyChat tables must be in the same database as vBulletin tables!

1. Add this code...
* If you want this to show up in your HEADER, you must add it to global.php

* If you want this to show up on the body of your home page, add it to index.php

~~~~~~~~~~~~~~~~
//CHAT USER COUNT
// Cleanup Old Users
// 240 = Wait 4 mins before deleteing inactive users

//CHAT DIRECTORY GOES HERE
$chatdir='./chat'

$DB_site->query("DELETE from c_users where u_time < ".(time() - 240)." and u_time > 0");

$numchattersa = $DB_site->query_first("SELECT count(username) AS username FROM c_users");

$numchatters = $numchattersa[username];
if ($numchatters==1) {
$membertext="member";
$istext="is";
}
else {
$membertext="members";
$istext="are";
}

$chatinfo = "&nbsp;There $istext <font color=red>$numchatters</font> $membertext in <a href=$chatdir/index.php3 >CHAT</a>";
//END CHAT USERS
~~~~~~~~~~~~~~~~

2. Add the variable $chatinfo in whatever template (spot) you want to put this phrase.

NOTES:
* It will use the correct english for all numbers - example:

There are 0 members in chat
There is 1 member in chat
There are 43 members in chat

* Example on http://www.babynames.com/boards

Cheers!
Jennifer.

Velocd
04-20-2002, 12:24 AM
Sorry, but this has already been released by Mem and me sometime before, so its not needed.

Reference:
https://vborg.vbsupport.ru/showthread.php?s=&threadid=37397

jamoss
04-20-2002, 12:37 AM
I said in my original message that it was a hack I **MODIFIED**

This version explains how to put it into the HEADER, it eliminates the need to create a custom template, and also puts in the correct English for all situations.

Jennifer.

Velocd
04-20-2002, 03:07 PM
Don't get touchy about it, I was just saying. Its nicer to put things in templates then headers, easy to modify. ;)