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)

bart6767 12-16-2009 01:52 PM

Currently Active Users widget ?
 
1 Attachment(s)
I have added a Currently Active Users widget ? to my CMS and it shows up fine but does anyone know how to make it update and refresh ?

Look at the photo below .

And does anyone know how to do this with PHP ? rather than static HTML

This is the code i used .

Code:

<!-- logged-in users -->
                        <div id="wgo_onlineusers" class="wgo_subblock">
                                <h3><img src="images/misc/users_online.png" alt="Currently Active Users" />Currently Active Users</h3>
                                <div>
                                        <p>There are currently <a href="online.php">8 users online</a>. <span class="shade">4 members and 4 guests</span></p>
                                        <p>Most users ever online was 37, 11-29-2009 at <span class="time">02:54 PM</span>.</p>
                                        <ol class="commalist" id="wgo_onlineusers_list">
                                                <b> <font color="red">• Administrators</font> <font color="666600">• Super Moderators</font> • Moderators • Registered Users </b><br /><br />  <li> <a class="username" href="member.php?1-The-Voice-of-champions"> <font color="red">The Voice of champions</font></a></li>      <li> <a class="username" href="member.php?49-BIG-SOOTY">BIG SOOTY</a></li>      <li> <a class="username" href="member.php?23-Mark-Ryan">Mark Ryan</a>+</li>      <li> <a class="username" href="member.php?19-tak1888"><font color="666600">tak1888</font></a>+</li>   
                                        </ol>
                                </div>
                        </div>
                        <!-- end logged-in users -->


ZexTasy 12-16-2009 06:30 PM

That is no PHP code, just static HTML ... you need to use PHP code and queries to get the updated information.

bart6767 12-16-2009 06:49 PM

Quote:

Originally Posted by ZexTasy (Post 1931807)
That is no PHP code, just static HTML ... you need to use PHP code and queries to get the updated information.

I know that but i posted here to see if anyone knew how to do it ?

Lynne 12-16-2009 10:13 PM

Have you tried copying the php code from the forum.php page?

Vaupell 12-16-2009 10:38 PM

im thinking makeing a template, and then make the widget and register the template
and then print_output

just like a normal php page, but inside the widget instead..

bart6767 12-16-2009 10:43 PM

Quote:

Originally Posted by Lynne (Post 1931917)
Have you tried copying the php code from the forum.php page?

Might try that .

Do you know what the code is or the php code that im looking for ?

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

Ok i found this and i think this is the right code .

How would i go about adding this to the PHP Widget ? what is the output in the last line .

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


Lynne 12-16-2009 10:53 PM

Quote:

Originally Posted by bart6767 (Post 1931939)
Might try that .

Do you know what the code is or the php code that im looking for ?

Did you try looking at the file before asking? It's pretty well commented with LOGGED IN USERS in big capital letters to tell you where the code is. :)

bart6767 12-16-2009 10:58 PM

Quote:

Originally Posted by Lynne (Post 1931947)
Did you try looking at the file before asking? It's pretty well commented with LOGGED IN USERS in big capital letters to tell you where the code is. :)

lol found it before you posted :D

And what should the full code be to add it to the widget so i can try it .

I posted it in post 6 but not sure what the last line should be with the output .

Lynne 12-16-2009 11:06 PM

You'll have to try things out and see what you need. The php code is in the forum.php file and the template code needed to output it is probably in the FORUMHOME template. If it isn't in there, then do this to find the template - vboptions > General Settings > Add Template Name in HTML Comments > set to Yes . Then go back to your page and view the source code and you will see the name of the template called around your part of the code.

That should give you plenty of information to go try this out on your test site and get it working.

bart6767 12-16-2009 11:29 PM

Quote:

Originally Posted by Lynne (Post 1931952)
You'll have to try things out and see what you need. The php code is in the forum.php file and the template code needed to output it is probably in the FORUMHOME template. If it isn't in there, then do this to find the template - vboptions > General Settings > Add Template Name in HTML Comments > set to Yes . Then go back to your page and view the source code and you will see the name of the template called around your part of the code.

That should give you plenty of information to go try this out on your test site and get it working.

Thanks i will try that and see what happens .:up:


All times are GMT. The time now is 08:34 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.01455 seconds
  • Memory Usage 1,820KB
  • 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
  • (5)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