@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Handles showing the post screen, loading the post to be modified, and loading any post quoted. |
@@ -35,12 +36,14 @@ discard block |
||
| 35 | 36 | global $sourcedir, $smcFunc, $language; |
| 36 | 37 | |
| 37 | 38 | loadLanguage('Post'); |
| 38 | - if (!empty($modSettings['drafts_post_enabled'])) |
|
| 39 | - loadLanguage('Drafts'); |
|
| 39 | + if (!empty($modSettings['drafts_post_enabled'])) { |
|
| 40 | + loadLanguage('Drafts'); |
|
| 41 | + } |
|
| 40 | 42 | |
| 41 | 43 | // You can't reply with a poll... hacker. |
| 42 | - if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg'])) |
|
| 43 | - unset($_REQUEST['poll']); |
|
| 44 | + if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg'])) { |
|
| 45 | + unset($_REQUEST['poll']); |
|
| 46 | + } |
|
| 44 | 47 | |
| 45 | 48 | // Posting an event? |
| 46 | 49 | $context['make_event'] = isset($_REQUEST['calendar']); |
@@ -58,12 +61,14 @@ discard block |
||
| 58 | 61 | { |
| 59 | 62 | // Get ids of all the boards they can post in. |
| 60 | 63 | $post_permissions = array('post_new'); |
| 61 | - if ($modSettings['postmod_active']) |
|
| 62 | - $post_permissions[] = 'post_unapproved_topics'; |
|
| 64 | + if ($modSettings['postmod_active']) { |
|
| 65 | + $post_permissions[] = 'post_unapproved_topics'; |
|
| 66 | + } |
|
| 63 | 67 | |
| 64 | 68 | $boards = boardsAllowedTo($post_permissions); |
| 65 | - if (empty($boards)) |
|
| 66 | - fatal_lang_error('cannot_post_new', false); |
|
| 69 | + if (empty($boards)) { |
|
| 70 | + fatal_lang_error('cannot_post_new', false); |
|
| 71 | + } |
|
| 67 | 72 | |
| 68 | 73 | // Get a list of boards for the select menu |
| 69 | 74 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
@@ -76,8 +81,9 @@ discard block |
||
| 76 | 81 | $board_list = getBoardList($boardListOptions); |
| 77 | 82 | } |
| 78 | 83 | // Let's keep things simple for ourselves below |
| 79 | - else |
|
| 80 | - $boards = array($board); |
|
| 84 | + else { |
|
| 85 | + $boards = array($board); |
|
| 86 | + } |
|
| 81 | 87 | |
| 82 | 88 | require_once($sourcedir . '/Subs-Post.php'); |
| 83 | 89 | |
@@ -100,10 +106,11 @@ discard block |
||
| 100 | 106 | array( |
| 101 | 107 | 'msg' => (int) $_REQUEST['msg'], |
| 102 | 108 | )); |
| 103 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
| 104 | - unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
|
| 105 | - else |
|
| 106 | - list ($topic) = $smcFunc['db_fetch_row']($request); |
|
| 109 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
| 110 | + unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
|
| 111 | + } else { |
|
| 112 | + list ($topic) = $smcFunc['db_fetch_row']($request); |
|
| 113 | + } |
|
| 107 | 114 | $smcFunc['db_free_result']($request); |
| 108 | 115 | } |
| 109 | 116 | |
@@ -130,33 +137,36 @@ discard block |
||
| 130 | 137 | $smcFunc['db_free_result']($request); |
| 131 | 138 | |
| 132 | 139 | // If this topic already has a poll, they sure can't add another. |
| 133 | - if (isset($_REQUEST['poll']) && $pollID > 0) |
|
| 134 | - unset($_REQUEST['poll']); |
|
| 140 | + if (isset($_REQUEST['poll']) && $pollID > 0) { |
|
| 141 | + unset($_REQUEST['poll']); |
|
| 142 | + } |
|
| 135 | 143 | |
| 136 | 144 | if (empty($_REQUEST['msg'])) |
| 137 | 145 | { |
| 138 | - if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) |
|
| 139 | - is_not_guest(); |
|
| 146 | + if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) { |
|
| 147 | + is_not_guest(); |
|
| 148 | + } |
|
| 140 | 149 | |
| 141 | 150 | // By default the reply will be approved... |
| 142 | 151 | $context['becomes_approved'] = true; |
| 143 | 152 | if ($id_member_poster != $user_info['id'] || $user_info['is_guest']) |
| 144 | 153 | { |
| 145 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
|
| 146 | - $context['becomes_approved'] = false; |
|
| 147 | - else |
|
| 148 | - isAllowedTo('post_reply_any'); |
|
| 149 | - } |
|
| 150 | - elseif (!allowedTo('post_reply_any')) |
|
| 154 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) { |
|
| 155 | + $context['becomes_approved'] = false; |
|
| 156 | + } else { |
|
| 157 | + isAllowedTo('post_reply_any'); |
|
| 158 | + } |
|
| 159 | + } elseif (!allowedTo('post_reply_any')) |
|
| 151 | 160 | { |
| 152 | - if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) |
|
| 153 | - $context['becomes_approved'] = false; |
|
| 154 | - else |
|
| 155 | - isAllowedTo('post_reply_own'); |
|
| 161 | + if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) { |
|
| 162 | + $context['becomes_approved'] = false; |
|
| 163 | + } else { |
|
| 164 | + isAllowedTo('post_reply_own'); |
|
| 165 | + } |
|
| 156 | 166 | } |
| 167 | + } else { |
|
| 168 | + $context['becomes_approved'] = true; |
|
| 157 | 169 | } |
| 158 | - else |
|
| 159 | - $context['becomes_approved'] = true; |
|
| 160 | 170 | |
| 161 | 171 | $context['can_lock'] = allowedTo('lock_any') || ($user_info['id'] == $id_member_poster && allowedTo('lock_own')); |
| 162 | 172 | $context['can_sticky'] = allowedTo('make_sticky'); |
@@ -171,17 +181,18 @@ discard block |
||
| 171 | 181 | $context['sticky'] = isset($_REQUEST['sticky']) ? !empty($_REQUEST['sticky']) : $sticky; |
| 172 | 182 | |
| 173 | 183 | // Check whether this is a really old post being bumped... |
| 174 | - if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) |
|
| 175 | - $post_errors[] = array('old_topic', array($modSettings['oldTopicDays'])); |
|
| 176 | - } |
|
| 177 | - else |
|
| 184 | + if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) { |
|
| 185 | + $post_errors[] = array('old_topic', array($modSettings['oldTopicDays'])); |
|
| 186 | + } |
|
| 187 | + } else |
|
| 178 | 188 | { |
| 179 | 189 | // @todo Should use JavaScript to hide and show the warning based on the selection in the board select menu |
| 180 | 190 | $context['becomes_approved'] = true; |
| 181 | - if ($modSettings['postmod_active'] && !allowedTo('post_new', $boards, true) && allowedTo('post_unapproved_topics', $boards, true)) |
|
| 182 | - $context['becomes_approved'] = false; |
|
| 183 | - else |
|
| 184 | - isAllowedTo('post_new', $boards, true); |
|
| 191 | + if ($modSettings['postmod_active'] && !allowedTo('post_new', $boards, true) && allowedTo('post_unapproved_topics', $boards, true)) { |
|
| 192 | + $context['becomes_approved'] = false; |
|
| 193 | + } else { |
|
| 194 | + isAllowedTo('post_new', $boards, true); |
|
| 195 | + } |
|
| 185 | 196 | |
| 186 | 197 | $locked = 0; |
| 187 | 198 | $context['already_locked'] = 0; |
@@ -211,27 +222,32 @@ discard block |
||
| 211 | 222 | if (empty($_REQUEST['message']) && empty($_REQUEST['preview']) && !empty($_SESSION['already_attached'])) |
| 212 | 223 | { |
| 213 | 224 | require_once($sourcedir . '/ManageAttachments.php'); |
| 214 | - foreach ($_SESSION['already_attached'] as $attachID => $attachment) |
|
| 215 | - removeAttachments(array('id_attach' => $attachID)); |
|
| 225 | + foreach ($_SESSION['already_attached'] as $attachID => $attachment) { |
|
| 226 | + removeAttachments(array('id_attach' => $attachID)); |
|
| 227 | + } |
|
| 216 | 228 | |
| 217 | 229 | unset($_SESSION['already_attached']); |
| 218 | 230 | } |
| 219 | 231 | |
| 220 | 232 | // Don't allow a post if it's locked and you aren't all powerful. |
| 221 | - if ($locked && !allowedTo('moderate_board')) |
|
| 222 | - fatal_lang_error('topic_locked', false); |
|
| 233 | + if ($locked && !allowedTo('moderate_board')) { |
|
| 234 | + fatal_lang_error('topic_locked', false); |
|
| 235 | + } |
|
| 223 | 236 | // Check the users permissions - is the user allowed to add or post a poll? |
| 224 | 237 | if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1') |
| 225 | 238 | { |
| 226 | 239 | // New topic, new poll. |
| 227 | - if (empty($topic)) |
|
| 228 | - isAllowedTo('poll_post'); |
|
| 240 | + if (empty($topic)) { |
|
| 241 | + isAllowedTo('poll_post'); |
|
| 242 | + } |
|
| 229 | 243 | // This is an old topic - but it is yours! Can you add to it? |
| 230 | - elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) |
|
| 231 | - isAllowedTo('poll_add_own'); |
|
| 244 | + elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) { |
|
| 245 | + isAllowedTo('poll_add_own'); |
|
| 246 | + } |
|
| 232 | 247 | // If you're not the owner, can you add to any poll? |
| 233 | - else |
|
| 234 | - isAllowedTo('poll_add_any'); |
|
| 248 | + else { |
|
| 249 | + isAllowedTo('poll_add_any'); |
|
| 250 | + } |
|
| 235 | 251 | |
| 236 | 252 | if (!empty($board)) |
| 237 | 253 | { |
@@ -240,8 +256,9 @@ discard block |
||
| 240 | 256 | $guest_vote_enabled = in_array(-1, $allowedVoteGroups['allowed']); |
| 241 | 257 | } |
| 242 | 258 | // No board, so we'll have to check this again in Post2 |
| 243 | - else |
|
| 244 | - $guest_vote_enabled = true; |
|
| 259 | + else { |
|
| 260 | + $guest_vote_enabled = true; |
|
| 261 | + } |
|
| 245 | 262 | |
| 246 | 263 | // Set up the poll options. |
| 247 | 264 | $context['poll_options'] = array( |
@@ -267,8 +284,9 @@ discard block |
||
| 267 | 284 | if ($context['make_event']) |
| 268 | 285 | { |
| 269 | 286 | // They might want to pick a board. |
| 270 | - if (!isset($context['current_board'])) |
|
| 271 | - $context['current_board'] = 0; |
|
| 287 | + if (!isset($context['current_board'])) { |
|
| 288 | + $context['current_board'] = 0; |
|
| 289 | + } |
|
| 272 | 290 | |
| 273 | 291 | // Start loading up the event info. |
| 274 | 292 | $context['event'] = array(); |
@@ -282,10 +300,11 @@ discard block |
||
| 282 | 300 | isAllowedTo('calendar_post'); |
| 283 | 301 | |
| 284 | 302 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
| 285 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
| 286 | - $time_string = '%k:%M'; |
|
| 287 | - else |
|
| 288 | - $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 303 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
| 304 | + $time_string = '%k:%M'; |
|
| 305 | + } else { |
|
| 306 | + $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 307 | + } |
|
| 289 | 308 | |
| 290 | 309 | $js_time_string = str_replace( |
| 291 | 310 | array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
@@ -307,8 +326,7 @@ discard block |
||
| 307 | 326 | require_once($sourcedir . '/Subs-Calendar.php'); |
| 308 | 327 | $eventProperties = getEventProperties($context['event']['id']); |
| 309 | 328 | $context['event'] = array_merge($context['event'], $eventProperties); |
| 310 | - } |
|
| 311 | - else |
|
| 329 | + } else |
|
| 312 | 330 | { |
| 313 | 331 | // Get the current event information. |
| 314 | 332 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -316,10 +334,12 @@ discard block |
||
| 316 | 334 | $context['event'] = array_merge($context['event'], $eventProperties); |
| 317 | 335 | |
| 318 | 336 | // Make sure the year and month are in the valid range. |
| 319 | - if ($context['event']['month'] < 1 || $context['event']['month'] > 12) |
|
| 320 | - fatal_lang_error('invalid_month', false); |
|
| 321 | - if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) |
|
| 322 | - fatal_lang_error('invalid_year', false); |
|
| 337 | + if ($context['event']['month'] < 1 || $context['event']['month'] > 12) { |
|
| 338 | + fatal_lang_error('invalid_month', false); |
|
| 339 | + } |
|
| 340 | + if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) { |
|
| 341 | + fatal_lang_error('invalid_year', false); |
|
| 342 | + } |
|
| 323 | 343 | |
| 324 | 344 | $context['event']['categories'] = $board_list; |
| 325 | 345 | } |
@@ -430,10 +450,11 @@ discard block |
||
| 430 | 450 | |
| 431 | 451 | if (!empty($context['new_replies'])) |
| 432 | 452 | { |
| 433 | - if ($context['new_replies'] == 1) |
|
| 434 | - $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
| 435 | - else |
|
| 436 | - $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
| 453 | + if ($context['new_replies'] == 1) { |
|
| 454 | + $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
| 455 | + } else { |
|
| 456 | + $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
| 457 | + } |
|
| 437 | 458 | |
| 438 | 459 | $post_errors[] = 'new_replies'; |
| 439 | 460 | |
@@ -445,9 +466,9 @@ discard block |
||
| 445 | 466 | // Get a response prefix (like 'Re:') in the default forum language. |
| 446 | 467 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
| 447 | 468 | { |
| 448 | - if ($language === $user_info['language']) |
|
| 449 | - $context['response_prefix'] = $txt['response_prefix']; |
|
| 450 | - else |
|
| 469 | + if ($language === $user_info['language']) { |
|
| 470 | + $context['response_prefix'] = $txt['response_prefix']; |
|
| 471 | + } else |
|
| 451 | 472 | { |
| 452 | 473 | loadLanguage('index', $language, false); |
| 453 | 474 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -460,23 +481,26 @@ discard block |
||
| 460 | 481 | // Do we have a body, but an error happened. |
| 461 | 482 | if (isset($_REQUEST['message']) || isset($_REQUEST['quickReply']) || !empty($context['post_error'])) |
| 462 | 483 | { |
| 463 | - if (isset($_REQUEST['quickReply'])) |
|
| 464 | - $_REQUEST['message'] = $_REQUEST['quickReply']; |
|
| 484 | + if (isset($_REQUEST['quickReply'])) { |
|
| 485 | + $_REQUEST['message'] = $_REQUEST['quickReply']; |
|
| 486 | + } |
|
| 465 | 487 | |
| 466 | 488 | // Validate inputs. |
| 467 | 489 | if (empty($context['post_error'])) |
| 468 | 490 | { |
| 469 | 491 | // This means they didn't click Post and get an error. |
| 470 | 492 | $really_previewing = true; |
| 471 | - } |
|
| 472 | - else |
|
| 493 | + } else |
|
| 473 | 494 | { |
| 474 | - if (!isset($_REQUEST['subject'])) |
|
| 475 | - $_REQUEST['subject'] = ''; |
|
| 476 | - if (!isset($_REQUEST['message'])) |
|
| 477 | - $_REQUEST['message'] = ''; |
|
| 478 | - if (!isset($_REQUEST['icon'])) |
|
| 479 | - $_REQUEST['icon'] = 'xx'; |
|
| 495 | + if (!isset($_REQUEST['subject'])) { |
|
| 496 | + $_REQUEST['subject'] = ''; |
|
| 497 | + } |
|
| 498 | + if (!isset($_REQUEST['message'])) { |
|
| 499 | + $_REQUEST['message'] = ''; |
|
| 500 | + } |
|
| 501 | + if (!isset($_REQUEST['icon'])) { |
|
| 502 | + $_REQUEST['icon'] = 'xx'; |
|
| 503 | + } |
|
| 480 | 504 | |
| 481 | 505 | // They are previewing if they asked to preview (i.e. came from quick reply). |
| 482 | 506 | $really_previewing = !empty($_POST['preview']); |
@@ -492,8 +516,9 @@ discard block |
||
| 492 | 516 | $form_message = $smcFunc['htmlspecialchars']($_REQUEST['message'], ENT_QUOTES); |
| 493 | 517 | |
| 494 | 518 | // Make sure the subject isn't too long - taking into account special characters. |
| 495 | - if ($smcFunc['strlen']($form_subject) > 100) |
|
| 496 | - $form_subject = $smcFunc['substr']($form_subject, 0, 100); |
|
| 519 | + if ($smcFunc['strlen']($form_subject) > 100) { |
|
| 520 | + $form_subject = $smcFunc['substr']($form_subject, 0, 100); |
|
| 521 | + } |
|
| 497 | 522 | |
| 498 | 523 | if (isset($_REQUEST['poll'])) |
| 499 | 524 | { |
@@ -505,8 +530,9 @@ discard block |
||
| 505 | 530 | $_POST['options'] = empty($_POST['options']) ? array() : htmlspecialchars__recursive($_POST['options']); |
| 506 | 531 | foreach ($_POST['options'] as $option) |
| 507 | 532 | { |
| 508 | - if (trim($option) == '') |
|
| 509 | - continue; |
|
| 533 | + if (trim($option) == '') { |
|
| 534 | + continue; |
|
| 535 | + } |
|
| 510 | 536 | |
| 511 | 537 | $context['choices'][] = array( |
| 512 | 538 | 'id' => $choice_id++, |
@@ -568,13 +594,14 @@ discard block |
||
| 568 | 594 | $context['preview_subject'] = $form_subject; |
| 569 | 595 | |
| 570 | 596 | censorText($context['preview_subject']); |
| 597 | + } else { |
|
| 598 | + $context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>'; |
|
| 571 | 599 | } |
| 572 | - else |
|
| 573 | - $context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>'; |
|
| 574 | 600 | |
| 575 | 601 | // Protect any CDATA blocks. |
| 576 | - if (isset($_REQUEST['xml'])) |
|
| 577 | - $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]><![CDATA[>')); |
|
| 602 | + if (isset($_REQUEST['xml'])) { |
|
| 603 | + $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]>< == 0) |
|
| 617 | - fatal_lang_error('no_board', false); |
|
| 643 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 644 | + fatal_lang_error('no_board', false); |
|
| 645 | + } |
|
| 618 | 646 | $row = $smcFunc['db_fetch_assoc']($request); |
| 619 | 647 | |
| 620 | 648 | $attachment_stuff = array($row); |
| 621 | - while ($row2 = $smcFunc['db_fetch_assoc']($request)) |
|
| 622 | - $attachment_stuff[] = $row2; |
|
| 649 | + while ($row2 = $smcFunc['db_fetch_assoc']($request)) { |
|
| 650 | + $attachment_stuff[] = $row2; |
|
| 651 | + } |
|
| 623 | 652 | $smcFunc['db_free_result']($request); |
| 624 | 653 | |
| 625 | 654 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
| 626 | 655 | { |
| 627 | 656 | // Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public. |
| 628 | - if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
| 629 | - fatal_lang_error('modify_post_time_passed', false); |
|
| 630 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) |
|
| 631 | - isAllowedTo('modify_replies'); |
|
| 632 | - else |
|
| 633 | - isAllowedTo('modify_own'); |
|
| 657 | + if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
| 658 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 659 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
| 660 | + isAllowedTo('modify_replies'); |
|
| 661 | + } else { |
|
| 662 | + isAllowedTo('modify_own'); |
|
| 663 | + } |
|
| 664 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
| 665 | + isAllowedTo('modify_replies'); |
|
| 666 | + } else { |
|
| 667 | + isAllowedTo('modify_any'); |
|
| 634 | 668 | } |
| 635 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 636 | - isAllowedTo('modify_replies'); |
|
| 637 | - else |
|
| 638 | - isAllowedTo('modify_any'); |
|
| 639 | 669 | |
| 640 | 670 | if ($context['can_announce'] && !empty($row['id_action'])) |
| 641 | 671 | { |
@@ -659,8 +689,9 @@ discard block |
||
| 659 | 689 | |
| 660 | 690 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 661 | 691 | { |
| 662 | - if ($row['filesize'] <= 0) |
|
| 663 | - continue; |
|
| 692 | + if ($row['filesize'] <= 0) { |
|
| 693 | + continue; |
|
| 694 | + } |
|
| 664 | 695 | $context['current_attachments'][$row['id_attach']] = array( |
| 665 | 696 | 'name' => $smcFunc['htmlspecialchars']($row['filename']), |
| 666 | 697 | 'size' => $row['filesize'], |
@@ -730,29 +761,32 @@ discard block |
||
| 730 | 761 | ) |
| 731 | 762 | ); |
| 732 | 763 | // The message they were trying to edit was most likely deleted. |
| 733 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 734 | - fatal_lang_error('no_message', false); |
|
| 764 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 765 | + fatal_lang_error('no_message', false); |
|
| 766 | + } |
|
| 735 | 767 | $row = $smcFunc['db_fetch_assoc']($request); |
| 736 | 768 | |
| 737 | 769 | $attachment_stuff = array($row); |
| 738 | - while ($row2 = $smcFunc['db_fetch_assoc']($request)) |
|
| 739 | - $attachment_stuff[] = $row2; |
|
| 770 | + while ($row2 = $smcFunc['db_fetch_assoc']($request)) { |
|
| 771 | + $attachment_stuff[] = $row2; |
|
| 772 | + } |
|
| 740 | 773 | $smcFunc['db_free_result']($request); |
| 741 | 774 | |
| 742 | 775 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
| 743 | 776 | { |
| 744 | 777 | // Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public. |
| 745 | - if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
| 746 | - fatal_lang_error('modify_post_time_passed', false); |
|
| 747 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) |
|
| 748 | - isAllowedTo('modify_replies'); |
|
| 749 | - else |
|
| 750 | - isAllowedTo('modify_own'); |
|
| 778 | + if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
| 779 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 780 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
| 781 | + isAllowedTo('modify_replies'); |
|
| 782 | + } else { |
|
| 783 | + isAllowedTo('modify_own'); |
|
| 784 | + } |
|
| 785 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
| 786 | + isAllowedTo('modify_replies'); |
|
| 787 | + } else { |
|
| 788 | + isAllowedTo('modify_any'); |
|
| 751 | 789 | } |
| 752 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 753 | - isAllowedTo('modify_replies'); |
|
| 754 | - else |
|
| 755 | - isAllowedTo('modify_any'); |
|
| 756 | 790 | |
| 757 | 791 | if ($context['can_announce'] && !empty($row['id_action'])) |
| 758 | 792 | { |
@@ -779,15 +813,17 @@ discard block |
||
| 779 | 813 | $context['icon'] = $row['icon']; |
| 780 | 814 | |
| 781 | 815 | // Show an "approve" box if the user can approve it, and the message isn't approved. |
| 782 | - if (!$row['approved'] && !$context['show_approval']) |
|
| 783 | - $context['show_approval'] = allowedTo('approve_posts'); |
|
| 816 | + if (!$row['approved'] && !$context['show_approval']) { |
|
| 817 | + $context['show_approval'] = allowedTo('approve_posts'); |
|
| 818 | + } |
|
| 784 | 819 | |
| 785 | 820 | // Sort the attachments so they are in the order saved |
| 786 | 821 | $temp = array(); |
| 787 | 822 | foreach ($attachment_stuff as $attachment) |
| 788 | 823 | { |
| 789 | - if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) |
|
| 790 | - $temp[$attachment['id_attach']] = $attachment; |
|
| 824 | + if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) { |
|
| 825 | + $temp[$attachment['id_attach']] = $attachment; |
|
| 826 | + } |
|
| 791 | 827 | |
| 792 | 828 | } |
| 793 | 829 | ksort($temp); |
@@ -849,14 +885,16 @@ discard block |
||
| 849 | 885 | 'is_approved' => 1, |
| 850 | 886 | ) |
| 851 | 887 | ); |
| 852 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 853 | - fatal_lang_error('quoted_post_deleted', false); |
|
| 888 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 889 | + fatal_lang_error('quoted_post_deleted', false); |
|
| 890 | + } |
|
| 854 | 891 | list ($form_subject, $mname, $mdate, $form_message) = $smcFunc['db_fetch_row']($request); |
| 855 | 892 | $smcFunc['db_free_result']($request); |
| 856 | 893 | |
| 857 | 894 | // Add 'Re: ' to the front of the quoted subject. |
| 858 | - if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
| 859 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
| 895 | + if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
| 896 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
| 897 | + } |
|
| 860 | 898 | |
| 861 | 899 | // Censor the message and subject. |
| 862 | 900 | censorText($form_message); |
@@ -869,10 +907,11 @@ discard block |
||
| 869 | 907 | for ($i = 0, $n = count($parts); $i < $n; $i++) |
| 870 | 908 | { |
| 871 | 909 | // It goes 0 = outside, 1 = begin tag, 2 = inside, 3 = close tag, repeat. |
| 872 | - if ($i % 4 == 0) |
|
| 873 | - $parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) |
|
| 910 | + if ($i % 4 == 0) { |
|
| 911 | + $parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) |
|
| 874 | 912 | { |
| 875 | 913 | return '[html]' . preg_replace('~<br\s?/?' . '>~i', '<br /><br>', "$m[1]") . '[/html]'; |
| 914 | + } |
|
| 876 | 915 | }, $parts[$i]); |
| 877 | 916 | } |
| 878 | 917 | $form_message = implode('', $parts); |
@@ -881,8 +920,9 @@ discard block |
||
| 881 | 920 | $form_message = preg_replace('~<br ?/?' . '>~i', "\n", $form_message); |
| 882 | 921 | |
| 883 | 922 | // Remove any nested quotes, if necessary. |
| 884 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
| 885 | - $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
| 923 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
| 924 | + $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
| 925 | + } |
|
| 886 | 926 | |
| 887 | 927 | // Add a quote string on the front and end. |
| 888 | 928 | $form_message = '[quote author=' . $mname . ' link=msg=' . (int) $_REQUEST['quote'] . ' date=' . $mdate . ']' . "\n" . rtrim($form_message) . "\n" . '[/quote]'; |
@@ -894,15 +934,15 @@ discard block |
||
| 894 | 934 | $form_subject = $first_subject; |
| 895 | 935 | |
| 896 | 936 | // Add 'Re: ' to the front of the subject. |
| 897 | - if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
| 898 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
| 937 | + if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
| 938 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
| 939 | + } |
|
| 899 | 940 | |
| 900 | 941 | // Censor the subject. |
| 901 | 942 | censorText($form_subject); |
| 902 | 943 | |
| 903 | 944 | $form_message = ''; |
| 904 | - } |
|
| 905 | - else |
|
| 945 | + } else |
|
| 906 | 946 | { |
| 907 | 947 | $form_subject = isset($_GET['subject']) ? $_GET['subject'] : ''; |
| 908 | 948 | $form_message = ''; |
@@ -921,13 +961,15 @@ discard block |
||
| 921 | 961 | if (isset($_REQUEST['msg'])) |
| 922 | 962 | { |
| 923 | 963 | $context['attachments']['quantity'] = count($context['current_attachments']); |
| 924 | - foreach ($context['current_attachments'] as $attachment) |
|
| 925 | - $context['attachments']['total_size'] += $attachment['size']; |
|
| 964 | + foreach ($context['current_attachments'] as $attachment) { |
|
| 965 | + $context['attachments']['total_size'] += $attachment['size']; |
|
| 966 | + } |
|
| 926 | 967 | } |
| 927 | 968 | |
| 928 | 969 | // A bit of house keeping first. |
| 929 | - if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) |
|
| 930 | - unset($_SESSION['temp_attachments']); |
|
| 970 | + if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) { |
|
| 971 | + unset($_SESSION['temp_attachments']); |
|
| 972 | + } |
|
| 931 | 973 | |
| 932 | 974 | if (!empty($_SESSION['temp_attachments'])) |
| 933 | 975 | { |
@@ -936,9 +978,10 @@ discard block |
||
| 936 | 978 | { |
| 937 | 979 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 938 | 980 | { |
| 939 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
| 940 | - if (file_exists($attachment['tmp_name'])) |
|
| 981 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) { |
|
| 982 | + if (file_exists($attachment['tmp_name'])) |
|
| 941 | 983 | unlink($attachment['tmp_name']); |
| 984 | + } |
|
| 942 | 985 | } |
| 943 | 986 | $post_errors[] = 'temp_attachments_gone'; |
| 944 | 987 | $_SESSION['temp_attachments'] = array(); |
@@ -952,8 +995,9 @@ discard block |
||
| 952 | 995 | // See if any files still exist before showing the warning message and the files attached. |
| 953 | 996 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 954 | 997 | { |
| 955 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
| 956 | - continue; |
|
| 998 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
| 999 | + continue; |
|
| 1000 | + } |
|
| 957 | 1001 | |
| 958 | 1002 | if (file_exists($attachment['tmp_name'])) |
| 959 | 1003 | { |
@@ -963,20 +1007,21 @@ discard block |
||
| 963 | 1007 | break; |
| 964 | 1008 | } |
| 965 | 1009 | } |
| 966 | - } |
|
| 967 | - else |
|
| 1010 | + } else |
|
| 968 | 1011 | { |
| 969 | 1012 | // Since, they don't belong here. Let's inform the user that they exist.. |
| 970 | - if (!empty($topic)) |
|
| 971 | - $delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp'; |
|
| 972 | - else |
|
| 973 | - $delete_url = $scripturl . '?action=post' . (!empty($board) ? ';board=' . $board : '') . ';delete_temp'; |
|
| 1013 | + if (!empty($topic)) { |
|
| 1014 | + $delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp'; |
|
| 1015 | + } else { |
|
| 1016 | + $delete_url = $scripturl . '?action=post' . (!empty($board) ? ';board=' . $board : '') . ';delete_temp'; |
|
| 1017 | + } |
|
| 974 | 1018 | |
| 975 | 1019 | // Compile a list of the files to show the user. |
| 976 | 1020 | $file_list = array(); |
| 977 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
| 978 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
| 1021 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) { |
|
| 1022 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
| 979 | 1023 | $file_list[] = $attachment['name']; |
| 1024 | + } |
|
| 980 | 1025 | |
| 981 | 1026 | $_SESSION['temp_attachments']['post']['files'] = $file_list; |
| 982 | 1027 | $file_list = '<div class="attachments">' . implode('<br>', $file_list) . '</div>'; |
@@ -988,8 +1033,7 @@ discard block |
||
| 988 | 1033 | |
| 989 | 1034 | $post_errors[] = array('temp_attachments_found', array($delete_url, $goback_url, $file_list)); |
| 990 | 1035 | $context['ignore_temp_attachments'] = true; |
| 991 | - } |
|
| 992 | - else |
|
| 1036 | + } else |
|
| 993 | 1037 | { |
| 994 | 1038 | $post_errors[] = array('temp_attachments_lost', array($delete_url, $file_list)); |
| 995 | 1039 | $context['ignore_temp_attachments'] = true; |
@@ -997,16 +1041,19 @@ discard block |
||
| 997 | 1041 | } |
| 998 | 1042 | } |
| 999 | 1043 | |
| 1000 | - if (!empty($context['we_are_history'])) |
|
| 1001 | - $post_errors[] = $context['we_are_history']; |
|
| 1044 | + if (!empty($context['we_are_history'])) { |
|
| 1045 | + $post_errors[] = $context['we_are_history']; |
|
| 1046 | + } |
|
| 1002 | 1047 | |
| 1003 | 1048 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 1004 | 1049 | { |
| 1005 | - if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) |
|
| 1006 | - break; |
|
| 1050 | + if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) { |
|
| 1051 | + break; |
|
| 1052 | + } |
|
| 1007 | 1053 | |
| 1008 | - if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
| 1009 | - continue; |
|
| 1054 | + if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
| 1055 | + continue; |
|
| 1056 | + } |
|
| 1010 | 1057 | |
| 1011 | 1058 | if ($attachID == 'initial_error') |
| 1012 | 1059 | { |
@@ -1021,15 +1068,17 @@ discard block |
||
| 1021 | 1068 | { |
| 1022 | 1069 | $txt['error_attach_errors'] = empty($txt['error_attach_errors']) ? '<br>' : ''; |
| 1023 | 1070 | $txt['error_attach_errors'] .= vsprintf($txt['attach_warning'], $attachment['name']) . '<div style="padding: 0 1em;">'; |
| 1024 | - foreach ($attachment['errors'] as $error) |
|
| 1025 | - $txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >'; |
|
| 1071 | + foreach ($attachment['errors'] as $error) { |
|
| 1072 | + $txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >'; |
|
| 1073 | + } |
|
| 1026 | 1074 | $txt['error_attach_errors'] .= '</div>'; |
| 1027 | 1075 | $post_errors[] = 'attach_errors'; |
| 1028 | 1076 | |
| 1029 | 1077 | // Take out the trash. |
| 1030 | 1078 | unset($_SESSION['temp_attachments'][$attachID]); |
| 1031 | - if (file_exists($attachment['tmp_name'])) |
|
| 1032 | - unlink($attachment['tmp_name']); |
|
| 1079 | + if (file_exists($attachment['tmp_name'])) { |
|
| 1080 | + unlink($attachment['tmp_name']); |
|
| 1081 | + } |
|
| 1033 | 1082 | continue; |
| 1034 | 1083 | } |
| 1035 | 1084 | |
@@ -1042,8 +1091,9 @@ discard block |
||
| 1042 | 1091 | |
| 1043 | 1092 | $context['attachments']['quantity']++; |
| 1044 | 1093 | $context['attachments']['total_size'] += $attachment['size']; |
| 1045 | - if (!isset($context['files_in_session_warning'])) |
|
| 1046 | - $context['files_in_session_warning'] = $txt['attached_files_in_session']; |
|
| 1094 | + if (!isset($context['files_in_session_warning'])) { |
|
| 1095 | + $context['files_in_session_warning'] = $txt['attached_files_in_session']; |
|
| 1096 | + } |
|
| 1047 | 1097 | |
| 1048 | 1098 | $context['current_attachments'][$attachID] = array( |
| 1049 | 1099 | 'name' => '<u>' . $smcFunc['htmlspecialchars']($attachment['name']) . '</u>', |
@@ -1071,8 +1121,9 @@ discard block |
||
| 1071 | 1121 | } |
| 1072 | 1122 | |
| 1073 | 1123 | // If they came from quick reply, and have to enter verification details, give them some notice. |
| 1074 | - if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) |
|
| 1075 | - $post_errors[] = 'need_qr_verification'; |
|
| 1124 | + if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) { |
|
| 1125 | + $post_errors[] = 'need_qr_verification'; |
|
| 1126 | + } |
|
| 1076 | 1127 | |
| 1077 | 1128 | /* |
| 1078 | 1129 | * There are two error types: serious and minor. Serious errors |
@@ -1089,52 +1140,56 @@ discard block |
||
| 1089 | 1140 | { |
| 1090 | 1141 | loadLanguage('Errors'); |
| 1091 | 1142 | $context['error_type'] = 'minor'; |
| 1092 | - foreach ($post_errors as $post_error) |
|
| 1093 | - if (is_array($post_error)) |
|
| 1143 | + foreach ($post_errors as $post_error) { |
|
| 1144 | + if (is_array($post_error)) |
|
| 1094 | 1145 | { |
| 1095 | 1146 | $post_error_id = $post_error[0]; |
| 1147 | + } |
|
| 1096 | 1148 | $context['post_error'][$post_error_id] = vsprintf($txt['error_' . $post_error_id], $post_error[1]); |
| 1097 | 1149 | |
| 1098 | 1150 | // If it's not a minor error flag it as such. |
| 1099 | - if (!in_array($post_error_id, $minor_errors)) |
|
| 1100 | - $context['error_type'] = 'serious'; |
|
| 1101 | - } |
|
| 1102 | - else |
|
| 1151 | + if (!in_array($post_error_id, $minor_errors)) { |
|
| 1152 | + $context['error_type'] = 'serious'; |
|
| 1153 | + } |
|
| 1154 | + } else |
|
| 1103 | 1155 | { |
| 1104 | 1156 | $context['post_error'][$post_error] = $txt['error_' . $post_error]; |
| 1105 | 1157 | |
| 1106 | 1158 | // If it's not a minor error flag it as such. |
| 1107 | - if (!in_array($post_error, $minor_errors)) |
|
| 1108 | - $context['error_type'] = 'serious'; |
|
| 1159 | + if (!in_array($post_error, $minor_errors)) { |
|
| 1160 | + $context['error_type'] = 'serious'; |
|
| 1161 | + } |
|
| 1109 | 1162 | } |
| 1110 | 1163 | } |
| 1111 | 1164 | |
| 1112 | 1165 | // What are you doing? Posting a poll, modifying, previewing, new post, or reply... |
| 1113 | - if (isset($_REQUEST['poll'])) |
|
| 1114 | - $context['page_title'] = $txt['new_poll']; |
|
| 1115 | - elseif ($context['make_event']) |
|
| 1116 | - $context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit']; |
|
| 1117 | - elseif (isset($_REQUEST['msg'])) |
|
| 1118 | - $context['page_title'] = $txt['modify_msg']; |
|
| 1119 | - elseif (isset($_REQUEST['subject'], $context['preview_subject'])) |
|
| 1120 | - $context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']); |
|
| 1121 | - elseif (empty($topic)) |
|
| 1122 | - $context['page_title'] = $txt['start_new_topic']; |
|
| 1123 | - else |
|
| 1124 | - $context['page_title'] = $txt['post_reply']; |
|
| 1166 | + if (isset($_REQUEST['poll'])) { |
|
| 1167 | + $context['page_title'] = $txt['new_poll']; |
|
| 1168 | + } elseif ($context['make_event']) { |
|
| 1169 | + $context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit']; |
|
| 1170 | + } elseif (isset($_REQUEST['msg'])) { |
|
| 1171 | + $context['page_title'] = $txt['modify_msg']; |
|
| 1172 | + } elseif (isset($_REQUEST['subject'], $context['preview_subject'])) { |
|
| 1173 | + $context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']); |
|
| 1174 | + } elseif (empty($topic)) { |
|
| 1175 | + $context['page_title'] = $txt['start_new_topic']; |
|
| 1176 | + } else { |
|
| 1177 | + $context['page_title'] = $txt['post_reply']; |
|
| 1178 | + } |
|
| 1125 | 1179 | |
| 1126 | 1180 | // Build the link tree. |
| 1127 | - if (empty($topic)) |
|
| 1128 | - $context['linktree'][] = array( |
|
| 1181 | + if (empty($topic)) { |
|
| 1182 | + $context['linktree'][] = array( |
|
| 1129 | 1183 | 'name' => '<em>' . $txt['start_new_topic'] . '</em>' |
| 1130 | 1184 | ); |
| 1131 | - else |
|
| 1132 | - $context['linktree'][] = array( |
|
| 1185 | + } else { |
|
| 1186 | + $context['linktree'][] = array( |
|
| 1133 | 1187 | 'url' => $scripturl . '?topic=' . $topic . '.' . $_REQUEST['start'], |
| 1134 | 1188 | 'name' => $form_subject, |
| 1135 | 1189 | 'extra_before' => '<span><strong class="nav">' . $context['page_title'] . ' (</strong></span>', |
| 1136 | 1190 | 'extra_after' => '<span><strong class="nav">)</strong></span>' |
| 1137 | 1191 | ); |
| 1192 | + } |
|
| 1138 | 1193 | |
| 1139 | 1194 | $context['subject'] = addcslashes($form_subject, '"'); |
| 1140 | 1195 | $context['message'] = str_replace(array('"', '<', '>', ' '), array('"', '<', '>', ' '), $form_message); |
@@ -1178,8 +1233,9 @@ discard block |
||
| 1178 | 1233 | // Message icons - customized icons are off? |
| 1179 | 1234 | $context['icons'] = getMessageIcons(!empty($board) ? $board : 0); |
| 1180 | 1235 | |
| 1181 | - if (!empty($context['icons'])) |
|
| 1182 | - $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
| 1236 | + if (!empty($context['icons'])) { |
|
| 1237 | + $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
| 1238 | + } |
|
| 1183 | 1239 | |
| 1184 | 1240 | // Are we starting a poll? if set the poll icon as selected if its available |
| 1185 | 1241 | if (isset($_REQUEST['poll'])) |
@@ -1199,8 +1255,9 @@ discard block |
||
| 1199 | 1255 | for ($i = 0, $n = count($context['icons']); $i < $n; $i++) |
| 1200 | 1256 | { |
| 1201 | 1257 | $context['icons'][$i]['selected'] = $context['icon'] == $context['icons'][$i]['value']; |
| 1202 | - if ($context['icons'][$i]['selected']) |
|
| 1203 | - $context['icon_url'] = $context['icons'][$i]['url']; |
|
| 1258 | + if ($context['icons'][$i]['selected']) { |
|
| 1259 | + $context['icon_url'] = $context['icons'][$i]['url']; |
|
| 1260 | + } |
|
| 1204 | 1261 | } |
| 1205 | 1262 | if (empty($context['icon_url'])) |
| 1206 | 1263 | { |
@@ -1214,8 +1271,9 @@ discard block |
||
| 1214 | 1271 | )); |
| 1215 | 1272 | } |
| 1216 | 1273 | |
| 1217 | - if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) |
|
| 1218 | - getTopic(); |
|
| 1274 | + if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) { |
|
| 1275 | + getTopic(); |
|
| 1276 | + } |
|
| 1219 | 1277 | |
| 1220 | 1278 | // If the user can post attachments prepare the warning labels. |
| 1221 | 1279 | if ($context['can_post_attachment']) |
@@ -1226,12 +1284,13 @@ discard block |
||
| 1226 | 1284 | $context['attachment_restrictions'] = array(); |
| 1227 | 1285 | $context['allowed_extensions'] = strtr(strtolower($modSettings['attachmentExtensions']), array(',' => ', ')); |
| 1228 | 1286 | $attachmentRestrictionTypes = array('attachmentNumPerPostLimit', 'attachmentPostLimit', 'attachmentSizeLimit'); |
| 1229 | - foreach ($attachmentRestrictionTypes as $type) |
|
| 1230 | - if (!empty($modSettings[$type])) |
|
| 1287 | + foreach ($attachmentRestrictionTypes as $type) { |
|
| 1288 | + if (!empty($modSettings[$type])) |
|
| 1231 | 1289 | { |
| 1232 | 1290 | // Show the max number of attachments if not 0. |
| 1233 | 1291 | if ($type == 'attachmentNumPerPostLimit') |
| 1234 | 1292 | $context['attachment_restrictions'][] = sprintf($txt['attach_remaining'], $modSettings['attachmentNumPerPostLimit'] - $context['attachments']['quantity']); |
| 1293 | + } |
|
| 1235 | 1294 | } |
| 1236 | 1295 | } |
| 1237 | 1296 | |
@@ -1265,8 +1324,8 @@ discard block |
||
| 1265 | 1324 | |
| 1266 | 1325 | if (!empty($context['current_attachments'])) |
| 1267 | 1326 | { |
| 1268 | - foreach ($context['current_attachments'] as $key => $mock) |
|
| 1269 | - addInlineJavaScript(' |
|
| 1327 | + foreach ($context['current_attachments'] as $key => $mock) { |
|
| 1328 | + addInlineJavaScript(' |
|
| 1270 | 1329 | current_attachments.push({ |
| 1271 | 1330 | name: '. JavaScriptEscape($mock['name']) . ', |
| 1272 | 1331 | size: '. $mock['size'] . ', |
@@ -1275,6 +1334,7 @@ discard block |
||
| 1275 | 1334 | type: '. JavaScriptEscape(!empty($mock['mime_type']) ? $mock['mime_type'] : '') . ', |
| 1276 | 1335 | thumbID: '. (!empty($mock['thumb']) ? $mock['thumb'] : 0) . ' |
| 1277 | 1336 | });', true); |
| 1337 | + } |
|
| 1278 | 1338 | } |
| 1279 | 1339 | |
| 1280 | 1340 | // File Upload. |
@@ -1349,9 +1409,10 @@ discard block |
||
| 1349 | 1409 | $context['posting_fields']['board']['dd'] .= ' |
| 1350 | 1410 | <optgroup label="' . $category['name'] . '">'; |
| 1351 | 1411 | |
| 1352 | - foreach ($category['boards'] as $brd) |
|
| 1353 | - $context['posting_fields']['board']['dd'] .= ' |
|
| 1412 | + foreach ($category['boards'] as $brd) { |
|
| 1413 | + $context['posting_fields']['board']['dd'] .= ' |
|
| 1354 | 1414 | <option value="' . $brd['id'] . '"' . ($brd['selected'] ? ' selected' : '') . '>' . ($brd['child_level'] > 0 ? str_repeat('==', $brd['child_level'] - 1) . '=>' : '') . ' ' . $brd['name'] . '</option>'; |
| 1415 | + } |
|
| 1355 | 1416 | |
| 1356 | 1417 | $context['posting_fields']['board']['dd'] .= ' |
| 1357 | 1418 | </optgroup>'; |
@@ -1382,8 +1443,9 @@ discard block |
||
| 1382 | 1443 | |
| 1383 | 1444 | |
| 1384 | 1445 | // Finally, load the template. |
| 1385 | - if (!isset($_REQUEST['xml'])) |
|
| 1386 | - loadTemplate('Post'); |
|
| 1446 | + if (!isset($_REQUEST['xml'])) { |
|
| 1447 | + loadTemplate('Post'); |
|
| 1448 | + } |
|
| 1387 | 1449 | |
| 1388 | 1450 | call_integration_hook('integrate_post_end'); |
| 1389 | 1451 | } |
@@ -1404,13 +1466,14 @@ discard block |
||
| 1404 | 1466 | // Sneaking off, are we? |
| 1405 | 1467 | if (empty($_POST) && empty($topic)) |
| 1406 | 1468 | { |
| 1407 | - if (empty($_SERVER['CONTENT_LENGTH'])) |
|
| 1408 | - redirectexit('action=post;board=' . $board . '.0'); |
|
| 1409 | - else |
|
| 1410 | - fatal_lang_error('post_upload_error', false); |
|
| 1469 | + if (empty($_SERVER['CONTENT_LENGTH'])) { |
|
| 1470 | + redirectexit('action=post;board=' . $board . '.0'); |
|
| 1471 | + } else { |
|
| 1472 | + fatal_lang_error('post_upload_error', false); |
|
| 1473 | + } |
|
| 1474 | + } elseif (empty($_POST) && !empty($topic)) { |
|
| 1475 | + redirectexit('action=post;topic=' . $topic . '.0'); |
|
| 1411 | 1476 | } |
| 1412 | - elseif (empty($_POST) && !empty($topic)) |
|
| 1413 | - redirectexit('action=post;topic=' . $topic . '.0'); |
|
| 1414 | 1477 | |
| 1415 | 1478 | // No need! |
| 1416 | 1479 | $context['robot_no_index'] = true; |
@@ -1422,8 +1485,9 @@ discard block |
||
| 1422 | 1485 | $post_errors = array(); |
| 1423 | 1486 | |
| 1424 | 1487 | // If the session has timed out, let the user re-submit their form. |
| 1425 | - if (checkSession('post', '', false) != '') |
|
| 1426 | - $post_errors[] = 'session_timeout'; |
|
| 1488 | + if (checkSession('post', '', false) != '') { |
|
| 1489 | + $post_errors[] = 'session_timeout'; |
|
| 1490 | + } |
|
| 1427 | 1491 | |
| 1428 | 1492 | // Wrong verification code? |
| 1429 | 1493 | if (!$user_info['is_admin'] && !$user_info['is_mod'] && !empty($modSettings['posts_require_captcha']) && ($user_info['posts'] < $modSettings['posts_require_captcha'] || ($user_info['is_guest'] && $modSettings['posts_require_captcha'] == -1))) |
@@ -1433,33 +1497,38 @@ discard block |
||
| 1433 | 1497 | 'id' => 'post', |
| 1434 | 1498 | ); |
| 1435 | 1499 | $context['require_verification'] = create_control_verification($verificationOptions, true); |
| 1436 | - if (is_array($context['require_verification'])) |
|
| 1437 | - $post_errors = array_merge($post_errors, $context['require_verification']); |
|
| 1500 | + if (is_array($context['require_verification'])) { |
|
| 1501 | + $post_errors = array_merge($post_errors, $context['require_verification']); |
|
| 1502 | + } |
|
| 1438 | 1503 | } |
| 1439 | 1504 | |
| 1440 | 1505 | require_once($sourcedir . '/Subs-Post.php'); |
| 1441 | 1506 | loadLanguage('Post'); |
| 1442 | 1507 | |
| 1443 | 1508 | // Drafts enabled and needed? |
| 1444 | - if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) |
|
| 1445 | - require_once($sourcedir . '/Drafts.php'); |
|
| 1509 | + if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) { |
|
| 1510 | + require_once($sourcedir . '/Drafts.php'); |
|
| 1511 | + } |
|
| 1446 | 1512 | |
| 1447 | 1513 | // First check to see if they are trying to delete any current attachments. |
| 1448 | 1514 | if (isset($_POST['attach_del'])) |
| 1449 | 1515 | { |
| 1450 | 1516 | $keep_temp = array(); |
| 1451 | 1517 | $keep_ids = array(); |
| 1452 | - foreach ($_POST['attach_del'] as $dummy) |
|
| 1453 | - if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false) |
|
| 1518 | + foreach ($_POST['attach_del'] as $dummy) { |
|
| 1519 | + if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false) |
|
| 1454 | 1520 | $keep_temp[] = $dummy; |
| 1455 | - else |
|
| 1456 | - $keep_ids[] = (int) $dummy; |
|
| 1521 | + } |
|
| 1522 | + else { |
|
| 1523 | + $keep_ids[] = (int) $dummy; |
|
| 1524 | + } |
|
| 1457 | 1525 | |
| 1458 | - if (isset($_SESSION['temp_attachments'])) |
|
| 1459 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
| 1526 | + if (isset($_SESSION['temp_attachments'])) { |
|
| 1527 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
| 1460 | 1528 | { |
| 1461 | 1529 | if ((isset($_SESSION['temp_attachments']['post']['files'], $attachment['name']) && in_array($attachment['name'], $_SESSION['temp_attachments']['post']['files'])) || in_array($attachID, $keep_temp) || strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
| 1462 | 1530 | continue; |
| 1531 | + } |
|
| 1463 | 1532 | |
| 1464 | 1533 | unset($_SESSION['temp_attachments'][$attachID]); |
| 1465 | 1534 | unlink($attachment['tmp_name']); |
@@ -1491,8 +1560,9 @@ discard block |
||
| 1491 | 1560 | { |
| 1492 | 1561 | require_once($sourcedir . '/ManageAttachments.php'); |
| 1493 | 1562 | |
| 1494 | - foreach ($_SESSION['already_attached'] as $attachID => $attachment) |
|
| 1495 | - removeAttachments(array('id_attach' => $attachID)); |
|
| 1563 | + foreach ($_SESSION['already_attached'] as $attachID => $attachment) { |
|
| 1564 | + removeAttachments(array('id_attach' => $attachID)); |
|
| 1565 | + } |
|
| 1496 | 1566 | |
| 1497 | 1567 | unset($_SESSION['already_attached']); |
| 1498 | 1568 | |
@@ -1515,12 +1585,14 @@ discard block |
||
| 1515 | 1585 | $smcFunc['db_free_result']($request); |
| 1516 | 1586 | |
| 1517 | 1587 | // Though the topic should be there, it might have vanished. |
| 1518 | - if (!is_array($topic_info)) |
|
| 1519 | - fatal_lang_error('topic_doesnt_exist', 404); |
|
| 1588 | + if (!is_array($topic_info)) { |
|
| 1589 | + fatal_lang_error('topic_doesnt_exist', 404); |
|
| 1590 | + } |
|
| 1520 | 1591 | |
| 1521 | 1592 | // Did this topic suddenly move? Just checking... |
| 1522 | - if ($topic_info['id_board'] != $board) |
|
| 1523 | - fatal_lang_error('not_a_topic'); |
|
| 1593 | + if ($topic_info['id_board'] != $board) { |
|
| 1594 | + fatal_lang_error('not_a_topic'); |
|
| 1595 | + } |
|
| 1524 | 1596 | |
| 1525 | 1597 | // Do the permissions and approval stuff... |
| 1526 | 1598 | $becomesApproved = true; |
@@ -1543,49 +1615,50 @@ discard block |
||
| 1543 | 1615 | if (!empty($topic) && !isset($_REQUEST['msg'])) |
| 1544 | 1616 | { |
| 1545 | 1617 | // Don't allow a post if it's locked. |
| 1546 | - if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) |
|
| 1547 | - fatal_lang_error('topic_locked', false); |
|
| 1618 | + if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) { |
|
| 1619 | + fatal_lang_error('topic_locked', false); |
|
| 1620 | + } |
|
| 1548 | 1621 | |
| 1549 | 1622 | // Sorry, multiple polls aren't allowed... yet. You should stop giving me ideas :P. |
| 1550 | - if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) |
|
| 1551 | - unset($_REQUEST['poll']); |
|
| 1552 | - |
|
| 1553 | - elseif ($topic_info['id_member_started'] != $user_info['id']) |
|
| 1554 | - { |
|
| 1555 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
|
| 1556 | - $becomesApproved = false; |
|
| 1557 | - |
|
| 1558 | - else |
|
| 1559 | - isAllowedTo('post_reply_any'); |
|
| 1560 | - } |
|
| 1561 | - elseif (!allowedTo('post_reply_any')) |
|
| 1623 | + if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) { |
|
| 1624 | + unset($_REQUEST['poll']); |
|
| 1625 | + } elseif ($topic_info['id_member_started'] != $user_info['id']) |
|
| 1626 | + { |
|
| 1627 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) { |
|
| 1628 | + $becomesApproved = false; |
|
| 1629 | + } else { |
|
| 1630 | + isAllowedTo('post_reply_any'); |
|
| 1631 | + } |
|
| 1632 | + } elseif (!allowedTo('post_reply_any')) |
|
| 1562 | 1633 | { |
| 1563 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) |
|
| 1564 | - $becomesApproved = false; |
|
| 1565 | - |
|
| 1566 | - else |
|
| 1567 | - isAllowedTo('post_reply_own'); |
|
| 1634 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) { |
|
| 1635 | + $becomesApproved = false; |
|
| 1636 | + } else { |
|
| 1637 | + isAllowedTo('post_reply_own'); |
|
| 1638 | + } |
|
| 1568 | 1639 | } |
| 1569 | 1640 | |
| 1570 | 1641 | if (isset($_POST['lock'])) |
| 1571 | 1642 | { |
| 1572 | 1643 | // Nothing is changed to the lock. |
| 1573 | - if (empty($topic_info['locked']) == empty($_POST['lock'])) |
|
| 1574 | - unset($_POST['lock']); |
|
| 1644 | + if (empty($topic_info['locked']) == empty($_POST['lock'])) { |
|
| 1645 | + unset($_POST['lock']); |
|
| 1646 | + } |
|
| 1575 | 1647 | |
| 1576 | 1648 | // You're have no permission to lock this topic. |
| 1577 | - elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) |
|
| 1578 | - unset($_POST['lock']); |
|
| 1649 | + elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) { |
|
| 1650 | + unset($_POST['lock']); |
|
| 1651 | + } |
|
| 1579 | 1652 | |
| 1580 | 1653 | // You are allowed to (un)lock your own topic only. |
| 1581 | 1654 | elseif (!allowedTo('lock_any')) |
| 1582 | 1655 | { |
| 1583 | 1656 | // You cannot override a moderator lock. |
| 1584 | - if ($topic_info['locked'] == 1) |
|
| 1585 | - unset($_POST['lock']); |
|
| 1586 | - |
|
| 1587 | - else |
|
| 1588 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 1657 | + if ($topic_info['locked'] == 1) { |
|
| 1658 | + unset($_POST['lock']); |
|
| 1659 | + } else { |
|
| 1660 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 1661 | + } |
|
| 1589 | 1662 | } |
| 1590 | 1663 | // Hail mighty moderator, (un)lock this topic immediately. |
| 1591 | 1664 | else |
@@ -1593,19 +1666,21 @@ discard block |
||
| 1593 | 1666 | $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
| 1594 | 1667 | |
| 1595 | 1668 | // Did someone (un)lock this while you were posting? |
| 1596 | - if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) |
|
| 1597 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
| 1669 | + if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) { |
|
| 1670 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
| 1671 | + } |
|
| 1598 | 1672 | } |
| 1599 | 1673 | } |
| 1600 | 1674 | |
| 1601 | 1675 | // So you wanna (un)sticky this...let's see. |
| 1602 | - if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) |
|
| 1603 | - unset($_POST['sticky']); |
|
| 1604 | - elseif (isset($_POST['sticky'])) |
|
| 1676 | + if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) { |
|
| 1677 | + unset($_POST['sticky']); |
|
| 1678 | + } elseif (isset($_POST['sticky'])) |
|
| 1605 | 1679 | { |
| 1606 | 1680 | // Did someone (un)sticky this while you were posting? |
| 1607 | - if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) |
|
| 1608 | - $post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky'; |
|
| 1681 | + if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) { |
|
| 1682 | + $post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky'; |
|
| 1683 | + } |
|
| 1609 | 1684 | } |
| 1610 | 1685 | |
| 1611 | 1686 | // If drafts are enabled, then pass this off |
@@ -1632,26 +1707,31 @@ discard block |
||
| 1632 | 1707 | |
| 1633 | 1708 | // Do like, the permissions, for safety and stuff... |
| 1634 | 1709 | $becomesApproved = true; |
| 1635 | - if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) |
|
| 1636 | - $becomesApproved = false; |
|
| 1637 | - else |
|
| 1638 | - isAllowedTo('post_new'); |
|
| 1710 | + if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) { |
|
| 1711 | + $becomesApproved = false; |
|
| 1712 | + } else { |
|
| 1713 | + isAllowedTo('post_new'); |
|
| 1714 | + } |
|
| 1639 | 1715 | |
| 1640 | 1716 | if (isset($_POST['lock'])) |
| 1641 | 1717 | { |
| 1642 | 1718 | // New topics are by default not locked. |
| 1643 | - if (empty($_POST['lock'])) |
|
| 1644 | - unset($_POST['lock']); |
|
| 1719 | + if (empty($_POST['lock'])) { |
|
| 1720 | + unset($_POST['lock']); |
|
| 1721 | + } |
|
| 1645 | 1722 | // Besides, you need permission. |
| 1646 | - elseif (!allowedTo(array('lock_any', 'lock_own'))) |
|
| 1647 | - unset($_POST['lock']); |
|
| 1723 | + elseif (!allowedTo(array('lock_any', 'lock_own'))) { |
|
| 1724 | + unset($_POST['lock']); |
|
| 1725 | + } |
|
| 1648 | 1726 | // A moderator-lock (1) can override a user-lock (2). |
| 1649 | - else |
|
| 1650 | - $_POST['lock'] = allowedTo('lock_any') ? 1 : 2; |
|
| 1727 | + else { |
|
| 1728 | + $_POST['lock'] = allowedTo('lock_any') ? 1 : 2; |
|
| 1729 | + } |
|
| 1651 | 1730 | } |
| 1652 | 1731 | |
| 1653 | - if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) |
|
| 1654 | - unset($_POST['sticky']); |
|
| 1732 | + if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) { |
|
| 1733 | + unset($_POST['sticky']); |
|
| 1734 | + } |
|
| 1655 | 1735 | |
| 1656 | 1736 | // Saving your new topic as a draft first? |
| 1657 | 1737 | if (!empty($modSettings['drafts_post_enabled']) && isset($_POST['save_draft'])) |
@@ -1676,31 +1756,37 @@ discard block |
||
| 1676 | 1756 | 'id_msg' => $_REQUEST['msg'], |
| 1677 | 1757 | ) |
| 1678 | 1758 | ); |
| 1679 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1680 | - fatal_lang_error('cant_find_messages', false); |
|
| 1759 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1760 | + fatal_lang_error('cant_find_messages', false); |
|
| 1761 | + } |
|
| 1681 | 1762 | $row = $smcFunc['db_fetch_assoc']($request); |
| 1682 | 1763 | $smcFunc['db_free_result']($request); |
| 1683 | 1764 | |
| 1684 | - if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) |
|
| 1685 | - fatal_lang_error('topic_locked', false); |
|
| 1765 | + if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) { |
|
| 1766 | + fatal_lang_error('topic_locked', false); |
|
| 1767 | + } |
|
| 1686 | 1768 | |
| 1687 | 1769 | if (isset($_POST['lock'])) |
| 1688 | 1770 | { |
| 1689 | 1771 | // Nothing changes to the lock status. |
| 1690 | - if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) |
|
| 1691 | - unset($_POST['lock']); |
|
| 1772 | + if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) { |
|
| 1773 | + unset($_POST['lock']); |
|
| 1774 | + } |
|
| 1692 | 1775 | // You're simply not allowed to (un)lock this. |
| 1693 | - elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) |
|
| 1694 | - unset($_POST['lock']); |
|
| 1776 | + elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) { |
|
| 1777 | + unset($_POST['lock']); |
|
| 1778 | + } |
|
| 1695 | 1779 | // You're only allowed to lock your own topics. |
| 1696 | 1780 | elseif (!allowedTo('lock_any')) |
| 1697 | 1781 | { |
| 1698 | 1782 | // You're not allowed to break a moderator's lock. |
| 1699 | - if ($topic_info['locked'] == 1) |
|
| 1700 | - unset($_POST['lock']); |
|
| 1783 | + if ($topic_info['locked'] == 1) { |
|
| 1784 | + unset($_POST['lock']); |
|
| 1785 | + } |
|
| 1701 | 1786 | // Lock it with a soft lock or unlock it. |
| 1702 | - else |
|
| 1703 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 1787 | + else { |
|
| 1788 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 1789 | + } |
|
| 1704 | 1790 | } |
| 1705 | 1791 | // You must be the moderator. |
| 1706 | 1792 | else |
@@ -1708,44 +1794,46 @@ discard block |
||
| 1708 | 1794 | $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
| 1709 | 1795 | |
| 1710 | 1796 | // Did someone (un)lock this while you were posting? |
| 1711 | - if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) |
|
| 1712 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
| 1797 | + if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) { |
|
| 1798 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
| 1799 | + } |
|
| 1713 | 1800 | } |
| 1714 | 1801 | } |
| 1715 | 1802 | |
| 1716 | 1803 | // Change the sticky status of this topic? |
| 1717 | - if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) |
|
| 1718 | - unset($_POST['sticky']); |
|
| 1719 | - elseif (isset($_POST['sticky'])) |
|
| 1804 | + if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) { |
|
| 1805 | + unset($_POST['sticky']); |
|
| 1806 | + } elseif (isset($_POST['sticky'])) |
|
| 1720 | 1807 | { |
| 1721 | 1808 | // Did someone (un)sticky this while you were posting? |
| 1722 | - if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) |
|
| 1723 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied'; |
|
| 1809 | + if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) { |
|
| 1810 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied'; |
|
| 1811 | + } |
|
| 1724 | 1812 | } |
| 1725 | 1813 | |
| 1726 | 1814 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
| 1727 | 1815 | { |
| 1728 | - if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
| 1729 | - fatal_lang_error('modify_post_time_passed', false); |
|
| 1730 | - elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
|
| 1731 | - isAllowedTo('modify_replies'); |
|
| 1732 | - else |
|
| 1733 | - isAllowedTo('modify_own'); |
|
| 1734 | - } |
|
| 1735 | - elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 1816 | + if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
| 1817 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 1818 | + } elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
| 1819 | + isAllowedTo('modify_replies'); |
|
| 1820 | + } else { |
|
| 1821 | + isAllowedTo('modify_own'); |
|
| 1822 | + } |
|
| 1823 | + } elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 1736 | 1824 | { |
| 1737 | 1825 | isAllowedTo('modify_replies'); |
| 1738 | 1826 | |
| 1739 | 1827 | // If you're modifying a reply, I say it better be logged... |
| 1740 | 1828 | $moderationAction = true; |
| 1741 | - } |
|
| 1742 | - else |
|
| 1829 | + } else |
|
| 1743 | 1830 | { |
| 1744 | 1831 | isAllowedTo('modify_any'); |
| 1745 | 1832 | |
| 1746 | 1833 | // Log it, assuming you're not modifying your own post. |
| 1747 | - if ($row['id_member'] != $user_info['id']) |
|
| 1748 | - $moderationAction = true; |
|
| 1834 | + if ($row['id_member'] != $user_info['id']) { |
|
| 1835 | + $moderationAction = true; |
|
| 1836 | + } |
|
| 1749 | 1837 | } |
| 1750 | 1838 | |
| 1751 | 1839 | // If drafts are enabled, then lets send this off to save |
@@ -1784,20 +1872,24 @@ discard block |
||
| 1784 | 1872 | $_POST['guestname'] = !isset($_POST['guestname']) ? '' : trim($_POST['guestname']); |
| 1785 | 1873 | $_POST['email'] = !isset($_POST['email']) ? '' : trim($_POST['email']); |
| 1786 | 1874 | |
| 1787 | - if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') |
|
| 1788 | - $post_errors[] = 'no_name'; |
|
| 1789 | - if ($smcFunc['strlen']($_POST['guestname']) > 25) |
|
| 1790 | - $post_errors[] = 'long_name'; |
|
| 1875 | + if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') { |
|
| 1876 | + $post_errors[] = 'no_name'; |
|
| 1877 | + } |
|
| 1878 | + if ($smcFunc['strlen']($_POST['guestname']) > 25) { |
|
| 1879 | + $post_errors[] = 'long_name'; |
|
| 1880 | + } |
|
| 1791 | 1881 | |
| 1792 | 1882 | if (empty($modSettings['guest_post_no_email'])) |
| 1793 | 1883 | { |
| 1794 | 1884 | // Only check if they changed it! |
| 1795 | 1885 | if (!isset($row) || $row['poster_email'] != $_POST['email']) |
| 1796 | 1886 | { |
| 1797 | - if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) |
|
| 1798 | - $post_errors[] = 'no_email'; |
|
| 1799 | - if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) |
|
| 1800 | - $post_errors[] = 'bad_email'; |
|
| 1887 | + if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) { |
|
| 1888 | + $post_errors[] = 'no_email'; |
|
| 1889 | + } |
|
| 1890 | + if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { |
|
| 1891 | + $post_errors[] = 'bad_email'; |
|
| 1892 | + } |
|
| 1801 | 1893 | } |
| 1802 | 1894 | |
| 1803 | 1895 | // Now make sure this email address is not banned from posting. |
@@ -1813,75 +1905,89 @@ discard block |
||
| 1813 | 1905 | } |
| 1814 | 1906 | |
| 1815 | 1907 | // Coming from the quickReply? |
| 1816 | - if (isset($_POST['quickReply'])) |
|
| 1817 | - $_POST['message'] = $_POST['quickReply']; |
|
| 1908 | + if (isset($_POST['quickReply'])) { |
|
| 1909 | + $_POST['message'] = $_POST['quickReply']; |
|
| 1910 | + } |
|
| 1818 | 1911 | |
| 1819 | 1912 | // Check the subject and message. |
| 1820 | - if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') |
|
| 1821 | - $post_errors[] = 'no_subject'; |
|
| 1822 | - if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') |
|
| 1823 | - $post_errors[] = 'no_message'; |
|
| 1824 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
| 1825 | - $post_errors[] = array('long_message', array($modSettings['max_messageLength'])); |
|
| 1826 | - else |
|
| 1913 | + if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') { |
|
| 1914 | + $post_errors[] = 'no_subject'; |
|
| 1915 | + } |
|
| 1916 | + if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') { |
|
| 1917 | + $post_errors[] = 'no_message'; |
|
| 1918 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) { |
|
| 1919 | + $post_errors[] = array('long_message', array($modSettings['max_messageLength'])); |
|
| 1920 | + } else |
|
| 1827 | 1921 | { |
| 1828 | 1922 | // Prepare the message a bit for some additional testing. |
| 1829 | 1923 | $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES); |
| 1830 | 1924 | |
| 1831 | 1925 | // Preparse code. (Zef) |
| 1832 | - if ($user_info['is_guest']) |
|
| 1833 | - $user_info['name'] = $_POST['guestname']; |
|
| 1926 | + if ($user_info['is_guest']) { |
|
| 1927 | + $user_info['name'] = $_POST['guestname']; |
|
| 1928 | + } |
|
| 1834 | 1929 | preparsecode($_POST['message']); |
| 1835 | 1930 | |
| 1836 | 1931 | // Let's see if there's still some content left without the tags. |
| 1837 | - if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) |
|
| 1838 | - $post_errors[] = 'no_message'; |
|
| 1932 | + if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) { |
|
| 1933 | + $post_errors[] = 'no_message'; |
|
| 1934 | + } |
|
| 1935 | + } |
|
| 1936 | + if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') { |
|
| 1937 | + $post_errors[] = 'no_event'; |
|
| 1839 | 1938 | } |
| 1840 | - if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') |
|
| 1841 | - $post_errors[] = 'no_event'; |
|
| 1842 | 1939 | // You are not! |
| 1843 | - if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) |
|
| 1844 | - fatal_error('Knave! Masquerader! Charlatan!', false); |
|
| 1940 | + if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) { |
|
| 1941 | + fatal_error('Knave! Masquerader! Charlatan!', false); |
|
| 1942 | + } |
|
| 1845 | 1943 | |
| 1846 | 1944 | // Validate the poll... |
| 1847 | 1945 | if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1') |
| 1848 | 1946 | { |
| 1849 | - if (!empty($topic) && !isset($_REQUEST['msg'])) |
|
| 1850 | - fatal_lang_error('no_access', false); |
|
| 1947 | + if (!empty($topic) && !isset($_REQUEST['msg'])) { |
|
| 1948 | + fatal_lang_error('no_access', false); |
|
| 1949 | + } |
|
| 1851 | 1950 | |
| 1852 | 1951 | // This is a new topic... so it's a new poll. |
| 1853 | - if (empty($topic)) |
|
| 1854 | - isAllowedTo('poll_post'); |
|
| 1952 | + if (empty($topic)) { |
|
| 1953 | + isAllowedTo('poll_post'); |
|
| 1954 | + } |
|
| 1855 | 1955 | // Can you add to your own topics? |
| 1856 | - elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) |
|
| 1857 | - isAllowedTo('poll_add_own'); |
|
| 1956 | + elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) { |
|
| 1957 | + isAllowedTo('poll_add_own'); |
|
| 1958 | + } |
|
| 1858 | 1959 | // Can you add polls to any topic, then? |
| 1859 | - else |
|
| 1860 | - isAllowedTo('poll_add_any'); |
|
| 1960 | + else { |
|
| 1961 | + isAllowedTo('poll_add_any'); |
|
| 1962 | + } |
|
| 1861 | 1963 | |
| 1862 | - if (!isset($_POST['question']) || trim($_POST['question']) == '') |
|
| 1863 | - $post_errors[] = 'no_question'; |
|
| 1964 | + if (!isset($_POST['question']) || trim($_POST['question']) == '') { |
|
| 1965 | + $post_errors[] = 'no_question'; |
|
| 1966 | + } |
|
| 1864 | 1967 | |
| 1865 | 1968 | $_POST['options'] = empty($_POST['options']) ? array() : htmltrim__recursive($_POST['options']); |
| 1866 | 1969 | |
| 1867 | 1970 | // Get rid of empty ones. |
| 1868 | - foreach ($_POST['options'] as $k => $option) |
|
| 1869 | - if ($option == '') |
|
| 1971 | + foreach ($_POST['options'] as $k => $option) { |
|
| 1972 | + if ($option == '') |
|
| 1870 | 1973 | unset($_POST['options'][$k], $_POST['options'][$k]); |
| 1974 | + } |
|
| 1871 | 1975 | |
| 1872 | 1976 | // What are you going to vote between with one choice?!? |
| 1873 | - if (count($_POST['options']) < 2) |
|
| 1874 | - $post_errors[] = 'poll_few'; |
|
| 1875 | - elseif (count($_POST['options']) > 256) |
|
| 1876 | - $post_errors[] = 'poll_many'; |
|
| 1977 | + if (count($_POST['options']) < 2) { |
|
| 1978 | + $post_errors[] = 'poll_few'; |
|
| 1979 | + } elseif (count($_POST['options']) > 256) { |
|
| 1980 | + $post_errors[] = 'poll_many'; |
|
| 1981 | + } |
|
| 1877 | 1982 | } |
| 1878 | 1983 | |
| 1879 | 1984 | if ($posterIsGuest) |
| 1880 | 1985 | { |
| 1881 | 1986 | // If user is a guest, make sure the chosen name isn't taken. |
| 1882 | 1987 | require_once($sourcedir . '/Subs-Members.php'); |
| 1883 | - if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) |
|
| 1884 | - $post_errors[] = 'bad_name'; |
|
| 1988 | + if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) { |
|
| 1989 | + $post_errors[] = 'bad_name'; |
|
| 1990 | + } |
|
| 1885 | 1991 | } |
| 1886 | 1992 | // If the user isn't a guest, get his or her name and email. |
| 1887 | 1993 | elseif (!isset($_REQUEST['msg'])) |
@@ -1912,8 +2018,9 @@ discard block |
||
| 1912 | 2018 | } |
| 1913 | 2019 | |
| 1914 | 2020 | // Make sure the user isn't spamming the board. |
| 1915 | - if (!isset($_REQUEST['msg'])) |
|
| 1916 | - spamProtection('post'); |
|
| 2021 | + if (!isset($_REQUEST['msg'])) { |
|
| 2022 | + spamProtection('post'); |
|
| 2023 | + } |
|
| 1917 | 2024 | |
| 1918 | 2025 | // At about this point, we're posting and that's that. |
| 1919 | 2026 | ignore_user_abort(true); |
@@ -1926,32 +2033,36 @@ discard block |
||
| 1926 | 2033 | $_POST['modify_reason'] = empty($_POST['modify_reason']) ? '' : strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => '')); |
| 1927 | 2034 | |
| 1928 | 2035 | // At this point, we want to make sure the subject isn't too long. |
| 1929 | - if ($smcFunc['strlen']($_POST['subject']) > 100) |
|
| 1930 | - $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
| 2036 | + if ($smcFunc['strlen']($_POST['subject']) > 100) { |
|
| 2037 | + $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
| 2038 | + } |
|
| 1931 | 2039 | |
| 1932 | 2040 | // Same with the "why did you edit this" text. |
| 1933 | - if ($smcFunc['strlen']($_POST['modify_reason']) > 100) |
|
| 1934 | - $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
| 2041 | + if ($smcFunc['strlen']($_POST['modify_reason']) > 100) { |
|
| 2042 | + $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
| 2043 | + } |
|
| 1935 | 2044 | |
| 1936 | 2045 | // Make the poll... |
| 1937 | 2046 | if (isset($_REQUEST['poll'])) |
| 1938 | 2047 | { |
| 1939 | 2048 | // Make sure that the user has not entered a ridiculous number of options.. |
| 1940 | - if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) |
|
| 1941 | - $_POST['poll_max_votes'] = 1; |
|
| 1942 | - elseif ($_POST['poll_max_votes'] > count($_POST['options'])) |
|
| 1943 | - $_POST['poll_max_votes'] = count($_POST['options']); |
|
| 1944 | - else |
|
| 1945 | - $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
| 2049 | + if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) { |
|
| 2050 | + $_POST['poll_max_votes'] = 1; |
|
| 2051 | + } elseif ($_POST['poll_max_votes'] > count($_POST['options'])) { |
|
| 2052 | + $_POST['poll_max_votes'] = count($_POST['options']); |
|
| 2053 | + } else { |
|
| 2054 | + $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
| 2055 | + } |
|
| 1946 | 2056 | |
| 1947 | 2057 | $_POST['poll_expire'] = (int) $_POST['poll_expire']; |
| 1948 | 2058 | $_POST['poll_expire'] = $_POST['poll_expire'] > 9999 ? 9999 : ($_POST['poll_expire'] < 0 ? 0 : $_POST['poll_expire']); |
| 1949 | 2059 | |
| 1950 | 2060 | // Just set it to zero if it's not there.. |
| 1951 | - if (!isset($_POST['poll_hide'])) |
|
| 1952 | - $_POST['poll_hide'] = 0; |
|
| 1953 | - else |
|
| 1954 | - $_POST['poll_hide'] = (int) $_POST['poll_hide']; |
|
| 2061 | + if (!isset($_POST['poll_hide'])) { |
|
| 2062 | + $_POST['poll_hide'] = 0; |
|
| 2063 | + } else { |
|
| 2064 | + $_POST['poll_hide'] = (int) $_POST['poll_hide']; |
|
| 2065 | + } |
|
| 1955 | 2066 | $_POST['poll_change_vote'] = isset($_POST['poll_change_vote']) ? 1 : 0; |
| 1956 | 2067 | |
| 1957 | 2068 | $_POST['poll_guest_vote'] = isset($_POST['poll_guest_vote']) ? 1 : 0; |
@@ -1960,16 +2071,19 @@ discard block |
||
| 1960 | 2071 | { |
| 1961 | 2072 | require_once($sourcedir . '/Subs-Members.php'); |
| 1962 | 2073 | $allowedVoteGroups = groupsAllowedTo('poll_vote', $board); |
| 1963 | - if (!in_array(-1, $allowedVoteGroups['allowed'])) |
|
| 1964 | - $_POST['poll_guest_vote'] = 0; |
|
| 2074 | + if (!in_array(-1, $allowedVoteGroups['allowed'])) { |
|
| 2075 | + $_POST['poll_guest_vote'] = 0; |
|
| 2076 | + } |
|
| 1965 | 2077 | } |
| 1966 | 2078 | |
| 1967 | 2079 | // If the user tries to set the poll too far in advance, don't let them. |
| 1968 | - if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) |
|
| 1969 | - fatal_lang_error('poll_range_error', false); |
|
| 2080 | + if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) { |
|
| 2081 | + fatal_lang_error('poll_range_error', false); |
|
| 2082 | + } |
|
| 1970 | 2083 | // Don't allow them to select option 2 for hidden results if it's not time limited. |
| 1971 | - elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) |
|
| 1972 | - $_POST['poll_hide'] = 1; |
|
| 2084 | + elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) { |
|
| 2085 | + $_POST['poll_hide'] = 1; |
|
| 2086 | + } |
|
| 1973 | 2087 | |
| 1974 | 2088 | // Clean up the question and answers. |
| 1975 | 2089 | $_POST['question'] = $smcFunc['htmlspecialchars']($_POST['question']); |
@@ -1983,13 +2097,15 @@ discard block |
||
| 1983 | 2097 | { |
| 1984 | 2098 | $attachIDs = array(); |
| 1985 | 2099 | $attach_errors = array(); |
| 1986 | - if (!empty($context['we_are_history'])) |
|
| 1987 | - $attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>'; |
|
| 2100 | + if (!empty($context['we_are_history'])) { |
|
| 2101 | + $attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>'; |
|
| 2102 | + } |
|
| 1988 | 2103 | |
| 1989 | 2104 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 1990 | 2105 | { |
| 1991 | - if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
| 1992 | - continue; |
|
| 2106 | + if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
| 2107 | + continue; |
|
| 2108 | + } |
|
| 1993 | 2109 | |
| 1994 | 2110 | // If there was an initial error just show that message. |
| 1995 | 2111 | if ($attachID == 'initial_error') |
@@ -2018,12 +2134,13 @@ discard block |
||
| 2018 | 2134 | if (createAttachment($attachmentOptions)) |
| 2019 | 2135 | { |
| 2020 | 2136 | $attachIDs[] = $attachmentOptions['id']; |
| 2021 | - if (!empty($attachmentOptions['thumb'])) |
|
| 2022 | - $attachIDs[] = $attachmentOptions['thumb']; |
|
| 2137 | + if (!empty($attachmentOptions['thumb'])) { |
|
| 2138 | + $attachIDs[] = $attachmentOptions['thumb']; |
|
| 2139 | + } |
|
| 2023 | 2140 | } |
| 2141 | + } else { |
|
| 2142 | + $attach_errors[] = '<dt> </dt>'; |
|
| 2024 | 2143 | } |
| 2025 | - else |
|
| 2026 | - $attach_errors[] = '<dt> </dt>'; |
|
| 2027 | 2144 | |
| 2028 | 2145 | if (!empty($attachmentOptions['errors'])) |
| 2029 | 2146 | { |
@@ -2035,14 +2152,16 @@ discard block |
||
| 2035 | 2152 | if (!is_array($error)) |
| 2036 | 2153 | { |
| 2037 | 2154 | $attach_errors[] = '<dd>' . $txt[$error] . '</dd>'; |
| 2038 | - if (in_array($error, $log_these)) |
|
| 2039 | - log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
| 2155 | + if (in_array($error, $log_these)) { |
|
| 2156 | + log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
| 2157 | + } |
|
| 2158 | + } else { |
|
| 2159 | + $attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>'; |
|
| 2040 | 2160 | } |
| 2041 | - else |
|
| 2042 | - $attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>'; |
|
| 2043 | 2161 | } |
| 2044 | - if (file_exists($attachment['tmp_name'])) |
|
| 2045 | - unlink($attachment['tmp_name']); |
|
| 2162 | + if (file_exists($attachment['tmp_name'])) { |
|
| 2163 | + unlink($attachment['tmp_name']); |
|
| 2164 | + } |
|
| 2046 | 2165 | } |
| 2047 | 2166 | } |
| 2048 | 2167 | unset($_SESSION['temp_attachments']); |
@@ -2083,24 +2202,24 @@ discard block |
||
| 2083 | 2202 | ); |
| 2084 | 2203 | |
| 2085 | 2204 | call_integration_hook('integrate_poll_add_edit', array($id_poll, false)); |
| 2205 | + } else { |
|
| 2206 | + $id_poll = 0; |
|
| 2086 | 2207 | } |
| 2087 | - else |
|
| 2088 | - $id_poll = 0; |
|
| 2089 | 2208 | |
| 2090 | 2209 | // Creating a new topic? |
| 2091 | 2210 | $newTopic = empty($_REQUEST['msg']) && empty($topic); |
| 2092 | 2211 | |
| 2093 | 2212 | // Check the icon. |
| 2094 | - if (!isset($_POST['icon'])) |
|
| 2095 | - $_POST['icon'] = 'xx'; |
|
| 2096 | - |
|
| 2097 | - else |
|
| 2213 | + if (!isset($_POST['icon'])) { |
|
| 2214 | + $_POST['icon'] = 'xx'; |
|
| 2215 | + } else |
|
| 2098 | 2216 | { |
| 2099 | 2217 | $_POST['icon'] = $smcFunc['htmlspecialchars']($_POST['icon']); |
| 2100 | 2218 | |
| 2101 | 2219 | // Need to figure it out if this is a valid icon name. |
| 2102 | - if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) |
|
| 2103 | - $_POST['icon'] = 'xx'; |
|
| 2220 | + if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) { |
|
| 2221 | + $_POST['icon'] = 'xx'; |
|
| 2222 | + } |
|
| 2104 | 2223 | } |
| 2105 | 2224 | |
| 2106 | 2225 | // Collect all parameters for the creation or modification of a post. |
@@ -2141,8 +2260,9 @@ discard block |
||
| 2141 | 2260 | } |
| 2142 | 2261 | |
| 2143 | 2262 | // This will save some time... |
| 2144 | - if (empty($approve_has_changed)) |
|
| 2145 | - unset($msgOptions['approved']); |
|
| 2263 | + if (empty($approve_has_changed)) { |
|
| 2264 | + unset($msgOptions['approved']); |
|
| 2265 | + } |
|
| 2146 | 2266 | |
| 2147 | 2267 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
| 2148 | 2268 | } |
@@ -2151,8 +2271,9 @@ discard block |
||
| 2151 | 2271 | { |
| 2152 | 2272 | createPost($msgOptions, $topicOptions, $posterOptions); |
| 2153 | 2273 | |
| 2154 | - if (isset($topicOptions['id'])) |
|
| 2155 | - $topic = $topicOptions['id']; |
|
| 2274 | + if (isset($topicOptions['id'])) { |
|
| 2275 | + $topic = $topicOptions['id']; |
|
| 2276 | + } |
|
| 2156 | 2277 | } |
| 2157 | 2278 | |
| 2158 | 2279 | // Are there attachments already uploaded and waiting to be assigned? |
@@ -2164,8 +2285,9 @@ discard block |
||
| 2164 | 2285 | } |
| 2165 | 2286 | |
| 2166 | 2287 | // If we had a draft for this, its time to remove it since it was just posted |
| 2167 | - if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) |
|
| 2168 | - DeleteDraft($_POST['id_draft']); |
|
| 2288 | + if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) { |
|
| 2289 | + DeleteDraft($_POST['id_draft']); |
|
| 2290 | + } |
|
| 2169 | 2291 | |
| 2170 | 2292 | // Editing or posting an event? |
| 2171 | 2293 | if (isset($_POST['calendar']) && (!isset($_REQUEST['eventid']) || $_REQUEST['eventid'] == -1)) |
@@ -2184,8 +2306,7 @@ discard block |
||
| 2184 | 2306 | 'member' => $user_info['id'], |
| 2185 | 2307 | ); |
| 2186 | 2308 | insertEvent($eventOptions); |
| 2187 | - } |
|
| 2188 | - elseif (isset($_POST['calendar'])) |
|
| 2309 | + } elseif (isset($_POST['calendar'])) |
|
| 2189 | 2310 | { |
| 2190 | 2311 | $_REQUEST['eventid'] = (int) $_REQUEST['eventid']; |
| 2191 | 2312 | |
@@ -2213,14 +2334,15 @@ discard block |
||
| 2213 | 2334 | } |
| 2214 | 2335 | |
| 2215 | 2336 | // Delete it? |
| 2216 | - if (isset($_REQUEST['deleteevent'])) |
|
| 2217 | - $smcFunc['db_query']('', ' |
|
| 2337 | + if (isset($_REQUEST['deleteevent'])) { |
|
| 2338 | + $smcFunc['db_query']('', ' |
|
| 2218 | 2339 | DELETE FROM {db_prefix}calendar |
| 2219 | 2340 | WHERE id_event = {int:id_event}', |
| 2220 | 2341 | array( |
| 2221 | 2342 | 'id_event' => $_REQUEST['eventid'], |
| 2222 | 2343 | ) |
| 2223 | 2344 | ); |
| 2345 | + } |
|
| 2224 | 2346 | // ... or just update it? |
| 2225 | 2347 | else |
| 2226 | 2348 | { |
@@ -2262,9 +2384,8 @@ discard block |
||
| 2262 | 2384 | array($user_info['id'], $topic, 0), |
| 2263 | 2385 | array('id_member', 'id_topic', 'id_board') |
| 2264 | 2386 | ); |
| 2265 | - } |
|
| 2266 | - elseif (!$newTopic) |
|
| 2267 | - $smcFunc['db_query']('', ' |
|
| 2387 | + } elseif (!$newTopic) { |
|
| 2388 | + $smcFunc['db_query']('', ' |
|
| 2268 | 2389 | DELETE FROM {db_prefix}log_notify |
| 2269 | 2390 | WHERE id_member = {int:current_member} |
| 2270 | 2391 | AND id_topic = {int:current_topic}', |
@@ -2273,16 +2394,20 @@ discard block |
||
| 2273 | 2394 | 'current_topic' => $topic, |
| 2274 | 2395 | ) |
| 2275 | 2396 | ); |
| 2397 | + } |
|
| 2276 | 2398 | |
| 2277 | 2399 | // Log an act of moderation - modifying. |
| 2278 | - if (!empty($moderationAction)) |
|
| 2279 | - logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
| 2400 | + if (!empty($moderationAction)) { |
|
| 2401 | + logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
| 2402 | + } |
|
| 2280 | 2403 | |
| 2281 | - if (isset($_POST['lock']) && $_POST['lock'] != 2) |
|
| 2282 | - logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 2404 | + if (isset($_POST['lock']) && $_POST['lock'] != 2) { |
|
| 2405 | + logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 2406 | + } |
|
| 2283 | 2407 | |
| 2284 | - if (isset($_POST['sticky'])) |
|
| 2285 | - logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 2408 | + if (isset($_POST['sticky'])) { |
|
| 2409 | + logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 2410 | + } |
|
| 2286 | 2411 | |
| 2287 | 2412 | // Returning to the topic? |
| 2288 | 2413 | if (!empty($_REQUEST['goback'])) |
@@ -2301,26 +2426,31 @@ discard block |
||
| 2301 | 2426 | ); |
| 2302 | 2427 | } |
| 2303 | 2428 | |
| 2304 | - if ($board_info['num_topics'] == 0) |
|
| 2305 | - cache_put_data('board-' . $board, null, 120); |
|
| 2429 | + if ($board_info['num_topics'] == 0) { |
|
| 2430 | + cache_put_data('board-' . $board, null, 120); |
|
| 2431 | + } |
|
| 2306 | 2432 | |
| 2307 | 2433 | call_integration_hook('integrate_post2_end'); |
| 2308 | 2434 | |
| 2309 | - if (!empty($_POST['announce_topic']) && allowedTo('announce_topic')) |
|
| 2310 | - redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2435 | + if (!empty($_POST['announce_topic']) && allowedTo('announce_topic')) { |
|
| 2436 | + redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2437 | + } |
|
| 2311 | 2438 | |
| 2312 | - if (!empty($_POST['move']) && allowedTo('move_any')) |
|
| 2313 | - redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2439 | + if (!empty($_POST['move']) && allowedTo('move_any')) { |
|
| 2440 | + redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2441 | + } |
|
| 2314 | 2442 | |
| 2315 | 2443 | // Return to post if the mod is on. |
| 2316 | - if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) |
|
| 2317 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
| 2318 | - elseif (!empty($_REQUEST['goback'])) |
|
| 2319 | - redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
| 2444 | + if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) { |
|
| 2445 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
| 2446 | + } elseif (!empty($_REQUEST['goback'])) { |
|
| 2447 | + redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
| 2448 | + } |
|
| 2320 | 2449 | // Dut-dut-duh-duh-DUH-duh-dut-duh-duh! *dances to the Final Fantasy Fanfare...* |
| 2321 | - else |
|
| 2322 | - redirectexit('board=' . $board . '.0'); |
|
| 2323 | -} |
|
| 2450 | + else { |
|
| 2451 | + redirectexit('board=' . $board . '.0'); |
|
| 2452 | + } |
|
| 2453 | + } |
|
| 2324 | 2454 | |
| 2325 | 2455 | /** |
| 2326 | 2456 | * Handle the announce topic function (action=announce). |
@@ -2338,8 +2468,9 @@ discard block |
||
| 2338 | 2468 | |
| 2339 | 2469 | validateSession(); |
| 2340 | 2470 | |
| 2341 | - if (empty($topic)) |
|
| 2342 | - fatal_lang_error('topic_gone', false); |
|
| 2471 | + if (empty($topic)) { |
|
| 2472 | + fatal_lang_error('topic_gone', false); |
|
| 2473 | + } |
|
| 2343 | 2474 | |
| 2344 | 2475 | loadLanguage('Post'); |
| 2345 | 2476 | loadTemplate('Post'); |
@@ -2366,8 +2497,9 @@ discard block |
||
| 2366 | 2497 | global $txt, $context, $topic, $board_info, $smcFunc; |
| 2367 | 2498 | |
| 2368 | 2499 | $groups = array_merge($board_info['groups'], array(1)); |
| 2369 | - foreach ($groups as $id => $group) |
|
| 2370 | - $groups[$id] = (int) $group; |
|
| 2500 | + foreach ($groups as $id => $group) { |
|
| 2501 | + $groups[$id] = (int) $group; |
|
| 2502 | + } |
|
| 2371 | 2503 | |
| 2372 | 2504 | $context['groups'] = array(); |
| 2373 | 2505 | if (in_array(0, $groups)) |
@@ -2410,8 +2542,9 @@ discard block |
||
| 2410 | 2542 | 'group_list' => $groups, |
| 2411 | 2543 | ) |
| 2412 | 2544 | ); |
| 2413 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2414 | - $context['groups'][$row['id_group']]['name'] = $row['group_name']; |
|
| 2545 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2546 | + $context['groups'][$row['id_group']]['name'] = $row['group_name']; |
|
| 2547 | + } |
|
| 2415 | 2548 | $smcFunc['db_free_result']($request); |
| 2416 | 2549 | |
| 2417 | 2550 | // Get the subject of the topic we're about to announce. |
@@ -2453,16 +2586,19 @@ discard block |
||
| 2453 | 2586 | $context['start'] = empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start']; |
| 2454 | 2587 | $groups = array_merge($board_info['groups'], array(1)); |
| 2455 | 2588 | |
| 2456 | - if (isset($_POST['membergroups'])) |
|
| 2457 | - $_POST['who'] = explode(',', $_POST['membergroups']); |
|
| 2589 | + if (isset($_POST['membergroups'])) { |
|
| 2590 | + $_POST['who'] = explode(',', $_POST['membergroups']); |
|
| 2591 | + } |
|
| 2458 | 2592 | |
| 2459 | 2593 | // Check whether at least one membergroup was selected. |
| 2460 | - if (empty($_POST['who'])) |
|
| 2461 | - fatal_lang_error('no_membergroup_selected'); |
|
| 2594 | + if (empty($_POST['who'])) { |
|
| 2595 | + fatal_lang_error('no_membergroup_selected'); |
|
| 2596 | + } |
|
| 2462 | 2597 | |
| 2463 | 2598 | // Make sure all membergroups are integers and can access the board of the announcement. |
| 2464 | - foreach ($_POST['who'] as $id => $mg) |
|
| 2465 | - $_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0; |
|
| 2599 | + foreach ($_POST['who'] as $id => $mg) { |
|
| 2600 | + $_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0; |
|
| 2601 | + } |
|
| 2466 | 2602 | |
| 2467 | 2603 | // Get the topic subject and censor it. |
| 2468 | 2604 | $request = $smcFunc['db_query']('', ' |
@@ -2508,12 +2644,13 @@ discard block |
||
| 2508 | 2644 | if ($smcFunc['db_num_rows']($request) == 0) |
| 2509 | 2645 | { |
| 2510 | 2646 | logAction('announce_topic', array('topic' => $topic), 'user'); |
| 2511 | - if (!empty($_REQUEST['move']) && allowedTo('move_any')) |
|
| 2512 | - redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2513 | - elseif (!empty($_REQUEST['goback'])) |
|
| 2514 | - redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie')); |
|
| 2515 | - else |
|
| 2516 | - redirectexit('board=' . $board . '.0'); |
|
| 2647 | + if (!empty($_REQUEST['move']) && allowedTo('move_any')) { |
|
| 2648 | + redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2649 | + } elseif (!empty($_REQUEST['goback'])) { |
|
| 2650 | + redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie')); |
|
| 2651 | + } else { |
|
| 2652 | + redirectexit('board=' . $board . '.0'); |
|
| 2653 | + } |
|
| 2517 | 2654 | } |
| 2518 | 2655 | |
| 2519 | 2656 | $announcements = array(); |
@@ -2532,8 +2669,9 @@ discard block |
||
| 2532 | 2669 | foreach ($rows as $row) |
| 2533 | 2670 | { |
| 2534 | 2671 | // Force them to have it? |
| 2535 | - if (empty($prefs[$row['id_member']]['announcements'])) |
|
| 2536 | - continue; |
|
| 2672 | + if (empty($prefs[$row['id_member']]['announcements'])) { |
|
| 2673 | + continue; |
|
| 2674 | + } |
|
| 2537 | 2675 | |
| 2538 | 2676 | $cur_language = empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']; |
| 2539 | 2677 | |
@@ -2561,8 +2699,9 @@ discard block |
||
| 2561 | 2699 | } |
| 2562 | 2700 | |
| 2563 | 2701 | // For each language send a different mail - low priority... |
| 2564 | - foreach ($announcements as $lang => $mail) |
|
| 2565 | - sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5); |
|
| 2702 | + foreach ($announcements as $lang => $mail) { |
|
| 2703 | + sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5); |
|
| 2704 | + } |
|
| 2566 | 2705 | |
| 2567 | 2706 | $context['percentage_done'] = round(100 * $context['start'] / $modSettings['latestMember'], 1); |
| 2568 | 2707 | |
@@ -2572,9 +2711,10 @@ discard block |
||
| 2572 | 2711 | $context['sub_template'] = 'announcement_send'; |
| 2573 | 2712 | |
| 2574 | 2713 | // Go back to the correct language for the user ;). |
| 2575 | - if (!empty($modSettings['userLanguage'])) |
|
| 2576 | - loadLanguage('Post'); |
|
| 2577 | -} |
|
| 2714 | + if (!empty($modSettings['userLanguage'])) { |
|
| 2715 | + loadLanguage('Post'); |
|
| 2716 | + } |
|
| 2717 | + } |
|
| 2578 | 2718 | |
| 2579 | 2719 | /** |
| 2580 | 2720 | * Get the topic for display purposes. |
@@ -2587,12 +2727,13 @@ discard block |
||
| 2587 | 2727 | { |
| 2588 | 2728 | global $topic, $modSettings, $context, $smcFunc, $counter, $options; |
| 2589 | 2729 | |
| 2590 | - if (isset($_REQUEST['xml'])) |
|
| 2591 | - $limit = ' |
|
| 2730 | + if (isset($_REQUEST['xml'])) { |
|
| 2731 | + $limit = ' |
|
| 2592 | 2732 | LIMIT ' . (empty($context['new_replies']) ? '0' : $context['new_replies']); |
| 2593 | - else |
|
| 2594 | - $limit = empty($modSettings['topicSummaryPosts']) ? '' : ' |
|
| 2733 | + } else { |
|
| 2734 | + $limit = empty($modSettings['topicSummaryPosts']) ? '' : ' |
|
| 2595 | 2735 | LIMIT ' . (int) $modSettings['topicSummaryPosts']; |
| 2736 | + } |
|
| 2596 | 2737 | |
| 2597 | 2738 | // If you're modifying, get only those posts before the current one. (otherwise get all.) |
| 2598 | 2739 | $request = $smcFunc['db_query']('', ' |
@@ -2630,8 +2771,9 @@ discard block |
||
| 2630 | 2771 | 'is_ignored' => !empty($modSettings['enable_buddylist']) && !empty($options['posts_apply_ignore_list']) && in_array($row['id_member'], $context['user']['ignoreusers']), |
| 2631 | 2772 | ); |
| 2632 | 2773 | |
| 2633 | - if (!empty($context['new_replies'])) |
|
| 2634 | - $context['new_replies']--; |
|
| 2774 | + if (!empty($context['new_replies'])) { |
|
| 2775 | + $context['new_replies']--; |
|
| 2776 | + } |
|
| 2635 | 2777 | } |
| 2636 | 2778 | $smcFunc['db_free_result']($request); |
| 2637 | 2779 | } |
@@ -2648,8 +2790,9 @@ discard block |
||
| 2648 | 2790 | global $sourcedir, $smcFunc; |
| 2649 | 2791 | |
| 2650 | 2792 | loadLanguage('Post'); |
| 2651 | - if (!isset($_REQUEST['xml'])) |
|
| 2652 | - loadTemplate('Post'); |
|
| 2793 | + if (!isset($_REQUEST['xml'])) { |
|
| 2794 | + loadTemplate('Post'); |
|
| 2795 | + } |
|
| 2653 | 2796 | |
| 2654 | 2797 | include_once($sourcedir . '/Subs-Post.php'); |
| 2655 | 2798 | |
@@ -2680,8 +2823,9 @@ discard block |
||
| 2680 | 2823 | $smcFunc['db_free_result']($request); |
| 2681 | 2824 | |
| 2682 | 2825 | $context['sub_template'] = 'quotefast'; |
| 2683 | - if (!empty($row)) |
|
| 2684 | - $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
| 2826 | + if (!empty($row)) { |
|
| 2827 | + $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
| 2828 | + } |
|
| 2685 | 2829 | |
| 2686 | 2830 | if (!empty($can_view_post)) |
| 2687 | 2831 | { |
@@ -2714,8 +2858,9 @@ discard block |
||
| 2714 | 2858 | } |
| 2715 | 2859 | |
| 2716 | 2860 | // Remove any nested quotes. |
| 2717 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
| 2718 | - $row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']); |
|
| 2861 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
| 2862 | + $row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']); |
|
| 2863 | + } |
|
| 2719 | 2864 | |
| 2720 | 2865 | $lb = "\n"; |
| 2721 | 2866 | |
@@ -2741,14 +2886,14 @@ discard block |
||
| 2741 | 2886 | 'time' => '', |
| 2742 | 2887 | ), |
| 2743 | 2888 | ); |
| 2744 | - } |
|
| 2745 | - else |
|
| 2746 | - $context['quote'] = array( |
|
| 2889 | + } else { |
|
| 2890 | + $context['quote'] = array( |
|
| 2747 | 2891 | 'xml' => '', |
| 2748 | 2892 | 'mozilla' => '', |
| 2749 | 2893 | 'text' => '', |
| 2750 | 2894 | ); |
| 2751 | -} |
|
| 2895 | + } |
|
| 2896 | + } |
|
| 2752 | 2897 | |
| 2753 | 2898 | /** |
| 2754 | 2899 | * Used to edit the body or subject of a message inline |
@@ -2760,8 +2905,9 @@ discard block |
||
| 2760 | 2905 | global $user_info, $context, $smcFunc, $language, $board_info; |
| 2761 | 2906 | |
| 2762 | 2907 | // We have to have a topic! |
| 2763 | - if (empty($topic)) |
|
| 2764 | - obExit(false); |
|
| 2908 | + if (empty($topic)) { |
|
| 2909 | + obExit(false); |
|
| 2910 | + } |
|
| 2765 | 2911 | |
| 2766 | 2912 | checkSession('get'); |
| 2767 | 2913 | require_once($sourcedir . '/Subs-Post.php'); |
@@ -2787,31 +2933,35 @@ discard block |
||
| 2787 | 2933 | 'guest_id' => 0, |
| 2788 | 2934 | ) |
| 2789 | 2935 | ); |
| 2790 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 2791 | - fatal_lang_error('no_board', false); |
|
| 2936 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 2937 | + fatal_lang_error('no_board', false); |
|
| 2938 | + } |
|
| 2792 | 2939 | $row = $smcFunc['db_fetch_assoc']($request); |
| 2793 | 2940 | $smcFunc['db_free_result']($request); |
| 2794 | 2941 | |
| 2795 | 2942 | // Change either body or subject requires permissions to modify messages. |
| 2796 | 2943 | if (isset($_POST['message']) || isset($_POST['subject']) || isset($_REQUEST['icon'])) |
| 2797 | 2944 | { |
| 2798 | - if (!empty($row['locked'])) |
|
| 2799 | - isAllowedTo('moderate_board'); |
|
| 2945 | + if (!empty($row['locked'])) { |
|
| 2946 | + isAllowedTo('moderate_board'); |
|
| 2947 | + } |
|
| 2800 | 2948 | |
| 2801 | 2949 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
| 2802 | 2950 | { |
| 2803 | - if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
| 2804 | - fatal_lang_error('modify_post_time_passed', false); |
|
| 2805 | - elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
|
| 2806 | - isAllowedTo('modify_replies'); |
|
| 2807 | - else |
|
| 2808 | - isAllowedTo('modify_own'); |
|
| 2951 | + if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
| 2952 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 2953 | + } elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
| 2954 | + isAllowedTo('modify_replies'); |
|
| 2955 | + } else { |
|
| 2956 | + isAllowedTo('modify_own'); |
|
| 2957 | + } |
|
| 2809 | 2958 | } |
| 2810 | 2959 | // Otherwise, they're locked out; someone who can modify the replies is needed. |
| 2811 | - elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 2812 | - isAllowedTo('modify_replies'); |
|
| 2813 | - else |
|
| 2814 | - isAllowedTo('modify_any'); |
|
| 2960 | + elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
| 2961 | + isAllowedTo('modify_replies'); |
|
| 2962 | + } else { |
|
| 2963 | + isAllowedTo('modify_any'); |
|
| 2964 | + } |
|
| 2815 | 2965 | |
| 2816 | 2966 | // Only log this action if it wasn't your message. |
| 2817 | 2967 | $moderationAction = $row['id_member'] != $user_info['id']; |
@@ -2823,10 +2973,10 @@ discard block |
||
| 2823 | 2973 | $_POST['subject'] = strtr($smcFunc['htmlspecialchars']($_POST['subject']), array("\r" => '', "\n" => '', "\t" => '')); |
| 2824 | 2974 | |
| 2825 | 2975 | // Maximum number of characters. |
| 2826 | - if ($smcFunc['strlen']($_POST['subject']) > 100) |
|
| 2827 | - $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
| 2828 | - } |
|
| 2829 | - elseif (isset($_POST['subject'])) |
|
| 2976 | + if ($smcFunc['strlen']($_POST['subject']) > 100) { |
|
| 2977 | + $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
| 2978 | + } |
|
| 2979 | + } elseif (isset($_POST['subject'])) |
|
| 2830 | 2980 | { |
| 2831 | 2981 | $post_errors[] = 'no_subject'; |
| 2832 | 2982 | unset($_POST['subject']); |
@@ -2838,13 +2988,11 @@ discard block |
||
| 2838 | 2988 | { |
| 2839 | 2989 | $post_errors[] = 'no_message'; |
| 2840 | 2990 | unset($_POST['message']); |
| 2841 | - } |
|
| 2842 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
| 2991 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
| 2843 | 2992 | { |
| 2844 | 2993 | $post_errors[] = 'long_message'; |
| 2845 | 2994 | unset($_POST['message']); |
| 2846 | - } |
|
| 2847 | - else |
|
| 2995 | + } else |
|
| 2848 | 2996 | { |
| 2849 | 2997 | $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES); |
| 2850 | 2998 | |
@@ -2860,31 +3008,34 @@ discard block |
||
| 2860 | 3008 | |
| 2861 | 3009 | if (isset($_POST['lock'])) |
| 2862 | 3010 | { |
| 2863 | - if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) |
|
| 2864 | - unset($_POST['lock']); |
|
| 2865 | - elseif (!allowedTo('lock_any')) |
|
| 3011 | + if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) { |
|
| 3012 | + unset($_POST['lock']); |
|
| 3013 | + } elseif (!allowedTo('lock_any')) |
|
| 2866 | 3014 | { |
| 2867 | - if ($row['locked'] == 1) |
|
| 2868 | - unset($_POST['lock']); |
|
| 2869 | - else |
|
| 2870 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 3015 | + if ($row['locked'] == 1) { |
|
| 3016 | + unset($_POST['lock']); |
|
| 3017 | + } else { |
|
| 3018 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 3019 | + } |
|
| 3020 | + } elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) { |
|
| 3021 | + unset($_POST['lock']); |
|
| 3022 | + } else { |
|
| 3023 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
|
| 2871 | 3024 | } |
| 2872 | - elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) |
|
| 2873 | - unset($_POST['lock']); |
|
| 2874 | - else |
|
| 2875 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
|
| 2876 | 3025 | } |
| 2877 | 3026 | |
| 2878 | - if (isset($_POST['sticky']) && !allowedTo('make_sticky')) |
|
| 2879 | - unset($_POST['sticky']); |
|
| 3027 | + if (isset($_POST['sticky']) && !allowedTo('make_sticky')) { |
|
| 3028 | + unset($_POST['sticky']); |
|
| 3029 | + } |
|
| 2880 | 3030 | |
| 2881 | 3031 | if (isset($_POST['modify_reason'])) |
| 2882 | 3032 | { |
| 2883 | 3033 | $_POST['modify_reason'] = strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => '')); |
| 2884 | 3034 | |
| 2885 | 3035 | // Maximum number of characters. |
| 2886 | - if ($smcFunc['strlen']($_POST['modify_reason']) > 100) |
|
| 2887 | - $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
| 3036 | + if ($smcFunc['strlen']($_POST['modify_reason']) > 100) { |
|
| 3037 | + $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
| 3038 | + } |
|
| 2888 | 3039 | } |
| 2889 | 3040 | |
| 2890 | 3041 | if (empty($post_errors)) |
@@ -2921,8 +3072,9 @@ discard block |
||
| 2921 | 3072 | } |
| 2922 | 3073 | } |
| 2923 | 3074 | // If nothing was changed there's no need to add an entry to the moderation log. |
| 2924 | - else |
|
| 2925 | - $moderationAction = false; |
|
| 3075 | + else { |
|
| 3076 | + $moderationAction = false; |
|
| 3077 | + } |
|
| 2926 | 3078 | |
| 2927 | 3079 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
| 2928 | 3080 | |
@@ -2940,9 +3092,9 @@ discard block |
||
| 2940 | 3092 | // Get the proper (default language) response prefix first. |
| 2941 | 3093 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
| 2942 | 3094 | { |
| 2943 | - if ($language === $user_info['language']) |
|
| 2944 | - $context['response_prefix'] = $txt['response_prefix']; |
|
| 2945 | - else |
|
| 3095 | + if ($language === $user_info['language']) { |
|
| 3096 | + $context['response_prefix'] = $txt['response_prefix']; |
|
| 3097 | + } else |
|
| 2946 | 3098 | { |
| 2947 | 3099 | loadLanguage('index', $language, false); |
| 2948 | 3100 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -2964,8 +3116,9 @@ discard block |
||
| 2964 | 3116 | ); |
| 2965 | 3117 | } |
| 2966 | 3118 | |
| 2967 | - if (!empty($moderationAction)) |
|
| 2968 | - logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
| 3119 | + if (!empty($moderationAction)) { |
|
| 3120 | + logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
| 3121 | + } |
|
| 2969 | 3122 | } |
| 2970 | 3123 | |
| 2971 | 3124 | if (isset($_REQUEST['xml'])) |
@@ -3006,8 +3159,7 @@ discard block |
||
| 3006 | 3159 | ); |
| 3007 | 3160 | |
| 3008 | 3161 | censorText($context['message']['subject']); |
| 3009 | - } |
|
| 3010 | - else |
|
| 3162 | + } else |
|
| 3011 | 3163 | { |
| 3012 | 3164 | $context['message'] = array( |
| 3013 | 3165 | 'id' => $row['id_msg'], |
@@ -3019,15 +3171,16 @@ discard block |
||
| 3019 | 3171 | loadLanguage('Errors'); |
| 3020 | 3172 | foreach ($post_errors as $post_error) |
| 3021 | 3173 | { |
| 3022 | - if ($post_error == 'long_message') |
|
| 3023 | - $context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']); |
|
| 3024 | - else |
|
| 3025 | - $context['message']['errors'][] = $txt['error_' . $post_error]; |
|
| 3174 | + if ($post_error == 'long_message') { |
|
| 3175 | + $context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']); |
|
| 3176 | + } else { |
|
| 3177 | + $context['message']['errors'][] = $txt['error_' . $post_error]; |
|
| 3178 | + } |
|
| 3026 | 3179 | } |
| 3027 | 3180 | } |
| 3181 | + } else { |
|
| 3182 | + obExit(false); |
|
| 3183 | + } |
|
| 3028 | 3184 | } |
| 3029 | - else |
|
| 3030 | - obExit(false); |
|
| 3031 | -} |
|
| 3032 | 3185 | |
| 3033 | 3186 | ?> |
| 3034 | 3187 | \ No newline at end of file |