Hello, I need adapt this for recaptcha
(original code)
// 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
(SAM´s code)
<?php
/*
$Id: contact_us.php,v 1.5 2010/02/02 Spooks Exp $
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright © 2010 osCommerce
Released under the GNU General Public License
*/
// anti-hacker account
require('includes/functions/account_secure.php');
clean_post ();
// EOF anti-hacker account
require('includes/application_top.php');
// start modification for reCaptcha
require_once('includes/classes/recaptchalib.php');
// end modification for reCaptcha
require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CONTACT_US);
$error = false;
if (isset($_GET['action']) && ($_GET['action'] == 'send')) {
$name = tep_db_prepare_input($_POST['name']);
$email = tep_db_prepare_input($_POST['email']);
$enquiry = tep_db_prepare_input($_POST['enquiry']);
$subject = tep_db_prepare_input($_POST['subject']);
$phone = tep_db_prepare_input($_POST['phone']);
$date = 'Date Sent: ' . date("d M Y H:i:s");
$orders_id = tep_not_null($_POST['orders_id']) ? $_POST['orders_id'] : false;
$xipaddress = $_SERVER["REMOTE_ADDR"];
$subject = $subject ? $subject : EMAIL_SUBJECT;
//$enquiry = preg_replace('/\r/','\', \'',$enquiry);
//$enquiry = preg_replace('/\(|\)/','\'',$enquiry);
//$_POST['enquiry'] = $result;
if (strlen($name) < ENTRY_LAST_NAME_MIN_LENGTH) {
$error = true;
$messageStack->add('contact', ENTRY_LAST_NAME_ERROR);
}
if (strlen($enquiry) < 8) {
$error = true;
$messageStack->add('contact', ENTRY_ERROR_ENQUIRY);
}
if (!tep_validate_email($email)) {
$error = true;
$messageStack->add('contact', ENTRY_EMAIL_ADDRESS_CHECK_ERROR);
}
if (!$error) {
$enquiry = MESSAGE_FROM . $name . "\n" . $date . "\n" . ($phone ? ENTRY_TELEPHONE_NUMBER . $phone . "\n" : '' ) . ($customer_id ? MAIL_CLIENT_ID . $customer_id . "\n" : '') . ($orders_id ? MAIL_ORDER_ID . $orders_id . "\n" : '') . "\n" . MAIL_IP . $xipaddress . '.' . "\n\n" . ENTRY_ENQUIRY . "\n" . $enquiry;
tep_mail(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, $subject, $enquiry, $name, $email);
tep_redirect(tep_href_link(FILENAME_CONTACT_US, 'action=success'));
}
}
$breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_CONTACT_US));
$account = array();$orders = array();$name = '';$email = '';$phone = '';
if (tep_session_is_registered('customer_id')) {
$account_query = tep_db_query("select customers_firstname, customers_lastname, customers_telephone, customers_id, customers_email_address from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'");
$account = tep_db_fetch_array($account_query);
$name = $account['customers_firstname'].' '.$account['customers_lastname'] ;
$email = $account['customers_email_address'] ;
$phone = $account['customers_telephone'] ;
$history_query = tep_db_query("select orders_id, date_purchased from " . TABLE_ORDERS . " where customers_id = '" . (int)$customer_id . "' order by orders_id DESC");
$orders[0] = array('id' => '0', 'text' => ENTRY_ORDER_ID);
while ($history = tep_db_fetch_array($history_query)) {
$orders[] = array('id' => $history['orders_id'], 'text' => $history['orders_id'] . ENTRY_ORDERED . tep_date_short($history['date_purchased']));
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body>
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->
<!-- body //-->
<table width="995" border="0" align="center" cellpadding="3" cellspacing="3" summary="" bgcolor="#FFFFFF">
<tr>
<!-- body_text //-->
<td width="100%" valign="top"><?php echo tep_draw_form('contact_us', tep_href_link(FILENAME_CONTACT_US, 'action=send')); ?><table border="0" summary="" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td><table border="0" summary="" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
</tr>
</table></td>
</tr>
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
</tr>
<?php
if ($messageStack->size('contact') > 0) {
?>
<tr>
<td><?php echo $messageStack->output('contact'); ?></td>
</tr>
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
</tr>
<?php
}
if (isset($_GET['action']) && ($_GET['action'] == 'success')) {
?>
<tr>
<td class="main" align="center"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_man_on_board.gif', HEADING_TITLE, '0', '0', 'align="left"') . TEXT_SUCCESS; ?></td>
</tr>
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
</tr>
<tr>
<td><table border="0" summary="" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
<tr class="infoBoxContents">
<td><table border="0" summary="" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
<td align="right"><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a>'; ?></td>
<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<?php
} else {
echo tep_draw_hidden_field('phone',$phone);
?>
<tr>
<td><table border="0" summary="" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
<tr class="infoBoxContents">
<td valign="top" width="40%">
<table>
<tr>
<td class="main" >
<b><?php echo nl2br(STORE_NAME_ADDRESS); ?></b><br><br>
<?php echo (OPENING_HOURS); ?>
</td>
</tr>
</table>
</td><td valign="top" width="60%"><table border="0" summary="" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td class="main"><?php echo ENTRY_NAME; ?></td>
</tr>
<tr>
<td class="main"><?php echo (isset($account['customers_lastname']) ? $name . tep_draw_hidden_field('name',$name) : tep_draw_input_field('name', $name, 'size="28"')); ?></td>
</tr>
<tr>
<td class="main"><?php echo ENTRY_EMAIL; ?></td>
</tr>
<tr>
<td class="main"><?php echo tep_draw_input_field('email', $email, 'size="28"'); ?></td>
</tr>
<tr>
<td class="main"><?php echo BOX_HEADING_SUBJECT; ?></td>
</tr>
<tr>
<td class="main"><?php echo tep_draw_input_field('subject', '', 'size="28"');
if (sizeof($orders) > 1) {
echo ' ' . tep_draw_pull_down_menu('orders_id', $orders);
}
?></td>
</tr>
<tr>
<td class="main"><?php echo ENTRY_ENQUIRY; ?></td>
</tr>
<tr>
<td><?php echo tep_draw_textarea_field('enquiry', 'soft', 50, 15); ?></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
</tr>
<tr>
<td><table border="0" summary="" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
<tr class="infoBoxContents">
<td><table border="0" summary="" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
<td align="right"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td>
<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<?php
}
?>
</table></form></td>
<!-- body_text_eof //-->
<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" summary="" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- right_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>
<!-- right_navigation_eof //-->
</table></td>
</tr>
</table>
<!-- body_eof //-->
<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
----------
Thanks