Files
huntingclubroster/main.php
T

40 lines
2.3 KiB
PHP
Raw Normal View History

2026-10-18 17:01:36 +00:00
<?php
2026-10-18 19:27:17 -04:00
declare(strict_types=1);
ini_set('display_errors','0');
ini_set('log_errors','1');
2026-10-18 19:27:17 -04:00
header('X-Content-Type-Options: nosniff');
header('Referrer-Policy: no-referrer');
header('X-Frame-Options: DENY');
header('Cache-Control: no-store');
set_exception_handler(function (Throwable $e): void {
$status=$e instanceof AppException?$e->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 '<!doctype html><html lang="en"><title>Request could not be completed</title><main><h1>Request could not be completed</h1><p>'.htmlspecialchars($message,ENT_QUOTES,'UTF-8').'</p><p><a href="main.php">Return to the application</a></p></main></html>';}
2026-10-18 19:27:17 -04:00
});
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');
2026-10-18 19:27:17 -04:00
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',
]);
2026-10-18 17:01:36 +00:00
session_start();
2026-10-18 19:27:17 -04:00
$application->do();