Weeding reference spammers from ShortStat reports
For some odd reason, I get a lot of referer spamming to one of my articles, aptly named New kind of referer spam?.
The frequency of visiting does not bother me, as I still have enough bandwidth available for each month. My only issue was with ShortStat, as the referer spammers polluted my recent referers display. Instead of seeing where people really came from, I saw a lot of domain names related to certain medicines and so forth.
After looking at the issue for a few weeks, I decided to something about it. The easiest solution was to add a filter to the display, and simply not show referers that match the filter.
I took the following steps to weed the list:
- Add a new configuration variable to configuration.php. The variable is an array that contains strings of unwanted referers.
- Edit function SI_getReferers in functions.php:
- Remove the limit in the SQL clause to get as many referers as needed.
- Add a counter to the display loop to check that we have displayed enough referers.
- Add a test loop for each URL. The loop iterates the items in the new configuration variable with strpos. If there is a match, the matching iteration is stopped and that referer is not shown.
- Add incrementing the counter after a referer has been displayed.
- Test the system.
- Write all nasty referers to the configuration variable.
Now, the list is clean once again. I inserted just four names in the configuration and that took care of everything. Hopefully there won’t be more.
The patch is a bit complex and as I’ve heavily tweaked ShortStat, it might not be applicable to a standard ShortStat distribution. Thus, there is no file to be downloaded — but I can provide the stuff for you, if you are interested.
As a sidenote, I’ve been pondering on moving on from ShortStat, as it seems that I’m the only guy developing anything with it anymore… Any suggestions besides Mint?
1. — Jan 6 2009