Initial commit: OMSORG website + Mitarbeiter-App
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+154
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
// OMSORG Formularversand
|
||||
// Voraussetzung: PHP mit aktivierter mail()-Funktion auf dem Webhosting.
|
||||
|
||||
mb_internal_encoding('UTF-8');
|
||||
$recipient = 'info@omsorg-pflegedienste.de';
|
||||
$maxFileSize = 10 * 1024 * 1024;
|
||||
$allowedExtensions = ['pdf','doc','docx','jpg','jpeg','png'];
|
||||
|
||||
function clean_text($value) {
|
||||
$value = is_array($value) ? '' : (string)$value;
|
||||
$value = str_replace(["\r", "\0"], '', $value);
|
||||
return trim($value);
|
||||
}
|
||||
|
||||
function h($value) {
|
||||
return htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
|
||||
function field($name) {
|
||||
return clean_text($_POST[$name] ?? '');
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
header('Location: index.html');
|
||||
exit;
|
||||
}
|
||||
|
||||
$formType = field('form_type');
|
||||
$name = field('name');
|
||||
$telefon = field('telefon');
|
||||
$email = field('email');
|
||||
$nachricht = field('nachricht');
|
||||
|
||||
if ($name === '' || $telefon === '') {
|
||||
http_response_code(400);
|
||||
$statusTitle = 'Bitte Pflichtfelder ausfüllen';
|
||||
$statusText = 'Name und Telefon sind erforderlich.';
|
||||
include __DIR__ . '/send-status-template.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
$lines = [];
|
||||
$subject = '';
|
||||
|
||||
if ($formType === 'bewerbung') {
|
||||
$subject = 'Neue Bewerbung über omsorg-pflegedienste.de';
|
||||
$lines[] = 'Neue Bewerbung über die Website';
|
||||
$lines[] = '';
|
||||
$lines[] = 'Name: ' . $name;
|
||||
$lines[] = 'Telefon: ' . $telefon;
|
||||
$lines[] = 'E-Mail: ' . ($email ?: 'nicht angegeben');
|
||||
$lines[] = '';
|
||||
$lines[] = 'Nachricht:';
|
||||
$lines[] = $nachricht ?: 'keine Nachricht angegeben';
|
||||
} elseif ($formType === 'einrichtung') {
|
||||
$einrichtung = field('einrichtung');
|
||||
$qualifikation = field('qualifikation');
|
||||
$zeitraumVon = field('zeitraum_von');
|
||||
$zeitraumBis = field('zeitraum_bis');
|
||||
|
||||
if ($einrichtung === '' || $qualifikation === '' || $zeitraumVon === '' || $zeitraumBis === '') {
|
||||
http_response_code(400);
|
||||
$statusTitle = 'Bitte Pflichtfelder ausfüllen';
|
||||
$statusText = 'Einrichtung, Qualifikation und Zeitraum sind erforderlich.';
|
||||
include __DIR__ . '/send-status-template.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
$subject = 'Neue Personalanfrage über omsorg-pflegedienste.de';
|
||||
$lines[] = 'Neue Personalanfrage über die Website';
|
||||
$lines[] = '';
|
||||
$lines[] = 'Einrichtung / Unternehmen: ' . $einrichtung;
|
||||
$lines[] = 'Ansprechpartner: ' . $name;
|
||||
$lines[] = 'Telefon: ' . $telefon;
|
||||
$lines[] = 'E-Mail: ' . ($email ?: 'nicht angegeben');
|
||||
$lines[] = 'Benötigte Unterstützung: ' . $qualifikation;
|
||||
$lines[] = 'Zeitraum: ' . $zeitraumVon . ' bis ' . $zeitraumBis;
|
||||
$lines[] = '';
|
||||
$lines[] = 'Weitere Angaben:';
|
||||
$lines[] = $nachricht ?: 'keine weiteren Angaben';
|
||||
} else {
|
||||
http_response_code(400);
|
||||
$statusTitle = 'Formular nicht erkannt';
|
||||
$statusText = 'Bitte versuchen Sie es erneut.';
|
||||
include __DIR__ . '/send-status-template.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
$bodyText = implode("\n", $lines) . "\n\n---\nGesendet über omsorg-pflegedienste.de";
|
||||
$from = 'no-reply@omsorg-pflegedienste.de';
|
||||
$replyTo = filter_var($email, FILTER_VALIDATE_EMAIL) ? $email : $recipient;
|
||||
|
||||
$headers = [];
|
||||
$headers[] = 'From: OMSORG Website <' . $from . '>';
|
||||
$headers[] = 'Reply-To: ' . $replyTo;
|
||||
$headers[] = 'MIME-Version: 1.0';
|
||||
|
||||
$hasAttachment = isset($_FILES['anlage']) && $_FILES['anlage']['error'] !== UPLOAD_ERR_NO_FILE;
|
||||
|
||||
if ($hasAttachment && $formType === 'bewerbung') {
|
||||
if ($_FILES['anlage']['error'] !== UPLOAD_ERR_OK || $_FILES['anlage']['size'] > $maxFileSize) {
|
||||
http_response_code(400);
|
||||
$statusTitle = 'Datei konnte nicht gesendet werden';
|
||||
$statusText = 'Bitte laden Sie eine Datei bis maximal 10 MB hoch.';
|
||||
include __DIR__ . '/send-status-template.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
$originalName = basename($_FILES['anlage']['name']);
|
||||
$extension = strtolower(pathinfo($originalName, PATHINFO_EXTENSION));
|
||||
if (!in_array($extension, $allowedExtensions, true)) {
|
||||
http_response_code(400);
|
||||
$statusTitle = 'Dateiformat nicht erlaubt';
|
||||
$statusText = 'Erlaubt sind PDF, DOC, DOCX, JPG und PNG.';
|
||||
include __DIR__ . '/send-status-template.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
$boundary = 'omsorg_' . md5(uniqid((string)mt_rand(), true));
|
||||
$headers[] = 'Content-Type: multipart/mixed; boundary="' . $boundary . '"';
|
||||
|
||||
$message = '--' . $boundary . "\r\n";
|
||||
$message .= "Content-Type: text/plain; charset=UTF-8\r\n";
|
||||
$message .= "Content-Transfer-Encoding: 8bit\r\n\r\n";
|
||||
$message .= $bodyText . "\r\n\r\n";
|
||||
|
||||
$fileContent = chunk_split(base64_encode(file_get_contents($_FILES['anlage']['tmp_name'])));
|
||||
$safeFileName = preg_replace('/[^A-Za-z0-9._-]/', '_', $originalName);
|
||||
$finfo = new finfo(FILEINFO_MIME_TYPE);
|
||||
$mimeType = $finfo->file($_FILES['anlage']['tmp_name']) ?: 'application/octet-stream';
|
||||
|
||||
$message .= '--' . $boundary . "\r\n";
|
||||
$message .= 'Content-Type: ' . $mimeType . '; name="' . $safeFileName . '"' . "\r\n";
|
||||
$message .= "Content-Transfer-Encoding: base64\r\n";
|
||||
$message .= 'Content-Disposition: attachment; filename="' . $safeFileName . '"' . "\r\n\r\n";
|
||||
$message .= $fileContent . "\r\n";
|
||||
$message .= '--' . $boundary . '--';
|
||||
} else {
|
||||
$headers[] = 'Content-Type: text/plain; charset=UTF-8';
|
||||
$message = $bodyText;
|
||||
}
|
||||
|
||||
$sent = mail($recipient, '=?UTF-8?B?' . base64_encode($subject) . '?=', $message, implode("\r\n", $headers));
|
||||
|
||||
if ($sent) {
|
||||
$statusTitle = 'Vielen Dank!';
|
||||
$statusText = 'Ihre Nachricht wurde erfolgreich an OMSORG gesendet. Wir melden uns schnellstmöglich bei Ihnen.';
|
||||
} else {
|
||||
http_response_code(500);
|
||||
$statusTitle = 'Versand nicht möglich';
|
||||
$statusText = 'Die Nachricht konnte vom Server nicht versendet werden. Bitte kontaktieren Sie uns direkt per E-Mail: info@omsorg-pflegedienste.de';
|
||||
}
|
||||
include __DIR__ . '/send-status-template.php';
|
||||
Reference in New Issue
Block a user