Page 1 of 92

Activity Stats MOD

Posted: Wed Mar 19, 2008 6:24 pm
by Extensions Robot
Modification name: Activity Stats MOD
Author: 5hocK
Modification description: - Lists of all registered users who have visited the board in the last 24 hours.
- Lists stats on the number of new posts, new topics and new users within the last 24 hours on the index
Modification version: 1.0.2
Tested on phpBB version: 3.0.12

Download file: activity_stats_mod.1.0.2.zip
File size: 63.09 KiB

Modification overview page: View

The phpBB Team is not responsible nor required to provide support for this modification. By installing this MOD, you acknowledge that the phpBB Support Team or phpBB Extensions Team may not be able to provide support.

-->Modification support<--

Activity Stats MOD

Posted: Wed Mar 19, 2008 6:24 pm
by Paul
Modification validated/released

Notes:

Activity Stats MOD

Posted: Wed Mar 19, 2008 6:24 pm
by Highway of Life
Supported Languages: (Credits)
  • English by Highway of Life
Styles supported:
  • prosilver
  • subsilver2
MOD Format:
Image

Notes:
  • If you enjoy this MOD, please consider supporting our MODing effort by donating to phpBB Academy at StarTrekGuide. Thanks!
Credits:
Geoffreak for the awesome automated MODX generator

Future Development:
If you have feature requests, bug reports or suggestions for the next version of the Activity Stats MOD, please post them here: http://www.phpbb.com/community/viewtopi ... &t=1339955

Support Topics:
STG Support Topic
phpBB.com Support Topic
phpBBModders Support Topic

Screenshots:
Image
[ Click for full size ]

Image
[ Click for full size ]

Demo:
prosilver demo
subsilver2 demo

FAQ:
Q: Why won’t it update the new posts/topics every time a new post is made?
A: This is because it caches the data for one hour, this means that this MOD will not be a burden on the server.
If the data refreshed for each post, it would be an unnecessary load on the Database with the extra queries for each user who loads the index page.

--------oOo--------

Q: Why does it sort based on Caps and can I get it to sort case insensitive?
A: Small oversight, you can get it to sort case insensitive by doing the following:
OPEN: includes/functions_activity_stats.php
FIND:

Code: Select all

'ORDER_BY'    => 'u.username',      
REPLACE, WITH:

Code: Select all

'ORDER_BY'    => 'u.username_clean',      
--------oOo--------

Q: How can I get the list to exclude the bots (spiders)?
A: OPEN: includes/functions_activity_stats.php
FIND:

Code: Select all

'WHERE'        => 'u.user_lastvisit > ' . (time() - 86400) . ' OR s.session_user_id <> ' . ANONYMOUS,     
REPLACE, WITH:

Code: Select all

'WHERE'        => 'u.user_type <> ' . USER_IGNORE . ' AND (u.user_lastvisit > ' . (time() - 86400) . ' OR s.session_user_id <> ' . ANONYMOUS . ')',    
--------oOo--------

Q: How do I ensure hidden users are really hidden?
A: To ensure that hidden users are hidden, perform the following change(s).
Please note that this code has NOT been tested. Ensure you know how to edit PHP well enough to implement this change prior to making these changes.

OPEN: /includes/functions_activity_stats.php

FIND:

Code: Select all

global $template, $user;   
REPLACE, WITH:

Code: Select all

global $template, $user, $auth;   
FIND:

Code: Select all

    foreach ($active_users as $row)
    {
        $template->assign_block_vars('lastvisit', array(
            'USERNAME_FULL'    => get_username_string((($row['user_type'] == USER_IGNORE) ? 'no_profile' : 'full'), $row['user_id'], $row['username'], $row['user_colour']),
        ));
    }   
REPLACE, WITH:

Code: Select all

    $users_online = 0;
    foreach ($active_users as $row)
    {
        if (!$row['user_viewonline'] && !$auth->acl_get('u_viewonline'))
        {
            // user does not have permission to view hidden users.
            continue;
        }
        
        $users_online++;
        $username_string = get_username_string((($row['user_type'] == USER_IGNORE) ? 'no_profile' : 'full'), $row['user_id'], $row['username'], $row['user_colour']);
        
        $username_string = (!$row['user_viewonline']) ? '<em>' . $username_string . '</em>' : $username_string;
        
        $template->assign_block_vars('lastvisit', array(
            'USERNAME_FULL'    => $username_string,
        ));
    }   
FIND:

Code: Select all

'USERS_24HOUR_TOTAL'    => sprintf($user->lang['USERS_24HOUR_TOTAL'], sizeof($active_users)),   
REPLACE, WITH:

Code: Select all

'USERS_24HOUR_TOTAL'    => sprintf($user->lang['USERS_24HOUR_TOTAL'], $users_online),   
FIND:

Code: Select all

'SELECT'    => 'u.user_id, u.user_colour, u.username, u.user_type',   
REPLACE, WITH:

Code: Select all

'SELECT'    => 'u.user_id, u.user_colour, u.username, u.user_type, u.user_allow_viewonline, s.session_viewonline',   
FIND:

Code: Select all

$active_users[$row['user_id']] = array(   
AFTER, ADD:

Code: Select all

    'user_viewonline'    => ($row['session_viewonline']) ? $row['session_viewonline'] : $row['user_allow_viewonline'],   
--------oOo--------

Q: How do I change the cache time from 60 minutes to 5 minutes?
A: Perform the following changes.
OPEN: functions_activity_stats.php

FIND:

Code: Select all

$cache->put('_active_users', $active_users, 3600); 
REPLACE, WITH:

Code: Select all

$cache->put('_active_users', $active_users, 300); 
FIND:

Code: Select all

$cache->put('_activity_mod', $activity, 3600); 
REPLACE, WITH:

Code: Select all

$cache->put('_activity_mod', $activity, 300); 
--------oOo--------

Q: I have a large board and one of the queries seems to be slowing down the board, how do I improve performance?
A: Download the following replacement for the functions file. This will greatly improve the speed at which the new_posts SQL Query will run. It also changes the cache time from 60 minutes down to 15 minutes.

[The extension zip has been deactivated and can no longer be displayed.]

---------oOo----------

Style instructions for any of CyberAlien's styles from Keldek
Keldek wrote:Integration instructions for eTech style

editing styles/etech/template/index_body.html

Find:

Code: Select all

			<td class="row1 nobold"><b class="gensmall">{L_LEGEND} :: {LEGEND}</b></td>
Replace With:

Code: Select all

			<td class="row1 nobold"><b class="gensmall">
				<!-- IF not S_IS_BOT --><p>
       				{USERS_24HOUR_TOTAL}: <!-- BEGIN lastvisit -->{lastvisit.USERNAME_FULL}<!-- IF not lastvisit.S_LAST_ROW -->, <!-- ENDIF -->				<!-- END lastvisit -->
				</p><!-- ENDIF -->

				<p><b>{L_LEGEND} :: {LEGEND}</b></p></td>

Find:

Code: Select all

<p class="genmed">{TOTAL_POSTS} | {TOTAL_TOPICS} | {TOTAL_USERS} | {NEWEST_USER}</p>
Add After:

Code: Select all

	<!-- IF not S_IS_BOT -->
	<br /><h3 id="24hour_stats">{L_24HOUR_STATS}</h3>
	<p>{24HOUR_POSTS} | {24HOUR_TOPICS} | {24HOUR_USERS}</p>
	<!-- ENDIF -->

Re: Activity Stats MOD

Posted: Wed Mar 19, 2008 8:20 pm
by NadineF
Installed and working great - thank you. I have adjusted it slightly so that it shows stats for last 48 hours rather than 24. Quick and easy to install - great mod :D

Re: Activity Stats MOD

Posted: Wed Mar 19, 2008 8:32 pm
by Molopää
Cool MOD thanks! :ugeek:

Re: Activity Stats MOD

Posted: Wed Mar 19, 2008 8:42 pm
by JasonWade
Is this the same as the last RC or is it updated after? Cause I got the last RC version and it has a slight "error":

when in the last 24 hours 2 new people register and in the 24 hours after I delete someone and no new members register it still says 2 new people registered, how can I fix this?

Re: Activity Stats MOD

Posted: Wed Mar 19, 2008 10:52 pm
by ryorevo
Congrats on the Release, ditto on the last question "has anything changed"?

And one quick question in my list of Users active over the last 24 hours I'm seeing an extra space, (with the last RC version) is this intentional, or perhaps something that I did incorrectly or a conflict with another mod?
Here's a partial list from my board (same in prosilver and subsilver2)

Code: Select all

Capt U-96 AKA Mike , Google [Bot] , Jeffo , Kim , MSN [Bot] , etc 

Re: Activity Stats MOD

Posted: Thu Mar 20, 2008 1:39 am
by sixtvs
Thanks you: easy install works perfectly!

Re: Activity Stats MOD

Posted: Thu Mar 20, 2008 2:52 am
by ryorevo
Disregard my earlier question about the extra spaces, it was my fault for the way I re-formatted the code in the index_body.html files :roll:

Re: Activity Stats MOD

Posted: Thu Mar 20, 2008 4:46 am
by Highway of Life
JasonWade wrote:Is this the same as the last RC or is it updated after? Cause I got the last RC version and it has a slight "error":

when in the last 24 hours 2 new people register and in the 24 hours after I delete someone and no new members register it still says 2 new people registered, how can I fix this?
It’s cached for 1 hour, see FAQ on the third post.

The only things that changed were the install instructions to increment instead of replace-with, though you won’t see any difference either way you go.
Also added the missing <edit></edit> tags to make it work properly with Blinky. Other than that, there are no other changes.

Re: Activity Stats MOD

Posted: Thu Mar 20, 2008 4:47 am
by Elias
On the demo board prosilver, where does it show the topics?

Re: Activity Stats MOD

Posted: Thu Mar 20, 2008 4:48 am
by Highway of Life
EY wrote:On the demo board prosilver, where does it show the topics?
See the second screenshot for New topics in the last 24 hours (count) :)

Re: Activity Stats MOD

Posted: Thu Mar 20, 2008 4:51 am
by Elias
Ah thanks.
Screenshots had an red X on them and was not able to see them.

Thanks for the fast reply.

Re: Activity Stats MOD

Posted: Thu Mar 20, 2008 9:36 am
by JasonWade
Highway of Life wrote:
JasonWade wrote:Is this the same as the last RC or is it updated after? Cause I got the last RC version and it has a slight "error":

when in the last 24 hours 2 new people register and in the 24 hours after I delete someone and no new members register it still says 2 new people registered, how can I fix this?
It’s cached for 1 hour, see FAQ on the third post.

The only things that changed were the install instructions to increment instead of replace-with, though you won’t see any difference either way you go.
Also added the missing <edit></edit> tags to make it work properly with Blinky. Other than that, there are no other changes.
I know the one hour thing but like I typed in the last 24 hours (more even) 0 new members registered but it still said 2 so I figure that's because I deleted a member in those 24 hours, that's what the problem is ;)

And thnx for letting me know about the edits

Re: Activity Stats MOD

Posted: Thu Mar 20, 2008 2:44 pm
by xnitelifex
Guest - Can view profiles, memberlist and online list: no
4 Users active over the last 24 hours: test1, test2, test3, test4

Registered Users - Can view profiles, memberlist and online list: no
4 Users active over the last 24 hours: test1, test2, test3, test4

Why the difference?