Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #11  
Old 03-20-2001, 01:29 PM
Guest
 
Posts: n/a
Default

yeah, this script "works" but it doesnt really work.

for example when i have 60 users online it says there are 120, and it keeps going up, and then every now and then it will drop down to the actual number..

any ideas..?
Reply With Quote
  #12  
Old 03-20-2001, 01:47 PM
Guest
 
Posts: n/a
Default

I think the online vbulletin script works with cookies and with a timeout option. The onlinescript by Slip counts all userid's in "session". So the results are different.

Compare in index.php from vbulletin:

Code:
if ($displayloggedin) {
  $datecut=time()-$cookietimeout;

  //$loggedins=$DB_site->query_first("SELECT COUNT(*) AS sessions FROM session WHERE lastactivity>$datecut");
  //$totalonline=$loggedins['sessions'];
  $loggedins=$DB_site->query_first("SELECT COUNT(*) AS sessions FROM session WHERE userid=0 AND lastactivity>$datecut");
  $numberguest=$loggedins['sessions'];
  //$numberregistered=$totalonline-$numberguest;
Reply With Quote
  #13  
Old 03-20-2001, 02:30 PM
Guest
 
Posts: n/a
Default

would anyone mind telling me how to implement that?

sorry, i'm incredibly stupid when it comes to PHP stuff..
Reply With Quote
  #14  
Old 03-20-2001, 02:57 PM
Guest
 
Posts: n/a
Default

Well, you could require() the global.php file and then you could use the $cookietimeout variable. Or you could pull it from the database yourself, either way (it's in the settings table, I believe). But then, you would adjust the code:
Code:
<?
require("forum/admin/config.php");
$datecut = time()-$cookietimeout;
$db=mysql_connect($servername,$dbusername,$dbpassword);
mysql_select_db($dbname);

$loggedins=mysql_query("SELECT COUNT(userid) AS users FROM session WHERE lastactivity>$datecut AND userid=0",$db) or die ("oops");
while($loggedin = mysql_fetch_array($loggedins))
	$totalonline=number_format($loggedin[users]);

// rest deleted to save space, but leave it in there!
?>
I added the part in red
Reply With Quote
  #15  
Old 03-20-2001, 04:20 PM
Guest
 
Posts: n/a
Default

That's what I thought, and it got rid of the cumulative effect of the previous code.

But now it insists there are 0 people online
Reply With Quote
  #16  
Old 03-20-2001, 07:11 PM
Guest
 
Posts: n/a
Default

Is it possible to add the number of "guests" currently online as well?

Thanks
-Hideki
Reply With Quote
  #17  
Old 03-20-2001, 09:37 PM
Guest
 
Posts: n/a
Default

anyone want to help with fixing this?
Reply With Quote
  #18  
Old 03-20-2001, 09:53 PM
Guest
 
Posts: n/a
Default

I have been looking at it...give me some time..
Reply With Quote
  #19  
Old 03-20-2001, 10:07 PM
Guest
 
Posts: n/a
Default

It would be coool if it actually showed the members (who)that are online like index.php
Reply With Quote
  #20  
Old 03-20-2001, 10:47 PM
Guest
 
Posts: n/a
Default

OK I think I goofed. I looked at the sessions table, so here goes.

For registered members, you need it where userid>0. For guests, it's where userid=0. So let's revisit the code:

Code:
<?
require("forum/admin/config.php");
$db=mysql_connect($servername,$dbusername,$dbpassword);
mysql_select_db($dbname);

$cookietimeout = mysql_query("SELECT value FROM setting WHERE varname = cookietimeout");
$datecut = time()-$cookietimeout;

$loggedins=mysql_query("SELECT COUNT(userid) AS users FROM session WHERE lastactivity>$datecut AND userid>0",$db) or die ("oops");
while($loggedin = mysql_fetch_array($loggedins))
	$membersonline=number_format($loggedin[users]);

$guestsloggedins=mysql_query("SELECT COUNT(userid) AS users FROM session WHERE lastactivity>$datecut AND userid=0",$db) or die ("oops");
while($guestsloggedin = mysql_fetch_array($guestsloggedins))
    $guestsonline=number_format($guestsloggedin[users]);

// rest of code to display numbers
?>
New code is in red. (I also changed a couple variables, but the new code is highlighted to point out what we did wrong.)
I also added a couple lines to set the date cut without involving global.php.
Use $membersonline to display the members online, and use $guestsonline to display the guests.
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 10:06 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.03763 seconds
  • Memory Usage 2,245KB
  • Queries Executed 12 (?)
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
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)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