Completed
Pull Request — release-2.1 (#4873)
by Fran
08:24
created
Themes/default/ManagePaid.template.php 1 patch
Braces   +63 added lines, -45 removed lines patch added patch discarded remove patch
@@ -21,9 +21,10 @@  discard block
 block discarded – undo
21 21
 	<div id="admincenter">
22 22
 		<form action="', $scripturl, '?action=admin;area=paidsubscribe;sa=modify;sid=', $context['sub_id'], '" method="post">';
23 23
 
24
-	if (!empty($context['disable_groups']))
25
-		echo '
24
+	if (!empty($context['disable_groups'])) {
25
+			echo '
26 26
 			<div class="noticebox">', $txt['paid_mod_edit_note'], '</div>';
27
+	}
27 28
 
28 29
 		echo '
29 30
 			<div class="cat_bar">
@@ -67,9 +68,10 @@  discard block
 block discarded – undo
67 68
 							<option value="0"', $context['sub']['prim_group'] == 0 ? ' selected' : '', '>', $txt['paid_mod_no_group'], '</option>';
68 69
 
69 70
 	// Put each group into the box.
70
-	foreach ($context['groups'] as $id => $name)
71
-		echo '
71
+	foreach ($context['groups'] as $id => $name) {
72
+			echo '
72 73
 							<option value="', $id, '"', $context['sub']['prim_group'] == $id ? ' selected' : '', '>', $name, '</option>';
74
+	}
73 75
 
74 76
 	echo '
75 77
 						</select>
@@ -81,12 +83,13 @@  discard block
 block discarded – undo
81 83
 					<dd>';
82 84
 
83 85
 	// Put a checkbox in for each group
84
-	foreach ($context['groups'] as $id => $name)
85
-		echo '
86
+	foreach ($context['groups'] as $id => $name) {
87
+			echo '
86 88
 						<label for="addgroup_', $id, '">
87 89
 							<input type="checkbox" id="addgroup_', $id, '" name="addgroup[', $id, ']"', in_array($id, $context['sub']['add_groups']) ? ' checked' : '', !empty($context['disable_groups']) ? ' disabled' : '', '>
88 90
 							<span class="smalltext">', $name, '</span>
89 91
 						</label><br>';
92
+	}
90 93
 
91 94
 	echo '
92 95
 					</dd>
@@ -236,8 +239,8 @@  discard block
 block discarded – undo
236 239
 				<dl class="settings">';
237 240
 
238 241
 	// Do we need a username?
239
-	if ($context['action_type'] == 'add')
240
-		echo '
242
+	if ($context['action_type'] == 'add') {
243
+			echo '
241 244
 					<dt>
242 245
 						<strong>', $txt['paid_username'], ':</strong><br>
243 246
 						<span class="smalltext">', $txt['one_username'], '</span>
@@ -245,6 +248,7 @@  discard block
 block discarded – undo
245 248
 					<dd>
246 249
 						<input type="text" name="name" id="name_control" value="', $context['sub']['username'], '" size="30">
247 250
 					</dd>';
251
+	}
248 252
 
249 253
 	echo '
250 254
 					<dt>
@@ -262,9 +266,10 @@  discard block
 block discarded – undo
262 266
 					<select name="year" id="year" onchange="generateDays();">';
263 267
 
264 268
 	// Show a list of all the years we allow...
265
-	for ($year = 2005; $year <= 2030; $year++)
266
-		echo '
269
+	for ($year = 2005; $year <= 2030; $year++) {
270
+			echo '
267 271
 						<option value="', $year, '"', $year == $context['sub']['start']['year'] ? ' selected' : '', '>', $year, '</option>';
272
+	}
268 273
 
269 274
 	echo '
270 275
 					</select>&nbsp;
@@ -272,9 +277,10 @@  discard block
 block discarded – undo
272 277
 					<select name="month" id="month" onchange="generateDays();">';
273 278
 
274 279
 	// There are 12 months per year - ensure that they all get listed.
275
-	for ($month = 1; $month <= 12; $month++)
276
-		echo '
280
+	for ($month = 1; $month <= 12; $month++) {
281
+			echo '
277 282
 						<option value="', $month, '"', $month == $context['sub']['start']['month'] ? ' selected' : '', '>', $txt['months'][$month], '</option>';
283
+	}
278 284
 
279 285
 	echo '
280 286
 					</select>&nbsp;
@@ -282,9 +288,10 @@  discard block
 block discarded – undo
282 288
 					<select name="day" id="day">';
283 289
 
284 290
 	// This prints out all the days in the current month - this changes dynamically as we switch months.
285
-	for ($day = 1; $day <= $context['sub']['start']['last_day']; $day++)
286
-		echo '
291
+	for ($day = 1; $day <= $context['sub']['start']['last_day']; $day++) {
292
+			echo '
287 293
 						<option value="', $day, '"', $day == $context['sub']['start']['day'] ? ' selected' : '', '>', $day, '</option>';
294
+	}
288 295
 
289 296
 	echo '
290 297
 					</select>
@@ -296,9 +303,10 @@  discard block
 block discarded – undo
296 303
 					<select name="yearend" id="yearend" onchange="generateDays(\'end\');">';
297 304
 
298 305
 	// Show a list of all the years we allow...
299
-	for ($year = 2005; $year <= 2030; $year++)
300
-		echo '
306
+	for ($year = 2005; $year <= 2030; $year++) {
307
+			echo '
301 308
 						<option value="', $year, '"', $year == $context['sub']['end']['year'] ? ' selected' : '', '>', $year, '</option>';
309
+	}
302 310
 
303 311
 	echo '
304 312
 					</select>&nbsp;
@@ -306,9 +314,10 @@  discard block
 block discarded – undo
306 314
 					<select name="monthend" id="monthend" onchange="generateDays(\'end\');">';
307 315
 
308 316
 	// There are 12 months per year - ensure that they all get listed.
309
-	for ($month = 1; $month <= 12; $month++)
310
-		echo '
317
+	for ($month = 1; $month <= 12; $month++) {
318
+			echo '
311 319
 						<option value="', $month, '"', $month == $context['sub']['end']['month'] ? ' selected' : '', '>', $txt['months'][$month], '</option>';
320
+	}
312 321
 
313 322
 	echo '
314 323
 					</select>&nbsp;
@@ -316,9 +325,10 @@  discard block
 block discarded – undo
316 325
 					<select name="dayend" id="dayend">';
317 326
 
318 327
 	// This prints out all the days in the current month - this changes dynamically as we switch months.
319
-	for ($day = 1; $day <= $context['sub']['end']['last_day']; $day++)
320
-		echo '
328
+	for ($day = 1; $day <= $context['sub']['end']['last_day']; $day++) {
329
+			echo '
321 330
 						<option value="', $day, '"', $day == $context['sub']['end']['day'] ? ' selected' : '', '>', $day, '</option>';
331
+	}
322 332
 
323 333
 	echo '
324 334
 					</select>
@@ -357,8 +367,8 @@  discard block
 block discarded – undo
357 367
 		<div class="windowbg">
358 368
 			<ul>';
359 369
 
360
-		foreach ($context['pending_payments'] as $id => $payment)
361
-			echo '
370
+		foreach ($context['pending_payments'] as $id => $payment) {
371
+					echo '
362 372
 				<li>
363 373
 					', $payment['desc'], '
364 374
 					<span class="floatleft">
@@ -368,6 +378,7 @@  discard block
 block discarded – undo
368 378
 						<a href="', $scripturl, '?action=admin;area=paidsubscribe;sa=modifyuser;lid=', $context['log_id'], ';pending=', $id, ';remove">', $txt['pending_payments_remove'], '</a>
369 379
 					</span>
370 380
 				</li>';
381
+		}
371 382
 
372 383
 		echo '
373 384
 			</ul>
@@ -392,12 +403,12 @@  discard block
 block discarded – undo
392 403
 				<h3 class="catbg">', $txt['subscriptions'], '</h3>
393 404
 			</div>';
394 405
 
395
-	if (empty($context['subscriptions']))
396
-		echo '
406
+	if (empty($context['subscriptions'])) {
407
+			echo '
397 408
 			<div class="information">
398 409
 				', $txt['paid_subs_none'], '
399 410
 			</div>';
400
-	else
411
+	} else
401 412
 	{
402 413
 		echo '
403 414
 			<div class="information">
@@ -408,8 +419,9 @@  discard block
 block discarded – undo
408 419
 		foreach ($context['subscriptions'] as $id => $subscription)
409 420
 		{
410 421
 			// Ignore the inactive ones...
411
-			if (empty($subscription['active']))
412
-				continue;
422
+			if (empty($subscription['active'])) {
423
+							continue;
424
+			}
413 425
 
414 426
 			echo '
415 427
 			<div class="cat_bar">
@@ -419,9 +431,10 @@  discard block
 block discarded – undo
419 431
 				<p><strong>', $subscription['name'], '</strong></p>
420 432
 				<p class="smalltext">', $subscription['desc'], '</p>';
421 433
 
422
-			if (!$subscription['flexible'])
423
-				echo '
434
+			if (!$subscription['flexible']) {
435
+							echo '
424 436
 				<div><strong>', $txt['paid_duration'], ':</strong> ', $subscription['length'], '</div>';
437
+			}
425 438
 
426 439
 			if ($context['user']['is_owner'])
427 440
 			{
@@ -434,24 +447,25 @@  discard block
 block discarded – undo
434 447
 				<select name="cur[', $subscription['id'], ']">';
435 448
 
436 449
 					// Print out the costs for this one.
437
-					foreach ($subscription['costs'] as $duration => $value)
438
-						echo '
450
+					foreach ($subscription['costs'] as $duration => $value) {
451
+											echo '
439 452
 					<option value="', $duration, '">', sprintf($modSettings['paid_currency_symbol'], $value), '/', $txt[$duration], '</option>';
453
+					}
440 454
 
441 455
 					echo '
442 456
 				</select>';
443
-				}
444
-				else
445
-					echo '
457
+				} else {
458
+									echo '
446 459
 				', sprintf($modSettings['paid_currency_symbol'], $subscription['costs']['fixed']);
460
+				}
447 461
 
448 462
 				echo '
449 463
 				<hr>
450 464
 				<input type="submit" name="sub_id[', $subscription['id'], ']" value="', $txt['paid_order'], '" class="button">';
451
-			}
452
-			else
453
-				echo '
465
+			} else {
466
+							echo '
454 467
 				<a href="', $scripturl, '?action=admin;area=paidsubscribe;sa=modifyuser;sid=', $subscription['id'], ';uid=', $context['member']['id'], (empty($context['current'][$subscription['id']]) ? '' : ';lid=' . $context['current'][$subscription['id']]['id']), '">', empty($context['current'][$subscription['id']]) ? $txt['paid_admin_add'] : $txt['paid_edit_subscription'], '</a>';
468
+			}
455 469
 
456 470
 			echo '
457 471
 			</div><!-- .windowbg -->';
@@ -478,18 +492,19 @@  discard block
 block discarded – undo
478 492
 			</thead>
479 493
 			<tbody>';
480 494
 
481
-	if (empty($context['current']))
482
-		echo '
495
+	if (empty($context['current'])) {
496
+			echo '
483 497
 				<tr class="windowbg">
484 498
 					<td colspan="4">
485 499
 						', $txt['paid_none_yet'], '
486 500
 					</td>
487 501
 				</tr>';
502
+	}
488 503
 
489 504
 	foreach ($context['current'] as $sub)
490 505
 	{
491
-		if (!$sub['hide'])
492
-			echo '
506
+		if (!$sub['hide']) {
507
+					echo '
493 508
 				<tr class="windowbg">
494 509
 					<td>
495 510
 						', (allowedTo('admin_forum') ? '<a href="' . $scripturl . '?action=admin;area=paidsubscribe;sa=modifyuser;lid=' . $sub['id'] . '">' . $sub['name'] . '</a>' : $sub['name']), '
@@ -500,6 +515,7 @@  discard block
 block discarded – undo
500 515
 					<td>', $sub['start'], '</td>
501 516
 					<td>', $sub['end'], '</td>
502 517
 				</tr>';
518
+		}
503 519
 	}
504 520
 
505 521
 	echo '
@@ -551,15 +567,17 @@  discard block
 block discarded – undo
551 567
 			', $gateway['desc'], '<br>
552 568
 			<form action="', $gateway['form'], '" method="post">';
553 569
 
554
-		if (!empty($gateway['javascript']))
555
-			echo '
570
+		if (!empty($gateway['javascript'])) {
571
+					echo '
556 572
 				<script>
557 573
 					', $gateway['javascript'], '
558 574
 				</script>';
575
+		}
559 576
 
560
-		foreach ($gateway['hidden'] as $name => $value)
561
-			echo '
577
+		foreach ($gateway['hidden'] as $name => $value) {
578
+					echo '
562 579
 				<input type="hidden" id="', $gateway['id'], '_', $name, '" name="', $name, '" value="', $value, '">';
580
+		}
563 581
 
564 582
 		echo '
565 583
 				<br>
Please login to merge, or discard this patch.
Themes/default/Search.template.php 1 patch
Braces   +78 added lines, -57 removed lines patch added patch discarded remove patch
@@ -20,17 +20,19 @@  discard block
 block discarded – undo
20 20
 	echo '
21 21
 	<form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '" name="searchform" id="searchform">';
22 22
 
23
-	if (!empty($context['search_errors']))
24
-		echo '
23
+	if (!empty($context['search_errors'])) {
24
+			echo '
25 25
 		<div class="errorbox">
26 26
 			', implode('<br>', $context['search_errors']['messages']), '
27 27
 		</div>';
28
+	}
28 29
 
29
-	if (!empty($context['search_ignored']))
30
-		echo '
30
+	if (!empty($context['search_ignored'])) {
31
+			echo '
31 32
 		<div class="noticebox">
32 33
 			', $txt['search_warning_ignored_word' . (count($context['search_ignored']) == 1 ? '' : 's')], ': ', implode(', ', $context['search_ignored']), '
33 34
 		</div>';
35
+	}
34 36
 
35 37
 	echo '
36 38
 		<div class="cat_bar">
@@ -48,9 +50,10 @@  discard block
 block discarded – undo
48 50
 				<dd>
49 51
 					<input type="search" name="search" id="searchfor" ', !empty($context['search_params']['search']) ? ' value="' . $context['search_params']['search'] . '"' : '', ' maxlength="', $context['search_string_limit'], '" size="40">';
50 52
 
51
-	if (empty($modSettings['search_simple_fulltext']))
52
-		echo '
53
+	if (empty($modSettings['search_simple_fulltext'])) {
54
+			echo '
53 55
 					<br><em class="smalltext">', $txt['search_example'], '</em>';
56
+	}
54 57
 
55 58
 	echo '
56 59
 				</dd>
@@ -114,21 +117,23 @@  discard block
 block discarded – undo
114 117
 			<input type="hidden" name="advanced" value="1">';
115 118
 
116 119
 	// Require an image to be typed to save spamming?
117
-	if ($context['require_verification'])
118
-		echo '
120
+	if ($context['require_verification']) {
121
+			echo '
119 122
 			<p>
120 123
 				<strong>', $txt['verification'], ':</strong>
121 124
 				', template_control_verification($context['visual_verification_id'], 'all'), '
122 125
 			</p>';
126
+	}
123 127
 
124 128
 	// If $context['search_params']['topic'] is set, that means we're searching just one topic.
125
-	if (!empty($context['search_params']['topic']))
126
-		echo '
129
+	if (!empty($context['search_params']['topic'])) {
130
+			echo '
127 131
 			<p>
128 132
 				', $txt['search_specific_topic'], ' &quot;', $context['search_topic']['link'], '&quot;.
129 133
 			</p>
130 134
 			<input type="hidden" name="topic" value="', $context['search_topic']['id'], '">
131 135
 			<input type="submit" name="b_search" value="', $txt['search'], '" class="button">';
136
+	}
132 137
 
133 138
 	echo '
134 139
 		</div>';
@@ -158,14 +163,15 @@  discard block
 block discarded – undo
158 163
 
159 164
 			foreach ($category['boards'] as $board)
160 165
 			{
161
-				if ($i == $limit)
162
-					echo '
166
+				if ($i == $limit) {
167
+									echo '
163 168
 							</ul>
164 169
 						</li>
165 170
 					</ul>
166 171
 					<ul class="ignoreboards floatright">
167 172
 						<li class="category">
168 173
 							<ul>';
174
+				}
169 175
 
170 176
 				echo '
171 177
 								<li class="board">
@@ -253,17 +259,19 @@  discard block
 block discarded – undo
253 259
 		<div class="roundframe">';
254 260
 
255 261
 		// Did they make any typos or mistakes, perhaps?
256
-		if (isset($context['did_you_mean']))
257
-			echo '
262
+		if (isset($context['did_you_mean'])) {
263
+					echo '
258 264
 			<p>
259 265
 				', $txt['search_did_you_mean'], ' <a href="', $scripturl, '?action=search2;params=', $context['did_you_mean_params'], '">', $context['did_you_mean'], '</a>.
260 266
 			</p>';
267
+		}
261 268
 
262
-		if (!empty($context['search_ignored']))
263
-			echo '
269
+		if (!empty($context['search_ignored'])) {
270
+					echo '
264 271
 			<p>
265 272
 				', $txt['search_warning_ignored_word' . (count($context['search_ignored']) == 1 ? '' : 's')], ': ', implode(', ', $context['search_ignored']), '
266 273
 			</p>';
274
+		}
267 275
 
268 276
 		echo '
269 277
 			<form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '">
@@ -286,10 +294,11 @@  discard block
 block discarded – undo
286 294
 					<input type="hidden" name="sort" value="', !empty($context['search_params']['sort']) ? $context['search_params']['sort'] : 'relevance', '">
287 295
 				</div>';
288 296
 
289
-		if (!empty($context['search_params']['brd']))
290
-			foreach ($context['search_params']['brd'] as $board_id)
297
+		if (!empty($context['search_params']['brd'])) {
298
+					foreach ($context['search_params']['brd'] as $board_id)
291 299
 				echo '
292 300
 				<input type="hidden" name="brd[', $board_id, ']" value="', $board_id, '">';
301
+		}
293 302
 
294 303
 		echo '
295 304
 			</form>
@@ -300,18 +309,20 @@  discard block
 block discarded – undo
300 309
 	if ($context['compact'])
301 310
 	{
302 311
 		// Quick moderation set to checkboxes? Oh, how fun :/
303
-		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1)
304
-			echo '
312
+		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) {
313
+					echo '
305 314
 	<form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="topicForm">';
315
+		}
306 316
 
307 317
 		echo '
308 318
 		<div class="cat_bar">
309 319
 			<h3 class="catbg">
310 320
 				<span class="floatright">';
311 321
 
312
-		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1)
313
-			echo '
322
+		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) {
323
+					echo '
314 324
 					<input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');">';
325
+		}
315 326
 		echo '
316 327
 				</span>
317 328
 				<span class="generic_icons filter"></span> ', $txt['mlist_search_results'], ': ', $context['search_params']['search'], '
@@ -319,15 +330,15 @@  discard block
 block discarded – undo
319 330
 		</div>';
320 331
 
321 332
 		// Was anything even found?
322
-		if (!empty($context['topics']))
323
-			echo '
333
+		if (!empty($context['topics'])) {
334
+					echo '
324 335
 		<div class="pagesection">
325 336
 			<span>', $context['page_index'], '</span>
326 337
 		</div>';
327
-
328
-		else
329
-			echo '
338
+		} else {
339
+					echo '
330 340
 		<div class="roundframe noup">', $txt['find_no_results'], '</div>';
341
+		}
331 342
 
332 343
 		// While we have results to show ...
333 344
 		while ($topic = $context['get_topics']())
@@ -350,31 +361,35 @@  discard block
 block discarded – undo
350 361
 					echo '
351 362
 				<span class="floatright">';
352 363
 
353
-					if ($options['display_quick_mod'] == 1)
354
-						echo '
364
+					if ($options['display_quick_mod'] == 1) {
365
+											echo '
355 366
 					<input type="checkbox" name="topics[]" value="', $topic['id'], '">';
356
-
357
-					else
367
+					} else
358 368
 					{
359
-						if ($topic['quick_mod']['remove'])
360
-							echo '
369
+						if ($topic['quick_mod']['remove']) {
370
+													echo '
361 371
 					<a href="', $scripturl, '?action=quickmod;board=' . $topic['board']['id'] . '.0;actions%5B', $topic['id'], '%5D=remove;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons delete" title="', $txt['remove_topic'], '"></span></a>';
372
+						}
362 373
 
363
-						if ($topic['quick_mod']['lock'])
364
-							echo '
374
+						if ($topic['quick_mod']['lock']) {
375
+													echo '
365 376
 					<a href="', $scripturl, '?action=quickmod;board=' . $topic['board']['id'] . '.0;actions%5B', $topic['id'], '%5D=lock;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons lock" title="', $topic['is_locked'] ? $txt['set_unlock'] : $txt['set_lock'], '"></span></a>';
377
+						}
366 378
 
367
-						if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove'])
368
-							echo '
379
+						if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) {
380
+													echo '
369 381
 					<br>';
382
+						}
370 383
 
371
-						if ($topic['quick_mod']['sticky'])
372
-							echo '
384
+						if ($topic['quick_mod']['sticky']) {
385
+													echo '
373 386
 					<a href="', $scripturl, '?action=quickmod;board=' . $topic['board']['id'] . '.0;actions%5B', $topic['id'], '%5D=sticky;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons sticky" title="', $topic['is_sticky'] ? $txt['set_nonsticky'] : $txt['set_sticky'], '"></span></a>';
387
+						}
374 388
 
375
-						if ($topic['quick_mod']['move'])
376
-							echo '
389
+						if ($topic['quick_mod']['move']) {
390
+													echo '
377 391
 					<a href="', $scripturl, '?action=movetopic;topic=', $topic['id'], '.0"><span class="generic_icons move" title="', $txt['move_topic'], '"></span></a>';
392
+						}
378 393
 					}
379 394
 
380 395
 					echo '
@@ -384,20 +399,22 @@  discard block
 block discarded – undo
384 399
 			echo '
385 400
 			</div><!-- .block -->';
386 401
 
387
-				if ($message['body_highlighted'] != '')
388
-					echo '
402
+				if ($message['body_highlighted'] != '') {
403
+									echo '
389 404
 				<div class="list_posts double_height">', $message['body_highlighted'], '</div>';
405
+				}
390 406
 			}
391 407
 
392 408
 			echo '
393 409
 		</div><!-- $topic[css_class] -->';
394 410
 		}
395 411
 
396
-		if (!empty($context['topics']))
397
-			echo '
412
+		if (!empty($context['topics'])) {
413
+					echo '
398 414
 		<div class="pagesection">
399 415
 			<span>', $context['page_index'], '</span>
400 416
 		</div>';
417
+		}
401 418
 
402 419
 		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']))
403 420
 		{
@@ -406,17 +423,19 @@  discard block
 block discarded – undo
406 423
 			<select class="qaction" name="qaction"', $context['can_move'] ? ' onchange="this.form.move_to.disabled = (this.options[this.selectedIndex].value != \'move\');"' : '', '>
407 424
 				<option value="">--------</option>';
408 425
 
409
-			foreach ($context['qmod_actions'] as $qmod_action)
410
-				if ($context['can_' . $qmod_action])
426
+			foreach ($context['qmod_actions'] as $qmod_action) {
427
+							if ($context['can_' . $qmod_action])
411 428
 					echo '
412 429
 				<option value="' . $qmod_action . '">' . $txt['quick_mod_' . $qmod_action] . '</option>';
430
+			}
413 431
 
414 432
 			echo '
415 433
 			</select>';
416 434
 
417
-			if ($context['can_move'])
418
-				echo '
435
+			if ($context['can_move']) {
436
+							echo '
419 437
 			<span id="quick_mod_jump_to"></span>';
438
+			}
420 439
 
421 440
 			echo '
422 441
 			<input type="hidden" name="redirect_url" value="', $scripturl . '?action=search2;params=' . $context['params'], '">
@@ -425,12 +444,12 @@  discard block
 block discarded – undo
425 444
 		}
426 445
 
427 446
 
428
-		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']))
429
-			echo '
447
+		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics'])) {
448
+					echo '
430 449
 		<input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '">
431 450
 	</form>';
432
-	}
433
-	else
451
+		}
452
+	} else
434 453
 	{
435 454
 		echo '
436 455
 	<div class="cat_bar">
@@ -442,9 +461,10 @@  discard block
 block discarded – undo
442 461
 		<span>', $context['page_index'], '</span>
443 462
 	</div>';
444 463
 
445
-		if (empty($context['topics']))
446
-			echo '
464
+		if (empty($context['topics'])) {
465
+					echo '
447 466
 	<div class="information">(', $txt['search_no_results'], ')</div>';
467
+		}
448 468
 
449 469
 		while ($topic = $context['get_topics']())
450 470
 		{
@@ -479,8 +499,8 @@  discard block
 block discarded – undo
479 499
 	<div class="smalltext righttext" id="search_jump_to"></div>
480 500
 	<script>';
481 501
 
482
-	if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move'])
483
-		echo '
502
+	if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) {
503
+			echo '
484 504
 		if (typeof(window.XMLHttpRequest) != "undefined")
485 505
 			aJumpTo[aJumpTo.length] = new JumpTo({
486 506
 				sContainerId: "quick_mod_jump_to",
@@ -495,6 +515,7 @@  discard block
 block discarded – undo
495 515
 				bDisabled: true,
496 516
 				sCustomName: "move_to"
497 517
 			});';
518
+	}
498 519
 
499 520
 	echo '
500 521
 		if (typeof(window.XMLHttpRequest) != "undefined")
Please login to merge, or discard this patch.
Themes/default/Login.template.php 1 patch
Braces   +44 added lines, -30 removed lines patch added patch discarded remove patch
@@ -28,15 +28,17 @@  discard block
 block discarded – undo
28 28
 				<form class="login" action="', $context['login_url'], '" name="frmLogin" id="frmLogin" method="post" accept-charset="', $context['character_set'], '">';
29 29
 
30 30
 	// Did they make a mistake last time?
31
-	if (!empty($context['login_errors']))
32
-		echo '
31
+	if (!empty($context['login_errors'])) {
32
+			echo '
33 33
 					<div class="errorbox">', implode('<br>', $context['login_errors']), '</div>
34 34
 					<br>';
35
+	}
35 36
 
36 37
 	// Or perhaps there's some special description for this time?
37
-	if (isset($context['description']))
38
-		echo '
38
+	if (isset($context['description'])) {
39
+			echo '
39 40
 					<div class="information">', $context['description'], '</div>';
41
+	}
40 42
 
41 43
 	// Now just get the basic information - username, password, etc.
42 44
 	echo '
@@ -55,19 +57,21 @@  discard block
 block discarded – undo
55 57
 						<dd>
56 58
 							<select name="cookielength" id="cookielength">';
57 59
 
58
-	foreach ($context['login_cookie_times'] as $cookie_time => $cookie_txt)
59
-		echo '
60
+	foreach ($context['login_cookie_times'] as $cookie_time => $cookie_txt) {
61
+			echo '
60 62
 								<option value="', $cookie_time, '"', $modSettings['cookieTime'] == $cookie_time ? ' selected' : '', '>', $txt[$cookie_txt], '</option>';
63
+	}
61 64
 
62 65
 	echo '
63 66
 							</select>
64 67
 						</dd>';
65 68
 
66 69
 	// If they have deleted their account, give them a chance to change their mind.
67
-	if (isset($context['login_show_undelete']))
68
-		echo '
70
+	if (isset($context['login_show_undelete'])) {
71
+			echo '
69 72
 						<dt class="alert">', $txt['undelete_account'], ':</dt>
70 73
 						<dd><input type="checkbox" name="undelete"></dd>';
74
+	}
71 75
 
72 76
 	echo '
73 77
 					</dl>
@@ -85,8 +89,8 @@  discard block
 block discarded – undo
85 89
 							document.getElementById("', !empty($context['from_ajax']) ? 'ajax_' : '', isset($context['default_username']) && $context['default_username'] != '' ? 'loginpass' : 'loginuser', '").focus();
86 90
 						}, 150);';
87 91
 
88
-	if (!empty($context['from_ajax']))
89
-		echo '
92
+	if (!empty($context['from_ajax'])) {
93
+			echo '
90 94
 						form = $("#frmLogin");
91 95
 						form.submit(function(e) {
92 96
 							e.preventDefault();
@@ -119,16 +123,18 @@  discard block
 block discarded – undo
119 123
 
120 124
 							return false;
121 125
 						});';
126
+	}
122 127
 
123 128
 	echo '
124 129
 					</script>
125 130
 				</form>';
126 131
 
127 132
 	// It is a long story as to why we have this when we're clearly not going to use it.
128
-	if (!empty($context['from_ajax']))
129
-		echo '
133
+	if (!empty($context['from_ajax'])) {
134
+			echo '
130 135
 				<br>
131 136
 				<a href="javascript:self.close();"></a>';
137
+	}
132 138
 
133 139
 	echo '
134 140
 			</div><!-- .roundframe -->
@@ -151,11 +157,12 @@  discard block
 block discarded – undo
151 157
 			</div>
152 158
 			<div class="roundframe">';
153 159
 
154
-	if (!empty($context['tfa_error']) || !empty($context['tfa_backup_error']))
155
-		echo '
160
+	if (!empty($context['tfa_error']) || !empty($context['tfa_backup_error'])) {
161
+			echo '
156 162
 				<div class="error">
157 163
 					', $txt['tfa_' . (!empty($context['tfa_error']) ? 'code_' : 'backup_') . 'invalid'], '
158 164
 				</div>';
165
+	}
159 166
 
160 167
 	echo '
161 168
 				<form action="', $context['tfa_url'], '" method="post" id="frmTfa">
@@ -183,8 +190,8 @@  discard block
 block discarded – undo
183 190
 				<script>
184 191
 					form = $("#frmTfa");';
185 192
 
186
-	if (!empty($context['from_ajax']))
187
-		echo '
193
+	if (!empty($context['from_ajax'])) {
194
+			echo '
188 195
 					form.submit(function(e) {
189 196
 						// If we are submitting backup code, let normal workflow follow since it redirects a couple times into a different page
190 197
 						if (form.find("input[name=tfa_backup]:first").val().length > 0)
@@ -203,6 +210,7 @@  discard block
 block discarded – undo
203 210
 
204 211
 						return false;
205 212
 					});';
213
+	}
206 214
 
207 215
 	echo '
208 216
 					form.find("input[name=backup]").click(function(e) {
@@ -234,10 +242,11 @@  discard block
 block discarded – undo
234 242
 			<p class="information centertext">
235 243
 				', empty($context['kick_message']) ? $txt['only_members_can_access'] : $context['kick_message'], '<br>';
236 244
 
237
-	if ($context['can_register'])
238
-		echo sprintf($txt['login_below_or_register'], $scripturl . '?action=signup', $context['forum_name_html_safe']);
239
-	else
240
-		echo $txt['login_below'];
245
+	if ($context['can_register']) {
246
+			echo sprintf($txt['login_below_or_register'], $scripturl . '?action=signup', $context['forum_name_html_safe']);
247
+	} else {
248
+			echo $txt['login_below'];
249
+	}
241 250
 
242 251
 	// And now the login information.
243 252
 	echo '
@@ -256,9 +265,10 @@  discard block
 block discarded – undo
256 265
 					<dd>
257 266
 							<select name="cookielength" id="cookielength">';
258 267
 
259
-	foreach ($context['login_cookie_times'] as $cookie_time => $cookie_txt)
260
-		echo '
268
+	foreach ($context['login_cookie_times'] as $cookie_time => $cookie_txt) {
269
+			echo '
261 270
 								<option value="', $cookie_time, '"', $modSettings['cookieTime'] == $cookie_time ? ' selected' : '', '>', $txt[$cookie_txt], '</option>';
271
+	}
262 272
 
263 273
 	echo '
264 274
 							</select>
@@ -315,9 +325,10 @@  discard block
 block discarded – undo
315 325
 					<dd>
316 326
 							<select name="cookielength" id="cookielength">';
317 327
 
318
-	foreach ($context['login_cookie_times'] as $cookie_time => $cookie_txt)
319
-		echo '
328
+	foreach ($context['login_cookie_times'] as $cookie_time => $cookie_txt) {
329
+			echo '
320 330
 								<option value="', $cookie_time, '"', $modSettings['cookieTime'] == $cookie_time ? ' selected' : '', '>', $txt[$cookie_txt], '</option>';
331
+	}
321 332
 
322 333
 	echo '
323 334
 							</select>
@@ -351,9 +362,10 @@  discard block
 block discarded – undo
351 362
 			</div>
352 363
 			<div class="roundframe centertext">';
353 364
 
354
-	if (!empty($context['incorrect_password']))
355
-		echo '
365
+	if (!empty($context['incorrect_password'])) {
366
+			echo '
356 367
 				<div class="error">', $txt['admin_incorrect_password'], '</div>';
368
+	}
357 369
 
358 370
 	echo '
359 371
 				<strong>', $txt['password'], ':</strong>
@@ -394,10 +406,11 @@  discard block
 block discarded – undo
394 406
 				<dl>';
395 407
 
396 408
 	// You didn't even have an ID?
397
-	if (empty($context['member_id']))
398
-		echo '
409
+	if (empty($context['member_id'])) {
410
+			echo '
399 411
 					<dt>', $txt['invalid_activation_username'], ':</dt>
400 412
 					<dd><input type="text" name="user" size="30"></dd>';
413
+	}
401 414
 
402 415
 	echo '
403 416
 					<dt>', $txt['invalid_activation_retry'], ':</dt>
@@ -434,13 +447,14 @@  discard block
 block discarded – undo
434 447
 					<dd><input type="password" name="passwd" size="30"></dd>
435 448
 				</dl>';
436 449
 
437
-	if ($context['can_activate'])
438
-		echo '
450
+	if ($context['can_activate']) {
451
+			echo '
439 452
 				<p>', $txt['invalid_activation_known'], '</p>
440 453
 				<dl>
441 454
 					<dt>', $txt['invalid_activation_retry'], ':</dt>
442 455
 					<dd><input type="text" name="code" size="30"></dd>
443 456
 				</dl>';
457
+	}
444 458
 
445 459
 	echo '
446 460
 				<p><input type="submit" value="', $txt['invalid_activation_resend'], '" class="button"></p>
Please login to merge, or discard this patch.
Sources/LogInOut.php 1 patch
Braces   +154 added lines, -121 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 4
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * Ask them for their login information. (shows a page for the user to type
@@ -29,8 +30,9 @@  discard block
 block discarded – undo
29 30
 	global $txt, $context, $scripturl, $user_info;
30 31
 
31 32
 	// You are already logged in, go take a tour of the boards
32
-	if (!empty($user_info['id']))
33
-		redirectexit();
33
+	if (!empty($user_info['id'])) {
34
+			redirectexit();
35
+	}
34 36
 
35 37
 	// We need to load the Login template/language file.
36 38
 	loadLanguage('Login');
@@ -57,10 +59,11 @@  discard block
 block discarded – undo
57 59
 	);
58 60
 
59 61
 	// Set the login URL - will be used when the login process is done (but careful not to send us to an attachment).
60
-	if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0)
61
-		$_SESSION['login_url'] = $_SESSION['old_url'];
62
-	elseif (isset($_SESSION['login_url']) && strpos($_SESSION['login_url'], 'dlattach') !== false)
63
-		unset($_SESSION['login_url']);
62
+	if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) {
63
+			$_SESSION['login_url'] = $_SESSION['old_url'];
64
+	} elseif (isset($_SESSION['login_url']) && strpos($_SESSION['login_url'], 'dlattach') !== false) {
65
+			unset($_SESSION['login_url']);
66
+	}
64 67
 
65 68
 	// Create a one time token.
66 69
 	createToken('login');
@@ -92,8 +95,9 @@  discard block
 block discarded – undo
92 95
 	global $cookiename, $modSettings, $context, $sourcedir, $maintenance;
93 96
 
94 97
 	// Check to ensure we're forcing SSL for authentication
95
-	if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn())
96
-		fatal_lang_error('login_ssl_required');
98
+	if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) {
99
+			fatal_lang_error('login_ssl_required');
100
+	}
97 101
 
98 102
 	// Load cookie authentication stuff.
99 103
 	require_once($sourcedir . '/Subs-Auth.php');
@@ -107,23 +111,26 @@  discard block
 block discarded – undo
107 111
 	if (isset($_GET['sa']) && $_GET['sa'] == 'salt' && !$user_info['is_guest'])
108 112
 	{
109 113
 		// First check for 2.1 json-format cookie in $_COOKIE
110
-		if (isset($_COOKIE[$cookiename]) && preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+~', $_COOKIE[$cookiename]) === 1)
111
-			list (,, $timeout) = $smcFunc['json_decode']($_COOKIE[$cookiename], true);
114
+		if (isset($_COOKIE[$cookiename]) && preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+~', $_COOKIE[$cookiename]) === 1) {
115
+					list (,, $timeout) = $smcFunc['json_decode']($_COOKIE[$cookiename], true);
116
+		}
112 117
 
113 118
 		// Try checking for 2.1 json-format cookie in $_SESSION
114
-		elseif (isset($_SESSION['login_' . $cookiename]) && preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+~', $_SESSION['login_' . $cookiename]) === 1)
115
-			list (,, $timeout) = $smcFunc['json_decode']($_SESSION['login_' . $cookiename]);
119
+		elseif (isset($_SESSION['login_' . $cookiename]) && preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+~', $_SESSION['login_' . $cookiename]) === 1) {
120
+					list (,, $timeout) = $smcFunc['json_decode']($_SESSION['login_' . $cookiename]);
121
+		}
116 122
 
117 123
 		// Next, try checking for 2.0 serialized string cookie in $_COOKIE
118
-		elseif (isset($_COOKIE[$cookiename]) && preg_match('~^a:[34]:\{i:0;i:\d+;i:1;s:(0|128):"([a-fA-F0-9]{128})?";i:2;[id]:\d+;~', $_COOKIE[$cookiename]) === 1)
119
-			list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]);
124
+		elseif (isset($_COOKIE[$cookiename]) && preg_match('~^a:[34]:\{i:0;i:\d+;i:1;s:(0|128):"([a-fA-F0-9]{128})?";i:2;[id]:\d+;~', $_COOKIE[$cookiename]) === 1) {
125
+					list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]);
126
+		}
120 127
 
121 128
 		// Last, see if you need to fall back on checking for 2.0 serialized string cookie in $_SESSION
122
-		elseif (isset($_SESSION['login_' . $cookiename]) && preg_match('~^a:[34]:\{i:0;i:\d+;i:1;s:(0|128):"([a-fA-F0-9]{128})?";i:2;[id]:\d+;~', $_SESSION['login_' . $cookiename]) === 1)
123
-			list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]);
124
-
125
-		else
126
-			trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR);
129
+		elseif (isset($_SESSION['login_' . $cookiename]) && preg_match('~^a:[34]:\{i:0;i:\d+;i:1;s:(0|128):"([a-fA-F0-9]{128})?";i:2;[id]:\d+;~', $_SESSION['login_' . $cookiename]) === 1) {
130
+					list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]);
131
+		} else {
132
+					trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR);
133
+		}
127 134
 
128 135
 		$user_settings['password_salt'] = substr(md5(mt_rand()), 0, 4);
129 136
 		updateMemberData($user_info['id'], array('password_salt' => $user_settings['password_salt']));
@@ -143,24 +150,23 @@  discard block
 block discarded – undo
143 150
 	elseif (isset($_GET['sa']) && $_GET['sa'] == 'check')
144 151
 	{
145 152
 		// Strike!  You're outta there!
146
-		if ($_GET['member'] != $user_info['id'])
147
-			fatal_lang_error('login_cookie_error', false);
153
+		if ($_GET['member'] != $user_info['id']) {
154
+					fatal_lang_error('login_cookie_error', false);
155
+		}
148 156
 
149 157
 		$user_info['can_mod'] = allowedTo('access_mod_center') || (!$user_info['is_guest'] && ($user_info['mod_cache']['gq'] != '0=1' || $user_info['mod_cache']['bq'] != '0=1' || ($modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap']))));
150 158
 
151 159
 		// Some whitelisting for login_url...
152
-		if (empty($_SESSION['login_url']))
153
-			redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa');
154
-		elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false))
160
+		if (empty($_SESSION['login_url'])) {
161
+					redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa');
162
+		} elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false))
155 163
 		{
156 164
 			unset ($_SESSION['login_url']);
157 165
 			redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa');
158
-		}
159
-		elseif (!empty($user_settings['tfa_secret']))
166
+		} elseif (!empty($user_settings['tfa_secret']))
160 167
 		{
161 168
 			redirectexit('action=logintfa');
162
-		}
163
-		else
169
+		} else
164 170
 		{
165 171
 			// Best not to clutter the session data too much...
166 172
 			$temp = $_SESSION['login_url'];
@@ -171,8 +177,9 @@  discard block
 block discarded – undo
171 177
 	}
172 178
 
173 179
 	// Beyond this point you are assumed to be a guest trying to login.
174
-	if (!$user_info['is_guest'])
175
-		redirectexit();
180
+	if (!$user_info['is_guest']) {
181
+			redirectexit();
182
+	}
176 183
 
177 184
 	// Are you guessing with a script?
178 185
 	checkSession();
@@ -180,18 +187,21 @@  discard block
 block discarded – undo
180 187
 	spamProtection('login');
181 188
 
182 189
 	// Set the login_url if it's not already set (but careful not to send us to an attachment).
183
-	if ((empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) || (isset($_GET['quicklogin']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'login') === false))
184
-		$_SESSION['login_url'] = $_SESSION['old_url'];
190
+	if ((empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) || (isset($_GET['quicklogin']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'login') === false)) {
191
+			$_SESSION['login_url'] = $_SESSION['old_url'];
192
+	}
185 193
 
186 194
 	// Been guessing a lot, haven't we?
187
-	if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3)
188
-		fatal_lang_error('login_threshold_fail', 'login');
195
+	if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3) {
196
+			fatal_lang_error('login_threshold_fail', 'login');
197
+	}
189 198
 
190 199
 	// Set up the cookie length.  (if it's invalid, just fall through and use the default.)
191
-	if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1))
192
-		$modSettings['cookieTime'] = 3153600;
193
-	elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 3153600))
194
-		$modSettings['cookieTime'] = (int) $_POST['cookielength'];
200
+	if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1)) {
201
+			$modSettings['cookieTime'] = 3153600;
202
+	} elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 3153600)) {
203
+			$modSettings['cookieTime'] = (int) $_POST['cookielength'];
204
+	}
195 205
 
196 206
 	// Login Cookie times. Format: time => txt
197 207
 	$context['login_cookie_times'] = array(
@@ -320,8 +330,9 @@  discard block
 block discarded – undo
320 330
 			$other_passwords[] = crypt(md5($_POST['passwrd']), md5($_POST['passwrd']));
321 331
 
322 332
 			// Snitz style - SHA-256.  Technically, this is a downgrade, but most PHP configurations don't support sha256 anyway.
323
-			if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256'))
324
-				$other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd']));
333
+			if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256')) {
334
+							$other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd']));
335
+			}
325 336
 
326 337
 			// phpBB3 users new hashing.  We now support it as well ;).
327 338
 			$other_passwords[] = phpBB3_password_check($_POST['passwrd'], $user_settings['passwd']);
@@ -341,27 +352,29 @@  discard block
 block discarded – undo
341 352
 			// Some common md5 ones.
342 353
 			$other_passwords[] = md5($user_settings['password_salt'] . $_POST['passwrd']);
343 354
 			$other_passwords[] = md5($_POST['passwrd'] . $user_settings['password_salt']);
344
-		}
345
-		elseif (strlen($user_settings['passwd']) == 40)
355
+		} elseif (strlen($user_settings['passwd']) == 40)
346 356
 		{
347 357
 			// Maybe they are using a hash from before the password fix.
348 358
 			// This is also valid for SMF 1.1 to 2.0 style of hashing, changed to bcrypt in SMF 2.1
349 359
 			$other_passwords[] = sha1(strtolower($user_settings['member_name']) . un_htmlspecialchars($_POST['passwrd']));
350 360
 
351 361
 			// BurningBoard3 style of hashing.
352
-			if (!empty($modSettings['enable_password_conversion']))
353
-				$other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd'])));
362
+			if (!empty($modSettings['enable_password_conversion'])) {
363
+							$other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd'])));
364
+			}
354 365
 
355 366
 			// Perhaps we converted to UTF-8 and have a valid password being hashed differently.
356 367
 			if ($context['character_set'] == 'UTF-8' && !empty($modSettings['previousCharacterSet']) && $modSettings['previousCharacterSet'] != 'utf8')
357 368
 			{
358 369
 				// Try iconv first, for no particular reason.
359
-				if (function_exists('iconv'))
360
-					$other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd'])));
370
+				if (function_exists('iconv')) {
371
+									$other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd'])));
372
+				}
361 373
 
362 374
 				// Say it aint so, iconv failed!
363
-				if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding'))
364
-					$other_passwords[] = sha1(strtolower(mb_convert_encoding($user_settings['member_name'], 'UTF-8', $modSettings['previousCharacterSet'])) . un_htmlspecialchars(mb_convert_encoding($_POST['passwrd'], 'UTF-8', $modSettings['previousCharacterSet'])));
375
+				if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding')) {
376
+									$other_passwords[] = sha1(strtolower(mb_convert_encoding($user_settings['member_name'], 'UTF-8', $modSettings['previousCharacterSet'])) . un_htmlspecialchars(mb_convert_encoding($_POST['passwrd'], 'UTF-8', $modSettings['previousCharacterSet'])));
377
+				}
365 378
 			}
366 379
 		}
367 380
 
@@ -391,8 +404,9 @@  discard block
 block discarded – undo
391 404
 			$_SESSION['failed_login'] = isset($_SESSION['failed_login']) ? ($_SESSION['failed_login'] + 1) : 1;
392 405
 
393 406
 			// Hmm... don't remember it, do you?  Here, try the password reminder ;).
394
-			if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold'])
395
-				redirectexit('action=reminder');
407
+			if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold']) {
408
+							redirectexit('action=reminder');
409
+			}
396 410
 			// We'll give you another chance...
397 411
 			else
398 412
 			{
@@ -403,8 +417,7 @@  discard block
 block discarded – undo
403 417
 				return;
404 418
 			}
405 419
 		}
406
-	}
407
-	elseif (!empty($user_settings['passwd_flood']))
420
+	} elseif (!empty($user_settings['passwd_flood']))
408 421
 	{
409 422
 		// Let's be sure they weren't a little hacker.
410 423
 		validatePasswordFlood($user_settings['id_member'], $user_settings['member_name'], $user_settings['passwd_flood'], true);
@@ -421,8 +434,9 @@  discard block
 block discarded – undo
421 434
 	}
422 435
 
423 436
 	// Check their activation status.
424
-	if (!checkActivation())
425
-		return;
437
+	if (!checkActivation()) {
438
+			return;
439
+	}
426 440
 
427 441
 	DoLogin();
428 442
 }
@@ -434,8 +448,9 @@  discard block
 block discarded – undo
434 448
 {
435 449
 	global $sourcedir, $txt, $context, $user_info, $modSettings, $scripturl;
436 450
 
437
-	if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode']))
438
-		fatal_lang_error('no_access', false);
451
+	if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode'])) {
452
+			fatal_lang_error('no_access', false);
453
+	}
439 454
 
440 455
 	loadLanguage('Profile');
441 456
 	require_once($sourcedir . '/Class-TOTP.php');
@@ -443,8 +458,9 @@  discard block
 block discarded – undo
443 458
 	$member = $context['tfa_member'];
444 459
 
445 460
 	// Prevent replay attacks by limiting at least 2 minutes before they can log in again via 2FA
446
-	if (time() - $member['last_login'] < 120)
447
-		fatal_lang_error('tfa_wait', false);
461
+	if (time() - $member['last_login'] < 120) {
462
+			fatal_lang_error('tfa_wait', false);
463
+	}
448 464
 
449 465
 	$totp = new \TOTP\Auth($member['tfa_secret']);
450 466
 	$totp->setRange(1);
@@ -458,8 +474,9 @@  discard block
 block discarded – undo
458 474
 	if (!empty($_POST['tfa_code']) && empty($_POST['tfa_backup']))
459 475
 	{
460 476
 		// Check to ensure we're forcing SSL for authentication
461
-		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn())
462
-			fatal_lang_error('login_ssl_required');
477
+		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) {
478
+					fatal_lang_error('login_ssl_required');
479
+		}
463 480
 
464 481
 		$code = $_POST['tfa_code'];
465 482
 
@@ -469,20 +486,19 @@  discard block
 block discarded – undo
469 486
 
470 487
 			setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt']));
471 488
 			redirectexit();
472
-		}
473
-		else
489
+		} else
474 490
 		{
475 491
 			validatePasswordFlood($member['id_member'], $member['member_name'], $member['passwd_flood'], false, true);
476 492
 
477 493
 			$context['tfa_error'] = true;
478 494
 			$context['tfa_value'] = $_POST['tfa_code'];
479 495
 		}
480
-	}
481
-	elseif (!empty($_POST['tfa_backup']))
496
+	} elseif (!empty($_POST['tfa_backup']))
482 497
 	{
483 498
 		// Check to ensure we're forcing SSL for authentication
484
-		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn())
485
-			fatal_lang_error('login_ssl_required');
499
+		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) {
500
+					fatal_lang_error('login_ssl_required');
501
+		}
486 502
 
487 503
 		$backup = $_POST['tfa_backup'];
488 504
 
@@ -496,8 +512,7 @@  discard block
 block discarded – undo
496 512
 			));
497 513
 			setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt']));
498 514
 			redirectexit('action=profile;area=tfasetup;backup');
499
-		}
500
-		else
515
+		} else
501 516
 		{
502 517
 			validatePasswordFlood($member['id_member'], $member['member_name'], $member['passwd_flood'], false, true);
503 518
 
@@ -520,8 +535,9 @@  discard block
 block discarded – undo
520 535
 {
521 536
 	global $context, $txt, $scripturl, $user_settings, $modSettings;
522 537
 
523
-	if (!isset($context['login_errors']))
524
-		$context['login_errors'] = array();
538
+	if (!isset($context['login_errors'])) {
539
+			$context['login_errors'] = array();
540
+	}
525 541
 
526 542
 	// What is the true activation status of this account?
527 543
 	$activation_status = $user_settings['is_activated'] > 10 ? $user_settings['is_activated'] - 10 : $user_settings['is_activated'];
@@ -533,8 +549,9 @@  discard block
 block discarded – undo
533 549
 		return false;
534 550
 	}
535 551
 	// Awaiting approval still?
536
-	elseif ($activation_status == 3)
537
-		fatal_lang_error('still_awaiting_approval', 'user');
552
+	elseif ($activation_status == 3) {
553
+			fatal_lang_error('still_awaiting_approval', 'user');
554
+	}
538 555
 	// Awaiting deletion, changed their mind?
539 556
 	elseif ($activation_status == 4)
540 557
 	{
@@ -542,8 +559,7 @@  discard block
 block discarded – undo
542 559
 		{
543 560
 			updateMemberData($user_settings['id_member'], array('is_activated' => 1));
544 561
 			updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 0 ? $modSettings['unapprovedMembers'] - 1 : 0)));
545
-		}
546
-		else
562
+		} else
547 563
 		{
548 564
 			$context['disable_login_hashing'] = true;
549 565
 			$context['login_errors'][] = $txt['awaiting_delete_account'];
@@ -583,8 +599,9 @@  discard block
 block discarded – undo
583 599
 	setLoginCookie(60 * $modSettings['cookieTime'], $user_settings['id_member'], hash_salt($user_settings['passwd'], $user_settings['password_salt']));
584 600
 
585 601
 	// Reset the login threshold.
586
-	if (isset($_SESSION['failed_login']))
587
-		unset($_SESSION['failed_login']);
602
+	if (isset($_SESSION['failed_login'])) {
603
+			unset($_SESSION['failed_login']);
604
+	}
588 605
 
589 606
 	$user_info['is_guest'] = false;
590 607
 	$user_settings['additional_groups'] = explode(',', $user_settings['additional_groups']);
@@ -606,16 +623,18 @@  discard block
 block discarded – undo
606 623
 			'id_member' => $user_info['id'],
607 624
 		)
608 625
 	);
609
-	if ($smcFunc['db_num_rows']($request) == 1)
610
-		$_SESSION['first_login'] = true;
611
-	else
612
-		unset($_SESSION['first_login']);
626
+	if ($smcFunc['db_num_rows']($request) == 1) {
627
+			$_SESSION['first_login'] = true;
628
+	} else {
629
+			unset($_SESSION['first_login']);
630
+	}
613 631
 	$smcFunc['db_free_result']($request);
614 632
 
615 633
 	// You've logged in, haven't you?
616 634
 	$update = array('member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP']);
617
-	if (empty($user_settings['tfa_secret']))
618
-		$update['last_login'] = time();
635
+	if (empty($user_settings['tfa_secret'])) {
636
+			$update['last_login'] = time();
637
+	}
619 638
 	updateMemberData($user_info['id'], $update);
620 639
 
621 640
 	// Get rid of the online entry for that old guest....
@@ -629,8 +648,8 @@  discard block
 block discarded – undo
629 648
 	$_SESSION['log_time'] = 0;
630 649
 
631 650
 	// Log this entry, only if we have it enabled.
632
-	if (!empty($modSettings['loginHistoryDays']))
633
-		$smcFunc['db_insert']('insert',
651
+	if (!empty($modSettings['loginHistoryDays'])) {
652
+			$smcFunc['db_insert']('insert',
634 653
 			'{db_prefix}member_logins',
635 654
 			array(
636 655
 				'id_member' => 'int', 'time' => 'int', 'ip' => 'inet', 'ip2' => 'inet',
@@ -642,13 +661,15 @@  discard block
 block discarded – undo
642 661
 				'id_member', 'time'
643 662
 			)
644 663
 		);
664
+	}
645 665
 
646 666
 	// Just log you back out if it's in maintenance mode and you AREN'T an admin.
647
-	if (empty($maintenance) || allowedTo('admin_forum'))
648
-		redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']);
649
-	else
650
-		redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']);
651
-}
667
+	if (empty($maintenance) || allowedTo('admin_forum')) {
668
+			redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']);
669
+	} else {
670
+			redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']);
671
+	}
672
+	}
652 673
 
653 674
 /**
654 675
  * Logs the current user out of their account.
@@ -664,13 +685,15 @@  discard block
 block discarded – undo
664 685
 	global $sourcedir, $user_info, $user_settings, $context, $smcFunc, $cookiename, $modSettings;
665 686
 
666 687
 	// Make sure they aren't being auto-logged out.
667
-	if (!$internal)
668
-		checkSession('get');
688
+	if (!$internal) {
689
+			checkSession('get');
690
+	}
669 691
 
670 692
 	require_once($sourcedir . '/Subs-Auth.php');
671 693
 
672
-	if (isset($_SESSION['pack_ftp']))
673
-		$_SESSION['pack_ftp'] = null;
694
+	if (isset($_SESSION['pack_ftp'])) {
695
+			$_SESSION['pack_ftp'] = null;
696
+	}
674 697
 
675 698
 	// It won't be first login anymore.
676 699
 	unset($_SESSION['first_login']);
@@ -698,8 +721,9 @@  discard block
 block discarded – undo
698 721
 
699 722
 	// And some other housekeeping while we're at it.
700 723
 	$salt = substr(md5(mt_rand()), 0, 4);
701
-	if (!empty($user_info['id']))
702
-		updateMemberData($user_info['id'], array('password_salt' => $salt));
724
+	if (!empty($user_info['id'])) {
725
+			updateMemberData($user_info['id'], array('password_salt' => $salt));
726
+	}
703 727
 
704 728
 	if (!empty($modSettings['tfa_mode']) && !empty($user_info['id']) && !empty($_COOKIE[$cookiename . '_tfa']))
705 729
 	{
@@ -712,14 +736,13 @@  discard block
 block discarded – undo
712 736
 	// Off to the merry board index we go!
713 737
 	if ($redirect)
714 738
 	{
715
-		if (empty($_SESSION['logout_url']))
716
-			redirectexit('', $context['server']['needs_login_fix']);
717
-		elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false))
739
+		if (empty($_SESSION['logout_url'])) {
740
+					redirectexit('', $context['server']['needs_login_fix']);
741
+		} elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false))
718 742
 		{
719 743
 			unset ($_SESSION['logout_url']);
720 744
 			redirectexit();
721
-		}
722
-		else
745
+		} else
723 746
 		{
724 747
 			$temp = $_SESSION['logout_url'];
725 748
 			unset($_SESSION['logout_url']);
@@ -752,8 +775,9 @@  discard block
 block discarded – undo
752 775
 function phpBB3_password_check($passwd, $passwd_hash)
753 776
 {
754 777
 	// Too long or too short?
755
-	if (strlen($passwd_hash) != 34)
756
-		return;
778
+	if (strlen($passwd_hash) != 34) {
779
+			return;
780
+	}
757 781
 
758 782
 	// Range of characters allowed.
759 783
 	$range = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
@@ -764,8 +788,9 @@  discard block
 block discarded – undo
764 788
 	$salt = substr($passwd_hash, 4, 8);
765 789
 
766 790
 	$hash = md5($salt . $passwd, true);
767
-	for (; $count != 0; --$count)
768
-		$hash = md5($hash . $passwd, true);
791
+	for (; $count != 0; --$count) {
792
+			$hash = md5($hash . $passwd, true);
793
+	}
769 794
 
770 795
 	$output = substr($passwd_hash, 0, 12);
771 796
 	$i = 0;
@@ -774,21 +799,25 @@  discard block
 block discarded – undo
774 799
 		$value = ord($hash[$i++]);
775 800
 		$output .= $range[$value & 0x3f];
776 801
 
777
-		if ($i < 16)
778
-			$value |= ord($hash[$i]) << 8;
802
+		if ($i < 16) {
803
+					$value |= ord($hash[$i]) << 8;
804
+		}
779 805
 
780 806
 		$output .= $range[($value >> 6) & 0x3f];
781 807
 
782
-		if ($i++ >= 16)
783
-			break;
808
+		if ($i++ >= 16) {
809
+					break;
810
+		}
784 811
 
785
-		if ($i < 16)
786
-			$value |= ord($hash[$i]) << 16;
812
+		if ($i < 16) {
813
+					$value |= ord($hash[$i]) << 16;
814
+		}
787 815
 
788 816
 		$output .= $range[($value >> 12) & 0x3f];
789 817
 
790
-		if ($i++ >= 16)
791
-			break;
818
+		if ($i++ >= 16) {
819
+					break;
820
+		}
792 821
 
793 822
 		$output .= $range[($value >> 18) & 0x3f];
794 823
 	}
@@ -820,8 +849,9 @@  discard block
 block discarded – undo
820 849
 		require_once($sourcedir . '/Subs-Auth.php');
821 850
 		setLoginCookie(-3600, 0);
822 851
 
823
-		if (isset($_SESSION['login_' . $cookiename]))
824
-			unset($_SESSION['login_' . $cookiename]);
852
+		if (isset($_SESSION['login_' . $cookiename])) {
853
+					unset($_SESSION['login_' . $cookiename]);
854
+		}
825 855
 	}
826 856
 
827 857
 	// We need a member!
@@ -835,8 +865,9 @@  discard block
 block discarded – undo
835 865
 	}
836 866
 
837 867
 	// Right, have we got a flood value?
838
-	if ($password_flood_value !== false)
839
-		@list ($time_stamp, $number_tries) = explode('|', $password_flood_value);
868
+	if ($password_flood_value !== false) {
869
+			@list ($time_stamp, $number_tries) = explode('|', $password_flood_value);
870
+	}
840 871
 
841 872
 	// Timestamp or number of tries invalid?
842 873
 	if (empty($number_tries) || empty($time_stamp))
@@ -852,15 +883,17 @@  discard block
 block discarded – undo
852 883
 		$number_tries = $time_stamp < time() - 20 ? 2 : $number_tries;
853 884
 
854 885
 		// They are trying too fast, make them wait longer
855
-		if ($time_stamp < time() - 10)
856
-			$time_stamp = time();
886
+		if ($time_stamp < time() - 10) {
887
+					$time_stamp = time();
888
+		}
857 889
 	}
858 890
 
859 891
 	$number_tries++;
860 892
 
861 893
 	// Broken the law?
862
-	if ($number_tries > 5)
863
-		fatal_lang_error('login_threshold_brute_fail', 'login', [$member_name]);
894
+	if ($number_tries > 5) {
895
+			fatal_lang_error('login_threshold_brute_fail', 'login', [$member_name]);
896
+	}
864 897
 
865 898
 	// Otherwise set the members data. If they correct on their first attempt then we actually clear it, otherwise we set it!
866 899
 	updateMemberData($id_member, array('passwd_flood' => $was_correct && $number_tries == 1 ? '' : $time_stamp . '|' . $number_tries));
Please login to merge, or discard this patch.
other/install.php 1 patch
Braces   +470 added lines, -350 removed lines patch added patch discarded remove patch
@@ -20,8 +20,9 @@  discard block
 block discarded – undo
20 20
 // ><html dir="ltr"><head><title>Error!</title></head><body>Sorry, this installer requires PHP!<div style="display: none;">
21 21
 
22 22
 // Let's pull in useful classes
23
-if (!defined('SMF'))
23
+if (!defined('SMF')) {
24 24
 	define('SMF', 1);
25
+}
25 26
 
26 27
 require_once('Sources/Class-Package.php');
27 28
 
@@ -63,10 +64,11 @@  discard block
 block discarded – undo
63 64
 
64 65
 			list ($charcode) = pg_fetch_row($request);
65 66
 
66
-			if ($charcode == 'UTF8')
67
-				return true;
68
-			else
69
-				return false;
67
+			if ($charcode == 'UTF8') {
68
+							return true;
69
+			} else {
70
+							return false;
71
+			}
70 72
 		},
71 73
 		'utf8_version' => '8.0',
72 74
 		'utf8_version_check' => '$request = pg_query(\'SELECT version()\'); list ($version) = pg_fetch_row($request); list($pgl, $version) = explode(" ", $version); return $version;',
@@ -76,12 +78,14 @@  discard block
 block discarded – undo
76 78
 			$value = preg_replace('~[^A-Za-z0-9_\$]~', '', $value);
77 79
 
78 80
 			// Is it reserved?
79
-			if ($value == 'pg_')
80
-				return $txt['error_db_prefix_reserved'];
81
+			if ($value == 'pg_') {
82
+							return $txt['error_db_prefix_reserved'];
83
+			}
81 84
 
82 85
 			// Is the prefix numeric?
83
-			if (preg_match('~^\d~', $value))
84
-				return $txt['error_db_prefix_numeric'];
86
+			if (preg_match('~^\d~', $value)) {
87
+							return $txt['error_db_prefix_numeric'];
88
+			}
85 89
 
86 90
 			return true;
87 91
 		},
@@ -128,10 +132,11 @@  discard block
 block discarded – undo
128 132
 		$incontext['skip'] = false;
129 133
 
130 134
 		// Call the step and if it returns false that means pause!
131
-		if (function_exists($step[2]) && $step[2]() === false)
132
-			break;
133
-		elseif (function_exists($step[2]))
134
-			$incontext['current_step']++;
135
+		if (function_exists($step[2]) && $step[2]() === false) {
136
+					break;
137
+		} elseif (function_exists($step[2])) {
138
+					$incontext['current_step']++;
139
+		}
135 140
 
136 141
 		// No warnings pass on.
137 142
 		$incontext['warning'] = '';
@@ -147,8 +152,9 @@  discard block
 block discarded – undo
147 152
 	global $databases;
148 153
 
149 154
 	// Just so people using older versions of PHP aren't left in the cold.
150
-	if (!isset($_SERVER['PHP_SELF']))
151
-		$_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php';
155
+	if (!isset($_SERVER['PHP_SELF'])) {
156
+			$_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php';
157
+	}
152 158
 
153 159
 	// Enable error reporting for fatal errors.
154 160
 	error_reporting(E_ERROR | E_PARSE);
@@ -164,21 +170,23 @@  discard block
 block discarded – undo
164 170
 	{
165 171
 		ob_start();
166 172
 
167
-		if (ini_get('session.save_handler') == 'user')
168
-			@ini_set('session.save_handler', 'files');
169
-		if (function_exists('session_start'))
170
-			@session_start();
171
-	}
172
-	else
173
+		if (ini_get('session.save_handler') == 'user') {
174
+					@ini_set('session.save_handler', 'files');
175
+		}
176
+		if (function_exists('session_start')) {
177
+					@session_start();
178
+		}
179
+	} else
173 180
 	{
174 181
 		ob_start('ob_gzhandler');
175 182
 
176
-		if (ini_get('session.save_handler') == 'user')
177
-			@ini_set('session.save_handler', 'files');
183
+		if (ini_get('session.save_handler') == 'user') {
184
+					@ini_set('session.save_handler', 'files');
185
+		}
178 186
 		session_start();
179 187
 
180
-		if (!headers_sent())
181
-			echo '<!DOCTYPE html>
188
+		if (!headers_sent()) {
189
+					echo '<!DOCTYPE html>
182 190
 <html>
183 191
 	<head>
184 192
 		<title>', htmlspecialchars($_GET['pass_string']), '</title>
@@ -187,14 +195,16 @@  discard block
 block discarded – undo
187 195
 		<strong>', htmlspecialchars($_GET['pass_string']), '</strong>
188 196
 	</body>
189 197
 </html>';
198
+		}
190 199
 		exit;
191 200
 	}
192 201
 
193 202
 	// Add slashes, as long as they aren't already being added.
194
-	if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0)
195
-		foreach ($_POST as $k => $v)
203
+	if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) {
204
+			foreach ($_POST as $k => $v)
196 205
 			if (strpos($k, 'password') === false && strpos($k, 'db_passwd') === false)
197 206
 				$_POST[$k] = addslashes($v);
207
+	}
198 208
 
199 209
 	// This is really quite simple; if ?delete is on the URL, delete the installer...
200 210
 	if (isset($_GET['delete']))
@@ -215,8 +225,7 @@  discard block
 block discarded – undo
215 225
 			$ftp->close();
216 226
 
217 227
 			unset($_SESSION['installer_temp_ftp']);
218
-		}
219
-		else
228
+		} else
220 229
 		{
221 230
 			@unlink(__FILE__);
222 231
 
@@ -230,10 +239,11 @@  discard block
 block discarded – undo
230 239
 		// Now just redirect to a blank.png...
231 240
 		$secure = false;
232 241
 
233
-		if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on')
234
-			$secure = true;
235
-		elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on')
236
-			$secure = true;
242
+		if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
243
+					$secure = true;
244
+		} elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') {
245
+					$secure = true;
246
+		}
237 247
 
238 248
 		header('location: http' . ($secure ? 's' : '') . '://' . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT']) . dirname($_SERVER['PHP_SELF']) . '/Themes/default/images/blank.png');
239 249
 		exit;
@@ -244,10 +254,11 @@  discard block
 block discarded – undo
244 254
 	{
245 255
 		// Get PHP's default timezone, if set
246 256
 		$ini_tz = ini_get('date.timezone');
247
-		if (!empty($ini_tz))
248
-			$timezone_id = $ini_tz;
249
-		else
250
-			$timezone_id = '';
257
+		if (!empty($ini_tz)) {
258
+					$timezone_id = $ini_tz;
259
+		} else {
260
+					$timezone_id = '';
261
+		}
251 262
 
252 263
 		// If date.timezone is unset, invalid, or just plain weird, make a best guess
253 264
 		if (!in_array($timezone_id, timezone_identifiers_list()))
@@ -277,8 +288,9 @@  discard block
 block discarded – undo
277 288
 		$dir = dir(dirname(__FILE__) . '/Themes/default/languages');
278 289
 		while ($entry = $dir->read())
279 290
 		{
280
-			if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php')
281
-				$incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12));
291
+			if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') {
292
+							$incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12));
293
+			}
282 294
 		}
283 295
 		$dir->close();
284 296
 	}
@@ -325,10 +337,11 @@  discard block
 block discarded – undo
325 337
 	}
326 338
 
327 339
 	// Override the language file?
328
-	if (isset($_GET['lang_file']))
329
-		$_SESSION['installer_temp_lang'] = $_GET['lang_file'];
330
-	elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file']))
331
-		$_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file'];
340
+	if (isset($_GET['lang_file'])) {
341
+			$_SESSION['installer_temp_lang'] = $_GET['lang_file'];
342
+	} elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) {
343
+			$_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file'];
344
+	}
332 345
 
333 346
 	// Make sure it exists, if it doesn't reset it.
334 347
 	if (!isset($_SESSION['installer_temp_lang']) || preg_match('~[^\\w_\\-.]~', $_SESSION['installer_temp_lang']) === 1 || !file_exists(dirname(__FILE__) . '/Themes/default/languages/' . $_SESSION['installer_temp_lang']))
@@ -337,8 +350,9 @@  discard block
 block discarded – undo
337 350
 		list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
338 351
 
339 352
 		// If we have english and some other language, use the other language.  We Americans hate english :P.
340
-		if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1)
341
-			list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
353
+		if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) {
354
+					list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
355
+		}
342 356
 	}
343 357
 
344 358
 	// And now include the actual language file itself.
@@ -355,15 +369,18 @@  discard block
 block discarded – undo
355 369
 	global $db_prefix, $db_connection, $sourcedir, $smcFunc, $modSettings;
356 370
 	global $db_server, $db_passwd, $db_type, $db_name, $db_user, $db_persist;
357 371
 
358
-	if (empty($sourcedir))
359
-		$sourcedir = dirname(__FILE__) . '/Sources';
372
+	if (empty($sourcedir)) {
373
+			$sourcedir = dirname(__FILE__) . '/Sources';
374
+	}
360 375
 
361 376
 	// Need this to check whether we need the database password.
362 377
 	require(dirname(__FILE__) . '/Settings.php');
363
-	if (!defined('SMF'))
364
-		define('SMF', 1);
365
-	if (empty($smcFunc))
366
-		$smcFunc = array();
378
+	if (!defined('SMF')) {
379
+			define('SMF', 1);
380
+	}
381
+	if (empty($smcFunc)) {
382
+			$smcFunc = array();
383
+	}
367 384
 
368 385
 	$modSettings['disableQueryCheck'] = true;
369 386
 
@@ -371,8 +388,9 @@  discard block
 block discarded – undo
371 388
 	if (!$db_connection)
372 389
 	{
373 390
 		require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
374
-		if (version_compare(PHP_VERSION, '5', '<'))
375
-			require_once($sourcedir . '/Subs-Compat.php');
391
+		if (version_compare(PHP_VERSION, '5', '<')) {
392
+					require_once($sourcedir . '/Subs-Compat.php');
393
+		}
376 394
 
377 395
 		$db_options = array('persist' => $db_persist);
378 396
 		$port = '';
@@ -383,19 +401,20 @@  discard block
 block discarded – undo
383 401
 			if ($db_type == 'mysql')
384 402
 			{
385 403
 				$port = ((int) $_POST['db_port'] == ini_get($db_type . 'default_port')) ? '' : (int) $_POST['db_port'];
386
-			}
387
-			elseif ($db_type == 'postgresql')
404
+			} elseif ($db_type == 'postgresql')
388 405
 			{
389 406
 				// PostgreSQL doesn't have a default port setting in php.ini, so just check against the default
390 407
 				$port = ((int) $_POST['db_port'] == 5432) ? '' : (int) $_POST['db_port'];
391 408
 			}
392 409
 		}
393 410
 
394
-		if (!empty($port))
395
-			$db_options['port'] = $port;
411
+		if (!empty($port)) {
412
+					$db_options['port'] = $port;
413
+		}
396 414
 
397
-		if (!$db_connection)
398
-			$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options);
415
+		if (!$db_connection) {
416
+					$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options);
417
+		}
399 418
 	}
400 419
 }
401 420
 
@@ -423,8 +442,9 @@  discard block
 block discarded – undo
423 442
 		// @todo REMOVE THIS!!
424 443
 		else
425 444
 		{
426
-			if (function_exists('doStep' . $_GET['step']))
427
-				call_user_func('doStep' . $_GET['step']);
445
+			if (function_exists('doStep' . $_GET['step'])) {
446
+							call_user_func('doStep' . $_GET['step']);
447
+			}
428 448
 		}
429 449
 		// Show the footer.
430 450
 		template_install_below();
@@ -442,8 +462,9 @@  discard block
 block discarded – undo
442 462
 	$incontext['sub_template'] = 'welcome_message';
443 463
 
444 464
 	// Done the submission?
445
-	if (isset($_POST['contbutt']))
446
-		return true;
465
+	if (isset($_POST['contbutt'])) {
466
+			return true;
467
+	}
447 468
 
448 469
 	// See if we think they have already installed it?
449 470
 	if (is_readable(dirname(__FILE__) . '/Settings.php'))
@@ -451,14 +472,17 @@  discard block
 block discarded – undo
451 472
 		$probably_installed = 0;
452 473
 		foreach (file(dirname(__FILE__) . '/Settings.php') as $line)
453 474
 		{
454
-			if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line))
455
-				$probably_installed++;
456
-			if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line))
457
-				$probably_installed++;
475
+			if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) {
476
+							$probably_installed++;
477
+			}
478
+			if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) {
479
+							$probably_installed++;
480
+			}
458 481
 		}
459 482
 
460
-		if ($probably_installed == 2)
461
-			$incontext['warning'] = $txt['error_already_installed'];
483
+		if ($probably_installed == 2) {
484
+					$incontext['warning'] = $txt['error_already_installed'];
485
+		}
462 486
 	}
463 487
 
464 488
 	// Is some database support even compiled in?
@@ -473,45 +497,54 @@  discard block
 block discarded – undo
473 497
 				$databases[$key]['supported'] = false;
474 498
 				$notFoundSQLFile = true;
475 499
 				$txt['error_db_script_missing'] = sprintf($txt['error_db_script_missing'], 'install_' . $GLOBALS['db_script_version'] . '_' . $type . '.sql');
500
+			} else {
501
+							$incontext['supported_databases'][] = $db;
476 502
 			}
477
-			else
478
-				$incontext['supported_databases'][] = $db;
479 503
 		}
480 504
 	}
481 505
 
482 506
 	// Check the PHP version.
483
-	if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>=')))
484
-		$error = 'error_php_too_low';
507
+	if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>='))) {
508
+			$error = 'error_php_too_low';
509
+	}
485 510
 	// Make sure we have a supported database
486
-	elseif (empty($incontext['supported_databases']))
487
-		$error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing';
511
+	elseif (empty($incontext['supported_databases'])) {
512
+			$error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing';
513
+	}
488 514
 	// How about session support?  Some crazy sysadmin remove it?
489
-	elseif (!function_exists('session_start'))
490
-		$error = 'error_session_missing';
515
+	elseif (!function_exists('session_start')) {
516
+			$error = 'error_session_missing';
517
+	}
491 518
 	// Make sure they uploaded all the files.
492
-	elseif (!file_exists(dirname(__FILE__) . '/index.php'))
493
-		$error = 'error_missing_files';
519
+	elseif (!file_exists(dirname(__FILE__) . '/index.php')) {
520
+			$error = 'error_missing_files';
521
+	}
494 522
 	// Very simple check on the session.save_path for Windows.
495 523
 	// @todo Move this down later if they don't use database-driven sessions?
496
-	elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\')
497
-		$error = 'error_session_save_path';
524
+	elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') {
525
+			$error = 'error_session_save_path';
526
+	}
498 527
 
499 528
 	// Since each of the three messages would look the same, anyway...
500
-	if (isset($error))
501
-		$incontext['error'] = $txt[$error];
529
+	if (isset($error)) {
530
+			$incontext['error'] = $txt[$error];
531
+	}
502 532
 
503 533
 	// Mod_security blocks everything that smells funny. Let SMF handle security.
504
-	if (!fixModSecurity() && !isset($_GET['overmodsecurity']))
505
-		$incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again'];
534
+	if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) {
535
+			$incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again'];
536
+	}
506 537
 
507 538
 	// Confirm mbstring is loaded...
508
-	if (!extension_loaded('mbstring'))
509
-		$incontext['error'] = $txt['install_no_mbstring'];
539
+	if (!extension_loaded('mbstring')) {
540
+			$incontext['error'] = $txt['install_no_mbstring'];
541
+	}
510 542
 
511 543
 	// Check for https stream support.
512 544
 	$supported_streams = stream_get_wrappers();
513
-	if (!in_array('https', $supported_streams))
514
-		$incontext['warning'] = $txt['install_no_https'];
545
+	if (!in_array('https', $supported_streams)) {
546
+			$incontext['warning'] = $txt['install_no_https'];
547
+	}
515 548
 
516 549
 	return false;
517 550
 }
@@ -536,12 +569,14 @@  discard block
 block discarded – undo
536 569
 		'Settings_bak.php',
537 570
 	);
538 571
 
539
-	foreach ($incontext['detected_languages'] as $lang => $temp)
540
-		$extra_files[] = 'Themes/default/languages/' . $lang;
572
+	foreach ($incontext['detected_languages'] as $lang => $temp) {
573
+			$extra_files[] = 'Themes/default/languages/' . $lang;
574
+	}
541 575
 
542 576
 	// With mod_security installed, we could attempt to fix it with .htaccess.
543
-	if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules()))
544
-		$writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.';
577
+	if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) {
578
+			$writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.';
579
+	}
545 580
 
546 581
 	$failed_files = array();
547 582
 
@@ -553,20 +588,23 @@  discard block
 block discarded – undo
553 588
 		foreach ($writable_files as $file)
554 589
 		{
555 590
 			// Some files won't exist, try to address up front
556
-			if (!file_exists(dirname(__FILE__) . '/' . $file))
557
-				@touch(dirname(__FILE__) . '/' . $file);
591
+			if (!file_exists(dirname(__FILE__) . '/' . $file)) {
592
+							@touch(dirname(__FILE__) . '/' . $file);
593
+			}
558 594
 			// NOW do the writable check...
559 595
 			if (!is_writable(dirname(__FILE__) . '/' . $file))
560 596
 			{
561 597
 				@chmod(dirname(__FILE__) . '/' . $file, 0755);
562 598
 
563 599
 				// Well, 755 hopefully worked... if not, try 777.
564
-				if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777))
565
-					$failed_files[] = $file;
600
+				if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) {
601
+									$failed_files[] = $file;
602
+				}
566 603
 			}
567 604
 		}
568
-		foreach ($extra_files as $file)
569
-			@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
605
+		foreach ($extra_files as $file) {
606
+					@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
607
+		}
570 608
 	}
571 609
 	// Windows is trickier.  Let's try opening for r+...
572 610
 	else
@@ -576,30 +614,35 @@  discard block
 block discarded – undo
576 614
 		foreach ($writable_files as $file)
577 615
 		{
578 616
 			// Folders can't be opened for write... but the index.php in them can ;)
579
-			if (is_dir(dirname(__FILE__) . '/' . $file))
580
-				$file .= '/index.php';
617
+			if (is_dir(dirname(__FILE__) . '/' . $file)) {
618
+							$file .= '/index.php';
619
+			}
581 620
 
582 621
 			// Funny enough, chmod actually does do something on windows - it removes the read only attribute.
583 622
 			@chmod(dirname(__FILE__) . '/' . $file, 0777);
584 623
 			$fp = @fopen(dirname(__FILE__) . '/' . $file, 'r+');
585 624
 
586 625
 			// Hmm, okay, try just for write in that case...
587
-			if (!is_resource($fp))
588
-				$fp = @fopen(dirname(__FILE__) . '/' . $file, 'w');
626
+			if (!is_resource($fp)) {
627
+							$fp = @fopen(dirname(__FILE__) . '/' . $file, 'w');
628
+			}
589 629
 
590
-			if (!is_resource($fp))
591
-				$failed_files[] = $file;
630
+			if (!is_resource($fp)) {
631
+							$failed_files[] = $file;
632
+			}
592 633
 
593 634
 			@fclose($fp);
594 635
 		}
595
-		foreach ($extra_files as $file)
596
-			@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
636
+		foreach ($extra_files as $file) {
637
+					@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
638
+		}
597 639
 	}
598 640
 
599 641
 	$failure = count($failed_files) >= 1;
600 642
 
601
-	if (!isset($_SERVER))
602
-		return !$failure;
643
+	if (!isset($_SERVER)) {
644
+			return !$failure;
645
+	}
603 646
 
604 647
 	// Put the list into context.
605 648
 	$incontext['failed_files'] = $failed_files;
@@ -647,19 +690,23 @@  discard block
 block discarded – undo
647 690
 
648 691
 		if (!isset($ftp) || $ftp->error !== false)
649 692
 		{
650
-			if (!isset($ftp))
651
-				$ftp = new ftp_connection(null);
693
+			if (!isset($ftp)) {
694
+							$ftp = new ftp_connection(null);
695
+			}
652 696
 			// Save the error so we can mess with listing...
653
-			elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message))
654
-				$incontext['ftp_errors'][] = $ftp->last_message;
697
+			elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) {
698
+							$incontext['ftp_errors'][] = $ftp->last_message;
699
+			}
655 700
 
656 701
 			list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__));
657 702
 
658
-			if (empty($_POST['ftp_path']) && $found_path)
659
-				$_POST['ftp_path'] = $detect_path;
703
+			if (empty($_POST['ftp_path']) && $found_path) {
704
+							$_POST['ftp_path'] = $detect_path;
705
+			}
660 706
 
661
-			if (!isset($_POST['ftp_username']))
662
-				$_POST['ftp_username'] = $username;
707
+			if (!isset($_POST['ftp_username'])) {
708
+							$_POST['ftp_username'] = $username;
709
+			}
663 710
 
664 711
 			// Set the username etc, into context.
665 712
 			$incontext['ftp'] = array(
@@ -671,8 +718,7 @@  discard block
 block discarded – undo
671 718
 			);
672 719
 
673 720
 			return false;
674
-		}
675
-		else
721
+		} else
676 722
 		{
677 723
 			$_SESSION['installer_temp_ftp'] = array(
678 724
 				'server' => $_POST['ftp_server'],
@@ -686,10 +732,12 @@  discard block
 block discarded – undo
686 732
 
687 733
 			foreach ($failed_files as $file)
688 734
 			{
689
-				if (!is_writable(dirname(__FILE__) . '/' . $file))
690
-					$ftp->chmod($file, 0755);
691
-				if (!is_writable(dirname(__FILE__) . '/' . $file))
692
-					$ftp->chmod($file, 0777);
735
+				if (!is_writable(dirname(__FILE__) . '/' . $file)) {
736
+									$ftp->chmod($file, 0755);
737
+				}
738
+				if (!is_writable(dirname(__FILE__) . '/' . $file)) {
739
+									$ftp->chmod($file, 0777);
740
+				}
693 741
 				if (!is_writable(dirname(__FILE__) . '/' . $file))
694 742
 				{
695 743
 					$failed_files_updated[] = $file;
@@ -745,15 +793,17 @@  discard block
 block discarded – undo
745 793
 
746 794
 			if (!$foundOne)
747 795
 			{
748
-				if (isset($db['default_host']))
749
-					$incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost';
796
+				if (isset($db['default_host'])) {
797
+									$incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost';
798
+				}
750 799
 				if (isset($db['default_user']))
751 800
 				{
752 801
 					$incontext['db']['user'] = ini_get($db['default_user']);
753 802
 					$incontext['db']['name'] = ini_get($db['default_user']);
754 803
 				}
755
-				if (isset($db['default_password']))
756
-					$incontext['db']['pass'] = ini_get($db['default_password']);
804
+				if (isset($db['default_password'])) {
805
+									$incontext['db']['pass'] = ini_get($db['default_password']);
806
+				}
757 807
 
758 808
 				// For simplicity and less confusion, leave the port blank by default
759 809
 				$incontext['db']['port'] = '';
@@ -772,10 +822,10 @@  discard block
 block discarded – undo
772 822
 		$incontext['db']['server'] = $_POST['db_server'];
773 823
 		$incontext['db']['prefix'] = $_POST['db_prefix'];
774 824
 
775
-		if (!empty($_POST['db_port']))
776
-			$incontext['db']['port'] = $_POST['db_port'];
777
-	}
778
-	else
825
+		if (!empty($_POST['db_port'])) {
826
+					$incontext['db']['port'] = $_POST['db_port'];
827
+		}
828
+	} else
779 829
 	{
780 830
 		$incontext['db']['prefix'] = 'smf_';
781 831
 	}
@@ -811,10 +861,11 @@  discard block
 block discarded – undo
811 861
 		if (!empty($_POST['db_port']))
812 862
 		{
813 863
 			// For MySQL, we can get the "default port" from PHP. PostgreSQL has no such option though.
814
-			if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port'))
815
-				$vars['db_port'] = (int) $_POST['db_port'];
816
-			elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432)
817
-				$vars['db_port'] = (int) $_POST['db_port'];
864
+			if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) {
865
+							$vars['db_port'] = (int) $_POST['db_port'];
866
+			} elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) {
867
+							$vars['db_port'] = (int) $_POST['db_port'];
868
+			}
818 869
 		}
819 870
 
820 871
 		// God I hope it saved!
@@ -827,8 +878,9 @@  discard block
 block discarded – undo
827 878
 		// Make sure it works.
828 879
 		require(dirname(__FILE__) . '/Settings.php');
829 880
 
830
-		if (empty($sourcedir))
831
-			$sourcedir = dirname(__FILE__) . '/Sources';
881
+		if (empty($sourcedir)) {
882
+					$sourcedir = dirname(__FILE__) . '/Sources';
883
+		}
832 884
 
833 885
 		// Better find the database file!
834 886
 		if (!file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php'))
@@ -838,18 +890,21 @@  discard block
 block discarded – undo
838 890
 		}
839 891
 
840 892
 		// Now include it for database functions!
841
-		if (!defined('SMF'))
842
-			define('SMF', 1);
893
+		if (!defined('SMF')) {
894
+					define('SMF', 1);
895
+		}
843 896
 
844 897
 		$modSettings['disableQueryCheck'] = true;
845
-		if (empty($smcFunc))
846
-			$smcFunc = array();
898
+		if (empty($smcFunc)) {
899
+					$smcFunc = array();
900
+		}
847 901
 
848 902
 			require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
849 903
 
850 904
 		// What - running PHP4? The shame!
851
-		if (version_compare(PHP_VERSION, '5', '<'))
852
-			require_once($sourcedir . '/Subs-Compat.php');
905
+		if (version_compare(PHP_VERSION, '5', '<')) {
906
+					require_once($sourcedir . '/Subs-Compat.php');
907
+		}
853 908
 
854 909
 		// Attempt a connection.
855 910
 		$needsDB = !empty($databases[$db_type]['always_has_db']);
@@ -937,12 +992,14 @@  discard block
 block discarded – undo
937 992
 	$incontext['page_title'] = $txt['install_settings'];
938 993
 
939 994
 	// Let's see if we got the database type correct.
940
-	if (isset($_POST['db_type'], $databases[$_POST['db_type']]))
941
-		$db_type = $_POST['db_type'];
995
+	if (isset($_POST['db_type'], $databases[$_POST['db_type']])) {
996
+			$db_type = $_POST['db_type'];
997
+	}
942 998
 
943 999
 	// Else we'd better be able to get the connection.
944
-	else
945
-		load_database();
1000
+	else {
1001
+			load_database();
1002
+	}
946 1003
 
947 1004
 	$db_type = isset($_POST['db_type']) ? $_POST['db_type'] : $db_type;
948 1005
 
@@ -951,10 +1008,11 @@  discard block
 block discarded – undo
951 1008
 
952 1009
 		$secure = false;
953 1010
 
954
-		if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on')
955
-			$secure = true;
956
-		elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on')
957
-			$secure = true;
1011
+		if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
1012
+					$secure = true;
1013
+		} elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') {
1014
+					$secure = true;
1015
+		}
958 1016
 
959 1017
 	// Now, to put what we've learned together... and add a path.
960 1018
 	$incontext['detected_url'] = 'http' . ($secure ? 's' : '') . '://' . $host . substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/'));
@@ -986,18 +1044,21 @@  discard block
 block discarded – undo
986 1044
 	// Submitting?
987 1045
 	if (isset($_POST['boardurl']))
988 1046
 	{
989
-		if (substr($_POST['boardurl'], -10) == '/index.php')
990
-			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
991
-		elseif (substr($_POST['boardurl'], -1) == '/')
992
-			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
993
-		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://')
994
-			$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
1047
+		if (substr($_POST['boardurl'], -10) == '/index.php') {
1048
+					$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
1049
+		} elseif (substr($_POST['boardurl'], -1) == '/') {
1050
+					$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
1051
+		}
1052
+		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') {
1053
+					$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
1054
+		}
995 1055
 
996 1056
 		//Make sure boardurl is aligned with ssl setting
997
-		if (empty($_POST['force_ssl']))
998
-			$_POST['boardurl'] = strtr($_POST['boardurl'], array('https://' => 'http://'));
999
-		else
1000
-			$_POST['boardurl'] = strtr($_POST['boardurl'], array('http://' => 'https://'));
1057
+		if (empty($_POST['force_ssl'])) {
1058
+					$_POST['boardurl'] = strtr($_POST['boardurl'], array('https://' => 'http://'));
1059
+		} else {
1060
+					$_POST['boardurl'] = strtr($_POST['boardurl'], array('http://' => 'https://'));
1061
+		}
1001 1062
 
1002 1063
 		// Save these variables.
1003 1064
 		$vars = array(
@@ -1036,10 +1097,10 @@  discard block
 block discarded – undo
1036 1097
 			{
1037 1098
 				$incontext['error'] = sprintf($txt['error_utf8_version'], $databases[$db_type]['utf8_version']);
1038 1099
 				return false;
1039
-			}
1040
-			else
1041
-				// Set the character set here.
1100
+			} else {
1101
+							// Set the character set here.
1042 1102
 				updateSettingsFile(array('db_character_set' => 'utf8'));
1103
+			}
1043 1104
 		}
1044 1105
 
1045 1106
 		// Good, skip on.
@@ -1059,8 +1120,9 @@  discard block
 block discarded – undo
1059 1120
 	$incontext['continue'] = 1;
1060 1121
 
1061 1122
 	// Already done?
1062
-	if (isset($_POST['pop_done']))
1063
-		return true;
1123
+	if (isset($_POST['pop_done'])) {
1124
+			return true;
1125
+	}
1064 1126
 
1065 1127
 	// Reload settings.
1066 1128
 	require(dirname(__FILE__) . '/Settings.php');
@@ -1078,8 +1140,9 @@  discard block
 block discarded – undo
1078 1140
 	$modSettings = array();
1079 1141
 	if ($result !== false)
1080 1142
 	{
1081
-		while ($row = $smcFunc['db_fetch_assoc']($result))
1082
-			$modSettings[$row['variable']] = $row['value'];
1143
+		while ($row = $smcFunc['db_fetch_assoc']($result)) {
1144
+					$modSettings[$row['variable']] = $row['value'];
1145
+		}
1083 1146
 		$smcFunc['db_free_result']($result);
1084 1147
 
1085 1148
 		// Do they match?  If so, this is just a refresh so charge on!
@@ -1092,20 +1155,22 @@  discard block
 block discarded – undo
1092 1155
 	$modSettings['disableQueryCheck'] = true;
1093 1156
 
1094 1157
 	// If doing UTF8, select it. PostgreSQL requires passing it as a string...
1095
-	if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support']))
1096
-		$smcFunc['db_query']('', '
1158
+	if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) {
1159
+			$smcFunc['db_query']('', '
1097 1160
 			SET NAMES {string:utf8}',
1098 1161
 			array(
1099 1162
 				'db_error_skip' => true,
1100 1163
 				'utf8' => 'utf8',
1101 1164
 			)
1102 1165
 		);
1166
+	}
1103 1167
 
1104 1168
 	// Windows likes to leave the trailing slash, which yields to C:\path\to\SMF\/attachments...
1105
-	if (substr(__DIR__, -1) == '\\')
1106
-		$attachdir = __DIR__ . 'attachments';
1107
-	else
1108
-		$attachdir = __DIR__ . '/attachments';
1169
+	if (substr(__DIR__, -1) == '\\') {
1170
+			$attachdir = __DIR__ . 'attachments';
1171
+	} else {
1172
+			$attachdir = __DIR__ . '/attachments';
1173
+	}
1109 1174
 
1110 1175
 	$replaces = array(
1111 1176
 		'{$db_prefix}' => $db_prefix,
@@ -1122,8 +1187,9 @@  discard block
 block discarded – undo
1122 1187
 
1123 1188
 	foreach ($txt as $key => $value)
1124 1189
 	{
1125
-		if (substr($key, 0, 8) == 'default_')
1126
-			$replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value);
1190
+		if (substr($key, 0, 8) == 'default_') {
1191
+					$replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value);
1192
+		}
1127 1193
 	}
1128 1194
 	$replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], array('\\\\n' => '\\n'));
1129 1195
 
@@ -1138,8 +1204,9 @@  discard block
 block discarded – undo
1138 1204
 
1139 1205
 		while ($row = $smcFunc['db_fetch_assoc']($get_engines))
1140 1206
 		{
1141
-			if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT')
1142
-				$engines[] = $row['Engine'];
1207
+			if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') {
1208
+							$engines[] = $row['Engine'];
1209
+			}
1143 1210
 		}
1144 1211
 
1145 1212
 		// Done with this now
@@ -1163,8 +1230,7 @@  discard block
 block discarded – undo
1163 1230
 			$replaces['START TRANSACTION;'] = '';
1164 1231
 			$replaces['COMMIT;'] = '';
1165 1232
 		}
1166
-	}
1167
-	else
1233
+	} else
1168 1234
 	{
1169 1235
 		$has_innodb = false;
1170 1236
 	}
@@ -1186,21 +1252,24 @@  discard block
 block discarded – undo
1186 1252
 	foreach ($sql_lines as $count => $line)
1187 1253
 	{
1188 1254
 		// No comments allowed!
1189
-		if (substr(trim($line), 0, 1) != '#')
1190
-			$current_statement .= "\n" . rtrim($line);
1255
+		if (substr(trim($line), 0, 1) != '#') {
1256
+					$current_statement .= "\n" . rtrim($line);
1257
+		}
1191 1258
 
1192 1259
 		// Is this the end of the query string?
1193
-		if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines)))
1194
-			continue;
1260
+		if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) {
1261
+					continue;
1262
+		}
1195 1263
 
1196 1264
 		// Does this table already exist?  If so, don't insert more data into it!
1197 1265
 		if (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) != 0 && in_array($match[1], $exists))
1198 1266
 		{
1199 1267
 			preg_match_all('~\)[,;]~', $current_statement, $matches);
1200
-			if (!empty($matches[0]))
1201
-				$incontext['sql_results']['insert_dups'] += count($matches[0]);
1202
-			else
1203
-				$incontext['sql_results']['insert_dups']++;
1268
+			if (!empty($matches[0])) {
1269
+							$incontext['sql_results']['insert_dups'] += count($matches[0]);
1270
+			} else {
1271
+							$incontext['sql_results']['insert_dups']++;
1272
+			}
1204 1273
 
1205 1274
 			$current_statement = '';
1206 1275
 			continue;
@@ -1209,8 +1278,9 @@  discard block
 block discarded – undo
1209 1278
 		if ($smcFunc['db_query']('', $current_statement, array('security_override' => true, 'db_error_skip' => true), $db_connection) === false)
1210 1279
 		{
1211 1280
 			// Use the appropriate function based on the DB type
1212
-			if ($db_type == 'mysql' || $db_type == 'mysqli')
1213
-				$db_errorno = $db_type . '_errno';
1281
+			if ($db_type == 'mysql' || $db_type == 'mysqli') {
1282
+							$db_errorno = $db_type . '_errno';
1283
+			}
1214 1284
 
1215 1285
 			// Error 1050: Table already exists!
1216 1286
 			// @todo Needs to be made better!
@@ -1225,18 +1295,18 @@  discard block
 block discarded – undo
1225 1295
 				// MySQLi requires a connection object. It's optional with MySQL and Postgres
1226 1296
 				$incontext['failures'][$count] = $smcFunc['db_error']($db_connection);
1227 1297
 			}
1228
-		}
1229
-		else
1298
+		} else
1230 1299
 		{
1231
-			if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1)
1232
-				$incontext['sql_results']['tables']++;
1233
-			elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1)
1300
+			if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) {
1301
+							$incontext['sql_results']['tables']++;
1302
+			} elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1)
1234 1303
 			{
1235 1304
 				preg_match_all('~\)[,;]~', $current_statement, $matches);
1236
-				if (!empty($matches[0]))
1237
-					$incontext['sql_results']['inserts'] += count($matches[0]);
1238
-				else
1239
-					$incontext['sql_results']['inserts']++;
1305
+				if (!empty($matches[0])) {
1306
+									$incontext['sql_results']['inserts'] += count($matches[0]);
1307
+				} else {
1308
+									$incontext['sql_results']['inserts']++;
1309
+				}
1240 1310
 			}
1241 1311
 		}
1242 1312
 
@@ -1249,15 +1319,17 @@  discard block
 block discarded – undo
1249 1319
 	// Sort out the context for the SQL.
1250 1320
 	foreach ($incontext['sql_results'] as $key => $number)
1251 1321
 	{
1252
-		if ($number == 0)
1253
-			unset($incontext['sql_results'][$key]);
1254
-		else
1255
-			$incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number);
1322
+		if ($number == 0) {
1323
+					unset($incontext['sql_results'][$key]);
1324
+		} else {
1325
+					$incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number);
1326
+		}
1256 1327
 	}
1257 1328
 
1258 1329
 	// Make sure UTF will be used globally.
1259
-	if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8'])))
1260
-		$newSettings[] = array('global_character_set', 'UTF-8');
1330
+	if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8']))) {
1331
+			$newSettings[] = array('global_character_set', 'UTF-8');
1332
+	}
1261 1333
 
1262 1334
 	// Auto-detect local & global cookie settings
1263 1335
 	$url_parts = parse_url($boardurl);
@@ -1286,15 +1358,19 @@  discard block
 block discarded – undo
1286 1358
 
1287 1359
 		// Look for subfolder, if found, set localCookie
1288 1360
 		// Checking for len > 1 ensures you don't have just a slash...
1289
-		if (!empty($url_parts['path']) && strlen($url_parts['path']) > 1)
1290
-			$localCookies = '1';
1361
+		if (!empty($url_parts['path']) && strlen($url_parts['path']) > 1) {
1362
+					$localCookies = '1';
1363
+		}
1291 1364
 
1292
-		if (isset($globalCookies))
1293
-			$newSettings[] = array('globalCookies', $globalCookies);
1294
-		if (isset($globalCookiesDomain))
1295
-			$newSettings[] = array('globalCookiesDomain', $globalCookiesDomain);
1296
-		if (isset($localCookies))
1297
-			$newSettings[] = array('localCookies', $localCookies);
1365
+		if (isset($globalCookies)) {
1366
+					$newSettings[] = array('globalCookies', $globalCookies);
1367
+		}
1368
+		if (isset($globalCookiesDomain)) {
1369
+					$newSettings[] = array('globalCookiesDomain', $globalCookiesDomain);
1370
+		}
1371
+		if (isset($localCookies)) {
1372
+					$newSettings[] = array('localCookies', $localCookies);
1373
+		}
1298 1374
 	}
1299 1375
 
1300 1376
 	// Are we allowing stat collection?
@@ -1312,16 +1388,17 @@  discard block
 block discarded – undo
1312 1388
 			fwrite($fp, $out);
1313 1389
 
1314 1390
 			$return_data = '';
1315
-			while (!feof($fp))
1316
-				$return_data .= fgets($fp, 128);
1391
+			while (!feof($fp)) {
1392
+							$return_data .= fgets($fp, 128);
1393
+			}
1317 1394
 
1318 1395
 			fclose($fp);
1319 1396
 
1320 1397
 			// Get the unique site ID.
1321 1398
 			preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID);
1322 1399
 
1323
-			if (!empty($ID[1]))
1324
-				$smcFunc['db_insert']('replace',
1400
+			if (!empty($ID[1])) {
1401
+							$smcFunc['db_insert']('replace',
1325 1402
 					$db_prefix . 'settings',
1326 1403
 					array('variable' => 'string', 'value' => 'string'),
1327 1404
 					array(
@@ -1330,11 +1407,12 @@  discard block
 block discarded – undo
1330 1407
 					),
1331 1408
 					array('variable')
1332 1409
 				);
1410
+			}
1333 1411
 		}
1334 1412
 	}
1335 1413
 	// Don't remove stat collection unless we unchecked the box for real, not from the loop.
1336
-	elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats']))
1337
-		$smcFunc['db_query']('', '
1414
+	elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) {
1415
+			$smcFunc['db_query']('', '
1338 1416
 			DELETE FROM {db_prefix}settings
1339 1417
 			WHERE variable = {string:enable_sm_stats}',
1340 1418
 			array(
@@ -1342,20 +1420,23 @@  discard block
 block discarded – undo
1342 1420
 				'db_error_skip' => true,
1343 1421
 			)
1344 1422
 		);
1423
+	}
1345 1424
 
1346 1425
 	// Are we enabling SSL?
1347
-	if (!empty($_POST['force_ssl']))
1348
-		$newSettings[] = array('force_ssl', 1);
1426
+	if (!empty($_POST['force_ssl'])) {
1427
+			$newSettings[] = array('force_ssl', 1);
1428
+	}
1349 1429
 
1350 1430
 	// Setting a timezone is required.
1351 1431
 	if (!isset($modSettings['default_timezone']) && function_exists('date_default_timezone_set'))
1352 1432
 	{
1353 1433
 		// Get PHP's default timezone, if set
1354 1434
 		$ini_tz = ini_get('date.timezone');
1355
-		if (!empty($ini_tz))
1356
-			$timezone_id = $ini_tz;
1357
-		else
1358
-			$timezone_id = '';
1435
+		if (!empty($ini_tz)) {
1436
+					$timezone_id = $ini_tz;
1437
+		} else {
1438
+					$timezone_id = '';
1439
+		}
1359 1440
 
1360 1441
 		// If date.timezone is unset, invalid, or just plain weird, make a best guess
1361 1442
 		if (!in_array($timezone_id, timezone_identifiers_list()))
@@ -1364,8 +1445,9 @@  discard block
 block discarded – undo
1364 1445
 			$timezone_id = timezone_name_from_abbr('', $server_offset, 0);
1365 1446
 		}
1366 1447
 
1367
-		if (date_default_timezone_set($timezone_id))
1368
-			$newSettings[] = array('default_timezone', $timezone_id);
1448
+		if (date_default_timezone_set($timezone_id)) {
1449
+					$newSettings[] = array('default_timezone', $timezone_id);
1450
+		}
1369 1451
 	}
1370 1452
 
1371 1453
 	if (!empty($newSettings))
@@ -1396,16 +1478,18 @@  discard block
 block discarded – undo
1396 1478
 	}
1397 1479
 
1398 1480
 	// MySQL specific stuff
1399
-	if (substr($db_type, 0, 5) != 'mysql')
1400
-		return false;
1481
+	if (substr($db_type, 0, 5) != 'mysql') {
1482
+			return false;
1483
+	}
1401 1484
 
1402 1485
 	// Find database user privileges.
1403 1486
 	$privs = array();
1404 1487
 	$get_privs = $smcFunc['db_query']('', 'SHOW PRIVILEGES', array());
1405 1488
 	while ($row = $smcFunc['db_fetch_assoc']($get_privs))
1406 1489
 	{
1407
-		if ($row['Privilege'] == 'Alter')
1408
-			$privs[] = $row['Privilege'];
1490
+		if ($row['Privilege'] == 'Alter') {
1491
+					$privs[] = $row['Privilege'];
1492
+		}
1409 1493
 	}
1410 1494
 	$smcFunc['db_free_result']($get_privs);
1411 1495
 
@@ -1435,8 +1519,9 @@  discard block
 block discarded – undo
1435 1519
 	$incontext['continue'] = 1;
1436 1520
 
1437 1521
 	// Skipping?
1438
-	if (!empty($_POST['skip']))
1439
-		return true;
1522
+	if (!empty($_POST['skip'])) {
1523
+			return true;
1524
+	}
1440 1525
 
1441 1526
 	// Need this to check whether we need the database password.
1442 1527
 	require(dirname(__FILE__) . '/Settings.php');
@@ -1453,18 +1538,22 @@  discard block
 block discarded – undo
1453 1538
 	// We need this to properly hash the password for Admin
1454 1539
 	$smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) {
1455 1540
 			global $sourcedir;
1456
-			if (function_exists('mb_strtolower'))
1457
-				return mb_strtolower($string, 'UTF-8');
1541
+			if (function_exists('mb_strtolower')) {
1542
+							return mb_strtolower($string, 'UTF-8');
1543
+			}
1458 1544
 			require_once($sourcedir . '/Subs-Charset.php');
1459 1545
 			return utf8_strtolower($string);
1460 1546
 		};
1461 1547
 
1462
-	if (!isset($_POST['username']))
1463
-		$_POST['username'] = '';
1464
-	if (!isset($_POST['email']))
1465
-		$_POST['email'] = '';
1466
-	if (!isset($_POST['server_email']))
1467
-		$_POST['server_email'] = '';
1548
+	if (!isset($_POST['username'])) {
1549
+			$_POST['username'] = '';
1550
+	}
1551
+	if (!isset($_POST['email'])) {
1552
+			$_POST['email'] = '';
1553
+	}
1554
+	if (!isset($_POST['server_email'])) {
1555
+			$_POST['server_email'] = '';
1556
+	}
1468 1557
 
1469 1558
 	$incontext['username'] = htmlspecialchars(stripslashes($_POST['username']));
1470 1559
 	$incontext['email'] = htmlspecialchars(stripslashes($_POST['email']));
@@ -1483,8 +1572,9 @@  discard block
 block discarded – undo
1483 1572
 			'admin_group' => 1,
1484 1573
 		)
1485 1574
 	);
1486
-	if ($smcFunc['db_num_rows']($request) != 0)
1487
-		$incontext['skip'] = 1;
1575
+	if ($smcFunc['db_num_rows']($request) != 0) {
1576
+			$incontext['skip'] = 1;
1577
+	}
1488 1578
 	$smcFunc['db_free_result']($request);
1489 1579
 
1490 1580
 	// Trying to create an account?
@@ -1515,8 +1605,9 @@  discard block
 block discarded – undo
1515 1605
 		}
1516 1606
 
1517 1607
 		// Update the webmaster's email?
1518
-		if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]'))
1519
-			updateSettingsFile(array('webmaster_email' => $_POST['server_email']));
1608
+		if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) {
1609
+					updateSettingsFile(array('webmaster_email' => $_POST['server_email']));
1610
+		}
1520 1611
 
1521 1612
 		// Work out whether we're going to have dodgy characters and remove them.
1522 1613
 		$invalid_characters = preg_match('~[<>&"\'=\\\]~', $_POST['username']) != 0;
@@ -1539,32 +1630,27 @@  discard block
 block discarded – undo
1539 1630
 			$smcFunc['db_free_result']($result);
1540 1631
 
1541 1632
 			$incontext['account_existed'] = $txt['error_user_settings_taken'];
1542
-		}
1543
-		elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25)
1633
+		} elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25)
1544 1634
 		{
1545 1635
 			// Try the previous step again.
1546 1636
 			$incontext['error'] = $_POST['username'] == '' ? $txt['error_username_left_empty'] : $txt['error_username_too_long'];
1547 1637
 			return false;
1548
-		}
1549
-		elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false)
1638
+		} elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false)
1550 1639
 		{
1551 1640
 			// Try the previous step again.
1552 1641
 			$incontext['error'] = $txt['error_invalid_characters_username'];
1553 1642
 			return false;
1554
-		}
1555
-		elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255)
1643
+		} elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255)
1556 1644
 		{
1557 1645
 			// One step back, this time fill out a proper admin email address.
1558 1646
 			$incontext['error'] = sprintf($txt['error_valid_admin_email_needed'], $_POST['username']);
1559 1647
 			return false;
1560
-		}
1561
-		elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255)
1648
+		} elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255)
1562 1649
 		{
1563 1650
 			// One step back, this time fill out a proper admin email address.
1564 1651
 			$incontext['error'] = $txt['error_valid_server_email_needed'];
1565 1652
 			return false;
1566
-		}
1567
-		elseif ($_POST['username'] != '')
1653
+		} elseif ($_POST['username'] != '')
1568 1654
 		{
1569 1655
 			$incontext['member_salt'] = substr(md5(mt_rand()), 0, 4);
1570 1656
 
@@ -1632,17 +1718,19 @@  discard block
 block discarded – undo
1632 1718
 	reloadSettings();
1633 1719
 
1634 1720
 	// Bring a warning over.
1635
-	if (!empty($incontext['account_existed']))
1636
-		$incontext['warning'] = $incontext['account_existed'];
1721
+	if (!empty($incontext['account_existed'])) {
1722
+			$incontext['warning'] = $incontext['account_existed'];
1723
+	}
1637 1724
 
1638
-	if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support']))
1639
-		$smcFunc['db_query']('', '
1725
+	if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) {
1726
+			$smcFunc['db_query']('', '
1640 1727
 			SET NAMES {string:db_character_set}',
1641 1728
 			array(
1642 1729
 				'db_character_set' => $db_character_set,
1643 1730
 				'db_error_skip' => true,
1644 1731
 			)
1645 1732
 		);
1733
+	}
1646 1734
 
1647 1735
 	// As track stats is by default enabled let's add some activity.
1648 1736
 	$smcFunc['db_insert']('ignore',
@@ -1663,14 +1751,16 @@  discard block
 block discarded – undo
1663 1751
 	// Only proceed if we can load the data.
1664 1752
 	if ($request)
1665 1753
 	{
1666
-		while ($row = $smcFunc['db_fetch_row']($request))
1667
-			$modSettings[$row[0]] = $row[1];
1754
+		while ($row = $smcFunc['db_fetch_row']($request)) {
1755
+					$modSettings[$row[0]] = $row[1];
1756
+		}
1668 1757
 		$smcFunc['db_free_result']($request);
1669 1758
 	}
1670 1759
 
1671 1760
 	// Automatically log them in ;)
1672
-	if (isset($incontext['member_id']) && isset($incontext['member_salt']))
1673
-		setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt']));
1761
+	if (isset($incontext['member_id']) && isset($incontext['member_salt'])) {
1762
+			setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt']));
1763
+	}
1674 1764
 
1675 1765
 	$result = $smcFunc['db_query']('', '
1676 1766
 		SELECT value
@@ -1681,13 +1771,14 @@  discard block
 block discarded – undo
1681 1771
 			'db_error_skip' => true,
1682 1772
 		)
1683 1773
 	);
1684
-	if ($smcFunc['db_num_rows']($result) != 0)
1685
-		list ($db_sessions) = $smcFunc['db_fetch_row']($result);
1774
+	if ($smcFunc['db_num_rows']($result) != 0) {
1775
+			list ($db_sessions) = $smcFunc['db_fetch_row']($result);
1776
+	}
1686 1777
 	$smcFunc['db_free_result']($result);
1687 1778
 
1688
-	if (empty($db_sessions))
1689
-		$_SESSION['admin_time'] = time();
1690
-	else
1779
+	if (empty($db_sessions)) {
1780
+			$_SESSION['admin_time'] = time();
1781
+	} else
1691 1782
 	{
1692 1783
 		$_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211);
1693 1784
 
@@ -1711,8 +1802,9 @@  discard block
 block discarded – undo
1711 1802
 	$smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' :
1712 1803
 		function($string){
1713 1804
 			global $sourcedir;
1714
-			if (function_exists('mb_strtolower'))
1715
-				return mb_strtolower($string, 'UTF-8');
1805
+			if (function_exists('mb_strtolower')) {
1806
+							return mb_strtolower($string, 'UTF-8');
1807
+			}
1716 1808
 			require_once($sourcedir . '/Subs-Charset.php');
1717 1809
 			return utf8_strtolower($string);
1718 1810
 		};
@@ -1728,8 +1820,9 @@  discard block
 block discarded – undo
1728 1820
 		)
1729 1821
 	);
1730 1822
 	$context['utf8'] = $db_character_set === 'utf8' || $txt['lang_character_set'] === 'UTF-8';
1731
-	if ($smcFunc['db_num_rows']($request) > 0)
1732
-		updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject']));
1823
+	if ($smcFunc['db_num_rows']($request) > 0) {
1824
+			updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject']));
1825
+	}
1733 1826
 	$smcFunc['db_free_result']($request);
1734 1827
 
1735 1828
 	// Now is the perfect time to fetch the SM files.
@@ -1748,8 +1841,9 @@  discard block
 block discarded – undo
1748 1841
 
1749 1842
 	// Check if we need some stupid MySQL fix.
1750 1843
 	$server_version = $smcFunc['db_server_info']();
1751
-	if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51')))
1752
-		updateSettings(array('db_mysql_group_by_fix' => '1'));
1844
+	if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) {
1845
+			updateSettings(array('db_mysql_group_by_fix' => '1'));
1846
+	}
1753 1847
 
1754 1848
 	// Some final context for the template.
1755 1849
 	$incontext['dir_still_writable'] = is_writable(dirname(__FILE__)) && substr(__FILE__, 1, 2) != ':\\';
@@ -1769,8 +1863,9 @@  discard block
 block discarded – undo
1769 1863
 	$settingsArray = file(dirname(__FILE__) . '/Settings.php');
1770 1864
 
1771 1865
 	// @todo Do we just want to read the file in clean, and split it this way always?
1772
-	if (count($settingsArray) == 1)
1773
-		$settingsArray = preg_split('~[\r\n]~', $settingsArray[0]);
1866
+	if (count($settingsArray) == 1) {
1867
+			$settingsArray = preg_split('~[\r\n]~', $settingsArray[0]);
1868
+	}
1774 1869
 
1775 1870
 	for ($i = 0, $n = count($settingsArray); $i < $n; $i++)
1776 1871
 	{
@@ -1778,25 +1873,29 @@  discard block
 block discarded – undo
1778 1873
 		if (trim($settingsArray[$i]) == 'if (file_exists(dirname(__FILE__) . \'/install.php\'))' && trim($settingsArray[$i + 1]) == '{' && trim($settingsArray[$i + 9]) == '}')
1779 1874
 		{
1780 1875
 			// Set the ten lines to nothing.
1781
-			for ($j=0; $j < 10; $j++)
1782
-				$settingsArray[$i++] = '';
1876
+			for ($j=0; $j < 10; $j++) {
1877
+							$settingsArray[$i++] = '';
1878
+			}
1783 1879
 
1784 1880
 			continue;
1785 1881
 		}
1786 1882
 
1787
-		if (trim($settingsArray[$i]) == '?' . '>')
1788
-			$settingsArray[$i] = '';
1883
+		if (trim($settingsArray[$i]) == '?' . '>') {
1884
+					$settingsArray[$i] = '';
1885
+		}
1789 1886
 
1790 1887
 		// Don't trim or bother with it if it's not a variable.
1791
-		if (substr($settingsArray[$i], 0, 1) != '$')
1792
-			continue;
1888
+		if (substr($settingsArray[$i], 0, 1) != '$') {
1889
+					continue;
1890
+		}
1793 1891
 
1794 1892
 		$settingsArray[$i] = rtrim($settingsArray[$i]) . "\n";
1795 1893
 
1796
-		foreach ($vars as $var => $val)
1797
-			if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0)
1894
+		foreach ($vars as $var => $val) {
1895
+					if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0)
1798 1896
 			{
1799 1897
 				$comment = strstr($settingsArray[$i], '#');
1898
+		}
1800 1899
 				$settingsArray[$i] = '$' . $var . ' = \'' . $val . '\';' . ($comment != '' ? "\t\t" . $comment : "\n");
1801 1900
 				unset($vars[$var]);
1802 1901
 			}
@@ -1806,36 +1905,41 @@  discard block
 block discarded – undo
1806 1905
 	if (!empty($vars))
1807 1906
 	{
1808 1907
 		$settingsArray[$i++] = '';
1809
-		foreach ($vars as $var => $val)
1810
-			$settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n";
1908
+		foreach ($vars as $var => $val) {
1909
+					$settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n";
1910
+		}
1811 1911
 	}
1812 1912
 
1813 1913
 	// Blank out the file - done to fix a oddity with some servers.
1814 1914
 	$fp = @fopen(dirname(__FILE__) . '/Settings.php', 'w');
1815
-	if (!$fp)
1816
-		return false;
1915
+	if (!$fp) {
1916
+			return false;
1917
+	}
1817 1918
 	fclose($fp);
1818 1919
 
1819 1920
 	$fp = fopen(dirname(__FILE__) . '/Settings.php', 'r+');
1820 1921
 
1821 1922
 	// Gotta have one of these ;)
1822
-	if (trim($settingsArray[0]) != '<?php')
1823
-		fwrite($fp, "<?php\n");
1923
+	if (trim($settingsArray[0]) != '<?php') {
1924
+			fwrite($fp, "<?php\n");
1925
+	}
1824 1926
 
1825 1927
 	$lines = count($settingsArray);
1826 1928
 	for ($i = 0; $i < $lines - 1; $i++)
1827 1929
 	{
1828 1930
 		// Don't just write a bunch of blank lines.
1829
-		if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '')
1830
-			fwrite($fp, strtr($settingsArray[$i], "\r", ''));
1931
+		if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') {
1932
+					fwrite($fp, strtr($settingsArray[$i], "\r", ''));
1933
+		}
1831 1934
 	}
1832 1935
 	fwrite($fp, $settingsArray[$i] . '?' . '>');
1833 1936
 	fclose($fp);
1834 1937
 
1835 1938
 	// Even though on normal installations the filemtime should prevent this being used by the installer incorrectly
1836 1939
 	// it seems that there are times it might not. So let's MAKE it dump the cache.
1837
-	if (function_exists('opcache_invalidate'))
1838
-		opcache_invalidate(dirname(__FILE__) . '/Settings.php', true);
1940
+	if (function_exists('opcache_invalidate')) {
1941
+			opcache_invalidate(dirname(__FILE__) . '/Settings.php', true);
1942
+	}
1839 1943
 
1840 1944
 	return true;
1841 1945
 }
@@ -1845,10 +1949,11 @@  discard block
 block discarded – undo
1845 1949
 	global $cachedir;
1846 1950
 
1847 1951
 	// Write out the db_last_error file with the error timestamp
1848
-	if (!empty($cachedir) && is_writable($cachedir))
1849
-		file_put_contents($cachedir . '/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>');
1850
-	else
1851
-		file_put_contents(dirname(__FILE__) . '/cache/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>');
1952
+	if (!empty($cachedir) && is_writable($cachedir)) {
1953
+			file_put_contents($cachedir . '/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>');
1954
+	} else {
1955
+			file_put_contents(dirname(__FILE__) . '/cache/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>');
1956
+	}
1852 1957
 
1853 1958
 	return true;
1854 1959
 }
@@ -1865,9 +1970,9 @@  discard block
 block discarded – undo
1865 1970
 	SecFilterScanPOST Off
1866 1971
 </IfModule>';
1867 1972
 
1868
-	if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules()))
1869
-		return true;
1870
-	elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess'))
1973
+	if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) {
1974
+			return true;
1975
+	} elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess'))
1871 1976
 	{
1872 1977
 		$current_htaccess = implode('', file(dirname(__FILE__) . '/.htaccess'));
1873 1978
 
@@ -1879,29 +1984,28 @@  discard block
 block discarded – undo
1879 1984
 				fwrite($ht_handle, $htaccess_addition);
1880 1985
 				fclose($ht_handle);
1881 1986
 				return true;
1987
+			} else {
1988
+							return false;
1882 1989
 			}
1883
-			else
1884
-				return false;
1990
+		} else {
1991
+					return true;
1885 1992
 		}
1886
-		else
1887
-			return true;
1888
-	}
1889
-	elseif (file_exists(dirname(__FILE__) . '/.htaccess'))
1890
-		return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false;
1891
-	elseif (is_writable(dirname(__FILE__)))
1993
+	} elseif (file_exists(dirname(__FILE__) . '/.htaccess')) {
1994
+			return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false;
1995
+	} elseif (is_writable(dirname(__FILE__)))
1892 1996
 	{
1893 1997
 		if ($ht_handle = fopen(dirname(__FILE__) . '/.htaccess', 'w'))
1894 1998
 		{
1895 1999
 			fwrite($ht_handle, $htaccess_addition);
1896 2000
 			fclose($ht_handle);
1897 2001
 			return true;
2002
+		} else {
2003
+					return false;
1898 2004
 		}
1899
-		else
2005
+	} else {
1900 2006
 			return false;
1901 2007
 	}
1902
-	else
1903
-		return false;
1904
-}
2008
+	}
1905 2009
 
1906 2010
 function template_install_above()
1907 2011
 {
@@ -1940,9 +2044,10 @@  discard block
 block discarded – undo
1940 2044
 							<label for="installer_language">', $txt['installer_language'], ':</label>
1941 2045
 							<select id="installer_language" name="lang_file" onchange="location.href = \'', $installurl, '?lang_file=\' + this.options[this.selectedIndex].value;">';
1942 2046
 
1943
-		foreach ($incontext['detected_languages'] as $lang => $name)
1944
-			echo '
2047
+		foreach ($incontext['detected_languages'] as $lang => $name) {
2048
+					echo '
1945 2049
 								<option', isset($_SESSION['installer_temp_lang']) && $_SESSION['installer_temp_lang'] == $lang ? ' selected' : '', ' value="', $lang, '">', $name, '</option>';
2050
+		}
1946 2051
 
1947 2052
 		echo '
1948 2053
 							</select>
@@ -1962,9 +2067,10 @@  discard block
 block discarded – undo
1962 2067
 					<h2>', $txt['upgrade_progress'], '</h2>
1963 2068
 					<ul>';
1964 2069
 
1965
-	foreach ($incontext['steps'] as $num => $step)
1966
-		echo '
2070
+	foreach ($incontext['steps'] as $num => $step) {
2071
+			echo '
1967 2072
 						<li class="', $num < $incontext['current_step'] ? 'stepdone' : ($num == $incontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>';
2073
+	}
1968 2074
 
1969 2075
 	echo '
1970 2076
 					</ul>
@@ -1990,20 +2096,23 @@  discard block
 block discarded – undo
1990 2096
 		echo '
1991 2097
 							<div class="floatright">';
1992 2098
 
1993
-		if (!empty($incontext['continue']))
1994
-			echo '
2099
+		if (!empty($incontext['continue'])) {
2100
+					echo '
1995 2101
 								<input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '" onclick="return submitThisOnce(this);" class="button">';
1996
-		if (!empty($incontext['skip']))
1997
-			echo '
2102
+		}
2103
+		if (!empty($incontext['skip'])) {
2104
+					echo '
1998 2105
 								<input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="return submitThisOnce(this);" class="button">';
2106
+		}
1999 2107
 		echo '
2000 2108
 							</div>';
2001 2109
 	}
2002 2110
 
2003 2111
 	// Show the closing form tag and other data only if not in the last step
2004
-	if (count($incontext['steps']) - 1 !== (int) $incontext['current_step'])
2005
-		echo '
2112
+	if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) {
2113
+			echo '
2006 2114
 						</form>';
2115
+	}
2007 2116
 
2008 2117
 	echo '
2009 2118
 					</div><!-- .panel -->
@@ -2036,13 +2145,15 @@  discard block
 block discarded – undo
2036 2145
 		</div>';
2037 2146
 
2038 2147
 	// Show the warnings, or not.
2039
-	if (template_warning_divs())
2040
-		echo '
2148
+	if (template_warning_divs()) {
2149
+			echo '
2041 2150
 		<h3>', $txt['install_all_lovely'], '</h3>';
2151
+	}
2042 2152
 
2043 2153
 	// Say we want the continue button!
2044
-	if (empty($incontext['error']))
2045
-		$incontext['continue'] = 1;
2154
+	if (empty($incontext['error'])) {
2155
+			$incontext['continue'] = 1;
2156
+	}
2046 2157
 
2047 2158
 	// For the latest version stuff.
2048 2159
 	echo '
@@ -2076,19 +2187,21 @@  discard block
 block discarded – undo
2076 2187
 	global $txt, $incontext;
2077 2188
 
2078 2189
 	// Errors are very serious..
2079
-	if (!empty($incontext['error']))
2080
-		echo '
2190
+	if (!empty($incontext['error'])) {
2191
+			echo '
2081 2192
 		<div class="errorbox">
2082 2193
 			<h3>', $txt['upgrade_critical_error'], '</h3>
2083 2194
 			', $incontext['error'], '
2084 2195
 		</div>';
2196
+	}
2085 2197
 	// A warning message?
2086
-	elseif (!empty($incontext['warning']))
2087
-		echo '
2198
+	elseif (!empty($incontext['warning'])) {
2199
+			echo '
2088 2200
 		<div class="errorbox">
2089 2201
 			<h3>', $txt['upgrade_warning'], '</h3>
2090 2202
 			', $incontext['warning'], '
2091 2203
 		</div>';
2204
+	}
2092 2205
 
2093 2206
 	return empty($incontext['error']) && empty($incontext['warning']);
2094 2207
 }
@@ -2104,26 +2217,29 @@  discard block
 block discarded – undo
2104 2217
 			<li>', $incontext['failed_files']), '</li>
2105 2218
 		</ul>';
2106 2219
 
2107
-	if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux')
2108
-		echo '
2220
+	if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') {
2221
+			echo '
2109 2222
 		<hr>
2110 2223
 		<p>', $txt['chmod_linux_info'], '</p>
2111 2224
 		<samp># chmod a+w ', implode(' ' . $incontext['detected_path'] . '/', $incontext['failed_files']), '</samp>';
2225
+	}
2112 2226
 
2113 2227
 	// This is serious!
2114
-	if (!template_warning_divs())
2115
-		return;
2228
+	if (!template_warning_divs()) {
2229
+			return;
2230
+	}
2116 2231
 
2117 2232
 	echo '
2118 2233
 		<hr>
2119 2234
 		<p>', $txt['ftp_setup_info'], '</p>';
2120 2235
 
2121
-	if (!empty($incontext['ftp_errors']))
2122
-		echo '
2236
+	if (!empty($incontext['ftp_errors'])) {
2237
+			echo '
2123 2238
 		<div class="error_message">
2124 2239
 			', $txt['error_ftp_no_connect'], '<br><br>
2125 2240
 			<code>', implode('<br>', $incontext['ftp_errors']), '</code>
2126 2241
 		</div>';
2242
+	}
2127 2243
 
2128 2244
 	echo '
2129 2245
 		<form action="', $incontext['form_url'], '" method="post">
@@ -2192,16 +2308,16 @@  discard block
 block discarded – undo
2192 2308
 			<dd>
2193 2309
 				<select name="db_type" id="db_type_input" onchange="toggleDBInput();">';
2194 2310
 
2195
-	foreach ($incontext['supported_databases'] as $key => $db)
2196
-			echo '
2311
+	foreach ($incontext['supported_databases'] as $key => $db) {
2312
+				echo '
2197 2313
 					<option value="', $key, '"', isset($_POST['db_type']) && $_POST['db_type'] == $key ? ' selected' : '', '>', $db['name'], '</option>';
2314
+	}
2198 2315
 
2199 2316
 	echo '
2200 2317
 				</select>
2201 2318
 				<div class="smalltext">', $txt['db_settings_type_info'], '</div>
2202 2319
 			</dd>';
2203
-	}
2204
-	else
2320
+	} else
2205 2321
 	{
2206 2322
 		echo '
2207 2323
 			<dd>
@@ -2376,9 +2492,10 @@  discard block
 block discarded – undo
2376 2492
 		<div class="red">', $txt['error_db_queries'], '</div>
2377 2493
 		<ul>';
2378 2494
 
2379
-		foreach ($incontext['failures'] as $line => $fail)
2380
-			echo '
2495
+		foreach ($incontext['failures'] as $line => $fail) {
2496
+					echo '
2381 2497
 			<li><strong>', $txt['error_db_queries_line'], $line + 1, ':</strong> ', nl2br(htmlspecialchars($fail)), '</li>';
2498
+		}
2382 2499
 
2383 2500
 		echo '
2384 2501
 		</ul>';
@@ -2443,15 +2560,16 @@  discard block
 block discarded – undo
2443 2560
 			</dd>
2444 2561
 		</dl>';
2445 2562
 
2446
-	if ($incontext['require_db_confirm'])
2447
-		echo '
2563
+	if ($incontext['require_db_confirm']) {
2564
+			echo '
2448 2565
 		<h2>', $txt['user_settings_database'], '</h2>
2449 2566
 		<p>', $txt['user_settings_database_info'], '</p>
2450 2567
 
2451 2568
 		<div class="lefttext">
2452 2569
 			<input type="password" name="password3" size="30">
2453 2570
 		</div>';
2454
-}
2571
+	}
2572
+	}
2455 2573
 
2456 2574
 // Tell them it's done, and to delete.
2457 2575
 function template_delete_install()
@@ -2464,13 +2582,14 @@  discard block
 block discarded – undo
2464 2582
 	template_warning_divs();
2465 2583
 
2466 2584
 	// Install directory still writable?
2467
-	if ($incontext['dir_still_writable'])
2468
-		echo '
2585
+	if ($incontext['dir_still_writable']) {
2586
+			echo '
2469 2587
 		<p><em>', $txt['still_writable'], '</em></p>';
2588
+	}
2470 2589
 
2471 2590
 	// Don't show the box if it's like 99% sure it won't work :P.
2472
-	if ($incontext['probably_delete_install'])
2473
-		echo '
2591
+	if ($incontext['probably_delete_install']) {
2592
+			echo '
2474 2593
 		<label>
2475 2594
 			<input type="checkbox" id="delete_self" onclick="doTheDelete();">
2476 2595
 			<strong>', $txt['delete_installer'], !isset($_SESSION['installer_temp_ftp']) ? ' ' . $txt['delete_installer_maybe'] : '', '</strong>
@@ -2486,6 +2605,7 @@  discard block
 block discarded – undo
2486 2605
 				theCheck.disabled = true;
2487 2606
 			}
2488 2607
 		</script>';
2608
+	}
2489 2609
 
2490 2610
 	echo '
2491 2611
 		<p>', sprintf($txt['go_to_your_forum'], $boardurl . '/index.php'), '</p>
Please login to merge, or discard this patch.
Themes/default/Packages.template.php 1 patch
Braces   +175 added lines, -128 removed lines patch added patch discarded remove patch
@@ -31,25 +31,27 @@  discard block
 block discarded – undo
31 31
 		</div>
32 32
 		<div class="information">';
33 33
 
34
-	if ($context['is_installed'])
35
-		echo '
34
+	if ($context['is_installed']) {
35
+			echo '
36 36
 			<strong>', $txt['package_installed_warning1'], '</strong><br>
37 37
 			<br>
38 38
 			', $txt['package_installed_warning2'], '<br>
39 39
 			<br>';
40
+	}
40 41
 
41 42
 	echo $txt['package_installed_warning3'], '
42 43
 		</div>
43 44
 		<br>';
44 45
 
45 46
 	// Do errors exist in the install? If so light them up like a christmas tree.
46
-	if ($context['has_failure'])
47
-		echo '
47
+	if ($context['has_failure']) {
48
+			echo '
48 49
 		<div class="errorbox">
49 50
 			', sprintf($txt['package_will_fail_title'], $txt['package_' . ($context['uninstalling'] ? 'uninstall' : 'install')]), '<br>
50 51
 			', sprintf($txt['package_will_fail_warning'], $txt['package_' . ($context['uninstalling'] ? 'uninstall' : 'install')]),
51 52
 			!empty($context['failure_details']) ? '<br><br><strong>' . $context['failure_details'] . '</strong>' : '', '
52 53
 		</div>';
54
+	}
53 55
 
54 56
 	// Display the package readme if one exists
55 57
 	if (isset($context['package_readme']))
@@ -63,9 +65,10 @@  discard block
 block discarded – undo
63 65
 			<span class="floatright">', $txt['package_available_readme_language'], '
64 66
 				<select name="readme_language" id="readme_language" onchange="if (this.options[this.selectedIndex].value) window.location.href = smf_prepareScriptUrl(smf_scripturl + \'', '?action=admin;area=packages;sa=', $context['uninstalling'] ? 'uninstall' : 'install', ';package=', $context['filename'], ';readme=\' + this.options[this.selectedIndex].value + \';license=\' + get_selected(\'license_language\'));">';
65 67
 
66
-		foreach ($context['readmes'] as $a => $b)
67
-			echo '
68
+		foreach ($context['readmes'] as $a => $b) {
69
+					echo '
68 70
 					<option value="', $b, '"', $a === 'selected' ? ' selected' : '', '>', $b == 'default' ? $txt['package_readme_default'] : ucfirst($b), '</option>';
71
+		}
69 72
 
70 73
 		echo '
71 74
 				</select>
@@ -86,9 +89,10 @@  discard block
 block discarded – undo
86 89
 			<span class="floatright">', $txt['package_available_license_language'], '
87 90
 				<select name="license_language" id="license_language" onchange="if (this.options[this.selectedIndex].value) window.location.href = smf_prepareScriptUrl(smf_scripturl + \'', '?action=admin;area=packages;sa=install', ';package=', $context['filename'], ';license=\' + this.options[this.selectedIndex].value + \';readme=\' + get_selected(\'readme_language\'));">';
88 91
 
89
-		foreach ($context['licenses'] as $a => $b)
90
-			echo '
92
+		foreach ($context['licenses'] as $a => $b) {
93
+					echo '
91 94
 					<option value="', $b, '"', $a === 'selected' ? ' selected' : '', '>', $b == 'default' ? $txt['package_license_default'] : ucfirst($b), '</option>';
95
+		}
92 96
 		echo '
93 97
 				</select>
94 98
 			</span>
@@ -115,9 +119,10 @@  discard block
 block discarded – undo
115 119
 					', $txt['package_db_uninstall_actions'], ':
116 120
 					<ul>';
117 121
 
118
-		foreach ($context['database_changes'] as $change)
119
-			echo '
122
+		foreach ($context['database_changes'] as $change) {
123
+					echo '
120 124
 						<li>', $change, '</li>';
125
+		}
121 126
 
122 127
 		echo '
123 128
 					</ul>
@@ -128,14 +133,14 @@  discard block
 block discarded – undo
128 133
 	echo '
129 134
 			<div class="information">';
130 135
 
131
-	if (empty($context['actions']) && empty($context['database_changes']))
132
-		echo '
136
+	if (empty($context['actions']) && empty($context['database_changes'])) {
137
+			echo '
133 138
 				<br>
134 139
 				<div class="errorbox">
135 140
 					', $txt['corrupt_compatible'], '
136 141
 				</div>
137 142
 			</div><!-- .information -->';
138
-	else
143
+	} else
139 144
 	{
140 145
 		echo '
141 146
 				', $txt['perform_actions'], '
@@ -239,9 +244,10 @@  discard block
 block discarded – undo
239 244
 						<td></td>
240 245
 						<td>';
241 246
 
242
-				if (!empty($context['themes_locked']))
243
-					echo '
247
+				if (!empty($context['themes_locked'])) {
248
+									echo '
244 249
 							<input type="hidden" name="custom_theme[]" value="', $id, '">';
250
+				}
245 251
 				echo '
246 252
 							<input type="checkbox" name="custom_theme[]" id="custom_theme_', $id, '" value="', $id, '" onclick="', (!empty($theme['has_failure']) ? 'if (this.form.custom_theme_' . $id . '.checked && !confirm(\'' . $txt['package_theme_failure_warning'] . '\')) return false;' : ''), 'invertAll(this, this.form, \'dummy_theme_', $id, '\', true);"', !empty($context['themes_locked']) ? ' disabled checked' : '', '>
247 253
 						</td>
@@ -307,21 +313,23 @@  discard block
 block discarded – undo
307 313
 	}
308 314
 
309 315
 	// Are we effectively ready to install?
310
-	if (!$context['ftp_needed'] && (!empty($context['actions']) || !empty($context['database_changes'])))
311
-		echo '
316
+	if (!$context['ftp_needed'] && (!empty($context['actions']) || !empty($context['database_changes']))) {
317
+			echo '
312 318
 			<div class="righttext padding">
313 319
 				<input type="submit" value="', $context['uninstalling'] ? $txt['package_uninstall_now'] : $txt['package_install_now'], '" onclick="return ', !empty($context['has_failure']) ? '(submitThisOnce(this) &amp;&amp; confirm(\'' . ($context['uninstalling'] ? $txt['package_will_fail_popup_uninstall'] : $txt['package_will_fail_popup']) . '\'))' : 'submitThisOnce(this)', ';" class="button">
314 320
 			</div>';
321
+	}
315 322
 
316 323
 	// If we need ftp information then demand it!
317
-	elseif ($context['ftp_needed'])
318
-		echo '
324
+	elseif ($context['ftp_needed']) {
325
+			echo '
319 326
 			<div class="cat_bar">
320 327
 				<h3 class="catbg">', $txt['package_ftp_necessary'], '</h3>
321 328
 			</div>
322 329
 			<div>
323 330
 				', template_control_chmod(), '
324 331
 			</div>';
332
+	}
325 333
 
326 334
 	echo '
327 335
 
@@ -338,8 +346,8 @@  discard block
 block discarded – undo
338 346
 	// Operations.
339 347
 	if (!empty($js_operations))
340 348
 	{
341
-		foreach ($js_operations as $key => $operation)
342
-			echo '
349
+		foreach ($js_operations as $key => $operation) {
350
+					echo '
343 351
 		aOperationElements[', $key, '] = new smc_Toggle({
344 352
 			bToggleEnabled: true,
345 353
 			bNoAnimate: true,
@@ -357,6 +365,7 @@  discard block
 block discarded – undo
357 365
 				}
358 366
 			]
359 367
 		});';
368
+		}
360 369
 	}
361 370
 
362 371
 	echo '
@@ -378,14 +387,15 @@  discard block
 block discarded – undo
378 387
 	</script>';
379 388
 
380 389
 	// And a bit more for database changes.
381
-	if (!empty($context['database_changes']))
382
-		echo '
390
+	if (!empty($context['database_changes'])) {
391
+			echo '
383 392
 	<script>
384 393
 		var database_changes_area = document.getElementById(\'db_changes_div\');
385 394
 		var db_vis = false;
386 395
 		database_changes_area.style.display = "none";
387 396
 	</script>';
388
-}
397
+	}
398
+	}
389 399
 
390 400
 /**
391 401
  * Extract package contents
@@ -394,8 +404,8 @@  discard block
 block discarded – undo
394 404
 {
395 405
 	global $context, $txt, $scripturl;
396 406
 
397
-	if (!empty($context['redirect_url']))
398
-		echo '
407
+	if (!empty($context['redirect_url'])) {
408
+			echo '
399 409
 	<script>
400 410
 		setTimeout("doRedirect();", ', empty($context['redirect_timeout']) ? '5000' : $context['redirect_timeout'], ');
401 411
 
@@ -404,52 +414,51 @@  discard block
 block discarded – undo
404 414
 			window.location = "', $context['redirect_url'], '";
405 415
 		}
406 416
 	</script>';
417
+	}
407 418
 
408 419
 	echo '
409 420
 	<div id="admincenter">';
410 421
 
411
-	if (empty($context['redirect_url']))
412
-		echo '
422
+	if (empty($context['redirect_url'])) {
423
+			echo '
413 424
 		<div class="cat_bar">
414 425
 			<h3 class="catbg">', $context['uninstalling'] ? $txt['uninstall'] : $txt['extracting'], '</h3>
415 426
 		</div>
416 427
 		<div class="information">', $txt['package_installed_extract'], '</div>';
417
-	else
418
-		echo '
428
+	} else {
429
+			echo '
419 430
 		<div class="cat_bar">
420 431
 			<h3 class="catbg">', $txt['package_installed_redirecting'], '</h3>
421 432
 		</div>';
433
+	}
422 434
 
423 435
 	echo '
424 436
 		<div class="windowbg">';
425 437
 
426 438
 	// If we are going to redirect we have a slightly different agenda.
427
-	if (!empty($context['redirect_url']))
428
-		echo '
439
+	if (!empty($context['redirect_url'])) {
440
+			echo '
429 441
 			', $context['redirect_text'], '<br><br>
430 442
 			<a href="', $context['redirect_url'], '">', $txt['package_installed_redirect_go_now'], '</a> | <a href="', $scripturl, '?action=admin;area=packages;sa=browse">', $txt['package_installed_redirect_cancel'], '</a>';
431
-
432
-	elseif ($context['uninstalling'])
433
-		echo '
443
+	} elseif ($context['uninstalling']) {
444
+			echo '
434 445
 			', $txt['package_uninstall_done'];
435
-
436
-	elseif ($context['install_finished'])
446
+	} elseif ($context['install_finished'])
437 447
 	{
438
-		if ($context['extract_type'] == 'avatar')
439
-			echo '
448
+		if ($context['extract_type'] == 'avatar') {
449
+					echo '
440 450
 			', $txt['avatars_extracted'];
441
-
442
-		elseif ($context['extract_type'] == 'language')
443
-			echo '
451
+		} elseif ($context['extract_type'] == 'language') {
452
+					echo '
444 453
 			', $txt['language_extracted'];
445
-
446
-		else
447
-			echo '
454
+		} else {
455
+					echo '
448 456
 			', $txt['package_installed_done'];
449
-	}
450
-	else
451
-		echo '
457
+		}
458
+	} else {
459
+			echo '
452 460
 			', $txt['corrupt_compatible'];
461
+	}
453 462
 
454 463
 	echo '
455 464
 		</div><!-- .windowbg -->';
@@ -483,9 +492,10 @@  discard block
 block discarded – undo
483 492
 		<div class="windowbg">
484 493
 			<ol>';
485 494
 
486
-	foreach ($context['files'] as $fileinfo)
487
-		echo '
495
+	foreach ($context['files'] as $fileinfo) {
496
+			echo '
488 497
 				<li><a href="', $scripturl, '?action=admin;area=packages;sa=examine;package=', $context['filename'], ';file=', $fileinfo['filename'], '" title="', $txt['view'], '">', $fileinfo['filename'], '</a> (', $fileinfo['size'], ' ', $txt['package_bytes'], ')</li>';
498
+	}
489 499
 
490 500
 	echo '
491 501
 			</ol>
@@ -549,9 +559,10 @@  discard block
 block discarded – undo
549 559
 			</script>
550 560
 			<div id="yourVersion" style="display:none">', $context['forum_version'], '</div>';
551 561
 
552
-	if (empty($modSettings['disable_smf_js']))
553
-		echo '
562
+	if (empty($modSettings['disable_smf_js'])) {
563
+			echo '
554 564
 			<script src="', $scripturl, '?action=viewsmfile;filename=latest-news.js"></script>';
565
+	}
555 566
 
556 567
 	// This sets the announcements and current versions themselves ;).
557 568
 	echo '
@@ -589,12 +600,13 @@  discard block
 block discarded – undo
589 600
 		}
590 601
 	}
591 602
 
592
-	if (!$mods_available)
593
-		echo '
603
+	if (!$mods_available) {
604
+			echo '
594 605
 		<div class="noticebox">', $txt['no_packages'], '</div>';
595
-	else
596
-		echo '
606
+	} else {
607
+			echo '
597 608
 		<br>';
609
+	}
598 610
 
599 611
 	// The advanced (emulation) box, collapsed by default
600 612
 	echo '
@@ -621,9 +633,10 @@  discard block
 block discarded – undo
621 633
 							<a id="revert" name="revert"></a>
622 634
 							<select name="version_emulate" id="ve">';
623 635
 
624
-	foreach ($context['emulation_versions'] as $version)
625
-		echo '
636
+	foreach ($context['emulation_versions'] as $version) {
637
+			echo '
626 638
 								<option value="', $version, '"', ($version == $context['selected_version'] ? ' selected="selected"' : ''), '>', $version, '</option>';
639
+	}
627 640
 
628 641
 	echo '
629 642
 							</select>
@@ -679,11 +692,12 @@  discard block
 block discarded – undo
679 692
 {
680 693
 	global $context, $txt, $scripturl;
681 694
 
682
-	if (!empty($context['package_ftp']['error']))
683
-		echo '
695
+	if (!empty($context['package_ftp']['error'])) {
696
+			echo '
684 697
 	<div class="errorbox">
685 698
 		<pre>', $context['package_ftp']['error'], '</pre>
686 699
 	</div>';
700
+	}
687 701
 
688 702
 	echo '
689 703
 	<div id="admin_form_wrapper">
@@ -766,13 +780,14 @@  discard block
 block discarded – undo
766 780
 					<legend>' . $txt['package_servers'] . '</legend>
767 781
 					<ul class="package_servers">';
768 782
 
769
-	foreach ($context['servers'] as $server)
770
-		echo '
783
+	foreach ($context['servers'] as $server) {
784
+			echo '
771 785
 						<li class="flow_auto">
772 786
 							<span class="floatleft">' . $server['name'] . '</span>
773 787
 							<span class="package_server floatright"><a href="' . $scripturl . '?action=admin;area=packages;get;sa=remove;server=' . $server['id'] . ';', $context['session_var'], '=', $context['session_id'], '">[ ' . $txt['delete'] . ' ]</a></span>
774 788
 							<span class="package_server floatright"><a href="' . $scripturl . '?action=admin;area=packages;get;sa=browse;server=' . $server['id'] . '">[ ' . $txt['package_browse'] . ' ]</a></span>
775 789
 						</li>';
790
+	}
776 791
 	echo '
777 792
 					</ul>
778 793
 				</fieldset>
@@ -859,11 +874,12 @@  discard block
 block discarded – undo
859 874
 		<div class="windowbg">';
860 875
 
861 876
 	// No packages, as yet.
862
-	if (empty($context['package_list']))
863
-		echo '
877
+	if (empty($context['package_list'])) {
878
+			echo '
864 879
 			<ul>
865 880
 				<li>', $txt['no_packages'], '</li>
866 881
 			</ul>';
882
+	}
867 883
 
868 884
 	// List out the packages...
869 885
 	else
@@ -877,11 +893,12 @@  discard block
 block discarded – undo
877 893
 				<li>
878 894
 					<strong><span id="ps_img_', $i, '" class="toggle_up" alt="*" style="display: none;"></span> ', $packageSection['title'], '</strong>';
879 895
 
880
-			if (!empty($packageSection['text']))
881
-				echo '
896
+			if (!empty($packageSection['text'])) {
897
+							echo '
882 898
 					<div class="sub_bar">
883 899
 						<h3 class="subbg">', $packageSection['text'], '</h3>
884 900
 					</div>';
901
+			}
885 902
 
886 903
 			echo '
887 904
 					<', $context['list_type'], ' id="package_section_', $i, '" class="packages">';
@@ -892,24 +909,28 @@  discard block
 block discarded – undo
892 909
 						<li>';
893 910
 
894 911
 				// Textual message. Could be empty just for a blank line...
895
-				if ($package['is_text'])
896
-					echo '
912
+				if ($package['is_text']) {
913
+									echo '
897 914
 							', empty($package['name']) ? '&nbsp;' : $package['name'];
915
+				}
898 916
 
899 917
 				// This is supposed to be a rule..
900
-				elseif ($package['is_line'])
901
-					echo '
918
+				elseif ($package['is_line']) {
919
+									echo '
902 920
 							<hr>';
921
+				}
903 922
 
904 923
 				// A remote link.
905
-				elseif ($package['is_remote'])
906
-					echo '
924
+				elseif ($package['is_remote']) {
925
+									echo '
907 926
 							<strong>', $package['link'], '</strong>';
927
+				}
908 928
 
909 929
 				// A title?
910
-				elseif ($package['is_heading'] || $package['is_title'])
911
-					echo '
930
+				elseif ($package['is_heading'] || $package['is_title']) {
931
+									echo '
912 932
 							<strong>', $package['name'], '</strong>';
933
+				}
913 934
 
914 935
 				// Otherwise, it's a package.
915 936
 				else
@@ -920,32 +941,36 @@  discard block
 block discarded – undo
920 941
 						<ul id="package_section_', $i, '_pkg_', $id, '" class="package_section">';
921 942
 
922 943
 					// Show the mod type?
923
-					if ($package['type'] != '')
924
-						echo '
944
+					if ($package['type'] != '') {
945
+											echo '
925 946
 							<li class="package_section">
926 947
 								', $txt['package_type'], ':&nbsp; ', $smcFunc['ucwords']($smcFunc['strtolower']($package['type'])), '
927 948
 							</li>';
949
+					}
928 950
 
929 951
 					// Show the version number?
930
-					if ($package['version'] != '')
931
-						echo '
952
+					if ($package['version'] != '') {
953
+											echo '
932 954
 							<li class="package_section">
933 955
 								', $txt['mod_version'], ':&nbsp; ', $package['version'], '
934 956
 							</li>';
957
+					}
935 958
 
936 959
 					// How 'bout the author?
937
-					if (!empty($package['author']) && $package['author']['name'] != '' && isset($package['author']['link']))
938
-						echo '
960
+					if (!empty($package['author']) && $package['author']['name'] != '' && isset($package['author']['link'])) {
961
+											echo '
939 962
 							<li class="package_section">
940 963
 								', $txt['mod_author'], ':&nbsp; ', $package['author']['link'], '
941 964
 							</li>';
965
+					}
942 966
 
943 967
 					// The homepage...
944
-					if ($package['author']['website']['link'] != '')
945
-						echo '
968
+					if ($package['author']['website']['link'] != '') {
969
+											echo '
946 970
 							<li class="package_section">
947 971
 								', $txt['author_website'], ':&nbsp; ', $package['author']['website']['link'], '
948 972
 							</li>';
973
+					}
949 974
 
950 975
 					// Description: bleh bleh!
951 976
 					// Location of file: http://someplace/.
@@ -1004,8 +1029,8 @@  discard block
 block discarded – undo
1004 1029
 
1005 1030
 			foreach ($ps['items'] as $id => $package)
1006 1031
 			{
1007
-				if (!$package['is_text'] && !$package['is_line'] && !$package['is_remote'])
1008
-					echo '
1032
+				if (!$package['is_text'] && !$package['is_line'] && !$package['is_remote']) {
1033
+									echo '
1009 1034
 		var oPackageToggle_', $section, '_pkg_', $id, ' = new smc_Toggle({
1010 1035
 			bToggleEnabled: true,
1011 1036
 			bCurrentlyCollapsed: true,
@@ -1020,6 +1045,7 @@  discard block
 block discarded – undo
1020 1045
 				}
1021 1046
 			]
1022 1047
 		});';
1048
+				}
1023 1049
 			}
1024 1050
 		}
1025 1051
 
@@ -1064,9 +1090,10 @@  discard block
 block discarded – undo
1064 1090
 {
1065 1091
 	global $context, $txt, $scripturl;
1066 1092
 
1067
-	if (!empty($context['saved_successful']))
1068
-		echo '
1093
+	if (!empty($context['saved_successful'])) {
1094
+			echo '
1069 1095
 	<div class="infobox">', $txt['settings_saved'], '</div>';
1096
+	}
1070 1097
 
1071 1098
 	echo '
1072 1099
 	<div id="admincenter">
@@ -1128,8 +1155,9 @@  discard block
 block discarded – undo
1128 1155
 	global $context, $txt;
1129 1156
 
1130 1157
 	// Nothing to do? Brilliant!
1131
-	if (empty($context['package_ftp']))
1132
-		return false;
1158
+	if (empty($context['package_ftp'])) {
1159
+			return false;
1160
+	}
1133 1161
 
1134 1162
 	if (empty($context['package_ftp']['form_elements_only']))
1135 1163
 	{
@@ -1139,19 +1167,21 @@  discard block
 block discarded – undo
1139 1167
 					', $txt['package_ftp_why_file_list'], '
1140 1168
 					<ul style="display: inline;">';
1141 1169
 
1142
-		if (!empty($context['notwritable_files']))
1143
-			foreach ($context['notwritable_files'] as $file)
1170
+		if (!empty($context['notwritable_files'])) {
1171
+					foreach ($context['notwritable_files'] as $file)
1144 1172
 				echo '
1145 1173
 						<li>', $file, '</li>';
1174
+		}
1146 1175
 
1147 1176
 		echo '
1148 1177
 					</ul>';
1149 1178
 
1150
-		if (!$context['server']['is_windows'])
1151
-			echo '
1179
+		if (!$context['server']['is_windows']) {
1180
+					echo '
1152 1181
 					<hr>
1153 1182
 					', $txt['package_chmod_linux'], '<br>
1154 1183
 					<samp># chmod a+w ', implode(' ', $context['notwritable_files']), '</samp>';
1184
+		}
1155 1185
 
1156 1186
 		echo '
1157 1187
 				</div><!-- #need_writable_list -->';
@@ -1164,9 +1194,10 @@  discard block
 block discarded – undo
1164 1194
 					</div>
1165 1195
 				</div>';
1166 1196
 
1167
-	if (!empty($context['package_ftp']['destination']))
1168
-		echo '
1197
+	if (!empty($context['package_ftp']['destination'])) {
1198
+			echo '
1169 1199
 				<form action="', $context['package_ftp']['destination'], '" method="post" accept-charset="', $context['character_set'], '">';
1200
+	}
1170 1201
 
1171 1202
 	echo '
1172 1203
 					<fieldset>
@@ -1200,24 +1231,27 @@  discard block
 block discarded – undo
1200 1231
 					</dl>
1201 1232
 					</fieldset>';
1202 1233
 
1203
-	if (empty($context['package_ftp']['form_elements_only']))
1204
-		echo '
1234
+	if (empty($context['package_ftp']['form_elements_only'])) {
1235
+			echo '
1205 1236
 					<div class="righttext" style="margin: 1ex;">
1206 1237
 						<span id="test_ftp_placeholder_full"></span>
1207 1238
 						<input type="submit" value="', $txt['package_proceed'], '" class="button">
1208 1239
 					</div>';
1240
+	}
1209 1241
 
1210
-	if (!empty($context['package_ftp']['destination']))
1211
-		echo '
1242
+	if (!empty($context['package_ftp']['destination'])) {
1243
+			echo '
1212 1244
 					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1213 1245
 				</form>';
1246
+	}
1214 1247
 
1215 1248
 	// Hide the details of the list.
1216
-	if (empty($context['package_ftp']['form_elements_only']))
1217
-		echo '
1249
+	if (empty($context['package_ftp']['form_elements_only'])) {
1250
+			echo '
1218 1251
 				<script>
1219 1252
 					document.getElementById(\'need_writable_list\').style.display = \'none\';
1220 1253
 				</script>';
1254
+	}
1221 1255
 
1222 1256
 	// Quick generate the test button.
1223 1257
 	echo '
@@ -1574,9 +1608,10 @@  discard block
 block discarded – undo
1574 1608
 					<td width="30%">
1575 1609
 						<strong>';
1576 1610
 
1577
-		if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive'))
1578
-			echo '
1611
+		if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) {
1612
+					echo '
1579 1613
 							<span class="generic_icons folder"></span>';
1614
+		}
1580 1615
 
1581 1616
 		echo '
1582 1617
 							', $name, '
@@ -1603,8 +1638,9 @@  discard block
 block discarded – undo
1603 1638
 					</td>
1604 1639
 				</tr>';
1605 1640
 
1606
-		if (!empty($dir['contents']))
1607
-			template_permission_show_contents($name, $dir['contents'], 1);
1641
+		if (!empty($dir['contents'])) {
1642
+					template_permission_show_contents($name, $dir['contents'], 1);
1643
+		}
1608 1644
 	}
1609 1645
 
1610 1646
 	echo '
@@ -1640,13 +1676,14 @@  discard block
 block discarded – undo
1640 1676
 			</fieldset>';
1641 1677
 
1642 1678
 	// Likely to need FTP?
1643
-	if (empty($context['ftp_connected']))
1644
-		echo '
1679
+	if (empty($context['ftp_connected'])) {
1680
+			echo '
1645 1681
 			<p>
1646 1682
 				', $txt['package_file_perms_ftp_details'], ':
1647 1683
 			</p>
1648 1684
 			', template_control_chmod(), '
1649 1685
 			<div class="noticebox">', $txt['package_file_perms_ftp_retain'], '</div>';
1686
+	}
1650 1687
 
1651 1688
 	echo '
1652 1689
 			<span id="test_ftp_placeholder_full"></span>
@@ -1655,9 +1692,10 @@  discard block
 block discarded – undo
1655 1692
 		</div><!-- .windowbg -->';
1656 1693
 
1657 1694
 	// Any looks fors we've already done?
1658
-	foreach ($context['look_for'] as $path)
1659
-		echo '
1695
+	foreach ($context['look_for'] as $path) {
1696
+			echo '
1660 1697
 		<input type="hidden" name="back_look[]" value="', $path, '">';
1698
+	}
1661 1699
 
1662 1700
 	echo '
1663 1701
 	</form>
@@ -1699,9 +1737,10 @@  discard block
 block discarded – undo
1699 1737
 					<td class="smalltext" width="30%">' . str_repeat('&nbsp;', $level * 5), '
1700 1738
 					', (!empty($dir['type']) && $dir['type'] == 'dir_recursive') || !empty($dir['list_contents']) ? '<a id="link_' . $cur_ident . '" href="' . $scripturl . '?action=admin;area=packages;sa=perms;find=' . base64_encode($ident . '/' . $name) . ';back_look=' . $context['back_look_data'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '#fol_' . $cur_ident . '" onclick="return expandFolder(\'' . $cur_ident . '\', \'' . addcslashes($ident . '/' . $name, "'\\") . '\');">' : '';
1701 1739
 
1702
-			if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive'))
1703
-				echo '
1740
+			if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) {
1741
+							echo '
1704 1742
 						<span class="generic_icons folder"></span>';
1743
+			}
1705 1744
 
1706 1745
 			echo '
1707 1746
 						', $name, '
@@ -1719,34 +1758,38 @@  discard block
 block discarded – undo
1719 1758
 				</tr>
1720 1759
 				<tr id="insert_div_loc_' . $cur_ident . '" style="display: none;"><td></td></tr>';
1721 1760
 
1722
-			if (!empty($dir['contents']))
1723
-				template_permission_show_contents($ident . '/' . $name, $dir['contents'], $level + 1, !empty($dir['more_files']));
1761
+			if (!empty($dir['contents'])) {
1762
+							template_permission_show_contents($ident . '/' . $name, $dir['contents'], $level + 1, !empty($dir['more_files']));
1763
+			}
1724 1764
 		}
1725 1765
 	}
1726 1766
 
1727 1767
 	// We have more files to show?
1728
-	if ($has_more)
1729
-		echo '
1768
+	if ($has_more) {
1769
+			echo '
1730 1770
 				<tr class="windowbg" id="content_', $js_ident, '_more">
1731 1771
 					<td class="smalltext" width="40%">' . str_repeat('&nbsp;', $level * 5), '
1732 1772
 						&#171; <a href="' . $scripturl . '?action=admin;area=packages;sa=perms;find=' . base64_encode($ident) . ';fileoffset=', ($context['file_offset'] + $context['file_limit']), ';' . $context['session_var'] . '=' . $context['session_id'] . '#fol_' . preg_replace('~[^A-Za-z0-9_\-=:]~', ':-:', $ident) . '">', $txt['package_file_perms_more_files'], '</a> &#187;
1733 1773
 					</td>
1734 1774
 					<td colspan="6"></td>
1735 1775
 				</tr>';
1776
+	}
1736 1777
 
1737 1778
 	if ($drawn_div)
1738 1779
 	{
1739 1780
 		// Hide anything too far down the tree.
1740 1781
 		$isFound = false;
1741
-		foreach ($context['look_for'] as $tree)
1742
-			if (substr($tree, 0, strlen($ident)) == $ident)
1782
+		foreach ($context['look_for'] as $tree) {
1783
+					if (substr($tree, 0, strlen($ident)) == $ident)
1743 1784
 				$isFound = true;
1785
+		}
1744 1786
 
1745
-		if ($level > 1 && !$isFound)
1746
-			echo '
1787
+		if ($level > 1 && !$isFound) {
1788
+					echo '
1747 1789
 		<script>
1748 1790
 			expandFolder(\'', $js_ident, '\', \'\');
1749 1791
 		</script>';
1792
+		}
1750 1793
 	}
1751 1794
 }
1752 1795
 
@@ -1766,11 +1809,12 @@  discard block
 block discarded – undo
1766 1809
 				<h3 class="catbg">', $txt['package_file_perms_applying'], '</h3>
1767 1810
 			</div>';
1768 1811
 
1769
-	if (!empty($context['skip_ftp']))
1770
-		echo '
1812
+	if (!empty($context['skip_ftp'])) {
1813
+			echo '
1771 1814
 			<div class="errorbox">
1772 1815
 				', $txt['package_file_perms_skipping_ftp'], '
1773 1816
 			</div>';
1817
+	}
1774 1818
 
1775 1819
 	// How many have we done?
1776 1820
 	$remaining_items = count($context['method'] == 'individual' ? $context['to_process'] : $context['directory_list']);
@@ -1808,28 +1852,31 @@  discard block
 block discarded – undo
1808 1852
 				<br>';
1809 1853
 
1810 1854
 	// Put out the right hidden data.
1811
-	if ($context['method'] == 'individual')
1812
-		echo '
1855
+	if ($context['method'] == 'individual') {
1856
+			echo '
1813 1857
 				<input type="hidden" name="custom_value" value="', $context['custom_value'], '">
1814 1858
 				<input type="hidden" name="totalItems" value="', $context['total_items'], '">
1815 1859
 				<input type="hidden" name="toProcess" value="', $context['to_process_encode'], '">';
1816
-	else
1817
-		echo '
1860
+	} else {
1861
+			echo '
1818 1862
 				<input type="hidden" name="predefined" value="', $context['predefined_type'], '">
1819 1863
 				<input type="hidden" name="fileOffset" value="', $context['file_offset'], '">
1820 1864
 				<input type="hidden" name="totalItems" value="', $context['total_items'], '">
1821 1865
 				<input type="hidden" name="dirList" value="', $context['directory_list_encode'], '">
1822 1866
 				<input type="hidden" name="specialFiles" value="', $context['special_files_encode'], '">';
1867
+	}
1823 1868
 
1824 1869
 	// Are we not using FTP for whatever reason.
1825
-	if (!empty($context['skip_ftp']))
1826
-		echo '
1870
+	if (!empty($context['skip_ftp'])) {
1871
+			echo '
1827 1872
 				<input type="hidden" name="skip_ftp" value="1">';
1873
+	}
1828 1874
 
1829 1875
 	// Retain state.
1830
-	foreach ($context['back_look_data'] as $path)
1831
-		echo '
1876
+	foreach ($context['back_look_data'] as $path) {
1877
+			echo '
1832 1878
 				<input type="hidden" name="back_look[]" value="', $path, '">';
1879
+	}
1833 1880
 
1834 1881
 	echo '
1835 1882
 				<input type="hidden" name="method" value="', $context['method'], '">
Please login to merge, or discard this patch.
Sources/Load.php 1 patch
Braces   +792 added lines, -597 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
  * Load the $modSettings array.
@@ -25,13 +26,14 @@  discard block
 block discarded – undo
25 26
 	global $cache_enable, $sourcedir, $context;
26 27
 
27 28
 	// Most database systems have not set UTF-8 as their default input charset.
28
-	if (!empty($db_character_set))
29
-		$smcFunc['db_query']('', '
29
+	if (!empty($db_character_set)) {
30
+			$smcFunc['db_query']('', '
30 31
 			SET NAMES {string:db_character_set}',
31 32
 			array(
32 33
 				'db_character_set' => $db_character_set,
33 34
 			)
34 35
 		);
36
+	}
35 37
 
36 38
 	// We need some caching support, maybe.
37 39
 	loadCacheAccelerator();
@@ -46,28 +48,36 @@  discard block
 block discarded – undo
46 48
 			)
47 49
 		);
48 50
 		$modSettings = array();
49
-		if (!$request)
50
-			display_db_error();
51
-		while ($row = $smcFunc['db_fetch_row']($request))
52
-			$modSettings[$row[0]] = $row[1];
51
+		if (!$request) {
52
+					display_db_error();
53
+		}
54
+		while ($row = $smcFunc['db_fetch_row']($request)) {
55
+					$modSettings[$row[0]] = $row[1];
56
+		}
53 57
 		$smcFunc['db_free_result']($request);
54 58
 
55 59
 		// Do a few things to protect against missing settings or settings with invalid values...
56
-		if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999)
57
-			$modSettings['defaultMaxTopics'] = 20;
58
-		if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999)
59
-			$modSettings['defaultMaxMessages'] = 15;
60
-		if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999)
61
-			$modSettings['defaultMaxMembers'] = 30;
62
-		if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999)
63
-			$modSettings['defaultMaxListItems'] = 15;
60
+		if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) {
61
+					$modSettings['defaultMaxTopics'] = 20;
62
+		}
63
+		if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) {
64
+					$modSettings['defaultMaxMessages'] = 15;
65
+		}
66
+		if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) {
67
+					$modSettings['defaultMaxMembers'] = 30;
68
+		}
69
+		if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999) {
70
+					$modSettings['defaultMaxListItems'] = 15;
71
+		}
64 72
 
65 73
 		// We excpiclity do not use $smcFunc['json_decode'] here yet, as $smcFunc is not fully loaded.
66
-		if (!is_array($modSettings['attachmentUploadDir']))
67
-			$modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true);
74
+		if (!is_array($modSettings['attachmentUploadDir'])) {
75
+					$modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true);
76
+		}
68 77
 
69
-		if (!empty($cache_enable))
70
-			cache_put_data('modSettings', $modSettings, 90);
78
+		if (!empty($cache_enable)) {
79
+					cache_put_data('modSettings', $modSettings, 90);
80
+		}
71 81
 	}
72 82
 
73 83
 	$modSettings['cache_enable'] = $cache_enable;
@@ -87,8 +97,9 @@  discard block
 block discarded – undo
87 97
 		};
88 98
 	$fix_utf8mb4 = function($string) use ($utf8, $smcFunc)
89 99
 	{
90
-		if (!$utf8 || $smcFunc['db_mb4'])
91
-			return $string;
100
+		if (!$utf8 || $smcFunc['db_mb4']) {
101
+					return $string;
102
+		}
92 103
 
93 104
 		$i = 0;
94 105
 		$len = strlen($string);
@@ -100,18 +111,15 @@  discard block
 block discarded – undo
100 111
 			{
101 112
 				$new_string .= $string[$i];
102 113
 				$i++;
103
-			}
104
-			elseif ($ord < 224)
114
+			} elseif ($ord < 224)
105 115
 			{
106 116
 				$new_string .= $string[$i] . $string[$i + 1];
107 117
 				$i += 2;
108
-			}
109
-			elseif ($ord < 240)
118
+			} elseif ($ord < 240)
110 119
 			{
111 120
 				$new_string .= $string[$i] . $string[$i + 1] . $string[$i + 2];
112 121
 				$i += 3;
113
-			}
114
-			elseif ($ord < 248)
122
+			} elseif ($ord < 248)
115 123
 			{
116 124
 				// Magic happens.
117 125
 				$val = (ord($string[$i]) & 0x07) << 18;
@@ -155,8 +163,7 @@  discard block
 block discarded – undo
155 163
 			{
156 164
 				$result = array_search($needle, array_slice($haystack_arr, $offset));
157 165
 				return is_int($result) ? $result + $offset : false;
158
-			}
159
-			else
166
+			} else
160 167
 			{
161 168
 				$needle_arr = preg_split('~(' . $ent_list . '|.)~' . ($utf8 ? 'u' : '') . '', $ent_check($needle), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
162 169
 				$needle_size = count($needle_arr);
@@ -165,8 +172,9 @@  discard block
 block discarded – undo
165 172
 				while ((int) $result === $result)
166 173
 				{
167 174
 					$offset += $result;
168
-					if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr)
169
-						return $offset;
175
+					if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) {
176
+											return $offset;
177
+					}
170 178
 					$result = array_search($needle_arr[0], array_slice($haystack_arr, ++$offset));
171 179
 				}
172 180
 				return false;
@@ -204,8 +212,9 @@  discard block
 block discarded – undo
204 212
 			$string = $ent_check($string);
205 213
 			preg_match('~^(' . $ent_list . '|.){' . $smcFunc['strlen'](substr($string, 0, $length)) . '}~' . ($utf8 ? 'u' : ''), $string, $matches);
206 214
 			$string = $matches[0];
207
-			while (strlen($string) > $length)
208
-				$string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string);
215
+			while (strlen($string) > $length) {
216
+							$string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string);
217
+			}
209 218
 			return $string;
210 219
 		},
211 220
 		'ucfirst' => $utf8 ? function($string) use (&$smcFunc)
@@ -215,8 +224,9 @@  discard block
 block discarded – undo
215 224
 		'ucwords' => $utf8 ? function($string) use (&$smcFunc)
216 225
 		{
217 226
 			$words = preg_split('~([\s\r\n\t]+)~', $string, -1, PREG_SPLIT_DELIM_CAPTURE);
218
-			for ($i = 0, $n = count($words); $i < $n; $i += 2)
219
-				$words[$i] = $smcFunc['ucfirst']($words[$i]);
227
+			for ($i = 0, $n = count($words); $i < $n; $i += 2) {
228
+							$words[$i] = $smcFunc['ucfirst']($words[$i]);
229
+			}
220 230
 			return implode('', $words);
221 231
 		} : 'ucwords',
222 232
 		'json_decode' => 'smf_json_decode',
@@ -224,16 +234,17 @@  discard block
 block discarded – undo
224 234
 	);
225 235
 
226 236
 	// Setting the timezone is a requirement for some functions.
227
-	if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list()))
228
-		date_default_timezone_set($modSettings['default_timezone']);
229
-	else
237
+	if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) {
238
+			date_default_timezone_set($modSettings['default_timezone']);
239
+	} else
230 240
 	{
231 241
 		// Get PHP's default timezone, if set
232 242
 		$ini_tz = ini_get('date.timezone');
233
-		if (!empty($ini_tz))
234
-			$modSettings['default_timezone'] = $ini_tz;
235
-		else
236
-			$modSettings['default_timezone'] = '';
243
+		if (!empty($ini_tz)) {
244
+					$modSettings['default_timezone'] = $ini_tz;
245
+		} else {
246
+					$modSettings['default_timezone'] = '';
247
+		}
237 248
 
238 249
 		// If date.timezone is unset, invalid, or just plain weird, make a best guess
239 250
 		if (!in_array($modSettings['default_timezone'], timezone_identifiers_list()))
@@ -251,22 +262,26 @@  discard block
 block discarded – undo
251 262
 		if (($modSettings['load_average'] = cache_get_data('loadavg', 90)) == null)
252 263
 		{
253 264
 			$modSettings['load_average'] = @file_get_contents('/proc/loadavg');
254
-			if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0)
255
-				$modSettings['load_average'] = (float) $matches[1];
256
-			elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0)
257
-				$modSettings['load_average'] = (float) $matches[1];
258
-			else
259
-				unset($modSettings['load_average']);
265
+			if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) {
266
+							$modSettings['load_average'] = (float) $matches[1];
267
+			} elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) {
268
+							$modSettings['load_average'] = (float) $matches[1];
269
+			} else {
270
+							unset($modSettings['load_average']);
271
+			}
260 272
 
261
-			if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0)
262
-				cache_put_data('loadavg', $modSettings['load_average'], 90);
273
+			if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) {
274
+							cache_put_data('loadavg', $modSettings['load_average'], 90);
275
+			}
263 276
 		}
264 277
 
265
-		if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0)
266
-			call_integration_hook('integrate_load_average', array($modSettings['load_average']));
278
+		if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) {
279
+					call_integration_hook('integrate_load_average', array($modSettings['load_average']));
280
+		}
267 281
 
268
-		if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum'])
269
-			display_loadavg_error();
282
+		if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) {
283
+					display_loadavg_error();
284
+		}
270 285
 	}
271 286
 
272 287
 	// Is post moderation alive and well? Everywhere else assumes this has been defined, so let's make sure it is.
@@ -287,8 +302,9 @@  discard block
 block discarded – undo
287 302
 	if (defined('SMF_INTEGRATION_SETTINGS'))
288 303
 	{
289 304
 		$integration_settings = $smcFunc['json_decode'](SMF_INTEGRATION_SETTINGS, true);
290
-		foreach ($integration_settings as $hook => $function)
291
-			add_integration_function($hook, $function, '', false);
305
+		foreach ($integration_settings as $hook => $function) {
306
+					add_integration_function($hook, $function, '', false);
307
+		}
292 308
 	}
293 309
 
294 310
 	// Any files to pre include?
@@ -298,8 +314,9 @@  discard block
 block discarded – undo
298 314
 		foreach ($pre_includes as $include)
299 315
 		{
300 316
 			$include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir));
301
-			if (file_exists($include))
302
-				require_once($include);
317
+			if (file_exists($include)) {
318
+							require_once($include);
319
+			}
303 320
 		}
304 321
 	}
305 322
 
@@ -392,9 +409,9 @@  discard block
 block discarded – undo
392 409
 				break;
393 410
 			}
394 411
 		}
412
+	} else {
413
+			$id_member = 0;
395 414
 	}
396
-	else
397
-		$id_member = 0;
398 415
 
399 416
 	if (empty($id_member) && isset($_COOKIE[$cookiename]))
400 417
 	{
@@ -402,8 +419,9 @@  discard block
 block discarded – undo
402 419
 		$cookie_data = $smcFunc['json_decode']($_COOKIE[$cookiename], true, false);
403 420
 
404 421
 		// Legacy format (for recent 2.0 --> 2.1 upgrades)
405
-		if (empty($cookie_data))
406
-			$cookie_data = safe_unserialize($_COOKIE[$cookiename]);
422
+		if (empty($cookie_data)) {
423
+					$cookie_data = safe_unserialize($_COOKIE[$cookiename]);
424
+		}
407 425
 
408 426
 		list($id_member, $password, $login_span, $cookie_domain, $cookie_path) = array_pad((array) $cookie_data, 5, '');
409 427
 
@@ -411,16 +429,17 @@  discard block
 block discarded – undo
411 429
 
412 430
 		// Make sure the cookie is set to the correct domain and path
413 431
 		require_once($sourcedir . '/Subs-Auth.php');
414
-		if (array($cookie_domain, $cookie_path) !== url_parts(!empty($modSettings['localCookies']), !empty($modSettings['globalCookies'])))
415
-			setLoginCookie((int) $login_span - time(), $id_member);
416
-	}
417
-	elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA'])))
432
+		if (array($cookie_domain, $cookie_path) !== url_parts(!empty($modSettings['localCookies']), !empty($modSettings['globalCookies']))) {
433
+					setLoginCookie((int) $login_span - time(), $id_member);
434
+		}
435
+	} elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA'])))
418 436
 	{
419 437
 		// @todo Perhaps we can do some more checking on this, such as on the first octet of the IP?
420 438
 		$cookie_data = $smcFunc['json_decode']($_SESSION['login_' . $cookiename], true);
421 439
 
422
-		if (empty($cookie_data))
423
-			$cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]);
440
+		if (empty($cookie_data)) {
441
+					$cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]);
442
+		}
424 443
 
425 444
 		list($id_member, $password, $login_span) = array_pad((array) $cookie_data, 3, '');
426 445
 		$id_member = !empty($id_member) && strlen($password) == 128 && (int) $login_span > time() ? (int) $id_member : 0;
@@ -445,30 +464,34 @@  discard block
 block discarded – undo
445 464
 			$user_settings = $smcFunc['db_fetch_assoc']($request);
446 465
 			$smcFunc['db_free_result']($request);
447 466
 
448
-			if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false && empty($user_info['possibly_robot']))
449
-				$user_settings['avatar'] = get_proxied_url($user_settings['avatar']);
467
+			if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) {
468
+							$user_settings['avatar'] = get_proxied_url($user_settings['avatar']);
469
+			}
450 470
 
451
-			if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
452
-				cache_put_data('user_settings-' . $id_member, $user_settings, 60);
471
+			if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
472
+							cache_put_data('user_settings-' . $id_member, $user_settings, 60);
473
+			}
453 474
 		}
454 475
 
455 476
 		// Did we find 'im?  If not, junk it.
456 477
 		if (!empty($user_settings))
457 478
 		{
458 479
 			// As much as the password should be right, we can assume the integration set things up.
459
-			if (!empty($already_verified) && $already_verified === true)
460
-				$check = true;
480
+			if (!empty($already_verified) && $already_verified === true) {
481
+							$check = true;
482
+			}
461 483
 			// SHA-512 hash should be 128 characters long.
462
-			elseif (strlen($password) == 128)
463
-				$check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password;
464
-			else
465
-				$check = false;
484
+			elseif (strlen($password) == 128) {
485
+							$check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password;
486
+			} else {
487
+							$check = false;
488
+			}
466 489
 
467 490
 			// Wrong password or not activated - either way, you're going nowhere.
468 491
 			$id_member = $check && ($user_settings['is_activated'] == 1 || $user_settings['is_activated'] == 11) ? (int) $user_settings['id_member'] : 0;
492
+		} else {
493
+					$id_member = 0;
469 494
 		}
470
-		else
471
-			$id_member = 0;
472 495
 
473 496
 		// If we no longer have the member maybe they're being all hackey, stop brute force!
474 497
 		if (!$id_member)
@@ -497,8 +520,9 @@  discard block
 block discarded – undo
497 520
 
498 521
 					list ($tfamember, $tfasecret) = array_pad((array) $tfa_data, 2, '');
499 522
 
500
-					if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member)
501
-						$tfasecret = null;
523
+					if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member) {
524
+											$tfasecret = null;
525
+					}
502 526
 				}
503 527
 
504 528
 				// They didn't finish logging in before coming here? Then they're no one to us.
@@ -520,10 +544,12 @@  discard block
 block discarded – undo
520 544
 		// Are we forcing 2FA? Need to check if the user groups actually require 2FA
521 545
 		elseif (!empty($modSettings['tfa_mode']) && $modSettings['tfa_mode'] >= 2 && $id_member && empty($user_settings['tfa_secret']))
522 546
 		{
523
-			if ($modSettings['tfa_mode'] == 2) //only do this if we are just forcing SOME membergroups
547
+			if ($modSettings['tfa_mode'] == 2) {
548
+				//only do this if we are just forcing SOME membergroups
524 549
 			{
525 550
 				//Build an array of ALL user membergroups.
526 551
 				$full_groups = array($user_settings['id_group']);
552
+			}
527 553
 				if (!empty($user_settings['additional_groups']))
528 554
 				{
529 555
 					$full_groups = array_merge($full_groups, explode(',', $user_settings['additional_groups']));
@@ -543,15 +569,17 @@  discard block
 block discarded – undo
543 569
 				);
544 570
 				$row = $smcFunc['db_fetch_assoc']($request);
545 571
 				$smcFunc['db_free_result']($request);
572
+			} else {
573
+							$row['total'] = 1;
546 574
 			}
547
-			else
548
-				$row['total'] = 1; //simplifies logics in the next "if"
575
+			//simplifies logics in the next "if"
549 576
 
550 577
 			$area = !empty($_REQUEST['area']) ? $_REQUEST['area'] : '';
551 578
 			$action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : '';
552 579
 
553
-			if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup'))
554
-				redirectexit('action=profile;area=tfasetup;forced');
580
+			if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) {
581
+							redirectexit('action=profile;area=tfasetup;forced');
582
+			}
555 583
 		}
556 584
 	}
557 585
 
@@ -588,29 +616,32 @@  discard block
 block discarded – undo
588 616
 				updateMemberData($id_member, array('id_msg_last_visit' => (int) $modSettings['maxMsgID'], 'last_login' => time(), 'member_ip' => $_SERVER['REMOTE_ADDR'], 'member_ip2' => $_SERVER['BAN_CHECK_IP']));
589 617
 				$user_settings['last_login'] = time();
590 618
 
591
-				if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
592
-					cache_put_data('user_settings-' . $id_member, $user_settings, 60);
619
+				if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
620
+									cache_put_data('user_settings-' . $id_member, $user_settings, 60);
621
+				}
593 622
 
594
-				if (!empty($modSettings['cache_enable']))
595
-					cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600);
623
+				if (!empty($modSettings['cache_enable'])) {
624
+									cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600);
625
+				}
596 626
 			}
627
+		} elseif (empty($_SESSION['id_msg_last_visit'])) {
628
+					$_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit'];
597 629
 		}
598
-		elseif (empty($_SESSION['id_msg_last_visit']))
599
-			$_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit'];
600 630
 
601 631
 		$username = $user_settings['member_name'];
602 632
 
603
-		if (empty($user_settings['additional_groups']))
604
-			$user_info = array(
633
+		if (empty($user_settings['additional_groups'])) {
634
+					$user_info = array(
605 635
 				'groups' => array($user_settings['id_group'], $user_settings['id_post_group'])
606 636
 			);
607
-		else
608
-			$user_info = array(
637
+		} else {
638
+					$user_info = array(
609 639
 				'groups' => array_merge(
610 640
 					array($user_settings['id_group'], $user_settings['id_post_group']),
611 641
 					explode(',', $user_settings['additional_groups'])
612 642
 				)
613 643
 			);
644
+		}
614 645
 
615 646
 		// Because history has proven that it is possible for groups to go bad - clean up in case.
616 647
 		$user_info['groups'] = array_map('intval', $user_info['groups']);
@@ -627,8 +658,7 @@  discard block
 block discarded – undo
627 658
 			$time_system = new DateTime('now', $tz_system);
628 659
 			$time_user = new DateTime('now', $tz_user);
629 660
 			$user_info['time_offset'] = ($tz_user->getOffset($time_user) - $tz_system->getOffset($time_system)) / 3600;
630
-		}
631
-		else
661
+		} else
632 662
 		{
633 663
 			// !!! Compatibility.
634 664
 			$user_info['time_offset'] = empty($user_settings['time_offset']) ? 0 : $user_settings['time_offset'];
@@ -642,8 +672,9 @@  discard block
 block discarded – undo
642 672
 		$user_info = array('groups' => array(-1));
643 673
 		$user_settings = array();
644 674
 
645
-		if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member']))
646
-			$_COOKIE[$cookiename] = '';
675
+		if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) {
676
+					$_COOKIE[$cookiename] = '';
677
+		}
647 678
 
648 679
 		// Expire the 2FA cookie
649 680
 		if (isset($_COOKIE[$cookiename . '_tfa']) && empty($context['tfa_member']))
@@ -660,19 +691,20 @@  discard block
 block discarded – undo
660 691
 		}
661 692
 
662 693
 		// Create a login token if it doesn't exist yet.
663
-		if (!isset($_SESSION['token']['post-login']))
664
-			createToken('login');
665
-		else
666
-			list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login'];
694
+		if (!isset($_SESSION['token']['post-login'])) {
695
+					createToken('login');
696
+		} else {
697
+					list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login'];
698
+		}
667 699
 
668 700
 		// Do we perhaps think this is a search robot? Check every five minutes just in case...
669 701
 		if ((!empty($modSettings['spider_mode']) || !empty($modSettings['spider_group'])) && (!isset($_SESSION['robot_check']) || $_SESSION['robot_check'] < time() - 300))
670 702
 		{
671 703
 			require_once($sourcedir . '/ManageSearchEngines.php');
672 704
 			$user_info['possibly_robot'] = SpiderCheck();
705
+		} elseif (!empty($modSettings['spider_mode'])) {
706
+					$user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0;
673 707
 		}
674
-		elseif (!empty($modSettings['spider_mode']))
675
-			$user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0;
676 708
 		// If we haven't turned on proper spider hunts then have a guess!
677 709
 		else
678 710
 		{
@@ -720,8 +752,9 @@  discard block
 block discarded – undo
720 752
 	$user_info['groups'] = array_unique($user_info['groups']);
721 753
 
722 754
 	// Make sure that the last item in the ignore boards array is valid. If the list was too long it could have an ending comma that could cause problems.
723
-	if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1]))
724
-		unset($user_info['ignoreboards'][$tmp]);
755
+	if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) {
756
+			unset($user_info['ignoreboards'][$tmp]);
757
+	}
725 758
 
726 759
 	// Allow the user to change their language.
727 760
 	if (!empty($modSettings['userLanguage']))
@@ -734,13 +767,14 @@  discard block
 block discarded – undo
734 767
 			$user_info['language'] = strtr($_GET['language'], './\\:', '____');
735 768
 
736 769
 			// Make it permanent for members.
737
-			if (!empty($user_info['id']))
738
-				updateMemberData($user_info['id'], array('lngfile' => $user_info['language']));
739
-			else
740
-				$_SESSION['language'] = $user_info['language'];
770
+			if (!empty($user_info['id'])) {
771
+							updateMemberData($user_info['id'], array('lngfile' => $user_info['language']));
772
+			} else {
773
+							$_SESSION['language'] = $user_info['language'];
774
+			}
775
+		} elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) {
776
+					$user_info['language'] = strtr($_SESSION['language'], './\\:', '____');
741 777
 		}
742
-		elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')]))
743
-			$user_info['language'] = strtr($_SESSION['language'], './\\:', '____');
744 778
 	}
745 779
 
746 780
 	$temp = build_query_board($user_info['id']);
@@ -803,9 +837,9 @@  discard block
 block discarded – undo
803 837
 		}
804 838
 
805 839
 		// Remember redirection is the key to avoiding fallout from your bosses.
806
-		if (!empty($topic))
807
-			redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']);
808
-		else
840
+		if (!empty($topic)) {
841
+					redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']);
842
+		} else
809 843
 		{
810 844
 			loadPermissions();
811 845
 			loadTheme();
@@ -823,10 +857,11 @@  discard block
 block discarded – undo
823 857
 	if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3))
824 858
 	{
825 859
 		// @todo SLOW?
826
-		if (!empty($topic))
827
-			$temp = cache_get_data('topic_board-' . $topic, 120);
828
-		else
829
-			$temp = cache_get_data('board-' . $board, 120);
860
+		if (!empty($topic)) {
861
+					$temp = cache_get_data('topic_board-' . $topic, 120);
862
+		} else {
863
+					$temp = cache_get_data('board-' . $board, 120);
864
+		}
830 865
 
831 866
 		if (!empty($temp))
832 867
 		{
@@ -864,8 +899,9 @@  discard block
 block discarded – undo
864 899
 			$row = $smcFunc['db_fetch_assoc']($request);
865 900
 
866 901
 			// Set the current board.
867
-			if (!empty($row['id_board']))
868
-				$board = $row['id_board'];
902
+			if (!empty($row['id_board'])) {
903
+							$board = $row['id_board'];
904
+			}
869 905
 
870 906
 			// Basic operating information. (globals... :/)
871 907
 			$board_info = array(
@@ -901,21 +937,23 @@  discard block
 block discarded – undo
901 937
 
902 938
 			do
903 939
 			{
904
-				if (!empty($row['id_moderator']))
905
-					$board_info['moderators'][$row['id_moderator']] = array(
940
+				if (!empty($row['id_moderator'])) {
941
+									$board_info['moderators'][$row['id_moderator']] = array(
906 942
 						'id' => $row['id_moderator'],
907 943
 						'name' => $row['real_name'],
908 944
 						'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'],
909 945
 						'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>'
910 946
 					);
947
+				}
911 948
 
912
-				if (!empty($row['id_moderator_group']))
913
-					$board_info['moderator_groups'][$row['id_moderator_group']] = array(
949
+				if (!empty($row['id_moderator_group'])) {
950
+									$board_info['moderator_groups'][$row['id_moderator_group']] = array(
914 951
 						'id' => $row['id_moderator_group'],
915 952
 						'name' => $row['group_name'],
916 953
 						'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'],
917 954
 						'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>'
918 955
 					);
956
+				}
919 957
 			}
920 958
 			while ($row = $smcFunc['db_fetch_assoc']($request));
921 959
 
@@ -947,12 +985,12 @@  discard block
 block discarded – undo
947 985
 			if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3))
948 986
 			{
949 987
 				// @todo SLOW?
950
-				if (!empty($topic))
951
-					cache_put_data('topic_board-' . $topic, $board_info, 120);
988
+				if (!empty($topic)) {
989
+									cache_put_data('topic_board-' . $topic, $board_info, 120);
990
+				}
952 991
 				cache_put_data('board-' . $board, $board_info, 120);
953 992
 			}
954
-		}
955
-		else
993
+		} else
956 994
 		{
957 995
 			// Otherwise the topic is invalid, there are no moderators, etc.
958 996
 			$board_info = array(
@@ -966,8 +1004,9 @@  discard block
 block discarded – undo
966 1004
 		$smcFunc['db_free_result']($request);
967 1005
 	}
968 1006
 
969
-	if (!empty($topic))
970
-		$_GET['board'] = (int) $board;
1007
+	if (!empty($topic)) {
1008
+			$_GET['board'] = (int) $board;
1009
+	}
971 1010
 
972 1011
 	if (!empty($board))
973 1012
 	{
@@ -977,10 +1016,12 @@  discard block
 block discarded – undo
977 1016
 		// Now check if the user is a moderator.
978 1017
 		$user_info['is_mod'] = isset($board_info['moderators'][$user_info['id']]) || count(array_intersect($user_info['groups'], $moderator_groups)) != 0;
979 1018
 
980
-		if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin'])
981
-			$board_info['error'] = 'access';
982
-		if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin'])
983
-			$board_info['error'] = 'access';
1019
+		if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) {
1020
+					$board_info['error'] = 'access';
1021
+		}
1022
+		if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) {
1023
+					$board_info['error'] = 'access';
1024
+		}
984 1025
 
985 1026
 		// Build up the linktree.
986 1027
 		$context['linktree'] = array_merge(
@@ -1003,8 +1044,9 @@  discard block
 block discarded – undo
1003 1044
 	$context['current_board'] = $board;
1004 1045
 
1005 1046
 	// No posting in redirection boards!
1006
-	if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect']))
1007
-		$board_info['error'] == 'post_in_redirect';
1047
+	if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) {
1048
+			$board_info['error'] == 'post_in_redirect';
1049
+	}
1008 1050
 
1009 1051
 	// Hacker... you can't see this topic, I'll tell you that. (but moderators can!)
1010 1052
 	if (!empty($board_info['error']) && (!empty($modSettings['deny_boards_access']) || $board_info['error'] != 'access' || !$user_info['is_mod']))
@@ -1030,24 +1072,23 @@  discard block
 block discarded – undo
1030 1072
 			ob_end_clean();
1031 1073
 			header('HTTP/1.1 403 Forbidden');
1032 1074
 			die;
1033
-		}
1034
-		elseif ($board_info['error'] == 'post_in_redirect')
1075
+		} elseif ($board_info['error'] == 'post_in_redirect')
1035 1076
 		{
1036 1077
 			// Slightly different error message here...
1037 1078
 			fatal_lang_error('cannot_post_redirect', false);
1038
-		}
1039
-		elseif ($user_info['is_guest'])
1079
+		} elseif ($user_info['is_guest'])
1040 1080
 		{
1041 1081
 			loadLanguage('Errors');
1042 1082
 			is_not_guest($txt['topic_gone']);
1083
+		} else {
1084
+					fatal_lang_error('topic_gone', false);
1043 1085
 		}
1044
-		else
1045
-			fatal_lang_error('topic_gone', false);
1046 1086
 	}
1047 1087
 
1048
-	if ($user_info['is_mod'])
1049
-		$user_info['groups'][] = 3;
1050
-}
1088
+	if ($user_info['is_mod']) {
1089
+			$user_info['groups'][] = 3;
1090
+	}
1091
+	}
1051 1092
 
1052 1093
 /**
1053 1094
  * Load this user's permissions.
@@ -1068,8 +1109,9 @@  discard block
 block discarded – undo
1068 1109
 		asort($cache_groups);
1069 1110
 		$cache_groups = implode(',', $cache_groups);
1070 1111
 		// If it's a spider then cache it different.
1071
-		if ($user_info['possibly_robot'])
1072
-			$cache_groups .= '-spider';
1112
+		if ($user_info['possibly_robot']) {
1113
+					$cache_groups .= '-spider';
1114
+		}
1073 1115
 
1074 1116
 		if ($modSettings['cache_enable'] >= 2 && !empty($board) && ($temp = cache_get_data('permissions:' . $cache_groups . ':' . $board, 240)) != null && time() - 240 > $modSettings['settings_updated'])
1075 1117
 		{
@@ -1077,9 +1119,9 @@  discard block
 block discarded – undo
1077 1119
 			banPermissions();
1078 1120
 
1079 1121
 			return;
1122
+		} elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) {
1123
+					list ($user_info['permissions'], $removals) = $temp;
1080 1124
 		}
1081
-		elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated'])
1082
-			list ($user_info['permissions'], $removals) = $temp;
1083 1125
 	}
1084 1126
 
1085 1127
 	// If it is detected as a robot, and we are restricting permissions as a special group - then implement this.
@@ -1101,23 +1143,26 @@  discard block
 block discarded – undo
1101 1143
 		$removals = array();
1102 1144
 		while ($row = $smcFunc['db_fetch_assoc']($request))
1103 1145
 		{
1104
-			if (empty($row['add_deny']))
1105
-				$removals[] = $row['permission'];
1106
-			else
1107
-				$user_info['permissions'][] = $row['permission'];
1146
+			if (empty($row['add_deny'])) {
1147
+							$removals[] = $row['permission'];
1148
+			} else {
1149
+							$user_info['permissions'][] = $row['permission'];
1150
+			}
1108 1151
 		}
1109 1152
 		$smcFunc['db_free_result']($request);
1110 1153
 
1111
-		if (isset($cache_groups))
1112
-			cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240);
1154
+		if (isset($cache_groups)) {
1155
+					cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240);
1156
+		}
1113 1157
 	}
1114 1158
 
1115 1159
 	// Get the board permissions.
1116 1160
 	if (!empty($board))
1117 1161
 	{
1118 1162
 		// Make sure the board (if any) has been loaded by loadBoard().
1119
-		if (!isset($board_info['profile']))
1120
-			fatal_lang_error('no_board');
1163
+		if (!isset($board_info['profile'])) {
1164
+					fatal_lang_error('no_board');
1165
+		}
1121 1166
 
1122 1167
 		$request = $smcFunc['db_query']('', '
1123 1168
 			SELECT permission, add_deny
@@ -1133,20 +1178,23 @@  discard block
 block discarded – undo
1133 1178
 		);
1134 1179
 		while ($row = $smcFunc['db_fetch_assoc']($request))
1135 1180
 		{
1136
-			if (empty($row['add_deny']))
1137
-				$removals[] = $row['permission'];
1138
-			else
1139
-				$user_info['permissions'][] = $row['permission'];
1181
+			if (empty($row['add_deny'])) {
1182
+							$removals[] = $row['permission'];
1183
+			} else {
1184
+							$user_info['permissions'][] = $row['permission'];
1185
+			}
1140 1186
 		}
1141 1187
 		$smcFunc['db_free_result']($request);
1142 1188
 	}
1143 1189
 
1144 1190
 	// Remove all the permissions they shouldn't have ;).
1145
-	if (!empty($modSettings['permission_enable_deny']))
1146
-		$user_info['permissions'] = array_diff($user_info['permissions'], $removals);
1191
+	if (!empty($modSettings['permission_enable_deny'])) {
1192
+			$user_info['permissions'] = array_diff($user_info['permissions'], $removals);
1193
+	}
1147 1194
 
1148
-	if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2)
1149
-		cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240);
1195
+	if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) {
1196
+			cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240);
1197
+	}
1150 1198
 
1151 1199
 	// Banned?  Watch, don't touch..
1152 1200
 	banPermissions();
@@ -1158,17 +1206,18 @@  discard block
 block discarded – undo
1158 1206
 		{
1159 1207
 			require_once($sourcedir . '/Subs-Auth.php');
1160 1208
 			rebuildModCache();
1209
+		} else {
1210
+					$user_info['mod_cache'] = $_SESSION['mc'];
1161 1211
 		}
1162
-		else
1163
-			$user_info['mod_cache'] = $_SESSION['mc'];
1164 1212
 
1165 1213
 		// This is a useful phantom permission added to the current user, and only the current user while they are logged in.
1166 1214
 		// For example this drastically simplifies certain changes to the profile area.
1167 1215
 		$user_info['permissions'][] = 'is_not_guest';
1168 1216
 		// And now some backwards compatibility stuff for mods and whatnot that aren't expecting the new permissions.
1169 1217
 		$user_info['permissions'][] = 'profile_view_own';
1170
-		if (in_array('profile_view', $user_info['permissions']))
1171
-			$user_info['permissions'][] = 'profile_view_any';
1218
+		if (in_array('profile_view', $user_info['permissions'])) {
1219
+					$user_info['permissions'][] = 'profile_view_any';
1220
+		}
1172 1221
 	}
1173 1222
 }
1174 1223
 
@@ -1186,8 +1235,9 @@  discard block
 block discarded – undo
1186 1235
 	global $image_proxy_enabled, $user_info;
1187 1236
 
1188 1237
 	// Can't just look for no users :P.
1189
-	if (empty($users))
1190
-		return array();
1238
+	if (empty($users)) {
1239
+			return array();
1240
+	}
1191 1241
 
1192 1242
 	// Pass the set value
1193 1243
 	$context['loadMemberContext_set'] = $set;
@@ -1202,8 +1252,9 @@  discard block
 block discarded – undo
1202 1252
 		for ($i = 0, $n = count($users); $i < $n; $i++)
1203 1253
 		{
1204 1254
 			$data = cache_get_data('member_data-' . $set . '-' . $users[$i], 240);
1205
-			if ($data == null)
1206
-				continue;
1255
+			if ($data == null) {
1256
+							continue;
1257
+			}
1207 1258
 
1208 1259
 			$loaded_ids[] = $data['id_member'];
1209 1260
 			$user_profile[$data['id_member']] = $data;
@@ -1270,16 +1321,19 @@  discard block
 block discarded – undo
1270 1321
 			$row['avatar_original'] = !empty($row['avatar']) ? $row['avatar'] : '';
1271 1322
 
1272 1323
 			// Take care of proxying avatar if required, do this here for maximum reach
1273
-			if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false && empty($user_info['possibly_robot']))
1274
-				$row['avatar'] = get_proxied_url($row['avatar']);
1324
+			if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) {
1325
+							$row['avatar'] = get_proxied_url($row['avatar']);
1326
+			}
1275 1327
 
1276 1328
 			// Keep track of the member's normal member group
1277 1329
 			$row['primary_group'] = !empty($row['member_group']) ? $row['member_group'] : '';
1278 1330
 
1279
-			if (isset($row['member_ip']))
1280
-				$row['member_ip'] = inet_dtop($row['member_ip']);
1281
-			if (isset($row['member_ip2']))
1282
-				$row['member_ip2'] = inet_dtop($row['member_ip2']);
1331
+			if (isset($row['member_ip'])) {
1332
+							$row['member_ip'] = inet_dtop($row['member_ip']);
1333
+			}
1334
+			if (isset($row['member_ip2'])) {
1335
+							$row['member_ip2'] = inet_dtop($row['member_ip2']);
1336
+			}
1283 1337
 			$new_loaded_ids[] = $row['id_member'];
1284 1338
 			$loaded_ids[] = $row['id_member'];
1285 1339
 			$row['options'] = array();
@@ -1298,8 +1352,9 @@  discard block
 block discarded – undo
1298 1352
 				'loaded_ids' => $new_loaded_ids,
1299 1353
 			)
1300 1354
 		);
1301
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1302
-			$user_profile[$row['id_member']]['options'][$row['variable']] = $row['value'];
1355
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1356
+					$user_profile[$row['id_member']]['options'][$row['variable']] = $row['value'];
1357
+		}
1303 1358
 		$smcFunc['db_free_result']($request);
1304 1359
 	}
1305 1360
 
@@ -1310,10 +1365,11 @@  discard block
 block discarded – undo
1310 1365
 	{
1311 1366
 		foreach ($loaded_ids as $a_member)
1312 1367
 		{
1313
-			if (!empty($user_profile[$a_member]['additional_groups']))
1314
-				$groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups']));
1315
-			else
1316
-				$groups = array($user_profile[$a_member]['id_group']);
1368
+			if (!empty($user_profile[$a_member]['additional_groups'])) {
1369
+							$groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups']));
1370
+			} else {
1371
+							$groups = array($user_profile[$a_member]['id_group']);
1372
+			}
1317 1373
 
1318 1374
 			$temp = array_intersect($groups, array_keys($board_info['moderator_groups']));
1319 1375
 
@@ -1326,8 +1382,9 @@  discard block
 block discarded – undo
1326 1382
 
1327 1383
 	if (!empty($new_loaded_ids) && !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3)
1328 1384
 	{
1329
-		for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++)
1330
-			cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240);
1385
+		for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) {
1386
+					cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240);
1387
+		}
1331 1388
 	}
1332 1389
 
1333 1390
 	// Are we loading any moderators?  If so, fix their group data...
@@ -1353,14 +1410,17 @@  discard block
 block discarded – undo
1353 1410
 		foreach ($temp_mods as $id)
1354 1411
 		{
1355 1412
 			// By popular demand, don't show admins or global moderators as moderators.
1356
-			if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2)
1357
-				$user_profile[$id]['member_group'] = $row['member_group'];
1413
+			if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) {
1414
+							$user_profile[$id]['member_group'] = $row['member_group'];
1415
+			}
1358 1416
 
1359 1417
 			// If the Moderator group has no color or icons, but their group does... don't overwrite.
1360
-			if (!empty($row['icons']))
1361
-				$user_profile[$id]['icons'] = $row['icons'];
1362
-			if (!empty($row['member_group_color']))
1363
-				$user_profile[$id]['member_group_color'] = $row['member_group_color'];
1418
+			if (!empty($row['icons'])) {
1419
+							$user_profile[$id]['icons'] = $row['icons'];
1420
+			}
1421
+			if (!empty($row['member_group_color'])) {
1422
+							$user_profile[$id]['member_group_color'] = $row['member_group_color'];
1423
+			}
1364 1424
 		}
1365 1425
 	}
1366 1426
 
@@ -1382,12 +1442,14 @@  discard block
 block discarded – undo
1382 1442
 	static $loadedLanguages = array();
1383 1443
 
1384 1444
 	// If this person's data is already loaded, skip it.
1385
-	if (isset($dataLoaded[$user]))
1386
-		return true;
1445
+	if (isset($dataLoaded[$user])) {
1446
+			return true;
1447
+	}
1387 1448
 
1388 1449
 	// We can't load guests or members not loaded by loadMemberData()!
1389
-	if ($user == 0)
1390
-		return false;
1450
+	if ($user == 0) {
1451
+			return false;
1452
+	}
1391 1453
 	if (!isset($user_profile[$user]))
1392 1454
 	{
1393 1455
 		trigger_error('loadMemberContext(): member id ' . $user . ' not previously loaded by loadMemberData()', E_USER_WARNING);
@@ -1413,12 +1475,16 @@  discard block
 block discarded – undo
1413 1475
 	$buddy_list = !empty($profile['buddy_list']) ? explode(',', $profile['buddy_list']) : array();
1414 1476
 
1415 1477
 	//We need a little fallback for the membergroup icons. If it doesn't exist in the current theme, fallback to default theme
1416
-	if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) //icon is set and exists
1478
+	if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) {
1479
+		//icon is set and exists
1417 1480
 		$group_icon_url = $settings['images_url'] . '/membericons/' . $profile['icons'][1];
1418
-	elseif (isset($profile['icons'][1])) //icon is set and doesn't exist, fallback to default
1481
+	} elseif (isset($profile['icons'][1])) {
1482
+		//icon is set and doesn't exist, fallback to default
1419 1483
 		$group_icon_url = $settings['default_images_url'] . '/membericons/' . $profile['icons'][1];
1420
-	else //not set, bye bye
1484
+	} else {
1485
+		//not set, bye bye
1421 1486
 		$group_icon_url = '';
1487
+	}
1422 1488
 
1423 1489
 	// These minimal values are always loaded
1424 1490
 	$memberContext[$user] = array(
@@ -1437,8 +1503,9 @@  discard block
 block discarded – undo
1437 1503
 	if ($context['loadMemberContext_set'] != 'minimal')
1438 1504
 	{
1439 1505
 		// Go the extra mile and load the user's native language name.
1440
-		if (empty($loadedLanguages))
1441
-			$loadedLanguages = getLanguages();
1506
+		if (empty($loadedLanguages)) {
1507
+					$loadedLanguages = getLanguages();
1508
+		}
1442 1509
 
1443 1510
 		$memberContext[$user] += array(
1444 1511
 			'username_color' => '<span ' . (!empty($profile['member_group_color']) ? 'style="color:' . $profile['member_group_color'] . ';"' : '') . '>' . $profile['member_name'] . '</span>',
@@ -1493,31 +1560,33 @@  discard block
 block discarded – undo
1493 1560
 	{
1494 1561
 		if (!empty($modSettings['gravatarOverride']) || (!empty($modSettings['gravatarEnabled']) && stristr($profile['avatar'], 'gravatar://')))
1495 1562
 		{
1496
-			if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11)
1497
-				$image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11));
1498
-			else
1499
-				$image = get_gravatar_url($profile['email_address']);
1500
-		}
1501
-		else
1563
+			if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) {
1564
+							$image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11));
1565
+			} else {
1566
+							$image = get_gravatar_url($profile['email_address']);
1567
+			}
1568
+		} else
1502 1569
 		{
1503 1570
 			// So it's stored in the member table?
1504 1571
 			if (!empty($profile['avatar']))
1505 1572
 			{
1506 1573
 				$image = (stristr($profile['avatar'], 'http://') || stristr($profile['avatar'], 'https://')) ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar'];
1574
+			} elseif (!empty($profile['filename'])) {
1575
+							$image = $modSettings['custom_avatar_url'] . '/' . $profile['filename'];
1507 1576
 			}
1508
-			elseif (!empty($profile['filename']))
1509
-				$image = $modSettings['custom_avatar_url'] . '/' . $profile['filename'];
1510 1577
 			// Right... no avatar...use the default one
1511
-			else
1512
-				$image = $modSettings['avatar_url'] . '/default.png';
1578
+			else {
1579
+							$image = $modSettings['avatar_url'] . '/default.png';
1580
+			}
1513 1581
 		}
1514
-		if (!empty($image))
1515
-			$memberContext[$user]['avatar'] = array(
1582
+		if (!empty($image)) {
1583
+					$memberContext[$user]['avatar'] = array(
1516 1584
 				'name' => $profile['avatar'],
1517 1585
 				'image' => '<img class="avatar" src="' . $image . '" alt="avatar_' . $profile['member_name'] . '">',
1518 1586
 				'href' => $image,
1519 1587
 				'url' => $image,
1520 1588
 			);
1589
+		}
1521 1590
 	}
1522 1591
 
1523 1592
 	// Are we also loading the members custom fields into context?
@@ -1525,13 +1594,15 @@  discard block
 block discarded – undo
1525 1594
 	{
1526 1595
 		$memberContext[$user]['custom_fields'] = array();
1527 1596
 
1528
-		if (!isset($context['display_fields']))
1529
-			$context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true);
1597
+		if (!isset($context['display_fields'])) {
1598
+					$context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true);
1599
+		}
1530 1600
 
1531 1601
 		foreach ($context['display_fields'] as $custom)
1532 1602
 		{
1533
-			if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']]))
1534
-				continue;
1603
+			if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) {
1604
+							continue;
1605
+			}
1535 1606
 
1536 1607
 			$value = $profile['options'][$custom['col_name']];
1537 1608
 
@@ -1539,31 +1610,36 @@  discard block
 block discarded – undo
1539 1610
 			$currentKey = 0;
1540 1611
 
1541 1612
 			// Create a key => value array for multiple options fields
1542
-			if (!empty($custom['options']))
1543
-				foreach ($custom['options'] as $k => $v)
1613
+			if (!empty($custom['options'])) {
1614
+							foreach ($custom['options'] as $k => $v)
1544 1615
 				{
1545 1616
 					$fieldOptions[] = $v;
1546
-					if (empty($currentKey))
1547
-						$currentKey = $v == $value ? $k : 0;
1617
+			}
1618
+					if (empty($currentKey)) {
1619
+											$currentKey = $v == $value ? $k : 0;
1620
+					}
1548 1621
 				}
1549 1622
 
1550 1623
 			// BBC?
1551
-			if ($custom['bbc'])
1552
-				$value = parse_bbc($value);
1624
+			if ($custom['bbc']) {
1625
+							$value = parse_bbc($value);
1626
+			}
1553 1627
 
1554 1628
 			// ... or checkbox?
1555
-			elseif (isset($custom['type']) && $custom['type'] == 'check')
1556
-				$value = $value ? $txt['yes'] : $txt['no'];
1629
+			elseif (isset($custom['type']) && $custom['type'] == 'check') {
1630
+							$value = $value ? $txt['yes'] : $txt['no'];
1631
+			}
1557 1632
 
1558 1633
 			// Enclosing the user input within some other text?
1559
-			if (!empty($custom['enclose']))
1560
-				$value = strtr($custom['enclose'], array(
1634
+			if (!empty($custom['enclose'])) {
1635
+							$value = strtr($custom['enclose'], array(
1561 1636
 					'{SCRIPTURL}' => $scripturl,
1562 1637
 					'{IMAGES_URL}' => $settings['images_url'],
1563 1638
 					'{DEFAULT_IMAGES_URL}' => $settings['default_images_url'],
1564 1639
 					'{INPUT}' => $value,
1565 1640
 					'{KEY}' => $currentKey,
1566 1641
 				));
1642
+			}
1567 1643
 
1568 1644
 			$memberContext[$user]['custom_fields'][] = array(
1569 1645
 				'title' => !empty($custom['title']) ? $custom['title'] : $custom['col_name'],
@@ -1590,8 +1666,9 @@  discard block
 block discarded – undo
1590 1666
 	global $smcFunc, $txt, $scripturl, $settings;
1591 1667
 
1592 1668
 	// Do not waste my time...
1593
-	if (empty($users) || empty($params))
1594
-		return false;
1669
+	if (empty($users) || empty($params)) {
1670
+			return false;
1671
+	}
1595 1672
 
1596 1673
 	// Make sure it's an array.
1597 1674
 	$users = !is_array($users) ? array($users) : array_unique($users);
@@ -1618,41 +1695,48 @@  discard block
 block discarded – undo
1618 1695
 		$currentKey = 0;
1619 1696
 
1620 1697
 		// Create a key => value array for multiple options fields
1621
-		if (!empty($row['field_options']))
1622
-			foreach (explode(',', $row['field_options']) as $k => $v)
1698
+		if (!empty($row['field_options'])) {
1699
+					foreach (explode(',', $row['field_options']) as $k => $v)
1623 1700
 			{
1624 1701
 				$fieldOptions[] = $v;
1625
-				if (empty($currentKey))
1626
-					$currentKey = $v == $row['value'] ? $k : 0;
1702
+		}
1703
+				if (empty($currentKey)) {
1704
+									$currentKey = $v == $row['value'] ? $k : 0;
1705
+				}
1627 1706
 			}
1628 1707
 
1629 1708
 		// BBC?
1630
-		if (!empty($row['bbc']))
1631
-			$row['value'] = parse_bbc($row['value']);
1709
+		if (!empty($row['bbc'])) {
1710
+					$row['value'] = parse_bbc($row['value']);
1711
+		}
1632 1712
 
1633 1713
 		// ... or checkbox?
1634
-		elseif (isset($row['type']) && $row['type'] == 'check')
1635
-			$row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no'];
1714
+		elseif (isset($row['type']) && $row['type'] == 'check') {
1715
+					$row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no'];
1716
+		}
1636 1717
 
1637 1718
 		// Enclosing the user input within some other text?
1638
-		if (!empty($row['enclose']))
1639
-			$row['value'] = strtr($row['enclose'], array(
1719
+		if (!empty($row['enclose'])) {
1720
+					$row['value'] = strtr($row['enclose'], array(
1640 1721
 				'{SCRIPTURL}' => $scripturl,
1641 1722
 				'{IMAGES_URL}' => $settings['images_url'],
1642 1723
 				'{DEFAULT_IMAGES_URL}' => $settings['default_images_url'],
1643 1724
 				'{INPUT}' => un_htmlspecialchars($row['value']),
1644 1725
 				'{KEY}' => $currentKey,
1645 1726
 			));
1727
+		}
1646 1728
 
1647 1729
 		// Send a simple array if there is just 1 param
1648
-		if (count($params) == 1)
1649
-			$return[$row['id_member']] = $row;
1730
+		if (count($params) == 1) {
1731
+					$return[$row['id_member']] = $row;
1732
+		}
1650 1733
 
1651 1734
 		// More than 1? knock yourself out...
1652 1735
 		else
1653 1736
 		{
1654
-			if (!isset($return[$row['id_member']]))
1655
-				$return[$row['id_member']] = array();
1737
+			if (!isset($return[$row['id_member']])) {
1738
+							$return[$row['id_member']] = array();
1739
+			}
1656 1740
 
1657 1741
 			$return[$row['id_member']][$row['variable']] = $row;
1658 1742
 		}
@@ -1686,8 +1770,9 @@  discard block
 block discarded – undo
1686 1770
 	global $context;
1687 1771
 
1688 1772
 	// Don't know any browser!
1689
-	if (empty($context['browser']))
1690
-		detectBrowser();
1773
+	if (empty($context['browser'])) {
1774
+			detectBrowser();
1775
+	}
1691 1776
 
1692 1777
 	return !empty($context['browser'][$browser]) || !empty($context['browser']['is_' . $browser]) ? true : false;
1693 1778
 }
@@ -1705,8 +1790,9 @@  discard block
 block discarded – undo
1705 1790
 	global $context, $settings, $options, $sourcedir, $ssi_theme, $smcFunc, $language, $board, $image_proxy_enabled;
1706 1791
 
1707 1792
 	// The theme was specified by parameter.
1708
-	if (!empty($id_theme))
1709
-		$id_theme = (int) $id_theme;
1793
+	if (!empty($id_theme)) {
1794
+			$id_theme = (int) $id_theme;
1795
+	}
1710 1796
 	// The theme was specified by REQUEST.
1711 1797
 	elseif (!empty($_REQUEST['theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum')))
1712 1798
 	{
@@ -1714,32 +1800,38 @@  discard block
 block discarded – undo
1714 1800
 		$_SESSION['id_theme'] = $id_theme;
1715 1801
 	}
1716 1802
 	// The theme was specified by REQUEST... previously.
1717
-	elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum')))
1718
-		$id_theme = (int) $_SESSION['id_theme'];
1803
+	elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) {
1804
+			$id_theme = (int) $_SESSION['id_theme'];
1805
+	}
1719 1806
 	// The theme is just the user's choice. (might use ?board=1;theme=0 to force board theme.)
1720
-	elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme']))
1721
-		$id_theme = $user_info['theme'];
1807
+	elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) {
1808
+			$id_theme = $user_info['theme'];
1809
+	}
1722 1810
 	// The theme was specified by the board.
1723
-	elseif (!empty($board_info['theme']))
1724
-		$id_theme = $board_info['theme'];
1811
+	elseif (!empty($board_info['theme'])) {
1812
+			$id_theme = $board_info['theme'];
1813
+	}
1725 1814
 	// The theme is the forum's default.
1726
-	else
1727
-		$id_theme = $modSettings['theme_guests'];
1815
+	else {
1816
+			$id_theme = $modSettings['theme_guests'];
1817
+	}
1728 1818
 
1729 1819
 	// Verify the id_theme... no foul play.
1730 1820
 	// Always allow the board specific theme, if they are overriding.
1731
-	if (!empty($board_info['theme']) && $board_info['override_theme'])
1732
-		$id_theme = $board_info['theme'];
1821
+	if (!empty($board_info['theme']) && $board_info['override_theme']) {
1822
+			$id_theme = $board_info['theme'];
1823
+	}
1733 1824
 	// If they have specified a particular theme to use with SSI allow it to be used.
1734
-	elseif (!empty($ssi_theme) && $id_theme == $ssi_theme)
1735
-		$id_theme = (int) $id_theme;
1736
-	elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum'))
1825
+	elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) {
1826
+			$id_theme = (int) $id_theme;
1827
+	} elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum'))
1737 1828
 	{
1738 1829
 		$themes = explode(',', $modSettings['enableThemes']);
1739
-		if (!in_array($id_theme, $themes))
1740
-			$id_theme = $modSettings['theme_guests'];
1741
-		else
1742
-			$id_theme = (int) $id_theme;
1830
+		if (!in_array($id_theme, $themes)) {
1831
+					$id_theme = $modSettings['theme_guests'];
1832
+		} else {
1833
+					$id_theme = (int) $id_theme;
1834
+		}
1743 1835
 	}
1744 1836
 		
1745 1837
 	// We already load the basic stuff?
@@ -1748,18 +1840,19 @@  discard block
 block discarded – undo
1748 1840
 		$member = empty($user_info['id']) ? -1 : $user_info['id'];
1749 1841
 
1750 1842
 		// Disable image proxy if we don't have SSL enabled
1751
-		if (empty($modSettings['force_ssl']))
1752
-			$image_proxy_enabled = false;
1843
+		if (empty($modSettings['force_ssl'])) {
1844
+					$image_proxy_enabled = false;
1845
+		}
1753 1846
 
1754 1847
 		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && ($temp = cache_get_data('theme_settings-' . $id_theme . ':' . $member, 60)) != null && time() - 60 > $modSettings['settings_updated'])
1755 1848
 		{
1756 1849
 			$themeData = $temp;
1757 1850
 			$flag = true;
1851
+		} elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) {
1852
+					$themeData = $temp + array($member => array());
1853
+		} else {
1854
+					$themeData = array(-1 => array(), 0 => array(), $member => array());
1758 1855
 		}
1759
-		elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated'])
1760
-			$themeData = $temp + array($member => array());
1761
-		else
1762
-			$themeData = array(-1 => array(), 0 => array(), $member => array());
1763 1856
 
1764 1857
 		if (empty($flag))
1765 1858
 		{
@@ -1779,31 +1872,37 @@  discard block
 block discarded – undo
1779 1872
 			while ($row = $smcFunc['db_fetch_assoc']($result))
1780 1873
 			{
1781 1874
 				// There are just things we shouldn't be able to change as members.
1782
-				if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url')))
1783
-					continue;
1875
+				if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url'))) {
1876
+									continue;
1877
+				}
1784 1878
 
1785 1879
 				// If this is the theme_dir of the default theme, store it.
1786
-				if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member']))
1787
-					$themeData[0]['default_' . $row['variable']] = $row['value'];
1880
+				if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) {
1881
+									$themeData[0]['default_' . $row['variable']] = $row['value'];
1882
+				}
1788 1883
 
1789 1884
 				// If this isn't set yet, is a theme option, or is not the default theme..
1790
-				if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1')
1791
-					$themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value'];
1885
+				if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') {
1886
+									$themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value'];
1887
+				}
1792 1888
 			}
1793 1889
 			$smcFunc['db_free_result']($result);
1794 1890
 
1795
-			if (!empty($themeData[-1]))
1796
-				foreach ($themeData[-1] as $k => $v)
1891
+			if (!empty($themeData[-1])) {
1892
+							foreach ($themeData[-1] as $k => $v)
1797 1893
 				{
1798 1894
 					if (!isset($themeData[$member][$k]))
1799 1895
 						$themeData[$member][$k] = $v;
1896
+			}
1800 1897
 				}
1801 1898
 
1802
-			if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
1803
-				cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60);
1899
+			if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
1900
+							cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60);
1901
+			}
1804 1902
 			// Only if we didn't already load that part of the cache...
1805
-			elseif (!isset($temp))
1806
-				cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90);
1903
+			elseif (!isset($temp)) {
1904
+							cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90);
1905
+			}
1807 1906
 		}
1808 1907
 
1809 1908
 		$settings = $themeData[0];
@@ -1820,17 +1919,20 @@  discard block
 block discarded – undo
1820 1919
 		$settings['template_dirs'][] = $settings['theme_dir'];
1821 1920
 
1822 1921
 		// Based on theme (if there is one).
1823
-		if (!empty($settings['base_theme_dir']))
1824
-			$settings['template_dirs'][] = $settings['base_theme_dir'];
1922
+		if (!empty($settings['base_theme_dir'])) {
1923
+					$settings['template_dirs'][] = $settings['base_theme_dir'];
1924
+		}
1825 1925
 
1826 1926
 		// Lastly the default theme.
1827
-		if ($settings['theme_dir'] != $settings['default_theme_dir'])
1828
-			$settings['template_dirs'][] = $settings['default_theme_dir'];
1927
+		if ($settings['theme_dir'] != $settings['default_theme_dir']) {
1928
+					$settings['template_dirs'][] = $settings['default_theme_dir'];
1929
+		}
1829 1930
 	}
1830 1931
 
1831 1932
 
1832
-	if (!$initialize)
1833
-		return;
1933
+	if (!$initialize) {
1934
+			return;
1935
+	}
1834 1936
 
1835 1937
 	// Check to see if we're forcing SSL
1836 1938
 	if (!empty($modSettings['force_ssl']) && empty($maintenance) &&
@@ -1851,8 +1953,9 @@  discard block
 block discarded – undo
1851 1953
 		$detected_url = httpsOn() ? 'https://' : 'http://';
1852 1954
 		$detected_url .= empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST'];
1853 1955
 		$temp = preg_replace('~/' . basename($scripturl) . '(/.+)?$~', '', strtr(dirname($_SERVER['PHP_SELF']), '\\', '/'));
1854
-		if ($temp != '/')
1855
-			$detected_url .= $temp;
1956
+		if ($temp != '/') {
1957
+					$detected_url .= $temp;
1958
+		}
1856 1959
 	}
1857 1960
 	if (isset($detected_url) && $detected_url != $boardurl)
1858 1961
 	{
@@ -1864,8 +1967,9 @@  discard block
 block discarded – undo
1864 1967
 			foreach ($aliases as $alias)
1865 1968
 			{
1866 1969
 				// Rip off all the boring parts, spaces, etc.
1867
-				if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias))
1868
-					$do_fix = true;
1970
+				if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) {
1971
+									$do_fix = true;
1972
+				}
1869 1973
 			}
1870 1974
 		}
1871 1975
 
@@ -1873,21 +1977,23 @@  discard block
 block discarded – undo
1873 1977
 		if (empty($do_fix) && strtr($detected_url, array('://' => '://www.')) == $boardurl && (empty($_GET) || count($_GET) == 1) && SMF != 'SSI')
1874 1978
 		{
1875 1979
 			// Okay, this seems weird, but we don't want an endless loop - this will make $_GET not empty ;).
1876
-			if (empty($_GET))
1877
-				redirectexit('wwwRedirect');
1878
-			else
1980
+			if (empty($_GET)) {
1981
+							redirectexit('wwwRedirect');
1982
+			} else
1879 1983
 			{
1880 1984
 				$k = key($_GET);
1881 1985
 				$v = current($_GET);
1882 1986
 
1883
-				if ($k != 'wwwRedirect')
1884
-					redirectexit('wwwRedirect;' . $k . '=' . $v);
1987
+				if ($k != 'wwwRedirect') {
1988
+									redirectexit('wwwRedirect;' . $k . '=' . $v);
1989
+				}
1885 1990
 			}
1886 1991
 		}
1887 1992
 
1888 1993
 		// #3 is just a check for SSL...
1889
-		if (strtr($detected_url, array('https://' => 'http://')) == $boardurl)
1890
-			$do_fix = true;
1994
+		if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) {
1995
+					$do_fix = true;
1996
+		}
1891 1997
 
1892 1998
 		// Okay, #4 - perhaps it's an IP address?  We're gonna want to use that one, then. (assuming it's the IP or something...)
1893 1999
 		if (!empty($do_fix) || preg_match('~^http[s]?://(?:[\d\.:]+|\[[\d:]+\](?::\d+)?)(?:$|/)~', $detected_url) == 1)
@@ -1922,8 +2028,9 @@  discard block
 block discarded – undo
1922 2028
 					$board_info['moderators'][$k]['link'] = strtr($dummy['link'], array('"' . $oldurl => '"' . $boardurl));
1923 2029
 				}
1924 2030
 			}
1925
-			foreach ($context['linktree'] as $k => $dummy)
1926
-				$context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl));
2031
+			foreach ($context['linktree'] as $k => $dummy) {
2032
+							$context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl));
2033
+			}
1927 2034
 		}
1928 2035
 	}
1929 2036
 	// Set up the contextual user array.
@@ -1942,16 +2049,16 @@  discard block
 block discarded – undo
1942 2049
 			'email' => $user_info['email'],
1943 2050
 			'ignoreusers' => $user_info['ignoreusers'],
1944 2051
 		);
1945
-		if (!$context['user']['is_guest'])
1946
-			$context['user']['name'] = $user_info['name'];
1947
-		elseif ($context['user']['is_guest'] && !empty($txt['guest_title']))
1948
-			$context['user']['name'] = $txt['guest_title'];
2052
+		if (!$context['user']['is_guest']) {
2053
+					$context['user']['name'] = $user_info['name'];
2054
+		} elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) {
2055
+					$context['user']['name'] = $txt['guest_title'];
2056
+		}
1949 2057
 
1950 2058
 		// Determine the current smiley set.
1951 2059
 		$user_info['smiley_set'] = (!in_array($user_info['smiley_set'], explode(',', $modSettings['smiley_sets_known'])) && $user_info['smiley_set'] != 'none') || empty($modSettings['smiley_sets_enable']) ? (!empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default']) : $user_info['smiley_set'];
1952 2060
 		$context['user']['smiley_set'] = $user_info['smiley_set'];
1953
-	}
1954
-	else
2061
+	} else
1955 2062
 	{
1956 2063
 		// What to do when there is no $user_info (e.g., an error very early in the login process)
1957 2064
 		$context['user'] = array(
@@ -1985,18 +2092,24 @@  discard block
 block discarded – undo
1985 2092
 	}
1986 2093
 
1987 2094
 	// Some basic information...
1988
-	if (!isset($context['html_headers']))
1989
-		$context['html_headers'] = '';
1990
-	if (!isset($context['javascript_files']))
1991
-		$context['javascript_files'] = array();
1992
-	if (!isset($context['css_files']))
1993
-		$context['css_files'] = array();
1994
-	if (!isset($context['css_header']))
1995
-		$context['css_header'] = array();
1996
-	if (!isset($context['javascript_inline']))
1997
-		$context['javascript_inline'] = array('standard' => array(), 'defer' => array());
1998
-	if (!isset($context['javascript_vars']))
1999
-		$context['javascript_vars'] = array();
2095
+	if (!isset($context['html_headers'])) {
2096
+			$context['html_headers'] = '';
2097
+	}
2098
+	if (!isset($context['javascript_files'])) {
2099
+			$context['javascript_files'] = array();
2100
+	}
2101
+	if (!isset($context['css_files'])) {
2102
+			$context['css_files'] = array();
2103
+	}
2104
+	if (!isset($context['css_header'])) {
2105
+			$context['css_header'] = array();
2106
+	}
2107
+	if (!isset($context['javascript_inline'])) {
2108
+			$context['javascript_inline'] = array('standard' => array(), 'defer' => array());
2109
+	}
2110
+	if (!isset($context['javascript_vars'])) {
2111
+			$context['javascript_vars'] = array();
2112
+	}
2000 2113
 
2001 2114
 	$context['login_url'] =  $scripturl . '?action=login2';
2002 2115
 	$context['menu_separator'] = !empty($settings['use_image_buttons']) ? ' ' : ' | ';
@@ -2008,16 +2121,18 @@  discard block
 block discarded – undo
2008 2121
 	$context['current_action'] = isset($_REQUEST['action']) ? $smcFunc['htmlspecialchars']($_REQUEST['action']) : null;
2009 2122
 	$context['current_subaction'] = isset($_REQUEST['sa']) ? $_REQUEST['sa'] : null;
2010 2123
 	$context['can_register'] = empty($modSettings['registration_method']) || $modSettings['registration_method'] != 3;
2011
-	if (isset($modSettings['load_average']))
2012
-		$context['load_average'] = $modSettings['load_average'];
2124
+	if (isset($modSettings['load_average'])) {
2125
+			$context['load_average'] = $modSettings['load_average'];
2126
+	}
2013 2127
 
2014 2128
 	// Detect the browser. This is separated out because it's also used in attachment downloads
2015 2129
 	detectBrowser();
2016 2130
 
2017 2131
 	// Set the top level linktree up.
2018 2132
 	// Note that if we're dealing with certain very early errors (e.g., login) the linktree might not be set yet...
2019
-	if (empty($context['linktree']))
2020
-		$context['linktree'] = array();
2133
+	if (empty($context['linktree'])) {
2134
+			$context['linktree'] = array();
2135
+	}
2021 2136
 	array_unshift($context['linktree'], array(
2022 2137
 		'url' => $scripturl,
2023 2138
 		'name' => $context['forum_name_html_safe']
@@ -2026,8 +2141,9 @@  discard block
 block discarded – undo
2026 2141
 	// This allows sticking some HTML on the page output - useful for controls.
2027 2142
 	$context['insert_after_template'] = '';
2028 2143
 
2029
-	if (!isset($txt))
2030
-		$txt = array();
2144
+	if (!isset($txt)) {
2145
+			$txt = array();
2146
+	}
2031 2147
 
2032 2148
 	$simpleActions = array(
2033 2149
 		'findmember',
@@ -2073,9 +2189,10 @@  discard block
 block discarded – undo
2073 2189
 
2074 2190
 	// See if theres any extra param to check.
2075 2191
 	$requiresXML = false;
2076
-	foreach ($extraParams as $key => $extra)
2077
-		if (isset($_REQUEST[$extra]))
2192
+	foreach ($extraParams as $key => $extra) {
2193
+			if (isset($_REQUEST[$extra]))
2078 2194
 			$requiresXML = true;
2195
+	}
2079 2196
 
2080 2197
 	// Output is fully XML, so no need for the index template.
2081 2198
 	if (isset($_REQUEST['xml']) && (in_array($context['current_action'], $xmlActions) || $requiresXML))
@@ -2090,37 +2207,39 @@  discard block
 block discarded – undo
2090 2207
 	{
2091 2208
 		loadLanguage('index+Modifications');
2092 2209
 		$context['template_layers'] = array();
2093
-	}
2094
-
2095
-	else
2210
+	} else
2096 2211
 	{
2097 2212
 		// Custom templates to load, or just default?
2098
-		if (isset($settings['theme_templates']))
2099
-			$templates = explode(',', $settings['theme_templates']);
2100
-		else
2101
-			$templates = array('index');
2213
+		if (isset($settings['theme_templates'])) {
2214
+					$templates = explode(',', $settings['theme_templates']);
2215
+		} else {
2216
+					$templates = array('index');
2217
+		}
2102 2218
 
2103 2219
 		// Load each template...
2104
-		foreach ($templates as $template)
2105
-			loadTemplate($template);
2220
+		foreach ($templates as $template) {
2221
+					loadTemplate($template);
2222
+		}
2106 2223
 
2107 2224
 		// ...and attempt to load their associated language files.
2108 2225
 		$required_files = implode('+', array_merge($templates, array('Modifications')));
2109 2226
 		loadLanguage($required_files, '', false);
2110 2227
 
2111 2228
 		// Custom template layers?
2112
-		if (isset($settings['theme_layers']))
2113
-			$context['template_layers'] = explode(',', $settings['theme_layers']);
2114
-		else
2115
-			$context['template_layers'] = array('html', 'body');
2229
+		if (isset($settings['theme_layers'])) {
2230
+					$context['template_layers'] = explode(',', $settings['theme_layers']);
2231
+		} else {
2232
+					$context['template_layers'] = array('html', 'body');
2233
+		}
2116 2234
 	}
2117 2235
 
2118 2236
 	// Initialize the theme.
2119 2237
 	loadSubTemplate('init', 'ignore');
2120 2238
 
2121 2239
 	// Allow overriding the board wide time/number formats.
2122
-	if (empty($user_settings['time_format']) && !empty($txt['time_format']))
2123
-		$user_info['time_format'] = $txt['time_format'];
2240
+	if (empty($user_settings['time_format']) && !empty($txt['time_format'])) {
2241
+			$user_info['time_format'] = $txt['time_format'];
2242
+	}
2124 2243
 
2125 2244
 	// Set the character set from the template.
2126 2245
 	$context['character_set'] = empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set'];
@@ -2128,12 +2247,14 @@  discard block
 block discarded – undo
2128 2247
 	$context['right_to_left'] = !empty($txt['lang_rtl']);
2129 2248
 
2130 2249
 	// Guests may still need a name.
2131
-	if ($context['user']['is_guest'] && empty($context['user']['name']))
2132
-		$context['user']['name'] = $txt['guest_title'];
2250
+	if ($context['user']['is_guest'] && empty($context['user']['name'])) {
2251
+			$context['user']['name'] = $txt['guest_title'];
2252
+	}
2133 2253
 
2134 2254
 	// Any theme-related strings that need to be loaded?
2135
-	if (!empty($settings['require_theme_strings']))
2136
-		loadLanguage('ThemeStrings', '', false);
2255
+	if (!empty($settings['require_theme_strings'])) {
2256
+			loadLanguage('ThemeStrings', '', false);
2257
+	}
2137 2258
 
2138 2259
 	// Make a special URL for the language.
2139 2260
 	$settings['lang_images_url'] = $settings['images_url'] . '/' . (!empty($txt['image_lang']) ? $txt['image_lang'] : $user_info['language']);
@@ -2144,8 +2265,9 @@  discard block
 block discarded – undo
2144 2265
 	// Here is my luvly Responsive CSS
2145 2266
 	loadCSSFile('responsive.css', array('force_current' => false, 'validate' => true, 'minimize' => true, 'order_pos' => 9000), 'smf_responsive');
2146 2267
 
2147
-	if ($context['right_to_left'])
2148
-		loadCSSFile('rtl.css', array('order_pos' => 200), 'smf_rtl');
2268
+	if ($context['right_to_left']) {
2269
+			loadCSSFile('rtl.css', array('order_pos' => 200), 'smf_rtl');
2270
+	}
2149 2271
 
2150 2272
 	// We allow theme variants, because we're cool.
2151 2273
 	$context['theme_variant'] = '';
@@ -2153,14 +2275,17 @@  discard block
 block discarded – undo
2153 2275
 	if (!empty($settings['theme_variants']))
2154 2276
 	{
2155 2277
 		// Overriding - for previews and that ilk.
2156
-		if (!empty($_REQUEST['variant']))
2157
-			$_SESSION['id_variant'] = $_REQUEST['variant'];
2278
+		if (!empty($_REQUEST['variant'])) {
2279
+					$_SESSION['id_variant'] = $_REQUEST['variant'];
2280
+		}
2158 2281
 		// User selection?
2159
-		if (empty($settings['disable_user_variant']) || allowedTo('admin_forum'))
2160
-			$context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : '');
2282
+		if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) {
2283
+					$context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : '');
2284
+		}
2161 2285
 		// If not a user variant, select the default.
2162
-		if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants']))
2163
-			$context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0];
2286
+		if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) {
2287
+					$context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0];
2288
+		}
2164 2289
 
2165 2290
 		// Do this to keep things easier in the templates.
2166 2291
 		$context['theme_variant'] = '_' . $context['theme_variant'];
@@ -2169,20 +2294,23 @@  discard block
 block discarded – undo
2169 2294
 		if (!empty($context['theme_variant']))
2170 2295
 		{
2171 2296
 			loadCSSFile('index' . $context['theme_variant'] . '.css', array('order_pos' => 300), 'smf_index' . $context['theme_variant']);
2172
-			if ($context['right_to_left'])
2173
-				loadCSSFile('rtl' . $context['theme_variant'] . '.css', array('order_pos' => 400), 'smf_rtl' . $context['theme_variant']);
2297
+			if ($context['right_to_left']) {
2298
+							loadCSSFile('rtl' . $context['theme_variant'] . '.css', array('order_pos' => 400), 'smf_rtl' . $context['theme_variant']);
2299
+			}
2174 2300
 		}
2175 2301
 	}
2176 2302
 
2177 2303
 	// Let's be compatible with old themes!
2178
-	if (!function_exists('template_html_above') && in_array('html', $context['template_layers']))
2179
-		$context['template_layers'] = array('main');
2304
+	if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) {
2305
+			$context['template_layers'] = array('main');
2306
+	}
2180 2307
 
2181 2308
 	$context['tabindex'] = 1;
2182 2309
 
2183 2310
 	// Compatibility.
2184
-	if (!isset($settings['theme_version']))
2185
-		$modSettings['memberCount'] = $modSettings['totalMembers'];
2311
+	if (!isset($settings['theme_version'])) {
2312
+			$modSettings['memberCount'] = $modSettings['totalMembers'];
2313
+	}
2186 2314
 
2187 2315
 	// Default JS variables for use in every theme
2188 2316
 	$context['javascript_vars'] = array(
@@ -2202,18 +2330,18 @@  discard block
 block discarded – undo
2202 2330
 	);
2203 2331
 
2204 2332
 	// Add the JQuery library to the list of files to load.
2205
-	if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn')
2206
-		loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery');
2207
-
2208
-	elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local')
2209
-		loadJavaScriptFile('jquery-3.2.1.min.js', array('seed' => false), 'smf_jquery');
2210
-
2211
-	elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom')
2212
-		loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery');
2333
+	if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') {
2334
+			loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery');
2335
+	} elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') {
2336
+			loadJavaScriptFile('jquery-3.2.1.min.js', array('seed' => false), 'smf_jquery');
2337
+	} elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') {
2338
+			loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery');
2339
+	}
2213 2340
 
2214 2341
 	// Auto loading? template_javascript() will take care of the local half of this.
2215
-	else
2216
-		loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery');
2342
+	else {
2343
+			loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery');
2344
+	}
2217 2345
 
2218 2346
 	// Queue our JQuery plugins!
2219 2347
 	loadJavaScriptFile('smf_jquery_plugins.js', array('minimize' => true), 'smf_jquery_plugins');
@@ -2236,12 +2364,12 @@  discard block
 block discarded – undo
2236 2364
 			require_once($sourcedir . '/ScheduledTasks.php');
2237 2365
 
2238 2366
 			// What to do, what to do?!
2239
-			if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time())
2240
-				AutoTask();
2241
-			else
2242
-				ReduceMailQueue();
2243
-		}
2244
-		else
2367
+			if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) {
2368
+							AutoTask();
2369
+			} else {
2370
+							ReduceMailQueue();
2371
+			}
2372
+		} else
2245 2373
 		{
2246 2374
 			$type = empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time() ? 'task' : 'mailq';
2247 2375
 			$ts = $type == 'mailq' ? $modSettings['mail_next_send'] : $modSettings['next_task_time'];
@@ -2292,8 +2420,9 @@  discard block
 block discarded – undo
2292 2420
 		foreach ($theme_includes as $include)
2293 2421
 		{
2294 2422
 			$include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir']));
2295
-			if (file_exists($include))
2296
-				require_once($include);
2423
+			if (file_exists($include)) {
2424
+							require_once($include);
2425
+			}
2297 2426
 		}
2298 2427
 	}
2299 2428
 
@@ -2323,16 +2452,19 @@  discard block
 block discarded – undo
2323 2452
 	// Do any style sheets first, cause we're easy with those.
2324 2453
 	if (!empty($style_sheets))
2325 2454
 	{
2326
-		if (!is_array($style_sheets))
2327
-			$style_sheets = array($style_sheets);
2455
+		if (!is_array($style_sheets)) {
2456
+					$style_sheets = array($style_sheets);
2457
+		}
2328 2458
 
2329
-		foreach ($style_sheets as $sheet)
2330
-			loadCSSFile($sheet . '.css', array(), $sheet);
2459
+		foreach ($style_sheets as $sheet) {
2460
+					loadCSSFile($sheet . '.css', array(), $sheet);
2461
+		}
2331 2462
 	}
2332 2463
 
2333 2464
 	// No template to load?
2334
-	if ($template_name === false)
2335
-		return true;
2465
+	if ($template_name === false) {
2466
+			return true;
2467
+	}
2336 2468
 
2337 2469
 	$loaded = false;
2338 2470
 	foreach ($settings['template_dirs'] as $template_dir)
@@ -2347,12 +2479,14 @@  discard block
 block discarded – undo
2347 2479
 
2348 2480
 	if ($loaded)
2349 2481
 	{
2350
-		if ($db_show_debug === true)
2351
-			$context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')';
2482
+		if ($db_show_debug === true) {
2483
+					$context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')';
2484
+		}
2352 2485
 
2353 2486
 		// If they have specified an initialization function for this template, go ahead and call it now.
2354
-		if (function_exists('template_' . $template_name . '_init'))
2355
-			call_user_func('template_' . $template_name . '_init');
2487
+		if (function_exists('template_' . $template_name . '_init')) {
2488
+					call_user_func('template_' . $template_name . '_init');
2489
+		}
2356 2490
 	}
2357 2491
 	// Hmmm... doesn't exist?!  I don't suppose the directory is wrong, is it?
2358 2492
 	elseif (!file_exists($settings['default_theme_dir']) && file_exists($boarddir . '/Themes/default'))
@@ -2372,13 +2506,14 @@  discard block
 block discarded – undo
2372 2506
 		loadTemplate($template_name);
2373 2507
 	}
2374 2508
 	// Cause an error otherwise.
2375
-	elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal)
2376
-		fatal_lang_error('theme_template_error', 'template', array((string) $template_name));
2377
-	elseif ($fatal)
2378
-		die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template'));
2379
-	else
2380
-		return false;
2381
-}
2509
+	elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) {
2510
+			fatal_lang_error('theme_template_error', 'template', array((string) $template_name));
2511
+	} elseif ($fatal) {
2512
+			die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template'));
2513
+	} else {
2514
+			return false;
2515
+	}
2516
+	}
2382 2517
 
2383 2518
 /**
2384 2519
  * Load a sub-template.
@@ -2396,17 +2531,19 @@  discard block
 block discarded – undo
2396 2531
 {
2397 2532
 	global $context, $txt, $db_show_debug;
2398 2533
 
2399
-	if ($db_show_debug === true)
2400
-		$context['debug']['sub_templates'][] = $sub_template_name;
2534
+	if ($db_show_debug === true) {
2535
+			$context['debug']['sub_templates'][] = $sub_template_name;
2536
+	}
2401 2537
 
2402 2538
 	// Figure out what the template function is named.
2403 2539
 	$theme_function = 'template_' . $sub_template_name;
2404
-	if (function_exists($theme_function))
2405
-		$theme_function();
2406
-	elseif ($fatal === false)
2407
-		fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name));
2408
-	elseif ($fatal !== 'ignore')
2409
-		die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name), 'template'));
2540
+	if (function_exists($theme_function)) {
2541
+			$theme_function();
2542
+	} elseif ($fatal === false) {
2543
+			fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name));
2544
+	} elseif ($fatal !== 'ignore') {
2545
+			die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name), 'template'));
2546
+	}
2410 2547
 
2411 2548
 	// Are we showing debugging for templates?  Just make sure not to do it before the doctype...
2412 2549
 	if (allowedTo('admin_forum') && isset($_REQUEST['debug']) && !in_array($sub_template_name, array('init', 'main_below')) && ob_get_length() > 0 && !isset($_REQUEST['xml']))
@@ -2436,8 +2573,9 @@  discard block
 block discarded – undo
2436 2573
 {
2437 2574
 	global $settings, $context, $modSettings;
2438 2575
 
2439
-	if (empty($context['css_files_order']))
2440
-		$context['css_files_order'] = array();
2576
+	if (empty($context['css_files_order'])) {
2577
+			$context['css_files_order'] = array();
2578
+	}
2441 2579
 
2442 2580
 	$params['seed'] = (!array_key_exists('seed', $params) || (array_key_exists('seed', $params) && $params['seed'] === true)) ? (array_key_exists('browser_cache', $modSettings) ? $modSettings['browser_cache'] : '') : (is_string($params['seed']) ? ($params['seed'] = $params['seed'][0] === '?' ? $params['seed'] : '?' . $params['seed']) : '');
2443 2581
 	$params['force_current'] = isset($params['force_current']) ? $params['force_current'] : false;
@@ -2448,8 +2586,9 @@  discard block
 block discarded – undo
2448 2586
 	$params['order_pos'] = isset($params['order_pos']) ? (int) $params['order_pos'] : 3000;
2449 2587
 
2450 2588
 	// If this is an external file, automatically set this to false.
2451
-	if (!empty($params['external']))
2452
-		$params['minimize'] = false;
2589
+	if (!empty($params['external'])) {
2590
+			$params['minimize'] = false;
2591
+	}
2453 2592
 
2454 2593
 	// Account for shorthand like admin.css?alp21 filenames
2455 2594
 	$has_seed = strpos($fileName, '.css?');
@@ -2466,16 +2605,12 @@  discard block
 block discarded – undo
2466 2605
 			{
2467 2606
 				$fileUrl = $settings['default_theme_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']);
2468 2607
 				$filePath = $settings['default_theme_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']);
2469
-			}
2470
-
2471
-			else
2608
+			} else
2472 2609
 			{
2473 2610
 				$fileUrl = false;
2474 2611
 				$filePath = false;
2475 2612
 			}
2476
-		}
2477
-
2478
-		else
2613
+		} else
2479 2614
 		{
2480 2615
 			$fileUrl = $settings[$themeRef . '_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']);
2481 2616
 			$filePath = $settings[$themeRef . '_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']);
@@ -2493,16 +2628,18 @@  discard block
 block discarded – undo
2493 2628
 	if (!empty($fileName))
2494 2629
 	{
2495 2630
 		// find a free number/position
2496
-		while (isset($context['css_files_order'][$params['order_pos']]))
2497
-			$params['order_pos']++;
2631
+		while (isset($context['css_files_order'][$params['order_pos']])) {
2632
+					$params['order_pos']++;
2633
+		}
2498 2634
 		$context['css_files_order'][$params['order_pos']] = $id;
2499 2635
 
2500 2636
 		$context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params);
2501 2637
 	}
2502 2638
 
2503
-	if (!empty($context['right_to_left']) && !empty($params['rtl']))
2504
-		loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0)));
2505
-}
2639
+	if (!empty($context['right_to_left']) && !empty($params['rtl'])) {
2640
+			loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0)));
2641
+	}
2642
+	}
2506 2643
 
2507 2644
 /**
2508 2645
  * Add a block of inline css code to be executed later
@@ -2519,8 +2656,9 @@  discard block
 block discarded – undo
2519 2656
 	global $context;
2520 2657
 
2521 2658
 	// Gotta add something...
2522
-	if (empty($css))
2523
-		return false;
2659
+	if (empty($css)) {
2660
+			return false;
2661
+	}
2524 2662
 
2525 2663
 	$context['css_header'][] = $css;
2526 2664
 }
@@ -2556,8 +2694,9 @@  discard block
 block discarded – undo
2556 2694
 	$params['validate'] = isset($params['validate']) ? $params['validate'] : true;
2557 2695
 
2558 2696
 	// If this is an external file, automatically set this to false.
2559
-	if (!empty($params['external']))
2560
-		$params['minimize'] = false;
2697
+	if (!empty($params['external'])) {
2698
+			$params['minimize'] = false;
2699
+	}
2561 2700
 
2562 2701
 	// Account for shorthand like admin.js?alp21 filenames
2563 2702
 	$has_seed = strpos($fileName, '.js?');
@@ -2574,16 +2713,12 @@  discard block
 block discarded – undo
2574 2713
 			{
2575 2714
 				$fileUrl = $settings['default_theme_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']);
2576 2715
 				$filePath = $settings['default_theme_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']);
2577
-			}
2578
-
2579
-			else
2716
+			} else
2580 2717
 			{
2581 2718
 				$fileUrl = false;
2582 2719
 				$filePath = false;
2583 2720
 			}
2584
-		}
2585
-
2586
-		else
2721
+		} else
2587 2722
 		{
2588 2723
 			$fileUrl = $settings[$themeRef . '_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']);
2589 2724
 			$filePath = $settings[$themeRef . '_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']);
@@ -2598,9 +2733,10 @@  discard block
 block discarded – undo
2598 2733
 	}
2599 2734
 
2600 2735
 	// Add it to the array for use in the template
2601
-	if (!empty($fileName))
2602
-		$context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params);
2603
-}
2736
+	if (!empty($fileName)) {
2737
+			$context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params);
2738
+	}
2739
+	}
2604 2740
 
2605 2741
 /**
2606 2742
  * Add a Javascript variable for output later (for feeding text strings and similar to JS)
@@ -2614,9 +2750,10 @@  discard block
 block discarded – undo
2614 2750
 {
2615 2751
 	global $context;
2616 2752
 
2617
-	if (!empty($key) && (!empty($value) || $value === '0'))
2618
-		$context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value;
2619
-}
2753
+	if (!empty($key) && (!empty($value) || $value === '0')) {
2754
+			$context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value;
2755
+	}
2756
+	}
2620 2757
 
2621 2758
 /**
2622 2759
  * Add a block of inline Javascript code to be executed later
@@ -2633,8 +2770,9 @@  discard block
 block discarded – undo
2633 2770
 {
2634 2771
 	global $context;
2635 2772
 
2636
-	if (empty($javascript))
2637
-		return false;
2773
+	if (empty($javascript)) {
2774
+			return false;
2775
+	}
2638 2776
 
2639 2777
 	$context['javascript_inline'][($defer === true ? 'defer' : 'standard')][] = $javascript;
2640 2778
 }
@@ -2655,15 +2793,18 @@  discard block
 block discarded – undo
2655 2793
 	static $already_loaded = array();
2656 2794
 
2657 2795
 	// Default to the user's language.
2658
-	if ($lang == '')
2659
-		$lang = isset($user_info['language']) ? $user_info['language'] : $language;
2796
+	if ($lang == '') {
2797
+			$lang = isset($user_info['language']) ? $user_info['language'] : $language;
2798
+	}
2660 2799
 
2661 2800
 	// Do we want the English version of language file as fallback?
2662
-	if (empty($modSettings['disable_language_fallback']) && $lang != 'english')
2663
-		loadLanguage($template_name, 'english', false);
2801
+	if (empty($modSettings['disable_language_fallback']) && $lang != 'english') {
2802
+			loadLanguage($template_name, 'english', false);
2803
+	}
2664 2804
 
2665
-	if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang)
2666
-		return $lang;
2805
+	if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) {
2806
+			return $lang;
2807
+	}
2667 2808
 
2668 2809
 	// Make sure we have $settings - if not we're in trouble and need to find it!
2669 2810
 	if (empty($settings['default_theme_dir']))
@@ -2674,8 +2815,9 @@  discard block
 block discarded – undo
2674 2815
 
2675 2816
 	// What theme are we in?
2676 2817
 	$theme_name = basename($settings['theme_url']);
2677
-	if (empty($theme_name))
2678
-		$theme_name = 'unknown';
2818
+	if (empty($theme_name)) {
2819
+			$theme_name = 'unknown';
2820
+	}
2679 2821
 
2680 2822
 	// For each file open it up and write it out!
2681 2823
 	foreach (explode('+', $template_name) as $template)
@@ -2717,8 +2859,9 @@  discard block
 block discarded – undo
2717 2859
 				$found = true;
2718 2860
 
2719 2861
 				// setlocale is required for basename() & pathinfo() to work properly on the selected language
2720
-				if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set']))
2721
-					setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']);
2862
+				if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) {
2863
+									setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']);
2864
+				}
2722 2865
 
2723 2866
 				break;
2724 2867
 			}
@@ -2758,8 +2901,9 @@  discard block
 block discarded – undo
2758 2901
 	}
2759 2902
 
2760 2903
 	// Keep track of what we're up to soldier.
2761
-	if ($db_show_debug === true)
2762
-		$context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')';
2904
+	if ($db_show_debug === true) {
2905
+			$context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')';
2906
+	}
2763 2907
 
2764 2908
 	// Remember what we have loaded, and in which language.
2765 2909
 	$already_loaded[$template_name] = $lang;
@@ -2805,8 +2949,9 @@  discard block
 block discarded – undo
2805 2949
 				)
2806 2950
 			);
2807 2951
 			// In the EXTREMELY unlikely event this happens, give an error message.
2808
-			if ($smcFunc['db_num_rows']($result) == 0)
2809
-				fatal_lang_error('parent_not_found', 'critical');
2952
+			if ($smcFunc['db_num_rows']($result) == 0) {
2953
+							fatal_lang_error('parent_not_found', 'critical');
2954
+			}
2810 2955
 			while ($row = $smcFunc['db_fetch_assoc']($result))
2811 2956
 			{
2812 2957
 				if (!isset($boards[$row['id_board']]))
@@ -2823,8 +2968,8 @@  discard block
 block discarded – undo
2823 2968
 					);
2824 2969
 				}
2825 2970
 				// If a moderator exists for this board, add that moderator for all children too.
2826
-				if (!empty($row['id_moderator']))
2827
-					foreach ($boards as $id => $dummy)
2971
+				if (!empty($row['id_moderator'])) {
2972
+									foreach ($boards as $id => $dummy)
2828 2973
 					{
2829 2974
 						$boards[$id]['moderators'][$row['id_moderator']] = array(
2830 2975
 							'id' => $row['id_moderator'],
@@ -2832,11 +2977,12 @@  discard block
 block discarded – undo
2832 2977
 							'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'],
2833 2978
 							'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>'
2834 2979
 						);
2980
+				}
2835 2981
 					}
2836 2982
 
2837 2983
 				// If a moderator group exists for this board, add that moderator group for all children too
2838
-				if (!empty($row['id_moderator_group']))
2839
-					foreach ($boards as $id => $dummy)
2984
+				if (!empty($row['id_moderator_group'])) {
2985
+									foreach ($boards as $id => $dummy)
2840 2986
 					{
2841 2987
 						$boards[$id]['moderator_groups'][$row['id_moderator_group']] = array(
2842 2988
 							'id' => $row['id_moderator_group'],
@@ -2844,6 +2990,7 @@  discard block
 block discarded – undo
2844 2990
 							'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'],
2845 2991
 							'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>'
2846 2992
 						);
2993
+				}
2847 2994
 					}
2848 2995
 			}
2849 2996
 			$smcFunc['db_free_result']($result);
@@ -2870,23 +3017,27 @@  discard block
 block discarded – undo
2870 3017
 	if (!$use_cache || ($context['languages'] = cache_get_data('known_languages', !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600)) == null)
2871 3018
 	{
2872 3019
 		// If we don't have our ucwords function defined yet, let's load the settings data.
2873
-		if (empty($smcFunc['ucwords']))
2874
-			reloadSettings();
3020
+		if (empty($smcFunc['ucwords'])) {
3021
+					reloadSettings();
3022
+		}
2875 3023
 
2876 3024
 		// If we don't have our theme information yet, let's get it.
2877
-		if (empty($settings['default_theme_dir']))
2878
-			loadTheme(0, false);
3025
+		if (empty($settings['default_theme_dir'])) {
3026
+					loadTheme(0, false);
3027
+		}
2879 3028
 
2880 3029
 		// Default language directories to try.
2881 3030
 		$language_directories = array(
2882 3031
 			$settings['default_theme_dir'] . '/languages',
2883 3032
 		);
2884
-		if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir'])
2885
-			$language_directories[] = $settings['actual_theme_dir'] . '/languages';
3033
+		if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) {
3034
+					$language_directories[] = $settings['actual_theme_dir'] . '/languages';
3035
+		}
2886 3036
 
2887 3037
 		// We possibly have a base theme directory.
2888
-		if (!empty($settings['base_theme_dir']))
2889
-			$language_directories[] = $settings['base_theme_dir'] . '/languages';
3038
+		if (!empty($settings['base_theme_dir'])) {
3039
+					$language_directories[] = $settings['base_theme_dir'] . '/languages';
3040
+		}
2890 3041
 
2891 3042
 		// Remove any duplicates.
2892 3043
 		$language_directories = array_unique($language_directories);
@@ -2900,20 +3051,21 @@  discard block
 block discarded – undo
2900 3051
 		foreach ($language_directories as $language_dir)
2901 3052
 		{
2902 3053
 			// Can't look in here... doesn't exist!
2903
-			if (!file_exists($language_dir))
2904
-				continue;
3054
+			if (!file_exists($language_dir)) {
3055
+							continue;
3056
+			}
2905 3057
 
2906 3058
 			$dir = dir($language_dir);
2907 3059
 			while ($entry = $dir->read())
2908 3060
 			{
2909 3061
 				// Look for the index language file... For good measure skip any "index.language-utf8.php" files
2910
-				if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches))
2911
-					continue;
2912
-
2913
-				if (!empty($langList) && !empty($langList[$matches[1]]))
2914
-					$langName = $langList[$matches[1]];
3062
+				if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) {
3063
+									continue;
3064
+				}
2915 3065
 
2916
-				else
3066
+				if (!empty($langList) && !empty($langList[$matches[1]])) {
3067
+									$langName = $langList[$matches[1]];
3068
+				} else
2917 3069
 				{
2918 3070
 					$langName = $smcFunc['ucwords'](strtr($matches[1], array('_' => ' ')));
2919 3071
 
@@ -2954,12 +3106,14 @@  discard block
 block discarded – undo
2954 3106
 		}
2955 3107
 
2956 3108
 		// Do we need to store the lang list?
2957
-		if (empty($langList))
2958
-			updateSettings(array('langList' => $smcFunc['json_encode']($catchLang)));
3109
+		if (empty($langList)) {
3110
+					updateSettings(array('langList' => $smcFunc['json_encode']($catchLang)));
3111
+		}
2959 3112
 
2960 3113
 		// Let's cash in on this deal.
2961
-		if (!empty($modSettings['cache_enable']))
2962
-			cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600);
3114
+		if (!empty($modSettings['cache_enable'])) {
3115
+					cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600);
3116
+		}
2963 3117
 	}
2964 3118
 
2965 3119
 	return $context['languages'];
@@ -2982,8 +3136,9 @@  discard block
 block discarded – undo
2982 3136
 	global $modSettings, $options, $txt;
2983 3137
 	static $censor_vulgar = null, $censor_proper;
2984 3138
 
2985
-	if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '')
2986
-		return $text;
3139
+	if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') {
3140
+			return $text;
3141
+	}
2987 3142
 
2988 3143
 	// If they haven't yet been loaded, load them.
2989 3144
 	if ($censor_vulgar == null)
@@ -3014,9 +3169,9 @@  discard block
 block discarded – undo
3014 3169
 	{
3015 3170
 		$func = !empty($modSettings['censorIgnoreCase']) ? 'str_ireplace' : 'str_replace';
3016 3171
 		$text = $func($censor_vulgar, $censor_proper, $text);
3172
+	} else {
3173
+			$text = preg_replace($censor_vulgar, $censor_proper, $text);
3017 3174
 	}
3018
-	else
3019
-		$text = preg_replace($censor_vulgar, $censor_proper, $text);
3020 3175
 
3021 3176
 	return $text;
3022 3177
 }
@@ -3042,30 +3197,35 @@  discard block
 block discarded – undo
3042 3197
 	@ini_set('track_errors', '1');
3043 3198
 
3044 3199
 	// Don't include the file more than once, if $once is true.
3045
-	if ($once && in_array($filename, $templates))
3046
-		return;
3200
+	if ($once && in_array($filename, $templates)) {
3201
+			return;
3202
+	}
3047 3203
 	// Add this file to the include list, whether $once is true or not.
3048
-	else
3049
-		$templates[] = $filename;
3204
+	else {
3205
+			$templates[] = $filename;
3206
+	}
3050 3207
 
3051 3208
 
3052 3209
 	$file_found = file_exists($filename);
3053 3210
 
3054
-	if ($once && $file_found)
3055
-		require_once($filename);
3056
-	elseif ($file_found)
3057
-		require($filename);
3211
+	if ($once && $file_found) {
3212
+			require_once($filename);
3213
+	} elseif ($file_found) {
3214
+			require($filename);
3215
+	}
3058 3216
 
3059 3217
 	if ($file_found !== true)
3060 3218
 	{
3061 3219
 		ob_end_clean();
3062
-		if (!empty($modSettings['enableCompressedOutput']))
3063
-			@ob_start('ob_gzhandler');
3064
-		else
3065
-			ob_start();
3220
+		if (!empty($modSettings['enableCompressedOutput'])) {
3221
+					@ob_start('ob_gzhandler');
3222
+		} else {
3223
+					ob_start();
3224
+		}
3066 3225
 
3067
-		if (isset($_GET['debug']))
3068
-			header('content-type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
3226
+		if (isset($_GET['debug'])) {
3227
+					header('content-type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
3228
+		}
3069 3229
 
3070 3230
 		// Don't cache error pages!!
3071 3231
 		header('expires: Mon, 26 Jul 1997 05:00:00 GMT');
@@ -3084,12 +3244,13 @@  discard block
 block discarded – undo
3084 3244
 		echo '<!DOCTYPE html>
3085 3245
 <html', !empty($context['right_to_left']) ? ' dir="rtl"' : '', '>
3086 3246
 	<head>';
3087
-		if (isset($context['character_set']))
3088
-			echo '
3247
+		if (isset($context['character_set'])) {
3248
+					echo '
3089 3249
 		<meta charset="', $context['character_set'], '">';
3250
+		}
3090 3251
 
3091
-		if (!empty($maintenance) && !allowedTo('admin_forum'))
3092
-			echo '
3252
+		if (!empty($maintenance) && !allowedTo('admin_forum')) {
3253
+					echo '
3093 3254
 		<title>', $mtitle, '</title>
3094 3255
 	</head>
3095 3256
 	<body>
@@ -3097,8 +3258,8 @@  discard block
 block discarded – undo
3097 3258
 		', $mmessage, '
3098 3259
 	</body>
3099 3260
 </html>';
3100
-		elseif (!allowedTo('admin_forum'))
3101
-			echo '
3261
+		} elseif (!allowedTo('admin_forum')) {
3262
+					echo '
3102 3263
 		<title>', $txt['template_parse_error'], '</title>
3103 3264
 	</head>
3104 3265
 	<body>
@@ -3106,14 +3267,16 @@  discard block
 block discarded – undo
3106 3267
 		', $txt['template_parse_error_message'], '
3107 3268
 	</body>
3108 3269
 </html>';
3109
-		else
3270
+		} else
3110 3271
 		{
3111 3272
 			$error = fetch_web_data($boardurl . strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => '')));
3112 3273
 			$error_array = error_get_last();
3113
-			if (empty($error) && ini_get('track_errors') && !empty($error_array))
3114
-				$error = $error_array['message'];
3115
-			if (empty($error))
3116
-				$error = $txt['template_parse_errmsg'];
3274
+			if (empty($error) && ini_get('track_errors') && !empty($error_array)) {
3275
+							$error = $error_array['message'];
3276
+			}
3277
+			if (empty($error)) {
3278
+							$error = $txt['template_parse_errmsg'];
3279
+			}
3117 3280
 
3118 3281
 			$error = strtr($error, array('<b>' => '<strong>', '</b>' => '</strong>'));
3119 3282
 
@@ -3124,11 +3287,12 @@  discard block
 block discarded – undo
3124 3287
 		<h3>', $txt['template_parse_error'], '</h3>
3125 3288
 		', sprintf($txt['template_parse_error_details'], strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => '')));
3126 3289
 
3127
-			if (!empty($error))
3128
-				echo '
3290
+			if (!empty($error)) {
3291
+							echo '
3129 3292
 		<hr>
3130 3293
 
3131 3294
 		<div style="margin: 0 20px;"><pre>', strtr(strtr($error, array('<strong>' . $boarddir => '<strong>...', '<strong>' . strtr($boarddir, '\\', '/') => '<strong>...')), '\\', '/'), '</pre></div>';
3295
+			}
3132 3296
 
3133 3297
 			// I know, I know... this is VERY COMPLICATED.  Still, it's good.
3134 3298
 			if (preg_match('~ <strong>(\d+)</strong><br( /)?' . '>$~i', $error, $match) != 0)
@@ -3138,10 +3302,11 @@  discard block
 block discarded – undo
3138 3302
 				$data2 = preg_split('~\<br( /)?\>~', $data2);
3139 3303
 
3140 3304
 				// Fix the PHP code stuff...
3141
-				if (!isBrowser('gecko'))
3142
-					$data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2);
3143
-				else
3144
-					$data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2);
3305
+				if (!isBrowser('gecko')) {
3306
+									$data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2);
3307
+				} else {
3308
+									$data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2);
3309
+				}
3145 3310
 
3146 3311
 				// Now we get to work around a bug in PHP where it doesn't escape <br>s!
3147 3312
 				$j = -1;
@@ -3149,8 +3314,9 @@  discard block
 block discarded – undo
3149 3314
 				{
3150 3315
 					$j++;
3151 3316
 
3152
-					if (substr_count($line, '<br>') == 0)
3153
-						continue;
3317
+					if (substr_count($line, '<br>') == 0) {
3318
+											continue;
3319
+					}
3154 3320
 
3155 3321
 					$n = substr_count($line, '<br>');
3156 3322
 					for ($i = 0; $i < $n; $i++)
@@ -3169,38 +3335,42 @@  discard block
 block discarded – undo
3169 3335
 				// Figure out what the color coding was before...
3170 3336
 				$line = max($match[1] - 9, 1);
3171 3337
 				$last_line = '';
3172
-				for ($line2 = $line - 1; $line2 > 1; $line2--)
3173
-					if (strpos($data2[$line2], '<') !== false)
3338
+				for ($line2 = $line - 1; $line2 > 1; $line2--) {
3339
+									if (strpos($data2[$line2], '<') !== false)
3174 3340
 					{
3175 3341
 						if (preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line2], $color_match) != 0)
3176 3342
 							$last_line = $color_match[1];
3343
+				}
3177 3344
 						break;
3178 3345
 					}
3179 3346
 
3180 3347
 				// Show the relevant lines...
3181 3348
 				for ($n = min($match[1] + 4, count($data2) + 1); $line <= $n; $line++)
3182 3349
 				{
3183
-					if ($line == $match[1])
3184
-						echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">';
3350
+					if ($line == $match[1]) {
3351
+											echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">';
3352
+					}
3185 3353
 
3186 3354
 					echo '<span style="color: black;">', sprintf('%' . strlen($n) . 's', $line), ':</span> ';
3187
-					if (isset($data2[$line]) && $data2[$line] != '')
3188
-						echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line];
3355
+					if (isset($data2[$line]) && $data2[$line] != '') {
3356
+											echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line];
3357
+					}
3189 3358
 
3190 3359
 					if (isset($data2[$line]) && preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line], $color_match) != 0)
3191 3360
 					{
3192 3361
 						$last_line = $color_match[1];
3193 3362
 						echo '</', substr($last_line, 1, 4), '>';
3363
+					} elseif ($last_line != '' && strpos($data2[$line], '<') !== false) {
3364
+											$last_line = '';
3365
+					} elseif ($last_line != '' && $data2[$line] != '') {
3366
+											echo '</', substr($last_line, 1, 4), '>';
3194 3367
 					}
3195
-					elseif ($last_line != '' && strpos($data2[$line], '<') !== false)
3196
-						$last_line = '';
3197
-					elseif ($last_line != '' && $data2[$line] != '')
3198
-						echo '</', substr($last_line, 1, 4), '>';
3199 3368
 
3200
-					if ($line == $match[1])
3201
-						echo '</pre></div><pre style="margin: 0;">';
3202
-					else
3203
-						echo "\n";
3369
+					if ($line == $match[1]) {
3370
+											echo '</pre></div><pre style="margin: 0;">';
3371
+					} else {
3372
+											echo "\n";
3373
+					}
3204 3374
 				}
3205 3375
 
3206 3376
 				echo '</pre></div>';
@@ -3224,8 +3394,9 @@  discard block
 block discarded – undo
3224 3394
 	global $db_type, $db_name, $ssi_db_user, $ssi_db_passwd, $sourcedir, $db_prefix, $db_port, $db_mb4;
3225 3395
 
3226 3396
 	// Figure out what type of database we are using.
3227
-	if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php'))
3228
-		$db_type = 'mysql';
3397
+	if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) {
3398
+			$db_type = 'mysql';
3399
+	}
3229 3400
 
3230 3401
 	// Load the file for the database.
3231 3402
 	require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
@@ -3233,11 +3404,13 @@  discard block
 block discarded – undo
3233 3404
 	$db_options = array();
3234 3405
 
3235 3406
 	// Add in the port if needed
3236
-	if (!empty($db_port))
3237
-		$db_options['port'] = $db_port;
3407
+	if (!empty($db_port)) {
3408
+			$db_options['port'] = $db_port;
3409
+	}
3238 3410
 
3239
-	if (!empty($db_mb4))
3240
-		$db_options['db_mb4'] = $db_mb4;
3411
+	if (!empty($db_mb4)) {
3412
+			$db_options['db_mb4'] = $db_mb4;
3413
+	}
3241 3414
 
3242 3415
 	// If we are in SSI try them first, but don't worry if it doesn't work, we have the normal username and password we can use.
3243 3416
 	if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd))
@@ -3256,13 +3429,15 @@  discard block
 block discarded – undo
3256 3429
 	}
3257 3430
 
3258 3431
 	// Safe guard here, if there isn't a valid connection lets put a stop to it.
3259
-	if (!$db_connection)
3260
-		display_db_error();
3432
+	if (!$db_connection) {
3433
+			display_db_error();
3434
+	}
3261 3435
 
3262 3436
 	// If in SSI mode fix up the prefix.
3263
-	if (SMF == 'SSI')
3264
-		db_fix_prefix($db_prefix, $db_name);
3265
-}
3437
+	if (SMF == 'SSI') {
3438
+			db_fix_prefix($db_prefix, $db_name);
3439
+	}
3440
+	}
3266 3441
 
3267 3442
 /**
3268 3443
  * Try to load up a supported caching method. This is saved in $cacheAPI if we are not overriding it.
@@ -3276,10 +3451,11 @@  discard block
 block discarded – undo
3276 3451
 	global $sourcedir, $cacheAPI, $cache_accelerator;
3277 3452
 
3278 3453
 	// Not overriding this and we have a cacheAPI, send it back.
3279
-	if (empty($overrideCache) && is_object($cacheAPI))
3280
-		return $cacheAPI;
3281
-	elseif (is_null($cacheAPI))
3282
-		$cacheAPI = false;
3454
+	if (empty($overrideCache) && is_object($cacheAPI)) {
3455
+			return $cacheAPI;
3456
+	} elseif (is_null($cacheAPI)) {
3457
+			$cacheAPI = false;
3458
+	}
3283 3459
 
3284 3460
 	// Make sure our class is in session.
3285 3461
 	require_once($sourcedir . '/Class-CacheAPI.php');
@@ -3300,8 +3476,9 @@  discard block
 block discarded – undo
3300 3476
 		if (!$testAPI->isSupported())
3301 3477
 		{
3302 3478
 			// Can we save ourselves?
3303
-			if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf')
3304
-				return loadCacheAccelerator(null, false);
3479
+			if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') {
3480
+							return loadCacheAccelerator(null, false);
3481
+			}
3305 3482
 			return false;
3306 3483
 		}
3307 3484
 
@@ -3313,9 +3490,9 @@  discard block
 block discarded – undo
3313 3490
 		{
3314 3491
 			$cacheAPI = $testAPI;
3315 3492
 			return $cacheAPI;
3493
+		} else {
3494
+					return $testAPI;
3316 3495
 		}
3317
-		else
3318
-			return $testAPI;
3319 3496
 	}
3320 3497
 }
3321 3498
 
@@ -3335,8 +3512,9 @@  discard block
 block discarded – undo
3335 3512
 
3336 3513
 	// @todo Why are we doing this if caching is disabled?
3337 3514
 
3338
-	if (function_exists('call_integration_hook'))
3339
-		call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level));
3515
+	if (function_exists('call_integration_hook')) {
3516
+			call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level));
3517
+	}
3340 3518
 
3341 3519
 	/* Refresh the cache if either:
3342 3520
 		1. Caching is disabled.
@@ -3350,16 +3528,19 @@  discard block
 block discarded – undo
3350 3528
 		require_once($sourcedir . '/' . $file);
3351 3529
 		$cache_block = call_user_func_array($function, $params);
3352 3530
 
3353
-		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level)
3354
-			cache_put_data($key, $cache_block, $cache_block['expires'] - time());
3531
+		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) {
3532
+					cache_put_data($key, $cache_block, $cache_block['expires'] - time());
3533
+		}
3355 3534
 	}
3356 3535
 
3357 3536
 	// Some cached data may need a freshening up after retrieval.
3358
-	if (!empty($cache_block['post_retri_eval']))
3359
-		eval($cache_block['post_retri_eval']);
3537
+	if (!empty($cache_block['post_retri_eval'])) {
3538
+			eval($cache_block['post_retri_eval']);
3539
+	}
3360 3540
 
3361
-	if (function_exists('call_integration_hook'))
3362
-		call_integration_hook('post_cache_quick_get', array(&$cache_block));
3541
+	if (function_exists('call_integration_hook')) {
3542
+			call_integration_hook('post_cache_quick_get', array(&$cache_block));
3543
+	}
3363 3544
 
3364 3545
 	return $cache_block['data'];
3365 3546
 }
@@ -3386,8 +3567,9 @@  discard block
 block discarded – undo
3386 3567
 	global $smcFunc, $cache_enable, $cacheAPI;
3387 3568
 	global $cache_hits, $cache_count, $db_show_debug;
3388 3569
 
3389
-	if (empty($cache_enable) || empty($cacheAPI))
3390
-		return;
3570
+	if (empty($cache_enable) || empty($cacheAPI)) {
3571
+			return;
3572
+	}
3391 3573
 
3392 3574
 	$cache_count = isset($cache_count) ? $cache_count + 1 : 1;
3393 3575
 	if (isset($db_show_debug) && $db_show_debug === true)
@@ -3400,12 +3582,14 @@  discard block
 block discarded – undo
3400 3582
 	$value = $value === null ? null : (isset($smcFunc['json_encode']) ? $smcFunc['json_encode']($value) : json_encode($value));
3401 3583
 	$cacheAPI->putData($key, $value, $ttl);
3402 3584
 
3403
-	if (function_exists('call_integration_hook'))
3404
-		call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl));
3585
+	if (function_exists('call_integration_hook')) {
3586
+			call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl));
3587
+	}
3405 3588
 
3406
-	if (isset($db_show_debug) && $db_show_debug === true)
3407
-		$cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));
3408
-}
3589
+	if (isset($db_show_debug) && $db_show_debug === true) {
3590
+			$cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));
3591
+	}
3592
+	}
3409 3593
 
3410 3594
 /**
3411 3595
  * Gets the value from the cache specified by key, so long as it is not older than ttl seconds.
@@ -3421,8 +3605,9 @@  discard block
 block discarded – undo
3421 3605
 	global $smcFunc, $cache_enable, $cacheAPI;
3422 3606
 	global $cache_hits, $cache_count, $cache_misses, $cache_count_misses, $db_show_debug;
3423 3607
 
3424
-	if (empty($cache_enable) || empty($cacheAPI))
3425
-		return;
3608
+	if (empty($cache_enable) || empty($cacheAPI)) {
3609
+			return;
3610
+	}
3426 3611
 
3427 3612
 	$cache_count = isset($cache_count) ? $cache_count + 1 : 1;
3428 3613
 	if (isset($db_show_debug) && $db_show_debug === true)
@@ -3442,16 +3627,18 @@  discard block
 block discarded – undo
3442 3627
 
3443 3628
 		if (empty($value))
3444 3629
 		{
3445
-			if (!is_array($cache_misses))
3446
-				$cache_misses = array();
3630
+			if (!is_array($cache_misses)) {
3631
+							$cache_misses = array();
3632
+			}
3447 3633
 
3448 3634
 			$cache_count_misses = isset($cache_count_misses) ? $cache_count_misses + 1 : 1;
3449 3635
 			$cache_misses[$cache_count_misses] = array('k' => $original_key, 'd' => 'get');
3450 3636
 		}
3451 3637
 	}
3452 3638
 
3453
-	if (function_exists('call_integration_hook') && isset($value))
3454
-		call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value));
3639
+	if (function_exists('call_integration_hook') && isset($value)) {
3640
+			call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value));
3641
+	}
3455 3642
 
3456 3643
 	return empty($value) ? null : (isset($smcFunc['json_decode']) ? $smcFunc['json_decode']($value, true) : smf_json_decode($value, true));
3457 3644
 }
@@ -3473,8 +3660,9 @@  discard block
 block discarded – undo
3473 3660
 	global $cacheAPI;
3474 3661
 
3475 3662
 	// If we can't get to the API, can't do this.
3476
-	if (empty($cacheAPI))
3477
-		return;
3663
+	if (empty($cacheAPI)) {
3664
+			return;
3665
+	}
3478 3666
 
3479 3667
 	// Ask the API to do the heavy lifting. cleanCache also calls invalidateCache to be sure.
3480 3668
 	$cacheAPI->cleanCache($type);
@@ -3499,8 +3687,9 @@  discard block
 block discarded – undo
3499 3687
 	global $modSettings, $smcFunc, $image_proxy_enabled, $user_info;
3500 3688
 
3501 3689
 	// Come on!
3502
-	if (empty($data))
3503
-		return array();
3690
+	if (empty($data)) {
3691
+			return array();
3692
+	}
3504 3693
 
3505 3694
 	// Set a nice default var.
3506 3695
 	$image = '';
@@ -3508,11 +3697,11 @@  discard block
 block discarded – undo
3508 3697
 	// Gravatar has been set as mandatory!
3509 3698
 	if (!empty($modSettings['gravatarOverride']))
3510 3699
 	{
3511
-		if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://'))
3512
-			$image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11));
3513
-
3514
-		else if (!empty($data['email']))
3515
-			$image = get_gravatar_url($data['email']);
3700
+		if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) {
3701
+					$image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11));
3702
+		} else if (!empty($data['email'])) {
3703
+					$image = get_gravatar_url($data['email']);
3704
+		}
3516 3705
 	}
3517 3706
 
3518 3707
 	// Look if the user has a gravatar field or has set an external url as avatar.
@@ -3524,54 +3713,60 @@  discard block
 block discarded – undo
3524 3713
 			// Gravatar.
3525 3714
 			if (stristr($data['avatar'], 'gravatar://'))
3526 3715
 			{
3527
-				if ($data['avatar'] == 'gravatar://')
3528
-					$image = get_gravatar_url($data['email']);
3529
-
3530
-				elseif (!empty($modSettings['gravatarAllowExtraEmail']))
3531
-					$image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11));
3716
+				if ($data['avatar'] == 'gravatar://') {
3717
+									$image = get_gravatar_url($data['email']);
3718
+				} elseif (!empty($modSettings['gravatarAllowExtraEmail'])) {
3719
+									$image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11));
3720
+				}
3532 3721
 			}
3533 3722
 
3534 3723
 			// External url.
3535 3724
 			else
3536 3725
 			{
3537 3726
 				// Using ssl?
3538
-				if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false && empty($user_info['possibly_robot']))
3539
-					$image = get_proxied_url($data['avatar']);
3727
+				if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) {
3728
+									$image = get_proxied_url($data['avatar']);
3729
+				}
3540 3730
 
3541 3731
 				// Just a plain external url.
3542
-				else
3543
-					$image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar'];
3732
+				else {
3733
+									$image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar'];
3734
+				}
3544 3735
 			}
3545 3736
 		}
3546 3737
 
3547 3738
 		// Perhaps this user has an attachment as avatar...
3548
-		else if (!empty($data['filename']))
3549
-			$image = $modSettings['custom_avatar_url'] . '/' . $data['filename'];
3739
+		else if (!empty($data['filename'])) {
3740
+					$image = $modSettings['custom_avatar_url'] . '/' . $data['filename'];
3741
+		}
3550 3742
 
3551 3743
 		// Right... no avatar... use our default image.
3552
-		else
3553
-			$image = $modSettings['avatar_url'] . '/default.png';
3744
+		else {
3745
+					$image = $modSettings['avatar_url'] . '/default.png';
3746
+		}
3554 3747
 	}
3555 3748
 
3556 3749
 	call_integration_hook('integrate_set_avatar_data', array(&$image, &$data));
3557 3750
 
3558 3751
 	// At this point in time $image has to be filled unless you chose to force gravatar and the user doesn't have the needed data to retrieve it... thus a check for !empty() is still needed.
3559
-	if (!empty($image))
3560
-		return array(
3752
+	if (!empty($image)) {
3753
+			return array(
3561 3754
 			'name' => !empty($data['avatar']) ? $data['avatar'] : '',
3562 3755
 			'image' => '<img class="avatar" src="' . $image . '" />',
3563 3756
 			'href' => $image,
3564 3757
 			'url' => $image,
3565 3758
 		);
3759
+	}
3566 3760
 
3567 3761
 	// Fallback to make life easier for everyone...
3568
-	else
3569
-		return array(
3762
+	else {
3763
+			return array(
3570 3764
 			'name' => '',
3571 3765
 			'image' => '',
3572 3766
 			'href' => '',
3573 3767
 			'url' => '',
3574 3768
 		);
3575
-}
3769
+	}
3770
+	}
3576 3771
 
3577 3772
 ?>
3578 3773
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/BoardIndex.php 1 patch
Braces   +20 added lines, -13 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 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
  * This function shows the board index.
@@ -34,8 +35,9 @@  discard block
 block discarded – undo
34 35
 	$context['canonical_url'] = $scripturl;
35 36
 
36 37
 	// Do not let search engines index anything if there is a random thing in $_GET.
37
-	if (!empty($_GET))
38
-		$context['robot_no_index'] = true;
38
+	if (!empty($_GET)) {
39
+			$context['robot_no_index'] = true;
40
+	}
39 41
 
40 42
 	// Retrieve the categories and boards.
41 43
 	require_once($sourcedir . '/Subs-BoardIndex.php');
@@ -62,11 +64,12 @@  discard block
 block discarded – undo
62 64
 			$context['latest_posts'] = cache_quick_get('boardindex-latest_posts:' . md5($user_info['query_wanna_see_board'] . $user_info['language']), 'Subs-Recent.php', 'cache_getLastPosts', array($latestPostOptions));
63 65
 		}
64 66
 
65
-		if (!empty($context['latest_posts']) || !empty($context['latest_post']))
66
-			$context['info_center'][] = array(
67
+		if (!empty($context['latest_posts']) || !empty($context['latest_post'])) {
68
+					$context['info_center'][] = array(
67 69
 				'tpl' => 'recent',
68 70
 				'txt' => 'recent_posts',
69 71
 			);
72
+		}
70 73
 	}
71 74
 
72 75
 	// Load the calendar?
@@ -87,20 +90,22 @@  discard block
 block discarded – undo
87 90
 		// This is used to show the "how-do-I-edit" help.
88 91
 		$context['calendar_can_edit'] = allowedTo('calendar_edit_any');
89 92
 
90
-		if (!empty($context['show_calendar']))
91
-			$context['info_center'][] = array(
93
+		if (!empty($context['show_calendar'])) {
94
+					$context['info_center'][] = array(
92 95
 				'tpl' => 'calendar',
93 96
 				'txt' => $context['calendar_only_today'] ? 'calendar_today' : 'calendar_upcoming',
94 97
 			);
98
+		}
95 99
 	}
96 100
 
97 101
 	// And stats.
98 102
 	$context['show_stats'] = allowedTo('view_stats') && !empty($modSettings['trackStats']);
99
-	if ($settings['show_stats_index'])
100
-		$context['info_center'][] = array(
103
+	if ($settings['show_stats_index']) {
104
+			$context['info_center'][] = array(
101 105
 				'tpl' => 'stats',
102 106
 				'txt' => 'forum_stats',
103 107
 			);
108
+	}
104 109
 
105 110
 	// Now the online stuff
106 111
 	require_once($sourcedir . '/Subs-MembersOnline.php');
@@ -118,12 +123,14 @@  discard block
 block discarded – undo
118 123
 			);
119 124
 
120 125
 	// Track most online statistics? (Subs-MembersOnline.php)
121
-	if (!empty($modSettings['trackStats']))
122
-		trackStatsUsersOnline($context['num_guests'] + $context['num_spiders'] + $context['num_users_online']);
126
+	if (!empty($modSettings['trackStats'])) {
127
+			trackStatsUsersOnline($context['num_guests'] + $context['num_spiders'] + $context['num_users_online']);
128
+	}
123 129
 
124 130
 	// Are we showing all membergroups on the board index?
125
-	if (!empty($settings['show_group_key']))
126
-		$context['membergroups'] = cache_quick_get('membergroup_list', 'Subs-Membergroups.php', 'cache_getMembergroupList', array());
131
+	if (!empty($settings['show_group_key'])) {
132
+			$context['membergroups'] = cache_quick_get('membergroup_list', 'Subs-Membergroups.php', 'cache_getMembergroupList', array());
133
+	}
127 134
 
128 135
 	// And back to normality.
129 136
 	$context['page_title'] = sprintf($txt['forum_index'], $context['forum_name']);
Please login to merge, or discard this patch.
Sources/Security.php 1 patch
Braces   +255 added lines, -197 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
  * Check if the user is who he/she says he is
@@ -42,12 +43,14 @@  discard block
 block discarded – undo
42 43
 	$refreshTime = isset($_GET['xml']) ? 4200 : 3600;
43 44
 
44 45
 	// Is the security option off?
45
-	if (!empty($modSettings['securityDisable' . ($type != 'admin' ? '_' . $type : '')]))
46
-		return;
46
+	if (!empty($modSettings['securityDisable' . ($type != 'admin' ? '_' . $type : '')])) {
47
+			return;
48
+	}
47 49
 
48 50
 	// Or are they already logged in?, Moderator or admin session is need for this area
49
-	if ((!empty($_SESSION[$type . '_time']) && $_SESSION[$type . '_time'] + $refreshTime >= time()) || (!empty($_SESSION['admin_time']) && $_SESSION['admin_time'] + $refreshTime >= time()))
50
-		return;
51
+	if ((!empty($_SESSION[$type . '_time']) && $_SESSION[$type . '_time'] + $refreshTime >= time()) || (!empty($_SESSION['admin_time']) && $_SESSION['admin_time'] + $refreshTime >= time())) {
52
+			return;
53
+	}
51 54
 
52 55
 	require_once($sourcedir . '/Subs-Auth.php');
53 56
 
@@ -55,8 +58,9 @@  discard block
 block discarded – undo
55 58
 	if (isset($_POST[$type . '_pass']))
56 59
 	{
57 60
 		// Check to ensure we're forcing SSL for authentication
58
-		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn())
59
-			fatal_lang_error('login_ssl_required');
61
+		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) {
62
+					fatal_lang_error('login_ssl_required');
63
+		}
60 64
 
61 65
 		checkSession();
62 66
 
@@ -72,17 +76,19 @@  discard block
 block discarded – undo
72 76
 	}
73 77
 
74 78
 	// Better be sure to remember the real referer
75
-	if (empty($_SESSION['request_referer']))
76
-		$_SESSION['request_referer'] = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array();
77
-	elseif (empty($_POST))
78
-		unset($_SESSION['request_referer']);
79
+	if (empty($_SESSION['request_referer'])) {
80
+			$_SESSION['request_referer'] = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array();
81
+	} elseif (empty($_POST)) {
82
+			unset($_SESSION['request_referer']);
83
+	}
79 84
 
80 85
 	// Need to type in a password for that, man.
81
-	if (!isset($_GET['xml']))
82
-		adminLogin($type);
83
-	else
84
-		return 'session_verify_fail';
85
-}
86
+	if (!isset($_GET['xml'])) {
87
+			adminLogin($type);
88
+	} else {
89
+			return 'session_verify_fail';
90
+	}
91
+	}
86 92
 
87 93
 /**
88 94
  * Require a user who is logged in. (not a guest.)
@@ -96,25 +102,30 @@  discard block
 block discarded – undo
96 102
 	global $user_info, $txt, $context, $scripturl, $modSettings;
97 103
 
98 104
 	// Luckily, this person isn't a guest.
99
-	if (!$user_info['is_guest'])
100
-		return;
105
+	if (!$user_info['is_guest']) {
106
+			return;
107
+	}
101 108
 
102 109
 	// Log what they were trying to do didn't work)
103
-	if (!empty($modSettings['who_enabled']))
104
-		$_GET['error'] = 'guest_login';
110
+	if (!empty($modSettings['who_enabled'])) {
111
+			$_GET['error'] = 'guest_login';
112
+	}
105 113
 	writeLog(true);
106 114
 
107 115
 	// Just die.
108
-	if (isset($_REQUEST['xml']))
109
-		obExit(false);
116
+	if (isset($_REQUEST['xml'])) {
117
+			obExit(false);
118
+	}
110 119
 
111 120
 	// Attempt to detect if they came from dlattach.
112
-	if (SMF != 'SSI' && empty($context['theme_loaded']))
113
-		loadTheme();
121
+	if (SMF != 'SSI' && empty($context['theme_loaded'])) {
122
+			loadTheme();
123
+	}
114 124
 
115 125
 	// Never redirect to an attachment
116
-	if (strpos($_SERVER['REQUEST_URL'], 'dlattach') === false)
117
-		$_SESSION['login_url'] = $_SERVER['REQUEST_URL'];
126
+	if (strpos($_SERVER['REQUEST_URL'], 'dlattach') === false) {
127
+			$_SESSION['login_url'] = $_SERVER['REQUEST_URL'];
128
+	}
118 129
 
119 130
 	// Load the Login template and language file.
120 131
 	loadLanguage('Login');
@@ -124,8 +135,7 @@  discard block
 block discarded – undo
124 135
 	{
125 136
 		$_SESSION['login_url'] = $scripturl . '?' . $_SERVER['QUERY_STRING'];
126 137
 		redirectexit('action=login');
127
-	}
128
-	else
138
+	} else
129 139
 	{
130 140
 		loadTemplate('Login');
131 141
 		$context['sub_template'] = 'kick_guest';
@@ -155,8 +165,9 @@  discard block
 block discarded – undo
155 165
 	global $sourcedir, $cookiename, $user_settings, $smcFunc;
156 166
 
157 167
 	// You cannot be banned if you are an admin - doesn't help if you log out.
158
-	if ($user_info['is_admin'])
159
-		return;
168
+	if ($user_info['is_admin']) {
169
+			return;
170
+	}
160 171
 
161 172
 	// Only check the ban every so often. (to reduce load.)
162 173
 	if ($forceCheck || !isset($_SESSION['ban']) || empty($modSettings['banLastUpdated']) || ($_SESSION['ban']['last_checked'] < $modSettings['banLastUpdated']) || $_SESSION['ban']['id_member'] != $user_info['id'] || $_SESSION['ban']['ip'] != $user_info['ip'] || $_SESSION['ban']['ip2'] != $user_info['ip2'] || (isset($user_info['email'], $_SESSION['ban']['email']) && $_SESSION['ban']['email'] != $user_info['email']))
@@ -177,8 +188,9 @@  discard block
 block discarded – undo
177 188
 		// Check both IP addresses.
178 189
 		foreach (array('ip', 'ip2') as $ip_number)
179 190
 		{
180
-			if ($ip_number == 'ip2' && $user_info['ip2'] == $user_info['ip'])
181
-				continue;
191
+			if ($ip_number == 'ip2' && $user_info['ip2'] == $user_info['ip']) {
192
+							continue;
193
+			}
182 194
 			$ban_query[] = ' {inet:' . $ip_number . '} BETWEEN bi.ip_low and bi.ip_high';
183 195
 			$ban_query_vars[$ip_number] = $user_info[$ip_number];
184 196
 			// IP was valid, maybe there's also a hostname...
@@ -228,24 +240,28 @@  discard block
 block discarded – undo
228 240
 			// Store every type of ban that applies to you in your session.
229 241
 			while ($row = $smcFunc['db_fetch_assoc']($request))
230 242
 			{
231
-				foreach ($restrictions as $restriction)
232
-					if (!empty($row[$restriction]))
243
+				foreach ($restrictions as $restriction) {
244
+									if (!empty($row[$restriction]))
233 245
 					{
234 246
 						$_SESSION['ban'][$restriction]['reason'] = $row['reason'];
247
+				}
235 248
 						$_SESSION['ban'][$restriction]['ids'][] = $row['id_ban'];
236
-						if (!isset($_SESSION['ban']['expire_time']) || ($_SESSION['ban']['expire_time'] != 0 && ($row['expire_time'] == 0 || $row['expire_time'] > $_SESSION['ban']['expire_time'])))
237
-							$_SESSION['ban']['expire_time'] = $row['expire_time'];
249
+						if (!isset($_SESSION['ban']['expire_time']) || ($_SESSION['ban']['expire_time'] != 0 && ($row['expire_time'] == 0 || $row['expire_time'] > $_SESSION['ban']['expire_time']))) {
250
+													$_SESSION['ban']['expire_time'] = $row['expire_time'];
251
+						}
238 252
 
239
-						if (!$user_info['is_guest'] && $restriction == 'cannot_access' && ($row['id_member'] == $user_info['id'] || $row['email_address'] == $user_info['email']))
240
-							$flag_is_activated = true;
253
+						if (!$user_info['is_guest'] && $restriction == 'cannot_access' && ($row['id_member'] == $user_info['id'] || $row['email_address'] == $user_info['email'])) {
254
+													$flag_is_activated = true;
255
+						}
241 256
 					}
242 257
 			}
243 258
 			$smcFunc['db_free_result']($request);
244 259
 		}
245 260
 
246 261
 		// Mark the cannot_access and cannot_post bans as being 'hit'.
247
-		if (isset($_SESSION['ban']['cannot_access']) || isset($_SESSION['ban']['cannot_post']) || isset($_SESSION['ban']['cannot_login']))
248
-			log_ban(array_merge(isset($_SESSION['ban']['cannot_access']) ? $_SESSION['ban']['cannot_access']['ids'] : array(), isset($_SESSION['ban']['cannot_post']) ? $_SESSION['ban']['cannot_post']['ids'] : array(), isset($_SESSION['ban']['cannot_login']) ? $_SESSION['ban']['cannot_login']['ids'] : array()));
262
+		if (isset($_SESSION['ban']['cannot_access']) || isset($_SESSION['ban']['cannot_post']) || isset($_SESSION['ban']['cannot_login'])) {
263
+					log_ban(array_merge(isset($_SESSION['ban']['cannot_access']) ? $_SESSION['ban']['cannot_access']['ids'] : array(), isset($_SESSION['ban']['cannot_post']) ? $_SESSION['ban']['cannot_post']['ids'] : array(), isset($_SESSION['ban']['cannot_login']) ? $_SESSION['ban']['cannot_login']['ids'] : array()));
264
+		}
249 265
 
250 266
 		// If for whatever reason the is_activated flag seems wrong, do a little work to clear it up.
251 267
 		if ($user_info['id'] && (($user_settings['is_activated'] >= 10 && !$flag_is_activated)
@@ -260,8 +276,9 @@  discard block
 block discarded – undo
260 276
 	if (!isset($_SESSION['ban']['cannot_access']) && !empty($_COOKIE[$cookiename . '_']))
261 277
 	{
262 278
 		$bans = explode(',', $_COOKIE[$cookiename . '_']);
263
-		foreach ($bans as $key => $value)
264
-			$bans[$key] = (int) $value;
279
+		foreach ($bans as $key => $value) {
280
+					$bans[$key] = (int) $value;
281
+		}
265 282
 		$request = $smcFunc['db_query']('', '
266 283
 			SELECT bi.id_ban, bg.reason, COALESCE(bg.expire_time, 0) AS expire_time
267 284
 			FROM {db_prefix}ban_items AS bi
@@ -298,14 +315,15 @@  discard block
 block discarded – undo
298 315
 	if (isset($_SESSION['ban']['cannot_access']))
299 316
 	{
300 317
 		// We don't wanna see you!
301
-		if (!$user_info['is_guest'])
302
-			$smcFunc['db_query']('', '
318
+		if (!$user_info['is_guest']) {
319
+					$smcFunc['db_query']('', '
303 320
 				DELETE FROM {db_prefix}log_online
304 321
 				WHERE id_member = {int:current_member}',
305 322
 				array(
306 323
 					'current_member' => $user_info['id'],
307 324
 				)
308 325
 			);
326
+		}
309 327
 
310 328
 		// 'Log' the user out.  Can't have any funny business... (save the name!)
311 329
 		$old_name = isset($user_info['name']) && $user_info['name'] != '' ? $user_info['name'] : $txt['guest_title'];
@@ -391,9 +409,10 @@  discard block
 block discarded – undo
391 409
 	}
392 410
 
393 411
 	// Fix up the banning permissions.
394
-	if (isset($user_info['permissions']))
395
-		banPermissions();
396
-}
412
+	if (isset($user_info['permissions'])) {
413
+			banPermissions();
414
+	}
415
+	}
397 416
 
398 417
 /**
399 418
  * Fix permissions according to ban status.
@@ -404,8 +423,9 @@  discard block
 block discarded – undo
404 423
 	global $user_info, $sourcedir, $modSettings, $context;
405 424
 
406 425
 	// Somehow they got here, at least take away all permissions...
407
-	if (isset($_SESSION['ban']['cannot_access']))
408
-		$user_info['permissions'] = array();
426
+	if (isset($_SESSION['ban']['cannot_access'])) {
427
+			$user_info['permissions'] = array();
428
+	}
409 429
 	// Okay, well, you can watch, but don't touch a thing.
410 430
 	elseif (isset($_SESSION['ban']['cannot_post']) || (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $user_info['warning']))
411 431
 	{
@@ -447,19 +467,20 @@  discard block
 block discarded – undo
447 467
 		call_integration_hook('integrate_warn_permissions', array(&$permission_change));
448 468
 		foreach ($permission_change as $old => $new)
449 469
 		{
450
-			if (!in_array($old, $user_info['permissions']))
451
-				unset($permission_change[$old]);
452
-			else
453
-				$user_info['permissions'][] = $new;
470
+			if (!in_array($old, $user_info['permissions'])) {
471
+							unset($permission_change[$old]);
472
+			} else {
473
+							$user_info['permissions'][] = $new;
474
+			}
454 475
 		}
455 476
 		$user_info['permissions'] = array_diff($user_info['permissions'], array_keys($permission_change));
456 477
 	}
457 478
 
458 479
 	// @todo Find a better place to call this? Needs to be after permissions loaded!
459 480
 	// Finally, some bits we cache in the session because it saves queries.
460
-	if (isset($_SESSION['mc']) && $_SESSION['mc']['time'] > $modSettings['settings_updated'] && $_SESSION['mc']['id'] == $user_info['id'])
461
-		$user_info['mod_cache'] = $_SESSION['mc'];
462
-	else
481
+	if (isset($_SESSION['mc']) && $_SESSION['mc']['time'] > $modSettings['settings_updated'] && $_SESSION['mc']['id'] == $user_info['id']) {
482
+			$user_info['mod_cache'] = $_SESSION['mc'];
483
+	} else
463 484
 	{
464 485
 		require_once($sourcedir . '/Subs-Auth.php');
465 486
 		rebuildModCache();
@@ -470,14 +491,12 @@  discard block
 block discarded – undo
470 491
 	{
471 492
 		$context['open_mod_reports'] = $_SESSION['rc']['reports'];
472 493
 		$context['open_member_reports'] = $_SESSION['rc']['member_reports'];
473
-	}
474
-	elseif ($_SESSION['mc']['bq'] != '0=1')
494
+	} elseif ($_SESSION['mc']['bq'] != '0=1')
475 495
 	{
476 496
 		require_once($sourcedir . '/Subs-ReportedContent.php');
477 497
 		$context['open_mod_reports'] = recountOpenReports('posts');
478 498
 		$context['open_member_reports'] = recountOpenReports('members');
479
-	}
480
-	else
499
+	} else
481 500
 	{
482 501
 		$context['open_mod_reports'] = 0;
483 502
 		$context['open_member_reports'] = 0;
@@ -497,8 +516,9 @@  discard block
 block discarded – undo
497 516
 	global $user_info, $smcFunc;
498 517
 
499 518
 	// Don't log web accelerators, it's very confusing...
500
-	if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch')
501
-		return;
519
+	if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') {
520
+			return;
521
+	}
502 522
 
503 523
 	$smcFunc['db_insert']('',
504 524
 		'{db_prefix}log_banned',
@@ -508,8 +528,8 @@  discard block
 block discarded – undo
508 528
 	);
509 529
 
510 530
 	// One extra point for these bans.
511
-	if (!empty($ban_ids))
512
-		$smcFunc['db_query']('', '
531
+	if (!empty($ban_ids)) {
532
+			$smcFunc['db_query']('', '
513 533
 			UPDATE {db_prefix}ban_items
514 534
 			SET hits = hits + 1
515 535
 			WHERE id_ban IN ({array_int:ban_ids})',
@@ -517,7 +537,8 @@  discard block
 block discarded – undo
517 537
 				'ban_ids' => $ban_ids,
518 538
 			)
519 539
 		);
520
-}
540
+	}
541
+	}
521 542
 
522 543
 /**
523 544
  * Checks if a given email address might be banned.
@@ -533,8 +554,9 @@  discard block
 block discarded – undo
533 554
 	global $txt, $smcFunc;
534 555
 
535 556
 	// Can't ban an empty email
536
-	if (empty($email) || trim($email) == '')
537
-		return;
557
+	if (empty($email) || trim($email) == '') {
558
+			return;
559
+	}
538 560
 
539 561
 	// Let's start with the bans based on your IP/hostname/memberID...
540 562
 	$ban_ids = isset($_SESSION['ban'][$restriction]) ? $_SESSION['ban'][$restriction]['ids'] : array();
@@ -607,16 +629,18 @@  discard block
 block discarded – undo
607 629
 	if ($type == 'post')
608 630
 	{
609 631
 		$check = isset($_POST[$_SESSION['session_var']]) ? $_POST[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_POST['sc']) ? $_POST['sc'] : null);
610
-		if ($check !== $sc)
611
-			$error = 'session_timeout';
632
+		if ($check !== $sc) {
633
+					$error = 'session_timeout';
634
+		}
612 635
 	}
613 636
 
614 637
 	// How about $_GET['sesc']?
615 638
 	elseif ($type == 'get')
616 639
 	{
617 640
 		$check = isset($_GET[$_SESSION['session_var']]) ? $_GET[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_GET['sesc']) ? $_GET['sesc'] : null);
618
-		if ($check !== $sc)
619
-			$error = 'session_verify_fail';
641
+		if ($check !== $sc) {
642
+					$error = 'session_verify_fail';
643
+		}
620 644
 	}
621 645
 
622 646
 	// Or can it be in either?
@@ -624,13 +648,15 @@  discard block
 block discarded – undo
624 648
 	{
625 649
 		$check = isset($_GET[$_SESSION['session_var']]) ? $_GET[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_GET['sesc']) ? $_GET['sesc'] : (isset($_POST[$_SESSION['session_var']]) ? $_POST[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_POST['sc']) ? $_POST['sc'] : null)));
626 650
 
627
-		if ($check !== $sc)
628
-			$error = 'session_verify_fail';
651
+		if ($check !== $sc) {
652
+					$error = 'session_verify_fail';
653
+		}
629 654
 	}
630 655
 
631 656
 	// Verify that they aren't changing user agents on us - that could be bad.
632
-	if ((!isset($_SESSION['USER_AGENT']) || $_SESSION['USER_AGENT'] != $_SERVER['HTTP_USER_AGENT']) && empty($modSettings['disableCheckUA']))
633
-		$error = 'session_verify_fail';
657
+	if ((!isset($_SESSION['USER_AGENT']) || $_SESSION['USER_AGENT'] != $_SERVER['HTTP_USER_AGENT']) && empty($modSettings['disableCheckUA'])) {
658
+			$error = 'session_verify_fail';
659
+	}
634 660
 
635 661
 	// Make sure a page with session check requirement is not being prefetched.
636 662
 	if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch')
@@ -641,30 +667,35 @@  discard block
 block discarded – undo
641 667
 	}
642 668
 
643 669
 	// Check the referring site - it should be the same server at least!
644
-	if (isset($_SESSION['request_referer']))
645
-		$referrer = $_SESSION['request_referer'];
646
-	else
647
-		$referrer = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array();
670
+	if (isset($_SESSION['request_referer'])) {
671
+			$referrer = $_SESSION['request_referer'];
672
+	} else {
673
+			$referrer = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array();
674
+	}
648 675
 	if (!empty($referrer['host']))
649 676
 	{
650
-		if (strpos($_SERVER['HTTP_HOST'], ':') !== false)
651
-			$real_host = substr($_SERVER['HTTP_HOST'], 0, strpos($_SERVER['HTTP_HOST'], ':'));
652
-		else
653
-			$real_host = $_SERVER['HTTP_HOST'];
677
+		if (strpos($_SERVER['HTTP_HOST'], ':') !== false) {
678
+					$real_host = substr($_SERVER['HTTP_HOST'], 0, strpos($_SERVER['HTTP_HOST'], ':'));
679
+		} else {
680
+					$real_host = $_SERVER['HTTP_HOST'];
681
+		}
654 682
 
655 683
 		$parsed_url = parse_url($boardurl);
656 684
 
657 685
 		// Are global cookies on?  If so, let's check them ;).
658 686
 		if (!empty($modSettings['globalCookies']))
659 687
 		{
660
-			if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $parsed_url['host'], $parts) == 1)
661
-				$parsed_url['host'] = $parts[1];
688
+			if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $parsed_url['host'], $parts) == 1) {
689
+							$parsed_url['host'] = $parts[1];
690
+			}
662 691
 
663
-			if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $referrer['host'], $parts) == 1)
664
-				$referrer['host'] = $parts[1];
692
+			if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $referrer['host'], $parts) == 1) {
693
+							$referrer['host'] = $parts[1];
694
+			}
665 695
 
666
-			if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $real_host, $parts) == 1)
667
-				$real_host = $parts[1];
696
+			if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $real_host, $parts) == 1) {
697
+							$real_host = $parts[1];
698
+			}
668 699
 		}
669 700
 
670 701
 		// Okay: referrer must either match parsed_url or real_host.
@@ -682,12 +713,14 @@  discard block
 block discarded – undo
682 713
 		$log_error = true;
683 714
 	}
684 715
 
685
-	if (strtolower($_SERVER['HTTP_USER_AGENT']) == 'hacker')
686
-		fatal_error('Sound the alarm!  It\'s a hacker!  Close the castle gates!!', false);
716
+	if (strtolower($_SERVER['HTTP_USER_AGENT']) == 'hacker') {
717
+			fatal_error('Sound the alarm!  It\'s a hacker!  Close the castle gates!!', false);
718
+	}
687 719
 
688 720
 	// Everything is ok, return an empty string.
689
-	if (!isset($error))
690
-		return '';
721
+	if (!isset($error)) {
722
+			return '';
723
+	}
691 724
 	// A session error occurred, show the error.
692 725
 	elseif ($is_fatal)
693 726
 	{
@@ -696,13 +729,14 @@  discard block
 block discarded – undo
696 729
 			ob_end_clean();
697 730
 			header('HTTP/1.1 403 Forbidden - Session timeout');
698 731
 			die;
732
+		} else {
733
+					fatal_lang_error($error, isset($log_error) ? 'user' : false);
699 734
 		}
700
-		else
701
-			fatal_lang_error($error, isset($log_error) ? 'user' : false);
702 735
 	}
703 736
 	// A session error occurred, return the error to the calling function.
704
-	else
705
-		return $error;
737
+	else {
738
+			return $error;
739
+	}
706 740
 
707 741
 	// We really should never fall through here, for very important reasons.  Let's make sure.
708 742
 	trigger_error('Hacking attempt...', E_USER_ERROR);
@@ -718,10 +752,9 @@  discard block
 block discarded – undo
718 752
 {
719 753
 	global $modSettings;
720 754
 
721
-	if (isset($_GET['confirm']) && isset($_SESSION['confirm_' . $action]) && md5($_GET['confirm'] . $_SERVER['HTTP_USER_AGENT']) == $_SESSION['confirm_' . $action])
722
-		return true;
723
-
724
-	else
755
+	if (isset($_GET['confirm']) && isset($_SESSION['confirm_' . $action]) && md5($_GET['confirm'] . $_SERVER['HTTP_USER_AGENT']) == $_SESSION['confirm_' . $action]) {
756
+			return true;
757
+	} else
725 758
 	{
726 759
 		$token = md5(mt_rand() . session_id() . (string) microtime() . $modSettings['rand_seed']);
727 760
 		$_SESSION['confirm_' . $action] = md5($token . $_SERVER['HTTP_USER_AGENT']);
@@ -772,9 +805,9 @@  discard block
 block discarded – undo
772 805
 			$return = $_SESSION['token'][$type . '-' . $action][3];
773 806
 			unset($_SESSION['token'][$type . '-' . $action]);
774 807
 			return $return;
808
+		} else {
809
+					return '';
775 810
 		}
776
-		else
777
-			return '';
778 811
 	}
779 812
 
780 813
 	// This nasty piece of code validates a token.
@@ -805,12 +838,14 @@  discard block
 block discarded – undo
805 838
 		fatal_lang_error('token_verify_fail', false);
806 839
 	}
807 840
 	// Remove this token as its useless
808
-	else
809
-		unset($_SESSION['token'][$type . '-' . $action]);
841
+	else {
842
+			unset($_SESSION['token'][$type . '-' . $action]);
843
+	}
810 844
 
811 845
 	// Randomly check if we should remove some older tokens.
812
-	if (mt_rand(0, 138) == 23)
813
-		cleanTokens();
846
+	if (mt_rand(0, 138) == 23) {
847
+			cleanTokens();
848
+	}
814 849
 
815 850
 	return false;
816 851
 }
@@ -825,14 +860,16 @@  discard block
 block discarded – undo
825 860
 function cleanTokens($complete = false)
826 861
 {
827 862
 	// We appreciate cleaning up after yourselves.
828
-	if (!isset($_SESSION['token']))
829
-		return;
863
+	if (!isset($_SESSION['token'])) {
864
+			return;
865
+	}
830 866
 
831 867
 	// Clean up tokens, trying to give enough time still.
832
-	foreach ($_SESSION['token'] as $key => $data)
833
-		if ($data[2] + 10800 < time() || $complete)
868
+	foreach ($_SESSION['token'] as $key => $data) {
869
+			if ($data[2] + 10800 < time() || $complete)
834 870
 			unset($_SESSION['token'][$key]);
835
-}
871
+	}
872
+	}
836 873
 
837 874
 /**
838 875
  * Check whether a form has been submitted twice.
@@ -850,37 +887,40 @@  discard block
 block discarded – undo
850 887
 {
851 888
 	global $context;
852 889
 
853
-	if (!isset($_SESSION['forms']))
854
-		$_SESSION['forms'] = array();
890
+	if (!isset($_SESSION['forms'])) {
891
+			$_SESSION['forms'] = array();
892
+	}
855 893
 
856 894
 	// Register a form number and store it in the session stack. (use this on the page that has the form.)
857 895
 	if ($action == 'register')
858 896
 	{
859 897
 		$context['form_sequence_number'] = 0;
860
-		while (empty($context['form_sequence_number']) || in_array($context['form_sequence_number'], $_SESSION['forms']))
861
-			$context['form_sequence_number'] = mt_rand(1, 16000000);
898
+		while (empty($context['form_sequence_number']) || in_array($context['form_sequence_number'], $_SESSION['forms'])) {
899
+					$context['form_sequence_number'] = mt_rand(1, 16000000);
900
+		}
862 901
 	}
863 902
 	// Check whether the submitted number can be found in the session.
864 903
 	elseif ($action == 'check')
865 904
 	{
866
-		if (!isset($_REQUEST['seqnum']))
867
-			return true;
868
-		elseif (!in_array($_REQUEST['seqnum'], $_SESSION['forms']))
905
+		if (!isset($_REQUEST['seqnum'])) {
906
+					return true;
907
+		} elseif (!in_array($_REQUEST['seqnum'], $_SESSION['forms']))
869 908
 		{
870 909
 			$_SESSION['forms'][] = (int) $_REQUEST['seqnum'];
871 910
 			return true;
911
+		} elseif ($is_fatal) {
912
+					fatal_lang_error('error_form_already_submitted', false);
913
+		} else {
914
+					return false;
872 915
 		}
873
-		elseif ($is_fatal)
874
-			fatal_lang_error('error_form_already_submitted', false);
875
-		else
876
-			return false;
877 916
 	}
878 917
 	// Don't check, just free the stack number.
879
-	elseif ($action == 'free' && isset($_REQUEST['seqnum']) && in_array($_REQUEST['seqnum'], $_SESSION['forms']))
880
-		$_SESSION['forms'] = array_diff($_SESSION['forms'], array($_REQUEST['seqnum']));
881
-	elseif ($action != 'free')
882
-		trigger_error('checkSubmitOnce(): Invalid action \'' . $action . '\'', E_USER_WARNING);
883
-}
918
+	elseif ($action == 'free' && isset($_REQUEST['seqnum']) && in_array($_REQUEST['seqnum'], $_SESSION['forms'])) {
919
+			$_SESSION['forms'] = array_diff($_SESSION['forms'], array($_REQUEST['seqnum']));
920
+	} elseif ($action != 'free') {
921
+			trigger_error('checkSubmitOnce(): Invalid action \'' . $action . '\'', E_USER_WARNING);
922
+	}
923
+	}
884 924
 
885 925
 /**
886 926
  * Check the user's permissions.
@@ -899,16 +939,19 @@  discard block
 block discarded – undo
899 939
 	global $user_info, $smcFunc;
900 940
 
901 941
 	// You're always allowed to do nothing. (unless you're a working man, MR. LAZY :P!)
902
-	if (empty($permission))
903
-		return true;
942
+	if (empty($permission)) {
943
+			return true;
944
+	}
904 945
 
905 946
 	// You're never allowed to do something if your data hasn't been loaded yet!
906
-	if (empty($user_info))
907
-		return false;
947
+	if (empty($user_info)) {
948
+			return false;
949
+	}
908 950
 
909 951
 	// Administrators are supermen :P.
910
-	if ($user_info['is_admin'])
911
-		return true;
952
+	if ($user_info['is_admin']) {
953
+			return true;
954
+	}
912 955
 
913 956
 	// Let's ensure this is an array.
914 957
 	$permission = (array) $permission;
@@ -916,14 +959,16 @@  discard block
 block discarded – undo
916 959
 	// Are we checking the _current_ board, or some other boards?
917 960
 	if ($boards === null)
918 961
 	{
919
-		if (count(array_intersect($permission, $user_info['permissions'])) != 0)
920
-			return true;
962
+		if (count(array_intersect($permission, $user_info['permissions'])) != 0) {
963
+					return true;
964
+		}
921 965
 		// You aren't allowed, by default.
922
-		else
923
-			return false;
966
+		else {
967
+					return false;
968
+		}
969
+	} elseif (!is_array($boards)) {
970
+			$boards = array($boards);
924 971
 	}
925
-	elseif (!is_array($boards))
926
-		$boards = array($boards);
927 972
 
928 973
 	$request = $smcFunc['db_query']('', '
929 974
 		SELECT MIN(bp.add_deny) AS add_deny
@@ -951,20 +996,23 @@  discard block
 block discarded – undo
951 996
 		while ($row = $smcFunc['db_fetch_assoc']($request))
952 997
 		{
953 998
 			$result = !empty($row['add_deny']);
954
-			if ($result == true)
955
-				break;
999
+			if ($result == true) {
1000
+							break;
1001
+			}
956 1002
 		}
957 1003
 		$smcFunc['db_free_result']($request);
958 1004
 		return $result;
959 1005
 	}
960 1006
 
961 1007
 	// Make sure they can do it on all of the boards.
962
-	if ($smcFunc['db_num_rows']($request) != count($boards))
963
-		return false;
1008
+	if ($smcFunc['db_num_rows']($request) != count($boards)) {
1009
+			return false;
1010
+	}
964 1011
 
965 1012
 	$result = true;
966
-	while ($row = $smcFunc['db_fetch_assoc']($request))
967
-		$result &= !empty($row['add_deny']);
1013
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1014
+			$result &= !empty($row['add_deny']);
1015
+	}
968 1016
 	$smcFunc['db_free_result']($request);
969 1017
 
970 1018
 	// If the query returned 1, they can do it... otherwise, they can't.
@@ -1031,9 +1079,10 @@  discard block
 block discarded – undo
1031 1079
 
1032 1080
 	// If you're doing something on behalf of some "heavy" permissions, validate your session.
1033 1081
 	// (take out the heavy permissions, and if you can't do anything but those, you need a validated session.)
1034
-	if (!allowedTo(array_diff($permission, $heavy_permissions), $boards))
1035
-		validateSession();
1036
-}
1082
+	if (!allowedTo(array_diff($permission, $heavy_permissions), $boards)) {
1083
+			validateSession();
1084
+	}
1085
+	}
1037 1086
 
1038 1087
 /**
1039 1088
  * Return the boards a user has a certain (board) permission on. (array(0) if all.)
@@ -1064,13 +1113,14 @@  discard block
 block discarded – undo
1064 1113
 	// Administrators are all powerful, sorry.
1065 1114
 	if ($user_info['is_admin'])
1066 1115
 	{
1067
-		if ($simple)
1068
-			return array(0);
1069
-		else
1116
+		if ($simple) {
1117
+					return array(0);
1118
+		} else
1070 1119
 		{
1071 1120
 			$boards = array();
1072
-			foreach ($permissions as $permission)
1073
-				$boards[$permission] = array(0);
1121
+			foreach ($permissions as $permission) {
1122
+							$boards[$permission] = array(0);
1123
+			}
1074 1124
 
1075 1125
 			return $boards;
1076 1126
 		}
@@ -1102,31 +1152,32 @@  discard block
 block discarded – undo
1102 1152
 	{
1103 1153
 		if ($simple)
1104 1154
 		{
1105
-			if (empty($row['add_deny']))
1106
-				$deny_boards[] = $row['id_board'];
1107
-			else
1108
-				$boards[] = $row['id_board'];
1109
-		}
1110
-		else
1155
+			if (empty($row['add_deny'])) {
1156
+							$deny_boards[] = $row['id_board'];
1157
+			} else {
1158
+							$boards[] = $row['id_board'];
1159
+			}
1160
+		} else
1111 1161
 		{
1112
-			if (empty($row['add_deny']))
1113
-				$deny_boards[$row['permission']][] = $row['id_board'];
1114
-			else
1115
-				$boards[$row['permission']][] = $row['id_board'];
1162
+			if (empty($row['add_deny'])) {
1163
+							$deny_boards[$row['permission']][] = $row['id_board'];
1164
+			} else {
1165
+							$boards[$row['permission']][] = $row['id_board'];
1166
+			}
1116 1167
 		}
1117 1168
 	}
1118 1169
 	$smcFunc['db_free_result']($request);
1119 1170
 
1120
-	if ($simple)
1121
-		$boards = array_unique(array_values(array_diff($boards, $deny_boards)));
1122
-	else
1171
+	if ($simple) {
1172
+			$boards = array_unique(array_values(array_diff($boards, $deny_boards)));
1173
+	} else
1123 1174
 	{
1124 1175
 		foreach ($permissions as $permission)
1125 1176
 		{
1126 1177
 			// never had it to start with
1127
-			if (empty($boards[$permission]))
1128
-				$boards[$permission] = array();
1129
-			else
1178
+			if (empty($boards[$permission])) {
1179
+							$boards[$permission] = array();
1180
+			} else
1130 1181
 			{
1131 1182
 				// Or it may have been removed
1132 1183
 				$deny_boards[$permission] = isset($deny_boards[$permission]) ? $deny_boards[$permission] : array();
@@ -1162,10 +1213,11 @@  discard block
 block discarded – undo
1162 1213
 
1163 1214
 
1164 1215
 	// Moderators are free...
1165
-	if (!allowedTo('moderate_board'))
1166
-		$timeLimit = isset($timeOverrides[$error_type]) ? $timeOverrides[$error_type] : $modSettings['spamWaitTime'];
1167
-	else
1168
-		$timeLimit = 2;
1216
+	if (!allowedTo('moderate_board')) {
1217
+			$timeLimit = isset($timeOverrides[$error_type]) ? $timeOverrides[$error_type] : $modSettings['spamWaitTime'];
1218
+	} else {
1219
+			$timeLimit = 2;
1220
+	}
1169 1221
 
1170 1222
 	call_integration_hook('integrate_spam_protection', array(&$timeOverrides, &$timeLimit));
1171 1223
 
@@ -1192,8 +1244,9 @@  discard block
 block discarded – undo
1192 1244
 	if ($smcFunc['db_affected_rows']() != 1)
1193 1245
 	{
1194 1246
 		// Spammer!  You only have to wait a *few* seconds!
1195
-		if (!$only_return_result)
1196
-			fatal_lang_error($error_type . '_WaitTime_broken', false, array($timeLimit));
1247
+		if (!$only_return_result) {
1248
+					fatal_lang_error($error_type . '_WaitTime_broken', false, array($timeLimit));
1249
+		}
1197 1250
 
1198 1251
 		return true;
1199 1252
 	}
@@ -1211,11 +1264,13 @@  discard block
 block discarded – undo
1211 1264
  */
1212 1265
 function secureDirectory($path, $attachments = false)
1213 1266
 {
1214
-	if (empty($path))
1215
-		return 'empty_path';
1267
+	if (empty($path)) {
1268
+			return 'empty_path';
1269
+	}
1216 1270
 
1217
-	if (!is_writable($path))
1218
-		return 'path_not_writable';
1271
+	if (!is_writable($path)) {
1272
+			return 'path_not_writable';
1273
+	}
1219 1274
 
1220 1275
 	$directoryname = basename($path);
1221 1276
 
@@ -1227,9 +1282,9 @@  discard block
 block discarded – undo
1227 1282
 
1228 1283
 RemoveHandler .php .php3 .phtml .cgi .fcgi .pl .fpl .shtml';
1229 1284
 
1230
-	if (file_exists($path . '/.htaccess'))
1231
-		$errors[] = 'htaccess_exists';
1232
-	else
1285
+	if (file_exists($path . '/.htaccess')) {
1286
+			$errors[] = 'htaccess_exists';
1287
+	} else
1233 1288
 	{
1234 1289
 		$fh = @fopen($path . '/.htaccess', 'w');
1235 1290
 		if ($fh)
@@ -1242,9 +1297,9 @@  discard block
 block discarded – undo
1242 1297
 		$errors[] = 'htaccess_cannot_create_file';
1243 1298
 	}
1244 1299
 
1245
-	if (file_exists($path . '/index.php'))
1246
-		$errors[] = 'index-php_exists';
1247
-	else
1300
+	if (file_exists($path . '/index.php')) {
1301
+			$errors[] = 'index-php_exists';
1302
+	} else
1248 1303
 	{
1249 1304
 		$fh = @fopen($path . '/index.php', 'w');
1250 1305
 		if ($fh)
@@ -1272,11 +1327,12 @@  discard block
 block discarded – undo
1272 1327
 		$errors[] = 'index-php_cannot_create_file';
1273 1328
 	}
1274 1329
 
1275
-	if (!empty($errors))
1276
-		return $errors;
1277
-	else
1278
-		return true;
1279
-}
1330
+	if (!empty($errors)) {
1331
+			return $errors;
1332
+	} else {
1333
+			return true;
1334
+	}
1335
+	}
1280 1336
 
1281 1337
 /**
1282 1338
 * This sets the X-Frame-Options header.
@@ -1289,14 +1345,16 @@  discard block
 block discarded – undo
1289 1345
 	global $modSettings;
1290 1346
 
1291 1347
 	$option = 'SAMEORIGIN';
1292
-	if (is_null($override) && !empty($modSettings['frame_security']))
1293
-		$option = $modSettings['frame_security'];
1294
-	elseif (in_array($override, array('SAMEORIGIN', 'DENY')))
1295
-		$option = $override;
1348
+	if (is_null($override) && !empty($modSettings['frame_security'])) {
1349
+			$option = $modSettings['frame_security'];
1350
+	} elseif (in_array($override, array('SAMEORIGIN', 'DENY'))) {
1351
+			$option = $override;
1352
+	}
1296 1353
 
1297 1354
 	// Don't bother setting the header if we have disabled it.
1298
-	if ($option == 'DISABLE')
1299
-		return;
1355
+	if ($option == 'DISABLE') {
1356
+			return;
1357
+	}
1300 1358
 
1301 1359
 	// Finally set it.
1302 1360
 	header('x-frame-options: ' . $option);
Please login to merge, or discard this patch.