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) --- includes/agewarning.inc | 19 +++++++++++++++++++ includes/bitset.inc | 22 +++++++++++++++++++--- includes/maintenance/clearUnused.php | 6 +++--- includes/short.inc | 2 ++ 4 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 includes/agewarning.inc (limited to 'includes') diff --git a/includes/agewarning.inc b/includes/agewarning.inc new file mode 100644 index 0000000..a7ab501 --- /dev/null +++ b/includes/agewarning.inc @@ -0,0 +1,19 @@ + [ + '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") { -- cgit