Recent Topics

1 Jun 10, 2012 05:39    

I'm not a fan of CAPTCHAs, so implementing them on my blog to reduce spam comments wasn't really something I wanted to do. Instead, I implemented a simple question for visitors to answer in v4.1.4. Not sure how accurate these instructions will be for other versions, but here's the code I added.

\skins\_item_comment_form.inc.php, after Line 103:

$comment_antispam = '';

\skins\_item_comment_form.inc.php, after Line 175 (before the end of the else):

$Form->text( 't', $comment_antispam, 40, 'Type the letter Q', '<br />You may have to type the letter again if you preview your comment.', 100, 'bComment' );

\htsrv\comment_post.php, after Line 82:

$antispam = param( 't', 'string' );

\htsrv\comment_post.php, after Line 173 (before the end of the else):

if( strcasecmp($antispam, 'q') != 0 )
	{
		$Messages->add( 'You must type the letter Q in the appropriate box.', 'error' );
	}

Obviously, feel free to customize your own implementation.

If you have any questions or enhancements, please post them here.

4 Jul 01, 2012 16:04

I have implemented a Turing test for b2evolution 2.4.2 by adapting the information that is available here for version 4.1.4:

http://forums.b2evolution.net/viewtopic.php?t=24516

First of all, make a backup of these two files just in case anything goes wrong:

\skins\_item_comment_form.inc.php
\htsrv\comment_post.php

Now we are going to adjust the content in \skins\_item_comment_form.inc.php. Find the line that reads

global $comment_cookies, $comment_allow_msgform;

Just after it add a line that reads

global $comment_antispam;

Find the line that reads

$comment_author = $Comment->author;

Just before it add a line that reads

$comment_antispam = '';

(Note that that is two apostrophes in a row, not a double quotation mark.)

Find the line that reads

$Form->text( 'o', $comment_author_url, 40, T_('Website'), '<br />'.T_('Your URL will be displayed.'), 100, 'bComment' );

Just after it (but before the closing brace) add a line that reads

$Form->text( 't', $comment_antispam, 40, 'Type letter Q', '<br />You may have to type the letter again if you preview your comment.', 100, 'bComment' );

Now we are going to adjust the content in \htsrv\comment_post.php. Find the line that reads

$url = param( 'o', 'string' );

After it add a line that reads

$antispam = param( 't', 'string' );

Find the lines that read

	if( empty($email) )
			{
				$Messages->add( T_('Please fill in your email.'), 'error' );
			}



After them (but before the following brace) add

	if( strcasecmp($antispam, 'q') != 0 )
	   {
		  $Messages->add( 'You must type the letter Q in the appropriate box.', 'error' );
	   }

Seems to work perfectly. If anybody else success with this approach, please let me know.

5 Apr 05, 2013 12:43

I've tried implementing this but where is the "appropriate box"? If I try to submit a comment it send me to an error page as describe in your last instruction, but when I go back to the page there's nowhere in which to type Q.

That is,

	$Form->text( 't', $comment_antispam, 40, 'Type letter Q', '<br />You may have to type the letter again if you preview your comment.', 100, 'bComment' );

doesn't seem to make any difference.

6 Dec 07, 2013 20:27

Looby,

The box appears right after the “Website” line and before the “Comment text” line. I attach a picture.

Don.

7 Dec 08, 2013 17:09

This last week some spambot found one of my b2e blogs and started sending me tons of spam via the "contact" link. I decided to implement a basic Turing text just like I had done for my comment function. I'm not a trained coder, so I had a lot of trepidation. Turned out to be pretty easy. I want to put together a Turing test for the "contact" portion of the blog so that I stop receiving spam. I started with the info up above (thanks, theanimation!)

Here was my adjusted procedure.

The two files that seem to be the major ones for processing that are:

/skins/_msgform.disp.php
/htsrv/message_send.php

Back up both of those before making any changes, just in case.

Here's what I did.

Now we are going to adjust the content in /skins/_msgform.disp.php. Find the line that reads

global $cookie_name, $cookie_email;

Just after it add a line that reads

global $contact_antispam;

Find the line that reads

$email_author = '';

Just after it add a line that reads

$contact_antispam = '';

Find the line that reads

$Form->textarea( 'h', '', 15, T_('Message'), T_('Plain text only.'), 40, 'bComment' );

Just after it add a line that reads

$Form->text( 't', $contact_antispam, 40, 'Type letter Q', '<br />You may have to type the letter again if you preview your comment.', 100, 'bComment' );

Now we are going to adjust the content in /htsrv/message_send.php. Find the line that reads

$message = param( 'h', 'html', '' );

After it add a line that reads

$antispam = param( 't', 'string' );

Find the lines that read

	if( empty( $message ) )
	{ // message should not be empty!
		$Messages->add( T_('Please do not send empty messages.'), 'error' );
	}
	elseif( $antispam_on_message_form && antispam_check( $message ) )
	{ // a blacklisted keyword ha sbeen found in the message:
		$Messages->add( T_('The supplied message is invalid / appears to be spam.'), 'error' );
	}



After them (but before the following brace) add

	if( strcasecmp($antispam, 'q') != 0 )
	   {
		  $Messages->add( 'You must type the letter Q in the appropriate box.', 'error' );
	   }

Seems to work perfectly. If anybody else has success with this approach, please let me know.


Form is loading...