Firefox PHP

Module: Online Users

Posted by Maurice Makaay 
Re: Module: Online Users
April 07, 2009 10:24PM
tested for a couple of days and works like a charm



some comments/suggestions:

- I understand the guest counting process can be a little bit tricky. How accurate is it? When users choose not to be tracked, do they appear as guest or are they simply not counted at all?

- I get the list of registered online users plus the sum of guest. It is possible to get the count of registered users too?

Something like:

Registered (34): user1,user2,user3,... user34
Guest users (22)

Makes much more sense to me than without the registered users counter

- Is it possible to include the time in the „High records“ data? (Max users online 31 January at 22:55PM)


thanks for fixing this module
Re: Module: Online Users
December 24, 2009 06:53PM
Hi...i noticed that when i log out my user name shows like i'm still still online (after refreshing the page)...it goes away after 15 minutes or so?
I'm assuming that this has to do with this module......is there any way to make it accurate?

Thanks
Re: Module: Online Users
December 25, 2009 01:15AM
Actually, that is probably based on the General Settings > Cookie/Session Settings > Track User Usage. Chances are you have this set to 15 minutes. Depending on how busy your site is and how powerful your server, you can set this all the way to "Constantly."


Joe Curia (aka Azumandias)
Modules: l0Admin Mass Email00000000l000000Automatic Time Zones000ll.l00000Enhanced Custom Profiles0.00Google Calendar0000l.l000000Post Previews
000000000Admin Security Suite000000000000Check Modules for Upgrades0000External Authentication000000Group Auto-Email00000.00000Private Message Alerts
000000000Attachment Download Counter0000Custom Attachment Icons000ll.ll00Favorite Forums000000.00000Highlighted Search Terms0000Self-Delete Posts Option
000000000Attachment Watermarks0l00000000Custom Language Database00l.l.0Forum Lockdown00000.00000Ignore Forums0000000000000Threaded Tree View
000000000Automatic Message Pruning00.llll.00Easy Color Scheme Manager0l.l00Forum Subscriptions0000lll000Moderated User Group
Templates:lGeneric Integration000000000 0000Simple Rounded000000 00000000Tabbed Emerald
Re: Module: Online Users
December 29, 2009 06:15PM
I have a couple feature request for this module and if I had the skill to code I would been more than happy to code it in myself so I hope someone would be willing to pick it up and code some new features to this module.

I would like to see total count amount of both the Online Users and Online Hidden Users next to the Online Users title
Something like this in the title box at the top - Online Users 243 Users (23 Hidden)
Total counts of online and hidden are viewable to everyone.

I would like the administrators to be able to see the hidden usernames in the Online Users box with the ( ) like this (Maurice) but it is still hidden from the public and only viewable to the administrators. The hidden username are still hidden from regular user or public.

I would like to remove the (admin) next to the adminstrator username and make the adminstrator username bold in letter instead. Or make a different color text for the adminstrator.

Thank you
Bill
Re: Module: Online Users
December 29, 2009 07:32PM
And to add to Bill's requests, I would like to see the names listed one per line...

Bill
Bob
Joe
Maurice
Thomas

I utilize a sidebar on my site, and I thought it would be cool to put this information in the side bar somehow instead of right before the footer.

- Bob
Re: Module: Online Users
December 29, 2009 08:36PM
Some of the features you have requested can be easily (and most practically) implemented in the template provided by this module. If you have a custom template, copy the mods/onlineusers/templates/emerald folder to mods/onlineusers/templates/yourtemplate then edit the css.tpl and onlineusers.tpl as needed. For example:
{LOOP MOD_ONLINEUSERS->USERS}{VAR OU MOD_ONLINEUSERS->USERS}{IF NOT FIRST}, {/IF}<a href="{OU->PROFILE}">{OU->NAME}</a> {IF OU->ADMIN OR OU->IDLE}({/IF}{IF OU->ADMIN}{LANG->mod_onlineusers->Administrator}{/IF}{IF OU->ADMIN AND OU->IDLE}, {/IF}{IF OU->IDLE}{OU->IDLE}{/IF}{IF OU->ADMIN OR OU->IDLE}){/IF}{VAR FIRST 0}{/LOOP MOD_ONLINEUSERS->USERS}
in order to remove the (admin) and bold the admin's name could become:
{LOOP MOD_ONLINEUSERS->USERS}{VAR OU MOD_ONLINEUSERS->USERS}{IF NOT FIRST}, {/IF}<a href="{OU->PROFILE}"{IF OU->ADMIN} style="font-weight: bold;"{/IF}>{OU->NAME}</a> {IF OU->IDLE}({/IF}{IF OU->IDLE}{OU->IDLE}{/IF}{IF OU->IDLE}){/IF}{VAR FIRST 0}{/LOOP MOD_ONLINEUSERS->USERS}
or, in order to separate the names with a line break could become:
{LOOP MOD_ONLINEUSERS->USERS}{VAR OU MOD_ONLINEUSERS->USERS}{IF NOT FIRST}</br>{/IF}<a href="{OU->PROFILE}">{OU->NAME}</a> {IF OU->ADMIN OR OU->IDLE}({/IF}{IF OU->ADMIN}{LANG->mod_onlineusers->Administrator}{/IF}{IF OU->ADMIN AND OU->IDLE}, {/IF}{IF OU->IDLE}{OU->IDLE}{/IF}{IF OU->ADMIN OR OU->IDLE}){/IF}{VAR FIRST 0}{/LOOP MOD_ONLINEUSERS->USERS}


Joe Curia (aka Azumandias)
Modules: l0Admin Mass Email00000000l000000Automatic Time Zones000ll.l00000Enhanced Custom Profiles0.00Google Calendar0000l.l000000Post Previews
000000000Admin Security Suite000000000000Check Modules for Upgrades0000External Authentication000000Group Auto-Email00000.00000Private Message Alerts
000000000Attachment Download Counter0000Custom Attachment Icons000ll.ll00Favorite Forums000000.00000Highlighted Search Terms0000Self-Delete Posts Option
000000000Attachment Watermarks0l00000000Custom Language Database00l.l.0Forum Lockdown00000.00000Ignore Forums0000000000000Threaded Tree View
000000000Automatic Message Pruning00.llll.00Easy Color Scheme Manager0l.l00Forum Subscriptions0000lll000Moderated User Group
Templates:lGeneric Integration000000000 0000Simple Rounded000000 00000000Tabbed Emerald
Re: Module: Online Users
December 30, 2009 12:25AM
Quote
Joe Curia
Some of the features you have requested can be easily (and most practically) implemented in the template provided by this module. If you have a custom template, copy the mods/onlineusers/templates/emerald folder to mods/onlineusers/templates/yourtemplate then edit the css.tpl and onlineusers.tpl as needed. For example:
{LOOP MOD_ONLINEUSERS->USERS}{VAR OU MOD_ONLINEUSERS->USERS}{IF NOT FIRST}, {/IF}<a href="{OU->PROFILE}">{OU->NAME}</a> {IF OU->ADMIN OR OU->IDLE}({/IF}{IF OU->ADMIN}{LANG->mod_onlineusers->Administrator}{/IF}{IF OU->ADMIN AND OU->IDLE}, {/IF}{IF OU->IDLE}{OU->IDLE}{/IF}{IF OU->ADMIN OR OU->IDLE}){/IF}{VAR FIRST 0}{/LOOP MOD_ONLINEUSERS->USERS}
in order to remove the (admin) and bold the admin's name could become:
{LOOP MOD_ONLINEUSERS->USERS}{VAR OU MOD_ONLINEUSERS->USERS}{IF NOT FIRST}, {/IF}<a href="{OU->PROFILE}"{IF OU->ADMIN} style="font-weight: bold;"{/IF}>{OU->NAME}</a> {IF OU->IDLE}({/IF}{IF OU->IDLE}{OU->IDLE}{/IF}{IF OU->IDLE}){/IF}{VAR FIRST 0}{/LOOP MOD_ONLINEUSERS->USERS}
or, in order to separate the names with a line break could become:
{LOOP MOD_ONLINEUSERS->USERS}{VAR OU MOD_ONLINEUSERS->USERS}{IF NOT FIRST}</br>{/IF}<a href="{OU->PROFILE}">{OU->NAME}</a> {IF OU->ADMIN OR OU->IDLE}({/IF}{IF OU->ADMIN}{LANG->mod_onlineusers->Administrator}{/IF}{IF OU->ADMIN AND OU->IDLE}, {/IF}{IF OU->IDLE}{OU->IDLE}{/IF}{IF OU->ADMIN OR OU->IDLE}){/IF}{VAR FIRST 0}{/LOOP MOD_ONLINEUSERS->USERS}



Thank you I will give that a try!

Bill
Re: Module: Online Users
January 31, 2010 06:30AM
Hello!

First, a contribution for once! How to change the Idle time for a user to the time they last clicked/refreshed a page in AM/PM format (rather than how many minutes/seconds they are idle):

Starting at line 168 in onlineusers.php:
// Format the user's idle time.
        $idle = 0;
        if ($PHORUM['user']['user_id'] &&
            $user['user_id'] == $PHORUM['user']['user_id']) {
            // NOOP: Don't show idle time for the active Phorum user.
        }
        elseif ($PHORUM['mod_onlineusers']['show_idle_time']) {
            $idle_secs = ($user['date_last_active'] - 7*60*60)%(24*60*60);
			$ampm = ( ($idle_secs/3600) < 11) ? AM : PM ;
            if ($idle_secs) {
              $idle = sprintf("%d:%02d %s",$idle_secs/7200, floor(($idle_secs%3600)/60), $ampm);
            }
        }
Please do note that the number highlighted in blue (the 7) is changeable to determine the timezone you are in. Remove the number and the * that follows to set the timezone to GMT.

So the result is getting:
Pmac627 (9:34 PM) --> Time of the last page refresh
Rather than:
Pmac627 (34:08) --> Time elapsed since last page refresh

Second, a really easy modification that helps reduce the clutter if you have a lot of visitors at once.
Showing the idle time in the form of a tooltip rather than next to the username.

Starting at line 8 in onlineusers.tpl:
{LOOP MOD_ONLINEUSERS->USERS}{VAR OU MOD_ONLINEUSERS->USERS}{IF NOT FIRST}, {/IF}<a href="{OU->PROFILE}" title="{IF OU->IDLE}Idle since {OU->IDLE}{ELSE}Currently Active{/IF}" >{OU->NAME}</a> {IF OU->ADMIN OR OU->IDLE}({/IF}{IF OU->ADMIN}{LANG->mod_onlineusers->Administrator}{/IF}{IF OU->ADMIN AND OU->IDLE}, {/IF}{IF OU->IDLE}{OU->IDLE}{/IF}{IF OU->ADMIN OR OU->IDLE}){/IF}{VAR FIRST 0}{/LOOP MOD_ONLINEUSERS->USERS}
With that, you wont see the users idle time next to their username. It will appear in a tiny box when you hover your mouse pointer over it.
~~~~~~~~~~~~~~~~~
Now with those presented, I have 2 questions of my own.

#1) I saw some discussion about in the hacks forum, but I determined that it should work with the onlineusers module, hence the question being here. I would like to figure out how to add color to the usernames in the onlineusers module, depending on their group. I know how to go about that more or less, but I am having difficulty finding the variable I need. Is there a universal variable used for groups, perhaps a number? There must be one, because it is utilized by the user tagging module to enable an administrator to set a tag with certain groups.

#2) This is far more complex and might merit a separate module, though I see it as another possible upgrade/hack to this module. A "Last Click" page as it is commonly known as. Basically, its a page that expands upon what the Onlineusers module already does. It lists, in order of most recent activity, the users currently online as well as the time of the last click (idle time) and what the last page was that they were viewing/posting in. All of the necessary variables are already used in onlineusers except the record of the last page visited by a specific user. Is there a variable for this already in onlineusers.php? I have not found it if it is there. The module keeps track of how many views each forum and thread has received, so I would like to assume that even for a brief moment, the forum/thread being viewed is kept track of, whether it is simply the numerical values given to the page for the database or the physical URL.

I hope some of that made sense... it is late here. If either or both of these questions are not supposed to be in this thread, (despite my believing they are appropriate here), I will gladly move them to wherever they belong as directed.

Thank you for any and all help!
Re: Module: Online Users
January 31, 2010 10:22AM
In your module hack, you are doing time formatting yourself. That is a bad idea. Think only of the possibility for users and administrators to change the timezone, which will render your code to be incorrect. Additionally, there are functions available for formatting time, so there's no need to do all the hard labor yourself. I think your time format could be generated with the following code.
Language: PHP
$idle = phorum_date("%l:%M %p", $user[';date_last_active';]);
(in a general hack for the public, it would be even better to use one of the predefined time formats from the language file, instead of the hard-coded "%l:%M %p")

#1) The data is not available, because it takes additional SQL queries to grab the groups from the database and put them in the user data arrays. You could try if changing phorum_api_user_get($list) to phorum_api_user_get($list, TRUE) will work for you. It should add the group data to the users that you are looping over for formatting the output.

#2) Personally, I would find it rather invasive when my clickpath could be followed through this module. Are you sure that your user base is waiting for this feature? But putting that aside: the data that you want to display is not stored anywhere. The only thing that is stored, is the id of the forum in which the user last clicked. If you want to track all the extra data, then you would have to code all this tracking yourself, e.g. by storing the information in a separate database table. This could become quite heavy on a busy forum, since every action is logged.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: Module: Online Users
May 20, 2010 02:56AM
I have a shared Phorum installation that uses the same files over several domains, with different database configs for each domain. The online users module doesn't know this so the cache file was getting messed up with data from all the sites, so I changed the key to be unique like this:

Language: Diff
--- mods/onlineusers/onlineusers.php (revision 762) +++ mods/onlineusers/onlineusers.php (working copy) @@ -62,7 +62,7 @@ //print "DEBUG: is user"; if (onlineusers_db_search($track_id,';guest';) !== NULL) { onlineusers_db_delete($track_id,';guest';); - phorum_cache_remove(';onlineusers';,$PHORUM[';vroot';]."-data"); + phorum_cache_remove(';onlineusers';,$PHORUM["DBCONFIG"]["name"]."-".$PHORUM[';vroot';]."-data"); } else { return; } @@ -130,7 +130,7 @@ // cached data is available yet, then update the list of online users. $do_update = true; if (!empty($PHORUM[';mod_onlineusers';][';cache_time';])) { - $PHORUM[';mod_onlineusers';][';data';] = phorum_cache_get(';onlineusers';,$PHORUM[';vroot';]."-data"); + $PHORUM[';mod_onlineusers';][';data';] = phorum_cache_get(';onlineusers';,$PHORUM["DBCONFIG"]["name"]."-".$PHORUM[';vroot';]."-data"); if($PHORUM[';mod_onlineusers';][';data';] !== NULL) { $do_update = false; } @@ -139,9 +139,10 @@ if ($do_update) { mod_onlineusers_update(); if (!empty($PHORUM[';mod_onlineusers';][';cache_time';])) { + #print "Debug: cache key=" . $PHORUM["DBCONFIG"]["name"]."-".$PHORUM[';vroot';]."-data"; phorum_cache_put( ';onlineusers';, - $PHORUM[';vroot';]."-data", + $PHORUM["DBCONFIG"]["name"]."-".$PHORUM[';vroot';]."-data", $PHORUM[';mod_onlineusers';][';data';], $PHORUM[';mod_onlineusers';][';cache_time';] );

Maybe there's a better way, but it's working well for me.

Thanks
Skye

___
Skye Nott
Corvus Digital
Sorry, only registered users may post in this forum.

Click here to login