| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- require dirname(__DIR__, 2) . '/app/bootstrap.php';
- session_boot();
- if (auth_check()) {
- redirect('index.php');
- }
- $error = null;
- if ($_SERVER['REQUEST_METHOD'] === 'POST') {
- csrf_verify();
- $lock = auth_locked_for();
- if ($lock > 0) {
- $error = 'Too many failed attempts. Try again in ' . ceil($lock / 60) . ' min.';
- } elseif (auth_attempt((string)($_POST['username'] ?? ''), (string)($_POST['password'] ?? ''))) {
- redirect('index.php');
- } else {
- $lock = auth_locked_for();
- $error = $lock > 0
- ? 'Too many failed attempts. Try again in ' . ceil($lock / 60) . ' min.'
- : 'Invalid username or password.';
- }
- }
- ?><!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <title>Admin login</title>
- <link rel="stylesheet" href="../assets/site.css">
- </head>
- <body class="admin">
- <div class="login-wrap"><div class="login-card">
- <h1>Backoffice</h1>
- <?php if ($error): ?><div class="flash flash-error" style="margin-top:1.2rem"><?= e($error) ?></div><?php endif; ?>
- <form method="post">
- <?= csrf_field() ?>
- <label for="u">Username</label>
- <input type="text" id="u" name="username" autofocus autocomplete="username">
- <label for="p">Password</label>
- <input type="password" id="p" name="password" autocomplete="current-password">
- <button type="submit" style="width:100%">Log in</button>
- </form>
- </div></div>
- </body>
- </html>
|