$message]); } header('Cache-Control: no-store'); $host = $_SERVER['HTTP_HOST'] ?? ''; if (!preg_match('/\A[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?(?::[0-9]{1,5})?\z/i', $host)) { failRequest(400, 'Invalid HTTP host'); return; } if (($_SERVER['REQUEST_METHOD'] ?? '') !== 'GET') { header('Allow: GET'); failRequest(405, 'Only GET is supported'); return; } $runtime = getenv('EZSERVER_RUNTIME'); $path = parse_url($_SERVER['REQUEST_URI'] ?? '/', PHP_URL_PATH); if ($path === '/') { header('Content-Type: text/html; charset=utf-8'); readfile($runtime . '/index.html'); return; } $patientLookup = getenv('EZSERVER_SQLITE') && preg_match('~\A/api(?:/index\.php)?/v1/e2ds/patientsbychartno/?\z~i', $path ?? ''); if (!$patientLookup && !preg_match('~\A/api(?:/index\.php)?(?:/v1/(?:auth/ping|info/(?:versions|versionsbyname(?:/name/[^/]+)?)))?/?\z~i', $path ?? '')) { failRequest(404, 'Route is unavailable in the macOS preview'); return; } $public = $runtime . '/www/ezwebserver/src/public'; $_SERVER['DOCUMENT_ROOT'] = $public; $_SERVER['SCRIPT_FILENAME'] = $public . '/api/index.php'; $_SERVER['SCRIPT_NAME'] = '/api/index.php'; $_SERVER['PHP_SELF'] = '/api/index.php'; $_SERVER['CI_ENV'] = 'production'; chdir($public . '/api'); require $_SERVER['SCRIPT_FILENAME'];