Add SQLite-backed announcement system and admin portal
- Add SQLite database initialization and management in inc/db.php - Implement session authentication and CSRF security helpers in inc/auth.php - Implement announcement querying and saving in inc/announcements.php - Add management dashboard, login, and logout in admin/ - Protect db/ directory with Apache access controls
This commit is contained in:
1 parent
b9d3262233
commit
9b7d9ceccb
7 files changed
+761
No files matched your search
+150
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../inc/auth.php';
|
||||
|
||||
$error = '';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$username = $_POST['username'] ?? '';
|
||||
$password = $_POST['password'] ?? '';
|
||||
|
||||
if (authenticate_user($username, $password)) {
|
||||
header('Location: index.php');
|
||||
exit;
|
||||
} else {
|
||||
$error = '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 | The Old Fitz Public House</title>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Fraunces:wght@600&family=Karla:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="../styles.css">
|
||||
<style>
|
||||
body {
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 1.5rem;
|
||||
}
|
||||
.login-card {
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--rule);
|
||||
border-radius: 0.25rem;
|
||||
padding: 2.5rem 2rem;
|
||||
width: 100%;
|
||||
max-width: 25rem;
|
||||
box-shadow: 0 1rem 2.5rem rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
.login-header {
|
||||
text-align: center;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
.login-header img {
|
||||
width: 2rem;
|
||||
height: 2rem;
|
||||
margin: 0 auto 0.75rem;
|
||||
}
|
||||
.login-header h1 {
|
||||
font-size: 1.5rem;
|
||||
color: var(--gold-bright);
|
||||
}
|
||||
.login-header p {
|
||||
font-family: 'IBM Plex Mono', monospace;
|
||||
font-size: 0.72rem;
|
||||
letter-spacing: 0.15em;
|
||||
text-transform: uppercase;
|
||||
color: var(--ink-muted);
|
||||
margin-top: 0.35rem;
|
||||
}
|
||||
.form-group {
|
||||
margin-bottom: 1.25rem;
|
||||
}
|
||||
.form-group label {
|
||||
display: block;
|
||||
font-family: 'IBM Plex Mono', monospace;
|
||||
font-size: 0.75rem;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
color: var(--gold);
|
||||
margin-bottom: 0.4rem;
|
||||
}
|
||||
.form-input {
|
||||
width: 100%;
|
||||
background: var(--ground-2);
|
||||
border: 1px solid var(--rule);
|
||||
color: var(--ink);
|
||||
font-family: 'Karla', sans-serif;
|
||||
font-size: 0.95rem;
|
||||
padding: 0.7rem 0.85rem;
|
||||
border-radius: 0.125rem;
|
||||
box-sizing: border-box;
|
||||
outline: none;
|
||||
transition: border-color .15s ease;
|
||||
}
|
||||
.form-input:focus {
|
||||
border-color: var(--gold-bright);
|
||||
}
|
||||
.error-msg {
|
||||
background: rgba(180, 50, 40, 0.15);
|
||||
border: 1px solid rgba(220, 80, 60, 0.4);
|
||||
color: #ff9d9d;
|
||||
padding: 0.75rem 1rem;
|
||||
font-size: 0.88rem;
|
||||
border-radius: 0.125rem;
|
||||
margin-bottom: 1.25rem;
|
||||
}
|
||||
.login-btn {
|
||||
width: 100%;
|
||||
justify-content: center;
|
||||
margin-top: 0.5rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
.back-link {
|
||||
display: block;
|
||||
text-align: center;
|
||||
margin-top: 1.5rem;
|
||||
font-family: 'IBM Plex Mono', monospace;
|
||||
font-size: 0.75rem;
|
||||
color: var(--ink-muted);
|
||||
text-decoration: none;
|
||||
}
|
||||
.back-link:hover {
|
||||
color: var(--gold-bright);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="login-card">
|
||||
<div class="login-header">
|
||||
<img src="../assets/knot.png" alt="" class="knot">
|
||||
<h1>The Old Fitz</h1>
|
||||
<p>Management Portal</p>
|
||||
</div>
|
||||
|
||||
<?php if (!empty($error)): ?>
|
||||
<div class="error-msg" role="alert"><?= htmlspecialchars($error) ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<form method="POST" action="login.php">
|
||||
<div class="form-group">
|
||||
<label for="username">Username</label>
|
||||
<input type="text" id="username" name="username" class="form-input" required autofocus autocomplete="username">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="password">Password</label>
|
||||
<input type="password" id="password" name="password" class="form-input" required autocomplete="current-password">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary login-btn">Sign In</button>
|
||||
</form>
|
||||
|
||||
<a href="../" class="back-link">← Return to Pub Website</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user