<?php
// Configurar zona horaria
date_default_timezone_set("Europe/Madrid");

// Obtener datos relevantes
$debug = [
    "host"            => $_SERVER['HTTP_HOST'] ?? "",
    "hostname"        => gethostname(),
    "server_name"     => $_SERVER['SERVER_NAME'] ?? "",
    "server_addr"     => $_SERVER['SERVER_ADDR'] ?? "",
    "server_port"     => $_SERVER['SERVER_PORT'] ?? "",
    "scheme"          => (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? "https" : "http",
    "remote_addr"     => $_SERVER['REMOTE_ADDR'] ?? "",
    "request_uri"     => $_SERVER['REQUEST_URI'] ?? "",
    "script_name"     => $_SERVER['SCRIPT_NAME'] ?? "",
    "referer"         => $_SERVER['HTTP_REFERER'] ?? "",
    "user_agent"      => $_SERVER['HTTP_USER_AGENT'] ?? "",
    "accept_language" => $_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? "",
];

// Mostrar en navegador de forma legible
echo "<h2>Depuración $_SERVER</h2>";
echo "<pre>";
print_r($debug);
echo "</pre>";

// También enviar como JSON (útil para fetch / consola JS)
header('Content-Type: application/json');
echo json_encode($debug, JSON_PRETTY_PRINT);
?>
