38471-vm/page_bootstrap.php
2026-05-03 09:09:47 +00:00

38 lines
1012 B
PHP

<?php
declare(strict_types=1);
$routeHelpersPath = __DIR__ . '/includes/page_routes.php';
if (is_file($routeHelpersPath)) {
require_once $routeHelpersPath;
}
if (!defined('APP_PAGE')) {
http_response_code(500);
exit('Route bootstrap is missing APP_PAGE.');
}
if (
function_exists('page_request_is_ajax')
&& function_exists('page_normalize_url')
&& PHP_SAPI !== 'cli'
&& strtoupper((string)($_SERVER['REQUEST_METHOD'] ?? 'GET')) === 'GET'
&& !page_request_is_ajax()
&& isset($_GET['page'])
) {
$requestUri = (string)($_SERVER['REQUEST_URI'] ?? '');
$normalized = page_normalize_url($requestUri);
if ($normalized !== '' && $normalized !== $requestUri) {
header('Location: ' . $normalized, true, 302);
exit;
}
}
define('APP_ROUTE_BOOTSTRAP', true);
if (function_exists('set_route_page_context')) {
set_route_page_context(APP_PAGE);
} else {
$_GET['page'] = APP_PAGE;
$_REQUEST['page'] = APP_PAGE;
}
require __DIR__ . '/index.php';