Files
radio-free-elsewhere/includes/admin_layout.php
T
Daniel MesserandClaude Opus 5.5 f659b09a0b Show the queued show and its start time in the index.php sidebar
- Shows get a description and an icon upload; broadcasts get a scheduled_at
  start time. schema.sql adds the columns to existing databases and seeds
  the descriptions from the old hand-written sidebar.
- The dashboard and cli/set_show.php take an optional date and Eastern start
  time when queuing; index.php shows it with the UTC conversion.
- liveBroadcast() and currentShow() ignore broadcasts unseen for longer than
  the grace period, so a stopped poller can't leave a show stuck as live.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 09:30:20 -05:00

107 lines
3.0 KiB
PHP

<?php
// Shared page chrome for the admin pages: the site's Strata layout with an admin menu in the sidebar.
if (basename($_SERVER['SCRIPT_FILENAME'] ?? '') === basename(__FILE__)) {
http_response_code(403);
exit;
}
function e(string $s): string {
return htmlspecialchars($s, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
}
// One-time status message shown at the top of the next admin page (for post-redirect-get)
function flash(string $message, string $type = 'success'): void {
startAdminSession();
$_SESSION['flash'] = ['message' => $message, 'type' => $type];
}
function adminHeader(string $title, ?array $admin = null): void {
?>
<!DOCTYPE HTML>
<html>
<head>
<title><?= e($title) ?> | RFE Admin</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="robots" content="noindex, nofollow" />
<link rel="stylesheet" href="../assets/css/main.css" />
<style>
#header ul.admin-nav {
list-style: none;
padding: 0;
margin-top: 2em;
}
#header ul.admin-nav li {
padding: 0.25em 0;
}
#header ul.admin-nav a {
color: #fff;
}
/* Strata doesn't style these input types */
input[type="date"],
input[type="time"] {
background: #f7f7f7;
border-radius: 0.35em;
border: solid 2px transparent;
color: inherit;
height: 2.75em;
padding: 0 0.75em;
width: 100%;
}
.admin-message {
padding: 0.75em 1em;
border-radius: 4px;
margin-bottom: 2em;
}
.admin-message.error {
background-color: rgba(200, 60, 60, 0.15);
color: #a33;
}
.admin-message.success {
background-color: rgba(60, 160, 90, 0.15);
color: #2a7a45;
}
</style>
</head>
<body>
<header id="header">
<div class="inner">
<a href="../index.php" class="image avatar"><img src="../images/avatar-rfe.jpg" alt="Radio Free Elsewhere logo" /></a>
<h1><strong>Radio Free Elsewhere</strong><br>
Admin</h1>
<?php if ($admin): ?>
<ul class="admin-nav">
<li><a href="index.php">Dashboard</a></li>
<li><a href="shows.php">Shows</a></li>
<li><a href="../live.php">View live page</a></li>
</ul>
<form method="post" action="logout.php">
<?= csrfField() ?>
<input type="submit" class="small" value="Log out <?= e($admin['username']) ?>" />
</form>
<?php endif; ?>
</div>
</header>
<div id="main">
<section>
<header class="major">
<h2><?= e($title) ?></h2>
</header>
<?php
if (!empty($_SESSION['flash'])) {
echo '<p class="admin-message ' . e($_SESSION['flash']['type']) . '">' . e($_SESSION['flash']['message']) . "</p>\n";
unset($_SESSION['flash']);
}
}
function adminFooter(): void {
?>
</section>
</div>
</body>
</html>
<?php
}