View Source
The actual code behind this page. No minification. No transpilation. What you see is what runs.
|
| /** |
| * PHP built-in server router. |
| * Strips the BASE_PATH prefix and dispatches to the correct file in public/. |
| */ |
| $base = rtrim(getenv('BASE_PATH') ?: '/dispelled-php', '/'); |
| $uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); |
| // Strip base prefix |
| if ($base !== '' && str_starts_with($uri, $base)) { |
| $path = substr($uri, strlen($base)); |
| } else { |
| $path = $uri; |
| } |
| if ($path === '' || $path === '/') { |
| $path = '/index.php'; |
| } |
| $file = __DIR__ . '/public' . $path; |
| if (is_file($file)) { |
| $ext = pathinfo($file, PATHINFO_EXTENSION); |
| if ($ext === 'php') { |
| include $file; |
| } else { |
| // Serve static assets (CSS, images, etc.) |
| $mimes = [ |
| 'css' => 'text/css', |
| 'js' => 'application/javascript', |
| 'png' => 'image/png', |
| 'jpg' => 'image/jpeg', |
| 'jpeg' => 'image/jpeg', |
| 'gif' => 'image/gif', |
| 'svg' => 'image/svg+xml', |
| 'ico' => 'image/x-icon', |
| 'woff2'=> 'font/woff2', |
| ]; |
| header('Content-Type: ' . ($mimes[$ext] ?? 'application/octet-stream')); |
| readfile($file); |
| } |
| exit; |
| } |
| http_response_code(404); |
| echo '<!DOCTYPE html><html><body><h1>404 Not Found</h1></body></html>'; |
dispelled