Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Putting reCaptcha into Product Reviews Write


longhorn1999

Recommended Posts

Hi,

 

After having multiple login/redirect issues and checking out my competition more closely, I decided to remove the login requirement for my product review pages. I want to make it as easy as possible for people to write reviews, and though they are checked before being approved, this opens the site up to potential spam of course.

 

I'm using the complete reviews system, both for the catalog and the admin, which seems to be the most popular one:

 

http://addons.oscommerce.com/info/4397

 

There are many contributions to add reCaptcha to the contact us forms, etc, but I can't seem to figure out how to integrate it into product_reviews_write.php.

 

instructions to modify contact us from one contribution, http://addons.oscommerce.com/info/7206:

First you will need to register with www.recaptcha.net , get the Public and Private Key for your domain. Download recaptchalib.php from www.recaptcha.net.  
Create a folder in your osCommerce root directory and upload the recaptchalib.php file to this folder

Replace "YOUR PUBLIC KEY HERE" with the public key you get upon registration of your domain with reCaptcha, and "YOUR PRIVATE KEY HERE" with your private 
key that you got upon registration with www.recaptcha.net.


open contact_us.php

find
<tr>
<td><?php echo tep_draw_textarea_field('enquiry', 'soft', 50, 15); ?></td>
</tr>

add after
<!-- START reCAPTCHA script. Modifications for osDate by www.garyfoster.net 02/13/2010-->

<tr>
<td class="main"><?php echo SPAM_CODE; ?></td></tr><tr><td>
<?php require_once('captcha/recaptchalib.php');
$publickey = "YOUR PUBLIC KEY HERE "; // you got this from the signup page
if ($request_type =='SSL') echo recaptcha_get_html($publickey, 0, $request_type);
else
echo recaptcha_get_html($publickey);

?>
</td>
</tr>

<//--END reCAPTCHA MOD by www.garyfoster.net 02/13/2010-->

find
if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'send')) {
$name = tep_db_prepare_input($HTTP_POST_VARS['name']);
$email_address = tep_db_prepare_input($HTTP_POST_VARS['email']);
$enquiry = tep_db_prepare_input($HTTP_POST_VARS['enquiry']);

add after
<!-- START reCAPTCHA script. Modifications for osDate by www.garyfoster.net 02/13/2010-->

$captchaurl = "captchaerror.php" ;
require_once('captcha/recaptchalib.php');
$privatekey = "YOUR PRIVATE KEY HERE ";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);

if (!$resp->is_valid) {
// What happens when the CAPTCHA was entered incorrectly

header( "Location: $captchaurl" );
exit ;
}

<//--END reCAPTCHA MOD by www.garyfoster.net 02/13/2010-->

save and upload

Open includes/languanges/english/contact_us.php

Find
?>

add before
<!-- START reCAPTCHA script. Modifications for osDate by www.garyfoster.net 02/13/2010-->

define('SPAM_CODE', 'Anti Spam field<br>please type in the words as you see them,<br>this is for anti spam protection.');

<//--END reCAPTCHA MOD by www.garyfoster.net 02/13/2010-->

 

I don't want to post my entire product_reviews_write.php here just yet since it's quite long, but has anyone else done this kind of modification successfully?

 

Any suggestions are appreciated, thanks.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...