<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $isLowerLoggedIn; global $app; if (!$isLoggedIn && !$isLowerLoggedIn) 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; $content = $json_object['content'] ?? null; if (!isset($system) || trim($system) === "" || strlen($system) !== 5 || !preg_match("/[a-z]/i", $system)) peh_error("System not found", 404); if (!isset($member) || trim($member) === "" || strlen($member) !== 5 || !preg_match("/[a-z]/i", $member)) if ($member !== null && $member !== "null") peh_error("System member not found", 404); if ($isLowerLoggedIn && $system !== $app["other"]["id"]) die(); if (!isset($content)) peh_error("No content", 400); if ($member !== null && $member !== "null") { $file = $_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/" . $member . ".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);