diff options
author | RaindropsSys <raindrops@equestria.dev> | 2024-03-30 23:40:33 +0100 |
---|---|---|
committer | RaindropsSys <raindrops@equestria.dev> | 2024-03-30 23:40:33 +0100 |
commit | 6b796258d413f00e498ce7f80f73a9f6c061f29c (patch) | |
tree | 49e64a5dd4cde2acff7f0a93ed3f8e20e1cb2dc8 /api | |
parent | 5860551daa0f60103ad24e93da29f401a653f144 (diff) | |
download | pluralconnect-6b796258d413f00e498ce7f80f73a9f6c061f29c.tar.gz pluralconnect-6b796258d413f00e498ce7f80f73a9f6c061f29c.tar.bz2 pluralconnect-6b796258d413f00e498ce7f80f73a9f6c061f29c.zip |
Updated 5 files, added 2 files, deleted 495 files and renamed 7 files (automated)
Diffstat (limited to 'api')
-rw-r--r-- | api/healthcheck.php | 3 | ||||
-rw-r--r-- | api/pluralkit-integration.php | 29 | ||||
-rw-r--r-- | api/timeline.php | 12 | ||||
-rw-r--r-- | api/violette.php | 25 |
4 files changed, 34 insertions, 35 deletions
diff --git a/api/healthcheck.php b/api/healthcheck.php new file mode 100644 index 0000000..0876dfa --- /dev/null +++ b/api/healthcheck.php @@ -0,0 +1,3 @@ +<?php + +die(); diff --git a/api/pluralkit-integration.php b/api/pluralkit-integration.php index 9b0033d..f0f22d3 100644 --- a/api/pluralkit-integration.php +++ b/api/pluralkit-integration.php @@ -6,6 +6,27 @@ $inputJSON = file_get_contents('php://input'); $input = json_decode($inputJSON, true); $data = $GLOBALS["ColdHazeApp"]["webhook"]; +function random($length = 13): string { + if (function_exists("random_bytes")) { + $bytes = random_bytes(ceil($length / 2)); + } elseif (function_exists("openssl_random_pseudo_bytes")) { + $bytes = openssl_random_pseudo_bytes(ceil($length / 2)); + } else { + throw new Exception("No cryptographically secure random function available"); + } + return substr(bin2hex($bytes), 0, $length); +} + +function createJob($title, $options): void { + $job = [ + "name" => $title, + "options" => $options, + "date" => date('c') + ]; + + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/data/jobs/" . round(microtime(true) * 1000000) . "-" . random() . ".json", json_encode($job)); +} + if ($user === null) { header("HTTP/1.1 500 Internal Server Error") and die(); } @@ -31,24 +52,18 @@ if ($input['system_id'] === "7d9f543e-f742-40f6-9d07-86c3f2983124") { die(); } -$lastFronter = json_decode(@file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/last.json"), true) ?? ""; +$lastFronter = json_decode(@file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/$system/last.json"), true) ?? ""; if ($input["type"] === "CREATE_MEMBER" || $input["type"] === "UPDATE_MEMBER" || $input["type"] === "DELETE_MEMBER") { createJob("PKMembers", [ "system" => $system ]); - createJob("UpdateAssets", [ - "type" => "members" - ]); } if ($input["type"] === "UPDATE_SYSTEM") { createJob("PKSystem", [ "system" => $system ]); - createJob("UpdateAssets", [ - "type" => "system" - ]); } if ($input["type"] === "CREATE_SWITCH" || $input["type"] === "UPDATE_SWITCH" || $input["type"] === "DELETE_SWITCH") { diff --git a/api/timeline.php b/api/timeline.php deleted file mode 100644 index 8271b7a..0000000 --- a/api/timeline.php +++ /dev/null @@ -1,12 +0,0 @@ -<?php - -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc"; global $app; -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $isLowerLoggedIn; global $_PROFILE; - -$systems = array_filter(array_keys($_GET), function ($i) { - global $isLowerLoggedIn; global $isLoggedIn; global $app; - return $i === "gdapd" || $i === "hrbom" || (($isLowerLoggedIn || $isLoggedIn) && $i === $app["other"]["id"]); -}); - -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/components/timeline.inc"; -displayTimeline($systems);
\ No newline at end of file diff --git a/api/violette.php b/api/violette.php index 1f6f4f0..52a0566 100644 --- a/api/violette.php +++ b/api/violette.php @@ -1,23 +1,16 @@ <?php -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc"; +$list = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/gdapd/members.json"), true); $data = [ - "count" => 0, - "ponies" => [] + "count" => count($list), + "ponies" => array_values(array_map(function ($i) { + return [ + "url" => $i["avatar_url"] ?? null, + "label" => $i["display_name"] ?? $i["name"] + ]; + }, $list)) ]; -$list = scoreOrder(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/members.json"), true), "gdapd"); - -$data["count"] = count($list); -$data["ponies"] = array_values(array_filter(array_map(function ($i) { - return [ - "url" => "https://ponycule.p.equestria.dev" . getAsset("gdapd", $i["id"] ?? "", "heads"), - "label" => $i["display_name"] ?? $i["name"] - ]; -}, $list), function ($i) { - return isset($i["url"]) && getAsset("gdapd", $i["id"] ?? "", "heads") !== null; -})); - header("Content-Type: application/json"); -die(json_encode($data, JSON_PRETTY_PRINT));
\ No newline at end of file +die(json_encode($data, JSON_PRETTY_PRINT)); |