summaryrefslogtreecommitdiff
path: root/pages/schedule.inc
diff options
context:
space:
mode:
Diffstat (limited to 'pages/schedule.inc')
-rw-r--r--pages/schedule.inc235
1 files changed, 0 insertions, 235 deletions
diff --git a/pages/schedule.inc b/pages/schedule.inc
deleted file mode 100644
index 3c6bc2a..0000000
--- a/pages/schedule.inc
+++ /dev/null
@@ -1,235 +0,0 @@
-<?php
-
-require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $lang; global $pages;
-require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc';
-global $app; global $_PROFILE;
-
-$pairs = [];
-
-$pairs2 = [
- ["lqolg"],
- ["tfbob"],
- ["zajrk"],
- ["ktrdb"],
- ["hpwyq"],
- ["qbzxm"],
- ["qraku"],
- ["mhnqy"],
- ["ztfjz"],
- ["ufadt"],
- ["ckqsw"]
-];
-
-// --------------------
-
-function getRelativeDay($offset) {
- if ($offset === 0) return "Today";
- if ($offset === 1) return "Tomorrow";
- return "On " . date('l', time() + ($offset * 86400)) . " (in $offset days, " . date('j M', time() + ($offset * 86400)) . ")";
-}
-
-$ignored = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/schedule/ignored.json"), true);
-$locked = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/schedule/locked.json"), true);
-
-$members = array_map(function ($i) {
- $system = "gdapd";
- $i["_lastFronted"] = -1;
- $id = $i["id"];
- $memberData = $i;
-
- $fronters = array_map(function ($item) {
- return $item["id"];
- }, json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/fronters.json"), true)["members"]);
-
- if (in_array($id, $fronters)) {
- $i["_lastFronted"] = time();
- } else {
- $switches = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/switches.json"), true);
-
- $thisMember = array_filter($switches, function ($item) use ($memberData) {
- return in_array($memberData["id"], $item["members"]);
- });
-
- $thisMember = array_values($thisMember);
- $frontingEnd = null;
-
- if (count($thisMember) > 0) {
- $thisIndex = array_search($thisMember[0], $switches);
-
- $frontingStart = $thisMember[0];
- $frontingEnd = $switches[$thisIndex - 1];
- }
-
- if ($frontingEnd !== null && isset($frontingStart)) {
- $i["_lastFronted"] = strtotime($frontingEnd["timestamp"]);
- }
- }
-
- return $i;
-}, array_values(array_filter(scoreOrderGlobal(), function ($i) {
- return $i["_system"] === "gdapd";
-})));
-
-if (isset($_GET["ignore"]) && isset($_GET["day"])) {
- if ($_GET["ignore"] === "1") {
- if (preg_match("/^\d{4}-\d{2}-\d{2}$/m", $_GET["day"]) === false) {
- header("Location: /-/schedule");
- die();
- }
-
- if (!in_array($_GET["day"], $ignored)) {
- $ignored[] = $_GET["day"];
- }
-
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/schedule/ignored.json", json_encode($ignored));
- header("Location: /-/schedule");
- die();
- } elseif ($_GET["ignore"] === "0") {
- if (preg_match("/^\d{4}-\d{2}-\d{2}$/m", $_GET["day"]) === false) {
- header("Location: /-/schedule");
- die();
- }
-
- if (in_array($_GET["day"], $ignored)) {
- unset($ignored[array_search($_GET["day"], $ignored)]);
- }
-
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/schedule/ignored.json", json_encode($ignored));
- header("Location: /-/schedule");
- die();
- }
-
- die();
-}
-
-
-?>
-
-<style>
- #main a {
- color: inherit;
- text-decoration: inherit;
- }
-
- #main a:hover {
- opacity: .75;
- }
-
- #main a:active, #main a:focus {
- opacity: .75;
- }
-</style>
-
-<br>
-<div class="container" id="main">
- <details>
- <summary style="list-style: none; outline: none; cursor: text;">
- <h2>Raindrops System schedule</h2>
- </summary>
- <ul>
- <?php $requested = []; foreach ([...$pairs, ...$pairs2] as $pair) {
- array_push($requested, ...$pair);
- } $requested = array_unique($requested); foreach ($requested as $id) {
- if (getMemberWithoutSystem($id) !== null) {
- echo("<li>" . (getMemberWithoutSystem($id)["display_name"] ?? getMemberWithoutSystem($id)["name"]) . "</li>");
- } else {
- echo("<li>NULL (" . $id . ")</li>");
- }
- } ?>
- </ul>
- <ul>
- <?php usort($pairs, function ($a, $b) use ($members) {
- $times = [];
-
- foreach ($a as $id) {
- if (getLastFronted($members, $id) > 0) $times[] = getLastFronted($members, $id);
- }
-
- $timeA = time() - min($times);
- $times = [];
-
- foreach ($b as $id) {
- if (getLastFronted($members, $id) > 0) $times[] = getLastFronted($members, $id);
- }
-
- $timeB = time() - min($times);
-
- if ($timeA < 5 || $timeB < 5) {
- return -INF;
- } else {
- return $timeB - $timeA;
- }
- }); $pairsM = array_values($pairs); foreach ($pairsM as $pair): $times = []; ?>
- <li>
- <?php foreach ($pair as $id): ?>
- <img style="width: 24px;" src="<?= getAsset("gdapd", $id) ?>"> <?= getMemberWithoutSystem($id)["display_name"] ?>
- <?php $times[] = getLastFronted($members, $id); endforeach; ?>
- (<?= time() - max($times) ?>)
- </li>
- <?php endforeach; ?>
- </ul>
- <ul>
- <?php usort($pairs2, function ($a, $b) use ($members) {
- $times = [];
-
- foreach ($a as $id) {
- if (getLastFronted($members, $id) > 0) $times[] = getLastFronted($members, $id);
- }
-
- $timeA = time() - min($times);
- $times = [];
-
- foreach ($b as $id) {
- if (getLastFronted($members, $id) > 0) $times[] = getLastFronted($members, $id);
- }
-
- $timeB = time() - min($times);
-
- if ($timeA < 5 || $timeB < 5) {
- return -INF;
- } else {
- return $timeB - $timeA;
- }
- }); $pairsM = array_values($pairs2); foreach ($pairsM as $pair): $times = []; ?>
- <li>
- <?php foreach ($pair as $id): ?>
- <img style="width: 24px;" src="<?= getAsset("gdapd", $id) ?>"> <?= getMemberWithoutSystem($id)["display_name"] ?>
- <?php $times[] = getLastFronted($members, $id); endforeach; ?>
- (<?= time() - max($times) ?>)
- </li>
- <?php endforeach; ?>
- </ul>
- </details>
-
- <div style="display: grid; grid-template-columns: max-content 1fr; grid-column-gap: 10px;">
- <?php
-
- $pairs = array_values($pairs);
- $pairs2 = array_values($pairs2);
-
- $i = 0;
- $i1 = 0;
- $i2 = 0;
- $max = 62;
-
- while ($i < $max): ?>
- <div style="text-align: right;">
- <b><?= getRelativeDay($i) ?>:</b>
- </div>
- <div>
- <?php $j = 0; foreach ($pairs2[$i2] as $id): ?>
- <a href="/<?= getMemberWithoutSystem($id)["name"] ?>"><img style="width: 24px;" src="<?= getAsset("gdapd", $id, "heads") ?>"> <?= getMemberWithoutSystem($id)["display_name"] ?></a>
- <?php if (isset($pairs2[$i2][$j + 1])): ?>and<?php endif; ?>
- <?php $j++; endforeach; $i2++; ?>
- </div>
-
- <?php $i++;
-
- if (!isset($pairs2[$i2])) $i2 = 0;
- if (!isset($pairs[$i1])) $i1 = 0;
-
- endwhile; ?>
- </div>
-</div>
-
-<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?>