Page 1 of 1

[MOD] Stop review spam disabling captcha

Posted: Thu Jul 01, 2010 4:58 pm
by Martin
I've noticed a high incidence of customers trying to contact me using the Contact form but the Captcha system is so poor that many don't find it easy to read and I lose out on sales. Unfortunately the Captcha setting also determines whether you use it for reviews which I DO want to have because the spam bots are constantly hitting that function.

So, quick and dirty "fix" to enable Captcha for reviews but disable for everything else.

Open: includes/display/ProductReviews.php

Find:

Code: Select all

		if (GetConfig('CaptchaEnabled') == false) {
			$GLOBALS['HideReviewCaptcha'] = "none";
		}
		else {
			// Generate the captcha image
			$GLOBALS['ISC_CLASS_CAPTCHA'] = GetClass('ISC_CAPTCHA');
			$GLOBALS['ISC_CLASS_CAPTCHA']->CreateSecret();
			$GLOBALS['CaptchaImage'] = $GLOBALS['ISC_CLASS_CAPTCHA']->ShowCaptcha();
		}
Replace with:

Code: Select all

			// Generate the captcha image
			$GLOBALS['ISC_CLASS_CAPTCHA'] = GetClass('ISC_CAPTCHA');
			$GLOBALS['ISC_CLASS_CAPTCHA']->CreateSecret();
			$GLOBALS['CaptchaImage'] = $GLOBALS['ISC_CLASS_CAPTCHA']->ShowCaptcha();
Pre 6.x
Open: includes/classes/class.review.php

6.x or later
Open: modules/comments/builtincomments/module.builtincomments.php

Find:

Code: Select all

		// Do we need to check captcha?
		if(GetConfig('CaptchaEnabled') && isc_strtolower($captcha) != isc_strtolower($GLOBALS['ISC_CLASS_CAPTCHA']->LoadSecret())) {
			$_SESSION['productReviewData'] = $reviewPostData;
			FlashMessage(GetLang('ReviewBadCaptcha'), MSG_ERROR, $prodReviewsLink, 'reviews');
			exit;
		}
Replace with:

Code: Select all

		// Do we need to check captcha?
		if(isc_strtolower($captcha) != isc_strtolower($GLOBALS['ISC_CLASS_CAPTCHA']->LoadSecret())) {
			$_SESSION['productReviewData'] = $reviewPostData;
			FlashMessage(GetLang('ReviewBadCaptcha'), MSG_ERROR, $prodReviewsLink, 'reviews');
			exit;
		}

Re: [MOD] Stop review spam disabling captcha

Posted: Tue Jul 20, 2010 12:23 pm
by Martin
Just to note that I got around to testing this and it works fine...

Oh and the bot that attacks the review system will only ever submit a review to the first product from the front page...

Re: [MOD] Stop review spam disabling captcha

Posted: Tue Mar 08, 2011 11:30 pm
by Martin
Updated this modification to be compatible with version 6.x onwards as well... Forgot this had been changed so any reviews would have resulted in a fail because the capcha wasn't showing unless it was set in the configuration. :oops:

Re: [MOD] Stop review spam disabling captcha

Posted: Wed Mar 09, 2011 1:07 am
by Martin
You may also want to use this ReCaptcha replacement code mod as well if this has been useful :)

viewtopic.php?f=12&t=1223

Re: [MOD] Stop review spam disabling captcha

Posted: Wed Mar 09, 2011 1:36 am
by CharlieFoxtrot
Good stuff, Martin!

Re: [MOD] Stop review spam disabling captcha

Posted: Sun Aug 07, 2011 8:03 pm
by mipra
Thank you very much. It works very well