vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Stats Display Code Doesnt Work on 4.2.5 (https://vborg.vbsupport.ru/showthread.php?t=327139)

ramesh_umk3 03-11-2019 10:10 AM

Stats Display Code Doesnt Work on 4.2.5
 
Hello,

Once i have updated client board i see stats code which was shared in vbulletin.com doesnt work any more. When i try to use it throws me SQL Data base error

Can anyone please fix the code for vBulletin 4.2.5 , Using MariaDB, PHP 5.6

PHP Code:

//CUSTOM FOR DISPLAY OF STATS IN HEADER

require_once('./includes/functions_bigthree.php');
require_once(
'./includes/functions_forumlist.php');

// ### LOGGED IN USERS #################################################
$activeusers '';
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;

//ADDED
$db = new vB_Database($vbulletin);

// make database connection
$db->connect(
    
$vbulletin->config['Database']['dbname'],
    
$vbulletin->config['MasterServer']['servername'],
    
$vbulletin->config['MasterServer']['port'],
    
$vbulletin->config['MasterServer']['username'],
    
$vbulletin->config['MasterServer']['password'],
    
$vbulletin->config['MasterServer']['usepconnect'],
    
$vbulletin->config['SlaveServer']['servername'],
    
$vbulletin->config['SlaveServer']['port'],
    
$vbulletin->config['SlaveServer']['username'],
    
$vbulletin->config['SlaveServer']['password'],
    
$vbulletin->config['SlaveServer']['usepconnect'],
    
$vbulletin->config['Mysqli']['ini_file'],
    (isset(
$vbulletin->config['Mysqli']['charset']) ? $vbulletin->config['Mysqli']['charset'] : '')
);

// define table prefix constant
define('TABLE_PREFIX'trim($vbulletin->config['Database']['tableprefix']));
//EO ADDED

    
$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 for an initial page view of index.php
        
$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;
        }
    }

    if (!
$vbulletin->userinfo['userid'] AND $numberguest == 0)
    {
        
$numberguest++;
    }

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

        (
$hook vBulletinHook::fetch_hook('forumhome_loggedinuser')) ? eval($hook) : false;

        if (
fetch_online_status($loggedin))
        {
            
$numbervisible++;
            
$show['comma_leader'] = ($activeusers != '');
            
$templater vB_Template::create('forumhome_loggedinuser');
                
$templater->register('loggedin'$loggedin);
            
$activeusers .= $templater->render();
        }
    }

    
// 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;
}

// ### GET FORUMS & MODERATOR iCACHES ########################
cache_ordered_forums(11);
if (
$vbulletin->options['showmoderatorcolumn'])
{
    
cache_moderators();
}
else if (
$vbulletin->userinfo['userid'])
{
    
cache_moderators($vbulletin->userinfo['userid']);
}

// define max depth for forums display based on $vbulletin->options[forumhomedepth]
define('MAXFORUMDEPTH'$vbulletin->options['forumhomedepth']);

$forumbits construct_forum_bit($forumid);
$forumhome_markread_script vB_Template::create('forumhome_markread_script')->render();

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

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

$totalthreads vb_number_format($totalthreads);
$totalposts vb_number_format($totalposts);

//ADDED
// check if userstats array is populated, else build it (on non-forum pages, e.g. member.php, usercp.php, etc., these stats aren't necessarily available, so need to build them)
if(!count($vbulletin->userstats)){
    require_once(
'./includes/functions_databuild.php');
    
$vbulletin->userstats build_user_statistics();
    
//exit(print_r($vbulletin->userstats));
}
//EO ADDED

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

//EO CUSTOM FOR DISPLAY OF STATS IN HEADER

$templater vB_Template::create('header');
    
$templater->register('ad_location'$ad_location);
    
$templater->register('pmbox'$pmbox);
    
$templater->register('notifications_menubits'$notifications_menubits);
    
$templater->register('notifications_total'$notifications_total);
    
$templater->register('notices'$notices);
//CUSTOM FOR DISPLAY OF STATS IN HEADER
    
$templater->register('numberguest'$numberguest);
    
$templater->register('numbermembers'$numbermembers);
    
$templater->register('numberregistered'$numberregistered);
    
$templater->register('totalonline'$totalonline);
    
$templater->register('activemembers'$activemembers);
    
$templater->register('activeusers'$activeusers);
    
$templater->register('totalposts'$totalposts);
    
$templater->register('totalthreads'$totalthreads);
//EO CUSTOM FOR DISPLAY OF STATS IN HEADER
$header $templater->render(); 

Thank in advance.

--------------- Added [DATE]1552303048[/DATE] at [TIME]1552303048[/TIME] ---------------

All i need is

{vb:raw totalonline}

and

{vb:raw numbermembers}

to be used in header bar.

Looking forward

Really thanks.

romaine 03-11-2019 02:56 PM

What PHP version are you using?

ramesh_umk3 03-12-2019 03:34 AM

Hello romaine

vBulletin 4.2.5
Using MariaDB
PHP 5.6

--------------- Added [DATE]1552371254[/DATE] at [TIME]1552371254[/TIME] ---------------

Solved.

Thanks All.


All times are GMT. The time now is 07:10 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.01907 seconds
  • Memory Usage 1,828KB
  • 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
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)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