summaryrefslogtreecommitdiff
path: root/pages/edit-private.inc
blob: f26c8c6d6d0a42d6eab598dbcaf7e8e60e6cbd83 (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
38
39
40
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $lang; global $pages;

if (!isset($_GET['_']) || trim($_GET['_']) === "") peh_error("Invalid request", 400);

$parts = explode("/", $_GET['_']);
array_shift($parts);
array_shift($parts);
$system = $parts[0];
$member = ($parts[1] ?? null) === "" ? null : $parts[1];

if ($system !== "cloudburst" && $system !== "raindrops") peh_error("Invalid system name: " . $system, 400);
$systemCommonName = $system === "cloudburst" ? "Cloudburst System" : "Raindrops System";
$systemID = $system === "cloudburst" ? "ynmuc" : "gdapd";

if ($member === null) {
    peh_error("Unsupported target: system", 500);
} else {
    $members = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $systemID . "/members.json"), true);
    $memberData = null;
    $memberCommonName = null;
    $memberID = null;

    foreach ($members as $m) {
        if ($m['name'] === $member) {
            $memberData = $m;
            $memberCommonName = $m['display_name'] ?? $m['name'];
            $memberID = $m['id'];
        }
    }

    if ($memberData === null) {
        peh_error("System member not found", 404);
    }

    require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/fragments/edit-private.inc';
}

exit;