View Full Version : Online Users
Mr Chad
08-11-2005, 09:25 PM
How can i make it so it displays the amount of ppl online in the header.
Its only working on the homepage. What php file should i edit.
Andreas
08-11-2005, 09:45 PM
Assuming that you only want the Numbers:
Hook: global_start
if (THIS_SCRIPT != 'index' AND !$show['search_engine'])
{
require_once(DIR . '/includes/functions_bigthree.php');
$datecut = TIMENOW - $vbulletin->options['cookietimeout'];
$numbervisible = 0;
$numberregistered = 0;
$numberguest = 0;
$forumusers = $db->query_read("
SELECT
user.username, (user.options & " . $vbulletin->bf_misc_useroptions['invisible'] . ") AS invisible, session.userid, session.lastactivity
FROM " . TABLE_PREFIX . "session AS session
LEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = session.userid)
WHERE session.lastactivity > $datecut
");
while ($loggedin = $db->fetch_array($forumusers))
{
$userid = $loggedin['userid'];
if (!$userid)
{ // Guest
$numberguest++;
}
else if (empty($userinfos["$userid"]) OR ($userinfos["$userid"]['lastactivity'] < $loggedin['lastactivity']))
{
$userinfos["$userid"] = $loggedin;
}
}
if (!$vbulletin->userinfo['userid'] AND $numberguest == 0)
{
$numberguest++;
}
foreach ($userinfos AS $userid => $loggedin)
{
$numberregistered++;
if (fetch_online_status($loggedin))
{
$numbervisible++;
}
}
// memory saving
unset($userinfos, $loggedin);
$db->free_result($forumusers);
$totalonline = $numberregistered + $numberguest;
$numberinvisible = $numberregistered - $numbervisible;
}
Then you can use $numberregistered, $numberguest, $totalonline, $numbervisible and $numberinvisible in Template header.
Mr Chad
08-11-2005, 10:02 PM
Assuming that you only want the Numbers:
Hook: global_start
if (THIS_SCRIPT != 'index' AND !$show['search_engine'])
{
require_once(DIR . '/includes/functions_bigthree.php');
$datecut = TIMENOW - $vbulletin->options['cookietimeout'];
$numbervisible = 0;
$numberregistered = 0;
$numberguest = 0;
$forumusers = $db->query_read("
SELECT
user.username, (user.options & " . $vbulletin->bf_misc_useroptions['invisible'] . ") AS invisible, session.userid, session.lastactivity
FROM " . TABLE_PREFIX . "session AS session
LEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = session.userid)
WHERE session.lastactivity > $datecut
");
while ($loggedin = $db->fetch_array($forumusers))
{
$userid = $loggedin['userid'];
if (!$userid)
{ // Guest
$numberguest++;
}
else if (empty($userinfos["$userid"]) OR ($userinfos["$userid"]['lastactivity'] < $loggedin['lastactivity']))
{
$userinfos["$userid"] = $loggedin;
}
}
if (!$vbulletin->userinfo['userid'] AND $numberguest == 0)
{
$numberguest++;
}
foreach ($userinfos AS $userid => $loggedin)
{
$numberregistered++;
if (fetch_online_status($loggedin))
{
$numbervisible++;
}
}
// memory saving
unset($userinfos, $loggedin);
$db->free_result($forumusers);
$totalonline = $numberregistered + $numberguest;
$numberinvisible = $numberregistered - $numbervisible;
}
Then you can use $numberregistered, $numberguest, $totalonline, $numbervisible and $numberinvisible in Template header.
Was i spose to add that in the global.php under the global_start section? If i was then it didnt work.
Andreas
08-11-2005, 10:21 PM
No, this was meant as a Plugin for Hook global_start.
And it does work for me :)
Mr Chad
08-11-2005, 10:23 PM
Oh, let me try this
ok i did it and, when i put the text
Online: $totalonline ($vbphrase[x_members_and_y_guests])
and look at the header it is jsut blank, like i didnt even put anything in it.
Tony G
08-12-2005, 05:20 AM
Did you add it under the correct hook? And I'm not sure if that phrase will work in there. Try it without the $vbphrase.
Mr Chad
08-13-2005, 05:29 AM
Did you add it under the correct hook? And I'm not sure if that phrase will work in there. Try it without the $vbphrase.
I dont understand why it is not working. Still nothing.
Assuming that you only want the Numbers:
Hook: global_start
if (THIS_SCRIPT != 'index' AND !$show['search_engine'])
{
require_once(DIR . '/includes/functions_bigthree.php');
$datecut = TIMENOW - $vbulletin->options['cookietimeout'];
$numbervisible = 0;
$numberregistered = 0;
$numberguest = 0;
$forumusers = $db->query_read("
SELECT
user.username, (user.options & " . $vbulletin->bf_misc_useroptions['invisible'] . ") AS invisible, session.userid, session.lastactivity
FROM " . TABLE_PREFIX . "session AS session
LEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = session.userid)
WHERE session.lastactivity > $datecut
");
while ($loggedin = $db->fetch_array($forumusers))
{
$userid = $loggedin['userid'];
if (!$userid)
{ // Guest
$numberguest++;
}
else if (empty($userinfos["$userid"]) OR ($userinfos["$userid"]['lastactivity'] < $loggedin['lastactivity']))
{
$userinfos["$userid"] = $loggedin;
}
}
if (!$vbulletin->userinfo['userid'] AND $numberguest == 0)
{
$numberguest++;
}
foreach ($userinfos AS $userid => $loggedin)
{
$numberregistered++;
if (fetch_online_status($loggedin))
{
$numbervisible++;
}
}
// memory saving
unset($userinfos, $loggedin);
$db->free_result($forumusers);
$totalonline = $numberregistered + $numberguest;
$numberinvisible = $numberregistered - $numbervisible;
}
Then you can use $numberregistered, $numberguest, $totalonline, $numbervisible and $numberinvisible in Template header.
What does !$show['search_engine'] do?
Thanks.
Andreas
08-18-2005, 07:57 PM
!show['search_engine'] = Current user is not a Spider
!show['search_engine'] = Current user is not a Spider
ah ok danke :)
yinyang
10-18-2005, 02:00 AM
weird. this doesn't work for me either.
heynurse
10-24-2005, 05:46 AM
I'd also like to show the $totalonline in my header, could someone provide specific instructions where to add the hook and what code to add to the header to call it? Thanks
I added it to the correct hook location, but it's just comming up blank for me when I use: $totalonline in my header.
Any tips? Is there a specific format I am supposed to be using in my header?
peterska2
10-24-2005, 10:53 PM
Nothing here either Kirby, I think you did a duff one there!! ;) :p
Nothing here either Kirby, I think you did a duff one there!! ;) :p
only problem i have is that the vbcmps online users module's guest count gets doubled.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.