From 633c92eae865e957121e08de634aeee11a8b3992 Mon Sep 17 00:00:00 2001 From: RaindropsSys Date: Mon, 24 Apr 2023 14:03:36 +0200 Subject: Updated 18 files, added 1692 files and deleted includes/system/compare.inc (automated) --- includes/system/history.inc | 177 ++++++++++++++++++++++++++------------------ 1 file changed, 107 insertions(+), 70 deletions(-) (limited to 'includes/system/history.inc') 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 @@ - +function frenchIfRequired($original) { + return $original; +} -
-
- (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; ?> +
+
+

@@ -76,28 +80,28 @@
-

+

-

No switches happened on that day

- +

No switches happened on that day

+ - +
" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;"> @@ -112,7 +116,7 @@
- +
" style="opacity:.5;font-family: monospace;font-size:14px;vertical-align: middle;"> @@ -121,13 +125,46 @@
- - + +
+ + + \ No newline at end of file -- cgit