Refactor configuration loading: Updated multiple public PHP files to require a new bootstrap file for configuration management. Adjusted paths for product configuration to enhance maintainability and consistency across the application.
This commit is contained in:
68
backend/config/site-config.php
Normal file
68
backend/config/site-config.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
/**
|
||||
* HexaHost.de – zentrale Domain- und Umgebungskonfiguration
|
||||
*/
|
||||
|
||||
define('SITE_DOMAIN_PRODUCTION', 'hexahost.de');
|
||||
define('SITE_DOMAIN_DEVELOPMENT', 'dev.hexahost.de');
|
||||
|
||||
/**
|
||||
* Aktuellen HTTP-Host (ohne Port) ermitteln
|
||||
*/
|
||||
function getSiteHost(): string
|
||||
{
|
||||
$host = $_SERVER['HTTP_HOST'] ?? SITE_DOMAIN_PRODUCTION;
|
||||
$host = strtolower($host);
|
||||
|
||||
if (str_contains($host, ':')) {
|
||||
$host = explode(':', $host, 2)[0];
|
||||
}
|
||||
|
||||
return $host;
|
||||
}
|
||||
|
||||
/**
|
||||
* true, wenn die Seite unter der Dev-Domain läuft
|
||||
*/
|
||||
function isDevelopmentSite(): bool
|
||||
{
|
||||
return getSiteHost() === SITE_DOMAIN_DEVELOPMENT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Basis-URL der aktuellen Anfrage (Schema + Host)
|
||||
*/
|
||||
function getSiteBaseUrl(): string
|
||||
{
|
||||
$https = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off')
|
||||
|| (isset($_SERVER['SERVER_PORT']) && (int) $_SERVER['SERVER_PORT'] === 443);
|
||||
|
||||
$scheme = $https ? 'https' : 'http';
|
||||
|
||||
return $scheme . '://' . getSiteHost();
|
||||
}
|
||||
|
||||
/**
|
||||
* Erlaubte CORS-Origins für AJAX (Kontaktformular)
|
||||
*
|
||||
* @return list<string>
|
||||
*/
|
||||
function getAllowedOrigins(): array
|
||||
{
|
||||
return [
|
||||
'https://' . SITE_DOMAIN_PRODUCTION,
|
||||
'https://www.' . SITE_DOMAIN_PRODUCTION,
|
||||
'https://' . SITE_DOMAIN_DEVELOPMENT,
|
||||
'http://localhost',
|
||||
'http://127.0.0.1',
|
||||
'http://localhost:8000',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Kanonische Basis-URL für SEO (Produktion immer hexahost.de)
|
||||
*/
|
||||
function getCanonicalBaseUrl(): string
|
||||
{
|
||||
return 'https://' . SITE_DOMAIN_PRODUCTION;
|
||||
}
|
||||
Reference in New Issue
Block a user