summaryrefslogtreecommitdiff
path: root/api/booru-check.php
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2023-01-25 21:29:24 +0100
committerMinteck <contact@minteck.org>2023-01-25 21:29:24 +0100
commit9b2f05228357a34a3c0f2950782835dfeb35086e (patch)
tree5a13df212ad9c22e3af921017950cb6d617d3a37 /api/booru-check.php
parent78003af142c7c851ee14dbafecaa47954e07a8c2 (diff)
downloadpluralconnect-9b2f05228357a34a3c0f2950782835dfeb35086e.tar.gz
pluralconnect-9b2f05228357a34a3c0f2950782835dfeb35086e.tar.bz2
pluralconnect-9b2f05228357a34a3c0f2950782835dfeb35086e.zip
Updated 3 files and added 2 files (automated)
Diffstat (limited to 'api/booru-check.php')
-rw-r--r--api/booru-check.php24
1 files changed, 24 insertions, 0 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