Please enter your
name.";
}
if (!preg_match("/^[0-9a-zA-ZÄÜÖ_.-]+@[0-9a-z.-]+\.[a-z]{2,6}$/", $email)) {
$fehler['email'] = "
Please enter a e-mail-address.";
}
if(!$subject) {
$fehler['subject'] = "
Please enter a subject.";
}
if(!$message) {
$fehler['message'] = "
Please enter a message.";
}
if($sicherheits_eingabe != $_SESSION['captcha_spam']){
unset($_SESSION['captcha_spam']);
$fehler['captcha'] = "
You entered a wrong code.";
}
if (!isset($fehler) || count($fehler) == 0) {
$error = false;
$errorMessage = '';
$uploadErrors = array();
$uploadedFiles = array();
$totalUploadSize = 0;
if ($cfg['UPLOAD_ACTIVE'] && in_array($_SERVER['REMOTE_ADDR'], $cfg['BLACKLIST_IP']) === true) {
$error = true;
$fehler['upload'] = "
You have no authorization to upload files.";
}
if (!$error) {
for ($i=0; $i < $cfg['NUM_ATTACHMENT_FIELDS']; $i++) {
if ($_FILES['f']['error'][$i] == UPLOAD_ERR_NO_FILE) {
continue;
}
$extension = explode('.', $_FILES['f']['name'][$i]);
$extension = strtolower($extension[count($extension)-1]);
$totalUploadSize += $_FILES['f']['size'][$i];
if ($_FILES['f']['error'][$i] != UPLOAD_ERR_OK) {
$uploadErrors[$j]['name'] = $_FILES['f']['name'][$i];
switch ($_FILES['f']['error'][$i]) {
case UPLOAD_ERR_INI_SIZE :
$uploadErrors[$j]['error'] = 'the file is too big (PHP-Ini directive).';
break;
case UPLOAD_ERR_FORM_SIZE :
$uploadErrors[$j]['error'] = 'the file is too big (MAX_FILE_SIZE in HTML-Formular).';
break;
case UPLOAD_ERR_PARTIAL :
if ($cfg['UPLOAD_ACTIVE']) {
$uploadErrors[$j]['error'] = 'the file has been uploaded partially.';
} else {
$uploadErrors[$j]['error'] = 'the file has been sent partially.';
}
break;
case UPLOAD_ERR_NO_TMP_DIR :
$uploadErrors[$j]['error'] = 'No temporarily folder has been found.';
break;
case UPLOAD_ERR_CANT_WRITE :
$uploadErrors[$j]['error'] = 'error during saving the file.';
break;
case UPLOAD_ERR_EXTENSION :
$uploadErrors[$j]['error'] = 'unknown error due to an extension.';
break;
default :
if ($cfg['UPLOAD_ACTIVE']) {
$uploadErrors[$j]['error'] = 'unknown error on uploading.';
} else {
$uploadErrors[$j]['error'] = 'unknown error on sending the email attachments.';
}
}
$j++;
$error = true;
}
else if ($totalUploadSize > $cfg['MAX_ATTACHMENT_SIZE']*1024) {
$uploadErrors[$j]['name'] = $_FILES['f']['name'][$i];
$uploadErrors[$j]['error'] = 'maximum upload reached ('.$cfg['MAX_ATTACHMENT_SIZE'].' KB).';
$j++;
$error = true;
}
else if ($_FILES['f']['size'][$i] > $cfg['MAX_FILE_SIZE']*1024) {
$uploadErrors[$j]['name'] = $_FILES['f']['name'][$i];
$uploadErrors[$j]['error'] = 'The file is too big (max. '.$cfg['MAX_FILE_SIZE'].' KB).';
$j++;
$error = true;
}
else if (!empty($cfg['BLACKLIST_EXT']) && strpos($cfg['BLACKLIST_EXT'], $extension) !== false) {
$uploadErrors[$j]['name'] = $_FILES['f']['name'][$i];
$uploadErrors[$j]['error'] = 'the file extension is not permitted.';
$j++;
$error = true;
}
else if (preg_match("=^[\\:*?<>|/]+$=", $_FILES['f']['name'][$i])) {
$uploadErrors[$j]['name'] = $_FILES['f']['name'][$i];
$uploadErrors[$j]['error'] = 'invalid symbols in the file name (\/:*?<>|).';
$j++;
$error = true;
}
else if ($cfg['UPLOAD_ACTIVE'] && file_exists($cfg['UPLOAD_FOLDER'].'/'.$_FILES['f']['name'][$i])) {
$uploadErrors[$j]['name'] = $_FILES['f']['name'][$i];
$uploadErrors[$j]['error'] = 'the file already exist.';
$j++;
$error = true;
}
else {
if ($cfg['UPLOAD_ACTIVE']) {
move_uploaded_file($_FILES['f']['tmp_name'][$i], $cfg['UPLOAD_FOLDER'].'/'.$_FILES['f']['name'][$i]);
}
$uploadedFiles[$_FILES['f']['tmp_name'][$i]] = $_FILES['f']['name'][$i];
}
}
}
if ($error) {
$errorMessage = 'following errors occured when sending the contact formular:'."\n";
if (count($uploadErrors) > 0) {
foreach ($uploadErrors as $err) {
$tmp .= '
'.$err['name']."\n- ".$err['error']."
\n";
}
$tmp = "
\n".$tmp;
}
$errorMessage .= $tmp.'';
$fehler['upload'] = $errorMessage;
}
}
// if no error, an email will be sent
if (!isset($fehler))
{
// ------------------------------------------------------------
// -------------------- send mail to admin --------------------
// ------------------------------------------------------------
// ---- create mail-message for admin
$mailcontent = "The following has been sent by the contact form:\n" . "-------------------------------------------------------------------------\n\n";
$mailcontent .= "Name: " . $name . "\n";
$mailcontent .= "E-Mail: " . $email . "\n\n";
$mailcontent .= "Phone Number: " . $phonenumber . "\n";
$mailcontent .= "Place: " . $place . "\n";
$mailcontent .= "\nSubject: " . $subject . "\n";
$mailcontent .= "Message:\n" . $_POST['message'] = preg_replace("/\r\r|\r\n|\n\r|\n\n/","\n",$_POST['message']) . "\n\n";
if(count($uploadedFiles) > 0){
if($cfg['UPLOAD_ACTIVE']){
$mailcontent .= 'The following files have been uploaded:'."\n";
foreach ($uploadedFiles as $filename) {
$mailcontent .= ' - '.$cfg['DOWNLOAD_URL'].'/'.$cfg['UPLOAD_FOLDER'].'/'.$filename."\n";
}
} else {
$mailcontent .= 'The following files have been attached:'."\n";
foreach ($uploadedFiles as $filename) {
$mailcontent .= ' - '.$filename."\n";
}
}
}
$mailcontent .= "\n\nIP address: " . $ip . "\n";
$mailcontent = strip_tags ($mailcontent);
// ---- get attachments for admin
$attachments = array();
if(!$cfg['UPLOAD_ACTIVE'] && count($uploadedFiles) > 0){
foreach($uploadedFiles as $tempFilename => $filename) {
$attachments[$filename] = file_get_contents($tempFilename);
}
}
// ---- send mail to admin
$success = sendMyMail($email, $name, $empfaenger, $subject, $mailcontent, $attachments);
// ------------------------------------------------------------
// ------------------- send mail to customer ------------------
// ------------------------------------------------------------
if($success){
// ---- create mail-message for customer
$mailcontent = "Thank you very much for your e-mail. We will reply as fast as we can.\n\n";
$mailcontent .= "Summary: \n" .
"-------------------------------------------------------------------------\n\n";
$mailcontent .= "Name: " . $name . "\n";
$mailcontent .= "E-Mail: " . $email . "\n\n";
$mailcontent .= "Phone Number: " . $phonenumber . "\n";
$mailcontent .= "Place: " . $place . "\n";
$mailcontent .= "\nSubject: " . $subject . "\n";
$mailcontent .= "Message:\n" . str_replace("\r", "", $message) . "\n\n";
if(count($uploadedFiles) > 0){
$mailcontent .= 'You have assigned the following files:'."\n";
foreach($uploadedFiles as $file){
$mailcontent .= ' - '.$file."\n";
}
}
$mailcontent = strip_tags ($mailcontent);
// ---- send mail to customer
$success = sendMyMail($empfaenger, $ihrname, $email, "Your request", $mailcontent);
echo "
";
exit;
}
}
}
// clean post
foreach($_POST as $key => $value){
$_POST[$key] = htmlentities($value, ENT_QUOTES, "UTF-8");
}
?>
".$eol;
$header .= "Reply-To: <".$fromMail.">".$eol;
$header .= "MIME-Version: 1.0".$eol;
if(is_array($attachments) && 0
$filecontent){
$filecontent = chunk_split(base64_encode($filecontent));
$message .= "--".$boundary.$eol;
$message .= "Content-Type: application/octet-stream; name=\"".$filename."\"".$eol;
$message .= "Content-Transfer-Encoding: base64".$eol;
$message .= "Content-Disposition: attachment; filename=\"".$filename."\"".$eol.$eol;
$message .= $filecontent.$eol;
}
$message .= "--".$boundary."--";
}
// content without attachments
else{
$message = $content;
}
// subject
$subject = "=?UTF-8?B?".base64_encode($subject)."?=";
// send mail
return mail($toMail, $subject, $message, $header);
}
?>
kontaktformular.com