mirror of
https://git.hexahost.dev/smueller/HexaHost-Frontend.git
synced 2026-06-02 08:08:43 +00:00
Enhance API functionality and security: Added rate limiting and domain validation across multiple API endpoints, improved error handling for missing or invalid parameters, and refactored email handling in contact form for better security and maintainability. Updated README.md with production build instructions and prerequisites.
This commit is contained in:
64
backend/config/contact-config.php
Normal file
64
backend/config/contact-config.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/**
|
||||
* Zentrale Betreff-Konfiguration für das Kontaktformular
|
||||
*/
|
||||
|
||||
/**
|
||||
* @return array<string, string> Betreff-Schlüssel => Anzeigename
|
||||
*/
|
||||
function getContactSubjectMap(): array {
|
||||
return [
|
||||
'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',
|
||||
'it-beratung' => 'IT-Beratung',
|
||||
'it-support' => 'IT-Support & Fehlerbehebung',
|
||||
'netzwerk-wlan' => 'Netzwerk & WLAN-Einrichtung',
|
||||
'it-sicherheit-backup' => 'IT-Sicherheit & Backup',
|
||||
'webseiten-hosting-service' => 'Webseiten- & Hosting-Service',
|
||||
'wartung-betreuung' => 'Wartung & Betreuung',
|
||||
'support' => 'Technischer Support',
|
||||
'beratung' => 'Persönliche Beratung',
|
||||
'migration' => 'Migration/Umzug',
|
||||
'sonstiges' => 'Sonstige Anfrage',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $subjectKey
|
||||
*/
|
||||
function isAllowedContactSubject(string $subjectKey): bool {
|
||||
return array_key_exists($subjectKey, getContactSubjectMap());
|
||||
}
|
||||
|
||||
/**
|
||||
* Betreff aus ?product= oder ?package= für die Kontaktseite ableiten
|
||||
*/
|
||||
function getPreselectedContactSubject(): string {
|
||||
$productMap = [
|
||||
'vpc' => 'vpc-anfrage',
|
||||
'vps' => 'vps-anfrage',
|
||||
'mail-gateway' => 'mail-gateway-anfrage',
|
||||
'webhosting' => 'webhosting-anfrage',
|
||||
];
|
||||
|
||||
if (!empty($_GET['product'])) {
|
||||
$product = strtolower(preg_replace('/[^a-z0-9-]/', '', (string) $_GET['product']));
|
||||
if (isset($productMap[$product])) {
|
||||
return $productMap[$product];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($_GET['package'])) {
|
||||
$package = strtolower(preg_replace('/[^a-z0-9-]/', '', (string) $_GET['package']));
|
||||
foreach ($productMap as $productId => $subjectKey) {
|
||||
if (str_starts_with($package, $productId . '-')) {
|
||||
return $subjectKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
Reference in New Issue
Block a user