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

Reply
 
Thread Tools Display Modes
  #1  
Old 06-13-2018, 05:29 AM
ramesh_umk3 ramesh_umk3 is offline
 
Join Date: Jul 2010
Location: Earth
Posts: 194
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Total Stats PHP 5.6 Issue.

Hello all,

As the title says the code i have been using for forum stats stopped working on php 5.6 version.

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);
$templater->register('facebook_header'$facebook_header);
//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(); 
The error i am getting is
PHP Code:
mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead
/home/XXXXXXX/public_html/XXXX.com/includes/class_core.php on line 315 
Could anyone make the code compatible with php 5.6

really thanks.

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

Solved:

1) Goto includes/class_core.php

Search:
PHP Code:
set_error_handler('catch_db_error'); 
Replace:
PHP Code:
//set_error_handler('catch_db_error'); 
Search:
PHP Code:
$link $this->functions[$usepconnect 'pconnect' 'connect']("$servername:$port"$username$password); 
Replace:
PHP Code:
@$link $this->functions[$usepconnect 'pconnect' 'connect']("$servername:$port"$username$password); 
Thanks to NewEraCracker
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 02:19 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.03311 seconds
  • Memory Usage 2,275KB
  • Queries Executed 11 (?)
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
  • (6)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)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_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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete