- Alle Module nach /modules/ verschoben (dinos, plants, storymachine, test, _template) - .htaccess transparentes Routing fuer /modules/ eingerichtet - ModuleService Auto-Discovery auf /modules/ Verzeichnis angepasst - Original Web Audio Synthese (playOrganicFart) und Furzkissen-UI in modules/test/index.php wiederhergestellt - AGENTS.md Dokumentation aktualisiert
64 lines
2.1 KiB
PHP
64 lines
2.1 KiB
PHP
<?php
|
|
/**
|
|
* Modul-Bootstrap für test
|
|
*/
|
|
if (session_status() === PHP_SESSION_NONE) {
|
|
session_start();
|
|
}
|
|
|
|
$authCandidates = [
|
|
__DIR__ . '/../../auth.php',
|
|
__DIR__ . '/../auth.php'
|
|
];
|
|
foreach ($authCandidates as $authPath) {
|
|
if (file_exists($authPath) && php_sapi_name() !== 'cli') {
|
|
$current_project = basename(__DIR__);
|
|
require_once $authPath;
|
|
break;
|
|
}
|
|
}
|
|
|
|
$currentUser = $_SESSION['user_email'] ?? 'Gast / Standalone';
|
|
$isAdmin = !empty($_SESSION['is_admin']);
|
|
|
|
if (!function_exists('module_env')) {
|
|
function module_env(string $key, ?string $default = null): ?string {
|
|
static $envCache = null;
|
|
if ($envCache === null) {
|
|
$envCache = [];
|
|
$candidates = [
|
|
__DIR__ . '/.env',
|
|
__DIR__ . '/../../home/.env',
|
|
__DIR__ . '/../home/.env',
|
|
__DIR__ . '/../../.env',
|
|
__DIR__ . '/../.env'
|
|
];
|
|
foreach ($candidates as $file) {
|
|
if (file_exists($file)) {
|
|
$lines = file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
|
if ($lines !== false) {
|
|
foreach ($lines as $line) {
|
|
$line = trim($line);
|
|
if ($line === '' || $line[0] === '#') continue;
|
|
if (strpos($line, '=') !== false) {
|
|
list($k, $v) = explode('=', $line, 2);
|
|
$cleanKey = trim($k);
|
|
if (!isset($envCache[$cleanKey])) {
|
|
$envCache[$cleanKey] = trim(trim($v), '"\'');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (isset($envCache[$key])) {
|
|
return $envCache[$key];
|
|
}
|
|
$sysEnv = getenv($key);
|
|
if ($sysEnv !== false && $sysEnv !== '') {
|
|
return $sysEnv;
|
|
}
|
|
return $_ENV[$key] ?? $default;
|
|
}
|
|
}
|