mirror of
https://git.hexahost.dev/smueller/HexaHost-Frontend.git
synced 2026-06-02 09:58:42 +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:
@@ -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