Completed
Pull Request — release-2.1 (#5052)
by Mathias
50:05
created
Themes/default/ManageSmileys.template.php 1 patch
Braces   +56 added lines, -41 removed lines patch added patch discarded remove patch
@@ -34,11 +34,12 @@  discard block
 block discarded – undo
34 34
 		</div>';
35 35
 
36 36
 	// If this is an existing set, and there are still un-added smileys - offer an import opportunity.
37
-	if (!empty($context['current_set']['can_import']))
38
-		echo '
37
+	if (!empty($context['current_set']['can_import'])) {
38
+			echo '
39 39
 		<div class="information noup">
40 40
 			', $context['current_set']['can_import'] == 1 ? sprintf($txt['smiley_set_import_single'], $context['current_set']['import_url']) : sprintf($txt['smiley_set_import_multiple'], $context['current_set']['can_import'], $context['current_set']['import_url']), '
41 41
 		</div>';
42
+	}
42 43
 
43 44
 	echo '
44 45
 		<div class="windowbg noup">
@@ -67,17 +68,18 @@  discard block
 block discarded – undo
67 68
 				<dd>
68 69
 					', $modSettings['smileys_url'], '/';
69 70
 
70
-	if (empty($context['smiley_set_dirs']))
71
-		echo '
71
+	if (empty($context['smiley_set_dirs'])) {
72
+			echo '
72 73
 					<input type="text" name="smiley_sets_path" id="smiley_sets_path" value="', $context['current_set']['path'], '"> ';
73
-	else
74
+	} else
74 75
 	{
75 76
 		echo '
76 77
 					<select name="smiley_sets_path" id="smiley_sets_path">';
77 78
 
78
-		foreach ($context['smiley_set_dirs'] as $smiley_set_dir)
79
-			echo '
79
+		foreach ($context['smiley_set_dirs'] as $smiley_set_dir) {
80
+					echo '
80 81
 						<option value="', $smiley_set_dir['id'], '"', $smiley_set_dir['current'] ? ' selected' : '', $smiley_set_dir['selectable'] ? '' : ' disabled', '>', $smiley_set_dir['id'], '</option>';
82
+		}
81 83
 		echo '
82 84
 					</select> ';
83 85
 	}
@@ -92,14 +94,15 @@  discard block
 block discarded – undo
92 94
 				</dd>';
93 95
 
94 96
 	// If this is a new smiley set they have the option to import smileys already in the directory.
95
-	if ($context['current_set']['is_new'] && !empty($modSettings['smiley_enable']))
96
-		echo '
97
+	if ($context['current_set']['is_new'] && !empty($modSettings['smiley_enable'])) {
98
+			echo '
97 99
 				<dt>
98 100
 					<strong><label for="smiley_sets_import">', $txt['smiley_set_import_directory'], '</label>: </strong>
99 101
 				</dt>
100 102
 				<dd>
101 103
 					<input type="checkbox" name="smiley_sets_import" id="smiley_sets_import" value="1">
102 104
 				</dd>';
105
+	}
103 106
 
104 107
 	echo '
105 108
 			</dl>
@@ -131,9 +134,10 @@  discard block
 block discarded – undo
131 134
 				<dd>
132 135
 					<img src="', $modSettings['smileys_url'], '/', $modSettings['smiley_sets_default'], '/', $context['current_smiley']['filename'] . $context['user']['smiley_set_default_ext'], '" id="preview" alt=""> ', $txt['smiley_preview_using'], ': <select id="set" onchange="updatePreview();">';
133 136
 
134
-	foreach ($context['smiley_sets'] as $smiley_set)
135
-		echo '
137
+	foreach ($context['smiley_sets'] as $smiley_set) {
138
+			echo '
136 139
 					<option value="', $smiley_set['path'], '"', $context['selected_set'] == $smiley_set['path'] ? ' selected' : '', '>', $smiley_set['name'], '</option>';
140
+	}
137 141
 
138 142
 	echo '
139 143
 					</select>
@@ -149,17 +153,18 @@  discard block
 block discarded – undo
149 153
 				</dt>
150 154
 				<dd>';
151 155
 
152
-	if (empty($context['filenames']))
153
-		echo '
156
+	if (empty($context['filenames'])) {
157
+			echo '
154 158
 					<input type="text" name="smiley_filename" id="smiley_filename" value="', $context['current_smiley']['filename'], '">';
155
-	else
159
+	} else
156 160
 	{
157 161
 		echo '
158 162
 					<select name="smiley_filename" id="smiley_filename" onchange="updatePreview();">';
159 163
 
160
-		foreach ($context['filenames'] as $filename)
161
-			echo '
164
+		foreach ($context['filenames'] as $filename) {
165
+					echo '
162 166
 						<option value="', $filename['id'], '"', $filename['selected'] ? ' selected' : '', '>', $filename['id'], '</option>';
167
+		}
163 168
 		echo '
164 169
 					</select>';
165 170
 	}
@@ -226,9 +231,10 @@  discard block
 block discarded – undo
226 231
 					<dd>
227 232
 						', $txt['smiley_preview_using'], ': <select id="set" onchange="updatePreview();selectMethod(\'existing\');">';
228 233
 
229
-	foreach ($context['smiley_sets'] as $smiley_set)
230
-		echo '
234
+	foreach ($context['smiley_sets'] as $smiley_set) {
235
+			echo '
231 236
 							<option value="', $smiley_set['path'], '"', $context['selected_set'] == $smiley_set['path'] ? ' selected' : '', '>', $smiley_set['name'], '</option>';
237
+	}
232 238
 
233 239
 	echo '
234 240
 						</select>
@@ -238,17 +244,18 @@  discard block
 block discarded – undo
238 244
 					</dt>
239 245
 					<dd>';
240 246
 
241
-	if (empty($context['filenames']))
242
-		echo '
247
+	if (empty($context['filenames'])) {
248
+			echo '
243 249
 						<input type="text" name="smiley_filename" id="smiley_filename" value="', $context['current_smiley']['filename'], '" onchange="selectMethod(\'existing\');">';
244
-	else
250
+	} else
245 251
 	{
246 252
 		echo '
247 253
 						<select name="smiley_filename" id="smiley_filename" onchange="updatePreview();selectMethod(\'existing\');">';
248 254
 
249
-		foreach ($context['filenames'] as $filename)
250
-			echo '
255
+		foreach ($context['filenames'] as $filename) {
256
+					echo '
251 257
 							<option value="', $filename['id'], '"', $filename['selected'] ? ' selected' : '', '>', $filename['id'], '</option>';
258
+		}
252 259
 		echo '
253 260
 						</select>';
254 261
 	}
@@ -261,14 +268,15 @@  discard block
 block discarded – undo
261 268
 
262 269
 			<dl id="uploadMore" class="settings">';
263 270
 
264
-	foreach ($context['smiley_sets'] as $smiley_set)
265
-		echo '
271
+	foreach ($context['smiley_sets'] as $smiley_set) {
272
+			echo '
266 273
 				<dt>
267 274
 					', sprintf($txt['smileys_add_upload_for'], '<strong>' . $smiley_set['name'] . '</strong>'), ':
268 275
 				</dt>
269 276
 				<dd>
270 277
 					<input type="file" name="individual_', $smiley_set['name'], '" onchange="selectMethod(\'upload\');">
271 278
 				</dd>';
279
+	}
272 280
 
273 281
 	echo '
274 282
 			</dl>
@@ -336,27 +344,30 @@  discard block
 block discarded – undo
336 344
 
337 345
 		foreach ($location['rows'] as $row)
338 346
 		{
339
-			if (!empty($context['move_smiley']))
340
-				echo '
347
+			if (!empty($context['move_smiley'])) {
348
+							echo '
341 349
 			<a href="', $scripturl, '?action=admin;area=smileys;sa=setorder;location=', $location['id'], ';source=', $context['move_smiley'], ';row=', $row[0]['row'], ';reorder=1;', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons select_below" title="', $txt['smileys_move_here'], '"></span></a>';
350
+			}
342 351
 
343 352
 			foreach ($row as $smiley)
344 353
 			{
345
-				if (empty($context['move_smiley']))
346
-					echo '
354
+				if (empty($context['move_smiley'])) {
355
+									echo '
347 356
 			<a href="', $scripturl, '?action=admin;area=smileys;sa=setorder;move=', $smiley['id'], '"><img src="', $modSettings['smileys_url'], '/', $modSettings['smiley_sets_default'], '/', $smiley['filename'], '" alt="', $smiley['description'], '"></a>';
348
-				else
349
-					echo '
357
+				} else {
358
+									echo '
350 359
 			<img src="', $modSettings['smileys_url'], '/', $modSettings['smiley_sets_default'], '/', $smiley['filename'], '" alt="', $smiley['description'], '" ', $smiley['selected'] ? 'class="selected_item"' : '', '>
351 360
 			<a href="', $scripturl, '?action=admin;area=smileys;sa=setorder;location=', $location['id'], ';source=', $context['move_smiley'], ';after=', $smiley['id'], ';reorder=1;', $context['session_var'], '=', $context['session_id'], '" title="', $txt['smileys_move_here'], '"><span class="generic_icons select_below" title="', $txt['smileys_move_here'], '"></span></a>';
361
+				}
352 362
 			}
353 363
 
354 364
 			echo '
355 365
 			<br>';
356 366
 		}
357
-		if (!empty($context['move_smiley']))
358
-			echo '
367
+		if (!empty($context['move_smiley'])) {
368
+					echo '
359 369
 			<a href="', $scripturl, '?action=admin;area=smileys;sa=setorder;location=', $location['id'], ';source=', $context['move_smiley'], ';row=', $location['last_row'], ';reorder=1;', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons select_below" title="', $txt['smileys_move_here'], '"></span></a>';
370
+		}
360 371
 		echo '
361 372
 		</div><!-- .windowbg -->
362 373
 		<input type="hidden" name="reorder" value="1">
@@ -389,14 +400,15 @@  discard block
 block discarded – undo
389 400
 		<div class="windowbg">
390 401
 			<dl class="settings">';
391 402
 
392
-	if (!$context['new_icon'])
393
-		echo '
403
+	if (!$context['new_icon']) {
404
+			echo '
394 405
 				<dt>
395 406
 					<strong>', $txt['smiley_preview'], ': </strong>
396 407
 				</dt>
397 408
 				<dd>
398 409
 					<img src="', $context['icon']['image_url'], '" alt="', $context['icon']['title'], '">
399 410
 				</dd>';
411
+	}
400 412
 
401 413
 	echo '
402 414
 				<dt>
@@ -423,9 +435,10 @@  discard block
 block discarded – undo
423 435
 		echo '
424 436
 						<optgroup label="', $category['name'], '">';
425 437
 
426
-		foreach ($category['boards'] as $board)
427
-			echo '
438
+		foreach ($category['boards'] as $board) {
439
+					echo '
428 440
 							<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=&gt;' : '', ' ', $board['name'], '</option>';
441
+		}
429 442
 
430 443
 		echo '
431 444
 						</optgroup>';
@@ -442,19 +455,21 @@  discard block
 block discarded – undo
442 455
 						<option value="0"', empty($context['icon']['after']) ? ' selected' : '', '>', $txt['icons_location_first_icon'], '</option>';
443 456
 
444 457
 	// Print the list of all the icons it can be put after...
445
-	foreach ($context['icons'] as $id => $data)
446
-		if (empty($context['icon']['id']) || $id != $context['icon']['id'])
458
+	foreach ($context['icons'] as $id => $data) {
459
+			if (empty($context['icon']['id']) || $id != $context['icon']['id'])
447 460
 			echo '
448 461
 						<option value="', $id, '"', !empty($context['icon']['after']) && $id == $context['icon']['after'] ? ' selected' : '', '>', $txt['icons_location_after'], ': ', $data['title'], '</option>';
462
+	}
449 463
 
450 464
 	echo '
451 465
 					</select>
452 466
 				</dd>
453 467
 			</dl>';
454 468
 
455
-	if (!$context['new_icon'])
456
-		echo '
469
+	if (!$context['new_icon']) {
470
+			echo '
457 471
 			<input type="hidden" name="icon" value="', $context['icon']['id'], '">';
472
+	}
458 473
 
459 474
 	echo '
460 475
 			<input type="submit" name="icons_save" value="', $txt['smileys_save'], '" class="button">
Please login to merge, or discard this patch.
Sources/LogInOut.php 1 patch
Braces   +154 added lines, -121 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 4
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * Ask them for their login information. (shows a page for the user to type
@@ -29,8 +30,9 @@  discard block
 block discarded – undo
29 30
 	global $txt, $context, $scripturl, $user_info;
30 31
 
31 32
 	// You are already logged in, go take a tour of the boards
32
-	if (!empty($user_info['id']))
33
-		redirectexit();
33
+	if (!empty($user_info['id'])) {
34
+			redirectexit();
35
+	}
34 36
 
35 37
 	// We need to load the Login template/language file.
36 38
 	loadLanguage('Login');
@@ -57,10 +59,11 @@  discard block
 block discarded – undo
57 59
 	);
58 60
 
59 61
 	// Set the login URL - will be used when the login process is done (but careful not to send us to an attachment).
60
-	if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0)
61
-		$_SESSION['login_url'] = $_SESSION['old_url'];
62
-	elseif (isset($_SESSION['login_url']) && strpos($_SESSION['login_url'], 'dlattach') !== false)
63
-		unset($_SESSION['login_url']);
62
+	if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) {
63
+			$_SESSION['login_url'] = $_SESSION['old_url'];
64
+	} elseif (isset($_SESSION['login_url']) && strpos($_SESSION['login_url'], 'dlattach') !== false) {
65
+			unset($_SESSION['login_url']);
66
+	}
64 67
 
65 68
 	// Create a one time token.
66 69
 	createToken('login');
@@ -83,8 +86,9 @@  discard block
 block discarded – undo
83 86
 	global $cookiename, $modSettings, $context, $sourcedir, $maintenance;
84 87
 
85 88
 	// Check to ensure we're forcing SSL for authentication
86
-	if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn())
87
-		fatal_lang_error('login_ssl_required');
89
+	if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) {
90
+			fatal_lang_error('login_ssl_required');
91
+	}
88 92
 
89 93
 	// Load cookie authentication stuff.
90 94
 	require_once($sourcedir . '/Subs-Auth.php');
@@ -98,23 +102,26 @@  discard block
 block discarded – undo
98 102
 	if (isset($_GET['sa']) && $_GET['sa'] == 'salt' && !$user_info['is_guest'])
99 103
 	{
100 104
 		// First check for 2.1 json-format cookie in $_COOKIE
101
-		if (isset($_COOKIE[$cookiename]) && preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+~', $_COOKIE[$cookiename]) === 1)
102
-			list (,, $timeout) = $smcFunc['json_decode']($_COOKIE[$cookiename], true);
105
+		if (isset($_COOKIE[$cookiename]) && preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+~', $_COOKIE[$cookiename]) === 1) {
106
+					list (,, $timeout) = $smcFunc['json_decode']($_COOKIE[$cookiename], true);
107
+		}
103 108
 
104 109
 		// Try checking for 2.1 json-format cookie in $_SESSION
105
-		elseif (isset($_SESSION['login_' . $cookiename]) && preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+~', $_SESSION['login_' . $cookiename]) === 1)
106
-			list (,, $timeout) = $smcFunc['json_decode']($_SESSION['login_' . $cookiename]);
110
+		elseif (isset($_SESSION['login_' . $cookiename]) && preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+~', $_SESSION['login_' . $cookiename]) === 1) {
111
+					list (,, $timeout) = $smcFunc['json_decode']($_SESSION['login_' . $cookiename]);
112
+		}
107 113
 
108 114
 		// Next, try checking for 2.0 serialized string cookie in $_COOKIE
109
-		elseif (isset($_COOKIE[$cookiename]) && preg_match('~^a:[34]:\{i:0;i:\d+;i:1;s:(0|128):"([a-fA-F0-9]{128})?";i:2;[id]:\d+;~', $_COOKIE[$cookiename]) === 1)
110
-			list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]);
115
+		elseif (isset($_COOKIE[$cookiename]) && preg_match('~^a:[34]:\{i:0;i:\d+;i:1;s:(0|128):"([a-fA-F0-9]{128})?";i:2;[id]:\d+;~', $_COOKIE[$cookiename]) === 1) {
116
+					list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]);
117
+		}
111 118
 
112 119
 		// Last, see if you need to fall back on checking for 2.0 serialized string cookie in $_SESSION
113
-		elseif (isset($_SESSION['login_' . $cookiename]) && preg_match('~^a:[34]:\{i:0;i:\d+;i:1;s:(0|128):"([a-fA-F0-9]{128})?";i:2;[id]:\d+;~', $_SESSION['login_' . $cookiename]) === 1)
114
-			list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]);
115
-
116
-		else
117
-			trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR);
120
+		elseif (isset($_SESSION['login_' . $cookiename]) && preg_match('~^a:[34]:\{i:0;i:\d+;i:1;s:(0|128):"([a-fA-F0-9]{128})?";i:2;[id]:\d+;~', $_SESSION['login_' . $cookiename]) === 1) {
121
+					list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]);
122
+		} else {
123
+					trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR);
124
+		}
118 125
 
119 126
 		$user_settings['password_salt'] = substr(md5(mt_rand()), 0, 4);
120 127
 		updateMemberData($user_info['id'], array('password_salt' => $user_settings['password_salt']));
@@ -134,24 +141,23 @@  discard block
 block discarded – undo
134 141
 	elseif (isset($_GET['sa']) && $_GET['sa'] == 'check')
135 142
 	{
136 143
 		// Strike!  You're outta there!
137
-		if ($_GET['member'] != $user_info['id'])
138
-			fatal_lang_error('login_cookie_error', false);
144
+		if ($_GET['member'] != $user_info['id']) {
145
+					fatal_lang_error('login_cookie_error', false);
146
+		}
139 147
 
140 148
 		$user_info['can_mod'] = allowedTo('access_mod_center') || (!$user_info['is_guest'] && ($user_info['mod_cache']['gq'] != '0=1' || $user_info['mod_cache']['bq'] != '0=1' || ($modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap']))));
141 149
 
142 150
 		// Some whitelisting for login_url...
143
-		if (empty($_SESSION['login_url']))
144
-			redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa');
145
-		elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false))
151
+		if (empty($_SESSION['login_url'])) {
152
+					redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa');
153
+		} elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false))
146 154
 		{
147 155
 			unset ($_SESSION['login_url']);
148 156
 			redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa');
149
-		}
150
-		elseif (!empty($user_settings['tfa_secret']))
157
+		} elseif (!empty($user_settings['tfa_secret']))
151 158
 		{
152 159
 			redirectexit('action=logintfa');
153
-		}
154
-		else
160
+		} else
155 161
 		{
156 162
 			// Best not to clutter the session data too much...
157 163
 			$temp = $_SESSION['login_url'];
@@ -162,8 +168,9 @@  discard block
 block discarded – undo
162 168
 	}
163 169
 
164 170
 	// Beyond this point you are assumed to be a guest trying to login.
165
-	if (!$user_info['is_guest'])
166
-		redirectexit();
171
+	if (!$user_info['is_guest']) {
172
+			redirectexit();
173
+	}
167 174
 
168 175
 	// Are you guessing with a script?
169 176
 	checkSession();
@@ -171,18 +178,21 @@  discard block
 block discarded – undo
171 178
 	spamProtection('login');
172 179
 
173 180
 	// Set the login_url if it's not already set (but careful not to send us to an attachment).
174
-	if ((empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) || (isset($_GET['quicklogin']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'login') === false))
175
-		$_SESSION['login_url'] = $_SESSION['old_url'];
181
+	if ((empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) || (isset($_GET['quicklogin']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'login') === false)) {
182
+			$_SESSION['login_url'] = $_SESSION['old_url'];
183
+	}
176 184
 
177 185
 	// Been guessing a lot, haven't we?
178
-	if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3)
179
-		fatal_lang_error('login_threshold_fail', 'login');
186
+	if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3) {
187
+			fatal_lang_error('login_threshold_fail', 'login');
188
+	}
180 189
 
181 190
 	// Set up the cookie length.  (if it's invalid, just fall through and use the default.)
182
-	if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1))
183
-		$modSettings['cookieTime'] = 3153600;
184
-	elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 3153600))
185
-		$modSettings['cookieTime'] = (int) $_POST['cookielength'];
191
+	if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1)) {
192
+			$modSettings['cookieTime'] = 3153600;
193
+	} elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 3153600)) {
194
+			$modSettings['cookieTime'] = (int) $_POST['cookielength'];
195
+	}
186 196
 
187 197
 	loadLanguage('Login');
188 198
 	// Load the template stuff.
@@ -302,8 +312,9 @@  discard block
 block discarded – undo
302 312
 			$other_passwords[] = crypt(md5($_POST['passwrd']), md5($_POST['passwrd']));
303 313
 
304 314
 			// Snitz style - SHA-256.  Technically, this is a downgrade, but most PHP configurations don't support sha256 anyway.
305
-			if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256'))
306
-				$other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd']));
315
+			if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256')) {
316
+							$other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd']));
317
+			}
307 318
 
308 319
 			// phpBB3 users new hashing.  We now support it as well ;).
309 320
 			$other_passwords[] = phpBB3_password_check($_POST['passwrd'], $user_settings['passwd']);
@@ -323,27 +334,29 @@  discard block
 block discarded – undo
323 334
 			// Some common md5 ones.
324 335
 			$other_passwords[] = md5($user_settings['password_salt'] . $_POST['passwrd']);
325 336
 			$other_passwords[] = md5($_POST['passwrd'] . $user_settings['password_salt']);
326
-		}
327
-		elseif (strlen($user_settings['passwd']) == 40)
337
+		} elseif (strlen($user_settings['passwd']) == 40)
328 338
 		{
329 339
 			// Maybe they are using a hash from before the password fix.
330 340
 			// This is also valid for SMF 1.1 to 2.0 style of hashing, changed to bcrypt in SMF 2.1
331 341
 			$other_passwords[] = sha1(strtolower($user_settings['member_name']) . un_htmlspecialchars($_POST['passwrd']));
332 342
 
333 343
 			// BurningBoard3 style of hashing.
334
-			if (!empty($modSettings['enable_password_conversion']))
335
-				$other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd'])));
344
+			if (!empty($modSettings['enable_password_conversion'])) {
345
+							$other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd'])));
346
+			}
336 347
 
337 348
 			// Perhaps we converted to UTF-8 and have a valid password being hashed differently.
338 349
 			if ($context['character_set'] == 'UTF-8' && !empty($modSettings['previousCharacterSet']) && $modSettings['previousCharacterSet'] != 'utf8')
339 350
 			{
340 351
 				// Try iconv first, for no particular reason.
341
-				if (function_exists('iconv'))
342
-					$other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd'])));
352
+				if (function_exists('iconv')) {
353
+									$other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd'])));
354
+				}
343 355
 
344 356
 				// Say it aint so, iconv failed!
345
-				if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding'))
346
-					$other_passwords[] = sha1(strtolower(mb_convert_encoding($user_settings['member_name'], 'UTF-8', $modSettings['previousCharacterSet'])) . un_htmlspecialchars(mb_convert_encoding($_POST['passwrd'], 'UTF-8', $modSettings['previousCharacterSet'])));
357
+				if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding')) {
358
+									$other_passwords[] = sha1(strtolower(mb_convert_encoding($user_settings['member_name'], 'UTF-8', $modSettings['previousCharacterSet'])) . un_htmlspecialchars(mb_convert_encoding($_POST['passwrd'], 'UTF-8', $modSettings['previousCharacterSet'])));
359
+				}
347 360
 			}
348 361
 		}
349 362
 
@@ -373,8 +386,9 @@  discard block
 block discarded – undo
373 386
 			$_SESSION['failed_login'] = isset($_SESSION['failed_login']) ? ($_SESSION['failed_login'] + 1) : 1;
374 387
 
375 388
 			// Hmm... don't remember it, do you?  Here, try the password reminder ;).
376
-			if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold'])
377
-				redirectexit('action=reminder');
389
+			if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold']) {
390
+							redirectexit('action=reminder');
391
+			}
378 392
 			// We'll give you another chance...
379 393
 			else
380 394
 			{
@@ -385,8 +399,7 @@  discard block
 block discarded – undo
385 399
 				return;
386 400
 			}
387 401
 		}
388
-	}
389
-	elseif (!empty($user_settings['passwd_flood']))
402
+	} elseif (!empty($user_settings['passwd_flood']))
390 403
 	{
391 404
 		// Let's be sure they weren't a little hacker.
392 405
 		validatePasswordFlood($user_settings['id_member'], $user_settings['member_name'], $user_settings['passwd_flood'], true);
@@ -403,8 +416,9 @@  discard block
 block discarded – undo
403 416
 	}
404 417
 
405 418
 	// Check their activation status.
406
-	if (!checkActivation())
407
-		return;
419
+	if (!checkActivation()) {
420
+			return;
421
+	}
408 422
 
409 423
 	DoLogin();
410 424
 }
@@ -416,8 +430,9 @@  discard block
 block discarded – undo
416 430
 {
417 431
 	global $sourcedir, $txt, $context, $user_info, $modSettings, $scripturl;
418 432
 
419
-	if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode']))
420
-		fatal_lang_error('no_access', false);
433
+	if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode'])) {
434
+			fatal_lang_error('no_access', false);
435
+	}
421 436
 
422 437
 	loadLanguage('Profile');
423 438
 	require_once($sourcedir . '/Class-TOTP.php');
@@ -425,8 +440,9 @@  discard block
 block discarded – undo
425 440
 	$member = $context['tfa_member'];
426 441
 
427 442
 	// Prevent replay attacks by limiting at least 2 minutes before they can log in again via 2FA
428
-	if (time() - $member['last_login'] < 120)
429
-		fatal_lang_error('tfa_wait', false);
443
+	if (time() - $member['last_login'] < 120) {
444
+			fatal_lang_error('tfa_wait', false);
445
+	}
430 446
 
431 447
 	$totp = new \TOTP\Auth($member['tfa_secret']);
432 448
 	$totp->setRange(1);
@@ -440,8 +456,9 @@  discard block
 block discarded – undo
440 456
 	if (!empty($_POST['tfa_code']) && empty($_POST['tfa_backup']))
441 457
 	{
442 458
 		// Check to ensure we're forcing SSL for authentication
443
-		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn())
444
-			fatal_lang_error('login_ssl_required');
459
+		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) {
460
+					fatal_lang_error('login_ssl_required');
461
+		}
445 462
 
446 463
 		$code = $_POST['tfa_code'];
447 464
 
@@ -451,20 +468,19 @@  discard block
 block discarded – undo
451 468
 
452 469
 			setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt']));
453 470
 			redirectexit();
454
-		}
455
-		else
471
+		} else
456 472
 		{
457 473
 			validatePasswordFlood($member['id_member'], $member['member_name'], $member['passwd_flood'], false, true);
458 474
 
459 475
 			$context['tfa_error'] = true;
460 476
 			$context['tfa_value'] = $_POST['tfa_code'];
461 477
 		}
462
-	}
463
-	elseif (!empty($_POST['tfa_backup']))
478
+	} elseif (!empty($_POST['tfa_backup']))
464 479
 	{
465 480
 		// Check to ensure we're forcing SSL for authentication
466
-		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn())
467
-			fatal_lang_error('login_ssl_required');
481
+		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) {
482
+					fatal_lang_error('login_ssl_required');
483
+		}
468 484
 
469 485
 		$backup = $_POST['tfa_backup'];
470 486
 
@@ -478,8 +494,7 @@  discard block
 block discarded – undo
478 494
 			));
479 495
 			setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt']));
480 496
 			redirectexit('action=profile;area=tfasetup;backup');
481
-		}
482
-		else
497
+		} else
483 498
 		{
484 499
 			validatePasswordFlood($member['id_member'], $member['member_name'], $member['passwd_flood'], false, true);
485 500
 
@@ -502,8 +517,9 @@  discard block
 block discarded – undo
502 517
 {
503 518
 	global $context, $txt, $scripturl, $user_settings, $modSettings;
504 519
 
505
-	if (!isset($context['login_errors']))
506
-		$context['login_errors'] = array();
520
+	if (!isset($context['login_errors'])) {
521
+			$context['login_errors'] = array();
522
+	}
507 523
 
508 524
 	// What is the true activation status of this account?
509 525
 	$activation_status = $user_settings['is_activated'] > 10 ? $user_settings['is_activated'] - 10 : $user_settings['is_activated'];
@@ -515,8 +531,9 @@  discard block
 block discarded – undo
515 531
 		return false;
516 532
 	}
517 533
 	// Awaiting approval still?
518
-	elseif ($activation_status == 3)
519
-		fatal_lang_error('still_awaiting_approval', 'user');
534
+	elseif ($activation_status == 3) {
535
+			fatal_lang_error('still_awaiting_approval', 'user');
536
+	}
520 537
 	// Awaiting deletion, changed their mind?
521 538
 	elseif ($activation_status == 4)
522 539
 	{
@@ -524,8 +541,7 @@  discard block
 block discarded – undo
524 541
 		{
525 542
 			updateMemberData($user_settings['id_member'], array('is_activated' => 1));
526 543
 			updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 0 ? $modSettings['unapprovedMembers'] - 1 : 0)));
527
-		}
528
-		else
544
+		} else
529 545
 		{
530 546
 			$context['disable_login_hashing'] = true;
531 547
 			$context['login_errors'][] = $txt['awaiting_delete_account'];
@@ -565,8 +581,9 @@  discard block
 block discarded – undo
565 581
 	setLoginCookie(60 * $modSettings['cookieTime'], $user_settings['id_member'], hash_salt($user_settings['passwd'], $user_settings['password_salt']));
566 582
 
567 583
 	// Reset the login threshold.
568
-	if (isset($_SESSION['failed_login']))
569
-		unset($_SESSION['failed_login']);
584
+	if (isset($_SESSION['failed_login'])) {
585
+			unset($_SESSION['failed_login']);
586
+	}
570 587
 
571 588
 	$user_info['is_guest'] = false;
572 589
 	$user_settings['additional_groups'] = explode(',', $user_settings['additional_groups']);
@@ -588,16 +605,18 @@  discard block
 block discarded – undo
588 605
 			'id_member' => $user_info['id'],
589 606
 		)
590 607
 	);
591
-	if ($smcFunc['db_num_rows']($request) == 1)
592
-		$_SESSION['first_login'] = true;
593
-	else
594
-		unset($_SESSION['first_login']);
608
+	if ($smcFunc['db_num_rows']($request) == 1) {
609
+			$_SESSION['first_login'] = true;
610
+	} else {
611
+			unset($_SESSION['first_login']);
612
+	}
595 613
 	$smcFunc['db_free_result']($request);
596 614
 
597 615
 	// You've logged in, haven't you?
598 616
 	$update = array('member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP']);
599
-	if (empty($user_settings['tfa_secret']))
600
-		$update['last_login'] = time();
617
+	if (empty($user_settings['tfa_secret'])) {
618
+			$update['last_login'] = time();
619
+	}
601 620
 	updateMemberData($user_info['id'], $update);
602 621
 
603 622
 	// Get rid of the online entry for that old guest....
@@ -611,8 +630,8 @@  discard block
 block discarded – undo
611 630
 	$_SESSION['log_time'] = 0;
612 631
 
613 632
 	// Log this entry, only if we have it enabled.
614
-	if (!empty($modSettings['loginHistoryDays']))
615
-		$smcFunc['db_insert']('insert',
633
+	if (!empty($modSettings['loginHistoryDays'])) {
634
+			$smcFunc['db_insert']('insert',
616 635
 			'{db_prefix}member_logins',
617 636
 			array(
618 637
 				'id_member' => 'int', 'time' => 'int', 'ip' => 'inet', 'ip2' => 'inet',
@@ -624,13 +643,15 @@  discard block
 block discarded – undo
624 643
 				'id_member', 'time'
625 644
 			)
626 645
 		);
646
+	}
627 647
 
628 648
 	// Just log you back out if it's in maintenance mode and you AREN'T an admin.
629
-	if (empty($maintenance) || allowedTo('admin_forum'))
630
-		redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']);
631
-	else
632
-		redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']);
633
-}
649
+	if (empty($maintenance) || allowedTo('admin_forum')) {
650
+			redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']);
651
+	} else {
652
+			redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']);
653
+	}
654
+	}
634 655
 
635 656
 /**
636 657
  * Logs the current user out of their account.
@@ -646,13 +667,15 @@  discard block
 block discarded – undo
646 667
 	global $sourcedir, $user_info, $user_settings, $context, $smcFunc, $cookiename, $modSettings;
647 668
 
648 669
 	// Make sure they aren't being auto-logged out.
649
-	if (!$internal)
650
-		checkSession('get');
670
+	if (!$internal) {
671
+			checkSession('get');
672
+	}
651 673
 
652 674
 	require_once($sourcedir . '/Subs-Auth.php');
653 675
 
654
-	if (isset($_SESSION['pack_ftp']))
655
-		$_SESSION['pack_ftp'] = null;
676
+	if (isset($_SESSION['pack_ftp'])) {
677
+			$_SESSION['pack_ftp'] = null;
678
+	}
656 679
 
657 680
 	// It won't be first login anymore.
658 681
 	unset($_SESSION['first_login']);
@@ -680,8 +703,9 @@  discard block
 block discarded – undo
680 703
 
681 704
 	// And some other housekeeping while we're at it.
682 705
 	$salt = substr(md5(mt_rand()), 0, 4);
683
-	if (!empty($user_info['id']))
684
-		updateMemberData($user_info['id'], array('password_salt' => $salt));
706
+	if (!empty($user_info['id'])) {
707
+			updateMemberData($user_info['id'], array('password_salt' => $salt));
708
+	}
685 709
 
686 710
 	if (!empty($modSettings['tfa_mode']) && !empty($user_info['id']) && !empty($_COOKIE[$cookiename . '_tfa']))
687 711
 	{
@@ -694,14 +718,13 @@  discard block
 block discarded – undo
694 718
 	// Off to the merry board index we go!
695 719
 	if ($redirect)
696 720
 	{
697
-		if (empty($_SESSION['logout_url']))
698
-			redirectexit('', $context['server']['needs_login_fix']);
699
-		elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false))
721
+		if (empty($_SESSION['logout_url'])) {
722
+					redirectexit('', $context['server']['needs_login_fix']);
723
+		} elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false))
700 724
 		{
701 725
 			unset ($_SESSION['logout_url']);
702 726
 			redirectexit();
703
-		}
704
-		else
727
+		} else
705 728
 		{
706 729
 			$temp = $_SESSION['logout_url'];
707 730
 			unset($_SESSION['logout_url']);
@@ -734,8 +757,9 @@  discard block
 block discarded – undo
734 757
 function phpBB3_password_check($passwd, $passwd_hash)
735 758
 {
736 759
 	// Too long or too short?
737
-	if (strlen($passwd_hash) != 34)
738
-		return;
760
+	if (strlen($passwd_hash) != 34) {
761
+			return;
762
+	}
739 763
 
740 764
 	// Range of characters allowed.
741 765
 	$range = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
@@ -746,8 +770,9 @@  discard block
 block discarded – undo
746 770
 	$salt = substr($passwd_hash, 4, 8);
747 771
 
748 772
 	$hash = md5($salt . $passwd, true);
749
-	for (; $count != 0; --$count)
750
-		$hash = md5($hash . $passwd, true);
773
+	for (; $count != 0; --$count) {
774
+			$hash = md5($hash . $passwd, true);
775
+	}
751 776
 
752 777
 	$output = substr($passwd_hash, 0, 12);
753 778
 	$i = 0;
@@ -756,21 +781,25 @@  discard block
 block discarded – undo
756 781
 		$value = ord($hash[$i++]);
757 782
 		$output .= $range[$value & 0x3f];
758 783
 
759
-		if ($i < 16)
760
-			$value |= ord($hash[$i]) << 8;
784
+		if ($i < 16) {
785
+					$value |= ord($hash[$i]) << 8;
786
+		}
761 787
 
762 788
 		$output .= $range[($value >> 6) & 0x3f];
763 789
 
764
-		if ($i++ >= 16)
765
-			break;
790
+		if ($i++ >= 16) {
791
+					break;
792
+		}
766 793
 
767
-		if ($i < 16)
768
-			$value |= ord($hash[$i]) << 16;
794
+		if ($i < 16) {
795
+					$value |= ord($hash[$i]) << 16;
796
+		}
769 797
 
770 798
 		$output .= $range[($value >> 12) & 0x3f];
771 799
 
772
-		if ($i++ >= 16)
773
-			break;
800
+		if ($i++ >= 16) {
801
+					break;
802
+		}
774 803
 
775 804
 		$output .= $range[($value >> 18) & 0x3f];
776 805
 	}
@@ -802,8 +831,9 @@  discard block
 block discarded – undo
802 831
 		require_once($sourcedir . '/Subs-Auth.php');
803 832
 		setLoginCookie(-3600, 0);
804 833
 
805
-		if (isset($_SESSION['login_' . $cookiename]))
806
-			unset($_SESSION['login_' . $cookiename]);
834
+		if (isset($_SESSION['login_' . $cookiename])) {
835
+					unset($_SESSION['login_' . $cookiename]);
836
+		}
807 837
 	}
808 838
 
809 839
 	// We need a member!
@@ -817,8 +847,9 @@  discard block
 block discarded – undo
817 847
 	}
818 848
 
819 849
 	// Right, have we got a flood value?
820
-	if ($password_flood_value !== false)
821
-		@list ($time_stamp, $number_tries) = explode('|', $password_flood_value);
850
+	if ($password_flood_value !== false) {
851
+			@list ($time_stamp, $number_tries) = explode('|', $password_flood_value);
852
+	}
822 853
 
823 854
 	// Timestamp or number of tries invalid?
824 855
 	if (empty($number_tries) || empty($time_stamp))
@@ -834,15 +865,17 @@  discard block
 block discarded – undo
834 865
 		$number_tries = $time_stamp < time() - 20 ? 2 : $number_tries;
835 866
 
836 867
 		// They are trying too fast, make them wait longer
837
-		if ($time_stamp < time() - 10)
838
-			$time_stamp = time();
868
+		if ($time_stamp < time() - 10) {
869
+					$time_stamp = time();
870
+		}
839 871
 	}
840 872
 
841 873
 	$number_tries++;
842 874
 
843 875
 	// Broken the law?
844
-	if ($number_tries > 5)
845
-		fatal_lang_error('login_threshold_brute_fail', 'login', [$member_name]);
876
+	if ($number_tries > 5) {
877
+			fatal_lang_error('login_threshold_brute_fail', 'login', [$member_name]);
878
+	}
846 879
 
847 880
 	// Otherwise set the members data. If they correct on their first attempt then we actually clear it, otherwise we set it!
848 881
 	updateMemberData($id_member, array('passwd_flood' => $was_correct && $number_tries == 1 ? '' : $time_stamp . '|' . $number_tries));
Please login to merge, or discard this patch.
Themes/default/GenericControls.template.php 1 patch
Braces   +74 added lines, -54 removed lines patch added patch discarded remove patch
@@ -23,11 +23,13 @@  discard block
 block discarded – undo
23 23
 
24 24
 	$editor_context = &$context['controls']['richedit'][$editor_id];
25 25
 
26
-	if ($smileyContainer === null)
27
-		$editor_context['sce_options']['emoticonsEnabled'] = false;
26
+	if ($smileyContainer === null) {
27
+			$editor_context['sce_options']['emoticonsEnabled'] = false;
28
+	}
28 29
 
29
-	if ($bbcContainer === null)
30
-		$editor_context['sce_options']['toolbar'] = '';
30
+	if ($bbcContainer === null) {
31
+			$editor_context['sce_options']['toolbar'] = '';
32
+	}
31 33
 
32 34
 	echo '
33 35
 		<textarea class="editor" name="', $editor_id, '" id="', $editor_id, '" cols="600" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);" onchange="storeCaret(this);" tabindex="', $context['tabindex']++, '" style="width: ', $editor_context['width'], '; height: ', $editor_context['height'], ';', isset($context['post_error']['no_message']) || isset($context['post_error']['long_message']) ? 'border: 1px solid red;' : '', '"', !empty($context['editor']['required']) ? ' required' : '', '>', $editor_context['value'], '</textarea>
@@ -40,18 +42,21 @@  discard block
 block discarded – undo
40 42
 				var textarea = $("#', $editor_id, '").get(0);
41 43
 				sceditor.create(textarea, ', $smcFunc['json_encode']($editor_context['sce_options'], JSON_PRETTY_PRINT), ');';
42 44
 
43
-	if ($editor_context['sce_options']['emoticonsEnabled'])
44
-		echo '
45
+	if ($editor_context['sce_options']['emoticonsEnabled']) {
46
+			echo '
45 47
 				sceditor.instance(textarea).createPermanentDropDown();';
48
+	}
46 49
 
47
-	if (empty($editor_context['rich_active']))
48
-		echo '
50
+	if (empty($editor_context['rich_active'])) {
51
+			echo '
49 52
 				sceditor.instance(textarea).toggleSourceMode();';
53
+	}
50 54
 
51
-	if (isset($context['post_error']['no_message']) || isset($context['post_error']['long_message']))
52
-		echo '
55
+	if (isset($context['post_error']['no_message']) || isset($context['post_error']['long_message'])) {
56
+			echo '
53 57
 				$(".sceditor-container").find("textarea").each(function() {$(this).css({border: "1px solid red"})});
54 58
 				$(".sceditor-container").find("iframe").each(function() {$(this).css({border: "1px solid red"})});';
59
+	}
55 60
 
56 61
 	echo '
57 62
 			});';
@@ -88,42 +93,47 @@  discard block
 block discarded – undo
88 93
 
89 94
 	$tempTab = $context['tabindex'];
90 95
 
91
-	if (!empty($context['drafts_pm_save']))
92
-		$tempTab++;
93
-	elseif (!empty($context['drafts_save']))
94
-		$tempTab++;
95
-	elseif ($editor_context['preview_type'])
96
-		$tempTab++;
97
-	elseif ($context['show_spellchecking'])
98
-		$tempTab++;
96
+	if (!empty($context['drafts_pm_save'])) {
97
+			$tempTab++;
98
+	} elseif (!empty($context['drafts_save'])) {
99
+			$tempTab++;
100
+	} elseif ($editor_context['preview_type']) {
101
+			$tempTab++;
102
+	} elseif ($context['show_spellchecking']) {
103
+			$tempTab++;
104
+	}
99 105
 
100 106
 	$tempTab++;
101 107
 	$context['tabindex'] = $tempTab;
102 108
 
103
-	if (!empty($context['drafts_pm_save']))
104
-		echo '
109
+	if (!empty($context['drafts_pm_save'])) {
110
+			echo '
105 111
 		<input type="submit" name="save_draft" value="', $txt['draft_save'], '" tabindex="', --$tempTab, '" onclick="submitThisOnce(this);" accesskey="d" class="button">
106 112
 		<input type="hidden" id="id_pm_draft" name="id_pm_draft" value="', empty($context['id_pm_draft']) ? 0 : $context['id_pm_draft'], '">';
113
+	}
107 114
 
108
-	if (!empty($context['drafts_save']))
109
-		echo '
115
+	if (!empty($context['drafts_save'])) {
116
+			echo '
110 117
 		<input type="submit" name="save_draft" value="', $txt['draft_save'], '" tabindex="', --$tempTab, '" onclick="return confirm(' . JavaScriptEscape($txt['draft_save_note']) . ') && submitThisOnce(this);" accesskey="d" class="button">
111 118
 		<input type="hidden" id="id_draft" name="id_draft" value="', empty($context['id_draft']) ? 0 : $context['id_draft'], '">';
119
+	}
112 120
 
113
-	if ($context['show_spellchecking'])
114
-		echo '
121
+	if ($context['show_spellchecking']) {
122
+			echo '
115 123
 		<input type="button" value="', $txt['spell_check'], '" tabindex="', --$tempTab, '" onclick="oEditorHandle_', $editor_id, '.spellCheckStart();" class="button">';
124
+	}
116 125
 
117
-	if ($editor_context['preview_type'])
118
-		echo '
126
+	if ($editor_context['preview_type']) {
127
+			echo '
119 128
 		<input type="submit" name="preview" value="', isset($editor_context['labels']['preview_button']) ? $editor_context['labels']['preview_button'] : $txt['preview'], '" tabindex="', --$tempTab, '" onclick="', $editor_context['preview_type'] == 2 ? '' : 'return submitThisOnce(this);', '" accesskey="p" class="button">';
129
+	}
120 130
 
121 131
 	echo '
122 132
 		<input type="submit" value="', isset($editor_context['labels']['post_button']) ? $editor_context['labels']['post_button'] : $txt['post'], '" name="post" tabindex="', --$tempTab, '" onclick="return submitThisOnce(this);" accesskey="s" class="button">';
123 133
 
124 134
 	// Load in the PM autosaver if it's enabled
125
-	if (!empty($context['drafts_pm_save']) && !empty($context['drafts_autosave']))
126
-		echo '
135
+	if (!empty($context['drafts_pm_save']) && !empty($context['drafts_autosave'])) {
136
+			echo '
127 137
 		<span class="righttext padding" style="display: block">
128 138
 			<span id="throbber" style="display:none"><img src="' . $settings['images_url'] . '/loading_sm.gif" alt="" class="centericon"></span>
129 139
 			<span id="draft_lastautosave" ></span>
@@ -141,10 +151,11 @@  discard block
 block discarded – undo
141 151
 				iFreq: ', (empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000), '
142 152
 			});
143 153
 		</script>';
154
+	}
144 155
 
145 156
 	// Start an instance of the auto saver if its enabled
146
-	if (!empty($context['drafts_save']) && !empty($context['drafts_autosave']))
147
-		echo '
157
+	if (!empty($context['drafts_save']) && !empty($context['drafts_autosave'])) {
158
+			echo '
148 159
 		<span class="righttext padding" style="display: block">
149 160
 			<span id="throbber" style="display:none"><img src="', $settings['images_url'], '/loading_sm.gif" alt="" class="centericon"></span>
150 161
 			<span id="draft_lastautosave" ></span>
@@ -161,7 +172,8 @@  discard block
 block discarded – undo
161 172
 				iFreq: ', $context['drafts_autosave_frequency'], '
162 173
 			});
163 174
 		</script>';
164
-}
175
+	}
176
+	}
165 177
 
166 178
 /**
167 179
  * This template displays a verification form
@@ -178,51 +190,57 @@  discard block
 block discarded – undo
178 190
 	$verify_context = &$context['controls']['verification'][$verify_id];
179 191
 
180 192
 	// Keep track of where we are.
181
-	if (empty($verify_context['tracking']) || $reset)
182
-		$verify_context['tracking'] = 0;
193
+	if (empty($verify_context['tracking']) || $reset) {
194
+			$verify_context['tracking'] = 0;
195
+	}
183 196
 
184 197
 	// How many items are there to display in total.
185 198
 	$total_items = count($verify_context['questions']) + ($verify_context['show_visual'] || $verify_context['can_recaptcha'] ? 1 : 0);
186 199
 
187 200
 	// If we've gone too far, stop.
188
-	if ($verify_context['tracking'] > $total_items)
189
-		return false;
201
+	if ($verify_context['tracking'] > $total_items) {
202
+			return false;
203
+	}
190 204
 
191 205
 	// Loop through each item to show them.
192 206
 	for ($i = 0; $i < $total_items; $i++)
193 207
 	{
194 208
 		// If we're after a single item only show it if we're in the right place.
195
-		if ($display_type == 'single' && $verify_context['tracking'] != $i)
196
-			continue;
209
+		if ($display_type == 'single' && $verify_context['tracking'] != $i) {
210
+					continue;
211
+		}
197 212
 
198
-		if ($display_type != 'single')
199
-			echo '
213
+		if ($display_type != 'single') {
214
+					echo '
200 215
 			<div id="verification_control_', $i, '" class="verification_control">';
216
+		}
201 217
 
202 218
 		// Display empty field, but only if we have one, and it's the first time.
203
-		if ($verify_context['empty_field'] && empty($i))
204
-			echo '
219
+		if ($verify_context['empty_field'] && empty($i)) {
220
+					echo '
205 221
 				<div class="smalltext vv_special">
206 222
 					', $txt['visual_verification_hidden'], ':
207 223
 					<input type="text" name="', $_SESSION[$verify_id . '_vv']['empty_field'], '" autocomplete="off" size="30" value="">
208 224
 				</div>';
225
+		}
209 226
 
210 227
 		// Do the actual stuff
211 228
 		if ($i == 0 && ($verify_context['show_visual'] || $verify_context['can_recaptcha']))
212 229
 		{
213 230
 			if ($verify_context['show_visual'])
214 231
 			{
215
-				if ($context['use_graphic_library'])
216
-					echo '
232
+				if ($context['use_graphic_library']) {
233
+									echo '
217 234
 				<img src="', $verify_context['image_href'], '" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '">';
218
-				else
219
-					echo '
235
+				} else {
236
+									echo '
220 237
 				<img src="', $verify_context['image_href'], ';letter=1" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_1">
221 238
 				<img src="', $verify_context['image_href'], ';letter=2" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_2">
222 239
 				<img src="', $verify_context['image_href'], ';letter=3" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_3">
223 240
 				<img src="', $verify_context['image_href'], ';letter=4" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_4">
224 241
 				<img src="', $verify_context['image_href'], ';letter=5" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_5">
225 242
 				<img src="', $verify_context['image_href'], ';letter=6" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_6">';
243
+				}
226 244
 
227 245
 				echo '
228 246
 				<div class="smalltext" style="margin: 4px 0 8px 0;">
@@ -240,8 +258,7 @@  discard block
 block discarded – undo
240 258
 				<br>
241 259
 				<script type="text/javascript" src="https://www.google.com/recaptcha/api.js?hl='.$lang.'"></script>';
242 260
 			}
243
-		}
244
-		else
261
+		} else
245 262
 		{
246 263
 			// Where in the question array is this question?
247 264
 			$qIndex = $verify_context['show_visual'] ? $i - 1 : $i;
@@ -253,21 +270,24 @@  discard block
 block discarded – undo
253 270
 				</div>';
254 271
 		}
255 272
 
256
-		if ($display_type != 'single')
257
-			echo '
273
+		if ($display_type != 'single') {
274
+					echo '
258 275
 			</div><!-- #verification_control_[i] -->';
276
+		}
259 277
 
260 278
 		// If we were displaying just one and we did it, break.
261
-		if ($display_type == 'single' && $verify_context['tracking'] == $i)
262
-			break;
279
+		if ($display_type == 'single' && $verify_context['tracking'] == $i) {
280
+					break;
281
+		}
263 282
 	}
264 283
 
265 284
 	// Assume we found something, always.
266 285
 	$verify_context['tracking']++;
267 286
 
268 287
 	// Tell something displaying piecemeal to keep going.
269
-	if ($display_type == 'single')
270
-		return true;
271
-}
288
+	if ($display_type == 'single') {
289
+			return true;
290
+	}
291
+	}
272 292
 
273 293
 ?>
274 294
\ No newline at end of file
Please login to merge, or discard this patch.
Themes/default/Post.template.php 1 patch
Braces   +184 added lines, -131 removed lines patch added patch discarded remove patch
@@ -22,24 +22,26 @@  discard block
 block discarded – undo
22 22
 		<script>';
23 23
 
24 24
 	// When using Go Back due to fatal_error, allow the form to be re-submitted with changes.
25
-	if (isBrowser('is_firefox'))
26
-		echo '
25
+	if (isBrowser('is_firefox')) {
26
+			echo '
27 27
 			window.addEventListener("pageshow", reActivate, false);';
28
+	}
28 29
 
29 30
 	// Start with message icons - and any missing from this theme.
30 31
 	echo '
31 32
 			var icon_urls = {';
32 33
 
33
-	foreach ($context['icons'] as $icon)
34
-		echo '
34
+	foreach ($context['icons'] as $icon) {
35
+			echo '
35 36
 				\'', $icon['value'], '\': \'', $icon['url'], '\'', $icon['is_last'] ? '' : ',';
37
+	}
36 38
 
37 39
 	echo '
38 40
 			};';
39 41
 
40 42
 	// If this is a poll - use some javascript to ensure the user doesn't create a poll with illegal option combinations.
41
-	if ($context['make_poll'])
42
-		echo '
43
+	if ($context['make_poll']) {
44
+			echo '
43 45
 			var pollOptionNum = 0, pollTabIndex;
44 46
 			var pollOptionId = ', $context['last_choice_id'], ';
45 47
 			function addPollOption()
@@ -58,11 +60,13 @@  discard block
 block discarded – undo
58 60
 
59 61
 				setOuterHTML(document.getElementById(\'pollMoreOptions\'), ', JavaScriptEscape('<dt><label for="options-'), ' + pollOptionId + ', JavaScriptEscape('">' . $txt['option'] . ' '), ' + pollOptionNum + ', JavaScriptEscape('</label>:</dt><dd><input type="text" name="options['), ' + pollOptionId + ', JavaScriptEscape(']" id="options-'), ' + pollOptionId + ', JavaScriptEscape('" value="" size="80" maxlength="255" tabindex="'), ' + pollTabIndex + ', JavaScriptEscape('"></dd><p id="pollMoreOptions"></p>'), ');
60 62
 			}';
63
+	}
61 64
 
62 65
 	// If we are making a calendar event we want to ensure we show the current days in a month etc... this is done here.
63
-	if ($context['make_event'])
64
-		echo '
66
+	if ($context['make_event']) {
67
+			echo '
65 68
 			var monthLength = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];';
69
+	}
66 70
 
67 71
 	// End of the javascript, start the form and display the link tree.
68 72
 	echo '
@@ -83,9 +87,10 @@  discard block
 block discarded – undo
83 87
 			</div>
84 88
 			<br>';
85 89
 
86
-	if ($context['make_event'] && (!$context['event']['new'] || !empty($context['current_board'])))
87
-		echo '
90
+	if ($context['make_event'] && (!$context['event']['new'] || !empty($context['current_board']))) {
91
+			echo '
88 92
 			<input type="hidden" name="eventid" value="', $context['event']['id'], '">';
93
+	}
89 94
 
90 95
 	// Start the main table.
91 96
 	echo '
@@ -110,26 +115,29 @@  discard block
 block discarded – undo
110 115
 					</div>';
111 116
 
112 117
 	// If this won't be approved let them know!
113
-	if (!$context['becomes_approved'])
114
-		echo '
118
+	if (!$context['becomes_approved']) {
119
+			echo '
115 120
 					<div class="noticebox">
116 121
 						<em>', $txt['wait_for_approval'], '</em>
117 122
 						<input type="hidden" name="not_approved" value="1">
118 123
 					</div>';
124
+	}
119 125
 
120 126
 	// If it's locked, show a message to warn the replier.
121
-	if (!empty($context['locked']))
122
-	echo '
127
+	if (!empty($context['locked'])) {
128
+		echo '
123 129
 					<div class="errorbox">
124 130
 						', $txt['topic_locked_no_reply'], '
125 131
 					</div>';
132
+	}
126 133
 
127
-	if (!empty($modSettings['drafts_post_enabled']))
128
-		echo '
134
+	if (!empty($modSettings['drafts_post_enabled'])) {
135
+			echo '
129 136
 					<div id="draft_section" class="infobox"', isset($context['draft_saved']) ? '' : ' style="display: none;"', '>',
130 137
 						sprintf($txt['draft_saved'], $scripturl . '?action=profile;u=' . $context['user']['id'] . ';area=showdrafts'), '
131 138
 						', (!empty($modSettings['drafts_keep_days']) ? ' <strong>' . sprintf($txt['draft_save_warning'], $modSettings['drafts_keep_days']) . '</strong>' : ''), '
132 139
 					</div>';
140
+	}
133 141
 
134 142
 	// The post header... important stuff
135 143
 	template_post_header();
@@ -162,9 +170,10 @@  discard block
 block discarded – undo
162 170
 				echo '
163 171
 										<optgroup label="', $category['name'], '">';
164 172
 
165
-				foreach ($category['boards'] as $board)
166
-					echo '
173
+				foreach ($category['boards'] as $board) {
174
+									echo '
167 175
 											<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=&gt;' : '', ' ', $board['name'], '</option>';
176
+				}
168 177
 				echo '
169 178
 										</optgroup>';
170 179
 			}
@@ -200,9 +209,10 @@  discard block
 block discarded – undo
200 209
 									<span class="label">', $txt['calendar_timezone'], '</span>
201 210
 									<select name="tz" id="tz"', !empty($context['event']['allday']) ? ' disabled' : '', '>';
202 211
 
203
-		foreach ($context['all_timezones'] as $tz => $tzname)
204
-			echo '
212
+		foreach ($context['all_timezones'] as $tz => $tzname) {
213
+					echo '
205 214
 										<option', is_numeric($tz) ? ' value="" disabled' : ' value="' . $tz . '"', $tz === $context['event']['tz'] ? ' selected' : '', '>', $tzname, '</option>';
215
+		}
206 216
 
207 217
 		echo '
208 218
 									</select>
@@ -231,14 +241,15 @@  discard block
 block discarded – undo
231 241
 								</dd>';
232 242
 
233 243
 		// Loop through all the choices and print them out.
234
-		foreach ($context['choices'] as $choice)
235
-			echo '
244
+		foreach ($context['choices'] as $choice) {
245
+					echo '
236 246
 								<dt>
237 247
 									<label for="options-', $choice['id'], '">', $txt['option'], ' ', $choice['number'], '</label>:
238 248
 								</dt>
239 249
 								<dd>
240 250
 									<input type="text" name="options[', $choice['id'], ']" id="options-', $choice['id'], '" value="', $choice['label'], '" tabindex="', $context['tabindex']++, '" size="80" maxlength="255">
241 251
 								</dd>';
252
+		}
242 253
 
243 254
 		echo '
244 255
 								<p id="pollMoreOptions"></p>
@@ -268,14 +279,15 @@  discard block
 block discarded – undo
268 279
 									<input type="checkbox" id="poll_change_vote" name="poll_change_vote"', !empty($context['poll']['change_vote']) ? ' checked' : '', '>
269 280
 								</dd>';
270 281
 
271
-		if ($context['poll_options']['guest_vote_enabled'])
272
-			echo '
282
+		if ($context['poll_options']['guest_vote_enabled']) {
283
+					echo '
273 284
 								<dt>
274 285
 									<label for="poll_guest_vote">', $txt['poll_guest_vote'], ':</label>
275 286
 								</dt>
276 287
 								<dd>
277 288
 									<input type="checkbox" id="poll_guest_vote" name="poll_guest_vote"', !empty($context['poll_options']['guest_vote']) ? ' checked' : '', '>
278 289
 								</dd>';
290
+		}
279 291
 
280 292
 		echo '
281 293
 								<dt>
@@ -296,8 +308,8 @@  discard block
 block discarded – undo
296 308
 					', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message');
297 309
 
298 310
 	// If we're editing and displaying edit details, show a box where they can say why
299
-	if (isset($context['editing']) && $modSettings['show_modify'])
300
-		echo '
311
+	if (isset($context['editing']) && $modSettings['show_modify']) {
312
+			echo '
301 313
 					<dl>
302 314
 						<dt class="clear">
303 315
 							<span id="caption_edit_reason">', $txt['reason_for_edit'], ':</span>
@@ -306,20 +318,23 @@  discard block
 block discarded – undo
306 318
 							<input type="text" name="modify_reason"', isset($context['last_modified_reason']) ? ' value="' . $context['last_modified_reason'] . '"' : '', ' tabindex="', $context['tabindex']++, '" size="80" maxlength="80">
307 319
 						</dd>
308 320
 					</dl>';
321
+	}
309 322
 
310 323
 	// If this message has been edited in the past - display when it was.
311
-	if (isset($context['last_modified']))
312
-		echo '
324
+	if (isset($context['last_modified'])) {
325
+			echo '
313 326
 					<div class="padding smalltext">
314 327
 						', $context['last_modified_text'], '
315 328
 					</div>';
329
+	}
316 330
 
317 331
 	// If the admin has enabled the hiding of the additional options - show a link and image for it.
318
-	if (!empty($modSettings['additional_options_collapsable']))
319
-		echo '
332
+	if (!empty($modSettings['additional_options_collapsable'])) {
333
+			echo '
320 334
 					<div id="postAdditionalOptionsHeader">
321 335
 						<strong><a href="#" id="postMoreExpandLink"> ', $context['can_post_attachment'] ? $txt['post_additionalopt_attach'] : $txt['post_additionalopt'], '</a></strong>
322 336
 					</div>';
337
+	}
323 338
 
324 339
 	echo '
325 340
 					<div id="postAdditionalOptions">';
@@ -352,19 +367,21 @@  discard block
 block discarded – undo
352 367
 								', $txt['uncheck_unwatchd_attach'], ':
353 368
 							</dd>';
354 369
 
355
-		foreach ($context['current_attachments'] as $attachment)
356
-			echo '
370
+		foreach ($context['current_attachments'] as $attachment) {
371
+					echo '
357 372
 							<dd class="smalltext">
358 373
 								<label for="attachment_', $attachment['attachID'], '"><input type="checkbox" id="attachment_', $attachment['attachID'], '" name="attach_del[]" value="', $attachment['attachID'], '"', empty($attachment['unchecked']) ? ' checked' : '', '> ', $attachment['name'], (empty($attachment['approved']) ? ' (' . $txt['awaiting_approval'] . ')' : ''),
359 374
 								!empty($modSettings['attachmentPostLimit']) || !empty($modSettings['attachmentSizeLimit']) ? sprintf($txt['attach_kb'], comma_format(round(max($attachment['size'], 1024) / 1024), 0)) : '', '</label>
360 375
 							</dd>';
376
+		}
361 377
 
362 378
 		echo '
363 379
 						</dl>';
364 380
 
365
-		if (!empty($context['files_in_session_warning']))
366
-			echo '
381
+		if (!empty($context['files_in_session_warning'])) {
382
+					echo '
367 383
 						<div class="smalltext">', $context['files_in_session_warning'], '</div>';
384
+		}
368 385
 	}
369 386
 
370 387
 	// Is the user allowed to post any additional ones? If so give them the boxes to do it!
@@ -429,13 +446,14 @@  discard block
 block discarded – undo
429 446
 									<div class="fallback">
430 447
 										<input type="file" multiple="multiple" name="attachment[]" id="attachment1" class="fallback"> (<a href="javascript:void(0);" onclick="cleanFileInput(\'attachment1\');">', $txt['clean_attach'], '</a>)';
431 448
 
432
-		if (!empty($modSettings['attachmentSizeLimit']))
433
-			echo '
449
+		if (!empty($modSettings['attachmentSizeLimit'])) {
450
+					echo '
434 451
 										<input type="hidden" name="MAX_FILE_SIZE" value="' . $modSettings['attachmentSizeLimit'] * 1024 . '">';
452
+		}
435 453
 
436 454
 		// Show more boxes if they aren't approaching that limit.
437
-		if ($context['num_allowed_attachments'] > 1)
438
-			echo '
455
+		if ($context['num_allowed_attachments'] > 1) {
456
+					echo '
439 457
 										<script>
440 458
 											var allowed_attachments = ', $context['num_allowed_attachments'], ';
441 459
 											var current_attachment = 1;
@@ -455,6 +473,7 @@  discard block
 block discarded – undo
455 473
 										<a href="#" onclick="addAttachment(); return false;">(', $txt['more_attachments'], ')</a>
456 474
 									</div><!-- .fallback -->
457 475
 								</div><!-- #attachUpload -->';
476
+		}
458 477
 
459 478
 		echo '
460 479
 							</dd>';
@@ -466,21 +485,25 @@  discard block
 block discarded – undo
466 485
 							<dd class="smalltext">';
467 486
 
468 487
 		// Show some useful information such as allowed extensions, maximum size and amount of attachments allowed.
469
-		if (!empty($modSettings['attachmentCheckExtensions']))
470
-			echo '
488
+		if (!empty($modSettings['attachmentCheckExtensions'])) {
489
+					echo '
471 490
 								', $txt['allowed_types'], ': ', $context['allowed_extensions'], '<br>';
491
+		}
472 492
 
473
-		if (!empty($context['attachment_restrictions']))
474
-			echo '
493
+		if (!empty($context['attachment_restrictions'])) {
494
+					echo '
475 495
 								', $txt['attach_restrictions'], ' ', implode(', ', $context['attachment_restrictions']), '<br>';
496
+		}
476 497
 
477
-		if ($context['num_allowed_attachments'] == 0)
478
-			echo '
498
+		if ($context['num_allowed_attachments'] == 0) {
499
+					echo '
479 500
 								', $txt['attach_limit_nag'], '<br>';
501
+		}
480 502
 
481
-		if (!$context['can_post_attachment_unapproved'])
482
-			echo '
503
+		if (!$context['can_post_attachment_unapproved']) {
504
+					echo '
483 505
 								<span class="alert">', $txt['attachment_requires_approval'], '</span>', '<br>';
506
+		}
484 507
 
485 508
 		echo '
486 509
 							</dd>
@@ -504,24 +527,26 @@  discard block
 block discarded – undo
504 527
 							<dt><strong>', $txt['subject'], '</strong></dt>
505 528
 							<dd><strong>', $txt['draft_saved_on'], '</strong></dd>';
506 529
 
507
-		foreach ($context['drafts'] as $draft)
508
-			echo '
530
+		foreach ($context['drafts'] as $draft) {
531
+					echo '
509 532
 							<dt>', $draft['link'], '</dt>
510 533
 							<dd>', $draft['poster_time'], '</dd>';
534
+		}
511 535
 		echo '
512 536
 						</dl>
513 537
 					</div>';
514 538
 	}
515 539
 
516 540
 	// Is visual verification enabled?
517
-	if ($context['require_verification'])
518
-		echo '
541
+	if ($context['require_verification']) {
542
+			echo '
519 543
 					<div class="post_verification">
520 544
 						<span', !empty($context['post_error']['need_qr_verification']) ? ' class="error"' : '', '>
521 545
 							<strong>', $txt['verification'], ':</strong>
522 546
 						</span>
523 547
 						', template_control_verification($context['visual_verification_id'], 'all'), '
524 548
 					</div>';
549
+	}
525 550
 
526 551
 	// Finally, the submit buttons.
527 552
 	echo '
@@ -530,9 +555,10 @@  discard block
 block discarded – undo
530 555
 						', template_control_richedit_buttons($context['post_box_name']);
531 556
 
532 557
 	// Option to delete an event if user is editing one.
533
-	if ($context['make_event'] && !$context['event']['new'])
534
-		echo '
558
+	if ($context['make_event'] && !$context['event']['new']) {
559
+			echo '
535 560
 						<input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['event_delete_confirm'] ,'" class="button you_sure">';
561
+	}
536 562
 
537 563
 	echo '
538 564
 					</span>
@@ -541,9 +567,10 @@  discard block
 block discarded – undo
541 567
 			<br class="clear">';
542 568
 
543 569
 	// Assuming this isn't a new topic pass across the last message id.
544
-	if (isset($context['topic_last_message']))
545
-		echo '
570
+	if (isset($context['topic_last_message'])) {
571
+			echo '
546 572
 			<input type="hidden" name="last_msg" value="', $context['topic_last_message'], '">';
573
+	}
547 574
 
548 575
 	echo '
549 576
 			<input type="hidden" name="additional_options" id="additional_options" value="', $context['show_additional_options'] ? '1' : '0', '">
@@ -564,13 +591,14 @@  discard block
 block discarded – undo
564 591
 			</h5>
565 592
 			&nbsp;-&nbsp;%PostTime%&nbsp;&#187; <span class="new_posts" id="image_new_%PostID%">' . $txt['new'] . '</span>';
566 593
 
567
-	if ($context['can_quote'])
568
-		$newPostsHTML .= '
594
+	if ($context['can_quote']) {
595
+			$newPostsHTML .= '
569 596
 			<ul class="quickbuttons sf-js-enabled sf-arrows" id="msg_%PostID%_quote" style="touch-action: pan-y;">
570 597
 				<li id="post_modify">
571 598
 					<a href="#postmodify" onclick="return insertQuoteFast(%PostID%);" class="quote_button"><span class="generic_icons quote"></span>' . $txt['quote'] . '</a>
572 599
 				</li>
573 600
 			</ul>';
601
+	}
574 602
 
575 603
 	$newPostsHTML .= '
576 604
 			<br class="clear">
@@ -596,16 +624,17 @@  discard block
 block discarded – undo
596 624
 				sSessionVar: ', JavaScriptEscape($context['session_var']), ',
597 625
 				newPostsTemplate:', JavaScriptEscape($newPostsHTML);
598 626
 
599
-	if (!empty($context['current_board']))
600
-		echo ',
627
+	if (!empty($context['current_board'])) {
628
+			echo ',
601 629
 				iCurrentBoard: ', $context['current_board'], '';
630
+	}
602 631
 
603 632
 	echo '
604 633
 			});';
605 634
 
606 635
 	// Code for showing and hiding additional options.
607
-	if (!empty($modSettings['additional_options_collapsable']))
608
-		echo '
636
+	if (!empty($modSettings['additional_options_collapsable'])) {
637
+			echo '
609 638
 			var oSwapAdditionalOptions = new smc_Toggle({
610 639
 				bToggleEnabled: true,
611 640
 				bCurrentlyCollapsed: ', $context['show_additional_options'] ? 'false' : 'true', ',
@@ -633,10 +662,11 @@  discard block
 block discarded – undo
633 662
 					}
634 663
 				]
635 664
 			});';
665
+	}
636 666
 
637 667
 	// Code for showing and hiding drafts
638
-	if (!empty($context['drafts']))
639
-		echo '
668
+	if (!empty($context['drafts'])) {
669
+			echo '
640 670
 			var oSwapDraftOptions = new smc_Toggle({
641 671
 				bToggleEnabled: true,
642 672
 				bCurrentlyCollapsed: true,
@@ -658,6 +688,7 @@  discard block
 block discarded – undo
658 688
 					}
659 689
 				]
660 690
 			});';
691
+	}
661 692
 
662 693
 	echo '
663 694
 			var oEditorID = "', $context['post_box_name'] ,'";
@@ -678,8 +709,9 @@  discard block
 block discarded – undo
678 709
 		foreach ($context['previous_posts'] as $post)
679 710
 		{
680 711
 			$ignoring = false;
681
-			if (!empty($post['is_ignored']))
682
-				$ignored_posts[] = $ignoring = $post['id'];
712
+			if (!empty($post['is_ignored'])) {
713
+							$ignored_posts[] = $ignoring = $post['id'];
714
+			}
683 715
 
684 716
 			echo '
685 717
 			<div class="windowbg">
@@ -689,22 +721,24 @@  discard block
 block discarded – undo
689 721
 					</h5>
690 722
 					&nbsp;-&nbsp;', $post['time'];
691 723
 
692
-			if ($context['can_quote'])
693
-				echo '
724
+			if ($context['can_quote']) {
725
+							echo '
694 726
 					<ul class="quickbuttons" id="msg_', $post['id'], '_quote">
695 727
 						<li style="display:none;" id="quoteSelected_', $post['id'], '" data-msgid="', $post['id'], '"><a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'] ,'</a></li>
696 728
 						<li id="post_modify"><a href="#postmodify" onclick="return insertQuoteFast(', $post['id'], ');"><span class="generic_icons quote"></span>', $txt['quote'], '</a></li>
697 729
 					</ul>';
730
+			}
698 731
 
699 732
 			echo '
700 733
 					<br class="clear">';
701 734
 
702
-			if ($ignoring)
703
-				echo '
735
+			if ($ignoring) {
736
+							echo '
704 737
 					<div id="msg_', $post['id'], '_ignored_prompt" class="smalltext">
705 738
 						', $txt['ignoring_user'], '
706 739
 						<a href="#" id="msg_', $post['id'], '_ignored_link" style="display: none;">', $txt['show_ignore_user_post'], '</a>
707 740
 					</div>';
741
+			}
708 742
 
709 743
 			echo '
710 744
 					<div class="list_posts smalltext" id="msg_', $post['id'], '_body" data-msgid="', $post['id'], '">', $post['message'], '</div>
@@ -859,10 +893,10 @@  discard block
 block discarded – undo
859 893
 		<div id="temporary_posting_area" style="display: none;"></div>
860 894
 		<script>';
861 895
 
862
-	if ($context['close_window'])
863
-		echo '
896
+	if ($context['close_window']) {
897
+			echo '
864 898
 			window.close();';
865
-	else
899
+	} else
866 900
 	{
867 901
 		// Lucky for us, Internet Explorer has an "innerText" feature which basically converts entities <--> text. Use it if possible ;)
868 902
 		echo '
@@ -916,11 +950,12 @@  discard block
 block discarded – undo
916 950
 				</p>
917 951
 				<ul>';
918 952
 
919
-	foreach ($context['groups'] as $group)
920
-		echo '
953
+	foreach ($context['groups'] as $group) {
954
+			echo '
921 955
 					<li>
922 956
 						<label for="who_', $group['id'], '"><input type="checkbox" name="who[', $group['id'], ']" id="who_', $group['id'], '" value="', $group['id'], '" checked> ', $group['name'], '</label> <em>(', $group['member_count'], ')</em>
923 957
 					</li>';
958
+	}
924 959
 
925 960
 	echo '
926 961
 					<li>
@@ -1027,28 +1062,32 @@  discard block
 block discarded – undo
1027 1062
 	foreach ($context['posting_fields'] as $pfid => $pf)
1028 1063
 	{
1029 1064
 		// We need both a label and an input
1030
-		if (empty($pf['label']) || empty($pf['input']))
1031
-			continue;
1065
+		if (empty($pf['label']) || empty($pf['input'])) {
1066
+					continue;
1067
+		}
1032 1068
 
1033 1069
 		// The labels are pretty simple...
1034 1070
 		echo '
1035 1071
 						<dt class="clear pf_', $pfid, '">';
1036 1072
 
1037 1073
 		// Any leading HTML before the label
1038
-		if (!empty($pf['label']['before']))
1039
-			echo '
1074
+		if (!empty($pf['label']['before'])) {
1075
+					echo '
1040 1076
 							', $pf['label']['before'];
1077
+		}
1041 1078
 
1042
-		if (!empty($pf['label']['html']))
1043
-			echo $pf['label']['html'];
1044
-		else
1045
-			echo '
1079
+		if (!empty($pf['label']['html'])) {
1080
+					echo $pf['label']['html'];
1081
+		} else {
1082
+					echo '
1046 1083
 							<label for="', !empty($pf['input']['attributes']['name']) ? $pf['input']['attributes']['name'] : $pfid, '" id="caption_', $pfid, '"', !empty($pf['label']['class']) ? ' class="' . $pf['label']['class'] . '"' : '', '>', $pf['label']['text'], '</label>';
1084
+		}
1047 1085
 
1048 1086
 		// Any trailing HTML after the label
1049
-		if (!empty($pf['label']['after']))
1050
-			echo '
1087
+		if (!empty($pf['label']['after'])) {
1088
+					echo '
1051 1089
 							', $pf['label']['after'];
1090
+		}
1052 1091
 
1053 1092
 		echo '
1054 1093
 						</dt>';
@@ -1058,9 +1097,10 @@  discard block
 block discarded – undo
1058 1097
 						<dd class="pf_', $pfid, '">';
1059 1098
 
1060 1099
 		// Any leading HTML before the main input
1061
-		if (!empty($pf['input']['before']))
1062
-			echo '
1100
+		if (!empty($pf['input']['before'])) {
1101
+					echo '
1063 1102
 							', $pf['input']['before'];
1103
+		}
1064 1104
 
1065 1105
 		// If there is a literal HTML string already defined, just print it.
1066 1106
 		if (!empty($pf['input']['html']))
@@ -1073,17 +1113,19 @@  discard block
 block discarded – undo
1073 1113
 			echo '
1074 1114
 							<input type="', $pf['input']['type'], '"';
1075 1115
 
1076
-			if (empty($pf['input']['attributes']['name']))
1077
-				echo ' name="', $pfid, '"';
1116
+			if (empty($pf['input']['attributes']['name'])) {
1117
+							echo ' name="', $pfid, '"';
1118
+			}
1078 1119
 
1079 1120
 			if (!empty($pf['input']['attributes']) && is_array($pf['input']['attributes']))
1080 1121
 			{
1081 1122
 				foreach ($pf['input']['attributes'] as $attribute => $value)
1082 1123
 				{
1083
-					if (is_bool($value))
1084
-						echo $value ? ' ' . $attribute : '';
1085
-					else
1086
-						echo ' ', $attribute, '="', $value, '"';
1124
+					if (is_bool($value)) {
1125
+											echo $value ? ' ' . $attribute : '';
1126
+					} else {
1127
+											echo ' ', $attribute, '="', $value, '"';
1128
+					}
1087 1129
 				}
1088 1130
 			}
1089 1131
 
@@ -1095,19 +1137,21 @@  discard block
 block discarded – undo
1095 1137
 			echo '
1096 1138
 							<textarea';
1097 1139
 
1098
-			if (empty($pf['input']['attributes']['name']))
1099
-				echo ' name="', $pfid, '"';
1140
+			if (empty($pf['input']['attributes']['name'])) {
1141
+							echo ' name="', $pfid, '"';
1142
+			}
1100 1143
 
1101 1144
 			if (!empty($pf['input']['attributes']) && is_array($pf['input']['attributes']))
1102 1145
 			{
1103 1146
 				foreach ($pf['input']['attributes'] as $attribute => $value)
1104 1147
 				{
1105
-					if ($attribute === 'value')
1106
-						continue;
1107
-					elseif (is_bool($value))
1108
-						echo $value ? ' ' . $attribute : '';
1109
-					else
1110
-						echo ' ', $attribute, '="', $value, '"';
1148
+					if ($attribute === 'value') {
1149
+											continue;
1150
+					} elseif (is_bool($value)) {
1151
+											echo $value ? ' ' . $attribute : '';
1152
+					} else {
1153
+											echo ' ', $attribute, '="', $value, '"';
1154
+					}
1111 1155
 				}
1112 1156
 			}
1113 1157
 
@@ -1120,17 +1164,19 @@  discard block
 block discarded – undo
1120 1164
 			echo '
1121 1165
 							<select';
1122 1166
 
1123
-			if (empty($pf['input']['attributes']['name']))
1124
-				echo ' name="', $pfid, '"';
1167
+			if (empty($pf['input']['attributes']['name'])) {
1168
+							echo ' name="', $pfid, '"';
1169
+			}
1125 1170
 
1126 1171
 			if (!empty($pf['input']['attributes']) && is_array($pf['input']['attributes']))
1127 1172
 			{
1128 1173
 				foreach ($pf['input']['attributes'] as $attribute => $value)
1129 1174
 				{
1130
-					if (is_bool($value))
1131
-						echo $value ? ' ' . $attribute : '';
1132
-					else
1133
-						echo ' ', $attribute, '="', $value, '"';
1175
+					if (is_bool($value)) {
1176
+											echo $value ? ' ' . $attribute : '';
1177
+					} else {
1178
+											echo ' ', $attribute, '="', $value, '"';
1179
+					}
1134 1180
 				}
1135 1181
 			}
1136 1182
 
@@ -1145,17 +1191,19 @@  discard block
 block discarded – undo
1145 1191
 					echo '
1146 1192
 								<optgroup';
1147 1193
 
1148
-					if (empty($option['attributes']['label']))
1149
-						echo ' label="', $optlabel, '"';
1194
+					if (empty($option['attributes']['label'])) {
1195
+											echo ' label="', $optlabel, '"';
1196
+					}
1150 1197
 
1151 1198
 					if (!empty($option['attributes']) && is_array($option['attributes']))
1152 1199
 					{
1153 1200
 						foreach ($option['attributes'] as $attribute => $value)
1154 1201
 						{
1155
-							if (is_bool($value))
1156
-								echo $value ? ' ' . $attribute : '';
1157
-							else
1158
-								echo ' ', $attribute, '="', $value, '"';
1202
+							if (is_bool($value)) {
1203
+															echo $value ? ' ' . $attribute : '';
1204
+							} else {
1205
+															echo ' ', $attribute, '="', $value, '"';
1206
+							}
1159 1207
 						}
1160 1208
 					}
1161 1209
 
@@ -1168,10 +1216,11 @@  discard block
 block discarded – undo
1168 1216
 
1169 1217
 						foreach ($grouped_option['attributes'] as $attribute => $value)
1170 1218
 						{
1171
-							if (is_bool($value))
1172
-								echo $value ? ' ' . $attribute : '';
1173
-							else
1174
-								echo ' ', $attribute, '="', $value, '"';
1219
+							if (is_bool($value)) {
1220
+															echo $value ? ' ' . $attribute : '';
1221
+							} else {
1222
+															echo ' ', $attribute, '="', $value, '"';
1223
+							}
1175 1224
 						}
1176 1225
 
1177 1226
 						echo '>', $grouped_optlabel, '</option>';
@@ -1189,10 +1238,11 @@  discard block
 block discarded – undo
1189 1238
 
1190 1239
 					foreach ($option['attributes'] as $attribute => $value)
1191 1240
 					{
1192
-						if (is_bool($value))
1193
-							echo $value ? ' ' . $attribute : '';
1194
-						else
1195
-							echo ' ', $attribute, '="', $value, '"';
1241
+						if (is_bool($value)) {
1242
+													echo $value ? ' ' . $attribute : '';
1243
+						} else {
1244
+													echo ' ', $attribute, '="', $value, '"';
1245
+						}
1196 1246
 					}
1197 1247
 
1198 1248
 					echo '>', $optlabel, '</option>';
@@ -1213,12 +1263,13 @@  discard block
 block discarded – undo
1213 1263
 			{
1214 1264
 				foreach ($pf['input']['attributes'] as $attribute => $value)
1215 1265
 				{
1216
-					if ($attribute === 'name')
1217
-						continue;
1218
-					elseif (is_bool($value))
1219
-						echo $value ? ' ' . $attribute : '';
1220
-					else
1221
-						echo ' ', $attribute, '="', $value, '"';
1266
+					if ($attribute === 'name') {
1267
+											continue;
1268
+					} elseif (is_bool($value)) {
1269
+											echo $value ? ' ' . $attribute : '';
1270
+					} else {
1271
+											echo ' ', $attribute, '="', $value, '"';
1272
+					}
1222 1273
 				}
1223 1274
 			}
1224 1275
 
@@ -1231,10 +1282,11 @@  discard block
 block discarded – undo
1231 1282
 
1232 1283
 				foreach ($option['attributes'] as $attribute => $value)
1233 1284
 				{
1234
-					if (is_bool($value))
1235
-						echo $value ? ' ' . $attribute : '';
1236
-					else
1237
-						echo ' ', $attribute, '="', $value, '"';
1285
+					if (is_bool($value)) {
1286
+											echo $value ? ' ' . $attribute : '';
1287
+					} else {
1288
+											echo ' ', $attribute, '="', $value, '"';
1289
+					}
1238 1290
 				}
1239 1291
 
1240 1292
 				echo ' tabindex="', $context['tabindex']++, '">', $optlabel, '</input>';
@@ -1245,9 +1297,10 @@  discard block
 block discarded – undo
1245 1297
 		}
1246 1298
 
1247 1299
 		// Any trailing HTML after the main input
1248
-		if (!empty($pf['input']['after']))
1249
-			echo '
1300
+		if (!empty($pf['input']['after'])) {
1301
+					echo '
1250 1302
 							', $pf['input']['after'];
1303
+		}
1251 1304
 
1252 1305
 		echo '
1253 1306
 						</dd>';
Please login to merge, or discard this patch.
Sources/Themes.php 1 patch
Braces   +348 added lines, -271 removed lines patch added patch discarded remove patch
@@ -30,8 +30,9 @@  discard block
 block discarded – undo
30 30
  * @version 2.1 Beta 4
31 31
  */
32 32
 
33
-if (!defined('SMF'))
33
+if (!defined('SMF')) {
34 34
 	die('No direct access...');
35
+}
35 36
 
36 37
 /**
37 38
  * Subaction handler - manages the action and delegates control to the proper
@@ -103,12 +104,12 @@  discard block
 block discarded – undo
103 104
 	cache_put_data('minimized_css', null);
104 105
 
105 106
 	// Follow the sa or just go to administration.
106
-	if (isset($_GET['sa']) && !empty($subActions[$_GET['sa']]))
107
-		call_helper($subActions[$_GET['sa']]);
108
-
109
-	else
110
-		call_helper($subActions['admin']);
111
-}
107
+	if (isset($_GET['sa']) && !empty($subActions[$_GET['sa']])) {
108
+			call_helper($subActions[$_GET['sa']]);
109
+	} else {
110
+			call_helper($subActions['admin']);
111
+	}
112
+	}
112 113
 
113 114
 /**
114 115
  * This function allows administration of themes and their settings,
@@ -130,15 +131,16 @@  discard block
 block discarded – undo
130 131
 		checkSession();
131 132
 		validateToken('admin-tm');
132 133
 
133
-		if (isset($_POST['options']['known_themes']))
134
-			foreach ($_POST['options']['known_themes'] as $key => $id)
134
+		if (isset($_POST['options']['known_themes'])) {
135
+					foreach ($_POST['options']['known_themes'] as $key => $id)
135 136
 				$_POST['options']['known_themes'][$key] = (int) $id;
137
+		} else {
138
+					fatal_lang_error('themes_none_selectable', false);
139
+		}
136 140
 
137
-		else
138
-			fatal_lang_error('themes_none_selectable', false);
139
-
140
-		if (!in_array($_POST['options']['theme_guests'], $_POST['options']['known_themes']))
141
-			fatal_lang_error('themes_default_selectable', false);
141
+		if (!in_array($_POST['options']['theme_guests'], $_POST['options']['known_themes'])) {
142
+					fatal_lang_error('themes_default_selectable', false);
143
+		}
142 144
 
143 145
 		// Commit the new settings.
144 146
 		updateSettings(array(
@@ -146,8 +148,9 @@  discard block
 block discarded – undo
146 148
 			'theme_guests' => $_POST['options']['theme_guests'],
147 149
 			'knownThemes' => implode(',', $_POST['options']['known_themes']),
148 150
 		));
149
-		if ((int) $_POST['theme_reset'] == 0 || in_array($_POST['theme_reset'], $_POST['options']['known_themes']))
150
-			updateMemberData(null, array('id_theme' => (int) $_POST['theme_reset']));
151
+		if ((int) $_POST['theme_reset'] == 0 || in_array($_POST['theme_reset'], $_POST['options']['known_themes'])) {
152
+					updateMemberData(null, array('id_theme' => (int) $_POST['theme_reset']));
153
+		}
151 154
 
152 155
 		redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=admin');
153 156
 	}
@@ -166,8 +169,9 @@  discard block
 block discarded – undo
166 169
 	// Look for a non existent theme directory. (ie theme87.)
167 170
 	$theme_dir = $boarddir . '/Themes/theme';
168 171
 	$i = 1;
169
-	while (file_exists($theme_dir . $i))
170
-		$i++;
172
+	while (file_exists($theme_dir . $i)) {
173
+			$i++;
174
+	}
171 175
 
172 176
 	$context['new_theme_name'] = 'theme' . $i;
173 177
 
@@ -189,8 +193,9 @@  discard block
 block discarded – undo
189 193
 	loadLanguage('Admin');
190 194
 	isAllowedTo('admin_forum');
191 195
 
192
-	if (isset($_REQUEST['th']))
193
-		return SetThemeSettings();
196
+	if (isset($_REQUEST['th'])) {
197
+			return SetThemeSettings();
198
+	}
194 199
 
195 200
 	if (isset($_POST['save']))
196 201
 	{
@@ -274,12 +279,13 @@  discard block
 block discarded – undo
274 279
 		$context['themes'] = array();
275 280
 		while ($row = $smcFunc['db_fetch_assoc']($request))
276 281
 		{
277
-			if (!isset($context['themes'][$row['id_theme']]))
278
-				$context['themes'][$row['id_theme']] = array(
282
+			if (!isset($context['themes'][$row['id_theme']])) {
283
+							$context['themes'][$row['id_theme']] = array(
279 284
 					'id' => $row['id_theme'],
280 285
 					'num_default_options' => 0,
281 286
 					'num_members' => 0,
282 287
 				);
288
+			}
283 289
 			$context['themes'][$row['id_theme']][$row['variable']] = $row['value'];
284 290
 		}
285 291
 		$smcFunc['db_free_result']($request);
@@ -293,8 +299,9 @@  discard block
 block discarded – undo
293 299
 				'guest_member' => -1,
294 300
 			)
295 301
 		);
296
-		while ($row = $smcFunc['db_fetch_assoc']($request))
297
-			$context['themes'][$row['id_theme']]['num_default_options'] = $row['value'];
302
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
303
+					$context['themes'][$row['id_theme']]['num_default_options'] = $row['value'];
304
+		}
298 305
 		$smcFunc['db_free_result']($request);
299 306
 
300 307
 		// Need to make sure we don't do custom fields.
@@ -305,8 +312,9 @@  discard block
 block discarded – undo
305 312
 			)
306 313
 		);
307 314
 		$customFields = array();
308
-		while ($row = $smcFunc['db_fetch_assoc']($request))
309
-			$customFields[] = $row['col_name'];
315
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
316
+					$customFields[] = $row['col_name'];
317
+		}
310 318
 		$smcFunc['db_free_result']($request);
311 319
 		$customFieldsQuery = empty($customFields) ? '' : ('AND variable NOT IN ({array_string:custom_fields})');
312 320
 
@@ -321,14 +329,16 @@  discard block
 block discarded – undo
321 329
 				'custom_fields' => empty($customFields) ? array() : $customFields,
322 330
 			)
323 331
 		);
324
-		while ($row = $smcFunc['db_fetch_assoc']($request))
325
-			$context['themes'][$row['id_theme']]['num_members'] = $row['value'];
332
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
333
+					$context['themes'][$row['id_theme']]['num_members'] = $row['value'];
334
+		}
326 335
 		$smcFunc['db_free_result']($request);
327 336
 
328 337
 		// There has to be a Settings template!
329
-		foreach ($context['themes'] as $k => $v)
330
-			if (empty($v['theme_dir']) || (!file_exists($v['theme_dir'] . '/Settings.template.php') && empty($v['num_members'])))
338
+		foreach ($context['themes'] as $k => $v) {
339
+					if (empty($v['theme_dir']) || (!file_exists($v['theme_dir'] . '/Settings.template.php') && empty($v['num_members'])))
331 340
 				unset($context['themes'][$k]);
341
+		}
332 342
 
333 343
 		loadTemplate('Themes');
334 344
 		$context['sub_template'] = 'reset_list';
@@ -343,16 +353,19 @@  discard block
 block discarded – undo
343 353
 		checkSession();
344 354
 		validateToken('admin-sto');
345 355
 
346
-		if (empty($_POST['options']))
347
-			$_POST['options'] = array();
348
-		if (empty($_POST['default_options']))
349
-			$_POST['default_options'] = array();
356
+		if (empty($_POST['options'])) {
357
+					$_POST['options'] = array();
358
+		}
359
+		if (empty($_POST['default_options'])) {
360
+					$_POST['default_options'] = array();
361
+		}
350 362
 
351 363
 		// Set up the sql query.
352 364
 		$setValues = array();
353 365
 
354
-		foreach ($_POST['options'] as $opt => $val)
355
-			$setValues[] = array(-1, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val);
366
+		foreach ($_POST['options'] as $opt => $val) {
367
+					$setValues[] = array(-1, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val);
368
+		}
356 369
 
357 370
 		$old_settings = array();
358 371
 		foreach ($_POST['default_options'] as $opt => $val)
@@ -366,8 +379,8 @@  discard block
 block discarded – undo
366 379
 		if (!empty($setValues))
367 380
 		{
368 381
 			// Are there options in non-default themes set that should be cleared?
369
-			if (!empty($old_settings))
370
-				$smcFunc['db_query']('', '
382
+			if (!empty($old_settings)) {
383
+							$smcFunc['db_query']('', '
371 384
 					DELETE FROM {db_prefix}themes
372 385
 					WHERE id_theme != {int:default_theme}
373 386
 						AND id_member = {int:guest_member}
@@ -378,6 +391,7 @@  discard block
 block discarded – undo
378 391
 						'old_settings' => $old_settings,
379 392
 					)
380 393
 				);
394
+			}
381 395
 
382 396
 			$smcFunc['db_insert']('replace',
383 397
 				'{db_prefix}themes',
@@ -391,8 +405,7 @@  discard block
 block discarded – undo
391 405
 		cache_put_data('theme_settings-1', null, 90);
392 406
 
393 407
 		redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=reset');
394
-	}
395
-	elseif (isset($_POST['submit']) && $_POST['who'] == 1)
408
+	} elseif (isset($_POST['submit']) && $_POST['who'] == 1)
396 409
 	{
397 410
 		checkSession();
398 411
 		validateToken('admin-sto');
@@ -405,9 +418,9 @@  discard block
 block discarded – undo
405 418
 		$old_settings = array();
406 419
 		foreach ($_POST['default_options'] as $opt => $val)
407 420
 		{
408
-			if ($_POST['default_options_master'][$opt] == 0)
409
-				continue;
410
-			elseif ($_POST['default_options_master'][$opt] == 1)
421
+			if ($_POST['default_options_master'][$opt] == 0) {
422
+							continue;
423
+			} elseif ($_POST['default_options_master'][$opt] == 1)
411 424
 			{
412 425
 				// Delete then insert for ease of database compatibility!
413 426
 				$smcFunc['db_query']('substring', '
@@ -433,8 +446,7 @@  discard block
 block discarded – undo
433 446
 				);
434 447
 
435 448
 				$old_settings[] = $opt;
436
-			}
437
-			elseif ($_POST['default_options_master'][$opt] == 2)
449
+			} elseif ($_POST['default_options_master'][$opt] == 2)
438 450
 			{
439 451
 				$smcFunc['db_query']('', '
440 452
 					DELETE FROM {db_prefix}themes
@@ -449,8 +461,8 @@  discard block
 block discarded – undo
449 461
 		}
450 462
 
451 463
 		// Delete options from other themes.
452
-		if (!empty($old_settings))
453
-			$smcFunc['db_query']('', '
464
+		if (!empty($old_settings)) {
465
+					$smcFunc['db_query']('', '
454 466
 				DELETE FROM {db_prefix}themes
455 467
 				WHERE id_theme != {int:default_theme}
456 468
 					AND id_member > {int:no_member}
@@ -461,12 +473,13 @@  discard block
 block discarded – undo
461 473
 					'old_settings' => $old_settings,
462 474
 				)
463 475
 			);
476
+		}
464 477
 
465 478
 		foreach ($_POST['options'] as $opt => $val)
466 479
 		{
467
-			if ($_POST['options_master'][$opt] == 0)
468
-				continue;
469
-			elseif ($_POST['options_master'][$opt] == 1)
480
+			if ($_POST['options_master'][$opt] == 0) {
481
+							continue;
482
+			} elseif ($_POST['options_master'][$opt] == 1)
470 483
 			{
471 484
 				// Delete then insert for ease of database compatibility - again!
472 485
 				$smcFunc['db_query']('substring', '
@@ -491,8 +504,7 @@  discard block
 block discarded – undo
491 504
 						'value' => (is_array($val) ? implode(',', $val) : $val),
492 505
 					)
493 506
 				);
494
-			}
495
-			elseif ($_POST['options_master'][$opt] == 2)
507
+			} elseif ($_POST['options_master'][$opt] == 2)
496 508
 			{
497 509
 				$smcFunc['db_query']('', '
498 510
 					DELETE FROM {db_prefix}themes
@@ -509,8 +521,7 @@  discard block
 block discarded – undo
509 521
 		}
510 522
 
511 523
 		redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=reset');
512
-	}
513
-	elseif (!empty($_GET['who']) && $_GET['who'] == 2)
524
+	} elseif (!empty($_GET['who']) && $_GET['who'] == 2)
514 525
 	{
515 526
 		checkSession('get');
516 527
 		validateToken('admin-stor', 'request');
@@ -525,8 +536,9 @@  discard block
 block discarded – undo
525 536
 				)
526 537
 			);
527 538
 			$customFields = array();
528
-			while ($row = $smcFunc['db_fetch_assoc']($request))
529
-				$customFields[] = $row['col_name'];
539
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
540
+							$customFields[] = $row['col_name'];
541
+			}
530 542
 			$smcFunc['db_free_result']($request);
531 543
 		}
532 544
 		$customFieldsQuery = empty($customFields) ? '' : ('AND variable NOT IN ({array_string:custom_fields})');
@@ -581,13 +593,13 @@  discard block
 block discarded – undo
581 593
 			)
582 594
 		);
583 595
 		$context['theme_options'] = array();
584
-		while ($row = $smcFunc['db_fetch_assoc']($request))
585
-			$context['theme_options'][$row['variable']] = $row['value'];
596
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
597
+					$context['theme_options'][$row['variable']] = $row['value'];
598
+		}
586 599
 		$smcFunc['db_free_result']($request);
587 600
 
588 601
 		$context['theme_options_reset'] = false;
589
-	}
590
-	else
602
+	} else
591 603
 	{
592 604
 		$context['theme_options'] = array();
593 605
 		$context['theme_options_reset'] = true;
@@ -596,8 +608,9 @@  discard block
 block discarded – undo
596 608
 	foreach ($context['options'] as $i => $setting)
597 609
 	{
598 610
 		// Just skip separators
599
-		if (!is_array($setting))
600
-			continue;
611
+		if (!is_array($setting)) {
612
+					continue;
613
+		}
601 614
 
602 615
 		// Is this disabled?
603 616
 		if (isset($setting['enabled']) && $setting['enabled'] === false)
@@ -606,15 +619,17 @@  discard block
 block discarded – undo
606 619
 			continue;
607 620
 		}
608 621
 
609
-		if (!isset($setting['type']) || $setting['type'] == 'bool')
610
-			$context['options'][$i]['type'] = 'checkbox';
611
-		elseif ($setting['type'] == 'int' || $setting['type'] == 'integer')
612
-			$context['options'][$i]['type'] = 'number';
613
-		elseif ($setting['type'] == 'string')
614
-			$context['options'][$i]['type'] = 'text';
622
+		if (!isset($setting['type']) || $setting['type'] == 'bool') {
623
+					$context['options'][$i]['type'] = 'checkbox';
624
+		} elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') {
625
+					$context['options'][$i]['type'] = 'number';
626
+		} elseif ($setting['type'] == 'string') {
627
+					$context['options'][$i]['type'] = 'text';
628
+		}
615 629
 
616
-		if (isset($setting['options']))
617
-			$context['options'][$i]['type'] = 'list';
630
+		if (isset($setting['options'])) {
631
+					$context['options'][$i]['type'] = 'list';
632
+		}
618 633
 
619 634
 		$context['options'][$i]['value'] = !isset($context['theme_options'][$setting['id']]) ? '' : $context['theme_options'][$setting['id']];
620 635
 	}
@@ -639,8 +654,9 @@  discard block
 block discarded – undo
639 654
 {
640 655
 	global $txt, $context, $settings, $modSettings, $smcFunc;
641 656
 
642
-	if (empty($_GET['th']) && empty($_GET['id']))
643
-		return ThemeAdmin();
657
+	if (empty($_GET['th']) && empty($_GET['id'])) {
658
+			return ThemeAdmin();
659
+	}
644 660
 
645 661
 	$_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id'];
646 662
 
@@ -651,8 +667,9 @@  discard block
 block discarded – undo
651 667
 	isAllowedTo('admin_forum');
652 668
 
653 669
 	// Validate inputs/user.
654
-	if (empty($_GET['th']))
655
-		fatal_lang_error('no_theme', false);
670
+	if (empty($_GET['th'])) {
671
+			fatal_lang_error('no_theme', false);
672
+	}
656 673
 
657 674
 	// Fetch the smiley sets...
658 675
 	$sets = explode(',', 'none,' . $modSettings['smiley_sets_known']);
@@ -660,8 +677,9 @@  discard block
 block discarded – undo
660 677
 	$context['smiley_sets'] = array(
661 678
 		'' => $txt['smileys_no_default']
662 679
 	);
663
-	foreach ($sets as $i => $set)
664
-		$context['smiley_sets'][$set] = $smcFunc['htmlspecialchars']($set_names[$i]);
680
+	foreach ($sets as $i => $set) {
681
+			$context['smiley_sets'][$set] = $smcFunc['htmlspecialchars']($set_names[$i]);
682
+	}
665 683
 
666 684
 	$old_id = $settings['theme_id'];
667 685
 	$old_settings = $settings;
@@ -686,8 +704,9 @@  discard block
 block discarded – undo
686 704
 	if (file_exists($settings['theme_dir'] . '/index.template.php'))
687 705
 	{
688 706
 		$file_contents = implode('', file($settings['theme_dir'] . '/index.template.php'));
689
-		if (preg_match('~\$settings\[\'theme_variants\'\]\s*=(.+?);~', $file_contents, $matches))
690
-				eval('global $settings;' . $matches[0]);
707
+		if (preg_match('~\$settings\[\'theme_variants\'\]\s*=(.+?);~', $file_contents, $matches)) {
708
+						eval('global $settings;' . $matches[0]);
709
+		}
691 710
 	}
692 711
 
693 712
 	// Let mods hook into the theme settings.
@@ -699,37 +718,45 @@  discard block
 block discarded – undo
699 718
 		checkSession();
700 719
 		validateToken('admin-sts');
701 720
 
702
-		if (empty($_POST['options']))
703
-			$_POST['options'] = array();
704
-		if (empty($_POST['default_options']))
705
-			$_POST['default_options'] = array();
721
+		if (empty($_POST['options'])) {
722
+					$_POST['options'] = array();
723
+		}
724
+		if (empty($_POST['default_options'])) {
725
+					$_POST['default_options'] = array();
726
+		}
706 727
 
707 728
 		// Make sure items are cast correctly.
708 729
 		foreach ($context['theme_settings'] as $item)
709 730
 		{
710 731
 			// Disregard this item if this is just a separator.
711
-			if (!is_array($item))
712
-				continue;
732
+			if (!is_array($item)) {
733
+							continue;
734
+			}
713 735
 
714 736
 			foreach (array('options', 'default_options') as $option)
715 737
 			{
716
-				if (!isset($_POST[$option][$item['id']]))
717
-					continue;
738
+				if (!isset($_POST[$option][$item['id']])) {
739
+									continue;
740
+				}
718 741
 				// Checkbox.
719
-				elseif (empty($item['type']))
720
-					$_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0;
742
+				elseif (empty($item['type'])) {
743
+									$_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0;
744
+				}
721 745
 				// Number
722
-				elseif ($item['type'] == 'number')
723
-					$_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']];
746
+				elseif ($item['type'] == 'number') {
747
+									$_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']];
748
+				}
724 749
 			}
725 750
 		}
726 751
 
727 752
 		// Set up the sql query.
728 753
 		$inserts = array();
729
-		foreach ($_POST['options'] as $opt => $val)
730
-			$inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val);
731
-		foreach ($_POST['default_options'] as $opt => $val)
732
-			$inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val);
754
+		foreach ($_POST['options'] as $opt => $val) {
755
+					$inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val);
756
+		}
757
+		foreach ($_POST['default_options'] as $opt => $val) {
758
+					$inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val);
759
+		}
733 760
 		// If we're actually inserting something..
734 761
 		if (!empty($inserts))
735 762
 		{
@@ -755,8 +782,9 @@  discard block
 block discarded – undo
755 782
 
756 783
 	foreach ($settings as $setting => $dummy)
757 784
 	{
758
-		if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs')))
759
-			$settings[$setting] = htmlspecialchars__recursive($settings[$setting]);
785
+		if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs'))) {
786
+					$settings[$setting] = htmlspecialchars__recursive($settings[$setting]);
787
+		}
760 788
 	}
761 789
 
762 790
 	$context['settings'] = $context['theme_settings'];
@@ -765,18 +793,21 @@  discard block
 block discarded – undo
765 793
 	foreach ($context['settings'] as $i => $setting)
766 794
 	{
767 795
 		// Separators are dummies, so leave them alone.
768
-		if (!is_array($setting))
769
-			continue;
796
+		if (!is_array($setting)) {
797
+					continue;
798
+		}
770 799
 
771
-		if (!isset($setting['type']) || $setting['type'] == 'bool')
772
-			$context['settings'][$i]['type'] = 'checkbox';
773
-		elseif ($setting['type'] == 'int' || $setting['type'] == 'integer')
774
-			$context['settings'][$i]['type'] = 'number';
775
-		elseif ($setting['type'] == 'string')
776
-			$context['settings'][$i]['type'] = 'text';
800
+		if (!isset($setting['type']) || $setting['type'] == 'bool') {
801
+					$context['settings'][$i]['type'] = 'checkbox';
802
+		} elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') {
803
+					$context['settings'][$i]['type'] = 'number';
804
+		} elseif ($setting['type'] == 'string') {
805
+					$context['settings'][$i]['type'] = 'text';
806
+		}
777 807
 
778
-		if (isset($setting['options']))
779
-			$context['settings'][$i]['type'] = 'list';
808
+		if (isset($setting['options'])) {
809
+					$context['settings'][$i]['type'] = 'list';
810
+		}
780 811
 
781 812
 		$context['settings'][$i]['value'] = !isset($settings[$setting['id']]) ? '' : $settings[$setting['id']];
782 813
 	}
@@ -829,8 +860,9 @@  discard block
 block discarded – undo
829 860
 	$themeID = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id'];
830 861
 
831 862
 	// You can't delete the default theme!
832
-	if ($themeID == 1)
833
-		fatal_lang_error('no_access', false);
863
+	if ($themeID == 1) {
864
+			fatal_lang_error('no_access', false);
865
+	}
834 866
 
835 867
 	$theme_info = get_single_theme($themeID);
836 868
 
@@ -838,8 +870,9 @@  discard block
 block discarded – undo
838 870
 	remove_theme($themeID);
839 871
 
840 872
 	// And remove all its files and folders too.
841
-	if (!empty($theme_info) && !empty($theme_info['theme_dir']))
842
-		remove_dir($theme_info['theme_dir']);
873
+	if (!empty($theme_info) && !empty($theme_info['theme_dir'])) {
874
+			remove_dir($theme_info['theme_dir']);
875
+	}
843 876
 
844 877
 	// Go back to the list page.
845 878
 	redirectexit('action=admin;area=theme;sa=list;' . $context['session_var'] . '=' . $context['session_id'] . ';done=removing');
@@ -864,12 +897,14 @@  discard block
 block discarded – undo
864 897
 	$enableThemes = explode(',', $modSettings['enableThemes']);
865 898
 
866 899
 	// Are we disabling it?
867
-	if (isset($_GET['disabled']))
868
-		$enableThemes = array_diff($enableThemes, array($themeID));
900
+	if (isset($_GET['disabled'])) {
901
+			$enableThemes = array_diff($enableThemes, array($themeID));
902
+	}
869 903
 
870 904
 	// Nope? then enable it!
871
-	else
872
-		$enableThemes[] = (string) $themeID;
905
+	else {
906
+			$enableThemes[] = (string) $themeID;
907
+	}
873 908
 
874 909
 	// Update the setting.
875 910
 	$enableThemes = strtr(implode(',', $enableThemes), array(',,' => ','));
@@ -904,18 +939,21 @@  discard block
 block discarded – undo
904 939
 
905 940
 	$_SESSION['id_theme'] = 0;
906 941
 
907
-	if (isset($_GET['id']))
908
-		$_GET['th'] = $_GET['id'];
942
+	if (isset($_GET['id'])) {
943
+			$_GET['th'] = $_GET['id'];
944
+	}
909 945
 
910 946
 	// Saving a variant cause JS doesn't work - pretend it did ;)
911 947
 	if (isset($_POST['save']))
912 948
 	{
913 949
 		// Which theme?
914
-		foreach ($_POST['save'] as $k => $v)
915
-			$_GET['th'] = (int) $k;
950
+		foreach ($_POST['save'] as $k => $v) {
951
+					$_GET['th'] = (int) $k;
952
+		}
916 953
 
917
-		if (isset($_POST['vrt'][$k]))
918
-			$_GET['vrt'] = $_POST['vrt'][$k];
954
+		if (isset($_POST['vrt'][$k])) {
955
+					$_GET['vrt'] = $_POST['vrt'][$k];
956
+		}
919 957
 	}
920 958
 
921 959
 	// Have we made a decision, or are we just browsing?
@@ -1004,10 +1042,10 @@  discard block
 block discarded – undo
1004 1042
 				);
1005 1043
 				cache_put_data('theme_settings-' . $_GET['th'] . ':' . (int) $_REQUEST['u'], null, 90);
1006 1044
 
1007
-				if ($user_info['id'] == $_REQUEST['u'])
1008
-					$_SESSION['id_variant'] = 0;
1009
-			}
1010
-			elseif ($_GET['th'] == 0)
1045
+				if ($user_info['id'] == $_REQUEST['u']) {
1046
+									$_SESSION['id_variant'] = 0;
1047
+				}
1048
+			} elseif ($_GET['th'] == 0)
1011 1049
 			{
1012 1050
 				// Remove any custom variants.
1013 1051
 				$smcFunc['db_query']('', '
@@ -1088,12 +1126,13 @@  discard block
 block discarded – undo
1088 1126
 		);
1089 1127
 		while ($row = $smcFunc['db_fetch_assoc']($request))
1090 1128
 		{
1091
-			if (!isset($context['available_themes'][$row['id_theme']]))
1092
-				$context['available_themes'][$row['id_theme']] = array(
1129
+			if (!isset($context['available_themes'][$row['id_theme']])) {
1130
+							$context['available_themes'][$row['id_theme']] = array(
1093 1131
 					'id' => $row['id_theme'],
1094 1132
 					'selected' => $context['current_theme'] == $row['id_theme'],
1095 1133
 					'num_users' => 0
1096 1134
 				);
1135
+			}
1097 1136
 			$context['available_themes'][$row['id_theme']][$row['variable']] = $row['value'];
1098 1137
 		}
1099 1138
 		$smcFunc['db_free_result']($request);
@@ -1106,9 +1145,9 @@  discard block
 block discarded – undo
1106 1145
 			'num_users' => 0
1107 1146
 		);
1108 1147
 		$guest_theme = 0;
1148
+	} else {
1149
+			$guest_theme = $modSettings['theme_guests'];
1109 1150
 	}
1110
-	else
1111
-		$guest_theme = $modSettings['theme_guests'];
1112 1151
 
1113 1152
 	$request = $smcFunc['db_query']('', '
1114 1153
 		SELECT id_theme, COUNT(*) AS the_count
@@ -1121,15 +1160,17 @@  discard block
 block discarded – undo
1121 1160
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1122 1161
 	{
1123 1162
 		// Figure out which theme it is they are REALLY using.
1124
-		if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',', $modSettings['knownThemes'])))
1125
-			$row['id_theme'] = $guest_theme;
1126
-		elseif (empty($modSettings['theme_allow']))
1127
-			$row['id_theme'] = $guest_theme;
1163
+		if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',', $modSettings['knownThemes']))) {
1164
+					$row['id_theme'] = $guest_theme;
1165
+		} elseif (empty($modSettings['theme_allow'])) {
1166
+					$row['id_theme'] = $guest_theme;
1167
+		}
1128 1168
 
1129
-		if (isset($context['available_themes'][$row['id_theme']]))
1130
-			$context['available_themes'][$row['id_theme']]['num_users'] += $row['the_count'];
1131
-		else
1132
-			$context['available_themes'][$guest_theme]['num_users'] += $row['the_count'];
1169
+		if (isset($context['available_themes'][$row['id_theme']])) {
1170
+					$context['available_themes'][$row['id_theme']]['num_users'] += $row['the_count'];
1171
+		} else {
1172
+					$context['available_themes'][$guest_theme]['num_users'] += $row['the_count'];
1173
+		}
1133 1174
 	}
1134 1175
 	$smcFunc['db_free_result']($request);
1135 1176
 
@@ -1148,8 +1189,9 @@  discard block
 block discarded – undo
1148 1189
 				'id_member' => isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? array(-1, $context['current_member']) : array(-1),
1149 1190
 			)
1150 1191
 		);
1151
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1152
-			$variant_preferences[$row['id_theme']] = $row['value'];
1192
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1193
+					$variant_preferences[$row['id_theme']] = $row['value'];
1194
+		}
1153 1195
 		$smcFunc['db_free_result']($request);
1154 1196
 	}
1155 1197
 
@@ -1160,17 +1202,18 @@  discard block
 block discarded – undo
1160 1202
 	foreach ($context['available_themes'] as $id_theme => $theme_data)
1161 1203
 	{
1162 1204
 		// Don't try to load the forum or board default theme's data... it doesn't have any!
1163
-		if ($id_theme == 0)
1164
-			continue;
1205
+		if ($id_theme == 0) {
1206
+					continue;
1207
+		}
1165 1208
 
1166 1209
 		// The thumbnail needs the correct path.
1167 1210
 		$settings['images_url'] = &$theme_data['images_url'];
1168 1211
 
1169
-		if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php'))
1170
-			include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php');
1171
-		elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php'))
1172
-			include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php');
1173
-		else
1212
+		if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php')) {
1213
+					include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php');
1214
+		} elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php')) {
1215
+					include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php');
1216
+		} else
1174 1217
 		{
1175 1218
 			$txt['theme_thumbnail_href'] = $theme_data['images_url'] . '/thumbnail.png';
1176 1219
 			$txt['theme_description'] = '';
@@ -1195,15 +1238,17 @@  discard block
 block discarded – undo
1195 1238
 					loadLanguage('Settings');
1196 1239
 
1197 1240
 					$context['available_themes'][$id_theme]['variants'] = array();
1198
-					foreach ($settings['theme_variants'] as $variant)
1199
-						$context['available_themes'][$id_theme]['variants'][$variant] = array(
1241
+					foreach ($settings['theme_variants'] as $variant) {
1242
+											$context['available_themes'][$id_theme]['variants'][$variant] = array(
1200 1243
 							'label' => isset($txt['variant_' . $variant]) ? $txt['variant_' . $variant] : $variant,
1201 1244
 							'thumbnail' => !file_exists($theme_data['theme_dir'] . '/images/thumbnail.png') || file_exists($theme_data['theme_dir'] . '/images/thumbnail_' . $variant . '.png') ? $theme_data['images_url'] . '/thumbnail_' . $variant . '.png' : ($theme_data['images_url'] . '/thumbnail.png'),
1202 1245
 						);
1246
+					}
1203 1247
 
1204 1248
 					$context['available_themes'][$id_theme]['selected_variant'] = isset($_GET['vrt']) ? $_GET['vrt'] : (!empty($variant_preferences[$id_theme]) ? $variant_preferences[$id_theme] : (!empty($settings['default_variant']) ? $settings['default_variant'] : $settings['theme_variants'][0]));
1205
-					if (!isset($context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail']))
1206
-						$context['available_themes'][$id_theme]['selected_variant'] = $settings['theme_variants'][0];
1249
+					if (!isset($context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail'])) {
1250
+											$context['available_themes'][$id_theme]['selected_variant'] = $settings['theme_variants'][0];
1251
+					}
1207 1252
 
1208 1253
 					$context['available_themes'][$id_theme]['thumbnail_href'] = $context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail'];
1209 1254
 					// Allow themes to override the text.
@@ -1219,8 +1264,9 @@  discard block
 block discarded – undo
1219 1264
 	// As long as we're not doing the default theme...
1220 1265
 	if (!isset($_REQUEST['u']) || $_REQUEST['u'] >= 0)
1221 1266
 	{
1222
-		if ($guest_theme != 0)
1223
-			$context['available_themes'][0] = $context['available_themes'][$guest_theme];
1267
+		if ($guest_theme != 0) {
1268
+					$context['available_themes'][0] = $context['available_themes'][$guest_theme];
1269
+		}
1224 1270
 
1225 1271
 		$context['available_themes'][0]['id'] = 0;
1226 1272
 		$context['available_themes'][0]['name'] = $txt['theme_forum_default'];
@@ -1269,14 +1315,16 @@  discard block
 block discarded – undo
1269 1315
 		$action = $smcFunc['htmlspecialchars'](trim($_GET['do']));
1270 1316
 
1271 1317
 		// Got any info from the specific form?
1272
-		if (!isset($_POST['save_' . $action]))
1273
-			fatal_lang_error('theme_install_no_action', false);
1318
+		if (!isset($_POST['save_' . $action])) {
1319
+					fatal_lang_error('theme_install_no_action', false);
1320
+		}
1274 1321
 
1275 1322
 		validateToken('admin-t-' . $action);
1276 1323
 
1277 1324
 		// Hopefully the themes directory is writable, or we might have a problem.
1278
-		if (!is_writable($themedir))
1279
-			fatal_lang_error('theme_install_write_error', 'critical');
1325
+		if (!is_writable($themedir)) {
1326
+					fatal_lang_error('theme_install_write_error', 'critical');
1327
+		}
1280 1328
 
1281 1329
 		// Call the function and handle the result.
1282 1330
 		$result = $subActions[$action]();
@@ -1291,9 +1339,10 @@  discard block
 block discarded – undo
1291 1339
 	}
1292 1340
 
1293 1341
 	// Nope, show a nice error.
1294
-	else
1295
-		fatal_lang_error('theme_install_no_action', false);
1296
-}
1342
+	else {
1343
+			fatal_lang_error('theme_install_no_action', false);
1344
+	}
1345
+	}
1297 1346
 
1298 1347
 /**
1299 1348
  * Installs a theme from a theme package.
@@ -1309,8 +1358,9 @@  discard block
 block discarded – undo
1309 1358
 	$dirtemp = $themedir . '/temp';
1310 1359
 
1311 1360
 	// Make sure the temp dir doesn't already exist
1312
-	if (file_exists($dirtemp))
1313
-		remove_dir($dirtemp);
1361
+	if (file_exists($dirtemp)) {
1362
+			remove_dir($dirtemp);
1363
+	}
1314 1364
 
1315 1365
 	// Create the temp dir.
1316 1366
 	mkdir($dirtemp, 0777);
@@ -1322,17 +1372,20 @@  discard block
 block discarded – undo
1322 1372
 		smf_chmod($dirtemp, '0755');
1323 1373
 
1324 1374
 		// How about now?
1325
-		if (!is_writable($dirtemp))
1326
-			fatal_lang_error('theme_install_write_error', 'critical');
1375
+		if (!is_writable($dirtemp)) {
1376
+					fatal_lang_error('theme_install_write_error', 'critical');
1377
+		}
1327 1378
 	}
1328 1379
 
1329 1380
 	// This happens when the admin session is gone and the user has to login again.
1330
-	if (!isset($_FILES) || !isset($_FILES['theme_gz']) || empty($_FILES['theme_gz']))
1331
-		redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']);
1381
+	if (!isset($_FILES) || !isset($_FILES['theme_gz']) || empty($_FILES['theme_gz'])) {
1382
+			redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']);
1383
+	}
1332 1384
 
1333 1385
 	// Another error check layer, something went wrong with the upload.
1334
-	if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0)
1335
-		fatal_lang_error('theme_install_error_file_' . $_FILES['theme_gz']['error'], false);
1386
+	if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0) {
1387
+			fatal_lang_error('theme_install_error_file_' . $_FILES['theme_gz']['error'], false);
1388
+	}
1336 1389
 
1337 1390
 	// Get the theme's name.
1338 1391
 	$name = pathinfo($_FILES['theme_gz']['name'], PATHINFO_FILENAME);
@@ -1363,11 +1416,10 @@  discard block
 block discarded – undo
1363 1416
 
1364 1417
 		// return all the info.
1365 1418
 		return $context['to_install'];
1419
+	} else {
1420
+			fatal_lang_error('theme_install_error_title', false);
1421
+	}
1366 1422
 	}
1367
-
1368
-	else
1369
-		fatal_lang_error('theme_install_error_title', false);
1370
-}
1371 1423
 
1372 1424
 /**
1373 1425
  * Makes a copy from the default theme, assigns a name for it and installs it.
@@ -1381,15 +1433,17 @@  discard block
 block discarded – undo
1381 1433
 	global $forum_version;
1382 1434
 
1383 1435
 	// There's gotta be something to work with.
1384
-	if (!isset($_REQUEST['copy']) || empty($_REQUEST['copy']))
1385
-		fatal_lang_error('theme_install_error_title', false);
1436
+	if (!isset($_REQUEST['copy']) || empty($_REQUEST['copy'])) {
1437
+			fatal_lang_error('theme_install_error_title', false);
1438
+	}
1386 1439
 
1387 1440
 	// Get a cleaner version.
1388 1441
 	$name = preg_replace('~[^A-Za-z0-9_\- ]~', '', $_REQUEST['copy']);
1389 1442
 
1390 1443
 	// Is there a theme already named like this?
1391
-	if (file_exists($themedir . '/' . $name))
1392
-		fatal_lang_error('theme_install_already_dir', false);
1444
+	if (file_exists($themedir . '/' . $name)) {
1445
+			fatal_lang_error('theme_install_already_dir', false);
1446
+	}
1393 1447
 
1394 1448
 	// This is a brand new theme so set all possible values.
1395 1449
 	$context['to_install'] = array(
@@ -1409,8 +1463,9 @@  discard block
 block discarded – undo
1409 1463
 
1410 1464
 	// Buy some time.
1411 1465
 	@set_time_limit(600);
1412
-	if (function_exists('apache_reset_timeout'))
1413
-		@apache_reset_timeout();
1466
+	if (function_exists('apache_reset_timeout')) {
1467
+			@apache_reset_timeout();
1468
+	}
1414 1469
 
1415 1470
 	// Create subdirectories for css and javascript files.
1416 1471
 	mkdir($context['to_install']['theme_dir'] . '/css', 0777);
@@ -1446,12 +1501,13 @@  discard block
 block discarded – undo
1446 1501
 
1447 1502
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1448 1503
 	{
1449
-		if ($row['variable'] == 'theme_templates')
1450
-			$theme_templates = $row['value'];
1451
-		elseif ($row['variable'] == 'theme_layers')
1452
-			$theme_layers = $row['value'];
1453
-		else
1454
-			continue;
1504
+		if ($row['variable'] == 'theme_templates') {
1505
+					$theme_templates = $row['value'];
1506
+		} elseif ($row['variable'] == 'theme_layers') {
1507
+					$theme_layers = $row['value'];
1508
+		} else {
1509
+					continue;
1510
+		}
1455 1511
 	}
1456 1512
 
1457 1513
 	$smcFunc['db_free_result']($request);
@@ -1510,12 +1566,14 @@  discard block
 block discarded – undo
1510 1566
 	global $themedir, $themeurl, $context;
1511 1567
 
1512 1568
 	// Cannot use the theme dir as a theme dir.
1513
-	if (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir))
1514
-		fatal_lang_error('theme_install_invalid_dir', false);
1569
+	if (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir)) {
1570
+			fatal_lang_error('theme_install_invalid_dir', false);
1571
+	}
1515 1572
 
1516 1573
 	// Check is there is "something" on the dir.
1517
-	elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml'))
1518
-		fatal_lang_error('theme_install_error', false);
1574
+	elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml')) {
1575
+			fatal_lang_error('theme_install_error', false);
1576
+	}
1519 1577
 
1520 1578
 	$name = basename($_REQUEST['theme_dir']);
1521 1579
 	$name = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $name);
@@ -1559,24 +1617,27 @@  discard block
 block discarded – undo
1559 1617
 	}
1560 1618
 
1561 1619
 	// Any special layers?
1562
-	if (isset($settings['catch_action']['layers']))
1563
-		$context['template_layers'] = $settings['catch_action']['layers'];
1620
+	if (isset($settings['catch_action']['layers'])) {
1621
+			$context['template_layers'] = $settings['catch_action']['layers'];
1622
+	}
1564 1623
 
1565 1624
 	// Any function to call?
1566 1625
 	if (isset($settings['catch_action']['function']))
1567 1626
 	{
1568 1627
 		$hook = $settings['catch_action']['function'];
1569 1628
 
1570
-		if (!isset($settings['catch_action']['filename']))
1571
-			$settings['catch_action']['filename'] = '';
1629
+		if (!isset($settings['catch_action']['filename'])) {
1630
+					$settings['catch_action']['filename'] = '';
1631
+		}
1572 1632
 
1573 1633
 		add_integration_function('integrate_wrap_action', $hook, false, $settings['catch_action']['filename'], false);
1574 1634
 		call_integration_hook('integrate_wrap_action');
1575 1635
 	}
1576 1636
 	// And finally, the main sub template ;).
1577
-	if (isset($settings['catch_action']['sub_template']))
1578
-		$context['sub_template'] = $settings['catch_action']['sub_template'];
1579
-}
1637
+	if (isset($settings['catch_action']['sub_template'])) {
1638
+			$context['sub_template'] = $settings['catch_action']['sub_template'];
1639
+	}
1640
+	}
1580 1641
 
1581 1642
 /**
1582 1643
  * Set an option via javascript.
@@ -1595,12 +1656,14 @@  discard block
 block discarded – undo
1595 1656
 	checkSession('get');
1596 1657
 
1597 1658
 	// This good-for-nothing pixel is being used to keep the session alive.
1598
-	if (empty($_GET['var']) || !isset($_GET['val']))
1599
-		redirectexit($settings['images_url'] . '/blank.png');
1659
+	if (empty($_GET['var']) || !isset($_GET['val'])) {
1660
+			redirectexit($settings['images_url'] . '/blank.png');
1661
+	}
1600 1662
 
1601 1663
 	// Sorry, guests can't go any further than this.
1602
-	if ($user_info['is_guest'] || $user_info['id'] == 0)
1603
-		obExit(false);
1664
+	if ($user_info['is_guest'] || $user_info['id'] == 0) {
1665
+			obExit(false);
1666
+	}
1604 1667
 
1605 1668
 	$reservedVars = array(
1606 1669
 		'actual_theme_url',
@@ -1623,8 +1686,9 @@  discard block
 block discarded – undo
1623 1686
 	);
1624 1687
 
1625 1688
 	// Can't change reserved vars.
1626
-	if (in_array(strtolower($_GET['var']), $reservedVars))
1627
-		redirectexit($settings['images_url'] . '/blank.png');
1689
+	if (in_array(strtolower($_GET['var']), $reservedVars)) {
1690
+			redirectexit($settings['images_url'] . '/blank.png');
1691
+	}
1628 1692
 
1629 1693
 	// Use a specific theme?
1630 1694
 	if (isset($_GET['th']) || isset($_GET['id']))
@@ -1640,8 +1704,9 @@  discard block
 block discarded – undo
1640 1704
 	{
1641 1705
 		$options['admin_preferences'] = !empty($options['admin_preferences']) ? $smcFunc['json_decode']($options['admin_preferences'], true) : array();
1642 1706
 		// New thingy...
1643
-		if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5)
1644
-			$options['admin_preferences'][$_GET['admin_key']] = $_GET['val'];
1707
+		if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5) {
1708
+					$options['admin_preferences'][$_GET['admin_key']] = $_GET['val'];
1709
+		}
1645 1710
 
1646 1711
 		// Change the value to be something nice,
1647 1712
 		$_GET['val'] = $smcFunc['json_encode']($options['admin_preferences']);
@@ -1671,8 +1736,9 @@  discard block
 block discarded – undo
1671 1736
 	global $context, $scripturl, $boarddir, $smcFunc, $txt;
1672 1737
 
1673 1738
 	// @todo Should this be removed?
1674
-	if (isset($_REQUEST['preview']))
1675
-		die('die() with fire');
1739
+	if (isset($_REQUEST['preview'])) {
1740
+			die('die() with fire');
1741
+	}
1676 1742
 
1677 1743
 	isAllowedTo('admin_forum');
1678 1744
 	loadTemplate('Themes');
@@ -1686,11 +1752,11 @@  discard block
 block discarded – undo
1686 1752
 		foreach ($context['themes'] as $key => $theme)
1687 1753
 		{
1688 1754
 			// There has to be a Settings template!
1689
-			if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css'))
1690
-				unset($context['themes'][$key]);
1691
-
1692
-			else
1693
-				$context['themes'][$key]['can_edit_style'] = file_exists($theme['theme_dir'] . '/css/index.css');
1755
+			if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css')) {
1756
+							unset($context['themes'][$key]);
1757
+			} else {
1758
+							$context['themes'][$key]['can_edit_style'] = file_exists($theme['theme_dir'] . '/css/index.css');
1759
+			}
1694 1760
 		}
1695 1761
 
1696 1762
 		$context['sub_template'] = 'edit_list';
@@ -1705,22 +1771,24 @@  discard block
 block discarded – undo
1705 1771
 	$context['theme_id'] = $currentTheme['id'];
1706 1772
 	$context['browse_title'] = sprintf($txt['themeadmin_browsing_theme'], $currentTheme['name']);
1707 1773
 
1708
-	if (!file_exists($currentTheme['theme_dir'] . '/index.template.php') && !file_exists($currentTheme['theme_dir'] . '/css/index.css'))
1709
-		fatal_lang_error('theme_edit_missing', false);
1774
+	if (!file_exists($currentTheme['theme_dir'] . '/index.template.php') && !file_exists($currentTheme['theme_dir'] . '/css/index.css')) {
1775
+			fatal_lang_error('theme_edit_missing', false);
1776
+	}
1710 1777
 
1711 1778
 	if (!isset($_REQUEST['filename']))
1712 1779
 	{
1713 1780
 		if (isset($_GET['directory']))
1714 1781
 		{
1715
-			if (substr($_GET['directory'], 0, 1) == '.')
1716
-				$_GET['directory'] = '';
1717
-			else
1782
+			if (substr($_GET['directory'], 0, 1) == '.') {
1783
+							$_GET['directory'] = '';
1784
+			} else
1718 1785
 			{
1719 1786
 				$_GET['directory'] = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $_GET['directory']);
1720 1787
 
1721 1788
 				$temp = realpath($currentTheme['theme_dir'] . '/' . $_GET['directory']);
1722
-				if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir']))
1723
-					$_GET['directory'] = '';
1789
+				if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) {
1790
+									$_GET['directory'] = '';
1791
+				}
1724 1792
 			}
1725 1793
 		}
1726 1794
 
@@ -1739,44 +1807,47 @@  discard block
 block discarded – undo
1739 1807
 				'href' => $scripturl . '?action=admin;area=theme;th=' . $_GET['th'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=edit;directory=' . $temp,
1740 1808
 				'size' => '',
1741 1809
 			));
1810
+		} else {
1811
+					$context['theme_files'] = get_file_listing($currentTheme['theme_dir'], '');
1742 1812
 		}
1743
-		else
1744
-			$context['theme_files'] = get_file_listing($currentTheme['theme_dir'], '');
1745 1813
 		
1746 1814
 		// Do not list minified_ files
1747 1815
 		foreach($context['theme_files'] as $key=>$file)
1748 1816
 		{
1749
-			if(strpos($file['filename'], 'minified_') !== FALSE)
1750
-				unset($context['theme_files'][$key]);
1817
+			if(strpos($file['filename'], 'minified_') !== FALSE) {
1818
+							unset($context['theme_files'][$key]);
1819
+			}
1751 1820
 		}
1752 1821
 
1753 1822
 		$context['sub_template'] = 'edit_browse';
1754 1823
 
1755 1824
 		return;
1756
-	}
1757
-	else
1825
+	} else
1758 1826
 	{
1759
-		if (substr($_REQUEST['filename'], 0, 1) == '.')
1760
-			$_REQUEST['filename'] = '';
1761
-		else
1827
+		if (substr($_REQUEST['filename'], 0, 1) == '.') {
1828
+					$_REQUEST['filename'] = '';
1829
+		} else
1762 1830
 		{
1763 1831
 			$_REQUEST['filename'] = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $_REQUEST['filename']);
1764 1832
 
1765 1833
 			$temp = realpath($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']);
1766
-			if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir']))
1767
-				$_REQUEST['filename'] = '';
1834
+			if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) {
1835
+							$_REQUEST['filename'] = '';
1836
+			}
1768 1837
 		}
1769 1838
 
1770
-		if (empty($_REQUEST['filename']))
1771
-			fatal_lang_error('theme_edit_missing', false);
1839
+		if (empty($_REQUEST['filename'])) {
1840
+					fatal_lang_error('theme_edit_missing', false);
1841
+		}
1772 1842
 	}
1773 1843
 
1774 1844
 	if (isset($_POST['save']))
1775 1845
 	{
1776 1846
 		if (checkSession('post', '', false) == '' && validateToken('admin-te-' . md5($_GET['th'] . '-' . $_REQUEST['filename']), 'post', false) == true)
1777 1847
 		{
1778
-			if (is_array($_POST['entire_file']))
1779
-				$_POST['entire_file'] = implode("\n", $_POST['entire_file']);
1848
+			if (is_array($_POST['entire_file'])) {
1849
+							$_POST['entire_file'] = implode("\n", $_POST['entire_file']);
1850
+			}
1780 1851
 
1781 1852
 			$_POST['entire_file'] = rtrim(strtr($_POST['entire_file'], array("\r" => '', '   ' => "\t")));
1782 1853
 
@@ -1788,10 +1859,11 @@  discard block
 block discarded – undo
1788 1859
 				fclose($fp);
1789 1860
 
1790 1861
 				$error = @file_get_contents($currentTheme['theme_url'] . '/tmp_' . session_id() . '.php');
1791
-				if (preg_match('~ <b>(\d+)</b><br( /)?' . '>$~i', $error) != 0)
1792
-					$error_file = $currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php';
1793
-				else
1794
-					unlink($currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php');
1862
+				if (preg_match('~ <b>(\d+)</b><br( /)?' . '>$~i', $error) != 0) {
1863
+									$error_file = $currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php';
1864
+				} else {
1865
+									unlink($currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php');
1866
+				}
1795 1867
 			}
1796 1868
 
1797 1869
 			if (!isset($error_file))
@@ -1812,10 +1884,11 @@  discard block
 block discarded – undo
1812 1884
 			$context['sub_template'] = 'edit_file';
1813 1885
 
1814 1886
 			// Recycle the submitted data.
1815
-			if (is_array($_POST['entire_file']))
1816
-				$context['entire_file'] = $smcFunc['htmlspecialchars'](implode("\n", $_POST['entire_file']));
1817
-			else
1818
-				$context['entire_file'] = $smcFunc['htmlspecialchars']($_POST['entire_file']);
1887
+			if (is_array($_POST['entire_file'])) {
1888
+							$context['entire_file'] = $smcFunc['htmlspecialchars'](implode("\n", $_POST['entire_file']));
1889
+			} else {
1890
+							$context['entire_file'] = $smcFunc['htmlspecialchars']($_POST['entire_file']);
1891
+			}
1819 1892
 
1820 1893
 			$context['edit_filename'] = $smcFunc['htmlspecialchars']($_POST['filename']);
1821 1894
 
@@ -1838,17 +1911,17 @@  discard block
 block discarded – undo
1838 1911
 		$context['sub_template'] = 'edit_style';
1839 1912
 
1840 1913
 		$context['entire_file'] = $smcFunc['htmlspecialchars'](strtr(file_get_contents($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']), array("\t" => '   ')));
1841
-	}
1842
-	elseif (substr($_REQUEST['filename'], -13) == '.template.php')
1914
+	} elseif (substr($_REQUEST['filename'], -13) == '.template.php')
1843 1915
 	{
1844 1916
 		$context['sub_template'] = 'edit_template';
1845 1917
 
1846
-		if (!isset($error_file))
1847
-			$file_data = file($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']);
1848
-		else
1918
+		if (!isset($error_file)) {
1919
+					$file_data = file($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']);
1920
+		} else
1849 1921
 		{
1850
-			if (preg_match('~(<b>.+?</b>:.+?<b>).+?(</b>.+?<b>\d+</b>)<br( /)?' . '>$~i', $error, $match) != 0)
1851
-				$context['parse_error'] = $match[1] . $_REQUEST['filename'] . $match[2];
1922
+			if (preg_match('~(<b>.+?</b>:.+?<b>).+?(</b>.+?<b>\d+</b>)<br( /)?' . '>$~i', $error, $match) != 0) {
1923
+							$context['parse_error'] = $match[1] . $_REQUEST['filename'] . $match[2];
1924
+			}
1852 1925
 			$file_data = file($error_file);
1853 1926
 			unlink($error_file);
1854 1927
 		}
@@ -1862,8 +1935,9 @@  discard block
 block discarded – undo
1862 1935
 				// Try to format the functions a little nicer...
1863 1936
 				$context['file_parts'][$j]['data'] = trim($context['file_parts'][$j]['data']) . "\n";
1864 1937
 
1865
-				if (empty($context['file_parts'][$j]['lines']))
1866
-					unset($context['file_parts'][$j]);
1938
+				if (empty($context['file_parts'][$j]['lines'])) {
1939
+									unset($context['file_parts'][$j]);
1940
+				}
1867 1941
 				$context['file_parts'][++$j] = array('lines' => 0, 'line' => $i + 1, 'data' => '');
1868 1942
 			}
1869 1943
 
@@ -1872,8 +1946,7 @@  discard block
 block discarded – undo
1872 1946
 		}
1873 1947
 
1874 1948
 		$context['entire_file'] = $smcFunc['htmlspecialchars'](strtr(implode('', $file_data), array("\t" => '   ')));
1875
-	}
1876
-	else
1949
+	} else
1877 1950
 	{
1878 1951
 		$context['sub_template'] = 'edit_file';
1879 1952
 
@@ -1899,8 +1972,9 @@  discard block
 block discarded – undo
1899 1972
 
1900 1973
 	$_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id'];
1901 1974
 
1902
-	if (empty($_GET['th']))
1903
-		fatal_lang_error('theme_install_invalid_id');
1975
+	if (empty($_GET['th'])) {
1976
+			fatal_lang_error('theme_install_invalid_id');
1977
+	}
1904 1978
 
1905 1979
 	// Get the theme info.
1906 1980
 	$theme = get_single_theme($_GET['th']);
@@ -1908,25 +1982,24 @@  discard block
 block discarded – undo
1908 1982
 
1909 1983
 	if (isset($_REQUEST['template']) && preg_match('~[\./\\\\:\0]~', $_REQUEST['template']) == 0)
1910 1984
 	{
1911
-		if (file_exists($settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php'))
1912
-			$filename = $settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php';
1913
-
1914
-		else
1915
-			fatal_lang_error('no_access', false);
1985
+		if (file_exists($settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php')) {
1986
+					$filename = $settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php';
1987
+		} else {
1988
+					fatal_lang_error('no_access', false);
1989
+		}
1916 1990
 
1917 1991
 		$fp = fopen($theme['theme_dir'] . '/' . $_REQUEST['template'] . '.template.php', 'w');
1918 1992
 		fwrite($fp, file_get_contents($filename));
1919 1993
 		fclose($fp);
1920 1994
 
1921 1995
 		redirectexit('action=admin;area=theme;th=' . $context['theme_id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=copy');
1922
-	}
1923
-	elseif (isset($_REQUEST['lang_file']) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $_REQUEST['lang_file']) != 0)
1996
+	} elseif (isset($_REQUEST['lang_file']) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $_REQUEST['lang_file']) != 0)
1924 1997
 	{
1925
-		if (file_exists($settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php'))
1926
-			$filename = $settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php';
1927
-
1928
-		else
1929
-			fatal_lang_error('no_access', false);
1998
+		if (file_exists($settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php')) {
1999
+					$filename = $settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php';
2000
+		} else {
2001
+					fatal_lang_error('no_access', false);
2002
+		}
1930 2003
 
1931 2004
 		$fp = fopen($theme['theme_dir'] . '/languages/' . $_REQUEST['lang_file'] . '.php', 'w');
1932 2005
 		fwrite($fp, file_get_contents($filename));
@@ -1941,16 +2014,18 @@  discard block
 block discarded – undo
1941 2014
 	$dir = dir($settings['default_theme_dir']);
1942 2015
 	while ($entry = $dir->read())
1943 2016
 	{
1944
-		if (substr($entry, -13) == '.template.php')
1945
-			$templates[] = substr($entry, 0, -13);
2017
+		if (substr($entry, -13) == '.template.php') {
2018
+					$templates[] = substr($entry, 0, -13);
2019
+		}
1946 2020
 	}
1947 2021
 	$dir->close();
1948 2022
 
1949 2023
 	$dir = dir($settings['default_theme_dir'] . '/languages');
1950 2024
 	while ($entry = $dir->read())
1951 2025
 	{
1952
-		if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches))
1953
-			$lang_files[] = $matches[1];
2026
+		if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches)) {
2027
+					$lang_files[] = $matches[1];
2028
+		}
1954 2029
 	}
1955 2030
 	$dir->close();
1956 2031
 
@@ -1958,21 +2033,23 @@  discard block
 block discarded – undo
1958 2033
 	natcasesort($lang_files);
1959 2034
 
1960 2035
 	$context['available_templates'] = array();
1961
-	foreach ($templates as $template)
1962
-		$context['available_templates'][$template] = array(
2036
+	foreach ($templates as $template) {
2037
+			$context['available_templates'][$template] = array(
1963 2038
 			'filename' => $template . '.template.php',
1964 2039
 			'value' => $template,
1965 2040
 			'already_exists' => false,
1966 2041
 			'can_copy' => is_writable($theme['theme_dir']),
1967 2042
 		);
2043
+	}
1968 2044
 	$context['available_language_files'] = array();
1969
-	foreach ($lang_files as $file)
1970
-		$context['available_language_files'][$file] = array(
2045
+	foreach ($lang_files as $file) {
2046
+			$context['available_language_files'][$file] = array(
1971 2047
 			'filename' => $file . '.php',
1972 2048
 			'value' => $file,
1973 2049
 			'already_exists' => false,
1974 2050
 			'can_copy' => file_exists($theme['theme_dir'] . '/languages') ? is_writable($theme['theme_dir'] . '/languages') : is_writable($theme['theme_dir']),
1975 2051
 		);
2052
+	}
1976 2053
 
1977 2054
 	$dir = dir($theme['theme_dir']);
1978 2055
 	while ($entry = $dir->read())
Please login to merge, or discard this patch.
Sources/Subs-Boards.php 1 patch
Braces   +256 added lines, -181 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 4
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * Mark a board or multiple boards read.
@@ -28,14 +29,16 @@  discard block
 block discarded – undo
28 29
 	global $user_info, $modSettings, $smcFunc;
29 30
 
30 31
 	// Force $boards to be an array.
31
-	if (!is_array($boards))
32
-		$boards = array($boards);
33
-	else
34
-		$boards = array_unique($boards);
32
+	if (!is_array($boards)) {
33
+			$boards = array($boards);
34
+	} else {
35
+			$boards = array_unique($boards);
36
+	}
35 37
 
36 38
 	// No boards, nothing to mark as read.
37
-	if (empty($boards))
38
-		return;
39
+	if (empty($boards)) {
40
+			return;
41
+	}
39 42
 
40 43
 	// Allow the user to mark a board as unread.
41 44
 	if ($unread)
@@ -65,8 +68,9 @@  discard block
 block discarded – undo
65 68
 	else
66 69
 	{
67 70
 		$markRead = array();
68
-		foreach ($boards as $board)
69
-			$markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $board);
71
+		foreach ($boards as $board) {
72
+					$markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $board);
73
+		}
70 74
 
71 75
 		// Update log_mark_read and log_boards.
72 76
 		$smcFunc['db_insert']('replace',
@@ -99,8 +103,9 @@  discard block
 block discarded – undo
99 103
 	list ($lowest_topic) = $smcFunc['db_fetch_row']($result);
100 104
 	$smcFunc['db_free_result']($result);
101 105
 
102
-	if (empty($lowest_topic))
103
-		return;
106
+	if (empty($lowest_topic)) {
107
+			return;
108
+	}
104 109
 
105 110
 	// @todo SLOW This query seems to eat it sometimes.
106 111
 	$result = $smcFunc['db_query']('', '
@@ -118,12 +123,13 @@  discard block
 block discarded – undo
118 123
 		)
119 124
 	);
120 125
 	$topics = array();
121
-	while ($row = $smcFunc['db_fetch_assoc']($result))
122
-		$topics[] = $row['id_topic'];
126
+	while ($row = $smcFunc['db_fetch_assoc']($result)) {
127
+			$topics[] = $row['id_topic'];
128
+	}
123 129
 	$smcFunc['db_free_result']($result);
124 130
 
125
-	if (!empty($topics))
126
-		$smcFunc['db_query']('', '
131
+	if (!empty($topics)) {
132
+			$smcFunc['db_query']('', '
127 133
 			DELETE FROM {db_prefix}log_topics
128 134
 			WHERE id_member = {int:current_member}
129 135
 				AND id_topic IN ({array_int:topic_list})',
@@ -132,7 +138,8 @@  discard block
 block discarded – undo
132 138
 				'topic_list' => $topics,
133 139
 			)
134 140
 		);
135
-}
141
+	}
142
+	}
136 143
 
137 144
 /**
138 145
  * Mark one or more boards as read.
@@ -157,23 +164,26 @@  discard block
 block discarded – undo
157 164
 			)
158 165
 		);
159 166
 		$boards = array();
160
-		while ($row = $smcFunc['db_fetch_assoc']($result))
161
-			$boards[] = $row['id_board'];
167
+		while ($row = $smcFunc['db_fetch_assoc']($result)) {
168
+					$boards[] = $row['id_board'];
169
+		}
162 170
 		$smcFunc['db_free_result']($result);
163 171
 
164
-		if (!empty($boards))
165
-			markBoardsRead($boards, isset($_REQUEST['unread']));
172
+		if (!empty($boards)) {
173
+					markBoardsRead($boards, isset($_REQUEST['unread']));
174
+		}
166 175
 
167 176
 		$_SESSION['id_msg_last_visit'] = $modSettings['maxMsgID'];
168
-		if (!empty($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'action=unread') !== false)
169
-			redirectexit('action=unread');
177
+		if (!empty($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'action=unread') !== false) {
178
+					redirectexit('action=unread');
179
+		}
170 180
 
171
-		if (isset($_SESSION['topicseen_cache']))
172
-			$_SESSION['topicseen_cache'] = array();
181
+		if (isset($_SESSION['topicseen_cache'])) {
182
+					$_SESSION['topicseen_cache'] = array();
183
+		}
173 184
 
174 185
 		redirectexit();
175
-	}
176
-	elseif (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'unreadreplies')
186
+	} elseif (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'unreadreplies')
177 187
 	{
178 188
 		// Make sure all the topics are integers!
179 189
 		$topics = array_map('intval', explode('-', $_REQUEST['topics']));
@@ -189,13 +199,15 @@  discard block
 block discarded – undo
189 199
 			)
190 200
 		);
191 201
 		$logged_topics = array();
192
-		while ($row = $smcFunc['db_fetch_assoc']($request))
193
-			$logged_topics[$row['id_topic']] = $row['unwatched'];
202
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
203
+					$logged_topics[$row['id_topic']] = $row['unwatched'];
204
+		}
194 205
 		$smcFunc['db_free_result']($request);
195 206
 
196 207
 		$markRead = array();
197
-		foreach ($topics as $id_topic)
198
-			$markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $id_topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0));
208
+		foreach ($topics as $id_topic) {
209
+					$markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $id_topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0));
210
+		}
199 211
 
200 212
 		$smcFunc['db_insert']('replace',
201 213
 			'{db_prefix}log_topics',
@@ -204,8 +216,9 @@  discard block
 block discarded – undo
204 216
 			array('id_member', 'id_topic')
205 217
 		);
206 218
 
207
-		if (isset($_SESSION['topicseen_cache']))
208
-			$_SESSION['topicseen_cache'] = array();
219
+		if (isset($_SESSION['topicseen_cache'])) {
220
+					$_SESSION['topicseen_cache'] = array();
221
+		}
209 222
 
210 223
 		redirectexit('action=unreadreplies');
211 224
 	}
@@ -230,11 +243,13 @@  discard block
 block discarded – undo
230 243
 		if (!empty($_GET['t']))
231 244
 		{
232 245
 			// If they read the whole topic, go back to the beginning.
233
-			if ($_GET['t'] >= $topicinfo['id_last_msg'])
234
-				$earlyMsg = 0;
246
+			if ($_GET['t'] >= $topicinfo['id_last_msg']) {
247
+							$earlyMsg = 0;
248
+			}
235 249
 			// If they want to mark the whole thing read, same.
236
-			elseif ($_GET['t'] <= $topicinfo['id_first_msg'])
237
-				$earlyMsg = 0;
250
+			elseif ($_GET['t'] <= $topicinfo['id_first_msg']) {
251
+							$earlyMsg = 0;
252
+			}
238 253
 			// Otherwise, get the latest message before the named one.
239 254
 			else
240 255
 			{
@@ -255,9 +270,9 @@  discard block
 block discarded – undo
255 270
 			}
256 271
 		}
257 272
 		// Marking read from first page?  That's the whole topic.
258
-		elseif ($_REQUEST['start'] == 0)
259
-			$earlyMsg = 0;
260
-		else
273
+		elseif ($_REQUEST['start'] == 0) {
274
+					$earlyMsg = 0;
275
+		} else
261 276
 		{
262 277
 			$result = $smcFunc['db_query']('', '
263 278
 				SELECT id_msg
@@ -285,8 +300,7 @@  discard block
 block discarded – undo
285 300
 		);
286 301
 
287 302
 		redirectexit('board=' . $board . '.0');
288
-	}
289
-	else
303
+	} else
290 304
 	{
291 305
 		$categories = array();
292 306
 		$boards = array();
@@ -294,17 +308,20 @@  discard block
 block discarded – undo
294 308
 		if (isset($_REQUEST['c']))
295 309
 		{
296 310
 			$_REQUEST['c'] = explode(',', $_REQUEST['c']);
297
-			foreach ($_REQUEST['c'] as $c)
298
-				$categories[] = (int) $c;
311
+			foreach ($_REQUEST['c'] as $c) {
312
+							$categories[] = (int) $c;
313
+			}
299 314
 		}
300 315
 		if (isset($_REQUEST['boards']))
301 316
 		{
302 317
 			$_REQUEST['boards'] = explode(',', $_REQUEST['boards']);
303
-			foreach ($_REQUEST['boards'] as $b)
304
-				$boards[] = (int) $b;
318
+			foreach ($_REQUEST['boards'] as $b) {
319
+							$boards[] = (int) $b;
320
+			}
321
+		}
322
+		if (!empty($board)) {
323
+					$boards[] = (int) $board;
305 324
 		}
306
-		if (!empty($board))
307
-			$boards[] = (int) $board;
308 325
 
309 326
 		if (isset($_REQUEST['children']) && !empty($boards))
310 327
 		{
@@ -324,9 +341,10 @@  discard block
 block discarded – undo
324 341
 					'board_list' => $boards,
325 342
 				)
326 343
 			);
327
-			while ($row = $smcFunc['db_fetch_assoc']($request))
328
-				if (in_array($row['id_parent'], $boards))
344
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
345
+							if (in_array($row['id_parent'], $boards))
329 346
 					$boards[] = $row['id_board'];
347
+			}
330 348
 			$smcFunc['db_free_result']($request);
331 349
 		}
332 350
 
@@ -343,8 +361,9 @@  discard block
 block discarded – undo
343 361
 			$clauseParameters['board_list'] = $boards;
344 362
 		}
345 363
 
346
-		if (empty($clauses))
347
-			redirectexit();
364
+		if (empty($clauses)) {
365
+					redirectexit();
366
+		}
348 367
 
349 368
 		$request = $smcFunc['db_query']('', '
350 369
 			SELECT b.id_board
@@ -355,19 +374,22 @@  discard block
 block discarded – undo
355 374
 			))
356 375
 		);
357 376
 		$boards = array();
358
-		while ($row = $smcFunc['db_fetch_assoc']($request))
359
-			$boards[] = $row['id_board'];
377
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
378
+					$boards[] = $row['id_board'];
379
+		}
360 380
 		$smcFunc['db_free_result']($request);
361 381
 
362
-		if (empty($boards))
363
-			redirectexit();
382
+		if (empty($boards)) {
383
+					redirectexit();
384
+		}
364 385
 
365 386
 		markBoardsRead($boards, isset($_REQUEST['unread']));
366 387
 
367 388
 		foreach ($boards as $b)
368 389
 		{
369
-			if (isset($_SESSION['topicseen_cache'][$b]))
370
-				$_SESSION['topicseen_cache'][$b] = array();
390
+			if (isset($_SESSION['topicseen_cache'][$b])) {
391
+							$_SESSION['topicseen_cache'][$b] = array();
392
+			}
371 393
 		}
372 394
 
373 395
 		if (!isset($_REQUEST['unread']))
@@ -385,8 +407,9 @@  discard block
 block discarded – undo
385 407
 			if ($smcFunc['db_num_rows']($result) > 0)
386 408
 			{
387 409
 				$logBoardInserts = array();
388
-				while ($row = $smcFunc['db_fetch_assoc']($result))
389
-					$logBoardInserts[] = array($modSettings['maxMsgID'], $user_info['id'], $row['id_board']);
410
+				while ($row = $smcFunc['db_fetch_assoc']($result)) {
411
+									$logBoardInserts[] = array($modSettings['maxMsgID'], $user_info['id'], $row['id_board']);
412
+				}
390 413
 
391 414
 				$smcFunc['db_insert']('replace',
392 415
 					'{db_prefix}log_boards',
@@ -397,17 +420,18 @@  discard block
 block discarded – undo
397 420
 			}
398 421
 			$smcFunc['db_free_result']($result);
399 422
 
400
-			if (empty($board))
401
-				redirectexit();
402
-			else
403
-				redirectexit('board=' . $board . '.0');
404
-		}
405
-		else
423
+			if (empty($board)) {
424
+							redirectexit();
425
+			} else {
426
+							redirectexit('board=' . $board . '.0');
427
+			}
428
+		} else
406 429
 		{
407
-			if (empty($board_info['parent']))
408
-				redirectexit();
409
-			else
410
-				redirectexit('board=' . $board_info['parent'] . '.0');
430
+			if (empty($board_info['parent'])) {
431
+							redirectexit();
432
+			} else {
433
+							redirectexit('board=' . $board_info['parent'] . '.0');
434
+			}
411 435
 		}
412 436
 	}
413 437
 }
@@ -432,11 +456,13 @@  discard block
 block discarded – undo
432 456
 			'selected_message' => (int) $messageID,
433 457
 		)
434 458
 	);
435
-	if ($smcFunc['db_num_rows']($result) > 0)
436
-		list ($memberID) = $smcFunc['db_fetch_row']($result);
459
+	if ($smcFunc['db_num_rows']($result) > 0) {
460
+			list ($memberID) = $smcFunc['db_fetch_row']($result);
461
+	}
437 462
 	// The message doesn't even exist.
438
-	else
439
-		$memberID = 0;
463
+	else {
464
+			$memberID = 0;
465
+	}
440 466
 	$smcFunc['db_free_result']($result);
441 467
 
442 468
 	return (int) $memberID;
@@ -457,8 +483,9 @@  discard block
 block discarded – undo
457 483
 	getBoardTree();
458 484
 
459 485
 	// Make sure given boards and categories exist.
460
-	if (!isset($boards[$board_id]) || (isset($boardOptions['target_board']) && !isset($boards[$boardOptions['target_board']])) || (isset($boardOptions['target_category']) && !isset($cat_tree[$boardOptions['target_category']])))
461
-		fatal_lang_error('no_board');
486
+	if (!isset($boards[$board_id]) || (isset($boardOptions['target_board']) && !isset($boards[$boardOptions['target_board']])) || (isset($boardOptions['target_category']) && !isset($cat_tree[$boardOptions['target_category']]))) {
487
+			fatal_lang_error('no_board');
488
+	}
462 489
 
463 490
 	$id = $board_id;
464 491
 	call_integration_hook('integrate_pre_modify_board', array($id, &$boardOptions));
@@ -486,8 +513,9 @@  discard block
 block discarded – undo
486 513
 			$child_level = 0;
487 514
 			$id_parent = 0;
488 515
 			$after = 0;
489
-			foreach ($cat_tree[$id_cat]['children'] as $id_board => $dummy)
490
-				$after = max($after, $boards[$id_board]['order']);
516
+			foreach ($cat_tree[$id_cat]['children'] as $id_board => $dummy) {
517
+							$after = max($after, $boards[$id_board]['order']);
518
+			}
491 519
 		}
492 520
 
493 521
 		// Make the board a child of a given board.
@@ -498,17 +526,19 @@  discard block
 block discarded – undo
498 526
 			$id_parent = $boardOptions['target_board'];
499 527
 
500 528
 			// People can be creative, in many ways...
501
-			if (isChildOf($id_parent, $board_id))
502
-				fatal_lang_error('mboards_parent_own_child_error', false);
503
-			elseif ($id_parent == $board_id)
504
-				fatal_lang_error('mboards_board_own_child_error', false);
529
+			if (isChildOf($id_parent, $board_id)) {
530
+							fatal_lang_error('mboards_parent_own_child_error', false);
531
+			} elseif ($id_parent == $board_id) {
532
+							fatal_lang_error('mboards_board_own_child_error', false);
533
+			}
505 534
 
506 535
 			$after = $boards[$boardOptions['target_board']]['order'];
507 536
 
508 537
 			// Check if there are already children and (if so) get the max board order.
509
-			if (!empty($boards[$id_parent]['tree']['children']) && empty($boardOptions['move_first_child']))
510
-				foreach ($boards[$id_parent]['tree']['children'] as $childBoard_id => $dummy)
538
+			if (!empty($boards[$id_parent]['tree']['children']) && empty($boardOptions['move_first_child'])) {
539
+							foreach ($boards[$id_parent]['tree']['children'] as $childBoard_id => $dummy)
511 540
 					$after = max($after, $boards[$childBoard_id]['order']);
541
+			}
512 542
 		}
513 543
 
514 544
 		// Place a board before or after another board, on the same child level.
@@ -521,8 +551,9 @@  discard block
 block discarded – undo
521 551
 		}
522 552
 
523 553
 		// Oops...?
524
-		else
525
-			trigger_error('modifyBoard(): The move_to value \'' . $boardOptions['move_to'] . '\' is incorrect', E_USER_ERROR);
554
+		else {
555
+					trigger_error('modifyBoard(): The move_to value \'' . $boardOptions['move_to'] . '\' is incorrect', E_USER_ERROR);
556
+		}
526 557
 
527 558
 		// Get a list of children of this board.
528 559
 		$childList = array();
@@ -531,14 +562,16 @@  discard block
 block discarded – undo
531 562
 		// See if there are changes that affect children.
532 563
 		$childUpdates = array();
533 564
 		$levelDiff = $child_level - $boards[$board_id]['level'];
534
-		if ($levelDiff != 0)
535
-			$childUpdates[] = 'child_level = child_level ' . ($levelDiff > 0 ? '+ ' : '') . '{int:level_diff}';
536
-		if ($id_cat != $boards[$board_id]['category'])
537
-			$childUpdates[] = 'id_cat = {int:category}';
565
+		if ($levelDiff != 0) {
566
+					$childUpdates[] = 'child_level = child_level ' . ($levelDiff > 0 ? '+ ' : '') . '{int:level_diff}';
567
+		}
568
+		if ($id_cat != $boards[$board_id]['category']) {
569
+					$childUpdates[] = 'id_cat = {int:category}';
570
+		}
538 571
 
539 572
 		// Fix the children of this board.
540
-		if (!empty($childList) && !empty($childUpdates))
541
-			$smcFunc['db_query']('', '
573
+		if (!empty($childList) && !empty($childUpdates)) {
574
+					$smcFunc['db_query']('', '
542 575
 				UPDATE {db_prefix}boards
543 576
 				SET ' . implode(',
544 577
 					', $childUpdates) . '
@@ -549,6 +582,7 @@  discard block
 block discarded – undo
549 582
 					'level_diff' => $levelDiff,
550 583
 				)
551 584
 			);
585
+		}
552 586
 
553 587
 		// Make some room for this spot.
554 588
 		$smcFunc['db_query']('', '
@@ -644,8 +678,8 @@  discard block
 block discarded – undo
644 678
 	call_integration_hook('integrate_modify_board', array($id, $boardOptions, &$boardUpdates, &$boardUpdateParameters));
645 679
 
646 680
 	// Do the updates (if any).
647
-	if (!empty($boardUpdates))
648
-		$smcFunc['db_query']('', '
681
+	if (!empty($boardUpdates)) {
682
+			$smcFunc['db_query']('', '
649 683
 			UPDATE {db_prefix}boards
650 684
 			SET
651 685
 				' . implode(',
@@ -655,13 +689,15 @@  discard block
 block discarded – undo
655 689
 				'selected_board' => $board_id,
656 690
 			))
657 691
 		);
692
+	}
658 693
 	
659 694
 	// Do permission sync
660 695
 	if (!empty($boardUpdateParameters['deny_groups']))
661 696
 	{
662 697
 		$insert = array();
663
-		foreach($boardOptions['deny_groups'] as $value)
664
-			$insert[] = array($value, $board_id, 1);
698
+		foreach($boardOptions['deny_groups'] as $value) {
699
+					$insert[] = array($value, $board_id, 1);
700
+		}
665 701
 
666 702
 		$smcFunc['db_query']('', '
667 703
 			DELETE FROM {db_prefix}board_permissions_view
@@ -681,8 +717,9 @@  discard block
 block discarded – undo
681 717
 	if (!empty($boardUpdateParameters['member_groups']))
682 718
 	{
683 719
 		$insert = array();
684
-		foreach($boardOptions['access_groups'] as $value)
685
-			$insert[] = array($value, $board_id, 0);
720
+		foreach($boardOptions['access_groups'] as $value) {
721
+					$insert[] = array($value, $board_id, 0);
722
+		}
686 723
 		$smcFunc['db_query']('', '
687 724
 			DELETE FROM {db_prefix}board_permissions_view
688 725
 			WHERE id_board = {int:selected_board} AND deny = 0',
@@ -722,13 +759,15 @@  discard block
 block discarded – undo
722 759
 			{
723 760
 				$moderators[$k] = trim($moderators[$k]);
724 761
 
725
-				if (strlen($moderators[$k]) == 0)
726
-					unset($moderators[$k]);
762
+				if (strlen($moderators[$k]) == 0) {
763
+									unset($moderators[$k]);
764
+				}
727 765
 			}
728 766
 
729 767
 			// Find all the id_member's for the member_name's in the list.
730
-			if (empty($boardOptions['moderators']))
731
-				$boardOptions['moderators'] = array();
768
+			if (empty($boardOptions['moderators'])) {
769
+							$boardOptions['moderators'] = array();
770
+			}
732 771
 			if (!empty($moderators))
733 772
 			{
734 773
 				$request = $smcFunc['db_query']('', '
@@ -741,8 +780,9 @@  discard block
 block discarded – undo
741 780
 						'limit' => count($moderators),
742 781
 					)
743 782
 				);
744
-				while ($row = $smcFunc['db_fetch_assoc']($request))
745
-					$boardOptions['moderators'][] = $row['id_member'];
783
+				while ($row = $smcFunc['db_fetch_assoc']($request)) {
784
+									$boardOptions['moderators'][] = $row['id_member'];
785
+				}
746 786
 				$smcFunc['db_free_result']($request);
747 787
 			}
748 788
 		}
@@ -751,8 +791,9 @@  discard block
 block discarded – undo
751 791
 		if (!empty($boardOptions['moderators']))
752 792
 		{
753 793
 			$inserts = array();
754
-			foreach ($boardOptions['moderators'] as $moderator)
755
-				$inserts[] = array($board_id, $moderator);
794
+			foreach ($boardOptions['moderators'] as $moderator) {
795
+							$inserts[] = array($board_id, $moderator);
796
+			}
756 797
 
757 798
 			$smcFunc['db_insert']('insert',
758 799
 				'{db_prefix}moderators',
@@ -782,14 +823,16 @@  discard block
 block discarded – undo
782 823
 			{
783 824
 				$moderator_groups[$k] = trim($moderator_groups[$k]);
784 825
 
785
-				if (strlen($moderator_groups[$k]) == 0)
786
-					unset($moderator_groups[$k]);
826
+				if (strlen($moderator_groups[$k]) == 0) {
827
+									unset($moderator_groups[$k]);
828
+				}
787 829
 			}
788 830
 
789 831
 			/* 	Find all the id_group's for all the group names in the list
790 832
 				But skip any invalid ones (invisible/post groups/Administrator/Moderator) */
791
-			if (empty($boardOptions['moderator_groups']))
792
-				$boardOptions['moderator_groups'] = array();
833
+			if (empty($boardOptions['moderator_groups'])) {
834
+							$boardOptions['moderator_groups'] = array();
835
+			}
793 836
 			if (!empty($moderator_groups))
794 837
 			{
795 838
 				$request = $smcFunc['db_query']('', '
@@ -820,8 +863,9 @@  discard block
 block discarded – undo
820 863
 		if (!empty($boardOptions['moderator_groups']))
821 864
 		{
822 865
 			$inserts = array();
823
-			foreach ($boardOptions['moderator_groups'] as $moderator_group)
824
-				$inserts[] = array($board_id, $moderator_group);
866
+			foreach ($boardOptions['moderator_groups'] as $moderator_group) {
867
+							$inserts[] = array($board_id, $moderator_group);
868
+			}
825 869
 
826 870
 			$smcFunc['db_insert']('insert',
827 871
 				'{db_prefix}moderator_groups',
@@ -835,14 +879,16 @@  discard block
 block discarded – undo
835 879
 		updateSettings(array('settings_updated' => time()));
836 880
 	}
837 881
 
838
-	if (isset($boardOptions['move_to']))
839
-		reorderBoards();
882
+	if (isset($boardOptions['move_to'])) {
883
+			reorderBoards();
884
+	}
840 885
 
841 886
 	clean_cache('data');
842 887
 
843
-	if (empty($boardOptions['dont_log']))
844
-		logAction('edit_board', array('board' => $board_id), 'admin');
845
-}
888
+	if (empty($boardOptions['dont_log'])) {
889
+			logAction('edit_board', array('board' => $board_id), 'admin');
890
+	}
891
+	}
846 892
 
847 893
 /**
848 894
  * Create a new board and set its properties and position.
@@ -858,11 +904,13 @@  discard block
 block discarded – undo
858 904
 	global $boards, $smcFunc;
859 905
 
860 906
 	// Trigger an error if one of the required values is not set.
861
-	if (!isset($boardOptions['board_name']) || trim($boardOptions['board_name']) == '' || !isset($boardOptions['move_to']) || !isset($boardOptions['target_category']))
862
-		trigger_error('createBoard(): One or more of the required options is not set', E_USER_ERROR);
907
+	if (!isset($boardOptions['board_name']) || trim($boardOptions['board_name']) == '' || !isset($boardOptions['move_to']) || !isset($boardOptions['target_category'])) {
908
+			trigger_error('createBoard(): One or more of the required options is not set', E_USER_ERROR);
909
+	}
863 910
 
864
-	if (in_array($boardOptions['move_to'], array('child', 'before', 'after')) && !isset($boardOptions['target_board']))
865
-		trigger_error('createBoard(): Target board is not set', E_USER_ERROR);
911
+	if (in_array($boardOptions['move_to'], array('child', 'before', 'after')) && !isset($boardOptions['target_board'])) {
912
+			trigger_error('createBoard(): Target board is not set', E_USER_ERROR);
913
+	}
866 914
 
867 915
 	// Set every optional value to its default value.
868 916
 	$boardOptions += array(
@@ -901,8 +949,9 @@  discard block
 block discarded – undo
901 949
 
902 950
 	$insert = array();
903 951
 
904
-	foreach(explode(',', $default_memgrps) as $value)
905
-			$insert[] = array($value, $board_id, 0);
952
+	foreach(explode(',', $default_memgrps) as $value) {
953
+				$insert[] = array($value, $board_id, 0);
954
+	}
906 955
 
907 956
 	$smcFunc['db_insert']('',
908 957
 		'{db_prefix}board_permissions_view',
@@ -912,8 +961,9 @@  discard block
 block discarded – undo
912 961
 		1
913 962
 	);
914 963
 
915
-	if (empty($board_id))
916
-		return 0;
964
+	if (empty($board_id)) {
965
+			return 0;
966
+	}
917 967
 
918 968
 	// Change the board according to the given specifications.
919 969
 	modifyBoard($board_id, $boardOptions);
@@ -976,8 +1026,9 @@  discard block
 block discarded – undo
976 1026
 	global $sourcedir, $boards, $smcFunc;
977 1027
 
978 1028
 	// No boards to delete? Return!
979
-	if (empty($boards_to_remove))
980
-		return;
1029
+	if (empty($boards_to_remove)) {
1030
+			return;
1031
+	}
981 1032
 
982 1033
 	getBoardTree();
983 1034
 
@@ -988,12 +1039,14 @@  discard block
 block discarded – undo
988 1039
 	{
989 1040
 		// Get a list of the child boards that will also be removed.
990 1041
 		$child_boards_to_remove = array();
991
-		foreach ($boards_to_remove as $board_to_remove)
992
-			recursiveBoards($child_boards_to_remove, $boards[$board_to_remove]['tree']);
1042
+		foreach ($boards_to_remove as $board_to_remove) {
1043
+					recursiveBoards($child_boards_to_remove, $boards[$board_to_remove]['tree']);
1044
+		}
993 1045
 
994 1046
 		// Merge the children with their parents.
995
-		if (!empty($child_boards_to_remove))
996
-			$boards_to_remove = array_unique(array_merge($boards_to_remove, $child_boards_to_remove));
1047
+		if (!empty($child_boards_to_remove)) {
1048
+					$boards_to_remove = array_unique(array_merge($boards_to_remove, $child_boards_to_remove));
1049
+		}
997 1050
 	}
998 1051
 	// Move the children to a safe home.
999 1052
 	else
@@ -1001,10 +1054,11 @@  discard block
 block discarded – undo
1001 1054
 		foreach ($boards_to_remove as $id_board)
1002 1055
 		{
1003 1056
 			// @todo Separate category?
1004
-			if ($moveChildrenTo === 0)
1005
-				fixChildren($id_board, 0, 0);
1006
-			else
1007
-				fixChildren($id_board, $boards[$moveChildrenTo]['level'] + 1, $moveChildrenTo);
1057
+			if ($moveChildrenTo === 0) {
1058
+							fixChildren($id_board, 0, 0);
1059
+			} else {
1060
+							fixChildren($id_board, $boards[$moveChildrenTo]['level'] + 1, $moveChildrenTo);
1061
+			}
1008 1062
 		}
1009 1063
 	}
1010 1064
 
@@ -1018,8 +1072,9 @@  discard block
 block discarded – undo
1018 1072
 		)
1019 1073
 	);
1020 1074
 	$topics = array();
1021
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1022
-		$topics[] = $row['id_topic'];
1075
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1076
+			$topics[] = $row['id_topic'];
1077
+	}
1023 1078
 	$smcFunc['db_free_result']($request);
1024 1079
 
1025 1080
 	require_once($sourcedir . '/RemoveTopic.php');
@@ -1116,8 +1171,9 @@  discard block
 block discarded – undo
1116 1171
 	clean_cache('data');
1117 1172
 
1118 1173
 	// Let's do some serious logging.
1119
-	foreach ($boards_to_remove as $id_board)
1120
-		logAction('delete_board', array('boardname' => $boards[$id_board]['name']), 'admin');
1174
+	foreach ($boards_to_remove as $id_board) {
1175
+			logAction('delete_board', array('boardname' => $boards[$id_board]['name']), 'admin');
1176
+	}
1121 1177
 
1122 1178
 	reorderBoards();
1123 1179
 }
@@ -1136,8 +1192,8 @@  discard block
 block discarded – undo
1136 1192
 	$board_order = 0;
1137 1193
 	foreach ($cat_tree as $catID => $dummy)
1138 1194
 	{
1139
-		foreach ($boardList[$catID] as $boardID)
1140
-			if ($boards[$boardID]['order'] != ++$board_order)
1195
+		foreach ($boardList[$catID] as $boardID) {
1196
+					if ($boards[$boardID]['order'] != ++$board_order)
1141 1197
 				$smcFunc['db_query']('', '
1142 1198
 					UPDATE {db_prefix}boards
1143 1199
 					SET board_order = {int:new_order}
@@ -1147,6 +1203,7 @@  discard block
 block discarded – undo
1147 1203
 						'selected_board' => $boardID,
1148 1204
 					)
1149 1205
 				);
1206
+		}
1150 1207
 	}
1151 1208
 
1152 1209
 	// Empty the board order cache
@@ -1175,8 +1232,9 @@  discard block
 block discarded – undo
1175 1232
 		)
1176 1233
 	);
1177 1234
 	$children = array();
1178
-	while ($row = $smcFunc['db_fetch_assoc']($result))
1179
-		$children[] = $row['id_board'];
1235
+	while ($row = $smcFunc['db_fetch_assoc']($result)) {
1236
+			$children[] = $row['id_board'];
1237
+	}
1180 1238
 	$smcFunc['db_free_result']($result);
1181 1239
 
1182 1240
 	// ...and set it to a new parent and child_level.
@@ -1192,9 +1250,10 @@  discard block
 block discarded – undo
1192 1250
 	);
1193 1251
 
1194 1252
 	// Recursively fix the children of the children.
1195
-	foreach ($children as $child)
1196
-		fixChildren($child, $newLevel + 1, $child);
1197
-}
1253
+	foreach ($children as $child) {
1254
+			fixChildren($child, $newLevel + 1, $child);
1255
+	}
1256
+	}
1198 1257
 
1199 1258
 /**
1200 1259
  * Tries to load up the entire board order and category very very quickly
@@ -1211,8 +1270,9 @@  discard block
 block discarded – undo
1211 1270
 		'boards' => array(),
1212 1271
 	);
1213 1272
 
1214
-	if (!empty($tree_order['boards']))
1215
-		return $tree_order;
1273
+	if (!empty($tree_order['boards'])) {
1274
+			return $tree_order;
1275
+	}
1216 1276
 
1217 1277
 	if (($cached = cache_get_data('board_order', 86400)) !== null)
1218 1278
 	{
@@ -1228,8 +1288,9 @@  discard block
 block discarded – undo
1228 1288
 	);
1229 1289
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1230 1290
 	{
1231
-		if (!in_array($row['id_cat'], $tree_order['cats']))
1232
-			$tree_order['cats'][] = $row['id_cat'];
1291
+		if (!in_array($row['id_cat'], $tree_order['cats'])) {
1292
+					$tree_order['cats'][] = $row['id_cat'];
1293
+		}
1233 1294
 		$tree_order['boards'][] = $row['id_board'];
1234 1295
 	}
1235 1296
 	$smcFunc['db_free_result']($request);
@@ -1249,16 +1310,19 @@  discard block
 block discarded – undo
1249 1310
 	$tree = getTreeOrder();
1250 1311
 
1251 1312
 	$ordered = array();
1252
-	foreach ($tree['boards'] as $board)
1253
-		if (!empty($boards[$board]))
1313
+	foreach ($tree['boards'] as $board) {
1314
+			if (!empty($boards[$board]))
1254 1315
 		{
1255 1316
 			$ordered[$board] = $boards[$board];
1317
+	}
1256 1318
 
1257
-			if (is_array($ordered[$board]) && !empty($ordered[$board]['boards']))
1258
-				sortBoards($ordered[$board]['boards']);
1319
+			if (is_array($ordered[$board]) && !empty($ordered[$board]['boards'])) {
1320
+							sortBoards($ordered[$board]['boards']);
1321
+			}
1259 1322
 
1260
-			if (is_array($ordered[$board]) && !empty($ordered[$board]['children']))
1261
-				sortBoards($ordered[$board]['children']);
1323
+			if (is_array($ordered[$board]) && !empty($ordered[$board]['children'])) {
1324
+							sortBoards($ordered[$board]['children']);
1325
+			}
1262 1326
 		}
1263 1327
 
1264 1328
 	$boards = $ordered;
@@ -1274,12 +1338,14 @@  discard block
 block discarded – undo
1274 1338
 	$tree = getTreeOrder();
1275 1339
 
1276 1340
 	$ordered = array();
1277
-	foreach ($tree['cats'] as $cat)
1278
-		if (!empty($categories[$cat]))
1341
+	foreach ($tree['cats'] as $cat) {
1342
+			if (!empty($categories[$cat]))
1279 1343
 		{
1280 1344
 			$ordered[$cat] = $categories[$cat];
1281
-			if (!empty($ordered[$cat]['boards']))
1282
-				sortBoards($ordered[$cat]['boards']);
1345
+	}
1346
+			if (!empty($ordered[$cat]['boards'])) {
1347
+							sortBoards($ordered[$cat]['boards']);
1348
+			}
1283 1349
 		}
1284 1350
 
1285 1351
 	$categories = $ordered;
@@ -1295,8 +1361,9 @@  discard block
 block discarded – undo
1295 1361
 {
1296 1362
 	global $smcFunc, $scripturl, $txt;
1297 1363
 
1298
-	if (empty($boards))
1299
-		return array();
1364
+	if (empty($boards)) {
1365
+			return array();
1366
+	}
1300 1367
 
1301 1368
 	$request = $smcFunc['db_query']('', '
1302 1369
 		SELECT mem.id_member, mem.real_name, mo.id_board
@@ -1310,8 +1377,9 @@  discard block
 block discarded – undo
1310 1377
 	$moderators = array();
1311 1378
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1312 1379
 	{
1313
-		if (empty($moderators[$row['id_board']]))
1314
-			$moderators[$row['id_board']] = array();
1380
+		if (empty($moderators[$row['id_board']])) {
1381
+					$moderators[$row['id_board']] = array();
1382
+		}
1315 1383
 
1316 1384
 		$moderators[$row['id_board']][] = array(
1317 1385
 			'id' => $row['id_member'],
@@ -1335,8 +1403,9 @@  discard block
 block discarded – undo
1335 1403
 {
1336 1404
 	global $smcFunc, $scripturl, $txt;
1337 1405
 
1338
-	if (empty($boards))
1339
-		return array();
1406
+	if (empty($boards)) {
1407
+			return array();
1408
+	}
1340 1409
 
1341 1410
 	$request = $smcFunc['db_query']('', '
1342 1411
 		SELECT mg.id_group, mg.group_name, bg.id_board
@@ -1350,8 +1419,9 @@  discard block
 block discarded – undo
1350 1419
 	$groups = array();
1351 1420
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1352 1421
 	{
1353
-		if (empty($groups[$row['id_board']]))
1354
-			$groups[$row['id_board']] = array();
1422
+		if (empty($groups[$row['id_board']])) {
1423
+					$groups[$row['id_board']] = array();
1424
+		}
1355 1425
 
1356 1426
 		$groups[$row['id_board']][] = array(
1357 1427
 			'id' => $row['id_group'],
@@ -1426,8 +1496,9 @@  discard block
 block discarded – undo
1426 1496
 
1427 1497
 		if (!empty($row['id_board']))
1428 1498
 		{
1429
-			if ($row['child_level'] != $curLevel)
1430
-				$prevBoard = 0;
1499
+			if ($row['child_level'] != $curLevel) {
1500
+							$prevBoard = 0;
1501
+			}
1431 1502
 
1432 1503
 			$boards[$row['id_board']] = array(
1433 1504
 				'id' => $row['id_board'],
@@ -1459,16 +1530,16 @@  discard block
 block discarded – undo
1459 1530
 					'children' => array()
1460 1531
 				);
1461 1532
 				$boards[$row['id_board']]['tree'] = &$cat_tree[$row['id_cat']]['children'][$row['id_board']];
1462
-			}
1463
-			else
1533
+			} else
1464 1534
 			{
1465 1535
 				// Parent doesn't exist!
1466
-				if (!isset($boards[$row['id_parent']]['tree']))
1467
-					fatal_lang_error('no_valid_parent', false, array($row['board_name']));
1536
+				if (!isset($boards[$row['id_parent']]['tree'])) {
1537
+									fatal_lang_error('no_valid_parent', false, array($row['board_name']));
1538
+				}
1468 1539
 
1469 1540
 				// Wrong childlevel...we can silently fix this...
1470
-				if ($boards[$row['id_parent']]['tree']['node']['level'] != $row['child_level'] - 1)
1471
-					$smcFunc['db_query']('', '
1541
+				if ($boards[$row['id_parent']]['tree']['node']['level'] != $row['child_level'] - 1) {
1542
+									$smcFunc['db_query']('', '
1472 1543
 						UPDATE {db_prefix}boards
1473 1544
 						SET child_level = {int:new_child_level}
1474 1545
 						WHERE id_board = {int:selected_board}',
@@ -1477,6 +1548,7 @@  discard block
 block discarded – undo
1477 1548
 							'selected_board' => $row['id_board'],
1478 1549
 						)
1479 1550
 					);
1551
+				}
1480 1552
 
1481 1553
 				$boards[$row['id_parent']]['tree']['children'][$row['id_board']] = array(
1482 1554
 					'node' => &$boards[$row['id_board']],
@@ -1510,8 +1582,9 @@  discard block
 block discarded – undo
1510 1582
  */
1511 1583
 function recursiveBoards(&$_boardList, &$_tree)
1512 1584
 {
1513
-	if (empty($_tree['children']))
1514
-		return;
1585
+	if (empty($_tree['children'])) {
1586
+			return;
1587
+	}
1515 1588
 
1516 1589
 	foreach ($_tree['children'] as $id => $node)
1517 1590
 	{
@@ -1530,11 +1603,13 @@  discard block
 block discarded – undo
1530 1603
 {
1531 1604
 	global $boards;
1532 1605
 
1533
-	if (empty($boards[$child]['parent']))
1534
-		return false;
1606
+	if (empty($boards[$child]['parent'])) {
1607
+			return false;
1608
+	}
1535 1609
 
1536
-	if ($boards[$child]['parent'] == $parent)
1537
-		return true;
1610
+	if ($boards[$child]['parent'] == $parent) {
1611
+			return true;
1612
+	}
1538 1613
 
1539 1614
 	return isChildOf($boards[$child]['parent'], $parent);
1540 1615
 }
Please login to merge, or discard this patch.
Sources/PersonalMessage.php 1 patch
Braces   +633 added lines, -471 removed lines patch added patch discarded remove patch
@@ -15,8 +15,9 @@  discard block
 block discarded – undo
15 15
  * @version 2.1 Beta 4
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
  * This helps organize things...
@@ -37,13 +38,14 @@  discard block
 block discarded – undo
37 38
 
38 39
 	loadLanguage('PersonalMessage+Drafts');
39 40
 
40
-	if (!isset($_REQUEST['xml']))
41
-		loadTemplate('PersonalMessage');
41
+	if (!isset($_REQUEST['xml'])) {
42
+			loadTemplate('PersonalMessage');
43
+	}
42 44
 
43 45
 	// Load up the members maximum message capacity.
44
-	if ($user_info['is_admin'])
45
-		$context['message_limit'] = 0;
46
-	elseif (($context['message_limit'] = cache_get_data('msgLimit:' . $user_info['id'], 360)) === null)
46
+	if ($user_info['is_admin']) {
47
+			$context['message_limit'] = 0;
48
+	} elseif (($context['message_limit'] = cache_get_data('msgLimit:' . $user_info['id'], 360)) === null)
47 49
 	{
48 50
 		// @todo Why do we do this?  It seems like if they have any limit we should use it.
49 51
 		$request = $smcFunc['db_query']('', '
@@ -78,8 +80,9 @@  discard block
 block discarded – undo
78 80
 	}
79 81
 
80 82
 	// a previous message was sent successfully? show a small indication.
81
-	if (isset($_GET['done']) && ($_GET['done'] == 'sent'))
82
-		$context['pm_sent'] = true;
83
+	if (isset($_GET['done']) && ($_GET['done'] == 'sent')) {
84
+			$context['pm_sent'] = true;
85
+	}
83 86
 
84 87
 	$context['labels'] = array();
85 88
 
@@ -210,11 +213,11 @@  discard block
 block discarded – undo
210 213
 	{
211 214
 		$_REQUEST['sa'] = '';
212 215
 		MessageFolder();
213
-	}
214
-	else
216
+	} else
215 217
 	{
216
-		if (!isset($_REQUEST['xml']) && $_REQUEST['sa'] != 'popup')
217
-			messageIndexBar($_REQUEST['sa']);
218
+		if (!isset($_REQUEST['xml']) && $_REQUEST['sa'] != 'popup') {
219
+					messageIndexBar($_REQUEST['sa']);
220
+		}
218 221
 
219 222
 		call_helper($subActions[$_REQUEST['sa']]);
220 223
 	}
@@ -297,15 +300,16 @@  discard block
 block discarded – undo
297 300
 	);
298 301
 
299 302
 	// Handle labels.
300
-	if (empty($context['currently_using_labels']))
301
-		unset($pm_areas['labels']);
302
-	else
303
+	if (empty($context['currently_using_labels'])) {
304
+			unset($pm_areas['labels']);
305
+	} else
303 306
 	{
304 307
 		// Note we send labels by id as it will have less problems in the querystring.
305 308
 		foreach ($context['labels'] as $label)
306 309
 		{
307
-			if ($label['id'] == -1)
308
-				continue;
310
+			if ($label['id'] == -1) {
311
+							continue;
312
+			}
309 313
 
310 314
 			// Count the amount of unread items in labels.
311 315
 			$pm_areas['labels']['amt'] += $label['unread_messages'];
@@ -356,8 +360,9 @@  discard block
 block discarded – undo
356 360
 	unset($pm_areas);
357 361
 
358 362
 	// No menu means no access.
359
-	if (!$pm_include_data && (!$user_info['is_guest'] || validateSession()))
360
-		fatal_lang_error('no_access', false);
363
+	if (!$pm_include_data && (!$user_info['is_guest'] || validateSession())) {
364
+			fatal_lang_error('no_access', false);
365
+	}
361 366
 
362 367
 	// Make a note of the Unique ID for this menu.
363 368
 	$context['pm_menu_id'] = $context['max_menu_id'];
@@ -368,9 +373,10 @@  discard block
 block discarded – undo
368 373
 	$context['menu_item_selected'] = $current_area;
369 374
 
370 375
 	// Set the template for this area and add the profile layer.
371
-	if (!isset($_REQUEST['xml']))
372
-		$context['template_layers'][] = 'pm';
373
-}
376
+	if (!isset($_REQUEST['xml'])) {
377
+			$context['template_layers'][] = 'pm';
378
+	}
379
+	}
374 380
 
375 381
 /**
376 382
  * The popup for when we ask for the popup from the user.
@@ -402,8 +408,9 @@  discard block
 block discarded – undo
402 408
 		)
403 409
 	);
404 410
 	$pms = array();
405
-	while ($row = $smcFunc['db_fetch_row']($request))
406
-		$pms[] = $row[0];
411
+	while ($row = $smcFunc['db_fetch_row']($request)) {
412
+			$pms[] = $row[0];
413
+	}
407 414
 	$smcFunc['db_free_result']($request);
408 415
 
409 416
 	if (!empty($pms))
@@ -431,8 +438,9 @@  discard block
 block discarded – undo
431 438
 		);
432 439
 		while ($row = $smcFunc['db_fetch_assoc']($request))
433 440
 		{
434
-			if (!empty($row['id_member_from']))
435
-				$senders[] = $row['id_member_from'];
441
+			if (!empty($row['id_member_from'])) {
442
+							$senders[] = $row['id_member_from'];
443
+			}
436 444
 
437 445
 			$row['replied_to_you'] = $row['id_pm'] != $row['id_pm_head'];
438 446
 			$row['time'] = timeformat($row['timestamp']);
@@ -442,13 +450,15 @@  discard block
 block discarded – undo
442 450
 		$smcFunc['db_free_result']($request);
443 451
 
444 452
 		$senders = loadMemberData($senders);
445
-		foreach ($senders as $member)
446
-			loadMemberContext($member);
453
+		foreach ($senders as $member) {
454
+					loadMemberContext($member);
455
+		}
447 456
 
448 457
 		// Having loaded everyone, attach them to the PMs.
449
-		foreach ($context['unread_pms'] as $id_pm => $details)
450
-			if (!empty($memberContext[$details['id_member_from']]))
458
+		foreach ($context['unread_pms'] as $id_pm => $details) {
459
+					if (!empty($memberContext[$details['id_member_from']]))
451 460
 				$context['unread_pms'][$id_pm]['member'] = &$memberContext[$details['id_member_from']];
461
+		}
452 462
 	}
453 463
 }
454 464
 
@@ -468,12 +478,13 @@  discard block
 block discarded – undo
468 478
 	}
469 479
 
470 480
 	// Make sure the starting location is valid.
471
-	if (isset($_GET['start']) && $_GET['start'] != 'new')
472
-		$_GET['start'] = (int) $_GET['start'];
473
-	elseif (!isset($_GET['start']) && !empty($options['view_newest_pm_first']))
474
-		$_GET['start'] = 0;
475
-	else
476
-		$_GET['start'] = 'new';
481
+	if (isset($_GET['start']) && $_GET['start'] != 'new') {
482
+			$_GET['start'] = (int) $_GET['start'];
483
+	} elseif (!isset($_GET['start']) && !empty($options['view_newest_pm_first'])) {
484
+			$_GET['start'] = 0;
485
+	} else {
486
+			$_GET['start'] = 'new';
487
+	}
477 488
 
478 489
 	// Set up some basic theme stuff.
479 490
 	$context['from_or_to'] = $context['folder'] != 'sent' ? 'from' : 'to';
@@ -487,9 +498,10 @@  discard block
 block discarded – undo
487 498
 		list ($sig_limits, $sig_bbc) = explode(':', $modSettings['signature_settings']);
488 499
 		$sig_limits = explode(',', $sig_limits);
489 500
 
490
-		if (!empty($sig_limits[5]) || !empty($sig_limits[6]))
491
-			addInlineCss('
501
+		if (!empty($sig_limits[5]) || !empty($sig_limits[6])) {
502
+					addInlineCss('
492 503
 	.signature img { ' . (!empty($sig_limits[5]) ? 'max-width: ' . (int) $sig_limits[5] . 'px; ' : '') . (!empty($sig_limits[6]) ? 'max-height: ' . (int) $sig_limits[6] . 'px; ' : '') . '}');
504
+		}
493 505
 	}
494 506
 
495 507
 	$labelJoin = '';
@@ -501,8 +513,7 @@  discard block
 block discarded – undo
501 513
 	{
502 514
 		$labelQuery = '
503 515
 			AND pmr.in_inbox = 1';
504
-	}
505
-	elseif ($context['folder'] != 'sent')
516
+	} elseif ($context['folder'] != 'sent')
506 517
 	{
507 518
 		$labelJoin = '
508 519
 			INNER JOIN {db_prefix}pm_labeled_messages AS pl ON (pl.id_pm = pmr.id_pm)';
@@ -544,22 +555,24 @@  discard block
 block discarded – undo
544 555
 	$txt['delete_all'] = str_replace('PMBOX', $pmbox, $txt['delete_all']);
545 556
 
546 557
 	// Now, build the link tree!
547
-	if ($context['current_label_id'] == -1)
548
-		$context['linktree'][] = array(
558
+	if ($context['current_label_id'] == -1) {
559
+			$context['linktree'][] = array(
549 560
 			'url' => $scripturl . '?action=pm;f=' . $context['folder'],
550 561
 			'name' => $pmbox
551 562
 		);
563
+	}
552 564
 
553 565
 	// Build it further for a label.
554
-	if ($context['current_label_id'] != -1)
555
-		$context['linktree'][] = array(
566
+	if ($context['current_label_id'] != -1) {
567
+			$context['linktree'][] = array(
556 568
 			'url' => $scripturl . '?action=pm;f=' . $context['folder'] . ';l=' . $context['current_label_id'],
557 569
 			'name' => $txt['pm_current_label'] . ': ' . $context['current_label']
558 570
 		);
571
+	}
559 572
 
560 573
 	// Figure out how many messages there are.
561
-	if ($context['folder'] == 'sent')
562
-		$request = $smcFunc['db_query']('', '
574
+	if ($context['folder'] == 'sent') {
575
+			$request = $smcFunc['db_query']('', '
563 576
 			SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ')
564 577
 			FROM {db_prefix}personal_messages AS pm
565 578
 			WHERE pm.id_member_from = {int:current_member}
@@ -569,8 +582,8 @@  discard block
 block discarded – undo
569 582
 				'not_deleted' => 0,
570 583
 			)
571 584
 		);
572
-	else
573
-		$request = $smcFunc['db_query']('', '
585
+	} else {
586
+			$request = $smcFunc['db_query']('', '
574 587
 			SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ')
575 588
 			FROM {db_prefix}pm_recipients AS pmr' . ($context['display_mode'] == 2 ? '
576 589
 				INNER JOIN {db_prefix}personal_messages AS pm ON (pm.id_pm = pmr.id_pm)' : '') . $labelJoin . '
@@ -581,6 +594,7 @@  discard block
 block discarded – undo
581 594
 				'not_deleted' => 0,
582 595
 			)
583 596
 		);
597
+	}
584 598
 	list ($max_messages) = $smcFunc['db_fetch_row']($request);
585 599
 	$smcFunc['db_free_result']($request);
586 600
 
@@ -589,10 +603,11 @@  discard block
 block discarded – undo
589 603
 	$maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages'];
590 604
 
591 605
 	// Start on the last page.
592
-	if (!is_numeric($_GET['start']) || $_GET['start'] >= $max_messages)
593
-		$_GET['start'] = ($max_messages - 1) - (($max_messages - 1) % $maxPerPage);
594
-	elseif ($_GET['start'] < 0)
595
-		$_GET['start'] = 0;
606
+	if (!is_numeric($_GET['start']) || $_GET['start'] >= $max_messages) {
607
+			$_GET['start'] = ($max_messages - 1) - (($max_messages - 1) % $maxPerPage);
608
+	} elseif ($_GET['start'] < 0) {
609
+			$_GET['start'] = 0;
610
+	}
596 611
 
597 612
 	// ... but wait - what if we want to start from a specific message?
598 613
 	if (isset($_GET['pmid']))
@@ -600,19 +615,21 @@  discard block
 block discarded – undo
600 615
 		$pmID = (int) $_GET['pmid'];
601 616
 
602 617
 		// Make sure you have access to this PM.
603
-		if (!isAccessiblePM($pmID, $context['folder'] == 'sent' ? 'outbox' : 'inbox'))
604
-			fatal_lang_error('no_access', false);
618
+		if (!isAccessiblePM($pmID, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) {
619
+					fatal_lang_error('no_access', false);
620
+		}
605 621
 
606 622
 		$context['current_pm'] = $pmID;
607 623
 
608 624
 		// With only one page of PM's we're gonna want page 1.
609
-		if ($max_messages <= $maxPerPage)
610
-			$_GET['start'] = 0;
625
+		if ($max_messages <= $maxPerPage) {
626
+					$_GET['start'] = 0;
627
+		}
611 628
 		// If we pass kstart we assume we're in the right place.
612 629
 		elseif (!isset($_GET['kstart']))
613 630
 		{
614
-			if ($context['folder'] == 'sent')
615
-				$request = $smcFunc['db_query']('', '
631
+			if ($context['folder'] == 'sent') {
632
+							$request = $smcFunc['db_query']('', '
616 633
 					SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ')
617 634
 					FROM {db_prefix}personal_messages
618 635
 					WHERE id_member_from = {int:current_member}
@@ -624,8 +641,8 @@  discard block
 block discarded – undo
624 641
 						'id_pm' => $pmID,
625 642
 					)
626 643
 				);
627
-			else
628
-				$request = $smcFunc['db_query']('', '
644
+			} else {
645
+							$request = $smcFunc['db_query']('', '
629 646
 					SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ')
630 647
 					FROM {db_prefix}pm_recipients AS pmr' . ($context['display_mode'] == 2 ? '
631 648
 						INNER JOIN {db_prefix}personal_messages AS pm ON (pm.id_pm = pmr.id_pm)' : '') . $labelJoin . '
@@ -638,6 +655,7 @@  discard block
 block discarded – undo
638 655
 						'id_pm' => $pmID,
639 656
 					)
640 657
 				);
658
+			}
641 659
 
642 660
 			list ($_GET['start']) = $smcFunc['db_fetch_row']($request);
643 661
 			$smcFunc['db_free_result']($request);
@@ -652,8 +670,9 @@  discard block
 block discarded – undo
652 670
 	{
653 671
 		$pmsg = (int) $_GET['pmsg'];
654 672
 
655
-		if (!isAccessiblePM($pmsg, $context['folder'] == 'sent' ? 'outbox' : 'inbox'))
656
-			fatal_lang_error('no_access', false);
673
+		if (!isAccessiblePM($pmsg, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) {
674
+					fatal_lang_error('no_access', false);
675
+		}
657 676
 	}
658 677
 
659 678
 	// Set up the page index.
@@ -747,8 +766,9 @@  discard block
 block discarded – undo
747 766
 	{
748 767
 		if (!isset($recipients[$row['id_pm']]))
749 768
 		{
750
-			if (isset($row['id_member_from']))
751
-				$posters[$row['id_pm']] = $row['id_member_from'];
769
+			if (isset($row['id_member_from'])) {
770
+							$posters[$row['id_pm']] = $row['id_member_from'];
771
+			}
752 772
 			$pms[$row['id_pm']] = $row['id_pm'];
753 773
 			$recipients[$row['id_pm']] = array(
754 774
 				'to' => array(),
@@ -757,29 +777,33 @@  discard block
 block discarded – undo
757 777
 		}
758 778
 
759 779
 		// Keep track of the last message so we know what the head is without another query!
760
-		if ((empty($pmID) && (empty($options['view_newest_pm_first']) || !isset($lastData))) || empty($lastData) || (!empty($pmID) && $pmID == $row['id_pm']))
761
-			$lastData = array(
780
+		if ((empty($pmID) && (empty($options['view_newest_pm_first']) || !isset($lastData))) || empty($lastData) || (!empty($pmID) && $pmID == $row['id_pm'])) {
781
+					$lastData = array(
762 782
 				'id' => $row['id_pm'],
763 783
 				'head' => $row['id_pm_head'],
764 784
 			);
785
+		}
765 786
 	}
766 787
 	$smcFunc['db_free_result']($request);
767 788
 
768 789
 	// Make sure that we have been given a correct head pm id!
769
-	if ($context['display_mode'] == 2 && !empty($pmID) && $pmID != $lastData['id'])
770
-		fatal_lang_error('no_access', false);
790
+	if ($context['display_mode'] == 2 && !empty($pmID) && $pmID != $lastData['id']) {
791
+			fatal_lang_error('no_access', false);
792
+	}
771 793
 
772 794
 	if (!empty($pms))
773 795
 	{
774 796
 		// Select the correct current message.
775
-		if (empty($pmID))
776
-			$context['current_pm'] = $lastData['id'];
797
+		if (empty($pmID)) {
798
+					$context['current_pm'] = $lastData['id'];
799
+		}
777 800
 
778 801
 		// This is a list of the pm's that are used for "full" display.
779
-		if ($context['display_mode'] == 0)
780
-			$display_pms = $pms;
781
-		else
782
-			$display_pms = array($context['current_pm']);
802
+		if ($context['display_mode'] == 0) {
803
+					$display_pms = $pms;
804
+		} else {
805
+					$display_pms = array($context['current_pm']);
806
+		}
783 807
 
784 808
 		// At this point we know the main id_pm's. But - if we are looking at conversations we need the others!
785 809
 		if ($context['display_mode'] == 2)
@@ -801,16 +825,18 @@  discard block
 block discarded – undo
801 825
 			while ($row = $smcFunc['db_fetch_assoc']($request))
802 826
 			{
803 827
 				// This is, frankly, a joke. We will put in a workaround for people sending to themselves - yawn!
804
-				if ($context['folder'] == 'sent' && $row['id_member_from'] == $user_info['id'] && $row['deleted_by_sender'] == 1)
805
-					continue;
806
-				elseif ($row['id_member'] == $user_info['id'] & $row['deleted'] == 1)
807
-					continue;
828
+				if ($context['folder'] == 'sent' && $row['id_member_from'] == $user_info['id'] && $row['deleted_by_sender'] == 1) {
829
+									continue;
830
+				} elseif ($row['id_member'] == $user_info['id'] & $row['deleted'] == 1) {
831
+									continue;
832
+				}
808 833
 
809
-				if (!isset($recipients[$row['id_pm']]))
810
-					$recipients[$row['id_pm']] = array(
834
+				if (!isset($recipients[$row['id_pm']])) {
835
+									$recipients[$row['id_pm']] = array(
811 836
 						'to' => array(),
812 837
 						'bcc' => array()
813 838
 					);
839
+				}
814 840
 				$display_pms[] = $row['id_pm'];
815 841
 				$posters[$row['id_pm']] = $row['id_member_from'];
816 842
 			}
@@ -861,8 +887,9 @@  discard block
 block discarded – undo
861 887
 				while ($row2 = $smcFunc['db_fetch_assoc']($request2))
862 888
 				{
863 889
 					$l_id = $row2['id_label'];
864
-					if (isset($context['labels'][$l_id]))
865
-						$context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']);
890
+					if (isset($context['labels'][$l_id])) {
891
+											$context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']);
892
+					}
866 893
 				}
867 894
 
868 895
 				$smcFunc['db_free_result']($request2);
@@ -879,9 +906,10 @@  discard block
 block discarded – undo
879 906
 		// Make sure we don't load unnecessary data.
880 907
 		if ($context['display_mode'] == 1)
881 908
 		{
882
-			foreach ($posters as $k => $v)
883
-				if (!in_array($k, $display_pms))
909
+			foreach ($posters as $k => $v) {
910
+							if (!in_array($k, $display_pms))
884 911
 					unset($posters[$k]);
912
+			}
885 913
 		}
886 914
 
887 915
 		// Load any users....
@@ -892,8 +920,9 @@  discard block
 block discarded – undo
892 920
 		{
893 921
 			// Get the order right.
894 922
 			$orderBy = array();
895
-			foreach (array_reverse($pms) as $pm)
896
-				$orderBy[] = 'pm.id_pm = ' . $pm;
923
+			foreach (array_reverse($pms) as $pm) {
924
+							$orderBy[] = 'pm.id_pm = ' . $pm;
925
+			}
897 926
 
898 927
 			// Seperate query for these bits!
899 928
 			$subjects_request = $smcFunc['db_query']('', '
@@ -939,9 +968,9 @@  discard block
 block discarded – undo
939 968
 			// Allow mods to add additional buttons here
940 969
 			call_integration_hook('integrate_conversation_buttons');
941 970
 		}
971
+	} else {
972
+			$messages_request = false;
942 973
 	}
943
-	else
944
-		$messages_request = false;
945 974
 
946 975
 	$context['can_send_pm'] = allowedTo('pm_send');
947 976
 	$context['can_send_email'] = allowedTo('moderate_forum');
@@ -952,11 +981,13 @@  discard block
 block discarded – undo
952 981
 	if ($context['folder'] != 'sent' && !empty($context['labels'][(int) $context['current_label_id']]['unread_messages']))
953 982
 	{
954 983
 		// If the display mode is "old sk00l" do them all...
955
-		if ($context['display_mode'] == 0)
956
-			markMessages(null, $context['current_label_id']);
984
+		if ($context['display_mode'] == 0) {
985
+					markMessages(null, $context['current_label_id']);
986
+		}
957 987
 		// Otherwise do just the current one!
958
-		elseif (!empty($context['current_pm']))
959
-			markMessages($display_pms, $context['current_label_id']);
988
+		elseif (!empty($context['current_pm'])) {
989
+					markMessages($display_pms, $context['current_label_id']);
990
+		}
960 991
 	}
961 992
 }
962 993
 
@@ -974,8 +1005,9 @@  discard block
 block discarded – undo
974 1005
 
975 1006
 	// Count the current message number....
976 1007
 	static $counter = null;
977
-	if ($counter === null || $reset)
978
-		$counter = $context['start'];
1008
+	if ($counter === null || $reset) {
1009
+			$counter = $context['start'];
1010
+	}
979 1011
 
980 1012
 	static $temp_pm_selected = null;
981 1013
 	if ($temp_pm_selected === null)
@@ -1020,19 +1052,22 @@  discard block
 block discarded – undo
1020 1052
 	}
1021 1053
 
1022 1054
 	// Bail if it's false, ie. no messages.
1023
-	if ($messages_request == false)
1024
-		return false;
1055
+	if ($messages_request == false) {
1056
+			return false;
1057
+	}
1025 1058
 
1026 1059
 	// Reset the data?
1027
-	if ($reset == true)
1028
-		return @$smcFunc['db_data_seek']($messages_request, 0);
1060
+	if ($reset == true) {
1061
+			return @$smcFunc['db_data_seek']($messages_request, 0);
1062
+	}
1029 1063
 
1030 1064
 	// Get the next one... bail if anything goes wrong.
1031 1065
 	$message = $smcFunc['db_fetch_assoc']($messages_request);
1032 1066
 	if (!$message)
1033 1067
 	{
1034
-		if ($type != 'subject')
1035
-			$smcFunc['db_free_result']($messages_request);
1068
+		if ($type != 'subject') {
1069
+					$smcFunc['db_free_result']($messages_request);
1070
+		}
1036 1071
 
1037 1072
 		return false;
1038 1073
 	}
@@ -1052,8 +1087,7 @@  discard block
 block discarded – undo
1052 1087
 		$memberContext[$message['id_member_from']]['email'] = '';
1053 1088
 		$memberContext[$message['id_member_from']]['show_email'] = false;
1054 1089
 		$memberContext[$message['id_member_from']]['is_guest'] = true;
1055
-	}
1056
-	else
1090
+	} else
1057 1091
 	{
1058 1092
 		$memberContext[$message['id_member_from']]['can_view_profile'] = allowedTo('profile_view') || ($message['id_member_from'] == $user_info['id'] && !$user_info['is_guest']);
1059 1093
 		$memberContext[$message['id_member_from']]['can_see_warning'] = !isset($context['disabled_fields']['warning_status']) && $memberContext[$message['id_member_from']]['warning_status'] && ($context['user']['can_mod'] || (!empty($modSettings['warning_show']) && ($modSettings['warning_show'] > 1 || $message['id_member_from'] == $user_info['id'])));
@@ -1094,9 +1128,10 @@  discard block
 block discarded – undo
1094 1128
 	$counter++;
1095 1129
 
1096 1130
 	// Any custom profile fields?
1097
-	if (!empty($memberContext[$message['id_member_from']]['custom_fields']))
1098
-		foreach ($memberContext[$message['id_member_from']]['custom_fields'] as $custom)
1131
+	if (!empty($memberContext[$message['id_member_from']]['custom_fields'])) {
1132
+			foreach ($memberContext[$message['id_member_from']]['custom_fields'] as $custom)
1099 1133
 			$output['custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom;
1134
+	}
1100 1135
 
1101 1136
 	call_integration_hook('integrate_prepare_pm_context', array(&$output, &$message, $counter));
1102 1137
 
@@ -1120,22 +1155,28 @@  discard block
 block discarded – undo
1120 1155
 			$context['search_params'][$k] = $v;
1121 1156
 		}
1122 1157
 	}
1123
-	if (isset($_REQUEST['search']))
1124
-		$context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']);
1158
+	if (isset($_REQUEST['search'])) {
1159
+			$context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']);
1160
+	}
1125 1161
 
1126
-	if (isset($context['search_params']['search']))
1127
-		$context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']);
1128
-	if (isset($context['search_params']['userspec']))
1129
-		$context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']);
1162
+	if (isset($context['search_params']['search'])) {
1163
+			$context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']);
1164
+	}
1165
+	if (isset($context['search_params']['userspec'])) {
1166
+			$context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']);
1167
+	}
1130 1168
 
1131
-	if (!empty($context['search_params']['searchtype']))
1132
-		$context['search_params']['searchtype'] = 2;
1169
+	if (!empty($context['search_params']['searchtype'])) {
1170
+			$context['search_params']['searchtype'] = 2;
1171
+	}
1133 1172
 
1134
-	if (!empty($context['search_params']['minage']))
1135
-		$context['search_params']['minage'] = (int) $context['search_params']['minage'];
1173
+	if (!empty($context['search_params']['minage'])) {
1174
+			$context['search_params']['minage'] = (int) $context['search_params']['minage'];
1175
+	}
1136 1176
 
1137
-	if (!empty($context['search_params']['maxage']))
1138
-		$context['search_params']['maxage'] = (int) $context['search_params']['maxage'];
1177
+	if (!empty($context['search_params']['maxage'])) {
1178
+			$context['search_params']['maxage'] = (int) $context['search_params']['maxage'];
1179
+	}
1139 1180
 
1140 1181
 	$context['search_params']['subject_only'] = !empty($context['search_params']['subject_only']);
1141 1182
 	$context['search_params']['show_complete'] = !empty($context['search_params']['show_complete']);
@@ -1162,8 +1203,9 @@  discard block
 block discarded – undo
1162 1203
 		$context['search_errors']['messages'] = array();
1163 1204
 		foreach ($context['search_errors'] as $search_error => $dummy)
1164 1205
 		{
1165
-			if ($search_error == 'messages')
1166
-				continue;
1206
+			if ($search_error == 'messages') {
1207
+							continue;
1208
+			}
1167 1209
 
1168 1210
 			$context['search_errors']['messages'][] = $txt['error_' . $search_error];
1169 1211
 		}
@@ -1185,8 +1227,9 @@  discard block
 block discarded – undo
1185 1227
 	global $scripturl, $modSettings, $user_info, $context, $txt;
1186 1228
 	global $memberContext, $smcFunc;
1187 1229
 
1188
-	if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search'])
1189
-		fatal_lang_error('loadavg_search_disabled', false);
1230
+	if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) {
1231
+			fatal_lang_error('loadavg_search_disabled', false);
1232
+	}
1190 1233
 
1191 1234
 	/**
1192 1235
 	 * @todo For the moment force the folder to the inbox.
@@ -1215,35 +1258,40 @@  discard block
 block discarded – undo
1215 1258
 	$context['start'] = isset($_GET['start']) ? (int) $_GET['start'] : 0;
1216 1259
 
1217 1260
 	// Store whether simple search was used (needed if the user wants to do another query).
1218
-	if (!isset($search_params['advanced']))
1219
-		$search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1;
1261
+	if (!isset($search_params['advanced'])) {
1262
+			$search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1;
1263
+	}
1220 1264
 
1221 1265
 	// 1 => 'allwords' (default, don't set as param) / 2 => 'anywords'.
1222
-	if (!empty($search_params['searchtype']) || (!empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2))
1223
-		$search_params['searchtype'] = 2;
1266
+	if (!empty($search_params['searchtype']) || (!empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2)) {
1267
+			$search_params['searchtype'] = 2;
1268
+	}
1224 1269
 
1225 1270
 	// Minimum age of messages. Default to zero (don't set param in that case).
1226
-	if (!empty($search_params['minage']) || (!empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0))
1227
-		$search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage'];
1271
+	if (!empty($search_params['minage']) || (!empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0)) {
1272
+			$search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage'];
1273
+	}
1228 1274
 
1229 1275
 	// Maximum age of messages. Default to infinite (9999 days: param not set).
1230
-	if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] != 9999))
1231
-		$search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage'];
1276
+	if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] != 9999)) {
1277
+			$search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage'];
1278
+	}
1232 1279
 
1233 1280
 	$search_params['subject_only'] = !empty($search_params['subject_only']) || !empty($_REQUEST['subject_only']);
1234 1281
 	$search_params['show_complete'] = !empty($search_params['show_complete']) || !empty($_REQUEST['show_complete']);
1235 1282
 
1236 1283
 	// Default the user name to a wildcard matching every user (*).
1237
-	if (!empty($search_params['user_spec']) || (!empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*'))
1238
-		$search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec'];
1284
+	if (!empty($search_params['user_spec']) || (!empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*')) {
1285
+			$search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec'];
1286
+	}
1239 1287
 
1240 1288
 	// This will be full of all kinds of parameters!
1241 1289
 	$searchq_parameters = array();
1242 1290
 
1243 1291
 	// If there's no specific user, then don't mention it in the main query.
1244
-	if (empty($search_params['userspec']))
1245
-		$userQuery = '';
1246
-	else
1292
+	if (empty($search_params['userspec'])) {
1293
+			$userQuery = '';
1294
+	} else
1247 1295
 	{
1248 1296
 		$userString = strtr($smcFunc['htmlspecialchars']($search_params['userspec'], ENT_QUOTES), array('&quot;' => '"'));
1249 1297
 		$userString = strtr($userString, array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_'));
@@ -1255,8 +1303,9 @@  discard block
 block discarded – undo
1255 1303
 		{
1256 1304
 			$possible_users[$k] = trim($possible_users[$k]);
1257 1305
 
1258
-			if (strlen($possible_users[$k]) == 0)
1259
-				unset($possible_users[$k]);
1306
+			if (strlen($possible_users[$k]) == 0) {
1307
+							unset($possible_users[$k]);
1308
+			}
1260 1309
 		}
1261 1310
 
1262 1311
 		if (!empty($possible_users))
@@ -1268,8 +1317,9 @@  discard block
 block discarded – undo
1268 1317
 			{
1269 1318
 				$where_params['name_' . $k] = $v;
1270 1319
 				$where_clause[] = '{raw:real_name} LIKE {string:name_' . $k . '}';
1271
-				if (!isset($where_params['real_name']))
1272
-					$where_params['real_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(real_name)' : 'real_name';
1320
+				if (!isset($where_params['real_name'])) {
1321
+									$where_params['real_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(real_name)' : 'real_name';
1322
+				}
1273 1323
 			}
1274 1324
 
1275 1325
 			// Who matches those criteria?
@@ -1282,28 +1332,28 @@  discard block
 block discarded – undo
1282 1332
 			);
1283 1333
 
1284 1334
 			// Simply do nothing if there're too many members matching the criteria.
1285
-			if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch)
1286
-				$userQuery = '';
1287
-			elseif ($smcFunc['db_num_rows']($request) == 0)
1335
+			if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch) {
1336
+							$userQuery = '';
1337
+			} elseif ($smcFunc['db_num_rows']($request) == 0)
1288 1338
 			{
1289 1339
 				$userQuery = 'AND pm.id_member_from = 0 AND ({raw:pm_from_name} LIKE {raw:guest_user_name_implode})';
1290 1340
 				$searchq_parameters['guest_user_name_implode'] = '\'' . implode('\' OR ' . ($smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name') . ' LIKE \'', $possible_users) . '\'';
1291 1341
 				$searchq_parameters['pm_from_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name';
1292
-			}
1293
-			else
1342
+			} else
1294 1343
 			{
1295 1344
 				$memberlist = array();
1296
-				while ($row = $smcFunc['db_fetch_assoc']($request))
1297
-					$memberlist[] = $row['id_member'];
1345
+				while ($row = $smcFunc['db_fetch_assoc']($request)) {
1346
+									$memberlist[] = $row['id_member'];
1347
+				}
1298 1348
 				$userQuery = 'AND (pm.id_member_from IN ({array_int:member_list}) OR (pm.id_member_from = 0 AND ({raw:pm_from_name} LIKE {raw:guest_user_name_implode})))';
1299 1349
 				$searchq_parameters['guest_user_name_implode'] = '\'' . implode('\' OR ' . ($smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name') . ' LIKE \'', $possible_users) . '\'';
1300 1350
 				$searchq_parameters['member_list'] = $memberlist;
1301 1351
 				$searchq_parameters['pm_from_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name';
1302 1352
 			}
1303 1353
 			$smcFunc['db_free_result']($request);
1354
+		} else {
1355
+					$userQuery = '';
1304 1356
 		}
1305
-		else
1306
-			$userQuery = '';
1307 1357
 	}
1308 1358
 
1309 1359
 	// Setup the sorting variables...
@@ -1311,8 +1361,9 @@  discard block
 block discarded – undo
1311 1361
 	$sort_columns = array(
1312 1362
 		'pm.id_pm',
1313 1363
 	);
1314
-	if (empty($search_params['sort']) && !empty($_REQUEST['sort']))
1315
-		list ($search_params['sort'], $search_params['sort_dir']) = array_pad(explode('|', $_REQUEST['sort']), 2, '');
1364
+	if (empty($search_params['sort']) && !empty($_REQUEST['sort'])) {
1365
+			list ($search_params['sort'], $search_params['sort_dir']) = array_pad(explode('|', $_REQUEST['sort']), 2, '');
1366
+	}
1316 1367
 	$search_params['sort'] = !empty($search_params['sort']) && in_array($search_params['sort'], $sort_columns) ? $search_params['sort'] : 'pm.id_pm';
1317 1368
 	$search_params['sort_dir'] = !empty($search_params['sort_dir']) && $search_params['sort_dir'] == 'asc' ? 'asc' : 'desc';
1318 1369
 
@@ -1322,24 +1373,27 @@  discard block
 block discarded – undo
1322 1373
 	if ($context['folder'] == 'inbox' && !empty($search_params['advanced']) && $context['currently_using_labels'])
1323 1374
 	{
1324 1375
 		// Came here from pagination?  Put them back into $_REQUEST for sanitization.
1325
-		if (isset($search_params['labels']))
1326
-			$_REQUEST['searchlabel'] = explode(',', $search_params['labels']);
1376
+		if (isset($search_params['labels'])) {
1377
+					$_REQUEST['searchlabel'] = explode(',', $search_params['labels']);
1378
+		}
1327 1379
 
1328 1380
 		// Assuming we have some labels - make them all integers.
1329 1381
 		if (!empty($_REQUEST['searchlabel']) && is_array($_REQUEST['searchlabel']))
1330 1382
 		{
1331
-			foreach ($_REQUEST['searchlabel'] as $key => $id)
1332
-				$_REQUEST['searchlabel'][$key] = (int) $id;
1383
+			foreach ($_REQUEST['searchlabel'] as $key => $id) {
1384
+							$_REQUEST['searchlabel'][$key] = (int) $id;
1385
+			}
1386
+		} else {
1387
+					$_REQUEST['searchlabel'] = array();
1333 1388
 		}
1334
-		else
1335
-			$_REQUEST['searchlabel'] = array();
1336 1389
 
1337 1390
 		// Now that everything is cleaned up a bit, make the labels a param.
1338 1391
 		$search_params['labels'] = implode(',', $_REQUEST['searchlabel']);
1339 1392
 
1340 1393
 		// No labels selected? That must be an error!
1341
-		if (empty($_REQUEST['searchlabel']))
1342
-			$context['search_errors']['no_labels_selected'] = true;
1394
+		if (empty($_REQUEST['searchlabel'])) {
1395
+					$context['search_errors']['no_labels_selected'] = true;
1396
+		}
1343 1397
 		// Otherwise prepare the query!
1344 1398
 		elseif (count($_REQUEST['searchlabel']) != count($context['labels']))
1345 1399
 		{
@@ -1362,8 +1416,7 @@  discard block
 block discarded – undo
1362 1416
 					// Not searching the inbox - PM must be labeled
1363 1417
 					$labelQuery = ' AND pml.id_label IN ({array_int:labels})';
1364 1418
 					$labelJoin = ' INNER JOIN {db_prefix}pm_labeled_messages AS pml ON (pml.id_pm = pmr.id_pm)';
1365
-				}
1366
-				else
1419
+				} else
1367 1420
 				{
1368 1421
 					// Searching the inbox - PM doesn't have to be labeled
1369 1422
 					$labelQuery = ' AND (' . substr($labelQuery, 5) . ' OR pml.id_label IN ({array_int:labels}))';
@@ -1378,8 +1431,9 @@  discard block
 block discarded – undo
1378 1431
 	// What are we actually searching for?
1379 1432
 	$search_params['search'] = !empty($search_params['search']) ? $search_params['search'] : (isset($_REQUEST['search']) ? $_REQUEST['search'] : '');
1380 1433
 	// If we ain't got nothing - we should error!
1381
-	if (!isset($search_params['search']) || $search_params['search'] == '')
1382
-		$context['search_errors']['invalid_search_string'] = true;
1434
+	if (!isset($search_params['search']) || $search_params['search'] == '') {
1435
+			$context['search_errors']['invalid_search_string'] = true;
1436
+	}
1383 1437
 
1384 1438
 	// Extract phrase parts first (e.g. some words "this is a phrase" some more words.)
1385 1439
 	preg_match_all('~(?:^|\s)([-]?)"([^"]+)"(?:$|\s)~' . ($context['utf8'] ? 'u' : ''), $search_params['search'], $matches, PREG_PATTERN_ORDER);
@@ -1392,12 +1446,14 @@  discard block
 block discarded – undo
1392 1446
 	$excludedWords = array();
1393 1447
 
1394 1448
 	// .. first, we check for things like -"some words", but not "-some words".
1395
-	foreach ($matches[1] as $index => $word)
1396
-		if ($word == '-')
1449
+	foreach ($matches[1] as $index => $word) {
1450
+			if ($word == '-')
1397 1451
 		{
1398 1452
 			$word = $smcFunc['strtolower'](trim($searchArray[$index]));
1399
-			if (strlen($word) > 0)
1400
-				$excludedWords[] = $word;
1453
+	}
1454
+			if (strlen($word) > 0) {
1455
+							$excludedWords[] = $word;
1456
+			}
1401 1457
 			unset($searchArray[$index]);
1402 1458
 		}
1403 1459
 
@@ -1407,8 +1463,9 @@  discard block
 block discarded – undo
1407 1463
 		if (strpos(trim($word), '-') === 0)
1408 1464
 		{
1409 1465
 			$word = substr($smcFunc['strtolower']($word), 1);
1410
-			if (strlen($word) > 0)
1411
-				$excludedWords[] = $word;
1466
+			if (strlen($word) > 0) {
1467
+							$excludedWords[] = $word;
1468
+			}
1412 1469
 			unset($tempSearch[$index]);
1413 1470
 		}
1414 1471
 	}
@@ -1419,9 +1476,9 @@  discard block
 block discarded – undo
1419 1476
 	foreach ($searchArray as $index => $value)
1420 1477
 	{
1421 1478
 		$searchArray[$index] = $smcFunc['strtolower'](trim($value));
1422
-		if ($searchArray[$index] == '')
1423
-			unset($searchArray[$index]);
1424
-		else
1479
+		if ($searchArray[$index] == '') {
1480
+					unset($searchArray[$index]);
1481
+		} else
1425 1482
 		{
1426 1483
 			// Sort out entities first.
1427 1484
 			$searchArray[$index] = $smcFunc['htmlspecialchars']($searchArray[$index]);
@@ -1431,27 +1488,32 @@  discard block
 block discarded – undo
1431 1488
 
1432 1489
 	// Create an array of replacements for highlighting.
1433 1490
 	$context['mark'] = array();
1434
-	foreach ($searchArray as $word)
1435
-		$context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>';
1491
+	foreach ($searchArray as $word) {
1492
+			$context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>';
1493
+	}
1436 1494
 
1437 1495
 	// This contains *everything*
1438 1496
 	$searchWords = array_merge($searchArray, $excludedWords);
1439 1497
 
1440 1498
 	// Make sure at least one word is being searched for.
1441
-	if (empty($searchArray))
1442
-		$context['search_errors']['invalid_search_string'] = true;
1499
+	if (empty($searchArray)) {
1500
+			$context['search_errors']['invalid_search_string'] = true;
1501
+	}
1443 1502
 
1444 1503
 	// Sort out the search query so the user can edit it - if they want.
1445 1504
 	$context['search_params'] = $search_params;
1446
-	if (isset($context['search_params']['search']))
1447
-		$context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']);
1448
-	if (isset($context['search_params']['userspec']))
1449
-		$context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']);
1505
+	if (isset($context['search_params']['search'])) {
1506
+			$context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']);
1507
+	}
1508
+	if (isset($context['search_params']['userspec'])) {
1509
+			$context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']);
1510
+	}
1450 1511
 
1451 1512
 	// Now we have all the parameters, combine them together for pagination and the like...
1452 1513
 	$context['params'] = array();
1453
-	foreach ($search_params as $k => $v)
1454
-		$context['params'][] = $k . '|\'|' . $v;
1514
+	foreach ($search_params as $k => $v) {
1515
+			$context['params'][] = $k . '|\'|' . $v;
1516
+	}
1455 1517
 	$context['params'] = base64_encode(implode('|"|', $context['params']));
1456 1518
 
1457 1519
 	// Compile the subject query part.
@@ -1459,26 +1521,31 @@  discard block
 block discarded – undo
1459 1521
 
1460 1522
 	foreach ($searchWords as $index => $word)
1461 1523
 	{
1462
-		if ($word == '')
1463
-			continue;
1524
+		if ($word == '') {
1525
+					continue;
1526
+		}
1464 1527
 
1465
-		if ($search_params['subject_only'])
1466
-			$andQueryParts[] = 'pm.subject' . (in_array($word, $excludedWords) ? ' NOT' : '') . ' LIKE {string:search_' . $index . '}';
1467
-		else
1468
-			$andQueryParts[] = '(pm.subject' . (in_array($word, $excludedWords) ? ' NOT' : '') . ' LIKE {string:search_' . $index . '} ' . (in_array($word, $excludedWords) ? 'AND pm.body NOT' : 'OR pm.body') . ' LIKE {string:search_' . $index . '})';
1528
+		if ($search_params['subject_only']) {
1529
+					$andQueryParts[] = 'pm.subject' . (in_array($word, $excludedWords) ? ' NOT' : '') . ' LIKE {string:search_' . $index . '}';
1530
+		} else {
1531
+					$andQueryParts[] = '(pm.subject' . (in_array($word, $excludedWords) ? ' NOT' : '') . ' LIKE {string:search_' . $index . '} ' . (in_array($word, $excludedWords) ? 'AND pm.body NOT' : 'OR pm.body') . ' LIKE {string:search_' . $index . '})';
1532
+		}
1469 1533
 		$searchq_parameters['search_' . $index] = '%' . strtr($word, array('_' => '\\_', '%' => '\\%')) . '%';
1470 1534
 	}
1471 1535
 
1472 1536
 	$searchQuery = ' 1=1';
1473
-	if (!empty($andQueryParts))
1474
-		$searchQuery = implode(!empty($search_params['searchtype']) && $search_params['searchtype'] == 2 ? ' OR ' : ' AND ', $andQueryParts);
1537
+	if (!empty($andQueryParts)) {
1538
+			$searchQuery = implode(!empty($search_params['searchtype']) && $search_params['searchtype'] == 2 ? ' OR ' : ' AND ', $andQueryParts);
1539
+	}
1475 1540
 
1476 1541
 	// Age limits?
1477 1542
 	$timeQuery = '';
1478
-	if (!empty($search_params['minage']))
1479
-		$timeQuery .= ' AND pm.msgtime < ' . (time() - $search_params['minage'] * 86400);
1480
-	if (!empty($search_params['maxage']))
1481
-		$timeQuery .= ' AND pm.msgtime > ' . (time() - $search_params['maxage'] * 86400);
1543
+	if (!empty($search_params['minage'])) {
1544
+			$timeQuery .= ' AND pm.msgtime < ' . (time() - $search_params['minage'] * 86400);
1545
+	}
1546
+	if (!empty($search_params['maxage'])) {
1547
+			$timeQuery .= ' AND pm.msgtime > ' . (time() - $search_params['maxage'] * 86400);
1548
+	}
1482 1549
 
1483 1550
 	// If we have errors - return back to the first screen...
1484 1551
 	if (!empty($context['search_errors']))
@@ -1564,8 +1631,9 @@  discard block
 block discarded – undo
1564 1631
 			)
1565 1632
 		);
1566 1633
 		$real_pm_ids = array();
1567
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1568
-			$real_pm_ids[$row['id_pm_head']] = $row['id_pm'];
1634
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1635
+					$real_pm_ids[$row['id_pm_head']] = $row['id_pm'];
1636
+		}
1569 1637
 		$smcFunc['db_free_result']($request);
1570 1638
 	}
1571 1639
 
@@ -1595,8 +1663,9 @@  discard block
 block discarded – undo
1595 1663
 		);
1596 1664
 		while ($row = $smcFunc['db_fetch_assoc']($request))
1597 1665
 		{
1598
-			if ($context['folder'] == 'sent' || empty($row['bcc']))
1599
-				$recipients[$row['id_pm']][empty($row['bcc']) ? 'to' : 'bcc'][] = empty($row['id_member_to']) ? $txt['guest_title'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member_to'] . '">' . $row['to_name'] . '</a>';
1666
+			if ($context['folder'] == 'sent' || empty($row['bcc'])) {
1667
+							$recipients[$row['id_pm']][empty($row['bcc']) ? 'to' : 'bcc'][] = empty($row['id_member_to']) ? $txt['guest_title'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member_to'] . '">' . $row['to_name'] . '</a>';
1668
+			}
1600 1669
 
1601 1670
 			if ($row['id_member_to'] == $user_info['id'] && $context['folder'] != 'sent')
1602 1671
 			{
@@ -1617,12 +1686,14 @@  discard block
 block discarded – undo
1617 1686
 				while ($row2 = $smcFunc['db_fetch_assoc']($request2))
1618 1687
 				{
1619 1688
 					$l_id = $row2['id_label'];
1620
-					if (isset($context['labels'][$l_id]))
1621
-						$context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']);
1689
+					if (isset($context['labels'][$l_id])) {
1690
+											$context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']);
1691
+					}
1622 1692
 
1623 1693
 					// Here we find the first label on a message - for linking to posts in results
1624
-					if (!isset($context['first_label'][$row['id_pm']]) && $row['in_inbox'] != 1)
1625
-						$context['first_label'][$row['id_pm']] = $l_id;
1694
+					if (!isset($context['first_label'][$row['id_pm']]) && $row['in_inbox'] != 1) {
1695
+											$context['first_label'][$row['id_pm']] = $l_id;
1696
+					}
1626 1697
 				}
1627 1698
 
1628 1699
 				$smcFunc['db_free_result']($request2);
@@ -1749,8 +1820,9 @@  discard block
 block discarded – undo
1749 1820
 		list ($postCount) = $smcFunc['db_fetch_row']($request);
1750 1821
 		$smcFunc['db_free_result']($request);
1751 1822
 
1752
-		if (!empty($postCount) && $postCount >= $modSettings['pm_posts_per_hour'])
1753
-			fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour']));
1823
+		if (!empty($postCount) && $postCount >= $modSettings['pm_posts_per_hour']) {
1824
+					fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour']));
1825
+		}
1754 1826
 	}
1755 1827
 
1756 1828
 	// Quoting/Replying to a message?
@@ -1759,8 +1831,9 @@  discard block
 block discarded – undo
1759 1831
 		$pmsg = (int) $_REQUEST['pmsg'];
1760 1832
 
1761 1833
 		// Make sure this is yours.
1762
-		if (!isAccessiblePM($pmsg))
1763
-			fatal_lang_error('no_access', false);
1834
+		if (!isAccessiblePM($pmsg)) {
1835
+					fatal_lang_error('no_access', false);
1836
+		}
1764 1837
 
1765 1838
 		// Work out whether this is one you've received?
1766 1839
 		$request = $smcFunc['db_query']('', '
@@ -1797,8 +1870,9 @@  discard block
 block discarded – undo
1797 1870
 				'id_pm' => $pmsg,
1798 1871
 			)
1799 1872
 		);
1800
-		if ($smcFunc['db_num_rows']($request) == 0)
1801
-			fatal_lang_error('pm_not_yours', false);
1873
+		if ($smcFunc['db_num_rows']($request) == 0) {
1874
+					fatal_lang_error('pm_not_yours', false);
1875
+		}
1802 1876
 		$row_quoted = $smcFunc['db_fetch_assoc']($request);
1803 1877
 		$smcFunc['db_free_result']($request);
1804 1878
 
@@ -1809,9 +1883,9 @@  discard block
 block discarded – undo
1809 1883
 		// Add 'Re: ' to it....
1810 1884
 		if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix')))
1811 1885
 		{
1812
-			if ($language === $user_info['language'])
1813
-				$context['response_prefix'] = $txt['response_prefix'];
1814
-			else
1886
+			if ($language === $user_info['language']) {
1887
+							$context['response_prefix'] = $txt['response_prefix'];
1888
+			} else
1815 1889
 			{
1816 1890
 				loadLanguage('index', $language, false);
1817 1891
 				$context['response_prefix'] = $txt['response_prefix'];
@@ -1820,22 +1894,25 @@  discard block
 block discarded – undo
1820 1894
 			cache_put_data('response_prefix', $context['response_prefix'], 600);
1821 1895
 		}
1822 1896
 		$form_subject = $row_quoted['subject'];
1823
-		if ($context['reply'] && trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0)
1824
-			$form_subject = $context['response_prefix'] . $form_subject;
1897
+		if ($context['reply'] && trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) {
1898
+					$form_subject = $context['response_prefix'] . $form_subject;
1899
+		}
1825 1900
 
1826 1901
 		if (isset($_REQUEST['quote']))
1827 1902
 		{
1828 1903
 			// Remove any nested quotes and <br>...
1829 1904
 			$form_message = preg_replace('~<br ?/?' . '>~i', "\n", $row_quoted['body']);
1830
-			if (!empty($modSettings['removeNestedQuotes']))
1831
-				$form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message);
1832
-			if (empty($row_quoted['id_member']))
1833
-				$form_message = '[quote author=&quot;' . $row_quoted['real_name'] . '&quot;]' . "\n" . $form_message . "\n" . '[/quote]';
1834
-			else
1835
-				$form_message = '[quote author=' . $row_quoted['real_name'] . ' link=action=profile;u=' . $row_quoted['id_member'] . ' date=' . $row_quoted['msgtime'] . ']' . "\n" . $form_message . "\n" . '[/quote]';
1905
+			if (!empty($modSettings['removeNestedQuotes'])) {
1906
+							$form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message);
1907
+			}
1908
+			if (empty($row_quoted['id_member'])) {
1909
+							$form_message = '[quote author=&quot;' . $row_quoted['real_name'] . '&quot;]' . "\n" . $form_message . "\n" . '[/quote]';
1910
+			} else {
1911
+							$form_message = '[quote author=' . $row_quoted['real_name'] . ' link=action=profile;u=' . $row_quoted['id_member'] . ' date=' . $row_quoted['msgtime'] . ']' . "\n" . $form_message . "\n" . '[/quote]';
1912
+			}
1913
+		} else {
1914
+					$form_message = '';
1836 1915
 		}
1837
-		else
1838
-			$form_message = '';
1839 1916
 
1840 1917
 		// Do the BBC thang on the message.
1841 1918
 		$row_quoted['body'] = parse_bbc($row_quoted['body'], true, 'pm' . $row_quoted['id_pm']);
@@ -1856,8 +1933,7 @@  discard block
 block discarded – undo
1856 1933
 			'timestamp' => forum_time(true, $row_quoted['msgtime']),
1857 1934
 			'body' => $row_quoted['body']
1858 1935
 		);
1859
-	}
1860
-	else
1936
+	} else
1861 1937
 	{
1862 1938
 		$context['quoted_message'] = false;
1863 1939
 		$form_subject = '';
@@ -1876,11 +1952,12 @@  discard block
 block discarded – undo
1876 1952
 		if ($_REQUEST['u'] == 'all' && isset($row_quoted))
1877 1953
 		{
1878 1954
 			// Firstly, to reply to all we clearly already have $row_quoted - so have the original member from.
1879
-			if ($row_quoted['id_member'] != $user_info['id'])
1880
-				$context['recipients']['to'][] = array(
1955
+			if ($row_quoted['id_member'] != $user_info['id']) {
1956
+							$context['recipients']['to'][] = array(
1881 1957
 					'id' => $row_quoted['id_member'],
1882 1958
 					'name' => $smcFunc['htmlspecialchars']($row_quoted['real_name']),
1883 1959
 				);
1960
+			}
1884 1961
 
1885 1962
 			// Now to get the others.
1886 1963
 			$request = $smcFunc['db_query']('', '
@@ -1896,18 +1973,19 @@  discard block
 block discarded – undo
1896 1973
 					'not_bcc' => 0,
1897 1974
 				)
1898 1975
 			);
1899
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1900
-				$context['recipients']['to'][] = array(
1976
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
1977
+							$context['recipients']['to'][] = array(
1901 1978
 					'id' => $row['id_member'],
1902 1979
 					'name' => $row['real_name'],
1903 1980
 				);
1981
+			}
1904 1982
 			$smcFunc['db_free_result']($request);
1905
-		}
1906
-		else
1983
+		} else
1907 1984
 		{
1908 1985
 			$_REQUEST['u'] = explode(',', $_REQUEST['u']);
1909
-			foreach ($_REQUEST['u'] as $key => $uID)
1910
-				$_REQUEST['u'][$key] = (int) $uID;
1986
+			foreach ($_REQUEST['u'] as $key => $uID) {
1987
+							$_REQUEST['u'][$key] = (int) $uID;
1988
+			}
1911 1989
 
1912 1990
 			$_REQUEST['u'] = array_unique($_REQUEST['u']);
1913 1991
 
@@ -1921,22 +1999,24 @@  discard block
 block discarded – undo
1921 1999
 					'limit' => count($_REQUEST['u']),
1922 2000
 				)
1923 2001
 			);
1924
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1925
-				$context['recipients']['to'][] = array(
2002
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
2003
+							$context['recipients']['to'][] = array(
1926 2004
 					'id' => $row['id_member'],
1927 2005
 					'name' => $row['real_name'],
1928 2006
 				);
2007
+			}
1929 2008
 			$smcFunc['db_free_result']($request);
1930 2009
 		}
1931 2010
 
1932 2011
 		// Get a literal name list in case the user has JavaScript disabled.
1933 2012
 		$names = array();
1934
-		foreach ($context['recipients']['to'] as $to)
1935
-			$names[] = $to['name'];
2013
+		foreach ($context['recipients']['to'] as $to) {
2014
+					$names[] = $to['name'];
2015
+		}
1936 2016
 		$context['to_value'] = empty($names) ? '' : '&quot;' . implode('&quot;, &quot;', $names) . '&quot;';
2017
+	} else {
2018
+			$context['to_value'] = '';
1937 2019
 	}
1938
-	else
1939
-		$context['to_value'] = '';
1940 2020
 
1941 2021
 	// Set the defaults...
1942 2022
 	$context['subject'] = $form_subject;
@@ -2006,8 +2086,9 @@  discard block
 block discarded – undo
2006 2086
 
2007 2087
 	// validate with loadMemberData()
2008 2088
 	$memberResult = loadMemberData($user_info['id'], false);
2009
-	if (!$memberResult)
2010
-		fatal_lang_error('not_a_user', false);
2089
+	if (!$memberResult) {
2090
+			fatal_lang_error('not_a_user', false);
2091
+	}
2011 2092
 	list ($memID) = $memberResult;
2012 2093
 
2013 2094
 	// drafts is where the functions reside
@@ -2033,9 +2114,9 @@  discard block
 block discarded – undo
2033 2114
 		$context['sub_template'] = 'send';
2034 2115
 		loadJavaScriptFile('PersonalMessage.js', array('defer' => false, 'minimize' => true), 'smf_pms');
2035 2116
 		loadJavaScriptFile('suggest.js', array('defer' => false, 'minimize' => true), 'smf_suggest');
2117
+	} else {
2118
+			$context['sub_template'] = 'pm';
2036 2119
 	}
2037
-	else
2038
-		$context['sub_template'] = 'pm';
2039 2120
 
2040 2121
 	$context['page_title'] = $txt['send_message'];
2041 2122
 
@@ -2096,10 +2177,11 @@  discard block
 block discarded – undo
2096 2177
 		);
2097 2178
 		if ($smcFunc['db_num_rows']($request) == 0)
2098 2179
 		{
2099
-			if (!isset($_REQUEST['xml']))
2100
-				fatal_lang_error('pm_not_yours', false);
2101
-			else
2102
-				$error_types[] = 'pm_not_yours';
2180
+			if (!isset($_REQUEST['xml'])) {
2181
+							fatal_lang_error('pm_not_yours', false);
2182
+			} else {
2183
+							$error_types[] = 'pm_not_yours';
2184
+			}
2103 2185
 		}
2104 2186
 		$row_quoted = $smcFunc['db_fetch_assoc']($request);
2105 2187
 		$smcFunc['db_free_result']($request);
@@ -2146,14 +2228,16 @@  discard block
 block discarded – undo
2146 2228
 		$context['post_error'][$error_type] = true;
2147 2229
 		if (isset($txt['error_' . $error_type]))
2148 2230
 		{
2149
-			if ($error_type == 'long_message')
2150
-				$txt['error_' . $error_type] = sprintf($txt['error_' . $error_type], $modSettings['max_messageLength']);
2231
+			if ($error_type == 'long_message') {
2232
+							$txt['error_' . $error_type] = sprintf($txt['error_' . $error_type], $modSettings['max_messageLength']);
2233
+			}
2151 2234
 			$context['post_error']['messages'][] = $txt['error_' . $error_type];
2152 2235
 		}
2153 2236
 
2154 2237
 		// If it's not a minor error flag it as such.
2155
-		if (!in_array($error_type, array('new_reply', 'not_approved', 'new_replies', 'old_topic', 'need_qr_verification', 'no_subject')))
2156
-			$context['error_type'] = 'serious';
2238
+		if (!in_array($error_type, array('new_reply', 'not_approved', 'new_replies', 'old_topic', 'need_qr_verification', 'no_subject'))) {
2239
+					$context['error_type'] = 'serious';
2240
+		}
2157 2241
 	}
2158 2242
 
2159 2243
 	// We need to load the editor once more.
@@ -2211,8 +2295,9 @@  discard block
 block discarded – undo
2211 2295
 	require_once($sourcedir . '/Subs-Auth.php');
2212 2296
 
2213 2297
 	// PM Drafts enabled and needed?
2214
-	if ($context['drafts_pm_save'] && (isset($_POST['save_draft']) || isset($_POST['id_pm_draft'])))
2215
-		require_once($sourcedir . '/Drafts.php');
2298
+	if ($context['drafts_pm_save'] && (isset($_POST['save_draft']) || isset($_POST['id_pm_draft']))) {
2299
+			require_once($sourcedir . '/Drafts.php');
2300
+	}
2216 2301
 
2217 2302
 	loadLanguage('PersonalMessage', '', false);
2218 2303
 
@@ -2242,24 +2327,27 @@  discard block
 block discarded – undo
2242 2327
 
2243 2328
 		if (!empty($postCount) && $postCount >= $modSettings['pm_posts_per_hour'])
2244 2329
 		{
2245
-			if (!isset($_REQUEST['xml']))
2246
-				fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour']));
2247
-			else
2248
-				$post_errors[] = 'pm_too_many_per_hour';
2330
+			if (!isset($_REQUEST['xml'])) {
2331
+							fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour']));
2332
+			} else {
2333
+							$post_errors[] = 'pm_too_many_per_hour';
2334
+			}
2249 2335
 		}
2250 2336
 	}
2251 2337
 
2252 2338
 	// If your session timed out, show an error, but do allow to re-submit.
2253
-	if (!isset($_REQUEST['xml']) && checkSession('post', '', false) != '')
2254
-		$post_errors[] = 'session_timeout';
2339
+	if (!isset($_REQUEST['xml']) && checkSession('post', '', false) != '') {
2340
+			$post_errors[] = 'session_timeout';
2341
+	}
2255 2342
 
2256 2343
 	$_REQUEST['subject'] = isset($_REQUEST['subject']) ? trim($_REQUEST['subject']) : '';
2257 2344
 	$_REQUEST['to'] = empty($_POST['to']) ? (empty($_GET['to']) ? '' : $_GET['to']) : $_POST['to'];
2258 2345
 	$_REQUEST['bcc'] = empty($_POST['bcc']) ? (empty($_GET['bcc']) ? '' : $_GET['bcc']) : $_POST['bcc'];
2259 2346
 
2260 2347
 	// Route the input from the 'u' parameter to the 'to'-list.
2261
-	if (!empty($_POST['u']))
2262
-		$_POST['recipient_to'] = explode(',', $_POST['u']);
2348
+	if (!empty($_POST['u'])) {
2349
+			$_POST['recipient_to'] = explode(',', $_POST['u']);
2350
+	}
2263 2351
 
2264 2352
 	// Construct the list of recipients.
2265 2353
 	$recipientList = array();
@@ -2271,8 +2359,9 @@  discard block
 block discarded – undo
2271 2359
 		$recipientList[$recipientType] = array();
2272 2360
 		if (!empty($_POST['recipient_' . $recipientType]) && is_array($_POST['recipient_' . $recipientType]))
2273 2361
 		{
2274
-			foreach ($_POST['recipient_' . $recipientType] as $recipient)
2275
-				$recipientList[$recipientType][] = (int) $recipient;
2362
+			foreach ($_POST['recipient_' . $recipientType] as $recipient) {
2363
+							$recipientList[$recipientType][] = (int) $recipient;
2364
+			}
2276 2365
 		}
2277 2366
 
2278 2367
 		// Are there also literal names set?
@@ -2286,10 +2375,11 @@  discard block
 block discarded – undo
2286 2375
 
2287 2376
 			foreach ($namedRecipientList[$recipientType] as $index => $recipient)
2288 2377
 			{
2289
-				if (strlen(trim($recipient)) > 0)
2290
-					$namedRecipientList[$recipientType][$index] = $smcFunc['htmlspecialchars']($smcFunc['strtolower'](trim($recipient)));
2291
-				else
2292
-					unset($namedRecipientList[$recipientType][$index]);
2378
+				if (strlen(trim($recipient)) > 0) {
2379
+									$namedRecipientList[$recipientType][$index] = $smcFunc['htmlspecialchars']($smcFunc['strtolower'](trim($recipient)));
2380
+				} else {
2381
+									unset($namedRecipientList[$recipientType][$index]);
2382
+				}
2293 2383
 			}
2294 2384
 
2295 2385
 			if (!empty($namedRecipientList[$recipientType]))
@@ -2319,8 +2409,9 @@  discard block
 block discarded – undo
2319 2409
 		}
2320 2410
 
2321 2411
 		// Selected a recipient to be deleted? Remove them now.
2322
-		if (!empty($_POST['delete_recipient']))
2323
-			$recipientList[$recipientType] = array_diff($recipientList[$recipientType], array((int) $_POST['delete_recipient']));
2412
+		if (!empty($_POST['delete_recipient'])) {
2413
+					$recipientList[$recipientType] = array_diff($recipientList[$recipientType], array((int) $_POST['delete_recipient']));
2414
+		}
2324 2415
 
2325 2416
 		// Make sure we don't include the same name twice
2326 2417
 		$recipientList[$recipientType] = array_unique($recipientList[$recipientType]);
@@ -2330,8 +2421,9 @@  discard block
 block discarded – undo
2330 2421
 	$is_recipient_change = !empty($_POST['delete_recipient']) || !empty($_POST['to_submit']) || !empty($_POST['bcc_submit']);
2331 2422
 
2332 2423
 	// Check if there's at least one recipient.
2333
-	if (empty($recipientList['to']) && empty($recipientList['bcc']))
2334
-		$post_errors[] = 'no_to';
2424
+	if (empty($recipientList['to']) && empty($recipientList['bcc'])) {
2425
+			$post_errors[] = 'no_to';
2426
+	}
2335 2427
 
2336 2428
 	// Make sure that we remove the members who did get it from the screen.
2337 2429
 	if (!$is_recipient_change)
@@ -2345,28 +2437,31 @@  discard block
 block discarded – undo
2345 2437
 				// Since we already have a post error, remove the previous one.
2346 2438
 				$post_errors = array_diff($post_errors, array('no_to'));
2347 2439
 
2348
-				foreach ($namesNotFound[$recipientType] as $name)
2349
-					$context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name);
2440
+				foreach ($namesNotFound[$recipientType] as $name) {
2441
+									$context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name);
2442
+				}
2350 2443
 			}
2351 2444
 		}
2352 2445
 	}
2353 2446
 
2354 2447
 	// Did they make any mistakes?
2355
-	if ($_REQUEST['subject'] == '')
2356
-		$post_errors[] = 'no_subject';
2357
-	if (!isset($_REQUEST['message']) || $_REQUEST['message'] == '')
2358
-		$post_errors[] = 'no_message';
2359
-	elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_REQUEST['message']) > $modSettings['max_messageLength'])
2360
-		$post_errors[] = 'long_message';
2361
-	else
2448
+	if ($_REQUEST['subject'] == '') {
2449
+			$post_errors[] = 'no_subject';
2450
+	}
2451
+	if (!isset($_REQUEST['message']) || $_REQUEST['message'] == '') {
2452
+			$post_errors[] = 'no_message';
2453
+	} elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_REQUEST['message']) > $modSettings['max_messageLength']) {
2454
+			$post_errors[] = 'long_message';
2455
+	} else
2362 2456
 	{
2363 2457
 		// Preparse the message.
2364 2458
 		$message = $_REQUEST['message'];
2365 2459
 		preparsecode($message);
2366 2460
 
2367 2461
 		// Make sure there's still some content left without the tags.
2368
-		if ($smcFunc['htmltrim'](strip_tags(parse_bbc($smcFunc['htmlspecialchars']($message, ENT_QUOTES), false), '<img>')) === '' && (!allowedTo('admin_forum') || strpos($message, '[html]') === false))
2369
-			$post_errors[] = 'no_message';
2462
+		if ($smcFunc['htmltrim'](strip_tags(parse_bbc($smcFunc['htmlspecialchars']($message, ENT_QUOTES), false), '<img>')) === '' && (!allowedTo('admin_forum') || strpos($message, '[html]') === false)) {
2463
+					$post_errors[] = 'no_message';
2464
+		}
2370 2465
 	}
2371 2466
 
2372 2467
 	// Wrong verification code?
@@ -2378,13 +2473,15 @@  discard block
 block discarded – undo
2378 2473
 		);
2379 2474
 		$context['require_verification'] = create_control_verification($verificationOptions, true);
2380 2475
 
2381
-		if (is_array($context['require_verification']))
2382
-			$post_errors = array_merge($post_errors, $context['require_verification']);
2476
+		if (is_array($context['require_verification'])) {
2477
+					$post_errors = array_merge($post_errors, $context['require_verification']);
2478
+		}
2383 2479
 	}
2384 2480
 
2385 2481
 	// If they did, give a chance to make ammends.
2386
-	if (!empty($post_errors) && !$is_recipient_change && !isset($_REQUEST['preview']) && !isset($_REQUEST['xml']))
2387
-		return messagePostError($post_errors, $namedRecipientList, $recipientList);
2482
+	if (!empty($post_errors) && !$is_recipient_change && !isset($_REQUEST['preview']) && !isset($_REQUEST['xml'])) {
2483
+			return messagePostError($post_errors, $namedRecipientList, $recipientList);
2484
+	}
2388 2485
 
2389 2486
 	// Want to take a second glance before you send?
2390 2487
 	if (isset($_REQUEST['preview']))
@@ -2415,8 +2512,9 @@  discard block
 block discarded – undo
2415 2512
 		foreach ($namesNotFound as $recipientType => $names)
2416 2513
 		{
2417 2514
 			$post_errors[] = 'bad_' . $recipientType;
2418
-			foreach ($names as $name)
2419
-				$context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name);
2515
+			foreach ($names as $name) {
2516
+							$context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name);
2517
+			}
2420 2518
 		}
2421 2519
 
2422 2520
 		return messagePostError(array(), $namedRecipientList, $recipientList);
@@ -2446,13 +2544,14 @@  discard block
 block discarded – undo
2446 2544
 	checkSubmitOnce('check');
2447 2545
 
2448 2546
 	// Do the actual sending of the PM.
2449
-	if (!empty($recipientList['to']) || !empty($recipientList['bcc']))
2450
-		$context['send_log'] = sendpm($recipientList, $_REQUEST['subject'], $_REQUEST['message'], true, null, !empty($_REQUEST['pm_head']) ? (int) $_REQUEST['pm_head'] : 0);
2451
-	else
2452
-		$context['send_log'] = array(
2547
+	if (!empty($recipientList['to']) || !empty($recipientList['bcc'])) {
2548
+			$context['send_log'] = sendpm($recipientList, $_REQUEST['subject'], $_REQUEST['message'], true, null, !empty($_REQUEST['pm_head']) ? (int) $_REQUEST['pm_head'] : 0);
2549
+	} else {
2550
+			$context['send_log'] = array(
2453 2551
 			'sent' => array(),
2454 2552
 			'failed' => array()
2455 2553
 		);
2554
+	}
2456 2555
 
2457 2556
 	// Mark the message as "replied to".
2458 2557
 	if (!empty($context['send_log']['sent']) && !empty($_REQUEST['replied_to']) && isset($_REQUEST['f']) && $_REQUEST['f'] == 'inbox')
@@ -2470,11 +2569,12 @@  discard block
 block discarded – undo
2470 2569
 	}
2471 2570
 
2472 2571
 	// If one or more of the recipient were invalid, go back to the post screen with the failed usernames.
2473
-	if (!empty($context['send_log']['failed']))
2474
-		return messagePostError($post_errors, $namesNotFound, array(
2572
+	if (!empty($context['send_log']['failed'])) {
2573
+			return messagePostError($post_errors, $namesNotFound, array(
2475 2574
 			'to' => array_intersect($recipientList['to'], $context['send_log']['failed']),
2476 2575
 			'bcc' => array_intersect($recipientList['bcc'], $context['send_log']['failed'])
2477 2576
 		));
2577
+	}
2478 2578
 
2479 2579
 	// Message sent successfully?
2480 2580
 	if (!empty($context['send_log']) && empty($context['send_log']['failed']))
@@ -2482,8 +2582,9 @@  discard block
 block discarded – undo
2482 2582
 		$context['current_label_redirect'] = $context['current_label_redirect'] . ';done=sent';
2483 2583
 
2484 2584
 		// If we had a PM draft for this one, then its time to remove it since it was just sent
2485
-		if ($context['drafts_pm_save'] && !empty($_POST['id_pm_draft']))
2486
-			DeleteDraft($_POST['id_pm_draft']);
2585
+		if ($context['drafts_pm_save'] && !empty($_POST['id_pm_draft'])) {
2586
+					DeleteDraft($_POST['id_pm_draft']);
2587
+		}
2487 2588
 	}
2488 2589
 
2489 2590
 	// Go back to the where they sent from, if possible...
@@ -2498,24 +2599,28 @@  discard block
 block discarded – undo
2498 2599
 
2499 2600
 	checkSession('request');
2500 2601
 
2501
-	if (isset($_REQUEST['del_selected']))
2502
-		$_REQUEST['pm_action'] = 'delete';
2602
+	if (isset($_REQUEST['del_selected'])) {
2603
+			$_REQUEST['pm_action'] = 'delete';
2604
+	}
2503 2605
 
2504 2606
 	if (isset($_REQUEST['pm_action']) && $_REQUEST['pm_action'] != '' && !empty($_REQUEST['pms']) && is_array($_REQUEST['pms']))
2505 2607
 	{
2506
-		foreach ($_REQUEST['pms'] as $pm)
2507
-			$_REQUEST['pm_actions'][(int) $pm] = $_REQUEST['pm_action'];
2608
+		foreach ($_REQUEST['pms'] as $pm) {
2609
+					$_REQUEST['pm_actions'][(int) $pm] = $_REQUEST['pm_action'];
2610
+		}
2508 2611
 	}
2509 2612
 
2510
-	if (empty($_REQUEST['pm_actions']))
2511
-		redirectexit($context['current_label_redirect']);
2613
+	if (empty($_REQUEST['pm_actions'])) {
2614
+			redirectexit($context['current_label_redirect']);
2615
+	}
2512 2616
 
2513 2617
 	// If we are in conversation, we may need to apply this to every message in the conversation.
2514 2618
 	if ($context['display_mode'] == 2 && isset($_REQUEST['conversation']))
2515 2619
 	{
2516 2620
 		$id_pms = array();
2517
-		foreach ($_REQUEST['pm_actions'] as $pm => $dummy)
2518
-			$id_pms[] = (int) $pm;
2621
+		foreach ($_REQUEST['pm_actions'] as $pm => $dummy) {
2622
+					$id_pms[] = (int) $pm;
2623
+		}
2519 2624
 
2520 2625
 		$request = $smcFunc['db_query']('', '
2521 2626
 			SELECT id_pm_head, id_pm
@@ -2526,8 +2631,9 @@  discard block
 block discarded – undo
2526 2631
 			)
2527 2632
 		);
2528 2633
 		$pm_heads = array();
2529
-		while ($row = $smcFunc['db_fetch_assoc']($request))
2530
-			$pm_heads[$row['id_pm_head']] = $row['id_pm'];
2634
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
2635
+					$pm_heads[$row['id_pm_head']] = $row['id_pm'];
2636
+		}
2531 2637
 		$smcFunc['db_free_result']($request);
2532 2638
 
2533 2639
 		$request = $smcFunc['db_query']('', '
@@ -2541,8 +2647,9 @@  discard block
 block discarded – undo
2541 2647
 		// Copy the action from the single to PM to the others.
2542 2648
 		while ($row = $smcFunc['db_fetch_assoc']($request))
2543 2649
 		{
2544
-			if (isset($pm_heads[$row['id_pm_head']]) && isset($_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]]))
2545
-				$_REQUEST['pm_actions'][$row['id_pm']] = $_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]];
2650
+			if (isset($pm_heads[$row['id_pm_head']]) && isset($_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]])) {
2651
+							$_REQUEST['pm_actions'][$row['id_pm']] = $_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]];
2652
+			}
2546 2653
 		}
2547 2654
 		$smcFunc['db_free_result']($request);
2548 2655
 	}
@@ -2553,22 +2660,21 @@  discard block
 block discarded – undo
2553 2660
 	$labels = array();
2554 2661
 	foreach ($_REQUEST['pm_actions'] as $pm => $action)
2555 2662
 	{
2556
-		if ($action === 'delete')
2557
-			$to_delete[] = (int) $pm;
2558
-		else
2663
+		if ($action === 'delete') {
2664
+					$to_delete[] = (int) $pm;
2665
+		} else
2559 2666
 		{
2560 2667
 			if (substr($action, 0, 4) == 'add_')
2561 2668
 			{
2562 2669
 				$type = 'add';
2563 2670
 				$action = substr($action, 4);
2564
-			}
2565
-			elseif (substr($action, 0, 4) == 'rem_')
2671
+			} elseif (substr($action, 0, 4) == 'rem_')
2566 2672
 			{
2567 2673
 				$type = 'rem';
2568 2674
 				$action = substr($action, 4);
2675
+			} else {
2676
+							$type = 'unk';
2569 2677
 			}
2570
-			else
2571
-				$type = 'unk';
2572 2678
 
2573 2679
 			if ($action == '-1' || (int) $action > 0)
2574 2680
 			{
@@ -2579,8 +2685,9 @@  discard block
 block discarded – undo
2579 2685
 	}
2580 2686
 
2581 2687
 	// Deleting, it looks like?
2582
-	if (!empty($to_delete))
2583
-		deleteMessages($to_delete, $context['display_mode'] == 2 ? null : $context['folder']);
2688
+	if (!empty($to_delete)) {
2689
+			deleteMessages($to_delete, $context['display_mode'] == 2 ? null : $context['folder']);
2690
+	}
2584 2691
 
2585 2692
 	// Are we labeling anything?
2586 2693
 	if (!empty($to_label) && $context['folder'] == 'inbox')
@@ -2646,8 +2753,7 @@  discard block
 block discarded – undo
2646 2753
 				}
2647 2754
 
2648 2755
 				$smcFunc['db_free_result']($request2);
2649
-			}
2650
-			elseif ($type == 'rem')
2756
+			} elseif ($type == 'rem')
2651 2757
 			{
2652 2758
 				// If we're removing from the inbox, see if we have at least one other label.
2653 2759
 				// This query is faster than the one above
@@ -2679,21 +2785,25 @@  discard block
 block discarded – undo
2679 2785
 			if ($to_label[$row['id_pm']] != '-1')
2680 2786
 			{
2681 2787
 				// If this label is in the list and we're not adding it, remove it
2682
-				if (array_key_exists($to_label[$row['id_pm']], $labels) && $type !== 'add')
2683
-					unset($labels[$to_label[$row['id_pm']]]);
2684
-				else if ($type !== 'rem')
2685
-					$labels[$to_label[$row['id_pm']]] = $to_label[$row['id_pm']];
2788
+				if (array_key_exists($to_label[$row['id_pm']], $labels) && $type !== 'add') {
2789
+									unset($labels[$to_label[$row['id_pm']]]);
2790
+				} else if ($type !== 'rem') {
2791
+									$labels[$to_label[$row['id_pm']]] = $to_label[$row['id_pm']];
2792
+				}
2686 2793
 			}
2687 2794
 
2688 2795
 			// Removing all labels or just removing the inbox label
2689
-			if ($type == 'rem' && empty($labels))
2690
-				$in_inbox = (empty($context['can_remove_inbox']) ? 1 : 0);
2796
+			if ($type == 'rem' && empty($labels)) {
2797
+							$in_inbox = (empty($context['can_remove_inbox']) ? 1 : 0);
2798
+			}
2691 2799
 			// Adding new labels, but removing inbox and applying new ones
2692
-			elseif ($type == 'add' && !empty($options['pm_remove_inbox_label']) && !empty($labels))
2693
-				$in_inbox = 0;
2800
+			elseif ($type == 'add' && !empty($options['pm_remove_inbox_label']) && !empty($labels)) {
2801
+							$in_inbox = 0;
2802
+			}
2694 2803
 			// Just adding it to the inbox
2695
-			else
2696
-				$in_inbox = 1;
2804
+			else {
2805
+							$in_inbox = 1;
2806
+			}
2697 2807
 
2698 2808
 			// Are we adding it to or removing it from the inbox?
2699 2809
 			if ($in_inbox != $row['in_inbox'])
@@ -2735,8 +2845,9 @@  discard block
 block discarded – undo
2735 2845
 			if (!empty($labels_to_apply))
2736 2846
 			{
2737 2847
 				$inserts = array();
2738
-				foreach ($labels_to_apply as $label)
2739
-					$inserts[] = array($row['id_pm'], $label);
2848
+				foreach ($labels_to_apply as $label) {
2849
+									$inserts[] = array($row['id_pm'], $label);
2850
+				}
2740 2851
 
2741 2852
 				$smcFunc['db_insert']('',
2742 2853
 					'{db_prefix}pm_labeled_messages',
@@ -2780,11 +2891,13 @@  discard block
 block discarded – undo
2780 2891
 	checkSession('get');
2781 2892
 
2782 2893
 	// If all then delete all messages the user has.
2783
-	if ($_REQUEST['f'] == 'all')
2784
-		deleteMessages(null, null);
2894
+	if ($_REQUEST['f'] == 'all') {
2895
+			deleteMessages(null, null);
2896
+	}
2785 2897
 	// Otherwise just the selected folder.
2786
-	else
2787
-		deleteMessages(null, $_REQUEST['f'] != 'sent' ? 'inbox' : 'sent');
2898
+	else {
2899
+			deleteMessages(null, $_REQUEST['f'] != 'sent' ? 'inbox' : 'sent');
2900
+	}
2788 2901
 
2789 2902
 	// Done... all gone.
2790 2903
 	redirectexit($context['current_label_redirect']);
@@ -2821,8 +2934,9 @@  discard block
 block discarded – undo
2821 2934
 				'msgtime' => $deleteTime,
2822 2935
 			)
2823 2936
 		);
2824
-		while ($row = $smcFunc['db_fetch_row']($request))
2825
-			$toDelete[] = $row[0];
2937
+		while ($row = $smcFunc['db_fetch_row']($request)) {
2938
+					$toDelete[] = $row[0];
2939
+		}
2826 2940
 		$smcFunc['db_free_result']($request);
2827 2941
 
2828 2942
 		// Select all messages in their inbox older than $deleteTime.
@@ -2839,8 +2953,9 @@  discard block
 block discarded – undo
2839 2953
 				'msgtime' => $deleteTime,
2840 2954
 			)
2841 2955
 		);
2842
-		while ($row = $smcFunc['db_fetch_assoc']($request))
2843
-			$toDelete[] = $row['id_pm'];
2956
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
2957
+					$toDelete[] = $row['id_pm'];
2958
+		}
2844 2959
 		$smcFunc['db_free_result']($request);
2845 2960
 
2846 2961
 		// Delete the actual messages.
@@ -2871,26 +2986,29 @@  discard block
 block discarded – undo
2871 2986
 {
2872 2987
 	global $user_info, $smcFunc;
2873 2988
 
2874
-	if ($owner === null)
2875
-		$owner = array($user_info['id']);
2876
-	elseif (empty($owner))
2877
-		return;
2878
-	elseif (!is_array($owner))
2879
-		$owner = array($owner);
2989
+	if ($owner === null) {
2990
+			$owner = array($user_info['id']);
2991
+	} elseif (empty($owner)) {
2992
+			return;
2993
+	} elseif (!is_array($owner)) {
2994
+			$owner = array($owner);
2995
+	}
2880 2996
 
2881 2997
 	if ($personal_messages !== null)
2882 2998
 	{
2883
-		if (empty($personal_messages) || !is_array($personal_messages))
2884
-			return;
2999
+		if (empty($personal_messages) || !is_array($personal_messages)) {
3000
+					return;
3001
+		}
2885 3002
 
2886
-		foreach ($personal_messages as $index => $delete_id)
2887
-			$personal_messages[$index] = (int) $delete_id;
3003
+		foreach ($personal_messages as $index => $delete_id) {
3004
+					$personal_messages[$index] = (int) $delete_id;
3005
+		}
2888 3006
 
2889 3007
 		$where = '
2890 3008
 				AND id_pm IN ({array_int:pm_list})';
3009
+	} else {
3010
+			$where = '';
2891 3011
 	}
2892
-	else
2893
-		$where = '';
2894 3012
 
2895 3013
 	if ($folder == 'sent' || $folder === null)
2896 3014
 	{
@@ -2925,17 +3043,19 @@  discard block
 block discarded – undo
2925 3043
 		// ...And update the statistics accordingly - now including unread messages!.
2926 3044
 		while ($row = $smcFunc['db_fetch_assoc']($request))
2927 3045
 		{
2928
-			if ($row['is_read'])
2929
-				updateMemberData($row['id_member'], array('instant_messages' => $where == '' ? 0 : 'instant_messages - ' . $row['num_deleted_messages']));
2930
-			else
2931
-				updateMemberData($row['id_member'], array('instant_messages' => $where == '' ? 0 : 'instant_messages - ' . $row['num_deleted_messages'], 'unread_messages' => $where == '' ? 0 : 'unread_messages - ' . $row['num_deleted_messages']));
3046
+			if ($row['is_read']) {
3047
+							updateMemberData($row['id_member'], array('instant_messages' => $where == '' ? 0 : 'instant_messages - ' . $row['num_deleted_messages']));
3048
+			} else {
3049
+							updateMemberData($row['id_member'], array('instant_messages' => $where == '' ? 0 : 'instant_messages - ' . $row['num_deleted_messages'], 'unread_messages' => $where == '' ? 0 : 'unread_messages - ' . $row['num_deleted_messages']));
3050
+			}
2932 3051
 
2933 3052
 			// If this is the current member we need to make their message count correct.
2934 3053
 			if ($user_info['id'] == $row['id_member'])
2935 3054
 			{
2936 3055
 				$user_info['messages'] -= $row['num_deleted_messages'];
2937
-				if (!($row['is_read']))
2938
-					$user_info['unread_messages'] -= $row['num_deleted_messages'];
3056
+				if (!($row['is_read'])) {
3057
+									$user_info['unread_messages'] -= $row['num_deleted_messages'];
3058
+				}
2939 3059
 			}
2940 3060
 		}
2941 3061
 		$smcFunc['db_free_result']($request);
@@ -3003,8 +3123,9 @@  discard block
 block discarded – undo
3003 3123
 		)
3004 3124
 	);
3005 3125
 	$remove_pms = array();
3006
-	while ($row = $smcFunc['db_fetch_assoc']($request))
3007
-		$remove_pms[] = $row['sender'];
3126
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
3127
+			$remove_pms[] = $row['sender'];
3128
+	}
3008 3129
 	$smcFunc['db_free_result']($request);
3009 3130
 
3010 3131
 	if (!empty($remove_pms))
@@ -3049,8 +3170,9 @@  discard block
 block discarded – undo
3049 3170
 {
3050 3171
 	global $user_info, $context, $smcFunc;
3051 3172
 
3052
-	if ($owner === null)
3053
-		$owner = $user_info['id'];
3173
+	if ($owner === null) {
3174
+			$owner = $user_info['id'];
3175
+	}
3054 3176
 
3055 3177
 	$in_inbox = '';
3056 3178
 
@@ -3074,8 +3196,7 @@  discard block
 block discarded – undo
3074 3196
 		}
3075 3197
 
3076 3198
 		$smcFunc['db_free_result']($get_messages);
3077
-	}
3078
-	elseif ($label = '-1')
3199
+	} elseif ($label = '-1')
3079 3200
 	{
3080 3201
 		// Marking all PMs in your inbox read
3081 3202
 		$in_inbox = '
@@ -3100,8 +3221,9 @@  discard block
 block discarded – undo
3100 3221
 	{
3101 3222
 		if ($owner == $user_info['id'])
3102 3223
 		{
3103
-			foreach ($context['labels'] as $label)
3104
-				$context['labels'][(int) $label['id']]['unread_messages'] = 0;
3224
+			foreach ($context['labels'] as $label) {
3225
+							$context['labels'][(int) $label['id']]['unread_messages'] = 0;
3226
+			}
3105 3227
 		}
3106 3228
 
3107 3229
 		$result = $smcFunc['db_query']('', '
@@ -3121,8 +3243,9 @@  discard block
 block discarded – undo
3121 3243
 		{
3122 3244
 			$total_unread += $row['num'];
3123 3245
 
3124
-			if ($owner != $user_info['id'] || empty($row['id_pm']))
3125
-				continue;
3246
+			if ($owner != $user_info['id'] || empty($row['id_pm'])) {
3247
+							continue;
3248
+			}
3126 3249
 
3127 3250
 			$this_labels = array();
3128 3251
 
@@ -3146,11 +3269,13 @@  discard block
 block discarded – undo
3146 3269
 
3147 3270
 			$smcFunc['db_free_result']($result2);
3148 3271
 
3149
-			foreach ($this_labels as $this_label)
3150
-				$context['labels'][$this_label]['unread_messages'] += $row['num'];
3272
+			foreach ($this_labels as $this_label) {
3273
+							$context['labels'][$this_label]['unread_messages'] += $row['num'];
3274
+			}
3151 3275
 
3152
-			if ($row['in_inbox'] == 1)
3153
-				$context['labels'][-1]['unread_messages'] += $row['num'];
3276
+			if ($row['in_inbox'] == 1) {
3277
+							$context['labels'][-1]['unread_messages'] += $row['num'];
3278
+			}
3154 3279
 		}
3155 3280
 		$smcFunc['db_free_result']($result);
3156 3281
 
@@ -3159,8 +3284,9 @@  discard block
 block discarded – undo
3159 3284
 		updateMemberData($owner, array('unread_messages' => $total_unread));
3160 3285
 
3161 3286
 		// If it was for the current member, reflect this in the $user_info array too.
3162
-		if ($owner == $user_info['id'])
3163
-			$user_info['unread_messages'] = $total_unread;
3287
+		if ($owner == $user_info['id']) {
3288
+					$user_info['unread_messages'] = $total_unread;
3289
+		}
3164 3290
 	}
3165 3291
 }
3166 3292
 
@@ -3188,8 +3314,9 @@  discard block
 block discarded – undo
3188 3314
 	// Add all existing labels to the array to save, slashing them as necessary...
3189 3315
 	foreach ($context['labels'] as $label)
3190 3316
 	{
3191
-		if ($label['id'] != -1)
3192
-			$the_labels[$label['id']] = $label['name'];
3317
+		if ($label['id'] != -1) {
3318
+					$the_labels[$label['id']] = $label['name'];
3319
+		}
3193 3320
 	}
3194 3321
 
3195 3322
 	if (isset($_POST[$context['session_var']]))
@@ -3208,8 +3335,9 @@  discard block
 block discarded – undo
3208 3335
 		{
3209 3336
 			$_POST['label'] = strtr($smcFunc['htmlspecialchars'](trim($_POST['label'])), array(',' => '&#044;'));
3210 3337
 
3211
-			if ($smcFunc['strlen']($_POST['label']) > 30)
3212
-				$_POST['label'] = $smcFunc['substr']($_POST['label'], 0, 30);
3338
+			if ($smcFunc['strlen']($_POST['label']) > 30) {
3339
+							$_POST['label'] = $smcFunc['substr']($_POST['label'], 0, 30);
3340
+			}
3213 3341
 			if ($_POST['label'] != '')
3214 3342
 			{
3215 3343
 				$the_labels[] = $_POST['label'];
@@ -3230,23 +3358,24 @@  discard block
 block discarded – undo
3230 3358
 		{
3231 3359
 			foreach ($the_labels as $id => $name)
3232 3360
 			{
3233
-				if ($id == -1)
3234
-					continue;
3235
-				elseif (isset($_POST['label_name'][$id]))
3361
+				if ($id == -1) {
3362
+									continue;
3363
+				} elseif (isset($_POST['label_name'][$id]))
3236 3364
 				{
3237 3365
 					$_POST['label_name'][$id] = trim(strtr($smcFunc['htmlspecialchars']($_POST['label_name'][$id]), array(',' => '&#044;')));
3238 3366
 
3239
-					if ($smcFunc['strlen']($_POST['label_name'][$id]) > 30)
3240
-						$_POST['label_name'][$id] = $smcFunc['substr']($_POST['label_name'][$id], 0, 30);
3367
+					if ($smcFunc['strlen']($_POST['label_name'][$id]) > 30) {
3368
+											$_POST['label_name'][$id] = $smcFunc['substr']($_POST['label_name'][$id], 0, 30);
3369
+					}
3241 3370
 					if ($_POST['label_name'][$id] != '')
3242 3371
 					{
3243 3372
 						// Changing the name of this label?
3244
-						if ($the_labels[$id] != $_POST['label_name'][$id])
3245
-							$label_updates[$id] = $_POST['label_name'][$id];
3373
+						if ($the_labels[$id] != $_POST['label_name'][$id]) {
3374
+													$label_updates[$id] = $_POST['label_name'][$id];
3375
+						}
3246 3376
 
3247 3377
 						$the_labels[(int) $id] = $_POST['label_name'][$id];
3248
-					}
3249
-					else
3378
+					} else
3250 3379
 					{
3251 3380
 						unset($the_labels[(int) $id]);
3252 3381
 						$labels_to_remove[] = $id;
@@ -3260,8 +3389,9 @@  discard block
 block discarded – undo
3260 3389
 		if (!empty($labels_to_add))
3261 3390
 		{
3262 3391
 			$inserts = array();
3263
-			foreach ($labels_to_add AS $label)
3264
-				$inserts[] = array($user_info['id'], $label);
3392
+			foreach ($labels_to_add AS $label) {
3393
+							$inserts[] = array($user_info['id'], $label);
3394
+			}
3265 3395
 
3266 3396
 			$smcFunc['db_insert']('', '{db_prefix}pm_labels', array('id_member' => 'int', 'name' => 'string-30'), $inserts, array());
3267 3397
 		}
@@ -3351,8 +3481,9 @@  discard block
 block discarded – undo
3351 3481
 				// Each action...
3352 3482
 				foreach ($rule['actions'] as $k2 => $action)
3353 3483
 				{
3354
-					if ($action['t'] != 'lab' || !in_array($action['v'], $labels_to_remove))
3355
-						continue;
3484
+					if ($action['t'] != 'lab' || !in_array($action['v'], $labels_to_remove)) {
3485
+											continue;
3486
+					}
3356 3487
 
3357 3488
 					$rule_changes[] = $rule['id'];
3358 3489
 
@@ -3367,8 +3498,8 @@  discard block
 block discarded – undo
3367 3498
 		{
3368 3499
 			$rule_changes = array_unique($rule_changes);
3369 3500
 			// Update/delete as appropriate.
3370
-			foreach ($rule_changes as $k => $id)
3371
-				if (!empty($context['rules'][$id]['actions']))
3501
+			foreach ($rule_changes as $k => $id) {
3502
+							if (!empty($context['rules'][$id]['actions']))
3372 3503
 				{
3373 3504
 					$smcFunc['db_query']('', '
3374 3505
 						UPDATE {db_prefix}pm_rules
@@ -3381,12 +3512,13 @@  discard block
 block discarded – undo
3381 3512
 							'actions' => $smcFunc['json_encode']($context['rules'][$id]['actions']),
3382 3513
 						)
3383 3514
 					);
3515
+			}
3384 3516
 					unset($rule_changes[$k]);
3385 3517
 				}
3386 3518
 
3387 3519
 			// Anything left here means it's lost all actions...
3388
-			if (!empty($rule_changes))
3389
-				$smcFunc['db_query']('', '
3520
+			if (!empty($rule_changes)) {
3521
+							$smcFunc['db_query']('', '
3390 3522
 					DELETE FROM {db_prefix}pm_rules
3391 3523
 					WHERE id_rule IN ({array_int:rule_list})
3392 3524
 							AND id_member = {int:current_member}',
@@ -3395,6 +3527,7 @@  discard block
 block discarded – undo
3395 3527
 						'rule_list' => $rule_changes,
3396 3528
 					)
3397 3529
 				);
3530
+			}
3398 3531
 		}
3399 3532
 
3400 3533
 		// Make sure we're not caching this!
@@ -3464,8 +3597,9 @@  discard block
 block discarded – undo
3464 3597
 		// Save the fields.
3465 3598
 		saveProfileFields();
3466 3599
 
3467
-		if (!empty($profile_vars))
3468
-			updateMemberData($user_info['id'], $profile_vars);
3600
+		if (!empty($profile_vars)) {
3601
+					updateMemberData($user_info['id'], $profile_vars);
3602
+		}
3469 3603
 	}
3470 3604
 
3471 3605
 	setupProfileContext(
@@ -3490,13 +3624,15 @@  discard block
 block discarded – undo
3490 3624
 	global $user_info, $language, $modSettings, $smcFunc;
3491 3625
 
3492 3626
 	// Check that this feature is even enabled!
3493
-	if (empty($modSettings['enableReportPM']) || empty($_REQUEST['pmsg']))
3494
-		fatal_lang_error('no_access', false);
3627
+	if (empty($modSettings['enableReportPM']) || empty($_REQUEST['pmsg'])) {
3628
+			fatal_lang_error('no_access', false);
3629
+	}
3495 3630
 
3496 3631
 	$pmsg = (int) $_REQUEST['pmsg'];
3497 3632
 
3498
-	if (!isAccessiblePM($pmsg, 'inbox'))
3499
-		fatal_lang_error('no_access', false);
3633
+	if (!isAccessiblePM($pmsg, 'inbox')) {
3634
+			fatal_lang_error('no_access', false);
3635
+	}
3500 3636
 
3501 3637
 	$context['pm_id'] = $pmsg;
3502 3638
 	$context['page_title'] = $txt['pm_report_title'];
@@ -3518,8 +3654,9 @@  discard block
 block discarded – undo
3518 3654
 			)
3519 3655
 		);
3520 3656
 		$context['admins'] = array();
3521
-		while ($row = $smcFunc['db_fetch_assoc']($request))
3522
-			$context['admins'][$row['id_member']] = $row['real_name'];
3657
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
3658
+					$context['admins'][$row['id_member']] = $row['real_name'];
3659
+		}
3523 3660
 		$smcFunc['db_free_result']($request);
3524 3661
 
3525 3662
 		// How many admins in total?
@@ -3548,8 +3685,9 @@  discard block
 block discarded – undo
3548 3685
 			)
3549 3686
 		);
3550 3687
 		// Can only be a hacker here!
3551
-		if ($smcFunc['db_num_rows']($request) == 0)
3552
-			fatal_lang_error('no_access', false);
3688
+		if ($smcFunc['db_num_rows']($request) == 0) {
3689
+					fatal_lang_error('no_access', false);
3690
+		}
3553 3691
 		list ($subject, $body, $time, $memberFromID, $memberFromName) = $smcFunc['db_fetch_row']($request);
3554 3692
 		$smcFunc['db_free_result']($request);
3555 3693
 
@@ -3573,15 +3711,17 @@  discard block
 block discarded – undo
3573 3711
 		while ($row = $smcFunc['db_fetch_assoc']($request))
3574 3712
 		{
3575 3713
 			// If it's hidden still don't reveal their names - privacy after all ;)
3576
-			if ($row['bcc'])
3577
-				$hidden_recipients++;
3578
-			else
3579
-				$recipients[] = '[url=' . $scripturl . '?action=profile;u=' . $row['id_member_to'] . ']' . $row['to_name'] . '[/url]';
3714
+			if ($row['bcc']) {
3715
+							$hidden_recipients++;
3716
+			} else {
3717
+							$recipients[] = '[url=' . $scripturl . '?action=profile;u=' . $row['id_member_to'] . ']' . $row['to_name'] . '[/url]';
3718
+			}
3580 3719
 		}
3581 3720
 		$smcFunc['db_free_result']($request);
3582 3721
 
3583
-		if ($hidden_recipients)
3584
-			$recipients[] = sprintf($txt['pm_report_pm_hidden'], $hidden_recipients);
3722
+		if ($hidden_recipients) {
3723
+					$recipients[] = sprintf($txt['pm_report_pm_hidden'], $hidden_recipients);
3724
+		}
3585 3725
 
3586 3726
 		// Now let's get out and loop through the admins.
3587 3727
 		$request = $smcFunc['db_query']('', '
@@ -3597,8 +3737,9 @@  discard block
 block discarded – undo
3597 3737
 		);
3598 3738
 
3599 3739
 		// Maybe we shouldn't advertise this?
3600
-		if ($smcFunc['db_num_rows']($request) == 0)
3601
-			fatal_lang_error('no_access', false);
3740
+		if ($smcFunc['db_num_rows']($request) == 0) {
3741
+					fatal_lang_error('no_access', false);
3742
+		}
3602 3743
 
3603 3744
 		$memberFromName = un_htmlspecialchars($memberFromName);
3604 3745
 
@@ -3617,8 +3758,9 @@  discard block
 block discarded – undo
3617 3758
 				// Make the body.
3618 3759
 				$report_body = str_replace(array('{REPORTER}', '{SENDER}'), array(un_htmlspecialchars($user_info['name']), $memberFromName), $txt['pm_report_pm_user_sent']);
3619 3760
 				$report_body .= "\n" . '[b]' . $_POST['reason'] . '[/b]' . "\n\n";
3620
-				if (!empty($recipients))
3621
-					$report_body .= $txt['pm_report_pm_other_recipients'] . ' ' . implode(', ', $recipients) . "\n\n";
3761
+				if (!empty($recipients)) {
3762
+									$report_body .= $txt['pm_report_pm_other_recipients'] . ' ' . implode(', ', $recipients) . "\n\n";
3763
+				}
3622 3764
 				$report_body .= $txt['pm_report_pm_unedited_below'] . "\n" . '[quote author=' . (empty($memberFromID) ? '&quot;' . $memberFromName . '&quot;' : $memberFromName . ' link=action=profile;u=' . $memberFromID . ' date=' . $time) . ']' . "\n" . un_htmlspecialchars($body) . '[/quote]';
3623 3765
 
3624 3766
 				// Plonk it in the array ;)
@@ -3638,12 +3780,14 @@  discard block
 block discarded – undo
3638 3780
 		$smcFunc['db_free_result']($request);
3639 3781
 
3640 3782
 		// Send a different email for each language.
3641
-		foreach ($messagesToSend as $lang => $message)
3642
-			sendpm($message['recipients'], $message['subject'], $message['body']);
3783
+		foreach ($messagesToSend as $lang => $message) {
3784
+					sendpm($message['recipients'], $message['subject'], $message['body']);
3785
+		}
3643 3786
 
3644 3787
 		// Give the user their own language back!
3645
-		if (!empty($modSettings['userLanguage']))
3646
-			loadLanguage('PersonalMessage', '', false);
3788
+		if (!empty($modSettings['userLanguage'])) {
3789
+					loadLanguage('PersonalMessage', '', false);
3790
+		}
3647 3791
 
3648 3792
 		// Leave them with a template.
3649 3793
 		$context['sub_template'] = 'report_message_complete';
@@ -3689,8 +3833,9 @@  discard block
 block discarded – undo
3689 3833
 	while ($row = $smcFunc['db_fetch_assoc']($request))
3690 3834
 	{
3691 3835
 		// Hide hidden groups!
3692
-		if ($row['hidden'] && !$row['can_moderate'] && !allowedTo('manage_membergroups'))
3693
-			continue;
3836
+		if ($row['hidden'] && !$row['can_moderate'] && !allowedTo('manage_membergroups')) {
3837
+					continue;
3838
+		}
3694 3839
 
3695 3840
 		$context['groups'][$row['id_group']] = $row['group_name'];
3696 3841
 	}
@@ -3716,9 +3861,10 @@  discard block
 block discarded – undo
3716 3861
 			$context['rule'] = $context['rules'][$context['rid']];
3717 3862
 			$members = array();
3718 3863
 			// Need to get member names!
3719
-			foreach ($context['rule']['criteria'] as $k => $criteria)
3720
-				if ($criteria['t'] == 'mid' && !empty($criteria['v']))
3864
+			foreach ($context['rule']['criteria'] as $k => $criteria) {
3865
+							if ($criteria['t'] == 'mid' && !empty($criteria['v']))
3721 3866
 					$members[(int) $criteria['v']] = $k;
3867
+			}
3722 3868
 
3723 3869
 			if (!empty($members))
3724 3870
 			{
@@ -3730,19 +3876,20 @@  discard block
 block discarded – undo
3730 3876
 						'member_list' => array_keys($members),
3731 3877
 					)
3732 3878
 				);
3733
-				while ($row = $smcFunc['db_fetch_assoc']($request))
3734
-					$context['rule']['criteria'][$members[$row['id_member']]]['v'] = $row['member_name'];
3879
+				while ($row = $smcFunc['db_fetch_assoc']($request)) {
3880
+									$context['rule']['criteria'][$members[$row['id_member']]]['v'] = $row['member_name'];
3881
+				}
3735 3882
 				$smcFunc['db_free_result']($request);
3736 3883
 			}
3737
-		}
3738
-		else
3739
-			$context['rule'] = array(
3884
+		} else {
3885
+					$context['rule'] = array(
3740 3886
 				'id' => '',
3741 3887
 				'name' => '',
3742 3888
 				'criteria' => array(),
3743 3889
 				'actions' => array(),
3744 3890
 				'logic' => 'and',
3745 3891
 			);
3892
+		}
3746 3893
 	}
3747 3894
 	// Saving?
3748 3895
 	elseif (isset($_GET['save']))
@@ -3752,22 +3899,25 @@  discard block
 block discarded – undo
3752 3899
 
3753 3900
 		// Name is easy!
3754 3901
 		$ruleName = $smcFunc['htmlspecialchars'](trim($_POST['rule_name']));
3755
-		if (empty($ruleName))
3756
-			fatal_lang_error('pm_rule_no_name', false);
3902
+		if (empty($ruleName)) {
3903
+					fatal_lang_error('pm_rule_no_name', false);
3904
+		}
3757 3905
 
3758 3906
 		// Sanity check...
3759
-		if (empty($_POST['ruletype']) || empty($_POST['acttype']))
3760
-			fatal_lang_error('pm_rule_no_criteria', false);
3907
+		if (empty($_POST['ruletype']) || empty($_POST['acttype'])) {
3908
+					fatal_lang_error('pm_rule_no_criteria', false);
3909
+		}
3761 3910
 
3762 3911
 		// Let's do the criteria first - it's also hardest!
3763 3912
 		$criteria = array();
3764 3913
 		foreach ($_POST['ruletype'] as $ind => $type)
3765 3914
 		{
3766 3915
 			// Check everything is here...
3767
-			if ($type == 'gid' && (!isset($_POST['ruledefgroup'][$ind]) || !isset($context['groups'][$_POST['ruledefgroup'][$ind]])))
3768
-				continue;
3769
-			elseif ($type != 'bud' && !isset($_POST['ruledef'][$ind]))
3770
-				continue;
3916
+			if ($type == 'gid' && (!isset($_POST['ruledefgroup'][$ind]) || !isset($context['groups'][$_POST['ruledefgroup'][$ind]]))) {
3917
+							continue;
3918
+			} elseif ($type != 'bud' && !isset($_POST['ruledef'][$ind])) {
3919
+							continue;
3920
+			}
3771 3921
 
3772 3922
 			// Members need to be found.
3773 3923
 			if ($type == 'mid')
@@ -3791,13 +3941,13 @@  discard block
 block discarded – undo
3791 3941
 				$smcFunc['db_free_result']($request);
3792 3942
 
3793 3943
 				$criteria[] = array('t' => 'mid', 'v' => $memID);
3944
+			} elseif ($type == 'bud') {
3945
+							$criteria[] = array('t' => 'bud', 'v' => 1);
3946
+			} elseif ($type == 'gid') {
3947
+							$criteria[] = array('t' => 'gid', 'v' => (int) $_POST['ruledefgroup'][$ind]);
3948
+			} elseif (in_array($type, array('sub', 'msg')) && trim($_POST['ruledef'][$ind]) != '') {
3949
+							$criteria[] = array('t' => $type, 'v' => $smcFunc['htmlspecialchars'](trim($_POST['ruledef'][$ind])));
3794 3950
 			}
3795
-			elseif ($type == 'bud')
3796
-				$criteria[] = array('t' => 'bud', 'v' => 1);
3797
-			elseif ($type == 'gid')
3798
-				$criteria[] = array('t' => 'gid', 'v' => (int) $_POST['ruledefgroup'][$ind]);
3799
-			elseif (in_array($type, array('sub', 'msg')) && trim($_POST['ruledef'][$ind]) != '')
3800
-				$criteria[] = array('t' => $type, 'v' => $smcFunc['htmlspecialchars'](trim($_POST['ruledef'][$ind])));
3801 3951
 		}
3802 3952
 
3803 3953
 		// Also do the actions!
@@ -3807,26 +3957,29 @@  discard block
 block discarded – undo
3807 3957
 		foreach ($_POST['acttype'] as $ind => $type)
3808 3958
 		{
3809 3959
 			// Picking a valid label?
3810
-			if ($type == 'lab' && (!isset($_POST['labdef'][$ind]) || !isset($context['labels'][$_POST['labdef'][$ind]])))
3811
-				continue;
3960
+			if ($type == 'lab' && (!isset($_POST['labdef'][$ind]) || !isset($context['labels'][$_POST['labdef'][$ind]]))) {
3961
+							continue;
3962
+			}
3812 3963
 
3813 3964
 			// Record what we're doing.
3814
-			if ($type == 'del')
3815
-				$doDelete = 1;
3816
-			elseif ($type == 'lab')
3817
-				$actions[] = array('t' => 'lab', 'v' => (int) $_POST['labdef'][$ind]);
3965
+			if ($type == 'del') {
3966
+							$doDelete = 1;
3967
+			} elseif ($type == 'lab') {
3968
+							$actions[] = array('t' => 'lab', 'v' => (int) $_POST['labdef'][$ind]);
3969
+			}
3818 3970
 		}
3819 3971
 
3820
-		if (empty($criteria) || (empty($actions) && !$doDelete))
3821
-			fatal_lang_error('pm_rule_no_criteria', false);
3972
+		if (empty($criteria) || (empty($actions) && !$doDelete)) {
3973
+					fatal_lang_error('pm_rule_no_criteria', false);
3974
+		}
3822 3975
 
3823 3976
 		// What are we storing?
3824 3977
 		$criteria = $smcFunc['json_encode']($criteria);
3825 3978
 		$actions = $smcFunc['json_encode']($actions);
3826 3979
 
3827 3980
 		// Create the rule?
3828
-		if (empty($context['rid']))
3829
-			$smcFunc['db_insert']('',
3981
+		if (empty($context['rid'])) {
3982
+					$smcFunc['db_insert']('',
3830 3983
 				'{db_prefix}pm_rules',
3831 3984
 				array(
3832 3985
 					'id_member' => 'int', 'rule_name' => 'string', 'criteria' => 'string', 'actions' => 'string',
@@ -3837,8 +3990,8 @@  discard block
 block discarded – undo
3837 3990
 				),
3838 3991
 				array('id_rule')
3839 3992
 			);
3840
-		else
3841
-			$smcFunc['db_query']('', '
3993
+		} else {
3994
+					$smcFunc['db_query']('', '
3842 3995
 				UPDATE {db_prefix}pm_rules
3843 3996
 				SET rule_name = {string:rule_name}, criteria = {string:criteria}, actions = {string:actions},
3844 3997
 					delete_pm = {int:delete_pm}, is_or = {int:is_or}
@@ -3854,6 +4007,7 @@  discard block
 block discarded – undo
3854 4007
 					'actions' => $actions,
3855 4008
 				)
3856 4009
 			);
4010
+		}
3857 4011
 
3858 4012
 		redirectexit('action=pm;sa=manrules');
3859 4013
 	}
@@ -3862,11 +4016,12 @@  discard block
 block discarded – undo
3862 4016
 	{
3863 4017
 		checkSession();
3864 4018
 		$toDelete = array();
3865
-		foreach ($_POST['delrule'] as $k => $v)
3866
-			$toDelete[] = (int) $k;
4019
+		foreach ($_POST['delrule'] as $k => $v) {
4020
+					$toDelete[] = (int) $k;
4021
+		}
3867 4022
 
3868
-		if (!empty($toDelete))
3869
-			$smcFunc['db_query']('', '
4023
+		if (!empty($toDelete)) {
4024
+					$smcFunc['db_query']('', '
3870 4025
 				DELETE FROM {db_prefix}pm_rules
3871 4026
 				WHERE id_rule IN ({array_int:delete_list})
3872 4027
 					AND id_member = {int:current_member}',
@@ -3875,6 +4030,7 @@  discard block
 block discarded – undo
3875 4030
 					'delete_list' => $toDelete,
3876 4031
 				)
3877 4032
 			);
4033
+		}
3878 4034
 
3879 4035
 		redirectexit('action=pm;sa=manrules');
3880 4036
 	}
@@ -3893,8 +4049,9 @@  discard block
 block discarded – undo
3893 4049
 	loadRules();
3894 4050
 
3895 4051
 	// No rules?
3896
-	if (empty($context['rules']))
3897
-		return;
4052
+	if (empty($context['rules'])) {
4053
+			return;
4054
+	}
3898 4055
 
3899 4056
 	// Just unread ones?
3900 4057
 	$ruleQuery = $all_messages ? '' : ' AND pmr.is_new = 1';
@@ -3924,8 +4081,9 @@  discard block
 block discarded – undo
3924 4081
 			// Loop through all the criteria hoping to make a match.
3925 4082
 			foreach ($rule['criteria'] as $criterium)
3926 4083
 			{
3927
-				if (($criterium['t'] == 'mid' && $criterium['v'] == $row['id_member_from']) || ($criterium['t'] == 'gid' && $criterium['v'] == $row['id_group']) || ($criterium['t'] == 'sub' && strpos($row['subject'], $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($row['body'], $criterium['v']) !== false))
3928
-					$match = true;
4084
+				if (($criterium['t'] == 'mid' && $criterium['v'] == $row['id_member_from']) || ($criterium['t'] == 'gid' && $criterium['v'] == $row['id_group']) || ($criterium['t'] == 'sub' && strpos($row['subject'], $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($row['body'], $criterium['v']) !== false)) {
4085
+									$match = true;
4086
+				}
3929 4087
 				// If we're adding and one criteria don't match then we stop!
3930 4088
 				elseif ($rule['logic'] == 'and')
3931 4089
 				{
@@ -3937,17 +4095,18 @@  discard block
 block discarded – undo
3937 4095
 			// If we have a match the rule must be true - act!
3938 4096
 			if ($match)
3939 4097
 			{
3940
-				if ($rule['delete'])
3941
-					$actions['deletes'][] = $row['id_pm'];
3942
-				else
4098
+				if ($rule['delete']) {
4099
+									$actions['deletes'][] = $row['id_pm'];
4100
+				} else
3943 4101
 				{
3944 4102
 					foreach ($rule['actions'] as $ruleAction)
3945 4103
 					{
3946 4104
 						if ($ruleAction['t'] == 'lab')
3947 4105
 						{
3948 4106
 							// Get a basic pot started!
3949
-							if (!isset($actions['labels'][$row['id_pm']]))
3950
-								$actions['labels'][$row['id_pm']] = array();
4107
+							if (!isset($actions['labels'][$row['id_pm']])) {
4108
+															$actions['labels'][$row['id_pm']] = array();
4109
+							}
3951 4110
 							$actions['labels'][$row['id_pm']][] = $ruleAction['v'];
3952 4111
 						}
3953 4112
 					}
@@ -3958,8 +4117,9 @@  discard block
 block discarded – undo
3958 4117
 	$smcFunc['db_free_result']($request);
3959 4118
 
3960 4119
 	// Deletes are easy!
3961
-	if (!empty($actions['deletes']))
3962
-		deleteMessages($actions['deletes']);
4120
+	if (!empty($actions['deletes'])) {
4121
+			deleteMessages($actions['deletes']);
4122
+	}
3963 4123
 
3964 4124
 	// Relabel?
3965 4125
 	if (!empty($actions['labels']))
@@ -3986,8 +4146,7 @@  discard block
 block discarded – undo
3986 4146
 								'current_member' => $user_info['id'],
3987 4147
 							)
3988 4148
 						);
3989
-					}
3990
-					else
4149
+					} else
3991 4150
 					{
3992 4151
 						$realLabels[] = $label['id'];
3993 4152
 					}
@@ -3996,8 +4155,9 @@  discard block
 block discarded – undo
3996 4155
 
3997 4156
 			$inserts = array();
3998 4157
 			// Now we insert the label info
3999
-			foreach ($realLabels as $a_label)
4000
-				$inserts[] = array($pm, $a_label);
4158
+			foreach ($realLabels as $a_label) {
4159
+							$inserts[] = array($pm, $a_label);
4160
+			}
4001 4161
 
4002 4162
 			$smcFunc['db_insert']('ignore',
4003 4163
 				'{db_prefix}pm_labeled_messages',
@@ -4018,8 +4178,9 @@  discard block
 block discarded – undo
4018 4178
 {
4019 4179
 	global $user_info, $context, $smcFunc;
4020 4180
 
4021
-	if (isset($context['rules']) && !$reload)
4022
-		return;
4181
+	if (isset($context['rules']) && !$reload) {
4182
+			return;
4183
+	}
4023 4184
 
4024 4185
 	$request = $smcFunc['db_query']('', '
4025 4186
 		SELECT
@@ -4043,8 +4204,9 @@  discard block
 block discarded – undo
4043 4204
 			'logic' => $row['is_or'] ? 'or' : 'and',
4044 4205
 		);
4045 4206
 
4046
-		if ($row['delete_pm'])
4047
-			$context['rules'][$row['id_rule']]['actions'][] = array('t' => 'del', 'v' => 1);
4207
+		if ($row['delete_pm']) {
4208
+					$context['rules'][$row['id_rule']]['actions'][] = array('t' => 'del', 'v' => 1);
4209
+		}
4048 4210
 	}
4049 4211
 	$smcFunc['db_free_result']($request);
4050 4212
 }
Please login to merge, or discard this patch.
Sources/Subs-Menu.php 1 patch
Braces   +84 added lines, -63 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Create a menu.
@@ -64,22 +65,26 @@  discard block
 block discarded – undo
64 65
 	$menu_context['current_action'] = isset($menuOptions['action']) ? $menuOptions['action'] : $context['current_action'];
65 66
 
66 67
 	// Allow extend *any* menu with a single hook
67
-	if (!empty($menu_context['current_action']))
68
-		call_integration_hook('integrate_' . $menu_context['current_action'] . '_areas', array(&$menuData));
68
+	if (!empty($menu_context['current_action'])) {
69
+			call_integration_hook('integrate_' . $menu_context['current_action'] . '_areas', array(&$menuData));
70
+	}
69 71
 
70 72
 	// What is the current area selected?
71
-	if (isset($menuOptions['current_area']) || isset($_GET['area']))
72
-		$menu_context['current_area'] = isset($menuOptions['current_area']) ? $menuOptions['current_area'] : $_GET['area'];
73
+	if (isset($menuOptions['current_area']) || isset($_GET['area'])) {
74
+			$menu_context['current_area'] = isset($menuOptions['current_area']) ? $menuOptions['current_area'] : $_GET['area'];
75
+	}
73 76
 
74 77
 	// Build a list of additional parameters that should go in the URL.
75 78
 	$menu_context['extra_parameters'] = '';
76
-	if (!empty($menuOptions['extra_url_parameters']))
77
-		foreach ($menuOptions['extra_url_parameters'] as $key => $value)
79
+	if (!empty($menuOptions['extra_url_parameters'])) {
80
+			foreach ($menuOptions['extra_url_parameters'] as $key => $value)
78 81
 			$menu_context['extra_parameters'] .= ';' . $key . '=' . $value;
82
+	}
79 83
 
80 84
 	// Only include the session ID in the URL if it's strictly necessary.
81
-	if (empty($menuOptions['disable_url_session_check']))
82
-		$menu_context['extra_parameters'] .= ';' . $context['session_var'] . '=' . $context['session_id'];
85
+	if (empty($menuOptions['disable_url_session_check'])) {
86
+			$menu_context['extra_parameters'] .= ';' . $context['session_var'] . '=' . $context['session_id'];
87
+	}
83 88
 
84 89
 	$include_data = array();
85 90
 
@@ -87,8 +92,9 @@  discard block
 block discarded – undo
87 92
 	foreach ($menuData as $section_id => $section)
88 93
 	{
89 94
 		// Is this enabled - or has as permission check - which fails?
90
-		if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($section['permission']) && !allowedTo($section['permission'])))
91
-			continue;
95
+		if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($section['permission']) && !allowedTo($section['permission']))) {
96
+					continue;
97
+		}
92 98
 
93 99
 		// Now we cycle through the sections to pick the right area.
94 100
 		foreach ($section['areas'] as $area_id => $area)
@@ -110,67 +116,67 @@  discard block
 block discarded – undo
110 116
 					if (empty($area['hidden']))
111 117
 					{
112 118
 						// First time this section?
113
-						if (!isset($menu_context['sections'][$section_id]))
114
-							$menu_context['sections'][$section_id]['title'] = $section['title'];
119
+						if (!isset($menu_context['sections'][$section_id])) {
120
+													$menu_context['sections'][$section_id]['title'] = $section['title'];
121
+						}
115 122
 
116 123
 						// Is there a counter amount to show for this section?
117
-						if (!empty($section['amt']))
118
-							$menu_context['sections'][$section_id]['amt'] = $section['amt'];
124
+						if (!empty($section['amt'])) {
125
+													$menu_context['sections'][$section_id]['amt'] = $section['amt'];
126
+						}
119 127
 
120 128
 						$menu_context['sections'][$section_id]['areas'][$area_id] = array('label' => isset($area['label']) ? $area['label'] : $txt[$area_id]);
121 129
 						// We'll need the ID as well...
122 130
 						$menu_context['sections'][$section_id]['id'] = $section_id;
123 131
 						// Does it have a custom URL?
124
-						if (isset($area['custom_url']))
125
-							$menu_context['sections'][$section_id]['areas'][$area_id]['url'] = $area['custom_url'];
132
+						if (isset($area['custom_url'])) {
133
+													$menu_context['sections'][$section_id]['areas'][$area_id]['url'] = $area['custom_url'];
134
+						}
126 135
 
127 136
 						// Is there a counter amount to show for this area?
128
-						if (!empty($area['amt']))
129
-							$menu_context['sections'][$section_id]['areas'][$area_id]['amt'] = $area['amt'];
137
+						if (!empty($area['amt'])) {
138
+													$menu_context['sections'][$section_id]['areas'][$area_id]['amt'] = $area['amt'];
139
+						}
130 140
 
131 141
 						// Does this area have its own icon?
132 142
 						if (!isset($area['force_menu_into_arms_of_another_menu']) && $user_info['name'] == 'iamanoompaloompa')
133 143
 						{
134 144
 							$menu_context['sections'][$section_id]['areas'][$area_id] = $smcFunc['json_decode'](base64_decode('eyJsYWJlbCI6Ik9vbXBhIExvb21wYSIsInVybCI6Imh0dHBzOlwvXC9lbi53aWtpcGVkaWEub3JnXC93aWtpXC9Pb21wYV9Mb29tcGFzPyIsImljb24iOiI8aW1nIHNyYz1cImh0dHBzOlwvXC93d3cuc2ltcGxlbWFjaGluZXMub3JnXC9pbWFnZXNcL29vbXBhLmdpZlwiIGFsdD1cIkknbSBhbiBPb21wYSBMb29tcGFcIiBcLz4ifQ=='), true);
135
-						}
136
-						elseif (isset($area['icon']))
145
+						} elseif (isset($area['icon']))
137 146
 						{
138 147
 							if (file_exists($settings['theme_dir'] . '/images/admin/' . $area['icon']))
139 148
 							{
140 149
 								$menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<img src="' . $settings['images_url'] . '/admin/' . $area['icon'] . '" alt="">';
141
-							}
142
-							elseif (file_exists($settings['default_theme_dir'] . '/images/admin/' . $area['icon']))
150
+							} elseif (file_exists($settings['default_theme_dir'] . '/images/admin/' . $area['icon']))
143 151
 							{
144 152
 								$menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<img src="' . $settings['default_images_url'] . '/admin/' . $area['icon'] . '" alt="">';
153
+							} else {
154
+															$menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area['icon'] . '"></span>';
145 155
 							}
146
-							else
147
-								$menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area['icon'] . '"></span>';
156
+						} else {
157
+													$menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area_id . '"></span>';
148 158
 						}
149
-						else
150
-							$menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area_id . '"></span>';
151 159
 
152 160
 						if (isset($area['icon_class']) && empty($menu_context['sections'][$section_id]['areas'][$area_id]['icon']))
153 161
 						{
154 162
 							$menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . $area['icon_class'];
155
-						}
156
-						elseif (isset($area['icon']))
163
+						} elseif (isset($area['icon']))
157 164
 						{
158 165
 							if (substr($area['icon'], -4) === '.png' || substr($area['icon'], -4) === '.gif')
159 166
 							{
160 167
 								if (file_exists($settings['theme_dir'] . '/images/admin/big/' . $area['icon']))
161 168
 								{
162 169
 									$menu_context['sections'][$section_id]['areas'][$area_id]['icon_file'] = $settings['theme_url'] . '/images/admin/big/' . $area['icon'];
163
-								}
164
-								elseif (file_exists($settings['default_theme_dir'] . '/images/admin/big/' . $area['icon']))
170
+								} elseif (file_exists($settings['default_theme_dir'] . '/images/admin/big/' . $area['icon']))
165 171
 								{
166 172
 									$menu_context['sections'][$section_id]['areas'][$area_id]['icon_file'] = $settings['default_theme_url'] . '/images/admin/big/' . $area['icon'];
167 173
 								}
168 174
 							}
169 175
 
170 176
 							$menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . str_replace(array('.png', '.gif'), '', $area['icon']);
177
+						} else {
178
+													$menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . str_replace(array('.png', '.gif'), '', $area_id);
171 179
 						}
172
-						else
173
-							$menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . str_replace(array('.png', '.gif'), '', $area_id);
174 180
 
175 181
 						// This is a shortcut for Font-Icon users so they don't have to re-do whole CSS.
176 182
 						$menu_context['sections'][$section_id]['areas'][$area_id]['plain_class'] = !empty($area['icon']) ? $area['icon'] : '';
@@ -187,39 +193,46 @@  discard block
 block discarded – undo
187 193
 							{
188 194
 								if ((empty($sub[1]) || allowedTo($sub[1])) && (!isset($sub['enabled']) || !empty($sub['enabled'])))
189 195
 								{
190
-									if ($first_sa == null)
191
-										$first_sa = $sa;
196
+									if ($first_sa == null) {
197
+																			$first_sa = $sa;
198
+									}
192 199
 
193 200
 									$menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa] = array('label' => $sub[0]);
194 201
 									// Custom URL?
195
-									if (isset($sub['url']))
196
-										$menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['url'] = $sub['url'];
202
+									if (isset($sub['url'])) {
203
+																			$menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['url'] = $sub['url'];
204
+									}
197 205
 
198 206
 									// Is there a counter amount to show for this subsection?
199
-									if (!empty($sub['amt']))
200
-										$menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['amt'] = $sub['amt'];
207
+									if (!empty($sub['amt'])) {
208
+																			$menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['amt'] = $sub['amt'];
209
+									}
201 210
 
202 211
 									// A bit complicated - but is this set?
203 212
 									if ($menu_context['current_area'] == $area_id)
204 213
 									{
205 214
 										// Save which is the first...
206
-										if (empty($first_sa))
207
-											$first_sa = $sa;
215
+										if (empty($first_sa)) {
216
+																					$first_sa = $sa;
217
+										}
208 218
 
209 219
 										// Is this the current subsection?
210
-										if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == $sa)
211
-											$menu_context['current_subsection'] = $sa;
220
+										if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == $sa) {
221
+																					$menu_context['current_subsection'] = $sa;
222
+										}
212 223
 										// Otherwise is it the default?
213
-										elseif (!isset($menu_context['current_subsection']) && !empty($sub[2]))
214
-											$menu_context['current_subsection'] = $sa;
224
+										elseif (!isset($menu_context['current_subsection']) && !empty($sub[2])) {
225
+																					$menu_context['current_subsection'] = $sa;
226
+										}
215 227
 									}
216 228
 
217 229
 									// Let's assume this is the last, for now.
218 230
 									$last_sa = $sa;
219 231
 								}
220 232
 								// Mark it as disabled...
221
-								else
222
-									$menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['disabled'] = true;
233
+								else {
234
+																	$menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['disabled'] = true;
235
+								}
223 236
 							}
224 237
 
225 238
 							// Set which one is first, last and selected in the group.
@@ -228,8 +241,9 @@  discard block
 block discarded – undo
228 241
 								$menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$context['right_to_left'] ? $last_sa : $first_sa]['is_first'] = true;
229 242
 								$menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$context['right_to_left'] ? $first_sa : $last_sa]['is_last'] = true;
230 243
 
231
-								if ($menu_context['current_area'] == $area_id && !isset($menu_context['current_subsection']))
232
-									$menu_context['current_subsection'] = $first_sa;
244
+								if ($menu_context['current_area'] == $area_id && !isset($menu_context['current_subsection'])) {
245
+																	$menu_context['current_subsection'] = $first_sa;
246
+								}
233 247
 							}
234 248
 						}
235 249
 					}
@@ -263,23 +277,26 @@  discard block
 block discarded – undo
263 277
 	$menu_context['base_url'] = isset($menuOptions['base_url']) ? $menuOptions['base_url'] : $scripturl . '?action=' . $menu_context['current_action'];
264 278
 
265 279
 	// If we didn't find the area we were looking for go to a default one.
266
-	if (isset($backup_area) && empty($found_section))
267
-		$menu_context['current_area'] = $backup_area;
280
+	if (isset($backup_area) && empty($found_section)) {
281
+			$menu_context['current_area'] = $backup_area;
282
+	}
268 283
 
269 284
 	// If there are sections quickly goes through all the sections to check if the base menu has an url
270 285
 	if (!empty($menu_context['current_section']))
271 286
 	{
272 287
 		$menu_context['sections'][$menu_context['current_section']]['selected'] = true;
273 288
 		$menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['selected'] = true;
274
-		if (!empty($menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']]))
275
-			$menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']]['selected'] = true;
289
+		if (!empty($menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']])) {
290
+					$menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']]['selected'] = true;
291
+		}
276 292
 
277
-		foreach ($menu_context['sections'] as $section_id => $section)
278
-			foreach ($section['areas'] as $area_id => $area)
293
+		foreach ($menu_context['sections'] as $section_id => $section) {
294
+					foreach ($section['areas'] as $area_id => $area)
279 295
 			{
280 296
 				if (!isset($menu_context['sections'][$section_id]['url']))
281 297
 				{
282 298
 					$menu_context['sections'][$section_id]['url'] = isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $area_id;
299
+		}
283 300
 					break;
284 301
 				}
285 302
 			}
@@ -290,8 +307,9 @@  discard block
 block discarded – undo
290 307
 	{
291 308
 		// Never happened!
292 309
 		$context['max_menu_id']--;
293
-		if ($context['max_menu_id'] == 0)
294
-			unset($context['max_menu_id']);
310
+		if ($context['max_menu_id'] == 0) {
311
+					unset($context['max_menu_id']);
312
+		}
295 313
 
296 314
 		return false;
297 315
 	}
@@ -302,8 +320,9 @@  discard block
 block discarded – undo
302 320
 	$context['template_layers'][] = $menu_context['layer_name'];
303 321
 
304 322
 	// Check we had something - for sanity sake.
305
-	if (empty($include_data))
306
-		return false;
323
+	if (empty($include_data)) {
324
+			return false;
325
+	}
307 326
 
308 327
 	// Finally - return information on the selected item.
309 328
 	$include_data += array(
@@ -326,12 +345,14 @@  discard block
 block discarded – undo
326 345
 	global $context;
327 346
 
328 347
 	$menu_name = $menu_id == 'last' && isset($context['max_menu_id']) && isset($context['menu_data_' . $context['max_menu_id']]) ? 'menu_data_' . $context['max_menu_id'] : 'menu_data_' . $menu_id;
329
-	if (!isset($context[$menu_name]))
330
-		return false;
348
+	if (!isset($context[$menu_name])) {
349
+			return false;
350
+	}
331 351
 
332 352
 	$layer_index = array_search($context[$menu_name]['layer_name'], $context['template_layers']);
333
-	if ($layer_index !== false)
334
-		unset($context['template_layers'][$layer_index]);
353
+	if ($layer_index !== false) {
354
+			unset($context['template_layers'][$layer_index]);
355
+	}
335 356
 
336 357
 	unset($context[$menu_name]);
337 358
 }
Please login to merge, or discard this patch.
Themes/default/GenericMenu.template.php 1 patch
Braces   +54 added lines, -39 removed lines patch added patch discarded remove patch
@@ -83,16 +83,18 @@  discard block
 block discarded – undo
83 83
 		foreach ($section['areas'] as $i => $area)
84 84
 		{
85 85
 			// Not supposed to be printed?
86
-			if (empty($area['label']))
87
-				continue;
86
+			if (empty($area['label'])) {
87
+							continue;
88
+			}
88 89
 
89 90
 			echo '
90 91
 								<li', !empty($area['subsections']) ? ' class="subsections"' : '', '>
91 92
 									<a class="', $area['icon_class'], !empty($area['selected']) ? ' chosen ' : '', '" href="', (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i), $menu_context['extra_parameters'], '">', $area['icon'], $area['label'], !empty($area['amt']) ? ' <span class="amt">' . $area['amt'] . '</span>' : '', '</a>';
92 93
 
93 94
 			// Is this the current area, or just some area?
94
-			if (!empty($area['selected']) && empty($context['tabs']))
95
-					$context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array();
95
+			if (!empty($area['selected']) && empty($context['tabs'])) {
96
+								$context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array();
97
+			}
96 98
 
97 99
 			// Are there any subsections?
98 100
 			if (!empty($area['subsections']))
@@ -102,8 +104,9 @@  discard block
 block discarded – undo
102 104
 
103 105
 				foreach ($area['subsections'] as $sa => $sub)
104 106
 				{
105
-					if (!empty($sub['disabled']))
106
-						continue;
107
+					if (!empty($sub['disabled'])) {
108
+											continue;
109
+					}
107 110
 
108 111
 					$url = isset($sub['url']) ? $sub['url'] : (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i) . ';sa=' . $sa;
109 112
 
@@ -150,8 +153,9 @@  discard block
 block discarded – undo
150 153
 							<h3 class="catbg">';
151 154
 
152 155
 		// The function is in Admin.template.php, but since this template is used elsewhere too better check if the function is available
153
-		if (function_exists('template_admin_quick_search'))
154
-			template_admin_quick_search();
156
+		if (function_exists('template_admin_quick_search')) {
157
+					template_admin_quick_search();
158
+		}
155 159
 
156 160
 		// Exactly how many tabs do we have?
157 161
 		if (!empty($context['tabs']))
@@ -166,30 +170,36 @@  discard block
 block discarded – undo
166 170
 				}
167 171
 
168 172
 				// Did this not even exist - or do we not have a label?
169
-				if (!isset($tab_context['tabs'][$id]))
170
-					$tab_context['tabs'][$id] = array('label' => $tab['label']);
171
-				elseif (!isset($tab_context['tabs'][$id]['label']))
172
-					$tab_context['tabs'][$id]['label'] = $tab['label'];
173
+				if (!isset($tab_context['tabs'][$id])) {
174
+									$tab_context['tabs'][$id] = array('label' => $tab['label']);
175
+				} elseif (!isset($tab_context['tabs'][$id]['label'])) {
176
+									$tab_context['tabs'][$id]['label'] = $tab['label'];
177
+				}
173 178
 
174 179
 				// Has a custom URL defined in the main admin structure?
175
-				if (isset($tab['url']) && !isset($tab_context['tabs'][$id]['url']))
176
-					$tab_context['tabs'][$id]['url'] = $tab['url'];
180
+				if (isset($tab['url']) && !isset($tab_context['tabs'][$id]['url'])) {
181
+									$tab_context['tabs'][$id]['url'] = $tab['url'];
182
+				}
177 183
 
178 184
 				// Any additional paramaters for the url?
179
-				if (isset($tab['add_params']) && !isset($tab_context['tabs'][$id]['add_params']))
180
-					$tab_context['tabs'][$id]['add_params'] = $tab['add_params'];
185
+				if (isset($tab['add_params']) && !isset($tab_context['tabs'][$id]['add_params'])) {
186
+									$tab_context['tabs'][$id]['add_params'] = $tab['add_params'];
187
+				}
181 188
 
182 189
 				// Has it been deemed selected?
183
-				if (!empty($tab['is_selected']))
184
-					$tab_context['tabs'][$id]['is_selected'] = true;
190
+				if (!empty($tab['is_selected'])) {
191
+									$tab_context['tabs'][$id]['is_selected'] = true;
192
+				}
185 193
 
186 194
 				// Does it have its own help?
187
-				if (!empty($tab['help']))
188
-					$tab_context['tabs'][$id]['help'] = $tab['help'];
195
+				if (!empty($tab['help'])) {
196
+									$tab_context['tabs'][$id]['help'] = $tab['help'];
197
+				}
189 198
 
190 199
 				// Is this the last one?
191
-				if (!empty($tab['is_last']) && !isset($tab_context['override_last']))
192
-					$tab_context['tabs'][$id]['is_last'] = true;
200
+				if (!empty($tab['is_last']) && !isset($tab_context['override_last'])) {
201
+									$tab_context['tabs'][$id]['is_last'] = true;
202
+				}
193 203
 			}
194 204
 
195 205
 			// Find the selected tab
@@ -206,22 +216,24 @@  discard block
 block discarded – undo
206 216
 		// Show an icon and/or a help item?
207 217
 		if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class']) || !empty($selected_tab['icon']) || !empty($tab_context['icon']) || !empty($selected_tab['help']) || !empty($tab_context['help']))
208 218
 		{
209
-			if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class']))
210
-				echo '
219
+			if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class'])) {
220
+							echo '
211 221
 								<span class="', !empty($selected_tab['icon_class']) ? $selected_tab['icon_class'] : $tab_context['icon_class'], ' icon"></span>';
212
-			elseif (!empty($selected_tab['icon']) || !empty($tab_context['icon']))
213
-				echo '
222
+			} elseif (!empty($selected_tab['icon']) || !empty($tab_context['icon'])) {
223
+							echo '
214 224
 								<img src="', $settings['images_url'], '/icons/', !empty($selected_tab['icon']) ? $selected_tab['icon'] : $tab_context['icon'], '" alt="" class="icon">';
225
+			}
215 226
 
216
-			if (!empty($selected_tab['help']) || !empty($tab_context['help']))
217
-				echo '
227
+			if (!empty($selected_tab['help']) || !empty($tab_context['help'])) {
228
+							echo '
218 229
 								<a href="', $scripturl, '?action=helpadmin;help=', !empty($selected_tab['help']) ? $selected_tab['help'] : $tab_context['help'], '" onclick="return reqOverlayDiv(this.href);" class="help"><span class="generic_icons help" title="', $txt['help'], '"></span></a>';
230
+			}
219 231
 
220 232
 			echo $tab_context['title'];
221
-		}
222
-		else
223
-			echo '
233
+		} else {
234
+					echo '
224 235
 								', $tab_context['title'];
236
+		}
225 237
 
226 238
 		echo '
227 239
 							</h3>', (function_exists('template_admin_quick_search') ? '
@@ -230,11 +242,12 @@  discard block
 block discarded – undo
230 242
 	}
231 243
 
232 244
 	// Shall we use the tabs? Yes, it's the only known way!
233
-	if (!empty($selected_tab['description']) || !empty($tab_context['description']))
234
-		echo '
245
+	if (!empty($selected_tab['description']) || !empty($tab_context['description'])) {
246
+			echo '
235 247
 					<p class="information">
236 248
 						', !empty($selected_tab['description']) ? $selected_tab['description'] : $tab_context['description'], '
237 249
 					</p>';
250
+	}
238 251
 
239 252
 	// Print out all the items in this tab (if any).
240 253
 	if (!empty($context['tabs']))
@@ -246,19 +259,21 @@  discard block
 block discarded – undo
246 259
 
247 260
 		foreach ($tab_context['tabs'] as $sa => $tab)
248 261
 		{
249
-			if (!empty($tab['disabled']))
250
-				continue;
262
+			if (!empty($tab['disabled'])) {
263
+							continue;
264
+			}
251 265
 
252
-			if (!empty($tab['is_selected']))
253
-				echo '
266
+			if (!empty($tab['is_selected'])) {
267
+							echo '
254 268
 							<li>
255 269
 								<a class="active" href="', isset($tab['url']) ? $tab['url'] : $menu_context['base_url'] . ';area=' . $menu_context['current_area'] . ';sa=' . $sa, $menu_context['extra_parameters'], isset($tab['add_params']) ? $tab['add_params'] : '', '">', $tab['label'], '</a>
256 270
 							</li>';
257
-			else
258
-				echo '
271
+			} else {
272
+							echo '
259 273
 							<li>
260 274
 								<a href="', isset($tab['url']) ? $tab['url'] : $menu_context['base_url'] . ';area=' . $menu_context['current_area'] . ';sa=' . $sa, $menu_context['extra_parameters'], isset($tab['add_params']) ? $tab['add_params'] : '', '">', $tab['label'], '</a>
261 275
 							</li>';
276
+			}
262 277
 		}
263 278
 
264 279
 		// The end of tabs
Please login to merge, or discard this patch.