November 2009

Recent posts

Archives

RSS format

Support

26 November 2009

We are starting to build up a new section of the site to allow you to get answers to your frequently asked questions, and understand how SlimStat works.

If you have a question you would like to see answered, please ask in the SlimStat Google Group and we’ll add the answer here.

Tracking downloads

5 November 2009

If you have looked at the demo, you may have noticed that SlimStat is tracking downloads of a zip file. Here is how I achieved that.

The zip file is placed in a folder named file. I added a line to .htaccess to redirect all requests for files in that folder to a PHP script at the top level:

RewriteRule ^file/(.*)$ /download.php?file=$1 [L]

The contents of download.php are as follows:

// if no file is specified, return 404 code
if ( !array_key_exists( 'file', $_GET ) ) {
header( '404 Not Found' );
exit;
}

// strip out unwanted characters from file name
$file = preg_replace( '/[^A-Za-z0-9\-\.]/', '', $_GET['file'] );
$file = str_replace( '/\.\.\//', '', $file );

// if file does not exist, return 404 code
if ( !file_exists( 'file/'.$file ) ) {
header( '404 Not Found' );
exit;
}

// send headers
header( 'Cache-control: private' );
header( 'Content-Length: '.filesize( 'file/'.$file ) );
header( 'Content-Type: application/zip' );
header( 'Content-Disposition: attachment; filename="'.$file.'"' );

// send file contents
readfile( 'file/'.$file );

// include slimstat
@include_once( $_SERVER['DOCUMENT_ROOT'].'/slimstat/stats_include.php' );

This code assumes that all files in that folder are zips, and sets the Content-Type header automatically. If you are serving other file types you will need to adjust your code accordingly.

Announcing SlimStat 2.0

4 November 2009

SlimStat 2.0 is here!

To accompany the new release, there’s a new website too, which is still somewhat under construction.

Many thanks to everyone who has tried the beta versions and/or reported bugs. It wouldn’t have been possible without your feedback.

SlimStat 2.0 has been almost completely rewritten from scratch compared to SlimStat 0.9. This means that it runs much faster than before, and it has incorporated some features that weren’t in the old version, most notably the ability to record stats via JavaScript. There are some things that have yet to be re-implemented, such as the Paths view. I hope to add these back in future versions.

In the meantime please download it and tell all your friends how fantastic it is. :)

As always please send bug reports here:

http://code.google.com/p/slimstat/