ShortStat Beta 3

Update

An upgrade to v0.34b is now available.

ShortStat is a modest, home rolled referrer and site activity monitor. Beta 3? What happened to 2? Well, the “first” version that you may be familiar with was actually the second build but the first public version.

New in this version:

  • Search engine keyword tracking. Currently supports all international versions of Google, AllTheWeb, Yahoo, MSN & AOL. More can be added upon request.
  • Optional IP-to-Country mapping using the IP-to-Country Database provided by WebHosting.Info
  • Support for hosting ShortStat on a different subdomain (see shortstat.shauninman.com/free/ for an example of a worn in installation)
  • Quoted associative arrays to avoid conflicts on some set-ups
  • Better care with variable naming, those that aren’t prefixed with SI_ will be phased out at a later date in favor of a web-based configuration

An installer and an update from v0.2b are included in the package. As before ShortStat is provided strictly on an as is basis. You are soley responsible and liable for any damage you do to your website or server.

Download ShortStat v0.3b.

While making this update I had an opportunity to get nice and friendly with my ShortStat database of 55k+ hits and I’m beginning to realize that the original ideal of a single table stats package just isn’t practical. With only 55k hits my ShortStat table was 10.2MB. I think the next version will require a normalized, multi-table database if it’s going to be scalable.

Previous
Gotta get up to Markdown
Next
Feed Update
Author
Shaun Inman
Posted
March 10th, 2004 at 8:04 am
Categories
ShortStat
Comments
050 (Now closed)

050 Comments

001

Sweeeeeeet.

I easily updated to 0.3. I love this little thing, man. Hope you keep working on it! :)

Thanks!

Author
Jeff Croft
Posted
Mar 10th, 2004 5:27 am
002

Quick suggestion:

What about making the site name a variable in confiruation.php so that I could easily make my title tag say something other than “ShaunInman.com’s ShortStat”. Just something that would identify the stats as belongs to my site, rather than yours. :)

Keep up the great work!

Author
Jeff Croft
Posted
Mar 10th, 2004 5:32 am
003

Good call Jeff. That will definitely make it into the next version—probably through that web-based config that I mention above. I also plan to add some more style hooks so you guys can start Zenning it if you want.

Author
Shaun Inman
Posted
Mar 10th, 2004 5:48 am
004

Upgrade wasnice ‘n easy - thanks! Now I can see that people have come to my site looking for “nice icon”!

I wouldn’t want to change the styles though - it looks just right. The overflow:auto divs make everything neat too.

Author
Jon Hicks
Posted
Mar 10th, 2004 5:59 am
005

I also love the default style, but I sure wouldn’t mind the hooks to play with it a bit, either. :)

Jeff

Author
Jeff Croft
Posted
Mar 10th, 2004 6:06 am
006

hey shaun - any possibility of building in an IP & host blocker to prevent spamming and recording of personal/known IPs?

Author
andrew
Posted
Mar 10th, 2004 8:50 am
007

It’s possible Andrew but I don’t think it’s within the scope of ShortStat. I’ve yet to receive any comment spam (fingers are crossed) that would motivate me to develop something like that but you never know.

Author
Shaun Inman
Posted
Mar 10th, 2004 10:53 am
008

Fantastico! Please program the next beta to make me coffee. cream. 2 sugars.

Author
Jason Santa Maria
Posted
Mar 10th, 2004 3:46 pm
009

I love it, in a totally inappriate and unnatural way. Just what I need, at a glance, none of the junk I’m not interested in. And it looks purdy, and I don’t have to worry about reinvigorate being down and making my site time out.

+1 shaunotron

Author
Wilson Miner
Posted
Mar 10th, 2004 8:03 pm
010

oh, and now i know that people get to my site by searching for “how to make yourself look pretty”

Author
Wilson Miner
Posted
Mar 10th, 2004 8:04 pm
011

Whoa…. the update took me less than 10 mins.

Thank you Shaun for adding in my requests. I’m getting more addicted in watching the stat… ;)

ShortStat is a must for every site, it lets me know my site and visitors more….

Author
sk
Posted
Mar 11th, 2004 4:10 am
012

One more comment. About the contries’ visits, the visits show me the statistics of ‘Hits’, is there any way to show ‘Uniques’ of each contries as well?

Author
sk
Posted
Mar 11th, 2004 4:13 am
013

That would be easy to add—while I’m at it I could do the same for just about all the sections that refer to hits (like resources, referrers, etc).

Author
Shaun Inman
Posted
Mar 11th, 2004 7:58 am
014

This is a beauty! Installed two days ago, updated just now. My work colleagues are wondering what I’m staring at all day. Thank you and keep up the good work!!

Author
Birgit
Posted
Mar 11th, 2004 9:33 am
015

Serendipity! Not but 1 week ago I was thinking about creating something like this and now I can spend the time on something else. This is really very cool.

I have some ideas about making further scalability/customization easier (for example, when adding an additional column to track), but I like how this app isn’t trying to be anything that it isn’t. The beauty is in the simplicity and the restraint it takes to keep with scope within reason but still producing exciting results.

Awesome, thank you for making this available.

Author
RMCox
Posted
Mar 12th, 2004 5:01 am
016

[ php and formatting below may be stripped out after i post this ]

To filter out your own IP or crapflooders from recording their domain in your refer logs, modify this text to inc.stats.php :: …

SI_sniffKeywords($url);

// this technique is an adaptation of 
// IP/BotWhack for Textism's Refer tool
// add IP's or hosts below as needed
$ban[]  = 'xx.xx.xxx.xxx';
$ban[]  = 'crapflooderdomain.com';

// set flag that will be tripped if IP or host is found to match
$OK = TRUE;

// check for IP or referer host in ban list
if(is_array($ban)) {
    foreach($ban as $a) {
        if (strpos($ip,$a) !== FALSE || strpos($domain,$a) !== FALSE) { $OK = FALSE; }
    }
}

// wrap original SQL query in a flag checker if statement
if ($OK) {
    $query = "INSERT INTO $SI_tables[stats] (remote_ip,country,domain,referer,resource,user_agent,platform,browser,version,dt) 
          VALUES ('$ip','$cntry','$domain','$ref','$res','$ua','$br[platform]','$br[browser]','$br[version]',$dt)";
    @mysql_query($query);
}
}

No guarantees that it’s foolproof, but so far as I can tell it seems to work for me.

Author
andrew
Posted
Mar 12th, 2004 10:29 pm
017

Cool Andrew, I’ll add a take on that to the next version!

Author
Shaun Inman
Posted
Mar 13th, 2004 3:20 am
018

A useful stat for me is the amount & types of http headers that people are receiving, i.e. 404/401/200 etc. It helps me track down coding problems, incorrect links, & security issues. It’d take up little real estate on the page, too. Thanks for the hard work, shaun!

Author
andrew
Posted
Mar 15th, 2004 11:04 am
019

I just got it hooked up, so now I’m hooked up…nice work once again, Mr. Inman.

Author
Dave Bedingfield
Posted
Mar 15th, 2004 11:07 pm
020

I’ve noticed that not many people using this tool actually have browser stats percentages that total 100%. Also, I went through and cleaned out the referrals I personally had made & now my browser stats are waaaay below 100%. I’m guessing the math in there is somehow tied to the primary id or hardcoded somehow?

Also, it appears that the ip/crapflooders thing I provided above works only partially. It seems that it’ll strip the entry but will still log the url. So what you end up with is a blank line in the referer section, with an anchor tag to the site with no text. Strange.

I haven’t had time to look into either of those issues … perhaps later tonight. Just something I’ve noticed after playing w/ this really cool tool for a while now.

Author
andrew
Posted
May 3rd, 2004 12:59 pm
021

I really like ShortStat! It displays some essential information with a fast glance. Great for daily viewing.. Thanks, Shaun. Btw. like your music too. :) demands more songs

Author
Daniel Borek
Posted
May 17th, 2004 7:48 am
022

I’m trying to get Shortstats working on a Mac OS X 10.3. Unfortunately, I keep getting an error when trying to connect to MySQL. I know I’ve got the username/pw/hostname right since I connect to MySQL with phpMyAdmin all the time.

Are there any ‘generic’ problems in getting this to work with OS X?

Thanks.

bw

Author
Bill Whitacre
Posted
May 21st, 2004 9:52 am
023

I’ve never tried getting ShortStat working on OS X so I don’t know of any ‘generic’ problems that might affect it. Sorry Bill.

Author
Shaun Inman
Posted
May 23rd, 2004 8:12 am
024

Shaun- ShortStat is great (and runs fine on my OSX box). The si_shortstat table fills up fast (15 megs in month!) but that’s no problem. It’s handy as heck to have realtime stats generated so quickly. Thanks for the hard work on this!

Author
hudson
Posted
May 27th, 2004 8:16 am
025

Hi, I was looking for a good stats script so I stumbled upon this gadget, very cool! however, it lacked a nice ‘button’ . So I made a standard button: http://switch.spielerij.net/images/butt … tstats.jpg It’s nog the regular 80x15 but 94x15, because the name ‘shortstat’ is too long to fit on the 80x15 version.

Maybe someone else could try to make such a button, the font is ‘Silkscreen’. Feel free to use mine, but please host it yourself :)

Author
Switch
Posted
Jun 21st, 2004 8:50 am
026

Shaun, I can run the _install.php script successfully and view the test page, but when I insert the php line on my page I get the $horribly error message. Any idea why? I have confirmed that the database information in my config file is correct. Thanks.

Author
since1968
Posted
Jun 21st, 2004 6:12 pm
027

Hello, Can somebody offer idiot proof, step-by-step instructions for getting the IP-to-Country listing to show?

Author
Martagnan
Posted
Jun 22nd, 2004 12:53 am
028

Shaun - great piece of programming here. I installed after the constant referencing on hicksdesign and I love it so much better than the stat program I was using before. No more ugly images on my home page to record stats. Good job!

Author
Jeff
Posted
Jun 22nd, 2004 7:19 am
029

Is there any way to see it in action without downloading it and installing it?

Author
Tomas
Posted
Jun 22nd, 2004 8:04 am
030

Sure Tomas, just go to shortstat.shauninman.com. Sorry, you’ll have to copy paste, I don’t want search engines crawling it. The daily breakdown is a new feature that I’ll be releasing shortly.

Author
Shaun Inman
Posted
Jun 22nd, 2004 8:22 am
031

This is great. I’ve been using Dean Allen’s refer for a while now, but ShortStat is much more comprehensive.

It also seems to spawn a large number of database queries. My homebrew blog uses the same database, without any cache, so after successfully installing and testing it, ShortStat turned my entire blog into a pile of error messages warning of “Too Many Datbase Connections.”

Perhaps, I’ll try again when it’s out of Beta.

Author
John
Posted
Jun 22nd, 2004 10:37 am
032

I don’t think that’s ShortStat causing the error. Shortstat uses a persistent database connection and only makes a single query per page view. Viewing the stats page requires between 10-15 queries (it is presenting a good deal of information) but they’re all made using the same persistent database connection.

Author
Shaun Inman
Posted
Jun 22nd, 2004 10:50 am
033

You’re right. It’s not the number of connections, but the persistence. Neither my blog engine nor Refer use persistent connections. My shared hosting provider might not grant me much more than one connection at a time. Oh well.

Author
John
Posted
Jun 22nd, 2004 1:22 pm
034

Hey John, try opening up functions.php and changing line 17 from: if (@mysql_pconnect(…) { to: if (@mysql_connect(…) {

and see if that doesn’t eliminate the problem.

Author
Shaun Inman
Posted
Jun 22nd, 2004 1:38 pm
035

Bill: Does your database user have the CREATE privilege on the db you want to use. To get more info about what is causing the error change: die($horribly) to die($horribly . mysql_error()) I also had problems when including shortstat files within class member functions, seems using global to bring the config variables into scope doesn’t work when you do this.

Martagnan: I had a prolem with getting the ip-to-country plug-in working too. Turns out the problem was that my server wasn’t fast enough to load all the ip ranges before php’s default 30 sec timeout kicked in. To get arround this add set_time_limit( 180 ); right before SI_pconnect(); in _ip-to-country.php.

Shaun: Great work. I’m hooked!

Author
Greg Fahy
Posted
Jun 22nd, 2004 1:38 pm
036

Thanks for fielding those questions Greg.

There was a lot of talk a week ago about “beta this” and “beta that” and what it all means. In the case of ShortStat “beta” means “never intended for public consumption” (which might explain the humorous but laughable error reporting). Glad there’s people like Greg to pick up my slack. ;D

Author
Shaun Inman
Posted
Jun 22nd, 2004 1:44 pm
037

Urm, I just installed and put the include on various pages, but it keeps returning a “Could not access the database, please make sure that the appropriate values have been added to the configuration file included in this package” error. I know for a fact that my password and username, etc. are all correct. Know anyhting that might be causing the problem? I’m on TextDrive, just like Jon.

Author
Hans
Posted
Jun 22nd, 2004 1:54 pm
038

I love Shortstat, it is an addictive little utility that is simple and easy to comprehend. The major issue I have is the webcrawler spam I get on my site. It would be fantastic if in an external text/php file I could be able to add domains into a blocklist for Shortstat to ignore. It would be even cooler if there was a way to block an address directly from the shortstat window itself. Again fantastic job and great UI!

Author
Ben Up the Tree
Posted
Jun 29th, 2004 5:56 am
039

hey, cool stat system, already incredibly useful for a quick glance at whats going on on my site

just wondered if anyone can explain how to get ip-country panel to work? i think this has been raised already but i can’t see any info on this.

Author
the.monkey
Posted
Jul 25th, 2004 3:07 pm
040

hold that thought. i missed Greg’s post that includes what i was looking for.

my bad and evil mistake >:-)

Author
the.monkey.redux
Posted
Jul 26th, 2004 7:39 am
041

Has anyone else had this simply fail at step 6, as I have?

“Step 6. …You should see /shortstat/_trackme.php in the Resources table as well as your Platform and Browser information. “

All that returns is a Shortstat page with no stats! I’ve installed three times and tested fom Firefox, Safari, and IE, but there is no browser info…nada. I have to be missing something very simple. I’ve altered the config file, the tables are created just fine, and I know that my database connection works.

My site is hosted on a Windows box (sorry…I’m slowly migrating from ColdFusion to PHP) - are there any Apache specific things in the code? I do have Dean Allen’s ‘Refer’ working just fine, but I would really love to add this as well. Thanks for any ideas.

Author
ryan m.
Posted
Jul 28th, 2004 9:48 am
042

Sure enough, after posting I was able to google what I needed. Apparently, IIS doesn’t have the $_SERVER['DOCUMENT_ROOT'] variable. Once I stuck the following lines in front of the Shortstat include, everything seemed to work just fine (watch line wrap):

if(!isset($_SERVER['DOCUMENT_ROOT'])) {
    $_SERVER['DOCUMENT_ROOT'] = substr($_SERVER['PATH_TRANSLATED'],0, strlen($_SERVER['SCRIPT_NAME']) * - 1);
    }

Sorry to hog the blog answering my own question, but maybe ths will help out some other odd duck trying to run this on IIS! It’s awesome, Shaun.

Author
Ryan M.
Posted
Jul 28th, 2004 12:24 pm
043

Thought I would add my 2c…

I have done step 1 and 2 correctly, however, when I do step 3 I receive the error message: “Could not access the database, please make sure that the appropriate values have been added to the configuration file included in this package.”

I unfortunately do not know enough of PHP or MySQL to know where the problem lies.

Any help?

DR

Author
David
Posted
Aug 8th, 2004 10:37 pm
044

Sorry, the label of the database name was incorrect.

All working fine now.

DR

Author
David
Posted
Aug 10th, 2004 2:11 am
045

Another satisfied customer here! I’m having some troubles with my hosting provider’s use of owners and Apache, but nevertheless it’s great!

Author
Gabriel Mihalache
Posted
Sep 12th, 2004 3:08 am
046

Man, it’s really cute. It’s what I was needing. Noo more awstats and relying on apache logs…. Wow, it’s so simple and useful. Thanks for this. It’ll make my life simpler and probably make me a stats freak….

Author
Bruno Torres
Posted
Oct 21st, 2004 3:16 am
047

Is it incrementalist? Or it resets on the next month and the previous goes to history?

Author
Bruno Torres
Posted
Oct 21st, 2004 9:20 am
048

Another note on using shortstat with a PHP/IIS setup. Apparently, IIS does not support the $_SERVER['REQUEST_URI'] variable. This leads your resource list to be populated with only one blank entry. The workaround for this is to change the line in inc.stats.php for the resource variable from:

$res = $_SERVER['REQUEST_URI'];

to:

$res = $_SERVER['SCRIPT_NAME'];
Author
Mike Johnson
Posted
Oct 31st, 2004 1:58 pm
049

I’ve installed on an OS X box. Works great, nice job. Only one question. My unique hits has stayed at one since I installed. I also use a visitor tracker so I know it’s at least three. (New install of both). Any ideas.

Author
Klaus
Posted
Jan 28th, 2005 3:10 am
050

What do you mean by step 5 Where would I put that code if I am using wordpress? in my index?

also, how do I get my layout to look as nice as your layout? How do I change it around?

Author
mariko iwata
Posted
Feb 7th, 2005 11:13 pm