Hi All,
First of all can I thank Scott for this great contribution! Very easy and straight forward to install and great to use! I would like to offer some extra code for those of you wanting to integrate the recaptcha to either Links Manager II here or OSC Affiliate here I have only used the 'integrated' look, but will post the 'non integrated' look if anyone wants it. I must add that I used my very limited knowledge to achieve this, hence posting here rather than adding to Scott's contribution thread... there may be better logic than I have used!
Links Manager II
catalog/links_submit.php
find:
// needs to be included earlier to set the success message in the messageStack
require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_LINKS_SUBMIT);
require(DIR_WS_FUNCTIONS . 'links.php');
add under:
// start modification for reCaptcha
require_once('includes/classes/recaptchalib.php');
// end modification for reCaptcha
find:
$links_password = tep_db_prepare_input($_POST['links_password']);
$error = false;
add under:
// start modification for reCaptcha
// the response from reCAPTCHA
$resp = null;
// was there a reCAPTCHA response?
$resp = recaptcha_check_answer (RECAPTCHA_PRIVATE_KEY,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (tep_validate_email($email_address) & ($resp->is_valid)) {
tep_mail(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, EMAIL_SUBJECT, $enquiry, $name, $email_address);
tep_redirect(tep_href_link(FILENAME_CONTACT_US, 'action=success'));
} else {
if (!tep_validate_email($email_address)) {
$error = true;
$messageStack->add('contact', ENTRY_EMAIL_ADDRESS_CHECK_ERROR);
}
if (!$resp->is_valid) {
$error = true;
$messageStack->add('contact', ENTRY_SECURITY_CHECK_ERROR . " (reCAPTCHA output: " . $resp->error . ")");
}
}
// end modification for reCaptcha
find:
<td class="main"><?php echo ENTRY_LINKS_PASSWORD; ?></td>
<td class="main"><?php echo tep_draw_password_field('links_password', $links_edit['links_partner_password']); ?></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
</tr>
<?php } ?>
add under:
<!-- start modification for reCaptcha -->
<tr>
<td class="main"><b><?php echo ENTRY_SECURITY_CHECK; ?></b></td>
</tr>
<tr>
<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
<tr class="infoBoxContents">
<td><table border="0" cellspacing="2" cellpadding="2">
<tr>
<?php
$languages_query = tep_db_query("select code from " . TABLE_LANGUAGES . " where directory = '" . $language . "'");
$language_id = tep_db_fetch_array($languages_query);
?>
<script>
var RecaptchaOptions = {
theme : 'clean',
tabindex : 3,
lang : '<?php if (in_array($language_id['code'] ,array('en', 'nl', 'fr', 'de', 'pt', 'ru', 'es', 'tr'))) {echo $language_id['code']; } else {echo 'en'; } ?>'
};
</script>
<td><?php echo recaptcha_get_html(RECAPTCHA_PUBLIC_KEY); ?></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<!-- end modification for reCaptcha -->
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
</tr>
<tr>
OSC Affiliate
catalog/affiliate_signup.php
find:
require('includes/application_top.php');
add under:
// start modification for reCaptcha
require_once('includes/classes/recaptchalib.php');
// end modification for reCaptcha
find:
$a_agb = tep_db_prepare_input($HTTP_POST_VARS['a_agb']);
$error = false; // reset error flag
add under:
// start modification for reCaptcha
// the response from reCAPTCHA
$resp = null;
// was there a reCAPTCHA response?
$resp = recaptcha_check_answer (RECAPTCHA_PRIVATE_KEY,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
$error = true;
$messageStack->add('friend', ENTRY_SECURITY_CHECK_ERROR . " (reCAPTCHA output: " . $resp->error . ")");
}
// end modification for reCaptcha
find:
require(DIR_WS_MODULES . 'affiliate_signup_details.php');
?>
</td>
add under:
<!-- start modification for reCaptcha -->
<tr>
<td class="main"><b><?php echo ENTRY_SECURITY_CHECK1; ?></b></td>
</tr>
<tr>
<?php
$languages_query = tep_db_query("select code from " . TABLE_LANGUAGES . " where directory = '" . $language . "'");
$language_id = tep_db_fetch_array($languages_query);
?>
<script>
var RecaptchaOptions = {
theme : 'clean',
tabindex : 3,
lang : '<?php if (in_array($language_id['code'] ,array('en', 'nl', 'fr', 'de', 'pt', 'ru', 'es', 'tr'))) {echo $language_id['code']; } else {echo 'en'; } ?>'
};
</script>
<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
<tr class="infoBoxContents">
<td><?php echo recaptcha_get_html(RECAPTCHA_PUBLIC_KEY); ?></td>
</tr>
</table></td>
</tr>
<!-- end modification for reCaptcha -->
I hope the above helps a few people... if you have any ideas on changing the code logic... please let me know!
James