mirror of
https://git.hexahost.dev/smueller/HexaHost-Frontend.git
synced 2026-06-02 11:28:42 +00:00
Refactor configuration files for HexaHost.de: Updated mail and product configuration files to improve clarity and maintainability. Added deprecation notices in the old config file, migrated email handling to a new structure, and enhanced documentation for better understanding. Improved header comments across various public pages for better organization and readability.
This commit is contained in:
@@ -1,135 +1,5 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
define('SMTP_HOST', 'smtp.ihre-domain.de');
|
||||
define('SMTP_PORT', 587);
|
||||
define('SMTP_USERNAME', 'kontakt@ihre-domain.de');
|
||||
define('SMTP_PASSWORD', 'ihr-smtp-passwort');
|
||||
define('SMTP_FROM_EMAIL', 'kontakt@hexahost.de');
|
||||
define('SMTP_TO_EMAIL', 'info@hexahost.de');
|
||||
|
||||
|
||||
define('ENABLE_CSRF_PROTECTION', true);
|
||||
define('ENABLE_RATE_LIMITING', true);
|
||||
define('MAX_REQUESTS_PER_HOUR', 10);
|
||||
|
||||
|
||||
define('ENABLE_SPAM_PROTECTION', true);
|
||||
define('MAX_MESSAGE_LENGTH', 5000);
|
||||
define('MIN_MESSAGE_LENGTH', 10);
|
||||
|
||||
|
||||
define('DEBUG_MODE', false);
|
||||
define('LOG_EMAILS', true);
|
||||
|
||||
|
||||
define('ADDITIONAL_HEADERS', [
|
||||
'X-Mailer' => 'HexaHost.de Contact Form',
|
||||
'X-Priority' => '3',
|
||||
'X-MSMail-Priority' => 'Normal',
|
||||
'Importance' => 'Normal',
|
||||
'X-Report-Abuse' => 'Please report abuse here: abuse@hexahost.de',
|
||||
'List-Unsubscribe' => '<mailto:unsubscribe@hexahost.de>',
|
||||
'Precedence' => 'bulk'
|
||||
]);
|
||||
|
||||
|
||||
define('ALLOWED_EMAIL_DOMAINS', [
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
]);
|
||||
|
||||
|
||||
define('BLACKLISTED_EMAILS', [
|
||||
|
||||
|
||||
]);
|
||||
|
||||
|
||||
if (!defined('SMTP_HOST') || !defined('SMTP_USERNAME') || !defined('SMTP_PASSWORD')) {
|
||||
die('SMTP-Konfiguration ist unvollständig. Bitte überprüfen Sie die mail-config.php');
|
||||
}
|
||||
if (!filter_var(SMTP_FROM_EMAIL, FILTER_VALIDATE_EMAIL)) {
|
||||
die('Ungültige SMTP_FROM_EMAIL Adresse');
|
||||
}
|
||||
|
||||
if (!filter_var(SMTP_TO_EMAIL, FILTER_VALIDATE_EMAIL)) {
|
||||
die('Ungültige SMTP_TO_EMAIL Adresse');
|
||||
}
|
||||
|
||||
|
||||
function logEmail($type, $data) {
|
||||
if (!LOG_EMAILS) return;
|
||||
|
||||
$logFile = __DIR__ . '/../logs/email.log';
|
||||
$logDir = dirname($logFile);
|
||||
|
||||
if (!is_dir($logDir)) {
|
||||
mkdir($logDir, 0755, true);
|
||||
}
|
||||
|
||||
$timestamp = date('Y-m-d H:i:s');
|
||||
$logEntry = "[$timestamp] $type: " . json_encode($data) . "\n";
|
||||
|
||||
file_put_contents($logFile, $logEntry, FILE_APPEND | LOCK_EX);
|
||||
}
|
||||
|
||||
|
||||
function isValidEmail($email) {
|
||||
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (in_array($email, BLACKLISTED_EMAILS)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (!empty(ALLOWED_EMAIL_DOMAINS)) {
|
||||
$domain = substr(strrchr($email, "@"), 1);
|
||||
if (!in_array($domain, ALLOWED_EMAIL_DOMAINS)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function getHexaHostConfig($key = null) {
|
||||
$config = [
|
||||
|
||||
'smtp_host' => SMTP_HOST,
|
||||
'smtp_port' => SMTP_PORT,
|
||||
'smtp_username' => SMTP_USERNAME,
|
||||
'smtp_password' => SMTP_PASSWORD,
|
||||
'smtp_encryption' => 'tls',
|
||||
'from_email' => SMTP_FROM_EMAIL,
|
||||
'from_name' => 'HexaHost.de Kontaktformular',
|
||||
'to_email' => SMTP_TO_EMAIL,
|
||||
'to_name' => 'HexaHost Support',
|
||||
|
||||
|
||||
'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_mode' => DEBUG_MODE,
|
||||
'log_errors' => LOG_EMAILS,
|
||||
];
|
||||
|
||||
if ($key === null) {
|
||||
return $config;
|
||||
}
|
||||
|
||||
return $config[$key] ?? null;
|
||||
}
|
||||
?>
|
||||
/**
|
||||
* Kompatibilitäts-Wrapper – leitet auf die zentrale Backend-Konfiguration um.
|
||||
*/
|
||||
require_once __DIR__ . '/../../backend/config/mail-config.php';
|
||||
|
||||
Reference in New Issue
Block a user