Hi,

I'm using version 1.3.7.1 and client doesn't want to upgrade. He's been getting a lot of spam through his contact form. I had previously installed the extra fields to contact form which is working just fine, but also wanted to add the recaptcha module to the contact form as well.

There seems to be one file which both modules have been modified: includes/modules/pages/contact_us/header_php.php

The add extra fields header_php.php file shows the following:
require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));

$error = false;
if (isset($_GET['action']) && ($_GET['action'] == 'send')) {
$phone = zen_db_prepare_input($_POST['phonenumber']);
$streetaddress = zen_db_prepare_input($_POST['streetaddress']);
$city = zen_db_prepare_input($_POST['city']);
$yourstate = zen_db_prepare_input($_POST['yourstate']);
$zip = zen_db_prepare_input($_POST['zip']);
$payment = zen_db_prepare_input($_POST['payment']);
$card = zen_db_prepare_input($_POST['card']);
$name = zen_db_prepare_input($_POST['contactname']);
$email_address = zen_db_prepare_input($_POST['email']);
$enquiry = zen_db_prepare_input(strip_tags($_POST['enquiry']));

$zc_validate_email = zen_validate_email($email_address);

if ($zc_validate_email and !empty($enquiry) and !empty($name)) {
// auto complete when logged in
if($_SESSION['customer_id']) {
$sql = "SELECT customers_id, customers_firstname, customers_lastname, customers_password, customers_email_address, customers_default_address_id, customers_telephone
FROM " . TABLE_CUSTOMERS . "
WHERE customers_id = :customersID";

$sql = $db->bindVars($sql, ':customersID', $_SESSION['customer_id'], 'integer');
$check_customer = $db->Execute($sql);
$customer_email= $check_customer->fields['customers_email_address'];
$customer_phone= $check_customer->fields['customers_telephone'];
$customer_name= $check_customer->fields['customers_firstname'] . ' ' . $check_customer->fields['customers_lastname'];
} else {
$customer_phone='Not logged in';
$customer_email='Not logged in';
$customer_name='Not logged in';
}

// use contact us dropdown if defined
if (CONTACT_US_LIST !=''){
$send_to_array=explode("," ,CONTACT_US_LIST);
preg_match('/\<[^>]+\>/', $send_to_array[$_POST['send_to']], $send_email_array);
$send_to_email= eregi_replace (">", "", $send_email_array[0]);
$send_to_email= eregi_replace ("<", "", $send_to_email);
$send_to_name = preg_replace('/\<[^*]*/', '', $send_to_array[$_POST['send_to']]);
} else { //otherwise default to EMAIL_FROM and store name
$send_to_email = EMAIL_FROM;
$send_to_name = STORE_NAME;
}

// Prepare extra-info details
$extra_info = email_collect_extra_info($name, $email_address, $customer_name, $customer_email, $customer_phone);
// Prepare Text-only portion of message
$text_message = OFFICE_FROM . "\t" . $name . "\n" .
OFFICE_PHONE . "\t" . $phone . "\n" .
OFFICE_STREETADDRESS . "\t" . $streetaddress . "\n" .
OFFICE_CITY . "\t" . $city . "\n" .
OFFICE_YOURSTATE . "\t" . $yourstate . "\n" .
OFFICE_ZIP . "\t" . $zip . "\n" .
OFFICE_PAYMENT . "\t" . $payment . "\n" .
OFFICE_CARD . "\t" . $card . "\n" .
OFFICE_EMAIL . "\t" . $email_address . "\n\n" .
'------------------------------------------------------' . "\n\n" .
strip_tags($_POST['enquiry']) . "\n\n" .
'------------------------------------------------------' . "\n\n" .
$extra_info['TEXT'];
// Prepare HTML-portion of message
$html_msg['EMAIL_MESSAGE_HTML'] = strip_tags($_POST['enquiry']);
$html_msg['CONTACT_US_OFFICE_FROM'] = OFFICE_FROM . ' ' . $name . '<br />' . OFFICE_PHONE . ' ' . $phone . '<br />' . OFFICE_EMAIL . '(' . $email_address . ')';
$html_msg['EXTRA_INFO'] = $extra_info['HTML'];
// Send message
zen_mail($send_to_name, $send_to_email, EMAIL_SUBJECT, $text_message, $name, $email_address, $html_msg,'contact_us');

zen_redirect(zen_href_link(FILENAME_CONTACT_US, 'action=success'));
} else {
$error = true;
if (empty($name)) {
$messageStack->add('contact', ENTRY_EMAIL_NAME_CHECK_ERROR);
}
if ($zc_validate_email == false) {
$messageStack->add('contact', ENTRY_EMAIL_ADDRESS_CHECK_ERROR);
}
if (empty($phone)) {
$messageStack->add('contact', ENTRY_EMAIL_PHONE_CHECK_ERROR);
}
if (empty($enquiry)) {
$messageStack->add('contact', ENTRY_EMAIL_CONTENT_CHECK_ERROR);
}
}
} // end action==send

// default email and name if customer is logged in
if($_SESSION['customer_id']) {
$sql = "SELECT customers_id, customers_firstname, customers_lastname, customers_password, customers_email_address, customers_default_address_id,customers_telephone
FROM " . TABLE_CUSTOMERS . "
WHERE customers_id = :customersID";

$sql = $db->bindVars($sql, ':customersID', $_SESSION['customer_id'], 'integer');
$check_customer = $db->Execute($sql);
$phone= $check_customer->fields['customers_telephone'];
$email= $check_customer->fields['customers_email_address'];
$name= $check_customer->fields['customers_firstname'] . ' ' . $check_customer->fields['customers_lastname'];
}

if (CONTACT_US_LIST !=''){
foreach(explode(",", CONTACT_US_LIST) as $k => $v) {
$send_to_array[] = array('id' => $k, 'text' => preg_replace('/\<[^*]*/', '', $v));
}
}

// include template specific file name defines
$define_page = zen_get_file_directory(DIR_WS_LANGUAGES . $_SESSION['language'] . '/html_includes/', FILENAME_DEFINE_CONTACT_US, 'false');

$breadcrumb->add(NAVBAR_TITLE);
?>

The recaptcha header_php.php file shows the following:
require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));
require(DIR_WS_CLASSES . 'recaptchalib.php');

$error = false;

if (isset($_GET['action']) && ($_GET['action'] == 'send')) {

$name = zen_db_prepare_input($_POST['contactname']);

$email_address = zen_db_prepare_input($_POST['email']);

$enquiry = zen_db_prepare_input(strip_tags($_POST['enquiry']));



$zc_validate_email = zen_validate_email($email_address);

if(CONTACT_US_RECAPTCHA_STATUS == 'true')
{
// start modification for reCaptcha
// the response from reCAPTCHA
$resp = null;

// was there a reCAPTCHA response?
$resp = recaptcha_check_answer (CONTACT_US_RECAPTCHA_PRIVATE_KEY,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
}


if ($zc_validate_email and !empty($enquiry) and !empty($name)) {

// auto complete when logged in

if($_SESSION['customer_id']) {

$sql = "SELECT customers_id, customers_firstname, customers_lastname, customers_password, customers_email_address, customers_default_address_id

FROM " . TABLE_CUSTOMERS . "

WHERE customers_id = :customersID";



$sql = $db->bindVars($sql, ':customersID', $_SESSION['customer_id'], 'integer');

$check_customer = $db->Execute($sql);

$customer_email= $check_customer->fields['customers_email_address'];

$customer_name= $check_customer->fields['customers_firstname'] . ' ' . $check_customer->fields['customers_lastname'];

} else {

$customer_email = NOT_LOGGED_IN_TEXT;

$customer_name = NOT_LOGGED_IN_TEXT;

}



// use contact us dropdown if defined

if (CONTACT_US_LIST !=''){

$send_to_array=explode("," ,CONTACT_US_LIST);

preg_match('/\<[^>]+\>/', $send_to_array[$_POST['send_to']], $send_email_array);

$send_to_email= eregi_replace (">", "", $send_email_array[0]);

$send_to_email= eregi_replace ("<", "", $send_to_email);

$send_to_name = preg_replace('/\<[^*]*/', '', $send_to_array[$_POST['send_to']]);

} else { //otherwise default to EMAIL_FROM and store name

$send_to_email = EMAIL_FROM;

$send_to_name = STORE_NAME;

}



// Prepare extra-info details

$extra_info = email_collect_extra_info($name, $email_address, $customer_name, $customer_email);

// Prepare Text-only portion of message

$text_message = OFFICE_FROM . "\t" . $name . "\n" .

OFFICE_EMAIL . "\t" . $email_address . "\n\n" .

'------------------------------------------------------' . "\n\n" .

strip_tags($_POST['enquiry']) . "\n\n" .

'------------------------------------------------------' . "\n\n" .

$extra_info['TEXT'];

// Prepare HTML-portion of message

$html_msg['EMAIL_MESSAGE_HTML'] = strip_tags($_POST['enquiry']);

$html_msg['CONTACT_US_OFFICE_FROM'] = OFFICE_FROM . ' ' . $name . '<br />' . OFFICE_EMAIL . '(' . $email_address . ')';

$html_msg['EXTRA_INFO'] = $extra_info['HTML'];


/*
* reCAPTCHA modification begin
* check for valid response before sending mail
*/
if(CONTACT_US_RECAPTCHA_STATUS == 'true' && $resp->is_valid)
{
// Send message
zen_mail($send_to_name, $send_to_email, EMAIL_SUBJECT, $text_message, $name, $email_address, $html_msg,'contact_us');
zen_redirect(zen_href_link(FILENAME_CONTACT_US, 'action=success'));
}
if(CONTACT_US_RECAPTCHA_STATUS == 'false'){
// Send message
zen_mail($send_to_name, $send_to_email, EMAIL_SUBJECT, $text_message, $name, $email_address, $html_msg,'contact_us');
zen_redirect(zen_href_link(FILENAME_CONTACT_US, 'action=success'));
}


/*
* reCAPTHCA modification begin
*/
if(CONTACT_US_RECAPTCHA_STATUS == 'true' && !$resp->is_valid)
{
$error = true;
$messageStack->add('contact', ENTRY_SECURITY_CHECK_ERROR);
}
/*
* reCAPTCHA modification end
*/


} else {

$error = true;

if (empty($name)) {

$messageStack->add('contact', ENTRY_EMAIL_NAME_CHECK_ERROR);

}

if ($zc_validate_email == false) {

$messageStack->add('contact', ENTRY_EMAIL_ADDRESS_CHECK_ERROR);

}

if (empty($enquiry)) {

$messageStack->add('contact', ENTRY_EMAIL_CONTENT_CHECK_ERROR);

}

/*
* reCAPTHCA modification begin
*/
if(CONTACT_US_RECAPTCHA_STATUS == 'true' && !$resp->is_valid)
{
$messageStack->add('contact', ENTRY_SECURITY_CHECK_ERROR);
}

}

} // end action==send



// default email and name if customer is logged in

if($_SESSION['customer_id']) {

$sql = "SELECT customers_id, customers_firstname, customers_lastname, customers_password, customers_email_address, customers_default_address_id

FROM " . TABLE_CUSTOMERS . "

WHERE customers_id = :customersID";



$sql = $db->bindVars($sql, ':customersID', $_SESSION['customer_id'], 'integer');

$check_customer = $db->Execute($sql);

$email= $check_customer->fields['customers_email_address'];

$name= $check_customer->fields['customers_firstname'] . ' ' . $check_customer->fields['customers_lastname'];

}



if (CONTACT_US_LIST !=''){

foreach(explode(",", CONTACT_US_LIST) as $k => $v) {

$send_to_array[] = array('id' => $k, 'text' => preg_replace('/\<[^*]*/', '', $v));

}

}



// include template specific file name defines

$define_page = zen_get_file_directory(DIR_WS_LANGUAGES . $_SESSION['language'] . '/html_includes/', FILENAME_DEFINE_CONTACT_US, 'false');



$breadcrumb->add(NAVBAR_TITLE);

?>

Obviously, I don't want to screw up the coding of either file and since I am not a coder, I want to be able to use both. Would anyone here please guide me as to how to integrate the code from both into the header_php.php file?

I'd really appreciate it.

webmiss