PunBB Resource

Your ultimate PunBB resource!

Keywords:

    (Extended)

You are not logged in.


Login to move these ads to the bottom of the page

#1 2008-11-22 10:16:21

Koos
Member
Registered: 2007-01-14
Posts: 336
Website

User Stats 1.2

Code:

##
##        Mod title:  User Stats
##
##      Mod version:  1.2.0
##   Works on PunBB:  1.2.*
##     Release date:  2008-11-22
##           Author:  Koos (pampoen10@yahoo.com)
##
##      Description:  Adds functionality for tracking visitors
##                    to your forum.
##
##   Affected files:  index.php
##                    viewtopic.php
##                                     
##       Affects DB:  New table:
##                       'userstats'
##
##       DISCLAIMER:  Please note that "mods" are not officially supported by
##                    PunBB. Installation of this modification is done at your
##                    own risk. Backup your forum database and any and all
##                    applicable files before proceeding.
##
################################################################################
## CHANGELOG:
## 1.2.0 : can now edit the config from the admin cp
           added additional options to the config
           added pagination
## 1.1.1 : updated web stat scripts
           updated pattern ip addresses
           can now differentiate between days by color
           now won't log consecutive visits by the same user to the same page
           - (within a 120 second period)
           other minor changes
## 1.1.0 : uses quicker and more efficient country detect script
## 1.0   : initial release 
################################################################################

Download here

Offline

 

#2 2008-11-22 10:18:47

Koos
Member
Registered: 2007-01-14
Posts: 336
Website

Re: User Stats 1.2

I have made this mod a while ago to track visitors to my forum - and thought I should share it.

Here are some of the features:

* Displays a simple log of visitors to your forum, showing the following details: Date, Username, Userip, Browser, Operating System, Country
* Can set max number of entries, each time replacing the oldest entry when the max is reached. This is especially an important feature for me, since I only wanted to see the list of the most recent visitors.
* The visits of registered users are highlighted
* The search terms the visitor used to find the tracked page is shown in brackets where applicable
* Can choose whether bots (like googlebot or yahoo!slurpbot) should be tracked
* Holding your mouse pointer over the icon on the very left of each entry will display the title of the page from where the visitor was tracked - together with a link.

Screenshot

New in v1.2.0:

1. Can now edit the config from the admin control panel. Alternatively you can still edit the userstats_config.php config file directly if you prefer.

2. Added pagination, so that you don't have to display all the visitor log entries on a single page. The number of entries to display per page can be set in the config.

3. Added some additional options to the config, e.g.: setting the sort order (ascending/descending), specifying ip addresses not to log, option to enable/disable the mod.

Last edited by Koos (2008-11-22 11:17:00)

Offline

 

#3 2008-11-22 10:19:56

Koos
Member
Registered: 2007-01-14
Posts: 336
Website

Re: User Stats 1.2

If you want to add a 'User stats' link to the navigation menu, which only those who have permission (set in the 'User stats' admin cp) can see, just follow the following steps.

Code:

#
#---------[ 1. OPEN ]---------------------------------------------------------
#

include/functions.php


#
#---------[ 2. FIND (line: 309) ]---------------------------------------------
#

    // Are there any additional navlinks we should insert into the array before imploding it?
    if ($pun_config['o_additional_navlinks'] != '')
    {


#
#---------[ 3. BEFORE, ADD ]-------------------------------------------------
#

    //------------user stats link mod start--------------
    include "userstats_config.php";
    if(
       (($pun_user['g_id'] == PUN_GUEST && $US_perm_guests == "1") || 
        ($pun_user['g_id'] > PUN_MOD && $US_perm_users == "1") || 
        ($pun_user['g_id'] == PUN_MOD && $US_perm_mods == "1") || 
        ($pun_user['g_id'] == PUN_ADMIN))
    )
    {
        $US_link = '<li id="navuserstats"><a href="userstats.php">User stats</a>';
        $US_pos = ($pun_user['g_id'] > PUN_MOD) ? -2 : -3;

        // Insert User stats link
        array_splice($links,$US_pos,0,$US_link);
    }
    //------------user stats link mod end----------------


#
#---------[ 4. SAVE/UPLOAD ]-------------------------------------------------

Last edited by Koos (2009-06-06 06:33:46)

Offline

 

#4 2008-12-20 14:48:28

doki
Member
Registered: 2007-04-30
Posts: 144

Re: User Stats 1.2

thanks koos for the update... Its now easy to configure and dont need to load the logs on a singel page...

Offline

 

#5 2008-12-27 18:07:24

Cyclone103
Member
From: Antarctica
Registered: 2008-10-08
Posts: 39
Website

Re: User Stats 1.2

I want other users to be able to view the user stats via a link, not just admins. What would be the script to allow all who I have set to allow to be able to see the stats?

Offline

 

#6 2009-02-01 06:11:31

Koos
Member
Registered: 2007-01-14
Posts: 336
Website

Re: User Stats 1.2

User Stats v1.2.1 now available.

Changes made:

(1)Fixed a permissions bug.

(2)Updated pattern ip addresses - for detecting the visitor's country.

Offline

 

#7 2009-02-01 07:21:58

Koos
Member
Registered: 2007-01-14
Posts: 336
Website

Re: User Stats 1.2

Cyclone103 wrote:

I want other users to be able to view the user stats via a link, not just admins. What would be the script to allow all who I have set to allow to be able to see the stats?

I have updated the post above, so that those who have permission will be able to see the link in the navigation menu.

Offline

 

#8 2009-02-01 10:17:11

Cyclone103
Member
From: Antarctica
Registered: 2008-10-08
Posts: 39
Website

Re: User Stats 1.2

Thank you.

Offline

 

#9 2009-05-12 11:10:07

doki
Member
Registered: 2007-04-30
Posts: 144

Re: User Stats 1.2

Feature Request: It would be nice if 2 circular graph will be added on this mod. 1 is for the browser and the other is for the os. With this graph we can easily see the % of which browser or OS is mostly use by the visitors...

Thanks

Offline

 

#10 2009-05-12 11:28:39

Koos
Member
Registered: 2007-01-14
Posts: 336
Website

Re: User Stats 1.2

Good idea. Maybe I'll add such a feature in the next release.

Offline

 

#11 2009-05-16 12:13:53

Pame
Member
Registered: 2009-03-26
Posts: 14

Re: User Stats 1.2

That should be great to have got 2 tables : one for registered users and one for guest !

but I do not know ;-)) if it is possible or not too hard to do

Offline

 

#12 2009-05-17 11:37:18

Koos
Member
Registered: 2007-01-14
Posts: 336
Website

Re: User Stats 1.2

Why 2 tables? It's already easy to separate guests and registered users. All guests will have userid=1 in the userid column.

Offline

 

#13 2009-05-27 02:38:28

jaason
Member
From: Poland
Registered: 2008-11-26
Posts: 29
Website

Re: User Stats 1.2

as You know I'm using PostgreSQL and I have problem with recode this query:
line 127 in userstats.php

Code:

$result2 = SELECT DISTINCT FROM_UNIXTIME(date+'.$tdiff.', \'%Y-%m-%d\') as timestamp FROM '.$db->prefix.'userstats 
            WHERE FROM_UNIXTIME(date+'.$tdiff.', \'%Y-%m-%d\') >= \''.$stat_nr.'\' 
            ORDER BY timestamp '.$US_sort_order.'

can You tell me how should look this query to work in postgre?

another thing:
I've create a requested charts for it, but You'll need to recode it for mysql.. probably just enough will be changing pg_query to mysql_query... and maybe something with the offset and limit...but should works;d

http://img36.imageshack.us/img36/8271/userstats.png


some instructions how to get it work:
1) download this and unpack in punroot directory: http://jaason.net/download/User-Stats-Charts.zip
2) open userstats.php and find line 158 : <div class="linkst"> and add before:  <? include "wykres.php";?>
3) save & upload


it's using FusionCharts Free
have fun and tell me how it works for You ;]

Last edited by jaason (2009-05-27 04:19:18)

Offline

 

#14 2009-05-27 08:01:26

MattF
Member
From: South Yorkshire, England
Registered: 2007-03-16
Posts: 430

Re: User Stats 1.2

You'll probably need to change FROM_UNIXTIME to gmdate or similar. Check out the documentation on the PHP site for the specifics on the format.

Offline

 

#15 2009-05-27 23:29:59

jaason
Member
From: Poland
Registered: 2008-11-26
Posts: 29
Website

Re: User Stats 1.2

MattF yes I need to change FROM_UNIXTIME, but due to my little experience with date functions in SQL I don't knew which function from Postgre I can replace it. Thx for Your help, I will try that;]

Last edited by jaason (2009-05-27 23:31:06)

Offline

 

#16 2009-05-28 11:43:06

MattF
Member
From: South Yorkshire, England
Registered: 2007-03-16
Posts: 430

Re: User Stats 1.2

The date/gmdate functions are actually PHP functions, not PgSQL ones. Can't remember offhand if there is a comparable command/function within PgSQL, but there's no need as you can format it via PHP itself. It's the better method for DB compatibility, as you've already found. big_smile

Edit: Just on a side note, with your mod, you are better off using the db_query wrapper rather than the specific mysql|pgsql commands, for any db queries. If you're including common.php within your script, the DB wrapper is available to your code.

Last edited by MattF (2009-05-28 17:17:02)

Offline

 

#17 2009-05-29 00:40:48

jaason
Member
From: Poland
Registered: 2008-11-26
Posts: 29
Website

Re: User Stats 1.2

I forgot to do that in my addon, thanks MattF for Your opinion, I will fix that as soon as I can ;]
I'll try to use this php function but still I can't figure out how this query works and what should really do... I have errors all the time:p

EDIT: ok, I correct that. You can download newest version from the same direction, try now.

Last edited by jaason (2009-05-29 05:31:45)

Offline

 

#18 2009-09-09 01:13:55

beeriz
New member
Registered: 2009-08-20
Posts: 2

Re: User Stats 1.2

Hello,

How to change the date format ?, I'm using French Punbb .

Offline

 

#19 2009-09-09 12:53:42

Koos
Member
Registered: 2007-01-14
Posts: 336
Website

Re: User Stats 1.2

The User Stats mod uses the forum's default date format. Just go to Administration->Options->Date format to change it.

Offline

 

#20 2009-09-20 10:22:22

Koos
Member
Registered: 2007-01-14
Posts: 336
Website

Re: User Stats 1.2

User Stats v1.2.2 now available.

Changes made:

(1) Created a workaround for the REQUEST_URI command which does not work on Microsoft IIS servers.

(2) Updated pattern ip addresses - for detecting the visitor's country.

(3) Updated web stat scripts - for detecting the visitor's operating system etc.

(3) Updated the install_mod.php install script to also work in PostgreSQL.

(4) Other minor changes and improvements.

Offline

 

#21 2009-09-26 05:24:52

IBTB
New member
Registered: 2008-03-30
Posts: 4

Re: User Stats 1.2

Works as a charm!

Thanks! smile

Offline

 

Board footer

Based on PunBB
© Copyright 2002–2005 Rickard Andersson

© Copyright 2004–2006 Kristoffer Jansson

User contributed files are property of their respective owners.