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

Reply
 
Thread Tools Display Modes
  #21  
Old 03-21-2001, 02:28 AM
Guest
 
Posts: n/a
Default

Thanks For Your Help

But can you post the whole code?
I didnt understand your directions!
Thanks
Reply With Quote
  #22  
Old 03-21-2001, 03:59 AM
Guest
 
Posts: n/a
Default

Sorry, I changed the code but it shows me 0members and 0 visitors!



You are on the right way, but there should be one mistake...
Reply With Quote
  #23  
Old 03-21-2001, 05:40 AM
Guest
 
Posts: n/a
Default

Couldnt get it to work either
Reply With Quote
  #24  
Old 03-21-2001, 11:16 AM
Guest
 
Posts: n/a
Default

Hmm. I noticed the 0 people yesterday, with different settings.

Just tried out:
I just changed "$datecut = time()-$cookietimeout;" into "$datecut = time()-300;"

And that worked. It just means it shows who's online in the last 5 minutes...

Can it be that the $cookietimeout query doesn't return a number but plain text?
Reply With Quote
  #25  
Old 03-21-2001, 11:57 AM
Guest
 
Posts: n/a
Default

This works. I have the timeout settings on 500 seconds in the vbulletin board, so the working skript looks now like that: (remember the right path to the admin/config file!)

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

$datecut = time()-500;

$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]);

$users=mysql_query("SELECT COUNT(userid) AS registeredusers FROM user",$db) or die ("double oops");
while($user = mysql_fetch_array($users))
	$totalusers=number_format($user[registeredusers]);


echo "<font face=arial size=2>
We have a total of $totalusers registered users. There are currently $membersonline members and $guestsonline guests online.</font>
";
?>
Reply With Quote
  #26  
Old 03-21-2001, 12:06 PM
Guest
 
Posts: n/a
Default

Hey Peter, I tried your exact code,
and it listed 3 members online,

But the thing is.... it'sa test board and I only have 2 members total!

I don't think it works.

Can anyone make this actually list the members name like in the index.php file?
Reply With Quote
  #27  
Old 03-21-2001, 12:47 PM
Guest
 
Posts: n/a
Default

hmm, thats right, something is more wrong, i have nearly the right results like in the vbulletib forum, but only nearly, so i thought at the beginning, the code is right. Sorry, I was to fast
Reply With Quote
  #28  
Old 03-21-2001, 07:12 PM
Guest
 
Posts: n/a
Default

Quote:
Originally posted by Pingu
I just changed "$datecut = time()-$cookietimeout;" into "$datecut = time()-300;"
And that worked. It just means it shows who's online in the last 5 minutes...
Can it be that the $cookietimeout query doesn't return a number but plain text?
I made a mistake in the code and therefore it was getting a MySQL error back instead of the cookietimeout. The corrected code is below.

Quote:
Originally posted by Sarge
...and it listed 3 members online, but the thing is.... it'sa test board and I only have 2 members total!
I think I figured this out too - adding "DISTINCT" should fix it. See the corrected code below.

OK after a bit of scratching my head, I think I have this thing figured out.

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[value];

$loggedins=mysql_query("SELECT DISTINCT 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]);

$users=mysql_query("SELECT COUNT(userid) AS registeredusers FROM user",$db) or die ("double oops");
while($user = mysql_fetch_array($users))
	$totalusers=number_format($user[registeredusers]);

echo "<font face=arial size=2>We have a total of $totalusers registered users. There are currently $membersonline members and $guestsonline guests online.</font>";
?>
Just remember to change the path to config.php, based on where you put this file. I think this should work now. *crosses fingers*
Reply With Quote
  #29  
Old 03-21-2001, 07:26 PM
Guest
 
Posts: n/a
Default

Now it lists 0 members and 0 guests online
Reply With Quote
  #30  
Old 03-21-2001, 07:45 PM
Guest
 
Posts: n/a
Default

OK I figured it out, finally. Change the code as follows. Replace this:
Code:
$cookietimeout = mysql_query("SELECT value FROM setting WHERE varname = 'cookietimeout'");
$datecut = time()-$cookietimeout[value];
with this:
Code:
$cookievalue = mysql_query("SELECT value FROM setting WHERE varname = 'cookietimeout'");
$cookietimeout = mysql_result($cookievalue, 0, 0);
$datecut = time()-$cookietimeout;
I've also attached the complete code in a file. Unzip the file online.php from it, and then open that file in Notepad (Windows) or Simpletext (Mac) and edit the path to config.php, if necessary. Upload it to where you want and then include it using PHP
Code:
<? include("/path/to/online.php"); ?>
or SSI
Code:
<!--#include virtual="/path/to/online.php"-->
.

Problems? Let me know. It should work now.
Attached Files
File Type: zip online.zip (616 Bytes, 14 views)
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 08:50 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.04617 seconds
  • Memory Usage 2,250KB
  • 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
  • (6)bbcode_code
  • (2)bbcode_quote
  • (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
  • (1)postbit_attachment
  • (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
  • postbit_attachment
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete