Completed
Pull Request — release-2.1 (#5028)
by 01
06:01
created
Themes/default/ManageSmileys.template.php 1 patch
Braces   +58 added lines, -44 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">
@@ -54,20 +55,20 @@  discard block
 block discarded – undo
54 55
 				</dt>
55 56
 				<dd>
56 57
 					', $modSettings['smileys_url'], '/';
57
-	if ($context['current_set']['id'] == 'default')
58
-		echo '<strong>default</strong><input type="hidden" name="smiley_sets_path" id="smiley_sets_path" value="default">';
59
-
60
-	elseif (empty($context['smiley_set_dirs']))
61
-		echo '
58
+	if ($context['current_set']['id'] == 'default') {
59
+			echo '<strong>default</strong><input type="hidden" name="smiley_sets_path" id="smiley_sets_path" value="default">';
60
+	} elseif (empty($context['smiley_set_dirs'])) {
61
+			echo '
62 62
 					<input type="text" name="smiley_sets_path" id="smiley_sets_path" value="', $context['current_set']['path'], '"> ';
63
-	else
63
+	} else
64 64
 	{
65 65
 		echo '
66 66
 					<select name="smiley_sets_path" id="smiley_sets_path">';
67 67
 
68
-		foreach ($context['smiley_set_dirs'] as $smiley_set_dir)
69
-			echo '
68
+		foreach ($context['smiley_set_dirs'] as $smiley_set_dir) {
69
+					echo '
70 70
 						<option value="', $smiley_set_dir['id'], '"', $smiley_set_dir['current'] ? ' selected' : '', $smiley_set_dir['selectable'] ? '' : ' disabled', '>', $smiley_set_dir['id'], '</option>';
71
+		}
71 72
 		echo '
72 73
 					</select> ';
73 74
 	}
@@ -82,14 +83,15 @@  discard block
 block discarded – undo
82 83
 				</dd>';
83 84
 
84 85
 	// If this is a new smiley set they have the option to import smileys already in the directory.
85
-	if ($context['current_set']['is_new'] && !empty($modSettings['smiley_enable']))
86
-		echo '
86
+	if ($context['current_set']['is_new'] && !empty($modSettings['smiley_enable'])) {
87
+			echo '
87 88
 				<dt>
88 89
 					<strong><label for="smiley_sets_import">', $txt['smiley_set_import_directory'], '</label>: </strong>
89 90
 				</dt>
90 91
 				<dd>
91 92
 					<input type="checkbox" name="smiley_sets_import" id="smiley_sets_import" value="1">
92 93
 				</dd>';
94
+	}
93 95
 
94 96
 	echo '
95 97
 			</dl>
@@ -121,9 +123,10 @@  discard block
 block discarded – undo
121 123
 				<dd>
122 124
 					<img src="', $modSettings['smileys_url'], '/', $modSettings['smiley_sets_default'], '/', $context['current_smiley']['filename'], '" id="preview" alt=""> ', $txt['smiley_preview_using'], ': <select name="set" onchange="updatePreview();">';
123 125
 
124
-	foreach ($context['smiley_sets'] as $smiley_set)
125
-		echo '
126
+	foreach ($context['smiley_sets'] as $smiley_set) {
127
+			echo '
126 128
 					<option value="', $smiley_set['path'], '"', $context['selected_set'] == $smiley_set['path'] ? ' selected' : '', '>', $smiley_set['name'], '</option>';
129
+	}
127 130
 
128 131
 	echo '
129 132
 					</select>
@@ -139,17 +142,18 @@  discard block
 block discarded – undo
139 142
 				</dt>
140 143
 				<dd>';
141 144
 
142
-	if (empty($context['filenames']))
143
-		echo '
145
+	if (empty($context['filenames'])) {
146
+			echo '
144 147
 					<input type="text" name="smiley_filename" id="smiley_filename" value="', $context['current_smiley']['filename'], '">';
145
-	else
148
+	} else
146 149
 	{
147 150
 		echo '
148 151
 					<select name="smiley_filename" id="smiley_filename" onchange="updatePreview();">';
149 152
 
150
-		foreach ($context['filenames'] as $filename)
151
-			echo '
153
+		foreach ($context['filenames'] as $filename) {
154
+					echo '
152 155
 						<option value="', $filename['id'], '"', $filename['selected'] ? ' selected' : '', '>', $filename['id'], '</option>';
156
+		}
153 157
 		echo '
154 158
 					</select>';
155 159
 	}
@@ -216,9 +220,10 @@  discard block
 block discarded – undo
216 220
 					<dd>
217 221
 						', $txt['smiley_preview_using'], ': <select name="set" onchange="updatePreview();selectMethod(\'existing\');">';
218 222
 
219
-	foreach ($context['smiley_sets'] as $smiley_set)
220
-		echo '
223
+	foreach ($context['smiley_sets'] as $smiley_set) {
224
+			echo '
221 225
 							<option value="', $smiley_set['path'], '"', $context['selected_set'] == $smiley_set['path'] ? ' selected' : '', '>', $smiley_set['name'], '</option>';
226
+	}
222 227
 
223 228
 	echo '
224 229
 						</select>
@@ -228,17 +233,18 @@  discard block
 block discarded – undo
228 233
 					</dt>
229 234
 					<dd>';
230 235
 
231
-	if (empty($context['filenames']))
232
-		echo '
236
+	if (empty($context['filenames'])) {
237
+			echo '
233 238
 						<input type="text" name="smiley_filename" id="smiley_filename" value="', $context['current_smiley']['filename'], '" onchange="selectMethod(\'existing\');">';
234
-	else
239
+	} else
235 240
 	{
236 241
 		echo '
237 242
 						<select name="smiley_filename" id="smiley_filename" onchange="updatePreview();selectMethod(\'existing\');">';
238 243
 
239
-		foreach ($context['filenames'] as $filename)
240
-			echo '
244
+		foreach ($context['filenames'] as $filename) {
245
+					echo '
241 246
 							<option value="', $filename['id'], '"', $filename['selected'] ? ' selected' : '', '>', $filename['id'], '</option>';
247
+		}
242 248
 		echo '
243 249
 						</select>';
244 250
 	}
@@ -267,14 +273,15 @@  discard block
 block discarded – undo
267 273
 
268 274
 			<dl id="uploadMore" style="display: none;" class="settings">';
269 275
 
270
-	foreach ($context['smiley_sets'] as $smiley_set)
271
-		echo '
276
+	foreach ($context['smiley_sets'] as $smiley_set) {
277
+			echo '
272 278
 				<dt>
273 279
 					', sprintf($txt['smileys_add_upload_for'], '<strong>' . $smiley_set['name'] . '</strong>'), ':
274 280
 				</dt>
275 281
 				<dd>
276 282
 					<input type="file" name="individual_', $smiley_set['name'], '" onchange="selectMethod(\'upload\');">
277 283
 				</dd>';
284
+	}
278 285
 
279 286
 	echo '
280 287
 			</dl>
@@ -341,27 +348,30 @@  discard block
 block discarded – undo
341 348
 
342 349
 		foreach ($location['rows'] as $row)
343 350
 		{
344
-			if (!empty($context['move_smiley']))
345
-				echo '
351
+			if (!empty($context['move_smiley'])) {
352
+							echo '
346 353
 			<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>';
354
+			}
347 355
 
348 356
 			foreach ($row as $smiley)
349 357
 			{
350
-				if (empty($context['move_smiley']))
351
-					echo '
358
+				if (empty($context['move_smiley'])) {
359
+									echo '
352 360
 			<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>';
353
-				else
354
-					echo '
361
+				} else {
362
+									echo '
355 363
 			<img src="', $modSettings['smileys_url'], '/', $modSettings['smiley_sets_default'], '/', $smiley['filename'], '" alt="', $smiley['description'], '" ', $smiley['selected'] ? 'class="selected_item"' : '', '>
356 364
 			<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>';
365
+				}
357 366
 			}
358 367
 
359 368
 			echo '
360 369
 			<br>';
361 370
 		}
362
-		if (!empty($context['move_smiley']))
363
-			echo '
371
+		if (!empty($context['move_smiley'])) {
372
+					echo '
364 373
 			<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>';
374
+		}
365 375
 		echo '
366 376
 		</div><!-- .windowbg -->
367 377
 		<input type="hidden" name="reorder" value="1">
@@ -394,14 +404,15 @@  discard block
 block discarded – undo
394 404
 		<div class="windowbg">
395 405
 			<dl class="settings">';
396 406
 
397
-	if (!$context['new_icon'])
398
-		echo '
407
+	if (!$context['new_icon']) {
408
+			echo '
399 409
 				<dt>
400 410
 					<strong>', $txt['smiley_preview'], ': </strong>
401 411
 				</dt>
402 412
 				<dd>
403 413
 					<img src="', $context['icon']['image_url'], '" alt="', $context['icon']['title'], '">
404 414
 				</dd>';
415
+	}
405 416
 
406 417
 	echo '
407 418
 				<dt>
@@ -428,9 +439,10 @@  discard block
 block discarded – undo
428 439
 		echo '
429 440
 						<optgroup label="', $category['name'], '">';
430 441
 
431
-		foreach ($category['boards'] as $board)
432
-			echo '
442
+		foreach ($category['boards'] as $board) {
443
+					echo '
433 444
 							<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=&gt;' : '', ' ', $board['name'], '</option>';
445
+		}
434 446
 
435 447
 		echo '
436 448
 						</optgroup>';
@@ -447,19 +459,21 @@  discard block
 block discarded – undo
447 459
 						<option value="0"', empty($context['icon']['after']) ? ' selected' : '', '>', $txt['icons_location_first_icon'], '</option>';
448 460
 
449 461
 	// Print the list of all the icons it can be put after...
450
-	foreach ($context['icons'] as $id => $data)
451
-		if (empty($context['icon']['id']) || $id != $context['icon']['id'])
462
+	foreach ($context['icons'] as $id => $data) {
463
+			if (empty($context['icon']['id']) || $id != $context['icon']['id'])
452 464
 			echo '
453 465
 						<option value="', $id, '"', !empty($context['icon']['after']) && $id == $context['icon']['after'] ? ' selected' : '', '>', $txt['icons_location_after'], ': ', $data['title'], '</option>';
466
+	}
454 467
 
455 468
 	echo '
456 469
 					</select>
457 470
 				</dd>
458 471
 			</dl>';
459 472
 
460
-	if (!$context['new_icon'])
461
-		echo '
473
+	if (!$context['new_icon']) {
474
+			echo '
462 475
 			<input type="hidden" name="icon" value="', $context['icon']['id'], '">';
476
+	}
463 477
 
464 478
 	echo '
465 479
 			<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/Post.template.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -401,8 +401,8 @@  discard block
 block discarded – undo
401 401
 										<div class="bar"></div>
402 402
 									</div>
403 403
 									<div class="attach-ui">
404
-										<a data-dz-remove class="button cancel">', $txt['modify_cancel'] ,'</a>
405
-										<a class="button upload">', $txt['upload'] ,'</a>
404
+										<a data-dz-remove class="button cancel">', $txt['modify_cancel'], '</a>
405
+										<a class="button upload">', $txt['upload'], '</a>
406 406
 									</div>
407 407
 								</div><!-- .attach-info -->
408 408
 							</div><!-- #au-template -->
@@ -419,10 +419,10 @@  discard block
 block discarded – undo
419 419
 							</dt>
420 420
 							<dd class="smalltext fallback">
421 421
 								<div id="attachUpload" class="descbox">
422
-									<h5>', $txt['attach_drop_zone'] ,'</h5>
423
-									<a class="button" id="attach-cancelAll">', $txt['attached_cancelAll'] ,'</a>
424
-									<a class="button" id="attach-uploadAll">', $txt['attached_uploadAll'] ,'</a>
425
-									<a class="button fileinput-button">', $txt['attach_add'] ,'</a>
422
+									<h5>', $txt['attach_drop_zone'], '</h5>
423
+									<a class="button" id="attach-cancelAll">', $txt['attached_cancelAll'], '</a>
424
+									<a class="button" id="attach-uploadAll">', $txt['attached_uploadAll'], '</a>
425
+									<a class="button fileinput-button">', $txt['attach_add'], '</a>
426 426
 									<div id="total-progress" class="progress_bar" role="progressBar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0">
427 427
 										<div class="bar"></div>
428 428
 									</div>
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
 	// Option to delete an event if user is editing one.
533 533
 	if ($context['make_event'] && !$context['event']['new'])
534 534
 		echo '
535
-						<input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['event_delete_confirm'] ,'" class="button you_sure">';
535
+						<input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['event_delete_confirm'], '" class="button you_sure">';
536 536
 
537 537
 	echo '
538 538
 					</span>
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
 
575 575
 	$newPostsHTML .= '
576 576
 			<br class="clear">
577
-			<div id="msg_%PostID%_ignored_prompt" class="smalltext" style="display: none;">' . $txt['ignoring_user'] .  '<a href="#" id="msg_%PostID%_ignored_link" style="%IgnoredStyle%">' . $txt['show_ignore_user_post'] . '</a></div>
577
+			<div id="msg_%PostID%_ignored_prompt" class="smalltext" style="display: none;">' . $txt['ignoring_user'] . '<a href="#" id="msg_%PostID%_ignored_link" style="%IgnoredStyle%">' . $txt['show_ignore_user_post'] . '</a></div>
578 578
 			<div class="list_posts smalltext" id="msg_%PostID%_body">%PostBody%</div>
579 579
 		</div>';
580 580
 
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
 			});';
661 661
 
662 662
 	echo '
663
-			var oEditorID = "', $context['post_box_name'] ,'";
663
+			var oEditorID = "', $context['post_box_name'], '";
664 664
 			var oEditorObject = oEditorHandle_', $context['post_box_name'], ';
665 665
 		</script>';
666 666
 
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
 			if ($context['can_quote'])
693 693
 				echo '
694 694
 					<ul class="quickbuttons" id="msg_', $post['id'], '_quote">
695
-						<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>
695
+						<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 696
 						<li id="post_modify"><a href="#postmodify" onclick="return insertQuoteFast(', $post['id'], ');"><span class="generic_icons quote"></span>', $txt['quote'], '</a></li>
697 697
 					</ul>';
698 698
 
@@ -777,7 +777,7 @@  discard block
 block discarded – undo
777 777
 	<head>
778 778
 		<meta charset="', $context['character_set'], '">
779 779
 		<title>', $txt['spell_check'], '</title>
780
-		<link rel="stylesheet" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css', $modSettings['browser_cache'] ,'">
780
+		<link rel="stylesheet" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css', $modSettings['browser_cache'], '">
781 781
 		<style>
782 782
 			body, td {
783 783
 				font-size: small;
@@ -807,8 +807,8 @@  discard block
 block discarded – undo
807 807
 			var spell_formname = window.opener.spell_formname;
808 808
 			var spell_fieldname = window.opener.spell_fieldname;
809 809
 		</script>
810
-		<script src="', $settings['default_theme_url'], '/scripts/spellcheck.js', $modSettings['browser_cache'] ,'"></script>
811
-		<script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'] ,'"></script>
810
+		<script src="', $settings['default_theme_url'], '/scripts/spellcheck.js', $modSettings['browser_cache'], '"></script>
811
+		<script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'], '"></script>
812 812
 		<script>
813 813
 			', $context['spell_js'], '
814 814
 		</script>
@@ -852,7 +852,7 @@  discard block
 block discarded – undo
852 852
 	<head>
853 853
 		<meta charset="', $context['character_set'], '">
854 854
 		<title>', $txt['retrieving_quote'], '</title>
855
-		<script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'] ,'"></script>
855
+		<script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'], '"></script>
856 856
 	</head>
857 857
 	<body>
858 858
 		', $txt['retrieving_quote'], '
Please login to merge, or discard this 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 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1744,9 +1744,9 @@
 block discarded – undo
1744 1744
 			$context['theme_files'] = get_file_listing($currentTheme['theme_dir'], '');
1745 1745
 		
1746 1746
 		// Do not list minified_ files
1747
-		foreach($context['theme_files'] as $key=>$file)
1747
+		foreach ($context['theme_files'] as $key=>$file)
1748 1748
 		{
1749
-			if(strpos($file['filename'], 'minified_') !== FALSE)
1749
+			if (strpos($file['filename'], 'minified_') !== FALSE)
1750 1750
 				unset($context['theme_files'][$key]);
1751 1751
 		}
1752 1752
 
Please login to merge, or discard this 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.
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.
Sources/Subs-Editor.php 1 patch
Braces   +403 added lines, -303 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
  * !!!Compatibility!!!
@@ -31,8 +32,9 @@  discard block
 block discarded – undo
31 32
 {
32 33
 	global $modSettings;
33 34
 
34
-	if (!$compat_mode)
35
-		return $text;
35
+	if (!$compat_mode) {
36
+			return $text;
37
+	}
36 38
 
37 39
 	// Turn line breaks back into br's.
38 40
 	$text = strtr($text, array("\r" => '', "\n" => '<br>'));
@@ -49,8 +51,9 @@  discard block
 block discarded – undo
49 51
 			for ($i = 0, $n = count($parts); $i < $n; $i++)
50 52
 			{
51 53
 				// Value of 2 means we're inside the tag.
52
-				if ($i % 4 == 2)
53
-					$parts[$i] = strtr($parts[$i], array('[' => '&#91;', ']' => '&#93;', "'" => "'"));
54
+				if ($i % 4 == 2) {
55
+									$parts[$i] = strtr($parts[$i], array('[' => '&#91;', ']' => '&#93;', "'" => "'"));
56
+				}
54 57
 			}
55 58
 			// Put our humpty dumpty message back together again.
56 59
 			$text = implode('', $parts);
@@ -109,8 +112,9 @@  discard block
 block discarded – undo
109 112
 	$text = preg_replace('~</p>\s*(?!<)~i', '</p><br>', $text);
110 113
 
111 114
 	// Safari/webkit wraps lines in Wysiwyg in <div>'s.
112
-	if (isBrowser('webkit'))
113
-		$text = preg_replace(array('~<div(?:\s(?:[^<>]*?))?' . '>~i', '</div>'), array('<br>', ''), $text);
115
+	if (isBrowser('webkit')) {
116
+			$text = preg_replace(array('~<div(?:\s(?:[^<>]*?))?' . '>~i', '</div>'), array('<br>', ''), $text);
117
+	}
114 118
 
115 119
 	// If there's a trailing break get rid of it - Firefox tends to add one.
116 120
 	$text = preg_replace('~<br\s?/?' . '>$~i', '', $text);
@@ -125,8 +129,9 @@  discard block
 block discarded – undo
125 129
 		for ($i = 0, $n = count($parts); $i < $n; $i++)
126 130
 		{
127 131
 			// Value of 2 means we're inside the tag.
128
-			if ($i % 4 == 2)
129
-				$parts[$i] = strip_tags($parts[$i]);
132
+			if ($i % 4 == 2) {
133
+							$parts[$i] = strip_tags($parts[$i]);
134
+			}
130 135
 		}
131 136
 
132 137
 		$text = strtr(implode('', $parts), array('#smf_br_spec_grudge_cool!#' => '<br>'));
@@ -152,18 +157,19 @@  discard block
 block discarded – undo
152 157
 			{
153 158
 				$found = array_search($file, $smileysto);
154 159
 				// Note the weirdness here is to stop double spaces between smileys.
155
-				if ($found)
156
-					$matches[1][$k] = '-[]-smf_smily_start#|#' . $smcFunc['htmlspecialchars']($smileysfrom[$found]) . '-[]-smf_smily_end#|#';
157
-				else
158
-					$matches[1][$k] = '';
160
+				if ($found) {
161
+									$matches[1][$k] = '-[]-smf_smily_start#|#' . $smcFunc['htmlspecialchars']($smileysfrom[$found]) . '-[]-smf_smily_end#|#';
162
+				} else {
163
+									$matches[1][$k] = '';
164
+				}
159 165
 			}
160
-		}
161
-		else
166
+		} else
162 167
 		{
163 168
 			// Load all the smileys.
164 169
 			$names = array();
165
-			foreach ($matches[1] as $file)
166
-				$names[] = $file;
170
+			foreach ($matches[1] as $file) {
171
+							$names[] = $file;
172
+			}
167 173
 			$names = array_unique($names);
168 174
 
169 175
 			if (!empty($names))
@@ -177,13 +183,15 @@  discard block
 block discarded – undo
177 183
 					)
178 184
 				);
179 185
 				$mappings = array();
180
-				while ($row = $smcFunc['db_fetch_assoc']($request))
181
-					$mappings[$row['filename']] = $smcFunc['htmlspecialchars']($row['code']);
186
+				while ($row = $smcFunc['db_fetch_assoc']($request)) {
187
+									$mappings[$row['filename']] = $smcFunc['htmlspecialchars']($row['code']);
188
+				}
182 189
 				$smcFunc['db_free_result']($request);
183 190
 
184
-				foreach ($matches[1] as $k => $file)
185
-					if (isset($mappings[$file]))
191
+				foreach ($matches[1] as $k => $file) {
192
+									if (isset($mappings[$file]))
186 193
 						$matches[1][$k] = '-[]-smf_smily_start#|#' . $mappings[$file] . '-[]-smf_smily_end#|#';
194
+				}
187 195
 			}
188 196
 		}
189 197
 
@@ -195,8 +203,9 @@  discard block
 block discarded – undo
195 203
 	}
196 204
 
197 205
 	// Only try to buy more time if the client didn't quit.
198
-	if (connection_aborted() && $context['server']['is_apache'])
199
-		@apache_reset_timeout();
206
+	if (connection_aborted() && $context['server']['is_apache']) {
207
+			@apache_reset_timeout();
208
+	}
200 209
 
201 210
 	$parts = preg_split('~(<[A-Za-z]+\s*[^<>]*?style="?[^<>"]+"?[^<>]*?(?:/?)>|</[A-Za-z]+>)~', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
202 211
 	$replacement = '';
@@ -207,9 +216,9 @@  discard block
 block discarded – undo
207 216
 		if (preg_match('~(<([A-Za-z]+)\s*[^<>]*?)style="?([^<>"]+)"?([^<>]*?(/?)>)~', $part, $matches) === 1)
208 217
 		{
209 218
 			// If it's being closed instantly, we can't deal with it...yet.
210
-			if ($matches[5] === '/')
211
-				continue;
212
-			else
219
+			if ($matches[5] === '/') {
220
+							continue;
221
+			} else
213 222
 			{
214 223
 				// Get an array of styles that apply to this element. (The strtr is there to combat HTML generated by Word.)
215 224
 				$styles = explode(';', strtr($matches[3], array('&quot;' => '')));
@@ -225,8 +234,9 @@  discard block
 block discarded – undo
225 234
 					$clean_type_value_pair = strtolower(strtr(trim($type_value_pair), '=', ':'));
226 235
 
227 236
 					// Something like 'font-weight: bold' is expected here.
228
-					if (strpos($clean_type_value_pair, ':') === false)
229
-						continue;
237
+					if (strpos($clean_type_value_pair, ':') === false) {
238
+											continue;
239
+					}
230 240
 
231 241
 					// Capture the elements of a single style item (e.g. 'font-weight' and 'bold').
232 242
 					list ($style_type, $style_value) = explode(':', $type_value_pair);
@@ -248,8 +258,7 @@  discard block
 block discarded – undo
248 258
 							{
249 259
 								$curCloseTags .= '[/u]';
250 260
 								$replacement .= '[u]';
251
-							}
252
-							elseif ($style_value == 'line-through')
261
+							} elseif ($style_value == 'line-through')
253 262
 							{
254 263
 								$curCloseTags .= '[/s]';
255 264
 								$replacement .= '[s]';
@@ -261,13 +270,11 @@  discard block
 block discarded – undo
261 270
 							{
262 271
 								$curCloseTags .= '[/left]';
263 272
 								$replacement .= '[left]';
264
-							}
265
-							elseif ($style_value == 'center')
273
+							} elseif ($style_value == 'center')
266 274
 							{
267 275
 								$curCloseTags .= '[/center]';
268 276
 								$replacement .= '[center]';
269
-							}
270
-							elseif ($style_value == 'right')
277
+							} elseif ($style_value == 'right')
271 278
 							{
272 279
 								$curCloseTags .= '[/right]';
273 280
 								$replacement .= '[right]';
@@ -289,8 +296,9 @@  discard block
 block discarded – undo
289 296
 
290 297
 						case 'font-size':
291 298
 							// Sometimes people put decimals where decimals should not be.
292
-							if (preg_match('~(\d)+\.\d+(p[xt])~i', $style_value, $dec_matches) === 1)
293
-								$style_value = $dec_matches[1] . $dec_matches[2];
299
+							if (preg_match('~(\d)+\.\d+(p[xt])~i', $style_value, $dec_matches) === 1) {
300
+															$style_value = $dec_matches[1] . $dec_matches[2];
301
+							}
294 302
 
295 303
 							$curCloseTags .= '[/size]';
296 304
 							$replacement .= '[size=' . $style_value . ']';
@@ -298,8 +306,9 @@  discard block
 block discarded – undo
298 306
 
299 307
 						case 'font-family':
300 308
 							// Only get the first freaking font if there's a list!
301
-							if (strpos($style_value, ',') !== false)
302
-								$style_value = substr($style_value, 0, strpos($style_value, ','));
309
+							if (strpos($style_value, ',') !== false) {
310
+															$style_value = substr($style_value, 0, strpos($style_value, ','));
311
+							}
303 312
 
304 313
 							$curCloseTags .= '[/font]';
305 314
 							$replacement .= '[font=' . strtr($style_value, array("'" => '')) . ']';
@@ -308,13 +317,15 @@  discard block
 block discarded – undo
308 317
 						// This is a hack for images with dimensions embedded.
309 318
 						case 'width':
310 319
 						case 'height':
311
-							if (preg_match('~[1-9]\d*~i', $style_value, $dimension) === 1)
312
-								$extra_attr .= ' ' . $style_type . '="' . $dimension[0] . '"';
320
+							if (preg_match('~[1-9]\d*~i', $style_value, $dimension) === 1) {
321
+															$extra_attr .= ' ' . $style_type . '="' . $dimension[0] . '"';
322
+							}
313 323
 						break;
314 324
 
315 325
 						case 'list-style-type':
316
-							if (preg_match('~none|disc|circle|square|decimal|decimal-leading-zero|lower-roman|upper-roman|lower-alpha|upper-alpha|lower-greek|lower-latin|upper-latin|hebrew|armenian|georgian|cjk-ideographic|hiragana|katakana|hiragana-iroha|katakana-iroha~i', $style_value, $listType) === 1)
317
-								$extra_attr .= ' listtype="' . $listType[0] . '"';
326
+							if (preg_match('~none|disc|circle|square|decimal|decimal-leading-zero|lower-roman|upper-roman|lower-alpha|upper-alpha|lower-greek|lower-latin|upper-latin|hebrew|armenian|georgian|cjk-ideographic|hiragana|katakana|hiragana-iroha|katakana-iroha~i', $style_value, $listType) === 1) {
327
+															$extra_attr .= ' listtype="' . $listType[0] . '"';
328
+							}
318 329
 						break;
319 330
 					}
320 331
 				}
@@ -327,18 +338,17 @@  discard block
 block discarded – undo
327 338
 				}
328 339
 
329 340
 				// If there's something that still needs closing, push it to the stack.
330
-				if (!empty($curCloseTags))
331
-					array_push($stack, array(
341
+				if (!empty($curCloseTags)) {
342
+									array_push($stack, array(
332 343
 							'element' => strtolower($curElement),
333 344
 							'closeTags' => $curCloseTags
334 345
 						)
335 346
 					);
336
-				elseif (!empty($extra_attr))
337
-					$replacement .= $precedingStyle . $extra_attr . $afterStyle;
347
+				} elseif (!empty($extra_attr)) {
348
+									$replacement .= $precedingStyle . $extra_attr . $afterStyle;
349
+				}
338 350
 			}
339
-		}
340
-
341
-		elseif (preg_match('~</([A-Za-z]+)>~', $part, $matches) === 1)
351
+		} elseif (preg_match('~</([A-Za-z]+)>~', $part, $matches) === 1)
342 352
 		{
343 353
 			// Is this the element that we've been waiting for to be closed?
344 354
 			if (!empty($stack) && strtolower($matches[1]) === $stack[count($stack) - 1]['element'])
@@ -348,28 +358,32 @@  discard block
 block discarded – undo
348 358
 			}
349 359
 
350 360
 			// Must've been something else.
351
-			else
352
-				$replacement .= $part;
361
+			else {
362
+							$replacement .= $part;
363
+			}
353 364
 		}
354 365
 		// In all other cases, just add the part to the replacement.
355
-		else
356
-			$replacement .= $part;
366
+		else {
367
+					$replacement .= $part;
368
+		}
357 369
 	}
358 370
 
359 371
 	// Now put back the replacement in the text.
360 372
 	$text = $replacement;
361 373
 
362 374
 	// We are not finished yet, request more time.
363
-	if (connection_aborted() && $context['server']['is_apache'])
364
-		@apache_reset_timeout();
375
+	if (connection_aborted() && $context['server']['is_apache']) {
376
+			@apache_reset_timeout();
377
+	}
365 378
 
366 379
 	// Let's pull out any legacy alignments.
367 380
 	while (preg_match('~<([A-Za-z]+)\s+[^<>]*?(align="*(left|center|right)"*)[^<>]*?(/?)>~i', $text, $matches) === 1)
368 381
 	{
369 382
 		// Find the position in the text of this tag over again.
370 383
 		$start_pos = strpos($text, $matches[0]);
371
-		if ($start_pos === false)
372
-			break;
384
+		if ($start_pos === false) {
385
+					break;
386
+		}
373 387
 
374 388
 		// End tag?
375 389
 		if ($matches[4] != '/' && strpos($text, '</' . $matches[1] . '>', $start_pos) !== false)
@@ -383,8 +397,7 @@  discard block
 block discarded – undo
383 397
 
384 398
 			// Put the tags back into the body.
385 399
 			$text = substr($text, 0, $start_pos) . $tag . '[' . $matches[3] . ']' . $content . '[/' . $matches[3] . ']' . substr($text, $end_pos);
386
-		}
387
-		else
400
+		} else
388 401
 		{
389 402
 			// Just get rid of this evil tag.
390 403
 			$text = substr($text, 0, $start_pos) . substr($text, $start_pos + strlen($matches[0]));
@@ -397,8 +410,9 @@  discard block
 block discarded – undo
397 410
 		// Find the position of this again.
398 411
 		$start_pos = strpos($text, $matches[0]);
399 412
 		$end_pos = false;
400
-		if ($start_pos === false)
401
-			break;
413
+		if ($start_pos === false) {
414
+					break;
415
+		}
402 416
 
403 417
 		// This must have an end tag - and we must find the right one.
404 418
 		$lower_text = strtolower($text);
@@ -431,8 +445,9 @@  discard block
 block discarded – undo
431 445
 				break;
432 446
 			}
433 447
 		}
434
-		if ($end_pos === false)
435
-			break;
448
+		if ($end_pos === false) {
449
+					break;
450
+		}
436 451
 
437 452
 		// Now work out what the attributes are.
438 453
 		$attribs = fetchTagAttributes($matches[1]);
@@ -446,11 +461,11 @@  discard block
 block discarded – undo
446 461
 				$v = (int) trim($v);
447 462
 				$v = empty($v) ? 1 : $v;
448 463
 				$tags[] = array('[size=' . $sizes_equivalence[$v] . ']', '[/size]');
464
+			} elseif ($s == 'face') {
465
+							$tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]');
466
+			} elseif ($s == 'color') {
467
+							$tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]');
449 468
 			}
450
-			elseif ($s == 'face')
451
-				$tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]');
452
-			elseif ($s == 'color')
453
-				$tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]');
454 469
 		}
455 470
 
456 471
 		// As before add in our tags.
@@ -458,8 +473,9 @@  discard block
 block discarded – undo
458 473
 		foreach ($tags as $tag)
459 474
 		{
460 475
 			$before .= $tag[0];
461
-			if (isset($tag[1]))
462
-				$after = $tag[1] . $after;
476
+			if (isset($tag[1])) {
477
+							$after = $tag[1] . $after;
478
+			}
463 479
 		}
464 480
 
465 481
 		// Remove the tag so it's never checked again.
@@ -470,8 +486,9 @@  discard block
 block discarded – undo
470 486
 	}
471 487
 
472 488
 	// Almost there, just a little more time.
473
-	if (connection_aborted() && $context['server']['is_apache'])
474
-		@apache_reset_timeout();
489
+	if (connection_aborted() && $context['server']['is_apache']) {
490
+			@apache_reset_timeout();
491
+	}
475 492
 
476 493
 	if (count($parts = preg_split('~<(/?)(li|ol|ul)([^>]*)>~i', $text, null, PREG_SPLIT_DELIM_CAPTURE)) > 1)
477 494
 	{
@@ -527,12 +544,13 @@  discard block
 block discarded – undo
527 544
 						{
528 545
 							$inList = true;
529 546
 
530
-							if ($tag === 'ol')
531
-								$listType = 'decimal';
532
-							elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1)
533
-								$listType = $listTypeMapping[$match[1]];
534
-							else
535
-								$listType = null;
547
+							if ($tag === 'ol') {
548
+															$listType = 'decimal';
549
+							} elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1) {
550
+															$listType = $listTypeMapping[$match[1]];
551
+							} else {
552
+															$listType = null;
553
+							}
536 554
 
537 555
 							$listDepth++;
538 556
 
@@ -596,9 +614,7 @@  discard block
 block discarded – undo
596 614
 							$parts[$i + 1] = '';
597 615
 							$parts[$i + 2] = str_repeat("\t", $listDepth) . '[/list]';
598 616
 							$parts[$i + 3] = '';
599
-						}
600
-
601
-						else
617
+						} else
602 618
 						{
603 619
 							// We're in a list item.
604 620
 							if ($listDepth > 0)
@@ -635,9 +651,7 @@  discard block
 block discarded – undo
635 651
 							$parts[$i + 1] = '';
636 652
 							$parts[$i + 2] = '';
637 653
 							$parts[$i + 3] = '';
638
-						}
639
-
640
-						else
654
+						} else
641 655
 						{
642 656
 							// Remove the trailing breaks from the list item.
643 657
 							$parts[$i] = preg_replace('~\s*<br\s*' . '/?' . '>\s*$~', '', $parts[$i]);
@@ -675,8 +689,9 @@  discard block
 block discarded – undo
675 689
 			$text .= str_repeat("\t", $listDepth) . '[/list]';
676 690
 		}
677 691
 
678
-		for ($i = $listDepth; $i > 0; $i--)
679
-			$text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]';
692
+		for ($i = $listDepth; $i > 0; $i--) {
693
+					$text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]';
694
+		}
680 695
 	}
681 696
 
682 697
 	// I love my own image...
@@ -684,8 +699,9 @@  discard block
 block discarded – undo
684 699
 	{
685 700
 		// Find the position of the image.
686 701
 		$start_pos = strpos($text, $matches[0]);
687
-		if ($start_pos === false)
688
-			break;
702
+		if ($start_pos === false) {
703
+					break;
704
+		}
689 705
 		$end_pos = $start_pos + strlen($matches[0]);
690 706
 
691 707
 		$params = '';
@@ -694,12 +710,13 @@  discard block
 block discarded – undo
694 710
 		$attrs = fetchTagAttributes($matches[1]);
695 711
 		foreach ($attrs as $attrib => $value)
696 712
 		{
697
-			if (in_array($attrib, array('width', 'height')))
698
-				$params .= ' ' . $attrib . '=' . (int) $value;
699
-			elseif ($attrib == 'alt' && trim($value) != '')
700
-				$params .= ' alt=' . trim($value);
701
-			elseif ($attrib == 'src')
702
-				$src = trim($value);
713
+			if (in_array($attrib, array('width', 'height'))) {
714
+							$params .= ' ' . $attrib . '=' . (int) $value;
715
+			} elseif ($attrib == 'alt' && trim($value) != '') {
716
+							$params .= ' alt=' . trim($value);
717
+			} elseif ($attrib == 'src') {
718
+							$src = trim($value);
719
+			}
703 720
 		}
704 721
 
705 722
 		$tag = '';
@@ -710,10 +727,11 @@  discard block
 block discarded – undo
710 727
 			{
711 728
 				$baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']);
712 729
 
713
-				if (substr($src, 0, 1) === '/')
714
-					$src = $baseURL . $src;
715
-				else
716
-					$src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src;
730
+				if (substr($src, 0, 1) === '/') {
731
+									$src = $baseURL . $src;
732
+				} else {
733
+									$src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src;
734
+				}
717 735
 			}
718 736
 
719 737
 			$tag = '[img' . $params . ']' . $src . '[/img]';
@@ -891,20 +909,23 @@  discard block
 block discarded – undo
891 909
 		},
892 910
 	);
893 911
 
894
-	foreach ($tags as $tag => $replace)
895
-		$text = preg_replace_callback($tag, $replace, $text);
912
+	foreach ($tags as $tag => $replace) {
913
+			$text = preg_replace_callback($tag, $replace, $text);
914
+	}
896 915
 
897 916
 	// Please give us just a little more time.
898
-	if (connection_aborted() && $context['server']['is_apache'])
899
-		@apache_reset_timeout();
917
+	if (connection_aborted() && $context['server']['is_apache']) {
918
+			@apache_reset_timeout();
919
+	}
900 920
 
901 921
 	// What about URL's - the pain in the ass of the tag world.
902 922
 	while (preg_match('~<a\s+([^<>]*)>([^<>]*)</a>~i', $text, $matches) === 1)
903 923
 	{
904 924
 		// Find the position of the URL.
905 925
 		$start_pos = strpos($text, $matches[0]);
906
-		if ($start_pos === false)
907
-			break;
926
+		if ($start_pos === false) {
927
+					break;
928
+		}
908 929
 		$end_pos = $start_pos + strlen($matches[0]);
909 930
 
910 931
 		$tag_type = 'url';
@@ -918,8 +939,9 @@  discard block
 block discarded – undo
918 939
 				$href = trim($value);
919 940
 
920 941
 				// Are we dealing with an FTP link?
921
-				if (preg_match('~^ftps?://~', $href) === 1)
922
-					$tag_type = 'ftp';
942
+				if (preg_match('~^ftps?://~', $href) === 1) {
943
+									$tag_type = 'ftp';
944
+				}
923 945
 
924 946
 				// Or is this a link to an email address?
925 947
 				elseif (substr($href, 0, 7) == 'mailto:')
@@ -933,28 +955,31 @@  discard block
 block discarded – undo
933 955
 				{
934 956
 					$baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']);
935 957
 
936
-					if (substr($href, 0, 1) === '/')
937
-						$href = $baseURL . $href;
938
-					else
939
-						$href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href;
958
+					if (substr($href, 0, 1) === '/') {
959
+											$href = $baseURL . $href;
960
+					} else {
961
+											$href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href;
962
+					}
940 963
 				}
941 964
 			}
942 965
 
943 966
 			// External URL?
944 967
 			if ($attrib == 'target' && $tag_type == 'url')
945 968
 			{
946
-				if (trim($value) == '_blank')
947
-					$tag_type == 'iurl';
969
+				if (trim($value) == '_blank') {
970
+									$tag_type == 'iurl';
971
+				}
948 972
 			}
949 973
 		}
950 974
 
951 975
 		$tag = '';
952 976
 		if ($href != '')
953 977
 		{
954
-			if ($matches[2] == $href)
955
-				$tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']';
956
-			else
957
-				$tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']';
978
+			if ($matches[2] == $href) {
979
+							$tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']';
980
+			} else {
981
+							$tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']';
982
+			}
958 983
 		}
959 984
 
960 985
 		// Replace the tag
@@ -994,17 +1019,18 @@  discard block
 block discarded – undo
994 1019
 		// We're either moving from the key to the attribute or we're in a string and this is fine.
995 1020
 		if ($text[$i] == '=')
996 1021
 		{
997
-			if ($tag_state == 0)
998
-				$tag_state = 1;
999
-			elseif ($tag_state == 2)
1000
-				$value .= '=';
1022
+			if ($tag_state == 0) {
1023
+							$tag_state = 1;
1024
+			} elseif ($tag_state == 2) {
1025
+							$value .= '=';
1026
+			}
1001 1027
 		}
1002 1028
 		// A space is either moving from an attribute back to a potential key or in a string is fine.
1003 1029
 		elseif ($text[$i] == ' ')
1004 1030
 		{
1005
-			if ($tag_state == 2)
1006
-				$value .= ' ';
1007
-			elseif ($tag_state == 1)
1031
+			if ($tag_state == 2) {
1032
+							$value .= ' ';
1033
+			} elseif ($tag_state == 1)
1008 1034
 			{
1009 1035
 				$attribs[$key] = $value;
1010 1036
 				$key = $value = '';
@@ -1015,24 +1041,27 @@  discard block
 block discarded – undo
1015 1041
 		elseif ($text[$i] == '"')
1016 1042
 		{
1017 1043
 			// Must be either going into or out of a string.
1018
-			if ($tag_state == 1)
1019
-				$tag_state = 2;
1020
-			else
1021
-				$tag_state = 1;
1044
+			if ($tag_state == 1) {
1045
+							$tag_state = 2;
1046
+			} else {
1047
+							$tag_state = 1;
1048
+			}
1022 1049
 		}
1023 1050
 		// Otherwise it's fine.
1024 1051
 		else
1025 1052
 		{
1026
-			if ($tag_state == 0)
1027
-				$key .= $text[$i];
1028
-			else
1029
-				$value .= $text[$i];
1053
+			if ($tag_state == 0) {
1054
+							$key .= $text[$i];
1055
+			} else {
1056
+							$value .= $text[$i];
1057
+			}
1030 1058
 		}
1031 1059
 	}
1032 1060
 
1033 1061
 	// Anything left?
1034
-	if ($key != '' && $value != '')
1035
-		$attribs[$key] = $value;
1062
+	if ($key != '' && $value != '') {
1063
+			$attribs[$key] = $value;
1064
+	}
1036 1065
 
1037 1066
 	return $attribs;
1038 1067
 }
@@ -1050,8 +1079,9 @@  discard block
 block discarded – undo
1050 1079
 	global $modSettings;
1051 1080
 
1052 1081
 	// Don't care about the texts that are too short.
1053
-	if (strlen($text) < 3)
1054
-		return $text;
1082
+	if (strlen($text) < 3) {
1083
+			return $text;
1084
+	}
1055 1085
 
1056 1086
 	// A list of tags that's disabled by the admin.
1057 1087
 	$disabled = empty($modSettings['disabledBBC']) ? array() : array_flip(explode(',', strtolower($modSettings['disabledBBC'])));
@@ -1062,10 +1092,12 @@  discard block
 block discarded – undo
1062 1092
 	$self_closing_tags = array();
1063 1093
 	foreach ($all_tags as $tag)
1064 1094
 	{
1065
-		if (!isset($disabled[$tag['tag']]))
1066
-			$valid_tags[$tag['tag']] = !empty($tag['block_level']);
1067
-		if (isset($tag['type']) && $tag['type'] == 'closed')
1068
-			$self_closing_tags[] = $tag['tag'];
1095
+		if (!isset($disabled[$tag['tag']])) {
1096
+					$valid_tags[$tag['tag']] = !empty($tag['block_level']);
1097
+		}
1098
+		if (isset($tag['type']) && $tag['type'] == 'closed') {
1099
+					$self_closing_tags[] = $tag['tag'];
1100
+		}
1069 1101
 	}
1070 1102
 
1071 1103
 	// Right - we're going to start by going through the whole lot to make sure we don't have align stuff crossed as this happens load and is stupid!
@@ -1092,16 +1124,19 @@  discard block
 block discarded – undo
1092 1124
 				$tagName = substr($match, $isClosingTag ? 2 : 1, -1);
1093 1125
 
1094 1126
 				// We're closing the exact same tag that we opened.
1095
-				if ($isClosingTag && $insideTag === $tagName)
1096
-					$insideTag = null;
1127
+				if ($isClosingTag && $insideTag === $tagName) {
1128
+									$insideTag = null;
1129
+				}
1097 1130
 
1098 1131
 				// We're opening a tag and we're not yet inside one either
1099
-				elseif (!$isClosingTag && $insideTag === null)
1100
-					$insideTag = $tagName;
1132
+				elseif (!$isClosingTag && $insideTag === null) {
1133
+									$insideTag = $tagName;
1134
+				}
1101 1135
 
1102 1136
 				// In all other cases, this tag must be invalid
1103
-				else
1104
-					unset($matches[$i]);
1137
+				else {
1138
+									unset($matches[$i]);
1139
+				}
1105 1140
 			}
1106 1141
 
1107 1142
 			// The next one is gonna be the other one.
@@ -1109,8 +1144,9 @@  discard block
 block discarded – undo
1109 1144
 		}
1110 1145
 
1111 1146
 		// We're still inside a tag and had no chance for closure?
1112
-		if ($insideTag !== null)
1113
-			$matches[] = '[/' . $insideTag . ']';
1147
+		if ($insideTag !== null) {
1148
+					$matches[] = '[/' . $insideTag . ']';
1149
+		}
1114 1150
 
1115 1151
 		// And a complete text string again.
1116 1152
 		$text = implode('', $matches);
@@ -1119,8 +1155,9 @@  discard block
 block discarded – undo
1119 1155
 	// Quickly remove any tags which are back to back.
1120 1156
 	$backToBackPattern = '~\\[(' . implode('|', array_diff(array_keys($valid_tags), array('td', 'anchor'))) . ')[^<>\\[\\]]*\\]\s*\\[/\\1\\]~';
1121 1157
 	$lastlen = 0;
1122
-	while (strlen($text) !== $lastlen)
1123
-		$lastlen = strlen($text = preg_replace($backToBackPattern, '', $text));
1158
+	while (strlen($text) !== $lastlen) {
1159
+			$lastlen = strlen($text = preg_replace($backToBackPattern, '', $text));
1160
+	}
1124 1161
 
1125 1162
 	// Need to sort the tags my name length.
1126 1163
 	uksort($valid_tags, 'sort_array_length');
@@ -1157,8 +1194,9 @@  discard block
 block discarded – undo
1157 1194
 			$isCompetingTag = in_array($tag, $competing_tags);
1158 1195
 
1159 1196
 			// Check if this might be one of those cleaned out tags.
1160
-			if ($tag === '')
1161
-				continue;
1197
+			if ($tag === '') {
1198
+							continue;
1199
+			}
1162 1200
 
1163 1201
 			// Special case: inside [code] blocks any code is left untouched.
1164 1202
 			elseif ($tag === 'code')
@@ -1169,8 +1207,9 @@  discard block
 block discarded – undo
1169 1207
 					$inCode = false;
1170 1208
 
1171 1209
 					// Reopen tags that were closed before the code block.
1172
-					if (!empty($inlineElements))
1173
-						$parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']';
1210
+					if (!empty($inlineElements)) {
1211
+											$parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']';
1212
+					}
1174 1213
 				}
1175 1214
 
1176 1215
 				// We're outside a coding and nobbc block and opening it.
@@ -1199,8 +1238,9 @@  discard block
 block discarded – undo
1199 1238
 					$inNoBbc = false;
1200 1239
 
1201 1240
 					// Some inline elements might've been closed that need reopening.
1202
-					if (!empty($inlineElements))
1203
-						$parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']';
1241
+					if (!empty($inlineElements)) {
1242
+											$parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']';
1243
+					}
1204 1244
 				}
1205 1245
 
1206 1246
 				// We're outside a nobbc and coding block and opening it.
@@ -1220,8 +1260,9 @@  discard block
 block discarded – undo
1220 1260
 			}
1221 1261
 
1222 1262
 			// So, we're inside one of the special blocks: ignore any tag.
1223
-			elseif ($inCode || $inNoBbc)
1224
-				continue;
1263
+			elseif ($inCode || $inNoBbc) {
1264
+							continue;
1265
+			}
1225 1266
 
1226 1267
 			// We're dealing with an opening tag.
1227 1268
 			if ($isOpeningTag)
@@ -1262,8 +1303,9 @@  discard block
 block discarded – undo
1262 1303
 							if ($parts[$j + 3] === $tag)
1263 1304
 							{
1264 1305
 								// If it's an opening tag, increase the level.
1265
-								if ($parts[$j + 2] === '')
1266
-									$curLevel++;
1306
+								if ($parts[$j + 2] === '') {
1307
+																	$curLevel++;
1308
+								}
1267 1309
 
1268 1310
 								// A closing tag, decrease the level.
1269 1311
 								else
@@ -1286,13 +1328,15 @@  discard block
 block discarded – undo
1286 1328
 					{
1287 1329
 						if ($isCompetingTag)
1288 1330
 						{
1289
-							if (!isset($competingElements[$tag]))
1290
-								$competingElements[$tag] = array();
1331
+							if (!isset($competingElements[$tag])) {
1332
+															$competingElements[$tag] = array();
1333
+							}
1291 1334
 
1292 1335
 							$competingElements[$tag][] = $parts[$i + 4];
1293 1336
 
1294
-							if (count($competingElements[$tag]) > 1)
1295
-								$parts[$i] .= '[/' . $tag . ']';
1337
+							if (count($competingElements[$tag]) > 1) {
1338
+															$parts[$i] .= '[/' . $tag . ']';
1339
+							}
1296 1340
 						}
1297 1341
 
1298 1342
 						$inlineElements[$elementContent] = $tag;
@@ -1312,15 +1356,17 @@  discard block
 block discarded – undo
1312 1356
 						$addClosingTags = array();
1313 1357
 						while ($element = array_pop($blockElements))
1314 1358
 						{
1315
-							if ($element === $tag)
1316
-								break;
1359
+							if ($element === $tag) {
1360
+															break;
1361
+							}
1317 1362
 
1318 1363
 							// Still a block tag was open not equal to this tag.
1319 1364
 							$addClosingTags[] = $element['type'];
1320 1365
 						}
1321 1366
 
1322
-						if (!empty($addClosingTags))
1323
-							$parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1];
1367
+						if (!empty($addClosingTags)) {
1368
+													$parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1];
1369
+						}
1324 1370
 
1325 1371
 						// Apparently the closing tag was not found on the stack.
1326 1372
 						if (!is_string($element) || $element !== $tag)
@@ -1330,8 +1376,7 @@  discard block
 block discarded – undo
1330 1376
 							$parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = '';
1331 1377
 							continue;
1332 1378
 						}
1333
-					}
1334
-					else
1379
+					} else
1335 1380
 					{
1336 1381
 						// Get rid of this closing tag!
1337 1382
 						$parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = '';
@@ -1360,53 +1405,62 @@  discard block
 block discarded – undo
1360 1405
 							unset($inlineElements[$tagContentToBeClosed]);
1361 1406
 
1362 1407
 							// Was this the tag we were looking for?
1363
-							if ($tagToBeClosed === $tag)
1364
-								break;
1408
+							if ($tagToBeClosed === $tag) {
1409
+															break;
1410
+							}
1365 1411
 
1366 1412
 							// Nope, close it and look further!
1367
-							else
1368
-								$parts[$i] .= '[/' . $tagToBeClosed . ']';
1413
+							else {
1414
+															$parts[$i] .= '[/' . $tagToBeClosed . ']';
1415
+							}
1369 1416
 						}
1370 1417
 
1371 1418
 						if ($isCompetingTag && !empty($competingElements[$tag]))
1372 1419
 						{
1373 1420
 							array_pop($competingElements[$tag]);
1374 1421
 
1375
-							if (count($competingElements[$tag]) > 0)
1376
-								$parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5];
1422
+							if (count($competingElements[$tag]) > 0) {
1423
+															$parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5];
1424
+							}
1377 1425
 						}
1378 1426
 					}
1379 1427
 
1380 1428
 					// Unexpected closing tag, ex-ter-mi-nate.
1381
-					else
1382
-						$parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = '';
1429
+					else {
1430
+											$parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = '';
1431
+					}
1383 1432
 				}
1384 1433
 			}
1385 1434
 		}
1386 1435
 
1387 1436
 		// Close the code tags.
1388
-		if ($inCode)
1389
-			$parts[$i] .= '[/code]';
1437
+		if ($inCode) {
1438
+					$parts[$i] .= '[/code]';
1439
+		}
1390 1440
 
1391 1441
 		// The same for nobbc tags.
1392
-		elseif ($inNoBbc)
1393
-			$parts[$i] .= '[/nobbc]';
1442
+		elseif ($inNoBbc) {
1443
+					$parts[$i] .= '[/nobbc]';
1444
+		}
1394 1445
 
1395 1446
 		// Still inline tags left unclosed? Close them now, better late than never.
1396
-		elseif (!empty($inlineElements))
1397
-			$parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']';
1447
+		elseif (!empty($inlineElements)) {
1448
+					$parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']';
1449
+		}
1398 1450
 
1399 1451
 		// Now close the block elements.
1400
-		if (!empty($blockElements))
1401
-			$parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']';
1452
+		if (!empty($blockElements)) {
1453
+					$parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']';
1454
+		}
1402 1455
 
1403 1456
 		$text = implode('', $parts);
1404 1457
 	}
1405 1458
 
1406 1459
 	// Final clean up of back to back tags.
1407 1460
 	$lastlen = 0;
1408
-	while (strlen($text) !== $lastlen)
1409
-		$lastlen = strlen($text = preg_replace($backToBackPattern, '', $text));
1461
+	while (strlen($text) !== $lastlen) {
1462
+			$lastlen = strlen($text = preg_replace($backToBackPattern, '', $text));
1463
+	}
1410 1464
 
1411 1465
 	return $text;
1412 1466
 }
@@ -1437,22 +1491,25 @@  discard block
 block discarded – undo
1437 1491
 	$context['template_layers'] = array();
1438 1492
 	// Lets make sure we aren't going to output anything nasty.
1439 1493
 	@ob_end_clean();
1440
-	if (!empty($modSettings['enableCompressedOutput']))
1441
-		@ob_start('ob_gzhandler');
1442
-	else
1443
-		@ob_start();
1494
+	if (!empty($modSettings['enableCompressedOutput'])) {
1495
+			@ob_start('ob_gzhandler');
1496
+	} else {
1497
+			@ob_start();
1498
+	}
1444 1499
 
1445 1500
 	// If we don't have any locale better avoid broken js
1446
-	if (empty($txt['lang_locale']))
1447
-		die();
1501
+	if (empty($txt['lang_locale'])) {
1502
+			die();
1503
+	}
1448 1504
 
1449 1505
 	$file_data = '(function ($) {
1450 1506
 	\'use strict\';
1451 1507
 
1452 1508
 	$.sceditor.locale[' . JavaScriptEscape($txt['lang_locale']) . '] = {';
1453
-	foreach ($editortxt as $key => $val)
1454
-		$file_data .= '
1509
+	foreach ($editortxt as $key => $val) {
1510
+			$file_data .= '
1455 1511
 		' . JavaScriptEscape($key) . ': ' . JavaScriptEscape($val) . ',';
1512
+	}
1456 1513
 
1457 1514
 	$file_data .= '
1458 1515
 		dateFormat: "day.month.year"
@@ -1520,8 +1577,9 @@  discard block
 block discarded – undo
1520 1577
 				)
1521 1578
 			);
1522 1579
 			$icon_data = array();
1523
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1524
-				$icon_data[] = $row;
1580
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
1581
+							$icon_data[] = $row;
1582
+			}
1525 1583
 			$smcFunc['db_free_result']($request);
1526 1584
 
1527 1585
 			$icons = array();
@@ -1536,9 +1594,9 @@  discard block
 block discarded – undo
1536 1594
 			}
1537 1595
 
1538 1596
 			cache_put_data('posting_icons-' . $board_id, $icons, 480);
1597
+		} else {
1598
+					$icons = $temp;
1539 1599
 		}
1540
-		else
1541
-			$icons = $temp;
1542 1600
 	}
1543 1601
 	call_integration_hook('integrate_load_message_icons', array(&$icons));
1544 1602
 
@@ -1581,8 +1639,9 @@  discard block
 block discarded – undo
1581 1639
 	{
1582 1640
 		// Some general stuff.
1583 1641
 		$settings['smileys_url'] = $modSettings['smileys_url'] . '/' . $user_info['smiley_set'];
1584
-		if (!empty($context['drafts_autosave']))
1585
-			$context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000;
1642
+		if (!empty($context['drafts_autosave'])) {
1643
+					$context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000;
1644
+		}
1586 1645
 
1587 1646
 		// This really has some WYSIWYG stuff.
1588 1647
 		loadCSSFile('jquery.sceditor.css', array('force_current' => false, 'validate' => true), 'smf_jquery_sceditor');
@@ -1599,8 +1658,9 @@  discard block
 block discarded – undo
1599 1658
 		var bbc_quote = \'' . addcslashes($txt['quote'], "'") . '\';
1600 1659
 		var bbc_search_on = \'' . addcslashes($txt['search_on'], "'") . '\';');
1601 1660
 		// editor language file
1602
-		if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US')
1603
-			loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language');
1661
+		if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US') {
1662
+					loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language');
1663
+		}
1604 1664
 
1605 1665
 		$context['shortcuts_text'] = $txt['shortcuts' . (!empty($context['drafts_save']) ? '_drafts' : '') . (stripos($_SERVER['HTTP_USER_AGENT'], 'Macintosh') !== false ? '_mac' : (isBrowser('is_firefox') ? '_firefox' : ''))];
1606 1666
 		$context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_character_set'] == 'UTF-8' || function_exists('iconv'))));
@@ -1609,11 +1669,12 @@  discard block
 block discarded – undo
1609 1669
 			loadJavaScriptFile('spellcheck.js', array('minimize' => true), 'smf_spellcheck');
1610 1670
 
1611 1671
 			// Some hidden information is needed in order to make the spell checking work.
1612
-			if (!isset($_REQUEST['xml']))
1613
-				$context['insert_after_template'] .= '
1672
+			if (!isset($_REQUEST['xml'])) {
1673
+							$context['insert_after_template'] .= '
1614 1674
 		<form name="spell_form" id="spell_form" method="post" accept-charset="' . $context['character_set'] . '" target="spellWindow" action="' . $scripturl . '?action=spellcheck">
1615 1675
 			<input type="hidden" name="spellstring" value="">
1616 1676
 		</form>';
1677
+			}
1617 1678
 		}
1618 1679
 	}
1619 1680
 
@@ -1805,8 +1866,9 @@  discard block
 block discarded – undo
1805 1866
 
1806 1867
 		// Generate a list of buttons that shouldn't be shown - this should be the fastest way to do this.
1807 1868
 		$disabled_tags = array();
1808
-		if (!empty($modSettings['disabledBBC']))
1809
-			$disabled_tags = explode(',', $modSettings['disabledBBC']);
1869
+		if (!empty($modSettings['disabledBBC'])) {
1870
+					$disabled_tags = explode(',', $modSettings['disabledBBC']);
1871
+		}
1810 1872
 
1811 1873
 		foreach ($disabled_tags as $tag)
1812 1874
 		{
@@ -1818,9 +1880,10 @@  discard block
 block discarded – undo
1818 1880
 				$context['disabled_tags']['orderedlist'] = true;
1819 1881
 			}
1820 1882
 
1821
-			foreach ($editor_tag_map as $thisTag => $tagNameBBC)
1822
-				if ($tag === $thisTag)
1883
+			foreach ($editor_tag_map as $thisTag => $tagNameBBC) {
1884
+							if ($tag === $thisTag)
1823 1885
 					$context['disabled_tags'][$tagNameBBC] = true;
1886
+			}
1824 1887
 
1825 1888
 			$context['disabled_tags'][$tag] = true;
1826 1889
 		}
@@ -1831,8 +1894,9 @@  discard block
 block discarded – undo
1831 1894
 
1832 1895
 		foreach ($context['bbc_tags'] as $row => $tagRow)
1833 1896
 		{
1834
-			if (!isset($context['bbc_toolbar'][$row]))
1835
-				$context['bbc_toolbar'][$row] = array();
1897
+			if (!isset($context['bbc_toolbar'][$row])) {
1898
+							$context['bbc_toolbar'][$row] = array();
1899
+			}
1836 1900
 
1837 1901
 			$tagsRow = array();
1838 1902
 
@@ -1868,20 +1932,21 @@  discard block
 block discarded – undo
1868 1932
 
1869 1933
 					$context['bbcodes_handlers'] .= '
1870 1934
 						});';
1871
-				}
1872
-				else
1935
+				} else
1873 1936
 				{
1874 1937
 					$context['bbc_toolbar'][$row][] = implode(',', $tagsRow);
1875 1938
 					$tagsRow = array();
1876 1939
 				}
1877 1940
 			}
1878 1941
 
1879
-			if (!empty($tagsRow))
1880
-				$context['bbc_toolbar'][$row][] = implode(',', $tagsRow);
1942
+			if (!empty($tagsRow)) {
1943
+							$context['bbc_toolbar'][$row][] = implode(',', $tagsRow);
1944
+			}
1881 1945
 		}
1882 1946
 
1883
-		if (!empty($bbcodes_styles))
1884
-			addInlineCss($bbcodes_styles);
1947
+		if (!empty($bbcodes_styles)) {
1948
+					addInlineCss($bbcodes_styles);
1949
+		}
1885 1950
 	}
1886 1951
 
1887 1952
 	// Initialize smiley array... if not loaded before.
@@ -1893,8 +1958,8 @@  discard block
 block discarded – undo
1893 1958
 		);
1894 1959
 
1895 1960
 		// Load smileys - don't bother to run a query if we're not using the database's ones anyhow.
1896
-		if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none')
1897
-			$context['smileys']['postform'][] = array(
1961
+		if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none') {
1962
+					$context['smileys']['postform'][] = array(
1898 1963
 				'smileys' => array(
1899 1964
 					array(
1900 1965
 						'code' => ':)',
@@ -1980,7 +2045,7 @@  discard block
 block discarded – undo
1980 2045
 				),
1981 2046
 				'isLast' => true,
1982 2047
 			);
1983
-		elseif ($user_info['smiley_set'] != 'none')
2048
+		} elseif ($user_info['smiley_set'] != 'none')
1984 2049
 		{
1985 2050
 			if (($temp = cache_get_data('posting_smileys', 480)) == null)
1986 2051
 			{
@@ -2003,17 +2068,19 @@  discard block
 block discarded – undo
2003 2068
 
2004 2069
 				foreach ($context['smileys'] as $section => $smileyRows)
2005 2070
 				{
2006
-					foreach ($smileyRows as $rowIndex => $smileys)
2007
-						$context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true;
2071
+					foreach ($smileyRows as $rowIndex => $smileys) {
2072
+											$context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true;
2073
+					}
2008 2074
 
2009
-					if (!empty($smileyRows))
2010
-						$context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true;
2075
+					if (!empty($smileyRows)) {
2076
+											$context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true;
2077
+					}
2011 2078
 				}
2012 2079
 
2013 2080
 				cache_put_data('posting_smileys', $context['smileys'], 480);
2081
+			} else {
2082
+							$context['smileys'] = $temp;
2014 2083
 			}
2015
-			else
2016
-				$context['smileys'] = $temp;
2017 2084
 		}
2018 2085
 	}
2019 2086
 
@@ -2029,12 +2096,15 @@  discard block
 block discarded – undo
2029 2096
 		'plugins' => '',
2030 2097
 		'bbcodeTrim' => true,
2031 2098
 	);
2032
-	if (!empty($context['controls']['richedit'][$editorOptions['id']]['locale']))
2033
-		$sce_options['locale'] = $context['controls']['richedit'][$editorOptions['id']]['locale'];
2034
-	if (!empty($context['right_to_left']))
2035
-		$sce_options['rtl'] = true;
2036
-	if ($editorOptions['id'] != 'quickReply')
2037
-		$sce_options['autofocus'] = true;
2099
+	if (!empty($context['controls']['richedit'][$editorOptions['id']]['locale'])) {
2100
+			$sce_options['locale'] = $context['controls']['richedit'][$editorOptions['id']]['locale'];
2101
+	}
2102
+	if (!empty($context['right_to_left'])) {
2103
+			$sce_options['rtl'] = true;
2104
+	}
2105
+	if ($editorOptions['id'] != 'quickReply') {
2106
+			$sce_options['autofocus'] = true;
2107
+	}
2038 2108
 
2039 2109
 	$sce_options['emoticons'] = array();
2040 2110
 	$sce_options['emoticonsDescriptions'] = array();
@@ -2051,10 +2121,11 @@  discard block
 block discarded – undo
2051 2121
 			$countLocations--;
2052 2122
 
2053 2123
 			unset($smiley_location);
2054
-			if ($location == 'postform')
2055
-				$smiley_location = &$sce_options['emoticons']['dropdown'];
2056
-			elseif ($location == 'popup')
2057
-				$smiley_location = &$sce_options['emoticons']['popup'];
2124
+			if ($location == 'postform') {
2125
+							$smiley_location = &$sce_options['emoticons']['dropdown'];
2126
+			} elseif ($location == 'popup') {
2127
+							$smiley_location = &$sce_options['emoticons']['popup'];
2128
+			}
2058 2129
 
2059 2130
 			$numRows = count($smileyRows);
2060 2131
 
@@ -2068,8 +2139,9 @@  discard block
 block discarded – undo
2068 2139
 					$sce_options['emoticonsDescriptions'][$smiley['code']] = $smiley['description'];
2069 2140
 				}
2070 2141
 
2071
-				if (empty($smileyRow['isLast']) && $numRows != 1)
2072
-					$smiley_location['-' . $emptyPlaceholder++] = '';
2142
+				if (empty($smileyRow['isLast']) && $numRows != 1) {
2143
+									$smiley_location['-' . $emptyPlaceholder++] = '';
2144
+				}
2073 2145
 			}
2074 2146
 		}
2075 2147
 	}
@@ -2084,8 +2156,9 @@  discard block
 block discarded – undo
2084 2156
 
2085 2157
 			$count_tags--;
2086 2158
 
2087
-			if (!empty($count_tags))
2088
-				$sce_options['toolbar'] .= '||';
2159
+			if (!empty($count_tags)) {
2160
+							$sce_options['toolbar'] .= '||';
2161
+			}
2089 2162
 		}
2090 2163
 	}
2091 2164
 
@@ -2113,8 +2186,9 @@  discard block
 block discarded – undo
2113 2186
 		loadTemplate('GenericControls');
2114 2187
 
2115 2188
 		// Some javascript ma'am?
2116
-		if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual'])))
2117
-			loadJavaScriptFile('captcha.js', array('minimize' => true), 'smf_captcha');
2189
+		if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual']))) {
2190
+					loadJavaScriptFile('captcha.js', array('minimize' => true), 'smf_captcha');
2191
+		}
2118 2192
 
2119 2193
 		$context['use_graphic_library'] = in_array('gd', get_loaded_extensions());
2120 2194
 
@@ -2127,8 +2201,8 @@  discard block
 block discarded – undo
2127 2201
 	$isNew = !isset($context['controls']['verification'][$verificationOptions['id']]);
2128 2202
 
2129 2203
 	// Log this into our collection.
2130
-	if ($isNew)
2131
-		$context['controls']['verification'][$verificationOptions['id']] = array(
2204
+	if ($isNew) {
2205
+			$context['controls']['verification'][$verificationOptions['id']] = array(
2132 2206
 			'id' => $verificationOptions['id'],
2133 2207
 			'empty_field' => empty($verificationOptions['no_empty_field']),
2134 2208
 			'show_visual' => !empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual'])),
@@ -2139,13 +2213,15 @@  discard block
 block discarded – undo
2139 2213
 			'questions' => array(),
2140 2214
 			'can_recaptcha' => !empty($modSettings['recaptcha_enabled']) && !empty($modSettings['recaptcha_site_key']) && !empty($modSettings['recaptcha_secret_key']),
2141 2215
 		);
2216
+	}
2142 2217
 	$thisVerification = &$context['controls']['verification'][$verificationOptions['id']];
2143 2218
 
2144 2219
 	// Is there actually going to be anything?
2145
-	if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha']))
2146
-		return false;
2147
-	elseif (!$isNew && !$do_test)
2148
-		return true;
2220
+	if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha'])) {
2221
+			return false;
2222
+	} elseif (!$isNew && !$do_test) {
2223
+			return true;
2224
+	}
2149 2225
 
2150 2226
 	// Sanitize reCAPTCHA fields?
2151 2227
 	if ($thisVerification['can_recaptcha'])
@@ -2158,11 +2234,12 @@  discard block
 block discarded – undo
2158 2234
 	}
2159 2235
 
2160 2236
 	// Add javascript for the object.
2161
-	if ($context['controls']['verification'][$verificationOptions['id']]['show_visual'])
2162
-		$context['insert_after_template'] .= '
2237
+	if ($context['controls']['verification'][$verificationOptions['id']]['show_visual']) {
2238
+			$context['insert_after_template'] .= '
2163 2239
 			<script>
2164 2240
 				var verification' . $verificationOptions['id'] . 'Handle = new smfCaptcha("' . $thisVerification['image_href'] . '", "' . $verificationOptions['id'] . '", ' . ($context['use_graphic_library'] ? 1 : 0) . ');
2165 2241
 			</script>';
2242
+	}
2166 2243
 
2167 2244
 	// If we want questions do we have a cache of all the IDs?
2168 2245
 	if (!empty($thisVerification['number_questions']) && empty($modSettings['question_id_cache']))
@@ -2185,8 +2262,9 @@  discard block
 block discarded – undo
2185 2262
 				unset ($row['id_question']);
2186 2263
 				// Make them all lowercase. We can't directly use $smcFunc['strtolower'] with array_walk, so do it manually, eh?
2187 2264
 				$row['answers'] = $smcFunc['json_decode']($row['answers'], true);
2188
-				foreach ($row['answers'] as $k => $v)
2189
-					$row['answers'][$k] = $smcFunc['strtolower']($v);
2265
+				foreach ($row['answers'] as $k => $v) {
2266
+									$row['answers'][$k] = $smcFunc['strtolower']($v);
2267
+				}
2190 2268
 
2191 2269
 				$modSettings['question_id_cache']['questions'][$id_question] = $row;
2192 2270
 				$modSettings['question_id_cache']['langs'][$row['lngfile']][] = $id_question;
@@ -2197,35 +2275,42 @@  discard block
 block discarded – undo
2197 2275
 		}
2198 2276
 	}
2199 2277
 
2200
-	if (!isset($_SESSION[$verificationOptions['id'] . '_vv']))
2201
-		$_SESSION[$verificationOptions['id'] . '_vv'] = array();
2278
+	if (!isset($_SESSION[$verificationOptions['id'] . '_vv'])) {
2279
+			$_SESSION[$verificationOptions['id'] . '_vv'] = array();
2280
+	}
2202 2281
 
2203 2282
 	// Do we need to refresh the verification?
2204
-	if (!$do_test && (!empty($_SESSION[$verificationOptions['id'] . '_vv']['did_pass']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) || $_SESSION[$verificationOptions['id'] . '_vv']['count'] > 3) && empty($verificationOptions['dont_refresh']))
2205
-		$force_refresh = true;
2206
-	else
2207
-		$force_refresh = false;
2283
+	if (!$do_test && (!empty($_SESSION[$verificationOptions['id'] . '_vv']['did_pass']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) || $_SESSION[$verificationOptions['id'] . '_vv']['count'] > 3) && empty($verificationOptions['dont_refresh'])) {
2284
+			$force_refresh = true;
2285
+	} else {
2286
+			$force_refresh = false;
2287
+	}
2208 2288
 
2209 2289
 	// This can also force a fresh, although unlikely.
2210
-	if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q'])))
2211
-		$force_refresh = true;
2290
+	if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q']))) {
2291
+			$force_refresh = true;
2292
+	}
2212 2293
 
2213 2294
 	$verification_errors = array();
2214 2295
 	// Start with any testing.
2215 2296
 	if ($do_test)
2216 2297
 	{
2217 2298
 		// This cannot happen!
2218
-		if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count']))
2219
-			fatal_lang_error('no_access', false);
2299
+		if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count'])) {
2300
+					fatal_lang_error('no_access', false);
2301
+		}
2220 2302
 		// ... nor this!
2221
-		if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q'])))
2222
-			fatal_lang_error('no_access', false);
2303
+		if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q']))) {
2304
+					fatal_lang_error('no_access', false);
2305
+		}
2223 2306
 		// Hmm, it's requested but not actually declared. This shouldn't happen.
2224
-		if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']))
2225
-			fatal_lang_error('no_access', false);
2307
+		if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) {
2308
+					fatal_lang_error('no_access', false);
2309
+		}
2226 2310
 		// While we're here, did the user do something bad?
2227
-		if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']]))
2228
-			$verification_errors[] = 'wrong_verification_answer';
2311
+		if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']])) {
2312
+					$verification_errors[] = 'wrong_verification_answer';
2313
+		}
2229 2314
 
2230 2315
 		if ($thisVerification['can_recaptcha'])
2231 2316
 		{
@@ -2236,22 +2321,25 @@  discard block
 block discarded – undo
2236 2321
 			{
2237 2322
 				$resp = $reCaptcha->verify($_POST['g-recaptcha-response'], $user_info['ip']);
2238 2323
 
2239
-				if (!$resp->isSuccess())
2240
-					$verification_errors[] = 'wrong_verification_code';
2324
+				if (!$resp->isSuccess()) {
2325
+									$verification_errors[] = 'wrong_verification_code';
2326
+				}
2327
+			} else {
2328
+							$verification_errors[] = 'wrong_verification_code';
2241 2329
 			}
2242
-			else
2243
-				$verification_errors[] = 'wrong_verification_code';
2244 2330
 		}
2245
-		if ($thisVerification['show_visual'] && (empty($_REQUEST[$verificationOptions['id'] . '_vv']['code']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['code']) || strtoupper($_REQUEST[$verificationOptions['id'] . '_vv']['code']) !== $_SESSION[$verificationOptions['id'] . '_vv']['code']))
2246
-			$verification_errors[] = 'wrong_verification_code';
2331
+		if ($thisVerification['show_visual'] && (empty($_REQUEST[$verificationOptions['id'] . '_vv']['code']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['code']) || strtoupper($_REQUEST[$verificationOptions['id'] . '_vv']['code']) !== $_SESSION[$verificationOptions['id'] . '_vv']['code'])) {
2332
+					$verification_errors[] = 'wrong_verification_code';
2333
+		}
2247 2334
 		if ($thisVerification['number_questions'])
2248 2335
 		{
2249 2336
 			$incorrectQuestions = array();
2250 2337
 			foreach ($_SESSION[$verificationOptions['id'] . '_vv']['q'] as $q)
2251 2338
 			{
2252 2339
 				// We don't have this question any more, thus no answers.
2253
-				if (!isset($modSettings['question_id_cache']['questions'][$q]))
2254
-					continue;
2340
+				if (!isset($modSettings['question_id_cache']['questions'][$q])) {
2341
+									continue;
2342
+				}
2255 2343
 				// This is quite complex. We have our question but it might have multiple answers.
2256 2344
 				// First, did they actually answer this question?
2257 2345
 				if (!isset($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) || trim($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) == '')
@@ -2263,24 +2351,28 @@  discard block
 block discarded – undo
2263 2351
 				else
2264 2352
 				{
2265 2353
 					$given_answer = trim($smcFunc['htmlspecialchars'](strtolower($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q])));
2266
-					if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers']))
2267
-						$incorrectQuestions[] = $q;
2354
+					if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers'])) {
2355
+											$incorrectQuestions[] = $q;
2356
+					}
2268 2357
 				}
2269 2358
 			}
2270 2359
 
2271
-			if (!empty($incorrectQuestions))
2272
-				$verification_errors[] = 'wrong_verification_answer';
2360
+			if (!empty($incorrectQuestions)) {
2361
+							$verification_errors[] = 'wrong_verification_answer';
2362
+			}
2273 2363
 		}
2274 2364
 	}
2275 2365
 
2276 2366
 	// Any errors means we refresh potentially.
2277 2367
 	if (!empty($verification_errors))
2278 2368
 	{
2279
-		if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors']))
2280
-			$_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0;
2369
+		if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors'])) {
2370
+					$_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0;
2371
+		}
2281 2372
 		// Too many errors?
2282
-		elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors'])
2283
-			$force_refresh = true;
2373
+		elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors']) {
2374
+					$force_refresh = true;
2375
+		}
2284 2376
 
2285 2377
 		// Keep a track of these.
2286 2378
 		$_SESSION[$verificationOptions['id'] . '_vv']['errors']++;
@@ -2313,8 +2405,9 @@  discard block
 block discarded – undo
2313 2405
 			// Are we overriding the range?
2314 2406
 			$character_range = !empty($verificationOptions['override_range']) ? $verificationOptions['override_range'] : $context['standard_captcha_range'];
2315 2407
 
2316
-			for ($i = 0; $i < 6; $i++)
2317
-				$_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)];
2408
+			for ($i = 0; $i < 6; $i++) {
2409
+							$_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)];
2410
+			}
2318 2411
 		}
2319 2412
 
2320 2413
 		// Getting some new questions?
@@ -2322,8 +2415,9 @@  discard block
 block discarded – undo
2322 2415
 		{
2323 2416
 			// Attempt to try the current page's language, followed by the user's preference, followed by the site default.
2324 2417
 			$possible_langs = array();
2325
-			if (isset($_SESSION['language']))
2326
-				$possible_langs[] = strtr($_SESSION['language'], array('-utf8' => ''));
2418
+			if (isset($_SESSION['language'])) {
2419
+							$possible_langs[] = strtr($_SESSION['language'], array('-utf8' => ''));
2420
+			}
2327 2421
 			if (!empty($user_info['language']));
2328 2422
 			$possible_langs[] = $user_info['language'];
2329 2423
 			$possible_langs[] = $language;
@@ -2342,8 +2436,7 @@  discard block
 block discarded – undo
2342 2436
 				}
2343 2437
 			}
2344 2438
 		}
2345
-	}
2346
-	else
2439
+	} else
2347 2440
 	{
2348 2441
 		// Same questions as before.
2349 2442
 		$questionIDs = !empty($_SESSION[$verificationOptions['id'] . '_vv']['q']) ? $_SESSION[$verificationOptions['id'] . '_vv']['q'] : array();
@@ -2353,8 +2446,9 @@  discard block
 block discarded – undo
2353 2446
 	// If we do have an empty field, it would be nice to hide it from legitimate users who shouldn't be populating it anyway.
2354 2447
 	if (!empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']))
2355 2448
 	{
2356
-		if (!isset($context['html_headers']))
2357
-			$context['html_headers'] = '';
2449
+		if (!isset($context['html_headers'])) {
2450
+					$context['html_headers'] = '';
2451
+		}
2358 2452
 		$context['html_headers'] .= '<style>.vv_special { display:none; }</style>';
2359 2453
 	}
2360 2454
 
@@ -2380,11 +2474,13 @@  discard block
 block discarded – undo
2380 2474
 	$_SESSION[$verificationOptions['id'] . '_vv']['count'] = empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) ? 1 : $_SESSION[$verificationOptions['id'] . '_vv']['count'] + 1;
2381 2475
 
2382 2476
 	// Return errors if we have them.
2383
-	if (!empty($verification_errors))
2384
-		return $verification_errors;
2477
+	if (!empty($verification_errors)) {
2478
+			return $verification_errors;
2479
+	}
2385 2480
 	// If we had a test that one, make a note.
2386
-	elseif ($do_test)
2387
-		$_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true;
2481
+	elseif ($do_test) {
2482
+			$_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true;
2483
+	}
2388 2484
 
2389 2485
 	// Say that everything went well chaps.
2390 2486
 	return true;
@@ -2409,8 +2505,9 @@  discard block
 block discarded – undo
2409 2505
 	call_integration_hook('integrate_autosuggest', array(&$searchTypes));
2410 2506
 
2411 2507
 	// If we're just checking the callback function is registered return true or false.
2412
-	if ($checkRegistered != null)
2413
-		return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered);
2508
+	if ($checkRegistered != null) {
2509
+			return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered);
2510
+	}
2414 2511
 
2415 2512
 	checkSession('get');
2416 2513
 	loadTemplate('Xml');
@@ -2561,24 +2658,27 @@  discard block
 block discarded – undo
2561 2658
 		foreach ($possible_versions as $ver)
2562 2659
 		{
2563 2660
 			$ver = trim($ver);
2564
-			if (strpos($ver, 'SMF') === 0)
2565
-				$versions[] = $ver;
2661
+			if (strpos($ver, 'SMF') === 0) {
2662
+							$versions[] = $ver;
2663
+			}
2566 2664
 		}
2567 2665
 	}
2568 2666
 	$smcFunc['db_free_result']($request);
2569 2667
 
2570 2668
 	// Just in case we don't have ANYthing.
2571
-	if (empty($versions))
2572
-		$versions = array('SMF 2.0');
2669
+	if (empty($versions)) {
2670
+			$versions = array('SMF 2.0');
2671
+	}
2573 2672
 
2574
-	foreach ($versions as $id => $version)
2575
-		if (strpos($version, strtoupper($_REQUEST['search'])) !== false)
2673
+	foreach ($versions as $id => $version) {
2674
+			if (strpos($version, strtoupper($_REQUEST['search'])) !== false)
2576 2675
 			$xml_data['items']['children'][] = array(
2577 2676
 				'attributes' => array(
2578 2677
 					'id' => $id,
2579 2678
 				),
2580 2679
 				'value' => $version,
2581 2680
 			);
2681
+	}
2582 2682
 
2583 2683
 	return $xml_data;
2584 2684
 }
Please login to merge, or discard this patch.