build: Update dist with new config structure

This commit is contained in:
TheOnlyMace
2026-01-17 00:16:36 +01:00
parent 9f0fe884ce
commit 9282baee44
5 changed files with 63 additions and 174 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

170
dist/config/config.php vendored
View File

@@ -1,171 +1,17 @@
<?php
/**
* HexaHost.de SMTP Konfiguration
* HexaHost.de Konfiguration
*
* WICHTIG: Ändern Sie diese Werte entsprechend Ihren SMTP-Einstellungen!
* HINWEIS: Diese Datei ist veraltet!
*
* Beispiele für verschiedene E-Mail-Provider:
* Die Konfiguration wurde nach mail-config.php verschoben.
* Bitte verwenden Sie stattdessen:
*
* Gmail:
* - smtp_host: smtp.gmail.com
* - smtp_port: 587
* - smtp_encryption: tls
* require_once 'config/mail-config.php';
*
* Outlook/Hotmail:
* - smtp_host: smtp-mail.outlook.com
* - smtp_port: 587
* - smtp_encryption: tls
*
* GMX:
* - smtp_host: mail.gmx.net
* - smtp_port: 587
* - smtp_encryption: tls
*
* Web.de:
* - smtp_host: smtp.web.de
* - smtp_port: 587
* - smtp_encryption: tls
*
* Eigener Mail-Server:
* - smtp_host: mail.ihre-domain.de
* - smtp_port: 587 (oder 465 für SSL)
* - smtp_encryption: tls (oder ssl)
* Diese Datei wird nur aus Kompatibilitätsgründen beibehalten.
*/
// SMTP Konfiguration - HIER IHRE WERTE EINTRAGEN
$smtp_config = [
// SMTP Server-Einstellungen
'smtp_host' => 'smtp.gmail.com', // z.B. smtp.gmail.com
'smtp_port' => 587, // 587 für TLS, 465 für SSL
'smtp_username' => 'test@hexahost.de', // z.B. info@hexahost.de
'smtp_password' => 'your-app-password', // Ihr SMTP-Passwort
'smtp_encryption' => 'tls', // 'tls' oder 'ssl'
// Absender-Einstellungen
'from_email' => 'test@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 "<!-- HexaHost Debug: $message -->\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');
}
}
// Lade die neue Konfiguration
require_once __DIR__ . '/mail-config.php';
?>

View File

@@ -140,16 +140,59 @@ function isValidEmail($email) {
return true;
}
// CSRF Token generieren
function generateCSRFToken() {
// CSRF Token generieren (wird in functions.php verwendet)
// Hinweis: Diese Funktion existiert auch in functions.php - hier nur als Fallback
if (!function_exists('generateCSRFToken')) {
function generateCSRFToken() {
if (!isset($_SESSION['csrf_token'])) {
$_SESSION['csrf_token'] = bin2hex(random_bytes(32));
}
return $_SESSION['csrf_token'];
}
}
// CSRF Token validieren
function validateCSRFToken($token) {
if (!function_exists('validateCSRFToken')) {
function validateCSRFToken($token) {
return isset($_SESSION['csrf_token']) && hash_equals($_SESSION['csrf_token'], $token);
}
}
/**
* Hilfsfunktion zum Abrufen der Konfiguration als Array
* Kompatibilität mit contact-handler.php
*
* @param string|null $key Optional: einzelner Schlüssel
* @return mixed Konfigurationsarray oder einzelner Wert
*/
function getHexaHostConfig($key = null) {
$config = [
// SMTP Server-Einstellungen
'smtp_host' => SMTP_HOST,
'smtp_port' => SMTP_PORT,
'smtp_username' => SMTP_USERNAME,
'smtp_password' => SMTP_PASSWORD,
'smtp_encryption' => 'tls',
// Absender/Empfänger
'from_email' => SMTP_FROM_EMAIL,
'from_name' => 'HexaHost.de Kontaktformular',
'to_email' => SMTP_TO_EMAIL,
'to_name' => 'HexaHost Support',
// Sicherheit
'max_requests_per_hour' => MAX_REQUESTS_PER_HOUR,
'honeypot_field' => 'website',
// Debug
'debug_mode' => DEBUG_MODE,
'log_errors' => LOG_EMAILS,
];
if ($key === null) {
return $config;
}
return $config[$key] ?? null;
}
?>