| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
<span class="code-comment"> * posting.php |
|---|
| 4 |
* ------------------- |
|---|
| 5 |
* begin : Saturday, Feb 13, 2001 |
|---|
| 6 |
* copyright : (C) 2001 The phpBB Group |
|---|
| 7 |
* email : support@phpbb.com |
|---|
| 8 |
* |
|---|
| 9 |
* $Id: posting.php,v 1.159.2.27 2005/10/30 15:17:13 acydburn Exp $ |
|---|
| 10 |
* |
|---|
| 11 |
* |
|---|
| 12 |
***************************************************************************/ |
|---|
| 13 |
|
|---|
| 14 |
/*************************************************************************** |
|---|
| 15 |
* |
|---|
| 16 |
* This program is free software; you can redistribute it and/or modify |
|---|
| 17 |
* it under the terms of the GNU General Public License as published by |
|---|
| 18 |
* the Free Software Foundation; either version 2 of the License, or |
|---|
| 19 |
* (at your option) any later version. |
|---|
| 20 |
* |
|---|
| 21 |
***************************************************************************/ |
|---|
| 22 |
|
|---|
| 23 |
if ( !defined('IN_PHPBB2_BRIDGE') ) {</span> |
|---|
| 24 |
<span class="code-keyword"> trigger_error('Invalid access'); |
|---|
| 25 |
} |
|---|
| 26 |
|
|---|
| 27 |
define('IN_PHPBB', true); |
|---|
| 28 |
$root_path = './';</span> |
|---|
| 29 |
<span class="code-lang">include($root_path . 'extension.inc'); |
|---|
| 30 |
include($root_path . 'phpBB2/includes/bbcode.'.$phpEx); |
|---|
| 31 |
include($root_path . 'phpBB2/includes/functions_post.'.$phpEx); |
|---|
| 32 |
include($root_path . 'include/bbcode/bbcode.lib.php'); |
|---|
| 33 |
include($root_path . 'include/functions_post.'.$phpEx); |
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
<span class="code-comment">// Check and set various parameters |
|---|
| 37 |
// |
|---|
| 38 |
$params = array('submit' => 'post', 'preview' => 'preview', 'delete' => 'delete', 'poll_delete' => 'poll_delete', 'poll_add' => 'add_poll_option', 'poll_edit' => 'edit_poll_option', 'mode' => 'mode');</span> |
|---|
| 39 |
<span class="code-lang"> |
|---|
| 40 |
foreach ( $params AS $var => $param ) { |
|---|
| 41 |
$$var = request_var($param, ''); |
|---|
| 42 |
} |
|---|
| 43 |
|
|---|
| 44 |
$confirm = isset($_POST['confirm']) ? true : false; |
|---|
| 45 |
$sid = request_var('sid', ''); |
|---|
| 46 |
|
|---|
| 47 |
$params = array('forum_id' => POST_FORUM_URL, 'topic_id' => POST_TOPIC_URL, 'post_id' => POST_POST_URL);</span> |
|---|
| 48 |
<span class="code-lang"> |
|---|
| 49 |
foreach ( $params AS $var => $param ) { |
|---|
| 50 |
$$var = request_var($param, 0); |
|---|
| 51 |
} |
|---|
| 52 |
|
|---|
| 53 |
$refresh = $preview || $poll_add || $poll_edit || $poll_delete; |
|---|
| 54 |
$orig_word = $replacement_word = array(); |
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 |
<span class="code-comment">// Set topic type |
|---|
| 58 |
// |
|---|
| 59 |
$topic_type = request_var('topictype', POST_NORMAL); |
|---|
| 60 |
$topic_type = ( in_array($topic_type, array(POST_NORMAL, POST_STICKY, POST_ANNOUNCE)) ) ? $topic_type : POST_NORMAL; |
|---|
| 61 |
$topic_first_post_sticky = request_var('topic_first_post_sticky', 0); |
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 |
<span class="code-comment">// If the mode is set to topic review then output |
|---|
| 65 |
// that review ... |
|---|
| 66 |
// |
|---|
| 67 |
if ( $mode == 'topicreview' )</span> |
|---|
| 68 |
<span class="code-keyword">{ |
|---|
| 69 |
require($root_path . 'phpBB2/includes/topic_review.'.$phpEx); |
|---|
| 70 |
|
|---|
| 71 |
topic_review($topic_id, false); |
|---|
| 72 |
gc(); |
|---|
| 73 |
} |
|---|
| 74 |
|
|---|
| 75 |
|
|---|
| 76 |
<span class="code-comment">// Start session management |
|---|
| 77 |
// |
|---|
| 78 |
$userdata = session_pagestart($user_ip); |
|---|
| 79 |
init_userprefs($userdata); |
|---|
| 80 |
|
|---|
| 81 |
<span class="code-comment">// End session management |
|---|
| 82 |
// |
|---|
| 83 |
|
|---|
| 84 |
// |
|---|
| 85 |
check_ban(BAN_FORUM_POST); |
|---|
| 86 |
|
|---|
| 87 |
<span class="code-comment"> |
|---|
| 88 |
// |
|---|
| 89 |
// Was cancel pressed? If so then redirect to the appropriate |
|---|
| 90 |
// page, no point in continuing with any further checks |
|---|
| 91 |
// |
|---|
| 92 |
|
|---|
| 93 |
// FIXME: In Cancel delete post: redirect is unable to parle a full url ! |
|---|
| 94 |
|
|---|
| 95 |
if ( isset($_POST['cancel']) )</span> |
|---|
| 96 |
<span class="code-keyword">{ |
|---|
| 97 |
if ( $post_id ) |
|---|
| 98 |
{ |
|---|
| 99 |
|
|---|
| 100 |
$redirect = $root_path . "phpbb2.php?page=viewtopic&" . POST_POST_URL . "=$post_id"; |
|---|
| 101 |
$post_append = "#$post_id"; |
|---|
| 102 |
} |
|---|
| 103 |
else if ( $topic_id ) |
|---|
| 104 |
{ |
|---|
| 105 |
|
|---|
| 106 |
$redirect = $root_path . "phpbb2.php?page=viewtopic&" . POST_TOPIC_URL . "=$topic_id"; |
|---|
| 107 |
$post_append = ''; |
|---|
| 108 |
} |
|---|
| 109 |
else if ( $forum_id ) |
|---|
| 110 |
{ |
|---|
| 111 |
|
|---|
| 112 |
$redirect = $root_path . "phpbb2.php?page=viewforum&" . POST_FORUM_URL . "=$forum_id"; |
|---|
| 113 |
$post_append = ''; |
|---|
| 114 |
} |
|---|
| 115 |
else |
|---|
| 116 |
{ |
|---|
| 117 |
|
|---|
| 118 |
$redirect = $root_path . "phpbb2.php?"; |
|---|
| 119 |
$post_append = ''; |
|---|
| 120 |
} |
|---|
| 121 |
|
|---|
| 122 |
redirect(append_sid($redirect) . $post_append); |
|---|
| 123 |
|
|---|
| 124 |
} |
|---|
| 125 |
|
|---|
| 126 |
|
|---|
| 127 |
<span class="code-comment">// What auth type do we need to check? |
|---|
| 128 |
// |
|---|
| 129 |
$is_auth = array();</span> |
|---|
| 130 |
<span class="code-lang">switch( $mode ) |
|---|
| 131 |
{ |
|---|
| 132 |
case 'newtopic': |
|---|
| 133 |
if ( $topic_type == POST_ANNOUNCE ) |
|---|
| 134 |
{ |
|---|
| 135 |
$is_auth_type = 'auth_announce'; |
|---|
| 136 |
} |
|---|
| 137 |
else if ( $topic_type == POST_STICKY ) |
|---|
| 138 |
{ |
|---|
| 139 |
$is_auth_type = 'auth_sticky'; |
|---|
| 140 |
} |
|---|
| 141 |
else |
|---|
| 142 |
{ |
|---|
| 143 |
$is_auth_type = 'auth_post'; |
|---|
| 144 |
} |
|---|
| 145 |
break; |
|---|
| 146 |
case 'reply': |
|---|
| 147 |
case 'quote': |
|---|
| 148 |
$is_auth_type = 'auth_reply'; |
|---|
| 149 |
break; |
|---|
| 150 |
case 'editpost': |
|---|
| 151 |
$is_auth_type = 'auth_edit'; |
|---|
| 152 |
break; |
|---|
| 153 |
case 'delete': |
|---|
| 154 |
case 'poll_delete': |
|---|
| 155 |
$is_auth_type = 'auth_delete'; |
|---|
| 156 |
break; |
|---|
| 157 |
case 'vote': |
|---|
| 158 |
$is_auth_type = 'auth_vote'; |
|---|
| 159 |
break; |
|---|
| 160 |
case 'topicreview': |
|---|
| 161 |
$is_auth_type = 'auth_read'; |
|---|
| 162 |
break; |
|---|
| 163 |
default: |
|---|
| 164 |
trigger_error($lang['no_post_mode']); |
|---|
| 165 |
return; |
|---|
| 166 |
break; |
|---|
| 167 |
} |
|---|
| 168 |
|
|---|
| 169 |
|
|---|
| 170 |
<span class="code-comment">// Here we do various lookups to find topic_id, forum_id, post_id etc. |
|---|
| 171 |
// Doing it here prevents spoofing (eg. faking forum_id, topic_id or post_id |
|---|
| 172 |
// |
|---|
| 173 |
$error_msg = ''; |
|---|
| 174 |
$post_data = array();</span> |
|---|
| 175 |
<span class="code-lang">switch ( $mode ) |
|---|
| 176 |
{ |
|---|
| 177 |
case 'newtopic': |
|---|
| 178 |
if ( empty($forum_id) ) |
|---|
| 179 |
{ |
|---|
| 180 |
trigger_error($lang['forum_not_exist']); |
|---|
| 181 |
return; |
|---|
| 182 |
} |
|---|
| 183 |
|
|---|
| 184 |
$sql = "SELECT * |
|---|
| 185 |
FROM " . FORUMS_TABLE . " |
|---|
| 186 |
WHERE forum_id = $forum_id"; |
|---|
| 187 |
break; |
|---|
| 188 |
|
|---|
| 189 |
case 'reply': |
|---|
| 190 |
case 'vote': |
|---|
| 191 |
if ( empty( $topic_id) ) |
|---|
| 192 |
{ |
|---|
| 193 |
trigger_error($lang['no_topic_id']); |
|---|
| 194 |
return; |
|---|
| 195 |
} |
|---|
| 196 |
|
|---|
| 197 |
$sql = "SELECT f.*, t.topic_status, t.topic_title, t.topic_type, t.topic_id |
|---|
| 198 |
FROM " . FORUMS_TABLE . " f, " . TOPICS_TABLE . " t |
|---|
| 199 |
WHERE t.topic_id = $topic_id |
|---|
| 200 |
AND f.forum_id = t.forum_id"; |
|---|
| 201 |
break; |
|---|
| 202 |
|
|---|
| 203 |
case 'quote': |
|---|
| 204 |
case 'editpost': |
|---|
| 205 |
case 'delete': |
|---|
| 206 |
case 'poll_delete': |
|---|
| 207 |
if ( empty($post_id) ) |
|---|
| 208 |
{ |
|---|
| 209 |
trigger_error($lang['no_post_id']); |
|---|
| 210 |
return; |
|---|
| 211 |
} |
|---|
| 212 |
|
|---|
| 213 |
|
|---|
| 214 |
//$from_sql = ( !$submit ) ? ", " . POSTS_TEXT_TABLE . " pt, " . USERS_TABLE . " u" : ''; |
|---|
| 215 |
//$where_sql = ( !$submit ) ? "AND pt.post_id = p.post_id AND u.uid = p.poster_id" : ''; |
|---|
| 216 |
$select_sql = ', t.topic_title, p.enable_bbcode, p.enable_html, p.enable_smilies, p.enable_sig, p.post_username, p.post_time, pt.post_subject, pt.post_text, u.name AS username, u.uid, u.user_sig'; |
|---|
| 217 |
$from_sql = ", " . POSTS_TEXT_TABLE . " pt, " . USERS_TABLE . " u"; |
|---|
| 218 |
$where_sql = "AND pt.post_id = p.post_id AND u.uid = p.poster_id"; |
|---|
| 219 |
|
|---|
| 220 |
$sql = "SELECT f.*, t.topic_id, t.topic_status, t.topic_type, t.topic_first_post_id, t.topic_last_post_id, t.topic_vote, t.topic_first_post_sticky, p.post_id, p.poster_id" . $select_sql . " |
|---|
| 221 |
FROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f" . $from_sql . " |
|---|
| 222 |
WHERE p.post_id = $post_id |
|---|
| 223 |
AND t.topic_id = p.topic_id |
|---|
| 224 |
AND f.forum_id = p.forum_id |
|---|
| 225 |
$where_sql"; |
|---|
| 226 |
break; |
|---|
| 227 |
|
|---|
| 228 |
default: |
|---|
| 229 |
trigger_error($lang['no_valid_mode']); |
|---|
| 230 |
return; |
|---|
| 231 |
} |
|---|
| 232 |
$result = $db->sql_query($sql);</span> |
|---|
| 233 |
<span class="code-lang"> |
|---|
| 234 |
if ( $post_info = $db->sql_fetchrow($result) ) |
|---|
| 235 |
{ |
|---|
| 236 |
$db->sql_freeresult($result); |
|---|
| 237 |
|
|---|
| 238 |
$forum_id = $post_info['forum_id']; |
|---|
| 239 |
$forum_name = $post_info['forum_name']; |
|---|
| 240 |
|
|---|
| 241 |
|
|---|
| 242 |
$seo->setForumUrl($forum_id, $forum_name); |
|---|
| 243 |
if ( $mode <> 'newtopic' ) { |
|---|
| 244 |
$seo->set_parent($post_info['topic_id'], $seo->seo_static['topic'], $forum_id, $seo->seo_static['forum']); |
|---|
| 245 |
$seo->set_url($post_info['topic_title'], $post_info['topic_id'], $seo->seo_static['topic']); |
|---|
| 246 |
} |
|---|
| 247 |
|
|---|
| 248 |
|
|---|
| 249 |
$is_auth = auth(AUTH_ALL, $forum_id, $userdata, $post_info); |
|---|
| 250 |
|
|---|
| 251 |
if ( $post_info['forum_status'] == FORUM_LOCKED && !$is_auth['auth_mod']) |
|---|
| 252 |
{ |
|---|
| 253 |
trigger_error($lang['forum_locked']); |
|---|
| 254 |
return; |
|---|
| 255 |
} |
|---|
| 256 |
else if ( $mode != 'newtopic' && $post_info['topic_status'] == TOPIC_LOCKED && !$is_auth['auth_mod']) |
|---|
| 257 |
{ |
|---|
| 258 |
trigger_error($lang['topic_locked']); |
|---|
| 259 |
return; |
|---|
| 260 |
} |
|---|
| 261 |
|
|---|
| 262 |
if ( $mode == 'editpost' || $mode == 'delete' || $mode == 'poll_delete' ) |
|---|
| 263 |
{ |
|---|
| 264 |
$topic_id = $post_info['topic_id']; |
|---|
| 265 |
|
|---|
| 266 |
$post_data['poster_post'] = ( $post_info['poster_id'] == $userdata['uid'] ) ? true : false; |
|---|
| 267 |
$post_data['first_post'] = ( $post_info['topic_first_post_id'] == $post_id ) ? true : false; |
|---|
| 268 |
$post_data['last_post'] = ( $post_info['topic_last_post_id'] == $post_id ) ? true : false; |
|---|
| 269 |
$post_data['last_topic'] = ( $post_info['forum_last_post_id'] == $post_id ) ? true : false; |
|---|
| 270 |
$post_data['has_poll'] = ( $post_info['topic_vote'] ) ? true : false; |
|---|
| 271 |
$post_data['topic_type'] = $post_info['topic_type']; |
|---|
| 272 |
$post_data['poster_id'] = $post_info['poster_id']; |
|---|
| 273 |
$post_data['topic_first_post_sticky'] = $post_info['topic_first_post_sticky']; |
|---|
| 274 |
|
|---|
| 275 |
if ( $post_data['first_post'] && $post_data['has_poll'] ) |
|---|
| 276 |
{ |
|---|
| 277 |
$sql = "SELECT * |
|---|
| 278 |
FROM " . VOTE_DESC_TABLE . " vd, " . VOTE_RESULTS_TABLE . " vr |
|---|
| 279 |
WHERE vd.topic_id = $topic_id |
|---|
| 280 |
AND vr.vote_id = vd.vote_id |
|---|
| 281 |
ORDER BY vr.vote_option_id"; |
|---|
| 282 |
$result = $db->sql_query($sql); |
|---|
| 283 |
$poll_options = array(); |
|---|
| 284 |
$poll_results_sum = 0; |
|---|
| 285 |
if ( $row = $db->sql_fetchrow($result) ) |
|---|
| 286 |
{ |
|---|
| 287 |
$poll_title = $row['vote_text']; |
|---|
| 288 |
$poll_id = $row['vote_id']; |
|---|
| 289 |
$poll_length = $row['vote_length'] / 86400; |
|---|
| 290 |
|
|---|
| 291 |
do |
|---|
| 292 |
{ |
|---|
| 293 |
$poll_options[$row['vote_option_id']] = $row['vote_option_text']; |
|---|
| 294 |
$poll_results_sum += $row['vote_result']; |
|---|
| 295 |
} |
|---|
| 296 |
while ( $row = $db->sql_fetchrow($result) ); |
|---|
| 297 |
} |
|---|
| 298 |
$db->sql_freeresult($result); |
|---|
| 299 |
|
|---|
| 300 |
$post_data['edit_poll'] = ( ( !$poll_results_sum || $is_auth['auth_mod'] ) && $post_data['first_post'] ) ? true : 0; |
|---|
| 301 |
} |
|---|
| 302 |
else |
|---|
| 303 |
{ |
|---|
| 304 |
$post_data['edit_poll'] = ($post_data['first_post'] && $is_auth['auth_pollcreate']) ? true : false; |
|---|
| 305 |
} |
|---|
| 306 |
|
|---|
| 307 |
|
|---|
| 308 |
// Can this user edit/delete the post/poll? |
|---|
| 309 |
// |
|---|
| 310 |
if ( $post_info['poster_id'] != $userdata['uid'] && !$is_auth['auth_mod'] ) |
|---|
| 311 |
{ |
|---|
| 312 |
$message = ( $delete || $mode == 'delete' ) ? $lang['delete_own_posts'] : $lang['edit_own_posts']; |
|---|
| 313 |
|
|---|
| 314 |
$message .= '<br /><br />' . sprintf($lang['click_return_topic'], '<a href="' . append_sid($root_path . "phpbb2.php?page=viewtopic&" . POST_TOPIC_URL . "=$topic_id") . '">', '</a>'); |
|---|
| 315 |
|
|---|
| 316 |
trigger_error($message); |
|---|
| 317 |
return; |
|---|
| 318 |
} |
|---|
| 319 |
else if ( !$post_data['last_post'] && !$is_auth['auth_mod'] && ( $mode == 'delete' || $delete ) ) |
|---|
| 320 |
{ |
|---|
| 321 |
trigger_error($lang['cannot_delete_replied']); |
|---|
| 322 |
return; |
|---|
| 323 |
} |
|---|
| 324 |
else if ( !$post_data['edit_poll'] && !$is_auth['auth_mod'] && ( $mode == 'poll_delete' || $poll_delete ) ) |
|---|
| 325 |
{ |
|---|
| 326 |
trigger_error($lang['cannot_delete_poll']); |
|---|
| 327 |
return; |
|---|
| 328 |
} |
|---|
| 329 |
|
|---|
| 330 |
// Ordinary users can't delete moderated posts |
|---|
| 331 |
else if ( check_mod_tags($is_auth['auth_mod'], $post_info['post_text']) && ( $mode == 'delete' || $delete ) ) |
|---|
| 332 |
{ |
|---|
| 333 |
trigger_error($lang['mod_no_delete'], $lang['mod_restrictions']); |
|---|
| 334 |
return; |
|---|
| 335 |
} |
|---|
| 336 |
|
|---|
| 337 |
} |
|---|
| 338 |
else |
|---|
| 339 |
{ |
|---|
| 340 |
if ( $mode == 'quote' ) |
|---|
| 341 |
{ |
|---|
| 342 |
$topic_id = $post_info['topic_id']; |
|---|
| 343 |
} |
|---|
| 344 |
if ( $mode == 'newtopic' ) |
|---|
| 345 |
{ |
|---|
| 346 |
$post_data['topic_type'] = POST_NORMAL; |
|---|
| 347 |
} |
|---|
| 348 |
|
|---|
| 349 |
$post_data['first_post'] = ( $mode == 'newtopic' ) ? true : 0; |
|---|
| 350 |
$post_data['last_post'] = false; |
|---|
| 351 |
$post_data['has_poll'] = false; |
|---|
| 352 |
$post_data['edit_poll'] = false; |
|---|
| 353 |
} |
|---|
| 354 |
if ( $mode == 'poll_delete' && !isset($poll_id) ) |
|---|
| 355 |
{ |
|---|
| 356 |
trigger_error($lang['no_such_post']); |
|---|
| 357 |
return; |
|---|
| 358 |
} |
|---|
| 359 |
} |
|---|
| 360 |
else |
|---|
| 361 |
{ |
|---|
| 362 |
trigger_error($lang['no_such_post']); |
|---|
| 363 |
return; |
|---|
| 364 |
} |
|---|
| 365 |
|
|---|
| 366 |
|
|---|
| 367 |
<span class="code-comment">// The user is not authed, if they're not logged in then redirect |
|---|
| 368 |
// them, else show them an error message |
|---|
| 369 |
// |
|---|
| 370 |
if ( !$is_auth[$is_auth_type] )</span> |
|---|
| 371 |
<span class="code-keyword">{ |
|---|
| 372 |
if ( $userdata['session_logged_in'] ) |
|---|
| 373 |
{ |
|---|
| 374 |
trigger_error(sprintf($lang['Sorry_' . $is_auth_type], $is_auth[$is_auth_type . "_type"])); |
|---|
| 375 |
return; |
|---|
| 376 |
} |
|---|
| 377 |
|
|---|
| 378 |
switch( $mode ) |
|---|
| 379 |
{ |
|---|
| 380 |
case 'newtopic': |
|---|
| 381 |
$redirect = "mode=newtopic&" . POST_FORUM_URL . "=" . $forum_id; |
|---|
| 382 |
break; |
|---|
| 383 |
case 'reply': |
|---|
| 384 |
case 'topicreview': |
|---|
| 385 |
$redirect = "mode=reply&" . POST_TOPIC_URL . "=" . $topic_id; |
|---|
| 386 |
break; |
|---|
| 387 |
case 'quote': |
|---|
| 388 |
case 'editpost': |
|---|
| 389 |
$redirect = "mode=quote&" . POST_POST_URL ."=" . $post_id; |
|---|
| 390 |
break; |
|---|
| 391 |
} |
|---|
| 392 |
|
|---|
| 393 |
loggedinorreturn(); |
|---|
| 394 |
|
|---|
| 395 |
} |
|---|
| 396 |
|
|---|
| 397 |
|
|---|
| 398 |
<span class="code-comment">// Set toggles for various options |
|---|
| 399 |
// |
|---|
| 400 |
if ( !$config['allow_html'] )</span> |
|---|
| 401 |
<span class="code-keyword">{ |
|---|
| 402 |
$html_on = 0; |
|---|
| 403 |
} |
|---|
| 404 |
else |
|---|
| 405 |
{ |
|---|
| 406 |
$html_on = ( $submit || $refresh ) ? ( ( isset($_POST['disable_html']) ) ? 0 : true ) : false; |
|---|
| 407 |
} |
|---|
| 408 |
|
|---|
| 409 |
if ( !$config['allow_bbcode'] ) |
|---|
| 410 |
{ |
|---|
| 411 |
$bbcode_on = 0; |
|---|
| 412 |
} |
|---|
| 413 |
else |
|---|
| 414 |
{ |
|---|
| 415 |
$bbcode_on = ( $submit || $refresh ) ? ( ( isset($_POST['disable_bbcode']) ) ? 0 : true ) : $config['allow_bbcode']; |
|---|
| 416 |
} |
|---|
| 417 |
|
|---|
| 418 |
if ( !$config['allow_smilies'] ) |
|---|
| 419 |
{ |
|---|
| 420 |
$smilies_on = 0; |
|---|
| 421 |
} |
|---|
| 422 |
else |
|---|
| 423 |
{ |
|---|
| 424 |
$smilies_on = ( $submit || $refresh ) ? ( ( isset($_POST['disable_smilies']) ) ? 0 : true ) : $config['allow_smilies']; |
|---|
| 425 |
} |
|---|
| 426 |
|
|---|
| 427 |
if ( ($submit || $refresh) && $is_auth['auth_read']) |
|---|
| 428 |
{ |
|---|
| 429 |
$notify_user = ( isset($_POST['notify']) ) ? true : 0; |
|---|
| 430 |
} |
|---|
| 431 |
else |
|---|
| 432 |
{ |
|---|
| 433 |
if ( $mode != 'newtopic' && $userdata['session_logged_in'] && $is_auth['auth_read'] ) |
|---|
| 434 |
{ |
|---|
| 435 |
$sql = "SELECT checkcomm_for_id |
|---|
| 436 |
FROM " . COMMENTS_NOTIFY_TABLE . " |
|---|
| 437 |
WHERE checkcomm_for_id = $topic_id |
|---|
| 438 |
AND checkcomm_type = " . TYPE_FORUM_POST . " |
|---|
| 439 |
AND checkcomm_userid = " . $userdata['uid']; |
|---|
| 440 |
$result = $db->sql_query($sql); |
|---|
| 441 |
|
|---|
| 442 |
$notify_user = ( $db->sql_fetchrow($result) ) ? TRUE : $userdata['commentpm']; |
|---|
| 443 |
$db->sql_freeresult($result); |
|---|
| 444 |
} |
|---|
| 445 |
else |
|---|
| 446 |
{ |
|---|
| 447 |
$notify_user = ( $userdata['session_logged_in'] && $is_auth['auth_read'] ) ? $userdata['commentpm'] : 0; |
|---|
| 448 |
} |
|---|
| 449 |
} |
|---|
| 450 |
$attach_sig = ( $submit || $refresh ) ? ( ( isset($_POST['attach_sig']) ) ? TRUE : 0 ) : ( ( $userdata['uid'] == ANONYMOUS ) ? 0 : ( $userdata['user_sig'] != '' ? TRUE : 0 ) ); |
|---|
| 451 |
|
|---|
| 452 |
$merge = false; |
|---|
| 453 |
|
|---|
| 454 |
|
|---|
| 455 |
|
|---|
| 456 |
|
|---|
| 457 |
<span class="code-comment">// What shall we do? |
|---|
| 458 |
// |
|---|
| 459 |
if ( ( $delete || $poll_delete || $mode == 'delete' ) && !$confirm )</span> |
|---|
| 460 |
<span class="code-keyword">{ |
|---|
| 461 |
|
|---|
| 462 |
// Confirm deletion |
|---|
| 463 |
// |
|---|
| 464 |
$s_hidden_fields = '<input type="hidden" name="' . POST_POST_URL . '" value="' . $post_id . '" />'; |
|---|
| 465 |
$s_hidden_fields .= ( $delete || $mode == "delete" ) ? '<input type="hidden" name="mode" value="delete" />' : '<input type="hidden" name="mode" value="poll_delete" />'; |
|---|
| 466 |
$s_hidden_fields .= '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" />'; |
|---|
| 467 |
|
|---|
| 468 |
|
|---|
| 469 |
$l_confirm = ( $delete || $mode == 'delete' ) ? $lang['confirm_delete'] : $lang['confirm_delete_poll']; |
|---|
| 470 |
|
|---|
| 471 |
|
|---|
| 472 |
// Output confirmation page |
|---|
| 473 |
// |
|---|
| 474 |
stdhead($lang['forums'] . ( isset($page_title) ? ' :: ' . $page_title : '' ), false); |
|---|
| 475 |
|
|---|
| 476 |
$template->assign_vars(array( |
|---|
| 477 |
'MESSAGE_TITLE' => $lang['information'], |
|---|
| 478 |
'MESSAGE_TEXT' => $l_confirm, |
|---|
| 479 |
|
|---|
| 480 |
|
|---|
| 481 |
'S_CONFIRM_ACTION' => append_sid($root_path . "phpbb2.php?page=posting"), |
|---|
| 482 |
'S_HIDDEN_FIELDS' => $s_hidden_fields) |
|---|
| 483 |
); |
|---|
| 484 |
|
|---|
| 485 |
$template->set_filenames(array( |
|---|
| 486 |
'body' => 'forum/confirm_body.tpl') |
|---|
| 487 |
); |
|---|
| 488 |
|
|---|
| 489 |
return; |
|---|
| 490 |
} |
|---|
| 491 |
else if ( $mode == 'vote' ) |
|---|
| 492 |
{ |
|---|
| 493 |
|
|---|
| 494 |
// Vote in a poll |
|---|
| 495 |
// |
|---|
| 496 |
if ( isset($_POST['vote_id']) ) |
|---|
| 497 |
{ |
|---|
| 498 |
$vote_option_id = intval($_POST['vote_id']); |
|---|
| 499 |
|
|---|
| 500 |
$sql = "SELECT vd.vote_id |
|---|
| 501 |
FROM " . VOTE_DESC_TABLE . " vd, " . VOTE_RESULTS_TABLE . " vr |
|---|
| 502 |
WHERE vd.topic_id = $topic_id |
|---|
| 503 |
AND vr.vote_id = vd.vote_id |
|---|
| 504 |
AND vr.vote_option_id = $vote_option_id |
|---|
| 505 |
GROUP BY vd.vote_id"; |
|---|
| 506 |
$result = $db->sql_query($sql); |
|---|
| 507 |
|
|---|
| 508 |
if ( $vote_info = $db->sql_fetchrow($result) ) |
|---|
| 509 |
{ |
|---|
| 510 |
$vote_id = $vote_info['vote_id']; |
|---|
| 511 |
|
|---|
| 512 |
$sql = "SELECT * |
|---|
| 513 |
FROM " . VOTE_USERS_TABLE . " |
|---|
| 514 |
WHERE vote_id = $vote_id |
|---|
| 515 |
AND vote_user_id = " . $userdata['uid']; |
|---|
| 516 |
$result2 = $db->sql_query($sql); |
|---|
| 517 |
|
|---|
| 518 |
if ( !($row = $db->sql_fetchrow($result2)) ) |
|---|
| 519 |
{ |
|---|
| 520 |
$sql = "UPDATE " . VOTE_RESULTS_TABLE . " |
|---|
| 521 |
SET vote_result = vote_result + 1 |
|---|
| 522 |
WHERE vote_id = $vote_id |
|---|
| 523 |
AND vote_option_id = $vote_option_id"; |
|---|
| 524 |
$db->sql_query($sql); |
|---|
| 525 |
|
|---|
| 526 |
$sql = "INSERT INTO " . VOTE_USERS_TABLE . " (vote_id, vote_user_id, vote_user_ip, vote_cast) |
|---|
| 527 |
VALUES ($vote_id, " . $userdata['uid'] . ", '$user_ip', $vote_option_id)"; |
|---|
| 528 |
$db->sql_query($sql); |
|---|
| 529 |
|
|---|
| 530 |
$message = $lang['vote_cast']; |
|---|
| 531 |
} |
|---|
| 532 |
else |
|---|
| 533 |
{ |
|---|
| 534 |
$message = $lang['already_voted']; |
|---|
| 535 |
} |
|---|
| 536 |
$db->sql_freeresult($result2); |
|---|
| 537 |
} |
|---|
| 538 |
else |
|---|
| 539 |
{ |
|---|
| 540 |
$message = $lang['no_vote_option']; |
|---|
| 541 |
} |
|---|
| 542 |
$db->sql_freeresult($result); |
|---|
| 543 |
|
|---|
| 544 |
meta_refresh(3, append_sid($root_path . "phpbb2.php?page=viewtopic&" . POST_TOPIC_URL . "=$topic_id")); |
|---|
| 545 |
|
|---|
| 546 |
$message .= '<br /><br />' . sprintf($lang['click_view_message'], '<a href="' . append_sid($root_path . "phpbb2.php?page=viewtopic&" . POST_TOPIC_URL . "=$topic_id") . '">', '</a>'); |
|---|
| 547 |
trigger_error($message); |
|---|
| 548 |
return; |
|---|
| 549 |
} |
|---|
| 550 |
else |
|---|
| 551 |
{ |
|---|
| 552 |
|
|---|
| 553 |
redirect(append_sid($root_path . "phpbb2.php?page=viewtopic&" . POST_TOPIC_URL . "=$topic_id")); |
|---|
| 554 |
} |
|---|
| 555 |
} |
|---|
| 556 |
else if ( $submit || $confirm ) |
|---|
| 557 |
{ |
|---|
| 558 |
|
|---|
| 559 |
// Submit post/vote (newtopic, edit, reply, etc.) |
|---|
| 560 |
// |
|---|
| 561 |
$return_message = ''; |
|---|
| 562 |
$return_meta = ''; |
|---|
| 563 |
|
|---|
| 564 |
if ($sid == '' || $sid != $userdata['session_id']) |
|---|
| 565 |
{ |
|---|
| 566 |
$error_msg .= (!empty($error_msg)) ? '<br />' . $lang['session_invalid'] : $lang['session_invalid']; |
|---|
| 567 |
} |
|---|
| 568 |
|
|---|
| 569 |
switch ( $mode ) |
|---|
| 570 |
{ |
|---|
| 571 |
case 'editpost': |
|---|
| 572 |
case 'newtopic': |
|---|
| 573 |
case 'reply': |
|---|
| 574 |
$username = request_var('username', ''); |
|---|
| 575 |
$subject = request_var('subject', ''); |
|---|
| 576 |
$message = request_var('message', ''); |
|---|
| 577 |
|
|---|
| 578 |
$poll_title = ( isset($_POST['poll_title']) && $is_auth['auth_pollcreate'] ) ? request_var('poll_title', '') : ''; |
|---|
| 579 |
$poll_options = ( isset($_POST['poll_option_text']) && $is_auth['auth_pollcreate'] ) ? request_var('poll_option_text', array(0 => '') ) : ''; |
|---|
| 580 |
$poll_length = ( isset($_POST['poll_length']) && $is_auth['auth_pollcreate'] ) ? request_var('poll_length', 0) : ''; |
|---|
| 581 |
|
|---|
| 582 |
$time2merge = intval($config['time_to_merge']) * 3600; |
|---|
| 583 |
|
|---|
| 584 |
if ( ($mode == 'reply') && ($userdata['uid'] != ANONYMOUS) ) |
|---|
| 585 |
{ |
|---|
| 586 |
$sql = "SELECT p.post_id, p.poster_id, p.post_created, pt.post_text FROM " . POSTS_TABLE . " p, ". POSTS_TEXT_TABLE ." pt WHERE p.topic_id = $topic_id AND pt.post_id = p.post_id ORDER BY post_time DESC LIMIT 1"; |
|---|
| 587 |
$result = $db->sql_query($sql); |
|---|
| 588 |
|
|---|
| 589 |
$last_post_data = $db->sql_fetchrow($result); |
|---|
| 590 |
$last_post_id = $last_post_data['post_id']; |
|---|
| 591 |
$last_poster = $last_post_data['poster_id']; |
|---|
| 592 |
$last_post_created = $last_post_data['post_created']; |
|---|
| 593 |
$last_post_text = $last_post_data['post_text']; |
|---|
| 594 |
|
|---|
| 595 |
if ( ($last_poster == $userdata['uid']) && ((time() - $last_post_created) < $time2merge) && (!check_mod_tags($is_auth['auth_mod'], $last_post_text)) ) |
|---|
| 596 |
{ |
|---|
| 597 |
$merge = true; |
|---|
| 598 |
} |
|---|
| 599 |
|
|---|
| 600 |
$db->sql_freeresult($result); |
|---|
| 601 |
} |
|---|
| 602 |
|
|---|
| 603 |
if ( !$merge ) |
|---|
| 604 |
{ |
|---|
| 605 |
|
|---|
| 606 |
prepare_post($mode, $post_data, $bbcode_on, $html_on, $smilies_on, $error_msg, $username, $subject, $message, $poll_title, $poll_options, $poll_length); |
|---|
| 607 |
|
|---|
| 608 |
if ( $error_msg == '' ) |
|---|
| 609 |
{ |
|---|
| 610 |
$topic_type = ( $topic_type != $post_data['topic_type'] && !$is_auth['auth_sticky'] && !$is_auth['auth_announce'] ) ? $post_data['topic_type'] : $topic_type; |
|---|
| 611 |
|
|---|
| 612 |
submit_post($mode, $post_data, $return_message, $return_meta, $forum_id, $topic_id, $post_id, $poll_id, $topic_type, $bbcode_on, $html_on, $smilies_on, $attach_sig, str_replace("\'", "''", $username), str_replace("\'", "''", $subject), str_replace("\'", "''", $message), str_replace("\'", "''", $poll_title), $poll_options, $poll_length, $topic_first_post_sticky); |
|---|
| 613 |
} |
|---|
| 614 |
} |
|---|
| 615 |
else |
|---|
| 616 |
{ |
|---|
| 617 |
$error_msg = ''; |
|---|
| 618 |
submit_merged_post($last_post_id, $forum_id, $subject, $message, $return_message, $return_meta); |
|---|
| 619 |
} |
|---|
| 620 |
break; |
|---|
| 621 |
|
|---|
| 622 |
case 'delete': |
|---|
| 623 |
case 'poll_delete': |
|---|
| 624 |
if ($error_msg != '') |
|---|
| 625 |
{ |
|---|
| 626 |
trigger_error($error_msg); |
|---|
| 627 |
} |
|---|
| 628 |
delete_post($mode, $post_data, $return_message, $return_meta, $forum_id, $topic_id, $post_id, $poll_id); |
|---|
| 629 |
break; |
|---|
| 630 |
} |
|---|
| 631 |
|
|---|
| 632 |
if ( $error_msg == '' ) |
|---|
| 633 |
{ |
|---|
| 634 |
if ( $mode != 'editpost' && (!$merge)) |
|---|
| 635 |
{ |
|---|
| 636 |
$user_id = ( $mode == 'reply' || $mode == 'newtopic' ) ? $userdata['uid'] : $post_data['poster_id']; |
|---|
| 637 |
update_post_stats($mode, $post_data, $forum_id, $topic_id, $post_id, $user_id); |
|---|
| 638 |
} |
|---|
| 639 |
|
|---|
| 640 |
if ($error_msg == '' && $mode != 'poll_delete' && (!$merge)) |
|---|
| 641 |
{ |
|---|
| 642 |
user_notification($notify_user, TYPE_FORUM_POST, array('mode' => $mode, 'topic_title' => $post_info['topic_title'], 'topic_id' => $topic_id, 'post_id' => $post_id)); |
|---|
| 643 |
} |
|---|
| 644 |
|
|---|
| 645 |
|
|---|
| 646 |
{ |
|---|
| 647 |
$tracking_topics = ( !empty($_COOKIE[$config['cookie_name'] . '_t']) ) ? unserialize($_COOKIE[$config['cookie_name'] . '_t']) : array(); |
|---|
| 648 |
$tracking_forums = ( !empty($_COOKIE[$config['cookie_name'] . '_f']) ) ? unserialize($_COOKIE[$config['cookie_name'] . '_f']) : array(); |
|---|
| 649 |
|
|---|
| 650 |
if ( count($tracking_topics) + count($tracking_forums) == 100 && empty($tracking_topics[$topic_id]) ) |
|---|
| 651 |
{ |
|---|
| 652 |
asort($tracking_topics); |
|---|
| 653 |
unset($tracking_topics[key($tracking_topics)]); |
|---|
| 654 |
} |
|---|
| 655 |
|
|---|
| 656 |
$tracking_topics[$topic_id] = time(); |
|---|
| 657 |
|
|---|
| 658 |
set_cookie('t', serialize($tracking_topics)); |
|---|
| 659 |
}*/ |
|---|
| 660 |
|
|---|
| 661 |
$template->assign_vars(array( |
|---|
| 662 |
'META' => $return_meta |
|---|
| 663 |
)); |
|---|
| 664 |
trigger_error($return_message); |
|---|
| 665 |
return; |
|---|
| 666 |
} |
|---|
| 667 |
} |
|---|
| 668 |
|
|---|
| 669 |
if( $refresh || isset($_POST['del_poll_option']) || $error_msg != '' ) |
|---|
| 670 |
{ |
|---|
| 671 |
$username = request_var('username', ''); |
|---|
| 672 |
$subject = request_var('subject', ''); |
|---|
| 673 |
$message = request_var('message', ''); |
|---|
| 674 |
|
|---|
| 675 |
$poll_title = request_var('poll_title', ''); |
|---|
| 676 |
$poll_length = request_var('poll_length', 0); |
|---|
| 677 |
$poll_option_text = request_var('poll_option_text', array( 0 => '' ) ); |
|---|
| 678 |
$poll_options = array(); |
|---|
| 679 |
|
|---|
| 680 |
foreach ( $poll_option_text AS $option_id => $option_text ) { |
|---|
| 681 |
if( isset($_POST['del_poll_option'][$option_id]) ) |
|---|
| 682 |
{ |
|---|
| 683 |
unset($poll_option_text[$option_id]); |
|---|
| 684 |
} |
|---|
| 685 |
else if ( !empty($option_text) ) |
|---|
| 686 |
{ |
|---|
| 687 |
$poll_options[$option_id] = $option_text; |
|---|
| 688 |
} |
|---|
| 689 |
} |
|---|
| 690 |
|
|---|
| 691 |
if ( isset($poll_add) && isset($_POST['add_poll_option_text']) && !empty($_POST['add_poll_option_text']) ) |
|---|
| 692 |
{ |
|---|
| 693 |
$poll_options[] = request_var('add_poll_option_text', ''); |
|---|
| 694 |
} |
|---|
| 695 |
|
|---|
| 696 |
if ( $mode == 'newtopic' || $mode == 'reply') |
|---|
| 697 |
{ |
|---|
| 698 |
$user_sig = ( $userdata['user_sig'] != '' && $config['allow_sig'] ) ? $userdata['user_sig'] : ''; |
|---|
| 699 |
} |
|---|
| 700 |
else if ( $mode == 'editpost' ) |
|---|
| 701 |
{ |
|---|
| 702 |
$user_sig = ( $post_info['user_sig'] != '' && $config['allow_sig'] ) ? $post_info['user_sig'] : ''; |
|---|
| 703 |
} |
|---|
| 704 |
|
|---|
| 705 |
if( $preview ) |
|---|
| 706 |
{ |
|---|
| 707 |
|
|---|
| 708 |
$bb_code = new bbcode; |
|---|
| 709 |
|
|---|
| 710 |
$preview_message = prepare_message(unprepare_message($message), $html_on, $bbcode_on, $smilies_on); |
|---|
| 711 |
$preview_subject = $subject; |
|---|
| 712 |
$preview_username = $username; |
|---|
| 713 |
|
|---|
| 714 |
// Tags [mod] [/mod] are prohibited for everyone except moderators and administrators (preview) |
|---|
| 715 |
if ( check_mod_tags($is_auth['auth_mod'], $preview_message) ) |
|---|
| 716 |
{ |
|---|
| 717 |
trigger_error($lang['mod_reserved']); |
|---|
| 718 |
return; |
|---|
| 719 |
} |
|---|
| 720 |
|
|---|
| 721 |
|
|---|
| 722 |
// |
|---|
| 723 |
// Finalise processing as per viewtopic |
|---|
| 724 |
// |
|---|
| 725 |
$user_sig = ( $config['allow_sig'] == 2 ) ? preg_replace ('#((\r)+?(\n)+?)*(\[url(.*)\])?\[img\](.+)\[/img\](\[/url\])?#i', '', $user_sig) : $user_sig ; |
|---|
| 726 |
if( !$html_on ) |
|---|
| 727 |
{ |
|---|
| 728 |
if( $user_sig != '' ) |
|---|
| 729 |
{ |
|---|
| 730 |
$user_sig = preg_replace('#(<)([\/]?.*?)(>)#is', '<\2>', $user_sig); |
|---|
| 731 |
} |
|---|
| 732 |
} |
|---|
| 733 |
|
|---|
| 734 |
if( $attach_sig && $user_sig != '' ) |
|---|
| 735 |
{ |
|---|
| 736 |
$bb_code->parse($user_sig); |
|---|
| 737 |
$user_sig = $bb_code->get_html(); |
|---|
| 738 |
} |
|---|
| 739 |
|
|---|
| 740 |
if( $bbcode_on ) |
|---|
| 741 |
{ |
|---|
| 742 |
$bb_code->parse($preview_message); |
|---|
| 743 |
$preview_message = $bb_code->get_html(); |
|---|
| 744 |
} |
|---|
| 745 |
|
|---|
| 746 |
|
|---|
| 747 |
|
|---|
| 748 |
$preview_username = censor_text($preview_username); |
|---|
| 749 |
$preview_subject = censor_text($preview_subject); |
|---|
| 750 |
$preview_message = censor_text($preview_message); |
|---|
| 751 |
|
|---|
| 752 |
if( $attach_sig && $user_sig != '' ) |
|---|
| 753 |
{ |
|---|
| 754 |
$preview_message = $preview_message . '<br /><br />_________________<br />' . $user_sig; |
|---|
| 755 |
} |
|---|
| 756 |
|
|---|
| 757 |
|
|---|
| 758 |
|
|---|
| 759 |
$template->set_filenames(array( |
|---|
| 760 |
'preview' => 'forum/posting_preview.tpl') |
|---|
| 761 |
); |
|---|
| 762 |
|
|---|
| 763 |
$template->assign_vars(array( |
|---|
| 764 |
'TOPIC_TITLE' => $preview_subject, |
|---|
| 765 |
'POST_SUBJECT' => $preview_subject, |
|---|
| 766 |
'POSTER_NAME' => $preview_username, |
|---|
| 767 |
'POST_DATE' => create_date(time()), |
|---|
| 768 |
'MESSAGE' => $preview_message ) |
|---|
| 769 |
|
|---|
| 770 |
); |
|---|
| 771 |
$tpl = $template->assign_display('preview'); |
|---|
| 772 |
$template->assign_vars(array( |
|---|
| 773 |
'POST_PREVIEW_BOX' => $tpl) |
|---|
| 774 |
); |
|---|
| 775 |
} |
|---|
| 776 |
else if( $error_msg != '' ) |
|---|
| 777 |
{ |
|---|
| 778 |
$template->set_filenames(array( |
|---|
| 779 |
'reg_header' => 'forum/error_body.tpl') |
|---|
| 780 |
); |
|---|
| 781 |
$template->assign_vars(array( |
|---|
| 782 |
'ERROR_MESSAGE' => $error_msg) |
|---|
| 783 |
); |
|---|
| 784 |
$tpl = $template->assign_display('reg_header'); |
|---|
| 785 |
$template->assign_vars(array( |
|---|
| 786 |
'ERROR_BOX' => $tpl) |
|---|
| 787 |
); |
|---|
| 788 |
} |
|---|
| 789 |
} |
|---|
| 790 |
else |
|---|
| 791 |
{ |
|---|
| 792 |
|
|---|
| 793 |
// User default entry point |
|---|
| 794 |
// |
|---|
| 795 |
if ( $mode == 'newtopic' ) |
|---|
| 796 |
{ |
|---|
| 797 |
$user_sig = ( $userdata['user_sig'] != '' ) ? $userdata['user_sig'] : ''; |
|---|
| 798 |
|
|---|
| 799 |
$username = ($userdata['session_logged_in']) ? $userdata['name'] : ''; |
|---|
| 800 |
$poll_title = ''; |
|---|
| 801 |
$poll_length = ''; |
|---|
| 802 |
$subject = ''; |
|---|
| 803 |
$message = ''; |
|---|
| 804 |
} |
|---|
| 805 |
else if ( $mode == 'reply' ) |
|---|
| 806 |
{ |
|---|
| 807 |
$user_sig = ( $userdata['user_sig'] != '' ) ? $userdata['user_sig'] : ''; |
|---|
| 808 |
|
|---|
| 809 |
$username = ( $userdata['session_logged_in'] ) ? $userdata['name'] : ''; |
|---|
| 810 |
$subject = ''; |
|---|
| 811 |
$message = ''; |
|---|
| 812 |
|
|---|
| 813 |
} |
|---|
| 814 |
else if ( $mode == 'quote' || $mode == 'editpost' ) |
|---|
| 815 |
{ |
|---|
| 816 |
$subject = ( $post_data['first_post'] ) ? $post_info['topic_title'] : $post_info['post_subject']; |
|---|
| 817 |
$message = $post_info['post_text']; |
|---|
| 818 |
$username = ''; |
|---|
| 819 |
|
|---|
| 820 |
if ( $mode == 'editpost' ) |
|---|
| 821 |
{ |
|---|
| 822 |
$attach_sig = ( $post_info['enable_sig'] && $post_info['user_sig'] != '' ) ? TRUE : 0; |
|---|
| 823 |
$user_sig = $post_info['user_sig']; |
|---|
| 824 |
|
|---|
| 825 |
$html_on = ( $post_info['enable_html'] ) ? true : false; |
|---|
| 826 |
$bbcode_on = ( $post_info['enable_bbcode'] ) ? true : false; |
|---|
| 827 |
$smilies_on = ( $post_info['enable_smilies'] ) ? true : false; |
|---|
| 828 |
|
|---|
| 829 |
// Ordinary users can't edit moderated posts |
|---|
| 830 |
if ( check_mod_tags($is_auth['auth_mod'], $message) ) |
|---|
| 831 |
{ |
|---|
| 832 |
trigger_error($lang['mod_no_edit']); |
|---|
| 833 |
return; |
|---|
| 834 |
} |
|---|
| 835 |
|
|---|
| 836 |
} |
|---|
| 837 |
else |
|---|
| 838 |
{ |
|---|
| 839 |
$attach_sig = ( $userdata['user_sig'] != '' ) ? TRUE : 0; |
|---|
| 840 |
$user_sig = $userdata['user_sig']; |
|---|
| 841 |
} |
|---|
| 842 |
|
|---|
| 843 |
$message = str_replace('<', '<', $message); |
|---|
| 844 |
$message = str_replace('>', '>', $message); |
|---|
| 845 |
$message = str_replace('<br />', "\n", $message); |
|---|
| 846 |
|
|---|
| 847 |
if ( $mode == 'quote' ) |
|---|
| 848 |
{ |
|---|
| 849 |
$msg_date = create_date($post_info['post_time']); |
|---|
| 850 |
|
|---|
| 851 |
|
|---|
| 852 |
$quote_username = ( trim($post_info['post_username']) != '' ) ? $post_info['post_username'] : $post_info['username']; |
|---|
| 853 |
$message = '[quote="' . $quote_username . '"]' . $message . '[/quote]'; |
|---|
| 854 |
|
|---|
| 855 |
|
|---|
| 856 |
// Remove mod tags when quoting |
|---|
| 857 |
if ( !empty($message) ) |
|---|
| 858 |
{ |
|---|
| 859 |
$message = preg_replace("/\[mod.*?\].*?\[\/mod.*?\]/si", '', $message); |
|---|
| 860 |
} |
|---|
| 861 |
|
|---|
| 862 |
|
|---|
| 863 |
if ( !preg_match('/^Re:/', $subject) && strlen($subject) > 0 ) |
|---|
| 864 |
{ |
|---|
| 865 |
$subject = 'Re: ' . $subject; |
|---|
| 866 |
} |
|---|
| 867 |
|
|---|
| 868 |
$mode = 'reply'; |
|---|
| 869 |
} |
|---|
| 870 |
else |
|---|
| 871 |
{ |
|---|
| 872 |
$username = ( $post_info['uid'] == ANONYMOUS && !empty($post_info['post_username']) ) ? $post_info['post_username'] : ''; |
|---|
| 873 |
} |
|---|
| 874 |
} |
|---|
| 875 |
} |
|---|
| 876 |
|
|---|
| 877 |
|
|---|
| 878 |
<span class="code-comment">// Signature toggle selection |
|---|
| 879 |
// |
|---|
| 880 |
if( $user_sig != '' )</span> |
|---|
| 881 |
<span class="code-keyword">{ |
|---|
| 882 |
$template->assign_block_vars('switch_signature_checkbox', array()); |
|---|
| 883 |
} |
|---|
| 884 |
|
|---|
| 885 |
|
|---|
| 886 |
<span class="code-comment">// HTML toggle selection |
|---|
| 887 |
// |
|---|
| 888 |
if ( $config['allow_html'] )</span> |
|---|
| 889 |
<span class="code-keyword">{ |
|---|
| 890 |
$html_status = $lang['html_is_on']; |
|---|
| 891 |
$template->assign_block_vars('switch_html_checkbox', array()); |
|---|
| 892 |
} |
|---|
| 893 |
else |
|---|
| 894 |
{ |
|---|
| 895 |
$html_status = $lang['html_is_off']; |
|---|
| 896 |
} |
|---|
| 897 |
|
|---|
| 898 |
|
|---|
| 899 |
<span class="code-comment">// BBCode toggle selection |
|---|
| 900 |
// |
|---|
| 901 |
if ( $config['allow_bbcode'] )</span> |
|---|
| 902 |
<span class="code-keyword">{ |
|---|
| 903 |
$bbcode_status = $lang['bbcode_is_on']; |
|---|
| 904 |
$template->assign_block_vars('switch_bbcode_checkbox', array()); |
|---|
| 905 |
} |
|---|
| 906 |
else |
|---|
| 907 |
{ |
|---|
| 908 |
$bbcode_status = $lang['bbcode_is_off']; |
|---|
| 909 |
} |
|---|
| 910 |
|
|---|
| 911 |
|
|---|
| 912 |
<span class="code-comment">// Smilies toggle selection |
|---|
| 913 |
// |
|---|
| 914 |
if ( $config['allow_smilies'] )</span> |
|---|
| 915 |
<span class="code-keyword">{ |
|---|
| 916 |
$smilies_status = $lang['smilies_are_on']; |
|---|
| 917 |
$template->assign_block_vars('switch_smilies_checkbox', array()); |
|---|
| 918 |
} |
|---|
| 919 |
else |
|---|
| 920 |
{ |
|---|
| 921 |
$smilies_status = $lang['smilies_are_off']; |
|---|
| 922 |
} |
|---|
| 923 |
|
|---|
| 924 |
if( !$userdata['session_logged_in'] || ( $mode == 'editpost' && $post_info['poster_id'] == ANONYMOUS ) ) |
|---|
| 925 |
{ |
|---|
| 926 |
$template->assign_block_vars('switch_username_select', array()); |
|---|
| 927 |
} |
|---|
| 928 |
|
|---|
| 929 |
|
|---|
| 930 |
<span class="code-comment">// Notify checkbox - only show if user is logged in |
|---|
| 931 |
// |
|---|
| 932 |
if ( $userdata['session_logged_in'] && $is_auth['auth_read'] )</span> |
|---|
| 933 |
<span class="code-keyword">{ |
|---|
| 934 |
if ( $mode != 'editpost' || ( $mode == 'editpost' && $post_info['poster_id'] != ANONYMOUS ) ) |
|---|
| 935 |
{ |
|---|
| 936 |
$template->assign_block_vars('switch_notify_checkbox', array()); |
|---|
| 937 |
} |
|---|
| 938 |
} |
|---|
| 939 |
|
|---|
| 940 |
|
|---|
| 941 |
<span class="code-comment">// Delete selection |
|---|
| 942 |
// |
|---|
| 943 |
if ( $mode == 'editpost' && ( ( $is_auth['auth_delete'] && $post_data['last_post'] && ( !$post_data['has_poll'] || $post_data['edit_poll'] ) ) || $is_auth['auth_mod'] ) )</span> |
|---|
| 944 |
<span class="code-keyword">{ |
|---|
| 945 |
$template->assign_block_vars('switch_delete_checkbox', array()); |
|---|
| 946 |
} |
|---|
| 947 |
|
|---|
| 948 |
|
|---|
| 949 |
<span class="code-comment">// Topic type selection |
|---|
| 950 |
// |
|---|
| 951 |
$topic_type_toggle = '';</span> |
|---|
| 952 |
<span class="code-lang">if ( $mode == 'newtopic' || ( $mode == 'editpost' && $post_data['first_post'] ) ) |
|---|
| 953 |
{ |
|---|
| 954 |
$template->assign_block_vars('switch_type_toggle', array()); |
|---|
| 955 |
|
|---|
| 956 |
if( $is_auth['auth_sticky'] ) |
|---|
| 957 |
{ |
|---|
| 958 |
$topic_type_toggle .= '<input type="radio" name="topictype" value="' . POST_STICKY . '"'; |
|---|
| 959 |
if ( $post_data['topic_type'] == POST_STICKY || $topic_type == POST_STICKY ) |
|---|
| 960 |
{ |
|---|
| 961 |
$topic_type_toggle .= ' checked="checked"'; |
|---|
| 962 |
} |
|---|
| 963 |
$topic_type_toggle .= ' /> ' . $lang['post_sticky'] . ' '; |
|---|
| 964 |
|
|---|
| 965 |
} |
|---|
| 966 |
|
|---|
| 967 |
if( $is_auth['auth_announce'] ) |
|---|
| 968 |
{ |
|---|
| 969 |
$topic_type_toggle .= '<input type="radio" name="topictype" value="' . POST_ANNOUNCE . '"'; |
|---|
| 970 |
if ( $post_data['topic_type'] == POST_ANNOUNCE || $topic_type == POST_ANNOUNCE ) |
|---|
| 971 |
{ |
|---|
| 972 |
$topic_type_toggle .= ' checked="checked"'; |
|---|
| 973 |
} |
|---|
| 974 |
$topic_type_toggle .= ' /> ' . $lang['post_announcement'] . ' '; |
|---|
| 975 |
} |
|---|
| 976 |
|
|---|
| 977 |
if ( $topic_type_toggle != '' ) |
|---|
| 978 |
{ |
|---|
| 979 |
$topic_type_toggle = $lang['post_topic_as'] . ': <input type="radio" name="topictype" value="' . POST_NORMAL .'"' . ( ( $post_data['topic_type'] == POST_NORMAL || $topic_type == POST_NORMAL ) ? ' checked="checked"' : '' ) . ' /> ' . $lang['post_normal'] . ' ' . $topic_type_toggle; |
|---|
| 980 |
} |
|---|
| 981 |
|
|---|
| 982 |
if( $is_auth['auth_sticky'] ) { |
|---|
| 983 |
|
|---|
| 984 |
$topic_type_toggle .= '<br /><input type="checkbox" name="topic_first_post_sticky" value="1"' . ( $post_data['topic_first_post_sticky'] ? ' checked="checked"' : '' ) . ' /> ' . $lang['topic_first_post_sticky']; |
|---|
| 985 |
} |
|---|
| 986 |
} |
|---|
| 987 |
|
|---|
| 988 |
$hidden_form_fields = '<input type="hidden" name="mode" value="' . $mode . '" />'; |
|---|
| 989 |
$hidden_form_fields .= '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" />';</span> |
|---|
| 990 |
<span class="code-lang"> |
|---|
| 991 |
|
|---|
| 992 |
switch( $mode ) |
|---|
| 993 |
{ |
|---|
| 994 |
case 'newtopic': |
|---|
| 995 |
$page_title = $lang['post_a_new_topic']; |
|---|
| 996 |
$hidden_form_fields .= '<input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '" />'; |
|---|
| 997 |
break; |
|---|
| 998 |
|
|---|
| 999 |
case 'reply': |
|---|
| 1000 |
$page_title = $lang['post_a_reply']; |
|---|
| 1001 |
$hidden_form_fields .= '<input type="hidden" name="' . POST_TOPIC_URL . '" value="' . $topic_id . '" />'; |
|---|
| 1002 |
break; |
|---|
| 1003 |
|
|---|
| 1004 |
case 'editpost': |
|---|
| 1005 |
$page_title = $lang['edit_post']; |
|---|
| 1006 |
$hidden_form_fields .= '<input type="hidden" name="' . POST_POST_URL . '" value="' . $post_id . '" />'; |
|---|
| 1007 |
break; |
|---|
| 1008 |
} |
|---|
| 1009 |
|
|---|
| 1010 |
|
|---|
| 1011 |
generate_smilies('inline'); |
|---|
| 1012 |
|
|---|
| 1013 |
|
|---|
| 1014 |
<span class="code-comment">// Include page header |
|---|
| 1015 |
// |
|---|
| 1016 |
stdhead($lang['forums'] . ( isset($page_title) ? ' :: ' . $page_title : '' ), false); |
|---|
| 1017 |
|
|---|
| 1018 |
$template->set_filenames(array(</span> |
|---|
| 1019 |
<span class="code-lang"> 'pollbody' => 'forum/posting_poll_body.tpl', |
|---|
| 1020 |
'reviewbody' => 'forum/posting_topic_review.tpl') |
|---|
| 1021 |
); |
|---|
| 1022 |
|
|---|
| 1023 |
<span class="code-comment">// Begin Simple Subforums MOD |
|---|
| 1024 |
$all_forums = array(); |
|---|
| 1025 |
make_jumpbox_ref('phpbb2.php?page=viewforum', $forum_id, $all_forums); |
|---|
| 1026 |
|
|---|
| 1027 |
$parent_id = 0;</span> |
|---|
| 1028 |
<span class="code-lang">for( $i = 0; $i < count($all_forums); $i++ ) |
|---|
| 1029 |
{ |
|---|
| 1030 |
if( $all_forums[$i]['forum_id'] == $forum_id ) |
|---|
| 1031 |
{ |
|---|
| 1032 |
$parent_id = $all_forums[$i]['forum_parent']; |
|---|
| 1033 |
} |
|---|
| 1034 |
} |
|---|
| 1035 |
|
|---|
| 1036 |
if( $parent_id ) |
|---|
| 1037 |
{ |
|---|
| 1038 |
for( $i = 0; $i < count($all_forums); $i++) |
|---|
| 1039 |
{ |
|---|
| 1040 |
if( $all_forums[$i]['forum_id'] == $parent_id ) |
|---|
| 1041 |
{ |
|---|
| 1042 |
$template->assign_vars(array( |
|---|
| 1043 |
'PARENT_FORUM' => 1, |
|---|
| 1044 |
'U_VIEW_PARENT_FORUM' => append_sid($root_path . "phpbb2.php?page=viewforum&" . POST_FORUM_URL . "=" . $all_forums[$i]['forum_id']), |
|---|
| 1045 |
'PARENT_FORUM_NAME' => $all_forums[$i]['forum_name'], |
|---|
| 1046 |
)); |
|---|
| 1047 |
} |
|---|
| 1048 |
} |
|---|
| 1049 |
} |
|---|
| 1050 |
|
|---|
| 1051 |
Multi_BBCode(); |
|---|
| 1052 |
|
|---|
| 1053 |
$template->assign_vars(array(</span> |
|---|
| 1054 |
<span class="code-lang"> 'FORUM_NAME' => $forum_name, |
|---|
| 1055 |
'L_POST_A' => $page_title, |
|---|
| 1056 |
'U_VIEW_FORUM' => append_sid($root_path . "phpbb2.php?page=viewforum&" . POST_FORUM_URL . "=$forum_id")) |
|---|
| 1057 |
); |
|---|
| 1058 |
|
|---|
| 1059 |
|
|---|
| 1060 |
<span class="code-comment">// Output the data to the template |
|---|
| 1061 |
// |
|---|
| 1062 |
$template->assign_vars(array(</span> |
|---|
| 1063 |
<span class="code-lang"> |
|---|
| 1064 |
'EDITOR_NAME' => $userdata['name'], |
|---|
| 1065 |
|
|---|
| 1066 |
'USERNAME' => $username, |
|---|
| 1067 |
'SUBJECT' => $subject, |
|---|
| 1068 |
'MESSAGE' => $message, |
|---|
| 1069 |
'HTML_STATUS' => $html_status, |
|---|
| 1070 |
'SMILIES_STATUS' => $smilies_status, |
|---|
| 1071 |
'BBCODE_STATUS' => $bbcode_status, |
|---|
| 1072 |
'L_DISABLE_HTML' => $lang['disable_html_post'], |
|---|
| 1073 |
'L_DISABLE_BBCODE' => $lang['disable_bbcode_post'], |
|---|
| 1074 |
'L_DISABLE_SMILIES' => $lang['disable_smilies_post'], |
|---|
| 1075 |
'L_NOTIFY_ON_REPLY' => $lang['notify'], |
|---|
| 1076 |
|
|---|
| 1077 |
'L_BBCODE_CLOSE_TAGS' => $lang['close_tags'], |
|---|
| 1078 |
|
|---|
| 1079 |
|
|---|
| 1080 |
'U_VIEWTOPIC' => ( $mode == 'reply' ) ? append_sid($root_path . "phpbb2.php?page=viewtopic&" . POST_TOPIC_URL . "=$topic_id&postorder=desc") : '', |
|---|
| 1081 |
|
|---|
| 1082 |
//FIXME: |
|---|
| 1083 |
'U_REVIEW_TOPIC' => ( $mode == 'reply' ) ? append_sid($root_path . "phpbb2.php?page=posting&mode=topicreview&" . POST_TOPIC_URL . "=$topic_id") : '', |
|---|
| 1084 |
'S_HTML_CHECKED' => ( !$html_on ) ? 'checked="checked"' : '', |
|---|
| 1085 |
'S_BBCODE_CHECKED' => ( !$bbcode_on ) ? 'checked="checked"' : '', |
|---|
| 1086 |
'S_SMILIES_CHECKED' => ( !$smilies_on ) ? 'checked="checked"' : '', |
|---|
| 1087 |
'S_SIGNATURE_CHECKED' => ( $attach_sig ) ? 'checked="checked"' : '', |
|---|
| 1088 |
'S_NOTIFY_CHECKED' => ( $notify_user ) ? 'checked="checked"' : '', |
|---|
| 1089 |
'S_TYPE_TOGGLE' => $topic_type_toggle, |
|---|
| 1090 |
'S_TOPIC_ID' => $topic_id, |
|---|
| 1091 |
|
|---|
| 1092 |
'S_POST_ACTION' => append_sid($root_path . "phpbb2.php?page=posting"), |
|---|
| 1093 |
'S_HIDDEN_FORM_FIELDS' => $hidden_form_fields) |
|---|
| 1094 |
); |
|---|
| 1095 |
|
|---|
| 1096 |
|
|---|
| 1097 |
<span class="code-comment">// Output the data to the template (for MAIL.RU Keyboard) |
|---|
| 1098 |
// |
|---|
| 1099 |
$template->assign_vars(array(</span> |
|---|
| 1100 |
<span class="code-lang"> 'S_VISIBILITY_RULES' => 'position:absolute;visibility:hidden;', |
|---|
| 1101 |
'S_VISIBILITY_KEYB' => 'position:absolute;visibility:hidden;', |
|---|
| 1102 |
'S_VISIBILITY_OFF' => '') |
|---|
| 1103 |
); |
|---|
| 1104 |
|
|---|
| 1105 |
|
|---|
| 1106 |
<span class="code-comment">// Poll entry switch/output |
|---|
| 1107 |
// |
|---|
| 1108 |
if( ( $mode == 'newtopic' || ( $mode == 'editpost' && $post_data['edit_poll']) ) && $is_auth['auth_pollcreate'] )</span> |
|---|
| 1109 |
<span class="code-keyword">{ |
|---|
| 1110 |
$template->assign_vars(array( |
|---|
| 1111 |
'L_ADD_A_POLL' => $lang['add_poll'], |
|---|
| 1112 |
'L_UPDATE_OPTION' => $lang['update'], |
|---|
| 1113 |
'L_DELETE_OPTION' => $lang['delete'], |
|---|
| 1114 |
'L_POLL_LENGTH' => $lang['poll_for'], |
|---|
| 1115 |
'L_POLL_LENGTH_EXPLAIN' => $lang['poll_for_explain'], |
|---|
| 1116 |
'L_POLL_DELETE' => $lang['delete_poll'], |
|---|
| 1117 |
|
|---|
| 1118 |
'POLL_TITLE' => $poll_title, |
|---|
| 1119 |
'POLL_LENGTH' => $poll_length) |
|---|
| 1120 |
); |
|---|
| 1121 |
|
|---|
| 1122 |
if( $mode == 'editpost' && $post_data['edit_poll'] && $post_data['has_poll']) |
|---|
| 1123 |
{ |
|---|
| 1124 |
$template->assign_block_vars('switch_poll_delete_toggle', array()); |
|---|
| 1125 |
} |
|---|
| 1126 |
|
|---|
| 1127 |
if( !empty($poll_options) ) |
|---|
| 1128 |
{ |
|---|
| 1129 |
while( list($option_id, $option_text) = each($poll_options) ) |
|---|
| 1130 |
{ |
|---|
| 1131 |
$template->assign_block_vars('poll_option_rows', array( |
|---|
| 1132 |
'POLL_OPTION' => str_replace('"', '"', $option_text), |
|---|
| 1133 |
|
|---|
| 1134 |
'S_POLL_OPTION_NUM' => $option_id) |
|---|
| 1135 |
); |
|---|
| 1136 |
} |
|---|
| 1137 |
} |
|---|
| 1138 |
|
|---|
| 1139 |
$tpl = $template->assign_display('pollbody'); |
|---|
| 1140 |
$template->assign_vars(array( |
|---|
| 1141 |
'POLLBOX' => $tpl) |
|---|
| 1142 |
); |
|---|
| 1143 |
} |
|---|
| 1144 |
|
|---|
| 1145 |
|
|---|
| 1146 |
<span class="code-comment">// Topic review |
|---|
| 1147 |
// |
|---|
| 1148 |
if( $mode == 'reply' && $is_auth['auth_read'] )</span> |
|---|
| 1149 |
<span class="code-keyword">{ |
|---|
| 1150 |
require($root_path . 'phpBB2/includes/topic_review.'.$phpEx); |
|---|
| 1151 |
topic_review($topic_id, true); |
|---|
| 1152 |
|
|---|
| 1153 |
$template->assign_block_vars('switch_inline_mode', array()); |
|---|
| 1154 |
$tpl = $template->assign_display('reviewbody'); |
|---|
| 1155 |
$template->assign_vars(array( |
|---|
| 1156 |
'TOPIC_REVIEW_BOX' => $tpl) |
|---|
| 1157 |
); |
|---|
| 1158 |
} |
|---|
| 1159 |
|
|---|
| 1160 |
$template->set_filenames(array(</span> |
|---|
| 1161 |
<span class="code-lang"> 'body' => 'forum/posting_body.tpl') |
|---|
| 1162 |
); |
|---|
| 1163 |
|
|---|
| 1164 |
return; |
|---|
| 1165 |
|
|---|
| 1166 |
?> |
|---|