Martin
2011-03-09 00:02:43
The mod should allow you to replace the ISC Captcha system for reviews and replace it with the
Right.. modification is as follows:
Create a folder structure like this one: /modules/
Download the reCaptcha PHP library from
Place the recaptchalib.php file in your newly created folder ie: in /modules/custom/recaptcha
Open
/**
* The reCAPTCHA server URL's
*/$recaptcha_private_key = 'Your_Private_API_key_for_this_site';
$recaptcha_public_key = 'Your_Public_API_key_for_this_site';... and
Open
$captcha = '';
if(isset($_POST['captcha'])) {
$captcha = $_POST['captcha'];
}
$captcha_check = true;
// Should reviews be approved automatically?
if(GetConfig('AutoApproveReviews')) {
$status = 1;
}
else {
$status = 0;
}
// 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;
}
//***************************************
// MOD Use ReCaptcha instead of ISC system
require_once(dirname(__FILE__).'/../../modules/custom/recaptcha/recaptchalib.php');
if(isset($recaptcha_private_key) && isset($recaptcha_public_key)) {
$resp = recaptcha_check_answer ($recaptcha_private_key,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
// Invalid recaptcha so do as per normal ISC system
if (!$resp->is_valid) {
$_SESSION['productReviewData'] = $reviewPostData;
FlashMessage(GetLang('ReviewBadCaptcha'), MSG_ERROR, $prodReviewsLink, 'reviews');
exit;
}
}
/*
* If the recaptcha key isn't set we gracefully degrade
* back to the ISC system rather than leave it wide open
*/
else {
$captcha = '';
if(isset($_POST['captcha'])) {
$captcha = $_POST['captcha'];
}
$captcha_check = true;
// Should reviews be approved automatically?
if(GetConfig('AutoApproveReviews')) {
$status = 1;
}
else {
$status = 0;
}
//***************************************
// MOD Force Capcha for reviews
// Do we need to check captcha?
//if(GetConfig('CaptchaEnabled') && isc_strtolower($captcha) != isc_strtolower($GLOBALS['ISC_CLASS_CAPTCHA']->LoadSecret())) {
if(isc_strtolower($captcha) != isc_strtolower($GLOBALS['ISC_CLASS_CAPTCHA']->LoadSecret())) {
$_SESSION['productReviewData'] = $reviewPostData;
FlashMessage(GetLang('ReviewBadCaptcha'), MSG_ERROR, $prodReviewsLink, 'reviews');
exit;
}
// MOD END Force Captcha for reviews
//***************************************
}
// MOD END Use ReCaptcha instead of ISC system
//***************************************Open:
// Is captcha enabled?
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:
//***************************************
// MOD Force Capcha for reviews
/*
// Is captcha enabled?
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();
}
*/
//***************************************
// MOD Use ReCaptcha instead of ISC system
require_once(dirname(__FILE__).'/../../custom/recaptcha/recaptchalib.php');
if(isset($recaptcha_private_key) && isset($recaptcha_public_key)) {
$GLOBALS['CaptchaImage'] = recaptcha_get_html($recaptcha_public_key);
$GLOBALS['CaptchaImage'] .= "
<script type=\"text/javascript\">
\$(function(){
$('#captcha').hide();
$('#captcha').val('true');
});
</script>
";
}
/*
* If the recaptcha key isn't set we gracefully degrade
* back to the ISC system rather than leave it wide open
*/
else {
// Generate the captcha image
$GLOBALS['ISC_CLASS_CAPTCHA'] = GetClass('ISC_CAPTCHA');
$GLOBALS['ISC_CLASS_CAPTCHA']->CreateSecret();
$GLOBALS['CaptchaImage'] = $GLOBALS['ISC_CLASS_CAPTCHA']->ShowCaptcha();
}
// MOD END Force Captcha for reviews
//***************************************That's about it... This is a "free" mod but once again I would appreciate it if you would donate to the next charity bucket or sponsored form you see by way of passing it forward...