Enhance configuration management: Updated README.md with Windows sync instructions, refactored backend configuration files to improve loading logic, and ensured consistent function definitions. Improved error handling in bootstrap.php for better user feedback during application startup.

This commit is contained in:
smueller
2026-05-22 14:07:27 +02:00
parent 96a5977283
commit 8afba16905
15 changed files with 1433 additions and 37 deletions

View File

@@ -14,4 +14,4 @@
// Lade die neue Konfiguration
require_once __DIR__ . '/mail-config.php';
?>

View File

@@ -195,4 +195,3 @@ function getHexaHostConfig($key = null) {
return $config[$key] ?? null;
}
?>

View File

@@ -553,4 +553,4 @@ function renderAllPackages($productId) {
}
return $html;
}
?>

View File

@@ -3,18 +3,25 @@
* HexaHost.de zentrale Domain- und Umgebungskonfiguration
*/
define('SITE_DOMAIN_PRODUCTION', 'hexahost.de');
define('SITE_DOMAIN_DEVELOPMENT', 'dev.hexahost.de');
if (!defined('SITE_DOMAIN_PRODUCTION')) {
define('SITE_DOMAIN_PRODUCTION', 'hexahost.de');
}
if (!defined('SITE_DOMAIN_DEVELOPMENT')) {
define('SITE_DOMAIN_DEVELOPMENT', 'dev.hexahost.de');
}
/**
* Aktuellen HTTP-Host (ohne Port) ermitteln
*
* @return string
*/
function getSiteHost(): string
function getSiteHost()
{
$host = $_SERVER['HTTP_HOST'] ?? SITE_DOMAIN_PRODUCTION;
$host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : SITE_DOMAIN_PRODUCTION;
$host = strtolower($host);
if (str_contains($host, ':')) {
if (strpos($host, ':') !== false) {
$host = explode(':', $host, 2)[0];
}
@@ -23,16 +30,20 @@ function getSiteHost(): string
/**
* true, wenn die Seite unter der Dev-Domain läuft
*
* @return bool
*/
function isDevelopmentSite(): bool
function isDevelopmentSite()
{
return getSiteHost() === SITE_DOMAIN_DEVELOPMENT;
}
/**
* Basis-URL der aktuellen Anfrage (Schema + Host)
*
* @return string
*/
function getSiteBaseUrl(): string
function getSiteBaseUrl()
{
$https = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off')
|| (isset($_SERVER['SERVER_PORT']) && (int) $_SERVER['SERVER_PORT'] === 443);
@@ -45,9 +56,9 @@ function getSiteBaseUrl(): string
/**
* Erlaubte CORS-Origins für AJAX (Kontaktformular)
*
* @return list<string>
* @return array<int, string>
*/
function getAllowedOrigins(): array
function getAllowedOrigins()
{
return [
'https://' . SITE_DOMAIN_PRODUCTION,
@@ -61,8 +72,10 @@ function getAllowedOrigins(): array
/**
* Kanonische Basis-URL für SEO (Produktion immer hexahost.de)
*
* @return string
*/
function getCanonicalBaseUrl(): string
function getCanonicalBaseUrl()
{
return 'https://' . SITE_DOMAIN_PRODUCTION;
}