Files
HexaHost-Frontend/backend/config/site-config.php

82 lines
1.6 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/**
* HexaHost.de zentrale Domain- und Umgebungskonfiguration
*/
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()
{
$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;
}
/**
* true, wenn die Seite unter der Dev-Domain läuft
*
* @return bool
*/
function isDevelopmentSite()
{
return getSiteHost() === SITE_DOMAIN_DEVELOPMENT;
}
/**
* Basis-URL der aktuellen Anfrage (Schema + Host)
*
* @return string
*/
function getSiteBaseUrl()
{
$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 array<int, string>
*/
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',
];
}
/**
* Kanonische Basis-URL für SEO (Produktion immer hexahost.de)
*
* @return string
*/
function getCanonicalBaseUrl()
{
return 'https://' . SITE_DOMAIN_PRODUCTION;
}