From 609dc69c1332813c3a367e184663e498c4f559ff Mon Sep 17 00:00:00 2001 From: RaindropsSys Date: Fri, 24 Mar 2023 08:54:44 +0100 Subject: Updated 2 files and added pages/api/badger.php (automated) --- pages/api/badger.php | 47 ++++++++++++++++++++++++++++++++++++++++++++ pages/api/emergency-real.php | 13 ++++++++++++ pages/api/emergency.php | 13 ++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 pages/api/badger.php (limited to 'pages') diff --git a/pages/api/badger.php b/pages/api/badger.php new file mode 100644 index 0000000..76f017e --- /dev/null +++ b/pages/api/badger.php @@ -0,0 +1,47 @@ + 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", + default => $i["_metadata"]["species"][0] . "_" . $i["_metadata"]["robot"] + }, + "age" => getAge($i["_metadata"]), + "avatar" => "https://ponies.equestria.horse" . getAsset($i["system"], $i["id"], "heads") + ]; +}, $list), JSON_PRETTY_PRINT)); \ No newline at end of file diff --git a/pages/api/emergency-real.php b/pages/api/emergency-real.php index 1e4c0e9..d0412c8 100644 --- a/pages/api/emergency-real.php +++ b/pages/api/emergency-real.php @@ -24,4 +24,17 @@ file_get_contents('https://' . $ntfy["server"] . '/' . $ntfy["topic"], false, st ] ])); +file_get_contents('https://' . $ntfy["server"] . '/emergency', false, stream_context_create([ + 'http' => [ + 'method' => 'POST', + 'header' => + "Content-Type: text/plain\r\n" . + "Title: ⚠️🆘 EMERGENCY ⚠️🆘\r\n" . + "Priority: urgent\r\n" . + "Tags: emergency\r\n" . + "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), + 'content' => "This is an emergency, " . $_PROFILE['name'] . " is in need of IMMEDIATE help. Please act now!" + ] +])); + die(); \ No newline at end of file diff --git a/pages/api/emergency.php b/pages/api/emergency.php index 5815148..2f764b1 100644 --- a/pages/api/emergency.php +++ b/pages/api/emergency.php @@ -24,4 +24,17 @@ file_get_contents('https://' . $ntfy["server"] . '/' . $ntfy["topic"], false, st ] ])); +file_get_contents('https://' . $ntfy["server"] . '/emergency', false, stream_context_create([ + 'http' => [ + 'method' => 'POST', + 'header' => + "Content-Type: text/plain\r\n" . + "Title: [Test] ⚠️🆘 EMERGENCY ⚠️🆘\r\n" . + "Priority: urgent\r\n" . + "Tags: emergency\r\n" . + "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), + 'content' => "[This notification is test] This is an emergency, " . $_PROFILE['name'] . " is in need of IMMEDIATE help. Please act now! [This notification is test]" + ] +])); + die(); \ No newline at end of file -- cgit