mirror of
https://git.hexahost.dev/smueller/HexaHost-Frontend.git
synced 2026-06-02 08:08:43 +00:00
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:
@@ -14,4 +14,4 @@
|
||||
|
||||
// Lade die neue Konfiguration
|
||||
require_once __DIR__ . '/mail-config.php';
|
||||
?>
|
||||
|
||||
|
||||
@@ -195,4 +195,3 @@ function getHexaHostConfig($key = null) {
|
||||
|
||||
return $config[$key] ?? null;
|
||||
}
|
||||
?>
|
||||
@@ -553,4 +553,4 @@ function renderAllPackages($productId) {
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,62 @@ $configDir = defined('HEXAHOST_CONFIG_DIR')
|
||||
? HEXAHOST_CONFIG_DIR
|
||||
: __DIR__ . '/../config';
|
||||
|
||||
require_once $configDir . '/site-config.php';
|
||||
$siteConfigFile = $configDir . '/site-config.php';
|
||||
if (is_file($siteConfigFile)) {
|
||||
require_once $siteConfigFile;
|
||||
} elseif (!function_exists('getSiteHost')) {
|
||||
define('SITE_DOMAIN_PRODUCTION', 'hexahost.de');
|
||||
define('SITE_DOMAIN_DEVELOPMENT', 'dev.hexahost.de');
|
||||
|
||||
function getSiteHost()
|
||||
{
|
||||
$host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : SITE_DOMAIN_PRODUCTION;
|
||||
$host = strtolower($host);
|
||||
if (strpos($host, ':') !== false) {
|
||||
$host = explode(':', $host, 2)[0];
|
||||
}
|
||||
return $host;
|
||||
}
|
||||
|
||||
function isDevelopmentSite()
|
||||
{
|
||||
return getSiteHost() === SITE_DOMAIN_DEVELOPMENT;
|
||||
}
|
||||
|
||||
function getSiteBaseUrl()
|
||||
{
|
||||
$https = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off')
|
||||
|| (isset($_SERVER['SERVER_PORT']) && (int) $_SERVER['SERVER_PORT'] === 443);
|
||||
return ($https ? 'https' : 'http') . '://' . getSiteHost();
|
||||
}
|
||||
|
||||
function getAllowedOrigins()
|
||||
{
|
||||
return [
|
||||
'https://' . SITE_DOMAIN_PRODUCTION,
|
||||
'https://www.' . SITE_DOMAIN_PRODUCTION,
|
||||
'https://' . SITE_DOMAIN_DEVELOPMENT,
|
||||
'http://localhost',
|
||||
'http://127.0.0.1',
|
||||
'http://localhost:8000',
|
||||
];
|
||||
}
|
||||
|
||||
function getCanonicalBaseUrl()
|
||||
{
|
||||
return 'https://' . SITE_DOMAIN_PRODUCTION;
|
||||
}
|
||||
}
|
||||
|
||||
// Fehleranzeige auf Dev/localhost für einfacheres Debugging
|
||||
$hexahostHost = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '';
|
||||
if (
|
||||
(function_exists('isDevelopmentSite') && isDevelopmentSite())
|
||||
|| preg_match('/^(localhost|127\.0\.0\.1)(:\d+)?$/', $hexahostHost)
|
||||
) {
|
||||
ini_set('display_errors', '1');
|
||||
ini_set('display_startup_errors', '1');
|
||||
}
|
||||
|
||||
// Sichere Session-Konfiguration
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
@@ -106,4 +161,3 @@ function generateCSRFToken() {
|
||||
}
|
||||
return $_SESSION['csrf_token'];
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user