This lil script saves the referrals to a text file. Each url will only be saved once, i.e it`s pretty Cool .

< ?

/*
This simple function can be regarded as Public Domain. You can do whatever you want, I do not require anything.
Change, distribute or sell this function, I do not care.
There is NO copyright.
*/

// create a subdirectory "safeReferrals" relative to the script location and change the permissions to 777
$pathToFile = "safeReferrals/txt.txt";

if (!empty($HTTP_REFERER)) {
safeReferral($HTTP_REFERER, $pathToFile);
}

function safeReferral($referral, $pathToFile) {
$text = "";
$array = @file($pathToFile);
if (is_array($array)) {
for ($i=0; $i $text = $text.$array[$i];
}
}
if (!eregi($referral."\n",$text)) {
$text .= $referral."\n";
}
$fp = fopen($pathToFile, "w+");
fwrite($fp, $text);
fclose($fp);
}

?>