blob: f679a71284dd1275c6f65220d2e60284ee6fd4ef (
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
41
42
43
|
<?php
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $isLoggedIn;
if (!$isLoggedIn) header("Location: /-/login") and die();
$request_raw = file_get_contents('php://input');
$json_object = json_decode($request_raw, true);
$system = $_GET['system'] ?? null;
$member = $_GET['member'] ?? null;
$subsystem = $_GET['subsystem'] ?? null;
$content = $json_object['content'] ?? null;
if (!isset($system) || trim($system) === "" || strlen($system) !== 5 || !preg_match("/[a-z]/i", $system))
header("Location: /?error=System not found") and die();
if (!isset($member) || trim($member) === "" || strlen($member) !== 5 || !preg_match("/[a-z]/i", $member))
if ($member !== null && $member !== "null") header("Location: /?error=System member not found") and die();
if (!isset($subsystem) || trim($subsystem) === "" || !preg_match("/[a-z\d]/i", $subsystem))
if ($subsystem !== null && $subsystem !== "null") header("Location: /?error=Subsystem not found") and die();
if (!isset($content))
header("Location: /?error=No content") and die();
if ($member !== null && $member !== "null") {
$file = $_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $system . "-" . $member . "-content.html";
} else {
if ($subsystem !== null && $subsystem !== "null") {
$file = $_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $system . "-subsystem-" . $subsystem . ".html";
} else {
$file = $_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $system . "-content.html";
}
}
if (trim($content) === "") {
if (file_exists($file)) {
unlink($file);
}
die();
}
file_put_contents($file, $content);
|