(string)$user, 'pass' => (string)$pass, 'path' => $path]; } $cfg = load_config($basePath); $USERNAME = $cfg['user']; $PASSWORD = $cfg['pass']; // ===== Login / Logout Handling ===== if (isset($_GET['logout'])) { $_SESSION = []; if (ini_get("session.use_cookies")) { $params = session_get_cookie_params(); setcookie(session_name(), '', time()-42000, $params["path"], $params["domain"], $params["secure"], $params["httponly"]); } session_destroy(); header("Location: ".$baseUrl."/"); exit; } $errors = []; if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['login'])) { $u = $_POST['user'] ?? ''; $p = $_POST['pass'] ?? ''; // hash_equals verhindert Timing-Angriffe if (hash_equals($USERNAME, $u) && hash_equals($PASSWORD, $p)) { session_regenerate_id(true); $_SESSION['auth'] = true; header("Location: ".$baseUrl."/"); exit; } else { $errors[] = "Login fehlgeschlagen."; } } $authed = ($_SESSION['auth'] ?? false) === true; // ===== Verzeichnisse scannen ===== $apps = []; if ($authed) { foreach (glob($basePath . '/*', GLOB_ONLYDIR) as $dirPath) { $name = basename($dirPath); // Ordner, die NICHT im Menü erscheinen if (in_array($name, ['vendor', '.git', '.well-known', 'config'], true)) continue; $iconRel = $name . '/icon.png'; $iconAbs = $basePath . '/' . $iconRel; $hasIcon = is_file($iconAbs); $apps[] = [ 'name' => $name, 'url' => ($baseUrl ? $baseUrl : '') . '/' . rawurlencode($name) . '/', 'icon' => $hasIcon ? (($baseUrl ? $baseUrl : '') . '/' . $iconRel . '?v=' . filemtime($iconAbs)) : null, ]; } usort($apps, fn($a, $b) => strcasecmp($a['name'], $b['name'])); } ?>
/experiment1) und optional ein icon.png hinein.