../public_html/includes/modules/pages/request_demo/header_php.php
Code:
<?php
//
// +----------------------------------------------------------------------+
// |zen-cart Open Source E-commerce |
// +----------------------------------------------------------------------+
// | Copyright © 2003 The zen-cart developers |
// | |
// | http://www.zen-cart.com/index.php|
// | |
// | Portions Copyright © 2003 osCommerce |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the GPL license, |
// | that is bundled with this package in the file LICENSE, and is|
// | available through the world-wide-web at the following url: |
// | http://www.zen-cart.com/license/2_0.txt.|
// | If you did not receive a copy of the zen-cart license and are unable |
// | to obtain it through the world-wide-web, please send a note to |
// | license AT zen-cart DOT com so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// $Id: header_php.php,v 1.0 2015/05/13 00:00:00 Avenview Exp $
//
require(DIR_WS_MODULES . 'require_languages.php');
$error = false;
if (isset($_GET['action']) && ($_GET['action'] == 'send')) {
$rad_fullname = zen_db_prepare_input($_POST['rad_fullname']);
$rad_company = zen_db_prepare_input($_POST['rad_company']);
$rad_email = zen_db_prepare_input($_POST['rad_email']);
$rad_phone = zen_db_prepare_input($_POST['rad_phone']);
$rad_address1 = zen_db_prepare_input($_POST['rad_address1']);
$rad_address2 = zen_db_prepare_input($_POST['rad_address2']);
$rad_city = zen_db_prepare_input($_POST['rad_city']);
$rad_postal = zen_db_prepare_input($_POST['rad_postal']);
$rad_state = zen_db_prepare_input($_POST['rad_state']);
$rad_country = zen_db_prepare_input($_POST['rad_country']);
$rad_product = zen_db_prepare_input($_POST['rad_product']);
$commments = zen_db_prepare_input($_POST['comments']);
/* Added CAPTCHA Verification here */
if (ACCOUNT_VALIDATION == 'true' && REQUEST_DEMO_VALIDATION == 'true') {
$antirobotreg = zen_db_prepare_input($_POST['antirobotreg']);
$sql = "SELECT * FROM " . TABLE_ANTI_ROBOT_REGISTRATION . " WHERE session_id = '" . zen_session_id() . "' LIMIT 1";
if( !$result = $db->Execute($sql) ) {
$error = true;
$entry_antirobotreg_error = true;
$text_antirobotreg_error = ERROR_VALIDATION_1;
$messageStack->add('request_demo_validation', ERROR_VALIDATION_1);
} else {
$entry_antirobotreg_error = false;
$antirobotrow = $db->Execute($sql);
if (( strtolower($_POST['antirobotreg']) != $antirobotrow->fields['reg_key'] ) or ($antirobotrow->fields['reg_key'] =='')) {
$error = true;
$entry_antirobotreg_error = true;
$text_antirobotreg_error = ERROR_VALIDATION_2;
$messageStack->add('request_demo_validation', ERROR_VALIDATION_2);
} else {
$sql = "DELETE FROM " . TABLE_ANTI_ROBOT_REGISTRATION . " WHERE session_id = '" . zen_session_id() . "'";
if( !$result = $db->Execute($sql) )
{
$error = true;
$entry_antirobotreg_error = true;
$text_antirobotreg_error = ERROR_VALIDATION_3;
$messageStack->add('request_demo_validation', ERROR_VALIDATION_3);
} else {
$sql = "OPTIMIZE TABLE " . TABLE_ANTI_ROBOT_REGISTRATION . "";
if( !$result = $db->Execute($sql) )
{
$error = true;
$entry_antirobotreg_error = true;
$text_antirobotreg_error = ERROR_VALIDATION_4;
$messageStack->add('request_demo_validation', ERROR_VALIDATION_4);
} else {
$entry_antirobotreg_error = false;
}
}
}
}
if (strlen($antirobotreg) <> ENTRY_VALIDATION_LENGTH) {
$error = true;
$entry_antirobotreg_error = true;
} else {
$entry_antirobotreg_error = false;
}
}
/* End CAPTCHA Verification */
if (!zen_validate_email($rad_email)) {
$error = true;
}
if (!zen_not_null($rad_fullname)) {
$error = true;
}
if (!zen_not_null($rad_company)) {
$error = false;
}
if (!zen_not_null($rad_phone)) {
$error = true;
}
if (!zen_not_null($rad_address1)) {
$error = false;
}
if (!zen_not_null($rad_address2))
$error = false;
}
if (!isset($_POST['termsandconds']) || ($_POST['termsandconds'] != '1')) {
$error = true;
$messageStack->add_session('request_demo', 'You must accept our terms and conditions before demo request can be processed.', 'error');
}
if ($error == false) {
// grab some customer info if logged in
if($_SESSION['customer_id']) {
$check_customer = $db->Execute("select customers_id, customers_firstname, customers_lastname, customers_password, customers_email_address, customers_default_address_id from " . TABLE_CUSTOMERS . " where customers_id = '" . $customer_id . "'");
$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';
$customer_name='Not logged in';
}
//assemble the email contents:
$email_text = 'Request A Demo: ' . "\n" .
'------------------------------------------------------' . "\n" .
'Fullname:' . "\t" . $rad_fullname . "\n" .
'Company:' . "\t" . $rad_company . "\n" .
'Email:' . "\t" . $rad_email . "\n" .
'Phone:' . "\t" . $rad_phone . "\n" .
'Address:' . "\t" . $rad_address1 . "\n" .
'Address (optional):' . "\t" . $rad_address2 . "\n" .
'City:' . "\t" . $rad_city . "\n" .
'Postal:' . "\t" . $rad_postal . "\n" .
'State/Province:' . "\t" . $rad_state . "\n" .
'Country:' . "\t" . $rad_country . "\n" .
'Product:' . "\t" . $rad_product . "\n" .
'Commments:' . "\t" . $commments . "\n" ;
OFFICE_USE . "\t" . "\n" .
OFFICE_LOGIN_NAME . "\t" . $customer_name . "\n" .
OFFICE_LOGIN_EMAIL . "\t" . $customer_email . "\n" .
OFFICE_IP_ADDRESS . "\t" . $_SERVER['REMOTE_ADDR'] . "\n" .
OFFICE_HOST_ADDRESS . "\t" . gethostbyaddr($_SERVER['REMOTE_ADDR']) . "\n" .
OFFICE_DATE_TIME . "\t" . date("D M j Y G:i:s T") . "\n" .
'------------------------------------------------------' . "\n\n" .
$email_text = zen_output_string_protected($email_text);
$email_html = nl2br("\n" . $email_text);
//send the email
zen_mail(STORE_NAME, SEND_TO_ADDRESS, EMAIL_SUBJECT, $email_text, $rad_fullname , $rad_email, array('EMAIL_MESSAGE_HTML' => $email_html), 'request_demo');
zen_redirect(zen_href_link(FILENAME_REQUEST_DEMO, 'action=success'));
} //endif $error=false
// endif action
// default email and name if customer is logged in
if($_SESSION['customer_id']) {
$check_customer = $db->Execute("select customers_id, customers_firstname, customers_lastname, customers_password, customers_email_address, customers_default_address_id from " . TABLE_CUSTOMERS . " where customers_id = '" . $_SESSION['customer_id'] . "'");
$email= $check_customer->fields['customers_email_address'];
$firstname= $check_customer->fields['customers_firstname'];
$lastname= $check_customer->fields['customers_lastname'];
}
?>
Bookmarks