summaryrefslogtreecommitdiff
path: root/pages/api/fronter.php
diff options
context:
space:
mode:
Diffstat (limited to 'pages/api/fronter.php')
-rw-r--r--pages/api/fronter.php177
1 files changed, 0 insertions, 177 deletions
diff --git a/pages/api/fronter.php b/pages/api/fronter.php
deleted file mode 100644
index a908efa..0000000
--- a/pages/api/fronter.php
+++ /dev/null
@@ -1,177 +0,0 @@
-<?php
-
-require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc";
-require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $isLowerLoggedIn;
-if (!$isLoggedIn || $isLowerLoggedIn) {
- header("Location: /-/login");
- die();
-}
-
-$system = $_GET['s'] ?? null;
-$member = $_GET['m'] ?? null;
-$index = (int)$_GET['i'] ?? null;
-$type = $_GET['t'] ?? null;
-$date = $_GET['d'] ?? null;
-
-if (!isset($system) || trim($system) === "" || strlen($system) !== 5 || !preg_match("/[a-z]/i", $system) || ($system !== "gdapd" && $system !== "ynmuc")) {
- peh_error("System not found", 404);
-}
-
-if (!isset($type) || trim($type) === "") {
- peh_error("Type not found", 404);
-}
-
-if (!isset($date) || trim($date) === "" || strlen($date) !== 10 || !preg_match("/[\d-]/i", $date)) {
- peh_error("Date not found", 404);
-}
-
-$list = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/planner/$system.json"), true);
-
-function moveElement(&$array, $a, $b) {
- $out = array_splice($array, $a, 1);
- array_splice($array, $b, 0, $out);
-}
-
-switch ($type) {
- case "add":
- 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 (!isset($list[$date])) $list[$date] = [];
- $list[$date][] = [$member, null];
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/planner.json", "{}");
- createJob("RefreshCache", []);
- break;
-
- case "cofront":
- if (!isset($index) || trim($index) === "" || !is_integer($index)) {
- if ($index !== null) peh_error("Invalid index", 400);
- }
-
- $day = $list[$date];
-
- if (!isset($day[$index])) {
- if ($index !== null) peh_error("Index 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);
- }
-
- $list[$date][$index][1] = $member;
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/planner.json", "{}");
- createJob("RefreshCache", []);
- break;
-
- case "delete":
- if (!isset($index) || trim($index) === "" || !is_integer($index)) {
- if ($index !== null) peh_error("Invalid index", 400);
- }
-
- $day = $list[$date];
-
- if (!isset($day[$index])) {
- if ($index !== null) peh_error("Index not found", 404);
- }
-
- unset($day[$index]);
- $list[$date] = array_values($day);
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/planner.json", "{}");
- createJob("RefreshCache", []);
-
- break;
-
- case "codelete":
- if (!isset($index) || trim($index) === "" || !is_integer($index)) {
- if ($index !== null) peh_error("Invalid index", 400);
- }
-
- $day = $list[$date];
-
- if (!isset($day[$index])) {
- if ($index !== null) peh_error("Index not found", 404);
- }
-
- $list[$date][$index][1] = null;
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/planner.json", "{}");
- createJob("RefreshCache", []);
-
- break;
-
- case "down":
- if (!isset($index) || trim($index) === "" || !is_integer($index)) {
- if ($index !== null) peh_error("Invalid index", 400);
- }
-
- $day = $list[$date];
-
- if (!isset($day[$index])) {
- if ($index !== null) peh_error("Index not found", 404);
- }
-
- moveElement($list[$date], $index, $index + 1 < count($list[$date]) ? $index + 1 : $index);
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/planner.json", "{}");
- createJob("RefreshCache", []);
-
- break;
-
- case "bottom":
- if (!isset($index) || trim($index) === "" || !is_integer($index)) {
- if ($index !== null) peh_error("Invalid index", 400);
- }
-
- $day = $list[$date];
-
- if (!isset($day[$index])) {
- if ($index !== null) peh_error("Index not found", 404);
- }
-
- moveElement($list[$date], $index, count($list[$date]) - 1);
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/planner.json", "{}");
- createJob("RefreshCache", []);
-
- break;
-
- case "up":
- if (!isset($index) || trim($index) === "" || !is_integer($index)) {
- if ($index !== null) peh_error("Invalid index", 400);
- }
-
- $day = $list[$date];
-
- if (!isset($day[$index])) {
- if ($index !== null) peh_error("Index not found", 404);
- }
-
- moveElement($list[$date], $index, $index - 1 > -1 ? $index - 1 : $index);
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/planner.json", "{}");
- createJob("RefreshCache", []);
-
- break;
-
- case "top":
- if (!isset($index) || trim($index) === "" || !is_integer($index)) {
- if ($index !== null) peh_error("Invalid index", 400);
- }
-
- $day = $list[$date];
-
- if (!isset($day[$index])) {
- if ($index !== null) peh_error("Index not found", 404);
- }
-
- moveElement($list[$date], $index, 0);
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/planner.json", "{}");
- createJob("RefreshCache", []);
-
- break;
-
- default:
- peh_error("Invalid type name", 400);
- break;
-}
-
-file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/planner/$system.json", json_encode($list));
-
-die(); \ No newline at end of file