WordPress.org

Ready to get started?Download WordPress

Forums

Anti spam using a comment hash (2 posts)

  1. rossz
    Member
    Posted 9 years ago #

    This is strictly a proof of concept bit of code. When you attempt to post a comment, a check is made to see if the same comment already exists by calculating the hash of the comment body. This will catch comment flooding by spammers, as well as the accidental hitting of "say it" twice in a row. It will also prevent the "me too" comment. The reason the code is proof-of-concept is because its overhead can be a bit high. It calculates the hash of every single comment each and every time a new comment is posted. A better way of handling this is to compute the hash at posting time and store it in the "comments" table. Place these two lines in wp-comment-post.php just after the block of code for "simple flood protection":

    $already_posted = $wpdb->get_var("SELECT count(*) FROM $tablecomments WHERE md5("$comment")=md5(comment_content)");
    if (!empty($already_posted) && $already_posted) die( __("This message has already been posted!") );

    This will only prevent multiple spams of the exact same garbage, but the first one will get through.

    Rossz

  2. Kafkaesqui

    Posted 9 years ago #

    Most spamming tools already take note of such protective methods by varying comment content. But it may catch the dumber stuff out there.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.