View Full Version : [BETA] Online Users Listing
Here is the long awaited (yeah right :) ) Online Users hack as shown at http://www.baseballboards.com/boards/
and referenced in kevinho's post.
Anyway, I stuck it in its own php file for ease of installing when vB updates are released.
To Do List:
Add javascript radio buttons to the right of the refresh button which easily allow the current user to change their "invisible to online list" profile setting
Include support for the following URLs:
member.php?action=clearcookies - AKA logout
index.php?action=showsmilies - Showing Smilies
index.php?action=showbbcode - Showing BBCode
showthread.php?postid=455277#post455277
Known Bugs:
I know there are URLs I'm forgetting, I usually wait until it says "Unknown Location" then I check to see what the URL is.
It can be slow if your tables are huge
To install you need two things:
A php file called anything you want (or member.php)
Your browser opened to your board/admin to add two new templates
Create the aforementioned PHP file or feel free to open member.php and pick a nice place.
Paste the following into your file of choice:
Matt 8-29-00
Look at the code a few messages down!!
/Matt 8-29-00
Ugly, eh? :D
Create a template called whoisonline and fill it with:
<HTML>
<HEAD>
<title>$bbtitle - Online Now!</title>
</HEAD>
<body bgcolor="#ffffff" text="#000000" id=all>
<table border="0" width="100%"><tr>
<td valign="top" align="left"></td>
<td valign="middle" align="center" nowrap>
</td></tr></table>
<a href="javascript:location.reload( )"><FONT SIZE="2" FACE="arial, helvetica">Refresh</font></a>
<table border=0 cellpadding=4 border=0 cellspacing=1 width=100%>
<tr bgcolor="#113274"><TD COLSPAN=2>
<table width="100%" border=0 cellpadding=0 cellspacing=0>
<tr><td align="left" valign="middle">
<FONT SIZE="2" FACE="arial, helvetica" color="#FFFFFF"><B>Online Users</B></font></td>
<td align="right" valign="middle">
<FONT SIZE="2" FACE="arial, helvetica" color="#FFFFFF"><B>Location</B></font></td>
</td></tr></table>
</td></tr>
$whoisonlinebits
</table>
and then one called whoisonlinebit and fill it with:
<tr><td bgcolor="#C3C3EB"><FONT SIZE="2" FACE="arial, helvetica"><a href="member.php?action=getinfo&userid=$userid">$username</a> <a href="private.php?action=newmessage&toid=$userid" target="_blank"><img src="images/pm1.gif" border=0></img></a></font></td>
<td bgcolor="#AAAAE6"><FONT SIZE="2" FACE="arial, helvetica"><a href="$locationLink" target="_blank">$location</a></font></td>
</tr>
NOTE: If you do not have private messaging installed (why not???!?!) then remove this line:
<a href="private.php?action=newmessage&toid=$userid" target="_blank"><img src="images/pm1.gif" border=0></img></a>
That should do it! All you have to do is create a link for it such as http://www.baseballboards.com/boards/whoisonline.php?action=onlineusers and then you'll get a nice list.
I would appreciate help on cleaning / optimizing the code and any URLs that I forgot cases for.
Thanks!!
--
Matt
[Edited by mrogish on 08-29-2000 at 10:32 PM]
Cool, I was waiting for someone to release this
http://216.10.26.98/vb/index.php - click the Whos online link.
Nice job, is there any chance of getting it to show where the guests are browsing?
I changed a bit of the html, it uses the meta refresh instead of the java method, and I changed some of the layout and set it to use the variables instead of having fixed fonts and colours etc.
ukliam,
Thanks for the kind words, I'll try to keep making improvements as I get more free time!
If you want to show all users remove
'WHERE s.userid <> 0' from the SELECT statement. That *should* display everything in the table. However, the code will be slightly goofed as there is no profile for USERID=0 (a guest), so if anyone clicks on the username vB should display an error (no userid or somesuch).
WOW Cool! Just found this hack. I liek the way it tells exactly what the user is doing, like viewing the homepage, posting a new thread, etc. Good Job!
I am adding this to my homepage now (one of few hacks that I will actually install because it doesnt require modification of the main script(s) )
Thanks again
~Chris
Thanks TechTalk,
I intentionally made it a separate .php file for the very reason that if it's not adopted into the final release :) I will have to stick it into the code again and again (like PMs).
Actually, I've updated it a lot to fix miscellaneous bugs that I've found (the largest one being the fact that non-moderators can view the topics of moderator-only threads -- this can be a security breach if you have important topics inside (such as "What to do with user XXX??").
Known bugs:
Logged out user (member.php?action=clearcookies)
Example:
http://www.baseballboards.com/boards/whoisonline.php?action=onlineusers
Here is whoisonline.php:
<?PHP
require( "global.php" );
// ############################### start online users form ###############################
// #####
// ##### Online Users Modification
// #####
// ##### Matt Rogish
// ##### 7/5/00
// #####
// ##### Updated 8/29/00
if( $action == "onlineusers" ) {
$loggedins = $DB_site->query_first( "SELECT COUNT(sessionid) AS sessions FROM session" );
$totalonline = $loggedins[ sessions ];
$loggedins = $DB_site->query_first( "SELECT COUNT(sessionid) AS sessions FROM session WHERE userid = 0" );
$numberguest = $loggedins[ sessions ];
$loggedins = $DB_site->query_first( "SELECT COUNT(sessionid) AS sessions FROM session WHERE userid <> 0" );
$numberregistered = $loggedins[ sessions ];
$numVisible = 0;
$onlineNow = $DB_site->query( "SELECT s.userid, u.username, s.location FROM session s LEFT JOIN user u ON u.userid = s.userid WHERE s.userid <> 0 AND u.invisible = 0 ORDER BY u.username ASC" );
if( $online = $DB_site->fetch_array( $onlineNow ) ) {
$numVisible++;
$userid = $online[ userid ];
$username = $online[ username ];
$location = $online[ location ];
// Save our hyperlink
$locationLink = $location;
// Give us the .php file and path
$phpFile = strtok( $location, "?" );
// Give us the extra threadid=47565&pagenumber=2
$queryString = strtok( "?" );
if( empty( $queryString ) ) {
if( strpos( $location, "chat" ) ) {
$location = "$bbtitle Chat";
} else {
$location = "$bbtitle Main";
} // end if
} else {
// Give us the query (threadID, forumID, etc.)
$query = strtok( $queryString, "=" );
if( strcasecmp( $query, "action" ) == 0 ) {
// Then we are either newreply or getinfo, etc.
$query = strtok( "&" );
// Preserve the "newreply" or "editpost"
$mainQuery = $query;
// Get the "other" thing
$query = strtok( "=" );
} // end if
// Give us the number (potentially followed by other things)
$oldID = strtok( "=" );
// Clear out the ID
$id = "";
if( eregi( "[0-9]+", $oldID, $cleanIDArray ) ) {
for( $i = 0; $i <= count( $cleanIDArray ); $i++ ) {
$id .= $cleanIDArray[ $i ];
} // end for
} else {
// Nothing, so probably the main page
$location = "$bbtitle Main";
} // end if
if( empty( $id ) ) {
$id = 0;
} // end if
if( strcasecmp( $query, "threadid" ) == 0 ){
$threadTitle = $DB_site->query_first( "SELECT title, forumid FROM thread WHERE threadid=$id" );
$location = $threadTitle[ title ];
$forumid = $threadTitle[ forumid ];
$forumid = verifyid( "forum", $forumid );
$getperms = getpermissions( $bbuserid, $bbusergroupid, $forumid );
if( $getperms[ canview ] == 0 ) {
$location = "Moderators Only Thread";
$locationLink = "/boards/";
} // end if
} else if( strcasecmp( $query, "forumid" ) == 0 and strcasecmp( $mainQuery, "newthread" ) != 0 ) {
$forumTitle = $DB_site->query_first( "SELECT title FROM forum WHERE forumid=$id" );
$location = $forumTitle[ title ];
} else if( strcasecmp( $query, "postid" ) == 0 and strcasecmp( $mainQuery, "editpost" ) != 0 ){
$getthreadid = $DB_site->query_first( "SELECT threadid FROM post WHERE postid=$id" );
$threadid = $getthreadid[ threadid ];
if( !empty( $threadid ) ) {
$threadTitle = $DB_site->query_first( "SELECT title, forumid FROM thread WHERE threadid=$threadid" );
$location = $threadTitle[ title ];
$forumid = $threadTitle[ forumid ];
$forumid = verifyid( "forum", $forumid );
$getperms = getpermissions( $bbuserid, $bbusergroupid, $forumid );
if( $getperms[ canview ] == 0 ) {
$location = "Moderators Only Thread";
$locationLink = "/boards/";
} // end if
} else {
$location = "Unknown location!";
} // end if
} else if( strcasecmp( $mainQuery, "getinfo" ) == 0 ) {
$userResult = $DB_site->query_first( "SELECT username FROM user WHERE userid=$id" );
$userName = $userResult[ username ];
$location = "Get User Information For: $userName";
} else if( strcasecmp( $mainQuery, "newthread" ) == 0 ) {
$forumTitle = $DB_site->query_first( "SELECT title FROM forum WHERE forumid=$id" );
$forum = $forumTitle[ title ];
$location = "Creating new thread in $forum";
} else if( strpos( $phpFile, "private.php" ) ) {
$location = "Private Messaging";
} else if( strpos( $phpFile, "search.php" ) ) {
$location = "Searching";
} else if( strpos( $phpFile, "memberlist.php" ) ) {
$location = "Member Listing";
} else if( strcasecmp( $mainQuery, "editpost" ) == 0 ) {
$getthread = $DB_site->query_first( "SELECT threadid FROM post WHERE postid=$id" );
$threadid = $getthread[ threadid ];
if( !empty( $threadid ) ) {
$threadTitle = $DB_site->query_first( "SELECT title, forumid FROM thread WHERE threadid=$threadid" );
$thread = $threadTitle[ title ];
$forumid = $threadTitle[ forumid ];
$forumid = verifyid( "forum", $forumid );
$getperms = getpermissions( $bbuserid, $bbusergroupid, $forumid );
if( $getperms[ canview ] == 0 ) {
$thread = "Moderators Only Thread";
$locationLink = "/boards/";
} // end if
} else {
$location = "Unknown location!";
} // end if
$location = "Editing post in $thread";
} else if( strcasecmp( $mainQuery, "onlineusers" ) == 0 ) {
$location = "Online Users Listing";
} else {
$location = "Unknown location!";
} // end if
} // end if
eval("\$whoisonlinebits .= \"" . gettemplate("whoisonlinebit") . "\";");
while( $online = $DB_site->fetch_array( $onlineNow ) ) {
$numVisible++;
$userid = $online[ userid ];
$username = $online[ username ];
$location = $online[ location ];
// Save our hyperlink
$locationLink = $location;
// Give us the .php file and path
$phpFile = strtok( $location, "?" );
// Give us the extra threadid=47565&pagenumber=2
$queryString = strtok( "?" );
if( empty( $queryString ) ) {
if( strpos( $location, "chat" ) ) {
$location = "$bbtitle Chat";
} else {
$location = "$bbtitle Main";
} // end if
} else {
// Give us the query (threadID, forumID, etc.)
$query = strtok( $queryString, "=" );
if( strcasecmp( $query, "action" ) == 0 ) {
// Then we are either newreply or getinfo, etc.
$query = strtok( "&" );
// Preserve the "newreply" or "editpost"
$mainQuery = $query;
// Get the "other" thing
$query = strtok( "=" );
} // end if
// Give us the number (potentially followed by other things)
$oldID = strtok( "=" );
// Clear out the ID
$id = "";
if( eregi( "[0-9]+", $oldID, $cleanIDArray ) ) {
for( $i = 0; $i <= count( $cleanIDArray ); $i++ ) {
$id .= $cleanIDArray[ $i ];
} // end for
} else {
// Nothing, so probably the main page
$location = "$bbtitle Main";
} // end if
if( empty( $id ) ) {
$id = 0;
} // end if
if( strcasecmp( $query, "threadid" ) == 0 ){
$threadTitle = $DB_site->query_first( "SELECT title, forumid FROM thread WHERE threadid=$id" );
$location = $threadTitle[ title ];
$forumid = $threadTitle[ forumid ];
$forumid = verifyid( "forum", $forumid );
$getperms = getpermissions( $bbuserid, $bbusergroupid, $forumid );
if( $getperms[ canview ] == 0 ) {
$location = "Moderators Only Thread";
$locationLink = "/boards/";
} // end if
} else if( strcasecmp( $query, "forumid" ) == 0 and strcasecmp( $mainQuery, "newthread" ) != 0 ) {
$forumTitle = $DB_site->query_first( "SELECT title FROM forum WHERE forumid=$id" );
$location = $forumTitle[ title ];
} else if( strcasecmp( $query, "postid" ) == 0 and strcasecmp( $mainQuery, "editpost" ) != 0 ) {
$getthreadid = $DB_site->query_first( "SELECT threadid FROM post WHERE postid=$id" );
$threadid = $getthreadid[ threadid ];
if( !empty( $threadid ) ) {
$threadTitle = $DB_site->query_first( "SELECT title, forumid FROM thread WHERE threadid=$threadid" );
$location = $threadTitle[ title ];
$forumid = $threadTitle[ forumid ];
$forumid = verifyid( "forum", $forumid );
$getperms = getpermissions( $bbuserid, $bbusergroupid, $forumid );
if( $getperms[ canview ] == 0 ) {
$location = "Moderators Only Thread";
$locationLink = "/boards/";
} // end if
} else {
$location = "Unknown location!";
} // end if
} else if( strcasecmp( $mainQuery, "getinfo" ) == 0 ) {
$userResult = $DB_site->query_first( "SELECT username FROM user WHERE userid=$id" );
$userName = $userResult[ username ];
$location = "Getting user information for $userName";
} else if( strcasecmp( $mainQuery, "newthread" ) == 0 ) {
$forumTitle = $DB_site->query_first( "SELECT title FROM forum WHERE forumid=$id" );
$forum = $forumTitle[ title ];
$location = "Creating new thread in $forum";
} else if( strpos( $phpFile, "private.php" ) ) {
$location = "Private Messaging";
} else if( strpos( $phpFile, "search.php" ) ) {
$location = "Searching";
} else if( strpos( $phpFile, "memberlist.php" ) ) {
$location = "Member Listing";
} else if( strcasecmp( $mainQuery, "editpost" ) == 0 ) {
$getthread = $DB_site->query_first( "SELECT threadid FROM post WHERE postid=$id" );
$threadid = $getthread[ threadid ];
if( !empty( $threadid ) ) {
$threadTitle = $DB_site->query_first( "SELECT title, forumid FROM thread WHERE threadid=$threadid" );
$thread = $threadTitle[ title ];
$forumid = $threadTitle[ forumid ];
$forumid = verifyid( "forum", $forumid );
$getperms = getpermissions( $bbuserid, $bbusergroupid, $forumid );
if( $getperms[ canview ] == 0 ) {
$thread = "Moderators Only Thread";
$locationLink = "/boards/";
} // end if
} else {
$location = "Unknown location!";
} // end if
$location = "Editing post in $thread";
} else if( strcasecmp( $mainQuery, "onlineusers" ) == 0 ) {
$location = "Online Users Listing";
} else {
$location = "Unknown location!";
} // end if
} // end if
eval( "\$whoisonlinebits .= \"" . gettemplate( "whoisonlinebit" ) . "\";" );
} // end while
eval( "echo dovars(\"" . gettemplate( "whoisonline" ) . "\");" );
} // end if
} // end if
// #####
// ##### Online Users Modification
// #####
// ##### Matt Rogish
// ##### 7/5/00
// #####
// ##### Updated 8/29/00
// ############################### end online users form ###############################
P.S.
If you are using it, you'll notice that forums the user doesn't have permission to see will show up as "mods only". Well, the $locationlink points to "/boards" since the directory structure we have is:
http://www.baseballboards.com/boards/ <-PHP files live here (aka "forums").
So, if your index.php resides in a different dir, replace
$locationLink = "/boards/";
with
$locationLink = "/SOME/PATH/";
woah... alot of code :eek:
gonna try this out...
eva2000:
Yep, it is fairly inefficent right now. This will probably change later, but right now I'm too busy with other boards 'stuff' to worry about it. :(
However, v2 of whoisonline.php will not be as inefficent, slow, etc. This was my first crack at it and it *works*, just not too quickly depending on the number of users / posts.
OK got it working here:
http://www.extremeforums.com/forums/onlineusers.php
I did change one thing: I got rid of the first "if" statement so I didnt have to add the "?action=onlineusers" to the end of the url.
One thing i noticed:
if the user is on:
http://www.extremeforums.com/forums/onlineusers.php
Then it says they are on "Extreme Forums Main".... Any fix for this?
Thanks
~Chris
Chris,
Yep, that is because I (for some unknown reason now) have it checking the second half of the URL to see what the user is doing.. so in effect it looks at the ?action=WHATEVER and if it sees "onlineusers" it will display "Online users listing". When you removed that, that functionality ceased to exist.
However, if you want it to work, here's how to "fix" :) it:
Change:
} else if( strcasecmp( $mainQuery, "onlineusers" ) == 0 ) {
Note: this exists in two places: line 189 and 363.. yeah I know it is dumb that I have to repeat the code twice, again... V2 will not suck! :)
To:
} else if( strpos( $phpFile, "onlineusers.php" ) ) {
So, that should check $phpFile for the existance of "onlineusers.php" and be happy.
Ok, I realize that could be done with $PHP_SELF, but for the time being do it my crappy way. :)
cool i added the link right next to the buddy list at http://animeboards.net/forums/index.php :D
http://animeboards.net/forums/whoisonline.php3?action=onlineusers
eva2000:
Cool! Glad to see people are using my code -- and it hasn't destroyed their system!
Oh wait, as soon as I've said that.. I can't get to your site! :( Is it down?
[Edited by mrogish on 08-29-2000 at 11:45 PM]
nope.. i can access it fine so can all my members...
eva2000,
Ok, I bet it is Road Runner's DNS servers flaking out again. Hope you enjoy the hack! :)
thanks... i do love it... seems members are staying longer and logging in for longer times and i only had the hack in for a few minutes :D
greate work :D
Oh, it's moments like these that make it all worthwhile...
**sniff**
*wipes a tear from his eye* :)
Also you did forget the "announcement.php" link. So if they are viewing an announcement, then it thinks they are just looking at that forum.
Any idea when the next version will be out?
Thanks
~Chris
Also if a user is at say:
http://www.extremeforums.com/forums/index.php?action=bbcode
It says "Unknown Location!" when infact they are viewing vb code ;)
Ill post some more info if you want it
~Chris
TechTalk,
Could you keep track of those things that break and then e-mail them to me?
I gotta get to bed now, early mornings really suck if I stay up all night!
If you compile a list of broken things and then let me know what they are (e-mail?), I'll cut a new version tomorrow!
wow can't wait until tomorrow :D
Hmm.. looks very similar to Stalion/Ed's buddy list ;)
Ofcourse this hack existed earlier.
When I use this, no matter what it shows the user as being on Forums Main. The only canges I have made are to change the extension to php3 and /boards/ to /board/
http://www.influx9.com/board/whoisonline.php3?action=onlineusers
Originally posted by Bane
When I use this, no matter what it shows the user as being on Forums Main. The only canges I have made are to change the extension to php3 and /boards/ to /board/
http://www.influx9.com/board/whoisonline.php3?action=onlineusers
Do a search and replace with your favorite text editor. Replace all instances of "php" with "php3"
~Chris
Im sorry, I should have said extensions.. I have already changed all the .php with .php3, as well as the actual files extension and the /path/
at - http://www.influx9.com/board/whoisonline.txt
[Edited by Bane on 08-30-2000 at 06:01 PM]
also 'unknown location' shows up when a member is viewing a category page or the avatar.php or buddy.php pages
i deleted a thread in a forum and now when i use http://animeboards.net/forums/whoisonline.php3?action=onlineusers it gives me an message
No forum specified. If you followed a valid link, please notify the webmaster ?
* wonders if their is still going to be a new version......
James, John........PLEASE!, PLEASE KILL THE CSS IN THE TEXT FIELDS AND THE YELLOW SMILIES!!!! NO YELLOW SMILIES!!! :D :mad:
~Chris
and not to mention NO YELLOW HOVER LINK ! :D
Yep, there will be, however I just got a new motherboard today (Dual PIII!) and I'm messing with it in one of my other boxes. As soon as it gets up and/or running, I'll fix the userlisting! :)
I don't know why I didn't see this one earlier! I'll wait for the new version to come out.
Still working on it in case anyone cares. Some other board things have been taking 110% of my time and will probably continue to do so for a few weeks. I will get to it as soon as I can! :(
I'm still interested.
Parker
Yup still waiting.....and I even took the time to send you an e-mail with some bugs :)
~Chris
yep very interested still... works wonders on tracking my members hehe
so how's this wonderful hack going on the bugs ? my version isn't reporting the threads viewed correctly now that there's more members http://animeboards.net/forums/whoisonline.php3?action=onlineusers ?
Almost done!
Expect to have a leaner, meaner script by the end of today! (Hopefully, as long as our database doesn't expload or anything! ;))
Looking forward to seeing this script as well.
Is today the lucky day? It is Friday the 13th, after all.
i'm watting ...
but i have a good idea
1 - hide everything about hidden user .
2 - add time for logged users .
3 - hide hidden forums and topics .
Any word on if a new version of this exists?
Thanks It works!
[Edited by Scaramanga_gold on 12-16-2000 at 10:05 AM]
im gettin a Error if im trying to click the location of a user if he is currently at the Private Messaging:
Database error in vBulletin: Invalid SQL: SELECT msgid,toid,fromid,title,UNIX_TIMESTAMP(datetime)
AS datetime,iconid,text,signature FROM privatercvdmsgid=11 WHERE msgid= AND fromid=1
mysql error: You have an error in your SQL syntax near '11 WHERE msgid= AND fromid=1'
at line 1
mysql error number: 1064
Date: Monday 18th of December 2000 10:18:59 AM
Script: /private.php?action=show&table=privatercvdmsgid=11
Referer:/whoisonline.php?action=onlineusers
It seems that the URLs being generated by whoisonline.php are not working as they should be for me. For example, sometimes the weirdest link is thrown out there. I have a link to a specific thread and it takes me to a reply page for that thread. Or... I have a link to a specific thread and it will look for the domain showthread.php as opposed to the file showthread.php on my domain. Have I done something incorrect?
Please advise.
Thanks,
Cygnus
another question. anyone can tell me what do I need to add to see where are the guests ?(guest1,guest2,guest3...)
<a href="http://www.vbulletin.com/forum/showthread.php?threadid=5007" target="_blank">http://www.vbulletin.com/forum/showt...?threadid=5007</a>
That's great but that doesn't fix my problem and it has added a new one.
I am trying to get one of these links to /forumdisplay.php?forumid=11 and it is taking me to /?forumid=11
The new problem is that the first person listed has no name though they have a location.
For the time being, I am going to pull all of the hrefs out of the code in your hack. I hope that you fix your hack so that it delivers what you said it would. Hacks that don't work are useless. Promises to revise hacks and leaving people hanging for months without so much as a peep on your progress is pretty lame. I don't mean to be a ++++ but as a developer, we already have a shitty enough reputation as slackers that I hate to see that furthered - even if it is among other developers.
Cygnus
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.