BlueGit

projects-timfalken-com verhalenboek

Files

verhalenboek / web / router.php

router.php

feat: voeg Verhalenboek toe met dagen, leesvoortgang en schrijf-API
timfa project_87242033_bot_b167a9be22027ad5a4b431d0ad8426c6 · pushed by timfa · 6 weeks ago
799da657 History
router.php 661 B Download Raw
1<?php
2declare(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;
6if (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}
11if (preg_match('~^/api\.php(?:/|$)~', $rel)) {
12 require __DIR__.'/api.php';
13 return true;
14}
15$full = __DIR__.$rel;
16if ($rel !== '/' && is_file($full)) return false;
17require __DIR__.'/index.php';
18return true;