Zen Cart Logo
Forums / General Questions / Contact Us Page Honey Pot Implementation On v1.39h

Contact Us Page Honey Pot Implementation On v1.39h

Views: 1,376

Results 1 to 2 of 2
24 Sep 2015, 11:18 AM
#1
lindasdd avatar

lindasdd

Zen Follower

Join Date:
Jun 2007
Posts:
474
Plugin Contributions:
0

Contact Us Page Honey Pot Implementation On v1.39h

I have one site running on v1.39h (upgrading soon).

In the meantime, I'd like to implement the Contact Us page improvements now available in v1.5.4.

Is this merely a replacement of the header.php file?

Or are additional files required?

Upon just replacing the header.php file the language file isn't loading so I'm assuming there is a script that isn't loading.

Although I could pull code from the old file: require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));
I'd much rather ensure the new file is working properly.

Current Contact Us Page code is:

<?php
/**
 * Contact Us Page
 *
 * @package page * @copyright Copyright 2003-2013 Zen Cart Development Team * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0 * @version GIT: $Id: Author: DrByte  Sun Feb 17 23:22:33 2013 -0500 Modified in v1.5.2 $
 */

// This should be first line of the script:$zco_notifier->notify('NOTIFY_HEADER_START_CONTACT_US');require(DIR_WS_MODULES . zen_get_module_directory('require_languages.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']));  $antiSpam = isset($_POST['should_be_empty']) ? zen_db_prepare_input($_POST['should_be_empty']) : '';
  $zco_notifier->notify('NOTIFY_CONTACT_US_CAPTCHA_CHECK');
  $zc_validate_email = zen_validate_email($email_address);
  if ($zc_validate_email and !empty($enquiry) and !empty($name) && $error == FALSE) {    // if anti-spam is not triggered, prepare and send email:
   if ($antiSpam != '') {      $zco_notifier->notify('NOTIFY_SPAM_DETECTED_USING_CONTACT_US');   } elseif ($antiSpam == '') {
    // 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= preg_replace ("/>/", "", $send_email_array[0]);
      $send_to_email= trim(preg_replace("/</", "", $send_to_email));
      $send_to_name = trim(preg_replace('/\<[^*]*/', '', $send_to_array[$_POST['send_to']]));
    } else {  //otherwise default to EMAIL_FROM and store name
    $send_to_email = trim(EMAIL_FROM);
    $send_to_name =  trim(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'];
    // 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', 'SSL'));  } 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);
    }
  }
} // end action==send
if (ENABLE_SSL == 'true' && $request_type != 'SSL') {  zen_redirect(zen_href_link(FILENAME_CONTACT_US, '', 'SSL'));}
// 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_address = $check_customer->fields['customers_email_address'];
  $name= $check_customer->fields['customers_firstname'] . ' ' . $check_customer->fields['customers_lastname'];
}

$send_to_array = array();
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);
// This should be the last line of the script:$zco_notifier->notify('NOTIFY_HEADER_END_CONTACT_US');

Thanks for any assistance.

24 Sep 2015, 11:54 AM
#2
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Contact Us Page Honey Pot Implementation On v1.39h

While I don't have the full solution immediately available other than just doing the upgrade and be done, no there is more than the header.php file for the contact_us page to use the honey pot that was first introduced in ZC 1.5.1 3+ years ago. The template file needs to first display a hidden field that will then be analyzed upon submission.if found to have caught something, then take the next action which could be a number of things, but has been to bypass the actual act of sending the emall but for the response to otherwise appear as if it was sent.

This doesn't require the exact code of any of the newer versions it just needs to be implemented in what exists. There are other changes to the system/operation making simple replacement of the old with the unmodified new non-functional.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...