WordPress.org

Ready to get started?Download WordPress

Forums

Against Spam Flood (11 posts)

  1. But wouldn't that discriminate against individuals who can't do math, or can't find their calculator. ^_-

  2. tagliamax
    Member
    Posted 9 years ago #

    Yes, this could be a limit, but consider that these operations are very elementary

  3. Mark (podz)
    Support Maven
    Posted 9 years ago #

  4. tagliamax
    Member
    Posted 9 years ago #

    Thank you very much, piepiepie! I loss bracket during "cut and paste"...
    Here is the code corrected (with bracket on the first switch() and without
    in is_valid_comment function)
    ***
    If you have problem with spam flood, try this:
    Open wp-comments.php file and find:

    <input name="submit" type="submit" tabindex="5" value="<?php _e("Say It!"); ?>" />

    Put this code before those lines
    <?php
    $fattori = array('two','three','four','five','six','seven','eight','nine');
    $i = rand(0,7);
    $j = rand(0,7);
    $fatt1 = $fattori[$i];
    $fatt2 = $fattori[$j];
    ?>
    Warning! To be sure that the comment
    doesn't come from an automatic mechanism, please answer to this simple question:
    How much is <?php echo $fatt1; ?> X <?php
    echo $fatt2; ?>
    ?
    <input name="fatt1" type="hidden" value="<?php echo
    $fatt1; ?>" />
    <input name="fatt2" type="hidden" value="<?php echo
    $fatt2; ?>" />
    <input name="prodotto" type="text" tabindex="5" maxlength="100"
    size="2" value="" />

    It's advisable to update the value of tabindex attribute in the submit field
    as follow:
    <input name="submit" type="submit" tabindex="6"
    value="<?php _e("Say It!"); ?>" />

    Ok, now open wp-comments-post.php file and find:
    // Simple flood-protection
    $lasttime = $wpdb->get_var("SELECT comment_date FROM $tablecomments
    WHERE comment_author_IP = '$user_ip' ORDER BY comment_date DESC LIMIT 1");

    Put this code before those lines:
    if(!isset($_POST['prodotto']) || ($_POST['prodotto']=="") ||
    !isset($_POST['fatt1']) || !isset($_POST['fatt2'])) {
    die("Sorry, the comment cannot be accepted. It could be spam!");
    }
    else
    {
    $prodotto = $_POST['prodotto'];
    $fatt1 = $_POST['fatt1'];
    $fatt2 = $_POST['fatt2'];
    }
    switch ($fatt1) {
    case "two":
    $fattore1 = 2;
    break;
    case "three":
    $fattore1 = 3;
    break;
    case "four":
    $fattore1 = 4;
    break;
    case "five":
    $fattore1 = 5;
    break;
    case "six":
    $fattore1 = 6;
    break;
    case "seven":
    $fattore1 = 7;
    break;
    case "eight":
    $fattore1 = 8;
    break;
    case "nine":
    $fattore1 = 9;
    break;
    default:
    $fattore1 = rand(1,100);
    break;
    }
    switch ($fatt2) {
    case "two":
    $fattore2 = 2;
    break;
    case "three":
    $fattore2 = 3;
    break;
    case "four":
    $fattore2 = 4;
    break;
    case "five":
    $fattore2 = 5;
    break;
    case "six":
    $fattore2 = 6;
    break;
    case "seven":
    $fattore2 = 7;
    break;
    case "eight":
    $fattore2 = 8;
    break;
    case "nine":
    $fattore2 = 9;
    break;
    default:
    $fattore2 = rand(1,100);
    break;
    }
    function is_valid_comment($f1,$f2,$prod) {
    $prod_v = $f1*$f2;
    if($prod != $prod_v)
    {
    return false;
    }
    else
    {
    return true;
    }
    }
    if(!is_valid_comment($fattore1,$fattore2,$prodotto)) {
    die("Sorry, the comment cannot be accepted. It could be spam, or your computation
    is wrong");
    }

  5. Jerry
    Member
    Posted 9 years ago #

    Thank you so much for this! I got comment spammed badly in just a couple of days and I was tired of deleting each comment.

  6. ShaeLeigh
    Member
    Posted 9 years ago #

    I just installed this...I'd be most pleased if someone would try it out and let me know if it seems to be working properly. With the blacklist plugin also installed, I am having trouble posting my own comments...I keep ending up in my own blacklist.

    url is http://www.shaeleighland.com/index.php

    and thanks!!!

  7. Joni
    Member
    Posted 9 years ago #

    I can't seem to get it to work. I type in NUMERALS in response to the questions and I know the math is right, but I keep getting Sorry, captain.... I tried to send a comment to your Vaja PDA case post three different times. No go.

    I do have something similar in place on my blog that seems to work; it was devised by Jeff Barr. You can go to my blog and check it out by dropping a comment. And you can read about it here.

    J

  8. ShaeLeigh
    Member
    Posted 9 years ago #

    I like what you've done...I seem to have messed up installing it, though...probably did not place the code correctly in wp-comments-post.php - can you take a quick look for me? I greatly appreciate your help!

  9. ShaeLeigh
    Member
    Posted 9 years ago #

    This is my error:

    Parse error: parse error, unexpected T_STRING in /var/www/html/wp-comments-post.php on line 127

  10. ShaeLeigh
    Member
    Posted 9 years ago #

    Another weird thing...now not all my posts are showing; some have disappeared. They all are in the edit posts screen in the control panel, but are missing in index.php? The only thing I've done is install this code, and deactivate the blacklist plugin. (nevermind this one...I figured this part out)

  11. ShaeLeigh
    Member
    Posted 9 years ago #

    Bump

    hoping to get a reply on how to fix this. My comments don't work at all since I installed it, and it's over my head to figure out why. If anyone is looking for a midnight challenge, I wouldn't mind the assistance :)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.