commit 5be534a7eb06f205a53ae67f940293aadee05151
parent 87f197803d75245967027c1f243b37add3d3a0b5
Author: JayVii <jayvii[AT]posteo[DOT]de>
Date: Sat, 12 Apr 2025 14:47:17 +0200
feat: only show current year's weeks and months
Diffstat:
M | index.php | | | 58 | ++++++++++++++++++++++++++++++++++++---------------------- |
1 file changed, 36 insertions(+), 22 deletions(-)
diff --git a/index.php b/index.php
@@ -14,7 +14,7 @@
<header>
<nav>
- <a href="all/">All Time</a>
+ <a href="#all">All Time</a>
<a href="#year">Yearly</a>
<a href="#month">Monthly</a>
<a href="#week">Weekly</a>
@@ -32,14 +32,21 @@
users send to the webserver.
</p>
+ <!-- All Time -->
+ <section id="all">
+ <h2>Long Time Traffic collection</h2>
+ <a class="button" href="all/">All Time</a>
+ </section>
+
<!-- Yearly List -->
<section id="year">
<h2>Yearly</h2>
<?php
/* Check which Yearly files exist and print them*/
- foreach (glob("[0-9][0-9][0-9][0-9]") as $year) {
- echo "<a class='button' href='" . $year . "/'>" . $year . "</a>";
-
+ foreach (array_reverse(glob("[0-9][0-9][0-9][0-9]")) as $year) {
+ ?>
+ <a class="button" href="<?php echo $year; ?>/"><?php echo $year; ?></a>
+ <?php
}
?>
</section>
@@ -47,33 +54,40 @@
<section id="month">
<h2>Monthly</h2>
<?php
- foreach (glob("[0-9][0-9][0-9][0-9]") as $year) {
- foreach (glob($year . "/" . "[0-9][0-9]") as $month) {
- echo "<a class='button' href='" . $month .
- "/'>" .
- date("F",
- strtotime(
- $year . "-" . substr("{$month}", -2) . "-01"
- )
- ) . " " . $year . "</a>";
-
- }
+ /* Only return monthly data from the latest year */
+ $year = end(glob("[0-9][0-9][0-9][0-9]"));
+ foreach (glob($year . "/" . "[0-9][0-9]") as $month) {
+ $mlab = date(
+ "F",
+ strtotime($year . "-" . substr("{$month}", -2) . "-01")
+ );
+ ?>
+ <a class="button" href="<?php echo $month; ?>/"><?php echo $mlab; ?></a>
+ <?php
}
?>
+ <p><em>
+ <strong>Note:</strong>
+ Only shows monthly data from <?php echo $year; ?>.
+ </em></p>
</section>
<section id="week">
<h2>Weekly</h2>
<?php
- foreach (glob("[0-9][0-9][0-9][0-9]") as $year) {
- foreach (glob($year . "/week-" . "[0-9][0-9]") as $week) {
- echo "<a class='button' href='" . $week .
- "/'>Week " . substr("{$week}", -2) . " " . $year .
- "</a>";
-
- }
+ /* Only return weekly data from the latest year */
+ $year = end(glob("[0-9][0-9][0-9][0-9]"));
+ foreach (glob($year . "/week-" . "[0-9][0-9]") as $week) {
+ $wlab = "Week " . substr("{$week}", -2);
+ ?>
+ <a class="button" href="<?php echo $week; ?>/"><?php echo $wlab; ?></a>
+ <?php
}
?>
+ <p><em>
+ <strong>Note:</strong>
+ Only shows weekly data from <?php echo $year; ?>.
+ </em></p>
</section>
</body>