@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 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']); |
@@ -55,8 +58,9 @@ discard block |
||
| 55 | 58 | $context['auto_notify'] = !empty($context['notify_prefs']['msg_auto_notify']); |
| 56 | 59 | |
| 57 | 60 | // You must be posting to *some* board. |
| 58 | - if (empty($board) && !$context['make_event']) |
|
| 59 | - fatal_lang_error('no_board', false); |
|
| 61 | + if (empty($board) && !$context['make_event']) { |
|
| 62 | + fatal_lang_error('no_board', false); |
|
| 63 | + } |
|
| 60 | 64 | |
| 61 | 65 | require_once($sourcedir . '/Subs-Post.php'); |
| 62 | 66 | |
@@ -79,10 +83,11 @@ discard block |
||
| 79 | 83 | array( |
| 80 | 84 | 'msg' => (int) $_REQUEST['msg'], |
| 81 | 85 | )); |
| 82 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
| 83 | - unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
|
| 84 | - else |
|
| 85 | - list ($topic) = $smcFunc['db_fetch_row']($request); |
|
| 86 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
| 87 | + unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
|
| 88 | + } else { |
|
| 89 | + list ($topic) = $smcFunc['db_fetch_row']($request); |
|
| 90 | + } |
|
| 86 | 91 | $smcFunc['db_free_result']($request); |
| 87 | 92 | } |
| 88 | 93 | |
@@ -109,33 +114,36 @@ discard block |
||
| 109 | 114 | $smcFunc['db_free_result']($request); |
| 110 | 115 | |
| 111 | 116 | // If this topic already has a poll, they sure can't add another. |
| 112 | - if (isset($_REQUEST['poll']) && $pollID > 0) |
|
| 113 | - unset($_REQUEST['poll']); |
|
| 117 | + if (isset($_REQUEST['poll']) && $pollID > 0) { |
|
| 118 | + unset($_REQUEST['poll']); |
|
| 119 | + } |
|
| 114 | 120 | |
| 115 | 121 | if (empty($_REQUEST['msg'])) |
| 116 | 122 | { |
| 117 | - if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) |
|
| 118 | - is_not_guest(); |
|
| 123 | + if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) { |
|
| 124 | + is_not_guest(); |
|
| 125 | + } |
|
| 119 | 126 | |
| 120 | 127 | // By default the reply will be approved... |
| 121 | 128 | $context['becomes_approved'] = true; |
| 122 | 129 | if ($id_member_poster != $user_info['id'] || $user_info['is_guest']) |
| 123 | 130 | { |
| 124 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
|
| 125 | - $context['becomes_approved'] = false; |
|
| 126 | - else |
|
| 127 | - isAllowedTo('post_reply_any'); |
|
| 128 | - } |
|
| 129 | - elseif (!allowedTo('post_reply_any')) |
|
| 131 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) { |
|
| 132 | + $context['becomes_approved'] = false; |
|
| 133 | + } else { |
|
| 134 | + isAllowedTo('post_reply_any'); |
|
| 135 | + } |
|
| 136 | + } elseif (!allowedTo('post_reply_any')) |
|
| 130 | 137 | { |
| 131 | - if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) |
|
| 132 | - $context['becomes_approved'] = false; |
|
| 133 | - else |
|
| 134 | - isAllowedTo('post_reply_own'); |
|
| 138 | + if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) { |
|
| 139 | + $context['becomes_approved'] = false; |
|
| 140 | + } else { |
|
| 141 | + isAllowedTo('post_reply_own'); |
|
| 142 | + } |
|
| 135 | 143 | } |
| 144 | + } else { |
|
| 145 | + $context['becomes_approved'] = true; |
|
| 136 | 146 | } |
| 137 | - else |
|
| 138 | - $context['becomes_approved'] = true; |
|
| 139 | 147 | |
| 140 | 148 | $context['can_lock'] = allowedTo('lock_any') || ($user_info['id'] == $id_member_poster && allowedTo('lock_own')); |
| 141 | 149 | $context['can_sticky'] = allowedTo('make_sticky'); |
@@ -147,18 +155,19 @@ discard block |
||
| 147 | 155 | $context['sticky'] = isset($_REQUEST['sticky']) ? !empty($_REQUEST['sticky']) : $sticky; |
| 148 | 156 | |
| 149 | 157 | // Check whether this is a really old post being bumped... |
| 150 | - if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) |
|
| 151 | - $post_errors[] = array('old_topic', array($modSettings['oldTopicDays'])); |
|
| 152 | - } |
|
| 153 | - else |
|
| 158 | + if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) { |
|
| 159 | + $post_errors[] = array('old_topic', array($modSettings['oldTopicDays'])); |
|
| 160 | + } |
|
| 161 | + } else |
|
| 154 | 162 | { |
| 155 | 163 | $context['becomes_approved'] = true; |
| 156 | 164 | if ((!$context['make_event'] || !empty($board))) |
| 157 | 165 | { |
| 158 | - if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) |
|
| 159 | - $context['becomes_approved'] = false; |
|
| 160 | - else |
|
| 161 | - isAllowedTo('post_new'); |
|
| 166 | + if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) { |
|
| 167 | + $context['becomes_approved'] = false; |
|
| 168 | + } else { |
|
| 169 | + isAllowedTo('post_new'); |
|
| 170 | + } |
|
| 162 | 171 | } |
| 163 | 172 | |
| 164 | 173 | $locked = 0; |
@@ -194,20 +203,24 @@ discard block |
||
| 194 | 203 | } |
| 195 | 204 | |
| 196 | 205 | // Don't allow a post if it's locked and you aren't all powerful. |
| 197 | - if ($locked && !allowedTo('moderate_board')) |
|
| 198 | - fatal_lang_error('topic_locked', false); |
|
| 206 | + if ($locked && !allowedTo('moderate_board')) { |
|
| 207 | + fatal_lang_error('topic_locked', false); |
|
| 208 | + } |
|
| 199 | 209 | // Check the users permissions - is the user allowed to add or post a poll? |
| 200 | 210 | if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1') |
| 201 | 211 | { |
| 202 | 212 | // New topic, new poll. |
| 203 | - if (empty($topic)) |
|
| 204 | - isAllowedTo('poll_post'); |
|
| 213 | + if (empty($topic)) { |
|
| 214 | + isAllowedTo('poll_post'); |
|
| 215 | + } |
|
| 205 | 216 | // This is an old topic - but it is yours! Can you add to it? |
| 206 | - elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) |
|
| 207 | - isAllowedTo('poll_add_own'); |
|
| 217 | + elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) { |
|
| 218 | + isAllowedTo('poll_add_own'); |
|
| 219 | + } |
|
| 208 | 220 | // If you're not the owner, can you add to any poll? |
| 209 | - else |
|
| 210 | - isAllowedTo('poll_add_any'); |
|
| 221 | + else { |
|
| 222 | + isAllowedTo('poll_add_any'); |
|
| 223 | + } |
|
| 211 | 224 | |
| 212 | 225 | require_once($sourcedir . '/Subs-Members.php'); |
| 213 | 226 | $allowedVoteGroups = groupsAllowedTo('poll_vote', $board); |
@@ -236,8 +249,9 @@ discard block |
||
| 236 | 249 | if ($context['make_event']) |
| 237 | 250 | { |
| 238 | 251 | // They might want to pick a board. |
| 239 | - if (!isset($context['current_board'])) |
|
| 240 | - $context['current_board'] = 0; |
|
| 252 | + if (!isset($context['current_board'])) { |
|
| 253 | + $context['current_board'] = 0; |
|
| 254 | + } |
|
| 241 | 255 | |
| 242 | 256 | // Start loading up the event info. |
| 243 | 257 | $context['event'] = array(); |
@@ -251,10 +265,11 @@ discard block |
||
| 251 | 265 | isAllowedTo('calendar_post'); |
| 252 | 266 | |
| 253 | 267 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
| 254 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
| 255 | - $time_string = '%k:%M'; |
|
| 256 | - else |
|
| 257 | - $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 268 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
| 269 | + $time_string = '%k:%M'; |
|
| 270 | + } else { |
|
| 271 | + $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 272 | + } |
|
| 258 | 273 | |
| 259 | 274 | $js_time_string = str_replace( |
| 260 | 275 | array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
@@ -276,8 +291,7 @@ discard block |
||
| 276 | 291 | require_once($sourcedir . '/Subs-Calendar.php'); |
| 277 | 292 | $eventProperties = getEventProperties($context['event']['id']); |
| 278 | 293 | $context['event'] = array_merge($context['event'], $eventProperties); |
| 279 | - } |
|
| 280 | - else |
|
| 294 | + } else |
|
| 281 | 295 | { |
| 282 | 296 | // Get the current event information. |
| 283 | 297 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -285,15 +299,18 @@ discard block |
||
| 285 | 299 | $context['event'] = array_merge($context['event'], $eventProperties); |
| 286 | 300 | |
| 287 | 301 | // Make sure the year and month are in the valid range. |
| 288 | - if ($context['event']['month'] < 1 || $context['event']['month'] > 12) |
|
| 289 | - fatal_lang_error('invalid_month', false); |
|
| 290 | - if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) |
|
| 291 | - fatal_lang_error('invalid_year', false); |
|
| 302 | + if ($context['event']['month'] < 1 || $context['event']['month'] > 12) { |
|
| 303 | + fatal_lang_error('invalid_month', false); |
|
| 304 | + } |
|
| 305 | + if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) { |
|
| 306 | + fatal_lang_error('invalid_year', false); |
|
| 307 | + } |
|
| 292 | 308 | |
| 293 | 309 | // Get a list of boards they can post in. |
| 294 | 310 | $boards = boardsAllowedTo('post_new'); |
| 295 | - if (empty($boards)) |
|
| 296 | - fatal_lang_error('cannot_post_new', 'user'); |
|
| 311 | + if (empty($boards)) { |
|
| 312 | + fatal_lang_error('cannot_post_new', 'user'); |
|
| 313 | + } |
|
| 297 | 314 | |
| 298 | 315 | // Load a list of boards for this event in the context. |
| 299 | 316 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
@@ -412,10 +429,11 @@ discard block |
||
| 412 | 429 | |
| 413 | 430 | if (!empty($context['new_replies'])) |
| 414 | 431 | { |
| 415 | - if ($context['new_replies'] == 1) |
|
| 416 | - $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
| 417 | - else |
|
| 418 | - $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
| 432 | + if ($context['new_replies'] == 1) { |
|
| 433 | + $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
| 434 | + } else { |
|
| 435 | + $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
| 436 | + } |
|
| 419 | 437 | |
| 420 | 438 | $post_errors[] = 'new_replies'; |
| 421 | 439 | |
@@ -427,9 +445,9 @@ discard block |
||
| 427 | 445 | // Get a response prefix (like 'Re:') in the default forum language. |
| 428 | 446 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
| 429 | 447 | { |
| 430 | - if ($language === $user_info['language']) |
|
| 431 | - $context['response_prefix'] = $txt['response_prefix']; |
|
| 432 | - else |
|
| 448 | + if ($language === $user_info['language']) { |
|
| 449 | + $context['response_prefix'] = $txt['response_prefix']; |
|
| 450 | + } else |
|
| 433 | 451 | { |
| 434 | 452 | loadLanguage('index', $language, false); |
| 435 | 453 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -442,8 +460,9 @@ discard block |
||
| 442 | 460 | // Do we have a body, but an error happened. |
| 443 | 461 | if (isset($_REQUEST['message']) || isset($_REQUEST['quickReply']) || !empty($context['post_error'])) |
| 444 | 462 | { |
| 445 | - if (isset($_REQUEST['quickReply'])) |
|
| 446 | - $_REQUEST['message'] = $_REQUEST['quickReply']; |
|
| 463 | + if (isset($_REQUEST['quickReply'])) { |
|
| 464 | + $_REQUEST['message'] = $_REQUEST['quickReply']; |
|
| 465 | + } |
|
| 447 | 466 | |
| 448 | 467 | // Validate inputs. |
| 449 | 468 | if (empty($context['post_error'])) |
@@ -451,15 +470,17 @@ discard block |
||
| 451 | 470 | // This means they didn't click Post and get an error. |
| 452 | 471 | $really_previewing = true; |
| 453 | 472 | |
| 454 | - } |
|
| 455 | - else |
|
| 473 | + } else |
|
| 456 | 474 | { |
| 457 | - if (!isset($_REQUEST['subject'])) |
|
| 458 | - $_REQUEST['subject'] = ''; |
|
| 459 | - if (!isset($_REQUEST['message'])) |
|
| 460 | - $_REQUEST['message'] = ''; |
|
| 461 | - if (!isset($_REQUEST['icon'])) |
|
| 462 | - $_REQUEST['icon'] = 'xx'; |
|
| 475 | + if (!isset($_REQUEST['subject'])) { |
|
| 476 | + $_REQUEST['subject'] = ''; |
|
| 477 | + } |
|
| 478 | + if (!isset($_REQUEST['message'])) { |
|
| 479 | + $_REQUEST['message'] = ''; |
|
| 480 | + } |
|
| 481 | + if (!isset($_REQUEST['icon'])) { |
|
| 482 | + $_REQUEST['icon'] = 'xx'; |
|
| 483 | + } |
|
| 463 | 484 | |
| 464 | 485 | // They are previewing if they asked to preview (i.e. came from quick reply). |
| 465 | 486 | $really_previewing = !empty($_POST['preview']); |
@@ -475,8 +496,9 @@ discard block |
||
| 475 | 496 | $form_message = $smcFunc['htmlspecialchars']($_REQUEST['message'], ENT_QUOTES); |
| 476 | 497 | |
| 477 | 498 | // Make sure the subject isn't too long - taking into account special characters. |
| 478 | - if ($smcFunc['strlen']($form_subject) > 100) |
|
| 479 | - $form_subject = $smcFunc['substr']($form_subject, 0, 100); |
|
| 499 | + if ($smcFunc['strlen']($form_subject) > 100) { |
|
| 500 | + $form_subject = $smcFunc['substr']($form_subject, 0, 100); |
|
| 501 | + } |
|
| 480 | 502 | |
| 481 | 503 | if (isset($_REQUEST['poll'])) |
| 482 | 504 | { |
@@ -488,8 +510,9 @@ discard block |
||
| 488 | 510 | $_POST['options'] = empty($_POST['options']) ? array() : htmlspecialchars__recursive($_POST['options']); |
| 489 | 511 | foreach ($_POST['options'] as $option) |
| 490 | 512 | { |
| 491 | - if (trim($option) == '') |
|
| 492 | - continue; |
|
| 513 | + if (trim($option) == '') { |
|
| 514 | + continue; |
|
| 515 | + } |
|
| 493 | 516 | |
| 494 | 517 | $context['choices'][] = array( |
| 495 | 518 | 'id' => $choice_id++, |
@@ -551,13 +574,14 @@ discard block |
||
| 551 | 574 | $context['preview_subject'] = $form_subject; |
| 552 | 575 | |
| 553 | 576 | censorText($context['preview_subject']); |
| 577 | + } else { |
|
| 578 | + $context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>'; |
|
| 554 | 579 | } |
| 555 | - else |
|
| 556 | - $context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>'; |
|
| 557 | 580 | |
| 558 | 581 | // Protect any CDATA blocks. |
| 559 | - if (isset($_REQUEST['xml'])) |
|
| 560 | - $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]><![CDATA[>')); |
|
| 582 | + if (isset($_REQUEST['xml'])) { |
|
| 583 | + $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]>< == 0) |
|
| 600 | - fatal_lang_error('no_board', false); |
|
| 623 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 624 | + fatal_lang_error('no_board', false); |
|
| 625 | + } |
|
| 601 | 626 | $row = $smcFunc['db_fetch_assoc']($request); |
| 602 | 627 | |
| 603 | 628 | $attachment_stuff = array($row); |
| 604 | - while ($row2 = $smcFunc['db_fetch_assoc']($request)) |
|
| 605 | - $attachment_stuff[] = $row2; |
|
| 629 | + while ($row2 = $smcFunc['db_fetch_assoc']($request)) { |
|
| 630 | + $attachment_stuff[] = $row2; |
|
| 631 | + } |
|
| 606 | 632 | $smcFunc['db_free_result']($request); |
| 607 | 633 | |
| 608 | 634 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
| 609 | 635 | { |
| 610 | 636 | // Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public. |
| 611 | - if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
| 612 | - fatal_lang_error('modify_post_time_passed', false); |
|
| 613 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) |
|
| 614 | - isAllowedTo('modify_replies'); |
|
| 615 | - else |
|
| 616 | - isAllowedTo('modify_own'); |
|
| 637 | + if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
| 638 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 639 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
| 640 | + isAllowedTo('modify_replies'); |
|
| 641 | + } else { |
|
| 642 | + isAllowedTo('modify_own'); |
|
| 643 | + } |
|
| 644 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
| 645 | + isAllowedTo('modify_replies'); |
|
| 646 | + } else { |
|
| 647 | + isAllowedTo('modify_any'); |
|
| 617 | 648 | } |
| 618 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 619 | - isAllowedTo('modify_replies'); |
|
| 620 | - else |
|
| 621 | - isAllowedTo('modify_any'); |
|
| 622 | 649 | |
| 623 | 650 | if ($context['can_announce'] && !empty($row['id_action'])) |
| 624 | 651 | { |
@@ -642,8 +669,9 @@ discard block |
||
| 642 | 669 | |
| 643 | 670 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 644 | 671 | { |
| 645 | - if ($row['filesize'] <= 0) |
|
| 646 | - continue; |
|
| 672 | + if ($row['filesize'] <= 0) { |
|
| 673 | + continue; |
|
| 674 | + } |
|
| 647 | 675 | $context['current_attachments'][$row['id_attach']] = array( |
| 648 | 676 | 'name' => $smcFunc['htmlspecialchars']($row['filename']), |
| 649 | 677 | 'size' => $row['filesize'], |
@@ -713,29 +741,32 @@ discard block |
||
| 713 | 741 | ) |
| 714 | 742 | ); |
| 715 | 743 | // The message they were trying to edit was most likely deleted. |
| 716 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 717 | - fatal_lang_error('no_message', false); |
|
| 744 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 745 | + fatal_lang_error('no_message', false); |
|
| 746 | + } |
|
| 718 | 747 | $row = $smcFunc['db_fetch_assoc']($request); |
| 719 | 748 | |
| 720 | 749 | $attachment_stuff = array($row); |
| 721 | - while ($row2 = $smcFunc['db_fetch_assoc']($request)) |
|
| 722 | - $attachment_stuff[] = $row2; |
|
| 750 | + while ($row2 = $smcFunc['db_fetch_assoc']($request)) { |
|
| 751 | + $attachment_stuff[] = $row2; |
|
| 752 | + } |
|
| 723 | 753 | $smcFunc['db_free_result']($request); |
| 724 | 754 | |
| 725 | 755 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
| 726 | 756 | { |
| 727 | 757 | // Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public. |
| 728 | - if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
| 729 | - fatal_lang_error('modify_post_time_passed', false); |
|
| 730 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) |
|
| 731 | - isAllowedTo('modify_replies'); |
|
| 732 | - else |
|
| 733 | - isAllowedTo('modify_own'); |
|
| 758 | + if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
| 759 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 760 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
| 761 | + isAllowedTo('modify_replies'); |
|
| 762 | + } else { |
|
| 763 | + isAllowedTo('modify_own'); |
|
| 764 | + } |
|
| 765 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
| 766 | + isAllowedTo('modify_replies'); |
|
| 767 | + } else { |
|
| 768 | + isAllowedTo('modify_any'); |
|
| 734 | 769 | } |
| 735 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 736 | - isAllowedTo('modify_replies'); |
|
| 737 | - else |
|
| 738 | - isAllowedTo('modify_any'); |
|
| 739 | 770 | |
| 740 | 771 | if ($context['can_announce'] && !empty($row['id_action'])) |
| 741 | 772 | { |
@@ -762,15 +793,17 @@ discard block |
||
| 762 | 793 | $context['icon'] = $row['icon']; |
| 763 | 794 | |
| 764 | 795 | // Show an "approve" box if the user can approve it, and the message isn't approved. |
| 765 | - if (!$row['approved'] && !$context['show_approval']) |
|
| 766 | - $context['show_approval'] = allowedTo('approve_posts'); |
|
| 796 | + if (!$row['approved'] && !$context['show_approval']) { |
|
| 797 | + $context['show_approval'] = allowedTo('approve_posts'); |
|
| 798 | + } |
|
| 767 | 799 | |
| 768 | 800 | // Sort the attachments so they are in the order saved |
| 769 | 801 | $temp = array(); |
| 770 | 802 | foreach ($attachment_stuff as $attachment) |
| 771 | 803 | { |
| 772 | - if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) |
|
| 773 | - $temp[$attachment['id_attach']] = $attachment; |
|
| 804 | + if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) { |
|
| 805 | + $temp[$attachment['id_attach']] = $attachment; |
|
| 806 | + } |
|
| 774 | 807 | |
| 775 | 808 | } |
| 776 | 809 | ksort($temp); |
@@ -832,14 +865,16 @@ discard block |
||
| 832 | 865 | 'is_approved' => 1, |
| 833 | 866 | ) |
| 834 | 867 | ); |
| 835 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 836 | - fatal_lang_error('quoted_post_deleted', false); |
|
| 868 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 869 | + fatal_lang_error('quoted_post_deleted', false); |
|
| 870 | + } |
|
| 837 | 871 | list ($form_subject, $mname, $mdate, $form_message) = $smcFunc['db_fetch_row']($request); |
| 838 | 872 | $smcFunc['db_free_result']($request); |
| 839 | 873 | |
| 840 | 874 | // Add 'Re: ' to the front of the quoted subject. |
| 841 | - if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
| 842 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
| 875 | + if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
| 876 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
| 877 | + } |
|
| 843 | 878 | |
| 844 | 879 | // Censor the message and subject. |
| 845 | 880 | censorText($form_message); |
@@ -852,10 +887,11 @@ discard block |
||
| 852 | 887 | for ($i = 0, $n = count($parts); $i < $n; $i++) |
| 853 | 888 | { |
| 854 | 889 | // It goes 0 = outside, 1 = begin tag, 2 = inside, 3 = close tag, repeat. |
| 855 | - if ($i % 4 == 0) |
|
| 856 | - $parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) |
|
| 890 | + if ($i % 4 == 0) { |
|
| 891 | + $parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) |
|
| 857 | 892 | { |
| 858 | 893 | return '[html]' . preg_replace('~<br\s?/?' . '>~i', '<br /><br>', "$m[1]") . '[/html]'; |
| 894 | + } |
|
| 859 | 895 | }, $parts[$i]); |
| 860 | 896 | } |
| 861 | 897 | $form_message = implode('', $parts); |
@@ -864,8 +900,9 @@ discard block |
||
| 864 | 900 | $form_message = preg_replace('~<br ?/?' . '>~i', "\n", $form_message); |
| 865 | 901 | |
| 866 | 902 | // Remove any nested quotes, if necessary. |
| 867 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
| 868 | - $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
| 903 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
| 904 | + $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
| 905 | + } |
|
| 869 | 906 | |
| 870 | 907 | // Add a quote string on the front and end. |
| 871 | 908 | $form_message = '[quote author=' . $mname . ' link=msg=' . (int) $_REQUEST['quote'] . ' date=' . $mdate . ']' . "\n" . rtrim($form_message) . "\n" . '[/quote]'; |
@@ -877,15 +914,15 @@ discard block |
||
| 877 | 914 | $form_subject = $first_subject; |
| 878 | 915 | |
| 879 | 916 | // Add 'Re: ' to the front of the subject. |
| 880 | - if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
| 881 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
| 917 | + if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
| 918 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
| 919 | + } |
|
| 882 | 920 | |
| 883 | 921 | // Censor the subject. |
| 884 | 922 | censorText($form_subject); |
| 885 | 923 | |
| 886 | 924 | $form_message = ''; |
| 887 | - } |
|
| 888 | - else |
|
| 925 | + } else |
|
| 889 | 926 | { |
| 890 | 927 | $form_subject = isset($_GET['subject']) ? $_GET['subject'] : ''; |
| 891 | 928 | $form_message = ''; |
@@ -903,13 +940,15 @@ discard block |
||
| 903 | 940 | if (isset($_REQUEST['msg'])) |
| 904 | 941 | { |
| 905 | 942 | $context['attachments']['quantity'] = count($context['current_attachments']); |
| 906 | - foreach ($context['current_attachments'] as $attachment) |
|
| 907 | - $context['attachments']['total_size'] += $attachment['size']; |
|
| 943 | + foreach ($context['current_attachments'] as $attachment) { |
|
| 944 | + $context['attachments']['total_size'] += $attachment['size']; |
|
| 945 | + } |
|
| 908 | 946 | } |
| 909 | 947 | |
| 910 | 948 | // A bit of house keeping first. |
| 911 | - if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) |
|
| 912 | - unset($_SESSION['temp_attachments']); |
|
| 949 | + if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) { |
|
| 950 | + unset($_SESSION['temp_attachments']); |
|
| 951 | + } |
|
| 913 | 952 | |
| 914 | 953 | if (!empty($_SESSION['temp_attachments'])) |
| 915 | 954 | { |
@@ -918,9 +957,10 @@ discard block |
||
| 918 | 957 | { |
| 919 | 958 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 920 | 959 | { |
| 921 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
| 922 | - if (file_exists($attachment['tmp_name'])) |
|
| 960 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) { |
|
| 961 | + if (file_exists($attachment['tmp_name'])) |
|
| 923 | 962 | unlink($attachment['tmp_name']); |
| 963 | + } |
|
| 924 | 964 | } |
| 925 | 965 | $post_errors[] = 'temp_attachments_gone'; |
| 926 | 966 | $_SESSION['temp_attachments'] = array(); |
@@ -934,8 +974,9 @@ discard block |
||
| 934 | 974 | // See if any files still exist before showing the warning message and the files attached. |
| 935 | 975 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 936 | 976 | { |
| 937 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
| 938 | - continue; |
|
| 977 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
| 978 | + continue; |
|
| 979 | + } |
|
| 939 | 980 | |
| 940 | 981 | if (file_exists($attachment['tmp_name'])) |
| 941 | 982 | { |
@@ -945,20 +986,21 @@ discard block |
||
| 945 | 986 | break; |
| 946 | 987 | } |
| 947 | 988 | } |
| 948 | - } |
|
| 949 | - else |
|
| 989 | + } else |
|
| 950 | 990 | { |
| 951 | 991 | // Since, they don't belong here. Let's inform the user that they exist.. |
| 952 | - if (!empty($topic)) |
|
| 953 | - $delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp'; |
|
| 954 | - else |
|
| 955 | - $delete_url = $scripturl . '?action=post;board=' . $board . ';delete_temp'; |
|
| 992 | + if (!empty($topic)) { |
|
| 993 | + $delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp'; |
|
| 994 | + } else { |
|
| 995 | + $delete_url = $scripturl . '?action=post;board=' . $board . ';delete_temp'; |
|
| 996 | + } |
|
| 956 | 997 | |
| 957 | 998 | // Compile a list of the files to show the user. |
| 958 | 999 | $file_list = array(); |
| 959 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
| 960 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
| 1000 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) { |
|
| 1001 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
| 961 | 1002 | $file_list[] = $attachment['name']; |
| 1003 | + } |
|
| 962 | 1004 | |
| 963 | 1005 | $_SESSION['temp_attachments']['post']['files'] = $file_list; |
| 964 | 1006 | $file_list = '<div class="attachments">' . implode('<br>', $file_list) . '</div>'; |
@@ -970,8 +1012,7 @@ discard block |
||
| 970 | 1012 | |
| 971 | 1013 | $post_errors[] = array('temp_attachments_found', array($delete_url, $goback_url, $file_list)); |
| 972 | 1014 | $context['ignore_temp_attachments'] = true; |
| 973 | - } |
|
| 974 | - else |
|
| 1015 | + } else |
|
| 975 | 1016 | { |
| 976 | 1017 | $post_errors[] = array('temp_attachments_lost', array($delete_url, $file_list)); |
| 977 | 1018 | $context['ignore_temp_attachments'] = true; |
@@ -979,16 +1020,19 @@ discard block |
||
| 979 | 1020 | } |
| 980 | 1021 | } |
| 981 | 1022 | |
| 982 | - if (!empty($context['we_are_history'])) |
|
| 983 | - $post_errors[] = $context['we_are_history']; |
|
| 1023 | + if (!empty($context['we_are_history'])) { |
|
| 1024 | + $post_errors[] = $context['we_are_history']; |
|
| 1025 | + } |
|
| 984 | 1026 | |
| 985 | 1027 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 986 | 1028 | { |
| 987 | - if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) |
|
| 988 | - break; |
|
| 1029 | + if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) { |
|
| 1030 | + break; |
|
| 1031 | + } |
|
| 989 | 1032 | |
| 990 | - if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
| 991 | - continue; |
|
| 1033 | + if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
| 1034 | + continue; |
|
| 1035 | + } |
|
| 992 | 1036 | |
| 993 | 1037 | if ($attachID == 'initial_error') |
| 994 | 1038 | { |
@@ -1003,15 +1047,17 @@ discard block |
||
| 1003 | 1047 | { |
| 1004 | 1048 | $txt['error_attach_errors'] = empty($txt['error_attach_errors']) ? '<br>' : ''; |
| 1005 | 1049 | $txt['error_attach_errors'] .= vsprintf($txt['attach_warning'], $attachment['name']) . '<div style="padding: 0 1em;">'; |
| 1006 | - foreach ($attachment['errors'] as $error) |
|
| 1007 | - $txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >'; |
|
| 1050 | + foreach ($attachment['errors'] as $error) { |
|
| 1051 | + $txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >'; |
|
| 1052 | + } |
|
| 1008 | 1053 | $txt['error_attach_errors'] .= '</div>'; |
| 1009 | 1054 | $post_errors[] = 'attach_errors'; |
| 1010 | 1055 | |
| 1011 | 1056 | // Take out the trash. |
| 1012 | 1057 | unset($_SESSION['temp_attachments'][$attachID]); |
| 1013 | - if (file_exists($attachment['tmp_name'])) |
|
| 1014 | - unlink($attachment['tmp_name']); |
|
| 1058 | + if (file_exists($attachment['tmp_name'])) { |
|
| 1059 | + unlink($attachment['tmp_name']); |
|
| 1060 | + } |
|
| 1015 | 1061 | continue; |
| 1016 | 1062 | } |
| 1017 | 1063 | |
@@ -1024,8 +1070,9 @@ discard block |
||
| 1024 | 1070 | |
| 1025 | 1071 | $context['attachments']['quantity']++; |
| 1026 | 1072 | $context['attachments']['total_size'] += $attachment['size']; |
| 1027 | - if (!isset($context['files_in_session_warning'])) |
|
| 1028 | - $context['files_in_session_warning'] = $txt['attached_files_in_session']; |
|
| 1073 | + if (!isset($context['files_in_session_warning'])) { |
|
| 1074 | + $context['files_in_session_warning'] = $txt['attached_files_in_session']; |
|
| 1075 | + } |
|
| 1029 | 1076 | |
| 1030 | 1077 | $context['current_attachments'][$attachID] = array( |
| 1031 | 1078 | 'name' => '<u>' . $smcFunc['htmlspecialchars']($attachment['name']) . '</u>', |
@@ -1053,8 +1100,9 @@ discard block |
||
| 1053 | 1100 | } |
| 1054 | 1101 | |
| 1055 | 1102 | // If they came from quick reply, and have to enter verification details, give them some notice. |
| 1056 | - if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) |
|
| 1057 | - $post_errors[] = 'need_qr_verification'; |
|
| 1103 | + if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) { |
|
| 1104 | + $post_errors[] = 'need_qr_verification'; |
|
| 1105 | + } |
|
| 1058 | 1106 | |
| 1059 | 1107 | /* |
| 1060 | 1108 | * There are two error types: serious and minor. Serious errors |
@@ -1071,52 +1119,56 @@ discard block |
||
| 1071 | 1119 | { |
| 1072 | 1120 | loadLanguage('Errors'); |
| 1073 | 1121 | $context['error_type'] = 'minor'; |
| 1074 | - foreach ($post_errors as $post_error) |
|
| 1075 | - if (is_array($post_error)) |
|
| 1122 | + foreach ($post_errors as $post_error) { |
|
| 1123 | + if (is_array($post_error)) |
|
| 1076 | 1124 | { |
| 1077 | 1125 | $post_error_id = $post_error[0]; |
| 1126 | + } |
|
| 1078 | 1127 | $context['post_error'][$post_error_id] = vsprintf($txt['error_' . $post_error_id], $post_error[1]); |
| 1079 | 1128 | |
| 1080 | 1129 | // If it's not a minor error flag it as such. |
| 1081 | - if (!in_array($post_error_id, $minor_errors)) |
|
| 1082 | - $context['error_type'] = 'serious'; |
|
| 1083 | - } |
|
| 1084 | - else |
|
| 1130 | + if (!in_array($post_error_id, $minor_errors)) { |
|
| 1131 | + $context['error_type'] = 'serious'; |
|
| 1132 | + } |
|
| 1133 | + } else |
|
| 1085 | 1134 | { |
| 1086 | 1135 | $context['post_error'][$post_error] = $txt['error_' . $post_error]; |
| 1087 | 1136 | |
| 1088 | 1137 | // If it's not a minor error flag it as such. |
| 1089 | - if (!in_array($post_error, $minor_errors)) |
|
| 1090 | - $context['error_type'] = 'serious'; |
|
| 1138 | + if (!in_array($post_error, $minor_errors)) { |
|
| 1139 | + $context['error_type'] = 'serious'; |
|
| 1140 | + } |
|
| 1091 | 1141 | } |
| 1092 | 1142 | } |
| 1093 | 1143 | |
| 1094 | 1144 | // What are you doing? Posting a poll, modifying, previewing, new post, or reply... |
| 1095 | - if (isset($_REQUEST['poll'])) |
|
| 1096 | - $context['page_title'] = $txt['new_poll']; |
|
| 1097 | - elseif ($context['make_event']) |
|
| 1098 | - $context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit']; |
|
| 1099 | - elseif (isset($_REQUEST['msg'])) |
|
| 1100 | - $context['page_title'] = $txt['modify_msg']; |
|
| 1101 | - elseif (isset($_REQUEST['subject'], $context['preview_subject'])) |
|
| 1102 | - $context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']); |
|
| 1103 | - elseif (empty($topic)) |
|
| 1104 | - $context['page_title'] = $txt['start_new_topic']; |
|
| 1105 | - else |
|
| 1106 | - $context['page_title'] = $txt['post_reply']; |
|
| 1145 | + if (isset($_REQUEST['poll'])) { |
|
| 1146 | + $context['page_title'] = $txt['new_poll']; |
|
| 1147 | + } elseif ($context['make_event']) { |
|
| 1148 | + $context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit']; |
|
| 1149 | + } elseif (isset($_REQUEST['msg'])) { |
|
| 1150 | + $context['page_title'] = $txt['modify_msg']; |
|
| 1151 | + } elseif (isset($_REQUEST['subject'], $context['preview_subject'])) { |
|
| 1152 | + $context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']); |
|
| 1153 | + } elseif (empty($topic)) { |
|
| 1154 | + $context['page_title'] = $txt['start_new_topic']; |
|
| 1155 | + } else { |
|
| 1156 | + $context['page_title'] = $txt['post_reply']; |
|
| 1157 | + } |
|
| 1107 | 1158 | |
| 1108 | 1159 | // Build the link tree. |
| 1109 | - if (empty($topic)) |
|
| 1110 | - $context['linktree'][] = array( |
|
| 1160 | + if (empty($topic)) { |
|
| 1161 | + $context['linktree'][] = array( |
|
| 1111 | 1162 | 'name' => '<em>' . $txt['start_new_topic'] . '</em>' |
| 1112 | 1163 | ); |
| 1113 | - else |
|
| 1114 | - $context['linktree'][] = array( |
|
| 1164 | + } else { |
|
| 1165 | + $context['linktree'][] = array( |
|
| 1115 | 1166 | 'url' => $scripturl . '?topic=' . $topic . '.' . $_REQUEST['start'], |
| 1116 | 1167 | 'name' => $form_subject, |
| 1117 | 1168 | 'extra_before' => '<span><strong class="nav">' . $context['page_title'] . ' (</strong></span>', |
| 1118 | 1169 | 'extra_after' => '<span><strong class="nav">)</strong></span>' |
| 1119 | 1170 | ); |
| 1171 | + } |
|
| 1120 | 1172 | |
| 1121 | 1173 | $context['subject'] = addcslashes($form_subject, '"'); |
| 1122 | 1174 | $context['message'] = str_replace(array('"', '<', '>', ' '), array('"', '<', '>', ' '), $form_message); |
@@ -1160,8 +1212,9 @@ discard block |
||
| 1160 | 1212 | // Message icons - customized icons are off? |
| 1161 | 1213 | $context['icons'] = getMessageIcons($board); |
| 1162 | 1214 | |
| 1163 | - if (!empty($context['icons'])) |
|
| 1164 | - $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
| 1215 | + if (!empty($context['icons'])) { |
|
| 1216 | + $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
| 1217 | + } |
|
| 1165 | 1218 | |
| 1166 | 1219 | // Are we starting a poll? if set the poll icon as selected if its available |
| 1167 | 1220 | if (isset($_REQUEST['poll'])) |
@@ -1181,8 +1234,9 @@ discard block |
||
| 1181 | 1234 | for ($i = 0, $n = count($context['icons']); $i < $n; $i++) |
| 1182 | 1235 | { |
| 1183 | 1236 | $context['icons'][$i]['selected'] = $context['icon'] == $context['icons'][$i]['value']; |
| 1184 | - if ($context['icons'][$i]['selected']) |
|
| 1185 | - $context['icon_url'] = $context['icons'][$i]['url']; |
|
| 1237 | + if ($context['icons'][$i]['selected']) { |
|
| 1238 | + $context['icon_url'] = $context['icons'][$i]['url']; |
|
| 1239 | + } |
|
| 1186 | 1240 | } |
| 1187 | 1241 | if (empty($context['icon_url'])) |
| 1188 | 1242 | { |
@@ -1196,8 +1250,9 @@ discard block |
||
| 1196 | 1250 | )); |
| 1197 | 1251 | } |
| 1198 | 1252 | |
| 1199 | - if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) |
|
| 1200 | - getTopic(); |
|
| 1253 | + if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) { |
|
| 1254 | + getTopic(); |
|
| 1255 | + } |
|
| 1201 | 1256 | |
| 1202 | 1257 | // If the user can post attachments prepare the warning labels. |
| 1203 | 1258 | if ($context['can_post_attachment']) |
@@ -1208,12 +1263,13 @@ discard block |
||
| 1208 | 1263 | $context['attachment_restrictions'] = array(); |
| 1209 | 1264 | $context['allowed_extensions'] = strtr(strtolower($modSettings['attachmentExtensions']), array(',' => ', ')); |
| 1210 | 1265 | $attachmentRestrictionTypes = array('attachmentNumPerPostLimit', 'attachmentPostLimit', 'attachmentSizeLimit'); |
| 1211 | - foreach ($attachmentRestrictionTypes as $type) |
|
| 1212 | - if (!empty($modSettings[$type])) |
|
| 1266 | + foreach ($attachmentRestrictionTypes as $type) { |
|
| 1267 | + if (!empty($modSettings[$type])) |
|
| 1213 | 1268 | { |
| 1214 | 1269 | // Show the max number of attachments if not 0. |
| 1215 | 1270 | if ($type == 'attachmentNumPerPostLimit') |
| 1216 | 1271 | $context['attachment_restrictions'][] = sprintf($txt['attach_remaining'], $modSettings['attachmentNumPerPostLimit'] - $context['attachments']['quantity']); |
| 1272 | + } |
|
| 1217 | 1273 | } |
| 1218 | 1274 | } |
| 1219 | 1275 | |
@@ -1247,8 +1303,8 @@ discard block |
||
| 1247 | 1303 | |
| 1248 | 1304 | if (!empty($context['current_attachments'])) |
| 1249 | 1305 | { |
| 1250 | - foreach ($context['current_attachments'] as $key => $mock) |
|
| 1251 | - addInlineJavaScript(' |
|
| 1306 | + foreach ($context['current_attachments'] as $key => $mock) { |
|
| 1307 | + addInlineJavaScript(' |
|
| 1252 | 1308 | current_attachments.push({ |
| 1253 | 1309 | name: '. JavaScriptEscape($mock['name']) . ', |
| 1254 | 1310 | size: '. $mock['size'] . ', |
@@ -1257,6 +1313,7 @@ discard block |
||
| 1257 | 1313 | type: '. JavaScriptEscape(!empty($mock['mime_type']) ? $mock['mime_type'] : '') . ', |
| 1258 | 1314 | thumbID: '. (!empty($mock['thumb']) ? $mock['thumb'] : 0) . ' |
| 1259 | 1315 | });', true); |
| 1316 | + } |
|
| 1260 | 1317 | } |
| 1261 | 1318 | |
| 1262 | 1319 | // File Upload. |
@@ -1301,8 +1358,9 @@ discard block |
||
| 1301 | 1358 | var current_board = '. (empty($context['current_board']) ? 'null' : $context['current_board']) . ';', false); |
| 1302 | 1359 | |
| 1303 | 1360 | // Finally, load the template. |
| 1304 | - if (!isset($_REQUEST['xml'])) |
|
| 1305 | - loadTemplate('Post'); |
|
| 1361 | + if (!isset($_REQUEST['xml'])) { |
|
| 1362 | + loadTemplate('Post'); |
|
| 1363 | + } |
|
| 1306 | 1364 | |
| 1307 | 1365 | call_integration_hook('integrate_post_end'); |
| 1308 | 1366 | } |
@@ -1323,13 +1381,14 @@ discard block |
||
| 1323 | 1381 | // Sneaking off, are we? |
| 1324 | 1382 | if (empty($_POST) && empty($topic)) |
| 1325 | 1383 | { |
| 1326 | - if (empty($_SERVER['CONTENT_LENGTH'])) |
|
| 1327 | - redirectexit('action=post;board=' . $board . '.0'); |
|
| 1328 | - else |
|
| 1329 | - fatal_lang_error('post_upload_error', false); |
|
| 1384 | + if (empty($_SERVER['CONTENT_LENGTH'])) { |
|
| 1385 | + redirectexit('action=post;board=' . $board . '.0'); |
|
| 1386 | + } else { |
|
| 1387 | + fatal_lang_error('post_upload_error', false); |
|
| 1388 | + } |
|
| 1389 | + } elseif (empty($_POST) && !empty($topic)) { |
|
| 1390 | + redirectexit('action=post;topic=' . $topic . '.0'); |
|
| 1330 | 1391 | } |
| 1331 | - elseif (empty($_POST) && !empty($topic)) |
|
| 1332 | - redirectexit('action=post;topic=' . $topic . '.0'); |
|
| 1333 | 1392 | |
| 1334 | 1393 | // No need! |
| 1335 | 1394 | $context['robot_no_index'] = true; |
@@ -1341,8 +1400,9 @@ discard block |
||
| 1341 | 1400 | $post_errors = array(); |
| 1342 | 1401 | |
| 1343 | 1402 | // If the session has timed out, let the user re-submit their form. |
| 1344 | - if (checkSession('post', '', false) != '') |
|
| 1345 | - $post_errors[] = 'session_timeout'; |
|
| 1403 | + if (checkSession('post', '', false) != '') { |
|
| 1404 | + $post_errors[] = 'session_timeout'; |
|
| 1405 | + } |
|
| 1346 | 1406 | |
| 1347 | 1407 | // Wrong verification code? |
| 1348 | 1408 | 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))) |
@@ -1352,33 +1412,38 @@ discard block |
||
| 1352 | 1412 | 'id' => 'post', |
| 1353 | 1413 | ); |
| 1354 | 1414 | $context['require_verification'] = create_control_verification($verificationOptions, true); |
| 1355 | - if (is_array($context['require_verification'])) |
|
| 1356 | - $post_errors = array_merge($post_errors, $context['require_verification']); |
|
| 1415 | + if (is_array($context['require_verification'])) { |
|
| 1416 | + $post_errors = array_merge($post_errors, $context['require_verification']); |
|
| 1417 | + } |
|
| 1357 | 1418 | } |
| 1358 | 1419 | |
| 1359 | 1420 | require_once($sourcedir . '/Subs-Post.php'); |
| 1360 | 1421 | loadLanguage('Post'); |
| 1361 | 1422 | |
| 1362 | 1423 | // Drafts enabled and needed? |
| 1363 | - if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) |
|
| 1364 | - require_once($sourcedir . '/Drafts.php'); |
|
| 1424 | + if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) { |
|
| 1425 | + require_once($sourcedir . '/Drafts.php'); |
|
| 1426 | + } |
|
| 1365 | 1427 | |
| 1366 | 1428 | // First check to see if they are trying to delete any current attachments. |
| 1367 | 1429 | if (isset($_POST['attach_del'])) |
| 1368 | 1430 | { |
| 1369 | 1431 | $keep_temp = array(); |
| 1370 | 1432 | $keep_ids = array(); |
| 1371 | - foreach ($_POST['attach_del'] as $dummy) |
|
| 1372 | - if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false) |
|
| 1433 | + foreach ($_POST['attach_del'] as $dummy) { |
|
| 1434 | + if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false) |
|
| 1373 | 1435 | $keep_temp[] = $dummy; |
| 1374 | - else |
|
| 1375 | - $keep_ids[] = (int) $dummy; |
|
| 1436 | + } |
|
| 1437 | + else { |
|
| 1438 | + $keep_ids[] = (int) $dummy; |
|
| 1439 | + } |
|
| 1376 | 1440 | |
| 1377 | - if (isset($_SESSION['temp_attachments'])) |
|
| 1378 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
| 1441 | + if (isset($_SESSION['temp_attachments'])) { |
|
| 1442 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
| 1379 | 1443 | { |
| 1380 | 1444 | 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) |
| 1381 | 1445 | continue; |
| 1446 | + } |
|
| 1382 | 1447 | |
| 1383 | 1448 | unset($_SESSION['temp_attachments'][$attachID]); |
| 1384 | 1449 | unlink($attachment['tmp_name']); |
@@ -1420,24 +1485,28 @@ discard block |
||
| 1420 | 1485 | $smcFunc['db_free_result']($request); |
| 1421 | 1486 | |
| 1422 | 1487 | // Though the topic should be there, it might have vanished. |
| 1423 | - if (!is_array($topic_info)) |
|
| 1424 | - fatal_lang_error('topic_doesnt_exist', 404); |
|
| 1488 | + if (!is_array($topic_info)) { |
|
| 1489 | + fatal_lang_error('topic_doesnt_exist', 404); |
|
| 1490 | + } |
|
| 1425 | 1491 | |
| 1426 | 1492 | // Did this topic suddenly move? Just checking... |
| 1427 | - if ($topic_info['id_board'] != $board) |
|
| 1428 | - fatal_lang_error('not_a_topic'); |
|
| 1493 | + if ($topic_info['id_board'] != $board) { |
|
| 1494 | + fatal_lang_error('not_a_topic'); |
|
| 1495 | + } |
|
| 1429 | 1496 | } |
| 1430 | 1497 | |
| 1431 | 1498 | // Replying to a topic? |
| 1432 | 1499 | if (!empty($topic) && !isset($_REQUEST['msg'])) |
| 1433 | 1500 | { |
| 1434 | 1501 | // Don't allow a post if it's locked. |
| 1435 | - if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) |
|
| 1436 | - fatal_lang_error('topic_locked', false); |
|
| 1502 | + if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) { |
|
| 1503 | + fatal_lang_error('topic_locked', false); |
|
| 1504 | + } |
|
| 1437 | 1505 | |
| 1438 | 1506 | // Sorry, multiple polls aren't allowed... yet. You should stop giving me ideas :P. |
| 1439 | - if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) |
|
| 1440 | - unset($_REQUEST['poll']); |
|
| 1507 | + if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) { |
|
| 1508 | + unset($_REQUEST['poll']); |
|
| 1509 | + } |
|
| 1441 | 1510 | |
| 1442 | 1511 | // Do the permissions and approval stuff... |
| 1443 | 1512 | $becomesApproved = true; |
@@ -1453,44 +1522,43 @@ discard block |
||
| 1453 | 1522 | |
| 1454 | 1523 | // Set a nice session var... |
| 1455 | 1524 | $_SESSION['becomesUnapproved'] = true; |
| 1456 | - } |
|
| 1457 | - |
|
| 1458 | - elseif ($topic_info['id_member_started'] != $user_info['id']) |
|
| 1525 | + } elseif ($topic_info['id_member_started'] != $user_info['id']) |
|
| 1459 | 1526 | { |
| 1460 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
|
| 1461 | - $becomesApproved = false; |
|
| 1462 | - |
|
| 1463 | - else |
|
| 1464 | - isAllowedTo('post_reply_any'); |
|
| 1465 | - } |
|
| 1466 | - elseif (!allowedTo('post_reply_any')) |
|
| 1527 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) { |
|
| 1528 | + $becomesApproved = false; |
|
| 1529 | + } else { |
|
| 1530 | + isAllowedTo('post_reply_any'); |
|
| 1531 | + } |
|
| 1532 | + } elseif (!allowedTo('post_reply_any')) |
|
| 1467 | 1533 | { |
| 1468 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) |
|
| 1469 | - $becomesApproved = false; |
|
| 1470 | - |
|
| 1471 | - else |
|
| 1472 | - isAllowedTo('post_reply_own'); |
|
| 1534 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) { |
|
| 1535 | + $becomesApproved = false; |
|
| 1536 | + } else { |
|
| 1537 | + isAllowedTo('post_reply_own'); |
|
| 1538 | + } |
|
| 1473 | 1539 | } |
| 1474 | 1540 | |
| 1475 | 1541 | if (isset($_POST['lock'])) |
| 1476 | 1542 | { |
| 1477 | 1543 | // Nothing is changed to the lock. |
| 1478 | - if ((empty($topic_info['locked']) && empty($_POST['lock'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) |
|
| 1479 | - unset($_POST['lock']); |
|
| 1544 | + if ((empty($topic_info['locked']) && empty($_POST['lock'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) { |
|
| 1545 | + unset($_POST['lock']); |
|
| 1546 | + } |
|
| 1480 | 1547 | |
| 1481 | 1548 | // You're have no permission to lock this topic. |
| 1482 | - elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) |
|
| 1483 | - unset($_POST['lock']); |
|
| 1549 | + elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) { |
|
| 1550 | + unset($_POST['lock']); |
|
| 1551 | + } |
|
| 1484 | 1552 | |
| 1485 | 1553 | // You are allowed to (un)lock your own topic only. |
| 1486 | 1554 | elseif (!allowedTo('lock_any')) |
| 1487 | 1555 | { |
| 1488 | 1556 | // You cannot override a moderator lock. |
| 1489 | - if ($topic_info['locked'] == 1) |
|
| 1490 | - unset($_POST['lock']); |
|
| 1491 | - |
|
| 1492 | - else |
|
| 1493 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 1557 | + if ($topic_info['locked'] == 1) { |
|
| 1558 | + unset($_POST['lock']); |
|
| 1559 | + } else { |
|
| 1560 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 1561 | + } |
|
| 1494 | 1562 | } |
| 1495 | 1563 | // Hail mighty moderator, (un)lock this topic immediately. |
| 1496 | 1564 | else |
@@ -1498,19 +1566,21 @@ discard block |
||
| 1498 | 1566 | $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
| 1499 | 1567 | |
| 1500 | 1568 | // Did someone (un)lock this while you were posting? |
| 1501 | - if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) |
|
| 1502 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
| 1569 | + if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) { |
|
| 1570 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
| 1571 | + } |
|
| 1503 | 1572 | } |
| 1504 | 1573 | } |
| 1505 | 1574 | |
| 1506 | 1575 | // So you wanna (un)sticky this...let's see. |
| 1507 | - if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) |
|
| 1508 | - unset($_POST['sticky']); |
|
| 1509 | - elseif (isset($_POST['sticky'])) |
|
| 1576 | + if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) { |
|
| 1577 | + unset($_POST['sticky']); |
|
| 1578 | + } elseif (isset($_POST['sticky'])) |
|
| 1510 | 1579 | { |
| 1511 | 1580 | // Did someone (un)sticky this while you were posting? |
| 1512 | - if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) |
|
| 1513 | - $post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky'; |
|
| 1581 | + if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) { |
|
| 1582 | + $post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky'; |
|
| 1583 | + } |
|
| 1514 | 1584 | } |
| 1515 | 1585 | |
| 1516 | 1586 | // If drafts are enabled, then pass this off |
@@ -1537,26 +1607,31 @@ discard block |
||
| 1537 | 1607 | |
| 1538 | 1608 | // Do like, the permissions, for safety and stuff... |
| 1539 | 1609 | $becomesApproved = true; |
| 1540 | - if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) |
|
| 1541 | - $becomesApproved = false; |
|
| 1542 | - else |
|
| 1543 | - isAllowedTo('post_new'); |
|
| 1610 | + if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) { |
|
| 1611 | + $becomesApproved = false; |
|
| 1612 | + } else { |
|
| 1613 | + isAllowedTo('post_new'); |
|
| 1614 | + } |
|
| 1544 | 1615 | |
| 1545 | 1616 | if (isset($_POST['lock'])) |
| 1546 | 1617 | { |
| 1547 | 1618 | // New topics are by default not locked. |
| 1548 | - if (empty($_POST['lock'])) |
|
| 1549 | - unset($_POST['lock']); |
|
| 1619 | + if (empty($_POST['lock'])) { |
|
| 1620 | + unset($_POST['lock']); |
|
| 1621 | + } |
|
| 1550 | 1622 | // Besides, you need permission. |
| 1551 | - elseif (!allowedTo(array('lock_any', 'lock_own'))) |
|
| 1552 | - unset($_POST['lock']); |
|
| 1623 | + elseif (!allowedTo(array('lock_any', 'lock_own'))) { |
|
| 1624 | + unset($_POST['lock']); |
|
| 1625 | + } |
|
| 1553 | 1626 | // A moderator-lock (1) can override a user-lock (2). |
| 1554 | - else |
|
| 1555 | - $_POST['lock'] = allowedTo('lock_any') ? 1 : 2; |
|
| 1627 | + else { |
|
| 1628 | + $_POST['lock'] = allowedTo('lock_any') ? 1 : 2; |
|
| 1629 | + } |
|
| 1556 | 1630 | } |
| 1557 | 1631 | |
| 1558 | - if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) |
|
| 1559 | - unset($_POST['sticky']); |
|
| 1632 | + if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) { |
|
| 1633 | + unset($_POST['sticky']); |
|
| 1634 | + } |
|
| 1560 | 1635 | |
| 1561 | 1636 | // Saving your new topic as a draft first? |
| 1562 | 1637 | if (!empty($modSettings['drafts_post_enabled']) && isset($_POST['save_draft'])) |
@@ -1581,31 +1656,37 @@ discard block |
||
| 1581 | 1656 | 'id_msg' => $_REQUEST['msg'], |
| 1582 | 1657 | ) |
| 1583 | 1658 | ); |
| 1584 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1585 | - fatal_lang_error('cant_find_messages', false); |
|
| 1659 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1660 | + fatal_lang_error('cant_find_messages', false); |
|
| 1661 | + } |
|
| 1586 | 1662 | $row = $smcFunc['db_fetch_assoc']($request); |
| 1587 | 1663 | $smcFunc['db_free_result']($request); |
| 1588 | 1664 | |
| 1589 | - if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) |
|
| 1590 | - fatal_lang_error('topic_locked', false); |
|
| 1665 | + if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) { |
|
| 1666 | + fatal_lang_error('topic_locked', false); |
|
| 1667 | + } |
|
| 1591 | 1668 | |
| 1592 | 1669 | if (isset($_POST['lock'])) |
| 1593 | 1670 | { |
| 1594 | 1671 | // Nothing changes to the lock status. |
| 1595 | - if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) |
|
| 1596 | - unset($_POST['lock']); |
|
| 1672 | + if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) { |
|
| 1673 | + unset($_POST['lock']); |
|
| 1674 | + } |
|
| 1597 | 1675 | // You're simply not allowed to (un)lock this. |
| 1598 | - elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) |
|
| 1599 | - unset($_POST['lock']); |
|
| 1676 | + elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) { |
|
| 1677 | + unset($_POST['lock']); |
|
| 1678 | + } |
|
| 1600 | 1679 | // You're only allowed to lock your own topics. |
| 1601 | 1680 | elseif (!allowedTo('lock_any')) |
| 1602 | 1681 | { |
| 1603 | 1682 | // You're not allowed to break a moderator's lock. |
| 1604 | - if ($topic_info['locked'] == 1) |
|
| 1605 | - unset($_POST['lock']); |
|
| 1683 | + if ($topic_info['locked'] == 1) { |
|
| 1684 | + unset($_POST['lock']); |
|
| 1685 | + } |
|
| 1606 | 1686 | // Lock it with a soft lock or unlock it. |
| 1607 | - else |
|
| 1608 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 1687 | + else { |
|
| 1688 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 1689 | + } |
|
| 1609 | 1690 | } |
| 1610 | 1691 | // You must be the moderator. |
| 1611 | 1692 | else |
@@ -1613,44 +1694,46 @@ discard block |
||
| 1613 | 1694 | $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
| 1614 | 1695 | |
| 1615 | 1696 | // Did someone (un)lock this while you were posting? |
| 1616 | - if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) |
|
| 1617 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
| 1697 | + if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) { |
|
| 1698 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
| 1699 | + } |
|
| 1618 | 1700 | } |
| 1619 | 1701 | } |
| 1620 | 1702 | |
| 1621 | 1703 | // Change the sticky status of this topic? |
| 1622 | - if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) |
|
| 1623 | - unset($_POST['sticky']); |
|
| 1624 | - elseif (isset($_POST['sticky'])) |
|
| 1704 | + if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) { |
|
| 1705 | + unset($_POST['sticky']); |
|
| 1706 | + } elseif (isset($_POST['sticky'])) |
|
| 1625 | 1707 | { |
| 1626 | 1708 | // Did someone (un)sticky this while you were posting? |
| 1627 | - if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) |
|
| 1628 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied'; |
|
| 1709 | + if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) { |
|
| 1710 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied'; |
|
| 1711 | + } |
|
| 1629 | 1712 | } |
| 1630 | 1713 | |
| 1631 | 1714 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
| 1632 | 1715 | { |
| 1633 | - if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
| 1634 | - fatal_lang_error('modify_post_time_passed', false); |
|
| 1635 | - elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
|
| 1636 | - isAllowedTo('modify_replies'); |
|
| 1637 | - else |
|
| 1638 | - isAllowedTo('modify_own'); |
|
| 1639 | - } |
|
| 1640 | - elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 1716 | + if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
| 1717 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 1718 | + } elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
| 1719 | + isAllowedTo('modify_replies'); |
|
| 1720 | + } else { |
|
| 1721 | + isAllowedTo('modify_own'); |
|
| 1722 | + } |
|
| 1723 | + } elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 1641 | 1724 | { |
| 1642 | 1725 | isAllowedTo('modify_replies'); |
| 1643 | 1726 | |
| 1644 | 1727 | // If you're modifying a reply, I say it better be logged... |
| 1645 | 1728 | $moderationAction = true; |
| 1646 | - } |
|
| 1647 | - else |
|
| 1729 | + } else |
|
| 1648 | 1730 | { |
| 1649 | 1731 | isAllowedTo('modify_any'); |
| 1650 | 1732 | |
| 1651 | 1733 | // Log it, assuming you're not modifying your own post. |
| 1652 | - if ($row['id_member'] != $user_info['id']) |
|
| 1653 | - $moderationAction = true; |
|
| 1734 | + if ($row['id_member'] != $user_info['id']) { |
|
| 1735 | + $moderationAction = true; |
|
| 1736 | + } |
|
| 1654 | 1737 | } |
| 1655 | 1738 | |
| 1656 | 1739 | // If drafts are enabled, then lets send this off to save |
@@ -1687,20 +1770,24 @@ discard block |
||
| 1687 | 1770 | $_POST['guestname'] = !isset($_POST['guestname']) ? '' : trim($_POST['guestname']); |
| 1688 | 1771 | $_POST['email'] = !isset($_POST['email']) ? '' : trim($_POST['email']); |
| 1689 | 1772 | |
| 1690 | - if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') |
|
| 1691 | - $post_errors[] = 'no_name'; |
|
| 1692 | - if ($smcFunc['strlen']($_POST['guestname']) > 25) |
|
| 1693 | - $post_errors[] = 'long_name'; |
|
| 1773 | + if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') { |
|
| 1774 | + $post_errors[] = 'no_name'; |
|
| 1775 | + } |
|
| 1776 | + if ($smcFunc['strlen']($_POST['guestname']) > 25) { |
|
| 1777 | + $post_errors[] = 'long_name'; |
|
| 1778 | + } |
|
| 1694 | 1779 | |
| 1695 | 1780 | if (empty($modSettings['guest_post_no_email'])) |
| 1696 | 1781 | { |
| 1697 | 1782 | // Only check if they changed it! |
| 1698 | 1783 | if (!isset($row) || $row['poster_email'] != $_POST['email']) |
| 1699 | 1784 | { |
| 1700 | - if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) |
|
| 1701 | - $post_errors[] = 'no_email'; |
|
| 1702 | - if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) |
|
| 1703 | - $post_errors[] = 'bad_email'; |
|
| 1785 | + if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) { |
|
| 1786 | + $post_errors[] = 'no_email'; |
|
| 1787 | + } |
|
| 1788 | + if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { |
|
| 1789 | + $post_errors[] = 'bad_email'; |
|
| 1790 | + } |
|
| 1704 | 1791 | } |
| 1705 | 1792 | |
| 1706 | 1793 | // Now make sure this email address is not banned from posting. |
@@ -1716,75 +1803,89 @@ discard block |
||
| 1716 | 1803 | } |
| 1717 | 1804 | |
| 1718 | 1805 | // Coming from the quickReply? |
| 1719 | - if (isset($_POST['quickReply'])) |
|
| 1720 | - $_POST['message'] = $_POST['quickReply']; |
|
| 1806 | + if (isset($_POST['quickReply'])) { |
|
| 1807 | + $_POST['message'] = $_POST['quickReply']; |
|
| 1808 | + } |
|
| 1721 | 1809 | |
| 1722 | 1810 | // Check the subject and message. |
| 1723 | - if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') |
|
| 1724 | - $post_errors[] = 'no_subject'; |
|
| 1725 | - if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') |
|
| 1726 | - $post_errors[] = 'no_message'; |
|
| 1727 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
| 1728 | - $post_errors[] = array('long_message', array($modSettings['max_messageLength'])); |
|
| 1729 | - else |
|
| 1811 | + if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') { |
|
| 1812 | + $post_errors[] = 'no_subject'; |
|
| 1813 | + } |
|
| 1814 | + if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') { |
|
| 1815 | + $post_errors[] = 'no_message'; |
|
| 1816 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) { |
|
| 1817 | + $post_errors[] = array('long_message', array($modSettings['max_messageLength'])); |
|
| 1818 | + } else |
|
| 1730 | 1819 | { |
| 1731 | 1820 | // Prepare the message a bit for some additional testing. |
| 1732 | 1821 | $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES); |
| 1733 | 1822 | |
| 1734 | 1823 | // Preparse code. (Zef) |
| 1735 | - if ($user_info['is_guest']) |
|
| 1736 | - $user_info['name'] = $_POST['guestname']; |
|
| 1824 | + if ($user_info['is_guest']) { |
|
| 1825 | + $user_info['name'] = $_POST['guestname']; |
|
| 1826 | + } |
|
| 1737 | 1827 | preparsecode($_POST['message']); |
| 1738 | 1828 | |
| 1739 | 1829 | // Let's see if there's still some content left without the tags. |
| 1740 | - if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) |
|
| 1741 | - $post_errors[] = 'no_message'; |
|
| 1830 | + if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) { |
|
| 1831 | + $post_errors[] = 'no_message'; |
|
| 1832 | + } |
|
| 1833 | + } |
|
| 1834 | + if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') { |
|
| 1835 | + $post_errors[] = 'no_event'; |
|
| 1742 | 1836 | } |
| 1743 | - if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') |
|
| 1744 | - $post_errors[] = 'no_event'; |
|
| 1745 | 1837 | // You are not! |
| 1746 | - if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) |
|
| 1747 | - fatal_error('Knave! Masquerader! Charlatan!', false); |
|
| 1838 | + if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) { |
|
| 1839 | + fatal_error('Knave! Masquerader! Charlatan!', false); |
|
| 1840 | + } |
|
| 1748 | 1841 | |
| 1749 | 1842 | // Validate the poll... |
| 1750 | 1843 | if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1') |
| 1751 | 1844 | { |
| 1752 | - if (!empty($topic) && !isset($_REQUEST['msg'])) |
|
| 1753 | - fatal_lang_error('no_access', false); |
|
| 1845 | + if (!empty($topic) && !isset($_REQUEST['msg'])) { |
|
| 1846 | + fatal_lang_error('no_access', false); |
|
| 1847 | + } |
|
| 1754 | 1848 | |
| 1755 | 1849 | // This is a new topic... so it's a new poll. |
| 1756 | - if (empty($topic)) |
|
| 1757 | - isAllowedTo('poll_post'); |
|
| 1850 | + if (empty($topic)) { |
|
| 1851 | + isAllowedTo('poll_post'); |
|
| 1852 | + } |
|
| 1758 | 1853 | // Can you add to your own topics? |
| 1759 | - elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) |
|
| 1760 | - isAllowedTo('poll_add_own'); |
|
| 1854 | + elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) { |
|
| 1855 | + isAllowedTo('poll_add_own'); |
|
| 1856 | + } |
|
| 1761 | 1857 | // Can you add polls to any topic, then? |
| 1762 | - else |
|
| 1763 | - isAllowedTo('poll_add_any'); |
|
| 1858 | + else { |
|
| 1859 | + isAllowedTo('poll_add_any'); |
|
| 1860 | + } |
|
| 1764 | 1861 | |
| 1765 | - if (!isset($_POST['question']) || trim($_POST['question']) == '') |
|
| 1766 | - $post_errors[] = 'no_question'; |
|
| 1862 | + if (!isset($_POST['question']) || trim($_POST['question']) == '') { |
|
| 1863 | + $post_errors[] = 'no_question'; |
|
| 1864 | + } |
|
| 1767 | 1865 | |
| 1768 | 1866 | $_POST['options'] = empty($_POST['options']) ? array() : htmltrim__recursive($_POST['options']); |
| 1769 | 1867 | |
| 1770 | 1868 | // Get rid of empty ones. |
| 1771 | - foreach ($_POST['options'] as $k => $option) |
|
| 1772 | - if ($option == '') |
|
| 1869 | + foreach ($_POST['options'] as $k => $option) { |
|
| 1870 | + if ($option == '') |
|
| 1773 | 1871 | unset($_POST['options'][$k], $_POST['options'][$k]); |
| 1872 | + } |
|
| 1774 | 1873 | |
| 1775 | 1874 | // What are you going to vote between with one choice?!? |
| 1776 | - if (count($_POST['options']) < 2) |
|
| 1777 | - $post_errors[] = 'poll_few'; |
|
| 1778 | - elseif (count($_POST['options']) > 256) |
|
| 1779 | - $post_errors[] = 'poll_many'; |
|
| 1875 | + if (count($_POST['options']) < 2) { |
|
| 1876 | + $post_errors[] = 'poll_few'; |
|
| 1877 | + } elseif (count($_POST['options']) > 256) { |
|
| 1878 | + $post_errors[] = 'poll_many'; |
|
| 1879 | + } |
|
| 1780 | 1880 | } |
| 1781 | 1881 | |
| 1782 | 1882 | if ($posterIsGuest) |
| 1783 | 1883 | { |
| 1784 | 1884 | // If user is a guest, make sure the chosen name isn't taken. |
| 1785 | 1885 | require_once($sourcedir . '/Subs-Members.php'); |
| 1786 | - if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) |
|
| 1787 | - $post_errors[] = 'bad_name'; |
|
| 1886 | + if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) { |
|
| 1887 | + $post_errors[] = 'bad_name'; |
|
| 1888 | + } |
|
| 1788 | 1889 | } |
| 1789 | 1890 | // If the user isn't a guest, get his or her name and email. |
| 1790 | 1891 | elseif (!isset($_REQUEST['msg'])) |
@@ -1815,8 +1916,9 @@ discard block |
||
| 1815 | 1916 | } |
| 1816 | 1917 | |
| 1817 | 1918 | // Make sure the user isn't spamming the board. |
| 1818 | - if (!isset($_REQUEST['msg'])) |
|
| 1819 | - spamProtection('post'); |
|
| 1919 | + if (!isset($_REQUEST['msg'])) { |
|
| 1920 | + spamProtection('post'); |
|
| 1921 | + } |
|
| 1820 | 1922 | |
| 1821 | 1923 | // At about this point, we're posting and that's that. |
| 1822 | 1924 | ignore_user_abort(true); |
@@ -1829,32 +1931,36 @@ discard block |
||
| 1829 | 1931 | $_POST['modify_reason'] = empty($_POST['modify_reason']) ? '' : strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => '')); |
| 1830 | 1932 | |
| 1831 | 1933 | // At this point, we want to make sure the subject isn't too long. |
| 1832 | - if ($smcFunc['strlen']($_POST['subject']) > 100) |
|
| 1833 | - $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
| 1934 | + if ($smcFunc['strlen']($_POST['subject']) > 100) { |
|
| 1935 | + $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
| 1936 | + } |
|
| 1834 | 1937 | |
| 1835 | 1938 | // Same with the "why did you edit this" text. |
| 1836 | - if ($smcFunc['strlen']($_POST['modify_reason']) > 100) |
|
| 1837 | - $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
| 1939 | + if ($smcFunc['strlen']($_POST['modify_reason']) > 100) { |
|
| 1940 | + $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
| 1941 | + } |
|
| 1838 | 1942 | |
| 1839 | 1943 | // Make the poll... |
| 1840 | 1944 | if (isset($_REQUEST['poll'])) |
| 1841 | 1945 | { |
| 1842 | 1946 | // Make sure that the user has not entered a ridiculous number of options.. |
| 1843 | - if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) |
|
| 1844 | - $_POST['poll_max_votes'] = 1; |
|
| 1845 | - elseif ($_POST['poll_max_votes'] > count($_POST['options'])) |
|
| 1846 | - $_POST['poll_max_votes'] = count($_POST['options']); |
|
| 1847 | - else |
|
| 1848 | - $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
| 1947 | + if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) { |
|
| 1948 | + $_POST['poll_max_votes'] = 1; |
|
| 1949 | + } elseif ($_POST['poll_max_votes'] > count($_POST['options'])) { |
|
| 1950 | + $_POST['poll_max_votes'] = count($_POST['options']); |
|
| 1951 | + } else { |
|
| 1952 | + $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
| 1953 | + } |
|
| 1849 | 1954 | |
| 1850 | 1955 | $_POST['poll_expire'] = (int) $_POST['poll_expire']; |
| 1851 | 1956 | $_POST['poll_expire'] = $_POST['poll_expire'] > 9999 ? 9999 : ($_POST['poll_expire'] < 0 ? 0 : $_POST['poll_expire']); |
| 1852 | 1957 | |
| 1853 | 1958 | // Just set it to zero if it's not there.. |
| 1854 | - if (!isset($_POST['poll_hide'])) |
|
| 1855 | - $_POST['poll_hide'] = 0; |
|
| 1856 | - else |
|
| 1857 | - $_POST['poll_hide'] = (int) $_POST['poll_hide']; |
|
| 1959 | + if (!isset($_POST['poll_hide'])) { |
|
| 1960 | + $_POST['poll_hide'] = 0; |
|
| 1961 | + } else { |
|
| 1962 | + $_POST['poll_hide'] = (int) $_POST['poll_hide']; |
|
| 1963 | + } |
|
| 1858 | 1964 | $_POST['poll_change_vote'] = isset($_POST['poll_change_vote']) ? 1 : 0; |
| 1859 | 1965 | |
| 1860 | 1966 | $_POST['poll_guest_vote'] = isset($_POST['poll_guest_vote']) ? 1 : 0; |
@@ -1863,16 +1969,19 @@ discard block |
||
| 1863 | 1969 | { |
| 1864 | 1970 | require_once($sourcedir . '/Subs-Members.php'); |
| 1865 | 1971 | $allowedVoteGroups = groupsAllowedTo('poll_vote', $board); |
| 1866 | - if (!in_array(-1, $allowedVoteGroups['allowed'])) |
|
| 1867 | - $_POST['poll_guest_vote'] = 0; |
|
| 1972 | + if (!in_array(-1, $allowedVoteGroups['allowed'])) { |
|
| 1973 | + $_POST['poll_guest_vote'] = 0; |
|
| 1974 | + } |
|
| 1868 | 1975 | } |
| 1869 | 1976 | |
| 1870 | 1977 | // If the user tries to set the poll too far in advance, don't let them. |
| 1871 | - if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) |
|
| 1872 | - fatal_lang_error('poll_range_error', false); |
|
| 1978 | + if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) { |
|
| 1979 | + fatal_lang_error('poll_range_error', false); |
|
| 1980 | + } |
|
| 1873 | 1981 | // Don't allow them to select option 2 for hidden results if it's not time limited. |
| 1874 | - elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) |
|
| 1875 | - $_POST['poll_hide'] = 1; |
|
| 1982 | + elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) { |
|
| 1983 | + $_POST['poll_hide'] = 1; |
|
| 1984 | + } |
|
| 1876 | 1985 | |
| 1877 | 1986 | // Clean up the question and answers. |
| 1878 | 1987 | $_POST['question'] = $smcFunc['htmlspecialchars']($_POST['question']); |
@@ -1886,13 +1995,15 @@ discard block |
||
| 1886 | 1995 | { |
| 1887 | 1996 | $attachIDs = array(); |
| 1888 | 1997 | $attach_errors = array(); |
| 1889 | - if (!empty($context['we_are_history'])) |
|
| 1890 | - $attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>'; |
|
| 1998 | + if (!empty($context['we_are_history'])) { |
|
| 1999 | + $attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>'; |
|
| 2000 | + } |
|
| 1891 | 2001 | |
| 1892 | 2002 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 1893 | 2003 | { |
| 1894 | - if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
| 1895 | - continue; |
|
| 2004 | + if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
| 2005 | + continue; |
|
| 2006 | + } |
|
| 1896 | 2007 | |
| 1897 | 2008 | // If there was an initial error just show that message. |
| 1898 | 2009 | if ($attachID == 'initial_error') |
@@ -1921,12 +2032,13 @@ discard block |
||
| 1921 | 2032 | if (createAttachment($attachmentOptions)) |
| 1922 | 2033 | { |
| 1923 | 2034 | $attachIDs[] = $attachmentOptions['id']; |
| 1924 | - if (!empty($attachmentOptions['thumb'])) |
|
| 1925 | - $attachIDs[] = $attachmentOptions['thumb']; |
|
| 2035 | + if (!empty($attachmentOptions['thumb'])) { |
|
| 2036 | + $attachIDs[] = $attachmentOptions['thumb']; |
|
| 2037 | + } |
|
| 1926 | 2038 | } |
| 2039 | + } else { |
|
| 2040 | + $attach_errors[] = '<dt> </dt>'; |
|
| 1927 | 2041 | } |
| 1928 | - else |
|
| 1929 | - $attach_errors[] = '<dt> </dt>'; |
|
| 1930 | 2042 | |
| 1931 | 2043 | if (!empty($attachmentOptions['errors'])) |
| 1932 | 2044 | { |
@@ -1938,14 +2050,16 @@ discard block |
||
| 1938 | 2050 | if (!is_array($error)) |
| 1939 | 2051 | { |
| 1940 | 2052 | $attach_errors[] = '<dd>' . $txt[$error] . '</dd>'; |
| 1941 | - if (in_array($error, $log_these)) |
|
| 1942 | - log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
| 2053 | + if (in_array($error, $log_these)) { |
|
| 2054 | + log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
| 2055 | + } |
|
| 2056 | + } else { |
|
| 2057 | + $attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>'; |
|
| 1943 | 2058 | } |
| 1944 | - else |
|
| 1945 | - $attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>'; |
|
| 1946 | 2059 | } |
| 1947 | - if (file_exists($attachment['tmp_name'])) |
|
| 1948 | - unlink($attachment['tmp_name']); |
|
| 2060 | + if (file_exists($attachment['tmp_name'])) { |
|
| 2061 | + unlink($attachment['tmp_name']); |
|
| 2062 | + } |
|
| 1949 | 2063 | } |
| 1950 | 2064 | } |
| 1951 | 2065 | unset($_SESSION['temp_attachments']); |
@@ -1986,24 +2100,24 @@ discard block |
||
| 1986 | 2100 | ); |
| 1987 | 2101 | |
| 1988 | 2102 | call_integration_hook('integrate_poll_add_edit', array($id_poll, false)); |
| 2103 | + } else { |
|
| 2104 | + $id_poll = 0; |
|
| 1989 | 2105 | } |
| 1990 | - else |
|
| 1991 | - $id_poll = 0; |
|
| 1992 | 2106 | |
| 1993 | 2107 | // Creating a new topic? |
| 1994 | 2108 | $newTopic = empty($_REQUEST['msg']) && empty($topic); |
| 1995 | 2109 | |
| 1996 | 2110 | // Check the icon. |
| 1997 | - if (!isset($_POST['icon'])) |
|
| 1998 | - $_POST['icon'] = 'xx'; |
|
| 1999 | - |
|
| 2000 | - else |
|
| 2111 | + if (!isset($_POST['icon'])) { |
|
| 2112 | + $_POST['icon'] = 'xx'; |
|
| 2113 | + } else |
|
| 2001 | 2114 | { |
| 2002 | 2115 | $_POST['icon'] = $smcFunc['htmlspecialchars']($_POST['icon']); |
| 2003 | 2116 | |
| 2004 | 2117 | // Need to figure it out if this is a valid icon name. |
| 2005 | - if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) |
|
| 2006 | - $_POST['icon'] = 'xx'; |
|
| 2118 | + if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) { |
|
| 2119 | + $_POST['icon'] = 'xx'; |
|
| 2120 | + } |
|
| 2007 | 2121 | } |
| 2008 | 2122 | |
| 2009 | 2123 | // Collect all parameters for the creation or modification of a post. |
@@ -2044,8 +2158,9 @@ discard block |
||
| 2044 | 2158 | } |
| 2045 | 2159 | |
| 2046 | 2160 | // This will save some time... |
| 2047 | - if (empty($approve_has_changed)) |
|
| 2048 | - unset($msgOptions['approved']); |
|
| 2161 | + if (empty($approve_has_changed)) { |
|
| 2162 | + unset($msgOptions['approved']); |
|
| 2163 | + } |
|
| 2049 | 2164 | |
| 2050 | 2165 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
| 2051 | 2166 | } |
@@ -2054,8 +2169,9 @@ discard block |
||
| 2054 | 2169 | { |
| 2055 | 2170 | createPost($msgOptions, $topicOptions, $posterOptions); |
| 2056 | 2171 | |
| 2057 | - if (isset($topicOptions['id'])) |
|
| 2058 | - $topic = $topicOptions['id']; |
|
| 2172 | + if (isset($topicOptions['id'])) { |
|
| 2173 | + $topic = $topicOptions['id']; |
|
| 2174 | + } |
|
| 2059 | 2175 | } |
| 2060 | 2176 | |
| 2061 | 2177 | // Assign the previously uploaded attachments to the brand new message. |
@@ -2067,8 +2183,9 @@ discard block |
||
| 2067 | 2183 | } |
| 2068 | 2184 | |
| 2069 | 2185 | // If we had a draft for this, its time to remove it since it was just posted |
| 2070 | - if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) |
|
| 2071 | - DeleteDraft($_POST['id_draft']); |
|
| 2186 | + if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) { |
|
| 2187 | + DeleteDraft($_POST['id_draft']); |
|
| 2188 | + } |
|
| 2072 | 2189 | |
| 2073 | 2190 | // Editing or posting an event? |
| 2074 | 2191 | if (isset($_POST['calendar']) && (!isset($_REQUEST['eventid']) || $_REQUEST['eventid'] == -1)) |
@@ -2087,8 +2204,7 @@ discard block |
||
| 2087 | 2204 | 'member' => $user_info['id'], |
| 2088 | 2205 | ); |
| 2089 | 2206 | insertEvent($eventOptions); |
| 2090 | - } |
|
| 2091 | - elseif (isset($_POST['calendar'])) |
|
| 2207 | + } elseif (isset($_POST['calendar'])) |
|
| 2092 | 2208 | { |
| 2093 | 2209 | $_REQUEST['eventid'] = (int) $_REQUEST['eventid']; |
| 2094 | 2210 | |
@@ -2116,14 +2232,15 @@ discard block |
||
| 2116 | 2232 | } |
| 2117 | 2233 | |
| 2118 | 2234 | // Delete it? |
| 2119 | - if (isset($_REQUEST['deleteevent'])) |
|
| 2120 | - $smcFunc['db_query']('', ' |
|
| 2235 | + if (isset($_REQUEST['deleteevent'])) { |
|
| 2236 | + $smcFunc['db_query']('', ' |
|
| 2121 | 2237 | DELETE FROM {db_prefix}calendar |
| 2122 | 2238 | WHERE id_event = {int:id_event}', |
| 2123 | 2239 | array( |
| 2124 | 2240 | 'id_event' => $_REQUEST['eventid'], |
| 2125 | 2241 | ) |
| 2126 | 2242 | ); |
| 2243 | + } |
|
| 2127 | 2244 | // ... or just update it? |
| 2128 | 2245 | else |
| 2129 | 2246 | { |
@@ -2165,9 +2282,8 @@ discard block |
||
| 2165 | 2282 | array($user_info['id'], $topic, 0), |
| 2166 | 2283 | array('id_member', 'id_topic', 'id_board') |
| 2167 | 2284 | ); |
| 2168 | - } |
|
| 2169 | - elseif (!$newTopic) |
|
| 2170 | - $smcFunc['db_query']('', ' |
|
| 2285 | + } elseif (!$newTopic) { |
|
| 2286 | + $smcFunc['db_query']('', ' |
|
| 2171 | 2287 | DELETE FROM {db_prefix}log_notify |
| 2172 | 2288 | WHERE id_member = {int:current_member} |
| 2173 | 2289 | AND id_topic = {int:current_topic}', |
@@ -2176,16 +2292,20 @@ discard block |
||
| 2176 | 2292 | 'current_topic' => $topic, |
| 2177 | 2293 | ) |
| 2178 | 2294 | ); |
| 2295 | + } |
|
| 2179 | 2296 | |
| 2180 | 2297 | // Log an act of moderation - modifying. |
| 2181 | - if (!empty($moderationAction)) |
|
| 2182 | - logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
| 2298 | + if (!empty($moderationAction)) { |
|
| 2299 | + logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
| 2300 | + } |
|
| 2183 | 2301 | |
| 2184 | - if (isset($_POST['lock']) && $_POST['lock'] != 2) |
|
| 2185 | - logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 2302 | + if (isset($_POST['lock']) && $_POST['lock'] != 2) { |
|
| 2303 | + logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 2304 | + } |
|
| 2186 | 2305 | |
| 2187 | - if (isset($_POST['sticky'])) |
|
| 2188 | - logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 2306 | + if (isset($_POST['sticky'])) { |
|
| 2307 | + logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 2308 | + } |
|
| 2189 | 2309 | |
| 2190 | 2310 | // Returning to the topic? |
| 2191 | 2311 | if (!empty($_REQUEST['goback'])) |
@@ -2204,26 +2324,31 @@ discard block |
||
| 2204 | 2324 | ); |
| 2205 | 2325 | } |
| 2206 | 2326 | |
| 2207 | - if ($board_info['num_topics'] == 0) |
|
| 2208 | - cache_put_data('board-' . $board, null, 120); |
|
| 2327 | + if ($board_info['num_topics'] == 0) { |
|
| 2328 | + cache_put_data('board-' . $board, null, 120); |
|
| 2329 | + } |
|
| 2209 | 2330 | |
| 2210 | 2331 | call_integration_hook('integrate_post2_end'); |
| 2211 | 2332 | |
| 2212 | - if (!empty($_POST['announce_topic'])) |
|
| 2213 | - redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2333 | + if (!empty($_POST['announce_topic'])) { |
|
| 2334 | + redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2335 | + } |
|
| 2214 | 2336 | |
| 2215 | - if (!empty($_POST['move']) && allowedTo('move_any')) |
|
| 2216 | - redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2337 | + if (!empty($_POST['move']) && allowedTo('move_any')) { |
|
| 2338 | + redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2339 | + } |
|
| 2217 | 2340 | |
| 2218 | 2341 | // Return to post if the mod is on. |
| 2219 | - if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) |
|
| 2220 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
| 2221 | - elseif (!empty($_REQUEST['goback'])) |
|
| 2222 | - redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
| 2342 | + if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) { |
|
| 2343 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
| 2344 | + } elseif (!empty($_REQUEST['goback'])) { |
|
| 2345 | + redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
| 2346 | + } |
|
| 2223 | 2347 | // Dut-dut-duh-duh-DUH-duh-dut-duh-duh! *dances to the Final Fantasy Fanfare...* |
| 2224 | - else |
|
| 2225 | - redirectexit('board=' . $board . '.0'); |
|
| 2226 | -} |
|
| 2348 | + else { |
|
| 2349 | + redirectexit('board=' . $board . '.0'); |
|
| 2350 | + } |
|
| 2351 | + } |
|
| 2227 | 2352 | |
| 2228 | 2353 | /** |
| 2229 | 2354 | * Handle the announce topic function (action=announce). |
@@ -2241,8 +2366,9 @@ discard block |
||
| 2241 | 2366 | |
| 2242 | 2367 | validateSession(); |
| 2243 | 2368 | |
| 2244 | - if (empty($topic)) |
|
| 2245 | - fatal_lang_error('topic_gone', false); |
|
| 2369 | + if (empty($topic)) { |
|
| 2370 | + fatal_lang_error('topic_gone', false); |
|
| 2371 | + } |
|
| 2246 | 2372 | |
| 2247 | 2373 | loadLanguage('Post'); |
| 2248 | 2374 | loadTemplate('Post'); |
@@ -2269,8 +2395,9 @@ discard block |
||
| 2269 | 2395 | global $txt, $context, $topic, $board, $board_info, $smcFunc; |
| 2270 | 2396 | |
| 2271 | 2397 | $groups = array_merge($board_info['groups'], array(1)); |
| 2272 | - foreach ($groups as $id => $group) |
|
| 2273 | - $groups[$id] = (int) $group; |
|
| 2398 | + foreach ($groups as $id => $group) { |
|
| 2399 | + $groups[$id] = (int) $group; |
|
| 2400 | + } |
|
| 2274 | 2401 | |
| 2275 | 2402 | $context['groups'] = array(); |
| 2276 | 2403 | if (in_array(0, $groups)) |
@@ -2313,8 +2440,9 @@ discard block |
||
| 2313 | 2440 | 'group_list' => $groups, |
| 2314 | 2441 | ) |
| 2315 | 2442 | ); |
| 2316 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2317 | - $context['groups'][$row['id_group']]['name'] = $row['group_name']; |
|
| 2443 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2444 | + $context['groups'][$row['id_group']]['name'] = $row['group_name']; |
|
| 2445 | + } |
|
| 2318 | 2446 | $smcFunc['db_free_result']($request); |
| 2319 | 2447 | |
| 2320 | 2448 | // Get the subject of the topic we're about to announce. |
@@ -2356,16 +2484,19 @@ discard block |
||
| 2356 | 2484 | $context['start'] = empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start']; |
| 2357 | 2485 | $groups = array_merge($board_info['groups'], array(1)); |
| 2358 | 2486 | |
| 2359 | - if (isset($_POST['membergroups'])) |
|
| 2360 | - $_POST['who'] = explode(',', $_POST['membergroups']); |
|
| 2487 | + if (isset($_POST['membergroups'])) { |
|
| 2488 | + $_POST['who'] = explode(',', $_POST['membergroups']); |
|
| 2489 | + } |
|
| 2361 | 2490 | |
| 2362 | 2491 | // Check whether at least one membergroup was selected. |
| 2363 | - if (empty($_POST['who'])) |
|
| 2364 | - fatal_lang_error('no_membergroup_selected'); |
|
| 2492 | + if (empty($_POST['who'])) { |
|
| 2493 | + fatal_lang_error('no_membergroup_selected'); |
|
| 2494 | + } |
|
| 2365 | 2495 | |
| 2366 | 2496 | // Make sure all membergroups are integers and can access the board of the announcement. |
| 2367 | - foreach ($_POST['who'] as $id => $mg) |
|
| 2368 | - $_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0; |
|
| 2497 | + foreach ($_POST['who'] as $id => $mg) { |
|
| 2498 | + $_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0; |
|
| 2499 | + } |
|
| 2369 | 2500 | |
| 2370 | 2501 | // Get the topic subject and censor it. |
| 2371 | 2502 | $request = $smcFunc['db_query']('', ' |
@@ -2411,12 +2542,13 @@ discard block |
||
| 2411 | 2542 | if ($smcFunc['db_num_rows']($request) == 0) |
| 2412 | 2543 | { |
| 2413 | 2544 | logAction('announce_topic', array('topic' => $topic), 'user'); |
| 2414 | - if (!empty($_REQUEST['move']) && allowedTo('move_any')) |
|
| 2415 | - redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2416 | - elseif (!empty($_REQUEST['goback'])) |
|
| 2417 | - redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie')); |
|
| 2418 | - else |
|
| 2419 | - redirectexit('board=' . $board . '.0'); |
|
| 2545 | + if (!empty($_REQUEST['move']) && allowedTo('move_any')) { |
|
| 2546 | + redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2547 | + } elseif (!empty($_REQUEST['goback'])) { |
|
| 2548 | + redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie')); |
|
| 2549 | + } else { |
|
| 2550 | + redirectexit('board=' . $board . '.0'); |
|
| 2551 | + } |
|
| 2420 | 2552 | } |
| 2421 | 2553 | |
| 2422 | 2554 | $announcements = array(); |
@@ -2435,8 +2567,9 @@ discard block |
||
| 2435 | 2567 | foreach ($rows as $row) |
| 2436 | 2568 | { |
| 2437 | 2569 | // Force them to have it? |
| 2438 | - if (empty($prefs[$row['id_member']]['announcements'])) |
|
| 2439 | - continue; |
|
| 2570 | + if (empty($prefs[$row['id_member']]['announcements'])) { |
|
| 2571 | + continue; |
|
| 2572 | + } |
|
| 2440 | 2573 | |
| 2441 | 2574 | $cur_language = empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']; |
| 2442 | 2575 | |
@@ -2464,8 +2597,9 @@ discard block |
||
| 2464 | 2597 | } |
| 2465 | 2598 | |
| 2466 | 2599 | // For each language send a different mail - low priority... |
| 2467 | - foreach ($announcements as $lang => $mail) |
|
| 2468 | - sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5); |
|
| 2600 | + foreach ($announcements as $lang => $mail) { |
|
| 2601 | + sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5); |
|
| 2602 | + } |
|
| 2469 | 2603 | |
| 2470 | 2604 | $context['percentage_done'] = round(100 * $context['start'] / $modSettings['latestMember'], 1); |
| 2471 | 2605 | |
@@ -2475,9 +2609,10 @@ discard block |
||
| 2475 | 2609 | $context['sub_template'] = 'announcement_send'; |
| 2476 | 2610 | |
| 2477 | 2611 | // Go back to the correct language for the user ;). |
| 2478 | - if (!empty($modSettings['userLanguage'])) |
|
| 2479 | - loadLanguage('Post'); |
|
| 2480 | -} |
|
| 2612 | + if (!empty($modSettings['userLanguage'])) { |
|
| 2613 | + loadLanguage('Post'); |
|
| 2614 | + } |
|
| 2615 | + } |
|
| 2481 | 2616 | |
| 2482 | 2617 | /** |
| 2483 | 2618 | * Get the topic for display purposes. |
@@ -2490,12 +2625,13 @@ discard block |
||
| 2490 | 2625 | { |
| 2491 | 2626 | global $topic, $modSettings, $context, $smcFunc, $counter, $options; |
| 2492 | 2627 | |
| 2493 | - if (isset($_REQUEST['xml'])) |
|
| 2494 | - $limit = ' |
|
| 2628 | + if (isset($_REQUEST['xml'])) { |
|
| 2629 | + $limit = ' |
|
| 2495 | 2630 | LIMIT ' . (empty($context['new_replies']) ? '0' : $context['new_replies']); |
| 2496 | - else |
|
| 2497 | - $limit = empty($modSettings['topicSummaryPosts']) ? '' : ' |
|
| 2631 | + } else { |
|
| 2632 | + $limit = empty($modSettings['topicSummaryPosts']) ? '' : ' |
|
| 2498 | 2633 | LIMIT ' . (int) $modSettings['topicSummaryPosts']; |
| 2634 | + } |
|
| 2499 | 2635 | |
| 2500 | 2636 | // If you're modifying, get only those posts before the current one. (otherwise get all.) |
| 2501 | 2637 | $request = $smcFunc['db_query']('', ' |
@@ -2533,8 +2669,9 @@ discard block |
||
| 2533 | 2669 | 'is_ignored' => !empty($modSettings['enable_buddylist']) && !empty($options['posts_apply_ignore_list']) && in_array($row['id_member'], $context['user']['ignoreusers']), |
| 2534 | 2670 | ); |
| 2535 | 2671 | |
| 2536 | - if (!empty($context['new_replies'])) |
|
| 2537 | - $context['new_replies']--; |
|
| 2672 | + if (!empty($context['new_replies'])) { |
|
| 2673 | + $context['new_replies']--; |
|
| 2674 | + } |
|
| 2538 | 2675 | } |
| 2539 | 2676 | $smcFunc['db_free_result']($request); |
| 2540 | 2677 | } |
@@ -2551,8 +2688,9 @@ discard block |
||
| 2551 | 2688 | global $sourcedir, $smcFunc; |
| 2552 | 2689 | |
| 2553 | 2690 | loadLanguage('Post'); |
| 2554 | - if (!isset($_REQUEST['xml'])) |
|
| 2555 | - loadTemplate('Post'); |
|
| 2691 | + if (!isset($_REQUEST['xml'])) { |
|
| 2692 | + loadTemplate('Post'); |
|
| 2693 | + } |
|
| 2556 | 2694 | |
| 2557 | 2695 | include_once($sourcedir . '/Subs-Post.php'); |
| 2558 | 2696 | |
@@ -2583,8 +2721,9 @@ discard block |
||
| 2583 | 2721 | $smcFunc['db_free_result']($request); |
| 2584 | 2722 | |
| 2585 | 2723 | $context['sub_template'] = 'quotefast'; |
| 2586 | - if (!empty($row)) |
|
| 2587 | - $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
| 2724 | + if (!empty($row)) { |
|
| 2725 | + $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
| 2726 | + } |
|
| 2588 | 2727 | |
| 2589 | 2728 | if (!empty($can_view_post)) |
| 2590 | 2729 | { |
@@ -2617,8 +2756,9 @@ discard block |
||
| 2617 | 2756 | } |
| 2618 | 2757 | |
| 2619 | 2758 | // Remove any nested quotes. |
| 2620 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
| 2621 | - $row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']); |
|
| 2759 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
| 2760 | + $row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']); |
|
| 2761 | + } |
|
| 2622 | 2762 | |
| 2623 | 2763 | $lb = "\n"; |
| 2624 | 2764 | |
@@ -2644,14 +2784,14 @@ discard block |
||
| 2644 | 2784 | 'time' => '', |
| 2645 | 2785 | ), |
| 2646 | 2786 | ); |
| 2647 | - } |
|
| 2648 | - else |
|
| 2649 | - $context['quote'] = array( |
|
| 2787 | + } else { |
|
| 2788 | + $context['quote'] = array( |
|
| 2650 | 2789 | 'xml' => '', |
| 2651 | 2790 | 'mozilla' => '', |
| 2652 | 2791 | 'text' => '', |
| 2653 | 2792 | ); |
| 2654 | -} |
|
| 2793 | + } |
|
| 2794 | + } |
|
| 2655 | 2795 | |
| 2656 | 2796 | /** |
| 2657 | 2797 | * Used to edit the body or subject of a message inline |
@@ -2663,8 +2803,9 @@ discard block |
||
| 2663 | 2803 | global $user_info, $context, $smcFunc, $language, $board_info; |
| 2664 | 2804 | |
| 2665 | 2805 | // We have to have a topic! |
| 2666 | - if (empty($topic)) |
|
| 2667 | - obExit(false); |
|
| 2806 | + if (empty($topic)) { |
|
| 2807 | + obExit(false); |
|
| 2808 | + } |
|
| 2668 | 2809 | |
| 2669 | 2810 | checkSession('get'); |
| 2670 | 2811 | require_once($sourcedir . '/Subs-Post.php'); |
@@ -2690,31 +2831,35 @@ discard block |
||
| 2690 | 2831 | 'guest_id' => 0, |
| 2691 | 2832 | ) |
| 2692 | 2833 | ); |
| 2693 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 2694 | - fatal_lang_error('no_board', false); |
|
| 2834 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 2835 | + fatal_lang_error('no_board', false); |
|
| 2836 | + } |
|
| 2695 | 2837 | $row = $smcFunc['db_fetch_assoc']($request); |
| 2696 | 2838 | $smcFunc['db_free_result']($request); |
| 2697 | 2839 | |
| 2698 | 2840 | // Change either body or subject requires permissions to modify messages. |
| 2699 | 2841 | if (isset($_POST['message']) || isset($_POST['subject']) || isset($_REQUEST['icon'])) |
| 2700 | 2842 | { |
| 2701 | - if (!empty($row['locked'])) |
|
| 2702 | - isAllowedTo('moderate_board'); |
|
| 2843 | + if (!empty($row['locked'])) { |
|
| 2844 | + isAllowedTo('moderate_board'); |
|
| 2845 | + } |
|
| 2703 | 2846 | |
| 2704 | 2847 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
| 2705 | 2848 | { |
| 2706 | - if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
| 2707 | - fatal_lang_error('modify_post_time_passed', false); |
|
| 2708 | - elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
|
| 2709 | - isAllowedTo('modify_replies'); |
|
| 2710 | - else |
|
| 2711 | - isAllowedTo('modify_own'); |
|
| 2849 | + if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
| 2850 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 2851 | + } elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
| 2852 | + isAllowedTo('modify_replies'); |
|
| 2853 | + } else { |
|
| 2854 | + isAllowedTo('modify_own'); |
|
| 2855 | + } |
|
| 2712 | 2856 | } |
| 2713 | 2857 | // Otherwise, they're locked out; someone who can modify the replies is needed. |
| 2714 | - elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 2715 | - isAllowedTo('modify_replies'); |
|
| 2716 | - else |
|
| 2717 | - isAllowedTo('modify_any'); |
|
| 2858 | + elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
| 2859 | + isAllowedTo('modify_replies'); |
|
| 2860 | + } else { |
|
| 2861 | + isAllowedTo('modify_any'); |
|
| 2862 | + } |
|
| 2718 | 2863 | |
| 2719 | 2864 | // Only log this action if it wasn't your message. |
| 2720 | 2865 | $moderationAction = $row['id_member'] != $user_info['id']; |
@@ -2726,10 +2871,10 @@ discard block |
||
| 2726 | 2871 | $_POST['subject'] = strtr($smcFunc['htmlspecialchars']($_POST['subject']), array("\r" => '', "\n" => '', "\t" => '')); |
| 2727 | 2872 | |
| 2728 | 2873 | // Maximum number of characters. |
| 2729 | - if ($smcFunc['strlen']($_POST['subject']) > 100) |
|
| 2730 | - $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
| 2731 | - } |
|
| 2732 | - elseif (isset($_POST['subject'])) |
|
| 2874 | + if ($smcFunc['strlen']($_POST['subject']) > 100) { |
|
| 2875 | + $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
| 2876 | + } |
|
| 2877 | + } elseif (isset($_POST['subject'])) |
|
| 2733 | 2878 | { |
| 2734 | 2879 | $post_errors[] = 'no_subject'; |
| 2735 | 2880 | unset($_POST['subject']); |
@@ -2741,13 +2886,11 @@ discard block |
||
| 2741 | 2886 | { |
| 2742 | 2887 | $post_errors[] = 'no_message'; |
| 2743 | 2888 | unset($_POST['message']); |
| 2744 | - } |
|
| 2745 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
| 2889 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
| 2746 | 2890 | { |
| 2747 | 2891 | $post_errors[] = 'long_message'; |
| 2748 | 2892 | unset($_POST['message']); |
| 2749 | - } |
|
| 2750 | - else |
|
| 2893 | + } else |
|
| 2751 | 2894 | { |
| 2752 | 2895 | $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES); |
| 2753 | 2896 | |
@@ -2763,31 +2906,34 @@ discard block |
||
| 2763 | 2906 | |
| 2764 | 2907 | if (isset($_POST['lock'])) |
| 2765 | 2908 | { |
| 2766 | - if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) |
|
| 2767 | - unset($_POST['lock']); |
|
| 2768 | - elseif (!allowedTo('lock_any')) |
|
| 2909 | + if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) { |
|
| 2910 | + unset($_POST['lock']); |
|
| 2911 | + } elseif (!allowedTo('lock_any')) |
|
| 2769 | 2912 | { |
| 2770 | - if ($row['locked'] == 1) |
|
| 2771 | - unset($_POST['lock']); |
|
| 2772 | - else |
|
| 2773 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 2913 | + if ($row['locked'] == 1) { |
|
| 2914 | + unset($_POST['lock']); |
|
| 2915 | + } else { |
|
| 2916 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 2917 | + } |
|
| 2918 | + } elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) { |
|
| 2919 | + unset($_POST['lock']); |
|
| 2920 | + } else { |
|
| 2921 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
|
| 2774 | 2922 | } |
| 2775 | - elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) |
|
| 2776 | - unset($_POST['lock']); |
|
| 2777 | - else |
|
| 2778 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
|
| 2779 | 2923 | } |
| 2780 | 2924 | |
| 2781 | - if (isset($_POST['sticky']) && !allowedTo('make_sticky')) |
|
| 2782 | - unset($_POST['sticky']); |
|
| 2925 | + if (isset($_POST['sticky']) && !allowedTo('make_sticky')) { |
|
| 2926 | + unset($_POST['sticky']); |
|
| 2927 | + } |
|
| 2783 | 2928 | |
| 2784 | 2929 | if (isset($_POST['modify_reason'])) |
| 2785 | 2930 | { |
| 2786 | 2931 | $_POST['modify_reason'] = strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => '')); |
| 2787 | 2932 | |
| 2788 | 2933 | // Maximum number of characters. |
| 2789 | - if ($smcFunc['strlen']($_POST['modify_reason']) > 100) |
|
| 2790 | - $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
| 2934 | + if ($smcFunc['strlen']($_POST['modify_reason']) > 100) { |
|
| 2935 | + $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
| 2936 | + } |
|
| 2791 | 2937 | } |
| 2792 | 2938 | |
| 2793 | 2939 | if (empty($post_errors)) |
@@ -2824,8 +2970,9 @@ discard block |
||
| 2824 | 2970 | } |
| 2825 | 2971 | } |
| 2826 | 2972 | // If nothing was changed there's no need to add an entry to the moderation log. |
| 2827 | - else |
|
| 2828 | - $moderationAction = false; |
|
| 2973 | + else { |
|
| 2974 | + $moderationAction = false; |
|
| 2975 | + } |
|
| 2829 | 2976 | |
| 2830 | 2977 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
| 2831 | 2978 | |
@@ -2843,9 +2990,9 @@ discard block |
||
| 2843 | 2990 | // Get the proper (default language) response prefix first. |
| 2844 | 2991 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
| 2845 | 2992 | { |
| 2846 | - if ($language === $user_info['language']) |
|
| 2847 | - $context['response_prefix'] = $txt['response_prefix']; |
|
| 2848 | - else |
|
| 2993 | + if ($language === $user_info['language']) { |
|
| 2994 | + $context['response_prefix'] = $txt['response_prefix']; |
|
| 2995 | + } else |
|
| 2849 | 2996 | { |
| 2850 | 2997 | loadLanguage('index', $language, false); |
| 2851 | 2998 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -2867,8 +3014,9 @@ discard block |
||
| 2867 | 3014 | ); |
| 2868 | 3015 | } |
| 2869 | 3016 | |
| 2870 | - if (!empty($moderationAction)) |
|
| 2871 | - logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
| 3017 | + if (!empty($moderationAction)) { |
|
| 3018 | + logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
| 3019 | + } |
|
| 2872 | 3020 | } |
| 2873 | 3021 | |
| 2874 | 3022 | if (isset($_REQUEST['xml'])) |
@@ -2909,8 +3057,7 @@ discard block |
||
| 2909 | 3057 | ); |
| 2910 | 3058 | |
| 2911 | 3059 | censorText($context['message']['subject']); |
| 2912 | - } |
|
| 2913 | - else |
|
| 3060 | + } else |
|
| 2914 | 3061 | { |
| 2915 | 3062 | $context['message'] = array( |
| 2916 | 3063 | 'id' => $row['id_msg'], |
@@ -2922,15 +3069,16 @@ discard block |
||
| 2922 | 3069 | loadLanguage('Errors'); |
| 2923 | 3070 | foreach ($post_errors as $post_error) |
| 2924 | 3071 | { |
| 2925 | - if ($post_error == 'long_message') |
|
| 2926 | - $context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']); |
|
| 2927 | - else |
|
| 2928 | - $context['message']['errors'][] = $txt['error_' . $post_error]; |
|
| 3072 | + if ($post_error == 'long_message') { |
|
| 3073 | + $context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']); |
|
| 3074 | + } else { |
|
| 3075 | + $context['message']['errors'][] = $txt['error_' . $post_error]; |
|
| 3076 | + } |
|
| 2929 | 3077 | } |
| 2930 | 3078 | } |
| 3079 | + } else { |
|
| 3080 | + obExit(false); |
|
| 3081 | + } |
|
| 2931 | 3082 | } |
| 2932 | - else |
|
| 2933 | - obExit(false); |
|
| 2934 | -} |
|
| 2935 | 3083 | |
| 2936 | 3084 | ?> |
| 2937 | 3085 | \ No newline at end of file |