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

Reply
 
Thread Tools Display Modes
  #11  
Old 12-04-2012, 02:15 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You also need part of the code you posted above. I guess the whole thing would look something like this:

Code:
// ### BOARD STATISTICS #################################################

// get total threads & posts from the forumcache
$totalthreads = 0;
$totalposts = 0;
if (is_array($vbulletin->forumcache))
{
	foreach ($vbulletin->forumcache AS $forum)
	{
		$totalthreads += $forum['threadcount'];
		$totalposts += $forum['replycount'];
	}
}
$totalthreads = vb_number_format($totalthreads);
$totalposts = vb_number_format($totalposts);

// get total members and newest member from template
$numbermembers = vb_number_format($vbulletin->userstats['numbermembers']);
$newuserinfo = array(
	'userid'   => $vbulletin->userstats['newuserid'],
	'username' => $vbulletin->userstats['newusername']
);
$activemembers = vb_number_format($vbulletin->userstats['activemembers']);
$show['activemembers'] = ($vbulletin->options['activememberdays'] > 0 AND ($vbulletin->options['activememberoptions'] & 2)) ? true : false;

$templatevalues = array('activemembers' => $activemembers,
	'activeusers' => $activeusers,
	'newuserinfo' => $newuserinfo,
	'numberguest' => $numberguest,
	'numbermembers' => $numbermembers,
	'numberregistered' => $numberregistered,
	'totalonline' => $totalonline,
	'totalposts' => $totalposts,
	'totalthreads' => $totalthreads);
vB_Template::preRegister('footer', $templatevalues);

but I think that's preRegistering a couple things you're not actually calculating in your code. I don't know if those are coming from somewhere else or if they should be removed.
Reply With Quote
  #12  
Old 12-04-2012, 02:38 PM
CrumbDown CrumbDown is offline
 
Join Date: Feb 2012
Posts: 37
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ahhhhh! That worked, BUT:

When I added these inside of the footer template: {vb:raw totalonline}, {vb:raw numberregistered}, {vb:raw numberguest}, they do not show but all other does like threads, posts etc
Reply With Quote
  #13  
Old 12-04-2012, 02:46 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Those are the ones your code isn't calculating. You probably need to find the code for those in forum.php and add it to your plugin code.
Reply With Quote
  #14  
Old 12-04-2012, 02:49 PM
CrumbDown CrumbDown is offline
 
Join Date: Feb 2012
Posts: 37
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I've been looking but only see these:

PHP Code:
// ###### NOW YOUR TEMPLATE IS BEING RENDERED ######

$templater vB_Template::create('footer');
    
$templater->register_page_templates();
    
$templater->register('activemembers'$activemembers);
    
$templater->register('activeusers'$activeusers);
    
$templater->register('forumbits'$forumbits);
    
$templater->register('newuserinfo'$newuserinfo);
    
$templater->register('numberguest'$numberguest);
    
$templater->register('numbermembers'$numbermembers);
    
$templater->register('numberregistered'$numberregistered);
    
$templater->register('totalonline'$totalonline);
    
$templater->register('totalposts'$totalposts);
    
$templater->register('totalthreads'$totalthreads);

print_output($templater->render()); 
Should I be using this layout?:

PHP Code:
$templater->register('totalonline'$totalonline); 
--------------- Added [DATE]1354636855[/DATE] at [TIME]1354636855[/TIME] ---------------

Found the other part:

PHP Code:
// ### LOGGED IN USERS #################################################
if (($vbulletin->options['displayloggedin'] == OR $vbulletin->options['displayloggedin'] == OR ($vbulletin->options['displayloggedin'] > AND $vbulletin->userinfo['userid'])) AND !$show['search_engine'])
{
    
$datecut TIMENOW $vbulletin->options['cookietimeout'];
    
$numbervisible 0;
    
$numberregistered 0;
    
$numberguest 0;

    
$hook_query_fields $hook_query_joins $hook_query_where '';
    (
$hook vBulletinHook::fetch_hook('forumhome_loggedinuser_query')) ? eval($hook) : false;

    
$forumusers $db->query_read_slave("
        SELECT
            user.username, (user.options & " 
$vbulletin->bf_misc_useroptions['invisible'] . ") AS invisible, user.usergroupid, user.lastvisit,
            session.userid, session.inforum, session.lastactivity, session.badlocation,
            IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid, infractiongroupid
            
$hook_query_fields
        FROM " 
TABLE_PREFIX "session AS session
        LEFT JOIN " 
TABLE_PREFIX "user AS user ON(user.userid = session.userid)
        
$hook_query_joins
        WHERE session.lastactivity > 
$datecut
            
$hook_query_where
        " 
iif($vbulletin->options['displayloggedin'] == OR $vbulletin->options['displayloggedin'] == 3"ORDER BY username ASC") . "
    "
);

    if (
$vbulletin->userinfo['userid'])
    {
        
// fakes the user being online
        
$vbulletin->userinfo['joingroupid'] = iif($vbulletin->userinfo['displaygroupid'], $vbulletin->userinfo['displaygroupid'], $vbulletin->userinfo['usergroupid']);
        
$userinfos = array
        (
            
$vbulletin->userinfo['userid'] => array
            (
                
'userid'            =>& $vbulletin->userinfo['userid'],
                
'username'          =>& $vbulletin->userinfo['username'],
                
'invisible'         =>& $vbulletin->userinfo['invisible'],
                
'inforum'           => 0,
                
'lastactivity'      => TIMENOW,
                
'lastvisit'         =>& $vbulletin->userinfo['lastvisit'],
                
'usergroupid'       =>& $vbulletin->userinfo['usergroupid'],
                
'displaygroupid'    =>& $vbulletin->userinfo['displaygroupid'],
                
'infractiongroupid' =>& $vbulletin->userinfo['infractiongroupid'],
            )
        );
    }
    else
    {
        
$userinfos = array();
    }

    
$inforum = array();
    while (
$loggedin $db->fetch_array($forumusers))
    {
        
$userid $loggedin['userid'];
        if (!
$userid)
        {    
// Guest
            
$numberguest++;
            if (!isset(
$inforum["$loggedin[inforum]"]))
            {
                
$inforum["$loggedin[inforum]"] = 0;
            }
            if (!
$loggedin['badlocation'])
            {
                
$inforum["$loggedin[inforum]"]++;
            }
        }
        else if (empty(
$userinfos["$userid"]) OR ($userinfos["$userid"]['lastactivity'] < $loggedin['lastactivity']))
        {
            
$userinfos["$userid"] = $loggedin;
        }
    }

    
// We are a guest and somehow got missed by the query. 
    
if (!$vbulletin->userinfo['userid'] AND !$numberguest)
    {
        
$numberguest++;
    }

    
$activeusers = array();
/*    VBIV-12365 
    Users who are moderated or awaiting e-mail confirmation were being counted as guests. 
    This was causing online count discrepancies between this and online.php, removed code */
    
foreach ($userinfos AS $userid => $loggedin)
    {
        
$numberregistered++;
        if (
$userid != $vbulletin->userinfo['userid'] AND !$loggedin['badlocation'])
        {
            if (!isset(
$inforum["$loggedin[inforum]"]))
            {
                
$inforum["$loggedin[inforum]"] = 0;
            }
            
$inforum["$loggedin[inforum]"]++;
        }

        
fetch_musername($loggedin);
        
$loggedin['comma'] = $vbphrase['comma_space'];
        (
$hook vBulletinHook::fetch_hook('forumhome_loggedinuser')) ? eval($hook) : false;

        if (
fetch_online_status($loggedin))
        {
            
$numbervisible++;
            
$activeusers[$numbervisible] = $loggedin;
        }
    }

    
// Last element
    
if ($numbervisible
    {
        
$activeusers[$numbervisible]['comma'] = '';
    }

    
// memory saving
    
unset($userinfos$loggedin);

    
$db->free_result($forumusers);

    
$totalonline $numberregistered $numberguest;
    
$numberinvisible $numberregistered $numbervisible;

    
// ### MAX LOGGEDIN USERS ################################
    
if (intval($vbulletin->maxloggedin['maxonline']) <= $totalonline)
    {
        
$vbulletin->maxloggedin['maxonline'] = $totalonline;
        
$vbulletin->maxloggedin['maxonlinedate'] = TIMENOW;
        
build_datastore('maxloggedin'serialize($vbulletin->maxloggedin), 1);
    }

    
$recordusers vb_number_format($vbulletin->maxloggedin['maxonline']);
    
$recorddate vbdate($vbulletin->options['dateformat'], $vbulletin->maxloggedin['maxonlinedate'], true);
    
$recordtime vbdate($vbulletin->options['timeformat'], $vbulletin->maxloggedin['maxonlinedate']);

    
$show['loggedinusers'] = true;
}
else
{
    
$show['loggedinusers'] = false;

But gives me an error: Fatal error:

Call to a member function query_read_slave() on a non-object in includes/class_bootstrap.php(430) : eval()'d code on line 17
Reply With Quote
  #15  
Old 12-04-2012, 04:44 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think that error is caused by using $db->query_read_slave(). Either change it to $vbulletin->db->query_read_slave() or else put a "global $db;" line in your plugin code.
Reply With Quote
  #16  
Old 12-04-2012, 04:53 PM
CrumbDown CrumbDown is offline
 
Join Date: Feb 2012
Posts: 37
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
...Either change it to $vbulletin->db->query_read_slave()
Not sure what you are talking about. Where do I find that?

Quote:
Originally Posted by kh99 View Post
or else put a "global $db;" line in your plugin code.
I've added "global $db;", without the quotes, inside the plugin php but changes nothing.

I must thank you for your continued support.
Reply With Quote
  #17  
Old 12-04-2012, 04:56 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Are you still getting "Call to a member function query_read_slave() on a non-object "? Did you put the global line at the beginning? Maybe you should post your current plugin code.
Reply With Quote
  #18  
Old 12-04-2012, 05:00 PM
CrumbDown CrumbDown is offline
 
Join Date: Feb 2012
Posts: 37
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yea I think I need to

Code:

PHP Code:
// ### LOGGED IN USERS #################################################
if (($vbulletin->options['displayloggedin'] == OR $vbulletin->options['displayloggedin'] == OR ($vbulletin->options['displayloggedin'] > AND $vbulletin->userinfo['userid'])) AND !$show['search_engine'])
{
    
$datecut TIMENOW $vbulletin->options['cookietimeout'];
    
$numbervisible 0;
    
$numberregistered 0;
    
$numberguest 0;

    
$hook_query_fields $hook_query_joins $hook_query_where '';
    (
$hook vBulletinHook::fetch_hook('forumhome_loggedinuser_query')) ? eval($hook) : false;

    
$forumusers $db->query_read_slave("
        SELECT
            user.username, (user.options & " 
$vbulletin->bf_misc_useroptions['invisible'] . ") AS invisible, user.usergroupid, user.lastvisit,
            session.userid, session.inforum, session.lastactivity, session.badlocation,
            IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid, infractiongroupid
            
$hook_query_fields
        FROM " 
TABLE_PREFIX "session AS session
        LEFT JOIN " 
TABLE_PREFIX "user AS user ON(user.userid = session.userid)
        
$hook_query_joins
        WHERE session.lastactivity > 
$datecut
            
$hook_query_where
        " 
iif($vbulletin->options['displayloggedin'] == OR $vbulletin->options['displayloggedin'] == 3"ORDER BY username ASC") . "
    "
);

    if (
$vbulletin->userinfo['userid'])
    {
        
// fakes the user being online
        
$vbulletin->userinfo['joingroupid'] = iif($vbulletin->userinfo['displaygroupid'], $vbulletin->userinfo['displaygroupid'], $vbulletin->userinfo['usergroupid']);
        
$userinfos = array
        (
            
$vbulletin->userinfo['userid'] => array
            (
                
'userid'            =>& $vbulletin->userinfo['userid'],
                
'username'          =>& $vbulletin->userinfo['username'],
                
'invisible'         =>& $vbulletin->userinfo['invisible'],
                
'inforum'           => 0,
                
'lastactivity'      => TIMENOW,
                
'lastvisit'         =>& $vbulletin->userinfo['lastvisit'],
                
'usergroupid'       =>& $vbulletin->userinfo['usergroupid'],
                
'displaygroupid'    =>& $vbulletin->userinfo['displaygroupid'],
                
'infractiongroupid' =>& $vbulletin->userinfo['infractiongroupid'],
            )
        );
    }
    else
    {
        
$userinfos = array();
    }

    
$inforum = array();
    while (
$loggedin $db->fetch_array($forumusers))
    {
        
$userid $loggedin['userid'];
        if (!
$userid)
        {    
// Guest
            
$numberguest++;
            if (!isset(
$inforum["$loggedin[inforum]"]))
            {
                
$inforum["$loggedin[inforum]"] = 0;
            }
            if (!
$loggedin['badlocation'])
            {
                
$inforum["$loggedin[inforum]"]++;
            }
        }
        else if (empty(
$userinfos["$userid"]) OR ($userinfos["$userid"]['lastactivity'] < $loggedin['lastactivity']))
        {
            
$userinfos["$userid"] = $loggedin;
        }
    }

    
// We are a guest and somehow got missed by the query. 
    
if (!$vbulletin->userinfo['userid'] AND !$numberguest)
    {
        
$numberguest++;
    }

    
$activeusers = array();
/*    VBIV-12365 
    Users who are moderated or awaiting e-mail confirmation were being counted as guests. 
    This was causing online count discrepancies between this and online.php, removed code */
    
foreach ($userinfos AS $userid => $loggedin)
    {
        
$numberregistered++;
        if (
$userid != $vbulletin->userinfo['userid'] AND !$loggedin['badlocation'])
        {
            if (!isset(
$inforum["$loggedin[inforum]"]))
            {
                
$inforum["$loggedin[inforum]"] = 0;
            }
            
$inforum["$loggedin[inforum]"]++;
        }

        
fetch_musername($loggedin);
        
$loggedin['comma'] = $vbphrase['comma_space'];
        (
$hook vBulletinHook::fetch_hook('forumhome_loggedinuser')) ? eval($hook) : false;

        if (
fetch_online_status($loggedin))
        {
            
$numbervisible++;
            
$activeusers[$numbervisible] = $loggedin;
        }
    }

    
// Last element
    
if ($numbervisible
    {
        
$activeusers[$numbervisible]['comma'] = '';
    }

    
// memory saving
    
unset($userinfos$loggedin);

    
$db->free_result($forumusers);

    
$totalonline $numberregistered $numberguest;
    
$numberinvisible $numberregistered $numbervisible;

    
// ### MAX LOGGEDIN USERS ################################
    
if (intval($vbulletin->maxloggedin['maxonline']) <= $totalonline)
    {
        
$vbulletin->maxloggedin['maxonline'] = $totalonline;
        
$vbulletin->maxloggedin['maxonlinedate'] = TIMENOW;
        
build_datastore('maxloggedin'serialize($vbulletin->maxloggedin), 1);
    }

    
$recordusers vb_number_format($vbulletin->maxloggedin['maxonline']);
    
$recorddate vbdate($vbulletin->options['dateformat'], $vbulletin->maxloggedin['maxonlinedate'], true);
    
$recordtime vbdate($vbulletin->options['timeformat'], $vbulletin->maxloggedin['maxonlinedate']);

    
$show['loggedinusers'] = true;
}
else
{
    
$show['loggedinusers'] = false;




// ### BOARD STATISTICS #################################################

// get total threads & posts from the forumcache
$totalthreads 0;
$totalposts 0;
if (
is_array($vbulletin->forumcache))
{
    foreach (
$vbulletin->forumcache AS $forum)
    {
        
$totalthreads += $forum['threadcount'];
        
$totalposts += $forum['replycount'];
    }
}
$totalthreads vb_number_format($totalthreads);
$totalposts vb_number_format($totalposts);

// get total members and newest member from template
$numbermembers vb_number_format($vbulletin->userstats['numbermembers']);
$newuserinfo = array(
    
'userid'   => $vbulletin->userstats['newuserid'],
    
'username' => $vbulletin->userstats['newusername']
);
$activemembers vb_number_format($vbulletin->userstats['activemembers']);
$show['activemembers'] = ($vbulletin->options['activememberdays'] > AND ($vbulletin->options['activememberoptions'] & 2)) ? true false;

$templatevalues = array('activemembers' => $activemembers,
    
'activeusers' => $activeusers,
    
'newuserinfo' => $newuserinfo,
    
'numberguest' => $numberguest,
    
'numbermembers' => $numbermembers,
    
'numberregistered' => $numberregistered,
    
'totalonline' => $totalonline,
    
'totalposts' => $totalposts,
    
'totalthreads' => $totalthreads);
vB_Template::preRegister('footer'$templatevalues); 
Reply With Quote
  #19  
Old 12-04-2012, 05:04 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK, try putting the global $db line just inside the if, like:

Code:
// ### LOGGED IN USERS #################################################
if (($vbulletin->options['displayloggedin'] == 1 OR $vbulletin->options['displayloggedin'] == 2 OR ($vbulletin->options['displayloggedin'] > 2 AND $vbulletin->userinfo['userid'])) AND !$show['search_engine'])
{
    global $db;
    $datecut = TIMENOW - $vbulletin->options['cookietimeout'];
Reply With Quote
  #20  
Old 12-04-2012, 05:09 PM
CrumbDown CrumbDown is offline
 
Join Date: Feb 2012
Posts: 37
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Kev, you deserve a donation, really you do!!

Although this maybe different, how to get the stats to show on all templates?
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 01:31 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04801 seconds
  • Memory Usage 2,419KB
  • Queries Executed 13 (?)
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
  • (2)bbcode_code
  • (4)bbcode_php
  • (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
  • (2)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
  • (10)postbit_onlinestatus
  • (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_postinfo_query
  • fetch_postinfo
  • 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
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete