From 8cdbff7146e81546143f1f54e75bfd0eb34d17a0 Mon Sep 17 00:00:00 2001 From: RaindropsSys Date: Tue, 2 May 2023 18:59:49 +0200 Subject: Updated 3 files and added 2 files (automated) --- pages/api/overage.php | 47 ++++++++++++++++++++++++++++++++++ pages/api/schedule.php | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++ pages/rules.inc | 12 ++++++--- 3 files changed, 124 insertions(+), 4 deletions(-) create mode 100644 pages/api/overage.php create mode 100644 pages/api/schedule.php (limited to 'pages') diff --git a/pages/api/overage.php b/pages/api/overage.php new file mode 100644 index 0000000..aef4ac6 --- /dev/null +++ b/pages/api/overage.php @@ -0,0 +1,47 @@ + null, + "cloudburst" => null +]; + +foreach (["raindrops", "cloudburst"] as $userName) { + $allowNsfw = null; + $fronters = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($userName === "raindrops" ? "gdapd" : "ynmuc") . "/fronters.json"), true); + + if (count($fronters["members"]) > 0) { + $id = $fronters["members"][0]["id"]; + + if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $id . ".json")) { + $info = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $id . ".json"), true); + + if (isset($info["birth"]["age"]) && $info["birth"]["age"] < 15 && $info["birth"]["age"] > 0) { + $allowNsfw = false; + } else if (isset($info["birth"]["year"]) && $info["birth"]["year"] > 1900) { + if (!isset($info["birth"]["date"])) $info["birth"]["date"] = "01-01"; + + $age = (int)date('Y') - $info["birth"]["year"] + (strtotime(date('Y') . "-" . $info["birth"]["date"]) <= time() ? 0 : -1); + + if ($age < 15) { + $allowNsfw = false; + } else { + $allowNsfw = true; + } + } else if ((!isset($info["birth"]["age"]) || $info["birth"]["age"] === 0) && (!isset($info["birth"]["year"]) || $info["birth"]["year"] > 1900)) { + $allowNsfw = false; + } else { + $allowNsfw = true; + } + } + } + + $obj[$userName] = $allowNsfw; +} + +die(json_encode($obj, JSON_PRETTY_PRINT)); \ No newline at end of file diff --git a/pages/api/schedule.php b/pages/api/schedule.php new file mode 100644 index 0000000..489e28f --- /dev/null +++ b/pages/api/schedule.php @@ -0,0 +1,69 @@ + [], + "tomorrow" => [] +]; + +$raindrops = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/planner/gdapd.json"), true); +$cloudburst = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/planner/ynmuc.json"), true); + +if (isset($raindrops[date('Y-m-d', time())]) || isset($cloudburst[date('Y-m-d', time())])) { + $rd = $raindrops[date('Y-m-d', time())]; + $cb = $cloudburst[date('Y-m-d', time())]; + $longest = max(count($rd), count($cb)); + + for ($x = 0; $x < $longest; $x++) { + $item = []; + $item["raindrops"] = null; + $item["cloudburst"] = null; + + if (isset($rd[$x])) { + $item["raindrops"] = array_map(function ($i) { return getMemberWithoutSystem($i)["display_name"] ?? getMemberWithoutSystem($i)["name"]; }, array_filter($rd[$x], function ($i) { return isset($i); })); + } else if (isset($obj["today"][$x - 1]["raindrops"])) { + $item["raindrops"] = $obj["today"][$x - 1]["raindrops"]; + } + + if (isset($cb[$x])) { + $item["cloudburst"] = array_map(function ($i) { return getMemberWithoutSystem($i)["display_name"] ?? getMemberWithoutSystem($i)["name"]; }, array_filter($cb[$x], function ($i) { return isset($i); })); + } else if (isset($obj["today"][$x - 1]["cloudburst"])) { + $item["cloudburst"] = $obj["today"][$x - 1]["cloudburst"]; + } + + $obj["today"][] = $item; + } +} + +if (isset($raindrops[date('Y-m-d', time() + 86400)]) || isset($cloudburst[date('Y-m-d', time() + 86400)])) { + $rd = $raindrops[date('Y-m-d', time() + 86400)]; + $cb = $cloudburst[date('Y-m-d', time() + 86400)]; + $longest = max(count($rd), count($cb)); + + for ($x = 0; $x < $longest; $x++) { + $item = []; + $item["raindrops"] = null; + $item["cloudburst"] = null; + + if (isset($rd[$x])) { + $item["raindrops"] = array_map(function ($i) { return getMemberWithoutSystem($i)["display_name"] ?? getMemberWithoutSystem($i)["name"]; }, array_filter($rd[$x], function ($i) { return isset($i); })); + } else if (isset($obj["today"][$x - 1]["raindrops"])) { + $item["raindrops"] = $obj["today"][$x - 1]["raindrops"]; + } + + if (isset($cb[$x])) { + $item["cloudburst"] = array_map(function ($i) { return getMemberWithoutSystem($i)["display_name"] ?? getMemberWithoutSystem($i)["name"]; }, array_filter($cb[$x], function ($i) { return isset($i); })); + } else if (isset($obj["today"][$x - 1]["cloudburst"])) { + $item["cloudburst"] = $obj["today"][$x - 1]["cloudburst"]; + } + + $obj["tomorrow"][] = $item; + } +} + +die(json_encode($obj, JSON_PRETTY_PRINT)); \ No newline at end of file diff --git a/pages/rules.inc b/pages/rules.inc index 23447f2..0c57819 100644 --- a/pages/rules.inc +++ b/pages/rules.inc @@ -1,5 +1,9 @@ = 1682985600) { + peh_error("Page not found: rules", 404); +} + require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc"; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $lang; global $pages; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/Parsedown.php"; $Parsedown = new Parsedown(); @@ -44,14 +48,16 @@ $cache = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/da ?> - -

Rules

Edit rules

+
+ The rules system will be removed on May 2nd 2023 at midnight UTC. This page will not be accessible anymore. If there is any data you want to keep, ask Raindrops System for a copy of the rules database. +
+ - -- cgit