Update index.php

change 10 most recent gold star supporters .
This commit is contained in:
deepend-tildeclub 2024-08-17 08:31:04 -06:00 committed by GitHub
parent bbfc51b8cb
commit 436a87e234
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 19 additions and 6 deletions

View File

@ -30,15 +30,28 @@
they give, only by the fact that they gave. they give, only by the fact that they gave.
Here's who has donated! When you're on the Here's who has donated! When you're on the
server, THANK THEM.</p> server, THANK THEM.</p>
<?php
$supporters = json_decode(file_get_contents('supporters.json'), true);
usort($supporters, function($a, $b) {
return strtotime($b['date']) - strtotime($a['date']);
});
$showAll = isset($_GET['show_all']) && $_GET['show_all'] == 'true';
$supportersToShow = $showAll ? $supporters : array_slice($supporters, 0, 10);
?>
<ul> <ul>
<?php <?php foreach ($supportersToShow as $supporter): ?>
$supporters = json_decode(file_get_contents('supporters.json'), true); <li><?= htmlspecialchars($supporter['date']) ?> | <a href="<?= htmlspecialchars($supporter['url']) ?>"><?= htmlspecialchars($supporter['name']) ?></a></li>
foreach ($supporters as $supporter) { <?php endforeach; ?>
echo '<li>' . htmlspecialchars($supporter['date']) . ' | <a href="' . htmlspecialchars($supporter['url']) . '">' . htmlspecialchars($supporter['name']) . '</a></li>';
}
?>
</ul> </ul>
<?php if (!$showAll): ?>
<p><a href="?show_all=true">Show all supporters</a></p>
<?php else: ?>
<p><a href="?show_all=false">Show only the 10 most recent supporters</a></p>
<?php endif; ?>
</div> </div>
<div class="col"> <div class="col">