@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Handles showing the post screen, loading the post to be modified, and loading any post quoted. |
@@ -35,12 +36,14 @@ discard block |
||
| 35 | 36 | global $sourcedir, $smcFunc, $language; |
| 36 | 37 | |
| 37 | 38 | loadLanguage('Post'); |
| 38 | - if (!empty($modSettings['drafts_post_enabled'])) |
|
| 39 | - loadLanguage('Drafts'); |
|
| 39 | + if (!empty($modSettings['drafts_post_enabled'])) { |
|
| 40 | + loadLanguage('Drafts'); |
|
| 41 | + } |
|
| 40 | 42 | |
| 41 | 43 | // You can't reply with a poll... hacker. |
| 42 | - if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg'])) |
|
| 43 | - unset($_REQUEST['poll']); |
|
| 44 | + if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg'])) { |
|
| 45 | + unset($_REQUEST['poll']); |
|
| 46 | + } |
|
| 44 | 47 | |
| 45 | 48 | // Posting an event? |
| 46 | 49 | $context['make_event'] = isset($_REQUEST['calendar']); |
@@ -54,8 +57,9 @@ discard block |
||
| 54 | 57 | $context['auto_notify'] = !empty($context['notify_prefs']['msg_auto_notify']); |
| 55 | 58 | |
| 56 | 59 | // You must be posting to *some* board. |
| 57 | - if (empty($board) && !$context['make_event']) |
|
| 58 | - fatal_lang_error('no_board', false); |
|
| 60 | + if (empty($board) && !$context['make_event']) { |
|
| 61 | + fatal_lang_error('no_board', false); |
|
| 62 | + } |
|
| 59 | 63 | |
| 60 | 64 | require_once($sourcedir . '/Subs-Post.php'); |
| 61 | 65 | |
@@ -80,9 +84,9 @@ discard block |
||
| 80 | 84 | )); |
| 81 | 85 | if ($smcFunc['db_num_rows']($request) != 1) { |
| 82 | 86 | unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
| 87 | + } else { |
|
| 88 | + list ($topic) = $smcFunc['db_fetch_row']($request); |
|
| 83 | 89 | } |
| 84 | - else |
|
| 85 | - list ($topic) = $smcFunc['db_fetch_row']($request); |
|
| 86 | 90 | $smcFunc['db_free_result']($request); |
| 87 | 91 | } |
| 88 | 92 | |
@@ -109,33 +113,36 @@ discard block |
||
| 109 | 113 | $smcFunc['db_free_result']($request); |
| 110 | 114 | |
| 111 | 115 | // If this topic already has a poll, they sure can't add another. |
| 112 | - if (isset($_REQUEST['poll']) && $pollID > 0) |
|
| 113 | - unset($_REQUEST['poll']); |
|
| 116 | + if (isset($_REQUEST['poll']) && $pollID > 0) { |
|
| 117 | + unset($_REQUEST['poll']); |
|
| 118 | + } |
|
| 114 | 119 | |
| 115 | 120 | if (empty($_REQUEST['msg'])) |
| 116 | 121 | { |
| 117 | - if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) |
|
| 118 | - is_not_guest(); |
|
| 122 | + if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) { |
|
| 123 | + is_not_guest(); |
|
| 124 | + } |
|
| 119 | 125 | |
| 120 | 126 | // By default the reply will be approved... |
| 121 | 127 | $context['becomes_approved'] = true; |
| 122 | 128 | if ($id_member_poster != $user_info['id'] || $user_info['is_guest']) |
| 123 | 129 | { |
| 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')) |
|
| 130 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) { |
|
| 131 | + $context['becomes_approved'] = false; |
|
| 132 | + } else { |
|
| 133 | + isAllowedTo('post_reply_any'); |
|
| 134 | + } |
|
| 135 | + } elseif (!allowedTo('post_reply_any')) |
|
| 130 | 136 | { |
| 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'); |
|
| 137 | + if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) { |
|
| 138 | + $context['becomes_approved'] = false; |
|
| 139 | + } else { |
|
| 140 | + isAllowedTo('post_reply_own'); |
|
| 141 | + } |
|
| 135 | 142 | } |
| 143 | + } else { |
|
| 144 | + $context['becomes_approved'] = true; |
|
| 136 | 145 | } |
| 137 | - else |
|
| 138 | - $context['becomes_approved'] = true; |
|
| 139 | 146 | |
| 140 | 147 | $context['can_lock'] = allowedTo('lock_any') || ($user_info['id'] == $id_member_poster && allowedTo('lock_own')); |
| 141 | 148 | $context['can_sticky'] = allowedTo('make_sticky'); |
@@ -147,18 +154,19 @@ discard block |
||
| 147 | 154 | $context['sticky'] = isset($_REQUEST['sticky']) ? !empty($_REQUEST['sticky']) : $sticky; |
| 148 | 155 | |
| 149 | 156 | // 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 |
|
| 157 | + if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) { |
|
| 158 | + $post_errors[] = array('old_topic', array($modSettings['oldTopicDays'])); |
|
| 159 | + } |
|
| 160 | + } else |
|
| 154 | 161 | { |
| 155 | 162 | $context['becomes_approved'] = true; |
| 156 | 163 | if ((!$context['make_event'] || !empty($board))) |
| 157 | 164 | { |
| 158 | - if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) |
|
| 159 | - $context['becomes_approved'] = false; |
|
| 160 | - else |
|
| 161 | - isAllowedTo('post_new'); |
|
| 165 | + if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) { |
|
| 166 | + $context['becomes_approved'] = false; |
|
| 167 | + } else { |
|
| 168 | + isAllowedTo('post_new'); |
|
| 169 | + } |
|
| 162 | 170 | } |
| 163 | 171 | |
| 164 | 172 | $locked = 0; |
@@ -194,20 +202,24 @@ discard block |
||
| 194 | 202 | } |
| 195 | 203 | |
| 196 | 204 | // 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); |
|
| 205 | + if ($locked && !allowedTo('moderate_board')) { |
|
| 206 | + fatal_lang_error('topic_locked', false); |
|
| 207 | + } |
|
| 199 | 208 | // Check the users permissions - is the user allowed to add or post a poll? |
| 200 | 209 | if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1') |
| 201 | 210 | { |
| 202 | 211 | // New topic, new poll. |
| 203 | - if (empty($topic)) |
|
| 204 | - isAllowedTo('poll_post'); |
|
| 212 | + if (empty($topic)) { |
|
| 213 | + isAllowedTo('poll_post'); |
|
| 214 | + } |
|
| 205 | 215 | // 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'); |
|
| 216 | + elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) { |
|
| 217 | + isAllowedTo('poll_add_own'); |
|
| 218 | + } |
|
| 208 | 219 | // If you're not the owner, can you add to any poll? |
| 209 | - else |
|
| 210 | - isAllowedTo('poll_add_any'); |
|
| 220 | + else { |
|
| 221 | + isAllowedTo('poll_add_any'); |
|
| 222 | + } |
|
| 211 | 223 | |
| 212 | 224 | require_once($sourcedir . '/Subs-Members.php'); |
| 213 | 225 | $allowedVoteGroups = groupsAllowedTo('poll_vote', $board); |
@@ -236,8 +248,9 @@ discard block |
||
| 236 | 248 | if ($context['make_event']) |
| 237 | 249 | { |
| 238 | 250 | // They might want to pick a board. |
| 239 | - if (!isset($context['current_board'])) |
|
| 240 | - $context['current_board'] = 0; |
|
| 251 | + if (!isset($context['current_board'])) { |
|
| 252 | + $context['current_board'] = 0; |
|
| 253 | + } |
|
| 241 | 254 | |
| 242 | 255 | // Start loading up the event info. |
| 243 | 256 | $context['event'] = array(); |
@@ -251,10 +264,11 @@ discard block |
||
| 251 | 264 | isAllowedTo('calendar_post'); |
| 252 | 265 | |
| 253 | 266 | // 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]); |
|
| 267 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
| 268 | + $time_string = '%k:%M'; |
|
| 269 | + } else { |
|
| 270 | + $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 271 | + } |
|
| 258 | 272 | |
| 259 | 273 | $js_time_string = str_replace( |
| 260 | 274 | array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
@@ -276,8 +290,7 @@ discard block |
||
| 276 | 290 | require_once($sourcedir . '/Subs-Calendar.php'); |
| 277 | 291 | $eventProperties = getEventProperties($context['event']['id']); |
| 278 | 292 | $context['event'] = array_merge($context['event'], $eventProperties); |
| 279 | - } |
|
| 280 | - else |
|
| 293 | + } else |
|
| 281 | 294 | { |
| 282 | 295 | // Get the current event information. |
| 283 | 296 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -285,15 +298,18 @@ discard block |
||
| 285 | 298 | $context['event'] = array_merge($context['event'], $eventProperties); |
| 286 | 299 | |
| 287 | 300 | // 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); |
|
| 301 | + if ($context['event']['month'] < 1 || $context['event']['month'] > 12) { |
|
| 302 | + fatal_lang_error('invalid_month', false); |
|
| 303 | + } |
|
| 304 | + if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) { |
|
| 305 | + fatal_lang_error('invalid_year', false); |
|
| 306 | + } |
|
| 292 | 307 | |
| 293 | 308 | // Get a list of boards they can post in. |
| 294 | 309 | $boards = boardsAllowedTo('post_new'); |
| 295 | - if (empty($boards)) |
|
| 296 | - fatal_lang_error('cannot_post_new', 'user'); |
|
| 310 | + if (empty($boards)) { |
|
| 311 | + fatal_lang_error('cannot_post_new', 'user'); |
|
| 312 | + } |
|
| 297 | 313 | |
| 298 | 314 | // Load a list of boards for this event in the context. |
| 299 | 315 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
@@ -412,10 +428,11 @@ discard block |
||
| 412 | 428 | |
| 413 | 429 | if (!empty($context['new_replies'])) |
| 414 | 430 | { |
| 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']); |
|
| 431 | + if ($context['new_replies'] == 1) { |
|
| 432 | + $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
| 433 | + } else { |
|
| 434 | + $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
| 435 | + } |
|
| 419 | 436 | |
| 420 | 437 | $post_errors[] = 'new_replies'; |
| 421 | 438 | |
@@ -427,9 +444,9 @@ discard block |
||
| 427 | 444 | // Get a response prefix (like 'Re:') in the default forum language. |
| 428 | 445 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
| 429 | 446 | { |
| 430 | - if ($language === $user_info['language']) |
|
| 431 | - $context['response_prefix'] = $txt['response_prefix']; |
|
| 432 | - else |
|
| 447 | + if ($language === $user_info['language']) { |
|
| 448 | + $context['response_prefix'] = $txt['response_prefix']; |
|
| 449 | + } else |
|
| 433 | 450 | { |
| 434 | 451 | loadLanguage('index', $language, false); |
| 435 | 452 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -442,8 +459,9 @@ discard block |
||
| 442 | 459 | // Do we have a body, but an error happened. |
| 443 | 460 | if (isset($_REQUEST['message']) || isset($_REQUEST['quickReply']) || !empty($context['post_error'])) |
| 444 | 461 | { |
| 445 | - if (isset($_REQUEST['quickReply'])) |
|
| 446 | - $_REQUEST['message'] = $_REQUEST['quickReply']; |
|
| 462 | + if (isset($_REQUEST['quickReply'])) { |
|
| 463 | + $_REQUEST['message'] = $_REQUEST['quickReply']; |
|
| 464 | + } |
|
| 447 | 465 | |
| 448 | 466 | // Validate inputs. |
| 449 | 467 | if (empty($context['post_error'])) |
@@ -451,15 +469,17 @@ discard block |
||
| 451 | 469 | // This means they didn't click Post and get an error. |
| 452 | 470 | $really_previewing = true; |
| 453 | 471 | |
| 454 | - } |
|
| 455 | - else |
|
| 472 | + } else |
|
| 456 | 473 | { |
| 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'; |
|
| 474 | + if (!isset($_REQUEST['subject'])) { |
|
| 475 | + $_REQUEST['subject'] = ''; |
|
| 476 | + } |
|
| 477 | + if (!isset($_REQUEST['message'])) { |
|
| 478 | + $_REQUEST['message'] = ''; |
|
| 479 | + } |
|
| 480 | + if (!isset($_REQUEST['icon'])) { |
|
| 481 | + $_REQUEST['icon'] = 'xx'; |
|
| 482 | + } |
|
| 463 | 483 | |
| 464 | 484 | // They are previewing if they asked to preview (i.e. came from quick reply). |
| 465 | 485 | $really_previewing = !empty($_POST['preview']); |
@@ -475,8 +495,9 @@ discard block |
||
| 475 | 495 | $form_message = $smcFunc['htmlspecialchars']($_REQUEST['message'], ENT_QUOTES); |
| 476 | 496 | |
| 477 | 497 | // 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); |
|
| 498 | + if ($smcFunc['strlen']($form_subject) > 100) { |
|
| 499 | + $form_subject = $smcFunc['substr']($form_subject, 0, 100); |
|
| 500 | + } |
|
| 480 | 501 | |
| 481 | 502 | if (isset($_REQUEST['poll'])) |
| 482 | 503 | { |
@@ -488,8 +509,9 @@ discard block |
||
| 488 | 509 | $_POST['options'] = empty($_POST['options']) ? array() : htmlspecialchars__recursive($_POST['options']); |
| 489 | 510 | foreach ($_POST['options'] as $option) |
| 490 | 511 | { |
| 491 | - if (trim($option) == '') |
|
| 492 | - continue; |
|
| 512 | + if (trim($option) == '') { |
|
| 513 | + continue; |
|
| 514 | + } |
|
| 493 | 515 | |
| 494 | 516 | $context['choices'][] = array( |
| 495 | 517 | 'id' => $choice_id++, |
@@ -551,13 +573,14 @@ discard block |
||
| 551 | 573 | $context['preview_subject'] = $form_subject; |
| 552 | 574 | |
| 553 | 575 | censorText($context['preview_subject']); |
| 576 | + } else { |
|
| 577 | + $context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>'; |
|
| 554 | 578 | } |
| 555 | - else |
|
| 556 | - $context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>'; |
|
| 557 | 579 | |
| 558 | 580 | // Protect any CDATA blocks. |
| 559 | - if (isset($_REQUEST['xml'])) |
|
| 560 | - $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]><![CDATA[>')); |
|
| 581 | + if (isset($_REQUEST['xml'])) { |
|
| 582 | + $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]>< == 0) |
|
| 600 | - fatal_lang_error('no_board', false); |
|
| 622 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 623 | + fatal_lang_error('no_board', false); |
|
| 624 | + } |
|
| 601 | 625 | $row = $smcFunc['db_fetch_assoc']($request); |
| 602 | 626 | |
| 603 | 627 | $attachment_stuff = array($row); |
| 604 | - while ($row2 = $smcFunc['db_fetch_assoc']($request)) |
|
| 605 | - $attachment_stuff[] = $row2; |
|
| 628 | + while ($row2 = $smcFunc['db_fetch_assoc']($request)) { |
|
| 629 | + $attachment_stuff[] = $row2; |
|
| 630 | + } |
|
| 606 | 631 | $smcFunc['db_free_result']($request); |
| 607 | 632 | |
| 608 | 633 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
| 609 | 634 | { |
| 610 | 635 | // 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'); |
|
| 636 | + if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
| 637 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 638 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
| 639 | + isAllowedTo('modify_replies'); |
|
| 640 | + } else { |
|
| 641 | + isAllowedTo('modify_own'); |
|
| 642 | + } |
|
| 643 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
| 644 | + isAllowedTo('modify_replies'); |
|
| 645 | + } else { |
|
| 646 | + isAllowedTo('modify_any'); |
|
| 617 | 647 | } |
| 618 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 619 | - isAllowedTo('modify_replies'); |
|
| 620 | - else |
|
| 621 | - isAllowedTo('modify_any'); |
|
| 622 | 648 | |
| 623 | 649 | if ($context['can_announce'] && !empty($row['id_action'])) |
| 624 | 650 | { |
@@ -642,8 +668,9 @@ discard block |
||
| 642 | 668 | |
| 643 | 669 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 644 | 670 | { |
| 645 | - if ($row['filesize'] <= 0) |
|
| 646 | - continue; |
|
| 671 | + if ($row['filesize'] <= 0) { |
|
| 672 | + continue; |
|
| 673 | + } |
|
| 647 | 674 | $context['current_attachments'][$row['id_attach']] = array( |
| 648 | 675 | 'name' => $smcFunc['htmlspecialchars']($row['filename']), |
| 649 | 676 | 'size' => $row['filesize'], |
@@ -713,29 +740,32 @@ discard block |
||
| 713 | 740 | ) |
| 714 | 741 | ); |
| 715 | 742 | // 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); |
|
| 743 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 744 | + fatal_lang_error('no_message', false); |
|
| 745 | + } |
|
| 718 | 746 | $row = $smcFunc['db_fetch_assoc']($request); |
| 719 | 747 | |
| 720 | 748 | $attachment_stuff = array($row); |
| 721 | - while ($row2 = $smcFunc['db_fetch_assoc']($request)) |
|
| 722 | - $attachment_stuff[] = $row2; |
|
| 749 | + while ($row2 = $smcFunc['db_fetch_assoc']($request)) { |
|
| 750 | + $attachment_stuff[] = $row2; |
|
| 751 | + } |
|
| 723 | 752 | $smcFunc['db_free_result']($request); |
| 724 | 753 | |
| 725 | 754 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
| 726 | 755 | { |
| 727 | 756 | // 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'); |
|
| 757 | + if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
| 758 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 759 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
| 760 | + isAllowedTo('modify_replies'); |
|
| 761 | + } else { |
|
| 762 | + isAllowedTo('modify_own'); |
|
| 763 | + } |
|
| 764 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
| 765 | + isAllowedTo('modify_replies'); |
|
| 766 | + } else { |
|
| 767 | + isAllowedTo('modify_any'); |
|
| 734 | 768 | } |
| 735 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 736 | - isAllowedTo('modify_replies'); |
|
| 737 | - else |
|
| 738 | - isAllowedTo('modify_any'); |
|
| 739 | 769 | |
| 740 | 770 | if ($context['can_announce'] && !empty($row['id_action'])) |
| 741 | 771 | { |
@@ -762,15 +792,17 @@ discard block |
||
| 762 | 792 | $context['icon'] = $row['icon']; |
| 763 | 793 | |
| 764 | 794 | // 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'); |
|
| 795 | + if (!$row['approved'] && !$context['show_approval']) { |
|
| 796 | + $context['show_approval'] = allowedTo('approve_posts'); |
|
| 797 | + } |
|
| 767 | 798 | |
| 768 | 799 | // Sort the attachments so they are in the order saved |
| 769 | 800 | $temp = array(); |
| 770 | 801 | foreach ($attachment_stuff as $attachment) |
| 771 | 802 | { |
| 772 | - if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) |
|
| 773 | - $temp[$attachment['id_attach']] = $attachment; |
|
| 803 | + if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) { |
|
| 804 | + $temp[$attachment['id_attach']] = $attachment; |
|
| 805 | + } |
|
| 774 | 806 | |
| 775 | 807 | } |
| 776 | 808 | ksort($temp); |
@@ -832,14 +864,16 @@ discard block |
||
| 832 | 864 | 'is_approved' => 1, |
| 833 | 865 | ) |
| 834 | 866 | ); |
| 835 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 836 | - fatal_lang_error('quoted_post_deleted', false); |
|
| 867 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 868 | + fatal_lang_error('quoted_post_deleted', false); |
|
| 869 | + } |
|
| 837 | 870 | list ($form_subject, $mname, $mdate, $form_message) = $smcFunc['db_fetch_row']($request); |
| 838 | 871 | $smcFunc['db_free_result']($request); |
| 839 | 872 | |
| 840 | 873 | // 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; |
|
| 874 | + if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
| 875 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
| 876 | + } |
|
| 843 | 877 | |
| 844 | 878 | // Censor the message and subject. |
| 845 | 879 | censorText($form_message); |
@@ -852,10 +886,11 @@ discard block |
||
| 852 | 886 | for ($i = 0, $n = count($parts); $i < $n; $i++) |
| 853 | 887 | { |
| 854 | 888 | // 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) |
|
| 889 | + if ($i % 4 == 0) { |
|
| 890 | + $parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) |
|
| 857 | 891 | { |
| 858 | 892 | return '[html]' . preg_replace('~<br\s?/?' . '>~i', '<br /><br>', "$m[1]") . '[/html]'; |
| 893 | + } |
|
| 859 | 894 | }, $parts[$i]); |
| 860 | 895 | } |
| 861 | 896 | $form_message = implode('', $parts); |
@@ -864,8 +899,9 @@ discard block |
||
| 864 | 899 | $form_message = preg_replace('~<br ?/?' . '>~i', "\n", $form_message); |
| 865 | 900 | |
| 866 | 901 | // 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); |
|
| 902 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
| 903 | + $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
| 904 | + } |
|
| 869 | 905 | |
| 870 | 906 | // Add a quote string on the front and end. |
| 871 | 907 | $form_message = '[quote author=' . $mname . ' link=msg=' . (int) $_REQUEST['quote'] . ' date=' . $mdate . ']' . "\n" . rtrim($form_message) . "\n" . '[/quote]'; |
@@ -877,15 +913,15 @@ discard block |
||
| 877 | 913 | $form_subject = $first_subject; |
| 878 | 914 | |
| 879 | 915 | // 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; |
|
| 916 | + if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
| 917 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
| 918 | + } |
|
| 882 | 919 | |
| 883 | 920 | // Censor the subject. |
| 884 | 921 | censorText($form_subject); |
| 885 | 922 | |
| 886 | 923 | $form_message = ''; |
| 887 | - } |
|
| 888 | - else |
|
| 924 | + } else |
|
| 889 | 925 | { |
| 890 | 926 | $form_subject = isset($_GET['subject']) ? $_GET['subject'] : ''; |
| 891 | 927 | $form_message = ''; |
@@ -903,13 +939,15 @@ discard block |
||
| 903 | 939 | if (isset($_REQUEST['msg'])) |
| 904 | 940 | { |
| 905 | 941 | $context['attachments']['quantity'] = count($context['current_attachments']); |
| 906 | - foreach ($context['current_attachments'] as $attachment) |
|
| 907 | - $context['attachments']['total_size'] += $attachment['size']; |
|
| 942 | + foreach ($context['current_attachments'] as $attachment) { |
|
| 943 | + $context['attachments']['total_size'] += $attachment['size']; |
|
| 944 | + } |
|
| 908 | 945 | } |
| 909 | 946 | |
| 910 | 947 | // A bit of house keeping first. |
| 911 | - if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) |
|
| 912 | - unset($_SESSION['temp_attachments']); |
|
| 948 | + if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) { |
|
| 949 | + unset($_SESSION['temp_attachments']); |
|
| 950 | + } |
|
| 913 | 951 | |
| 914 | 952 | if (!empty($_SESSION['temp_attachments'])) |
| 915 | 953 | { |
@@ -918,9 +956,10 @@ discard block |
||
| 918 | 956 | { |
| 919 | 957 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 920 | 958 | { |
| 921 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
| 922 | - if (file_exists($attachment['tmp_name'])) |
|
| 959 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) { |
|
| 960 | + if (file_exists($attachment['tmp_name'])) |
|
| 923 | 961 | unlink($attachment['tmp_name']); |
| 962 | + } |
|
| 924 | 963 | } |
| 925 | 964 | $post_errors[] = 'temp_attachments_gone'; |
| 926 | 965 | $_SESSION['temp_attachments'] = array(); |
@@ -934,8 +973,9 @@ discard block |
||
| 934 | 973 | // See if any files still exist before showing the warning message and the files attached. |
| 935 | 974 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 936 | 975 | { |
| 937 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
| 938 | - continue; |
|
| 976 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
| 977 | + continue; |
|
| 978 | + } |
|
| 939 | 979 | |
| 940 | 980 | if (file_exists($attachment['tmp_name'])) |
| 941 | 981 | { |
@@ -945,20 +985,21 @@ discard block |
||
| 945 | 985 | break; |
| 946 | 986 | } |
| 947 | 987 | } |
| 948 | - } |
|
| 949 | - else |
|
| 988 | + } else |
|
| 950 | 989 | { |
| 951 | 990 | // 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'; |
|
| 991 | + if (!empty($topic)) { |
|
| 992 | + $delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp'; |
|
| 993 | + } else { |
|
| 994 | + $delete_url = $scripturl . '?action=post;board=' . $board . ';delete_temp'; |
|
| 995 | + } |
|
| 956 | 996 | |
| 957 | 997 | // Compile a list of the files to show the user. |
| 958 | 998 | $file_list = array(); |
| 959 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
| 960 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
| 999 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) { |
|
| 1000 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
| 961 | 1001 | $file_list[] = $attachment['name']; |
| 1002 | + } |
|
| 962 | 1003 | |
| 963 | 1004 | $_SESSION['temp_attachments']['post']['files'] = $file_list; |
| 964 | 1005 | $file_list = '<div class="attachments">' . implode('<br>', $file_list) . '</div>'; |
@@ -970,8 +1011,7 @@ discard block |
||
| 970 | 1011 | |
| 971 | 1012 | $post_errors[] = array('temp_attachments_found', array($delete_url, $goback_url, $file_list)); |
| 972 | 1013 | $context['ignore_temp_attachments'] = true; |
| 973 | - } |
|
| 974 | - else |
|
| 1014 | + } else |
|
| 975 | 1015 | { |
| 976 | 1016 | $post_errors[] = array('temp_attachments_lost', array($delete_url, $file_list)); |
| 977 | 1017 | $context['ignore_temp_attachments'] = true; |
@@ -979,16 +1019,19 @@ discard block |
||
| 979 | 1019 | } |
| 980 | 1020 | } |
| 981 | 1021 | |
| 982 | - if (!empty($context['we_are_history'])) |
|
| 983 | - $post_errors[] = $context['we_are_history']; |
|
| 1022 | + if (!empty($context['we_are_history'])) { |
|
| 1023 | + $post_errors[] = $context['we_are_history']; |
|
| 1024 | + } |
|
| 984 | 1025 | |
| 985 | 1026 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 986 | 1027 | { |
| 987 | - if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) |
|
| 988 | - break; |
|
| 1028 | + if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) { |
|
| 1029 | + break; |
|
| 1030 | + } |
|
| 989 | 1031 | |
| 990 | - if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
| 991 | - continue; |
|
| 1032 | + if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
| 1033 | + continue; |
|
| 1034 | + } |
|
| 992 | 1035 | |
| 993 | 1036 | if ($attachID == 'initial_error') |
| 994 | 1037 | { |
@@ -1003,15 +1046,17 @@ discard block |
||
| 1003 | 1046 | { |
| 1004 | 1047 | $txt['error_attach_errors'] = empty($txt['error_attach_errors']) ? '<br>' : ''; |
| 1005 | 1048 | $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 >'; |
|
| 1049 | + foreach ($attachment['errors'] as $error) { |
|
| 1050 | + $txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >'; |
|
| 1051 | + } |
|
| 1008 | 1052 | $txt['error_attach_errors'] .= '</div>'; |
| 1009 | 1053 | $post_errors[] = 'attach_errors'; |
| 1010 | 1054 | |
| 1011 | 1055 | // Take out the trash. |
| 1012 | 1056 | unset($_SESSION['temp_attachments'][$attachID]); |
| 1013 | - if (file_exists($attachment['tmp_name'])) |
|
| 1014 | - unlink($attachment['tmp_name']); |
|
| 1057 | + if (file_exists($attachment['tmp_name'])) { |
|
| 1058 | + unlink($attachment['tmp_name']); |
|
| 1059 | + } |
|
| 1015 | 1060 | continue; |
| 1016 | 1061 | } |
| 1017 | 1062 | |
@@ -1024,8 +1069,9 @@ discard block |
||
| 1024 | 1069 | |
| 1025 | 1070 | $context['attachments']['quantity']++; |
| 1026 | 1071 | $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']; |
|
| 1072 | + if (!isset($context['files_in_session_warning'])) { |
|
| 1073 | + $context['files_in_session_warning'] = $txt['attached_files_in_session']; |
|
| 1074 | + } |
|
| 1029 | 1075 | |
| 1030 | 1076 | $context['current_attachments'][$attachID] = array( |
| 1031 | 1077 | 'name' => '<u>' . $smcFunc['htmlspecialchars']($attachment['name']) . '</u>', |
@@ -1053,8 +1099,9 @@ discard block |
||
| 1053 | 1099 | } |
| 1054 | 1100 | |
| 1055 | 1101 | // 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'; |
|
| 1102 | + if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) { |
|
| 1103 | + $post_errors[] = 'need_qr_verification'; |
|
| 1104 | + } |
|
| 1058 | 1105 | |
| 1059 | 1106 | /* |
| 1060 | 1107 | * There are two error types: serious and minor. Serious errors |
@@ -1071,52 +1118,56 @@ discard block |
||
| 1071 | 1118 | { |
| 1072 | 1119 | loadLanguage('Errors'); |
| 1073 | 1120 | $context['error_type'] = 'minor'; |
| 1074 | - foreach ($post_errors as $post_error) |
|
| 1075 | - if (is_array($post_error)) |
|
| 1121 | + foreach ($post_errors as $post_error) { |
|
| 1122 | + if (is_array($post_error)) |
|
| 1076 | 1123 | { |
| 1077 | 1124 | $post_error_id = $post_error[0]; |
| 1125 | + } |
|
| 1078 | 1126 | $context['post_error'][$post_error_id] = vsprintf($txt['error_' . $post_error_id], $post_error[1]); |
| 1079 | 1127 | |
| 1080 | 1128 | // 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 |
|
| 1129 | + if (!in_array($post_error_id, $minor_errors)) { |
|
| 1130 | + $context['error_type'] = 'serious'; |
|
| 1131 | + } |
|
| 1132 | + } else |
|
| 1085 | 1133 | { |
| 1086 | 1134 | $context['post_error'][$post_error] = $txt['error_' . $post_error]; |
| 1087 | 1135 | |
| 1088 | 1136 | // If it's not a minor error flag it as such. |
| 1089 | - if (!in_array($post_error, $minor_errors)) |
|
| 1090 | - $context['error_type'] = 'serious'; |
|
| 1137 | + if (!in_array($post_error, $minor_errors)) { |
|
| 1138 | + $context['error_type'] = 'serious'; |
|
| 1139 | + } |
|
| 1091 | 1140 | } |
| 1092 | 1141 | } |
| 1093 | 1142 | |
| 1094 | 1143 | // 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']; |
|
| 1144 | + if (isset($_REQUEST['poll'])) { |
|
| 1145 | + $context['page_title'] = $txt['new_poll']; |
|
| 1146 | + } elseif ($context['make_event']) { |
|
| 1147 | + $context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit']; |
|
| 1148 | + } elseif (isset($_REQUEST['msg'])) { |
|
| 1149 | + $context['page_title'] = $txt['modify_msg']; |
|
| 1150 | + } elseif (isset($_REQUEST['subject'], $context['preview_subject'])) { |
|
| 1151 | + $context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']); |
|
| 1152 | + } elseif (empty($topic)) { |
|
| 1153 | + $context['page_title'] = $txt['start_new_topic']; |
|
| 1154 | + } else { |
|
| 1155 | + $context['page_title'] = $txt['post_reply']; |
|
| 1156 | + } |
|
| 1107 | 1157 | |
| 1108 | 1158 | // Build the link tree. |
| 1109 | - if (empty($topic)) |
|
| 1110 | - $context['linktree'][] = array( |
|
| 1159 | + if (empty($topic)) { |
|
| 1160 | + $context['linktree'][] = array( |
|
| 1111 | 1161 | 'name' => '<em>' . $txt['start_new_topic'] . '</em>' |
| 1112 | 1162 | ); |
| 1113 | - else |
|
| 1114 | - $context['linktree'][] = array( |
|
| 1163 | + } else { |
|
| 1164 | + $context['linktree'][] = array( |
|
| 1115 | 1165 | 'url' => $scripturl . '?topic=' . $topic . '.' . $_REQUEST['start'], |
| 1116 | 1166 | 'name' => $form_subject, |
| 1117 | 1167 | 'extra_before' => '<span><strong class="nav">' . $context['page_title'] . ' (</strong></span>', |
| 1118 | 1168 | 'extra_after' => '<span><strong class="nav">)</strong></span>' |
| 1119 | 1169 | ); |
| 1170 | + } |
|
| 1120 | 1171 | |
| 1121 | 1172 | $context['subject'] = addcslashes($form_subject, '"'); |
| 1122 | 1173 | $context['message'] = str_replace(array('"', '<', '>', ' '), array('"', '<', '>', ' '), $form_message); |
@@ -1160,8 +1211,9 @@ discard block |
||
| 1160 | 1211 | // Message icons - customized icons are off? |
| 1161 | 1212 | $context['icons'] = getMessageIcons($board); |
| 1162 | 1213 | |
| 1163 | - if (!empty($context['icons'])) |
|
| 1164 | - $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
| 1214 | + if (!empty($context['icons'])) { |
|
| 1215 | + $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
| 1216 | + } |
|
| 1165 | 1217 | |
| 1166 | 1218 | // Are we starting a poll? if set the poll icon as selected if its available |
| 1167 | 1219 | if (isset($_REQUEST['poll'])) |
@@ -1181,8 +1233,9 @@ discard block |
||
| 1181 | 1233 | for ($i = 0, $n = count($context['icons']); $i < $n; $i++) |
| 1182 | 1234 | { |
| 1183 | 1235 | $context['icons'][$i]['selected'] = $context['icon'] == $context['icons'][$i]['value']; |
| 1184 | - if ($context['icons'][$i]['selected']) |
|
| 1185 | - $context['icon_url'] = $context['icons'][$i]['url']; |
|
| 1236 | + if ($context['icons'][$i]['selected']) { |
|
| 1237 | + $context['icon_url'] = $context['icons'][$i]['url']; |
|
| 1238 | + } |
|
| 1186 | 1239 | } |
| 1187 | 1240 | if (empty($context['icon_url'])) |
| 1188 | 1241 | { |
@@ -1196,8 +1249,9 @@ discard block |
||
| 1196 | 1249 | )); |
| 1197 | 1250 | } |
| 1198 | 1251 | |
| 1199 | - if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) |
|
| 1200 | - getTopic(); |
|
| 1252 | + if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) { |
|
| 1253 | + getTopic(); |
|
| 1254 | + } |
|
| 1201 | 1255 | |
| 1202 | 1256 | // If the user can post attachments prepare the warning labels. |
| 1203 | 1257 | if ($context['can_post_attachment']) |
@@ -1208,12 +1262,13 @@ discard block |
||
| 1208 | 1262 | $context['attachment_restrictions'] = array(); |
| 1209 | 1263 | $context['allowed_extensions'] = strtr(strtolower($modSettings['attachmentExtensions']), array(',' => ', ')); |
| 1210 | 1264 | $attachmentRestrictionTypes = array('attachmentNumPerPostLimit', 'attachmentPostLimit', 'attachmentSizeLimit'); |
| 1211 | - foreach ($attachmentRestrictionTypes as $type) |
|
| 1212 | - if (!empty($modSettings[$type])) |
|
| 1265 | + foreach ($attachmentRestrictionTypes as $type) { |
|
| 1266 | + if (!empty($modSettings[$type])) |
|
| 1213 | 1267 | { |
| 1214 | 1268 | // Show the max number of attachments if not 0. |
| 1215 | 1269 | if ($type == 'attachmentNumPerPostLimit') |
| 1216 | 1270 | $context['attachment_restrictions'][] = sprintf($txt['attach_remaining'], $modSettings['attachmentNumPerPostLimit'] - $context['attachments']['quantity']); |
| 1271 | + } |
|
| 1217 | 1272 | } |
| 1218 | 1273 | } |
| 1219 | 1274 | |
@@ -1247,8 +1302,8 @@ discard block |
||
| 1247 | 1302 | |
| 1248 | 1303 | if (!empty($context['current_attachments'])) |
| 1249 | 1304 | { |
| 1250 | - foreach ($context['current_attachments'] as $key => $mock) |
|
| 1251 | - addInlineJavaScript(' |
|
| 1305 | + foreach ($context['current_attachments'] as $key => $mock) { |
|
| 1306 | + addInlineJavaScript(' |
|
| 1252 | 1307 | current_attachments.push({ |
| 1253 | 1308 | name: '. JavaScriptEscape($mock['name']) . ', |
| 1254 | 1309 | size: '. $mock['size'] . ', |
@@ -1257,6 +1312,7 @@ discard block |
||
| 1257 | 1312 | type: '. JavaScriptEscape(!empty($mock['mime_type']) ? $mock['mime_type'] : '') . ', |
| 1258 | 1313 | thumbID: '. (!empty($mock['thumb']) ? $mock['thumb'] : 0) . ' |
| 1259 | 1314 | });', true); |
| 1315 | + } |
|
| 1260 | 1316 | } |
| 1261 | 1317 | |
| 1262 | 1318 | // File Upload. |
@@ -1341,8 +1397,9 @@ discard block |
||
| 1341 | 1397 | |
| 1342 | 1398 | |
| 1343 | 1399 | // Finally, load the template. |
| 1344 | - if (!isset($_REQUEST['xml'])) |
|
| 1345 | - loadTemplate('Post'); |
|
| 1400 | + if (!isset($_REQUEST['xml'])) { |
|
| 1401 | + loadTemplate('Post'); |
|
| 1402 | + } |
|
| 1346 | 1403 | |
| 1347 | 1404 | call_integration_hook('integrate_post_end'); |
| 1348 | 1405 | } |
@@ -1363,13 +1420,14 @@ discard block |
||
| 1363 | 1420 | // Sneaking off, are we? |
| 1364 | 1421 | if (empty($_POST) && empty($topic)) |
| 1365 | 1422 | { |
| 1366 | - if (empty($_SERVER['CONTENT_LENGTH'])) |
|
| 1367 | - redirectexit('action=post;board=' . $board . '.0'); |
|
| 1368 | - else |
|
| 1369 | - fatal_lang_error('post_upload_error', false); |
|
| 1423 | + if (empty($_SERVER['CONTENT_LENGTH'])) { |
|
| 1424 | + redirectexit('action=post;board=' . $board . '.0'); |
|
| 1425 | + } else { |
|
| 1426 | + fatal_lang_error('post_upload_error', false); |
|
| 1427 | + } |
|
| 1428 | + } elseif (empty($_POST) && !empty($topic)) { |
|
| 1429 | + redirectexit('action=post;topic=' . $topic . '.0'); |
|
| 1370 | 1430 | } |
| 1371 | - elseif (empty($_POST) && !empty($topic)) |
|
| 1372 | - redirectexit('action=post;topic=' . $topic . '.0'); |
|
| 1373 | 1431 | |
| 1374 | 1432 | // No need! |
| 1375 | 1433 | $context['robot_no_index'] = true; |
@@ -1381,8 +1439,9 @@ discard block |
||
| 1381 | 1439 | $post_errors = array(); |
| 1382 | 1440 | |
| 1383 | 1441 | // If the session has timed out, let the user re-submit their form. |
| 1384 | - if (checkSession('post', '', false) != '') |
|
| 1385 | - $post_errors[] = 'session_timeout'; |
|
| 1442 | + if (checkSession('post', '', false) != '') { |
|
| 1443 | + $post_errors[] = 'session_timeout'; |
|
| 1444 | + } |
|
| 1386 | 1445 | |
| 1387 | 1446 | // Wrong verification code? |
| 1388 | 1447 | 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))) |
@@ -1392,33 +1451,38 @@ discard block |
||
| 1392 | 1451 | 'id' => 'post', |
| 1393 | 1452 | ); |
| 1394 | 1453 | $context['require_verification'] = create_control_verification($verificationOptions, true); |
| 1395 | - if (is_array($context['require_verification'])) |
|
| 1396 | - $post_errors = array_merge($post_errors, $context['require_verification']); |
|
| 1454 | + if (is_array($context['require_verification'])) { |
|
| 1455 | + $post_errors = array_merge($post_errors, $context['require_verification']); |
|
| 1456 | + } |
|
| 1397 | 1457 | } |
| 1398 | 1458 | |
| 1399 | 1459 | require_once($sourcedir . '/Subs-Post.php'); |
| 1400 | 1460 | loadLanguage('Post'); |
| 1401 | 1461 | |
| 1402 | 1462 | // Drafts enabled and needed? |
| 1403 | - if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) |
|
| 1404 | - require_once($sourcedir . '/Drafts.php'); |
|
| 1463 | + if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) { |
|
| 1464 | + require_once($sourcedir . '/Drafts.php'); |
|
| 1465 | + } |
|
| 1405 | 1466 | |
| 1406 | 1467 | // First check to see if they are trying to delete any current attachments. |
| 1407 | 1468 | if (isset($_POST['attach_del'])) |
| 1408 | 1469 | { |
| 1409 | 1470 | $keep_temp = array(); |
| 1410 | 1471 | $keep_ids = array(); |
| 1411 | - foreach ($_POST['attach_del'] as $dummy) |
|
| 1412 | - if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false) |
|
| 1472 | + foreach ($_POST['attach_del'] as $dummy) { |
|
| 1473 | + if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false) |
|
| 1413 | 1474 | $keep_temp[] = $dummy; |
| 1414 | - else |
|
| 1415 | - $keep_ids[] = (int) $dummy; |
|
| 1475 | + } |
|
| 1476 | + else { |
|
| 1477 | + $keep_ids[] = (int) $dummy; |
|
| 1478 | + } |
|
| 1416 | 1479 | |
| 1417 | - if (isset($_SESSION['temp_attachments'])) |
|
| 1418 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
| 1480 | + if (isset($_SESSION['temp_attachments'])) { |
|
| 1481 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
| 1419 | 1482 | { |
| 1420 | 1483 | 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) |
| 1421 | 1484 | continue; |
| 1485 | + } |
|
| 1422 | 1486 | |
| 1423 | 1487 | unset($_SESSION['temp_attachments'][$attachID]); |
| 1424 | 1488 | unlink($attachment['tmp_name']); |
@@ -1460,12 +1524,14 @@ discard block |
||
| 1460 | 1524 | $smcFunc['db_free_result']($request); |
| 1461 | 1525 | |
| 1462 | 1526 | // Though the topic should be there, it might have vanished. |
| 1463 | - if (!is_array($topic_info)) |
|
| 1464 | - fatal_lang_error('topic_doesnt_exist', 404); |
|
| 1527 | + if (!is_array($topic_info)) { |
|
| 1528 | + fatal_lang_error('topic_doesnt_exist', 404); |
|
| 1529 | + } |
|
| 1465 | 1530 | |
| 1466 | 1531 | // Did this topic suddenly move? Just checking... |
| 1467 | - if ($topic_info['id_board'] != $board) |
|
| 1468 | - fatal_lang_error('not_a_topic'); |
|
| 1532 | + if ($topic_info['id_board'] != $board) { |
|
| 1533 | + fatal_lang_error('not_a_topic'); |
|
| 1534 | + } |
|
| 1469 | 1535 | |
| 1470 | 1536 | // Do the permissions and approval stuff... |
| 1471 | 1537 | $becomesApproved = true; |
@@ -1488,49 +1554,50 @@ discard block |
||
| 1488 | 1554 | if (!empty($topic) && !isset($_REQUEST['msg'])) |
| 1489 | 1555 | { |
| 1490 | 1556 | // Don't allow a post if it's locked. |
| 1491 | - if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) |
|
| 1492 | - fatal_lang_error('topic_locked', false); |
|
| 1557 | + if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) { |
|
| 1558 | + fatal_lang_error('topic_locked', false); |
|
| 1559 | + } |
|
| 1493 | 1560 | |
| 1494 | 1561 | // Sorry, multiple polls aren't allowed... yet. You should stop giving me ideas :P. |
| 1495 | - if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) |
|
| 1496 | - unset($_REQUEST['poll']); |
|
| 1497 | - |
|
| 1498 | - elseif ($topic_info['id_member_started'] != $user_info['id']) |
|
| 1499 | - { |
|
| 1500 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
|
| 1501 | - $becomesApproved = false; |
|
| 1502 | - |
|
| 1503 | - else |
|
| 1504 | - isAllowedTo('post_reply_any'); |
|
| 1505 | - } |
|
| 1506 | - elseif (!allowedTo('post_reply_any')) |
|
| 1562 | + if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) { |
|
| 1563 | + unset($_REQUEST['poll']); |
|
| 1564 | + } elseif ($topic_info['id_member_started'] != $user_info['id']) |
|
| 1565 | + { |
|
| 1566 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) { |
|
| 1567 | + $becomesApproved = false; |
|
| 1568 | + } else { |
|
| 1569 | + isAllowedTo('post_reply_any'); |
|
| 1570 | + } |
|
| 1571 | + } elseif (!allowedTo('post_reply_any')) |
|
| 1507 | 1572 | { |
| 1508 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) |
|
| 1509 | - $becomesApproved = false; |
|
| 1510 | - |
|
| 1511 | - else |
|
| 1512 | - isAllowedTo('post_reply_own'); |
|
| 1573 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) { |
|
| 1574 | + $becomesApproved = false; |
|
| 1575 | + } else { |
|
| 1576 | + isAllowedTo('post_reply_own'); |
|
| 1577 | + } |
|
| 1513 | 1578 | } |
| 1514 | 1579 | |
| 1515 | 1580 | if (isset($_POST['lock'])) |
| 1516 | 1581 | { |
| 1517 | 1582 | // Nothing is changed to the lock. |
| 1518 | - if ((empty($topic_info['locked']) && empty($_POST['lock'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) |
|
| 1519 | - unset($_POST['lock']); |
|
| 1583 | + if ((empty($topic_info['locked']) && empty($_POST['lock'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) { |
|
| 1584 | + unset($_POST['lock']); |
|
| 1585 | + } |
|
| 1520 | 1586 | |
| 1521 | 1587 | // You're have no permission to lock this topic. |
| 1522 | - elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) |
|
| 1523 | - unset($_POST['lock']); |
|
| 1588 | + elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) { |
|
| 1589 | + unset($_POST['lock']); |
|
| 1590 | + } |
|
| 1524 | 1591 | |
| 1525 | 1592 | // You are allowed to (un)lock your own topic only. |
| 1526 | 1593 | elseif (!allowedTo('lock_any')) |
| 1527 | 1594 | { |
| 1528 | 1595 | // You cannot override a moderator lock. |
| 1529 | - if ($topic_info['locked'] == 1) |
|
| 1530 | - unset($_POST['lock']); |
|
| 1531 | - |
|
| 1532 | - else |
|
| 1533 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 1596 | + if ($topic_info['locked'] == 1) { |
|
| 1597 | + unset($_POST['lock']); |
|
| 1598 | + } else { |
|
| 1599 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 1600 | + } |
|
| 1534 | 1601 | } |
| 1535 | 1602 | // Hail mighty moderator, (un)lock this topic immediately. |
| 1536 | 1603 | else |
@@ -1538,19 +1605,21 @@ discard block |
||
| 1538 | 1605 | $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
| 1539 | 1606 | |
| 1540 | 1607 | // Did someone (un)lock this while you were posting? |
| 1541 | - if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) |
|
| 1542 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
| 1608 | + if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) { |
|
| 1609 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
| 1610 | + } |
|
| 1543 | 1611 | } |
| 1544 | 1612 | } |
| 1545 | 1613 | |
| 1546 | 1614 | // So you wanna (un)sticky this...let's see. |
| 1547 | - if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) |
|
| 1548 | - unset($_POST['sticky']); |
|
| 1549 | - elseif (isset($_POST['sticky'])) |
|
| 1615 | + if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) { |
|
| 1616 | + unset($_POST['sticky']); |
|
| 1617 | + } elseif (isset($_POST['sticky'])) |
|
| 1550 | 1618 | { |
| 1551 | 1619 | // Did someone (un)sticky this while you were posting? |
| 1552 | - if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) |
|
| 1553 | - $post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky'; |
|
| 1620 | + if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) { |
|
| 1621 | + $post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky'; |
|
| 1622 | + } |
|
| 1554 | 1623 | } |
| 1555 | 1624 | |
| 1556 | 1625 | // If drafts are enabled, then pass this off |
@@ -1577,26 +1646,31 @@ discard block |
||
| 1577 | 1646 | |
| 1578 | 1647 | // Do like, the permissions, for safety and stuff... |
| 1579 | 1648 | $becomesApproved = true; |
| 1580 | - if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) |
|
| 1581 | - $becomesApproved = false; |
|
| 1582 | - else |
|
| 1583 | - isAllowedTo('post_new'); |
|
| 1649 | + if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) { |
|
| 1650 | + $becomesApproved = false; |
|
| 1651 | + } else { |
|
| 1652 | + isAllowedTo('post_new'); |
|
| 1653 | + } |
|
| 1584 | 1654 | |
| 1585 | 1655 | if (isset($_POST['lock'])) |
| 1586 | 1656 | { |
| 1587 | 1657 | // New topics are by default not locked. |
| 1588 | - if (empty($_POST['lock'])) |
|
| 1589 | - unset($_POST['lock']); |
|
| 1658 | + if (empty($_POST['lock'])) { |
|
| 1659 | + unset($_POST['lock']); |
|
| 1660 | + } |
|
| 1590 | 1661 | // Besides, you need permission. |
| 1591 | - elseif (!allowedTo(array('lock_any', 'lock_own'))) |
|
| 1592 | - unset($_POST['lock']); |
|
| 1662 | + elseif (!allowedTo(array('lock_any', 'lock_own'))) { |
|
| 1663 | + unset($_POST['lock']); |
|
| 1664 | + } |
|
| 1593 | 1665 | // A moderator-lock (1) can override a user-lock (2). |
| 1594 | - else |
|
| 1595 | - $_POST['lock'] = allowedTo('lock_any') ? 1 : 2; |
|
| 1666 | + else { |
|
| 1667 | + $_POST['lock'] = allowedTo('lock_any') ? 1 : 2; |
|
| 1668 | + } |
|
| 1596 | 1669 | } |
| 1597 | 1670 | |
| 1598 | - if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) |
|
| 1599 | - unset($_POST['sticky']); |
|
| 1671 | + if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) { |
|
| 1672 | + unset($_POST['sticky']); |
|
| 1673 | + } |
|
| 1600 | 1674 | |
| 1601 | 1675 | // Saving your new topic as a draft first? |
| 1602 | 1676 | if (!empty($modSettings['drafts_post_enabled']) && isset($_POST['save_draft'])) |
@@ -1621,31 +1695,37 @@ discard block |
||
| 1621 | 1695 | 'id_msg' => $_REQUEST['msg'], |
| 1622 | 1696 | ) |
| 1623 | 1697 | ); |
| 1624 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1625 | - fatal_lang_error('cant_find_messages', false); |
|
| 1698 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1699 | + fatal_lang_error('cant_find_messages', false); |
|
| 1700 | + } |
|
| 1626 | 1701 | $row = $smcFunc['db_fetch_assoc']($request); |
| 1627 | 1702 | $smcFunc['db_free_result']($request); |
| 1628 | 1703 | |
| 1629 | - if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) |
|
| 1630 | - fatal_lang_error('topic_locked', false); |
|
| 1704 | + if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) { |
|
| 1705 | + fatal_lang_error('topic_locked', false); |
|
| 1706 | + } |
|
| 1631 | 1707 | |
| 1632 | 1708 | if (isset($_POST['lock'])) |
| 1633 | 1709 | { |
| 1634 | 1710 | // Nothing changes to the lock status. |
| 1635 | - if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) |
|
| 1636 | - unset($_POST['lock']); |
|
| 1711 | + if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) { |
|
| 1712 | + unset($_POST['lock']); |
|
| 1713 | + } |
|
| 1637 | 1714 | // You're simply not allowed to (un)lock this. |
| 1638 | - elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) |
|
| 1639 | - unset($_POST['lock']); |
|
| 1715 | + elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) { |
|
| 1716 | + unset($_POST['lock']); |
|
| 1717 | + } |
|
| 1640 | 1718 | // You're only allowed to lock your own topics. |
| 1641 | 1719 | elseif (!allowedTo('lock_any')) |
| 1642 | 1720 | { |
| 1643 | 1721 | // You're not allowed to break a moderator's lock. |
| 1644 | - if ($topic_info['locked'] == 1) |
|
| 1645 | - unset($_POST['lock']); |
|
| 1722 | + if ($topic_info['locked'] == 1) { |
|
| 1723 | + unset($_POST['lock']); |
|
| 1724 | + } |
|
| 1646 | 1725 | // Lock it with a soft lock or unlock it. |
| 1647 | - else |
|
| 1648 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 1726 | + else { |
|
| 1727 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 1728 | + } |
|
| 1649 | 1729 | } |
| 1650 | 1730 | // You must be the moderator. |
| 1651 | 1731 | else |
@@ -1653,44 +1733,46 @@ discard block |
||
| 1653 | 1733 | $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
| 1654 | 1734 | |
| 1655 | 1735 | // Did someone (un)lock this while you were posting? |
| 1656 | - if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) |
|
| 1657 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
| 1736 | + if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) { |
|
| 1737 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
| 1738 | + } |
|
| 1658 | 1739 | } |
| 1659 | 1740 | } |
| 1660 | 1741 | |
| 1661 | 1742 | // Change the sticky status of this topic? |
| 1662 | - if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) |
|
| 1663 | - unset($_POST['sticky']); |
|
| 1664 | - elseif (isset($_POST['sticky'])) |
|
| 1743 | + if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) { |
|
| 1744 | + unset($_POST['sticky']); |
|
| 1745 | + } elseif (isset($_POST['sticky'])) |
|
| 1665 | 1746 | { |
| 1666 | 1747 | // Did someone (un)sticky this while you were posting? |
| 1667 | - if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) |
|
| 1668 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied'; |
|
| 1748 | + if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) { |
|
| 1749 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied'; |
|
| 1750 | + } |
|
| 1669 | 1751 | } |
| 1670 | 1752 | |
| 1671 | 1753 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
| 1672 | 1754 | { |
| 1673 | - if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
| 1674 | - fatal_lang_error('modify_post_time_passed', false); |
|
| 1675 | - elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
|
| 1676 | - isAllowedTo('modify_replies'); |
|
| 1677 | - else |
|
| 1678 | - isAllowedTo('modify_own'); |
|
| 1679 | - } |
|
| 1680 | - elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 1755 | + if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
| 1756 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 1757 | + } elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
| 1758 | + isAllowedTo('modify_replies'); |
|
| 1759 | + } else { |
|
| 1760 | + isAllowedTo('modify_own'); |
|
| 1761 | + } |
|
| 1762 | + } elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 1681 | 1763 | { |
| 1682 | 1764 | isAllowedTo('modify_replies'); |
| 1683 | 1765 | |
| 1684 | 1766 | // If you're modifying a reply, I say it better be logged... |
| 1685 | 1767 | $moderationAction = true; |
| 1686 | - } |
|
| 1687 | - else |
|
| 1768 | + } else |
|
| 1688 | 1769 | { |
| 1689 | 1770 | isAllowedTo('modify_any'); |
| 1690 | 1771 | |
| 1691 | 1772 | // Log it, assuming you're not modifying your own post. |
| 1692 | - if ($row['id_member'] != $user_info['id']) |
|
| 1693 | - $moderationAction = true; |
|
| 1773 | + if ($row['id_member'] != $user_info['id']) { |
|
| 1774 | + $moderationAction = true; |
|
| 1775 | + } |
|
| 1694 | 1776 | } |
| 1695 | 1777 | |
| 1696 | 1778 | // If drafts are enabled, then lets send this off to save |
@@ -1728,20 +1810,24 @@ discard block |
||
| 1728 | 1810 | $_POST['guestname'] = !isset($_POST['guestname']) ? '' : trim($_POST['guestname']); |
| 1729 | 1811 | $_POST['email'] = !isset($_POST['email']) ? '' : trim($_POST['email']); |
| 1730 | 1812 | |
| 1731 | - if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') |
|
| 1732 | - $post_errors[] = 'no_name'; |
|
| 1733 | - if ($smcFunc['strlen']($_POST['guestname']) > 25) |
|
| 1734 | - $post_errors[] = 'long_name'; |
|
| 1813 | + if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') { |
|
| 1814 | + $post_errors[] = 'no_name'; |
|
| 1815 | + } |
|
| 1816 | + if ($smcFunc['strlen']($_POST['guestname']) > 25) { |
|
| 1817 | + $post_errors[] = 'long_name'; |
|
| 1818 | + } |
|
| 1735 | 1819 | |
| 1736 | 1820 | if (empty($modSettings['guest_post_no_email'])) |
| 1737 | 1821 | { |
| 1738 | 1822 | // Only check if they changed it! |
| 1739 | 1823 | if (!isset($row) || $row['poster_email'] != $_POST['email']) |
| 1740 | 1824 | { |
| 1741 | - if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) |
|
| 1742 | - $post_errors[] = 'no_email'; |
|
| 1743 | - if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) |
|
| 1744 | - $post_errors[] = 'bad_email'; |
|
| 1825 | + if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) { |
|
| 1826 | + $post_errors[] = 'no_email'; |
|
| 1827 | + } |
|
| 1828 | + if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { |
|
| 1829 | + $post_errors[] = 'bad_email'; |
|
| 1830 | + } |
|
| 1745 | 1831 | } |
| 1746 | 1832 | |
| 1747 | 1833 | // Now make sure this email address is not banned from posting. |
@@ -1757,75 +1843,89 @@ discard block |
||
| 1757 | 1843 | } |
| 1758 | 1844 | |
| 1759 | 1845 | // Coming from the quickReply? |
| 1760 | - if (isset($_POST['quickReply'])) |
|
| 1761 | - $_POST['message'] = $_POST['quickReply']; |
|
| 1846 | + if (isset($_POST['quickReply'])) { |
|
| 1847 | + $_POST['message'] = $_POST['quickReply']; |
|
| 1848 | + } |
|
| 1762 | 1849 | |
| 1763 | 1850 | // Check the subject and message. |
| 1764 | - if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') |
|
| 1765 | - $post_errors[] = 'no_subject'; |
|
| 1766 | - if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') |
|
| 1767 | - $post_errors[] = 'no_message'; |
|
| 1768 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
| 1769 | - $post_errors[] = array('long_message', array($modSettings['max_messageLength'])); |
|
| 1770 | - else |
|
| 1851 | + if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') { |
|
| 1852 | + $post_errors[] = 'no_subject'; |
|
| 1853 | + } |
|
| 1854 | + if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') { |
|
| 1855 | + $post_errors[] = 'no_message'; |
|
| 1856 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) { |
|
| 1857 | + $post_errors[] = array('long_message', array($modSettings['max_messageLength'])); |
|
| 1858 | + } else |
|
| 1771 | 1859 | { |
| 1772 | 1860 | // Prepare the message a bit for some additional testing. |
| 1773 | 1861 | $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES); |
| 1774 | 1862 | |
| 1775 | 1863 | // Preparse code. (Zef) |
| 1776 | - if ($user_info['is_guest']) |
|
| 1777 | - $user_info['name'] = $_POST['guestname']; |
|
| 1864 | + if ($user_info['is_guest']) { |
|
| 1865 | + $user_info['name'] = $_POST['guestname']; |
|
| 1866 | + } |
|
| 1778 | 1867 | preparsecode($_POST['message']); |
| 1779 | 1868 | |
| 1780 | 1869 | // Let's see if there's still some content left without the tags. |
| 1781 | - if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) |
|
| 1782 | - $post_errors[] = 'no_message'; |
|
| 1870 | + if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) { |
|
| 1871 | + $post_errors[] = 'no_message'; |
|
| 1872 | + } |
|
| 1873 | + } |
|
| 1874 | + if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') { |
|
| 1875 | + $post_errors[] = 'no_event'; |
|
| 1783 | 1876 | } |
| 1784 | - if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') |
|
| 1785 | - $post_errors[] = 'no_event'; |
|
| 1786 | 1877 | // You are not! |
| 1787 | - if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) |
|
| 1788 | - fatal_error('Knave! Masquerader! Charlatan!', false); |
|
| 1878 | + if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) { |
|
| 1879 | + fatal_error('Knave! Masquerader! Charlatan!', false); |
|
| 1880 | + } |
|
| 1789 | 1881 | |
| 1790 | 1882 | // Validate the poll... |
| 1791 | 1883 | if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1') |
| 1792 | 1884 | { |
| 1793 | - if (!empty($topic) && !isset($_REQUEST['msg'])) |
|
| 1794 | - fatal_lang_error('no_access', false); |
|
| 1885 | + if (!empty($topic) && !isset($_REQUEST['msg'])) { |
|
| 1886 | + fatal_lang_error('no_access', false); |
|
| 1887 | + } |
|
| 1795 | 1888 | |
| 1796 | 1889 | // This is a new topic... so it's a new poll. |
| 1797 | - if (empty($topic)) |
|
| 1798 | - isAllowedTo('poll_post'); |
|
| 1890 | + if (empty($topic)) { |
|
| 1891 | + isAllowedTo('poll_post'); |
|
| 1892 | + } |
|
| 1799 | 1893 | // Can you add to your own topics? |
| 1800 | - elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) |
|
| 1801 | - isAllowedTo('poll_add_own'); |
|
| 1894 | + elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) { |
|
| 1895 | + isAllowedTo('poll_add_own'); |
|
| 1896 | + } |
|
| 1802 | 1897 | // Can you add polls to any topic, then? |
| 1803 | - else |
|
| 1804 | - isAllowedTo('poll_add_any'); |
|
| 1898 | + else { |
|
| 1899 | + isAllowedTo('poll_add_any'); |
|
| 1900 | + } |
|
| 1805 | 1901 | |
| 1806 | - if (!isset($_POST['question']) || trim($_POST['question']) == '') |
|
| 1807 | - $post_errors[] = 'no_question'; |
|
| 1902 | + if (!isset($_POST['question']) || trim($_POST['question']) == '') { |
|
| 1903 | + $post_errors[] = 'no_question'; |
|
| 1904 | + } |
|
| 1808 | 1905 | |
| 1809 | 1906 | $_POST['options'] = empty($_POST['options']) ? array() : htmltrim__recursive($_POST['options']); |
| 1810 | 1907 | |
| 1811 | 1908 | // Get rid of empty ones. |
| 1812 | - foreach ($_POST['options'] as $k => $option) |
|
| 1813 | - if ($option == '') |
|
| 1909 | + foreach ($_POST['options'] as $k => $option) { |
|
| 1910 | + if ($option == '') |
|
| 1814 | 1911 | unset($_POST['options'][$k], $_POST['options'][$k]); |
| 1912 | + } |
|
| 1815 | 1913 | |
| 1816 | 1914 | // What are you going to vote between with one choice?!? |
| 1817 | - if (count($_POST['options']) < 2) |
|
| 1818 | - $post_errors[] = 'poll_few'; |
|
| 1819 | - elseif (count($_POST['options']) > 256) |
|
| 1820 | - $post_errors[] = 'poll_many'; |
|
| 1915 | + if (count($_POST['options']) < 2) { |
|
| 1916 | + $post_errors[] = 'poll_few'; |
|
| 1917 | + } elseif (count($_POST['options']) > 256) { |
|
| 1918 | + $post_errors[] = 'poll_many'; |
|
| 1919 | + } |
|
| 1821 | 1920 | } |
| 1822 | 1921 | |
| 1823 | 1922 | if ($posterIsGuest) |
| 1824 | 1923 | { |
| 1825 | 1924 | // If user is a guest, make sure the chosen name isn't taken. |
| 1826 | 1925 | require_once($sourcedir . '/Subs-Members.php'); |
| 1827 | - if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) |
|
| 1828 | - $post_errors[] = 'bad_name'; |
|
| 1926 | + if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) { |
|
| 1927 | + $post_errors[] = 'bad_name'; |
|
| 1928 | + } |
|
| 1829 | 1929 | } |
| 1830 | 1930 | // If the user isn't a guest, get his or her name and email. |
| 1831 | 1931 | elseif (!isset($_REQUEST['msg'])) |
@@ -1856,8 +1956,9 @@ discard block |
||
| 1856 | 1956 | } |
| 1857 | 1957 | |
| 1858 | 1958 | // Make sure the user isn't spamming the board. |
| 1859 | - if (!isset($_REQUEST['msg'])) |
|
| 1860 | - spamProtection('post'); |
|
| 1959 | + if (!isset($_REQUEST['msg'])) { |
|
| 1960 | + spamProtection('post'); |
|
| 1961 | + } |
|
| 1861 | 1962 | |
| 1862 | 1963 | // At about this point, we're posting and that's that. |
| 1863 | 1964 | ignore_user_abort(true); |
@@ -1870,32 +1971,36 @@ discard block |
||
| 1870 | 1971 | $_POST['modify_reason'] = empty($_POST['modify_reason']) ? '' : strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => '')); |
| 1871 | 1972 | |
| 1872 | 1973 | // At this point, we want to make sure the subject isn't too long. |
| 1873 | - if ($smcFunc['strlen']($_POST['subject']) > 100) |
|
| 1874 | - $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
| 1974 | + if ($smcFunc['strlen']($_POST['subject']) > 100) { |
|
| 1975 | + $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
| 1976 | + } |
|
| 1875 | 1977 | |
| 1876 | 1978 | // Same with the "why did you edit this" text. |
| 1877 | - if ($smcFunc['strlen']($_POST['modify_reason']) > 100) |
|
| 1878 | - $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
| 1979 | + if ($smcFunc['strlen']($_POST['modify_reason']) > 100) { |
|
| 1980 | + $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
| 1981 | + } |
|
| 1879 | 1982 | |
| 1880 | 1983 | // Make the poll... |
| 1881 | 1984 | if (isset($_REQUEST['poll'])) |
| 1882 | 1985 | { |
| 1883 | 1986 | // Make sure that the user has not entered a ridiculous number of options.. |
| 1884 | - if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) |
|
| 1885 | - $_POST['poll_max_votes'] = 1; |
|
| 1886 | - elseif ($_POST['poll_max_votes'] > count($_POST['options'])) |
|
| 1887 | - $_POST['poll_max_votes'] = count($_POST['options']); |
|
| 1888 | - else |
|
| 1889 | - $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
| 1987 | + if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) { |
|
| 1988 | + $_POST['poll_max_votes'] = 1; |
|
| 1989 | + } elseif ($_POST['poll_max_votes'] > count($_POST['options'])) { |
|
| 1990 | + $_POST['poll_max_votes'] = count($_POST['options']); |
|
| 1991 | + } else { |
|
| 1992 | + $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
| 1993 | + } |
|
| 1890 | 1994 | |
| 1891 | 1995 | $_POST['poll_expire'] = (int) $_POST['poll_expire']; |
| 1892 | 1996 | $_POST['poll_expire'] = $_POST['poll_expire'] > 9999 ? 9999 : ($_POST['poll_expire'] < 0 ? 0 : $_POST['poll_expire']); |
| 1893 | 1997 | |
| 1894 | 1998 | // Just set it to zero if it's not there.. |
| 1895 | - if (!isset($_POST['poll_hide'])) |
|
| 1896 | - $_POST['poll_hide'] = 0; |
|
| 1897 | - else |
|
| 1898 | - $_POST['poll_hide'] = (int) $_POST['poll_hide']; |
|
| 1999 | + if (!isset($_POST['poll_hide'])) { |
|
| 2000 | + $_POST['poll_hide'] = 0; |
|
| 2001 | + } else { |
|
| 2002 | + $_POST['poll_hide'] = (int) $_POST['poll_hide']; |
|
| 2003 | + } |
|
| 1899 | 2004 | $_POST['poll_change_vote'] = isset($_POST['poll_change_vote']) ? 1 : 0; |
| 1900 | 2005 | |
| 1901 | 2006 | $_POST['poll_guest_vote'] = isset($_POST['poll_guest_vote']) ? 1 : 0; |
@@ -1904,16 +2009,19 @@ discard block |
||
| 1904 | 2009 | { |
| 1905 | 2010 | require_once($sourcedir . '/Subs-Members.php'); |
| 1906 | 2011 | $allowedVoteGroups = groupsAllowedTo('poll_vote', $board); |
| 1907 | - if (!in_array(-1, $allowedVoteGroups['allowed'])) |
|
| 1908 | - $_POST['poll_guest_vote'] = 0; |
|
| 2012 | + if (!in_array(-1, $allowedVoteGroups['allowed'])) { |
|
| 2013 | + $_POST['poll_guest_vote'] = 0; |
|
| 2014 | + } |
|
| 1909 | 2015 | } |
| 1910 | 2016 | |
| 1911 | 2017 | // If the user tries to set the poll too far in advance, don't let them. |
| 1912 | - if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) |
|
| 1913 | - fatal_lang_error('poll_range_error', false); |
|
| 2018 | + if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) { |
|
| 2019 | + fatal_lang_error('poll_range_error', false); |
|
| 2020 | + } |
|
| 1914 | 2021 | // Don't allow them to select option 2 for hidden results if it's not time limited. |
| 1915 | - elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) |
|
| 1916 | - $_POST['poll_hide'] = 1; |
|
| 2022 | + elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) { |
|
| 2023 | + $_POST['poll_hide'] = 1; |
|
| 2024 | + } |
|
| 1917 | 2025 | |
| 1918 | 2026 | // Clean up the question and answers. |
| 1919 | 2027 | $_POST['question'] = $smcFunc['htmlspecialchars']($_POST['question']); |
@@ -1927,13 +2035,15 @@ discard block |
||
| 1927 | 2035 | { |
| 1928 | 2036 | $attachIDs = array(); |
| 1929 | 2037 | $attach_errors = array(); |
| 1930 | - if (!empty($context['we_are_history'])) |
|
| 1931 | - $attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>'; |
|
| 2038 | + if (!empty($context['we_are_history'])) { |
|
| 2039 | + $attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>'; |
|
| 2040 | + } |
|
| 1932 | 2041 | |
| 1933 | 2042 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 1934 | 2043 | { |
| 1935 | - if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
| 1936 | - continue; |
|
| 2044 | + if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
| 2045 | + continue; |
|
| 2046 | + } |
|
| 1937 | 2047 | |
| 1938 | 2048 | // If there was an initial error just show that message. |
| 1939 | 2049 | if ($attachID == 'initial_error') |
@@ -1962,12 +2072,13 @@ discard block |
||
| 1962 | 2072 | if (createAttachment($attachmentOptions)) |
| 1963 | 2073 | { |
| 1964 | 2074 | $attachIDs[] = $attachmentOptions['id']; |
| 1965 | - if (!empty($attachmentOptions['thumb'])) |
|
| 1966 | - $attachIDs[] = $attachmentOptions['thumb']; |
|
| 2075 | + if (!empty($attachmentOptions['thumb'])) { |
|
| 2076 | + $attachIDs[] = $attachmentOptions['thumb']; |
|
| 2077 | + } |
|
| 1967 | 2078 | } |
| 2079 | + } else { |
|
| 2080 | + $attach_errors[] = '<dt> </dt>'; |
|
| 1968 | 2081 | } |
| 1969 | - else |
|
| 1970 | - $attach_errors[] = '<dt> </dt>'; |
|
| 1971 | 2082 | |
| 1972 | 2083 | if (!empty($attachmentOptions['errors'])) |
| 1973 | 2084 | { |
@@ -1979,14 +2090,16 @@ discard block |
||
| 1979 | 2090 | if (!is_array($error)) |
| 1980 | 2091 | { |
| 1981 | 2092 | $attach_errors[] = '<dd>' . $txt[$error] . '</dd>'; |
| 1982 | - if (in_array($error, $log_these)) |
|
| 1983 | - log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
| 2093 | + if (in_array($error, $log_these)) { |
|
| 2094 | + log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
| 2095 | + } |
|
| 2096 | + } else { |
|
| 2097 | + $attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>'; |
|
| 1984 | 2098 | } |
| 1985 | - else |
|
| 1986 | - $attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>'; |
|
| 1987 | 2099 | } |
| 1988 | - if (file_exists($attachment['tmp_name'])) |
|
| 1989 | - unlink($attachment['tmp_name']); |
|
| 2100 | + if (file_exists($attachment['tmp_name'])) { |
|
| 2101 | + unlink($attachment['tmp_name']); |
|
| 2102 | + } |
|
| 1990 | 2103 | } |
| 1991 | 2104 | } |
| 1992 | 2105 | unset($_SESSION['temp_attachments']); |
@@ -2027,24 +2140,24 @@ discard block |
||
| 2027 | 2140 | ); |
| 2028 | 2141 | |
| 2029 | 2142 | call_integration_hook('integrate_poll_add_edit', array($id_poll, false)); |
| 2143 | + } else { |
|
| 2144 | + $id_poll = 0; |
|
| 2030 | 2145 | } |
| 2031 | - else |
|
| 2032 | - $id_poll = 0; |
|
| 2033 | 2146 | |
| 2034 | 2147 | // Creating a new topic? |
| 2035 | 2148 | $newTopic = empty($_REQUEST['msg']) && empty($topic); |
| 2036 | 2149 | |
| 2037 | 2150 | // Check the icon. |
| 2038 | - if (!isset($_POST['icon'])) |
|
| 2039 | - $_POST['icon'] = 'xx'; |
|
| 2040 | - |
|
| 2041 | - else |
|
| 2151 | + if (!isset($_POST['icon'])) { |
|
| 2152 | + $_POST['icon'] = 'xx'; |
|
| 2153 | + } else |
|
| 2042 | 2154 | { |
| 2043 | 2155 | $_POST['icon'] = $smcFunc['htmlspecialchars']($_POST['icon']); |
| 2044 | 2156 | |
| 2045 | 2157 | // Need to figure it out if this is a valid icon name. |
| 2046 | - if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) |
|
| 2047 | - $_POST['icon'] = 'xx'; |
|
| 2158 | + if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) { |
|
| 2159 | + $_POST['icon'] = 'xx'; |
|
| 2160 | + } |
|
| 2048 | 2161 | } |
| 2049 | 2162 | |
| 2050 | 2163 | // Collect all parameters for the creation or modification of a post. |
@@ -2085,8 +2198,9 @@ discard block |
||
| 2085 | 2198 | } |
| 2086 | 2199 | |
| 2087 | 2200 | // This will save some time... |
| 2088 | - if (empty($approve_has_changed)) |
|
| 2089 | - unset($msgOptions['approved']); |
|
| 2201 | + if (empty($approve_has_changed)) { |
|
| 2202 | + unset($msgOptions['approved']); |
|
| 2203 | + } |
|
| 2090 | 2204 | |
| 2091 | 2205 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
| 2092 | 2206 | } |
@@ -2095,8 +2209,9 @@ discard block |
||
| 2095 | 2209 | { |
| 2096 | 2210 | createPost($msgOptions, $topicOptions, $posterOptions); |
| 2097 | 2211 | |
| 2098 | - if (isset($topicOptions['id'])) |
|
| 2099 | - $topic = $topicOptions['id']; |
|
| 2212 | + if (isset($topicOptions['id'])) { |
|
| 2213 | + $topic = $topicOptions['id']; |
|
| 2214 | + } |
|
| 2100 | 2215 | } |
| 2101 | 2216 | |
| 2102 | 2217 | // Assign the previously uploaded attachments to the brand new message. |
@@ -2108,8 +2223,9 @@ discard block |
||
| 2108 | 2223 | } |
| 2109 | 2224 | |
| 2110 | 2225 | // If we had a draft for this, its time to remove it since it was just posted |
| 2111 | - if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) |
|
| 2112 | - DeleteDraft($_POST['id_draft']); |
|
| 2226 | + if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) { |
|
| 2227 | + DeleteDraft($_POST['id_draft']); |
|
| 2228 | + } |
|
| 2113 | 2229 | |
| 2114 | 2230 | // Editing or posting an event? |
| 2115 | 2231 | if (isset($_POST['calendar']) && (!isset($_REQUEST['eventid']) || $_REQUEST['eventid'] == -1)) |
@@ -2128,8 +2244,7 @@ discard block |
||
| 2128 | 2244 | 'member' => $user_info['id'], |
| 2129 | 2245 | ); |
| 2130 | 2246 | insertEvent($eventOptions); |
| 2131 | - } |
|
| 2132 | - elseif (isset($_POST['calendar'])) |
|
| 2247 | + } elseif (isset($_POST['calendar'])) |
|
| 2133 | 2248 | { |
| 2134 | 2249 | $_REQUEST['eventid'] = (int) $_REQUEST['eventid']; |
| 2135 | 2250 | |
@@ -2157,14 +2272,15 @@ discard block |
||
| 2157 | 2272 | } |
| 2158 | 2273 | |
| 2159 | 2274 | // Delete it? |
| 2160 | - if (isset($_REQUEST['deleteevent'])) |
|
| 2161 | - $smcFunc['db_query']('', ' |
|
| 2275 | + if (isset($_REQUEST['deleteevent'])) { |
|
| 2276 | + $smcFunc['db_query']('', ' |
|
| 2162 | 2277 | DELETE FROM {db_prefix}calendar |
| 2163 | 2278 | WHERE id_event = {int:id_event}', |
| 2164 | 2279 | array( |
| 2165 | 2280 | 'id_event' => $_REQUEST['eventid'], |
| 2166 | 2281 | ) |
| 2167 | 2282 | ); |
| 2283 | + } |
|
| 2168 | 2284 | // ... or just update it? |
| 2169 | 2285 | else |
| 2170 | 2286 | { |
@@ -2206,9 +2322,8 @@ discard block |
||
| 2206 | 2322 | array($user_info['id'], $topic, 0), |
| 2207 | 2323 | array('id_member', 'id_topic', 'id_board') |
| 2208 | 2324 | ); |
| 2209 | - } |
|
| 2210 | - elseif (!$newTopic) |
|
| 2211 | - $smcFunc['db_query']('', ' |
|
| 2325 | + } elseif (!$newTopic) { |
|
| 2326 | + $smcFunc['db_query']('', ' |
|
| 2212 | 2327 | DELETE FROM {db_prefix}log_notify |
| 2213 | 2328 | WHERE id_member = {int:current_member} |
| 2214 | 2329 | AND id_topic = {int:current_topic}', |
@@ -2217,16 +2332,20 @@ discard block |
||
| 2217 | 2332 | 'current_topic' => $topic, |
| 2218 | 2333 | ) |
| 2219 | 2334 | ); |
| 2335 | + } |
|
| 2220 | 2336 | |
| 2221 | 2337 | // Log an act of moderation - modifying. |
| 2222 | - if (!empty($moderationAction)) |
|
| 2223 | - logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
| 2338 | + if (!empty($moderationAction)) { |
|
| 2339 | + logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
| 2340 | + } |
|
| 2224 | 2341 | |
| 2225 | - if (isset($_POST['lock']) && $_POST['lock'] != 2) |
|
| 2226 | - logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 2342 | + if (isset($_POST['lock']) && $_POST['lock'] != 2) { |
|
| 2343 | + logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 2344 | + } |
|
| 2227 | 2345 | |
| 2228 | - if (isset($_POST['sticky'])) |
|
| 2229 | - logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 2346 | + if (isset($_POST['sticky'])) { |
|
| 2347 | + logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 2348 | + } |
|
| 2230 | 2349 | |
| 2231 | 2350 | // Returning to the topic? |
| 2232 | 2351 | if (!empty($_REQUEST['goback'])) |
@@ -2245,26 +2364,31 @@ discard block |
||
| 2245 | 2364 | ); |
| 2246 | 2365 | } |
| 2247 | 2366 | |
| 2248 | - if ($board_info['num_topics'] == 0) |
|
| 2249 | - cache_put_data('board-' . $board, null, 120); |
|
| 2367 | + if ($board_info['num_topics'] == 0) { |
|
| 2368 | + cache_put_data('board-' . $board, null, 120); |
|
| 2369 | + } |
|
| 2250 | 2370 | |
| 2251 | 2371 | call_integration_hook('integrate_post2_end'); |
| 2252 | 2372 | |
| 2253 | - if (!empty($_POST['announce_topic'])) |
|
| 2254 | - redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2373 | + if (!empty($_POST['announce_topic'])) { |
|
| 2374 | + redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2375 | + } |
|
| 2255 | 2376 | |
| 2256 | - if (!empty($_POST['move']) && allowedTo('move_any')) |
|
| 2257 | - redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2377 | + if (!empty($_POST['move']) && allowedTo('move_any')) { |
|
| 2378 | + redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2379 | + } |
|
| 2258 | 2380 | |
| 2259 | 2381 | // Return to post if the mod is on. |
| 2260 | - if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) |
|
| 2261 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
| 2262 | - elseif (!empty($_REQUEST['goback'])) |
|
| 2263 | - redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
| 2382 | + if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) { |
|
| 2383 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
| 2384 | + } elseif (!empty($_REQUEST['goback'])) { |
|
| 2385 | + redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
| 2386 | + } |
|
| 2264 | 2387 | // Dut-dut-duh-duh-DUH-duh-dut-duh-duh! *dances to the Final Fantasy Fanfare...* |
| 2265 | - else |
|
| 2266 | - redirectexit('board=' . $board . '.0'); |
|
| 2267 | -} |
|
| 2388 | + else { |
|
| 2389 | + redirectexit('board=' . $board . '.0'); |
|
| 2390 | + } |
|
| 2391 | + } |
|
| 2268 | 2392 | |
| 2269 | 2393 | /** |
| 2270 | 2394 | * Handle the announce topic function (action=announce). |
@@ -2282,8 +2406,9 @@ discard block |
||
| 2282 | 2406 | |
| 2283 | 2407 | validateSession(); |
| 2284 | 2408 | |
| 2285 | - if (empty($topic)) |
|
| 2286 | - fatal_lang_error('topic_gone', false); |
|
| 2409 | + if (empty($topic)) { |
|
| 2410 | + fatal_lang_error('topic_gone', false); |
|
| 2411 | + } |
|
| 2287 | 2412 | |
| 2288 | 2413 | loadLanguage('Post'); |
| 2289 | 2414 | loadTemplate('Post'); |
@@ -2310,8 +2435,9 @@ discard block |
||
| 2310 | 2435 | global $txt, $context, $topic, $board_info, $smcFunc; |
| 2311 | 2436 | |
| 2312 | 2437 | $groups = array_merge($board_info['groups'], array(1)); |
| 2313 | - foreach ($groups as $id => $group) |
|
| 2314 | - $groups[$id] = (int) $group; |
|
| 2438 | + foreach ($groups as $id => $group) { |
|
| 2439 | + $groups[$id] = (int) $group; |
|
| 2440 | + } |
|
| 2315 | 2441 | |
| 2316 | 2442 | $context['groups'] = array(); |
| 2317 | 2443 | if (in_array(0, $groups)) |
@@ -2354,8 +2480,9 @@ discard block |
||
| 2354 | 2480 | 'group_list' => $groups, |
| 2355 | 2481 | ) |
| 2356 | 2482 | ); |
| 2357 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2358 | - $context['groups'][$row['id_group']]['name'] = $row['group_name']; |
|
| 2483 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2484 | + $context['groups'][$row['id_group']]['name'] = $row['group_name']; |
|
| 2485 | + } |
|
| 2359 | 2486 | $smcFunc['db_free_result']($request); |
| 2360 | 2487 | |
| 2361 | 2488 | // Get the subject of the topic we're about to announce. |
@@ -2397,16 +2524,19 @@ discard block |
||
| 2397 | 2524 | $context['start'] = empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start']; |
| 2398 | 2525 | $groups = array_merge($board_info['groups'], array(1)); |
| 2399 | 2526 | |
| 2400 | - if (isset($_POST['membergroups'])) |
|
| 2401 | - $_POST['who'] = explode(',', $_POST['membergroups']); |
|
| 2527 | + if (isset($_POST['membergroups'])) { |
|
| 2528 | + $_POST['who'] = explode(',', $_POST['membergroups']); |
|
| 2529 | + } |
|
| 2402 | 2530 | |
| 2403 | 2531 | // Check whether at least one membergroup was selected. |
| 2404 | - if (empty($_POST['who'])) |
|
| 2405 | - fatal_lang_error('no_membergroup_selected'); |
|
| 2532 | + if (empty($_POST['who'])) { |
|
| 2533 | + fatal_lang_error('no_membergroup_selected'); |
|
| 2534 | + } |
|
| 2406 | 2535 | |
| 2407 | 2536 | // Make sure all membergroups are integers and can access the board of the announcement. |
| 2408 | - foreach ($_POST['who'] as $id => $mg) |
|
| 2409 | - $_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0; |
|
| 2537 | + foreach ($_POST['who'] as $id => $mg) { |
|
| 2538 | + $_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0; |
|
| 2539 | + } |
|
| 2410 | 2540 | |
| 2411 | 2541 | // Get the topic subject and censor it. |
| 2412 | 2542 | $request = $smcFunc['db_query']('', ' |
@@ -2452,12 +2582,13 @@ discard block |
||
| 2452 | 2582 | if ($smcFunc['db_num_rows']($request) == 0) |
| 2453 | 2583 | { |
| 2454 | 2584 | logAction('announce_topic', array('topic' => $topic), 'user'); |
| 2455 | - if (!empty($_REQUEST['move']) && allowedTo('move_any')) |
|
| 2456 | - redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2457 | - elseif (!empty($_REQUEST['goback'])) |
|
| 2458 | - redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie')); |
|
| 2459 | - else |
|
| 2460 | - redirectexit('board=' . $board . '.0'); |
|
| 2585 | + if (!empty($_REQUEST['move']) && allowedTo('move_any')) { |
|
| 2586 | + redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2587 | + } elseif (!empty($_REQUEST['goback'])) { |
|
| 2588 | + redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie')); |
|
| 2589 | + } else { |
|
| 2590 | + redirectexit('board=' . $board . '.0'); |
|
| 2591 | + } |
|
| 2461 | 2592 | } |
| 2462 | 2593 | |
| 2463 | 2594 | $announcements = array(); |
@@ -2476,8 +2607,9 @@ discard block |
||
| 2476 | 2607 | foreach ($rows as $row) |
| 2477 | 2608 | { |
| 2478 | 2609 | // Force them to have it? |
| 2479 | - if (empty($prefs[$row['id_member']]['announcements'])) |
|
| 2480 | - continue; |
|
| 2610 | + if (empty($prefs[$row['id_member']]['announcements'])) { |
|
| 2611 | + continue; |
|
| 2612 | + } |
|
| 2481 | 2613 | |
| 2482 | 2614 | $cur_language = empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']; |
| 2483 | 2615 | |
@@ -2505,8 +2637,9 @@ discard block |
||
| 2505 | 2637 | } |
| 2506 | 2638 | |
| 2507 | 2639 | // For each language send a different mail - low priority... |
| 2508 | - foreach ($announcements as $lang => $mail) |
|
| 2509 | - sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5); |
|
| 2640 | + foreach ($announcements as $lang => $mail) { |
|
| 2641 | + sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5); |
|
| 2642 | + } |
|
| 2510 | 2643 | |
| 2511 | 2644 | $context['percentage_done'] = round(100 * $context['start'] / $modSettings['latestMember'], 1); |
| 2512 | 2645 | |
@@ -2516,9 +2649,10 @@ discard block |
||
| 2516 | 2649 | $context['sub_template'] = 'announcement_send'; |
| 2517 | 2650 | |
| 2518 | 2651 | // Go back to the correct language for the user ;). |
| 2519 | - if (!empty($modSettings['userLanguage'])) |
|
| 2520 | - loadLanguage('Post'); |
|
| 2521 | -} |
|
| 2652 | + if (!empty($modSettings['userLanguage'])) { |
|
| 2653 | + loadLanguage('Post'); |
|
| 2654 | + } |
|
| 2655 | + } |
|
| 2522 | 2656 | |
| 2523 | 2657 | /** |
| 2524 | 2658 | * Get the topic for display purposes. |
@@ -2531,12 +2665,13 @@ discard block |
||
| 2531 | 2665 | { |
| 2532 | 2666 | global $topic, $modSettings, $context, $smcFunc, $counter, $options; |
| 2533 | 2667 | |
| 2534 | - if (isset($_REQUEST['xml'])) |
|
| 2535 | - $limit = ' |
|
| 2668 | + if (isset($_REQUEST['xml'])) { |
|
| 2669 | + $limit = ' |
|
| 2536 | 2670 | LIMIT ' . (empty($context['new_replies']) ? '0' : $context['new_replies']); |
| 2537 | - else |
|
| 2538 | - $limit = empty($modSettings['topicSummaryPosts']) ? '' : ' |
|
| 2671 | + } else { |
|
| 2672 | + $limit = empty($modSettings['topicSummaryPosts']) ? '' : ' |
|
| 2539 | 2673 | LIMIT ' . (int) $modSettings['topicSummaryPosts']; |
| 2674 | + } |
|
| 2540 | 2675 | |
| 2541 | 2676 | // If you're modifying, get only those posts before the current one. (otherwise get all.) |
| 2542 | 2677 | $request = $smcFunc['db_query']('', ' |
@@ -2574,8 +2709,9 @@ discard block |
||
| 2574 | 2709 | 'is_ignored' => !empty($modSettings['enable_buddylist']) && !empty($options['posts_apply_ignore_list']) && in_array($row['id_member'], $context['user']['ignoreusers']), |
| 2575 | 2710 | ); |
| 2576 | 2711 | |
| 2577 | - if (!empty($context['new_replies'])) |
|
| 2578 | - $context['new_replies']--; |
|
| 2712 | + if (!empty($context['new_replies'])) { |
|
| 2713 | + $context['new_replies']--; |
|
| 2714 | + } |
|
| 2579 | 2715 | } |
| 2580 | 2716 | $smcFunc['db_free_result']($request); |
| 2581 | 2717 | } |
@@ -2592,8 +2728,9 @@ discard block |
||
| 2592 | 2728 | global $sourcedir, $smcFunc; |
| 2593 | 2729 | |
| 2594 | 2730 | loadLanguage('Post'); |
| 2595 | - if (!isset($_REQUEST['xml'])) |
|
| 2596 | - loadTemplate('Post'); |
|
| 2731 | + if (!isset($_REQUEST['xml'])) { |
|
| 2732 | + loadTemplate('Post'); |
|
| 2733 | + } |
|
| 2597 | 2734 | |
| 2598 | 2735 | include_once($sourcedir . '/Subs-Post.php'); |
| 2599 | 2736 | |
@@ -2624,8 +2761,9 @@ discard block |
||
| 2624 | 2761 | $smcFunc['db_free_result']($request); |
| 2625 | 2762 | |
| 2626 | 2763 | $context['sub_template'] = 'quotefast'; |
| 2627 | - if (!empty($row)) |
|
| 2628 | - $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
| 2764 | + if (!empty($row)) { |
|
| 2765 | + $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
| 2766 | + } |
|
| 2629 | 2767 | |
| 2630 | 2768 | if (!empty($can_view_post)) |
| 2631 | 2769 | { |
@@ -2658,8 +2796,9 @@ discard block |
||
| 2658 | 2796 | } |
| 2659 | 2797 | |
| 2660 | 2798 | // Remove any nested quotes. |
| 2661 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
| 2662 | - $row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']); |
|
| 2799 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
| 2800 | + $row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']); |
|
| 2801 | + } |
|
| 2663 | 2802 | |
| 2664 | 2803 | $lb = "\n"; |
| 2665 | 2804 | |
@@ -2685,14 +2824,14 @@ discard block |
||
| 2685 | 2824 | 'time' => '', |
| 2686 | 2825 | ), |
| 2687 | 2826 | ); |
| 2688 | - } |
|
| 2689 | - else |
|
| 2690 | - $context['quote'] = array( |
|
| 2827 | + } else { |
|
| 2828 | + $context['quote'] = array( |
|
| 2691 | 2829 | 'xml' => '', |
| 2692 | 2830 | 'mozilla' => '', |
| 2693 | 2831 | 'text' => '', |
| 2694 | 2832 | ); |
| 2695 | -} |
|
| 2833 | + } |
|
| 2834 | + } |
|
| 2696 | 2835 | |
| 2697 | 2836 | /** |
| 2698 | 2837 | * Used to edit the body or subject of a message inline |
@@ -2704,8 +2843,9 @@ discard block |
||
| 2704 | 2843 | global $user_info, $context, $smcFunc, $language, $board_info; |
| 2705 | 2844 | |
| 2706 | 2845 | // We have to have a topic! |
| 2707 | - if (empty($topic)) |
|
| 2708 | - obExit(false); |
|
| 2846 | + if (empty($topic)) { |
|
| 2847 | + obExit(false); |
|
| 2848 | + } |
|
| 2709 | 2849 | |
| 2710 | 2850 | checkSession('get'); |
| 2711 | 2851 | require_once($sourcedir . '/Subs-Post.php'); |
@@ -2731,31 +2871,35 @@ discard block |
||
| 2731 | 2871 | 'guest_id' => 0, |
| 2732 | 2872 | ) |
| 2733 | 2873 | ); |
| 2734 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 2735 | - fatal_lang_error('no_board', false); |
|
| 2874 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 2875 | + fatal_lang_error('no_board', false); |
|
| 2876 | + } |
|
| 2736 | 2877 | $row = $smcFunc['db_fetch_assoc']($request); |
| 2737 | 2878 | $smcFunc['db_free_result']($request); |
| 2738 | 2879 | |
| 2739 | 2880 | // Change either body or subject requires permissions to modify messages. |
| 2740 | 2881 | if (isset($_POST['message']) || isset($_POST['subject']) || isset($_REQUEST['icon'])) |
| 2741 | 2882 | { |
| 2742 | - if (!empty($row['locked'])) |
|
| 2743 | - isAllowedTo('moderate_board'); |
|
| 2883 | + if (!empty($row['locked'])) { |
|
| 2884 | + isAllowedTo('moderate_board'); |
|
| 2885 | + } |
|
| 2744 | 2886 | |
| 2745 | 2887 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
| 2746 | 2888 | { |
| 2747 | - if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
| 2748 | - fatal_lang_error('modify_post_time_passed', false); |
|
| 2749 | - elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
|
| 2750 | - isAllowedTo('modify_replies'); |
|
| 2751 | - else |
|
| 2752 | - isAllowedTo('modify_own'); |
|
| 2889 | + if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
| 2890 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 2891 | + } elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
| 2892 | + isAllowedTo('modify_replies'); |
|
| 2893 | + } else { |
|
| 2894 | + isAllowedTo('modify_own'); |
|
| 2895 | + } |
|
| 2753 | 2896 | } |
| 2754 | 2897 | // Otherwise, they're locked out; someone who can modify the replies is needed. |
| 2755 | - elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 2756 | - isAllowedTo('modify_replies'); |
|
| 2757 | - else |
|
| 2758 | - isAllowedTo('modify_any'); |
|
| 2898 | + elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
| 2899 | + isAllowedTo('modify_replies'); |
|
| 2900 | + } else { |
|
| 2901 | + isAllowedTo('modify_any'); |
|
| 2902 | + } |
|
| 2759 | 2903 | |
| 2760 | 2904 | // Only log this action if it wasn't your message. |
| 2761 | 2905 | $moderationAction = $row['id_member'] != $user_info['id']; |
@@ -2767,10 +2911,10 @@ discard block |
||
| 2767 | 2911 | $_POST['subject'] = strtr($smcFunc['htmlspecialchars']($_POST['subject']), array("\r" => '', "\n" => '', "\t" => '')); |
| 2768 | 2912 | |
| 2769 | 2913 | // Maximum number of characters. |
| 2770 | - if ($smcFunc['strlen']($_POST['subject']) > 100) |
|
| 2771 | - $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
| 2772 | - } |
|
| 2773 | - elseif (isset($_POST['subject'])) |
|
| 2914 | + if ($smcFunc['strlen']($_POST['subject']) > 100) { |
|
| 2915 | + $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
| 2916 | + } |
|
| 2917 | + } elseif (isset($_POST['subject'])) |
|
| 2774 | 2918 | { |
| 2775 | 2919 | $post_errors[] = 'no_subject'; |
| 2776 | 2920 | unset($_POST['subject']); |
@@ -2782,13 +2926,11 @@ discard block |
||
| 2782 | 2926 | { |
| 2783 | 2927 | $post_errors[] = 'no_message'; |
| 2784 | 2928 | unset($_POST['message']); |
| 2785 | - } |
|
| 2786 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
| 2929 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
| 2787 | 2930 | { |
| 2788 | 2931 | $post_errors[] = 'long_message'; |
| 2789 | 2932 | unset($_POST['message']); |
| 2790 | - } |
|
| 2791 | - else |
|
| 2933 | + } else |
|
| 2792 | 2934 | { |
| 2793 | 2935 | $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES); |
| 2794 | 2936 | |
@@ -2804,31 +2946,34 @@ discard block |
||
| 2804 | 2946 | |
| 2805 | 2947 | if (isset($_POST['lock'])) |
| 2806 | 2948 | { |
| 2807 | - if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) |
|
| 2808 | - unset($_POST['lock']); |
|
| 2809 | - elseif (!allowedTo('lock_any')) |
|
| 2949 | + if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) { |
|
| 2950 | + unset($_POST['lock']); |
|
| 2951 | + } elseif (!allowedTo('lock_any')) |
|
| 2810 | 2952 | { |
| 2811 | - if ($row['locked'] == 1) |
|
| 2812 | - unset($_POST['lock']); |
|
| 2813 | - else |
|
| 2814 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 2953 | + if ($row['locked'] == 1) { |
|
| 2954 | + unset($_POST['lock']); |
|
| 2955 | + } else { |
|
| 2956 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 2957 | + } |
|
| 2958 | + } elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) { |
|
| 2959 | + unset($_POST['lock']); |
|
| 2960 | + } else { |
|
| 2961 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
|
| 2815 | 2962 | } |
| 2816 | - elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) |
|
| 2817 | - unset($_POST['lock']); |
|
| 2818 | - else |
|
| 2819 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
|
| 2820 | 2963 | } |
| 2821 | 2964 | |
| 2822 | - if (isset($_POST['sticky']) && !allowedTo('make_sticky')) |
|
| 2823 | - unset($_POST['sticky']); |
|
| 2965 | + if (isset($_POST['sticky']) && !allowedTo('make_sticky')) { |
|
| 2966 | + unset($_POST['sticky']); |
|
| 2967 | + } |
|
| 2824 | 2968 | |
| 2825 | 2969 | if (isset($_POST['modify_reason'])) |
| 2826 | 2970 | { |
| 2827 | 2971 | $_POST['modify_reason'] = strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => '')); |
| 2828 | 2972 | |
| 2829 | 2973 | // Maximum number of characters. |
| 2830 | - if ($smcFunc['strlen']($_POST['modify_reason']) > 100) |
|
| 2831 | - $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
| 2974 | + if ($smcFunc['strlen']($_POST['modify_reason']) > 100) { |
|
| 2975 | + $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
| 2976 | + } |
|
| 2832 | 2977 | } |
| 2833 | 2978 | |
| 2834 | 2979 | if (empty($post_errors)) |
@@ -2865,8 +3010,9 @@ discard block |
||
| 2865 | 3010 | } |
| 2866 | 3011 | } |
| 2867 | 3012 | // If nothing was changed there's no need to add an entry to the moderation log. |
| 2868 | - else |
|
| 2869 | - $moderationAction = false; |
|
| 3013 | + else { |
|
| 3014 | + $moderationAction = false; |
|
| 3015 | + } |
|
| 2870 | 3016 | |
| 2871 | 3017 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
| 2872 | 3018 | |
@@ -2884,9 +3030,9 @@ discard block |
||
| 2884 | 3030 | // Get the proper (default language) response prefix first. |
| 2885 | 3031 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
| 2886 | 3032 | { |
| 2887 | - if ($language === $user_info['language']) |
|
| 2888 | - $context['response_prefix'] = $txt['response_prefix']; |
|
| 2889 | - else |
|
| 3033 | + if ($language === $user_info['language']) { |
|
| 3034 | + $context['response_prefix'] = $txt['response_prefix']; |
|
| 3035 | + } else |
|
| 2890 | 3036 | { |
| 2891 | 3037 | loadLanguage('index', $language, false); |
| 2892 | 3038 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -2908,8 +3054,9 @@ discard block |
||
| 2908 | 3054 | ); |
| 2909 | 3055 | } |
| 2910 | 3056 | |
| 2911 | - if (!empty($moderationAction)) |
|
| 2912 | - logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
| 3057 | + if (!empty($moderationAction)) { |
|
| 3058 | + logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
| 3059 | + } |
|
| 2913 | 3060 | } |
| 2914 | 3061 | |
| 2915 | 3062 | if (isset($_REQUEST['xml'])) |
@@ -2950,8 +3097,7 @@ discard block |
||
| 2950 | 3097 | ); |
| 2951 | 3098 | |
| 2952 | 3099 | censorText($context['message']['subject']); |
| 2953 | - } |
|
| 2954 | - else |
|
| 3100 | + } else |
|
| 2955 | 3101 | { |
| 2956 | 3102 | $context['message'] = array( |
| 2957 | 3103 | 'id' => $row['id_msg'], |
@@ -2963,15 +3109,16 @@ discard block |
||
| 2963 | 3109 | loadLanguage('Errors'); |
| 2964 | 3110 | foreach ($post_errors as $post_error) |
| 2965 | 3111 | { |
| 2966 | - if ($post_error == 'long_message') |
|
| 2967 | - $context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']); |
|
| 2968 | - else |
|
| 2969 | - $context['message']['errors'][] = $txt['error_' . $post_error]; |
|
| 3112 | + if ($post_error == 'long_message') { |
|
| 3113 | + $context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']); |
|
| 3114 | + } else { |
|
| 3115 | + $context['message']['errors'][] = $txt['error_' . $post_error]; |
|
| 3116 | + } |
|
| 2970 | 3117 | } |
| 2971 | 3118 | } |
| 3119 | + } else { |
|
| 3120 | + obExit(false); |
|
| 3121 | + } |
|
| 2972 | 3122 | } |
| 2973 | - else |
|
| 2974 | - obExit(false); |
|
| 2975 | -} |
|
| 2976 | 3123 | |
| 2977 | 3124 | ?> |
| 2978 | 3125 | \ No newline at end of file |