Page is a not externally linkable
stuartmcdonald - 12:57 pm on May 6, 2005 (gmt 0)
<?php That will run all the entries into a logfile called googlesyn_log.txt on your site. You can then check it every day and decide which sites you want to keep and which you want to ban. The above stores the entire google string, if you could be bothered you could split it up to just grab the url value out of the query string so you'll get a smaller logfile. If you really had no life you could get the above to email you every time a hit came in ;-) Not perfect, but it beats going through 300meg of log files manually LOL.
If you just want to run off a "mini-log" to record just the hits from the content network, you could use something like the following ( this is in PHP - no doubt the code could be vastly improved, or written in any script language) as an include file:
if(eregi("googlesyndication.com",$HTTP_REFERER)){
if ($QUERY_STRING!= ""){
$url = "http://".$SERVER_NAME.$PHP_SELF.'?'.$QUERY_STRING;
}else{
$url = "http://".$SERVER_NAME.$PHP_SELF;
}
$today = date("F j, Y, g:i a");
$host = gethostbyaddr($REMOTE_ADDR);
$logfile = @fopen('googlesyn_log.txt', 'a');
@fputs($logfile, "$today - Googlesyndication - $url - $host - $HTTP_REFERER\n");
@fclose($logfile);
}
?>