summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
Diffstat (limited to 'includes')
-rw-r--r--includes/agewarning.inc19
-rw-r--r--includes/bitset.inc22
-rw-r--r--includes/maintenance/clearUnused.php6
-rw-r--r--includes/short.inc2
4 files changed, 43 insertions, 6 deletions
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 @@
+<?php
+
+function showWarning($name, $id, $system) {
+ $ntfy = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true)["ntfy"];
+
+ file_get_contents('https://' . $ntfy["server"] . '/' . $ntfy['topic'], false, stream_context_create([
+ 'http' => [
+ '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 @@
<?php
-function parseBitset ($bitset) {
+function parseBitset($bitset, $birthData) {
$bin = str_repeat("0", 48 - strlen(decbin($bitset))) . decbin($bitset);
$sharedMemory = bindec(substr($bin, 24, 2));
@@ -63,7 +63,23 @@ function parseBitset ($bitset) {
default => 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") {