Files

55 lines
1.6 KiB
PHP

<?php
declare(strict_types=1);
/**
* Uruk International Prize - Root Router & Gateway Proxy
* Supports both direct server document root and /backend/public dispatching.
*/
$uri = parse_url($_SERVER['REQUEST_URI'] ?? '/', PHP_URL_PATH);
// 1. Static asset serving (e.g., logo, css, js)
$filePath = __DIR__ . $uri;
if ($uri !== '/' && file_exists($filePath) && !is_dir($filePath)) {
$extension = strtolower(pathinfo($filePath, PATHINFO_EXTENSION));
$mimeTypes = [
'png' => 'image/png',
'jpg' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'svg' => 'image/svg+xml',
'ico' => 'image/x-icon',
'css' => 'text/css',
'js' => 'application/javascript',
'html' => 'text/html; charset=UTF-8',
];
if (isset($mimeTypes[$extension])) {
header('Content-Type: ' . $mimeTypes[$extension]);
readfile($filePath);
exit;
}
}
// 2. If requesting the feasibility presentation or homepage in browser
if ($uri === '/' || $uri === '/feasibility' || $uri === '/docs') {
$htmlDoc = __DIR__ . '/docs/uruk_project_feasibility_and_architecture.html';
if (file_exists($htmlDoc)) {
header('Content-Type: text/html; charset=UTF-8');
readfile($htmlDoc);
exit;
}
}
// 2. Dispatch all API routes and gateway endpoints to backend/public/index.php
$backendIndex = __DIR__ . '/backend/public/index.php';
if (file_exists($backendIndex)) {
require_once $backendIndex;
exit;
}
http_response_code(404);
echo json_encode([
'success' => false,
'error' => 'Core Backend Engine not found.',
]);