BlueGit

projects-timfalken-com meteors

Files

meteors / server / router.php

router.php

router.php 690 B Download Raw
1<?php
2declare(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;
7if ($uri !== '/' && is_file($file)) {
8 return false;
9}
10if (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.
15if (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}
21return false;