summaryrefslogtreecommitdiff
path: root/pages/api/rename.php
diff options
context:
space:
mode:
authorRaindropsSys <contact@minteck.org>2023-05-16 22:17:15 +0200
committerRaindropsSys <contact@minteck.org>2023-05-16 22:17:15 +0200
commit98a84f3aa735f31b08e807c8a4f0549742cbd1b0 (patch)
tree9a510d41197d6af646f1ee0bdbf261437211f1bc /pages/api/rename.php
parent60f7da42c41b35b44fa397397a5e4bccd6039d45 (diff)
downloadpluralconnect-98a84f3aa735f31b08e807c8a4f0549742cbd1b0.tar.gz
pluralconnect-98a84f3aa735f31b08e807c8a4f0549742cbd1b0.tar.bz2
pluralconnect-98a84f3aa735f31b08e807c8a4f0549742cbd1b0.zip
Updated 8 files (automated)
Diffstat (limited to 'pages/api/rename.php')
-rw-r--r--pages/api/rename.php26
1 files changed, 23 insertions, 3 deletions
diff --git a/pages/api/rename.php b/pages/api/rename.php
index d450557..abec81e 100644
--- a/pages/api/rename.php
+++ b/pages/api/rename.php
@@ -10,8 +10,28 @@ if (!$isLoggedIn || $isLowerLoggedIn) {
die();
}
-$data = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens/" . str_replace("/", "", $_COOKIE['PEH2_SESSION_TOKEN'])), true);
+$obj = [
+ "success" => true
+];
-$data["name"] = $_GET["name"] ?? $data["name"];
+global $token;
+$data = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens/" . str_replace("/", "", $token)), true);
-file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens/" . str_replace("/", "", $_COOKIE['PEH2_SESSION_TOKEN']), json_encode($data)); \ No newline at end of file
+$data["name"] = $_POST["name"] ?? $_GET["name"] ?? $data["name"];
+$obj["pre_name"] = $data["name"];
+
+$request_raw = file_get_contents('php://input');
+$json_object = json_decode($request_raw, true);
+
+if (json_last_error() === JSON_ERROR_NONE) {
+ $obj["json_error"] = [ json_last_error(), json_last_error_msg() ];
+ if (isset($json_object["name"])) {
+ $data["name"] = $json_object["name"];
+ $obj["json_name"] = $json_object["name"];
+ }
+}
+
+$obj["new_name"] = $data["name"];
+
+file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens/" . str_replace("/", "", $token), json_encode($data));
+die(json_encode($obj)); \ No newline at end of file