Initial commit of simple php site.

This commit is contained in:
2026-05-22 13:02:57 +02:00
parent 96419b9f81
commit b2b00df260
11 changed files with 129 additions and 7 deletions
+43
View File
@@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
// --- Security headers ---
header_remove('X-Powered-By');
header('X-Frame-Options: DENY');
header('X-Content-Type-Options: nosniff');
header('Referrer-Policy: strict-origin-when-cross-origin');
header('Content-Security-Policy: default-src \'self\'');
// --- Routing ---
$uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
if ($uri === false || $uri === null) {
http_response_code(400);
exit;
}
$routes = [
'/' => 'web/pages/home.php',
'/about' => 'web/pages/about.php',
];
$base = realpath(ROOT . '/web/pages');
if ($base === false) {
http_response_code(500);
exit;
}
if (array_key_exists($uri, $routes)) {
$real = realpath(ROOT . '/' . $routes[$uri]);
if ($real !== false && str_starts_with($real, $base . DIRECTORY_SEPARATOR)) {
require $real;
} else {
http_response_code(403);
exit;
}
} else {
http_response_code(404);
require ROOT . '/web/pages/404.php';
}