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

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 09-19-2008, 03:04 AM
biome.pat biome.pat is offline
 
Join Date: Aug 2008
Location: Toronto, ON, Canada
Posts: 43
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Modified "What's Going On" has a glitch in currently active users

Hey folks!

So get ready for some agonizingly sloppy code, because I'm an amateur here.
I've been playing around with index.php in order to tweak the "What's Going On" box. I wanted it to list only registered users and mods (id: 2 & 7) as "Currently Active Users", and instead of guests representing unregistered users (who have no access to the board anyhow), I wanted that variable to reflect the number of browsing users who had yet to be moderated (id: 4 -- we allow unmoderated users to browse only, but not post). Those who haven't confirmed their email yet (id: 3), have no access at all.

Since only fully registered users' names have been approved, we only wanted to list them (not folks awaiting email verification nor moderation). My boss panicked a few times when it appeared as if students had managed to sign up with lewd usernames, so that's why he's got me doing this.

So I think I've got it all done (albeit sloppily, as I said), except that there's always an extra comma somewhere (plus one extra user in the active user count), and since it's right after the logged in user when in alpha order, I'm assuming it's reading me twice.

Any ideas? It says BIOME_EDIT wherever I changed something...

PHP Code:
// ### 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;

    
$forumusers $db->query_read_slave("
        SELECT
            user.username, (user.options & " 
$vbulletin->bf_misc_useroptions['invisible'] . ") AS invisible, user.usergroupid,
            session.userid, session.inforum, session.lastactivity,
            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,
                
'usergroupid'       =>& $vbulletin->userinfo['usergroupid'],
                
'displaygroupid'    =>& $vbulletin->userinfo['displaygroupid'],
                
'infractiongroupid' =>& $vbulletin->userinfo['infractiongroupid'],
            )
        );
    }
    else
    {
        
$userinfos = array();
    }
    
$inforum = array();

    while (
$loggedin $db->fetch_array($forumusers))
    {
        
$usergroupid $loggedin['usergroupid']; //BIOME_EDIT
        
$userid $loggedin['userid'];
        if (
$usergroupid == 4)
        {    
// Guest BIOME_EDIT(Pending)
            
$numberguest++;
//**BIOME_EDIT    $inforum["$loggedin[inforum]"]++;
        
}
        else if (empty(
$userinfos["$userid"]) OR ($userinfos["$userid"]['lastactivity'] < $loggedin['lastactivity']))
        {
            
$userinfos["$userid"] = $loggedin;
        }
    }
//**BIOME_EDIT
//    if (!$vbulletin->userinfo['userid'] AND $numberguest == 0)
//    {
//        $numberguest++;
//    }
//
    
if ($userinfos["$userid"]['usergroupid'] == OR $userinfos["$userid"]['usergroupid'] == OR $userinfos["$userid"]['usergroupid']== OR $userinfos["$userid"]['usergroupid'] == 7)
    {
        foreach (
$userinfos AS $userid => $loggedin)
        {
            
$numberregistered++;
            if (
$userid != $vbulletin->userinfo['userid'])
            {
                
$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 != '');
                eval(
'$activeusers .= "' fetch_template('forumhome_loggedinuser') . '";');
            }
        }
    }

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

    
$db->free_result($forumusers);

    
$totalonline $numberregistered//BIOME_EDIT Prevent guests from being counted in total online and records + $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;

Reply With Quote
 


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:10 PM.


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.06770 seconds
  • Memory Usage 2,434KB
  • 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)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (2)post_thanks_box
  • (2)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit_info
  • (2)postbit
  • (1)postbit_attachment
  • (2)postbit_onlinestatus
  • (2)postbit_wrapper
  • (1)showthread_list
  • (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_threadedmode.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_threaded
  • showthread_threaded_construct_link
  • 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
  • postbit_attachment
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete