vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Currently Active Users widget ? (https://vborg.vbsupport.ru/showthread.php?t=230319)

Charlie98902 12-17-2009 12:25 AM

Dang Bart thought you hit the jackpot till Lynne replied :D

Awaiting to hear how to do this or give the wiget to others in the mod section.

bart6767 12-17-2009 12:29 AM

Quote:

Originally Posted by Charlie98902 (Post 1931974)
Dang Bart thought you hit the jackpot till Lynne replied :D

Awaiting to hear how to do this or give the wiget to others in the mod section.

Lol someone will get it to work :D

Charlie98902 12-17-2009 01:10 AM

Quote:

Originally Posted by bart6767 (Post 1931976)
Lol someone will get it to work :D

We nominated you to be "The One" :D

bart6767 12-17-2009 01:26 AM

Quote:

Originally Posted by Charlie98902 (Post 1931991)
We nominated you to be "The One" :D

no luck here :(

Lynne 12-17-2009 02:49 AM

Did anybody try it? It really is just that code with a couple of tweaks - must include functions_bigthread and also make $vbulletin and $db global. It gets spit out as a list on my site now cuz I didn't do anything css-wise, but it works.

Vaupell 12-17-2009 06:10 AM

welll tryed using the forum.php code
and then print_output a template with only one line
i took from the whats goin on box..


Php widget
PHP Code:

$globaltemplates = array('EOnlinebox',
);


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

$templater vB_Template::create('EOnlinebox");
$templater->register_page_templates();
$templater->register('
EOnlinebox', $totalonline);
print_output($templater->render()); 


yeah its a mess, and needs cleanup, lots of wasted features, but just took the code from forum.php
figureing makeing that work, it would be better to clean up later.




Template : [EOnlinebox]
Code:

<!-- logged-in users -->
{vb:rawphrase there_are_x_online, {vb:raw totalonline}} {vb:rawphrase x_members_and_y_guests, {vb:raw numberregistered}, {vb:raw numberguest}}
<!-- end logged-in users -->

tryed a few things out, and resultet in some different things

- cleared entire cms page and only wrote the online line
- added errors ontop of the cms page where the widget is placed
- result in db errors

so kinda clueless to makeing it work in a widget,
and cant find any php widgets to download and see how they work as a eksample..

ragtek 12-17-2009 06:47 AM

Quote:

Originally Posted by Lynne (Post 1932031)
Did anybody try it? It really is just that code with a couple of tweaks - must include functions_bigthread and also make $vbulletin and $db global. It gets spit out as a list on my site now cuz I didn't do anything css-wise, but it works.

$vbulletin and $db global? aeeeeeehm pls not;) use vB::$db-> and vB::$vbulletin-> in widgets ;)

bart6767 12-17-2009 07:23 AM

Quote:

Originally Posted by Lynne (Post 1932031)
Did anybody try it? It really is just that code with a couple of tweaks - must include functions_bigthread and also make $vbulletin and $db global. It gets spit out as a list on my site now cuz I didn't do anything css-wise, but it works.

I tryed a few things with no luck .

Can you post the code you used that worked for you ? so i can test it .

Lynne 12-17-2009 03:48 PM

Quote:

Originally Posted by ragtek (Post 1932094)
$vbulletin and $db global? aeeeeeehm pls not;) use vB::$db-> and vB::$vbulletin-> in widgets ;)

Thanks. I was just doing it real quick to see that it would work before actually doing it correctly. :)
Quote:

Originally Posted by bart6767 (Post 1932104)
I tryed a few things with no luck .

Can you post the code you used that worked for you ? so i can test it .

I'll try to put it together (need to put together an install text file) and post it in the widget mods area if no one else does sooner.

ragtek 12-17-2009 04:08 PM

Quote:

Originally Posted by Lynne (Post 1932313)
I'll try to put it together (need to put together an install text file) and post it in the widget mods area if no one else does sooner.

yea, sounds nice:)


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.01285 seconds
  • Memory Usage 1,811KB
  • 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_code_printable
  • (1)bbcode_php_printable
  • (8)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete