summaryrefslogtreecommitdiff
path: root/includes/util/evening.inc
diff options
context:
space:
mode:
authorRaindropsSys <contact@minteck.org>2023-07-20 18:29:09 +0200
committerRaindropsSys <contact@minteck.org>2023-07-20 18:29:09 +0200
commit46251292b5c8b431de66aeff473594ccec60e04c (patch)
treec9f2c196e50f064a66625813660148379212d9d7 /includes/util/evening.inc
parent93c96fd1d89782570de9478c26f17b406e9dd7a0 (diff)
downloadpluralconnect-46251292b5c8b431de66aeff473594ccec60e04c.tar.gz
pluralconnect-46251292b5c8b431de66aeff473594ccec60e04c.tar.bz2
pluralconnect-46251292b5c8b431de66aeff473594ccec60e04c.zip
Updated 19 files and added 26 files (automated)
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