Completed
Branch release-2.1 (3c29ac)
by Mathias
08:54
created
Sources/Subs-MessageIndex.php 1 patch
Braces   +13 added lines, -10 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
  * @version 2.1 Beta 3
12 12
  */
13 13
 
14
-if (!defined('SMF'))
14
+if (!defined('SMF')) {
15 15
 	die('No direct access...');
16
+}
16 17
 
17 18
 /**
18 19
  * Generates the query to determine the list of available boards for a user
@@ -25,8 +26,9 @@  discard block
 block discarded – undo
25 26
 {
26 27
 	global $smcFunc, $sourcedir;
27 28
 
28
-	if (isset($boardListOptions['excluded_boards']) && isset($boardListOptions['included_boards']))
29
-		trigger_error('getBoardList(): Setting both excluded_boards and included_boards is not allowed.', E_USER_ERROR);
29
+	if (isset($boardListOptions['excluded_boards']) && isset($boardListOptions['included_boards'])) {
30
+			trigger_error('getBoardList(): Setting both excluded_boards and included_boards is not allowed.', E_USER_ERROR);
31
+	}
30 32
 
31 33
 	$where = array();
32 34
 	$where_parameters = array();
@@ -42,11 +44,11 @@  discard block
 block discarded – undo
42 44
 		$where_parameters['included_boards'] = $boardListOptions['included_boards'];
43 45
 	}
44 46
 
45
-	if (!empty($boardListOptions['ignore_boards']))
46
-		$where[] = '{query_wanna_see_board}';
47
-
48
-	elseif (!empty($boardListOptions['use_permissions']))
49
-		$where[] = '{query_see_board}';
47
+	if (!empty($boardListOptions['ignore_boards'])) {
48
+			$where[] = '{query_wanna_see_board}';
49
+	} elseif (!empty($boardListOptions['use_permissions'])) {
50
+			$where[] = '{query_see_board}';
51
+	}
50 52
 
51 53
 	if (!empty($boardListOptions['not_redirection']))
52 54
 	{
@@ -68,12 +70,13 @@  discard block
 block discarded – undo
68 70
 	{
69 71
 		while ($row = $smcFunc['db_fetch_assoc']($request))
70 72
 		{
71
-			if (!isset($return_value[$row['id_cat']]))
72
-				$return_value[$row['id_cat']] = array(
73
+			if (!isset($return_value[$row['id_cat']])) {
74
+							$return_value[$row['id_cat']] = array(
73 75
 					'id' => $row['id_cat'],
74 76
 					'name' => $row['cat_name'],
75 77
 					'boards' => array(),
76 78
 				);
79
+			}
77 80
 
78 81
 			$return_value[$row['id_cat']]['boards'][$row['id_board']] = array(
79 82
 				'id' => $row['id_board'],
Please login to merge, or discard this patch.
Sources/DbSearch-postgresql.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -37,12 +37,12 @@  discard block
 block discarded – undo
37 37
 	$version = $smcFunc['db_get_version']();
38 38
 	// if we got a Beta Version
39 39
 	if (stripos($version, 'beta') !== false)
40
-		$version = substr($version, 0, stripos($version, 'beta')).'.0';
40
+		$version = substr($version, 0, stripos($version, 'beta')) . '.0';
41 41
 	// or RC
42 42
 	if (stripos($version, 'rc') !== false)
43
-		$version = substr($version, 0, stripos($version, 'rc')).'.0';
43
+		$version = substr($version, 0, stripos($version, 'rc')) . '.0';
44 44
 
45
-	if (version_compare($version,'9.5.0','>='))
45
+	if (version_compare($version, '9.5.0', '>='))
46 46
 		$smcFunc['db_support_ignore'] = true;
47 47
 }
48 48
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
  */
55 55
 function smf_db_search_support($search_type)
56 56
 {
57
-	$supported_types = array('custom','fulltext');
57
+	$supported_types = array('custom', 'fulltext');
58 58
 
59 59
 	return in_array($search_type, $supported_types);
60 60
 }
@@ -108,9 +108,9 @@  discard block
 block discarded – undo
108 108
 	if (preg_match('~^\s*INSERT\sIGNORE~i', $db_string) != 0)
109 109
 	{
110 110
 		$db_string = preg_replace('~^\s*INSERT\sIGNORE~i', 'INSERT', $db_string);
111
-		if ($smcFunc['db_support_ignore']){
111
+		if ($smcFunc['db_support_ignore']) {
112 112
 			//pg style "INSERT INTO.... ON CONFLICT DO NOTHING"
113
-			$db_string = $db_string.' ON CONFLICT DO NOTHING';
113
+			$db_string = $db_string . ' ON CONFLICT DO NOTHING';
114 114
 		}
115 115
 		else
116 116
 		{
Please login to merge, or discard this patch.
Braces   +19 added lines, -14 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
  *  Add the file functions to the $smcFunc array.
@@ -23,28 +24,32 @@  discard block
 block discarded – undo
23 24
 {
24 25
 	global $smcFunc;
25 26
 
26
-	if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_search_query')
27
-		$smcFunc += array(
27
+	if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_search_query') {
28
+			$smcFunc += array(
28 29
 			'db_search_query' => 'smf_db_search_query',
29 30
 			'db_search_support' => 'smf_db_search_support',
30 31
 			'db_create_word_search' => 'smf_db_create_word_search',
31 32
 			'db_support_ignore' => false,
32 33
 		);
34
+	}
33 35
 
34 36
 	db_extend();
35 37
 
36 38
 	//pg 9.5 got ignore support
37 39
 	$version = $smcFunc['db_get_version']();
38 40
 	// if we got a Beta Version
39
-	if (stripos($version, 'beta') !== false)
40
-		$version = substr($version, 0, stripos($version, 'beta')).'.0';
41
+	if (stripos($version, 'beta') !== false) {
42
+			$version = substr($version, 0, stripos($version, 'beta')).'.0';
43
+	}
41 44
 	// or RC
42
-	if (stripos($version, 'rc') !== false)
43
-		$version = substr($version, 0, stripos($version, 'rc')).'.0';
45
+	if (stripos($version, 'rc') !== false) {
46
+			$version = substr($version, 0, stripos($version, 'rc')).'.0';
47
+	}
44 48
 
45
-	if (version_compare($version,'9.5.0','>='))
46
-		$smcFunc['db_support_ignore'] = true;
47
-}
49
+	if (version_compare($version,'9.5.0','>=')) {
50
+			$smcFunc['db_support_ignore'] = true;
51
+	}
52
+	}
48 53
 
49 54
 /**
50 55
  * This function will tell you whether this database type supports this search type.
@@ -103,16 +108,16 @@  discard block
 block discarded – undo
103 108
 		),
104 109
 	);
105 110
 
106
-	if (isset($replacements[$identifier]))
107
-		$db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string);
111
+	if (isset($replacements[$identifier])) {
112
+			$db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string);
113
+	}
108 114
 	if (preg_match('~^\s*INSERT\sIGNORE~i', $db_string) != 0)
109 115
 	{
110 116
 		$db_string = preg_replace('~^\s*INSERT\sIGNORE~i', 'INSERT', $db_string);
111 117
 		if ($smcFunc['db_support_ignore']){
112 118
 			//pg style "INSERT INTO.... ON CONFLICT DO NOTHING"
113 119
 			$db_string = $db_string.' ON CONFLICT DO NOTHING';
114
-		}
115
-		else
120
+		} else
116 121
 		{
117 122
 			// Don't error on multi-insert.
118 123
 			$db_values['db_error_skip'] = true;
Please login to merge, or discard this patch.
Sources/ManageSettings.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1323,7 +1323,7 @@  discard block
 block discarded – undo
1323 1323
 					'class' => 'centercol',
1324 1324
 				),
1325 1325
 				'data' => array(
1326
-					'function' => function ($rowData)
1326
+					'function' => function($rowData)
1327 1327
 					{
1328 1328
 						$isChecked = $rowData['disabled'] ? '' : ' checked';
1329 1329
 						$onClickHandler = $rowData['can_show_register'] ? sprintf(' onclick="document.getElementById(\'reg_%1$s\').disabled = !this.checked;"', $rowData['id']) : '';
@@ -1339,7 +1339,7 @@  discard block
 block discarded – undo
1339 1339
 					'class' => 'centercol',
1340 1340
 				),
1341 1341
 				'data' => array(
1342
-					'function' => function ($rowData)
1342
+					'function' => function($rowData)
1343 1343
 					{
1344 1344
 						$isChecked = $rowData['on_register'] && !$rowData['disabled'] ? ' checked' : '';
1345 1345
 						$isDisabled = $rowData['can_show_register'] ? '' : ' disabled';
@@ -1386,15 +1386,15 @@  discard block
 block discarded – undo
1386 1386
 					'value' => $txt['custom_profile_fieldorder'],
1387 1387
 				),
1388 1388
 				'data' => array(
1389
-					'function' => function ($rowData) use ($context, $txt, $scripturl)
1389
+					'function' => function($rowData) use ($context, $txt, $scripturl)
1390 1390
 					{
1391
-						$return = '<p class="centertext bold_text">'. $rowData['field_order'] .'<br />';
1391
+						$return = '<p class="centertext bold_text">' . $rowData['field_order'] . '<br />';
1392 1392
 
1393 1393
 						if ($rowData['field_order'] > 1)
1394
-							$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>';
1394
+							$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="' . $txt['custom_edit_order_move'] . ' ' . $txt['custom_edit_order_up'] . '"></span></a>';
1395 1395
 
1396 1396
 						if ($rowData['field_order'] < $context['custFieldsMaxOrder'])
1397
-							$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>';
1397
+							$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="' . $txt['custom_edit_order_move'] . ' ' . $txt['custom_edit_order_down'] . '"></span></a>';
1398 1398
 
1399 1399
 						$return .= '</p>';
1400 1400
 
@@ -1412,7 +1412,7 @@  discard block
 block discarded – undo
1412 1412
 					'value' => $txt['custom_profile_fieldname'],
1413 1413
 				),
1414 1414
 				'data' => array(
1415
-					'function' => function ($rowData) use ($scripturl)
1415
+					'function' => function($rowData) use ($scripturl)
1416 1416
 					{
1417 1417
 						return sprintf('<a href="%1$s?action=admin;area=featuresettings;sa=profileedit;fid=%2$d">%3$s</a><div class="smalltext">%4$s</div>', $scripturl, $rowData['id_field'], $rowData['field_name'], $rowData['field_desc']);
1418 1418
 					},
@@ -1428,7 +1428,7 @@  discard block
 block discarded – undo
1428 1428
 					'value' => $txt['custom_profile_fieldtype'],
1429 1429
 				),
1430 1430
 				'data' => array(
1431
-					'function' => function ($rowData) use ($txt)
1431
+					'function' => function($rowData) use ($txt)
1432 1432
 					{
1433 1433
 						$textKey = sprintf('custom_profile_type_%1$s', $rowData['field_type']);
1434 1434
 						return isset($txt[$textKey]) ? $txt[$textKey] : $textKey;
@@ -1446,7 +1446,7 @@  discard block
 block discarded – undo
1446 1446
 					'value' => $txt['custom_profile_active'],
1447 1447
 				),
1448 1448
 				'data' => array(
1449
-					'function' => function ($rowData) use ($txt)
1449
+					'function' => function($rowData) use ($txt)
1450 1450
 					{
1451 1451
 						return $rowData['active'] ? $txt['yes'] : $txt['no'];
1452 1452
 					},
@@ -1463,7 +1463,7 @@  discard block
 block discarded – undo
1463 1463
 					'value' => $txt['custom_profile_placement'],
1464 1464
 				),
1465 1465
 				'data' => array(
1466
-					'function' => function ($rowData)
1466
+					'function' => function($rowData)
1467 1467
 					{
1468 1468
 						global $txt, $context;
1469 1469
 
@@ -1698,7 +1698,7 @@  discard block
 block discarded – undo
1698 1698
 			redirectexit('action=admin;area=featuresettings;sa=profile'); // @todo implement an error handler
1699 1699
 
1700 1700
 		// All good, proceed.
1701
-		$smcFunc['db_query']('','
1701
+		$smcFunc['db_query']('', '
1702 1702
 			UPDATE {db_prefix}custom_fields
1703 1703
 			SET field_order = {int:old_order}
1704 1704
 			WHERE field_order = {int:new_order}',
@@ -1707,7 +1707,7 @@  discard block
 block discarded – undo
1707 1707
 				'old_order' => $context['field']['order'],
1708 1708
 			)
1709 1709
 		);
1710
-		$smcFunc['db_query']('','
1710
+		$smcFunc['db_query']('', '
1711 1711
 			UPDATE {db_prefix}custom_fields
1712 1712
 			SET field_order = {int:new_order}
1713 1713
 			WHERE id_field = {int:id_field}',
@@ -1809,7 +1809,7 @@  discard block
 block discarded – undo
1809 1809
 			$smcFunc['db_free_result']($request);
1810 1810
 
1811 1811
 			$unique = false;
1812
-			for ($i = 0; !$unique && $i < 9; $i ++)
1812
+			for ($i = 0; !$unique && $i < 9; $i++)
1813 1813
 			{
1814 1814
 				if (!in_array($col_name, $current_fields))
1815 1815
 					$unique = true;
@@ -1982,7 +1982,7 @@  discard block
 block discarded – undo
1982 1982
 		);
1983 1983
 
1984 1984
 		// Re-arrange the order.
1985
-		$smcFunc['db_query']('','
1985
+		$smcFunc['db_query']('', '
1986 1986
 			UPDATE {db_prefix}custom_fields
1987 1987
 			SET field_order = field_order - 1
1988 1988
 			WHERE field_order > {int:current_order}',
@@ -2246,7 +2246,7 @@  discard block
 block discarded – undo
2246 2246
 	$context['token_check'] = 'noti-admin';
2247 2247
 
2248 2248
 	// Specify our action since we'll want to post back here instead of the profile
2249
-	$context['action'] = 'action=admin;area=featuresettings;sa=alerts;'. $context['session_var'] .'='. $context['session_id'];
2249
+	$context['action'] = 'action=admin;area=featuresettings;sa=alerts;' . $context['session_var'] . '=' . $context['session_id'];
2250 2250
 
2251 2251
 	loadTemplate('Profile');
2252 2252
 	loadLanguage('Profile');
Please login to merge, or discard this patch.
Braces   +273 added lines, -199 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
  * This function makes sure the requested subaction does exists, if it doesn't, it sets a default action or.
@@ -202,16 +203,18 @@  discard block
 block discarded – undo
202 203
 	{
203 204
 		$all_zones = timezone_identifiers_list();
204 205
 		// Make sure we set the value to the same as the printed value.
205
-		foreach ($all_zones as $zone)
206
-			$config_vars['default_timezone'][2][$zone] = $zone;
206
+		foreach ($all_zones as $zone) {
207
+					$config_vars['default_timezone'][2][$zone] = $zone;
208
+		}
209
+	} else {
210
+			unset($config_vars['default_timezone']);
207 211
 	}
208
-	else
209
-		unset($config_vars['default_timezone']);
210 212
 
211 213
 	call_integration_hook('integrate_modify_basic_settings', array(&$config_vars));
212 214
 
213
-	if ($return_config)
214
-		return $config_vars;
215
+	if ($return_config) {
216
+			return $config_vars;
217
+	}
215 218
 
216 219
 	// Saving?
217 220
 	if (isset($_GET['save']))
@@ -219,8 +222,9 @@  discard block
 block discarded – undo
219 222
 		checkSession();
220 223
 
221 224
 		// Prevent absurd boundaries here - make it a day tops.
222
-		if (isset($_POST['lastActive']))
223
-			$_POST['lastActive'] = min((int) $_POST['lastActive'], 1440);
225
+		if (isset($_POST['lastActive'])) {
226
+					$_POST['lastActive'] = min((int) $_POST['lastActive'], 1440);
227
+		}
224 228
 
225 229
 		call_integration_hook('integrate_save_basic_settings');
226 230
 
@@ -265,8 +269,9 @@  discard block
 block discarded – undo
265 269
 
266 270
 	call_integration_hook('integrate_modify_bbc_settings', array(&$config_vars));
267 271
 
268
-	if ($return_config)
269
-		return $config_vars;
272
+	if ($return_config) {
273
+			return $config_vars;
274
+	}
270 275
 
271 276
 	// Setup the template.
272 277
 	require_once($sourcedir . '/ManageServer.php');
@@ -283,13 +288,15 @@  discard block
 block discarded – undo
283 288
 
284 289
 		// Clean up the tags.
285 290
 		$bbcTags = array();
286
-		foreach (parse_bbc(false) as $tag)
287
-			$bbcTags[] = $tag['tag'];
291
+		foreach (parse_bbc(false) as $tag) {
292
+					$bbcTags[] = $tag['tag'];
293
+		}
288 294
 
289
-		if (!isset($_POST['disabledBBC_enabledTags']))
290
-			$_POST['disabledBBC_enabledTags'] = array();
291
-		elseif (!is_array($_POST['disabledBBC_enabledTags']))
292
-			$_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']);
295
+		if (!isset($_POST['disabledBBC_enabledTags'])) {
296
+					$_POST['disabledBBC_enabledTags'] = array();
297
+		} elseif (!is_array($_POST['disabledBBC_enabledTags'])) {
298
+					$_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']);
299
+		}
293 300
 		// Work out what is actually disabled!
294 301
 		$_POST['disabledBBC'] = implode(',', array_diff($bbcTags, $_POST['disabledBBC_enabledTags']));
295 302
 
@@ -333,8 +340,9 @@  discard block
 block discarded – undo
333 340
 
334 341
 	call_integration_hook('integrate_layout_settings', array(&$config_vars));
335 342
 
336
-	if ($return_config)
337
-		return $config_vars;
343
+	if ($return_config) {
344
+			return $config_vars;
345
+	}
338 346
 
339 347
 	// Saving?
340 348
 	if (isset($_GET['save']))
@@ -375,8 +383,9 @@  discard block
 block discarded – undo
375 383
 
376 384
 	call_integration_hook('integrate_likes_settings', array(&$config_vars));
377 385
 
378
-	if ($return_config)
379
-		return $config_vars;
386
+	if ($return_config) {
387
+			return $config_vars;
388
+	}
380 389
 
381 390
 	// Saving?
382 391
 	if (isset($_GET['save']))
@@ -414,8 +423,9 @@  discard block
 block discarded – undo
414 423
 
415 424
 	call_integration_hook('integrate_mentions_settings', array(&$config_vars));
416 425
 
417
-	if ($return_config)
418
-		return $config_vars;
426
+	if ($return_config) {
427
+			return $config_vars;
428
+	}
419 429
 
420 430
 	// Saving?
421 431
 	if (isset($_GET['save']))
@@ -459,8 +469,8 @@  discard block
 block discarded – undo
459 469
 			'enable' => array('check', 'warning_enable'),
460 470
 	);
461 471
 
462
-	if (!empty($modSettings['warning_settings']) && $currently_enabled)
463
-		$config_vars += array(
472
+	if (!empty($modSettings['warning_settings']) && $currently_enabled) {
473
+			$config_vars += array(
464 474
 			'',
465 475
 				array('int', 'warning_watch', 'subtext' => $txt['setting_warning_watch_note'] . ' ' . $txt['zero_to_disable']),
466 476
 				'moderate' => array('int', 'warning_moderate', 'subtext' => $txt['setting_warning_moderate_note'] . ' ' . $txt['zero_to_disable']),
@@ -469,15 +479,18 @@  discard block
 block discarded – undo
469 479
 				'rem2' => array('int', 'warning_decrement', 'subtext' => $txt['setting_warning_decrement_note'] . ' ' . $txt['zero_to_disable']),
470 480
 				array('permissions', 'view_warning'),
471 481
 		);
482
+	}
472 483
 
473 484
 	call_integration_hook('integrate_warning_settings', array(&$config_vars));
474 485
 
475
-	if ($return_config)
476
-		return $config_vars;
486
+	if ($return_config) {
487
+			return $config_vars;
488
+	}
477 489
 
478 490
 	// Cannot use moderation if post moderation is not enabled.
479
-	if (!$modSettings['postmod_active'])
480
-		unset($config_vars['moderate']);
491
+	if (!$modSettings['postmod_active']) {
492
+			unset($config_vars['moderate']);
493
+	}
481 494
 
482 495
 	// Will need the utility functions from here.
483 496
 	require_once($sourcedir . '/ManageServer.php');
@@ -502,16 +515,16 @@  discard block
 block discarded – undo
502 515
 				'warning_watch' => 10,
503 516
 				'warning_mute' => 60,
504 517
 			);
505
-			if ($modSettings['postmod_active'])
506
-				$vars['warning_moderate'] = 35;
518
+			if ($modSettings['postmod_active']) {
519
+							$vars['warning_moderate'] = 35;
520
+			}
507 521
 
508 522
 			foreach ($vars as $var => $value)
509 523
 			{
510 524
 				$config_vars[] = array('int', $var);
511 525
 				$_POST[$var] = $value;
512 526
 			}
513
-		}
514
-		else
527
+		} else
515 528
 		{
516 529
 			$_POST['warning_watch'] = min($_POST['warning_watch'], 100);
517 530
 			$_POST['warning_moderate'] = $modSettings['postmod_active'] ? min($_POST['warning_moderate'], 100) : 0;
@@ -592,8 +605,9 @@  discard block
 block discarded – undo
592 605
 
593 606
 	call_integration_hook('integrate_spam_settings', array(&$config_vars));
594 607
 
595
-	if ($return_config)
596
-		return $config_vars;
608
+	if ($return_config) {
609
+			return $config_vars;
610
+	}
597 611
 
598 612
 	// You need to be an admin to edit settings!
599 613
 	isAllowedTo('admin_forum');
@@ -627,8 +641,9 @@  discard block
 block discarded – undo
627 641
 
628 642
 	if (empty($context['qa_by_lang'][strtr($language, array('-utf8' => ''))]) && !empty($context['question_answers']))
629 643
 	{
630
-		if (empty($context['settings_insert_above']))
631
-			$context['settings_insert_above'] = '';
644
+		if (empty($context['settings_insert_above'])) {
645
+					$context['settings_insert_above'] = '';
646
+		}
632 647
 
633 648
 		$context['settings_insert_above'] .= '<div class="noticebox">' . sprintf($txt['question_not_defined'], $context['languages'][$language]['name']) . '</div>';
634 649
 	}
@@ -671,8 +686,9 @@  discard block
 block discarded – undo
671 686
 		$_POST['pm_spam_settings'] = (int) $_POST['max_pm_recipients'] . ',' . (int) $_POST['pm_posts_verification'] . ',' . (int) $_POST['pm_posts_per_hour'];
672 687
 
673 688
 		// Hack in guest requiring verification!
674
-		if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha']))
675
-			$_POST['posts_require_captcha'] = -1;
689
+		if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha'])) {
690
+					$_POST['posts_require_captcha'] = -1;
691
+		}
676 692
 
677 693
 		$save_vars = $config_vars;
678 694
 		unset($save_vars['pm1'], $save_vars['pm2'], $save_vars['pm3'], $save_vars['guest_verify']);
@@ -689,14 +705,16 @@  discard block
 block discarded – undo
689 705
 		foreach ($context['qa_languages'] as $lang_id => $dummy)
690 706
 		{
691 707
 			// If we had some questions for this language before, but don't now, delete everything from that language.
692
-			if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id]))
693
-				$changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]);
708
+			if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id])) {
709
+							$changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]);
710
+			}
694 711
 
695 712
 			// Now step through and see if any existing questions no longer exist.
696
-			if (!empty($context['qa_by_lang'][$lang_id]))
697
-				foreach ($context['qa_by_lang'][$lang_id] as $q_id)
713
+			if (!empty($context['qa_by_lang'][$lang_id])) {
714
+							foreach ($context['qa_by_lang'][$lang_id] as $q_id)
698 715
 					if (empty($_POST['question'][$lang_id][$q_id]))
699 716
 						$changes['delete'][] = $q_id;
717
+			}
700 718
 
701 719
 			// Now let's see if there are new questions or ones that need updating.
702 720
 			if (isset($_POST['question'][$lang_id]))
@@ -705,14 +723,16 @@  discard block
 block discarded – undo
705 723
 				{
706 724
 					// Ignore junky ids.
707 725
 					$q_id = (int) $q_id;
708
-					if ($q_id <= 0)
709
-						continue;
726
+					if ($q_id <= 0) {
727
+											continue;
728
+					}
710 729
 
711 730
 					// Check the question isn't empty (because they want to delete it?)
712 731
 					if (empty($question) || trim($question) == '')
713 732
 					{
714
-						if (isset($context['question_answers'][$q_id]))
715
-							$changes['delete'][] = $q_id;
733
+						if (isset($context['question_answers'][$q_id])) {
734
+													$changes['delete'][] = $q_id;
735
+						}
716 736
 						continue;
717 737
 					}
718 738
 					$question = $smcFunc['htmlspecialchars'](trim($question));
@@ -720,19 +740,22 @@  discard block
 block discarded – undo
720 740
 					// Get the answers. Firstly check there actually might be some.
721 741
 					if (!isset($_POST['answer'][$lang_id][$q_id]) || !is_array($_POST['answer'][$lang_id][$q_id]))
722 742
 					{
723
-						if (isset($context['question_answers'][$q_id]))
724
-							$changes['delete'][] = $q_id;
743
+						if (isset($context['question_answers'][$q_id])) {
744
+													$changes['delete'][] = $q_id;
745
+						}
725 746
 						continue;
726 747
 					}
727 748
 					// Now get them and check that they might be viable.
728 749
 					$answers = array();
729
-					foreach ($_POST['answer'][$lang_id][$q_id] as $answer)
730
-						if (!empty($answer) && trim($answer) !== '')
750
+					foreach ($_POST['answer'][$lang_id][$q_id] as $answer) {
751
+											if (!empty($answer) && trim($answer) !== '')
731 752
 							$answers[] = $smcFunc['htmlspecialchars'](trim($answer));
753
+					}
732 754
 					if (empty($answers))
733 755
 					{
734
-						if (isset($context['question_answers'][$q_id]))
735
-							$changes['delete'][] = $q_id;
756
+						if (isset($context['question_answers'][$q_id])) {
757
+													$changes['delete'][] = $q_id;
758
+						}
736 759
 						continue;
737 760
 					}
738 761
 					$answers = json_encode($answers);
@@ -742,16 +765,17 @@  discard block
 block discarded – undo
742 765
 					{
743 766
 						// New question. Now, we don't want to randomly consume ids, so we'll set those, rather than trusting the browser's supplied ids.
744 767
 						$changes['insert'][] = array($lang_id, $question, $answers);
745
-					}
746
-					else
768
+					} else
747 769
 					{
748 770
 						// It's an existing question. Let's see what's changed, if anything.
749
-						if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers'])
750
-							$changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers);
771
+						if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers']) {
772
+													$changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers);
773
+						}
751 774
 					}
752 775
 
753
-					if (!isset($qs_per_lang[$lang_id]))
754
-						$qs_per_lang[$lang_id] = 0;
776
+					if (!isset($qs_per_lang[$lang_id])) {
777
+											$qs_per_lang[$lang_id] = 0;
778
+					}
755 779
 					$qs_per_lang[$lang_id]++;
756 780
 				}
757 781
 			}
@@ -801,8 +825,9 @@  discard block
 block discarded – undo
801 825
 
802 826
 		// Lastly, the count of messages needs to be no more than the lowest number of questions for any one language.
803 827
 		$count_questions = empty($qs_per_lang) ? 0 : min($qs_per_lang);
804
-		if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions)
805
-			$_POST['qa_verification_number'] = $count_questions;
828
+		if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions) {
829
+					$_POST['qa_verification_number'] = $count_questions;
830
+		}
806 831
 
807 832
 		call_integration_hook('integrate_save_spam_settings', array(&$save_vars));
808 833
 
@@ -817,24 +842,27 @@  discard block
 block discarded – undo
817 842
 
818 843
 	$character_range = array_merge(range('A', 'H'), array('K', 'M', 'N', 'P', 'R'), range('T', 'Y'));
819 844
 	$_SESSION['visual_verification_code'] = '';
820
-	for ($i = 0; $i < 6; $i++)
821
-		$_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)];
845
+	for ($i = 0; $i < 6; $i++) {
846
+			$_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)];
847
+	}
822 848
 
823 849
 	// Some javascript for CAPTCHA.
824 850
 	$context['settings_post_javascript'] = '';
825
-	if ($context['use_graphic_library'])
826
-		$context['settings_post_javascript'] .= '
851
+	if ($context['use_graphic_library']) {
852
+			$context['settings_post_javascript'] .= '
827 853
 		function refreshImages()
828 854
 		{
829 855
 			var imageType = document.getElementById(\'visual_verification_type\').value;
830 856
 			document.getElementById(\'verification_image\').src = \'' . $context['verification_image_href'] . ';type=\' + imageType;
831 857
 		}';
858
+	}
832 859
 
833 860
 	// Show the image itself, or text saying we can't.
834
-	if ($context['use_graphic_library'])
835
-		$config_vars['vv']['postinput'] = '<br><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image"><br>';
836
-	else
837
-		$config_vars['vv']['postinput'] = '<br><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>';
861
+	if ($context['use_graphic_library']) {
862
+			$config_vars['vv']['postinput'] = '<br><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image"><br>';
863
+	} else {
864
+			$config_vars['vv']['postinput'] = '<br><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>';
865
+	}
838 866
 
839 867
 	// Hack for PM spam settings.
840 868
 	list ($modSettings['max_pm_recipients'], $modSettings['pm_posts_verification'], $modSettings['pm_posts_per_hour']) = explode(',', $modSettings['pm_spam_settings']);
@@ -844,9 +872,10 @@  discard block
 block discarded – undo
844 872
 	$modSettings['posts_require_captcha'] = !isset($modSettings['posts_require_captcha']) || $modSettings['posts_require_captcha'] == -1 ? 0 : $modSettings['posts_require_captcha'];
845 873
 
846 874
 	// Some minor javascript for the guest post setting.
847
-	if ($modSettings['posts_require_captcha'])
848
-		$context['settings_post_javascript'] .= '
875
+	if ($modSettings['posts_require_captcha']) {
876
+			$context['settings_post_javascript'] .= '
849 877
 		document.getElementById(\'guests_require_captcha\').disabled = true;';
878
+	}
850 879
 
851 880
 	// And everything else.
852 881
 	$context['post_url'] = $scripturl . '?action=admin;area=antispam;save';
@@ -893,8 +922,9 @@  discard block
 block discarded – undo
893 922
 
894 923
 	call_integration_hook('integrate_signature_settings', array(&$config_vars));
895 924
 
896
-	if ($return_config)
897
-		return $config_vars;
925
+	if ($return_config) {
926
+			return $config_vars;
927
+	}
898 928
 
899 929
 	// Setup the template.
900 930
 	$context['page_title'] = $txt['signature_settings'];
@@ -949,8 +979,9 @@  discard block
 block discarded – undo
949 979
 				$sig = strtr($row['signature'], array('<br>' => "\n"));
950 980
 
951 981
 				// Max characters...
952
-				if (!empty($sig_limits[1]))
953
-					$sig = $smcFunc['substr']($sig, 0, $sig_limits[1]);
982
+				if (!empty($sig_limits[1])) {
983
+									$sig = $smcFunc['substr']($sig, 0, $sig_limits[1]);
984
+				}
954 985
 				// Max lines...
955 986
 				if (!empty($sig_limits[2]))
956 987
 				{
@@ -960,8 +991,9 @@  discard block
 block discarded – undo
960 991
 						if ($sig[$i] == "\n")
961 992
 						{
962 993
 							$count++;
963
-							if ($count >= $sig_limits[2])
964
-								$sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' '));
994
+							if ($count >= $sig_limits[2]) {
995
+															$sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' '));
996
+							}
965 997
 						}
966 998
 					}
967 999
 				}
@@ -972,17 +1004,19 @@  discard block
 block discarded – undo
972 1004
 					{
973 1005
 						$limit_broke = 0;
974 1006
 						// Attempt to allow all sizes of abuse, so to speak.
975
-						if ($matches[2][$ind] == 'px' && $size > $sig_limits[7])
976
-							$limit_broke = $sig_limits[7] . 'px';
977
-						elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75))
978
-							$limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt';
979
-						elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16))
980
-							$limit_broke = ((float) $sig_limits[7] / 16) . 'em';
981
-						elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18)
982
-							$limit_broke = 'large';
983
-
984
-						if ($limit_broke)
985
-							$sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig);
1007
+						if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) {
1008
+													$limit_broke = $sig_limits[7] . 'px';
1009
+						} elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) {
1010
+													$limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt';
1011
+						} elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) {
1012
+													$limit_broke = ((float) $sig_limits[7] / 16) . 'em';
1013
+						} elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) {
1014
+													$limit_broke = 'large';
1015
+						}
1016
+
1017
+						if ($limit_broke) {
1018
+													$sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig);
1019
+						}
986 1020
 					}
987 1021
 				}
988 1022
 
@@ -1038,32 +1072,34 @@  discard block
 block discarded – undo
1038 1072
 											$img_offset = false;
1039 1073
 										}
1040 1074
 									}
1075
+								} else {
1076
+																	$replaces[$image] = '';
1041 1077
 								}
1042
-								else
1043
-									$replaces[$image] = '';
1044 1078
 
1045 1079
 								continue;
1046 1080
 							}
1047 1081
 
1048 1082
 							// Does it have predefined restraints? Width first.
1049
-							if ($matches[6][$key])
1050
-								$matches[2][$key] = $matches[6][$key];
1083
+							if ($matches[6][$key]) {
1084
+															$matches[2][$key] = $matches[6][$key];
1085
+							}
1051 1086
 							if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5])
1052 1087
 							{
1053 1088
 								$width = $sig_limits[5];
1054 1089
 								$matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]);
1090
+							} elseif ($matches[2][$key]) {
1091
+															$width = $matches[2][$key];
1055 1092
 							}
1056
-							elseif ($matches[2][$key])
1057
-								$width = $matches[2][$key];
1058 1093
 							// ... and height.
1059 1094
 							if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6])
1060 1095
 							{
1061 1096
 								$height = $sig_limits[6];
1062
-								if ($width != -1)
1063
-									$width = $width * ($height / $matches[4][$key]);
1097
+								if ($width != -1) {
1098
+																	$width = $width * ($height / $matches[4][$key]);
1099
+								}
1100
+							} elseif ($matches[4][$key]) {
1101
+															$height = $matches[4][$key];
1064 1102
 							}
1065
-							elseif ($matches[4][$key])
1066
-								$height = $matches[4][$key];
1067 1103
 
1068 1104
 							// If the dimensions are still not fixed - we need to check the actual image.
1069 1105
 							if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6]))
@@ -1081,12 +1117,13 @@  discard block
 block discarded – undo
1081 1117
 									if ($sizes[1] > $sig_limits[6] && $sig_limits[6])
1082 1118
 									{
1083 1119
 										$height = $sig_limits[6];
1084
-										if ($width == -1)
1085
-											$width = $sizes[0];
1120
+										if ($width == -1) {
1121
+																					$width = $sizes[0];
1122
+										}
1086 1123
 										$width = $width * ($height / $sizes[1]);
1124
+									} elseif ($width != -1) {
1125
+																			$height = $sizes[1];
1087 1126
 									}
1088
-									elseif ($width != -1)
1089
-										$height = $sizes[1];
1090 1127
 								}
1091 1128
 							}
1092 1129
 
@@ -1099,8 +1136,9 @@  discard block
 block discarded – undo
1099 1136
 							// Record that we got one.
1100 1137
 							$image_count_holder[$image] = isset($image_count_holder[$image]) ? $image_count_holder[$image] + 1 : 1;
1101 1138
 						}
1102
-						if (!empty($replaces))
1103
-							$sig = str_replace(array_keys($replaces), array_values($replaces), $sig);
1139
+						if (!empty($replaces)) {
1140
+													$sig = str_replace(array_keys($replaces), array_values($replaces), $sig);
1141
+						}
1104 1142
 					}
1105 1143
 				}
1106 1144
 				// Try to fix disabled tags.
@@ -1112,18 +1150,20 @@  discard block
 block discarded – undo
1112 1150
 
1113 1151
 				$sig = strtr($sig, array("\n" => '<br>'));
1114 1152
 				call_integration_hook('integrate_apply_signature_settings', array(&$sig, $sig_limits, $disabledTags));
1115
-				if ($sig != $row['signature'])
1116
-					$changes[$row['id_member']] = $sig;
1153
+				if ($sig != $row['signature']) {
1154
+									$changes[$row['id_member']] = $sig;
1155
+				}
1156
+			}
1157
+			if ($smcFunc['db_num_rows']($request) == 0) {
1158
+							$done = true;
1117 1159
 			}
1118
-			if ($smcFunc['db_num_rows']($request) == 0)
1119
-				$done = true;
1120 1160
 			$smcFunc['db_free_result']($request);
1121 1161
 
1122 1162
 			// Do we need to delete what we have?
1123 1163
 			if (!empty($changes))
1124 1164
 			{
1125
-				foreach ($changes as $id => $sig)
1126
-					$smcFunc['db_query']('', '
1165
+				foreach ($changes as $id => $sig) {
1166
+									$smcFunc['db_query']('', '
1127 1167
 						UPDATE {db_prefix}members
1128 1168
 						SET signature = {string:signature}
1129 1169
 						WHERE id_member = {int:id_member}',
@@ -1132,11 +1172,13 @@  discard block
 block discarded – undo
1132 1172
 							'signature' => $sig,
1133 1173
 						)
1134 1174
 					);
1175
+				}
1135 1176
 			}
1136 1177
 
1137 1178
 			$_GET['step'] += 50;
1138
-			if (!$done)
1139
-				pauseSignatureApplySettings();
1179
+			if (!$done) {
1180
+							pauseSignatureApplySettings();
1181
+			}
1140 1182
 		}
1141 1183
 		$settings_applied = true;
1142 1184
 	}
@@ -1154,8 +1196,9 @@  discard block
 block discarded – undo
1154 1196
 	);
1155 1197
 
1156 1198
 	// Temporarily make each setting a modSetting!
1157
-	foreach ($context['signature_settings'] as $key => $value)
1158
-		$modSettings['signature_' . $key] = $value;
1199
+	foreach ($context['signature_settings'] as $key => $value) {
1200
+			$modSettings['signature_' . $key] = $value;
1201
+	}
1159 1202
 
1160 1203
 	// Make sure we check the right tags!
1161 1204
 	$modSettings['bbc_disabled_signature_bbc'] = $disabledTags;
@@ -1167,23 +1210,26 @@  discard block
 block discarded – undo
1167 1210
 
1168 1211
 		// Clean up the tag stuff!
1169 1212
 		$bbcTags = array();
1170
-		foreach (parse_bbc(false) as $tag)
1171
-			$bbcTags[] = $tag['tag'];
1213
+		foreach (parse_bbc(false) as $tag) {
1214
+					$bbcTags[] = $tag['tag'];
1215
+		}
1172 1216
 
1173
-		if (!isset($_POST['signature_bbc_enabledTags']))
1174
-			$_POST['signature_bbc_enabledTags'] = array();
1175
-		elseif (!is_array($_POST['signature_bbc_enabledTags']))
1176
-			$_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']);
1217
+		if (!isset($_POST['signature_bbc_enabledTags'])) {
1218
+					$_POST['signature_bbc_enabledTags'] = array();
1219
+		} elseif (!is_array($_POST['signature_bbc_enabledTags'])) {
1220
+					$_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']);
1221
+		}
1177 1222
 
1178 1223
 		$sig_limits = array();
1179 1224
 		foreach ($context['signature_settings'] as $key => $value)
1180 1225
 		{
1181
-			if ($key == 'allow_smileys')
1182
-				continue;
1183
-			elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys']))
1184
-				$sig_limits[] = -1;
1185
-			else
1186
-				$sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0;
1226
+			if ($key == 'allow_smileys') {
1227
+							continue;
1228
+			} elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys'])) {
1229
+							$sig_limits[] = -1;
1230
+			} else {
1231
+							$sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0;
1232
+			}
1187 1233
 		}
1188 1234
 
1189 1235
 		call_integration_hook('integrate_save_signature_settings', array(&$sig_limits, &$bbcTags));
@@ -1216,12 +1262,14 @@  discard block
 block discarded – undo
1216 1262
 
1217 1263
 	// Try get more time...
1218 1264
 	@set_time_limit(600);
1219
-	if (function_exists('apache_reset_timeout'))
1220
-		@apache_reset_timeout();
1265
+	if (function_exists('apache_reset_timeout')) {
1266
+			@apache_reset_timeout();
1267
+	}
1221 1268
 
1222 1269
 	// Have we exhausted all the time we allowed?
1223
-	if (time() - array_sum(explode(' ', $sig_start)) < 3)
1224
-		return;
1270
+	if (time() - array_sum(explode(' ', $sig_start)) < 3) {
1271
+			return;
1272
+	}
1225 1273
 
1226 1274
 	$context['continue_get_data'] = '?action=admin;area=featuresettings;sa=sig;apply;step=' . $_GET['step'] . ';' . $context['session_var'] . '=' . $context['session_id'];
1227 1275
 	$context['page_title'] = $txt['not_done_title'];
@@ -1267,9 +1315,10 @@  discard block
 block discarded – undo
1267 1315
 		$disable_fields = array_flip($standard_fields);
1268 1316
 		if (!empty($_POST['active']))
1269 1317
 		{
1270
-			foreach ($_POST['active'] as $value)
1271
-				if (isset($disable_fields[$value]))
1318
+			foreach ($_POST['active'] as $value) {
1319
+							if (isset($disable_fields[$value]))
1272 1320
 					unset($disable_fields[$value]);
1321
+			}
1273 1322
 		}
1274 1323
 		// What we have left!
1275 1324
 		$changes['disabled_profile_fields'] = empty($disable_fields) ? '' : implode(',', array_keys($disable_fields));
@@ -1278,16 +1327,18 @@  discard block
 block discarded – undo
1278 1327
 		$reg_fields = array();
1279 1328
 		if (!empty($_POST['reg']))
1280 1329
 		{
1281
-			foreach ($_POST['reg'] as $value)
1282
-				if (in_array($value, $standard_fields) && !isset($disable_fields[$value]))
1330
+			foreach ($_POST['reg'] as $value) {
1331
+							if (in_array($value, $standard_fields) && !isset($disable_fields[$value]))
1283 1332
 					$reg_fields[] = $value;
1333
+			}
1284 1334
 		}
1285 1335
 		// What we have left!
1286 1336
 		$changes['registration_fields'] = empty($reg_fields) ? '' : implode(',', $reg_fields);
1287 1337
 
1288 1338
 		$_SESSION['adm-save'] = true;
1289
-		if (!empty($changes))
1290
-			updateSettings($changes);
1339
+		if (!empty($changes)) {
1340
+					updateSettings($changes);
1341
+		}
1291 1342
 	}
1292 1343
 
1293 1344
 	createToken('admin-scp');
@@ -1390,11 +1441,13 @@  discard block
 block discarded – undo
1390 1441
 					{
1391 1442
 						$return = '<p class="centertext bold_text">'. $rowData['field_order'] .'<br />';
1392 1443
 
1393
-						if ($rowData['field_order'] > 1)
1394
-							$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>';
1444
+						if ($rowData['field_order'] > 1) {
1445
+													$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>';
1446
+						}
1395 1447
 
1396
-						if ($rowData['field_order'] < $context['custFieldsMaxOrder'])
1397
-							$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>';
1448
+						if ($rowData['field_order'] < $context['custFieldsMaxOrder']) {
1449
+													$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>';
1450
+						}
1398 1451
 
1399 1452
 						$return .= '</p>';
1400 1453
 
@@ -1532,16 +1585,16 @@  discard block
 block discarded – undo
1532 1585
 		$disabled_fields = isset($modSettings['disabled_profile_fields']) ? explode(',', $modSettings['disabled_profile_fields']) : array();
1533 1586
 		$registration_fields = isset($modSettings['registration_fields']) ? explode(',', $modSettings['registration_fields']) : array();
1534 1587
 
1535
-		foreach ($standard_fields as $field)
1536
-			$list[] = array(
1588
+		foreach ($standard_fields as $field) {
1589
+					$list[] = array(
1537 1590
 				'id' => $field,
1538 1591
 				'label' => isset($txt['standard_profile_field_' . $field]) ? $txt['standard_profile_field_' . $field] : (isset($txt[$field]) ? $txt[$field] : $field),
1539 1592
 				'disabled' => in_array($field, $disabled_fields),
1540 1593
 				'on_register' => in_array($field, $registration_fields) && !in_array($field, $fields_no_registration),
1541 1594
 				'can_show_register' => !in_array($field, $fields_no_registration),
1542 1595
 			);
1543
-	}
1544
-	else
1596
+		}
1597
+	} else
1545 1598
 	{
1546 1599
 		// Load all the fields.
1547 1600
 		$request = $smcFunc['db_query']('', '
@@ -1555,8 +1608,9 @@  discard block
 block discarded – undo
1555 1608
 				'items_per_page' => $items_per_page,
1556 1609
 			)
1557 1610
 		);
1558
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1559
-			$list[] = $row;
1611
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1612
+					$list[] = $row;
1613
+		}
1560 1614
 		$smcFunc['db_free_result']($request);
1561 1615
 	}
1562 1616
 
@@ -1622,9 +1676,9 @@  discard block
 block discarded – undo
1622 1676
 		$context['field'] = array();
1623 1677
 		while ($row = $smcFunc['db_fetch_assoc']($request))
1624 1678
 		{
1625
-			if ($row['field_type'] == 'textarea')
1626
-				@list ($rows, $cols) = @explode(',', $row['default_value']);
1627
-			else
1679
+			if ($row['field_type'] == 'textarea') {
1680
+							@list ($rows, $cols) = @explode(',', $row['default_value']);
1681
+			} else
1628 1682
 			{
1629 1683
 				$rows = 3;
1630 1684
 				$cols = 30;
@@ -1660,8 +1714,8 @@  discard block
 block discarded – undo
1660 1714
 	}
1661 1715
 
1662 1716
 	// Setup the default values as needed.
1663
-	if (empty($context['field']))
1664
-		$context['field'] = array(
1717
+	if (empty($context['field'])) {
1718
+			$context['field'] = array(
1665 1719
 			'name' => '',
1666 1720
 			'col_name' => '???',
1667 1721
 			'desc' => '',
@@ -1686,6 +1740,7 @@  discard block
 block discarded – undo
1686 1740
 			'enclose' => '',
1687 1741
 			'placement' => 0,
1688 1742
 		);
1743
+	}
1689 1744
 
1690 1745
 	// Are we moving it?
1691 1746
 	if (isset($_GET['move']) && in_array($smcFunc['htmlspecialchars']($_GET['move']), $move_to))
@@ -1694,8 +1749,10 @@  discard block
 block discarded – undo
1694 1749
 		$new_order = ($_GET['move'] == 'up' ? ($context['field']['order'] - 1) : ($context['field']['order'] + 1));
1695 1750
 
1696 1751
 		// Is this a valid position?
1697
-		if ($new_order <= 0 || $new_order > $order_count)
1698
-			redirectexit('action=admin;area=featuresettings;sa=profile'); // @todo implement an error handler
1752
+		if ($new_order <= 0 || $new_order > $order_count) {
1753
+					redirectexit('action=admin;area=featuresettings;sa=profile');
1754
+		}
1755
+		// @todo implement an error handler
1699 1756
 
1700 1757
 		// All good, proceed.
1701 1758
 		$smcFunc['db_query']('','
@@ -1726,12 +1783,14 @@  discard block
 block discarded – undo
1726 1783
 		validateToken('admin-ecp');
1727 1784
 
1728 1785
 		// Everyone needs a name - even the (bracket) unknown...
1729
-		if (trim($_POST['field_name']) == '')
1730
-			redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name');
1786
+		if (trim($_POST['field_name']) == '') {
1787
+					redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name');
1788
+		}
1731 1789
 
1732 1790
 		// Regex you say?  Do a very basic test to see if the pattern is valid
1733
-		if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false)
1734
-			redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error');
1791
+		if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false) {
1792
+					redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error');
1793
+		}
1735 1794
 
1736 1795
 		$_POST['field_name'] = $smcFunc['htmlspecialchars']($_POST['field_name']);
1737 1796
 		$_POST['field_desc'] = $smcFunc['htmlspecialchars']($_POST['field_desc']);
@@ -1748,8 +1807,9 @@  discard block
 block discarded – undo
1748 1807
 
1749 1808
 		// Some masking stuff...
1750 1809
 		$mask = isset($_POST['mask']) ? $_POST['mask'] : '';
1751
-		if ($mask == 'regex' && isset($_POST['regex']))
1752
-			$mask .= $_POST['regex'];
1810
+		if ($mask == 'regex' && isset($_POST['regex'])) {
1811
+					$mask .= $_POST['regex'];
1812
+		}
1753 1813
 
1754 1814
 		$field_length = isset($_POST['max_length']) ? (int) $_POST['max_length'] : 255;
1755 1815
 		$enclose = isset($_POST['enclose']) ? $_POST['enclose'] : '';
@@ -1768,8 +1828,9 @@  discard block
 block discarded – undo
1768 1828
 				$v = strtr($v, array(',' => ''));
1769 1829
 
1770 1830
 				// Nada, zip, etc...
1771
-				if (trim($v) == '')
1772
-					continue;
1831
+				if (trim($v) == '') {
1832
+									continue;
1833
+				}
1773 1834
 
1774 1835
 				// Otherwise, save it boy.
1775 1836
 				$field_options .= $v . ',';
@@ -1777,15 +1838,17 @@  discard block
 block discarded – undo
1777 1838
 				$newOptions[$k] = $v;
1778 1839
 
1779 1840
 				// Is it default?
1780
-				if (isset($_POST['default_select']) && $_POST['default_select'] == $k)
1781
-					$default = $v;
1841
+				if (isset($_POST['default_select']) && $_POST['default_select'] == $k) {
1842
+									$default = $v;
1843
+				}
1782 1844
 			}
1783 1845
 			$field_options = substr($field_options, 0, -1);
1784 1846
 		}
1785 1847
 
1786 1848
 		// Text area has default has dimensions
1787
-		if ($_POST['field_type'] == 'textarea')
1788
-			$default = (int) $_POST['rows'] . ',' . (int) $_POST['cols'];
1849
+		if ($_POST['field_type'] == 'textarea') {
1850
+					$default = (int) $_POST['rows'] . ',' . (int) $_POST['cols'];
1851
+		}
1789 1852
 
1790 1853
 		// Come up with the unique name?
1791 1854
 		if (empty($context['fid']))
@@ -1794,32 +1857,36 @@  discard block
 block discarded – undo
1794 1857
 			preg_match('~([\w\d_-]+)~', $col_name, $matches);
1795 1858
 
1796 1859
 			// If there is nothing to the name, then let's start out own - for foreign languages etc.
1797
-			if (isset($matches[1]))
1798
-				$col_name = $initial_col_name = 'cust_' . strtolower($matches[1]);
1799
-			else
1800
-				$col_name = $initial_col_name = 'cust_' . mt_rand(1, 9999);
1860
+			if (isset($matches[1])) {
1861
+							$col_name = $initial_col_name = 'cust_' . strtolower($matches[1]);
1862
+			} else {
1863
+							$col_name = $initial_col_name = 'cust_' . mt_rand(1, 9999);
1864
+			}
1801 1865
 
1802 1866
 			// Make sure this is unique.
1803 1867
 			$current_fields = array();
1804 1868
 			$request = $smcFunc['db_query']('', '
1805 1869
 				SELECT id_field, col_name
1806 1870
 				FROM {db_prefix}custom_fields');
1807
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1808
-				$current_fields[$row['id_field']] = $row['col_name'];
1871
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
1872
+							$current_fields[$row['id_field']] = $row['col_name'];
1873
+			}
1809 1874
 			$smcFunc['db_free_result']($request);
1810 1875
 
1811 1876
 			$unique = false;
1812 1877
 			for ($i = 0; !$unique && $i < 9; $i ++)
1813 1878
 			{
1814
-				if (!in_array($col_name, $current_fields))
1815
-					$unique = true;
1816
-				else
1817
-					$col_name = $initial_col_name . $i;
1879
+				if (!in_array($col_name, $current_fields)) {
1880
+									$unique = true;
1881
+				} else {
1882
+									$col_name = $initial_col_name . $i;
1883
+				}
1818 1884
 			}
1819 1885
 
1820 1886
 			// Still not a unique column name? Leave it up to the user, then.
1821
-			if (!$unique)
1822
-				fatal_lang_error('custom_option_not_unique');
1887
+			if (!$unique) {
1888
+							fatal_lang_error('custom_option_not_unique');
1889
+			}
1823 1890
 		}
1824 1891
 		// Work out what to do with the user data otherwise...
1825 1892
 		else
@@ -1847,8 +1914,9 @@  discard block
 block discarded – undo
1847 1914
 				// Work out what's changed!
1848 1915
 				foreach ($context['field']['options'] as $k => $option)
1849 1916
 				{
1850
-					if (trim($option) == '')
1851
-						continue;
1917
+					if (trim($option) == '') {
1918
+											continue;
1919
+					}
1852 1920
 
1853 1921
 					// Still exists?
1854 1922
 					if (in_array($option, $newOptions))
@@ -1862,8 +1930,8 @@  discard block
 block discarded – undo
1862 1930
 				foreach ($optionChanges as $k => $option)
1863 1931
 				{
1864 1932
 					// Just been renamed?
1865
-					if (!in_array($k, $takenKeys) && !empty($newOptions[$k]))
1866
-						$smcFunc['db_query']('', '
1933
+					if (!in_array($k, $takenKeys) && !empty($newOptions[$k])) {
1934
+											$smcFunc['db_query']('', '
1867 1935
 							UPDATE {db_prefix}themes
1868 1936
 							SET value = {string:new_value}
1869 1937
 							WHERE variable = {string:current_column}
@@ -1876,6 +1944,7 @@  discard block
 block discarded – undo
1876 1944
 								'old_value' => $option,
1877 1945
 							)
1878 1946
 						);
1947
+					}
1879 1948
 				}
1880 1949
 			}
1881 1950
 			// @todo Maybe we should adjust based on new text length limits?
@@ -1918,8 +1987,8 @@  discard block
 block discarded – undo
1918 1987
 			);
1919 1988
 
1920 1989
 			// Just clean up any old selects - these are a pain!
1921
-			if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions))
1922
-				$smcFunc['db_query']('', '
1990
+			if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions)) {
1991
+							$smcFunc['db_query']('', '
1923 1992
 					DELETE FROM {db_prefix}themes
1924 1993
 					WHERE variable = {string:current_column}
1925 1994
 						AND value NOT IN ({array_string:new_option_values})
@@ -1930,8 +1999,8 @@  discard block
 block discarded – undo
1930 1999
 						'current_column' => $context['field']['col_name'],
1931 2000
 					)
1932 2001
 				);
1933
-		}
1934
-		else
2002
+			}
2003
+		} else
1935 2004
 		{
1936 2005
 			// Gotta figure it out the order.
1937 2006
 			$new_order = $order_count > 1 ? ($order_count + 1) : 1;
@@ -2105,11 +2174,13 @@  discard block
 block discarded – undo
2105 2174
 	call_integration_hook('integrate_prune_settings', array(&$config_vars, &$prune_toggle, false));
2106 2175
 
2107 2176
 	$prune_toggle_dt = array();
2108
-	foreach ($prune_toggle as $item)
2109
-		$prune_toggle_dt[] = 'setting_' . $item;
2177
+	foreach ($prune_toggle as $item) {
2178
+			$prune_toggle_dt[] = 'setting_' . $item;
2179
+	}
2110 2180
 
2111
-	if ($return_config)
2112
-		return $config_vars;
2181
+	if ($return_config) {
2182
+			return $config_vars;
2183
+	}
2113 2184
 
2114 2185
 	addInlineJavaScript('
2115 2186
 	function togglePruned()
@@ -2147,15 +2218,16 @@  discard block
 block discarded – undo
2147 2218
 			$vals = array();
2148 2219
 			foreach ($config_vars as $index => $dummy)
2149 2220
 			{
2150
-				if (!is_array($dummy) || $index == 'pruningOptions' || !in_array($dummy[1], $prune_toggle))
2151
-					continue;
2221
+				if (!is_array($dummy) || $index == 'pruningOptions' || !in_array($dummy[1], $prune_toggle)) {
2222
+									continue;
2223
+				}
2152 2224
 
2153 2225
 				$vals[] = empty($_POST[$dummy[1]]) || $_POST[$dummy[1]] < 0 ? 0 : (int) $_POST[$dummy[1]];
2154 2226
 			}
2155 2227
 			$_POST['pruningOptions'] = implode(',', $vals);
2228
+		} else {
2229
+					$_POST['pruningOptions'] = '';
2156 2230
 		}
2157
-		else
2158
-			$_POST['pruningOptions'] = '';
2159 2231
 
2160 2232
 		saveDBSettings($savevar);
2161 2233
 		$_SESSION['adm-save'] = true;
@@ -2167,10 +2239,11 @@  discard block
 block discarded – undo
2167 2239
 	$context['sub_template'] = 'show_settings';
2168 2240
 
2169 2241
 	// Get the actual values
2170
-	if (!empty($modSettings['pruningOptions']))
2171
-		@list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']);
2172
-	else
2173
-		$modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0;
2242
+	if (!empty($modSettings['pruningOptions'])) {
2243
+			@list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']);
2244
+	} else {
2245
+			$modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0;
2246
+	}
2174 2247
 
2175 2248
 	prepareDBSettingContext($config_vars);
2176 2249
 }
@@ -2192,8 +2265,9 @@  discard block
 block discarded – undo
2192 2265
 	// Make it even easier to add new settings.
2193 2266
 	call_integration_hook('integrate_general_mod_settings', array(&$config_vars));
2194 2267
 
2195
-	if ($return_config)
2196
-		return $config_vars;
2268
+	if ($return_config) {
2269
+			return $config_vars;
2270
+	}
2197 2271
 
2198 2272
 	$context['post_url'] = $scripturl . '?action=admin;area=modsettings;save;sa=general';
2199 2273
 	$context['settings_title'] = $txt['mods_cat_modifications_misc'];
Please login to merge, or discard this patch.
Sources/ManageErrors.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -42,42 +42,42 @@  discard block
 block discarded – undo
42 42
 
43 43
 	// You can filter by any of the following columns:
44 44
 	$filters = array(
45
-		'id_member' => array (
45
+		'id_member' => array(
46 46
 			'txt' => $txt['username'],
47 47
 			'operator' => '=',
48 48
 			'datatype' => 'int',
49 49
 		),
50
-		'ip' => array (
50
+		'ip' => array(
51 51
 			'txt' => $txt['ip_address'],
52 52
 			'operator' => '=',
53 53
 			'datatype' => 'inet',
54 54
 		),
55
-		'session' => array (
55
+		'session' => array(
56 56
 			'txt' => $txt['session'],
57 57
 			'operator' => 'LIKE',
58 58
 			'datatype' => 'string',
59 59
 		),
60
-		'url' => array (
60
+		'url' => array(
61 61
 			'txt' => $txt['error_url'],
62 62
 			'operator' => 'LIKE',
63 63
 			'datatype' => 'string',
64 64
 		),
65
-		'message' => array (
65
+		'message' => array(
66 66
 			'txt' => $txt['error_message'],
67 67
 			'operator' => 'LIKE',
68 68
 			'datatype' => 'string',
69 69
 		),
70
-		'error_type' => array (
70
+		'error_type' => array(
71 71
 			'txt' => $txt['error_type'],
72 72
 			'operator' => 'LIKE',
73 73
 			'datatype' => 'string',
74 74
 		),
75
-		'file' => array (
75
+		'file' => array(
76 76
 			'txt' => $txt['file'],
77 77
 			'operator' => 'LIKE',
78 78
 			'datatype' => 'string',
79 79
 		),
80
-		'line' => array (
80
+		'line' => array(
81 81
 			'txt' => $txt['line'],
82 82
 			'operator' => '=',
83 83
 			'datatype' => 'int',
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 	$result = $smcFunc['db_query']('', '
104 104
 		SELECT COUNT(*)
105 105
 		FROM {db_prefix}log_errors' . (isset($filter) ? '
106
-		WHERE ' . $filter['variable'] . ' '.$filters[$_GET['filter']]['operator'].' {'.$filters[$_GET['filter']]['datatype'].':filter}' : ''),
106
+		WHERE ' . $filter['variable'] . ' ' . $filters[$_GET['filter']]['operator'] . ' {' . $filters[$_GET['filter']]['datatype'] . ':filter}' : ''),
107 107
 		array(
108 108
 			'filter' => isset($filter) ? $filter['value']['sql'] : '',
109 109
 		)
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 	$request = $smcFunc['db_query']('', '
147 147
 		SELECT id_error, id_member, ip, url, log_time, message, session, error_type, file, line
148 148
 		FROM {db_prefix}log_errors' . (isset($filter) ? '
149
-		WHERE ' . $filter['variable'] . ' '.$filters[$_GET['filter']]['operator'].' {'.$filters[$_GET['filter']]['datatype'].':filter}' : '') . '
149
+		WHERE ' . $filter['variable'] . ' ' . $filters[$_GET['filter']]['operator'] . ' {' . $filters[$_GET['filter']]['datatype'] . ':filter}' : '') . '
150 150
 		ORDER BY id_error ' . ($context['sort_direction'] == 'down' ? 'DESC' : '') . '
151 151
 		LIMIT {int:start}, {int:max}',
152 152
 		array(
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 	$context['errors'] = array();
159 159
 	$members = array();
160 160
 
161
-	for ($i = 0; $row = $smcFunc['db_fetch_assoc']($request); $i ++)
161
+	for ($i = 0; $row = $smcFunc['db_fetch_assoc']($request); $i++)
162 162
 	{
163 163
 		$search_message = preg_replace('~&lt;span class=&quot;remove&quot;&gt;(.+?)&lt;/span&gt;~', '%', $smcFunc['db_escape_wildcard_string']($row['message']));
164 164
 		if ($search_message == $filter['value']['sql'])
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 			'id' => $row['id_error'],
185 185
 			'error_type' => array(
186 186
 				'type' => $row['error_type'],
187
-				'name' => isset($txt['errortype_'.$row['error_type']]) ? $txt['errortype_'.$row['error_type']] : $row['error_type'],
187
+				'name' => isset($txt['errortype_' . $row['error_type']]) ? $txt['errortype_' . $row['error_type']] : $row['error_type'],
188 188
 			),
189 189
 			'file' => array(),
190 190
 		);
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
 	// We don't want to slice off too many so lets make sure we stop at the last one
413 413
 	$max = min($max, max(array_keys($file_data)));
414 414
 
415
-	$file_data = array_slice($file_data, $min-1, $max - $min);
415
+	$file_data = array_slice($file_data, $min - 1, $max - $min);
416 416
 
417 417
 	$context['file_data'] = array(
418 418
 		'contents' => $file_data,
Please login to merge, or discard this 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/Search.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
 
660 660
 	// Remove the phrase parts and extract the words.
661 661
 	$wordArray = preg_replace('~(?:^|\s)(?:[-]?)"(?:[^"]+)"(?:$|\s)~' . ($context['utf8'] ? 'u' : ''), ' ', $search_params['search']);
662
-	$wordArray = explode(' ',  $smcFunc['htmlspecialchars'](un_htmlspecialchars($wordArray), ENT_QUOTES));
662
+	$wordArray = explode(' ', $smcFunc['htmlspecialchars'](un_htmlspecialchars($wordArray), ENT_QUOTES));
663 663
 
664 664
 	// A minus sign in front of a word excludes the word.... so...
665 665
 	$excludedWords = array();
@@ -1104,7 +1104,7 @@  discard block
 block discarded – undo
1104 1104
 						SELECT
1105 1105
 							{int:id_search},
1106 1106
 							t.id_topic,
1107
-							' . $relevance. ',
1107
+							' . $relevance . ',
1108 1108
 							' . (empty($userQuery) ? 't.id_first_msg' : 'm.id_msg') . ',
1109 1109
 							1
1110 1110
 						FROM ' . $subject_query['from'] . (empty($subject_query['inner_join']) ? '' : '
@@ -1339,7 +1339,7 @@  discard block
 block discarded – undo
1339 1339
 						if (empty($subject_query['where']))
1340 1340
 							continue;
1341 1341
 
1342
-						$ignoreRequest = $smcFunc['db_search_query']('insert_log_search_topics', ($smcFunc['db_support_ignore'] ? ( '
1342
+						$ignoreRequest = $smcFunc['db_search_query']('insert_log_search_topics', ($smcFunc['db_support_ignore'] ? ('
1343 1343
 							INSERT IGNORE INTO {db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_topics
1344 1344
 								(' . ($createTemporary ? '' : 'id_search, ') . 'id_topic)') : '') . '
1345 1345
 							SELECT ' . ($createTemporary ? '' : $_SESSION['search_cache']['id_search'] . ', ') . 't.id_topic
@@ -1568,7 +1568,7 @@  discard block
 block discarded – undo
1568 1568
 					}
1569 1569
 					$main_query['select']['relevance'] = substr($relevance, 0, -3) . ') / ' . $new_weight_total . ' AS relevance';
1570 1570
 
1571
-					$ignoreRequest = $smcFunc['db_search_query']('insert_log_search_results_no_index', ($smcFunc['db_support_ignore'] ? ( '
1571
+					$ignoreRequest = $smcFunc['db_search_query']('insert_log_search_results_no_index', ($smcFunc['db_support_ignore'] ? ('
1572 1572
 						INSERT IGNORE INTO ' . '{db_prefix}log_search_results
1573 1573
 							(' . implode(', ', array_keys($main_query['select'])) . ')') : '') . '
1574 1574
 						SELECT
@@ -1636,7 +1636,7 @@  discard block
 block discarded – undo
1636 1636
 					$relevance = substr($relevance, 0, -3) . ') / ' . $weight_total . ' AS relevance';
1637 1637
 
1638 1638
 					$usedIDs = array_flip(empty($inserts) ? array() : array_keys($inserts));
1639
-					$ignoreRequest = $smcFunc['db_search_query']('insert_log_search_results_sub_only', ($smcFunc['db_support_ignore'] ? ( '
1639
+					$ignoreRequest = $smcFunc['db_search_query']('insert_log_search_results_sub_only', ($smcFunc['db_support_ignore'] ? ('
1640 1640
 						INSERT IGNORE INTO {db_prefix}log_search_results
1641 1641
 							(id_search, id_topic, relevance, id_msg, num_matches)') : '') . '
1642 1642
 						SELECT
@@ -2102,7 +2102,7 @@  discard block
 block discarded – undo
2102 2102
 		$query = trim($query, "\*+");
2103 2103
 		$query = strtr($smcFunc['htmlspecialchars']($query), array('\\\'' => '\''));
2104 2104
 
2105
-		$body_highlighted = preg_replace_callback('/((<[^>]*)|' . preg_quote(strtr($query, array('\'' => '&#039;')), '/') . ')/i' . ($context['utf8'] ? 'u' : ''), function ($m)
2105
+		$body_highlighted = preg_replace_callback('/((<[^>]*)|' . preg_quote(strtr($query, array('\'' => '&#039;')), '/') . ')/i' . ($context['utf8'] ? 'u' : ''), function($m)
2106 2106
 		{
2107 2107
 			return isset($m[2]) && "$m[2]" == "$m[1]" ? stripslashes("$m[1]") : "<strong class=\"highlight\">$m[1]</strong>";
2108 2108
 		}, $body_highlighted);
Please login to merge, or discard this patch.
Braces   +416 added lines, -309 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
 // This defines two version types for checking the API's are compatible with this version of SMF.
20 21
 $GLOBALS['search_versions'] = array(
@@ -39,8 +40,9 @@  discard block
 block discarded – undo
39 40
 	global $txt, $scripturl, $modSettings, $user_info, $context, $smcFunc, $sourcedir;
40 41
 
41 42
 	// Is the load average too high to allow searching just now?
42
-	if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search'])
43
-		fatal_lang_error('loadavg_search_disabled', false);
43
+	if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) {
44
+			fatal_lang_error('loadavg_search_disabled', false);
45
+	}
44 46
 
45 47
 	loadLanguage('Search');
46 48
 	// Don't load this in XML mode.
@@ -88,23 +90,30 @@  discard block
 block discarded – undo
88 90
 			@list ($k, $v) = explode('|\'|', $data);
89 91
 			$context['search_params'][$k] = $v;
90 92
 		}
91
-		if (isset($context['search_params']['brd']))
92
-			$context['search_params']['brd'] = $context['search_params']['brd'] == '' ? array() : explode(',', $context['search_params']['brd']);
93
+		if (isset($context['search_params']['brd'])) {
94
+					$context['search_params']['brd'] = $context['search_params']['brd'] == '' ? array() : explode(',', $context['search_params']['brd']);
95
+		}
93 96
 	}
94 97
 
95
-	if (isset($_REQUEST['search']))
96
-		$context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']);
98
+	if (isset($_REQUEST['search'])) {
99
+			$context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']);
100
+	}
97 101
 
98
-	if (isset($context['search_params']['search']))
99
-		$context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']);
100
-	if (isset($context['search_params']['userspec']))
101
-		$context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']);
102
-	if (!empty($context['search_params']['searchtype']))
103
-		$context['search_params']['searchtype'] = 2;
104
-	if (!empty($context['search_params']['minage']))
105
-		$context['search_params']['minage'] = (int) $context['search_params']['minage'];
106
-	if (!empty($context['search_params']['maxage']))
107
-		$context['search_params']['maxage'] = (int) $context['search_params']['maxage'];
102
+	if (isset($context['search_params']['search'])) {
103
+			$context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']);
104
+	}
105
+	if (isset($context['search_params']['userspec'])) {
106
+			$context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']);
107
+	}
108
+	if (!empty($context['search_params']['searchtype'])) {
109
+			$context['search_params']['searchtype'] = 2;
110
+	}
111
+	if (!empty($context['search_params']['minage'])) {
112
+			$context['search_params']['minage'] = (int) $context['search_params']['minage'];
113
+	}
114
+	if (!empty($context['search_params']['maxage'])) {
115
+			$context['search_params']['maxage'] = (int) $context['search_params']['maxage'];
116
+	}
108 117
 
109 118
 	$context['search_params']['show_complete'] = !empty($context['search_params']['show_complete']);
110 119
 	$context['search_params']['subject_only'] = !empty($context['search_params']['subject_only']);
@@ -116,11 +125,13 @@  discard block
 block discarded – undo
116 125
 		$context['search_errors']['messages'] = array();
117 126
 		foreach ($context['search_errors'] as $search_error => $dummy)
118 127
 		{
119
-			if ($search_error === 'messages')
120
-				continue;
128
+			if ($search_error === 'messages') {
129
+							continue;
130
+			}
121 131
 
122
-			if ($search_error == 'string_too_long')
123
-				$txt['error_string_too_long'] = sprintf($txt['error_string_too_long'], $context['search_string_limit']);
132
+			if ($search_error == 'string_too_long') {
133
+							$txt['error_string_too_long'] = sprintf($txt['error_string_too_long'], $context['search_string_limit']);
134
+			}
124 135
 
125 136
 			$context['search_errors']['messages'][] = $txt['error_' . $search_error];
126 137
 		}
@@ -143,12 +154,13 @@  discard block
 block discarded – undo
143 154
 	while ($row = $smcFunc['db_fetch_assoc']($request))
144 155
 	{
145 156
 		// This category hasn't been set up yet..
146
-		if (!isset($context['categories'][$row['id_cat']]))
147
-			$context['categories'][$row['id_cat']] = array(
157
+		if (!isset($context['categories'][$row['id_cat']])) {
158
+					$context['categories'][$row['id_cat']] = array(
148 159
 				'id' => $row['id_cat'],
149 160
 				'name' => $row['cat_name'],
150 161
 				'boards' => array()
151 162
 			);
163
+		}
152 164
 
153 165
 		// Set this board up, and let the template know when it's a child.  (indent them..)
154 166
 		$context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array(
@@ -159,8 +171,9 @@  discard block
 block discarded – undo
159 171
 		);
160 172
 
161 173
 		// If a board wasn't checked that probably should have been ensure the board selection is selected, yo!
162
-		if (!$context['categories'][$row['id_cat']]['boards'][$row['id_board']]['selected'] && (empty($modSettings['recycle_enable']) || $row['id_board'] != $modSettings['recycle_board']))
163
-			$context['boards_check_all'] = false;
174
+		if (!$context['categories'][$row['id_cat']]['boards'][$row['id_board']]['selected'] && (empty($modSettings['recycle_enable']) || $row['id_board'] != $modSettings['recycle_board'])) {
175
+					$context['boards_check_all'] = false;
176
+		}
164 177
 	}
165 178
 	$smcFunc['db_free_result']($request);
166 179
 
@@ -182,18 +195,20 @@  discard block
 block discarded – undo
182 195
 	}
183 196
 
184 197
 	$max_boards = ceil(count($temp_boards) / 2);
185
-	if ($max_boards == 1)
186
-		$max_boards = 2;
198
+	if ($max_boards == 1) {
199
+			$max_boards = 2;
200
+	}
187 201
 
188 202
 	// Now, alternate them so they can be shown left and right ;).
189 203
 	$context['board_columns'] = array();
190 204
 	for ($i = 0; $i < $max_boards; $i++)
191 205
 	{
192 206
 		$context['board_columns'][] = $temp_boards[$i];
193
-		if (isset($temp_boards[$i + $max_boards]))
194
-			$context['board_columns'][] = $temp_boards[$i + $max_boards];
195
-		else
196
-			$context['board_columns'][] = array();
207
+		if (isset($temp_boards[$i + $max_boards])) {
208
+					$context['board_columns'][] = $temp_boards[$i + $max_boards];
209
+		} else {
210
+					$context['board_columns'][] = array();
211
+		}
197 212
 	}
198 213
 
199 214
 	if (!empty($_REQUEST['topic']))
@@ -225,8 +240,9 @@  discard block
 block discarded – undo
225 240
 			)
226 241
 		);
227 242
 
228
-		if ($smcFunc['db_num_rows']($request) == 0)
229
-			fatal_lang_error('topic_gone', false);
243
+		if ($smcFunc['db_num_rows']($request) == 0) {
244
+					fatal_lang_error('topic_gone', false);
245
+		}
230 246
 
231 247
 		list ($context['search_topic']['subject']) = $smcFunc['db_fetch_row']($request);
232 248
 		$smcFunc['db_free_result']($request);
@@ -256,11 +272,13 @@  discard block
 block discarded – undo
256 272
 	global $excludedWords, $participants, $smcFunc;
257 273
 
258 274
 	// if comming from the quick search box, and we want to search on members, well we need to do that ;)
259
-	if (isset($_REQUEST['search_selection']) && $_REQUEST['search_selection'] === 'members')
260
-		redirectexit($scripturl . '?action=mlist;sa=search;fields=name,email;search=' . urlencode($_REQUEST['search']));
275
+	if (isset($_REQUEST['search_selection']) && $_REQUEST['search_selection'] === 'members') {
276
+			redirectexit($scripturl . '?action=mlist;sa=search;fields=name,email;search=' . urlencode($_REQUEST['search']));
277
+	}
261 278
 
262
-	if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search'])
263
-		fatal_lang_error('loadavg_search_disabled', false);
279
+	if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) {
280
+			fatal_lang_error('loadavg_search_disabled', false);
281
+	}
264 282
 
265 283
 	// No, no, no... this is a bit hard on the server, so don't you go prefetching it!
266 284
 	if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch')
@@ -307,8 +325,9 @@  discard block
 block discarded – undo
307 325
 	}
308 326
 
309 327
 	// Zero weight.  Weightless :P.
310
-	if (empty($weight_total))
311
-		fatal_lang_error('search_invalid_weights');
328
+	if (empty($weight_total)) {
329
+			fatal_lang_error('search_invalid_weights');
330
+	}
312 331
 
313 332
 	// These vars don't require an interface, they're just here for tweaking.
314 333
 	$recentPercentage = 0.30;
@@ -326,11 +345,13 @@  discard block
 block discarded – undo
326 345
 	$context['search_string_limit'] = 100;
327 346
 
328 347
 	loadLanguage('Search');
329
-	if (!isset($_REQUEST['xml']))
330
-		loadTemplate('Search');
348
+	if (!isset($_REQUEST['xml'])) {
349
+			loadTemplate('Search');
350
+	}
331 351
 	//If we're doing XML we need to use the results template regardless really.
332
-	else
333
-		$context['sub_template'] = 'results';
352
+	else {
353
+			$context['sub_template'] = 'results';
354
+	}
334 355
 
335 356
 	// Are you allowed?
336 357
 	isAllowedTo('search_posts');
@@ -363,34 +384,39 @@  discard block
 block discarded – undo
363 384
 			$search_params[$k] = $v;
364 385
 		}
365 386
 
366
-		if (isset($search_params['brd']))
367
-			$search_params['brd'] = empty($search_params['brd']) ? array() : explode(',', $search_params['brd']);
387
+		if (isset($search_params['brd'])) {
388
+					$search_params['brd'] = empty($search_params['brd']) ? array() : explode(',', $search_params['brd']);
389
+		}
368 390
 	}
369 391
 
370 392
 	// Store whether simple search was used (needed if the user wants to do another query).
371
-	if (!isset($search_params['advanced']))
372
-		$search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1;
393
+	if (!isset($search_params['advanced'])) {
394
+			$search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1;
395
+	}
373 396
 
374 397
 	// 1 => 'allwords' (default, don't set as param) / 2 => 'anywords'.
375
-	if (!empty($search_params['searchtype']) || (!empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2))
376
-		$search_params['searchtype'] = 2;
398
+	if (!empty($search_params['searchtype']) || (!empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2)) {
399
+			$search_params['searchtype'] = 2;
400
+	}
377 401
 
378 402
 	// Minimum age of messages. Default to zero (don't set param in that case).
379
-	if (!empty($search_params['minage']) || (!empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0))
380
-		$search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage'];
403
+	if (!empty($search_params['minage']) || (!empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0)) {
404
+			$search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage'];
405
+	}
381 406
 
382 407
 	// Maximum age of messages. Default to infinite (9999 days: param not set).
383
-	if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] < 9999))
384
-		$search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage'];
408
+	if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] < 9999)) {
409
+			$search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage'];
410
+	}
385 411
 
386 412
 	// Searching a specific topic?
387 413
 	if (!empty($_REQUEST['topic']) || (!empty($_REQUEST['search_selection']) && $_REQUEST['search_selection'] == 'topic'))
388 414
 	{
389 415
 		$search_params['topic'] = empty($_REQUEST['search_selection']) ? (int) $_REQUEST['topic'] : (isset($_REQUEST['sd_topic']) ? (int) $_REQUEST['sd_topic'] : '');
390 416
 		$search_params['show_complete'] = true;
417
+	} elseif (!empty($search_params['topic'])) {
418
+			$search_params['topic'] = (int) $search_params['topic'];
391 419
 	}
392
-	elseif (!empty($search_params['topic']))
393
-		$search_params['topic'] = (int) $search_params['topic'];
394 420
 
395 421
 	if (!empty($search_params['minage']) || !empty($search_params['maxage']))
396 422
 	{
@@ -408,19 +434,21 @@  discard block
 block discarded – undo
408 434
 			)
409 435
 		);
410 436
 		list ($minMsgID, $maxMsgID) = $smcFunc['db_fetch_row']($request);
411
-		if ($minMsgID < 0 || $maxMsgID < 0)
412
-			$context['search_errors']['no_messages_in_time_frame'] = true;
437
+		if ($minMsgID < 0 || $maxMsgID < 0) {
438
+					$context['search_errors']['no_messages_in_time_frame'] = true;
439
+		}
413 440
 		$smcFunc['db_free_result']($request);
414 441
 	}
415 442
 
416 443
 	// Default the user name to a wildcard matching every user (*).
417
-	if (!empty($search_params['userspec']) || (!empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*'))
418
-		$search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec'];
444
+	if (!empty($search_params['userspec']) || (!empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*')) {
445
+			$search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec'];
446
+	}
419 447
 
420 448
 	// If there's no specific user, then don't mention it in the main query.
421
-	if (empty($search_params['userspec']))
422
-		$userQuery = '';
423
-	else
449
+	if (empty($search_params['userspec'])) {
450
+			$userQuery = '';
451
+	} else
424 452
 	{
425 453
 		$userString = strtr($smcFunc['htmlspecialchars']($search_params['userspec'], ENT_QUOTES), array('&quot;' => '"'));
426 454
 		$userString = strtr($userString, array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_'));
@@ -432,19 +460,21 @@  discard block
 block discarded – undo
432 460
 		{
433 461
 			$possible_users[$k] = trim($possible_users[$k]);
434 462
 
435
-			if (strlen($possible_users[$k]) == 0)
436
-				unset($possible_users[$k]);
463
+			if (strlen($possible_users[$k]) == 0) {
464
+							unset($possible_users[$k]);
465
+			}
437 466
 		}
438 467
 
439 468
 		// Create a list of database-escaped search names.
440 469
 		$realNameMatches = array();
441
-		foreach ($possible_users as $possible_user)
442
-			$realNameMatches[] = $smcFunc['db_quote'](
470
+		foreach ($possible_users as $possible_user) {
471
+					$realNameMatches[] = $smcFunc['db_quote'](
443 472
 				'{string:possible_user}',
444 473
 				array(
445 474
 					'possible_user' => $possible_user
446 475
 				)
447 476
 			);
477
+		}
448 478
 
449 479
 		// Retrieve a list of possible members.
450 480
 		$request = $smcFunc['db_query']('', '
@@ -456,9 +486,9 @@  discard block
 block discarded – undo
456 486
 			)
457 487
 		);
458 488
 		// Simply do nothing if there're too many members matching the criteria.
459
-		if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch)
460
-			$userQuery = '';
461
-		elseif ($smcFunc['db_num_rows']($request) == 0)
489
+		if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch) {
490
+					$userQuery = '';
491
+		} elseif ($smcFunc['db_num_rows']($request) == 0)
462 492
 		{
463 493
 			$userQuery = $smcFunc['db_quote'](
464 494
 				'm.id_member = {int:id_member_guest} AND ({raw:match_possible_guest_names})',
@@ -467,12 +497,12 @@  discard block
 block discarded – undo
467 497
 					'match_possible_guest_names' => 'm.poster_name LIKE ' . implode(' OR m.poster_name LIKE ', $realNameMatches),
468 498
 				)
469 499
 			);
470
-		}
471
-		else
500
+		} else
472 501
 		{
473 502
 			$memberlist = array();
474
-			while ($row = $smcFunc['db_fetch_assoc']($request))
475
-				$memberlist[] = $row['id_member'];
503
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
504
+							$memberlist[] = $row['id_member'];
505
+			}
476 506
 			$userQuery = $smcFunc['db_quote'](
477 507
 				'(m.id_member IN ({array_int:matched_members}) OR (m.id_member = {int:id_member_guest} AND ({raw:match_possible_guest_names})))',
478 508
 				array(
@@ -486,22 +516,25 @@  discard block
 block discarded – undo
486 516
 	}
487 517
 
488 518
 	// If the boards were passed by URL (params=), temporarily put them back in $_REQUEST.
489
-	if (!empty($search_params['brd']) && is_array($search_params['brd']))
490
-		$_REQUEST['brd'] = $search_params['brd'];
519
+	if (!empty($search_params['brd']) && is_array($search_params['brd'])) {
520
+			$_REQUEST['brd'] = $search_params['brd'];
521
+	}
491 522
 
492 523
 	// Ensure that brd is an array.
493 524
 	if ((!empty($_REQUEST['brd']) && !is_array($_REQUEST['brd'])) || (!empty($_REQUEST['search_selection']) && $_REQUEST['search_selection'] == 'board'))
494 525
 	{
495
-		if (!empty($_REQUEST['brd']))
496
-			$_REQUEST['brd'] = strpos($_REQUEST['brd'], ',') !== false ? explode(',', $_REQUEST['brd']) : array($_REQUEST['brd']);
497
-		else
498
-			$_REQUEST['brd'] = isset($_REQUEST['sd_brd']) ? array($_REQUEST['sd_brd']) : array();
526
+		if (!empty($_REQUEST['brd'])) {
527
+					$_REQUEST['brd'] = strpos($_REQUEST['brd'], ',') !== false ? explode(',', $_REQUEST['brd']) : array($_REQUEST['brd']);
528
+		} else {
529
+					$_REQUEST['brd'] = isset($_REQUEST['sd_brd']) ? array($_REQUEST['sd_brd']) : array();
530
+		}
499 531
 	}
500 532
 
501 533
 	// Make sure all boards are integers.
502
-	if (!empty($_REQUEST['brd']))
503
-		foreach ($_REQUEST['brd'] as $id => $brd)
534
+	if (!empty($_REQUEST['brd'])) {
535
+			foreach ($_REQUEST['brd'] as $id => $brd)
504 536
 			$_REQUEST['brd'][$id] = (int) $brd;
537
+	}
505 538
 
506 539
 	// Special case for boards: searching just one topic?
507 540
 	if (!empty($search_params['topic']))
@@ -520,17 +553,18 @@  discard block
 block discarded – undo
520 553
 			)
521 554
 		);
522 555
 
523
-		if ($smcFunc['db_num_rows']($request) == 0)
524
-			fatal_lang_error('topic_gone', false);
556
+		if ($smcFunc['db_num_rows']($request) == 0) {
557
+					fatal_lang_error('topic_gone', false);
558
+		}
525 559
 
526 560
 		$search_params['brd'] = array();
527 561
 		list ($search_params['brd'][0]) = $smcFunc['db_fetch_row']($request);
528 562
 		$smcFunc['db_free_result']($request);
529 563
 	}
530 564
 	// Select all boards you've selected AND are allowed to see.
531
-	elseif ($user_info['is_admin'] && (!empty($search_params['advanced']) || !empty($_REQUEST['brd'])))
532
-		$search_params['brd'] = empty($_REQUEST['brd']) ? array() : $_REQUEST['brd'];
533
-	else
565
+	elseif ($user_info['is_admin'] && (!empty($search_params['advanced']) || !empty($_REQUEST['brd']))) {
566
+			$search_params['brd'] = empty($_REQUEST['brd']) ? array() : $_REQUEST['brd'];
567
+	} else
534 568
 	{
535 569
 		$see_board = empty($search_params['advanced']) ? 'query_wanna_see_board' : 'query_see_board';
536 570
 		$request = $smcFunc['db_query']('', '
@@ -548,19 +582,22 @@  discard block
 block discarded – undo
548 582
 			)
549 583
 		);
550 584
 		$search_params['brd'] = array();
551
-		while ($row = $smcFunc['db_fetch_assoc']($request))
552
-			$search_params['brd'][] = $row['id_board'];
585
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
586
+					$search_params['brd'][] = $row['id_board'];
587
+		}
553 588
 		$smcFunc['db_free_result']($request);
554 589
 
555 590
 		// This error should pro'bly only happen for hackers.
556
-		if (empty($search_params['brd']))
557
-			$context['search_errors']['no_boards_selected'] = true;
591
+		if (empty($search_params['brd'])) {
592
+					$context['search_errors']['no_boards_selected'] = true;
593
+		}
558 594
 	}
559 595
 
560 596
 	if (count($search_params['brd']) != 0)
561 597
 	{
562
-		foreach ($search_params['brd'] as $k => $v)
563
-			$search_params['brd'][$k] = (int) $v;
598
+		foreach ($search_params['brd'] as $k => $v) {
599
+					$search_params['brd'][$k] = (int) $v;
600
+		}
564 601
 
565 602
 		// If we've selected all boards, this parameter can be left empty.
566 603
 		$request = $smcFunc['db_query']('', '
@@ -574,15 +611,16 @@  discard block
 block discarded – undo
574 611
 		list ($num_boards) = $smcFunc['db_fetch_row']($request);
575 612
 		$smcFunc['db_free_result']($request);
576 613
 
577
-		if (count($search_params['brd']) == $num_boards)
614
+		if (count($search_params['brd']) == $num_boards) {
615
+					$boardQuery = '';
616
+		} elseif (count($search_params['brd']) == $num_boards - 1 && !empty($modSettings['recycle_board']) && !in_array($modSettings['recycle_board'], $search_params['brd'])) {
617
+					$boardQuery = '!= ' . $modSettings['recycle_board'];
618
+		} else {
619
+					$boardQuery = 'IN (' . implode(', ', $search_params['brd']) . ')';
620
+		}
621
+	} else {
578 622
 			$boardQuery = '';
579
-		elseif (count($search_params['brd']) == $num_boards - 1 && !empty($modSettings['recycle_board']) && !in_array($modSettings['recycle_board'], $search_params['brd']))
580
-			$boardQuery = '!= ' . $modSettings['recycle_board'];
581
-		else
582
-			$boardQuery = 'IN (' . implode(', ', $search_params['brd']) . ')';
583 623
 	}
584
-	else
585
-		$boardQuery = '';
586 624
 
587 625
 	$search_params['show_complete'] = !empty($search_params['show_complete']) || !empty($_REQUEST['show_complete']);
588 626
 	$search_params['subject_only'] = !empty($search_params['subject_only']) || !empty($_REQUEST['subject_only']);
@@ -596,11 +634,13 @@  discard block
 block discarded – undo
596 634
 		'id_msg',
597 635
 	);
598 636
 	call_integration_hook('integrate_search_sort_columns', array(&$sort_columns));
599
-	if (empty($search_params['sort']) && !empty($_REQUEST['sort']))
600
-		list ($search_params['sort'], $search_params['sort_dir']) = array_pad(explode('|', $_REQUEST['sort']), 2, '');
637
+	if (empty($search_params['sort']) && !empty($_REQUEST['sort'])) {
638
+			list ($search_params['sort'], $search_params['sort_dir']) = array_pad(explode('|', $_REQUEST['sort']), 2, '');
639
+	}
601 640
 	$search_params['sort'] = !empty($search_params['sort']) && in_array($search_params['sort'], $sort_columns) ? $search_params['sort'] : 'relevance';
602
-	if (!empty($search_params['topic']) && $search_params['sort'] === 'num_replies')
603
-		$search_params['sort'] = 'id_msg';
641
+	if (!empty($search_params['topic']) && $search_params['sort'] === 'num_replies') {
642
+			$search_params['sort'] = 'id_msg';
643
+	}
604 644
 
605 645
 	// Sorting direction: descending unless stated otherwise.
606 646
 	$search_params['sort_dir'] = !empty($search_params['sort_dir']) && $search_params['sort_dir'] == 'asc' ? 'asc' : 'desc';
@@ -624,17 +664,19 @@  discard block
 block discarded – undo
624 664
 	// What are we searching for?
625 665
 	if (empty($search_params['search']))
626 666
 	{
627
-		if (isset($_GET['search']))
628
-			$search_params['search'] = un_htmlspecialchars($_GET['search']);
629
-		elseif (isset($_POST['search']))
630
-			$search_params['search'] = $_POST['search'];
631
-		else
632
-			$search_params['search'] = '';
667
+		if (isset($_GET['search'])) {
668
+					$search_params['search'] = un_htmlspecialchars($_GET['search']);
669
+		} elseif (isset($_POST['search'])) {
670
+					$search_params['search'] = $_POST['search'];
671
+		} else {
672
+					$search_params['search'] = '';
673
+		}
633 674
 	}
634 675
 
635 676
 	// Nothing??
636
-	if (!isset($search_params['search']) || $search_params['search'] == '')
637
-		$context['search_errors']['invalid_search_string'] = true;
677
+	if (!isset($search_params['search']) || $search_params['search'] == '') {
678
+			$context['search_errors']['invalid_search_string'] = true;
679
+	}
638 680
 	// Too long?
639 681
 	elseif ($smcFunc['strlen']($search_params['search']) > $context['search_string_limit'])
640 682
 	{
@@ -648,8 +690,9 @@  discard block
 block discarded – undo
648 690
 	$stripped_query = un_htmlspecialchars($smcFunc['strtolower']($stripped_query));
649 691
 
650 692
 	// This (hidden) setting will do fulltext searching in the most basic way.
651
-	if (!empty($modSettings['search_simple_fulltext']))
652
-		$stripped_query = strtr($stripped_query, array('"' => ''));
693
+	if (!empty($modSettings['search_simple_fulltext'])) {
694
+			$stripped_query = strtr($stripped_query, array('"' => ''));
695
+	}
653 696
 
654 697
 	$no_regexp = preg_match('~&#(?:\d{1,7}|x[0-9a-fA-F]{1,6});~', $stripped_query) === 1;
655 698
 
@@ -672,8 +715,9 @@  discard block
 block discarded – undo
672 715
 	{
673 716
 		if ($word === '-')
674 717
 		{
675
-			if (($word = trim($phraseArray[$index], '-_\' ')) !== '' && !in_array($word, $blacklisted_words))
676
-				$excludedWords[] = $word;
718
+			if (($word = trim($phraseArray[$index], '-_\' ')) !== '' && !in_array($word, $blacklisted_words)) {
719
+							$excludedWords[] = $word;
720
+			}
677 721
 			unset($phraseArray[$index]);
678 722
 		}
679 723
 	}
@@ -683,8 +727,9 @@  discard block
 block discarded – undo
683 727
 	{
684 728
 		if (strpos(trim($word), '-') === 0)
685 729
 		{
686
-			if (($word = trim($word, '-_\' ')) !== '' && !in_array($word, $blacklisted_words))
687
-				$excludedWords[] = $word;
730
+			if (($word = trim($word, '-_\' ')) !== '' && !in_array($word, $blacklisted_words)) {
731
+							$excludedWords[] = $word;
732
+			}
688 733
 			unset($wordArray[$index]);
689 734
 		}
690 735
 	}
@@ -697,8 +742,9 @@  discard block
 block discarded – undo
697 742
 	foreach ($searchArray as $index => $value)
698 743
 	{
699 744
 		// Skip anything practically empty.
700
-		if (($searchArray[$index] = trim($value, '-_\' ')) === '')
701
-			unset($searchArray[$index]);
745
+		if (($searchArray[$index] = trim($value, '-_\' ')) === '') {
746
+					unset($searchArray[$index]);
747
+		}
702 748
 		// Skip blacklisted words. Make sure to note we skipped them in case we end up with nothing.
703 749
 		elseif (in_array($searchArray[$index], $blacklisted_words))
704 750
 		{
@@ -710,39 +756,45 @@  discard block
 block discarded – undo
710 756
 		{
711 757
 			$context['search_ignored'][] = $value;
712 758
 			unset($searchArray[$index]);
759
+		} else {
760
+					$searchArray[$index] = $searchArray[$index];
713 761
 		}
714
-		else
715
-			$searchArray[$index] = $searchArray[$index];
716 762
 	}
717 763
 	$searchArray = array_slice(array_unique($searchArray), 0, 10);
718 764
 
719 765
 	// Create an array of replacements for highlighting.
720 766
 	$context['mark'] = array();
721
-	foreach ($searchArray as $word)
722
-		$context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>';
767
+	foreach ($searchArray as $word) {
768
+			$context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>';
769
+	}
723 770
 
724 771
 	// Initialize two arrays storing the words that have to be searched for.
725 772
 	$orParts = array();
726 773
 	$searchWords = array();
727 774
 
728 775
 	// Make sure at least one word is being searched for.
729
-	if (empty($searchArray))
730
-		$context['search_errors']['invalid_search_string' . (!empty($foundBlackListedWords) ? '_blacklist' : '')] = true;
776
+	if (empty($searchArray)) {
777
+			$context['search_errors']['invalid_search_string' . (!empty($foundBlackListedWords) ? '_blacklist' : '')] = true;
778
+	}
731 779
 	// All words/sentences must match.
732
-	elseif (empty($search_params['searchtype']))
733
-		$orParts[0] = $searchArray;
780
+	elseif (empty($search_params['searchtype'])) {
781
+			$orParts[0] = $searchArray;
782
+	}
734 783
 	// Any word/sentence must match.
735
-	else
736
-		foreach ($searchArray as $index => $value)
784
+	else {
785
+			foreach ($searchArray as $index => $value)
737 786
 			$orParts[$index] = array($value);
787
+	}
738 788
 
739 789
 	// Don't allow duplicate error messages if one string is too short.
740
-	if (isset($context['search_errors']['search_string_small_words'], $context['search_errors']['invalid_search_string']))
741
-		unset($context['search_errors']['invalid_search_string']);
790
+	if (isset($context['search_errors']['search_string_small_words'], $context['search_errors']['invalid_search_string'])) {
791
+			unset($context['search_errors']['invalid_search_string']);
792
+	}
742 793
 	// Make sure the excluded words are in all or-branches.
743
-	foreach ($orParts as $orIndex => $andParts)
744
-		foreach ($excludedWords as $word)
794
+	foreach ($orParts as $orIndex => $andParts) {
795
+			foreach ($excludedWords as $word)
745 796
 			$orParts[$orIndex][] = $word;
797
+	}
746 798
 
747 799
 	// Determine the or-branches and the fulltext search words.
748 800
 	foreach ($orParts as $orIndex => $andParts)
@@ -756,8 +808,9 @@  discard block
 block discarded – undo
756 808
 		);
757 809
 
758 810
 		// Sort the indexed words (large words -> small words -> excluded words).
759
-		if ($searchAPI->supportsMethod('searchSort'))
760
-			usort($orParts[$orIndex], 'searchSort');
811
+		if ($searchAPI->supportsMethod('searchSort')) {
812
+					usort($orParts[$orIndex], 'searchSort');
813
+		}
761 814
 
762 815
 		foreach ($orParts[$orIndex] as $word)
763 816
 		{
@@ -769,15 +822,17 @@  discard block
 block discarded – undo
769 822
 			if (!$is_excluded || count($subjectWords) === 1)
770 823
 			{
771 824
 				$searchWords[$orIndex]['subject_words'] = array_merge($searchWords[$orIndex]['subject_words'], $subjectWords);
772
-				if ($is_excluded)
773
-					$excludedSubjectWords = array_merge($excludedSubjectWords, $subjectWords);
825
+				if ($is_excluded) {
826
+									$excludedSubjectWords = array_merge($excludedSubjectWords, $subjectWords);
827
+				}
828
+			} else {
829
+							$excludedPhrases[] = $word;
774 830
 			}
775
-			else
776
-				$excludedPhrases[] = $word;
777 831
 
778 832
 			// Have we got indexes to prepare?
779
-			if ($searchAPI->supportsMethod('prepareIndexes'))
780
-				$searchAPI->prepareIndexes($word, $searchWords[$orIndex], $excludedIndexWords, $is_excluded);
833
+			if ($searchAPI->supportsMethod('prepareIndexes')) {
834
+							$searchAPI->prepareIndexes($word, $searchWords[$orIndex], $excludedIndexWords, $is_excluded);
835
+			}
781 836
 		}
782 837
 
783 838
 		// Search_force_index requires all AND parts to have at least one fulltext word.
@@ -785,8 +840,7 @@  discard block
 block discarded – undo
785 840
 		{
786 841
 			$context['search_errors']['query_not_specific_enough'] = true;
787 842
 			break;
788
-		}
789
-		elseif ($search_params['subject_only'] && empty($searchWords[$orIndex]['subject_words']) && empty($excludedSubjectWords))
843
+		} elseif ($search_params['subject_only'] && empty($searchWords[$orIndex]['subject_words']) && empty($excludedSubjectWords))
790 844
 		{
791 845
 			$context['search_errors']['query_not_specific_enough'] = true;
792 846
 			break;
@@ -814,8 +868,9 @@  discard block
 block discarded – undo
814 868
 		$found_misspelling = false;
815 869
 		foreach ($searchArray as $word)
816 870
 		{
817
-			if (empty($link))
818
-				continue;
871
+			if (empty($link)) {
872
+							continue;
873
+			}
819 874
 
820 875
 			// Don't check phrases.
821 876
 			if (preg_match('~^\w+$~', $word) === 0)
@@ -830,8 +885,7 @@  discard block
 block discarded – undo
830 885
 				$did_you_mean['search'][] = $word;
831 886
 				$did_you_mean['display'][] = $smcFunc['htmlspecialchars']($word);
832 887
 				continue;
833
-			}
834
-			elseif (spell_check($link, $word))
888
+			} elseif (spell_check($link, $word))
835 889
 			{
836 890
 				$did_you_mean['search'][] = $word;
837 891
 				$did_you_mean['display'][] = $smcFunc['htmlspecialchars']($word);
@@ -842,11 +896,13 @@  discard block
 block discarded – undo
842 896
 			foreach ($suggestions as $i => $s)
843 897
 			{
844 898
 				// Search is case insensitive.
845
-				if ($smcFunc['strtolower']($s) == $smcFunc['strtolower']($word))
846
-					unset($suggestions[$i]);
899
+				if ($smcFunc['strtolower']($s) == $smcFunc['strtolower']($word)) {
900
+									unset($suggestions[$i]);
901
+				}
847 902
 				// Plus, don't suggest something the user thinks is rude!
848
-				elseif ($suggestions[$i] != censorText($s))
849
-					unset($suggestions[$i]);
903
+				elseif ($suggestions[$i] != censorText($s)) {
904
+									unset($suggestions[$i]);
905
+				}
850 906
 			}
851 907
 
852 908
 			// Anything found?  If so, correct it!
@@ -856,8 +912,7 @@  discard block
 block discarded – undo
856 912
 				$did_you_mean['search'][] = $suggestions[0];
857 913
 				$did_you_mean['display'][] = '<em><strong>' . $smcFunc['htmlspecialchars']($suggestions[0]) . '</strong></em>';
858 914
 				$found_misspelling = true;
859
-			}
860
-			else
915
+			} else
861 916
 			{
862 917
 				$did_you_mean['search'][] = $word;
863 918
 				$did_you_mean['display'][] = $smcFunc['htmlspecialchars']($word);
@@ -874,8 +929,7 @@  discard block
 block discarded – undo
874 929
 				{
875 930
 					$temp_excluded['search'][] = '-"' . $word . '"';
876 931
 					$temp_excluded['display'][] = '-&quot;' . $smcFunc['htmlspecialchars']($word) . '&quot;';
877
-				}
878
-				else
932
+				} else
879 933
 				{
880 934
 					$temp_excluded['search'][] = '-' . $word;
881 935
 					$temp_excluded['display'][] = '-' . $smcFunc['htmlspecialchars']($word);
@@ -887,11 +941,13 @@  discard block
 block discarded – undo
887 941
 
888 942
 			$temp_params = $search_params;
889 943
 			$temp_params['search'] = implode(' ', $did_you_mean['search']);
890
-			if (isset($temp_params['brd']))
891
-				$temp_params['brd'] = implode(',', $temp_params['brd']);
944
+			if (isset($temp_params['brd'])) {
945
+							$temp_params['brd'] = implode(',', $temp_params['brd']);
946
+			}
892 947
 			$context['params'] = array();
893
-			foreach ($temp_params as $k => $v)
894
-				$context['did_you_mean_params'][] = $k . '|\'|' . $v;
948
+			foreach ($temp_params as $k => $v) {
949
+							$context['did_you_mean_params'][] = $k . '|\'|' . $v;
950
+			}
895 951
 			$context['did_you_mean_params'] = base64_encode(implode('|"|', $context['did_you_mean_params']));
896 952
 			$context['did_you_mean'] = implode(' ', $did_you_mean['display']);
897 953
 		}
@@ -899,18 +955,20 @@  discard block
 block discarded – undo
899 955
 
900 956
 	// Let the user adjust the search query, should they wish?
901 957
 	$context['search_params'] = $search_params;
902
-	if (isset($context['search_params']['search']))
903
-		$context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']);
904
-	if (isset($context['search_params']['userspec']))
905
-		$context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']);
958
+	if (isset($context['search_params']['search'])) {
959
+			$context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']);
960
+	}
961
+	if (isset($context['search_params']['userspec'])) {
962
+			$context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']);
963
+	}
906 964
 
907 965
 	// Do we have captcha enabled?
908 966
 	if ($user_info['is_guest'] && !empty($modSettings['search_enable_captcha']) && empty($_SESSION['ss_vv_passed']) && (empty($_SESSION['last_ss']) || $_SESSION['last_ss'] != $search_params['search']))
909 967
 	{
910 968
 		// If we come from another search box tone down the error...
911
-		if (!isset($_REQUEST['search_vv']))
912
-			$context['search_errors']['need_verification_code'] = true;
913
-		else
969
+		if (!isset($_REQUEST['search_vv'])) {
970
+					$context['search_errors']['need_verification_code'] = true;
971
+		} else
914 972
 		{
915 973
 			require_once($sourcedir . '/Subs-Editor.php');
916 974
 			$verificationOptions = array(
@@ -920,12 +978,14 @@  discard block
 block discarded – undo
920 978
 
921 979
 			if (is_array($context['require_verification']))
922 980
 			{
923
-				foreach ($context['require_verification'] as $error)
924
-					$context['search_errors'][$error] = true;
981
+				foreach ($context['require_verification'] as $error) {
982
+									$context['search_errors'][$error] = true;
983
+				}
925 984
 			}
926 985
 			// Don't keep asking for it - they've proven themselves worthy.
927
-			else
928
-				$_SESSION['ss_vv_passed'] = true;
986
+			else {
987
+							$_SESSION['ss_vv_passed'] = true;
988
+			}
929 989
 		}
930 990
 	}
931 991
 
@@ -933,19 +993,22 @@  discard block
 block discarded – undo
933 993
 
934 994
 	// All search params have been checked, let's compile them to a single string... made less simple by PHP 4.3.9 and below.
935 995
 	$temp_params = $search_params;
936
-	if (isset($temp_params['brd']))
937
-		$temp_params['brd'] = implode(',', $temp_params['brd']);
996
+	if (isset($temp_params['brd'])) {
997
+			$temp_params['brd'] = implode(',', $temp_params['brd']);
998
+	}
938 999
 	$context['params'] = array();
939
-	foreach ($temp_params as $k => $v)
940
-		$context['params'][] = $k . '|\'|' . $v;
1000
+	foreach ($temp_params as $k => $v) {
1001
+			$context['params'][] = $k . '|\'|' . $v;
1002
+	}
941 1003
 
942 1004
 	if (!empty($context['params']))
943 1005
 	{
944 1006
 		// Due to old IE's 2083 character limit, we have to compress long search strings
945 1007
 		$params = @gzcompress(implode('|"|', $context['params']));
946 1008
 		// Gzcompress failed, use try non-gz
947
-		if (empty($params))
948
-			$params = implode('|"|', $context['params']);
1009
+		if (empty($params)) {
1010
+					$params = implode('|"|', $context['params']);
1011
+		}
949 1012
 		// Base64 encode, then replace +/= with uri safe ones that can be reverted
950 1013
 		$context['params'] = str_replace(array('+', '/', '='), array('-', '_', '.'), base64_encode($params));
951 1014
 	}
@@ -971,8 +1034,9 @@  discard block
 block discarded – undo
971 1034
 	}
972 1035
 
973 1036
 	// Spam me not, Spam-a-lot?
974
-	if (empty($_SESSION['last_ss']) || $_SESSION['last_ss'] != $search_params['search'])
975
-		spamProtection('search');
1037
+	if (empty($_SESSION['last_ss']) || $_SESSION['last_ss'] != $search_params['search']) {
1038
+			spamProtection('search');
1039
+	}
976 1040
 	// Store the last search string to allow pages of results to be browsed.
977 1041
 	$_SESSION['last_ss'] = $search_params['search'];
978 1042
 
@@ -1032,8 +1096,9 @@  discard block
 block discarded – undo
1032 1096
 						'where' => array(),
1033 1097
 					);
1034 1098
 
1035
-					if ($modSettings['postmod_active'])
1036
-						$subject_query['where'][] = 't.approved = {int:is_approved}';
1099
+					if ($modSettings['postmod_active']) {
1100
+											$subject_query['where'][] = 't.approved = {int:is_approved}';
1101
+					}
1037 1102
 
1038 1103
 					$numTables = 0;
1039 1104
 					$prev_join = 0;
@@ -1045,8 +1110,7 @@  discard block
 block discarded – undo
1045 1110
 						{
1046 1111
 							$subject_query['left_join'][] = '{db_prefix}log_search_subjects AS subj' . $numTables . ' ON (subj' . $numTables . '.word ' . (empty($modSettings['search_match_words']) ? 'LIKE {string:subject_words_' . $numTables . '_wild}' : '= {string:subject_words_' . $numTables . '}') . ' AND subj' . $numTables . '.id_topic = t.id_topic)';
1047 1112
 							$subject_query['where'][] = '(subj' . $numTables . '.word IS NULL)';
1048
-						}
1049
-						else
1113
+						} else
1050 1114
 						{
1051 1115
 							$subject_query['inner_join'][] = '{db_prefix}log_search_subjects AS subj' . $numTables . ' ON (subj' . $numTables . '.id_topic = ' . ($prev_join === 0 ? 't' : 'subj' . $prev_join) . '.id_topic)';
1052 1116
 							$subject_query['where'][] = 'subj' . $numTables . '.word ' . (empty($modSettings['search_match_words']) ? 'LIKE {string:subject_words_' . $numTables . '_wild}' : '= {string:subject_words_' . $numTables . '}');
@@ -1064,14 +1128,18 @@  discard block
 block discarded – undo
1064 1128
 						}
1065 1129
 						$subject_query['where'][] = $userQuery;
1066 1130
 					}
1067
-					if (!empty($search_params['topic']))
1068
-						$subject_query['where'][] = 't.id_topic = ' . $search_params['topic'];
1069
-					if (!empty($minMsgID))
1070
-						$subject_query['where'][] = 't.id_first_msg >= ' . $minMsgID;
1071
-					if (!empty($maxMsgID))
1072
-						$subject_query['where'][] = 't.id_last_msg <= ' . $maxMsgID;
1073
-					if (!empty($boardQuery))
1074
-						$subject_query['where'][] = 't.id_board ' . $boardQuery;
1131
+					if (!empty($search_params['topic'])) {
1132
+											$subject_query['where'][] = 't.id_topic = ' . $search_params['topic'];
1133
+					}
1134
+					if (!empty($minMsgID)) {
1135
+											$subject_query['where'][] = 't.id_first_msg >= ' . $minMsgID;
1136
+					}
1137
+					if (!empty($maxMsgID)) {
1138
+											$subject_query['where'][] = 't.id_last_msg <= ' . $maxMsgID;
1139
+					}
1140
+					if (!empty($boardQuery)) {
1141
+											$subject_query['where'][] = 't.id_board ' . $boardQuery;
1142
+					}
1075 1143
 					if (!empty($excludedPhrases))
1076 1144
 					{
1077 1145
 						if ($subject_query['from'] != '{db_prefix}messages AS m')
@@ -1091,8 +1159,9 @@  discard block
 block discarded – undo
1091 1159
 					foreach ($weight_factors as $type => $value)
1092 1160
 					{
1093 1161
 						$relevance .= $weight[$type];
1094
-						if (!empty($value['results']))
1095
-							$relevance .= ' * ' . $value['results'];
1162
+						if (!empty($value['results'])) {
1163
+													$relevance .= ' * ' . $value['results'];
1164
+						}
1096 1165
 						$relevance .= ' + ';
1097 1166
 					}
1098 1167
 					$relevance = substr($relevance, 0, -3) . ') / ' . $weight_total . ' AS relevance';
@@ -1130,20 +1199,23 @@  discard block
 block discarded – undo
1130 1199
 						while ($row = $smcFunc['db_fetch_row']($ignoreRequest))
1131 1200
 						{
1132 1201
 							// No duplicates!
1133
-							if (isset($inserts[$row[1]]))
1134
-								continue;
1202
+							if (isset($inserts[$row[1]])) {
1203
+															continue;
1204
+							}
1135 1205
 
1136
-							foreach ($row as $key => $value)
1137
-								$inserts[$row[1]][] = (int) $row[$key];
1206
+							foreach ($row as $key => $value) {
1207
+															$inserts[$row[1]][] = (int) $row[$key];
1208
+							}
1138 1209
 						}
1139 1210
 						$smcFunc['db_free_result']($ignoreRequest);
1140 1211
 						$numSubjectResults = count($inserts);
1212
+					} else {
1213
+											$numSubjectResults += $smcFunc['db_affected_rows']();
1141 1214
 					}
1142
-					else
1143
-						$numSubjectResults += $smcFunc['db_affected_rows']();
1144 1215
 
1145
-					if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results'])
1146
-						break;
1216
+					if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results']) {
1217
+											break;
1218
+					}
1147 1219
 				}
1148 1220
 
1149 1221
 				// If there's data to be inserted for non-IGNORE databases do it here!
@@ -1158,8 +1230,7 @@  discard block
 block discarded – undo
1158 1230
 				}
1159 1231
 
1160 1232
 				$_SESSION['search_cache']['num_results'] = $numSubjectResults;
1161
-			}
1162
-			else
1233
+			} else
1163 1234
 			{
1164 1235
 				$main_query = array(
1165 1236
 					'select' => array(
@@ -1191,8 +1262,7 @@  discard block
 block discarded – undo
1191 1262
 					$main_query['weights'] = $weight_factors;
1192 1263
 
1193 1264
 					$main_query['group_by'][] = 't.id_topic';
1194
-				}
1195
-				else
1265
+				} else
1196 1266
 				{
1197 1267
 					// This is outrageous!
1198 1268
 					$main_query['select']['id_topic'] = 'm.id_msg AS id_topic';
@@ -1213,8 +1283,9 @@  discard block
 block discarded – undo
1213 1283
 						$main_query['where'][] = 't.id_topic = {int:topic}';
1214 1284
 						$main_query['parameters']['topic'] = $search_params['topic'];
1215 1285
 					}
1216
-					if (!empty($search_params['show_complete']))
1217
-						$main_query['group_by'][] = 'm.id_msg, t.id_first_msg, t.id_last_msg';
1286
+					if (!empty($search_params['show_complete'])) {
1287
+											$main_query['group_by'][] = 'm.id_msg, t.id_first_msg, t.id_last_msg';
1288
+					}
1218 1289
 				}
1219 1290
 
1220 1291
 				// *** Get the subject results.
@@ -1241,14 +1312,15 @@  discard block
 block discarded – undo
1241 1312
 					) !== false;
1242 1313
 
1243 1314
 					// Clean up some previous cache.
1244
-					if (!$createTemporary)
1245
-						$smcFunc['db_search_query']('delete_log_search_topics', '
1315
+					if (!$createTemporary) {
1316
+											$smcFunc['db_search_query']('delete_log_search_topics', '
1246 1317
 							DELETE FROM {db_prefix}log_search_topics
1247 1318
 							WHERE id_search = {int:search_id}',
1248 1319
 							array(
1249 1320
 								'search_id' => $_SESSION['search_cache']['id_search'],
1250 1321
 							)
1251 1322
 						);
1323
+					}
1252 1324
 
1253 1325
 					foreach ($searchWords as $orIndex => $words)
1254 1326
 					{
@@ -1280,8 +1352,7 @@  discard block
 block discarded – undo
1280 1352
 								$subject_query['where'][] = '(subj' . $numTables . '.word IS NULL)';
1281 1353
 								$subject_query['where'][] = 'm.body NOT ' . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:body_not_' . $count . '}';
1282 1354
 								$subject_query['params']['body_not_' . $count++] = empty($modSettings['search_match_words']) || $no_regexp ? '%' . strtr($subjectWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $subjectWord), '\\\'') . '[[:>:]]';
1283
-							}
1284
-							else
1355
+							} else
1285 1356
 							{
1286 1357
 								$subject_query['inner_join'][] = '{db_prefix}log_search_subjects AS subj' . $numTables . ' ON (subj' . $numTables . '.id_topic = ' . ($prev_join === 0 ? 't' : 'subj' . $prev_join) . '.id_topic)';
1287 1358
 								$subject_query['where'][] = 'subj' . $numTables . '.word LIKE {string:subject_like_' . $count . '}';
@@ -1336,8 +1407,9 @@  discard block
 block discarded – undo
1336 1407
 						call_integration_hook('integrate_subject_search_query', array(&$subject_query));
1337 1408
 
1338 1409
 						// Nothing to search for?
1339
-						if (empty($subject_query['where']))
1340
-							continue;
1410
+						if (empty($subject_query['where'])) {
1411
+													continue;
1412
+						}
1341 1413
 
1342 1414
 						$ignoreRequest = $smcFunc['db_search_query']('insert_log_search_topics', ($smcFunc['db_support_ignore'] ? ( '
1343 1415
 							INSERT IGNORE INTO {db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_topics
@@ -1360,19 +1432,21 @@  discard block
 block discarded – undo
1360 1432
 							{
1361 1433
 								$ind = $createTemporary ? 0 : 1;
1362 1434
 								// No duplicates!
1363
-								if (isset($inserts[$row[$ind]]))
1364
-									continue;
1435
+								if (isset($inserts[$row[$ind]])) {
1436
+																	continue;
1437
+								}
1365 1438
 
1366 1439
 								$inserts[$row[$ind]] = $row;
1367 1440
 							}
1368 1441
 							$smcFunc['db_free_result']($ignoreRequest);
1369 1442
 							$numSubjectResults = count($inserts);
1443
+						} else {
1444
+													$numSubjectResults += $smcFunc['db_affected_rows']();
1370 1445
 						}
1371
-						else
1372
-							$numSubjectResults += $smcFunc['db_affected_rows']();
1373 1446
 
1374
-						if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results'])
1375
-							break;
1447
+						if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results']) {
1448
+													break;
1449
+						}
1376 1450
 					}
1377 1451
 
1378 1452
 					// Got some non-MySQL data to plonk in?
@@ -1390,8 +1464,9 @@  discard block
 block discarded – undo
1390 1464
 					{
1391 1465
 						$main_query['weights']['subject']['search'] = 'CASE WHEN MAX(lst.id_topic) IS NULL THEN 0 ELSE 1 END';
1392 1466
 						$main_query['left_join'][] = '{db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_topics AS lst ON (' . ($createTemporary ? '' : 'lst.id_search = {int:id_search} AND ') . 'lst.id_topic = t.id_topic)';
1393
-						if (!$createTemporary)
1394
-							$main_query['parameters']['id_search'] = $_SESSION['search_cache']['id_search'];
1467
+						if (!$createTemporary) {
1468
+													$main_query['parameters']['id_search'] = $_SESSION['search_cache']['id_search'];
1469
+						}
1395 1470
 					}
1396 1471
 				}
1397 1472
 
@@ -1419,14 +1494,15 @@  discard block
 block discarded – undo
1419 1494
 					) !== false;
1420 1495
 
1421 1496
 					// Clear, all clear!
1422
-					if (!$createTemporary)
1423
-						$smcFunc['db_search_query']('delete_log_search_messages', '
1497
+					if (!$createTemporary) {
1498
+											$smcFunc['db_search_query']('delete_log_search_messages', '
1424 1499
 							DELETE FROM {db_prefix}log_search_messages
1425 1500
 							WHERE id_search = {int:id_search}',
1426 1501
 							array(
1427 1502
 								'id_search' => $_SESSION['search_cache']['id_search'],
1428 1503
 							)
1429 1504
 						);
1505
+					}
1430 1506
 
1431 1507
 					foreach ($searchWords as $orIndex => $words)
1432 1508
 					{
@@ -1460,19 +1536,21 @@  discard block
 block discarded – undo
1460 1536
 								while ($row = $smcFunc['db_fetch_row']($ignoreRequest))
1461 1537
 								{
1462 1538
 									// No duplicates!
1463
-									if (isset($inserts[$row[0]]))
1464
-										continue;
1539
+									if (isset($inserts[$row[0]])) {
1540
+																			continue;
1541
+									}
1465 1542
 
1466 1543
 									$inserts[$row[0]] = $row;
1467 1544
 								}
1468 1545
 								$smcFunc['db_free_result']($ignoreRequest);
1469 1546
 								$indexedResults = count($inserts);
1547
+							} else {
1548
+															$indexedResults += $smcFunc['db_affected_rows']();
1470 1549
 							}
1471
-							else
1472
-								$indexedResults += $smcFunc['db_affected_rows']();
1473 1550
 
1474
-							if (!empty($maxMessageResults) && $indexedResults >= $maxMessageResults)
1475
-								break;
1551
+							if (!empty($maxMessageResults) && $indexedResults >= $maxMessageResults) {
1552
+															break;
1553
+							}
1476 1554
 						}
1477 1555
 					}
1478 1556
 
@@ -1492,8 +1570,7 @@  discard block
 block discarded – undo
1492 1570
 						$context['search_errors']['query_not_specific_enough'] = true;
1493 1571
 						$_REQUEST['params'] = $context['params'];
1494 1572
 						return PlushSearch1();
1495
-					}
1496
-					elseif (!empty($indexedResults))
1573
+					} elseif (!empty($indexedResults))
1497 1574
 					{
1498 1575
 						$main_query['inner_join'][] = '{db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_messages AS lsm ON (lsm.id_msg = m.id_msg)';
1499 1576
 						if (!$createTemporary)
@@ -1515,15 +1592,18 @@  discard block
 block discarded – undo
1515 1592
 						foreach ($words['all_words'] as $regularWord)
1516 1593
 						{
1517 1594
 							$where[] = 'm.body' . (in_array($regularWord, $excludedWords) ? ' NOT' : '') . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:all_word_body_' . $count . '}';
1518
-							if (in_array($regularWord, $excludedWords))
1519
-								$where[] = 'm.subject NOT' . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:all_word_body_' . $count . '}';
1595
+							if (in_array($regularWord, $excludedWords)) {
1596
+															$where[] = 'm.subject NOT' . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:all_word_body_' . $count . '}';
1597
+							}
1520 1598
 							$main_query['parameters']['all_word_body_' . $count++] = empty($modSettings['search_match_words']) || $no_regexp ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]';
1521 1599
 						}
1522
-						if (!empty($where))
1523
-							$orWhere[] = count($where) > 1 ? '(' . implode(' AND ', $where) . ')' : $where[0];
1600
+						if (!empty($where)) {
1601
+													$orWhere[] = count($where) > 1 ? '(' . implode(' AND ', $where) . ')' : $where[0];
1602
+						}
1603
+					}
1604
+					if (!empty($orWhere)) {
1605
+											$main_query['where'][] = count($orWhere) > 1 ? '(' . implode(' OR ', $orWhere) . ')' : $orWhere[0];
1524 1606
 					}
1525
-					if (!empty($orWhere))
1526
-						$main_query['where'][] = count($orWhere) > 1 ? '(' . implode(' OR ', $orWhere) . ')' : $orWhere[0];
1527 1607
 
1528 1608
 					if (!empty($userQuery))
1529 1609
 					{
@@ -1561,8 +1641,9 @@  discard block
 block discarded – undo
1561 1641
 					foreach ($main_query['weights'] as $type => $value)
1562 1642
 					{
1563 1643
 						$relevance .= $weight[$type];
1564
-						if (!empty($value['search']))
1565
-							$relevance .= ' * ' . $value['search'];
1644
+						if (!empty($value['search'])) {
1645
+													$relevance .= ' * ' . $value['search'];
1646
+						}
1566 1647
 						$relevance .= ' + ';
1567 1648
 						$new_weight_total += $weight[$type];
1568 1649
 					}
@@ -1593,11 +1674,13 @@  discard block
 block discarded – undo
1593 1674
 						while ($row = $smcFunc['db_fetch_row']($ignoreRequest))
1594 1675
 						{
1595 1676
 							// No duplicates!
1596
-							if (isset($inserts[$row[2]]))
1597
-								continue;
1677
+							if (isset($inserts[$row[2]])) {
1678
+															continue;
1679
+							}
1598 1680
 
1599
-							foreach ($row as $key => $value)
1600
-								$inserts[$row[2]][] = (int) $row[$key];
1681
+							foreach ($row as $key => $value) {
1682
+															$inserts[$row[2]][] = (int) $row[$key];
1683
+							}
1601 1684
 						}
1602 1685
 						$smcFunc['db_free_result']($ignoreRequest);
1603 1686
 
@@ -1605,8 +1688,9 @@  discard block
 block discarded – undo
1605 1688
 						if (!empty($inserts))
1606 1689
 						{
1607 1690
 							$query_columns = array();
1608
-							foreach ($main_query['select'] as $k => $v)
1609
-								$query_columns[$k] = 'int';
1691
+							foreach ($main_query['select'] as $k => $v) {
1692
+															$query_columns[$k] = 'int';
1693
+							}
1610 1694
 
1611 1695
 							$smcFunc['db_insert']('',
1612 1696
 								'{db_prefix}log_search_results',
@@ -1616,21 +1700,23 @@  discard block
 block discarded – undo
1616 1700
 							);
1617 1701
 						}
1618 1702
 						$_SESSION['search_cache']['num_results'] += count($inserts);
1703
+					} else {
1704
+											$_SESSION['search_cache']['num_results'] = $smcFunc['db_affected_rows']();
1619 1705
 					}
1620
-					else
1621
-						$_SESSION['search_cache']['num_results'] = $smcFunc['db_affected_rows']();
1622 1706
 				}
1623 1707
 
1624 1708
 				// Insert subject-only matches.
1625 1709
 				if ($_SESSION['search_cache']['num_results'] < $modSettings['search_max_results'] && $numSubjectResults !== 0)
1626 1710
 				{
1627 1711
 					$relevance = '1000 * (';
1628
-					foreach ($weight_factors as $type => $value)
1629
-						if (isset($value['results']))
1712
+					foreach ($weight_factors as $type => $value) {
1713
+											if (isset($value['results']))
1630 1714
 						{
1631 1715
 							$relevance .= $weight[$type];
1632
-							if (!empty($value['results']))
1633
-								$relevance .= ' * ' . $value['results'];
1716
+					}
1717
+							if (!empty($value['results'])) {
1718
+															$relevance .= ' * ' . $value['results'];
1719
+							}
1634 1720
 							$relevance .= ' + ';
1635 1721
 						}
1636 1722
 					$relevance = substr($relevance, 0, -3) . ') / ' . $weight_total . ' AS relevance';
@@ -1664,8 +1750,9 @@  discard block
 block discarded – undo
1664 1750
 						while ($row = $smcFunc['db_fetch_row']($ignoreRequest))
1665 1751
 						{
1666 1752
 							// No duplicates!
1667
-							if (isset($usedIDs[$row[1]]))
1668
-								continue;
1753
+							if (isset($usedIDs[$row[1]])) {
1754
+															continue;
1755
+							}
1669 1756
 
1670 1757
 							$usedIDs[$row[1]] = true;
1671 1758
 							$inserts[] = $row;
@@ -1683,12 +1770,12 @@  discard block
 block discarded – undo
1683 1770
 							);
1684 1771
 						}
1685 1772
 						$_SESSION['search_cache']['num_results'] += count($inserts);
1773
+					} else {
1774
+											$_SESSION['search_cache']['num_results'] += $smcFunc['db_affected_rows']();
1686 1775
 					}
1687
-					else
1688
-						$_SESSION['search_cache']['num_results'] += $smcFunc['db_affected_rows']();
1776
+				} elseif ($_SESSION['search_cache']['num_results'] == -1) {
1777
+									$_SESSION['search_cache']['num_results'] = 0;
1689 1778
 				}
1690
-				elseif ($_SESSION['search_cache']['num_results'] == -1)
1691
-					$_SESSION['search_cache']['num_results'] = 0;
1692 1779
 			}
1693 1780
 		}
1694 1781
 
@@ -1758,14 +1845,16 @@  discard block
 block discarded – undo
1758 1845
 			)
1759 1846
 		);
1760 1847
 		$posters = array();
1761
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1762
-			$posters[] = $row['id_member'];
1848
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1849
+					$posters[] = $row['id_member'];
1850
+		}
1763 1851
 		$smcFunc['db_free_result']($request);
1764 1852
 
1765 1853
 		call_integration_hook('integrate_search_message_list', array(&$msg_list, &$posters));
1766 1854
 
1767
-		if (!empty($posters))
1768
-			loadMemberData(array_unique($posters));
1855
+		if (!empty($posters)) {
1856
+					loadMemberData(array_unique($posters));
1857
+		}
1769 1858
 
1770 1859
 		// Get the messages out for the callback - select enough that it can be made to look just like Display.
1771 1860
 		$messages_request = $smcFunc['db_query']('', '
@@ -1799,8 +1888,9 @@  discard block
 block discarded – undo
1799 1888
 		);
1800 1889
 
1801 1890
 		// If there are no results that means the things in the cache got deleted, so pretend we have no topics anymore.
1802
-		if ($smcFunc['db_num_rows']($messages_request) == 0)
1803
-			$context['topics'] = array();
1891
+		if ($smcFunc['db_num_rows']($messages_request) == 0) {
1892
+					$context['topics'] = array();
1893
+		}
1804 1894
 
1805 1895
 		// If we want to know who participated in what then load this now.
1806 1896
 		if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest'])
@@ -1818,8 +1908,9 @@  discard block
 block discarded – undo
1818 1908
 					'limit' => count($participants),
1819 1909
 				)
1820 1910
 			);
1821
-			while ($row = $smcFunc['db_fetch_assoc']($result))
1822
-				$participants[$row['id_topic']] = true;
1911
+			while ($row = $smcFunc['db_fetch_assoc']($result)) {
1912
+							$participants[$row['id_topic']] = true;
1913
+			}
1823 1914
 			$smcFunc['db_free_result']($result);
1824 1915
 		}
1825 1916
 	}
@@ -1828,15 +1919,17 @@  discard block
 block discarded – undo
1828 1919
 	$context['page_index'] = constructPageIndex($scripturl . '?action=search2;params=' . $context['params'], $_REQUEST['start'], $num_results, $modSettings['search_results_per_page'], false);
1829 1920
 
1830 1921
 	// Consider the search complete!
1831
-	if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
1832
-		cache_put_data('search_start:' . ($user_info['is_guest'] ? $user_info['ip'] : $user_info['id']), null, 90);
1922
+	if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
1923
+			cache_put_data('search_start:' . ($user_info['is_guest'] ? $user_info['ip'] : $user_info['id']), null, 90);
1924
+	}
1833 1925
 
1834 1926
 	$context['key_words'] = &$searchArray;
1835 1927
 
1836 1928
 	// Setup the default topic icons... for checking they exist and the like!
1837 1929
 	$context['icon_sources'] = array();
1838
-	foreach ($context['stable_icons'] as $icon)
1839
-		$context['icon_sources'][$icon] = 'images_url';
1930
+	foreach ($context['stable_icons'] as $icon) {
1931
+			$context['icon_sources'][$icon] = 'images_url';
1932
+	}
1840 1933
 
1841 1934
 	$context['sub_template'] = 'results';
1842 1935
 	$context['page_title'] = $txt['search_results'];
@@ -1867,26 +1960,31 @@  discard block
 block discarded – undo
1867 1960
 	global $boards_can, $participants, $smcFunc;
1868 1961
 	static $recycle_board = null;
1869 1962
 
1870
-	if ($recycle_board === null)
1871
-		$recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0;
1963
+	if ($recycle_board === null) {
1964
+			$recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0;
1965
+	}
1872 1966
 
1873 1967
 	// Remember which message this is.  (ie. reply #83)
1874 1968
 	static $counter = null;
1875
-	if ($counter == null || $reset)
1876
-		$counter = $_REQUEST['start'] + 1;
1969
+	if ($counter == null || $reset) {
1970
+			$counter = $_REQUEST['start'] + 1;
1971
+	}
1877 1972
 
1878 1973
 	// If the query returned false, bail.
1879
-	if ($messages_request == false)
1880
-		return false;
1974
+	if ($messages_request == false) {
1975
+			return false;
1976
+	}
1881 1977
 
1882 1978
 	// Start from the beginning...
1883
-	if ($reset)
1884
-		return @$smcFunc['db_data_seek']($messages_request, 0);
1979
+	if ($reset) {
1980
+			return @$smcFunc['db_data_seek']($messages_request, 0);
1981
+	}
1885 1982
 
1886 1983
 	// Attempt to get the next message.
1887 1984
 	$message = $smcFunc['db_fetch_assoc']($messages_request);
1888
-	if (!$message)
1889
-		return false;
1985
+	if (!$message) {
1986
+			return false;
1987
+	}
1890 1988
 
1891 1989
 	// Can't have an empty subject can we?
1892 1990
 	$message['subject'] = $message['subject'] != '' ? $message['subject'] : $txt['no_subject'];
@@ -1925,9 +2023,9 @@  discard block
 block discarded – undo
1925 2023
 
1926 2024
 		if ($smcFunc['strlen']($message['body']) > $charLimit)
1927 2025
 		{
1928
-			if (empty($context['key_words']))
1929
-				$message['body'] = $smcFunc['substr']($message['body'], 0, $charLimit) . '<strong>...</strong>';
1930
-			else
2026
+			if (empty($context['key_words'])) {
2027
+							$message['body'] = $smcFunc['substr']($message['body'], 0, $charLimit) . '<strong>...</strong>';
2028
+			} else
1931 2029
 			{
1932 2030
 				$matchString = '';
1933 2031
 				$force_partial_word = false;
@@ -1936,18 +2034,20 @@  discard block
 block discarded – undo
1936 2034
 					$keyword = un_htmlspecialchars($keyword);
1937 2035
 					$keyword = preg_replace_callback('~(&amp;#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'entity_fix__callback', strtr($keyword, array('\\\'' => '\'', '&' => '&amp;')));
1938 2036
 
1939
-					if (preg_match('~[\'\.,/@%&;:(){}\[\]_\-+\\\\]$~', $keyword) != 0 || preg_match('~^[\'\.,/@%&;:(){}\[\]_\-+\\\\]~', $keyword) != 0)
1940
-						$force_partial_word = true;
2037
+					if (preg_match('~[\'\.,/@%&;:(){}\[\]_\-+\\\\]$~', $keyword) != 0 || preg_match('~^[\'\.,/@%&;:(){}\[\]_\-+\\\\]~', $keyword) != 0) {
2038
+											$force_partial_word = true;
2039
+					}
1941 2040
 					$matchString .= strtr(preg_quote($keyword, '/'), array('\*' => '.+?')) . '|';
1942 2041
 				}
1943 2042
 				$matchString = un_htmlspecialchars(substr($matchString, 0, -1));
1944 2043
 
1945 2044
 				$message['body'] = un_htmlspecialchars(strtr($message['body'], array('&nbsp;' => ' ', '<br>' => "\n", '&#91;' => '[', '&#93;' => ']', '&#58;' => ':', '&#64;' => '@')));
1946 2045
 
1947
-				if (empty($modSettings['search_method']) || $force_partial_word)
1948
-					preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?|^)(' . $matchString . ')(.{0,' . $charLimit . '}[\s\W]|[^\s\W]{0,' . $charLimit . '})/is' . ($context['utf8'] ? 'u' : ''), $message['body'], $matches);
1949
-				else
1950
-					preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?[\s\W]|^)(' . $matchString . ')([\s\W].{0,' . $charLimit . '}[\s\W]|[\s\W][^\s\W]{0,' . $charLimit . '})/is' . ($context['utf8'] ? 'u' : ''), $message['body'], $matches);
2046
+				if (empty($modSettings['search_method']) || $force_partial_word) {
2047
+									preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?|^)(' . $matchString . ')(.{0,' . $charLimit . '}[\s\W]|[^\s\W]{0,' . $charLimit . '})/is' . ($context['utf8'] ? 'u' : ''), $message['body'], $matches);
2048
+				} else {
2049
+									preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?[\s\W]|^)(' . $matchString . ')([\s\W].{0,' . $charLimit . '}[\s\W]|[\s\W][^\s\W]{0,' . $charLimit . '})/is' . ($context['utf8'] ? 'u' : ''), $message['body'], $matches);
2050
+				}
1951 2051
 
1952 2052
 				$message['body'] = '';
1953 2053
 				foreach ($matches[0] as $index => $match)
@@ -1960,8 +2060,7 @@  discard block
 block discarded – undo
1960 2060
 			// Re-fix the international characters.
1961 2061
 			$message['body'] = preg_replace_callback('~(&amp;#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'entity_fix__callback', $message['body']);
1962 2062
 		}
1963
-	}
1964
-	else
2063
+	} else
1965 2064
 	{
1966 2065
 		// Run BBC interpreter on the message.
1967 2066
 		$message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']);
@@ -1980,21 +2079,26 @@  discard block
 block discarded – undo
1980 2079
 	// Sadly, we need to check the icon ain't broke.
1981 2080
 	if (!empty($modSettings['messageIconChecks_enable']))
1982 2081
 	{
1983
-		if (!isset($context['icon_sources'][$message['first_icon']]))
1984
-			$context['icon_sources'][$message['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['first_icon'] . '.png') ? 'images_url' : 'default_images_url';
1985
-		if (!isset($context['icon_sources'][$message['last_icon']]))
1986
-			$context['icon_sources'][$message['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['last_icon'] . '.png') ? 'images_url' : 'default_images_url';
1987
-		if (!isset($context['icon_sources'][$message['icon']]))
1988
-			$context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url';
1989
-	}
1990
-	else
2082
+		if (!isset($context['icon_sources'][$message['first_icon']])) {
2083
+					$context['icon_sources'][$message['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['first_icon'] . '.png') ? 'images_url' : 'default_images_url';
2084
+		}
2085
+		if (!isset($context['icon_sources'][$message['last_icon']])) {
2086
+					$context['icon_sources'][$message['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['last_icon'] . '.png') ? 'images_url' : 'default_images_url';
2087
+		}
2088
+		if (!isset($context['icon_sources'][$message['icon']])) {
2089
+					$context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url';
2090
+		}
2091
+	} else
1991 2092
 	{
1992
-		if (!isset($context['icon_sources'][$message['first_icon']]))
1993
-			$context['icon_sources'][$message['first_icon']] = 'images_url';
1994
-		if (!isset($context['icon_sources'][$message['last_icon']]))
1995
-			$context['icon_sources'][$message['last_icon']] = 'images_url';
1996
-		if (!isset($context['icon_sources'][$message['icon']]))
1997
-			$context['icon_sources'][$message['icon']] = 'images_url';
2093
+		if (!isset($context['icon_sources'][$message['first_icon']])) {
2094
+					$context['icon_sources'][$message['first_icon']] = 'images_url';
2095
+		}
2096
+		if (!isset($context['icon_sources'][$message['last_icon']])) {
2097
+					$context['icon_sources'][$message['last_icon']] = 'images_url';
2098
+		}
2099
+		if (!isset($context['icon_sources'][$message['icon']])) {
2100
+					$context['icon_sources'][$message['icon']] = 'images_url';
2101
+		}
1998 2102
 	}
1999 2103
 
2000 2104
 	// Do we have quote tag enabled?
@@ -2004,12 +2108,14 @@  discard block
 block discarded – undo
2004 2108
 	$colorClass = 'windowbg';
2005 2109
 
2006 2110
 	// Sticky topics should get a different color, too.
2007
-	if ($message['is_sticky'])
2008
-		$colorClass .= ' sticky';
2111
+	if ($message['is_sticky']) {
2112
+			$colorClass .= ' sticky';
2113
+	}
2009 2114
 
2010 2115
 	// Locked topics get special treatment as well.
2011
-	if ($message['locked'])
2012
-		$colorClass .= ' locked';
2116
+	if ($message['locked']) {
2117
+			$colorClass .= ' locked';
2118
+	}
2013 2119
 
2014 2120
 	$output = array_merge($context['topics'][$message['id_msg']], array(
2015 2121
 		'id' => $message['id_topic'],
@@ -2153,8 +2259,9 @@  discard block
 block discarded – undo
2153 2259
 
2154 2260
 	// Load up the search API we are going to use.
2155 2261
 	$modSettings['search_index'] = empty($modSettings['search_index']) ? 'standard' : $modSettings['search_index'];
2156
-	if (!file_exists($sourcedir . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.php'))
2157
-		fatal_lang_error('search_api_missing');
2262
+	if (!file_exists($sourcedir . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.php')) {
2263
+			fatal_lang_error('search_api_missing');
2264
+	}
2158 2265
 	require_once($sourcedir . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.php');
2159 2266
 
2160 2267
 	// Create an instance of the search API and check it is valid for this version of SMF.
Please login to merge, or discard this patch.
Sources/Likes.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 	public function get($property = '')
168 168
 	{
169 169
 		// All properties inside Likes are protected, thus, an underscore is used.
170
-		$property = '_'. $property;
170
+		$property = '_' . $property;
171 171
 		return property_exists($this, $property) ? $this->$property : false;
172 172
 	}
173 173
 
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
 
572 572
 			// Nope?  then just do a redirect to whatever URL was provided.
573 573
 			else
574
-				redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] .';error='. $this->_error : '');
574
+				redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] . ';error=' . $this->_error : '');
575 575
 
576 576
 			return;
577 577
 		}
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
 			if (in_array($this->_sa, $generic))
589 589
 			{
590 590
 				$context['sub_template'] = 'generic';
591
-				$context['data'] = isset($txt['like_'. $this->_data]) ? $txt['like_'. $this->_data] : $this->_data;
591
+				$context['data'] = isset($txt['like_' . $this->_data]) ? $txt['like_' . $this->_data] : $this->_data;
592 592
 			}
593 593
 
594 594
 			// Directly pass the current called sub-action and the data generated by its associated Method.
Please login to merge, or discard this patch.
Braces   +106 added lines, -77 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
  * Class Likes
@@ -108,8 +109,9 @@  discard block
 block discarded – undo
108 109
 		$this->_extra = isset($_GET['extra']) ? $_GET['extra'] : false;
109 110
 
110 111
 		// We do not want to output debug information here.
111
-		if ($this->_js)
112
-			$db_show_debug = false;
112
+		if ($this->_js) {
113
+					$db_show_debug = false;
114
+		}
113 115
 	}
114 116
 
115 117
 	/**
@@ -143,8 +145,9 @@  discard block
 block discarded – undo
143 145
 			$call = $this->_sa;
144 146
 
145 147
 			// Guest can only view likes.
146
-			if ($call != 'view')
147
-				is_not_guest();
148
+			if ($call != 'view') {
149
+							is_not_guest();
150
+			}
148 151
 
149 152
 			checkSession('get');
150 153
 
@@ -182,15 +185,17 @@  discard block
 block discarded – undo
182 185
 		global $smcFunc, $modSettings;
183 186
 
184 187
 		// This feature is currently disable.
185
-		if (empty($modSettings['enable_likes']))
186
-			return $this->_error = 'like_disable';
188
+		if (empty($modSettings['enable_likes'])) {
189
+					return $this->_error = 'like_disable';
190
+		}
187 191
 
188 192
 		// Zerothly, they did indicate some kind of content to like, right?
189 193
 		preg_match('~^([a-z0-9\-\_]{1,6})~i', $this->_type, $matches);
190 194
 		$this->_type = isset($matches[1]) ? $matches[1] : '';
191 195
 
192
-		if ($this->_type == '' || $this->_content <= 0)
193
-			return $this->_error = 'cannot_';
196
+		if ($this->_type == '' || $this->_content <= 0) {
197
+					return $this->_error = 'cannot_';
198
+		}
194 199
 
195 200
 		// First we need to verify if the user can see the type of content or not. This is set up to be extensible,
196 201
 		// so we'll check for the one type we do know about, and if it's not that, we'll defer to any hooks.
@@ -209,12 +214,14 @@  discard block
 block discarded – undo
209 214
 					'msg' => $this->_content,
210 215
 				)
211 216
 			);
212
-			if ($smcFunc['db_num_rows']($request) == 1)
213
-				list ($this->_idTopic, $topicOwner) = $smcFunc['db_fetch_row']($request);
217
+			if ($smcFunc['db_num_rows']($request) == 1) {
218
+							list ($this->_idTopic, $topicOwner) = $smcFunc['db_fetch_row']($request);
219
+			}
214 220
 
215 221
 			$smcFunc['db_free_result']($request);
216
-			if (empty($this->_idTopic))
217
-				return $this->_error = 'cannot_';
222
+			if (empty($this->_idTopic)) {
223
+							return $this->_error = 'cannot_';
224
+			}
218 225
 
219 226
 			// So we know what topic it's in and more importantly we know the user can see it.
220 227
 			// If we're not viewing, we need some info set up.
@@ -224,9 +231,7 @@  discard block
 block discarded – undo
224 231
 			$this->_validLikes['can_see'] = allowedTo('likes_view') ? true : 'cannot_view_likes';
225 232
 
226 233
 			$this->_validLikes['can_like'] = ($this->_user['id'] == $topicOwner ? 'cannot_like_content' : (allowedTo('likes_like') ? true : 'cannot_like_content'));
227
-		}
228
-
229
-		else
234
+		} else
230 235
 		{
231 236
 			// Modders: This will give you whatever the user offers up in terms of liking, e.g. $this->_type=msg, $this->_content=1
232 237
 			// When you hook this, check $this->_type first. If it is not something your mod worries about, return false.
@@ -244,8 +249,9 @@  discard block
 block discarded – undo
244 249
 					if ($result !== false)
245 250
 					{
246 251
 						// Match the type with what we already have.
247
-						if (!isset($result['type']) || $result['type'] != $this->_type)
248
-							return $this->_error = 'not_valid_like_type';
252
+						if (!isset($result['type']) || $result['type'] != $this->_type) {
253
+													return $this->_error = 'not_valid_like_type';
254
+						}
249 255
 
250 256
 						// Fill out the rest.
251 257
 						$this->_type = $result['type'];
@@ -256,17 +262,20 @@  discard block
 block discarded – undo
256 262
 				}
257 263
 			}
258 264
 
259
-			if (!$found)
260
-				return $this->_error = 'cannot_';
265
+			if (!$found) {
266
+							return $this->_error = 'cannot_';
267
+			}
261 268
 		}
262 269
 
263 270
 		// Does the user can see this?
264
-		if (isset($this->_validLikes['can_see']) && is_string($this->_validLikes['can_see']))
265
-			return $this->_error = $this->_validLikes['can_see'];
271
+		if (isset($this->_validLikes['can_see']) && is_string($this->_validLikes['can_see'])) {
272
+					return $this->_error = $this->_validLikes['can_see'];
273
+		}
266 274
 
267 275
 		// Does the user can like this? Viewing a list of likes doesn't require this permission.
268
-			if ($this->_sa != 'view' && isset($this->_validLikes['can_like']) && is_string($this->_validLikes['can_like']))
269
-				return $this->_error = $this->_validLikes['can_like'];
276
+			if ($this->_sa != 'view' && isset($this->_validLikes['can_like']) && is_string($this->_validLikes['can_like'])) {
277
+							return $this->_error = $this->_validLikes['can_like'];
278
+			}
270 279
 	}
271 280
 
272 281
 	/**
@@ -291,8 +300,9 @@  discard block
 block discarded – undo
291 300
 		);
292 301
 
293 302
 		// Are we calling this directly? if so, set a proper data for the response. Do note that __METHOD__ returns both the class name and the function name.
294
-		if ($this->_sa == __FUNCTION__)
295
-			$this->_data = __FUNCTION__;
303
+		if ($this->_sa == __FUNCTION__) {
304
+					$this->_data = __FUNCTION__;
305
+		}
296 306
 	}
297 307
 
298 308
 	/**
@@ -322,8 +332,8 @@  discard block
 block discarded – undo
322 332
 
323 333
 		// Add a background task to process sending alerts.
324 334
 		// Mod author, you can add your own background task for your own custom like event using the "integrate_issue_like" hook or your callback, both are immediately called after this.
325
-		if ($this->_type == 'msg')
326
-			$smcFunc['db_insert']('insert',
335
+		if ($this->_type == 'msg') {
336
+					$smcFunc['db_insert']('insert',
327 337
 				'{db_prefix}background_tasks',
328 338
 				array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'),
329 339
 				array('$sourcedir/tasks/Likes-Notify.php', 'Likes_Notify_Background', json_encode(array(
@@ -335,10 +345,12 @@  discard block
 block discarded – undo
335 345
 				)), 0),
336 346
 				array('id_task')
337 347
 			);
348
+		}
338 349
 
339 350
 		// Are we calling this directly? if so, set a proper data for the response. Do note that __METHOD__ returns both the class name and the function name.
340
-		if ($this->_sa == __FUNCTION__)
341
-			$this->_data = __FUNCTION__;
351
+		if ($this->_sa == __FUNCTION__) {
352
+					$this->_data = __FUNCTION__;
353
+		}
342 354
 	}
343 355
 
344 356
 	/**
@@ -364,8 +376,9 @@  discard block
 block discarded – undo
364 376
 		$smcFunc['db_free_result']($request);
365 377
 
366 378
 		// If you want to call this directly, fill out _data property too.
367
-		if ($this->_sa == __FUNCTION__)
368
-			$this->_data = $this->_numLikes;
379
+		if ($this->_sa == __FUNCTION__) {
380
+					$this->_data = $this->_numLikes;
381
+		}
369 382
 	}
370 383
 
371 384
 	/**
@@ -378,8 +391,9 @@  discard block
 block discarded – undo
378 391
 		global $smcFunc;
379 392
 
380 393
 		// Safety first!
381
-		if (empty($this->_type) || empty($this->_content))
382
-			return $this->_error = 'cannot_';
394
+		if (empty($this->_type) || empty($this->_content)) {
395
+					return $this->_error = 'cannot_';
396
+		}
383 397
 
384 398
 		// Do we already like this?
385 399
 		$request = $smcFunc['db_query']('', '
@@ -397,26 +411,28 @@  discard block
 block discarded – undo
397 411
 		$this->_alreadyLiked = (bool) $smcFunc['db_num_rows']($request) != 0;
398 412
 		$smcFunc['db_free_result']($request);
399 413
 
400
-		if ($this->_alreadyLiked)
401
-			$this->delete();
402
-
403
-		else
404
-			$this->insert();
414
+		if ($this->_alreadyLiked) {
415
+					$this->delete();
416
+		} else {
417
+					$this->insert();
418
+		}
405 419
 
406 420
 		// Now, how many people like this content now? We *could* just +1 / -1 the relevant container but that has proven to become unstable.
407 421
 		$this->_count();
408 422
 
409 423
 		// Update the likes count for messages.
410
-		if ($this->_type == 'msg')
411
-			$this->msgIssueLike();
424
+		if ($this->_type == 'msg') {
425
+					$this->msgIssueLike();
426
+		}
412 427
 
413 428
 		// Any callbacks?
414 429
 		elseif (!empty($this->_validLikes['callback']))
415 430
 		{
416 431
 			$call = call_helper($this->_validLikes['callback'], true);
417 432
 
418
-			if (!empty($call))
419
-				call_user_func_array($call, array($this));
433
+			if (!empty($call)) {
434
+							call_user_func_array($call, array($this));
435
+			}
420 436
 		}
421 437
 
422 438
 		// Sometimes there might be other things that need updating after we do this like.
@@ -425,8 +441,9 @@  discard block
 block discarded – undo
425 441
 		// Now some clean up. This is provided here for any like handlers that want to do any cache flushing.
426 442
 		// This way a like handler doesn't need to explicitly declare anything in integrate_issue_like, but do so
427 443
 		// in integrate_valid_likes where it absolutely has to exist.
428
-		if (!empty($this->_validLikes['flush_cache']))
429
-			cache_put_data($this->_validLikes['flush_cache'], null);
444
+		if (!empty($this->_validLikes['flush_cache'])) {
445
+					cache_put_data($this->_validLikes['flush_cache'], null);
446
+		}
430 447
 
431 448
 		// All done, start building the data to pass as response.
432 449
 		$this->_data = array(
@@ -450,8 +467,9 @@  discard block
 block discarded – undo
450 467
 	{
451 468
 		global $smcFunc;
452 469
 
453
-		if ($this->_type !== 'msg')
454
-			return;
470
+		if ($this->_type !== 'msg') {
471
+					return;
472
+		}
455 473
 
456 474
 		$smcFunc['db_query']('', '
457 475
 			UPDATE {db_prefix}messages
@@ -492,8 +510,9 @@  discard block
 block discarded – undo
492 510
 				'like_type' => $this->_type,
493 511
 			)
494 512
 		);
495
-		while ($row = $smcFunc['db_fetch_assoc']($request))
496
-			$context['likers'][$row['id_member']] = array('timestamp' => $row['like_time']);
513
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
514
+					$context['likers'][$row['id_member']] = array('timestamp' => $row['like_time']);
515
+		}
497 516
 
498 517
 		// Now to get member data, including avatars and so on.
499 518
 		$members = array_keys($context['likers']);
@@ -501,8 +520,9 @@  discard block
 block discarded – undo
501 520
 		if (count($loaded) != count($members))
502 521
 		{
503 522
 			$members = array_diff($members, $loaded);
504
-			foreach ($members as $not_loaded)
505
-				unset ($context['likers'][$not_loaded]);
523
+			foreach ($members as $not_loaded) {
524
+							unset ($context['likers'][$not_loaded]);
525
+			}
506 526
 		}
507 527
 
508 528
 		foreach ($context['likers'] as $liker => $dummy)
@@ -544,12 +564,14 @@  discard block
 block discarded – undo
544 564
 		global $context, $txt;
545 565
 
546 566
 		// Don't do anything if someone else has already take care of the response.
547
-		if (!$this->_setResponse)
548
-			return;
567
+		if (!$this->_setResponse) {
568
+					return;
569
+		}
549 570
 
550 571
 		// Want a json response huh?
551
-		if ($this->_validLikes['json'])
552
-			return $this->jsonResponse();
572
+		if ($this->_validLikes['json']) {
573
+					return $this->jsonResponse();
574
+		}
553 575
 
554 576
 		// Set everything up for display.
555 577
 		loadTemplate('Likes');
@@ -559,8 +581,9 @@  discard block
 block discarded – undo
559 581
 		if ($this->_error)
560 582
 		{
561 583
 			// If this is a generic error, set it up good.
562
-			if ($this->_error == 'cannot_')
563
-				$this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content';
584
+			if ($this->_error == 'cannot_') {
585
+							$this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content';
586
+			}
564 587
 
565 588
 			// Is this request coming from an ajax call?
566 589
 			if ($this->_js)
@@ -570,8 +593,9 @@  discard block
 block discarded – undo
570 593
 			}
571 594
 
572 595
 			// Nope?  then just do a redirect to whatever URL was provided.
573
-			else
574
-				redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] .';error='. $this->_error : '');
596
+			else {
597
+							redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] .';error='. $this->_error : '');
598
+			}
575 599
 
576 600
 			return;
577 601
 		}
@@ -580,8 +604,9 @@  discard block
 block discarded – undo
580 604
 		else
581 605
 		{
582 606
 			// Not an ajax request so send the user back to the previous location or the main page.
583
-			if (!$this->_js)
584
-				redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] : '');
607
+			if (!$this->_js) {
608
+							redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] : '');
609
+			}
585 610
 
586 611
 			// These fine gentlemen all share the same template.
587 612
 			$generic = array('delete', 'insert', '_count');
@@ -612,8 +637,9 @@  discard block
 block discarded – undo
612 637
 		// If there is an error, send it.
613 638
 		if ($this->_error)
614 639
 		{
615
-			if ($this->_error == 'cannot_')
616
-				$this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content';
640
+			if ($this->_error == 'cannot_') {
641
+							$this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content';
642
+			}
617 643
 
618 644
 			$print['error'] = $this->_error;
619 645
 		}
@@ -649,33 +675,36 @@  discard block
 block discarded – undo
649 675
 	<body style="background-color: #444455; color: white; font-style: italic; font-family: serif;">
650 676
 		<div style="margin-top: 12%; font-size: 1.1em; line-height: 1.4; text-align: center;">';
651 677
 
652
-	if (!isset($_GET['verse']) || ($_GET['verse'] != '2:18' && $_GET['verse'] != '22:1-2'))
653
-		$_GET['verse'] = '4:16';
678
+	if (!isset($_GET['verse']) || ($_GET['verse'] != '2:18' && $_GET['verse'] != '22:1-2')) {
679
+			$_GET['verse'] = '4:16';
680
+	}
654 681
 
655
-	if ($_GET['verse'] == '2:18')
656
-		echo '
682
+	if ($_GET['verse'] == '2:18') {
683
+			echo '
657 684
 			Woe, it was that his name wasn\'t <em>known</em>, that he came in mystery, and was recognized by none.&nbsp;And it became to be in those days <em>something</em>.&nbsp; Something not yet <em id="unknown" name="[Unknown]">unknown</em> to mankind.&nbsp; And thus what was to be known the <em>secret project</em> began into its existence.&nbsp; Henceforth the opposition was only <em>weary</em> and <em>fearful</em>, for now their match was at arms against them.';
658
-	elseif ($_GET['verse'] == '4:16')
659
-		echo '
685
+	} elseif ($_GET['verse'] == '4:16') {
686
+			echo '
660 687
 			And it came to pass that the <em>unbelievers</em> dwindled in number and saw rise of many <em>proselytizers</em>, and the opposition found fear in the face of the <em>x</em> and the <em>j</em> while those who stood with the <em>something</em> grew stronger and came together.&nbsp; Still, this was only the <em>beginning</em>, and what lay in the future was <em id="unknown" name="[Unknown]">unknown</em> to all, even those on the right side.';
661
-	elseif ($_GET['verse'] == '22:1-2')
662
-		echo '
688
+	} elseif ($_GET['verse'] == '22:1-2') {
689
+			echo '
663 690
 			<p>Now <em>behold</em>, that which was once the secret project was <em id="unknown" name="[Unknown]">unknown</em> no longer.&nbsp; Alas, it needed more than <em>only one</em>, but yet even thought otherwise.&nbsp; It became that the opposition <em>rumored</em> and lied, but still to no avail.&nbsp; Their match, though not <em>perfect</em>, had them outdone.</p>
664 691
 			<p style="margin: 2ex 1ex 0 1ex; font-size: 1.05em; line-height: 1.5; text-align: center;">Let it continue.&nbsp; <em>The end</em>.</p>';
692
+	}
665 693
 
666 694
 	echo '
667 695
 		</div>
668 696
 		<div style="margin-top: 2ex; font-size: 2em; text-align: right;">';
669 697
 
670
-	if ($_GET['verse'] == '2:18')
671
-		echo '
698
+	if ($_GET['verse'] == '2:18') {
699
+			echo '
672 700
 			from <span style="font-family: Georgia, serif;"><strong><a href="', $scripturl, '?action=about:unknown;verse=4:16" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 2:18</span>';
673
-	elseif ($_GET['verse'] == '4:16')
674
-		echo '
701
+	} elseif ($_GET['verse'] == '4:16') {
702
+			echo '
675 703
 			from <span style="font-family: Georgia, serif;"><strong><a href="', $scripturl, '?action=about:unknown;verse=22:1-2" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 4:16</span>';
676
-	elseif ($_GET['verse'] == '22:1-2')
677
-		echo '
704
+	} elseif ($_GET['verse'] == '22:1-2') {
705
+			echo '
678 706
 			from <span style="font-family: Georgia, serif;"><strong>The Book of Unknown</strong>, 22:1-2</span>';
707
+	}
679 708
 
680 709
 	echo '
681 710
 		</div>
Please login to merge, or discard this patch.
Sources/Display.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 			COALESCE(mem.real_name, ms.poster_name) AS topic_started_name, ms.poster_time AS topic_started_time,
160 160
 			' . ($user_info['is_guest'] ? 't.id_last_msg + 1' : 'COALESCE(lt.id_msg, lmr.id_msg, -1) + 1') . ' AS new_from
161 161
 			' . (!empty($board_info['recycle']) ? ', id_previous_board, id_previous_topic' : '') . '
162
-			' . (!empty($topic_selects) ? (', '. implode(', ', $topic_selects)) : '') . '
162
+			' . (!empty($topic_selects) ? (', ' . implode(', ', $topic_selects)) : '') . '
163 163
 			' . (!$user_info['is_guest'] ? ', COALESCE(lt.unwatched, 0) as unwatched' : '') . '
164 164
 		FROM {db_prefix}topics AS t
165 165
 			INNER JOIN {db_prefix}messages AS ms ON (ms.id_msg = t.id_first_msg)
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 			WHERE INSTR(lo.url, {string:in_url_string}) > 0 OR lo.session = {string:session}',
389 389
 			array(
390 390
 				'reg_id_group' => 0,
391
-				'in_url_string' => '"topic":'.$topic,
391
+				'in_url_string' => '"topic":' . $topic,
392 392
 				'session' => $user_info['is_guest'] ? 'ip' . $user_info['ip'] : session_id(),
393 393
 			)
394 394
 		);
@@ -457,8 +457,8 @@  discard block
 block discarded – undo
457 457
 		$context['links'] = array(
458 458
 			'first' => $_REQUEST['start'] >= $context['messages_per_page'] ? $scripturl . '?topic=' . $topic . '.0' : '',
459 459
 			'prev' => $_REQUEST['start'] >= $context['messages_per_page'] ? $scripturl . '?topic=' . $topic . '.' . ($_REQUEST['start'] - $context['messages_per_page']) : '',
460
-			'next' => $_REQUEST['start'] + $context['messages_per_page'] < $context['total_visible_posts'] ? $scripturl . '?topic=' . $topic. '.' . ($_REQUEST['start'] + $context['messages_per_page']) : '',
461
-			'last' => $_REQUEST['start'] + $context['messages_per_page'] < $context['total_visible_posts'] ? $scripturl . '?topic=' . $topic. '.' . (floor($context['total_visible_posts'] / $context['messages_per_page']) * $context['messages_per_page']) : '',
460
+			'next' => $_REQUEST['start'] + $context['messages_per_page'] < $context['total_visible_posts'] ? $scripturl . '?topic=' . $topic . '.' . ($_REQUEST['start'] + $context['messages_per_page']) : '',
461
+			'last' => $_REQUEST['start'] + $context['messages_per_page'] < $context['total_visible_posts'] ? $scripturl . '?topic=' . $topic . '.' . (floor($context['total_visible_posts'] / $context['messages_per_page']) * $context['messages_per_page']) : '',
462 462
 			'up' => $scripturl . '?board=' . $board . '.0'
463 463
 		);
464 464
 	}
@@ -1037,7 +1037,7 @@  discard block
 block discarded – undo
1037 1037
 				id_msg, icon, subject, poster_time, poster_ip, id_member, modified_time, modified_name, modified_reason, body,
1038 1038
 				smileys_enabled, poster_name, poster_email, approved, likes,
1039 1039
 				id_msg_modified < {int:new_from} AS is_read
1040
-				' . (!empty($msg_selects) ? (', '. implode(', ', $msg_selects)) : '') . '
1040
+				' . (!empty($msg_selects) ? (', ' . implode(', ', $msg_selects)) : '') . '
1041 1041
 			FROM {db_prefix}messages
1042 1042
 				' . (!empty($msg_tables) ? implode("\n\t", $msg_tables) : '') . '
1043 1043
 			WHERE id_msg IN ({array_int:message_list})
@@ -1681,17 +1681,17 @@  discard block
 block discarded – undo
1681 1681
 	if (!empty($modSettings['attachmentRecodeLineEndings']) && !isset($_REQUEST['image']) && in_array($file_ext, array('txt', 'css', 'htm', 'html', 'php', 'xml')))
1682 1682
 	{
1683 1683
 		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== false)
1684
-			$callback = function ($buffer)
1684
+			$callback = function($buffer)
1685 1685
 			{
1686 1686
 				return preg_replace('~[\r]?\n~', "\r\n", $buffer);
1687 1687
 			};
1688 1688
 		elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false)
1689
-			$callback = function ($buffer)
1689
+			$callback = function($buffer)
1690 1690
 			{
1691 1691
 				return preg_replace('~[\r]?\n~', "\r", $buffer);
1692 1692
 			};
1693 1693
 		else
1694
-			$callback = function ($buffer)
1694
+			$callback = function($buffer)
1695 1695
 			{
1696 1696
 				return preg_replace('~[\r]?\n~', "\n", $buffer);
1697 1697
 			};
@@ -1772,7 +1772,7 @@  discard block
 block discarded – undo
1772 1772
 		list($subname) = $smcFunc['db_fetch_row']($request);
1773 1773
 		$smcFunc['db_free_result']($request);
1774 1774
 		$_SESSION['split_selection'][$topic] = $messages;
1775
-		redirectexit('action=splittopics;sa=selectTopics;topic=' . $topic . '.0;subname_enc=' .urlencode($subname) . ';' . $context['session_var'] . '=' . $context['session_id']);
1775
+		redirectexit('action=splittopics;sa=selectTopics;topic=' . $topic . '.0;subname_enc=' . urlencode($subname) . ';' . $context['session_var'] . '=' . $context['session_id']);
1776 1776
 	}
1777 1777
 
1778 1778
 	// Allowed to delete any message?
Please login to merge, or discard this patch.
Braces   +335 added lines, -251 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'];
@@ -546,10 +561,11 @@  discard block
 block discarded – undo
546 561
 	if (allowedTo('calendar_view') && !empty($modSettings['cal_showInTopic']) && !empty($modSettings['cal_enabled']))
547 562
 	{
548 563
 		// First, try create a better time format, ignoring the "time" elements.
549
-		if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0]))
550
-			$date_string = $user_info['time_format'];
551
-		else
552
-			$date_string = $matches[0];
564
+		if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) {
565
+					$date_string = $user_info['time_format'];
566
+		} else {
567
+					$date_string = $matches[0];
568
+		}
553 569
 
554 570
 		// Any calendar information for this topic?
555 571
 		$request = $smcFunc['db_query']('', '
@@ -587,8 +603,9 @@  discard block
 block discarded – undo
587 603
 		}
588 604
 		$smcFunc['db_free_result']($request);
589 605
 
590
-		if (!empty($context['linked_calendar_events']))
591
-			$context['linked_calendar_events'][count($context['linked_calendar_events']) - 1]['is_last'] = true;
606
+		if (!empty($context['linked_calendar_events'])) {
607
+					$context['linked_calendar_events'][count($context['linked_calendar_events']) - 1]['is_last'] = true;
608
+		}
592 609
 	}
593 610
 
594 611
 	// Create the poll info if it exists.
@@ -661,20 +678,21 @@  discard block
 block discarded – undo
661 678
 				foreach ($guestinfo as $i => $guestvoted)
662 679
 				{
663 680
 					$guestvoted = explode(',', $guestvoted);
664
-					if ($guestvoted[0] == $context['topicinfo']['id_poll'])
665
-						break;
681
+					if ($guestvoted[0] == $context['topicinfo']['id_poll']) {
682
+											break;
683
+					}
666 684
 				}
667 685
 				// Has the poll been reset since guest voted?
668 686
 				if ($pollinfo['reset_poll'] > $guestvoted[1])
669 687
 				{
670 688
 					// Remove the poll info from the cookie to allow guest to vote again
671 689
 					unset($guestinfo[$i]);
672
-					if (!empty($guestinfo))
673
-						$_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo);
674
-					else
675
-						unset($_COOKIE['guest_poll_vote']);
676
-				}
677
-				else
690
+					if (!empty($guestinfo)) {
691
+											$_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo);
692
+					} else {
693
+											unset($_COOKIE['guest_poll_vote']);
694
+					}
695
+				} else
678 696
 				{
679 697
 					// What did they vote for?
680 698
 					unset($guestvoted[0], $guestvoted[1]);
@@ -788,23 +806,29 @@  discard block
 block discarded – undo
788 806
 		// Build the poll moderation button array.
789 807
 		$context['poll_buttons'] = array();
790 808
 
791
-		if ($context['allow_return_vote'])
792
-			$context['poll_buttons']['vote'] = array('text' => 'poll_return_vote', 'image' => 'poll_options.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']);
809
+		if ($context['allow_return_vote']) {
810
+					$context['poll_buttons']['vote'] = array('text' => 'poll_return_vote', 'image' => 'poll_options.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']);
811
+		}
793 812
 
794
-		if ($context['show_view_results_button'])
795
-			$context['poll_buttons']['results'] = array('text' => 'poll_results', 'image' => 'poll_results.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults');
813
+		if ($context['show_view_results_button']) {
814
+					$context['poll_buttons']['results'] = array('text' => 'poll_results', 'image' => 'poll_results.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults');
815
+		}
796 816
 
797
-		if ($context['allow_change_vote'])
798
-			$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']);
817
+		if ($context['allow_change_vote']) {
818
+					$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']);
819
+		}
799 820
 
800
-		if ($context['allow_lock_poll'])
801
-			$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']);
821
+		if ($context['allow_lock_poll']) {
822
+					$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']);
823
+		}
802 824
 
803
-		if ($context['allow_edit_poll'])
804
-			$context['poll_buttons']['edit'] = array('text' => 'poll_edit', 'image' => 'poll_edit.png', 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']);
825
+		if ($context['allow_edit_poll']) {
826
+					$context['poll_buttons']['edit'] = array('text' => 'poll_edit', 'image' => 'poll_edit.png', 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']);
827
+		}
805 828
 
806
-		if ($context['can_remove_poll'])
807
-			$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']);
829
+		if ($context['can_remove_poll']) {
830
+					$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']);
831
+		}
808 832
 
809 833
 		// Allow mods to add additional buttons here
810 834
 		call_integration_hook('integrate_poll_buttons');
@@ -845,8 +869,9 @@  discard block
 block discarded – undo
845 869
 	$all_posters = array();
846 870
 	while ($row = $smcFunc['db_fetch_assoc']($request))
847 871
 	{
848
-		if (!empty($row['id_member']))
849
-			$all_posters[$row['id_msg']] = $row['id_member'];
872
+		if (!empty($row['id_member'])) {
873
+					$all_posters[$row['id_msg']] = $row['id_member'];
874
+		}
850 875
 		$messages[] = $row['id_msg'];
851 876
 	}
852 877
 	$smcFunc['db_free_result']($request);
@@ -858,8 +883,9 @@  discard block
 block discarded – undo
858 883
 	if (!$user_info['is_guest'] && !empty($messages))
859 884
 	{
860 885
 		$mark_at_msg = max($messages);
861
-		if ($mark_at_msg >= $context['topicinfo']['id_last_msg'])
862
-			$mark_at_msg = $modSettings['maxMsgID'];
886
+		if ($mark_at_msg >= $context['topicinfo']['id_last_msg']) {
887
+					$mark_at_msg = $modSettings['maxMsgID'];
888
+		}
863 889
 		if ($mark_at_msg >= $context['topicinfo']['new_from'])
864 890
 		{
865 891
 			$smcFunc['db_insert']($context['topicinfo']['new_from'] == 0 ? 'ignore' : 'replace',
@@ -891,8 +917,9 @@  discard block
 block discarded – undo
891 917
 		while ($row = $smcFunc['db_fetch_assoc']($request))
892 918
 		{
893 919
 			// Find if this topic is marked for notification...
894
-			if (!empty($row['id_topic']))
895
-				$context['is_marked_notify'] = true;
920
+			if (!empty($row['id_topic'])) {
921
+							$context['is_marked_notify'] = true;
922
+			}
896 923
 
897 924
 			// Only do this once, but mark the notifications as "not sent yet" for next time.
898 925
 			if (!empty($row['sent']) && $do_once)
@@ -914,8 +941,9 @@  discard block
 block discarded – undo
914 941
 		}
915 942
 
916 943
 		// Have we recently cached the number of new topics in this board, and it's still a lot?
917
-		if (isset($_REQUEST['topicseen']) && isset($_SESSION['topicseen_cache'][$board]) && $_SESSION['topicseen_cache'][$board] > 5)
918
-			$_SESSION['topicseen_cache'][$board]--;
944
+		if (isset($_REQUEST['topicseen']) && isset($_SESSION['topicseen_cache'][$board]) && $_SESSION['topicseen_cache'][$board] > 5) {
945
+					$_SESSION['topicseen_cache'][$board]--;
946
+		}
919 947
 		// Mark board as seen if this is the only new topic.
920 948
 		elseif (isset($_REQUEST['topicseen']))
921 949
 		{
@@ -939,14 +967,16 @@  discard block
 block discarded – undo
939 967
 			$smcFunc['db_free_result']($request);
940 968
 
941 969
 			// If there're no real new topics in this board, mark the board as seen.
942
-			if (empty($numNewTopics))
943
-				$_REQUEST['boardseen'] = true;
944
-			else
945
-				$_SESSION['topicseen_cache'][$board] = $numNewTopics;
970
+			if (empty($numNewTopics)) {
971
+							$_REQUEST['boardseen'] = true;
972
+			} else {
973
+							$_SESSION['topicseen_cache'][$board] = $numNewTopics;
974
+			}
946 975
 		}
947 976
 		// Probably one less topic - maybe not, but even if we decrease this too fast it will only make us look more often.
948
-		elseif (isset($_SESSION['topicseen_cache'][$board]))
949
-			$_SESSION['topicseen_cache'][$board]--;
977
+		elseif (isset($_SESSION['topicseen_cache'][$board])) {
978
+					$_SESSION['topicseen_cache'][$board]--;
979
+		}
950 980
 
951 981
 		// Mark board as seen if we came using last post link from BoardIndex. (or other places...)
952 982
 		if (isset($_REQUEST['boardseen']))
@@ -1003,23 +1033,26 @@  discard block
 block discarded – undo
1003 1033
 			$temp = array();
1004 1034
 			while ($row = $smcFunc['db_fetch_assoc']($request))
1005 1035
 			{
1006
-				if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id']))
1007
-					continue;
1036
+				if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) {
1037
+									continue;
1038
+				}
1008 1039
 
1009 1040
 				$temp[$row['id_attach']] = $row;
1010 1041
 				$temp[$row['id_attach']]['topic'] = $topic;
1011 1042
 				$temp[$row['id_attach']]['board'] = $board;
1012 1043
 
1013
-				if (!isset($context['loaded_attachments'][$row['id_msg']]))
1014
-					$context['loaded_attachments'][$row['id_msg']] = array();
1044
+				if (!isset($context['loaded_attachments'][$row['id_msg']])) {
1045
+									$context['loaded_attachments'][$row['id_msg']] = array();
1046
+				}
1015 1047
 			}
1016 1048
 			$smcFunc['db_free_result']($request);
1017 1049
 
1018 1050
 			// This is better than sorting it with the query...
1019 1051
 			ksort($temp);
1020 1052
 
1021
-			foreach ($temp as $row)
1022
-				$context['loaded_attachments'][$row['id_msg']][] = $row;
1053
+			foreach ($temp as $row) {
1054
+							$context['loaded_attachments'][$row['id_msg']][] = $row;
1055
+			}
1023 1056
 		}
1024 1057
 
1025 1058
 		$msg_parameters = array(
@@ -1046,21 +1079,23 @@  discard block
 block discarded – undo
1046 1079
 		);
1047 1080
 
1048 1081
 		// And the likes
1049
-		if (!empty($modSettings['enable_likes']))
1050
-			$context['my_likes'] = $context['user']['is_guest'] ? array() : prepareLikesContext($topic);
1082
+		if (!empty($modSettings['enable_likes'])) {
1083
+					$context['my_likes'] = $context['user']['is_guest'] ? array() : prepareLikesContext($topic);
1084
+		}
1051 1085
 
1052 1086
 		// Go to the last message if the given time is beyond the time of the last message.
1053
-		if (isset($context['start_from']) && $context['start_from'] >= $context['topicinfo']['num_replies'])
1054
-			$context['start_from'] = $context['topicinfo']['num_replies'];
1087
+		if (isset($context['start_from']) && $context['start_from'] >= $context['topicinfo']['num_replies']) {
1088
+					$context['start_from'] = $context['topicinfo']['num_replies'];
1089
+		}
1055 1090
 
1056 1091
 		// Since the anchor information is needed on the top of the page we load these variables beforehand.
1057 1092
 		$context['first_message'] = isset($messages[$firstIndex]) ? $messages[$firstIndex] : $messages[0];
1058
-		if (empty($options['view_newest_first']))
1059
-			$context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['start_from'];
1060
-		else
1061
-			$context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['topicinfo']['num_replies'] - $context['start_from'];
1062
-	}
1063
-	else
1093
+		if (empty($options['view_newest_first'])) {
1094
+					$context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['start_from'];
1095
+		} else {
1096
+					$context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['topicinfo']['num_replies'] - $context['start_from'];
1097
+		}
1098
+	} else
1064 1099
 	{
1065 1100
 		$messages_request = false;
1066 1101
 		$context['first_message'] = 0;
@@ -1096,8 +1131,9 @@  discard block
 block discarded – undo
1096 1131
 		'can_see_likes' => 'likes_view',
1097 1132
 		'can_like' => 'likes_like',
1098 1133
 	);
1099
-	foreach ($common_permissions as $contextual => $perm)
1100
-		$context[$contextual] = allowedTo($perm);
1134
+	foreach ($common_permissions as $contextual => $perm) {
1135
+			$context[$contextual] = allowedTo($perm);
1136
+	}
1101 1137
 
1102 1138
 	// Permissions with _any/_own versions.  $context[YYY] => ZZZ_any/_own.
1103 1139
 	$anyown_permissions = array(
@@ -1110,8 +1146,9 @@  discard block
 block discarded – undo
1110 1146
 		'can_reply_unapproved' => 'post_unapproved_replies',
1111 1147
 		'can_view_warning' => 'profile_warning',
1112 1148
 	);
1113
-	foreach ($anyown_permissions as $contextual => $perm)
1114
-		$context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own'));
1149
+	foreach ($anyown_permissions as $contextual => $perm) {
1150
+			$context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own'));
1151
+	}
1115 1152
 
1116 1153
 	if (!$user_info['is_admin'] && !$modSettings['topic_move_any'])
1117 1154
 	{
@@ -1157,8 +1194,9 @@  discard block
 block discarded – undo
1157 1194
 	// Check if the draft functions are enabled and that they have permission to use them (for quick reply.)
1158 1195
 	$context['drafts_save'] = !empty($modSettings['drafts_post_enabled']) && allowedTo('post_draft') && $context['can_reply'];
1159 1196
 	$context['drafts_autosave'] = !empty($context['drafts_save']) && !empty($modSettings['drafts_autosave_enabled']);
1160
-	if (!empty($context['drafts_save']))
1161
-		loadLanguage('Drafts');
1197
+	if (!empty($context['drafts_save'])) {
1198
+			loadLanguage('Drafts');
1199
+	}
1162 1200
 
1163 1201
 	// When was the last time this topic was replied to?  Should we warn them about it?
1164 1202
 	if (!empty($modSettings['oldTopicDays']) && ($context['can_reply'] || $context['can_reply_unapproved']) && empty($context['topicinfo']['is_sticky']))
@@ -1219,26 +1257,31 @@  discard block
 block discarded – undo
1219 1257
 	// Message icons - customized icons are off?
1220 1258
 	$context['icons'] = getMessageIcons($board);
1221 1259
 
1222
-	if (!empty($context['icons']))
1223
-		$context['icons'][count($context['icons']) - 1]['is_last'] = true;
1260
+	if (!empty($context['icons'])) {
1261
+			$context['icons'][count($context['icons']) - 1]['is_last'] = true;
1262
+	}
1224 1263
 
1225 1264
 	// Build the normal button array.
1226 1265
 	$context['normal_buttons'] = array();
1227 1266
 
1228
-	if ($context['can_reply'])
1229
-		$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);
1267
+	if ($context['can_reply']) {
1268
+			$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);
1269
+	}
1230 1270
 
1231
-	if ($context['can_add_poll'])
1232
-		$context['normal_buttons']['add_poll'] = array('text' => 'add_poll', 'image' => 'add_poll.png', 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']);
1271
+	if ($context['can_add_poll']) {
1272
+			$context['normal_buttons']['add_poll'] = array('text' => 'add_poll', 'image' => 'add_poll.png', 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']);
1273
+	}
1233 1274
 
1234
-	if ($context['can_mark_unread'])
1235
-		$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']);
1275
+	if ($context['can_mark_unread']) {
1276
+			$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']);
1277
+	}
1236 1278
 
1237
-	if ($context['can_print'])
1238
-		$context['normal_buttons']['print'] = array('text' => 'print', 'image' => 'print.png', 'custom' => 'rel="nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0');
1279
+	if ($context['can_print']) {
1280
+			$context['normal_buttons']['print'] = array('text' => 'print', 'image' => 'print.png', 'custom' => 'rel="nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0');
1281
+	}
1239 1282
 	
1240
-	if ($context['can_set_notify'])
1241
-		$context['normal_buttons']['notify'] = array(
1283
+	if ($context['can_set_notify']) {
1284
+			$context['normal_buttons']['notify'] = array(
1242 1285
 			'text' => 'notify_topic_' . $context['topic_notification_mode'],
1243 1286
 			'sub_buttons' => array(
1244 1287
 				array(
@@ -1260,38 +1303,47 @@  discard block
 block discarded – undo
1260 1303
 				),
1261 1304
 			),
1262 1305
 		);
1306
+	}
1263 1307
 
1264 1308
 	// Build the mod button array
1265 1309
 	$context['mod_buttons'] = array();
1266 1310
 
1267
-	if ($context['can_move'])
1268
-		$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');
1311
+	if ($context['can_move']) {
1312
+			$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');
1313
+	}
1269 1314
 
1270
-	if ($context['can_delete'])
1271
-		$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']);
1315
+	if ($context['can_delete']) {
1316
+			$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']);
1317
+	}
1272 1318
 
1273
-	if ($context['can_lock'])
1274
-		$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']);
1319
+	if ($context['can_lock']) {
1320
+			$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']);
1321
+	}
1275 1322
 
1276
-	if ($context['can_sticky'])
1277
-		$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']);
1323
+	if ($context['can_sticky']) {
1324
+			$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']);
1325
+	}
1278 1326
 
1279
-	if ($context['can_merge'])
1280
-		$context['mod_buttons']['merge'] = array('text' => 'merge', 'image' => 'merge.png', 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']);
1327
+	if ($context['can_merge']) {
1328
+			$context['mod_buttons']['merge'] = array('text' => 'merge', 'image' => 'merge.png', 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']);
1329
+	}
1281 1330
 
1282
-	if ($context['calendar_post'])
1283
-		$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');
1331
+	if ($context['calendar_post']) {
1332
+			$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');
1333
+	}
1284 1334
 
1285 1335
 	// Restore topic. eh?  No monkey business.
1286
-	if ($context['can_restore_topic'])
1287
-		$context['mod_buttons']['restore_topic'] = array('text' => 'restore_topic', 'image' => '', 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']);
1336
+	if ($context['can_restore_topic']) {
1337
+			$context['mod_buttons']['restore_topic'] = array('text' => 'restore_topic', 'image' => '', 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']);
1338
+	}
1288 1339
 
1289 1340
 	// Show a message in case a recently posted message became unapproved.
1290 1341
 	$context['becomesUnapproved'] = !empty($_SESSION['becomesUnapproved']) ? true : false;
1291 1342
 
1292 1343
 	// Don't want to show this forever...
1293
-	if ($context['becomesUnapproved'])
1294
-		unset($_SESSION['becomesUnapproved']);
1344
+	if ($context['becomesUnapproved']) {
1345
+			unset($_SESSION['becomesUnapproved']);
1346
+	}
1295 1347
 
1296 1348
 	// Allow adding new mod buttons easily.
1297 1349
 	// Note: $context['normal_buttons'] and $context['mod_buttons'] are added for backward compatibility with 2.0, but are deprecated and should not be used
@@ -1300,12 +1352,14 @@  discard block
 block discarded – undo
1300 1352
 	call_integration_hook('integrate_mod_buttons', array(&$context['mod_buttons']));
1301 1353
 
1302 1354
 	// Load the drafts js file
1303
-	if ($context['drafts_autosave'])
1304
-		loadJavaScriptFile('drafts.js', array('defer' => false), 'smf_drafts');
1355
+	if ($context['drafts_autosave']) {
1356
+			loadJavaScriptFile('drafts.js', array('defer' => false), 'smf_drafts');
1357
+	}
1305 1358
 
1306 1359
 	// Spellcheck
1307
-	if ($context['show_spellchecking'])
1308
-		loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck');
1360
+	if ($context['show_spellchecking']) {
1361
+			loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck');
1362
+	}
1309 1363
 
1310 1364
 	// topic.js
1311 1365
 	loadJavaScriptFile('topic.js', array('defer' => false), 'smf_topic');
@@ -1339,16 +1393,19 @@  discard block
 block discarded – undo
1339 1393
 	static $counter = null;
1340 1394
 
1341 1395
 	// If the query returned false, bail.
1342
-	if ($messages_request == false)
1343
-		return false;
1396
+	if ($messages_request == false) {
1397
+			return false;
1398
+	}
1344 1399
 
1345 1400
 	// Remember which message this is.  (ie. reply #83)
1346
-	if ($counter === null || $reset)
1347
-		$counter = empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start'];
1401
+	if ($counter === null || $reset) {
1402
+			$counter = empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start'];
1403
+	}
1348 1404
 
1349 1405
 	// Start from the beginning...
1350
-	if ($reset)
1351
-		return @$smcFunc['db_data_seek']($messages_request, 0);
1406
+	if ($reset) {
1407
+			return @$smcFunc['db_data_seek']($messages_request, 0);
1408
+	}
1352 1409
 
1353 1410
 	// Attempt to get the next message.
1354 1411
 	$message = $smcFunc['db_fetch_assoc']($messages_request);
@@ -1362,19 +1419,21 @@  discard block
 block discarded – undo
1362 1419
 	if (empty($context['icon_sources']))
1363 1420
 	{
1364 1421
 		$context['icon_sources'] = array();
1365
-		foreach ($context['stable_icons'] as $icon)
1366
-			$context['icon_sources'][$icon] = 'images_url';
1422
+		foreach ($context['stable_icons'] as $icon) {
1423
+					$context['icon_sources'][$icon] = 'images_url';
1424
+		}
1367 1425
 	}
1368 1426
 
1369 1427
 	// Message Icon Management... check the images exist.
1370 1428
 	if (empty($modSettings['messageIconChecks_disable']))
1371 1429
 	{
1372 1430
 		// If the current icon isn't known, then we need to do something...
1373
-		if (!isset($context['icon_sources'][$message['icon']]))
1374
-			$context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url';
1431
+		if (!isset($context['icon_sources'][$message['icon']])) {
1432
+					$context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url';
1433
+		}
1434
+	} elseif (!isset($context['icon_sources'][$message['icon']])) {
1435
+			$context['icon_sources'][$message['icon']] = 'images_url';
1375 1436
 	}
1376
-	elseif (!isset($context['icon_sources'][$message['icon']]))
1377
-		$context['icon_sources'][$message['icon']] = 'images_url';
1378 1437
 
1379 1438
 	// If you're a lazy bum, you probably didn't give a subject...
1380 1439
 	$message['subject'] = $message['subject'] != '' ? $message['subject'] : $txt['no_subject'];
@@ -1399,8 +1458,7 @@  discard block
 block discarded – undo
1399 1458
 		$memberContext[$message['id_member']]['email'] = $message['poster_email'];
1400 1459
 		$memberContext[$message['id_member']]['show_email'] = allowedTo('moderate_forum');
1401 1460
 		$memberContext[$message['id_member']]['is_guest'] = true;
1402
-	}
1403
-	else
1461
+	} else
1404 1462
 	{
1405 1463
 		// Define this here to make things a bit more readable
1406 1464
 		$can_view_warning = $context['user']['can_mod'] || allowedTo('view_warning_any') || ($message['id_member'] == $user_info['id'] && allowedTo('view_warning_own'));
@@ -1423,8 +1481,9 @@  discard block
 block discarded – undo
1423 1481
 	$message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']);
1424 1482
 
1425 1483
 	// If it's in the recycle bin we need to override whatever icon we did have.
1426
-	if (!empty($board_info['recycle']))
1427
-		$message['icon'] = 'recycled';
1484
+	if (!empty($board_info['recycle'])) {
1485
+			$message['icon'] = 'recycled';
1486
+	}
1428 1487
 
1429 1488
 	require_once($sourcedir . '/Subs-Attachments.php');
1430 1489
 
@@ -1468,32 +1527,36 @@  discard block
 block discarded – undo
1468 1527
 	}
1469 1528
 
1470 1529
 	// Are likes enable?
1471
-	if (!empty($modSettings['enable_likes']))
1472
-		$output['likes'] = array(
1530
+	if (!empty($modSettings['enable_likes'])) {
1531
+			$output['likes'] = array(
1473 1532
 			'count' => $message['likes'],
1474 1533
 			'you' => in_array($message['id_msg'], $context['my_likes']),
1475 1534
 			'can_like' => !$context['user']['is_guest'] && $message['id_member'] != $context['user']['id'] && !empty($context['can_like']),
1476 1535
 		);
1536
+	}
1477 1537
 
1478 1538
 	// Is this user the message author?
1479 1539
 	$output['is_message_author'] = $message['id_member'] == $user_info['id'];
1480
-	if (!empty($output['modified']['name']))
1481
-		$output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], $output['modified']['name']);
1540
+	if (!empty($output['modified']['name'])) {
1541
+			$output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], $output['modified']['name']);
1542
+	}
1482 1543
 
1483 1544
 	// Did they give a reason for editing?
1484
-	if (!empty($output['modified']['name']) && !empty($output['modified']['reason']))
1485
-		$output['modified']['last_edit_text'] .= '&nbsp;' . sprintf($txt['last_edit_reason'], $output['modified']['reason']);
1545
+	if (!empty($output['modified']['name']) && !empty($output['modified']['reason'])) {
1546
+			$output['modified']['last_edit_text'] .= '&nbsp;' . sprintf($txt['last_edit_reason'], $output['modified']['reason']);
1547
+	}
1486 1548
 
1487 1549
 	// Any custom profile fields?
1488
-	if (!empty($memberContext[$message['id_member']]['custom_fields']))
1489
-		foreach ($memberContext[$message['id_member']]['custom_fields'] as $custom)
1550
+	if (!empty($memberContext[$message['id_member']]['custom_fields'])) {
1551
+			foreach ($memberContext[$message['id_member']]['custom_fields'] as $custom)
1490 1552
 			$output['custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom;
1553
+	}
1491 1554
 
1492
-	if (empty($options['view_newest_first']))
1493
-		$counter++;
1494
-
1495
-	else
1496
-		$counter--;
1555
+	if (empty($options['view_newest_first'])) {
1556
+			$counter++;
1557
+	} else {
1558
+			$counter--;
1559
+	}
1497 1560
 
1498 1561
 	call_integration_hook('integrate_prepare_display_context', array(&$output, &$message, $counter));
1499 1562
 
@@ -1519,21 +1582,23 @@  discard block
 block discarded – undo
1519 1582
 	$context['no_last_modified'] = true;
1520 1583
 
1521 1584
 	// Prevent a preview image from being displayed twice.
1522
-	if (isset($_GET['action']) && $_GET['action'] == 'dlattach' && isset($_GET['type']) && ($_GET['type'] == 'avatar' || $_GET['type'] == 'preview'))
1523
-		return;
1585
+	if (isset($_GET['action']) && $_GET['action'] == 'dlattach' && isset($_GET['type']) && ($_GET['type'] == 'avatar' || $_GET['type'] == 'preview')) {
1586
+			return;
1587
+	}
1524 1588
 
1525 1589
 	// Make sure some attachment was requested!
1526
-	if (!isset($_REQUEST['attach']) && !isset($_REQUEST['id']))
1527
-		fatal_lang_error('no_access', false);
1590
+	if (!isset($_REQUEST['attach']) && !isset($_REQUEST['id'])) {
1591
+			fatal_lang_error('no_access', false);
1592
+	}
1528 1593
 
1529 1594
 	$_REQUEST['attach'] = isset($_REQUEST['attach']) ? (int) $_REQUEST['attach'] : (int) $_REQUEST['id'];
1530 1595
 
1531 1596
 	// Do we have a hook wanting to use our attachment system? We use $attachRequest to prevent accidental usage of $request.
1532 1597
 	$attachRequest = null;
1533 1598
 	call_integration_hook('integrate_download_request', array(&$attachRequest));
1534
-	if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest))
1535
-		$request = $attachRequest;
1536
-	else
1599
+	if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) {
1600
+			$request = $attachRequest;
1601
+	} else
1537 1602
 	{
1538 1603
 		// This checks only the current board for $board/$topic's permissions.
1539 1604
 		isAllowedTo('view_attachments');
@@ -1554,19 +1619,21 @@  discard block
 block discarded – undo
1554 1619
 		);
1555 1620
 	}
1556 1621
 
1557
-	if ($smcFunc['db_num_rows']($request) == 0)
1558
-		fatal_lang_error('no_access', false);
1622
+	if ($smcFunc['db_num_rows']($request) == 0) {
1623
+			fatal_lang_error('no_access', false);
1624
+	}
1559 1625
 
1560 1626
 	list ($id_folder, $real_filename, $file_hash, $file_ext, $id_attach, $attachment_type, $mime_type, $is_approved, $id_member) = $smcFunc['db_fetch_row']($request);
1561 1627
 	$smcFunc['db_free_result']($request);
1562 1628
 
1563 1629
 	// If it isn't yet approved, do they have permission to view it?
1564
-	if (!$is_approved && ($id_member == 0 || $user_info['id'] != $id_member) && ($attachment_type == 0 || $attachment_type == 3))
1565
-		isAllowedTo('approve_posts');
1630
+	if (!$is_approved && ($id_member == 0 || $user_info['id'] != $id_member) && ($attachment_type == 0 || $attachment_type == 3)) {
1631
+			isAllowedTo('approve_posts');
1632
+	}
1566 1633
 
1567 1634
 	// Update the download counter (unless it's a thumbnail).
1568
-	if ($attachment_type != 3)
1569
-		$smcFunc['db_query']('attach_download_increase', '
1635
+	if ($attachment_type != 3) {
1636
+			$smcFunc['db_query']('attach_download_increase', '
1570 1637
 			UPDATE LOW_PRIORITY {db_prefix}attachments
1571 1638
 			SET downloads = downloads + 1
1572 1639
 			WHERE id_attach = {int:id_attach}',
@@ -1574,15 +1641,15 @@  discard block
 block discarded – undo
1574 1641
 				'id_attach' => $id_attach,
1575 1642
 			)
1576 1643
 		);
1644
+	}
1577 1645
 
1578 1646
 	$filename = getAttachmentFilename($real_filename, $_REQUEST['attach'], $id_folder, false, $file_hash);
1579 1647
 
1580 1648
 	// This is done to clear any output that was made before now.
1581 1649
 	ob_end_clean();
1582
-	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')))
1583
-		@ob_start('ob_gzhandler');
1584
-
1585
-	else
1650
+	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'))) {
1651
+			@ob_start('ob_gzhandler');
1652
+	} else
1586 1653
 	{
1587 1654
 		ob_start();
1588 1655
 		header('Content-Encoding: none');
@@ -1625,8 +1692,9 @@  discard block
 block discarded – undo
1625 1692
 	// Send the attachment headers.
1626 1693
 	header('Pragma: ');
1627 1694
 
1628
-	if (!isBrowser('gecko'))
1629
-		header('Content-Transfer-Encoding: binary');
1695
+	if (!isBrowser('gecko')) {
1696
+			header('Content-Transfer-Encoding: binary');
1697
+	}
1630 1698
 
1631 1699
 	header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT');
1632 1700
 	header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($filename)) . ' GMT');
@@ -1635,18 +1703,19 @@  discard block
 block discarded – undo
1635 1703
 	header('ETag: ' . $eTag);
1636 1704
 
1637 1705
 	// Make sure the mime type warrants an inline display.
1638
-	if (isset($_REQUEST['image']) && !empty($mime_type) && strpos($mime_type, 'image/') !== 0)
1639
-		unset($_REQUEST['image']);
1706
+	if (isset($_REQUEST['image']) && !empty($mime_type) && strpos($mime_type, 'image/') !== 0) {
1707
+			unset($_REQUEST['image']);
1708
+	}
1640 1709
 
1641 1710
 	// Does this have a mime type?
1642
-	elseif (!empty($mime_type) && (isset($_REQUEST['image']) || !in_array($file_ext, array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff'))))
1643
-		header('Content-Type: ' . strtr($mime_type, array('image/bmp' => 'image/x-ms-bmp')));
1644
-
1645
-	else
1711
+	elseif (!empty($mime_type) && (isset($_REQUEST['image']) || !in_array($file_ext, array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) {
1712
+			header('Content-Type: ' . strtr($mime_type, array('image/bmp' => 'image/x-ms-bmp')));
1713
+	} else
1646 1714
 	{
1647 1715
 		header('Content-Type: ' . (isBrowser('ie') || isBrowser('opera') ? 'application/octetstream' : 'application/octet-stream'));
1648
-		if (isset($_REQUEST['image']))
1649
-			unset($_REQUEST['image']);
1716
+		if (isset($_REQUEST['image'])) {
1717
+					unset($_REQUEST['image']);
1718
+		}
1650 1719
 	}
1651 1720
 
1652 1721
 	// Convert the file to UTF-8, cuz most browsers dig that.
@@ -1654,23 +1723,22 @@  discard block
 block discarded – undo
1654 1723
 	$disposition = !isset($_REQUEST['image']) ? 'attachment' : 'inline';
1655 1724
 
1656 1725
 	// Different browsers like different standards...
1657
-	if (isBrowser('firefox'))
1658
-		header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)));
1659
-
1660
-	elseif (isBrowser('opera'))
1661
-		header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"');
1662
-
1663
-	elseif (isBrowser('ie'))
1664
-		header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"');
1665
-
1666
-	else
1667
-		header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"');
1726
+	if (isBrowser('firefox')) {
1727
+			header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)));
1728
+	} elseif (isBrowser('opera')) {
1729
+			header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"');
1730
+	} elseif (isBrowser('ie')) {
1731
+			header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"');
1732
+	} else {
1733
+			header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"');
1734
+	}
1668 1735
 
1669 1736
 	// If this has an "image extension" - but isn't actually an image - then ensure it isn't cached cause of silly IE.
1670
-	if (!isset($_REQUEST['image']) && in_array($file_ext, array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff')))
1671
-		header('Cache-Control: no-cache');
1672
-	else
1673
-		header('Cache-Control: max-age=' . (525600 * 60) . ', private');
1737
+	if (!isset($_REQUEST['image']) && in_array($file_ext, array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) {
1738
+			header('Cache-Control: no-cache');
1739
+	} else {
1740
+			header('Cache-Control: max-age=' . (525600 * 60) . ', private');
1741
+	}
1674 1742
 
1675 1743
 	header('Content-Length: ' . filesize($filename));
1676 1744
 
@@ -1680,20 +1748,23 @@  discard block
 block discarded – undo
1680 1748
 	// Recode line endings for text files, if enabled.
1681 1749
 	if (!empty($modSettings['attachmentRecodeLineEndings']) && !isset($_REQUEST['image']) && in_array($file_ext, array('txt', 'css', 'htm', 'html', 'php', 'xml')))
1682 1750
 	{
1683
-		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== false)
1684
-			$callback = function ($buffer)
1751
+		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== false) {
1752
+					$callback = function ($buffer)
1685 1753
 			{
1686 1754
 				return preg_replace('~[\r]?\n~', "\r\n", $buffer);
1755
+		}
1687 1756
 			};
1688
-		elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false)
1689
-			$callback = function ($buffer)
1757
+		elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
1758
+					$callback = function ($buffer)
1690 1759
 			{
1691 1760
 				return preg_replace('~[\r]?\n~', "\r", $buffer);
1761
+		}
1692 1762
 			};
1693
-		else
1694
-			$callback = function ($buffer)
1763
+		else {
1764
+					$callback = function ($buffer)
1695 1765
 			{
1696 1766
 				return preg_replace('~[\r]?\n~', "\n", $buffer);
1767
+		}
1697 1768
 			};
1698 1769
 	}
1699 1770
 
@@ -1701,23 +1772,26 @@  discard block
 block discarded – undo
1701 1772
 	if (filesize($filename) > 4194304)
1702 1773
 	{
1703 1774
 		// Forcibly end any output buffering going on.
1704
-		while (@ob_get_level() > 0)
1705
-			@ob_end_clean();
1775
+		while (@ob_get_level() > 0) {
1776
+					@ob_end_clean();
1777
+		}
1706 1778
 
1707 1779
 		$fp = fopen($filename, 'rb');
1708 1780
 		while (!feof($fp))
1709 1781
 		{
1710
-			if (isset($callback))
1711
-				echo $callback(fread($fp, 8192));
1712
-			else
1713
-				echo fread($fp, 8192);
1782
+			if (isset($callback)) {
1783
+							echo $callback(fread($fp, 8192));
1784
+			} else {
1785
+							echo fread($fp, 8192);
1786
+			}
1714 1787
 			flush();
1715 1788
 		}
1716 1789
 		fclose($fp);
1717 1790
 	}
1718 1791
 	// 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.
1719
-	elseif (isset($callback) || @readfile($filename) === null)
1720
-		echo isset($callback) ? $callback(file_get_contents($filename)) : file_get_contents($filename);
1792
+	elseif (isset($callback) || @readfile($filename) === null) {
1793
+			echo isset($callback) ? $callback(file_get_contents($filename)) : file_get_contents($filename);
1794
+	}
1721 1795
 
1722 1796
 	obExit(false);
1723 1797
 }
@@ -1730,8 +1804,9 @@  discard block
 block discarded – undo
1730 1804
  */
1731 1805
 function approved_attach_sort($a, $b)
1732 1806
 {
1733
-	if ($a['is_approved'] == $b['is_approved'])
1734
-		return 0;
1807
+	if ($a['is_approved'] == $b['is_approved']) {
1808
+			return 0;
1809
+	}
1735 1810
 
1736 1811
 	return $a['is_approved'] > $b['is_approved'] ? -1 : 1;
1737 1812
 }
@@ -1748,16 +1823,19 @@  discard block
 block discarded – undo
1748 1823
 
1749 1824
 	require_once($sourcedir . '/RemoveTopic.php');
1750 1825
 
1751
-	if (empty($_REQUEST['msgs']))
1752
-		redirectexit('topic=' . $topic . '.' . $_REQUEST['start']);
1826
+	if (empty($_REQUEST['msgs'])) {
1827
+			redirectexit('topic=' . $topic . '.' . $_REQUEST['start']);
1828
+	}
1753 1829
 
1754 1830
 	$messages = array();
1755
-	foreach ($_REQUEST['msgs'] as $dummy)
1756
-		$messages[] = (int) $dummy;
1831
+	foreach ($_REQUEST['msgs'] as $dummy) {
1832
+			$messages[] = (int) $dummy;
1833
+	}
1757 1834
 
1758 1835
 	// We are restoring messages. We handle this in another place.
1759
-	if (isset($_REQUEST['restore_selected']))
1760
-		redirectexit('action=restoretopic;msgs=' . implode(',', $messages) . ';' . $context['session_var'] . '=' . $context['session_id']);
1836
+	if (isset($_REQUEST['restore_selected'])) {
1837
+			redirectexit('action=restoretopic;msgs=' . implode(',', $messages) . ';' . $context['session_var'] . '=' . $context['session_id']);
1838
+	}
1761 1839
 	if (isset($_REQUEST['split_selection']))
1762 1840
 	{
1763 1841
 		$request = $smcFunc['db_query']('', '
@@ -1776,8 +1854,9 @@  discard block
 block discarded – undo
1776 1854
 	}
1777 1855
 
1778 1856
 	// Allowed to delete any message?
1779
-	if (allowedTo('delete_any'))
1780
-		$allowed_all = true;
1857
+	if (allowedTo('delete_any')) {
1858
+			$allowed_all = true;
1859
+	}
1781 1860
 	// Allowed to delete replies to their messages?
1782 1861
 	elseif (allowedTo('delete_replies'))
1783 1862
 	{
@@ -1794,13 +1873,14 @@  discard block
 block discarded – undo
1794 1873
 		$smcFunc['db_free_result']($request);
1795 1874
 
1796 1875
 		$allowed_all = $starter == $user_info['id'];
1876
+	} else {
1877
+			$allowed_all = false;
1797 1878
 	}
1798
-	else
1799
-		$allowed_all = false;
1800 1879
 
1801 1880
 	// Make sure they're allowed to delete their own messages, if not any.
1802
-	if (!$allowed_all)
1803
-		isAllowedTo('delete_own');
1881
+	if (!$allowed_all) {
1882
+			isAllowedTo('delete_own');
1883
+	}
1804 1884
 
1805 1885
 	// Allowed to remove which messages?
1806 1886
 	$request = $smcFunc['db_query']('', '
@@ -1820,8 +1900,9 @@  discard block
 block discarded – undo
1820 1900
 	$messages = array();
1821 1901
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1822 1902
 	{
1823
-		if (!$allowed_all && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time())
1824
-			continue;
1903
+		if (!$allowed_all && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) {
1904
+					continue;
1905
+		}
1825 1906
 
1826 1907
 		$messages[$row['id_msg']] = array($row['subject'], $row['id_member']);
1827 1908
 	}
@@ -1844,17 +1925,20 @@  discard block
 block discarded – undo
1844 1925
 	foreach ($messages as $message => $info)
1845 1926
 	{
1846 1927
 		// Just skip the first message - if it's not the last.
1847
-		if ($message == $first_message && $message != $last_message)
1848
-			continue;
1928
+		if ($message == $first_message && $message != $last_message) {
1929
+					continue;
1930
+		}
1849 1931
 		// If the first message is going then don't bother going back to the topic as we're effectively deleting it.
1850
-		elseif ($message == $first_message)
1851
-			$topicGone = true;
1932
+		elseif ($message == $first_message) {
1933
+					$topicGone = true;
1934
+		}
1852 1935
 
1853 1936
 		removeMessage($message);
1854 1937
 
1855 1938
 		// Log this moderation action ;).
1856
-		if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id']))
1857
-			logAction('delete', array('topic' => $topic, 'subject' => $info[0], 'member' => $info[1], 'board' => $board));
1939
+		if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) {
1940
+					logAction('delete', array('topic' => $topic, 'subject' => $info[0], 'member' => $info[1], 'board' => $board));
1941
+		}
1858 1942
 	}
1859 1943
 
1860 1944
 	redirectexit(!empty($topicGone) ? 'board=' . $board : 'topic=' . $topic . '.' . $_REQUEST['start']);
Please login to merge, or discard this patch.
Themes/index.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,8 @@
 block discarded – undo
10 10
 	header('Location: ' . $boardurl);
11 11
 }
12 12
 // Can't find it... just forget it.
13
-else
13
+else {
14 14
 	exit;
15
+}
15 16
 
16 17
 ?>
17 18
\ No newline at end of file
Please login to merge, or discard this patch.
Themes/default/ManageMaintenance.template.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 		</div>
286 286
 		<div class="cat_bar">
287 287
 			<h3 class="catbg">
288
-				<a href="', $scripturl, '?action=helpadmin;help=maintenance_members" onclick="return reqOverlayDiv(this.href);" class="help"><span class="generic_icons help" title="', $txt['help'],'"></span></a> ', $txt['maintain_members'], '
288
+				<a href="', $scripturl, '?action=helpadmin;help=maintenance_members" onclick="return reqOverlayDiv(this.href);" class="help"><span class="generic_icons help" title="', $txt['help'], '"></span></a> ', $txt['maintain_members'], '
289 289
 			</h3>
290 290
 		</div>
291 291
 		<div class="windowbg2 noup">
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 	echo '
437 437
 						</div>
438 438
 					</div>
439
-					<input type="submit" value="', $txt['maintain_old_remove'] ,'" data-confirm="', $txt['maintain_old_confirm'] ,'" class="button_submit you_sure">
439
+					<input type="submit" value="', $txt['maintain_old_remove'], '" data-confirm="', $txt['maintain_old_confirm'], '" class="button_submit you_sure">
440 440
 					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
441 441
 					<input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '">
442 442
 				</form>
Please login to merge, or discard this patch.
Braces   +36 added lines, -25 removed lines patch added patch discarded remove patch
@@ -18,11 +18,12 @@  discard block
 block discarded – undo
18 18
 	global $context, $txt, $scripturl, $modSettings;
19 19
 
20 20
 	// If maintenance has finished tell the user.
21
-	if (!empty($context['maintenance_finished']))
22
-		echo '
21
+	if (!empty($context['maintenance_finished'])) {
22
+			echo '
23 23
 			<div class="infobox">
24 24
 				', sprintf($txt['maintain_done'], $context['maintenance_finished']), '
25 25
 			</div>';
26
+	}
26 27
 
27 28
 	echo '
28 29
 	<div id="manage_maintenance">
@@ -107,11 +108,12 @@  discard block
 block discarded – undo
107 108
 	<div id="manage_maintenance">';
108 109
 
109 110
 	// If maintenance has finished tell the user.
110
-	if (!empty($context['maintenance_finished']))
111
-		echo '
111
+	if (!empty($context['maintenance_finished'])) {
112
+			echo '
112 113
 			<div class="infobox">
113 114
 				', sprintf($txt['maintain_done'], $context['maintenance_finished']), '
114 115
 			</div>';
116
+	}
115 117
 
116 118
 	echo '
117 119
 		<div class="cat_bar">
@@ -238,11 +240,12 @@  discard block
 block discarded – undo
238 240
 	<div id="manage_maintenance">';
239 241
 
240 242
 	// If maintenance has finished tell the user.
241
-	if (!empty($context['maintenance_finished']))
242
-	echo '
243
+	if (!empty($context['maintenance_finished'])) {
244
+		echo '
243 245
 		<div class="infobox">
244 246
 			', sprintf($txt['maintain_done'], $context['maintenance_finished']), '
245 247
 		</div>';
248
+	}
246 249
 
247 250
 	echo '
248 251
 		<div class="cat_bar">
@@ -300,9 +303,10 @@  discard block
 block discarded – undo
300 303
 				<p><a href="#membersLink" onclick="swapMembers();"><img src="', $settings['images_url'], '/selected.png" alt="+" id="membersIcon"></a> <a href="#membersLink" onclick="swapMembers();" id="membersText" style="font-weight: bold;">', $txt['maintain_members_all'], '</a></p>
301 304
 				<div style="display: none; padding: 3px" id="membersPanel">';
302 305
 
303
-	foreach ($context['membergroups'] as $group)
304
-		echo '
306
+	foreach ($context['membergroups'] as $group) {
307
+			echo '
305 308
 					<label for="groups', $group['id'], '"><input type="checkbox" name="groups[', $group['id'], ']" id="groups', $group['id'], '" checked class="input_check"> ', $group['name'], '</label><br>';
309
+	}
306 310
 
307 311
 	echo '
308 312
 				</div>
@@ -346,11 +350,12 @@  discard block
 block discarded – undo
346 350
 	global $scripturl, $txt, $context, $settings, $modSettings;
347 351
 
348 352
 	// If maintenance has finished tell the user.
349
-	if (!empty($context['maintenance_finished']))
350
-		echo '
353
+	if (!empty($context['maintenance_finished'])) {
354
+			echo '
351 355
 			<div class="infobox">
352 356
 				', sprintf($txt['maintain_done'], $context['maintenance_finished']), '
353 357
 			</div>';
358
+	}
354 359
 
355 360
 	// Bit of javascript for showing which boards to prune in an otherwise hidden list.
356 361
 	echo '
@@ -418,19 +423,21 @@  discard block
 block discarded – undo
418 423
 								<ul>';
419 424
 
420 425
 		// Display a checkbox with every board.
421
-		foreach ($category['boards'] as $board)
422
-			echo '
426
+		foreach ($category['boards'] as $board) {
427
+					echo '
423 428
 									<li style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'] * 1.5, 'em;"><label for="boards_', $board['id'], '"><input type="checkbox" name="boards[', $board['id'], ']" id="boards_', $board['id'], '" checked class="input_check">', $board['name'], '</label></li>';
429
+		}
424 430
 
425 431
 		echo '
426 432
 								</ul>
427 433
 							</fieldset>';
428 434
 
429 435
 		// Increase $i, and check if we're at the middle yet.
430
-		if (++$i == $middle)
431
-			echo '
436
+		if (++$i == $middle) {
437
+					echo '
432 438
 						</div>
433 439
 						<div class="floatright" style="width: 49%;">';
440
+		}
434 441
 	}
435 442
 
436 443
 	echo '
@@ -469,9 +476,10 @@  discard block
 block discarded – undo
469 476
 		echo '
470 477
 					<optgroup label="', $category['name'], '">';
471 478
 
472
-		foreach ($category['boards'] as $board)
473
-			echo '
479
+		foreach ($category['boards'] as $board) {
480
+					echo '
474 481
 						<option value="', $board['id'], '"> ', str_repeat('==', $board['child_level']), '=&gt;&nbsp;', $board['name'], '</option>';
482
+		}
475 483
 
476 484
 		echo '
477 485
 					</optgroup>';
@@ -489,9 +497,10 @@  discard block
 block discarded – undo
489 497
 		echo '
490 498
 					<optgroup label="', $category['name'], '">';
491 499
 
492
-		foreach ($category['boards'] as $board)
493
-			echo '
500
+		foreach ($category['boards'] as $board) {
501
+					echo '
494 502
 						<option value="', $board['id'], '"> ', str_repeat('==', $board['child_level']), '=&gt;&nbsp;', $board['name'], '</option>';
503
+		}
495 504
 
496 505
 		echo '
497 506
 					</optgroup>';
@@ -531,9 +540,10 @@  discard block
 block discarded – undo
531 540
 				', $txt['database_optimize_attempt'], '<br>';
532 541
 
533 542
 	// List each table being optimized...
534
-	foreach ($context['optimized_tables'] as $table)
535
-		echo '
543
+	foreach ($context['optimized_tables'] as $table) {
544
+			echo '
536 545
 				', sprintf($txt['database_optimizing'], $table['name'], $table['data_freed']), '<br>';
546
+	}
537 547
 
538 548
 	// How did we go?
539 549
 	echo '
@@ -590,13 +600,14 @@  discard block
 block discarded – undo
590 600
 				', implode('</li><li>', $context['exceeding_messages']), '
591 601
 				</li>
592 602
 			</ul>';
593
-		if (!empty($context['exceeding_messages_morethan']))
594
-			echo '
603
+		if (!empty($context['exceeding_messages_morethan'])) {
604
+					echo '
595 605
 			<p>', $context['exceeding_messages_morethan'], '</p>';
596
-	}
597
-	else
598
-		echo '
606
+		}
607
+	} else {
608
+			echo '
599 609
 			<p class="infobox">', $txt['convert_to_text'], '</p>';
610
+	}
600 611
 
601 612
 	echo '
602 613
 			<form action="', $scripturl, '?action=admin;area=maintain;sa=database;activity=convertmsgbody" method="post" accept-charset="', $context['character_set'], '">
Please login to merge, or discard this patch.