<!DOCTYPE html>
<html lang="de">
<? require_once("../common/version_comment.inc.php"); ?>
<?php
$translation = \DynCom\mysyde\common\classes\Registry::get('translation');
?>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo $translation->get('backend_login_title'); ?></title>

    <link rel="apple-touch-icon" sizes="180x180" href="/layout/admin/img/favicon/favicon.ico">
    <link rel="icon" type="image/png" sizes="32x32" href="/layout/admin/img/favicon/favicon.ico">
    <link rel="icon" type="image/png" sizes="16x16" href="/layout/admin/img/favicon/favicon.ico">
    <link rel="apple-touch-icon" sizes="180x180" href="/layout/admin/img/2016/favicons/apple-touch-icon.png">
    <link rel="icon" type="image/png" href="/layout/admin/img/2016/favicons/favicon-32x32.png" sizes="32x32">
    <link rel="icon" type="image/png" href="/layout/admin/img/2016/favicons/favicon-16x16.png" sizes="16x16">

    <link
        href="/layout/admin/css/mysyde.css?t=<?= filemtime($_SERVER['DOCUMENT_ROOT'] . '/layout/admin/css/mysyde.css')?>"
        rel="stylesheet" type="text/css" />
    <link
        href="/layout/admin/css/responsive.css?t=<?= filemtime($_SERVER['DOCUMENT_ROOT'] . '/layout/admin/css/responsive.css')?>"
        rel="stylesheet" type="text/css" />
    <link rel="mask-icon" href="/layout/admin/img/2016/favicons/safari-pinned-tab.svg" color="#99c137">
    <meta name="theme-color" content="#ffffff">
</head>

<body class="login">
    <div id="login-container">

        <div id="login">

            <div class="login-wrapper">
                <div class="login-left-content">
                <div id="mysyde-logo"><img src="/layout/admin/img/icons/mysyde-icon.png" alt="MySyde Icon"></div>
                <div id="login_1"><?php echo $translation->get('backend_login_headline'); ?></div>
                <?

            $falseLoginData = get_false_password_admin_login_counter(md5(getUserIP()),"");
            $now = time();
            $dataBaseCounter = 0;
            $blockTime = $now;
            $blockErrorCounter = 0;

            if(count($falseLoginData) > 0)
            {
                $dataBaseCounter = $falseLoginData[0]['total_counter'];
                $blockTime = $falseLoginData[0]['next_login_time'];
                $blockErrorCounter = $falseLoginData[0]['block_counter'];;
            }

            $counter = $dataBaseCounter / $GLOBALS['shop_setup']['allowed_false_login_times'];
            $counter = (int)$counter;
            $waitingSeconds = $counter * $GLOBALS['shop_setup']['false_login_waiting_seconds'];

            if($counter != $blockErrorCounter)
            {
                $blockTime =  $now + $waitingSeconds;
                add_false_password_admin_loign_counter(md5(getUserIP()), "", $dataBaseCounter ,$blockTime,  $counter);
            }


            if( $blockTime >  $now)
            {
                $message = str_replace('%number_of_times%',$dataBaseCounter ,$translation->get('reach_false_login_times'));
                $message = str_replace('%minutes_number%',((int)$waitingSeconds/60),$message);
                echo '<h2>'.$message.'</h2>';

            }
            else
            {
                ?>

                <div id="login_2">
                    <div class="statusMessage">
                        <p><?php echo $_SESSION['success_status'];
                                        unset($_SESSION['success_status']);
                            ?>
                            <?php echo $_SESSION['status_message'];
                                        unset($_SESSION['status_message']);
                            ?>
                        </p>
                    </div>
                    <form name="form_admin_login" autocomplete="new-password" id="form_admin_login"
                        action="?action=admin_login" method="post">
                        <div class="label"><label
                                for="input_login"><?php echo $translation->get('backend_login_label'); ?>
                                :</label></div>
                        <div class="input"><input autocomplete="new-password" placeholder=" " class="code" type="text"
                                name="input_login" id="input_login_user" /></div>
                        <div class="label"><label
                                for="input_password"><?php echo $translation->get('backend_password_label'); ?>:</label>
                        </div>
                        <div class="input"><input autocomplete="new-password" placeholder=" " class="code"
                                name="input_password" type="password" id="input_password" />
                        </div>
                        <div class="button-wrapper">
                            <div class="passwort"><a href="?action=forget_password">Passwort vergessen?</a></div>
                            <input class="button" name="" type="submit"
                                value="<?php echo $translation->get('backend_login_button'); ?>" />
                        </div>
                    </form>
                </div>
            </div>



            <?
            }
            ?>




<div class="video-wrapper">
    <video src="https://www.breadcrumb-solutions.de/mysyde-login-animation.mov"autoplay="true" height="100%" loop="true" muted="true" ></video>
</div>

        </div>
    </div>

    </div>
    <div class=" login sitelanguage-version"><?php echo current_website_language($site, $language); ?><div class="version"><?php echo $translation->get("version")?></div></div>


    <script type="text/javascript" src="/plugins/jquery/jquery-3.5.1.min.js"></script>
    <script>
    $(document).ready(function() {
        $(document).on('focus', ':input', function() {
            $(this).attr('autocomplete', 'off');
        });
    });
    </script>
</body>

</html>