WordPress.org

Ready to get started?Download WordPress

Forums

Spam free forever more! (5 posts)

  1. kc8esj
    Member
    Posted 9 years ago #

    Hi,
    I'm not sure if anyone has made this hack yet, but I got so fed up with the spam posts that I spent the few minutes to make it. The way it works is it simply uses an image on the comments page that the user has to enter to submit their comment.. I've used just two letters , but you can make it do as many as you would want.

    You can see how it looks here: http://richard.cernava.com/index.php?p=62#comments

    How do you do the hack???

    #1 Download wp-comments-verify.php (this is the file that generates the image) at http://richard.cernava.com/wp-comments-verify.phps

    #2 Rename it to wp-comments-verify.php and place it in the main folder with the rest of the wp files. Remeber you can edit it and modify the colors of the out put file etc!

    #3 Edit /wp-includes/functions.php and right after <?php on the next line add and save:

    function verify($input)
    {
    session_start();
    $input = trim($input);

    $code = $_SESSION["vcode"];

    $_SESSION["vcode"] = '';

    if ($code == $input && $input != '')
    return 1;
    else
    return 0;
    }

    #4 Edit ~/wp-comments-post.php goto line 85 right after

    if ( '' == $comment )
    die( __('Error: please type a comment.') );

    and add this:

    if (!verify($code))

    die( __('Error: Invalid verification code.') );

    #5 Edit ~/wp-comments.php got line 54 right after

    <code><form action="<?php echo get_settings('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">

    Add this and save:

    <input type="text" name="code" id="code" class="textarea" value="" size="2" tabindex="1" />
    <label for="verification"><img src="<?php echo get_settings('siteurl'); ?>/wp-comments-verify.php"><?php _e("(Enter Code)"); ?></label>

    That should fix the problems!!

  2. moshu
    Member
    Posted 9 years ago #

  3. NuclearMoose
    Member
    Posted 9 years ago #

    "Spam-free forever" is akin to building an "unsinkable cruise ship". :)

  4. James
    Happiness Engineer
    Posted 9 years ago #

    Thanks for going to the effort, but as Moshu pointed out, there are already plenty of available Captcha plugins for WordPress.

  5. kc8esj
    Member
    Posted 9 years ago #

    hehe, very true:P

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.