mirror of
https://git.hexahost.dev/smueller/HexaHost-Frontend.git
synced 2026-06-02 06:58:43 +00:00
69 lines
1.5 KiB
PHP
69 lines
1.5 KiB
PHP
<?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;
|
||
}
|