Hacking ShortStat: Hide Yourself from Yourself · 208 words posted 06/29/2004 04:50 PM

I use Shaun Inman’s excellent littleware ShortStat to get a snapshot of who’s visiting my site. My only complaint: I don’t want to show up in my own statistics. With two quick mods, you can tell ShortStat to exclude your IP address from its tracking.

Please back up your files before making the following changes.

First, add a variable to the configuration.php file:

$exclude = "your.ip.here";

Next, open inc.stats.php and wrap the query lines at the bottom of the file in this conditional:

if (!strstr($ip, $exclude)) { ... query stuff here ... }

In English: if the $_SERVER['REMOTE_ADDR'] value (which is your IP address, stored in $ip) doesn’t include your IP address, it’s OK to insert the visitor in the stats. This is very quick and dirty—a better solution might store a range of IP addresses in an array, or use RegEx to account for IP blocks—but I work from home with a single, static IP, so it works for me.

Enjoy.

Update: As sooned as I posted this mod, I noticed someone had already posted a similar fix in March in a comment to the ShortStat beta. See here, and scroll about half way down the page comments. Look for the post from Andrew.

* * *


1. On Jul 18, 02:34 PM Matthew Pennell said:
Hi,

I’ve just updated my Shortstat installation with an expansion on this idea – it doesn’t prevent inc.stats.php from tracking you on the site, but it allows you to filter your own visits out of the stats within the /shortstat/ package dynamically.

Check out my Shortstat blog entry for the exact details if you’re interested.

Matt. #

2. On Jul 20, 10:00 AM since1968 said:
Matthew: Very nice mod. Thanks for posting the link. #