vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 2.x Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=4)
-   -   Number of users browsing current forum (https://vborg.vbsupport.ru/showthread.php?t=38005)

Zzed 04-28-2002 10:00 PM

Number of users browsing current forum
 
This is a really simple hack that displays the number of users browsing the current forum along
with the list of users.

It requires no template changes. ;)

In forumdisplay.php

find:
PHP Code:

if ($showforumusers) {
        
$datecut $ourtimenow $cookietimeout;
        
$browsers '';
        
$comma '';
        
$forumusers $DB_site->query("SELECT username, invisible, userid
                                                FROM user
                                                WHERE  inforum = 
$foruminfo[forumid]
                                                        AND lastactivity > 
$datecut
                                                        AND lastvisit <> lastactivity"
);
        while (
$forumuser $DB_site->fetch_array($forumusers)) {
                if ((!
$forumuser['invisible'] or $bbuserinfo['usergroupid'] == 6) and $bbuserinfo['userid'] != $forumuser['userid']) {
                        
$userid $forumuser['userid'];
                        
$username $forumuser['username'];
                        if (
$forumuser['invisible'] == 1) { // Invisible User but show to Admin
                                
$invisibleuser '*';
                        } else {
                                
$invisibleuser '';
                        }
                        eval(
"\$browsers .= \"".$comma.gettemplate('forumdisplay_loggedinuser')."\";");
                        
$comma ', ';
                }
        }
        
// Don't ask the DB for the user that is viewing the page as they wouldn't be here if they weren't! DOH!
        // This way our query up above can hit the inforum index so don't change unless you know what you are doing.
        
if ((!$bbuserinfo['invisible'] or $bbuserinfo['usergroupid'] == 6) and $bbuserinfo['userid'] <> 0) {
                
$userid $bbuserinfo['userid'];
                
$username $bbuserinfo['username'];
                if (
$bbuserinfo['invisible'] == 1) { // Admin is invisible but show himself to himself, get it!
                        
$invisibleuser '*';
                } else {
                        
$invisibleuser '';
                }
                eval(
"\$browsers .= \"".$comma.gettemplate('forumdisplay_loggedinuser')."\";");
        }
        if (
$browsers) {
                if (!
$moderatedby) {
                        
$onlineusers "<br>";
                }
                eval(
"\$onlineusers .= \"".gettemplate('forumdisplay_loggedinusers')."\";");
        }


And replace it with:
PHP Code:

if ($showforumusers) {
        
$datecut $ourtimenow $cookietimeout;
        
$browsers '';
        
$comma '';
        
$usercount 0;
        
$forumusers $DB_site->query("SELECT username, invisible, userid
                                                FROM user
                                                WHERE  inforum = 
$foruminfo[forumid]
                                                        AND lastactivity > 
$datecut
                                                        AND lastvisit <> lastactivity"
);
        while (
$forumuser $DB_site->fetch_array($forumusers)) {
                if ((!
$forumuser['invisible'] or $bbuserinfo['usergroupid'] == 6) and $bbuserinfo['userid'] != $forumuser['userid']) {
                        
$userid $forumuser['userid'];
                        
$username $forumuser['username'];
                        if (
$forumuser['invisible'] == 1) { // Invisible User but show to Admin
                                
$invisibleuser '*';
                        } else {
                                
$invisibleuser '';
                        }
                        eval(
"\$browsers .= \"".$comma.gettemplate('forumdisplay_loggedinuser')."\";");
                        
$comma ', ';
                        
$usercount++;
                }
        }
        
// Don't ask the DB for the user that is viewing the page as they wouldn't be here if they weren't! DOH!
        // This way our query up above can hit the inforum index so don't change unless you know what you are doing.
        
if ((!$bbuserinfo['invisible'] or $bbuserinfo['usergroupid'] == 6) and $bbuserinfo['userid'] <> 0) {
                
$userid $bbuserinfo['userid'];
                
$username $bbuserinfo['username'];
                if (
$bbuserinfo['invisible'] == 1) { // Admin is invisible but show himself to himself, get it!
                        
$invisibleuser '*';
                } else {
                        
$invisibleuser '';
                }
                
$usercount++;
                eval(
"\$browsers .= \"".$comma.gettemplate('forumdisplay_loggedinuser')."\";");
        }
        if (
$browsers) {
                
$browsers "<b>($usercount users)</b> $browsers";
                if (!
$moderatedby) {
                        
$onlineusers "<br>";
                }
                eval(
"\$onlineusers .= \"".gettemplate('forumdisplay_loggedinusers')."\";");
        }


You can see a sample of this at my site: http://www.ls1.com/forums/index.php

Neo 04-29-2002 05:12 AM

It would be better if the number could be showen on the main forum page :)

Floris 04-29-2002 06:41 AM

I had the same idea :P

So, this only adds the number of people right? Because vB 2.2.5 already has 'Users browsing this forum: nick1, nick2, ..' by default.

Neo 04-29-2002 06:58 AM

I will make this tonight if I am not to lazy :P

Zzed 04-29-2002 08:23 AM

Quote:

Originally posted by xiphoid
I had the same idea :P

So, this only adds the number of people right? Because vB 2.2.5 already has 'Users browsing this forum: nick1, nick2, ..' by default.

Yes, it adds the number of people to the list.

Like this:
Quote:

(Users Browsing this Forum: (11 users) mrgto*, Mikesbird, ghetto808, INSSANE, 1BADFIREHAWK, oxide, 00camaroSS, TGrits10, Big Spanky, Amuka, Zed*)

RDX1 04-29-2002 11:53 PM

i dont get what this hack does

Zzed 04-30-2002 04:56 AM

Look at the bold text in my previous reply.

TECK 04-30-2002 07:43 PM

this is a great hack.. and it doesnt require to add a new field.. however i'm concerned with the extra query? how is the server load doing?

Zzed 04-30-2002 07:47 PM

There is no extra query. The counting is being done within the loop. It should have zero effect on the server.

yasunari 04-30-2002 11:05 PM

I found that it won't count the Guest on the forum?
It would be great if it can count how many guest in each forum :P


All times are GMT. The time now is 01:47 PM.

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.01262 seconds
  • Memory Usage 1,791KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete