From e72d0adbcd7e69928a1ef380c7a841c160284c68 Mon Sep 17 00:00:00 2001 From: Minteck Date: Mon, 2 Jan 2023 20:29:01 +0100 Subject: Update --- api/desktop-app.php | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 api/desktop-app.php (limited to 'api') diff --git a/api/desktop-app.php b/api/desktop-app.php new file mode 100644 index 0000000..20b1da9 --- /dev/null +++ b/api/desktop-app.php @@ -0,0 +1,76 @@ + 0) { + $fronter = $fronters[0]; + $info = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $fronter["id"] . ".json"), true); + $info = parseMetadata($info); + + if (isset($info["birth"]["age"]) && $info["birth"]["age"] < 16 && $info["birth"]["age"] > 0) { + $proceed = 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 < 16) { + $proceed = false; + } + } + } + } + + if ($proceed) { + $data = $keys[$_GET["id"]]["config"] ?? []; + } +} else { + $data = [ + "success" => true, + "valid" => false, + "underage" => false, + "normal" => false + ]; + + $keys = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/permitted.json"), true); + + if (in_array($_GET["id"], array_keys($keys))) { + $data["valid"] = true; + + $fronters = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $keys[$_GET["id"]]["system"] . "/fronters.json"), true)["members"]; + + if (count($fronters) > 0) { + $fronter = $fronters[0]; + $info = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $fronter["id"] . ".json"), true); + $info = parseMetadata($info); + + $data["normal"] = $info["sexually_active"]; + + if (isset($info["birth"]["age"]) && $info["birth"]["age"] < 16 && $info["birth"]["age"] > 0) { + $data["underage"] = true; + } 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 < 16) { + $data["underage"] = true; + } + } + } + } +} + +die(json_encode($data)); \ No newline at end of file -- cgit