diff --git a/backend/config/config.php b/backend/config/config.php index ea8ee0f..60968a7 100644 --- a/backend/config/config.php +++ b/backend/config/config.php @@ -1,6 +1,17 @@ diff --git a/backend/config/mail-config.php b/backend/config/mail-config.php index bb883dc..48e59f6 100644 --- a/backend/config/mail-config.php +++ b/backend/config/mail-config.php @@ -1,25 +1,30 @@ 'HexaHost.de Contact Form', 'X-Priority' => '3', @@ -30,35 +35,22 @@ define('ADDITIONAL_HEADERS', [ 'Precedence' => 'bulk' ]); - - +// Erlaubte Domains für E-Mail-Adressen (optional) define('ALLOWED_EMAIL_DOMAINS', [ - - - - - - - - - - + // Leer lassen für alle Domains zu erlauben + // 'gmail.com', + // 'outlook.com', + // 'web.de', + // 'gmx.de' ]); - - +// Blacklist für E-Mail-Adressen (optional) define('BLACKLISTED_EMAILS', [ - - - - + // 'spam@example.com', + // 'test@test.com' ]); - -if (!defined('SMTP_HOST') || !defined('SMTP_USERNAME') || !defined('SMTP_PASSWORD')) { - die('SMTP-Konfiguration ist unvollständig. Bitte überprüfen Sie die mail-config.php'); -} - +// Überprüfung der E-Mail-Adressen if (!filter_var(SMTP_FROM_EMAIL, FILTER_VALIDATE_EMAIL)) { die('Ungültige SMTP_FROM_EMAIL Adresse'); } @@ -67,7 +59,7 @@ if (!filter_var(SMTP_TO_EMAIL, FILTER_VALIDATE_EMAIL)) { die('Ungültige SMTP_TO_EMAIL Adresse'); } - +// Logging-Funktion function logEmail($type, $data) { if (!LOG_EMAILS) return; @@ -84,21 +76,18 @@ function logEmail($type, $data) { file_put_contents($logFile, $logEntry, FILE_APPEND | LOCK_EX); } - - +// Hilfsfunktion für E-Mail-Validierung function isValidEmail($email) { if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { return false; } - - + // Prüfe Blacklist if (in_array($email, BLACKLISTED_EMAILS)) { return false; } - - + // Prüfe Domain-Whitelist (falls gesetzt) if (!empty(ALLOWED_EMAIL_DOMAINS)) { $domain = substr(strrchr($email, "@"), 1); if (!in_array($domain, ALLOWED_EMAIL_DOMAINS)) { @@ -109,26 +98,29 @@ function isValidEmail($email) { return true; } - - +/** + * 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 = [ - + // 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', 'enable_csrf' => ENABLE_CSRF_PROTECTION, 'min_message_length' => MIN_MESSAGE_LENGTH, 'max_message_length' => MAX_MESSAGE_LENGTH, - - + // Debug 'debug_mode' => DEBUG_MODE, 'log_errors' => LOG_EMAILS, ]; diff --git a/backend/config/products-config.php b/backend/config/products-config.php index 9d703aa..3f9db46 100644 --- a/backend/config/products-config.php +++ b/backend/config/products-config.php @@ -1,9 +1,18 @@ 'Virtual Private Container', 'short_name' => 'VPC', @@ -103,9 +112,9 @@ $PRODUCTS['vpc'] = [ ], ]; - - - +// ============================================================================ +// VIRTUAL PRIVATE SERVER (VPS) +// ============================================================================ $PRODUCTS['vps'] = [ 'name' => 'Virtual Private Server', 'short_name' => 'VPS', @@ -205,9 +214,9 @@ $PRODUCTS['vps'] = [ ], ]; - - - +// ============================================================================ +// MAIL GATEWAY +// ============================================================================ $PRODUCTS['mail-gateway'] = [ 'name' => 'Mail Gateway', 'short_name' => 'Mail', @@ -307,9 +316,9 @@ $PRODUCTS['mail-gateway'] = [ ], ]; - - - +// ============================================================================ +// WEBHOSTING +// ============================================================================ $PRODUCTS['webhosting'] = [ 'name' => 'Webhosting', 'short_name' => 'Webhosting', @@ -417,52 +426,68 @@ $PRODUCTS['webhosting'] = [ ], ]; +// ============================================================================ +// HILFSFUNKTIONEN +// ============================================================================ - - - - +/** + * Alle Produkte abrufen + */ function getAllProducts() { global $PRODUCTS; return $PRODUCTS; } - +/** + * Ein Produkt abrufen + */ function getProduct($productId) { global $PRODUCTS; return $PRODUCTS[$productId] ?? null; } - +/** + * Alle Pakete eines Produkts abrufen + */ function getProductPackages($productId) { global $PRODUCTS; return $PRODUCTS[$productId]['packages'] ?? []; } - +/** + * Ein bestimmtes Paket abrufen + */ function getPackage($productId, $packageId) { global $PRODUCTS; return $PRODUCTS[$productId]['packages'][$packageId] ?? null; } - +/** + * Preis eines Pakets abrufen + */ function getPackagePrice($productId, $packageId) { $package = getPackage($productId, $packageId); return $package['price'] ?? null; } - +/** + * Minimalen Preis eines Produkts abrufen + */ function getMinPrice($productId) { global $PRODUCTS; return $PRODUCTS[$productId]['min_price'] ?? null; } - +/** + * Preis formatiert ausgeben + */ function formatPrice($price, $withCurrency = true) { return $withCurrency ? $price . '€' : $price; } - +/** + * Generiert HTML für eine Paket-Karte + */ function renderPackageCard($productId, $packageId, $package) { $featuredClass = $package['featured'] ? ' featured' : ''; $featuredBadge = $package['featured'] ? '' : ''; @@ -510,7 +535,9 @@ function renderPackageCard($productId, $packageId, $package) { ); } - +/** + * Generiert HTML für alle Pakete eines Produkts + */ function renderAllPackages($productId) { $packages = getProductPackages($productId); $html = ''; diff --git a/backend/includes/footer.php b/backend/includes/footer.php index 7d884de..03118f4 100644 --- a/backend/includes/footer.php +++ b/backend/includes/footer.php @@ -49,7 +49,7 @@ - + '; -} - - -function generateCSRFToken() { - if (!isset($_SESSION['csrf_token'])) { - $_SESSION['csrf_token'] = bin2hex(random_bytes(32)); - } - return $_SESSION['csrf_token']; -} - - -function validateCSRFToken($token) { - if (!isset($_SESSION['csrf_token']) || !is_string($token)) { - return false; - } - if (!hash_equals($_SESSION['csrf_token'], $token)) { - return false; - } - unset($_SESSION['csrf_token']); - return true; -} - - -function sanitizeHeaderValue(string $value): string { - return str_replace(["\r", "\n", "\0"], '', trim($value)); -} - - -function getClientIP(): string { - if (!empty($_SERVER['HTTP_CF_CONNECTING_IP']) - && filter_var($_SERVER['HTTP_CF_CONNECTING_IP'], FILTER_VALIDATE_IP)) { - return $_SERVER['HTTP_CF_CONNECTING_IP']; - } - - $remoteAddr = $_SERVER['REMOTE_ADDR'] ?? '0.0.0.0'; - $isTrustedProxy = filter_var( - $remoteAddr, - FILTER_VALIDATE_IP, - FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE - ) === false; - - if ($isTrustedProxy) { - foreach (['HTTP_X_REAL_IP', 'HTTP_X_FORWARDED_FOR'] as $header) { - if (empty($_SERVER[$header])) { - continue; - } - $ip = trim(explode(',', $_SERVER[$header])[0]); - if (filter_var($ip, FILTER_VALIDATE_IP)) { - return $ip; - } - } - } - - return $remoteAddr; -} -?> \ No newline at end of file diff --git a/public/includes/header.php b/public/includes/header.php deleted file mode 100644 index 649f96d..0000000 --- a/public/includes/header.php +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - - - - - - - - - - - - - - <?php echo isset($page_title) ? htmlspecialchars($page_title) : 'HexaHost.de - Zuverlässiges Hosting aus Niederbayern'; ?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
\ No newline at end of file diff --git a/public/index.php b/public/index.php index 9df9005..d32ca7d 100644 --- a/public/index.php +++ b/public/index.php @@ -1,17 +1,17 @@
- +
@@ -44,7 +44,7 @@ includeHeader($page_title, $page_description, $current_page);
- +
@@ -150,7 +150,7 @@ includeHeader($page_title, $page_description, $current_page);
- +
@@ -192,7 +192,7 @@ includeHeader($page_title, $page_description, $current_page);
- +
@@ -248,7 +248,7 @@ includeHeader($page_title, $page_description, $current_page);
- +
@@ -265,6 +265,6 @@ includeHeader($page_title, $page_description, $current_page);
\ No newline at end of file diff --git a/public/it-dienstleistungen.php b/public/it-dienstleistungen.php index de6439a..7cd8237 100644 --- a/public/it-dienstleistungen.php +++ b/public/it-dienstleistungen.php @@ -1,17 +1,17 @@
- +
@@ -32,7 +32,7 @@ includeHeader($page_title, $page_description, $current_page);
- +
@@ -60,7 +60,7 @@ includeHeader($page_title, $page_description, $current_page);
- +
@@ -128,7 +128,7 @@ includeHeader($page_title, $page_description, $current_page);
- +
@@ -143,6 +143,6 @@ includeHeader($page_title, $page_description, $current_page);
diff --git a/public/mail-gateway.php b/public/mail-gateway.php index d247076..b0fd0f2 100644 --- a/public/mail-gateway.php +++ b/public/mail-gateway.php @@ -2,21 +2,21 @@ require_once __DIR__ . '/../backend/includes/functions.php'; require_once __DIR__ . '/../backend/config/products-config.php'; - +// Produkt-Daten aus Config laden $product = getProduct('mail-gateway'); $packages = getProductPackages('mail-gateway'); - +// Page configuration $page_title = $product['page_title']; $page_description = $product['page_description']; $current_page = 'mail-gateway'; - +// Include header includeHeader($page_title, $page_description, $current_page); ?>
- +
@@ -59,7 +59,7 @@ includeHeader($page_title, $page_description, $current_page);
- +
@@ -74,7 +74,7 @@ includeHeader($page_title, $page_description, $current_page);
- +
@@ -129,7 +129,7 @@ includeHeader($page_title, $page_description, $current_page);
- +
@@ -159,7 +159,7 @@ includeHeader($page_title, $page_description, $current_page);
- +
@@ -175,6 +175,6 @@ includeHeader($page_title, $page_description, $current_page);
diff --git a/public/vpc.php b/public/vpc.php index 786f5df..bc24083 100644 --- a/public/vpc.php +++ b/public/vpc.php @@ -2,21 +2,21 @@ require_once __DIR__ . '/../backend/includes/functions.php'; require_once __DIR__ . '/../backend/config/products-config.php'; - +// Produkt-Daten aus Config laden $product = getProduct('vpc'); $packages = getProductPackages('vpc'); - +// Page configuration $page_title = $product['page_title']; $page_description = $product['page_description']; $current_page = 'vpc'; - +// Include header includeHeader($page_title, $page_description, $current_page); ?>
- +
@@ -58,7 +58,7 @@ includeHeader($page_title, $page_description, $current_page);
- +
@@ -73,7 +73,7 @@ includeHeader($page_title, $page_description, $current_page);
- +
@@ -129,7 +129,7 @@ includeHeader($page_title, $page_description, $current_page);
- +
@@ -159,7 +159,7 @@ includeHeader($page_title, $page_description, $current_page);
- +
@@ -175,6 +175,6 @@ includeHeader($page_title, $page_description, $current_page);
diff --git a/public/vps.php b/public/vps.php index d675f8c..8e2fd5a 100644 --- a/public/vps.php +++ b/public/vps.php @@ -2,21 +2,21 @@ require_once __DIR__ . '/../backend/includes/functions.php'; require_once __DIR__ . '/../backend/config/products-config.php'; - +// Produkt-Daten aus Config laden $product = getProduct('vps'); $packages = getProductPackages('vps'); - +// Page configuration $page_title = $product['page_title']; $page_description = $product['page_description']; $current_page = 'vps'; - +// Include header includeHeader($page_title, $page_description, $current_page); ?>
- +
@@ -63,7 +63,7 @@ includeHeader($page_title, $page_description, $current_page);
- +
@@ -78,7 +78,7 @@ includeHeader($page_title, $page_description, $current_page);
- +
@@ -134,7 +134,7 @@ includeHeader($page_title, $page_description, $current_page);
- +
@@ -164,7 +164,7 @@ includeHeader($page_title, $page_description, $current_page);
- +
@@ -180,6 +180,6 @@ includeHeader($page_title, $page_description, $current_page);
diff --git a/public/webhosting.php b/public/webhosting.php index 3d803c5..86c2bc7 100644 --- a/public/webhosting.php +++ b/public/webhosting.php @@ -2,21 +2,21 @@ require_once __DIR__ . '/../backend/includes/functions.php'; require_once __DIR__ . '/../backend/config/products-config.php'; - +// Produkt-Daten aus Config laden $product = getProduct('webhosting'); $packages = getProductPackages('webhosting'); - +// Page configuration $page_title = $product['page_title']; $page_description = $product['page_description']; $current_page = 'webhosting'; - +// Include header includeHeader($page_title, $page_description, $current_page); ?>
- +
@@ -60,7 +60,7 @@ includeHeader($page_title, $page_description, $current_page);
- +
@@ -75,7 +75,7 @@ includeHeader($page_title, $page_description, $current_page);
- +
@@ -133,7 +133,7 @@ includeHeader($page_title, $page_description, $current_page);
- +
@@ -163,7 +163,7 @@ includeHeader($page_title, $page_description, $current_page);
- +
@@ -179,6 +179,6 @@ includeHeader($page_title, $page_description, $current_page);
diff --git a/public/widerruf.php b/public/widerruf.php index e831971..cba182a 100644 --- a/public/widerruf.php +++ b/public/widerruf.php @@ -1,12 +1,12 @@ @@ -131,6 +131,6 @@ includeHeader($page_title, $page_description, $current_page);