From d5ecbed2db322ec3d3962ef920329ee1aa893c86 Mon Sep 17 00:00:00 2001 From: Lars Gebhardt-Kusche Date: Mon, 2 Feb 2026 23:44:38 +0100 Subject: [PATCH] debug --- config/current.ver | 2 +- config/emailtemplate.conf.php | 14 ++++++++++++++ config/fileload.php | 16 ++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/config/current.ver b/config/current.ver index bb7a48b..67eb680 100644 --- a/config/current.ver +++ b/config/current.ver @@ -1 +1 @@ -1.2.11 \ No newline at end of file +1.2.12 \ No newline at end of file diff --git a/config/emailtemplate.conf.php b/config/emailtemplate.conf.php index 428e025..4dce39b 100644 --- a/config/emailtemplate.conf.php +++ b/config/emailtemplate.conf.php @@ -25,6 +25,20 @@ if (!$bootstrapLoaded) { $overrides = $GLOBALS['EMAILTEMPLATE_OVERRIDES'] ?? []; $env = (string)($overrides['env'] ?? (defined('APP_ENV') ? APP_ENV : (getenv('APP_ENV') ?: 'local'))); +$host = ''; +if (!empty($_SERVER['HTTP_X_FORWARDED_HOST'])) { + $host = strtolower(trim(explode(',', (string)$_SERVER['HTTP_X_FORWARDED_HOST'])[0])); +} elseif (!empty($_SERVER['HTTP_HOST'])) { + $host = strtolower((string)$_SERVER['HTTP_HOST']); +} +if ($host !== '') { + $host = preg_replace('/:\\d+$/', '', $host); + if ($host === 'staging.emailtemplate.it') { + $env = 'staging'; + } elseif (preg_match('/(^|\\.)emailtemplate\\.it$/', $host)) { + $env = 'prod'; + } +} $baseUrl = (string)($overrides['base_url'] ?? (defined('APP_URL_PRIMARY') ? APP_URL_PRIMARY : (getenv('APP_BASE_URL') ?: ''))); $cookieDomainDefault = (string)($overrides['cookie_domain'] ?? ($overrides['auth']['cookie_domain'] ?? (defined('APP_COOKIE_DOMAIN') ? APP_COOKIE_DOMAIN : (defined('APP_DOMAIN_PRIMARY') ? '.' . APP_DOMAIN_PRIMARY : '')))); $sessionNameDefault = (string)($overrides['session_name'] ?? ($overrides['auth']['session_name'] ?? (defined('APP_COOKIE_PREFIX') ? APP_COOKIE_PREFIX . 'session' : 'et_session'))); diff --git a/config/fileload.php b/config/fileload.php index ef10cb7..3224aac 100644 --- a/config/fileload.php +++ b/config/fileload.php @@ -10,6 +10,22 @@ $envHint = getenv('APP_ENV_FILE') ?: (getenv('APP_ENV') ?: null); if ($envHint && !preg_match('/^[A-Za-z0-9_\-]+$/', $envHint)) { $envHint = null; } +if ($envHint === null) { + $host = ''; + if (!empty($_SERVER['HTTP_X_FORWARDED_HOST'])) { + $host = strtolower(trim(explode(',', (string)$_SERVER['HTTP_X_FORWARDED_HOST'])[0])); + } elseif (!empty($_SERVER['HTTP_HOST'])) { + $host = strtolower((string)$_SERVER['HTTP_HOST']); + } + if ($host !== '') { + $host = preg_replace('/:\\d+$/', '', $host); + if ($host === 'staging.emailtemplate.it') { + $envHint = 'staging'; + } elseif (preg_match('/(^|\\.)emailtemplate\\.it$/', $host)) { + $envHint = 'prod'; + } + } +} if ($envHint === null) { if (is_dir(__DIR__ . '/staging')) { $envHint = 'staging';