'image/jpeg', 'jpeg' => 'image/jpeg', 'png' => 'image/png', 'gif' => 'image/gif', 'webp' => 'image/webp', 'svg' => 'image/svg+xml', 'pdf' => 'application/pdf', 'zip' => 'application/zip', 'mp4' => 'video/mp4', 'webm' => 'video/webm', 'ogg' => 'video/ogg', 'mp3' => 'audio/mpeg', 'wav' => 'audio/wav', 'css' => 'text/css', 'js' => 'application/javascript', ]; if (strpos($path, '/-media/') === 0) { $relative = ltrim(substr($path, 7), '/'); $root = realpath(__DIR__ . '/..'); $filePath = $root . '/content/' . $relative; if (strpos($filePath, $root . '/content') === 0) { $ext = strtolower(pathinfo($filePath, PATHINFO_EXTENSION)); if (in_array($ext, $allowedExt) && file_exists($filePath) && !is_dir($filePath)) { if (isset($mimeTypes[$ext])) { header('Content-Type: ' . $mimeTypes[$ext]); } readfile($filePath); exit; } } http_response_code(404); echo '
Access denied.
'; exit; } // Bot detection — block known bots/AI scrapers early if (RequestLogger::detectBot() !== null) { http_response_code(403); echo 'Access denied.
'; exit; } $cms = new CodePressCMS($config); // Log page view (not for media/assets) if (!str_starts_with($path, '/-media/') && !str_starts_with($path, '/-assets/')) { $requestLogFile = dirname(__DIR__) . '/admin/storage/logs/requests.log'; $logger = new RequestLogger($requestLogFile); $logger->log( $_GET['page'] ?? $config['default_page'] ?? 'index', $_SERVER['HTTP_X_FORWARDED_FOR'] ?? $_SERVER['HTTP_X_REAL_IP'] ?? $_SERVER['REMOTE_ADDR'] ?? 'cli', $_SERVER['HTTP_USER_AGENT'] ?? '', $_SERVER['HTTP_REFERER'] ?? '', $_SERVER['HTTP_HOST'] ?? '', $_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? '' ); } $cms->render();