mirror of
https://github.com/myronblair/do-server-config
synced 2026-07-27 21:18:32 -05:00
40 lines
1.3 KiB
PHP
40 lines
1.3 KiB
PHP
<?php
|
|
require_once __DIR__ . '/../includes/auth.php';
|
|
|
|
if (AdminAuth::isLoggedIn()) {
|
|
header('Location: /admin/index.php');
|
|
exit;
|
|
}
|
|
|
|
$error = '';
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$password = $_POST['password'] ?? '';
|
|
if (AdminAuth::attempt($password)) {
|
|
header('Location: /admin/index.php');
|
|
exit;
|
|
}
|
|
$error = AdminAuth::isLockedOut($_SERVER['REMOTE_ADDR'] ?? 'unknown')
|
|
? 'Too many failed attempts. Try again in 15 minutes.'
|
|
: 'Incorrect password';
|
|
}
|
|
|
|
$pageTitle = 'Login - ChuckCo Time Keeper';
|
|
require_once __DIR__ . '/../includes/header.php';
|
|
?>
|
|
<div class="container" style="max-width:400px; padding-top: 4rem;">
|
|
<div class="card">
|
|
<h2 class="text-center">ChuckCo Time Keeper</h2>
|
|
<?php if ($error): ?>
|
|
<div class="alert alert-error"><?= e($error) ?></div>
|
|
<?php endif; ?>
|
|
<form method="POST">
|
|
<div class="form-group">
|
|
<label class="form-label">Admin Password</label>
|
|
<input type="password" name="password" class="form-input" autofocus required>
|
|
</div>
|
|
<button type="submit" class="btn btn-primary btn-block">Log In</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
<?php require_once __DIR__ . '/../includes/footer.php'; ?>
|