From 5860551daa0f60103ad24e93da29f401a653f144 Mon Sep 17 00:00:00 2001 From: RaindropsSys Date: Fri, 29 Mar 2024 22:05:35 +0100 Subject: Updated 20 files, added 6 files, deleted 144 files and renamed .idea/ponycule.iml (automated) --- pages/api/_main.php | 30 +++++++++ pages/api/badger.php | 52 ---------------- pages/api/disconnect.php | 37 ----------- pages/api/docs.php | 31 --------- pages/api/emergency-real.php | 37 ----------- pages/api/emergency.php | 37 ----------- pages/api/me.php | 39 ------------ pages/api/pleasure-real.php | 50 --------------- pages/api/pleasure.php | 50 --------------- pages/api/pluralkit-integration.php | 4 +- pages/api/ponytown.php | 121 ------------------------------------ pages/api/reauthenticate.php | 49 --------------- pages/api/rename.php | 37 ----------- pages/api/session.php | 29 --------- pages/api/token.php | 7 --- 15 files changed, 31 insertions(+), 579 deletions(-) create mode 100644 pages/api/_main.php delete mode 100644 pages/api/badger.php delete mode 100644 pages/api/disconnect.php delete mode 100644 pages/api/docs.php delete mode 100644 pages/api/emergency-real.php delete mode 100644 pages/api/emergency.php delete mode 100644 pages/api/me.php delete mode 100644 pages/api/pleasure-real.php delete mode 100644 pages/api/pleasure.php delete mode 100644 pages/api/ponytown.php delete mode 100644 pages/api/reauthenticate.php delete mode 100644 pages/api/rename.php delete mode 100644 pages/api/session.php delete mode 100644 pages/api/token.php (limited to 'pages/api') diff --git a/pages/api/_main.php b/pages/api/_main.php new file mode 100644 index 0000000..215c1b2 --- /dev/null +++ b/pages/api/_main.php @@ -0,0 +1,30 @@ + 0) { - if ($metadata["birth"]["age"] === -1) { - $age = " - Eternal"; - } elseif ($metadata["birth"]["age"] <= 0) { - $age = ""; - } else { - $age = " - " . ($metadata["birth"]["age"]); - } - } else { - if ($metadata["birth"]["year"] <= 1900) { - $age = ""; - } else { - $age = " - " . ((int)date('Y') - $metadata["birth"]["year"] + (strtotime(date('Y') . "-" . $metadata["birth"]["date"]) <= time() ? 0 : -1)); - } - } - - return $age; -} - -header("Content-Type: application/json"); -die(json_encode(array_map(function ($i) { - return [ - "id" => $i["id"], - "name" => $i["display_name"] ?? $i["name"], - "system" => $i["system"], - "pronouns" => $i["pronouns"], - "species" => match ($i["_metadata"]["species"][0]) { - "earth" => $i["_metadata"]["robot"] ? "Robot earth pony" : (!$i["_metadata"]["plush"] ? "Earth pony" : "Earth pony plush"), - "alicorn" => $i["_metadata"]["robot"] ? "Robot alicorn" : (!$i["_metadata"]["plush"] ? "Alicorn" : "Alicorn plush"), - "crystal" => $i["_metadata"]["robot"] ? "Robot crystal pony" : (!$i["_metadata"]["plush"] ? "Crystal pony" : "Crystal pony plush"), - "pegasus" => $i["_metadata"]["robot"] ? "Robot pegasus" : (!$i["_metadata"]["plush"] ? "Pegasus" : "Pegasus plush"), - "batpony" => $i["_metadata"]["robot"] ? "Robot bat pony" : (!$i["_metadata"]["plush"] ? "Bat pony" : "Bat pony plush"), - "unicorn" => $i["_metadata"]["robot"] ? "Robot unicorn" : (!$i["_metadata"]["plush"] ? "Unicorn" : "Unicorn plush"), - "changeling" => "Changeling", - "human" => "Human", - "merpony" => "Merpony", - default => $i["_metadata"]["species"][0] . "_" . $i["_metadata"]["robot"] - }, - "age" => getAge($i["_metadata"]), - "avatar" => "https://ponycule.p.equestria.dev" . getAsset($i["system"], $i["id"], "heads") - ]; -}, $list), JSON_PRETTY_PRINT)); \ No newline at end of file diff --git a/pages/api/disconnect.php b/pages/api/disconnect.php deleted file mode 100644 index ffd3f40..0000000 --- a/pages/api/disconnect.php +++ /dev/null @@ -1,37 +0,0 @@ - [ - 'method' => 'POST', - 'header' => - "Content-Type: text/plain\r\n" . - "Title: " . formatPonypush("⚠️ Emergency alert") . "\r\n" . - "Priority: urgent\r\n" . - "Tags: emergency\r\n" . - "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), - 'content' => formatPonypush("This is an emergency, " . $_PROFILE['name'] . " is in need of immediate help. Please act now!") - ] -]); - -foreach ($channels as $channel) { - file_get_contents('https://' . $ntfy["server"] . '/' . $channel, false, $context); -} - -die(); \ No newline at end of file diff --git a/pages/api/emergency.php b/pages/api/emergency.php deleted file mode 100644 index e682598..0000000 --- a/pages/api/emergency.php +++ /dev/null @@ -1,37 +0,0 @@ - [ - 'method' => 'POST', - 'header' => - "Content-Type: text/plain\r\n" . - "Title: " . formatPonypush("[Test] ⚠️ Emergency alert") . "\r\n" . - "Priority: urgent\r\n" . - "Tags: emergency\r\n" . - "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), - 'content' => formatPonypush("[This notification is test] This is an emergency, " . $_PROFILE['name'] . " is in need of immediate help. Please act now! [This notification is test]") - ] -]); - -foreach ($channels as $channel) { - file_get_contents('https://' . $ntfy["server"] . '/' . $channel, false, $context); -} - -die(); \ No newline at end of file diff --git a/pages/api/me.php b/pages/api/me.php deleted file mode 100644 index 0e91189..0000000 --- a/pages/api/me.php +++ /dev/null @@ -1,39 +0,0 @@ - true, - "name" => "Raindrops System", - "id" => "raindrops", - "pluralkit" => "gdapd", - "avatar" => getAsset("gdapd"), - "email" => $_PROFILE["profile"]["email"]["email"] - ])); -} else if ($_PROFILE["login"] === "Moonglow") { - die(json_encode([ - "valid" => true, - "name" => "Moonglow", - "id" => "moonglow", - "pluralkit" => "hrbom", - "avatar" => getAsset("hrbom"), - "email" => $_PROFILE["profile"]["email"]["email"] - ])); -} else { - die(json_encode([ - "valid" => true, - "name" => $app["other"]["name"], - "id" => $app["other"]["slug"], - "pluralkit" => $app["other"]["id"], - "avatar" => getAsset($app["other"]["id"]), - "email" => $_PROFILE["profile"]["email"]["email"] - ])); -} \ No newline at end of file diff --git a/pages/api/pleasure-real.php b/pages/api/pleasure-real.php deleted file mode 100644 index c1cbd59..0000000 --- a/pages/api/pleasure-real.php +++ /dev/null @@ -1,50 +0,0 @@ - [ - 'method' => 'POST', - 'header' => - "Content-Type: text/plain\r\n" . - "Title: " . formatPonypush("🏩 $pony wants to play for a bit") . "\r\n" . - "Priority: high\r\n" . - "Tags: pleasure\r\n" . - "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), - 'content' => formatPonypush("Hey, $pony wants to play and have fun with you, get up!") - ] -]); - -foreach ($channels as $channel) { - file_get_contents('https://' . $ntfy["server"] . '/' . $channel, false, $context); -} - -die(); \ No newline at end of file diff --git a/pages/api/pleasure.php b/pages/api/pleasure.php deleted file mode 100644 index 7b268cb..0000000 --- a/pages/api/pleasure.php +++ /dev/null @@ -1,50 +0,0 @@ - [ - 'method' => 'POST', - 'header' => - "Content-Type: text/plain\r\n" . - "Title: " . formatPonypush("[Test] 🏩 $pony wants to play for a bit") . "\r\n" . - "Priority: high\r\n" . - "Tags: pleasure\r\n" . - "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), - 'content' => formatPonypush("[This notification is a test] Hey, $pony wants to play and have fun with you, get up! [This notification is a test]") - ] -]); - -foreach ($channels as $channel) { - file_get_contents('https://' . $ntfy["server"] . '/' . $channel, false, $context); -} - -die(); \ No newline at end of file diff --git a/pages/api/pluralkit-integration.php b/pages/api/pluralkit-integration.php index a3faa6f..9b0033d 100644 --- a/pages/api/pluralkit-integration.php +++ b/pages/api/pluralkit-integration.php @@ -1,7 +1,5 @@ $system ]); -} \ No newline at end of file +} diff --git a/pages/api/ponytown.php b/pages/api/ponytown.php deleted file mode 100644 index bc40975..0000000 --- a/pages/api/ponytown.php +++ /dev/null @@ -1,121 +0,0 @@ - 70) { - $errors[] = "0x{$_}000002A: Image #" . $_ . " is wider than it should, are you sure you set zoom to 1x? Maybe you inverted the files?"; - } - - if ($_ === 1 && $size[1] > 70) { - $errors[] = "0x{$_}000002B: Image #" . $_ . " is higher than it should, are you sure you set zoom to 1x? Maybe you inverted the files?"; - } - - if ($_ === 2 && $size[0] > 40) { - $errors[] = "0x{$_}000002A: Image #" . $_ . " is wider than it should, are you sure you set zoom to 1x? Maybe you inverted the files?"; - } - - if ($_ === 2 && $size[1] > 35) { - $errors[] = "0x{$_}000002B: Image #" . $_ . " is higher than it should, are you sure you set zoom to 1x? Maybe you inverted the files?"; - } -} - -if (count($errors) === 0 && isset($_GET["real"])) { - foreach ([1, 2] as $_) { - $input = $json_object[$_ - 1]; - - $mime = explode(";", substr($input, 5))[0]; - $file = base64_decode(explode(",", explode(";", substr($input, 5))[1])[1]); - - $image = @imagecreatefromstring($file); - - imagealphablending($image, false); - imagesavealpha($image, true); - - if ($_ === 1) { - imagepng($image, $_SERVER['DOCUMENT_ROOT'] . "/assets/ponies/" . $member["id"] . ".png"); - } else { - imagepng($image, $_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . $member["name"] . ".png"); - } - } -} - -createJob("UpdateAssets", [ - "type" => "ponytown" -]); - -die(json_encode([ - "success" => count($errors) === 0, - "errors" => $errors -])); \ No newline at end of file diff --git a/pages/api/reauthenticate.php b/pages/api/reauthenticate.php deleted file mode 100644 index b194098..0000000 --- a/pages/api/reauthenticate.php +++ /dev/null @@ -1,49 +0,0 @@ - true -]; - -global $token; -$data = json_decode(pf_utf8_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/sessions/" . str_replace("/", "", $token))), true); - -$data["name"] = $_POST["name"] ?? $_GET["name"] ?? $data["name"]; -$obj["pre_name"] = $data["name"]; - -$request_raw = file_get_contents('php://input'); -$json_object = json_decode($request_raw, true); - -if (json_last_error() === JSON_ERROR_NONE) { - $obj["json_error"] = [ json_last_error(), json_last_error_msg() ]; - if (isset($json_object["name"])) { - $data["name"] = $json_object["name"]; - $obj["json_name"] = $json_object["name"]; - } -} - -$obj["new_name"] = $data["name"]; - -file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/sessions/" . str_replace("/", "", $token), pf_utf8_encode(json_encode($data))); -die(json_encode($obj)); \ No newline at end of file diff --git a/pages/api/session.php b/pages/api/session.php deleted file mode 100644 index 25d833d..0000000 --- a/pages/api/session.php +++ /dev/null @@ -1,29 +0,0 @@ - null, - "created" => null, - "last_seen" => null, - "seen_at" => null - ], JSON_PRETTY_PRINT)); - } - - $data = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/sessions/" . str_replace("/", "", $token)), true); - - die(json_encode([ - "name" => $data["name"], - "created" => date('c', $data["created"]), - "last_seen" => date('c', $data["last"]), - "seen_at" => array_keys($data["addresses"] ?? []) - ], JSON_PRETTY_PRINT)); -} \ No newline at end of file diff --git a/pages/api/token.php b/pages/api/token.php deleted file mode 100644 index 5c80ca3..0000000 --- a/pages/api/token.php +++ /dev/null @@ -1,7 +0,0 @@ -