From a0b315c13f1656747b40a00d9353bb228f9e7e0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20M=C3=BCller?= Date: Thu, 31 Jul 2025 16:30:05 +0200 Subject: [PATCH] =?UTF-8?q?Aktualisierung=20der=20Kontaktseite:=20Ersetzun?= =?UTF-8?q?g=20von=20Live=20Chat=20durch=20Discord-Support,=20Anpassung=20?= =?UTF-8?q?des=20Kontaktformulars=20mit=20Honeypot-Feld=20f=C3=BCr=20Bot-S?= =?UTF-8?q?chutz=20und=20Verbesserung=20der=20Formularvalidierung.=20Hinzu?= =?UTF-8?q?f=C3=BCgung=20von=20CSS-Stilen=20f=C3=BCr=20neue=20Abschnitte?= =?UTF-8?q?=20und=20Optimierung=20der=20responsiven=20Darstellung.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/README-EMAIL-SETUP.md | 199 ++++++++++++++++ public/assets/css/style.css | 114 ++++++++++ public/assets/js/contact.js | 58 +++-- public/config.php | 171 ++++++++++++++ public/contact-handler.php | 424 +++++++++++++++++++++++++++++++++++ public/contact.html | 14 +- 6 files changed, 959 insertions(+), 21 deletions(-) create mode 100644 public/README-EMAIL-SETUP.md create mode 100644 public/config.php create mode 100644 public/contact-handler.php diff --git a/public/README-EMAIL-SETUP.md b/public/README-EMAIL-SETUP.md new file mode 100644 index 0000000..7733ae8 --- /dev/null +++ b/public/README-EMAIL-SETUP.md @@ -0,0 +1,199 @@ +# HexaHost.de E-Mail-System Setup + +## 📧 Kontaktformular E-Mail-Versand + +Dieses System ermöglicht den E-Mail-Versand über das Kontaktformular mit SMTP-Integration und umfassendem Spam-Schutz. + +## 🚀 Installation + +### 1. SMTP-Konfiguration + +Öffnen Sie die Datei `config.php` und tragen Sie Ihre SMTP-Daten ein: + +```php +$smtp_config = [ + 'smtp_host' => 'smtp.gmail.com', // Ihr SMTP-Server + 'smtp_port' => 587, // Port (587 für TLS, 465 für SSL) + 'smtp_username' => 'info@hexahost.de', // Ihr SMTP-Benutzername + 'smtp_password' => 'IHR_PASSWORT', // Ihr SMTP-Passwort + 'smtp_encryption' => 'tls', // 'tls' oder 'ssl' + 'from_email' => 'info@hexahost.de', // Absender-E-Mail + 'to_email' => 'info@hexahost.de', // Empfänger-E-Mail +]; +``` + +### 2. E-Mail-Provider Beispiele + +#### Gmail +```php +'smtp_host' => 'smtp.gmail.com', +'smtp_port' => 587, +'smtp_encryption' => 'tls', +``` +**Hinweis:** Aktivieren Sie "Weniger sichere Apps" oder verwenden Sie App-Passwörter. + +#### Outlook/Hotmail +```php +'smtp_host' => 'smtp-mail.outlook.com', +'smtp_port' => 587, +'smtp_encryption' => 'tls', +``` + +#### GMX +```php +'smtp_host' => 'mail.gmx.net', +'smtp_port' => 587, +'smtp_encryption' => 'tls', +``` + +#### Web.de +```php +'smtp_host' => 'smtp.web.de', +'smtp_port' => 587, +'smtp_encryption' => 'tls', +``` + +#### Eigener Mail-Server +```php +'smtp_host' => 'mail.ihre-domain.de', +'smtp_port' => 587, // oder 465 für SSL +'smtp_encryption' => 'tls', // oder 'ssl' +``` + +## 🔒 Sicherheitsfeatures + +### Anti-Spam Schutz +- **Rate Limiting**: Max. 5 Anfragen pro Stunde pro IP +- **Honeypot**: Verstecktes Feld für Bot-Schutz +- **Input-Validierung**: Sanitization aller Eingaben +- **E-Mail-Validierung**: Format-Prüfung + +### E-Mail-Headers für Spam-Schutz +```php +X-Mailer: HexaHost Contact Form +X-Priority: 3 +X-MSMail-Priority: Normal +Importance: Normal +X-Report-Abuse: Please report abuse here: abuse@hexahost.de +``` + +## 📧 E-Mail-Template + +### HTML-E-Mail +- Responsive Design +- HexaHost Branding +- Strukturierte Darstellung aller Formulardaten +- IP-Adresse und Zeitstempel für Tracking + +### Text-Version +- Fallback für E-Mail-Clients ohne HTML-Support +- Alle wichtigen Informationen enthalten + +## 🛠️ DNS-Konfiguration für Spam-Schutz + +### SPF Record (TXT Record) +``` +v=spf1 include:_spf.hexahost.de ~all +``` + +### DMARC Record (TXT Record) +``` +v=DMARC1; p=quarantine; rua=mailto:dmarc@hexahost.de +``` + +### DKIM +- Wird über Ihren Mail-Server konfiguriert +- Erhöht die Zustellbarkeit erheblich + +## 🔧 Debugging + +### Debug-Modus aktivieren +```php +$debug_config = [ + 'debug_mode' => true, + 'log_errors' => true, + 'log_file' => 'contact_form_errors.log', +]; +``` + +### Log-Datei prüfen +```bash +tail -f contact_form_errors.log +``` + +## 📋 Dateistruktur + +``` +public/ +├── contact-handler.php # E-Mail-Verarbeitung +├── config.php # SMTP-Konfiguration +├── contact.html # Kontaktformular +├── assets/ +│ ├── css/ +│ │ └── style.css # Styling +│ └── js/ +│ └── contact.js # Frontend-Logic +└── README-EMAIL-SETUP.md # Diese Anleitung +``` + +## 🧪 Testing + +### 1. Konfiguration testen +```bash +php -f config.php +``` + +### 2. E-Mail-Versand testen +1. Öffnen Sie `contact.html` +2. Füllen Sie das Formular aus +3. Senden Sie eine Test-Nachricht +4. Prüfen Sie Ihr E-Mail-Postfach + +### 3. Fehlerbehebung +- Prüfen Sie die Browser-Konsole (F12) +- Prüfen Sie die PHP-Fehler-Logs +- Aktivieren Sie den Debug-Modus + +## 🔧 Erweiterte Konfiguration + +### PHPMailer Integration +Falls PHPMailer verfügbar ist, wird es automatisch verwendet: + +```bash +composer require phpmailer/phpmailer +``` + +### Fallback +Falls PHPMailer nicht verfügbar ist, wird die native PHP `mail()` Funktion verwendet. + +## 📊 Monitoring + +### Erfolgreiche E-Mails +- Empfangen Sie strukturierte HTML-E-Mails +- Alle Formulardaten werden übersichtlich dargestellt +- IP-Adresse und Zeitstempel für Tracking + +### Fehlerbehandlung +- Detaillierte Fehlermeldungen im Log +- Benutzerfreundliche Frontend-Meldungen +- Rate-Limiting-Schutz + +## 🚨 Wichtige Hinweise + +1. **Sicherheit**: Ändern Sie die Standard-Konfiguration +2. **Passwörter**: Verwenden Sie sichere SMTP-Passwörter +3. **SSL/TLS**: Verwenden Sie immer verschlüsselte Verbindungen +4. **DNS**: Konfigurieren Sie SPF, DMARC und DKIM +5. **Backups**: Sichern Sie die Konfigurationsdateien + +## 📞 Support + +Bei Problemen: +1. Prüfen Sie die Log-Dateien +2. Aktivieren Sie den Debug-Modus +3. Testen Sie die SMTP-Verbindung +4. Kontaktieren Sie Ihren Hosting-Provider + +--- + +**© 2024 HexaHost.de - Alle Rechte vorbehalten** \ No newline at end of file diff --git a/public/assets/css/style.css b/public/assets/css/style.css index 9074cb7..d4bc214 100644 --- a/public/assets/css/style.css +++ b/public/assets/css/style.css @@ -509,6 +509,97 @@ body { font-size: var(--font-size-sm); } +/* How it Works Section */ +.how-it-works { + padding: var(--spacing-3xl) 0; + background: rgba(255, 255, 255, 0.02); +} + +.steps-grid { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); + gap: var(--spacing-xl); + margin-top: var(--spacing-2xl); +} + +.step-item { + padding: var(--spacing-xl); + text-align: center; + position: relative; +} + +.step-number { + width: 60px; + height: 60px; + background: linear-gradient(135deg, var(--primary-color), var(--accent-color-1)); + border-radius: 50%; + display: flex; + align-items: center; + justify-content: center; + font-size: var(--font-size-xl); + font-weight: 700; + color: var(--white); + margin: 0 auto var(--spacing-lg); + box-shadow: 0 8px 32px 0 rgba(255, 81, 249, 0.3); +} + +.step-item h3 { + font-size: var(--font-size-lg); + font-weight: 600; + margin-bottom: var(--spacing-md); + color: var(--text-primary); +} + +.step-item p { + color: var(--text-secondary); + line-height: 1.6; + font-size: var(--font-size-base); +} + +/* Mail Features Section */ +.mail-features { + padding: var(--spacing-3xl) 0; + background: rgba(255, 255, 255, 0.03); +} + +/* Benefits Section */ +.benefits { + padding: var(--spacing-3xl) 0; + background: rgba(255, 255, 255, 0.02); +} + +.benefits-grid { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); + gap: var(--spacing-xl); + margin-top: var(--spacing-2xl); +} + +.benefit-item { + padding: var(--spacing-xl); + text-align: center; +} + +.benefit-icon { + width: 48px; + height: 48px; + margin: 0 auto var(--spacing-lg); + color: var(--primary-color); +} + +.benefit-item h3 { + font-size: var(--font-size-lg); + font-weight: 600; + margin-bottom: var(--spacing-md); + color: var(--text-primary); +} + +.benefit-item p { + color: var(--text-secondary); + line-height: 1.6; + font-size: var(--font-size-base); +} + /* CTA Section */ .cta { padding: var(--spacing-3xl) 0; @@ -1263,6 +1354,19 @@ body { transition: all var(--transition-base); } +/* Spezielle Styling für Select-Elemente */ +.form-group select { + background: rgba(255, 255, 255, 0.1); + backdrop-filter: blur(10px); + -webkit-backdrop-filter: blur(10px); +} + +.form-group select option { + background: rgba(13, 8, 33, 0.95); + color: var(--text-primary); + padding: var(--spacing-sm); +} + .form-group input:focus, .form-group select:focus, .form-group textarea:focus { @@ -1444,6 +1548,16 @@ body { grid-template-columns: 1fr; } + .steps-grid { + grid-template-columns: 1fr; + gap: var(--spacing-lg); + } + + .benefits-grid { + grid-template-columns: 1fr; + gap: var(--spacing-lg); + } + .story-content { grid-template-columns: 1fr; } diff --git a/public/assets/js/contact.js b/public/assets/js/contact.js index addf78b..eaff8cb 100644 --- a/public/assets/js/contact.js +++ b/public/assets/js/contact.js @@ -50,12 +50,16 @@ // Get form data const formData = new FormData(form); + + // Add honeypot field (hidden field for bot protection) + formData.append('website', ''); // Honeypot field + + // Basic validation const data = {}; for (let [key, value] of formData.entries()) { data[key] = value; } - // Basic validation if (!validateForm(data)) { return; } @@ -66,21 +70,49 @@ submitBtn.textContent = 'Wird gesendet...'; submitBtn.disabled = true; - // Simulate form submission (replace with actual endpoint) - setTimeout(() => { - // Reset form - form.reset(); - - // Show success message - showNotification('Ihre Nachricht wurde erfolgreich gesendet! Wir melden uns in Kürze bei Ihnen.', 'success'); - + // Send form data to PHP backend + fetch('contact-handler.php', { + method: 'POST', + body: formData + }) + .then(response => response.json()) + .then(data => { + if (data.success) { + // Reset form + form.reset(); + + // Show success message + showNotification(data.message, 'success'); + + // Scroll to top + window.scrollTo({ top: 0, behavior: 'smooth' }); + } else { + // Show error message + showNotification(data.message, 'error'); + + // Highlight missing fields if provided + if (data.missing_fields) { + data.missing_fields.forEach(field => { + const fieldElement = document.getElementById(field); + if (fieldElement) { + fieldElement.style.borderColor = '#ff4d6d'; + setTimeout(() => { + fieldElement.style.borderColor = ''; + }, 3000); + } + }); + } + } + }) + .catch(error => { + console.error('Error:', error); + showNotification('Ein Fehler ist aufgetreten. Bitte versuchen Sie es später erneut.', 'error'); + }) + .finally(() => { // Reset button submitBtn.textContent = originalText; submitBtn.disabled = false; - - // Scroll to top - window.scrollTo({ top: 0, behavior: 'smooth' }); - }, 2000); + }); }); } diff --git a/public/config.php b/public/config.php new file mode 100644 index 0000000..e91af5f --- /dev/null +++ b/public/config.php @@ -0,0 +1,171 @@ + 'YOUR_SMTP_HOST', // z.B. smtp.gmail.com + 'smtp_port' => 587, // 587 für TLS, 465 für SSL + 'smtp_username' => 'YOUR_SMTP_USERNAME', // z.B. info@hexahost.de + 'smtp_password' => 'YOUR_SMTP_PASSWORD', // Ihr SMTP-Passwort + 'smtp_encryption' => 'tls', // 'tls' oder 'ssl' + + // Absender-Einstellungen + 'from_email' => 'info@hexahost.de', // Absender-E-Mail + 'from_name' => 'HexaHost.de Kontaktformular', // Absender-Name + + // Empfänger-Einstellungen + 'to_email' => 'info@hexahost.de', // Empfänger-E-Mail + 'to_name' => 'HexaHost Support', // Empfänger-Name + + // Sicherheitseinstellungen + 'max_requests_per_hour' => 5, // Max. Anfragen pro Stunde pro IP + 'honeypot_field' => 'website', // Verstecktes Feld für Bot-Schutz + + // E-Mail-Template-Einstellungen + 'email_template' => 'html', // 'html' oder 'text' + 'include_ip_address' => true, // IP-Adresse in E-Mail anzeigen + 'include_timestamp' => true, // Zeitstempel in E-Mail anzeigen +]; + +// DNS-Einstellungen für Spam-Schutz (werden über DNS konfiguriert) +$dns_config = [ + // SPF Record (TXT Record in DNS) + 'spf_record' => 'v=spf1 include:_spf.hexahost.de ~all', + + // DMARC Record (TXT Record in DNS) + 'dmarc_record' => 'v=DMARC1; p=quarantine; rua=mailto:dmarc@hexahost.de', + + // DKIM wird über den Mail-Server konfiguriert +]; + +// Debug-Einstellungen (nur für Entwicklung) +$debug_config = [ + 'debug_mode' => false, // Debug-Modus aktivieren + 'log_errors' => true, // Fehler loggen + 'log_file' => 'contact_form_errors.log', // Log-Datei +]; + +// Exportiere Konfiguration für andere Dateien +if (!defined('HEXAHOST_CONFIG_LOADED')) { + define('HEXAHOST_CONFIG_LOADED', true); + + // Globale Variablen für andere Dateien + $GLOBALS['hexahost_smtp_config'] = $smtp_config; + $GLOBALS['hexahost_dns_config'] = $dns_config; + $GLOBALS['hexahost_debug_config'] = $debug_config; +} + +// Hilfsfunktion zum Abrufen der Konfiguration +function getHexaHostConfig($key = null) { + global $smtp_config, $dns_config, $debug_config; + + if ($key === null) { + return array_merge($smtp_config, $dns_config, $debug_config); + } + + if (isset($smtp_config[$key])) { + return $smtp_config[$key]; + } + + if (isset($dns_config[$key])) { + return $dns_config[$key]; + } + + if (isset($debug_config[$key])) { + return $debug_config[$key]; + } + + return null; +} + +// Debug-Funktion +function hexahostDebug($message, $type = 'info') { + global $debug_config; + + if (!$debug_config['debug_mode']) { + return; + } + + $timestamp = date('Y-m-d H:i:s'); + $log_message = "[$timestamp] [$type] $message" . PHP_EOL; + + if ($debug_config['log_errors']) { + error_log($log_message, 3, $debug_config['log_file']); + } + + if ($debug_config['debug_mode']) { + echo "\n"; + } +} + +// Validierung der SMTP-Konfiguration +function validateSMTPConfig() { + $config = getHexaHostConfig(); + $errors = []; + + // Prüfe ob alle erforderlichen Felder ausgefüllt sind + $required_fields = ['smtp_host', 'smtp_username', 'smtp_password', 'from_email', 'to_email']; + + foreach ($required_fields as $field) { + if (empty($config[$field]) || $config[$field] === 'YOUR_SMTP_' . strtoupper(substr($field, 5))) { + $errors[] = "Konfigurationsfehler: $field ist nicht korrekt eingestellt."; + } + } + + // Prüfe SMTP-Port + if (!is_numeric($config['smtp_port']) || $config['smtp_port'] < 1 || $config['smtp_port'] > 65535) { + $errors[] = "Konfigurationsfehler: Ungültiger SMTP-Port."; + } + + // Prüfe E-Mail-Format + if (!filter_var($config['from_email'], FILTER_VALIDATE_EMAIL)) { + $errors[] = "Konfigurationsfehler: Ungültige Absender-E-Mail."; + } + + if (!filter_var($config['to_email'], FILTER_VALIDATE_EMAIL)) { + $errors[] = "Konfigurationsfehler: Ungültige Empfänger-E-Mail."; + } + + return $errors; +} + +// Zeige Konfigurationsfehler an (nur im Debug-Modus) +if (getHexaHostConfig('debug_mode')) { + $config_errors = validateSMTPConfig(); + if (!empty($config_errors)) { + hexahostDebug('SMTP-Konfigurationsfehler: ' . implode(', ', $config_errors), 'error'); + } +} +?> \ No newline at end of file diff --git a/public/contact-handler.php b/public/contact-handler.php new file mode 100644 index 0000000..e0deedb --- /dev/null +++ b/public/contact-handler.php @@ -0,0 +1,424 @@ + false, 'message' => 'Method not allowed']); + exit; +} + +// Rate Limiting +function checkRateLimit($ip) { + global $config; + $cache_file = sys_get_temp_dir() . '/hexahost_contact_' . md5($ip) . '.txt'; + $current_time = time(); + + if (file_exists($cache_file)) { + $data = json_decode(file_get_contents($cache_file), true); + if ($data && isset($data['requests'])) { + // Entferne alte Einträge (älter als 1 Stunde) + $data['requests'] = array_filter($data['requests'], function($timestamp) use ($current_time) { + return ($current_time - $timestamp) < 3600; + }); + + if (count($data['requests']) >= $config['max_requests_per_hour']) { + return false; + } + } + } + + // Füge aktuellen Request hinzu + $data = isset($data) ? $data : ['requests' => []]; + $data['requests'][] = $current_time; + file_put_contents($cache_file, json_encode($data)); + + return true; +} + +// Honeypot Check +function checkHoneypot($data) { + global $config; + $honeypot_field = $config['honeypot_field']; + + // Das Honeypot-Feld sollte leer sein (verstecktes Feld) + if (!empty($data[$honeypot_field])) { + return false; + } + + return true; +} + +// E-Mail-Validierung +function validateEmail($email) { + return filter_var($email, FILTER_VALIDATE_EMAIL) !== false; +} + +// Input-Sanitization +function sanitizeInput($input) { + return htmlspecialchars(strip_tags(trim($input)), ENT_QUOTES, 'UTF-8'); +} + +// SMTP E-Mail-Versand mit PHPMailer +function sendEmail($data) { + global $config; + + // PHPMailer laden (falls verfügbar) + if (!class_exists('PHPMailer\PHPMailer\PHPMailer')) { + // Fallback: Native PHP mail() Funktion + return sendEmailNative($data); + } + + try { + $mail = new PHPMailer\PHPMailer\PHPMailer(true); + + // Server-Einstellungen + $mail->isSMTP(); + $mail->Host = $config['smtp_host']; + $mail->SMTPAuth = true; + $mail->Username = $config['smtp_username']; + $mail->Password = $config['smtp_password']; + $mail->SMTPSecure = $config['smtp_encryption']; + $mail->Port = $config['smtp_port']; + $mail->CharSet = 'UTF-8'; + + // Absender + $mail->setFrom($config['from_email'], $config['from_name']); + $mail->addReplyTo($data['email'], $data['firstName'] . ' ' . $data['lastName']); + + // Empfänger + $mail->addAddress($config['to_email'], $config['to_name']); + + // Betreff + $subject_map = [ + 'allgemeine-anfrage' => 'Allgemeine Anfrage', + 'vpc-anfrage' => 'Virtual Private Container Anfrage', + 'vps-anfrage' => 'Virtual Private Server Anfrage', + 'mail-gateway-anfrage' => 'Mail Gateway Anfrage', + 'webhosting-anfrage' => 'Webhosting Anfrage', + 'support' => 'Technischer Support', + 'beratung' => 'Persönliche Beratung', + 'migration' => 'Migration/Umzug', + 'sonstiges' => 'Sonstige Anfrage' + ]; + + $subject = isset($subject_map[$data['subject']]) ? $subject_map[$data['subject']] : 'Neue Kontaktanfrage'; + $mail->Subject = '[HexaHost.de] ' . $subject; + + // HTML E-Mail-Inhalt + $html_content = generateEmailHTML($data); + $mail->isHTML(true); + $mail->Body = $html_content; + $mail->AltBody = generateEmailText($data); + + // Anti-Spam Headers + $mail->addCustomHeader('X-Mailer', 'HexaHost Contact Form'); + $mail->addCustomHeader('X-Priority', '3'); + $mail->addCustomHeader('X-MSMail-Priority', 'Normal'); + $mail->addCustomHeader('Importance', 'Normal'); + $mail->addCustomHeader('X-Report-Abuse', 'Please report abuse here: abuse@hexahost.de'); + + // DKIM, SPF, DMARC werden über DNS konfiguriert + + $mail->send(); + return true; + + } catch (Exception $e) { + error_log('HexaHost Contact Form Error: ' . $e->getMessage()); + return false; + } +} + +// Fallback: Native PHP mail() Funktion +function sendEmailNative($data) { + global $config; + + $subject_map = [ + 'allgemeine-anfrage' => 'Allgemeine Anfrage', + 'vpc-anfrage' => 'Virtual Private Container Anfrage', + 'vps-anfrage' => 'Virtual Private Server Anfrage', + 'mail-gateway-anfrage' => 'Mail Gateway Anfrage', + 'webhosting-anfrage' => 'Webhosting Anfrage', + 'support' => 'Technischer Support', + 'beratung' => 'Persönliche Beratung', + 'migration' => 'Migration/Umzug', + 'sonstiges' => 'Sonstige Anfrage' + ]; + + $subject = isset($subject_map[$data['subject']]) ? $subject_map[$data['subject']] : 'Neue Kontaktanfrage'; + $subject = '[HexaHost.de] ' . $subject; + + // Headers für Spam-Schutz + $headers = [ + 'From: ' . $config['from_name'] . ' <' . $config['from_email'] . '>', + 'Reply-To: ' . $data['firstName'] . ' ' . $data['lastName'] . ' <' . $data['email'] . '>', + 'MIME-Version: 1.0', + 'Content-Type: text/html; charset=UTF-8', + 'X-Mailer: HexaHost Contact Form', + 'X-Priority: 3', + 'X-MSMail-Priority: Normal', + 'Importance: Normal', + 'X-Report-Abuse: Please report abuse here: abuse@hexahost.de' + ]; + + $message = generateEmailHTML($data); + + return mail($config['to_email'], $subject, $message, implode("\r\n", $headers)); +} + +// HTML E-Mail-Template +function generateEmailHTML($data) { + $subject_map = [ + 'allgemeine-anfrage' => 'Allgemeine Anfrage', + 'vpc-anfrage' => 'Virtual Private Container Anfrage', + 'vps-anfrage' => 'Virtual Private Server Anfrage', + 'mail-gateway-anfrage' => 'Mail Gateway Anfrage', + 'webhosting-anfrage' => 'Webhosting Anfrage', + 'support' => 'Technischer Support', + 'beratung' => 'Persönliche Beratung', + 'migration' => 'Migration/Umzug', + 'sonstiges' => 'Sonstige Anfrage' + ]; + + $subject_text = isset($subject_map[$data['subject']]) ? $subject_map[$data['subject']] : 'Neue Kontaktanfrage'; + + return ' + + + + + + Neue Kontaktanfrage - HexaHost.de + + + +
+
+

Neue Kontaktanfrage

+

HexaHost.de Kontaktformular

+
+ +
+
+
Betreff:
+
' . $subject_text . '
+
+ +
+
Name:
+
' . $data['firstName'] . ' ' . $data['lastName'] . '
+
+ +
+
E-Mail:
+
' . $data['email'] . '
+
'; + + if (!empty($data['phone'])) { + $html .= ' +
+
Telefon:
+
' . $data['phone'] . '
+
'; + } + + if (!empty($data['company'])) { + $html .= ' +
+
Unternehmen:
+
' . $data['company'] . '
+
'; + } + + $html .= ' +
+
Nachricht:
+
' . nl2br($data['message']) . '
+
+ +
+
Newsletter-Anmeldung:
+
' . (!empty($data['newsletter']) ? 'Ja' : 'Nein') . '
+
+ +
+
IP-Adresse:
+
' . $_SERVER['REMOTE_ADDR'] . '
+
+ +
+
Zeitstempel:
+
' . date('d.m.Y H:i:s') . '
+
+
+ + +
+ + '; + + return $html; +} + +// Text-Version der E-Mail +function generateEmailText($data) { + $subject_map = [ + 'allgemeine-anfrage' => 'Allgemeine Anfrage', + 'vpc-anfrage' => 'Virtual Private Container Anfrage', + 'vps-anfrage' => 'Virtual Private Server Anfrage', + 'mail-gateway-anfrage' => 'Mail Gateway Anfrage', + 'webhosting-anfrage' => 'Webhosting Anfrage', + 'support' => 'Technischer Support', + 'beratung' => 'Persönliche Beratung', + 'migration' => 'Migration/Umzug', + 'sonstiges' => 'Sonstige Anfrage' + ]; + + $subject_text = isset($subject_map[$data['subject']]) ? $subject_map[$data['subject']] : 'Neue Kontaktanfrage'; + + $text = "NEUE KONTAKTANFRAGE - HexaHost.de\n"; + $text .= "=====================================\n\n"; + $text .= "Betreff: " . $subject_text . "\n"; + $text .= "Name: " . $data['firstName'] . " " . $data['lastName'] . "\n"; + $text .= "E-Mail: " . $data['email'] . "\n"; + + if (!empty($data['phone'])) { + $text .= "Telefon: " . $data['phone'] . "\n"; + } + + if (!empty($data['company'])) { + $text .= "Unternehmen: " . $data['company'] . "\n"; + } + + $text .= "\nNachricht:\n"; + $text .= "----------\n"; + $text .= $data['message'] . "\n\n"; + + $text .= "Newsletter-Anmeldung: " . (!empty($data['newsletter']) ? "Ja" : "Nein") . "\n"; + $text .= "IP-Adresse: " . $_SERVER['REMOTE_ADDR'] . "\n"; + $text .= "Zeitstempel: " . date('d.m.Y H:i:s') . "\n\n"; + + $text .= "---\n"; + $text .= "Diese E-Mail wurde automatisch vom HexaHost.de Kontaktformular generiert.\n"; + $text .= "© 2024 HexaHost.de - Alle Rechte vorbehalten"; + + return $text; +} + +// Hauptverarbeitung +try { + // Rate Limiting Check + $client_ip = $_SERVER['REMOTE_ADDR']; + if (!checkRateLimit($client_ip)) { + http_response_code(429); + echo json_encode([ + 'success' => false, + 'message' => 'Zu viele Anfragen. Bitte versuchen Sie es später erneut.' + ]); + exit; + } + + // Honeypot Check + if (!checkHoneypot($_POST)) { + http_response_code(400); + echo json_encode([ + 'success' => false, + 'message' => 'Ungültige Anfrage.' + ]); + exit; + } + + // Pflichtfelder prüfen + $required_fields = ['firstName', 'lastName', 'email', 'subject', 'message', 'privacy']; + $missing_fields = []; + + foreach ($required_fields as $field) { + if (empty($_POST[$field])) { + $missing_fields[] = $field; + } + } + + if (!empty($missing_fields)) { + http_response_code(400); + echo json_encode([ + 'success' => false, + 'message' => 'Bitte füllen Sie alle Pflichtfelder aus.', + 'missing_fields' => $missing_fields + ]); + exit; + } + + // E-Mail-Validierung + if (!validateEmail($_POST['email'])) { + http_response_code(400); + echo json_encode([ + 'success' => false, + 'message' => 'Bitte geben Sie eine gültige E-Mail-Adresse ein.' + ]); + exit; + } + + // Daten sanitieren + $data = [ + 'firstName' => sanitizeInput($_POST['firstName']), + 'lastName' => sanitizeInput($_POST['lastName']), + 'email' => sanitizeInput($_POST['email']), + 'phone' => sanitizeInput($_POST['phone'] ?? ''), + 'company' => sanitizeInput($_POST['company'] ?? ''), + 'subject' => sanitizeInput($_POST['subject']), + 'message' => sanitizeInput($_POST['message']), + 'newsletter' => isset($_POST['newsletter']) ? true : false, + 'privacy' => isset($_POST['privacy']) ? true : false + ]; + + // E-Mail senden + if (sendEmail($data)) { + echo json_encode([ + 'success' => true, + 'message' => 'Ihre Nachricht wurde erfolgreich gesendet! Wir melden uns in Kürze bei Ihnen.' + ]); + } else { + http_response_code(500); + echo json_encode([ + 'success' => false, + 'message' => 'Beim Senden der Nachricht ist ein Fehler aufgetreten. Bitte versuchen Sie es später erneut.' + ]); + } + +} catch (Exception $e) { + error_log('HexaHost Contact Form Error: ' . $e->getMessage()); + http_response_code(500); + echo json_encode([ + 'success' => false, + 'message' => 'Ein unerwarteter Fehler ist aufgetreten. Bitte versuchen Sie es später erneut.' + ]); +} +?> \ No newline at end of file diff --git a/public/contact.html b/public/contact.html index de16c26..a5ab0b0 100644 --- a/public/contact.html +++ b/public/contact.html @@ -97,11 +97,11 @@ -

Live Chat

-

Direkter Support ĂĽber unseren Live Chat fĂĽr schnelle Hilfe.

- -

Mo-Fr: 9:00-18:00 Uhr

+

Discord

+

Direkter Support ĂĽber unseren Discord fĂĽr schnelle Hilfe.

+ +
@@ -174,17 +174,15 @@
-
+