[MOD] Stop review spam disabling captcha

For Articles relating to more than one ISC version
Post Reply
Martin
Site Admin
Site Admin
Posts: 1854
Joined: Wed Jun 17, 2009 6:30 pm
Location: South Yorkshire UK
Contact:

[MOD] Stop review spam disabling captcha

Post 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;
		}
Martin
Site Admin
Site Admin
Posts: 1854
Joined: Wed Jun 17, 2009 6:30 pm
Location: South Yorkshire UK
Contact:

Re: [MOD] Stop review spam disabling captcha

Post 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...
Martin
Site Admin
Site Admin
Posts: 1854
Joined: Wed Jun 17, 2009 6:30 pm
Location: South Yorkshire UK
Contact:

Re: [MOD] Stop review spam disabling captcha

Post 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:
Martin
Site Admin
Site Admin
Posts: 1854
Joined: Wed Jun 17, 2009 6:30 pm
Location: South Yorkshire UK
Contact:

Re: [MOD] Stop review spam disabling captcha

Post 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
CharlieFoxtrot
Confirmed
Confirmed
Posts: 413
Joined: Sun Aug 09, 2009 1:23 pm

Re: [MOD] Stop review spam disabling captcha

Post by CharlieFoxtrot »

Good stuff, Martin!
ISC 4.0.7

"... and let's be honest that whole "by design" thing is getting old too."
mipra
Posts: 23
Joined: Fri Sep 03, 2010 7:08 pm

Re: [MOD] Stop review spam disabling captcha

Post by mipra »

Thank you very much. It works very well
Post Reply