Completed
Pull Request — release-2.1 (#4959)
by Jeremy
07:43
created
Themes/default/Register.template.php 1 patch
Braces   +90 added lines, -65 removed lines patch added patch discarded remove patch
@@ -28,14 +28,15 @@  discard block
 block discarded – undo
28 28
 			<div id="confirm_buttons">';
29 29
 
30 30
 	// Age restriction in effect?
31
-	if ($context['show_coppa'])
32
-		echo '
31
+	if ($context['show_coppa']) {
32
+			echo '
33 33
 				<input type="submit" name="accept_agreement" value="', $context['coppa_agree_above'], '" class="button"><br>
34 34
 				<br>
35 35
 				<input type="submit" name="accept_agreement_coppa" value="', $context['coppa_agree_below'], '" class="button">';
36
-	else
37
-		echo '
36
+	} else {
37
+			echo '
38 38
 				<input type="submit" name="accept_agreement" value="', $txt['agreement_agree'], '" class="button">';
39
+	}
39 40
 
40 41
 	echo '
41 42
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -78,9 +79,10 @@  discard block
 block discarded – undo
78 79
 			<ul>';
79 80
 
80 81
 		// Cycle through each error and display an error message.
81
-		foreach ($context['registration_errors'] as $error)
82
-			echo '
82
+		foreach ($context['registration_errors'] as $error) {
83
+					echo '
83 84
 				<li>', $error, '</li>';
85
+		}
84 86
 
85 87
 		echo '
86 88
 			</ul>
@@ -149,14 +151,15 @@  discard block
 block discarded – undo
149 151
 		echo '
150 152
 					<dl class="register_form">';
151 153
 
152
-		foreach ($context['custom_fields'] as $field)
153
-			if ($field['show_reg'] > 1)
154
+		foreach ($context['custom_fields'] as $field) {
155
+					if ($field['show_reg'] > 1)
154 156
 				echo '
155 157
 						<dt>
156 158
 							<strong', !empty($field['is_error']) ? ' class="red"' : '', '>', $field['name'], ':</strong>
157 159
 							<span class="smalltext">', $field['desc'], '</span>
158 160
 						</dt>
159 161
 						<dd>', str_replace('name="', 'tabindex="' . $context['tabindex']++ . '" name="', $field['input_html']), '</dd>';
162
+		}
160 163
 
161 164
 		echo '
162 165
 					</dl>';
@@ -167,14 +170,15 @@  discard block
 block discarded – undo
167 170
 			</div><!-- .roundframe -->';
168 171
 
169 172
 	// If we have either of these, show the extra group.
170
-	if (!empty($context['profile_fields']) || !empty($context['custom_fields']))
171
-		echo '
173
+	if (!empty($context['profile_fields']) || !empty($context['custom_fields'])) {
174
+			echo '
172 175
 			<div class="title_bar">
173 176
 				<h3 class="titlebg">', $txt['additional_information'], '</h3>
174 177
 			</div>
175 178
 			<div class="roundframe noup">
176 179
 				<fieldset>
177 180
 					<dl class="register_form" id="custom_group">';
181
+	}
178 182
 
179 183
 	if (!empty($context['profile_fields']))
180 184
 	{
@@ -188,41 +192,45 @@  discard block
 block discarded – undo
188 192
 					$callback_func = 'template_profile_' . $field['callback_func'];
189 193
 					$callback_func();
190 194
 				}
191
-			}
192
-			else
195
+			} else
193 196
 			{
194 197
 				echo '
195 198
 						<dt>
196 199
 							<strong', !empty($field['is_error']) ? ' class="red"' : '', '>', $field['label'], ':</strong>';
197 200
 
198 201
 				// Does it have any subtext to show?
199
-				if (!empty($field['subtext']))
200
-					echo '
202
+				if (!empty($field['subtext'])) {
203
+									echo '
201 204
 							<span class="smalltext">', $field['subtext'], '</span>';
205
+				}
202 206
 
203 207
 				echo '
204 208
 						</dt>
205 209
 						<dd>';
206 210
 
207 211
 				// Want to put something infront of the box?
208
-				if (!empty($field['preinput']))
209
-					echo '
212
+				if (!empty($field['preinput'])) {
213
+									echo '
210 214
 							', $field['preinput'];
215
+				}
211 216
 
212 217
 				// What type of data are we showing?
213
-				if ($field['type'] == 'label')
214
-					echo '
218
+				if ($field['type'] == 'label') {
219
+									echo '
215 220
 							', $field['value'];
221
+				}
216 222
 
217 223
 				// Maybe it's a text box - very likely!
218
-				elseif (in_array($field['type'], array('int', 'float', 'text', 'password', 'url')))
219
-					echo '
224
+				elseif (in_array($field['type'], array('int', 'float', 'text', 'password', 'url'))) {
225
+									echo '
220 226
 							<input type="', $field['type'] == 'password' ? 'password' : 'text', '" name="', $key, '" id="', $key, '" size="', empty($field['size']) ? 30 : $field['size'], '" value="', $field['value'], '" tabindex="', $context['tabindex']++, '" ', $field['input_attr'], '>';
227
+				}
221 228
 
222 229
 				// You "checking" me out? ;)
223
-				elseif ($field['type'] == 'check')
224
-					echo '
230
+				elseif ($field['type'] == 'check') {
231
+									echo '
225 232
 							<input type="hidden" name="', $key, '" value="0"><input type="checkbox" name="', $key, '" id="', $key, '"', !empty($field['value']) ? ' checked' : '', ' value="1" tabindex="', $context['tabindex']++, '" ', $field['input_attr'], '>';
233
+				}
226 234
 
227 235
 				// Always fun - select boxes!
228 236
 				elseif ($field['type'] == 'select')
@@ -233,14 +241,16 @@  discard block
 block discarded – undo
233 241
 					if (isset($field['options']))
234 242
 					{
235 243
 						// Is this some code to generate the options?
236
-						if (!is_array($field['options']))
237
-							$field['options'] = eval($field['options']);
244
+						if (!is_array($field['options'])) {
245
+													$field['options'] = eval($field['options']);
246
+						}
238 247
 
239 248
 						// Assuming we now have some!
240
-						if (is_array($field['options']))
241
-							foreach ($field['options'] as $value => $name)
249
+						if (is_array($field['options'])) {
250
+													foreach ($field['options'] as $value => $name)
242 251
 								echo '
243 252
 								<option', is_numeric($value) ? ' value="" disabled' : ' value="' . $value . '"', $value === $field['value'] ? ' selected' : '', '>', $name, '</option>';
253
+						}
244 254
 					}
245 255
 
246 256
 					echo '
@@ -248,9 +258,10 @@  discard block
 block discarded – undo
248 258
 				}
249 259
 
250 260
 				// Something to end with?
251
-				if (!empty($field['postinput']))
252
-					echo '
261
+				if (!empty($field['postinput'])) {
262
+									echo '
253 263
 							', $field['postinput'];
264
+				}
254 265
 
255 266
 				echo '
256 267
 						</dd>';
@@ -261,25 +272,27 @@  discard block
 block discarded – undo
261 272
 	// Are there any custom fields?
262 273
 	if (!empty($context['custom_fields']))
263 274
 	{
264
-		foreach ($context['custom_fields'] as $field)
265
-			if ($field['show_reg'] < 2)
275
+		foreach ($context['custom_fields'] as $field) {
276
+					if ($field['show_reg'] < 2)
266 277
 				echo '
267 278
 						<dt>
268 279
 							<strong', !empty($field['is_error']) ? ' class="red"' : '', '>', $field['name'], ':</strong>
269 280
 							<span class="smalltext">', $field['desc'], '</span>
270 281
 						</dt>
271 282
 						<dd>', $field['input_html'], '</dd>';
283
+		}
272 284
 	}
273 285
 
274 286
 	// If we have either of these, close the list like a proper gent.
275
-	if (!empty($context['profile_fields']) || !empty($context['custom_fields']))
276
-		echo '
287
+	if (!empty($context['profile_fields']) || !empty($context['custom_fields'])) {
288
+			echo '
277 289
 					</dl>
278 290
 				</fieldset>
279 291
 			</div><!-- .roundframe -->';
292
+	}
280 293
 
281
-	if ($context['visual_verification'])
282
-		echo '
294
+	if ($context['visual_verification']) {
295
+			echo '
283 296
 			<div class="title_bar">
284 297
 				<h3 class="titlebg">', $txt['verification'], '</h3>
285 298
 			</div>
@@ -288,19 +301,21 @@  discard block
 block discarded – undo
288 301
 					', template_control_verification($context['visual_verification_id'], 'all'), '
289 302
 				</fieldset>
290 303
 			</div>';
304
+	}
291 305
 
292 306
 	echo '
293 307
 			<div id="confirm_buttons" class="flow_auto">';
294 308
 
295 309
 	// Age restriction in effect?
296
-	if (!$context['require_agreement'] && $context['show_coppa'])
297
-		echo '
310
+	if (!$context['require_agreement'] && $context['show_coppa']) {
311
+			echo '
298 312
 				<input type="submit" name="accept_agreement" value="', $context['coppa_agree_above'], '" class="button"><br>
299 313
 				<br>
300 314
 				<input type="submit" name="accept_agreement_coppa" value="', $context['coppa_agree_below'], '" class="button">';
301
-	else
302
-		echo '
315
+	} else {
316
+			echo '
303 317
 				<input type="submit" name="regSubmit" value="', $txt['register'], '" tabindex="', $context['tabindex']++, '" class="button">';
318
+	}
304 319
 
305 320
 	echo '
306 321
 			</div>
@@ -362,25 +377,28 @@  discard block
 block discarded – undo
362 377
 				<p>', $context['coppa']['many_options'] ? $txt['coppa_send_to_two_options'] : $txt['coppa_send_to_one_option'], '</p>';
363 378
 
364 379
 	// Can they send by post?
365
-	if (!empty($context['coppa']['post']))
366
-		echo '
380
+	if (!empty($context['coppa']['post'])) {
381
+			echo '
367 382
 				<h4>1) ', $txt['coppa_send_by_post'], '</h4>
368 383
 				<div class="coppa_contact">
369 384
 					', $context['coppa']['post'], '
370 385
 				</div>';
386
+	}
371 387
 
372 388
 	// Can they send by fax??
373
-	if (!empty($context['coppa']['fax']))
374
-		echo '
389
+	if (!empty($context['coppa']['fax'])) {
390
+			echo '
375 391
 				<h4>', !empty($context['coppa']['post']) ? '2' : '1', ') ', $txt['coppa_send_by_fax'], '</h4>
376 392
 				<div class="coppa_contact">
377 393
 					', $context['coppa']['fax'], '
378 394
 				</div>';
395
+	}
379 396
 
380 397
 	// Offer an alternative Phone Number?
381
-	if ($context['coppa']['phone'])
382
-		echo '
398
+	if ($context['coppa']['phone']) {
399
+			echo '
383 400
 				<p>', $context['coppa']['phone'], '</p>';
401
+	}
384 402
 
385 403
 	echo '
386 404
 			</div><!-- #coppa -->';
@@ -445,19 +463,20 @@  discard block
 block discarded – undo
445 463
 	<body style="margin: 1ex;">
446 464
 		<div class="windowbg description" style="text-align: center;">';
447 465
 
448
-	if (isBrowser('is_ie') || isBrowser('is_ie11'))
449
-		echo '
466
+	if (isBrowser('is_ie') || isBrowser('is_ie11')) {
467
+			echo '
450 468
 			<object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" type="audio/x-wav">
451 469
 				<param name="AutoStart" value="1">
452 470
 				<param name="FileName" value="', $context['verification_sound_href'], '">
453 471
 			</object>';
454
-	else
455
-		echo '
472
+	} else {
473
+			echo '
456 474
 			<audio src="', $context['verification_sound_href'], '" controls>
457 475
 				<object type="audio/x-wav" data="', $context['verification_sound_href'], '">
458 476
 					<a href="', $context['verification_sound_href'], '" rel="nofollow">', $context['verification_sound_href'], '</a>
459 477
 				</object>
460 478
 			</audio>';
479
+	}
461 480
 
462 481
 	echo '
463 482
 			<br>
@@ -485,11 +504,12 @@  discard block
 block discarded – undo
485 504
 				</div>
486 505
 				<div id="register_screen" class="windowbg">';
487 506
 
488
-	if (!empty($context['registration_done']))
489
-		echo '
507
+	if (!empty($context['registration_done'])) {
508
+			echo '
490 509
 					<div class="infobox">
491 510
 						', $context['registration_done'], '
492 511
 					</div>';
512
+	}
493 513
 
494 514
 	echo '
495 515
 					<dl class="register_form" id="admin_register_form">
@@ -525,9 +545,10 @@  discard block
 block discarded – undo
525 545
 						<dd>
526 546
 							<select name="group" id="group_select" tabindex="', $context['tabindex']++, '">';
527 547
 
528
-		foreach ($context['member_groups'] as $id => $name)
529
-			echo '
548
+		foreach ($context['member_groups'] as $id => $name) {
549
+					echo '
530 550
 								<option value="', $id, '">', $name, '</option>';
551
+		}
531 552
 
532 553
 		echo '
533 554
 							</select>
@@ -535,8 +556,8 @@  discard block
 block discarded – undo
535 556
 	}
536 557
 
537 558
 	// If there is any field marked as required, show it here!
538
-	if (!empty($context['custom_fields_required']) && !empty($context['custom_fields']))
539
-		foreach ($context['custom_fields'] as $field)
559
+	if (!empty($context['custom_fields_required']) && !empty($context['custom_fields'])) {
560
+			foreach ($context['custom_fields'] as $field)
540 561
 			if ($field['show_reg'] > 1)
541 562
 				echo '
542 563
 						<dt>
@@ -546,6 +567,7 @@  discard block
 block discarded – undo
546 567
 						<dd>
547 568
 							', str_replace('name="', 'tabindex="' . $context['tabindex']++ . '" name="', $field['input_html']), '
548 569
 						</dd>';
570
+	}
549 571
 
550 572
 	echo '
551 573
 						<dt>
@@ -582,18 +604,19 @@  discard block
 block discarded – undo
582 604
 {
583 605
 	global $context, $scripturl, $txt;
584 606
 
585
-	if (!empty($context['saved_successful']))
586
-		echo '
607
+	if (!empty($context['saved_successful'])) {
608
+			echo '
587 609
 		<div class="infobox">', $txt['settings_saved'], '</div>';
588
-
589
-	elseif (!empty($context['could_not_save']))
590
-		echo '
610
+	} elseif (!empty($context['could_not_save'])) {
611
+			echo '
591 612
 		<div class="errorbox">', $txt['admin_agreement_not_saved'], '</div>';
613
+	}
592 614
 
593 615
 	// Warning for if the file isn't writable.
594
-	if (!empty($context['warning']))
595
-		echo '
616
+	if (!empty($context['warning'])) {
617
+			echo '
596 618
 		<div class="errorbox">', $context['warning'], '</div>';
619
+	}
597 620
 
598 621
 	// Just a big box to edit the text file ;)
599 622
 	echo '
@@ -615,9 +638,10 @@  discard block
 block discarded – undo
615 638
 						<strong>', $txt['admin_agreement_select_language'], ':</strong>
616 639
 						<select name="agree_lang" onchange="document.getElementById(\'change_reg\').submit();" tabindex="', $context['tabindex']++, '">';
617 640
 
618
-		foreach ($context['editable_agreements'] as $file => $name)
619
-			echo '
641
+		foreach ($context['editable_agreements'] as $file => $name) {
642
+					echo '
620 643
 							<option value="', $file, '"', $context['current_agreement'] == $file ? ' selected' : '', '>', $name, '</option>';
644
+		}
621 645
 
622 646
 		echo '
623 647
 						</select>
@@ -657,9 +681,10 @@  discard block
 block discarded – undo
657 681
 {
658 682
 	global $context, $scripturl, $txt;
659 683
 
660
-	if (!empty($context['saved_successful']))
661
-		echo '
684
+	if (!empty($context['saved_successful'])) {
685
+			echo '
662 686
 	<div class="infobox">', $txt['settings_saved'], '</div>';
687
+	}
663 688
 
664 689
 	echo '
665 690
 	<form id="admin_form_wrapper" action="', $scripturl, '?action=admin;area=regcenter" method="post" accept-charset="', $context['character_set'], '">
Please login to merge, or discard this patch.
Themes/default/ManageBans.template.php 1 patch
Braces   +24 added lines, -16 removed lines patch added patch discarded remove patch
@@ -29,9 +29,10 @@  discard block
 block discarded – undo
29 29
 				<strong>', $txt['ban_errors_detected'], '</strong>
30 30
 				<ul>';
31 31
 
32
-		foreach ($context['error_messages'] as $error)
33
-			echo '
32
+		foreach ($context['error_messages'] as $error) {
33
+					echo '
34 34
 					<li class="error">', $error, '</li>';
35
+		}
35 36
 
36 37
 		echo '
37 38
 				</ul>
@@ -45,9 +46,10 @@  discard block
 block discarded – undo
45 46
 				</h3>
46 47
 			</div>';
47 48
 
48
-	if ($context['ban']['is_new'])
49
-		echo '
49
+	if ($context['ban']['is_new']) {
50
+			echo '
50 51
 			<div class="information noup">', $txt['ban_add_notes'], '</div>';
52
+	}
51 53
 
52 54
 	echo '
53 55
 			<div class="windowbg noup">
@@ -59,8 +61,8 @@  discard block
 block discarded – undo
59 61
 						<input type="text" id="ban_name" name="ban_name" value="', $context['ban']['name'], '" size="45" maxlength="60">
60 62
 					</dd>';
61 63
 
62
-	if (isset($context['ban']['reason']))
63
-		echo '
64
+	if (isset($context['ban']['reason'])) {
65
+			echo '
64 66
 					<dt>
65 67
 						<strong><label for="reason">', $txt['ban_reason'], ':</label></strong><br>
66 68
 						<span class="smalltext">', $txt['ban_reason_desc'], '</span>
@@ -68,9 +70,10 @@  discard block
 block discarded – undo
68 70
 					<dd>
69 71
 						<textarea name="reason" id="reason" cols="40" rows="3">', $context['ban']['reason'], '</textarea>
70 72
 					</dd>';
73
+	}
71 74
 
72
-	if (isset($context['ban']['notes']))
73
-		echo '
75
+	if (isset($context['ban']['notes'])) {
76
+			echo '
74 77
 					<dt>
75 78
 						<strong><label for="ban_notes">', $txt['ban_notes'], ':</label></strong><br>
76 79
 						<span class="smalltext">', $txt['ban_notes_desc'], '</span>
@@ -78,6 +81,7 @@  discard block
 block discarded – undo
78 81
 					<dd>
79 82
 						<textarea name="notes" id="ban_notes" cols="40" rows="3">', $context['ban']['notes'], '</textarea>
80 83
 					</dd>';
84
+	}
81 85
 
82 86
 	echo '
83 87
 				</dl>
@@ -117,8 +121,8 @@  discard block
 block discarded – undo
117 121
 							<input type="text" name="main_ip" value="', $context['ban_suggestions']['main_ip'], '" size="44" onfocus="document.getElementById(\'main_ip_check\').checked = true;">
118 122
 						</dd>';
119 123
 
120
-		if (empty($modSettings['disableHostnameLookup']))
121
-			echo '
124
+		if (empty($modSettings['disableHostnameLookup'])) {
125
+					echo '
122 126
 						<dt>
123 127
 							<input type="checkbox" name="ban_suggestions[]" id="hostname_check" value="hostname"', !empty($context['ban_suggestions']['hostname']) ? ' checked' : '', '>
124 128
 							<label for="hostname_check">', $txt['ban_on_hostname'], '</label>
@@ -126,6 +130,7 @@  discard block
 block discarded – undo
126 130
 						<dd>
127 131
 							<input type="text" name="hostname" value="', $context['ban_suggestions']['hostname'], '" size="44" onfocus="document.getElementById(\'hostname_check\').checked = true;">
128 132
 						</dd>';
133
+		}
129 134
 
130 135
 		echo '
131 136
 						<dt>
@@ -155,14 +160,15 @@  discard block
 block discarded – undo
155 160
 					<dl class="settings">';
156 161
 
157 162
 					$count = 0;
158
-					foreach ($ban_ips as $ip)
159
-						echo '
163
+					foreach ($ban_ips as $ip) {
164
+											echo '
160 165
 						<dt>
161 166
 							<input type="checkbox" id="suggestions_', $key, '_', $count, '" name="ban_suggestions[', $key, '][]"', !empty($context['ban_suggestions']['saved_triggers'][$key]) && in_array($ip, $context['ban_suggestions']['saved_triggers'][$key]) ? ' checked' : '', ' value="', $ip, '">
162 167
 						</dt>
163 168
 						<dd>
164 169
 							<label for="suggestions_', $key, '_', $count++, '">', $ip, '</label>
165 170
 						</dd>';
171
+					}
166 172
 
167 173
 					echo '
168 174
 					</dl>';
@@ -204,8 +210,8 @@  discard block
 block discarded – undo
204 210
 		addLoadEvent(fUpdateStatus);';
205 211
 
206 212
 	// Auto suggest only needed for adding new bans, not editing
207
-	if ($context['ban']['is_new'] && empty($_REQUEST['u']))
208
-		echo '
213
+	if ($context['ban']['is_new'] && empty($_REQUEST['u'])) {
214
+			echo '
209 215
 		var oAddMemberSuggest = new smc_AutoSuggest({
210 216
 			sSelf: \'oAddMemberSuggest\',
211 217
 			sSessionId: smf_session_id,
@@ -223,6 +229,7 @@  discard block
 block discarded – undo
223 229
 			return true;
224 230
 		}
225 231
 		oAddMemberSuggest.registerCallback(\'onBeforeUpdate\', \'onUpdateName\');';
232
+	}
226 233
 
227 234
 	echo '
228 235
 		function confirmBan(aForm)
@@ -271,8 +278,8 @@  discard block
 block discarded – undo
271 278
 							<input type="text" name="main_ip" value="', $context['ban_trigger']['ip']['value'], '" size="44" onfocus="document.getElementById(\'main_ip_check\').checked = true;">
272 279
 						</dd>';
273 280
 
274
-	if (empty($modSettings['disableHostnameLookup']))
275
-		echo '
281
+	if (empty($modSettings['disableHostnameLookup'])) {
282
+			echo '
276 283
 						<dt>
277 284
 							<input type="checkbox" name="ban_suggestions[]" id="hostname_check" value="hostname"', $context['ban_trigger']['hostname']['selected'] ? ' checked' : '', '>
278 285
 							<label for="hostname_check">', $txt['ban_on_hostname'], '</label>
@@ -280,6 +287,7 @@  discard block
 block discarded – undo
280 287
 						<dd>
281 288
 							<input type="text" name="hostname" value="', $context['ban_trigger']['hostname']['value'], '" size="44" onfocus="document.getElementById(\'hostname_check\').checked = true;">
282 289
 						</dd>';
290
+	}
283 291
 
284 292
 	echo '
285 293
 						<dt>
Please login to merge, or discard this patch.
Themes/default/ManageAttachments.template.php 1 patch
Braces   +29 added lines, -20 removed lines patch added patch discarded remove patch
@@ -116,9 +116,10 @@  discard block
 block discarded – undo
116 116
 		</div><!-- .windowbg -->
117 117
 	</div><!-- #manage_attachments -->';
118 118
 
119
-	if (!empty($context['results']))
120
-		echo '
119
+	if (!empty($context['results'])) {
120
+			echo '
121 121
 	<div class="noticebox">', $context['results'], '</div>';
122
+	}
122 123
 
123 124
 	echo '
124 125
 	<div id="transfer" class="cat_bar">
@@ -133,9 +134,10 @@  discard block
 block discarded – undo
133 134
 					<select name="from">
134 135
 						<option value="0">', $txt['attachment_transfer_select'], '</option>';
135 136
 
136
-	foreach ($context['attach_dirs'] as $id => $dir)
137
-		echo '
137
+	foreach ($context['attach_dirs'] as $id => $dir) {
138
+			echo '
138 139
 						<option value="', $id, '">', $dir, '</option>';
140
+	}
139 141
 
140 142
 	echo '
141 143
 					</select>
@@ -146,13 +148,14 @@  discard block
 block discarded – undo
146 148
 						<option value="0">', $txt['attachment_transfer_auto_select'], '</option>
147 149
 						<option value="-1">', $txt['attachment_transfer_forum_root'], '</option>';
148 150
 
149
-	if (!empty($context['base_dirs']))
150
-		foreach ($context['base_dirs'] as $id => $dir)
151
+	if (!empty($context['base_dirs'])) {
152
+			foreach ($context['base_dirs'] as $id => $dir)
151 153
 			echo '
152 154
 						<option value="', $id, '">', $dir, '</option>';
153
-	else
154
-			echo '
155
+	} else {
156
+				echo '
155 157
 						<option value="0" disabled>', $txt['attachment_transfer_no_base'], '</option>';
158
+	}
156 159
 
157 160
 	echo '
158 161
 					</select>
@@ -162,18 +165,20 @@  discard block
 block discarded – undo
162 165
 					<select name="to">
163 166
 						<option value="0">', $txt['attachment_transfer_select'], '</option>';
164 167
 
165
-	foreach ($context['attach_dirs'] as $id => $dir)
166
-		echo '
168
+	foreach ($context['attach_dirs'] as $id => $dir) {
169
+			echo '
167 170
 						<option value="', $id, '">', $dir, '</option>';
171
+	}
168 172
 
169 173
 	echo '
170 174
 					</select>
171 175
 				</dd>';
172 176
 
173
-	if (!empty($modSettings['attachmentDirFileLimit']))
174
-		echo '
177
+	if (!empty($modSettings['attachmentDirFileLimit'])) {
178
+			echo '
175 179
 				<dt>', $txt['attachment_transfer_empty'], '</dt>
176 180
 				<dd><input type="checkbox" name="empty_it"', $context['checked'] ? ' checked' : '', '></dd>';
181
+	}
177 182
 
178 183
 	echo '
179 184
 			</dl>
@@ -209,8 +214,8 @@  discard block
 block discarded – undo
209 214
 	global $context, $txt, $scripturl;
210 215
 
211 216
 	// If we've completed just let them know!
212
-	if ($context['completed'])
213
-		echo '
217
+	if ($context['completed']) {
218
+			echo '
214 219
 	<div id="manage_attachments">
215 220
 		<div class="cat_bar">
216 221
 			<h3 class="catbg">', $txt['repair_attachments_complete'], '</h3>
@@ -219,10 +224,11 @@  discard block
 block discarded – undo
219 224
 			', $txt['repair_attachments_complete_desc'], '
220 225
 		</div>
221 226
 	</div>';
227
+	}
222 228
 
223 229
 	// What about if no errors were even found?
224
-	elseif (!$context['errors_found'])
225
-		echo '
230
+	elseif (!$context['errors_found']) {
231
+			echo '
226 232
 	<div id="manage_attachments">
227 233
 		<div class="cat_bar">
228 234
 			<h3 class="catbg">', $txt['repair_attachments_complete'], '</h3>
@@ -231,6 +237,7 @@  discard block
 block discarded – undo
231 237
 			', $txt['repair_attachments_no_errors'], '
232 238
 		</div>
233 239
 	</div>';
240
+	}
234 241
 
235 242
 	// Otherwise, I'm sad to say, we have a problem!
236 243
 	else
@@ -245,11 +252,12 @@  discard block
 block discarded – undo
245 252
 				<p>', $txt['repair_attachments_error_desc'], '</p>';
246 253
 
247 254
 		// Loop through each error reporting the status
248
-		foreach ($context['repair_errors'] as $error => $number)
249
-			if (!empty($number))
255
+		foreach ($context['repair_errors'] as $error => $number) {
256
+					if (!empty($number))
250 257
 				echo '
251 258
 				<input type="checkbox" name="to_fix[]" id="', $error, '" value="', $error, '">
252 259
 				<label for="', $error, '">', sprintf($txt['attach_repair_' . $error], $number), '</label><br>';
260
+		}
253 261
 
254 262
 		echo '
255 263
 				<br>
@@ -268,8 +276,9 @@  discard block
 block discarded – undo
268 276
 {
269 277
 	global $modSettings;
270 278
 
271
-	if (!empty($modSettings['attachment_basedirectories']))
272
-		template_show_list('base_paths');
279
+	if (!empty($modSettings['attachment_basedirectories'])) {
280
+			template_show_list('base_paths');
281
+	}
273 282
 
274 283
 	template_show_list('attach_paths');
275 284
 }
Please login to merge, or discard this patch.
Themes/default/Who.template.php 1 patch
Braces   +45 added lines, -31 removed lines patch added patch discarded remove patch
@@ -31,9 +31,10 @@  discard block
 block discarded – undo
31 31
 						', $txt['who_show1'], '
32 32
 						<select name="show_top" onchange="document.forms.whoFilter.show.value = this.value; document.forms.whoFilter.submit();">';
33 33
 
34
-	foreach ($context['show_methods'] as $value => $label)
35
-		echo '
34
+	foreach ($context['show_methods'] as $value => $label) {
35
+			echo '
36 36
 							<option value="', $value, '" ', $value == $context['show_by'] ? ' selected' : '', '>', $label, '</option>';
37
+	}
37 38
 	echo '
38 39
 						</select>
39 40
 						<noscript>
@@ -58,20 +59,22 @@  discard block
 block discarded – undo
58 59
 							<td>';
59 60
 
60 61
 		// Guests can't be messaged.
61
-		if (!$member['is_guest'])
62
-			echo '
62
+		if (!$member['is_guest']) {
63
+					echo '
63 64
 								<span class="contact_info floatright">
64 65
 									', $context['can_send_pm'] ? '<a href="' . $member['online']['href'] . '" title="' . $member['online']['text'] . '">' : '', $settings['use_image_buttons'] ? '<span class="' . ($member['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $member['online']['text'] . '"></span>' : $member['online']['label'], $context['can_send_pm'] ? '</a>' : '', '
65 66
 								</span>';
67
+		}
66 68
 
67 69
 		echo '
68 70
 								<span class="member', $member['is_hidden'] ? ' hidden' : '', '">
69 71
 									', $member['is_guest'] ? $member['name'] : '<a href="' . $member['href'] . '" title="' . $txt['profile_of'] . ' ' . $member['name'] . '"' . (empty($member['color']) ? '' : ' style="color: ' . $member['color'] . '"') . '>' . $member['name'] . '</a>', '
70 72
 								</span>';
71 73
 
72
-		if (!empty($member['ip']))
73
-			echo '
74
+		if (!empty($member['ip'])) {
75
+					echo '
74 76
 								(<a href="' . $scripturl . '?action=', ($member['is_guest'] ? 'trackip' : 'profile;area=tracking;sa=ip;u=' . $member['id']), ';searchip=' . $member['ip'] . '">' . $member['ip'] . '</a>)';
77
+		}
75 78
 
76 79
 		echo '
77 80
 							</td>
@@ -81,13 +84,14 @@  discard block
 block discarded – undo
81 84
 	}
82 85
 
83 86
 	// No members?
84
-	if (empty($context['members']))
85
-		echo '
87
+	if (empty($context['members'])) {
88
+			echo '
86 89
 						<tr class="windowbg">
87 90
 							<td colspan="3">
88 91
 							', $txt['who_no_online_' . ($context['show_by'] == 'guests' || $context['show_by'] == 'spiders' ? $context['show_by'] : 'members')], '
89 92
 							</td>
90 93
 						</tr>';
94
+	}
91 95
 
92 96
 	echo '
93 97
 					</tbody>
@@ -98,9 +102,10 @@  discard block
 block discarded – undo
98 102
 						', $txt['who_show1'], '
99 103
 						<select name="show" onchange="document.forms.whoFilter.submit();">';
100 104
 
101
-	foreach ($context['show_methods'] as $value => $label)
102
-		echo '
105
+	foreach ($context['show_methods'] as $value => $label) {
106
+			echo '
103 107
 							<option value="', $value, '" ', $value == $context['show_by'] ? ' selected' : '', '>', $label, '</option>';
108
+	}
104 109
 	echo '
105 110
 						</select>
106 111
 						<noscript>
@@ -129,17 +134,19 @@  discard block
 block discarded – undo
129 134
 
130 135
 	foreach ($context['credits'] as $section)
131 136
 	{
132
-		if (isset($section['pretext']))
133
-			echo '
137
+		if (isset($section['pretext'])) {
138
+					echo '
134 139
 		<div class="windowbg">
135 140
 			<p>', $section['pretext'], '</p>
136 141
 		</div>';
142
+		}
137 143
 
138
-		if (isset($section['title']))
139
-			echo '
144
+		if (isset($section['title'])) {
145
+					echo '
140 146
 		<div class="cat_bar">
141 147
 			<h3 class="catbg">', $section['title'], '</h3>
142 148
 		</div>';
149
+		}
143 150
 
144 151
 		echo '
145 152
 		<div class="windowbg">
@@ -147,17 +154,18 @@  discard block
 block discarded – undo
147 154
 
148 155
 		foreach ($section['groups'] as $group)
149 156
 		{
150
-			if (isset($group['title']))
151
-				echo '
157
+			if (isset($group['title'])) {
158
+							echo '
152 159
 				<dt>
153 160
 					<strong>', $group['title'], '</strong>
154 161
 				</dt>
155 162
 				<dd>';
163
+			}
156 164
 
157 165
 			// Try to make this read nicely.
158
-			if (count($group['members']) <= 2)
159
-				echo implode(' ' . $txt['credits_and'] . ' ', $group['members']);
160
-			else
166
+			if (count($group['members']) <= 2) {
167
+							echo implode(' ' . $txt['credits_and'] . ' ', $group['members']);
168
+			} else
161 169
 			{
162 170
 				$last_peep = array_pop($group['members']);
163 171
 				echo implode(', ', $group['members']), ' ', $txt['credits_and'], ' ', $last_peep;
@@ -170,9 +178,10 @@  discard block
 block discarded – undo
170 178
 		echo '
171 179
 			</dl>';
172 180
 
173
-		if (isset($section['posttext']))
174
-			echo '
181
+		if (isset($section['posttext'])) {
182
+					echo '
175 183
 				<p class="posttext">', $section['posttext'], '</p>';
184
+		}
176 185
 
177 186
 		echo '
178 187
 		</div>';
@@ -187,26 +196,29 @@  discard block
 block discarded – undo
187 196
 		</div>
188 197
 		<div class="windowbg">';
189 198
 
190
-		if (!empty($context['credits_software_graphics']['graphics']))
191
-			echo '
199
+		if (!empty($context['credits_software_graphics']['graphics'])) {
200
+					echo '
192 201
 			<dl>
193 202
 				<dt><strong>', $txt['credits_graphics'], '</strong></dt>
194 203
 				<dd>', implode('</dd><dd>', $context['credits_software_graphics']['graphics']), '</dd>
195 204
 			</dl>';
205
+		}
196 206
 
197
-		if (!empty($context['credits_software_graphics']['software']))
198
-			echo '
207
+		if (!empty($context['credits_software_graphics']['software'])) {
208
+					echo '
199 209
 			<dl>
200 210
 				<dt><strong>', $txt['credits_software'], '</strong></dt>
201 211
 				<dd>', implode('</dd><dd>', $context['credits_software_graphics']['software']), '</dd>
202 212
 			</dl>';
213
+		}
203 214
 
204
-		if (!empty($context['credits_software_graphics']['fonts']))
205
-			echo '
215
+		if (!empty($context['credits_software_graphics']['fonts'])) {
216
+					echo '
206 217
 			<dl>
207 218
 				<dt><strong>', $txt['credits_fonts'], '</strong></dt>
208 219
 				<dd>', implode('</dd><dd>', $context['credits_software_graphics']['fonts']), '</dd>
209 220
 			</dl>';
221
+		}
210 222
 		echo '
211 223
 		</div>';
212 224
 	}
@@ -222,14 +234,16 @@  discard block
 block discarded – undo
222 234
 			<ul>';
223 235
 
224 236
 		// Display the credits.
225
-		if (!empty($context['credits_modifications']))
226
-			echo '
237
+		if (!empty($context['credits_modifications'])) {
238
+					echo '
227 239
 				<li>', implode('</li><li>', $context['credits_modifications']), '</li>';
240
+		}
228 241
 
229 242
 		// Legacy.
230
-		if (!empty($context['copyrights']['mods']))
231
-			echo '
243
+		if (!empty($context['copyrights']['mods'])) {
244
+					echo '
232 245
 				<li>', implode('</li><li>', $context['copyrights']['mods']), '</li>';
246
+		}
233 247
 
234 248
 		echo '
235 249
 			</ul>
Please login to merge, or discard this patch.
Themes/default/ModerationCenter.template.php 1 patch
Braces   +59 added lines, -41 removed lines patch added patch discarded remove patch
@@ -54,18 +54,20 @@  discard block
 block discarded – undo
54 54
 		<div class="windowbg" id="group_requests_panel">
55 55
 			<ul>';
56 56
 
57
-	foreach ($context['group_requests'] as $request)
58
-		echo '
57
+	foreach ($context['group_requests'] as $request) {
58
+			echo '
59 59
 				<li class="smalltext">
60 60
 					<a href="', $request['request_href'], '">', $request['group']['name'], '</a> ', $txt['mc_groupr_by'], ' ', $request['member']['link'], '
61 61
 				</li>';
62
+	}
62 63
 
63 64
 	// Don't have any watched users right now?
64
-	if (empty($context['group_requests']))
65
-		echo '
65
+	if (empty($context['group_requests'])) {
66
+			echo '
66 67
 				<li>
67 68
 					<strong class="smalltext">', $txt['mc_group_requests_none'], '</strong>
68 69
 				</li>';
70
+	}
69 71
 
70 72
 	echo '
71 73
 			</ul>
@@ -121,18 +123,20 @@  discard block
 block discarded – undo
121 123
 		<div class="windowbg" id="watched_users_panel">
122 124
 			<ul>';
123 125
 
124
-	foreach ($context['watched_users'] as $user)
125
-		echo '
126
+	foreach ($context['watched_users'] as $user) {
127
+			echo '
126 128
 				<li>
127 129
 					<span class="smalltext">', sprintf(!empty($user['last_login']) ? $txt['mc_seen'] : $txt['mc_seen_never'], $user['link'], $user['last_login']), '</span>
128 130
 				</li>';
131
+	}
129 132
 
130 133
 	// Don't have any watched users right now?
131
-	if (empty($context['watched_users']))
132
-		echo '
134
+	if (empty($context['watched_users'])) {
135
+			echo '
133 136
 				<li>
134 137
 					<strong class="smalltext">', $txt['mc_watched_users_none'], '</strong>
135 138
 				</li>';
139
+	}
136 140
 
137 141
 	echo '
138 142
 			</ul>
@@ -188,18 +192,20 @@  discard block
 block discarded – undo
188 192
 		<div class="windowbg" id="reported_posts_panel">
189 193
 			<ul>';
190 194
 
191
-	foreach ($context['reported_posts'] as $post)
192
-		echo '
195
+	foreach ($context['reported_posts'] as $post) {
196
+			echo '
193 197
 				<li>
194 198
 					<span class="smalltext">', sprintf($txt['mc_post_report'], $post['report_link'], $post['author']['link']), '</span>
195 199
 				</li>';
200
+	}
196 201
 
197 202
 	// Don't have any watched users right now?
198
-	if (empty($context['reported_posts']))
199
-		echo '
203
+	if (empty($context['reported_posts'])) {
204
+			echo '
200 205
 				<li>
201 206
 					<strong class="smalltext">', $txt['mc_recent_reports_none'], '</strong>
202 207
 				</li>';
208
+	}
203 209
 
204 210
 	echo '
205 211
 			</ul>
@@ -255,18 +261,20 @@  discard block
 block discarded – undo
255 261
 		<div class="windowbg" id="reported_users_panel">
256 262
 			<ul>';
257 263
 
258
-	foreach ($context['reported_users'] as $user)
259
-		echo '
264
+	foreach ($context['reported_users'] as $user) {
265
+			echo '
260 266
 				<li>
261 267
 					<span class="smalltext">', $user['user']['link'], '</span>
262 268
 				</li>';
269
+	}
263 270
 
264 271
 	// Don't have any watched users right now?
265
-	if (empty($context['reported_users']))
266
-		echo '
272
+	if (empty($context['reported_users'])) {
273
+			echo '
267 274
 				<li>
268 275
 					<strong class="smalltext">', $txt['mc_reported_users_none'], '</strong>
269 276
 				</li>';
277
+	}
270 278
 
271 279
 	echo '
272 280
 			</ul>
@@ -313,11 +321,12 @@  discard block
 block discarded – undo
313 321
 	global $context, $txt, $scripturl;
314 322
 
315 323
 	// Let them know the action was a success.
316
-	if (!empty($context['report_post_action']))
317
-		echo '
324
+	if (!empty($context['report_post_action'])) {
325
+			echo '
318 326
 		<div class="infobox">
319 327
 			', $txt['report_action_' . $context['report_post_action']], '
320 328
 		</div>';
329
+	}
321 330
 
322 331
 	echo '
323 332
 		<div id="modnotes">
@@ -333,11 +342,12 @@  discard block
 block discarded – undo
333 342
 					<ul class="moderation_notes">';
334 343
 
335 344
 		// Cycle through the notes.
336
-		foreach ($context['notes'] as $note)
337
-			echo '
345
+		foreach ($context['notes'] as $note) {
346
+					echo '
338 347
 						<li class="smalltext">
339 348
 							', ($note['can_delete'] ? '<a href="' . $note['delete_href'] . ';' . $context['mod-modnote-del_token_var'] . '=' . $context['mod-modnote-del_token'] . '" data-confirm="' . $txt['mc_reportedp_delete_confirm'] . '" class="you_sure"><span class="generic_icons delete"></span></a>' : ''), $note['time'], ' <strong>', $note['author']['link'], ':</strong> ', $note['text'], '
340 349
 						</li>';
350
+		}
341 351
 
342 352
 		echo '
343 353
 					</ul>
@@ -378,18 +388,19 @@  discard block
 block discarded – undo
378 388
 	$remove_button = create_button('delete', 'remove_message', 'remove');
379 389
 
380 390
 	// No posts?
381
-	if (empty($context['unapproved_items']))
382
-		echo '
391
+	if (empty($context['unapproved_items'])) {
392
+			echo '
383 393
 			<div class="windowbg">
384 394
 				<p class="centertext">
385 395
 					', $txt['mc_unapproved_' . $context['current_view'] . '_none_found'], '
386 396
 				</p>
387 397
 			</div>';
388
-	else
389
-		echo '
398
+	} else {
399
+			echo '
390 400
 			<div class="pagesection floatleft">
391 401
 				', $context['page_index'], '
392 402
 			</div>';
403
+	}
393 404
 
394 405
 	foreach ($context['unapproved_items'] as $item)
395 406
 	{
@@ -408,14 +419,16 @@  discard block
 block discarded – undo
408 419
 				<span class="floatright">
409 420
 					<a href="', $scripturl, '?action=moderate;area=postmod;sa=', $context['current_view'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], ';approve=', $item['id'], '">', $approve_button, '</a>';
410 421
 
411
-		if ($item['can_delete'])
412
-			echo '
422
+		if ($item['can_delete']) {
423
+					echo '
413 424
 					', $context['menu_separator'], '
414 425
 					<a href="', $scripturl, '?action=moderate;area=postmod;sa=', $context['current_view'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], ';delete=', $item['id'], '">', $remove_button, '</a>';
426
+		}
415 427
 
416
-		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1)
417
-			echo '
428
+		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) {
429
+					echo '
418 430
 					<input type="checkbox" name="item[]" value="', $item['id'], '" checked> ';
431
+		}
419 432
 
420 433
 		echo '
421 434
 				</span>
@@ -425,8 +438,8 @@  discard block
 block discarded – undo
425 438
 	echo '
426 439
 			<div class="pagesection">';
427 440
 
428
-	if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1)
429
-		echo '
441
+	if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) {
442
+			echo '
430 443
 				<div class="floatright">
431 444
 					<select name="do" onchange="if (this.value != 0 &amp;&amp; confirm(\'', $txt['mc_unapproved_sure'], '\')) submit();">
432 445
 						<option value="0">', $txt['with_selected'], ':</option>
@@ -438,12 +451,14 @@  discard block
 block discarded – undo
438 451
 						<input type="submit" name="mc_go" value="', $txt['go'], '" class="button">
439 452
 					</noscript>
440 453
 				</div>';
454
+	}
441 455
 
442
-	if (!empty($context['unapproved_items']))
443
-		echo '
456
+	if (!empty($context['unapproved_items'])) {
457
+			echo '
444 458
 				<div class="floatleft">
445 459
 					<div class="pagelinks">', $context['page_index'], '</div>
446 460
 				</div>';
461
+	}
447 462
 
448 463
 	echo '
449 464
 			</div><!-- .pagesection -->
@@ -464,8 +479,9 @@  discard block
 block discarded – undo
464 479
 
465 480
 	// We'll have a delete please bob.
466 481
 	// @todo Discuss this with the team and rewrite if required.
467
-	if (empty($delete_button))
468
-		$delete_button = create_button('delete', 'remove_message', 'remove', 'class="centericon"');
482
+	if (empty($delete_button)) {
483
+			$delete_button = create_button('delete', 'remove_message', 'remove', 'class="centericon"');
484
+	}
469 485
 
470 486
 	$output_html = '
471 487
 					<div>
@@ -474,10 +490,11 @@  discard block
 block discarded – undo
474 490
 						</div>
475 491
 						<div class="floatright">';
476 492
 
477
-	if ($post['can_delete'])
478
-		$output_html .= '
493
+	if ($post['can_delete']) {
494
+			$output_html .= '
479 495
 							<a href="' . $scripturl . '?action=moderate;area=userwatch;sa=post;delete=' . $post['id'] . ';start=' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" data-confirm="' . $txt['mc_watched_users_delete_post'] . '" class="you_sure">' . $delete_button . '</a>
480 496
 							<input type="checkbox" name="delete[]" value="' . $post['id'] . '">';
497
+	}
481 498
 
482 499
 	$output_html .= '
483 500
 						</div>
@@ -521,12 +538,12 @@  discard block
 block discarded – undo
521 538
 				<input type="submit" name="save" value="', $txt['save'], '" class="button">
522 539
 			</div>
523 540
 		</form>';
524
-	}
525
-	else
526
-		echo '
541
+	} else {
542
+			echo '
527 543
 		<div class="windowbg">
528 544
 			<div class="centertext">', $txt['mc_no_settings'], '</div>
529 545
 		</div>';
546
+	}
530 547
 
531 548
 	echo '
532 549
 	</div><!-- #modcenter -->';
@@ -622,13 +639,14 @@  discard block
 block discarded – undo
622 639
 					</dd>
623 640
 				</dl>';
624 641
 
625
-	if ($context['template_data']['can_edit_personal'])
626
-		echo '
642
+	if ($context['template_data']['can_edit_personal']) {
643
+			echo '
627 644
 				<input type="checkbox" name="make_personal" id="make_personal"', $context['template_data']['personal'] ? ' checked' : '', '>
628 645
 					<label for="make_personal">
629 646
 						<strong>', $txt['mc_warning_template_personal'], '</strong>
630 647
 					</label>
631 648
 					<p class="smalltext">', $txt['mc_warning_template_personal_desc'], '</p>';
649
+	}
632 650
 
633 651
 	echo '
634 652
 				<input type="submit" name="preview" id="preview_button" value="', $txt['preview'], '" class="button">
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.
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.