<?php
/*
 * pages/login.php
 * PHP logic: INTACT - $login_info setat de include/functions/pages/login.php (via header)
 * HTML: design Nostalgia2
 */
?>

<!-- Header -->
<nav class="navbar navbar-dark bg-news-header mb-5">
    <div class="container-fluid">
        <h4 class="h4 small m-0 text-uppercase"><?php echo strtoupper($lang['login']); ?></h4>
    </div>
</nav>

<!-- Mesaje login (doar daca s-a trimis form) -->
<?php
if(isset($_POST['username']) && isset($_POST['password'])) {
    $alert_class = 'alert-danger';
    $msg = 'ERROR';
    switch($login_info[0]) {
        case 1: $alert_class = 'alert-success'; $msg = 'Logged in!'; break;
        case 2: $msg = $lang['account-blocked']; break;
        case 3: $msg = $lang['error-login']; break;
        case 4: $msg = $lang['error-login-email']; break;
        case 5: $msg = $lang['account-blocked-temporary'].' ('.$login_info[2].')'; break;
    }
    echo '<div class="alert '.$alert_class.' alert-dismissible fade show m-3" role="alert">
        <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
        '.$msg.'</div>';
    if($login_info[0] == 2 || $login_info[0] == 5)
        echo '<div class="alert alert-info alert-dismissible fade show m-3" role="alert">
            <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
            '.$lang['reason'].': '.$login_info[1].'</div>';
}
?>

<!-- Form login -->
<div class="main_board_darker_background p-4">
    <form role="form" method="post" action="">
        <div class="col-7 mx-auto">

            <div class="left-inner-addon input-container mt-2">
                <img src="<?php echo $site_url; ?>assets/img/icon-user.png" alt="">
                <input name="username" type="text"
                    class="form-control-input form-control form-input text-white small"
                    placeholder="<?php echo $lang['user-name-or-email']; ?>"
                    pattern=".{5,64}" maxlength="64" autocomplete="off" required>
            </div>

            <div class="left-inner-addon input-container mt-2">
                <img src="<?php echo $site_url; ?>assets/img/icon-pass.png" alt="">
                <input name="password" type="password"
                    class="form-control-input form-control form-input text-white small"
                    placeholder="<?php echo $lang['password']; ?>"
                    pattern=".{5,16}" maxlength="16" required>
            </div>

        </div>

        <div class="sider-btn mt-3">
            <button class="my-2 mx-auto text-center sign-in-button btn bg-button small fw-bold"
                type="submit" style="display:block;">
                <?php echo $lang['login']; ?>
            </button>
        </div>

        <div class="row mx-auto small text-white mt-2">
            <div class="login-options p-0 text-center">
                <ul class="list-unstyled">
                    <li>
                        <a href="<?php echo $site_url; ?>users/register" class="text-gold">
                            &#8226; <?php echo $lang['register']; ?>
                        </a>
                    </li>
                    <li>
                        <a href="<?php echo $site_url; ?>users/lost" class="text-gold">
                            &#8226; <?php echo $lang['forget-password']; ?>
                        </a>
                    </li>
                </ul>
            </div>
        </div>
    </form>
</div>
