<?php $pageTitle='Top 50 — Almost Heaven Radio'; include __DIR__ . '/header.php'; include __DIR__ . '/menu.php'; require_once __DIR__ . '/includes/stream_lib.php'; @smurf_top50_touch(__DIR__ . '/data/top50.json', __DIR__ . '/data/top50_state.json'); $rows=smurf_top50_sorted(__DIR__ . '/data/top50.json'); if(empty($rows)){ $playlistFile=__DIR__.'/data/played.txt'; if(is_readable($playlistFile)){ foreach(array_slice(array_reverse(file($playlistFile, FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES) ?: []),0,50) as $track){ $rows[]=['title'=>$track,'count'=>null]; } } } ?>
<main class="content-area"><div class="content-wrapper page-shell"><section class="content-card"><h1>🎵 Top 50 Recently Played</h1><p>Almost Heaven’s freshest tracks.</p><?php if(empty($rows)): ?><p>No tracks logged yet.</p><?php else: ?><ol class="table-like-list"><?php foreach($rows as $row): ?><li><strong><?= htmlspecialchars((string)($row['title'] ?? '')) ?></strong><?php if(isset($row['count']) && $row['count'] !== null): ?><span style="float:right;"><?= (int)$row['count'] ?></span><?php endif; ?></li><?php endforeach; ?></ol><?php endif; ?></section></div></main>
<?php include __DIR__ . '/footer.php'; ?>