1 (edited by cuteseal 2004-12-09 01:09)

Topic: Access Tracking

Hi all, I was finding that tracking hits to the forums using my site's access logs and counter wasn't doing it for me --  I wanted to find out which forum members were accessing the site, and what percentage were guests and so forth.  Hence, this mod.

Demo here:
http://www.shuttertalk.com/forums/access.php

To install:

This mod creates a new database table, so <insert usual spiel about backing up blah bla>. 

1.  Create the access table using a db tool such as phpmyadmin.  Make sure you replace `punbb_prefix` below (including quotes) with the table prefix that you use.

CREATE TABLE `punbb_prefix`access (
  user_id int(10) unsigned NOT NULL default '0',
  request varchar(100) default NULL,
  ident varchar(200) NOT NULL default '',
  logged int(10) unsigned NOT NULL default '0'
) TYPE=HEAP;

2.  Modify the file includes/functions.php:

Find the following (~line 164):

    // Delete entries older than timeout_online seconds and any duplicates (start transaction)
    $db->query('DELETE FROM '.$db->prefix.'online WHERE logged<'.($now-$pun_config['o_timeout_online']).' OR ident=\''.addslashes($cookie['username']).'\' OR ident=\''.get_remote_address().'\'', PUN_TRANS_START) or error('Unable to delete from online list', __FILE__, __LINE__, $db->error());

    // Add a new entry. username and user_id if logged in; ip and user_id=0 if not (end transaction)
    $db->query('INSERT INTO '.$db->prefix.'online (user_id, ident, logged) VALUES(\''.$user_id.'\', \''.$ident.'\', '.$now.')', PUN_TRANS_END) or error('Unable to insert into online list', __FILE__, __LINE__, $db->error());

Add after:

    // Update Access Log
    $daylength = 86400;
    $db->query('DELETE FROM '.$db->prefix.'access WHERE logged<'.($now-$daylength), PUN_TRANS_START) or error('Unable to delete from online list', __FILE__, __LINE__, $db->error());
    $db->query('INSERT INTO '.$db->prefix.'access (user_id, ident, logged, request) VALUES(\''.$user_id.'\', \''.$ident.'\', '.$now.', \''.$_SERVER['REQUEST_URI'].'\')', PUN_TRANS_END) or error('Unable to insert into access list', __FILE__, __LINE__, $db->error());

3.  Drop the file access.php into your punbb directory.  Download it here


That's it!  To use it, just hit access.php and it will give you a listing of members and guests accesses in 15 minute intervals.  The 2nd table at the bottom also shows the last 100 actions performed by people.  Only 24 hours worth of data is retained in the tables.

The access.php code is pretty ugly at the moment (it does about 96 separate db queries for each 15 minute interval in the last 24 hours.  I'm sure someone could revise it down to just 1 query if they wanted to...

Please let me know if you have any suggestions / comments.

Digital photography news, reviews, discussions and more!
http://www.shuttertalk.com

The online bible for all
http://www.publicbible.com

Re: Access Tracking

nice! is this admin only viewable? if not maybe ip masking of some sort.

~James
FluxBB - Less is more

Re: Access Tracking

Ooops... yeah good idea... on the todo list. smile

Digital photography news, reviews, discussions and more!
http://www.shuttertalk.com

The online bible for all
http://www.publicbible.com

4

Re: Access Tracking

Very Nice thank's

Yours, Benny.

Re: Access Tracking

No worries!  Hope it's useful!

Digital photography news, reviews, discussions and more!
http://www.shuttertalk.com

The online bible for all
http://www.publicbible.com

Re: Access Tracking

you could always password protect the page

Re: Access Tracking

might be a neat admin plugin on 1.2

Re: Access Tracking

yea, good ole admin plugins smile

who really cares about there ip (i mean everyone being able to see it)? i did, but its not like it matters. anyone that can get past my 3 firewalls has the right to hack me.

Indocron
$theQuestion = (2*b) || !(2*b);

Re: Access Tracking

no its bad to show everyone everyone elses IPs...

10

Re: Access Tracking

Please anybody could reup the file access.php ? Thank you

Re: Access Tracking

Judging by the dates on these posts, it wasn't made for the 1.2 branch, so even if available it probably wouldn't work anyway.

Looking for a certain modification for your forum? Please take a look here before posting.

12

Re: Access Tracking

Any idea for code of file access.php ?

Thank you.

13

Re: Access Tracking

Nobody can help me? I wish to work on this function.