| 1 | <?php |
| 2 | declare(strict_types=1); |
| 3 | // Router for PHP's built-in server: php -S 127.0.0.1:8080 -t build server/router.php |
| 4 | // (copied to build/router.php; the -t directory is the docroot). |
| 5 | $uri = urldecode(parse_url($_SERVER['REQUEST_URI'] ?? '/', PHP_URL_PATH) ?? '/'); |
| 6 | $file = __DIR__ . $uri; |
| 7 | if ($uri !== '/' && is_file($file)) { |
| 8 | return false; |
| 9 | } |
| 10 | if (str_ends_with($uri, '.php') && is_file($file)) { |
| 11 | require $file; |
| 12 | return true; |
| 13 | } |
| 14 | // Fall through to index.html for the game UI. |
| 15 | if (is_file(__DIR__ . '/index.html')) { |
| 16 | header('Content-Type: text/html; charset=utf-8'); |
| 17 | header('Cache-Control: no-cache'); |
| 18 | readfile(__DIR__ . '/index.html'); |
| 19 | return true; |
| 20 | } |
| 21 | return false; |
projects-timfalken-com meteors