I managed to get both the regular referrer and the keyword referrer scripts into one file. But then I had to break them out because of the way PHP includes works under Nucleus. Still most of the functions are in one file and there are two small files for including in my pages.
Here’s a break down to each file:
reflog.php – the file that does all of the logging. It creates the file the others read. It logs a set number of log items. I set this to 100 because it should contain both the search and non-search referrers. It puts the date and time in each line as well.
searchfunctions.php – work horse of the display. It contains functions for doing the actual building of the html from the log file. There are three functions in it.
function displayReferrers($displayType,$referrerFile, $displayLimit)This used to be the body of the one file version. Now it is what is called by the other files. You pass if what type of display you want. “Search” is the only option at the moment, and if you pass in an empty string or anything else you the the standard referrers. You pass in the relative path to the referrer log file, and the max number of items you want displayed.
function killURL($inURL)This function read in a file called “ref_kill.txt”. It then searches for each line in the passed in url. If it finds it, it return YES, meaning don’t display this URL. You put strings on one line each in the text file.
function getSearchEngineAndKeywords($inURL) This routine parses out the query words and returns the search engine if it is a query. If not it return null.
Update: Found a bug in killURL that was causing it to only filter on the last item in the kill file. You need to trim the search first, or it will include the return character. The online script has been updated.
Update 2:Made a change so if you get a URL from a search engine but it has no query string getSearchEngineAndKeywords will return null instead of an empty query. Did this because I added Technorati to my search engine list. Now queries show up in the query list, while pings show up in referrers.