Your IP : 216.73.217.78


Current Path : /home/seto/888mirror.pm/admin/
Upload File :
Current File : /home/seto/888mirror.pm/admin/login.php

<?php
require_once __DIR__ . '/../includes/auth.php';

auth_start();
if (!empty($_SESSION['user_id'])) {
    header('Location: /admin/dashboard.php');
    exit();
}

$error = '';
$ip    = $_SERVER['REMOTE_ADDR'] ?? '0.0.0.0';

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $login    = trim($_POST['login'] ?? '');
    $password = $_POST['password'] ?? '';

    if (brute_is_blocked($ip)) {
        $error = 'Слишком много попыток. Подождите 10 минут.';
    } elseif (!$login || !$password) {
        $error = 'Заполните все поля.';
    } elseif (!auth_login($login, $password)) {
        $left  = brute_attempts_left($ip);
        $error = "Неверный логин или пароль. Осталось попыток: $left.";
    } else {
        header('Location: /admin/dashboard.php');
        exit();
    }
}
?>
<!DOCTYPE html>
<html lang="ru">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Вход — Admin</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <style>
        body { background: #f0f2f5; }
        .login-card { max-width: 400px; margin: 100px auto; }
    </style>
</head>
<body>
<div class="login-card">
    <div class="card shadow-sm">
        <div class="card-body p-4">
            <h4 class="card-title mb-4 text-center">888mirror — Admin</h4>
            <?php if ($error): ?>
                <div class="alert alert-danger py-2"><?= htmlspecialchars($error) ?></div>
            <?php endif ?>
            <form method="post" autocomplete="off">
                <div class="mb-3">
                    <label class="form-label">Логин</label>
                    <input type="text" name="login" class="form-control" required autofocus
                           value="<?= htmlspecialchars($_POST['login'] ?? '') ?>">
                </div>
                <div class="mb-3">
                    <label class="form-label">Пароль</label>
                    <input type="password" name="password" class="form-control" required>
                </div>
                <button type="submit" class="btn btn-primary w-100">Войти</button>
            </form>
        </div>
    </div>
</div>
</body>
</html>