From 68efbff6a981bf5c3081ee4574e14b64a731ff47 Mon Sep 17 00:00:00 2001 From: RaindropsSys Date: Fri, 23 Jun 2023 12:49:45 +0200 Subject: Updated 2 files (automated) --- pages/evening.inc | 81 +++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 64 insertions(+), 17 deletions(-) (limited to 'pages/evening.inc') diff --git a/pages/evening.inc b/pages/evening.inc index c0b2818..f40cb20 100644 --- a/pages/evening.inc +++ b/pages/evening.inc @@ -3,9 +3,13 @@ $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", "[]"); +if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/evening/locked.json")) file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/evening/locked.json", "{}"); + +if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/evening.json")) unlink($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/evening.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); +$locked = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/evening/locked.json"), true); if (isset($_GET["ignore"]) && isset($_GET["day"])) { if ($_GET["ignore"] === "1") { @@ -43,6 +47,26 @@ if (isset($_GET["ignore"]) && isset($_GET["day"])) { die(); } +if (isset($_GET["lock"]) && isset($_GET["day"]) && isset($_GET["data"])) { + if (isset($locked[$_GET["day"]])) { + unset($locked[$_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/locked.json", json_encode($locked)); + header("Location: /-/evening"); + die(); + } else { + $locked[$_GET["day"]] = $_GET["data"]; + + 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/locked.json", json_encode($locked)); + header("Location: /-/evening"); + 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", "{}"); @@ -169,23 +193,23 @@ if (!isset($cache["content"]) || date('Y-m-d') !== $cache["day"]) { $times = []; foreach ($a[0] as $id) { - $times[] = getLastFronted($members, $id); + if (getLastFronted($members, $id) > 0) $times[] = getLastFronted($members, $id); } foreach ($a[1] as $id) { - $times[] = getLastFronted($members, $id); + if (getLastFronted($members, $id) > 0) $times[] = getLastFronted($members, $id); } - $timeA = time() - min(...$times); + $timeA = time() - min($times); $times = []; foreach ($b[0] as $id) { - $times[] = getLastFronted($members, $id); + if (getLastFronted($members, $id) > 0) $times[] = getLastFronted($members, $id); } foreach ($b[1] as $id) { - $times[] = getLastFronted($members, $id); + if (getLastFronted($members, $id) > 0) $times[] = getLastFronted($members, $id); } - $timeB = time() - min(...$times); + $timeB = time() - min($times); return $timeB - $timeA; }); $pairs = array_values($pairs); foreach ($pairs as $pair): $times = []; ?> @@ -197,26 +221,35 @@ if (!isset($cache["content"]) || date('Y-m-d') !== $cache["day"]) { "> - () + () - = 1686787200): ?> + = 1686787200): ?>

-
+
@@ -226,27 +259,41 @@ if (!isset($cache["content"]) || date('Y-m-d') !== $cache["day"]) { $times = []; foreach ($pair[0] as $id) { - $times[] = getLastFronted($members, $id); + if (getLastFronted($members, $id) > 0) $times[] = getLastFronted($members, $id); } foreach ($pair[1] as $id) { - $times[] = getLastFronted($members, $id); + if (getLastFronted($members, $id) > 0) $times[] = getLastFronted($members, $id); } - $time = time() - min(...$times); + $time = time() - min($times); echo(timeAgo(time() - $time)); ?>
+ + " class="btn btn-outline-secondary">Unlock + + " class="btn btn-outline-primary">Lock +    - Unignore + Unignore - Ignore + Ignore
" : "" ?> - +