summaryrefslogtreecommitdiff
path: root/includes/footer.php
blob: 4592b8e28624ac6d2967d007a257da26c3fa612b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php

if (!function_exists("timeAgo")) {
    function timeAgo($time): string {
        if (!is_numeric($time)) {
            $time = strtotime($time);
        }

        $periods = ["second", "minute", "hour", "day", "week", "month", "year", "age"];
        $lengths = array("60", "60", "24", "7", "4.35", "12", "100");

        $now = time();

        $difference = $now - $time;
        if ($difference <= 10 && $difference >= 0) {
            return $tense = "now";
        } elseif ($difference > 0) {
            $tense = "ago";
        } else {
            $tense = "later";
        }

        for ($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) {
            $difference /= $lengths[$j];
        }

        $difference = round($difference);

        $period =  $periods[$j] . ($difference >1 ? "s" :'');
        return "{$difference} {$period} {$tense}";
    }
}

?>

<hr>
<div class="container text-muted">
    <?php

    $refresh = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/refresh.json"), true);

    ?>
    © <?= date("Y") ?> <a href="https://equestria.horse" target="_blank" class="text-muted">Equestria.dev Developers</a> · <a href="https://git.equestria.dev/equestria.dev/ponies.equestria.horse" target="_blank" class="text-muted">Source Code</a><br>
    <a href="/-/debug" class="text-muted" style="text-decoration: none;">Data updated <?= trim(timeAgo($refresh["timestamp"])) ?> (<?= date('D j M, G:i:s T', $refresh["timestamp"]) ?>; took <?= round($refresh["duration"] * 1000) ?> ms, <?= count($refresh["restored"]) > 0 ? (count($refresh["restored"]) > 1 ? "reported " . count($refresh["restored"]) . " failures" : "reported 1 failure") : "no failures reported" ?>)</a>
    <br><br><br>
</div>

<script>
    let tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
    let tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
        return new bootstrap.Tooltip(tooltipTriggerEl)
    });

    Array.from(document.querySelectorAll('[data-bs-toggle="tooltip"]')).forEach((item) => {
        if (!item.classList.contains("tooltip-nohelp")) {
            item.style.cursor = "help";
        }
    })
</script>

</body>
</html>