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

Renegade 07-25-2002 10:16 AM

I am looking for the hack that vbulletin.org uses. It offers the number of users browsing the forum on the main index page. Anybody know how to do this?

Renegade 07-25-2002 10:17 AM

I am trying to find the hack that vbulletin.org uses in the main forum index page. It displays the number of users browsing the forum in the forum name field??

Barret 09-01-2002 03:48 AM

Quote:

Originally posted by Renegade
I am trying to find the hack that vbulletin.org uses in the main forum index page. It displays the number of users browsing the forum in the forum name field??
I`m looking for the same hack! ;)

Chris M 09-01-2002 08:23 AM

Cool:)

If you could get it for "Users browsing this Thread", that would be cool:)

Satan

Boofo 09-01-2002 08:36 AM

Just do the same coding in showthread.php and you did the forumdisplay and it will be the same. :) I even went one step further and have it saying:

(1 User Browsing this Thread: Boofo) and
(2 Users Browsing this Thread: Boofo, hellsatan)

Quote:

Originally posted by hellsatan
Cool:)

If you could get it for "Users browsing this Thread", that would be cool:)

Satan


Chris M 09-01-2002 08:45 AM

Ok so it would work:)

Cool:)

Thanks:D

Satan

Boofo 09-01-2002 08:47 AM

I have the code if it would help you. ;)

Chris M 09-01-2002 09:01 AM

Yes please:)

Satan

Boofo 09-01-2002 09:37 AM

Here you go. :)

NOTE: You need to have Firefdly's Users browsing this thread hack installed.

Code:

-----------------------
In showthread.php:
-----------------------
After this:
-----------------------

if ($showforumusers) {
        $datecut = $ourtimenow - $cookietimeout;
        $browsers = '';
        $comma = '';

-----------------------
Add this:
-----------------------

$usercount = 0;

-----------------------
After this:
-----------------------

} else {
                                $invisibleuser = '';
                    }
                        eval("\$browsers .= \"".$comma.gettemplate('forumdisplay_loggedinuser')."\";");
                        $comma = ', ';

-----------------------
Add this:
-----------------------

$usercount++;

-----------------------
Before this:
-----------------------

eval("\$browsers .= \"".$comma.gettemplate('forumdisplay_loggedinuser')."\";");

-----------------------
Add this
-----------------------

$usercount++;

-----------------------
After this:
-----------------------

if ($browsers) {

-----------------------
Add this:
-----------------------

                $s = 's';
    if (intval($usercount) < 1) {
            $usercount = 0;
        }
        if (intval($usercount) == 1) {
            $s = '';
        }

-----------------------
In the "showthread_browsing" template:
-----------------------
Replace the contents with this:
-----------------------

<br>(<b>$usercount</b> User$s Browsing this Thread: $browsers)


Chris M 09-01-2002 09:45 AM

Thanks:)

Satan

Barret 09-04-2002 03:40 PM

But how to get it to show on index.php?


All times are GMT. The time now is 04:43 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.01248 seconds
  • Memory Usage 1,834KB
  • 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
  • (1)bbcode_code_printable
  • (2)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (21)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete