At the very top of your individual archive template:
<$MTInclude module="referrals"$>
$path_parts = pathinfo($_SERVER['PHP_SELF']);
if (!empty($_SERVER['HTTP_REFERER'])){
saveReferrer($path_parts['basename'], $_SERVER['HTTP_REFERER']);
}
?>
In the spot in your individual archive template where you want the list:
echo listReferrers($path_parts['basename']); ?>
In a template module named referrals:
$backlink_dir = "/local/path/to/chmodded/777/dir/";
$suffix = "_refer.txt";
$blacklist = array('example.com', 'www.example.com');
$my_email = "me@example.com";
$pre_links = "
\n\n";
$post_links = "\n
\n";
/*
call saveReferrer with
$path_parts = pathinfo($_SERVER['PHP_SELF']);
if (!empty($_SERVER['HTTP_REFERER'])){
saveReferrer($path_parts['basename'], $_SERVER['HTTP_REFERER']);
}
*/
// save new referrer
function saveReferrer($post, $referrer){
global $blacklist, $backlink_dir, $suffix;
$url = parse_url($referrer);
if (!in_array($url['host'], $blacklist)){
$referrer = normalizeUrl($referrer);
// if file exists, read it
if($referrals = @file($backlink_dir . $post . $suffix)){
// look for our referrer
reset($referrals);
$repeat = false;
while( list($key, $line) = each($referrals) ){
$line = explode('[+]', trim($line));
if ($line[0] == $referrer){
$repeat = true;
$new_ip = true;
for ($i=0;$i" . displayUrl($line_parts[0]) . " (" . $line_parts[1] . ")
";
}
$ob .= $post_links;
}
return $ob;
}
function displayUrl ($url){
$parts = parse_url($url);
if ($parts['path'] == "/"){
$parts['path'] = "";
}
$pretty_url = $parts['host'] . $parts['path'];
return $pretty_url;
}
?>