-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();