if($_POST["step"] == "send"){
$error_message = "";
//check for required fields
foreach($_POST as $key => $value){
for($i = 0; $i < count($TextFieldsArray); $i++){
$text_field = explode("|", $TextFieldsArray[$i]);
$text_field_name = $text_field[0];
$text_field_label = $text_field[1];
$text_field_required = $text_field[2];
if($text_field_name == $key && $text_field_required == 1 && $value == ""){
$error_message .= "Errore: ".$text_field_label." è un campo obbligatorio.
";
}
}
}
//check for valid email format
function valid_email($email){
$regexp = "^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,6})$";
// Get the hostname.
$fromHost = explode("@", $email);
// Test for both valid syntax and a valid server.
if ( !eregi($regexp, $email) || !checkdnsrr($fromHost[1], "MX") ) {
return false;
}else{
return true;
}
}
$txt_email = stripslashes(trim($_POST['txt_email']));
if(!valid_email($txt_email)){ $error_message .= "Errore: Indirizzo email non valido.
"; }
//check for blocked ips
$sonicx = strstr($BlockedIP, getenv('REMOTE_ADDR'));
if($sonicx == TRUE){
$send_email = "no";
$error_message .= "Sorry but we could not process your form at this time.
";
$error_type = "fatal";
}
$sonicxemail = @strstr($BlockedEmail, $_POST["txt_email"]);
if($sonicxemail == TRUE){
$send_email = "no";
$error_message .= "Sorry but we could not process your form at this time.
";
$error_type = "fatal";
}
//process captcha
function captcha( $number ) {
$key = substr($_SESSION['key8'],0,5);
if( $number != $key || $number == ""){
return false;
} else {
return true;
}
}
$number = $_POST['number'];
if(!captcha( $number )){
$error_message .= "Errore: Il codice di sicurezza non corrisponde!";
}
//formup and send the email
if (preg_match ("/".str_replace("www.", "", $_SERVER["SERVER_NAME"])."/i", $_SERVER["HTTP_REFERER"])
&& ($error_message == "")){
//start formatting and building the message
// handle post strings
reset($_POST);
while(list($key, $val) = each($_POST)) {
$GLOBALS[$key] = $val;
if (is_array($val)) {
$sonicMessage .= "$key: ";
foreach ($val as $vala) {
$vala =stripslashes($vala);
$vala = htmlspecialchars($vala);
$sonicMessage .= "$vala, ";
}
$sonicMessage .= "
\r\n";
}else{
$val = stripslashes($val);
if (($key == "Submit") || ($key == "submit")){
//skip it and move on
}else{
if ($val == ""){
$sonicMessage .= "$key: -
\r\n";
}else{
$sonicMessage .= "$key: $val
\r\n";
}
}
}
} // end while
//determine the mail routing
foreach($SubjectArray as $key=>$val){
if($_POST["subject"] == $key){
$MailToAddress = $val;
$MailToName = $key;
} //end if
} //end foreach
$sonicMessage .= "
\n Sender IP: ".getenv('REMOTE_ADDR')."