From 46251292b5c8b431de66aeff473594ccec60e04c Mon Sep 17 00:00:00 2001
From: RaindropsSys <contact@minteck.org>
Date: Thu, 20 Jul 2023 18:29:09 +0200
Subject: Updated 19 files and added 26 files (automated)

---
 includes/util/evening.inc | 68 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)
 create mode 100644 includes/util/evening.inc

(limited to 'includes/util/evening.inc')

diff --git a/includes/util/evening.inc b/includes/util/evening.inc
new file mode 100644
index 0000000..58e511e
--- /dev/null
+++ b/includes/util/evening.inc
@@ -0,0 +1,68 @@
+<?php
+
+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");
+
+global $use2023UI;
+
+$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") {
+        if (preg_match("/^\d{4}-\d{2}-\d{2}$/m", $_GET["day"]) === false) {
+            header("Location: /$_GET[_]");
+            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: /$_GET[_]");
+        die();
+    } elseif ($_GET["ignore"] === "0") {
+        if (preg_match("/^\d{4}-\d{2}-\d{2}$/m", $_GET["day"]) === false) {
+            header("Location: /$_GET[_]");
+            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: /$_GET[_]");
+        die();
+    }
+
+    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: /$_GET[_]");
+        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: /$_GET[_]");
+        die();
+    }
+}
\ No newline at end of file
-- 
cgit