<?php include "private.php"; $user = new Account(); $user->initWithId($_SESSION[KEY_SESSION][Account::KEY_ID]); if (!$user->isAdmin()) { // We redirect them to the login page header("Location: /thread/"); die; } if (!empty($_POST)) { if ($_POST["action"] == "noticeboard_create") { // create new note post request $author_id = $_SESSION[KEY_SESSION][Account::KEY_ID]; $content = $_POST["notice_content"]; $content = preg_replace("/\n/", "<br>", $content); $content = preg_replace_callback("|\\[(.*?)\\]\\((.*?)\\)|", function ($matches) { return "<a href=\"{$matches[2]}\">{$matches['1']}</a>"; }, $content); if (!empty($content)) { NoticeBoard::create($author_id, $content); } die; } else { if ($_POST["action"] == "noticeboard_update") { // update note status $id = abs(intval($_POST["id"])); $checked = false; if ($_POST["checked"] == "checked") { $checked = true; }