0) {
$search = array('\\', '[', ']', '-', '$', '.', '*', '(', ')', '?', '+', '^', '{', '}', '|');
$replace = array('\\\\', '\[', '\]', '\-', '\$', '\.', '\*', '\(', '\)', '\?', '\+', '\^', '\{', '\}', '\|');
$regExp .= str_replace($search, $replace, $limitExtraChars);
}
if ( (strlen($regExp) > 0) && (strlen($value) > 0) ){
if (preg_match('/[^' . $regExp . ']/', $value)) {
return false;
}
}
if ( (strlen($value) == 0) && ($optional === kOptional) ) {
return true;
} elseif ( (strlen($value) >= $low) && ($mode == kStringRangeFrom) ) {
return true;
} elseif ( (strlen($value) <= $high) && ($mode == kStringRangeTo) ) {
return true;
} elseif ( (strlen($value) >= $low) && (strlen($value) <= $high) && ($mode == kStringRangeBetween) ) {
return true;
} else {
return false;
}
}
function CheckNumeric($value, $low, $high, $mode, $optional) {
if ( (strlen($value) == 0) && ($optional === kOptional) ) {
return true;
} elseif (!is_numeric($value)) {
return false;
} elseif ( ($value >= $low) && ($mode == kNumberRangeFrom) ) {
return true;
} elseif ( ($value <= $high) && ($mode == kNumberRangeTo) ) {
return true;
} elseif ( ($value >= $low) && ($value <= $high) && ($mode == kNumberRangeBetween) ) {
return true;
} else {
return false;
}
}
function CheckEmail($email, $optional) {
if ( (strlen($email) == 0) && ($optional === kOptional) ) {
return true;
} elseif ( eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email) ) {
return true;
} else {
return false;
}
}
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$clientIP = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$clientIP = $_SERVER['REMOTE_ADDR'];
}
$FTGname = DoStripSlashes( $_REQUEST['name'] );
$FTGemail = DoStripSlashes( $_REQUEST['email'] );
$FTGcompany = DoStripSlashes( $_REQUEST['company'] );
$FTGaddress = DoStripSlashes( $_REQUEST['address'] );
$FTGaddress1 = DoStripSlashes( $_REQUEST['address1'] );
$FTGcity = DoStripSlashes( $_REQUEST['city'] );
$FTGstate = DoStripSlashes( $_REQUEST['state'] );
$FTGzip = DoStripSlashes( $_REQUEST['zip'] );
$FTGphone = DoStripSlashes( $_REQUEST['phone'] );
$FTGcomment = DoStripSlashes( $_REQUEST['comment'] );
$FTGsubmit = DoStripSlashes( $_REQUEST['submit'] );
# Fields Validations
$validationFailed = false;
if (!CheckString($FTGname, 1, 0, kStringRangeFrom, kNo, kNo, kNo, '', kMandatory)) {
$FTGErrorMessage['name'] = 'Please enter your name';
$validationFailed = true;
}
if (!CheckEmail($FTGemail, kMandatory)) {
$FTGErrorMessage['email'] = 'Please enter a correct email address';
$validationFailed = true;
}
if (!CheckNumeric($FTGzip, 500, 99499, kNumberRangeBetween, kMandatory)) {
$FTGErrorMessage['zip'] = 'Please enter a valid 5 digit zip code';
$validationFailed = true;
}
# Embed error page and dump it to the browser
if ($validationFailed === true) {
$fileErrorPage = 'error.html';
if (file_exists($fileErrorPage) === false) {
echo 'ErrorThe error page: ' . $fileErrorPage. ' cannot be found on the server.';
exit;
}
$errorPage = ProcessPHPFile($fileErrorPage);
$errorList = implode("
\n", $FTGErrorMessage);
$errorPage = str_replace('', $errorList, $errorPage);
$errorPage = str_replace('', $FTGname, $errorPage);
$errorPage = str_replace('', $FTGemail, $errorPage);
$errorPage = str_replace('', $FTGcompany, $errorPage);
$errorPage = str_replace('', $FTGaddress, $errorPage);
$errorPage = str_replace('', $FTGaddress1, $errorPage);
$errorPage = str_replace('', $FTGcity, $errorPage);
$errorPage = str_replace('', $FTGstate, $errorPage);
$errorPage = str_replace('', $FTGzip, $errorPage);
$errorPage = str_replace('', $FTGphone, $errorPage);
$errorPage = str_replace('', $FTGcomment, $errorPage);
$errorPage = str_replace('', $FTGsubmit, $errorPage);
$errorPage = str_replace('', $FTGErrorMessage['name'], $errorPage);
$errorPage = str_replace('', $FTGErrorMessage['email'], $errorPage);
$errorPage = str_replace('', $FTGErrorMessage['zip'], $errorPage);
echo $errorPage;
exit;
}
# Email to Form Owner
$emailSubject = FilterCChars("Request for resume and headshot");
$emailBody = "name : $FTGname\n"
. "email : $FTGemail\n"
. "company : $FTGcompany\n"
. "address : $FTGaddress\n"
. "address1 : $FTGaddress1\n"
. "city : $FTGcity\n"
. "state : $FTGstate\n"
. "zip : $FTGzip\n"
. "phone : $FTGphone\n"
. "comment : $FTGcomment\n"
. "submit : $FTGsubmit\n"
. "";
$emailTo = 'Steve ,Chuck ';
$emailFrom = FilterCChars("$FTGemail");
$emailHeader = "From: $emailFrom\n"
. "MIME-Version: 1.0\n"
. "Content-type: text/plain; charset=\"ISO-8859-1\"\n"
. "Content-transfer-encoding: 7bit\n";
mail($emailTo, $emailSubject, $emailBody, $emailHeader);
# Redirect user to success page
header("Location: success.html");
exit;
?>