Completed
Push — release-2.1 ( 3a4586...29f159 )
by Michael
21:25 queued 13:06
created
Sources/Post.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -256,8 +256,8 @@  discard block
 block discarded – undo
256 256
 			$time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]);
257 257
 
258 258
 		$js_time_string = str_replace(
259
-			array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r',      '%R',  '%S', '%T',    '%X'),
260
-			array('H',  'G',  'h',  'g',  'i',  'A',  'a',  'h:i:s A', 'H:i', 's',  'H:i:s', 'H:i:s'),
259
+			array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'),
260
+			array('H', 'G', 'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'H:i:s'),
261 261
 			$time_string
262 262
 		);
263 263
 
@@ -1306,14 +1306,14 @@  discard block
 block discarded – undo
1306 1306
 	if (isset($context['name']) && isset($context['email']))
1307 1307
 	{
1308 1308
 		$context['posting_fields']['guestname'] = array(
1309
-			'dt' => '<span id="caption_guestname"' .  (isset($context['post_error']['long_name']) || isset($context['post_error']['no_name']) || isset($context['post_error']['bad_name']) ? ' class="error"' : '') . '>' . $txt['name'] . '</span>',
1309
+			'dt' => '<span id="caption_guestname"' . (isset($context['post_error']['long_name']) || isset($context['post_error']['no_name']) || isset($context['post_error']['bad_name']) ? ' class="error"' : '') . '>' . $txt['name'] . '</span>',
1310 1310
 			'dd' => '<input type="text" name="guestname" size="25" value="' . $context['name'] . '" class="input_text" required>',
1311 1311
 		);
1312 1312
 
1313 1313
 		if (empty($modSettings['guest_post_no_email']))
1314 1314
 		{
1315 1315
 			$context['posting_fields']['email'] = array(
1316
-				'dt' => '<span id="caption_email"' .  (isset($context['post_error']['no_email']) || isset($context['post_error']['bad_email']) ? ' class="error"' : '') . '>' . $txt['email'] . '</span>',
1316
+				'dt' => '<span id="caption_email"' . (isset($context['post_error']['no_email']) || isset($context['post_error']['bad_email']) ? ' class="error"' : '') . '>' . $txt['email'] . '</span>',
1317 1317
 				'dd' => '<input type="email" name="email" size="25" value="' . $context['email'] . '" class="input_text" required>',
1318 1318
 			);
1319 1319
 		}
Please login to merge, or discard this patch.
Braces   +659 added lines, -511 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 3
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * Handles showing the post screen, loading the post to be modified, and loading any post quoted.
@@ -35,12 +36,14 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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(']]>' => ']]]]><![CDATA[>'));
583
+			}
560 584
 		}
561 585
 
562 586
 		// Set up the checkboxes.
@@ -595,29 +619,32 @@  discard block
 block discarded – undo
595 619
 			);
596 620
 			// The message they were trying to edit was most likely deleted.
597 621
 			// @todo Change this error message?
598
-			if ($smcFunc['db_num_rows']($request) == 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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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', '&lt;br /&gt;<br>', "$m[1]") . '[/html]';
893
+					}
858 894
 						}, $parts[$i]);
859 895
 				}
860 896
 				$form_message = implode('', $parts);
@@ -863,8 +899,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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('"', '<', '>', '&nbsp;'), array('&quot;', '&lt;', '&gt;', ' '), $form_message);
@@ -1159,8 +1211,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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.
@@ -1341,8 +1398,9 @@  discard block
 block discarded – undo
1341 1398
 
1342 1399
 
1343 1400
 	// Finally, load the template.
1344
-	if (!isset($_REQUEST['xml']))
1345
-		loadTemplate('Post');
1401
+	if (!isset($_REQUEST['xml'])) {
1402
+			loadTemplate('Post');
1403
+	}
1346 1404
 
1347 1405
 	call_integration_hook('integrate_post_end');
1348 1406
 }
@@ -1363,13 +1421,14 @@  discard block
 block discarded – undo
1363 1421
 	// Sneaking off, are we?
1364 1422
 	if (empty($_POST) && empty($topic))
1365 1423
 	{
1366
-		if (empty($_SERVER['CONTENT_LENGTH']))
1367
-			redirectexit('action=post;board=' . $board . '.0');
1368
-		else
1369
-			fatal_lang_error('post_upload_error', false);
1424
+		if (empty($_SERVER['CONTENT_LENGTH'])) {
1425
+					redirectexit('action=post;board=' . $board . '.0');
1426
+		} else {
1427
+					fatal_lang_error('post_upload_error', false);
1428
+		}
1429
+	} elseif (empty($_POST) && !empty($topic)) {
1430
+			redirectexit('action=post;topic=' . $topic . '.0');
1370 1431
 	}
1371
-	elseif (empty($_POST) && !empty($topic))
1372
-		redirectexit('action=post;topic=' . $topic . '.0');
1373 1432
 
1374 1433
 	// No need!
1375 1434
 	$context['robot_no_index'] = true;
@@ -1381,8 +1440,9 @@  discard block
 block discarded – undo
1381 1440
 	$post_errors = array();
1382 1441
 
1383 1442
 	// If the session has timed out, let the user re-submit their form.
1384
-	if (checkSession('post', '', false) != '')
1385
-		$post_errors[] = 'session_timeout';
1443
+	if (checkSession('post', '', false) != '') {
1444
+			$post_errors[] = 'session_timeout';
1445
+	}
1386 1446
 
1387 1447
 	// Wrong verification code?
1388 1448
 	if (!$user_info['is_admin'] && !$user_info['is_mod'] && !empty($modSettings['posts_require_captcha']) && ($user_info['posts'] < $modSettings['posts_require_captcha'] || ($user_info['is_guest'] && $modSettings['posts_require_captcha'] == -1)))
@@ -1392,33 +1452,38 @@  discard block
 block discarded – undo
1392 1452
 			'id' => 'post',
1393 1453
 		);
1394 1454
 		$context['require_verification'] = create_control_verification($verificationOptions, true);
1395
-		if (is_array($context['require_verification']))
1396
-			$post_errors = array_merge($post_errors, $context['require_verification']);
1455
+		if (is_array($context['require_verification'])) {
1456
+					$post_errors = array_merge($post_errors, $context['require_verification']);
1457
+		}
1397 1458
 	}
1398 1459
 
1399 1460
 	require_once($sourcedir . '/Subs-Post.php');
1400 1461
 	loadLanguage('Post');
1401 1462
 
1402 1463
 	// Drafts enabled and needed?
1403
-	if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft'])))
1404
-		require_once($sourcedir . '/Drafts.php');
1464
+	if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) {
1465
+			require_once($sourcedir . '/Drafts.php');
1466
+	}
1405 1467
 
1406 1468
 	// First check to see if they are trying to delete any current attachments.
1407 1469
 	if (isset($_POST['attach_del']))
1408 1470
 	{
1409 1471
 		$keep_temp = array();
1410 1472
 		$keep_ids = array();
1411
-		foreach ($_POST['attach_del'] as $dummy)
1412
-			if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false)
1473
+		foreach ($_POST['attach_del'] as $dummy) {
1474
+					if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false)
1413 1475
 				$keep_temp[] = $dummy;
1414
-			else
1415
-				$keep_ids[] = (int) $dummy;
1476
+		}
1477
+			else {
1478
+							$keep_ids[] = (int) $dummy;
1479
+			}
1416 1480
 
1417
-		if (isset($_SESSION['temp_attachments']))
1418
-			foreach ($_SESSION['temp_attachments'] as $attachID => $attachment)
1481
+		if (isset($_SESSION['temp_attachments'])) {
1482
+					foreach ($_SESSION['temp_attachments'] as $attachID => $attachment)
1419 1483
 			{
1420 1484
 				if ((isset($_SESSION['temp_attachments']['post']['files'], $attachment['name']) && in_array($attachment['name'], $_SESSION['temp_attachments']['post']['files'])) || in_array($attachID, $keep_temp) || strpos($attachID, 'post_tmp_' . $user_info['id']) === false)
1421 1485
 					continue;
1486
+		}
1422 1487
 
1423 1488
 				unset($_SESSION['temp_attachments'][$attachID]);
1424 1489
 				unlink($attachment['tmp_name']);
@@ -1460,24 +1525,28 @@  discard block
 block discarded – undo
1460 1525
 		$smcFunc['db_free_result']($request);
1461 1526
 
1462 1527
 		// Though the topic should be there, it might have vanished.
1463
-		if (!is_array($topic_info))
1464
-			fatal_lang_error('topic_doesnt_exist', 404);
1528
+		if (!is_array($topic_info)) {
1529
+					fatal_lang_error('topic_doesnt_exist', 404);
1530
+		}
1465 1531
 
1466 1532
 		// Did this topic suddenly move? Just checking...
1467
-		if ($topic_info['id_board'] != $board)
1468
-			fatal_lang_error('not_a_topic');
1533
+		if ($topic_info['id_board'] != $board) {
1534
+					fatal_lang_error('not_a_topic');
1535
+		}
1469 1536
 	}
1470 1537
 
1471 1538
 	// Replying to a topic?
1472 1539
 	if (!empty($topic) && !isset($_REQUEST['msg']))
1473 1540
 	{
1474 1541
 		// Don't allow a post if it's locked.
1475
-		if ($topic_info['locked'] != 0 && !allowedTo('moderate_board'))
1476
-			fatal_lang_error('topic_locked', false);
1542
+		if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) {
1543
+					fatal_lang_error('topic_locked', false);
1544
+		}
1477 1545
 
1478 1546
 		// Sorry, multiple polls aren't allowed... yet.  You should stop giving me ideas :P.
1479
-		if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0)
1480
-			unset($_REQUEST['poll']);
1547
+		if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) {
1548
+					unset($_REQUEST['poll']);
1549
+		}
1481 1550
 
1482 1551
 		// Do the permissions and approval stuff...
1483 1552
 		$becomesApproved = true;
@@ -1493,44 +1562,43 @@  discard block
 block discarded – undo
1493 1562
 
1494 1563
 			// Set a nice session var...
1495 1564
 			$_SESSION['becomesUnapproved'] = true;
1496
-		}
1497
-
1498
-		elseif ($topic_info['id_member_started'] != $user_info['id'])
1565
+		} elseif ($topic_info['id_member_started'] != $user_info['id'])
1499 1566
 		{
1500
-			if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any'))
1501
-				$becomesApproved = false;
1502
-
1503
-			else
1504
-				isAllowedTo('post_reply_any');
1505
-		}
1506
-		elseif (!allowedTo('post_reply_any'))
1567
+			if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) {
1568
+							$becomesApproved = false;
1569
+			} else {
1570
+							isAllowedTo('post_reply_any');
1571
+			}
1572
+		} elseif (!allowedTo('post_reply_any'))
1507 1573
 		{
1508
-			if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own'))
1509
-				$becomesApproved = false;
1510
-
1511
-			else
1512
-				isAllowedTo('post_reply_own');
1574
+			if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) {
1575
+							$becomesApproved = false;
1576
+			} else {
1577
+							isAllowedTo('post_reply_own');
1578
+			}
1513 1579
 		}
1514 1580
 
1515 1581
 		if (isset($_POST['lock']))
1516 1582
 		{
1517 1583
 			// Nothing is changed to the lock.
1518
-			if ((empty($topic_info['locked']) && empty($_POST['lock'])) || (!empty($_POST['lock']) && !empty($topic_info['locked'])))
1519
-				unset($_POST['lock']);
1584
+			if ((empty($topic_info['locked']) && empty($_POST['lock'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) {
1585
+							unset($_POST['lock']);
1586
+			}
1520 1587
 
1521 1588
 			// You're have no permission to lock this topic.
1522
-			elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started']))
1523
-				unset($_POST['lock']);
1589
+			elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) {
1590
+							unset($_POST['lock']);
1591
+			}
1524 1592
 
1525 1593
 			// You are allowed to (un)lock your own topic only.
1526 1594
 			elseif (!allowedTo('lock_any'))
1527 1595
 			{
1528 1596
 				// You cannot override a moderator lock.
1529
-				if ($topic_info['locked'] == 1)
1530
-					unset($_POST['lock']);
1531
-
1532
-				else
1533
-					$_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
1597
+				if ($topic_info['locked'] == 1) {
1598
+									unset($_POST['lock']);
1599
+				} else {
1600
+									$_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
1601
+				}
1534 1602
 			}
1535 1603
 			// Hail mighty moderator, (un)lock this topic immediately.
1536 1604
 			else
@@ -1538,19 +1606,21 @@  discard block
 block discarded – undo
1538 1606
 				$_POST['lock'] = empty($_POST['lock']) ? 0 : 1;
1539 1607
 
1540 1608
 				// Did someone (un)lock this while you were posting?
1541
-				if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked'])
1542
-					$post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked';
1609
+				if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) {
1610
+									$post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked';
1611
+				}
1543 1612
 			}
1544 1613
 		}
1545 1614
 
1546 1615
 		// So you wanna (un)sticky this...let's see.
1547
-		if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky')))
1548
-			unset($_POST['sticky']);
1549
-		elseif (isset($_POST['sticky']))
1616
+		if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) {
1617
+					unset($_POST['sticky']);
1618
+		} elseif (isset($_POST['sticky']))
1550 1619
 		{
1551 1620
 			// Did someone (un)sticky this while you were posting?
1552
-			if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky'])
1553
-				$post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky';
1621
+			if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) {
1622
+							$post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky';
1623
+			}
1554 1624
 		}
1555 1625
 
1556 1626
 		// If drafts are enabled, then pass this off
@@ -1577,26 +1647,31 @@  discard block
 block discarded – undo
1577 1647
 
1578 1648
 		// Do like, the permissions, for safety and stuff...
1579 1649
 		$becomesApproved = true;
1580
-		if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics'))
1581
-			$becomesApproved = false;
1582
-		else
1583
-			isAllowedTo('post_new');
1650
+		if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) {
1651
+					$becomesApproved = false;
1652
+		} else {
1653
+					isAllowedTo('post_new');
1654
+		}
1584 1655
 
1585 1656
 		if (isset($_POST['lock']))
1586 1657
 		{
1587 1658
 			// New topics are by default not locked.
1588
-			if (empty($_POST['lock']))
1589
-				unset($_POST['lock']);
1659
+			if (empty($_POST['lock'])) {
1660
+							unset($_POST['lock']);
1661
+			}
1590 1662
 			// Besides, you need permission.
1591
-			elseif (!allowedTo(array('lock_any', 'lock_own')))
1592
-				unset($_POST['lock']);
1663
+			elseif (!allowedTo(array('lock_any', 'lock_own'))) {
1664
+							unset($_POST['lock']);
1665
+			}
1593 1666
 			// A moderator-lock (1) can override a user-lock (2).
1594
-			else
1595
-				$_POST['lock'] = allowedTo('lock_any') ? 1 : 2;
1667
+			else {
1668
+							$_POST['lock'] = allowedTo('lock_any') ? 1 : 2;
1669
+			}
1596 1670
 		}
1597 1671
 
1598
-		if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky')))
1599
-			unset($_POST['sticky']);
1672
+		if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) {
1673
+					unset($_POST['sticky']);
1674
+		}
1600 1675
 
1601 1676
 		// Saving your new topic as a draft first?
1602 1677
 		if (!empty($modSettings['drafts_post_enabled']) && isset($_POST['save_draft']))
@@ -1621,31 +1696,37 @@  discard block
 block discarded – undo
1621 1696
 				'id_msg' => $_REQUEST['msg'],
1622 1697
 			)
1623 1698
 		);
1624
-		if ($smcFunc['db_num_rows']($request) == 0)
1625
-			fatal_lang_error('cant_find_messages', false);
1699
+		if ($smcFunc['db_num_rows']($request) == 0) {
1700
+					fatal_lang_error('cant_find_messages', false);
1701
+		}
1626 1702
 		$row = $smcFunc['db_fetch_assoc']($request);
1627 1703
 		$smcFunc['db_free_result']($request);
1628 1704
 
1629
-		if (!empty($topic_info['locked']) && !allowedTo('moderate_board'))
1630
-			fatal_lang_error('topic_locked', false);
1705
+		if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) {
1706
+					fatal_lang_error('topic_locked', false);
1707
+		}
1631 1708
 
1632 1709
 		if (isset($_POST['lock']))
1633 1710
 		{
1634 1711
 			// Nothing changes to the lock status.
1635
-			if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked'])))
1636
-				unset($_POST['lock']);
1712
+			if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) {
1713
+							unset($_POST['lock']);
1714
+			}
1637 1715
 			// You're simply not allowed to (un)lock this.
1638
-			elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started']))
1639
-				unset($_POST['lock']);
1716
+			elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) {
1717
+							unset($_POST['lock']);
1718
+			}
1640 1719
 			// You're only allowed to lock your own topics.
1641 1720
 			elseif (!allowedTo('lock_any'))
1642 1721
 			{
1643 1722
 				// You're not allowed to break a moderator's lock.
1644
-				if ($topic_info['locked'] == 1)
1645
-					unset($_POST['lock']);
1723
+				if ($topic_info['locked'] == 1) {
1724
+									unset($_POST['lock']);
1725
+				}
1646 1726
 				// Lock it with a soft lock or unlock it.
1647
-				else
1648
-					$_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
1727
+				else {
1728
+									$_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
1729
+				}
1649 1730
 			}
1650 1731
 			// You must be the moderator.
1651 1732
 			else
@@ -1653,44 +1734,46 @@  discard block
 block discarded – undo
1653 1734
 				$_POST['lock'] = empty($_POST['lock']) ? 0 : 1;
1654 1735
 
1655 1736
 				// Did someone (un)lock this while you were posting?
1656
-				if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked'])
1657
-					$post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked';
1737
+				if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) {
1738
+									$post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked';
1739
+				}
1658 1740
 			}
1659 1741
 		}
1660 1742
 
1661 1743
 		// Change the sticky status of this topic?
1662
-		if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky']))
1663
-			unset($_POST['sticky']);
1664
-		elseif (isset($_POST['sticky']))
1744
+		if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) {
1745
+					unset($_POST['sticky']);
1746
+		} elseif (isset($_POST['sticky']))
1665 1747
 		{
1666 1748
 			// Did someone (un)sticky this while you were posting?
1667
-			if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky'])
1668
-				$post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied';
1749
+			if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) {
1750
+							$post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied';
1751
+			}
1669 1752
 		}
1670 1753
 
1671 1754
 		if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any'))
1672 1755
 		{
1673
-			if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time())
1674
-				fatal_lang_error('modify_post_time_passed', false);
1675
-			elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own'))
1676
-				isAllowedTo('modify_replies');
1677
-			else
1678
-				isAllowedTo('modify_own');
1679
-		}
1680
-		elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any'))
1756
+			if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) {
1757
+							fatal_lang_error('modify_post_time_passed', false);
1758
+			} elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) {
1759
+							isAllowedTo('modify_replies');
1760
+			} else {
1761
+							isAllowedTo('modify_own');
1762
+			}
1763
+		} elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any'))
1681 1764
 		{
1682 1765
 			isAllowedTo('modify_replies');
1683 1766
 
1684 1767
 			// If you're modifying a reply, I say it better be logged...
1685 1768
 			$moderationAction = true;
1686
-		}
1687
-		else
1769
+		} else
1688 1770
 		{
1689 1771
 			isAllowedTo('modify_any');
1690 1772
 
1691 1773
 			// Log it, assuming you're not modifying your own post.
1692
-			if ($row['id_member'] != $user_info['id'])
1693
-				$moderationAction = true;
1774
+			if ($row['id_member'] != $user_info['id']) {
1775
+							$moderationAction = true;
1776
+			}
1694 1777
 		}
1695 1778
 
1696 1779
 		// If drafts are enabled, then lets send this off to save
@@ -1727,20 +1810,24 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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>&nbsp;</dt>';
1967 2081
 			}
1968
-			else
1969
-				$attach_errors[] = '<dt>&nbsp;</dt>';
1970 2082
 
1971 2083
 			if (!empty($attachmentOptions['errors']))
1972 2084
 			{
@@ -1978,14 +2090,16 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
2309 2435
 	global $txt, $context, $topic, $board, $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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
Please login to merge, or discard this patch.
Themes/default/Post.template.php 2 patches
Braces   +89 added lines, -61 removed lines patch added patch discarded remove patch
@@ -22,22 +22,24 @@  discard block
 block discarded – undo
22 22
 		<script>';
23 23
 
24 24
 	// When using Go Back due to fatal_error, allow the form to be re-submitted with changes.
25
-	if (isBrowser('is_firefox'))
26
-		echo '
25
+	if (isBrowser('is_firefox')) {
26
+			echo '
27 27
 			window.addEventListener("pageshow", reActivate, false);';
28
+	}
28 29
 
29 30
 	// Start with message icons - and any missing from this theme.
30 31
 	echo '
31 32
 			var icon_urls = {';
32
-	foreach ($context['icons'] as $icon)
33
-		echo '
33
+	foreach ($context['icons'] as $icon) {
34
+			echo '
34 35
 				\'', $icon['value'], '\': \'', $icon['url'], '\'', $icon['is_last'] ? '' : ',';
36
+	}
35 37
 	echo '
36 38
 			};';
37 39
 
38 40
 	// If this is a poll - use some javascript to ensure the user doesn't create a poll with illegal option combinations.
39
-	if ($context['make_poll'])
40
-		echo '
41
+	if ($context['make_poll']) {
42
+			echo '
41 43
 			var pollOptionNum = 0, pollTabIndex;
42 44
 			var pollOptionId = ', $context['last_choice_id'], ';
43 45
 			function addPollOption()
@@ -56,11 +58,13 @@  discard block
 block discarded – undo
56 58
 
57 59
 				setOuterHTML(document.getElementById(\'pollMoreOptions\'), ', JavaScriptEscape('<dt><label for="options-'), ' + pollOptionId + ', JavaScriptEscape('">' . $txt['option'] . ' '), ' + pollOptionNum + ', JavaScriptEscape('</label>:</dt><dd><input type="text" name="options['), ' + pollOptionId + ', JavaScriptEscape(']" id="options-'), ' + pollOptionId + ', JavaScriptEscape('" value="" size="80" maxlength="255" tabindex="'), ' + pollTabIndex + ', JavaScriptEscape('" class="input_text"></dd><p id="pollMoreOptions"></p>'), ');
58 60
 			}';
61
+	}
59 62
 
60 63
 	// If we are making a calendar event we want to ensure we show the current days in a month etc... this is done here.
61
-	if ($context['make_event'])
62
-		echo '
64
+	if ($context['make_event']) {
65
+			echo '
63 66
 			var monthLength = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];';
67
+	}
64 68
 
65 69
 	// End of the javascript, start the form and display the link tree.
66 70
 	echo '
@@ -80,9 +84,10 @@  discard block
 block discarded – undo
80 84
 				</div>
81 85
 			</div><br>';
82 86
 
83
-	if ($context['make_event'] && (!$context['event']['new'] || !empty($context['current_board'])))
84
-		echo '
87
+	if ($context['make_event'] && (!$context['event']['new'] || !empty($context['current_board']))) {
88
+			echo '
85 89
 			<input type="hidden" name="eventid" value="', $context['event']['id'], '">';
90
+	}
86 91
 
87 92
 	// Start the main table.
88 93
 	echo '
@@ -117,18 +122,20 @@  discard block
 block discarded – undo
117 122
 	}
118 123
 
119 124
 	// If it's locked, show a message to warn the replier.
120
-	if (!empty($context['locked']))
121
-	echo '
125
+	if (!empty($context['locked'])) {
126
+		echo '
122 127
 					<p class="errorbox">
123 128
 						', $txt['topic_locked_no_reply'], '
124 129
 					</p>';
130
+	}
125 131
 
126
-	if (!empty($modSettings['drafts_post_enabled']))
127
-		echo '
132
+	if (!empty($modSettings['drafts_post_enabled'])) {
133
+			echo '
128 134
 					<div id="draft_section" class="infobox"', isset($context['draft_saved']) ? '' : ' style="display: none;"', '>',
129 135
 						sprintf($txt['draft_saved'], $scripturl . '?action=profile;u=' . $context['user']['id'] . ';area=showdrafts'), '
130 136
 						', (!empty($modSettings['drafts_keep_days']) ? ' <strong>' . sprintf($txt['draft_save_warning'], $modSettings['drafts_keep_days']) . '</strong>' : ''), '
131 137
 					</div>';
138
+	}
132 139
 
133 140
 	// The post header... important stuff
134 141
 	echo '
@@ -180,9 +187,10 @@  discard block
 block discarded – undo
180 187
 				{
181 188
 					echo '
182 189
 										<optgroup label="', $category['name'], '">';
183
-					foreach ($category['boards'] as $board)
184
-						echo '
190
+					foreach ($category['boards'] as $board) {
191
+											echo '
185 192
 											<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=&gt;' : '', ' ', $board['name'], '&nbsp;</option>';
193
+					}
186 194
 					echo '
187 195
 										</optgroup>';
188 196
 				}
@@ -218,9 +226,10 @@  discard block
 block discarded – undo
218 226
 									<span class="label">', $txt['calendar_timezone'], '</span>
219 227
 									<select name="tz" id="tz"', !empty($context['event']['allday']) ? ' disabled' : '', '>';
220 228
 
221
-			foreach ($context['all_timezones'] as $tz => $tzname)
222
-				echo '
229
+			foreach ($context['all_timezones'] as $tz => $tzname) {
230
+							echo '
223 231
 										<option value="', $tz, '"', $tz == $context['event']['tz'] ? ' selected' : '', '>', $tzname, '</option>';
232
+			}
224 233
 
225 234
 			echo '
226 235
 									</select>
@@ -286,14 +295,15 @@  discard block
 block discarded – undo
286 295
 									<input type="checkbox" id="poll_change_vote" name="poll_change_vote"', !empty($context['poll']['change_vote']) ? ' checked' : '', ' class="input_check">
287 296
 								</dd>';
288 297
 
289
-		if ($context['poll_options']['guest_vote_enabled'])
290
-			echo '
298
+		if ($context['poll_options']['guest_vote_enabled']) {
299
+					echo '
291 300
 								<dt>
292 301
 									<label for="poll_guest_vote">', $txt['poll_guest_vote'], ':</label>
293 302
 								</dt>
294 303
 								<dd>
295 304
 									<input type="checkbox" id="poll_guest_vote" name="poll_guest_vote"', !empty($context['poll_options']['guest_vote']) ? ' checked' : '', ' class="input_check">
296 305
 								</dd>';
306
+		}
297 307
 
298 308
 		echo '
299 309
 								<dt>
@@ -314,8 +324,8 @@  discard block
 block discarded – undo
314 324
 					', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message');
315 325
 
316 326
 	// If we're editing and displaying edit details, show a box where they can say why
317
-	if (isset($context['editing']) && $modSettings['show_modify'])
318
-		echo '
327
+	if (isset($context['editing']) && $modSettings['show_modify']) {
328
+			echo '
319 329
 					<dl>
320 330
 						<dt class="clear">
321 331
 							<span id="caption_edit_reason">', $txt['reason_for_edit'], ':</span>
@@ -324,20 +334,23 @@  discard block
 block discarded – undo
324 334
 							<input type="text" name="modify_reason"', isset($context['last_modified_reason']) ? ' value="' . $context['last_modified_reason'] . '"' : '', ' tabindex="', $context['tabindex']++, '" size="80" maxlength="80" class="input_text">
325 335
 						</dd>
326 336
 					</dl>';
337
+	}
327 338
 
328 339
 	// If this message has been edited in the past - display when it was.
329
-	if (isset($context['last_modified']))
330
-		echo '
340
+	if (isset($context['last_modified'])) {
341
+			echo '
331 342
 					<div class="padding smalltext">
332 343
 						', $context['last_modified_text'], '
333 344
 					</div>';
345
+	}
334 346
 
335 347
 	// If the admin has enabled the hiding of the additional options - show a link and image for it.
336
-	if (!empty($modSettings['additional_options_collapsable']))
337
-		echo '
348
+	if (!empty($modSettings['additional_options_collapsable'])) {
349
+			echo '
338 350
 					<div id="postAdditionalOptionsHeader">
339 351
 						<strong><a href="#" id="postMoreExpandLink"> ', $context['can_post_attachment'] ? $txt['post_additionalopt_attach'] : $txt['post_additionalopt'], '</a></strong>
340 352
 					</div>';
353
+	}
341 354
 
342 355
 	echo '
343 356
 					<div id="postAdditionalOptions">';
@@ -369,19 +382,21 @@  discard block
 block discarded – undo
369 382
 								<input type="hidden" name="attach_del[]" value="0">
370 383
 								', $txt['uncheck_unwatchd_attach'], ':
371 384
 							</dd>';
372
-		foreach ($context['current_attachments'] as $attachment)
373
-			echo '
385
+		foreach ($context['current_attachments'] as $attachment) {
386
+					echo '
374 387
 							<dd class="smalltext">
375 388
 								<label for="attachment_', $attachment['attachID'], '"><input type="checkbox" id="attachment_', $attachment['attachID'], '" name="attach_del[]" value="', $attachment['attachID'], '"', empty($attachment['unchecked']) ? ' checked' : '', ' class="input_check"> ', $attachment['name'], (empty($attachment['approved']) ? ' (' . $txt['awaiting_approval'] . ')' : ''),
376 389
 								!empty($modSettings['attachmentPostLimit']) || !empty($modSettings['attachmentSizeLimit']) ? sprintf($txt['attach_kb'], comma_format(round(max($attachment['size'], 1028) / 1028), 0)) : '', '</label>
377 390
 							</dd>';
391
+		}
378 392
 
379 393
 		echo '
380 394
 						</dl>';
381 395
 
382
-		if (!empty($context['files_in_session_warning']))
383
-			echo '
396
+		if (!empty($context['files_in_session_warning'])) {
397
+					echo '
384 398
 						<div class="smalltext">', $context['files_in_session_warning'], '</div>';
399
+		}
385 400
 	}
386 401
 
387 402
 	// Is the user allowed to post any additional ones? If so give them the boxes to do it!
@@ -434,8 +449,8 @@  discard block
 block discarded – undo
434 449
 								', empty($modSettings['attachmentSizeLimit']) ? '' : ('<input type="hidden" name="MAX_FILE_SIZE" value="' . $modSettings['attachmentSizeLimit'] * 1028 . '">');
435 450
 
436 451
 		// Show more boxes if they aren't approaching that limit.
437
-		if ($context['num_allowed_attachments'] > 1)
438
-			echo '
452
+		if ($context['num_allowed_attachments'] > 1) {
453
+					echo '
439 454
 										<script>
440 455
 											var allowed_attachments = ', $context['num_allowed_attachments'], ';
441 456
 											var current_attachment = 1;
@@ -456,9 +471,10 @@  discard block
 block discarded – undo
456 471
 									</div>
457 472
 								</div>
458 473
 							</dd>';
459
-		else
460
-			echo '
474
+		} else {
475
+					echo '
461 476
 							</dd>';
477
+		}
462 478
 
463 479
 		// Add any template changes for an alternative upload system here.
464 480
 		call_integration_hook('integrate_upload_template');
@@ -467,21 +483,25 @@  discard block
 block discarded – undo
467 483
 							<dd class="smalltext">';
468 484
 
469 485
 		// Show some useful information such as allowed extensions, maximum size and amount of attachments allowed.
470
-		if (!empty($modSettings['attachmentCheckExtensions']))
471
-			echo '
486
+		if (!empty($modSettings['attachmentCheckExtensions'])) {
487
+					echo '
472 488
 								', $txt['allowed_types'], ': ', $context['allowed_extensions'], '<br>';
489
+		}
473 490
 
474
-		if (!empty($context['attachment_restrictions']))
475
-			echo '
491
+		if (!empty($context['attachment_restrictions'])) {
492
+					echo '
476 493
 								', $txt['attach_restrictions'], ' ', implode(', ', $context['attachment_restrictions']), '<br>';
494
+		}
477 495
 
478
-		if ($context['num_allowed_attachments'] == 0)
479
-			echo '
496
+		if ($context['num_allowed_attachments'] == 0) {
497
+					echo '
480 498
 								', $txt['attach_limit_nag'], '<br>';
499
+		}
481 500
 
482
-		if (!$context['can_post_attachment_unapproved'])
483
-			echo '
501
+		if (!$context['can_post_attachment_unapproved']) {
502
+					echo '
484 503
 								<span class="alert">', $txt['attachment_requires_approval'], '</span>', '<br>';
504
+		}
485 505
 
486 506
 		echo '
487 507
 							</dd>
@@ -504,10 +524,11 @@  discard block
 block discarded – undo
504 524
 							<dt><strong>', $txt['subject'], '</strong></dt>
505 525
 							<dd><strong>', $txt['draft_saved_on'], '</strong></dd>';
506 526
 
507
-		foreach ($context['drafts'] as $draft)
508
-			echo '
527
+		foreach ($context['drafts'] as $draft) {
528
+					echo '
509 529
 							<dt>', $draft['link'], '</dt>
510 530
 							<dd>', $draft['poster_time'], '</dd>';
531
+		}
511 532
 		echo '
512 533
 						</dl>
513 534
 					</div>';
@@ -532,9 +553,10 @@  discard block
 block discarded – undo
532 553
 						', template_control_richedit_buttons($context['post_box_name']);
533 554
 
534 555
 	// Option to delete an event if user is editing one.
535
-	if ($context['make_event'] && !$context['event']['new'])
536
-		echo '
556
+	if ($context['make_event'] && !$context['event']['new']) {
557
+			echo '
537 558
 						<input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['event_delete_confirm'] ,'" class="button_submit you_sure">';
559
+	}
538 560
 
539 561
 	echo '
540 562
 					</span>
@@ -543,9 +565,10 @@  discard block
 block discarded – undo
543 565
 			<br class="clear">';
544 566
 
545 567
 	// Assuming this isn't a new topic pass across the last message id.
546
-	if (isset($context['topic_last_message']))
547
-		echo '
568
+	if (isset($context['topic_last_message'])) {
569
+			echo '
548 570
 			<input type="hidden" name="last_msg" value="', $context['topic_last_message'], '">';
571
+	}
549 572
 
550 573
 	echo '
551 574
 			<input type="hidden" name="additional_options" id="additional_options" value="', $context['show_additional_options'] ? '1' : '0', '">
@@ -687,9 +710,10 @@  discard block
 block discarded – undo
687 710
 
688 711
 						newPostsHTML += \'<div class="windowbg\' + (++reply_counter % 2 == 0 ? \'2\' : \'\') + \'"><div id="msg\' + newPosts[i].getAttribute("id") + \'"><div class="floatleft"><h5>', $txt['posted_by'], ': \' + newPosts[i].getElementsByTagName("poster")[0].firstChild.nodeValue + \'</h5><span class="smalltext">&#171;&nbsp;<strong>', $txt['on'], ':</strong> \' + newPosts[i].getElementsByTagName("time")[0].firstChild.nodeValue + \'&nbsp;&#187;</span> <span class="new_posts" id="image_new_\' + newPosts[i].getAttribute("id") + \'">', $txt['new'], '</span></div>\';';
689 712
 
690
-	if ($context['can_quote'])
691
-		echo '
713
+	if ($context['can_quote']) {
714
+			echo '
692 715
 						newPostsHTML += \'<ul class="quickbuttons" id="msg_\' + newPosts[i].getAttribute("id") + \'_quote"><li><a href="#postmodify" onclick="return insertQuoteFast(\\\'\' + newPosts[i].getAttribute("id") + \'\\\');" class="quote_button"><span>', $txt['quote'], '</span><\' + \'/a></li></ul>\';';
716
+	}
693 717
 
694 718
 	echo '
695 719
 						newPostsHTML += \'<br class="clear">\';
@@ -732,8 +756,8 @@  discard block
 block discarded – undo
732 756
 			}';
733 757
 
734 758
 	// Code for showing and hiding additional options.
735
-	if (!empty($modSettings['additional_options_collapsable']))
736
-		echo '
759
+	if (!empty($modSettings['additional_options_collapsable'])) {
760
+			echo '
737 761
 			var oSwapAdditionalOptions = new smc_Toggle({
738 762
 				bToggleEnabled: true,
739 763
 				bCurrentlyCollapsed: ', $context['show_additional_options'] ? 'false' : 'true', ',
@@ -761,10 +785,11 @@  discard block
 block discarded – undo
761 785
 					}
762 786
 				]
763 787
 			});';
788
+	}
764 789
 
765 790
 	// Code for showing and hiding drafts
766
-	if (!empty($context['drafts']))
767
-		echo '
791
+	if (!empty($context['drafts'])) {
792
+			echo '
768 793
 			var oSwapDraftOptions = new smc_Toggle({
769 794
 				bToggleEnabled: true,
770 795
 				bCurrentlyCollapsed: true,
@@ -786,6 +811,7 @@  discard block
 block discarded – undo
786 811
 					}
787 812
 				]
788 813
 			});';
814
+	}
789 815
 
790 816
 	echo '
791 817
 			var oEditorID = "', $context['post_box_name'] ,'";
@@ -806,8 +832,9 @@  discard block
 block discarded – undo
806 832
 		foreach ($context['previous_posts'] as $post)
807 833
 		{
808 834
 			$ignoring = false;
809
-			if (!empty($post['is_ignored']))
810
-				$ignored_posts[] = $ignoring = $post['id'];
835
+			if (!empty($post['is_ignored'])) {
836
+							$ignored_posts[] = $ignoring = $post['id'];
837
+			}
811 838
 
812 839
 			echo '
813 840
 			<div class="windowbg">
@@ -990,10 +1017,10 @@  discard block
 block discarded – undo
990 1017
 		<div id="temporary_posting_area" style="display: none;"></div>
991 1018
 		<script>';
992 1019
 
993
-	if ($context['close_window'])
994
-		echo '
1020
+	if ($context['close_window']) {
1021
+			echo '
995 1022
 			window.close();';
996
-	else
1023
+	} else
997 1024
 	{
998 1025
 		// Lucky for us, Internet Explorer has an "innerText" feature which basically converts entities <--> text. Use it if possible ;).
999 1026
 		echo '
@@ -1047,11 +1074,12 @@  discard block
 block discarded – undo
1047 1074
 				</p>
1048 1075
 				<ul>';
1049 1076
 
1050
-	foreach ($context['groups'] as $group)
1051
-		echo '
1077
+	foreach ($context['groups'] as $group) {
1078
+			echo '
1052 1079
 					<li>
1053 1080
 						<label for="who_', $group['id'], '"><input type="checkbox" name="who[', $group['id'], ']" id="who_', $group['id'], '" value="', $group['id'], '" checked class="input_check"> ', $group['name'], '</label> <em>(', $group['member_count'], ')</em>
1054 1081
 					</li>';
1082
+	}
1055 1083
 
1056 1084
 	echo '
1057 1085
 					<li>
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -416,8 +416,8 @@  discard block
 block discarded – undo
416 416
 									</div>
417 417
 									<div class="progressBar" role="progressBar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><span></span></div>
418 418
 									<div class="attach-ui">
419
-										<a data-dz-remove class="button_submit cancel">', $txt['modify_cancel'] ,'</a>
420
-										<a class="button_submit upload">', $txt['upload'] ,'</a>
419
+										<a data-dz-remove class="button_submit cancel">', $txt['modify_cancel'], '</a>
420
+										<a class="button_submit upload">', $txt['upload'], '</a>
421 421
 									</div>
422 422
 								</div>
423 423
 							</div>
@@ -435,10 +435,10 @@  discard block
 block discarded – undo
435 435
 							</dt>
436 436
 							<dd class="smalltext fallback">
437 437
 								<div id="attachUpload" class="descbox">
438
-									<h5>', $txt['attach_drop_zone'] ,'</h5>
439
-									<a class="button_submit" id="attach-cancelAll">', $txt['attached_cancelAll'] ,'</a>
440
-									<a class="button_submit" id="attach-uploadAll">', $txt['attached_uploadAll'] ,'</a>
441
-									<a class="button_submit fileinput-button">', $txt['attach_add'] ,'</a>
438
+									<h5>', $txt['attach_drop_zone'], '</h5>
439
+									<a class="button_submit" id="attach-cancelAll">', $txt['attached_cancelAll'], '</a>
440
+									<a class="button_submit" id="attach-uploadAll">', $txt['attached_uploadAll'], '</a>
441
+									<a class="button_submit fileinput-button">', $txt['attach_add'], '</a>
442 442
 									<div id="total-progress" class="progressBar" role="progressBar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><span></span></div>
443 443
 									<div class="fallback">
444 444
 										<input type="file" multiple="multiple" name="attachment[]" id="attachment1" class="input_file fallback"> (<a href="javascript:void(0);" onclick="cleanFileInput(\'attachment1\');">', $txt['clean_attach'], '</a>)
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
 	// Option to delete an event if user is editing one.
546 546
 	if ($context['make_event'] && !$context['event']['new'])
547 547
 		echo '
548
-						<input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['event_delete_confirm'] ,'" class="button_submit you_sure">';
548
+						<input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['event_delete_confirm'], '" class="button_submit you_sure">';
549 549
 
550 550
 	echo '
551 551
 					</span>
@@ -799,7 +799,7 @@  discard block
 block discarded – undo
799 799
 			});';
800 800
 
801 801
 	echo '
802
-			var oEditorID = "', $context['post_box_name'] ,'";
802
+			var oEditorID = "', $context['post_box_name'], '";
803 803
 			var oEditorObject = oEditorHandle_', $context['post_box_name'], ';
804 804
 		</script>';
805 805
 
@@ -831,7 +831,7 @@  discard block
 block discarded – undo
831 831
 			{
832 832
 				echo '
833 833
 					<ul class="quickbuttons" id="msg_', $post['id'], '_quote">
834
-						<li style="display:none;" id="quoteSelected_', $post['id'], '" data-msgid="', $post['id'], '"><a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'] ,'</a></li>
834
+						<li style="display:none;" id="quoteSelected_', $post['id'], '" data-msgid="', $post['id'], '"><a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'], '</a></li>
835 835
 						<li id="post_modify"><a href="#postmodify" onclick="return insertQuoteFast(', $post['id'], ');"><span class="generic_icons quote"></span>', $txt['quote'], '</a></li>
836 836
 					</ul>';
837 837
 			}
@@ -918,7 +918,7 @@  discard block
 block discarded – undo
918 918
 	<head>
919 919
 		<meta charset="', $context['character_set'], '">
920 920
 		<title>', $txt['spell_check'], '</title>
921
-		<link rel="stylesheet" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css', $modSettings['browser_cache'] ,'">
921
+		<link rel="stylesheet" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css', $modSettings['browser_cache'], '">
922 922
 		<style>
923 923
 			body, td
924 924
 			{
@@ -951,8 +951,8 @@  discard block
 block discarded – undo
951 951
 			var spell_formname = window.opener.spell_formname;
952 952
 			var spell_fieldname = window.opener.spell_fieldname;
953 953
 		</script>
954
-		<script src="', $settings['default_theme_url'], '/scripts/spellcheck.js', $modSettings['browser_cache'] ,'"></script>
955
-		<script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'] ,'"></script>
954
+		<script src="', $settings['default_theme_url'], '/scripts/spellcheck.js', $modSettings['browser_cache'], '"></script>
955
+		<script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'], '"></script>
956 956
 		<script>
957 957
 			', $context['spell_js'], '
958 958
 		</script>
@@ -994,7 +994,7 @@  discard block
 block discarded – undo
994 994
 	<head>
995 995
 		<meta charset="', $context['character_set'], '">
996 996
 		<title>', $txt['retrieving_quote'], '</title>
997
-		<script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'] ,'"></script>
997
+		<script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'], '"></script>
998 998
 	</head>
999 999
 	<body>
1000 1000
 		', $txt['retrieving_quote'], '
Please login to merge, or discard this patch.