diff options
Diffstat (limited to 'api')
-rw-r--r-- | api/cloudburst-banners.php | 1 | ||||
-rw-r--r-- | api/docs.php | 31 | ||||
-rw-r--r-- | api/pleasure-real.php | 14 | ||||
-rw-r--r-- | api/pleasure.php | 14 | ||||
-rw-r--r-- | api/pluralkit-integration.php | 20 | ||||
-rw-r--r-- | api/raindrops-banners.php | 1 | ||||
-rw-r--r-- | api/raindrops-img.php | 10 | ||||
-rw-r--r-- | api/save-private.php | 43 | ||||
-rw-r--r-- | api/wakeup-real.php | 28 | ||||
-rw-r--r-- | api/wakeup.php | 28 |
10 files changed, 188 insertions, 2 deletions
diff --git a/api/cloudburst-banners.php b/api/cloudburst-banners.php index 32b47fa..8bbd575 100644 --- a/api/cloudburst-banners.php +++ b/api/cloudburst-banners.php @@ -10,6 +10,7 @@ $data = []; foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-members.json"), true) as $member) { if ($member['name'] === "unknown") continue; if ($member['name'] === "fusion") continue; + if ($member['name'] === "new") continue; $data[$member['name']] = getMemberBannerData($member['id'], "ynmuc"); } diff --git a/api/docs.php b/api/docs.php new file mode 100644 index 0000000..edcd4fb --- /dev/null +++ b/api/docs.php @@ -0,0 +1,31 @@ +<?php + +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $isLoggedIn; global $_PROFILE; +if (!$isLoggedIn) header("Location: /-/login") and die(); + +$request_raw = file_get_contents('php://input'); +$json_object = json_decode($request_raw, true); + +$select = $_GET['id'] ?? null; + +if (isset($select)) { + if (ctype_alnum($select) && file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/docs/" . $select . ".json")) { + $id = $select; + $data = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/docs/" . $select . ".json"), true); + } else { + header("Location: /-/docs"); + die(); + } +} else { + header("Location: /-/docs"); + die(); +} + +if ($json_object["content"]) $data["contents"] = $json_object["content"]; +if ($json_object["name"]) $data["name"] = $json_object["name"]; +if ($json_object["category"]) $data["category"] = trim($json_object["category"]) !== "" && trim($json_object["category"]) !== "Unsorted" && trim($json_object["category"]) !== "unsorted" && trim($json_object["category"]) !== "/no" && trim($json_object["category"]) !== "Unsort" && trim($json_object["category"]) !== "unsort" ? $json_object["category"] : null; + +$data["last"]["date"] = time(); +$data["last"]["author"] = $_PROFILE['login']; + +file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/docs/" . $select . ".json", utf8_encode(json_encode($data)));
\ No newline at end of file diff --git a/api/pleasure-real.php b/api/pleasure-real.php index d62c8d4..fe8896d 100644 --- a/api/pleasure-real.php +++ b/api/pleasure-real.php @@ -4,7 +4,19 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $isLogg if (!$isLoggedIn) header("Location: /-/login") and die(); global $_PROFILE; -if ($_PROFILE['login'] === "raindrops") $pony = "Cloudy"; else $pony = "Lavender"; +$frontCloudburst = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-fronters.json"), true)["members"]; +$frontRaindrops = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-fronters.json"), true)["members"]; + +if ($frontCloudburst[0]["id"] === "erknz" && $frontRaindrops[0]["id"] === "qbzxm") { + if ($_PROFILE['login'] === "raindrops") $pony = "Cloudy"; else $pony = "Lavender"; +} else if ($frontCloudburst[0]["id"] === "zzise" && $frontRaindrops[0]["id"] === "tfbob") { + if ($_PROFILE['login'] === "raindrops") $pony = "Violet"; else $pony = "Sky Dream"; +} else if ($frontCloudburst[0]["id"] === "vncoa" && $frontRaindrops[0]["id"] === "qraku") { + if ($_PROFILE['login'] === "raindrops") $pony = "Starry"; else $pony = "Minty"; +} else { + $pony = "somepony"; +} + $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([ diff --git a/api/pleasure.php b/api/pleasure.php index 5b72405..cdd49c0 100644 --- a/api/pleasure.php +++ b/api/pleasure.php @@ -4,7 +4,19 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $isLogg if (!$isLoggedIn) header("Location: /-/login") and die(); global $_PROFILE; -if ($_PROFILE['login'] === "raindrops") $pony = "Cloudy"; else $pony = "Lavender"; +$frontCloudburst = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-fronters.json"), true)["members"]; +$frontRaindrops = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-fronters.json"), true)["members"]; + +if ($frontCloudburst[0]["id"] === "erknz" && $frontRaindrops[0]["id"] === "qbzxm") { + if ($_PROFILE['login'] === "raindrops") $pony = "Cloudy"; else $pony = "Lavender"; +} else if ($frontCloudburst[0]["id"] === "zzise" && $frontRaindrops[0]["id"] === "tfbob") { + if ($_PROFILE['login'] === "raindrops") $pony = "Violet"; else $pony = "Sky Dream"; +} else if ($frontCloudburst[0]["id"] === "vncoa" && $frontRaindrops[0]["id"] === "qraku") { + if ($_PROFILE['login'] === "raindrops") $pony = "Starry"; else $pony = "Minty"; +} else { + $pony = "somepony"; +} + $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([ diff --git a/api/pluralkit-integration.php b/api/pluralkit-integration.php index 262d4a6..98f4cb9 100644 --- a/api/pluralkit-integration.php +++ b/api/pluralkit-integration.php @@ -53,6 +53,26 @@ if ($input["type"] === "CREATE_SWITCH" || $input["type"] === "UPDATE_SWITCH" || ] ])); + if ($system === "gdapd") { + $topic = "public-switches-raindrops"; + } else { + $topic = "public-switches-cloudburst"; + } + + file_get_contents('https://' . $ntfy["server"] . '/' . $topic, false, stream_context_create([ + 'http' => [ + 'method' => 'POST', + 'header' => + "Content-Type: text/plain\r\n" . + "Title: 🐴 Switch occurred in the $name\r\n" . + "Priority: default\r\n" . + "Tags: switch\r\n" . + "Actions: view, Open on Cold Haze, https://ponies.equestria.horse/" . $fronters["members"][0]["name"] . "/, clear=true\r\n" . + "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), + 'content' => ($fronters["members"][0]["display_name"] ?? $fronters["members"][0]["name"]) . " switched in just now" + ] + ])); + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data.json-res", "affected: " . $input["type"] . " (" . gettype($input["type"]) . ")") and die(); } else { file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data.json-res", "invalid method: " . $input["type"] . " (" . gettype($input["type"]) . ")") and die(); diff --git a/api/raindrops-banners.php b/api/raindrops-banners.php index f42426a..b2a5ef4 100644 --- a/api/raindrops-banners.php +++ b/api/raindrops-banners.php @@ -10,6 +10,7 @@ $data = []; foreach (json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-members.json"), true) as $member) { if ($member['name'] === "unknown") continue; if ($member['name'] === "fusion") continue; + if ($member['name'] === "new") continue; $data[$member['name']] = getMemberBannerData($member['id'], "gdapd"); } diff --git a/api/raindrops-img.php b/api/raindrops-img.php new file mode 100644 index 0000000..3b24d97 --- /dev/null +++ b/api/raindrops-img.php @@ -0,0 +1,10 @@ +<?php + +$fronters = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-fronters.json"), true); + +$url = isset($fronters['members'][0]) ? ($fronters['members'][0]["avatar_url"] ?? "https://static.equestria.horse/ponies/uploads/raindrops.png") : "https://static.equestria.horse/ponies/uploads/raindrops.png"; +file_put_contents("/tmp/temp", file_get_contents($url)); +header("Content-Type: " . mime_content_type("/tmp/temp")); +unlink("/tmp/temp"); + +echo(file_get_contents($url));
\ No newline at end of file diff --git a/api/save-private.php b/api/save-private.php new file mode 100644 index 0000000..13e3ecf --- /dev/null +++ b/api/save-private.php @@ -0,0 +1,43 @@ +<?php + +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $isLoggedIn; +if (!$isLoggedIn) header("Location: /-/login") and die(); + +$request_raw = file_get_contents('php://input'); +$json_object = json_decode($request_raw, true); + +$system = $_GET['system'] ?? null; +$member = $_GET['member'] ?? null; +$subsystem = $_GET['subsystem'] ?? null; +$content = $json_object['content'] ?? null; + +if (!isset($system) || trim($system) === "" || strlen($system) !== 5 || !preg_match("/[a-z]/i", $system)) + header("Location: /?error=System not found") and die(); + +if (!isset($member) || trim($member) === "" || strlen($member) !== 5 || !preg_match("/[a-z]/i", $member)) + if ($member !== null && $member !== "null") header("Location: /?error=System member not found") and die(); + +if (!isset($subsystem) || trim($subsystem) === "" || !preg_match("/[a-z\d]/i", $subsystem)) + if ($subsystem !== null && $subsystem !== "null") header("Location: /?error=Subsystem not found") and die(); + +if (!isset($content)) + header("Location: /?error=No content") and die(); + +if ($member !== null && $member !== "null") { + $file = $_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $system . "-" . $member . "-private.html"; +} else { + if ($subsystem !== null && $subsystem !== "null") { + $file = $_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $system . "-subsystem-" . $subsystem . ".html"; + } else { + $file = $_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $system . "-content.html"; + } +} + +if (trim($content) === "") { + if (file_exists($file)) { + unlink($file); + } + die(); +} + +file_put_contents($file, $content);
\ No newline at end of file diff --git a/api/wakeup-real.php b/api/wakeup-real.php new file mode 100644 index 0000000..a263bf0 --- /dev/null +++ b/api/wakeup-real.php @@ -0,0 +1,28 @@ +<?php + +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $isLoggedIn; +if (!$isLoggedIn) header("Location: /-/login") and die(); +global $_PROFILE; + +$frontCloudburst = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-fronters.json"), true)["members"]; +$frontRaindrops = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-fronters.json"), true)["members"]; + +$pony = "somepony"; +if ($_PROFILE['login'] === "raindrops") $pony = $frontRaindrops[0]["display_name"]; else $pony = $frontCloudburst[0]["display_name"]; + +$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: 🥱 Wake up!\r\n" . + "Priority: high\r\n" . + "Tags: wakeup\r\n" . + "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), + 'content' => "Hey, $pony wants you to wake up!" + ] +])); + +die();
\ No newline at end of file diff --git a/api/wakeup.php b/api/wakeup.php new file mode 100644 index 0000000..7eb96c3 --- /dev/null +++ b/api/wakeup.php @@ -0,0 +1,28 @@ +<?php + +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $isLoggedIn; +if (!$isLoggedIn) header("Location: /-/login") and die(); +global $_PROFILE; + +$frontCloudburst = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-fronters.json"), true)["members"]; +$frontRaindrops = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-fronters.json"), true)["members"]; + +$pony = "somepony"; +if ($_PROFILE['login'] === "raindrops") $pony = $frontRaindrops[0]["display_name"]; else $pony = $frontCloudburst[0]["display_name"]; + +$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: [Test] 🥱 Wake up!\r\n" . + "Priority: high\r\n" . + "Tags: wakeup\r\n" . + "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), + 'content' => "[This notification is test] Hey, $pony wants you to wake up! [This notification is test]" + ] +])); + +die();
\ No newline at end of file |