Your ultimate PunBB resource!
You are not logged in.
##
## 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
################################################################################Offline
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
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.
#
#---------[ 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
thanks koos for the update... Its now easy to configure and dont need to load the logs on a singel page...
Offline
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
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
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
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
as You know I'm using PostgreSQL and I have problem with recode this query:
line 127 in userstats.php
$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
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
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
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. ![]()
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
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
Hello,
How to change the date format ?, I'm using French Punbb .
Offline
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