|
|
Contact Us
FDG Web, LLCMailing Address Everett Office Phone: (425) 374-5383 |
is_valid ){
array_push( $errors, 'Invalid CAPTCHA.' );
}
if( empty( $errors ) ){
$email_form_keys = array("firstname" => array("First Name: ", "No First Name Submitted"),
"lastname" => array("Last Name: ", "No First Name Submitted"),
"url" => array("Web Site: ", "No URL Submitted"),
"email" => array("Email Address: ", "No Email Address Submitted"),
"phone" => array("Address: ", "No Address Submitted"),
"phonech" => array("Contact Via Phone: ", "No"),
"emailch" => array("Contact Via Email: ", "No"),
"textfield" => array("Message:\n\n", "No Comment Submitted"),
) ;
$check_keys = array("firstname", "lastname", "website", "email", "phone", "phonech", "emailch") ;
// do our check
$check = false ;
foreach ($_POST as $key => $val) {
if (in_array($key, $check_keys)) {
$check = (containsInjectionAttempt($val)) ? true : $check ;
}else{
$check = (containsHeaderCrap($val)) ? true : $check ;
}
}
// check our referrer -- if we're not from the same domain, then don't allow
$url = strtolower($_SERVER['HTTP_HOST']);
$url = ereg_replace("www.", "", $url);
$check = (!ereg($url,$_SERVER['HTTP_REFERER'])) ? true : $check ;
if ($check) {
// if we find some bad stuff in the email--
$junk = rawurlencode(serialize($_POST)) ;
$body = "IP Address: {$_SERVER['REMOTE_ADDR']}\nTime: " . date("r") . "\n" ;
$body .= "Referrer: " . (!empty($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : "No Referrer") . "\n" ;
$body .= "\n\n" ;
mail($bad_email_to, "email injection attack", $body, "From: $email_from\n") ;
}else{
// we format the email message body and send it to the recipient
$body = "" ;
foreach ($email_form_keys as $key => $val) {
$body .= (empty($_POST[$key])) ? $val[0] . $val[1] . "\n" : $val[0] . $_POST[$key] . "\n" ;
if ($key == "Zip") {
$phone = "Phone: " ;
if (empty($_POST['Phone1']) && empty($_POST['Phone2']) && empty($_POST['Phone3'])) {
$phone .= "No Phone Number Submitted\n" ;
}else{
$phone .= "({$_POST['Phone1']}){$_POST['Phone2']}-{$_POST['Phone3']}\n" ;
}
$body .= $phone ;
}
}
$html_message = str_replace("\n", "
", $body) ;
foreach ($email_to as $to) {
$boundary = md5(uniqid(time()));
$headers = 'From: ' . $email_from . "\n";
$headers .= 'To: ' . $to . "\n";
$headers .= 'Return-Path: ' . $email_from . "\n";
$headers .= 'MIME-Version: 1.0' ."\n";
$headers .= 'Content-Type: multipart/alternative; boundary="' . $boundary . '"' . "\n\n";
$headers .= $body . "\n";
$headers .= '--' . $boundary . "\n";
$headers .= 'Content-Type: text/plain; charset=ISO-8859-1' ."\n";
$headers .= 'Content-Transfer-Encoding: 8bit'. "\n\n";
$headers .= $body . "\n";
$headers .= '--' . $boundary . "\n";
$headers .= 'Content-Type: text/HTML; charset=ISO-8859-1' ."\n";
$headers .= 'Content-Transfer-Encoding: 8bit'. "\n\n";
$headers .= $html_message . "\n";
$headers .= '--' . $boundary . "--\n";
mail('', $email_subject,'', $headers);
}
$body = "IP Address: {$_SERVER['REMOTE_ADDR']}\nTime: " . date("r") . "\n" . $body ;
$html_message = str_replace("\n", "
", $body) ;
foreach ($extra_email_to as $to) {
$boundary = md5(uniqid(time()));
$headers = 'From: ' . $email_from . "\n";
$headers .= 'To: ' . $to . "\n";
$headers .= 'Return-Path: ' . $email_from . "\n";
$headers .= 'MIME-Version: 1.0' ."\n";
$headers .= 'Content-Type: multipart/alternative; boundary="' . $boundary . '"' . "\n\n";
$headers .= $body . "\n";
$headers .= '--' . $boundary . "\n";
$headers .= 'Content-Type: text/plain; charset=ISO-8859-1' ."\n";
$headers .= 'Content-Transfer-Encoding: 8bit'. "\n\n";
$headers .= $body . "\n";
$headers .= '--' . $boundary . "\n";
$headers .= 'Content-Type: text/HTML; charset=ISO-8859-1' ."\n";
$headers .= 'Content-Transfer-Encoding: 8bit'. "\n\n";
$headers .= $html_message . "\n";
$headers .= '--' . $boundary . "--\n";
mail('', $email_subject,'', $headers);
}
}
// redirect to thank you page
header( 'Location: ' . $redirect_page );
exit();
}
}
?>
|