assign('imagehash', $imagehash); unset($imagehash); } function clean_input($input){ $input = htmlspecialchars(trim($input)); if (get_magic_quotes_gpc()) { $input = stripslashes($input); } $tests = array("/%0a/", "/%0d/", "/bcc\:/i", "/Content\-Type\:/i", "/Mime\-Version\:/i", "/cc\:/i", "/from\:/i", "/to\:/i", "/Content\-Transfer\-Encoding\:/i"); $input = preg_replace($tests, "", $input); return $input; } function error($err) { global $tpl, $data, $language; $path = array(); $path[] = array('ID' => '0', 'TITLE' => _L(SITE_NAME), 'TITLE_URL' => DOC_ROOT, 'DESCRIPTION' => SITE_DESC); $path[] = array('ID' => '0', 'TITLE' => _L($language['L_TITLE']), 'TITLE_URL' => '', 'DESCRIPTION' => _L($language['L_DESCRIPTION'])); $tpl->assign($data); $tpl->assign($language); $tpl->assign('ERROR', $err); $tpl->assign('path', $path); echo $tpl->fetch('quote.tpl'); unset($language); unset($data); unset($link); unset($path); unset($_POST, $_GET, $_REQUEST); exit; } if (empty($_POST['submit'])) { SmartyValidate :: connect($tpl); SmartyValidate :: register_form('contact_listing', true); SmartyValidate :: register_criteria('isNotEqual', 'validate_not_equal', 'contact_listing'); SmartyValidate :: register_validator('v_name', 'NAME', 'notEmpty', false, false, false, 'contact_listing'); SmartyValidate :: register_validator('v_email', 'EMAIL', 'isEmail', false, false, false, 'contact_listing'); SmartyValidate :: register_validator('v_semail', 'SEMAIL', 'isEmail', false, false, false, 'contact_listing'); SmartyValidate :: register_validator('v_home_phone', 'HOME_PHONE', 'notEmpty', false, false, false, 'contact_listing'); SmartyValidate :: register_validator('v_best_time', 'BEST_TIME', 'notEmpty', false, false, false, 'contact_listing'); SmartyValidate :: register_validator('v_city', 'CITY', 'notEmpty', false, false, false, 'contact_listing'); SmartyValidate :: register_validator('v_state', 'STATE', 'notEmpty', false, false, false, 'contact_listing'); SmartyValidate :: register_validator('v_zip', 'ZIP', 'notEmpty', false, false, false, 'contact_listing'); SmartyValidate :: register_validator('v_footage', 'FOOTAGE', 'notEmpty', false, false, false, 'contact_listing'); SmartyValidate :: register_validator('v_age', 'AGE', 'notEmpty', false, false, false, 'contact_listing'); SmartyValidate :: register_validator('v_property_type', 'PROPERTY_TYPE', 'notEmpty', false, false, false, 'contact_listing'); SmartyValidate :: register_validator('v_foundation_type', 'FOUNDATION_TYPE', 'notEmpty', false, false, false, 'contact_listing'); SmartyValidate :: register_validator('v_num_bedrooms', 'NUM_BEDROOMS', 'notEmpty', false, false, false, 'contact_listing'); SmartyValidate :: register_validator('v_num_bathrooms', 'NUM_BATHROOMS', 'notEmpty', false, false, false, 'contact_listing'); if (VISUAL_CONFIRM == 1) { SmartyValidate :: register_criteria('isCaptchaValid', 'validate_captcha', 'contact_listing'); SmartyValidate :: register_validator('v_CAPTCHA', 'CAPTCHA:IMAGEHASH', 'isCaptchaValid', false, false, null, 'contact_listing'); } } else { SmartyValidate :: connect($tpl); foreach ($_POST as $key => $val) { $data[$key] = clean_input($val); } if (VISUAL_CONFIRM == 1) { if (! empty ($_POST['CAPTCHA'])) { $data = array_merge($data, array ('CAPTCHA' => $_POST['CAPTCHA'], 'IMAGEHASH' => $_POST['IMAGEHASH'])); } } if (SmartyValidate :: is_valid($data, 'contact_listing')) { require_once 'libs/phpmailer/class.phpmailer.php'; $mail = new PHPMailer(); $mail->PluginDir = 'libs/phpmailer/'; $mail->Mailer = 'mail'; $mail->From = $data['EMAIL']; $mail->FromName = $data['NAME']; unset($data['id'], $data['submit']); if (isset ($data['CAPTCHA'])) { unset($data['CAPTCHA']); } if (isset ($data['IMAGEHASH'])) { unset($data['IMAGEHASH']); } $body = "Hi [Your Home Inspection Company Name],\n\nThe following lead was generated by the American Home Inspector Directory. Please respond to the client as soon as possible to grab this lead. Research shows that most clients choose their home inspectors within 24 hours of their initial request. If you are unable to perform this inspection or the client's property is not in your area, please forward this lead to " . $data['EMAIL'] . "\n====================================\n\n"; foreach ($data as $key => $val) { $body .= "$key: $val\n"; } $body .= "\n----------\n" . SITE_NAME . "\n" . SITE_URL . "\n"; $mail->From = $data['EMAIL']; $mail->FromName = $data['NAME']; $mail->Subject = "Request Quote"; $mail->Body = $body; $mail->AddAddress($data['SEMAIL'], $data['SNAME']); if (! $mail->Send()) { $tpl->assign('error', true); } else { $tpl->assign('SUCCESS', true); } $mail->ClearAddresses(); unset($_POST, $_GET, $_REQUEST); } } if (VISUAL_CONFIRM == 1) { $tpl->assign('captcha_length', CAPTCHA_PHRASE_LENGTH); } $path = array(); $path[] = array('ID' => '0', 'TITLE' => _L(SITE_NAME), 'TITLE_URL' => DOC_ROOT, 'DESCRIPTION' => SITE_DESC); $path[] = array('ID' => '0', 'TITLE' => 'Sample Request Quote', 'TITLE_URL' => '', 'DESCRIPTION' => 'Sample Request Quote'); $tpl->assign($data); $tpl->assign('ID', $id); $tpl->assign('TITLE', $title); $tpl->assign('UPLOADS', $uploads); $tpl->assign($language); $tpl->assign('path', $path); echo $tpl->fetch('sample-email-lead.tpl'); unset($language); unset($data); unset($path); ?>