<?php
require_once "../config.php";

header("Content-Type: application/json");

$hdr = $_SERVER["HTTP_AUTHORIZATION"] ?? "";
$all = [];

foreach ($_SERVER as $k => $v) {
    if (strpos($k, "HTTP_") === 0) $all[$k] = $v;
}

echo json_encode([
    "success" => true,
    "has_http_authorization" => isset($_SERVER["HTTP_AUTHORIZATION"]),
    "http_authorization" => $hdr,
    "session_id" => session_id(),
    "session_has_token" => isset($_SESSION["fxh_desktop_token"]),
    "session_token_prefix" => isset($_SESSION["fxh_desktop_token"]) ? substr($_SESSION["fxh_desktop_token"], 0, 12) : null,
    "headers" => $all
]);
exit;
