permitted('users_warn')) { error(403); } authorize(); $postId = (int)($_POST['postid'] ?? 0); $post = $manager->findById($postId); if (is_null($post)) { error(404); } $userMan = new \Gazelle\Manager\User(); $user = $userMan->findById($post->userId()); if (is_null($user)) { error(404); } if ($user->classLevel() >= $Viewer->classLevel()) { error(403); } $body = trim($_POST['body'] ?? ''); if (empty($body)) { error("Post body cannot be left empty (you can leave a reason for others to see)"); } if (empty($_POST['reason'])) { error("Reason for warning not provided"); } if (!isset($_POST['length']) || !strlen($_POST['length'])) { error("Length of warning not provided"); } $weeks = (int)$_POST['length']; $reason = trim($_POST['reason']); $userMessage = trim($_POST['privatemessage']); $user->warnPost($post, $weeks, $Viewer, $reason, $userMessage); header("Location: {$post->location()}"); return [$post, $body]; }