Hi,
just wrote some tutorial for a safer click counter on proxy list script sites:
the code you should use for your "count_hits.php" file is:
PHP Code:
if (empty($_GET['url'])) {
$url = 'http://www.yoursite.com/';
} else {
if (get_magic_quotes_gpc()) $_GET['url'] = stripslashes($_GET['url']);
$gURL = mysql_real_escape_string($_GET['url']);
$result = mysql_query("SELECT ident FROM links WHERE ident = '".$gURL."'");
if (mysql_num_rows($result) == 1) {
$id = mysql_result($result, 0, 'ident');
$IP = mysql_real_escape_string($_SERVER['REMOTE_ADDR']);
$time_diff = 3600*24*14; // count ones in 14 days
$sql = sprintf("SELECT COUNT(*) AS testval FROM clicks WHERE ip_adr = '%s' AND click_time+%d > NOW() AND site_id = %d", $IP, $time_diff, $id);
$res = mysql_query($sql) or die(mysql_error());
$test = mysql_result($res, 0, 'testval');
if ($tell == 0) {
mysql_query(sprintf("INSERT INTO clicks SET ip_adr = '%s', site_id = %d", $IP, $gURL));
}
} else {
$url = 'http://www.yoursite.com/';
}
}
header('Location: '.$url);
exit;
Check the original URL for database preparations and further information:
Count clicks the right way! | Web Development Blog
I hope this will help, don't forget empty your clicks database table once in a few month!