summaryrefslogtreecommitdiff
path: root/includes/system
diff options
context:
space:
mode:
authorRaindropsSys <contact@minteck.org>2023-04-24 14:03:36 +0200
committerRaindropsSys <contact@minteck.org>2023-04-24 14:03:36 +0200
commit633c92eae865e957121e08de634aeee11a8b3992 (patch)
tree09d881bee1dae0b6eee49db1dfaf0f500240606c /includes/system
parentc4657e4509733699c0f26a3c900bab47e915d5a0 (diff)
downloadpluralconnect-633c92eae865e957121e08de634aeee11a8b3992.tar.gz
pluralconnect-633c92eae865e957121e08de634aeee11a8b3992.tar.bz2
pluralconnect-633c92eae865e957121e08de634aeee11a8b3992.zip
Updated 18 files, added 1692 files and deleted includes/system/compare.inc (automated)
Diffstat (limited to 'includes/system')
-rw-r--r--includes/system/compare.inc187
-rw-r--r--includes/system/history.inc177
2 files changed, 107 insertions, 257 deletions
diff --git a/includes/system/compare.inc b/includes/system/compare.inc
deleted file mode 100644
index 86bc32a..0000000
--- a/includes/system/compare.inc
+++ /dev/null
@@ -1,187 +0,0 @@
-<?php global $system; global $lang; global $pages; global $systemCommonName; global $systemID; $pages = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/pages.json"), true); $title = $pages["s:compare"]["name"][$lang["_name"]] . " · " . $systemCommonName; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; global $travelling; global $app;
-
-$members = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/members.json"), true);
-
-?>
-
- <br>
- <div class="container">
- <h2><?= $lang["compare"]["title"] ?> <?= $systemCommonName ?></h2>
- <div class="comparison" style="<?php if ($systemID === $app["other"]["id"]): ?>grid-template-columns: 3fr 1.5fr 2fr repeat(4, 1fr);<?php endif; ?>">
- <span class="comparison-header comparison-item">
- <span class="comparison-header-l0"><abbr title="<?= $lang["compare"]["member"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["member"][0] ?></abbr></span>
- <span class="comparison-header-l1"><abbr title="<?= $lang["compare"]["member"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["member"][1] ?></abbr></span>
- <span class="comparison-header-l2"><abbr title="<?= $lang["compare"]["member"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["member"][2] ?></abbr></span>
- <span class="comparison-header-l3"><abbr title="<?= $lang["compare"]["member"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["member"][3] ?></abbr></span>
- <span class="comparison-header-l4"><abbr title="<?= $lang["compare"]["member"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["member"][4] ?></abbr></span>
- <span class="comparison-header-l5"><abbr title="<?= $lang["compare"]["member"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["member"][5] ?></abbr></span>
- </span>
- <span class="comparison-header comparison-item">
- <span class="comparison-header-l0"><abbr title="<?= $lang["compare"]["species"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["species"][0] ?></abbr></span>
- <span class="comparison-header-l1"><abbr title="<?= $lang["compare"]["species"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["species"][1] ?></abbr></span>
- <span class="comparison-header-l2"><abbr title="<?= $lang["compare"]["species"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["species"][2] ?></abbr></span>
- <span class="comparison-header-l3"><abbr title="<?= $lang["compare"]["species"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["species"][3] ?></abbr></span>
- <span class="comparison-header-l4"><abbr title="<?= $lang["compare"]["species"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["species"][4] ?></abbr></span>
- <span class="comparison-header-l5"><abbr title="<?= $lang["compare"]["species"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["species"][5] ?></abbr></span>
- </span>
- <?php if ($systemID !== $app["other"]["id"]): ?>
- <span class="comparison-header comparison-item">
- <span class="comparison-header-l0"><abbr title="Code" data-bs-toggle="tooltip">Code</abbr></span>
- <span class="comparison-header-l1"><abbr title="Code" data-bs-toggle="tooltip">Code</abbr></span>
- <span class="comparison-header-l2"><abbr title="Code" data-bs-toggle="tooltip">Code</abbr></span>
- <span class="comparison-header-l3"><abbr title="Code" data-bs-toggle="tooltip">Code</abbr></span>
- <span class="comparison-header-l4"><abbr title="Code" data-bs-toggle="tooltip">Code</abbr></span>
- <span class="comparison-header-l5"><abbr title="Code" data-bs-toggle="tooltip">Code</abbr></span>
- </span>
- <?php endif; ?>
- <span class="comparison-header comparison-item">
- <span class="comparison-header-l0"><abbr title="<?= $lang["compare"]["relations"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["relations"][0] ?></abbr></span>
- <span class="comparison-header-l1"><abbr title="<?= $lang["compare"]["relations"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["relations"][1] ?></abbr></span>
- <span class="comparison-header-l2"><abbr title="<?= $lang["compare"]["relations"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["relations"][2] ?></abbr></span>
- <span class="comparison-header-l3"><abbr title="<?= $lang["compare"]["relations"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["relations"][3] ?></abbr></span>
- <span class="comparison-header-l4"><abbr title="<?= $lang["compare"]["relations"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["relations"][4] ?></abbr></span>
- <span class="comparison-header-l5"><abbr title="<?= $lang["compare"]["relations"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["relations"][5] ?></abbr></span>
- </span>
- <span class="comparison-header comparison-item">
- <span class="comparison-header-l0"><abbr title="<?= $lang["compare"]["memory"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["memory"][0] ?></abbr></span>
- <span class="comparison-header-l1"><abbr title="<?= $lang["compare"]["memory"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["memory"][1] ?></abbr></span>
- <span class="comparison-header-l2"><abbr title="<?= $lang["compare"]["memory"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["memory"][2] ?></abbr></span>
- <span class="comparison-header-l3"><abbr title="<?= $lang["compare"]["memory"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["memory"][3] ?></abbr></span>
- <span class="comparison-header-l4"><abbr title="<?= $lang["compare"]["memory"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["memory"][4] ?></abbr></span>
- <span class="comparison-header-l5"><abbr title="<?= $lang["compare"]["memory"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["memory"][5] ?></abbr></span>
- </span>
- <span class="comparison-header comparison-item">
- <span class="comparison-header-l0"><abbr title="<?= $lang["compare"]["fictive"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["fictive"][0] ?></abbr></span>
- <span class="comparison-header-l1"><abbr title="<?= $lang["compare"]["fictive"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["fictive"][1] ?></abbr></span>
- <span class="comparison-header-l2"><abbr title="<?= $lang["compare"]["fictive"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["fictive"][2] ?></abbr></span>
- <span class="comparison-header-l3"><abbr title="<?= $lang["compare"]["fictive"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["fictive"][3] ?></abbr></span>
- <span class="comparison-header-l4"><abbr title="<?= $lang["compare"]["fictive"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["fictive"][4] ?></abbr></span>
- <span class="comparison-header-l5"><abbr title="<?= $lang["compare"]["fictive"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["fictive"][5] ?></abbr></span>
- </span>
- <span class="comparison-header comparison-item">
- <span class="comparison-header-l0"><abbr title="<?= $lang["compare"]["little"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["little"][0] ?></abbr></span>
- <span class="comparison-header-l1"><abbr title="<?= $lang["compare"]["little"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["little"][1] ?></abbr></span>
- <span class="comparison-header-l2"><abbr title="<?= $lang["compare"]["little"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["little"][2] ?></abbr></span>
- <span class="comparison-header-l3"><abbr title="<?= $lang["compare"]["little"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["little"][3] ?></abbr></span>
- <span class="comparison-header-l4"><abbr title="<?= $lang["compare"]["little"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["little"][4] ?></abbr></span>
- <span class="comparison-header-l5"><abbr title="<?= $lang["compare"]["little"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["little"][5] ?></abbr></span>
- </span>
- <span class="comparison-header comparison-item">
- <span class="comparison-header-l0"><abbr title="<?= $lang["compare"]["protector"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["protector"][0] ?></abbr></span>
- <span class="comparison-header-l1"><abbr title="<?= $lang["compare"]["protector"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["protector"][1] ?></abbr></span>
- <span class="comparison-header-l2"><abbr title="<?= $lang["compare"]["protector"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["protector"][2] ?></abbr></span>
- <span class="comparison-header-l3"><abbr title="<?= $lang["compare"]["protector"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["protector"][3] ?></abbr></span>
- <span class="comparison-header-l4"><abbr title="<?= $lang["compare"]["protector"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["protector"][4] ?></abbr></span>
- <span class="comparison-header-l5"><abbr title="<?= $lang["compare"]["protector"][0] ?>" data-bs-toggle="tooltip"><?= $lang["compare"]["protector"][5] ?></abbr></span>
- </span>
-
- <?php foreach (scoreOrder($members, $systemID) as $member):
-
- $metadata = $member["_metadata"];
-
- ?>
- <a title="<?= $member["display_name"] ?? $member["name"] ?>" data-bs-toggle="tooltip" class="member-link comparison-item comparison-item-clickable" href="/<?= $member["name"] ?>">
- <img src="<?= getAsset($systemID, $member["id"], "heads") ?>" style="width:24px;"> <span style="vertical-align: middle;"><span class="comparison-name-full"><?= $member["display_name"] ?? $member["name"] ?></span><span class="comparison-name-small"><?= getMiniName($member["display_name"] ?? $member["name"]) ?></span></span>
- <span class="comparison-colors" style="background-color: #<?= $member["color"] ?? "ffffff" ?>; height: 16px; width: 16px;display: inline-block;vertical-align: middle;border-radius:2px;"></span>
- </a>
- <span class="comparison-item">
- <?php foreach ($metadata["species"] ?? [] as $species): ?>
- <img data-bs-toggle="tooltip" title="<?php switch ($species) {
- case "earth":
- if ($metadata["robot"]) echo $lang["species"]["earth"][0]; else if ($metadata["plush"]) echo $lang["species"]["earth"][1]; else echo $lang["species"]["earth"][2];
- break;
-
- case "alicorn":
- if ($metadata["robot"]) echo $lang["species"]["alicorn"][0]; else if ($metadata["plush"]) echo $lang["species"]["alicorn"][1]; else echo $lang["species"]["alicorn"][2];
- break;
-
- case "crystal":
- if ($metadata["robot"]) echo $lang["species"]["crystal"][0]; else if ($metadata["plush"]) echo $lang["species"]["crystal"][1]; else echo $lang["species"]["crystal"][2];
- break;
-
- case "pegasus":
- if ($metadata["robot"]) echo $lang["species"]["pegasus"][0]; else if ($metadata["plush"]) echo $lang["species"]["pegasus"][1]; else echo $lang["species"]["pegasus"][2];
- break;
-
- case "batpony":
- if ($metadata["robot"]) echo $lang["species"]["batpony"][0]; else if ($metadata["plush"]) echo $lang["species"]["batpony"][1]; else echo $lang["species"]["batpony"][2];
- break;
-
- case "unicorn":
- if ($metadata["robot"]) echo $lang["species"]["unicorn"][0]; else if ($metadata["plush"]) echo $lang["species"]["unicorn"][1]; else echo $lang["species"]["unicorn"][2];
- break;
-
- default:
- echo $species . "_" . $metadata["robot"];
- break;
- } ?>" style="width:24px;vertical-align: middle;position:relative;top:-5px;" src="/assets/species/<?= $species ?><?= $metadata["robot"] ? "-robot" : ($metadata["plush"] ? "-plush" : "") ?>.png" alt="<?= $species ?>">
- <?php endforeach; ?>
- </span>
- <?php if ($systemID !== $app["other"]["id"]): ?>
- <span class="comparison-item">
- <?php if (isset($metadata["code"]) && trim($metadata["code"]) !== ""): ?>
- <code style="color: white;"><?= strtoupper(substr($metadata["code"], 0, 3)) ?></code>
- <?php else: ?>-<?php endif; ?>
- </span>
- <?php endif; ?>
- <span class="comparison-item">
- <?= count($metadata["marefriends"]) + count($metadata["sisters"]) + count($metadata["caretakers"]) === 0 ? "-" : "" ?>
- <span class="comparison-relations-count">
- <?= count($metadata["marefriends"]) + count($metadata["sisters"]) > 0 ? count($metadata["marefriends"]) + count($metadata["sisters"]) : "" ?>
- </span>
- <span class="comparison-relations-full">
- <?php global $isLowerLoggedIn; global $isLoggedIn; $index = 0; foreach ($metadata["marefriends"] as $marefriend): $mfSystem = explode("/", $marefriend)[0]; if (!($mfSystem === $app["other"]["id"] && !$isLoggedIn && !$isLowerLoggedIn)): $mfMemberID = explode("/", $marefriend)[1]; $mfMember = array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$mfSystem/members.json"), true), function ($item) use ($mfSystem) {
- global $mfMemberID; global $app; global $isLoggedIn; global $isLowerLoggedIn;
- return $item["id"] === $mfMemberID && !($mfSystem === $app["other"]["id"] && !$isLoggedIn && !$isLowerLoggedIn);
- }); sort($mfMember); $mfMember = $mfMember[0]; ?><a title="<b><?= $mfMember["display_name"] ?? $mfMember["name"] ?></b><br><?= $lang["compare"]["status"][0] ?>" data-bs-toggle="tooltip" data-bs-html="true" class="member-link tooltip-nohelp" href="/<?= $mfMember["name"] ?>"><img src="<?= getAsset($mfSystem, $mfMember["id"], "heads") ?>" style="width:24px;"></a><?php endif; $index++; endforeach; ?><?php $index = 0; foreach ($metadata["sisters"] as $marefriend): $mfSystem = explode("/", $marefriend)[0]; if (!($mfSystem === $app["other"]["id"] && !$isLoggedIn && !$isLowerLoggedIn)): $mfMemberID = explode("/", $marefriend)[1]; $mfMember = array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$mfSystem/members.json"), true), function ($item) use ($mfSystem) {
- global $mfMemberID; global $app; global $isLoggedIn; global $isLowerLoggedIn;
- return $item["id"] === $mfMemberID && !($mfSystem === $app["other"]["id"] && !$isLoggedIn && !$isLowerLoggedIn);
- }); sort($mfMember); $mfMember = $mfMember[0]; ?><a title="<b><?= $mfMember["display_name"] ?? $mfMember["name"] ?></b><br><?= $lang["compare"]["status"][1] ?>" data-bs-toggle="tooltip" data-bs-html="true" class="member-link tooltip-nohelp" href="/<?= $mfMember["name"] ?>"><img src="<?= getAsset($mfSystem, $mfMember["id"], "heads") ?>" style="width:24px;"></a><?php endif; $index++; endforeach; ?><?php $index = 0; foreach ($metadata["caretakers"] as $marefriend): $mfSystem = explode("/", $marefriend)[0]; if (!($mfSystem === $app["other"]["id"] && !$isLoggedIn && !$isLowerLoggedIn)): $mfMemberID = explode("/", $marefriend)[1]; $mfMember = array_filter(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$mfSystem/members.json"), true), function ($item) use ($mfSystem) {
- global $mfMemberID; global $app; global $isLoggedIn; global $isLowerLoggedIn;
- return $item["id"] === $mfMemberID && !($mfSystem === $app["other"]["id"] && !$isLoggedIn && !$isLowerLoggedIn);
- }); sort($mfMember); $mfMember = $mfMember[0]; ?><a title="<b><?= $mfMember["display_name"] ?? $mfMember["name"] ?></b><br><?= $lang["compare"]["status"][2] ?>" data-bs-toggle="tooltip" data-bs-html="true" class="member-link tooltip-nohelp" href="/<?= $mfMember["name"] ?>"><img src="<?= getAsset($mfSystem, $mfMember["id"], "heads") ?>" style="width:24px;"></a><?php endif; $index++; endforeach; ?>
- </span>
- </span>
- <span class="comparison-item">
- <?php if ($metadata["shared_memory"] > 0): ?>
- <?php if ($metadata["shared_memory"] === 1): ?>
- <img data-bs-toggle="tooltip" title="<?= $lang["compare"]["state"][5] ?>" src="/assets/icons/partial.svg" alt="<?= $lang["compare"]["state"][5] ?>" style="width:24px;">
- <?php else: ?>
- <img data-bs-toggle="tooltip" title="<?= $lang["compare"]["state"][6] ?>" src="/assets/icons/complete.svg" alt="<?= $lang["compare"]["state"][6] ?>" style="width:24px;">
- <?php endif; ?>
- <?php else: ?>
- <img data-bs-toggle="tooltip" title="<?= $lang["compare"]["state"][2] ?>" src="/assets/icons/none.svg" alt="<?= $lang["compare"]["state"][2] ?>" style="width:24px;">
- <?php endif; ?>
- </span>
- <span class="comparison-item">
- <?php if ($metadata["fictive"]): ?>
- <img data-bs-toggle="tooltip" title="<?= $lang["compare"]["state"][0] ?>" src="/assets/icons/complete.svg" alt="<?= $lang["compare"]["state"][0] ?>" style="width:24px;">
- <?php else: ?>
- <img data-bs-toggle="tooltip" title="<?= $lang["compare"]["state"][2] ?>" src="/assets/icons/none.svg" alt="<?= $lang["compare"]["state"][2] ?>" style="width:24px;">
- <?php endif; ?>
- </span>
- <span class="comparison-item">
- <?php if ($metadata["little"] === 2): ?>
- <img data-bs-toggle="tooltip" title="<?= $lang["compare"]["state"][0] ?>" src="/assets/icons/complete.svg" alt="<?= $lang["compare"]["state"][0] ?>" style="width:24px;">
- <?php elseif ($metadata["little"] === 3): ?>
- <img data-bs-toggle="tooltip" title="<?= $lang["compare"]["state"][3] ?>" src="/assets/icons/partial.svg" alt="<?= $lang["compare"]["state"][1] ?>" style="width:24px;">
- <?php else: ?>
- <img data-bs-toggle="tooltip" title="<?= $lang["compare"]["state"][2] ?>" src="/assets/icons/none.svg" alt="<?= $lang["compare"]["state"][2] ?>" style="width:24px;">
- <?php endif; ?>
- </span>
- <span class="comparison-item">
- <?php if ($metadata["protector"]): ?>
- <?php if ($travelling[$member["id"]]["travelling"]): ?>
- <img data-bs-toggle="tooltip" title="<?= $lang["compare"]["state"][4] ?>" src="/assets/icons/partial.svg" alt="<?= $lang["compare"]["state"][4] ?>" style="width:24px;">
- <?php else: ?>
- <img data-bs-toggle="tooltip" title="<?= $lang["compare"]["state"][0] ?>" src="/assets/icons/complete.svg" alt="<?= $lang["compare"]["state"][0] ?>" style="width:24px;">
- <?php endif; ?>
- <?php else: ?>
- <img data-bs-toggle="tooltip" title="<?= $lang["compare"]["state"][2] ?>" src="/assets/icons/none.svg" alt="<?= $lang["compare"]["state"][2] ?>" style="width:24px;">
- <?php endif; ?>
- </span>
- <?php endforeach; ?>
- </div>
- </div>
-
-<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?> \ No newline at end of file
diff --git a/includes/system/history.inc b/includes/system/history.inc
index bf1d016..963e124 100644
--- a/includes/system/history.inc
+++ b/includes/system/history.inc
@@ -1,70 +1,74 @@
-<?php global $system; global $lang; global $pages; global $systemCommonName; $pages = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/pages.json"), true); $title = $pages["s:history"]["name"][$lang["_name"]] . " · " . $systemCommonName; global $systemID; global $app; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc';
+<?php global $system; global $lang; global $pages; global $systemCommonName; $pages = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/pages.json"), true); $title = $pages["s:history"]["name"][$lang["_name"]] . " · " . $systemCommonName; global $systemID; global $app; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc'; global $isLoggedIn; global $isLowerLoggedIn;
-?>
+function frenchIfRequired($original) {
+ return $original;
+}
- <br>
- <div class="container" id="page-content">
- <?php
+function getSwitchesForDay(int $day) {
+ global $switches;
- $switches = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/switches.json"), true);
- uksort($switches, function ($a, $b) {
- if (isset($b["timestamp"]) && isset($a["timestamp"])) {
- return strtotime($b["timestamp"]) - strtotime($a["timestamp"]);
- } else {
- return null;
- }
- });
+ $filtered = array_values(array_filter($switches, function ($i) use ($day) {
+ $diff = strtotime(date("Y-m-d")) - strtotime(explode("T", $i["timestamp"])[0]);
+ return $diff <= (86400 * $day) && $diff > (86400 * ($day - 1));
+ }));
- function frenchIfRequired($original) {
- return $original;
+ uksort($filtered, function ($a, $b) {
+ if (isset($b["timestamp"]) && isset($a["timestamp"])) {
+ return strtotime($b["timestamp"]) - strtotime($a["timestamp"]);
+ } else {
+ return null;
}
+ });
- function getSwitchesForDay(int $day) {
- global $switches;
+ return $filtered;
+}
- $filtered = array_values(array_filter($switches, function ($i) use ($day) {
- $diff = strtotime(date("Y-m-d")) - strtotime(explode("T", $i["timestamp"])[0]);
- return $diff <= (86400 * $day) && $diff > (86400 * ($day - 1));
- }));
+function getSwitchBefore(string $id) {
+ global $switches;
- uksort($filtered, function ($a, $b) {
- if (isset($b["timestamp"]) && isset($a["timestamp"])) {
- return strtotime($b["timestamp"]) - strtotime($a["timestamp"]);
- } else {
- return null;
- }
- });
+ $currentPassed = false;
+ $before = null;
- return $filtered;
+ foreach ($switches as $switch) {
+ if ($currentPassed) {
+ $before = $switch;
+ break;
+ } else {
+ if ($switch["id"] === $id) {
+ $currentPassed = true;
+ }
}
+ }
- function getSwitchBefore(string $id) {
- global $switches;
-
- $currentPassed = false;
- $before = null;
-
- foreach ($switches as $switch) {
- if ($currentPassed) {
- $before = $switch;
- break;
- } else {
- if ($switch["id"] === $id) {
- $currentPassed = true;
- }
- }
- }
+ return $before;
+}
- return $before;
- }
+function isNotToday(int $timestamp, int $offset) {
+ if (date('Y-m-d', $timestamp) !== date('Y-m-d', time() - (86400 * $offset))) {
+ return true;
+ } else {
+ return false;
+ }
+}
- function isNotToday(int $timestamp, int $offset) {
- if (date('Y-m-d', $timestamp) !== date('Y-m-d', time() - (86400 * $offset))) {
- return true;
+if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/history.json")) file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/history.json", "{}");
+
+$cache = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/history.json"), true);
+
+function page() { global $lang; global $systemCommonName; global $systemID; global $app; global $switches; ?>
+ <br>
+ <div class="container" id="page-content">
+ <?php
+
+ $switches = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$systemID/switches.json"), true);
+
+ uksort($switches, function ($a, $b) {
+ if (isset($b["timestamp"]) && isset($a["timestamp"])) {
+ return strtotime($b["timestamp"]) - strtotime($a["timestamp"]);
} else {
- return false;
+ return null;
}
- }
+ });
?>
<h2><?= $systemID === $app["other"]["id"] ? "Front history in " . $app["other"]["name"] : $lang["history"]["title"] . " " . $systemCommonName ?></h2>
@@ -76,28 +80,28 @@
</script>
</div>
<?php foreach ([
- [ "Today", 0 ],
- [ "Yesterday", 1 ],
- [ date('D j M', time() - (86400 * 2)), 2 ],
- [ date('D j M', time() - (86400 * 3)), 3 ],
- [ date('D j M', time() - (86400 * 4)), 4 ],
- [ date('D j M', time() - (86400 * 5)), 5 ],
- [ date('D j M', time() - (86400 * 6)), 6 ],
- [ date('D j M', time() - (86400 * 7)), 7 ],
- [ date('D j M', time() - (86400 * 8)), 8 ],
- [ date('D j M', time() - (86400 * 9)), 9 ],
- ] as $day):
+ [ "Today", 0 ],
+ [ "Yesterday", 1 ],
+ [ date('D j M', time() - (86400 * 2)), 2 ],
+ [ date('D j M', time() - (86400 * 3)), 3 ],
+ [ date('D j M', time() - (86400 * 4)), 4 ],
+ [ date('D j M', time() - (86400 * 5)), 5 ],
+ [ date('D j M', time() - (86400 * 6)), 6 ],
+ [ date('D j M', time() - (86400 * 7)), 7 ],
+ [ date('D j M', time() - (86400 * 8)), 8 ],
+ [ date('D j M', time() - (86400 * 9)), 9 ],
+ ] as $day):
$switchesDay = getSwitchesForDay($day[1]);
if (isset($switchesDay[count($switchesDay) - 1])) {
$switchesDay[] = getSwitchBefore($switchesDay[count($switchesDay) - 1]["id"]);
}
?>
- <h4 style="margin-top:15px;"><?= frenchIfRequired($day[0]) ?></h4>
+ <h4 style="margin-top:15px;"><?= frenchIfRequired($day[0]) ?></h4>
<?php if (count($switchesDay) === 0): ?>
- <p class="text-muted">No switches happened on that day</p>
- <?php endif; ?>
+ <p class="text-muted">No switches happened on that day</p>
+ <?php endif; ?>
<?php foreach ($switchesDay as $switch): $switch["timestamp"] = strtotime($switch["timestamp"]); ?>
- <?php if (isset($switch["members"][0])): $member = getMemberWithoutSystem($switch["members"][0]); ?>
+ <?php if (isset($switch["members"][0])): $member = getMemberWithoutSystem($switch["members"][0]); ?>
<div class="fronter">
<span class="fronter-date" data-date-time="<?= isNotToday($switch["timestamp"], $day[1]) ? strtotime(date('Y-m-d', $switch["timestamp"])) : $switch["timestamp"] ?>" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;">
<?= isNotToday($switch["timestamp"], $day[1]) ? "00:00" : date('H:i', $switch["timestamp"]) ?>
@@ -112,7 +116,7 @@
<?php endif; ?>
</span>
</div>
- <?php else: ?>
+ <?php else: ?>
<div class="fronter">
<span class="fronter-date" data-date-time="<?= isNotToday($switch["timestamp"], $day[1]) ? strtotime(date('Y-m-d', $switch["timestamp"])) : $switch["timestamp"] ?>" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;">
<?= isNotToday($switch["timestamp"], $day[1]) ? "00:00" : date('H:i', $switch["timestamp"]) ?>
@@ -121,13 +125,46 @@
<span class="text-muted"><?= $lang["history"]["fallback"] ?></span>
</span>
</div>
- <?php endif; ?>
- <?php endforeach; ?>
+ <?php endif; ?>
+ <?php endforeach; ?>
<?php endforeach; ?>
</div>
<script>
Array.from(document.getElementsByClassName("fronter-date")).forEach((i) => { i.innerText = new Date(parseInt(i.getAttribute("data-date-time").trim()) * 1000).toTimeString().split(" ")[0].substring(0, 5) + " " });
document.getElementById("timezone").style.display = "";
</script>
+<?php }
+
+?>
+
+<?php
+
+if (!isset($cache[$systemID])) $cache[$systemID] = [];
+
+if (!isset($cache[$systemID]["private"]) || !isset($cache[$systemID]["public"])) {
+ ob_start();
+ $isLoggedInOldState = $isLoggedIn;
+ $isLowerLoggedInOldState = $isLowerLoggedIn;
+ $isLoggedIn = true;
+ $isLowerLoggedIn = true;
+ page();
+ $isLoggedIn = $isLoggedInOldState;
+ $isLowerLoggedIn = $isLowerLoggedInOldState;
+ $cache[$systemID]["private"] = ob_get_contents();
+ ob_end_clean();
+
+ ob_start();
+ $isLoggedInOldState = $isLoggedIn;
+ $isLowerLoggedInOldState = $isLowerLoggedIn;
+ $isLoggedIn = false;
+ $isLowerLoggedIn = false;
+ page();
+ $isLoggedIn = $isLoggedInOldState;
+ $isLowerLoggedIn = $isLowerLoggedInOldState;
+ $cache[$systemID]["public"] = ob_get_contents();
+ ob_end_clean();
+}
+
+echo($isLoggedIn ? $cache[$systemID]["private"] : $cache[$systemID]["public"]); file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/history.json", json_encode($cache)); ?>
<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?> \ No newline at end of file