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

  • loopbiz

    (@loopbiz)


    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;
    }
    else
    {
    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
    http://crossfirewar.com 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

    Alan.

Viewing 15 replies - 1 through 15 (of 28 total)
  • RustIndy

    (@rustindy)

    This feature has been built into WP1.5 on the Discussion Option page 🙂

    Jinsan

    (@jinsan)

    but useful for those not on 1.5

    autowriter

    (@autowriter)

    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.

    Michael

    diretribe

    (@diretribe)

    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?

    Joe

    (@joe)

    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:
    Mudbomb.com

    Moderator James Huff

    (@macmanx)

    Well, since we’re now going off topic and throwing out other anti-spam solutions, enjoy the feast: http://www.tamba2.org.uk/wordpress/spam/

    NuclearMoose

    (@nuclearmoose)

    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.

    Joe

    (@joe)

    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.

    DianeV

    (@dianev)

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

    wordygirl

    (@wordygirl)

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

    diretribe

    (@diretribe)

    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!

    Anne has 17
    Jenny has 9
    Sam has 5

    that right ?

    diretribe

    (@diretribe)

    Correct. You can now post a comment 😉

    Joe

    (@joe)

    DianeV:
    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.

    LouisC

    (@louisc)

    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.