summaryrefslogtreecommitdiff
path: root/pages
diff options
context:
space:
mode:
Diffstat (limited to 'pages')
-rw-r--r--pages/api/computer.php2
-rw-r--r--pages/api/computername.php2
-rw-r--r--pages/computers.inc6
-rw-r--r--pages/evening.inc262
-rw-r--r--pages/fronting.inc3
5 files changed, 273 insertions, 2 deletions
diff --git a/pages/api/computer.php b/pages/api/computer.php
index 7dce4b6..2c75183 100644
--- a/pages/api/computer.php
+++ b/pages/api/computer.php
@@ -1,5 +1,7 @@
<?php
+if (time() >= 1688169600) die();
+
if (isset($_GET["chrome"])) {
header("Access-Control-Allow-Origin: chrome-extension://" . preg_replace("/[^a-z]/m", "", $_GET["chrome"]));
header("Access-Control-Allow-Credentials: true");
diff --git a/pages/api/computername.php b/pages/api/computername.php
index 1a719b0..477a8e6 100644
--- a/pages/api/computername.php
+++ b/pages/api/computername.php
@@ -1,5 +1,7 @@
<?php
+if (time() >= 1688169600) die();
+
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $_PROFILE;
if (!$isLoggedIn) header("Location: /-/login") and die();
diff --git a/pages/computers.inc b/pages/computers.inc
index 643fe87..55d8ec5 100644
--- a/pages/computers.inc
+++ b/pages/computers.inc
@@ -1,5 +1,9 @@
<?php
+if (time() >= 1688169600) {
+ peh_error("Page not found: computers", 404);
+}
+
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $lang; global $pages; global $pagename; global $_USER; global $_PROFILE;
$computer = [];
$parts = explode("/", $pagename);
@@ -897,7 +901,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc';
<p>Click on a device to view information about it</p>
<div class="alert alert-warning">
- <b>Luna and the Cold Haze Devices software are deprecated.</b> These applications are now deprecated and monitoring devices through Luna is not supported anymore. Basic support and servers will be shut down in August 2023.
+ <b>Luna and the Cold Haze Devices software are deprecated.</b> These applications are now deprecated and monitoring devices through Luna is not supported anymore. Basic support and servers will be shut down on July 1<sup>st</sup>.
</div>
<ul class="list-group">
diff --git a/pages/evening.inc b/pages/evening.inc
new file mode 100644
index 0000000..6f9e7b8
--- /dev/null
+++ b/pages/evening.inc
@@ -0,0 +1,262 @@
+<?php
+
+$emergencyHeader = true; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $lang; global $pages;
+
+if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/evening/ignored.json")) file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/evening/ignored.json", "[]");
+
+$pairs = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/evening/pairs.json"), true);
+$ignored = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/evening/ignored.json"), true);
+
+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: /-/evening");
+ die();
+ }
+
+ if (!in_array($_GET["day"], $ignored)) {
+ $ignored[] = $_GET["day"];
+ }
+
+ if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/evening.json")) unlink($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/evening.json");
+
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/evening/ignored.json", json_encode($ignored));
+ header("Location: /-/evening");
+ die();
+ } elseif ($_GET["ignore"] === "0") {
+ if (preg_match("/^\d{4}-\d{2}-\d{2}$/m", $_GET["day"]) === false) {
+ header("Location: /-/evening");
+ die();
+ }
+
+ if (in_array($_GET["day"], $ignored)) {
+ unset($ignored[array_search($_GET["day"], $ignored)]);
+ }
+
+ if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/evening.json")) unlink($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/evening.json");
+
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/evening/ignored.json", json_encode($ignored));
+ header("Location: /-/evening");
+ die();
+ }
+
+ die();
+}
+
+require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc';
+
+if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/evening.json")) file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/evening.json", "{}");
+$cache = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/evening.json"), true);
+
+if (!isset($cache["content"]) || date('Y-m-d') !== $cache["day"]) {
+ ob_start();
+
+ $members = $members = [
+ ...array_map(function ($i) {
+ $system = "ynmuc";
+ $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"] === "ynmuc";
+ }))),
+ ...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";
+ })))
+ ];
+
+ ?>
+
+<style>
+ @media (max-width: 767px) {
+ .member-name, .member-list-separator {
+ display: none;
+ }
+
+ .member-collection {
+ width: 100%;
+ text-align: center;
+ }
+ }
+
+ .member-link:hover {
+ opacity: .75;
+ }
+</style>
+
+<br>
+<div class="container">
+ <div>
+ <h2><?= $pages["evening"]["name"][$lang["_name"]] ?><?= time() >= 1686787200 ? "" : " (Beta)" ?></h2>
+
+ <div class="alert alert-warning">
+ <b>The evening schedule will replace the fronting schedule starting June 15<sup>th</sup>.</b> The fronting schedule page contains more information and shows the schedule up to that date. The evening schedule is experimental until then.
+ </div>
+
+ <details>
+ <summary style="list-style: none; outline: none; cursor: text;">
+ <p>Click on the "Ignore" button to mark an evening as ignored and shift the schedule one day after. You can revert this by clicking on "Unignore".</p>
+ </summary>
+ <ul>
+ <?php usort($pairs, function ($a, $b) use ($members) {
+ $times = [];
+
+ foreach ($a[0] as $id) {
+ $times[] = getLastFronted($members, $id);
+ }
+ foreach ($a[1] as $id) {
+ $times[] = getLastFronted($members, $id);
+ }
+
+ $timeA = time() - min(...$times);
+ $times = [];
+
+ foreach ($b[0] as $id) {
+ $times[] = getLastFronted($members, $id);
+ }
+ foreach ($b[1] as $id) {
+ $times[] = getLastFronted($members, $id);
+ }
+
+ $timeB = time() - min(...$times);
+
+ return $timeB - $timeA;
+ }); $pairs = array_values($pairs); foreach ($pairs as $pair): $times = []; ?>
+ <li>
+ <?php foreach ($pair[0] as $id): ?>
+ <img style="width: 24px;" src="<?= getAsset("ynmuc", $id) ?>"> <?= getMemberWithoutSystem($id)["display_name"] ?>
+ <?php $times[] = getLastFronted($members, $id); endforeach; ?>
+ with
+ <?php foreach ($pair[1] 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>
+
+ <?php $listI = 0; for ($i = 0; $i < 15; $i++): $pair = $pairs[$listI]; if (time() + 86400 * $i >= 1686787200): ?>
+ <h4><?= date('l j', time() + 86400 * $i) ?></h4>
+ <div style="display: grid; grid-template-columns: repeat(2, 1fr) 100px 100px; grid-gap: 20px; margin-bottom: 10px;">
+ <div style="display: flex; align-items: center;<?php if (in_array(date('Y-m-d', time() + 86400 * $i), $ignored)): ?>opacity: .75; filter: saturate(0);<?php endif; ?>">
+ <div class="member-collection">
+ <?php foreach ($pair[0] as $id): ?>
+ <a class="member-link" href="/<?= getMemberWithoutSystem($id)["name"] ?>"><img style="width: 24px;" src="<?= getAsset("ynmuc", $id, "heads") ?>"> <span class="member-name" style="<?php if (in_array(date('Y-m-d', time() + 86400 * $i), $ignored)): ?>text-decoration: line-through;<?php endif; ?>"><?= getMemberWithoutSystem($id)["display_name"] ?></span></a><br class="member-list-separator">
+ <?php $times[] = getLastFronted($members, $id); endforeach; ?>
+ </div>
+ </div>
+ <div style="display: flex; align-items: center;<?php if (in_array(date('Y-m-d', time() + 86400 * $i), $ignored)): ?>opacity: .75; filter: saturate(0);<?php endif; ?>">
+ <div class="member-collection">
+ <?php foreach ($pair[1] as $id): ?>
+ <a class="member-link" href="/<?= getMemberWithoutSystem($id)["name"] ?>"><img style="width: 24px;" src="<?= getAsset("gdapd", $id, "heads") ?>"> <span class="member-name" style="<?php if (in_array(date('Y-m-d', time() + 86400 * $i), $ignored)): ?>text-decoration: line-through;<?php endif; ?>"><?= getMemberWithoutSystem($id)["display_name"] ?></span></a><br class="member-list-separator">
+ <?php $times[] = getLastFronted($members, $id); endforeach; ?>
+ </div>
+ </div>
+ <div style="display: flex; align-items: center; justify-content: center;">
+ <?php
+
+ $times = [];
+
+ foreach ($pair[0] as $id) {
+ $times[] = getLastFronted($members, $id);
+ }
+ foreach ($pair[1] as $id) {
+ $times[] = getLastFronted($members, $id);
+ }
+
+ $time = time() - min(...$times);
+ echo(timeAgo(time() - $time));
+
+ ?>
+ </div>
+ <div style="display: flex; align-items: center; justify-content: center;">
+ <?php if (in_array(date('Y-m-d', time() + 86400 * $i), $ignored)): ?>
+ <a href="?ignore=0&day=<?= date('Y-m-d', time() + 86400 * $i) ?>" class="btn btn-outline-success">Unignore</a>
+ <?php else: ?>
+ <a href="?ignore=1&day=<?= date('Y-m-d', time() + 86400 * $i) ?>" class="btn btn-outline-danger">Ignore</a>
+ <?php endif; ?>
+ </div>
+ </div>
+ <?= $i < 14 ? "<hr>" : "" ?>
+ <?php endif; if (!in_array(date('Y-m-d', time() + 86400 * $i), $ignored)) $listI++; if ($listI === count($pairs)) $listI = 0; endfor; ?>
+ </div>
+</div>
+<?php
+
+ $cache["content"] = ob_get_contents();
+ $cache["day"] = date('Y-m-d');
+ ob_end_clean();
+}
+
+echo($cache["content"]);
+file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/evening.json", json_encode($cache));
+
+?>
+
+<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?>
diff --git a/pages/fronting.inc b/pages/fronting.inc
index 9873b81..1c16a80 100644
--- a/pages/fronting.inc
+++ b/pages/fronting.inc
@@ -1,7 +1,8 @@
<?php
if (time() >= 1686787200) {
- peh_error("Page not found: fronting", 404);
+ header("Location: /evening");
+ die();
}
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $lang; global $pages;