summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2023-02-05 13:00:59 +0100
committerMinteck <contact@minteck.org>2023-02-05 13:00:59 +0100
commitabd342282b48d742cca1740f76d220037fd13800 (patch)
tree49654e39819b4bca60d0c64f716495551b92d143
parentc6df470866ce00f91345888eac6d8aa76db694dc (diff)
downloadpluralconnect-abd342282b48d742cca1740f76d220037fd13800.tar.gz
pluralconnect-abd342282b48d742cca1740f76d220037fd13800.tar.bz2
pluralconnect-abd342282b48d742cca1740f76d220037fd13800.zip
Updated 6 files, added 2 files and renamed assets/uploads/pt-twilight.png (automated)
-rw-r--r--api/pluralkit-integration.php26
-rw-r--r--api/test1.php9
-rw-r--r--assets/uploads/pt-rarity.pngbin0 -> 4405 bytes
-rw-r--r--assets/uploads/pt-twi.png (renamed from assets/uploads/pt-twilight.png)bin4700 -> 4700 bytes
-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
-rw-r--r--pages/bitset.inc6
9 files changed, 73 insertions, 17 deletions
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 @@
<?php
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/agewarning.inc";
+
$user = $_GET['user'] ?? null;
$inputJSON = file_get_contents('php://input');
$input = json_decode($inputJSON, true);
@@ -34,8 +36,10 @@ if ($input['system_id'] === "7d9f543e-f742-40f6-9d07-86c3f2983124") {
$lastFronter = json_decode(@file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/last.json"), true) ?? "";
if ($input["type"] === "CREATE_SWITCH" || $input["type"] === "UPDATE_SWITCH" || $input["type"] === "DELETE_SWITCH") {
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/fronters.json", file_get_contents("https://pluralkit.equestria.dev/v2/systems/$input[system_id]/fronters"));
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/switches.json", file_get_contents("https://pluralkit.equestria.dev/v2/systems/$input[system_id]/switches"));
+ sleep(1.5);
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/fronters.json", file_get_contents("https://api.pluralkit.me/v2/systems/$input[system_id]/fronters"));
+ sleep(1.5);
+ file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/switches.json", file_get_contents("https://api.pluralkit.me/v2/systems/$input[system_id]/switches"));
$fronters = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/fronters.json"), true);
$currentFronter = $fronters["members"][0]["id"];
@@ -45,6 +49,24 @@ if ($input["type"] === "CREATE_SWITCH" || $input["type"] === "UPDATE_SWITCH" ||
file_put_contents("/mnt/ponytown-chat/tokens/" . $ponytown, $fronters["members"][0]["display_name"]);
+ if (count($fronters["members"]) > 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 @@
<?php
-$img = imagecreate(2048, 1024);
-$color = imagecolorallocate($img, 255, 0, 0);
-
-header("Content-type: image/jpeg");
-imagejpeg($img);
-imagedestroy($img); \ No newline at end of file
+die();
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/agewarning.inc";
+showWarning("Zoom Zephyrwing", "zoomzephyrwing", "gdapd"); \ No newline at end of file
diff --git a/assets/uploads/pt-rarity.png b/assets/uploads/pt-rarity.png
new file mode 100644
index 0000000..5a2cd2b
--- /dev/null
+++ b/assets/uploads/pt-rarity.png
Binary files differ
diff --git a/assets/uploads/pt-twilight.png b/assets/uploads/pt-twi.png
index 766f3fc..766f3fc 100644
--- a/assets/uploads/pt-twilight.png
+++ b/assets/uploads/pt-twi.png
Binary files differ
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") {
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';
<div data-bs-toggle="tooltip" title="Memory polling" id="binary-bit-25" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#fa77ef;">0</div>
<div data-bs-toggle="tooltip" title="Memory polling" id="binary-bit-26" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#fa77ef;">0</div>
<div data-bs-toggle="tooltip" title="Value reserved for future use" id="binary-bit-27" class="text-muted font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;">0</div>
- <div data-bs-toggle="tooltip" title="Little/younger" id="binary-bit-28" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#b277fa;">0</div>
- <div data-bs-toggle="tooltip" title="Little/younger" id="binary-bit-29" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#b277fa;">0</div>
+ <div data-bs-toggle="tooltip" title="Value reserved for future use" id="binary-bit-28" class="text-muted font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;">0</div>
+ <div data-bs-toggle="tooltip" title="Value reserved for future use" id="binary-bit-29" class="text-muted font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;">0</div>
<div data-bs-toggle="tooltip" title="Protector" id="binary-bit-30" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#77faab;">0</div>
<div data-bs-toggle="tooltip" title="Fictive" id="binary-bit-31" class="font-monospace tooltip-nohelp text-info" style="text-align: center;cursor: pointer;">0</div>
<div data-bs-toggle="tooltip" title="Value reserved for future use" id="binary-bit-32" class="text-muted font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;">0</div>
@@ -408,7 +408,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc';
</label><br>
<label style="margin-bottom:5px;">
<input type="checkbox" id="value-26" onchange="updateFromSelection();">
- Enable sexual features (for littles/younger only)
+ Enable sexual features (for ponies below 16)
</label><br>
<label style="margin-bottom:5px;">
<input type="checkbox" id="value-18" onchange="updateFromSelection();">