generated from jric11/baseProject
16 lines
701 B
PHP
16 lines
701 B
PHP
|
|
<?php
|
||
|
|
/** Router for the local PHP development server; not used by Apache/IIS. */
|
||
|
|
if (PHP_SAPI !== 'cli-server') { http_response_code(404); exit; }
|
||
|
|
$path = rawurldecode(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) ?: '/');
|
||
|
|
if ($path === '/' || $path === '/main.php') {
|
||
|
|
require __DIR__ . '/../main.php';
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
if (preg_match('~\A/(css|js|images)/[A-Za-z0-9_./-]+\.(css|js|png|jpg|jpeg|gif|svg|ico|woff2?|ttf|map)\z~i', $path)) {
|
||
|
|
$file = realpath(__DIR__ . '/..' . $path);
|
||
|
|
$root = realpath(__DIR__ . '/..');
|
||
|
|
if ($file && str_starts_with($file, $root . DIRECTORY_SEPARATOR) && !str_contains($path, '..')) return false;
|
||
|
|
}
|
||
|
|
http_response_code(404);
|
||
|
|
exit('Page not found.');
|