<?php
declare(strict_types=1);
// Router voor de lokale PHP-server. Productie gebruikt de echte bestanden en .htaccess.
$path = rawurldecode(parse_url($_SERVER['REQUEST_URI'] ?? '/', PHP_URL_PATH) ?? '/');
$rel = $path === '' ? '/' : $path;
if (preg_match('~(?:^|/)(?:data|lib|tests|\.[^/]*)(?:/|$)|(?:README\.md|router\.php)$~i', $rel)) {
    http_response_code(403);
    header('Content-Type: text/plain; charset=utf-8');
    exit('Verboden');
}
if (preg_match('~^/api\.php(?:/|$)~', $rel)) {
    require __DIR__.'/api.php';
    return true;
}
$full = __DIR__.$rel;
if ($rel !== '/' && is_file($full)) {
    if (str_ends_with(strtolower($rel), '.webmanifest')) {
        header('Content-Type: application/manifest+json; charset=utf-8');
        header('Cache-Control: no-cache');
        readfile($full);
        return true;
    }
    return false;
}
require __DIR__.'/index.php';
return true;
