Completed
Pull Request — release-2.1 (#4029)
by Mert
09:24 queued 21s
created
Sources/ManageScheduledTasks.php 1 patch
Braces   +54 added lines, -38 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
  * Scheduled tasks management dispatcher. This function checks permissions and delegates
@@ -40,10 +41,11 @@  discard block
 block discarded – undo
40 41
 	);
41 42
 
42 43
 	// We need to find what's the action.
43
-	if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]))
44
-		$context['sub_action'] = $_REQUEST['sa'];
45
-	else
46
-		$context['sub_action'] = 'tasks';
44
+	if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) {
45
+			$context['sub_action'] = $_REQUEST['sa'];
46
+	} else {
47
+			$context['sub_action'] = 'tasks';
48
+	}
47 49
 
48 50
 	// Now for the lovely tabs. That we all love.
49 51
 	$context[$context['admin_menu_name']]['tab_data'] = array(
@@ -90,9 +92,10 @@  discard block
 block discarded – undo
90 92
 
91 93
 		// Enable and disable as required.
92 94
 		$enablers = array(0);
93
-		foreach ($_POST['enable_task'] as $id => $enabled)
94
-			if ($enabled)
95
+		foreach ($_POST['enable_task'] as $id => $enabled) {
96
+					if ($enabled)
95 97
 				$enablers[] = (int) $id;
98
+		}
96 99
 
97 100
 		// Do the update!
98 101
 		$smcFunc['db_query']('', '
@@ -130,8 +133,9 @@  discard block
 block discarded – undo
130 133
 
131 134
 		// Lets figure out which ones they want to run.
132 135
 		$tasks = array();
133
-		foreach ($_POST['run_task'] as $task => $dummy)
134
-			$tasks[] = (int) $task;
136
+		foreach ($_POST['run_task'] as $task => $dummy) {
137
+					$tasks[] = (int) $task;
138
+		}
135 139
 
136 140
 		// Load up the tasks.
137 141
 		$request = $smcFunc['db_query']('', '
@@ -151,36 +155,41 @@  discard block
 block discarded – undo
151 155
 		while ($row = $smcFunc['db_fetch_assoc']($request))
152 156
 		{
153 157
 			// What kind of task are we handling?
154
-			if (!empty($row['callable']))
155
-				$task_string = $row['callable'];
158
+			if (!empty($row['callable'])) {
159
+							$task_string = $row['callable'];
160
+			}
156 161
 
157 162
 			// Default SMF task or old mods?
158
-			elseif (function_exists('scheduled_' . $row['task']))
159
-				$task_string = 'scheduled_' . $row['task'];
163
+			elseif (function_exists('scheduled_' . $row['task'])) {
164
+							$task_string = 'scheduled_' . $row['task'];
165
+			}
160 166
 
161 167
 			// One last resource, the task name.
162
-			elseif (!empty($row['task']))
163
-				$task_string = $row['task'];
168
+			elseif (!empty($row['task'])) {
169
+							$task_string = $row['task'];
170
+			}
164 171
 
165 172
 			$start_time = microtime();
166 173
 			// The functions got to exist for us to use it.
167
-			if (empty($task_string))
168
-				continue;
174
+			if (empty($task_string)) {
175
+							continue;
176
+			}
169 177
 
170 178
 			// Try to stop a timeout, this would be bad...
171 179
 			@set_time_limit(300);
172
-			if (function_exists('apache_reset_timeout'))
173
-				@apache_reset_timeout();
180
+			if (function_exists('apache_reset_timeout')) {
181
+							@apache_reset_timeout();
182
+			}
174 183
 
175 184
 			// Get the callable.
176 185
 			$callable_task = call_helper($task_string, true);
177 186
 
178 187
 			// Perform the task.
179
-			if (!empty($callable_task))
180
-				$completed = call_user_func($callable_task);
181
-
182
-			else
183
-				$completed = false;
188
+			if (!empty($callable_task)) {
189
+							$completed = call_user_func($callable_task);
190
+			} else {
191
+							$completed = false;
192
+			}
184 193
 
185 194
 			// Log that we did it ;)
186 195
 			if ($completed)
@@ -197,8 +206,9 @@  discard block
 block discarded – undo
197 206
 		$smcFunc['db_free_result']($request);
198 207
 
199 208
 		// If we had any errors, push them to session so we can pick them up next time to tell the user.
200
-		if (!empty($context['scheduled_errors']))
201
-			$_SESSION['st_error'] = $context['scheduled_errors'];
209
+		if (!empty($context['scheduled_errors'])) {
210
+					$_SESSION['st_error'] = $context['scheduled_errors'];
211
+		}
202 212
 
203 213
 		redirectexit('action=admin;area=scheduledtasks;done');
204 214
 	}
@@ -370,8 +380,9 @@  discard block
 block discarded – undo
370 380
 	$context['server_time'] = timeformat(time(), false, 'server');
371 381
 
372 382
 	// Cleaning...
373
-	if (!isset($_GET['tid']))
374
-		fatal_lang_error('no_access', false);
383
+	if (!isset($_GET['tid'])) {
384
+			fatal_lang_error('no_access', false);
385
+	}
375 386
 	$_GET['tid'] = (int) $_GET['tid'];
376 387
 
377 388
 	// Saving?
@@ -387,10 +398,12 @@  discard block
 block discarded – undo
387 398
 		preg_match('~(\d{1,2}):(\d{1,2})~', $_POST['offset'], $matches);
388 399
 
389 400
 		// If a half is empty then assume zero offset!
390
-		if (!isset($matches[2]) || $matches[2] > 59)
391
-			$matches[2] = 0;
392
-		if (!isset($matches[1]) || $matches[1] > 23)
393
-			$matches[1] = 0;
401
+		if (!isset($matches[2]) || $matches[2] > 59) {
402
+					$matches[2] = 0;
403
+		}
404
+		if (!isset($matches[1]) || $matches[1] > 23) {
405
+					$matches[1] = 0;
406
+		}
394 407
 
395 408
 		// Now the offset is easy; easy peasy - except we need to offset by a few hours...
396 409
 		$offset = $matches[1] * 3600 + $matches[2] * 60 - date('Z');
@@ -400,8 +413,9 @@  discard block
 block discarded – undo
400 413
 		$unit = in_array(substr($_POST['unit'], 0, 1), array('m', 'h', 'd', 'w')) ? substr($_POST['unit'], 0, 1) : 'd';
401 414
 
402 415
 		// Don't allow one minute intervals.
403
-		if ($interval == 1 && $unit == 'm')
404
-			$interval = 2;
416
+		if ($interval == 1 && $unit == 'm') {
417
+					$interval = 2;
418
+		}
405 419
 
406 420
 		// Is it disabled?
407 421
 		$disabled = !isset($_POST['enabled']) ? 1 : 0;
@@ -439,8 +453,9 @@  discard block
 block discarded – undo
439 453
 	);
440 454
 
441 455
 	// Should never, ever, happen!
442
-	if ($smcFunc['db_num_rows']($request) == 0)
443
-		fatal_lang_error('no_access', false);
456
+	if ($smcFunc['db_num_rows']($request) == 0) {
457
+			fatal_lang_error('no_access', false);
458
+	}
444 459
 
445 460
 	while ($row = $smcFunc['db_fetch_assoc']($request))
446 461
 	{
@@ -598,13 +613,14 @@  discard block
 block discarded – undo
598 613
 		)
599 614
 	);
600 615
 	$log_entries = array();
601
-	while ($row = $smcFunc['db_fetch_assoc']($request))
602
-		$log_entries[] = array(
616
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
617
+			$log_entries[] = array(
603 618
 			'id' => $row['id_log'],
604 619
 			'name' => isset($txt['scheduled_task_' . $row['task']]) ? $txt['scheduled_task_' . $row['task']] : $row['task'],
605 620
 			'time_run' => $row['time_run'],
606 621
 			'time_taken' => $row['time_taken'],
607 622
 		);
623
+	}
608 624
 	$smcFunc['db_free_result']($request);
609 625
 
610 626
 	return $log_entries;
Please login to merge, or discard this patch.
Sources/Mentions.php 1 patch
Braces   +26 added lines, -18 removed lines patch added patch discarded remove patch
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
 			)
51 51
 		);
52 52
 		$members = array();
53
-		while ($row = $smcFunc['db_fetch_assoc']($request))
54
-			$members[$row['id_member']] = array(
53
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
54
+					$members[$row['id_member']] = array(
55 55
 				'id' => $row['id_member'],
56 56
 				'real_name' => $row['real_name'],
57 57
 				'email_address' => $row['email_address'],
@@ -62,6 +62,7 @@  discard block
 block discarded – undo
62 62
 				),
63 63
 				'lngfile' => $row['lngfile'],
64 64
 			);
65
+		}
65 66
 		$smcFunc['db_free_result']($request);
66 67
 
67 68
 		return $members;
@@ -83,13 +84,14 @@  discard block
 block discarded – undo
83 84
 
84 85
 		call_integration_hook('mention_insert_' . $content_type, array($content_id, &$members));
85 86
 
86
-		foreach ($members as $member)
87
-			$smcFunc['db_insert']('ignore',
87
+		foreach ($members as $member) {
88
+					$smcFunc['db_insert']('ignore',
88 89
 				'{db_prefix}mentions',
89 90
 				array('content_id' => 'int', 'content_type' => 'string', 'id_member' => 'int', 'id_mentioned' => 'int', 'time' => 'int'),
90 91
 				array((int) $content_id, $content_type, $id_member, $member['id'], time()),
91 92
 				array('content_id', 'content_type', 'id_mentioned')
92 93
 			);
94
+		}
93 95
 	}
94 96
 
95 97
 	/**
@@ -103,8 +105,9 @@  discard block
 block discarded – undo
103 105
 	 */
104 106
 	public static function getBody($body, array $members)
105 107
 	{
106
-		foreach ($members as $member)
107
-			$body = str_ireplace(static::$char . $member['real_name'], '[member=' . $member['id'] . ']' . $member['real_name'] . '[/member]', $body);
108
+		foreach ($members as $member) {
109
+					$body = str_ireplace(static::$char . $member['real_name'], '[member=' . $member['id'] . ']' . $member['real_name'] . '[/member]', $body);
110
+		}
108 111
 
109 112
 		return $body;
110 113
 	}
@@ -123,8 +126,9 @@  discard block
 block discarded – undo
123 126
 
124 127
 		$possible_names = self::getPossibleMentions($body);
125 128
 
126
-		if (empty($possible_names) || !allowedTo('mention'))
127
-			return array();
129
+		if (empty($possible_names) || !allowedTo('mention')) {
130
+					return array();
131
+		}
128 132
 
129 133
 		$request = $smcFunc['db_query']('', '
130 134
 			SELECT id_member, real_name
@@ -140,8 +144,9 @@  discard block
 block discarded – undo
140 144
 		$members = array();
141 145
 		while ($row = $smcFunc['db_fetch_assoc']($request))
142 146
 		{
143
-			if (stripos($body, static::$char . $row['real_name']) === false)
144
-				continue;
147
+			if (stripos($body, static::$char . $row['real_name']) === false) {
148
+							continue;
149
+			}
145 150
 
146 151
 			$members[$row['id_member']] = array(
147 152
 				'id' => $row['id_member'],
@@ -185,8 +190,9 @@  discard block
 block discarded – undo
185 190
 		$body = htmlspecialchars_decode(preg_replace('~<br\s*/?\>~', "\n", str_replace('&nbsp;', ' ', $body)), ENT_QUOTES);
186 191
 
187 192
 		// Remove quotes, we don't want to get double mentions.
188
-		while (preg_match('~\[quote[^\]]*\](.+?)\[\/quote\]~s', $body))
189
-			$body = preg_replace('~\[quote[^\]]*\](.+?)\[\/quote\]~s', '', $body);
193
+		while (preg_match('~\[quote[^\]]*\](.+?)\[\/quote\]~s', $body)) {
194
+					$body = preg_replace('~\[quote[^\]]*\](.+?)\[\/quote\]~s', '', $body);
195
+		}
190 196
 
191 197
 		$matches = array();
192 198
 		$string = str_split($body);
@@ -197,9 +203,9 @@  discard block
 block discarded – undo
197 203
 			{
198 204
 				$depth++;
199 205
 				$matches[] = array();
206
+			} elseif ($char == "\n") {
207
+							$depth = 0;
200 208
 			}
201
-			elseif ($char == "\n")
202
-				$depth = 0;
203 209
 
204 210
 			for ($i = $depth; $i > 0; $i--)
205 211
 			{
@@ -212,8 +218,9 @@  discard block
 block discarded – undo
212 218
 			}
213 219
 		}
214 220
 
215
-		foreach ($matches as $k => $match)
216
-			$matches[$k] = substr(implode('', $match), 1);
221
+		foreach ($matches as $k => $match) {
222
+					$matches[$k] = substr(implode('', $match), 1);
223
+		}
217 224
 
218 225
 		// Names can have spaces, other breaks, or they can't...we try to match every possible
219 226
 		// combination.
@@ -223,8 +230,9 @@  discard block
 block discarded – undo
223 230
 			$match = preg_split('/([^\w])/', $match, -1, PREG_SPLIT_DELIM_CAPTURE);
224 231
 			$count = count($match);
225 232
 			
226
-			for ($i = 1; $i <= $count; $i++)
227
-				$names[] = $smcFunc['htmlspecialchars']($smcFunc['htmltrim'](implode('', array_slice($match, 0, $i))));
233
+			for ($i = 1; $i <= $count; $i++) {
234
+							$names[] = $smcFunc['htmlspecialchars']($smcFunc['htmltrim'](implode('', array_slice($match, 0, $i))));
235
+			}
228 236
 		}
229 237
 
230 238
 		$names = array_unique($names);
Please login to merge, or discard this patch.
Sources/ManageSettings.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1326,7 +1326,7 @@  discard block
 block discarded – undo
1326 1326
 					'class' => 'centercol',
1327 1327
 				),
1328 1328
 				'data' => array(
1329
-					'function' => function ($rowData)
1329
+					'function' => function($rowData)
1330 1330
 					{
1331 1331
 						$isChecked = $rowData['disabled'] ? '' : ' checked';
1332 1332
 						$onClickHandler = $rowData['can_show_register'] ? sprintf(' onclick="document.getElementById(\'reg_%1$s\').disabled = !this.checked;"', $rowData['id']) : '';
@@ -1342,7 +1342,7 @@  discard block
 block discarded – undo
1342 1342
 					'class' => 'centercol',
1343 1343
 				),
1344 1344
 				'data' => array(
1345
-					'function' => function ($rowData)
1345
+					'function' => function($rowData)
1346 1346
 					{
1347 1347
 						$isChecked = $rowData['on_register'] && !$rowData['disabled'] ? ' checked' : '';
1348 1348
 						$isDisabled = $rowData['can_show_register'] ? '' : ' disabled';
@@ -1389,15 +1389,15 @@  discard block
 block discarded – undo
1389 1389
 					'value' => $txt['custom_profile_fieldorder'],
1390 1390
 				),
1391 1391
 				'data' => array(
1392
-					'function' => function ($rowData) use ($context, $txt, $scripturl)
1392
+					'function' => function($rowData) use ($context, $txt, $scripturl)
1393 1393
 					{
1394
-						$return = '<p class="centertext bold_text">'. $rowData['field_order'] .'<br />';
1394
+						$return = '<p class="centertext bold_text">' . $rowData['field_order'] . '<br />';
1395 1395
 
1396 1396
 						if ($rowData['field_order'] > 1)
1397
-							$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>';
1397
+							$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="' . $txt['custom_edit_order_move'] . ' ' . $txt['custom_edit_order_up'] . '"></span></a>';
1398 1398
 
1399 1399
 						if ($rowData['field_order'] < $context['custFieldsMaxOrder'])
1400
-							$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>';
1400
+							$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="' . $txt['custom_edit_order_move'] . ' ' . $txt['custom_edit_order_down'] . '"></span></a>';
1401 1401
 
1402 1402
 						$return .= '</p>';
1403 1403
 
@@ -1415,7 +1415,7 @@  discard block
 block discarded – undo
1415 1415
 					'value' => $txt['custom_profile_fieldname'],
1416 1416
 				),
1417 1417
 				'data' => array(
1418
-					'function' => function ($rowData) use ($scripturl)
1418
+					'function' => function($rowData) use ($scripturl)
1419 1419
 					{
1420 1420
 						return sprintf('<a href="%1$s?action=admin;area=featuresettings;sa=profileedit;fid=%2$d">%3$s</a><div class="smalltext">%4$s</div>', $scripturl, $rowData['id_field'], $rowData['field_name'], $rowData['field_desc']);
1421 1421
 					},
@@ -1431,7 +1431,7 @@  discard block
 block discarded – undo
1431 1431
 					'value' => $txt['custom_profile_fieldtype'],
1432 1432
 				),
1433 1433
 				'data' => array(
1434
-					'function' => function ($rowData) use ($txt)
1434
+					'function' => function($rowData) use ($txt)
1435 1435
 					{
1436 1436
 						$textKey = sprintf('custom_profile_type_%1$s', $rowData['field_type']);
1437 1437
 						return isset($txt[$textKey]) ? $txt[$textKey] : $textKey;
@@ -1449,7 +1449,7 @@  discard block
 block discarded – undo
1449 1449
 					'value' => $txt['custom_profile_active'],
1450 1450
 				),
1451 1451
 				'data' => array(
1452
-					'function' => function ($rowData) use ($txt)
1452
+					'function' => function($rowData) use ($txt)
1453 1453
 					{
1454 1454
 						return $rowData['active'] ? $txt['yes'] : $txt['no'];
1455 1455
 					},
@@ -1466,7 +1466,7 @@  discard block
 block discarded – undo
1466 1466
 					'value' => $txt['custom_profile_placement'],
1467 1467
 				),
1468 1468
 				'data' => array(
1469
-					'function' => function ($rowData)
1469
+					'function' => function($rowData)
1470 1470
 					{
1471 1471
 						global $txt, $context;
1472 1472
 
@@ -1701,7 +1701,7 @@  discard block
 block discarded – undo
1701 1701
 			redirectexit('action=admin;area=featuresettings;sa=profile'); // @todo implement an error handler
1702 1702
 
1703 1703
 		// All good, proceed.
1704
-		$smcFunc['db_query']('','
1704
+		$smcFunc['db_query']('', '
1705 1705
 			UPDATE {db_prefix}custom_fields
1706 1706
 			SET field_order = {int:old_order}
1707 1707
 			WHERE field_order = {int:new_order}',
@@ -1710,7 +1710,7 @@  discard block
 block discarded – undo
1710 1710
 				'old_order' => $context['field']['order'],
1711 1711
 			)
1712 1712
 		);
1713
-		$smcFunc['db_query']('','
1713
+		$smcFunc['db_query']('', '
1714 1714
 			UPDATE {db_prefix}custom_fields
1715 1715
 			SET field_order = {int:new_order}
1716 1716
 			WHERE id_field = {int:id_field}',
@@ -1812,7 +1812,7 @@  discard block
 block discarded – undo
1812 1812
 			$smcFunc['db_free_result']($request);
1813 1813
 
1814 1814
 			$unique = false;
1815
-			for ($i = 0; !$unique && $i < 9; $i ++)
1815
+			for ($i = 0; !$unique && $i < 9; $i++)
1816 1816
 			{
1817 1817
 				if (!in_array($col_name, $current_fields))
1818 1818
 					$unique = true;
@@ -1985,7 +1985,7 @@  discard block
 block discarded – undo
1985 1985
 		);
1986 1986
 
1987 1987
 		// Re-arrange the order.
1988
-		$smcFunc['db_query']('','
1988
+		$smcFunc['db_query']('', '
1989 1989
 			UPDATE {db_prefix}custom_fields
1990 1990
 			SET field_order = field_order - 1
1991 1991
 			WHERE field_order > {int:current_order}',
@@ -2249,7 +2249,7 @@  discard block
 block discarded – undo
2249 2249
 	$context['token_check'] = 'noti-admin';
2250 2250
 
2251 2251
 	// Specify our action since we'll want to post back here instead of the profile
2252
-	$context['action'] = 'action=admin;area=featuresettings;sa=alerts;'. $context['session_var'] .'='. $context['session_id'];
2252
+	$context['action'] = 'action=admin;area=featuresettings;sa=alerts;' . $context['session_var'] . '=' . $context['session_id'];
2253 2253
 
2254 2254
 	loadTemplate('Profile');
2255 2255
 	loadLanguage('Profile');
Please login to merge, or discard this patch.
Braces   +273 added lines, -199 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 3
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * This function makes sure the requested subaction does exists, if it doesn't, it sets a default action or.
@@ -205,16 +206,18 @@  discard block
 block discarded – undo
205 206
 	{
206 207
 		$all_zones = timezone_identifiers_list();
207 208
 		// Make sure we set the value to the same as the printed value.
208
-		foreach ($all_zones as $zone)
209
-			$config_vars['default_timezone'][2][$zone] = $zone;
209
+		foreach ($all_zones as $zone) {
210
+					$config_vars['default_timezone'][2][$zone] = $zone;
211
+		}
212
+	} else {
213
+			unset($config_vars['default_timezone']);
210 214
 	}
211
-	else
212
-		unset($config_vars['default_timezone']);
213 215
 
214 216
 	call_integration_hook('integrate_modify_basic_settings', array(&$config_vars));
215 217
 
216
-	if ($return_config)
217
-		return $config_vars;
218
+	if ($return_config) {
219
+			return $config_vars;
220
+	}
218 221
 
219 222
 	// Saving?
220 223
 	if (isset($_GET['save']))
@@ -222,8 +225,9 @@  discard block
 block discarded – undo
222 225
 		checkSession();
223 226
 
224 227
 		// Prevent absurd boundaries here - make it a day tops.
225
-		if (isset($_POST['lastActive']))
226
-			$_POST['lastActive'] = min((int) $_POST['lastActive'], 1440);
228
+		if (isset($_POST['lastActive'])) {
229
+					$_POST['lastActive'] = min((int) $_POST['lastActive'], 1440);
230
+		}
227 231
 
228 232
 		call_integration_hook('integrate_save_basic_settings');
229 233
 
@@ -268,8 +272,9 @@  discard block
 block discarded – undo
268 272
 
269 273
 	call_integration_hook('integrate_modify_bbc_settings', array(&$config_vars));
270 274
 
271
-	if ($return_config)
272
-		return $config_vars;
275
+	if ($return_config) {
276
+			return $config_vars;
277
+	}
273 278
 
274 279
 	// Setup the template.
275 280
 	require_once($sourcedir . '/ManageServer.php');
@@ -286,13 +291,15 @@  discard block
 block discarded – undo
286 291
 
287 292
 		// Clean up the tags.
288 293
 		$bbcTags = array();
289
-		foreach (parse_bbc(false) as $tag)
290
-			$bbcTags[] = $tag['tag'];
294
+		foreach (parse_bbc(false) as $tag) {
295
+					$bbcTags[] = $tag['tag'];
296
+		}
291 297
 
292
-		if (!isset($_POST['disabledBBC_enabledTags']))
293
-			$_POST['disabledBBC_enabledTags'] = array();
294
-		elseif (!is_array($_POST['disabledBBC_enabledTags']))
295
-			$_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']);
298
+		if (!isset($_POST['disabledBBC_enabledTags'])) {
299
+					$_POST['disabledBBC_enabledTags'] = array();
300
+		} elseif (!is_array($_POST['disabledBBC_enabledTags'])) {
301
+					$_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']);
302
+		}
296 303
 		// Work out what is actually disabled!
297 304
 		$_POST['disabledBBC'] = implode(',', array_diff($bbcTags, $_POST['disabledBBC_enabledTags']));
298 305
 
@@ -336,8 +343,9 @@  discard block
 block discarded – undo
336 343
 
337 344
 	call_integration_hook('integrate_layout_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
 	// Saving?
343 351
 	if (isset($_GET['save']))
@@ -378,8 +386,9 @@  discard block
 block discarded – undo
378 386
 
379 387
 	call_integration_hook('integrate_likes_settings', array(&$config_vars));
380 388
 
381
-	if ($return_config)
382
-		return $config_vars;
389
+	if ($return_config) {
390
+			return $config_vars;
391
+	}
383 392
 
384 393
 	// Saving?
385 394
 	if (isset($_GET['save']))
@@ -417,8 +426,9 @@  discard block
 block discarded – undo
417 426
 
418 427
 	call_integration_hook('integrate_mentions_settings', array(&$config_vars));
419 428
 
420
-	if ($return_config)
421
-		return $config_vars;
429
+	if ($return_config) {
430
+			return $config_vars;
431
+	}
422 432
 
423 433
 	// Saving?
424 434
 	if (isset($_GET['save']))
@@ -462,8 +472,8 @@  discard block
 block discarded – undo
462 472
 			'enable' => array('check', 'warning_enable'),
463 473
 	);
464 474
 
465
-	if (!empty($modSettings['warning_settings']) && $currently_enabled)
466
-		$config_vars += array(
475
+	if (!empty($modSettings['warning_settings']) && $currently_enabled) {
476
+			$config_vars += array(
467 477
 			'',
468 478
 				array('int', 'warning_watch', 'subtext' => $txt['setting_warning_watch_note'] . ' ' . $txt['zero_to_disable']),
469 479
 				'moderate' => array('int', 'warning_moderate', 'subtext' => $txt['setting_warning_moderate_note'] . ' ' . $txt['zero_to_disable']),
@@ -472,15 +482,18 @@  discard block
 block discarded – undo
472 482
 				'rem2' => array('int', 'warning_decrement', 'subtext' => $txt['setting_warning_decrement_note'] . ' ' . $txt['zero_to_disable']),
473 483
 				array('permissions', 'view_warning'),
474 484
 		);
485
+	}
475 486
 
476 487
 	call_integration_hook('integrate_warning_settings', array(&$config_vars));
477 488
 
478
-	if ($return_config)
479
-		return $config_vars;
489
+	if ($return_config) {
490
+			return $config_vars;
491
+	}
480 492
 
481 493
 	// Cannot use moderation if post moderation is not enabled.
482
-	if (!$modSettings['postmod_active'])
483
-		unset($config_vars['moderate']);
494
+	if (!$modSettings['postmod_active']) {
495
+			unset($config_vars['moderate']);
496
+	}
484 497
 
485 498
 	// Will need the utility functions from here.
486 499
 	require_once($sourcedir . '/ManageServer.php');
@@ -505,16 +518,16 @@  discard block
 block discarded – undo
505 518
 				'warning_watch' => 10,
506 519
 				'warning_mute' => 60,
507 520
 			);
508
-			if ($modSettings['postmod_active'])
509
-				$vars['warning_moderate'] = 35;
521
+			if ($modSettings['postmod_active']) {
522
+							$vars['warning_moderate'] = 35;
523
+			}
510 524
 
511 525
 			foreach ($vars as $var => $value)
512 526
 			{
513 527
 				$config_vars[] = array('int', $var);
514 528
 				$_POST[$var] = $value;
515 529
 			}
516
-		}
517
-		else
530
+		} else
518 531
 		{
519 532
 			$_POST['warning_watch'] = min($_POST['warning_watch'], 100);
520 533
 			$_POST['warning_moderate'] = $modSettings['postmod_active'] ? min($_POST['warning_moderate'], 100) : 0;
@@ -595,8 +608,9 @@  discard block
 block discarded – undo
595 608
 
596 609
 	call_integration_hook('integrate_spam_settings', array(&$config_vars));
597 610
 
598
-	if ($return_config)
599
-		return $config_vars;
611
+	if ($return_config) {
612
+			return $config_vars;
613
+	}
600 614
 
601 615
 	// You need to be an admin to edit settings!
602 616
 	isAllowedTo('admin_forum');
@@ -630,8 +644,9 @@  discard block
 block discarded – undo
630 644
 
631 645
 	if (empty($context['qa_by_lang'][strtr($language, array('-utf8' => ''))]) && !empty($context['question_answers']))
632 646
 	{
633
-		if (empty($context['settings_insert_above']))
634
-			$context['settings_insert_above'] = '';
647
+		if (empty($context['settings_insert_above'])) {
648
+					$context['settings_insert_above'] = '';
649
+		}
635 650
 
636 651
 		$context['settings_insert_above'] .= '<div class="noticebox">' . sprintf($txt['question_not_defined'], $context['languages'][$language]['name']) . '</div>';
637 652
 	}
@@ -674,8 +689,9 @@  discard block
 block discarded – undo
674 689
 		$_POST['pm_spam_settings'] = (int) $_POST['max_pm_recipients'] . ',' . (int) $_POST['pm_posts_verification'] . ',' . (int) $_POST['pm_posts_per_hour'];
675 690
 
676 691
 		// Hack in guest requiring verification!
677
-		if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha']))
678
-			$_POST['posts_require_captcha'] = -1;
692
+		if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha'])) {
693
+					$_POST['posts_require_captcha'] = -1;
694
+		}
679 695
 
680 696
 		$save_vars = $config_vars;
681 697
 		unset($save_vars['pm1'], $save_vars['pm2'], $save_vars['pm3'], $save_vars['guest_verify']);
@@ -692,14 +708,16 @@  discard block
 block discarded – undo
692 708
 		foreach ($context['qa_languages'] as $lang_id => $dummy)
693 709
 		{
694 710
 			// If we had some questions for this language before, but don't now, delete everything from that language.
695
-			if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id]))
696
-				$changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]);
711
+			if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id])) {
712
+							$changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]);
713
+			}
697 714
 
698 715
 			// Now step through and see if any existing questions no longer exist.
699
-			if (!empty($context['qa_by_lang'][$lang_id]))
700
-				foreach ($context['qa_by_lang'][$lang_id] as $q_id)
716
+			if (!empty($context['qa_by_lang'][$lang_id])) {
717
+							foreach ($context['qa_by_lang'][$lang_id] as $q_id)
701 718
 					if (empty($_POST['question'][$lang_id][$q_id]))
702 719
 						$changes['delete'][] = $q_id;
720
+			}
703 721
 
704 722
 			// Now let's see if there are new questions or ones that need updating.
705 723
 			if (isset($_POST['question'][$lang_id]))
@@ -708,14 +726,16 @@  discard block
 block discarded – undo
708 726
 				{
709 727
 					// Ignore junky ids.
710 728
 					$q_id = (int) $q_id;
711
-					if ($q_id <= 0)
712
-						continue;
729
+					if ($q_id <= 0) {
730
+											continue;
731
+					}
713 732
 
714 733
 					// Check the question isn't empty (because they want to delete it?)
715 734
 					if (empty($question) || trim($question) == '')
716 735
 					{
717
-						if (isset($context['question_answers'][$q_id]))
718
-							$changes['delete'][] = $q_id;
736
+						if (isset($context['question_answers'][$q_id])) {
737
+													$changes['delete'][] = $q_id;
738
+						}
719 739
 						continue;
720 740
 					}
721 741
 					$question = $smcFunc['htmlspecialchars'](trim($question));
@@ -723,19 +743,22 @@  discard block
 block discarded – undo
723 743
 					// Get the answers. Firstly check there actually might be some.
724 744
 					if (!isset($_POST['answer'][$lang_id][$q_id]) || !is_array($_POST['answer'][$lang_id][$q_id]))
725 745
 					{
726
-						if (isset($context['question_answers'][$q_id]))
727
-							$changes['delete'][] = $q_id;
746
+						if (isset($context['question_answers'][$q_id])) {
747
+													$changes['delete'][] = $q_id;
748
+						}
728 749
 						continue;
729 750
 					}
730 751
 					// Now get them and check that they might be viable.
731 752
 					$answers = array();
732
-					foreach ($_POST['answer'][$lang_id][$q_id] as $answer)
733
-						if (!empty($answer) && trim($answer) !== '')
753
+					foreach ($_POST['answer'][$lang_id][$q_id] as $answer) {
754
+											if (!empty($answer) && trim($answer) !== '')
734 755
 							$answers[] = $smcFunc['htmlspecialchars'](trim($answer));
756
+					}
735 757
 					if (empty($answers))
736 758
 					{
737
-						if (isset($context['question_answers'][$q_id]))
738
-							$changes['delete'][] = $q_id;
759
+						if (isset($context['question_answers'][$q_id])) {
760
+													$changes['delete'][] = $q_id;
761
+						}
739 762
 						continue;
740 763
 					}
741 764
 					$answers = json_encode($answers);
@@ -745,16 +768,17 @@  discard block
 block discarded – undo
745 768
 					{
746 769
 						// New question. Now, we don't want to randomly consume ids, so we'll set those, rather than trusting the browser's supplied ids.
747 770
 						$changes['insert'][] = array($lang_id, $question, $answers);
748
-					}
749
-					else
771
+					} else
750 772
 					{
751 773
 						// It's an existing question. Let's see what's changed, if anything.
752
-						if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers'])
753
-							$changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers);
774
+						if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers']) {
775
+													$changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers);
776
+						}
754 777
 					}
755 778
 
756
-					if (!isset($qs_per_lang[$lang_id]))
757
-						$qs_per_lang[$lang_id] = 0;
779
+					if (!isset($qs_per_lang[$lang_id])) {
780
+											$qs_per_lang[$lang_id] = 0;
781
+					}
758 782
 					$qs_per_lang[$lang_id]++;
759 783
 				}
760 784
 			}
@@ -804,8 +828,9 @@  discard block
 block discarded – undo
804 828
 
805 829
 		// Lastly, the count of messages needs to be no more than the lowest number of questions for any one language.
806 830
 		$count_questions = empty($qs_per_lang) ? 0 : min($qs_per_lang);
807
-		if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions)
808
-			$_POST['qa_verification_number'] = $count_questions;
831
+		if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions) {
832
+					$_POST['qa_verification_number'] = $count_questions;
833
+		}
809 834
 
810 835
 		call_integration_hook('integrate_save_spam_settings', array(&$save_vars));
811 836
 
@@ -820,24 +845,27 @@  discard block
 block discarded – undo
820 845
 
821 846
 	$character_range = array_merge(range('A', 'H'), array('K', 'M', 'N', 'P', 'R'), range('T', 'Y'));
822 847
 	$_SESSION['visual_verification_code'] = '';
823
-	for ($i = 0; $i < 6; $i++)
824
-		$_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)];
848
+	for ($i = 0; $i < 6; $i++) {
849
+			$_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)];
850
+	}
825 851
 
826 852
 	// Some javascript for CAPTCHA.
827 853
 	$context['settings_post_javascript'] = '';
828
-	if ($context['use_graphic_library'])
829
-		$context['settings_post_javascript'] .= '
854
+	if ($context['use_graphic_library']) {
855
+			$context['settings_post_javascript'] .= '
830 856
 		function refreshImages()
831 857
 		{
832 858
 			var imageType = document.getElementById(\'visual_verification_type\').value;
833 859
 			document.getElementById(\'verification_image\').src = \'' . $context['verification_image_href'] . ';type=\' + imageType;
834 860
 		}';
861
+	}
835 862
 
836 863
 	// Show the image itself, or text saying we can't.
837
-	if ($context['use_graphic_library'])
838
-		$config_vars['vv']['postinput'] = '<br><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image"><br>';
839
-	else
840
-		$config_vars['vv']['postinput'] = '<br><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>';
864
+	if ($context['use_graphic_library']) {
865
+			$config_vars['vv']['postinput'] = '<br><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image"><br>';
866
+	} else {
867
+			$config_vars['vv']['postinput'] = '<br><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>';
868
+	}
841 869
 
842 870
 	// Hack for PM spam settings.
843 871
 	list ($modSettings['max_pm_recipients'], $modSettings['pm_posts_verification'], $modSettings['pm_posts_per_hour']) = explode(',', $modSettings['pm_spam_settings']);
@@ -847,9 +875,10 @@  discard block
 block discarded – undo
847 875
 	$modSettings['posts_require_captcha'] = !isset($modSettings['posts_require_captcha']) || $modSettings['posts_require_captcha'] == -1 ? 0 : $modSettings['posts_require_captcha'];
848 876
 
849 877
 	// Some minor javascript for the guest post setting.
850
-	if ($modSettings['posts_require_captcha'])
851
-		$context['settings_post_javascript'] .= '
878
+	if ($modSettings['posts_require_captcha']) {
879
+			$context['settings_post_javascript'] .= '
852 880
 		document.getElementById(\'guests_require_captcha\').disabled = true;';
881
+	}
853 882
 
854 883
 	// And everything else.
855 884
 	$context['post_url'] = $scripturl . '?action=admin;area=antispam;save';
@@ -896,8 +925,9 @@  discard block
 block discarded – undo
896 925
 
897 926
 	call_integration_hook('integrate_signature_settings', array(&$config_vars));
898 927
 
899
-	if ($return_config)
900
-		return $config_vars;
928
+	if ($return_config) {
929
+			return $config_vars;
930
+	}
901 931
 
902 932
 	// Setup the template.
903 933
 	$context['page_title'] = $txt['signature_settings'];
@@ -952,8 +982,9 @@  discard block
 block discarded – undo
952 982
 				$sig = strtr($row['signature'], array('<br>' => "\n"));
953 983
 
954 984
 				// Max characters...
955
-				if (!empty($sig_limits[1]))
956
-					$sig = $smcFunc['substr']($sig, 0, $sig_limits[1]);
985
+				if (!empty($sig_limits[1])) {
986
+									$sig = $smcFunc['substr']($sig, 0, $sig_limits[1]);
987
+				}
957 988
 				// Max lines...
958 989
 				if (!empty($sig_limits[2]))
959 990
 				{
@@ -963,8 +994,9 @@  discard block
 block discarded – undo
963 994
 						if ($sig[$i] == "\n")
964 995
 						{
965 996
 							$count++;
966
-							if ($count >= $sig_limits[2])
967
-								$sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' '));
997
+							if ($count >= $sig_limits[2]) {
998
+															$sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' '));
999
+							}
968 1000
 						}
969 1001
 					}
970 1002
 				}
@@ -975,17 +1007,19 @@  discard block
 block discarded – undo
975 1007
 					{
976 1008
 						$limit_broke = 0;
977 1009
 						// Attempt to allow all sizes of abuse, so to speak.
978
-						if ($matches[2][$ind] == 'px' && $size > $sig_limits[7])
979
-							$limit_broke = $sig_limits[7] . 'px';
980
-						elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75))
981
-							$limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt';
982
-						elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16))
983
-							$limit_broke = ((float) $sig_limits[7] / 16) . 'em';
984
-						elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18)
985
-							$limit_broke = 'large';
986
-
987
-						if ($limit_broke)
988
-							$sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig);
1010
+						if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) {
1011
+													$limit_broke = $sig_limits[7] . 'px';
1012
+						} elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) {
1013
+													$limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt';
1014
+						} elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) {
1015
+													$limit_broke = ((float) $sig_limits[7] / 16) . 'em';
1016
+						} elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) {
1017
+													$limit_broke = 'large';
1018
+						}
1019
+
1020
+						if ($limit_broke) {
1021
+													$sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig);
1022
+						}
989 1023
 					}
990 1024
 				}
991 1025
 
@@ -1041,32 +1075,34 @@  discard block
 block discarded – undo
1041 1075
 											$img_offset = false;
1042 1076
 										}
1043 1077
 									}
1078
+								} else {
1079
+																	$replaces[$image] = '';
1044 1080
 								}
1045
-								else
1046
-									$replaces[$image] = '';
1047 1081
 
1048 1082
 								continue;
1049 1083
 							}
1050 1084
 
1051 1085
 							// Does it have predefined restraints? Width first.
1052
-							if ($matches[6][$key])
1053
-								$matches[2][$key] = $matches[6][$key];
1086
+							if ($matches[6][$key]) {
1087
+															$matches[2][$key] = $matches[6][$key];
1088
+							}
1054 1089
 							if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5])
1055 1090
 							{
1056 1091
 								$width = $sig_limits[5];
1057 1092
 								$matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]);
1093
+							} elseif ($matches[2][$key]) {
1094
+															$width = $matches[2][$key];
1058 1095
 							}
1059
-							elseif ($matches[2][$key])
1060
-								$width = $matches[2][$key];
1061 1096
 							// ... and height.
1062 1097
 							if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6])
1063 1098
 							{
1064 1099
 								$height = $sig_limits[6];
1065
-								if ($width != -1)
1066
-									$width = $width * ($height / $matches[4][$key]);
1100
+								if ($width != -1) {
1101
+																	$width = $width * ($height / $matches[4][$key]);
1102
+								}
1103
+							} elseif ($matches[4][$key]) {
1104
+															$height = $matches[4][$key];
1067 1105
 							}
1068
-							elseif ($matches[4][$key])
1069
-								$height = $matches[4][$key];
1070 1106
 
1071 1107
 							// If the dimensions are still not fixed - we need to check the actual image.
1072 1108
 							if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6]))
@@ -1084,12 +1120,13 @@  discard block
 block discarded – undo
1084 1120
 									if ($sizes[1] > $sig_limits[6] && $sig_limits[6])
1085 1121
 									{
1086 1122
 										$height = $sig_limits[6];
1087
-										if ($width == -1)
1088
-											$width = $sizes[0];
1123
+										if ($width == -1) {
1124
+																					$width = $sizes[0];
1125
+										}
1089 1126
 										$width = $width * ($height / $sizes[1]);
1127
+									} elseif ($width != -1) {
1128
+																			$height = $sizes[1];
1090 1129
 									}
1091
-									elseif ($width != -1)
1092
-										$height = $sizes[1];
1093 1130
 								}
1094 1131
 							}
1095 1132
 
@@ -1102,8 +1139,9 @@  discard block
 block discarded – undo
1102 1139
 							// Record that we got one.
1103 1140
 							$image_count_holder[$image] = isset($image_count_holder[$image]) ? $image_count_holder[$image] + 1 : 1;
1104 1141
 						}
1105
-						if (!empty($replaces))
1106
-							$sig = str_replace(array_keys($replaces), array_values($replaces), $sig);
1142
+						if (!empty($replaces)) {
1143
+													$sig = str_replace(array_keys($replaces), array_values($replaces), $sig);
1144
+						}
1107 1145
 					}
1108 1146
 				}
1109 1147
 				// Try to fix disabled tags.
@@ -1115,18 +1153,20 @@  discard block
 block discarded – undo
1115 1153
 
1116 1154
 				$sig = strtr($sig, array("\n" => '<br>'));
1117 1155
 				call_integration_hook('integrate_apply_signature_settings', array(&$sig, $sig_limits, $disabledTags));
1118
-				if ($sig != $row['signature'])
1119
-					$changes[$row['id_member']] = $sig;
1156
+				if ($sig != $row['signature']) {
1157
+									$changes[$row['id_member']] = $sig;
1158
+				}
1159
+			}
1160
+			if ($smcFunc['db_num_rows']($request) == 0) {
1161
+							$done = true;
1120 1162
 			}
1121
-			if ($smcFunc['db_num_rows']($request) == 0)
1122
-				$done = true;
1123 1163
 			$smcFunc['db_free_result']($request);
1124 1164
 
1125 1165
 			// Do we need to delete what we have?
1126 1166
 			if (!empty($changes))
1127 1167
 			{
1128
-				foreach ($changes as $id => $sig)
1129
-					$smcFunc['db_query']('', '
1168
+				foreach ($changes as $id => $sig) {
1169
+									$smcFunc['db_query']('', '
1130 1170
 						UPDATE {db_prefix}members
1131 1171
 						SET signature = {string:signature}
1132 1172
 						WHERE id_member = {int:id_member}',
@@ -1135,11 +1175,13 @@  discard block
 block discarded – undo
1135 1175
 							'signature' => $sig,
1136 1176
 						)
1137 1177
 					);
1178
+				}
1138 1179
 			}
1139 1180
 
1140 1181
 			$_GET['step'] += 50;
1141
-			if (!$done)
1142
-				pauseSignatureApplySettings();
1182
+			if (!$done) {
1183
+							pauseSignatureApplySettings();
1184
+			}
1143 1185
 		}
1144 1186
 		$settings_applied = true;
1145 1187
 	}
@@ -1157,8 +1199,9 @@  discard block
 block discarded – undo
1157 1199
 	);
1158 1200
 
1159 1201
 	// Temporarily make each setting a modSetting!
1160
-	foreach ($context['signature_settings'] as $key => $value)
1161
-		$modSettings['signature_' . $key] = $value;
1202
+	foreach ($context['signature_settings'] as $key => $value) {
1203
+			$modSettings['signature_' . $key] = $value;
1204
+	}
1162 1205
 
1163 1206
 	// Make sure we check the right tags!
1164 1207
 	$modSettings['bbc_disabled_signature_bbc'] = $disabledTags;
@@ -1170,23 +1213,26 @@  discard block
 block discarded – undo
1170 1213
 
1171 1214
 		// Clean up the tag stuff!
1172 1215
 		$bbcTags = array();
1173
-		foreach (parse_bbc(false) as $tag)
1174
-			$bbcTags[] = $tag['tag'];
1216
+		foreach (parse_bbc(false) as $tag) {
1217
+					$bbcTags[] = $tag['tag'];
1218
+		}
1175 1219
 
1176
-		if (!isset($_POST['signature_bbc_enabledTags']))
1177
-			$_POST['signature_bbc_enabledTags'] = array();
1178
-		elseif (!is_array($_POST['signature_bbc_enabledTags']))
1179
-			$_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']);
1220
+		if (!isset($_POST['signature_bbc_enabledTags'])) {
1221
+					$_POST['signature_bbc_enabledTags'] = array();
1222
+		} elseif (!is_array($_POST['signature_bbc_enabledTags'])) {
1223
+					$_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']);
1224
+		}
1180 1225
 
1181 1226
 		$sig_limits = array();
1182 1227
 		foreach ($context['signature_settings'] as $key => $value)
1183 1228
 		{
1184
-			if ($key == 'allow_smileys')
1185
-				continue;
1186
-			elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys']))
1187
-				$sig_limits[] = -1;
1188
-			else
1189
-				$sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0;
1229
+			if ($key == 'allow_smileys') {
1230
+							continue;
1231
+			} elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys'])) {
1232
+							$sig_limits[] = -1;
1233
+			} else {
1234
+							$sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0;
1235
+			}
1190 1236
 		}
1191 1237
 
1192 1238
 		call_integration_hook('integrate_save_signature_settings', array(&$sig_limits, &$bbcTags));
@@ -1219,12 +1265,14 @@  discard block
 block discarded – undo
1219 1265
 
1220 1266
 	// Try get more time...
1221 1267
 	@set_time_limit(600);
1222
-	if (function_exists('apache_reset_timeout'))
1223
-		@apache_reset_timeout();
1268
+	if (function_exists('apache_reset_timeout')) {
1269
+			@apache_reset_timeout();
1270
+	}
1224 1271
 
1225 1272
 	// Have we exhausted all the time we allowed?
1226
-	if (time() - array_sum(explode(' ', $sig_start)) < 3)
1227
-		return;
1273
+	if (time() - array_sum(explode(' ', $sig_start)) < 3) {
1274
+			return;
1275
+	}
1228 1276
 
1229 1277
 	$context['continue_get_data'] = '?action=admin;area=featuresettings;sa=sig;apply;step=' . $_GET['step'] . ';' . $context['session_var'] . '=' . $context['session_id'];
1230 1278
 	$context['page_title'] = $txt['not_done_title'];
@@ -1270,9 +1318,10 @@  discard block
 block discarded – undo
1270 1318
 		$disable_fields = array_flip($standard_fields);
1271 1319
 		if (!empty($_POST['active']))
1272 1320
 		{
1273
-			foreach ($_POST['active'] as $value)
1274
-				if (isset($disable_fields[$value]))
1321
+			foreach ($_POST['active'] as $value) {
1322
+							if (isset($disable_fields[$value]))
1275 1323
 					unset($disable_fields[$value]);
1324
+			}
1276 1325
 		}
1277 1326
 		// What we have left!
1278 1327
 		$changes['disabled_profile_fields'] = empty($disable_fields) ? '' : implode(',', array_keys($disable_fields));
@@ -1281,16 +1330,18 @@  discard block
 block discarded – undo
1281 1330
 		$reg_fields = array();
1282 1331
 		if (!empty($_POST['reg']))
1283 1332
 		{
1284
-			foreach ($_POST['reg'] as $value)
1285
-				if (in_array($value, $standard_fields) && !isset($disable_fields[$value]))
1333
+			foreach ($_POST['reg'] as $value) {
1334
+							if (in_array($value, $standard_fields) && !isset($disable_fields[$value]))
1286 1335
 					$reg_fields[] = $value;
1336
+			}
1287 1337
 		}
1288 1338
 		// What we have left!
1289 1339
 		$changes['registration_fields'] = empty($reg_fields) ? '' : implode(',', $reg_fields);
1290 1340
 
1291 1341
 		$_SESSION['adm-save'] = true;
1292
-		if (!empty($changes))
1293
-			updateSettings($changes);
1342
+		if (!empty($changes)) {
1343
+					updateSettings($changes);
1344
+		}
1294 1345
 	}
1295 1346
 
1296 1347
 	createToken('admin-scp');
@@ -1393,11 +1444,13 @@  discard block
 block discarded – undo
1393 1444
 					{
1394 1445
 						$return = '<p class="centertext bold_text">'. $rowData['field_order'] .'<br />';
1395 1446
 
1396
-						if ($rowData['field_order'] > 1)
1397
-							$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>';
1447
+						if ($rowData['field_order'] > 1) {
1448
+													$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>';
1449
+						}
1398 1450
 
1399
-						if ($rowData['field_order'] < $context['custFieldsMaxOrder'])
1400
-							$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>';
1451
+						if ($rowData['field_order'] < $context['custFieldsMaxOrder']) {
1452
+													$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>';
1453
+						}
1401 1454
 
1402 1455
 						$return .= '</p>';
1403 1456
 
@@ -1535,16 +1588,16 @@  discard block
 block discarded – undo
1535 1588
 		$disabled_fields = isset($modSettings['disabled_profile_fields']) ? explode(',', $modSettings['disabled_profile_fields']) : array();
1536 1589
 		$registration_fields = isset($modSettings['registration_fields']) ? explode(',', $modSettings['registration_fields']) : array();
1537 1590
 
1538
-		foreach ($standard_fields as $field)
1539
-			$list[] = array(
1591
+		foreach ($standard_fields as $field) {
1592
+					$list[] = array(
1540 1593
 				'id' => $field,
1541 1594
 				'label' => isset($txt['standard_profile_field_' . $field]) ? $txt['standard_profile_field_' . $field] : (isset($txt[$field]) ? $txt[$field] : $field),
1542 1595
 				'disabled' => in_array($field, $disabled_fields),
1543 1596
 				'on_register' => in_array($field, $registration_fields) && !in_array($field, $fields_no_registration),
1544 1597
 				'can_show_register' => !in_array($field, $fields_no_registration),
1545 1598
 			);
1546
-	}
1547
-	else
1599
+		}
1600
+	} else
1548 1601
 	{
1549 1602
 		// Load all the fields.
1550 1603
 		$request = $smcFunc['db_query']('', '
@@ -1558,8 +1611,9 @@  discard block
 block discarded – undo
1558 1611
 				'items_per_page' => $items_per_page,
1559 1612
 			)
1560 1613
 		);
1561
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1562
-			$list[] = $row;
1614
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1615
+					$list[] = $row;
1616
+		}
1563 1617
 		$smcFunc['db_free_result']($request);
1564 1618
 	}
1565 1619
 
@@ -1625,9 +1679,9 @@  discard block
 block discarded – undo
1625 1679
 		$context['field'] = array();
1626 1680
 		while ($row = $smcFunc['db_fetch_assoc']($request))
1627 1681
 		{
1628
-			if ($row['field_type'] == 'textarea')
1629
-				@list ($rows, $cols) = @explode(',', $row['default_value']);
1630
-			else
1682
+			if ($row['field_type'] == 'textarea') {
1683
+							@list ($rows, $cols) = @explode(',', $row['default_value']);
1684
+			} else
1631 1685
 			{
1632 1686
 				$rows = 3;
1633 1687
 				$cols = 30;
@@ -1663,8 +1717,8 @@  discard block
 block discarded – undo
1663 1717
 	}
1664 1718
 
1665 1719
 	// Setup the default values as needed.
1666
-	if (empty($context['field']))
1667
-		$context['field'] = array(
1720
+	if (empty($context['field'])) {
1721
+			$context['field'] = array(
1668 1722
 			'name' => '',
1669 1723
 			'col_name' => '???',
1670 1724
 			'desc' => '',
@@ -1689,6 +1743,7 @@  discard block
 block discarded – undo
1689 1743
 			'enclose' => '',
1690 1744
 			'placement' => 0,
1691 1745
 		);
1746
+	}
1692 1747
 
1693 1748
 	// Are we moving it?
1694 1749
 	if (isset($_GET['move']) && in_array($smcFunc['htmlspecialchars']($_GET['move']), $move_to))
@@ -1697,8 +1752,10 @@  discard block
 block discarded – undo
1697 1752
 		$new_order = ($_GET['move'] == 'up' ? ($context['field']['order'] - 1) : ($context['field']['order'] + 1));
1698 1753
 
1699 1754
 		// Is this a valid position?
1700
-		if ($new_order <= 0 || $new_order > $order_count)
1701
-			redirectexit('action=admin;area=featuresettings;sa=profile'); // @todo implement an error handler
1755
+		if ($new_order <= 0 || $new_order > $order_count) {
1756
+					redirectexit('action=admin;area=featuresettings;sa=profile');
1757
+		}
1758
+		// @todo implement an error handler
1702 1759
 
1703 1760
 		// All good, proceed.
1704 1761
 		$smcFunc['db_query']('','
@@ -1729,12 +1786,14 @@  discard block
 block discarded – undo
1729 1786
 		validateToken('admin-ecp');
1730 1787
 
1731 1788
 		// Everyone needs a name - even the (bracket) unknown...
1732
-		if (trim($_POST['field_name']) == '')
1733
-			redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name');
1789
+		if (trim($_POST['field_name']) == '') {
1790
+					redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name');
1791
+		}
1734 1792
 
1735 1793
 		// Regex you say?  Do a very basic test to see if the pattern is valid
1736
-		if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false)
1737
-			redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error');
1794
+		if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false) {
1795
+					redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error');
1796
+		}
1738 1797
 
1739 1798
 		$_POST['field_name'] = $smcFunc['htmlspecialchars']($_POST['field_name']);
1740 1799
 		$_POST['field_desc'] = $smcFunc['htmlspecialchars']($_POST['field_desc']);
@@ -1751,8 +1810,9 @@  discard block
 block discarded – undo
1751 1810
 
1752 1811
 		// Some masking stuff...
1753 1812
 		$mask = isset($_POST['mask']) ? $_POST['mask'] : '';
1754
-		if ($mask == 'regex' && isset($_POST['regex']))
1755
-			$mask .= $_POST['regex'];
1813
+		if ($mask == 'regex' && isset($_POST['regex'])) {
1814
+					$mask .= $_POST['regex'];
1815
+		}
1756 1816
 
1757 1817
 		$field_length = isset($_POST['max_length']) ? (int) $_POST['max_length'] : 255;
1758 1818
 		$enclose = isset($_POST['enclose']) ? $_POST['enclose'] : '';
@@ -1771,8 +1831,9 @@  discard block
 block discarded – undo
1771 1831
 				$v = strtr($v, array(',' => ''));
1772 1832
 
1773 1833
 				// Nada, zip, etc...
1774
-				if (trim($v) == '')
1775
-					continue;
1834
+				if (trim($v) == '') {
1835
+									continue;
1836
+				}
1776 1837
 
1777 1838
 				// Otherwise, save it boy.
1778 1839
 				$field_options .= $v . ',';
@@ -1780,15 +1841,17 @@  discard block
 block discarded – undo
1780 1841
 				$newOptions[$k] = $v;
1781 1842
 
1782 1843
 				// Is it default?
1783
-				if (isset($_POST['default_select']) && $_POST['default_select'] == $k)
1784
-					$default = $v;
1844
+				if (isset($_POST['default_select']) && $_POST['default_select'] == $k) {
1845
+									$default = $v;
1846
+				}
1785 1847
 			}
1786 1848
 			$field_options = substr($field_options, 0, -1);
1787 1849
 		}
1788 1850
 
1789 1851
 		// Text area has default has dimensions
1790
-		if ($_POST['field_type'] == 'textarea')
1791
-			$default = (int) $_POST['rows'] . ',' . (int) $_POST['cols'];
1852
+		if ($_POST['field_type'] == 'textarea') {
1853
+					$default = (int) $_POST['rows'] . ',' . (int) $_POST['cols'];
1854
+		}
1792 1855
 
1793 1856
 		// Come up with the unique name?
1794 1857
 		if (empty($context['fid']))
@@ -1797,32 +1860,36 @@  discard block
 block discarded – undo
1797 1860
 			preg_match('~([\w\d_-]+)~', $col_name, $matches);
1798 1861
 
1799 1862
 			// If there is nothing to the name, then let's start out own - for foreign languages etc.
1800
-			if (isset($matches[1]))
1801
-				$col_name = $initial_col_name = 'cust_' . strtolower($matches[1]);
1802
-			else
1803
-				$col_name = $initial_col_name = 'cust_' . mt_rand(1, 9999);
1863
+			if (isset($matches[1])) {
1864
+							$col_name = $initial_col_name = 'cust_' . strtolower($matches[1]);
1865
+			} else {
1866
+							$col_name = $initial_col_name = 'cust_' . mt_rand(1, 9999);
1867
+			}
1804 1868
 
1805 1869
 			// Make sure this is unique.
1806 1870
 			$current_fields = array();
1807 1871
 			$request = $smcFunc['db_query']('', '
1808 1872
 				SELECT id_field, col_name
1809 1873
 				FROM {db_prefix}custom_fields');
1810
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1811
-				$current_fields[$row['id_field']] = $row['col_name'];
1874
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
1875
+							$current_fields[$row['id_field']] = $row['col_name'];
1876
+			}
1812 1877
 			$smcFunc['db_free_result']($request);
1813 1878
 
1814 1879
 			$unique = false;
1815 1880
 			for ($i = 0; !$unique && $i < 9; $i ++)
1816 1881
 			{
1817
-				if (!in_array($col_name, $current_fields))
1818
-					$unique = true;
1819
-				else
1820
-					$col_name = $initial_col_name . $i;
1882
+				if (!in_array($col_name, $current_fields)) {
1883
+									$unique = true;
1884
+				} else {
1885
+									$col_name = $initial_col_name . $i;
1886
+				}
1821 1887
 			}
1822 1888
 
1823 1889
 			// Still not a unique column name? Leave it up to the user, then.
1824
-			if (!$unique)
1825
-				fatal_lang_error('custom_option_not_unique');
1890
+			if (!$unique) {
1891
+							fatal_lang_error('custom_option_not_unique');
1892
+			}
1826 1893
 		}
1827 1894
 		// Work out what to do with the user data otherwise...
1828 1895
 		else
@@ -1850,8 +1917,9 @@  discard block
 block discarded – undo
1850 1917
 				// Work out what's changed!
1851 1918
 				foreach ($context['field']['options'] as $k => $option)
1852 1919
 				{
1853
-					if (trim($option) == '')
1854
-						continue;
1920
+					if (trim($option) == '') {
1921
+											continue;
1922
+					}
1855 1923
 
1856 1924
 					// Still exists?
1857 1925
 					if (in_array($option, $newOptions))
@@ -1865,8 +1933,8 @@  discard block
 block discarded – undo
1865 1933
 				foreach ($optionChanges as $k => $option)
1866 1934
 				{
1867 1935
 					// Just been renamed?
1868
-					if (!in_array($k, $takenKeys) && !empty($newOptions[$k]))
1869
-						$smcFunc['db_query']('', '
1936
+					if (!in_array($k, $takenKeys) && !empty($newOptions[$k])) {
1937
+											$smcFunc['db_query']('', '
1870 1938
 							UPDATE {db_prefix}themes
1871 1939
 							SET value = {string:new_value}
1872 1940
 							WHERE variable = {string:current_column}
@@ -1879,6 +1947,7 @@  discard block
 block discarded – undo
1879 1947
 								'old_value' => $option,
1880 1948
 							)
1881 1949
 						);
1950
+					}
1882 1951
 				}
1883 1952
 			}
1884 1953
 			// @todo Maybe we should adjust based on new text length limits?
@@ -1921,8 +1990,8 @@  discard block
 block discarded – undo
1921 1990
 			);
1922 1991
 
1923 1992
 			// Just clean up any old selects - these are a pain!
1924
-			if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions))
1925
-				$smcFunc['db_query']('', '
1993
+			if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions)) {
1994
+							$smcFunc['db_query']('', '
1926 1995
 					DELETE FROM {db_prefix}themes
1927 1996
 					WHERE variable = {string:current_column}
1928 1997
 						AND value NOT IN ({array_string:new_option_values})
@@ -1933,8 +2002,8 @@  discard block
 block discarded – undo
1933 2002
 						'current_column' => $context['field']['col_name'],
1934 2003
 					)
1935 2004
 				);
1936
-		}
1937
-		else
2005
+			}
2006
+		} else
1938 2007
 		{
1939 2008
 			// Gotta figure it out the order.
1940 2009
 			$new_order = $order_count > 1 ? ($order_count + 1) : 1;
@@ -2108,11 +2177,13 @@  discard block
 block discarded – undo
2108 2177
 	call_integration_hook('integrate_prune_settings', array(&$config_vars, &$prune_toggle, false));
2109 2178
 
2110 2179
 	$prune_toggle_dt = array();
2111
-	foreach ($prune_toggle as $item)
2112
-		$prune_toggle_dt[] = 'setting_' . $item;
2180
+	foreach ($prune_toggle as $item) {
2181
+			$prune_toggle_dt[] = 'setting_' . $item;
2182
+	}
2113 2183
 
2114
-	if ($return_config)
2115
-		return $config_vars;
2184
+	if ($return_config) {
2185
+			return $config_vars;
2186
+	}
2116 2187
 
2117 2188
 	addInlineJavaScript('
2118 2189
 	function togglePruned()
@@ -2150,15 +2221,16 @@  discard block
 block discarded – undo
2150 2221
 			$vals = array();
2151 2222
 			foreach ($config_vars as $index => $dummy)
2152 2223
 			{
2153
-				if (!is_array($dummy) || $index == 'pruningOptions' || !in_array($dummy[1], $prune_toggle))
2154
-					continue;
2224
+				if (!is_array($dummy) || $index == 'pruningOptions' || !in_array($dummy[1], $prune_toggle)) {
2225
+									continue;
2226
+				}
2155 2227
 
2156 2228
 				$vals[] = empty($_POST[$dummy[1]]) || $_POST[$dummy[1]] < 0 ? 0 : (int) $_POST[$dummy[1]];
2157 2229
 			}
2158 2230
 			$_POST['pruningOptions'] = implode(',', $vals);
2231
+		} else {
2232
+					$_POST['pruningOptions'] = '';
2159 2233
 		}
2160
-		else
2161
-			$_POST['pruningOptions'] = '';
2162 2234
 
2163 2235
 		saveDBSettings($savevar);
2164 2236
 		$_SESSION['adm-save'] = true;
@@ -2170,10 +2242,11 @@  discard block
 block discarded – undo
2170 2242
 	$context['sub_template'] = 'show_settings';
2171 2243
 
2172 2244
 	// Get the actual values
2173
-	if (!empty($modSettings['pruningOptions']))
2174
-		@list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']);
2175
-	else
2176
-		$modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0;
2245
+	if (!empty($modSettings['pruningOptions'])) {
2246
+			@list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']);
2247
+	} else {
2248
+			$modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0;
2249
+	}
2177 2250
 
2178 2251
 	prepareDBSettingContext($config_vars);
2179 2252
 }
@@ -2195,8 +2268,9 @@  discard block
 block discarded – undo
2195 2268
 	// Make it even easier to add new settings.
2196 2269
 	call_integration_hook('integrate_general_mod_settings', array(&$config_vars));
2197 2270
 
2198
-	if ($return_config)
2199
-		return $config_vars;
2271
+	if ($return_config) {
2272
+			return $config_vars;
2273
+	}
2200 2274
 
2201 2275
 	$context['post_url'] = $scripturl . '?action=admin;area=modsettings;save;sa=general';
2202 2276
 	$context['settings_title'] = $txt['mods_cat_modifications_misc'];
Please login to merge, or discard this patch.
Sources/Class-CacheAPI.php 1 patch
Braces   +13 added lines, -9 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
  * @version 2.1 Beta 3
12 12
  */
13 13
 
14
-if (!defined('SMF'))
14
+if (!defined('SMF')) {
15 15
 	die('Hacking attempt...');
16
+}
16 17
 
17 18
 /**
18 19
  * Interface cache_api_interface
@@ -186,8 +187,9 @@  discard block
 block discarded – undo
186 187
 	{
187 188
 		global $cache_enable;
188 189
 
189
-		if ($test)
190
-			return true;
190
+		if ($test) {
191
+					return true;
192
+		}
191 193
 		return !empty($cache_enable);
192 194
 	}
193 195
 
@@ -206,10 +208,11 @@  discard block
 block discarded – undo
206 208
 		global $boardurl, $cachedir;
207 209
 
208 210
 		// Set the default if no prefix was specified.
209
-		if (empty($prefix))
210
-			$this->prefix = md5($boardurl . filemtime($cachedir . '/' . 'index.php')) . '-SMF-';
211
-		else
212
-			$this->prefix = $prefix;
211
+		if (empty($prefix)) {
212
+					$this->prefix = md5($boardurl . filemtime($cachedir . '/' . 'index.php')) . '-SMF-';
213
+		} else {
214
+					$this->prefix = $prefix;
215
+		}
213 216
 
214 217
 		return true;
215 218
 	}
@@ -272,8 +275,9 @@  discard block
 block discarded – undo
272 275
 
273 276
 		// Invalidate cache, to be sure!
274 277
 		// ... as long as index.php can be modified, anyway.
275
-		if (is_writable($cachedir . '/' . 'index.php'))
276
-			@touch($cachedir . '/' . 'index.php');
278
+		if (is_writable($cachedir . '/' . 'index.php')) {
279
+					@touch($cachedir . '/' . 'index.php');
280
+		}
277 281
 
278 282
 		return true;
279 283
 	}
Please login to merge, or discard this patch.
Sources/Register.php 1 patch
Braces   +168 added lines, -122 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
  * Begin the registration process.
@@ -29,19 +30,23 @@  discard block
 block discarded – undo
29 30
 	global $language, $scripturl, $smcFunc, $sourcedir, $cur_profile;
30 31
 
31 32
 	// Is this an incoming AJAX check?
32
-	if (isset($_GET['sa']) && $_GET['sa'] == 'usernamecheck')
33
-		return RegisterCheckUsername();
33
+	if (isset($_GET['sa']) && $_GET['sa'] == 'usernamecheck') {
34
+			return RegisterCheckUsername();
35
+	}
34 36
 
35 37
 	// Check if the administrator has it disabled.
36
-	if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == '3')
37
-		fatal_lang_error('registration_disabled', false);
38
+	if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == '3') {
39
+			fatal_lang_error('registration_disabled', false);
40
+	}
38 41
 
39 42
 	// If this user is an admin - redirect them to the admin registration page.
40
-	if (allowedTo('moderate_forum') && !$user_info['is_guest'])
41
-		redirectexit('action=admin;area=regcenter;sa=register');
43
+	if (allowedTo('moderate_forum') && !$user_info['is_guest']) {
44
+			redirectexit('action=admin;area=regcenter;sa=register');
45
+	}
42 46
 	// You are not a guest, so you are a member - and members don't get to register twice!
43
-	elseif (empty($user_info['is_guest']))
44
-		redirectexit();
47
+	elseif (empty($user_info['is_guest'])) {
48
+			redirectexit();
49
+	}
45 50
 
46 51
 	loadLanguage('Login');
47 52
 	loadTemplate('Register');
@@ -82,16 +87,18 @@  discard block
 block discarded – undo
82 87
 		}
83 88
 	}
84 89
 	// Make sure they don't squeeze through without agreeing.
85
-	elseif ($current_step > 1 && $context['require_agreement'] && !$context['registration_passed_agreement'])
86
-		$current_step = 1;
90
+	elseif ($current_step > 1 && $context['require_agreement'] && !$context['registration_passed_agreement']) {
91
+			$current_step = 1;
92
+	}
87 93
 
88 94
 	// Show the user the right form.
89 95
 	$context['sub_template'] = $current_step == 1 ? 'registration_agreement' : 'registration_form';
90 96
 	$context['page_title'] = $current_step == 1 ? $txt['registration_agreement'] : $txt['registration_form'];
91 97
 
92 98
 	// Kinda need this.
93
-	if ($context['sub_template'] == 'registration_form')
94
-		loadJavaScriptFile('register.js', array('defer' => false), 'smf_register');
99
+	if ($context['sub_template'] == 'registration_form') {
100
+			loadJavaScriptFile('register.js', array('defer' => false), 'smf_register');
101
+	}
95 102
 
96 103
 	// Add the register chain to the link tree.
97 104
 	$context['linktree'][] = array(
@@ -100,24 +107,26 @@  discard block
 block discarded – undo
100 107
 	);
101 108
 
102 109
 	// Prepare the time gate! Do it like so, in case later steps want to reset the limit for any reason, but make sure the time is the current one.
103
-	if (!isset($_SESSION['register']))
104
-		$_SESSION['register'] = array(
110
+	if (!isset($_SESSION['register'])) {
111
+			$_SESSION['register'] = array(
105 112
 			'timenow' => time(),
106 113
 			'limit' => 10, // minimum number of seconds required on this page for registration
107 114
 		);
108
-	else
109
-		$_SESSION['register']['timenow'] = time();
115
+	} else {
116
+			$_SESSION['register']['timenow'] = time();
117
+	}
110 118
 
111 119
 	// If you have to agree to the agreement, it needs to be fetched from the file.
112 120
 	if ($context['require_agreement'])
113 121
 	{
114 122
 		// Have we got a localized one?
115
-		if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt'))
116
-			$context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']);
117
-		elseif (file_exists($boarddir . '/agreement.txt'))
118
-			$context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement');
119
-		else
120
-			$context['agreement'] = '';
123
+		if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt')) {
124
+					$context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']);
125
+		} elseif (file_exists($boarddir . '/agreement.txt')) {
126
+					$context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement');
127
+		} else {
128
+					$context['agreement'] = '';
129
+		}
121 130
 
122 131
 		// Nothing to show, lets disable registration and inform the admin of this error
123 132
 		if (empty($context['agreement']))
@@ -133,8 +142,9 @@  discard block
 block discarded – undo
133 142
 		$selectedLanguage = empty($_SESSION['language']) ? $language : $_SESSION['language'];
134 143
 
135 144
 		// Do we have any languages?
136
-		if (empty($context['languages']))
137
-			getLanguages();
145
+		if (empty($context['languages'])) {
146
+					getLanguages();
147
+		}
138 148
 
139 149
 		// Try to find our selected language.
140 150
 		foreach ($context['languages'] as $key => $lang)
@@ -142,8 +152,9 @@  discard block
 block discarded – undo
142 152
 			$context['languages'][$key]['name'] = strtr($lang['name'], array('-utf8' => ''));
143 153
 
144 154
 			// Found it!
145
-			if ($selectedLanguage == $lang['filename'])
146
-				$context['languages'][$key]['selected'] = true;
155
+			if ($selectedLanguage == $lang['filename']) {
156
+							$context['languages'][$key]['selected'] = true;
157
+			}
147 158
 		}
148 159
 	}
149 160
 
@@ -167,9 +178,10 @@  discard block
 block discarded – undo
167 178
 		$reg_fields = explode(',', $modSettings['registration_fields']);
168 179
 
169 180
 		// We might have had some submissions on this front - go check.
170
-		foreach ($reg_fields as $field)
171
-			if (isset($_POST[$field]))
181
+		foreach ($reg_fields as $field) {
182
+					if (isset($_POST[$field]))
172 183
 				$cur_profile[$field] = $smcFunc['htmlspecialchars']($_POST[$field]);
184
+		}
173 185
 
174 186
 		// Load all the fields in question.
175 187
 		setupProfileContext($reg_fields);
@@ -186,8 +198,9 @@  discard block
 block discarded – undo
186 198
 		$context['visual_verification_id'] = $verificationOptions['id'];
187 199
 	}
188 200
 	// Otherwise we have nothing to show.
189
-	else
190
-		$context['visual_verification'] = false;
201
+	else {
202
+			$context['visual_verification'] = false;
203
+	}
191 204
 
192 205
 
193 206
 	$context += array(
@@ -198,8 +211,9 @@  discard block
 block discarded – undo
198 211
 
199 212
 	// Were there any errors?
200 213
 	$context['registration_errors'] = array();
201
-	if (!empty($reg_errors))
202
-		$context['registration_errors'] = $reg_errors;
214
+	if (!empty($reg_errors)) {
215
+			$context['registration_errors'] = $reg_errors;
216
+	}
203 217
 
204 218
 	createToken('register');
205 219
 }
@@ -216,27 +230,32 @@  discard block
 block discarded – undo
216 230
 	validateToken('register');
217 231
 
218 232
 	// Check to ensure we're forcing SSL for authentication
219
-	if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on'))
220
-		fatal_lang_error('register_ssl_required');
233
+	if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) {
234
+			fatal_lang_error('register_ssl_required');
235
+	}
221 236
 
222 237
 	// Start collecting together any errors.
223 238
 	$reg_errors = array();
224 239
 
225 240
 	// You can't register if it's disabled.
226
-	if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 3)
227
-		fatal_lang_error('registration_disabled', false);
241
+	if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 3) {
242
+			fatal_lang_error('registration_disabled', false);
243
+	}
228 244
 
229 245
 	// Well, if you don't agree, you can't register.
230
-	if (!empty($modSettings['requireAgreement']) && empty($_SESSION['registration_agreed']))
231
-		redirectexit();
246
+	if (!empty($modSettings['requireAgreement']) && empty($_SESSION['registration_agreed'])) {
247
+			redirectexit();
248
+	}
232 249
 
233 250
 	// Make sure they came from *somewhere*, have a session.
234
-	if (!isset($_SESSION['old_url']))
235
-		redirectexit('action=signup');
251
+	if (!isset($_SESSION['old_url'])) {
252
+			redirectexit('action=signup');
253
+	}
236 254
 
237 255
 	// If we don't require an agreement, we need a extra check for coppa.
238
-	if (empty($modSettings['requireAgreement']) && !empty($modSettings['coppaAge']))
239
-		$_SESSION['skip_coppa'] = !empty($_POST['accept_agreement']);
256
+	if (empty($modSettings['requireAgreement']) && !empty($modSettings['coppaAge'])) {
257
+			$_SESSION['skip_coppa'] = !empty($_POST['accept_agreement']);
258
+	}
240 259
 	// Are they under age, and under age users are banned?
241 260
 	if (!empty($modSettings['coppaAge']) && empty($modSettings['coppaType']) && empty($_SESSION['skip_coppa']))
242 261
 	{
@@ -245,8 +264,9 @@  discard block
 block discarded – undo
245 264
 	}
246 265
 
247 266
 	// Check the time gate for miscreants. First make sure they came from somewhere that actually set it up.
248
-	if (empty($_SESSION['register']['timenow']) || empty($_SESSION['register']['limit']))
249
-		redirectexit('action=signup');
267
+	if (empty($_SESSION['register']['timenow']) || empty($_SESSION['register']['limit'])) {
268
+			redirectexit('action=signup');
269
+	}
250 270
 	// Failing that, check the time on it.
251 271
 	if (time() - $_SESSION['register']['timenow'] < $_SESSION['register']['limit'])
252 272
 	{
@@ -266,15 +286,17 @@  discard block
 block discarded – undo
266 286
 		if (is_array($context['visual_verification']))
267 287
 		{
268 288
 			loadLanguage('Errors');
269
-			foreach ($context['visual_verification'] as $error)
270
-				$reg_errors[] = $txt['error_' . $error];
289
+			foreach ($context['visual_verification'] as $error) {
290
+							$reg_errors[] = $txt['error_' . $error];
291
+			}
271 292
 		}
272 293
 	}
273 294
 
274 295
 	foreach ($_POST as $key => $value)
275 296
 	{
276
-		if (!is_array($_POST[$key]))
277
-			$_POST[$key] = htmltrim__recursive(str_replace(array("\n", "\r"), '', $_POST[$key]));
297
+		if (!is_array($_POST[$key])) {
298
+					$_POST[$key] = htmltrim__recursive(str_replace(array("\n", "\r"), '', $_POST[$key]));
299
+		}
278 300
 	}
279 301
 
280 302
 	// Collect all extra registration fields someone might have filled in.
@@ -304,12 +326,14 @@  discard block
 block discarded – undo
304 326
 		$reg_fields = explode(',', $modSettings['registration_fields']);
305 327
 
306 328
 		// Website is a little different
307
-		if (in_array('website', $reg_fields))
308
-			$possible_strings += array('website_url', 'website_title');
329
+		if (in_array('website', $reg_fields)) {
330
+					$possible_strings += array('website_url', 'website_title');
331
+		}
309 332
 	}
310 333
 
311
-	if (isset($_POST['secret_answer']) && $_POST['secret_answer'] != '')
312
-		$_POST['secret_answer'] = md5($_POST['secret_answer']);
334
+	if (isset($_POST['secret_answer']) && $_POST['secret_answer'] != '') {
335
+			$_POST['secret_answer'] = md5($_POST['secret_answer']);
336
+	}
313 337
 
314 338
 	// Needed for isReservedName() and registerMember().
315 339
 	require_once($sourcedir . '/Subs-Members.php');
@@ -318,32 +342,37 @@  discard block
 block discarded – undo
318 342
 	if (isset($_POST['real_name']) && (allowedTo('profile_displayed_name') || allowedTo('moderate_forum')))
319 343
 	{
320 344
 		$_POST['real_name'] = trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $_POST['real_name']));
321
-		if (trim($_POST['real_name']) != '' && !isReservedName($_POST['real_name']) && $smcFunc['strlen']($_POST['real_name']) < 60)
322
-			$possible_strings[] = 'real_name';
345
+		if (trim($_POST['real_name']) != '' && !isReservedName($_POST['real_name']) && $smcFunc['strlen']($_POST['real_name']) < 60) {
346
+					$possible_strings[] = 'real_name';
347
+		}
323 348
 	}
324 349
 
325 350
 	// Handle a string as a birthdate...
326
-	if (isset($_POST['birthdate']) && $_POST['birthdate'] != '')
327
-		$_POST['birthdate'] = strftime('%Y-%m-%d', strtotime($_POST['birthdate']));
351
+	if (isset($_POST['birthdate']) && $_POST['birthdate'] != '') {
352
+			$_POST['birthdate'] = strftime('%Y-%m-%d', strtotime($_POST['birthdate']));
353
+	}
328 354
 	// Or birthdate parts...
329
-	elseif (!empty($_POST['bday1']) && !empty($_POST['bday2']))
330
-		$_POST['birthdate'] = sprintf('%04d-%02d-%02d', empty($_POST['bday3']) ? 0 : (int) $_POST['bday3'], (int) $_POST['bday1'], (int) $_POST['bday2']);
355
+	elseif (!empty($_POST['bday1']) && !empty($_POST['bday2'])) {
356
+			$_POST['birthdate'] = sprintf('%04d-%02d-%02d', empty($_POST['bday3']) ? 0 : (int) $_POST['bday3'], (int) $_POST['bday1'], (int) $_POST['bday2']);
357
+	}
331 358
 
332 359
 	// Validate the passed language file.
333 360
 	if (isset($_POST['lngfile']) && !empty($modSettings['userLanguage']))
334 361
 	{
335 362
 		// Do we have any languages?
336
-		if (empty($context['languages']))
337
-			getLanguages();
363
+		if (empty($context['languages'])) {
364
+					getLanguages();
365
+		}
338 366
 
339 367
 		// Did we find it?
340
-		if (isset($context['languages'][$_POST['lngfile']]))
341
-			$_SESSION['language'] = $_POST['lngfile'];
342
-		else
368
+		if (isset($context['languages'][$_POST['lngfile']])) {
369
+					$_SESSION['language'] = $_POST['lngfile'];
370
+		} else {
371
+					unset($_POST['lngfile']);
372
+		}
373
+	} else {
343 374
 			unset($_POST['lngfile']);
344 375
 	}
345
-	else
346
-		unset($_POST['lngfile']);
347 376
 
348 377
 	// Set the options needed for registration.
349 378
 	$regOptions = array(
@@ -363,22 +392,27 @@  discard block
 block discarded – undo
363 392
 	);
364 393
 
365 394
 	// Include the additional options that might have been filled in.
366
-	foreach ($possible_strings as $var)
367
-		if (isset($_POST[$var]))
395
+	foreach ($possible_strings as $var) {
396
+			if (isset($_POST[$var]))
368 397
 			$regOptions['extra_register_vars'][$var] = $smcFunc['htmlspecialchars']($_POST[$var], ENT_QUOTES);
369
-	foreach ($possible_ints as $var)
370
-		if (isset($_POST[$var]))
398
+	}
399
+	foreach ($possible_ints as $var) {
400
+			if (isset($_POST[$var]))
371 401
 			$regOptions['extra_register_vars'][$var] = (int) $_POST[$var];
372
-	foreach ($possible_floats as $var)
373
-		if (isset($_POST[$var]))
402
+	}
403
+	foreach ($possible_floats as $var) {
404
+			if (isset($_POST[$var]))
374 405
 			$regOptions['extra_register_vars'][$var] = (float) $_POST[$var];
375
-	foreach ($possible_bools as $var)
376
-		if (isset($_POST[$var]))
406
+	}
407
+	foreach ($possible_bools as $var) {
408
+			if (isset($_POST[$var]))
377 409
 			$regOptions['extra_register_vars'][$var] = empty($_POST[$var]) ? 0 : 1;
410
+	}
378 411
 
379 412
 	// Registration options are always default options...
380
-	if (isset($_POST['default_options']))
381
-		$_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options'];
413
+	if (isset($_POST['default_options'])) {
414
+			$_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options'];
415
+	}
382 416
 	$regOptions['theme_vars'] = isset($_POST['options']) && is_array($_POST['options']) ? $_POST['options'] : array();
383 417
 
384 418
 	// Make sure they are clean, dammit!
@@ -398,12 +432,14 @@  discard block
 block discarded – undo
398 432
 	while ($row = $smcFunc['db_fetch_assoc']($request))
399 433
 	{
400 434
 		// Don't allow overriding of the theme variables.
401
-		if (isset($regOptions['theme_vars'][$row['col_name']]))
402
-			unset($regOptions['theme_vars'][$row['col_name']]);
435
+		if (isset($regOptions['theme_vars'][$row['col_name']])) {
436
+					unset($regOptions['theme_vars'][$row['col_name']]);
437
+		}
403 438
 
404 439
 		// Not actually showing it then?
405
-		if (!$row['show_reg'])
406
-			continue;
440
+		if (!$row['show_reg']) {
441
+					continue;
442
+		}
407 443
 
408 444
 		// Prepare the value!
409 445
 		$value = isset($_POST['customfield'][$row['col_name']]) ? trim($_POST['customfield'][$row['col_name']]) : '';
@@ -412,24 +448,27 @@  discard block
 block discarded – undo
412 448
 		if (!in_array($row['field_type'], array('check', 'select', 'radio')))
413 449
 		{
414 450
 			// Is it too long?
415
-			if ($row['field_length'] && $row['field_length'] < $smcFunc['strlen']($value))
416
-				$custom_field_errors[] = array('custom_field_too_long', array($row['field_name'], $row['field_length']));
451
+			if ($row['field_length'] && $row['field_length'] < $smcFunc['strlen']($value)) {
452
+							$custom_field_errors[] = array('custom_field_too_long', array($row['field_name'], $row['field_length']));
453
+			}
417 454
 
418 455
 			// Any masks to apply?
419 456
 			if ($row['field_type'] == 'text' && !empty($row['mask']) && $row['mask'] != 'none')
420 457
 			{
421
-				if ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255))
422
-					$custom_field_errors[] = array('custom_field_invalid_email', array($row['field_name']));
423
-				elseif ($row['mask'] == 'number' && preg_match('~[^\d]~', $value))
424
-					$custom_field_errors[] = array('custom_field_not_number', array($row['field_name']));
425
-				elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0)
426
-					$custom_field_errors[] = array('custom_field_inproper_format', array($row['field_name']));
458
+				if ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) {
459
+									$custom_field_errors[] = array('custom_field_invalid_email', array($row['field_name']));
460
+				} elseif ($row['mask'] == 'number' && preg_match('~[^\d]~', $value)) {
461
+									$custom_field_errors[] = array('custom_field_not_number', array($row['field_name']));
462
+				} elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) {
463
+									$custom_field_errors[] = array('custom_field_inproper_format', array($row['field_name']));
464
+				}
427 465
 			}
428 466
 		}
429 467
 
430 468
 		// Is this required but not there?
431
-		if (trim($value) == '' && $row['show_reg'] > 1)
432
-			$custom_field_errors[] = array('custom_field_empty', array($row['field_name']));
469
+		if (trim($value) == '' && $row['show_reg'] > 1) {
470
+					$custom_field_errors[] = array('custom_field_empty', array($row['field_name']));
471
+		}
433 472
 	}
434 473
 	$smcFunc['db_free_result']($request);
435 474
 
@@ -437,8 +476,9 @@  discard block
 block discarded – undo
437 476
 	if (!empty($custom_field_errors))
438 477
 	{
439 478
 		loadLanguage('Errors');
440
-		foreach ($custom_field_errors as $error)
441
-			$reg_errors[] = vsprintf($txt['error_' . $error[0]], $error[1]);
479
+		foreach ($custom_field_errors as $error) {
480
+					$reg_errors[] = vsprintf($txt['error_' . $error[0]], $error[1]);
481
+		}
442 482
 	}
443 483
 
444 484
 	// Lets check for other errors before trying to register the member.
@@ -483,8 +523,9 @@  discard block
 block discarded – undo
483 523
 	}
484 524
 
485 525
 	// If COPPA has been selected then things get complicated, setup the template.
486
-	if (!empty($modSettings['coppaAge']) && empty($_SESSION['skip_coppa']))
487
-		redirectexit('action=coppa;member=' . $memberID);
526
+	if (!empty($modSettings['coppaAge']) && empty($_SESSION['skip_coppa'])) {
527
+			redirectexit('action=coppa;member=' . $memberID);
528
+	}
488 529
 	// Basic template variable setup.
489 530
 	elseif (!empty($modSettings['registration_method']))
490 531
 	{
@@ -496,8 +537,7 @@  discard block
 block discarded – undo
496 537
 			'sub_template' => 'after',
497 538
 			'description' => $modSettings['registration_method'] == 2 ? $txt['approval_after_registration'] : $txt['activate_after_registration']
498 539
 		);
499
-	}
500
-	else
540
+	} else
501 541
 	{
502 542
 		call_integration_hook('integrate_activate', array($regOptions['username']));
503 543
 
@@ -517,16 +557,18 @@  discard block
 block discarded – undo
517 557
 	global $context, $txt, $modSettings, $scripturl, $sourcedir, $smcFunc, $language, $user_info;
518 558
 
519 559
 	// Logged in users should not bother to activate their accounts
520
-	if (!empty($user_info['id']))
521
-		redirectexit();
560
+	if (!empty($user_info['id'])) {
561
+			redirectexit();
562
+	}
522 563
 
523 564
 	loadLanguage('Login');
524 565
 	loadTemplate('Login');
525 566
 
526 567
 	if (empty($_REQUEST['u']) && empty($_POST['user']))
527 568
 	{
528
-		if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == '3')
529
-			fatal_lang_error('no_access', false);
569
+		if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == '3') {
570
+					fatal_lang_error('no_access', false);
571
+		}
530 572
 
531 573
 		$context['member_id'] = 0;
532 574
 		$context['sub_template'] = 'resend';
@@ -566,11 +608,13 @@  discard block
 block discarded – undo
566 608
 	// Change their email address? (they probably tried a fake one first :P.)
567 609
 	if (isset($_POST['new_email'], $_REQUEST['passwd']) && hash_password($row['member_name'], $_REQUEST['passwd']) == $row['passwd'] && ($row['is_activated'] == 0 || $row['is_activated'] == 2))
568 610
 	{
569
-		if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == 3)
570
-			fatal_lang_error('no_access', false);
611
+		if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == 3) {
612
+					fatal_lang_error('no_access', false);
613
+		}
571 614
 
572
-		if (!filter_var($_POST['new_email'], FILTER_VALIDATE_EMAIL))
573
-			fatal_error(sprintf($txt['valid_email_needed'], $smcFunc['htmlspecialchars']($_POST['new_email'])), false);
615
+		if (!filter_var($_POST['new_email'], FILTER_VALIDATE_EMAIL)) {
616
+					fatal_error(sprintf($txt['valid_email_needed'], $smcFunc['htmlspecialchars']($_POST['new_email'])), false);
617
+		}
574 618
 
575 619
 		// Make sure their email isn't banned.
576 620
 		isBannedEmail($_POST['new_email'], 'cannot_register', $txt['ban_register_prohibited']);
@@ -586,8 +630,9 @@  discard block
 block discarded – undo
586 630
 			)
587 631
 		);
588 632
 
589
-		if ($smcFunc['db_num_rows']($request) != 0)
590
-			fatal_lang_error('email_in_use', false, array($smcFunc['htmlspecialchars']($_POST['new_email'])));
633
+		if ($smcFunc['db_num_rows']($request) != 0) {
634
+					fatal_lang_error('email_in_use', false, array($smcFunc['htmlspecialchars']($_POST['new_email'])));
635
+		}
591 636
 		$smcFunc['db_free_result']($request);
592 637
 
593 638
 		updateMemberData($row['id_member'], array('email_address' => $_POST['new_email']));
@@ -625,9 +670,9 @@  discard block
 block discarded – undo
625 670
 	// Quit if this code is not right.
626 671
 	if (empty($_REQUEST['code']) || $row['validation_code'] != $_REQUEST['code'])
627 672
 	{
628
-		if (!empty($row['is_activated']))
629
-			fatal_lang_error('already_activated', false);
630
-		elseif ($row['validation_code'] == '')
673
+		if (!empty($row['is_activated'])) {
674
+					fatal_lang_error('already_activated', false);
675
+		} elseif ($row['validation_code'] == '')
631 676
 		{
632 677
 			loadLanguage('Profile');
633 678
 			fatal_error(sprintf($txt['registration_not_approved'], $scripturl . '?action=activate;user=' . $row['member_name']), false);
@@ -677,8 +722,9 @@  discard block
 block discarded – undo
677 722
 	loadTemplate('Register');
678 723
 
679 724
 	// No User ID??
680
-	if (!isset($_GET['member']))
681
-		fatal_lang_error('no_access', false);
725
+	if (!isset($_GET['member'])) {
726
+			fatal_lang_error('no_access', false);
727
+	}
682 728
 
683 729
 	// Get the user details...
684 730
 	$request = $smcFunc['db_query']('', '
@@ -691,8 +737,9 @@  discard block
 block discarded – undo
691 737
 			'is_coppa' => 5,
692 738
 		)
693 739
 	);
694
-	if ($smcFunc['db_num_rows']($request) == 0)
695
-		fatal_lang_error('no_access', false);
740
+	if ($smcFunc['db_num_rows']($request) == 0) {
741
+			fatal_lang_error('no_access', false);
742
+	}
696 743
 	list ($username) = $smcFunc['db_fetch_row']($request);
697 744
 	$smcFunc['db_free_result']($request);
698 745
 
@@ -730,8 +777,7 @@  discard block
 block discarded – undo
730 777
 			echo $data;
731 778
 			obExit(false);
732 779
 		}
733
-	}
734
-	else
780
+	} else
735 781
 	{
736 782
 		$context += array(
737 783
 			'page_title' => $txt['coppa_title'],
@@ -784,8 +830,9 @@  discard block
 block discarded – undo
784 830
 	{
785 831
 		require_once($sourcedir . '/Subs-Graphics.php');
786 832
 
787
-		if (in_array('gd', get_loaded_extensions()) && !showCodeImage($code))
788
-			header('HTTP/1.1 400 Bad Request');
833
+		if (in_array('gd', get_loaded_extensions()) && !showCodeImage($code)) {
834
+					header('HTTP/1.1 400 Bad Request');
835
+		}
789 836
 
790 837
 		// Otherwise just show a pre-defined letter.
791 838
 		elseif (isset($_REQUEST['letter']))
@@ -803,14 +850,13 @@  discard block
 block discarded – undo
803 850
 			header('Content-Type: image/gif');
804 851
 			die("\x47\x49\x46\x38\x39\x61\x01\x00\x01\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x21\xF9\x04\x01\x00\x00\x00\x00\x2C\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02\x44\x01\x00\x3B");
805 852
 		}
806
-	}
807
-
808
-	elseif ($_REQUEST['format'] === '.wav')
853
+	} elseif ($_REQUEST['format'] === '.wav')
809 854
 	{
810 855
 		require_once($sourcedir . '/Subs-Sound.php');
811 856
 
812
-		if (!createWaveFile($code))
813
-			header('HTTP/1.1 400 Bad Request');
857
+		if (!createWaveFile($code)) {
858
+					header('HTTP/1.1 400 Bad Request');
859
+		}
814 860
 	}
815 861
 
816 862
 	// We all die one day...
Please login to merge, or discard this patch.
Sources/ManagePermissions.php 1 patch
Braces   +312 added lines, -223 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
  * Dispatches to the right function based on the given subaction.
@@ -176,8 +177,9 @@  discard block
 block discarded – undo
176 177
 		// If it's inherited, just add it as a child.
177 178
 		if ($row['id_parent'] != -2)
178 179
 		{
179
-			if (isset($context['groups'][$row['id_parent']]))
180
-				$context['groups'][$row['id_parent']]['children'][$row['id_group']] = $row['group_name'];
180
+			if (isset($context['groups'][$row['id_parent']])) {
181
+							$context['groups'][$row['id_parent']]['children'][$row['id_group']] = $row['group_name'];
182
+			}
181 183
 			continue;
182 184
 		}
183 185
 
@@ -202,10 +204,11 @@  discard block
 block discarded – undo
202 204
 			'access' => false,
203 205
 		);
204 206
 
205
-		if ($row['min_posts'] == -1)
206
-			$normalGroups[$row['id_group']] = $row['id_group'];
207
-		else
208
-			$postGroups[$row['id_group']] = $row['id_group'];
207
+		if ($row['min_posts'] == -1) {
208
+					$normalGroups[$row['id_group']] = $row['id_group'];
209
+		} else {
210
+					$postGroups[$row['id_group']] = $row['id_group'];
211
+		}
209 212
 	}
210 213
 	$smcFunc['db_free_result']($query);
211 214
 
@@ -221,8 +224,9 @@  discard block
 block discarded – undo
221 224
 				'post_group_list' => $postGroups,
222 225
 			)
223 226
 		);
224
-		while ($row = $smcFunc['db_fetch_assoc']($query))
225
-			$context['groups'][$row['id_group']]['num_members'] += $row['num_members'];
227
+		while ($row = $smcFunc['db_fetch_assoc']($query)) {
228
+					$context['groups'][$row['id_group']]['num_members'] += $row['num_members'];
229
+		}
226 230
 		$smcFunc['db_free_result']($query);
227 231
 	}
228 232
 
@@ -238,8 +242,9 @@  discard block
 block discarded – undo
238 242
 				'normal_group_list' => $normalGroups,
239 243
 			)
240 244
 		);
241
-		while ($row = $smcFunc['db_fetch_assoc']($query))
242
-			$context['groups'][$row['id_group']]['num_members'] += $row['num_members'];
245
+		while ($row = $smcFunc['db_fetch_assoc']($query)) {
246
+					$context['groups'][$row['id_group']]['num_members'] += $row['num_members'];
247
+		}
243 248
 		$smcFunc['db_free_result']($query);
244 249
 
245 250
 		// This one is slower, but it's okay... careful not to count twice!
@@ -256,15 +261,17 @@  discard block
 block discarded – undo
256 261
 				'blank_string' => '',
257 262
 			)
258 263
 		);
259
-		while ($row = $smcFunc['db_fetch_assoc']($query))
260
-			$context['groups'][$row['id_group']]['num_members'] += $row['num_members'];
264
+		while ($row = $smcFunc['db_fetch_assoc']($query)) {
265
+					$context['groups'][$row['id_group']]['num_members'] += $row['num_members'];
266
+		}
261 267
 		$smcFunc['db_free_result']($query);
262 268
 	}
263 269
 
264 270
 	foreach ($context['groups'] as $id => $data)
265 271
 	{
266
-		if ($data['href'] != '')
267
-			$context['groups'][$id]['link'] = '<a href="' . $data['href'] . '">' . $data['num_members'] . '</a>';
272
+		if ($data['href'] != '') {
273
+					$context['groups'][$id]['link'] = '<a href="' . $data['href'] . '">' . $data['num_members'] . '</a>';
274
+		}
268 275
 	}
269 276
 
270 277
 	if (empty($_REQUEST['pid']))
@@ -278,9 +285,10 @@  discard block
 block discarded – undo
278 285
 				'hidden_permissions' => !empty($context['hidden_permissions']) ? $context['hidden_permissions'] : array(),
279 286
 			)
280 287
 		);
281
-		while ($row = $smcFunc['db_fetch_assoc']($request))
282
-			if (isset($context['groups'][(int) $row['id_group']]) && (!empty($row['add_deny']) || $row['id_group'] != -1))
288
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
289
+					if (isset($context['groups'][(int) $row['id_group']]) && (!empty($row['add_deny']) || $row['id_group'] != -1))
283 290
 				$context['groups'][(int) $row['id_group']]['num_permissions'][empty($row['add_deny']) ? 'denied' : 'allowed'] = $row['num_permissions'];
291
+		}
284 292
 		$smcFunc['db_free_result']($request);
285 293
 
286 294
 		// Get the "default" profile permissions too.
@@ -297,17 +305,18 @@  discard block
 block discarded – undo
297 305
 		);
298 306
 		while ($row = $smcFunc['db_fetch_assoc']($request))
299 307
 		{
300
-			if (isset($context['groups'][(int) $row['id_group']]) && (!empty($row['add_deny']) || $row['id_group'] != -1))
301
-				$context['groups'][(int) $row['id_group']]['num_permissions'][empty($row['add_deny']) ? 'denied' : 'allowed'] += $row['num_permissions'];
308
+			if (isset($context['groups'][(int) $row['id_group']]) && (!empty($row['add_deny']) || $row['id_group'] != -1)) {
309
+							$context['groups'][(int) $row['id_group']]['num_permissions'][empty($row['add_deny']) ? 'denied' : 'allowed'] += $row['num_permissions'];
310
+			}
302 311
 		}
303 312
 		$smcFunc['db_free_result']($request);
304
-	}
305
-	else
313
+	} else
306 314
 	{
307 315
 		$_REQUEST['pid'] = (int) $_REQUEST['pid'];
308 316
 
309
-		if (!isset($context['profiles'][$_REQUEST['pid']]))
310
-			fatal_lang_error('no_access', false);
317
+		if (!isset($context['profiles'][$_REQUEST['pid']])) {
318
+					fatal_lang_error('no_access', false);
319
+		}
311 320
 
312 321
 		// Change the selected tab to better reflect that this really is a board profile.
313 322
 		$context[$context['admin_menu_name']]['current_subsection'] = 'profiles';
@@ -323,8 +332,9 @@  discard block
 block discarded – undo
323 332
 		);
324 333
 		while ($row = $smcFunc['db_fetch_assoc']($request))
325 334
 		{
326
-			if (isset($context['groups'][(int) $row['id_group']]) && (!empty($row['add_deny']) || $row['id_group'] != -1))
327
-				$context['groups'][(int) $row['id_group']]['num_permissions'][empty($row['add_deny']) ? 'denied' : 'allowed'] += $row['num_permissions'];
335
+			if (isset($context['groups'][(int) $row['id_group']]) && (!empty($row['add_deny']) || $row['id_group'] != -1)) {
336
+							$context['groups'][(int) $row['id_group']]['num_permissions'][empty($row['add_deny']) ? 'denied' : 'allowed'] += $row['num_permissions'];
337
+			}
328 338
 		}
329 339
 		$smcFunc['db_free_result']($request);
330 340
 
@@ -366,8 +376,8 @@  discard block
 block discarded – undo
366 376
 
367 377
 		if (!empty($changes))
368 378
 		{
369
-			foreach ($changes as $profile => $boards)
370
-				$smcFunc['db_query']('', '
379
+			foreach ($changes as $profile => $boards) {
380
+							$smcFunc['db_query']('', '
371 381
 					UPDATE {db_prefix}boards
372 382
 					SET id_profile = {int:current_profile}
373 383
 					WHERE id_board IN ({array_int:board_list})',
@@ -376,6 +386,7 @@  discard block
 block discarded – undo
376 386
 						'current_profile' => $profile,
377 387
 					)
378 388
 				);
389
+			}
379 390
 		}
380 391
 
381 392
 		$context['edit_all'] = false;
@@ -400,8 +411,9 @@  discard block
 block discarded – undo
400 411
 		);
401 412
 		foreach ($boardList[$catid] as $boardid)
402 413
 		{
403
-			if (!isset($context['profiles'][$boards[$boardid]['profile']]))
404
-				$boards[$boardid]['profile'] = 1;
414
+			if (!isset($context['profiles'][$boards[$boardid]['profile']])) {
415
+							$boards[$boardid]['profile'] = 1;
416
+			}
405 417
 
406 418
 			$context['categories'][$catid]['boards'][$boardid] = array(
407 419
 				'id' => &$boards[$boardid]['id'],
@@ -433,64 +445,74 @@  discard block
 block discarded – undo
433 445
 	loadIllegalGuestPermissions();
434 446
 
435 447
 	// Make sure only one of the quick options was selected.
436
-	if ((!empty($_POST['predefined']) && ((isset($_POST['copy_from']) && $_POST['copy_from'] != 'empty') || !empty($_POST['permissions']))) || (!empty($_POST['copy_from']) && $_POST['copy_from'] != 'empty' && !empty($_POST['permissions'])))
437
-		fatal_lang_error('permissions_only_one_option', false);
448
+	if ((!empty($_POST['predefined']) && ((isset($_POST['copy_from']) && $_POST['copy_from'] != 'empty') || !empty($_POST['permissions']))) || (!empty($_POST['copy_from']) && $_POST['copy_from'] != 'empty' && !empty($_POST['permissions']))) {
449
+			fatal_lang_error('permissions_only_one_option', false);
450
+	}
438 451
 
439
-	if (empty($_POST['group']) || !is_array($_POST['group']))
440
-		$_POST['group'] = array();
452
+	if (empty($_POST['group']) || !is_array($_POST['group'])) {
453
+			$_POST['group'] = array();
454
+	}
441 455
 
442 456
 	// Only accept numeric values for selected membergroups.
443
-	foreach ($_POST['group'] as $id => $group_id)
444
-		$_POST['group'][$id] = (int) $group_id;
457
+	foreach ($_POST['group'] as $id => $group_id) {
458
+			$_POST['group'][$id] = (int) $group_id;
459
+	}
445 460
 	$_POST['group'] = array_unique($_POST['group']);
446 461
 
447
-	if (empty($_REQUEST['pid']))
448
-		$_REQUEST['pid'] = 0;
449
-	else
450
-		$_REQUEST['pid'] = (int) $_REQUEST['pid'];
462
+	if (empty($_REQUEST['pid'])) {
463
+			$_REQUEST['pid'] = 0;
464
+	} else {
465
+			$_REQUEST['pid'] = (int) $_REQUEST['pid'];
466
+	}
451 467
 
452 468
 	// Fix up the old global to the new default!
453 469
 	$bid = max(1, $_REQUEST['pid']);
454 470
 
455 471
 	// No modifying the predefined profiles.
456
-	if ($_REQUEST['pid'] > 1 && $_REQUEST['pid'] < 5)
457
-		fatal_lang_error('no_access', false);
472
+	if ($_REQUEST['pid'] > 1 && $_REQUEST['pid'] < 5) {
473
+			fatal_lang_error('no_access', false);
474
+	}
458 475
 
459 476
 	// Clear out any cached authority.
460 477
 	updateSettings(array('settings_updated' => time()));
461 478
 
462 479
 	// No groups where selected.
463
-	if (empty($_POST['group']))
464
-		redirectexit('action=admin;area=permissions;pid=' . $_REQUEST['pid']);
480
+	if (empty($_POST['group'])) {
481
+			redirectexit('action=admin;area=permissions;pid=' . $_REQUEST['pid']);
482
+	}
465 483
 
466 484
 	// Set a predefined permission profile.
467 485
 	if (!empty($_POST['predefined']))
468 486
 	{
469 487
 		// Make sure it's a predefined permission set we expect.
470
-		if (!in_array($_POST['predefined'], array('restrict', 'standard', 'moderator', 'maintenance')))
471
-			redirectexit('action=admin;area=permissions;pid=' . $_REQUEST['pid']);
488
+		if (!in_array($_POST['predefined'], array('restrict', 'standard', 'moderator', 'maintenance'))) {
489
+					redirectexit('action=admin;area=permissions;pid=' . $_REQUEST['pid']);
490
+		}
472 491
 
473 492
 		foreach ($_POST['group'] as $group_id)
474 493
 		{
475
-			if (!empty($_REQUEST['pid']))
476
-				setPermissionLevel($_POST['predefined'], $group_id, $_REQUEST['pid']);
477
-			else
478
-				setPermissionLevel($_POST['predefined'], $group_id);
494
+			if (!empty($_REQUEST['pid'])) {
495
+							setPermissionLevel($_POST['predefined'], $group_id, $_REQUEST['pid']);
496
+			} else {
497
+							setPermissionLevel($_POST['predefined'], $group_id);
498
+			}
479 499
 		}
480 500
 	}
481 501
 	// Set a permission profile based on the permissions of a selected group.
482 502
 	elseif ($_POST['copy_from'] != 'empty')
483 503
 	{
484 504
 		// Just checking the input.
485
-		if (!is_numeric($_POST['copy_from']))
486
-			redirectexit('action=admin;area=permissions;pid=' . $_REQUEST['pid']);
505
+		if (!is_numeric($_POST['copy_from'])) {
506
+					redirectexit('action=admin;area=permissions;pid=' . $_REQUEST['pid']);
507
+		}
487 508
 
488 509
 		// Make sure the group we're copying to is never included.
489 510
 		$_POST['group'] = array_diff($_POST['group'], array($_POST['copy_from']));
490 511
 
491 512
 		// No groups left? Too bad.
492
-		if (empty($_POST['group']))
493
-			redirectexit('action=admin;area=permissions;pid=' . $_REQUEST['pid']);
513
+		if (empty($_POST['group'])) {
514
+					redirectexit('action=admin;area=permissions;pid=' . $_REQUEST['pid']);
515
+		}
494 516
 
495 517
 		if (empty($_REQUEST['pid']))
496 518
 		{
@@ -504,22 +526,26 @@  discard block
 block discarded – undo
504 526
 				)
505 527
 			);
506 528
 			$target_perm = array();
507
-			while ($row = $smcFunc['db_fetch_assoc']($request))
508
-				$target_perm[$row['permission']] = $row['add_deny'];
529
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
530
+							$target_perm[$row['permission']] = $row['add_deny'];
531
+			}
509 532
 			$smcFunc['db_free_result']($request);
510 533
 
511 534
 			$inserts = array();
512
-			foreach ($_POST['group'] as $group_id)
513
-				foreach ($target_perm as $perm => $add_deny)
535
+			foreach ($_POST['group'] as $group_id) {
536
+							foreach ($target_perm as $perm => $add_deny)
514 537
 				{
515 538
 					// No dodgy permissions please!
516 539
 					if (!empty($context['illegal_permissions']) && in_array($perm, $context['illegal_permissions']))
517 540
 						continue;
518
-					if ($group_id == -1 && in_array($perm, $context['non_guest_permissions']))
519
-						continue;
541
+			}
542
+					if ($group_id == -1 && in_array($perm, $context['non_guest_permissions'])) {
543
+											continue;
544
+					}
520 545
 
521
-					if ($group_id != 1 && $group_id != 3)
522
-						$inserts[] = array($perm, $group_id, $add_deny);
546
+					if ($group_id != 1 && $group_id != 3) {
547
+											$inserts[] = array($perm, $group_id, $add_deny);
548
+					}
523 549
 				}
524 550
 
525 551
 			// Delete the previous permissions...
@@ -559,17 +585,19 @@  discard block
 block discarded – undo
559 585
 			)
560 586
 		);
561 587
 		$target_perm = array();
562
-		while ($row = $smcFunc['db_fetch_assoc']($request))
563
-			$target_perm[$row['permission']] = $row['add_deny'];
588
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
589
+					$target_perm[$row['permission']] = $row['add_deny'];
590
+		}
564 591
 		$smcFunc['db_free_result']($request);
565 592
 
566 593
 		$inserts = array();
567
-		foreach ($_POST['group'] as $group_id)
568
-			foreach ($target_perm as $perm => $add_deny)
594
+		foreach ($_POST['group'] as $group_id) {
595
+					foreach ($target_perm as $perm => $add_deny)
569 596
 			{
570 597
 				// Are these for guests?
571 598
 				if ($group_id == -1 && in_array($perm, $context['non_guest_permissions']))
572 599
 					continue;
600
+		}
573 601
 
574 602
 				$inserts[] = array($perm, $group_id, $bid, $add_deny);
575 603
 			}
@@ -607,13 +635,14 @@  discard block
 block discarded – undo
607 635
 		list ($permissionType, $permission) = explode('/', $_POST['permissions']);
608 636
 
609 637
 		// Check whether our input is within expected range.
610
-		if (!in_array($_POST['add_remove'], array('add', 'clear', 'deny')) || !in_array($permissionType, array('membergroup', 'board')))
611
-			redirectexit('action=admin;area=permissions;pid=' . $_REQUEST['pid']);
638
+		if (!in_array($_POST['add_remove'], array('add', 'clear', 'deny')) || !in_array($permissionType, array('membergroup', 'board'))) {
639
+					redirectexit('action=admin;area=permissions;pid=' . $_REQUEST['pid']);
640
+		}
612 641
 
613 642
 		if ($_POST['add_remove'] == 'clear')
614 643
 		{
615
-			if ($permissionType == 'membergroup')
616
-				$smcFunc['db_query']('', '
644
+			if ($permissionType == 'membergroup') {
645
+							$smcFunc['db_query']('', '
617 646
 					DELETE FROM {db_prefix}permissions
618 647
 					WHERE id_group IN ({array_int:current_group_list})
619 648
 						AND permission = {string:current_permission}
@@ -624,8 +653,8 @@  discard block
 block discarded – undo
624 653
 						'illegal_permissions' => !empty($context['illegal_permissions']) ? $context['illegal_permissions'] : array(),
625 654
 					)
626 655
 				);
627
-			else
628
-				$smcFunc['db_query']('', '
656
+			} else {
657
+							$smcFunc['db_query']('', '
629 658
 					DELETE FROM {db_prefix}board_permissions
630 659
 					WHERE id_group IN ({array_int:current_group_list})
631 660
 						AND id_profile = {int:current_profile}
@@ -636,6 +665,7 @@  discard block
 block discarded – undo
636 665
 						'current_permission' => $permission,
637 666
 					)
638 667
 				);
668
+			}
639 669
 		}
640 670
 		// Add a permission (either 'set' or 'deny').
641 671
 		else
@@ -644,32 +674,36 @@  discard block
 block discarded – undo
644 674
 			$permChange = array();
645 675
 			foreach ($_POST['group'] as $groupID)
646 676
 			{
647
-				if ($groupID == -1 && in_array($permission, $context['non_guest_permissions']))
648
-					continue;
677
+				if ($groupID == -1 && in_array($permission, $context['non_guest_permissions'])) {
678
+									continue;
679
+				}
649 680
 
650
-				if ($permissionType == 'membergroup' && $groupID != 1 && $groupID != 3 && (empty($context['illegal_permissions']) || !in_array($permission, $context['illegal_permissions'])))
651
-					$permChange[] = array($permission, $groupID, $add_deny);
652
-				elseif ($permissionType != 'membergroup')
653
-					$permChange[] = array($permission, $groupID, $bid, $add_deny);
681
+				if ($permissionType == 'membergroup' && $groupID != 1 && $groupID != 3 && (empty($context['illegal_permissions']) || !in_array($permission, $context['illegal_permissions']))) {
682
+									$permChange[] = array($permission, $groupID, $add_deny);
683
+				} elseif ($permissionType != 'membergroup') {
684
+									$permChange[] = array($permission, $groupID, $bid, $add_deny);
685
+				}
654 686
 			}
655 687
 
656 688
 			if (!empty($permChange))
657 689
 			{
658
-				if ($permissionType == 'membergroup')
659
-					$smcFunc['db_insert']('replace',
690
+				if ($permissionType == 'membergroup') {
691
+									$smcFunc['db_insert']('replace',
660 692
 						'{db_prefix}permissions',
661 693
 						array('permission' => 'string', 'id_group' => 'int', 'add_deny' => 'int'),
662 694
 						$permChange,
663 695
 						array('permission', 'id_group')
664 696
 					);
697
+				}
665 698
 				// Board permissions go into the other table.
666
-				else
667
-					$smcFunc['db_insert']('replace',
699
+				else {
700
+									$smcFunc['db_insert']('replace',
668 701
 						'{db_prefix}board_permissions',
669 702
 						array('permission' => 'string', 'id_group' => 'int', 'id_profile' => 'int', 'add_deny' => 'int'),
670 703
 						$permChange,
671 704
 						array('permission', 'id_group', 'id_profile')
672 705
 					);
706
+				}
673 707
 			}
674 708
 		}
675 709
 
@@ -687,14 +721,16 @@  discard block
 block discarded – undo
687 721
 {
688 722
 	global $context, $txt, $smcFunc, $modSettings;
689 723
 
690
-	if (!isset($_GET['group']))
691
-		fatal_lang_error('no_access', false);
724
+	if (!isset($_GET['group'])) {
725
+			fatal_lang_error('no_access', false);
726
+	}
692 727
 
693 728
 	$context['group']['id'] = (int) $_GET['group'];
694 729
 
695 730
 	// It's not likely you'd end up here with this setting disabled.
696
-	if ($_GET['group'] == 1)
697
-		redirectexit('action=admin;area=permissions');
731
+	if ($_GET['group'] == 1) {
732
+			redirectexit('action=admin;area=permissions');
733
+	}
698 734
 
699 735
 	loadAllPermissions();
700 736
 	loadPermissionProfiles();
@@ -715,13 +751,14 @@  discard block
 block discarded – undo
715 751
 		$smcFunc['db_free_result']($result);
716 752
 
717 753
 		// Cannot edit an inherited group!
718
-		if ($parent != -2)
719
-			fatal_lang_error('cannot_edit_permissions_inherited');
754
+		if ($parent != -2) {
755
+					fatal_lang_error('cannot_edit_permissions_inherited');
756
+		}
757
+	} elseif ($context['group']['id'] == -1) {
758
+			$context['group']['name'] = $txt['membergroups_guests'];
759
+	} else {
760
+			$context['group']['name'] = $txt['membergroups_members'];
720 761
 	}
721
-	elseif ($context['group']['id'] == -1)
722
-		$context['group']['name'] = $txt['membergroups_guests'];
723
-	else
724
-		$context['group']['name'] = $txt['membergroups_members'];
725 762
 
726 763
 	$context['profile']['id'] = empty($_GET['pid']) ? 0 : (int) $_GET['pid'];
727 764
 
@@ -767,8 +804,9 @@  discard block
 block discarded – undo
767 804
 				'current_group' => $_GET['group'],
768 805
 			)
769 806
 		);
770
-		while ($row = $smcFunc['db_fetch_assoc']($result))
771
-			$permissions['membergroup'][empty($row['add_deny']) ? 'denied' : 'allowed'][] = $row['permission'];
807
+		while ($row = $smcFunc['db_fetch_assoc']($result)) {
808
+					$permissions['membergroup'][empty($row['add_deny']) ? 'denied' : 'allowed'][] = $row['permission'];
809
+		}
772 810
 		$smcFunc['db_free_result']($result);
773 811
 	}
774 812
 
@@ -783,8 +821,9 @@  discard block
 block discarded – undo
783 821
 			'current_profile' => $context['permission_type'] == 'membergroup' ? 1 : $context['profile']['id'],
784 822
 		)
785 823
 	);
786
-	while ($row = $smcFunc['db_fetch_assoc']($result))
787
-		$permissions['board'][empty($row['add_deny']) ? 'denied' : 'allowed'][] = $row['permission'];
824
+	while ($row = $smcFunc['db_fetch_assoc']($result)) {
825
+			$permissions['board'][empty($row['add_deny']) ? 'denied' : 'allowed'][] = $row['permission'];
826
+	}
788 827
 	$smcFunc['db_free_result']($result);
789 828
 
790 829
 	// Loop through each permission and set whether it's checked.
@@ -803,9 +842,9 @@  discard block
 block discarded – undo
803 842
 					{
804 843
 						$curPerm['any']['select'] = in_array($perm['id'] . '_any', $permissions[$permissionType]['allowed']) ? 'on' : (in_array($perm['id'] . '_any', $permissions[$permissionType]['denied']) ? 'deny' : 'off');
805 844
 						$curPerm['own']['select'] = in_array($perm['id'] . '_own', $permissions[$permissionType]['allowed']) ? 'on' : (in_array($perm['id'] . '_own', $permissions[$permissionType]['denied']) ? 'deny' : 'off');
845
+					} else {
846
+											$curPerm['select'] = in_array($perm['id'], $permissions[$permissionType]['denied']) ? 'deny' : (in_array($perm['id'], $permissions[$permissionType]['allowed']) ? 'on' : 'off');
806 847
 					}
807
-					else
808
-						$curPerm['select'] = in_array($perm['id'], $permissions[$permissionType]['denied']) ? 'deny' : (in_array($perm['id'], $permissions[$permissionType]['allowed']) ? 'on' : 'off');
809 848
 
810 849
 						// Keep the last value if it's hidden.
811 850
 						if ($perm['hidden'] || $permissionArray['hidden'])
@@ -822,13 +861,13 @@  discard block
 block discarded – undo
822 861
 									$perm['any']['id'],
823 862
 									$curPerm['any']['select'] == 'deny' && !empty($modSettings['permission_enable_deny']) ? 'deny' : $curPerm['any']['select'],
824 863
 								);
825
-							}
826
-							else
827
-								$context['hidden_perms'][] = array(
864
+							} else {
865
+															$context['hidden_perms'][] = array(
828 866
 									$permissionType,
829 867
 									$perm['id'],
830 868
 									$curPerm['select'] == 'deny' && !empty($modSettings['permission_enable_deny']) ? 'deny' : $curPerm['select'],
831 869
 								);
870
+							}
832 871
 						}
833 872
 				}
834 873
 			}
@@ -856,13 +895,14 @@  discard block
 block discarded – undo
856 895
 	$_GET['pid'] = (int) $_GET['pid'];
857 896
 
858 897
 	// Cannot modify predefined profiles.
859
-	if ($_GET['pid'] > 1 && $_GET['pid'] < 5)
860
-		fatal_lang_error('no_access', false);
898
+	if ($_GET['pid'] > 1 && $_GET['pid'] < 5) {
899
+			fatal_lang_error('no_access', false);
900
+	}
861 901
 
862 902
 	// Verify this isn't inherited.
863
-	if ($_GET['group'] == -1 || $_GET['group'] == 0)
864
-		$parent = -2;
865
-	else
903
+	if ($_GET['group'] == -1 || $_GET['group'] == 0) {
904
+			$parent = -2;
905
+	} else
866 906
 	{
867 907
 		$result = $smcFunc['db_query']('', '
868 908
 			SELECT id_parent
@@ -877,8 +917,9 @@  discard block
 block discarded – undo
877 917
 		$smcFunc['db_free_result']($result);
878 918
 	}
879 919
 
880
-	if ($parent != -2)
881
-		fatal_lang_error('cannot_edit_permissions_inherited');
920
+	if ($parent != -2) {
921
+			fatal_lang_error('cannot_edit_permissions_inherited');
922
+	}
882 923
 
883 924
 	$givePerms = array('membergroup' => array(), 'board' => array());
884 925
 
@@ -896,12 +937,13 @@  discard block
 block discarded – undo
896 937
 		{
897 938
 			if (is_array($perm_array))
898 939
 			{
899
-				foreach ($perm_array as $permission => $value)
900
-					if ($value == 'on' || $value == 'deny')
940
+				foreach ($perm_array as $permission => $value) {
941
+									if ($value == 'on' || $value == 'deny')
901 942
 					{
902 943
 						// Don't allow people to escalate themselves!
903 944
 						if (!empty($context['illegal_permissions']) && in_array($permission, $context['illegal_permissions']))
904 945
 							continue;
946
+				}
905 947
 
906 948
 						$givePerms[$perm_type][] = array($_GET['group'], $permission, $value == 'deny' ? 0 : 1);
907 949
 					}
@@ -946,8 +988,9 @@  discard block
 block discarded – undo
946 988
 	);
947 989
 	if (!empty($givePerms['board']))
948 990
 	{
949
-		foreach ($givePerms['board'] as $k => $v)
950
-			$givePerms['board'][$k][] = $profileid;
991
+		foreach ($givePerms['board'] as $k => $v) {
992
+					$givePerms['board'][$k][] = $profileid;
993
+		}
951 994
 		$smcFunc['db_insert']('replace',
952 995
 			'{db_prefix}board_permissions',
953 996
 			array('id_group' => 'int', 'permission' => 'string', 'add_deny' => 'int', 'id_profile' => 'int'),
@@ -988,8 +1031,9 @@  discard block
 block discarded – undo
988 1031
 
989 1032
 	call_integration_hook('integrate_modify_permission_settings', array(&$config_vars));
990 1033
 
991
-	if ($return_config)
992
-		return $config_vars;
1034
+	if ($return_config) {
1035
+			return $config_vars;
1036
+	}
993 1037
 
994 1038
 	$context['page_title'] = $txt['permission_settings_title'];
995 1039
 	$context['sub_template'] = 'show_settings';
@@ -1040,8 +1084,9 @@  discard block
 block discarded – undo
1040 1084
 					'min_posts' => -1,
1041 1085
 				)
1042 1086
 			);
1043
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1044
-				$post_groups[] = $row['id_group'];
1087
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
1088
+							$post_groups[] = $row['id_group'];
1089
+			}
1045 1090
 			$smcFunc['db_free_result']($request);
1046 1091
 
1047 1092
 			// Remove'em.
@@ -1250,16 +1295,19 @@  discard block
 block discarded – undo
1250 1295
 	// Make sure we're not granting someone too many permissions!
1251 1296
 	foreach ($groupLevels['global'][$level] as $k => $permission)
1252 1297
 	{
1253
-		if (!empty($context['illegal_permissions']) && in_array($permission, $context['illegal_permissions']))
1254
-			unset($groupLevels['global'][$level][$k]);
1298
+		if (!empty($context['illegal_permissions']) && in_array($permission, $context['illegal_permissions'])) {
1299
+					unset($groupLevels['global'][$level][$k]);
1300
+		}
1255 1301
 
1256
-		if ($group == -1 && in_array($permission, $context['non_guest_permissions']))
1257
-			unset($groupLevels['global'][$level][$k]);
1302
+		if ($group == -1 && in_array($permission, $context['non_guest_permissions'])) {
1303
+					unset($groupLevels['global'][$level][$k]);
1304
+		}
1258 1305
 	}
1259
-	if ($group == -1)
1260
-		foreach ($groupLevels['board'][$level] as $k => $permission)
1306
+	if ($group == -1) {
1307
+			foreach ($groupLevels['board'][$level] as $k => $permission)
1261 1308
 			if (in_array($permission, $context['non_guest_permissions']))
1262 1309
 				unset($groupLevels['board'][$level][$k]);
1310
+	}
1263 1311
 
1264 1312
 	// Reset all cached permissions.
1265 1313
 	updateSettings(array('settings_updated' => time()));
@@ -1269,8 +1317,9 @@  discard block
 block discarded – undo
1269 1317
 	{
1270 1318
 		$group = (int) $group;
1271 1319
 
1272
-		if (empty($groupLevels['global'][$level]))
1273
-			return;
1320
+		if (empty($groupLevels['global'][$level])) {
1321
+					return;
1322
+		}
1274 1323
 
1275 1324
 		$smcFunc['db_query']('', '
1276 1325
 			DELETE FROM {db_prefix}permissions
@@ -1292,8 +1341,9 @@  discard block
 block discarded – undo
1292 1341
 		);
1293 1342
 
1294 1343
 		$groupInserts = array();
1295
-		foreach ($groupLevels['global'][$level] as $permission)
1296
-			$groupInserts[] = array($group, $permission);
1344
+		foreach ($groupLevels['global'][$level] as $permission) {
1345
+					$groupInserts[] = array($group, $permission);
1346
+		}
1297 1347
 
1298 1348
 		$smcFunc['db_insert']('insert',
1299 1349
 			'{db_prefix}permissions',
@@ -1303,8 +1353,9 @@  discard block
 block discarded – undo
1303 1353
 		);
1304 1354
 
1305 1355
 		$boardInserts = array();
1306
-		foreach ($groupLevels['board'][$level] as $permission)
1307
-			$boardInserts[] = array(1, $group, $permission);
1356
+		foreach ($groupLevels['board'][$level] as $permission) {
1357
+					$boardInserts[] = array(1, $group, $permission);
1358
+		}
1308 1359
 
1309 1360
 		$smcFunc['db_insert']('insert',
1310 1361
 			'{db_prefix}board_permissions',
@@ -1335,8 +1386,9 @@  discard block
 block discarded – undo
1335 1386
 		if (!empty($groupLevels['board'][$level]))
1336 1387
 		{
1337 1388
 			$boardInserts = array();
1338
-			foreach ($groupLevels['board'][$level] as $permission)
1339
-				$boardInserts[] = array($profile, $group, $permission);
1389
+			foreach ($groupLevels['board'][$level] as $permission) {
1390
+							$boardInserts[] = array($profile, $group, $permission);
1391
+			}
1340 1392
 
1341 1393
 			$smcFunc['db_insert']('insert',
1342 1394
 				'{db_prefix}board_permissions',
@@ -1359,8 +1411,9 @@  discard block
 block discarded – undo
1359 1411
 			)
1360 1412
 		);
1361 1413
 
1362
-		if (empty($boardLevels[$level]))
1363
-			return;
1414
+		if (empty($boardLevels[$level])) {
1415
+					return;
1416
+		}
1364 1417
 
1365 1418
 		// Get all the groups...
1366 1419
 		$query = $smcFunc['db_query']('', '
@@ -1378,8 +1431,9 @@  discard block
 block discarded – undo
1378 1431
 			$group = $row[0];
1379 1432
 
1380 1433
 			$boardInserts = array();
1381
-			foreach ($boardLevels[$level] as $permission)
1382
-				$boardInserts[] = array($profile, $group, $permission);
1434
+			foreach ($boardLevels[$level] as $permission) {
1435
+							$boardInserts[] = array($profile, $group, $permission);
1436
+			}
1383 1437
 
1384 1438
 			$smcFunc['db_insert']('insert',
1385 1439
 				'{db_prefix}board_permissions',
@@ -1392,8 +1446,9 @@  discard block
 block discarded – undo
1392 1446
 
1393 1447
 		// Add permissions for ungrouped members.
1394 1448
 		$boardInserts = array();
1395
-		foreach ($boardLevels[$level] as $permission)
1396
-			$boardInserts[] = array($profile, 0, $permission);
1449
+		foreach ($boardLevels[$level] as $permission) {
1450
+					$boardInserts[] = array($profile, 0, $permission);
1451
+		}
1397 1452
 
1398 1453
 		$smcFunc['db_insert']('insert',
1399 1454
 				'{db_prefix}board_permissions',
@@ -1403,9 +1458,10 @@  discard block
 block discarded – undo
1403 1458
 			);
1404 1459
 	}
1405 1460
 	// $profile and $group are both null!
1406
-	else
1407
-		fatal_lang_error('no_access', false);
1408
-}
1461
+	else {
1462
+			fatal_lang_error('no_access', false);
1463
+	}
1464
+	}
1409 1465
 
1410 1466
 /**
1411 1467
  * Load permissions into $context['permissions'].
@@ -1607,15 +1663,17 @@  discard block
 block discarded – undo
1607 1663
 		foreach ($permissionList as $permission => $permissionArray)
1608 1664
 		{
1609 1665
 			// If this is a guest permission we don't do it if it's the guest group.
1610
-			if (isset($context['group']['id']) && $context['group']['id'] == -1 && in_array($permission, $context['non_guest_permissions']))
1611
-				continue;
1666
+			if (isset($context['group']['id']) && $context['group']['id'] == -1 && in_array($permission, $context['non_guest_permissions'])) {
1667
+							continue;
1668
+			}
1612 1669
 
1613 1670
 			// What groups will this permission be in?
1614 1671
 			$own_group = $permissionArray[1];
1615 1672
 
1616 1673
 			// First, Do these groups actually exist - if not add them.
1617
-			if (!isset($permissionGroups[$permissionType][$own_group]))
1618
-				$permissionGroups[$permissionType][$own_group] = true;
1674
+			if (!isset($permissionGroups[$permissionType][$own_group])) {
1675
+							$permissionGroups[$permissionType][$own_group] = true;
1676
+			}
1619 1677
 
1620 1678
 			// What column should this be located into?
1621 1679
 			$position = !in_array($own_group, $leftPermissionGroups) ? 1 : 0;
@@ -1623,8 +1681,8 @@  discard block
 block discarded – undo
1623 1681
 			// If the groups have not yet been created be sure to create them.
1624 1682
 			$bothGroups = array('own' => $own_group);
1625 1683
 
1626
-			foreach ($bothGroups as $group)
1627
-				if (!isset($context['permissions'][$permissionType]['columns'][$position][$group]))
1684
+			foreach ($bothGroups as $group) {
1685
+							if (!isset($context['permissions'][$permissionType]['columns'][$position][$group]))
1628 1686
 					$context['permissions'][$permissionType]['columns'][$position][$group] = array(
1629 1687
 						'type' => $permissionType,
1630 1688
 						'id' => $group,
@@ -1634,6 +1692,7 @@  discard block
 block discarded – undo
1634 1692
 						'hidden' => false,
1635 1693
 						'permissions' => array()
1636 1694
 					);
1695
+			}
1637 1696
 
1638 1697
 			$context['permissions'][$permissionType]['columns'][$position][$own_group]['permissions'][$permission] = array(
1639 1698
 				'id' => $permission,
@@ -1658,27 +1717,30 @@  discard block
 block discarded – undo
1658 1717
 				{
1659 1718
 					$context['hidden_permissions'][] = $permission . '_own';
1660 1719
 					$context['hidden_permissions'][] = $permission . '_any';
1720
+				} else {
1721
+									$context['hidden_permissions'][] = $permission;
1661 1722
 				}
1662
-				else
1663
-					$context['hidden_permissions'][] = $permission;
1664 1723
 			}
1665 1724
 		}
1666 1725
 		ksort($context['permissions'][$permissionType]['columns']);
1667 1726
 
1668 1727
 		// Check we don't leave any empty groups - and mark hidden ones as such.
1669
-		foreach ($context['permissions'][$permissionType]['columns'] as $column => $groups)
1670
-			foreach ($groups as $id => $group)
1728
+		foreach ($context['permissions'][$permissionType]['columns'] as $column => $groups) {
1729
+					foreach ($groups as $id => $group)
1671 1730
 			{
1672 1731
 				if (empty($group['permissions']))
1673 1732
 					unset($context['permissions'][$permissionType]['columns'][$column][$id]);
1733
+		}
1674 1734
 				else
1675 1735
 				{
1676 1736
 					$foundNonHidden = false;
1677
-					foreach ($group['permissions'] as $permission)
1678
-						if (empty($permission['hidden']))
1737
+					foreach ($group['permissions'] as $permission) {
1738
+											if (empty($permission['hidden']))
1679 1739
 							$foundNonHidden = true;
1680
-					if (!$foundNonHidden)
1681
-						$context['permissions'][$permissionType]['columns'][$column][$id]['hidden'] = true;
1740
+					}
1741
+					if (!$foundNonHidden) {
1742
+											$context['permissions'][$permissionType]['columns'][$column][$id]['hidden'] = true;
1743
+					}
1682 1744
 				}
1683 1745
 			}
1684 1746
 	}
@@ -1705,12 +1767,13 @@  discard block
 block discarded – undo
1705 1767
 	$context['can_change_permissions'] = allowedTo('manage_permissions');
1706 1768
 
1707 1769
 	// Nothing to initialize here.
1708
-	if (!$context['can_change_permissions'])
1709
-		return;
1770
+	if (!$context['can_change_permissions']) {
1771
+			return;
1772
+	}
1710 1773
 
1711 1774
 	// Load the permission settings for guests
1712
-	foreach ($permissions as $permission)
1713
-		$context[$permission] = array(
1775
+	foreach ($permissions as $permission) {
1776
+			$context[$permission] = array(
1714 1777
 			-1 => array(
1715 1778
 				'id' => -1,
1716 1779
 				'name' => $txt['membergroups_guests'],
@@ -1724,6 +1787,7 @@  discard block
 block discarded – undo
1724 1787
 				'status' => 'off',
1725 1788
 			),
1726 1789
 		);
1790
+	}
1727 1791
 
1728 1792
 	$request = $smcFunc['db_query']('', '
1729 1793
 		SELECT id_group, CASE WHEN add_deny = {int:denied} THEN {string:deny} ELSE {string:on} END AS status, permission
@@ -1737,8 +1801,9 @@  discard block
 block discarded – undo
1737 1801
 			'on' => 'on',
1738 1802
 		)
1739 1803
 	);
1740
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1741
-		$context[$row['permission']][$row['id_group']]['status'] = $row['status'];
1804
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1805
+			$context[$row['permission']][$row['id_group']]['status'] = $row['status'];
1806
+	}
1742 1807
 	$smcFunc['db_free_result']($request);
1743 1808
 
1744 1809
 	$request = $smcFunc['db_query']('', '
@@ -1759,14 +1824,15 @@  discard block
 block discarded – undo
1759 1824
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1760 1825
 	{
1761 1826
 		// Initialize each permission as being 'off' until proven otherwise.
1762
-		foreach ($permissions as $permission)
1763
-			if (!isset($context[$permission][$row['id_group']]))
1827
+		foreach ($permissions as $permission) {
1828
+					if (!isset($context[$permission][$row['id_group']]))
1764 1829
 				$context[$permission][$row['id_group']] = array(
1765 1830
 					'id' => $row['id_group'],
1766 1831
 					'name' => $row['group_name'],
1767 1832
 					'is_postgroup' => $row['min_posts'] != -1,
1768 1833
 					'status' => 'off',
1769 1834
 				);
1835
+		}
1770 1836
 
1771 1837
 		$context[$row['permission']][$row['id_group']]['status'] = empty($row['status']) ? 'deny' : ($row['status'] == 1 ? 'on' : 'off');
1772 1838
 	}
@@ -1780,8 +1846,9 @@  discard block
 block discarded – undo
1780 1846
 	{
1781 1847
 		foreach ($permissions as $permission)
1782 1848
 		{
1783
-			if (isset($context[$permission][$group]))
1784
-				unset($context[$permission][$group]);
1849
+			if (isset($context[$permission][$group])) {
1850
+							unset($context[$permission][$group]);
1851
+			}
1785 1852
 		}
1786 1853
 	}
1787 1854
 
@@ -1789,8 +1856,9 @@  discard block
 block discarded – undo
1789 1856
 	$non_guest_perms = array_intersect(str_replace(array('_any', '_own'), '', $permissions), $context['non_guest_permissions']);
1790 1857
 	foreach ($non_guest_perms as $permission)
1791 1858
 	{
1792
-		if (isset($context[$permission][-1]))
1793
-			unset($context[$permission][-1]);
1859
+		if (isset($context[$permission][-1])) {
1860
+					unset($context[$permission][-1]);
1861
+		}
1794 1862
 	}
1795 1863
 
1796 1864
 	// Create the token for the separate inline permission verification.
@@ -1825,8 +1893,9 @@  discard block
 block discarded – undo
1825 1893
 	global $context, $smcFunc;
1826 1894
 
1827 1895
 	// No permissions? Not a great deal to do here.
1828
-	if (!allowedTo('manage_permissions'))
1829
-		return;
1896
+	if (!allowedTo('manage_permissions')) {
1897
+			return;
1898
+	}
1830 1899
 
1831 1900
 	// Almighty session check, verify our ways.
1832 1901
 	checkSession();
@@ -1838,13 +1907,15 @@  discard block
 block discarded – undo
1838 1907
 	$insertRows = array();
1839 1908
 	foreach ($permissions as $permission)
1840 1909
 	{
1841
-		if (!isset($_POST[$permission]))
1842
-			continue;
1910
+		if (!isset($_POST[$permission])) {
1911
+					continue;
1912
+		}
1843 1913
 
1844 1914
 		foreach ($_POST[$permission] as $id_group => $value)
1845 1915
 		{
1846
-			if (in_array($value, array('on', 'deny')) && (empty($context['illegal_permissions']) || !in_array($permission, $context['illegal_permissions'])))
1847
-				$insertRows[] = array((int) $id_group, $permission, $value == 'on' ? 1 : 0);
1916
+			if (in_array($value, array('on', 'deny')) && (empty($context['illegal_permissions']) || !in_array($permission, $context['illegal_permissions']))) {
1917
+							$insertRows[] = array((int) $id_group, $permission, $value == 'on' ? 1 : 0);
1918
+			}
1848 1919
 		}
1849 1920
 	}
1850 1921
 
@@ -1860,13 +1931,14 @@  discard block
 block discarded – undo
1860 1931
 	);
1861 1932
 
1862 1933
 	// ...and replace them with new ones.
1863
-	if (!empty($insertRows))
1864
-		$smcFunc['db_insert']('insert',
1934
+	if (!empty($insertRows)) {
1935
+			$smcFunc['db_insert']('insert',
1865 1936
 			'{db_prefix}permissions',
1866 1937
 			array('id_group' => 'int', 'permission' => 'string', 'add_deny' => 'int'),
1867 1938
 			$insertRows,
1868 1939
 			array('id_group', 'permission')
1869 1940
 		);
1941
+	}
1870 1942
 
1871 1943
 	// Do a full child update.
1872 1944
 	updateChildPermissions(array(), -1);
@@ -1893,10 +1965,11 @@  discard block
 block discarded – undo
1893 1965
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1894 1966
 	{
1895 1967
 		// Format the label nicely.
1896
-		if (isset($txt['permissions_profile_' . $row['profile_name']]))
1897
-			$name = $txt['permissions_profile_' . $row['profile_name']];
1898
-		else
1899
-			$name = $row['profile_name'];
1968
+		if (isset($txt['permissions_profile_' . $row['profile_name']])) {
1969
+					$name = $txt['permissions_profile_' . $row['profile_name']];
1970
+		} else {
1971
+					$name = $row['profile_name'];
1972
+		}
1900 1973
 
1901 1974
 		$context['profiles'][$row['id_profile']] = array(
1902 1975
 			'id' => $row['id_profile'],
@@ -1951,17 +2024,19 @@  discard block
 block discarded – undo
1951 2024
 			)
1952 2025
 		);
1953 2026
 		$inserts = array();
1954
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1955
-			$inserts[] = array($profile_id, $row['id_group'], $row['permission'], $row['add_deny']);
2027
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
2028
+					$inserts[] = array($profile_id, $row['id_group'], $row['permission'], $row['add_deny']);
2029
+		}
1956 2030
 		$smcFunc['db_free_result']($request);
1957 2031
 
1958
-		if (!empty($inserts))
1959
-			$smcFunc['db_insert']('insert',
2032
+		if (!empty($inserts)) {
2033
+					$smcFunc['db_insert']('insert',
1960 2034
 				'{db_prefix}board_permissions',
1961 2035
 				array('id_profile' => 'int', 'id_group' => 'int', 'permission' => 'string', 'add_deny' => 'int'),
1962 2036
 				$inserts,
1963 2037
 				array('id_profile', 'id_group', 'permission')
1964 2038
 			);
2039
+		}
1965 2040
 	}
1966 2041
 	// Renaming?
1967 2042
 	elseif (isset($_POST['rename']))
@@ -1970,16 +2045,16 @@  discard block
 block discarded – undo
1970 2045
 		validateToken('admin-mpp');
1971 2046
 
1972 2047
 		// Just showing the boxes?
1973
-		if (!isset($_POST['rename_profile']))
1974
-			$context['show_rename_boxes'] = true;
1975
-		else
2048
+		if (!isset($_POST['rename_profile'])) {
2049
+					$context['show_rename_boxes'] = true;
2050
+		} else
1976 2051
 		{
1977 2052
 			foreach ($_POST['rename_profile'] as $id => $value)
1978 2053
 			{
1979 2054
 				$value = $smcFunc['htmlspecialchars']($value);
1980 2055
 
1981
-				if (trim($value) != '' && $id > 4)
1982
-					$smcFunc['db_query']('', '
2056
+				if (trim($value) != '' && $id > 4) {
2057
+									$smcFunc['db_query']('', '
1983 2058
 						UPDATE {db_prefix}permission_profiles
1984 2059
 						SET profile_name = {string:profile_name}
1985 2060
 						WHERE id_profile = {int:current_profile}',
@@ -1988,6 +2063,7 @@  discard block
 block discarded – undo
1988 2063
 							'profile_name' => $value,
1989 2064
 						)
1990 2065
 					);
2066
+				}
1991 2067
 			}
1992 2068
 		}
1993 2069
 	}
@@ -1998,9 +2074,10 @@  discard block
 block discarded – undo
1998 2074
 		validateToken('admin-mpp');
1999 2075
 
2000 2076
 		$profiles = array();
2001
-		foreach ($_POST['delete_profile'] as $profile)
2002
-			if ($profile > 4)
2077
+		foreach ($_POST['delete_profile'] as $profile) {
2078
+					if ($profile > 4)
2003 2079
 				$profiles[] = (int) $profile;
2080
+		}
2004 2081
 
2005 2082
 		// Verify it's not in use...
2006 2083
 		$request = $smcFunc['db_query']('', '
@@ -2012,8 +2089,9 @@  discard block
 block discarded – undo
2012 2089
 				'profile_list' => $profiles,
2013 2090
 			)
2014 2091
 		);
2015
-		if ($smcFunc['db_num_rows']($request) != 0)
2016
-			fatal_lang_error('no_access', false);
2092
+		if ($smcFunc['db_num_rows']($request) != 0) {
2093
+					fatal_lang_error('no_access', false);
2094
+		}
2017 2095
 		$smcFunc['db_free_result']($request);
2018 2096
 
2019 2097
 		// Oh well, delete.
@@ -2037,10 +2115,11 @@  discard block
 block discarded – undo
2037 2115
 		array(
2038 2116
 		)
2039 2117
 	);
2040
-	while ($row = $smcFunc['db_fetch_assoc']($request))
2041
-		if (isset($context['profiles'][$row['id_profile']]))
2118
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
2119
+			if (isset($context['profiles'][$row['id_profile']]))
2042 2120
 		{
2043 2121
 			$context['profiles'][$row['id_profile']]['in_use'] = true;
2122
+	}
2044 2123
 			$context['profiles'][$row['id_profile']]['boards'] = $row['board_count'];
2045 2124
 			$context['profiles'][$row['id_profile']]['boards_text'] = $row['board_count'] > 1 ? sprintf($txt['permissions_profile_used_by_many'], $row['board_count']) : $txt['permissions_profile_used_by_' . ($row['board_count'] ? 'one' : 'none')];
2046 2125
 		}
@@ -2052,8 +2131,9 @@  discard block
 block discarded – undo
2052 2131
 	{
2053 2132
 		// Can't delete special ones.
2054 2133
 		$context['profiles'][$id]['can_edit'] = isset($txt['permissions_profile_' . $profile['unformatted_name']]) ? false : true;
2055
-		if ($context['profiles'][$id]['can_edit'])
2056
-			$context['can_edit_something'] = true;
2134
+		if ($context['profiles'][$id]['can_edit']) {
2135
+					$context['can_edit_something'] = true;
2136
+		}
2057 2137
 
2058 2138
 		// You can only delete it if you can edit it AND it's not in use.
2059 2139
 		$context['profiles'][$id]['can_delete'] = $context['profiles'][$id]['can_edit'] && empty($profile['in_use']) ? true : false;
@@ -2074,8 +2154,9 @@  discard block
 block discarded – undo
2074 2154
 	global $smcFunc;
2075 2155
 
2076 2156
 	// All the parent groups to sort out.
2077
-	if (!is_array($parents))
2078
-		$parents = array($parents);
2157
+	if (!is_array($parents)) {
2158
+			$parents = array($parents);
2159
+	}
2079 2160
 
2080 2161
 	// Find all the children of this group.
2081 2162
 	$request = $smcFunc['db_query']('', '
@@ -2102,8 +2183,9 @@  discard block
 block discarded – undo
2102 2183
 	$parents = array_unique($parents);
2103 2184
 
2104 2185
 	// Not a sausage, or a child?
2105
-	if (empty($children))
2106
-		return false;
2186
+	if (empty($children)) {
2187
+			return false;
2188
+	}
2107 2189
 
2108 2190
 	// First off, are we doing general permissions?
2109 2191
 	if ($profile < 1 || $profile === null)
@@ -2118,9 +2200,10 @@  discard block
 block discarded – undo
2118 2200
 			)
2119 2201
 		);
2120 2202
 		$permissions = array();
2121
-		while ($row = $smcFunc['db_fetch_assoc']($request))
2122
-			foreach ($children[$row['id_group']] as $child)
2203
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
2204
+					foreach ($children[$row['id_group']] as $child)
2123 2205
 				$permissions[] = array($child, $row['permission'], $row['add_deny']);
2206
+		}
2124 2207
 		$smcFunc['db_free_result']($request);
2125 2208
 
2126 2209
 		$smcFunc['db_query']('', '
@@ -2160,9 +2243,10 @@  discard block
 block discarded – undo
2160 2243
 			)
2161 2244
 		);
2162 2245
 		$permissions = array();
2163
-		while ($row = $smcFunc['db_fetch_assoc']($request))
2164
-			foreach ($children[$row['id_group']] as $child)
2246
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
2247
+					foreach ($children[$row['id_group']] as $child)
2165 2248
 				$permissions[] = array($child, $row['id_profile'], $row['permission'], $row['add_deny']);
2249
+		}
2166 2250
 		$smcFunc['db_free_result']($request);
2167 2251
 
2168 2252
 		$smcFunc['db_query']('', '
@@ -2196,12 +2280,15 @@  discard block
 block discarded – undo
2196 2280
 	global $context;
2197 2281
 
2198 2282
 	$context['illegal_permissions'] = array();
2199
-	if (!allowedTo('admin_forum'))
2200
-		$context['illegal_permissions'][] = 'admin_forum';
2201
-	if (!allowedTo('manage_membergroups'))
2202
-		$context['illegal_permissions'][] = 'manage_membergroups';
2203
-	if (!allowedTo('manage_permissions'))
2204
-		$context['illegal_permissions'][] = 'manage_permissions';
2283
+	if (!allowedTo('admin_forum')) {
2284
+			$context['illegal_permissions'][] = 'admin_forum';
2285
+	}
2286
+	if (!allowedTo('manage_membergroups')) {
2287
+			$context['illegal_permissions'][] = 'manage_membergroups';
2288
+	}
2289
+	if (!allowedTo('manage_permissions')) {
2290
+			$context['illegal_permissions'][] = 'manage_permissions';
2291
+	}
2205 2292
 
2206 2293
 	call_integration_hook('integrate_load_illegal_permissions');
2207 2294
 }
@@ -2350,16 +2437,17 @@  discard block
 block discarded – undo
2350 2437
 				'attachment' => 'disallow',
2351 2438
 				'children' => array(),
2352 2439
 			);
2440
+		} elseif (isset($context['profile_groups'][$row['id_parent']])) {
2441
+					$context['profile_groups'][$row['id_parent']]['children'][] = $row['group_name'];
2353 2442
 		}
2354
-		elseif (isset($context['profile_groups'][$row['id_parent']]))
2355
-			$context['profile_groups'][$row['id_parent']]['children'][] = $row['group_name'];
2356 2443
 	}
2357 2444
 	$smcFunc['db_free_result']($request);
2358 2445
 
2359 2446
 	// What are the permissions we are querying?
2360 2447
 	$all_permissions = array();
2361
-	foreach ($mappings as $perm_set)
2362
-		$all_permissions = array_merge($all_permissions, $perm_set);
2448
+	foreach ($mappings as $perm_set) {
2449
+			$all_permissions = array_merge($all_permissions, $perm_set);
2450
+	}
2363 2451
 
2364 2452
 	// If we're saving the changes then do just that - save them.
2365 2453
 	if (!empty($_POST['save_changes']) && ($context['current_profile'] == 1 || $context['current_profile'] > 4))
@@ -2374,8 +2462,7 @@  discard block
 block discarded – undo
2374 2462
 			{
2375 2463
 				// Turning it on. This seems easy enough.
2376 2464
 				updateSettings(array('postmod_active' => 1));
2377
-			}
2378
-			else
2465
+			} else
2379 2466
 			{
2380 2467
 				// Turning it off. Not so straightforward. We have to turn off warnings to moderation level, and make everything approved.
2381 2468
 				updateSettings(array(
@@ -2386,8 +2473,7 @@  discard block
 block discarded – undo
2386 2473
 				require_once($sourcedir . '/PostModeration.php');
2387 2474
 				approveAllData();
2388 2475
 			}
2389
-		}
2390
-		elseif ($modSettings['postmod_active'])
2476
+		} elseif ($modSettings['postmod_active'])
2391 2477
 		{
2392 2478
 			// We're not saving a new setting - and if it's still enabled we have more work to do.
2393 2479
 
@@ -2417,21 +2503,22 @@  discard block
 block discarded – undo
2417 2503
 							// Give them both sets for fun.
2418 2504
 							$new_permissions[] = array($context['current_profile'], $group['id'], $data[0], 1);
2419 2505
 							$new_permissions[] = array($context['current_profile'], $group['id'], $data[1], 1);
2506
+						} elseif ($_POST[$index][$group['id']] == 'moderate') {
2507
+													$new_permissions[] = array($context['current_profile'], $group['id'], $data[1], 1);
2420 2508
 						}
2421
-						elseif ($_POST[$index][$group['id']] == 'moderate')
2422
-							$new_permissions[] = array($context['current_profile'], $group['id'], $data[1], 1);
2423 2509
 					}
2424 2510
 				}
2425 2511
 			}
2426 2512
 
2427 2513
 			// Insert new permissions.
2428
-			if (!empty($new_permissions))
2429
-				$smcFunc['db_insert']('',
2514
+			if (!empty($new_permissions)) {
2515
+							$smcFunc['db_insert']('',
2430 2516
 					'{db_prefix}board_permissions',
2431 2517
 					array('id_profile' => 'int', 'id_group' => 'int', 'permission' => 'string', 'add_deny' => 'int'),
2432 2518
 					$new_permissions,
2433 2519
 					array('id_profile', 'id_group', 'permission')
2434 2520
 				);
2521
+			}
2435 2522
 		}
2436 2523
 	}
2437 2524
 
@@ -2460,11 +2547,13 @@  discard block
 block discarded – undo
2460 2547
 					if ($row['add_deny'])
2461 2548
 					{
2462 2549
 						// Full allowance?
2463
-						if ($index == 0)
2464
-							$context['profile_groups'][$row['id_group']][$key] = 'allow';
2550
+						if ($index == 0) {
2551
+													$context['profile_groups'][$row['id_group']][$key] = 'allow';
2552
+						}
2465 2553
 						// Otherwise only bother with moderate if not on allow.
2466
-						elseif ($context['profile_groups'][$row['id_group']][$key] != 'allow')
2467
-							$context['profile_groups'][$row['id_group']][$key] = 'moderate';
2554
+						elseif ($context['profile_groups'][$row['id_group']][$key] != 'allow') {
2555
+													$context['profile_groups'][$row['id_group']][$key] = 'moderate';
2556
+						}
2468 2557
 					}
2469 2558
 				}
2470 2559
 			}
Please login to merge, or discard this patch.
Sources/SearchAPI-Fulltext.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -206,12 +206,12 @@  discard block
 block discarded – undo
206 206
 
207 207
 		if (!empty($modSettings['search_simple_fulltext']))
208 208
 		{
209
-			if($smcFunc['db_title'] == "PostgreSQL")
209
+			if ($smcFunc['db_title'] == "PostgreSQL")
210 210
 			{
211 211
 				//we use the default language "default_text_search_config", otherwise we had to assgine the language here
212 212
 				//to_tsvector(body) -> to_tsvector($language,body) to_tsquery(...) -> to_tsquery($language,...)
213 213
 				$language_ftx = 'english';
214
-				$request = $smcFunc['db_query']('','
214
+				$request = $smcFunc['db_query']('', '
215 215
 					SHOW default_text_search_config',
216 216
 					array()
217 217
 				);
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 			// remove any indexed words that are used in the complex body search terms
236 236
 			$words['indexed_words'] = array_diff($words['indexed_words'], $words['complex_words']);
237 237
 
238
-			if($smcFunc['db_title'] == "PostgreSQL"){
238
+			if ($smcFunc['db_title'] == "PostgreSQL") {
239 239
 				$row = 0;
240 240
 				foreach ($words['indexed_words'] as $fulltextWord) {
241 241
 					$query_params['boolean_match'] .= ($row <> 0 ? '&' : '');
@@ -251,12 +251,12 @@  discard block
 block discarded – undo
251 251
 
252 252
 			// if we have bool terms to search, add them in
253 253
 			if ($query_params['boolean_match']) {
254
-				if($smcFunc['db_title'] == "PostgreSQL")
254
+				if ($smcFunc['db_title'] == "PostgreSQL")
255 255
 				{
256 256
 					//we use the default language "default_text_search_config", otherwise we had to assgine the language here
257 257
 					//to_tsvector(body) -> to_tsvector($language,body) to_tsquery(...) -> to_tsquery($language,...)
258 258
 					$language_ftx = 'english';
259
-					$request = $smcFunc['db_query']('','
259
+					$request = $smcFunc['db_query']('', '
260 260
 						SHOW default_text_search_config',
261 261
 						array()
262 262
 					);
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 
276 276
 		}
277 277
 
278
-		$ignoreRequest = $smcFunc['db_search_query']('insert_into_log_messages_fulltext', ($smcFunc['db_support_ignore'] ? ( '
278
+		$ignoreRequest = $smcFunc['db_search_query']('insert_into_log_messages_fulltext', ($smcFunc['db_support_ignore'] ? ('
279 279
 			INSERT IGNORE INTO {db_prefix}' . $search_data['insert_into'] . '
280 280
 				(' . implode(', ', array_keys($query_select)) . ')') : '') . '
281 281
 			SELECT ' . implode(', ', $query_select) . '
Please login to merge, or discard this patch.
Braces   +44 added lines, -34 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
  * @version 2.1 Beta 3
12 12
  */
13 13
 
14
-if (!defined('SMF'))
14
+if (!defined('SMF')) {
15 15
 	die('No direct access...');
16
+}
16 17
 
17 18
 /**
18 19
  * Class fulltext_search
@@ -98,8 +99,9 @@  discard block
 block discarded – undo
98 99
 			$smcFunc['db_free_result']($request);
99 100
 		}
100 101
 		// 4 is the MySQL default...
101
-		else
102
-			$min_word_length = 4;
102
+		else {
103
+					$min_word_length = 4;
104
+		}
103 105
 
104 106
 		return $min_word_length;
105 107
 	}
@@ -138,8 +140,7 @@  discard block
 block discarded – undo
138 140
 					$wordsSearch['words'][] = trim($word, "/*- ");
139 141
 					$wordsSearch['complex_words'][] = count($subwords) === 1 ? $word : '"' . $word . '"';
140 142
 				}
141
-			}
142
-			elseif ($smcFunc['strlen'](trim($word, "/*- ")) < $this->min_word_length)
143
+			} elseif ($smcFunc['strlen'](trim($word, "/*- ")) < $this->min_word_length)
143 144
 			{
144 145
 				// short words have feelings too
145 146
 				$wordsSearch['words'][] = trim($word, "/*- ");
@@ -149,8 +150,9 @@  discard block
 block discarded – undo
149 150
 
150 151
 		$fulltextWord = count($subwords) === 1 ? $word : '"' . $word . '"';
151 152
 		$wordsSearch['indexed_words'][] = $fulltextWord;
152
-		if ($isExcluded)
153
-			$wordsExclude[] = $fulltextWord;
153
+		if ($isExcluded) {
154
+					$wordsExclude[] = $fulltextWord;
155
+		}
154 156
 	}
155 157
 
156 158
 	/**
@@ -166,41 +168,50 @@  discard block
 block discarded – undo
166 168
 		$query_where = array();
167 169
 		$query_params = $search_data['params'];
168 170
 
169
-		if ($query_params['id_search'])
170
-			$query_select['id_search'] = '{int:id_search}';
171
+		if ($query_params['id_search']) {
172
+					$query_select['id_search'] = '{int:id_search}';
173
+		}
171 174
 
172 175
 		$count = 0;
173
-		if (empty($modSettings['search_simple_fulltext']))
174
-			foreach ($words['words'] as $regularWord)
176
+		if (empty($modSettings['search_simple_fulltext'])) {
177
+					foreach ($words['words'] as $regularWord)
175 178
 			{
176 179
 				$query_where[] = 'm.body' . (in_array($regularWord, $query_params['excluded_words']) ? ' NOT' : '') . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:complex_body_' . $count . '}';
180
+		}
177 181
 				$query_params['complex_body_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]';
178 182
 			}
179 183
 
180
-		if ($query_params['user_query'])
181
-			$query_where[] = '{raw:user_query}';
182
-		if ($query_params['board_query'])
183
-			$query_where[] = 'm.id_board {raw:board_query}';
184
+		if ($query_params['user_query']) {
185
+					$query_where[] = '{raw:user_query}';
186
+		}
187
+		if ($query_params['board_query']) {
188
+					$query_where[] = 'm.id_board {raw:board_query}';
189
+		}
184 190
 
185
-		if ($query_params['topic'])
186
-			$query_where[] = 'm.id_topic = {int:topic}';
187
-		if ($query_params['min_msg_id'])
188
-			$query_where[] = 'm.id_msg >= {int:min_msg_id}';
189
-		if ($query_params['max_msg_id'])
190
-			$query_where[] = 'm.id_msg <= {int:max_msg_id}';
191
+		if ($query_params['topic']) {
192
+					$query_where[] = 'm.id_topic = {int:topic}';
193
+		}
194
+		if ($query_params['min_msg_id']) {
195
+					$query_where[] = 'm.id_msg >= {int:min_msg_id}';
196
+		}
197
+		if ($query_params['max_msg_id']) {
198
+					$query_where[] = 'm.id_msg <= {int:max_msg_id}';
199
+		}
191 200
 
192 201
 		$count = 0;
193
-		if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index']))
194
-			foreach ($query_params['excluded_phrases'] as $phrase)
202
+		if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) {
203
+					foreach ($query_params['excluded_phrases'] as $phrase)
195 204
 			{
196 205
 				$query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:exclude_subject_phrase_' . $count . '}';
206
+		}
197 207
 				$query_params['exclude_subject_phrase_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($phrase, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $phrase), '\\\'') . '[[:>:]]';
198 208
 			}
199 209
 		$count = 0;
200
-		if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index']))
201
-			foreach ($query_params['excluded_subject_words'] as $excludedWord)
210
+		if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) {
211
+					foreach ($query_params['excluded_subject_words'] as $excludedWord)
202 212
 			{
203 213
 				$query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:exclude_subject_words_' . $count . '}';
214
+		}
204 215
 				$query_params['exclude_subject_words_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($excludedWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $excludedWord), '\\\'') . '[[:>:]]';
205 216
 			}
206 217
 
@@ -223,12 +234,11 @@  discard block
 block discarded – undo
223 234
 				}
224 235
 				$query_where[] = 'to_tsvector({string:language_ftx},body) @@ to_tsquery({string:language_ftx},{string:body_match})';
225 236
 				$query_params['language_ftx'] = $language_ftx;
237
+			} else {
238
+							$query_where[] = 'MATCH (body) AGAINST ({string:body_match})';
226 239
 			}
227
-			else
228
-				$query_where[] = 'MATCH (body) AGAINST ({string:body_match})';
229 240
 			$query_params['body_match'] = implode(' ', array_diff($words['indexed_words'], $query_params['excluded_index_words']));
230
-		}
231
-		else
241
+		} else
232 242
 		{
233 243
 			$query_params['boolean_match'] = '';
234 244
 
@@ -242,10 +252,10 @@  discard block
 block discarded – undo
242 252
 					$query_params['boolean_match'] .= (in_array($fulltextWord, $query_params['excluded_index_words']) ? '!' : '') . $fulltextWord . ' ';
243 253
 					$row++;
244 254
 				}
245
-			}
246
-			else
247
-				foreach ($words['indexed_words'] as $fulltextWord)
255
+			} else {
256
+							foreach ($words['indexed_words'] as $fulltextWord)
248 257
 					$query_params['boolean_match'] .= (in_array($fulltextWord, $query_params['excluded_index_words']) ? '-' : '+') . $fulltextWord . ' ';
258
+			}
249 259
 
250 260
 			$query_params['boolean_match'] = substr($query_params['boolean_match'], 0, -1);
251 261
 
@@ -268,9 +278,9 @@  discard block
 block discarded – undo
268 278
 					}
269 279
 					$query_where[] = 'to_tsvector({string:language_ftx},body) @@ to_tsquery({string:language_ftx},{string:boolean_match})';
270 280
 					$query_params['language_ftx'] = $language_ftx;
281
+				} else {
282
+									$query_where[] = 'MATCH (body) AGAINST ({string:boolean_match} IN BOOLEAN MODE)';
271 283
 				}
272
-				else
273
-					$query_where[] = 'MATCH (body) AGAINST ({string:boolean_match} IN BOOLEAN MODE)';
274 284
 			}
275 285
 
276 286
 		}
Please login to merge, or discard this patch.
Sources/ManageSmileys.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
 					'class' => 'centercol',
394 394
 				),
395 395
 				'data' => array(
396
-					'function' => function ($rowData)
396
+					'function' => function($rowData)
397 397
 					{
398 398
 						return $rowData['selected'] ? '<span class="generic_icons valid"></span>' : '';
399 399
 					},
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 					'class' => 'centercol',
454 454
 				),
455 455
 				'data' => array(
456
-					'function' => function ($rowData)
456
+					'function' => function($rowData)
457 457
 					{
458 458
 						return $rowData['selected'] ? '' : sprintf('<input type="checkbox" name="smiley_set[%1$d]" class="input_check">', $rowData['id']);
459 459
 					},
@@ -997,7 +997,7 @@  discard block
 block discarded – undo
997 997
 						'value' => $txt['smileys_location'],
998 998
 					),
999 999
 					'data' => array(
1000
-						'function' => function ($rowData) use ($txt)
1000
+						'function' => function($rowData) use ($txt)
1001 1001
 						{
1002 1002
 							if (empty($rowData['hidden']))
1003 1003
 								return $txt['smileys_location_form'];
@@ -1017,7 +1017,7 @@  discard block
 block discarded – undo
1017 1017
 						'value' => $txt['smileys_description'],
1018 1018
 					),
1019 1019
 					'data' => array(
1020
-						'function' => function ($rowData) use ($context, $txt, $modSettings, $smcFunc)
1020
+						'function' => function($rowData) use ($context, $txt, $modSettings, $smcFunc)
1021 1021
 						{
1022 1022
 							if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir']))
1023 1023
 								return $smcFunc['htmlspecialchars']($rowData['description']);
@@ -1557,7 +1557,7 @@  discard block
 block discarded – undo
1557 1557
 				'action' => $smcFunc['htmlspecialchars'](strtr($action['destination'], array($boarddir => '.')))
1558 1558
 			);
1559 1559
 
1560
-			$file =  $packagesdir . '/temp/' . $base_path . $action['filename'];
1560
+			$file = $packagesdir . '/temp/' . $base_path . $action['filename'];
1561 1561
 			if (isset($action['filename']) && (!file_exists($file) || !is_writable(dirname($action['destination']))))
1562 1562
 			{
1563 1563
 				$context['has_failure'] = true;
@@ -1601,7 +1601,7 @@  discard block
 block discarded – undo
1601 1601
 		{
1602 1602
 			updateSettings(array(
1603 1603
 				'smiley_sets_known' => $modSettings['smiley_sets_known'] . ',' . basename($action['action']),
1604
-				'smiley_sets_names' => $modSettings['smiley_sets_names'] . "\n" . $smileyInfo['name'] . (count($context['actions']) > 1 ? ' ' .  (!empty($action['description']) ? $smcFunc['htmlspecialchars']($action['description']) : basename($action['action'])) : ''),
1604
+				'smiley_sets_names' => $modSettings['smiley_sets_names'] . "\n" . $smileyInfo['name'] . (count($context['actions']) > 1 ? ' ' . (!empty($action['description']) ? $smcFunc['htmlspecialchars']($action['description']) : basename($action['action'])) : ''),
1605 1605
 			));
1606 1606
 		}
1607 1607
 
@@ -1613,7 +1613,7 @@  discard block
 block discarded – undo
1613 1613
 			'{db_prefix}log_packages',
1614 1614
 			array(
1615 1615
 				'filename' => 'string', 'name' => 'string', 'package_id' => 'string', 'version' => 'string',
1616
-				'id_member_installed' => 'int', 'member_installed' => 'string','time_installed' => 'int',
1616
+				'id_member_installed' => 'int', 'member_installed' => 'string', 'time_installed' => 'int',
1617 1617
 				'install_state' => 'int', 'failed_steps' => 'string', 'themes_installed' => 'string',
1618 1618
 				'member_removed' => 'int', 'db_changes' => 'string', 'credits' => 'string',
1619 1619
 			),
@@ -1862,7 +1862,7 @@  discard block
 block discarded – undo
1862 1862
 		'columns' => array(
1863 1863
 			'icon' => array(
1864 1864
 				'data' => array(
1865
-					'function' => function ($rowData) use ($settings, $smcFunc)
1865
+					'function' => function($rowData) use ($settings, $smcFunc)
1866 1866
 					{
1867 1867
 						$images_url = $settings[file_exists(sprintf('%1$s/images/post/%2$s.png', $settings['theme_dir'], $rowData['filename'])) ? 'actual_images_url' : 'default_images_url'];
1868 1868
 						return sprintf('<img src="%1$s/post/%2$s.png" alt="%3$s">', $images_url, $rowData['filename'], $smcFunc['htmlspecialchars']($rowData['title']));
@@ -1896,7 +1896,7 @@  discard block
 block discarded – undo
1896 1896
 					'value' => $txt['icons_board'],
1897 1897
 				),
1898 1898
 				'data' => array(
1899
-					'function' => function ($rowData) use ($txt)
1899
+					'function' => function($rowData) use ($txt)
1900 1900
 					{
1901 1901
 						return empty($rowData['board_name']) ? $txt['icons_edit_icons_all_boards'] : $rowData['board_name'];
1902 1902
 					},
Please login to merge, or discard this patch.
Braces   +297 added lines, -211 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
  * This is the dispatcher of smileys administration.
@@ -91,8 +92,9 @@  discard block
 block discarded – undo
91 92
 	);
92 93
 
93 94
 	// Some settings may not be enabled, disallow these from the tabs as appropriate.
94
-	if (empty($modSettings['messageIcons_enable']))
95
-		$context[$context['admin_menu_name']]['tab_data']['tabs']['editicons']['disabled'] = true;
95
+	if (empty($modSettings['messageIcons_enable'])) {
96
+			$context[$context['admin_menu_name']]['tab_data']['tabs']['editicons']['disabled'] = true;
97
+	}
96 98
 	if (empty($modSettings['smiley_enable']))
97 99
 	{
98 100
 		$context[$context['admin_menu_name']]['tab_data']['tabs']['addsmiley']['disabled'] = true;
@@ -125,8 +127,9 @@  discard block
 block discarded – undo
125 127
 	$set_names = explode("\n", $modSettings['smiley_sets_names']);
126 128
 
127 129
 	$smiley_context = array();
128
-	foreach ($smiley_sets as $i => $set)
129
-		$smiley_context[$set] = $set_names[$i];
130
+	foreach ($smiley_sets as $i => $set) {
131
+			$smiley_context[$set] = $set_names[$i];
132
+	}
130 133
 
131 134
 	// All the settings for the page...
132 135
 	$config_vars = array(
@@ -147,8 +150,9 @@  discard block
 block discarded – undo
147 150
 
148 151
 	call_integration_hook('integrate_modify_smiley_settings', array(&$config_vars));
149 152
 
150
-	if ($return_config)
151
-		return $config_vars;
153
+	if ($return_config) {
154
+			return $config_vars;
155
+	}
152 156
 
153 157
 	// Setup the basics of the settings template.
154 158
 	require_once($sourcedir . '/ManageServer.php');
@@ -207,8 +211,9 @@  discard block
 block discarded – undo
207 211
 			foreach ($_POST['smiley_set'] as $id => $val)
208 212
 			{
209 213
 				// If this is the set you've marked as default, or the only one remaining, you can't delete it
210
-				if ($modSettings['smiley_sets_default'] != $set_paths[$id] && count($set_paths) != 1 && isset($set_paths[$id], $set_names[$id]))
211
-					unset($set_paths[$id], $set_names[$id]);
214
+				if ($modSettings['smiley_sets_default'] != $set_paths[$id] && count($set_paths) != 1 && isset($set_paths[$id], $set_names[$id])) {
215
+									unset($set_paths[$id], $set_names[$id]);
216
+				}
212 217
 			}
213 218
 
214 219
 			// Shortcut... array_merge() on a single array resets the numeric keys
@@ -222,8 +227,9 @@  discard block
 block discarded – undo
222 227
 			));
223 228
 		}
224 229
 		// Add a new smiley set.
225
-		elseif (!empty($_POST['add']))
226
-			$context['sub_action'] = 'modifyset';
230
+		elseif (!empty($_POST['add'])) {
231
+					$context['sub_action'] = 'modifyset';
232
+		}
227 233
 		// Create or modify a smiley set.
228 234
 		elseif (isset($_POST['set']))
229 235
 		{
@@ -233,8 +239,9 @@  discard block
 block discarded – undo
233 239
 			// Create a new smiley set.
234 240
 			if ($_POST['set'] == -1 && isset($_POST['smiley_sets_path']))
235 241
 			{
236
-				if (in_array($_POST['smiley_sets_path'], $set_paths))
237
-					fatal_lang_error('smiley_set_already_exists');
242
+				if (in_array($_POST['smiley_sets_path'], $set_paths)) {
243
+									fatal_lang_error('smiley_set_already_exists');
244
+				}
238 245
 
239 246
 				updateSettings(array(
240 247
 					'smiley_sets_known' => $modSettings['smiley_sets_known'] . ',' . $_POST['smiley_sets_path'],
@@ -246,12 +253,14 @@  discard block
 block discarded – undo
246 253
 			else
247 254
 			{
248 255
 				// Make sure the smiley set exists.
249
-				if (!isset($set_paths[$_POST['set']]) || !isset($set_names[$_POST['set']]))
250
-					fatal_lang_error('smiley_set_not_found');
256
+				if (!isset($set_paths[$_POST['set']]) || !isset($set_names[$_POST['set']])) {
257
+									fatal_lang_error('smiley_set_not_found');
258
+				}
251 259
 
252 260
 				// Make sure the path is not yet used by another smileyset.
253
-				if (in_array($_POST['smiley_sets_path'], $set_paths) && $_POST['smiley_sets_path'] != $set_paths[$_POST['set']])
254
-					fatal_lang_error('smiley_set_path_already_used');
261
+				if (in_array($_POST['smiley_sets_path'], $set_paths) && $_POST['smiley_sets_path'] != $set_paths[$_POST['set']]) {
262
+									fatal_lang_error('smiley_set_path_already_used');
263
+				}
255 264
 
256 265
 				$set_paths[$_POST['set']] = $_POST['smiley_sets_path'];
257 266
 				$set_names[$_POST['set']] = $_POST['smiley_sets_name'];
@@ -263,8 +272,9 @@  discard block
 block discarded – undo
263 272
 			}
264 273
 
265 274
 			// The user might have checked to also import smileys.
266
-			if (!empty($_POST['smiley_sets_import']))
267
-				ImportSmileys($_POST['smiley_sets_path']);
275
+			if (!empty($_POST['smiley_sets_import'])) {
276
+							ImportSmileys($_POST['smiley_sets_path']);
277
+			}
268 278
 		}
269 279
 		cache_put_data('parsing_smileys', null, 480);
270 280
 		cache_put_data('posting_smileys', null, 480);
@@ -273,13 +283,14 @@  discard block
 block discarded – undo
273 283
 	// Load all available smileysets...
274 284
 	$context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']);
275 285
 	$set_names = explode("\n", $modSettings['smiley_sets_names']);
276
-	foreach ($context['smiley_sets'] as $i => $set)
277
-		$context['smiley_sets'][$i] = array(
286
+	foreach ($context['smiley_sets'] as $i => $set) {
287
+			$context['smiley_sets'][$i] = array(
278 288
 			'id' => $i,
279 289
 			'path' => $smcFunc['htmlspecialchars']($set),
280 290
 			'name' => $smcFunc['htmlspecialchars']($set_names[$i]),
281 291
 			'selected' => $set == $modSettings['smiley_sets_default']
282 292
 		);
293
+	}
283 294
 
284 295
 	// Importing any smileys from an existing set?
285 296
 	if ($context['sub_action'] == 'import')
@@ -290,8 +301,9 @@  discard block
 block discarded – undo
290 301
 		$_GET['set'] = (int) $_GET['set'];
291 302
 
292 303
 		// Sanity check - then import.
293
-		if (isset($context['smiley_sets'][$_GET['set']]))
294
-			ImportSmileys(un_htmlspecialchars($context['smiley_sets'][$_GET['set']]['path']));
304
+		if (isset($context['smiley_sets'][$_GET['set']])) {
305
+					ImportSmileys(un_htmlspecialchars($context['smiley_sets'][$_GET['set']]['path']));
306
+		}
295 307
 
296 308
 		// Force the process to continue.
297 309
 		$context['sub_action'] = 'modifyset';
@@ -301,15 +313,15 @@  discard block
 block discarded – undo
301 313
 	if ($context['sub_action'] == 'modifyset')
302 314
 	{
303 315
 		$_GET['set'] = !isset($_GET['set']) ? -1 : (int) $_GET['set'];
304
-		if ($_GET['set'] == -1 || !isset($context['smiley_sets'][$_GET['set']]))
305
-			$context['current_set'] = array(
316
+		if ($_GET['set'] == -1 || !isset($context['smiley_sets'][$_GET['set']])) {
317
+					$context['current_set'] = array(
306 318
 				'id' => '-1',
307 319
 				'path' => '',
308 320
 				'name' => '',
309 321
 				'selected' => false,
310 322
 				'is_new' => true,
311 323
 			);
312
-		else
324
+		} else
313 325
 		{
314 326
 			$context['current_set'] = &$context['smiley_sets'][$_GET['set']];
315 327
 			$context['current_set']['is_new'] = false;
@@ -321,13 +333,15 @@  discard block
 block discarded – undo
321 333
 				$dir = dir($modSettings['smileys_dir'] . '/' . $context['current_set']['path']);
322 334
 				while ($entry = $dir->read())
323 335
 				{
324
-					if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png')))
325
-						$smileys[strtolower($entry)] = $entry;
336
+					if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) {
337
+											$smileys[strtolower($entry)] = $entry;
338
+					}
326 339
 				}
327 340
 				$dir->close();
328 341
 
329
-				if (empty($smileys))
330
-					fatal_lang_error('smiley_set_dir_not_found', false, array($context['current_set']['name']));
342
+				if (empty($smileys)) {
343
+									fatal_lang_error('smiley_set_dir_not_found', false, array($context['current_set']['name']));
344
+				}
331 345
 
332 346
 				// Exclude the smileys that are already in the database.
333 347
 				$request = $smcFunc['db_query']('', '
@@ -338,9 +352,10 @@  discard block
 block discarded – undo
338 352
 						'smiley_list' => $smileys,
339 353
 					)
340 354
 				);
341
-				while ($row = $smcFunc['db_fetch_assoc']($request))
342
-					if (isset($smileys[strtolower($row['filename'])]))
355
+				while ($row = $smcFunc['db_fetch_assoc']($request)) {
356
+									if (isset($smileys[strtolower($row['filename'])]))
343 357
 						unset($smileys[strtolower($row['filename'])]);
358
+				}
344 359
 				$smcFunc['db_free_result']($request);
345 360
 
346 361
 				$context['current_set']['can_import'] = count($smileys);
@@ -355,13 +370,14 @@  discard block
 block discarded – undo
355 370
 			$dir = dir($modSettings['smileys_dir']);
356 371
 			while ($entry = $dir->read())
357 372
 			{
358
-				if (!in_array($entry, array('.', '..')) && is_dir($modSettings['smileys_dir'] . '/' . $entry))
359
-					$context['smiley_set_dirs'][] = array(
373
+				if (!in_array($entry, array('.', '..')) && is_dir($modSettings['smileys_dir'] . '/' . $entry)) {
374
+									$context['smiley_set_dirs'][] = array(
360 375
 						'id' => $entry,
361 376
 						'path' => $modSettings['smileys_dir'] . '/' . $entry,
362 377
 						'selectable' => $entry == $context['current_set']['path'] || !in_array($entry, explode(',', $modSettings['smiley_sets_known'])),
363 378
 						'current' => $entry == $context['current_set']['path'],
364 379
 					);
380
+				}
365 381
 			}
366 382
 			$dir->close();
367 383
 		}
@@ -371,8 +387,9 @@  discard block
 block discarded – undo
371 387
 	createToken('admin-mss', 'request');
372 388
 
373 389
 	// In case we need to import smileys, we need to add the token in now.
374
-	if (isset($context['current_set']['import_url']))
375
-		$context['current_set']['import_url'] .= ';' . $context['admin-mss_token_var'] . '=' . $context['admin-mss_token'];
390
+	if (isset($context['current_set']['import_url'])) {
391
+			$context['current_set']['import_url'] .= ';' . $context['admin-mss_token_var'] . '=' . $context['admin-mss_token'];
392
+	}
376 393
 
377 394
 	$listOptions = array(
378 395
 		'id' => 'smiley_set_list',
@@ -510,21 +527,23 @@  discard block
 block discarded – undo
510 527
 		$cols['name'][] = $set_names[$i];
511 528
 	}
512 529
 	$sort_flag = strpos($sort, 'DESC') === false ? SORT_ASC : SORT_DESC;
513
-	if (substr($sort, 0, 4) === 'name')
514
-		array_multisort($cols['name'], $sort_flag, SORT_REGULAR, $cols['path'], $cols['selected'], $cols['id']);
515
-	elseif (substr($sort, 0, 4) === 'path')
516
-		array_multisort($cols['path'], $sort_flag, SORT_REGULAR, $cols['name'], $cols['selected'], $cols['id']);
517
-	else
518
-		array_multisort($cols['selected'], $sort_flag, SORT_REGULAR, $cols['path'], $cols['name'], $cols['id']);
530
+	if (substr($sort, 0, 4) === 'name') {
531
+			array_multisort($cols['name'], $sort_flag, SORT_REGULAR, $cols['path'], $cols['selected'], $cols['id']);
532
+	} elseif (substr($sort, 0, 4) === 'path') {
533
+			array_multisort($cols['path'], $sort_flag, SORT_REGULAR, $cols['name'], $cols['selected'], $cols['id']);
534
+	} else {
535
+			array_multisort($cols['selected'], $sort_flag, SORT_REGULAR, $cols['path'], $cols['name'], $cols['id']);
536
+	}
519 537
 
520 538
 	$smiley_sets = array();
521
-	foreach ($cols['id'] as $i => $id)
522
-		$smiley_sets[] = array(
539
+	foreach ($cols['id'] as $i => $id) {
540
+			$smiley_sets[] = array(
523 541
 			'id' => $id,
524 542
 			'path' => $cols['path'][$i],
525 543
 			'name' => $cols['name'][$i],
526 544
 			'selected' => $cols['path'][$i] == $modSettings['smiley_sets_default']
527 545
 		);
546
+	}
528 547
 
529 548
 	return $smiley_sets;
530 549
 }
@@ -553,13 +572,14 @@  discard block
 block discarded – undo
553 572
 	$context['smileys_dir_found'] = is_dir($context['smileys_dir']);
554 573
 	$context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']);
555 574
 	$set_names = explode("\n", $modSettings['smiley_sets_names']);
556
-	foreach ($context['smiley_sets'] as $i => $set)
557
-		$context['smiley_sets'][$i] = array(
575
+	foreach ($context['smiley_sets'] as $i => $set) {
576
+			$context['smiley_sets'][$i] = array(
558 577
 			'id' => $i,
559 578
 			'path' => $smcFunc['htmlspecialchars']($set),
560 579
 			'name' => $smcFunc['htmlspecialchars']($set_names[$i]),
561 580
 			'selected' => $set == $modSettings['smiley_sets_default']
562 581
 		);
582
+	}
563 583
 
564 584
 	// Submitting a form?
565 585
 	if (isset($_POST[$context['session_var']], $_POST['smiley_code']))
@@ -575,8 +595,9 @@  discard block
 block discarded – undo
575 595
 		$_POST['smiley_filename'] = htmltrim__recursive($_POST['smiley_filename']);
576 596
 
577 597
 		// Make sure some code was entered.
578
-		if (empty($_POST['smiley_code']))
579
-			fatal_lang_error('smiley_has_no_code');
598
+		if (empty($_POST['smiley_code'])) {
599
+					fatal_lang_error('smiley_has_no_code');
600
+		}
580 601
 
581 602
 		// Check whether the new code has duplicates. It should be unique.
582 603
 		$request = $smcFunc['db_query']('', '
@@ -588,8 +609,9 @@  discard block
 block discarded – undo
588 609
 				'smiley_code' => $_POST['smiley_code'],
589 610
 			)
590 611
 		);
591
-		if ($smcFunc['db_num_rows']($request) > 0)
592
-			fatal_lang_error('smiley_not_unique');
612
+		if ($smcFunc['db_num_rows']($request) > 0) {
613
+					fatal_lang_error('smiley_not_unique');
614
+		}
593 615
 		$smcFunc['db_free_result']($request);
594 616
 
595 617
 		// If we are uploading - check all the smiley sets are writable!
@@ -598,38 +620,44 @@  discard block
 block discarded – undo
598 620
 			$writeErrors = array();
599 621
 			foreach ($context['smiley_sets'] as $set)
600 622
 			{
601
-				if (!is_writable($context['smileys_dir'] . '/' . un_htmlspecialchars($set['path'])))
602
-					$writeErrors[] = $set['path'];
623
+				if (!is_writable($context['smileys_dir'] . '/' . un_htmlspecialchars($set['path']))) {
624
+									$writeErrors[] = $set['path'];
625
+				}
626
+			}
627
+			if (!empty($writeErrors)) {
628
+							fatal_lang_error('smileys_upload_error_notwritable', true, array(implode(', ', $writeErrors)));
603 629
 			}
604
-			if (!empty($writeErrors))
605
-				fatal_lang_error('smileys_upload_error_notwritable', true, array(implode(', ', $writeErrors)));
606 630
 		}
607 631
 
608 632
 		// Uploading just one smiley for all of them?
609 633
 		if (isset($_POST['sameall']) && isset($_FILES['uploadSmiley']['name']) && $_FILES['uploadSmiley']['name'] != '')
610 634
 		{
611
-			if (!is_uploaded_file($_FILES['uploadSmiley']['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['uploadSmiley']['tmp_name'])))
612
-				fatal_lang_error('smileys_upload_error');
635
+			if (!is_uploaded_file($_FILES['uploadSmiley']['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['uploadSmiley']['tmp_name']))) {
636
+							fatal_lang_error('smileys_upload_error');
637
+			}
613 638
 
614 639
 			// Sorry, no spaces, dots, or anything else but letters allowed.
615 640
 			$_FILES['uploadSmiley']['name'] = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $_FILES['uploadSmiley']['name']);
616 641
 
617 642
 			// We only allow image files - it's THAT simple - no messing around here...
618
-			if (!in_array(strtolower(substr(strrchr($_FILES['uploadSmiley']['name'], '.'), 1)), $allowedTypes))
619
-				fatal_lang_error('smileys_upload_error_types', false, array(implode(', ', $allowedTypes)));
643
+			if (!in_array(strtolower(substr(strrchr($_FILES['uploadSmiley']['name'], '.'), 1)), $allowedTypes)) {
644
+							fatal_lang_error('smileys_upload_error_types', false, array(implode(', ', $allowedTypes)));
645
+			}
620 646
 
621 647
 			// We only need the filename...
622 648
 			$destName = basename($_FILES['uploadSmiley']['name']);
623 649
 
624 650
 			// Make sure they aren't trying to upload a nasty file - for their own good here!
625
-			if (in_array(strtolower($destName), $disabledFiles))
626
-				fatal_lang_error('smileys_upload_error_illegal');
651
+			if (in_array(strtolower($destName), $disabledFiles)) {
652
+							fatal_lang_error('smileys_upload_error_illegal');
653
+			}
627 654
 
628 655
 			// Check if the file already exists... and if not move it to EVERY smiley set directory.
629 656
 			$i = 0;
630 657
 			// Keep going until we find a set the file doesn't exist in. (or maybe it exists in all of them?)
631
-			while (isset($context['smiley_sets'][$i]) && file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($context['smiley_sets'][$i]['path']) . '/' . $destName))
632
-				$i++;
658
+			while (isset($context['smiley_sets'][$i]) && file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($context['smiley_sets'][$i]['path']) . '/' . $destName)) {
659
+							$i++;
660
+			}
633 661
 
634 662
 			// Okay, we're going to put the smiley right here, since it's not there yet!
635 663
 			if (isset($context['smiley_sets'][$i]['path']))
@@ -644,8 +672,9 @@  discard block
 block discarded – undo
644 672
 					$currentPath = $context['smileys_dir'] . '/' . un_htmlspecialchars($context['smiley_sets'][$i]['path']) . '/' . $destName;
645 673
 
646 674
 					// The file is already there!  Don't overwrite it!
647
-					if (file_exists($currentPath))
648
-						continue;
675
+					if (file_exists($currentPath)) {
676
+											continue;
677
+					}
649 678
 
650 679
 					// Okay, so copy the first one we made to here.
651 680
 					copy($smileyLocation, $currentPath);
@@ -662,13 +691,15 @@  discard block
 block discarded – undo
662 691
 			$newName = '';
663 692
 			foreach ($_FILES as $name => $data)
664 693
 			{
665
-				if ($_FILES[$name]['name'] == '')
666
-					fatal_lang_error('smileys_upload_error_blank');
694
+				if ($_FILES[$name]['name'] == '') {
695
+									fatal_lang_error('smileys_upload_error_blank');
696
+				}
667 697
 
668
-				if (empty($newName))
669
-					$newName = basename($_FILES[$name]['name']);
670
-				elseif (basename($_FILES[$name]['name']) != $newName)
671
-					fatal_lang_error('smileys_upload_error_name');
698
+				if (empty($newName)) {
699
+									$newName = basename($_FILES[$name]['name']);
700
+				} elseif (basename($_FILES[$name]['name']) != $newName) {
701
+									fatal_lang_error('smileys_upload_error_name');
702
+				}
672 703
 			}
673 704
 
674 705
 			foreach ($context['smiley_sets'] as $i => $set)
@@ -676,31 +707,36 @@  discard block
 block discarded – undo
676 707
 				$set['name'] = un_htmlspecialchars($set['name']);
677 708
 				$set['path'] = un_htmlspecialchars($set['path']);
678 709
 
679
-				if (!isset($_FILES['individual_' . $set['name']]['name']) || $_FILES['individual_' . $set['name']]['name'] == '')
680
-					continue;
710
+				if (!isset($_FILES['individual_' . $set['name']]['name']) || $_FILES['individual_' . $set['name']]['name'] == '') {
711
+									continue;
712
+				}
681 713
 
682 714
 				// Got one...
683
-				if (!is_uploaded_file($_FILES['individual_' . $set['name']]['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['individual_' . $set['name']]['tmp_name'])))
684
-					fatal_lang_error('smileys_upload_error');
715
+				if (!is_uploaded_file($_FILES['individual_' . $set['name']]['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['individual_' . $set['name']]['tmp_name']))) {
716
+									fatal_lang_error('smileys_upload_error');
717
+				}
685 718
 
686 719
 				// Sorry, no spaces, dots, or anything else but letters allowed.
687 720
 				$_FILES['individual_' . $set['name']]['name'] = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $_FILES['individual_' . $set['name']]['name']);
688 721
 
689 722
 				// We only allow image files - it's THAT simple - no messing around here...
690
-				if (!in_array(strtolower(substr(strrchr($_FILES['individual_' . $set['name']]['name'], '.'), 1)), $allowedTypes))
691
-					fatal_lang_error('smileys_upload_error_types', false, array(implode(', ', $allowedTypes)));
723
+				if (!in_array(strtolower(substr(strrchr($_FILES['individual_' . $set['name']]['name'], '.'), 1)), $allowedTypes)) {
724
+									fatal_lang_error('smileys_upload_error_types', false, array(implode(', ', $allowedTypes)));
725
+				}
692 726
 
693 727
 				// We only need the filename...
694 728
 				$destName = basename($_FILES['individual_' . $set['name']]['name']);
695 729
 
696 730
 				// Make sure they aren't trying to upload a nasty file - for their own good here!
697
-				if (in_array(strtolower($destName), $disabledFiles))
698
-					fatal_lang_error('smileys_upload_error_illegal');
731
+				if (in_array(strtolower($destName), $disabledFiles)) {
732
+									fatal_lang_error('smileys_upload_error_illegal');
733
+				}
699 734
 
700 735
 				// If the file exists - ignore it.
701 736
 				$smileyLocation = $context['smileys_dir'] . '/' . $set['path'] . '/' . $destName;
702
-				if (file_exists($smileyLocation))
703
-					continue;
737
+				if (file_exists($smileyLocation)) {
738
+									continue;
739
+				}
704 740
 
705 741
 				// Finally - move the image!
706 742
 				move_uploaded_file($_FILES['individual_' . $set['name']]['tmp_name'], $smileyLocation);
@@ -712,8 +748,9 @@  discard block
 block discarded – undo
712 748
 		}
713 749
 
714 750
 		// Also make sure a filename was given.
715
-		if (empty($_POST['smiley_filename']))
716
-			fatal_lang_error('smiley_has_no_filename');
751
+		if (empty($_POST['smiley_filename'])) {
752
+					fatal_lang_error('smiley_has_no_filename');
753
+		}
717 754
 
718 755
 		// Find the position on the right.
719 756
 		$smiley_order = '0';
@@ -732,8 +769,9 @@  discard block
 block discarded – undo
732 769
 			list ($smiley_order) = $smcFunc['db_fetch_row']($request);
733 770
 			$smcFunc['db_free_result']($request);
734 771
 
735
-			if (empty($smiley_order))
736
-				$smiley_order = '0';
772
+			if (empty($smiley_order)) {
773
+							$smiley_order = '0';
774
+			}
737 775
 		}
738 776
 		$smcFunc['db_insert']('',
739 777
 			'{db_prefix}smileys',
@@ -761,17 +799,19 @@  discard block
 block discarded – undo
761 799
 	{
762 800
 		foreach ($context['smiley_sets'] as $smiley_set)
763 801
 		{
764
-			if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path'])))
765
-				continue;
802
+			if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']))) {
803
+							continue;
804
+			}
766 805
 
767 806
 			$dir = dir($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']));
768 807
 			while ($entry = $dir->read())
769 808
 			{
770
-				if (!in_array($entry, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png')))
771
-					$context['filenames'][strtolower($entry)] = array(
809
+				if (!in_array($entry, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) {
810
+									$context['filenames'][strtolower($entry)] = array(
772 811
 						'id' => $smcFunc['htmlspecialchars']($entry),
773 812
 						'selected' => false,
774 813
 					);
814
+				}
775 815
 			}
776 816
 			$dir->close();
777 817
 		}
@@ -809,17 +849,19 @@  discard block
 block discarded – undo
809 849
 		// Changing the selected smileys?
810 850
 		if (isset($_POST['smiley_action']) && !empty($_POST['checked_smileys']))
811 851
 		{
812
-			foreach ($_POST['checked_smileys'] as $id => $smiley_id)
813
-				$_POST['checked_smileys'][$id] = (int) $smiley_id;
852
+			foreach ($_POST['checked_smileys'] as $id => $smiley_id) {
853
+							$_POST['checked_smileys'][$id] = (int) $smiley_id;
854
+			}
814 855
 
815
-			if ($_POST['smiley_action'] == 'delete')
816
-				$smcFunc['db_query']('', '
856
+			if ($_POST['smiley_action'] == 'delete') {
857
+							$smcFunc['db_query']('', '
817 858
 					DELETE FROM {db_prefix}smileys
818 859
 					WHERE id_smiley IN ({array_int:checked_smileys})',
819 860
 					array(
820 861
 						'checked_smileys' => $_POST['checked_smileys'],
821 862
 					)
822 863
 				);
864
+			}
823 865
 			// Changing the status of the smiley?
824 866
 			else
825 867
 			{
@@ -829,8 +871,8 @@  discard block
 block discarded – undo
829 871
 					'hidden' => 1,
830 872
 					'popup' => 2
831 873
 				);
832
-				if (isset($displayTypes[$_POST['smiley_action']]))
833
-					$smcFunc['db_query']('', '
874
+				if (isset($displayTypes[$_POST['smiley_action']])) {
875
+									$smcFunc['db_query']('', '
834 876
 						UPDATE {db_prefix}smileys
835 877
 						SET hidden = {int:display_type}
836 878
 						WHERE id_smiley IN ({array_int:checked_smileys})',
@@ -839,6 +881,7 @@  discard block
 block discarded – undo
839 881
 							'display_type' => $displayTypes[$_POST['smiley_action']],
840 882
 						)
841 883
 					);
884
+				}
842 885
 			}
843 886
 		}
844 887
 		// Create/modify a smiley.
@@ -864,12 +907,14 @@  discard block
 block discarded – undo
864 907
 				$_POST['smiley_location'] = empty($_POST['smiley_location']) || $_POST['smiley_location'] > 2 || $_POST['smiley_location'] < 0 ? 0 : (int) $_POST['smiley_location'];
865 908
 
866 909
 				// Make sure some code was entered.
867
-				if (empty($_POST['smiley_code']))
868
-					fatal_lang_error('smiley_has_no_code');
910
+				if (empty($_POST['smiley_code'])) {
911
+									fatal_lang_error('smiley_has_no_code');
912
+				}
869 913
 
870 914
 				// Also make sure a filename was given.
871
-				if (empty($_POST['smiley_filename']))
872
-					fatal_lang_error('smiley_has_no_filename');
915
+				if (empty($_POST['smiley_filename'])) {
916
+									fatal_lang_error('smiley_has_no_filename');
917
+				}
873 918
 
874 919
 				// Check whether the new code has duplicates. It should be unique.
875 920
 				$request = $smcFunc['db_query']('', '
@@ -883,8 +928,9 @@  discard block
 block discarded – undo
883 928
 						'smiley_code' => $_POST['smiley_code'],
884 929
 					)
885 930
 				);
886
-				if ($smcFunc['db_num_rows']($request) > 0)
887
-					fatal_lang_error('smiley_not_unique');
931
+				if ($smcFunc['db_num_rows']($request) > 0) {
932
+									fatal_lang_error('smiley_not_unique');
933
+				}
888 934
 				$smcFunc['db_free_result']($request);
889 935
 
890 936
 				$smcFunc['db_query']('', '
@@ -913,13 +959,14 @@  discard block
 block discarded – undo
913 959
 	// Load all known smiley sets.
914 960
 	$context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']);
915 961
 	$set_names = explode("\n", $modSettings['smiley_sets_names']);
916
-	foreach ($context['smiley_sets'] as $i => $set)
917
-		$context['smiley_sets'][$i] = array(
962
+	foreach ($context['smiley_sets'] as $i => $set) {
963
+			$context['smiley_sets'][$i] = array(
918 964
 			'id' => $i,
919 965
 			'path' => $smcFunc['htmlspecialchars']($set),
920 966
 			'name' => $smcFunc['htmlspecialchars']($set_names[$i]),
921 967
 			'selected' => $set == $modSettings['smiley_sets_default']
922 968
 		);
969
+	}
923 970
 
924 971
 	// Prepare overview of all (custom) smileys.
925 972
 	if ($context['sub_action'] == 'editsmileys')
@@ -935,9 +982,10 @@  discard block
 block discarded – undo
935 982
 		// Create a list of options for selecting smiley sets.
936 983
 		$smileyset_option_list = '
937 984
 			<select name="set" onchange="changeSet(this.options[this.selectedIndex].value);">';
938
-		foreach ($context['smiley_sets'] as $smiley_set)
939
-			$smileyset_option_list .= '
985
+		foreach ($context['smiley_sets'] as $smiley_set) {
986
+					$smileyset_option_list .= '
940 987
 				<option value="' . $smiley_set['path'] . '"' . ($modSettings['smiley_sets_default'] == $smiley_set['path'] ? ' selected' : '') . '>' . $smiley_set['name'] . '</option>';
988
+		}
941 989
 		$smileyset_option_list .= '
942 990
 			</select>';
943 991
 
@@ -999,12 +1047,13 @@  discard block
 block discarded – undo
999 1047
 					'data' => array(
1000 1048
 						'function' => function ($rowData) use ($txt)
1001 1049
 						{
1002
-							if (empty($rowData['hidden']))
1003
-								return $txt['smileys_location_form'];
1004
-							elseif ($rowData['hidden'] == 1)
1005
-								return $txt['smileys_location_hidden'];
1006
-							else
1007
-								return $txt['smileys_location_popup'];
1050
+							if (empty($rowData['hidden'])) {
1051
+															return $txt['smileys_location_form'];
1052
+							} elseif ($rowData['hidden'] == 1) {
1053
+															return $txt['smileys_location_hidden'];
1054
+							} else {
1055
+															return $txt['smileys_location_popup'];
1056
+							}
1008 1057
 						},
1009 1058
 					),
1010 1059
 					'sort' => array(
@@ -1019,19 +1068,22 @@  discard block
 block discarded – undo
1019 1068
 					'data' => array(
1020 1069
 						'function' => function ($rowData) use ($context, $txt, $modSettings, $smcFunc)
1021 1070
 						{
1022
-							if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir']))
1023
-								return $smcFunc['htmlspecialchars']($rowData['description']);
1071
+							if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'])) {
1072
+															return $smcFunc['htmlspecialchars']($rowData['description']);
1073
+							}
1024 1074
 
1025 1075
 							// Check if there are smileys missing in some sets.
1026 1076
 							$missing_sets = array();
1027
-							foreach ($context['smiley_sets'] as $smiley_set)
1028
-								if (!file_exists(sprintf('%1$s/%2$s/%3$s', $modSettings['smileys_dir'], $smiley_set['path'], $rowData['filename'])))
1077
+							foreach ($context['smiley_sets'] as $smiley_set) {
1078
+															if (!file_exists(sprintf('%1$s/%2$s/%3$s', $modSettings['smileys_dir'], $smiley_set['path'], $rowData['filename'])))
1029 1079
 									$missing_sets[] = $smiley_set['path'];
1080
+							}
1030 1081
 
1031 1082
 							$description = $smcFunc['htmlspecialchars']($rowData['description']);
1032 1083
 
1033
-							if (!empty($missing_sets))
1034
-								$description .= sprintf('<br><span class="smalltext"><strong>%1$s:</strong> %2$s</span>', $txt['smileys_not_found_in_set'], implode(', ', $missing_sets));
1084
+							if (!empty($missing_sets)) {
1085
+															$description .= sprintf('<br><span class="smalltext"><strong>%1$s:</strong> %2$s</span>', $txt['smileys_not_found_in_set'], implode(', ', $missing_sets));
1086
+							}
1035 1087
 
1036 1088
 							return $description;
1037 1089
 						},
@@ -1147,13 +1199,14 @@  discard block
 block discarded – undo
1147 1199
 		$context['smileys_dir_found'] = is_dir($context['smileys_dir']);
1148 1200
 		$context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']);
1149 1201
 		$set_names = explode("\n", $modSettings['smiley_sets_names']);
1150
-		foreach ($context['smiley_sets'] as $i => $set)
1151
-			$context['smiley_sets'][$i] = array(
1202
+		foreach ($context['smiley_sets'] as $i => $set) {
1203
+					$context['smiley_sets'][$i] = array(
1152 1204
 				'id' => $i,
1153 1205
 				'path' => $smcFunc['htmlspecialchars']($set),
1154 1206
 				'name' => $smcFunc['htmlspecialchars']($set_names[$i]),
1155 1207
 				'selected' => $set == $modSettings['smiley_sets_default']
1156 1208
 			);
1209
+		}
1157 1210
 
1158 1211
 		$context['selected_set'] = $modSettings['smiley_sets_default'];
1159 1212
 
@@ -1163,17 +1216,19 @@  discard block
 block discarded – undo
1163 1216
 		{
1164 1217
 			foreach ($context['smiley_sets'] as $smiley_set)
1165 1218
 			{
1166
-				if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path'])))
1167
-					continue;
1219
+				if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']))) {
1220
+									continue;
1221
+				}
1168 1222
 
1169 1223
 				$dir = dir($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']));
1170 1224
 				while ($entry = $dir->read())
1171 1225
 				{
1172
-					if (!in_array($entry, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png')))
1173
-						$context['filenames'][strtolower($entry)] = array(
1226
+					if (!in_array($entry, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) {
1227
+											$context['filenames'][strtolower($entry)] = array(
1174 1228
 							'id' => $smcFunc['htmlspecialchars']($entry),
1175 1229
 							'selected' => false,
1176 1230
 						);
1231
+					}
1177 1232
 				}
1178 1233
 				$dir->close();
1179 1234
 			}
@@ -1188,8 +1243,9 @@  discard block
 block discarded – undo
1188 1243
 				'current_smiley' => (int) $_REQUEST['smiley'],
1189 1244
 			)
1190 1245
 		);
1191
-		if ($smcFunc['db_num_rows']($request) != 1)
1192
-			fatal_lang_error('smiley_not_found');
1246
+		if ($smcFunc['db_num_rows']($request) != 1) {
1247
+					fatal_lang_error('smiley_not_found');
1248
+		}
1193 1249
 		$context['current_smiley'] = $smcFunc['db_fetch_assoc']($request);
1194 1250
 		$smcFunc['db_free_result']($request);
1195 1251
 
@@ -1197,8 +1253,9 @@  discard block
 block discarded – undo
1197 1253
 		$context['current_smiley']['filename'] = $smcFunc['htmlspecialchars']($context['current_smiley']['filename']);
1198 1254
 		$context['current_smiley']['description'] = $smcFunc['htmlspecialchars']($context['current_smiley']['description']);
1199 1255
 
1200
-		if (isset($context['filenames'][strtolower($context['current_smiley']['filename'])]))
1201
-			$context['filenames'][strtolower($context['current_smiley']['filename'])]['selected'] = true;
1256
+		if (isset($context['filenames'][strtolower($context['current_smiley']['filename'])])) {
1257
+					$context['filenames'][strtolower($context['current_smiley']['filename'])]['selected'] = true;
1258
+		}
1202 1259
 	}
1203 1260
 }
1204 1261
 
@@ -1223,8 +1280,9 @@  discard block
 block discarded – undo
1223 1280
 		)
1224 1281
 	);
1225 1282
 	$smileys = array();
1226
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1227
-		$smileys[] = $row;
1283
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1284
+			$smileys[] = $row;
1285
+	}
1228 1286
 	$smcFunc['db_free_result']($request);
1229 1287
 
1230 1288
 	return $smileys;
@@ -1264,8 +1322,9 @@  discard block
 block discarded – undo
1264 1322
 		$_GET['location'] = empty($_GET['location']) || $_GET['location'] != 'popup' ? 0 : 2;
1265 1323
 		$_GET['source'] = empty($_GET['source']) ? 0 : (int) $_GET['source'];
1266 1324
 
1267
-		if (empty($_GET['source']))
1268
-			fatal_lang_error('smiley_not_found');
1325
+		if (empty($_GET['source'])) {
1326
+					fatal_lang_error('smiley_not_found');
1327
+		}
1269 1328
 
1270 1329
 		if (!empty($_GET['after']))
1271 1330
 		{
@@ -1281,12 +1340,12 @@  discard block
 block discarded – undo
1281 1340
 					'after_smiley' => $_GET['after'],
1282 1341
 				)
1283 1342
 			);
1284
-			if ($smcFunc['db_num_rows']($request) != 1)
1285
-				fatal_lang_error('smiley_not_found');
1343
+			if ($smcFunc['db_num_rows']($request) != 1) {
1344
+							fatal_lang_error('smiley_not_found');
1345
+			}
1286 1346
 			list ($smiley_row, $smiley_order, $smileyLocation) = $smcFunc['db_fetch_row']($request);
1287 1347
 			$smcFunc['db_free_result']($request);
1288
-		}
1289
-		else
1348
+		} else
1290 1349
 		{
1291 1350
 			$smiley_row = (int) $_GET['row'];
1292 1351
 			$smiley_order = -1;
@@ -1360,14 +1419,15 @@  discard block
 block discarded – undo
1360 1419
 	$context['move_smiley'] = empty($_REQUEST['move']) ? 0 : (int) $_REQUEST['move'];
1361 1420
 
1362 1421
 	// Make sure all rows are sequential.
1363
-	foreach (array_keys($context['smileys']) as $location)
1364
-		$context['smileys'][$location] = array(
1422
+	foreach (array_keys($context['smileys']) as $location) {
1423
+			$context['smileys'][$location] = array(
1365 1424
 			'id' => $location,
1366 1425
 			'title' => $location == 'postform' ? $txt['smileys_location_form'] : $txt['smileys_location_popup'],
1367 1426
 			'description' => $location == 'postform' ? $txt['smileys_location_form_description'] : $txt['smileys_location_popup_description'],
1368 1427
 			'last_row' => count($context['smileys'][$location]['rows']),
1369 1428
 			'rows' => array_values($context['smileys'][$location]['rows']),
1370 1429
 		);
1430
+	}
1371 1431
 
1372 1432
 	// Check & fix smileys that are not ordered properly in the database.
1373 1433
 	foreach (array_keys($context['smileys']) as $location)
@@ -1392,8 +1452,8 @@  discard block
 block discarded – undo
1392 1452
 				$context['smileys'][$location]['rows'][$id][0]['row'] = $id;
1393 1453
 			}
1394 1454
 			// Make sure the smiley order is always sequential.
1395
-			foreach ($smiley_row as $order_id => $smiley)
1396
-				if ($order_id != $smiley['order'])
1455
+			foreach ($smiley_row as $order_id => $smiley) {
1456
+							if ($order_id != $smiley['order'])
1397 1457
 					$smcFunc['db_query']('', '
1398 1458
 						UPDATE {db_prefix}smileys
1399 1459
 						SET smiley_order = {int:new_order}
@@ -1403,6 +1463,7 @@  discard block
 block discarded – undo
1403 1463
 							'current_smiley' => $smiley['id'],
1404 1464
 						)
1405 1465
 					);
1466
+			}
1406 1467
 		}
1407 1468
 	}
1408 1469
 
@@ -1435,19 +1496,20 @@  discard block
 block discarded – undo
1435 1496
 		$context['filename'] = $base_name;
1436 1497
 
1437 1498
 		// Check that the smiley is from simplemachines.org, for now... maybe add mirroring later.
1438
-		if (preg_match('~^http://[\w_\-]+\.simplemachines\.org/~', $_REQUEST['set_gz']) == 0 || strpos($_REQUEST['set_gz'], 'dlattach') !== false)
1439
-			fatal_lang_error('not_on_simplemachines');
1499
+		if (preg_match('~^http://[\w_\-]+\.simplemachines\.org/~', $_REQUEST['set_gz']) == 0 || strpos($_REQUEST['set_gz'], 'dlattach') !== false) {
1500
+					fatal_lang_error('not_on_simplemachines');
1501
+		}
1440 1502
 
1441 1503
 		$destination = $packagesdir . '/' . $base_name;
1442 1504
 
1443
-		if (file_exists($destination))
1444
-			fatal_lang_error('package_upload_error_exists');
1505
+		if (file_exists($destination)) {
1506
+					fatal_lang_error('package_upload_error_exists');
1507
+		}
1445 1508
 
1446 1509
 		// Let's copy it to the Packages directory
1447 1510
 		file_put_contents($destination, fetch_web_data($_REQUEST['set_gz']));
1448 1511
 		$testing = true;
1449
-	}
1450
-	elseif (isset($_REQUEST['package']))
1512
+	} elseif (isset($_REQUEST['package']))
1451 1513
 	{
1452 1514
 		$base_name = basename($_REQUEST['package']);
1453 1515
 		$name = $smcFunc['htmlspecialchars'](strtok(basename($_REQUEST['package']), '.'));
@@ -1456,12 +1518,14 @@  discard block
 block discarded – undo
1456 1518
 		$destination = $packagesdir . '/' . basename($_REQUEST['package']);
1457 1519
 	}
1458 1520
 
1459
-	if (empty($destination) || !file_exists($destination))
1460
-		fatal_lang_error('package_no_file', false);
1521
+	if (empty($destination) || !file_exists($destination)) {
1522
+			fatal_lang_error('package_no_file', false);
1523
+	}
1461 1524
 
1462 1525
 	// Make sure temp directory exists and is empty.
1463
-	if (file_exists($packagesdir . '/temp'))
1464
-		deltree($packagesdir . '/temp', false);
1526
+	if (file_exists($packagesdir . '/temp')) {
1527
+			deltree($packagesdir . '/temp', false);
1528
+	}
1465 1529
 
1466 1530
 	if (!mktree($packagesdir . '/temp', 0755))
1467 1531
 	{
@@ -1473,31 +1537,37 @@  discard block
 block discarded – undo
1473 1537
 			create_chmod_control(array($packagesdir . '/temp/delme.tmp'), array('destination_url' => $scripturl . '?action=admin;area=smileys;sa=install;set_gz=' . $_REQUEST['set_gz'], 'crash_on_error' => true));
1474 1538
 
1475 1539
 			deltree($packagesdir . '/temp', false);
1476
-			if (!mktree($packagesdir . '/temp', 0777))
1477
-				fatal_lang_error('package_cant_download', false);
1540
+			if (!mktree($packagesdir . '/temp', 0777)) {
1541
+							fatal_lang_error('package_cant_download', false);
1542
+			}
1478 1543
 		}
1479 1544
 	}
1480 1545
 
1481 1546
 	$extracted = read_tgz_file($destination, $packagesdir . '/temp');
1482
-	if (!$extracted)
1483
-		fatal_lang_error('packageget_unable', false, array('http://custom.simplemachines.org/mods/index.php?action=search;type=12;basic_search=' . $name));
1484
-	if ($extracted && !file_exists($packagesdir . '/temp/package-info.xml'))
1485
-		foreach ($extracted as $file)
1547
+	if (!$extracted) {
1548
+			fatal_lang_error('packageget_unable', false, array('http://custom.simplemachines.org/mods/index.php?action=search;type=12;basic_search=' . $name));
1549
+	}
1550
+	if ($extracted && !file_exists($packagesdir . '/temp/package-info.xml')) {
1551
+			foreach ($extracted as $file)
1486 1552
 			if (basename($file['filename']) == 'package-info.xml')
1487 1553
 			{
1488 1554
 				$base_path = dirname($file['filename']) . '/';
1555
+	}
1489 1556
 				break;
1490 1557
 			}
1491 1558
 
1492
-	if (!isset($base_path))
1493
-		$base_path = '';
1559
+	if (!isset($base_path)) {
1560
+			$base_path = '';
1561
+	}
1494 1562
 
1495
-	if (!file_exists($packagesdir . '/temp/' . $base_path . 'package-info.xml'))
1496
-		fatal_lang_error('package_get_error_missing_xml', false);
1563
+	if (!file_exists($packagesdir . '/temp/' . $base_path . 'package-info.xml')) {
1564
+			fatal_lang_error('package_get_error_missing_xml', false);
1565
+	}
1497 1566
 
1498 1567
 	$smileyInfo = getPackageInfo($context['filename']);
1499
-	if (!is_array($smileyInfo))
1500
-		fatal_lang_error($smileyInfo);
1568
+	if (!is_array($smileyInfo)) {
1569
+			fatal_lang_error($smileyInfo);
1570
+	}
1501 1571
 
1502 1572
 	// See if it is installed?
1503 1573
 	$request = $smcFunc['db_query']('', '
@@ -1513,8 +1583,9 @@  discard block
 block discarded – undo
1513 1583
 		)
1514 1584
 	);
1515 1585
 
1516
-	if ($smcFunc['db_num_rows']($request) > 0)
1517
-		fata_lang_error('package_installed_warning1');
1586
+	if ($smcFunc['db_num_rows']($request) > 0) {
1587
+			fata_lang_error('package_installed_warning1');
1588
+	}
1518 1589
 
1519 1590
 	// Everything is fine, now it's time to do something
1520 1591
 	$actions = parsePackageInfo($smileyInfo['xml'], true, 'install');
@@ -1531,23 +1602,23 @@  discard block
 block discarded – undo
1531 1602
 		{
1532 1603
 			$has_readme = true;
1533 1604
 			$type = 'package_' . $action['type'];
1534
-			if (file_exists($packagesdir . '/temp/' . $base_path . $action['filename']))
1535
-				$context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($packagesdir . '/temp/' . $base_path . $action['filename']), "\n\r"));
1536
-			elseif (file_exists($action['filename']))
1537
-				$context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($action['filename']), "\n\r"));
1605
+			if (file_exists($packagesdir . '/temp/' . $base_path . $action['filename'])) {
1606
+							$context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($packagesdir . '/temp/' . $base_path . $action['filename']), "\n\r"));
1607
+			} elseif (file_exists($action['filename'])) {
1608
+							$context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($action['filename']), "\n\r"));
1609
+			}
1538 1610
 
1539 1611
 			if (!empty($action['parse_bbc']))
1540 1612
 			{
1541 1613
 				require_once($sourcedir . '/Subs-Post.php');
1542 1614
 				preparsecode($context[$type]);
1543 1615
 				$context[$type] = parse_bbc($context[$type]);
1616
+			} else {
1617
+							$context[$type] = nl2br($context[$type]);
1544 1618
 			}
1545
-			else
1546
-				$context[$type] = nl2br($context[$type]);
1547 1619
 
1548 1620
 			continue;
1549
-		}
1550
-		elseif ($action['type'] == 'require-dir')
1621
+		} elseif ($action['type'] == 'require-dir')
1551 1622
 		{
1552 1623
 			// Do this one...
1553 1624
 			$thisAction = array(
@@ -1566,12 +1637,12 @@  discard block
 block discarded – undo
1566 1637
 				);
1567 1638
 			}
1568 1639
 			// @todo None given?
1569
-			if (empty($thisAction['description']))
1570
-				$thisAction['description'] = isset($action['description']) ? $action['description'] : '';
1640
+			if (empty($thisAction['description'])) {
1641
+							$thisAction['description'] = isset($action['description']) ? $action['description'] : '';
1642
+			}
1571 1643
 
1572 1644
 			$context['actions'][] = $thisAction;
1573
-		}
1574
-		elseif ($action['type'] == 'credits')
1645
+		} elseif ($action['type'] == 'credits')
1575 1646
 		{
1576 1647
 			// Time to build the billboard
1577 1648
 			$credits_tag = array(
@@ -1630,12 +1701,14 @@  discard block
 block discarded – undo
1630 1701
 		cache_put_data('posting_smileys', null, 480);
1631 1702
 	}
1632 1703
 
1633
-	if (file_exists($packagesdir . '/temp'))
1634
-		deltree($packagesdir . '/temp');
1704
+	if (file_exists($packagesdir . '/temp')) {
1705
+			deltree($packagesdir . '/temp');
1706
+	}
1635 1707
 
1636
-	if (!$testing)
1637
-		redirectexit('action=admin;area=smileys');
1638
-}
1708
+	if (!$testing) {
1709
+			redirectexit('action=admin;area=smileys');
1710
+	}
1711
+	}
1639 1712
 
1640 1713
 /**
1641 1714
  * A function to import new smileys from an existing directory into the database.
@@ -1646,15 +1719,17 @@  discard block
 block discarded – undo
1646 1719
 {
1647 1720
 	global $modSettings, $smcFunc;
1648 1721
 
1649
-	if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'] . '/' . $smileyPath))
1650
-		fatal_lang_error('smiley_set_unable_to_import');
1722
+	if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'] . '/' . $smileyPath)) {
1723
+			fatal_lang_error('smiley_set_unable_to_import');
1724
+	}
1651 1725
 
1652 1726
 	$smileys = array();
1653 1727
 	$dir = dir($modSettings['smileys_dir'] . '/' . $smileyPath);
1654 1728
 	while ($entry = $dir->read())
1655 1729
 	{
1656
-		if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png')))
1657
-			$smileys[strtolower($entry)] = $entry;
1730
+		if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) {
1731
+					$smileys[strtolower($entry)] = $entry;
1732
+		}
1658 1733
 	}
1659 1734
 	$dir->close();
1660 1735
 
@@ -1667,9 +1742,10 @@  discard block
 block discarded – undo
1667 1742
 			'smiley_list' => $smileys,
1668 1743
 		)
1669 1744
 	);
1670
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1671
-		if (isset($smileys[strtolower($row['filename'])]))
1745
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1746
+			if (isset($smileys[strtolower($row['filename'])]))
1672 1747
 			unset($smileys[strtolower($row['filename'])]);
1748
+	}
1673 1749
 	$smcFunc['db_free_result']($request);
1674 1750
 
1675 1751
 	$request = $smcFunc['db_query']('', '
@@ -1686,9 +1762,10 @@  discard block
 block discarded – undo
1686 1762
 	$smcFunc['db_free_result']($request);
1687 1763
 
1688 1764
 	$new_smileys = array();
1689
-	foreach ($smileys as $smiley)
1690
-		if (strlen($smiley) <= 48)
1765
+	foreach ($smileys as $smiley) {
1766
+			if (strlen($smiley) <= 48)
1691 1767
 			$new_smileys[] = array(':' . strtok($smiley, '.') . ':', $smiley, strtok($smiley, '.'), 0, ++$smiley_order);
1768
+	}
1692 1769
 
1693 1770
 	if (!empty($new_smileys))
1694 1771
 	{
@@ -1753,8 +1830,9 @@  discard block
 block discarded – undo
1753 1830
 		if (isset($_POST['delete']) && !empty($_POST['checked_icons']))
1754 1831
 		{
1755 1832
 			$deleteIcons = array();
1756
-			foreach ($_POST['checked_icons'] as $icon)
1757
-				$deleteIcons[] = (int) $icon;
1833
+			foreach ($_POST['checked_icons'] as $icon) {
1834
+							$deleteIcons[] = (int) $icon;
1835
+			}
1758 1836
 
1759 1837
 			// Do the actual delete!
1760 1838
 			$smcFunc['db_query']('', '
@@ -1771,35 +1849,41 @@  discard block
 block discarded – undo
1771 1849
 			$_GET['icon'] = (int) $_GET['icon'];
1772 1850
 
1773 1851
 			// Do some preperation with the data... like check the icon exists *somewhere*
1774
-			if (strpos($_POST['icon_filename'], '.png') !== false)
1775
-				$_POST['icon_filename'] = substr($_POST['icon_filename'], 0, -4);
1776
-			if (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon_filename'] . '.png'))
1777
-				fatal_lang_error('icon_not_found');
1852
+			if (strpos($_POST['icon_filename'], '.png') !== false) {
1853
+							$_POST['icon_filename'] = substr($_POST['icon_filename'], 0, -4);
1854
+			}
1855
+			if (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon_filename'] . '.png')) {
1856
+							fatal_lang_error('icon_not_found');
1857
+			}
1778 1858
 			// There is a 16 character limit on message icons...
1779
-			elseif (strlen($_POST['icon_filename']) > 16)
1780
-				fatal_lang_error('icon_name_too_long');
1781
-			elseif ($_POST['icon_location'] == $_GET['icon'] && !empty($_GET['icon']))
1782
-				fatal_lang_error('icon_after_itself');
1859
+			elseif (strlen($_POST['icon_filename']) > 16) {
1860
+							fatal_lang_error('icon_name_too_long');
1861
+			} elseif ($_POST['icon_location'] == $_GET['icon'] && !empty($_GET['icon'])) {
1862
+							fatal_lang_error('icon_after_itself');
1863
+			}
1783 1864
 
1784 1865
 			// First do the sorting... if this is an edit reduce the order of everything after it by one ;)
1785 1866
 			if ($_GET['icon'] != 0)
1786 1867
 			{
1787 1868
 				$oldOrder = $context['icons'][$_GET['icon']]['true_order'];
1788
-				foreach ($context['icons'] as $id => $data)
1789
-					if ($data['true_order'] > $oldOrder)
1869
+				foreach ($context['icons'] as $id => $data) {
1870
+									if ($data['true_order'] > $oldOrder)
1790 1871
 						$context['icons'][$id]['true_order']--;
1872
+				}
1791 1873
 			}
1792 1874
 
1793 1875
 			// If there are no existing icons and this is a new one, set the id to 1 (mainly for non-mysql)
1794
-			if (empty($_GET['icon']) && empty($context['icons']))
1795
-				$_GET['icon'] = 1;
1876
+			if (empty($_GET['icon']) && empty($context['icons'])) {
1877
+							$_GET['icon'] = 1;
1878
+			}
1796 1879
 
1797 1880
 			// Get the new order.
1798 1881
 			$newOrder = $_POST['icon_location'] == 0 ? 0 : $context['icons'][$_POST['icon_location']]['true_order'] + 1;
1799 1882
 			// Do the same, but with the one that used to be after this icon, done to avoid conflict.
1800
-			foreach ($context['icons'] as $id => $data)
1801
-				if ($data['true_order'] >= $newOrder)
1883
+			foreach ($context['icons'] as $id => $data) {
1884
+							if ($data['true_order'] >= $newOrder)
1802 1885
 					$context['icons'][$id]['true_order']++;
1886
+			}
1803 1887
 
1804 1888
 			// Finally set the current icon's position!
1805 1889
 			$context['icons'][$_GET['icon']]['true_order'] = $newOrder;
@@ -1817,8 +1901,7 @@  discard block
 block discarded – undo
1817 1901
 				if ($id != 0)
1818 1902
 				{
1819 1903
 					$iconInsert[] = array($id, $icon['board_id'], $icon['title'], $icon['filename'], $icon['true_order']);
1820
-				}
1821
-				else
1904
+				} else
1822 1905
 				{
1823 1906
 					$iconInsert_new[] = array($icon['board_id'], $icon['title'], $icon['filename'], $icon['true_order']);
1824 1907
 				}
@@ -1843,8 +1926,9 @@  discard block
 block discarded – undo
1843 1926
 		}
1844 1927
 
1845 1928
 		// Unless we're adding a new thing, we'll escape
1846
-		if (!isset($_POST['add']))
1847
-			redirectexit('action=admin;area=smileys;sa=editicons');
1929
+		if (!isset($_POST['add'])) {
1930
+					redirectexit('action=admin;area=smileys;sa=editicons');
1931
+		}
1848 1932
 	}
1849 1933
 
1850 1934
 	$context[$context['admin_menu_name']]['current_subsection'] = 'editicons';
@@ -1954,8 +2038,9 @@  discard block
 block discarded – undo
1954 2038
 		$context['new_icon'] = !isset($_GET['icon']);
1955 2039
 
1956 2040
 		// Get the properties of the current icon from the icon list.
1957
-		if (!$context['new_icon'])
1958
-			$context['icon'] = $context['icons'][$_GET['icon']];
2041
+		if (!$context['new_icon']) {
2042
+					$context['icon'] = $context['icons'][$_GET['icon']];
2043
+		}
1959 2044
 
1960 2045
 		// Get a list of boards needed for assigning this icon to a specific board.
1961 2046
 		$boardListOptions = array(
@@ -1989,8 +2074,9 @@  discard block
 block discarded – undo
1989 2074
 	);
1990 2075
 
1991 2076
 	$message_icons = array();
1992
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1993
-		$message_icons[] = $row;
2077
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
2078
+			$message_icons[] = $row;
2079
+	}
1994 2080
 	$smcFunc['db_free_result']($request);
1995 2081
 
1996 2082
 	return $message_icons;
Please login to merge, or discard this patch.
Sources/ManageCalendar.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 					'value' => $txt['date'],
137 137
 				),
138 138
 				'data' => array(
139
-					'function' => function ($rowData) use ($txt)
139
+					'function' => function($rowData) use ($txt)
140 140
 					{
141 141
 						// Recurring every year or just a single year?
142 142
 						$year = $rowData['year'] == '0004' ? sprintf('(%1$s)', $txt['every_year']) : $rowData['year'];
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 		checkSession();
219 219
 
220 220
 		// Not too long good sir?
221
-		$_REQUEST['title'] =  $smcFunc['substr']($_REQUEST['title'], 0, 60);
221
+		$_REQUEST['title'] = $smcFunc['substr']($_REQUEST['title'], 0, 60);
222 222
 		$_REQUEST['holiday'] = isset($_REQUEST['holiday']) ? (int) $_REQUEST['holiday'] : 0;
223 223
 
224 224
 		if (isset($_REQUEST['delete']))
Please login to merge, or discard this patch.
Braces   +37 added lines, -28 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 controlling function doesn't have much to do... yet.
@@ -43,8 +44,7 @@  discard block
 block discarded – undo
43 44
 			'settings' => 'ModifyCalendarSettings'
44 45
 		);
45 46
 		$default = 'holidays';
46
-	}
47
-	else
47
+	} else
48 48
 	{
49 49
 		$subActions = array(
50 50
 			'settings' => 'ModifyCalendarSettings'
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
 		'help' => 'calendar',
61 61
 		'description' => $txt['calendar_settings_desc'],
62 62
 	);
63
-	if (!empty($modSettings['cal_enabled']))
64
-		$context[$context['admin_menu_name']]['tab_data']['tabs'] = array(
63
+	if (!empty($modSettings['cal_enabled'])) {
64
+			$context[$context['admin_menu_name']]['tab_data']['tabs'] = array(
65 65
 			'holidays' => array(
66 66
 				'description' => $txt['manage_holidays_desc'],
67 67
 			),
@@ -69,6 +69,7 @@  discard block
 block discarded – undo
69 69
 				'description' => $txt['calendar_settings_desc'],
70 70
 			),
71 71
 		);
72
+	}
72 73
 
73 74
 	call_integration_hook('integrate_manage_calendar', array(&$subActions));
74 75
 
@@ -88,8 +89,9 @@  discard block
 block discarded – undo
88 89
 		checkSession();
89 90
 		validateToken('admin-mc');
90 91
 
91
-		foreach ($_REQUEST['holiday'] as $id => $value)
92
-			$_REQUEST['holiday'][$id] = (int) $id;
92
+		foreach ($_REQUEST['holiday'] as $id => $value) {
93
+					$_REQUEST['holiday'][$id] = (int) $id;
94
+		}
93 95
 
94 96
 		// Now the IDs are "safe" do the delete...
95 97
 		require_once($sourcedir . '/Subs-Calendar.php');
@@ -209,8 +211,9 @@  discard block
 block discarded – undo
209 211
 	$context['sub_template'] = 'edit_holiday';
210 212
 
211 213
 	// Cast this for safety...
212
-	if (isset($_REQUEST['holiday']))
213
-		$_REQUEST['holiday'] = (int) $_REQUEST['holiday'];
214
+	if (isset($_REQUEST['holiday'])) {
215
+			$_REQUEST['holiday'] = (int) $_REQUEST['holiday'];
216
+	}
214 217
 
215 218
 	// Submitting?
216 219
 	if (isset($_POST[$context['session_var']]) && (isset($_REQUEST['delete']) || $_REQUEST['title'] != ''))
@@ -221,19 +224,19 @@  discard block
 block discarded – undo
221 224
 		$_REQUEST['title'] =  $smcFunc['substr']($_REQUEST['title'], 0, 60);
222 225
 		$_REQUEST['holiday'] = isset($_REQUEST['holiday']) ? (int) $_REQUEST['holiday'] : 0;
223 226
 
224
-		if (isset($_REQUEST['delete']))
225
-			$smcFunc['db_query']('', '
227
+		if (isset($_REQUEST['delete'])) {
228
+					$smcFunc['db_query']('', '
226 229
 				DELETE FROM {db_prefix}calendar_holidays
227 230
 				WHERE id_holiday = {int:selected_holiday}',
228 231
 				array(
229 232
 					'selected_holiday' => $_REQUEST['holiday'],
230 233
 				)
231 234
 			);
232
-		else
235
+		} else
233 236
 		{
234 237
 			$date = strftime($_REQUEST['year'] <= 4 ? '0004-%m-%d' : '%Y-%m-%d', mktime(0, 0, 0, $_REQUEST['month'], $_REQUEST['day'], $_REQUEST['year']));
235
-			if (isset($_REQUEST['edit']))
236
-				$smcFunc['db_query']('', '
238
+			if (isset($_REQUEST['edit'])) {
239
+							$smcFunc['db_query']('', '
237 240
 					UPDATE {db_prefix}calendar_holidays
238 241
 					SET event_date = {date:holiday_date}, title = {string:holiday_title}
239 242
 					WHERE id_holiday = {int:selected_holiday}',
@@ -243,8 +246,8 @@  discard block
 block discarded – undo
243 246
 						'holiday_title' => $_REQUEST['title'],
244 247
 					)
245 248
 				);
246
-			else
247
-				$smcFunc['db_insert']('',
249
+			} else {
250
+							$smcFunc['db_insert']('',
248 251
 					'{db_prefix}calendar_holidays',
249 252
 					array(
250 253
 						'event_date' => 'date', 'title' => 'string-60',
@@ -254,6 +257,7 @@  discard block
 block discarded – undo
254 257
 					),
255 258
 					array('id_holiday')
256 259
 				);
260
+			}
257 261
 		}
258 262
 
259 263
 		updateSettings(array(
@@ -265,14 +269,15 @@  discard block
 block discarded – undo
265 269
 	}
266 270
 
267 271
 	// Default states...
268
-	if ($context['is_new'])
269
-		$context['holiday'] = array(
272
+	if ($context['is_new']) {
273
+			$context['holiday'] = array(
270 274
 			'id' => 0,
271 275
 			'day' => date('d'),
272 276
 			'month' => date('m'),
273 277
 			'year' => '0000',
274 278
 			'title' => ''
275 279
 		);
280
+	}
276 281
 	// If it's not new load the data.
277 282
 	else
278 283
 	{
@@ -285,14 +290,15 @@  discard block
 block discarded – undo
285 290
 				'selected_holiday' => $_REQUEST['holiday'],
286 291
 			)
287 292
 		);
288
-		while ($row = $smcFunc['db_fetch_assoc']($request))
289
-			$context['holiday'] = array(
293
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
294
+					$context['holiday'] = array(
290 295
 				'id' => $row['id_holiday'],
291 296
 				'day' => $row['day'],
292 297
 				'month' => $row['month'],
293 298
 				'year' => $row['year'] <= 4 ? 0 : $row['year'],
294 299
 				'title' => $row['title']
295 300
 			);
301
+		}
296 302
 		$smcFunc['db_free_result']($request);
297 303
 	}
298 304
 
@@ -319,16 +325,17 @@  discard block
 block discarded – undo
319 325
 		array(
320 326
 		)
321 327
 	);
322
-	while ($row = $smcFunc['db_fetch_assoc']($request))
323
-		$boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name'];
328
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
329
+			$boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name'];
330
+	}
324 331
 	$smcFunc['db_free_result']($request);
325 332
 
326 333
 	require_once($sourcedir . '/Subs-Boards.php');
327 334
 	sortBoards($boards);
328 335
 
329 336
 	// Look, all the calendar settings - of which there are many!
330
-	if (!empty($modSettings['cal_enabled']))
331
-		$config_vars = array(
337
+	if (!empty($modSettings['cal_enabled'])) {
338
+			$config_vars = array(
332 339
 				array('check', 'cal_enabled'),
333 340
 			'',
334 341
 				// All the permissions:
@@ -371,14 +378,16 @@  discard block
 block discarded – undo
371 378
 				array('check', 'cal_short_days'),
372 379
 				array('check', 'cal_short_months'),
373 380
 		);
374
-	else
375
-		$config_vars = array(
381
+	} else {
382
+			$config_vars = array(
376 383
 			array('check', 'cal_enabled'),
377 384
 		);
385
+	}
378 386
 
379 387
 	call_integration_hook('integrate_modify_calendar_settings', array(&$config_vars));
380
-	if ($return_config)
381
-		return $config_vars;
388
+	if ($return_config) {
389
+			return $config_vars;
390
+	}
382 391
 
383 392
 	// Get the settings template fired up.
384 393
 	require_once($sourcedir . '/ManageServer.php');
Please login to merge, or discard this patch.