blob: abec81ee3c9e6b93b308df36edd7942257ef666b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
<?php
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc";
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $isLowerLoggedIn;
header("Content-Type: application/json");
if (!$isLoggedIn || $isLowerLoggedIn) {
header("Location: /-/login");
die();
}
$obj = [
"success" => true
];
global $token;
$data = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens/" . str_replace("/", "", $token)), true);
$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));
|