, 30-09-2003 * Inspired through modification by PHP Referer 0.1 by ivan at xpenguin dot com (http://www.xpenguin.com/phpreferer.php). * Should equally be distributed under GPL * * php must not run in safemode. It must be allowed to execute the shell commands `tail` and `grep` * Which also means, that your site must run on a Unix/Linux platform * * require this file from your php-page and invoke * googleSearches(); * to print the searchphrases */ function googleSearches(){ # your logfile $todaylog = "/path/to/mylogs/access_log"; # number of searchstrings to show $referersToShow = 10; # number of lines to tail - defaults to 1500. Check the referrer density of your logfile to tune performance $linesToTail = 3000; # unique part of location to be monitored for google . ie "weblog" or "~mypage" $inurl = "weblog"; # end of config $referers = array(); error_reporting(1); $tailedLog = `tail -$linesToTail $todaylog | grep "http://www.google"`; $arrayOfLines = explode("\n",$tailedLog); end($arrayOfLines); for($i=0;$i".str_replace("+"," ",$regs[2]).""); } } } } // ensures, that we only get the specified number of hits. $refererCount=0; foreach($final as $x) { print "$x
\n"; if($refererCount++ == $referersToShow-1) break; } } ?>