Support » Plugins » I hate blogspammers – this is how I kill them

  • Dont stupid blogspammers have anything useful to do?
    My blogs have moderated comments and its a pain to delete 50 per day!
    (BTW: I changed the default radio button to be “Delete comment” )

    So here is a very minor code change to blast them into oblivion with no effort on your part, after setting up your kill words.
    – it also has a fix for a problem that should be handled elsewhere, but I don’t have time right now. Maybe someone else can do it.

    First, add this function in wp-includes/functions.php

    function zap_comment($author, $email, $url, $comment, $user_ip)
    // moderation keys empty?
    if (” == trim( get_settings(‘moderation_keys’) ) ) return false;
    $words = explode(“\n”, get_settings(‘moderation_keys’) );
    foreach ($words as $word)
    $word = trim($word);
    $pattern = “#$word#i”;
    if(‘##i’ != $pattern) // ignore blank lines in the bad words list
    if ( preg_match($pattern, $author) ) return true;
    if ( preg_match($pattern, $email) ) return true;
    if ( preg_match($pattern, $url) ) return true;
    if ( preg_match($pattern, $comment) ) return true;
    if ( preg_match($pattern, $user_ip) ) return true;
    return false;

    Then change the checkcomment code in wp-comments-post.php

    if(check_comment($author, $email, $url, $comment, $user_ip))
    $approved = 1;
    if(zap_comment($author, $email, $url, $comment, $user_ip))
    die( __(‘Stop spamming my blog, I just delete all your spam anyway.’) );
    $approved = 0;

    You can test this by visiting one of my blogs at and posting a comment.

    To trigger it, use the phrase “stupid blogspammers”

    Hopefully someone will consider using this and adding another textarea for kill_keys, rather than using moderation_keys


Viewing 15 replies - 1 through 15 (of 28 total)
  • This feature has been built into WP1.5 on the Discussion Option page 🙂

    but useful for those not on 1.5

    Hi Alan – I have just tested your site using “stupid blogspammers” in the comment as suggested. Very nice! I then copied the code you provided above and added it to my own site. It’s brilliant! Thank you so much for taking the time to design this code and for sharing it.


    Something that would be neat (not in 1.5 either) would be to block posts on various other things – e.g. the name given by the spammer, or an url specified (either in the poster-info, or in the post). Since the blogspam follows some rules on these things – esp. the most regular ones – that would do nicely.

    I am wondering where this spam comes from? Most of what I get has non-working links in anyway – whats the point exactly?

    The best anti-spam hack I’ve seen is Authimage. It requires the poster to enter in an image code(which the spam bots can’t read). EXCELLENT hack!

    You can see what it looks like in the comments section of my blog:

    Moderator James Huff


    Halfelf Minion 🚀

    Well, since we’re now going off topic and throwing out other anti-spam solutions, enjoy the feast:

    Some bots are now capable of reading image codes. This is not a long-term solution to stopping spam. Methods will have to continue to evolve as the spammers evolve.

    Those “image-reader” bots aren’t very accurate though. They have problems with certain fonts and with skewed characters. If you know just a tiny bit of PHP, you can change both the font and the skew angle in the authimage hack. So, unless there’s a huge leap in spam bot technology, this is a safe solution for a while.

    However I agree that eventually the spammers will probably figure out a way around this, too.

    Joe, what is the “bit of PHP” that we’d need to skew font and angle?

    thanks much Alan, you made me very happy this morning.

    Interesting to hear that bots can now read those images. Perhaps something similar to displaying sums to add up would be an extra step in complexity to keep them at bay for a while?

    Try this on a bot…

    “Anne has 15 apples,
    Jenny has 12, but gave 3 to Sam
    Sam had 4 to start with, then gave 2 to Anne.
    How many has Sam got now?”

    No bot is going to work that out (I think I might just start on a plugin/hack for this…. hmmm). Hell, it’s probably even script kiddie proof. Success!

    Mark (podz)


    Support Maven

    Anne has 17
    Jenny has 9
    Sam has 5

    that right ?

    Correct. You can now post a comment 😉

    If you open up authimage.php, find this near the beginning:
    ImageTTFText($im, 18, 5,
    That 18 is font size in pt. The 5 is the angle in degrees.

    Note that the angle is already skewed a bit by default (5 degrees), so it should be “good enough for now” as-is.

    The problem with the authimage hack is that if you use a textbrowser like links or lynx, you’re screwed.

    I prefer SpamKarma.

Viewing 15 replies - 1 through 15 (of 28 total)
  • The topic ‘I hate blogspammers – this is how I kill them’ is closed to new replies.