Completed
Branch release-2.1 (3c29ac)
by Mathias
08:54
created
Sources/ReportedContent.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 	// Get the report details.
188 188
 	$report = getReportDetails($report_id);
189 189
 
190
-	if(!$report)
190
+	if (!$report)
191 191
 		fatal_lang_error('mc_no_modreport_found');
192 192
 
193 193
 	// Build the report data - basic details first, then extra stuff based on the type
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 	if ($context['report_type'] == 'members')
251 251
 	{
252 252
 		// Find their ID in the serialized action string...
253
-		$user_id_length = strlen((string)$context['report']['user']['id']);
253
+		$user_id_length = strlen((string) $context['report']['user']['id']);
254 254
 		$member = 's:6:"member";s:' . $user_id_length . ':"' . $context['report']['user']['id'] . '";}';
255 255
 
256 256
 		$params = array(
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
 	// What are we gonna do?
530 530
 	$action = isset($_GET['ignore']) ? 'ignore' : 'closed';
531 531
 
532
-	validateToken('mod-report-'. $action, 'get');
532
+	validateToken('mod-report-' . $action, 'get');
533 533
 
534 534
 	// Are we ignore or "un-ignore"? "un-ignore" that's a funny word!
535 535
 	$value = (int) $_GET[$action];
Please login to merge, or discard this patch.
Braces   +61 added lines, -46 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Sets and call a function based on the given subaction. Acts as a dispatcher function.
@@ -54,8 +55,9 @@  discard block
 block discarded – undo
54 55
 	);
55 56
 
56 57
 	// This comes under the umbrella of moderating posts.
57
-	if ($context['report_type'] == 'members' || $user_info['mod_cache']['bq'] == '0=1')
58
-		isAllowedTo('moderate_forum');
58
+	if ($context['report_type'] == 'members' || $user_info['mod_cache']['bq'] == '0=1') {
59
+			isAllowedTo('moderate_forum');
60
+	}
59 61
 
60 62
 	$subActions = array(
61 63
 		'show' => 'ShowReports',
@@ -70,11 +72,11 @@  discard block
 block discarded – undo
70 72
 	call_integration_hook('integrate_reported_' . $context['report_type'], array(&$subActions));
71 73
 
72 74
 	// By default we call the open sub-action.
73
-	if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]))
74
-		$context['sub_action'] = $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_REQUEST['sa']), ENT_QUOTES);
75
-
76
-	else
77
-		$context['sub_action'] = 'show';
75
+	if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) {
76
+			$context['sub_action'] = $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_REQUEST['sa']), ENT_QUOTES);
77
+	} else {
78
+			$context['sub_action'] = 'show';
79
+	}
78 80
 
79 81
 	// Hi Ho Silver Away!
80 82
 	call_helper($subActions[$context['sub_action']]);
@@ -116,11 +118,13 @@  discard block
 block discarded – undo
116 118
 
117 119
 		// All the ones to update...
118 120
 		$toClose = array();
119
-		foreach ($_POST['close'] as $rid)
120
-			$toClose[] = (int) $rid;
121
+		foreach ($_POST['close'] as $rid) {
122
+					$toClose[] = (int) $rid;
123
+		}
121 124
 
122
-		if (!empty($toClose))
123
-			updateReport('closed', 1, $toClose);
125
+		if (!empty($toClose)) {
126
+					updateReport('closed', 1, $toClose);
127
+		}
124 128
 
125 129
 		// Set the confirmation message.
126 130
 		$_SESSION['rc_confirmation'] = 'close_all';
@@ -178,8 +182,9 @@  discard block
 block discarded – undo
178 182
 	$reportComments = array();
179 183
 
180 184
 	// Have to at least give us something to work with.
181
-	if (empty($_REQUEST['rid']))
182
-		fatal_lang_error('mc_reportedp_none_found');
185
+	if (empty($_REQUEST['rid'])) {
186
+			fatal_lang_error('mc_reportedp_none_found');
187
+	}
183 188
 
184 189
 	// Integers only please
185 190
 	$report_id = (int) $_REQUEST['rid'];
@@ -187,8 +192,9 @@  discard block
 block discarded – undo
187 192
 	// Get the report details.
188 193
 	$report = getReportDetails($report_id);
189 194
 
190
-	if(!$report)
191
-		fatal_lang_error('mc_no_modreport_found');
195
+	if(!$report) {
196
+			fatal_lang_error('mc_no_modreport_found');
197
+	}
192 198
 
193 199
 	// Build the report data - basic details first, then extra stuff based on the type
194 200
 	$context['report'] = array(
@@ -214,8 +220,7 @@  discard block
 block discarded – undo
214 220
 				'href' => $scripturl . '?action=profile;u=' . $report['id_user'],
215 221
 			),
216 222
 		);
217
-	}
218
-	else
223
+	} else
219 224
 	{
220 225
 		$extraDetails = array(
221 226
 			'topic_id' => $report['id_topic'],
@@ -238,8 +243,9 @@  discard block
 block discarded – undo
238 243
 
239 244
 	$reportComments = getReportComments($report_id);
240 245
 
241
-	if (!empty($reportComments))
242
-		$context['report'] = array_merge($context['report'], $reportComments);
246
+	if (!empty($reportComments)) {
247
+			$context['report'] = array_merge($context['report'], $reportComments);
248
+	}
243 249
 
244 250
 	// What have the other moderators done to this message?
245 251
 	require_once($sourcedir . '/Modlog.php');
@@ -260,8 +266,7 @@  discard block
 block discarded – undo
260 266
 			1,
261 267
 			true,
262 268
 		);
263
-	}
264
-	else
269
+	} else
265 270
 	{
266 271
 		$params = array(
267 272
 			'lm.id_topic = {int:id_topic}
@@ -361,16 +366,16 @@  discard block
 block discarded – undo
361 366
 	createList($listOptions);
362 367
 
363 368
 	// Make sure to get the correct tab selected.
364
-	if ($context['report']['closed'])
365
-		$context[$context['moderation_menu_name']]['current_subsection'] = 'closed';
369
+	if ($context['report']['closed']) {
370
+			$context[$context['moderation_menu_name']]['current_subsection'] = 'closed';
371
+	}
366 372
 
367 373
 	// Finally we are done :P
368 374
 	if ($context['report_type'] == 'members')
369 375
 	{
370 376
 		$context['page_title'] = sprintf($txt['mc_viewmemberreport'], $context['report']['user']['name']);
371 377
 		$context['sub_template'] = 'viewmemberreport';
372
-	}
373
-	else
378
+	} else
374 379
 	{
375 380
 		$context['page_title'] = sprintf($txt['mc_viewmodreport'], $context['report']['subject'], $context['report']['author']['name']);
376 381
 		$context['sub_template'] = 'viewmodreport';
@@ -395,8 +400,9 @@  discard block
 block discarded – undo
395 400
 	$comment = array();
396 401
 
397 402
 	// The report ID is a must.
398
-	if (empty($_REQUEST['rid']))
399
-		fatal_lang_error('mc_reportedp_none_found');
403
+	if (empty($_REQUEST['rid'])) {
404
+			fatal_lang_error('mc_reportedp_none_found');
405
+	}
400 406
 
401 407
 	// Integers only please.
402 408
 	$report_id = (int) $_REQUEST['rid'];
@@ -421,8 +427,9 @@  discard block
 block discarded – undo
421 427
 		checkSession('get');
422 428
 		validateToken('mod-reportC-delete', 'get');
423 429
 
424
-		if (empty($_REQUEST['mid']))
425
-			fatal_lang_error('mc_reportedp_comment_none_found');
430
+		if (empty($_REQUEST['mid'])) {
431
+					fatal_lang_error('mc_reportedp_comment_none_found');
432
+		}
426 433
 
427 434
 		$comment_id = (int) $_REQUEST['mid'];
428 435
 
@@ -430,15 +437,17 @@  discard block
 block discarded – undo
430 437
 		$comment = getCommentModDetails($comment_id);
431 438
 
432 439
 		// Perhaps somebody else already deleted this fine gem...
433
-		if (empty($comment))
434
-			fatal_lang_error('report_action_message_delete_issue');
440
+		if (empty($comment)) {
441
+					fatal_lang_error('report_action_message_delete_issue');
442
+		}
435 443
 
436 444
 		// Can you actually do this?
437 445
 		$comment_owner = $user_info['id'] == $comment['id_member'];
438 446
 
439 447
 		// Nope! sorry.
440
-		if (!allowedTo('admin_forum') && !$comment_owner)
441
-			fatal_lang_error('report_action_message_delete_cannot');
448
+		if (!allowedTo('admin_forum') && !$comment_owner) {
449
+					fatal_lang_error('report_action_message_delete_cannot');
450
+		}
442 451
 
443 452
 		// All good!
444 453
 		deleteModComment($comment_id);
@@ -465,11 +474,13 @@  discard block
 block discarded – undo
465 474
 	checkSession(isset($_REQUEST['save']) ? 'post' : 'get');
466 475
 
467 476
 	// The report ID is a must.
468
-	if (empty($_REQUEST['rid']))
469
-		fatal_lang_error('mc_reportedp_none_found');
477
+	if (empty($_REQUEST['rid'])) {
478
+			fatal_lang_error('mc_reportedp_none_found');
479
+	}
470 480
 
471
-	if (empty($_REQUEST['mid']))
472
-		fatal_lang_error('mc_reportedp_comment_none_found');
481
+	if (empty($_REQUEST['mid'])) {
482
+			fatal_lang_error('mc_reportedp_comment_none_found');
483
+	}
473 484
 
474 485
 	// Integers only please.
475 486
 	$context['report_id'] = (int) $_REQUEST['rid'];
@@ -477,8 +488,9 @@  discard block
 block discarded – undo
477 488
 
478 489
 	$context['comment'] = getCommentModDetails($context['comment_id']);
479 490
 
480
-	if (empty($context['comment']))
481
-		fatal_lang_error('mc_reportedp_comment_none_found');
491
+	if (empty($context['comment'])) {
492
+			fatal_lang_error('mc_reportedp_comment_none_found');
493
+	}
482 494
 
483 495
 	// Set up the comforting bits...
484 496
 	$context['page_title'] = $txt['mc_reported_posts'];
@@ -489,15 +501,17 @@  discard block
 block discarded – undo
489 501
 		validateToken('mod-reportC-edit');
490 502
 
491 503
 		// Make sure there is some data to edit on the DB.
492
-		if (empty($context['comment']))
493
-			fatal_lang_error('report_action_message_edit_issue');
504
+		if (empty($context['comment'])) {
505
+					fatal_lang_error('report_action_message_edit_issue');
506
+		}
494 507
 
495 508
 		// Still there, good, now lets see if you can actually edit it...
496 509
 		$comment_owner = $user_info['id'] == $context['comment']['id_member'];
497 510
 
498 511
 		// So, you aren't neither an admin or the comment owner huh? that's too bad.
499
-		if (!allowedTo('admin_forum') && !$comment_owner)
500
-			fatal_lang_error('report_action_message_edit_cannot');
512
+		if (!allowedTo('admin_forum') && !$comment_owner) {
513
+					fatal_lang_error('report_action_message_edit_cannot');
514
+		}
501 515
 
502 516
 		// All good!
503 517
 		$edited_comment = trim($smcFunc['htmlspecialchars']($_POST['mod_comment']));
@@ -523,8 +537,9 @@  discard block
 block discarded – undo
523 537
 	checkSession('get');
524 538
 
525 539
 	// We need to do something!
526
-	if (empty($_GET['rid']) && (!isset($_GET['ignore']) || !isset($_GET['closed'])))
527
-		fatal_lang_error('mc_reportedp_none_found');
540
+	if (empty($_GET['rid']) && (!isset($_GET['ignore']) || !isset($_GET['closed']))) {
541
+			fatal_lang_error('mc_reportedp_none_found');
542
+	}
528 543
 
529 544
 	// What are we gonna do?
530 545
 	$action = isset($_GET['ignore']) ? 'ignore' : 'closed';
Please login to merge, or discard this patch.
Sources/Help.php 1 patch
Braces   +29 added lines, -22 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
  * Redirect to the user help ;).
@@ -95,12 +96,13 @@  discard block
 block discarded – undo
95 96
 	);
96 97
 
97 98
 	// Have we got a localized one?
98
-	if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt'))
99
-		$context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']);
100
-	elseif (file_exists($boarddir . '/agreement.txt'))
101
-		$context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement');
102
-	else
103
-		$context['agreement'] = '';
99
+	if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt')) {
100
+			$context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']);
101
+	} elseif (file_exists($boarddir . '/agreement.txt')) {
102
+			$context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement');
103
+	} else {
104
+			$context['agreement'] = '';
105
+	}
104 106
 
105 107
 	// Nothing to show, so let's get out of here
106 108
 	if (empty($context['agreement']))
@@ -128,18 +130,21 @@  discard block
 block discarded – undo
128 130
 {
129 131
 	global $txt, $helptxt, $context, $scripturl;
130 132
 
131
-	if (!isset($_GET['help']) || !is_string($_GET['help']))
132
-		fatal_lang_error('no_access', false);
133
+	if (!isset($_GET['help']) || !is_string($_GET['help'])) {
134
+			fatal_lang_error('no_access', false);
135
+	}
133 136
 
134
-	if (!isset($helptxt))
135
-		$helptxt = array();
137
+	if (!isset($helptxt)) {
138
+			$helptxt = array();
139
+	}
136 140
 
137 141
 	// Load the admin help language file and template.
138 142
 	loadLanguage('Help');
139 143
 
140 144
 	// Permission specific help?
141
-	if (isset($_GET['help']) && substr($_GET['help'], 0, 14) == 'permissionhelp')
142
-		loadLanguage('ManagePermissions');
145
+	if (isset($_GET['help']) && substr($_GET['help'], 0, 14) == 'permissionhelp') {
146
+			loadLanguage('ManagePermissions');
147
+	}
143 148
 
144 149
 	loadTemplate('Help');
145 150
 
@@ -154,16 +159,18 @@  discard block
 block discarded – undo
154 159
 	$context['sub_template'] = 'popup';
155 160
 
156 161
 	// What help string should be used?
157
-	if (isset($helptxt[$_GET['help']]))
158
-		$context['help_text'] = $helptxt[$_GET['help']];
159
-	elseif (isset($txt[$_GET['help']]))
160
-		$context['help_text'] = $txt[$_GET['help']];
161
-	else
162
-		$context['help_text'] = $_GET['help'];
162
+	if (isset($helptxt[$_GET['help']])) {
163
+			$context['help_text'] = $helptxt[$_GET['help']];
164
+	} elseif (isset($txt[$_GET['help']])) {
165
+			$context['help_text'] = $txt[$_GET['help']];
166
+	} else {
167
+			$context['help_text'] = $_GET['help'];
168
+	}
163 169
 
164 170
 	// Does this text contain a link that we should fill in?
165
-	if (preg_match('~%([0-9]+\$)?s\?~', $context['help_text'], $match))
166
-		$context['help_text'] = sprintf($context['help_text'], $scripturl, $context['session_id'], $context['session_var']);
167
-}
171
+	if (preg_match('~%([0-9]+\$)?s\?~', $context['help_text'], $match)) {
172
+			$context['help_text'] = sprintf($context['help_text'], $scripturl, $context['session_id'], $context['session_var']);
173
+	}
174
+	}
168 175
 
169 176
 ?>
170 177
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/ManageMembers.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -357,9 +357,9 @@  discard block
 block discarded – undo
357 357
 				$parameter = strtolower(strtr($smcFunc['htmlspecialchars']($search_params[$param_name], ENT_QUOTES), array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_')));
358 358
 
359 359
 				if ($smcFunc['db_case_sensitive'])
360
-					$query_parts[] = '(LOWER(' . implode( ') LIKE {string:' . $param_name . '_normal} OR LOWER(', $param_info['db_fields']) . ') LIKE {string:' . $param_name . '_normal})';
360
+					$query_parts[] = '(LOWER(' . implode(') LIKE {string:' . $param_name . '_normal} OR LOWER(', $param_info['db_fields']) . ') LIKE {string:' . $param_name . '_normal})';
361 361
 				else
362
-					$query_parts[] = '(' . implode( ' LIKE {string:' . $param_name . '_normal} OR ', $param_info['db_fields']) . ' LIKE {string:' . $param_name . '_normal})';
362
+					$query_parts[] = '(' . implode(' LIKE {string:' . $param_name . '_normal} OR ', $param_info['db_fields']) . ' LIKE {string:' . $param_name . '_normal})';
363 363
 				$where_params[$param_name . '_normal'] = '%' . $parameter . '%';
364 364
 			}
365 365
 		}
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
 					'value' => $txt['viewmembers_online'],
519 519
 				),
520 520
 				'data' => array(
521
-					'function' => function ($rowData) use ($txt)
521
+					'function' => function($rowData) use ($txt)
522 522
 					{
523 523
 						// Calculate number of days since last online.
524 524
 						if (empty($rowData['last_login']))
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
 					'class' => 'centercol',
573 573
 				),
574 574
 				'data' => array(
575
-					'function' => function ($rowData) use ($user_info)
575
+					'function' => function($rowData) use ($user_info)
576 576
 					{
577 577
 						return '<input type="checkbox" name="delete[]" value="' . $rowData['id_member'] . '" class="input_check"' . ($rowData['id_member'] == $user_info['id'] || $rowData['id_group'] == 1 || in_array(1, explode(',', $rowData['additional_groups'])) ? ' disabled' : '') . '>';
578 578
 					},
@@ -877,7 +877,7 @@  discard block
 block discarded – undo
877 877
 					'value' => $txt['hostname'],
878 878
 				),
879 879
 				'data' => array(
880
-					'function' => function ($rowData)
880
+					'function' => function($rowData)
881 881
 					{
882 882
 						return host_from_ip(inet_dtop($rowData['member_ip']));
883 883
 					},
@@ -889,7 +889,7 @@  discard block
 block discarded – undo
889 889
 					'value' => $context['current_filter'] == 4 ? $txt['viewmembers_online'] : $txt['date_registered'],
890 890
 				),
891 891
 				'data' => array(
892
-					'function' => function ($rowData) use ($context)
892
+					'function' => function($rowData) use ($context)
893 893
 					{
894 894
 						return timeformat($rowData['' . ($context['current_filter'] == 4 ? 'last_login' : 'date_registered') . '']);
895 895
 					},
@@ -906,7 +906,7 @@  discard block
 block discarded – undo
906 906
 					'style' => 'width: 20%;',
907 907
 				),
908 908
 				'data' => array(
909
-					'function' => function ($rowData) use ($scripturl, $txt)
909
+					'function' => function($rowData) use ($scripturl, $txt)
910 910
 					{
911 911
 						$member_links = array();
912 912
 						foreach ($rowData['duplicate_members'] as $member)
@@ -916,7 +916,7 @@  discard block
 block discarded – undo
916 916
 							else
917 917
 								$member_links[] = $member['name'] . ' (' . $txt['guest'] . ')';
918 918
 						}
919
-						return implode (', ', $member_links);
919
+						return implode(', ', $member_links);
920 920
 					},
921 921
 					'class' => 'smalltext',
922 922
 				),
Please login to merge, or discard this patch.
Braces   +158 added lines, -116 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
  * The main entrance point for the Manage Members screen.
@@ -62,16 +63,18 @@  discard block
 block discarded – undo
62 63
 	$context['activation_numbers'] = array();
63 64
 	$context['awaiting_activation'] = 0;
64 65
 	$context['awaiting_approval'] = 0;
65
-	while ($row = $smcFunc['db_fetch_assoc']($request))
66
-		$context['activation_numbers'][$row['is_activated']] = $row['total_members'];
66
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
67
+			$context['activation_numbers'][$row['is_activated']] = $row['total_members'];
68
+	}
67 69
 	$smcFunc['db_free_result']($request);
68 70
 
69 71
 	foreach ($context['activation_numbers'] as $activation_type => $total_members)
70 72
 	{
71
-		if (in_array($activation_type, array(0, 2)))
72
-			$context['awaiting_activation'] += $total_members;
73
-		elseif (in_array($activation_type, array(3, 4, 5)))
74
-			$context['awaiting_approval'] += $total_members;
73
+		if (in_array($activation_type, array(0, 2))) {
74
+					$context['awaiting_activation'] += $total_members;
75
+		} elseif (in_array($activation_type, array(3, 4, 5))) {
76
+					$context['awaiting_approval'] += $total_members;
77
+		}
75 78
 	}
76 79
 
77 80
 	// For the page header... do we show activation?
@@ -124,8 +127,9 @@  discard block
 block discarded – undo
124 127
 	}
125 128
 	if (!$context['show_approve'] && ($_REQUEST['sa'] != 'browse' || $_REQUEST['type'] != 'approve'))
126 129
 	{
127
-		if (!$context['show_activate'] && ($_REQUEST['sa'] != 'browse' || $_REQUEST['type'] != 'activate'))
128
-			$context['tabs']['search']['is_last'] = true;
130
+		if (!$context['show_activate'] && ($_REQUEST['sa'] != 'browse' || $_REQUEST['type'] != 'activate')) {
131
+					$context['tabs']['search']['is_last'] = true;
132
+		}
129 133
 		unset($context['tabs']['approve']);
130 134
 	}
131 135
 
@@ -157,8 +161,9 @@  discard block
 block discarded – undo
157 161
 		foreach ($_POST['delete'] as $key => $value)
158 162
 		{
159 163
 			// Don't delete yourself, idiot.
160
-			if ($value != $user_info['id'])
161
-				$delete[$key] = (int) $value;
164
+			if ($value != $user_info['id']) {
165
+							$delete[$key] = (int) $value;
166
+			}
162 167
 		}
163 168
 
164 169
 		if (!empty($delete))
@@ -194,17 +199,18 @@  discard block
 block discarded – undo
194 199
 		);
195 200
 		while ($row = $smcFunc['db_fetch_assoc']($request))
196 201
 		{
197
-			if ($row['min_posts'] == -1)
198
-				$context['membergroups'][] = array(
202
+			if ($row['min_posts'] == -1) {
203
+							$context['membergroups'][] = array(
199 204
 					'id' => $row['id_group'],
200 205
 					'name' => $row['group_name'],
201 206
 					'can_be_additional' => true
202 207
 				);
203
-			else
204
-				$context['postgroups'][] = array(
208
+			} else {
209
+							$context['postgroups'][] = array(
205 210
 					'id' => $row['id_group'],
206 211
 					'name' => $row['group_name']
207 212
 				);
213
+			}
208 214
 		}
209 215
 		$smcFunc['db_free_result']($request);
210 216
 
@@ -268,14 +274,15 @@  discard block
 block discarded – undo
268 274
 		call_integration_hook('integrate_view_members_params', array(&$params));
269 275
 
270 276
 		$search_params = array();
271
-		if ($context['sub_action'] == 'query' && !empty($_REQUEST['params']) && empty($_POST['types']))
272
-			$search_params = smf_json_decode(base64_decode($_REQUEST['params']), true);
273
-		elseif (!empty($_POST))
277
+		if ($context['sub_action'] == 'query' && !empty($_REQUEST['params']) && empty($_POST['types'])) {
278
+					$search_params = smf_json_decode(base64_decode($_REQUEST['params']), true);
279
+		} elseif (!empty($_POST))
274 280
 		{
275 281
 			$search_params['types'] = $_POST['types'];
276
-			foreach ($params as $param_name => $param_info)
277
-				if (isset($_POST[$param_name]))
282
+			foreach ($params as $param_name => $param_info) {
283
+							if (isset($_POST[$param_name]))
278 284
 					$search_params[$param_name] = $_POST[$param_name];
285
+			}
279 286
 		}
280 287
 
281 288
 		$search_url_params = isset($search_params) ? base64_encode(json_encode($search_params)) : null;
@@ -288,18 +295,21 @@  discard block
 block discarded – undo
288 295
 		foreach ($params as $param_name => $param_info)
289 296
 		{
290 297
 			// Not filled in?
291
-			if (!isset($search_params[$param_name]) || $search_params[$param_name] === '')
292
-				continue;
298
+			if (!isset($search_params[$param_name]) || $search_params[$param_name] === '') {
299
+							continue;
300
+			}
293 301
 
294 302
 			// Make sure numeric values are really numeric.
295
-			if (in_array($param_info['type'], array('int', 'age')))
296
-				$search_params[$param_name] = (int) $search_params[$param_name];
303
+			if (in_array($param_info['type'], array('int', 'age'))) {
304
+							$search_params[$param_name] = (int) $search_params[$param_name];
305
+			}
297 306
 			// Date values have to match the specified format.
298 307
 			elseif ($param_info['type'] == 'date')
299 308
 			{
300 309
 				// Check if this date format is valid.
301
-				if (preg_match('/^\d{4}-\d{1,2}-\d{1,2}$/', $search_params[$param_name]) == 0)
302
-					continue;
310
+				if (preg_match('/^\d{4}-\d{1,2}-\d{1,2}$/', $search_params[$param_name]) == 0) {
311
+									continue;
312
+				}
303 313
 
304 314
 				$search_params[$param_name] = strtotime($search_params[$param_name]);
305 315
 			}
@@ -308,8 +318,9 @@  discard block
 block discarded – undo
308 318
 			if (!empty($param_info['range']))
309 319
 			{
310 320
 				// Default to '=', just in case...
311
-				if (empty($range_trans[$search_params['types'][$param_name]]))
312
-					$search_params['types'][$param_name] = '=';
321
+				if (empty($range_trans[$search_params['types'][$param_name]])) {
322
+									$search_params['types'][$param_name] = '=';
323
+				}
313 324
 
314 325
 				// Handle special case 'age'.
315 326
 				if ($param_info['type'] == 'age')
@@ -337,29 +348,30 @@  discard block
 block discarded – undo
337 348
 				elseif ($param_info['type'] == 'date' && $search_params['types'][$param_name] == '=')
338 349
 				{
339 350
 					$query_parts[] = $param_info['db_fields'][0] . ' > ' . $search_params[$param_name] . ' AND ' . $param_info['db_fields'][0] . ' < ' . ($search_params[$param_name] + 86400);
351
+				} else {
352
+									$query_parts[] = $param_info['db_fields'][0] . ' ' . $range_trans[$search_params['types'][$param_name]] . ' ' . $search_params[$param_name];
340 353
 				}
341
-				else
342
-					$query_parts[] = $param_info['db_fields'][0] . ' ' . $range_trans[$search_params['types'][$param_name]] . ' ' . $search_params[$param_name];
343 354
 			}
344 355
 			// Checkboxes.
345 356
 			elseif ($param_info['type'] == 'checkbox')
346 357
 			{
347 358
 				// Each checkbox or no checkbox at all is checked -> ignore.
348
-				if (!is_array($search_params[$param_name]) || count($search_params[$param_name]) == 0 || count($search_params[$param_name]) == count($param_info['values']))
349
-					continue;
359
+				if (!is_array($search_params[$param_name]) || count($search_params[$param_name]) == 0 || count($search_params[$param_name]) == count($param_info['values'])) {
360
+									continue;
361
+				}
350 362
 
351 363
 				$query_parts[] = ($param_info['db_fields'][0]) . ' IN ({array_string:' . $param_name . '_check})';
352 364
 				$where_params[$param_name . '_check'] = $search_params[$param_name];
353
-			}
354
-			else
365
+			} else
355 366
 			{
356 367
 				// Replace the wildcard characters ('*' and '?') into MySQL ones.
357 368
 				$parameter = strtolower(strtr($smcFunc['htmlspecialchars']($search_params[$param_name], ENT_QUOTES), array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_')));
358 369
 
359
-				if ($smcFunc['db_case_sensitive'])
360
-					$query_parts[] = '(LOWER(' . implode( ') LIKE {string:' . $param_name . '_normal} OR LOWER(', $param_info['db_fields']) . ') LIKE {string:' . $param_name . '_normal})';
361
-				else
362
-					$query_parts[] = '(' . implode( ' LIKE {string:' . $param_name . '_normal} OR ', $param_info['db_fields']) . ' LIKE {string:' . $param_name . '_normal})';
370
+				if ($smcFunc['db_case_sensitive']) {
371
+									$query_parts[] = '(LOWER(' . implode( ') LIKE {string:' . $param_name . '_normal} OR LOWER(', $param_info['db_fields']) . ') LIKE {string:' . $param_name . '_normal})';
372
+				} else {
373
+									$query_parts[] = '(' . implode( ' LIKE {string:' . $param_name . '_normal} OR ', $param_info['db_fields']) . ' LIKE {string:' . $param_name . '_normal})';
374
+				}
363 375
 				$where_params[$param_name . '_normal'] = '%' . $parameter . '%';
364 376
 			}
365 377
 		}
@@ -375,16 +387,18 @@  discard block
 block discarded – undo
375 387
 		}
376 388
 
377 389
 		// Additional membergroups (these are only relevant if not all primary groups where selected!).
378
-		if (!empty($search_params['membergroups'][2]) && (empty($search_params['membergroups'][1]) || count($context['membergroups']) != count($search_params['membergroups'][1])))
379
-			foreach ($search_params['membergroups'][2] as $mg)
390
+		if (!empty($search_params['membergroups'][2]) && (empty($search_params['membergroups'][1]) || count($context['membergroups']) != count($search_params['membergroups'][1]))) {
391
+					foreach ($search_params['membergroups'][2] as $mg)
380 392
 			{
381 393
 				$mg_query_parts[] = 'FIND_IN_SET({int:add_group_' . $mg . '}, mem.additional_groups) != 0';
394
+		}
382 395
 				$where_params['add_group_' . $mg] = $mg;
383 396
 			}
384 397
 
385 398
 		// Combine the one or two membergroup parts into one query part linked with an OR.
386
-		if (!empty($mg_query_parts))
387
-			$query_parts[] = '(' . implode(' OR ', $mg_query_parts) . ')';
399
+		if (!empty($mg_query_parts)) {
400
+					$query_parts[] = '(' . implode(' OR ', $mg_query_parts) . ')';
401
+		}
388 402
 
389 403
 		// Get all selected post count related membergroups.
390 404
 		if (!empty($search_params['postgroups']) && count($search_params['postgroups']) != count($context['postgroups']))
@@ -396,9 +410,9 @@  discard block
 block discarded – undo
396 410
 		// Construct the where part of the query.
397 411
 		$where = empty($query_parts) ? '1=1' : implode('
398 412
 			AND ', $query_parts);
413
+	} else {
414
+			$search_url_params = null;
399 415
 	}
400
-	else
401
-		$search_url_params = null;
402 416
 
403 417
 	// Construct the additional URL part with the query info in it.
404 418
 	$context['params_url'] = $context['sub_action'] == 'query' ? ';sa=query;params=' . $search_url_params : '';
@@ -521,28 +535,32 @@  discard block
 block discarded – undo
521 535
 					'function' => function ($rowData) use ($txt)
522 536
 					{
523 537
 						// Calculate number of days since last online.
524
-						if (empty($rowData['last_login']))
525
-							$difference = $txt['never'];
526
-						else
538
+						if (empty($rowData['last_login'])) {
539
+													$difference = $txt['never'];
540
+						} else
527 541
 						{
528 542
 							$num_days_difference = jeffsdatediff($rowData['last_login']);
529 543
 
530 544
 							// Today.
531
-							if (empty($num_days_difference))
532
-								$difference = $txt['viewmembers_today'];
545
+							if (empty($num_days_difference)) {
546
+															$difference = $txt['viewmembers_today'];
547
+							}
533 548
 
534 549
 							// Yesterday.
535
-							elseif ($num_days_difference == 1)
536
-								$difference = sprintf('1 %1$s', $txt['viewmembers_day_ago']);
550
+							elseif ($num_days_difference == 1) {
551
+															$difference = sprintf('1 %1$s', $txt['viewmembers_day_ago']);
552
+							}
537 553
 
538 554
 							// X days ago.
539
-							else
540
-								$difference = sprintf('%1$d %2$s', $num_days_difference, $txt['viewmembers_days_ago']);
555
+							else {
556
+															$difference = sprintf('%1$d %2$s', $num_days_difference, $txt['viewmembers_days_ago']);
557
+							}
541 558
 						}
542 559
 
543 560
 						// Show it in italics if they're not activated...
544
-						if ($rowData['is_activated'] % 10 != 1)
545
-							$difference = sprintf('<em title="%1$s">%2$s</em>', $txt['not_activated'], $difference);
561
+						if ($rowData['is_activated'] % 10 != 1) {
562
+													$difference = sprintf('<em title="%1$s">%2$s</em>', $txt['not_activated'], $difference);
563
+						}
546 564
 
547 565
 						return $difference;
548 566
 					},
@@ -594,8 +612,9 @@  discard block
 block discarded – undo
594 612
 	);
595 613
 
596 614
 	// Without enough permissions, don't show 'delete members' checkboxes.
597
-	if (!allowedTo('profile_remove_any'))
598
-		unset($listOptions['cols']['check'], $listOptions['form'], $listOptions['additional_rows']);
615
+	if (!allowedTo('profile_remove_any')) {
616
+			unset($listOptions['cols']['check'], $listOptions['form'], $listOptions['additional_rows']);
617
+	}
599 618
 
600 619
 	require_once($sourcedir . '/Subs-List.php');
601 620
 	createList($listOptions);
@@ -638,17 +657,18 @@  discard block
 block discarded – undo
638 657
 	);
639 658
 	while ($row = $smcFunc['db_fetch_assoc']($request))
640 659
 	{
641
-		if ($row['min_posts'] == -1)
642
-			$context['membergroups'][] = array(
660
+		if ($row['min_posts'] == -1) {
661
+					$context['membergroups'][] = array(
643 662
 				'id' => $row['id_group'],
644 663
 				'name' => $row['group_name'],
645 664
 				'can_be_additional' => true
646 665
 			);
647
-		else
648
-			$context['postgroups'][] = array(
666
+		} else {
667
+					$context['postgroups'][] = array(
649 668
 				'id' => $row['id_group'],
650 669
 				'name' => $row['group_name']
651 670
 			);
671
+		}
652 672
 	}
653 673
 	$smcFunc['db_free_result']($request);
654 674
 
@@ -675,8 +695,9 @@  discard block
 block discarded – undo
675 695
 	$context['page_title'] = $txt['admin_members'];
676 696
 	$context['sub_template'] = 'admin_browse';
677 697
 	$context['browse_type'] = isset($_REQUEST['type']) ? $_REQUEST['type'] : (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1 ? 'activate' : 'approve');
678
-	if (isset($context['tabs'][$context['browse_type']]))
679
-		$context['tabs'][$context['browse_type']]['is_selected'] = true;
698
+	if (isset($context['tabs'][$context['browse_type']])) {
699
+			$context['tabs'][$context['browse_type']]['is_selected'] = true;
700
+	}
680 701
 
681 702
 	// Allowed filters are those we can have, in theory.
682 703
 	$context['allowed_filters'] = $context['browse_type'] == 'approve' ? array(3, 4, 5) : array(0, 2);
@@ -687,18 +708,20 @@  discard block
 block discarded – undo
687 708
 	foreach ($context['activation_numbers'] as $type => $amount)
688 709
 	{
689 710
 		// We have some of these...
690
-		if (in_array($type, $context['allowed_filters']) && $amount > 0)
691
-			$context['available_filters'][] = array(
711
+		if (in_array($type, $context['allowed_filters']) && $amount > 0) {
712
+					$context['available_filters'][] = array(
692 713
 				'type' => $type,
693 714
 				'amount' => $amount,
694 715
 				'desc' => isset($txt['admin_browse_filter_type_' . $type]) ? $txt['admin_browse_filter_type_' . $type] : '?',
695 716
 				'selected' => $type == $context['current_filter']
696 717
 			);
718
+		}
697 719
 	}
698 720
 
699 721
 	// If the filter was not sent, set it to whatever has people in it!
700
-	if ($context['current_filter'] == -1 && !empty($context['available_filters'][0]['amount']))
701
-		$context['current_filter'] = $context['available_filters'][0]['type'];
722
+	if ($context['current_filter'] == -1 && !empty($context['available_filters'][0]['amount'])) {
723
+			$context['current_filter'] = $context['available_filters'][0]['type'];
724
+	}
702 725
 
703 726
 	// This little variable is used to determine if we should flag where we are looking.
704 727
 	$context['show_filter'] = ($context['current_filter'] != 0 && $context['current_filter'] != 3) || count($context['available_filters']) > 1;
@@ -713,44 +736,47 @@  discard block
 block discarded – undo
713 736
 	);
714 737
 
715 738
 	// Are we showing duplicate information?
716
-	if (isset($_GET['showdupes']))
717
-		$_SESSION['showdupes'] = (int) $_GET['showdupes'];
739
+	if (isset($_GET['showdupes'])) {
740
+			$_SESSION['showdupes'] = (int) $_GET['showdupes'];
741
+	}
718 742
 	$context['show_duplicates'] = !empty($_SESSION['showdupes']);
719 743
 
720 744
 	// Determine which actions we should allow on this page.
721 745
 	if ($context['browse_type'] == 'approve')
722 746
 	{
723 747
 		// If we are approving deleted accounts we have a slightly different list... actually a mirror ;)
724
-		if ($context['current_filter'] == 4)
725
-			$context['allowed_actions'] = array(
748
+		if ($context['current_filter'] == 4) {
749
+					$context['allowed_actions'] = array(
726 750
 				'reject' => $txt['admin_browse_w_approve_deletion'],
727 751
 				'ok' => $txt['admin_browse_w_reject'],
728 752
 			);
729
-		else
730
-			$context['allowed_actions'] = array(
753
+		} else {
754
+					$context['allowed_actions'] = array(
731 755
 				'ok' => $txt['admin_browse_w_approve'],
732 756
 				'okemail' => $txt['admin_browse_w_approve'] . ' ' . $txt['admin_browse_w_email'],
733 757
 				'require_activation' => $txt['admin_browse_w_approve_require_activate'],
734 758
 				'reject' => $txt['admin_browse_w_reject'],
735 759
 				'rejectemail' => $txt['admin_browse_w_reject'] . ' ' . $txt['admin_browse_w_email'],
736 760
 			);
737
-	}
738
-	elseif ($context['browse_type'] == 'activate')
739
-		$context['allowed_actions'] = array(
761
+		}
762
+	} elseif ($context['browse_type'] == 'activate') {
763
+			$context['allowed_actions'] = array(
740 764
 			'ok' => $txt['admin_browse_w_activate'],
741 765
 			'okemail' => $txt['admin_browse_w_activate'] . ' ' . $txt['admin_browse_w_email'],
742 766
 			'delete' => $txt['admin_browse_w_delete'],
743 767
 			'deleteemail' => $txt['admin_browse_w_delete'] . ' ' . $txt['admin_browse_w_email'],
744 768
 			'remind' => $txt['admin_browse_w_remind'] . ' ' . $txt['admin_browse_w_email'],
745 769
 		);
770
+	}
746 771
 
747 772
 	// Create an option list for actions allowed to be done with selected members.
748 773
 	$allowed_actions = '
749 774
 			<option selected value="">' . $txt['admin_browse_with_selected'] . ':</option>
750 775
 			<option value="" disabled>-----------------------------</option>';
751
-	foreach ($context['allowed_actions'] as $key => $desc)
752
-		$allowed_actions .= '
776
+	foreach ($context['allowed_actions'] as $key => $desc) {
777
+			$allowed_actions .= '
753 778
 			<option value="' . $key . '">' . $desc . '</option>';
779
+	}
754 780
 
755 781
 	// Setup the Javascript function for selecting an action for the list.
756 782
 	$javascript = '
@@ -762,15 +788,16 @@  discard block
 block discarded – undo
762 788
 			var message = "";';
763 789
 
764 790
 	// We have special messages for approving deletion of accounts - it's surprisingly logical - honest.
765
-	if ($context['current_filter'] == 4)
766
-		$javascript .= '
791
+	if ($context['current_filter'] == 4) {
792
+			$javascript .= '
767 793
 			if (document.forms.postForm.todo.value.indexOf("reject") != -1)
768 794
 				message = "' . $txt['admin_browse_w_delete'] . '";
769 795
 			else
770 796
 				message = "' . $txt['admin_browse_w_reject'] . '";';
797
+	}
771 798
 	// Otherwise a nice standard message.
772
-	else
773
-		$javascript .= '
799
+	else {
800
+			$javascript .= '
774 801
 			if (document.forms.postForm.todo.value.indexOf("delete") != -1)
775 802
 				message = "' . $txt['admin_browse_w_delete'] . '";
776 803
 			else if (document.forms.postForm.todo.value.indexOf("reject") != -1)
@@ -779,6 +806,7 @@  discard block
 block discarded – undo
779 806
 				message = "' . $txt['admin_browse_w_remind'] . '";
780 807
 			else
781 808
 				message = "' . ($context['browse_type'] == 'approve' ? $txt['admin_browse_w_approve'] : $txt['admin_browse_w_activate']) . '";';
809
+	}
782 810
 	$javascript .= '
783 811
 			if (confirm(message + " ' . $txt['admin_browse_warn'] . '"))
784 812
 				document.forms.postForm.submit();
@@ -911,10 +939,11 @@  discard block
 block discarded – undo
911 939
 						$member_links = array();
912 940
 						foreach ($rowData['duplicate_members'] as $member)
913 941
 						{
914
-							if ($member['id'])
915
-								$member_links[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '" ' . (!empty($member['is_banned']) ? 'class="red"' : '') . '>' . $member['name'] . '</a>';
916
-							else
917
-								$member_links[] = $member['name'] . ' (' . $txt['guest'] . ')';
942
+							if ($member['id']) {
943
+															$member_links[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '" ' . (!empty($member['is_banned']) ? 'class="red"' : '') . '>' . $member['name'] . '</a>';
944
+							} else {
945
+															$member_links[] = $member['name'] . ' (' . $txt['guest'] . ')';
946
+							}
918 947
 						}
919 948
 						return implode (', ', $member_links);
920 949
 					},
@@ -963,14 +992,16 @@  discard block
 block discarded – undo
963 992
 	);
964 993
 
965 994
 	// Pick what column to actually include if we're showing duplicates.
966
-	if ($context['show_duplicates'])
967
-		unset($listOptions['columns']['email']);
968
-	else
969
-		unset($listOptions['columns']['duplicates']);
995
+	if ($context['show_duplicates']) {
996
+			unset($listOptions['columns']['email']);
997
+	} else {
998
+			unset($listOptions['columns']['duplicates']);
999
+	}
970 1000
 
971 1001
 	// Only show hostname on duplicates as it takes a lot of time.
972
-	if (!$context['show_duplicates'] || !empty($modSettings['disableHostnameLookup']))
973
-		unset($listOptions['columns']['hostname']);
1002
+	if (!$context['show_duplicates'] || !empty($modSettings['disableHostnameLookup'])) {
1003
+			unset($listOptions['columns']['hostname']);
1004
+	}
974 1005
 
975 1006
 	// Is there any need to show filters?
976 1007
 	if (isset($context['available_filters']) && count($context['available_filters']) > 1)
@@ -978,9 +1009,10 @@  discard block
 block discarded – undo
978 1009
 		$filterOptions = '
979 1010
 			<strong>' . $txt['admin_browse_filter_by'] . ':</strong>
980 1011
 			<select name="filter" onchange="this.form.submit();">';
981
-		foreach ($context['available_filters'] as $filter)
982
-			$filterOptions .= '
1012
+		foreach ($context['available_filters'] as $filter) {
1013
+					$filterOptions .= '
983 1014
 				<option value="' . $filter['type'] . '"' . ($filter['selected'] ? ' selected' : '') . '>' . $filter['desc'] . ' - ' . $filter['amount'] . ' ' . ($filter['amount'] == 1 ? $txt['user'] : $txt['users']) . '</option>';
1015
+		}
984 1016
 		$filterOptions .= '
985 1017
 			</select>
986 1018
 			<noscript><input type="submit" value="' . $txt['go'] . '" name="filter" class="button_submit"></noscript>';
@@ -992,12 +1024,13 @@  discard block
 block discarded – undo
992 1024
 	}
993 1025
 
994 1026
 	// What about if we only have one filter, but it's not the "standard" filter - show them what they are looking at.
995
-	if (!empty($context['show_filter']) && !empty($context['available_filters']))
996
-		$listOptions['additional_rows'][] = array(
1027
+	if (!empty($context['show_filter']) && !empty($context['available_filters'])) {
1028
+			$listOptions['additional_rows'][] = array(
997 1029
 			'position' => 'above_column_headers',
998 1030
 			'value' => '<strong>' . $txt['admin_browse_filter_show'] . ':</strong> ' . $context['available_filters'][0]['desc'],
999 1031
 			'class' => 'smalltext floatright',
1000 1032
 		);
1033
+	}
1001 1034
 
1002 1035
 	// Now that we have all the options, create the list.
1003 1036
 	require_once($sourcedir . '/Subs-List.php');
@@ -1028,12 +1061,14 @@  discard block
 block discarded – undo
1028 1061
 	$current_filter = (int) $_REQUEST['orig_filter'];
1029 1062
 
1030 1063
 	// If we are applying a filter do just that - then redirect.
1031
-	if (isset($_REQUEST['filter']) && $_REQUEST['filter'] != $_REQUEST['orig_filter'])
1032
-		redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $_REQUEST['filter'] . ';start=' . $_REQUEST['start']);
1064
+	if (isset($_REQUEST['filter']) && $_REQUEST['filter'] != $_REQUEST['orig_filter']) {
1065
+			redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $_REQUEST['filter'] . ';start=' . $_REQUEST['start']);
1066
+	}
1033 1067
 
1034 1068
 	// Nothing to do?
1035
-	if (!isset($_POST['todoAction']) && !isset($_POST['time_passed']))
1036
-		redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']);
1069
+	if (!isset($_POST['todoAction']) && !isset($_POST['time_passed'])) {
1070
+			redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']);
1071
+	}
1037 1072
 
1038 1073
 	// Are we dealing with members who have been waiting for > set amount of time?
1039 1074
 	if (isset($_POST['time_passed']))
@@ -1046,8 +1081,9 @@  discard block
 block discarded – undo
1046 1081
 	else
1047 1082
 	{
1048 1083
 		$members = array();
1049
-		foreach ($_POST['todoAction'] as $id)
1050
-			$members[] = (int) $id;
1084
+		foreach ($_POST['todoAction'] as $id) {
1085
+					$members[] = (int) $id;
1086
+		}
1051 1087
 		$condition = '
1052 1088
 			AND id_member IN ({array_int:members})';
1053 1089
 	}
@@ -1068,8 +1104,9 @@  discard block
 block discarded – undo
1068 1104
 	$member_count = $smcFunc['db_num_rows']($request);
1069 1105
 
1070 1106
 	// If no results then just return!
1071
-	if ($member_count == 0)
1072
-		redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']);
1107
+	if ($member_count == 0) {
1108
+			redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']);
1109
+	}
1073 1110
 
1074 1111
 	$member_info = array();
1075 1112
 	$members = array();
@@ -1108,8 +1145,9 @@  discard block
 block discarded – undo
1108 1145
 		// Do we have to let the integration code know about the activations?
1109 1146
 		if (!empty($modSettings['integrate_activate']))
1110 1147
 		{
1111
-			foreach ($member_info as $member)
1112
-				call_integration_hook('integrate_activate', array($member['username']));
1148
+			foreach ($member_info as $member) {
1149
+							call_integration_hook('integrate_activate', array($member['username']));
1150
+			}
1113 1151
 		}
1114 1152
 
1115 1153
 		// Check for email.
@@ -1240,20 +1278,23 @@  discard block
 block discarded – undo
1240 1278
 		$log_inserts = array();
1241 1279
 
1242 1280
 		require_once($sourcedir . '/Logging.php');
1243
-		foreach ($member_info as $member)
1244
-			logAction($log_action, array('member' => $member['id']), 'admin');
1281
+		foreach ($member_info as $member) {
1282
+					logAction($log_action, array('member' => $member['id']), 'admin');
1283
+		}
1245 1284
 	}
1246 1285
 
1247 1286
 	// Although updateStats *may* catch this, best to do it manually just in case (Doesn't always sort out unapprovedMembers).
1248
-	if (in_array($current_filter, array(3, 4, 5)))
1249
-		updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > $member_count ? $modSettings['unapprovedMembers'] - $member_count : 0)));
1287
+	if (in_array($current_filter, array(3, 4, 5))) {
1288
+			updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > $member_count ? $modSettings['unapprovedMembers'] - $member_count : 0)));
1289
+	}
1250 1290
 
1251 1291
 	// Update the member's stats. (but, we know the member didn't change their name.)
1252 1292
 	updateStats('member', false);
1253 1293
 
1254 1294
 	// If they haven't been deleted, update the post group statistics on them...
1255
-	if (!in_array($_POST['todo'], array('delete', 'deleteemail', 'reject', 'rejectemail', 'remind')))
1256
-		updateStats('postgroups', $members);
1295
+	if (!in_array($_POST['todo'], array('delete', 'deleteemail', 'reject', 'rejectemail', 'remind'))) {
1296
+			updateStats('postgroups', $members);
1297
+	}
1257 1298
 
1258 1299
 	redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']);
1259 1300
 }
@@ -1278,10 +1319,11 @@  discard block
 block discarded – undo
1278 1319
 	$dis = time() - $old;
1279 1320
 
1280 1321
 	// Before midnight?
1281
-	if ($dis < $sinceMidnight)
1282
-		return 0;
1283
-	else
1284
-		$dis -= $sinceMidnight;
1322
+	if ($dis < $sinceMidnight) {
1323
+			return 0;
1324
+	} else {
1325
+			$dis -= $sinceMidnight;
1326
+	}
1285 1327
 
1286 1328
 	// Divide out the seconds in a day to get the number of days.
1287 1329
 	return ceil($dis / (24 * 60 * 60));
Please login to merge, or discard this patch.
Sources/BoardIndex.php 1 patch
Braces   +20 added lines, -13 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 shows the board index.
@@ -34,8 +35,9 @@  discard block
 block discarded – undo
34 35
 	$context['canonical_url'] = $scripturl;
35 36
 
36 37
 	// Do not let search engines index anything if there is a random thing in $_GET.
37
-	if (!empty($_GET))
38
-		$context['robot_no_index'] = true;
38
+	if (!empty($_GET)) {
39
+			$context['robot_no_index'] = true;
40
+	}
39 41
 
40 42
 	// Retrieve the categories and boards.
41 43
 	require_once($sourcedir . '/Subs-BoardIndex.php');
@@ -62,11 +64,12 @@  discard block
 block discarded – undo
62 64
 			$context['latest_posts'] = cache_quick_get('boardindex-latest_posts:' . md5($user_info['query_wanna_see_board'] . $user_info['language']), 'Subs-Recent.php', 'cache_getLastPosts', array($latestPostOptions));
63 65
 		}
64 66
 
65
-		if (!empty($context['latest_posts']) || !empty($context['latest_post']))
66
-			$context['info_center'][] = array(
67
+		if (!empty($context['latest_posts']) || !empty($context['latest_post'])) {
68
+					$context['info_center'][] = array(
67 69
 				'tpl' => 'recent',
68 70
 				'txt' => 'recent_posts',
69 71
 			);
72
+		}
70 73
 	}
71 74
 
72 75
 	// Load the calendar?
@@ -87,20 +90,22 @@  discard block
 block discarded – undo
87 90
 		// This is used to show the "how-do-I-edit" help.
88 91
 		$context['calendar_can_edit'] = allowedTo('calendar_edit_any');
89 92
 
90
-		if ($context['show_calendar'])
91
-			$context['info_center'][] = array(
93
+		if ($context['show_calendar']) {
94
+					$context['info_center'][] = array(
92 95
 				'tpl' => 'calendar',
93 96
 				'txt' => $context['calendar_only_today'] ? 'calendar_today' : 'calendar_upcoming',
94 97
 			);
98
+		}
95 99
 	}
96 100
 
97 101
 	// And stats.
98 102
 	$context['show_stats'] = allowedTo('view_stats') && !empty($modSettings['trackStats']);
99
-	if ($settings['show_stats_index'])
100
-		$context['info_center'][] = array(
103
+	if ($settings['show_stats_index']) {
104
+			$context['info_center'][] = array(
101 105
 				'tpl' => 'stats',
102 106
 				'txt' => 'forum_stats',
103 107
 			);
108
+	}
104 109
 
105 110
 	// Now the online stuff
106 111
 	require_once($sourcedir . '/Subs-MembersOnline.php');
@@ -118,12 +123,14 @@  discard block
 block discarded – undo
118 123
 			);
119 124
 
120 125
 	// Track most online statistics? (Subs-MembersOnline.php)
121
-	if (!empty($modSettings['trackStats']))
122
-		trackStatsUsersOnline($context['num_guests'] + $context['num_spiders'] + $context['num_users_online']);
126
+	if (!empty($modSettings['trackStats'])) {
127
+			trackStatsUsersOnline($context['num_guests'] + $context['num_spiders'] + $context['num_users_online']);
128
+	}
123 129
 
124 130
 	// Are we showing all membergroups on the board index?
125
-	if (!empty($settings['show_group_key']))
126
-		$context['membergroups'] = cache_quick_get('membergroup_list', 'Subs-Membergroups.php', 'cache_getMembergroupList', array());
131
+	if (!empty($settings['show_group_key'])) {
132
+			$context['membergroups'] = cache_quick_get('membergroup_list', 'Subs-Membergroups.php', 'cache_getMembergroupList', array());
133
+	}
127 134
 
128 135
 	// And back to normality.
129 136
 	$context['page_title'] = sprintf($txt['forum_index'], $context['forum_name']);
Please login to merge, or discard this patch.
Sources/ViewQuery.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -139,7 +139,7 @@
 block discarded – undo
139 139
 		if ($query_id == $q && $is_select_query)
140 140
 		{
141 141
 			$result = $smcFunc['db_query']('', '
142
-				EXPLAIN '.($smcFunc['db_title'] == 'PostgreSQL' ? 'ANALYZE ':'') . $select,
142
+				EXPLAIN '.($smcFunc['db_title'] == 'PostgreSQL' ? 'ANALYZE ' : '') . $select,
143 143
 				array(
144 144
 				)
145 145
 			);
Please login to merge, or discard this patch.
Braces   +34 added lines, -26 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
  * Show the database queries for debugging
@@ -30,8 +31,9 @@  discard block
 block discarded – undo
30 31
 	global $scripturl, $settings, $context, $db_connection, $boarddir, $smcFunc, $txt, $db_show_debug;
31 32
 
32 33
 	// We should have debug mode enabled, as well as something to display!
33
-	if (!isset($db_show_debug) || $db_show_debug !== true || !isset($_SESSION['debug']))
34
-		fatal_lang_error('no_access', false);
34
+	if (!isset($db_show_debug) || $db_show_debug !== true || !isset($_SESSION['debug'])) {
35
+			fatal_lang_error('no_access', false);
36
+	}
35 37
 
36 38
 	// Don't allow except for administrators.
37 39
 	isAllowedTo('admin_forum');
@@ -41,10 +43,11 @@  discard block
 block discarded – undo
41 43
 	{
42 44
 		$_SESSION['view_queries'] = $_SESSION['view_queries'] == 1 ? 0 : 1;
43 45
 
44
-		if (strpos($_SESSION['old_url'], 'action=viewquery') !== false)
45
-			redirectexit();
46
-		else
47
-			redirectexit($_SESSION['old_url']);
46
+		if (strpos($_SESSION['old_url'], 'action=viewquery') !== false) {
47
+					redirectexit();
48
+		} else {
49
+					redirectexit($_SESSION['old_url']);
50
+		}
48 51
 	}
49 52
 
50 53
 	call_integration_hook('integrate_egg_nog');
@@ -83,26 +86,28 @@  discard block
 block discarded – undo
83 86
 		foreach ($query as $line)
84 87
 		{
85 88
 			preg_match('/^(\t*)/', $line, $temp);
86
-			if (strlen($temp[0]) < $min_indent || $min_indent == 0)
87
-				$min_indent = strlen($temp[0]);
89
+			if (strlen($temp[0]) < $min_indent || $min_indent == 0) {
90
+							$min_indent = strlen($temp[0]);
91
+			}
92
+		}
93
+		foreach ($query as $l => $dummy) {
94
+					$query[$l] = substr($dummy, $min_indent);
88 95
 		}
89
-		foreach ($query as $l => $dummy)
90
-			$query[$l] = substr($dummy, $min_indent);
91 96
 		$query_data['q'] = implode("\n", $query);
92 97
 
93 98
 		// Make the filenames look a bit better.
94
-		if (isset($query_data['f']))
95
-			$query_data['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $query_data['f']);
99
+		if (isset($query_data['f'])) {
100
+					$query_data['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $query_data['f']);
101
+		}
96 102
 
97 103
 		$is_select_query = substr(trim($query_data['q']), 0, 6) == 'SELECT';
98
-		if ($is_select_query)
99
-			$select = $query_data['q'];
100
-		elseif (preg_match('~^INSERT(?: IGNORE)? INTO \w+(?:\s+\([^)]+\))?\s+(SELECT .+)$~s', trim($query_data['q']), $matches) != 0)
104
+		if ($is_select_query) {
105
+					$select = $query_data['q'];
106
+		} elseif (preg_match('~^INSERT(?: IGNORE)? INTO \w+(?:\s+\([^)]+\))?\s+(SELECT .+)$~s', trim($query_data['q']), $matches) != 0)
101 107
 		{
102 108
 			$is_select_query = true;
103 109
 			$select = $matches[1];
104
-		}
105
-		elseif (preg_match('~^CREATE TEMPORARY TABLE .+?(SELECT .+)$~s', trim($query_data['q']), $matches) != 0)
110
+		} elseif (preg_match('~^CREATE TEMPORARY TABLE .+?(SELECT .+)$~s', trim($query_data['q']), $matches) != 0)
106 111
 		{
107 112
 			$is_select_query = true;
108 113
 			$select = $matches[1];
@@ -110,10 +115,11 @@  discard block
 block discarded – undo
110 115
 		// Temporary tables created in earlier queries are not explainable.
111 116
 		if ($is_select_query)
112 117
 		{
113
-			foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp)
114
-				if (strpos($select, $tmp) !== false)
118
+			foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) {
119
+							if (strpos($select, $tmp) !== false)
115 120
 				{
116 121
 					$is_select_query = false;
122
+			}
117 123
 					break;
118 124
 				}
119 125
 		}
@@ -124,13 +130,15 @@  discard block
 block discarded – undo
124 130
 				', nl2br(str_replace("\t", '&nbsp;&nbsp;&nbsp;', $smcFunc['htmlspecialchars']($query_data['q']))), '
125 131
 			</a><br>';
126 132
 
127
-		if (!empty($query_data['f']) && !empty($query_data['l']))
128
-			echo sprintf($txt['debug_query_in_line'], $query_data['f'], $query_data['l']);
133
+		if (!empty($query_data['f']) && !empty($query_data['l'])) {
134
+					echo sprintf($txt['debug_query_in_line'], $query_data['f'], $query_data['l']);
135
+		}
129 136
 
130
-		if (isset($query_data['s'], $query_data['t']) && isset($txt['debug_query_which_took_at']))
131
-			echo sprintf($txt['debug_query_which_took_at'], round($query_data['t'], 8), round($query_data['s'], 8));
132
-		else
133
-			echo sprintf($txt['debug_query_which_took'], round($query_data['t'], 8));
137
+		if (isset($query_data['s'], $query_data['t']) && isset($txt['debug_query_which_took_at'])) {
138
+					echo sprintf($txt['debug_query_which_took_at'], round($query_data['t'], 8), round($query_data['s'], 8));
139
+		} else {
140
+					echo sprintf($txt['debug_query_which_took'], round($query_data['t'], 8));
141
+		}
134 142
 
135 143
 		echo '
136 144
 		</div>';
Please login to merge, or discard this patch.
Sources/ManageRegistration.php 1 patch
Braces   +27 added lines, -19 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
  * Entrance point for the registration center, it checks permissions and forwards
@@ -31,8 +32,9 @@  discard block
 block discarded – undo
31 32
 	global $context, $txt;
32 33
 
33 34
 	// Old templates might still request this.
34
-	if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'browse')
35
-		redirectexit('action=admin;area=viewmembers;sa=browse' . (isset($_REQUEST['type']) ? ';type=' . $_REQUEST['type'] : ''));
35
+	if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'browse') {
36
+			redirectexit('action=admin;area=viewmembers;sa=browse' . (isset($_REQUEST['type']) ? ';type=' . $_REQUEST['type'] : ''));
37
+	}
36 38
 
37 39
 	$subActions = array(
38 40
 		'register' => array('AdminRegister', 'moderate_forum'),
@@ -99,9 +101,10 @@  discard block
 block discarded – undo
99 101
 		checkSession();
100 102
 		validateToken('admin-regc');
101 103
 
102
-		foreach ($_POST as $key => $value)
103
-			if (!is_array($_POST[$key]))
104
+		foreach ($_POST as $key => $value) {
105
+					if (!is_array($_POST[$key]))
104 106
 				$_POST[$key] = htmltrim__recursive(str_replace(array("\n", "\r"), '', $_POST[$key]));
107
+		}
105 108
 
106 109
 		$regOptions = array(
107 110
 			'interface' => 'admin',
@@ -161,12 +164,13 @@  discard block
 block discarded – undo
161 164
 			)
162 165
 		);
163 166
 		$context['member_groups'] = array(0 => $txt['admin_register_group_none']);
164
-		while ($row = $smcFunc['db_fetch_assoc']($request))
165
-			$context['member_groups'][$row['id_group']] = $row['group_name'];
167
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
168
+					$context['member_groups'][$row['id_group']] = $row['group_name'];
169
+		}
166 170
 		$smcFunc['db_free_result']($request);
171
+	} else {
172
+			$context['member_groups'] = array();
167 173
 	}
168
-	else
169
-		$context['member_groups'] = array();
170 174
 
171 175
 	// Basic stuff.
172 176
 	$context['sub_template'] = 'admin_register';
@@ -207,8 +211,9 @@  discard block
 block discarded – undo
207 211
 		{
208 212
 			$context['editable_agreements']['.' . $lang['filename']] = $lang['name'];
209 213
 			// Are we editing this?
210
-			if (isset($_POST['agree_lang']) && $_POST['agree_lang'] == '.' . $lang['filename'])
211
-				$context['current_agreement'] = '.' . $lang['filename'];
214
+			if (isset($_POST['agree_lang']) && $_POST['agree_lang'] == '.' . $lang['filename']) {
215
+							$context['current_agreement'] = '.' . $lang['filename'];
216
+			}
212 217
 		}
213 218
 	}
214 219
 
@@ -223,10 +228,11 @@  discard block
 block discarded – undo
223 228
 
224 229
 		updateSettings(array('requireAgreement' => !empty($_POST['requireAgreement'])));
225 230
 
226
-		if ($bytes == strlen($to_write))
227
-			$context['saved_successful'] = true;
228
-		else
229
-			$context['could_not_save'] = true;
231
+		if ($bytes == strlen($to_write)) {
232
+					$context['saved_successful'] = true;
233
+		} else {
234
+					$context['could_not_save'] = true;
235
+		}
230 236
 	}
231 237
 
232 238
 	$context['agreement'] = file_exists($boarddir . '/agreement' . $context['current_agreement'] . '.txt') ? $smcFunc['htmlspecialchars'](file_get_contents($boarddir . '/agreement' . $context['current_agreement'] . '.txt')) : '';
@@ -310,8 +316,9 @@  discard block
 block discarded – undo
310 316
 
311 317
 	call_integration_hook('integrate_modify_registration_settings', array(&$config_vars));
312 318
 
313
-	if ($return_config)
314
-		return $config_vars;
319
+	if ($return_config) {
320
+			return $config_vars;
321
+	}
315 322
 
316 323
 	// Setup the template
317 324
 	$context['sub_template'] = 'show_settings';
@@ -322,8 +329,9 @@  discard block
 block discarded – undo
322 329
 		checkSession();
323 330
 
324 331
 		// Are there some contacts missing?
325
-		if (!empty($_POST['coppaAge']) && !empty($_POST['coppaType']) && empty($_POST['coppaPost']) && empty($_POST['coppaFax']))
326
-			fatal_lang_error('admin_setting_coppa_require_contact');
332
+		if (!empty($_POST['coppaAge']) && !empty($_POST['coppaType']) && empty($_POST['coppaPost']) && empty($_POST['coppaFax'])) {
333
+					fatal_lang_error('admin_setting_coppa_require_contact');
334
+		}
327 335
 
328 336
 		// Post needs to take into account line breaks.
329 337
 		$_POST['coppaPost'] = str_replace("\n", '<br>', empty($_POST['coppaPost']) ? '' : $_POST['coppaPost']);
Please login to merge, or discard this patch.
Sources/ManagePosts.php 2 patches
Indentation   -1 removed lines patch added patch discarded remove patch
@@ -273,7 +273,6 @@
 block discarded – undo
273 273
  * Modify any setting related to topics.
274 274
  * Requires the admin_forum permission.
275 275
  * Accessed from ?action=admin;area=postsettings;sa=topics.
276
-
277 276
  * @param bool $return_config Whether or not to return the config_vars array (used for admin search)
278 277
  * @return void|array Returns nothing or returns $config_vars if $return_config is true
279 278
  * @uses Admin template, edit_topic_settings sub-template.
Please login to merge, or discard this patch.
Braces   +39 added lines, -29 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
  * The main entrance point for the 'Posts and topics' screen.
@@ -98,23 +99,23 @@  discard block
 block discarded – undo
98 99
 		{
99 100
 			$_POST['censortext'] = explode("\n", strtr($_POST['censortext'], array("\r" => '')));
100 101
 
101
-			foreach ($_POST['censortext'] as $c)
102
-				list ($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, '');
103
-		}
104
-		elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper']))
102
+			foreach ($_POST['censortext'] as $c) {
103
+							list ($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, '');
104
+			}
105
+		} elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper']))
105 106
 		{
106 107
 			if (is_array($_POST['censor_vulgar']))
107 108
 			{
108 109
 				foreach ($_POST['censor_vulgar'] as $i => $value)
109 110
 				{
110
-					if (trim(strtr($value, '*', ' ')) == '')
111
-						unset($_POST['censor_vulgar'][$i], $_POST['censor_proper'][$i]);
111
+					if (trim(strtr($value, '*', ' ')) == '') {
112
+											unset($_POST['censor_vulgar'][$i], $_POST['censor_proper'][$i]);
113
+					}
112 114
 				}
113 115
 
114 116
 				$censored_vulgar = $_POST['censor_vulgar'];
115 117
 				$censored_proper = $_POST['censor_proper'];
116
-			}
117
-			else
118
+			} else
118 119
 			{
119 120
 				$censored_vulgar = explode("\n", strtr($_POST['censor_vulgar'], array("\r" => '')));
120 121
 				$censored_proper = explode("\n", strtr($_POST['censor_proper'], array("\r" => '')));
@@ -151,12 +152,14 @@  discard block
 block discarded – undo
151 152
 	$context['censored_words'] = array();
152 153
 	for ($i = 0, $n = count($censor_vulgar); $i < $n; $i++)
153 154
 	{
154
-		if (empty($censor_vulgar[$i]))
155
-			continue;
155
+		if (empty($censor_vulgar[$i])) {
156
+					continue;
157
+		}
156 158
 
157 159
 		// Skip it, it's either spaces or stars only.
158
-		if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '')
159
-			continue;
160
+		if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '') {
161
+					continue;
162
+		}
160 163
 
161 164
 		$context['censored_words'][$smcFunc['htmlspecialchars'](trim($censor_vulgar[$i]))] = isset($censor_proper[$i]) ? $smcFunc['htmlspecialchars']($censor_proper[$i]) : '';
162 165
 	}
@@ -187,10 +190,11 @@  discard block
 block discarded – undo
187 190
 
188 191
 	// Make an inline conditional a little shorter...
189 192
 	$can_spell_check = false;
190
-	if (function_exists('pspell_new'))
191
-		$can_spell_check = true;
192
-	elseif (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv')))
193
-		$can_spell_check = true;
193
+	if (function_exists('pspell_new')) {
194
+			$can_spell_check = true;
195
+	} elseif (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv'))) {
196
+			$can_spell_check = true;
197
+	}
194 198
 
195 199
 	// All the settings...
196 200
 	$config_vars = array(
@@ -221,8 +225,9 @@  discard block
 block discarded – undo
221 225
 
222 226
 	call_integration_hook('integrate_modify_post_settings', array(&$config_vars));
223 227
 
224
-	if ($return_config)
225
-		return $config_vars;
228
+	if ($return_config) {
229
+			return $config_vars;
230
+	}
226 231
 
227 232
 	// We'll want this for our easy save.
228 233
 	require_once($sourcedir . '/ManageServer.php');
@@ -242,17 +247,20 @@  discard block
 block discarded – undo
242 247
 			db_extend('packages');
243 248
 
244 249
 			$colData = $smcFunc['db_list_columns']('{db_prefix}messages', true);
245
-			foreach ($colData as $column)
246
-				if ($column['name'] == 'body')
250
+			foreach ($colData as $column) {
251
+							if ($column['name'] == 'body')
247 252
 					$body_type = $column['type'];
253
+			}
248 254
 
249
-			if (isset($body_type) && ($_POST['max_messageLength'] > 65535 || $_POST['max_messageLength'] == 0) && $body_type == 'text')
250
-				fatal_lang_error('convert_to_mediumtext', false, array($scripturl . '?action=admin;area=maintain;sa=database'));
255
+			if (isset($body_type) && ($_POST['max_messageLength'] > 65535 || $_POST['max_messageLength'] == 0) && $body_type == 'text') {
256
+							fatal_lang_error('convert_to_mediumtext', false, array($scripturl . '?action=admin;area=maintain;sa=database'));
257
+			}
251 258
 		}
252 259
 
253 260
 		// If we're changing the post preview length let's check its valid
254
-		if (!empty($_POST['preview_characters']))
255
-			$_POST['preview_characters'] = (int) min(max(0, $_POST['preview_characters']), 512);
261
+		if (!empty($_POST['preview_characters'])) {
262
+					$_POST['preview_characters'] = (int) min(max(0, $_POST['preview_characters']), 512);
263
+		}
256 264
 
257 265
 		call_integration_hook('integrate_save_post_settings');
258 266
 
@@ -313,8 +321,9 @@  discard block
 block discarded – undo
313 321
 
314 322
 	call_integration_hook('integrate_modify_topic_settings', array(&$config_vars));
315 323
 
316
-	if ($return_config)
317
-		return $config_vars;
324
+	if ($return_config) {
325
+			return $config_vars;
326
+	}
318 327
 
319 328
 	// Get the settings template ready.
320 329
 	require_once($sourcedir . '/ManageServer.php');
@@ -367,8 +376,9 @@  discard block
 block discarded – undo
367 376
 		array('int', 'drafts_autosave_frequency', 'postinput' => $txt['manageposts_seconds'], 'subtext' => $txt['drafts_autosave_frequency_subnote']),
368 377
 	);
369 378
 
370
-	if ($return_config)
371
-		return $config_vars;
379
+	if ($return_config) {
380
+			return $config_vars;
381
+	}
372 382
 
373 383
 	// Get the settings template ready.
374 384
 	require_once($sourcedir . '/ManageServer.php');
Please login to merge, or discard this patch.
Sources/ManageMail.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 					'value' => $txt['mailqueue_subject'],
115 115
 				),
116 116
 				'data' => array(
117
-					'function' => function ($rowData) use ($smcFunc)
117
+					'function' => function($rowData) use ($smcFunc)
118 118
 					{
119 119
 						return $smcFunc['strlen']($rowData['subject']) > 50 ? sprintf('%1$s...', $smcFunc['htmlspecialchars']($smcFunc['substr']($rowData['subject'], 0, 47))) : $smcFunc['htmlspecialchars']($rowData['subject']);
120 120
 					},
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 					'value' => $txt['mailqueue_priority'],
149 149
 				),
150 150
 				'data' => array(
151
-					'function' => function ($rowData) use ($txt)
151
+					'function' => function($rowData) use ($txt)
152 152
 					{
153 153
 						// We probably have a text label with your priority.
154 154
 						$txtKey = sprintf('mq_mpriority_%1$s', $rowData['priority']);
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 					'value' => $txt['mailqueue_age'],
169 169
 				),
170 170
 				'data' => array(
171
-					'function' => function ($rowData)
171
+					'function' => function($rowData)
172 172
 					{
173 173
 						return time_since(time() - $rowData['time_sent']);
174 174
 					},
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 					'value' => '<input type="checkbox" onclick="invertAll(this, this.form);" class="input_check">',
185 185
 				),
186 186
 				'data' => array(
187
-					'function' => function ($rowData)
187
+					'function' => function($rowData)
188 188
 					{
189 189
 						return '<input type="checkbox" name="delete[]" value="' . $rowData['id_mail'] . '" class="input_check">';
190 190
 					},
Please login to merge, or discard this patch.
Braces   +26 added lines, -18 removed lines patch added patch discarded remove patch
@@ -15,8 +15,9 @@  discard block
 block discarded – undo
15 15
  * @version 2.1 Beta 3
16 16
  */
17 17
 
18
-if (!defined('SMF'))
18
+if (!defined('SMF')) {
19 19
 	die('No direct access...');
20
+}
20 21
 
21 22
 /**
22 23
  * Main dispatcher. This function checks permissions and passes control through to the relevant section.
@@ -245,8 +246,9 @@  discard block
 block discarded – undo
245 246
 	while ($row = $smcFunc['db_fetch_assoc']($request))
246 247
 	{
247 248
 		// Private PM/email subjects and similar shouldn't be shown in the mailbox area.
248
-		if (!empty($row['private']))
249
-			$row['subject'] = $txt['personal_message'];
249
+		if (!empty($row['private'])) {
250
+					$row['subject'] = $txt['personal_message'];
251
+		}
250 252
 
251 253
 		$mails[] = $row;
252 254
 	}
@@ -300,8 +302,9 @@  discard block
 block discarded – undo
300 302
 		$element = substr($key, strrpos($key, '_') + 1);
301 303
 		$processedBirthdayEmails[$index][$element] = $value;
302 304
 	}
303
-	foreach ($processedBirthdayEmails as $index => $dummy)
304
-		$emails[$index] = $index;
305
+	foreach ($processedBirthdayEmails as $index => $dummy) {
306
+			$emails[$index] = $index;
307
+	}
305 308
 
306 309
 	$config_vars = array(
307 310
 			// Mail queue stuff, this rocks ;)
@@ -322,8 +325,9 @@  discard block
 block discarded – undo
322 325
 
323 326
 	call_integration_hook('integrate_modify_mail_settings', array(&$config_vars));
324 327
 
325
-	if ($return_config)
326
-		return $config_vars;
328
+	if ($return_config) {
329
+			return $config_vars;
330
+	}
327 331
 
328 332
 	// Saving?
329 333
 	if (isset($_GET['save']))
@@ -398,9 +402,9 @@  discard block
 block discarded – undo
398 402
 		);
399 403
 		list ($_GET['te']) = $smcFunc['db_fetch_row']($request);
400 404
 		$smcFunc['db_free_result']($request);
405
+	} else {
406
+			$_GET['te'] = (int) $_GET['te'];
401 407
 	}
402
-	else
403
-		$_GET['te'] = (int) $_GET['te'];
404 408
 
405 409
 	$_GET['sent'] = isset($_GET['sent']) ? (int) $_GET['sent'] : 0;
406 410
 
@@ -424,12 +428,14 @@  discard block
 block discarded – undo
424 428
 
425 429
 	// Try get more time...
426 430
 	@set_time_limit(600);
427
-	if (function_exists('apache_reset_timeout'))
428
-		@apache_reset_timeout();
431
+	if (function_exists('apache_reset_timeout')) {
432
+			@apache_reset_timeout();
433
+	}
429 434
 
430 435
 	// Have we already used our maximum time?
431
-	if (time() - array_sum(explode(' ', $time_start)) < 5)
432
-		return;
436
+	if (time() - array_sum(explode(' ', $time_start)) < 5) {
437
+			return;
438
+	}
433 439
 
434 440
 	$context['continue_get_data'] = '?action=admin;area=mailqueue;sa=clear;te=' . $_GET['te'] . ';sent=' . $_GET['sent'] . ';' . $context['session_var'] . '=' . $context['session_id'];
435 441
 	$context['page_title'] = $txt['not_done_title'];
@@ -459,8 +465,9 @@  discard block
 block discarded – undo
459 465
 {
460 466
 	global $txt;
461 467
 
462
-	if ($time_diff < 0)
463
-		$time_diff = 0;
468
+	if ($time_diff < 0) {
469
+			$time_diff = 0;
470
+	}
464 471
 
465 472
 	// Just do a bit of an if fest...
466 473
 	if ($time_diff > 86400)
@@ -481,8 +488,9 @@  discard block
 block discarded – undo
481 488
 		return sprintf($minutes == 1 ? $txt['mq_minute'] : $txt['mq_minutes'], $minutes);
482 489
 	}
483 490
 	// Otherwise must be second
484
-	else
485
-		return sprintf($time_diff == 1 ? $txt['mq_second'] : $txt['mq_seconds'], $time_diff);
486
-}
491
+	else {
492
+			return sprintf($time_diff == 1 ? $txt['mq_second'] : $txt['mq_seconds'], $time_diff);
493
+	}
494
+	}
487 495
 
488 496
 ?>
Please login to merge, or discard this patch.
Sources/ManageAttachments.php 2 patches
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -104,14 +104,14 @@  discard block
 block discarded – undo
104 104
 	$context['valid_upload_dir'] = is_dir($context['attachmentUploadDir']) && is_writable($context['attachmentUploadDir']);
105 105
 
106 106
 	if (!empty($modSettings['automanage_attachments']))
107
-		$context['valid_basedirectory'] =  !empty($modSettings['basedirectory_for_attachments']) && is_writable($modSettings['basedirectory_for_attachments']);
107
+		$context['valid_basedirectory'] = !empty($modSettings['basedirectory_for_attachments']) && is_writable($modSettings['basedirectory_for_attachments']);
108 108
 
109 109
 	else
110 110
 		$context['valid_basedirectory'] = true;
111 111
 
112 112
 	// A bit of razzle dazzle with the $txt strings. :)
113 113
 	$txt['attachment_path'] = $context['attachmentUploadDir'];
114
-	$txt['basedirectory_for_attachments_path']= isset($modSettings['basedirectory_for_attachments']) ? $modSettings['basedirectory_for_attachments'] : '';
114
+	$txt['basedirectory_for_attachments_path'] = isset($modSettings['basedirectory_for_attachments']) ? $modSettings['basedirectory_for_attachments'] : '';
115 115
 	$txt['use_subdirectories_for_attachments_note'] = empty($modSettings['attachment_basedirectories']) || empty($modSettings['use_subdirectories_for_attachments']) ? $txt['use_subdirectories_for_attachments_note'] : '';
116 116
 	$txt['attachmentUploadDir_multiple_configure'] = '<a href="' . $scripturl . '?action=admin;area=manageattachments;sa=attachpaths">[' . $txt['attachmentUploadDir_multiple_configure'] . ']</a>';
117 117
 	$txt['attach_current_dir'] = empty($modSettings['automanage_attachments']) ? $txt['attach_current_dir'] : $txt['attach_last_dir'];
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 			array('select', 'automanage_attachments', array(0 => $txt['attachments_normal'], 1 => $txt['attachments_auto_space'], 2 => $txt['attachments_auto_years'], 3 => $txt['attachments_auto_months'], 4 => $txt['attachments_auto_16'])),
137 137
 			array('check', 'use_subdirectories_for_attachments', 'subtext' => $txt['use_subdirectories_for_attachments_note']),
138 138
 			(empty($modSettings['attachment_basedirectories']) ? array('text', 'basedirectory_for_attachments', 40,) : array('var_message', 'basedirectory_for_attachments', 'message' => 'basedirectory_for_attachments_path', 'invalid' => empty($context['valid_basedirectory']), 'text_label' => (!empty($context['valid_basedirectory']) ? $txt['basedirectory_for_attachments_current'] : $txt['basedirectory_for_attachments_warning']))),
139
-			empty($modSettings['attachment_basedirectories']) && $modSettings['currentAttachmentUploadDir'] == 1 && count($modSettings['attachmentUploadDir']) == 1	? array('json', 'attachmentUploadDir', 'subtext' => $txt['attachmentUploadDir_multiple_configure'], 40, 'invalid' => !$context['valid_upload_dir'], 'disabled' => true) : array('var_message', 'attach_current_directory', 'subtext' => $txt['attachmentUploadDir_multiple_configure'], 'message' => 'attachment_path', 'invalid' => empty($context['valid_upload_dir']), 'text_label' => (!empty($context['valid_upload_dir']) ? $txt['attach_current_dir'] : $txt['attach_current_dir_warning'])),
139
+			empty($modSettings['attachment_basedirectories']) && $modSettings['currentAttachmentUploadDir'] == 1 && count($modSettings['attachmentUploadDir']) == 1 ? array('json', 'attachmentUploadDir', 'subtext' => $txt['attachmentUploadDir_multiple_configure'], 40, 'invalid' => !$context['valid_upload_dir'], 'disabled' => true) : array('var_message', 'attach_current_directory', 'subtext' => $txt['attachmentUploadDir_multiple_configure'], 'message' => 'attachment_path', 'invalid' => empty($context['valid_upload_dir']), 'text_label' => (!empty($context['valid_upload_dir']) ? $txt['attach_current_dir'] : $txt['attach_current_dir_warning'])),
140 140
 			array('int', 'attachmentDirFileLimit', 'subtext' => $txt['zero_for_no_limit'], 6),
141 141
 			array('int', 'attachmentDirSizeLimit', 'subtext' => $txt['zero_for_no_limit'], 6, 'postinput' => $txt['kilobyte']),
142 142
 			array('check', 'dont_show_attach_under_post', 'subtext' => $txt['dont_show_attach_under_post_sub']),
@@ -349,16 +349,16 @@  discard block
 block discarded – undo
349 349
 
350 350
 		// These settings cannot be left empty!
351 351
 		if (empty($_POST['custom_avatar_dir']))
352
-			$_POST['custom_avatar_dir'] = $boarddir .'/custom_avatar';
352
+			$_POST['custom_avatar_dir'] = $boarddir . '/custom_avatar';
353 353
 
354 354
 		if (empty($_POST['custom_avatar_url']))
355
-			$_POST['custom_avatar_url'] = $boardurl .'/custom_avatar';
355
+			$_POST['custom_avatar_url'] = $boardurl . '/custom_avatar';
356 356
 
357 357
 		if (empty($_POST['avatar_directory']))
358
-			$_POST['avatar_directory'] = $boarddir .'/avatars';
358
+			$_POST['avatar_directory'] = $boarddir . '/avatars';
359 359
 
360 360
 		if (empty($_POST['avatar_url']))
361
-			$_POST['avatar_url'] = $boardurl .'/avatars';
361
+			$_POST['avatar_url'] = $boardurl . '/avatars';
362 362
 
363 363
 		call_integration_hook('integrate_save_avatar_settings');
364 364
 
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 		'items_per_page' => $modSettings['defaultMaxListItems'],
423 423
 		'base_href' => $scripturl . '?action=admin;area=manageattachments;sa=browse' . ($context['browse_type'] === 'avatars' ? ';avatars' : ($context['browse_type'] === 'thumbs' ? ';thumbs' : '')),
424 424
 		'default_sort_col' => 'name',
425
-		'no_items_label' => $txt['attachment_manager_' . ($context['browse_type'] === 'avatars' ? 'avatars' : ( $context['browse_type'] === 'thumbs' ? 'thumbs' : 'attachments')) . '_no_entries'],
425
+		'no_items_label' => $txt['attachment_manager_' . ($context['browse_type'] === 'avatars' ? 'avatars' : ($context['browse_type'] === 'thumbs' ? 'thumbs' : 'attachments')) . '_no_entries'],
426 426
 		'get_items' => array(
427 427
 			'function' => 'list_getFiles',
428 428
 			'params' => array(
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
 					'value' => $txt['attachment_name'],
442 442
 				),
443 443
 				'data' => array(
444
-					'function' => function ($rowData) use ($modSettings, $context, $scripturl, $smcFunc)
444
+					'function' => function($rowData) use ($modSettings, $context, $scripturl, $smcFunc)
445 445
 					{
446 446
 						$link = '<a href="';
447 447
 
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
 					'value' => $txt['attachment_file_size'],
483 483
 				),
484 484
 				'data' => array(
485
-					'function' => function ($rowData) use ($txt)
485
+					'function' => function($rowData) use ($txt)
486 486
 					{
487 487
 						return sprintf('%1$s%2$s', round($rowData['size'] / 1024, 2), $txt['kilobyte']);
488 488
 					},
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
 					'value' => $context['browse_type'] == 'avatars' ? $txt['attachment_manager_member'] : $txt['posted_by'],
498 498
 				),
499 499
 				'data' => array(
500
-					'function' => function ($rowData) use ($scripturl, $smcFunc)
500
+					'function' => function($rowData) use ($scripturl, $smcFunc)
501 501
 					{
502 502
 						// In case of an attachment, return the poster of the attachment.
503 503
 						if (empty($rowData['id_member']))
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
 					'value' => $context['browse_type'] == 'avatars' ? $txt['attachment_manager_last_active'] : $txt['date'],
519 519
 				),
520 520
 				'data' => array(
521
-					'function' => function ($rowData) use ($txt, $context, $scripturl)
521
+					'function' => function($rowData) use ($txt, $context, $scripturl)
522 522
 					{
523 523
 						// The date the message containing the attachment was posted or the owner of the avatar was active.
524 524
 						$date = empty($rowData['poster_time']) ? $txt['never'] : timeformat($rowData['poster_time']);
@@ -1336,7 +1336,7 @@  discard block
 block discarded – undo
1336 1336
 					if (!empty($modSettings['currentAttachmentUploadDir']))
1337 1337
 					{
1338 1338
 						// Get the attachment name with out the folder.
1339
-						$attachment_name = $row['id_attach'] . '_' . $row['file_hash'] .'.dat';
1339
+						$attachment_name = $row['id_attach'] . '_' . $row['file_hash'] . '.dat';
1340 1340
 
1341 1341
 						// Loop through the other folders.
1342 1342
 						foreach ($modSettings['attachmentUploadDir'] as $id => $dir)
@@ -1952,7 +1952,7 @@  discard block
 block discarded – undo
1952 1952
 				if (automanage_attachments_create_directory($path))
1953 1953
 					$_POST['current_dir'] = $modSettings['currentAttachmentUploadDir'];
1954 1954
 				else
1955
-					$errors[] =  $path . ': ' . $txt[$context['dir_creation_error']];
1955
+					$errors[] = $path . ': ' . $txt[$context['dir_creation_error']];
1956 1956
 			}
1957 1957
 
1958 1958
 			// Changing a directory name?
@@ -2074,7 +2074,7 @@  discard block
 block discarded – undo
2074 2074
 		}
2075 2075
 
2076 2076
 		// If the user wishes to go back, update the last_dir array
2077
-		if ($_POST['current_dir'] !=  $modSettings['currentAttachmentUploadDir']&& !empty($modSettings['last_attachments_directory']) && (isset($modSettings['last_attachments_directory'][$_POST['current_dir']]) || isset($modSettings['last_attachments_directory'][0])))
2077
+		if ($_POST['current_dir'] != $modSettings['currentAttachmentUploadDir'] && !empty($modSettings['last_attachments_directory']) && (isset($modSettings['last_attachments_directory'][$_POST['current_dir']]) || isset($modSettings['last_attachments_directory'][0])))
2078 2078
 		{
2079 2079
 			if (!is_array($modSettings['last_attachments_directory']))
2080 2080
 				$modSettings['last_attachments_directory'] = smf_json_decode($modSettings['last_attachments_directory'], true);
@@ -2087,7 +2087,7 @@  discard block
 block discarded – undo
2087 2087
 				$use_subdirectories_for_attachments = 0;
2088 2088
 				if (!empty($modSettings['attachment_basedirectories']))
2089 2089
 					foreach ($modSettings['attachment_basedirectories'] as $bid => $base)
2090
-						if (strpos($modSettings['attachmentUploadDir'][$_POST['current_dir']], $base . DIRECTORY_SEPARATOR) !==false)
2090
+						if (strpos($modSettings['attachmentUploadDir'][$_POST['current_dir']], $base . DIRECTORY_SEPARATOR) !== false)
2091 2091
 						{
2092 2092
 							$use_subdirectories_for_attachments = 1;
2093 2093
 							break;
@@ -2263,7 +2263,7 @@  discard block
 block discarded – undo
2263 2263
 					'class' => 'centercol',
2264 2264
 				),
2265 2265
 				'data' => array(
2266
-					'function' => function ($rowData)
2266
+					'function' => function($rowData)
2267 2267
 					{
2268 2268
 						return '<input type="radio" name="current_dir" value="' . $rowData['id'] . '"' . ($rowData['current'] ? ' checked' : '') . (!empty($rowData['disable_current']) ? ' disabled' : '') . ' class="input_radio">';
2269 2269
 					},
@@ -2276,7 +2276,7 @@  discard block
 block discarded – undo
2276 2276
 					'value' => $txt['attach_path'],
2277 2277
 				),
2278 2278
 				'data' => array(
2279
-					'function' => function ($rowData)
2279
+					'function' => function($rowData)
2280 2280
 					{
2281 2281
 						return '<input type="hidden" name="dirs[' . $rowData['id'] . ']" value="' . $rowData['path'] . '"><input type="text" size="40" name="dirs[' . $rowData['id'] . ']" value="' . $rowData['path'] . '"' . (!empty($rowData['disable_base_dir']) ? ' disabled' : '') . ' class="input_text" style="width: 100%">';
2282 2282
 					},
@@ -2355,7 +2355,7 @@  discard block
 block discarded – undo
2355 2355
 						'class' => 'centercol',
2356 2356
 					),
2357 2357
 					'data' => array(
2358
-						'function' => function ($rowData)
2358
+						'function' => function($rowData)
2359 2359
 						{
2360 2360
 							return '<input type="radio" name="current_base_dir" value="' . $rowData['id'] . '"' . ($rowData['current'] ? ' checked' : '') . ' class="input_radio">';
2361 2361
 						},
@@ -2726,7 +2726,7 @@  discard block
 block discarded – undo
2726 2726
 					$dir_size += !empty($row['size']) ? $row['size'] : filesize($source);
2727 2727
 
2728 2728
 					// If we've reached a limit. Do something.
2729
-					if (!empty($modSettings['attachmentDirSizeLimit']) && $dir_size > $modSettings['attachmentDirSizeLimit'] * 1024 || (!empty($modSettings['attachmentDirFileLimit']) && $dir_files >  $modSettings['attachmentDirFileLimit']))
2729
+					if (!empty($modSettings['attachmentDirSizeLimit']) && $dir_size > $modSettings['attachmentDirSizeLimit'] * 1024 || (!empty($modSettings['attachmentDirFileLimit']) && $dir_files > $modSettings['attachmentDirFileLimit']))
2730 2730
 					{
2731 2731
 						if (!empty($_POST['auto']))
2732 2732
 						{
Please login to merge, or discard this patch.
Braces   +429 added lines, -325 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 main 'Attachments and Avatars' management function.
@@ -63,10 +64,11 @@  discard block
 block discarded – undo
63 64
 	call_integration_hook('integrate_manage_attachments', array(&$subActions));
64 65
 
65 66
 	// Pick the correct sub-action.
66
-	if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]))
67
-		$context['sub_action'] = $_REQUEST['sa'];
68
-	else
69
-		$context['sub_action'] = 'browse';
67
+	if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) {
68
+			$context['sub_action'] = $_REQUEST['sa'];
69
+	} else {
70
+			$context['sub_action'] = 'browse';
71
+	}
70 72
 
71 73
 	// Default page title is good.
72 74
 	$context['page_title'] = $txt['attachments_avatars'];
@@ -94,20 +96,20 @@  discard block
 block discarded – undo
94 96
 	$context['attachmentUploadDir'] = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']];
95 97
 
96 98
 	// If not set, show a default path for the base directory
97
-	if (!isset($_GET['save']) && empty($modSettings['basedirectory_for_attachments']))
98
-		if (is_dir($modSettings['attachmentUploadDir'][1]))
99
+	if (!isset($_GET['save']) && empty($modSettings['basedirectory_for_attachments'])) {
100
+			if (is_dir($modSettings['attachmentUploadDir'][1]))
99 101
 			$modSettings['basedirectory_for_attachments'] = $modSettings['attachmentUploadDir'][1];
100
-
101
-	else
102
-		$modSettings['basedirectory_for_attachments'] = $context['attachmentUploadDir'];
102
+	} else {
103
+			$modSettings['basedirectory_for_attachments'] = $context['attachmentUploadDir'];
104
+	}
103 105
 
104 106
 	$context['valid_upload_dir'] = is_dir($context['attachmentUploadDir']) && is_writable($context['attachmentUploadDir']);
105 107
 
106
-	if (!empty($modSettings['automanage_attachments']))
107
-		$context['valid_basedirectory'] =  !empty($modSettings['basedirectory_for_attachments']) && is_writable($modSettings['basedirectory_for_attachments']);
108
-
109
-	else
110
-		$context['valid_basedirectory'] = true;
108
+	if (!empty($modSettings['automanage_attachments'])) {
109
+			$context['valid_basedirectory'] =  !empty($modSettings['basedirectory_for_attachments']) && is_writable($modSettings['basedirectory_for_attachments']);
110
+	} else {
111
+			$context['valid_basedirectory'] = true;
112
+	}
111 113
 
112 114
 	// A bit of razzle dazzle with the $txt strings. :)
113 115
 	$txt['attachment_path'] = $context['attachmentUploadDir'];
@@ -185,8 +187,9 @@  discard block
 block discarded – undo
185 187
 
186 188
 	call_integration_hook('integrate_modify_attachment_settings', array(&$config_vars));
187 189
 
188
-	if ($return_config)
189
-		return $config_vars;
190
+	if ($return_config) {
191
+			return $config_vars;
192
+	}
190 193
 
191 194
 	// These are very likely to come in handy! (i.e. without them we're doomed!)
192 195
 	require_once($sourcedir . '/ManagePermissions.php');
@@ -197,21 +200,24 @@  discard block
 block discarded – undo
197 200
 	{
198 201
 		checkSession();
199 202
 
200
-		if (isset($_POST['attachmentUploadDir']))
201
-			unset($_POST['attachmentUploadDir']);
203
+		if (isset($_POST['attachmentUploadDir'])) {
204
+					unset($_POST['attachmentUploadDir']);
205
+		}
202 206
 
203 207
 		if (!empty($_POST['use_subdirectories_for_attachments']))
204 208
 		{
205
-			if (isset($_POST['use_subdirectories_for_attachments']) && empty($_POST['basedirectory_for_attachments']))
206
-				$_POST['basedirectory_for_attachments'] = (!empty($modSettings['basedirectory_for_attachments']) ? ($modSettings['basedirectory_for_attachments']) : $boarddir);
209
+			if (isset($_POST['use_subdirectories_for_attachments']) && empty($_POST['basedirectory_for_attachments'])) {
210
+							$_POST['basedirectory_for_attachments'] = (!empty($modSettings['basedirectory_for_attachments']) ? ($modSettings['basedirectory_for_attachments']) : $boarddir);
211
+			}
207 212
 
208 213
 			if (!empty($_POST['use_subdirectories_for_attachments']) && !empty($modSettings['attachment_basedirectories']))
209 214
 			{
210
-				if (!is_array($modSettings['attachment_basedirectories']))
211
-					$modSettings['attachment_basedirectories'] = smf_json_decode($modSettings['attachment_basedirectories'], true);
215
+				if (!is_array($modSettings['attachment_basedirectories'])) {
216
+									$modSettings['attachment_basedirectories'] = smf_json_decode($modSettings['attachment_basedirectories'], true);
217
+				}
218
+			} else {
219
+							$modSettings['attachment_basedirectories'] = array();
212 220
 			}
213
-			else
214
-				$modSettings['attachment_basedirectories'] = array();
215 221
 
216 222
 			if (!empty($_POST['use_subdirectories_for_attachments']) && !empty($_POST['basedirectory_for_attachments']) && !in_array($_POST['basedirectory_for_attachments'], $modSettings['attachment_basedirectories']))
217 223
 			{
@@ -219,8 +225,9 @@  discard block
 block discarded – undo
219 225
 
220 226
 				if (!in_array($_POST['basedirectory_for_attachments'], $modSettings['attachmentUploadDir']))
221 227
 				{
222
-					if (!automanage_attachments_create_directory($_POST['basedirectory_for_attachments']))
223
-						$_POST['basedirectory_for_attachments'] = $modSettings['basedirectory_for_attachments'];
228
+					if (!automanage_attachments_create_directory($_POST['basedirectory_for_attachments'])) {
229
+											$_POST['basedirectory_for_attachments'] = $modSettings['basedirectory_for_attachments'];
230
+					}
224 231
 				}
225 232
 
226 233
 				if (!in_array($_POST['basedirectory_for_attachments'], $modSettings['attachment_basedirectories']))
@@ -336,8 +343,9 @@  discard block
 block discarded – undo
336 343
 
337 344
 	call_integration_hook('integrate_modify_avatar_settings', array(&$config_vars));
338 345
 
339
-	if ($return_config)
340
-		return $config_vars;
346
+	if ($return_config) {
347
+			return $config_vars;
348
+	}
341 349
 
342 350
 	// We need this file for the settings template.
343 351
 	require_once($sourcedir . '/ManageServer.php');
@@ -348,17 +356,21 @@  discard block
 block discarded – undo
348 356
 		checkSession();
349 357
 
350 358
 		// These settings cannot be left empty!
351
-		if (empty($_POST['custom_avatar_dir']))
352
-			$_POST['custom_avatar_dir'] = $boarddir .'/custom_avatar';
359
+		if (empty($_POST['custom_avatar_dir'])) {
360
+					$_POST['custom_avatar_dir'] = $boarddir .'/custom_avatar';
361
+		}
353 362
 
354
-		if (empty($_POST['custom_avatar_url']))
355
-			$_POST['custom_avatar_url'] = $boardurl .'/custom_avatar';
363
+		if (empty($_POST['custom_avatar_url'])) {
364
+					$_POST['custom_avatar_url'] = $boardurl .'/custom_avatar';
365
+		}
356 366
 
357
-		if (empty($_POST['avatar_directory']))
358
-			$_POST['avatar_directory'] = $boarddir .'/avatars';
367
+		if (empty($_POST['avatar_directory'])) {
368
+					$_POST['avatar_directory'] = $boarddir .'/avatars';
369
+		}
359 370
 
360
-		if (empty($_POST['avatar_url']))
361
-			$_POST['avatar_url'] = $boardurl .'/avatars';
371
+		if (empty($_POST['avatar_url'])) {
372
+					$_POST['avatar_url'] = $boardurl .'/avatars';
373
+		}
362 374
 
363 375
 		call_integration_hook('integrate_save_avatar_settings');
364 376
 
@@ -406,11 +418,13 @@  discard block
 block discarded – undo
406 418
 	$list_title = $txt['attachment_manager_browse_files'] . ': ';
407 419
 	foreach ($titles as $browse_type => $details)
408 420
 	{
409
-		if ($browse_type != 'attachments')
410
-			$list_title .= ' | ';
421
+		if ($browse_type != 'attachments') {
422
+					$list_title .= ' | ';
423
+		}
411 424
 
412
-		if ($context['browse_type'] == $browse_type)
413
-			$list_title .= '<img src="' . $settings['images_url'] . '/selected.png" alt="&gt;"> ';
425
+		if ($context['browse_type'] == $browse_type) {
426
+					$list_title .= '<img src="' . $settings['images_url'] . '/selected.png" alt="&gt;"> ';
427
+		}
414 428
 
415 429
 		$list_title .= '<a href="' . $scripturl . $details[0] . '">' . $details[1] . '</a>';
416 430
 	}
@@ -446,28 +460,33 @@  discard block
 block discarded – undo
446 460
 						$link = '<a href="';
447 461
 
448 462
 						// In case of a custom avatar URL attachments have a fixed directory.
449
-						if ($rowData['attachment_type'] == 1)
450
-							$link .= sprintf('%1$s/%2$s', $modSettings['custom_avatar_url'], $rowData['filename']);
463
+						if ($rowData['attachment_type'] == 1) {
464
+													$link .= sprintf('%1$s/%2$s', $modSettings['custom_avatar_url'], $rowData['filename']);
465
+						}
451 466
 
452 467
 						// By default avatars are downloaded almost as attachments.
453
-						elseif ($context['browse_type'] == 'avatars')
454
-							$link .= sprintf('%1$s?action=dlattach;type=avatar;attach=%2$d', $scripturl, $rowData['id_attach']);
468
+						elseif ($context['browse_type'] == 'avatars') {
469
+													$link .= sprintf('%1$s?action=dlattach;type=avatar;attach=%2$d', $scripturl, $rowData['id_attach']);
470
+						}
455 471
 
456 472
 						// Normal attachments are always linked to a topic ID.
457
-						else
458
-							$link .= sprintf('%1$s?action=dlattach;topic=%2$d.0;attach=%3$d', $scripturl, $rowData['id_topic'], $rowData['id_attach']);
473
+						else {
474
+													$link .= sprintf('%1$s?action=dlattach;topic=%2$d.0;attach=%3$d', $scripturl, $rowData['id_topic'], $rowData['id_attach']);
475
+						}
459 476
 
460 477
 						$link .= '"';
461 478
 
462 479
 						// Show a popup on click if it's a picture and we know its dimensions.
463
-						if (!empty($rowData['width']) && !empty($rowData['height']))
464
-							$link .= sprintf(' onclick="return reqWin(this.href' . ($rowData['attachment_type'] == 1 ? '' : ' + \';image\'') . ', %1$d, %2$d, true);"', $rowData['width'] + 20, $rowData['height'] + 20);
480
+						if (!empty($rowData['width']) && !empty($rowData['height'])) {
481
+													$link .= sprintf(' onclick="return reqWin(this.href' . ($rowData['attachment_type'] == 1 ? '' : ' + \';image\'') . ', %1$d, %2$d, true);"', $rowData['width'] + 20, $rowData['height'] + 20);
482
+						}
465 483
 
466 484
 						$link .= sprintf('>%1$s</a>', preg_replace('~&amp;#(\\\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\\\1;', $smcFunc['htmlspecialchars']($rowData['filename'])));
467 485
 
468 486
 						// Show the dimensions.
469
-						if (!empty($rowData['width']) && !empty($rowData['height']))
470
-							$link .= sprintf(' <span class="smalltext">%1$dx%2$d</span>', $rowData['width'], $rowData['height']);
487
+						if (!empty($rowData['width']) && !empty($rowData['height'])) {
488
+													$link .= sprintf(' <span class="smalltext">%1$dx%2$d</span>', $rowData['width'], $rowData['height']);
489
+						}
471 490
 
472 491
 						return $link;
473 492
 					},
@@ -500,12 +519,14 @@  discard block
 block discarded – undo
500 519
 					'function' => function ($rowData) use ($scripturl, $smcFunc)
501 520
 					{
502 521
 						// In case of an attachment, return the poster of the attachment.
503
-						if (empty($rowData['id_member']))
504
-							return $smcFunc['htmlspecialchars']($rowData['poster_name']);
522
+						if (empty($rowData['id_member'])) {
523
+													return $smcFunc['htmlspecialchars']($rowData['poster_name']);
524
+						}
505 525
 
506 526
 						// Otherwise it must be an avatar, return the link to the owner of it.
507
-						else
508
-							return sprintf('<a href="%1$s?action=profile;u=%2$d">%3$s</a>', $scripturl, $rowData['id_member'], $rowData['poster_name']);
527
+						else {
528
+													return sprintf('<a href="%1$s?action=profile;u=%2$d">%3$s</a>', $scripturl, $rowData['id_member'], $rowData['poster_name']);
529
+						}
509 530
 					},
510 531
 				),
511 532
 				'sort' => array(
@@ -524,8 +545,9 @@  discard block
 block discarded – undo
524 545
 						$date = empty($rowData['poster_time']) ? $txt['never'] : timeformat($rowData['poster_time']);
525 546
 
526 547
 						// Add a link to the topic in case of an attachment.
527
-						if ($context['browse_type'] !== 'avatars')
528
-							$date .= sprintf('<br>%1$s <a href="%2$s?topic=%3$d.msg%4$d#msg%4$d">%5$s</a>', $txt['in'], $scripturl, $rowData['id_topic'], $rowData['id_msg'], $rowData['subject']);
548
+						if ($context['browse_type'] !== 'avatars') {
549
+													$date .= sprintf('<br>%1$s <a href="%2$s?topic=%3$d.msg%4$d#msg%4$d">%5$s</a>', $txt['in'], $scripturl, $rowData['id_topic'], $rowData['id_msg'], $rowData['subject']);
550
+						}
529 551
 
530 552
 						return $date;
531 553
 					},
@@ -610,8 +632,8 @@  discard block
 block discarded – undo
610 632
 	global $smcFunc, $txt;
611 633
 
612 634
 	// Choose a query depending on what we are viewing.
613
-	if ($browse_type === 'avatars')
614
-		$request = $smcFunc['db_query']('', '
635
+	if ($browse_type === 'avatars') {
636
+			$request = $smcFunc['db_query']('', '
615 637
 			SELECT
616 638
 				{string:blank_text} AS id_msg, COALESCE(mem.real_name, {string:not_applicable_text}) AS poster_name,
617 639
 				mem.last_login AS poster_time, 0 AS id_topic, a.id_member, a.id_attach, a.filename, a.file_hash, a.attachment_type,
@@ -630,8 +652,8 @@  discard block
 block discarded – undo
630 652
 				'per_page' => $items_per_page,
631 653
 			)
632 654
 		);
633
-	else
634
-		$request = $smcFunc['db_query']('', '
655
+	} else {
656
+			$request = $smcFunc['db_query']('', '
635 657
 			SELECT
636 658
 				m.id_msg, COALESCE(mem.real_name, m.poster_name) AS poster_name, m.poster_time, m.id_topic, m.id_member,
637 659
 				a.id_attach, a.filename, a.file_hash, a.attachment_type, a.size, a.width, a.height, a.downloads, mf.subject, t.id_board
@@ -650,9 +672,11 @@  discard block
 block discarded – undo
650 672
 				'per_page' => $items_per_page,
651 673
 			)
652 674
 		);
675
+	}
653 676
 	$files = array();
654
-	while ($row = $smcFunc['db_fetch_assoc']($request))
655
-		$files[] = $row;
677
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
678
+			$files[] = $row;
679
+	}
656 680
 	$smcFunc['db_free_result']($request);
657 681
 
658 682
 	return $files;
@@ -670,8 +694,8 @@  discard block
 block discarded – undo
670 694
 	global $smcFunc;
671 695
 
672 696
 	// Depending on the type of file, different queries are used.
673
-	if ($browse_type === 'avatars')
674
-		$request = $smcFunc['db_query']('', '
697
+	if ($browse_type === 'avatars') {
698
+			$request = $smcFunc['db_query']('', '
675 699
 		SELECT COUNT(*)
676 700
 		FROM {db_prefix}attachments
677 701
 		WHERE id_member != {int:guest_id_member}',
@@ -679,8 +703,8 @@  discard block
 block discarded – undo
679 703
 			'guest_id_member' => 0,
680 704
 		)
681 705
 	);
682
-	else
683
-		$request = $smcFunc['db_query']('', '
706
+	} else {
707
+			$request = $smcFunc['db_query']('', '
684 708
 			SELECT COUNT(*) AS num_attach
685 709
 			FROM {db_prefix}attachments AS a
686 710
 				INNER JOIN {db_prefix}messages AS m ON (m.id_msg = a.id_msg)
@@ -693,6 +717,7 @@  discard block
 block discarded – undo
693 717
 				'guest_id_member' => 0,
694 718
 			)
695 719
 		);
720
+	}
696 721
 
697 722
 	list ($num_files) = $smcFunc['db_fetch_row']($request);
698 723
 	$smcFunc['db_free_result']($request);
@@ -775,12 +800,14 @@  discard block
 block discarded – undo
775 800
 	$current_dir_size /= 1024;
776 801
 
777 802
 	// If they specified a limit only....
778
-	if (!empty($modSettings['attachmentDirSizeLimit']))
779
-		$context['attachment_space'] = comma_format(max($modSettings['attachmentDirSizeLimit'] - $current_dir_size, 0), 2);
803
+	if (!empty($modSettings['attachmentDirSizeLimit'])) {
804
+			$context['attachment_space'] = comma_format(max($modSettings['attachmentDirSizeLimit'] - $current_dir_size, 0), 2);
805
+	}
780 806
 	$context['attachment_current_size'] = comma_format($current_dir_size, 2);
781 807
 
782
-	if (!empty($modSettings['attachmentDirFileLimit']))
783
-		$context['attachment_files'] = comma_format(max($modSettings['attachmentDirFileLimit'] - $current_dir_files, 0), 0);
808
+	if (!empty($modSettings['attachmentDirFileLimit'])) {
809
+			$context['attachment_files'] = comma_format(max($modSettings['attachmentDirFileLimit'] - $current_dir_files, 0), 0);
810
+	}
784 811
 	$context['attachment_current_files'] = comma_format($current_dir_files, 0);
785 812
 
786 813
 	$context['attach_multiple_dirs'] = count($attach_dirs) > 1 ? true : false;
@@ -817,8 +844,8 @@  discard block
 block discarded – undo
817 844
 		$messages = removeAttachments(array('attachment_type' => 0, 'poster_time' => (time() - 24 * 60 * 60 * $_POST['age'])), 'messages', true);
818 845
 
819 846
 		// Update the messages to reflect the change.
820
-		if (!empty($messages) && !empty($_POST['notice']))
821
-			$smcFunc['db_query']('', '
847
+		if (!empty($messages) && !empty($_POST['notice'])) {
848
+					$smcFunc['db_query']('', '
822 849
 				UPDATE {db_prefix}messages
823 850
 				SET body = CONCAT(body, {string:notice})
824 851
 				WHERE id_msg IN ({array_int:messages})',
@@ -827,8 +854,8 @@  discard block
 block discarded – undo
827 854
 					'notice' => '<br><br>' . $_POST['notice'],
828 855
 				)
829 856
 			);
830
-	}
831
-	else
857
+		}
858
+	} else
832 859
 	{
833 860
 		// Remove all the old avatars.
834 861
 		removeAttachments(array('not_id_member' => 0, 'last_login' => (time() - 24 * 60 * 60 * $_POST['age'])), 'members');
@@ -853,8 +880,8 @@  discard block
 block discarded – undo
853 880
 	$messages = removeAttachments(array('attachment_type' => 0, 'size' => 1024 * $_POST['size']), 'messages', true);
854 881
 
855 882
 	// And make a note on the post.
856
-	if (!empty($messages) && !empty($_POST['notice']))
857
-		$smcFunc['db_query']('', '
883
+	if (!empty($messages) && !empty($_POST['notice'])) {
884
+			$smcFunc['db_query']('', '
858 885
 			UPDATE {db_prefix}messages
859 886
 			SET body = CONCAT(body, {string:notice})
860 887
 			WHERE id_msg IN ({array_int:messages})',
@@ -863,6 +890,7 @@  discard block
 block discarded – undo
863 890
 				'notice' => '<br><br>' . $_POST['notice'],
864 891
 			)
865 892
 		);
893
+	}
866 894
 
867 895
 	redirectexit('action=admin;area=manageattachments;sa=maintenance');
868 896
 }
@@ -882,16 +910,17 @@  discard block
 block discarded – undo
882 910
 	{
883 911
 		$attachments = array();
884 912
 		// There must be a quicker way to pass this safety test??
885
-		foreach ($_POST['remove'] as $removeID => $dummy)
886
-			$attachments[] = (int) $removeID;
913
+		foreach ($_POST['remove'] as $removeID => $dummy) {
914
+					$attachments[] = (int) $removeID;
915
+		}
887 916
 
888 917
 		// If the attachments are from a 3rd party, let them remove it. Hooks should remove their ids from the array.
889 918
 		$filesRemoved = false;
890 919
 		call_integration_hook('integrate_attachment_remove', array(&$filesRemoved, $attachments));
891 920
 
892
-		if ($_REQUEST['type'] == 'avatars' && !empty($attachments))
893
-			removeAttachments(array('id_attach' => $attachments));
894
-		else if (!empty($attachments))
921
+		if ($_REQUEST['type'] == 'avatars' && !empty($attachments)) {
922
+					removeAttachments(array('id_attach' => $attachments));
923
+		} else if (!empty($attachments))
895 924
 		{
896 925
 			$messages = removeAttachments(array('id_attach' => $attachments), 'messages', true);
897 926
 
@@ -930,12 +959,13 @@  discard block
 block discarded – undo
930 959
 
931 960
 	$messages = removeAttachments(array('attachment_type' => 0), '', true);
932 961
 
933
-	if (!isset($_POST['notice']))
934
-		$_POST['notice'] = $txt['attachment_delete_admin'];
962
+	if (!isset($_POST['notice'])) {
963
+			$_POST['notice'] = $txt['attachment_delete_admin'];
964
+	}
935 965
 
936 966
 	// Add the notice on the end of the changed messages.
937
-	if (!empty($messages))
938
-		$smcFunc['db_query']('', '
967
+	if (!empty($messages)) {
968
+			$smcFunc['db_query']('', '
939 969
 			UPDATE {db_prefix}messages
940 970
 			SET body = CONCAT(body, {string:deleted_message})
941 971
 			WHERE id_msg IN ({array_int:messages})',
@@ -944,6 +974,7 @@  discard block
 block discarded – undo
944 974
 				'deleted_message' => '<br><br>' . $_POST['notice'],
945 975
 			)
946 976
 		);
977
+	}
947 978
 
948 979
 	redirectexit('action=admin;area=manageattachments;sa=maintenance');
949 980
 }
@@ -982,24 +1013,26 @@  discard block
 block discarded – undo
982 1013
 			$is_not = substr($real_type, 0, 4) == 'not_';
983 1014
 			$type = $is_not ? substr($real_type, 4) : $real_type;
984 1015
 
985
-			if (in_array($type, array('id_member', 'id_attach', 'id_msg')))
986
-				$new_condition[] = 'a.' . $type . ($is_not ? ' NOT' : '') . ' IN (' . (is_array($restriction) ? '{array_int:' . $real_type . '}' : '{int:' . $real_type . '}') . ')';
987
-			elseif ($type == 'attachment_type')
988
-				$new_condition[] = 'a.attachment_type = {int:' . $real_type . '}';
989
-			elseif ($type == 'poster_time')
990
-				$new_condition[] = 'm.poster_time < {int:' . $real_type . '}';
991
-			elseif ($type == 'last_login')
992
-				$new_condition[] = 'mem.last_login < {int:' . $real_type . '}';
993
-			elseif ($type == 'size')
994
-				$new_condition[] = 'a.size > {int:' . $real_type . '}';
995
-			elseif ($type == 'id_topic')
996
-				$new_condition[] = 'm.id_topic IN (' . (is_array($restriction) ? '{array_int:' . $real_type . '}' : '{int:' . $real_type . '}') . ')';
1016
+			if (in_array($type, array('id_member', 'id_attach', 'id_msg'))) {
1017
+							$new_condition[] = 'a.' . $type . ($is_not ? ' NOT' : '') . ' IN (' . (is_array($restriction) ? '{array_int:' . $real_type . '}' : '{int:' . $real_type . '}') . ')';
1018
+			} elseif ($type == 'attachment_type') {
1019
+							$new_condition[] = 'a.attachment_type = {int:' . $real_type . '}';
1020
+			} elseif ($type == 'poster_time') {
1021
+							$new_condition[] = 'm.poster_time < {int:' . $real_type . '}';
1022
+			} elseif ($type == 'last_login') {
1023
+							$new_condition[] = 'mem.last_login < {int:' . $real_type . '}';
1024
+			} elseif ($type == 'size') {
1025
+							$new_condition[] = 'a.size > {int:' . $real_type . '}';
1026
+			} elseif ($type == 'id_topic') {
1027
+							$new_condition[] = 'm.id_topic IN (' . (is_array($restriction) ? '{array_int:' . $real_type . '}' : '{int:' . $real_type . '}') . ')';
1028
+			}
997 1029
 
998 1030
 			// Add the parameter!
999 1031
 			$query_parameter[$real_type] = $restriction;
1000 1032
 
1001
-			if ($type == 'do_logging')
1002
-				$do_logging = $condition['id_attach'];
1033
+			if ($type == 'do_logging') {
1034
+							$do_logging = $condition['id_attach'];
1035
+			}
1003 1036
 		}
1004 1037
 		$condition = implode(' AND ', $new_condition);
1005 1038
 	}
@@ -1031,15 +1064,15 @@  discard block
 block discarded – undo
1031 1064
 			// wasn't it obvious? :P
1032 1065
 			// @todo look again at this.
1033 1066
 			@unlink($modSettings['custom_avatar_dir'] . '/' . $row['filename']);
1034
-		}
1035
-		else
1067
+		} else
1036 1068
 		{
1037 1069
 			$filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']);
1038 1070
 			@unlink($filename);
1039 1071
 
1040 1072
 			// If this was a thumb, the parent attachment should know about it.
1041
-			if (!empty($row['id_parent']))
1042
-				$parents[] = $row['id_parent'];
1073
+			if (!empty($row['id_parent'])) {
1074
+							$parents[] = $row['id_parent'];
1075
+			}
1043 1076
 
1044 1077
 			// If this attachments has a thumb, remove it as well.
1045 1078
 			if (!empty($row['id_thumb']) && $autoThumbRemoval)
@@ -1051,8 +1084,9 @@  discard block
 block discarded – undo
1051 1084
 		}
1052 1085
 
1053 1086
 		// Make a list.
1054
-		if ($return_affected_messages && empty($row['attachment_type']))
1055
-			$msgs[] = $row['id_msg'];
1087
+		if ($return_affected_messages && empty($row['attachment_type'])) {
1088
+					$msgs[] = $row['id_msg'];
1089
+		}
1056 1090
 
1057 1091
 		$attach[] = $row['id_attach'];
1058 1092
 	}
@@ -1060,8 +1094,8 @@  discard block
 block discarded – undo
1060 1094
 
1061 1095
 	// Removed attachments don't have to be updated anymore.
1062 1096
 	$parents = array_diff($parents, $attach);
1063
-	if (!empty($parents))
1064
-		$smcFunc['db_query']('', '
1097
+	if (!empty($parents)) {
1098
+			$smcFunc['db_query']('', '
1065 1099
 			UPDATE {db_prefix}attachments
1066 1100
 			SET id_thumb = {int:no_thumb}
1067 1101
 			WHERE id_attach IN ({array_int:parent_attachments})',
@@ -1070,6 +1104,7 @@  discard block
 block discarded – undo
1070 1104
 				'no_thumb' => 0,
1071 1105
 			)
1072 1106
 		);
1107
+	}
1073 1108
 
1074 1109
 	if (!empty($do_logging))
1075 1110
 	{
@@ -1086,31 +1121,34 @@  discard block
 block discarded – undo
1086 1121
 			)
1087 1122
 		);
1088 1123
 
1089
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1090
-			logAction(
1124
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1125
+					logAction(
1091 1126
 				'remove_attach',
1092 1127
 				array(
1093 1128
 					'message' => $row['id_msg'],
1094 1129
 					'filename' => preg_replace('~&amp;#(\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\1;', $smcFunc['htmlspecialchars']($row['filename'])),
1095 1130
 				)
1096 1131
 			);
1132
+		}
1097 1133
 		$smcFunc['db_free_result']($request);
1098 1134
 	}
1099 1135
 
1100
-	if (!empty($attach))
1101
-		$smcFunc['db_query']('', '
1136
+	if (!empty($attach)) {
1137
+			$smcFunc['db_query']('', '
1102 1138
 			DELETE FROM {db_prefix}attachments
1103 1139
 			WHERE id_attach IN ({array_int:attachment_list})',
1104 1140
 			array(
1105 1141
 				'attachment_list' => $attach,
1106 1142
 			)
1107 1143
 		);
1144
+	}
1108 1145
 
1109 1146
 	call_integration_hook('integrate_remove_attachments', array($attach));
1110 1147
 
1111
-	if ($return_affected_messages)
1112
-		return array_unique($msgs);
1113
-}
1148
+	if ($return_affected_messages) {
1149
+			return array_unique($msgs);
1150
+	}
1151
+	}
1114 1152
 
1115 1153
 /**
1116 1154
  * This function should find attachments in the database that no longer exist and clear them, and fix filesize issues.
@@ -1122,8 +1160,9 @@  discard block
 block discarded – undo
1122 1160
 	checkSession('get');
1123 1161
 
1124 1162
 	// If we choose cancel, redirect right back.
1125
-	if (isset($_POST['cancel']))
1126
-		redirectexit('action=admin;area=manageattachments;sa=maintenance');
1163
+	if (isset($_POST['cancel'])) {
1164
+			redirectexit('action=admin;area=manageattachments;sa=maintenance');
1165
+	}
1127 1166
 
1128 1167
 	// Try give us a while to sort this out...
1129 1168
 	@set_time_limit(600);
@@ -1140,13 +1179,15 @@  discard block
 block discarded – undo
1140 1179
 		if (isset($_GET['fixErrors']))
1141 1180
 		{
1142 1181
 			// Nothing?
1143
-			if (empty($_POST['to_fix']))
1144
-				redirectexit('action=admin;area=manageattachments;sa=maintenance');
1182
+			if (empty($_POST['to_fix'])) {
1183
+							redirectexit('action=admin;area=manageattachments;sa=maintenance');
1184
+			}
1145 1185
 
1146 1186
 			$_SESSION['attachments_to_fix'] = array();
1147 1187
 			// @todo No need to do this I think.
1148
-			foreach ($_POST['to_fix'] as $value)
1149
-				$_SESSION['attachments_to_fix'][] = $value;
1188
+			foreach ($_POST['to_fix'] as $value) {
1189
+							$_SESSION['attachments_to_fix'][] = $value;
1190
+			}
1150 1191
 		}
1151 1192
 	}
1152 1193
 
@@ -1213,13 +1254,14 @@  discard block
 block discarded – undo
1213 1254
 					}
1214 1255
 				}
1215 1256
 			}
1216
-			if ($smcFunc['db_num_rows']($result) != 0)
1217
-				$to_fix[] = 'missing_thumbnail_parent';
1257
+			if ($smcFunc['db_num_rows']($result) != 0) {
1258
+							$to_fix[] = 'missing_thumbnail_parent';
1259
+			}
1218 1260
 			$smcFunc['db_free_result']($result);
1219 1261
 
1220 1262
 			// Do we need to delete what we have?
1221
-			if ($fix_errors && !empty($to_remove) && in_array('missing_thumbnail_parent', $to_fix))
1222
-				$smcFunc['db_query']('', '
1263
+			if ($fix_errors && !empty($to_remove) && in_array('missing_thumbnail_parent', $to_fix)) {
1264
+							$smcFunc['db_query']('', '
1223 1265
 					DELETE FROM {db_prefix}attachments
1224 1266
 					WHERE id_attach IN ({array_int:to_remove})
1225 1267
 						AND attachment_type = {int:attachment_type}',
@@ -1228,6 +1270,7 @@  discard block
 block discarded – undo
1228 1270
 						'attachment_type' => 3,
1229 1271
 					)
1230 1272
 				);
1273
+			}
1231 1274
 
1232 1275
 			pauseAttachmentMaintenance($to_fix, $thumbnails);
1233 1276
 		}
@@ -1272,13 +1315,14 @@  discard block
 block discarded – undo
1272 1315
 				$to_update[] = $row['id_attach'];
1273 1316
 				$context['repair_errors']['parent_missing_thumbnail']++;
1274 1317
 			}
1275
-			if ($smcFunc['db_num_rows']($result) != 0)
1276
-				$to_fix[] = 'parent_missing_thumbnail';
1318
+			if ($smcFunc['db_num_rows']($result) != 0) {
1319
+							$to_fix[] = 'parent_missing_thumbnail';
1320
+			}
1277 1321
 			$smcFunc['db_free_result']($result);
1278 1322
 
1279 1323
 			// Do we need to delete what we have?
1280
-			if ($fix_errors && !empty($to_update) && in_array('parent_missing_thumbnail', $to_fix))
1281
-				$smcFunc['db_query']('', '
1324
+			if ($fix_errors && !empty($to_update) && in_array('parent_missing_thumbnail', $to_fix)) {
1325
+							$smcFunc['db_query']('', '
1282 1326
 					UPDATE {db_prefix}attachments
1283 1327
 					SET id_thumb = {int:no_thumb}
1284 1328
 					WHERE id_attach IN ({array_int:to_update})',
@@ -1287,6 +1331,7 @@  discard block
 block discarded – undo
1287 1331
 						'no_thumb' => 0,
1288 1332
 					)
1289 1333
 				);
1334
+			}
1290 1335
 
1291 1336
 			pauseAttachmentMaintenance($to_fix, $thumbnails);
1292 1337
 		}
@@ -1324,10 +1369,11 @@  discard block
 block discarded – undo
1324 1369
 			while ($row = $smcFunc['db_fetch_assoc']($result))
1325 1370
 			{
1326 1371
 				// Get the filename.
1327
-				if ($row['attachment_type'] == 1)
1328
-					$filename = $modSettings['custom_avatar_dir'] . '/' . $row['filename'];
1329
-				else
1330
-					$filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']);
1372
+				if ($row['attachment_type'] == 1) {
1373
+									$filename = $modSettings['custom_avatar_dir'] . '/' . $row['filename'];
1374
+				} else {
1375
+									$filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']);
1376
+				}
1331 1377
 
1332 1378
 				// File doesn't exist?
1333 1379
 				if (!file_exists($filename))
@@ -1339,15 +1385,16 @@  discard block
 block discarded – undo
1339 1385
 						$attachment_name = $row['id_attach'] . '_' . $row['file_hash'] .'.dat';
1340 1386
 
1341 1387
 						// Loop through the other folders.
1342
-						foreach ($modSettings['attachmentUploadDir'] as $id => $dir)
1343
-							if (file_exists($dir . '/' . $attachment_name))
1388
+						foreach ($modSettings['attachmentUploadDir'] as $id => $dir) {
1389
+													if (file_exists($dir . '/' . $attachment_name))
1344 1390
 							{
1345 1391
 								$context['repair_errors']['wrong_folder']++;
1392
+						}
1346 1393
 								$errors_found[] = 'wrong_folder';
1347 1394
 
1348 1395
 								// Are we going to fix this now?
1349
-								if ($fix_errors && in_array('wrong_folder', $to_fix))
1350
-									$smcFunc['db_query']('', '
1396
+								if ($fix_errors && in_array('wrong_folder', $to_fix)) {
1397
+																	$smcFunc['db_query']('', '
1351 1398
 										UPDATE {db_prefix}attachments
1352 1399
 										SET id_folder = {int:new_folder}
1353 1400
 										WHERE id_attach = {int:id_attach}',
@@ -1356,6 +1403,7 @@  discard block
 block discarded – undo
1356 1403
 											'id_attach' => $row['id_attach'],
1357 1404
 										)
1358 1405
 									);
1406
+								}
1359 1407
 
1360 1408
 								continue 2;
1361 1409
 							}
@@ -1364,8 +1412,7 @@  discard block
 block discarded – undo
1364 1412
 					$to_remove[] = $row['id_attach'];
1365 1413
 					$context['repair_errors']['file_missing_on_disk']++;
1366 1414
 					$errors_found[] = 'file_missing_on_disk';
1367
-				}
1368
-				elseif (filesize($filename) == 0)
1415
+				} elseif (filesize($filename) == 0)
1369 1416
 				{
1370 1417
 					$context['repair_errors']['file_size_of_zero']++;
1371 1418
 					$errors_found[] = 'file_size_of_zero';
@@ -1376,8 +1423,7 @@  discard block
 block discarded – undo
1376 1423
 						$to_remove[] = $row['id_attach'];
1377 1424
 						@unlink($filename);
1378 1425
 					}
1379
-				}
1380
-				elseif (filesize($filename) != $row['size'])
1426
+				} elseif (filesize($filename) != $row['size'])
1381 1427
 				{
1382 1428
 					$context['repair_errors']['file_wrong_size']++;
1383 1429
 					$errors_found[] = 'file_wrong_size';
@@ -1398,14 +1444,18 @@  discard block
 block discarded – undo
1398 1444
 				}
1399 1445
 			}
1400 1446
 
1401
-			if (in_array('file_missing_on_disk', $errors_found))
1402
-				$to_fix[] = 'file_missing_on_disk';
1403
-			if (in_array('file_size_of_zero', $errors_found))
1404
-				$to_fix[] = 'file_size_of_zero';
1405
-			if (in_array('file_wrong_size', $errors_found))
1406
-				$to_fix[] = 'file_wrong_size';
1407
-			if (in_array('wrong_folder', $errors_found))
1408
-				$to_fix[] = 'wrong_folder';
1447
+			if (in_array('file_missing_on_disk', $errors_found)) {
1448
+							$to_fix[] = 'file_missing_on_disk';
1449
+			}
1450
+			if (in_array('file_size_of_zero', $errors_found)) {
1451
+							$to_fix[] = 'file_size_of_zero';
1452
+			}
1453
+			if (in_array('file_wrong_size', $errors_found)) {
1454
+							$to_fix[] = 'file_wrong_size';
1455
+			}
1456
+			if (in_array('wrong_folder', $errors_found)) {
1457
+							$to_fix[] = 'wrong_folder';
1458
+			}
1409 1459
 			$smcFunc['db_free_result']($result);
1410 1460
 
1411 1461
 			// Do we need to delete what we have?
@@ -1475,20 +1525,22 @@  discard block
 block discarded – undo
1475 1525
 				// If we are repairing remove the file from disk now.
1476 1526
 				if ($fix_errors && in_array('avatar_no_member', $to_fix))
1477 1527
 				{
1478
-					if ($row['attachment_type'] == 1)
1479
-						$filename = $modSettings['custom_avatar_dir'] . '/' . $row['filename'];
1480
-					else
1481
-						$filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']);
1528
+					if ($row['attachment_type'] == 1) {
1529
+											$filename = $modSettings['custom_avatar_dir'] . '/' . $row['filename'];
1530
+					} else {
1531
+											$filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']);
1532
+					}
1482 1533
 					@unlink($filename);
1483 1534
 				}
1484 1535
 			}
1485
-			if ($smcFunc['db_num_rows']($result) != 0)
1486
-				$to_fix[] = 'avatar_no_member';
1536
+			if ($smcFunc['db_num_rows']($result) != 0) {
1537
+							$to_fix[] = 'avatar_no_member';
1538
+			}
1487 1539
 			$smcFunc['db_free_result']($result);
1488 1540
 
1489 1541
 			// Do we need to delete what we have?
1490
-			if ($fix_errors && !empty($to_remove) && in_array('avatar_no_member', $to_fix))
1491
-				$smcFunc['db_query']('', '
1542
+			if ($fix_errors && !empty($to_remove) && in_array('avatar_no_member', $to_fix)) {
1543
+							$smcFunc['db_query']('', '
1492 1544
 					DELETE FROM {db_prefix}attachments
1493 1545
 					WHERE id_attach IN ({array_int:to_remove})
1494 1546
 						AND id_member != {int:no_member}
@@ -1499,6 +1551,7 @@  discard block
 block discarded – undo
1499 1551
 						'no_msg' => 0,
1500 1552
 					)
1501 1553
 				);
1554
+			}
1502 1555
 
1503 1556
 			pauseAttachmentMaintenance($to_fix, $thumbnails);
1504 1557
 		}
@@ -1554,13 +1607,14 @@  discard block
 block discarded – undo
1554 1607
 					@unlink($filename);
1555 1608
 				}
1556 1609
 			}
1557
-			if ($smcFunc['db_num_rows']($result) != 0)
1558
-				$to_fix[] = 'attachment_no_msg';
1610
+			if ($smcFunc['db_num_rows']($result) != 0) {
1611
+							$to_fix[] = 'attachment_no_msg';
1612
+			}
1559 1613
 			$smcFunc['db_free_result']($result);
1560 1614
 
1561 1615
 			// Do we need to delete what we have?
1562
-			if ($fix_errors && !empty($to_remove) && in_array('attachment_no_msg', $to_fix))
1563
-				$smcFunc['db_query']('', '
1616
+			if ($fix_errors && !empty($to_remove) && in_array('attachment_no_msg', $to_fix)) {
1617
+							$smcFunc['db_query']('', '
1564 1618
 					DELETE FROM {db_prefix}attachments
1565 1619
 					WHERE id_attach IN ({array_int:to_remove})
1566 1620
 						AND id_member = {int:no_member}
@@ -1571,6 +1625,7 @@  discard block
 block discarded – undo
1571 1625
 						'no_msg' => 0,
1572 1626
 					)
1573 1627
 				);
1628
+			}
1574 1629
 
1575 1630
 			pauseAttachmentMaintenance($to_fix, $thumbnails);
1576 1631
 		}
@@ -1594,8 +1649,9 @@  discard block
 block discarded – undo
1594 1649
 			{
1595 1650
 				while ($file = readdir($dir))
1596 1651
 				{
1597
-					if (in_array($file, array('.', '..', '.htaccess', 'index.php')))
1598
-						continue;
1652
+					if (in_array($file, array('.', '..', '.htaccess', 'index.php'))) {
1653
+											continue;
1654
+					}
1599 1655
 
1600 1656
 					if ($files_checked <= $current_check)
1601 1657
 					{
@@ -1603,8 +1659,9 @@  discard block
 block discarded – undo
1603 1659
 						if (strpos($file, 'post_tmp_') !== false)
1604 1660
 						{
1605 1661
 							// Temp file is more than 5 hours old!
1606
-							if (filemtime($attach_dir . '/' . $file) < time() - 18000)
1607
-								@unlink($attach_dir . '/' . $file);
1662
+							if (filemtime($attach_dir . '/' . $file) < time() - 18000) {
1663
+															@unlink($attach_dir . '/' . $file);
1664
+							}
1608 1665
 						}
1609 1666
 						// That should be an attachment, let's check if we have it in the database
1610 1667
 						elseif (strpos($file, '_') !== false)
@@ -1626,8 +1683,7 @@  discard block
 block discarded – undo
1626 1683
 									if ($fix_errors && in_array('files_without_attachment', $to_fix))
1627 1684
 									{
1628 1685
 										@unlink($attach_dir . '/' . $file);
1629
-									}
1630
-									else
1686
+									} else
1631 1687
 									{
1632 1688
 										$context['repair_errors']['files_without_attachment']++;
1633 1689
 										$to_fix[] = 'files_without_attachment';
@@ -1635,14 +1691,12 @@  discard block
 block discarded – undo
1635 1691
 								}
1636 1692
 								$smcFunc['db_free_result']($request);
1637 1693
 							}
1638
-						}
1639
-						else
1694
+						} else
1640 1695
 						{
1641 1696
 							if ($fix_errors && in_array('files_without_attachment', $to_fix))
1642 1697
 							{
1643 1698
 								@unlink($attach_dir . '/' . $file);
1644
-							}
1645
-							else
1699
+							} else
1646 1700
 							{
1647 1701
 								$context['repair_errors']['files_without_attachment']++;
1648 1702
 								$to_fix[] = 'files_without_attachment';
@@ -1651,8 +1705,9 @@  discard block
 block discarded – undo
1651 1705
 					}
1652 1706
 					$current_check++;
1653 1707
 					$_GET['substep'] = $current_check;
1654
-					if ($current_check - $files_checked >= $max_checks)
1655
-						pauseAttachmentMaintenance($to_fix);
1708
+					if ($current_check - $files_checked >= $max_checks) {
1709
+											pauseAttachmentMaintenance($to_fix);
1710
+					}
1656 1711
 				}
1657 1712
 				closedir($dir);
1658 1713
 			}
@@ -1688,12 +1743,14 @@  discard block
 block discarded – undo
1688 1743
 
1689 1744
 	// Try get more time...
1690 1745
 	@set_time_limit(600);
1691
-	if (function_exists('apache_reset_timeout'))
1692
-		@apache_reset_timeout();
1746
+	if (function_exists('apache_reset_timeout')) {
1747
+			@apache_reset_timeout();
1748
+	}
1693 1749
 
1694 1750
 	// Have we already used our maximum time?
1695
-	if (time() - array_sum(explode(' ', $time_start)) < 3 || $context['starting_substep'] == $_GET['substep'])
1696
-		return;
1751
+	if (time() - array_sum(explode(' ', $time_start)) < 3 || $context['starting_substep'] == $_GET['substep']) {
1752
+			return;
1753
+	}
1697 1754
 
1698 1755
 	$context['continue_get_data'] = '?action=admin;area=manageattachments;sa=repair' . (isset($_GET['fixErrors']) ? ';fixErrors' : '') . ';step=' . $_GET['step'] . ';substep=' . $_GET['substep'] . ';' . $context['session_var'] . '=' . $context['session_id'];
1699 1756
 	$context['page_title'] = $txt['not_done_title'];
@@ -1705,10 +1762,11 @@  discard block
 block discarded – undo
1705 1762
 	$context[$context['admin_menu_name']]['current_subsection'] = 'maintenance';
1706 1763
 
1707 1764
 	// Change these two if more steps are added!
1708
-	if (empty($max_substep))
1709
-		$context['continue_percent'] = round(($_GET['step'] * 100) / 25);
1710
-	else
1711
-		$context['continue_percent'] = round(($_GET['step'] * 100 + ($_GET['substep'] * 100) / $max_substep) / 25);
1765
+	if (empty($max_substep)) {
1766
+			$context['continue_percent'] = round(($_GET['step'] * 100) / 25);
1767
+	} else {
1768
+			$context['continue_percent'] = round(($_GET['step'] * 100 + ($_GET['substep'] * 100) / $max_substep) / 25);
1769
+	}
1712 1770
 
1713 1771
 	// Never more than 100%!
1714 1772
 	$context['continue_percent'] = min($context['continue_percent'], 100);
@@ -1750,15 +1808,17 @@  discard block
 block discarded – undo
1750 1808
 				'attachment_type' => 0,
1751 1809
 			)
1752 1810
 		);
1753
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1754
-			$attachments[] = $row['id_attach'];
1811
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1812
+					$attachments[] = $row['id_attach'];
1813
+		}
1755 1814
 		$smcFunc['db_free_result']($request);
1815
+	} elseif (!empty($_GET['aid'])) {
1816
+			$attachments[] = (int) $_GET['aid'];
1756 1817
 	}
1757
-	elseif (!empty($_GET['aid']))
1758
-		$attachments[] = (int) $_GET['aid'];
1759 1818
 
1760
-	if (empty($attachments))
1761
-		fatal_lang_error('no_access', false);
1819
+	if (empty($attachments)) {
1820
+			fatal_lang_error('no_access', false);
1821
+	}
1762 1822
 
1763 1823
 	// Now we have some ID's cleaned and ready to approve, but first - let's check we have permission!
1764 1824
 	$allowed_boards = boardsAllowedTo('approve_posts');
@@ -1791,17 +1851,18 @@  discard block
 block discarded – undo
1791 1851
 	}
1792 1852
 	$smcFunc['db_free_result']($request);
1793 1853
 
1794
-	if (empty($attachments))
1795
-		fatal_lang_error('no_access', false);
1854
+	if (empty($attachments)) {
1855
+			fatal_lang_error('no_access', false);
1856
+	}
1796 1857
 
1797 1858
 	// Finally, we are there. Follow through!
1798 1859
 	if ($is_approve)
1799 1860
 	{
1800 1861
 		// Checked and deemed worthy.
1801 1862
 		ApproveAttachments($attachments);
1863
+	} else {
1864
+			removeAttachments(array('id_attach' => $attachments, 'do_logging' => true));
1802 1865
 	}
1803
-	else
1804
-		removeAttachments(array('id_attach' => $attachments, 'do_logging' => true));
1805 1866
 
1806 1867
 	// Return to the topic....
1807 1868
 	redirectexit($redirect);
@@ -1817,8 +1878,9 @@  discard block
 block discarded – undo
1817 1878
 {
1818 1879
 	global $smcFunc;
1819 1880
 
1820
-	if (empty($attachments))
1821
-		return 0;
1881
+	if (empty($attachments)) {
1882
+			return 0;
1883
+	}
1822 1884
 
1823 1885
 	// For safety, check for thumbnails...
1824 1886
 	$request = $smcFunc['db_query']('', '
@@ -1837,15 +1899,17 @@  discard block
 block discarded – undo
1837 1899
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1838 1900
 	{
1839 1901
 		// Update the thumbnail too...
1840
-		if (!empty($row['id_thumb']))
1841
-			$attachments[] = $row['id_thumb'];
1902
+		if (!empty($row['id_thumb'])) {
1903
+					$attachments[] = $row['id_thumb'];
1904
+		}
1842 1905
 
1843 1906
 		$attachments[] = $row['id_attach'];
1844 1907
 	}
1845 1908
 	$smcFunc['db_free_result']($request);
1846 1909
 
1847
-	if (empty($attachments))
1848
-		return 0;
1910
+	if (empty($attachments)) {
1911
+			return 0;
1912
+	}
1849 1913
 
1850 1914
 	// Approving an attachment is not hard - it's easy.
1851 1915
 	$smcFunc['db_query']('', '
@@ -1871,14 +1935,15 @@  discard block
 block discarded – undo
1871 1935
 		)
1872 1936
 	);
1873 1937
 
1874
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1875
-		logAction(
1938
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1939
+			logAction(
1876 1940
 			'approve_attach',
1877 1941
 			array(
1878 1942
 				'message' => $row['id_msg'],
1879 1943
 				'filename' => preg_replace('~&amp;#(\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\1;', $smcFunc['htmlspecialchars']($row['filename'])),
1880 1944
 			)
1881 1945
 		);
1946
+	}
1882 1947
 	$smcFunc['db_free_result']($request);
1883 1948
 
1884 1949
 	// Remove from the approval queue.
@@ -1901,11 +1966,11 @@  discard block
 block discarded – undo
1901 1966
 	global $modSettings, $scripturl, $context, $txt, $sourcedir, $boarddir, $smcFunc, $settings;
1902 1967
 
1903 1968
 	// Since this needs to be done eventually.
1904
-	if (!isset($modSettings['attachment_basedirectories']))
1905
-		$modSettings['attachment_basedirectories'] = array();
1906
-
1907
-	elseif (!is_array($modSettings['attachment_basedirectories']))
1908
-		$modSettings['attachment_basedirectories'] = smf_json_decode($modSettings['attachment_basedirectories'], true);
1969
+	if (!isset($modSettings['attachment_basedirectories'])) {
1970
+			$modSettings['attachment_basedirectories'] = array();
1971
+	} elseif (!is_array($modSettings['attachment_basedirectories'])) {
1972
+			$modSettings['attachment_basedirectories'] = smf_json_decode($modSettings['attachment_basedirectories'], true);
1973
+	}
1909 1974
 
1910 1975
 	$errors = array();
1911 1976
 
@@ -1920,8 +1985,9 @@  discard block
 block discarded – undo
1920 1985
 		{
1921 1986
 			$error = '';
1922 1987
 			$id = (int) $id;
1923
-			if ($id < 1)
1924
-				continue;
1988
+			if ($id < 1) {
1989
+							continue;
1990
+			}
1925 1991
 
1926 1992
 			// Sorry, these dirs are NOT valid
1927 1993
 			$invalid_dirs = array($boarddir, $settings['default_theme_dir'], $sourcedir);
@@ -1940,8 +2006,7 @@  discard block
 block discarded – undo
1940 2006
 				{
1941 2007
 						$errors[] = $path . ': ' . $txt['attach_dir_duplicate_msg'];
1942 2008
 						continue;
1943
-				}
1944
-				elseif (empty($path))
2009
+				} elseif (empty($path))
1945 2010
 				{
1946 2011
 					// Ignore this and set $id to one less
1947 2012
 					continue;
@@ -1949,10 +2014,11 @@  discard block
 block discarded – undo
1949 2014
 
1950 2015
 				// OK, so let's try to create it then.
1951 2016
 				require_once($sourcedir . '/Subs-Attachments.php');
1952
-				if (automanage_attachments_create_directory($path))
1953
-					$_POST['current_dir'] = $modSettings['currentAttachmentUploadDir'];
1954
-				else
1955
-					$errors[] =  $path . ': ' . $txt[$context['dir_creation_error']];
2017
+				if (automanage_attachments_create_directory($path)) {
2018
+									$_POST['current_dir'] = $modSettings['currentAttachmentUploadDir'];
2019
+				} else {
2020
+									$errors[] =  $path . ': ' . $txt[$context['dir_creation_error']];
2021
+				}
1956 2022
 			}
1957 2023
 
1958 2024
 			// Changing a directory name?
@@ -1965,8 +2031,7 @@  discard block
 block discarded – undo
1965 2031
 						$errors[] = $path . ': ' . $txt['attach_dir_no_rename'];
1966 2032
 						$path = $modSettings['attachmentUploadDir'][$id];
1967 2033
 					}
1968
-				}
1969
-				else
2034
+				} else
1970 2035
 				{
1971 2036
 					$errors[] = $path . ': ' . $txt['attach_dir_exists_msg'];
1972 2037
 					$path = $modSettings['attachmentUploadDir'][$id];
@@ -1991,12 +2056,13 @@  discard block
 block discarded – undo
1991 2056
 				$path = $modSettings['attachmentUploadDir'][$id];
1992 2057
 
1993 2058
 				// It's not a good idea to delete the current directory.
1994
-				if ($id == (!empty($_POST['current_dir']) ? $_POST['current_dir'] : $modSettings['currentAttachmentUploadDir']))
1995
-					$errors[] = $path . ': ' . $txt['attach_dir_is_current'];
2059
+				if ($id == (!empty($_POST['current_dir']) ? $_POST['current_dir'] : $modSettings['currentAttachmentUploadDir'])) {
2060
+									$errors[] = $path . ': ' . $txt['attach_dir_is_current'];
2061
+				}
1996 2062
 				// Or the current base directory
1997
-				elseif (!empty($modSettings['basedirectory_for_attachments']) && $modSettings['basedirectory_for_attachments'] == $modSettings['attachmentUploadDir'][$id])
1998
-					$errors[] = $path . ': ' . $txt['attach_dir_is_current_bd'];
1999
-				else
2063
+				elseif (!empty($modSettings['basedirectory_for_attachments']) && $modSettings['basedirectory_for_attachments'] == $modSettings['attachmentUploadDir'][$id]) {
2064
+									$errors[] = $path . ': ' . $txt['attach_dir_is_current_bd'];
2065
+				} else
2000 2066
 				{
2001 2067
 					// Let's not try to delete a path with files in it.
2002 2068
 					$request = $smcFunc['db_query']('', '
@@ -2015,17 +2081,18 @@  discard block
 block discarded – undo
2015 2081
 					if (!empty($modSettings['attachment_basedirectories']))
2016 2082
 					{
2017 2083
 						// Count any sub-folders.
2018
-						foreach ($modSettings['attachmentUploadDir'] as $sub)
2019
-							if (strpos($sub, $path . DIRECTORY_SEPARATOR) !== false)
2084
+						foreach ($modSettings['attachmentUploadDir'] as $sub) {
2085
+													if (strpos($sub, $path . DIRECTORY_SEPARATOR) !== false)
2020 2086
 								$num_attach++;
2087
+						}
2021 2088
 					}
2022 2089
 
2023 2090
 					// It's safe to delete. So try to delete the folder also
2024 2091
 					if ($num_attach == 0)
2025 2092
 					{
2026
-						if (is_dir($path))
2027
-							$doit = true;
2028
-						elseif (is_dir($boarddir . DIRECTORY_SEPARATOR . $path))
2093
+						if (is_dir($path)) {
2094
+													$doit = true;
2095
+						} elseif (is_dir($boarddir . DIRECTORY_SEPARATOR . $path))
2029 2096
 						{
2030 2097
 							$doit = true;
2031 2098
 							$path = $boarddir . DIRECTORY_SEPARATOR . $path;
@@ -2035,8 +2102,9 @@  discard block
 block discarded – undo
2035 2102
 						{
2036 2103
 							unlink($path . '/.htaccess');
2037 2104
 							unlink($path . '/index.php');
2038
-							if (!@rmdir($path))
2039
-								$error = $path . ': ' . $txt['attach_dir_no_delete'];
2105
+							if (!@rmdir($path)) {
2106
+															$error = $path . ': ' . $txt['attach_dir_no_delete'];
2107
+							}
2040 2108
 						}
2041 2109
 
2042 2110
 						// Remove it from the base directory list.
@@ -2046,14 +2114,15 @@  discard block
 block discarded – undo
2046 2114
 							updateSettings(array('attachment_basedirectories' => json_encode($modSettings['attachment_basedirectories'])));
2047 2115
 							$modSettings['attachment_basedirectories'] = smf_json_decode($modSettings['attachment_basedirectories'], true);
2048 2116
 						}
2117
+					} else {
2118
+											$error = $path . ': ' . $txt['attach_dir_no_remove'];
2049 2119
 					}
2050
-					else
2051
-						$error = $path . ': ' . $txt['attach_dir_no_remove'];
2052 2120
 
2053
-					if (empty($error))
2054
-						continue;
2055
-					else
2056
-						$errors[] = $error;
2121
+					if (empty($error)) {
2122
+											continue;
2123
+					} else {
2124
+											$errors[] = $error;
2125
+					}
2057 2126
 				}
2058 2127
 			}
2059 2128
 
@@ -2061,23 +2130,26 @@  discard block
 block discarded – undo
2061 2130
 		}
2062 2131
 
2063 2132
 		// We need to make sure the current directory is right.
2064
-		if (empty($_POST['current_dir']) && !empty($modSettings['currentAttachmentUploadDir']))
2065
-			$_POST['current_dir'] = $modSettings['currentAttachmentUploadDir'];
2133
+		if (empty($_POST['current_dir']) && !empty($modSettings['currentAttachmentUploadDir'])) {
2134
+					$_POST['current_dir'] = $modSettings['currentAttachmentUploadDir'];
2135
+		}
2066 2136
 
2067 2137
 		// Find the current directory if there's no value carried,
2068 2138
 		if (empty($_POST['current_dir']) || empty($new_dirs[$_POST['current_dir']]))
2069 2139
 		{
2070
-			if (array_key_exists($modSettings['currentAttachmentUploadDir'], $modSettings['attachmentUploadDir']))
2071
-				$_POST['current_dir'] = $modSettings['currentAttachmentUploadDir'];
2072
-			else
2073
-				$_POST['current_dir'] = max(array_keys($modSettings['attachmentUploadDir']));
2140
+			if (array_key_exists($modSettings['currentAttachmentUploadDir'], $modSettings['attachmentUploadDir'])) {
2141
+							$_POST['current_dir'] = $modSettings['currentAttachmentUploadDir'];
2142
+			} else {
2143
+							$_POST['current_dir'] = max(array_keys($modSettings['attachmentUploadDir']));
2144
+			}
2074 2145
 		}
2075 2146
 
2076 2147
 		// If the user wishes to go back, update the last_dir array
2077 2148
 		if ($_POST['current_dir'] !=  $modSettings['currentAttachmentUploadDir']&& !empty($modSettings['last_attachments_directory']) && (isset($modSettings['last_attachments_directory'][$_POST['current_dir']]) || isset($modSettings['last_attachments_directory'][0])))
2078 2149
 		{
2079
-			if (!is_array($modSettings['last_attachments_directory']))
2080
-				$modSettings['last_attachments_directory'] = smf_json_decode($modSettings['last_attachments_directory'], true);
2150
+			if (!is_array($modSettings['last_attachments_directory'])) {
2151
+							$modSettings['last_attachments_directory'] = smf_json_decode($modSettings['last_attachments_directory'], true);
2152
+			}
2081 2153
 			$num = substr(strrchr($modSettings['attachmentUploadDir'][$_POST['current_dir']], '_'), 1);
2082 2154
 
2083 2155
 			if (is_numeric($num))
@@ -2085,16 +2157,18 @@  discard block
 block discarded – undo
2085 2157
 				// Need to find the base folder.
2086 2158
 				$bid = -1;
2087 2159
 				$use_subdirectories_for_attachments = 0;
2088
-				if (!empty($modSettings['attachment_basedirectories']))
2089
-					foreach ($modSettings['attachment_basedirectories'] as $bid => $base)
2160
+				if (!empty($modSettings['attachment_basedirectories'])) {
2161
+									foreach ($modSettings['attachment_basedirectories'] as $bid => $base)
2090 2162
 						if (strpos($modSettings['attachmentUploadDir'][$_POST['current_dir']], $base . DIRECTORY_SEPARATOR) !==false)
2091 2163
 						{
2092 2164
 							$use_subdirectories_for_attachments = 1;
2165
+				}
2093 2166
 							break;
2094 2167
 						}
2095 2168
 
2096
-				if ($use_subdirectories_for_attachments == 0 && strpos($modSettings['attachmentUploadDir'][$_POST['current_dir']], $boarddir . DIRECTORY_SEPARATOR) !== false)
2097
-					$bid = 0;
2169
+				if ($use_subdirectories_for_attachments == 0 && strpos($modSettings['attachmentUploadDir'][$_POST['current_dir']], $boarddir . DIRECTORY_SEPARATOR) !== false) {
2170
+									$bid = 0;
2171
+				}
2098 2172
 
2099 2173
 				$modSettings['last_attachments_directory'][$bid] = (int) $num;
2100 2174
 				$modSettings['basedirectory_for_attachments'] = !empty($modSettings['basedirectory_for_attachments']) ? $modSettings['basedirectory_for_attachments'] : '';
@@ -2113,8 +2187,8 @@  discard block
 block discarded – undo
2113 2187
 			// We might need to reset the paths. This loop will just loop through once.
2114 2188
 			foreach ($new_dirs as $id => $dir)
2115 2189
 			{
2116
-				if ($id != 1)
2117
-					$smcFunc['db_query']('', '
2190
+				if ($id != 1) {
2191
+									$smcFunc['db_query']('', '
2118 2192
 						UPDATE {db_prefix}attachments
2119 2193
 						SET id_folder = {int:default_folder}
2120 2194
 						WHERE id_folder = {int:current_folder}',
@@ -2123,14 +2197,14 @@  discard block
 block discarded – undo
2123 2197
 							'current_folder' => $id,
2124 2198
 						)
2125 2199
 					);
2200
+				}
2126 2201
 
2127 2202
 				$update = array(
2128 2203
 					'currentAttachmentUploadDir' => 1,
2129 2204
 					'attachmentUploadDir' => json_encode(array(1 => $dir)),
2130 2205
 				);
2131 2206
 			}
2132
-		}
2133
-		else
2207
+		} else
2134 2208
 		{
2135 2209
 			// Save it to the database.
2136 2210
 			$update = array(
@@ -2139,11 +2213,13 @@  discard block
 block discarded – undo
2139 2213
 			);
2140 2214
 		}
2141 2215
 
2142
-		if (!empty($update))
2143
-			updateSettings($update);
2216
+		if (!empty($update)) {
2217
+					updateSettings($update);
2218
+		}
2144 2219
 
2145
-		if (!empty($errors))
2146
-			$_SESSION['errors']['dir'] = $errors;
2220
+		if (!empty($errors)) {
2221
+					$_SESSION['errors']['dir'] = $errors;
2222
+		}
2147 2223
 
2148 2224
 		redirectexit('action=admin;area=manageattachments;sa=attachpaths;' . $context['session_var'] . '=' . $context['session_id']);
2149 2225
 	}
@@ -2157,10 +2233,11 @@  discard block
 block discarded – undo
2157 2233
 		$_POST['current_base_dir'] = isset($_POST['current_base_dir']) ? (int) $_POST['current_base_dir'] : 1;
2158 2234
 		if (empty($_POST['new_base_dir']) && !empty($_POST['current_base_dir']))
2159 2235
 		{
2160
-			if ($modSettings['basedirectory_for_attachments'] != $modSettings['attachmentUploadDir'][$_POST['current_base_dir']])
2161
-				$update = (array(
2236
+			if ($modSettings['basedirectory_for_attachments'] != $modSettings['attachmentUploadDir'][$_POST['current_base_dir']]) {
2237
+							$update = (array(
2162 2238
 					'basedirectory_for_attachments' => $modSettings['attachmentUploadDir'][$_POST['current_base_dir']],
2163 2239
 				));
2240
+			}
2164 2241
 		}
2165 2242
 
2166 2243
 		if (isset($_POST['base_dir']))
@@ -2208,13 +2285,15 @@  discard block
 block discarded – undo
2208 2285
 
2209 2286
 			if (!in_array($_POST['new_base_dir'], $modSettings['attachmentUploadDir']))
2210 2287
 			{
2211
-				if (!automanage_attachments_create_directory($_POST['new_base_dir']))
2212
-					$errors[] = $_POST['new_base_dir'] . ': ' . $txt['attach_dir_base_no_create'];
2288
+				if (!automanage_attachments_create_directory($_POST['new_base_dir'])) {
2289
+									$errors[] = $_POST['new_base_dir'] . ': ' . $txt['attach_dir_base_no_create'];
2290
+				}
2213 2291
 			}
2214 2292
 
2215 2293
 			$modSettings['currentAttachmentUploadDir'] = array_search($_POST['new_base_dir'], $modSettings['attachmentUploadDir']);
2216
-			if (!in_array($_POST['new_base_dir'], $modSettings['attachment_basedirectories']))
2217
-				$modSettings['attachment_basedirectories'][$modSettings['currentAttachmentUploadDir']] = $_POST['new_base_dir'];
2294
+			if (!in_array($_POST['new_base_dir'], $modSettings['attachment_basedirectories'])) {
2295
+							$modSettings['attachment_basedirectories'][$modSettings['currentAttachmentUploadDir']] = $_POST['new_base_dir'];
2296
+			}
2218 2297
 			ksort($modSettings['attachment_basedirectories']);
2219 2298
 
2220 2299
 			$update = (array(
@@ -2224,11 +2303,13 @@  discard block
 block discarded – undo
2224 2303
 			));
2225 2304
 		}
2226 2305
 
2227
-		if (!empty($errors))
2228
-			$_SESSION['errors']['base'] = $errors;
2306
+		if (!empty($errors)) {
2307
+					$_SESSION['errors']['base'] = $errors;
2308
+		}
2229 2309
 
2230
-		if (!empty($update))
2231
-			updateSettings($update);
2310
+		if (!empty($update)) {
2311
+					updateSettings($update);
2312
+		}
2232 2313
 
2233 2314
 		redirectexit('action=admin;area=manageattachments;sa=attachpaths;' . $context['session_var'] . '=' . $context['session_id']);
2234 2315
 	}
@@ -2238,13 +2319,15 @@  discard block
 block discarded – undo
2238 2319
 		if (is_array($_SESSION['errors']))
2239 2320
 		{
2240 2321
 			$errors = array();
2241
-			if (!empty($_SESSION['errors']['dir']))
2242
-				foreach ($_SESSION['errors']['dir'] as $error)
2322
+			if (!empty($_SESSION['errors']['dir'])) {
2323
+							foreach ($_SESSION['errors']['dir'] as $error)
2243 2324
 					$errors['dir'][] = $smcFunc['htmlspecialchars']($error, ENT_QUOTES);
2325
+			}
2244 2326
 
2245
-			if (!empty($_SESSION['errors']['base']))
2246
-				foreach ($_SESSION['errors']['base'] as $error)
2327
+			if (!empty($_SESSION['errors']['base'])) {
2328
+							foreach ($_SESSION['errors']['base'] as $error)
2247 2329
 					$errors['base'][] = $smcFunc['htmlspecialchars']($error, ENT_QUOTES);
2330
+			}
2248 2331
 		}
2249 2332
 		unset($_SESSION['errors']);
2250 2333
 	}
@@ -2454,8 +2537,9 @@  discard block
 block discarded – undo
2454 2537
 	foreach ($modSettings['attachmentUploadDir'] as $id => $dir)
2455 2538
 	{
2456 2539
 		// If there aren't any attachments in this directory this won't exist.
2457
-		if (!isset($expected_files[$id]))
2458
-			$expected_files[$id] = 0;
2540
+		if (!isset($expected_files[$id])) {
2541
+					$expected_files[$id] = 0;
2542
+		}
2459 2543
 
2460 2544
 		// Check if the directory is doing okay.
2461 2545
 		list ($status, $error, $files) = attachDirStatus($dir, $expected_files[$id]);
@@ -2468,10 +2552,11 @@  discard block
 block discarded – undo
2468 2552
 			$is_base_dir = in_array($dir, $modSettings['attachment_basedirectories']);
2469 2553
 
2470 2554
 			// Count any sub-folders.
2471
-			foreach ($modSettings['attachmentUploadDir'] as $sid => $sub)
2472
-				if (strpos($sub, $dir . DIRECTORY_SEPARATOR) !== false)
2555
+			foreach ($modSettings['attachmentUploadDir'] as $sid => $sub) {
2556
+							if (strpos($sub, $dir . DIRECTORY_SEPARATOR) !== false)
2473 2557
 				{
2474 2558
 					$expected_files[$id]++;
2559
+			}
2475 2560
 					$sub_dirs++;
2476 2561
 				}
2477 2562
 		}
@@ -2489,8 +2574,8 @@  discard block
 block discarded – undo
2489 2574
 	}
2490 2575
 
2491 2576
 	// Just stick a new directory on at the bottom.
2492
-	if (isset($_REQUEST['new_path']))
2493
-		$attachdirs[] = array(
2577
+	if (isset($_REQUEST['new_path'])) {
2578
+			$attachdirs[] = array(
2494 2579
 			'id' => max(array_merge(array_keys($expected_files), array_keys($modSettings['attachmentUploadDir']))) + 1,
2495 2580
 			'current' => false,
2496 2581
 			'path' => '',
@@ -2498,6 +2583,7 @@  discard block
 block discarded – undo
2498 2583
 			'num_files' => '',
2499 2584
 			'status' => '',
2500 2585
 		);
2586
+	}
2501 2587
 
2502 2588
 	return $attachdirs;
2503 2589
 }
@@ -2510,8 +2596,9 @@  discard block
 block discarded – undo
2510 2596
 {
2511 2597
 	global $modSettings, $txt;
2512 2598
 
2513
-	if (empty($modSettings['attachment_basedirectories']))
2514
-		return;
2599
+	if (empty($modSettings['attachment_basedirectories'])) {
2600
+			return;
2601
+	}
2515 2602
 
2516 2603
 	$basedirs = array();
2517 2604
 	// Get a list of the base directories.
@@ -2519,16 +2606,18 @@  discard block
 block discarded – undo
2519 2606
 	{
2520 2607
 		// Loop through the attach directory array to count any sub-directories
2521 2608
 		$expected_dirs = 0;
2522
-		foreach ($modSettings['attachmentUploadDir'] as $sid => $sub)
2523
-			if (strpos($sub, $dir . DIRECTORY_SEPARATOR) !== false)
2609
+		foreach ($modSettings['attachmentUploadDir'] as $sid => $sub) {
2610
+					if (strpos($sub, $dir . DIRECTORY_SEPARATOR) !== false)
2524 2611
 				$expected_dirs++;
2612
+		}
2525 2613
 
2526
-		if (!is_dir($dir))
2527
-			$status = 'does_not_exist';
2528
-		elseif (!is_writeable($dir))
2529
-			$status = 'not_writable';
2530
-		else
2531
-			$status = 'ok';
2614
+		if (!is_dir($dir)) {
2615
+					$status = 'does_not_exist';
2616
+		} elseif (!is_writeable($dir)) {
2617
+					$status = 'not_writable';
2618
+		} else {
2619
+					$status = 'ok';
2620
+		}
2532 2621
 
2533 2622
 		$basedirs[] = array(
2534 2623
 			'id' => $id,
@@ -2539,14 +2628,15 @@  discard block
 block discarded – undo
2539 2628
 		);
2540 2629
 	}
2541 2630
 
2542
-	if (isset($_REQUEST['new_base_path']))
2543
-		$basedirs[] = array(
2631
+	if (isset($_REQUEST['new_base_path'])) {
2632
+			$basedirs[] = array(
2544 2633
 			'id' => '',
2545 2634
 			'current' => false,
2546 2635
 			'path' => '<input type="text" name="new_base_dir" value="" size="40">',
2547 2636
 			'num_dirs' => '',
2548 2637
 			'status' => '',
2549 2638
 		);
2639
+	}
2550 2640
 
2551 2641
 	return $basedirs;
2552 2642
 }
@@ -2562,10 +2652,11 @@  discard block
 block discarded – undo
2562 2652
  */
2563 2653
 function attachDirStatus($dir, $expected_files)
2564 2654
 {
2565
-	if (!is_dir($dir))
2566
-		return array('does_not_exist', true, '');
2567
-	elseif (!is_writable($dir))
2568
-		return array('not_writable', true, '');
2655
+	if (!is_dir($dir)) {
2656
+			return array('does_not_exist', true, '');
2657
+	} elseif (!is_writable($dir)) {
2658
+			return array('not_writable', true, '');
2659
+	}
2569 2660
 
2570 2661
 	// Everything is okay so far, start to scan through the directory.
2571 2662
 	$num_files = 0;
@@ -2573,22 +2664,26 @@  discard block
 block discarded – undo
2573 2664
 	while ($file = $dir_handle->read())
2574 2665
 	{
2575 2666
 		// Now do we have a real file here?
2576
-		if (in_array($file, array('.', '..', '.htaccess', 'index.php')))
2577
-			continue;
2667
+		if (in_array($file, array('.', '..', '.htaccess', 'index.php'))) {
2668
+					continue;
2669
+		}
2578 2670
 
2579 2671
 		$num_files++;
2580 2672
 	}
2581 2673
 	$dir_handle->close();
2582 2674
 
2583
-	if ($num_files < $expected_files)
2584
-		return array('files_missing', true, $num_files);
2675
+	if ($num_files < $expected_files) {
2676
+			return array('files_missing', true, $num_files);
2677
+	}
2585 2678
 	// Empty?
2586
-	elseif ($expected_files == 0)
2587
-		return array('unused', false, $num_files);
2679
+	elseif ($expected_files == 0) {
2680
+			return array('unused', false, $num_files);
2681
+	}
2588 2682
 	// All good!
2589
-	else
2590
-		return array('ok', false, $num_files);
2591
-}
2683
+	else {
2684
+			return array('ok', false, $num_files);
2685
+	}
2686
+	}
2592 2687
 
2593 2688
 /**
2594 2689
  * Maintance function to move attachments from one directory to another
@@ -2600,10 +2695,11 @@  discard block
 block discarded – undo
2600 2695
 	checkSession();
2601 2696
 
2602 2697
 	$modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true);
2603
-	if (!empty($modSettings['attachment_basedirectories']))
2604
-		$modSettings['attachment_basedirectories'] = smf_json_decode($modSettings['attachment_basedirectories'], true);
2605
-	else
2606
-		$modSettings['basedirectory_for_attachments'] = array();
2698
+	if (!empty($modSettings['attachment_basedirectories'])) {
2699
+			$modSettings['attachment_basedirectories'] = smf_json_decode($modSettings['attachment_basedirectories'], true);
2700
+	} else {
2701
+			$modSettings['basedirectory_for_attachments'] = array();
2702
+	}
2607 2703
 
2608 2704
 	$_POST['from'] = (int) $_POST['from'];
2609 2705
 	$_POST['auto'] = !empty($_POST['auto']) ? (int) $_POST['auto'] : 0;
@@ -2617,11 +2713,13 @@  discard block
 block discarded – undo
2617 2713
 	$total_moved = 0;
2618 2714
 	$total_not_moved = 0;
2619 2715
 
2620
-	if (empty($_POST['from']) || (empty($_POST['auto']) && empty($_POST['to'])))
2621
-		$results[] = $txt['attachment_transfer_no_dir'];
2716
+	if (empty($_POST['from']) || (empty($_POST['auto']) && empty($_POST['to']))) {
2717
+			$results[] = $txt['attachment_transfer_no_dir'];
2718
+	}
2622 2719
 
2623
-	if ($_POST['from'] == $_POST['to'])
2624
-		$results[] = $txt['attachment_transfer_same_dir'];
2720
+	if ($_POST['from'] == $_POST['to']) {
2721
+			$results[] = $txt['attachment_transfer_same_dir'];
2722
+	}
2625 2723
 
2626 2724
 	if (empty($results))
2627 2725
 	{
@@ -2640,8 +2738,9 @@  discard block
 block discarded – undo
2640 2738
 		$smcFunc['db_free_result']($request);
2641 2739
 		$total_progress -= $start;
2642 2740
 
2643
-		if ($total_progress < 1)
2644
-			$results[] = $txt['attachment_transfer_no_find'];
2741
+		if ($total_progress < 1) {
2742
+					$results[] = $txt['attachment_transfer_no_find'];
2743
+		}
2645 2744
 	}
2646 2745
 
2647 2746
 	if (empty($results))
@@ -2657,9 +2756,9 @@  discard block
 block discarded – undo
2657 2756
 
2658 2757
 			automanage_attachments_check_directory();
2659 2758
 			$new_dir = $modSettings['currentAttachmentUploadDir'];
2759
+		} else {
2760
+					$new_dir = $_POST['to'];
2660 2761
 		}
2661
-		else
2662
-			$new_dir = $_POST['to'];
2663 2762
 
2664 2763
 		$modSettings['currentAttachmentUploadDir'] = $new_dir;
2665 2764
 
@@ -2667,8 +2766,9 @@  discard block
 block discarded – undo
2667 2766
 		while ($break == false)
2668 2767
 		{
2669 2768
 			@set_time_limit(300);
2670
-			if (function_exists('apache_reset_timeout'))
2671
-				@apache_reset_timeout();
2769
+			if (function_exists('apache_reset_timeout')) {
2770
+							@apache_reset_timeout();
2771
+			}
2672 2772
 
2673 2773
 			// If limits are set, get the file count and size for the destination folder
2674 2774
 			if ($dir_files <= 0 && (!empty($modSettings['attachmentDirSizeLimit']) || !empty($modSettings['attachmentDirFileLimit'])))
@@ -2704,13 +2804,15 @@  discard block
 block discarded – undo
2704 2804
 
2705 2805
 			if ($smcFunc['db_num_rows']($request) === 0)
2706 2806
 			{
2707
-				if (empty($current_progress))
2708
-					$results[] = $txt['attachment_transfer_no_find'];
2807
+				if (empty($current_progress)) {
2808
+									$results[] = $txt['attachment_transfer_no_find'];
2809
+				}
2709 2810
 				break;
2710 2811
 			}
2711 2812
 
2712
-			if ($smcFunc['db_num_rows']($request) < $limit)
2713
-				$break = true;
2813
+			if ($smcFunc['db_num_rows']($request) < $limit) {
2814
+							$break = true;
2815
+			}
2714 2816
 
2715 2817
 			// Move them
2716 2818
 			$moved = array();
@@ -2734,8 +2836,9 @@  discard block
 block discarded – undo
2734 2836
 							automanage_attachments_by_space();
2735 2837
 
2736 2838
 							$results[] = sprintf($txt['attachments_transferred'], $total_moved, $modSettings['attachmentUploadDir'][$new_dir]);
2737
-							if (!empty($total_not_moved))
2738
-								$results[] = sprintf($txt['attachments_not_transferred'], $total_not_moved);
2839
+							if (!empty($total_not_moved)) {
2840
+															$results[] = sprintf($txt['attachments_not_transferred'], $total_not_moved);
2841
+							}
2739 2842
 
2740 2843
 							$dir_files = 0;
2741 2844
 							$total_moved = 0;
@@ -2743,8 +2846,7 @@  discard block
 block discarded – undo
2743 2846
 
2744 2847
 							$break = false;
2745 2848
 							break;
2746
-						}
2747
-						else
2849
+						} else
2748 2850
 						{
2749 2851
 							// Hmm, not in auto. Time to bail out then...
2750 2852
 							$results[] = $txt['attachment_transfer_no_room'];
@@ -2759,9 +2861,9 @@  discard block
 block discarded – undo
2759 2861
 					$total_moved++;
2760 2862
 					$current_progress++;
2761 2863
 					$moved[] = $row['id_attach'];
2864
+				} else {
2865
+									$total_not_moved++;
2762 2866
 				}
2763
-				else
2764
-					$total_not_moved++;
2765 2867
 			}
2766 2868
 			$smcFunc['db_free_result']($request);
2767 2869
 
@@ -2800,13 +2902,15 @@  discard block
 block discarded – undo
2800 2902
 		}
2801 2903
 
2802 2904
 		$results[] = sprintf($txt['attachments_transferred'], $total_moved, $modSettings['attachmentUploadDir'][$new_dir]);
2803
-		if (!empty($total_not_moved))
2804
-			$results[] = sprintf($txt['attachments_not_transferred'], $total_not_moved);
2905
+		if (!empty($total_not_moved)) {
2906
+					$results[] = sprintf($txt['attachments_not_transferred'], $total_not_moved);
2907
+		}
2805 2908
 	}
2806 2909
 
2807 2910
 	$_SESSION['results'] = $results;
2808
-	if (file_exists($boarddir . '/progress.php'))
2809
-		unlink($boarddir . '/progress.php');
2911
+	if (file_exists($boarddir . '/progress.php')) {
2912
+			unlink($boarddir . '/progress.php');
2913
+	}
2810 2914
 
2811 2915
 	redirectexit('action=admin;area=manageattachments;sa=maintenance#transfer');
2812 2916
 }
Please login to merge, or discard this patch.