Publiczna aplikacja fdmtech.pl: renderer CMS, formularz audytu, szablony i logotypy
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
// PHP built-in server router: expose only real assets under public/assets.
|
||||
if (PHP_SAPI === 'cli-server') {
|
||||
$path = explode('?', $_SERVER['REQUEST_URI'] ?? '/', 2)[0];
|
||||
$assetRoot = realpath(__DIR__ . '/assets');
|
||||
$asset = realpath(__DIR__ . $path);
|
||||
if ($assetRoot && $asset && str_starts_with($path, '/assets/') && str_starts_with($asset, $assetRoot . DIRECTORY_SEPARATOR)
|
||||
&& is_file($asset) && preg_match('/\.(?:css|js|png|jpe?g|webp|gif|svg|ico|woff2?)$/i', $asset)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
require dirname(__DIR__) . '/app/bootstrap.php';
|
||||
|
||||
ini_set('display_errors', '0');
|
||||
try {
|
||||
$config = \FDMTech\Config::load(dirname(__DIR__));
|
||||
ini_set('session.use_strict_mode', '1');
|
||||
ini_set('session.use_only_cookies', '1');
|
||||
session_name('fdmtech_session');
|
||||
session_set_cookie_params(['lifetime' => 0, 'path' => '/', 'secure' => $config->bool('SESSION_SECURE', true),
|
||||
'httponly' => true, 'samesite' => 'Lax']);
|
||||
if (!session_start()) {
|
||||
throw new RuntimeException('Session storage unavailable');
|
||||
}
|
||||
$response = (new \FDMTech\Application($config))->handle($_SERVER, $_POST, $_SESSION);
|
||||
session_write_close();
|
||||
$response->send(($_SERVER['REQUEST_METHOD'] ?? '') === 'HEAD');
|
||||
} catch (Throwable $error) {
|
||||
error_log('FDMTech bootstrap failure [' . $error::class . ']');
|
||||
(new \FDMTech\Response(503, '<!doctype html><html lang="pl"><meta charset="utf-8"><title>Serwis niedostępny</title><h1>Serwis jest chwilowo niedostępny</h1></html>',
|
||||
['Content-Type' => 'text/html; charset=UTF-8', 'Cache-Control' => 'no-store', 'Retry-After' => '60',
|
||||
'Content-Security-Policy' => "default-src 'none'; frame-ancestors 'none'; base-uri 'none'", 'X-Robots-Tag' => 'noindex, nofollow']))
|
||||
->send(($_SERVER['REQUEST_METHOD'] ?? '') === 'HEAD');
|
||||
}
|
||||
Reference in New Issue
Block a user