This commit is contained in:
2025-12-10 01:40:05 +01:00
parent 10cc7b5d30
commit 8b5004b292
14 changed files with 374 additions and 100 deletions

View File

@@ -6,10 +6,19 @@
// APP_COOKIE_PREFIX, APP_COOKIE_DOMAIN, APP_ENV etc.
// -----------------------------------------------------------
// Try to load primary environment bootstrap.
$bootstrapCandidates = [__DIR__ . '/config.php'];
$bootstrapCandidates = [__DIR__ . '/versions.php'];
$envHint = getenv('APP_ENV_FILE') ?: (getenv('APP_ENV') ?: null);
if ($envHint && !preg_match('/^[A-Za-z0-9_\-]+$/', $envHint)) {
$envHint = null;
}
if ($envHint === null) {
if (is_dir(__DIR__ . '/staging')) {
$envHint = 'staging';
} elseif (is_dir(__DIR__ . '/prod')) {
$envHint = 'prod';
}
}
$envHint = getenv('APP_ENV') ?: (getenv('APP_ENV_FILE') ?: null);
$bootstrapCandidates = [__DIR__ . '/config.php'];
if ($envHint) {
$bootstrapCandidates[] = __DIR__ . '/' . $envHint . '/config.php';
}
@@ -18,13 +27,32 @@ foreach ($bootstrapCandidates as $bootstrap) {
if ($bootstrap && is_file($bootstrap)) {
require_once $bootstrap;
$bootstrapLoaded = true;
break;
}
}
if (!$bootstrapLoaded) {
throw new RuntimeException('No environment config found under config/.');
}
$versionFiles = [__DIR__ . '/versions.php'];
if ($envHint) {
$versionFiles[] = __DIR__ . '/' . $envHint . '/versions.php';
}
$versionLoaded = false;
foreach ($versionFiles as $versionFile) {
if ($versionFile && is_file($versionFile)) {
require_once $versionFile;
$versionLoaded = true;
}
}
if (!$versionLoaded) {
$mainversion = $mainversion ?? 1;
$subversion = $subversion ?? 0;
$patchversion = $patchversion ?? 0;
}
$mainversion = (int)($mainversion ?? 1);
$subversion = (int)($subversion ?? 0);
$patchversion = (int)($patchversion ?? 0);
$emailtemplateConfigPath = __DIR__ . '/emailtemplate.conf.php';
if (is_file($emailtemplateConfigPath)) {
$GLOBALS['emailtemplate_config'] = require $emailtemplateConfigPath;
@@ -173,4 +201,4 @@ require_once __DIR__ . '/i18n.php';
// 4) Rest des Systems laden (DB, Funktionen, Hilfs-Libs)
// -----------------------------------------------------------
require_once __DIR__ . "/db.php";
//require_once __DIR__ . '/../src/functions.php';
require_once __DIR__ . '/../inc/helpers.php';