vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   total visitors online plugin not working (https://vborg.vbsupport.ru/showthread.php?t=313377)

Chadi 07-31-2014 07:03 PM

total visitors online plugin not working
 
I have a strange issue here.

I'm using this active plugin with global_start hook location for both desktop and mobile templates. It works fine in mobile (navbar), but not in desktop (header template)

Same exact code in plugin, same code in templates:

Code:

// get online users
$datecut = TIMENOW - $vbulletin->options['cookietimeout'];
$guestsarry = $db->query_first("SELECT COUNT(host) AS sessions FROM " . TABLE_PREFIX . "session WHERE userid = 0 AND lastactivity > $datecut");
$membersarry = $db->query_read("SELECT DISTINCT userid FROM " . TABLE_PREFIX . "session WHERE userid <> 0 AND lastactivity > $datecut");
$msxguests = intval($guestsarry['sessions']);
$msxmembers = intval($db->num_rows($membersarry));
$msxtotal = $msxmembers + $msxguests;
vB_Template::preRegister('navbar_link',array('msxtotal' => $msxtotal, 'msxmembers' => $msxmembers, 'msxguests' => $msxguests));
// get online users

Code:

<div style="background-color: #fff; text-align: center; padding: 10px; float: right">
<span style="font-size: 16px; color: #777">there are <span style="color: #43A6DF; font-weight: bold">{vb:raw $msxtotal}</span> people online</span>
</div>

The issue is on desktop, it is not outputting the actual number. It only says "there are members online". In mobile, it shows actual total people online, perfectly reflecting the same in the who's online footer section on the desktop version.

I have the code in the header template in desktop version and navbar template in mobile.

Scanu 07-31-2014 07:09 PM

You'll have to register the variable also to the header template then. Try this code
PHP Code:

// get online users
$datecut TIMENOW $vbulletin->options['cookietimeout'];
$guestsarry $db->query_first("SELECT COUNT(host) AS sessions FROM " TABLE_PREFIX "session WHERE userid = 0 AND lastactivity > $datecut");
$membersarry $db->query_read("SELECT DISTINCT userid FROM " TABLE_PREFIX "session WHERE userid <> 0 AND lastactivity > $datecut");
$msxguests intval($guestsarry['sessions']);
$msxmembers intval($db->num_rows($membersarry));
$msxtotal $msxmembers $msxguests;
vB_Template::preRegister('navbar_link',array('msxtotal' => $msxtotal'msxmembers' => $msxmembers'msxguests' => $msxguests));
vB_Template::preRegister('header',array('msxtotal' => $msxtotal'msxmembers' => $msxmembers'msxguests' => $msxguests));
// get online users 


Chadi 07-31-2014 07:11 PM

Perfect that works! Thanks :)

Scanu 07-31-2014 07:19 PM

You're welcome :)


All times are GMT. The time now is 07:01 PM.

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.00986 seconds
  • Memory Usage 1,725KB
  • 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
  • (2)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete