<?php
function noNewLine( $string ) // reinigt email header
{
$string = preg_replace( "/[^a-z0-9 !?:;,.\/_\-=+@#$&\*\(\)]/im", "", $string );
$string = preg_replace( "/(content-type:|bcc:|cc:|to:|from:)/im", "", $string );
$string = preg_replace('/\x0A|\x0D\x0A|\x0D/s', '', $string); //entfernt Newliner \n
return $string;
}
require_once "config/confic_mailmanager.php"; // enthält emailadressen der möglichen empfänger
$redirect = $check_redirect[$_POST["redirect"]]; //im Formular gesetzes ziel wird umgewandelt
// Robot Check
// - Prüft formkey
// - Zeitsperre
// - Falschausfüllung
include_once 'form_key.inc.php'; // benutzt die funcion validFormKey()
if(!empty($_POST["url"]) OR validFormKey($_POST["link"]) == "invalid" ){ // input type="hidden" name="url" value="" muss leer sein -- input type="hidden" name="link" value="$CODE" enthält Code aus scripts/form_key.inc.php
$msg = "err1";
unset($_POST);
}elseif(validFormKey($_POST["link"]) == "valid" && empty($_POST["url"])) {
// Prüft email adresse
$pruefung = array(
'email' => '/^[\w.+-]{2,64}\@[\w.-]{2,255}\.[a-z]{2,6}$/',
/*'subject' => '/^[[:print:]]{3,}$/',*/
);
if(preg_match($pruefung["email"], $_POST["email"])){
$email = noNewLine( $_POST["email"] );
}else{
unset($_POST);
$msg = "err2";
}
}else{
$msg = "err";
}
$name = noNewLine( $_POST["name"] );
$name_fam = noNewLine( $_POST["name_fam"] );
$subject = noNewLine( $_POST["subject"] );
$text = $_POST['text'];
$info = $_POST["info"]; // Felder mit dem Name="Info", um einzelne Werte zu übermitteln
$recipient = $_POST["recipient"]; //noNewLine( $_POST["recipient"]); // aus: input type="hidden" name="recipient" => kontrolle in confic_mailmanager.php
// $_POST["recipient"];
if(!empty($info)){
$info = "INFO: $info";
}else{
$info = "";
}
if(!empty($text)){
$text = "Text:\n
$text";
}else{
$text = "";
}
$recipient = $check_to["$recipient"]; // im array $check_to in confic/confic_mailmanager.php Wert hohlen
$to = "\"feedback form\" <". $recipient .">";
$from = "\"$name\" <$email>";
$reply = "\"$name\" <$email>";
$subject = $subject;
$message = "
Von: $name $name_fam
Email: $email \n
Subject: $subject
$text
$info\n
";
$headers .= "From: $from\r\n";
$headers .= "Reply-To: $reply\r\n";
if(empty($msg)){ // msg enthält die Fehlermeldungen
mail($to, $subject, $message, $headers);
$msg = "ok";
}
header("Location: $redirect&msg=$msg");
exit;
?>