vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.0 Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=33)
-   -   Who's online on non-vB page (with usernames, same rules as Who's Online on forumhome) (https://vborg.vbsupport.ru/showthread.php?t=60019)

Loon 01-11-2004 04:25 PM

Hi

I had a similar problem when i made some external site stats for my board. I think it's counting the total number of sessions in the table for members rather than for each unique id

replace:

PHP Code:

SELECT DISTINCT COUNT(userid

with:

PHP Code:

SELECT COUNT(DISTINCT userid

And it should solve the incorrect count of members.

Gary King 01-11-2004 05:31 PM

Quote:

Originally Posted by Loon
Hi

I had a similar problem when i made some external site stats for my board. I think it's counting the total number of sessions in the table for members rather than for each unique id

replace:

PHP Code:

SELECT DISTINCT COUNT(userid

with:

PHP Code:

SELECT COUNT(DISTINCT userid

And it should solve the incorrect count of members.

Okay could someone please confirm and if it is the correct query then let me know, I'll change in the instructions :)

eva2000 01-12-2004 04:54 AM

Quote:

Originally Posted by Gary W
Okay could someone please confirm and if it is the correct query then let me know, I'll change in the instructions :)

spot on.. .
PHP Code:

SELECT COUNT(DISTINCT userid

fixed it

Gary King 01-12-2004 11:04 PM

Quote:

Originally Posted by eva2000
spot on.. .
PHP Code:

SELECT COUNT(DISTINCT userid

fixed it

Okay I'll change in instructions then :)

Yuneek 03-04-2004 05:22 PM

Quote:

Originally Posted by Gary W
Okay I'll change in instructions then :)

Okay.. I'm kind of confused.

What directory should online.php be located? I want all the names of the users online to be listed, so, I think I eed to use online.php. I tried putting it in the same directory as my files I want it to be displayed on, but it couldn't find the files it needed such as global.php. So, I tried to put it in the /forum directory, but it overwrote the online.php that vB needs, so I didn't want to do that.

What do I do?

Gary King 03-04-2004 06:41 PM

If you place the online.php outside of vB directory then just change the path to something else in the require_once() code.

Yuneek 03-05-2004 05:02 PM

Errors:
Quote:

Warning: chdir(): No such file or directory (errno 2) in /home/dp/public_html/beta/online.php on line 9

Warning: main(./includes/init.php): failed to open stream: No such file or directory in /home/dp/public_html/forum/global.php on line 18

Fatal error: main(): Failed opening required './includes/init.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/dp/public_html/forum/global.php on line 18
Online.php:
Quote:

<?php

error_reporting(E_ALL & ~E_NOTICE);

$path = "./forum/"; // path to your forums folder, normally /forum/

$phrasegroups = array('wol');

chdir($path);
require_once("/home/dp/public_html/forum/global.php");

$showusernames = 1; // 1 to show usernames online, 0 to only show the number of users online

$datecut = time()-$vboptions['cookietimeout'];

if ($showusernames == 1)
{
$regmembers = $DB_site->query("SELECT DISTINCT username,options FROM ".$tableprefix."user,".$tableprefix."session
WHERE ".$tableprefix."session.userid=".$tableprefix."use r.userid AND ".$tableprefix."session.lastactivity>$datecut
ORDER BY username ASC") or exit("oops2");

while($regmember = $DB_site->fetch_array($regmembers))
{
$regmember['options'] = intval($regmember['options']);

foreach($_USEROPTIONS as $optionname => $optionval)
{
$regmember["$optionname"] = iif($regmember['options'] & $optionval, 1, 0);
}

if ((($regmember['invisible'] == 0)) and $regmemberson or ($bbuserinfo['usergroupid'] == 6 and $regmember['invisible'] == 1))
{
$regmemberson .= ", ";
}

$regmembercomma++;
if ($regmember['invisible'] == 0 or $bbuserinfo['usergroupid'] == 6) {
if ($regmember['invisible'] == 1) {
$userinvisible = "*";
}

$regmemberson .= $regmember['username'].$userinvisible;
} else {
$regmembercomma++;
}
}

if (!$regmemberson)
{
$regmemberson = "(none)";
}

} else {
$regmembers = $DB_site->query_first("SELECT COUNT(DISTINCT userid) AS membersonline FROM ".$tableprefix."session WHERE userid>0 AND ".$tableprefix."session.lastactivity>$datecut" ) or exit("oops3");

$regmemberson = number_format($regmembers['membersonline']);
}

$howmany = substr_count($regmemberson,",");

if (($showusernames == 1 and $howmany >= 1) or ($showusernames == 0 and $regmemberson > 1))
{
$memberstext = $vbphrase['members'];
}
else
{
$memberstext = $vbphrase['member'];
}

$guests = $DB_site->query_first("SELECT COUNT(userid) AS guestsonline FROM ".$tableprefix."session WHERE userid=0 AND ".$tableprefix."session.lastactivity>$datecut" ) or exit("oops4");
if ($guests['guestsonline'] > 1)
{
$gueststext = $vbphrase['guests'];
}
else
{
$gueststext = $vbphrase['guest'];
}
$guestson = number_format($guests['guestsonline']);

$show = $memberstext.' '.strtolower($vbphrase['online']).': '.$regmemberson.'. '.$gueststext.' '.strtolower($vbphrase['online']).': '.$guestson.'.';
?>
Top of PHP page I want to include members on:
Quote:

<?php require_once("online.php"); ?>
Table I want members to show up in, same page as last quote:
Quote:

<table class="online">
<tr>
<td class="online" valign="top">
<span class="head">Who's Online</span><br /><br />
<?php
print $show;
?>
</td>
</tr>
</table>
Online.php and the file I want the members to show up on are in the same directory which is public_html/beta/ and the forum is public_html/forum/.

What am I doing wrong?

Gary King 03-05-2004 07:34 PM

Quote:

Originally Posted by Yuneek
Errors:


Online.php:


Top of PHP page I want to include members on:


Table I want members to show up in, same page as last quote:


Online.php and the file I want the members to show up on are in the same directory which is public_html/beta/ and the forum is public_html/forum/.

What am I doing wrong?

Change $path = "./forum/"; to $path = "./../forum/";

webrats 03-05-2004 09:08 PM

if i still this on a non vb page will it show the users browseing that page as guest?

Gary King 03-05-2004 10:38 PM

Quote:

Originally Posted by webrats
if i still this on a non vb page will it show the users browseing that page as guest?

Yep it should I believe.


All times are GMT. The time now is 11:09 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.01201 seconds
  • Memory Usage 1,759KB
  • 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_php_printable
  • (10)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)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