Completed
Pull Request — release-2.1 (#3931)
by Fran
07:05
created
Sources/minify/index.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,9 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Try to handle it with the upper level index.php. (it should know what to do.)
4
-if (file_exists(dirname(dirname(__FILE__)) . '/index.php'))
4
+if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) {
5 5
 	include (dirname(dirname(__FILE__)) . '/index.php');
6
-else
6
+} else {
7 7
 	exit;
8
+}
8 9
 
9 10
 ?>
10 11
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/minify/src/Exceptions/index.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,9 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Try to handle it with the upper level index.php. (it should know what to do.)
4
-if (file_exists(dirname(dirname(__FILE__)) . '/index.php'))
4
+if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) {
5 5
 	include (dirname(dirname(__FILE__)) . '/index.php');
6
-else
6
+} else {
7 7
 	exit;
8
+}
8 9
 
9 10
 ?>
10 11
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/minify/src/index.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,9 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Try to handle it with the upper level index.php. (it should know what to do.)
4
-if (file_exists(dirname(dirname(__FILE__)) . '/index.php'))
4
+if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) {
5 5
 	include (dirname(dirname(__FILE__)) . '/index.php');
6
-else
6
+} else {
7 7
 	exit;
8
+}
8 9
 
9 10
 ?>
10 11
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/Memberlist.php 1 patch
Braces   +78 added lines, -61 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 3
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * Shows a listing of registered members.
@@ -110,8 +111,9 @@  discard block
 block discarded – undo
110 111
 
111 112
 	$context['custom_profile_fields'] = getCustFieldsMList();
112 113
 
113
-	if (!empty($context['custom_profile_fields']['columns']))
114
-		$context['columns'] += $context['custom_profile_fields']['columns'];
114
+	if (!empty($context['custom_profile_fields']['columns'])) {
115
+			$context['columns'] += $context['custom_profile_fields']['columns'];
116
+	}
115 117
 
116 118
 	$context['colspan'] = 0;
117 119
 	$context['disabled_fields'] = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array();
@@ -147,12 +149,12 @@  discard block
 block discarded – undo
147 149
 	call_integration_hook('integrate_memberlist_buttons');
148 150
 
149 151
 	// Jump to the sub action.
150
-	if (isset($subActions[$context['listing_by']]))
151
-		call_helper($subActions[$context['listing_by']][1]);
152
-
153
-	else
154
-		call_helper($subActions['all'][1]);
155
-}
152
+	if (isset($subActions[$context['listing_by']])) {
153
+			call_helper($subActions[$context['listing_by']][1]);
154
+	} else {
155
+			call_helper($subActions['all'][1]);
156
+	}
157
+	}
156 158
 
157 159
 /**
158 160
  * List all members, page by page, with sorting.
@@ -177,8 +179,9 @@  discard block
 block discarded – undo
177 179
 	if ($use_cache)
178 180
 	{
179 181
 		// Maybe there's something cached already.
180
-		if (!empty($modSettings['memberlist_cache']))
181
-			$memberlist_cache = smf_json_decode($modSettings['memberlist_cache'], true);
182
+		if (!empty($modSettings['memberlist_cache'])) {
183
+					$memberlist_cache = smf_json_decode($modSettings['memberlist_cache'], true);
184
+		}
182 185
 
183 186
 		// The chunk size for the cached index.
184 187
 		$cache_step_size = 500;
@@ -234,13 +237,15 @@  discard block
 block discarded – undo
234 237
 	}
235 238
 
236 239
 	// Set defaults for sort (real_name) and start. (0)
237
-	if (!isset($_REQUEST['sort']) || !isset($context['columns'][$_REQUEST['sort']]))
238
-		$_REQUEST['sort'] = 'real_name';
240
+	if (!isset($_REQUEST['sort']) || !isset($context['columns'][$_REQUEST['sort']])) {
241
+			$_REQUEST['sort'] = 'real_name';
242
+	}
239 243
 
240 244
 	if (!is_numeric($_REQUEST['start']))
241 245
 	{
242
-		if (preg_match('~^[^\'\\\\/]~' . ($context['utf8'] ? 'u' : ''), $smcFunc['strtolower']($_REQUEST['start']), $match) === 0)
243
-			fatal_error('Hacker?', false);
246
+		if (preg_match('~^[^\'\\\\/]~' . ($context['utf8'] ? 'u' : ''), $smcFunc['strtolower']($_REQUEST['start']), $match) === 0) {
247
+					fatal_error('Hacker?', false);
248
+		}
244 249
 
245 250
 		$_REQUEST['start'] = $match[0];
246 251
 
@@ -259,16 +264,18 @@  discard block
 block discarded – undo
259 264
 	}
260 265
 
261 266
 	$context['letter_links'] = '';
262
-	for ($i = 97; $i < 123; $i++)
263
-		$context['letter_links'] .= '<a href="' . $scripturl . '?action=mlist;sa=all;start=' . chr($i) . '#letter' . chr($i) . '">' . strtoupper(chr($i)) . '</a> ';
267
+	for ($i = 97; $i < 123; $i++) {
268
+			$context['letter_links'] .= '<a href="' . $scripturl . '?action=mlist;sa=all;start=' . chr($i) . '#letter' . chr($i) . '">' . strtoupper(chr($i)) . '</a> ';
269
+	}
264 270
 
265 271
 	// Sort out the column information.
266 272
 	foreach ($context['columns'] as $col => $column_details)
267 273
 	{
268 274
 		$context['columns'][$col]['href'] = $scripturl . '?action=mlist;sort=' . $col . ';start=0';
269 275
 
270
-		if ((!isset($_REQUEST['desc']) && $col == $_REQUEST['sort']) || ($col != $_REQUEST['sort'] && !empty($column_details['default_sort_rev'])))
271
-			$context['columns'][$col]['href'] .= ';desc';
276
+		if ((!isset($_REQUEST['desc']) && $col == $_REQUEST['sort']) || ($col != $_REQUEST['sort'] && !empty($column_details['default_sort_rev']))) {
277
+					$context['columns'][$col]['href'] .= ';desc';
278
+		}
272 279
 
273 280
 		$context['columns'][$col]['link'] = '<a href="' . $context['columns'][$col]['href'] . '" rel="nofollow">' . $context['columns'][$col]['label'] . '</a>';
274 281
 		$context['columns'][$col]['selected'] = $_REQUEST['sort'] == $col;
@@ -317,8 +324,9 @@  discard block
 block discarded – undo
317 324
 	elseif ($use_cache && $_REQUEST['sort'] === 'real_name')
318 325
 	{
319 326
 		$first_offset = floor(($memberlist_cache['num_members'] - $modSettings['defaultMaxMembers'] - $_REQUEST['start']) / $cache_step_size) * $cache_step_size;
320
-		if ($first_offset < 0)
321
-			$first_offset = 0;
327
+		if ($first_offset < 0) {
328
+					$first_offset = 0;
329
+		}
322 330
 		$second_offset = ceil(($memberlist_cache['num_members'] - $_REQUEST['start']) / $cache_step_size) * $cache_step_size;
323 331
 
324 332
 		$where = 'mem.real_name BETWEEN {string:real_name_low} AND {string:real_name_high}';
@@ -395,12 +403,13 @@  discard block
 block discarded – undo
395 403
 		)
396 404
 	);
397 405
 	$context['custom_search_fields'] = array();
398
-	while ($row = $smcFunc['db_fetch_assoc']($request))
399
-		$context['custom_search_fields'][$row['col_name']] = array(
406
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
407
+			$context['custom_search_fields'][$row['col_name']] = array(
400 408
 			'colname' => $row['col_name'],
401 409
 			'name' => $row['field_name'],
402 410
 			'desc' => $row['field_desc'],
403 411
 		);
412
+	}
404 413
 	$smcFunc['db_free_result']($request);
405 414
 
406 415
 	// They're searching..
@@ -413,23 +422,27 @@  discard block
 block discarded – undo
413 422
 		$context['old_search_value'] = urlencode($_REQUEST['search']);
414 423
 
415 424
 		// No fields?  Use default...
416
-		if (empty($_POST['fields']))
417
-			$_POST['fields'] = array('name');
425
+		if (empty($_POST['fields'])) {
426
+					$_POST['fields'] = array('name');
427
+		}
418 428
 
419 429
 		// Set defaults for how the results are sorted
420
-		if (!isset($_REQUEST['sort']) || !isset($context['columns'][$_REQUEST['sort']]))
421
-			$_REQUEST['sort'] = 'real_name';
430
+		if (!isset($_REQUEST['sort']) || !isset($context['columns'][$_REQUEST['sort']])) {
431
+					$_REQUEST['sort'] = 'real_name';
432
+		}
422 433
 
423 434
 		// Build the column link / sort information.
424 435
 		foreach ($context['columns'] as $col => $column_details)
425 436
 		{
426 437
 			$context['columns'][$col]['href'] = $scripturl . '?action=mlist;sa=search;start=0;sort=' . $col;
427 438
 
428
-			if ((!isset($_REQUEST['desc']) && $col == $_REQUEST['sort']) || ($col != $_REQUEST['sort'] && !empty($column_details['default_sort_rev'])))
429
-				$context['columns'][$col]['href'] .= ';desc';
439
+			if ((!isset($_REQUEST['desc']) && $col == $_REQUEST['sort']) || ($col != $_REQUEST['sort'] && !empty($column_details['default_sort_rev']))) {
440
+							$context['columns'][$col]['href'] .= ';desc';
441
+			}
430 442
 
431
-			if (isset($_POST['search']) && isset($_POST['fields']))
432
-				$context['columns'][$col]['href'] .= ';search=' . $_POST['search'] . ';fields=' . implode(',', $_POST['fields']);
443
+			if (isset($_POST['search']) && isset($_POST['fields'])) {
444
+							$context['columns'][$col]['href'] .= ';search=' . $_POST['search'] . ';fields=' . implode(',', $_POST['fields']);
445
+			}
433 446
 
434 447
 			$context['columns'][$col]['link'] = '<a href="' . $context['columns'][$col]['href'] . '" rel="nofollow">' . $context['columns'][$col]['label'] . '</a>';
435 448
 			$context['columns'][$col]['selected'] = $_REQUEST['sort'] == $col;
@@ -452,8 +465,7 @@  discard block
 block discarded – undo
452 465
 		{
453 466
 			$fields = allowedTo('moderate_forum') ? array('member_name', 'real_name') : array('real_name');
454 467
 			$search_fields[] = 'name';
455
-		}
456
-		else
468
+		} else
457 469
 		{
458 470
 			$fields = array();
459 471
 			$search_fields = array();
@@ -478,9 +490,10 @@  discard block
 block discarded – undo
478 490
 			$search_fields[] = 'email';
479 491
 		}
480 492
 
481
-		if ($smcFunc['db_case_sensitive'])
482
-			foreach ($fields as $key => $field)
493
+		if ($smcFunc['db_case_sensitive']) {
494
+					foreach ($fields as $key => $field)
483 495
 				$fields[$key] = 'LOWER(' . $field . ')';
496
+		}
484 497
 
485 498
 		$customJoin = array();
486 499
 		$customCount = 10;
@@ -499,8 +512,9 @@  discard block
 block discarded – undo
499 512
 		}
500 513
 
501 514
 		// No search fields? That means you're trying to hack things
502
-		if (empty($search_fields))
503
-			fatal_lang_error('invalid_search_string', false);
515
+		if (empty($search_fields)) {
516
+					fatal_lang_error('invalid_search_string', false);
517
+		}
504 518
 
505 519
 		$query = $_POST['search'] == '' ? '= {string:blank_string}' : ($smcFunc['db_case_sensitive'] ? 'LIKE LOWER({string:search})' : 'LIKE {string:search}');
506 520
 
@@ -538,8 +552,7 @@  discard block
 block discarded – undo
538 552
 		);
539 553
 		printMemberListRows($request);
540 554
 		$smcFunc['db_free_result']($request);
541
-	}
542
-	else
555
+	} else
543 556
 	{
544 557
 		// These are all the possible fields.
545 558
 		$context['search_fields'] = array(
@@ -554,14 +567,14 @@  discard block
 block discarded – undo
554 567
 		{
555 568
 			unset($context['search_fields']['email']);
556 569
 			$context['search_defaults'] = array('name');
557
-		}
558
-		else
570
+		} else
559 571
 		{
560 572
 			$context['search_defaults'] = array('name', 'email');
561 573
 		}
562 574
 
563
-		foreach ($context['custom_search_fields'] as $field)
564
-			$context['search_fields']['cust_' . $field['colname']] = sprintf($txt['mlist_search_by'], $field['name']);
575
+		foreach ($context['custom_search_fields'] as $field) {
576
+					$context['search_fields']['cust_' . $field['colname']] = sprintf($txt['mlist_search_by'], $field['name']);
577
+		}
565 578
 
566 579
 		$context['sub_template'] = 'search';
567 580
 		$context['old_search'] = isset($_GET['search']) ? $_GET['search'] : (isset($_POST['search']) ? $smcFunc['htmlspecialchars']($_POST['search']) : '');
@@ -603,12 +616,14 @@  discard block
 block discarded – undo
603 616
 	$smcFunc['db_free_result']($result);
604 617
 
605 618
 	// Avoid division by zero...
606
-	if ($most_posts == 0)
607
-		$most_posts = 1;
619
+	if ($most_posts == 0) {
620
+			$most_posts = 1;
621
+	}
608 622
 
609 623
 	$members = array();
610
-	while ($row = $smcFunc['db_fetch_assoc']($request))
611
-		$members[] = $row['id_member'];
624
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
625
+			$members[] = $row['id_member'];
626
+	}
612 627
 
613 628
 	// Load all the members for display.
614 629
 	loadMemberData($members);
@@ -616,8 +631,9 @@  discard block
 block discarded – undo
616 631
 	$context['members'] = array();
617 632
 	foreach ($members as $member)
618 633
 	{
619
-		if (!loadMemberContext($member))
620
-			continue;
634
+		if (!loadMemberContext($member)) {
635
+					continue;
636
+		}
621 637
 
622 638
 		$context['members'][$member] = $memberContext[$member];
623 639
 		$context['members'][$member]['post_percent'] = round(($context['members'][$member]['real_posts'] * 100) / $most_posts);
@@ -634,20 +650,21 @@  discard block
 block discarded – undo
634 650
 					continue;
635 651
 				}
636 652
 
637
-				if ($column['bbc'] && !empty($context['members'][$member]['options'][$key]))
638
-					$context['members'][$member]['options'][$key] = strip_tags(parse_bbc($context['members'][$member]['options'][$key]));
639
-
640
-				elseif ($column['type'] == 'check')
641
-					$context['members'][$member]['options'][$key] = $context['members'][$member]['options'][$key] == 0 ? $txt['no'] : $txt['yes'];
653
+				if ($column['bbc'] && !empty($context['members'][$member]['options'][$key])) {
654
+									$context['members'][$member]['options'][$key] = strip_tags(parse_bbc($context['members'][$member]['options'][$key]));
655
+				} elseif ($column['type'] == 'check') {
656
+									$context['members'][$member]['options'][$key] = $context['members'][$member]['options'][$key] == 0 ? $txt['no'] : $txt['yes'];
657
+				}
642 658
 
643 659
 				// Enclosing the user input within some other text?
644
-				if (!empty($column['enclose']))
645
-					$context['members'][$member]['options'][$key] = strtr($column['enclose'], array(
660
+				if (!empty($column['enclose'])) {
661
+									$context['members'][$member]['options'][$key] = strtr($column['enclose'], array(
646 662
 						'{SCRIPTURL}' => $scripturl,
647 663
 						'{IMAGES_URL}' => $settings['images_url'],
648 664
 						'{DEFAULT_IMAGES_URL}' => $settings['default_images_url'],
649 665
 						'{INPUT}' => $context['members'][$member]['options'][$key],
650 666
 					));
667
+				}
651 668
 			}
652 669
 		}
653 670
 	}
@@ -688,17 +705,17 @@  discard block
 block discarded – undo
688 705
 		);
689 706
 
690 707
 		// Get the right sort method depending on the cust field type.
691
-		if ($row['field_type'] != 'check')
692
-			$cpf['columns'][$row['col_name']]['sort'] = array(
708
+		if ($row['field_type'] != 'check') {
709
+					$cpf['columns'][$row['col_name']]['sort'] = array(
693 710
 				'down' => 'LENGTH(t' . $row['col_name'] . '.value) > 0 ASC, COALESCE(t' . $row['col_name'] . '.value, "") DESC',
694 711
 				'up' => 'LENGTH(t' . $row['col_name'] . '.value) > 0 DESC, COALESCE(t' . $row['col_name'] . '.value, "") ASC'
695 712
 			);
696
-
697
-		else
698
-			$cpf['columns'][$row['col_name']]['sort'] = array(
713
+		} else {
714
+					$cpf['columns'][$row['col_name']]['sort'] = array(
699 715
 				'down' => 't' . $row['col_name'] . '.value DESC',
700 716
 				'up' => 't' . $row['col_name'] . '.value ASC'
701 717
 			);
718
+		}
702 719
 
703 720
 		$cpf['join'][$row['col_name']] = 'LEFT JOIN {db_prefix}themes AS t' . $row['col_name'] . ' ON (t' . $row['col_name'] . '.variable = {literal:' . $row['col_name'] . '} AND t' . $row['col_name'] . '.id_theme = 1 AND t' . $row['col_name'] . '.id_member = mem.id_member)';
704 721
 	}
Please login to merge, or discard this patch.
Sources/Display.php 1 patch
Braces   +333 added lines, -249 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 3
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * The central part of the board - topic display.
@@ -34,8 +35,9 @@  discard block
 block discarded – undo
34 35
 	global $attachments, $messages_request, $language, $smcFunc;
35 36
 
36 37
 	// What are you gonna display if these are empty?!
37
-	if (empty($topic))
38
-		fatal_lang_error('no_board', false);
38
+	if (empty($topic)) {
39
+			fatal_lang_error('no_board', false);
40
+	}
39 41
 
40 42
 	// Load the proper template.
41 43
 	loadTemplate('Display');
@@ -52,15 +54,17 @@  discard block
 block discarded – undo
52 54
 	$context['messages_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages'];
53 55
 
54 56
 	// Let's do some work on what to search index.
55
-	if (count($_GET) > 2)
56
-		foreach ($_GET as $k => $v)
57
+	if (count($_GET) > 2) {
58
+			foreach ($_GET as $k => $v)
57 59
 		{
58 60
 			if (!in_array($k, array('topic', 'board', 'start', session_name())))
59 61
 				$context['robot_no_index'] = true;
62
+	}
60 63
 		}
61 64
 
62
-	if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0))
63
-		$context['robot_no_index'] = true;
65
+	if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) {
66
+			$context['robot_no_index'] = true;
67
+	}
64 68
 
65 69
 	// Find the previous or next topic.  Make a fuss if there are no more.
66 70
 	if (isset($_REQUEST['prev_next']) && ($_REQUEST['prev_next'] == 'prev' || $_REQUEST['prev_next'] == 'next'))
@@ -172,8 +176,9 @@  discard block
 block discarded – undo
172 176
 			$topic_parameters
173 177
 	);
174 178
 
175
-	if ($smcFunc['db_num_rows']($request) == 0)
176
-		fatal_lang_error('not_a_topic', false, 404);
179
+	if ($smcFunc['db_num_rows']($request) == 0) {
180
+			fatal_lang_error('not_a_topic', false, 404);
181
+	}
177 182
 	$context['topicinfo'] = $smcFunc['db_fetch_assoc']($request);
178 183
 	$smcFunc['db_free_result']($request);
179 184
 
@@ -210,8 +215,9 @@  discard block
 block discarded – undo
210 215
 	$context['topic_unwatched'] = isset($context['topicinfo']['unwatched']) ? $context['topicinfo']['unwatched'] : 0;
211 216
 
212 217
 	// Add up unapproved replies to get real number of replies...
213
-	if ($modSettings['postmod_active'] && $approve_posts)
214
-		$context['real_num_replies'] += $context['topicinfo']['unapproved_posts'] - ($context['topicinfo']['approved'] ? 0 : 1);
218
+	if ($modSettings['postmod_active'] && $approve_posts) {
219
+			$context['real_num_replies'] += $context['topicinfo']['unapproved_posts'] - ($context['topicinfo']['approved'] ? 0 : 1);
220
+	}
215 221
 
216 222
 	// If this topic has unapproved posts, we need to work out how many posts the user can see, for page indexing.
217 223
 	if ($modSettings['postmod_active'] && $context['topicinfo']['unapproved_posts'] && !$user_info['is_guest'] && !$approve_posts)
@@ -231,11 +237,11 @@  discard block
 block discarded – undo
231 237
 		$smcFunc['db_free_result']($request);
232 238
 
233 239
 		$context['total_visible_posts'] = $context['num_replies'] + $myUnapprovedPosts + ($context['topicinfo']['approved'] ? 1 : 0);
240
+	} elseif ($user_info['is_guest']) {
241
+			$context['total_visible_posts'] = $context['num_replies'] + ($context['topicinfo']['approved'] ? 1 : 0);
242
+	} else {
243
+			$context['total_visible_posts'] = $context['num_replies'] + $context['topicinfo']['unapproved_posts'] + ($context['topicinfo']['approved'] ? 1 : 0);
234 244
 	}
235
-	elseif ($user_info['is_guest'])
236
-		$context['total_visible_posts'] = $context['num_replies'] + ($context['topicinfo']['approved'] ? 1 : 0);
237
-	else
238
-		$context['total_visible_posts'] = $context['num_replies'] + $context['topicinfo']['unapproved_posts'] + ($context['topicinfo']['approved'] ? 1 : 0);
239 245
 
240 246
 	// The start isn't a number; it's information about what to do, where to go.
241 247
 	if (!is_numeric($_REQUEST['start']))
@@ -248,8 +254,7 @@  discard block
 block discarded – undo
248 254
 			{
249 255
 				$context['start_from'] = $context['total_visible_posts'] - 1;
250 256
 				$_REQUEST['start'] = empty($options['view_newest_first']) ? $context['start_from'] : 0;
251
-			}
252
-			else
257
+			} else
253 258
 			{
254 259
 				// Find the earliest unread message in the topic. (the use of topics here is just for both tables.)
255 260
 				$request = $smcFunc['db_query']('', '
@@ -277,9 +282,9 @@  discard block
 block discarded – undo
277 282
 		if (substr($_REQUEST['start'], 0, 4) == 'from')
278 283
 		{
279 284
 			$timestamp = (int) substr($_REQUEST['start'], 4);
280
-			if ($timestamp === 0)
281
-				$_REQUEST['start'] = 0;
282
-			else
285
+			if ($timestamp === 0) {
286
+							$_REQUEST['start'] = 0;
287
+			} else
283 288
 			{
284 289
 				// Find the number of messages posted before said time...
285 290
 				$request = $smcFunc['db_query']('', '
@@ -307,11 +312,11 @@  discard block
 block discarded – undo
307 312
 		elseif (substr($_REQUEST['start'], 0, 3) == 'msg')
308 313
 		{
309 314
 			$virtual_msg = (int) substr($_REQUEST['start'], 3);
310
-			if (!$context['topicinfo']['unapproved_posts'] && $virtual_msg >= $context['topicinfo']['id_last_msg'])
311
-				$context['start_from'] = $context['total_visible_posts'] - 1;
312
-			elseif (!$context['topicinfo']['unapproved_posts'] && $virtual_msg <= $context['topicinfo']['id_first_msg'])
313
-				$context['start_from'] = 0;
314
-			else
315
+			if (!$context['topicinfo']['unapproved_posts'] && $virtual_msg >= $context['topicinfo']['id_last_msg']) {
316
+							$context['start_from'] = $context['total_visible_posts'] - 1;
317
+			} elseif (!$context['topicinfo']['unapproved_posts'] && $virtual_msg <= $context['topicinfo']['id_first_msg']) {
318
+							$context['start_from'] = 0;
319
+			} else
315 320
 			{
316 321
 				// Find the start value for that message......
317 322
 				$request = $smcFunc['db_query']('', '
@@ -394,21 +399,25 @@  discard block
 block discarded – undo
394 399
 		);
395 400
 		while ($row = $smcFunc['db_fetch_assoc']($request))
396 401
 		{
397
-			if (empty($row['id_member']))
398
-				continue;
402
+			if (empty($row['id_member'])) {
403
+							continue;
404
+			}
399 405
 
400
-			if (!empty($row['online_color']))
401
-				$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>';
402
-			else
403
-				$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
406
+			if (!empty($row['online_color'])) {
407
+							$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>';
408
+			} else {
409
+							$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
410
+			}
404 411
 
405 412
 			$is_buddy = in_array($row['id_member'], $user_info['buddies']);
406
-			if ($is_buddy)
407
-				$link = '<strong>' . $link . '</strong>';
413
+			if ($is_buddy) {
414
+							$link = '<strong>' . $link . '</strong>';
415
+			}
408 416
 
409 417
 			// Add them both to the list and to the more detailed list.
410
-			if (!empty($row['show_online']) || allowedTo('moderate_forum'))
411
-				$context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link;
418
+			if (!empty($row['show_online']) || allowedTo('moderate_forum')) {
419
+							$context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link;
420
+			}
412 421
 			$context['view_members'][$row['log_time'] . $row['member_name']] = array(
413 422
 				'id' => $row['id_member'],
414 423
 				'username' => $row['member_name'],
@@ -420,8 +429,9 @@  discard block
 block discarded – undo
420 429
 				'hidden' => empty($row['show_online']),
421 430
 			);
422 431
 
423
-			if (empty($row['show_online']))
424
-				$context['view_num_hidden']++;
432
+			if (empty($row['show_online'])) {
433
+							$context['view_num_hidden']++;
434
+			}
425 435
 		}
426 436
 
427 437
 		// The number of guests is equal to the rows minus the ones we actually used ;).
@@ -435,11 +445,13 @@  discard block
 block discarded – undo
435 445
 
436 446
 	// If all is set, but not allowed... just unset it.
437 447
 	$can_show_all = !empty($modSettings['enableAllMessages']) && $context['total_visible_posts'] > $context['messages_per_page'] && $context['total_visible_posts'] < $modSettings['enableAllMessages'];
438
-	if (isset($_REQUEST['all']) && !$can_show_all)
439
-		unset($_REQUEST['all']);
448
+	if (isset($_REQUEST['all']) && !$can_show_all) {
449
+			unset($_REQUEST['all']);
450
+	}
440 451
 	// Otherwise, it must be allowed... so pretend start was -1.
441
-	elseif (isset($_REQUEST['all']))
442
-		$_REQUEST['start'] = -1;
452
+	elseif (isset($_REQUEST['all'])) {
453
+			$_REQUEST['start'] = -1;
454
+	}
443 455
 
444 456
 	// Construct the page index, allowing for the .START method...
445 457
 	$context['page_index'] = constructPageIndex($scripturl . '?topic=' . $topic . '.%1$d', $_REQUEST['start'], $context['total_visible_posts'], $context['messages_per_page'], true);
@@ -476,8 +488,9 @@  discard block
 block discarded – undo
476 488
 			$_REQUEST['start'] = 0;
477 489
 		}
478 490
 		// They aren't using it, but the *option* is there, at least.
479
-		else
480
-			$context['page_index'] .= '&nbsp;<a href="' . $scripturl . '?topic=' . $topic . '.0;all">' . $txt['all'] . '</a> ';
491
+		else {
492
+					$context['page_index'] .= '&nbsp;<a href="' . $scripturl . '?topic=' . $topic . '.0;all">' . $txt['all'] . '</a> ';
493
+		}
481 494
 	}
482 495
 
483 496
 	// Build the link tree.
@@ -493,14 +506,16 @@  discard block
 block discarded – undo
493 506
 	if (!empty($board_info['moderators']))
494 507
 	{
495 508
 		// Add a link for each moderator...
496
-		foreach ($board_info['moderators'] as $mod)
497
-			$context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>';
509
+		foreach ($board_info['moderators'] as $mod) {
510
+					$context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>';
511
+		}
498 512
 	}
499 513
 	if (!empty($board_info['moderator_groups']))
500 514
 	{
501 515
 		// Add a link for each moderator group as well...
502
-		foreach ($board_info['moderator_groups'] as $mod_group)
503
-			$context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=viewmemberes;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>';
516
+		foreach ($board_info['moderator_groups'] as $mod_group) {
517
+					$context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=viewmemberes;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>';
518
+		}
504 519
 	}
505 520
 
506 521
 	if (!empty($context['link_moderators']))
@@ -531,9 +546,9 @@  discard block
 block discarded – undo
531 546
 	// For quick reply we need a response prefix in the default forum language.
532 547
 	if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix', 600)))
533 548
 	{
534
-		if ($language === $user_info['language'])
535
-			$context['response_prefix'] = $txt['response_prefix'];
536
-		else
549
+		if ($language === $user_info['language']) {
550
+					$context['response_prefix'] = $txt['response_prefix'];
551
+		} else
537 552
 		{
538 553
 			loadLanguage('index', $language, false);
539 554
 			$context['response_prefix'] = $txt['response_prefix'];
@@ -565,8 +580,9 @@  discard block
 block discarded – undo
565 580
 			list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row);
566 581
 
567 582
 			// Sanity check
568
-			if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count']))
569
-				continue;
583
+			if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) {
584
+							continue;
585
+			}
570 586
 
571 587
 			$linked_calendar_event = array(
572 588
 				'id' => $row['id_event'],
@@ -615,8 +631,9 @@  discard block
 block discarded – undo
615 631
 		}
616 632
 		$smcFunc['db_free_result']($request);
617 633
 
618
-		if (!empty($context['linked_calendar_events']))
619
-			$context['linked_calendar_events'][count($context['linked_calendar_events']) - 1]['is_last'] = true;
634
+		if (!empty($context['linked_calendar_events'])) {
635
+					$context['linked_calendar_events'][count($context['linked_calendar_events']) - 1]['is_last'] = true;
636
+		}
620 637
 	}
621 638
 
622 639
 	// Create the poll info if it exists.
@@ -689,20 +706,21 @@  discard block
 block discarded – undo
689 706
 				foreach ($guestinfo as $i => $guestvoted)
690 707
 				{
691 708
 					$guestvoted = explode(',', $guestvoted);
692
-					if ($guestvoted[0] == $context['topicinfo']['id_poll'])
693
-						break;
709
+					if ($guestvoted[0] == $context['topicinfo']['id_poll']) {
710
+											break;
711
+					}
694 712
 				}
695 713
 				// Has the poll been reset since guest voted?
696 714
 				if ($pollinfo['reset_poll'] > $guestvoted[1])
697 715
 				{
698 716
 					// Remove the poll info from the cookie to allow guest to vote again
699 717
 					unset($guestinfo[$i]);
700
-					if (!empty($guestinfo))
701
-						$_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo);
702
-					else
703
-						unset($_COOKIE['guest_poll_vote']);
704
-				}
705
-				else
718
+					if (!empty($guestinfo)) {
719
+											$_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo);
720
+					} else {
721
+											unset($_COOKIE['guest_poll_vote']);
722
+					}
723
+				} else
706 724
 				{
707 725
 					// What did they vote for?
708 726
 					unset($guestvoted[0], $guestvoted[1]);
@@ -816,23 +834,29 @@  discard block
 block discarded – undo
816 834
 		// Build the poll moderation button array.
817 835
 		$context['poll_buttons'] = array();
818 836
 
819
-		if ($context['allow_return_vote'])
820
-			$context['poll_buttons']['vote'] = array('text' => 'poll_return_vote', 'image' => 'poll_options.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']);
837
+		if ($context['allow_return_vote']) {
838
+					$context['poll_buttons']['vote'] = array('text' => 'poll_return_vote', 'image' => 'poll_options.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']);
839
+		}
821 840
 
822
-		if ($context['show_view_results_button'])
823
-			$context['poll_buttons']['results'] = array('text' => 'poll_results', 'image' => 'poll_results.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults');
841
+		if ($context['show_view_results_button']) {
842
+					$context['poll_buttons']['results'] = array('text' => 'poll_results', 'image' => 'poll_results.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults');
843
+		}
824 844
 
825
-		if ($context['allow_change_vote'])
826
-			$context['poll_buttons']['change_vote'] = array('text' => 'poll_change_vote', 'image' => 'poll_change_vote.png', 'url' => $scripturl . '?action=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . ';' . $context['session_var'] . '=' . $context['session_id']);
845
+		if ($context['allow_change_vote']) {
846
+					$context['poll_buttons']['change_vote'] = array('text' => 'poll_change_vote', 'image' => 'poll_change_vote.png', 'url' => $scripturl . '?action=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . ';' . $context['session_var'] . '=' . $context['session_id']);
847
+		}
827 848
 
828
-		if ($context['allow_lock_poll'])
829
-			$context['poll_buttons']['lock'] = array('text' => (!$context['poll']['is_locked'] ? 'poll_lock' : 'poll_unlock'), 'image' => 'poll_lock.png', 'url' => $scripturl . '?action=lockvoting;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
849
+		if ($context['allow_lock_poll']) {
850
+					$context['poll_buttons']['lock'] = array('text' => (!$context['poll']['is_locked'] ? 'poll_lock' : 'poll_unlock'), 'image' => 'poll_lock.png', 'url' => $scripturl . '?action=lockvoting;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
851
+		}
830 852
 
831
-		if ($context['allow_edit_poll'])
832
-			$context['poll_buttons']['edit'] = array('text' => 'poll_edit', 'image' => 'poll_edit.png', 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']);
853
+		if ($context['allow_edit_poll']) {
854
+					$context['poll_buttons']['edit'] = array('text' => 'poll_edit', 'image' => 'poll_edit.png', 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']);
855
+		}
833 856
 
834
-		if ($context['can_remove_poll'])
835
-			$context['poll_buttons']['remove_poll'] = array('text' => 'poll_remove', 'image' => 'admin_remove_poll.png', 'custom' => 'data-confirm="' . $txt['poll_remove_warn'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removepoll;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
857
+		if ($context['can_remove_poll']) {
858
+					$context['poll_buttons']['remove_poll'] = array('text' => 'poll_remove', 'image' => 'admin_remove_poll.png', 'custom' => 'data-confirm="' . $txt['poll_remove_warn'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removepoll;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
859
+		}
836 860
 
837 861
 		// Allow mods to add additional buttons here
838 862
 		call_integration_hook('integrate_poll_buttons');
@@ -873,8 +897,9 @@  discard block
 block discarded – undo
873 897
 	$all_posters = array();
874 898
 	while ($row = $smcFunc['db_fetch_assoc']($request))
875 899
 	{
876
-		if (!empty($row['id_member']))
877
-			$all_posters[$row['id_msg']] = $row['id_member'];
900
+		if (!empty($row['id_member'])) {
901
+					$all_posters[$row['id_msg']] = $row['id_member'];
902
+		}
878 903
 		$messages[] = $row['id_msg'];
879 904
 	}
880 905
 	$smcFunc['db_free_result']($request);
@@ -886,8 +911,9 @@  discard block
 block discarded – undo
886 911
 	if (!$user_info['is_guest'] && !empty($messages))
887 912
 	{
888 913
 		$mark_at_msg = max($messages);
889
-		if ($mark_at_msg >= $context['topicinfo']['id_last_msg'])
890
-			$mark_at_msg = $modSettings['maxMsgID'];
914
+		if ($mark_at_msg >= $context['topicinfo']['id_last_msg']) {
915
+					$mark_at_msg = $modSettings['maxMsgID'];
916
+		}
891 917
 		if ($mark_at_msg >= $context['topicinfo']['new_from'])
892 918
 		{
893 919
 			$smcFunc['db_insert']($context['topicinfo']['new_from'] == 0 ? 'ignore' : 'replace',
@@ -919,8 +945,9 @@  discard block
 block discarded – undo
919 945
 		while ($row = $smcFunc['db_fetch_assoc']($request))
920 946
 		{
921 947
 			// Find if this topic is marked for notification...
922
-			if (!empty($row['id_topic']))
923
-				$context['is_marked_notify'] = true;
948
+			if (!empty($row['id_topic'])) {
949
+							$context['is_marked_notify'] = true;
950
+			}
924 951
 
925 952
 			// Only do this once, but mark the notifications as "not sent yet" for next time.
926 953
 			if (!empty($row['sent']) && $do_once)
@@ -942,8 +969,9 @@  discard block
 block discarded – undo
942 969
 		}
943 970
 
944 971
 		// Have we recently cached the number of new topics in this board, and it's still a lot?
945
-		if (isset($_REQUEST['topicseen']) && isset($_SESSION['topicseen_cache'][$board]) && $_SESSION['topicseen_cache'][$board] > 5)
946
-			$_SESSION['topicseen_cache'][$board]--;
972
+		if (isset($_REQUEST['topicseen']) && isset($_SESSION['topicseen_cache'][$board]) && $_SESSION['topicseen_cache'][$board] > 5) {
973
+					$_SESSION['topicseen_cache'][$board]--;
974
+		}
947 975
 		// Mark board as seen if this is the only new topic.
948 976
 		elseif (isset($_REQUEST['topicseen']))
949 977
 		{
@@ -967,14 +995,16 @@  discard block
 block discarded – undo
967 995
 			$smcFunc['db_free_result']($request);
968 996
 
969 997
 			// If there're no real new topics in this board, mark the board as seen.
970
-			if (empty($numNewTopics))
971
-				$_REQUEST['boardseen'] = true;
972
-			else
973
-				$_SESSION['topicseen_cache'][$board] = $numNewTopics;
998
+			if (empty($numNewTopics)) {
999
+							$_REQUEST['boardseen'] = true;
1000
+			} else {
1001
+							$_SESSION['topicseen_cache'][$board] = $numNewTopics;
1002
+			}
974 1003
 		}
975 1004
 		// Probably one less topic - maybe not, but even if we decrease this too fast it will only make us look more often.
976
-		elseif (isset($_SESSION['topicseen_cache'][$board]))
977
-			$_SESSION['topicseen_cache'][$board]--;
1005
+		elseif (isset($_SESSION['topicseen_cache'][$board])) {
1006
+					$_SESSION['topicseen_cache'][$board]--;
1007
+		}
978 1008
 
979 1009
 		// Mark board as seen if we came using last post link from BoardIndex. (or other places...)
980 1010
 		if (isset($_REQUEST['boardseen']))
@@ -1031,23 +1061,26 @@  discard block
 block discarded – undo
1031 1061
 			$temp = array();
1032 1062
 			while ($row = $smcFunc['db_fetch_assoc']($request))
1033 1063
 			{
1034
-				if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id']))
1035
-					continue;
1064
+				if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) {
1065
+									continue;
1066
+				}
1036 1067
 
1037 1068
 				$temp[$row['id_attach']] = $row;
1038 1069
 				$temp[$row['id_attach']]['topic'] = $topic;
1039 1070
 				$temp[$row['id_attach']]['board'] = $board;
1040 1071
 
1041
-				if (!isset($context['loaded_attachments'][$row['id_msg']]))
1042
-					$context['loaded_attachments'][$row['id_msg']] = array();
1072
+				if (!isset($context['loaded_attachments'][$row['id_msg']])) {
1073
+									$context['loaded_attachments'][$row['id_msg']] = array();
1074
+				}
1043 1075
 			}
1044 1076
 			$smcFunc['db_free_result']($request);
1045 1077
 
1046 1078
 			// This is better than sorting it with the query...
1047 1079
 			ksort($temp);
1048 1080
 
1049
-			foreach ($temp as $row)
1050
-				$context['loaded_attachments'][$row['id_msg']][] = $row;
1081
+			foreach ($temp as $row) {
1082
+							$context['loaded_attachments'][$row['id_msg']][] = $row;
1083
+			}
1051 1084
 		}
1052 1085
 
1053 1086
 		$msg_parameters = array(
@@ -1074,21 +1107,23 @@  discard block
 block discarded – undo
1074 1107
 		);
1075 1108
 
1076 1109
 		// And the likes
1077
-		if (!empty($modSettings['enable_likes']))
1078
-			$context['my_likes'] = $context['user']['is_guest'] ? array() : prepareLikesContext($topic);
1110
+		if (!empty($modSettings['enable_likes'])) {
1111
+					$context['my_likes'] = $context['user']['is_guest'] ? array() : prepareLikesContext($topic);
1112
+		}
1079 1113
 
1080 1114
 		// Go to the last message if the given time is beyond the time of the last message.
1081
-		if (isset($context['start_from']) && $context['start_from'] >= $context['topicinfo']['num_replies'])
1082
-			$context['start_from'] = $context['topicinfo']['num_replies'];
1115
+		if (isset($context['start_from']) && $context['start_from'] >= $context['topicinfo']['num_replies']) {
1116
+					$context['start_from'] = $context['topicinfo']['num_replies'];
1117
+		}
1083 1118
 
1084 1119
 		// Since the anchor information is needed on the top of the page we load these variables beforehand.
1085 1120
 		$context['first_message'] = isset($messages[$firstIndex]) ? $messages[$firstIndex] : $messages[0];
1086
-		if (empty($options['view_newest_first']))
1087
-			$context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['start_from'];
1088
-		else
1089
-			$context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['topicinfo']['num_replies'] - $context['start_from'];
1090
-	}
1091
-	else
1121
+		if (empty($options['view_newest_first'])) {
1122
+					$context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['start_from'];
1123
+		} else {
1124
+					$context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['topicinfo']['num_replies'] - $context['start_from'];
1125
+		}
1126
+	} else
1092 1127
 	{
1093 1128
 		$messages_request = false;
1094 1129
 		$context['first_message'] = 0;
@@ -1124,8 +1159,9 @@  discard block
 block discarded – undo
1124 1159
 		'can_see_likes' => 'likes_view',
1125 1160
 		'can_like' => 'likes_like',
1126 1161
 	);
1127
-	foreach ($common_permissions as $contextual => $perm)
1128
-		$context[$contextual] = allowedTo($perm);
1162
+	foreach ($common_permissions as $contextual => $perm) {
1163
+			$context[$contextual] = allowedTo($perm);
1164
+	}
1129 1165
 
1130 1166
 	// Permissions with _any/_own versions.  $context[YYY] => ZZZ_any/_own.
1131 1167
 	$anyown_permissions = array(
@@ -1138,8 +1174,9 @@  discard block
 block discarded – undo
1138 1174
 		'can_reply_unapproved' => 'post_unapproved_replies',
1139 1175
 		'can_view_warning' => 'profile_warning',
1140 1176
 	);
1141
-	foreach ($anyown_permissions as $contextual => $perm)
1142
-		$context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own'));
1177
+	foreach ($anyown_permissions as $contextual => $perm) {
1178
+			$context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own'));
1179
+	}
1143 1180
 
1144 1181
 	if (!$user_info['is_admin'] && !$modSettings['topic_move_any'])
1145 1182
 	{
@@ -1185,8 +1222,9 @@  discard block
 block discarded – undo
1185 1222
 	// Check if the draft functions are enabled and that they have permission to use them (for quick reply.)
1186 1223
 	$context['drafts_save'] = !empty($modSettings['drafts_post_enabled']) && allowedTo('post_draft') && $context['can_reply'];
1187 1224
 	$context['drafts_autosave'] = !empty($context['drafts_save']) && !empty($modSettings['drafts_autosave_enabled']);
1188
-	if (!empty($context['drafts_save']))
1189
-		loadLanguage('Drafts');
1225
+	if (!empty($context['drafts_save'])) {
1226
+			loadLanguage('Drafts');
1227
+	}
1190 1228
 
1191 1229
 	// When was the last time this topic was replied to?  Should we warn them about it?
1192 1230
 	if (!empty($modSettings['oldTopicDays']) && ($context['can_reply'] || $context['can_reply_unapproved']) && empty($context['topicinfo']['is_sticky']))
@@ -1247,26 +1285,31 @@  discard block
 block discarded – undo
1247 1285
 	// Message icons - customized icons are off?
1248 1286
 	$context['icons'] = getMessageIcons($board);
1249 1287
 
1250
-	if (!empty($context['icons']))
1251
-		$context['icons'][count($context['icons']) - 1]['is_last'] = true;
1288
+	if (!empty($context['icons'])) {
1289
+			$context['icons'][count($context['icons']) - 1]['is_last'] = true;
1290
+	}
1252 1291
 
1253 1292
 	// Build the normal button array.
1254 1293
 	$context['normal_buttons'] = array();
1255 1294
 
1256
-	if ($context['can_reply'])
1257
-		$context['normal_buttons']['reply'] = array('text' => 'reply', 'image' => 'reply.png', 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';last_msg=' . $context['topic_last_message'], 'active' => true);
1295
+	if ($context['can_reply']) {
1296
+			$context['normal_buttons']['reply'] = array('text' => 'reply', 'image' => 'reply.png', 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';last_msg=' . $context['topic_last_message'], 'active' => true);
1297
+	}
1258 1298
 
1259
-	if ($context['can_add_poll'])
1260
-		$context['normal_buttons']['add_poll'] = array('text' => 'add_poll', 'image' => 'add_poll.png', 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']);
1299
+	if ($context['can_add_poll']) {
1300
+			$context['normal_buttons']['add_poll'] = array('text' => 'add_poll', 'image' => 'add_poll.png', 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']);
1301
+	}
1261 1302
 
1262
-	if ($context['can_mark_unread'])
1263
-		$context['normal_buttons']['mark_unread'] = array('text' => 'mark_unread', 'image' => 'markunread.png', 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
1303
+	if ($context['can_mark_unread']) {
1304
+			$context['normal_buttons']['mark_unread'] = array('text' => 'mark_unread', 'image' => 'markunread.png', 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
1305
+	}
1264 1306
 
1265
-	if ($context['can_print'])
1266
-		$context['normal_buttons']['print'] = array('text' => 'print', 'image' => 'print.png', 'custom' => 'rel="nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0');
1307
+	if ($context['can_print']) {
1308
+			$context['normal_buttons']['print'] = array('text' => 'print', 'image' => 'print.png', 'custom' => 'rel="nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0');
1309
+	}
1267 1310
 
1268
-	if ($context['can_set_notify'])
1269
-		$context['normal_buttons']['notify'] = array(
1311
+	if ($context['can_set_notify']) {
1312
+			$context['normal_buttons']['notify'] = array(
1270 1313
 			'text' => 'notify_topic_' . $context['topic_notification_mode'],
1271 1314
 			'sub_buttons' => array(
1272 1315
 				array(
@@ -1288,38 +1331,47 @@  discard block
 block discarded – undo
1288 1331
 				),
1289 1332
 			),
1290 1333
 		);
1334
+	}
1291 1335
 
1292 1336
 	// Build the mod button array
1293 1337
 	$context['mod_buttons'] = array();
1294 1338
 
1295
-	if ($context['can_move'])
1296
-		$context['mod_buttons']['move'] = array('text' => 'move_topic', 'image' => 'admin_move.png', 'url' => $scripturl . '?action=movetopic;current_board=' . $context['current_board'] . ';topic=' . $context['current_topic'] . '.0');
1339
+	if ($context['can_move']) {
1340
+			$context['mod_buttons']['move'] = array('text' => 'move_topic', 'image' => 'admin_move.png', 'url' => $scripturl . '?action=movetopic;current_board=' . $context['current_board'] . ';topic=' . $context['current_topic'] . '.0');
1341
+	}
1297 1342
 
1298
-	if ($context['can_delete'])
1299
-		$context['mod_buttons']['delete'] = array('text' => 'remove_topic', 'image' => 'admin_rem.png', 'custom' => 'data-confirm="' . $txt['are_sure_remove_topic'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removetopic2;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']);
1343
+	if ($context['can_delete']) {
1344
+			$context['mod_buttons']['delete'] = array('text' => 'remove_topic', 'image' => 'admin_rem.png', 'custom' => 'data-confirm="' . $txt['are_sure_remove_topic'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removetopic2;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']);
1345
+	}
1300 1346
 
1301
-	if ($context['can_lock'])
1302
-		$context['mod_buttons']['lock'] = array('text' => empty($context['is_locked']) ? 'set_lock' : 'set_unlock', 'image' => 'admin_lock.png', 'url' => $scripturl . '?action=lock;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
1347
+	if ($context['can_lock']) {
1348
+			$context['mod_buttons']['lock'] = array('text' => empty($context['is_locked']) ? 'set_lock' : 'set_unlock', 'image' => 'admin_lock.png', 'url' => $scripturl . '?action=lock;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
1349
+	}
1303 1350
 
1304
-	if ($context['can_sticky'])
1305
-		$context['mod_buttons']['sticky'] = array('text' => empty($context['is_sticky']) ? 'set_sticky' : 'set_nonsticky', 'image' => 'admin_sticky.png', 'url' => $scripturl . '?action=sticky;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
1351
+	if ($context['can_sticky']) {
1352
+			$context['mod_buttons']['sticky'] = array('text' => empty($context['is_sticky']) ? 'set_sticky' : 'set_nonsticky', 'image' => 'admin_sticky.png', 'url' => $scripturl . '?action=sticky;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
1353
+	}
1306 1354
 
1307
-	if ($context['can_merge'])
1308
-		$context['mod_buttons']['merge'] = array('text' => 'merge', 'image' => 'merge.png', 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']);
1355
+	if ($context['can_merge']) {
1356
+			$context['mod_buttons']['merge'] = array('text' => 'merge', 'image' => 'merge.png', 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']);
1357
+	}
1309 1358
 
1310
-	if ($context['calendar_post'])
1311
-		$context['mod_buttons']['calendar'] = array('text' => 'calendar_link', 'image' => 'linktocal.png', 'url' => $scripturl . '?action=post;calendar;msg=' . $context['topic_first_message'] . ';topic=' . $context['current_topic'] . '.0');
1359
+	if ($context['calendar_post']) {
1360
+			$context['mod_buttons']['calendar'] = array('text' => 'calendar_link', 'image' => 'linktocal.png', 'url' => $scripturl . '?action=post;calendar;msg=' . $context['topic_first_message'] . ';topic=' . $context['current_topic'] . '.0');
1361
+	}
1312 1362
 
1313 1363
 	// Restore topic. eh?  No monkey business.
1314
-	if ($context['can_restore_topic'])
1315
-		$context['mod_buttons']['restore_topic'] = array('text' => 'restore_topic', 'image' => '', 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']);
1364
+	if ($context['can_restore_topic']) {
1365
+			$context['mod_buttons']['restore_topic'] = array('text' => 'restore_topic', 'image' => '', 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']);
1366
+	}
1316 1367
 
1317 1368
 	// Show a message in case a recently posted message became unapproved.
1318 1369
 	$context['becomesUnapproved'] = !empty($_SESSION['becomesUnapproved']) ? true : false;
1319 1370
 
1320 1371
 	// Don't want to show this forever...
1321
-	if ($context['becomesUnapproved'])
1322
-		unset($_SESSION['becomesUnapproved']);
1372
+	if ($context['becomesUnapproved']) {
1373
+			unset($_SESSION['becomesUnapproved']);
1374
+	}
1323 1375
 
1324 1376
 	// Allow adding new mod buttons easily.
1325 1377
 	// Note: $context['normal_buttons'] and $context['mod_buttons'] are added for backward compatibility with 2.0, but are deprecated and should not be used
@@ -1328,12 +1380,14 @@  discard block
 block discarded – undo
1328 1380
 	call_integration_hook('integrate_mod_buttons', array(&$context['mod_buttons']));
1329 1381
 
1330 1382
 	// Load the drafts js file
1331
-	if ($context['drafts_autosave'])
1332
-		loadJavaScriptFile('drafts.js', array('defer' => false), 'smf_drafts');
1383
+	if ($context['drafts_autosave']) {
1384
+			loadJavaScriptFile('drafts.js', array('defer' => false), 'smf_drafts');
1385
+	}
1333 1386
 
1334 1387
 	// Spellcheck
1335
-	if ($context['show_spellchecking'])
1336
-		loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck');
1388
+	if ($context['show_spellchecking']) {
1389
+			loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck');
1390
+	}
1337 1391
 
1338 1392
 	// topic.js
1339 1393
 	loadJavaScriptFile('topic.js', array('defer' => false), 'smf_topic');
@@ -1367,16 +1421,19 @@  discard block
 block discarded – undo
1367 1421
 	static $counter = null;
1368 1422
 
1369 1423
 	// If the query returned false, bail.
1370
-	if ($messages_request == false)
1371
-		return false;
1424
+	if ($messages_request == false) {
1425
+			return false;
1426
+	}
1372 1427
 
1373 1428
 	// Remember which message this is.  (ie. reply #83)
1374
-	if ($counter === null || $reset)
1375
-		$counter = empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start'];
1429
+	if ($counter === null || $reset) {
1430
+			$counter = empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start'];
1431
+	}
1376 1432
 
1377 1433
 	// Start from the beginning...
1378
-	if ($reset)
1379
-		return @$smcFunc['db_data_seek']($messages_request, 0);
1434
+	if ($reset) {
1435
+			return @$smcFunc['db_data_seek']($messages_request, 0);
1436
+	}
1380 1437
 
1381 1438
 	// Attempt to get the next message.
1382 1439
 	$message = $smcFunc['db_fetch_assoc']($messages_request);
@@ -1390,19 +1447,21 @@  discard block
 block discarded – undo
1390 1447
 	if (empty($context['icon_sources']))
1391 1448
 	{
1392 1449
 		$context['icon_sources'] = array();
1393
-		foreach ($context['stable_icons'] as $icon)
1394
-			$context['icon_sources'][$icon] = 'images_url';
1450
+		foreach ($context['stable_icons'] as $icon) {
1451
+					$context['icon_sources'][$icon] = 'images_url';
1452
+		}
1395 1453
 	}
1396 1454
 
1397 1455
 	// Message Icon Management... check the images exist.
1398 1456
 	if (empty($modSettings['messageIconChecks_disable']))
1399 1457
 	{
1400 1458
 		// If the current icon isn't known, then we need to do something...
1401
-		if (!isset($context['icon_sources'][$message['icon']]))
1402
-			$context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url';
1459
+		if (!isset($context['icon_sources'][$message['icon']])) {
1460
+					$context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url';
1461
+		}
1462
+	} elseif (!isset($context['icon_sources'][$message['icon']])) {
1463
+			$context['icon_sources'][$message['icon']] = 'images_url';
1403 1464
 	}
1404
-	elseif (!isset($context['icon_sources'][$message['icon']]))
1405
-		$context['icon_sources'][$message['icon']] = 'images_url';
1406 1465
 
1407 1466
 	// If you're a lazy bum, you probably didn't give a subject...
1408 1467
 	$message['subject'] = $message['subject'] != '' ? $message['subject'] : $txt['no_subject'];
@@ -1427,8 +1486,7 @@  discard block
 block discarded – undo
1427 1486
 		$memberContext[$message['id_member']]['email'] = $message['poster_email'];
1428 1487
 		$memberContext[$message['id_member']]['show_email'] = allowedTo('moderate_forum');
1429 1488
 		$memberContext[$message['id_member']]['is_guest'] = true;
1430
-	}
1431
-	else
1489
+	} else
1432 1490
 	{
1433 1491
 		// Define this here to make things a bit more readable
1434 1492
 		$can_view_warning = $context['user']['can_mod'] || allowedTo('view_warning_any') || ($message['id_member'] == $user_info['id'] && allowedTo('view_warning_own'));
@@ -1451,8 +1509,9 @@  discard block
 block discarded – undo
1451 1509
 	$message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']);
1452 1510
 
1453 1511
 	// If it's in the recycle bin we need to override whatever icon we did have.
1454
-	if (!empty($board_info['recycle']))
1455
-		$message['icon'] = 'recycled';
1512
+	if (!empty($board_info['recycle'])) {
1513
+			$message['icon'] = 'recycled';
1514
+	}
1456 1515
 
1457 1516
 	require_once($sourcedir . '/Subs-Attachments.php');
1458 1517
 
@@ -1496,32 +1555,36 @@  discard block
 block discarded – undo
1496 1555
 	}
1497 1556
 
1498 1557
 	// Are likes enable?
1499
-	if (!empty($modSettings['enable_likes']))
1500
-		$output['likes'] = array(
1558
+	if (!empty($modSettings['enable_likes'])) {
1559
+			$output['likes'] = array(
1501 1560
 			'count' => $message['likes'],
1502 1561
 			'you' => in_array($message['id_msg'], $context['my_likes']),
1503 1562
 			'can_like' => !$context['user']['is_guest'] && $message['id_member'] != $context['user']['id'] && !empty($context['can_like']),
1504 1563
 		);
1564
+	}
1505 1565
 
1506 1566
 	// Is this user the message author?
1507 1567
 	$output['is_message_author'] = $message['id_member'] == $user_info['id'];
1508
-	if (!empty($output['modified']['name']))
1509
-		$output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], $output['modified']['name']);
1568
+	if (!empty($output['modified']['name'])) {
1569
+			$output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], $output['modified']['name']);
1570
+	}
1510 1571
 
1511 1572
 	// Did they give a reason for editing?
1512
-	if (!empty($output['modified']['name']) && !empty($output['modified']['reason']))
1513
-		$output['modified']['last_edit_text'] .= '&nbsp;' . sprintf($txt['last_edit_reason'], $output['modified']['reason']);
1573
+	if (!empty($output['modified']['name']) && !empty($output['modified']['reason'])) {
1574
+			$output['modified']['last_edit_text'] .= '&nbsp;' . sprintf($txt['last_edit_reason'], $output['modified']['reason']);
1575
+	}
1514 1576
 
1515 1577
 	// Any custom profile fields?
1516
-	if (!empty($memberContext[$message['id_member']]['custom_fields']))
1517
-		foreach ($memberContext[$message['id_member']]['custom_fields'] as $custom)
1578
+	if (!empty($memberContext[$message['id_member']]['custom_fields'])) {
1579
+			foreach ($memberContext[$message['id_member']]['custom_fields'] as $custom)
1518 1580
 			$output['custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom;
1581
+	}
1519 1582
 
1520
-	if (empty($options['view_newest_first']))
1521
-		$counter++;
1522
-
1523
-	else
1524
-		$counter--;
1583
+	if (empty($options['view_newest_first'])) {
1584
+			$counter++;
1585
+	} else {
1586
+			$counter--;
1587
+	}
1525 1588
 
1526 1589
 	call_integration_hook('integrate_prepare_display_context', array(&$output, &$message, $counter));
1527 1590
 
@@ -1547,21 +1610,23 @@  discard block
 block discarded – undo
1547 1610
 	$context['no_last_modified'] = true;
1548 1611
 
1549 1612
 	// Prevent a preview image from being displayed twice.
1550
-	if (isset($_GET['action']) && $_GET['action'] == 'dlattach' && isset($_GET['type']) && ($_GET['type'] == 'avatar' || $_GET['type'] == 'preview'))
1551
-		return;
1613
+	if (isset($_GET['action']) && $_GET['action'] == 'dlattach' && isset($_GET['type']) && ($_GET['type'] == 'avatar' || $_GET['type'] == 'preview')) {
1614
+			return;
1615
+	}
1552 1616
 
1553 1617
 	// Make sure some attachment was requested!
1554
-	if (!isset($_REQUEST['attach']) && !isset($_REQUEST['id']))
1555
-		fatal_lang_error('no_access', false);
1618
+	if (!isset($_REQUEST['attach']) && !isset($_REQUEST['id'])) {
1619
+			fatal_lang_error('no_access', false);
1620
+	}
1556 1621
 
1557 1622
 	$_REQUEST['attach'] = isset($_REQUEST['attach']) ? (int) $_REQUEST['attach'] : (int) $_REQUEST['id'];
1558 1623
 
1559 1624
 	// Do we have a hook wanting to use our attachment system? We use $attachRequest to prevent accidental usage of $request.
1560 1625
 	$attachRequest = null;
1561 1626
 	call_integration_hook('integrate_download_request', array(&$attachRequest));
1562
-	if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest))
1563
-		$request = $attachRequest;
1564
-	else
1627
+	if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) {
1628
+			$request = $attachRequest;
1629
+	} else
1565 1630
 	{
1566 1631
 		// This checks only the current board for $board/$topic's permissions.
1567 1632
 		isAllowedTo('view_attachments');
@@ -1582,19 +1647,21 @@  discard block
 block discarded – undo
1582 1647
 		);
1583 1648
 	}
1584 1649
 
1585
-	if ($smcFunc['db_num_rows']($request) == 0)
1586
-		fatal_lang_error('no_access', false);
1650
+	if ($smcFunc['db_num_rows']($request) == 0) {
1651
+			fatal_lang_error('no_access', false);
1652
+	}
1587 1653
 
1588 1654
 	list ($id_folder, $real_filename, $file_hash, $file_ext, $id_attach, $attachment_type, $mime_type, $is_approved, $id_member) = $smcFunc['db_fetch_row']($request);
1589 1655
 	$smcFunc['db_free_result']($request);
1590 1656
 
1591 1657
 	// If it isn't yet approved, do they have permission to view it?
1592
-	if (!$is_approved && ($id_member == 0 || $user_info['id'] != $id_member) && ($attachment_type == 0 || $attachment_type == 3))
1593
-		isAllowedTo('approve_posts');
1658
+	if (!$is_approved && ($id_member == 0 || $user_info['id'] != $id_member) && ($attachment_type == 0 || $attachment_type == 3)) {
1659
+			isAllowedTo('approve_posts');
1660
+	}
1594 1661
 
1595 1662
 	// Update the download counter (unless it's a thumbnail).
1596
-	if ($attachment_type != 3)
1597
-		$smcFunc['db_query']('attach_download_increase', '
1663
+	if ($attachment_type != 3) {
1664
+			$smcFunc['db_query']('attach_download_increase', '
1598 1665
 			UPDATE LOW_PRIORITY {db_prefix}attachments
1599 1666
 			SET downloads = downloads + 1
1600 1667
 			WHERE id_attach = {int:id_attach}',
@@ -1602,15 +1669,15 @@  discard block
 block discarded – undo
1602 1669
 				'id_attach' => $id_attach,
1603 1670
 			)
1604 1671
 		);
1672
+	}
1605 1673
 
1606 1674
 	$filename = getAttachmentFilename($real_filename, $_REQUEST['attach'], $id_folder, false, $file_hash);
1607 1675
 
1608 1676
 	// This is done to clear any output that was made before now.
1609 1677
 	ob_end_clean();
1610
-	if (!empty($modSettings['enableCompressedOutput']) && @filesize($filename) <= 4194304 && in_array($file_ext, array('txt', 'html', 'htm', 'js', 'doc', 'docx', 'rtf', 'css', 'php', 'log', 'xml', 'sql', 'c', 'java')))
1611
-		@ob_start('ob_gzhandler');
1612
-
1613
-	else
1678
+	if (!empty($modSettings['enableCompressedOutput']) && @filesize($filename) <= 4194304 && in_array($file_ext, array('txt', 'html', 'htm', 'js', 'doc', 'docx', 'rtf', 'css', 'php', 'log', 'xml', 'sql', 'c', 'java'))) {
1679
+			@ob_start('ob_gzhandler');
1680
+	} else
1614 1681
 	{
1615 1682
 		ob_start();
1616 1683
 		header('Content-Encoding: none');
@@ -1653,8 +1720,9 @@  discard block
 block discarded – undo
1653 1720
 	// Send the attachment headers.
1654 1721
 	header('Pragma: ');
1655 1722
 
1656
-	if (!isBrowser('gecko'))
1657
-		header('Content-Transfer-Encoding: binary');
1723
+	if (!isBrowser('gecko')) {
1724
+			header('Content-Transfer-Encoding: binary');
1725
+	}
1658 1726
 
1659 1727
 	header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT');
1660 1728
 	header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($filename)) . ' GMT');
@@ -1663,18 +1731,19 @@  discard block
 block discarded – undo
1663 1731
 	header('ETag: ' . $eTag);
1664 1732
 
1665 1733
 	// Make sure the mime type warrants an inline display.
1666
-	if (isset($_REQUEST['image']) && !empty($mime_type) && strpos($mime_type, 'image/') !== 0)
1667
-		unset($_REQUEST['image']);
1734
+	if (isset($_REQUEST['image']) && !empty($mime_type) && strpos($mime_type, 'image/') !== 0) {
1735
+			unset($_REQUEST['image']);
1736
+	}
1668 1737
 
1669 1738
 	// Does this have a mime type?
1670
-	elseif (!empty($mime_type) && (isset($_REQUEST['image']) || !in_array($file_ext, array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff'))))
1671
-		header('Content-Type: ' . strtr($mime_type, array('image/bmp' => 'image/x-ms-bmp')));
1672
-
1673
-	else
1739
+	elseif (!empty($mime_type) && (isset($_REQUEST['image']) || !in_array($file_ext, array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) {
1740
+			header('Content-Type: ' . strtr($mime_type, array('image/bmp' => 'image/x-ms-bmp')));
1741
+	} else
1674 1742
 	{
1675 1743
 		header('Content-Type: ' . (isBrowser('ie') || isBrowser('opera') ? 'application/octetstream' : 'application/octet-stream'));
1676
-		if (isset($_REQUEST['image']))
1677
-			unset($_REQUEST['image']);
1744
+		if (isset($_REQUEST['image'])) {
1745
+					unset($_REQUEST['image']);
1746
+		}
1678 1747
 	}
1679 1748
 
1680 1749
 	// Convert the file to UTF-8, cuz most browsers dig that.
@@ -1682,23 +1751,22 @@  discard block
 block discarded – undo
1682 1751
 	$disposition = !isset($_REQUEST['image']) ? 'attachment' : 'inline';
1683 1752
 
1684 1753
 	// Different browsers like different standards...
1685
-	if (isBrowser('firefox'))
1686
-		header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)));
1687
-
1688
-	elseif (isBrowser('opera'))
1689
-		header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"');
1690
-
1691
-	elseif (isBrowser('ie'))
1692
-		header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"');
1693
-
1694
-	else
1695
-		header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"');
1754
+	if (isBrowser('firefox')) {
1755
+			header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)));
1756
+	} elseif (isBrowser('opera')) {
1757
+			header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"');
1758
+	} elseif (isBrowser('ie')) {
1759
+			header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"');
1760
+	} else {
1761
+			header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"');
1762
+	}
1696 1763
 
1697 1764
 	// If this has an "image extension" - but isn't actually an image - then ensure it isn't cached cause of silly IE.
1698
-	if (!isset($_REQUEST['image']) && in_array($file_ext, array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff')))
1699
-		header('Cache-Control: no-cache');
1700
-	else
1701
-		header('Cache-Control: max-age=' . (525600 * 60) . ', private');
1765
+	if (!isset($_REQUEST['image']) && in_array($file_ext, array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) {
1766
+			header('Cache-Control: no-cache');
1767
+	} else {
1768
+			header('Cache-Control: max-age=' . (525600 * 60) . ', private');
1769
+	}
1702 1770
 
1703 1771
 	header('Content-Length: ' . filesize($filename));
1704 1772
 
@@ -1708,20 +1776,23 @@  discard block
 block discarded – undo
1708 1776
 	// Recode line endings for text files, if enabled.
1709 1777
 	if (!empty($modSettings['attachmentRecodeLineEndings']) && !isset($_REQUEST['image']) && in_array($file_ext, array('txt', 'css', 'htm', 'html', 'php', 'xml')))
1710 1778
 	{
1711
-		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== false)
1712
-			$callback = function($buffer)
1779
+		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== false) {
1780
+					$callback = function($buffer)
1713 1781
 			{
1714 1782
 				return preg_replace('~[\r]?\n~', "\r\n", $buffer);
1783
+		}
1715 1784
 			};
1716
-		elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false)
1717
-			$callback = function($buffer)
1785
+		elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
1786
+					$callback = function($buffer)
1718 1787
 			{
1719 1788
 				return preg_replace('~[\r]?\n~', "\r", $buffer);
1789
+		}
1720 1790
 			};
1721
-		else
1722
-			$callback = function($buffer)
1791
+		else {
1792
+					$callback = function($buffer)
1723 1793
 			{
1724 1794
 				return preg_replace('~[\r]?\n~', "\n", $buffer);
1795
+		}
1725 1796
 			};
1726 1797
 	}
1727 1798
 
@@ -1729,23 +1800,26 @@  discard block
 block discarded – undo
1729 1800
 	if (filesize($filename) > 4194304)
1730 1801
 	{
1731 1802
 		// Forcibly end any output buffering going on.
1732
-		while (@ob_get_level() > 0)
1733
-			@ob_end_clean();
1803
+		while (@ob_get_level() > 0) {
1804
+					@ob_end_clean();
1805
+		}
1734 1806
 
1735 1807
 		$fp = fopen($filename, 'rb');
1736 1808
 		while (!feof($fp))
1737 1809
 		{
1738
-			if (isset($callback))
1739
-				echo $callback(fread($fp, 8192));
1740
-			else
1741
-				echo fread($fp, 8192);
1810
+			if (isset($callback)) {
1811
+							echo $callback(fread($fp, 8192));
1812
+			} else {
1813
+							echo fread($fp, 8192);
1814
+			}
1742 1815
 			flush();
1743 1816
 		}
1744 1817
 		fclose($fp);
1745 1818
 	}
1746 1819
 	// On some of the less-bright hosts, readfile() is disabled.  It's just a faster, more byte safe, version of what's in the if.
1747
-	elseif (isset($callback) || @readfile($filename) === null)
1748
-		echo isset($callback) ? $callback(file_get_contents($filename)) : file_get_contents($filename);
1820
+	elseif (isset($callback) || @readfile($filename) === null) {
1821
+			echo isset($callback) ? $callback(file_get_contents($filename)) : file_get_contents($filename);
1822
+	}
1749 1823
 
1750 1824
 	obExit(false);
1751 1825
 }
@@ -1758,8 +1832,9 @@  discard block
 block discarded – undo
1758 1832
  */
1759 1833
 function approved_attach_sort($a, $b)
1760 1834
 {
1761
-	if ($a['is_approved'] == $b['is_approved'])
1762
-		return 0;
1835
+	if ($a['is_approved'] == $b['is_approved']) {
1836
+			return 0;
1837
+	}
1763 1838
 
1764 1839
 	return $a['is_approved'] > $b['is_approved'] ? -1 : 1;
1765 1840
 }
@@ -1776,16 +1851,19 @@  discard block
 block discarded – undo
1776 1851
 
1777 1852
 	require_once($sourcedir . '/RemoveTopic.php');
1778 1853
 
1779
-	if (empty($_REQUEST['msgs']))
1780
-		redirectexit('topic=' . $topic . '.' . $_REQUEST['start']);
1854
+	if (empty($_REQUEST['msgs'])) {
1855
+			redirectexit('topic=' . $topic . '.' . $_REQUEST['start']);
1856
+	}
1781 1857
 
1782 1858
 	$messages = array();
1783
-	foreach ($_REQUEST['msgs'] as $dummy)
1784
-		$messages[] = (int) $dummy;
1859
+	foreach ($_REQUEST['msgs'] as $dummy) {
1860
+			$messages[] = (int) $dummy;
1861
+	}
1785 1862
 
1786 1863
 	// We are restoring messages. We handle this in another place.
1787
-	if (isset($_REQUEST['restore_selected']))
1788
-		redirectexit('action=restoretopic;msgs=' . implode(',', $messages) . ';' . $context['session_var'] . '=' . $context['session_id']);
1864
+	if (isset($_REQUEST['restore_selected'])) {
1865
+			redirectexit('action=restoretopic;msgs=' . implode(',', $messages) . ';' . $context['session_var'] . '=' . $context['session_id']);
1866
+	}
1789 1867
 	if (isset($_REQUEST['split_selection']))
1790 1868
 	{
1791 1869
 		$request = $smcFunc['db_query']('', '
@@ -1804,8 +1882,9 @@  discard block
 block discarded – undo
1804 1882
 	}
1805 1883
 
1806 1884
 	// Allowed to delete any message?
1807
-	if (allowedTo('delete_any'))
1808
-		$allowed_all = true;
1885
+	if (allowedTo('delete_any')) {
1886
+			$allowed_all = true;
1887
+	}
1809 1888
 	// Allowed to delete replies to their messages?
1810 1889
 	elseif (allowedTo('delete_replies'))
1811 1890
 	{
@@ -1822,13 +1901,14 @@  discard block
 block discarded – undo
1822 1901
 		$smcFunc['db_free_result']($request);
1823 1902
 
1824 1903
 		$allowed_all = $starter == $user_info['id'];
1904
+	} else {
1905
+			$allowed_all = false;
1825 1906
 	}
1826
-	else
1827
-		$allowed_all = false;
1828 1907
 
1829 1908
 	// Make sure they're allowed to delete their own messages, if not any.
1830
-	if (!$allowed_all)
1831
-		isAllowedTo('delete_own');
1909
+	if (!$allowed_all) {
1910
+			isAllowedTo('delete_own');
1911
+	}
1832 1912
 
1833 1913
 	// Allowed to remove which messages?
1834 1914
 	$request = $smcFunc['db_query']('', '
@@ -1848,8 +1928,9 @@  discard block
 block discarded – undo
1848 1928
 	$messages = array();
1849 1929
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1850 1930
 	{
1851
-		if (!$allowed_all && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time())
1852
-			continue;
1931
+		if (!$allowed_all && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) {
1932
+					continue;
1933
+		}
1853 1934
 
1854 1935
 		$messages[$row['id_msg']] = array($row['subject'], $row['id_member']);
1855 1936
 	}
@@ -1872,17 +1953,20 @@  discard block
 block discarded – undo
1872 1953
 	foreach ($messages as $message => $info)
1873 1954
 	{
1874 1955
 		// Just skip the first message - if it's not the last.
1875
-		if ($message == $first_message && $message != $last_message)
1876
-			continue;
1956
+		if ($message == $first_message && $message != $last_message) {
1957
+					continue;
1958
+		}
1877 1959
 		// If the first message is going then don't bother going back to the topic as we're effectively deleting it.
1878
-		elseif ($message == $first_message)
1879
-			$topicGone = true;
1960
+		elseif ($message == $first_message) {
1961
+					$topicGone = true;
1962
+		}
1880 1963
 
1881 1964
 		removeMessage($message);
1882 1965
 
1883 1966
 		// Log this moderation action ;).
1884
-		if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id']))
1885
-			logAction('delete', array('topic' => $topic, 'subject' => $info[0], 'member' => $info[1], 'board' => $board));
1967
+		if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) {
1968
+					logAction('delete', array('topic' => $topic, 'subject' => $info[0], 'member' => $info[1], 'board' => $board));
1969
+		}
1886 1970
 	}
1887 1971
 
1888 1972
 	redirectexit(!empty($topicGone) ? 'board=' . $board : 'topic=' . $topic . '.' . $_REQUEST['start']);
Please login to merge, or discard this patch.
Sources/Profile.php 1 patch
Braces   +155 added lines, -118 removed lines patch added patch discarded remove patch
@@ -15,8 +15,9 @@  discard block
 block discarded – undo
15 15
  * @version 2.1 Beta 3
16 16
  */
17 17
 
18
-if (!defined('SMF'))
18
+if (!defined('SMF')) {
19 19
 	die('No direct access...');
20
+}
20 21
 
21 22
 /**
22 23
  * The main designating function for modifying profiles. Loads up info, determins what to do, etc.
@@ -30,18 +31,21 @@  discard block
 block discarded – undo
30 31
 	global $db_show_debug, $smcFunc;
31 32
 
32 33
 	// Don't reload this as we may have processed error strings.
33
-	if (empty($post_errors))
34
-		loadLanguage('Profile+Drafts');
34
+	if (empty($post_errors)) {
35
+			loadLanguage('Profile+Drafts');
36
+	}
35 37
 	loadTemplate('Profile');
36 38
 
37 39
 	require_once($sourcedir . '/Subs-Menu.php');
38 40
 
39 41
 	// Did we get the user by name...
40
-	if (isset($_REQUEST['user']))
41
-		$memberResult = loadMemberData($_REQUEST['user'], true, 'profile');
42
+	if (isset($_REQUEST['user'])) {
43
+			$memberResult = loadMemberData($_REQUEST['user'], true, 'profile');
44
+	}
42 45
 	// ... or by id_member?
43
-	elseif (!empty($_REQUEST['u']))
44
-		$memberResult = loadMemberData((int) $_REQUEST['u'], false, 'profile');
46
+	elseif (!empty($_REQUEST['u'])) {
47
+			$memberResult = loadMemberData((int) $_REQUEST['u'], false, 'profile');
48
+	}
45 49
 	// If it was just ?action=profile, edit your own profile, but only if you're not a guest.
46 50
 	else
47 51
 	{
@@ -51,8 +55,9 @@  discard block
 block discarded – undo
51 55
 	}
52 56
 
53 57
 	// Check if loadMemberData() has returned a valid result.
54
-	if (!$memberResult)
55
-		fatal_lang_error('not_a_user', false, 404);
58
+	if (!$memberResult) {
59
+			fatal_lang_error('not_a_user', false, 404);
60
+	}
56 61
 
57 62
 	// If all went well, we have a valid member ID!
58 63
 	list ($memID) = $memberResult;
@@ -68,8 +73,9 @@  discard block
 block discarded – undo
68 73
 
69 74
 	// Group management isn't actually a permission. But we need it to be for this, so we need a phantom permission.
70 75
 	// And we care about what the current user can do, not what the user whose profile it is.
71
-	if ($user_info['mod_cache']['gq'] != '0=1')
72
-		$user_info['permissions'][] = 'approve_group_requests';
76
+	if ($user_info['mod_cache']['gq'] != '0=1') {
77
+			$user_info['permissions'][] = 'approve_group_requests';
78
+	}
73 79
 
74 80
 	// If paid subscriptions are enabled, make sure we actually have at least one subscription available...
75 81
 	$context['subs_available'] = false;
@@ -437,21 +443,25 @@  discard block
 block discarded – undo
437 443
 		foreach ($section['areas'] as $area_id => $area)
438 444
 		{
439 445
 			// If it said no permissions that meant it wasn't valid!
440
-			if (empty($area['permission'][$context['user']['is_owner'] ? 'own' : 'any']))
441
-				$profile_areas[$section_id]['areas'][$area_id]['enabled'] = false;
446
+			if (empty($area['permission'][$context['user']['is_owner'] ? 'own' : 'any'])) {
447
+							$profile_areas[$section_id]['areas'][$area_id]['enabled'] = false;
448
+			}
442 449
 			// Otherwise pick the right set.
443
-			else
444
-				$profile_areas[$section_id]['areas'][$area_id]['permission'] = $area['permission'][$context['user']['is_owner'] ? 'own' : 'any'];
450
+			else {
451
+							$profile_areas[$section_id]['areas'][$area_id]['permission'] = $area['permission'][$context['user']['is_owner'] ? 'own' : 'any'];
452
+			}
445 453
 
446 454
 			// Password required in most cases
447
-			if (!empty($area['password']))
448
-				$context['password_areas'][] = $area_id;
455
+			if (!empty($area['password'])) {
456
+							$context['password_areas'][] = $area_id;
457
+			}
449 458
 		}
450 459
 	}
451 460
 
452 461
 	// Is there an updated message to show?
453
-	if (isset($_GET['updated']))
454
-		$context['profile_updated'] = $txt['profile_updated_own'];
462
+	if (isset($_GET['updated'])) {
463
+			$context['profile_updated'] = $txt['profile_updated_own'];
464
+	}
455 465
 
456 466
 	// Set a few options for the menu.
457 467
 	$menuOptions = array(
@@ -466,8 +476,9 @@  discard block
 block discarded – undo
466 476
 	$profile_include_data = createMenu($profile_areas, $menuOptions);
467 477
 
468 478
 	// No menu means no access.
469
-	if (!$profile_include_data && (!$user_info['is_guest'] || validateSession()))
470
-		fatal_lang_error('no_access', false);
479
+	if (!$profile_include_data && (!$user_info['is_guest'] || validateSession())) {
480
+			fatal_lang_error('no_access', false);
481
+	}
471 482
 
472 483
 	// Make a note of the Unique ID for this menu.
473 484
 	$context['profile_menu_id'] = $context['max_menu_id'];
@@ -493,8 +504,9 @@  discard block
 block discarded – undo
493 504
 			if ($current_area == $area_id)
494 505
 			{
495 506
 				// This can't happen - but is a security check.
496
-				if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($area['enabled']) && $area['enabled'] == false))
497
-					fatal_lang_error('no_access', false);
507
+				if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($area['enabled']) && $area['enabled'] == false)) {
508
+									fatal_lang_error('no_access', false);
509
+				}
498 510
 
499 511
 				// Are we saving data in a valid area?
500 512
 				if (isset($area['sc']) && (isset($_REQUEST['save']) || $context['do_preview']))
@@ -513,12 +525,14 @@  discard block
 block discarded – undo
513 525
 				}
514 526
 
515 527
 				// Does this require session validating?
516
-				if (!empty($area['validate']) || (isset($_REQUEST['save']) && !$context['user']['is_owner']))
517
-					$security_checks['validate'] = true;
528
+				if (!empty($area['validate']) || (isset($_REQUEST['save']) && !$context['user']['is_owner'])) {
529
+									$security_checks['validate'] = true;
530
+				}
518 531
 
519 532
 				// Permissions for good measure.
520
-				if (!empty($profile_include_data['permission']))
521
-					$security_checks['permission'] = $profile_include_data['permission'];
533
+				if (!empty($profile_include_data['permission'])) {
534
+									$security_checks['permission'] = $profile_include_data['permission'];
535
+				}
522 536
 
523 537
 				// Either way got something.
524 538
 				$found_area = true;
@@ -527,21 +541,26 @@  discard block
 block discarded – undo
527 541
 	}
528 542
 
529 543
 	// Oh dear, some serious security lapse is going on here... we'll put a stop to that!
530
-	if (!$found_area)
531
-		fatal_lang_error('no_access', false);
544
+	if (!$found_area) {
545
+			fatal_lang_error('no_access', false);
546
+	}
532 547
 
533 548
 	// Release this now.
534 549
 	unset($profile_areas);
535 550
 
536 551
 	// Now the context is setup have we got any security checks to carry out additional to that above?
537
-	if (isset($security_checks['session']))
538
-		checkSession($security_checks['session']);
539
-	if (isset($security_checks['validate']))
540
-		validateSession();
541
-	if (isset($security_checks['validateToken']))
542
-		validateToken($token_name, $token_type);
543
-	if (isset($security_checks['permission']))
544
-		isAllowedTo($security_checks['permission']);
552
+	if (isset($security_checks['session'])) {
553
+			checkSession($security_checks['session']);
554
+	}
555
+	if (isset($security_checks['validate'])) {
556
+			validateSession();
557
+	}
558
+	if (isset($security_checks['validateToken'])) {
559
+			validateToken($token_name, $token_type);
560
+	}
561
+	if (isset($security_checks['permission'])) {
562
+			isAllowedTo($security_checks['permission']);
563
+	}
545 564
 
546 565
 	// Create a token if needed.
547 566
 	if (isset($security_checks['needsToken']) || isset($security_checks['validateToken']))
@@ -551,8 +570,9 @@  discard block
 block discarded – undo
551 570
 	}
552 571
 
553 572
 	// File to include?
554
-	if (isset($profile_include_data['file']))
555
-		require_once($sourcedir . '/' . $profile_include_data['file']);
573
+	if (isset($profile_include_data['file'])) {
574
+			require_once($sourcedir . '/' . $profile_include_data['file']);
575
+	}
556 576
 
557 577
 	// Build the link tree.
558 578
 	$context['linktree'][] = array(
@@ -560,17 +580,19 @@  discard block
 block discarded – undo
560 580
 		'name' => sprintf($txt['profile_of_username'], $context['member']['name']),
561 581
 	);
562 582
 
563
-	if (!empty($profile_include_data['label']))
564
-		$context['linktree'][] = array(
583
+	if (!empty($profile_include_data['label'])) {
584
+			$context['linktree'][] = array(
565 585
 			'url' => $scripturl . '?action=profile' . ($memID != $user_info['id'] ? ';u=' . $memID : '') . ';area=' . $profile_include_data['current_area'],
566 586
 			'name' => $profile_include_data['label'],
567 587
 		);
588
+	}
568 589
 
569
-	if (!empty($profile_include_data['current_subsection']) && $profile_include_data['subsections'][$profile_include_data['current_subsection']][0] != $profile_include_data['label'])
570
-		$context['linktree'][] = array(
590
+	if (!empty($profile_include_data['current_subsection']) && $profile_include_data['subsections'][$profile_include_data['current_subsection']][0] != $profile_include_data['label']) {
591
+			$context['linktree'][] = array(
571 592
 			'url' => $scripturl . '?action=profile' . ($memID != $user_info['id'] ? ';u=' . $memID : '') . ';area=' . $profile_include_data['current_area'] . ';sa=' . $profile_include_data['current_subsection'],
572 593
 			'name' => $profile_include_data['subsections'][$profile_include_data['current_subsection']][0],
573 594
 		);
595
+	}
574 596
 
575 597
 	// Set the template for this area and add the profile layer.
576 598
 	$context['sub_template'] = $profile_include_data['function'];
@@ -596,12 +618,14 @@  discard block
 block discarded – undo
596 618
 		if ($check_password)
597 619
 		{
598 620
 			// Check to ensure we're forcing SSL for authentication
599
-			if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on'))
600
-				fatal_lang_error('login_ssl_required');
621
+			if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) {
622
+							fatal_lang_error('login_ssl_required');
623
+			}
601 624
 
602 625
 			// You didn't even enter a password!
603
-			if (trim($_POST['oldpasswrd']) == '')
604
-				$post_errors[] = 'no_password';
626
+			if (trim($_POST['oldpasswrd']) == '') {
627
+							$post_errors[] = 'no_password';
628
+			}
605 629
 
606 630
 			// Since the password got modified due to all the $_POST cleaning, lets undo it so we can get the correct password
607 631
 			$_POST['oldpasswrd'] = un_htmlspecialchars($_POST['oldpasswrd']);
@@ -610,33 +634,35 @@  discard block
 block discarded – undo
610 634
 			$good_password = in_array(true, call_integration_hook('integrate_verify_password', array($cur_profile['member_name'], $_POST['oldpasswrd'], false)), true);
611 635
 
612 636
 			// Bad password!!!
613
-			if (!$good_password && !hash_verify_password($user_profile[$memID]['member_name'], un_htmlspecialchars(stripslashes($_POST['oldpasswrd'])), $user_info['passwd']))
614
-				$post_errors[] = 'bad_password';
637
+			if (!$good_password && !hash_verify_password($user_profile[$memID]['member_name'], un_htmlspecialchars(stripslashes($_POST['oldpasswrd'])), $user_info['passwd'])) {
638
+							$post_errors[] = 'bad_password';
639
+			}
615 640
 
616 641
 			// Warn other elements not to jump the gun and do custom changes!
617
-			if (in_array('bad_password', $post_errors))
618
-				$context['password_auth_failed'] = true;
642
+			if (in_array('bad_password', $post_errors)) {
643
+							$context['password_auth_failed'] = true;
644
+			}
619 645
 		}
620 646
 
621 647
 		// Change the IP address in the database.
622
-		if ($context['user']['is_owner'])
623
-			$profile_vars['member_ip'] = $user_info['ip'];
648
+		if ($context['user']['is_owner']) {
649
+					$profile_vars['member_ip'] = $user_info['ip'];
650
+		}
624 651
 
625 652
 		// Now call the sub-action function...
626 653
 		if ($current_area == 'activateaccount')
627 654
 		{
628
-			if (empty($post_errors))
629
-				activateAccount($memID);
630
-		}
631
-		elseif ($current_area == 'deleteaccount')
655
+			if (empty($post_errors)) {
656
+							activateAccount($memID);
657
+			}
658
+		} elseif ($current_area == 'deleteaccount')
632 659
 		{
633 660
 			if (empty($post_errors))
634 661
 			{
635 662
 				deleteAccount2($memID);
636 663
 				redirectexit();
637 664
 			}
638
-		}
639
-		elseif ($current_area == 'groupmembership' && empty($post_errors))
665
+		} elseif ($current_area == 'groupmembership' && empty($post_errors))
640 666
 		{
641 667
 			$msg = groupMembership2($profile_vars, $post_errors, $memID);
642 668
 
@@ -647,10 +673,9 @@  discard block
 block discarded – undo
647 673
 		elseif ($current_area == 'authentication')
648 674
 		{
649 675
 			authentication($memID, true);
650
-		}
651
-		elseif (in_array($current_area, array('account', 'forumprofile', 'theme')))
652
-			saveProfileFields();
653
-		else
676
+		} elseif (in_array($current_area, array('account', 'forumprofile', 'theme'))) {
677
+					saveProfileFields();
678
+		} else
654 679
 		{
655 680
 			$force_redirect = true;
656 681
 			// Ensure we include this.
@@ -666,34 +691,36 @@  discard block
 block discarded – undo
666 691
 			// Load the language file so we can give a nice explanation of the errors.
667 692
 			loadLanguage('Errors');
668 693
 			$context['post_errors'] = $post_errors;
669
-		}
670
-		elseif (!empty($profile_vars))
694
+		} elseif (!empty($profile_vars))
671 695
 		{
672 696
 			// If we've changed the password, notify any integration that may be listening in.
673
-			if (isset($profile_vars['passwd']))
674
-				call_integration_hook('integrate_reset_pass', array($cur_profile['member_name'], $cur_profile['member_name'], $_POST['passwrd2']));
697
+			if (isset($profile_vars['passwd'])) {
698
+							call_integration_hook('integrate_reset_pass', array($cur_profile['member_name'], $cur_profile['member_name'], $_POST['passwrd2']));
699
+			}
675 700
 
676 701
 			updateMemberData($memID, $profile_vars);
677 702
 
678 703
 			// What if this is the newest member?
679
-			if ($modSettings['latestMember'] == $memID)
680
-				updateStats('member');
681
-			elseif (isset($profile_vars['real_name']))
682
-				updateSettings(array('memberlist_updated' => time()));
704
+			if ($modSettings['latestMember'] == $memID) {
705
+							updateStats('member');
706
+			} elseif (isset($profile_vars['real_name'])) {
707
+							updateSettings(array('memberlist_updated' => time()));
708
+			}
683 709
 
684 710
 			// If the member changed his/her birthdate, update calendar statistics.
685
-			if (isset($profile_vars['birthdate']) || isset($profile_vars['real_name']))
686
-				updateSettings(array(
711
+			if (isset($profile_vars['birthdate']) || isset($profile_vars['real_name'])) {
712
+							updateSettings(array(
687 713
 					'calendar_updated' => time(),
688 714
 				));
715
+			}
689 716
 
690 717
 			// Anything worth logging?
691 718
 			if (!empty($context['log_changes']) && !empty($modSettings['modlog_enabled']))
692 719
 			{
693 720
 				$log_changes = array();
694 721
 				require_once($sourcedir . '/Logging.php');
695
-				foreach ($context['log_changes'] as $k => $v)
696
-					$log_changes[] = array(
722
+				foreach ($context['log_changes'] as $k => $v) {
723
+									$log_changes[] = array(
697 724
 						'action' => $k,
698 725
 						'log_type' => 'user',
699 726
 						'extra' => array_merge($v, array(
@@ -701,14 +728,16 @@  discard block
 block discarded – undo
701 728
 							'member_affected' => $memID,
702 729
 						)),
703 730
 					);
731
+				}
704 732
 
705 733
 				logActions($log_changes);
706 734
 			}
707 735
 
708 736
 			// Have we got any post save functions to execute?
709
-			if (!empty($context['profile_execute_on_save']))
710
-				foreach ($context['profile_execute_on_save'] as $saveFunc)
737
+			if (!empty($context['profile_execute_on_save'])) {
738
+							foreach ($context['profile_execute_on_save'] as $saveFunc)
711 739
 					$saveFunc();
740
+			}
712 741
 
713 742
 			// Let them know it worked!
714 743
 			$context['profile_updated'] = $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $cur_profile['member_name']);
@@ -722,27 +751,31 @@  discard block
 block discarded – undo
722 751
 	if (!empty($post_errors))
723 752
 	{
724 753
 		// Set all the errors so the template knows what went wrong.
725
-		foreach ($post_errors as $error_type)
726
-			$context['modify_error'][$error_type] = true;
754
+		foreach ($post_errors as $error_type) {
755
+					$context['modify_error'][$error_type] = true;
756
+		}
727 757
 	}
728 758
 	// If it's you then we should redirect upon save.
729
-	elseif (!empty($profile_vars) && $context['user']['is_owner'] && !$context['do_preview'])
730
-		redirectexit('action=profile;area=' . $current_area . (!empty($current_sa) ? ';sa=' . $current_sa : '') . ';updated');
731
-	elseif (!empty($force_redirect))
732
-		redirectexit('action=profile' . ($context['user']['is_owner'] ? '' : ';u=' . $memID) . ';area=' . $current_area);
759
+	elseif (!empty($profile_vars) && $context['user']['is_owner'] && !$context['do_preview']) {
760
+			redirectexit('action=profile;area=' . $current_area . (!empty($current_sa) ? ';sa=' . $current_sa : '') . ';updated');
761
+	} elseif (!empty($force_redirect)) {
762
+			redirectexit('action=profile' . ($context['user']['is_owner'] ? '' : ';u=' . $memID) . ';area=' . $current_area);
763
+	}
733 764
 
734 765
 
735 766
 	// Get the right callable.
736 767
 	$call = call_helper($profile_include_data['function'], true);
737 768
 
738 769
 	// Is it valid?
739
-	if (!empty($call))
740
-		call_user_func($call, $memID);
770
+	if (!empty($call)) {
771
+			call_user_func($call, $memID);
772
+	}
741 773
 
742 774
 	// Set the page title if it's not already set...
743
-	if (!isset($context['page_title']))
744
-		$context['page_title'] = $txt['profile'] . (isset($txt[$current_area]) ? ' - ' . $txt[$current_area] : '');
745
-}
775
+	if (!isset($context['page_title'])) {
776
+			$context['page_title'] = $txt['profile'] . (isset($txt[$current_area]) ? ' - ' . $txt[$current_area] : '');
777
+	}
778
+	}
746 779
 
747 780
 /**
748 781
  * Set up the requirements for the profile popup - the area that is shown as the popup menu for the current user.
@@ -865,16 +898,18 @@  discard block
 block discarded – undo
865 898
 	if (!allowedTo('admin_forum') && $area != 'register')
866 899
 	{
867 900
 		// If it's the owner they can see two types of private fields, regardless.
868
-		if ($memID == $user_info['id'])
869
-			$where .= $area == 'summary' ? ' AND private < 3' : ' AND (private = 0 OR private = 2)';
870
-		else
871
-			$where .= $area == 'summary' ? ' AND private < 2' : ' AND private = 0';
901
+		if ($memID == $user_info['id']) {
902
+					$where .= $area == 'summary' ? ' AND private < 3' : ' AND (private = 0 OR private = 2)';
903
+		} else {
904
+					$where .= $area == 'summary' ? ' AND private < 2' : ' AND private = 0';
905
+		}
872 906
 	}
873 907
 
874
-	if ($area == 'register')
875
-		$where .= ' AND show_reg != 0';
876
-	elseif ($area != 'summary')
877
-		$where .= ' AND show_profile = {string:area}';
908
+	if ($area == 'register') {
909
+			$where .= ' AND show_reg != 0';
910
+	} elseif ($area != 'summary') {
911
+			$where .= ' AND show_profile = {string:area}';
912
+	}
878 913
 
879 914
 	// Load all the relevant fields - and data.
880 915
 	$request = $smcFunc['db_query']('', '
@@ -900,13 +935,15 @@  discard block
 block discarded – undo
900 935
 		if (isset($_POST['customfield']) && isset($_POST['customfield'][$row['col_name']]))
901 936
 		{
902 937
 			$value = $smcFunc['htmlspecialchars']($_POST['customfield'][$row['col_name']]);
903
-			if (in_array($row['field_type'], array('select', 'radio')))
904
-					$value = ($options = explode(',', $row['field_options'])) && isset($options[$value]) ? $options[$value] : '';
938
+			if (in_array($row['field_type'], array('select', 'radio'))) {
939
+								$value = ($options = explode(',', $row['field_options'])) && isset($options[$value]) ? $options[$value] : '';
940
+			}
905 941
 		}
906 942
 
907 943
 		// Don't show the "disabled" option for the "gender" field if we are on the "summary" area.
908
-		if ($area == 'summary' && $row['col_name'] == 'cust_gender' && $value == 'Disabled')
909
-			continue;
944
+		if ($area == 'summary' && $row['col_name'] == 'cust_gender' && $value == 'Disabled') {
945
+					continue;
946
+		}
910 947
 
911 948
 		// HTML for the input form.
912 949
 		$output_html = $value;
@@ -915,8 +952,7 @@  discard block
 block discarded – undo
915 952
 			$true = (!$exists && $row['default_value']) || $value;
916 953
 			$input_html = '<input type="checkbox" name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . ($true ? ' checked' : '') . ' class="input_check">';
917 954
 			$output_html = $true ? $txt['yes'] : $txt['no'];
918
-		}
919
-		elseif ($row['field_type'] == 'select')
955
+		} elseif ($row['field_type'] == 'select')
920 956
 		{
921 957
 			$input_html = '<select name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"><option value="-1"></option>';
922 958
 			$options = explode(',', $row['field_options']);
@@ -924,13 +960,13 @@  discard block
 block discarded – undo
924 960
 			{
925 961
 				$true = (!$exists && $row['default_value'] == $v) || $value == $v;
926 962
 				$input_html .= '<option value="' . $k . '"' . ($true ? ' selected' : '') . '>' . $v . '</option>';
927
-				if ($true)
928
-					$output_html = $v;
963
+				if ($true) {
964
+									$output_html = $v;
965
+				}
929 966
 			}
930 967
 
931 968
 			$input_html .= '</select>';
932
-		}
933
-		elseif ($row['field_type'] == 'radio')
969
+		} elseif ($row['field_type'] == 'radio')
934 970
 		{
935 971
 			$input_html = '<fieldset>';
936 972
 			$options = explode(',', $row['field_options']);
@@ -938,36 +974,37 @@  discard block
 block discarded – undo
938 974
 			{
939 975
 				$true = (!$exists && $row['default_value'] == $v) || $value == $v;
940 976
 				$input_html .= '<label for="customfield_' . $row['col_name'] . '_' . $k . '"><input type="radio" name="customfield[' . $row['col_name'] . ']" class="input_radio" id="customfield_' . $row['col_name'] . '_' . $k . '" value="' . $k . '"' . ($true ? ' checked' : '') . '>' . $v . '</label><br>';
941
-				if ($true)
942
-					$output_html = $v;
977
+				if ($true) {
978
+									$output_html = $v;
979
+				}
943 980
 			}
944 981
 			$input_html .= '</fieldset>';
945
-		}
946
-		elseif ($row['field_type'] == 'text')
982
+		} elseif ($row['field_type'] == 'text')
947 983
 		{
948 984
 			$input_html = '<input type="text" name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . ($row['field_length'] != 0 ? ' maxlength="' . $row['field_length'] . '"' : '') . ' size="' . ($row['field_length'] == 0 || $row['field_length'] >= 50 ? 50 : ($row['field_length'] > 30 ? 30 : ($row['field_length'] > 10 ? 20 : 10))) . '" value="' . un_htmlspecialchars($value) . '" class="input_text"' . ($row['show_reg'] == 2 ? ' required' : '') . '>';
949
-		}
950
-		else
985
+		} else
951 986
 		{
952 987
 			@list ($rows, $cols) = @explode(',', $row['default_value']);
953 988
 			$input_html = '<textarea name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . (!empty($rows) ? ' rows="' . $rows . '"' : '') . (!empty($cols) ? ' cols="' . $cols . '"' : '') . ($row['show_reg'] == 2 ? ' required' : '') . '>' . un_htmlspecialchars($value) . '</textarea>';
954 989
 		}
955 990
 
956 991
 		// Parse BBCode
957
-		if ($row['bbc'])
958
-			$output_html = parse_bbc($output_html);
959
-		elseif ($row['field_type'] == 'textarea')
960
-			// Allow for newlines at least
992
+		if ($row['bbc']) {
993
+					$output_html = parse_bbc($output_html);
994
+		} elseif ($row['field_type'] == 'textarea') {
995
+					// Allow for newlines at least
961 996
 			$output_html = strtr($output_html, array("\n" => '<br>'));
997
+		}
962 998
 
963 999
 		// Enclosing the user input within some other text?
964
-		if (!empty($row['enclose']) && !empty($output_html))
965
-			$output_html = strtr($row['enclose'], array(
1000
+		if (!empty($row['enclose']) && !empty($output_html)) {
1001
+					$output_html = strtr($row['enclose'], array(
966 1002
 				'{SCRIPTURL}' => $scripturl,
967 1003
 				'{IMAGES_URL}' => $settings['images_url'],
968 1004
 				'{DEFAULT_IMAGES_URL}' => $settings['default_images_url'],
969 1005
 				'{INPUT}' => un_htmlspecialchars($output_html),
970 1006
 			));
1007
+		}
971 1008
 
972 1009
 		$context['custom_fields'][] = array(
973 1010
 			'name' => $row['field_name'],
Please login to merge, or discard this patch.
Sources/ManageErrors.php 1 patch
Braces   +49 added lines, -38 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 3
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * View the forum's error log.
@@ -30,8 +31,9 @@  discard block
 block discarded – undo
30 31
 	global $scripturl, $txt, $context, $modSettings, $user_profile, $filter, $smcFunc;
31 32
 
32 33
 	// Viewing contents of a file?
33
-	if (isset($_GET['file']))
34
-		return ViewFile();
34
+	if (isset($_GET['file'])) {
35
+			return ViewFile();
36
+	}
35 37
 
36 38
 	// Check for the administrative permission to do this.
37 39
 	isAllowedTo('admin_forum');
@@ -85,8 +87,8 @@  discard block
 block discarded – undo
85 87
 	);
86 88
 
87 89
 	// Set up the filtering...
88
-	if (isset($_GET['value'], $_GET['filter']) && isset($filters[$_GET['filter']]))
89
-		$filter = array(
90
+	if (isset($_GET['value'], $_GET['filter']) && isset($filters[$_GET['filter']])) {
91
+			$filter = array(
90 92
 			'variable' => $_GET['filter'],
91 93
 			'value' => array(
92 94
 				'sql' => in_array($_GET['filter'], array('message', 'url', 'file')) ? base64_decode(strtr($_GET['value'], array(' ' => '+'))) : $smcFunc['db_escape_wildcard_string']($_GET['value']),
@@ -94,10 +96,12 @@  discard block
 block discarded – undo
94 96
 			'href' => ';filter=' . $_GET['filter'] . ';value=' . $_GET['value'],
95 97
 			'entity' => $filters[$_GET['filter']]['txt']
96 98
 		);
99
+	}
97 100
 
98 101
 	// Deleting, are we?
99
-	if (isset($_POST['delall']) || isset($_POST['delete']))
100
-		deleteErrors();
102
+	if (isset($_POST['delall']) || isset($_POST['delete'])) {
103
+			deleteErrors();
104
+	}
101 105
 
102 106
 	// Just how many errors are there?
103 107
 	$result = $smcFunc['db_query']('', '
@@ -112,12 +116,14 @@  discard block
 block discarded – undo
112 116
 	$smcFunc['db_free_result']($result);
113 117
 
114 118
 	// If this filter is empty...
115
-	if ($num_errors == 0 && isset($filter))
116
-		redirectexit('action=admin;area=logs;sa=errorlog' . (isset($_REQUEST['desc']) ? ';desc' : ''));
119
+	if ($num_errors == 0 && isset($filter)) {
120
+			redirectexit('action=admin;area=logs;sa=errorlog' . (isset($_REQUEST['desc']) ? ';desc' : ''));
121
+	}
117 122
 
118 123
 	// Clean up start.
119
-	if (!isset($_GET['start']) || $_GET['start'] < 0)
120
-		$_GET['start'] = 0;
124
+	if (!isset($_GET['start']) || $_GET['start'] < 0) {
125
+			$_GET['start'] = 0;
126
+	}
121 127
 
122 128
 	// Do we want to reverse error listing?
123 129
 	$context['sort_direction'] = isset($_REQUEST['desc']) ? 'down' : 'up';
@@ -127,9 +133,9 @@  discard block
 block discarded – undo
127 133
 	$context['start'] = $_GET['start'];
128 134
 
129 135
 	// Update the error count
130
-	if (!isset($filter))
131
-		$context['num_errors'] = $num_errors;
132
-	else
136
+	if (!isset($filter)) {
137
+			$context['num_errors'] = $num_errors;
138
+	} else
133 139
 	{
134 140
 		// We want all errors, not just the number of filtered messages...
135 141
 		$query = $smcFunc['db_query']('', '
@@ -161,8 +167,9 @@  discard block
 block discarded – undo
161 167
 	for ($i = 0; $row = $smcFunc['db_fetch_assoc']($request); $i++)
162 168
 	{
163 169
 		$search_message = preg_replace('~&lt;span class=&quot;remove&quot;&gt;(.+?)&lt;/span&gt;~', '%', $smcFunc['db_escape_wildcard_string']($row['message']));
164
-		if ($search_message == $filter['value']['sql'])
165
-			$search_message = $smcFunc['db_escape_wildcard_string']($row['message']);
170
+		if ($search_message == $filter['value']['sql']) {
171
+					$search_message = $smcFunc['db_escape_wildcard_string']($row['message']);
172
+		}
166 173
 		$show_message = strtr(strtr(preg_replace('~&lt;span class=&quot;remove&quot;&gt;(.+?)&lt;/span&gt;~', '$1', $row['message']), array("\r" => '', '<br>' => "\n", '<' => '&lt;', '>' => '&gt;', '"' => '&quot;')), array("\n" => '<br>'));
167 174
 
168 175
 		$context['errors'][$row['id_error']] = array(
@@ -221,8 +228,9 @@  discard block
 block discarded – undo
221 228
 				'members' => count($members),
222 229
 			)
223 230
 		);
224
-		while ($row = $smcFunc['db_fetch_assoc']($request))
225
-			$members[$row['id_member']] = $row;
231
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
232
+					$members[$row['id_member']] = $row;
233
+		}
226 234
 		$smcFunc['db_free_result']($request);
227 235
 
228 236
 		// This is a guest...
@@ -254,20 +262,18 @@  discard block
 block discarded – undo
254 262
 			$id = $filter['value']['sql'];
255 263
 			loadMemberData($id, false, 'minimal');
256 264
 			$context['filter']['value']['html'] = '<a href="' . $scripturl . '?action=profile;u=' . $id . '">' . $user_profile[$id]['real_name'] . '</a>';
257
-		}
258
-		elseif ($filter['variable'] == 'url')
259
-			$context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']((substr($filter['value']['sql'], 0, 1) == '?' ? $scripturl : '') . $filter['value']['sql']), array('\_' => '_')) . '\'';
260
-		elseif ($filter['variable'] == 'message')
265
+		} elseif ($filter['variable'] == 'url') {
266
+					$context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']((substr($filter['value']['sql'], 0, 1) == '?' ? $scripturl : '') . $filter['value']['sql']), array('\_' => '_')) . '\'';
267
+		} elseif ($filter['variable'] == 'message')
261 268
 		{
262 269
 			$context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']($filter['value']['sql']), array("\n" => '<br>', '&lt;br /&gt;' => '<br>', "\t" => '&nbsp;&nbsp;&nbsp;', '\_' => '_', '\\%' => '%', '\\\\' => '\\')) . '\'';
263 270
 			$context['filter']['value']['html'] = preg_replace('~&amp;lt;span class=&amp;quot;remove&amp;quot;&amp;gt;(.+?)&amp;lt;/span&amp;gt;~', '$1', $context['filter']['value']['html']);
264
-		}
265
-		elseif ($filter['variable'] == 'error_type')
271
+		} elseif ($filter['variable'] == 'error_type')
266 272
 		{
267 273
 			$context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']($filter['value']['sql']), array("\n" => '<br>', '&lt;br /&gt;' => '<br>', "\t" => '&nbsp;&nbsp;&nbsp;', '\_' => '_', '\\%' => '%', '\\\\' => '\\')) . '\'';
274
+		} else {
275
+					$context['filter']['value']['html'] = &$filter['value']['sql'];
268 276
 		}
269
-		else
270
-			$context['filter']['value']['html'] = &$filter['value']['sql'];
271 277
 	}
272 278
 
273 279
 	$context['error_types'] = array();
@@ -308,10 +314,11 @@  discard block
 block discarded – undo
308 314
 	$context['error_types']['all']['label'] .= ' (' . $sum . ')';
309 315
 
310 316
 	// Finally, work out what is the last tab!
311
-	if (isset($context['error_types'][$sum]))
312
-		$context['error_types'][$sum]['is_last'] = true;
313
-	else
314
-		$context['error_types']['all']['is_last'] = true;
317
+	if (isset($context['error_types'][$sum])) {
318
+			$context['error_types'][$sum]['is_last'] = true;
319
+	} else {
320
+			$context['error_types']['all']['is_last'] = true;
321
+	}
315 322
 
316 323
 	// And this is pretty basic ;).
317 324
 	$context['page_title'] = $txt['errlog'];
@@ -337,21 +344,23 @@  discard block
 block discarded – undo
337 344
 	validateToken('admin-el');
338 345
 
339 346
 	// Delete all or just some?
340
-	if (isset($_POST['delall']) && !isset($filter))
341
-		$smcFunc['db_query']('truncate_table', '
347
+	if (isset($_POST['delall']) && !isset($filter)) {
348
+			$smcFunc['db_query']('truncate_table', '
342 349
 			TRUNCATE {db_prefix}log_errors',
343 350
 			array(
344 351
 			)
345 352
 		);
353
+	}
346 354
 	// Deleting all with a filter?
347
-	elseif (isset($_POST['delall']) && isset($filter))
348
-		$smcFunc['db_query']('', '
355
+	elseif (isset($_POST['delall']) && isset($filter)) {
356
+			$smcFunc['db_query']('', '
349 357
 			DELETE FROM {db_prefix}log_errors
350 358
 			WHERE ' . $filter['variable'] . ' LIKE {string:filter}',
351 359
 			array(
352 360
 				'filter' => $filter['value']['sql'],
353 361
 			)
354 362
 		);
363
+	}
355 364
 	// Just specific errors?
356 365
 	elseif (!empty($_POST['delete']))
357 366
 	{
@@ -397,15 +406,17 @@  discard block
 block discarded – undo
397 406
 	$line = isset($_REQUEST['line']) ? (int) $_REQUEST['line'] : 0;
398 407
 
399 408
 	// Make sure the file we are looking for is one they are allowed to look at
400
-	if ($ext != '.php' || (strpos($file, $real_board) === false && strpos($file, $real_source) === false) || ($basename == 'settings.php' || $basename == 'settings_bak.php') || strpos($file, $real_cache) !== false || !is_readable($file))
401
-		fatal_lang_error('error_bad_file', true, array($smcFunc['htmlspecialchars']($file)));
409
+	if ($ext != '.php' || (strpos($file, $real_board) === false && strpos($file, $real_source) === false) || ($basename == 'settings.php' || $basename == 'settings_bak.php') || strpos($file, $real_cache) !== false || !is_readable($file)) {
410
+			fatal_lang_error('error_bad_file', true, array($smcFunc['htmlspecialchars']($file)));
411
+	}
402 412
 
403 413
 	// get the min and max lines
404 414
 	$min = $line - 20 <= 0 ? 1 : $line - 20;
405 415
 	$max = $line + 21; // One additional line to make everything work out correctly
406 416
 
407
-	if ($max <= 0 || $min >= $max)
408
-		fatal_lang_error('error_bad_line');
417
+	if ($max <= 0 || $min >= $max) {
418
+			fatal_lang_error('error_bad_line');
419
+	}
409 420
 
410 421
 	$file_data = explode('<br />', highlight_php_code($smcFunc['htmlspecialchars'](implode('', file($file)))));
411 422
 
Please login to merge, or discard this patch.
Sources/ReportedContent.php 1 patch
Braces   +61 added lines, -46 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
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
  * Sets and call a function based on the given subaction. Acts as a dispatcher function.
@@ -54,8 +55,9 @@  discard block
 block discarded – undo
54 55
 	);
55 56
 
56 57
 	// This comes under the umbrella of moderating posts.
57
-	if ($context['report_type'] == 'members' || $user_info['mod_cache']['bq'] == '0=1')
58
-		isAllowedTo('moderate_forum');
58
+	if ($context['report_type'] == 'members' || $user_info['mod_cache']['bq'] == '0=1') {
59
+			isAllowedTo('moderate_forum');
60
+	}
59 61
 
60 62
 	$subActions = array(
61 63
 		'show' => 'ShowReports',
@@ -70,11 +72,11 @@  discard block
 block discarded – undo
70 72
 	call_integration_hook('integrate_reported_' . $context['report_type'], array(&$subActions));
71 73
 
72 74
 	// By default we call the open sub-action.
73
-	if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]))
74
-		$context['sub_action'] = $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_REQUEST['sa']), ENT_QUOTES);
75
-
76
-	else
77
-		$context['sub_action'] = 'show';
75
+	if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) {
76
+			$context['sub_action'] = $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_REQUEST['sa']), ENT_QUOTES);
77
+	} else {
78
+			$context['sub_action'] = 'show';
79
+	}
78 80
 
79 81
 	// Hi Ho Silver Away!
80 82
 	call_helper($subActions[$context['sub_action']]);
@@ -116,11 +118,13 @@  discard block
 block discarded – undo
116 118
 
117 119
 		// All the ones to update...
118 120
 		$toClose = array();
119
-		foreach ($_POST['close'] as $rid)
120
-			$toClose[] = (int) $rid;
121
+		foreach ($_POST['close'] as $rid) {
122
+					$toClose[] = (int) $rid;
123
+		}
121 124
 
122
-		if (!empty($toClose))
123
-			updateReport('closed', 1, $toClose);
125
+		if (!empty($toClose)) {
126
+					updateReport('closed', 1, $toClose);
127
+		}
124 128
 
125 129
 		// Set the confirmation message.
126 130
 		$_SESSION['rc_confirmation'] = 'close_all';
@@ -175,8 +179,9 @@  discard block
 block discarded – undo
175 179
 	global $context, $sourcedir, $scripturl, $txt;
176 180
 
177 181
 	// Have to at least give us something to work with.
178
-	if (empty($_REQUEST['rid']))
179
-		fatal_lang_error('mc_reportedp_none_found');
182
+	if (empty($_REQUEST['rid'])) {
183
+			fatal_lang_error('mc_reportedp_none_found');
184
+	}
180 185
 
181 186
 	// Integers only please
182 187
 	$report_id = (int) $_REQUEST['rid'];
@@ -184,8 +189,9 @@  discard block
 block discarded – undo
184 189
 	// Get the report details.
185 190
 	$report = getReportDetails($report_id);
186 191
 
187
-	if (!$report)
188
-		fatal_lang_error('mc_no_modreport_found');
192
+	if (!$report) {
193
+			fatal_lang_error('mc_no_modreport_found');
194
+	}
189 195
 
190 196
 	// Build the report data - basic details first, then extra stuff based on the type
191 197
 	$context['report'] = array(
@@ -211,8 +217,7 @@  discard block
 block discarded – undo
211 217
 				'href' => $scripturl . '?action=profile;u=' . $report['id_user'],
212 218
 			),
213 219
 		);
214
-	}
215
-	else
220
+	} else
216 221
 	{
217 222
 		$extraDetails = array(
218 223
 			'topic_id' => $report['id_topic'],
@@ -235,8 +240,9 @@  discard block
 block discarded – undo
235 240
 
236 241
 	$reportComments = getReportComments($report_id);
237 242
 
238
-	if (!empty($reportComments))
239
-		$context['report'] = array_merge($context['report'], $reportComments);
243
+	if (!empty($reportComments)) {
244
+			$context['report'] = array_merge($context['report'], $reportComments);
245
+	}
240 246
 
241 247
 	// What have the other moderators done to this message?
242 248
 	require_once($sourcedir . '/Modlog.php');
@@ -257,8 +263,7 @@  discard block
 block discarded – undo
257 263
 			1,
258 264
 			true,
259 265
 		);
260
-	}
261
-	else
266
+	} else
262 267
 	{
263 268
 		$params = array(
264 269
 			'lm.id_topic = {int:id_topic}
@@ -358,16 +363,16 @@  discard block
 block discarded – undo
358 363
 	createList($listOptions);
359 364
 
360 365
 	// Make sure to get the correct tab selected.
361
-	if ($context['report']['closed'])
362
-		$context[$context['moderation_menu_name']]['current_subsection'] = 'closed';
366
+	if ($context['report']['closed']) {
367
+			$context[$context['moderation_menu_name']]['current_subsection'] = 'closed';
368
+	}
363 369
 
364 370
 	// Finally we are done :P
365 371
 	if ($context['report_type'] == 'members')
366 372
 	{
367 373
 		$context['page_title'] = sprintf($txt['mc_viewmemberreport'], $context['report']['user']['name']);
368 374
 		$context['sub_template'] = 'viewmemberreport';
369
-	}
370
-	else
375
+	} else
371 376
 	{
372 377
 		$context['page_title'] = sprintf($txt['mc_viewmodreport'], $context['report']['subject'], $context['report']['author']['name']);
373 378
 		$context['sub_template'] = 'viewmodreport';
@@ -390,8 +395,9 @@  discard block
 block discarded – undo
390 395
 	global $smcFunc, $scripturl, $user_info, $context;
391 396
 
392 397
 	// The report ID is a must.
393
-	if (empty($_REQUEST['rid']))
394
-		fatal_lang_error('mc_reportedp_none_found');
398
+	if (empty($_REQUEST['rid'])) {
399
+			fatal_lang_error('mc_reportedp_none_found');
400
+	}
395 401
 
396 402
 	// Integers only please.
397 403
 	$report_id = (int) $_REQUEST['rid'];
@@ -416,8 +422,9 @@  discard block
 block discarded – undo
416 422
 		checkSession('get');
417 423
 		validateToken('mod-reportC-delete', 'get');
418 424
 
419
-		if (empty($_REQUEST['mid']))
420
-			fatal_lang_error('mc_reportedp_comment_none_found');
425
+		if (empty($_REQUEST['mid'])) {
426
+					fatal_lang_error('mc_reportedp_comment_none_found');
427
+		}
421 428
 
422 429
 		$comment_id = (int) $_REQUEST['mid'];
423 430
 
@@ -425,15 +432,17 @@  discard block
 block discarded – undo
425 432
 		$comment = getCommentModDetails($comment_id);
426 433
 
427 434
 		// Perhaps somebody else already deleted this fine gem...
428
-		if (empty($comment))
429
-			fatal_lang_error('report_action_message_delete_issue');
435
+		if (empty($comment)) {
436
+					fatal_lang_error('report_action_message_delete_issue');
437
+		}
430 438
 
431 439
 		// Can you actually do this?
432 440
 		$comment_owner = $user_info['id'] == $comment['id_member'];
433 441
 
434 442
 		// Nope! sorry.
435
-		if (!allowedTo('admin_forum') && !$comment_owner)
436
-			fatal_lang_error('report_action_message_delete_cannot');
443
+		if (!allowedTo('admin_forum') && !$comment_owner) {
444
+					fatal_lang_error('report_action_message_delete_cannot');
445
+		}
437 446
 
438 447
 		// All good!
439 448
 		deleteModComment($comment_id);
@@ -458,11 +467,13 @@  discard block
 block discarded – undo
458 467
 	checkSession(isset($_REQUEST['save']) ? 'post' : 'get');
459 468
 
460 469
 	// The report ID is a must.
461
-	if (empty($_REQUEST['rid']))
462
-		fatal_lang_error('mc_reportedp_none_found');
470
+	if (empty($_REQUEST['rid'])) {
471
+			fatal_lang_error('mc_reportedp_none_found');
472
+	}
463 473
 
464
-	if (empty($_REQUEST['mid']))
465
-		fatal_lang_error('mc_reportedp_comment_none_found');
474
+	if (empty($_REQUEST['mid'])) {
475
+			fatal_lang_error('mc_reportedp_comment_none_found');
476
+	}
466 477
 
467 478
 	// Integers only please.
468 479
 	$context['report_id'] = (int) $_REQUEST['rid'];
@@ -470,8 +481,9 @@  discard block
 block discarded – undo
470 481
 
471 482
 	$context['comment'] = getCommentModDetails($context['comment_id']);
472 483
 
473
-	if (empty($context['comment']))
474
-		fatal_lang_error('mc_reportedp_comment_none_found');
484
+	if (empty($context['comment'])) {
485
+			fatal_lang_error('mc_reportedp_comment_none_found');
486
+	}
475 487
 
476 488
 	// Set up the comforting bits...
477 489
 	$context['page_title'] = $txt['mc_reported_posts'];
@@ -482,15 +494,17 @@  discard block
 block discarded – undo
482 494
 		validateToken('mod-reportC-edit');
483 495
 
484 496
 		// Make sure there is some data to edit on the DB.
485
-		if (empty($context['comment']))
486
-			fatal_lang_error('report_action_message_edit_issue');
497
+		if (empty($context['comment'])) {
498
+					fatal_lang_error('report_action_message_edit_issue');
499
+		}
487 500
 
488 501
 		// Still there, good, now lets see if you can actually edit it...
489 502
 		$comment_owner = $user_info['id'] == $context['comment']['id_member'];
490 503
 
491 504
 		// So, you aren't neither an admin or the comment owner huh? that's too bad.
492
-		if (!allowedTo('admin_forum') && !$comment_owner)
493
-			fatal_lang_error('report_action_message_edit_cannot');
505
+		if (!allowedTo('admin_forum') && !$comment_owner) {
506
+					fatal_lang_error('report_action_message_edit_cannot');
507
+		}
494 508
 
495 509
 		// All good!
496 510
 		$edited_comment = trim($smcFunc['htmlspecialchars']($_POST['mod_comment']));
@@ -516,8 +530,9 @@  discard block
 block discarded – undo
516 530
 	checkSession('get');
517 531
 
518 532
 	// We need to do something!
519
-	if (empty($_GET['rid']) && (!isset($_GET['ignore']) || !isset($_GET['closed'])))
520
-		fatal_lang_error('mc_reportedp_none_found');
533
+	if (empty($_GET['rid']) && (!isset($_GET['ignore']) || !isset($_GET['closed']))) {
534
+			fatal_lang_error('mc_reportedp_none_found');
535
+	}
521 536
 
522 537
 	// What are we gonna do?
523 538
 	$action = isset($_GET['ignore']) ? 'ignore' : 'closed';
Please login to merge, or discard this patch.
Sources/index.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,8 @@
 block discarded – undo
12 12
 	header('Location: ' . $boardurl);
13 13
 }
14 14
 // Can't find it... just forget it.
15
-else
15
+else {
16 16
 	exit;
17
+}
17 18
 
18 19
 ?>
19 20
\ No newline at end of file
Please login to merge, or discard this patch.