Location: PHPKode > scripts > Click Stats > redirect.php
<?php

if (isset($protocol)){
	$protocol = $_GET['protocol'];
}
else $protocol = "http://";

$url = $_GET['url']; 

$file = str_replace("/", "_", $url);
$filename = $_SERVER['DOCUMENT_ROOT'] ."/redirectstats/$file.txt";

$hits = 0;

if (file_exists($filename)){
	$handle = fopen($filename, 'r');
	$hits = fread($handle, filesize($filename));
	fclose($handle);	
}

$hits++;

$fp = fopen($filename, 'w') or die("oops");
fwrite($fp, $hits);
fclose($fp);
$redirect = $protocol . $url;

header('Location:' . $redirect);

?>
Return current item: Click Stats