From abd342282b48d742cca1740f76d220037fd13800 Mon Sep 17 00:00:00 2001 From: Minteck Date: Sun, 5 Feb 2023 13:00:59 +0100 Subject: Updated 6 files, added 2 files and renamed assets/uploads/pt-twilight.png (automated) --- api/pluralkit-integration.php | 26 ++++++++++++++++++++++++-- api/test1.php | 9 +++------ assets/uploads/pt-rarity.png | Bin 0 -> 4405 bytes assets/uploads/pt-twi.png | Bin 0 -> 4700 bytes assets/uploads/pt-twilight.png | Bin 4700 -> 0 bytes includes/agewarning.inc | 19 +++++++++++++++++++ includes/bitset.inc | 22 +++++++++++++++++++--- includes/maintenance/clearUnused.php | 6 +++--- includes/short.inc | 2 ++ pages/bitset.inc | 6 +++--- 10 files changed, 73 insertions(+), 17 deletions(-) create mode 100644 assets/uploads/pt-rarity.png create mode 100644 assets/uploads/pt-twi.png delete mode 100644 assets/uploads/pt-twilight.png create mode 100644 includes/agewarning.inc diff --git a/api/pluralkit-integration.php b/api/pluralkit-integration.php index 6d1166c..b3badd7 100644 --- a/api/pluralkit-integration.php +++ b/api/pluralkit-integration.php @@ -1,5 +1,7 @@ 0) { + foreach ($fronters["members"] as $member) { + if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $member["id"] . ".json")) { + $metadata = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metadata/" . $member["id"] . ".json"), true); + + if (!isset($metadata["birth"])) { + showWarning($member["display_name"] ?? $member["name"], $member["name"], $system); + } else if (isset($metadata['birth']["age"]) && $metadata["birth"]["age"] === 0 && (!isset($metadata['birth']["year"]) || $metadata["birth"]["year"] < 1900)) { + showWarning($member["display_name"] ?? $member["name"], $member["name"], $system); + } else if (isset($metadata['birth']["year"]) && $metadata["birth"]["year"] < 1900) { + showWarning($member["display_name"] ?? $member["name"], $member["name"], $system); + } else if (!isset($metadata['birth']["year"]) && !isset($metadata['birth']["age"])) { + showWarning($member["display_name"] ?? $member["name"], $member["name"], $system); + } + } + } + } + if (count($fronters["members"]) > 1) { $context = stream_context_create([ 'http' => [ diff --git a/api/test1.php b/api/test1.php index 6d25f85..a8c9c97 100644 --- a/api/test1.php +++ b/api/test1.php @@ -1,8 +1,5 @@ [ + 'method' => 'POST', + 'header' => + "Content-Type: text/plain\r\n" . + "Title: ⚠️ $name does not have an age or birth year set\r\n" . + "Priority: max\r\n" . + "Tags: switch\r\n" . + "Actions: view, Edit on Cold Haze, https://ponies.equestria.horse/-/metadata/" . ($system === "gdapd" ? "raindrops" : "cloudburst") . "/" . $id . "/, clear=true\r\n" . + "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), + 'content' => "To make sure they still appear on the fronting schedule after March 1st, they need to set an age or birth year now." + ] + ])); +} \ No newline at end of file diff --git a/includes/bitset.inc b/includes/bitset.inc index f8ac366..5106d80 100644 --- a/includes/bitset.inc +++ b/includes/bitset.inc @@ -1,6 +1,6 @@ null, }; - if ($little === 1) $little = 0; + $little = 0; + + if (isset($birthData["age"]) && $birthData["age"] !== 0) { + $age = $birthData["age"]; + } else if (isset($birthData["year"]) && $birthData["year"] > 1900) { + $age = (int)date('Y') - $birthData["year"] + (strtotime(date('Y') . "-" . $birthData["date"]) <= time() ? 0 : -1); + } else { + $age = -2; + } + + if ($age <= 10 && $age > 0) { + $little = 2; + } + + if ($age < 16 && $age > 10) { + $little = 3; + } return [ 'shared_memory' => $sharedMemory, @@ -106,7 +122,7 @@ function parseBitset ($bitset) { function parseMetadata ($metadata) { if (isset($metadata)) { if ($metadata["bitset"]) { - $m = parseBitset($metadata["bitset"]); + $m = parseBitset($metadata["bitset"], $metadata["birth"] ?? []); $m["sexfriends"] = $metadata["sexfriends"] ?? []; $m["marefriends"] = $metadata["marefriends"] ?? []; $m["bitset"] = $metadata["bitset"] ?? 0; diff --git a/includes/maintenance/clearUnused.php b/includes/maintenance/clearUnused.php index 99b6ca4..499375b 100644 --- a/includes/maintenance/clearUnused.php +++ b/includes/maintenance/clearUnused.php @@ -12,16 +12,16 @@ foreach (array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/metada $bits = str_split(substr(str_repeat("0", 48), 0, 48 - strlen(decbin($data["bitset"]))) . decbin($data["bitset"])); echo(" Old:\n"); echo(" " . str_replace("+", "\e[92m1\e[39m", str_replace("-", "\e[31m0\e[39m", implode("", str_replace("0", "-", str_replace("1", "+", $bits))))) . "\n"); - echo(" XXXXXXXXXX X XXXXXX X XX XXXX X\n"); + echo(" XX \n"); $bitsOld = implode("", $bits); - foreach ([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 18, 19, 20, 21, 22, 23, 26, 31, 32, 41, 42, 43, 44, 47] as $bit) { + foreach ([27, 28] as $bit) { $bits[$bit] = "0"; } echo(" New:\n"); echo(" " . str_replace("+", "\e[92m1\e[39m", str_replace("-", "\e[31m0\e[39m", implode("", str_replace("0", "-", str_replace("1", "+", $bits))))) . "\n"); - echo(" XXXXXXXXXX X XXXXXX X XX XXXX X\n"); + echo(" XX \n"); echo(" Changed " . levenshtein($bitsOld, implode("", $bits)) . " bit(s)\n"); echo(" Backup made in " . substr($file, 0, -5) . "-old.json\n"); diff --git a/includes/short.inc b/includes/short.inc index 98efd20..fe0baa5 100644 --- a/includes/short.inc +++ b/includes/short.inc @@ -12,6 +12,7 @@ $list = [ "rd" => "/raindrops", "cb" => "/cloudburst", "minty" => "/cloudydreams", + "twilight" => "/twi", "cloudy" => "/cloudydreams", "zipp" => "/zippstorm", "babs" => "/babsseed", @@ -40,6 +41,7 @@ foreach ($members as $member) { } $list["minty"] = "/cloudydreams"; +$list["twilight"] = "/twi"; if (in_array($toplevel, array_keys($list)) && $list[$toplevel]) { if ($toplevel !== "unknown") { diff --git a/pages/bitset.inc b/pages/bitset.inc index 309bab8..b16a23e 100644 --- a/pages/bitset.inc +++ b/pages/bitset.inc @@ -61,8 +61,8 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc';
0
0
0
-
0
-
0
+
0
+
0
0
0
0
@@ -408,7 +408,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc';