# b2 comments WORD VERIFIER #
by Cyberian75
UPDATE 12.06.06: OBSOLETE!! Use the b2 image verifier instead.
Last updated 02.02.06; Added stripslashes to avoid problem with apostrophe (').
Source: http://cafelog.com/board/viewtopic.php?t=5948
Archived: http://web.archive.org/web/20050207180407/http://cafelog.com/board/viewtopic.php?t=5948
Have your commenters type in the first word of your post or title to comment with this hack.
This modification is great for combating spambots posting through b2comments.post.php
Everything in between "//[code]" are actual codes.
STEP 1 a)
In the "b2comments.post.php" file after the "comment_post_ID" variable, put the following:
[code]
$word = strtolower(trim($HTTP_POST_VARS["word"]));
$postdata = get_postdata($comment_post_ID);
$content = stripslashes($postdata["Content"]);
eregi("[a-z0-9\-]+", $content, $matches);
if (empty($word) || $word != strtolower($matches[0])) {
setcookie("comment",$comment, time()+30000000);
echo "Error: the word you entered do not match or is empty.";
echo "\n
\ngo back\n\n";
exit;
} elseif (isset($HTTP_COOKIE_VARS["comment"])) {
setcookie("comment","", time()-30000000);
}
[/code]
STEP1 b)
If you want the user to write the first word of the title, change
$content = stripslashes($postdata["Content"]);
to
$content = stripslashes($postdata["Title"]);
in the above code:)
STEP 2
Then on top of your comment page(s):
[code]
$comment = (empty($HTTP_COOKIE_VARS["comment"])) ? "comment" : $HTTP_COOKIE_VARS["comment"];
[/code]
STEP 3
Then in your comment form:
[code]
Please enter the first word of this post:
[/code]
ADDITIONAL STEP
And in between the textarea tag:
This last one is optional, tho:p
NOTE: If you're using the first word of the TITLE and not the post, use "Title" instead of "Content"
That's all!
Source: http://cafelog.com/board/viewtopic.php?t=5948