declare(strict_types=1); if (isset($_SERVER['REQUEST_URI']) && is_string($_SERVER['REQUEST_URI']) && str_starts_with($_SERVER['REQUEST_URI'], '//') ) { $_SERVER['REQUEST_URI'] = '/' . ltrim($_SERVER['REQUEST_URI'], '/'); } if (PHP_SAPI === 'cli-server') { $requestUri = parse_url($_SERVER['REQUEST_URI'] ?? '/', PHP_URL_PATH); $filePath = __DIR__ . $requestUri; if ($requestUri !== '/' && is_file($filePath)) { $ext = pathinfo($filePath, PATHINFO_EXTENSION); if ($ext !== 'php') { return false; } require $filePath; return; } } $lockFile = dirname(__DIR__) . '/data/install-lock.php'; $__rawUri = parse_url($_SERVER['REQUEST_URI'] ?? '/', PHP_URL_PATH) ?: '/'; $__isCompletePath = (bool) preg_match('#(^|/)install/complete/?$#', $__rawUri); if (!file_exists($lockFile) || $__isCompletePath) { $uri = $_SERVER['REQUEST_URI'] ?? '/'; $script = (string) ($_SERVER['SCRIPT_NAME'] ?? ''); $basePath = rtrim(str_replace('\\', '/', dirname($script)), '/'); if (str_ends_with($basePath, '/public')) { $basePath = substr($basePath, 0, -strlen('/public')); } elseif (str_ends_with($basePath, '/install')) { $basePath = substr($basePath, 0, -strlen('/install')); } if ($basePath === '/') { $basePath = ''; } $relUri = $uri; if ($basePath !== '' && str_starts_with($relUri, $basePath)) { $relUri = substr($relUri, strlen($basePath)) ?: '/'; } if (strpos($relUri, '/install') !== 0 && !preg_match('/\.(css|js|map|png|jpg|jpeg|gif|svg|ico|webp|avif|woff2?|ttf|otf|json|xml|txt|webmanifest)$/i', $relUri)) { header('Location: ' . ($basePath === '' ? '/install' : $basePath . '/install')); exit; } if (strpos($relUri, '/install') === 0) { $installerEntry = dirname(__DIR__) . '/install/index.php'; if (is_file($installerEntry)) { require $installerEntry; return; } } } require __DIR__ . '/../src/bootstrap.php'; $app = new \App\System\Application(dirname(__DIR__)); $kernel = $app->make(\App\System\Kernel::class); $response = $kernel->handle(\App\System\Http\Request::capture()); $response->send(); $kernel->terminate($response); $__rbStatus = $response->getStatusCode(); $__rbPath = parse_url($_SERVER['REQUEST_URI'] ?? '/', PHP_URL_PATH) ?: '/'; $__rbSkipCron = $__rbStatus >= 400 || preg_match('/\.(css|js|mjs|map|png|jpe?g|gif|svg|ico|webp|avif|woff2?|ttf|otf|json|xml|txt|webmanifest)$/i', $__rbPath) === 1 || \App\System\BotDetector::isBot($_SERVER['HTTP_USER_AGENT'] ?? null); if (!$__rbSkipCron) { \App\System\WebCron::tick(dirname(__DIR__)); }