Completed
Pull Request — release-2.1 (#4985)
by Fran
06:10
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
 
@@ -1305,14 +1305,14 @@  discard block
 block discarded – undo
1305 1305
 	if (isset($context['name']) && isset($context['email']))
1306 1306
 	{
1307 1307
 		$context['posting_fields']['guestname'] = array(
1308
-			'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>',
1308
+			'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 1309
 			'dd' => '<input type="text" name="guestname" size="25" value="' . $context['name'] . '" required>',
1310 1310
 		);
1311 1311
 
1312 1312
 		if (empty($modSettings['guest_post_no_email']))
1313 1313
 		{
1314 1314
 			$context['posting_fields']['email'] = array(
1315
-				'dt' => '<span id="caption_email"' .  (isset($context['post_error']['no_email']) || isset($context['post_error']['bad_email']) ? ' class="error"' : '') . '>' . $txt['email'] . '</span>',
1315
+				'dt' => '<span id="caption_email"' . (isset($context['post_error']['no_email']) || isset($context['post_error']['bad_email']) ? ' class="error"' : '') . '>' . $txt['email'] . '</span>',
1316 1316
 				'dd' => '<input type="email" name="email" size="25" value="' . $context['email'] . '" required>',
1317 1317
 			);
1318 1318
 		}
Please login to merge, or discard this patch.
Braces   +677 added lines, -523 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 4
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * Handles showing the post screen, loading the post to be modified, and loading any post quoted.
@@ -35,12 +36,14 @@  discard block
 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']);
@@ -60,12 +63,14 @@  discard block
 block discarded – undo
60 63
 	{
61 64
 		// Get ids of all the boards they can post in.
62 65
 		$post_permissions = array('post_new');
63
-		if ($modSettings['postmod_active'])
64
-			$post_permissions[] = 'post_unapproved_topics';
66
+		if ($modSettings['postmod_active']) {
67
+					$post_permissions[] = 'post_unapproved_topics';
68
+		}
65 69
 
66 70
 		$boards = boardsAllowedTo($post_permissions);
67
-		if (empty($boards))
68
-			fatal_lang_error('cannot_post_new', false);
71
+		if (empty($boards)) {
72
+					fatal_lang_error('cannot_post_new', false);
73
+		}
69 74
 
70 75
 		// Get a list of boards for the select menu
71 76
 		require_once($sourcedir . '/Subs-MessageIndex.php');
@@ -78,8 +83,9 @@  discard block
 block discarded – undo
78 83
 		$board_list = getBoardList($boardListOptions);
79 84
 	}
80 85
 	// Let's keep things simple for ourselves below
81
-	else
82
-		$boards = array($board);
86
+	else {
87
+			$boards = array($board);
88
+	}
83 89
 
84 90
 	require_once($sourcedir . '/Subs-Post.php');
85 91
 
@@ -102,10 +108,11 @@  discard block
 block discarded – undo
102 108
 			array(
103 109
 				'msg' => (int) $_REQUEST['msg'],
104 110
 		));
105
-		if ($smcFunc['db_num_rows']($request) != 1)
106
-			unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']);
107
-		else
108
-			list ($topic) = $smcFunc['db_fetch_row']($request);
111
+		if ($smcFunc['db_num_rows']($request) != 1) {
112
+					unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']);
113
+		} else {
114
+					list ($topic) = $smcFunc['db_fetch_row']($request);
115
+		}
109 116
 		$smcFunc['db_free_result']($request);
110 117
 	}
111 118
 
@@ -132,33 +139,36 @@  discard block
 block discarded – undo
132 139
 		$smcFunc['db_free_result']($request);
133 140
 
134 141
 		// If this topic already has a poll, they sure can't add another.
135
-		if (isset($_REQUEST['poll']) && $pollID > 0)
136
-			unset($_REQUEST['poll']);
142
+		if (isset($_REQUEST['poll']) && $pollID > 0) {
143
+					unset($_REQUEST['poll']);
144
+		}
137 145
 
138 146
 		if (empty($_REQUEST['msg']))
139 147
 		{
140
-			if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any')))
141
-				is_not_guest();
148
+			if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) {
149
+							is_not_guest();
150
+			}
142 151
 
143 152
 			// By default the reply will be approved...
144 153
 			$context['becomes_approved'] = true;
145 154
 			if ($id_member_poster != $user_info['id'] || $user_info['is_guest'])
146 155
 			{
147
-				if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any'))
148
-					$context['becomes_approved'] = false;
149
-				else
150
-					isAllowedTo('post_reply_any');
151
-			}
152
-			elseif (!allowedTo('post_reply_any'))
156
+				if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) {
157
+									$context['becomes_approved'] = false;
158
+				} else {
159
+									isAllowedTo('post_reply_any');
160
+				}
161
+			} elseif (!allowedTo('post_reply_any'))
153 162
 			{
154
-				if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any')))
155
-					$context['becomes_approved'] = false;
156
-				else
157
-					isAllowedTo('post_reply_own');
163
+				if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) {
164
+									$context['becomes_approved'] = false;
165
+				} else {
166
+									isAllowedTo('post_reply_own');
167
+				}
158 168
 			}
169
+		} else {
170
+					$context['becomes_approved'] = true;
159 171
 		}
160
-		else
161
-			$context['becomes_approved'] = true;
162 172
 
163 173
 		$context['can_lock'] = allowedTo('lock_any') || ($user_info['id'] == $id_member_poster && allowedTo('lock_own'));
164 174
 		$context['can_sticky'] = allowedTo('make_sticky');
@@ -173,17 +183,18 @@  discard block
 block discarded – undo
173 183
 		$context['sticky'] = isset($_REQUEST['sticky']) ? !empty($_REQUEST['sticky']) : $sticky;
174 184
 
175 185
 		// Check whether this is a really old post being bumped...
176
-		if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject']))
177
-			$post_errors[] = array('old_topic', array($modSettings['oldTopicDays']));
178
-	}
179
-	else
186
+		if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) {
187
+					$post_errors[] = array('old_topic', array($modSettings['oldTopicDays']));
188
+		}
189
+	} else
180 190
 	{
181 191
 		// @todo Should use JavaScript to hide and show the warning based on the selection in the board select menu
182 192
 		$context['becomes_approved'] = true;
183
-		if ($modSettings['postmod_active'] && !allowedTo('post_new', $boards, true) && allowedTo('post_unapproved_topics', $boards, true))
184
-			$context['becomes_approved'] = false;
185
-		else
186
-			isAllowedTo('post_new', $boards, true);
193
+		if ($modSettings['postmod_active'] && !allowedTo('post_new', $boards, true) && allowedTo('post_unapproved_topics', $boards, true)) {
194
+					$context['becomes_approved'] = false;
195
+		} else {
196
+					isAllowedTo('post_new', $boards, true);
197
+		}
187 198
 
188 199
 		$locked = 0;
189 200
 		$context['already_locked'] = 0;
@@ -213,27 +224,32 @@  discard block
 block discarded – undo
213 224
 	if (empty($_REQUEST['message']) && empty($_REQUEST['preview']) && !empty($_SESSION['already_attached']))
214 225
 	{
215 226
 		require_once($sourcedir . '/ManageAttachments.php');
216
-		foreach ($_SESSION['already_attached'] as $attachID => $attachment)
217
-			removeAttachments(array('id_attach' => $attachID));
227
+		foreach ($_SESSION['already_attached'] as $attachID => $attachment) {
228
+					removeAttachments(array('id_attach' => $attachID));
229
+		}
218 230
 
219 231
 		unset($_SESSION['already_attached']);
220 232
 	}
221 233
 
222 234
 	// Don't allow a post if it's locked and you aren't all powerful.
223
-	if ($locked && !allowedTo('moderate_board'))
224
-		fatal_lang_error('topic_locked', false);
235
+	if ($locked && !allowedTo('moderate_board')) {
236
+			fatal_lang_error('topic_locked', false);
237
+	}
225 238
 	// Check the users permissions - is the user allowed to add or post a poll?
226 239
 	if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1')
227 240
 	{
228 241
 		// New topic, new poll.
229
-		if (empty($topic))
230
-			isAllowedTo('poll_post');
242
+		if (empty($topic)) {
243
+					isAllowedTo('poll_post');
244
+		}
231 245
 		// This is an old topic - but it is yours!  Can you add to it?
232
-		elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any'))
233
-			isAllowedTo('poll_add_own');
246
+		elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) {
247
+					isAllowedTo('poll_add_own');
248
+		}
234 249
 		// If you're not the owner, can you add to any poll?
235
-		else
236
-			isAllowedTo('poll_add_any');
250
+		else {
251
+					isAllowedTo('poll_add_any');
252
+		}
237 253
 
238 254
 		if (!empty($board))
239 255
 		{
@@ -242,8 +258,9 @@  discard block
 block discarded – undo
242 258
 			$guest_vote_enabled = in_array(-1, $allowedVoteGroups['allowed']);
243 259
 		}
244 260
 		// No board, so we'll have to check this again in Post2
245
-		else
246
-			$guest_vote_enabled = true;
261
+		else {
262
+					$guest_vote_enabled = true;
263
+		}
247 264
 
248 265
 		// Set up the poll options.
249 266
 		$context['poll_options'] = array(
@@ -269,8 +286,9 @@  discard block
 block discarded – undo
269 286
 	if ($context['make_event'])
270 287
 	{
271 288
 		// They might want to pick a board.
272
-		if (!isset($context['current_board']))
273
-			$context['current_board'] = 0;
289
+		if (!isset($context['current_board'])) {
290
+					$context['current_board'] = 0;
291
+		}
274 292
 
275 293
 		// Start loading up the event info.
276 294
 		$context['event'] = array();
@@ -284,10 +302,11 @@  discard block
 block discarded – undo
284 302
 		isAllowedTo('calendar_post');
285 303
 
286 304
 		// We want a fairly compact version of the time, but as close as possible to the user's settings.
287
-		if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0]))
288
-			$time_string = '%k:%M';
289
-		else
290
-			$time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]);
305
+		if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) {
306
+					$time_string = '%k:%M';
307
+		} else {
308
+					$time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]);
309
+		}
291 310
 
292 311
 		$js_time_string = str_replace(
293 312
 			array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r',      '%R',  '%S', '%T',    '%X'),
@@ -309,8 +328,7 @@  discard block
 block discarded – undo
309 328
 			require_once($sourcedir . '/Subs-Calendar.php');
310 329
 			$eventProperties = getEventProperties($context['event']['id']);
311 330
 			$context['event'] = array_merge($context['event'], $eventProperties);
312
-		}
313
-		else
331
+		} else
314 332
 		{
315 333
 			// Get the current event information.
316 334
 			require_once($sourcedir . '/Subs-Calendar.php');
@@ -318,10 +336,12 @@  discard block
 block discarded – undo
318 336
 			$context['event'] = array_merge($context['event'], $eventProperties);
319 337
 
320 338
 			// Make sure the year and month are in the valid range.
321
-			if ($context['event']['month'] < 1 || $context['event']['month'] > 12)
322
-				fatal_lang_error('invalid_month', false);
323
-			if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear'])
324
-				fatal_lang_error('invalid_year', false);
339
+			if ($context['event']['month'] < 1 || $context['event']['month'] > 12) {
340
+							fatal_lang_error('invalid_month', false);
341
+			}
342
+			if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) {
343
+							fatal_lang_error('invalid_year', false);
344
+			}
325 345
 
326 346
 			$context['event']['categories'] = $board_list;
327 347
 		}
@@ -432,10 +452,11 @@  discard block
 block discarded – undo
432 452
 
433 453
 			if (!empty($context['new_replies']))
434 454
 			{
435
-				if ($context['new_replies'] == 1)
436
-					$txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply'];
437
-				else
438
-					$txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']);
455
+				if ($context['new_replies'] == 1) {
456
+									$txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply'];
457
+				} else {
458
+									$txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']);
459
+				}
439 460
 
440 461
 				$post_errors[] = 'new_replies';
441 462
 
@@ -447,9 +468,9 @@  discard block
 block discarded – undo
447 468
 	// Get a response prefix (like 'Re:') in the default forum language.
448 469
 	if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix')))
449 470
 	{
450
-		if ($language === $user_info['language'])
451
-			$context['response_prefix'] = $txt['response_prefix'];
452
-		else
471
+		if ($language === $user_info['language']) {
472
+					$context['response_prefix'] = $txt['response_prefix'];
473
+		} else
453 474
 		{
454 475
 			loadLanguage('index', $language, false);
455 476
 			$context['response_prefix'] = $txt['response_prefix'];
@@ -462,23 +483,26 @@  discard block
 block discarded – undo
462 483
 	// Do we have a body, but an error happened.
463 484
 	if (isset($_REQUEST['message']) || isset($_REQUEST['quickReply']) || !empty($context['post_error']))
464 485
 	{
465
-		if (isset($_REQUEST['quickReply']))
466
-			$_REQUEST['message'] = $_REQUEST['quickReply'];
486
+		if (isset($_REQUEST['quickReply'])) {
487
+					$_REQUEST['message'] = $_REQUEST['quickReply'];
488
+		}
467 489
 
468 490
 		// Validate inputs.
469 491
 		if (empty($context['post_error']))
470 492
 		{
471 493
 			// This means they didn't click Post and get an error.
472 494
 			$really_previewing = true;
473
-		}
474
-		else
495
+		} else
475 496
 		{
476
-			if (!isset($_REQUEST['subject']))
477
-				$_REQUEST['subject'] = '';
478
-			if (!isset($_REQUEST['message']))
479
-				$_REQUEST['message'] = '';
480
-			if (!isset($_REQUEST['icon']))
481
-				$_REQUEST['icon'] = 'xx';
497
+			if (!isset($_REQUEST['subject'])) {
498
+							$_REQUEST['subject'] = '';
499
+			}
500
+			if (!isset($_REQUEST['message'])) {
501
+							$_REQUEST['message'] = '';
502
+			}
503
+			if (!isset($_REQUEST['icon'])) {
504
+							$_REQUEST['icon'] = 'xx';
505
+			}
482 506
 
483 507
 			// They are previewing if they asked to preview (i.e. came from quick reply).
484 508
 			$really_previewing = !empty($_POST['preview']);
@@ -494,8 +518,9 @@  discard block
 block discarded – undo
494 518
 		$form_message = $smcFunc['htmlspecialchars']($_REQUEST['message'], ENT_QUOTES);
495 519
 
496 520
 		// Make sure the subject isn't too long - taking into account special characters.
497
-		if ($smcFunc['strlen']($form_subject) > 100)
498
-			$form_subject = $smcFunc['substr']($form_subject, 0, 100);
521
+		if ($smcFunc['strlen']($form_subject) > 100) {
522
+					$form_subject = $smcFunc['substr']($form_subject, 0, 100);
523
+		}
499 524
 
500 525
 		if (isset($_REQUEST['poll']))
501 526
 		{
@@ -507,8 +532,9 @@  discard block
 block discarded – undo
507 532
 			$_POST['options'] = empty($_POST['options']) ? array() : htmlspecialchars__recursive($_POST['options']);
508 533
 			foreach ($_POST['options'] as $option)
509 534
 			{
510
-				if (trim($option) == '')
511
-					continue;
535
+				if (trim($option) == '') {
536
+									continue;
537
+				}
512 538
 
513 539
 				$context['choices'][] = array(
514 540
 					'id' => $choice_id++,
@@ -570,13 +596,14 @@  discard block
 block discarded – undo
570 596
 				$context['preview_subject'] = $form_subject;
571 597
 
572 598
 				censorText($context['preview_subject']);
599
+			} else {
600
+							$context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>';
573 601
 			}
574
-			else
575
-				$context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>';
576 602
 
577 603
 			// Protect any CDATA blocks.
578
-			if (isset($_REQUEST['xml']))
579
-				$context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]><![CDATA[>'));
604
+			if (isset($_REQUEST['xml'])) {
605
+							$context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]><![CDATA[>'));
606
+			}
580 607
 		}
581 608
 
582 609
 		// Set up the checkboxes.
@@ -615,29 +642,32 @@  discard block
 block discarded – undo
615 642
 			);
616 643
 			// The message they were trying to edit was most likely deleted.
617 644
 			// @todo Change this error message?
618
-			if ($smcFunc['db_num_rows']($request) == 0)
619
-				fatal_lang_error('no_board', false);
645
+			if ($smcFunc['db_num_rows']($request) == 0) {
646
+							fatal_lang_error('no_board', false);
647
+			}
620 648
 			$row = $smcFunc['db_fetch_assoc']($request);
621 649
 
622 650
 			$attachment_stuff = array($row);
623
-			while ($row2 = $smcFunc['db_fetch_assoc']($request))
624
-				$attachment_stuff[] = $row2;
651
+			while ($row2 = $smcFunc['db_fetch_assoc']($request)) {
652
+							$attachment_stuff[] = $row2;
653
+			}
625 654
 			$smcFunc['db_free_result']($request);
626 655
 
627 656
 			if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any'))
628 657
 			{
629 658
 				// Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public.
630
-				if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time())
631
-					fatal_lang_error('modify_post_time_passed', false);
632
-				elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own'))
633
-					isAllowedTo('modify_replies');
634
-				else
635
-					isAllowedTo('modify_own');
659
+				if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) {
660
+									fatal_lang_error('modify_post_time_passed', false);
661
+				} elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) {
662
+									isAllowedTo('modify_replies');
663
+				} else {
664
+									isAllowedTo('modify_own');
665
+				}
666
+			} elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) {
667
+							isAllowedTo('modify_replies');
668
+			} else {
669
+							isAllowedTo('modify_any');
636 670
 			}
637
-			elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any'))
638
-				isAllowedTo('modify_replies');
639
-			else
640
-				isAllowedTo('modify_any');
641 671
 
642 672
 			if ($context['can_announce'] && !empty($row['id_action']))
643 673
 			{
@@ -661,8 +691,9 @@  discard block
 block discarded – undo
661 691
 
662 692
 				while ($row = $smcFunc['db_fetch_assoc']($request))
663 693
 				{
664
-					if ($row['filesize'] <= 0)
665
-						continue;
694
+					if ($row['filesize'] <= 0) {
695
+											continue;
696
+					}
666 697
 					$context['current_attachments'][$row['id_attach']] = array(
667 698
 						'name' => $smcFunc['htmlspecialchars']($row['filename']),
668 699
 						'size' => $row['filesize'],
@@ -732,29 +763,32 @@  discard block
 block discarded – undo
732 763
 			)
733 764
 		);
734 765
 		// The message they were trying to edit was most likely deleted.
735
-		if ($smcFunc['db_num_rows']($request) == 0)
736
-			fatal_lang_error('no_message', false);
766
+		if ($smcFunc['db_num_rows']($request) == 0) {
767
+					fatal_lang_error('no_message', false);
768
+		}
737 769
 		$row = $smcFunc['db_fetch_assoc']($request);
738 770
 
739 771
 		$attachment_stuff = array($row);
740
-		while ($row2 = $smcFunc['db_fetch_assoc']($request))
741
-			$attachment_stuff[] = $row2;
772
+		while ($row2 = $smcFunc['db_fetch_assoc']($request)) {
773
+					$attachment_stuff[] = $row2;
774
+		}
742 775
 		$smcFunc['db_free_result']($request);
743 776
 
744 777
 		if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any'))
745 778
 		{
746 779
 			// Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public.
747
-			if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time())
748
-				fatal_lang_error('modify_post_time_passed', false);
749
-			elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own'))
750
-				isAllowedTo('modify_replies');
751
-			else
752
-				isAllowedTo('modify_own');
780
+			if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) {
781
+							fatal_lang_error('modify_post_time_passed', false);
782
+			} elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) {
783
+							isAllowedTo('modify_replies');
784
+			} else {
785
+							isAllowedTo('modify_own');
786
+			}
787
+		} elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) {
788
+					isAllowedTo('modify_replies');
789
+		} else {
790
+					isAllowedTo('modify_any');
753 791
 		}
754
-		elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any'))
755
-			isAllowedTo('modify_replies');
756
-		else
757
-			isAllowedTo('modify_any');
758 792
 
759 793
 		if ($context['can_announce'] && !empty($row['id_action']))
760 794
 		{
@@ -781,15 +815,17 @@  discard block
 block discarded – undo
781 815
 		$context['icon'] = $row['icon'];
782 816
 
783 817
 		// Show an "approve" box if the user can approve it, and the message isn't approved.
784
-		if (!$row['approved'] && !$context['show_approval'])
785
-			$context['show_approval'] = allowedTo('approve_posts');
818
+		if (!$row['approved'] && !$context['show_approval']) {
819
+					$context['show_approval'] = allowedTo('approve_posts');
820
+		}
786 821
 
787 822
 		// Sort the attachments so they are in the order saved
788 823
 		$temp = array();
789 824
 		foreach ($attachment_stuff as $attachment)
790 825
 		{
791
-			if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable']))
792
-				$temp[$attachment['id_attach']] = $attachment;
826
+			if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) {
827
+							$temp[$attachment['id_attach']] = $attachment;
828
+			}
793 829
 		}
794 830
 		ksort($temp);
795 831
 
@@ -850,14 +886,16 @@  discard block
 block discarded – undo
850 886
 					'is_approved' => 1,
851 887
 				)
852 888
 			);
853
-			if ($smcFunc['db_num_rows']($request) == 0)
854
-				fatal_lang_error('quoted_post_deleted', false);
889
+			if ($smcFunc['db_num_rows']($request) == 0) {
890
+							fatal_lang_error('quoted_post_deleted', false);
891
+			}
855 892
 			list ($form_subject, $mname, $mdate, $form_message) = $smcFunc['db_fetch_row']($request);
856 893
 			$smcFunc['db_free_result']($request);
857 894
 
858 895
 			// Add 'Re: ' to the front of the quoted subject.
859
-			if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0)
860
-				$form_subject = $context['response_prefix'] . $form_subject;
896
+			if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) {
897
+							$form_subject = $context['response_prefix'] . $form_subject;
898
+			}
861 899
 
862 900
 			// Censor the message and subject.
863 901
 			censorText($form_message);
@@ -870,10 +908,11 @@  discard block
 block discarded – undo
870 908
 				for ($i = 0, $n = count($parts); $i < $n; $i++)
871 909
 				{
872 910
 					// It goes 0 = outside, 1 = begin tag, 2 = inside, 3 = close tag, repeat.
873
-					if ($i % 4 == 0)
874
-						$parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m)
911
+					if ($i % 4 == 0) {
912
+											$parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m)
875 913
 						{
876 914
 							return '[html]' . preg_replace('~<br\s?/?' . '>~i', '&lt;br /&gt;<br>', "$m[1]") . '[/html]';
915
+					}
877 916
 						}, $parts[$i]);
878 917
 				}
879 918
 				$form_message = implode('', $parts);
@@ -882,8 +921,9 @@  discard block
 block discarded – undo
882 921
 			$form_message = preg_replace('~<br ?/?' . '>~i', "\n", $form_message);
883 922
 
884 923
 			// Remove any nested quotes, if necessary.
885
-			if (!empty($modSettings['removeNestedQuotes']))
886
-				$form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message);
924
+			if (!empty($modSettings['removeNestedQuotes'])) {
925
+							$form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message);
926
+			}
887 927
 
888 928
 			// Add a quote string on the front and end.
889 929
 			$form_message = '[quote author=' . $mname . ' link=msg=' . (int) $_REQUEST['quote'] . ' date=' . $mdate . ']' . "\n" . rtrim($form_message) . "\n" . '[/quote]';
@@ -895,15 +935,15 @@  discard block
 block discarded – undo
895 935
 			$form_subject = $first_subject;
896 936
 
897 937
 			// Add 'Re: ' to the front of the subject.
898
-			if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0)
899
-				$form_subject = $context['response_prefix'] . $form_subject;
938
+			if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) {
939
+							$form_subject = $context['response_prefix'] . $form_subject;
940
+			}
900 941
 
901 942
 			// Censor the subject.
902 943
 			censorText($form_subject);
903 944
 
904 945
 			$form_message = '';
905
-		}
906
-		else
946
+		} else
907 947
 		{
908 948
 			$form_subject = isset($_GET['subject']) ? $_GET['subject'] : '';
909 949
 			$form_message = '';
@@ -922,13 +962,15 @@  discard block
 block discarded – undo
922 962
 		if (isset($_REQUEST['msg']))
923 963
 		{
924 964
 			$context['attachments']['quantity'] = count($context['current_attachments']);
925
-			foreach ($context['current_attachments'] as $attachment)
926
-				$context['attachments']['total_size'] += $attachment['size'];
965
+			foreach ($context['current_attachments'] as $attachment) {
966
+							$context['attachments']['total_size'] += $attachment['size'];
967
+			}
927 968
 		}
928 969
 
929 970
 		// A bit of house keeping first.
930
-		if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1)
931
-			unset($_SESSION['temp_attachments']);
971
+		if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) {
972
+					unset($_SESSION['temp_attachments']);
973
+		}
932 974
 
933 975
 		if (!empty($_SESSION['temp_attachments']))
934 976
 		{
@@ -937,9 +979,10 @@  discard block
 block discarded – undo
937 979
 			{
938 980
 				foreach ($_SESSION['temp_attachments'] as $attachID => $attachment)
939 981
 				{
940
-					if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false)
941
-						if (file_exists($attachment['tmp_name']))
982
+					if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) {
983
+											if (file_exists($attachment['tmp_name']))
942 984
 							unlink($attachment['tmp_name']);
985
+					}
943 986
 				}
944 987
 				$post_errors[] = 'temp_attachments_gone';
945 988
 				$_SESSION['temp_attachments'] = array();
@@ -953,8 +996,9 @@  discard block
 block discarded – undo
953 996
 					// See if any files still exist before showing the warning message and the files attached.
954 997
 					foreach ($_SESSION['temp_attachments'] as $attachID => $attachment)
955 998
 					{
956
-						if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false)
957
-							continue;
999
+						if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) {
1000
+													continue;
1001
+						}
958 1002
 
959 1003
 						if (file_exists($attachment['tmp_name']))
960 1004
 						{
@@ -964,20 +1008,21 @@  discard block
 block discarded – undo
964 1008
 							break;
965 1009
 						}
966 1010
 					}
967
-				}
968
-				else
1011
+				} else
969 1012
 				{
970 1013
 					// Since, they don't belong here. Let's inform the user that they exist..
971
-					if (!empty($topic))
972
-						$delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp';
973
-					else
974
-						$delete_url = $scripturl . '?action=post' . (!empty($board) ? ';board=' . $board : '') . ';delete_temp';
1014
+					if (!empty($topic)) {
1015
+											$delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp';
1016
+					} else {
1017
+											$delete_url = $scripturl . '?action=post' . (!empty($board) ? ';board=' . $board : '') . ';delete_temp';
1018
+					}
975 1019
 
976 1020
 					// Compile a list of the files to show the user.
977 1021
 					$file_list = array();
978
-					foreach ($_SESSION['temp_attachments'] as $attachID => $attachment)
979
-						if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false)
1022
+					foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) {
1023
+											if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false)
980 1024
 							$file_list[] = $attachment['name'];
1025
+					}
981 1026
 
982 1027
 					$_SESSION['temp_attachments']['post']['files'] = $file_list;
983 1028
 					$file_list = '<div class="attachments">' . implode('<br>', $file_list) . '</div>';
@@ -989,8 +1034,7 @@  discard block
 block discarded – undo
989 1034
 
990 1035
 						$post_errors[] = array('temp_attachments_found', array($delete_url, $goback_url, $file_list));
991 1036
 						$context['ignore_temp_attachments'] = true;
992
-					}
993
-					else
1037
+					} else
994 1038
 					{
995 1039
 						$post_errors[] = array('temp_attachments_lost', array($delete_url, $file_list));
996 1040
 						$context['ignore_temp_attachments'] = true;
@@ -998,16 +1042,19 @@  discard block
 block discarded – undo
998 1042
 				}
999 1043
 			}
1000 1044
 
1001
-			if (!empty($context['we_are_history']))
1002
-				$post_errors[] = $context['we_are_history'];
1045
+			if (!empty($context['we_are_history'])) {
1046
+							$post_errors[] = $context['we_are_history'];
1047
+			}
1003 1048
 
1004 1049
 			foreach ($_SESSION['temp_attachments'] as $attachID => $attachment)
1005 1050
 			{
1006
-				if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files']))
1007
-					break;
1051
+				if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) {
1052
+									break;
1053
+				}
1008 1054
 
1009
-				if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false)
1010
-					continue;
1055
+				if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) {
1056
+									continue;
1057
+				}
1011 1058
 
1012 1059
 				if ($attachID == 'initial_error')
1013 1060
 				{
@@ -1022,15 +1069,17 @@  discard block
 block discarded – undo
1022 1069
 				{
1023 1070
 					$txt['error_attach_errors'] = empty($txt['error_attach_errors']) ? '<br>' : '';
1024 1071
 					$txt['error_attach_errors'] .= vsprintf($txt['attach_warning'], $attachment['name']) . '<div style="padding: 0 1em;">';
1025
-					foreach ($attachment['errors'] as $error)
1026
-						$txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >';
1072
+					foreach ($attachment['errors'] as $error) {
1073
+											$txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >';
1074
+					}
1027 1075
 					$txt['error_attach_errors'] .= '</div>';
1028 1076
 					$post_errors[] = 'attach_errors';
1029 1077
 
1030 1078
 					// Take out the trash.
1031 1079
 					unset($_SESSION['temp_attachments'][$attachID]);
1032
-					if (file_exists($attachment['tmp_name']))
1033
-						unlink($attachment['tmp_name']);
1080
+					if (file_exists($attachment['tmp_name'])) {
1081
+											unlink($attachment['tmp_name']);
1082
+					}
1034 1083
 					continue;
1035 1084
 				}
1036 1085
 
@@ -1043,8 +1092,9 @@  discard block
 block discarded – undo
1043 1092
 
1044 1093
 				$context['attachments']['quantity']++;
1045 1094
 				$context['attachments']['total_size'] += $attachment['size'];
1046
-				if (!isset($context['files_in_session_warning']))
1047
-					$context['files_in_session_warning'] = $txt['attached_files_in_session'];
1095
+				if (!isset($context['files_in_session_warning'])) {
1096
+									$context['files_in_session_warning'] = $txt['attached_files_in_session'];
1097
+				}
1048 1098
 
1049 1099
 				$context['current_attachments'][$attachID] = array(
1050 1100
 					'name' => '<u>' . $smcFunc['htmlspecialchars']($attachment['name']) . '</u>',
@@ -1072,8 +1122,9 @@  discard block
 block discarded – undo
1072 1122
 	}
1073 1123
 
1074 1124
 	// If they came from quick reply, and have to enter verification details, give them some notice.
1075
-	if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification']))
1076
-		$post_errors[] = 'need_qr_verification';
1125
+	if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) {
1126
+			$post_errors[] = 'need_qr_verification';
1127
+	}
1077 1128
 
1078 1129
 	/*
1079 1130
 	 * There are two error types: serious and minor. Serious errors
@@ -1090,52 +1141,56 @@  discard block
 block discarded – undo
1090 1141
 	{
1091 1142
 		loadLanguage('Errors');
1092 1143
 		$context['error_type'] = 'minor';
1093
-		foreach ($post_errors as $post_error)
1094
-			if (is_array($post_error))
1144
+		foreach ($post_errors as $post_error) {
1145
+					if (is_array($post_error))
1095 1146
 			{
1096 1147
 				$post_error_id = $post_error[0];
1148
+		}
1097 1149
 				$context['post_error'][$post_error_id] = vsprintf($txt['error_' . $post_error_id], $post_error[1]);
1098 1150
 
1099 1151
 				// If it's not a minor error flag it as such.
1100
-				if (!in_array($post_error_id, $minor_errors))
1101
-					$context['error_type'] = 'serious';
1102
-			}
1103
-			else
1152
+				if (!in_array($post_error_id, $minor_errors)) {
1153
+									$context['error_type'] = 'serious';
1154
+				}
1155
+			} else
1104 1156
 			{
1105 1157
 				$context['post_error'][$post_error] = $txt['error_' . $post_error];
1106 1158
 
1107 1159
 				// If it's not a minor error flag it as such.
1108
-				if (!in_array($post_error, $minor_errors))
1109
-					$context['error_type'] = 'serious';
1160
+				if (!in_array($post_error, $minor_errors)) {
1161
+									$context['error_type'] = 'serious';
1162
+				}
1110 1163
 			}
1111 1164
 	}
1112 1165
 
1113 1166
 	// What are you doing? Posting a poll, modifying, previewing, new post, or reply...
1114
-	if (isset($_REQUEST['poll']))
1115
-		$context['page_title'] = $txt['new_poll'];
1116
-	elseif ($context['make_event'])
1117
-		$context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit'];
1118
-	elseif (isset($_REQUEST['msg']))
1119
-		$context['page_title'] = $txt['modify_msg'];
1120
-	elseif (isset($_REQUEST['subject'], $context['preview_subject']))
1121
-		$context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']);
1122
-	elseif (empty($topic))
1123
-		$context['page_title'] = $txt['start_new_topic'];
1124
-	else
1125
-		$context['page_title'] = $txt['post_reply'];
1167
+	if (isset($_REQUEST['poll'])) {
1168
+			$context['page_title'] = $txt['new_poll'];
1169
+	} elseif ($context['make_event']) {
1170
+			$context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit'];
1171
+	} elseif (isset($_REQUEST['msg'])) {
1172
+			$context['page_title'] = $txt['modify_msg'];
1173
+	} elseif (isset($_REQUEST['subject'], $context['preview_subject'])) {
1174
+			$context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']);
1175
+	} elseif (empty($topic)) {
1176
+			$context['page_title'] = $txt['start_new_topic'];
1177
+	} else {
1178
+			$context['page_title'] = $txt['post_reply'];
1179
+	}
1126 1180
 
1127 1181
 	// Build the link tree.
1128
-	if (empty($topic))
1129
-		$context['linktree'][] = array(
1182
+	if (empty($topic)) {
1183
+			$context['linktree'][] = array(
1130 1184
 			'name' => '<em>' . $txt['start_new_topic'] . '</em>'
1131 1185
 		);
1132
-	else
1133
-		$context['linktree'][] = array(
1186
+	} else {
1187
+			$context['linktree'][] = array(
1134 1188
 			'url' => $scripturl . '?topic=' . $topic . '.' . $_REQUEST['start'],
1135 1189
 			'name' => $form_subject,
1136 1190
 			'extra_before' => '<span><strong class="nav">' . $context['page_title'] . ' (</strong></span>',
1137 1191
 			'extra_after' => '<span><strong class="nav">)</strong></span>'
1138 1192
 		);
1193
+	}
1139 1194
 
1140 1195
 	$context['subject'] = addcslashes($form_subject, '"');
1141 1196
 	$context['message'] = str_replace(array('"', '<', '>', '&nbsp;'), array('&quot;', '&lt;', '&gt;', ' '), $form_message);
@@ -1179,8 +1234,9 @@  discard block
 block discarded – undo
1179 1234
 	// Message icons - customized icons are off?
1180 1235
 	$context['icons'] = getMessageIcons(!empty($board) ? $board : 0);
1181 1236
 
1182
-	if (!empty($context['icons']))
1183
-		$context['icons'][count($context['icons']) - 1]['is_last'] = true;
1237
+	if (!empty($context['icons'])) {
1238
+			$context['icons'][count($context['icons']) - 1]['is_last'] = true;
1239
+	}
1184 1240
 
1185 1241
 	// Are we starting a poll? if set the poll icon as selected if its available
1186 1242
 	if (isset($_REQUEST['poll']))
@@ -1200,8 +1256,9 @@  discard block
 block discarded – undo
1200 1256
 	for ($i = 0, $n = count($context['icons']); $i < $n; $i++)
1201 1257
 	{
1202 1258
 		$context['icons'][$i]['selected'] = $context['icon'] == $context['icons'][$i]['value'];
1203
-		if ($context['icons'][$i]['selected'])
1204
-			$context['icon_url'] = $context['icons'][$i]['url'];
1259
+		if ($context['icons'][$i]['selected']) {
1260
+					$context['icon_url'] = $context['icons'][$i]['url'];
1261
+		}
1205 1262
 	}
1206 1263
 	if (empty($context['icon_url']))
1207 1264
 	{
@@ -1215,8 +1272,9 @@  discard block
 block discarded – undo
1215 1272
 		));
1216 1273
 	}
1217 1274
 
1218
-	if (!empty($topic) && !empty($modSettings['topicSummaryPosts']))
1219
-		getTopic();
1275
+	if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) {
1276
+			getTopic();
1277
+	}
1220 1278
 
1221 1279
 	// If the user can post attachments prepare the warning labels.
1222 1280
 	if ($context['can_post_attachment'])
@@ -1227,12 +1285,13 @@  discard block
 block discarded – undo
1227 1285
 		$context['attachment_restrictions'] = array();
1228 1286
 		$context['allowed_extensions'] = strtr(strtolower($modSettings['attachmentExtensions']), array(',' => ', '));
1229 1287
 		$attachmentRestrictionTypes = array('attachmentNumPerPostLimit', 'attachmentPostLimit', 'attachmentSizeLimit');
1230
-		foreach ($attachmentRestrictionTypes as $type)
1231
-			if (!empty($modSettings[$type]))
1288
+		foreach ($attachmentRestrictionTypes as $type) {
1289
+					if (!empty($modSettings[$type]))
1232 1290
 			{
1233 1291
 				// Show the max number of attachments if not 0.
1234 1292
 				if ($type == 'attachmentNumPerPostLimit')
1235 1293
 					$context['attachment_restrictions'][] = sprintf($txt['attach_remaining'], $modSettings['attachmentNumPerPostLimit'] - $context['attachments']['quantity']);
1294
+		}
1236 1295
 			}
1237 1296
 	}
1238 1297
 
@@ -1266,8 +1325,8 @@  discard block
 block discarded – undo
1266 1325
 
1267 1326
 	if (!empty($context['current_attachments']))
1268 1327
 	{
1269
-		foreach ($context['current_attachments'] as $key => $mock)
1270
-			addInlineJavaScript('
1328
+		foreach ($context['current_attachments'] as $key => $mock) {
1329
+					addInlineJavaScript('
1271 1330
 	current_attachments.push({
1272 1331
 		name: '. JavaScriptEscape($mock['name']) . ',
1273 1332
 		size: '. $mock['size'] . ',
@@ -1276,6 +1335,7 @@  discard block
 block discarded – undo
1276 1335
 		type: '. JavaScriptEscape(!empty($mock['mime_type']) ? $mock['mime_type'] : '') . ',
1277 1336
 		thumbID: '. (!empty($mock['thumb']) ? $mock['thumb'] : 0) . '
1278 1337
 	});');
1338
+		}
1279 1339
 	}
1280 1340
 
1281 1341
 	// File Upload.
@@ -1350,9 +1410,10 @@  discard block
 block discarded – undo
1350 1410
 			$context['posting_fields']['board']['dd'] .= '
1351 1411
 							<optgroup label="' . $category['name'] . '">';
1352 1412
 
1353
-			foreach ($category['boards'] as $brd)
1354
-				$context['posting_fields']['board']['dd'] .= '
1413
+			foreach ($category['boards'] as $brd) {
1414
+							$context['posting_fields']['board']['dd'] .= '
1355 1415
 								<option value="' . $brd['id'] . '"' . ($brd['selected'] ? ' selected' : '') . '>' . ($brd['child_level'] > 0 ? str_repeat('==', $brd['child_level'] - 1) . '=&gt;' : '') . ' ' . $brd['name'] . '</option>';
1416
+			}
1356 1417
 
1357 1418
 			$context['posting_fields']['board']['dd'] .= '
1358 1419
 							</optgroup>';
@@ -1383,8 +1444,9 @@  discard block
 block discarded – undo
1383 1444
 
1384 1445
 
1385 1446
 	// Finally, load the template.
1386
-	if (!isset($_REQUEST['xml']))
1387
-		loadTemplate('Post');
1447
+	if (!isset($_REQUEST['xml'])) {
1448
+			loadTemplate('Post');
1449
+	}
1388 1450
 
1389 1451
 	call_integration_hook('integrate_post_end');
1390 1452
 }
@@ -1405,13 +1467,14 @@  discard block
 block discarded – undo
1405 1467
 	// Sneaking off, are we?
1406 1468
 	if (empty($_POST) && empty($topic))
1407 1469
 	{
1408
-		if (empty($_SERVER['CONTENT_LENGTH']))
1409
-			redirectexit('action=post;board=' . $board . '.0');
1410
-		else
1411
-			fatal_lang_error('post_upload_error', false);
1470
+		if (empty($_SERVER['CONTENT_LENGTH'])) {
1471
+					redirectexit('action=post;board=' . $board . '.0');
1472
+		} else {
1473
+					fatal_lang_error('post_upload_error', false);
1474
+		}
1475
+	} elseif (empty($_POST) && !empty($topic)) {
1476
+			redirectexit('action=post;topic=' . $topic . '.0');
1412 1477
 	}
1413
-	elseif (empty($_POST) && !empty($topic))
1414
-		redirectexit('action=post;topic=' . $topic . '.0');
1415 1478
 
1416 1479
 	// No need!
1417 1480
 	$context['robot_no_index'] = true;
@@ -1423,8 +1486,9 @@  discard block
 block discarded – undo
1423 1486
 	$post_errors = array();
1424 1487
 
1425 1488
 	// If the session has timed out, let the user re-submit their form.
1426
-	if (checkSession('post', '', false) != '')
1427
-		$post_errors[] = 'session_timeout';
1489
+	if (checkSession('post', '', false) != '') {
1490
+			$post_errors[] = 'session_timeout';
1491
+	}
1428 1492
 
1429 1493
 	// Wrong verification code?
1430 1494
 	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)))
@@ -1434,8 +1498,9 @@  discard block
 block discarded – undo
1434 1498
 			'id' => 'post',
1435 1499
 		);
1436 1500
 		$context['require_verification'] = create_control_verification($verificationOptions, true);
1437
-		if (is_array($context['require_verification']))
1438
-			$post_errors = array_merge($post_errors, $context['require_verification']);
1501
+		if (is_array($context['require_verification'])) {
1502
+					$post_errors = array_merge($post_errors, $context['require_verification']);
1503
+		}
1439 1504
 	}
1440 1505
 
1441 1506
 	require_once($sourcedir . '/Subs-Post.php');
@@ -1444,25 +1509,29 @@  discard block
 block discarded – undo
1444 1509
 	call_integration_hook('integrate_post2_start');
1445 1510
 
1446 1511
 	// Drafts enabled and needed?
1447
-	if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft'])))
1448
-		require_once($sourcedir . '/Drafts.php');
1512
+	if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) {
1513
+			require_once($sourcedir . '/Drafts.php');
1514
+	}
1449 1515
 
1450 1516
 	// First check to see if they are trying to delete any current attachments.
1451 1517
 	if (isset($_POST['attach_del']))
1452 1518
 	{
1453 1519
 		$keep_temp = array();
1454 1520
 		$keep_ids = array();
1455
-		foreach ($_POST['attach_del'] as $dummy)
1456
-			if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false)
1521
+		foreach ($_POST['attach_del'] as $dummy) {
1522
+					if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false)
1457 1523
 				$keep_temp[] = $dummy;
1458
-			else
1459
-				$keep_ids[] = (int) $dummy;
1524
+		}
1525
+			else {
1526
+							$keep_ids[] = (int) $dummy;
1527
+			}
1460 1528
 
1461
-		if (isset($_SESSION['temp_attachments']))
1462
-			foreach ($_SESSION['temp_attachments'] as $attachID => $attachment)
1529
+		if (isset($_SESSION['temp_attachments'])) {
1530
+					foreach ($_SESSION['temp_attachments'] as $attachID => $attachment)
1463 1531
 			{
1464 1532
 				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)
1465 1533
 					continue;
1534
+		}
1466 1535
 
1467 1536
 				unset($_SESSION['temp_attachments'][$attachID]);
1468 1537
 				unlink($attachment['tmp_name']);
@@ -1494,8 +1563,9 @@  discard block
 block discarded – undo
1494 1563
 	{
1495 1564
 		require_once($sourcedir . '/ManageAttachments.php');
1496 1565
 
1497
-		foreach ($_SESSION['already_attached'] as $attachID => $attachment)
1498
-			removeAttachments(array('id_attach' => $attachID));
1566
+		foreach ($_SESSION['already_attached'] as $attachID => $attachment) {
1567
+					removeAttachments(array('id_attach' => $attachID));
1568
+		}
1499 1569
 
1500 1570
 		unset($_SESSION['already_attached']);
1501 1571
 
@@ -1518,12 +1588,14 @@  discard block
 block discarded – undo
1518 1588
 		$smcFunc['db_free_result']($request);
1519 1589
 
1520 1590
 		// Though the topic should be there, it might have vanished.
1521
-		if (!is_array($topic_info))
1522
-			fatal_lang_error('topic_doesnt_exist', 404);
1591
+		if (!is_array($topic_info)) {
1592
+					fatal_lang_error('topic_doesnt_exist', 404);
1593
+		}
1523 1594
 
1524 1595
 		// Did this topic suddenly move? Just checking...
1525
-		if ($topic_info['id_board'] != $board)
1526
-			fatal_lang_error('not_a_topic');
1596
+		if ($topic_info['id_board'] != $board) {
1597
+					fatal_lang_error('not_a_topic');
1598
+		}
1527 1599
 
1528 1600
 		// Do the permissions and approval stuff...
1529 1601
 		$becomesApproved = true;
@@ -1546,49 +1618,50 @@  discard block
 block discarded – undo
1546 1618
 	if (!empty($topic) && !isset($_REQUEST['msg']))
1547 1619
 	{
1548 1620
 		// Don't allow a post if it's locked.
1549
-		if ($topic_info['locked'] != 0 && !allowedTo('moderate_board'))
1550
-			fatal_lang_error('topic_locked', false);
1621
+		if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) {
1622
+					fatal_lang_error('topic_locked', false);
1623
+		}
1551 1624
 
1552 1625
 		// Sorry, multiple polls aren't allowed... yet.  You should stop giving me ideas :P.
1553
-		if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0)
1554
-			unset($_REQUEST['poll']);
1555
-
1556
-		elseif ($topic_info['id_member_started'] != $user_info['id'])
1557
-		{
1558
-			if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any'))
1559
-				$becomesApproved = false;
1560
-
1561
-			else
1562
-				isAllowedTo('post_reply_any');
1563
-		}
1564
-		elseif (!allowedTo('post_reply_any'))
1626
+		if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) {
1627
+					unset($_REQUEST['poll']);
1628
+		} elseif ($topic_info['id_member_started'] != $user_info['id'])
1629
+		{
1630
+			if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) {
1631
+							$becomesApproved = false;
1632
+			} else {
1633
+							isAllowedTo('post_reply_any');
1634
+			}
1635
+		} elseif (!allowedTo('post_reply_any'))
1565 1636
 		{
1566
-			if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own'))
1567
-				$becomesApproved = false;
1568
-
1569
-			else
1570
-				isAllowedTo('post_reply_own');
1637
+			if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) {
1638
+							$becomesApproved = false;
1639
+			} else {
1640
+							isAllowedTo('post_reply_own');
1641
+			}
1571 1642
 		}
1572 1643
 
1573 1644
 		if (isset($_POST['lock']))
1574 1645
 		{
1575 1646
 			// Nothing is changed to the lock.
1576
-			if (empty($topic_info['locked']) == empty($_POST['lock']))
1577
-				unset($_POST['lock']);
1647
+			if (empty($topic_info['locked']) == empty($_POST['lock'])) {
1648
+							unset($_POST['lock']);
1649
+			}
1578 1650
 
1579 1651
 			// You're have no permission to lock this topic.
1580
-			elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started']))
1581
-				unset($_POST['lock']);
1652
+			elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) {
1653
+							unset($_POST['lock']);
1654
+			}
1582 1655
 
1583 1656
 			// You are allowed to (un)lock your own topic only.
1584 1657
 			elseif (!allowedTo('lock_any'))
1585 1658
 			{
1586 1659
 				// You cannot override a moderator lock.
1587
-				if ($topic_info['locked'] == 1)
1588
-					unset($_POST['lock']);
1589
-
1590
-				else
1591
-					$_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
1660
+				if ($topic_info['locked'] == 1) {
1661
+									unset($_POST['lock']);
1662
+				} else {
1663
+									$_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
1664
+				}
1592 1665
 			}
1593 1666
 			// Hail mighty moderator, (un)lock this topic immediately.
1594 1667
 			else
@@ -1596,19 +1669,21 @@  discard block
 block discarded – undo
1596 1669
 				$_POST['lock'] = empty($_POST['lock']) ? 0 : 1;
1597 1670
 
1598 1671
 				// Did someone (un)lock this while you were posting?
1599
-				if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked'])
1600
-					$post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked';
1672
+				if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) {
1673
+									$post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked';
1674
+				}
1601 1675
 			}
1602 1676
 		}
1603 1677
 
1604 1678
 		// So you wanna (un)sticky this...let's see.
1605
-		if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky')))
1606
-			unset($_POST['sticky']);
1607
-		elseif (isset($_POST['sticky']))
1679
+		if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) {
1680
+					unset($_POST['sticky']);
1681
+		} elseif (isset($_POST['sticky']))
1608 1682
 		{
1609 1683
 			// Did someone (un)sticky this while you were posting?
1610
-			if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky'])
1611
-				$post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky';
1684
+			if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) {
1685
+							$post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky';
1686
+			}
1612 1687
 		}
1613 1688
 
1614 1689
 		// If drafts are enabled, then pass this off
@@ -1635,26 +1710,31 @@  discard block
 block discarded – undo
1635 1710
 
1636 1711
 		// Do like, the permissions, for safety and stuff...
1637 1712
 		$becomesApproved = true;
1638
-		if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics'))
1639
-			$becomesApproved = false;
1640
-		else
1641
-			isAllowedTo('post_new');
1713
+		if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) {
1714
+					$becomesApproved = false;
1715
+		} else {
1716
+					isAllowedTo('post_new');
1717
+		}
1642 1718
 
1643 1719
 		if (isset($_POST['lock']))
1644 1720
 		{
1645 1721
 			// New topics are by default not locked.
1646
-			if (empty($_POST['lock']))
1647
-				unset($_POST['lock']);
1722
+			if (empty($_POST['lock'])) {
1723
+							unset($_POST['lock']);
1724
+			}
1648 1725
 			// Besides, you need permission.
1649
-			elseif (!allowedTo(array('lock_any', 'lock_own')))
1650
-				unset($_POST['lock']);
1726
+			elseif (!allowedTo(array('lock_any', 'lock_own'))) {
1727
+							unset($_POST['lock']);
1728
+			}
1651 1729
 			// A moderator-lock (1) can override a user-lock (2).
1652
-			else
1653
-				$_POST['lock'] = allowedTo('lock_any') ? 1 : 2;
1730
+			else {
1731
+							$_POST['lock'] = allowedTo('lock_any') ? 1 : 2;
1732
+			}
1654 1733
 		}
1655 1734
 
1656
-		if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky')))
1657
-			unset($_POST['sticky']);
1735
+		if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) {
1736
+					unset($_POST['sticky']);
1737
+		}
1658 1738
 
1659 1739
 		// Saving your new topic as a draft first?
1660 1740
 		if (!empty($modSettings['drafts_post_enabled']) && isset($_POST['save_draft']))
@@ -1679,31 +1759,37 @@  discard block
 block discarded – undo
1679 1759
 				'id_msg' => $_REQUEST['msg'],
1680 1760
 			)
1681 1761
 		);
1682
-		if ($smcFunc['db_num_rows']($request) == 0)
1683
-			fatal_lang_error('cant_find_messages', false);
1762
+		if ($smcFunc['db_num_rows']($request) == 0) {
1763
+					fatal_lang_error('cant_find_messages', false);
1764
+		}
1684 1765
 		$row = $smcFunc['db_fetch_assoc']($request);
1685 1766
 		$smcFunc['db_free_result']($request);
1686 1767
 
1687
-		if (!empty($topic_info['locked']) && !allowedTo('moderate_board'))
1688
-			fatal_lang_error('topic_locked', false);
1768
+		if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) {
1769
+					fatal_lang_error('topic_locked', false);
1770
+		}
1689 1771
 
1690 1772
 		if (isset($_POST['lock']))
1691 1773
 		{
1692 1774
 			// Nothing changes to the lock status.
1693
-			if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked'])))
1694
-				unset($_POST['lock']);
1775
+			if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) {
1776
+							unset($_POST['lock']);
1777
+			}
1695 1778
 			// You're simply not allowed to (un)lock this.
1696
-			elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started']))
1697
-				unset($_POST['lock']);
1779
+			elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) {
1780
+							unset($_POST['lock']);
1781
+			}
1698 1782
 			// You're only allowed to lock your own topics.
1699 1783
 			elseif (!allowedTo('lock_any'))
1700 1784
 			{
1701 1785
 				// You're not allowed to break a moderator's lock.
1702
-				if ($topic_info['locked'] == 1)
1703
-					unset($_POST['lock']);
1786
+				if ($topic_info['locked'] == 1) {
1787
+									unset($_POST['lock']);
1788
+				}
1704 1789
 				// Lock it with a soft lock or unlock it.
1705
-				else
1706
-					$_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
1790
+				else {
1791
+									$_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
1792
+				}
1707 1793
 			}
1708 1794
 			// You must be the moderator.
1709 1795
 			else
@@ -1711,44 +1797,46 @@  discard block
 block discarded – undo
1711 1797
 				$_POST['lock'] = empty($_POST['lock']) ? 0 : 1;
1712 1798
 
1713 1799
 				// Did someone (un)lock this while you were posting?
1714
-				if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked'])
1715
-					$post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked';
1800
+				if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) {
1801
+									$post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked';
1802
+				}
1716 1803
 			}
1717 1804
 		}
1718 1805
 
1719 1806
 		// Change the sticky status of this topic?
1720
-		if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky']))
1721
-			unset($_POST['sticky']);
1722
-		elseif (isset($_POST['sticky']))
1807
+		if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) {
1808
+					unset($_POST['sticky']);
1809
+		} elseif (isset($_POST['sticky']))
1723 1810
 		{
1724 1811
 			// Did someone (un)sticky this while you were posting?
1725
-			if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky'])
1726
-				$post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied';
1812
+			if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) {
1813
+							$post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied';
1814
+			}
1727 1815
 		}
1728 1816
 
1729 1817
 		if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any'))
1730 1818
 		{
1731
-			if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time())
1732
-				fatal_lang_error('modify_post_time_passed', false);
1733
-			elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own'))
1734
-				isAllowedTo('modify_replies');
1735
-			else
1736
-				isAllowedTo('modify_own');
1737
-		}
1738
-		elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any'))
1819
+			if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) {
1820
+							fatal_lang_error('modify_post_time_passed', false);
1821
+			} elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) {
1822
+							isAllowedTo('modify_replies');
1823
+			} else {
1824
+							isAllowedTo('modify_own');
1825
+			}
1826
+		} elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any'))
1739 1827
 		{
1740 1828
 			isAllowedTo('modify_replies');
1741 1829
 
1742 1830
 			// If you're modifying a reply, I say it better be logged...
1743 1831
 			$moderationAction = true;
1744
-		}
1745
-		else
1832
+		} else
1746 1833
 		{
1747 1834
 			isAllowedTo('modify_any');
1748 1835
 
1749 1836
 			// Log it, assuming you're not modifying your own post.
1750
-			if ($row['id_member'] != $user_info['id'])
1751
-				$moderationAction = true;
1837
+			if ($row['id_member'] != $user_info['id']) {
1838
+							$moderationAction = true;
1839
+			}
1752 1840
 		}
1753 1841
 
1754 1842
 		// If drafts are enabled, then lets send this off to save
@@ -1775,8 +1863,9 @@  discard block
 block discarded – undo
1775 1863
 		// Update search api
1776 1864
 		require_once($sourcedir . '/Search.php');
1777 1865
 		$searchAPI = findSearchAPI();
1778
-		if ($searchAPI->supportsMethod('postRemoved'))
1779
-			$searchAPI->postRemoved($_REQUEST['msg']);
1866
+		if ($searchAPI->supportsMethod('postRemoved')) {
1867
+					$searchAPI->postRemoved($_REQUEST['msg']);
1868
+		}
1780 1869
 
1781 1870
 	}
1782 1871
 
@@ -1794,20 +1883,24 @@  discard block
 block discarded – undo
1794 1883
 		$_POST['guestname'] = !isset($_POST['guestname']) ? '' : trim($_POST['guestname']);
1795 1884
 		$_POST['email'] = !isset($_POST['email']) ? '' : trim($_POST['email']);
1796 1885
 
1797
-		if ($_POST['guestname'] == '' || $_POST['guestname'] == '_')
1798
-			$post_errors[] = 'no_name';
1799
-		if ($smcFunc['strlen']($_POST['guestname']) > 25)
1800
-			$post_errors[] = 'long_name';
1886
+		if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') {
1887
+					$post_errors[] = 'no_name';
1888
+		}
1889
+		if ($smcFunc['strlen']($_POST['guestname']) > 25) {
1890
+					$post_errors[] = 'long_name';
1891
+		}
1801 1892
 
1802 1893
 		if (empty($modSettings['guest_post_no_email']))
1803 1894
 		{
1804 1895
 			// Only check if they changed it!
1805 1896
 			if (!isset($row) || $row['poster_email'] != $_POST['email'])
1806 1897
 			{
1807
-				if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == ''))
1808
-					$post_errors[] = 'no_email';
1809
-				if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL))
1810
-					$post_errors[] = 'bad_email';
1898
+				if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) {
1899
+									$post_errors[] = 'no_email';
1900
+				}
1901
+				if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
1902
+									$post_errors[] = 'bad_email';
1903
+				}
1811 1904
 			}
1812 1905
 
1813 1906
 			// Now make sure this email address is not banned from posting.
@@ -1823,76 +1916,90 @@  discard block
 block discarded – undo
1823 1916
 	}
1824 1917
 
1825 1918
 	// Coming from the quickReply?
1826
-	if (isset($_POST['quickReply']))
1827
-		$_POST['message'] = $_POST['quickReply'];
1919
+	if (isset($_POST['quickReply'])) {
1920
+			$_POST['message'] = $_POST['quickReply'];
1921
+	}
1828 1922
 
1829 1923
 	// Check the subject and message.
1830
-	if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '')
1831
-		$post_errors[] = 'no_subject';
1832
-	if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '')
1833
-		$post_errors[] = 'no_message';
1834
-	elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength'])
1835
-		$post_errors[] = array('long_message', array($modSettings['max_messageLength']));
1836
-	else
1924
+	if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') {
1925
+			$post_errors[] = 'no_subject';
1926
+	}
1927
+	if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') {
1928
+			$post_errors[] = 'no_message';
1929
+	} elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) {
1930
+			$post_errors[] = array('long_message', array($modSettings['max_messageLength']));
1931
+	} else
1837 1932
 	{
1838 1933
 		// Prepare the message a bit for some additional testing.
1839 1934
 		$_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES);
1840 1935
 
1841 1936
 		// Preparse code. (Zef)
1842
-		if ($user_info['is_guest'])
1843
-			$user_info['name'] = $_POST['guestname'];
1937
+		if ($user_info['is_guest']) {
1938
+					$user_info['name'] = $_POST['guestname'];
1939
+		}
1844 1940
 		preparsecode($_POST['message']);
1845 1941
 
1846 1942
 		// Let's see if there's still some content left without the tags.
1847
-		if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false))
1848
-			$post_errors[] = 'no_message';
1943
+		if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) {
1944
+					$post_errors[] = 'no_message';
1945
+		}
1849 1946
 
1850 1947
 	}
1851
-	if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '')
1852
-		$post_errors[] = 'no_event';
1948
+	if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') {
1949
+			$post_errors[] = 'no_event';
1950
+	}
1853 1951
 	// You are not!
1854
-	if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin'])
1855
-		fatal_error('Knave! Masquerader! Charlatan!', false);
1952
+	if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) {
1953
+			fatal_error('Knave! Masquerader! Charlatan!', false);
1954
+	}
1856 1955
 
1857 1956
 	// Validate the poll...
1858 1957
 	if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1')
1859 1958
 	{
1860
-		if (!empty($topic) && !isset($_REQUEST['msg']))
1861
-			fatal_lang_error('no_access', false);
1959
+		if (!empty($topic) && !isset($_REQUEST['msg'])) {
1960
+					fatal_lang_error('no_access', false);
1961
+		}
1862 1962
 
1863 1963
 		// This is a new topic... so it's a new poll.
1864
-		if (empty($topic))
1865
-			isAllowedTo('poll_post');
1964
+		if (empty($topic)) {
1965
+					isAllowedTo('poll_post');
1966
+		}
1866 1967
 		// Can you add to your own topics?
1867
-		elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any'))
1868
-			isAllowedTo('poll_add_own');
1968
+		elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) {
1969
+					isAllowedTo('poll_add_own');
1970
+		}
1869 1971
 		// Can you add polls to any topic, then?
1870
-		else
1871
-			isAllowedTo('poll_add_any');
1972
+		else {
1973
+					isAllowedTo('poll_add_any');
1974
+		}
1872 1975
 
1873
-		if (!isset($_POST['question']) || trim($_POST['question']) == '')
1874
-			$post_errors[] = 'no_question';
1976
+		if (!isset($_POST['question']) || trim($_POST['question']) == '') {
1977
+					$post_errors[] = 'no_question';
1978
+		}
1875 1979
 
1876 1980
 		$_POST['options'] = empty($_POST['options']) ? array() : htmltrim__recursive($_POST['options']);
1877 1981
 
1878 1982
 		// Get rid of empty ones.
1879
-		foreach ($_POST['options'] as $k => $option)
1880
-			if ($option == '')
1983
+		foreach ($_POST['options'] as $k => $option) {
1984
+					if ($option == '')
1881 1985
 				unset($_POST['options'][$k], $_POST['options'][$k]);
1986
+		}
1882 1987
 
1883 1988
 		// What are you going to vote between with one choice?!?
1884
-		if (count($_POST['options']) < 2)
1885
-			$post_errors[] = 'poll_few';
1886
-		elseif (count($_POST['options']) > 256)
1887
-			$post_errors[] = 'poll_many';
1989
+		if (count($_POST['options']) < 2) {
1990
+					$post_errors[] = 'poll_few';
1991
+		} elseif (count($_POST['options']) > 256) {
1992
+					$post_errors[] = 'poll_many';
1993
+		}
1888 1994
 	}
1889 1995
 
1890 1996
 	if ($posterIsGuest)
1891 1997
 	{
1892 1998
 		// If user is a guest, make sure the chosen name isn't taken.
1893 1999
 		require_once($sourcedir . '/Subs-Members.php');
1894
-		if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name']))
1895
-			$post_errors[] = 'bad_name';
2000
+		if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) {
2001
+					$post_errors[] = 'bad_name';
2002
+		}
1896 2003
 	}
1897 2004
 	// If the user isn't a guest, get his or her name and email.
1898 2005
 	elseif (!isset($_REQUEST['msg']))
@@ -1923,8 +2030,9 @@  discard block
 block discarded – undo
1923 2030
 	}
1924 2031
 
1925 2032
 	// Make sure the user isn't spamming the board.
1926
-	if (!isset($_REQUEST['msg']))
1927
-		spamProtection('post');
2033
+	if (!isset($_REQUEST['msg'])) {
2034
+			spamProtection('post');
2035
+	}
1928 2036
 
1929 2037
 	// At about this point, we're posting and that's that.
1930 2038
 	ignore_user_abort(true);
@@ -1937,32 +2045,36 @@  discard block
 block discarded – undo
1937 2045
 	$_POST['modify_reason'] = empty($_POST['modify_reason']) ? '' : strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => ''));
1938 2046
 
1939 2047
 	// At this point, we want to make sure the subject isn't too long.
1940
-	if ($smcFunc['strlen']($_POST['subject']) > 100)
1941
-		$_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100);
2048
+	if ($smcFunc['strlen']($_POST['subject']) > 100) {
2049
+			$_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100);
2050
+	}
1942 2051
 
1943 2052
 	// Same with the "why did you edit this" text.
1944
-	if ($smcFunc['strlen']($_POST['modify_reason']) > 100)
1945
-		$_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100);
2053
+	if ($smcFunc['strlen']($_POST['modify_reason']) > 100) {
2054
+			$_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100);
2055
+	}
1946 2056
 
1947 2057
 	// Make the poll...
1948 2058
 	if (isset($_REQUEST['poll']))
1949 2059
 	{
1950 2060
 		// Make sure that the user has not entered a ridiculous number of options..
1951
-		if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0)
1952
-			$_POST['poll_max_votes'] = 1;
1953
-		elseif ($_POST['poll_max_votes'] > count($_POST['options']))
1954
-			$_POST['poll_max_votes'] = count($_POST['options']);
1955
-		else
1956
-			$_POST['poll_max_votes'] = (int) $_POST['poll_max_votes'];
2061
+		if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) {
2062
+					$_POST['poll_max_votes'] = 1;
2063
+		} elseif ($_POST['poll_max_votes'] > count($_POST['options'])) {
2064
+					$_POST['poll_max_votes'] = count($_POST['options']);
2065
+		} else {
2066
+					$_POST['poll_max_votes'] = (int) $_POST['poll_max_votes'];
2067
+		}
1957 2068
 
1958 2069
 		$_POST['poll_expire'] = (int) $_POST['poll_expire'];
1959 2070
 		$_POST['poll_expire'] = $_POST['poll_expire'] > 9999 ? 9999 : ($_POST['poll_expire'] < 0 ? 0 : $_POST['poll_expire']);
1960 2071
 
1961 2072
 		// Just set it to zero if it's not there..
1962
-		if (!isset($_POST['poll_hide']))
1963
-			$_POST['poll_hide'] = 0;
1964
-		else
1965
-			$_POST['poll_hide'] = (int) $_POST['poll_hide'];
2073
+		if (!isset($_POST['poll_hide'])) {
2074
+					$_POST['poll_hide'] = 0;
2075
+		} else {
2076
+					$_POST['poll_hide'] = (int) $_POST['poll_hide'];
2077
+		}
1966 2078
 		$_POST['poll_change_vote'] = isset($_POST['poll_change_vote']) ? 1 : 0;
1967 2079
 
1968 2080
 		$_POST['poll_guest_vote'] = isset($_POST['poll_guest_vote']) ? 1 : 0;
@@ -1971,16 +2083,19 @@  discard block
 block discarded – undo
1971 2083
 		{
1972 2084
 			require_once($sourcedir . '/Subs-Members.php');
1973 2085
 			$allowedVoteGroups = groupsAllowedTo('poll_vote', $board);
1974
-			if (!in_array(-1, $allowedVoteGroups['allowed']))
1975
-				$_POST['poll_guest_vote'] = 0;
2086
+			if (!in_array(-1, $allowedVoteGroups['allowed'])) {
2087
+							$_POST['poll_guest_vote'] = 0;
2088
+			}
1976 2089
 		}
1977 2090
 
1978 2091
 		// If the user tries to set the poll too far in advance, don't let them.
1979
-		if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1)
1980
-			fatal_lang_error('poll_range_error', false);
2092
+		if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) {
2093
+					fatal_lang_error('poll_range_error', false);
2094
+		}
1981 2095
 		// Don't allow them to select option 2 for hidden results if it's not time limited.
1982
-		elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2)
1983
-			$_POST['poll_hide'] = 1;
2096
+		elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) {
2097
+					$_POST['poll_hide'] = 1;
2098
+		}
1984 2099
 
1985 2100
 		// Clean up the question and answers.
1986 2101
 		$_POST['question'] = $smcFunc['htmlspecialchars']($_POST['question']);
@@ -1994,13 +2109,15 @@  discard block
 block discarded – undo
1994 2109
 	{
1995 2110
 		$attachIDs = array();
1996 2111
 		$attach_errors = array();
1997
-		if (!empty($context['we_are_history']))
1998
-			$attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>';
2112
+		if (!empty($context['we_are_history'])) {
2113
+					$attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>';
2114
+		}
1999 2115
 
2000 2116
 		foreach ($_SESSION['temp_attachments'] as  $attachID => $attachment)
2001 2117
 		{
2002
-			if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false)
2003
-				continue;
2118
+			if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) {
2119
+							continue;
2120
+			}
2004 2121
 
2005 2122
 			// If there was an initial error just show that message.
2006 2123
 			if ($attachID == 'initial_error')
@@ -2029,12 +2146,13 @@  discard block
 block discarded – undo
2029 2146
 				if (createAttachment($attachmentOptions))
2030 2147
 				{
2031 2148
 					$attachIDs[] = $attachmentOptions['id'];
2032
-					if (!empty($attachmentOptions['thumb']))
2033
-						$attachIDs[] = $attachmentOptions['thumb'];
2149
+					if (!empty($attachmentOptions['thumb'])) {
2150
+											$attachIDs[] = $attachmentOptions['thumb'];
2151
+					}
2034 2152
 				}
2153
+			} else {
2154
+							$attach_errors[] = '<dt>&nbsp;</dt>';
2035 2155
 			}
2036
-			else
2037
-				$attach_errors[] = '<dt>&nbsp;</dt>';
2038 2156
 
2039 2157
 			if (!empty($attachmentOptions['errors']))
2040 2158
 			{
@@ -2046,14 +2164,16 @@  discard block
 block discarded – undo
2046 2164
 					if (!is_array($error))
2047 2165
 					{
2048 2166
 						$attach_errors[] = '<dd>' . $txt[$error] . '</dd>';
2049
-						if (in_array($error, $log_these))
2050
-							log_error($attachment['name'] . ': ' . $txt[$error], 'critical');
2167
+						if (in_array($error, $log_these)) {
2168
+													log_error($attachment['name'] . ': ' . $txt[$error], 'critical');
2169
+						}
2170
+					} else {
2171
+											$attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>';
2051 2172
 					}
2052
-					else
2053
-						$attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>';
2054 2173
 				}
2055
-				if (file_exists($attachment['tmp_name']))
2056
-					unlink($attachment['tmp_name']);
2174
+				if (file_exists($attachment['tmp_name'])) {
2175
+									unlink($attachment['tmp_name']);
2176
+				}
2057 2177
 			}
2058 2178
 		}
2059 2179
 		unset($_SESSION['temp_attachments']);
@@ -2094,24 +2214,24 @@  discard block
 block discarded – undo
2094 2214
 		);
2095 2215
 
2096 2216
 		call_integration_hook('integrate_poll_add_edit', array($id_poll, false));
2217
+	} else {
2218
+			$id_poll = 0;
2097 2219
 	}
2098
-	else
2099
-		$id_poll = 0;
2100 2220
 
2101 2221
 	// Creating a new topic?
2102 2222
 	$newTopic = empty($_REQUEST['msg']) && empty($topic);
2103 2223
 
2104 2224
 	// Check the icon.
2105
-	if (!isset($_POST['icon']))
2106
-		$_POST['icon'] = 'xx';
2107
-
2108
-	else
2225
+	if (!isset($_POST['icon'])) {
2226
+			$_POST['icon'] = 'xx';
2227
+	} else
2109 2228
 	{
2110 2229
 		$_POST['icon'] = $smcFunc['htmlspecialchars']($_POST['icon']);
2111 2230
 
2112 2231
 		// Need to figure it out if this is a valid icon name.
2113
-		if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')))
2114
-			$_POST['icon'] = 'xx';
2232
+		if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) {
2233
+					$_POST['icon'] = 'xx';
2234
+		}
2115 2235
 	}
2116 2236
 
2117 2237
 	// Collect all parameters for the creation or modification of a post.
@@ -2152,8 +2272,9 @@  discard block
 block discarded – undo
2152 2272
 		}
2153 2273
 
2154 2274
 		// This will save some time...
2155
-		if (empty($approve_has_changed))
2156
-			unset($msgOptions['approved']);
2275
+		if (empty($approve_has_changed)) {
2276
+					unset($msgOptions['approved']);
2277
+		}
2157 2278
 
2158 2279
 		modifyPost($msgOptions, $topicOptions, $posterOptions);
2159 2280
 	}
@@ -2162,8 +2283,9 @@  discard block
 block discarded – undo
2162 2283
 	{
2163 2284
 		createPost($msgOptions, $topicOptions, $posterOptions);
2164 2285
 
2165
-		if (isset($topicOptions['id']))
2166
-			$topic = $topicOptions['id'];
2286
+		if (isset($topicOptions['id'])) {
2287
+					$topic = $topicOptions['id'];
2288
+		}
2167 2289
 	}
2168 2290
 
2169 2291
 	// Are there attachments already uploaded and waiting to be assigned?
@@ -2175,8 +2297,9 @@  discard block
 block discarded – undo
2175 2297
 	}
2176 2298
 
2177 2299
 	// If we had a draft for this, its time to remove it since it was just posted
2178
-	if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft']))
2179
-		DeleteDraft($_POST['id_draft']);
2300
+	if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) {
2301
+			DeleteDraft($_POST['id_draft']);
2302
+	}
2180 2303
 
2181 2304
 	// Editing or posting an event?
2182 2305
 	if (isset($_POST['calendar']) && (!isset($_REQUEST['eventid']) || $_REQUEST['eventid'] == -1))
@@ -2195,8 +2318,7 @@  discard block
 block discarded – undo
2195 2318
 			'member' => $user_info['id'],
2196 2319
 		);
2197 2320
 		insertEvent($eventOptions);
2198
-	}
2199
-	elseif (isset($_POST['calendar']))
2321
+	} elseif (isset($_POST['calendar']))
2200 2322
 	{
2201 2323
 		$_REQUEST['eventid'] = (int) $_REQUEST['eventid'];
2202 2324
 
@@ -2224,14 +2346,15 @@  discard block
 block discarded – undo
2224 2346
 		}
2225 2347
 
2226 2348
 		// Delete it?
2227
-		if (isset($_REQUEST['deleteevent']))
2228
-			$smcFunc['db_query']('', '
2349
+		if (isset($_REQUEST['deleteevent'])) {
2350
+					$smcFunc['db_query']('', '
2229 2351
 				DELETE FROM {db_prefix}calendar
2230 2352
 				WHERE id_event = {int:id_event}',
2231 2353
 				array(
2232 2354
 					'id_event' => $_REQUEST['eventid'],
2233 2355
 				)
2234 2356
 			);
2357
+		}
2235 2358
 		// ... or just update it?
2236 2359
 		else
2237 2360
 		{
@@ -2273,9 +2396,8 @@  discard block
 block discarded – undo
2273 2396
 			array($user_info['id'], $topic, 0),
2274 2397
 			array('id_member', 'id_topic', 'id_board')
2275 2398
 		);
2276
-	}
2277
-	elseif (!$newTopic)
2278
-		$smcFunc['db_query']('', '
2399
+	} elseif (!$newTopic) {
2400
+			$smcFunc['db_query']('', '
2279 2401
 			DELETE FROM {db_prefix}log_notify
2280 2402
 			WHERE id_member = {int:current_member}
2281 2403
 				AND id_topic = {int:current_topic}',
@@ -2284,16 +2406,20 @@  discard block
 block discarded – undo
2284 2406
 				'current_topic' => $topic,
2285 2407
 			)
2286 2408
 		);
2409
+	}
2287 2410
 
2288 2411
 	// Log an act of moderation - modifying.
2289
-	if (!empty($moderationAction))
2290
-		logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board));
2412
+	if (!empty($moderationAction)) {
2413
+			logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board));
2414
+	}
2291 2415
 
2292
-	if (isset($_POST['lock']) && $_POST['lock'] != 2)
2293
-		logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board']));
2416
+	if (isset($_POST['lock']) && $_POST['lock'] != 2) {
2417
+			logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board']));
2418
+	}
2294 2419
 
2295
-	if (isset($_POST['sticky']))
2296
-		logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board']));
2420
+	if (isset($_POST['sticky'])) {
2421
+			logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board']));
2422
+	}
2297 2423
 
2298 2424
 	// Returning to the topic?
2299 2425
 	if (!empty($_REQUEST['goback']))
@@ -2312,26 +2438,31 @@  discard block
 block discarded – undo
2312 2438
 		);
2313 2439
 	}
2314 2440
 
2315
-	if ($board_info['num_topics'] == 0)
2316
-		cache_put_data('board-' . $board, null, 120);
2441
+	if ($board_info['num_topics'] == 0) {
2442
+			cache_put_data('board-' . $board, null, 120);
2443
+	}
2317 2444
 
2318 2445
 	call_integration_hook('integrate_post2_end');
2319 2446
 
2320
-	if (!empty($_POST['announce_topic']) && allowedTo('announce_topic'))
2321
-		redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback'));
2447
+	if (!empty($_POST['announce_topic']) && allowedTo('announce_topic')) {
2448
+			redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback'));
2449
+	}
2322 2450
 
2323
-	if (!empty($_POST['move']) && allowedTo('move_any'))
2324
-		redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback'));
2451
+	if (!empty($_POST['move']) && allowedTo('move_any')) {
2452
+			redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback'));
2453
+	}
2325 2454
 
2326 2455
 	// Return to post if the mod is on.
2327
-	if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback']))
2328
-		redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie'));
2329
-	elseif (!empty($_REQUEST['goback']))
2330
-		redirectexit('topic=' . $topic . '.new#new', isBrowser('ie'));
2456
+	if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) {
2457
+			redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie'));
2458
+	} elseif (!empty($_REQUEST['goback'])) {
2459
+			redirectexit('topic=' . $topic . '.new#new', isBrowser('ie'));
2460
+	}
2331 2461
 	// Dut-dut-duh-duh-DUH-duh-dut-duh-duh!  *dances to the Final Fantasy Fanfare...*
2332
-	else
2333
-		redirectexit('board=' . $board . '.0');
2334
-}
2462
+	else {
2463
+			redirectexit('board=' . $board . '.0');
2464
+	}
2465
+	}
2335 2466
 
2336 2467
 /**
2337 2468
  * Handle the announce topic function (action=announce).
@@ -2349,8 +2480,9 @@  discard block
 block discarded – undo
2349 2480
 
2350 2481
 	validateSession();
2351 2482
 
2352
-	if (empty($topic))
2353
-		fatal_lang_error('topic_gone', false);
2483
+	if (empty($topic)) {
2484
+			fatal_lang_error('topic_gone', false);
2485
+	}
2354 2486
 
2355 2487
 	loadLanguage('Post');
2356 2488
 	loadTemplate('Post');
@@ -2377,8 +2509,9 @@  discard block
 block discarded – undo
2377 2509
 	global $txt, $context, $topic, $board_info, $smcFunc;
2378 2510
 
2379 2511
 	$groups = array_merge($board_info['groups'], array(1));
2380
-	foreach ($groups as $id => $group)
2381
-		$groups[$id] = (int) $group;
2512
+	foreach ($groups as $id => $group) {
2513
+			$groups[$id] = (int) $group;
2514
+	}
2382 2515
 
2383 2516
 	$context['groups'] = array();
2384 2517
 	if (in_array(0, $groups))
@@ -2421,8 +2554,9 @@  discard block
 block discarded – undo
2421 2554
 			'group_list' => $groups,
2422 2555
 		)
2423 2556
 	);
2424
-	while ($row = $smcFunc['db_fetch_assoc']($request))
2425
-		$context['groups'][$row['id_group']]['name'] = $row['group_name'];
2557
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
2558
+			$context['groups'][$row['id_group']]['name'] = $row['group_name'];
2559
+	}
2426 2560
 	$smcFunc['db_free_result']($request);
2427 2561
 
2428 2562
 	// Get the subject of the topic we're about to announce.
@@ -2464,16 +2598,19 @@  discard block
 block discarded – undo
2464 2598
 	$context['start'] = empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start'];
2465 2599
 	$groups = array_merge($board_info['groups'], array(1));
2466 2600
 
2467
-	if (isset($_POST['membergroups']))
2468
-		$_POST['who'] = explode(',', $_POST['membergroups']);
2601
+	if (isset($_POST['membergroups'])) {
2602
+			$_POST['who'] = explode(',', $_POST['membergroups']);
2603
+	}
2469 2604
 
2470 2605
 	// Check whether at least one membergroup was selected.
2471
-	if (empty($_POST['who']))
2472
-		fatal_lang_error('no_membergroup_selected');
2606
+	if (empty($_POST['who'])) {
2607
+			fatal_lang_error('no_membergroup_selected');
2608
+	}
2473 2609
 
2474 2610
 	// Make sure all membergroups are integers and can access the board of the announcement.
2475
-	foreach ($_POST['who'] as $id => $mg)
2476
-		$_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0;
2611
+	foreach ($_POST['who'] as $id => $mg) {
2612
+			$_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0;
2613
+	}
2477 2614
 
2478 2615
 	// Get the topic subject and censor it.
2479 2616
 	$request = $smcFunc['db_query']('', '
@@ -2519,12 +2656,13 @@  discard block
 block discarded – undo
2519 2656
 	if ($smcFunc['db_num_rows']($request) == 0)
2520 2657
 	{
2521 2658
 		logAction('announce_topic', array('topic' => $topic), 'user');
2522
-		if (!empty($_REQUEST['move']) && allowedTo('move_any'))
2523
-			redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback'));
2524
-		elseif (!empty($_REQUEST['goback']))
2525
-			redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie'));
2526
-		else
2527
-			redirectexit('board=' . $board . '.0');
2659
+		if (!empty($_REQUEST['move']) && allowedTo('move_any')) {
2660
+					redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback'));
2661
+		} elseif (!empty($_REQUEST['goback'])) {
2662
+					redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie'));
2663
+		} else {
2664
+					redirectexit('board=' . $board . '.0');
2665
+		}
2528 2666
 	}
2529 2667
 
2530 2668
 	$announcements = array();
@@ -2543,8 +2681,9 @@  discard block
 block discarded – undo
2543 2681
 	foreach ($rows as $row)
2544 2682
 	{
2545 2683
 		// Force them to have it?
2546
-		if (empty($prefs[$row['id_member']]['announcements']))
2547
-			continue;
2684
+		if (empty($prefs[$row['id_member']]['announcements'])) {
2685
+					continue;
2686
+		}
2548 2687
 
2549 2688
 		$cur_language = empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile'];
2550 2689
 
@@ -2572,8 +2711,9 @@  discard block
 block discarded – undo
2572 2711
 	}
2573 2712
 
2574 2713
 	// For each language send a different mail - low priority...
2575
-	foreach ($announcements as $lang => $mail)
2576
-		sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5);
2714
+	foreach ($announcements as $lang => $mail) {
2715
+			sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5);
2716
+	}
2577 2717
 
2578 2718
 	$context['percentage_done'] = round(100 * $context['start'] / $modSettings['latestMember'], 1);
2579 2719
 
@@ -2583,9 +2723,10 @@  discard block
 block discarded – undo
2583 2723
 	$context['sub_template'] = 'announcement_send';
2584 2724
 
2585 2725
 	// Go back to the correct language for the user ;).
2586
-	if (!empty($modSettings['userLanguage']))
2587
-		loadLanguage('Post');
2588
-}
2726
+	if (!empty($modSettings['userLanguage'])) {
2727
+			loadLanguage('Post');
2728
+	}
2729
+	}
2589 2730
 
2590 2731
 /**
2591 2732
  * Get the topic for display purposes.
@@ -2598,12 +2739,13 @@  discard block
 block discarded – undo
2598 2739
 {
2599 2740
 	global $topic, $modSettings, $context, $smcFunc, $counter, $options;
2600 2741
 
2601
-	if (isset($_REQUEST['xml']))
2602
-		$limit = '
2742
+	if (isset($_REQUEST['xml'])) {
2743
+			$limit = '
2603 2744
 		LIMIT ' . (empty($context['new_replies']) ? '0' : $context['new_replies']);
2604
-	else
2605
-		$limit = empty($modSettings['topicSummaryPosts']) ? '' : '
2745
+	} else {
2746
+			$limit = empty($modSettings['topicSummaryPosts']) ? '' : '
2606 2747
 		LIMIT ' . (int) $modSettings['topicSummaryPosts'];
2748
+	}
2607 2749
 
2608 2750
 	// If you're modifying, get only those posts before the current one. (otherwise get all.)
2609 2751
 	$request = $smcFunc['db_query']('', '
@@ -2641,8 +2783,9 @@  discard block
 block discarded – undo
2641 2783
 			'is_ignored' => !empty($modSettings['enable_buddylist']) && !empty($options['posts_apply_ignore_list']) && in_array($row['id_member'], $context['user']['ignoreusers']),
2642 2784
 		);
2643 2785
 
2644
-		if (!empty($context['new_replies']))
2645
-			$context['new_replies']--;
2786
+		if (!empty($context['new_replies'])) {
2787
+					$context['new_replies']--;
2788
+		}
2646 2789
 	}
2647 2790
 	$smcFunc['db_free_result']($request);
2648 2791
 }
@@ -2659,8 +2802,9 @@  discard block
 block discarded – undo
2659 2802
 	global $sourcedir, $smcFunc;
2660 2803
 
2661 2804
 	loadLanguage('Post');
2662
-	if (!isset($_REQUEST['xml']))
2663
-		loadTemplate('Post');
2805
+	if (!isset($_REQUEST['xml'])) {
2806
+			loadTemplate('Post');
2807
+	}
2664 2808
 
2665 2809
 	include_once($sourcedir . '/Subs-Post.php');
2666 2810
 
@@ -2691,8 +2835,9 @@  discard block
 block discarded – undo
2691 2835
 	$smcFunc['db_free_result']($request);
2692 2836
 
2693 2837
 	$context['sub_template'] = 'quotefast';
2694
-	if (!empty($row))
2695
-		$can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']);
2838
+	if (!empty($row)) {
2839
+			$can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']);
2840
+	}
2696 2841
 
2697 2842
 	if (!empty($can_view_post))
2698 2843
 	{
@@ -2725,8 +2870,9 @@  discard block
 block discarded – undo
2725 2870
 		}
2726 2871
 
2727 2872
 		// Remove any nested quotes.
2728
-		if (!empty($modSettings['removeNestedQuotes']))
2729
-			$row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']);
2873
+		if (!empty($modSettings['removeNestedQuotes'])) {
2874
+					$row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']);
2875
+		}
2730 2876
 
2731 2877
 		$lb = "\n";
2732 2878
 
@@ -2752,14 +2898,14 @@  discard block
 block discarded – undo
2752 2898
 				'time' => '',
2753 2899
 			),
2754 2900
 		);
2755
-	}
2756
-	else
2757
-		$context['quote'] = array(
2901
+	} else {
2902
+			$context['quote'] = array(
2758 2903
 			'xml' => '',
2759 2904
 			'mozilla' => '',
2760 2905
 			'text' => '',
2761 2906
 		);
2762
-}
2907
+	}
2908
+	}
2763 2909
 
2764 2910
 /**
2765 2911
  * Used to edit the body or subject of a message inline
@@ -2771,8 +2917,9 @@  discard block
 block discarded – undo
2771 2917
 	global $user_info, $context, $smcFunc, $language, $board_info;
2772 2918
 
2773 2919
 	// We have to have a topic!
2774
-	if (empty($topic))
2775
-		obExit(false);
2920
+	if (empty($topic)) {
2921
+			obExit(false);
2922
+	}
2776 2923
 
2777 2924
 	checkSession('get');
2778 2925
 	require_once($sourcedir . '/Subs-Post.php');
@@ -2798,31 +2945,35 @@  discard block
 block discarded – undo
2798 2945
 			'guest_id' => 0,
2799 2946
 		)
2800 2947
 	);
2801
-	if ($smcFunc['db_num_rows']($request) == 0)
2802
-		fatal_lang_error('no_board', false);
2948
+	if ($smcFunc['db_num_rows']($request) == 0) {
2949
+			fatal_lang_error('no_board', false);
2950
+	}
2803 2951
 	$row = $smcFunc['db_fetch_assoc']($request);
2804 2952
 	$smcFunc['db_free_result']($request);
2805 2953
 
2806 2954
 	// Change either body or subject requires permissions to modify messages.
2807 2955
 	if (isset($_POST['message']) || isset($_POST['subject']) || isset($_REQUEST['icon']))
2808 2956
 	{
2809
-		if (!empty($row['locked']))
2810
-			isAllowedTo('moderate_board');
2957
+		if (!empty($row['locked'])) {
2958
+					isAllowedTo('moderate_board');
2959
+		}
2811 2960
 
2812 2961
 		if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any'))
2813 2962
 		{
2814
-			if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time())
2815
-				fatal_lang_error('modify_post_time_passed', false);
2816
-			elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own'))
2817
-				isAllowedTo('modify_replies');
2818
-			else
2819
-				isAllowedTo('modify_own');
2963
+			if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) {
2964
+							fatal_lang_error('modify_post_time_passed', false);
2965
+			} elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) {
2966
+							isAllowedTo('modify_replies');
2967
+			} else {
2968
+							isAllowedTo('modify_own');
2969
+			}
2820 2970
 		}
2821 2971
 		// Otherwise, they're locked out; someone who can modify the replies is needed.
2822
-		elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any'))
2823
-			isAllowedTo('modify_replies');
2824
-		else
2825
-			isAllowedTo('modify_any');
2972
+		elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) {
2973
+					isAllowedTo('modify_replies');
2974
+		} else {
2975
+					isAllowedTo('modify_any');
2976
+		}
2826 2977
 
2827 2978
 		// Only log this action if it wasn't your message.
2828 2979
 		$moderationAction = $row['id_member'] != $user_info['id'];
@@ -2834,10 +2985,10 @@  discard block
 block discarded – undo
2834 2985
 		$_POST['subject'] = strtr($smcFunc['htmlspecialchars']($_POST['subject']), array("\r" => '', "\n" => '', "\t" => ''));
2835 2986
 
2836 2987
 		// Maximum number of characters.
2837
-		if ($smcFunc['strlen']($_POST['subject']) > 100)
2838
-			$_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100);
2839
-	}
2840
-	elseif (isset($_POST['subject']))
2988
+		if ($smcFunc['strlen']($_POST['subject']) > 100) {
2989
+					$_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100);
2990
+		}
2991
+	} elseif (isset($_POST['subject']))
2841 2992
 	{
2842 2993
 		$post_errors[] = 'no_subject';
2843 2994
 		unset($_POST['subject']);
@@ -2849,13 +3000,11 @@  discard block
 block discarded – undo
2849 3000
 		{
2850 3001
 			$post_errors[] = 'no_message';
2851 3002
 			unset($_POST['message']);
2852
-		}
2853
-		elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength'])
3003
+		} elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength'])
2854 3004
 		{
2855 3005
 			$post_errors[] = 'long_message';
2856 3006
 			unset($_POST['message']);
2857
-		}
2858
-		else
3007
+		} else
2859 3008
 		{
2860 3009
 			$_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES);
2861 3010
 
@@ -2871,31 +3020,34 @@  discard block
 block discarded – undo
2871 3020
 
2872 3021
 	if (isset($_POST['lock']))
2873 3022
 	{
2874
-		if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member']))
2875
-			unset($_POST['lock']);
2876
-		elseif (!allowedTo('lock_any'))
3023
+		if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) {
3024
+					unset($_POST['lock']);
3025
+		} elseif (!allowedTo('lock_any'))
2877 3026
 		{
2878
-			if ($row['locked'] == 1)
2879
-				unset($_POST['lock']);
2880
-			else
2881
-				$_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
3027
+			if ($row['locked'] == 1) {
3028
+							unset($_POST['lock']);
3029
+			} else {
3030
+							$_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
3031
+			}
3032
+		} elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) {
3033
+					unset($_POST['lock']);
3034
+		} else {
3035
+					$_POST['lock'] = empty($_POST['lock']) ? 0 : 1;
2882 3036
 		}
2883
-		elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked'])
2884
-			unset($_POST['lock']);
2885
-		else
2886
-			$_POST['lock'] = empty($_POST['lock']) ? 0 : 1;
2887 3037
 	}
2888 3038
 
2889
-	if (isset($_POST['sticky']) && !allowedTo('make_sticky'))
2890
-		unset($_POST['sticky']);
3039
+	if (isset($_POST['sticky']) && !allowedTo('make_sticky')) {
3040
+			unset($_POST['sticky']);
3041
+	}
2891 3042
 
2892 3043
 	if (isset($_POST['modify_reason']))
2893 3044
 	{
2894 3045
 		$_POST['modify_reason'] = strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => ''));
2895 3046
 
2896 3047
 		// Maximum number of characters.
2897
-		if ($smcFunc['strlen']($_POST['modify_reason']) > 100)
2898
-			$_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100);
3048
+		if ($smcFunc['strlen']($_POST['modify_reason']) > 100) {
3049
+					$_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100);
3050
+		}
2899 3051
 	}
2900 3052
 
2901 3053
 	if (empty($post_errors))
@@ -2932,8 +3084,9 @@  discard block
 block discarded – undo
2932 3084
 			}
2933 3085
 		}
2934 3086
 		// If nothing was changed there's no need to add an entry to the moderation log.
2935
-		else
2936
-			$moderationAction = false;
3087
+		else {
3088
+					$moderationAction = false;
3089
+		}
2937 3090
 
2938 3091
 		modifyPost($msgOptions, $topicOptions, $posterOptions);
2939 3092
 
@@ -2951,9 +3104,9 @@  discard block
 block discarded – undo
2951 3104
 			// Get the proper (default language) response prefix first.
2952 3105
 			if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix')))
2953 3106
 			{
2954
-				if ($language === $user_info['language'])
2955
-					$context['response_prefix'] = $txt['response_prefix'];
2956
-				else
3107
+				if ($language === $user_info['language']) {
3108
+									$context['response_prefix'] = $txt['response_prefix'];
3109
+				} else
2957 3110
 				{
2958 3111
 					loadLanguage('index', $language, false);
2959 3112
 					$context['response_prefix'] = $txt['response_prefix'];
@@ -2975,8 +3128,9 @@  discard block
 block discarded – undo
2975 3128
 			);
2976 3129
 		}
2977 3130
 
2978
-		if (!empty($moderationAction))
2979
-			logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board));
3131
+		if (!empty($moderationAction)) {
3132
+					logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board));
3133
+		}
2980 3134
 	}
2981 3135
 
2982 3136
 	if (isset($_REQUEST['xml']))
@@ -3017,8 +3171,7 @@  discard block
 block discarded – undo
3017 3171
 			);
3018 3172
 
3019 3173
 			censorText($context['message']['subject']);
3020
-		}
3021
-		else
3174
+		} else
3022 3175
 		{
3023 3176
 			$context['message'] = array(
3024 3177
 				'id' => $row['id_msg'],
@@ -3030,15 +3183,16 @@  discard block
 block discarded – undo
3030 3183
 			loadLanguage('Errors');
3031 3184
 			foreach ($post_errors as $post_error)
3032 3185
 			{
3033
-				if ($post_error == 'long_message')
3034
-					$context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']);
3035
-				else
3036
-					$context['message']['errors'][] = $txt['error_' . $post_error];
3186
+				if ($post_error == 'long_message') {
3187
+									$context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']);
3188
+				} else {
3189
+									$context['message']['errors'][] = $txt['error_' . $post_error];
3190
+				}
3037 3191
 			}
3038 3192
 		}
3193
+	} else {
3194
+			obExit(false);
3195
+	}
3039 3196
 	}
3040
-	else
3041
-		obExit(false);
3042
-}
3043 3197
 
3044 3198
 ?>
3045 3199
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/Modlog.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 					'class' => 'centercol',
257 257
 				),
258 258
 				'data' => array(
259
-					'function' => function ($entry)
259
+					'function' => function($entry)
260 260
 					{
261 261
 						return '<input type="checkbox" name="delete[]" value="' . $entry['id'] . '"' . ($entry['editable'] ? '' : ' disabled') . '>';
262 262
 					},
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
 		if (empty($entries[$k]['action_text']))
639 639
 			$entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action'];
640 640
 		$entries[$k]['action_text'] = preg_replace_callback('~\{([A-Za-z\d_]+)\}~i',
641
-			function ($matches) use ($entries, $k)
641
+			function($matches) use ($entries, $k)
642 642
 			{
643 643
 				return isset($entries[$k]['extra'][$matches[1]]) ? $entries[$k]['extra'][$matches[1]] : '';
644 644
 			}, $entries[$k]['action_text']);
Please login to merge, or discard this patch.
Braces   +99 added lines, -75 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 4
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * Prepares the information from the moderation log for viewing.
@@ -32,14 +33,16 @@  discard block
 block discarded – undo
32 33
 
33 34
 	// Are we looking at the moderation log or the administration log.
34 35
 	$context['log_type'] = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 3 : 1;
35
-	if ($context['log_type'] == 3)
36
-		isAllowedTo('admin_forum');
36
+	if ($context['log_type'] == 3) {
37
+			isAllowedTo('admin_forum');
38
+	}
37 39
 
38 40
 	// These change dependant on whether we are viewing the moderation or admin log.
39
-	if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin')
40
-		$context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type'];
41
-	else
42
-		$context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type'];
41
+	if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin') {
42
+			$context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type'];
43
+	} else {
44
+			$context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type'];
45
+	}
43 46
 
44 47
 	$context['can_delete'] = allowedTo('admin_forum');
45 48
 
@@ -67,8 +70,7 @@  discard block
 block discarded – undo
67 70
 		$log_type = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 'admin' : 'moderate';
68 71
 		logAction('clearlog_' . $log_type, array(), $log_type);
69 72
 
70
-	}
71
-	elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete'])
73
+	} elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete'])
72 74
 	{
73 75
 		checkSession();
74 76
 		validateToken('mod-ml');
@@ -114,15 +116,17 @@  discard block
 block discarded – undo
114 116
 		'ip' => array('sql' => 'lm.ip', 'label' => $txt['modlog_ip'])
115 117
 	);
116 118
 
117
-	if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search']))
118
-		$search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search'];
119
-	else
120
-		$search_params_string = $search_params['string'];
119
+	if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) {
120
+			$search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search'];
121
+	} else {
122
+			$search_params_string = $search_params['string'];
123
+	}
121 124
 
122
-	if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']]))
123
-		$search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member');
124
-	else
125
-		$search_params_type = $search_params['type'];
125
+	if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) {
126
+			$search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member');
127
+	} else {
128
+			$search_params_type = $search_params['type'];
129
+	}
126 130
 
127 131
 	$search_params_column = $searchTypes[$search_params_type]['sql'];
128 132
 	$search_params = array(
@@ -301,15 +305,16 @@  discard block
 block discarded – undo
301 305
 	$context['default_list'] = 'moderation_log_list';
302 306
 
303 307
 	// If a hook has changed this, respect it.
304
-	if (!empty($moderation_menu_name))
305
-		$context[$context['moderation_menu_name']]['tab_data'] = $moderation_menu_name;
306
-	elseif (isset($context['moderation_menu_name']))
307
-		$context[$context['moderation_menu_name']]['tab_data'] = array(
308
+	if (!empty($moderation_menu_name)) {
309
+			$context[$context['moderation_menu_name']]['tab_data'] = $moderation_menu_name;
310
+	} elseif (isset($context['moderation_menu_name'])) {
311
+			$context[$context['moderation_menu_name']]['tab_data'] = array(
308 312
 			'title' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log'],
309 313
 			'help' => $context['log_type'] == 3 ? 'adminlog' : 'modlog',
310 314
 			'description' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log_desc']
311 315
 		);
312
-}
316
+	}
317
+	}
313 318
 
314 319
 /**
315 320
  * Get the number of mod log entries.
@@ -413,30 +418,35 @@  discard block
 block discarded – undo
413 418
 		// Add on some of the column stuff info
414 419
 		if (!empty($row['id_board']))
415 420
 		{
416
-			if ($row['action'] == 'move')
417
-				$row['extra']['board_to'] = $row['id_board'];
418
-			else
419
-				$row['extra']['board'] = $row['id_board'];
421
+			if ($row['action'] == 'move') {
422
+							$row['extra']['board_to'] = $row['id_board'];
423
+			} else {
424
+							$row['extra']['board'] = $row['id_board'];
425
+			}
420 426
 		}
421 427
 
422
-		if (!empty($row['id_topic']))
423
-			$row['extra']['topic'] = $row['id_topic'];
424
-		if (!empty($row['id_msg']))
425
-			$row['extra']['message'] = $row['id_msg'];
428
+		if (!empty($row['id_topic'])) {
429
+					$row['extra']['topic'] = $row['id_topic'];
430
+		}
431
+		if (!empty($row['id_msg'])) {
432
+					$row['extra']['message'] = $row['id_msg'];
433
+		}
426 434
 
427 435
 		// Is this associated with a topic?
428
-		if (isset($row['extra']['topic']))
429
-			$topics[(int) $row['extra']['topic']][] = $row['id_action'];
430
-		if (isset($row['extra']['new_topic']))
431
-			$topics[(int) $row['extra']['new_topic']][] = $row['id_action'];
436
+		if (isset($row['extra']['topic'])) {
437
+					$topics[(int) $row['extra']['topic']][] = $row['id_action'];
438
+		}
439
+		if (isset($row['extra']['new_topic'])) {
440
+					$topics[(int) $row['extra']['new_topic']][] = $row['id_action'];
441
+		}
432 442
 
433 443
 		// How about a member?
434 444
 		if (isset($row['extra']['member']))
435 445
 		{
436 446
 			// Guests don't have names!
437
-			if (empty($row['extra']['member']))
438
-				$row['extra']['member'] = $txt['modlog_parameter_guest'];
439
-			else
447
+			if (empty($row['extra']['member'])) {
448
+							$row['extra']['member'] = $txt['modlog_parameter_guest'];
449
+			} else
440 450
 			{
441 451
 				// Try to find it...
442 452
 				$members[(int) $row['extra']['member']][] = $row['id_action'];
@@ -444,35 +454,42 @@  discard block
 block discarded – undo
444 454
 		}
445 455
 
446 456
 		// Associated with a board?
447
-		if (isset($row['extra']['board_to']))
448
-			$boards[(int) $row['extra']['board_to']][] = $row['id_action'];
449
-		if (isset($row['extra']['board_from']))
450
-			$boards[(int) $row['extra']['board_from']][] = $row['id_action'];
451
-		if (isset($row['extra']['board']))
452
-			$boards[(int) $row['extra']['board']][] = $row['id_action'];
457
+		if (isset($row['extra']['board_to'])) {
458
+					$boards[(int) $row['extra']['board_to']][] = $row['id_action'];
459
+		}
460
+		if (isset($row['extra']['board_from'])) {
461
+					$boards[(int) $row['extra']['board_from']][] = $row['id_action'];
462
+		}
463
+		if (isset($row['extra']['board'])) {
464
+					$boards[(int) $row['extra']['board']][] = $row['id_action'];
465
+		}
453 466
 
454 467
 		// A message?
455
-		if (isset($row['extra']['message']))
456
-			$messages[(int) $row['extra']['message']][] = $row['id_action'];
468
+		if (isset($row['extra']['message'])) {
469
+					$messages[(int) $row['extra']['message']][] = $row['id_action'];
470
+		}
457 471
 
458 472
 		// IP Info?
459
-		if (isset($row['extra']['ip_range']))
460
-			if ($seeIP)
473
+		if (isset($row['extra']['ip_range'])) {
474
+					if ($seeIP)
461 475
 				$row['extra']['ip_range'] = '<a href="' . $scripturl . '?action=trackip;searchip=' . $row['extra']['ip_range'] . '">' . $row['extra']['ip_range'] . '</a>';
462
-			else
463
-				$row['extra']['ip_range'] = $txt['logged'];
476
+		} else {
477
+							$row['extra']['ip_range'] = $txt['logged'];
478
+			}
464 479
 
465 480
 		// Email?
466
-		if (isset($row['extra']['email']))
467
-			$row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>';
481
+		if (isset($row['extra']['email'])) {
482
+					$row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>';
483
+		}
468 484
 
469 485
 		// Bans are complex.
470 486
 		if ($row['action'] == 'ban' || $row['action'] == 'banremove')
471 487
 		{
472 488
 			$row['action_text'] = $txt['modlog_ac_ban' . ($row['action'] == 'banremove' ? '_remove' : '')];
473
-			foreach (array('member', 'email', 'ip_range', 'hostname') as $type)
474
-				if (isset($row['extra'][$type]))
489
+			foreach (array('member', 'email', 'ip_range', 'hostname') as $type) {
490
+							if (isset($row['extra'][$type]))
475 491
 					$row['action_text'] .= $txt['modlog_ac_ban_trigger_' . $type];
492
+			}
476 493
 		}
477 494
 
478 495
 		// The array to go to the template. Note here that action is set to a "default" value of the action doesn't match anything in the descriptions. Allows easy adding of logging events with basic details.
@@ -508,12 +525,13 @@  discard block
 block discarded – undo
508 525
 			foreach ($boards[$row['id_board']] as $action)
509 526
 			{
510 527
 				// Make the board number into a link - dealing with moving too.
511
-				if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board'])
512
-					$entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
513
-				elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board'])
514
-					$entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
515
-				elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board'])
516
-					$entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
528
+				if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) {
529
+									$entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
530
+				} elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) {
531
+									$entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
532
+				} elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) {
533
+									$entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
534
+				}
517 535
 			}
518 536
 		}
519 537
 		$smcFunc['db_free_result']($request);
@@ -547,10 +565,11 @@  discard block
 block discarded – undo
547 565
 				);
548 566
 
549 567
 				// Make the topic number into a link - dealing with splitting too.
550
-				if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic'])
551
-					$this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>';
552
-				elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic'])
553
-					$this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>';
568
+				if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic']) {
569
+									$this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>';
570
+				} elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic']) {
571
+									$this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>';
572
+				}
554 573
 			}
555 574
 		}
556 575
 		$smcFunc['db_free_result']($request);
@@ -583,8 +602,9 @@  discard block
 block discarded – undo
583 602
 				);
584 603
 
585 604
 				// Make the message number into a link.
586
-				if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg'])
587
-					$this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>';
605
+				if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg']) {
606
+									$this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>';
607
+				}
588 608
 			}
589 609
 		}
590 610
 		$smcFunc['db_free_result']($request);
@@ -624,25 +644,29 @@  discard block
 block discarded – undo
624 644
 	foreach ($entries as $k => $entry)
625 645
 	{
626 646
 		// Make any message info links so its easier to go find that message.
627
-		if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id'])))
628
-			$entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>';
647
+		if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id']))) {
648
+					$entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>';
649
+		}
629 650
 
630 651
 		// Mark up any deleted members, topics and boards.
631
-		foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type)
632
-			if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type]))
652
+		foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type) {
653
+					if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type]))
633 654
 				$entries[$k]['extra'][$type] = sprintf($txt['modlog_id'], $entry['extra'][$type]);
655
+		}
634 656
 
635 657
 		if (isset($entry['extra']['report']))
636 658
 		{
637 659
 			// Member profile reports go in a different area
638
-			if (stristr($entry['action'], 'user_report'))
639
-				$entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>';
640
-			else
641
-				$entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>';
660
+			if (stristr($entry['action'], 'user_report')) {
661
+							$entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>';
662
+			} else {
663
+							$entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>';
664
+			}
642 665
 		}
643 666
 
644
-		if (empty($entries[$k]['action_text']))
645
-			$entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action'];
667
+		if (empty($entries[$k]['action_text'])) {
668
+					$entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action'];
669
+		}
646 670
 		$entries[$k]['action_text'] = preg_replace_callback('~\{([A-Za-z\d_]+)\}~i',
647 671
 			function ($matches) use ($entries, $k)
648 672
 			{
Please login to merge, or discard this patch.
Sources/Likes.php 1 patch
Braces   +103 added lines, -75 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Class Likes
@@ -106,8 +107,9 @@  discard block
 block discarded – undo
106 107
 		$this->_extra = isset($_GET['extra']) ? $_GET['extra'] : false;
107 108
 
108 109
 		// We do not want to output debug information here.
109
-		if ($this->_js)
110
-			$db_show_debug = false;
110
+		if ($this->_js) {
111
+					$db_show_debug = false;
112
+		}
111 113
 	}
112 114
 
113 115
 	/**
@@ -141,8 +143,9 @@  discard block
 block discarded – undo
141 143
 			$call = $this->_sa;
142 144
 
143 145
 			// Guest can only view likes.
144
-			if ($call != 'view')
145
-				is_not_guest();
146
+			if ($call != 'view') {
147
+							is_not_guest();
148
+			}
146 149
 
147 150
 			checkSession('get');
148 151
 
@@ -180,15 +183,17 @@  discard block
 block discarded – undo
180 183
 		global $smcFunc, $modSettings;
181 184
 
182 185
 		// This feature is currently disable.
183
-		if (empty($modSettings['enable_likes']))
184
-			return $this->_error = 'like_disable';
186
+		if (empty($modSettings['enable_likes'])) {
187
+					return $this->_error = 'like_disable';
188
+		}
185 189
 
186 190
 		// Zerothly, they did indicate some kind of content to like, right?
187 191
 		preg_match('~^([a-z0-9\-\_]{1,6})~i', $this->_type, $matches);
188 192
 		$this->_type = isset($matches[1]) ? $matches[1] : '';
189 193
 
190
-		if ($this->_type == '' || $this->_content <= 0)
191
-			return $this->_error = 'cannot_';
194
+		if ($this->_type == '' || $this->_content <= 0) {
195
+					return $this->_error = 'cannot_';
196
+		}
192 197
 
193 198
 		// First we need to verify if the user can see the type of content or not. This is set up to be extensible,
194 199
 		// so we'll check for the one type we do know about, and if it's not that, we'll defer to any hooks.
@@ -207,12 +212,14 @@  discard block
 block discarded – undo
207 212
 					'msg' => $this->_content,
208 213
 				)
209 214
 			);
210
-			if ($smcFunc['db_num_rows']($request) == 1)
211
-				list ($this->_idTopic, $topicOwner) = $smcFunc['db_fetch_row']($request);
215
+			if ($smcFunc['db_num_rows']($request) == 1) {
216
+							list ($this->_idTopic, $topicOwner) = $smcFunc['db_fetch_row']($request);
217
+			}
212 218
 
213 219
 			$smcFunc['db_free_result']($request);
214
-			if (empty($this->_idTopic))
215
-				return $this->_error = 'cannot_';
220
+			if (empty($this->_idTopic)) {
221
+							return $this->_error = 'cannot_';
222
+			}
216 223
 
217 224
 			// So we know what topic it's in and more importantly we know the user can see it.
218 225
 			// If we're not viewing, we need some info set up.
@@ -221,9 +228,7 @@  discard block
 block discarded – undo
221 228
 			$this->_validLikes['redirect'] = 'topic=' . $this->_idTopic . '.msg' . $this->_content . '#msg' . $this->_content;
222 229
 
223 230
 			$this->_validLikes['can_like'] = ($this->_user['id'] == $topicOwner ? 'cannot_like_content' : (allowedTo('likes_like') ? true : 'cannot_like_content'));
224
-		}
225
-
226
-		else
231
+		} else
227 232
 		{
228 233
 			// Modders: This will give you whatever the user offers up in terms of liking, e.g. $this->_type=msg, $this->_content=1
229 234
 			// When you hook this, check $this->_type first. If it is not something your mod worries about, return false.
@@ -241,8 +246,9 @@  discard block
 block discarded – undo
241 246
 					if ($result !== false)
242 247
 					{
243 248
 						// Match the type with what we already have.
244
-						if (!isset($result['type']) || $result['type'] != $this->_type)
245
-							return $this->_error = 'not_valid_like_type';
249
+						if (!isset($result['type']) || $result['type'] != $this->_type) {
250
+													return $this->_error = 'not_valid_like_type';
251
+						}
246 252
 
247 253
 						// Fill out the rest.
248 254
 						$this->_type = $result['type'];
@@ -253,13 +259,15 @@  discard block
 block discarded – undo
253 259
 				}
254 260
 			}
255 261
 
256
-			if (!$found)
257
-				return $this->_error = 'cannot_';
262
+			if (!$found) {
263
+							return $this->_error = 'cannot_';
264
+			}
258 265
 		}
259 266
 
260 267
 		// Does the user can like this? Viewing a list of likes doesn't require this permission.
261
-			if ($this->_sa != 'view' && isset($this->_validLikes['can_like']) && is_string($this->_validLikes['can_like']))
262
-				return $this->_error = $this->_validLikes['can_like'];
268
+			if ($this->_sa != 'view' && isset($this->_validLikes['can_like']) && is_string($this->_validLikes['can_like'])) {
269
+							return $this->_error = $this->_validLikes['can_like'];
270
+			}
263 271
 	}
264 272
 
265 273
 	/**
@@ -284,8 +292,9 @@  discard block
 block discarded – undo
284 292
 		);
285 293
 
286 294
 		// Are we calling this directly? if so, set a proper data for the response. Do note that __METHOD__ returns both the class name and the function name.
287
-		if ($this->_sa == __FUNCTION__)
288
-			$this->_data = __FUNCTION__;
295
+		if ($this->_sa == __FUNCTION__) {
296
+					$this->_data = __FUNCTION__;
297
+		}
289 298
 	}
290 299
 
291 300
 	/**
@@ -315,8 +324,8 @@  discard block
 block discarded – undo
315 324
 
316 325
 		// Add a background task to process sending alerts.
317 326
 		// Mod author, you can add your own background task for your own custom like event using the "integrate_issue_like" hook or your callback, both are immediately called after this.
318
-		if ($this->_type == 'msg')
319
-			$smcFunc['db_insert']('insert',
327
+		if ($this->_type == 'msg') {
328
+					$smcFunc['db_insert']('insert',
320 329
 				'{db_prefix}background_tasks',
321 330
 				array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'),
322 331
 				array('$sourcedir/tasks/Likes-Notify.php', 'Likes_Notify_Background', $smcFunc['json_encode'](array(
@@ -328,10 +337,12 @@  discard block
 block discarded – undo
328 337
 				)), 0),
329 338
 				array('id_task')
330 339
 			);
340
+		}
331 341
 
332 342
 		// Are we calling this directly? if so, set a proper data for the response. Do note that __METHOD__ returns both the class name and the function name.
333
-		if ($this->_sa == __FUNCTION__)
334
-			$this->_data = __FUNCTION__;
343
+		if ($this->_sa == __FUNCTION__) {
344
+					$this->_data = __FUNCTION__;
345
+		}
335 346
 	}
336 347
 
337 348
 	/**
@@ -357,8 +368,9 @@  discard block
 block discarded – undo
357 368
 		$smcFunc['db_free_result']($request);
358 369
 
359 370
 		// If you want to call this directly, fill out _data property too.
360
-		if ($this->_sa == __FUNCTION__)
361
-			$this->_data = $this->_numLikes;
371
+		if ($this->_sa == __FUNCTION__) {
372
+					$this->_data = $this->_numLikes;
373
+		}
362 374
 	}
363 375
 
364 376
 	/**
@@ -371,8 +383,9 @@  discard block
 block discarded – undo
371 383
 		global $smcFunc;
372 384
 
373 385
 		// Safety first!
374
-		if (empty($this->_type) || empty($this->_content))
375
-			return $this->_error = 'cannot_';
386
+		if (empty($this->_type) || empty($this->_content)) {
387
+					return $this->_error = 'cannot_';
388
+		}
376 389
 
377 390
 		// Do we already like this?
378 391
 		$request = $smcFunc['db_query']('', '
@@ -390,26 +403,28 @@  discard block
 block discarded – undo
390 403
 		$this->_alreadyLiked = (bool) $smcFunc['db_num_rows']($request) != 0;
391 404
 		$smcFunc['db_free_result']($request);
392 405
 
393
-		if ($this->_alreadyLiked)
394
-			$this->delete();
395
-
396
-		else
397
-			$this->insert();
406
+		if ($this->_alreadyLiked) {
407
+					$this->delete();
408
+		} else {
409
+					$this->insert();
410
+		}
398 411
 
399 412
 		// Now, how many people like this content now? We *could* just +1 / -1 the relevant container but that has proven to become unstable.
400 413
 		$this->_count();
401 414
 
402 415
 		// Update the likes count for messages.
403
-		if ($this->_type == 'msg')
404
-			$this->msgIssueLike();
416
+		if ($this->_type == 'msg') {
417
+					$this->msgIssueLike();
418
+		}
405 419
 
406 420
 		// Any callbacks?
407 421
 		elseif (!empty($this->_validLikes['callback']))
408 422
 		{
409 423
 			$call = call_helper($this->_validLikes['callback'], true);
410 424
 
411
-			if (!empty($call))
412
-				call_user_func_array($call, array($this));
425
+			if (!empty($call)) {
426
+							call_user_func_array($call, array($this));
427
+			}
413 428
 		}
414 429
 
415 430
 		// Sometimes there might be other things that need updating after we do this like.
@@ -418,8 +433,9 @@  discard block
 block discarded – undo
418 433
 		// Now some clean up. This is provided here for any like handlers that want to do any cache flushing.
419 434
 		// This way a like handler doesn't need to explicitly declare anything in integrate_issue_like, but do so
420 435
 		// in integrate_valid_likes where it absolutely has to exist.
421
-		if (!empty($this->_validLikes['flush_cache']))
422
-			cache_put_data($this->_validLikes['flush_cache'], null);
436
+		if (!empty($this->_validLikes['flush_cache'])) {
437
+					cache_put_data($this->_validLikes['flush_cache'], null);
438
+		}
423 439
 
424 440
 		// All done, start building the data to pass as response.
425 441
 		$this->_data = array(
@@ -442,8 +458,9 @@  discard block
 block discarded – undo
442 458
 	{
443 459
 		global $smcFunc;
444 460
 
445
-		if ($this->_type !== 'msg')
446
-			return;
461
+		if ($this->_type !== 'msg') {
462
+					return;
463
+		}
447 464
 
448 465
 		$smcFunc['db_query']('', '
449 466
 			UPDATE {db_prefix}messages
@@ -484,8 +501,9 @@  discard block
 block discarded – undo
484 501
 				'like_type' => $this->_type,
485 502
 			)
486 503
 		);
487
-		while ($row = $smcFunc['db_fetch_assoc']($request))
488
-			$context['likers'][$row['id_member']] = array('timestamp' => $row['like_time']);
504
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
505
+					$context['likers'][$row['id_member']] = array('timestamp' => $row['like_time']);
506
+		}
489 507
 
490 508
 		// Now to get member data, including avatars and so on.
491 509
 		$members = array_keys($context['likers']);
@@ -493,8 +511,9 @@  discard block
 block discarded – undo
493 511
 		if (count($loaded) != count($members))
494 512
 		{
495 513
 			$members = array_diff($members, $loaded);
496
-			foreach ($members as $not_loaded)
497
-				unset ($context['likers'][$not_loaded]);
514
+			foreach ($members as $not_loaded) {
515
+							unset ($context['likers'][$not_loaded]);
516
+			}
498 517
 		}
499 518
 
500 519
 		foreach ($context['likers'] as $liker => $dummy)
@@ -536,12 +555,14 @@  discard block
 block discarded – undo
536 555
 		global $context, $txt;
537 556
 
538 557
 		// Don't do anything if someone else has already take care of the response.
539
-		if (!$this->_setResponse)
540
-			return;
558
+		if (!$this->_setResponse) {
559
+					return;
560
+		}
541 561
 
542 562
 		// Want a json response huh?
543
-		if ($this->_validLikes['json'])
544
-			return $this->jsonResponse();
563
+		if ($this->_validLikes['json']) {
564
+					return $this->jsonResponse();
565
+		}
545 566
 
546 567
 		// Set everything up for display.
547 568
 		loadTemplate('Likes');
@@ -551,8 +572,9 @@  discard block
 block discarded – undo
551 572
 		if ($this->_error)
552 573
 		{
553 574
 			// If this is a generic error, set it up good.
554
-			if ($this->_error == 'cannot_')
555
-				$this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content';
575
+			if ($this->_error == 'cannot_') {
576
+							$this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content';
577
+			}
556 578
 
557 579
 			// Is this request coming from an ajax call?
558 580
 			if ($this->_js)
@@ -562,8 +584,9 @@  discard block
 block discarded – undo
562 584
 			}
563 585
 
564 586
 			// Nope?  then just do a redirect to whatever URL was provided.
565
-			else
566
-				redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] . ';error=' . $this->_error : '');
587
+			else {
588
+							redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] . ';error=' . $this->_error : '');
589
+			}
567 590
 
568 591
 			return;
569 592
 		}
@@ -572,8 +595,9 @@  discard block
 block discarded – undo
572 595
 		else
573 596
 		{
574 597
 			// Not an ajax request so send the user back to the previous location or the main page.
575
-			if (!$this->_js)
576
-				redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] : '');
598
+			if (!$this->_js) {
599
+							redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] : '');
600
+			}
577 601
 
578 602
 			// These fine gentlemen all share the same template.
579 603
 			$generic = array('delete', 'insert', '_count');
@@ -606,8 +630,9 @@  discard block
 block discarded – undo
606 630
 		// If there is an error, send it.
607 631
 		if ($this->_error)
608 632
 		{
609
-			if ($this->_error == 'cannot_')
610
-				$this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content';
633
+			if ($this->_error == 'cannot_') {
634
+							$this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content';
635
+			}
611 636
 
612 637
 			$print['error'] = $this->_error;
613 638
 		}
@@ -643,33 +668,36 @@  discard block
 block discarded – undo
643 668
 	<body style="background-color: #444455; color: white; font-style: italic; font-family: serif;">
644 669
 		<div style="margin-top: 12%; font-size: 1.1em; line-height: 1.4; text-align: center;">';
645 670
 
646
-	if (!isset($_GET['verse']) || ($_GET['verse'] != '2:18' && $_GET['verse'] != '22:1-2'))
647
-		$_GET['verse'] = '4:16';
671
+	if (!isset($_GET['verse']) || ($_GET['verse'] != '2:18' && $_GET['verse'] != '22:1-2')) {
672
+			$_GET['verse'] = '4:16';
673
+	}
648 674
 
649
-	if ($_GET['verse'] == '2:18')
650
-		echo '
675
+	if ($_GET['verse'] == '2:18') {
676
+			echo '
651 677
 			Woe, it was that his name wasn\'t <em>known</em>, that he came in mystery, and was recognized by none.&nbsp;And it became to be in those days <em>something</em>.&nbsp; Something not yet <em id="unknown" name="[Unknown]">unknown</em> to mankind.&nbsp; And thus what was to be known the <em>secret project</em> began into its existence.&nbsp; Henceforth the opposition was only <em>weary</em> and <em>fearful</em>, for now their match was at arms against them.';
652
-	elseif ($_GET['verse'] == '4:16')
653
-		echo '
678
+	} elseif ($_GET['verse'] == '4:16') {
679
+			echo '
654 680
 			And it came to pass that the <em>unbelievers</em> dwindled in number and saw rise of many <em>proselytizers</em>, and the opposition found fear in the face of the <em>x</em> and the <em>j</em> while those who stood with the <em>something</em> grew stronger and came together.&nbsp; Still, this was only the <em>beginning</em>, and what lay in the future was <em id="unknown" name="[Unknown]">unknown</em> to all, even those on the right side.';
655
-	elseif ($_GET['verse'] == '22:1-2')
656
-		echo '
681
+	} elseif ($_GET['verse'] == '22:1-2') {
682
+			echo '
657 683
 			<p>Now <em>behold</em>, that which was once the secret project was <em id="unknown" name="[Unknown]">unknown</em> no longer.&nbsp; Alas, it needed more than <em>only one</em>, but yet even thought otherwise.&nbsp; It became that the opposition <em>rumored</em> and lied, but still to no avail.&nbsp; Their match, though not <em>perfect</em>, had them outdone.</p>
658 684
 			<p style="margin: 2ex 1ex 0 1ex; font-size: 1.05em; line-height: 1.5; text-align: center;">Let it continue.&nbsp; <em>The end</em>.</p>';
685
+	}
659 686
 
660 687
 	echo '
661 688
 		</div>
662 689
 		<div style="margin-top: 2ex; font-size: 2em; text-align: right;">';
663 690
 
664
-	if ($_GET['verse'] == '2:18')
665
-		echo '
691
+	if ($_GET['verse'] == '2:18') {
692
+			echo '
666 693
 			from <span style="font-family: Georgia, serif;"><strong><a href="', $scripturl, '?action=about:unknown;verse=4:16" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 2:18</span>';
667
-	elseif ($_GET['verse'] == '4:16')
668
-		echo '
694
+	} elseif ($_GET['verse'] == '4:16') {
695
+			echo '
669 696
 			from <span style="font-family: Georgia, serif;"><strong><a href="', $scripturl, '?action=about:unknown;verse=22:1-2" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 4:16</span>';
670
-	elseif ($_GET['verse'] == '22:1-2')
671
-		echo '
697
+	} elseif ($_GET['verse'] == '22:1-2') {
698
+			echo '
672 699
 			from <span style="font-family: Georgia, serif;"><strong>The Book of Unknown</strong>, 22:1-2</span>';
700
+	}
673 701
 
674 702
 	echo '
675 703
 		</div>
Please login to merge, or discard this patch.
Sources/Class-CacheAPI.php 1 patch
Braces   +20 added lines, -15 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
  * @version 2.1 Beta 4
12 12
  */
13 13
 
14
-if (!defined('SMF'))
14
+if (!defined('SMF')) {
15 15
 	die('Hacking attempt...');
16
+}
16 17
 
17 18
 /**
18 19
  * Interface cache_api_interface
@@ -182,8 +183,9 @@  discard block
 block discarded – undo
182 183
 	{
183 184
 		global $cache_enable;
184 185
 
185
-		if ($test)
186
-			return true;
186
+		if ($test) {
187
+					return true;
188
+		}
187 189
 		return !empty($cache_enable);
188 190
 	}
189 191
 
@@ -202,18 +204,20 @@  discard block
 block discarded – undo
202 204
 		global $boardurl, $cachedir;
203 205
 
204 206
 		// Find a valid good file to do mtime checks on.
205
-		if (file_exists($cachedir . '/' . 'index.php'))
206
-			$filemtime = $cachedir . '/' . 'index.php';
207
-		elseif (is_dir($cachedir . '/'))
208
-			$filemtime = $cachedir . '/';
209
-		else
210
-			$filemtime = $boardurl . '/index.php';
207
+		if (file_exists($cachedir . '/' . 'index.php')) {
208
+					$filemtime = $cachedir . '/' . 'index.php';
209
+		} elseif (is_dir($cachedir . '/')) {
210
+					$filemtime = $cachedir . '/';
211
+		} else {
212
+					$filemtime = $boardurl . '/index.php';
213
+		}
211 214
 
212 215
 		// Set the default if no prefix was specified.
213
-		if (empty($prefix))
214
-			$this->prefix = md5($boardurl . filemtime($filemtime)) . '-SMF-';
215
-		else
216
-			$this->prefix = $prefix;
216
+		if (empty($prefix)) {
217
+					$this->prefix = md5($boardurl . filemtime($filemtime)) . '-SMF-';
218
+		} else {
219
+					$this->prefix = $prefix;
220
+		}
217 221
 
218 222
 		return true;
219 223
 	}
@@ -276,8 +280,9 @@  discard block
 block discarded – undo
276 280
 
277 281
 		// Invalidate cache, to be sure!
278 282
 		// ... as long as index.php can be modified, anyway.
279
-		if (is_writable($cachedir . '/' . 'index.php'))
280
-			@touch($cachedir . '/' . 'index.php');
283
+		if (is_writable($cachedir . '/' . 'index.php')) {
284
+					@touch($cachedir . '/' . 'index.php');
285
+		}
281 286
 
282 287
 		return true;
283 288
 	}
Please login to merge, or discard this patch.
Sources/Subs-MembersOnline.php 1 patch
Braces   +27 added lines, -21 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Retrieve a list and several other statistics of the users currently online.
@@ -45,8 +46,9 @@  discard block
 block discarded – undo
45 46
 	}
46 47
 
47 48
 	// Not allowed sort method? Bang! Error!
48
-	elseif (!in_array($membersOnlineOptions['sort'], $allowed_sort_options))
49
-		trigger_error('Sort method for getMembersOnlineStats() function is not allowed', E_USER_NOTICE);
49
+	elseif (!in_array($membersOnlineOptions['sort'], $allowed_sort_options)) {
50
+			trigger_error('Sort method for getMembersOnlineStats() function is not allowed', E_USER_NOTICE);
51
+	}
50 52
 
51 53
 	// Initialize the array that'll be returned later on.
52 54
 	$membersOnlineStats = array(
@@ -63,8 +65,9 @@  discard block
 block discarded – undo
63 65
 	// Get any spiders if enabled.
64 66
 	$spiders = array();
65 67
 	$spider_finds = array();
66
-	if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] < 3 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache']))
67
-		$spiders = $smcFunc['json_decode']($modSettings['spider_name_cache'], true);
68
+	if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] < 3 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) {
69
+			$spiders = $smcFunc['json_decode']($modSettings['spider_name_cache'], true);
70
+	}
68 71
 
69 72
 	// Load the users online right now.
70 73
 	$request = $smcFunc['db_query']('', '
@@ -92,9 +95,7 @@  discard block
 block discarded – undo
92 95
 			$membersOnlineStats['num_guests']++;
93 96
 
94 97
 			continue;
95
-		}
96
-
97
-		elseif (empty($row['show_online']) && empty($membersOnlineOptions['show_hidden']))
98
+		} elseif (empty($row['show_online']) && empty($membersOnlineOptions['show_hidden']))
98 99
 		{
99 100
 			// Just increase the stats and don't add this hidden user to any list.
100 101
 			$membersOnlineStats['num_users_hidden']++;
@@ -102,10 +103,11 @@  discard block
 block discarded – undo
102 103
 		}
103 104
 
104 105
 		// Some basic color coding...
105
-		if (!empty($row['online_color']))
106
-			$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>';
107
-		else
108
-			$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
106
+		if (!empty($row['online_color'])) {
107
+					$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>';
108
+		} else {
109
+					$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
110
+		}
109 111
 
110 112
 		// Buddies get counted and highlighted.
111 113
 		$is_buddy = in_array($row['id_member'], $user_info['buddies']);
@@ -132,8 +134,8 @@  discard block
 block discarded – undo
132 134
 		$membersOnlineStats['list_users_online'][$row[$membersOnlineOptions['sort']] . '_' . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link;
133 135
 
134 136
 		// Store all distinct (primary) membergroups that are shown.
135
-		if (!isset($membersOnlineStats['online_groups'][$row['id_group']]))
136
-			$membersOnlineStats['online_groups'][$row['id_group']] = array(
137
+		if (!isset($membersOnlineStats['online_groups'][$row['id_group']])) {
138
+					$membersOnlineStats['online_groups'][$row['id_group']] = array(
137 139
 				'id' => $row['id_group'],
138 140
 				'name' => $row['group_name'],
139 141
 				'color' => $row['online_color'],
@@ -141,6 +143,7 @@  discard block
 block discarded – undo
141 143
 				'type' => $row['group_type'],
142 144
 				'parent' => $row['id_parent'],
143 145
 			);
146
+		}
144 147
 	}
145 148
 	$smcFunc['db_free_result']($request);
146 149
 
@@ -201,11 +204,12 @@  discard block
 block discarded – undo
201 204
 	$settingsToUpdate = array();
202 205
 
203 206
 	// More members on now than ever were?  Update it!
204
-	if (!isset($modSettings['mostOnline']) || $total_users_online >= $modSettings['mostOnline'])
205
-		$settingsToUpdate = array(
207
+	if (!isset($modSettings['mostOnline']) || $total_users_online >= $modSettings['mostOnline']) {
208
+			$settingsToUpdate = array(
206 209
 			'mostOnline' => $total_users_online,
207 210
 			'mostDate' => time()
208 211
 		);
212
+	}
209 213
 
210 214
 	$date = strftime('%Y-%m-%d', forum_time(false));
211 215
 
@@ -237,8 +241,9 @@  discard block
 block discarded – undo
237 241
 		{
238 242
 			list ($modSettings['mostOnlineToday']) = $smcFunc['db_fetch_row']($request);
239 243
 
240
-			if ($total_users_online > $modSettings['mostOnlineToday'])
241
-				trackStats(array('most_on' => $total_users_online));
244
+			if ($total_users_online > $modSettings['mostOnlineToday']) {
245
+							trackStats(array('most_on' => $total_users_online));
246
+			}
242 247
 
243 248
 			$total_users_online = max($total_users_online, $modSettings['mostOnlineToday']);
244 249
 		}
@@ -255,8 +260,9 @@  discard block
 block discarded – undo
255 260
 		$settingsToUpdate['mostOnlineToday'] = $total_users_online;
256 261
 	}
257 262
 
258
-	if (!empty($settingsToUpdate))
259
-		updateSettings($settingsToUpdate);
260
-}
263
+	if (!empty($settingsToUpdate)) {
264
+			updateSettings($settingsToUpdate);
265
+	}
266
+	}
261 267
 
262 268
 ?>
263 269
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/DbExtra-postgresql.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 
92 92
 	$table = str_replace('{db_prefix}', $db_prefix, $table);
93 93
 
94
-	$pg_tables = array('pg_catalog','information_schema');
94
+	$pg_tables = array('pg_catalog', 'information_schema');
95 95
 
96 96
 	$request = $smcFunc['db_query']('', '
97 97
 		SELECT pg_relation_size(C.oid) AS "size"
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 	global $db_connection;
291 291
 	static $ver;
292 292
 
293
-	if(!empty($ver))
293
+	if (!empty($ver))
294 294
 		return $ver;
295 295
 
296 296
 	$ver = pg_version($db_connection)['server'];
Please login to merge, or discard this patch.
Braces   +43 added lines, -32 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Add the functions implemented in this file to the $smcFunc array.
@@ -23,8 +24,8 @@  discard block
 block discarded – undo
23 24
 {
24 25
 	global $smcFunc;
25 26
 
26
-	if (!isset($smcFunc['db_backup_table']) || $smcFunc['db_backup_table'] != 'smf_db_backup_table')
27
-		$smcFunc += array(
27
+	if (!isset($smcFunc['db_backup_table']) || $smcFunc['db_backup_table'] != 'smf_db_backup_table') {
28
+			$smcFunc += array(
28 29
 			'db_backup_table' => 'smf_db_backup_table',
29 30
 			'db_optimize_table' => 'smf_db_optimize_table',
30 31
 			'db_table_sql' => 'smf_db_table_sql',
@@ -33,7 +34,8 @@  discard block
 block discarded – undo
33 34
 			'db_get_vendor' => 'smf_db_get_vendor',
34 35
 			'db_allow_persistent' => 'smf_db_allow_persistent',
35 36
 		);
36
-}
37
+	}
38
+	}
37 39
 
38 40
 /**
39 41
  * Backup $table to $backup_table.
@@ -49,13 +51,14 @@  discard block
 block discarded – undo
49 51
 
50 52
 	// Do we need to drop it first?
51 53
 	$tables = smf_db_list_tables(false, $backup_table);
52
-	if (!empty($tables))
53
-		$smcFunc['db_query']('', '
54
+	if (!empty($tables)) {
55
+			$smcFunc['db_query']('', '
54 56
 			DROP TABLE {raw:backup_table}',
55 57
 			array(
56 58
 				'backup_table' => $backup_table,
57 59
 			)
58 60
 		);
61
+	}
59 62
 
60 63
 	/**
61 64
 	 * @todo Should we create backups of sequences as well?
@@ -118,8 +121,9 @@  discard block
 block discarded – undo
118 121
 			)
119 122
 		);
120 123
 
121
-	if (!$request)
122
-		return -1;
124
+	if (!$request) {
125
+			return -1;
126
+	}
123 127
 
124 128
 	$request = $smcFunc['db_query']('', '
125 129
 		SELECT pg_relation_size(C.oid) AS "size"
@@ -137,11 +141,12 @@  discard block
 block discarded – undo
137 141
 	$row = $smcFunc['db_fetch_assoc']($request);
138 142
 	$smcFunc['db_free_result']($request);
139 143
 
140
-	if (isset($row['size']))
141
-			return ($old_size - $row['size']) / 1024;
142
-	else
143
-		return 0;
144
-}
144
+	if (isset($row['size'])) {
145
+				return ($old_size - $row['size']) / 1024;
146
+	} else {
147
+			return 0;
148
+	}
149
+	}
145 150
 
146 151
 /**
147 152
  * This function lists all tables in the database.
@@ -168,8 +173,9 @@  discard block
 block discarded – undo
168 173
 	);
169 174
 
170 175
 	$tables = array();
171
-	while ($row = $smcFunc['db_fetch_row']($request))
172
-		$tables[] = $row[0];
176
+	while ($row = $smcFunc['db_fetch_row']($request)) {
177
+			$tables[] = $row[0];
178
+	}
173 179
 	$smcFunc['db_free_result']($request);
174 180
 
175 181
 	return $tables;
@@ -210,12 +216,14 @@  discard block
 block discarded – undo
210 216
 	);
211 217
 	while ($row = $smcFunc['db_fetch_assoc']($result))
212 218
 	{
213
-		if ($row['data_type'] == 'character varying')
214
-			$row['data_type'] = 'varchar';
215
-		elseif ($row['data_type'] == 'character')
216
-			$row['data_type'] = 'char';
217
-		if ($row['character_maximum_length'])
218
-			$row['data_type'] .= '(' . $row['character_maximum_length'] . ')';
219
+		if ($row['data_type'] == 'character varying') {
220
+					$row['data_type'] = 'varchar';
221
+		} elseif ($row['data_type'] == 'character') {
222
+					$row['data_type'] = 'char';
223
+		}
224
+		if ($row['character_maximum_length']) {
225
+					$row['data_type'] .= '(' . $row['character_maximum_length'] . ')';
226
+		}
219 227
 
220 228
 		// Make the CREATE for this column.
221 229
 		$schema_create .= ' "' . $row['column_name'] . '" ' . $row['data_type'] . ($row['is_nullable'] != 'YES' ? ' NOT NULL' : '');
@@ -266,13 +274,14 @@  discard block
 block discarded – undo
266 274
 	{
267 275
 		if ($row['is_primary'])
268 276
 		{
269
-			if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0)
270
-				continue;
277
+			if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0) {
278
+							continue;
279
+			}
271 280
 
272 281
 			$index_create .= $crlf . 'ALTER TABLE ' . $tableName . ' ADD PRIMARY KEY ("' . $matches[1] . '");';
282
+		} else {
283
+					$index_create .= $crlf . $row['inddef'] . ';';
273 284
 		}
274
-		else
275
-			$index_create .= $crlf . $row['inddef'] . ';';
276 285
 	}
277 286
 	$smcFunc['db_free_result']($result);
278 287
 
@@ -291,8 +300,9 @@  discard block
 block discarded – undo
291 300
 	global $db_connection;
292 301
 	static $ver;
293 302
 
294
-	if(!empty($ver))
295
-		return $ver;
303
+	if(!empty($ver)) {
304
+			return $ver;
305
+	}
296 306
 
297 307
 	$ver = pg_version($db_connection)['server'];
298 308
 
@@ -317,10 +327,11 @@  discard block
 block discarded – undo
317 327
 function smf_db_allow_persistent()
318 328
 {
319 329
 	$value = ini_get('pgsql.allow_persistent');
320
-	if (strtolower($value) == 'on' || strtolower($value) == 'true' || $value == '1')
321
-		return true;
322
-	else
323
-		return false;
324
-}
330
+	if (strtolower($value) == 'on' || strtolower($value) == 'true' || $value == '1') {
331
+			return true;
332
+	} else {
333
+			return false;
334
+	}
335
+	}
325 336
 
326 337
 ?>
327 338
\ No newline at end of file
Please login to merge, or discard this patch.
Themes/default/ManageMembers.template.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -148,8 +148,8 @@  discard block
 block discarded – undo
148 148
 				</thead>
149 149
 				<tbody>';
150 150
 
151
-	foreach ($context['membergroups'] as $membergroup)
152
-		echo '
151
+	foreach ($context['membergroups'] as $membergroup) {
152
+			echo '
153 153
 					<tr class="windowbg">
154 154
 						<td>', $membergroup['name'], '</td>
155 155
 						<td class="centercol">
@@ -159,6 +159,7 @@  discard block
 block discarded – undo
159 159
 							', $membergroup['can_be_additional'] ? '<input type="checkbox" name="membergroups[2][]" value="' . $membergroup['id'] . '" checked>' : '', '
160 160
 						</td>
161 161
 					</tr>';
162
+	}
162 163
 
163 164
 	echo '
164 165
 					<tr class="windowbg">
@@ -185,8 +186,8 @@  discard block
 block discarded – undo
185 186
 				</thead>
186 187
 				<tbody>';
187 188
 
188
-	foreach ($context['postgroups'] as $postgroup)
189
-		echo '
189
+	foreach ($context['postgroups'] as $postgroup) {
190
+			echo '
190 191
 					<tr class="windowbg">
191 192
 						<td>
192 193
 							', $postgroup['name'], '
@@ -195,6 +196,7 @@  discard block
 block discarded – undo
195 196
 							<input type="checkbox" name="postgroups[]" value="', $postgroup['id'], '" checked>
196 197
 						</td>
197 198
 					</tr>';
199
+	}
198 200
 
199 201
 	echo '
200 202
 					<tr class="windowbg">
Please login to merge, or discard this patch.
Themes/default/index.template.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -232,7 +232,7 @@
 block discarded – undo
232 232
 			// In maintenance mode, only login is allowed and don't show OverlayDiv
233 233
 			echo '
234 234
 			<ul class="floatleft welcome">
235
-				<li>', sprintf($txt['welcome_guest'], $txt['guest_title'], '', $scripturl. '?action=login', 'return true;'), '</li>
235
+				<li>', sprintf($txt['welcome_guest'], $txt['guest_title'], '', $scripturl . '?action=login', 'return true;'), '</li>
236 236
 			</ul>';
237 237
 
238 238
 	if (!empty($modSettings['userLanguage']) && !empty($context['languages']) && count($context['languages']) > 1)
Please login to merge, or discard this patch.
Braces   +98 added lines, -67 removed lines patch added patch discarded remove patch
@@ -72,9 +72,10 @@  discard block
 block discarded – undo
72 72
 
73 73
 	// Allow css/js files to be disabled for this specific theme.
74 74
 	// Add the identifier as an array key. IE array('smf_script'); Some external files might not add identifiers, on those cases SMF uses its filename as reference.
75
-	if (!isset($settings['disable_files']))
76
-		$settings['disable_files'] = array();
77
-}
75
+	if (!isset($settings['disable_files'])) {
76
+			$settings['disable_files'] = array();
77
+	}
78
+	}
78 79
 
79 80
 /**
80 81
  * The main sub template above the content.
@@ -112,8 +113,9 @@  discard block
 block discarded – undo
112 113
 		echo '
113 114
 	<meta';
114 115
 
115
-		foreach ($meta_tag as $meta_key => $meta_value)
116
-			echo ' ', $meta_key, '="', $meta_value, '"';
116
+		foreach ($meta_tag as $meta_key => $meta_value) {
117
+					echo ' ', $meta_key, '="', $meta_value, '"';
118
+		}
117 119
 
118 120
 		echo '>';
119 121
 	}
@@ -124,14 +126,16 @@  discard block
 block discarded – undo
124 126
 	<meta name="theme-color" content="#557EA0">';
125 127
 
126 128
 	// Please don't index these Mr Robot.
127
-	if (!empty($context['robot_no_index']))
128
-		echo '
129
+	if (!empty($context['robot_no_index'])) {
130
+			echo '
129 131
 	<meta name="robots" content="noindex">';
132
+	}
130 133
 
131 134
 	// Present a canonical url for search engines to prevent duplicate content in their indices.
132
-	if (!empty($context['canonical_url']))
133
-		echo '
135
+	if (!empty($context['canonical_url'])) {
136
+			echo '
134 137
 	<link rel="canonical" href="', $context['canonical_url'], '">';
138
+	}
135 139
 
136 140
 	// Show all the relative links, such as help, search, contents, and the like.
137 141
 	echo '
@@ -140,24 +144,28 @@  discard block
 block discarded – undo
140 144
 	<link rel="search" href="' . $scripturl . '?action=search">' : '');
141 145
 
142 146
 	// If RSS feeds are enabled, advertise the presence of one.
143
-	if (!empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged']))
144
-		echo '
147
+	if (!empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged'])) {
148
+			echo '
145 149
 	<link rel="alternate" type="application/rss+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['rss'], '" href="', $scripturl, '?action=.xml;type=rss2', !empty($context['current_board']) ? ';board=' . $context['current_board'] : '', '">
146 150
 	<link rel="alternate" type="application/atom+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['atom'], '" href="', $scripturl, '?action=.xml;type=atom', !empty($context['current_board']) ? ';board=' . $context['current_board'] : '', '">';
151
+	}
147 152
 
148 153
 	// If we're viewing a topic, these should be the previous and next topics, respectively.
149
-	if (!empty($context['links']['next']))
150
-		echo '
154
+	if (!empty($context['links']['next'])) {
155
+			echo '
151 156
 	<link rel="next" href="', $context['links']['next'], '">';
157
+	}
152 158
 
153
-	if (!empty($context['links']['prev']))
154
-		echo '
159
+	if (!empty($context['links']['prev'])) {
160
+			echo '
155 161
 	<link rel="prev" href="', $context['links']['prev'], '">';
162
+	}
156 163
 
157 164
 	// If we're in a board, or a topic for that matter, the index will be the board's index.
158
-	if (!empty($context['current_board']))
159
-		echo '
165
+	if (!empty($context['current_board'])) {
166
+			echo '
160 167
 	<link rel="index" href="', $scripturl, '?board=', $context['current_board'], '.0">';
168
+	}
161 169
 
162 170
 	// Output any remaining HTML headers. (from mods, maybe?)
163 171
 	echo $context['html_headers'];
@@ -190,20 +198,22 @@  discard block
 block discarded – undo
190 198
 				<li>
191 199
 					<a href="', $scripturl, '?action=profile"', !empty($context['self_profile']) ? ' class="active"' : '', ' id="profile_menu_top" onclick="return false;">';
192 200
 
193
-		if (!empty($context['user']['avatar']))
194
-			echo $context['user']['avatar']['image'];
201
+		if (!empty($context['user']['avatar'])) {
202
+					echo $context['user']['avatar']['image'];
203
+		}
195 204
 
196 205
 		echo $context['user']['name'], '</a>
197 206
 					<div id="profile_menu" class="top_menu"></div>
198 207
 				</li>';
199 208
 
200 209
 		// Secondly, PMs if we're doing them
201
-		if ($context['allow_pm'])
202
-			echo '
210
+		if ($context['allow_pm']) {
211
+					echo '
203 212
 				<li>
204 213
 					<a href="', $scripturl, '?action=pm"', !empty($context['self_pm']) ? ' class="active"' : '', ' id="pm_menu_top">', $txt['pm_short'], !empty($context['user']['unread_messages']) ? ' <span class="amt">' . $context['user']['unread_messages'] . '</span>' : '', '</a>
205 214
 					<div id="pm_menu" class="top_menu scrollable"></div>
206 215
 				</li>';
216
+		}
207 217
 
208 218
 		// Thirdly, alerts
209 219
 		echo '
@@ -218,17 +228,18 @@  discard block
 block discarded – undo
218 228
 	}
219 229
 	// Otherwise they're a guest. Ask them to either register or login.
220 230
 	else
221
-		if (empty($maintenance))
222
-			echo '
231
+		if (empty($maintenance)) {
232
+					echo '
223 233
 			<ul class="floatleft welcome">
224 234
 				<li>', sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup'), '</li>
225 235
 			</ul>';
226
-		else
227
-			// In maintenance mode, only login is allowed and don't show OverlayDiv
236
+		} else {
237
+					// In maintenance mode, only login is allowed and don't show OverlayDiv
228 238
 			echo '
229 239
 			<ul class="floatleft welcome">
230 240
 				<li>', sprintf($txt['welcome_guest'], $txt['guest_title'], '', $scripturl. '?action=login', 'return true;'), '</li>
231 241
 			</ul>';
242
+		}
232 243
 
233 244
 	if (!empty($modSettings['userLanguage']) && !empty($context['languages']) && count($context['languages']) > 1)
234 245
 	{
@@ -236,9 +247,10 @@  discard block
 block discarded – undo
236 247
 			<form id="languages_form" method="get" class="floatright">
237 248
 				<select id="language_select" name="language" onchange="this.form.submit()">';
238 249
 
239
-		foreach ($context['languages'] as $language)
240
-			echo '
250
+		foreach ($context['languages'] as $language) {
251
+					echo '
241 252
 					<option value="', $language['filename'], '"', isset($context['user']['language']) && $context['user']['language'] == $language['filename'] ? ' selected="selected"' : '', '>', str_replace('-utf8', '', $language['name']), '</option>';
253
+		}
242 254
 
243 255
 		echo '
244 256
 				</select>
@@ -262,32 +274,37 @@  discard block
 block discarded – undo
262 274
 					<option value="all"', ($selected == 'all' ? ' selected' : ''), '>', $txt['search_entireforum'], ' </option>';
263 275
 
264 276
 		// Can't limit it to a specific topic if we are not in one
265
-		if (!empty($context['current_topic']))
266
-			echo '
277
+		if (!empty($context['current_topic'])) {
278
+					echo '
267 279
 					<option value="topic"', ($selected == 'current_topic' ? ' selected' : ''), '>', $txt['search_thistopic'], '</option>';
280
+		}
268 281
 
269 282
 		// Can't limit it to a specific board if we are not in one
270
-		if (!empty($context['current_board']))
271
-			echo '
283
+		if (!empty($context['current_board'])) {
284
+					echo '
272 285
 					<option value="board"', ($selected == 'current_board' ? ' selected' : ''), '>', $txt['search_thisbrd'], '</option>';
286
+		}
273 287
 
274 288
 		// Can't search for members if we can't see the memberlist
275
-		if (!empty($context['allow_memberlist']))
276
-			echo '
289
+		if (!empty($context['allow_memberlist'])) {
290
+					echo '
277 291
 					<option value="members"', ($selected == 'members' ? ' selected' : ''), '>', $txt['search_members'], ' </option>';
292
+		}
278 293
 
279 294
 		echo '
280 295
 				</select>';
281 296
 
282 297
 		// Search within current topic?
283
-		if (!empty($context['current_topic']))
284
-			echo '
298
+		if (!empty($context['current_topic'])) {
299
+					echo '
285 300
 				<input type="hidden" name="sd_topic" value="', $context['current_topic'], '">';
301
+		}
286 302
 
287 303
 		// If we're on a certain board, limit it to this board ;).
288
-		elseif (!empty($context['current_board']))
289
-			echo '
304
+		elseif (!empty($context['current_board'])) {
305
+					echo '
290 306
 				<input type="hidden" name="sd_brd" value="', $context['current_board'], '">';
307
+		}
291 308
 
292 309
 		echo '
293 310
 				<input type="submit" name="search2" value="', $txt['search'], '" class="button">
@@ -319,12 +336,13 @@  discard block
 block discarded – undo
319 336
 					</div>';
320 337
 
321 338
 	// Show a random news item? (or you could pick one from news_lines...)
322
-	if (!empty($settings['enable_news']) && !empty($context['random_news_line']))
323
-		echo '
339
+	if (!empty($settings['enable_news']) && !empty($context['random_news_line'])) {
340
+			echo '
324 341
 					<div class="news">
325 342
 						<h2>', $txt['news'], ': </h2>
326 343
 						<p>', $context['random_news_line'], '</p>
327 344
 					</div>';
345
+	}
328 346
 
329 347
 	echo '
330 348
 					<hr class="clear">
@@ -385,9 +403,10 @@  discard block
 block discarded – undo
385 403
 		</ul>';
386 404
 
387 405
 	// Show the load time?
388
-	if ($context['show_load_time'])
389
-		echo '
406
+	if ($context['show_load_time']) {
407
+			echo '
390 408
 		<p>', sprintf($txt['page_created_full'], $context['load_time'], $context['load_queries']), '</p>';
409
+	}
391 410
 
392 411
 	echo '
393 412
 		</div>
@@ -418,18 +437,20 @@  discard block
 block discarded – undo
418 437
 	global $context, $shown_linktree, $scripturl, $txt;
419 438
 
420 439
 	// If linktree is empty, just return - also allow an override.
421
-	if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show))
422
-		return;
440
+	if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show)) {
441
+			return;
442
+	}
423 443
 		echo '
424 444
 				<div class="navigate_section">
425 445
 					<ul>';
426 446
 
427
-	if ($context['user']['is_logged'])
428
-		echo '
447
+	if ($context['user']['is_logged']) {
448
+			echo '
429 449
 						<li class="unread_links">
430 450
 							<a href="', $scripturl, '?action=unread" title="', $txt['unread_since_visit'], '">', $txt['view_unread_category'], '</a>
431 451
 							<a href="', $scripturl, '?action=unreadreplies" title="', $txt['show_unread_replies'], '">', $txt['unread_replies'], '</a>
432 452
 						</li>';
453
+	}
433 454
 
434 455
 	// Each tree item has a URL and name. Some may have extra_before and extra_after.
435 456
 	foreach ($context['linktree'] as $link_num => $tree)
@@ -440,25 +461,29 @@  discard block
 block discarded – undo
440 461
 		// Don't show a separator for the first one.
441 462
 		// Better here. Always points to the next level when the linktree breaks to a second line.
442 463
 		// Picked a better looking HTML entity, and added support for RTL plus a span for styling.
443
-		if ($link_num != 0)
444
-			echo '
464
+		if ($link_num != 0) {
465
+					echo '
445 466
 							<span class="dividers">', $context['right_to_left'] ? ' &#9668; ' : ' &#9658; ', '</span>';
467
+		}
446 468
 
447 469
 		// Show something before the link?
448
-		if (isset($tree['extra_before']))
449
-			echo $tree['extra_before'], ' ';
470
+		if (isset($tree['extra_before'])) {
471
+					echo $tree['extra_before'], ' ';
472
+		}
450 473
 
451 474
 		// Show the link, including a URL if it should have one.
452
-		if (isset($tree['url']))
453
-			echo '
475
+		if (isset($tree['url'])) {
476
+					echo '
454 477
 							<a href="' . $tree['url'] . '"><span>' . $tree['name'] . '</span></a>';
455
-		else
456
-			echo '
478
+		} else {
479
+					echo '
457 480
 							<span>' . $tree['name'] . '</span>';
481
+		}
458 482
 
459 483
 		// Show something after the link...?
460
-		if (isset($tree['extra_after']))
461
-			echo ' ', $tree['extra_after'];
484
+		if (isset($tree['extra_after'])) {
485
+					echo ' ', $tree['extra_after'];
486
+		}
462 487
 
463 488
 		echo '
464 489
 						</li>';
@@ -509,13 +534,14 @@  discard block
 block discarded – undo
509 534
 					echo '
510 535
 									<ul>';
511 536
 
512
-					foreach ($childbutton['sub_buttons'] as $grandchildbutton)
513
-						echo '
537
+					foreach ($childbutton['sub_buttons'] as $grandchildbutton) {
538
+											echo '
514 539
 										<li>
515 540
 											<a href="', $grandchildbutton['href'], '"', isset($grandchildbutton['target']) ? ' target="' . $grandchildbutton['target'] . '"' : '', '>
516 541
 												', $grandchildbutton['title'], '
517 542
 											</a>
518 543
 										</li>';
544
+					}
519 545
 
520 546
 					echo '
521 547
 									</ul>';
@@ -546,8 +572,9 @@  discard block
 block discarded – undo
546 572
 {
547 573
 	global $context, $txt;
548 574
 
549
-	if (!is_array($strip_options))
550
-		$strip_options = array();
575
+	if (!is_array($strip_options)) {
576
+			$strip_options = array();
577
+	}
551 578
 
552 579
 	// Create the buttons...
553 580
 	$buttons = array();
@@ -556,8 +583,9 @@  discard block
 block discarded – undo
556 583
 		// As of 2.1, the 'test' for each button happens while the array is being generated. The extra 'test' check here is deprecated but kept for backward compatibility (update your mods, folks!)
557 584
 		if (!isset($value['test']) || !empty($context[$value['test']]))
558 585
 		{
559
-			if (!isset($value['id']))
560
-				$value['id'] = $key;
586
+			if (!isset($value['id'])) {
587
+							$value['id'] = $key;
588
+			}
561 589
 
562 590
 			$button = '
563 591
 				<a class="button button_strip_' . $key . (!empty($value['active']) ? ' active' : '') . (isset($value['class']) ? ' ' . $value['class'] : '') . '" ' . (!empty($value['url']) ? 'href="' . $value['url'] . '"' : '') . ' ' . (isset($value['custom']) ? ' ' . $value['custom'] : '') . '>' . $txt[$value['text']] . '</a>';
@@ -570,13 +598,15 @@  discard block
 block discarded – undo
570 598
 							<div class="overview">';
571 599
 				foreach ($value['sub_buttons'] as $element)
572 600
 				{
573
-					if (isset($element['test']) && empty($context[$element['test']]))
574
-						continue;
601
+					if (isset($element['test']) && empty($context[$element['test']])) {
602
+											continue;
603
+					}
575 604
 
576 605
 					$button .= '
577 606
 								<a href="' . $element['url'] . '"><strong>' . $txt[$element['text']] . '</strong>';
578
-					if (isset($txt[$element['text'] . '_desc']))
579
-						$button .= '<br><span>' . $txt[$element['text'] . '_desc'] . '</span>';
607
+					if (isset($txt[$element['text'] . '_desc'])) {
608
+											$button .= '<br><span>' . $txt[$element['text'] . '_desc'] . '</span>';
609
+					}
580 610
 					$button .= '</a>';
581 611
 				}
582 612
 				$button .= '
@@ -590,8 +620,9 @@  discard block
 block discarded – undo
590 620
 	}
591 621
 
592 622
 	// No buttons? No button strip either.
593
-	if (empty($buttons))
594
-		return;
623
+	if (empty($buttons)) {
624
+			return;
625
+	}
595 626
 
596 627
 	echo '
597 628
 		<div class="buttonlist', !empty($direction) ? ' float' . $direction : '', '"', (empty($buttons) ? ' style="display: none;"' : ''), (!empty($strip_options['id']) ? ' id="' . $strip_options['id'] . '"' : ''), '>
Please login to merge, or discard this patch.
Themes/default/Admin.template.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -945,7 +945,7 @@
 block discarded – undo
945 945
 				}
946 946
 
947 947
 				echo isset($config_var['postinput']) ? '
948
-											' . $config_var['postinput'] : '','
948
+											' . $config_var['postinput'] : '', '
949 949
 									</dd>';
950 950
 			}
951 951
 		}
Please login to merge, or discard this patch.
Braces   +182 added lines, -130 removed lines patch added patch discarded remove patch
@@ -61,9 +61,10 @@  discard block
 block discarded – undo
61 61
 										', implode(', ', $context['administrators']);
62 62
 
63 63
 	// If we have lots of admins... don't show them all.
64
-	if (!empty($context['more_admins_link']))
65
-		echo '
64
+	if (!empty($context['more_admins_link'])) {
65
+			echo '
66 66
 										(', $context['more_admins_link'], ')';
67
+	}
67 68
 
68 69
 	echo '
69 70
 									</div><!-- #version_details -->
@@ -80,17 +81,19 @@  discard block
 block discarded – undo
80 81
 		foreach ($area['areas'] as $item_id => $item)
81 82
 		{
82 83
 			// No point showing the 'home' page here, we're already on it!
83
-			if ($area_id == 'forum' && $item_id == 'index')
84
-				continue;
84
+			if ($area_id == 'forum' && $item_id == 'index') {
85
+							continue;
86
+			}
85 87
 
86 88
 			$url = isset($item['url']) ? $item['url'] : $scripturl . '?action=admin;area=' . $item_id . (!empty($context[$context['admin_menu_name']]['extra_parameters']) ? $context[$context['admin_menu_name']]['extra_parameters'] : '');
87 89
 
88
-			if (!empty($item['icon_file']))
89
-				echo '
90
+			if (!empty($item['icon_file'])) {
91
+							echo '
90 92
 							<a href="', $url, '" class="admin_group', !empty($item['inactive']) ? ' inactive' : '', '"><img class="large_admin_menu_icon_file" src="', $item['icon_file'], '" alt="">', $item['label'], '</a>';
91
-			else
92
-				echo '
93
+			} else {
94
+							echo '
93 95
 							<a href="', $url, '"><span class="large_', $item['icon_class'], !empty($item['inactive']) ? ' inactive' : '', '"></span>', $item['label'], '</a>';
96
+			}
94 97
 		}
95 98
 
96 99
 		echo '
@@ -98,10 +101,11 @@  discard block
 block discarded – undo
98 101
 	}
99 102
 
100 103
 	// The below functions include all the scripts needed from the simplemachines.org site. The language and format are passed for internationalization.
101
-	if (empty($modSettings['disable_smf_js']))
102
-		echo '
104
+	if (empty($modSettings['disable_smf_js'])) {
105
+			echo '
103 106
 					<script src="', $scripturl, '?action=viewsmfile;filename=current-version.js"></script>
104 107
 					<script src="', $scripturl, '?action=viewsmfile;filename=latest-news.js"></script>';
108
+	}
105 109
 
106 110
 	// This sets the announcements and current versions themselves ;).
107 111
 	echo '
@@ -178,9 +182,10 @@  discard block
 block discarded – undo
178 182
 							<em>', $version['version'], '</em>';
179 183
 
180 184
 		// more details for this item, show them a link
181
-		if ($context['can_admin'] && isset($version['more']))
182
-			echo
185
+		if ($context['can_admin'] && isset($version['more'])) {
186
+					echo
183 187
 							' <a href="', $scripturl, $version['more'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['version_check_more'], '</a>';
188
+		}
184 189
 		echo '
185 190
 							<br>';
186 191
 	}
@@ -211,21 +216,23 @@  discard block
 block discarded – undo
211 216
 
212 217
 	foreach ($context['credits'] as $section)
213 218
 	{
214
-		if (isset($section['pretext']))
215
-			echo '
219
+		if (isset($section['pretext'])) {
220
+					echo '
216 221
 							<p>', $section['pretext'], '</p>
217 222
 							<hr>';
223
+		}
218 224
 
219 225
 		echo '
220 226
 							<dl>';
221 227
 
222 228
 		foreach ($section['groups'] as $group)
223 229
 		{
224
-			if (isset($group['title']))
225
-				echo '
230
+			if (isset($group['title'])) {
231
+							echo '
226 232
 								<dt>
227 233
 									<strong>', $group['title'], ':</strong>
228 234
 								</dt>';
235
+			}
229 236
 
230 237
 			echo '
231 238
 								<dd>', implode(', ', $group['members']), '</dd>';
@@ -234,10 +241,11 @@  discard block
 block discarded – undo
234 241
 		echo '
235 242
 							</dl>';
236 243
 
237
-		if (isset($section['posttext']))
238
-			echo '
244
+		if (isset($section['posttext'])) {
245
+					echo '
239 246
 							<hr>
240 247
 							<p>', $section['posttext'], '</p>';
248
+		}
241 249
 	}
242 250
 
243 251
 	echo '
@@ -252,9 +260,10 @@  discard block
 block discarded – undo
252 260
 						smfSupportVersions.forum = "', $context['forum_version'], '";';
253 261
 
254 262
 	// Don't worry, none of this is logged, it's just used to give information that might be of use.
255
-	foreach ($context['current_versions'] as $variable => $version)
256
-		echo '
263
+	foreach ($context['current_versions'] as $variable => $version) {
264
+			echo '
257 265
 						smfSupportVersions.', $variable, ' = "', $version['version'], '";';
266
+	}
258 267
 
259 268
 	// Now we just have to include the script and wait ;).
260 269
 	echo '
@@ -350,8 +359,8 @@  discard block
 block discarded – undo
350 359
 								<tbody>';
351 360
 
352 361
 	// Loop through every source file displaying its version - using javascript.
353
-	foreach ($context['file_versions'] as $filename => $version)
354
-		echo '
362
+	foreach ($context['file_versions'] as $filename => $version) {
363
+			echo '
355 364
 									<tr class="windowbg">
356 365
 										<td class="half_table">
357 366
 											', $filename, '
@@ -363,6 +372,7 @@  discard block
 block discarded – undo
363 372
 											<em id="currentSources', $filename, '">??</em>
364 373
 										</td>
365 374
 									</tr>';
375
+	}
366 376
 
367 377
 	// Default template files.
368 378
 	echo '
@@ -388,8 +398,8 @@  discard block
 block discarded – undo
388 398
 							<table id="Default" class="table_grid">
389 399
 								<tbody>';
390 400
 
391
-	foreach ($context['default_template_versions'] as $filename => $version)
392
-		echo '
401
+	foreach ($context['default_template_versions'] as $filename => $version) {
402
+			echo '
393 403
 									<tr class="windowbg">
394 404
 										<td class="half_table">
395 405
 											', $filename, '
@@ -401,6 +411,7 @@  discard block
 block discarded – undo
401 411
 											<em id="currentDefault', $filename, '">??</em>
402 412
 										</td>
403 413
 									</tr>';
414
+	}
404 415
 
405 416
 	// Now the language files...
406 417
 	echo '
@@ -428,8 +439,8 @@  discard block
 block discarded – undo
428 439
 
429 440
 	foreach ($context['default_language_versions'] as $language => $files)
430 441
 	{
431
-		foreach ($files as $filename => $version)
432
-			echo '
442
+		foreach ($files as $filename => $version) {
443
+					echo '
433 444
 									<tr class="windowbg">
434 445
 										<td class="half_table">
435 446
 											', $filename, '.<em>', $language, '</em>.php
@@ -441,6 +452,7 @@  discard block
 block discarded – undo
441 452
 											<em id="current', $filename, '.', $language, '">??</em>
442 453
 										</td>
443 454
 									</tr>';
455
+		}
444 456
 	}
445 457
 
446 458
 	echo '
@@ -470,8 +482,8 @@  discard block
 block discarded – undo
470 482
 							<table id="Templates" class="table_grid">
471 483
 								<tbody>';
472 484
 
473
-		foreach ($context['template_versions'] as $filename => $version)
474
-			echo '
485
+		foreach ($context['template_versions'] as $filename => $version) {
486
+					echo '
475 487
 									<tr class="windowbg">
476 488
 										<td class="half_table">
477 489
 											', $filename, '
@@ -483,6 +495,7 @@  discard block
 block discarded – undo
483 495
 											<em id="currentTemplates', $filename, '">??</em>
484 496
 										</td>
485 497
 									</tr>';
498
+		}
486 499
 
487 500
 		echo '
488 501
 								</tbody>
@@ -512,8 +525,8 @@  discard block
 block discarded – undo
512 525
 							<table id="Tasks" class="table_grid">
513 526
 								<tbody>';
514 527
 
515
-		foreach ($context['tasks_versions'] as $filename => $version)
516
-			echo '
528
+		foreach ($context['tasks_versions'] as $filename => $version) {
529
+					echo '
517 530
 									<tr class="windowbg">
518 531
 										<td class="half_table">
519 532
 											', $filename, '
@@ -525,6 +538,7 @@  discard block
 block discarded – undo
525 538
 											<em id="currentTasks', $filename, '">??</em>
526 539
 										</td>
527 540
 									</tr>';
541
+		}
528 542
 
529 543
 		echo '
530 544
 								</tbody>
@@ -565,9 +579,10 @@  discard block
 block discarded – undo
565 579
 {
566 580
 	global $context, $scripturl, $txt, $modSettings;
567 581
 
568
-	if (!empty($context['saved_successful']))
569
-		echo '
582
+	if (!empty($context['saved_successful'])) {
583
+			echo '
570 584
 					<div class="infobox">', $txt['settings_saved'], '</div>';
585
+	}
571 586
 
572 587
 	// First section is for adding/removing words from the censored list.
573 588
 	echo '
@@ -581,11 +596,12 @@  discard block
 block discarded – undo
581 596
 								<p>', $txt['admin_censored_where'], '</p>';
582 597
 
583 598
 	// Show text boxes for censoring [bad   ] => [good  ].
584
-	foreach ($context['censored_words'] as $vulgar => $proper)
585
-		echo '
599
+	foreach ($context['censored_words'] as $vulgar => $proper) {
600
+			echo '
586 601
 								<div class="block">
587 602
 									<input type="text" name="censor_vulgar[]" value="', $vulgar, '" size="30"> =&gt; <input type="text" name="censor_proper[]" value="', $proper, '" size="30">
588 603
 								</div>';
604
+	}
589 605
 
590 606
 	// Now provide a way to censor more words.
591 607
 	echo '
@@ -658,27 +674,30 @@  discard block
 block discarded – undo
658 674
 						<div class="windowbg">
659 675
 							', $txt['not_done_reason'];
660 676
 
661
-	if (!empty($context['continue_percent']))
662
-		echo '
677
+	if (!empty($context['continue_percent'])) {
678
+			echo '
663 679
 							<div class="progress_bar">
664 680
 								<span>', $context['continue_percent'], '%</span>
665 681
 								<div class="bar" style="width: ', $context['continue_percent'], '%;"></div>
666 682
 							</div>';
683
+	}
667 684
 
668
-	if (!empty($context['substep_enabled']))
669
-		echo '
685
+	if (!empty($context['substep_enabled'])) {
686
+			echo '
670 687
 							<div class="progress_bar progress_blue">
671 688
 								<span>', $context['substep_title'], ' (', $context['substep_continue_percent'], '%)</span>
672 689
 								<div class="bar" style="width: ', $context['substep_continue_percent'], '%;"></div>
673 690
 							</div>';
691
+	}
674 692
 
675 693
 	echo '
676 694
 							<form action="', $scripturl, $context['continue_get_data'], '" method="post" accept-charset="', $context['character_set'], '" name="autoSubmit" id="autoSubmit">';
677 695
 
678 696
 	// Do we have a token?
679
-	if (isset($context['not_done_token']) && isset($context[$context['not_done_token'] . '_token'], $context[$context['not_done_token'] . '_token_var']))
680
-		echo '
697
+	if (isset($context['not_done_token']) && isset($context[$context['not_done_token'] . '_token'], $context[$context['not_done_token'] . '_token_var'])) {
698
+			echo '
681 699
 							<input type="hidden" name="', $context[$context['not_done_token'] . '_token_var'], '" value="', $context[$context['not_done_token'] . '_token'], '">';
700
+	}
682 701
 
683 702
 	echo '
684 703
 								<input type="submit" name="cont" value="', $txt['not_done_continue'], '" class="button">
@@ -711,34 +730,39 @@  discard block
 block discarded – undo
711 730
 {
712 731
 	global $context, $txt, $scripturl;
713 732
 
714
-	if (!empty($context['saved_successful']))
715
-		echo '
733
+	if (!empty($context['saved_successful'])) {
734
+			echo '
716 735
 					<div class="infobox">', $txt['settings_saved'], '</div>';
717
-	elseif (!empty($context['saved_failed']))
718
-		echo '
736
+	} elseif (!empty($context['saved_failed'])) {
737
+			echo '
719 738
 					<div class="errorbox">', sprintf($txt['settings_not_saved'], $context['saved_failed']), '</div>';
739
+	}
720 740
 
721
-	if (!empty($context['settings_pre_javascript']))
722
-		echo '
741
+	if (!empty($context['settings_pre_javascript'])) {
742
+			echo '
723 743
 					<script>', $context['settings_pre_javascript'], '</script>';
744
+	}
724 745
 
725
-	if (!empty($context['settings_insert_above']))
726
-		echo $context['settings_insert_above'];
746
+	if (!empty($context['settings_insert_above'])) {
747
+			echo $context['settings_insert_above'];
748
+	}
727 749
 
728 750
 	echo '
729 751
 						<form id="admin_form_wrapper" action="', $context['post_url'], '" method="post" accept-charset="', $context['character_set'], '"', !empty($context['force_form_onsubmit']) ? ' onsubmit="' . $context['force_form_onsubmit'] . '"' : '', '>';
730 752
 
731 753
 	// Is there a custom title?
732
-	if (isset($context['settings_title']))
733
-		echo '
754
+	if (isset($context['settings_title'])) {
755
+			echo '
734 756
 							<div class="cat_bar">
735 757
 								<h3 class="catbg">', $context['settings_title'], '</h3>
736 758
 							</div>';
759
+	}
737 760
 
738 761
 	// Have we got a message to display?
739
-	if (!empty($context['settings_message']))
740
-		echo '
762
+	if (!empty($context['settings_message'])) {
763
+			echo '
741 764
 							<div class="information">', $context['settings_message'], '</div>';
765
+	}
742 766
 
743 767
 	// Now actually loop through all the variables.
744 768
 	$is_open = false;
@@ -791,8 +815,9 @@  discard block
 block discarded – undo
791 815
 		// Hang about? Are you pulling my leg - a callback?!
792 816
 		if (is_array($config_var) && $config_var['type'] == 'callback')
793 817
 		{
794
-			if (function_exists('template_callback_' . $config_var['name']))
795
-				call_user_func('template_callback_' . $config_var['name']);
818
+			if (function_exists('template_callback_' . $config_var['name'])) {
819
+							call_user_func('template_callback_' . $config_var['name']);
820
+			}
796 821
 
797 822
 			continue;
798 823
 		}
@@ -822,9 +847,10 @@  discard block
 block discarded – undo
822 847
 				$text_types = array('color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time');
823 848
 
824 849
 				// Show the [?] button.
825
-				if ($config_var['help'])
826
-					echo '
850
+				if ($config_var['help']) {
851
+									echo '
827 852
 										<a id="setting_', $config_var['name'], '_help" href="', $scripturl, '?action=helpadmin;help=', $config_var['help'], '" onclick="return reqOverlayDiv(this.href);"><span class="generic_icons help" title="', $txt['help'], '"></span></a> ';
853
+				}
828 854
 
829 855
 				echo '
830 856
 										<a id="setting_', $config_var['name'], '"></a> <span', ($config_var['disabled'] ? ' style="color: #777777;"' : ($config_var['invalid'] ? ' class="error"' : '')), '><label for="', $config_var['name'], '">', $config_var['label'], '</label>', $subtext, ($config_var['type'] == 'password' ? '<br><em>' . $txt['admin_confirm_password'] . '</em>' : ''), '</span>
@@ -833,23 +859,26 @@  discard block
 block discarded – undo
833 859
 										$config_var['preinput'];
834 860
 
835 861
 				// Show a check box.
836
-				if ($config_var['type'] == 'check')
837
-					echo '
862
+				if ($config_var['type'] == 'check') {
863
+									echo '
838 864
 										<input type="checkbox"', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '"', ($config_var['value'] ? ' checked' : ''), ' value="1">';
865
+				}
839 866
 				// Escape (via htmlspecialchars.) the text box.
840
-				elseif ($config_var['type'] == 'password')
841
-					echo '
867
+				elseif ($config_var['type'] == 'password') {
868
+									echo '
842 869
 										<input type="password"', $disabled, $javascript, ' name="', $config_var['name'], '[0]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), ' value="*#fakepass#*" onfocus="this.value = \'\'; this.form.', $config_var['name'], '.disabled = false;"><br>
843 870
 										<input type="password" disabled id="', $config_var['name'], '" name="', $config_var['name'], '[1]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), '>';
871
+				}
844 872
 				// Show a selection box.
845 873
 				elseif ($config_var['type'] == 'select')
846 874
 				{
847 875
 					echo '
848 876
 										<select name="', $config_var['name'], '" id="', $config_var['name'], '" ', $javascript, $disabled, (!empty($config_var['multiple']) ? ' multiple="multiple"' : ''), (!empty($config_var['multiple']) && !empty($config_var['size']) ? ' size="' . $config_var['size'] . '"' : ''), '>';
849 877
 
850
-					foreach ($config_var['data'] as $option)
851
-						echo '
878
+					foreach ($config_var['data'] as $option) {
879
+											echo '
852 880
 											<option value="', $option[0], '"', (!empty($config_var['value']) && ($option[0] == $config_var['value'] || (!empty($config_var['multiple']) && in_array($option[0], $config_var['value']))) ? ' selected' : ''), '>', $option[1], '</option>';
881
+					}
853 882
 					echo '
854 883
 										</select>';
855 884
 				}
@@ -866,16 +895,18 @@  discard block
 block discarded – undo
866 895
 
867 896
 					foreach ($context['board_list'] as $id_cat => $cat)
868 897
 					{
869
-						if (!$first)
870
-							echo '
898
+						if (!$first) {
899
+													echo '
871 900
 											<hr>';
901
+						}
872 902
 						echo '
873 903
 											<strong>', $cat['name'], '</strong>
874 904
 											<ul>';
875 905
 
876
-						foreach ($cat['boards'] as $id_board => $brd)
877
-							echo '
906
+						foreach ($cat['boards'] as $id_board => $brd) {
907
+													echo '
878 908
 												<li><label><input type="checkbox" name="', $config_var['name'], '[', $brd['id'], ']" value="1"', in_array($brd['id'], $config_var['value']) ? ' checked' : '', '> ', $brd['child_level'] > 0 ? str_repeat('&nbsp; &nbsp;', $brd['child_level']) : '', $brd['name'], '</label></li>';
909
+						}
879 910
 
880 911
 						echo '
881 912
 											</ul>';
@@ -885,12 +916,14 @@  discard block
 block discarded – undo
885 916
 										</fieldset>';
886 917
 				}
887 918
 				// Text area?
888
-				elseif ($config_var['type'] == 'large_text')
889
-					echo '
919
+				elseif ($config_var['type'] == 'large_text') {
920
+									echo '
890 921
 										<textarea rows="', (!empty($config_var['size']) ? $config_var['size'] : (!empty($config_var['rows']) ? $config_var['rows'] : 4)), '" cols="', (!empty($config_var['cols']) ? $config_var['cols'] : 30), '" ', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '">', $config_var['value'], '</textarea>';
922
+				}
891 923
 				// Permission group?
892
-				elseif ($config_var['type'] == 'permissions')
893
-					theme_inline_permissions($config_var['name']);
924
+				elseif ($config_var['type'] == 'permissions') {
925
+									theme_inline_permissions($config_var['name']);
926
+				}
894 927
 
895 928
 				// BBC selection?
896 929
 				elseif ($config_var['type'] == 'bbc')
@@ -902,22 +935,24 @@  discard block
 block discarded – undo
902 935
 
903 936
 					foreach ($context['bbc_columns'] as $bbcColumn)
904 937
 					{
905
-						foreach ($bbcColumn as $bbcTag)
906
-							echo '
938
+						foreach ($bbcColumn as $bbcTag) {
939
+													echo '
907 940
 												<li class="list_bbc floatleft">
908 941
 													<input type="checkbox" name="', $config_var['name'], '_enabledTags[]" id="tag_', $config_var['name'], '_', $bbcTag['tag'], '" value="', $bbcTag['tag'], '"', !in_array($bbcTag['tag'], $context['bbc_sections'][$config_var['name']]['disabled']) ? ' checked' : '', '> <label for="tag_', $config_var['name'], '_', $bbcTag['tag'], '">', $bbcTag['tag'], '</label>', $bbcTag['show_help'] ? ' (<a href="' . $scripturl . '?action=helpadmin;help=tag_' . $bbcTag['tag'] . '" onclick="return reqOverlayDiv(this.href);">?</a>)' : '', '
909 942
 												</li>';
943
+						}
910 944
 					}
911 945
 					echo '					</ul>
912 946
 											<input type="checkbox" id="bbc_', $config_var['name'], '_select_all" onclick="invertAll(this, this.form, \'', $config_var['name'], '_enabledTags\');"', $context['bbc_sections'][$config_var['name']]['all_selected'] ? ' checked' : '', '> <label for="bbc_', $config_var['name'], '_select_all"><em>', $txt['bbcTagsToUse_select_all'], '</em></label>
913 947
 										</fieldset>';
914 948
 				}
915 949
 				// A simple message?
916
-				elseif ($config_var['type'] == 'var_message')
917
-					echo '
950
+				elseif ($config_var['type'] == 'var_message') {
951
+									echo '
918 952
 										<div', !empty($config_var['name']) ? ' id="' . $config_var['name'] . '"' : '', '>
919 953
 											', $config_var['var_message'], '
920 954
 										</div>';
955
+				}
921 956
 				// Assume it must be a text box
922 957
 				else
923 958
 				{
@@ -942,61 +977,69 @@  discard block
 block discarded – undo
942 977
 											' . $config_var['postinput'] : '','
943 978
 									</dd>';
944 979
 			}
945
-		}
946
-		else
980
+		} else
947 981
 		{
948 982
 			// Just show a separator.
949
-			if ($config_var == '')
950
-				echo '
983
+			if ($config_var == '') {
984
+							echo '
951 985
 								</dl>
952 986
 								<hr>
953 987
 								<dl class="settings">';
954
-			else
955
-				echo '
988
+			} else {
989
+							echo '
956 990
 									<dd>
957 991
 										<strong>' . $config_var . '</strong>
958 992
 									</dd>';
993
+			}
959 994
 		}
960 995
 	}
961 996
 
962
-	if ($is_open)
963
-		echo '
997
+	if ($is_open) {
998
+			echo '
964 999
 								</dl>';
1000
+	}
965 1001
 
966
-	if (empty($context['settings_save_dont_show']))
967
-		echo '
1002
+	if (empty($context['settings_save_dont_show'])) {
1003
+			echo '
968 1004
 								<input type="submit" value="', $txt['save'], '"', (!empty($context['save_disabled']) ? ' disabled' : ''), (!empty($context['settings_save_onclick']) ? ' onclick="' . $context['settings_save_onclick'] . '"' : ''), ' class="button">';
1005
+	}
969 1006
 
970
-	if ($is_open)
971
-		echo '
1007
+	if ($is_open) {
1008
+			echo '
972 1009
 							</div><!-- .windowbg -->';
1010
+	}
973 1011
 
974 1012
 
975 1013
 	// At least one token has to be used!
976
-	if (isset($context['admin-ssc_token']))
977
-		echo '
1014
+	if (isset($context['admin-ssc_token'])) {
1015
+			echo '
978 1016
 							<input type="hidden" name="', $context['admin-ssc_token_var'], '" value="', $context['admin-ssc_token'], '">';
1017
+	}
979 1018
 
980
-	if (isset($context['admin-dbsc_token']))
981
-		echo '
1019
+	if (isset($context['admin-dbsc_token'])) {
1020
+			echo '
982 1021
 							<input type="hidden" name="', $context['admin-dbsc_token_var'], '" value="', $context['admin-dbsc_token'], '">';
1022
+	}
983 1023
 
984
-	if (isset($context['admin-mp_token']))
985
-		echo '
1024
+	if (isset($context['admin-mp_token'])) {
1025
+			echo '
986 1026
 							<input type="hidden" name="', $context['admin-mp_token_var'], '" value="', $context['admin-mp_token'], '">';
1027
+	}
987 1028
 
988 1029
 	echo '
989 1030
 							<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
990 1031
 						</form>';
991 1032
 
992
-	if (!empty($context['settings_post_javascript']))
993
-		echo '
1033
+	if (!empty($context['settings_post_javascript'])) {
1034
+			echo '
994 1035
 					<script>
995 1036
 						', $context['settings_post_javascript'], '
996 1037
 					</script>';
1038
+	}
997 1039
 
998
-	if (!empty($context['settings_insert_below']))
999
-		echo $context['settings_insert_below'];
1040
+	if (!empty($context['settings_insert_below'])) {
1041
+			echo $context['settings_insert_below'];
1042
+	}
1000 1043
 
1001 1044
 	// We may have added a board listing. If we did, we need to make it work.
1002 1045
 	addInlineJavascript('
@@ -1019,9 +1062,10 @@  discard block
 block discarded – undo
1019 1062
 {
1020 1063
 	global $context, $txt;
1021 1064
 
1022
-	if (!empty($context['saved_successful']))
1023
-		echo '
1065
+	if (!empty($context['saved_successful'])) {
1066
+			echo '
1024 1067
 					<div class="infobox">', $txt['settings_saved'], '</div>';
1068
+	}
1025 1069
 
1026 1070
 	// Standard fields.
1027 1071
 	template_show_list('standard_profile_fields');
@@ -1055,11 +1099,12 @@  discard block
 block discarded – undo
1055 1099
 	{
1056 1100
 		loadLanguage('Errors');
1057 1101
 
1058
-		if (isset($txt['custom_option_' . $_GET['msg']]))
1059
-			echo '
1102
+		if (isset($txt['custom_option_' . $_GET['msg']])) {
1103
+					echo '
1060 1104
 					<div class="errorbox">',
1061 1105
 						$txt['custom_option_' . $_GET['msg']], '
1062 1106
 					</div>';
1107
+		}
1063 1108
 	}
1064 1109
 
1065 1110
 	echo '
@@ -1125,9 +1170,10 @@  discard block
 block discarded – undo
1125 1170
 										<dd>
1126 1171
 											<select name="placement" id="placement">';
1127 1172
 
1128
-	foreach ($context['cust_profile_fields_placement'] as $order => $name)
1129
-		echo '
1173
+	foreach ($context['cust_profile_fields_placement'] as $order => $name) {
1174
+			echo '
1130 1175
 												<option value="', $order, '"', $context['field']['placement'] == $order ? ' selected' : '', '>', $txt['custom_profile_placement_' . $name], '</option>';
1176
+	}
1131 1177
 
1132 1178
 	echo '
1133 1179
 											</select>
@@ -1151,9 +1197,10 @@  discard block
 block discarded – undo
1151 1197
 										<dd>
1152 1198
 											<select name="field_type" id="field_type" onchange="updateInputBoxes();">';
1153 1199
 
1154
-	foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type)
1155
-		echo '
1200
+	foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type) {
1201
+			echo '
1156 1202
 												<option value="', $field_type, '"', $context['field']['type'] == $field_type ? ' selected' : '', '>', $txt['custom_profile_type_' . $field_type], '</option>';
1203
+	}
1157 1204
 
1158 1205
 	echo '
1159 1206
 											</select>
@@ -1185,9 +1232,10 @@  discard block
 block discarded – undo
1185 1232
 										</dt>
1186 1233
 										<dd id="options_dd">';
1187 1234
 
1188
-	foreach ($context['field']['options'] as $k => $option)
1189
-		echo '
1235
+	foreach ($context['field']['options'] as $k => $option) {
1236
+			echo '
1190 1237
 											', $k == 0 ? '' : '<br>', '<input type="radio" name="default_select" value="', $k, '"', $context['field']['default_select'] == $option ? ' checked' : '', '><input type="text" name="select_option[', $k, ']" value="', $option, '">';
1238
+	}
1191 1239
 
1192 1240
 	echo '
1193 1241
 											<span id="addopt"></span>
@@ -1251,9 +1299,10 @@  discard block
 block discarded – undo
1251 1299
 								</fieldset>
1252 1300
 								<input type="submit" name="save" value="', $txt['save'], '" class="button">';
1253 1301
 
1254
-	if ($context['fid'])
1255
-		echo '
1302
+	if ($context['fid']) {
1303
+			echo '
1256 1304
 								<input type="submit" name="delete" value="', $txt['delete'], '" data-confirm="', $txt['custom_edit_delete_sure'], '" class="button you_sure">';
1305
+	}
1257 1306
 
1258 1307
 	echo '
1259 1308
 							</div><!-- .windowbg -->
@@ -1299,8 +1348,7 @@  discard block
 block discarded – undo
1299 1348
 							<p class="centertext">
1300 1349
 								<strong>', $txt['admin_search_results_none'], '</strong>
1301 1350
 							</p>';
1302
-	}
1303
-	else
1351
+	} else
1304 1352
 	{
1305 1353
 		echo '
1306 1354
 							<ol class="search_results">';
@@ -1327,9 +1375,10 @@  discard block
 block discarded – undo
1327 1375
 								<li>
1328 1376
 									<a href="', $result['url'], '"><strong>', $result['name'], '</strong></a> [', isset($txt['admin_search_section_' . $result['type']]) ? $txt['admin_search_section_' . $result['type']] : $result['type'], ']';
1329 1377
 
1330
-				if ($result['help'])
1331
-					echo '
1378
+				if ($result['help']) {
1379
+									echo '
1332 1380
 									<p class="double_height">', $result['help'], '</p>';
1381
+				}
1333 1382
 
1334 1383
 				echo '
1335 1384
 								</li>';
@@ -1369,10 +1418,11 @@  discard block
 block discarded – undo
1369 1418
 									<strong>', $txt['setup_verification_answer'], '</strong>
1370 1419
 								</dd>';
1371 1420
 
1372
-		if (!empty($context['qa_by_lang'][$lang_id]))
1373
-			foreach ($context['qa_by_lang'][$lang_id] as $q_id)
1421
+		if (!empty($context['qa_by_lang'][$lang_id])) {
1422
+					foreach ($context['qa_by_lang'][$lang_id] as $q_id)
1374 1423
 			{
1375 1424
 				$question = $context['question_answers'][$q_id];
1425
+		}
1376 1426
 
1377 1427
 				echo '
1378 1428
 								<dt>
@@ -1380,9 +1430,10 @@  discard block
 block discarded – undo
1380 1430
 								</dt>
1381 1431
 								<dd>';
1382 1432
 
1383
-				foreach ($question['answers'] as $answer)
1384
-					echo '
1433
+				foreach ($question['answers'] as $answer) {
1434
+									echo '
1385 1435
 									<input type="text" name="answer[', $lang_id, '][', $q_id, '][]" value="', $answer, '" size="50" class="verification_answer">';
1436
+				}
1386 1437
 
1387 1438
 				echo '
1388 1439
 									<div class="qa_add_answer"><a href="javascript:void(0);">[ ', $txt['setup_verification_add_answer'], ' ]</a></div>
@@ -1420,11 +1471,12 @@  discard block
 block discarded – undo
1420 1471
 							', $txt['errors_found'], ':
1421 1472
 							<ul>';
1422 1473
 
1423
-			foreach ($context['repair_errors'] as $error)
1424
-				echo '
1474
+			foreach ($context['repair_errors'] as $error) {
1475
+							echo '
1425 1476
 								<li>
1426 1477
 									', $error, '
1427 1478
 								</li>';
1479
+			}
1428 1480
 
1429 1481
 			echo '
1430 1482
 							</ul>
@@ -1434,15 +1486,14 @@  discard block
 block discarded – undo
1434 1486
 							<p class="padding">
1435 1487
 								<strong><a href="', $scripturl, '?action=admin;area=repairboards;fixErrors;', $context['session_var'], '=', $context['session_id'], ';', $context['admin-repairboards_token_var'], '=', $context['admin-repairboards_token'], '">', $txt['yes'], '</a> - <a href="', $scripturl, '?action=admin;area=maintain">', $txt['no'], '</a></strong>
1436 1488
 							</p>';
1437
-		}
1438
-		else
1439
-			echo '
1489
+		} else {
1490
+					echo '
1440 1491
 							<p>', $txt['maintain_no_errors'], '</p>
1441 1492
 							<p class="padding">
1442 1493
 								<a href="', $scripturl, '?action=admin;area=maintain;sa=routine">', $txt['maintain_return'], '</a>
1443 1494
 							</p>';
1444
-	}
1445
-	else
1495
+		}
1496
+	} else
1446 1497
 	{
1447 1498
 		if (!empty($context['redirect_to_recount']))
1448 1499
 		{
@@ -1455,8 +1506,7 @@  discard block
 block discarded – undo
1455 1506
 								<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1456 1507
 								<input type="submit" name="recount" id="recount_now" value="', $txt['errors_recount_now'], '">
1457 1508
 							</form>';
1458
-		}
1459
-		else
1509
+		} else
1460 1510
 		{
1461 1511
 			echo '
1462 1512
 							<p>', $txt['errors_fixed'], '</p>
@@ -1546,9 +1596,10 @@  discard block
 block discarded – undo
1546 1596
 								<tr class="windowbg">
1547 1597
 									<td class="equal_table">', $key, '</td>';
1548 1598
 
1549
-				foreach ($setting as $key_lm => $value)
1550
-					echo '
1599
+				foreach ($setting as $key_lm => $value) {
1600
+									echo '
1551 1601
 									<td class="equal_table">', $value, '</td>';
1602
+				}
1552 1603
 
1553 1604
 				echo '
1554 1605
 								</tr>';
@@ -1608,8 +1659,8 @@  discard block
 block discarded – undo
1608 1659
 {
1609 1660
 	global $context, $txt;
1610 1661
 
1611
-	if ($context['user']['is_admin'])
1612
-		echo '
1662
+	if ($context['user']['is_admin']) {
1663
+			echo '
1613 1664
 								<span class="floatright admin_search">
1614 1665
 									<span class="generic_icons filter centericon"></span>
1615 1666
 									<input type="search" name="search_term" placeholder="', $txt['admin_search'], '">
@@ -1620,6 +1671,7 @@  discard block
 block discarded – undo
1620 1671
 									</select>
1621 1672
 									<input type="submit" name="search_go" id="search_go" value="', $txt['admin_search_go'], '" class="button">
1622 1673
 								</span>';
1623
-}
1674
+	}
1675
+	}
1624 1676
 
1625 1677
 ?>
1626 1678
\ No newline at end of file
Please login to merge, or discard this patch.