diff options
author | Minteck <contact@minteck.org> | 2022-08-10 00:04:25 +0200 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2022-08-10 00:04:25 +0200 |
commit | 0417260bf158c5d7b62888dae2e202b0de115a05 (patch) | |
tree | 7f54ee56da118813f2d1b3a324d322d0c74fa51b /includes/system.php | |
download | pluralconnect-0417260bf158c5d7b62888dae2e202b0de115a05.tar.gz pluralconnect-0417260bf158c5d7b62888dae2e202b0de115a05.tar.bz2 pluralconnect-0417260bf158c5d7b62888dae2e202b0de115a05.zip |
Initial commit
Diffstat (limited to 'includes/system.php')
-rw-r--r-- | includes/system.php | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/includes/system.php b/includes/system.php new file mode 100644 index 0000000..606d63d --- /dev/null +++ b/includes/system.php @@ -0,0 +1,61 @@ +<?php global $system; global $systemCommonName; global $systemID; $title = $systemCommonName; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'; + +function getMember(string $id) { + global $systemID; + + $members = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-members.json"), true); + $member = null; + + foreach ($members as $m) { + if ($m["id"] === $id) $member = $m; + } + + return $member; +} + +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} "; +} + +?> + +<br> +<div class="container"> + <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/sysbanner.php"; ?> + <br> + + <div id="page-content"> + <?php global $isLoggedIn; if ($isLoggedIn): ?> + <small style="opacity:.5;display:block;">(<a href="/edit/<?= $system ?>">edit</a>)</small> + <?php endif; ?> + <?= file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID-disclaimers.html") ?> + </div> + <?php if ($system === "cloudburst") cloudburst(true); else raindrops(true); ?> +</div> + +<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.php'; ?>
\ No newline at end of file |