| 1 | <?php |
| 2 | declare(strict_types=1); |
| 3 | // Router voor de lokale PHP-server. Productie gebruikt de echte bestanden en .htaccess. |
| 4 | $path = rawurldecode(parse_url($_SERVER['REQUEST_URI'] ?? '/', PHP_URL_PATH) ?? '/'); |
| 5 | $rel = $path === '' ? '/' : $path; |
| 6 | if (preg_match('~(?:^|/)(?:data|lib|tests|\.[^/]*)(?:/|$)|(?:README\.md|router\.php)$~i', $rel)) { |
| 7 | http_response_code(403); |
| 8 | header('Content-Type: text/plain; charset=utf-8'); |
| 9 | exit('Verboden'); |
| 10 | } |
| 11 | if (preg_match('~^/api\.php(?:/|$)~', $rel)) { |
| 12 | require __DIR__.'/api.php'; |
| 13 | return true; |
| 14 | } |
| 15 | $full = __DIR__.$rel; |
| 16 | if ($rel !== '/' && is_file($full)) return false; |
| 17 | require __DIR__.'/index.php'; |
| 18 | return true; |
projects-timfalken-com verhalenboek