Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > General > Member Archives
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Details »»

Version: , by (Guest)
Developer Last Online: Jan 1970 Show Printable Version Email this Page

Version: Unknown Rating:
Released: 07-25-2000 Last Update: Never Installs: 0
 
No support by the author.

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:
Code:
Matt 8-29-00
Look at the code a few messages down!!
/Matt 8-29-00
Ugly, eh?

Create a template called whoisonline and fill it with:

Code:
<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:

Code:
<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:

Code:
<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...on=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]

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #2  
Old 07-25-2000, 08:45 AM
Guest
 
Posts: n/a
Default

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.
Reply With Quote
  #3  
Old 07-25-2000, 12:24 PM
Guest
 
Posts: n/a
Default

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).
Reply With Quote
  #4  
Old 08-30-2000, 01:07 AM
Guest
 
Posts: n/a
Default

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
Reply With Quote
  #5  
Old 08-30-2000, 01:18 AM
Guest
 
Posts: n/a
Default

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...on=onlineusers

Here is whoisonline.php:

Code:
<?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 ###############################
Reply With Quote
  #6  
Old 08-30-2000, 01:21 AM
Guest
 
Posts: n/a
Default

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/";
Reply With Quote
  #7  
Old 08-30-2000, 01:23 AM
Guest
 
Posts: n/a
Default

woah... alot of code

gonna try this out...
Reply With Quote
  #8  
Old 08-30-2000, 01:30 AM
Guest
 
Posts: n/a
Default

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.
Reply With Quote
  #9  
Old 08-30-2000, 01:45 AM
Guest
 
Posts: n/a
Default

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
Reply With Quote
  #10  
Old 08-30-2000, 02:24 AM
Guest
 
Posts: n/a
Default

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:

Code:
} 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:

Code:
} 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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:17 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04619 seconds
  • Memory Usage 2,304KB
  • Queries Executed 23 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (7)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete