From c7b836bcf265d0816acbee24e4f3b08907cf138d Mon Sep 17 00:00:00 2001 From: David Dyer Date: Sun, 25 Oct 2026 16:06:15 -0400 Subject: [PATCH] Refactor admin pages to use shared head and navigation components - Created `admin-head.php` for consistent markup across admin pages. - Created `admin-nav.php` for shared navigation bar, reducing duplication. - Updated all admin pages (account, hours, index, login, menu, users) to utilize the new components. - Added security headers to `auth.php` and `index.php` for improved security. - Introduced `security-headers.php` to manage security headers across the application. - Moved inline styles from admin pages to SCSS files to comply with Content Security Policy (CSP). - Normalized file permissions during build process to prevent permission issues on deployment. --- admin/account.php | 35 +-------- admin/hours.php | 38 ++-------- admin/index.php | 46 +++--------- admin/login.php | 11 +-- admin/menu.js | 12 ++- admin/menu.php | 34 +-------- admin/users.js | 12 ++- admin/users.php | 32 +------- docker-compose.yaml | 72 ++++++++++-------- inc/admin-head.php | 23 ++++++ inc/admin-nav.php | 46 ++++++++++++ inc/auth.php | 17 +---- inc/security-headers.php | 65 ++++++++++++++++ index.php | 2 + menu.php | 24 +++--- scripts/build-dist.js | 19 +++++ src/scss/pages/_admin-announcements.scss | 29 ++++++++ src/scss/pages/_admin-hours.scss | 9 +++ src/scss/pages/_menu.scss | 56 ++++++++++++++ src/scss/styles.scss | 1 + styles.css | 95 ++++++++++++++++++++++++ 21 files changed, 447 insertions(+), 231 deletions(-) create mode 100644 inc/admin-head.php create mode 100644 inc/admin-nav.php create mode 100644 inc/security-headers.php create mode 100644 src/scss/pages/_admin-announcements.scss diff --git a/admin/account.php b/admin/account.php index 53419fb..ef143ea 100644 --- a/admin/account.php +++ b/admin/account.php @@ -3,6 +3,8 @@ declare(strict_types=1); require_once __DIR__ . '/../inc/auth.php'; require_once __DIR__ . '/../inc/assets.php'; +require_once __DIR__ . '/../inc/admin-head.php'; +require_once __DIR__ . '/../inc/admin-nav.php'; require_once __DIR__ . '/../inc/users.php'; // Any signed-in user can change their own username and/or password here, @@ -80,46 +82,17 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { } $justSaved = !$_POST && isset($_GET['saved']); -$isAdmin = ($user['role'] ?? '') === 'admin'; // After a failed save, keep the username they typed in the field. $usernameValue = $_POST ? trim(account_post_str('username')) : $user['username']; ?> - - - - My Account | The Old Fitz Admin - - - - - + - +
diff --git a/admin/hours.php b/admin/hours.php index 37258bd..218e335 100644 --- a/admin/hours.php +++ b/admin/hours.php @@ -3,6 +3,8 @@ declare(strict_types=1); require_once __DIR__ . '/../inc/auth.php'; require_once __DIR__ . '/../inc/assets.php'; +require_once __DIR__ . '/../inc/admin-head.php'; +require_once __DIR__ . '/../inc/admin-nav.php'; require_once __DIR__ . '/../inc/hours.php'; require_auth(); @@ -66,39 +68,11 @@ $justSaved = !$_POST && isset($_GET['saved']); - - - - Hours | The Old Fitz Admin - - - - - + - +
@@ -157,7 +131,7 @@ $justSaved = !$_POST && isset($_GET['saved']);
-

Leave "Kitchen Closes" blank on a day if the kitchen doesn't have a separate cutoff from the bar. Special closures (holidays, weather) are handled on the Announcements page instead of here.

+

Leave "Kitchen Closes" blank on a day if the kitchen doesn't have a separate cutoff from the bar. Special closures (holidays, weather) are handled on the Announcements page instead of here.

@@ -171,7 +145,7 @@ $justSaved = !$_POST && isset($_GET['saved']); 👀 Public Site Preview
-

This is how the schedule above will read on the site once saved.

+

This is how the schedule above will read on the site once saved.

diff --git a/admin/index.php b/admin/index.php index 90546f3..5a8e5fa 100644 --- a/admin/index.php +++ b/admin/index.php @@ -1,6 +1,8 @@ - - - - Pub Management Dashboard | The Old Fitz - - - - - + - +
@@ -194,21 +168,21 @@ $announcements = get_all_announcements();
-
+
-
+
→ Always (while on)
-
+
Edit -
+ @@ -286,14 +260,14 @@ $announcements = get_all_announcements(); - Leave blank to show immediately while enabled. + Leave blank to show immediately while enabled.
- Auto-hides after 11:59 PM on this date. + Auto-hides after 11:59 PM on this date.
diff --git a/admin/login.php b/admin/login.php index 1438c89..f43c9e8 100644 --- a/admin/login.php +++ b/admin/login.php @@ -2,6 +2,7 @@ require_once __DIR__ . '/../inc/auth.php'; require_once __DIR__ . '/../inc/login-throttle.php'; require_once __DIR__ . '/../inc/assets.php'; +require_once __DIR__ . '/../inc/admin-head.php'; $error = ''; @@ -27,15 +28,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { ?> - - - - Admin Login | The Old Fitz Public House - - - - - +