summaryrefslogtreecommitdiff
path: root/includes/util/evening.inc
diff options
context:
space:
mode:
Diffstat (limited to 'includes/util/evening.inc')
-rw-r--r--includes/util/evening.inc68
1 files changed, 68 insertions, 0 deletions
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