Activity Stats MOD

All new MODs released in our MOD Database will be announced in here. All support for released MODs needs to take place in the Customisations Database.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTICE: This forum is only for the announcement of new releases and/or updates of MODs. Any MOD support should be obtained through the Customisations Database in the support area designated for each MOD.

A direct link to support for each MOD is in the first post of the respective topic.
Locked
User avatar
3Di
Former Team Member
Posts: 16091
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milano 🇮🇹 Frankfurt 🇩🇪
Name: Marco
Contact:

Re: Activity Stats MOD

Post by 3Di »

Funk Theory wrote:
3Di wrote:
Funk Theory wrote:cheers, worked like a charm ;) dont suppose you know how to sort the hidden users out? :lol:
:) --- and the Q about hiddens is? :|
Basically, how do you keep the hidden users 'hidden' on the list, only not hidden to admins of course? You stay hidden if your profile is set that way when logged in, but once the mod refreshes eg after 24 hours, the user shows up on the list, i dont want them too. Theres a bit of the beginning of this mod but part of the code is missing so as yet I havent been able to do it. Be grateful if you could help as so far no one has been able to.
I have it working. Feel free to post you file here or to PM it to me, I'll give it a shot, indeed. :)
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Want to compensate me for my interest? Donate
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
PÕQ~Hitman
Registered User
Posts: 97
Joined: Tue Jul 29, 2008 2:26 am

Re: Activity Stats MOD

Post by PÕQ~Hitman »

Well i installed this and it refreshes every 5 mins

Well the number of posts was 46 then it goes down to 43 then new users droped by 1

it says there is 190 people last 24 hours, some of these people havent been seen in ages..

So what is up a bug of some sort?
User avatar
Funk Theory
Registered User
Posts: 736
Joined: Mon Sep 25, 2006 3:33 pm
Location: UK
Contact:

Re: Activity Stats MOD

Post by Funk Theory »

3Di wrote:I have it working. Feel free to post you file here or to PM it to me, I'll give it a shot, indeed. :)
Thanks. It appears someone fixed the code on the first post of this thread so I have given it another go, however, I now get an error:

Code: Select all

Parse error: syntax error, unexpected T_DOUBLE_ARROW in /home/www/webmatrEU/forum/includes/functions_activity_stats.php on line 110
I have looked through my file and that line (110) but cant see anything really obvious. Heres my code on the file i amended:

Code: Select all

<?php
/**
*
* @package phpBB3
* @author Highway of Life ( David Lewis ) http://startrekguide.com
* @version $Id$
* @copyright (c) 2008 Star Trek Guide Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
	exit();
}

/**
 * Display extra stats, activity over the last 24 hours for new users, posts and topics.
 *
 * @return bool
 */
function activity_mod()
{
	global $template, $user, $auth;  

	$user->add_lang('mods/activity_stats');

	// if the user is a bot, we won’t even process this function...
	if ($user->data['is_bot'])
	{
		return false;
	}

	// obtain user activity data
	$active_users = obtain_active_user_data();
	
	// obtain posts/topics/new users activity
	$activity = obtain_activity_data();

	// 24 hour users online list, assign to the template block: lastvisit
	
        $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,
            ));
        }   

	// assign the stats to the template.
	$template->assign_vars(array(
		'USERS_24HOUR_TOTAL'    => sprintf($user->lang['USERS_24HOUR_TOTAL'], $users_online),
		'24HOUR_TOPICS'			=> sprintf($user->lang['24HOUR_TOPICS'], $activity['topics']),
		'24HOUR_POSTS'			=> sprintf($user->lang['24HOUR_POSTS'], $activity['posts']),
		'24HOUR_USERS'			=> sprintf($user->lang['24HOUR_USERS'], $activity['users']),
	));

	return true;
}

/**
 * Obtain an array of active users over the last 24 hours.
 *
 * @return array
 */
function obtain_active_user_data()
{
	global $cache;

	if (($active_users = $cache->get('_active_users')) === false)
	{
		global $db;

		$active_users = array();

		// grab a list of users who are currently online
		// and users who have visited in the last 24 hours
		$sql_ary = array(
			    'SELECT'    => 'u.user_id, u.user_colour, u.username, u.user_type, u.user_allow_viewonline, s.session_viewonline',   
			'FROM'		=> array(USERS_TABLE => 'u'),
			'LEFT_JOIN'	=> array(
				array(
					'FROM'	=> array(SESSIONS_TABLE => 's'),
					'ON'	=> 's.session_user_id = u.user_id',
				),
			),
			'WHERE'		=> 'u.user_lastvisit > ' . (time() - 86400) . ' OR s.session_user_id <> ' . ANONYMOUS,
			'GROUP_BY'	=> 'u.user_id',
			'ORDER_BY'	=> 'u.username_clean',
		);

		$result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary));

		while ($row = $db->sql_fetchrow($result))
		{
			  'user_viewonline'    => ($row['session_viewonline']) ? $row['session_viewonline'] : $row['user_allow_viewonline'],   
				'user_id'		=> $row['user_id'],
				'user_type'		=> $row['user_type'],
				'username'		=> $row['username'],
				'user_colour'	=> $row['user_colour'],
			);
		}
		$db->sql_freeresult($result);

		// cache this data for 1 hour, this improves performance
		$cache->put('_active_users', $active_users, 3600);
	}

	return $active_users;
}

/**
 * obtained cached 24 hour activity data
 *
 * @return array
 */
function obtain_activity_data()
{
	global $cache;

	if (($activity = $cache->get('_activity_mod')) === false)
	{
		global $db;

		// set interval to 24 hours ago
		$interval = time() - 86400;

		$activity = array();

		// total new posts in the last 24 hours
		$sql = 'SELECT COUNT(post_id) AS new_posts
				FROM ' . POSTS_TABLE . '
				WHERE post_time > ' . $interval;
		$result = $db->sql_query($sql);
		$activity['posts'] = $db->sql_fetchfield('new_posts');
		$db->sql_freeresult($result);

		// total new topics in the last 24 hours
		$sql = 'SELECT COUNT(topic_id) AS new_topics
				FROM ' . TOPICS_TABLE . '
				WHERE topic_time > ' . $interval;
		$result = $db->sql_query($sql);
		$activity['topics'] = $db->sql_fetchfield('new_topics');
		$db->sql_freeresult($result);

		// total new users in the last 24 hours, counts inactive users as well
		$sql = 'SELECT COUNT(user_id) AS new_users
				FROM ' . USERS_TABLE . '
				WHERE user_regdate > ' . $interval;
		$result = $db->sql_query($sql);
		$activity['users'] = $db->sql_fetchfield('new_users');
		$db->sql_freeresult($result);

		// cache this data for 1 hour, this improves performance
		$cache->put('_activity_mod', $activity, 3600);
	}

	return $activity;
}
?>

One other question, can you force the cache to refresh on this mod so i can see the hidden users disappear once i have rectified this or do i need to wait 24 hours?
User avatar
RMcGirr83
Former Team Member
Posts: 21834
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr

Re: Activity Stats MOD

Post by RMcGirr83 »

You're missing the part that builds the array

this

Code: Select all

          while ($row = $db->sql_fetchrow($result))
          {
          	
               'user_viewonline'    => ($row['session_viewonline']) ? $row['session_viewonline'] : $row['user_allow_viewonline'],   
                'user_id'      => $row['user_id'],
                'user_type'      => $row['user_type'],
                'username'      => $row['username'],
                'user_colour'   => $row['user_colour'],
             );
          }
should be like this

Code: Select all

          while ($row = $db->sql_fetchrow($result))
          {
          	$active_users[$row['user_id']] = array(
               'user_viewonline'    => ($row['session_viewonline']) ? $row['session_viewonline'] : $row['user_allow_viewonline'],   
                'user_id'      => $row['user_id'],
                'user_type'      => $row['user_type'],
                'username'      => $row['username'],
                'user_colour'   => $row['user_colour'],
             );
          }
Former Modifications/Extensions Team Member | My extensions | github | All requests for support via PM will be ignored
Appreciate the extensions/mods/support then buy me a beerImage
User avatar
Funk Theory
Registered User
Posts: 736
Joined: Mon Sep 25, 2006 3:33 pm
Location: UK
Contact:

Re: Activity Stats MOD

Post by Funk Theory »

If i put that extra part of code in, the mod disappears so do i need to purge the cache?

(EDIT I have purcged the cache now so will need to wait to see if the hidden users still appear, thanks)
User avatar
RMcGirr83
Former Team Member
Posts: 21834
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr

Re: Activity Stats MOD

Post by RMcGirr83 »

Okay, first off...the database field is called "user_allow_viewonline"...not user_viewonline. :)

So you have to build that into the cache.

I have modified my includes file so that hidden users don't show unless correctly authed. You can find it here. It's active here.

Save it as functions_activity_stats.php and upload into the includes folder overwriting the old one (rename the old one if you like).
Former Modifications/Extensions Team Member | My extensions | github | All requests for support via PM will be ignored
Appreciate the extensions/mods/support then buy me a beerImage
User avatar
Funk Theory
Registered User
Posts: 736
Joined: Mon Sep 25, 2006 3:33 pm
Location: UK
Contact:

Re: Activity Stats MOD

Post by Funk Theory »

thanks, i will download the txt file if needed, i have resolved it now with the additional code you gave me as i can see the hidden users whem im logged in but not logged in as a normal user. Really appreciate your help ;)
User avatar
AllCity
Registered User
Posts: 230
Joined: Sun Jun 22, 2008 6:33 pm
Name: Andrey Shapoval
Contact:

Re: Activity Stats MOD

Post by AllCity »

laraweb wrote:
barryoneoff wrote:I've just updated to phpBB version 3.0.3. from 3.0.2. via the auto update. Everything went well except for this mod, which seems to have had some of it's files wiped out. It doesn't show the last 24 hours users.
Should I install the whole mod again, or is it not compatable with 3.0.3.?
Yes, I have the same problem. It worked fine on 3.0.2 and after the auto-update it is like this:

Image
its mod for phpbb3 not for phpbb2 ;)
My mods home page.
User avatar
barryoneoff
Registered User
Posts: 248
Joined: Sat Mar 24, 2007 10:14 pm
Location: East London, England
Contact:

Re: Activity Stats MOD

Post by barryoneoff »

It was just the line in the index.php that had to be re-entered. It's working fine now. :)
Image
Click above to support St. Josephs Hospice.
Barryoneoff's London. ... City of London walks.
PÕQ~Hitman
Registered User
Posts: 97
Joined: Tue Jul 29, 2008 2:26 am

Re: Activity Stats MOD

Post by PÕQ~Hitman »

Okay in my list of users on in last 24 hours, there are people who have not logged in for weeks and months


whats going on my code is fine.....
User avatar
Highway of Life
Former Team Member
Posts: 6048
Joined: Wed Feb 02, 2005 5:41 pm
Location: Seattle, WA
Name: David Lewis
Contact:

Re: Activity Stats MOD

Post by Highway of Life »

What does the lastvisit time of those users say?

You can always check manually, the user should either be logged in now (or within the last x hours of the session time), and or have a last visit within the last 24 hours.
The phpBB Weekly Podcast - Discussing the developments of phpBB4 and beyond.

New to phpBB3? Want to learn about programing?
Visit phpBB Academy at StarTrekGuide to learn how.
User avatar
jmaraujo
Registered User
Posts: 240
Joined: Fri Jun 01, 2007 9:48 pm
Location: Rivera - Uruguay
Name: Juan

Re: Activity Stats MOD

Post by jmaraujo »

Hello, Highway of Life.

I know this is a weird request, but can you help me to modify your mod so I only get this data?:

Image

The reason I'm asking for this is becasuse I'm already using nick vergessen's "Who was here?" mod, which is very similar, but, for what I need, nick's mod has the advantage of showing the time of the user's last visit.

Sorry for the strange request... ;) :lol: I know I'm asking too much here, but it's worth the shot.

I hope it's not a disrespect to your hard work writing this mod.

Thanks in advance!

Juan M.
User avatar
laraweb
Registered User
Posts: 10
Joined: Tue Apr 22, 2008 7:12 pm
Location: Germany
Contact:

Re: Activity Stats MOD

Post by laraweb »

AllCity wrote:
laraweb wrote:
barryoneoff wrote:I've just updated to phpBB version 3.0.3. from 3.0.2. via the auto update. Everything went well except for this mod, which seems to have had some of it's files wiped out. It doesn't show the last 24 hours users.
Should I install the whole mod again, or is it not compatable with 3.0.3.?
Yes, I have the same problem. It worked fine on 3.0.2 and after the auto-update it is like this:
its mod for phpbb3 not for phpbb2 ;)
Very funny, but I'm using phpBB3 with subsilver2 Image
Highway of Life wrote:If this MOD is not working on 3.0.3, it is because you either wiped out the files or the edits, simply re-apply the edits for this MOD, just ensure you don’t duplicate your edits.
The edit in index.php was deleted while updating on 3.0.3, now it works again...
Image
User avatar
3Di
Former Team Member
Posts: 16091
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milano 🇮🇹 Frankfurt 🇩🇪
Name: Marco
Contact:

Re: Activity Stats MOD

Post by 3Di »

3Di wrote:@ HoL:

I managed to use part of your code to fit my needs, now talking about hidden users:

is that correct the count does not show the exact amount of users if hiddens are there?

I mean, today I got 2 hiddens and 5 regged, so to speak..

it says 5 if not logged-in and 7 if I am (ofcourse I have permissions) ..

don't know if I was enough clear and thanks.

:)
Perhaps I was not so clear m8, the matter I'm talking about it is simple.. let's see if I can explain it better.. have a look to my phpBB2 board I MODded: http://ipcf.io3di.com .. as you can see there there is a stat that speaks books to everyone.. see:
2 users have visited this Board within the last 24 hours :: 2 Registered, 0 Hidden
that's what I was talking about then, do you think you can help me out here in order to make it somehow like that?

Many thx in advance. :)
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Want to compensate me for my interest? Donate
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
PÕQ~Hitman
Registered User
Posts: 97
Joined: Tue Jul 29, 2008 2:26 am

Re: Activity Stats MOD

Post by PÕQ~Hitman »

Well some say the last visit was Oct 23....

Some are June 2...
Locked

Return to “[3.0.x] MOD Database Releases”