diff options
Diffstat (limited to 'api')
-rw-r--r-- | api/app-images.php | 2 | ||||
-rw-r--r-- | api/cloudburst-banners.php | 2 | ||||
-rw-r--r-- | api/cloudburst-data.php | 2 | ||||
-rw-r--r-- | api/cloudburst-scored.php | 9 | ||||
-rw-r--r-- | api/data.php | 2 | ||||
-rw-r--r-- | api/emergency-real.php | 2 | ||||
-rw-r--r-- | api/emergency.php | 2 | ||||
-rw-r--r-- | api/eval.php | 12 | ||||
-rw-r--r-- | api/fronter.php | 2 | ||||
-rw-r--r-- | api/me-picture.php | 2 | ||||
-rw-r--r-- | api/me.php | 2 | ||||
-rw-r--r-- | api/pleasure-real.php | 2 | ||||
-rw-r--r-- | api/pleasure.php | 2 | ||||
-rw-r--r-- | api/pluralkit-integration.php | 27 | ||||
-rw-r--r-- | api/raindrops-banners.php | 2 | ||||
-rw-r--r-- | api/raindrops-data.php | 2 | ||||
-rw-r--r-- | api/raindrops-scored.php | 9 | ||||
-rw-r--r-- | api/save.php | 2 | ||||
-rw-r--r-- | api/token.php | 2 | ||||
-rw-r--r-- | api/video.php | 2 |
20 files changed, 71 insertions, 18 deletions
diff --git a/api/app-images.php b/api/app-images.php index edab3c9..76b11a0 100644 --- a/api/app-images.php +++ b/api/app-images.php @@ -1,7 +1,7 @@ <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $isLoggedIn; -if (!$isLoggedIn) header("Location: /login") and die(); +if (!$isLoggedIn) header("Location: /-/login") and die(); global $_PROFILE; $data = [ diff --git a/api/cloudburst-banners.php b/api/cloudburst-banners.php index 5cf06f8..32b47fa 100644 --- a/api/cloudburst-banners.php +++ b/api/cloudburst-banners.php @@ -3,7 +3,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $isLoggedIn; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/bitset.php"; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/banner.php"; -if (!$isLoggedIn) header("Location: /login") and die(); +if (!$isLoggedIn) header("Location: /-/login") and die(); $data = []; diff --git a/api/cloudburst-data.php b/api/cloudburst-data.php index f1bab0b..c996815 100644 --- a/api/cloudburst-data.php +++ b/api/cloudburst-data.php @@ -2,7 +2,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $isLoggedIn; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/bitset.php"; -if (!$isLoggedIn) header("Location: /login") and die(); +if (!$isLoggedIn) header("Location: /-/login") and die(); $data = []; $data["members"] = []; diff --git a/api/cloudburst-scored.php b/api/cloudburst-scored.php new file mode 100644 index 0000000..37acbcc --- /dev/null +++ b/api/cloudburst-scored.php @@ -0,0 +1,9 @@ +<?php + +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $isLoggedIn; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/score.php"; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/bitset.php"; +if (!$isLoggedIn) header("Location: /-/login") and die(); + +header("Content-Type: application/json"); +die(json_encode(array_values(scoreOrder(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc-members.json"), true), "ynmuc")), JSON_PRETTY_PRINT));
\ No newline at end of file diff --git a/api/data.php b/api/data.php index 7ede925..51df59a 100644 --- a/api/data.php +++ b/api/data.php @@ -2,7 +2,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $isLoggedIn; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/bitset.php"; -if (!$isLoggedIn) header("Location: /login") and die(); +if (!$isLoggedIn) header("Location: /-/login") and die(); if (!isset($_GET['f']) || !file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $_GET['f'])) { die(); diff --git a/api/emergency-real.php b/api/emergency-real.php index 6a569e8..06e1813 100644 --- a/api/emergency-real.php +++ b/api/emergency-real.php @@ -1,7 +1,7 @@ <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $isLoggedIn; -if (!$isLoggedIn) header("Location: /login") and die(); +if (!$isLoggedIn) header("Location: /-/login") and die(); global $_PROFILE; $ntfy = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true)["ntfy"]; diff --git a/api/emergency.php b/api/emergency.php index 9a0ed7f..5c9f32f 100644 --- a/api/emergency.php +++ b/api/emergency.php @@ -1,7 +1,7 @@ <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $isLoggedIn; -if (!$isLoggedIn) header("Location: /login") and die(); +if (!$isLoggedIn) header("Location: /-/login") and die(); global $_PROFILE; $ntfy = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true)["ntfy"]; diff --git a/api/eval.php b/api/eval.php new file mode 100644 index 0000000..4270ed1 --- /dev/null +++ b/api/eval.php @@ -0,0 +1,12 @@ +<?php + +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $isLoggedIn; +if (!$isLoggedIn) header("Location: /-/login") and die(); + +header("Content-Type: text/plain"); + +if (isset($_GET["c"])) { + var_dump(eval($_GET['c'])); +} else { + die(); +}
\ No newline at end of file diff --git a/api/fronter.php b/api/fronter.php index 44c2c76..e74d34a 100644 --- a/api/fronter.php +++ b/api/fronter.php @@ -1,7 +1,7 @@ <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $isLoggedIn; -if (!$isLoggedIn) header("Location: /login") and die(); +if (!$isLoggedIn) header("Location: /-/login") and die(); $system = $_GET['s'] ?? null; $member = $_GET['m'] ?? null; diff --git a/api/me-picture.php b/api/me-picture.php index 408b8c8..636188e 100644 --- a/api/me-picture.php +++ b/api/me-picture.php @@ -1,7 +1,7 @@ <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $isLoggedIn; -if (!$isLoggedIn) header("Location: /login") and die(); +if (!$isLoggedIn) header("Location: /-/login") and die(); global $_PROFILE; header("Content-Type: application/json"); @@ -1,7 +1,7 @@ <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $isLoggedIn; -if (!$isLoggedIn) header("Location: /login") and die(); +if (!$isLoggedIn) header("Location: /-/login") and die(); global $_PROFILE; header("Content-Type: application/json"); diff --git a/api/pleasure-real.php b/api/pleasure-real.php index 992f659..d62c8d4 100644 --- a/api/pleasure-real.php +++ b/api/pleasure-real.php @@ -1,7 +1,7 @@ <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $isLoggedIn; -if (!$isLoggedIn) header("Location: /login") and die(); +if (!$isLoggedIn) header("Location: /-/login") and die(); global $_PROFILE; if ($_PROFILE['login'] === "raindrops") $pony = "Cloudy"; else $pony = "Lavender"; diff --git a/api/pleasure.php b/api/pleasure.php index 702fe2f..5b72405 100644 --- a/api/pleasure.php +++ b/api/pleasure.php @@ -1,7 +1,7 @@ <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $isLoggedIn; -if (!$isLoggedIn) header("Location: /login") and die(); +if (!$isLoggedIn) header("Location: /-/login") and die(); global $_PROFILE; if ($_PROFILE['login'] === "raindrops") $pony = "Cloudy"; else $pony = "Lavender"; diff --git a/api/pluralkit-integration.php b/api/pluralkit-integration.php index b2247ce..262d4a6 100644 --- a/api/pluralkit-integration.php +++ b/api/pluralkit-integration.php @@ -21,15 +21,38 @@ if ($input["signing_token"] !== $data[$user]) { if ($input['system_id'] === "7d9f543e-f742-40f6-9d07-86c3f2983124") { $system = "gdapd"; + $name = "Raindrops System"; } else { $system = "ynmuc"; + $name = "Cloudburst System"; } +$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") { - usleep(550000); file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system-fronters.json", file_get_contents("https://pluralkit.equestria.dev/v2/systems/$input[system_id]/fronters")); - usleep(550000); file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system-switches.json", file_get_contents("https://pluralkit.equestria.dev/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"]; + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system-last.json", json_encode($currentFronter)); + + $ntfy = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true)["ntfy"]; + + file_get_contents('https://' . $ntfy["server"] . '/public-switches', 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 715d7c4..f42426a 100644 --- a/api/raindrops-banners.php +++ b/api/raindrops-banners.php @@ -3,7 +3,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $isLoggedIn; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/bitset.php"; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/banner.php"; -if (!$isLoggedIn) header("Location: /login") and die(); +if (!$isLoggedIn) header("Location: /-/login") and die(); $data = []; diff --git a/api/raindrops-data.php b/api/raindrops-data.php index 6af9233..958fb8f 100644 --- a/api/raindrops-data.php +++ b/api/raindrops-data.php @@ -2,7 +2,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $isLoggedIn; require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/bitset.php"; -if (!$isLoggedIn) header("Location: /login") and die(); +if (!$isLoggedIn) header("Location: /-/login") and die(); $data = []; $data["members"] = []; diff --git a/api/raindrops-scored.php b/api/raindrops-scored.php new file mode 100644 index 0000000..929cdc8 --- /dev/null +++ b/api/raindrops-scored.php @@ -0,0 +1,9 @@ +<?php + +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $isLoggedIn; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/score.php"; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/bitset.php"; +if (!$isLoggedIn) header("Location: /-/login") and die(); + +header("Content-Type: application/json"); +die(json_encode(array_values(scoreOrder(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd-members.json"), true), "gdapd")), JSON_PRETTY_PRINT));
\ No newline at end of file diff --git a/api/save.php b/api/save.php index a54a02a..f679a71 100644 --- a/api/save.php +++ b/api/save.php @@ -1,7 +1,7 @@ <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $isLoggedIn; -if (!$isLoggedIn) header("Location: /login") and die(); +if (!$isLoggedIn) header("Location: /-/login") and die(); $request_raw = file_get_contents('php://input'); $json_object = json_decode($request_raw, true); diff --git a/api/token.php b/api/token.php index 81fe3d0..8c18c30 100644 --- a/api/token.php +++ b/api/token.php @@ -1,7 +1,7 @@ <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $isLoggedIn; -if (!$isLoggedIn) header("Location: /login") and die(); +if (!$isLoggedIn) header("Location: /-/login") and die(); header("Content-Type: text/plain"); die($_COOKIE['PEH2_SESSION_TOKEN']);
\ No newline at end of file diff --git a/api/video.php b/api/video.php index 7ac32a1..e960ddf 100644 --- a/api/video.php +++ b/api/video.php @@ -1,7 +1,7 @@ <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $isLoggedIn; -if (!$isLoggedIn) header("Location: /login") and die(); +if (!$isLoggedIn) header("Location: /-/login") and die(); if (isset($_GET['id'])) { header("Content-Type: application/json"); |