[RC] Activity Stats MOD 0.1.2

Misc MOD Downloads for phpBB3 -- Any MOD that does not fit into any other category
Forum rules
Image Please feel free to download any MOD's here, support for each MOD is located it's own thread.

To post your own MOD, please first read the MOD Guidelines

Re: [RC] Activity Stats MOD 0.1.2

Postby RonP » 04 Apr 2008, 16:32

You know what I usually donate upon a successful install with open source products. Seeing as you didn't see my PM or that I was online the whole time you were on and still didn't reply tells me that I am considered a pain in the but. So thanks but no thanks.
RonP
Crewman
Crewman
 
Posts: 5
Joined: 04 Apr 2008, 11:48
Gender: Male
phpBB Knowledge: 5




phpBB Academy at StarTrekGuide
Support STG
Using PayPal Donate

Re: [RC] Activity Stats MOD 0.1.2

Postby Highway of Life » 04 Apr 2008, 17:45

Just because I answered your first post in 6 minutes 17 seconds, does not mean my subsequent replies will come within the same amount of time.
Most, if not all of us here are very busy, myself included. I am not paid to offer support, I have to do it in my free time, and as the time of day is while I?m at work, I suppose you expect me to steal time from my work to help with this small problem? :rant:

The issue is not from your index.php file, but from the template file.
I?ll need to see the template file to find where the problem is.

Thanks,
- Highway
Watch out! I might do a code wheelie!

User avatar
Highway of Life    
STG Jedi Master
STG Jedi Master
 
Posts: 10458
Joined: 08 May 2006, 05:23
Location: Beware of Programmers carrying screwdrivers
Gender: Male
phpBB Knowledge: 10

Re: [RC] Activity Stats MOD 0.1.2

Postby harmlessgoat22 » 04 Apr 2008, 18:18

It'd be nice if everyone realized this. Sometimes I'll scan over a post that I know how to find the answer to but don't have time at the moment, then later go back and give a proper answer. I have loads of free time, and don't have time to answer every question. Imagine what it's like for Highway, who is very busy, generally speaking. I've never known him to not be busy.
User avatar
harmlessgoat22    
STG Support Team
STG Support Team
 
Posts: 2886
Joined: 13 Jul 2006, 17:38
Gender: Male
phpBB Knowledge: 8

Re: [RC] Activity Stats MOD 0.1.2

Postby RonP » 04 Apr 2008, 18:33

I apologize I had my forum set up with the index code to show the error and did not want to leave it in all day.

I believe this is the first bit of code and i see it looks differant.

Code: Select all
<!-- IF S_DISPLAY_ONLINE_LIST -->
   <!-- IF U_VIEWONLINE --><h3><a href="{U_VIEWONLINE}">{L_WHO_IS_ONLINE}</a></h3><!-- ELSE --><h3>{L_WHO_IS_ONLINE}</h3><!-- ENDIF -->
   <p>{TOTAL_USERS_ONLINE} ({L_ONLINE_EXPLAIN})<br />{RECORD_USERS}<br /> <br />{LOGGED_IN_USER_LIST}
   <pre id="id0x0a619008">&lt;!-- IF not S_IS_BOT --&gt;&lt;br /&gt;&lt;br /&gt;
   {USERS_24HOUR_TOTAL}: &lt;!-- BEGIN lastvisit --&gt;{lastvisit.USERNAME_FULL}&lt;!-- IF not lastvisit.S_LAST_ROW --&gt;, &lt;!-- ENDIF --&gt;&lt;!-- END lastvisit --&gt;
   &lt;!-- ENDIF --&gt;</pre>
   <!-- IF LEGEND --><br /><em>{L_LEGEND}: {LEGEND}</em><!-- ENDIF --></p>
<!-- ENDIF -->


Code: Select all
<!-- IF NEWEST_USER -->
   <h3>{L_STATISTICS}</h3>
   <p>{TOTAL_POSTS} &bull; {TOTAL_TOPICS} &bull; {TOTAL_USERS} &bull; {NEWEST_USER}</p>
   <pre id="id0x0a6193a0">&lt;!-- IF not S_IS_BOT --&gt;
   &lt;h3 id="24hour_stats"&gt;{L_24HOUR_STATS}&lt;/h3&gt;
   &lt;p&gt;{24HOUR_POSTS} &amp;bull; {24HOUR_TOPICS} &amp;bull; {24HOUR_USERS}&lt;/p&gt;
   &lt;!-- ENDIF --&gt;</pre>
<!-- ENDIF -->
RonP
Crewman
Crewman
 
Posts: 5
Joined: 04 Apr 2008, 11:48
Gender: Male
phpBB Knowledge: 5

Re: [RC] Activity Stats MOD 0.1.2

Postby RonP » 04 Apr 2008, 18:49

Fixed it my linux html editor is too smart for itself thins it know better and added thos extra bits of code.
RonP
Crewman
Crewman
 
Posts: 5
Joined: 04 Apr 2008, 11:48
Gender: Male
phpBB Knowledge: 5

Re: [RC] Activity Stats MOD 0.1.2

Postby Highway of Life » 04 Apr 2008, 18:53

The editor htmlspecialchar-ed the text you pasted, which is why it displayed the html instead of parsing it as it should have.

Glad you got it fixed. :good:
Watch out! I might do a code wheelie!

User avatar
Highway of Life    
STG Jedi Master
STG Jedi Master
 
Posts: 10458
Joined: 08 May 2006, 05:23
Location: Beware of Programmers carrying screwdrivers
Gender: Male
phpBB Knowledge: 10

Re: [RC] Activity Stats MOD 0.1.2

Postby Jaymie1989 » 08 Apr 2008, 15:38

Great Mod David.

How ever when i change the php to not count the bots it still does. I done what you said in the first post and its still the same.
Here is the php file
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;

    
$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
    
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']),
            ));
    }

    
// assign the stats to the template.
    
$template->assign_vars(array(
        
'USERS_24HOUR_TOTAL'    => sprintf($user->lang['USERS_24HOUR_TOTAL'], sizeof($active_users)),
        
'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',
            
'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_type <> ' USER_IGNORE ' AND (u.user_lastvisit > ' . (time() - 86400) . ' OR s.session_user_id <> ' ANONYMOUS ')'
            
'GROUP_BY'    => 'u.user_id',
            
'ORDER_BY'    => 'u.username',
        );

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

        while (
$row $db->sql_fetchrow($result))
        {
            
$active_users[$row['user_id']] = array(
                
'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_users3600);
    }

    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'$activity3600);
    }

    return 
$activity;
}
?>
Jaymie1989    
Supporter
Supporter
 
Posts: 1370
Joined: 30 Sep 2007, 15:51
Location: Some where in phpbb_users table
Favorite Team: Liverpool FC
Gender: Male
phpBB Knowledge: 5

Re: [RC] Activity Stats MOD 0.1.2

Postby cichlid » 25 Apr 2008, 20:57

Sorry if i have posted this in the wrong section, but just wondering, is there a way that i can add on my forums the following in 1 line

want it to look like this.

Members Today: xxx Total Post Today:xxx

just a little stat mod to state the following

cheers
cichlid
Ensign
Ensign
 
Posts: 94
Joined: 25 Jul 2007, 01:54
Gender: Male

Re: [RC] Activity Stats MOD 0.1.2

Postby Oggster » 26 Apr 2008, 11:27

Nice mod sir.
I was wondering how hard it would be to have these stats
show up in the viewonline.php instead of the index page.
That way a link must be clicked to see and load the queries.

For large forums that would show 1000's of results at bottom would be big a server load
every time a member logs in and loads all that info.

Also would be nice if this part was a stand alone mod or could remain on the index.
"New Posts 125 ? New Topics 15 ? New users 68 "

Maybe expanded...
New Posts 125 /Topics 15 ? New users 68 ? 74 yesterday ? 487 this week

Certainly a great job none the less!!!
Oggster    
Supporter
Supporter
 
Posts: 9
Joined: 20 Apr 2008, 23:09
Gender: Male
phpBB Knowledge: 2

Re: [RC] Activity Stats MOD 0.1.2

Postby Jaymie1989 » 26 Apr 2008, 11:38

Thats a big board you have got there.

You can just edit the viewonline.html template file instead of the index_body.html and that would be the same. although you might have to play around with the online.php file and not the index.php file
Jaymie1989    
Supporter
Supporter
 
Posts: 1370
Joined: 30 Sep 2007, 15:51
Location: Some where in phpbb_users table
Favorite Team: Liverpool FC
Gender: Male
phpBB Knowledge: 5

PreviousNext

Return to Miscellaneous MODs, Hacks and Downloads

Who is online

Users browsing this forum: No registered users and 4 guests