<?
/*
    License:
    This code is copyright © 2007 Aaron Linville and Erik J. Barzeski.
    The right to re-use or re-purpose this code for your own use is granted
    so long as reasonable credit is given to the original authors, including
    a link to <http://nslog.com/desktops/resizer>. In other words, use it all
    you want, but be so kind as to give some credit.
*/


/*
CREATE TABLE `downloads` (
`dl_id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`filename` VARCHAR( 32 ) NOT NULL ,
`height` INT( 4 ) NOT NULL ,
`width` INT( 4 ) NOT NULL ,
`dl_time` DATETIME NOT NULL ,
`ip_address` VARCHAR( 15 ) NOT NULL ,
`os_version` VARCHAR( 32 ) NOT NULL
) ENGINE = MYISAM ;
*/


$ip_address gethostbyname($_SERVER['REMOTE_ADDR']);

// Put your IP address here so your own "testing" doesn't add to the stats
if($ip_address != '123.45.67.890')
{
    
$server 'localhost';        // Probably will not change
    
$username 'username';        // Database username here
    
$password 'password';        // Database password here
    
$db_name 'db_name';        // Database name here
    
    
$dbh mysql_connect($server$username$password) or die ('Unable to connect to MySQL');
    
$selected mysql_select_db($db_name$dbh) or die ('Unable to select database.');

    global 
$image$height$width;
    
    
$browser get_browser(nulltrue);
    
$os_version $browser['platform'];
    
    
$query "INSERT INTO downloads (filename, height, width, dl_time, ip_address, os_version) VALUES ('$image', '$height', '$width', now(), '$ip_address', '$os_version');";
    
$result = @mysql_query($query);
    
    
mysql_close($dbh);
}
?>