vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Online users on main page (https://vborg.vbsupport.ru/showthread.php?t=58339)

Rico 11-02-2003 02:02 AM

Online users on main page
 
How can i show all the current online users on the main page of my website. I would want to show users and guests currently online and the names of the users.

Thanks

Sylvus 11-02-2003 03:45 AM

Save this as whosonline.php and put it in your forum directory.

Code:

<?
//...........Who's Online v0.0.2...........\\
//......by Kevin (kevin@tubescan.com)......\\

// For vBulletin version 2, beta 3
// (c) 2001 Jelsoft Enterprises, Ltd.

// vbulletin.com thread: http://www.vbulletin.com/forum/showt...threadid=12010

///////////// CHANGE LOG /////////////
//
// New in version 0.0.2
// -- Option to display either usernames or just a number of registered members online
//
// New in version 0.0.1
// -- Released! :)
//
/////////// END CHANGE LOG ///////////

//////// CONFIG EXPLANATION //////////
//
// There are only two config options in this script.
// First is whether or not you want usernames displayed for registered members who are on the board. If you opt to not display
// usernames, it will simply display the number of members. Guests are unaffected by this. If you want usernames displayed, set
// $usernames to "on" in the CONFIG section below. If you want a simple number, set it to "off".
// The second is the path to config.php (in the /admin directory of your forums). It MUST NOT include a leading *or* trailing slash.
// So, for example: Your config.php is in
// /home/mysite/public_html/board/admin/
// and you are putting this file into
// /home/mysite/public_html/directory/
// So your path is
// /home/mysite/public_html/board/admin
// Make sure you set this correctly. You can refer to the General Options in your Admin Control Panel if you need a refresher on
// your path.
//
////// END CONFIG EXPLANATION ////////

/////////////// CONFIG ///////////////
//
$usernames = "on"; // if you would like it to display the names of registered members who are on, leave this set to "on".
                                  // if you want just a number of members, change it to "off".
$path = "full_site_path/forum/admin"; // set the path to your admin directory. see above for info about this.
//
///////////// END CONFIG /////////////

require('./global.php');
require("$path/config.php");
$db=mysql_connect($servername,$dbusername,$dbpassword);
mysql_select_db($dbname);

$cookievalue = mysql_query("SELECT value FROM setting WHERE varname = 'cookietimeout'") or die("oops1");
$cookietimeout = mysql_result($cookievalue, 0, 0);
$datecut = time()-$cookietimeout;

$invisibleregmember = "0";

if ($usernames == "on") {
        $regmembers = mysql_query("SELECT DISTINCT username,invisible FROM user,session WHERE session.userid=user.userid AND session.lastactivity>$datecut AND invisible='0' ORDER BY username ASC") or die("oops2");
        while($regmember = mysql_fetch_array($regmembers)):
                ++$regmembercomma;
                if ($regmember[invisible] == 0) {
                        $regmemberson .= $regmember[username];
                } else {
                        ++$regmembercomma;
                }
                if ($regmembercomma < mysql_num_rows($regmembers)):
                        $regmemberson .= ", ";
                endif;
        endwhile;
} else {
        $regmembers = mysql_query("SELECT DISTINCT COUNT(userid) AS membersonline FROM session WHERE userid>0 AND session.lastactivity>$datecut") or die("oops2");
        while($members = mysql_fetch_array($regmembers)) {
                $regmemberson = number_format($members[membersonline]);
        }
}

$guests = mysql_query("SELECT COUNT(userid) AS guestsonline FROM session WHERE userid=0 AND session.lastactivity>$datecut") or die("oops3");
while($guest = mysql_fetch_array($guests)):
        $guestson = number_format($guest[guestsonline]);
endwhile;

echo("<font size=1 face=Verdana, Arial, Helvetica, sans-serif COLOR=#e7cead> $regmemberson and $guestson Guests.");
?>

Then on your home page, being index.shtml, use this to call in the file.

<!--#include virtual="forum/whosonline.php" -->

That's how I do it on my site anyhow.

Syl...

Rico 11-02-2003 05:15 PM

Thanks for the help . This is exactly what i was looking for . I cant seem to get the user names to show though . The variable is set to "on" . The user count does show though . Does this script work for vb3 because that is what im running ? Thanks

amykhar 11-02-2003 11:34 PM

No hacks have been released here for VB3 and will not be until it is out of beta.

Sylvus 11-03-2003 01:11 AM

No, what I posted is for the VB 2.x series.

Syl...

Thug 06-04-2006 08:30 PM

can anyone post a 3.5. version of this
thanx

davidw 06-05-2006 12:10 AM

If you use your forums page for your main page, or if you have renamed your forums page to another web page for using a portal, look to the page where your forums reside and towards the bottom. There should be a list of currently active users. If you are using a portal and do not see this (as your main page) you may want to get a block/module that displays this information. I hope this helps.


All times are GMT. The time now is 02:41 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.01030 seconds
  • Memory Usage 1,738KB
  • 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
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)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