false, 'error' => 'Система не установлена. Откройте /install'], 503); header('Location: /install/'); exit; } if (($seg[0] ?? '') === 'api') { require APP_DIR . '/api.php'; require APP_DIR . '/image.php'; require APP_DIR . '/fns.php'; api_route($_SERVER['REQUEST_METHOD'], array_slice($seg, 1)); exit; } if (($seg[0] ?? '') === 'legal') { require APP_DIR . '/legal.php'; render_legal($seg[1] ?? 'policy'); exit; } /* Фотографии отдаём через PHP, чтобы каталог uploads можно было закрыть от прямого доступа и не дать выполнить залитый файл. */ if (($seg[0] ?? '') === 'file' && isset($seg[1])) { $name = basename($seg[1]); $full = ROOT_DIR . '/uploads/' . $name; if (!preg_match('/^[\w\-]+\.jpg$/', $name) || !is_file($full)) { http_response_code(404); exit; } header('Content-Type: image/jpeg'); header('Cache-Control: public, max-age=604800'); readfile($full); exit; } /* Всё остальное — одностраничное приложение. */ start_session(); csrf_token(); readfile(ROOT_DIR . '/view/index.html');