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