root / trunk / phpBB / posting.php
History | View | Annotate | Download (57.8 kB)
| 1 | 2 | thefinn | <?php
|
|---|---|---|---|
| 2 | 7736 | acydburn | /**
|
| 3 | 5114 | acydburn | * |
| 4 | 5114 | acydburn | * @package phpBB3 |
| 5 | 7736 | acydburn | * @copyright (c) 2005 phpBB Group |
| 6 | 11653 | git-gate | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 |
| 7 | 5114 | acydburn | * |
| 8 | 5114 | acydburn | */ |
| 9 | 2 | thefinn | |
| 10 | 5114 | acydburn | /**
|
| 11 | 5883 | acydburn | * @ignore |
| 12 | 5114 | acydburn | */ |
| 13 | 4767 | acydburn | define('IN_PHPBB', true); |
| 14 | 7954 | acydburn | $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; |
| 15 | 4473 | psotfx | $phpEx = substr(strrchr(__FILE__, '.'), 1); |
| 16 | 6015 | acydburn | include($phpbb_root_path . 'common.' . $phpEx); |
| 17 | 6015 | acydburn | include($phpbb_root_path . 'includes/functions_posting.' . $phpEx); |
| 18 | 5247 | acydburn | include($phpbb_root_path . 'includes/functions_display.' . $phpEx); |
| 19 | 6015 | acydburn | include($phpbb_root_path . 'includes/message_parser.' . $phpEx); |
| 20 | 169 | thefinn | |
| 21 | 4167 | psotfx | |
| 22 | 2972 | psotfx | // Start session management
|
| 23 | 5247 | acydburn | $user->session_begin();
|
| 24 | 2972 | psotfx | $auth->acl($user->data); |
| 25 | 2972 | psotfx | |
| 26 | 4167 | psotfx | |
| 27 | 3354 | psotfx | // Grab only parameters needed here
|
| 28 | 4539 | acydburn | $post_id = request_var('p', 0); |
| 29 | 4539 | acydburn | $topic_id = request_var('t', 0); |
| 30 | 4539 | acydburn | $forum_id = request_var('f', 0); |
| 31 | 4668 | acydburn | $draft_id = request_var('d', 0); |
| 32 | 4539 | acydburn | $lastclick = request_var('lastclick', 0); |
| 33 | 3354 | psotfx | |
| 34 | 5902 | acydburn | $submit = (isset($_POST['post'])) ? true : false; |
| 35 | 5902 | acydburn | $preview = (isset($_POST['preview'])) ? true : false; |
| 36 | 5902 | acydburn | $save = (isset($_POST['save'])) ? true : false; |
| 37 | 5902 | acydburn | $load = (isset($_POST['load'])) ? true : false; |
| 38 | 5902 | acydburn | $delete = (isset($_POST['delete'])) ? true : false; |
| 39 | 5967 | acydburn | $cancel = (isset($_POST['cancel']) && !isset($_POST['save'])) ? true : false; |
| 40 | 3553 | acydburn | |
| 41 | 9981 | acydburn | $refresh = (isset($_POST['add_file']) || isset($_POST['delete_file']) || isset($_POST['full_editor']) || isset($_POST['cancel_unglobalise']) || $save || $load) ? true : false; |
| 42 | 4767 | acydburn | $mode = ($delete && !$preview && !$refresh && $submit) ? 'delete' : request_var('mode', ''); |
| 43 | 3631 | acydburn | |
| 44 | 5902 | acydburn | $error = $post_data = array(); |
| 45 | 4620 | psotfx | $current_time = time(); |
| 46 | 4170 | psotfx | |
| 47 | 2958 | psotfx | // Was cancel pressed? If so then redirect to the appropriate page
|
| 48 | 4890 | acydburn | if ($cancel || ($current_time - $lastclick < 2 && $submit)) |
| 49 | 378 | psotfx | {
|
| 50 | 9406 | terrafrost | $f = ($forum_id) ? 'f=' . $forum_id . '&' : ''; |
| 51 | 9406 | terrafrost | $redirect = ($post_id) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", $f . 'p=' . $post_id) . '#p' . $post_id : (($topic_id) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", $f . 't=' . $topic_id) : (($forum_id) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id) : append_sid("{$phpbb_root_path}index.$phpEx"))); |
| 52 | 2958 | psotfx | redirect($redirect);
|
| 53 | 378 | psotfx | } |
| 54 | 378 | psotfx | |
| 55 | 5678 | acydburn | if (in_array($mode, array('post', 'reply', 'quote', 'edit', 'delete')) && !$forum_id) |
| 56 | 4460 | acydburn | {
|
| 57 | 4575 | acydburn | trigger_error('NO_FORUM'); |
| 58 | 4460 | acydburn | } |
| 59 | 4460 | acydburn | |
| 60 | 6015 | acydburn | // We need to know some basic information in all cases before we do anything.
|
| 61 | 3354 | psotfx | switch ($mode) |
| 62 | 2183 | psotfx | {
|
| 63 | 2972 | psotfx | case 'post': |
| 64 | 4139 | acydburn | $sql = 'SELECT * |
| 65 | 4139 | acydburn | FROM ' . FORUMS_TABLE . " |
| 66 | 4139 | acydburn | WHERE forum_id = $forum_id"; |
| 67 | 5486 | acydburn | break;
|
| 68 | 2983 | psotfx | |
| 69 | 4614 | acydburn | case 'bump': |
| 70 | 2923 | psotfx | case 'reply': |
| 71 | 3543 | acydburn | if (!$topic_id) |
| 72 | 582 | psotfx | {
|
| 73 | 4575 | acydburn | trigger_error('NO_TOPIC'); |
| 74 | 2183 | psotfx | } |
| 75 | 824 | psotfx | |
| 76 | 9499 | acydburn | // Force forum id
|
| 77 | 9499 | acydburn | $sql = 'SELECT forum_id |
| 78 | 9499 | acydburn | FROM ' . TOPICS_TABLE . ' |
| 79 | 9499 | acydburn | WHERE topic_id = ' . $topic_id; |
| 80 | 9499 | acydburn | $result = $db->sql_query($sql); |
| 81 | 9499 | acydburn | $f_id = (int) $db->sql_fetchfield('forum_id'); |
| 82 | 9499 | acydburn | $db->sql_freeresult($result); |
| 83 | 9499 | acydburn | |
| 84 | 9499 | acydburn | $forum_id = (!$f_id) ? $forum_id : $f_id; |
| 85 | 9499 | acydburn | |
| 86 | 4968 | acydburn | $sql = 'SELECT f.*, t.* |
| 87 | 4139 | acydburn | FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f |
| 88 | 4139 | acydburn | WHERE t.topic_id = $topic_id |
| 89 | 11100 | git-gate | AND f.forum_id = t.forum_id" .
|
| 90 | 11100 | git-gate | (($auth->acl_get('m_approve', $forum_id)) ? '' : ' AND t.topic_approved = 1'); |
| 91 | 5486 | acydburn | break;
|
| 92 | 4970 | psotfx | |
| 93 | 2923 | psotfx | case 'quote': |
| 94 | 2972 | psotfx | case 'edit': |
| 95 | 2923 | psotfx | case 'delete': |
| 96 | 3543 | acydburn | if (!$post_id) |
| 97 | 2383 | psotfx | {
|
| 98 | 7356 | davidmj | $user->setup('posting'); |
| 99 | 4575 | acydburn | trigger_error('NO_POST'); |
| 100 | 2383 | psotfx | } |
| 101 | 2305 | psotfx | |
| 102 | 9499 | acydburn | // Force forum id
|
| 103 | 9499 | acydburn | $sql = 'SELECT forum_id |
| 104 | 9499 | acydburn | FROM ' . POSTS_TABLE . ' |
| 105 | 9499 | acydburn | WHERE post_id = ' . $post_id; |
| 106 | 9499 | acydburn | $result = $db->sql_query($sql); |
| 107 | 9499 | acydburn | $f_id = (int) $db->sql_fetchfield('forum_id'); |
| 108 | 9499 | acydburn | $db->sql_freeresult($result); |
| 109 | 9499 | acydburn | |
| 110 | 9499 | acydburn | $forum_id = (!$f_id) ? $forum_id : $f_id; |
| 111 | 9499 | acydburn | |
| 112 | 6698 | acydburn | $sql = 'SELECT f.*, t.*, p.*, u.username, u.username_clean, u.user_sig, u.user_sig_bbcode_uid, u.user_sig_bbcode_bitfield |
| 113 | 4139 | acydburn | FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . ' f, ' . USERS_TABLE . " u |
| 114 | 4139 | acydburn | WHERE p.post_id = $post_id |
| 115 | 2923 | psotfx | AND t.topic_id = p.topic_id |
| 116 | 3575 | acydburn | AND u.user_id = p.poster_id |
| 117 | 11100 | git-gate | AND f.forum_id = t.forum_id" .
|
| 118 | 11100 | git-gate | (($auth->acl_get('m_approve', $forum_id)) ? '' : ' AND p.post_approved = 1'); |
| 119 | 5486 | acydburn | break;
|
| 120 | 326 | thefinn | |
| 121 | 2986 | psotfx | case 'smilies': |
| 122 | 4883 | acydburn | $sql = ''; |
| 123 | 4544 | acydburn | generate_smilies('window', $forum_id); |
| 124 | 5486 | acydburn | break;
|
| 125 | 2986 | psotfx | |
| 126 | 4883 | acydburn | case 'popup': |
| 127 | 5678 | acydburn | if ($forum_id) |
| 128 | 5678 | acydburn | {
|
| 129 | 5678 | acydburn | $sql = 'SELECT forum_style |
| 130 | 5678 | acydburn | FROM ' . FORUMS_TABLE . ' |
| 131 | 5678 | acydburn | WHERE forum_id = ' . $forum_id; |
| 132 | 5678 | acydburn | } |
| 133 | 5678 | acydburn | else
|
| 134 | 5678 | acydburn | {
|
| 135 | 5678 | acydburn | upload_popup(); |
| 136 | 8957 | acydburn | return;
|
| 137 | 5678 | acydburn | } |
| 138 | 5486 | acydburn | break;
|
| 139 | 4883 | acydburn | |
| 140 | 2923 | psotfx | default:
|
| 141 | 4170 | psotfx | $sql = ''; |
| 142 | 5902 | acydburn | break;
|
| 143 | 987 | psotfx | } |
| 144 | 2183 | psotfx | |
| 145 | 5902 | acydburn | if (!$sql) |
| 146 | 2972 | psotfx | {
|
| 147 | 7356 | davidmj | $user->setup('posting'); |
| 148 | 5902 | acydburn | trigger_error('NO_POST_MODE'); |
| 149 | 5902 | acydburn | } |
| 150 | 3354 | psotfx | |
| 151 | 5902 | acydburn | $result = $db->sql_query($sql); |
| 152 | 5902 | acydburn | $post_data = $db->sql_fetchrow($result); |
| 153 | 5902 | acydburn | $db->sql_freeresult($result); |
| 154 | 3572 | acydburn | |
| 155 | 6478 | acydburn | if (!$post_data) |
| 156 | 6478 | acydburn | {
|
| 157 | 7356 | davidmj | if (!($mode == 'post' || $mode == 'bump' || $mode == 'reply')) |
| 158 | 7356 | davidmj | {
|
| 159 | 7356 | davidmj | $user->setup('posting'); |
| 160 | 7356 | davidmj | } |
| 161 | 6478 | acydburn | trigger_error(($mode == 'post' || $mode == 'bump' || $mode == 'reply') ? 'NO_TOPIC' : 'NO_POST'); |
| 162 | 6478 | acydburn | } |
| 163 | 6478 | acydburn | |
| 164 | 10342 | acydburn | // Not able to reply to unapproved posts/topics
|
| 165 | 10342 | acydburn | // TODO: add more descriptive language key
|
| 166 | 10342 | acydburn | if ($auth->acl_get('m_approve', $forum_id) && ((($mode == 'reply' || $mode == 'bump') && !$post_data['topic_approved']) || ($mode == 'quote' && !$post_data['post_approved']))) |
| 167 | 10342 | acydburn | {
|
| 168 | 10342 | acydburn | trigger_error(($mode == 'reply' || $mode == 'bump') ? 'TOPIC_UNAPPROVED' : 'POST_UNAPPROVED'); |
| 169 | 10342 | acydburn | } |
| 170 | 10342 | acydburn | |
| 171 | 5902 | acydburn | if ($mode == 'popup') |
| 172 | 5902 | acydburn | {
|
| 173 | 5902 | acydburn | upload_popup($post_data['forum_style']); |
| 174 | 8957 | acydburn | return;
|
| 175 | 2972 | psotfx | } |
| 176 | 2983 | psotfx | |
| 177 | 6190 | acydburn | $user->setup(array('posting', 'mcp', 'viewtopic'), $post_data['forum_style']); |
| 178 | 6190 | acydburn | |
| 179 | 10342 | acydburn | if ($config['enable_post_confirm'] && !$user->data['is_registered']) |
| 180 | 10342 | acydburn | {
|
| 181 | 10342 | acydburn | include($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx); |
| 182 | 11361 | git-gate | $captcha = phpbb_captcha_factory::get_instance($config['captcha_plugin']); |
| 183 | 10342 | acydburn | $captcha->init(CONFIRM_POST); |
| 184 | 10342 | acydburn | } |
| 185 | 10342 | acydburn | |
| 186 | 5902 | acydburn | // Use post_row values in favor of submitted ones...
|
| 187 | 5902 | acydburn | $forum_id = (!empty($post_data['forum_id'])) ? (int) $post_data['forum_id'] : (int) $forum_id; |
| 188 | 5902 | acydburn | $topic_id = (!empty($post_data['topic_id'])) ? (int) $post_data['topic_id'] : (int) $topic_id; |
| 189 | 5902 | acydburn | $post_id = (!empty($post_data['post_id'])) ? (int) $post_data['post_id'] : (int) $post_id; |
| 190 | 5902 | acydburn | |
| 191 | 5902 | acydburn | // Need to login to passworded forum first?
|
| 192 | 5902 | acydburn | if ($post_data['forum_password']) |
| 193 | 2983 | psotfx | {
|
| 194 | 5902 | acydburn | login_forum_box(array(
|
| 195 | 5902 | acydburn | 'forum_id' => $forum_id, |
| 196 | 5902 | acydburn | 'forum_password' => $post_data['forum_password']) |
| 197 | 5902 | acydburn | ); |
| 198 | 2983 | psotfx | } |
| 199 | 2983 | psotfx | |
| 200 | 5765 | acydburn | // Check permissions
|
| 201 | 7804 | acydburn | if ($user->data['is_bot']) |
| 202 | 7804 | acydburn | {
|
| 203 | 7804 | acydburn | redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
|
| 204 | 7804 | acydburn | } |
| 205 | 5902 | acydburn | |
| 206 | 5902 | acydburn | // Is the user able to read within this forum?
|
| 207 | 5902 | acydburn | if (!$auth->acl_get('f_read', $forum_id)) |
| 208 | 2958 | psotfx | {
|
| 209 | 6619 | acydburn | if ($user->data['user_id'] != ANONYMOUS) |
| 210 | 4836 | acydburn | {
|
| 211 | 5765 | acydburn | trigger_error('USER_CANNOT_READ'); |
| 212 | 4836 | acydburn | } |
| 213 | 4970 | psotfx | |
| 214 | 5765 | acydburn | login_box('', $user->lang['LOGIN_EXPLAIN_POST']); |
| 215 | 5765 | acydburn | } |
| 216 | 5765 | acydburn | |
| 217 | 5902 | acydburn | // Permission to do the action asked?
|
| 218 | 6135 | acydburn | $is_authed = false; |
| 219 | 6135 | acydburn | |
| 220 | 6135 | acydburn | switch ($mode) |
| 221 | 5765 | acydburn | {
|
| 222 | 6135 | acydburn | case 'post': |
| 223 | 6135 | acydburn | if ($auth->acl_get('f_post', $forum_id)) |
| 224 | 6135 | acydburn | {
|
| 225 | 6135 | acydburn | $is_authed = true; |
| 226 | 6135 | acydburn | } |
| 227 | 6135 | acydburn | break;
|
| 228 | 6135 | acydburn | |
| 229 | 6135 | acydburn | case 'bump': |
| 230 | 6135 | acydburn | if ($auth->acl_get('f_bump', $forum_id)) |
| 231 | 6135 | acydburn | {
|
| 232 | 6135 | acydburn | $is_authed = true; |
| 233 | 6135 | acydburn | } |
| 234 | 6135 | acydburn | break;
|
| 235 | 6135 | acydburn | |
| 236 | 6135 | acydburn | case 'quote': |
| 237 | 6831 | acydburn | |
| 238 | 6831 | acydburn | $post_data['post_edit_locked'] = 0; |
| 239 | 6831 | acydburn | |
| 240 | 6831 | acydburn | // no break;
|
| 241 | 6831 | acydburn | |
| 242 | 6135 | acydburn | case 'reply': |
| 243 | 6135 | acydburn | if ($auth->acl_get('f_reply', $forum_id)) |
| 244 | 6135 | acydburn | {
|
| 245 | 6135 | acydburn | $is_authed = true; |
| 246 | 6135 | acydburn | } |
| 247 | 6135 | acydburn | break;
|
| 248 | 6135 | acydburn | |
| 249 | 6135 | acydburn | case 'edit': |
| 250 | 6135 | acydburn | if ($user->data['is_registered'] && $auth->acl_gets('f_edit', 'm_edit', $forum_id)) |
| 251 | 6135 | acydburn | {
|
| 252 | 6135 | acydburn | $is_authed = true; |
| 253 | 6135 | acydburn | } |
| 254 | 6135 | acydburn | break;
|
| 255 | 6135 | acydburn | |
| 256 | 6135 | acydburn | case 'delete': |
| 257 | 6135 | acydburn | if ($user->data['is_registered'] && $auth->acl_gets('f_delete', 'm_delete', $forum_id)) |
| 258 | 6135 | acydburn | {
|
| 259 | 6135 | acydburn | $is_authed = true; |
| 260 | 6135 | acydburn | } |
| 261 | 6135 | acydburn | break;
|
| 262 | 6135 | acydburn | } |
| 263 | 6135 | acydburn | |
| 264 | 6135 | acydburn | if (!$is_authed) |
| 265 | 6135 | acydburn | {
|
| 266 | 6135 | acydburn | $check_auth = ($mode == 'quote') ? 'reply' : $mode; |
| 267 | 6135 | acydburn | |
| 268 | 5765 | acydburn | if ($user->data['is_registered']) |
| 269 | 5765 | acydburn | {
|
| 270 | 5765 | acydburn | trigger_error('USER_CANNOT_' . strtoupper($check_auth)); |
| 271 | 5765 | acydburn | } |
| 272 | 5765 | acydburn | |
| 273 | 4970 | psotfx | login_box('', $user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)]); |
| 274 | 2972 | psotfx | } |
| 275 | 502 | psotfx | |
| 276 | 5902 | acydburn | // Is the user able to post within this forum?
|
| 277 | 5902 | acydburn | if ($post_data['forum_type'] != FORUM_POST && in_array($mode, array('post', 'bump', 'quote', 'reply'))) |
| 278 | 5902 | acydburn | {
|
| 279 | 5902 | acydburn | trigger_error('USER_CANNOT_FORUM_POST'); |
| 280 | 5902 | acydburn | } |
| 281 | 5902 | acydburn | |
| 282 | 2997 | psotfx | // Forum/Topic locked?
|
| 283 | 5902 | acydburn | if (($post_data['forum_status'] == ITEM_LOCKED || (isset($post_data['topic_status']) && $post_data['topic_status'] == ITEM_LOCKED)) && !$auth->acl_get('m_edit', $forum_id)) |
| 284 | 2997 | psotfx | {
|
| 285 | 5902 | acydburn | trigger_error(($post_data['forum_status'] == ITEM_LOCKED) ? 'FORUM_LOCKED' : 'TOPIC_LOCKED'); |
| 286 | 2997 | psotfx | } |
| 287 | 2997 | psotfx | |
| 288 | 4970 | psotfx | // Can we edit this post ... if we're a moderator with rights then always yes
|
| 289 | 4970 | psotfx | // else it depends on editing times, lock status and if we're the correct user
|
| 290 | 5902 | acydburn | if ($mode == 'edit' && !$auth->acl_get('m_edit', $forum_id)) |
| 291 | 2972 | psotfx | {
|
| 292 | 5902 | acydburn | if ($user->data['user_id'] != $post_data['poster_id']) |
| 293 | 4970 | psotfx | {
|
| 294 | 4970 | psotfx | trigger_error('USER_CANNOT_EDIT'); |
| 295 | 4970 | psotfx | } |
| 296 | 4970 | psotfx | |
| 297 | 6104 | acydburn | if (!($post_data['post_time'] > time() - ($config['edit_time'] * 60) || !$config['edit_time'])) |
| 298 | 4883 | acydburn | {
|
| 299 | 4883 | acydburn | trigger_error('CANNOT_EDIT_TIME'); |
| 300 | 4883 | acydburn | } |
| 301 | 2849 | psotfx | |
| 302 | 5902 | acydburn | if ($post_data['post_edit_locked']) |
| 303 | 4883 | acydburn | {
|
| 304 | 4883 | acydburn | trigger_error('CANNOT_EDIT_POST_LOCKED'); |
| 305 | 4883 | acydburn | } |
| 306 | 3553 | acydburn | } |
| 307 | 3553 | acydburn | |
| 308 | 5902 | acydburn | // Handle delete mode...
|
| 309 | 5902 | acydburn | if ($mode == 'delete') |
| 310 | 3858 | ludovic_arnaud | {
|
| 311 | 5902 | acydburn | handle_post_delete($forum_id, $topic_id, $post_id, $post_data); |
| 312 | 8957 | acydburn | return;
|
| 313 | 3858 | ludovic_arnaud | } |
| 314 | 3858 | ludovic_arnaud | |
| 315 | 5902 | acydburn | // Handle bump mode...
|
| 316 | 5902 | acydburn | if ($mode == 'bump') |
| 317 | 3582 | acydburn | {
|
| 318 | 8775 | Kellanved | if ($bump_time = bump_topic_allowed($forum_id, $post_data['topic_bumped'], $post_data['topic_last_post_time'], $post_data['topic_poster'], $post_data['topic_last_poster_id']) |
| 319 | 8944 | acydburn | && check_link_hash(request_var('hash', ''), "topic_{$post_data['topic_id']}")) |
| 320 | 3582 | acydburn | {
|
| 321 | 11199 | git-gate | $meta_url = phpbb_bump_topic($forum_id, $topic_id, $post_data, $current_time); |
| 322 | 5902 | acydburn | meta_refresh(3, $meta_url); |
| 323 | 5902 | acydburn | |
| 324 | 11603 | git-gate | $message = $user->lang['TOPIC_BUMPED'] . '<br /><br />' . $user->lang('VIEW_MESSAGE', '<a href="' . $meta_url . '">', '</a>'); |
| 325 | 6015 | acydburn | $message .= '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id) . '">', '</a>'); |
| 326 | 5902 | acydburn | |
| 327 | 3883 | acydburn | trigger_error($message); |
| 328 | 3582 | acydburn | } |
| 329 | 6015 | acydburn | |
| 330 | 5902 | acydburn | trigger_error('BUMP_ERROR'); |
| 331 | 5902 | acydburn | } |
| 332 | 5902 | acydburn | |
| 333 | 8034 | acydburn | // Subject length limiting to 60 characters if first post...
|
| 334 | 8034 | acydburn | if ($mode == 'post' || ($mode == 'edit' && $post_data['topic_first_post_id'] == $post_data['post_id'])) |
| 335 | 8034 | acydburn | {
|
| 336 | 8034 | acydburn | $template->assign_var('S_NEW_MESSAGE', true); |
| 337 | 8034 | acydburn | } |
| 338 | 5902 | acydburn | |
| 339 | 5902 | acydburn | // Determine some vars
|
| 340 | 7777 | kellanved | if (isset($post_data['poster_id']) && $post_data['poster_id'] == ANONYMOUS) |
| 341 | 7777 | kellanved | {
|
| 342 | 7777 | kellanved | $post_data['quote_username'] = (!empty($post_data['post_username'])) ? $post_data['post_username'] : $user->lang['GUEST']; |
| 343 | 7777 | kellanved | } |
| 344 | 7777 | kellanved | else
|
| 345 | 7777 | kellanved | {
|
| 346 | 7777 | kellanved | $post_data['quote_username'] = isset($post_data['username']) ? $post_data['username'] : ''; |
| 347 | 7777 | kellanved | } |
| 348 | 8034 | acydburn | |
| 349 | 5902 | acydburn | $post_data['post_edit_locked'] = (isset($post_data['post_edit_locked'])) ? (int) $post_data['post_edit_locked'] : 0; |
| 350 | 9731 | bantu | $post_data['post_subject_md5'] = (isset($post_data['post_subject']) && $mode == 'edit') ? md5($post_data['post_subject']) : ''; |
| 351 | 5902 | acydburn | $post_data['post_subject'] = (in_array($mode, array('quote', 'edit'))) ? $post_data['post_subject'] : ((isset($post_data['topic_title'])) ? $post_data['topic_title'] : ''); |
| 352 | 5902 | acydburn | $post_data['topic_time_limit'] = (isset($post_data['topic_time_limit'])) ? (($post_data['topic_time_limit']) ? (int) $post_data['topic_time_limit'] / 86400 : (int) $post_data['topic_time_limit']) : 0; |
| 353 | 5902 | acydburn | $post_data['poll_length'] = (!empty($post_data['poll_length'])) ? (int) $post_data['poll_length'] / 86400 : 0; |
| 354 | 5902 | acydburn | $post_data['poll_start'] = (!empty($post_data['poll_start'])) ? (int) $post_data['poll_start'] : 0; |
| 355 | 5902 | acydburn | $post_data['icon_id'] = (!isset($post_data['icon_id']) || in_array($mode, array('quote', 'reply'))) ? 0 : (int) $post_data['icon_id']; |
| 356 | 5902 | acydburn | $post_data['poll_options'] = array(); |
| 357 | 5902 | acydburn | |
| 358 | 5902 | acydburn | // Get Poll Data
|
| 359 | 5902 | acydburn | if ($post_data['poll_start']) |
| 360 | 5902 | acydburn | {
|
| 361 | 5902 | acydburn | $sql = 'SELECT poll_option_text |
| 362 | 5902 | acydburn | FROM ' . POLL_OPTIONS_TABLE . " |
| 363 | 5902 | acydburn | WHERE topic_id = $topic_id |
| 364 | 5902 | acydburn | ORDER BY poll_option_id";
|
| 365 | 5902 | acydburn | $result = $db->sql_query($sql); |
| 366 | 5902 | acydburn | |
| 367 | 5902 | acydburn | while ($row = $db->sql_fetchrow($result)) |
| 368 | 3582 | acydburn | {
|
| 369 | 5902 | acydburn | $post_data['poll_options'][] = trim($row['poll_option_text']); |
| 370 | 3582 | acydburn | } |
| 371 | 5902 | acydburn | $db->sql_freeresult($result); |
| 372 | 3582 | acydburn | } |
| 373 | 3582 | acydburn | |
| 374 | 10784 | git-gate | if ($mode == 'edit') |
| 375 | 10784 | git-gate | {
|
| 376 | 10784 | git-gate | $original_poll_data = array( |
| 377 | 10784 | git-gate | 'poll_title' => $post_data['poll_title'], |
| 378 | 10784 | git-gate | 'poll_length' => $post_data['poll_length'], |
| 379 | 10784 | git-gate | 'poll_max_options' => $post_data['poll_max_options'], |
| 380 | 10784 | git-gate | 'poll_option_text' => implode("\n", $post_data['poll_options']), |
| 381 | 10784 | git-gate | 'poll_start' => $post_data['poll_start'], |
| 382 | 10784 | git-gate | 'poll_last_vote' => $post_data['poll_last_vote'], |
| 383 | 10784 | git-gate | 'poll_vote_change' => $post_data['poll_vote_change'], |
| 384 | 10784 | git-gate | ); |
| 385 | 10784 | git-gate | } |
| 386 | 10754 | git-gate | |
| 387 | 5902 | acydburn | $orig_poll_options_size = sizeof($post_data['poll_options']); |
| 388 | 4167 | psotfx | |
| 389 | 5902 | acydburn | $message_parser = new parse_message(); |
| 390 | 5902 | acydburn | |
| 391 | 5902 | acydburn | if (isset($post_data['post_text'])) |
| 392 | 3582 | acydburn | {
|
| 393 | 5902 | acydburn | $message_parser->message = &$post_data['post_text']; |
| 394 | 5902 | acydburn | unset($post_data['post_text']); |
| 395 | 3582 | acydburn | } |
| 396 | 3582 | acydburn | |
| 397 | 5902 | acydburn | // Set some default variables
|
| 398 | 5922 | acydburn | $uninit = array('post_attachment' => 0, 'poster_id' => $user->data['user_id'], 'enable_magic_url' => 0, 'topic_status' => 0, 'topic_type' => POST_NORMAL, 'post_subject' => '', 'topic_title' => '', 'post_time' => 0, 'post_edit_reason' => '', 'notify_set' => 0); |
| 399 | 6014 | acydburn | |
| 400 | 5902 | acydburn | foreach ($uninit as $var_name => $default_value) |
| 401 | 3582 | acydburn | {
|
| 402 | 5902 | acydburn | if (!isset($post_data[$var_name])) |
| 403 | 5902 | acydburn | {
|
| 404 | 5902 | acydburn | $post_data[$var_name] = $default_value; |
| 405 | 5902 | acydburn | } |
| 406 | 3582 | acydburn | } |
| 407 | 5902 | acydburn | unset($uninit); |
| 408 | 3582 | acydburn | |
| 409 | 6364 | acydburn | // Always check if the submitted attachment data is valid and belongs to the user.
|
| 410 | 6364 | acydburn | // Further down (especially in submit_post()) we do not check this again.
|
| 411 | 6014 | acydburn | $message_parser->get_submitted_attachment_data($post_data['poster_id']); |
| 412 | 6014 | acydburn | |
| 413 | 5902 | acydburn | if ($post_data['post_attachment'] && !$submit && !$refresh && !$preview && $mode == 'edit') |
| 414 | 3582 | acydburn | {
|
| 415 | 6015 | acydburn | // Do not change to SELECT *
|
| 416 | 6364 | acydburn | $sql = 'SELECT attach_id, is_orphan, attach_comment, real_filename |
| 417 | 5902 | acydburn | FROM ' . ATTACHMENTS_TABLE . " |
| 418 | 5902 | acydburn | WHERE post_msg_id = $post_id |
| 419 | 5902 | acydburn | AND in_message = 0 |
| 420 | 6364 | acydburn | AND is_orphan = 0 |
| 421 | 6628 | acydburn | ORDER BY filetime DESC";
|
| 422 | 5902 | acydburn | $result = $db->sql_query($sql); |
| 423 | 5902 | acydburn | $message_parser->attachment_data = array_merge($message_parser->attachment_data, $db->sql_fetchrowset($result)); |
| 424 | 5902 | acydburn | $db->sql_freeresult($result); |
| 425 | 3582 | acydburn | } |
| 426 | 3582 | acydburn | |
| 427 | 5902 | acydburn | if ($post_data['poster_id'] == ANONYMOUS) |
| 428 | 5902 | acydburn | {
|
| 429 | 5902 | acydburn | $post_data['username'] = ($mode == 'quote' || $mode == 'edit') ? trim($post_data['post_username']) : ''; |
| 430 | 5902 | acydburn | } |
| 431 | 5902 | acydburn | else
|
| 432 | 5902 | acydburn | {
|
| 433 | 5902 | acydburn | $post_data['username'] = ($mode == 'quote' || $mode == 'edit') ? trim($post_data['username']) : ''; |
| 434 | 5902 | acydburn | } |
| 435 | 4167 | psotfx | |
| 436 | 5902 | acydburn | $post_data['enable_urls'] = $post_data['enable_magic_url']; |
| 437 | 4047 | ludovic_arnaud | |
| 438 | 5902 | acydburn | if ($mode != 'edit') |
| 439 | 4614 | acydburn | {
|
| 440 | 5902 | acydburn | $post_data['enable_sig'] = ($config['allow_sig'] && $user->optionget('attachsig')) ? true: false; |
| 441 | 5902 | acydburn | $post_data['enable_smilies'] = ($config['allow_smilies'] && $user->optionget('smilies')) ? true : false; |
| 442 | 5902 | acydburn | $post_data['enable_bbcode'] = ($config['allow_bbcode'] && $user->optionget('bbcode')) ? true : false; |
| 443 | 5902 | acydburn | $post_data['enable_urls'] = true; |
| 444 | 5902 | acydburn | } |
| 445 | 4614 | acydburn | |
| 446 | 5902 | acydburn | $post_data['enable_magic_url'] = $post_data['drafts'] = false; |
| 447 | 4614 | acydburn | |
| 448 | 5902 | acydburn | // User own some drafts?
|
| 449 | 7384 | acydburn | if ($user->data['is_registered'] && $auth->acl_get('u_savedrafts') && ($mode == 'reply' || $mode == 'post' || $mode == 'quote')) |
| 450 | 5902 | acydburn | {
|
| 451 | 5902 | acydburn | $sql = 'SELECT draft_id |
| 452 | 5902 | acydburn | FROM ' . DRAFTS_TABLE . ' |
| 453 | 7615 | acydburn | WHERE user_id = ' . $user->data['user_id'] . |
| 454 | 8146 | acydburn | (($forum_id) ? ' AND forum_id = ' . (int) $forum_id : '') . |
| 455 | 7615 | acydburn | (($topic_id) ? ' AND topic_id = ' . (int) $topic_id : '') . |
| 456 | 5902 | acydburn | (($draft_id) ? " AND draft_id <> $draft_id" : ''); |
| 457 | 5902 | acydburn | $result = $db->sql_query_limit($sql, 1); |
| 458 | 4614 | acydburn | |
| 459 | 5902 | acydburn | if ($db->sql_fetchrow($result)) |
| 460 | 5902 | acydburn | {
|
| 461 | 5902 | acydburn | $post_data['drafts'] = true; |
| 462 | 5902 | acydburn | } |
| 463 | 5902 | acydburn | $db->sql_freeresult($result); |
| 464 | 5902 | acydburn | } |
| 465 | 4614 | acydburn | |
| 466 | 5902 | acydburn | $check_value = (($post_data['enable_bbcode']+1) << 8) + (($post_data['enable_smilies']+1) << 4) + (($post_data['enable_urls']+1) << 2) + (($post_data['enable_sig']+1) << 1); |
| 467 | 4614 | acydburn | |
| 468 | 5902 | acydburn | // Check if user is watching this topic
|
| 469 | 5949 | acydburn | if ($mode != 'post' && $config['allow_topic_notify'] && $user->data['is_registered']) |
| 470 | 5902 | acydburn | {
|
| 471 | 5902 | acydburn | $sql = 'SELECT topic_id |
| 472 | 5902 | acydburn | FROM ' . TOPICS_WATCH_TABLE . ' |
| 473 | 5902 | acydburn | WHERE topic_id = ' . $topic_id . ' |
| 474 | 5902 | acydburn | AND user_id = ' . $user->data['user_id']; |
| 475 | 5902 | acydburn | $result = $db->sql_query($sql); |
| 476 | 5902 | acydburn | $post_data['notify_set'] = (int) $db->sql_fetchfield('topic_id'); |
| 477 | 5902 | acydburn | $db->sql_freeresult($result); |
| 478 | 4614 | acydburn | } |
| 479 | 5902 | acydburn | |
| 480 | 5902 | acydburn | // Do we want to edit our post ?
|
| 481 | 6073 | acydburn | if ($mode == 'edit' && $post_data['bbcode_uid']) |
| 482 | 4634 | acydburn | {
|
| 483 | 5902 | acydburn | $message_parser->bbcode_uid = $post_data['bbcode_uid']; |
| 484 | 4634 | acydburn | } |
| 485 | 4614 | acydburn | |
| 486 | 5902 | acydburn | // HTML, BBCode, Smilies, Images and Flash status
|
| 487 | 5902 | acydburn | $bbcode_status = ($config['allow_bbcode'] && $auth->acl_get('f_bbcode', $forum_id)) ? true : false; |
| 488 | 9615 | nickvergessen | $smilies_status = ($config['allow_smilies'] && $auth->acl_get('f_smilies', $forum_id)) ? true : false; |
| 489 | 7241 | acydburn | $img_status = ($bbcode_status && $auth->acl_get('f_img', $forum_id)) ? true : false; |
| 490 | 6364 | acydburn | $url_status = ($config['allow_post_links']) ? true : false; |
| 491 | 7715 | kellanved | $flash_status = ($bbcode_status && $auth->acl_get('f_flash', $forum_id) && $config['allow_post_flash']) ? true : false; |
| 492 | 9590 | toonarmy | $quote_status = true; |
| 493 | 5902 | acydburn | |
| 494 | 4467 | acydburn | // Save Draft
|
| 495 | 7384 | acydburn | if ($save && $user->data['is_registered'] && $auth->acl_get('u_savedrafts') && ($mode == 'reply' || $mode == 'post' || $mode == 'quote')) |
| 496 | 4467 | acydburn | {
|
| 497 | 6584 | acydburn | $subject = utf8_normalize_nfc(request_var('subject', '', true)); |
| 498 | 5902 | acydburn | $subject = (!$subject && $mode != 'post') ? $post_data['topic_title'] : $subject; |
| 499 | 6584 | acydburn | $message = utf8_normalize_nfc(request_var('message', '', true)); |
| 500 | 8350 | acydburn | |
| 501 | 4862 | acydburn | if ($subject && $message) |
| 502 | 4467 | acydburn | {
|
| 503 | 5967 | acydburn | if (confirm_box(true)) |
| 504 | 5967 | acydburn | {
|
| 505 | 5967 | acydburn | $sql = 'INSERT INTO ' . DRAFTS_TABLE . ' ' . $db->sql_build_array('INSERT', array( |
| 506 | 7961 | acydburn | 'user_id' => (int) $user->data['user_id'], |
| 507 | 7961 | acydburn | 'topic_id' => (int) $topic_id, |
| 508 | 7961 | acydburn | 'forum_id' => (int) $forum_id, |
| 509 | 7961 | acydburn | 'save_time' => (int) $current_time, |
| 510 | 7961 | acydburn | 'draft_subject' => (string) $subject, |
| 511 | 7961 | acydburn | 'draft_message' => (string) $message) |
| 512 | 5967 | acydburn | ); |
| 513 | 5967 | acydburn | $db->sql_query($sql); |
| 514 | 4970 | psotfx | |
| 515 | 6015 | acydburn | $meta_info = ($mode == 'post') ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id) : append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id"); |
| 516 | 4467 | acydburn | |
| 517 | 5967 | acydburn | meta_refresh(3, $meta_info); |
| 518 | 4668 | acydburn | |
| 519 | 5967 | acydburn | $message = $user->lang['DRAFT_SAVED'] . '<br /><br />'; |
| 520 | 5967 | acydburn | $message .= ($mode != 'post') ? sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $meta_info . '">', '</a>') . '<br /><br />' : ''; |
| 521 | 6015 | acydburn | $message .= sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id) . '">', '</a>'); |
| 522 | 4668 | acydburn | |
| 523 | 5967 | acydburn | trigger_error($message); |
| 524 | 5967 | acydburn | } |
| 525 | 5967 | acydburn | else
|
| 526 | 5967 | acydburn | {
|
| 527 | 5967 | acydburn | $s_hidden_fields = build_hidden_fields(array( |
| 528 | 5967 | acydburn | 'mode' => $mode, |
| 529 | 5967 | acydburn | 'save' => true, |
| 530 | 5967 | acydburn | 'f' => $forum_id, |
| 531 | 5967 | acydburn | 't' => $topic_id, |
| 532 | 5967 | acydburn | 'subject' => $subject, |
| 533 | 5967 | acydburn | 'message' => $message, |
| 534 | 8380 | Kellanved | 'attachment_data' => $message_parser->attachment_data, |
| 535 | 6161 | acydburn | ) |
| 536 | 5967 | acydburn | ); |
| 537 | 5967 | acydburn | |
| 538 | 9859 | toonarmy | $hidden_fields = array( |
| 539 | 9859 | toonarmy | 'icon_id' => 0, |
| 540 | 9859 | toonarmy | |
| 541 | 9859 | toonarmy | 'disable_bbcode' => false, |
| 542 | 9859 | toonarmy | 'disable_smilies' => false, |
| 543 | 9859 | toonarmy | 'disable_magic_url' => false, |
| 544 | 9859 | toonarmy | 'attach_sig' => true, |
| 545 | 9859 | toonarmy | 'lock_topic' => false, |
| 546 | 9859 | toonarmy | |
| 547 | 9859 | toonarmy | 'topic_type' => POST_NORMAL, |
| 548 | 9859 | toonarmy | 'topic_time_limit' => 0, |
| 549 | 9859 | toonarmy | |
| 550 | 9859 | toonarmy | 'poll_title' => '', |
| 551 | 9859 | toonarmy | 'poll_option_text' => '', |
| 552 | 9859 | toonarmy | 'poll_max_options' => 1, |
| 553 | 9859 | toonarmy | 'poll_length' => 0, |
| 554 | 9859 | toonarmy | 'poll_vote_change' => false, |
| 555 | 9859 | toonarmy | ); |
| 556 | 9859 | toonarmy | |
| 557 | 9859 | toonarmy | foreach ($hidden_fields as $name => $default) |
| 558 | 9859 | toonarmy | {
|
| 559 | 9859 | toonarmy | if (!isset($_POST[$name])) |
| 560 | 9859 | toonarmy | {
|
| 561 | 9859 | toonarmy | // Don't include it, if its not available
|
| 562 | 9859 | toonarmy | unset($hidden_fields[$name]); |
| 563 | 9859 | toonarmy | continue;
|
| 564 | 9859 | toonarmy | } |
| 565 | 9859 | toonarmy | |
| 566 | 9859 | toonarmy | if (is_bool($default)) |
| 567 | 9859 | toonarmy | {
|
| 568 | 9859 | toonarmy | // Use the string representation
|
| 569 | 9859 | toonarmy | $hidden_fields[$name] = request_var($name, ''); |
| 570 | 9859 | toonarmy | } |
| 571 | 9859 | toonarmy | else
|
| 572 | 9859 | toonarmy | {
|
| 573 | 9859 | toonarmy | $hidden_fields[$name] = request_var($name, $default); |
| 574 | 9859 | toonarmy | } |
| 575 | 9859 | toonarmy | } |
| 576 | 9859 | toonarmy | |
| 577 | 9859 | toonarmy | $s_hidden_fields .= build_hidden_fields($hidden_fields); |
| 578 | 9859 | toonarmy | |
| 579 | 5967 | acydburn | confirm_box(false, 'SAVE_DRAFT', $s_hidden_fields); |
| 580 | 5967 | acydburn | } |
| 581 | 4467 | acydburn | } |
| 582 | 6801 | davidmj | else
|
| 583 | 6801 | davidmj | {
|
| 584 | 8306 | acydburn | if (utf8_clean_string($subject) === '') |
| 585 | 6801 | davidmj | {
|
| 586 | 6801 | davidmj | $error[] = $user->lang['EMPTY_SUBJECT']; |
| 587 | 6801 | davidmj | } |
| 588 | 4539 | acydburn | |
| 589 | 8306 | acydburn | if (utf8_clean_string($message) === '') |
| 590 | 6801 | davidmj | {
|
| 591 | 6801 | davidmj | $error[] = $user->lang['TOO_FEW_CHARS']; |
| 592 | 6801 | davidmj | } |
| 593 | 6801 | davidmj | } |
| 594 | 5902 | acydburn | unset($subject, $message); |
| 595 | 4467 | acydburn | } |
| 596 | 4467 | acydburn | |
| 597 | 5902 | acydburn | // Load requested Draft
|
| 598 | 7384 | acydburn | if ($draft_id && ($mode == 'reply' || $mode == 'quote' || $mode == 'post') && $user->data['is_registered'] && $auth->acl_get('u_savedrafts')) |
| 599 | 4668 | acydburn | {
|
| 600 | 4970 | psotfx | $sql = 'SELECT draft_subject, draft_message |
| 601 | 4970 | psotfx | FROM ' . DRAFTS_TABLE . " |
| 602 | 4668 | acydburn | WHERE draft_id = $draft_id |
| 603 | 4668 | acydburn | AND user_id = " . $user->data['user_id']; |
| 604 | 4668 | acydburn | $result = $db->sql_query_limit($sql, 1); |
| 605 | 5902 | acydburn | $row = $db->sql_fetchrow($result); |
| 606 | 5902 | acydburn | $db->sql_freeresult($result); |
| 607 | 4970 | psotfx | |
| 608 | 5902 | acydburn | if ($row) |
| 609 | 4668 | acydburn | {
|
| 610 | 5922 | acydburn | $post_data['post_subject'] = $row['draft_subject']; |
| 611 | 5922 | acydburn | $message_parser->message = $row['draft_message']; |
| 612 | 5922 | acydburn | |
| 613 | 4668 | acydburn | $template->assign_var('S_DRAFT_LOADED', true); |
| 614 | 4668 | acydburn | } |
| 615 | 4668 | acydburn | else
|
| 616 | 4668 | acydburn | {
|
| 617 | 4668 | acydburn | $draft_id = 0; |
| 618 | 4668 | acydburn | } |
| 619 | 4668 | acydburn | } |
| 620 | 4467 | acydburn | |
| 621 | 5902 | acydburn | // Load draft overview
|
| 622 | 7384 | acydburn | if ($load && ($mode == 'reply' || $mode == 'quote' || $mode == 'post') && $post_data['drafts']) |
| 623 | 4668 | acydburn | {
|
| 624 | 4668 | acydburn | load_drafts($topic_id, $forum_id); |
| 625 | 4668 | acydburn | } |
| 626 | 4668 | acydburn | |
| 627 | 6448 | davidmj | |
| 628 | 3961 | psotfx | if ($submit || $preview || $refresh) |
| 629 | 2923 | psotfx | {
|
| 630 | 6584 | acydburn | $post_data['topic_cur_post_id'] = request_var('topic_cur_post_id', 0); |
| 631 | 7920 | acydburn | $post_data['post_subject'] = utf8_normalize_nfc(request_var('subject', '', true)); |
| 632 | 6584 | acydburn | $message_parser->message = utf8_normalize_nfc(request_var('message', '', true)); |
| 633 | 4486 | acydburn | |
| 634 | 6584 | acydburn | $post_data['username'] = utf8_normalize_nfc(request_var('username', $post_data['username'], true)); |
| 635 | 10801 | git-gate | $post_data['post_edit_reason'] = ($request->variable('edit_reason', false, false, phpbb_request_interface::POST) && $mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? utf8_normalize_nfc(request_var('edit_reason', '', true)) : ''; |
| 636 | 6894 | acydburn | |
| 637 | 6894 | acydburn | $post_data['orig_topic_type'] = $post_data['topic_type']; |
| 638 | 5902 | acydburn | $post_data['topic_type'] = request_var('topic_type', (($mode != 'post') ? (int) $post_data['topic_type'] : POST_NORMAL)); |
| 639 | 5902 | acydburn | $post_data['topic_time_limit'] = request_var('topic_time_limit', (($mode != 'post') ? (int) $post_data['topic_time_limit'] : 0)); |
| 640 | 3572 | acydburn | |
| 641 | 9580 | bantu | if ($post_data['enable_icons'] && $auth->acl_get('f_icons', $forum_id)) |
| 642 | 9580 | bantu | {
|
| 643 | 9580 | bantu | $post_data['icon_id'] = request_var('icon', (int) $post_data['icon_id']); |
| 644 | 9580 | bantu | } |
| 645 | 9580 | bantu | |
| 646 | 5902 | acydburn | $post_data['enable_bbcode'] = (!$bbcode_status || isset($_POST['disable_bbcode'])) ? false : true; |
| 647 | 5902 | acydburn | $post_data['enable_smilies'] = (!$smilies_status || isset($_POST['disable_smilies'])) ? false : true; |
| 648 | 5902 | acydburn | $post_data['enable_urls'] = (isset($_POST['disable_magic_url'])) ? 0 : 1; |
| 649 | 8362 | Kellanved | $post_data['enable_sig'] = (!$config['allow_sig'] || !$auth->acl_get('f_sigs', $forum_id) || !$auth->acl_get('u_sig')) ? false : ((isset($_POST['attach_sig']) && $user->data['is_registered']) ? true : false); |
| 650 | 3937 | ludovic_arnaud | |
| 651 | 5949 | acydburn | if ($config['allow_topic_notify'] && $user->data['is_registered']) |
| 652 | 5949 | acydburn | {
|
| 653 | 5949 | acydburn | $notify = (isset($_POST['notify'])) ? true : false; |
| 654 | 5949 | acydburn | } |
| 655 | 5949 | acydburn | else
|
| 656 | 5949 | acydburn | {
|
| 657 | 5949 | acydburn | $notify = false; |
| 658 | 5949 | acydburn | } |
| 659 | 5949 | acydburn | |
| 660 | 5902 | acydburn | $topic_lock = (isset($_POST['lock_topic'])) ? true : false; |
| 661 | 5902 | acydburn | $post_lock = (isset($_POST['lock_post'])) ? true : false; |
| 662 | 5902 | acydburn | $poll_delete = (isset($_POST['poll_delete'])) ? true : false; |
| 663 | 3572 | acydburn | |
| 664 | 4978 | acydburn | if ($submit) |
| 665 | 4978 | acydburn | {
|
| 666 | 5902 | acydburn | $status_switch = (($post_data['enable_bbcode']+1) << 8) + (($post_data['enable_smilies']+1) << 4) + (($post_data['enable_urls']+1) << 2) + (($post_data['enable_sig']+1) << 1); |
| 667 | 4978 | acydburn | $status_switch = ($status_switch != $check_value); |
| 668 | 4978 | acydburn | } |
| 669 | 4978 | acydburn | else
|
| 670 | 4978 | acydburn | {
|
| 671 | 4978 | acydburn | $status_switch = 1; |
| 672 | 4978 | acydburn | } |
| 673 | 4093 | acydburn | |
| 674 | 4981 | acydburn | // Delete Poll
|
| 675 | 8146 | acydburn | if ($poll_delete && $mode == 'edit' && sizeof($post_data['poll_options']) && |
| 676 | 5902 | acydburn | ((!$post_data['poll_last_vote'] && $post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) || $auth->acl_get('m_delete', $forum_id))) |
| 677 | 3631 | acydburn | {
|
| 678 | 8268 | acydburn | if ($submit && check_form_key('posting')) |
| 679 | 6513 | acydburn | {
|
| 680 | 6513 | acydburn | $sql = 'DELETE FROM ' . POLL_OPTIONS_TABLE . " |
| 681 | 6513 | acydburn | WHERE topic_id = $topic_id"; |
| 682 | 6513 | acydburn | $db->sql_query($sql); |
| 683 | 3631 | acydburn | |
| 684 | 6513 | acydburn | $sql = 'DELETE FROM ' . POLL_VOTES_TABLE . " |
| 685 | 6513 | acydburn | WHERE topic_id = $topic_id"; |
| 686 | 6513 | acydburn | $db->sql_query($sql); |
| 687 | 8350 | acydburn | |
| 688 | 6513 | acydburn | $topic_sql = array( |
| 689 | 6513 | acydburn | 'poll_title' => '', |
| 690 | 6513 | acydburn | 'poll_start' => 0, |
| 691 | 6513 | acydburn | 'poll_length' => 0, |
| 692 | 6513 | acydburn | 'poll_last_vote' => 0, |
| 693 | 6513 | acydburn | 'poll_max_options' => 0, |
| 694 | 6513 | acydburn | 'poll_vote_change' => 0 |
| 695 | 6513 | acydburn | ); |
| 696 | 3883 | acydburn | |
| 697 | 6513 | acydburn | $sql = 'UPDATE ' . TOPICS_TABLE . ' |
| 698 | 6513 | acydburn | SET ' . $db->sql_build_array('UPDATE', $topic_sql) . " |
| 699 | 6513 | acydburn | WHERE topic_id = $topic_id"; |
| 700 | 6513 | acydburn | $db->sql_query($sql); |
| 701 | 6513 | acydburn | } |
| 702 | 3883 | acydburn | |
| 703 | 5902 | acydburn | $post_data['poll_title'] = $post_data['poll_option_text'] = ''; |
| 704 | 5902 | acydburn | $post_data['poll_vote_change'] = $post_data['poll_max_options'] = $post_data['poll_length'] = 0; |
| 705 | 3631 | acydburn | } |
| 706 | 3631 | acydburn | else
|
| 707 | 3631 | acydburn | {
|
| 708 | 6584 | acydburn | $post_data['poll_title'] = utf8_normalize_nfc(request_var('poll_title', '', true)); |
| 709 | 5902 | acydburn | $post_data['poll_length'] = request_var('poll_length', 0); |
| 710 | 6584 | acydburn | $post_data['poll_option_text'] = utf8_normalize_nfc(request_var('poll_option_text', '', true)); |
| 711 | 5902 | acydburn | $post_data['poll_max_options'] = request_var('poll_max_options', 1); |
| 712 | 9470 | acydburn | $post_data['poll_vote_change'] = ($auth->acl_get('f_votechg', $forum_id) && $auth->acl_get('f_vote', $forum_id) && isset($_POST['poll_vote_change'])) ? 1 : 0; |
| 713 | 3631 | acydburn | } |
| 714 | 3631 | acydburn | |
| 715 | 3072 | psotfx | // If replying/quoting and last post id has changed
|
| 716 | 4093 | acydburn | // give user option to continue submit or return to post
|
| 717 | 3543 | acydburn | // notify and show user the post made between his request and the final submit
|
| 718 | 5902 | acydburn | if (($mode == 'reply' || $mode == 'quote') && $post_data['topic_cur_post_id'] && $post_data['topic_cur_post_id'] != $post_data['topic_last_post_id']) |
| 719 | 3072 | psotfx | {
|
| 720 | 6161 | acydburn | // Only do so if it is allowed forum-wide
|
| 721 | 6364 | acydburn | if ($post_data['forum_flags'] & FORUM_FLAG_POST_REVIEW) |
| 722 | 3898 | acydburn | {
|
| 723 | 6161 | acydburn | if (topic_review($topic_id, $forum_id, 'post_review', $post_data['topic_cur_post_id'])) |
| 724 | 6161 | acydburn | {
|
| 725 | 6161 | acydburn | $template->assign_var('S_POST_REVIEW', true); |
| 726 | 6161 | acydburn | } |
| 727 | 6161 | acydburn | |
| 728 | 6161 | acydburn | $submit = false; |
| 729 | 6161 | acydburn | $refresh = true; |
| 730 | 3898 | acydburn | } |
| 731 | 3072 | psotfx | } |
| 732 | 3072 | psotfx | |
| 733 | 4819 | acydburn | // Parse Attachments - before checksum is calculated
|
| 734 | 10186 | nickvergessen | $message_parser->parse_attachments('fileupload', $mode, $forum_id, $submit, $preview, $refresh); |
| 735 | 4170 | psotfx | |
| 736 | 3354 | psotfx | // Grab md5 'checksum' of new message
|
| 737 | 3816 | acydburn | $message_md5 = md5($message_parser->message); |
| 738 | 2972 | psotfx | |
| 739 | 9731 | bantu | // If editing and checksum has changed we know the post was edited while we're editing
|
| 740 | 9731 | bantu | // Notify and show user the changed post
|
| 741 | 9731 | bantu | if ($mode == 'edit' && $post_data['forum_flags'] & FORUM_FLAG_POST_REVIEW) |
| 742 | 9731 | bantu | {
|
| 743 | 9731 | bantu | $edit_post_message_checksum = request_var('edit_post_message_checksum', ''); |
| 744 | 9731 | bantu | $edit_post_subject_checksum = request_var('edit_post_subject_checksum', ''); |
| 745 | 9731 | bantu | |
| 746 | 9731 | bantu | // $post_data['post_checksum'] is the checksum of the post submitted in the meantime
|
| 747 | 9731 | bantu | // $message_md5 is the checksum of the post we're about to submit
|
| 748 | 9731 | bantu | // $edit_post_message_checksum is the checksum of the post we're editing
|
| 749 | 9731 | bantu | // ...
|
| 750 | 9731 | bantu | |
| 751 | 9731 | bantu | // We make sure nobody else made exactly the same change
|
| 752 | 9731 | bantu | // we're about to submit by also checking $message_md5 != $post_data['post_checksum']
|
| 753 | 9731 | bantu | if (($edit_post_message_checksum !== '' && $edit_post_message_checksum != $post_data['post_checksum'] && $message_md5 != $post_data['post_checksum']) |
| 754 | 9731 | bantu | || ($edit_post_subject_checksum !== '' && $edit_post_subject_checksum != $post_data['post_subject_md5'] && md5($post_data['post_subject']) != $post_data['post_subject_md5'])) |
| 755 | 9731 | bantu | {
|
| 756 | 9731 | bantu | if (topic_review($topic_id, $forum_id, 'post_review_edit', $post_id)) |
| 757 | 9731 | bantu | {
|
| 758 | 9731 | bantu | $template->assign_vars(array( |
| 759 | 9731 | bantu | 'S_POST_REVIEW' => true, |
| 760 | 9731 | bantu | |
| 761 | 9742 | bantu | 'L_POST_REVIEW' => $user->lang['POST_REVIEW_EDIT'], |
| 762 | 9731 | bantu | 'L_POST_REVIEW_EXPLAIN' => $user->lang['POST_REVIEW_EDIT_EXPLAIN'], |
| 763 | 9731 | bantu | )); |
| 764 | 9731 | bantu | } |
| 765 | 9731 | bantu | |
| 766 | 9731 | bantu | $submit = false; |
| 767 | 9731 | bantu | $refresh = true; |
| 768 | 9731 | bantu | } |
| 769 | 9731 | bantu | } |
| 770 | 9731 | bantu | |
| 771 | 2983 | psotfx | // Check checksum ... don't re-parse message if the same
|
| 772 | 8128 | davidmj | $update_message = ($mode != 'edit' || $message_md5 != $post_data['post_checksum'] || $status_switch || strlen($post_data['bbcode_uid']) < BBCODE_UID_LEN) ? true : false; |
| 773 | 8350 | acydburn | |
| 774 | 9955 | acydburn | // Also check if subject got updated...
|
| 775 | 9955 | acydburn | $update_subject = $mode != 'edit' || ($post_data['post_subject_md5'] && $post_data['post_subject_md5'] != md5($post_data['post_subject'])); |
| 776 | 9955 | acydburn | |
| 777 | 4938 | acydburn | // Parse message
|
| 778 | 4938 | acydburn | if ($update_message) |
| 779 | 2923 | psotfx | {
|
| 780 | 6414 | acydburn | if (sizeof($message_parser->warn_msg)) |
| 781 | 6414 | acydburn | {
|
| 782 | 6414 | acydburn | $error[] = implode('<br />', $message_parser->warn_msg); |
| 783 | 6414 | acydburn | $message_parser->warn_msg = array(); |
| 784 | 6414 | acydburn | } |
| 785 | 6414 | acydburn | |
| 786 | 6364 | acydburn | $message_parser->parse($post_data['enable_bbcode'], ($config['allow_post_links']) ? $post_data['enable_urls'] : false, $post_data['enable_smilies'], $img_status, $flash_status, $quote_status, $config['allow_post_links']); |
| 787 | 6414 | acydburn | |
| 788 | 6414 | acydburn | // On a refresh we do not care about message parsing errors
|
| 789 | 6414 | acydburn | if (sizeof($message_parser->warn_msg) && $refresh) |
| 790 | 6414 | acydburn | {
|
| 791 | 6414 | acydburn | $message_parser->warn_msg = array(); |
| 792 | 6414 | acydburn | } |
| 793 | 2972 | psotfx | } |
| 794 | 4938 | acydburn | else
|
| 795 | 4938 | acydburn | {
|
| 796 | 5902 | acydburn | $message_parser->bbcode_bitfield = $post_data['bbcode_bitfield']; |
| 797 | 4938 | acydburn | } |
| 798 | 2183 | psotfx | |
| 799 | 4696 | ludovic_arnaud | if ($mode != 'edit' && !$preview && !$refresh && $config['flood_interval'] && !$auth->acl_get('f_ignoreflood', $forum_id)) |
| 800 | 3697 | acydburn | {
|
| 801 | 2972 | psotfx | // Flood check
|
| 802 | 4699 | acydburn | $last_post_time = 0; |
| 803 | 4699 | acydburn | |
| 804 | 5117 | acydburn | if ($user->data['is_registered']) |
| 805 | 4575 | acydburn | {
|
| 806 | 4699 | acydburn | $last_post_time = $user->data['user_lastpost_time']; |
| 807 | 4575 | acydburn | } |
| 808 | 4575 | acydburn | else
|
| 809 | 4575 | acydburn | {
|
| 810 | 4696 | ludovic_arnaud | $sql = 'SELECT post_time AS last_post_time |
| 811 | 4696 | ludovic_arnaud | FROM ' . POSTS_TABLE . " |
| 812 | 4696 | ludovic_arnaud | WHERE poster_ip = '" . $user->ip . "' |
| 813 | 4696 | ludovic_arnaud | AND post_time > " . ($current_time - $config['flood_interval']); |
| 814 | 4699 | acydburn | $result = $db->sql_query_limit($sql, 1); |
| 815 | 4699 | acydburn | if ($row = $db->sql_fetchrow($result)) |
| 816 | 4699 | acydburn | {
|
| 817 | 4699 | acydburn | $last_post_time = $row['last_post_time']; |
| 818 | 4699 | acydburn | } |
| 819 | 4883 | acydburn | $db->sql_freeresult($result); |
| 820 | 4575 | acydburn | } |
| 821 | 2183 | psotfx | |
| 822 | 5902 | acydburn | if ($last_post_time && ($current_time - $last_post_time) < intval($config['flood_interval'])) |
| 823 | 2972 | psotfx | {
|
| 824 | 5902 | acydburn | $error[] = $user->lang['FLOOD_ERROR']; |
| 825 | 2972 | psotfx | } |
| 826 | 2972 | psotfx | } |
| 827 | 2183 | psotfx | |
| 828 | 2972 | psotfx | // Validate username
|
| 829 | 7823 | kellanved | if (($post_data['username'] && !$user->data['is_registered']) || ($mode == 'edit' && $post_data['poster_id'] == ANONYMOUS && $post_data['username'] && $post_data['post_username'] && $post_data['post_username'] != $post_data['username'])) |
| 830 | 2972 | psotfx | {
|
| 831 | 3926 | acydburn | include($phpbb_root_path . 'includes/functions_user.' . $phpEx); |
| 832 | 4970 | psotfx | |
| 833 | 10889 | git-gate | $user->add_lang('ucp'); |
| 834 | 10889 | git-gate | |
| 835 | 7138 | acydburn | if (($result = validate_username($post_data['username'], (!empty($post_data['post_username'])) ? $post_data['post_username'] : '')) !== false) |
| 836 | 2972 | psotfx | {
|
| 837 | 6447 | acydburn | $error[] = $user->lang[$result . '_USERNAME']; |
| 838 | 2972 | psotfx | } |
| 839 | 10889 | git-gate | |
| 840 | 10889 | git-gate | if (($result = validate_string($post_data['username'], false, $config['min_name_chars'], $config['max_name_chars'])) !== false) |
| 841 | 10889 | git-gate | {
|
| 842 | 10889 | git-gate | $min_max_amount = ($result == 'TOO_SHORT') ? $config['min_name_chars'] : $config['max_name_chars']; |
| 843 | 11603 | git-gate | $error[] = $user->lang('FIELD_' . $result, $min_max_amount, $user->lang['USERNAME']); |
| 844 | 10889 | git-gate | } |
| 845 | 2923 | psotfx | } |
| 846 | 2183 | psotfx | |
| 847 | 5902 | acydburn | if ($config['enable_post_confirm'] && !$user->data['is_registered'] && in_array($mode, array('quote', 'post', 'reply'))) |
| 848 | 5739 | davidmj | {
|
| 849 | 9702 | Kellanved | $captcha_data = array( |
| 850 | 9702 | Kellanved | 'message' => utf8_normalize_nfc(request_var('message', '', true)), |
| 851 | 9702 | Kellanved | 'subject' => utf8_normalize_nfc(request_var('subject', '', true)), |
| 852 | 9702 | Kellanved | 'username' => utf8_normalize_nfc(request_var('username', '', true)), |
| 853 | 9702 | Kellanved | ); |
| 854 | 9702 | Kellanved | $vc_response = $captcha->validate($captcha_data); |
| 855 | 9524 | Kellanved | if ($vc_response) |
| 856 | 5739 | davidmj | {
|
| 857 | 9524 | Kellanved | $error[] = $vc_response; |
| 858 | 5739 | davidmj | } |
| 859 | 5739 | davidmj | } |
| 860 | 5739 | davidmj | |
| 861 | 8120 | kellanved | // check form
|
| 862 | 8265 | kellanved | if (($submit || $preview) && !check_form_key('posting')) |
| 863 | 8120 | kellanved | {
|
| 864 | 8120 | kellanved | $error[] = $user->lang['FORM_INVALID']; |
| 865 | 8120 | kellanved | } |
| 866 | 8120 | kellanved | |
| 867 | 2972 | psotfx | // Parse subject
|
| 868 | 8306 | acydburn | if (!$preview && !$refresh && utf8_clean_string($post_data['post_subject']) === '' && ($mode == 'post' || ($mode == 'edit' && $post_data['topic_first_post_id'] == $post_id))) |
| 869 | 2972 | psotfx | {
|
| 870 | 4167 | psotfx | $error[] = $user->lang['EMPTY_SUBJECT']; |
| 871 | 2972 | psotfx | } |
| 872 | 4970 | psotfx | |
| 873 | 5902 | acydburn | $post_data['poll_last_vote'] = (isset($post_data['poll_last_vote'])) ? $post_data['poll_last_vote'] : 0; |
| 874 | 3631 | acydburn | |
| 875 | 8146 | acydburn | if ($post_data['poll_option_text'] && |
| 876 | 7766 | acydburn | ($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id']/* && (!$post_data['poll_last_vote'] || $auth->acl_get('m_edit', $forum_id))*/)) |
| 877 | 4981 | acydburn | && $auth->acl_get('f_poll', $forum_id)) |
| 878 | 4981 | acydburn | {
|
| 879 | 4981 | acydburn | $poll = array( |
| 880 | 5902 | acydburn | 'poll_title' => $post_data['poll_title'], |
| 881 | 5902 | acydburn | 'poll_length' => $post_data['poll_length'], |
| 882 | 5902 | acydburn | 'poll_max_options' => $post_data['poll_max_options'], |
| 883 | 5902 | acydburn | 'poll_option_text' => $post_data['poll_option_text'], |
| 884 | 5902 | acydburn | 'poll_start' => $post_data['poll_start'], |
| 885 | 5902 | acydburn | 'poll_last_vote' => $post_data['poll_last_vote'], |
| 886 | 5902 | acydburn | 'poll_vote_change' => $post_data['poll_vote_change'], |
| 887 | 5902 | acydburn | 'enable_bbcode' => $post_data['enable_bbcode'], |
| 888 | 5902 | acydburn | 'enable_urls' => $post_data['enable_urls'], |
| 889 | 5902 | acydburn | 'enable_smilies' => $post_data['enable_smilies'], |
| 890 | 4981 | acydburn | 'img_status' => $img_status |
| 891 | 4981 | acydburn | ); |
| 892 | 2183 | psotfx | |
| 893 | 4981 | acydburn | $message_parser->parse_poll($poll); |
| 894 | 6015 | acydburn | |
| 895 | 11605 | git-gate | $post_data['poll_options'] = (isset($poll['poll_options'])) ? $poll['poll_options'] : array(); |
| 896 | 5902 | acydburn | $post_data['poll_title'] = (isset($poll['poll_title'])) ? $poll['poll_title'] : ''; |
| 897 | 3631 | acydburn | |
| 898 | 7267 | acydburn | /* We reset votes, therefore also allow removing options
|
| 899 | 5902 | acydburn | if ($post_data['poll_last_vote'] && ($poll['poll_options_size'] < $orig_poll_options_size)) |
| 900 | 4981 | acydburn | {
|
| 901 | 4981 | acydburn | $message_parser->warn_msg[] = $user->lang['NO_DELETE_POLL_OPTIONS']; |
| 902 | 7267 | acydburn | }*/ |
| 903 | 4981 | acydburn | } |
| 904 | 11555 | git-gate | else if ($mode == 'edit' && $post_id == $post_data['topic_first_post_id'] && $auth->acl_get('f_poll', $forum_id)) |
| 905 | 11555 | git-gate | {
|
| 906 | 11555 | git-gate | // The user removed all poll options, this is equal to deleting the poll.
|
| 907 | 11555 | git-gate | $poll = array( |
| 908 | 11555 | git-gate | 'poll_title' => '', |
| 909 | 11555 | git-gate | 'poll_length' => 0, |
| 910 | 11555 | git-gate | 'poll_max_options' => 0, |
| 911 | 11555 | git-gate | 'poll_option_text' => '', |
| 912 | 11555 | git-gate | 'poll_start' => 0, |
| 913 | 11555 | git-gate | 'poll_last_vote' => 0, |
| 914 | 11555 | git-gate | 'poll_vote_change' => 0, |
| 915 | 11555 | git-gate | 'poll_options' => array(), |
| 916 | 11555 | git-gate | ); |
| 917 | 11555 | git-gate | |
| 918 | 11605 | git-gate | $post_data['poll_options'] = array(); |
| 919 | 11605 | git-gate | $post_data['poll_title'] = ''; |
| 920 | 11555 | git-gate | $post_data['poll_start'] = $post_data['poll_length'] = $post_data['poll_max_options'] = $post_data['poll_last_vote'] = $post_data['poll_vote_change'] = 0; |
| 921 | 11555 | git-gate | } |
| 922 | 10754 | git-gate | else if (!$auth->acl_get('f_poll', $forum_id) && ($mode == 'edit') && ($post_id == $post_data['topic_first_post_id']) && ($original_poll_data['poll_title'] != '')) |
| 923 | 10754 | git-gate | {
|
| 924 | 10754 | git-gate | // We have a poll but the editing user is not permitted to create/edit it.
|
| 925 | 10754 | git-gate | // So we just keep the original poll-data.
|
| 926 | 10754 | git-gate | $poll = array_merge($original_poll_data, array( |
| 927 | 10754 | git-gate | 'enable_bbcode' => $post_data['enable_bbcode'], |
| 928 | 10754 | git-gate | 'enable_urls' => $post_data['enable_urls'], |
| 929 | 10754 | git-gate | 'enable_smilies' => $post_data['enable_smilies'], |
| 930 | 10754 | git-gate | 'img_status' => $img_status, |
| 931 | 10754 | git-gate | )); |
| 932 | 10754 | git-gate | |
| 933 | 10754 | git-gate | $message_parser->parse_poll($poll); |
| 934 | 10754 | git-gate | |
| 935 | 11605 | git-gate | $post_data['poll_options'] = (isset($poll['poll_options'])) ? $poll['poll_options'] : array(); |
| 936 | 10754 | git-gate | $post_data['poll_title'] = (isset($poll['poll_title'])) ? $poll['poll_title'] : ''; |
| 937 | 10754 | git-gate | } |
| 938 | 4981 | acydburn | else
|
| 939 | 4981 | acydburn | {
|
| 940 | 4981 | acydburn | $poll = array(); |
| 941 | 4981 | acydburn | } |
| 942 | 4981 | acydburn | |
| 943 | 2983 | psotfx | // Check topic type
|
| 944 | 5902 | acydburn | if ($post_data['topic_type'] != POST_NORMAL && ($mode == 'post' || ($mode == 'edit' && $post_data['topic_first_post_id'] == $post_id))) |
| 945 | 2983 | psotfx | {
|
| 946 | 5902 | acydburn | switch ($post_data['topic_type']) |
| 947 | 2983 | psotfx | {
|
| 948 | 3980 | psotfx | case POST_GLOBAL: |
| 949 | 3553 | acydburn | case POST_ANNOUNCE: |
| 950 | 4167 | psotfx | $auth_option = 'f_announce'; |
| 951 | 5486 | acydburn | break;
|
| 952 | 5486 | acydburn | |
| 953 | 3553 | acydburn | case POST_STICKY: |
| 954 | 4167 | psotfx | $auth_option = 'f_sticky'; |
| 955 | 5486 | acydburn | break;
|
| 956 | 6015 | acydburn | |
| 957 | 4167 | psotfx | default:
|
| 958 | 4167 | psotfx | $auth_option = ''; |
| 959 | 5902 | acydburn | break;
|
| 960 | 2983 | psotfx | } |
| 961 | 2983 | psotfx | |
| 962 | 4167 | psotfx | if (!$auth->acl_get($auth_option, $forum_id)) |
| 963 | 2983 | psotfx | {
|
| 964 | 7241 | acydburn | // There is a special case where a user edits his post whereby the topic type got changed by an admin/mod.
|
| 965 | 7241 | acydburn | // Another case would be a mod not having sticky permissions for example but edit permissions.
|
| 966 | 7241 | acydburn | if ($mode == 'edit') |
| 967 | 6894 | acydburn | {
|
| 968 | 6894 | acydburn | // To prevent non-authed users messing around with the topic type we reset it to the original one.
|
| 969 | 6894 | acydburn | $post_data['topic_type'] = $post_data['orig_topic_type']; |
| 970 | 6894 | acydburn | } |
| 971 | 6894 | acydburn | else
|
| 972 | 6894 | acydburn | {
|
| 973 | 6894 | acydburn | $error[] = $user->lang['CANNOT_POST_' . str_replace('F_', '', strtoupper($auth_option))]; |
| 974 | 6894 | acydburn | } |
| 975 | 2983 | psotfx | } |
| 976 | 2983 | psotfx | } |
| 977 | 2983 | psotfx | |
| 978 | 6414 | acydburn | if (sizeof($message_parser->warn_msg)) |
| 979 | 4184 | acydburn | {
|
| 980 | 4184 | acydburn | $error[] = implode('<br />', $message_parser->warn_msg); |
| 981 | 4184 | acydburn | } |
| 982 | 4184 | acydburn | |
| 983 | 6414 | acydburn | // DNSBL check
|
| 984 | 6414 | acydburn | if ($config['check_dnsbl'] && !$refresh) |
| 985 | 6414 | acydburn | {
|
| 986 | 6698 | acydburn | if (($dnsbl = $user->check_dnsbl('post')) !== false) |
| 987 | 6414 | acydburn | {
|
| 988 | 6414 | acydburn | $error[] = sprintf($user->lang['IP_BLACKLISTED'], $user->ip, $dnsbl[1]); |
| 989 | 6414 | acydburn | } |
| 990 | 6414 | acydburn | } |
| 991 | 6414 | acydburn | |
| 992 | 2981 | psotfx | // Store message, sync counters
|
| 993 | 4167 | psotfx | if (!sizeof($error) && $submit) |
| 994 | 2972 | psotfx | {
|
| 995 | 4460 | acydburn | if ($submit) |
| 996 | 3817 | acydburn | {
|
| 997 | 4460 | acydburn | // Lock/Unlock Topic
|
| 998 | 5902 | acydburn | $change_topic_status = $post_data['topic_status']; |
| 999 | 6317 | acydburn | $perm_lock_unlock = ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && !empty($post_data['topic_poster']) && $user->data['user_id'] == $post_data['topic_poster'] && $post_data['topic_status'] == ITEM_UNLOCKED)) ? true : false; |
| 1000 | 3817 | acydburn | |
| 1001 | 5902 | acydburn | if ($post_data['topic_status'] == ITEM_LOCKED && !$topic_lock && $perm_lock_unlock) |
| 1002 | 4460 | acydburn | {
|
| 1003 | 4460 | acydburn | $change_topic_status = ITEM_UNLOCKED; |
| 1004 | 4460 | acydburn | } |
| 1005 | 5902 | acydburn | else if ($post_data['topic_status'] == ITEM_UNLOCKED && $topic_lock && $perm_lock_unlock) |
| 1006 | 4460 | acydburn | {
|
| 1007 | 4460 | acydburn | $change_topic_status = ITEM_LOCKED; |
| 1008 | 4460 | acydburn | } |
| 1009 | 4970 | psotfx | |
| 1010 | 5902 | acydburn | if ($change_topic_status != $post_data['topic_status']) |
| 1011 | 4460 | acydburn | {
|
| 1012 | 4460 | acydburn | $sql = 'UPDATE ' . TOPICS_TABLE . " |
| 1013 | 4460 | acydburn | SET topic_status = $change_topic_status |
| 1014 | 4460 | acydburn | WHERE topic_id = $topic_id |
| 1015 | 4460 | acydburn | AND topic_moved_id = 0";
|
| 1016 | 4460 | acydburn | $db->sql_query($sql); |
| 1017 | 4970 | psotfx | |
| 1018 | 5902 | acydburn | $user_lock = ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $post_data['topic_poster']) ? 'USER_' : ''; |
| 1019 | 4767 | acydburn | |
| 1020 | 5902 | acydburn | add_log('mod', $forum_id, $topic_id, 'LOG_' . $user_lock . (($change_topic_status == ITEM_LOCKED) ? 'LOCK' : 'UNLOCK'), $post_data['topic_title']); |
| 1021 | 4460 | acydburn | } |
| 1022 | 4460 | acydburn | |
| 1023 | 4460 | acydburn | // Lock/Unlock Post Edit
|
| 1024 | 5902 | acydburn | if ($mode == 'edit' && $post_data['post_edit_locked'] == ITEM_LOCKED && !$post_lock && $auth->acl_get('m_edit', $forum_id)) |
| 1025 | 4460 | acydburn | {
|
| 1026 | 5902 | acydburn | $post_data['post_edit_locked'] = ITEM_UNLOCKED; |
| 1027 | 4460 | acydburn | } |
| 1028 | 5902 | acydburn | else if ($mode == 'edit' && $post_data['post_edit_locked'] == ITEM_UNLOCKED && $post_lock && $auth->acl_get('m_edit', $forum_id)) |
| 1029 | 4460 | acydburn | {
|
| 1030 | 5902 | acydburn | $post_data['post_edit_locked'] = ITEM_LOCKED; |
| 1031 | 4460 | acydburn | } |
| 1032 | 4460 | acydburn | |
| 1033 | 5902 | acydburn | $data = array( |
| 1034 | 5922 | acydburn | 'topic_title' => (empty($post_data['topic_title'])) ? $post_data['post_subject'] : $post_data['topic_title'], |
| 1035 | 5902 | acydburn | 'topic_first_post_id' => (isset($post_data['topic_first_post_id'])) ? (int) $post_data['topic_first_post_id'] : 0, |
| 1036 | 5902 | acydburn | 'topic_last_post_id' => (isset($post_data['topic_last_post_id'])) ? (int) $post_data['topic_last_post_id'] : 0, |
| 1037 | 5902 | acydburn | 'topic_time_limit' => (int) $post_data['topic_time_limit'], |
| 1038 | 7114 | acydburn | 'topic_attachment' => (isset($post_data['topic_attachment'])) ? (int) $post_data['topic_attachment'] : 0, |
| 1039 | 4545 | acydburn | 'post_id' => (int) $post_id, |
| 1040 | 4545 | acydburn | 'topic_id' => (int) $topic_id, |
| 1041 | 4545 | acydburn | 'forum_id' => (int) $forum_id, |
| 1042 | 5902 | acydburn | 'icon_id' => (int) $post_data['icon_id'], |
| 1043 | 5902 | acydburn | 'poster_id' => (int) $post_data['poster_id'], |
| 1044 | 5902 | acydburn | 'enable_sig' => (bool) $post_data['enable_sig'], |
| 1045 | 5902 | acydburn | 'enable_bbcode' => (bool) $post_data['enable_bbcode'], |
| 1046 | 5902 | acydburn | 'enable_smilies' => (bool) $post_data['enable_smilies'], |
| 1047 | 5902 | acydburn | 'enable_urls' => (bool) $post_data['enable_urls'], |
| 1048 | 5902 | acydburn | 'enable_indexing' => (bool) $post_data['enable_indexing'], |
| 1049 | 4890 | acydburn | 'message_md5' => (string) $message_md5, |
| 1050 | 5902 | acydburn | 'post_time' => (isset($post_data['post_time'])) ? (int) $post_data['post_time'] : $current_time, |
| 1051 | 5902 | acydburn | 'post_checksum' => (isset($post_data['post_checksum'])) ? (string) $post_data['post_checksum'] : '', |
| 1052 | 5902 | acydburn | 'post_edit_reason' => $post_data['post_edit_reason'], |
| 1053 | 5902 | acydburn | 'post_edit_user' => ($mode == 'edit') ? $user->data['user_id'] : ((isset($post_data['post_edit_user'])) ? (int) $post_data['post_edit_user'] : 0), |
| 1054 | 5902 | acydburn | 'forum_parents' => $post_data['forum_parents'], |
| 1055 | 5902 | acydburn | 'forum_name' => $post_data['forum_name'], |
| 1056 | 4460 | acydburn | 'notify' => $notify, |
| 1057 | 5902 | acydburn | 'notify_set' => $post_data['notify_set'], |
| 1058 | 5902 | acydburn | 'poster_ip' => (isset($post_data['poster_ip'])) ? $post_data['poster_ip'] : $user->ip, |
| 1059 | 5902 | acydburn | 'post_edit_locked' => (int) $post_data['post_edit_locked'], |
| 1060 | 6209 | davidmj | 'bbcode_bitfield' => $message_parser->bbcode_bitfield, |
| 1061 | 4978 | acydburn | 'bbcode_uid' => $message_parser->bbcode_uid, |
| 1062 | 4978 | acydburn | 'message' => $message_parser->message, |
| 1063 | 4978 | acydburn | 'attachment_data' => $message_parser->attachment_data, |
| 1064 | 7519 | acydburn | 'filename_data' => $message_parser->filename_data, |
| 1065 | 7519 | acydburn | |
| 1066 | 7519 | acydburn | 'topic_approved' => (isset($post_data['topic_approved'])) ? $post_data['topic_approved'] : false, |
| 1067 | 7519 | acydburn | 'post_approved' => (isset($post_data['post_approved'])) ? $post_data['post_approved'] : false, |
| 1068 | 4460 | acydburn | ); |
| 1069 | 7537 | davidmj | |
| 1070 | 7537 | davidmj | if ($mode == 'edit') |
| 1071 | 7537 | davidmj | {
|
| 1072 | 7537 | davidmj | $data['topic_replies_real'] = $post_data['topic_replies_real']; |
| 1073 | 7831 | davidmj | $data['topic_replies'] = $post_data['topic_replies']; |
| 1074 | 7537 | davidmj | } |
| 1075 | 7537 | davidmj | |
| 1076 | 9959 | acydburn | // The last parameter tells submit_post if search indexer has to be run
|
| 1077 | 9959 | acydburn | $redirect_url = submit_post($mode, $post_data['post_subject'], $post_data['username'], $post_data['topic_type'], $poll, $data, $update_message, ($update_message || $update_subject) ? true : false); |
| 1078 | 9554 | acydburn | |
| 1079 | 9999 | Kellanved | if ($config['enable_post_confirm'] && !$user->data['is_registered'] && (isset($captcha) && $captcha->is_solved() === true) && ($mode == 'post' || $mode == 'reply' || $mode == 'quote')) |
| 1080 | 9999 | Kellanved | {
|
| 1081 | 9999 | Kellanved | $captcha->reset(); |
| 1082 | 9999 | Kellanved | } |
| 1083 | 10166 | acydburn | |
| 1084 | 9636 | acydburn | // Check the permissions for post approval. Moderators are not affected.
|
| 1085 | 10558 | git-gate | if ((!$auth->acl_get('f_noapprove', $data['forum_id']) && !$auth->acl_get('m_approve', $data['forum_id']) && empty($data['force_approved_state'])) || (isset($data['force_approved_state']) && !$data['force_approved_state'])) |
| 1086 | 7749 | acydburn | {
|
| 1087 | 7749 | acydburn | meta_refresh(10, $redirect_url); |
| 1088 | 7749 | acydburn | $message = ($mode == 'edit') ? $user->lang['POST_EDITED_MOD'] : $user->lang['POST_STORED_MOD']; |
| 1089 | 7887 | kellanved | $message .= (($user->data['user_id'] == ANONYMOUS) ? '' : ' '. $user->lang['POST_APPROVAL_NOTIFY']); |
| 1090 | 7749 | acydburn | } |
| 1091 | 7749 | acydburn | else
|
| 1092 | 7749 | acydburn | {
|
| 1093 | 7749 | acydburn | meta_refresh(3, $redirect_url); |
| 1094 | 5902 | acydburn | |
| 1095 | 7749 | acydburn | $message = ($mode == 'edit') ? 'POST_EDITED' : 'POST_STORED'; |
| 1096 | 7749 | acydburn | $message = $user->lang[$message] . '<br /><br />' . sprintf($user->lang['VIEW_MESSAGE'], '<a href="' . $redirect_url . '">', '</a>'); |
| 1097 | 7749 | acydburn | } |
| 1098 | 7749 | acydburn | |
| 1099 | 6015 | acydburn | $message .= '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $data['forum_id']) . '">', '</a>'); |
| 1100 | 5902 | acydburn | trigger_error($message); |
| 1101 | 4460 | acydburn | } |
| 1102 | 4970 | psotfx | } |
| 1103 | 3572 | acydburn | } |
| 1104 | 2983 | psotfx | |
| 1105 | 4139 | acydburn | // Preview
|
| 1106 | 4167 | psotfx | if (!sizeof($error) && $preview) |
| 1107 | 3553 | acydburn | {
|
| 1108 | 5902 | acydburn | $post_data['post_time'] = ($mode == 'edit') ? $post_data['post_time'] : $current_time; |
| 1109 | 3812 | ludovic_arnaud | |
| 1110 | 5902 | acydburn | $preview_message = $message_parser->format_display($post_data['enable_bbcode'], $post_data['enable_urls'], $post_data['enable_smilies'], false); |
| 1111 | 4167 | psotfx | |
| 1112 | 5902 | acydburn | $preview_signature = ($mode == 'edit') ? $post_data['user_sig'] : $user->data['user_sig']; |
| 1113 | 5902 | acydburn | $preview_signature_uid = ($mode == 'edit') ? $post_data['user_sig_bbcode_uid'] : $user->data['user_sig_bbcode_uid']; |
| 1114 | 5902 | acydburn | $preview_signature_bitfield = ($mode == 'edit') ? $post_data['user_sig_bbcode_bitfield'] : $user->data['user_sig_bbcode_bitfield']; |
| 1115 | 4170 | psotfx | |
| 1116 | 4978 | acydburn | // Signature
|
| 1117 | 5902 | acydburn | if ($post_data['enable_sig'] && $config['allow_sig'] && $preview_signature && $auth->acl_get('f_sigs', $forum_id)) |
| 1118 | 4978 | acydburn | {
|
| 1119 | 4978 | acydburn | $parse_sig = new parse_message($preview_signature); |
| 1120 | 4978 | acydburn | $parse_sig->bbcode_uid = $preview_signature_uid; |
| 1121 | 4978 | acydburn | $parse_sig->bbcode_bitfield = $preview_signature_bitfield; |
| 1122 | 3812 | ludovic_arnaud | |
| 1123 | 4978 | acydburn | // Not sure about parameters for bbcode/smilies/urls... in signatures
|
| 1124 | 10558 | git-gate | $parse_sig->format_display($config['allow_sig_bbcode'], $config['allow_sig_links'], $config['allow_sig_smilies']); |
| 1125 | 4978 | acydburn | $preview_signature = $parse_sig->message; |
| 1126 | 4978 | acydburn | unset($parse_sig); |
| 1127 | 4978 | acydburn | } |
| 1128 | 4978 | acydburn | else
|
| 1129 | 4978 | acydburn | {
|
| 1130 | 4978 | acydburn | $preview_signature = ''; |
| 1131 | 4978 | acydburn | } |
| 1132 | 6015 | acydburn | |
| 1133 | 5922 | acydburn | $preview_subject = censor_text($post_data['post_subject']); |
| 1134 | 6015 | acydburn | |
| 1135 | 3631 | acydburn | // Poll Preview
|
| 1136 | 7766 | acydburn | if (!$poll_delete && ($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id']/* && (!$post_data['poll_last_vote'] || $auth->acl_get('m_edit', $forum_id))*/)) |
| 1137 | 4981 | acydburn | && $auth->acl_get('f_poll', $forum_id)) |
| 1138 | 3572 | acydburn | {
|
| 1139 | 5902 | acydburn | $parse_poll = new parse_message($post_data['poll_title']); |
| 1140 | 4981 | acydburn | $parse_poll->bbcode_uid = $message_parser->bbcode_uid; |
| 1141 | 4981 | acydburn | $parse_poll->bbcode_bitfield = $message_parser->bbcode_bitfield; |
| 1142 | 4981 | acydburn | |
| 1143 | 5902 | acydburn | $parse_poll->format_display($post_data['enable_bbcode'], $post_data['enable_urls'], $post_data['enable_smilies']); |
| 1144 | 6015 | acydburn | |
| 1145 | 7749 | acydburn | if ($post_data['poll_length']) |
| 1146 | 7749 | acydburn | {
|
| 1147 | 7749 | acydburn | $poll_end = ($post_data['poll_length'] * 86400) + (($post_data['poll_start']) ? $post_data['poll_start'] : time()); |
| 1148 | 7749 | acydburn | } |
| 1149 | 7749 | acydburn | |
| 1150 | 3631 | acydburn | $template->assign_vars(array( |
| 1151 | 6015 | acydburn | 'S_HAS_POLL_OPTIONS' => (sizeof($post_data['poll_options'])), |
| 1152 | 6015 | acydburn | 'S_IS_MULTI_CHOICE' => ($post_data['poll_max_options'] > 1) ? true : false, |
| 1153 | 4981 | acydburn | |
| 1154 | 4981 | acydburn | 'POLL_QUESTION' => $parse_poll->message, |
| 1155 | 8350 | acydburn | |
| 1156 | 7749 | acydburn | 'L_POLL_LENGTH' => ($post_data['poll_length']) ? sprintf($user->lang['POLL_RUN_TILL'], $user->format_date($poll_end)) : '', |
| 1157 | 11603 | git-gate | 'L_MAX_VOTES' => $user->lang('MAX_OPTIONS_SELECT', (int) $post_data['poll_max_options']), |
| 1158 | 11603 | git-gate | )); |
| 1159 | 3631 | acydburn | |
| 1160 | 5902 | acydburn | $parse_poll->message = implode("\n", $post_data['poll_options']); |
| 1161 | 5902 | acydburn | $parse_poll->format_display($post_data['enable_bbcode'], $post_data['enable_urls'], $post_data['enable_smilies']); |
| 1162 | 4981 | acydburn | $preview_poll_options = explode('<br />', $parse_poll->message); |
| 1163 | 4981 | acydburn | unset($parse_poll); |
| 1164 | 4981 | acydburn | |
| 1165 | 7917 | davidmj | foreach ($preview_poll_options as $key => $option) |
| 1166 | 3631 | acydburn | {
|
| 1167 | 6015 | acydburn | $template->assign_block_vars('poll_option', array( |
| 1168 | 7917 | davidmj | 'POLL_OPTION_CAPTION' => $option, |
| 1169 | 7917 | davidmj | 'POLL_OPTION_ID' => $key + 1) |
| 1170 | 6015 | acydburn | ); |
| 1171 | 3631 | acydburn | } |
| 1172 | 4981 | acydburn | unset($preview_poll_options); |
| 1173 | 3572 | acydburn | } |
| 1174 | 4139 | acydburn | |
| 1175 | 4139 | acydburn | // Attachment Preview
|
| 1176 | 4139 | acydburn | if (sizeof($message_parser->attachment_data)) |
| 1177 | 4139 | acydburn | {
|
| 1178 | 4767 | acydburn | $template->assign_var('S_HAS_ATTACHMENTS', true); |
| 1179 | 4984 | acydburn | |
| 1180 | 6803 | acydburn | $update_count = array(); |
| 1181 | 4984 | acydburn | $attachment_data = $message_parser->attachment_data; |
| 1182 | 4984 | acydburn | |
| 1183 | 6803 | acydburn | parse_attachments($forum_id, $preview_message, $attachment_data, $update_count, true); |
| 1184 | 4984 | acydburn | |
| 1185 | 4984 | acydburn | foreach ($attachment_data as $i => $attachment) |
| 1186 | 4984 | acydburn | {
|
| 1187 | 4984 | acydburn | $template->assign_block_vars('attachment', array( |
| 1188 | 4984 | acydburn | 'DISPLAY_ATTACHMENT' => $attachment) |
| 1189 | 4984 | acydburn | ); |
| 1190 | 4984 | acydburn | } |
| 1191 | 6803 | acydburn | unset($attachment_data); |
| 1192 | 4139 | acydburn | } |
| 1193 | 3553 | acydburn | |
| 1194 | 4978 | acydburn | if (!sizeof($error)) |
| 1195 | 4978 | acydburn | {
|
| 1196 | 4978 | acydburn | $template->assign_vars(array( |
| 1197 | 4978 | acydburn | 'PREVIEW_SUBJECT' => $preview_subject, |
| 1198 | 4978 | acydburn | 'PREVIEW_MESSAGE' => $preview_message, |
| 1199 | 4978 | acydburn | 'PREVIEW_SIGNATURE' => $preview_signature, |
| 1200 | 4167 | psotfx | |
| 1201 | 4978 | acydburn | 'S_DISPLAY_PREVIEW' => true) |
| 1202 | 4978 | acydburn | ); |
| 1203 | 4978 | acydburn | } |
| 1204 | 3858 | ludovic_arnaud | } |
| 1205 | 987 | psotfx | |
| 1206 | 4978 | acydburn | // Decode text for message display
|
| 1207 | 5902 | acydburn | $post_data['bbcode_uid'] = ($mode == 'quote' && !$preview && !$refresh && !sizeof($error)) ? $post_data['bbcode_uid'] : $message_parser->bbcode_uid; |
| 1208 | 5902 | acydburn | $message_parser->decode_message($post_data['bbcode_uid']); |
| 1209 | 3631 | acydburn | |
| 1210 | 6022 | acydburn | if ($mode == 'quote' && !$submit && !$preview && !$refresh) |
| 1211 | 3572 | acydburn | {
|
| 1212 | 9835 | Kellanved | if ($config['allow_bbcode']) |
| 1213 | 9835 | Kellanved | {
|
| 1214 | 9835 | Kellanved | $message_parser->message = '[quote="' . $post_data['quote_username'] . '"]' . censor_text(trim($message_parser->message)) . "[/quote]\n"; |
| 1215 | 9835 | Kellanved | } |
| 1216 | 9835 | Kellanved | else
|
| 1217 | 9835 | Kellanved | {
|
| 1218 | 9838 | Kellanved | $offset = 0; |
| 1219 | 9838 | Kellanved | $quote_string = "> "; |
| 1220 | 9838 | Kellanved | $message = censor_text(trim($message_parser->message)); |
| 1221 | 9838 | Kellanved | // see if we are nesting. It's easily tricked but should work for one level of nesting
|
| 1222 | 9838 | Kellanved | if (strpos($message, ">") !== false) |
| 1223 | 9838 | Kellanved | {
|
| 1224 | 9838 | Kellanved | $offset = 10; |
| 1225 | 9838 | Kellanved | } |
| 1226 | 9838 | Kellanved | $message = utf8_wordwrap($message, 75 + $offset, "\n"); |
| 1227 | 9838 | Kellanved | |
| 1228 | 9838 | Kellanved | $message = $quote_string . $message; |
| 1229 | 9838 | Kellanved | $message = str_replace("\n", "\n" . $quote_string, $message); |
| 1230 | 10637 | git-gate | $message_parser->message = $post_data['quote_username'] . " " . $user->lang['WROTE'] . ":\n" . $message . "\n"; |
| 1231 | 9835 | Kellanved | } |
| 1232 | 3572 | acydburn | } |
| 1233 | 3572 | acydburn | |
| 1234 | 6022 | acydburn | if (($mode == 'reply' || $mode == 'quote') && !$submit && !$preview && !$refresh) |
| 1235 | 3631 | acydburn | {
|
| 1236 | 7354 | shs | $post_data['post_subject'] = ((strpos($post_data['post_subject'], 'Re: ') !== 0) ? 'Re: ' : '') . censor_text($post_data['post_subject']); |
| 1237 | 3631 | acydburn | } |
| 1238 | 3631 | acydburn | |
| 1239 | 4978 | acydburn | $attachment_data = $message_parser->attachment_data; |
| 1240 | 4978 | acydburn | $filename_data = $message_parser->filename_data; |
| 1241 | 5902 | acydburn | $post_data['post_text'] = $message_parser->message; |
| 1242 | 4981 | acydburn | |
| 1243 | 10808 | git-gate | if (sizeof($post_data['poll_options']) || !empty($post_data['poll_title'])) |
| 1244 | 4981 | acydburn | {
|
| 1245 | 5902 | acydburn | $message_parser->message = $post_data['poll_title']; |
| 1246 | 5902 | acydburn | $message_parser->bbcode_uid = $post_data['bbcode_uid']; |
| 1247 | 4981 | acydburn | |
| 1248 | 4981 | acydburn | $message_parser->decode_message();
|
| 1249 | 5902 | acydburn | $post_data['poll_title'] = $message_parser->message; |
| 1250 | 4981 | acydburn | |
| 1251 | 5902 | acydburn | $message_parser->message = implode("\n", $post_data['poll_options']); |
| 1252 | 4981 | acydburn | $message_parser->decode_message();
|
| 1253 | 5902 | acydburn | $post_data['poll_options'] = explode("\n", $message_parser->message); |
| 1254 | 4981 | acydburn | } |
| 1255 | 4167 | psotfx | |
| 1256 | 2923 | psotfx | // MAIN POSTING PAGE BEGINS HERE
|
| 1257 | 470 | thefinn | |
| 1258 | 3014 | psotfx | // Forum moderators?
|
| 1259 | 5902 | acydburn | $moderators = array(); |
| 1260 | 9640 | acydburn | if ($config['load_moderators']) |
| 1261 | 9640 | acydburn | {
|
| 1262 | 9640 | acydburn | get_moderators($moderators, $forum_id); |
| 1263 | 9640 | acydburn | } |
| 1264 | 3014 | psotfx | |
| 1265 | 5108 | acydburn | // Generate smiley listing
|
| 1266 | 4544 | acydburn | generate_smilies('inline', $forum_id); |
| 1267 | 487 | psotfx | |
| 1268 | 4819 | acydburn | // Generate inline attachment select box
|
| 1269 | 4978 | acydburn | posting_gen_inline_attachments($attachment_data);
|
| 1270 | 4819 | acydburn | |
| 1271 | 4968 | acydburn | // Do show topic type selection only in first post.
|
| 1272 | 4968 | acydburn | $topic_type_toggle = false; |
| 1273 | 4919 | acydburn | |
| 1274 | 5902 | acydburn | if ($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id'])) |
| 1275 | 3553 | acydburn | {
|
| 1276 | 5902 | acydburn | $topic_type_toggle = posting_gen_topic_types($forum_id, $post_data['topic_type']); |
| 1277 | 4968 | acydburn | } |
| 1278 | 4919 | acydburn | |
| 1279 | 4968 | acydburn | $s_topic_icons = false; |
| 1280 | 7490 | davidmj | if ($post_data['enable_icons'] && $auth->acl_get('f_icons', $forum_id)) |
| 1281 | 4968 | acydburn | {
|
| 1282 | 5902 | acydburn | $s_topic_icons = posting_gen_topic_icons($mode, $post_data['icon_id']); |
| 1283 | 487 | psotfx | } |
| 1284 | 323 | thefinn | |
| 1285 | 5902 | acydburn | $bbcode_checked = (isset($post_data['enable_bbcode'])) ? !$post_data['enable_bbcode'] : (($config['allow_bbcode']) ? !$user->optionget('bbcode') : 1); |
| 1286 | 5902 | acydburn | $smilies_checked = (isset($post_data['enable_smilies'])) ? !$post_data['enable_smilies'] : (($config['allow_smilies']) ? !$user->optionget('smilies') : 1); |
| 1287 | 5902 | acydburn | $urls_checked = (isset($post_data['enable_urls'])) ? !$post_data['enable_urls'] : 0; |
| 1288 | 5902 | acydburn | $sig_checked = $post_data['enable_sig']; |
| 1289 | 8138 | acydburn | $lock_topic_checked = (isset($topic_lock) && $topic_lock) ? $topic_lock : (($post_data['topic_status'] == ITEM_LOCKED) ? 1 : 0); |
| 1290 | 5902 | acydburn | $lock_post_checked = (isset($post_lock)) ? $post_lock : $post_data['post_edit_locked']; |
| 1291 | 2983 | psotfx | |
| 1292 | 6527 | acydburn | // If the user is replying or posting and not already watching this topic but set to always being notified we need to overwrite this setting
|
| 1293 | 6527 | acydburn | $notify_set = ($mode != 'edit' && $config['allow_topic_notify'] && $user->data['is_registered'] && !$post_data['notify_set']) ? $user->data['user_notify'] : $post_data['notify_set']; |
| 1294 | 6527 | acydburn | $notify_checked = (isset($notify)) ? $notify : (($mode == 'post') ? $user->data['user_notify'] : $notify_set); |
| 1295 | 5902 | acydburn | |
| 1296 | 10975 | git-gate | // Page title & action URL
|
| 1297 | 10975 | git-gate | $s_action = append_sid("{$phpbb_root_path}posting.$phpEx", "mode=$mode&f=$forum_id"); |
| 1298 | 4139 | acydburn | $s_action .= ($topic_id) ? "&t=$topic_id" : ''; |
| 1299 | 4139 | acydburn | $s_action .= ($post_id) ? "&p=$post_id" : ''; |
| 1300 | 3575 | acydburn | |
| 1301 | 3354 | psotfx | switch ($mode) |
| 1302 | 836 | psotfx | {
|
| 1303 | 2972 | psotfx | case 'post': |
| 1304 | 3022 | psotfx | $page_title = $user->lang['POST_TOPIC']; |
| 1305 | 5486 | acydburn | break;
|
| 1306 | 824 | psotfx | |
| 1307 | 3553 | acydburn | case 'quote': |
| 1308 | 987 | psotfx | case 'reply': |
| 1309 | 3022 | psotfx | $page_title = $user->lang['POST_REPLY']; |
| 1310 | 5486 | acydburn | break;
|
| 1311 | 987 | psotfx | |
| 1312 | 3575 | acydburn | case 'delete': |
| 1313 | 2972 | psotfx | case 'edit': |
| 1314 | 3061 | psotfx | $page_title = $user->lang['EDIT_POST']; |
| 1315 | 5902 | acydburn | break;
|
| 1316 | 836 | psotfx | } |
| 1317 | 824 | psotfx | |
| 1318 | 4904 | acydburn | // Build Navigation Links
|
| 1319 | 5902 | acydburn | generate_forum_nav($post_data);
|
| 1320 | 3354 | psotfx | |
| 1321 | 4904 | acydburn | // Build Forum Rules
|
| 1322 | 5902 | acydburn | generate_forum_rules($post_data);
|
| 1323 | 4903 | acydburn | |
| 1324 | 9960 | Kellanved | // Posting uses is_solved for legacy reasons. Plugins have to use is_solved to force themselves to be displayed.
|
| 1325 | 9679 | Kellanved | if ($config['enable_post_confirm'] && !$user->data['is_registered'] && (isset($captcha) && $captcha->is_solved() === false) && ($mode == 'post' || $mode == 'reply' || $mode == 'quote')) |
| 1326 | 5739 | davidmj | {
|
| 1327 | 5739 | davidmj | |
| 1328 | 6601 | acydburn | $template->assign_vars(array( |
| 1329 | 6601 | acydburn | 'S_CONFIRM_CODE' => true, |
| 1330 | 9609 | Kellanved | 'CAPTCHA_TEMPLATE' => $captcha->get_template(), |
| 1331 | 6601 | acydburn | )); |
| 1332 | 5739 | davidmj | } |
| 1333 | 5739 | davidmj | |
| 1334 | 5902 | acydburn | $s_hidden_fields = ($mode == 'reply' || $mode == 'quote') ? '<input type="hidden" name="topic_cur_post_id" value="' . $post_data['topic_last_post_id'] . '" />' : ''; |
| 1335 | 4625 | acydburn | $s_hidden_fields .= '<input type="hidden" name="lastclick" value="' . $current_time . '" />'; |
| 1336 | 5902 | acydburn | $s_hidden_fields .= ($draft_id || isset($_REQUEST['draft_loaded'])) ? '<input type="hidden" name="draft_loaded" value="' . request_var('draft_loaded', $draft_id) . '" />' : ''; |
| 1337 | 3631 | acydburn | |
| 1338 | 9731 | bantu | if ($mode == 'edit') |
| 1339 | 9731 | bantu | {
|
| 1340 | 9731 | bantu | $s_hidden_fields .= build_hidden_fields(array( |
| 1341 | 9731 | bantu | 'edit_post_message_checksum' => $post_data['post_checksum'], |
| 1342 | 9731 | bantu | 'edit_post_subject_checksum' => $post_data['post_subject_md5'], |
| 1343 | 9731 | bantu | )); |
| 1344 | 9731 | bantu | } |
| 1345 | 9731 | bantu | |
| 1346 | 6601 | acydburn | // Add the confirm id/code pair to the hidden fields, else an error is displayed on next submit/preview
|
| 1347 | 9680 | Kellanved | if (isset($captcha) && $captcha->is_solved() !== false) |
| 1348 | 6601 | acydburn | {
|
| 1349 | 9524 | Kellanved | $s_hidden_fields .= build_hidden_fields($captcha->get_hidden_fields()); |
| 1350 | 6601 | acydburn | } |
| 1351 | 6601 | acydburn | |
| 1352 | 8883 | acydburn | $form_enctype = (@ini_get('file_uploads') == '0' || strtolower(@ini_get('file_uploads')) == 'off' || !$config['allow_attachments'] || !$auth->acl_get('u_attach') || !$auth->acl_get('f_attach', $forum_id)) ? '' : ' enctype="multipart/form-data"'; |
| 1353 | 8120 | kellanved | add_form_key('posting');
|
| 1354 | 3631 | acydburn | |
| 1355 | 8120 | kellanved | |
| 1356 | 2923 | psotfx | // Start assigning vars for main posting page ...
|
| 1357 | 2183 | psotfx | $template->assign_vars(array( |
| 1358 | 6015 | acydburn | 'L_POST_A' => $page_title, |
| 1359 | 6015 | acydburn | 'L_ICON' => ($mode == 'reply' || $mode == 'quote' || ($mode == 'edit' && $post_id != $post_data['topic_first_post_id'])) ? $user->lang['POST_ICON'] : $user->lang['TOPIC_ICON'], |
| 1360 | 11603 | git-gate | 'L_MESSAGE_BODY_EXPLAIN' => $user->lang('MESSAGE_BODY_EXPLAIN', (int) $config['max_post_chars']), |
| 1361 | 1609 | psotfx | |
| 1362 | 6015 | acydburn | 'FORUM_NAME' => $post_data['forum_name'], |
| 1363 | 6188 | davidmj | 'FORUM_DESC' => ($post_data['forum_desc']) ? generate_text_for_display($post_data['forum_desc'], $post_data['forum_desc_uid'], $post_data['forum_desc_bitfield'], $post_data['forum_desc_options']) : '', |
| 1364 | 6135 | acydburn | 'TOPIC_TITLE' => censor_text($post_data['topic_title']), |
| 1365 | 6015 | acydburn | 'MODERATORS' => (sizeof($moderators)) ? implode(', ', $moderators[$forum_id]) : '', |
| 1366 | 5902 | acydburn | 'USERNAME' => ((!$preview && $mode != 'quote') || $preview) ? $post_data['username'] : '', |
| 1367 | 5902 | acydburn | 'SUBJECT' => $post_data['post_subject'], |
| 1368 | 5902 | acydburn | 'MESSAGE' => $post_data['post_text'], |
| 1369 | 6364 | acydburn | 'BBCODE_STATUS' => ($bbcode_status) ? sprintf($user->lang['BBCODE_IS_ON'], '<a href="' . append_sid("{$phpbb_root_path}faq.$phpEx", 'mode=bbcode') . '">', '</a>') : sprintf($user->lang['BBCODE_IS_OFF'], '<a href="' . append_sid("{$phpbb_root_path}faq.$phpEx", 'mode=bbcode') . '">', '</a>'), |
| 1370 | 3572 | acydburn | 'IMG_STATUS' => ($img_status) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'], |
| 1371 | 3572 | acydburn | 'FLASH_STATUS' => ($flash_status) ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'], |
| 1372 | 3572 | acydburn | 'SMILIES_STATUS' => ($smilies_status) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'], |
| 1373 | 7241 | acydburn | 'URL_STATUS' => ($bbcode_status && $url_status) ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'], |
| 1374 | 9365 | toonarmy | 'MAX_FONT_SIZE' => (int) $config['max_post_font_size'], |
| 1375 | 6237 | acydburn | 'MINI_POST_IMG' => $user->img('icon_post_target', $user->lang['POST']), |
| 1376 | 5902 | acydburn | 'POST_DATE' => ($post_data['post_time']) ? $user->format_date($post_data['post_time']) : '', |
| 1377 | 4970 | psotfx | 'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '', |
| 1378 | 5902 | acydburn | 'TOPIC_TIME_LIMIT' => (int) $post_data['topic_time_limit'], |
| 1379 | 5902 | acydburn | 'EDIT_REASON' => $post_data['post_edit_reason'], |
| 1380 | 6015 | acydburn | 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id"), |
| 1381 | 6601 | acydburn | 'U_VIEW_TOPIC' => ($mode != 'post') ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id") : '', |
| 1382 | 6015 | acydburn | 'U_PROGRESS_BAR' => append_sid("{$phpbb_root_path}posting.$phpEx", "f=$forum_id&mode=popup"), |
| 1383 | 8099 | acydburn | 'UA_PROGRESS_BAR' => addslashes(append_sid("{$phpbb_root_path}posting.$phpEx", "f=$forum_id&mode=popup")), |
| 1384 | 1609 | psotfx | |
| 1385 | 5858 | acydburn | 'S_PRIVMSGS' => false, |
| 1386 | 5858 | acydburn | 'S_CLOSE_PROGRESS_WINDOW' => (isset($_POST['add_file'])) ? true : false, |
| 1387 | 5858 | acydburn | 'S_EDIT_POST' => ($mode == 'edit') ? true : false, |
| 1388 | 5858 | acydburn | 'S_EDIT_REASON' => ($mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? true : false, |
| 1389 | 7138 | acydburn | 'S_DISPLAY_USERNAME' => (!$user->data['is_registered'] || ($mode == 'edit' && $post_data['poster_id'] == ANONYMOUS)) ? true : false, |
| 1390 | 5902 | acydburn | 'S_SHOW_TOPIC_ICONS' => $s_topic_icons, |
| 1391 | 10080 | nickvergessen | 'S_DELETE_ALLOWED' => ($mode == 'edit' && (($post_id == $post_data['topic_last_post_id'] && $post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id) && !$post_data['post_edit_locked'] && ($post_data['post_time'] > time() - ($config['delete_time'] * 60) || !$config['delete_time'])) || $auth->acl_get('m_delete', $forum_id))) ? true : false, |
| 1392 | 10637 | git-gate | 'S_BBCODE_ALLOWED' => ($bbcode_status) ? 1 : 0, |
| 1393 | 6015 | acydburn | 'S_BBCODE_CHECKED' => ($bbcode_checked) ? ' checked="checked"' : '', |
| 1394 | 5902 | acydburn | 'S_SMILIES_ALLOWED' => $smilies_status, |
| 1395 | 5902 | acydburn | 'S_SMILIES_CHECKED' => ($smilies_checked) ? ' checked="checked"' : '', |
| 1396 | 5902 | acydburn | 'S_SIG_ALLOWED' => ($auth->acl_get('f_sigs', $forum_id) && $config['allow_sig'] && $user->data['is_registered']) ? true : false, |
| 1397 | 5902 | acydburn | 'S_SIGNATURE_CHECKED' => ($sig_checked) ? ' checked="checked"' : '', |
| 1398 | 7732 | kellanved | 'S_NOTIFY_ALLOWED' => (!$user->data['is_registered'] || ($mode == 'edit' && $user->data['user_id'] != $post_data['poster_id']) || !$config['allow_topic_notify'] || !$config['email_enable']) ? false : true, |
| 1399 | 6015 | acydburn | 'S_NOTIFY_CHECKED' => ($notify_checked) ? ' checked="checked"' : '', |
| 1400 | 6317 | acydburn | 'S_LOCK_TOPIC_ALLOWED' => (($mode == 'edit' || $mode == 'reply' || $mode == 'quote') && ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && !empty($post_data['topic_poster']) && $user->data['user_id'] == $post_data['topic_poster'] && $post_data['topic_status'] == ITEM_UNLOCKED))) ? true : false, |
| 1401 | 5902 | acydburn | 'S_LOCK_TOPIC_CHECKED' => ($lock_topic_checked) ? ' checked="checked"' : '', |
| 1402 | 5902 | acydburn | 'S_LOCK_POST_ALLOWED' => ($mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? true : false, |
| 1403 | 5902 | acydburn | 'S_LOCK_POST_CHECKED' => ($lock_post_checked) ? ' checked="checked"' : '', |
| 1404 | 6364 | acydburn | 'S_LINKS_ALLOWED' => $url_status, |
| 1405 | 5902 | acydburn | 'S_MAGIC_URL_CHECKED' => ($urls_checked) ? ' checked="checked"' : '', |
| 1406 | 5902 | acydburn | 'S_TYPE_TOGGLE' => $topic_type_toggle, |
| 1407 | 7384 | acydburn | 'S_SAVE_ALLOWED' => ($auth->acl_get('u_savedrafts') && $user->data['is_registered'] && $mode != 'edit') ? true : false, |
| 1408 | 5902 | acydburn | 'S_HAS_DRAFTS' => ($auth->acl_get('u_savedrafts') && $user->data['is_registered'] && $post_data['drafts']) ? true : false, |
| 1409 | 5902 | acydburn | 'S_FORM_ENCTYPE' => $form_enctype, |
| 1410 | 3697 | acydburn | |
| 1411 | 5603 | acydburn | 'S_BBCODE_IMG' => $img_status, |
| 1412 | 6364 | acydburn | 'S_BBCODE_URL' => $url_status, |
| 1413 | 5603 | acydburn | 'S_BBCODE_FLASH' => $flash_status, |
| 1414 | 5603 | acydburn | 'S_BBCODE_QUOTE' => $quote_status, |
| 1415 | 5603 | acydburn | |
| 1416 | 6015 | acydburn | 'S_POST_ACTION' => $s_action, |
| 1417 | 3631 | acydburn | 'S_HIDDEN_FIELDS' => $s_hidden_fields) |
| 1418 | 487 | psotfx | ); |
| 1419 | 347 | psotfx | |
| 1420 | 5603 | acydburn | // Build custom bbcodes array
|
| 1421 | 6149 | acydburn | display_custom_bbcodes(); |
| 1422 | 5603 | acydburn | |
| 1423 | 3631 | acydburn | // Poll entry
|
| 1424 | 7766 | acydburn | if (($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id']/* && (!$post_data['poll_last_vote'] || $auth->acl_get('m_edit', $forum_id))*/)) |
| 1425 | 4981 | acydburn | && $auth->acl_get('f_poll', $forum_id)) |
| 1426 | 3631 | acydburn | {
|
| 1427 | 3631 | acydburn | $template->assign_vars(array( |
| 1428 | 4767 | acydburn | 'S_SHOW_POLL_BOX' => true, |
| 1429 | 9470 | acydburn | 'S_POLL_VOTE_CHANGE' => ($auth->acl_get('f_votechg', $forum_id) && $auth->acl_get('f_vote', $forum_id)), |
| 1430 | 5902 | acydburn | 'S_POLL_DELETE' => ($mode == 'edit' && sizeof($post_data['poll_options']) && ((!$post_data['poll_last_vote'] && $post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) || $auth->acl_get('m_delete', $forum_id))), |
| 1431 | 6513 | acydburn | 'S_POLL_DELETE_CHECKED' => (!empty($poll_delete)) ? true : false, |
| 1432 | 3631 | acydburn | |
| 1433 | 11603 | git-gate | 'L_POLL_OPTIONS_EXPLAIN' => $user->lang('POLL_OPTIONS_' . (($mode == 'edit') ? 'EDIT_' : '') . 'EXPLAIN', (int) $config['max_poll_options']), |
| 1434 | 3631 | acydburn | |
| 1435 | 5902 | acydburn | 'VOTE_CHANGE_CHECKED' => (!empty($post_data['poll_vote_change'])) ? ' checked="checked"' : '', |
| 1436 | 6015 | acydburn | 'POLL_TITLE' => (isset($post_data['poll_title'])) ? $post_data['poll_title'] : '', |
| 1437 | 5902 | acydburn | 'POLL_OPTIONS' => (!empty($post_data['poll_options'])) ? implode("\n", $post_data['poll_options']) : '', |
| 1438 | 5902 | acydburn | 'POLL_MAX_OPTIONS' => (isset($post_data['poll_max_options'])) ? (int) $post_data['poll_max_options'] : 1, |
| 1439 | 6015 | acydburn | 'POLL_LENGTH' => $post_data['poll_length']) |
| 1440 | 3631 | acydburn | ); |
| 1441 | 3631 | acydburn | } |
| 1442 | 3631 | acydburn | |
| 1443 | 8976 | acydburn | // Show attachment box for adding attachments if true
|
| 1444 | 8976 | acydburn | $allowed = ($auth->acl_get('f_attach', $forum_id) && $auth->acl_get('u_attach') && $config['allow_attachments'] && $form_enctype); |
| 1445 | 8976 | acydburn | |
| 1446 | 3697 | acydburn | // Attachment entry
|
| 1447 | 8976 | acydburn | posting_gen_attachment_entry($attachment_data, $filename_data, $allowed); |
| 1448 | 3697 | acydburn | |
| 1449 | 2923 | psotfx | // Output page ...
|
| 1450 | 9961 | Kellanved | page_header($page_title, false); |
| 1451 | 2923 | psotfx | |
| 1452 | 2923 | psotfx | $template->set_filenames(array( |
| 1453 | 3072 | psotfx | 'body' => 'posting_body.html') |
| 1454 | 2923 | psotfx | ); |
| 1455 | 3572 | acydburn | |
| 1456 | 6015 | acydburn | make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
|
| 1457 | 2923 | psotfx | |
| 1458 | 3575 | acydburn | // Topic review
|
| 1459 | 3575 | acydburn | if ($mode == 'reply' || $mode == 'quote') |
| 1460 | 3575 | acydburn | {
|
| 1461 | 4551 | acydburn | if (topic_review($topic_id, $forum_id)) |
| 1462 | 4542 | acydburn | {
|
| 1463 | 4767 | acydburn | $template->assign_var('S_DISPLAY_REVIEW', true); |
| 1464 | 4542 | acydburn | } |
| 1465 | 3575 | acydburn | } |
| 1466 | 3575 | acydburn | |
| 1467 | 3969 | psotfx | page_footer(); |
| 1468 | 487 | psotfx | |
| 1469 | 5114 | acydburn | /**
|
| 1470 | 5902 | acydburn | * Show upload popup (progress bar) |
| 1471 | 5114 | acydburn | */ |
| 1472 | 5902 | acydburn | function upload_popup($forum_style = 0) |
| 1473 | 4479 | acydburn | {
|
| 1474 | 5902 | acydburn | global $template, $user; |
| 1475 | 4479 | acydburn | |
| 1476 | 5902 | acydburn | ($forum_style) ? $user->setup('posting', $forum_style) : $user->setup('posting'); |
| 1477 | 4479 | acydburn | |
| 1478 | 9961 | Kellanved | page_header($user->lang['PROGRESS_BAR'], false); |
| 1479 | 5580 | acydburn | |
| 1480 | 5902 | acydburn | $template->set_filenames(array( |
| 1481 | 5902 | acydburn | 'popup' => 'posting_progress_bar.html') |
| 1482 | 5902 | acydburn | ); |
| 1483 | 4479 | acydburn | |
| 1484 | 5902 | acydburn | $template->assign_vars(array( |
| 1485 | 6237 | acydburn | 'PROGRESS_BAR' => $user->img('upload_bar', $user->lang['UPLOAD_IN_PROGRESS'])) |
| 1486 | 5902 | acydburn | ); |
| 1487 | 4479 | acydburn | |
| 1488 | 5902 | acydburn | $template->display('popup'); |
| 1489 | 8655 | acydburn | |
| 1490 | 8655 | acydburn | garbage_collection(); |
| 1491 | 8655 | acydburn | exit_handler(); |
| 1492 | 4479 | acydburn | } |
| 1493 | 4479 | acydburn | |
| 1494 | 5114 | acydburn | /**
|
| 1495 | 5902 | acydburn | * Do the various checks required for removing posts as well as removing it |
| 1496 | 5114 | acydburn | */ |
| 1497 | 5902 | acydburn | function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data) |
| 1498 | 4477 | acydburn | {
|
| 1499 | 8924 | toonarmy | global $user, $db, $auth, $config; |
| 1500 | 6015 | acydburn | global $phpbb_root_path, $phpEx; |
| 1501 | 6015 | acydburn | |
| 1502 | 5902 | acydburn | // If moderator removing post or user itself removing post, present a confirmation screen
|
| 1503 | 10080 | nickvergessen | if ($auth->acl_get('m_delete', $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get('f_delete', $forum_id) && $post_id == $post_data['topic_last_post_id'] && !$post_data['post_edit_locked'] && ($post_data['post_time'] > time() - ($config['delete_time'] * 60) || !$config['delete_time']))) |
| 1504 | 4477 | acydburn | {
|
| 1505 | 5902 | acydburn | $s_hidden_fields = build_hidden_fields(array( |
| 1506 | 5902 | acydburn | 'p' => $post_id, |
| 1507 | 5902 | acydburn | 'f' => $forum_id, |
| 1508 | 5902 | acydburn | 'mode' => 'delete') |
| 1509 | 4477 | acydburn | ); |
| 1510 | 4477 | acydburn | |
| 1511 | 5902 | acydburn | if (confirm_box(true)) |
| 1512 | 4477 | acydburn | {
|
| 1513 | 5902 | acydburn | $data = array( |
| 1514 | 5902 | acydburn | 'topic_first_post_id' => $post_data['topic_first_post_id'], |
| 1515 | 5902 | acydburn | 'topic_last_post_id' => $post_data['topic_last_post_id'], |
| 1516 | 8362 | Kellanved | 'topic_replies_real' => $post_data['topic_replies_real'], |
| 1517 | 5902 | acydburn | 'topic_approved' => $post_data['topic_approved'], |
| 1518 | 5902 | acydburn | 'topic_type' => $post_data['topic_type'], |
| 1519 | 5902 | acydburn | 'post_approved' => $post_data['post_approved'], |
| 1520 | 6063 | naderman | 'post_reported' => $post_data['post_reported'], |
| 1521 | 5902 | acydburn | 'post_time' => $post_data['post_time'], |
| 1522 | 6224 | acydburn | 'poster_id' => $post_data['poster_id'], |
| 1523 | 6224 | acydburn | 'post_postcount' => $post_data['post_postcount'] |
| 1524 | 4477 | acydburn | ); |
| 1525 | 4477 | acydburn | |
| 1526 | 5902 | acydburn | $next_post_id = delete_post($forum_id, $topic_id, $post_id, $data); |
| 1527 | 10170 | acydburn | $post_username = ($post_data['poster_id'] == ANONYMOUS && !empty($post_data['post_username'])) ? $post_data['post_username'] : $post_data['username']; |
| 1528 | 4477 | acydburn | |
| 1529 | 8362 | Kellanved | if ($next_post_id === false) |
| 1530 | 4477 | acydburn | {
|
| 1531 | 10170 | acydburn | add_log('mod', $forum_id, $topic_id, 'LOG_DELETE_TOPIC', $post_data['topic_title'], $post_username); |
| 1532 | 4970 | psotfx | |
| 1533 | 6015 | acydburn | $meta_info = append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id"); |
| 1534 | 5902 | acydburn | $message = $user->lang['POST_DELETED']; |
| 1535 | 5247 | acydburn | } |
| 1536 | 4477 | acydburn | else
|
| 1537 | 4477 | acydburn | {
|
| 1538 | 10170 | acydburn | add_log('mod', $forum_id, $topic_id, 'LOG_DELETE_POST', $post_data['post_subject'], $post_username); |
| 1539 | 4477 | acydburn | |
| 1540 | 6015 | acydburn | $meta_info = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&p=$next_post_id") . "#p$next_post_id"; |
| 1541 | 5902 | acydburn | $message = $user->lang['POST_DELETED'] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $meta_info . '">', '</a>'); |
| 1542 | 4477 | acydburn | } |
| 1543 | 4970 | psotfx | |
| 1544 | 5902 | acydburn | meta_refresh(3, $meta_info); |
| 1545 | 6015 | acydburn | $message .= '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id) . '">', '</a>'); |
| 1546 | 5902 | acydburn | trigger_error($message); |
| 1547 | 4477 | acydburn | } |
| 1548 | 5902 | acydburn | else
|
| 1549 | 4477 | acydburn | {
|
| 1550 | 8350 | acydburn | confirm_box(false, 'DELETE_POST', $s_hidden_fields); |
| 1551 | 4477 | acydburn | } |
| 1552 | 4477 | acydburn | } |
| 1553 | 4477 | acydburn | |
| 1554 | 5902 | acydburn | // If we are here the user is not able to delete - present the correct error message
|
| 1555 | 7322 | acydburn | if ($post_data['poster_id'] != $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) |
| 1556 | 4504 | acydburn | {
|
| 1557 | 5902 | acydburn | trigger_error('DELETE_OWN_POSTS'); |
| 1558 | 4504 | acydburn | } |
| 1559 | 4504 | acydburn | |
| 1560 | 5902 | acydburn | if ($post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id) && $post_id != $post_data['topic_last_post_id']) |
| 1561 | 4477 | acydburn | {
|
| 1562 | 5902 | acydburn | trigger_error('CANNOT_DELETE_REPLIED'); |
| 1563 | 4477 | acydburn | } |
| 1564 | 4477 | acydburn | |
| 1565 | 5902 | acydburn | trigger_error('USER_CANNOT_DELETE'); |
| 1566 | 4477 | acydburn | } |

