parseCleanURL(); $currentPath = ltrim($currentPath, '/'); $currentPath = str_replace(['../', './'], '', $currentPath); $fullPath = $baseDir . '/' . $currentPath; $webCurrentPath = '/files' . ($currentPath ? '/' . $currentPath : ''); $config = loadConfiguration(); $disableFileDownloads = isset($config['main']['disable_file_downloads']) ? $config['main']['disable_file_downloads'] : false; $disableFolderDownloads = isset($config['main']['disable_folder_downloads']) ? $config['main']['disable_folder_downloads'] : false; $iconType = isset($config['main']['icon_type']) ? $config['main']['icon_type'] : 'default'; $denyList = parseDenyAllowList(isset($config['main']['deny_list']) ? $config['main']['deny_list'] : ''); $allowList = parseDenyAllowList(isset($config['main']['allow_list']) ? $config['main']['allow_list'] : ''); $conflictingRules = findConflictingRules($denyList, $allowList); $cacheInstance = initializeCache(); if (!empty($currentPath)) { if ($router->isFileRequest($currentPath)) { $router->handleFileRequest($currentPath); exit; } if ($router->isFolderRequest($currentPath)) { if (isset($_GET['download']) && $_GET['download'] === 'archive') { $router->handleFolderRequest($currentPath); exit; } $router->handleFolderRequest($currentPath); } else { http_response_code(404); exit('Path not found'); } } function getSecurityStatus() { global $config; $isHttps = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443 || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https'); $hostname = ''; if (isset($config['main']['access_url']) && !empty($config['main']['access_url'])) { $parsedUrl = parse_url($config['main']['access_url']); $hostname = $parsedUrl['host'] ?? $_SERVER['HTTP_HOST']; } else { $hostname = $_SERVER['HTTP_HOST']; } return [ 'secure' => $isHttps, 'hostname' => $hostname ]; } function getVersionInfo() { global $config, $indexerFilesDir; static $versionInfo = null; if ($versionInfo !== null) { return $versionInfo; } $currentVersion = $config['version'] ?? null; $cache = initializeCache(); $cachedVersionData = $cache->getVersionInfo(); if ($cachedVersionData !== null) { $versionInfo = [ 'current' => $currentVersion, 'remote' => $cachedVersionData['remote_version'], 'type' => $cachedVersionData['installation_type'] ]; return $versionInfo; } // CRITICAL: Don't check on every request - only return cached or nothing // Let a cron job or manual check update this instead $installationType = file_exists($indexerFilesDir . '/.docker') ? 'docker' : (file_exists($indexerFilesDir . '/.script') ? 'script' : 'manual'); $versionInfo = [ 'current' => $currentVersion, 'remote' => null, 'type' => $installationType ]; return $versionInfo; } function generateUpdateNotice() { $info = getVersionInfo(); if (!$info['remote'] || !version_compare($info['current'], $info['remote'], '<')) { return ''; } $instructions = [ 'docker' => 'Update using Docker: Pull the latest image and restart your container.', 'script' => 'Update using the installation script: Run "5q12-index update".', 'manual' => 'Manual installation: Download and replace files manually from the repository.' ]; $changelogUrl = 'https://ccls.icu/src/repositories/5q12-indexer/releases/latest/changelog.md/?view=default'; return '