diff options
author | RaindropsSys <contact@minteck.org> | 2023-05-02 18:59:49 +0200 |
---|---|---|
committer | RaindropsSys <contact@minteck.org> | 2023-05-02 18:59:49 +0200 |
commit | 8cdbff7146e81546143f1f54e75bfd0eb34d17a0 (patch) | |
tree | 47cd0d41c8b34676982d30cec934d5e2080ea9ff /pages/api/overage.php | |
parent | 59b56c2283c12c8a82144a836faee4f12b15e5c1 (diff) | |
download | pluralconnect-8cdbff7146e81546143f1f54e75bfd0eb34d17a0.tar.gz pluralconnect-8cdbff7146e81546143f1f54e75bfd0eb34d17a0.tar.bz2 pluralconnect-8cdbff7146e81546143f1f54e75bfd0eb34d17a0.zip |
Updated 3 files and added 2 files (automated)
Diffstat (limited to 'pages/api/overage.php')
-rw-r--r-- | pages/api/overage.php | 47 |
1 files changed, 47 insertions, 0 deletions
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 @@ +<?php + +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $_PROFILE; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc"; +if (!$isLoggedIn) header("Location: /-/login") and die(); + +header("Content-Type: application/json"); + +$obj = [ + "raindrops" => 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 |