Completed
Push — release-2.1 ( 754615...c3ff7f )
by Mathias
13s
created
proxy.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -140,7 +140,7 @@
 block discarded – undo
140 140
 		$max_age = $time - $cached['time'] + (5 * 86400);
141 141
 		header('content-type: ' . $cached['content_type']);
142 142
 		header('content-length: ' . $cached['size']);
143
-		header('cache-control: public, max-age=' . $max_age );
143
+		header('cache-control: public, max-age=' . $max_age);
144 144
 		header('last-modified: ' . gmdate('D, d M Y H:i:s', $cached['time']) . ' GMT');
145 145
 		header('etag: ' . $eTag);
146 146
 		echo base64_decode($cached['body']);
Please login to merge, or discard this patch.
Braces   +35 added lines, -23 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	define('SMF', 'proxy');
18
+}
18 19
 
19 20
 global $proxyhousekeeping;
20 21
 
@@ -68,30 +69,35 @@  discard block
 block discarded – undo
68 69
 	 */
69 70
 	public function checkRequest()
70 71
 	{
71
-		if (!$this->enabled)
72
-			return false;
72
+		if (!$this->enabled) {
73
+					return false;
74
+		}
73 75
 
74 76
 		// Try to create the image cache directory if it doesn't exist
75
-		if (!file_exists($this->cache))
76
-			if (!mkdir($this->cache) || !copy(dirname($this->cache) . '/index.php', $this->cache . '/index.php'))
77
+		if (!file_exists($this->cache)) {
78
+					if (!mkdir($this->cache) || !copy(dirname($this->cache) . '/index.php', $this->cache . '/index.php'))
77 79
 				return false;
80
+		}
78 81
 
79 82
 		// Basic sanity check
80 83
 		$_GET['request'] = filter_var($_GET['request'], FILTER_VALIDATE_URL);
81 84
 
82 85
 		// We aren't going anywhere without these
83
-		if (empty($_GET['hash']) || empty($_GET['request']))
84
-			return false;
86
+		if (empty($_GET['hash']) || empty($_GET['request'])) {
87
+					return false;
88
+		}
85 89
 
86 90
 		$hash = $_GET['hash'];
87 91
 		$request = $_GET['request'];
88 92
 
89
-		if (md5($request . $this->secret) != $hash)
90
-			return false;
93
+		if (md5($request . $this->secret) != $hash) {
94
+					return false;
95
+		}
91 96
 
92 97
 		// Attempt to cache the request if it doesn't exist
93
-		if (!$this->isCached($request))
94
-			return $this->cacheImage($request);
98
+		if (!$this->isCached($request)) {
99
+					return $this->cacheImage($request);
100
+		}
95 101
 
96 102
 		return true;
97 103
 	}
@@ -128,8 +134,9 @@  discard block
 block discarded – undo
128 134
 		if (!$cached || $time - $cached['time'] > ($this->maxDays * 86400))
129 135
 		{
130 136
 			@unlink($cached_file);
131
-			if ($this->checkRequest())
132
-				$this->serve();
137
+			if ($this->checkRequest()) {
138
+							$this->serve();
139
+			}
133 140
 			$this::redirectexit($request);
134 141
 		}
135 142
 
@@ -142,8 +149,9 @@  discard block
 block discarded – undo
142 149
 
143 150
 		// Make sure we're serving an image
144 151
 		$contentParts = explode('/', !empty($cached['content_type']) ? $cached['content_type'] : '');
145
-		if ($contentParts[0] != 'image')
146
-			exit;
152
+		if ($contentParts[0] != 'image') {
153
+					exit;
154
+		}
147 155
 
148 156
 		$max_age = $time - $cached['time'] + (5 * 86400);
149 157
 		header('content-type: ' . $cached['content_type']);
@@ -193,25 +201,29 @@  discard block
 block discarded – undo
193 201
 		$image = fetch_web_data($request);
194 202
 
195 203
 		// Looks like nobody was home
196
-		if (empty($image))
197
-			return -1;
204
+		if (empty($image)) {
205
+					return -1;
206
+		}
198 207
 
199 208
 		// What kind of file did they give us?
200 209
 		$finfo = finfo_open(FILEINFO_MIME_TYPE);
201 210
 		$mime_type = finfo_buffer($finfo, $image);
202 211
 
203 212
 		// SVG needs a little extra care
204
-		if ($ext == 'svg' && $mime_type == 'text/plain')
205
-			$mime_type = 'image/svg+xml';
213
+		if ($ext == 'svg' && $mime_type == 'text/plain') {
214
+					$mime_type = 'image/svg+xml';
215
+		}
206 216
 
207 217
 		// Make sure the url is returning an image
208
-		if (strpos($mime_type, 'image/') !== 0)
209
-			return -1;
218
+		if (strpos($mime_type, 'image/') !== 0) {
219
+					return -1;
220
+		}
210 221
 
211 222
 		// Validate the filesize
212 223
 		$size = strlen($image);
213
-		if ($size > ($this->maxSize * 1024))
214
-			return 0;
224
+		if ($size > ($this->maxSize * 1024)) {
225
+					return 0;
226
+		}
215 227
 
216 228
 		// Cache it for later
217 229
 		return file_put_contents($dest, json_encode(array(
Please login to merge, or discard this patch.
Themes/default/Profile.template.php 2 patches
Spacing   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
 		$fields = '';
465 465
 		foreach ($context['print_custom_fields']['below_signature'] as $field)
466 466
 			if (!empty($field['output_html']))
467
-				$fields .=  '
467
+				$fields .= '
468 468
 					<li>' . $field['output_html'] . '</li>';
469 469
 
470 470
 		if (!empty($fields))
@@ -3106,8 +3106,7 @@  discard block
 block discarded – undo
3106 3106
 			<div class="roundframe">
3107 3107
 				<div>
3108 3108
 		', !empty($context['tfa_backup']) ? '
3109
-					<div class="smalltext error">' . $txt['tfa_backup_used_desc'] . '</div>' :
3110
-			($modSettings['tfa_mode'] == 2 ? '
3109
+					<div class="smalltext error">' . $txt['tfa_backup_used_desc'] . '</div>' : ($modSettings['tfa_mode'] == 2 ? '
3111 3110
 									<div class="smalltext"><strong>' . $txt['tfa_forced_desc'] . '</strong></div>' : ''), '
3112 3111
 									<div class="smalltext">', $txt['tfa_desc'], '</div>
3113 3112
 									<div class="floatleft">
Please login to merge, or discard this patch.
Braces   +523 added lines, -402 removed lines patch added patch discarded remove patch
@@ -18,23 +18,25 @@  discard block
 block discarded – undo
18 18
 	global $context;
19 19
 
20 20
 	// Prevent Chrome from auto completing fields when viewing/editing other members profiles
21
-	if (isBrowser('is_chrome') && !$context['user']['is_owner'])
22
-		echo '
21
+	if (isBrowser('is_chrome') && !$context['user']['is_owner']) {
22
+			echo '
23 23
 			<script>
24 24
 				disableAutoComplete();
25 25
 			</script>';
26
+	}
26 27
 
27 28
 	// If an error occurred while trying to save previously, give the user a clue!
28 29
 	echo '
29 30
 			', template_error_message();
30 31
 
31 32
 	// If the profile was update successfully, let the user know this.
32
-	if (!empty($context['profile_updated']))
33
-		echo '
33
+	if (!empty($context['profile_updated'])) {
34
+			echo '
34 35
 			<div class="infobox">
35 36
 				', $context['profile_updated'], '
36 37
 			</div>';
37
-}
38
+	}
39
+	}
38 40
 
39 41
 /**
40 42
  * Template for any HTML needed below the profile (closing off divs/tables, etc.)
@@ -99,19 +101,19 @@  discard block
 block discarded – undo
99 101
 		</div>
100 102
 		<div class="alerts_unread">';
101 103
 
102
-	if (empty($context['unread_alerts']))
103
-		template_alerts_all_read();
104
-
105
-	else
104
+	if (empty($context['unread_alerts'])) {
105
+			template_alerts_all_read();
106
+	} else
106 107
 	{
107
-		foreach ($context['unread_alerts'] as $id_alert => $details)
108
-			echo '
108
+		foreach ($context['unread_alerts'] as $id_alert => $details) {
109
+					echo '
109 110
 			<div class="unread">
110 111
 				', !empty($details['sender']) ? $details['sender']['avatar']['image'] : '', '
111 112
 				<div class="details">
112 113
 					', !empty($details['icon']) ? $details['icon'] : '', '<span>', $details['text'], '</span> - ', $details['time'], '
113 114
 				</div>
114 115
 			</div>';
116
+		}
115 117
 	}
116 118
 
117 119
 	echo '
@@ -158,37 +160,41 @@  discard block
 block discarded – undo
158 160
 	if (!empty($context['print_custom_fields']['above_member']))
159 161
 	{
160 162
 		$fields = '';
161
-		foreach ($context['print_custom_fields']['above_member'] as $field)
162
-			if (!empty($field['output_html']))
163
+		foreach ($context['print_custom_fields']['above_member'] as $field) {
164
+					if (!empty($field['output_html']))
163 165
 				$fields .= '
164 166
 					<li>' . $field['output_html'] . '</li>';
167
+		}
165 168
 
166
-		if (!empty($fields))
167
-			echo '
169
+		if (!empty($fields)) {
170
+					echo '
168 171
 			<div class="custom_fields_above_name">
169 172
 				<ul>', $fields, '
170 173
 				</ul>
171 174
 			</div>';
175
+		}
172 176
 	}
173 177
 
174 178
 	echo '
175 179
 			<div class="username clear">
176 180
 				<h4>';
177 181
 
178
-	if (!empty($context['print_custom_fields']['before_member']))
179
-		foreach ($context['print_custom_fields']['before_member'] as $field)
182
+	if (!empty($context['print_custom_fields']['before_member'])) {
183
+			foreach ($context['print_custom_fields']['before_member'] as $field)
180 184
 			if (!empty($field['output_html']))
181 185
 				echo '
182 186
 					<span>', $field['output_html'], '</span>';
187
+	}
183 188
 
184 189
 	echo '
185 190
 					', $context['member']['name'];
186 191
 
187
-	if (!empty($context['print_custom_fields']['after_member']))
188
-		foreach ($context['print_custom_fields']['after_member'] as $field)
192
+	if (!empty($context['print_custom_fields']['after_member'])) {
193
+			foreach ($context['print_custom_fields']['after_member'] as $field)
189 194
 			if (!empty($field['output_html']))
190 195
 				echo '
191 196
 					<span>', $field['output_html'], '</span>';
197
+	}
192 198
 
193 199
 
194 200
 	echo '
@@ -201,39 +207,44 @@  discard block
 block discarded – undo
201 207
 	if (!empty($context['print_custom_fields']['below_avatar']))
202 208
 	{
203 209
 		$fields = '';
204
-		foreach ($context['print_custom_fields']['below_avatar'] as $field)
205
-			if (!empty($field['output_html']))
210
+		foreach ($context['print_custom_fields']['below_avatar'] as $field) {
211
+					if (!empty($field['output_html']))
206 212
 				$fields .= '
207 213
 					<li>' . $field['output_html'] . '</li>';
214
+		}
208 215
 
209
-		if (!empty($fields))
210
-			echo '
216
+		if (!empty($fields)) {
217
+					echo '
211 218
 			<div class="custom_fields_below_avatar">
212 219
 				<ul>', $fields, '
213 220
 				</ul>
214 221
 			</div>';
222
+		}
215 223
 	}
216 224
 
217 225
 	echo '
218 226
 			<ul class="icon_fields clear">';
219 227
 
220 228
 	// Email is only visible if it's your profile or you have the moderate_forum permission
221
-	if ($context['member']['show_email'])
222
-		echo '
229
+	if ($context['member']['show_email']) {
230
+			echo '
223 231
 				<li><a href="mailto:', $context['member']['email'], '" title="', $context['member']['email'], '" rel="nofollow"><span class="generic_icons mail" title="' . $txt['email'] . '"></span></a></li>';
232
+	}
224 233
 
225 234
 	// Don't show an icon if they haven't specified a website.
226
-	if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website']))
227
-		echo '
235
+	if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website'])) {
236
+			echo '
228 237
 				<li><a href="', $context['member']['website']['url'], '" title="' . $context['member']['website']['title'] . '" target="_blank" rel="noopener">', ($settings['use_image_buttons'] ? '<span class="generic_icons www" title="' . $context['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>';
238
+	}
229 239
 
230 240
 	// Are there any custom profile fields as icons?
231 241
 	if (!empty($context['print_custom_fields']['icons']))
232 242
 	{
233
-		foreach ($context['print_custom_fields']['icons'] as $field)
234
-			if (!empty($field['output_html']))
243
+		foreach ($context['print_custom_fields']['icons'] as $field) {
244
+					if (!empty($field['output_html']))
235 245
 				echo '
236 246
 				<li class="custom_field">', $field['output_html'], '</li>';
247
+		}
237 248
 	}
238 249
 
239 250
 	echo '
@@ -242,24 +253,27 @@  discard block
 block discarded – undo
242 253
 				', $context['can_send_pm'] ? '<a href="' . $context['member']['online']['href'] . '" title="' . $context['member']['online']['text'] . '" rel="nofollow">' : '', $settings['use_image_buttons'] ? '<span class="' . ($context['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $context['member']['online']['text'] . '"></span>' : $context['member']['online']['label'], $context['can_send_pm'] ? '</a>' : '', $settings['use_image_buttons'] ? '<span class="smalltext"> ' . $context['member']['online']['label'] . '</span>' : '';
243 254
 
244 255
 	// Can they add this member as a buddy?
245
-	if (!empty($context['can_have_buddy']) && !$context['user']['is_owner'])
246
-		echo '
256
+	if (!empty($context['can_have_buddy']) && !$context['user']['is_owner']) {
257
+			echo '
247 258
 				<br>
248 259
 				<a href="', $scripturl, '?action=buddy;u=', $context['id_member'], ';', $context['session_var'], '=', $context['session_id'], '">[', $txt['buddy_' . ($context['member']['is_buddy'] ? 'remove' : 'add')], ']</a>';
260
+	}
249 261
 
250 262
 	echo '
251 263
 			</span>';
252 264
 
253
-	if (!$context['user']['is_owner'] && $context['can_send_pm'])
254
-		echo '
265
+	if (!$context['user']['is_owner'] && $context['can_send_pm']) {
266
+			echo '
255 267
 			<a href="', $scripturl, '?action=pm;sa=send;u=', $context['id_member'], '" class="infolinks">', $txt['profile_sendpm_short'], '</a>';
268
+	}
256 269
 
257 270
 	echo '
258 271
 			<a href="', $scripturl, '?action=profile;area=showposts;u=', $context['id_member'], '" class="infolinks">', $txt['showPosts'], '</a>';
259 272
 
260
-	if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled']))
261
-		echo '
273
+	if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled'])) {
274
+			echo '
262 275
 			<a href="', $scripturl, '?action=profile;area=showdrafts;u=', $context['id_member'], '" class="infolinks">', $txt['drafts_show'], '</a>';
276
+	}
263 277
 
264 278
 	echo '
265 279
 			<a href="', $scripturl, '?action=profile;area=statistics;u=', $context['id_member'], '" class="infolinks">', $txt['statPanel'], '</a>';
@@ -268,17 +282,19 @@  discard block
 block discarded – undo
268 282
 	if (!empty($context['print_custom_fields']['bottom_poster']))
269 283
 	{
270 284
 		$fields = '';
271
-		foreach ($context['print_custom_fields']['bottom_poster'] as $field)
272
-			if (!empty($field['output_html']))
285
+		foreach ($context['print_custom_fields']['bottom_poster'] as $field) {
286
+					if (!empty($field['output_html']))
273 287
 				$fields .= '
274 288
 					<li>' . $field['output_html'] . '</li>';
289
+		}
275 290
 
276
-		if (!empty($fields))
277
-			echo '
291
+		if (!empty($fields)) {
292
+					echo '
278 293
 			<div class="custom_fields_bottom">
279 294
 				<ul class="nolist">', $fields, '
280 295
 				</ul>
281 296
 			</div>';
297
+		}
282 298
 	}
283 299
 
284 300
 	echo '
@@ -287,30 +303,35 @@  discard block
 block discarded – undo
287 303
 		<div id="detailedinfo">
288 304
 			<dl class="settings">';
289 305
 
290
-	if ($context['user']['is_owner'] || $context['user']['is_admin'])
291
-		echo '
306
+	if ($context['user']['is_owner'] || $context['user']['is_admin']) {
307
+			echo '
292 308
 				<dt>', $txt['username'], ': </dt>
293 309
 				<dd>', $context['member']['username'], '</dd>';
310
+	}
294 311
 
295
-	if (!isset($context['disabled_fields']['posts']))
296
-		echo '
312
+	if (!isset($context['disabled_fields']['posts'])) {
313
+			echo '
297 314
 				<dt>', $txt['profile_posts'], ': </dt>
298 315
 				<dd>', $context['member']['posts'], ' (', $context['member']['posts_per_day'], ' ', $txt['posts_per_day'], ')</dd>';
316
+	}
299 317
 
300
-	if ($context['member']['show_email'])
301
-		echo '
318
+	if ($context['member']['show_email']) {
319
+			echo '
302 320
 				<dt>', $txt['email'], ': </dt>
303 321
 				<dd><a href="mailto:', $context['member']['email'], '">', $context['member']['email'], '</a></dd>';
322
+	}
304 323
 
305
-	if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title']))
306
-		echo '
324
+	if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title'])) {
325
+			echo '
307 326
 				<dt>', $txt['custom_title'], ': </dt>
308 327
 				<dd>', $context['member']['title'], '</dd>';
328
+	}
309 329
 
310
-	if (!empty($context['member']['blurb']))
311
-		echo '
330
+	if (!empty($context['member']['blurb'])) {
331
+			echo '
312 332
 				<dt>', $txt['personal_text'], ': </dt>
313 333
 				<dd>', $context['member']['blurb'], '</dd>';
334
+	}
314 335
 
315 336
 	echo '
316 337
 				<dt>', $txt['age'], ':</dt>
@@ -324,19 +345,21 @@  discard block
 block discarded – undo
324 345
 	{
325 346
 		$fields = array();
326 347
 
327
-		foreach ($context['print_custom_fields']['standard'] as $field)
328
-			if (!empty($field['output_html']))
348
+		foreach ($context['print_custom_fields']['standard'] as $field) {
349
+					if (!empty($field['output_html']))
329 350
 				$fields[] = $field;
351
+		}
330 352
 
331 353
 		if (count($fields) > 0)
332 354
 		{
333 355
 			echo '
334 356
 			<dl class="settings">';
335 357
 
336
-			foreach ($fields as $field)
337
-				echo '
358
+			foreach ($fields as $field) {
359
+							echo '
338 360
 				<dt>', $field['name'], ':</dt>
339 361
 				<dd>', $field['output_html'], '</dd>';
362
+			}
340 363
 
341 364
 			echo '
342 365
 			</dl>';
@@ -356,9 +379,10 @@  discard block
 block discarded – undo
356 379
 					<a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=', ($context['can_issue_warning'] && !$context['user']['is_owner'] ? 'issuewarning' : 'viewwarning'), '">', $context['member']['warning'], '%</a>';
357 380
 
358 381
 		// Can we provide information on what this means?
359
-		if (!empty($context['warning_status']))
360
-			echo '
382
+		if (!empty($context['warning_status'])) {
383
+					echo '
361 384
 					<span class="smalltext">(', $context['warning_status'], ')</span>';
385
+		}
362 386
 
363 387
 		echo '
364 388
 				</dd>';
@@ -369,11 +393,12 @@  discard block
 block discarded – undo
369 393
 	{
370 394
 
371 395
 		// If the person looking at the summary has permission, and the account isn't activated, give the viewer the ability to do it themselves.
372
-		if (!empty($context['activate_message']))
373
-			echo '
396
+		if (!empty($context['activate_message'])) {
397
+					echo '
374 398
 				<dt class="clear">
375 399
 					<span class="alert">', $context['activate_message'], '</span> (<a href="', $context['activate_link'], '"', ($context['activate_type'] == 4 ? ' class="you_sure" data-confirm="' . $txt['profileConfirm'] . '"' : ''), '>', $context['activate_link_text'], '</a>)
376 400
 				</dt>';
401
+		}
377 402
 
378 403
 		// If the current member is banned, show a message and possibly a link to the ban.
379 404
 		if (!empty($context['member']['bans']))
@@ -385,10 +410,11 @@  discard block
 block discarded – undo
385 410
 				<dt class="clear" id="ban_info" style="display: none;">
386 411
 					<strong>', $txt['user_banned_by_following'], ':</strong>';
387 412
 
388
-			foreach ($context['member']['bans'] as $ban)
389
-				echo '
413
+			foreach ($context['member']['bans'] as $ban) {
414
+							echo '
390 415
 					<br>
391 416
 					<span class="smalltext">', $ban['explanation'], '</span>';
417
+			}
392 418
 
393 419
 			echo '
394 420
 				</dt>';
@@ -402,30 +428,34 @@  discard block
 block discarded – undo
402 428
 	// If the person looking is allowed, they can check the members IP address and hostname.
403 429
 	if ($context['can_see_ip'])
404 430
 	{
405
-		if (!empty($context['member']['ip']))
406
-		echo '
431
+		if (!empty($context['member']['ip'])) {
432
+				echo '
407 433
 				<dt>', $txt['ip'], ': </dt>
408 434
 				<dd><a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['member']['ip'], ';u=', $context['member']['id'], '">', $context['member']['ip'], '</a></dd>';
435
+		}
409 436
 
410
-		if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip']))
411
-			echo '
437
+		if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip'])) {
438
+					echo '
412 439
 				<dt>', $txt['hostname'], ': </dt>
413 440
 				<dd>', $context['member']['hostname'], '</dd>';
441
+		}
414 442
 	}
415 443
 
416 444
 	echo '
417 445
 				<dt>', $txt['local_time'], ':</dt>
418 446
 				<dd>', $context['member']['local_time'], '</dd>';
419 447
 
420
-	if (!empty($modSettings['userLanguage']) && !empty($context['member']['language']))
421
-		echo '
448
+	if (!empty($modSettings['userLanguage']) && !empty($context['member']['language'])) {
449
+			echo '
422 450
 				<dt>', $txt['language'], ':</dt>
423 451
 				<dd>', $context['member']['language'], '</dd>';
452
+	}
424 453
 
425
-	if ($context['member']['show_last_login'])
426
-		echo '
454
+	if ($context['member']['show_last_login']) {
455
+			echo '
427 456
 				<dt>', $txt['lastLoggedIn'], ': </dt>
428 457
 				<dd>', $context['member']['last_login'], (!empty($context['member']['is_hidden']) ? ' (' . $txt['hidden'] . ')' : ''), '</dd>';
458
+	}
429 459
 
430 460
 	echo '
431 461
 			</dl>';
@@ -434,42 +464,47 @@  discard block
 block discarded – undo
434 464
 	if (!empty($context['print_custom_fields']['above_signature']))
435 465
 	{
436 466
 		$fields = '';
437
-		foreach ($context['print_custom_fields']['above_signature'] as $field)
438
-			if (!empty($field['output_html']))
467
+		foreach ($context['print_custom_fields']['above_signature'] as $field) {
468
+					if (!empty($field['output_html']))
439 469
 				$fields .= '
440 470
 					<li>' . $field['output_html'] . '</li>';
471
+		}
441 472
 
442
-		if (!empty($fields))
443
-			echo '
473
+		if (!empty($fields)) {
474
+					echo '
444 475
 			<div class="custom_fields_above_signature">
445 476
 				<ul class="nolist">', $fields, '
446 477
 				</ul>
447 478
 			</div>';
479
+		}
448 480
 	}
449 481
 
450 482
 	// Show the users signature.
451
-	if ($context['signature_enabled'] && !empty($context['member']['signature']))
452
-		echo '
483
+	if ($context['signature_enabled'] && !empty($context['member']['signature'])) {
484
+			echo '
453 485
 			<div class="signature">
454 486
 				<h5>', $txt['signature'], ':</h5>
455 487
 				', $context['member']['signature'], '
456 488
 			</div>';
489
+	}
457 490
 
458 491
 	// Are there any custom profile fields for below the signature?
459 492
 	if (!empty($context['print_custom_fields']['below_signature']))
460 493
 	{
461 494
 		$fields = '';
462
-		foreach ($context['print_custom_fields']['below_signature'] as $field)
463
-			if (!empty($field['output_html']))
495
+		foreach ($context['print_custom_fields']['below_signature'] as $field) {
496
+					if (!empty($field['output_html']))
464 497
 				$fields .=  '
465 498
 					<li>' . $field['output_html'] . '</li>';
499
+		}
466 500
 
467
-		if (!empty($fields))
468
-			echo '
501
+		if (!empty($fields)) {
502
+					echo '
469 503
 			<div class="custom_fields_below_signature">
470 504
 				<ul class="nolist">', $fields, '
471 505
 				</ul>
472 506
 			</div>';
507
+		}
473 508
 	}
474 509
 
475 510
 	echo '
@@ -511,62 +546,70 @@  discard block
 block discarded – undo
511 546
 			</div>
512 547
 			<div class="list_posts">';
513 548
 
514
-			if (!$post['approved'])
515
-				echo '
549
+			if (!$post['approved']) {
550
+							echo '
516 551
 				<div class="approve_post">
517 552
 					<em>', $txt['post_awaiting_approval'], '</em>
518 553
 				</div>';
554
+			}
519 555
 
520 556
 			echo '
521 557
 				', $post['body'], '
522 558
 			</div>';
523 559
 
524
-			if ($post['can_reply'] || $post['can_quote'] || $post['can_delete'])
525
-				echo '
560
+			if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) {
561
+							echo '
526 562
 			<div class="floatright">
527 563
 				<ul class="quickbuttons">';
564
+			}
528 565
 
529 566
 			// If they *can* reply?
530
-			if ($post['can_reply'])
531
-				echo '
567
+			if ($post['can_reply']) {
568
+							echo '
532 569
 					<li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>';
570
+			}
533 571
 
534 572
 			// If they *can* quote?
535
-			if ($post['can_quote'])
536
-				echo '
573
+			if ($post['can_quote']) {
574
+							echo '
537 575
 					<li><a href="', $scripturl . '?action=post;topic=', $post['topic'], '.', $post['start'], ';quote=', $post['id'], '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>';
576
+			}
538 577
 
539 578
 			// How about... even... remove it entirely?!
540
-			if ($post['can_delete'])
541
-				echo '
579
+			if ($post['can_delete']) {
580
+							echo '
542 581
 					<li><a href="', $scripturl, '?action=deletemsg;msg=', $post['id'], ';topic=', $post['topic'], ';profile;u=', $context['member']['id'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>';
582
+			}
543 583
 
544
-			if ($post['can_reply'] || $post['can_quote'] || $post['can_delete'])
545
-				echo '
584
+			if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) {
585
+							echo '
546 586
 				</ul>
547 587
 			</div><!-- .floatright -->';
588
+			}
548 589
 
549 590
 			echo '
550 591
 		</div><!-- $post[css_class] -->';
551 592
 		}
593
+	} else {
594
+			template_show_list('attachments');
552 595
 	}
553
-	else
554
-		template_show_list('attachments');
555 596
 
556 597
 	// No posts? Just end with a informative message.
557
-	if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts'])))
558
-		echo '
598
+	if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts']))) {
599
+			echo '
559 600
 		<div class="windowbg2">
560 601
 			', isset($context['attachments']) ? $txt['show_attachments_none'] : ($context['is_topics'] ? $txt['show_topics_none'] : $txt['show_posts_none']), '
561 602
 		</div>';
603
+	}
562 604
 
563 605
 	// Show more page numbers.
564
-	if (!empty($context['page_index']))
565
-		echo '
606
+	if (!empty($context['page_index'])) {
607
+			echo '
566 608
 		<div class="pagesection">
567 609
 			<div class="pagelinks">', $context['page_index'], '</div>
568 610
 		</div>';
569
-}
611
+	}
612
+	}
570 613
 
571 614
 /**
572 615
  * Template for showing alerts within the alerts popup
@@ -576,11 +619,12 @@  discard block
 block discarded – undo
576 619
 	global $context, $txt, $scripturl;
577 620
 
578 621
 	// Do we have an update message?
579
-	if (!empty($context['update_message']))
580
-		echo '
622
+	if (!empty($context['update_message'])) {
623
+			echo '
581 624
 		<div class="infobox">
582 625
 			', $context['update_message'], '
583 626
 		</div>';
627
+	}
584 628
 
585 629
 	echo '
586 630
 		<div class="cat_bar">
@@ -589,13 +633,12 @@  discard block
 block discarded – undo
589 633
 			</h3>
590 634
 		</div>';
591 635
 
592
-	if (empty($context['alerts']))
593
-		echo '
636
+	if (empty($context['alerts'])) {
637
+			echo '
594 638
 		<div class="information">
595 639
 			', $txt['alerts_none'], '
596 640
 		</div>';
597
-
598
-	else
641
+	} else
599 642
 	{
600 643
 		// Start the form.
601 644
 		echo '
@@ -657,12 +700,12 @@  discard block
 block discarded – undo
657 700
 		</div>' : '';
658 701
 
659 702
 	// No drafts? Just show an informative message.
660
-	if (empty($context['drafts']))
661
-		echo '
703
+	if (empty($context['drafts'])) {
704
+			echo '
662 705
 		<div class="windowbg2 centertext">
663 706
 			', $txt['draft_none'], '
664 707
 		</div>';
665
-	else
708
+	} else
666 709
 	{
667 710
 		// For every draft to be displayed, give it its own div, and show the important details of the draft.
668 711
 		foreach ($context['drafts'] as $draft)
@@ -674,13 +717,15 @@  discard block
 block discarded – undo
674 717
 				<h5>
675 718
 					<strong><a href="', $scripturl, '?board=', $draft['board']['id'], '.0">', $draft['board']['name'], '</a> / ', $draft['topic']['link'], '</strong> &nbsp; &nbsp;';
676 719
 
677
-			if (!empty($draft['sticky']))
678
-				echo '
720
+			if (!empty($draft['sticky'])) {
721
+							echo '
679 722
 					<span class="generic_icons sticky" title="', $txt['sticky_topic'], '"></span>';
723
+			}
680 724
 
681
-			if (!empty($draft['locked']))
682
-				echo '
725
+			if (!empty($draft['locked'])) {
726
+							echo '
683 727
 					<span class="generic_icons lock" title="', $txt['locked_topic'], '"></span>';
728
+			}
684 729
 
685 730
 			echo '
686 731
 				</h5>
@@ -713,13 +758,13 @@  discard block
 block discarded – undo
713 758
 {
714 759
 	global $context, $scripturl, $txt;
715 760
 
716
-	if (!empty($context['saved_successful']))
717
-		echo '
761
+	if (!empty($context['saved_successful'])) {
762
+			echo '
718 763
 	<div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>';
719
-
720
-	elseif (!empty($context['saved_failed']))
721
-		echo '
764
+	} elseif (!empty($context['saved_failed'])) {
765
+			echo '
722 766
 	<div class="errorbox">', $context['saved_failed'], '</div>';
767
+	}
723 768
 
724 769
 	echo '
725 770
 	<div id="edit_buddies">
@@ -734,14 +779,16 @@  discard block
 block discarded – undo
734 779
 					<th scope="col" class="quarter_table">', $txt['name'], '</th>
735 780
 					<th scope="col">', $txt['status'], '</th>';
736 781
 
737
-	if (allowedTo('moderate_forum'))
738
-		echo '
782
+	if (allowedTo('moderate_forum')) {
783
+			echo '
739 784
 					<th scope="col">', $txt['email'], '</th>';
785
+	}
740 786
 
741
-	if (!empty($context['custom_pf']))
742
-		foreach ($context['custom_pf'] as $column)
787
+	if (!empty($context['custom_pf'])) {
788
+			foreach ($context['custom_pf'] as $column)
743 789
 				echo '
744 790
 					<th scope="col">', $column['label'], '</th>';
791
+	}
745 792
 
746 793
 	echo '
747 794
 					<th scope="col">', $txt['remove'], '</th>
@@ -750,13 +797,14 @@  discard block
 block discarded – undo
750 797
 			<tbody>';
751 798
 
752 799
 	// If they don't have any buddies don't list them!
753
-	if (empty($context['buddies']))
754
-		echo '
800
+	if (empty($context['buddies'])) {
801
+			echo '
755 802
 				<tr class="windowbg">
756 803
 					<td colspan="', allowedTo('moderate_forum') ? '10' : '9', '">
757 804
 						<strong>', $txt['no_buddies'], '</strong>
758 805
 					</td>
759 806
 				</tr>';
807
+	}
760 808
 
761 809
 		// Now loop through each buddy showing info on each.
762 810
 	else
@@ -770,17 +818,19 @@  discard block
 block discarded – undo
770 818
 						<a href="', $buddy['online']['href'], '"><span class="' . ($buddy['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $buddy['online']['text'] . '"></span></a>
771 819
 					</td>';
772 820
 
773
-			if ($buddy['show_email'])
774
-				echo '
821
+			if ($buddy['show_email']) {
822
+							echo '
775 823
 					<td>
776 824
 						<a href="mailto:' . $buddy['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $buddy['name'] . '"></span></a>
777 825
 					</td>';
826
+			}
778 827
 
779 828
 			// Show the custom profile fields for this user.
780
-			if (!empty($context['custom_pf']))
781
-				foreach ($context['custom_pf'] as $key => $column)
829
+			if (!empty($context['custom_pf'])) {
830
+							foreach ($context['custom_pf'] as $key => $column)
782 831
 					echo '
783 832
 					<td class="lefttext">', $buddy['options'][$key], '</td>';
833
+			}
784 834
 
785 835
 			echo '
786 836
 					<td>
@@ -813,9 +863,10 @@  discard block
 block discarded – undo
813 863
 			</dl>
814 864
 		</div>';
815 865
 
816
-	if (!empty($context['token_check']))
817
-		echo '
866
+	if (!empty($context['token_check'])) {
867
+			echo '
818 868
 		<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
869
+	}
819 870
 
820 871
 	echo '
821 872
 		<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -841,13 +892,13 @@  discard block
 block discarded – undo
841 892
 {
842 893
 	global $context, $scripturl, $txt;
843 894
 
844
-	if (!empty($context['saved_successful']))
845
-		echo '
895
+	if (!empty($context['saved_successful'])) {
896
+			echo '
846 897
 	<div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>';
847
-
848
-	elseif (!empty($context['saved_failed']))
849
-		echo '
898
+	} elseif (!empty($context['saved_failed'])) {
899
+			echo '
850 900
 	<div class="errorbox">', $context['saved_failed'], '</div>';
901
+	}
851 902
 
852 903
 	echo '
853 904
 	<div id="edit_buddies">
@@ -862,9 +913,10 @@  discard block
 block discarded – undo
862 913
 					<th scope="col" class="quarter_table">', $txt['name'], '</th>
863 914
 					<th scope="col">', $txt['status'], '</th>';
864 915
 
865
-	if (allowedTo('moderate_forum'))
866
-		echo '
916
+	if (allowedTo('moderate_forum')) {
917
+			echo '
867 918
 					<th scope="col">', $txt['email'], '</th>';
919
+	}
868 920
 
869 921
 	echo '
870 922
 					<th scope="col">', $txt['ignore_remove'], '</th>
@@ -873,13 +925,14 @@  discard block
 block discarded – undo
873 925
 			<tbody>';
874 926
 
875 927
 	// If they don't have anyone on their ignore list, don't list it!
876
-	if (empty($context['ignore_list']))
877
-		echo '
928
+	if (empty($context['ignore_list'])) {
929
+			echo '
878 930
 				<tr class="windowbg">
879 931
 					<td colspan="', allowedTo('moderate_forum') ? '4' : '3', '">
880 932
 						<strong>', $txt['no_ignore'], '</strong>
881 933
 					</td>
882 934
 				</tr>';
935
+	}
883 936
 
884 937
 	// Now loop through each buddy showing info on each.
885 938
 	foreach ($context['ignore_list'] as $member)
@@ -891,11 +944,12 @@  discard block
 block discarded – undo
891 944
 						<a href="', $member['online']['href'], '"><span class="' . ($member['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $member['online']['text'] . '"></span></a>
892 945
 					</td>';
893 946
 
894
-		if ($member['show_email'])
895
-			echo '
947
+		if ($member['show_email']) {
948
+					echo '
896 949
 					<td>
897 950
 						<a href="mailto:' . $member['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $member['name'] . '"></span></a>
898 951
 					</td>';
952
+		}
899 953
 		echo '
900 954
 					<td>
901 955
 						<a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=lists;sa=ignore;remove=', $member['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons delete" title="', $txt['ignore_remove'], '"></span></a>
@@ -925,9 +979,10 @@  discard block
 block discarded – undo
925 979
 			</dl>
926 980
 		</div>';
927 981
 
928
-	if (!empty($context['token_check']))
929
-		echo '
982
+	if (!empty($context['token_check'])) {
983
+			echo '
930 984
 		<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
985
+	}
931 986
 
932 987
 	echo '
933 988
 		<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -973,9 +1028,10 @@  discard block
 block discarded – undo
973 1028
 					<a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip'], ';u=', $context['member']['id'], '">', $context['last_ip'], '</a>';
974 1029
 
975 1030
 	// Second address detected?
976
-	if (!empty($context['last_ip2']))
977
-		echo '
1031
+	if (!empty($context['last_ip2'])) {
1032
+			echo '
978 1033
 					, <a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip2'], ';u=', $context['member']['id'], '">', $context['last_ip2'], '</a>';
1034
+	}
979 1035
 
980 1036
 	echo '
981 1037
 				</dd>';
@@ -1041,9 +1097,10 @@  discard block
 block discarded – undo
1041 1097
 		</div>
1042 1098
 		<div class="windowbg2 noup">';
1043 1099
 
1044
-		foreach ($context['whois_servers'] as $server)
1045
-			echo '
1100
+		foreach ($context['whois_servers'] as $server) {
1101
+					echo '
1046 1102
 			<a href="', $server['url'], '" target="_blank" rel="noopener"', '>', $server['name'], '</a><br>';
1103
+		}
1047 1104
 		echo '
1048 1105
 		</div>
1049 1106
 		<br>';
@@ -1055,13 +1112,12 @@  discard block
 block discarded – undo
1055 1112
 			<h3 class="catbg">', $txt['members_from_ip'], ' ', $context['ip'], '</h3>
1056 1113
 		</div>';
1057 1114
 
1058
-	if (empty($context['ips']))
1059
-		echo '
1115
+	if (empty($context['ips'])) {
1116
+			echo '
1060 1117
 		<p class="windowbg2 description">
1061 1118
 			<em>', $txt['no_members_from_ip'], '</em>
1062 1119
 		</p>';
1063
-
1064
-	else
1120
+	} else
1065 1121
 	{
1066 1122
 		echo '
1067 1123
 		<table class="table_grid">
@@ -1074,12 +1130,13 @@  discard block
 block discarded – undo
1074 1130
 			<tbody>';
1075 1131
 
1076 1132
 		// Loop through each of the members and display them.
1077
-		foreach ($context['ips'] as $ip => $memberlist)
1078
-			echo '
1133
+		foreach ($context['ips'] as $ip => $memberlist) {
1134
+					echo '
1079 1135
 				<tr class="windowbg">
1080 1136
 					<td><a href="', $context['base_url'], ';searchip=', $ip, '">', $ip, '</a></td>
1081 1137
 					<td>', implode(', ', $memberlist), '</td>
1082 1138
 				</tr>';
1139
+		}
1083 1140
 
1084 1141
 		echo '
1085 1142
 			</tbody>
@@ -1121,11 +1178,10 @@  discard block
 block discarded – undo
1121 1178
 			</h3>
1122 1179
 		</div>';
1123 1180
 
1124
-	if ($context['member']['has_all_permissions'])
1125
-		echo '
1181
+	if ($context['member']['has_all_permissions']) {
1182
+			echo '
1126 1183
 		<div class="information">', $txt['showPermissions_all'], '</div>';
1127
-
1128
-	else
1184
+	} else
1129 1185
 	{
1130 1186
 		echo '
1131 1187
 		<div class="information">',$txt['showPermissions_help'], '</div>
@@ -1140,9 +1196,10 @@  discard block
 block discarded – undo
1140 1196
 			<div class="windowbg smalltext">
1141 1197
 				', $txt['showPermissions_restricted_boards_desc'], ':<br>';
1142 1198
 
1143
-			foreach ($context['no_access_boards'] as $no_access_board)
1144
-				echo '
1199
+			foreach ($context['no_access_boards'] as $no_access_board) {
1200
+							echo '
1145 1201
 				<a href="', $scripturl, '?board=', $no_access_board['id'], '.0">', $no_access_board['name'], '</a>', $no_access_board['is_last'] ? '' : ', ';
1202
+			}
1146 1203
 			echo '
1147 1204
 			</div>';
1148 1205
 		}
@@ -1174,12 +1231,13 @@  discard block
 block discarded – undo
1174 1231
 							</td>
1175 1232
 							<td class="smalltext">';
1176 1233
 
1177
-				if ($permission['is_denied'])
1178
-					echo '
1234
+				if ($permission['is_denied']) {
1235
+									echo '
1179 1236
 								<span class="alert">', $txt['showPermissions_denied'], ': ', implode(', ', $permission['groups']['denied']), '</span>';
1180
-				else
1181
-					echo '
1237
+				} else {
1238
+									echo '
1182 1239
 								', $txt['showPermissions_given'], ': ', implode(', ', $permission['groups']['allowed']);
1240
+				}
1183 1241
 
1184 1242
 				echo '
1185 1243
 							</td>
@@ -1190,10 +1248,10 @@  discard block
 block discarded – undo
1190 1248
 				</table>
1191 1249
 			</div><!-- .tborder -->
1192 1250
 			<br>';
1193
-		}
1194
-		else
1195
-			echo '
1251
+		} else {
1252
+					echo '
1196 1253
 			<p class="windowbg2">', $txt['showPermissions_none_general'], '</p>';
1254
+		}
1197 1255
 
1198 1256
 		// Board permission section.
1199 1257
 		echo '
@@ -1204,14 +1262,16 @@  discard block
 block discarded – undo
1204 1262
 						<select name="board" onchange="if (this.options[this.selectedIndex].value) this.form.submit();">
1205 1263
 							<option value="0"', $context['board'] == 0 ? ' selected' : '', '>', $txt['showPermissions_global'], '</option>';
1206 1264
 
1207
-		if (!empty($context['boards']))
1208
-			echo '
1265
+		if (!empty($context['boards'])) {
1266
+					echo '
1209 1267
 							<option value="" disabled>---------------------------</option>';
1268
+		}
1210 1269
 
1211 1270
 		// Fill the box with any local permission boards.
1212
-		foreach ($context['boards'] as $board)
1213
-			echo '
1271
+		foreach ($context['boards'] as $board) {
1272
+					echo '
1214 1273
 							<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['name'], ' (', $board['profile_name'], ')</option>';
1274
+		}
1215 1275
 
1216 1276
 		echo '
1217 1277
 						</select>
@@ -1240,13 +1300,13 @@  discard block
 block discarded – undo
1240 1300
 						</td>
1241 1301
 						<td class="smalltext">';
1242 1302
 
1243
-				if ($permission['is_denied'])
1244
-					echo '
1303
+				if ($permission['is_denied']) {
1304
+									echo '
1245 1305
 							<span class="alert">', $txt['showPermissions_denied'], ': ', implode(', ', $permission['groups']['denied']), '</span>';
1246
-
1247
-				else
1248
-					echo '
1306
+				} else {
1307
+									echo '
1249 1308
 							', $txt['showPermissions_given'], ': ', implode(', ', $permission['groups']['allowed']);
1309
+				}
1250 1310
 
1251 1311
 				echo '
1252 1312
 						</td>
@@ -1255,10 +1315,10 @@  discard block
 block discarded – undo
1255 1315
 			echo '
1256 1316
 				</tbody>
1257 1317
 			</table>';
1258
-		}
1259
-		else
1260
-			echo '
1318
+		} else {
1319
+					echo '
1261 1320
 			<p class="windowbg2">', $txt['showPermissions_none_board'], '</p>';
1321
+		}
1262 1322
 	echo '
1263 1323
 		</div><!-- #permissions -->';
1264 1324
 	}
@@ -1299,9 +1359,10 @@  discard block
 block discarded – undo
1299 1359
 			</div>';
1300 1360
 
1301 1361
 	// If they haven't post at all, don't draw the graph.
1302
-	if (empty($context['posts_by_time']))
1303
-		echo '
1362
+	if (empty($context['posts_by_time'])) {
1363
+			echo '
1304 1364
 			<p class="centertext padding">', $txt['statPanel_noPosts'], '</p>';
1365
+	}
1305 1366
 
1306 1367
 	// Otherwise do!
1307 1368
 	else
@@ -1310,8 +1371,8 @@  discard block
 block discarded – undo
1310 1371
 			<ul class="activity_stats flow_hidden">';
1311 1372
 
1312 1373
 		// The labels.
1313
-		foreach ($context['posts_by_time'] as $time_of_day)
1314
-			echo '
1374
+		foreach ($context['posts_by_time'] as $time_of_day) {
1375
+					echo '
1315 1376
 				<li', $time_of_day['is_last'] ? ' class="last"' : '', '>
1316 1377
 					<div class="bar" style="padding-top: ', ((int) (100 - $time_of_day['relative_percent'])), 'px;" title="', sprintf($txt['statPanel_activityTime_posts'], $time_of_day['posts'], $time_of_day['posts_percent']), '">
1317 1378
 						<div style="height: ', (int) $time_of_day['relative_percent'], 'px;">
@@ -1320,6 +1381,7 @@  discard block
 block discarded – undo
1320 1381
 					</div>
1321 1382
 					<span class="stats_hour">', $time_of_day['hour_format'], '</span>
1322 1383
 				</li>';
1384
+		}
1323 1385
 
1324 1386
 		echo '
1325 1387
 			</ul>';
@@ -1338,11 +1400,10 @@  discard block
 block discarded – undo
1338 1400
 					</h3>
1339 1401
 				</div>';
1340 1402
 
1341
-	if (empty($context['popular_boards']))
1342
-		echo '
1403
+	if (empty($context['popular_boards'])) {
1404
+			echo '
1343 1405
 				<p class="centertext padding">', $txt['statPanel_noPosts'], '</p>';
1344
-
1345
-	else
1406
+	} else
1346 1407
 	{
1347 1408
 		echo '
1348 1409
 				<dl class="stats">';
@@ -1372,10 +1433,10 @@  discard block
 block discarded – undo
1372 1433
 					</h3>
1373 1434
 				</div>';
1374 1435
 
1375
-	if (empty($context['board_activity']))
1376
-		echo '
1436
+	if (empty($context['board_activity'])) {
1437
+			echo '
1377 1438
 				<p class="centertext padding">', $txt['statPanel_noPosts'], '</p>';
1378
-	else
1439
+	} else
1379 1440
 	{
1380 1441
 		echo '
1381 1442
 				<dl class="stats">';
@@ -1426,90 +1487,97 @@  discard block
 block discarded – undo
1426 1487
 				<h3 class="catbg profile_hd">';
1427 1488
 
1428 1489
 		// Don't say "Profile" if this isn't the profile...
1429
-		if (!empty($context['profile_header_text']))
1430
-			echo '
1490
+		if (!empty($context['profile_header_text'])) {
1491
+					echo '
1431 1492
 					', $context['profile_header_text'];
1432
-		else
1433
-			echo '
1493
+		} else {
1494
+					echo '
1434 1495
 					', $txt['profile'];
1496
+		}
1435 1497
 
1436 1498
 		echo '
1437 1499
 				</h3>
1438 1500
 			</div>';
1439 1501
 
1440 1502
 	// Have we some description?
1441
-	if ($context['page_desc'])
1442
-		echo '
1503
+	if ($context['page_desc']) {
1504
+			echo '
1443 1505
 			<p class="information">', $context['page_desc'], '</p>';
1506
+	}
1444 1507
 
1445 1508
 	echo '
1446 1509
 			<div class="roundframe">';
1447 1510
 
1448 1511
 	// Any bits at the start?
1449
-	if (!empty($context['profile_prehtml']))
1450
-		echo '
1512
+	if (!empty($context['profile_prehtml'])) {
1513
+			echo '
1451 1514
 				<div>', $context['profile_prehtml'], '</div>';
1515
+	}
1452 1516
 
1453
-	if (!empty($context['profile_fields']))
1454
-		echo '
1517
+	if (!empty($context['profile_fields'])) {
1518
+			echo '
1455 1519
 				<dl class="settings">';
1520
+	}
1456 1521
 
1457 1522
 	// Start the big old loop 'of love.
1458 1523
 	$lastItem = 'hr';
1459 1524
 	foreach ($context['profile_fields'] as $key => $field)
1460 1525
 	{
1461 1526
 		// We add a little hack to be sure we never get more than one hr in a row!
1462
-		if ($lastItem == 'hr' && $field['type'] == 'hr')
1463
-			continue;
1527
+		if ($lastItem == 'hr' && $field['type'] == 'hr') {
1528
+					continue;
1529
+		}
1464 1530
 
1465 1531
 		$lastItem = $field['type'];
1466
-		if ($field['type'] == 'hr')
1467
-			echo '
1532
+		if ($field['type'] == 'hr') {
1533
+					echo '
1468 1534
 				</dl>
1469 1535
 				<hr>
1470 1536
 				<dl class="settings">';
1471
-
1472
-		elseif ($field['type'] == 'callback')
1537
+		} elseif ($field['type'] == 'callback')
1473 1538
 		{
1474 1539
 			if (isset($field['callback_func']) && function_exists('template_profile_' . $field['callback_func']))
1475 1540
 			{
1476 1541
 				$callback_func = 'template_profile_' . $field['callback_func'];
1477 1542
 				$callback_func();
1478 1543
 			}
1479
-		}
1480
-		else
1544
+		} else
1481 1545
 		{
1482 1546
 			echo '
1483 1547
 					<dt>
1484 1548
 						<strong', !empty($field['is_error']) ? ' class="error"' : '', '>', $field['type'] !== 'label' ? '<label for="' . $key . '">' : '', $field['label'], $field['type'] !== 'label' ? '</label>' : '', '</strong>';
1485 1549
 
1486 1550
 			// Does it have any subtext to show?
1487
-			if (!empty($field['subtext']))
1488
-				echo '
1551
+			if (!empty($field['subtext'])) {
1552
+							echo '
1489 1553
 						<br>
1490 1554
 						<span class="smalltext">', $field['subtext'], '</span>';
1555
+			}
1491 1556
 
1492 1557
 			echo '
1493 1558
 					</dt>
1494 1559
 					<dd>';
1495 1560
 
1496 1561
 			// Want to put something infront of the box?
1497
-			if (!empty($field['preinput']))
1498
-				echo '
1562
+			if (!empty($field['preinput'])) {
1563
+							echo '
1499 1564
 						', $field['preinput'];
1565
+			}
1500 1566
 
1501 1567
 			// What type of data are we showing?
1502
-			if ($field['type'] == 'label')
1503
-				echo '
1568
+			if ($field['type'] == 'label') {
1569
+							echo '
1504 1570
 						', $field['value'];
1571
+			}
1505 1572
 
1506 1573
 			// Maybe it's a text box - very likely!
1507 1574
 			elseif (in_array($field['type'], array('int', 'float', 'text', 'password', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'number', 'time', 'url')))
1508 1575
 			{
1509
-				if ($field['type'] == 'int' || $field['type'] == 'float')
1510
-					$type = 'number';
1511
-				else
1512
-					$type = $field['type'];
1576
+				if ($field['type'] == 'int' || $field['type'] == 'float') {
1577
+									$type = 'number';
1578
+				} else {
1579
+									$type = $field['type'];
1580
+				}
1513 1581
 				$step = $field['type'] == 'float' ? ' step="0.1"' : '';
1514 1582
 
1515 1583
 
@@ -1517,10 +1585,11 @@  discard block
 block discarded – undo
1517 1585
 						<input type="', $type, '" name="', $key, '" id="', $key, '" size="', empty($field['size']) ? 30 : $field['size'], '" value="', $field['value'], '" ', $field['input_attr'], ' ', $step, '>';
1518 1586
 			}
1519 1587
 			// You "checking" me out? ;)
1520
-			elseif ($field['type'] == 'check')
1521
-				echo '
1588
+			elseif ($field['type'] == 'check') {
1589
+							echo '
1522 1590
 						<input type="hidden" name="', $key, '" value="0">
1523 1591
 						<input type="checkbox" name="', $key, '" id="', $key, '"', !empty($field['value']) ? ' checked' : '', ' value="1" ', $field['input_attr'], '>';
1592
+			}
1524 1593
 
1525 1594
 			// Always fun - select boxes!
1526 1595
 			elseif ($field['type'] == 'select')
@@ -1531,14 +1600,16 @@  discard block
 block discarded – undo
1531 1600
 				if (isset($field['options']))
1532 1601
 				{
1533 1602
 					// Is this some code to generate the options?
1534
-					if (!is_array($field['options']))
1535
-						$field['options'] = $field['options']();
1603
+					if (!is_array($field['options'])) {
1604
+											$field['options'] = $field['options']();
1605
+					}
1536 1606
 
1537 1607
 					// Assuming we now have some!
1538
-					if (is_array($field['options']))
1539
-						foreach ($field['options'] as $value => $name)
1608
+					if (is_array($field['options'])) {
1609
+											foreach ($field['options'] as $value => $name)
1540 1610
 							echo '
1541 1611
 							<option value="', $value, '"', $value == $field['value'] ? ' selected' : '', '>', $name, '</option>';
1612
+					}
1542 1613
 				}
1543 1614
 
1544 1615
 				echo '
@@ -1546,31 +1617,34 @@  discard block
 block discarded – undo
1546 1617
 			}
1547 1618
 
1548 1619
 			// Something to end with?
1549
-			if (!empty($field['postinput']))
1550
-				echo '
1620
+			if (!empty($field['postinput'])) {
1621
+							echo '
1551 1622
 						', $field['postinput'];
1623
+			}
1552 1624
 
1553 1625
 			echo '
1554 1626
 					</dd>';
1555 1627
 		}
1556 1628
 	}
1557 1629
 
1558
-	if (!empty($context['profile_fields']))
1559
-		echo '
1630
+	if (!empty($context['profile_fields'])) {
1631
+			echo '
1560 1632
 				</dl>';
1633
+	}
1561 1634
 
1562 1635
 	// Are there any custom profile fields - if so print them!
1563 1636
 	if (!empty($context['custom_fields']))
1564 1637
 	{
1565
-		if ($lastItem != 'hr')
1566
-			echo '
1638
+		if ($lastItem != 'hr') {
1639
+					echo '
1567 1640
 				<hr>';
1641
+		}
1568 1642
 
1569 1643
 		echo '
1570 1644
 				<dl class="settings">';
1571 1645
 
1572
-		foreach ($context['custom_fields'] as $field)
1573
-			echo '
1646
+		foreach ($context['custom_fields'] as $field) {
1647
+					echo '
1574 1648
 					<dt>
1575 1649
 						<strong>', $field['name'], ': </strong><br>
1576 1650
 						<span class="smalltext">', $field['desc'], '</span>
@@ -1578,6 +1652,7 @@  discard block
 block discarded – undo
1578 1652
 					<dd>
1579 1653
 						', $field['input_html'], '
1580 1654
 					</dd>';
1655
+		}
1581 1656
 
1582 1657
 		echo '
1583 1658
 				</dl>';
@@ -1585,13 +1660,14 @@  discard block
 block discarded – undo
1585 1660
 	}
1586 1661
 
1587 1662
 	// Any closing HTML?
1588
-	if (!empty($context['profile_posthtml']))
1589
-		echo '
1663
+	if (!empty($context['profile_posthtml'])) {
1664
+			echo '
1590 1665
 				<div>', $context['profile_posthtml'], '</div>';
1666
+	}
1591 1667
 
1592 1668
 	// Only show the password box if it's actually needed.
1593
-	if ($context['require_password'])
1594
-		echo '
1669
+	if ($context['require_password']) {
1670
+			echo '
1595 1671
 				<dl class="settings">
1596 1672
 					<dt>
1597 1673
 						<strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '><label for="oldpasswrd">', $txt['current_password'], ': </label></strong><br>
@@ -1601,18 +1677,21 @@  discard block
 block discarded – undo
1601 1677
 						<input type="password" name="oldpasswrd" id="oldpasswrd" size="20">
1602 1678
 					</dd>
1603 1679
 				</dl>';
1680
+	}
1604 1681
 
1605 1682
 	// The button shouldn't say "Change profile" unless we're changing the profile...
1606
-	if (!empty($context['submit_button_text']))
1607
-		echo '
1683
+	if (!empty($context['submit_button_text'])) {
1684
+			echo '
1608 1685
 				<input type="submit" name="save" value="', $context['submit_button_text'], '" class="button floatright">';
1609
-	else
1610
-		echo '
1686
+	} else {
1687
+			echo '
1611 1688
 				<input type="submit" name="save" value="', $txt['change_profile'], '" class="button floatright">';
1689
+	}
1612 1690
 
1613
-	if (!empty($context['token_check']))
1614
-		echo '
1691
+	if (!empty($context['token_check'])) {
1692
+			echo '
1615 1693
 				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
1694
+	}
1616 1695
 
1617 1696
 	echo '
1618 1697
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -1622,10 +1701,11 @@  discard block
 block discarded – undo
1622 1701
 		</form>';
1623 1702
 
1624 1703
 	// Any final spellchecking stuff?
1625
-	if (!empty($context['show_spellchecking']))
1626
-		echo '
1704
+	if (!empty($context['show_spellchecking'])) {
1705
+			echo '
1627 1706
 		<form name="spell_form" id="spell_form" method="post" accept-charset="', $context['character_set'], '" target="spellWindow" action="', $scripturl, '?action=spellcheck"><input type="hidden" name="spellstring" value=""></form>';
1628
-}
1707
+	}
1708
+	}
1629 1709
 
1630 1710
 /**
1631 1711
  * Personal Message settings.
@@ -1662,10 +1742,11 @@  discard block
 block discarded – undo
1662 1742
 						<select name="pm_receive_from" id="pm_receive_from">
1663 1743
 							<option value="0"', empty($context['receive_from']) || (empty($modSettings['enable_buddylist']) && $context['receive_from'] < 3) ? ' selected' : '', '>', $txt['pm_receive_from_everyone'], '</option>';
1664 1744
 
1665
-	if (!empty($modSettings['enable_buddylist']))
1666
-		echo '
1745
+	if (!empty($modSettings['enable_buddylist'])) {
1746
+			echo '
1667 1747
 							<option value="1"', !empty($context['receive_from']) && $context['receive_from'] == 1 ? ' selected' : '', '>', $txt['pm_receive_from_ignore'], '</option>
1668 1748
 							<option value="2"', !empty($context['receive_from']) && $context['receive_from'] == 2 ? ' selected' : '', '>', $txt['pm_receive_from_buddies'], '</option>';
1749
+	}
1669 1750
 
1670 1751
 	echo '
1671 1752
 							<option value="3"', !empty($context['receive_from']) && $context['receive_from'] > 2 ? ' selected' : '', '>', $txt['pm_receive_from_admins'], '</option>
@@ -1708,11 +1789,12 @@  discard block
 block discarded – undo
1708 1789
 		if (empty($setting) || !is_array($setting))
1709 1790
 		{
1710 1791
 			// Insert a separator (unless this is the first item in the list)
1711
-			if ($i !== $first_option_key)
1712
-				echo '
1792
+			if ($i !== $first_option_key) {
1793
+							echo '
1713 1794
 				</dl>
1714 1795
 				<hr>
1715 1796
 				<dl class="settings">';
1797
+			}
1716 1798
 
1717 1799
 			// Should we give a name to this section?
1718 1800
 			if (is_string($setting) && !empty($setting))
@@ -1721,69 +1803,67 @@  discard block
 block discarded – undo
1721 1803
 				echo '
1722 1804
 					<dt><strong>' . $setting . '</strong></dt>
1723 1805
 					<dd></dd>';
1806
+			} else {
1807
+							$titled_section = false;
1724 1808
 			}
1725
-			else
1726
-				$titled_section = false;
1727 1809
 
1728 1810
 			continue;
1729 1811
 		}
1730 1812
 
1731 1813
 		// Is this disabled?
1732
-		if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled']))
1733
-			continue;
1734
-
1735
-		elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage']))
1736
-			continue;
1737
-
1738
-		elseif ($setting['id'] == 'show_no_censored' && empty($modSettings['allow_no_censored']))
1739
-			continue;
1740
-
1741
-		elseif ($setting['id'] == 'posts_apply_ignore_list' && empty($modSettings['enable_buddylist']))
1742
-			continue;
1743
-
1744
-		elseif ($setting['id'] == 'wysiwyg_default' && !empty($modSettings['disable_wysiwyg']))
1745
-			continue;
1746
-
1747
-		elseif ($setting['id'] == 'drafts_autosave_enabled' && (empty($modSettings['drafts_autosave_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled']))))
1748
-			continue;
1749
-
1750
-		elseif ($setting['id'] == 'drafts_show_saved_enabled' && (empty($modSettings['drafts_show_saved_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled']))))
1751
-			continue;
1814
+		if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled'])) {
1815
+					continue;
1816
+		} elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) {
1817
+					continue;
1818
+		} elseif ($setting['id'] == 'show_no_censored' && empty($modSettings['allow_no_censored'])) {
1819
+					continue;
1820
+		} elseif ($setting['id'] == 'posts_apply_ignore_list' && empty($modSettings['enable_buddylist'])) {
1821
+					continue;
1822
+		} elseif ($setting['id'] == 'wysiwyg_default' && !empty($modSettings['disable_wysiwyg'])) {
1823
+					continue;
1824
+		} elseif ($setting['id'] == 'drafts_autosave_enabled' && (empty($modSettings['drafts_autosave_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) {
1825
+					continue;
1826
+		} elseif ($setting['id'] == 'drafts_show_saved_enabled' && (empty($modSettings['drafts_show_saved_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) {
1827
+					continue;
1828
+		}
1752 1829
 
1753 1830
 		// Some of these may not be set...  Set to defaults here
1754 1831
 		$opts = array('topics_per_page', 'messages_per_page', 'display_quick_mod');
1755
-		if (in_array($setting['id'], $opts) && !isset($context['member']['options'][$setting['id']]))
1756
-			$context['member']['options'][$setting['id']] = 0;
1757
-
1758
-		if (!isset($setting['type']) || $setting['type'] == 'bool')
1759
-			$setting['type'] = 'checkbox';
1760
-
1761
-		elseif ($setting['type'] == 'int' || $setting['type'] == 'integer')
1762
-			$setting['type'] = 'number';
1832
+		if (in_array($setting['id'], $opts) && !isset($context['member']['options'][$setting['id']])) {
1833
+					$context['member']['options'][$setting['id']] = 0;
1834
+		}
1763 1835
 
1764
-		elseif ($setting['type'] == 'string')
1765
-			$setting['type'] = 'text';
1836
+		if (!isset($setting['type']) || $setting['type'] == 'bool') {
1837
+					$setting['type'] = 'checkbox';
1838
+		} elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') {
1839
+					$setting['type'] = 'number';
1840
+		} elseif ($setting['type'] == 'string') {
1841
+					$setting['type'] = 'text';
1842
+		}
1766 1843
 
1767
-		if (isset($setting['options']))
1768
-			$setting['type'] = 'list';
1844
+		if (isset($setting['options'])) {
1845
+					$setting['type'] = 'list';
1846
+		}
1769 1847
 
1770 1848
 		echo '
1771 1849
 					<dt>
1772 1850
 						<label for="', $setting['id'], '">', !$titled_section ? '<strong>' : '', $setting['label'], !$titled_section ? '</strong>' : '', '</label>';
1773 1851
 
1774
-		if (isset($setting['description']))
1775
-			echo '
1852
+		if (isset($setting['description'])) {
1853
+					echo '
1776 1854
 						<br>
1777 1855
 						<span class="smalltext">', $setting['description'], '</span>';
1856
+		}
1778 1857
 		echo '
1779 1858
 					</dt>
1780 1859
 					<dd>';
1781 1860
 
1782 1861
 		// Display checkbox options
1783
-		if ($setting['type'] == 'checkbox')
1784
-			echo '
1862
+		if ($setting['type'] == 'checkbox') {
1863
+					echo '
1785 1864
 						<input type="hidden" name="default_options[' . $setting['id'] . ']" value="0">
1786 1865
 						<input type="checkbox" name="default_options[', $setting['id'], ']" id="', $setting['id'], '"', !empty($context['member']['options'][$setting['id']]) ? ' checked' : '', ' value="1">';
1866
+		}
1787 1867
 
1788 1868
 		// How about selection lists, we all love them
1789 1869
 		elseif ($setting['type'] == 'list')
@@ -1791,9 +1871,10 @@  discard block
 block discarded – undo
1791 1871
 			echo '
1792 1872
 						<select name="default_options[', $setting['id'], ']" id="', $setting['id'], '"', '>';
1793 1873
 
1794
-			foreach ($setting['options'] as $value => $label)
1795
-				echo '
1874
+			foreach ($setting['options'] as $value => $label) {
1875
+							echo '
1796 1876
 							<option value="', $value, '"', $value == $context['member']['options'][$setting['id']] ? ' selected' : '', '>', $label, '</option>';
1877
+			}
1797 1878
 
1798 1879
 			echo '
1799 1880
 						</select>';
@@ -1809,14 +1890,13 @@  discard block
 block discarded – undo
1809 1890
 
1810 1891
 				echo '
1811 1892
 						<input type="number"', $min . $max . $step;
1812
-			}
1813
-			elseif (isset($setting['type']) && $setting['type'] == 'url')
1814
-				echo'
1893
+			} elseif (isset($setting['type']) && $setting['type'] == 'url') {
1894
+							echo'
1815 1895
 						<input type="url"';
1816
-
1817
-			else
1818
-				echo '
1896
+			} else {
1897
+							echo '
1819 1898
 						<input type="text"';
1899
+			}
1820 1900
 
1821 1901
 			echo ' name="default_options[', $setting['id'], ']" id="', $setting['id'], '" value="', isset($context['member']['options'][$setting['id']]) ? $context['member']['options'][$setting['id']] : $setting['value'], '"', $setting['type'] == 'number' ? ' size="5"' : '', '>';
1822 1902
 		}
@@ -1853,8 +1933,8 @@  discard block
 block discarded – undo
1853 1933
 				<dl class="settings">';
1854 1934
 
1855 1935
 	// Allow notification on announcements to be disabled?
1856
-	if (!empty($modSettings['allow_disableAnnounce']))
1857
-		echo '
1936
+	if (!empty($modSettings['allow_disableAnnounce'])) {
1937
+			echo '
1858 1938
 					<dt>
1859 1939
 						<label for="notify_announcements">', $txt['notify_important_email'], '</label>
1860 1940
 					</dt>
@@ -1862,15 +1942,17 @@  discard block
 block discarded – undo
1862 1942
 						<input type="hidden" name="notify_announcements" value="0">
1863 1943
 						<input type="checkbox" id="notify_announcements" name="notify_announcements" value="1"', !empty($context['member']['notify_announcements']) ? ' checked' : '', '>
1864 1944
 					</dd>';
1945
+	}
1865 1946
 
1866
-	if (!empty($modSettings['enable_ajax_alerts']))
1867
-		echo '
1947
+	if (!empty($modSettings['enable_ajax_alerts'])) {
1948
+			echo '
1868 1949
 					<dt>
1869 1950
 						<label for="notify_send_body">', $txt['notify_alert_timeout'], '</label>
1870 1951
 					</dt>
1871 1952
 					<dd>
1872 1953
 						<input type="number" size="4" id="notify_alert_timeout" name="opt_alert_timeout" min="0" value="', $context['member']['alert_timeout'], '">
1873 1954
 					</dd>';
1955
+	}
1874 1956
 
1875 1957
 	echo '
1876 1958
 				</dl>
@@ -1902,9 +1984,10 @@  discard block
 block discarded – undo
1902 1984
 
1903 1985
 				$label = $txt['alert_opt_' . $opts[1]];
1904 1986
 				$label_pos = isset($opts['label']) ? $opts['label'] : '';
1905
-				if ($label_pos == 'before')
1906
-					echo '
1987
+				if ($label_pos == 'before') {
1988
+									echo '
1907 1989
 						<label for="opt_', $opts[1], '">', $label, '</label>';
1990
+				}
1908 1991
 
1909 1992
 				$this_value = isset($context['alert_prefs'][$opts[1]]) ? $context['alert_prefs'][$opts[1]] : 0;
1910 1993
 				switch ($opts[0])
@@ -1918,17 +2001,19 @@  discard block
 block discarded – undo
1918 2001
 						echo '
1919 2002
 						<select name="opt_', $opts[1], '" id="opt_', $opts[1], '">';
1920 2003
 
1921
-						foreach ($opts['opts'] as $k => $v)
1922
-							echo '
2004
+						foreach ($opts['opts'] as $k => $v) {
2005
+													echo '
1923 2006
 							<option value="', $k, '"', $this_value == $k ? ' selected' : '', '>', $v, '</option>';
2007
+						}
1924 2008
 						echo '
1925 2009
 						</select>';
1926 2010
 						break;
1927 2011
 				}
1928 2012
 
1929
-				if ($label_pos == 'after')
1930
-					echo '
2013
+				if ($label_pos == 'after') {
2014
+									echo '
1931 2015
 						<label for="opt_', $opts[1], '">', $label, '</label>';
2016
+				}
1932 2017
 
1933 2018
 				echo '
1934 2019
 					</td>
@@ -2045,11 +2130,12 @@  discard block
 block discarded – undo
2045 2130
 			<p class="information">', $txt['groupMembership_info'], '</p>';
2046 2131
 
2047 2132
 	// Do we have an update message?
2048
-	if (!empty($context['update_message']))
2049
-		echo '
2133
+	if (!empty($context['update_message'])) {
2134
+			echo '
2050 2135
 			<div class="infobox">
2051 2136
 				', $context['update_message'], '.
2052 2137
 			</div>';
2138
+	}
2053 2139
 
2054 2140
 	echo '
2055 2141
 			<div id="groups">';
@@ -2071,8 +2157,7 @@  discard block
 block discarded – undo
2071 2157
 						</div>
2072 2158
 					</div>
2073 2159
 				</div><!-- .groupmembership -->';
2074
-	}
2075
-	else
2160
+	} else
2076 2161
 	{
2077 2162
 		echo '
2078 2163
 				<div class="title_bar">
@@ -2084,27 +2169,30 @@  discard block
 block discarded – undo
2084 2169
 			echo '
2085 2170
 				<div class="windowbg" id="primdiv_', $group['id'], '">';
2086 2171
 
2087
-				if ($context['can_edit_primary'])
2088
-					echo '
2172
+				if ($context['can_edit_primary']) {
2173
+									echo '
2089 2174
 					<input type="radio" name="primary" id="primary_', $group['id'], '" value="', $group['id'], '"', $group['is_primary'] ? ' checked' : '', ' onclick="highlightSelected(\'primdiv_' . $group['id'] . '\');"', $group['can_be_primary'] ? '' : ' disabled', '>';
2175
+				}
2090 2176
 
2091 2177
 				echo '
2092 2178
 					<label for="primary_', $group['id'], '"><strong>', (empty($group['color']) ? $group['name'] : '<span style="color: ' . $group['color'] . '">' . $group['name'] . '</span>'), '</strong>', (!empty($group['desc']) ? '<br><span class="smalltext">' . $group['desc'] . '</span>' : ''), '</label>';
2093 2179
 
2094 2180
 				// Can they leave their group?
2095
-				if ($group['can_leave'])
2096
-					echo '
2181
+				if ($group['can_leave']) {
2182
+									echo '
2097 2183
 					<a href="' . $scripturl . '?action=profile;save;u=' . $context['id_member'] . ';area=groupmembership;' . $context['session_var'] . '=' . $context['session_id'] . ';gid=' . $group['id'] . ';', $context[$context['token_check'] . '_token_var'], '=', $context[$context['token_check'] . '_token'], '">' . $txt['leave_group'] . '</a>';
2184
+				}
2098 2185
 
2099 2186
 				echo '
2100 2187
 				</div><!-- .windowbg -->';
2101 2188
 		}
2102 2189
 
2103
-		if ($context['can_edit_primary'])
2104
-			echo '
2190
+		if ($context['can_edit_primary']) {
2191
+					echo '
2105 2192
 				<div class="padding righttext">
2106 2193
 					<input type="submit" value="', $txt['make_primary'], '" class="button">
2107 2194
 				</div>';
2195
+		}
2108 2196
 
2109 2197
 		// Any groups they can join?
2110 2198
 		if (!empty($context['groups']['available']))
@@ -2120,17 +2208,16 @@  discard block
 block discarded – undo
2120 2208
 				<div class="windowbg">
2121 2209
 					<strong>', (empty($group['color']) ? $group['name'] : '<span style="color: ' . $group['color'] . '">' . $group['name'] . '</span>'), '</strong>', (!empty($group['desc']) ? '<br><span class="smalltext">' . $group['desc'] . '</span>' : ''), '';
2122 2210
 
2123
-				if ($group['type'] == 3)
2124
-					echo '
2211
+				if ($group['type'] == 3) {
2212
+									echo '
2125 2213
 					<a href="', $scripturl, '?action=profile;save;u=', $context['id_member'], ';area=groupmembership;', $context['session_var'], '=', $context['session_id'], ';gid=', $group['id'], ';', $context[$context['token_check'] . '_token_var'], '=', $context[$context['token_check'] . '_token'], '" class="button floatright">', $txt['join_group'], '</a>';
2126
-
2127
-				elseif ($group['type'] == 2 && $group['pending'])
2128
-					echo '
2214
+				} elseif ($group['type'] == 2 && $group['pending']) {
2215
+									echo '
2129 2216
 					<span class="floatright">', $txt['approval_pending'], '</span>';
2130
-
2131
-				elseif ($group['type'] == 2)
2132
-					echo '
2217
+				} elseif ($group['type'] == 2) {
2218
+									echo '
2133 2219
 					<a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=groupmembership;request=', $group['id'], '" class="button floatright">', $txt['request_group'], '</a>';
2220
+				}
2134 2221
 
2135 2222
 				echo '
2136 2223
 				</div><!-- .windowbg -->';
@@ -2153,9 +2240,10 @@  discard block
 block discarded – undo
2153 2240
 
2154 2241
 						prevDiv.className = "windowbg";
2155 2242
 					}';
2156
-		if (isset($context['groups']['member'][$context['primary_group']]))
2157
-			echo '
2243
+		if (isset($context['groups']['member'][$context['primary_group']])) {
2244
+					echo '
2158 2245
 					highlightSelected("primdiv_' . $context['primary_group'] . '");';
2246
+		}
2159 2247
 
2160 2248
 		echo '
2161 2249
 				</script>';
@@ -2164,9 +2252,10 @@  discard block
 block discarded – undo
2164 2252
 	echo '
2165 2253
 			</div><!-- #groups -->';
2166 2254
 
2167
-	if (!empty($context['token_check']))
2168
-		echo '
2255
+	if (!empty($context['token_check'])) {
2256
+			echo '
2169 2257
 			<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2258
+	}
2170 2259
 
2171 2260
 	echo '
2172 2261
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -2214,14 +2303,15 @@  discard block
 block discarded – undo
2214 2303
 
2215 2304
 		foreach ($category['boards'] as $board)
2216 2305
 		{
2217
-			if ($i == $limit)
2218
-				echo '
2306
+			if ($i == $limit) {
2307
+							echo '
2219 2308
 						</ul>
2220 2309
 					</li>
2221 2310
 				</ul>
2222 2311
 				<ul class="ignoreboards floatright">
2223 2312
 					<li class="category">
2224 2313
 						<ul>';
2314
+			}
2225 2315
 
2226 2316
 			echo '
2227 2317
 							<li class="board" style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'], 'em;">
@@ -2267,10 +2357,11 @@  discard block
 block discarded – undo
2267 2357
 
2268 2358
 	// Work out the starting color.
2269 2359
 	$context['current_color'] = $context['colors'][0];
2270
-	foreach ($context['colors'] as $limit => $color)
2271
-		if ($context['member']['warning'] >= $limit)
2360
+	foreach ($context['colors'] as $limit => $color) {
2361
+			if ($context['member']['warning'] >= $limit)
2272 2362
 			$context['current_color'] = $color;
2273
-}
2363
+	}
2364
+	}
2274 2365
 
2275 2366
 // Show all warnings of a user?
2276 2367
 function template_viewWarning()
@@ -2309,14 +2400,15 @@  discard block
 block discarded – undo
2309 2400
 				</dd>';
2310 2401
 
2311 2402
 	// There's some impact of this?
2312
-	if (!empty($context['level_effects'][$context['current_level']]))
2313
-		echo '
2403
+	if (!empty($context['level_effects'][$context['current_level']])) {
2404
+			echo '
2314 2405
 				<dt>
2315 2406
 					<strong>', $txt['profile_viewwarning_impact'], ':</strong>
2316 2407
 				</dt>
2317 2408
 				<dd>
2318 2409
 					', $context['level_effects'][$context['current_level']], '
2319 2410
 				</dd>';
2411
+	}
2320 2412
 
2321 2413
 	echo '
2322 2414
 			</dl>
@@ -2354,10 +2446,11 @@  discard block
 block discarded – undo
2354 2446
 
2355 2447
 			// Otherwise see what we can do...';
2356 2448
 
2357
-	foreach ($context['notification_templates'] as $k => $type)
2358
-		echo '
2449
+	foreach ($context['notification_templates'] as $k => $type) {
2450
+			echo '
2359 2451
 			if (index == ', $k, ')
2360 2452
 				document.getElementById(\'warn_body\').value = "', strtr($type['body'], array('"' => "'", "\n" => '\\n', "\r" => '')), '";';
2453
+	}
2361 2454
 
2362 2455
 	echo '
2363 2456
 		}
@@ -2367,10 +2460,11 @@  discard block
 block discarded – undo
2367 2460
 			// Also set the right effect.
2368 2461
 			effectText = "";';
2369 2462
 
2370
-	foreach ($context['level_effects'] as $limit => $text)
2371
-		echo '
2463
+	foreach ($context['level_effects'] as $limit => $text) {
2464
+			echo '
2372 2465
 			if (slideAmount >= ', $limit, ')
2373 2466
 				effectText = "', $text, '";';
2467
+	}
2374 2468
 
2375 2469
 	echo '
2376 2470
 			setInnerHTML(document.getElementById(\'cur_level_div\'), slideAmount + \'% (\' + effectText + \')\');
@@ -2385,32 +2479,35 @@  discard block
 block discarded – undo
2385 2479
 			</h3>
2386 2480
 		</div>';
2387 2481
 
2388
-	if (!$context['user']['is_owner'])
2389
-		echo '
2482
+	if (!$context['user']['is_owner']) {
2483
+			echo '
2390 2484
 		<p class="information">', $txt['profile_warning_desc'], '</p>';
2485
+	}
2391 2486
 
2392 2487
 	echo '
2393 2488
 		<div class="windowbg">
2394 2489
 			<dl class="settings">';
2395 2490
 
2396
-	if (!$context['user']['is_owner'])
2397
-		echo '
2491
+	if (!$context['user']['is_owner']) {
2492
+			echo '
2398 2493
 				<dt>
2399 2494
 					<strong>', $txt['profile_warning_name'], ':</strong>
2400 2495
 				</dt>
2401 2496
 				<dd>
2402 2497
 					<strong>', $context['member']['name'], '</strong>
2403 2498
 				</dd>';
2499
+	}
2404 2500
 
2405 2501
 	echo '
2406 2502
 				<dt>
2407 2503
 					<strong>', $txt['profile_warning_level'], ':</strong>';
2408 2504
 
2409 2505
 	// Is there only so much they can apply?
2410
-	if ($context['warning_limit'])
2411
-		echo '
2506
+	if ($context['warning_limit']) {
2507
+			echo '
2412 2508
 					<br>
2413 2509
 					<span class="smalltext">', sprintf($txt['profile_warning_limit_attribute'], $context['warning_limit']), '</span>';
2510
+	}
2414 2511
 
2415 2512
 	echo '
2416 2513
 				</dt>
@@ -2465,9 +2562,10 @@  discard block
 block discarded – undo
2465 2562
 						<option value="-1">', $txt['profile_warning_notify_template'], '</option>
2466 2563
 						<option value="-1" disabled>------------------------------</option>';
2467 2564
 
2468
-		foreach ($context['notification_templates'] as $id_template => $template)
2469
-			echo '
2565
+		foreach ($context['notification_templates'] as $id_template => $template) {
2566
+					echo '
2470 2567
 						<option value="', $id_template, '">', $template['title'], '</option>';
2568
+		}
2471 2569
 
2472 2570
 		echo '
2473 2571
 					</select>
@@ -2480,9 +2578,10 @@  discard block
 block discarded – undo
2480 2578
 			</dl>
2481 2579
 			<div class="righttext">';
2482 2580
 
2483
-	if (!empty($context['token_check']))
2484
-		echo '
2581
+	if (!empty($context['token_check'])) {
2582
+			echo '
2485 2583
 				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2584
+	}
2486 2585
 
2487 2586
 	echo '
2488 2587
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -2498,8 +2597,8 @@  discard block
 block discarded – undo
2498 2597
 	echo '
2499 2598
 	<script>';
2500 2599
 
2501
-	if (!$context['user']['is_owner'])
2502
-		echo '
2600
+	if (!$context['user']['is_owner']) {
2601
+			echo '
2503 2602
 		modifyWarnNotify();
2504 2603
 		$(document).ready(function() {
2505 2604
 			$("#preview_button").click(function() {
@@ -2538,6 +2637,7 @@  discard block
 block discarded – undo
2538 2637
 			});
2539 2638
 			return false;
2540 2639
 		}';
2640
+	}
2541 2641
 
2542 2642
 	echo '
2543 2643
 	</script>';
@@ -2560,17 +2660,19 @@  discard block
 block discarded – undo
2560 2660
 			</div>';
2561 2661
 
2562 2662
 	// If deleting another account give them a lovely info box.
2563
-	if (!$context['user']['is_owner'])
2564
-		echo '
2663
+	if (!$context['user']['is_owner']) {
2664
+			echo '
2565 2665
 			<p class="information">', $txt['deleteAccount_desc'], '</p>';
2666
+	}
2566 2667
 
2567 2668
 	echo '
2568 2669
 			<div class="windowbg2">';
2569 2670
 
2570 2671
 	// If they are deleting their account AND the admin needs to approve it - give them another piece of info ;)
2571
-	if ($context['needs_approval'])
2572
-		echo '
2672
+	if ($context['needs_approval']) {
2673
+			echo '
2573 2674
 				<div class="errorbox">', $txt['deleteAccount_approval'], '</div>';
2675
+	}
2574 2676
 
2575 2677
 	// If the user is deleting their own account warn them first - and require a password!
2576 2678
 	if ($context['user']['is_owner'])
@@ -2582,9 +2684,10 @@  discard block
 block discarded – undo
2582 2684
 					<input type="password" name="oldpasswrd" size="20">
2583 2685
 					<input type="submit" value="', $txt['yes'], '" class="button">';
2584 2686
 
2585
-		if (!empty($context['token_check']))
2586
-			echo '
2687
+		if (!empty($context['token_check'])) {
2688
+					echo '
2587 2689
 					<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2690
+		}
2588 2691
 
2589 2692
 		echo '
2590 2693
 					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -2614,10 +2717,11 @@  discard block
 block discarded – undo
2614 2717
 						<option value="topics">', $txt['deleteAccount_topics'], '</option>
2615 2718
 					</select>';
2616 2719
 
2617
-			if ($context['show_perma_delete'])
2618
-				echo '
2720
+			if ($context['show_perma_delete']) {
2721
+							echo '
2619 2722
 					<br>
2620 2723
 					<label for="perma_delete"><input type="checkbox" name="perma_delete" id="perma_delete" value="1">', $txt['deleteAccount_permanent'], ':</label>';
2724
+			}
2621 2725
 
2622 2726
 			echo '
2623 2727
 				</div>';
@@ -2630,9 +2734,10 @@  discard block
 block discarded – undo
2630 2734
 				<div>
2631 2735
 					<input type="submit" value="', $txt['delete'], '" class="button">';
2632 2736
 
2633
-		if (!empty($context['token_check']))
2634
-			echo '
2737
+		if (!empty($context['token_check'])) {
2738
+					echo '
2635 2739
 				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2740
+		}
2636 2741
 
2637 2742
 		echo '
2638 2743
 					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -2658,8 +2763,8 @@  discard block
 block discarded – undo
2658 2763
 					<hr>';
2659 2764
 
2660 2765
 	// Only show the password box if it's actually needed.
2661
-	if ($context['require_password'])
2662
-		echo '
2766
+	if ($context['require_password']) {
2767
+			echo '
2663 2768
 					<dl class="settings">
2664 2769
 						<dt>
2665 2770
 							<strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '>', $txt['current_password'], ': </strong><br>
@@ -2669,13 +2774,15 @@  discard block
 block discarded – undo
2669 2774
 							<input type="password" name="oldpasswrd" size="20">
2670 2775
 						</dd>
2671 2776
 					</dl>';
2777
+	}
2672 2778
 
2673 2779
 	echo '
2674 2780
 					<div class="righttext">';
2675 2781
 
2676
-	if (!empty($context['token_check']))
2677
-		echo '
2782
+	if (!empty($context['token_check'])) {
2783
+			echo '
2678 2784
 						<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2785
+	}
2679 2786
 
2680 2787
 	echo '
2681 2788
 						<input type="submit" value="', $txt['change_profile'], '" class="button">
@@ -2702,9 +2809,10 @@  discard block
 block discarded – undo
2702 2809
 			<ul id="list_errors">';
2703 2810
 
2704 2811
 		// Cycle through each error and display an error message.
2705
-		foreach ($context['post_errors'] as $error)
2706
-			echo '
2812
+		foreach ($context['post_errors'] as $error) {
2813
+					echo '
2707 2814
 				<li>', isset($txt['profile_error_' . $error]) ? $txt['profile_error_' . $error] : $error, '</li>';
2815
+		}
2708 2816
 
2709 2817
 		echo '
2710 2818
 			</ul>';
@@ -2730,12 +2838,13 @@  discard block
 block discarded – undo
2730 2838
 								<select name="id_group" ', ($context['user']['is_owner'] && $context['member']['group_id'] == 1 ? 'onchange="if (this.value != 1 &amp;&amp; !confirm(\'' . $txt['deadmin_confirm'] . '\')) this.value = 1;"' : ''), '>';
2731 2839
 
2732 2840
 	// Fill the select box with all primary member groups that can be assigned to a member.
2733
-	foreach ($context['member_groups'] as $member_group)
2734
-		if (!empty($member_group['can_be_primary']))
2841
+	foreach ($context['member_groups'] as $member_group) {
2842
+			if (!empty($member_group['can_be_primary']))
2735 2843
 			echo '
2736 2844
 									<option value="', $member_group['id'], '"', $member_group['is_primary'] ? ' selected' : '', '>
2737 2845
 										', $member_group['name'], '
2738 2846
 									</option>';
2847
+	}
2739 2848
 
2740 2849
 	echo '
2741 2850
 								</select>
@@ -2748,10 +2857,11 @@  discard block
 block discarded – undo
2748 2857
 									<input type="hidden" name="additional_groups[]" value="0">';
2749 2858
 
2750 2859
 	// For each membergroup show a checkbox so members can be assigned to more than one group.
2751
-	foreach ($context['member_groups'] as $member_group)
2752
-		if ($member_group['can_be_additional'])
2860
+	foreach ($context['member_groups'] as $member_group) {
2861
+			if ($member_group['can_be_additional'])
2753 2862
 			echo '
2754 2863
 									<label for="additional_groups-', $member_group['id'], '"><input type="checkbox" name="additional_groups[]" value="', $member_group['id'], '" id="additional_groups-', $member_group['id'], '"', $member_group['is_additional'] ? ' checked' : '', '> ', $member_group['name'], '</label><br>';
2864
+	}
2755 2865
 
2756 2866
 	echo '
2757 2867
 								</span>
@@ -2811,9 +2921,10 @@  discard block
 block discarded – undo
2811 2921
 								<span class="smalltext">', $txt['sig_info'], '</span><br>
2812 2922
 								<br>';
2813 2923
 
2814
-	if ($context['show_spellchecking'])
2815
-		echo '
2924
+	if ($context['show_spellchecking']) {
2925
+			echo '
2816 2926
 								<input type="button" value="', $txt['spell_check'], '" onclick="spellCheck(\'creator\', \'signature\');" class="button">';
2927
+	}
2817 2928
 
2818 2929
 	echo '
2819 2930
 							</dt>
@@ -2821,17 +2932,20 @@  discard block
 block discarded – undo
2821 2932
 								<textarea class="editor" onkeyup="calcCharLeft();" id="signature" name="signature" rows="5" cols="50">', $context['member']['signature'], '</textarea><br>';
2822 2933
 
2823 2934
 	// If there is a limit at all!
2824
-	if (!empty($context['signature_limits']['max_length']))
2825
-		echo '
2935
+	if (!empty($context['signature_limits']['max_length'])) {
2936
+			echo '
2826 2937
 								<span class="smalltext">', sprintf($txt['max_sig_characters'], $context['signature_limits']['max_length']), ' <span id="signatureLeft">', $context['signature_limits']['max_length'], '</span></span><br>';
2938
+	}
2827 2939
 
2828
-	if (!empty($context['show_preview_button']))
2829
-		echo '
2940
+	if (!empty($context['show_preview_button'])) {
2941
+			echo '
2830 2942
 								<input type="button" name="preview_signature" id="preview_button" value="', $txt['preview_signature'], '" class="button floatright">';
2943
+	}
2831 2944
 
2832
-	if ($context['signature_warning'])
2833
-		echo '
2945
+	if ($context['signature_warning']) {
2946
+			echo '
2834 2947
 								<span class="smalltext">', $context['signature_warning'], '</span>';
2948
+	}
2835 2949
 
2836 2950
 	// Some javascript used to count how many characters have been used so far in the signature.
2837 2951
 	echo '
@@ -2876,9 +2990,10 @@  discard block
 block discarded – undo
2876 2990
 										<select name="cat" id="cat" size="10" onchange="changeSel(\'\');" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'server_stored\');">';
2877 2991
 
2878 2992
 		// This lists all the file categories.
2879
-		foreach ($context['avatars'] as $avatar)
2880
-			echo '
2993
+		foreach ($context['avatars'] as $avatar) {
2994
+					echo '
2881 2995
 											<option value="', $avatar['filename'] . ($avatar['is_dir'] ? '/' : ''), '"', ($avatar['checked'] ? ' selected' : ''), '>', $avatar['name'], '</option>';
2996
+		}
2882 2997
 
2883 2998
 		echo '
2884 2999
 										</select>
@@ -2910,20 +3025,22 @@  discard block
 block discarded – undo
2910 3025
 	}
2911 3026
 
2912 3027
 	// If the user can link to an off server avatar, show them a box to input the address.
2913
-	if (!empty($context['member']['avatar']['allow_external']))
2914
-		echo '
3028
+	if (!empty($context['member']['avatar']['allow_external'])) {
3029
+			echo '
2915 3030
 								<div id="avatar_external">
2916 3031
 									<div class="smalltext">', $txt['avatar_by_url'], '</div>', !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_download_and_resize' ? template_max_size('external') : '', '
2917 3032
 									<input type="text" name="userpicpersonal" size="45" value="', ((stristr($context['member']['avatar']['external'], 'http://') || stristr($context['member']['avatar']['external'], 'https://')) ? $context['member']['avatar']['external'] : 'http://'), '" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'external\');" onchange="if (typeof(previewExternalAvatar) != \'undefined\') previewExternalAvatar(this.value);">
2918 3033
 								</div>';
3034
+	}
2919 3035
 
2920 3036
 	// If the user is able to upload avatars to the server show them an upload box.
2921
-	if (!empty($context['member']['avatar']['allow_upload']))
2922
-		echo '
3037
+	if (!empty($context['member']['avatar']['allow_upload'])) {
3038
+			echo '
2923 3039
 								<div id="avatar_upload">
2924 3040
 									<input type="file" size="44" name="attachment" id="avatar_upload_box" value="" onchange="readfromUpload(this)"  onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'upload\');" accept="image/gif, image/jpeg, image/jpg, image/png">', template_max_size('upload'), '
2925 3041
 									', (!empty($context['member']['avatar']['id_attach']) ? '<br><img src="' . $context['member']['avatar']['href'] . (strpos($context['member']['avatar']['href'], '?') === false ? '?' : '&amp;') . 'time=' . time() . '" alt="" id="attached_image"><input type="hidden" name="id_attach" value="' . $context['member']['avatar']['id_attach'] . '">' : ''), '
2926 3042
 								</div>';
3043
+	}
2927 3044
 
2928 3045
 	// if the user is able to use Gravatar avatars show then the image preview
2929 3046
 	if (!empty($context['member']['avatar']['allow_gravatar']))
@@ -2932,16 +3049,17 @@  discard block
 block discarded – undo
2932 3049
 								<div id="avatar_gravatar">
2933 3050
 									<img src="' . $context['member']['avatar']['href'] . '" alt="">';
2934 3051
 
2935
-		if (empty($modSettings['gravatarAllowExtraEmail']))
2936
-			echo '
3052
+		if (empty($modSettings['gravatarAllowExtraEmail'])) {
3053
+					echo '
2937 3054
 									<div class="smalltext">', $txt['gravatar_noAlternateEmail'], '</div>';
2938
-		else
3055
+		} else
2939 3056
 		{
2940 3057
 			// Depending on other stuff, the stored value here might have some odd things in it from other areas.
2941
-			if ($context['member']['avatar']['external'] == $context['member']['email'])
2942
-				$textbox_value = '';
2943
-			else
2944
-				$textbox_value = $context['member']['avatar']['external'];
3058
+			if ($context['member']['avatar']['external'] == $context['member']['email']) {
3059
+							$textbox_value = '';
3060
+			} else {
3061
+							$textbox_value = $context['member']['avatar']['external'];
3062
+			}
2945 3063
 
2946 3064
 			echo '
2947 3065
 									<div class="smalltext">', $txt['gravatar_alternateEmail'], '</div>
@@ -3013,8 +3131,9 @@  discard block
 block discarded – undo
3013 3131
 	$h = !empty($modSettings['avatar_max_height_' . $type]) ? comma_format($modSettings['avatar_max_height_' . $type]) : 0;
3014 3132
 
3015 3133
 	$suffix = (!empty($w) ? 'w' : '') . (!empty($h) ? 'h' : '');
3016
-	if (empty($suffix))
3017
-		return;
3134
+	if (empty($suffix)) {
3135
+			return;
3136
+	}
3018 3137
 
3019 3138
 	echo '
3020 3139
 								<div class="smalltext">', sprintf($txt['avatar_max_size_' . $suffix], $w, $h), '</div>';
@@ -3039,9 +3158,10 @@  discard block
 block discarded – undo
3039 3158
 								<select name="easyformat" id="easyformat" onchange="document.forms.creator.time_format.value = this.options[this.selectedIndex].value;">';
3040 3159
 
3041 3160
 	// Help the user by showing a list of common time formats.
3042
-	foreach ($context['easy_timeformats'] as $time_format)
3043
-		echo '
3161
+	foreach ($context['easy_timeformats'] as $time_format) {
3162
+			echo '
3044 3163
 									<option value="', $time_format['format'], '"', $time_format['format'] == $context['member']['time_format'] ? ' selected' : '', '>', $time_format['title'], '</option>';
3164
+	}
3045 3165
 
3046 3166
 	echo '
3047 3167
 								</select>
@@ -3079,9 +3199,10 @@  discard block
 block discarded – undo
3079 3199
 							<dd>
3080 3200
 								<select name="smiley_set" id="smiley_set" onchange="document.getElementById(\'smileypr\').src = this.selectedIndex == 0 ? \'', $settings['images_url'], '/blank.png\' : \'', $modSettings['smileys_url'], '/\' + (this.selectedIndex != 1 ? this.options[this.selectedIndex].value : \'', !empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default'], '\') + \'/smiley.png\';">';
3081 3201
 
3082
-	foreach ($context['smiley_sets'] as $set)
3083
-		echo '
3202
+	foreach ($context['smiley_sets'] as $set) {
3203
+			echo '
3084 3204
 									<option value="', $set['id'], '"', $set['selected'] ? ' selected' : '', '>', $set['name'], '</option>';
3205
+	}
3085 3206
 
3086 3207
 	echo '
3087 3208
 								</select>
@@ -3133,10 +3254,11 @@  discard block
 block discarded – undo
3133 3254
 										<img src="', $context['tfa_qr_url'], '" alt="">
3134 3255
 									</div>';
3135 3256
 
3136
-	if (!empty($context['from_ajax']))
3137
-		echo '
3257
+	if (!empty($context['from_ajax'])) {
3258
+			echo '
3138 3259
 					<br>
3139 3260
 					<a href="javascript:self.close();"></a>';
3261
+	}
3140 3262
 
3141 3263
 	echo '
3142 3264
 				</div>
@@ -3176,17 +3298,16 @@  discard block
 block discarded – undo
3176 3298
 							</dt>
3177 3299
 							<dd>';
3178 3300
 
3179
-	if (!$context['tfa_enabled'] && $context['user']['is_owner'])
3180
-		echo '
3301
+	if (!$context['tfa_enabled'] && $context['user']['is_owner']) {
3302
+			echo '
3181 3303
 								<a href="', !empty($modSettings['force_ssl']) ? strtr($scripturl, array('http://' => 'https://')) : $scripturl, '?action=profile;area=tfasetup" id="enable_tfa">', $txt['tfa_profile_enable'], '</a>';
3182
-
3183
-	elseif (!$context['tfa_enabled'])
3184
-		echo '
3304
+	} elseif (!$context['tfa_enabled']) {
3305
+			echo '
3185 3306
 								', $txt['tfa_profile_disabled'];
3186
-
3187
-	else
3188
-		echo '
3307
+	} else {
3308
+			echo '
3189 3309
 								', sprintf($txt['tfa_profile_enabled'], $scripturl . '?action=profile;u=' . $context['id_member'] . ';area=tfasetup;disable');
3310
+	}
3190 3311
 
3191 3312
 	echo '
3192 3313
 							</dd>';
Please login to merge, or discard this patch.
Sources/DbExtra-mysql.php 1 patch
Braces   +72 added lines, -51 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Add the functions implemented in this file to the $smcFunc array.
@@ -23,8 +24,8 @@  discard block
 block discarded – undo
23 24
 {
24 25
 	global $smcFunc;
25 26
 
26
-	if (!isset($smcFunc['db_backup_table']) || $smcFunc['db_backup_table'] != 'smf_db_backup_table')
27
-		$smcFunc += array(
27
+	if (!isset($smcFunc['db_backup_table']) || $smcFunc['db_backup_table'] != 'smf_db_backup_table') {
28
+			$smcFunc += array(
28 29
 			'db_backup_table' => 'smf_db_backup_table',
29 30
 			'db_optimize_table' => 'smf_db_optimize_table',
30 31
 			'db_table_sql' => 'smf_db_table_sql',
@@ -33,7 +34,8 @@  discard block
 block discarded – undo
33 34
 			'db_get_vendor' => 'smf_db_get_vendor',
34 35
 			'db_allow_persistent' => 'smf_db_allow_persistent',
35 36
 		);
36
-}
37
+	}
38
+	}
37 39
 
38 40
 /**
39 41
  * Backup $table to $backup_table.
@@ -75,8 +77,9 @@  discard block
 block discarded – undo
75 77
 			));
76 78
 
77 79
 		// Old school or no school?
78
-		if ($request)
79
-			return $request;
80
+		if ($request) {
81
+					return $request;
82
+		}
80 83
 	}
81 84
 
82 85
 	// At this point, the quick method failed.
@@ -100,8 +103,9 @@  discard block
 block discarded – undo
100 103
 	foreach ($create as $k => $l)
101 104
 	{
102 105
 		// Get the name of the auto_increment column.
103
-		if (strpos($l, 'auto_increment'))
104
-			$auto_inc = trim($l);
106
+		if (strpos($l, 'auto_increment')) {
107
+					$auto_inc = trim($l);
108
+		}
105 109
 
106 110
 		// For the engine type, see if we can work out what it is.
107 111
 		if (strpos($l, 'ENGINE') !== false || strpos($l, 'TYPE') !== false)
@@ -109,30 +113,36 @@  discard block
 block discarded – undo
109 113
 			// Extract the engine type.
110 114
 			preg_match('~(ENGINE|TYPE)=(\w+)(\sDEFAULT)?(\sCHARSET=(\w+))?(\sCOLLATE=(\w+))?~', $l, $match);
111 115
 
112
-			if (!empty($match[1]))
113
-				$engine = $match[1];
116
+			if (!empty($match[1])) {
117
+							$engine = $match[1];
118
+			}
114 119
 
115
-			if (!empty($match[2]))
116
-				$engine = $match[2];
120
+			if (!empty($match[2])) {
121
+							$engine = $match[2];
122
+			}
117 123
 
118
-			if (!empty($match[5]))
119
-				$charset = $match[5];
124
+			if (!empty($match[5])) {
125
+							$charset = $match[5];
126
+			}
120 127
 
121
-			if (!empty($match[7]))
122
-				$collate = $match[7];
128
+			if (!empty($match[7])) {
129
+							$collate = $match[7];
130
+			}
123 131
 		}
124 132
 
125 133
 		// Skip everything but keys...
126
-		if (strpos($l, 'KEY') === false)
127
-			unset($create[$k]);
134
+		if (strpos($l, 'KEY') === false) {
135
+					unset($create[$k]);
136
+		}
128 137
 	}
129 138
 
130
-	if (!empty($create))
131
-		$create = '(
139
+	if (!empty($create)) {
140
+			$create = '(
132 141
 			' . implode('
133 142
 			', $create) . ')';
134
-	else
135
-		$create = '';
143
+	} else {
144
+			$create = '';
145
+	}
136 146
 
137 147
 	$request = $smcFunc['db_query']('', '
138 148
 		CREATE TABLE {raw:backup_table} {raw:create}
@@ -151,8 +161,9 @@  discard block
 block discarded – undo
151 161
 
152 162
 	if ($auto_inc != '')
153 163
 	{
154
-		if (preg_match('~\`(.+?)\`\s~', $auto_inc, $match) != 0 && substr($auto_inc, -1, 1) == ',')
155
-			$auto_inc = substr($auto_inc, 0, -1);
164
+		if (preg_match('~\`(.+?)\`\s~', $auto_inc, $match) != 0 && substr($auto_inc, -1, 1) == ',') {
165
+					$auto_inc = substr($auto_inc, 0, -1);
166
+		}
156 167
 
157 168
 		$smcFunc['db_query']('', '
158 169
 			ALTER TABLE {raw:backup_table}
@@ -196,8 +207,9 @@  discard block
 block discarded – undo
196 207
 				'table' => $table,
197 208
 			)
198 209
 		);
199
-	if (!$request)
200
-		return -1;
210
+	if (!$request) {
211
+			return -1;
212
+	}
201 213
 
202 214
 	// How much left?
203 215
 	$request = $smcFunc['db_query']('', '
@@ -240,8 +252,9 @@  discard block
 block discarded – undo
240 252
 		)
241 253
 	);
242 254
 	$tables = array();
243
-	while ($row = $smcFunc['db_fetch_row']($request))
244
-		$tables[] = $row[0];
255
+	while ($row = $smcFunc['db_fetch_row']($request)) {
256
+			$tables[] = $row[0];
257
+	}
245 258
 	$smcFunc['db_free_result']($request);
246 259
 
247 260
 	return $tables;
@@ -285,8 +298,9 @@  discard block
 block discarded – undo
285 298
 		if (!empty($row['Default']) || $row['Null'] !== 'YES')
286 299
 		{
287 300
 			// Make a special case of auto-timestamp.
288
-			if ($row['Default'] == 'CURRENT_TIMESTAMP')
289
-				$schema_create .= ' /*!40102 NOT NULL default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP */';
301
+			if ($row['Default'] == 'CURRENT_TIMESTAMP') {
302
+							$schema_create .= ' /*!40102 NOT NULL default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP */';
303
+			}
290 304
 			// Text shouldn't have a default.
291 305
 			elseif ($row['Default'] !== null)
292 306
 			{
@@ -321,14 +335,16 @@  discard block
 block discarded – undo
321 335
 		$row['Key_name'] = $row['Key_name'] == 'PRIMARY' ? 'PRIMARY KEY' : (empty($row['Non_unique']) ? 'UNIQUE ' : ($row['Comment'] == 'FULLTEXT' || (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT') ? 'FULLTEXT ' : 'KEY ')) . '`' . $row['Key_name'] . '`';
322 336
 
323 337
 		// Is this the first column in the index?
324
-		if (empty($indexes[$row['Key_name']]))
325
-			$indexes[$row['Key_name']] = array();
338
+		if (empty($indexes[$row['Key_name']])) {
339
+					$indexes[$row['Key_name']] = array();
340
+		}
326 341
 
327 342
 		// A sub part, like only indexing 15 characters of a varchar.
328
-		if (!empty($row['Sub_part']))
329
-			$indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`(' . $row['Sub_part'] . ')';
330
-		else
331
-			$indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`';
343
+		if (!empty($row['Sub_part'])) {
344
+					$indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`(' . $row['Sub_part'] . ')';
345
+		} else {
346
+					$indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`';
347
+		}
332 348
 	}
333 349
 	$smcFunc['db_free_result']($result);
334 350
 
@@ -366,8 +382,9 @@  discard block
 block discarded – undo
366 382
 {
367 383
 	static $ver;
368 384
 
369
-	if (!empty($ver))
370
-		return $ver;
385
+	if (!empty($ver)) {
386
+			return $ver;
387
+	}
371 388
 
372 389
 	global $smcFunc;
373 390
 
@@ -392,8 +409,9 @@  discard block
 block discarded – undo
392 409
 	global $smcFunc;
393 410
 	static $db_type;
394 411
 
395
-	if (!empty($db_type))
396
-		return $db_type;
412
+	if (!empty($db_type)) {
413
+			return $db_type;
414
+	}
397 415
 
398 416
 	$request = $smcFunc['db_query']('', 'SELECT @@version_comment');
399 417
 	list ($comment) = $smcFunc['db_fetch_row']($request);
@@ -402,13 +420,15 @@  discard block
 block discarded – undo
402 420
 	// Skip these if we don't have a comment.
403 421
 	if (!empty($comment))
404 422
 	{
405
-		if (stripos($comment, 'percona') !== false)
406
-			return 'Percona';
407
-		if (stripos($comment, 'mariadb') !== false)
408
-			return 'MariaDB';
423
+		if (stripos($comment, 'percona') !== false) {
424
+					return 'Percona';
425
+		}
426
+		if (stripos($comment, 'mariadb') !== false) {
427
+					return 'MariaDB';
428
+		}
429
+	} else {
430
+			return 'fail';
409 431
 	}
410
-	else
411
-		return 'fail';
412 432
 
413 433
 	return 'MySQL';
414 434
 }
@@ -421,10 +441,11 @@  discard block
 block discarded – undo
421 441
 function smf_db_allow_persistent()
422 442
 {
423 443
 	$value = ini_get('mysqli.allow_persistent');
424
-	if (strtolower($value) == 'on' || strtolower($value) == 'true' || $value == '1')
425
-		return true;
426
-	else
427
-		return false;
428
-}
444
+	if (strtolower($value) == 'on' || strtolower($value) == 'true' || $value == '1') {
445
+			return true;
446
+	} else {
447
+			return false;
448
+	}
449
+	}
429 450
 
430 451
 ?>
431 452
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/Subs-Editor.php 1 patch
Braces   +412 added lines, -309 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!!!
@@ -30,8 +31,9 @@  discard block
 block discarded – undo
30 31
 {
31 32
 	global $modSettings;
32 33
 
33
-	if (!$compat_mode)
34
-		return $text;
34
+	if (!$compat_mode) {
35
+			return $text;
36
+	}
35 37
 
36 38
 	// Turn line breaks back into br's.
37 39
 	$text = strtr($text, array("\r" => '', "\n" => '<br>'));
@@ -48,8 +50,9 @@  discard block
 block discarded – undo
48 50
 			for ($i = 0, $n = count($parts); $i < $n; $i++)
49 51
 			{
50 52
 				// Value of 2 means we're inside the tag.
51
-				if ($i % 4 == 2)
52
-					$parts[$i] = strtr($parts[$i], array('[' => '&#91;', ']' => '&#93;', "'" => "'"));
53
+				if ($i % 4 == 2) {
54
+									$parts[$i] = strtr($parts[$i], array('[' => '&#91;', ']' => '&#93;', "'" => "'"));
55
+				}
53 56
 			}
54 57
 			// Put our humpty dumpty message back together again.
55 58
 			$text = implode('', $parts);
@@ -107,8 +110,9 @@  discard block
 block discarded – undo
107 110
 	$text = preg_replace('~</p>\s*(?!<)~i', '</p><br>', $text);
108 111
 
109 112
 	// Safari/webkit wraps lines in Wysiwyg in <div>'s.
110
-	if (isBrowser('webkit'))
111
-		$text = preg_replace(array('~<div(?:\s(?:[^<>]*?))?' . '>~i', '</div>'), array('<br>', ''), $text);
113
+	if (isBrowser('webkit')) {
114
+			$text = preg_replace(array('~<div(?:\s(?:[^<>]*?))?' . '>~i', '</div>'), array('<br>', ''), $text);
115
+	}
112 116
 
113 117
 	// If there's a trailing break get rid of it - Firefox tends to add one.
114 118
 	$text = preg_replace('~<br\s?/?' . '>$~i', '', $text);
@@ -123,8 +127,9 @@  discard block
 block discarded – undo
123 127
 		for ($i = 0, $n = count($parts); $i < $n; $i++)
124 128
 		{
125 129
 			// Value of 2 means we're inside the tag.
126
-			if ($i % 4 == 2)
127
-				$parts[$i] = strip_tags($parts[$i]);
130
+			if ($i % 4 == 2) {
131
+							$parts[$i] = strip_tags($parts[$i]);
132
+			}
128 133
 		}
129 134
 
130 135
 		$text = strtr(implode('', $parts), array('#smf_br_spec_grudge_cool!#' => '<br>'));
@@ -150,18 +155,19 @@  discard block
 block discarded – undo
150 155
 			{
151 156
 				$found = array_search($file, $smileysto);
152 157
 				// Note the weirdness here is to stop double spaces between smileys.
153
-				if ($found)
154
-					$matches[1][$k] = '-[]-smf_smily_start#|#' . $smcFunc['htmlspecialchars']($smileysfrom[$found]) . '-[]-smf_smily_end#|#';
155
-				else
156
-					$matches[1][$k] = '';
158
+				if ($found) {
159
+									$matches[1][$k] = '-[]-smf_smily_start#|#' . $smcFunc['htmlspecialchars']($smileysfrom[$found]) . '-[]-smf_smily_end#|#';
160
+				} else {
161
+									$matches[1][$k] = '';
162
+				}
157 163
 			}
158
-		}
159
-		else
164
+		} else
160 165
 		{
161 166
 			// Load all the smileys.
162 167
 			$names = array();
163
-			foreach ($matches[1] as $file)
164
-				$names[] = $file;
168
+			foreach ($matches[1] as $file) {
169
+							$names[] = $file;
170
+			}
165 171
 			$names = array_unique($names);
166 172
 
167 173
 			if (!empty($names))
@@ -175,13 +181,15 @@  discard block
 block discarded – undo
175 181
 					)
176 182
 				);
177 183
 				$mappings = array();
178
-				while ($row = $smcFunc['db_fetch_assoc']($request))
179
-					$mappings[$row['filename']] = $smcFunc['htmlspecialchars']($row['code']);
184
+				while ($row = $smcFunc['db_fetch_assoc']($request)) {
185
+									$mappings[$row['filename']] = $smcFunc['htmlspecialchars']($row['code']);
186
+				}
180 187
 				$smcFunc['db_free_result']($request);
181 188
 
182
-				foreach ($matches[1] as $k => $file)
183
-					if (isset($mappings[$file]))
189
+				foreach ($matches[1] as $k => $file) {
190
+									if (isset($mappings[$file]))
184 191
 						$matches[1][$k] = '-[]-smf_smily_start#|#' . $mappings[$file] . '-[]-smf_smily_end#|#';
192
+				}
185 193
 			}
186 194
 		}
187 195
 
@@ -193,8 +201,9 @@  discard block
 block discarded – undo
193 201
 	}
194 202
 
195 203
 	// Only try to buy more time if the client didn't quit.
196
-	if (connection_aborted() && $context['server']['is_apache'])
197
-		@apache_reset_timeout();
204
+	if (connection_aborted() && $context['server']['is_apache']) {
205
+			@apache_reset_timeout();
206
+	}
198 207
 
199 208
 	$parts = preg_split('~(<[A-Za-z]+\s*[^<>]*?style="?[^<>"]+"?[^<>]*?(?:/?)>|</[A-Za-z]+>)~', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
200 209
 	$replacement = '';
@@ -205,9 +214,9 @@  discard block
 block discarded – undo
205 214
 		if (preg_match('~(<([A-Za-z]+)\s*[^<>]*?)style="?([^<>"]+)"?([^<>]*?(/?)>)~', $part, $matches) === 1)
206 215
 		{
207 216
 			// If it's being closed instantly, we can't deal with it...yet.
208
-			if ($matches[5] === '/')
209
-				continue;
210
-			else
217
+			if ($matches[5] === '/') {
218
+							continue;
219
+			} else
211 220
 			{
212 221
 				// Get an array of styles that apply to this element. (The strtr is there to combat HTML generated by Word.)
213 222
 				$styles = explode(';', strtr($matches[3], array('&quot;' => '')));
@@ -223,8 +232,9 @@  discard block
 block discarded – undo
223 232
 					$clean_type_value_pair = strtolower(strtr(trim($type_value_pair), '=', ':'));
224 233
 
225 234
 					// Something like 'font-weight: bold' is expected here.
226
-					if (strpos($clean_type_value_pair, ':') === false)
227
-						continue;
235
+					if (strpos($clean_type_value_pair, ':') === false) {
236
+											continue;
237
+					}
228 238
 
229 239
 					// Capture the elements of a single style item (e.g. 'font-weight' and 'bold').
230 240
 					list ($style_type, $style_value) = explode(':', $type_value_pair);
@@ -246,8 +256,7 @@  discard block
 block discarded – undo
246 256
 							{
247 257
 								$curCloseTags .= '[/u]';
248 258
 								$replacement .= '[u]';
249
-							}
250
-							elseif ($style_value == 'line-through')
259
+							} elseif ($style_value == 'line-through')
251 260
 							{
252 261
 								$curCloseTags .= '[/s]';
253 262
 								$replacement .= '[s]';
@@ -259,13 +268,11 @@  discard block
 block discarded – undo
259 268
 							{
260 269
 								$curCloseTags .= '[/left]';
261 270
 								$replacement .= '[left]';
262
-							}
263
-							elseif ($style_value == 'center')
271
+							} elseif ($style_value == 'center')
264 272
 							{
265 273
 								$curCloseTags .= '[/center]';
266 274
 								$replacement .= '[center]';
267
-							}
268
-							elseif ($style_value == 'right')
275
+							} elseif ($style_value == 'right')
269 276
 							{
270 277
 								$curCloseTags .= '[/right]';
271 278
 								$replacement .= '[right]';
@@ -287,8 +294,9 @@  discard block
 block discarded – undo
287 294
 
288 295
 						case 'font-size':
289 296
 							// Sometimes people put decimals where decimals should not be.
290
-							if (preg_match('~(\d)+\.\d+(p[xt])~i', $style_value, $dec_matches) === 1)
291
-								$style_value = $dec_matches[1] . $dec_matches[2];
297
+							if (preg_match('~(\d)+\.\d+(p[xt])~i', $style_value, $dec_matches) === 1) {
298
+															$style_value = $dec_matches[1] . $dec_matches[2];
299
+							}
292 300
 
293 301
 							$curCloseTags .= '[/size]';
294 302
 							$replacement .= '[size=' . $style_value . ']';
@@ -296,8 +304,9 @@  discard block
 block discarded – undo
296 304
 
297 305
 						case 'font-family':
298 306
 							// Only get the first freaking font if there's a list!
299
-							if (strpos($style_value, ',') !== false)
300
-								$style_value = substr($style_value, 0, strpos($style_value, ','));
307
+							if (strpos($style_value, ',') !== false) {
308
+															$style_value = substr($style_value, 0, strpos($style_value, ','));
309
+							}
301 310
 
302 311
 							$curCloseTags .= '[/font]';
303 312
 							$replacement .= '[font=' . strtr($style_value, array("'" => '')) . ']';
@@ -306,13 +315,15 @@  discard block
 block discarded – undo
306 315
 						// This is a hack for images with dimensions embedded.
307 316
 						case 'width':
308 317
 						case 'height':
309
-							if (preg_match('~[1-9]\d*~i', $style_value, $dimension) === 1)
310
-								$extra_attr .= ' ' . $style_type . '="' . $dimension[0] . '"';
318
+							if (preg_match('~[1-9]\d*~i', $style_value, $dimension) === 1) {
319
+															$extra_attr .= ' ' . $style_type . '="' . $dimension[0] . '"';
320
+							}
311 321
 						break;
312 322
 
313 323
 						case 'list-style-type':
314
-							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)
315
-								$extra_attr .= ' listtype="' . $listType[0] . '"';
324
+							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) {
325
+															$extra_attr .= ' listtype="' . $listType[0] . '"';
326
+							}
316 327
 						break;
317 328
 					}
318 329
 				}
@@ -325,18 +336,17 @@  discard block
 block discarded – undo
325 336
 				}
326 337
 
327 338
 				// If there's something that still needs closing, push it to the stack.
328
-				if (!empty($curCloseTags))
329
-					array_push($stack, array(
339
+				if (!empty($curCloseTags)) {
340
+									array_push($stack, array(
330 341
 							'element' => strtolower($curElement),
331 342
 							'closeTags' => $curCloseTags
332 343
 						)
333 344
 					);
334
-				elseif (!empty($extra_attr))
335
-					$replacement .= $precedingStyle . $extra_attr . $afterStyle;
345
+				} elseif (!empty($extra_attr)) {
346
+									$replacement .= $precedingStyle . $extra_attr . $afterStyle;
347
+				}
336 348
 			}
337
-		}
338
-
339
-		elseif (preg_match('~</([A-Za-z]+)>~', $part, $matches) === 1)
349
+		} elseif (preg_match('~</([A-Za-z]+)>~', $part, $matches) === 1)
340 350
 		{
341 351
 			// Is this the element that we've been waiting for to be closed?
342 352
 			if (!empty($stack) && strtolower($matches[1]) === $stack[count($stack) - 1]['element'])
@@ -346,28 +356,32 @@  discard block
 block discarded – undo
346 356
 			}
347 357
 
348 358
 			// Must've been something else.
349
-			else
350
-				$replacement .= $part;
359
+			else {
360
+							$replacement .= $part;
361
+			}
351 362
 		}
352 363
 		// In all other cases, just add the part to the replacement.
353
-		else
354
-			$replacement .= $part;
364
+		else {
365
+					$replacement .= $part;
366
+		}
355 367
 	}
356 368
 
357 369
 	// Now put back the replacement in the text.
358 370
 	$text = $replacement;
359 371
 
360 372
 	// We are not finished yet, request more time.
361
-	if (connection_aborted() && $context['server']['is_apache'])
362
-		@apache_reset_timeout();
373
+	if (connection_aborted() && $context['server']['is_apache']) {
374
+			@apache_reset_timeout();
375
+	}
363 376
 
364 377
 	// Let's pull out any legacy alignments.
365 378
 	while (preg_match('~<([A-Za-z]+)\s+[^<>]*?(align="*(left|center|right)"*)[^<>]*?(/?)>~i', $text, $matches) === 1)
366 379
 	{
367 380
 		// Find the position in the text of this tag over again.
368 381
 		$start_pos = strpos($text, $matches[0]);
369
-		if ($start_pos === false)
370
-			break;
382
+		if ($start_pos === false) {
383
+					break;
384
+		}
371 385
 
372 386
 		// End tag?
373 387
 		if ($matches[4] != '/' && strpos($text, '</' . $matches[1] . '>', $start_pos) !== false)
@@ -381,8 +395,7 @@  discard block
 block discarded – undo
381 395
 
382 396
 			// Put the tags back into the body.
383 397
 			$text = substr($text, 0, $start_pos) . $tag . '[' . $matches[3] . ']' . $content . '[/' . $matches[3] . ']' . substr($text, $end_pos);
384
-		}
385
-		else
398
+		} else
386 399
 		{
387 400
 			// Just get rid of this evil tag.
388 401
 			$text = substr($text, 0, $start_pos) . substr($text, $start_pos + strlen($matches[0]));
@@ -395,8 +408,9 @@  discard block
 block discarded – undo
395 408
 		// Find the position of this again.
396 409
 		$start_pos = strpos($text, $matches[0]);
397 410
 		$end_pos = false;
398
-		if ($start_pos === false)
399
-			break;
411
+		if ($start_pos === false) {
412
+					break;
413
+		}
400 414
 
401 415
 		// This must have an end tag - and we must find the right one.
402 416
 		$lower_text = strtolower($text);
@@ -429,8 +443,9 @@  discard block
 block discarded – undo
429 443
 				break;
430 444
 			}
431 445
 		}
432
-		if ($end_pos === false)
433
-			break;
446
+		if ($end_pos === false) {
447
+					break;
448
+		}
434 449
 
435 450
 		// Now work out what the attributes are.
436 451
 		$attribs = fetchTagAttributes($matches[1]);
@@ -444,11 +459,11 @@  discard block
 block discarded – undo
444 459
 				$v = (int) trim($v);
445 460
 				$v = empty($v) ? 1 : $v;
446 461
 				$tags[] = array('[size=' . $sizes_equivalence[$v] . ']', '[/size]');
462
+			} elseif ($s == 'face') {
463
+							$tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]');
464
+			} elseif ($s == 'color') {
465
+							$tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]');
447 466
 			}
448
-			elseif ($s == 'face')
449
-				$tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]');
450
-			elseif ($s == 'color')
451
-				$tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]');
452 467
 		}
453 468
 
454 469
 		// As before add in our tags.
@@ -456,8 +471,9 @@  discard block
 block discarded – undo
456 471
 		foreach ($tags as $tag)
457 472
 		{
458 473
 			$before .= $tag[0];
459
-			if (isset($tag[1]))
460
-				$after = $tag[1] . $after;
474
+			if (isset($tag[1])) {
475
+							$after = $tag[1] . $after;
476
+			}
461 477
 		}
462 478
 
463 479
 		// Remove the tag so it's never checked again.
@@ -468,8 +484,9 @@  discard block
 block discarded – undo
468 484
 	}
469 485
 
470 486
 	// Almost there, just a little more time.
471
-	if (connection_aborted() && $context['server']['is_apache'])
472
-		@apache_reset_timeout();
487
+	if (connection_aborted() && $context['server']['is_apache']) {
488
+			@apache_reset_timeout();
489
+	}
473 490
 
474 491
 	if (count($parts = preg_split('~<(/?)(li|ol|ul)([^>]*)>~i', $text, null, PREG_SPLIT_DELIM_CAPTURE)) > 1)
475 492
 	{
@@ -525,12 +542,13 @@  discard block
 block discarded – undo
525 542
 						{
526 543
 							$inList = true;
527 544
 
528
-							if ($tag === 'ol')
529
-								$listType = 'decimal';
530
-							elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1)
531
-								$listType = $listTypeMapping[$match[1]];
532
-							else
533
-								$listType = null;
545
+							if ($tag === 'ol') {
546
+															$listType = 'decimal';
547
+							} elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1) {
548
+															$listType = $listTypeMapping[$match[1]];
549
+							} else {
550
+															$listType = null;
551
+							}
534 552
 
535 553
 							$listDepth++;
536 554
 
@@ -594,9 +612,7 @@  discard block
 block discarded – undo
594 612
 							$parts[$i + 1] = '';
595 613
 							$parts[$i + 2] = str_repeat("\t", $listDepth) . '[/list]';
596 614
 							$parts[$i + 3] = '';
597
-						}
598
-
599
-						else
615
+						} else
600 616
 						{
601 617
 							// We're in a list item.
602 618
 							if ($listDepth > 0)
@@ -633,9 +649,7 @@  discard block
 block discarded – undo
633 649
 							$parts[$i + 1] = '';
634 650
 							$parts[$i + 2] = '';
635 651
 							$parts[$i + 3] = '';
636
-						}
637
-
638
-						else
652
+						} else
639 653
 						{
640 654
 							// Remove the trailing breaks from the list item.
641 655
 							$parts[$i] = preg_replace('~\s*<br\s*' . '/?' . '>\s*$~', '', $parts[$i]);
@@ -673,8 +687,9 @@  discard block
 block discarded – undo
673 687
 			$text .= str_repeat("\t", $listDepth) . '[/list]';
674 688
 		}
675 689
 
676
-		for ($i = $listDepth; $i > 0; $i--)
677
-			$text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]';
690
+		for ($i = $listDepth; $i > 0; $i--) {
691
+					$text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]';
692
+		}
678 693
 
679 694
 	}
680 695
 
@@ -683,8 +698,9 @@  discard block
 block discarded – undo
683 698
 	{
684 699
 		// Find the position of the image.
685 700
 		$start_pos = strpos($text, $matches[0]);
686
-		if ($start_pos === false)
687
-			break;
701
+		if ($start_pos === false) {
702
+					break;
703
+		}
688 704
 		$end_pos = $start_pos + strlen($matches[0]);
689 705
 
690 706
 		$params = '';
@@ -693,12 +709,13 @@  discard block
 block discarded – undo
693 709
 		$attrs = fetchTagAttributes($matches[1]);
694 710
 		foreach ($attrs as $attrib => $value)
695 711
 		{
696
-			if (in_array($attrib, array('width', 'height')))
697
-				$params .= ' ' . $attrib . '=' . (int) $value;
698
-			elseif ($attrib == 'alt' && trim($value) != '')
699
-				$params .= ' alt=' . trim($value);
700
-			elseif ($attrib == 'src')
701
-				$src = trim($value);
712
+			if (in_array($attrib, array('width', 'height'))) {
713
+							$params .= ' ' . $attrib . '=' . (int) $value;
714
+			} elseif ($attrib == 'alt' && trim($value) != '') {
715
+							$params .= ' alt=' . trim($value);
716
+			} elseif ($attrib == 'src') {
717
+							$src = trim($value);
718
+			}
702 719
 		}
703 720
 
704 721
 		$tag = '';
@@ -709,10 +726,11 @@  discard block
 block discarded – undo
709 726
 			{
710 727
 				$baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']);
711 728
 
712
-				if (substr($src, 0, 1) === '/')
713
-					$src = $baseURL . $src;
714
-				else
715
-					$src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src;
729
+				if (substr($src, 0, 1) === '/') {
730
+									$src = $baseURL . $src;
731
+				} else {
732
+									$src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src;
733
+				}
716 734
 			}
717 735
 
718 736
 			$tag = '[img' . $params . ']' . $src . '[/img]';
@@ -890,20 +908,23 @@  discard block
 block discarded – undo
890 908
 		},
891 909
 	);
892 910
 
893
-	foreach ($tags as $tag => $replace)
894
-		$text = preg_replace_callback($tag, $replace, $text);
911
+	foreach ($tags as $tag => $replace) {
912
+			$text = preg_replace_callback($tag, $replace, $text);
913
+	}
895 914
 
896 915
 	// Please give us just a little more time.
897
-	if (connection_aborted() && $context['server']['is_apache'])
898
-		@apache_reset_timeout();
916
+	if (connection_aborted() && $context['server']['is_apache']) {
917
+			@apache_reset_timeout();
918
+	}
899 919
 
900 920
 	// What about URL's - the pain in the ass of the tag world.
901 921
 	while (preg_match('~<a\s+([^<>]*)>([^<>]*)</a>~i', $text, $matches) === 1)
902 922
 	{
903 923
 		// Find the position of the URL.
904 924
 		$start_pos = strpos($text, $matches[0]);
905
-		if ($start_pos === false)
906
-			break;
925
+		if ($start_pos === false) {
926
+					break;
927
+		}
907 928
 		$end_pos = $start_pos + strlen($matches[0]);
908 929
 
909 930
 		$tag_type = 'url';
@@ -917,8 +938,9 @@  discard block
 block discarded – undo
917 938
 				$href = trim($value);
918 939
 
919 940
 				// Are we dealing with an FTP link?
920
-				if (preg_match('~^ftps?://~', $href) === 1)
921
-					$tag_type = 'ftp';
941
+				if (preg_match('~^ftps?://~', $href) === 1) {
942
+									$tag_type = 'ftp';
943
+				}
922 944
 
923 945
 				// Or is this a link to an email address?
924 946
 				elseif (substr($href, 0, 7) == 'mailto:')
@@ -932,28 +954,31 @@  discard block
 block discarded – undo
932 954
 				{
933 955
 					$baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']);
934 956
 
935
-					if (substr($href, 0, 1) === '/')
936
-						$href = $baseURL . $href;
937
-					else
938
-						$href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href;
957
+					if (substr($href, 0, 1) === '/') {
958
+											$href = $baseURL . $href;
959
+					} else {
960
+											$href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href;
961
+					}
939 962
 				}
940 963
 			}
941 964
 
942 965
 			// External URL?
943 966
 			if ($attrib == 'target' && $tag_type == 'url')
944 967
 			{
945
-				if (trim($value) == '_blank')
946
-					$tag_type == 'iurl';
968
+				if (trim($value) == '_blank') {
969
+									$tag_type == 'iurl';
970
+				}
947 971
 			}
948 972
 		}
949 973
 
950 974
 		$tag = '';
951 975
 		if ($href != '')
952 976
 		{
953
-			if ($matches[2] == $href)
954
-				$tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']';
955
-			else
956
-				$tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']';
977
+			if ($matches[2] == $href) {
978
+							$tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']';
979
+			} else {
980
+							$tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']';
981
+			}
957 982
 		}
958 983
 
959 984
 		// Replace the tag
@@ -992,17 +1017,18 @@  discard block
 block discarded – undo
992 1017
 		// We're either moving from the key to the attribute or we're in a string and this is fine.
993 1018
 		if ($text[$i] == '=')
994 1019
 		{
995
-			if ($tag_state == 0)
996
-				$tag_state = 1;
997
-			elseif ($tag_state == 2)
998
-				$value .= '=';
1020
+			if ($tag_state == 0) {
1021
+							$tag_state = 1;
1022
+			} elseif ($tag_state == 2) {
1023
+							$value .= '=';
1024
+			}
999 1025
 		}
1000 1026
 		// A space is either moving from an attribute back to a potential key or in a string is fine.
1001 1027
 		elseif ($text[$i] == ' ')
1002 1028
 		{
1003
-			if ($tag_state == 2)
1004
-				$value .= ' ';
1005
-			elseif ($tag_state == 1)
1029
+			if ($tag_state == 2) {
1030
+							$value .= ' ';
1031
+			} elseif ($tag_state == 1)
1006 1032
 			{
1007 1033
 				$attribs[$key] = $value;
1008 1034
 				$key = $value = '';
@@ -1013,24 +1039,27 @@  discard block
 block discarded – undo
1013 1039
 		elseif ($text[$i] == '"')
1014 1040
 		{
1015 1041
 			// Must be either going into or out of a string.
1016
-			if ($tag_state == 1)
1017
-				$tag_state = 2;
1018
-			else
1019
-				$tag_state = 1;
1042
+			if ($tag_state == 1) {
1043
+							$tag_state = 2;
1044
+			} else {
1045
+							$tag_state = 1;
1046
+			}
1020 1047
 		}
1021 1048
 		// Otherwise it's fine.
1022 1049
 		else
1023 1050
 		{
1024
-			if ($tag_state == 0)
1025
-				$key .= $text[$i];
1026
-			else
1027
-				$value .= $text[$i];
1051
+			if ($tag_state == 0) {
1052
+							$key .= $text[$i];
1053
+			} else {
1054
+							$value .= $text[$i];
1055
+			}
1028 1056
 		}
1029 1057
 	}
1030 1058
 
1031 1059
 	// Anything left?
1032
-	if ($key != '' && $value != '')
1033
-		$attribs[$key] = $value;
1060
+	if ($key != '' && $value != '') {
1061
+			$attribs[$key] = $value;
1062
+	}
1034 1063
 
1035 1064
 	return $attribs;
1036 1065
 }
@@ -1046,15 +1075,17 @@  discard block
 block discarded – undo
1046 1075
 	global $modSettings;
1047 1076
 
1048 1077
 	// Don't care about the texts that are too short.
1049
-	if (strlen($text) < 3)
1050
-		return $text;
1078
+	if (strlen($text) < 3) {
1079
+			return $text;
1080
+	}
1051 1081
 
1052 1082
 	// A list of tags that's disabled by the admin.
1053 1083
 	$disabled = empty($modSettings['disabledBBC']) ? array() : array_flip(explode(',', strtolower($modSettings['disabledBBC'])));
1054 1084
 
1055 1085
 	// Add flash if it's disabled as embedded tag.
1056
-	if (empty($modSettings['enableEmbeddedFlash']))
1057
-		$disabled['flash'] = true;
1086
+	if (empty($modSettings['enableEmbeddedFlash'])) {
1087
+			$disabled['flash'] = true;
1088
+	}
1058 1089
 
1059 1090
 	// Get a list of all the tags that are not disabled.
1060 1091
 	$all_tags = parse_bbc(false);
@@ -1062,10 +1093,12 @@  discard block
 block discarded – undo
1062 1093
 	$self_closing_tags = array();
1063 1094
 	foreach ($all_tags as $tag)
1064 1095
 	{
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'];
1096
+		if (!isset($disabled[$tag['tag']])) {
1097
+					$valid_tags[$tag['tag']] = !empty($tag['block_level']);
1098
+		}
1099
+		if (isset($tag['type']) && $tag['type'] == 'closed') {
1100
+					$self_closing_tags[] = $tag['tag'];
1101
+		}
1069 1102
 	}
1070 1103
 
1071 1104
 	// 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 +1125,19 @@  discard block
 block discarded – undo
1092 1125
 				$tagName = substr($match, $isClosingTag ? 2 : 1, -1);
1093 1126
 
1094 1127
 				// We're closing the exact same tag that we opened.
1095
-				if ($isClosingTag && $insideTag === $tagName)
1096
-					$insideTag = null;
1128
+				if ($isClosingTag && $insideTag === $tagName) {
1129
+									$insideTag = null;
1130
+				}
1097 1131
 
1098 1132
 				// We're opening a tag and we're not yet inside one either
1099
-				elseif (!$isClosingTag && $insideTag === null)
1100
-					$insideTag = $tagName;
1133
+				elseif (!$isClosingTag && $insideTag === null) {
1134
+									$insideTag = $tagName;
1135
+				}
1101 1136
 
1102 1137
 				// In all other cases, this tag must be invalid
1103
-				else
1104
-					unset($matches[$i]);
1138
+				else {
1139
+									unset($matches[$i]);
1140
+				}
1105 1141
 			}
1106 1142
 
1107 1143
 			// The next one is gonna be the other one.
@@ -1109,8 +1145,9 @@  discard block
 block discarded – undo
1109 1145
 		}
1110 1146
 
1111 1147
 		// We're still inside a tag and had no chance for closure?
1112
-		if ($insideTag !== null)
1113
-			$matches[] = '[/' . $insideTag . ']';
1148
+		if ($insideTag !== null) {
1149
+					$matches[] = '[/' . $insideTag . ']';
1150
+		}
1114 1151
 
1115 1152
 		// And a complete text string again.
1116 1153
 		$text = implode('', $matches);
@@ -1119,8 +1156,9 @@  discard block
 block discarded – undo
1119 1156
 	// Quickly remove any tags which are back to back.
1120 1157
 	$backToBackPattern = '~\\[(' . implode('|', array_diff(array_keys($valid_tags), array('td', 'anchor'))) . ')[^<>\\[\\]]*\\]\s*\\[/\\1\\]~';
1121 1158
 	$lastlen = 0;
1122
-	while (strlen($text) !== $lastlen)
1123
-		$lastlen = strlen($text = preg_replace($backToBackPattern, '', $text));
1159
+	while (strlen($text) !== $lastlen) {
1160
+			$lastlen = strlen($text = preg_replace($backToBackPattern, '', $text));
1161
+	}
1124 1162
 
1125 1163
 	// Need to sort the tags my name length.
1126 1164
 	uksort($valid_tags, 'sort_array_length');
@@ -1157,8 +1195,9 @@  discard block
 block discarded – undo
1157 1195
 			$isCompetingTag = in_array($tag, $competing_tags);
1158 1196
 
1159 1197
 			// Check if this might be one of those cleaned out tags.
1160
-			if ($tag === '')
1161
-				continue;
1198
+			if ($tag === '') {
1199
+							continue;
1200
+			}
1162 1201
 
1163 1202
 			// Special case: inside [code] blocks any code is left untouched.
1164 1203
 			elseif ($tag === 'code')
@@ -1169,8 +1208,9 @@  discard block
 block discarded – undo
1169 1208
 					$inCode = false;
1170 1209
 
1171 1210
 					// Reopen tags that were closed before the code block.
1172
-					if (!empty($inlineElements))
1173
-						$parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']';
1211
+					if (!empty($inlineElements)) {
1212
+											$parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']';
1213
+					}
1174 1214
 				}
1175 1215
 
1176 1216
 				// We're outside a coding and nobbc block and opening it.
@@ -1199,8 +1239,9 @@  discard block
 block discarded – undo
1199 1239
 					$inNoBbc = false;
1200 1240
 
1201 1241
 					// Some inline elements might've been closed that need reopening.
1202
-					if (!empty($inlineElements))
1203
-						$parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']';
1242
+					if (!empty($inlineElements)) {
1243
+											$parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']';
1244
+					}
1204 1245
 				}
1205 1246
 
1206 1247
 				// We're outside a nobbc and coding block and opening it.
@@ -1220,8 +1261,9 @@  discard block
 block discarded – undo
1220 1261
 			}
1221 1262
 
1222 1263
 			// So, we're inside one of the special blocks: ignore any tag.
1223
-			elseif ($inCode || $inNoBbc)
1224
-				continue;
1264
+			elseif ($inCode || $inNoBbc) {
1265
+							continue;
1266
+			}
1225 1267
 
1226 1268
 			// We're dealing with an opening tag.
1227 1269
 			if ($isOpeningTag)
@@ -1262,8 +1304,9 @@  discard block
 block discarded – undo
1262 1304
 							if ($parts[$j + 3] === $tag)
1263 1305
 							{
1264 1306
 								// If it's an opening tag, increase the level.
1265
-								if ($parts[$j + 2] === '')
1266
-									$curLevel++;
1307
+								if ($parts[$j + 2] === '') {
1308
+																	$curLevel++;
1309
+								}
1267 1310
 
1268 1311
 								// A closing tag, decrease the level.
1269 1312
 								else
@@ -1286,13 +1329,15 @@  discard block
 block discarded – undo
1286 1329
 					{
1287 1330
 						if ($isCompetingTag)
1288 1331
 						{
1289
-							if (!isset($competingElements[$tag]))
1290
-								$competingElements[$tag] = array();
1332
+							if (!isset($competingElements[$tag])) {
1333
+															$competingElements[$tag] = array();
1334
+							}
1291 1335
 
1292 1336
 							$competingElements[$tag][] = $parts[$i + 4];
1293 1337
 
1294
-							if (count($competingElements[$tag]) > 1)
1295
-								$parts[$i] .= '[/' . $tag . ']';
1338
+							if (count($competingElements[$tag]) > 1) {
1339
+															$parts[$i] .= '[/' . $tag . ']';
1340
+							}
1296 1341
 						}
1297 1342
 
1298 1343
 						$inlineElements[$elementContent] = $tag;
@@ -1313,15 +1358,17 @@  discard block
 block discarded – undo
1313 1358
 						$addClosingTags = array();
1314 1359
 						while ($element = array_pop($blockElements))
1315 1360
 						{
1316
-							if ($element === $tag)
1317
-								break;
1361
+							if ($element === $tag) {
1362
+															break;
1363
+							}
1318 1364
 
1319 1365
 							// Still a block tag was open not equal to this tag.
1320 1366
 							$addClosingTags[] = $element['type'];
1321 1367
 						}
1322 1368
 
1323
-						if (!empty($addClosingTags))
1324
-							$parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1];
1369
+						if (!empty($addClosingTags)) {
1370
+													$parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1];
1371
+						}
1325 1372
 
1326 1373
 						// Apparently the closing tag was not found on the stack.
1327 1374
 						if (!is_string($element) || $element !== $tag)
@@ -1331,8 +1378,7 @@  discard block
 block discarded – undo
1331 1378
 							$parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = '';
1332 1379
 							continue;
1333 1380
 						}
1334
-					}
1335
-					else
1381
+					} else
1336 1382
 					{
1337 1383
 						// Get rid of this closing tag!
1338 1384
 						$parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = '';
@@ -1361,53 +1407,62 @@  discard block
 block discarded – undo
1361 1407
 							unset($inlineElements[$tagContentToBeClosed]);
1362 1408
 
1363 1409
 							// Was this the tag we were looking for?
1364
-							if ($tagToBeClosed === $tag)
1365
-								break;
1410
+							if ($tagToBeClosed === $tag) {
1411
+															break;
1412
+							}
1366 1413
 
1367 1414
 							// Nope, close it and look further!
1368
-							else
1369
-								$parts[$i] .= '[/' . $tagToBeClosed . ']';
1415
+							else {
1416
+															$parts[$i] .= '[/' . $tagToBeClosed . ']';
1417
+							}
1370 1418
 						}
1371 1419
 
1372 1420
 						if ($isCompetingTag && !empty($competingElements[$tag]))
1373 1421
 						{
1374 1422
 							array_pop($competingElements[$tag]);
1375 1423
 
1376
-							if (count($competingElements[$tag]) > 0)
1377
-								$parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5];
1424
+							if (count($competingElements[$tag]) > 0) {
1425
+															$parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5];
1426
+							}
1378 1427
 						}
1379 1428
 					}
1380 1429
 
1381 1430
 					// Unexpected closing tag, ex-ter-mi-nate.
1382
-					else
1383
-						$parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = '';
1431
+					else {
1432
+											$parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = '';
1433
+					}
1384 1434
 				}
1385 1435
 			}
1386 1436
 		}
1387 1437
 
1388 1438
 		// Close the code tags.
1389
-		if ($inCode)
1390
-			$parts[$i] .= '[/code]';
1439
+		if ($inCode) {
1440
+					$parts[$i] .= '[/code]';
1441
+		}
1391 1442
 
1392 1443
 		// The same for nobbc tags.
1393
-		elseif ($inNoBbc)
1394
-			$parts[$i] .= '[/nobbc]';
1444
+		elseif ($inNoBbc) {
1445
+					$parts[$i] .= '[/nobbc]';
1446
+		}
1395 1447
 
1396 1448
 		// Still inline tags left unclosed? Close them now, better late than never.
1397
-		elseif (!empty($inlineElements))
1398
-			$parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']';
1449
+		elseif (!empty($inlineElements)) {
1450
+					$parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']';
1451
+		}
1399 1452
 
1400 1453
 		// Now close the block elements.
1401
-		if (!empty($blockElements))
1402
-			$parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']';
1454
+		if (!empty($blockElements)) {
1455
+					$parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']';
1456
+		}
1403 1457
 
1404 1458
 		$text = implode('', $parts);
1405 1459
 	}
1406 1460
 
1407 1461
 	// Final clean up of back to back tags.
1408 1462
 	$lastlen = 0;
1409
-	while (strlen($text) !== $lastlen)
1410
-		$lastlen = strlen($text = preg_replace($backToBackPattern, '', $text));
1463
+	while (strlen($text) !== $lastlen) {
1464
+			$lastlen = strlen($text = preg_replace($backToBackPattern, '', $text));
1465
+	}
1411 1466
 
1412 1467
 	return $text;
1413 1468
 }
@@ -1436,22 +1491,25 @@  discard block
 block discarded – undo
1436 1491
 	$context['template_layers'] = array();
1437 1492
 	// Lets make sure we aren't going to output anything nasty.
1438 1493
 	@ob_end_clean();
1439
-	if (!empty($modSettings['enableCompressedOutput']))
1440
-		@ob_start('ob_gzhandler');
1441
-	else
1442
-		@ob_start();
1494
+	if (!empty($modSettings['enableCompressedOutput'])) {
1495
+			@ob_start('ob_gzhandler');
1496
+	} else {
1497
+			@ob_start();
1498
+	}
1443 1499
 
1444 1500
 	// If we don't have any locale better avoid broken js
1445
-	if (empty($txt['lang_locale']))
1446
-		die();
1501
+	if (empty($txt['lang_locale'])) {
1502
+			die();
1503
+	}
1447 1504
 
1448 1505
 	$file_data = '(function ($) {
1449 1506
 	\'use strict\';
1450 1507
 
1451 1508
 	$.sceditor.locale[' . JavaScriptEscape($txt['lang_locale']) . '] = {';
1452
-	foreach ($editortxt as $key => $val)
1453
-		$file_data .= '
1509
+	foreach ($editortxt as $key => $val) {
1510
+			$file_data .= '
1454 1511
 		' . JavaScriptEscape($key) . ': ' . JavaScriptEscape($val) . ',';
1512
+	}
1455 1513
 
1456 1514
 	$file_data .= '
1457 1515
 		dateFormat: "day.month.year"
@@ -1519,8 +1577,9 @@  discard block
 block discarded – undo
1519 1577
 				)
1520 1578
 			);
1521 1579
 			$icon_data = array();
1522
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1523
-				$icon_data[] = $row;
1580
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
1581
+							$icon_data[] = $row;
1582
+			}
1524 1583
 			$smcFunc['db_free_result']($request);
1525 1584
 
1526 1585
 			$icons = array();
@@ -1535,9 +1594,9 @@  discard block
 block discarded – undo
1535 1594
 			}
1536 1595
 
1537 1596
 			cache_put_data('posting_icons-' . $board_id, $icons, 480);
1597
+		} else {
1598
+					$icons = $temp;
1538 1599
 		}
1539
-		else
1540
-			$icons = $temp;
1541 1600
 	}
1542 1601
 	call_integration_hook('integrate_load_message_icons', array(&$icons));
1543 1602
 
@@ -1579,8 +1638,9 @@  discard block
 block discarded – undo
1579 1638
 	{
1580 1639
 		// Some general stuff.
1581 1640
 		$settings['smileys_url'] = $modSettings['smileys_url'] . '/' . $user_info['smiley_set'];
1582
-		if (!empty($context['drafts_autosave']))
1583
-			$context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000;
1641
+		if (!empty($context['drafts_autosave'])) {
1642
+					$context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000;
1643
+		}
1584 1644
 
1585 1645
 		// This really has some WYSIWYG stuff.
1586 1646
 		loadCSSFile('jquery.sceditor.css', array('force_current' => false, 'validate' => true), 'smf_jquery_sceditor');
@@ -1598,8 +1658,9 @@  discard block
 block discarded – undo
1598 1658
 		var bbc_quote = \'' . addcslashes($txt['quote'], "'") . '\';
1599 1659
 		var bbc_search_on = \'' . addcslashes($txt['search_on'], "'") . '\';');
1600 1660
 		// editor language file
1601
-		if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US')
1602
-			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
+		}
1603 1664
 
1604 1665
 		$context['shortcuts_text'] = $txt['shortcuts' . (!empty($context['drafts_save']) ? '_drafts' : '') . (stripos($_SERVER['HTTP_USER_AGENT'], 'Macintosh') !== false ? '_mac' : (isBrowser('is_firefox') ? '_firefox' : ''))];
1605 1666
 		$context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv'))));
@@ -1608,11 +1669,12 @@  discard block
 block discarded – undo
1608 1669
 			loadJavaScriptFile('spellcheck.js', array(), 'smf_spellcheck');
1609 1670
 
1610 1671
 			// Some hidden information is needed in order to make the spell checking work.
1611
-			if (!isset($_REQUEST['xml']))
1612
-				$context['insert_after_template'] .= '
1672
+			if (!isset($_REQUEST['xml'])) {
1673
+							$context['insert_after_template'] .= '
1613 1674
 		<form name="spell_form" id="spell_form" method="post" accept-charset="' . $context['character_set'] . '" target="spellWindow" action="' . $scripturl . '?action=spellcheck">
1614 1675
 			<input type="hidden" name="spellstring" value="">
1615 1676
 		</form>';
1677
+			}
1616 1678
 		}
1617 1679
 	}
1618 1680
 
@@ -1803,10 +1865,12 @@  discard block
 block discarded – undo
1803 1865
 
1804 1866
 		// Generate a list of buttons that shouldn't be shown - this should be the fastest way to do this.
1805 1867
 		$disabled_tags = array();
1806
-		if (!empty($modSettings['disabledBBC']))
1807
-			$disabled_tags = explode(',', $modSettings['disabledBBC']);
1808
-		if (empty($modSettings['enableEmbeddedFlash']))
1809
-			$disabled_tags[] = 'flash';
1868
+		if (!empty($modSettings['disabledBBC'])) {
1869
+					$disabled_tags = explode(',', $modSettings['disabledBBC']);
1870
+		}
1871
+		if (empty($modSettings['enableEmbeddedFlash'])) {
1872
+					$disabled_tags[] = 'flash';
1873
+		}
1810 1874
 
1811 1875
 		foreach ($disabled_tags as $tag)
1812 1876
 		{
@@ -1818,9 +1882,10 @@  discard block
 block discarded – undo
1818 1882
 				$context['disabled_tags']['orderedlist'] = true;
1819 1883
 			}
1820 1884
 
1821
-			foreach ($editor_tag_map as $thisTag => $tagNameBBC)
1822
-				if ($tag === $thisTag)
1885
+			foreach ($editor_tag_map as $thisTag => $tagNameBBC) {
1886
+							if ($tag === $thisTag)
1823 1887
 					$context['disabled_tags'][$tagNameBBC] = true;
1888
+			}
1824 1889
 
1825 1890
 			$context['disabled_tags'][$tag] = true;
1826 1891
 		}
@@ -1831,8 +1896,9 @@  discard block
 block discarded – undo
1831 1896
 
1832 1897
 		foreach ($context['bbc_tags'] as $row => $tagRow)
1833 1898
 		{
1834
-			if (!isset($context['bbc_toolbar'][$row]))
1835
-				$context['bbc_toolbar'][$row] = array();
1899
+			if (!isset($context['bbc_toolbar'][$row])) {
1900
+							$context['bbc_toolbar'][$row] = array();
1901
+			}
1836 1902
 
1837 1903
 			$tagsRow = array();
1838 1904
 
@@ -1868,20 +1934,21 @@  discard block
 block discarded – undo
1868 1934
 
1869 1935
 					$context['bbcodes_handlers'] .= '
1870 1936
 						});';
1871
-				}
1872
-				else
1937
+				} else
1873 1938
 				{
1874 1939
 					$context['bbc_toolbar'][$row][] = implode(',', $tagsRow);
1875 1940
 					$tagsRow = array();
1876 1941
 				}
1877 1942
 			}
1878 1943
 
1879
-			if (!empty($tagsRow))
1880
-				$context['bbc_toolbar'][$row][] = implode(',', $tagsRow);
1944
+			if (!empty($tagsRow)) {
1945
+							$context['bbc_toolbar'][$row][] = implode(',', $tagsRow);
1946
+			}
1881 1947
 		}
1882 1948
 
1883
-		if (!empty($bbcodes_styles))
1884
-			addInlineCss($bbcodes_styles);
1949
+		if (!empty($bbcodes_styles)) {
1950
+					addInlineCss($bbcodes_styles);
1951
+		}
1885 1952
 	}
1886 1953
 
1887 1954
 	// Initialize smiley array... if not loaded before.
@@ -1893,8 +1960,8 @@  discard block
 block discarded – undo
1893 1960
 		);
1894 1961
 
1895 1962
 		// 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(
1963
+		if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none') {
1964
+					$context['smileys']['postform'][] = array(
1898 1965
 				'smileys' => array(
1899 1966
 					array(
1900 1967
 						'code' => ':)',
@@ -1980,7 +2047,7 @@  discard block
 block discarded – undo
1980 2047
 				),
1981 2048
 				'isLast' => true,
1982 2049
 			);
1983
-		elseif ($user_info['smiley_set'] != 'none')
2050
+		} elseif ($user_info['smiley_set'] != 'none')
1984 2051
 		{
1985 2052
 			if (($temp = cache_get_data('posting_smileys', 480)) == null)
1986 2053
 			{
@@ -2003,17 +2070,19 @@  discard block
 block discarded – undo
2003 2070
 
2004 2071
 				foreach ($context['smileys'] as $section => $smileyRows)
2005 2072
 				{
2006
-					foreach ($smileyRows as $rowIndex => $smileys)
2007
-						$context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true;
2073
+					foreach ($smileyRows as $rowIndex => $smileys) {
2074
+											$context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true;
2075
+					}
2008 2076
 
2009
-					if (!empty($smileyRows))
2010
-						$context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true;
2077
+					if (!empty($smileyRows)) {
2078
+											$context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true;
2079
+					}
2011 2080
 				}
2012 2081
 
2013 2082
 				cache_put_data('posting_smileys', $context['smileys'], 480);
2083
+			} else {
2084
+							$context['smileys'] = $temp;
2014 2085
 			}
2015
-			else
2016
-				$context['smileys'] = $temp;
2017 2086
 		}
2018 2087
 	}
2019 2088
 
@@ -2029,12 +2098,15 @@  discard block
 block discarded – undo
2029 2098
 		'plugins' => 'undo' . (empty($modSettings['disabledBBC']) || strpos($modSettings['disabledBBC'], 'youtube') === false ? ',autoyoutube' : ''),
2030 2099
 		'bbcodeTrim' => true,
2031 2100
 	);
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;
2101
+	if (!empty($context['controls']['richedit'][$editorOptions['id']]['locale'])) {
2102
+			$sce_options['locale'] = $context['controls']['richedit'][$editorOptions['id']]['locale'];
2103
+	}
2104
+	if (!empty($context['right_to_left'])) {
2105
+			$sce_options['rtl'] = true;
2106
+	}
2107
+	if ($editorOptions['id'] != 'quickReply') {
2108
+			$sce_options['autofocus'] = true;
2109
+	}
2038 2110
 
2039 2111
 	$sce_options['emoticons'] = array();
2040 2112
 	$sce_options['emoticonsEnabled'] = false;
@@ -2050,10 +2122,11 @@  discard block
 block discarded – undo
2050 2122
 			$countLocations--;
2051 2123
 
2052 2124
 			unset($smiley_location);
2053
-			if ($location == 'postform')
2054
-				$smiley_location = &$sce_options['emoticons']['dropdown'];
2055
-			elseif ($location == 'popup')
2056
-				$smiley_location = &$sce_options['emoticons']['popup'];
2125
+			if ($location == 'postform') {
2126
+							$smiley_location = &$sce_options['emoticons']['dropdown'];
2127
+			} elseif ($location == 'popup') {
2128
+							$smiley_location = &$sce_options['emoticons']['popup'];
2129
+			}
2057 2130
 
2058 2131
 			$numRows = count($smileyRows);
2059 2132
 
@@ -2061,11 +2134,13 @@  discard block
 block discarded – undo
2061 2134
 			$emptyPlaceholder = 0;
2062 2135
 			foreach ($smileyRows as $smileyRow)
2063 2136
 			{
2064
-				foreach ($smileyRow['smileys'] as $smiley)
2065
-					$smiley_location[$smiley['code']] = $settings['smileys_url'] . '/' . $smiley['filename'];
2137
+				foreach ($smileyRow['smileys'] as $smiley) {
2138
+									$smiley_location[$smiley['code']] = $settings['smileys_url'] . '/' . $smiley['filename'];
2139
+				}
2066 2140
 
2067
-				if (empty($smileyRow['isLast']) && $numRows != 1)
2068
-					$smiley_location['-' . $emptyPlaceholder++] = '';
2141
+				if (empty($smileyRow['isLast']) && $numRows != 1) {
2142
+									$smiley_location['-' . $emptyPlaceholder++] = '';
2143
+				}
2069 2144
 			}
2070 2145
 		}
2071 2146
 	}
@@ -2080,8 +2155,9 @@  discard block
 block discarded – undo
2080 2155
 
2081 2156
 			$count_tags--;
2082 2157
 
2083
-			if (!empty($count_tags))
2084
-				$sce_options['toolbar'] .= '||';
2158
+			if (!empty($count_tags)) {
2159
+							$sce_options['toolbar'] .= '||';
2160
+			}
2085 2161
 		}
2086 2162
 	}
2087 2163
 
@@ -2109,8 +2185,9 @@  discard block
 block discarded – undo
2109 2185
 		loadTemplate('GenericControls');
2110 2186
 
2111 2187
 		// Some javascript ma'am?
2112
-		if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual'])))
2113
-			loadJavaScriptFile('captcha.js', array(), 'smf_captcha');
2188
+		if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual']))) {
2189
+					loadJavaScriptFile('captcha.js', array(), 'smf_captcha');
2190
+		}
2114 2191
 
2115 2192
 		$context['use_graphic_library'] = in_array('gd', get_loaded_extensions());
2116 2193
 
@@ -2123,8 +2200,8 @@  discard block
 block discarded – undo
2123 2200
 	$isNew = !isset($context['controls']['verification'][$verificationOptions['id']]);
2124 2201
 
2125 2202
 	// Log this into our collection.
2126
-	if ($isNew)
2127
-		$context['controls']['verification'][$verificationOptions['id']] = array(
2203
+	if ($isNew) {
2204
+			$context['controls']['verification'][$verificationOptions['id']] = array(
2128 2205
 			'id' => $verificationOptions['id'],
2129 2206
 			'empty_field' => empty($verificationOptions['no_empty_field']),
2130 2207
 			'show_visual' => !empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual'])),
@@ -2135,13 +2212,15 @@  discard block
 block discarded – undo
2135 2212
 			'questions' => array(),
2136 2213
 			'can_recaptcha' => !empty($modSettings['recaptcha_enabled']) && !empty($modSettings['recaptcha_site_key']) && !empty($modSettings['recaptcha_secret_key']),
2137 2214
 		);
2215
+	}
2138 2216
 	$thisVerification = &$context['controls']['verification'][$verificationOptions['id']];
2139 2217
 
2140 2218
 	// Is there actually going to be anything?
2141
-	if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha']))
2142
-		return false;
2143
-	elseif (!$isNew && !$do_test)
2144
-		return true;
2219
+	if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha'])) {
2220
+			return false;
2221
+	} elseif (!$isNew && !$do_test) {
2222
+			return true;
2223
+	}
2145 2224
 
2146 2225
 	// Sanitize reCAPTCHA fields?
2147 2226
 	if ($thisVerification['can_recaptcha'])
@@ -2154,11 +2233,12 @@  discard block
 block discarded – undo
2154 2233
 	}
2155 2234
 
2156 2235
 	// Add javascript for the object.
2157
-	if ($context['controls']['verification'][$verificationOptions['id']]['show_visual'])
2158
-		$context['insert_after_template'] .= '
2236
+	if ($context['controls']['verification'][$verificationOptions['id']]['show_visual']) {
2237
+			$context['insert_after_template'] .= '
2159 2238
 			<script>
2160 2239
 				var verification' . $verificationOptions['id'] . 'Handle = new smfCaptcha("' . $thisVerification['image_href'] . '", "' . $verificationOptions['id'] . '", ' . ($context['use_graphic_library'] ? 1 : 0) . ');
2161 2240
 			</script>';
2241
+	}
2162 2242
 
2163 2243
 	// If we want questions do we have a cache of all the IDs?
2164 2244
 	if (!empty($thisVerification['number_questions']) && empty($modSettings['question_id_cache']))
@@ -2181,8 +2261,9 @@  discard block
 block discarded – undo
2181 2261
 				unset ($row['id_question']);
2182 2262
 				// Make them all lowercase. We can't directly use $smcFunc['strtolower'] with array_walk, so do it manually, eh?
2183 2263
 				$row['answers'] = $smcFunc['json_decode']($row['answers'], true);
2184
-				foreach ($row['answers'] as $k => $v)
2185
-					$row['answers'][$k] = $smcFunc['strtolower']($v);
2264
+				foreach ($row['answers'] as $k => $v) {
2265
+									$row['answers'][$k] = $smcFunc['strtolower']($v);
2266
+				}
2186 2267
 
2187 2268
 				$modSettings['question_id_cache']['questions'][$id_question] = $row;
2188 2269
 				$modSettings['question_id_cache']['langs'][$row['lngfile']][] = $id_question;
@@ -2193,35 +2274,42 @@  discard block
 block discarded – undo
2193 2274
 		}
2194 2275
 	}
2195 2276
 
2196
-	if (!isset($_SESSION[$verificationOptions['id'] . '_vv']))
2197
-		$_SESSION[$verificationOptions['id'] . '_vv'] = array();
2277
+	if (!isset($_SESSION[$verificationOptions['id'] . '_vv'])) {
2278
+			$_SESSION[$verificationOptions['id'] . '_vv'] = array();
2279
+	}
2198 2280
 
2199 2281
 	// Do we need to refresh the verification?
2200
-	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']))
2201
-		$force_refresh = true;
2202
-	else
2203
-		$force_refresh = false;
2282
+	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'])) {
2283
+			$force_refresh = true;
2284
+	} else {
2285
+			$force_refresh = false;
2286
+	}
2204 2287
 
2205 2288
 	// This can also force a fresh, although unlikely.
2206
-	if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q'])))
2207
-		$force_refresh = true;
2289
+	if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q']))) {
2290
+			$force_refresh = true;
2291
+	}
2208 2292
 
2209 2293
 	$verification_errors = array();
2210 2294
 	// Start with any testing.
2211 2295
 	if ($do_test)
2212 2296
 	{
2213 2297
 		// This cannot happen!
2214
-		if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count']))
2215
-			fatal_lang_error('no_access', false);
2298
+		if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count'])) {
2299
+					fatal_lang_error('no_access', false);
2300
+		}
2216 2301
 		// ... nor this!
2217
-		if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q'])))
2218
-			fatal_lang_error('no_access', false);
2302
+		if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q']))) {
2303
+					fatal_lang_error('no_access', false);
2304
+		}
2219 2305
 		// Hmm, it's requested but not actually declared. This shouldn't happen.
2220
-		if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']))
2221
-			fatal_lang_error('no_access', false);
2306
+		if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) {
2307
+					fatal_lang_error('no_access', false);
2308
+		}
2222 2309
 		// While we're here, did the user do something bad?
2223
-		if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']]))
2224
-			$verification_errors[] = 'wrong_verification_answer';
2310
+		if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']])) {
2311
+					$verification_errors[] = 'wrong_verification_answer';
2312
+		}
2225 2313
 
2226 2314
 		if ($thisVerification['can_recaptcha'])
2227 2315
 		{
@@ -2232,22 +2320,25 @@  discard block
 block discarded – undo
2232 2320
 			{
2233 2321
 				$resp = $reCaptcha->verify($_POST['g-recaptcha-response'], $user_info['ip']);
2234 2322
 
2235
-				if (!$resp->isSuccess())
2236
-					$verification_errors[] = 'wrong_verification_code';
2323
+				if (!$resp->isSuccess()) {
2324
+									$verification_errors[] = 'wrong_verification_code';
2325
+				}
2326
+			} else {
2327
+							$verification_errors[] = 'wrong_verification_code';
2237 2328
 			}
2238
-			else
2239
-				$verification_errors[] = 'wrong_verification_code';
2240 2329
 		}
2241
-		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']))
2242
-			$verification_errors[] = 'wrong_verification_code';
2330
+		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'])) {
2331
+					$verification_errors[] = 'wrong_verification_code';
2332
+		}
2243 2333
 		if ($thisVerification['number_questions'])
2244 2334
 		{
2245 2335
 			$incorrectQuestions = array();
2246 2336
 			foreach ($_SESSION[$verificationOptions['id'] . '_vv']['q'] as $q)
2247 2337
 			{
2248 2338
 				// We don't have this question any more, thus no answers.
2249
-				if (!isset($modSettings['question_id_cache']['questions'][$q]))
2250
-					continue;
2339
+				if (!isset($modSettings['question_id_cache']['questions'][$q])) {
2340
+									continue;
2341
+				}
2251 2342
 				// This is quite complex. We have our question but it might have multiple answers.
2252 2343
 				// First, did they actually answer this question?
2253 2344
 				if (!isset($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) || trim($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) == '')
@@ -2259,24 +2350,28 @@  discard block
 block discarded – undo
2259 2350
 				else
2260 2351
 				{
2261 2352
 					$given_answer = trim($smcFunc['htmlspecialchars'](strtolower($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q])));
2262
-					if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers']))
2263
-						$incorrectQuestions[] = $q;
2353
+					if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers'])) {
2354
+											$incorrectQuestions[] = $q;
2355
+					}
2264 2356
 				}
2265 2357
 			}
2266 2358
 
2267
-			if (!empty($incorrectQuestions))
2268
-				$verification_errors[] = 'wrong_verification_answer';
2359
+			if (!empty($incorrectQuestions)) {
2360
+							$verification_errors[] = 'wrong_verification_answer';
2361
+			}
2269 2362
 		}
2270 2363
 	}
2271 2364
 
2272 2365
 	// Any errors means we refresh potentially.
2273 2366
 	if (!empty($verification_errors))
2274 2367
 	{
2275
-		if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors']))
2276
-			$_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0;
2368
+		if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors'])) {
2369
+					$_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0;
2370
+		}
2277 2371
 		// Too many errors?
2278
-		elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors'])
2279
-			$force_refresh = true;
2372
+		elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors']) {
2373
+					$force_refresh = true;
2374
+		}
2280 2375
 
2281 2376
 		// Keep a track of these.
2282 2377
 		$_SESSION[$verificationOptions['id'] . '_vv']['errors']++;
@@ -2309,8 +2404,9 @@  discard block
 block discarded – undo
2309 2404
 			// Are we overriding the range?
2310 2405
 			$character_range = !empty($verificationOptions['override_range']) ? $verificationOptions['override_range'] : $context['standard_captcha_range'];
2311 2406
 
2312
-			for ($i = 0; $i < 6; $i++)
2313
-				$_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)];
2407
+			for ($i = 0; $i < 6; $i++) {
2408
+							$_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)];
2409
+			}
2314 2410
 		}
2315 2411
 
2316 2412
 		// Getting some new questions?
@@ -2318,8 +2414,9 @@  discard block
 block discarded – undo
2318 2414
 		{
2319 2415
 			// Attempt to try the current page's language, followed by the user's preference, followed by the site default.
2320 2416
 			$possible_langs = array();
2321
-			if (isset($_SESSION['language']))
2322
-				$possible_langs[] = strtr($_SESSION['language'], array('-utf8' => ''));
2417
+			if (isset($_SESSION['language'])) {
2418
+							$possible_langs[] = strtr($_SESSION['language'], array('-utf8' => ''));
2419
+			}
2323 2420
 			if (!empty($user_info['language']));
2324 2421
 			$possible_langs[] = $user_info['language'];
2325 2422
 			$possible_langs[] = $language;
@@ -2338,8 +2435,7 @@  discard block
 block discarded – undo
2338 2435
 				}
2339 2436
 			}
2340 2437
 		}
2341
-	}
2342
-	else
2438
+	} else
2343 2439
 	{
2344 2440
 		// Same questions as before.
2345 2441
 		$questionIDs = !empty($_SESSION[$verificationOptions['id'] . '_vv']['q']) ? $_SESSION[$verificationOptions['id'] . '_vv']['q'] : array();
@@ -2349,8 +2445,9 @@  discard block
 block discarded – undo
2349 2445
 	// If we do have an empty field, it would be nice to hide it from legitimate users who shouldn't be populating it anyway.
2350 2446
 	if (!empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']))
2351 2447
 	{
2352
-		if (!isset($context['html_headers']))
2353
-			$context['html_headers'] = '';
2448
+		if (!isset($context['html_headers'])) {
2449
+					$context['html_headers'] = '';
2450
+		}
2354 2451
 		$context['html_headers'] .= '<style>.vv_special { display:none; }</style>';
2355 2452
 	}
2356 2453
 
@@ -2376,11 +2473,13 @@  discard block
 block discarded – undo
2376 2473
 	$_SESSION[$verificationOptions['id'] . '_vv']['count'] = empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) ? 1 : $_SESSION[$verificationOptions['id'] . '_vv']['count'] + 1;
2377 2474
 
2378 2475
 	// Return errors if we have them.
2379
-	if (!empty($verification_errors))
2380
-		return $verification_errors;
2476
+	if (!empty($verification_errors)) {
2477
+			return $verification_errors;
2478
+	}
2381 2479
 	// If we had a test that one, make a note.
2382
-	elseif ($do_test)
2383
-		$_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true;
2480
+	elseif ($do_test) {
2481
+			$_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true;
2482
+	}
2384 2483
 
2385 2484
 	// Say that everything went well chaps.
2386 2485
 	return true;
@@ -2405,8 +2504,9 @@  discard block
 block discarded – undo
2405 2504
 	call_integration_hook('integrate_autosuggest', array(&$searchTypes));
2406 2505
 
2407 2506
 	// If we're just checking the callback function is registered return true or false.
2408
-	if ($checkRegistered != null)
2409
-		return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered);
2507
+	if ($checkRegistered != null) {
2508
+			return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered);
2509
+	}
2410 2510
 
2411 2511
 	checkSession('get');
2412 2512
 	loadTemplate('Xml');
@@ -2557,24 +2657,27 @@  discard block
 block discarded – undo
2557 2657
 		foreach ($possible_versions as $ver)
2558 2658
 		{
2559 2659
 			$ver = trim($ver);
2560
-			if (strpos($ver, 'SMF') === 0)
2561
-				$versions[] = $ver;
2660
+			if (strpos($ver, 'SMF') === 0) {
2661
+							$versions[] = $ver;
2662
+			}
2562 2663
 		}
2563 2664
 	}
2564 2665
 	$smcFunc['db_free_result']($request);
2565 2666
 
2566 2667
 	// Just in case we don't have ANYthing.
2567
-	if (empty($versions))
2568
-		$versions = array('SMF 2.0');
2668
+	if (empty($versions)) {
2669
+			$versions = array('SMF 2.0');
2670
+	}
2569 2671
 
2570
-	foreach ($versions as $id => $version)
2571
-		if (strpos($version, strtoupper($_REQUEST['search'])) !== false)
2672
+	foreach ($versions as $id => $version) {
2673
+			if (strpos($version, strtoupper($_REQUEST['search'])) !== false)
2572 2674
 			$xml_data['items']['children'][] = array(
2573 2675
 				'attributes' => array(
2574 2676
 					'id' => $id,
2575 2677
 				),
2576 2678
 				'value' => $version,
2577 2679
 			);
2680
+	}
2578 2681
 
2579 2682
 	return $xml_data;
2580 2683
 }
Please login to merge, or discard this patch.