2/21/2005
WordPress Trackback Spam Killer
I’ve been getting hammered with trackback spam. I have my blacklist setup to weed out anything that comes from our good friends, the “texas hold em / online poker” folks. However, this just puts the trackback spam into the moderation queue. That means I have to clean it out ever so often. I’m lazy, so that rarely happens. To get around this, I wrote a modification to the WordPress wp-trackback.php file to search for these spammers and nix their attempts at making me do work.
I created a new file called ‘wp-trackback_spamkiller.php’ that contained the following code. You can add whatever words you would like to be blacklisted in the $blacklist array.
<?
function trackbackSpamKiller($message){
# add to this to get rid of trackback spam containing these words
$blacklist = array(
'online casino',
'texas hold',
'texashold',
'online poker',
'virtual strip poker'
);
foreach($blacklist as $key=> $val){
# if it's in there... kill the attempt
if(strstr($message,$val)){
die("Please don't spam me.");
}
}
}
?>
After you have created that file and uploaded it to the same folder as your ‘wp-trackback.php’ file you will need to make a call to the function in the ‘wp-trackback.php’ file. Download the ‘wp-trackback.php’ file and find the line that reads:
require(dirname(__FILE__) . '/wp-config.php');
Directly under that line, insert the following line:
require('wp-trackback_spamkiller.php');
This will allow the trackback file to call the function that we created earlier. Now you need to actually call the function so that the test can be performed. Find the line in your ‘wp-trackback.php’ file that reads:
$blog_name = $_POST['blog_name'];
Immediately after that line, paste these lines:
trackbackSpamKiller($title); trackbackSpamKiller($blog_name); trackbackSpamKiller($excerpt);
Now, save the ‘wp-trackback.php’ file and upload it to the server. Your trackback spam should no longer appear in the moderation queue. I’ll probably refine this in the future but for now, it works. Of course, caveat emptor.
UPDATE: I changed the formatting a little and made some changes to the blacklist array. I’m looking into allowing the blacklist array to be pulled from the moderation queue list. That way you can use the same blacklist rather than maintaining two lists. –Axs (3:15pm 2005-02-23)
Nothing playing at time of post.
Filed by AxsDeny at 4:02 pm under General, Web Design

Trackback Spam Must Die Big ups to Dave for writing a trackback spam killer. I plan to implement it very soon on my own as I see more and more trackback spam hitting my blog.
Wordpress & Trackback Spam Nachdem die lieben Herrn “Teas Holdem” & “Fre Onlne P*ker” unseren Blog mit immer mehr Trackback-Spam zu beglücken suchten, hab ich heute mal diesen Hack eingebaut. Schaun ma mal obs hilft…
[...] 6/2005 Trackback Spam Killer Filed under: General — Bridget @ 4:11 pm Trackback Spam Killer has been implemented on this blog. Beware! Comm [...]
[...] This “WordPress Trackback Spam Killer” use a keyword based blacklist. I don’t even try it — I know in the guts that keyword blocking can never be effective. Everybody knows the successful rate (or lack thereof) of spamassassin when encountering non-latin characters. (I don’t mean I’m against spamassassin, it really helped a lot when blocking spam from western countries.) [...]