vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   I *really* need help with getting this online users thing working.. (https://vborg.vbsupport.ru/showthread.php?t=11772)

03-21-2001 02:28 AM

Thanks For Your Help

But can you post the whole code?
I didnt understand your directions!
Thanks

03-21-2001 03:59 AM

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...

03-21-2001 05:40 AM

Couldnt get it to work either

03-21-2001 11:16 AM

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?

03-21-2001 11:57 AM

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>
";
?>


03-21-2001 12:06 PM

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?

03-21-2001 12:47 PM

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

03-21-2001 07:12 PM

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*

03-21-2001 07:26 PM

Now it lists 0 members and 0 guests online

03-21-2001 07:45 PM

1 Attachment(s)
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. :)


All times are GMT. The time now is 07:42 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.01155 seconds
  • Memory Usage 1,743KB
  • 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
  • (6)bbcode_code_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)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