summaryrefslogtreecommitdiff
path: root/pages/api/rename.php
blob: d4505574d8c9651d01db8e3bdc99fecc315e2deb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?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();
}

$data = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens/" . str_replace("/", "", $_COOKIE['PEH2_SESSION_TOKEN'])), true);

$data["name"] = $_GET["name"] ?? $data["name"];

file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens/" . str_replace("/", "", $_COOKIE['PEH2_SESSION_TOKEN']), json_encode($data));