diff --git a/backend/config/config.php b/backend/config/config.php index 60968a7..ea8ee0f 100644 --- a/backend/config/config.php +++ b/backend/config/config.php @@ -1,17 +1,6 @@ diff --git a/backend/config/mail-config.php b/backend/config/mail-config.php index 48e59f6..6e5129c 100644 --- a/backend/config/mail-config.php +++ b/backend/config/mail-config.php @@ -1,30 +1,25 @@ 'HexaHost.de Contact Form', 'X-Priority' => '3', @@ -35,22 +30,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' + + ]); -// Überprüfung der E-Mail-Adressen + if (!filter_var(SMTP_FROM_EMAIL, FILTER_VALIDATE_EMAIL)) { die('Ungültige SMTP_FROM_EMAIL Adresse'); } @@ -59,7 +54,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; @@ -76,18 +71,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)) { @@ -98,29 +93,23 @@ 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 3f9db46..9d703aa 100644 --- a/backend/config/products-config.php +++ b/backend/config/products-config.php @@ -1,18 +1,9 @@ 'Virtual Private Container', 'short_name' => 'VPC', @@ -112,9 +103,9 @@ $PRODUCTS['vpc'] = [ ], ]; -// ============================================================================ -// VIRTUAL PRIVATE SERVER (VPS) -// ============================================================================ + + + $PRODUCTS['vps'] = [ 'name' => 'Virtual Private Server', 'short_name' => 'VPS', @@ -214,9 +205,9 @@ $PRODUCTS['vps'] = [ ], ]; -// ============================================================================ -// MAIL GATEWAY -// ============================================================================ + + + $PRODUCTS['mail-gateway'] = [ 'name' => 'Mail Gateway', 'short_name' => 'Mail', @@ -316,9 +307,9 @@ $PRODUCTS['mail-gateway'] = [ ], ]; -// ============================================================================ -// WEBHOSTING -// ============================================================================ + + + $PRODUCTS['webhosting'] = [ 'name' => 'Webhosting', 'short_name' => 'Webhosting', @@ -426,68 +417,52 @@ $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'] ? '' : ''; @@ -535,9 +510,7 @@ 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 03118f4..7d884de 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 new file mode 100644 index 0000000..649f96d --- /dev/null +++ b/public/includes/header.php @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + <?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 d32ca7d..9df9005 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 7cd8237..de6439a 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 b0fd0f2..d247076 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 bc24083..786f5df 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 8e2fd5a..d675f8c 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 86c2bc7..3d803c5 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 cba182a..e831971 100644 --- a/public/widerruf.php +++ b/public/widerruf.php @@ -1,12 +1,12 @@ @@ -131,6 +131,6 @@ includeHeader($page_title, $page_description, $current_page);