diff --git a/mod.php b/mod.php index c7239968..9ccee228 100644 --- a/mod.php +++ b/mod.php @@ -488,8 +488,7 @@ $body = ''; - if($mod['type'] >= $config['mod']['noticeboard_post']) { - if(isset($_POST['subject']) && isset($_POST['body']) && !empty($_POST['body'])) { + if(hasPermission($config['mod']['noticeboard_post']) && isset($_POST['subject']) && isset($_POST['body']) && !empty($_POST['body'])) { $query = prepare("INSERT INTO `noticeboard` VALUES (NULL, :mod, :time, :subject, :body)"); $query->bindValue(':mod', $mod['id'], PDO::PARAM_INT); $query->bindvalue(':time', time(), PDO::PARAM_INT); @@ -498,60 +497,64 @@ markup($_POST['body']); $query->bindValue(':body', $_POST['body']); $query->execute() or error(db_error($query)); + + header('Location: ?/noticeboard', true, $config['redirect_http']); + } else { + + if(hasPermission($config['mod']['noticeboard_post'])) { + $body .= '
'; } - $body .= ''; - } + $query = prepare("SELECT * FROM `noticeboard` ORDER BY `id` DESC LIMIT :limit"); + $query->bindValue(':limit', $config['mod']['noticeboard_display'], PDO::PARAM_INT); + $query->execute() or error(db_error($query)); + while($notice = $query->fetch()) { + $m_query = prepare("SELECT `username` FROM `mods` WHERE `id` = :id"); + $m_query->bindValue(':id', $notice['mod'], PDO::PARAM_INT); + $m_query->execute() or error(db_error($m_query)); + if(!$_mod = $m_query->fetch()) { + $_mod = Array('username' => '???'); + } - $query = prepare("SELECT * FROM `noticeboard` ORDER BY `id` DESC LIMIT :limit"); - $query->bindValue(':limit', $config['mod']['noticeboard_display'], PDO::PARAM_INT); - $query->execute() or error(db_error($query)); - while($notice = $query->fetch()) { - $m_query = prepare("SELECT `username` FROM `mods` WHERE `id` = :id"); - $m_query->bindValue(':id', $notice['mod'], PDO::PARAM_INT); - $m_query->execute() or error(db_error($m_query)); - if(!$_mod = $m_query->fetch()) { - $_mod = Array('username' => '???'); + $body .= '' . $notice['body'] . '
' . $notice['body'] . '