include "web2mail_config.php";
$path = __FILE__;
$path = preg_replace( "'\\\web2mail\.php'", "", $path);
$path = preg_replace( "'/web2mail\.php'", "", $path);
$send = false;
if(isset($_POST['submit'])){
$date = date("l d F Y");
$time = date("g:i:s a");
$ermsg = "";
$send = true;
$ip = $_SERVER['REMOTE_ADDR'];
$name = cleanUp($_POST['nome']);
$email = cleanUp($_POST['email']);
$message = $_POST['message'];
$cognome = $_POST['cognome'];
$via = $_POST['Via'];
$citt = $_POST['citt'];
$cap = $_POST['CAP'];
$prov = $_POST['PR'];
$tel = $_POST['tel'];
$copi = $_POST['Italiano'];
$copin = $_POST['Inglese'];
$subject = cleanUp($_POST['subject']);
$emailvalid = is_valid_email($email);
if (!isset($name) || $name == ""){
$emsg = "
Inserisci il tuo nome"; $send = false;
}
if (!isset($cognome) || $cognome == ""){
$emsg = "Inserisci il tuo cognome"; $send = false;
}
if (!isset($Via) || $Via == ""){
$emsg = "Inserisci la tua via"; $send = false;
}
if (!isset($citt) || $citt == ""){
$emsg = "Inserisci il nome della cittā"; $send = false;
}
if (!isset($cap) || $cap == ""){
$emsg = "Inserisci il tuo nome"; $send = false;
}
if (!isset($email) || $email == "" || $emailvalid == 1){
$emsg .= "Indirizzo email mancante o scorretto"; $send = false;
}
if (!isset($prov) || $prov == ""){
$emsg = "Inserisci la tua provincia"; $send = false;
}
if (!isset($tel) || $tel == ""){
$emsg = "Inserisci il tuo telefono"; $send = false;
}
if (!isset($subject) || $subject == ""){
$emsg .= "Bisogna indicare un oggetto"; $send = false;
}
if (!isset($message) || $message == ""){
$emsg .= "Il messaggio č vuoto"; $send = false;
}
if($send){
$sent = false;
include("mail_functions.php");
$message = strip_tags($message);
$message = stripslashes($message);
$subject = stripslashes($subject);
if($multipart_emails == "yes"){
if(sendHTMLEmail($name, $email, $cognome, $via, $citt, $cap, $prov, $tel, $copi, $copin, $message, $subject, $recipient, $ip, $date, $time)){
$sent = true;
}
}
else{
$recipient = "$yourname <$admin_email>";
$headers = "DA: $name <$email>\r\nReply-To: $email\r\n";
$msg = "INVIATO: $date - $time\nFrom: $name - $email\n\n\n$message\n\nIP: $ip\n\n\n";
if(mail ($recipient, $subject, $msg, $headers)){
$sent = true;
}
}
if($sent){
if($auto_responder == "yes"){
if($multipart_emails == "yes"){
sendHTMLEmailAuto($name, $email, $subject);
}
else{
sendTextEmailAuto($name, $email, $subject);
}
}
if($default_thank_msg == "yes"){
include($path."/thankyou.php");
}
else{
header("Location: $thankyou_message_url");
}
}
else{
include($path."/thankyou.php");
}
}
}
if(!$send){
if(strlen($emsg) > 0 && $error_messages == "yes"){
echo "Ci sono i seguenti errori:
$emsg
";
}
include($path."/form.php");
}
function cleanUp($field)
{
//Remove line feeds
$ret = str_replace("\r", "", $field);
$ret = str_replace("\n", "", $ret);
// Remove injected headers
$find = array("/bcc\:/i",
"/Content\-Type\:/i",
"/Mime\-Type\:/i",
"/cc\:/i",
"/to\:/i");
$ret = preg_replace($find, "", $ret);
return $ret;
}
function is_valid_email($sender_mail) {
if(ereg("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $sender_mail)) {
return 0;
}
else{
return 1;
}
}
?>