summaryrefslogtreecommitdiff
path: root/inc/mod/pages.php
diff options
context:
space:
mode:
authorMichael Save <savetheinternet@tinyboard.org>2013-01-24 19:16:25 +1100
committerMichael Save <savetheinternet@tinyboard.org>2013-01-24 19:16:25 +1100
commit85710249b705c455b2243f450765e458c14cdba6 (patch)
tree106cb607d97b1da2921c4ea94d78591cd8e71835 /inc/mod/pages.php
parent85578b7105f7b53e0f45fc886270540b9d07b2f3 (diff)
Raw HTML editing
Diffstat (limited to 'inc/mod/pages.php')
-rw-r--r--inc/mod/pages.php22
1 files changed, 16 insertions, 6 deletions
diff --git a/inc/mod/pages.php b/inc/mod/pages.php
index 1a55ec7d..70f2e964 100644
--- a/inc/mod/pages.php
+++ b/inc/mod/pages.php
@@ -986,7 +986,7 @@ function mod_ban_post($board, $delete, $post, $token = false) {
mod_page(_('New ban'), 'mod/ban_form.html', $args);
}
-function mod_edit_post($board, $postID) {
+function mod_edit_post($board, $edit_raw_html, $postID) {
global $config, $mod;
if (!openBoard($board))
@@ -994,8 +994,11 @@ function mod_edit_post($board, $postID) {
if (!hasPermission($config['mod']['editpost'], $board))
error($config['error']['noaccess']);
+
+ if ($edit_raw_html && !hasPermission($config['mod']['rawhtml'], $board))
+ error($config['error']['noaccess']);
- $security_token = make_secure_link_token($board . '/edit/' . $postID);
+ $security_token = make_secure_link_token($board . '/edit' . ($edit_raw_html ? '_raw' : '') . '/' . $postID);
$query = prepare(sprintf('SELECT * FROM `posts_%s` WHERE `id` = :id', $board));
$query->bindValue(':id', $postID);
@@ -1005,7 +1008,10 @@ function mod_edit_post($board, $postID) {
error($config['error']['404']);
if (isset($_POST['name'], $_POST['email'], $_POST['subject'], $_POST['body'])) {
- $query = prepare(sprintf('UPDATE `posts_%s` SET `name` = :name, `email` = :email, `subject` = :subject, `body_nomarkup` = :body WHERE `id` = :id', $board));
+ if ($edit_raw_html)
+ $query = prepare(sprintf('UPDATE `posts_%s` SET `name` = :name, `email` = :email, `subject` = :subject, `body` = :body WHERE `id` = :id', $board));
+ else
+ $query = prepare(sprintf('UPDATE `posts_%s` SET `name` = :name, `email` = :email, `subject` = :subject, `body_nomarkup` = :body WHERE `id` = :id', $board));
$query->bindValue(':id', $postID);
$query->bindValue('name', $_POST['name']);
$query->bindValue(':email', $_POST['email']);
@@ -1013,15 +1019,19 @@ function mod_edit_post($board, $postID) {
$query->bindValue(':body', $_POST['body']);
$query->execute() or error(db_error($query));
- rebuildPost($postID);
+ if (!$edit_raw_html)
+ rebuildPost($postID);
+
buildIndex();
header('Location: ?/' . sprintf($config['board_path'], $board) . $config['dir']['res'] . sprintf($config['file_page'], $post['thread'] ? $post['thread'] : $postID) . '#' . $postID, true, $config['redirect_http']);
} else {
- if ($config['minify_html'])
+ if ($config['minify_html']) {
$post['body_nomarkup'] = str_replace("\n", '&#010;', $post['body_nomarkup']);
+ $post['body'] = str_replace("\n", '&#010;', $post['body']);
+ }
- mod_page(_('Edit post'), 'mod/edit_post_form.html', array('token' => $security_token, 'post' => $post));
+ mod_page(_('Edit post'), 'mod/edit_post_form.html', array('token' => $security_token, 'board' => $board, 'raw' => $edit_raw_html, 'post' => $post));
}
}