status : ($e instanceof InvalidArgumentException ? 422 : 500); $message = $status < 500 ? $e->getMessage() : 'The application could not complete this request. Please try again later.'; if ($e instanceof PDOException && $e->getCode() === '23000') { $status = 409; $message = 'This record already exists or is still referenced by another record.'; } if ($status >= 500) error_log((string) $e); http_response_code($status); if (strtolower($_SERVER['HTTP_X_REQUESTED_WITH'] ?? '') === 'xmlhttprequest') { header('Content-Type: application/json'); echo json_encode(['ok' => false, 'error' => $message]); } else { header('Content-Type: text/html; charset=UTF-8'); echo 'Request could not be completed

Request could not be completed

' . htmlspecialchars($message, ENT_QUOTES, 'UTF-8') . '

Return to the application

'; } }); require_once __DIR__ . '/classes/Base.php'; $application = new Base(); $https = Transport::https($_SERVER, getenv('HCR_TRUSTED_PROXIES') ?: ''); header("Content-Security-Policy: default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self'; connect-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'"); header('Permissions-Policy: camera=(), microphone=(), geolocation=()'); if ($https && (string) $application->getSettings()->Environment === 'Production') header('Strict-Transport-Security: max-age=31536000'); if ((string) $application->getSettings()->Environment === 'Production' && !$https) { http_response_code(400); exit('HTTPS is required. Open the secure application URL.'); } ini_set('session.use_strict_mode', '1'); ini_set('session.use_only_cookies', '1'); session_name('HUNTINGCLUBROSTER'); session_set_cookie_params([ 'lifetime' => 0, 'path' => '/', 'secure' => $https, 'httponly' => true, 'samesite' => 'Lax', ]); session_start(); $application->do();