"Who is online" plugin (onlinestats) "Who is online" plugin (onlinestats)
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

"Who is online" plugin (onlinestats)

Started by Joachim Müller, January 16, 2006, 02:34:00 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Joachim Müller

Nibbler, the author of the popular mod "A phpbb style 'who is online' block" has posted a plugin version of this mod. The advantage of using a plugin compared to the mod is that you won't have to re-apply all code changes when updating your coppermine gallery, and setting it up in the first place should be easier.
Please note though that the plugin is considered experimental - use it at your own risk and report possible flaws here, but test it thorougly first and read the caveats on the mod thread I refered to above.

What it does:
Displays number and identity of users currently browsing the gallery.
This plugin has been created for cpg1.4.x


How to install:
  • Log into your coppermine page as admin
  • Go to coppermine's config, expand "General settings", click "Manage plugins" next to "Enable plugins" (make sure that you have set "Enable plugins to "Yes"). Alternatively, you can directly access the plugin manager by entering http://yoursite.tld/your_coppermine_folder/pluginmgr.php into the address bar of your browser
  • On the plugin manager page, click "browse", navigate to the plugin zip, click "upload". Alternatively, you can unzip the plugin on your client (preserving the folder structure) and then FTP-upload the unzipped folder into the plugins sub-folder of your coppermine install.
  • If the plugin has been unzipped properly on your server, the plugin manager should refresh and you should see the plugin listed in the section "Plugins Not installed". Click the install icon (the "i") next to it
  • If the plugin has got a configuration screen, go through it and submit your changes. "Onlinestats" does have a configuration screen that prompts for the time users should be displayed as being online before dropping out of the index for inactivity. It is recommended that you keep the default value.
  • Most plugins are then ready for use and active. Onlinestats has to be enabled separately, see below.


How to enable:
To enable this plugin, you'll have to add "onlinestats" to "the content of the main page" in coppermine's config in the section "Album list view". The setting should look like "breadcrumb/catlist/alblist/onlinestats" or similar. For details, review the documentation that comes with coppermine (inside the docs folder) in the section "The gallery configuration page" > "Album list view" > "The content of the main page".

Known issues:
The plugin currently comes in English, Dutch, French, German and Italian. To translate it, add you language file to the lang folder within the plugin's folder.


Credits:
This plugin was created by Nibbler. It is based on the "Who is online mod" for cpg1.3.x.
Don't try to contact the plugin author for support - post on the board publicly instead.


Caveats:
This plugin is still in an early beta stage (experimental). Please report possible bugs or improvements on the thread that deals with it: http://forum.coppermine-gallery.net/index.php?topic=26532.0
The plugin runs additional queries on the database each time it is being executed, burning cpu cycles and using resources. If your coppermine gallery is slow or has got a lot of users, you shouldn't use it.
[Edit GauGau 2006-12-04]Plugin should be pretty stable.[/edit]

Changes:
From 1.1 to 1.2
  • Fixed the set duration not being taken into account
From 1.2 to 1.6
  • Unknown changes, contributors failed to modify readme file
From 1.6 to 1.7
  • Updated version number in header
  • Re-packaged with language files
  • Minor fixes in HTML output for standards compliance
From 1.7 to 1.8
  • Improved bridge compatibility
  • Added Spanish and Lithuanian language files (user contributions)
  • Corrected double application of timezone offset
  • Added missing code in uninstall to clean records
  • Minor changes to english lang file

Joachim

Paver

For a historical lesson and for those who download the plugin above before GauGau replaces it with a 1.4.3 working version, please see this thread:
http://forum.coppermine-gallery.net/index.php?topic=26447.0

Joachim Müller

As Paver suggested I modified the plugin accordingly and updated the first posting in this thread. Users running the stable releases of cpg1.4.x should use the first attachment. The second attachment is the "old", buggy plugin that was initially made for the unsupported beta cpg1.4.1 and is not recommended for use - I only added it for historical reasons.

Changes:
  • Added a readme file that explains how to install and set up the plugin
  • Renamed the folder from "online" to "onlinestats" for consistency reasons
  • Applied the suggested changes by Paver in the thread he refered to above

Updating:
If you already have the old plugin installed, unsinstall it first (using the plugin manager) before installing the updated version from above

Joachim

clarus

This plugin is very usefull!!! Thanks!
100% workable!  ;D

Yukino

you seriously rock my freakin' socks!

i have this running no problems as of yet.

many thanks!!

esdee51

This plugin works great. I'm using phpbb 2.0.19 & cpg 1.4.3 bridged.

Just one question - line 81 in codebase.php has
cpg_db_query("DELETE FROM {$CONFIG['TABLE_ONLINE']} WHERE last_action < NOW() - INTERVAL 60 MINUTE");

Should 60 not be changed to 10 or whatever is set in the configuration when installing the plugin?

I'm a newbie so please excuse me if I am wrong.

Paver

#6
esdee51: What a smart cookie you are!  You are absolutely correct.  I am vindicated because I said I didn't test out this plugin, but all you others who are using it should be ashamed of yourselves.  Well, not really since it's not something you can check that easily without a tremendous amount of patience - unless you look at the code like this inquistive newbie here.

So, going to that line, add the following lines before it:
$result = cpg_db_query("SELECT value FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'mod_updates_duration'");
$row = mysql_fetch_row($result);
$duration = $row[0];

Then modify that line to replace '60' with $duration as shown:
cpg_db_query("DELETE FROM {$CONFIG['TABLE_ONLINE']} WHERE last_action < NOW() - INTERVAL $duration MINUTE");

NOTE: This addition is not the most efficient way to do this.  Read a few posts down for the better modification.

And there you have it.  I think.  I still haven't tested out this plugin thoroughly.   :P

esdee51

Thanks Paver :)

It now works perfectly!

I notice a difference in the total number of users as shown by this plugin and in phpBB. This shows 1 more than the total number. Possibly it is due to user_id starting from 1 in CPG whereas phpBB has an additional user_id as -1 for Anonymous, which is not there in the CPG table.
Right now I have taken care of this by changing line 121 of codebase.php (the original file dated 17/01/2006) from:

        $num_users = $num_users[0];
to
       $num_users = $num_users[0] - 1;

I am sure there is a more elegant way to get over this problem as it might be present in other bridged installations as well.


Joachim Müller

@Paver: is it really necessary to run the additional query to check for the config var? Imo it should already exist, the $CONFIG var should be populated already.

Paver

#9
GauGau: You're absolutely correct. 

So the only mod necessary is to change this line:
cpg_db_query("DELETE FROM {$CONFIG['TABLE_ONLINE']} WHERE last_action < NOW() - INTERVAL 60 MINUTE");
to this line, replacing '60' with the config value:
cpg_db_query("DELETE FROM {$CONFIG['TABLE_ONLINE']} WHERE last_action < NOW() - INTERVAL {$CONFIG['mod_updates_duration']} MINUTE");

I'll note it above.

Joachim Müller

thanks for looking into this. I updated the first posting on this thread with your fix, changing version count to 1.2

Paver

esdee51: You mentioned a $num_users discrepancy.  I'm using an unbridged installation and there is an entry for Anonymous in the Coppermine users table.  What you mentioned about the starting number is irrelevant I believe because it doesn't matter what the user_id is; $num_users is just a count of the number of records in the Coppermine users table - it doesn't use the user_id to detemine the count.

It sounds like the discrepancy you found is due to a sync issue in your bridge.  Maybe it's supposed to be that way; I just don't know.  I haven't looked into bridges.  If the mod you mentioned does what you want, that's great.  If you want to investigate the bridge users count and match up users even, that information may be useful if it's a real issue in the bridging.  Check the bridge board and share information if it's useful & relevant.  As I said, it may be "by design" and if that's true, then this plugin could be modified with an option or something to deal with this.

As it is now, the plugin counts the correct number of users in the Coppermine users table.

silyashevich

If this plugin installed - Mozilla Firefox not work with cookies gallery :( IExplorer - working.
If uninstall plugin - Firefox working.
AND have no problem with firefox (v 1.0.6) - its works correctly. Maybe bug?
Sorry if i not right.

Gary B

I have been trying to get this plugin to work...it seems to me that I can only get it to work if I don't have bridging turned on to my phpbb. Then it worked just fine. When I tried (after I saw it working) to re-enable bridging I got the following error messages when I tried to enter the gallery.
Template error
Failed to find block 'admin_approval'(#(<!-- BEGIN admin_approval -->)(.*?)(<!-- END admin_approval -->)#s) in :

                <div align="center">
                <table cellpadding="0" cellspacing="1">
                        <tr>

                                <td class="admin_menu"><a href="admin.php" title="{ADMIN_TITLE}">{ADMIN_LNK}</a></td>
                                <td class="admin_menu"><a href="catmgr.php" title="{CATEGORIES_TITLE}">{CATEGORIES_LNK}</a></td>
                                <td class="admin_menu"><a href="albmgr.php{CATL}" title="{ALBUMS_TITLE}">{ALBUMS_LNK}</a></td>
                                <td class="admin_menu"><a href="groupmgr.php" title="{GROUPS_TITLE}">{GROUPS_LNK}</a></td>
                                <td class="admin_menu"><a href="usermgr.php" title="{USERS_TITLE}">{USERS_LNK}</a></td>
                                <td class="admin_menu"><a href="banning.php" title="{BAN_TITLE}">{BAN_LNK}</a></td>
                                <td class="admin_menu"><a href="reviewcom.php" title="{COMMENTS_TITLE}">{COMMENTS_LNK}</a></td>
<!-- BEGIN log_ecards -->
                                <td class="admin_menu"><a href="db_ecard.php" title="{DB_ECARD_TITLE}">{DB_ECARD_LNK}</a></td>
<!-- END log_ecards -->
                                <td class="admin_menu"><a href="picmgr.php" title="{PICTURES_TITLE}">{PICTURES_LNK}</a></td>
                                <td class="admin_menu"><a href="searchnew.php" title="{SEARCHNEW_TITLE}">{SEARCHNEW_LNK}</a></td>
                                <td class="admin_menu"><a href="util.php" title="{UTIL_TITLE}">{UTIL_LNK}</a></td>
                                <td class="admin_menu"><a href="profile.php?op=edit_profile" title="{MY_PROF_TITLE}">{MY_PROF_LNK}</a></td>
<!-- BEGIN documentation -->
                                <td class="admin_menu"><a href="{DOCUMENTATION_HREF}" title="{DOCUMENTATION_TITLE}" target="cpg_documentation">{DOCUMENTATION_LNK}</a></td>
<!-- END documentation -->
                        </tr>
                </table>
                </div>



Which is very odd since before I installed the plugin and had bridging installed I had never seen the errors above before.

www.themeparks.com/library

Guests have access to everything except uploading as I don't allow uploading except for admins.

Best Wishes
Gary

Paver

@Gary B: I'm not exactly sure why you get this error with this plugin; I'll have to look into this more - I tried a quick "follow the code", but haven't figured it out yet.

But there is a way to fix this error.  I started a post to describe this frequently-asked question about the "Template error - Failed to find block...", but I haven't finished it so it's not posted yet.

This is a theme error where you probably have customized the $template_gallery_admin_menu variable and left out the admin_approval block.  Please compare what you have in your theme/theme.php with the sample/theme.php and copy the <!-- BEGIN admin_approval --> and END tags as shown.  If you don't want the actual admin_approval button to show up, just leave the space between the BEGIN & END tags blank, but you need to have those tags because Coppermine is looking for them.  By leaving them blank, that's the proper way to remove a button.  (That's what my post will describe in detail.)

I'm not sure why this plugin activates the Coppermine core code to look for this admin_approval block; that's what I need to figure out.  But I'm pretty sure it's in the Coppermine core so some other "standard" use of an un-added-on-to-Coppermine would have probably brought out this defect in your theme; this plugin somehow has exposed it now.  (When I say defect, it's just that the theme.php file has to be more strict than you might think since Coppermine expects certain tags and gets upset - rightly or wrongly - when they are missing.)

Paver

@silyashevich: Please post more information about your Coppermine version and what you mean about cookies problem.  I don't understand what to look for.  I'm using FireFox 1.5 and have no problem with this plugin.  (You should look into upgrading to FireFox 1.5 but I don't think it's related to your problem.)

silyashevich

Quote from: Paver on January 23, 2006, 06:21:47 AM
@silyashevich: Please post more information about your Coppermine version and what you mean about cookies problem.  I don't understand what to look for.  I'm using FireFox 1.5 and have no problem with this plugin.  (You should look into upgrading to FireFox 1.5 but I don't think it's related to your problem.)
With plugin is ON: when come into gallery one browser, for example Mozilla Firefox and then leave galrey. With other browser, for example Internet Explorer not unable to login. The gallery loading and on rediract page writes a mistake - " the browser does not accept cookies ".

sorry for bad english  :-[

Joachim Müller

post more details instead of just rephrasing - a link might be a good start.

Konstantinos


lordprodigy

I have another issue / suggestion about this plugin regarding permissions...

In the who is online block, there are the nicknames of the registered users, which are linked to their respective profiles. Me as a non registered user I can click on them and view their profile... I think its wrong (privacy concerns) and would like the nicknames to be clickable only if I am logged in. If I am a non logged in used, I would like either a) when you click on the profile, to take you to registration / login page, or, b) make them non linked.

I dont know if I make myself clear. I hope someone can do this. I dont mind either solution, whichever one is easier to code.

Im thinking out loud.. can we add something like this
if (!USER_ID) cpg_die(ERROR, 'You need to register to access this page', __FILE__, __LINE__);

in profile.php ... ?