<?php
require_once dirname(__DIR__) . '/safety/ChairmanSafeLoader.php';
$status = ChairmanSafeLoader::status();
$raceDate = isset($_GET['race_date']) ? $_GET['race_date'] : (isset($_GET['date']) ? $_GET['date'] : date('Y-m-d'));
$payload = ChairmanSafeLoader::payload($raceDate);
function hh($s){return htmlspecialchars((string)$s, ENT_QUOTES, 'UTF-8');}
?><!doctype html>
<html><head><meta charset="utf-8"><title>Chairman Gateway Check v4.2 FIXED</title>
<style>body{background:#050914;color:#e7fbff;font-family:Arial;padding:25px}.box{border:1px solid #283c59;background:#0c1423;padding:18px;border-radius:12px;margin-bottom:15px}.ok{color:#32ffa7}.bad{color:#ff5a86}.gold{color:#ffc107}pre{white-space:pre-wrap;color:#9ed9ff}</style>
</head><body>
<h1>Chairman Gateway Check v4.2 FIXED</h1>
<div class="box"><h2>Status</h2><pre><?=hh(json_encode($status,JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT))?></pre></div>
<div class="box"><h2>Payload Test</h2><p>Race Date: <span class="gold"><?=hh($raceDate)?></span></p><pre><?=hh(json_encode(array('ok'=>$payload['ok']??false,'counts'=>$payload['counts']??array(),'elapsed_ms'=>$payload['elapsed_ms']??0,'status'=>$payload['status']??'OK'),JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT))?></pre></div>
</body></html>
