<?php
    // ensure start_time is set
    $GLOBALS['bf_s1'] = $GLOBALS['bf_s1']??hrtime(true) - 1000000;
    $resp_code = intval(\BitFire\Config::int("response_code", 200));
    $error_css = \Threadfin\get_public("error.css");
    $error_css = isset($error_css) ? htmlentities($error_css) : "";
    $st = (hrtime(true) - $GLOBALS['bf_s1']) / 1e+6;
    \BitFire\BitFire::get_instance()->blocked($st, $resp_code, $custom_err);
    \ThreadFin\trace("BL CODE $resp_code");
    http_response_code($resp_code);
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <title>Request blocked by BitFire</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="robots" content="noindex, nofollow">

    <!-- Keep FA include as in original to avoid layout shifts -->
    <link type="text/css" rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/fontawesome.min.css">
    <link type="text/css" rel="stylesheet" href="<?php echo $error_css; ?>">
</head>
<body>
<div id="block" role="main">
  <div class="block-bg"></div>
  <div class="block">
    <div class="block-err"><h1>Halt!</h1></div>

    <h2>Something Happened</h2>

    <p class="nor">
      <?php echo $custom_err; ?>
    </p>

    <p class="nor">
      If this is an error, please click the request review button below.
      Reference ID U:<i><?php echo htmlspecialchars($uuid ?? '', ENT_QUOTES, 'UTF-8'); ?></i>
    </p>

    <!-- Keep anchor with original id and data-attribute; de-duplicate inner button id -->
    <a href="#" id="review" data-reference="<?php echo htmlspecialchars($uuid ?? '', ENT_QUOTES, 'UTF-8'); ?>">
      <button type="button" id="review">Request Review</button>
    </a>

    <a href="/">
      <button type="button" id="home">Back To Homepage</button>
    </a>

    <noscript>
      <p class="nor">JavaScript is required to submit a review. Please enable JavaScript and try again.</p>
    </noscript>
  </div>
</div>

<div id="attribute">
  <p>
    <span>
      Powered by:
      <a href="https://bitfire.co" target="_blank" rel="noopener noreferrer" style="color: #fff;">BitFire</a>
    </span>
    <span>
      Photo by:
      <a href="https://www.pexels.com/@pok-rie-33563/" rel="nofollow ugc noopener noreferrer" target="_blank" style="color: #fff;">@pok-rie</a>
    </span>
  </p>
</div>

<script defer src="<?php echo \BitFire\Config::str('cms_content_url')?>/plugins/bitfire/public/block.js"></script>
</body>
</html>

<!--
detailed block reason: 
<?php echo "$code\n"; if (\BitFire\Config::enabled('debug')) { echo(json_encode($block, JSON_PRETTY_PRINT)); } echo $st; ?>
-->
