<?php $pageTitle='Comments — Almost Heaven Radio'; include __DIR__ . '/../header.php'; include __DIR__ . '/../menu.php'; $comments=file_exists(__DIR__.'/../data/comments.json')?json_decode((string)file_get_contents(__DIR__.'/../data/comments.json'),true):[]; if(!is_array($comments)) $comments=[]; $approved=array_values(array_filter($comments, fn($c)=>!empty($c['approved']))); $approved=array_reverse($approved); ?>
<main class="content-area"><div class="content-wrapper page-shell"><section class="content-card"><h1>💬 Listener Comments</h1><p>Leave a message and read approved comments from the station community.</p><form method="post" action="submit_comment.php" class="d-grid" style="gap:14px;margin-top:18px;"><input type="hidden" name="return_to" value="<?= htmlspecialchars($_SERVER['REQUEST_URI'] ?? '/comments/index.php') ?>"><input type="text" name="name" placeholder="Your name" required><textarea name="message" rows="7" placeholder="Your message" required></textarea><div><button class="play-button" type="submit">Send Comment</button></div></form></section><section class="content-card"><h2>Approved Comments</h2><div class="table-like-list"><?php foreach($approved as $comment): ?><li><strong><?= htmlspecialchars($comment['name'] ?? 'Listener') ?></strong><br><?= nl2br(htmlspecialchars($comment['message'] ?? '')) ?></li><?php endforeach; if(!$approved): ?><li>No approved comments yet.</li><?php endif; ?></div></section></div></main>
<?php include __DIR__ . '/../footer.php'; ?>
