diff options
Diffstat (limited to 'api')
-rw-r--r-- | api/booru-check.php | 24 | ||||
-rw-r--r-- | api/booru.php | 8 | ||||
-rw-r--r-- | api/raindrops-img.php | 3 |
3 files changed, 34 insertions, 1 deletions
diff --git a/api/booru-check.php b/api/booru-check.php new file mode 100644 index 0000000..b2a3800 --- /dev/null +++ b/api/booru-check.php @@ -0,0 +1,24 @@ +<?php + +$list = array_map(function ($i) { + return sha1($i) . md5($i); +}, array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens"), function ($i) { return !str_starts_with($i, "."); })); +header("Content-Type: text/plain"); + +$obj = [ + "valid" => false, + "user" => null +]; + +if (isset($_GET["key"])) { + if (in_array($_GET["key"], $list)) { + $obj["valid"] = true; + + foreach (array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens"), function ($i) { return !str_starts_with($i, "."); }) as $token) { + $data = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens/" . $token), true); + $obj["user"] = $data["login"]; + } + } +} + +die(json_encode($obj));
\ No newline at end of file diff --git a/api/booru.php b/api/booru.php new file mode 100644 index 0000000..3c3c1d0 --- /dev/null +++ b/api/booru.php @@ -0,0 +1,8 @@ +<?php + +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.inc"; +global $isLoggedIn; +if (!$isLoggedIn) header("Location: /-/login") and die(); + +header("Location: http://localhost:8083/auth/?key=" . sha1($_COOKIE['PEH2_SESSION_TOKEN']) . md5($_COOKIE['PEH2_SESSION_TOKEN'])); +die();
\ No newline at end of file diff --git a/api/raindrops-img.php b/api/raindrops-img.php index 6a7484f..4cbac6b 100644 --- a/api/raindrops-img.php +++ b/api/raindrops-img.php @@ -1,8 +1,9 @@ <?php +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/functions.inc"; $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"; +$url = isset($fronters['members'][0]) ? ($fronters['members'][0]["avatar_url"] ? $_SERVER['DOCUMENT_ROOT'] . getAsset("gdapd", $fronters['members'][0]["id"]) : $_SERVER['DOCUMENT_ROOT'] . "/uploads/raindrops.png") : $_SERVER['DOCUMENT_ROOT'] . "/uploads/raindrops.png"; file_put_contents("/tmp/temp", file_get_contents($url)); header("Content-Type: " . mime_content_type("/tmp/temp")); unlink("/tmp/temp"); |