Completed
Pull Request — release-2.1 (#4446)
by Mathias
12: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 title_top">
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 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 title_top">
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="windowbg2 noup">';
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,13 +604,13 @@  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
 	// Just a big box to edit the text file ;)
594 616
 	echo '
@@ -598,9 +620,10 @@  discard block
 block discarded – undo
598 620
 			</div>';
599 621
 
600 622
 	// Warning for if the file isn't writable.
601
-	if (!empty($context['warning']))
602
-		echo '
623
+	if (!empty($context['warning'])) {
624
+			echo '
603 625
 			<p class="error">', $context['warning'], '</p>';
626
+	}
604 627
 
605 628
 	echo '
606 629
 			<div class="windowbg2 noup" id="registration_agreement">';
@@ -617,9 +640,10 @@  discard block
 block discarded – undo
617 640
 						<strong>', $txt['admin_agreement_select_language'], ':</strong>
618 641
 						<select name="agree_lang" onchange="document.getElementById(\'change_reg\').submit();" tabindex="', $context['tabindex']++, '">';
619 642
 
620
-		foreach ($context['editable_agreements'] as $file => $name)
621
-			echo '
643
+		foreach ($context['editable_agreements'] as $file => $name) {
644
+					echo '
622 645
 							<option value="', $file, '"', $context['current_agreement'] == $file ? ' selected' : '', '>', $name, '</option>';
646
+		}
623 647
 
624 648
 		echo '
625 649
 						</select>
@@ -659,9 +683,10 @@  discard block
 block discarded – undo
659 683
 {
660 684
 	global $context, $scripturl, $txt;
661 685
 
662
-	if (!empty($context['saved_successful']))
663
-		echo '
686
+	if (!empty($context['saved_successful'])) {
687
+			echo '
664 688
 	<div class="infobox">', $txt['settings_saved'], '</div>';
689
+	}
665 690
 
666 691
 	echo '
667 692
 	<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/Search.template.php 1 patch
Braces   +90 added lines, -65 removed lines patch added patch discarded remove patch
@@ -20,17 +20,19 @@  discard block
 block discarded – undo
20 20
 	echo '
21 21
 	<form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '" name="searchform" id="searchform">';
22 22
 
23
-	if (!empty($context['search_errors']))
24
-		echo '
23
+	if (!empty($context['search_errors'])) {
24
+			echo '
25 25
 		<div class="errorbox">
26 26
 			', implode('<br>', $context['search_errors']['messages']), '
27 27
 		</div>';
28
+	}
28 29
 
29
-	if (!empty($context['search_ignored']))
30
-		echo '
30
+	if (!empty($context['search_ignored'])) {
31
+			echo '
31 32
 		<div class="noticebox">
32 33
 			', $txt['search_warning_ignored_word' . (count($context['search_ignored']) == 1 ? '' : 's')], ': ', implode(', ', $context['search_ignored']), '
33 34
 		</div>';
35
+	}
34 36
 
35 37
 	echo '
36 38
 		<div class="cat_bar">
@@ -48,9 +50,10 @@  discard block
 block discarded – undo
48 50
 				<dd>
49 51
 					<input type="search" name="search" id="searchfor" ', !empty($context['search_params']['search']) ? ' value="' . $context['search_params']['search'] . '"' : '', ' maxlength="', $context['search_string_limit'], '" size="40">';
50 52
 
51
-	if (empty($modSettings['search_simple_fulltext']))
52
-		echo '
53
+	if (empty($modSettings['search_simple_fulltext'])) {
54
+			echo '
53 55
 					<br><em class="smalltext">', $txt['search_example'], '</em>';
56
+	}
54 57
 
55 58
 	echo '
56 59
 				</dd>
@@ -114,21 +117,23 @@  discard block
 block discarded – undo
114 117
 			<input type="hidden" name="advanced" value="1">';
115 118
 
116 119
 	// Require an image to be typed to save spamming?
117
-	if ($context['require_verification'])
118
-		echo '
120
+	if ($context['require_verification']) {
121
+			echo '
119 122
 			<p>
120 123
 				<strong>', $txt['verification'], ':</strong>
121 124
 				', template_control_verification($context['visual_verification_id'], 'all'), '
122 125
 			</p>';
126
+	}
123 127
 
124 128
 	// If $context['search_params']['topic'] is set, that means we're searching just one topic.
125
-	if (!empty($context['search_params']['topic']))
126
-		echo '
129
+	if (!empty($context['search_params']['topic'])) {
130
+			echo '
127 131
 			<p>
128 132
 				', $txt['search_specific_topic'], ' &quot;', $context['search_topic']['link'], '&quot;.
129 133
 			</p>
130 134
 			<input type="hidden" name="topic" value="', $context['search_topic']['id'], '">
131 135
 			<input type="submit" name="b_search" value="', $txt['search'], '" class="button">';
136
+	}
132 137
 
133 138
 	echo '
134 139
 		</div>';
@@ -158,14 +163,15 @@  discard block
 block discarded – undo
158 163
 
159 164
 			foreach ($category['boards'] as $board)
160 165
 			{
161
-				if ($i == $limit)
162
-					echo '
166
+				if ($i == $limit) {
167
+									echo '
163 168
 							</ul>
164 169
 						</li>
165 170
 					</ul>
166 171
 					<ul class="ignoreboards floatright">
167 172
 						<li class="category">
168 173
 							<ul>';
174
+				}
169 175
 
170 176
 				echo '
171 177
 								<li class="board">
@@ -253,17 +259,19 @@  discard block
 block discarded – undo
253 259
 		<div class="roundframe noup">';
254 260
 
255 261
 		// Did they make any typos or mistakes, perhaps?
256
-		if (isset($context['did_you_mean']))
257
-			echo '
262
+		if (isset($context['did_you_mean'])) {
263
+					echo '
258 264
 			<p>
259 265
 				', $txt['search_did_you_mean'], ' <a href="', $scripturl, '?action=search2;params=', $context['did_you_mean_params'], '">', $context['did_you_mean'], '</a>.
260 266
 			</p>';
267
+		}
261 268
 
262
-		if (!empty($context['search_ignored']))
263
-			echo '
269
+		if (!empty($context['search_ignored'])) {
270
+					echo '
264 271
 			<p>
265 272
 				', $txt['search_warning_ignored_word' . (count($context['search_ignored']) == 1 ? '' : 's')], ': ', implode(', ', $context['search_ignored']), '
266 273
 			</p>';
274
+		}
267 275
 
268 276
 		echo '
269 277
 			<form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '">
@@ -286,10 +294,11 @@  discard block
 block discarded – undo
286 294
 					<input type="hidden" name="sort" value="', !empty($context['search_params']['sort']) ? $context['search_params']['sort'] : 'relevance', '">
287 295
 				</div>';
288 296
 
289
-		if (!empty($context['search_params']['brd']))
290
-			foreach ($context['search_params']['brd'] as $board_id)
297
+		if (!empty($context['search_params']['brd'])) {
298
+					foreach ($context['search_params']['brd'] as $board_id)
291 299
 				echo '
292 300
 				<input type="hidden" name="brd[', $board_id, ']" value="', $board_id, '">';
301
+		}
293 302
 
294 303
 		echo '
295 304
 			</form>
@@ -300,18 +309,20 @@  discard block
 block discarded – undo
300 309
 	if ($context['compact'])
301 310
 	{
302 311
 		// Quick moderation set to checkboxes? Oh, how fun :/
303
-		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1)
304
-			echo '
312
+		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) {
313
+					echo '
305 314
 	<form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="topicForm">';
315
+		}
306 316
 
307 317
 		echo '
308 318
 		<div class="cat_bar">
309 319
 			<h3 class="catbg">
310 320
 				<span class="floatright">';
311 321
 
312
-		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1)
313
-			echo '
322
+		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) {
323
+					echo '
314 324
 					<input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');">';
325
+		}
315 326
 		echo '
316 327
 				</span>
317 328
 				<span class="generic_icons filter"></span> ', $txt['mlist_search_results'], ': ', $context['search_params']['search'], '
@@ -319,15 +330,15 @@  discard block
 block discarded – undo
319 330
 		</div>';
320 331
 
321 332
 		// Was anything even found?
322
-		if (!empty($context['topics']))
323
-			echo '
333
+		if (!empty($context['topics'])) {
334
+					echo '
324 335
 		<div class="pagesection">
325 336
 			<span>', $context['page_index'], '</span>
326 337
 		</div>';
327
-
328
-		else
329
-			echo '
338
+		} else {
339
+					echo '
330 340
 		<div class="roundframe noup">', $txt['find_no_results'], '</div>';
341
+		}
331 342
 
332 343
 		// While we have results to show ...
333 344
 		while ($topic = $context['get_topics']())
@@ -350,31 +361,35 @@  discard block
 block discarded – undo
350 361
 					echo '
351 362
 				<span class="floatright">';
352 363
 
353
-					if ($options['display_quick_mod'] == 1)
354
-						echo '
364
+					if ($options['display_quick_mod'] == 1) {
365
+											echo '
355 366
 					<input type="checkbox" name="topics[]" value="', $topic['id'], '">';
356
-
357
-					else
367
+					} else
358 368
 					{
359
-						if ($topic['quick_mod']['remove'])
360
-							echo '
369
+						if ($topic['quick_mod']['remove']) {
370
+													echo '
361 371
 					<a href="', $scripturl, '?action=quickmod;board=' . $topic['board']['id'] . '.0;actions%5B', $topic['id'], '%5D=remove;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons delete" title="', $txt['remove_topic'], '"></span></a>';
372
+						}
362 373
 
363
-						if ($topic['quick_mod']['lock'])
364
-							echo '
374
+						if ($topic['quick_mod']['lock']) {
375
+													echo '
365 376
 					<a href="', $scripturl, '?action=quickmod;board=' . $topic['board']['id'] . '.0;actions%5B', $topic['id'], '%5D=lock;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons lock" title="', $topic['is_locked'] ? $txt['set_unlock'] : $txt['set_lock'], '"></span></a>';
377
+						}
366 378
 
367
-						if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove'])
368
-							echo '
379
+						if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) {
380
+													echo '
369 381
 					<br>';
382
+						}
370 383
 
371
-						if ($topic['quick_mod']['sticky'])
372
-							echo '
384
+						if ($topic['quick_mod']['sticky']) {
385
+													echo '
373 386
 					<a href="', $scripturl, '?action=quickmod;board=' . $topic['board']['id'] . '.0;actions%5B', $topic['id'], '%5D=sticky;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons sticky" title="', $topic['is_sticky'] ? $txt['set_nonsticky'] : $txt['set_sticky'], '"></span></a>';
387
+						}
374 388
 
375
-						if ($topic['quick_mod']['move'])
376
-							echo '
389
+						if ($topic['quick_mod']['move']) {
390
+													echo '
377 391
 					<a href="', $scripturl, '?action=movetopic;topic=', $topic['id'], '.0"><span class="generic_icons move" title="', $txt['move_topic'], '"></span></a>';
392
+						}
378 393
 					}
379 394
 
380 395
 					echo '
@@ -384,20 +399,22 @@  discard block
 block discarded – undo
384 399
 			echo '
385 400
 			</div><!-- .block -->';
386 401
 
387
-				if ($message['body_highlighted'] != '')
388
-					echo '
402
+				if ($message['body_highlighted'] != '') {
403
+									echo '
389 404
 				<div class="list_posts double_height">', $message['body_highlighted'], '</div>';
405
+				}
390 406
 			}
391 407
 
392 408
 			echo '
393 409
 		</div><!-- $topic[css_class] -->';
394 410
 
395 411
 		}
396
-		if (!empty($context['topics']))
397
-			echo '
412
+		if (!empty($context['topics'])) {
413
+					echo '
398 414
 		<div class="pagesection">
399 415
 			<span>', $context['page_index'], '</span>
400 416
 		</div>';
417
+		}
401 418
 
402 419
 		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']))
403 420
 		{
@@ -406,17 +423,19 @@  discard block
 block discarded – undo
406 423
 			<select class="qaction" name="qaction"', $context['can_move'] ? ' onchange="this.form.move_to.disabled = (this.options[this.selectedIndex].value != \'move\');"' : '', '>
407 424
 				<option value="">--------</option>';
408 425
 
409
-			foreach ($context['qmod_actions'] as $qmod_action)
410
-				if ($context['can_' . $qmod_action])
426
+			foreach ($context['qmod_actions'] as $qmod_action) {
427
+							if ($context['can_' . $qmod_action])
411 428
 					echo '
412 429
 				<option value="' . $qmod_action . '">' . $txt['quick_mod_' . $qmod_action] . '</option>';
430
+			}
413 431
 
414 432
 			echo '
415 433
 			</select>';
416 434
 
417
-			if ($context['can_move'])
418
-				echo '
435
+			if ($context['can_move']) {
436
+							echo '
419 437
 			<span id="quick_mod_jump_to"></span>';
438
+			}
420 439
 
421 440
 			echo '
422 441
 			<input type="hidden" name="redirect_url" value="', $scripturl . '?action=search2;params=' . $context['params'], '">
@@ -425,13 +444,13 @@  discard block
 block discarded – undo
425 444
 		}
426 445
 
427 446
 
428
-		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']))
429
-			echo '
447
+		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics'])) {
448
+					echo '
430 449
 		<input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '">
431 450
 	</form>';
451
+		}
432 452
 
433
-	}
434
-	else
453
+	} else
435 454
 	{
436 455
 		echo '
437 456
 	<div class="cat_bar">
@@ -443,9 +462,10 @@  discard block
 block discarded – undo
443 462
 		<span>', $context['page_index'], '</span>
444 463
 	</div>';
445 464
 
446
-		if (empty($context['topics']))
447
-			echo '
465
+		if (empty($context['topics'])) {
466
+					echo '
448 467
 	<div class="information">(', $txt['search_no_results'], ')</div>';
468
+		}
449 469
 
450 470
 		while ($topic = $context['get_topics']())
451 471
 		{
@@ -462,23 +482,27 @@  discard block
 block discarded – undo
462 482
 		</div>
463 483
 		<div class="list_posts">', $message['body_highlighted'], '</div>';
464 484
 
465
-			if ($topic['can_reply'])
466
-				echo '
485
+			if ($topic['can_reply']) {
486
+							echo '
467 487
 		<ul class="quickbuttons">';
488
+			}
468 489
 
469 490
 			// If they *can* reply?
470
-			if ($topic['can_reply'])
471
-				echo '
491
+			if ($topic['can_reply']) {
492
+							echo '
472 493
 			<li><a href="', $scripturl . '?action=post;topic=' . $topic['id'] . '.' . $message['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>';
494
+			}
473 495
 
474 496
 			// If they *can* quote?
475
-			if ($topic['can_quote'])
476
-				echo '
497
+			if ($topic['can_quote']) {
498
+							echo '
477 499
 			<li><a href="', $scripturl . '?action=post;topic=' . $topic['id'] . '.' . $message['start'] . ';quote=' . $message['id'] . '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>';
500
+			}
478 501
 
479
-			if ($topic['can_reply'])
480
-				echo '
502
+			if ($topic['can_reply']) {
503
+							echo '
481 504
 		</ul>';
505
+			}
482 506
 			echo '
483 507
 		<br class="clear">
484 508
 	</div><!-- $topic[css_class] -->';
@@ -497,8 +521,8 @@  discard block
 block discarded – undo
497 521
 	<div class="smalltext righttext" id="search_jump_to"></div>
498 522
 	<script>';
499 523
 
500
-	if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move'])
501
-		echo '
524
+	if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) {
525
+			echo '
502 526
 		if (typeof(window.XMLHttpRequest) != "undefined")
503 527
 			aJumpTo[aJumpTo.length] = new JumpTo({
504 528
 				sContainerId: "quick_mod_jump_to",
@@ -513,6 +537,7 @@  discard block
 block discarded – undo
513 537
 				bDisabled: true,
514 538
 				sCustomName: "move_to"
515 539
 			});';
540
+	}
516 541
 
517 542
 	echo '
518 543
 		if (typeof(window.XMLHttpRequest) != "undefined")
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="windowbg2 noup" 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="windowbg2 noup" 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="windowbg2 noup" 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="windowbg2 noup" 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="windowbg2">
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.
Sources/CacheAPI-postgres.php 2 patches
Braces   +28 added lines, -19 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
  * @version 2.1 Beta 4
12 12
  */
13 13
 
14
-if (!defined('SMF'))
14
+if (!defined('SMF')) {
15 15
 	die('Hacking attempt...');
16
+}
16 17
 
17 18
 /**
18 19
  * PostgreSQL Cache API class
@@ -49,8 +50,9 @@  discard block
 block discarded – undo
49 50
 
50 51
 		$result = pg_execute($db_connection, '', array('public', $db_prefix . 'cache'));
51 52
 
52
-		if (pg_affected_rows($result) === 0)
53
-			pg_query($db_connection, 'CREATE UNLOGGED TABLE ' . $db_prefix . 'cache (key text, value text, ttl bigint, PRIMARY KEY (key))');			
53
+		if (pg_affected_rows($result) === 0) {
54
+					pg_query($db_connection, 'CREATE UNLOGGED TABLE ' . $db_prefix . 'cache (key text, value text, ttl bigint, PRIMARY KEY (key))');
55
+		}
54 56
 	}
55 57
 
56 58
 	/**
@@ -60,14 +62,16 @@  discard block
 block discarded – undo
60 62
 	{
61 63
 		global $smcFunc, $db_connection;
62 64
 
63
-		if ($smcFunc['db_title'] !== 'PostgreSQL')
64
-			return false;
65
+		if ($smcFunc['db_title'] !== 'PostgreSQL') {
66
+					return false;
67
+		}
65 68
 
66 69
 		$result = pg_query($db_connection, 'SHOW server_version_num');
67 70
 		$res = pg_fetch_assoc($result);
68 71
 		
69
-		if ($res['server_version_num'] < 90500)
70
-			return false;
72
+		if ($res['server_version_num'] < 90500) {
73
+					return false;
74
+		}
71 75
 		
72 76
 		return $test ? true : parent::isSupported();
73 77
 	}
@@ -81,13 +85,15 @@  discard block
 block discarded – undo
81 85
 
82 86
 		$ttl = time() - $ttl;
83 87
 		
84
-		if (empty($this->pg_get_data_prep))
85
-			$this->pg_get_data_prep = pg_prepare($db_connection, 'smf_cache_get_data', 'SELECT value FROM ' . $db_prefix . 'cache WHERE key = $1 AND ttl >= $2 LIMIT 1');
88
+		if (empty($this->pg_get_data_prep)) {
89
+					$this->pg_get_data_prep = pg_prepare($db_connection, 'smf_cache_get_data', 'SELECT value FROM ' . $db_prefix . 'cache WHERE key = $1 AND ttl >= $2 LIMIT 1');
90
+		}
86 91
 			
87 92
 		$result = pg_execute($db_connection, 'smf_cache_get_data', array($key, $ttl));
88 93
 		
89
-		if (pg_affected_rows($result) === 0)
90
-			return null;
94
+		if (pg_affected_rows($result) === 0) {
95
+					return null;
96
+		}
91 97
 
92 98
 		$res = pg_fetch_assoc($result);
93 99
 
@@ -101,23 +107,26 @@  discard block
 block discarded – undo
101 107
 	{
102 108
 		global  $db_prefix, $db_connection;
103 109
 
104
-		if (!isset($value))
105
-			$value = '';
110
+		if (!isset($value)) {
111
+					$value = '';
112
+		}
106 113
 
107 114
 		$ttl = time() + $ttl;
108 115
 
109
-		if (empty($this->pg_put_data_prep))
110
-			$this->pg_put_data_prep = pg_prepare($db_connection, 'smf_cache_put_data',
116
+		if (empty($this->pg_put_data_prep)) {
117
+					$this->pg_put_data_prep = pg_prepare($db_connection, 'smf_cache_put_data',
111 118
 				'INSERT INTO ' . $db_prefix . 'cache(key,value,ttl) VALUES($1,$2,$3)
112 119
 				ON CONFLICT(key) DO UPDATE SET value = excluded.value, ttl = excluded.ttl'
113 120
 			);
121
+		}
114 122
 
115 123
 		$result = pg_execute($db_connection, 'smf_cache_put_data', array($key, $value, $ttl));
116 124
 
117
-		if (pg_affected_rows($result) > 0)
118
-			return true;
119
-		else
120
-			return false;
125
+		if (pg_affected_rows($result) > 0) {
126
+					return true;
127
+		} else {
128
+					return false;
129
+		}
121 130
 	}
122 131
 
123 132
 	/**
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	{
166 166
 		global $db_connection, $db_prefix;
167 167
 		
168
-		pg_query($db_connection, 'CREATE LOCAL TEMP TABLE IF NOT EXISTS ' . $db_prefix . 'cache_tmp AS SELECT * FROM ' . $db_prefix . 'cache WHERE ttl >= ' . time() );
168
+		pg_query($db_connection, 'CREATE LOCAL TEMP TABLE IF NOT EXISTS ' . $db_prefix . 'cache_tmp AS SELECT * FROM ' . $db_prefix . 'cache WHERE ttl >= ' . time());
169 169
 	}
170 170
 	
171 171
 	/**
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	{
190 190
 		global $db_connection, $db_prefix;
191 191
 		
192
-		pg_query($db_connection, 'INSERT INTO ' . $db_prefix . 'cache SELECT * FROM '. $db_prefix . 'cache_tmp ON CONFLICT DO NOTHING');
192
+		pg_query($db_connection, 'INSERT INTO ' . $db_prefix . 'cache SELECT * FROM ' . $db_prefix . 'cache_tmp ON CONFLICT DO NOTHING');
193 193
 	}
194 194
 }
195 195
 
Please login to merge, or discard this patch.
Sources/Profile-Actions.php 1 patch
Braces   +117 added lines, -86 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Activate an account.
@@ -48,8 +49,9 @@  discard block
 block discarded – undo
48 49
 		logAction('approve_member', array('member' => $memID), 'admin');
49 50
 
50 51
 		// If we are doing approval, update the stats for the member just in case.
51
-		if (in_array($user_profile[$memID]['is_activated'], array(3, 4, 5, 13, 14, 15)))
52
-			updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 1 ? $modSettings['unapprovedMembers'] - 1 : 0)));
52
+		if (in_array($user_profile[$memID]['is_activated'], array(3, 4, 5, 13, 14, 15))) {
53
+					updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 1 ? $modSettings['unapprovedMembers'] - 1 : 0)));
54
+		}
53 55
 
54 56
 		// Make sure we update the stats too.
55 57
 		updateStats('member', false);
@@ -76,8 +78,9 @@  discard block
 block discarded – undo
76 78
 	$issueErrors = array();
77 79
 
78 80
 	// Doesn't hurt to be overly cautious.
79
-	if (empty($modSettings['warning_enable']) || ($context['user']['is_owner'] && !$cur_profile['warning']) || !allowedTo('issue_warning'))
80
-		fatal_lang_error('no_access', false);
81
+	if (empty($modSettings['warning_enable']) || ($context['user']['is_owner'] && !$cur_profile['warning']) || !allowedTo('issue_warning')) {
82
+			fatal_lang_error('no_access', false);
83
+	}
81 84
 
82 85
 	// Get the base (errors related) stuff done.
83 86
 	loadLanguage('Errors');
@@ -135,16 +138,18 @@  discard block
 block discarded – undo
135 138
 
136 139
 		// This cannot be empty!
137 140
 		$_POST['warn_reason'] = isset($_POST['warn_reason']) ? trim($_POST['warn_reason']) : '';
138
-		if ($_POST['warn_reason'] == '' && !$context['user']['is_owner'])
139
-			$issueErrors[] = 'warning_no_reason';
141
+		if ($_POST['warn_reason'] == '' && !$context['user']['is_owner']) {
142
+					$issueErrors[] = 'warning_no_reason';
143
+		}
140 144
 		$_POST['warn_reason'] = $smcFunc['htmlspecialchars']($_POST['warn_reason']);
141 145
 
142 146
 		$_POST['warning_level'] = (int) $_POST['warning_level'];
143 147
 		$_POST['warning_level'] = max(0, min(100, $_POST['warning_level']));
144
-		if ($_POST['warning_level'] < $context['min_allowed'])
145
-			$_POST['warning_level'] = $context['min_allowed'];
146
-		elseif ($_POST['warning_level'] > $context['max_allowed'])
147
-			$_POST['warning_level'] = $context['max_allowed'];
148
+		if ($_POST['warning_level'] < $context['min_allowed']) {
149
+					$_POST['warning_level'] = $context['min_allowed'];
150
+		} elseif ($_POST['warning_level'] > $context['max_allowed']) {
151
+					$_POST['warning_level'] = $context['max_allowed'];
152
+		}
148 153
 
149 154
 		// Do we actually have to issue them with a PM?
150 155
 		$id_notice = 0;
@@ -152,8 +157,9 @@  discard block
 block discarded – undo
152 157
 		{
153 158
 			$_POST['warn_sub'] = trim($_POST['warn_sub']);
154 159
 			$_POST['warn_body'] = trim($_POST['warn_body']);
155
-			if (empty($_POST['warn_sub']) || empty($_POST['warn_body']))
156
-				$issueErrors[] = 'warning_notify_blank';
160
+			if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) {
161
+							$issueErrors[] = 'warning_notify_blank';
162
+			}
157 163
 			// Send the PM?
158 164
 			else
159 165
 			{
@@ -190,8 +196,8 @@  discard block
 block discarded – undo
190 196
 		if (empty($issueErrors))
191 197
 		{
192 198
 			// Log what we've done!
193
-			if (!$context['user']['is_owner'])
194
-				$smcFunc['db_insert']('',
199
+			if (!$context['user']['is_owner']) {
200
+							$smcFunc['db_insert']('',
195 201
 					'{db_prefix}log_comments',
196 202
 					array(
197 203
 						'id_member' => 'int', 'member_name' => 'string', 'comment_type' => 'string', 'id_recipient' => 'int', 'recipient_name' => 'string-255',
@@ -203,14 +209,14 @@  discard block
 block discarded – undo
203 209
 					),
204 210
 					array('id_comment')
205 211
 				);
212
+			}
206 213
 
207 214
 			// Make the change.
208 215
 			updateMemberData($memID, array('warning' => $_POST['warning_level']));
209 216
 
210 217
 			// Leave a lovely message.
211 218
 			$context['profile_updated'] = $context['user']['is_owner'] ? $txt['profile_updated_own'] : $txt['profile_warning_success'];
212
-		}
213
-		else
219
+		} else
214 220
 		{
215 221
 			// Try to remember some bits.
216 222
 			$context['warning_data'] = array(
@@ -229,8 +235,9 @@  discard block
 block discarded – undo
229 235
 	{
230 236
 		$warning_body = !empty($_POST['warn_body']) ? trim(censorText($_POST['warn_body'])) : '';
231 237
 		$context['preview_subject'] = !empty($_POST['warn_sub']) ? trim($smcFunc['htmlspecialchars']($_POST['warn_sub'])) : '';
232
-		if (empty($_POST['warn_sub']) || empty($_POST['warn_body']))
233
-			$issueErrors[] = 'warning_notify_blank';
238
+		if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) {
239
+					$issueErrors[] = 'warning_notify_blank';
240
+		}
234 241
 
235 242
 		if (!empty($_POST['warn_body']))
236 243
 		{
@@ -254,8 +261,9 @@  discard block
 block discarded – undo
254 261
 	{
255 262
 		// Fill in the suite of errors.
256 263
 		$context['post_errors'] = array();
257
-		foreach ($issueErrors as $error)
258
-			$context['post_errors'][] = $txt[$error];
264
+		foreach ($issueErrors as $error) {
265
+					$context['post_errors'][] = $txt[$error];
266
+		}
259 267
 	}
260 268
 
261 269
 
@@ -272,9 +280,10 @@  discard block
 block discarded – undo
272 280
 		$modSettings['warning_mute'] => $txt['profile_warning_effect_mute'],
273 281
 	);
274 282
 	$context['current_level'] = 0;
275
-	foreach ($context['level_effects'] as $limit => $dummy)
276
-		if ($context['member']['warning'] >= $limit)
283
+	foreach ($context['level_effects'] as $limit => $dummy) {
284
+			if ($context['member']['warning'] >= $limit)
277 285
 			$context['current_level'] = $limit;
286
+	}
278 287
 
279 288
 	$listOptions = array(
280 289
 		'id' => 'view_warnings',
@@ -337,11 +346,12 @@  discard block
 block discarded – undo
337 346
 							' . $warning['reason'] . '
338 347
 						</div>';
339 348
 
340
-						if (!empty($warning['id_notice']))
341
-							$ret .= '
349
+						if (!empty($warning['id_notice'])) {
350
+													$ret .= '
342 351
 						<div class="floatright">
343 352
 							<a href="' . $scripturl . '?action=moderate;area=notice;nid=' . $warning['id_notice'] . '" onclick="window.open(this.href, \'\', \'scrollbars=yes,resizable=yes,width=400,height=250\');return false;" target="_blank" rel="noopener" title="' . $txt['profile_warning_previous_notice'] . '"><span class="generic_icons filter centericon"></span></a>
344 353
 						</div>';
354
+						}
345 355
 
346 356
 						return $ret;
347 357
 					},
@@ -413,8 +423,9 @@  discard block
 block discarded – undo
413 423
 	while ($row = $smcFunc['db_fetch_assoc']($request))
414 424
 	{
415 425
 		// If we're not warning for a message skip any that are.
416
-		if (!$context['warning_for_message'] && strpos($row['body'], '{MESSAGE}') !== false)
417
-			continue;
426
+		if (!$context['warning_for_message'] && strpos($row['body'], '{MESSAGE}') !== false) {
427
+					continue;
428
+		}
418 429
 
419 430
 		$context['notification_templates'][] = array(
420 431
 			'title' => $row['template_title'],
@@ -424,16 +435,18 @@  discard block
 block discarded – undo
424 435
 	$smcFunc['db_free_result']($request);
425 436
 
426 437
 	// Setup the "default" templates.
427
-	foreach (array('spamming', 'offence', 'insulting') as $type)
428
-		$context['notification_templates'][] = array(
438
+	foreach (array('spamming', 'offence', 'insulting') as $type) {
439
+			$context['notification_templates'][] = array(
429 440
 			'title' => $txt['profile_warning_notify_title_' . $type],
430 441
 			'body' => sprintf($txt['profile_warning_notify_template_outline' . (!empty($context['warning_for_message']) ? '_post' : '')], $txt['profile_warning_notify_for_' . $type]),
431 442
 		);
443
+	}
432 444
 
433 445
 	// Replace all the common variables in the templates.
434
-	foreach ($context['notification_templates'] as $k => $name)
435
-		$context['notification_templates'][$k]['body'] = strtr($name['body'], array('{MEMBER}' => un_htmlspecialchars($context['member']['name']), '{MESSAGE}' => '[url=' . $scripturl . '?msg=' . $context['warning_for_message'] . ']' . un_htmlspecialchars($context['warned_message_subject']) . '[/url]', '{SCRIPTURL}' => $scripturl, '{FORUMNAME}' => $mbname, '{REGARDS}' => $txt['regards_team']));
436
-}
446
+	foreach ($context['notification_templates'] as $k => $name) {
447
+			$context['notification_templates'][$k]['body'] = strtr($name['body'], array('{MEMBER}' => un_htmlspecialchars($context['member']['name']), '{MESSAGE}' => '[url=' . $scripturl . '?msg=' . $context['warning_for_message'] . ']' . un_htmlspecialchars($context['warned_message_subject']) . '[/url]', '{SCRIPTURL}' => $scripturl, '{FORUMNAME}' => $mbname, '{REGARDS}' => $txt['regards_team']));
448
+	}
449
+	}
437 450
 
438 451
 /**
439 452
  * Get the number of warnings a user has. Callback for $listOptions['get_count'] in issueWarning()
@@ -517,10 +530,11 @@  discard block
 block discarded – undo
517 530
 {
518 531
 	global $txt, $context, $modSettings, $cur_profile;
519 532
 
520
-	if (!$context['user']['is_owner'])
521
-		isAllowedTo('profile_remove_any');
522
-	elseif (!allowedTo('profile_remove_any'))
523
-		isAllowedTo('profile_remove_own');
533
+	if (!$context['user']['is_owner']) {
534
+			isAllowedTo('profile_remove_any');
535
+	} elseif (!allowedTo('profile_remove_any')) {
536
+			isAllowedTo('profile_remove_own');
537
+	}
524 538
 
525 539
 	// Permissions for removing stuff...
526 540
 	$context['can_delete_posts'] = !$context['user']['is_owner'] && allowedTo('moderate_forum');
@@ -547,10 +561,11 @@  discard block
 block discarded – undo
547 561
 
548 562
 	// @todo Add a way to delete pms as well?
549 563
 
550
-	if (!$context['user']['is_owner'])
551
-		isAllowedTo('profile_remove_any');
552
-	elseif (!allowedTo('profile_remove_any'))
553
-		isAllowedTo('profile_remove_own');
564
+	if (!$context['user']['is_owner']) {
565
+			isAllowedTo('profile_remove_any');
566
+	} elseif (!allowedTo('profile_remove_any')) {
567
+			isAllowedTo('profile_remove_own');
568
+	}
554 569
 
555 570
 	checkSession();
556 571
 
@@ -576,8 +591,9 @@  discard block
 block discarded – undo
576 591
 		list ($another) = $smcFunc['db_fetch_row']($request);
577 592
 		$smcFunc['db_free_result']($request);
578 593
 
579
-		if (empty($another))
580
-			fatal_lang_error('at_least_one_admin', 'critical');
594
+		if (empty($another)) {
595
+					fatal_lang_error('at_least_one_admin', 'critical');
596
+		}
581 597
 	}
582 598
 
583 599
 	// This file is needed for the deleteMembers function.
@@ -656,8 +672,9 @@  discard block
 block discarded – undo
656 672
 					)
657 673
 				);
658 674
 				$topicIDs = array();
659
-				while ($row = $smcFunc['db_fetch_assoc']($request))
660
-					$topicIDs[] = $row['id_topic'];
675
+				while ($row = $smcFunc['db_fetch_assoc']($request)) {
676
+									$topicIDs[] = $row['id_topic'];
677
+				}
661 678
 				$smcFunc['db_free_result']($request);
662 679
 
663 680
 				// Actually remove the topics. Ignore recycling if we want to perma-delete things...
@@ -680,8 +697,9 @@  discard block
 block discarded – undo
680 697
 			// This could take a while... but ya know it's gonna be worth it in the end.
681 698
 			while ($row = $smcFunc['db_fetch_assoc']($request))
682 699
 			{
683
-				if (function_exists('apache_reset_timeout'))
684
-					@apache_reset_timeout();
700
+				if (function_exists('apache_reset_timeout')) {
701
+									@apache_reset_timeout();
702
+				}
685 703
 
686 704
 				removeMessage($row['id_msg']);
687 705
 			}
@@ -689,8 +707,9 @@  discard block
 block discarded – undo
689 707
 		}
690 708
 
691 709
 		// Only delete this poor members account if they are actually being booted out of camp.
692
-		if (isset($_POST['deleteAccount']))
693
-			deleteMembers($memID);
710
+		if (isset($_POST['deleteAccount'])) {
711
+					deleteMembers($memID);
712
+		}
694 713
 	}
695 714
 	// Do they need approval to delete?
696 715
 	elseif (!empty($modSettings['approveAccountDeletion']) && !allowedTo('moderate_forum'))
@@ -741,18 +760,18 @@  discard block
 block discarded – undo
741 760
 		{
742 761
 			foreach ($costs as $duration => $cost)
743 762
 			{
744
-				if ($cost != 0)
745
-					$cost_array[$duration] = $cost;
763
+				if ($cost != 0) {
764
+									$cost_array[$duration] = $cost;
765
+				}
746 766
 			}
747
-		}
748
-		else
767
+		} else
749 768
 		{
750 769
 			$cost_array['fixed'] = $costs['fixed'];
751 770
 		}
752 771
 
753
-		if (empty($cost_array))
754
-			unset($context['subscriptions'][$id]);
755
-		else
772
+		if (empty($cost_array)) {
773
+					unset($context['subscriptions'][$id]);
774
+		} else
756 775
 		{
757 776
 			$context['subscriptions'][$id]['member'] = 0;
758 777
 			$context['subscriptions'][$id]['subscribed'] = false;
@@ -765,13 +784,15 @@  discard block
 block discarded – undo
765 784
 	foreach ($gateways as $id => $gateway)
766 785
 	{
767 786
 		$gateways[$id] = new $gateway['display_class']();
768
-		if (!$gateways[$id]->gatewayEnabled())
769
-			unset($gateways[$id]);
787
+		if (!$gateways[$id]->gatewayEnabled()) {
788
+					unset($gateways[$id]);
789
+		}
770 790
 	}
771 791
 
772 792
 	// No gateways yet?
773
-	if (empty($gateways))
774
-		fatal_error($txt['paid_admin_not_setup_gateway']);
793
+	if (empty($gateways)) {
794
+			fatal_error($txt['paid_admin_not_setup_gateway']);
795
+	}
775 796
 
776 797
 	// Get the current subscriptions.
777 798
 	$request = $smcFunc['db_query']('', '
@@ -786,8 +807,9 @@  discard block
 block discarded – undo
786 807
 	while ($row = $smcFunc['db_fetch_assoc']($request))
787 808
 	{
788 809
 		// The subscription must exist!
789
-		if (!isset($context['subscriptions'][$row['id_subscribe']]))
790
-			continue;
810
+		if (!isset($context['subscriptions'][$row['id_subscribe']])) {
811
+					continue;
812
+		}
791 813
 
792 814
 		$context['current'][$row['id_subscribe']] = array(
793 815
 			'id' => $row['id_sublog'],
@@ -801,8 +823,9 @@  discard block
 block discarded – undo
801 823
 			'status_text' => $row['status'] == 0 ? ($row['payments_pending'] ? $txt['paid_pending'] : $txt['paid_finished']) : $txt['paid_active'],
802 824
 		);
803 825
 
804
-		if ($row['status'] == 1)
805
-			$context['subscriptions'][$row['id_subscribe']]['subscribed'] = true;
826
+		if ($row['status'] == 1) {
827
+					$context['subscriptions'][$row['id_subscribe']]['subscribed'] = true;
828
+		}
806 829
 	}
807 830
 	$smcFunc['db_free_result']($request);
808 831
 
@@ -853,21 +876,25 @@  discard block
 block discarded – undo
853 876
 	if (isset($_GET['confirm']) && isset($_POST['sub_id']) && is_array($_POST['sub_id']))
854 877
 	{
855 878
 		// Hopefully just one.
856
-		foreach ($_POST['sub_id'] as $k => $v)
857
-			$ID_SUB = (int) $k;
879
+		foreach ($_POST['sub_id'] as $k => $v) {
880
+					$ID_SUB = (int) $k;
881
+		}
858 882
 
859
-		if (!isset($context['subscriptions'][$ID_SUB]) || $context['subscriptions'][$ID_SUB]['active'] == 0)
860
-			fatal_lang_error('paid_sub_not_active');
883
+		if (!isset($context['subscriptions'][$ID_SUB]) || $context['subscriptions'][$ID_SUB]['active'] == 0) {
884
+					fatal_lang_error('paid_sub_not_active');
885
+		}
861 886
 
862 887
 		// Simplify...
863 888
 		$context['sub'] = $context['subscriptions'][$ID_SUB];
864 889
 		$period = 'xx';
865
-		if ($context['sub']['flexible'])
866
-			$period = isset($_POST['cur'][$ID_SUB]) && isset($context['sub']['costs'][$_POST['cur'][$ID_SUB]]) ? $_POST['cur'][$ID_SUB] : 'xx';
890
+		if ($context['sub']['flexible']) {
891
+					$period = isset($_POST['cur'][$ID_SUB]) && isset($context['sub']['costs'][$_POST['cur'][$ID_SUB]]) ? $_POST['cur'][$ID_SUB] : 'xx';
892
+		}
867 893
 
868 894
 		// Check we have a valid cost.
869
-		if ($context['sub']['flexible'] && $period == 'xx')
870
-			fatal_lang_error('paid_sub_not_active');
895
+		if ($context['sub']['flexible'] && $period == 'xx') {
896
+					fatal_lang_error('paid_sub_not_active');
897
+		}
871 898
 
872 899
 		// Sort out the cost/currency.
873 900
 		$context['currency'] = $modSettings['paid_currency_code'];
@@ -880,8 +907,7 @@  discard block
 block discarded – undo
880 907
 			$context['cost'] = sprintf($modSettings['paid_currency_symbol'], $context['value']) . '/' . $txt[$_POST['cur'][$ID_SUB]];
881 908
 			// The period value for paypal.
882 909
 			$context['paypal_period'] = strtoupper(substr($_POST['cur'][$ID_SUB], 0, 1));
883
-		}
884
-		else
910
+		} else
885 911
 		{
886 912
 			// Real cost...
887 913
 			$context['value'] = $context['sub']['costs']['fixed'];
@@ -898,13 +924,15 @@  discard block
 block discarded – undo
898 924
 		foreach ($gateways as $id => $gateway)
899 925
 		{
900 926
 			$fields = $gateways[$id]->fetchGatewayFields($context['sub']['id'] . '+' . $memID, $context['sub'], $context['value'], $period, $scripturl . '?action=profile;u=' . $memID . ';area=subscriptions;sub_id=' . $context['sub']['id'] . ';done');
901
-			if (!empty($fields['form']))
902
-				$context['gateways'][] = $fields;
927
+			if (!empty($fields['form'])) {
928
+							$context['gateways'][] = $fields;
929
+			}
903 930
 		}
904 931
 
905 932
 		// Bugger?!
906
-		if (empty($context['gateways']))
907
-			fatal_error($txt['paid_admin_not_setup_gateway']);
933
+		if (empty($context['gateways'])) {
934
+					fatal_error($txt['paid_admin_not_setup_gateway']);
935
+		}
908 936
 
909 937
 		// Now we are going to assume they want to take this out ;)
910 938
 		$new_data = array($context['sub']['id'], $context['value'], $period, 'prepay');
@@ -912,16 +940,19 @@  discard block
 block discarded – undo
912 940
 		{
913 941
 			// What are the details like?
914 942
 			$current_pending = array();
915
-			if ($context['current'][$context['sub']['id']]['pending_details'] != '')
916
-				$current_pending = $smcFunc['json_decode']($context['current'][$context['sub']['id']]['pending_details'], true);
943
+			if ($context['current'][$context['sub']['id']]['pending_details'] != '') {
944
+							$current_pending = $smcFunc['json_decode']($context['current'][$context['sub']['id']]['pending_details'], true);
945
+			}
917 946
 			// Don't get silly.
918
-			if (count($current_pending) > 9)
919
-				$current_pending = array();
947
+			if (count($current_pending) > 9) {
948
+							$current_pending = array();
949
+			}
920 950
 			$pending_count = 0;
921 951
 			// Only record real pending payments as will otherwise confuse the admin!
922
-			foreach ($current_pending as $pending)
923
-				if ($pending[3] == 'payback')
952
+			foreach ($current_pending as $pending) {
953
+							if ($pending[3] == 'payback')
924 954
 					$pending_count++;
955
+			}
925 956
 
926 957
 			if (!in_array($new_data, $current_pending))
927 958
 			{
@@ -966,9 +997,9 @@  discard block
 block discarded – undo
966 997
 
967 998
 		// Quit.
968 999
 		return;
1000
+	} else {
1001
+			$context['sub_template'] = 'user_subscription';
1002
+	}
969 1003
 	}
970
-	else
971
-		$context['sub_template'] = 'user_subscription';
972
-}
973 1004
 
974 1005
 ?>
975 1006
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/Session.php 1 patch
Braces   +34 added lines, -23 removed lines patch added patch discarded remove patch
@@ -17,8 +17,9 @@  discard block
 block discarded – undo
17 17
  * @version 2.1 Beta 4
18 18
  */
19 19
 
20
-if (!defined('SMF'))
20
+if (!defined('SMF')) {
21 21
 	die('No direct access...');
22
+}
22 23
 
23 24
 /**
24 25
  * Attempt to start the session, unless it already has been.
@@ -38,8 +39,9 @@  discard block
 block discarded – undo
38 39
 	{
39 40
 		$parsed_url = parse_url($boardurl);
40 41
 
41
-		if (preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1)
42
-			@ini_set('session.cookie_domain', '.' . $parts[1]);
42
+		if (preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1) {
43
+					@ini_set('session.cookie_domain', '.' . $parts[1]);
44
+		}
43 45
 	}
44 46
 	// @todo Set the session cookie path?
45 47
 
@@ -47,8 +49,9 @@  discard block
 block discarded – undo
47 49
 	if ((ini_get('session.auto_start') == 1 && !empty($modSettings['databaseSession_enable'])) || session_id() == '')
48 50
 	{
49 51
 		// Attempt to end the already-started session.
50
-		if (ini_get('session.auto_start') == 1)
51
-			session_write_close();
52
+		if (ini_get('session.auto_start') == 1) {
53
+					session_write_close();
54
+		}
52 55
 
53 56
 		// This is here to stop people from using bad junky PHPSESSIDs.
54 57
 		if (isset($_REQUEST[session_name()]) && preg_match('~^[A-Za-z0-9,-]{16,64}$~', $_REQUEST[session_name()]) == 0 && !isset($_COOKIE[session_name()]))
@@ -63,23 +66,26 @@  discard block
 block discarded – undo
63 66
 		if (!empty($modSettings['databaseSession_enable']))
64 67
 		{
65 68
 			@ini_set('session.serialize_handler', 'php_serialize');
66
-			if (ini_get('session.serialize_handler') != 'php_serialize')
67
-				@ini_set('session.serialize_handler', 'php');
69
+			if (ini_get('session.serialize_handler') != 'php_serialize') {
70
+							@ini_set('session.serialize_handler', 'php');
71
+			}
68 72
 			session_set_save_handler('sessionOpen', 'sessionClose', 'sessionRead', 'sessionWrite', 'sessionDestroy', 'sessionGC');
69 73
 			@ini_set('session.gc_probability', '1');
74
+		} elseif (ini_get('session.gc_maxlifetime') <= 1440 && !empty($modSettings['databaseSession_lifetime'])) {
75
+					@ini_set('session.gc_maxlifetime', max($modSettings['databaseSession_lifetime'], 60));
70 76
 		}
71
-		elseif (ini_get('session.gc_maxlifetime') <= 1440 && !empty($modSettings['databaseSession_lifetime']))
72
-			@ini_set('session.gc_maxlifetime', max($modSettings['databaseSession_lifetime'], 60));
73 77
 
74 78
 		// Use cache setting sessions?
75
-		if (empty($modSettings['databaseSession_enable']) && !empty($modSettings['cache_enable']) && php_sapi_name() != 'cli')
76
-			call_integration_hook('integrate_session_handlers');
79
+		if (empty($modSettings['databaseSession_enable']) && !empty($modSettings['cache_enable']) && php_sapi_name() != 'cli') {
80
+					call_integration_hook('integrate_session_handlers');
81
+		}
77 82
 
78 83
 		session_start();
79 84
 
80 85
 		// Change it so the cache settings are a little looser than default.
81
-		if (!empty($modSettings['databaseSession_loose']))
82
-			header('Cache-Control: private');
86
+		if (!empty($modSettings['databaseSession_loose'])) {
87
+					header('Cache-Control: private');
88
+		}
83 89
 	}
84 90
 
85 91
 	// Set the randomly generated code.
@@ -125,8 +131,9 @@  discard block
 block discarded – undo
125 131
 {
126 132
 	global $smcFunc;
127 133
 
128
-	if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0)
129
-		return '';
134
+	if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) {
135
+			return '';
136
+	}
130 137
 
131 138
 	// Look for it in the database.
132 139
 	$result = $smcFunc['db_query']('', '
@@ -155,8 +162,9 @@  discard block
 block discarded – undo
155 162
 {
156 163
 	global $smcFunc;
157 164
 
158
-	if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0)
159
-		return false;
165
+	if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) {
166
+			return false;
167
+	}
160 168
 
161 169
 	// First try to update an existing row...
162 170
 	$smcFunc['db_query']('', '
@@ -171,13 +179,14 @@  discard block
 block discarded – undo
171 179
 	);
172 180
 
173 181
 	// If that didn't work, try inserting a new one.
174
-	if ($smcFunc['db_affected_rows']() == 0)
175
-		$smcFunc['db_insert']('ignore',
182
+	if ($smcFunc['db_affected_rows']() == 0) {
183
+			$smcFunc['db_insert']('ignore',
176 184
 			'{db_prefix}sessions',
177 185
 			array('session_id' => 'string', 'data' => 'string', 'last_update' => 'int'),
178 186
 			array($session_id, $data, time()),
179 187
 			array('session_id')
180 188
 		);
189
+	}
181 190
 
182 191
 	return ($smcFunc['db_affected_rows']() == 0 ? false : true);
183 192
 }
@@ -192,8 +201,9 @@  discard block
 block discarded – undo
192 201
 {
193 202
 	global $smcFunc;
194 203
 
195
-	if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0)
196
-		return false;
204
+	if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) {
205
+			return false;
206
+	}
197 207
 
198 208
 	// Just delete the row...
199 209
 	$smcFunc['db_query']('', '
@@ -219,8 +229,9 @@  discard block
 block discarded – undo
219 229
 	global $modSettings, $smcFunc;
220 230
 
221 231
 	// Just set to the default or lower?  Ignore it for a higher value. (hopefully)
222
-	if (!empty($modSettings['databaseSession_lifetime']) && ($max_lifetime <= 1440 || $modSettings['databaseSession_lifetime'] > $max_lifetime))
223
-		$max_lifetime = max($modSettings['databaseSession_lifetime'], 60);
232
+	if (!empty($modSettings['databaseSession_lifetime']) && ($max_lifetime <= 1440 || $modSettings['databaseSession_lifetime'] > $max_lifetime)) {
233
+			$max_lifetime = max($modSettings['databaseSession_lifetime'], 60);
234
+	}
224 235
 
225 236
 	// Clean up after yerself ;).
226 237
 	$smcFunc['db_query']('', '
Please login to merge, or discard this patch.
Sources/Security.php 1 patch
Braces   +255 added lines, -197 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 4
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * Check if the user is who he/she says he is
@@ -42,12 +43,14 @@  discard block
 block discarded – undo
42 43
 	$refreshTime = isset($_GET['xml']) ? 4200 : 3600;
43 44
 
44 45
 	// Is the security option off?
45
-	if (!empty($modSettings['securityDisable' . ($type != 'admin' ? '_' . $type : '')]))
46
-		return;
46
+	if (!empty($modSettings['securityDisable' . ($type != 'admin' ? '_' . $type : '')])) {
47
+			return;
48
+	}
47 49
 
48 50
 	// Or are they already logged in?, Moderator or admin session is need for this area
49
-	if ((!empty($_SESSION[$type . '_time']) && $_SESSION[$type . '_time'] + $refreshTime >= time()) || (!empty($_SESSION['admin_time']) && $_SESSION['admin_time'] + $refreshTime >= time()))
50
-		return;
51
+	if ((!empty($_SESSION[$type . '_time']) && $_SESSION[$type . '_time'] + $refreshTime >= time()) || (!empty($_SESSION['admin_time']) && $_SESSION['admin_time'] + $refreshTime >= time())) {
52
+			return;
53
+	}
51 54
 
52 55
 	require_once($sourcedir . '/Subs-Auth.php');
53 56
 
@@ -55,8 +58,9 @@  discard block
 block discarded – undo
55 58
 	if (isset($_POST[$type . '_pass']))
56 59
 	{
57 60
 		// Check to ensure we're forcing SSL for authentication
58
-		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn())
59
-			fatal_lang_error('login_ssl_required');
61
+		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) {
62
+					fatal_lang_error('login_ssl_required');
63
+		}
60 64
 
61 65
 		checkSession();
62 66
 
@@ -72,17 +76,19 @@  discard block
 block discarded – undo
72 76
 	}
73 77
 
74 78
 	// Better be sure to remember the real referer
75
-	if (empty($_SESSION['request_referer']))
76
-		$_SESSION['request_referer'] = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array();
77
-	elseif (empty($_POST))
78
-		unset($_SESSION['request_referer']);
79
+	if (empty($_SESSION['request_referer'])) {
80
+			$_SESSION['request_referer'] = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array();
81
+	} elseif (empty($_POST)) {
82
+			unset($_SESSION['request_referer']);
83
+	}
79 84
 
80 85
 	// Need to type in a password for that, man.
81
-	if (!isset($_GET['xml']))
82
-		adminLogin($type);
83
-	else
84
-		return 'session_verify_fail';
85
-}
86
+	if (!isset($_GET['xml'])) {
87
+			adminLogin($type);
88
+	} else {
89
+			return 'session_verify_fail';
90
+	}
91
+	}
86 92
 
87 93
 /**
88 94
  * Require a user who is logged in. (not a guest.)
@@ -96,25 +102,30 @@  discard block
 block discarded – undo
96 102
 	global $user_info, $txt, $context, $scripturl, $modSettings;
97 103
 
98 104
 	// Luckily, this person isn't a guest.
99
-	if (!$user_info['is_guest'])
100
-		return;
105
+	if (!$user_info['is_guest']) {
106
+			return;
107
+	}
101 108
 
102 109
 	// Log what they were trying to do didn't work)
103
-	if (!empty($modSettings['who_enabled']))
104
-		$_GET['error'] = 'guest_login';
110
+	if (!empty($modSettings['who_enabled'])) {
111
+			$_GET['error'] = 'guest_login';
112
+	}
105 113
 	writeLog(true);
106 114
 
107 115
 	// Just die.
108
-	if (isset($_REQUEST['xml']))
109
-		obExit(false);
116
+	if (isset($_REQUEST['xml'])) {
117
+			obExit(false);
118
+	}
110 119
 
111 120
 	// Attempt to detect if they came from dlattach.
112
-	if (SMF != 'SSI' && empty($context['theme_loaded']))
113
-		loadTheme();
121
+	if (SMF != 'SSI' && empty($context['theme_loaded'])) {
122
+			loadTheme();
123
+	}
114 124
 
115 125
 	// Never redirect to an attachment
116
-	if (strpos($_SERVER['REQUEST_URL'], 'dlattach') === false)
117
-		$_SESSION['login_url'] = $_SERVER['REQUEST_URL'];
126
+	if (strpos($_SERVER['REQUEST_URL'], 'dlattach') === false) {
127
+			$_SESSION['login_url'] = $_SERVER['REQUEST_URL'];
128
+	}
118 129
 
119 130
 	// Load the Login template and language file.
120 131
 	loadLanguage('Login');
@@ -124,8 +135,7 @@  discard block
 block discarded – undo
124 135
 	{
125 136
 		$_SESSION['login_url'] = $scripturl . '?' . $_SERVER['QUERY_STRING'];
126 137
 		redirectexit('action=login');
127
-	}
128
-	else
138
+	} else
129 139
 	{
130 140
 		loadTemplate('Login');
131 141
 		$context['sub_template'] = 'kick_guest';
@@ -155,8 +165,9 @@  discard block
 block discarded – undo
155 165
 	global $sourcedir, $cookiename, $user_settings, $smcFunc;
156 166
 
157 167
 	// You cannot be banned if you are an admin - doesn't help if you log out.
158
-	if ($user_info['is_admin'])
159
-		return;
168
+	if ($user_info['is_admin']) {
169
+			return;
170
+	}
160 171
 
161 172
 	// Only check the ban every so often. (to reduce load.)
162 173
 	if ($forceCheck || !isset($_SESSION['ban']) || empty($modSettings['banLastUpdated']) || ($_SESSION['ban']['last_checked'] < $modSettings['banLastUpdated']) || $_SESSION['ban']['id_member'] != $user_info['id'] || $_SESSION['ban']['ip'] != $user_info['ip'] || $_SESSION['ban']['ip2'] != $user_info['ip2'] || (isset($user_info['email'], $_SESSION['ban']['email']) && $_SESSION['ban']['email'] != $user_info['email']))
@@ -177,8 +188,9 @@  discard block
 block discarded – undo
177 188
 		// Check both IP addresses.
178 189
 		foreach (array('ip', 'ip2') as $ip_number)
179 190
 		{
180
-			if ($ip_number == 'ip2' && $user_info['ip2'] == $user_info['ip'])
181
-				continue;
191
+			if ($ip_number == 'ip2' && $user_info['ip2'] == $user_info['ip']) {
192
+							continue;
193
+			}
182 194
 			$ban_query[] = ' {inet:' . $ip_number . '} BETWEEN bi.ip_low and bi.ip_high';
183 195
 			$ban_query_vars[$ip_number] = $user_info[$ip_number];
184 196
 			// IP was valid, maybe there's also a hostname...
@@ -228,24 +240,28 @@  discard block
 block discarded – undo
228 240
 			// Store every type of ban that applies to you in your session.
229 241
 			while ($row = $smcFunc['db_fetch_assoc']($request))
230 242
 			{
231
-				foreach ($restrictions as $restriction)
232
-					if (!empty($row[$restriction]))
243
+				foreach ($restrictions as $restriction) {
244
+									if (!empty($row[$restriction]))
233 245
 					{
234 246
 						$_SESSION['ban'][$restriction]['reason'] = $row['reason'];
247
+				}
235 248
 						$_SESSION['ban'][$restriction]['ids'][] = $row['id_ban'];
236
-						if (!isset($_SESSION['ban']['expire_time']) || ($_SESSION['ban']['expire_time'] != 0 && ($row['expire_time'] == 0 || $row['expire_time'] > $_SESSION['ban']['expire_time'])))
237
-							$_SESSION['ban']['expire_time'] = $row['expire_time'];
249
+						if (!isset($_SESSION['ban']['expire_time']) || ($_SESSION['ban']['expire_time'] != 0 && ($row['expire_time'] == 0 || $row['expire_time'] > $_SESSION['ban']['expire_time']))) {
250
+													$_SESSION['ban']['expire_time'] = $row['expire_time'];
251
+						}
238 252
 
239
-						if (!$user_info['is_guest'] && $restriction == 'cannot_access' && ($row['id_member'] == $user_info['id'] || $row['email_address'] == $user_info['email']))
240
-							$flag_is_activated = true;
253
+						if (!$user_info['is_guest'] && $restriction == 'cannot_access' && ($row['id_member'] == $user_info['id'] || $row['email_address'] == $user_info['email'])) {
254
+													$flag_is_activated = true;
255
+						}
241 256
 					}
242 257
 			}
243 258
 			$smcFunc['db_free_result']($request);
244 259
 		}
245 260
 
246 261
 		// Mark the cannot_access and cannot_post bans as being 'hit'.
247
-		if (isset($_SESSION['ban']['cannot_access']) || isset($_SESSION['ban']['cannot_post']) || isset($_SESSION['ban']['cannot_login']))
248
-			log_ban(array_merge(isset($_SESSION['ban']['cannot_access']) ? $_SESSION['ban']['cannot_access']['ids'] : array(), isset($_SESSION['ban']['cannot_post']) ? $_SESSION['ban']['cannot_post']['ids'] : array(), isset($_SESSION['ban']['cannot_login']) ? $_SESSION['ban']['cannot_login']['ids'] : array()));
262
+		if (isset($_SESSION['ban']['cannot_access']) || isset($_SESSION['ban']['cannot_post']) || isset($_SESSION['ban']['cannot_login'])) {
263
+					log_ban(array_merge(isset($_SESSION['ban']['cannot_access']) ? $_SESSION['ban']['cannot_access']['ids'] : array(), isset($_SESSION['ban']['cannot_post']) ? $_SESSION['ban']['cannot_post']['ids'] : array(), isset($_SESSION['ban']['cannot_login']) ? $_SESSION['ban']['cannot_login']['ids'] : array()));
264
+		}
249 265
 
250 266
 		// If for whatever reason the is_activated flag seems wrong, do a little work to clear it up.
251 267
 		if ($user_info['id'] && (($user_settings['is_activated'] >= 10 && !$flag_is_activated)
@@ -260,8 +276,9 @@  discard block
 block discarded – undo
260 276
 	if (!isset($_SESSION['ban']['cannot_access']) && !empty($_COOKIE[$cookiename . '_']))
261 277
 	{
262 278
 		$bans = explode(',', $_COOKIE[$cookiename . '_']);
263
-		foreach ($bans as $key => $value)
264
-			$bans[$key] = (int) $value;
279
+		foreach ($bans as $key => $value) {
280
+					$bans[$key] = (int) $value;
281
+		}
265 282
 		$request = $smcFunc['db_query']('', '
266 283
 			SELECT bi.id_ban, bg.reason
267 284
 			FROM {db_prefix}ban_items AS bi
@@ -297,14 +314,15 @@  discard block
 block discarded – undo
297 314
 	if (isset($_SESSION['ban']['cannot_access']))
298 315
 	{
299 316
 		// We don't wanna see you!
300
-		if (!$user_info['is_guest'])
301
-			$smcFunc['db_query']('', '
317
+		if (!$user_info['is_guest']) {
318
+					$smcFunc['db_query']('', '
302 319
 				DELETE FROM {db_prefix}log_online
303 320
 				WHERE id_member = {int:current_member}',
304 321
 				array(
305 322
 					'current_member' => $user_info['id'],
306 323
 				)
307 324
 			);
325
+		}
308 326
 
309 327
 		// 'Log' the user out.  Can't have any funny business... (save the name!)
310 328
 		$old_name = isset($user_info['name']) && $user_info['name'] != '' ? $user_info['name'] : $txt['guest_title'];
@@ -390,9 +408,10 @@  discard block
 block discarded – undo
390 408
 	}
391 409
 
392 410
 	// Fix up the banning permissions.
393
-	if (isset($user_info['permissions']))
394
-		banPermissions();
395
-}
411
+	if (isset($user_info['permissions'])) {
412
+			banPermissions();
413
+	}
414
+	}
396 415
 
397 416
 /**
398 417
  * Fix permissions according to ban status.
@@ -403,8 +422,9 @@  discard block
 block discarded – undo
403 422
 	global $user_info, $sourcedir, $modSettings, $context;
404 423
 
405 424
 	// Somehow they got here, at least take away all permissions...
406
-	if (isset($_SESSION['ban']['cannot_access']))
407
-		$user_info['permissions'] = array();
425
+	if (isset($_SESSION['ban']['cannot_access'])) {
426
+			$user_info['permissions'] = array();
427
+	}
408 428
 	// Okay, well, you can watch, but don't touch a thing.
409 429
 	elseif (isset($_SESSION['ban']['cannot_post']) || (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $user_info['warning']))
410 430
 	{
@@ -446,19 +466,20 @@  discard block
 block discarded – undo
446 466
 		call_integration_hook('integrate_warn_permissions', array(&$permission_change));
447 467
 		foreach ($permission_change as $old => $new)
448 468
 		{
449
-			if (!in_array($old, $user_info['permissions']))
450
-				unset($permission_change[$old]);
451
-			else
452
-				$user_info['permissions'][] = $new;
469
+			if (!in_array($old, $user_info['permissions'])) {
470
+							unset($permission_change[$old]);
471
+			} else {
472
+							$user_info['permissions'][] = $new;
473
+			}
453 474
 		}
454 475
 		$user_info['permissions'] = array_diff($user_info['permissions'], array_keys($permission_change));
455 476
 	}
456 477
 
457 478
 	// @todo Find a better place to call this? Needs to be after permissions loaded!
458 479
 	// Finally, some bits we cache in the session because it saves queries.
459
-	if (isset($_SESSION['mc']) && $_SESSION['mc']['time'] > $modSettings['settings_updated'] && $_SESSION['mc']['id'] == $user_info['id'])
460
-		$user_info['mod_cache'] = $_SESSION['mc'];
461
-	else
480
+	if (isset($_SESSION['mc']) && $_SESSION['mc']['time'] > $modSettings['settings_updated'] && $_SESSION['mc']['id'] == $user_info['id']) {
481
+			$user_info['mod_cache'] = $_SESSION['mc'];
482
+	} else
462 483
 	{
463 484
 		require_once($sourcedir . '/Subs-Auth.php');
464 485
 		rebuildModCache();
@@ -469,14 +490,12 @@  discard block
 block discarded – undo
469 490
 	{
470 491
 		$context['open_mod_reports'] = $_SESSION['rc']['reports'];
471 492
 		$context['open_member_reports'] = $_SESSION['rc']['member_reports'];
472
-	}
473
-	elseif ($_SESSION['mc']['bq'] != '0=1')
493
+	} elseif ($_SESSION['mc']['bq'] != '0=1')
474 494
 	{
475 495
 		require_once($sourcedir . '/Subs-ReportedContent.php');
476 496
 		$context['open_mod_reports'] = recountOpenReports('posts');
477 497
 		$context['open_member_reports'] = recountOpenReports('members');
478
-	}
479
-	else
498
+	} else
480 499
 	{
481 500
 		$context['open_mod_reports'] = 0;
482 501
 		$context['open_member_reports'] = 0;
@@ -496,8 +515,9 @@  discard block
 block discarded – undo
496 515
 	global $user_info, $smcFunc;
497 516
 
498 517
 	// Don't log web accelerators, it's very confusing...
499
-	if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch')
500
-		return;
518
+	if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') {
519
+			return;
520
+	}
501 521
 
502 522
 	$smcFunc['db_insert']('',
503 523
 		'{db_prefix}log_banned',
@@ -507,8 +527,8 @@  discard block
 block discarded – undo
507 527
 	);
508 528
 
509 529
 	// One extra point for these bans.
510
-	if (!empty($ban_ids))
511
-		$smcFunc['db_query']('', '
530
+	if (!empty($ban_ids)) {
531
+			$smcFunc['db_query']('', '
512 532
 			UPDATE {db_prefix}ban_items
513 533
 			SET hits = hits + 1
514 534
 			WHERE id_ban IN ({array_int:ban_ids})',
@@ -516,7 +536,8 @@  discard block
 block discarded – undo
516 536
 				'ban_ids' => $ban_ids,
517 537
 			)
518 538
 		);
519
-}
539
+	}
540
+	}
520 541
 
521 542
 /**
522 543
  * Checks if a given email address might be banned.
@@ -532,8 +553,9 @@  discard block
 block discarded – undo
532 553
 	global $txt, $smcFunc;
533 554
 
534 555
 	// Can't ban an empty email
535
-	if (empty($email) || trim($email) == '')
536
-		return;
556
+	if (empty($email) || trim($email) == '') {
557
+			return;
558
+	}
537 559
 
538 560
 	// Let's start with the bans based on your IP/hostname/memberID...
539 561
 	$ban_ids = isset($_SESSION['ban'][$restriction]) ? $_SESSION['ban'][$restriction]['ids'] : array();
@@ -606,16 +628,18 @@  discard block
 block discarded – undo
606 628
 	if ($type == 'post')
607 629
 	{
608 630
 		$check = isset($_POST[$_SESSION['session_var']]) ? $_POST[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_POST['sc']) ? $_POST['sc'] : null);
609
-		if ($check !== $sc)
610
-			$error = 'session_timeout';
631
+		if ($check !== $sc) {
632
+					$error = 'session_timeout';
633
+		}
611 634
 	}
612 635
 
613 636
 	// How about $_GET['sesc']?
614 637
 	elseif ($type == 'get')
615 638
 	{
616 639
 		$check = isset($_GET[$_SESSION['session_var']]) ? $_GET[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_GET['sesc']) ? $_GET['sesc'] : null);
617
-		if ($check !== $sc)
618
-			$error = 'session_verify_fail';
640
+		if ($check !== $sc) {
641
+					$error = 'session_verify_fail';
642
+		}
619 643
 	}
620 644
 
621 645
 	// Or can it be in either?
@@ -623,13 +647,15 @@  discard block
 block discarded – undo
623 647
 	{
624 648
 		$check = isset($_GET[$_SESSION['session_var']]) ? $_GET[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_GET['sesc']) ? $_GET['sesc'] : (isset($_POST[$_SESSION['session_var']]) ? $_POST[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_POST['sc']) ? $_POST['sc'] : null)));
625 649
 
626
-		if ($check !== $sc)
627
-			$error = 'session_verify_fail';
650
+		if ($check !== $sc) {
651
+					$error = 'session_verify_fail';
652
+		}
628 653
 	}
629 654
 
630 655
 	// Verify that they aren't changing user agents on us - that could be bad.
631
-	if ((!isset($_SESSION['USER_AGENT']) || $_SESSION['USER_AGENT'] != $_SERVER['HTTP_USER_AGENT']) && empty($modSettings['disableCheckUA']))
632
-		$error = 'session_verify_fail';
656
+	if ((!isset($_SESSION['USER_AGENT']) || $_SESSION['USER_AGENT'] != $_SERVER['HTTP_USER_AGENT']) && empty($modSettings['disableCheckUA'])) {
657
+			$error = 'session_verify_fail';
658
+	}
633 659
 
634 660
 	// Make sure a page with session check requirement is not being prefetched.
635 661
 	if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch')
@@ -640,30 +666,35 @@  discard block
 block discarded – undo
640 666
 	}
641 667
 
642 668
 	// Check the referring site - it should be the same server at least!
643
-	if (isset($_SESSION['request_referer']))
644
-		$referrer = $_SESSION['request_referer'];
645
-	else
646
-		$referrer = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array();
669
+	if (isset($_SESSION['request_referer'])) {
670
+			$referrer = $_SESSION['request_referer'];
671
+	} else {
672
+			$referrer = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array();
673
+	}
647 674
 	if (!empty($referrer['host']))
648 675
 	{
649
-		if (strpos($_SERVER['HTTP_HOST'], ':') !== false)
650
-			$real_host = substr($_SERVER['HTTP_HOST'], 0, strpos($_SERVER['HTTP_HOST'], ':'));
651
-		else
652
-			$real_host = $_SERVER['HTTP_HOST'];
676
+		if (strpos($_SERVER['HTTP_HOST'], ':') !== false) {
677
+					$real_host = substr($_SERVER['HTTP_HOST'], 0, strpos($_SERVER['HTTP_HOST'], ':'));
678
+		} else {
679
+					$real_host = $_SERVER['HTTP_HOST'];
680
+		}
653 681
 
654 682
 		$parsed_url = parse_url($boardurl);
655 683
 
656 684
 		// Are global cookies on?  If so, let's check them ;).
657 685
 		if (!empty($modSettings['globalCookies']))
658 686
 		{
659
-			if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $parsed_url['host'], $parts) == 1)
660
-				$parsed_url['host'] = $parts[1];
687
+			if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $parsed_url['host'], $parts) == 1) {
688
+							$parsed_url['host'] = $parts[1];
689
+			}
661 690
 
662
-			if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $referrer['host'], $parts) == 1)
663
-				$referrer['host'] = $parts[1];
691
+			if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $referrer['host'], $parts) == 1) {
692
+							$referrer['host'] = $parts[1];
693
+			}
664 694
 
665
-			if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $real_host, $parts) == 1)
666
-				$real_host = $parts[1];
695
+			if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $real_host, $parts) == 1) {
696
+							$real_host = $parts[1];
697
+			}
667 698
 		}
668 699
 
669 700
 		// Okay: referrer must either match parsed_url or real_host.
@@ -681,12 +712,14 @@  discard block
 block discarded – undo
681 712
 		$log_error = true;
682 713
 	}
683 714
 
684
-	if (strtolower($_SERVER['HTTP_USER_AGENT']) == 'hacker')
685
-		fatal_error('Sound the alarm!  It\'s a hacker!  Close the castle gates!!', false);
715
+	if (strtolower($_SERVER['HTTP_USER_AGENT']) == 'hacker') {
716
+			fatal_error('Sound the alarm!  It\'s a hacker!  Close the castle gates!!', false);
717
+	}
686 718
 
687 719
 	// Everything is ok, return an empty string.
688
-	if (!isset($error))
689
-		return '';
720
+	if (!isset($error)) {
721
+			return '';
722
+	}
690 723
 	// A session error occurred, show the error.
691 724
 	elseif ($is_fatal)
692 725
 	{
@@ -695,13 +728,14 @@  discard block
 block discarded – undo
695 728
 			ob_end_clean();
696 729
 			header('HTTP/1.1 403 Forbidden - Session timeout');
697 730
 			die;
731
+		} else {
732
+					fatal_lang_error($error, isset($log_error) ? 'user' : false);
698 733
 		}
699
-		else
700
-			fatal_lang_error($error, isset($log_error) ? 'user' : false);
701 734
 	}
702 735
 	// A session error occurred, return the error to the calling function.
703
-	else
704
-		return $error;
736
+	else {
737
+			return $error;
738
+	}
705 739
 
706 740
 	// We really should never fall through here, for very important reasons.  Let's make sure.
707 741
 	trigger_error('Hacking attempt...', E_USER_ERROR);
@@ -717,10 +751,9 @@  discard block
 block discarded – undo
717 751
 {
718 752
 	global $modSettings;
719 753
 
720
-	if (isset($_GET['confirm']) && isset($_SESSION['confirm_' . $action]) && md5($_GET['confirm'] . $_SERVER['HTTP_USER_AGENT']) == $_SESSION['confirm_' . $action])
721
-		return true;
722
-
723
-	else
754
+	if (isset($_GET['confirm']) && isset($_SESSION['confirm_' . $action]) && md5($_GET['confirm'] . $_SERVER['HTTP_USER_AGENT']) == $_SESSION['confirm_' . $action]) {
755
+			return true;
756
+	} else
724 757
 	{
725 758
 		$token = md5(mt_rand() . session_id() . (string) microtime() . $modSettings['rand_seed']);
726 759
 		$_SESSION['confirm_' . $action] = md5($token . $_SERVER['HTTP_USER_AGENT']);
@@ -771,9 +804,9 @@  discard block
 block discarded – undo
771 804
 			$return = $_SESSION['token'][$type . '-' . $action][3];
772 805
 			unset($_SESSION['token'][$type . '-' . $action]);
773 806
 			return $return;
807
+		} else {
808
+					return '';
774 809
 		}
775
-		else
776
-			return '';
777 810
 	}
778 811
 
779 812
 	// This nasty piece of code validates a token.
@@ -804,12 +837,14 @@  discard block
 block discarded – undo
804 837
 		fatal_lang_error('token_verify_fail', false);
805 838
 	}
806 839
 	// Remove this token as its useless
807
-	else
808
-		unset($_SESSION['token'][$type . '-' . $action]);
840
+	else {
841
+			unset($_SESSION['token'][$type . '-' . $action]);
842
+	}
809 843
 
810 844
 	// Randomly check if we should remove some older tokens.
811
-	if (mt_rand(0, 138) == 23)
812
-		cleanTokens();
845
+	if (mt_rand(0, 138) == 23) {
846
+			cleanTokens();
847
+	}
813 848
 
814 849
 	return false;
815 850
 }
@@ -824,14 +859,16 @@  discard block
 block discarded – undo
824 859
 function cleanTokens($complete = false)
825 860
 {
826 861
 	// We appreciate cleaning up after yourselves.
827
-	if (!isset($_SESSION['token']))
828
-		return;
862
+	if (!isset($_SESSION['token'])) {
863
+			return;
864
+	}
829 865
 
830 866
 	// Clean up tokens, trying to give enough time still.
831
-	foreach ($_SESSION['token'] as $key => $data)
832
-		if ($data[2] + 10800 < time() || $complete)
867
+	foreach ($_SESSION['token'] as $key => $data) {
868
+			if ($data[2] + 10800 < time() || $complete)
833 869
 			unset($_SESSION['token'][$key]);
834
-}
870
+	}
871
+	}
835 872
 
836 873
 /**
837 874
  * Check whether a form has been submitted twice.
@@ -849,37 +886,40 @@  discard block
 block discarded – undo
849 886
 {
850 887
 	global $context;
851 888
 
852
-	if (!isset($_SESSION['forms']))
853
-		$_SESSION['forms'] = array();
889
+	if (!isset($_SESSION['forms'])) {
890
+			$_SESSION['forms'] = array();
891
+	}
854 892
 
855 893
 	// Register a form number and store it in the session stack. (use this on the page that has the form.)
856 894
 	if ($action == 'register')
857 895
 	{
858 896
 		$context['form_sequence_number'] = 0;
859
-		while (empty($context['form_sequence_number']) || in_array($context['form_sequence_number'], $_SESSION['forms']))
860
-			$context['form_sequence_number'] = mt_rand(1, 16000000);
897
+		while (empty($context['form_sequence_number']) || in_array($context['form_sequence_number'], $_SESSION['forms'])) {
898
+					$context['form_sequence_number'] = mt_rand(1, 16000000);
899
+		}
861 900
 	}
862 901
 	// Check whether the submitted number can be found in the session.
863 902
 	elseif ($action == 'check')
864 903
 	{
865
-		if (!isset($_REQUEST['seqnum']))
866
-			return true;
867
-		elseif (!in_array($_REQUEST['seqnum'], $_SESSION['forms']))
904
+		if (!isset($_REQUEST['seqnum'])) {
905
+					return true;
906
+		} elseif (!in_array($_REQUEST['seqnum'], $_SESSION['forms']))
868 907
 		{
869 908
 			$_SESSION['forms'][] = (int) $_REQUEST['seqnum'];
870 909
 			return true;
910
+		} elseif ($is_fatal) {
911
+					fatal_lang_error('error_form_already_submitted', false);
912
+		} else {
913
+					return false;
871 914
 		}
872
-		elseif ($is_fatal)
873
-			fatal_lang_error('error_form_already_submitted', false);
874
-		else
875
-			return false;
876 915
 	}
877 916
 	// Don't check, just free the stack number.
878
-	elseif ($action == 'free' && isset($_REQUEST['seqnum']) && in_array($_REQUEST['seqnum'], $_SESSION['forms']))
879
-		$_SESSION['forms'] = array_diff($_SESSION['forms'], array($_REQUEST['seqnum']));
880
-	elseif ($action != 'free')
881
-		trigger_error('checkSubmitOnce(): Invalid action \'' . $action . '\'', E_USER_WARNING);
882
-}
917
+	elseif ($action == 'free' && isset($_REQUEST['seqnum']) && in_array($_REQUEST['seqnum'], $_SESSION['forms'])) {
918
+			$_SESSION['forms'] = array_diff($_SESSION['forms'], array($_REQUEST['seqnum']));
919
+	} elseif ($action != 'free') {
920
+			trigger_error('checkSubmitOnce(): Invalid action \'' . $action . '\'', E_USER_WARNING);
921
+	}
922
+	}
883 923
 
884 924
 /**
885 925
  * Check the user's permissions.
@@ -896,16 +936,19 @@  discard block
 block discarded – undo
896 936
 	global $user_info, $smcFunc;
897 937
 
898 938
 	// You're always allowed to do nothing. (unless you're a working man, MR. LAZY :P!)
899
-	if (empty($permission))
900
-		return true;
939
+	if (empty($permission)) {
940
+			return true;
941
+	}
901 942
 
902 943
 	// You're never allowed to do something if your data hasn't been loaded yet!
903
-	if (empty($user_info))
904
-		return false;
944
+	if (empty($user_info)) {
945
+			return false;
946
+	}
905 947
 
906 948
 	// Administrators are supermen :P.
907
-	if ($user_info['is_admin'])
908
-		return true;
949
+	if ($user_info['is_admin']) {
950
+			return true;
951
+	}
909 952
 
910 953
 	// Let's ensure this is an array.
911 954
 	$permission = (array) $permission;
@@ -913,14 +956,16 @@  discard block
 block discarded – undo
913 956
 	// Are we checking the _current_ board, or some other boards?
914 957
 	if ($boards === null)
915 958
 	{
916
-		if (count(array_intersect($permission, $user_info['permissions'])) != 0)
917
-			return true;
959
+		if (count(array_intersect($permission, $user_info['permissions'])) != 0) {
960
+					return true;
961
+		}
918 962
 		// You aren't allowed, by default.
919
-		else
920
-			return false;
963
+		else {
964
+					return false;
965
+		}
966
+	} elseif (!is_array($boards)) {
967
+			$boards = array($boards);
921 968
 	}
922
-	elseif (!is_array($boards))
923
-		$boards = array($boards);
924 969
 
925 970
 	$request = $smcFunc['db_query']('', '
926 971
 		SELECT MIN(bp.add_deny) AS add_deny
@@ -943,12 +988,14 @@  discard block
 block discarded – undo
943 988
 	);
944 989
 
945 990
 	// Make sure they can do it on all of the boards.
946
-	if ($smcFunc['db_num_rows']($request) != count($boards))
947
-		return false;
991
+	if ($smcFunc['db_num_rows']($request) != count($boards)) {
992
+			return false;
993
+	}
948 994
 
949 995
 	$result = true;
950
-	while ($row = $smcFunc['db_fetch_assoc']($request))
951
-		$result &= !empty($row['add_deny']);
996
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
997
+			$result &= !empty($row['add_deny']);
998
+	}
952 999
 	$smcFunc['db_free_result']($request);
953 1000
 
954 1001
 	// If the query returned 1, they can do it... otherwise, they can't.
@@ -1013,9 +1060,10 @@  discard block
 block discarded – undo
1013 1060
 
1014 1061
 	// If you're doing something on behalf of some "heavy" permissions, validate your session.
1015 1062
 	// (take out the heavy permissions, and if you can't do anything but those, you need a validated session.)
1016
-	if (!allowedTo(array_diff($permission, $heavy_permissions), $boards))
1017
-		validateSession();
1018
-}
1063
+	if (!allowedTo(array_diff($permission, $heavy_permissions), $boards)) {
1064
+			validateSession();
1065
+	}
1066
+	}
1019 1067
 
1020 1068
 /**
1021 1069
  * Return the boards a user has a certain (board) permission on. (array(0) if all.)
@@ -1034,8 +1082,9 @@  discard block
 block discarded – undo
1034 1082
 	global $user_info, $smcFunc;
1035 1083
 
1036 1084
 	// Arrays are nice, most of the time.
1037
-	if (!is_array($permissions))
1038
-		$permissions = array($permissions);
1085
+	if (!is_array($permissions)) {
1086
+			$permissions = array($permissions);
1087
+	}
1039 1088
 
1040 1089
 	/*
1041 1090
 	 * Set $simple to true to use this function as it were in SMF 2.0.x.
@@ -1047,13 +1096,14 @@  discard block
 block discarded – undo
1047 1096
 	// Administrators are all powerful, sorry.
1048 1097
 	if ($user_info['is_admin'])
1049 1098
 	{
1050
-		if ($simple)
1051
-			return array(0);
1052
-		else
1099
+		if ($simple) {
1100
+					return array(0);
1101
+		} else
1053 1102
 		{
1054 1103
 			$boards = array();
1055
-			foreach ($permissions as $permission)
1056
-				$boards[$permission] = array(0);
1104
+			foreach ($permissions as $permission) {
1105
+							$boards[$permission] = array(0);
1106
+			}
1057 1107
 
1058 1108
 			return $boards;
1059 1109
 		}
@@ -1085,31 +1135,32 @@  discard block
 block discarded – undo
1085 1135
 	{
1086 1136
 		if ($simple)
1087 1137
 		{
1088
-			if (empty($row['add_deny']))
1089
-				$deny_boards[] = $row['id_board'];
1090
-			else
1091
-				$boards[] = $row['id_board'];
1092
-		}
1093
-		else
1138
+			if (empty($row['add_deny'])) {
1139
+							$deny_boards[] = $row['id_board'];
1140
+			} else {
1141
+							$boards[] = $row['id_board'];
1142
+			}
1143
+		} else
1094 1144
 		{
1095
-			if (empty($row['add_deny']))
1096
-				$deny_boards[$row['permission']][] = $row['id_board'];
1097
-			else
1098
-				$boards[$row['permission']][] = $row['id_board'];
1145
+			if (empty($row['add_deny'])) {
1146
+							$deny_boards[$row['permission']][] = $row['id_board'];
1147
+			} else {
1148
+							$boards[$row['permission']][] = $row['id_board'];
1149
+			}
1099 1150
 		}
1100 1151
 	}
1101 1152
 	$smcFunc['db_free_result']($request);
1102 1153
 
1103
-	if ($simple)
1104
-		$boards = array_unique(array_values(array_diff($boards, $deny_boards)));
1105
-	else
1154
+	if ($simple) {
1155
+			$boards = array_unique(array_values(array_diff($boards, $deny_boards)));
1156
+	} else
1106 1157
 	{
1107 1158
 		foreach ($permissions as $permission)
1108 1159
 		{
1109 1160
 			// never had it to start with
1110
-			if (empty($boards[$permission]))
1111
-				$boards[$permission] = array();
1112
-			else
1161
+			if (empty($boards[$permission])) {
1162
+							$boards[$permission] = array();
1163
+			} else
1113 1164
 			{
1114 1165
 				// Or it may have been removed
1115 1166
 				$deny_boards[$permission] = isset($deny_boards[$permission]) ? $deny_boards[$permission] : array();
@@ -1145,10 +1196,11 @@  discard block
 block discarded – undo
1145 1196
 
1146 1197
 
1147 1198
 	// Moderators are free...
1148
-	if (!allowedTo('moderate_board'))
1149
-		$timeLimit = isset($timeOverrides[$error_type]) ? $timeOverrides[$error_type] : $modSettings['spamWaitTime'];
1150
-	else
1151
-		$timeLimit = 2;
1199
+	if (!allowedTo('moderate_board')) {
1200
+			$timeLimit = isset($timeOverrides[$error_type]) ? $timeOverrides[$error_type] : $modSettings['spamWaitTime'];
1201
+	} else {
1202
+			$timeLimit = 2;
1203
+	}
1152 1204
 
1153 1205
 	call_integration_hook('integrate_spam_protection', array(&$timeOverrides, &$timeLimit));
1154 1206
 
@@ -1175,8 +1227,9 @@  discard block
 block discarded – undo
1175 1227
 	if ($smcFunc['db_affected_rows']() != 1)
1176 1228
 	{
1177 1229
 		// Spammer!  You only have to wait a *few* seconds!
1178
-		if (!$only_return_result)
1179
-			fatal_lang_error($error_type . '_WaitTime_broken', false, array($timeLimit));
1230
+		if (!$only_return_result) {
1231
+					fatal_lang_error($error_type . '_WaitTime_broken', false, array($timeLimit));
1232
+		}
1180 1233
 
1181 1234
 		return true;
1182 1235
 	}
@@ -1194,11 +1247,13 @@  discard block
 block discarded – undo
1194 1247
  */
1195 1248
 function secureDirectory($path, $attachments = false)
1196 1249
 {
1197
-	if (empty($path))
1198
-		return 'empty_path';
1250
+	if (empty($path)) {
1251
+			return 'empty_path';
1252
+	}
1199 1253
 
1200
-	if (!is_writable($path))
1201
-		return 'path_not_writable';
1254
+	if (!is_writable($path)) {
1255
+			return 'path_not_writable';
1256
+	}
1202 1257
 
1203 1258
 	$directoryname = basename($path);
1204 1259
 
@@ -1210,9 +1265,9 @@  discard block
 block discarded – undo
1210 1265
 
1211 1266
 RemoveHandler .php .php3 .phtml .cgi .fcgi .pl .fpl .shtml';
1212 1267
 
1213
-	if (file_exists($path . '/.htaccess'))
1214
-		$errors[] = 'htaccess_exists';
1215
-	else
1268
+	if (file_exists($path . '/.htaccess')) {
1269
+			$errors[] = 'htaccess_exists';
1270
+	} else
1216 1271
 	{
1217 1272
 		$fh = @fopen($path . '/.htaccess', 'w');
1218 1273
 		if ($fh) {
@@ -1224,9 +1279,9 @@  discard block
 block discarded – undo
1224 1279
 		$errors[] = 'htaccess_cannot_create_file';
1225 1280
 	}
1226 1281
 
1227
-	if (file_exists($path . '/index.php'))
1228
-		$errors[] = 'index-php_exists';
1229
-	else
1282
+	if (file_exists($path . '/index.php')) {
1283
+			$errors[] = 'index-php_exists';
1284
+	} else
1230 1285
 	{
1231 1286
 		$fh = @fopen($path . '/index.php', 'w');
1232 1287
 		if ($fh) {
@@ -1253,11 +1308,12 @@  discard block
 block discarded – undo
1253 1308
 		$errors[] = 'index-php_cannot_create_file';
1254 1309
 	}
1255 1310
 
1256
-	if (!empty($errors))
1257
-		return $errors;
1258
-	else
1259
-		return true;
1260
-}
1311
+	if (!empty($errors)) {
1312
+			return $errors;
1313
+	} else {
1314
+			return true;
1315
+	}
1316
+	}
1261 1317
 
1262 1318
 /**
1263 1319
 * This sets the X-Frame-Options header.
@@ -1270,14 +1326,16 @@  discard block
 block discarded – undo
1270 1326
 	global $modSettings;
1271 1327
 
1272 1328
 	$option = 'SAMEORIGIN';
1273
-	if (is_null($override) && !empty($modSettings['frame_security']))
1274
-		$option = $modSettings['frame_security'];
1275
-	elseif (in_array($override, array('SAMEORIGIN', 'DENY')))
1276
-		$option = $override;
1329
+	if (is_null($override) && !empty($modSettings['frame_security'])) {
1330
+			$option = $modSettings['frame_security'];
1331
+	} elseif (in_array($override, array('SAMEORIGIN', 'DENY'))) {
1332
+			$option = $override;
1333
+	}
1277 1334
 
1278 1335
 	// Don't bother setting the header if we have disabled it.
1279
-	if ($option == 'DISABLE')
1280
-		return;
1336
+	if ($option == 'DISABLE') {
1337
+			return;
1338
+	}
1281 1339
 
1282 1340
 	// Finally set it.
1283 1341
 	header('X-Frame-Options: ' . $option);
Please login to merge, or discard this patch.
Sources/Register.php 1 patch
Braces   +171 added lines, -124 removed lines patch added patch discarded remove patch
@@ -15,8 +15,9 @@  discard block
 block discarded – undo
15 15
  * @version 2.1 Beta 4
16 16
  */
17 17
 
18
-if (!defined('SMF'))
18
+if (!defined('SMF')) {
19 19
 	die('No direct access...');
20
+}
20 21
 
21 22
 /**
22 23
  * Begin the registration process.
@@ -29,19 +30,23 @@  discard block
 block discarded – undo
29 30
 	global $language, $scripturl, $smcFunc, $sourcedir, $cur_profile;
30 31
 
31 32
 	// Is this an incoming AJAX check?
32
-	if (isset($_GET['sa']) && $_GET['sa'] == 'usernamecheck')
33
-		return RegisterCheckUsername();
33
+	if (isset($_GET['sa']) && $_GET['sa'] == 'usernamecheck') {
34
+			return RegisterCheckUsername();
35
+	}
34 36
 
35 37
 	// Check if the administrator has it disabled.
36
-	if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == '3')
37
-		fatal_lang_error('registration_disabled', false);
38
+	if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == '3') {
39
+			fatal_lang_error('registration_disabled', false);
40
+	}
38 41
 
39 42
 	// If this user is an admin - redirect them to the admin registration page.
40
-	if (allowedTo('moderate_forum') && !$user_info['is_guest'])
41
-		redirectexit('action=admin;area=regcenter;sa=register');
43
+	if (allowedTo('moderate_forum') && !$user_info['is_guest']) {
44
+			redirectexit('action=admin;area=regcenter;sa=register');
45
+	}
42 46
 	// You are not a guest, so you are a member - and members don't get to register twice!
43
-	elseif (empty($user_info['is_guest']))
44
-		redirectexit();
47
+	elseif (empty($user_info['is_guest'])) {
48
+			redirectexit();
49
+	}
45 50
 
46 51
 	loadLanguage('Login');
47 52
 	loadTemplate('Register');
@@ -82,16 +87,18 @@  discard block
 block discarded – undo
82 87
 		}
83 88
 	}
84 89
 	// Make sure they don't squeeze through without agreeing.
85
-	elseif ($current_step > 1 && $context['require_agreement'] && !$context['registration_passed_agreement'])
86
-		$current_step = 1;
90
+	elseif ($current_step > 1 && $context['require_agreement'] && !$context['registration_passed_agreement']) {
91
+			$current_step = 1;
92
+	}
87 93
 
88 94
 	// Show the user the right form.
89 95
 	$context['sub_template'] = $current_step == 1 ? 'registration_agreement' : 'registration_form';
90 96
 	$context['page_title'] = $current_step == 1 ? $txt['registration_agreement'] : $txt['registration_form'];
91 97
 
92 98
 	// Kinda need this.
93
-	if ($context['sub_template'] == 'registration_form')
94
-		loadJavaScriptFile('register.js', array('defer' => false), 'smf_register');
99
+	if ($context['sub_template'] == 'registration_form') {
100
+			loadJavaScriptFile('register.js', array('defer' => false), 'smf_register');
101
+	}
95 102
 
96 103
 	// Add the register chain to the link tree.
97 104
 	$context['linktree'][] = array(
@@ -100,24 +107,26 @@  discard block
 block discarded – undo
100 107
 	);
101 108
 
102 109
 	// Prepare the time gate! Do it like so, in case later steps want to reset the limit for any reason, but make sure the time is the current one.
103
-	if (!isset($_SESSION['register']))
104
-		$_SESSION['register'] = array(
110
+	if (!isset($_SESSION['register'])) {
111
+			$_SESSION['register'] = array(
105 112
 			'timenow' => time(),
106 113
 			'limit' => 10, // minimum number of seconds required on this page for registration
107 114
 		);
108
-	else
109
-		$_SESSION['register']['timenow'] = time();
115
+	} else {
116
+			$_SESSION['register']['timenow'] = time();
117
+	}
110 118
 
111 119
 	// If you have to agree to the agreement, it needs to be fetched from the file.
112 120
 	if ($context['require_agreement'])
113 121
 	{
114 122
 		// Have we got a localized one?
115
-		if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt'))
116
-			$context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']);
117
-		elseif (file_exists($boarddir . '/agreement.txt'))
118
-			$context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement');
119
-		else
120
-			$context['agreement'] = '';
123
+		if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt')) {
124
+					$context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']);
125
+		} elseif (file_exists($boarddir . '/agreement.txt')) {
126
+					$context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement');
127
+		} else {
128
+					$context['agreement'] = '';
129
+		}
121 130
 
122 131
 		// Nothing to show, lets disable registration and inform the admin of this error
123 132
 		if (empty($context['agreement']))
@@ -133,8 +142,9 @@  discard block
 block discarded – undo
133 142
 		$selectedLanguage = empty($_SESSION['language']) ? $language : $_SESSION['language'];
134 143
 
135 144
 		// Do we have any languages?
136
-		if (empty($context['languages']))
137
-			getLanguages();
145
+		if (empty($context['languages'])) {
146
+					getLanguages();
147
+		}
138 148
 
139 149
 		// Try to find our selected language.
140 150
 		foreach ($context['languages'] as $key => $lang)
@@ -142,8 +152,9 @@  discard block
 block discarded – undo
142 152
 			$context['languages'][$key]['name'] = strtr($lang['name'], array('-utf8' => ''));
143 153
 
144 154
 			// Found it!
145
-			if ($selectedLanguage == $lang['filename'])
146
-				$context['languages'][$key]['selected'] = true;
155
+			if ($selectedLanguage == $lang['filename']) {
156
+							$context['languages'][$key]['selected'] = true;
157
+			}
147 158
 		}
148 159
 	}
149 160
 
@@ -167,9 +178,10 @@  discard block
 block discarded – undo
167 178
 		$reg_fields = explode(',', $modSettings['registration_fields']);
168 179
 
169 180
 		// We might have had some submissions on this front - go check.
170
-		foreach ($reg_fields as $field)
171
-			if (isset($_POST[$field]))
181
+		foreach ($reg_fields as $field) {
182
+					if (isset($_POST[$field]))
172 183
 				$cur_profile[$field] = $smcFunc['htmlspecialchars']($_POST[$field]);
184
+		}
173 185
 
174 186
 		// Load all the fields in question.
175 187
 		setupProfileContext($reg_fields);
@@ -186,8 +198,9 @@  discard block
 block discarded – undo
186 198
 		$context['visual_verification_id'] = $verificationOptions['id'];
187 199
 	}
188 200
 	// Otherwise we have nothing to show.
189
-	else
190
-		$context['visual_verification'] = false;
201
+	else {
202
+			$context['visual_verification'] = false;
203
+	}
191 204
 
192 205
 
193 206
 	$context += array(
@@ -198,8 +211,9 @@  discard block
 block discarded – undo
198 211
 
199 212
 	// Were there any errors?
200 213
 	$context['registration_errors'] = array();
201
-	if (!empty($reg_errors))
202
-		$context['registration_errors'] = $reg_errors;
214
+	if (!empty($reg_errors)) {
215
+			$context['registration_errors'] = $reg_errors;
216
+	}
203 217
 
204 218
 	createToken('register');
205 219
 }
@@ -216,27 +230,32 @@  discard block
 block discarded – undo
216 230
 	validateToken('register');
217 231
 
218 232
 	// Check to ensure we're forcing SSL for authentication
219
-	if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn())
220
-		fatal_lang_error('register_ssl_required');
233
+	if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) {
234
+			fatal_lang_error('register_ssl_required');
235
+	}
221 236
 
222 237
 	// Start collecting together any errors.
223 238
 	$reg_errors = array();
224 239
 
225 240
 	// You can't register if it's disabled.
226
-	if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 3)
227
-		fatal_lang_error('registration_disabled', false);
241
+	if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 3) {
242
+			fatal_lang_error('registration_disabled', false);
243
+	}
228 244
 
229 245
 	// Well, if you don't agree, you can't register.
230
-	if (!empty($modSettings['requireAgreement']) && empty($_SESSION['registration_agreed']))
231
-		redirectexit();
246
+	if (!empty($modSettings['requireAgreement']) && empty($_SESSION['registration_agreed'])) {
247
+			redirectexit();
248
+	}
232 249
 
233 250
 	// Make sure they came from *somewhere*, have a session.
234
-	if (!isset($_SESSION['old_url']))
235
-		redirectexit('action=signup');
251
+	if (!isset($_SESSION['old_url'])) {
252
+			redirectexit('action=signup');
253
+	}
236 254
 
237 255
 	// If we don't require an agreement, we need a extra check for coppa.
238
-	if (empty($modSettings['requireAgreement']) && !empty($modSettings['coppaAge']))
239
-		$_SESSION['skip_coppa'] = !empty($_POST['accept_agreement']);
256
+	if (empty($modSettings['requireAgreement']) && !empty($modSettings['coppaAge'])) {
257
+			$_SESSION['skip_coppa'] = !empty($_POST['accept_agreement']);
258
+	}
240 259
 	// Are they under age, and under age users are banned?
241 260
 	if (!empty($modSettings['coppaAge']) && empty($modSettings['coppaType']) && empty($_SESSION['skip_coppa']))
242 261
 	{
@@ -245,8 +264,9 @@  discard block
 block discarded – undo
245 264
 	}
246 265
 
247 266
 	// Check the time gate for miscreants. First make sure they came from somewhere that actually set it up.
248
-	if (empty($_SESSION['register']['timenow']) || empty($_SESSION['register']['limit']))
249
-		redirectexit('action=signup');
267
+	if (empty($_SESSION['register']['timenow']) || empty($_SESSION['register']['limit'])) {
268
+			redirectexit('action=signup');
269
+	}
250 270
 	// Failing that, check the time on it.
251 271
 	if (time() - $_SESSION['register']['timenow'] < $_SESSION['register']['limit'])
252 272
 	{
@@ -266,15 +286,17 @@  discard block
 block discarded – undo
266 286
 		if (is_array($context['visual_verification']))
267 287
 		{
268 288
 			loadLanguage('Errors');
269
-			foreach ($context['visual_verification'] as $error)
270
-				$reg_errors[] = $txt['error_' . $error];
289
+			foreach ($context['visual_verification'] as $error) {
290
+							$reg_errors[] = $txt['error_' . $error];
291
+			}
271 292
 		}
272 293
 	}
273 294
 
274 295
 	foreach ($_POST as $key => $value)
275 296
 	{
276
-		if (!is_array($_POST[$key]))
277
-			$_POST[$key] = htmltrim__recursive(str_replace(array("\n", "\r"), '', $_POST[$key]));
297
+		if (!is_array($_POST[$key])) {
298
+					$_POST[$key] = htmltrim__recursive(str_replace(array("\n", "\r"), '', $_POST[$key]));
299
+		}
278 300
 	}
279 301
 
280 302
 	// Collect all extra registration fields someone might have filled in.
@@ -304,12 +326,14 @@  discard block
 block discarded – undo
304 326
 		$reg_fields = explode(',', $modSettings['registration_fields']);
305 327
 
306 328
 		// Website is a little different
307
-		if (in_array('website', $reg_fields))
308
-			$possible_strings = array_merge(array('website_url', 'website_title'), $possible_strings);
329
+		if (in_array('website', $reg_fields)) {
330
+					$possible_strings = array_merge(array('website_url', 'website_title'), $possible_strings);
331
+		}
309 332
 	}
310 333
 
311
-	if (isset($_POST['secret_answer']) && $_POST['secret_answer'] != '')
312
-		$_POST['secret_answer'] = md5($_POST['secret_answer']);
334
+	if (isset($_POST['secret_answer']) && $_POST['secret_answer'] != '') {
335
+			$_POST['secret_answer'] = md5($_POST['secret_answer']);
336
+	}
313 337
 
314 338
 	// Needed for isReservedName() and registerMember().
315 339
 	require_once($sourcedir . '/Subs-Members.php');
@@ -318,8 +342,9 @@  discard block
 block discarded – undo
318 342
 	if (isset($_POST['real_name']))
319 343
 	{
320 344
 		// Are you already allowed to edit the displayed name?
321
-		if (allowedTo('profile_displayed_name') || allowedTo('moderate_forum'))
322
-			$canEditDisplayName = true;
345
+		if (allowedTo('profile_displayed_name') || allowedTo('moderate_forum')) {
346
+					$canEditDisplayName = true;
347
+		}
323 348
 
324 349
 		// If you are a guest, will you be allowed to once you register?
325 350
 		else
@@ -343,33 +368,38 @@  discard block
 block discarded – undo
343 368
 			$_POST['real_name'] = trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $_POST['real_name']));
344 369
 
345 370
 			// Only set it if we are sure it is good
346
-			if (trim($_POST['real_name']) != '' && !isReservedName($_POST['real_name']) && $smcFunc['strlen']($_POST['real_name']) < 60)
347
-				$possible_strings[] = 'real_name';
371
+			if (trim($_POST['real_name']) != '' && !isReservedName($_POST['real_name']) && $smcFunc['strlen']($_POST['real_name']) < 60) {
372
+							$possible_strings[] = 'real_name';
373
+			}
348 374
 		}
349 375
 	}
350 376
 
351 377
 	// Handle a string as a birthdate...
352
-	if (isset($_POST['birthdate']) && $_POST['birthdate'] != '')
353
-		$_POST['birthdate'] = strftime('%Y-%m-%d', strtotime($_POST['birthdate']));
378
+	if (isset($_POST['birthdate']) && $_POST['birthdate'] != '') {
379
+			$_POST['birthdate'] = strftime('%Y-%m-%d', strtotime($_POST['birthdate']));
380
+	}
354 381
 	// Or birthdate parts...
355
-	elseif (!empty($_POST['bday1']) && !empty($_POST['bday2']))
356
-		$_POST['birthdate'] = sprintf('%04d-%02d-%02d', empty($_POST['bday3']) ? 0 : (int) $_POST['bday3'], (int) $_POST['bday1'], (int) $_POST['bday2']);
382
+	elseif (!empty($_POST['bday1']) && !empty($_POST['bday2'])) {
383
+			$_POST['birthdate'] = sprintf('%04d-%02d-%02d', empty($_POST['bday3']) ? 0 : (int) $_POST['bday3'], (int) $_POST['bday1'], (int) $_POST['bday2']);
384
+	}
357 385
 
358 386
 	// Validate the passed language file.
359 387
 	if (isset($_POST['lngfile']) && !empty($modSettings['userLanguage']))
360 388
 	{
361 389
 		// Do we have any languages?
362
-		if (empty($context['languages']))
363
-			getLanguages();
390
+		if (empty($context['languages'])) {
391
+					getLanguages();
392
+		}
364 393
 
365 394
 		// Did we find it?
366
-		if (isset($context['languages'][$_POST['lngfile']]))
367
-			$_SESSION['language'] = $_POST['lngfile'];
368
-		else
395
+		if (isset($context['languages'][$_POST['lngfile']])) {
396
+					$_SESSION['language'] = $_POST['lngfile'];
397
+		} else {
398
+					unset($_POST['lngfile']);
399
+		}
400
+	} else {
369 401
 			unset($_POST['lngfile']);
370 402
 	}
371
-	else
372
-		unset($_POST['lngfile']);
373 403
 
374 404
 	// Set the options needed for registration.
375 405
 	$regOptions = array(
@@ -389,22 +419,27 @@  discard block
 block discarded – undo
389 419
 	);
390 420
 
391 421
 	// Include the additional options that might have been filled in.
392
-	foreach ($possible_strings as $var)
393
-		if (isset($_POST[$var]))
422
+	foreach ($possible_strings as $var) {
423
+			if (isset($_POST[$var]))
394 424
 			$regOptions['extra_register_vars'][$var] = $smcFunc['htmlspecialchars']($_POST[$var], ENT_QUOTES);
395
-	foreach ($possible_ints as $var)
396
-		if (isset($_POST[$var]))
425
+	}
426
+	foreach ($possible_ints as $var) {
427
+			if (isset($_POST[$var]))
397 428
 			$regOptions['extra_register_vars'][$var] = (int) $_POST[$var];
398
-	foreach ($possible_floats as $var)
399
-		if (isset($_POST[$var]))
429
+	}
430
+	foreach ($possible_floats as $var) {
431
+			if (isset($_POST[$var]))
400 432
 			$regOptions['extra_register_vars'][$var] = (float) $_POST[$var];
401
-	foreach ($possible_bools as $var)
402
-		if (isset($_POST[$var]))
433
+	}
434
+	foreach ($possible_bools as $var) {
435
+			if (isset($_POST[$var]))
403 436
 			$regOptions['extra_register_vars'][$var] = empty($_POST[$var]) ? 0 : 1;
437
+	}
404 438
 
405 439
 	// Registration options are always default options...
406
-	if (isset($_POST['default_options']))
407
-		$_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options'];
440
+	if (isset($_POST['default_options'])) {
441
+			$_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options'];
442
+	}
408 443
 	$regOptions['theme_vars'] = isset($_POST['options']) && is_array($_POST['options']) ? $_POST['options'] : array();
409 444
 
410 445
 	// Make sure they are clean, dammit!
@@ -424,12 +459,14 @@  discard block
 block discarded – undo
424 459
 	while ($row = $smcFunc['db_fetch_assoc']($request))
425 460
 	{
426 461
 		// Don't allow overriding of the theme variables.
427
-		if (isset($regOptions['theme_vars'][$row['col_name']]))
428
-			unset($regOptions['theme_vars'][$row['col_name']]);
462
+		if (isset($regOptions['theme_vars'][$row['col_name']])) {
463
+					unset($regOptions['theme_vars'][$row['col_name']]);
464
+		}
429 465
 
430 466
 		// Not actually showing it then?
431
-		if (!$row['show_reg'])
432
-			continue;
467
+		if (!$row['show_reg']) {
468
+					continue;
469
+		}
433 470
 
434 471
 		// Prepare the value!
435 472
 		$value = isset($_POST['customfield'][$row['col_name']]) ? trim($_POST['customfield'][$row['col_name']]) : '';
@@ -438,24 +475,27 @@  discard block
 block discarded – undo
438 475
 		if (!in_array($row['field_type'], array('check', 'select', 'radio')))
439 476
 		{
440 477
 			// Is it too long?
441
-			if ($row['field_length'] && $row['field_length'] < $smcFunc['strlen']($value))
442
-				$custom_field_errors[] = array('custom_field_too_long', array($row['field_name'], $row['field_length']));
478
+			if ($row['field_length'] && $row['field_length'] < $smcFunc['strlen']($value)) {
479
+							$custom_field_errors[] = array('custom_field_too_long', array($row['field_name'], $row['field_length']));
480
+			}
443 481
 
444 482
 			// Any masks to apply?
445 483
 			if ($row['field_type'] == 'text' && !empty($row['mask']) && $row['mask'] != 'none')
446 484
 			{
447
-				if ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255))
448
-					$custom_field_errors[] = array('custom_field_invalid_email', array($row['field_name']));
449
-				elseif ($row['mask'] == 'number' && preg_match('~[^\d]~', $value))
450
-					$custom_field_errors[] = array('custom_field_not_number', array($row['field_name']));
451
-				elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0)
452
-					$custom_field_errors[] = array('custom_field_inproper_format', array($row['field_name']));
485
+				if ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) {
486
+									$custom_field_errors[] = array('custom_field_invalid_email', array($row['field_name']));
487
+				} elseif ($row['mask'] == 'number' && preg_match('~[^\d]~', $value)) {
488
+									$custom_field_errors[] = array('custom_field_not_number', array($row['field_name']));
489
+				} elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) {
490
+									$custom_field_errors[] = array('custom_field_inproper_format', array($row['field_name']));
491
+				}
453 492
 			}
454 493
 		}
455 494
 
456 495
 		// Is this required but not there?
457
-		if (trim($value) == '' && $row['show_reg'] > 1)
458
-			$custom_field_errors[] = array('custom_field_empty', array($row['field_name']));
496
+		if (trim($value) == '' && $row['show_reg'] > 1) {
497
+					$custom_field_errors[] = array('custom_field_empty', array($row['field_name']));
498
+		}
459 499
 	}
460 500
 	$smcFunc['db_free_result']($request);
461 501
 
@@ -463,8 +503,9 @@  discard block
 block discarded – undo
463 503
 	if (!empty($custom_field_errors))
464 504
 	{
465 505
 		loadLanguage('Errors');
466
-		foreach ($custom_field_errors as $error)
467
-			$reg_errors[] = vsprintf($txt['error_' . $error[0]], $error[1]);
506
+		foreach ($custom_field_errors as $error) {
507
+					$reg_errors[] = vsprintf($txt['error_' . $error[0]], $error[1]);
508
+		}
468 509
 	}
469 510
 
470 511
 	// Lets check for other errors before trying to register the member.
@@ -509,8 +550,9 @@  discard block
 block discarded – undo
509 550
 	}
510 551
 
511 552
 	// If COPPA has been selected then things get complicated, setup the template.
512
-	if (!empty($modSettings['coppaAge']) && empty($_SESSION['skip_coppa']))
513
-		redirectexit('action=coppa;member=' . $memberID);
553
+	if (!empty($modSettings['coppaAge']) && empty($_SESSION['skip_coppa'])) {
554
+			redirectexit('action=coppa;member=' . $memberID);
555
+	}
514 556
 	// Basic template variable setup.
515 557
 	elseif (!empty($modSettings['registration_method']))
516 558
 	{
@@ -522,8 +564,7 @@  discard block
 block discarded – undo
522 564
 			'sub_template' => 'after',
523 565
 			'description' => $modSettings['registration_method'] == 2 ? $txt['approval_after_registration'] : $txt['activate_after_registration']
524 566
 		);
525
-	}
526
-	else
567
+	} else
527 568
 	{
528 569
 		call_integration_hook('integrate_activate', array($regOptions['username']));
529 570
 
@@ -543,16 +584,18 @@  discard block
 block discarded – undo
543 584
 	global $context, $txt, $modSettings, $scripturl, $sourcedir, $smcFunc, $language, $user_info;
544 585
 
545 586
 	// Logged in users should not bother to activate their accounts
546
-	if (!empty($user_info['id']))
547
-		redirectexit();
587
+	if (!empty($user_info['id'])) {
588
+			redirectexit();
589
+	}
548 590
 
549 591
 	loadLanguage('Login');
550 592
 	loadTemplate('Login');
551 593
 
552 594
 	if (empty($_REQUEST['u']) && empty($_POST['user']))
553 595
 	{
554
-		if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == '3')
555
-			fatal_lang_error('no_access', false);
596
+		if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == '3') {
597
+					fatal_lang_error('no_access', false);
598
+		}
556 599
 
557 600
 		$context['member_id'] = 0;
558 601
 		$context['sub_template'] = 'resend';
@@ -592,11 +635,13 @@  discard block
 block discarded – undo
592 635
 	// Change their email address? (they probably tried a fake one first :P.)
593 636
 	if (isset($_POST['new_email'], $_REQUEST['passwd']) && hash_password($row['member_name'], $_REQUEST['passwd']) == $row['passwd'] && ($row['is_activated'] == 0 || $row['is_activated'] == 2))
594 637
 	{
595
-		if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == 3)
596
-			fatal_lang_error('no_access', false);
638
+		if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == 3) {
639
+					fatal_lang_error('no_access', false);
640
+		}
597 641
 
598
-		if (!filter_var($_POST['new_email'], FILTER_VALIDATE_EMAIL))
599
-			fatal_error(sprintf($txt['valid_email_needed'], $smcFunc['htmlspecialchars']($_POST['new_email'])), false);
642
+		if (!filter_var($_POST['new_email'], FILTER_VALIDATE_EMAIL)) {
643
+					fatal_error(sprintf($txt['valid_email_needed'], $smcFunc['htmlspecialchars']($_POST['new_email'])), false);
644
+		}
600 645
 
601 646
 		// Make sure their email isn't banned.
602 647
 		isBannedEmail($_POST['new_email'], 'cannot_register', $txt['ban_register_prohibited']);
@@ -612,8 +657,9 @@  discard block
 block discarded – undo
612 657
 			)
613 658
 		);
614 659
 
615
-		if ($smcFunc['db_num_rows']($request) != 0)
616
-			fatal_lang_error('email_in_use', false, array($smcFunc['htmlspecialchars']($_POST['new_email'])));
660
+		if ($smcFunc['db_num_rows']($request) != 0) {
661
+					fatal_lang_error('email_in_use', false, array($smcFunc['htmlspecialchars']($_POST['new_email'])));
662
+		}
617 663
 		$smcFunc['db_free_result']($request);
618 664
 
619 665
 		updateMemberData($row['id_member'], array('email_address' => $_POST['new_email']));
@@ -651,9 +697,9 @@  discard block
 block discarded – undo
651 697
 	// Quit if this code is not right.
652 698
 	if (empty($_REQUEST['code']) || $row['validation_code'] != $_REQUEST['code'])
653 699
 	{
654
-		if (!empty($row['is_activated']))
655
-			fatal_lang_error('already_activated', false);
656
-		elseif ($row['validation_code'] == '')
700
+		if (!empty($row['is_activated'])) {
701
+					fatal_lang_error('already_activated', false);
702
+		} elseif ($row['validation_code'] == '')
657 703
 		{
658 704
 			loadLanguage('Profile');
659 705
 			fatal_error(sprintf($txt['registration_not_approved'], $scripturl . '?action=activate;user=' . $row['member_name']), false);
@@ -703,8 +749,9 @@  discard block
 block discarded – undo
703 749
 	loadTemplate('Register');
704 750
 
705 751
 	// No User ID??
706
-	if (!isset($_GET['member']))
707
-		fatal_lang_error('no_access', false);
752
+	if (!isset($_GET['member'])) {
753
+			fatal_lang_error('no_access', false);
754
+	}
708 755
 
709 756
 	// Get the user details...
710 757
 	$request = $smcFunc['db_query']('', '
@@ -717,8 +764,9 @@  discard block
 block discarded – undo
717 764
 			'is_coppa' => 5,
718 765
 		)
719 766
 	);
720
-	if ($smcFunc['db_num_rows']($request) == 0)
721
-		fatal_lang_error('no_access', false);
767
+	if ($smcFunc['db_num_rows']($request) == 0) {
768
+			fatal_lang_error('no_access', false);
769
+	}
722 770
 	list ($username) = $smcFunc['db_fetch_row']($request);
723 771
 	$smcFunc['db_free_result']($request);
724 772
 
@@ -756,8 +804,7 @@  discard block
 block discarded – undo
756 804
 			echo $data;
757 805
 			obExit(false);
758 806
 		}
759
-	}
760
-	else
807
+	} else
761 808
 	{
762 809
 		$context += array(
763 810
 			'page_title' => $txt['coppa_title'],
@@ -810,8 +857,9 @@  discard block
 block discarded – undo
810 857
 	{
811 858
 		require_once($sourcedir . '/Subs-Graphics.php');
812 859
 
813
-		if (in_array('gd', get_loaded_extensions()) && !showCodeImage($code))
814
-			header('HTTP/1.1 400 Bad Request');
860
+		if (in_array('gd', get_loaded_extensions()) && !showCodeImage($code)) {
861
+					header('HTTP/1.1 400 Bad Request');
862
+		}
815 863
 
816 864
 		// Otherwise just show a pre-defined letter.
817 865
 		elseif (isset($_REQUEST['letter']))
@@ -829,14 +877,13 @@  discard block
 block discarded – undo
829 877
 			header('Content-Type: image/gif');
830 878
 			die("\x47\x49\x46\x38\x39\x61\x01\x00\x01\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x21\xF9\x04\x01\x00\x00\x00\x00\x2C\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02\x44\x01\x00\x3B");
831 879
 		}
832
-	}
833
-
834
-	elseif ($_REQUEST['format'] === '.wav')
880
+	} elseif ($_REQUEST['format'] === '.wav')
835 881
 	{
836 882
 		require_once($sourcedir . '/Subs-Sound.php');
837 883
 
838
-		if (!createWaveFile($code))
839
-			header('HTTP/1.1 400 Bad Request');
884
+		if (!createWaveFile($code)) {
885
+					header('HTTP/1.1 400 Bad Request');
886
+		}
840 887
 	}
841 888
 
842 889
 	// We all die one day...
Please login to merge, or discard this patch.
Sources/Profile.php 1 patch
Braces   +155 added lines, -118 removed lines patch added patch discarded remove patch
@@ -15,8 +15,9 @@  discard block
 block discarded – undo
15 15
  * @version 2.1 Beta 4
16 16
  */
17 17
 
18
-if (!defined('SMF'))
18
+if (!defined('SMF')) {
19 19
 	die('No direct access...');
20
+}
20 21
 
21 22
 /**
22 23
  * The main designating function for modifying profiles. Loads up info, determins what to do, etc.
@@ -29,18 +30,21 @@  discard block
 block discarded – undo
29 30
 	global $modSettings, $memberContext, $profile_vars, $post_errors, $smcFunc;
30 31
 
31 32
 	// Don't reload this as we may have processed error strings.
32
-	if (empty($post_errors))
33
-		loadLanguage('Profile+Drafts');
33
+	if (empty($post_errors)) {
34
+			loadLanguage('Profile+Drafts');
35
+	}
34 36
 	loadTemplate('Profile');
35 37
 
36 38
 	require_once($sourcedir . '/Subs-Menu.php');
37 39
 
38 40
 	// Did we get the user by name...
39
-	if (isset($_REQUEST['user']))
40
-		$memberResult = loadMemberData($_REQUEST['user'], true, 'profile');
41
+	if (isset($_REQUEST['user'])) {
42
+			$memberResult = loadMemberData($_REQUEST['user'], true, 'profile');
43
+	}
41 44
 	// ... or by id_member?
42
-	elseif (!empty($_REQUEST['u']))
43
-		$memberResult = loadMemberData((int) $_REQUEST['u'], false, 'profile');
45
+	elseif (!empty($_REQUEST['u'])) {
46
+			$memberResult = loadMemberData((int) $_REQUEST['u'], false, 'profile');
47
+	}
44 48
 	// If it was just ?action=profile, edit your own profile, but only if you're not a guest.
45 49
 	else
46 50
 	{
@@ -50,8 +54,9 @@  discard block
 block discarded – undo
50 54
 	}
51 55
 
52 56
 	// Check if loadMemberData() has returned a valid result.
53
-	if (!$memberResult)
54
-		fatal_lang_error('not_a_user', false, 404);
57
+	if (!$memberResult) {
58
+			fatal_lang_error('not_a_user', false, 404);
59
+	}
55 60
 
56 61
 	// If all went well, we have a valid member ID!
57 62
 	list ($memID) = $memberResult;
@@ -67,8 +72,9 @@  discard block
 block discarded – undo
67 72
 
68 73
 	// Group management isn't actually a permission. But we need it to be for this, so we need a phantom permission.
69 74
 	// And we care about what the current user can do, not what the user whose profile it is.
70
-	if ($user_info['mod_cache']['gq'] != '0=1')
71
-		$user_info['permissions'][] = 'approve_group_requests';
75
+	if ($user_info['mod_cache']['gq'] != '0=1') {
76
+			$user_info['permissions'][] = 'approve_group_requests';
77
+	}
72 78
 
73 79
 	// If paid subscriptions are enabled, make sure we actually have at least one subscription available...
74 80
 	$context['subs_available'] = false;
@@ -436,21 +442,25 @@  discard block
 block discarded – undo
436 442
 		foreach ($section['areas'] as $area_id => $area)
437 443
 		{
438 444
 			// If it said no permissions that meant it wasn't valid!
439
-			if (empty($area['permission'][$context['user']['is_owner'] ? 'own' : 'any']))
440
-				$profile_areas[$section_id]['areas'][$area_id]['enabled'] = false;
445
+			if (empty($area['permission'][$context['user']['is_owner'] ? 'own' : 'any'])) {
446
+							$profile_areas[$section_id]['areas'][$area_id]['enabled'] = false;
447
+			}
441 448
 			// Otherwise pick the right set.
442
-			else
443
-				$profile_areas[$section_id]['areas'][$area_id]['permission'] = $area['permission'][$context['user']['is_owner'] ? 'own' : 'any'];
449
+			else {
450
+							$profile_areas[$section_id]['areas'][$area_id]['permission'] = $area['permission'][$context['user']['is_owner'] ? 'own' : 'any'];
451
+			}
444 452
 
445 453
 			// Password required in most cases
446
-			if (!empty($area['password']))
447
-				$context['password_areas'][] = $area_id;
454
+			if (!empty($area['password'])) {
455
+							$context['password_areas'][] = $area_id;
456
+			}
448 457
 		}
449 458
 	}
450 459
 
451 460
 	// Is there an updated message to show?
452
-	if (isset($_GET['updated']))
453
-		$context['profile_updated'] = $txt['profile_updated_own'];
461
+	if (isset($_GET['updated'])) {
462
+			$context['profile_updated'] = $txt['profile_updated_own'];
463
+	}
454 464
 
455 465
 	// Set a few options for the menu.
456 466
 	$menuOptions = array(
@@ -465,8 +475,9 @@  discard block
 block discarded – undo
465 475
 	$profile_include_data = createMenu($profile_areas, $menuOptions);
466 476
 
467 477
 	// No menu means no access.
468
-	if (!$profile_include_data && (!$user_info['is_guest'] || validateSession()))
469
-		fatal_lang_error('no_access', false);
478
+	if (!$profile_include_data && (!$user_info['is_guest'] || validateSession())) {
479
+			fatal_lang_error('no_access', false);
480
+	}
470 481
 
471 482
 	// Make a note of the Unique ID for this menu.
472 483
 	$context['profile_menu_id'] = $context['max_menu_id'];
@@ -492,8 +503,9 @@  discard block
 block discarded – undo
492 503
 			if ($current_area == $area_id)
493 504
 			{
494 505
 				// This can't happen - but is a security check.
495
-				if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($area['enabled']) && $area['enabled'] == false))
496
-					fatal_lang_error('no_access', false);
506
+				if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($area['enabled']) && $area['enabled'] == false)) {
507
+									fatal_lang_error('no_access', false);
508
+				}
497 509
 
498 510
 				// Are we saving data in a valid area?
499 511
 				if (isset($area['sc']) && (isset($_REQUEST['save']) || $context['do_preview']))
@@ -512,12 +524,14 @@  discard block
 block discarded – undo
512 524
 				}
513 525
 
514 526
 				// Does this require session validating?
515
-				if (!empty($area['validate']) || (isset($_REQUEST['save']) && !$context['user']['is_owner']))
516
-					$security_checks['validate'] = true;
527
+				if (!empty($area['validate']) || (isset($_REQUEST['save']) && !$context['user']['is_owner'])) {
528
+									$security_checks['validate'] = true;
529
+				}
517 530
 
518 531
 				// Permissions for good measure.
519
-				if (!empty($profile_include_data['permission']))
520
-					$security_checks['permission'] = $profile_include_data['permission'];
532
+				if (!empty($profile_include_data['permission'])) {
533
+									$security_checks['permission'] = $profile_include_data['permission'];
534
+				}
521 535
 
522 536
 				// Either way got something.
523 537
 				$found_area = true;
@@ -526,21 +540,26 @@  discard block
 block discarded – undo
526 540
 	}
527 541
 
528 542
 	// Oh dear, some serious security lapse is going on here... we'll put a stop to that!
529
-	if (!$found_area)
530
-		fatal_lang_error('no_access', false);
543
+	if (!$found_area) {
544
+			fatal_lang_error('no_access', false);
545
+	}
531 546
 
532 547
 	// Release this now.
533 548
 	unset($profile_areas);
534 549
 
535 550
 	// Now the context is setup have we got any security checks to carry out additional to that above?
536
-	if (isset($security_checks['session']))
537
-		checkSession($security_checks['session']);
538
-	if (isset($security_checks['validate']))
539
-		validateSession();
540
-	if (isset($security_checks['validateToken']))
541
-		validateToken($token_name, $token_type);
542
-	if (isset($security_checks['permission']))
543
-		isAllowedTo($security_checks['permission']);
551
+	if (isset($security_checks['session'])) {
552
+			checkSession($security_checks['session']);
553
+	}
554
+	if (isset($security_checks['validate'])) {
555
+			validateSession();
556
+	}
557
+	if (isset($security_checks['validateToken'])) {
558
+			validateToken($token_name, $token_type);
559
+	}
560
+	if (isset($security_checks['permission'])) {
561
+			isAllowedTo($security_checks['permission']);
562
+	}
544 563
 
545 564
 	// Create a token if needed.
546 565
 	if (isset($security_checks['needsToken']) || isset($security_checks['validateToken']))
@@ -550,8 +569,9 @@  discard block
 block discarded – undo
550 569
 	}
551 570
 
552 571
 	// File to include?
553
-	if (isset($profile_include_data['file']))
554
-		require_once($sourcedir . '/' . $profile_include_data['file']);
572
+	if (isset($profile_include_data['file'])) {
573
+			require_once($sourcedir . '/' . $profile_include_data['file']);
574
+	}
555 575
 
556 576
 	// Build the link tree.
557 577
 	$context['linktree'][] = array(
@@ -559,17 +579,19 @@  discard block
 block discarded – undo
559 579
 		'name' => sprintf($txt['profile_of_username'], $context['member']['name']),
560 580
 	);
561 581
 
562
-	if (!empty($profile_include_data['label']))
563
-		$context['linktree'][] = array(
582
+	if (!empty($profile_include_data['label'])) {
583
+			$context['linktree'][] = array(
564 584
 			'url' => $scripturl . '?action=profile' . ($memID != $user_info['id'] ? ';u=' . $memID : '') . ';area=' . $profile_include_data['current_area'],
565 585
 			'name' => $profile_include_data['label'],
566 586
 		);
587
+	}
567 588
 
568
-	if (!empty($profile_include_data['current_subsection']) && $profile_include_data['subsections'][$profile_include_data['current_subsection']][0] != $profile_include_data['label'])
569
-		$context['linktree'][] = array(
589
+	if (!empty($profile_include_data['current_subsection']) && $profile_include_data['subsections'][$profile_include_data['current_subsection']][0] != $profile_include_data['label']) {
590
+			$context['linktree'][] = array(
570 591
 			'url' => $scripturl . '?action=profile' . ($memID != $user_info['id'] ? ';u=' . $memID : '') . ';area=' . $profile_include_data['current_area'] . ';sa=' . $profile_include_data['current_subsection'],
571 592
 			'name' => $profile_include_data['subsections'][$profile_include_data['current_subsection']][0],
572 593
 		);
594
+	}
573 595
 
574 596
 	// Set the template for this area and add the profile layer.
575 597
 	$context['sub_template'] = $profile_include_data['function'];
@@ -595,12 +617,14 @@  discard block
 block discarded – undo
595 617
 		if ($check_password)
596 618
 		{
597 619
 			// Check to ensure we're forcing SSL for authentication
598
-			if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn())
599
-				fatal_lang_error('login_ssl_required');
620
+			if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) {
621
+							fatal_lang_error('login_ssl_required');
622
+			}
600 623
 
601 624
 			// You didn't even enter a password!
602
-			if (trim($_POST['oldpasswrd']) == '')
603
-				$post_errors[] = 'no_password';
625
+			if (trim($_POST['oldpasswrd']) == '') {
626
+							$post_errors[] = 'no_password';
627
+			}
604 628
 
605 629
 			// Since the password got modified due to all the $_POST cleaning, lets undo it so we can get the correct password
606 630
 			$_POST['oldpasswrd'] = un_htmlspecialchars($_POST['oldpasswrd']);
@@ -609,42 +633,43 @@  discard block
 block discarded – undo
609 633
 			$good_password = in_array(true, call_integration_hook('integrate_verify_password', array($cur_profile['member_name'], $_POST['oldpasswrd'], false)), true);
610 634
 
611 635
 			// Bad password!!!
612
-			if (!$good_password && !hash_verify_password($user_profile[$memID]['member_name'], un_htmlspecialchars(stripslashes($_POST['oldpasswrd'])), $user_info['passwd']))
613
-				$post_errors[] = 'bad_password';
636
+			if (!$good_password && !hash_verify_password($user_profile[$memID]['member_name'], un_htmlspecialchars(stripslashes($_POST['oldpasswrd'])), $user_info['passwd'])) {
637
+							$post_errors[] = 'bad_password';
638
+			}
614 639
 
615 640
 			// Warn other elements not to jump the gun and do custom changes!
616
-			if (in_array('bad_password', $post_errors))
617
-				$context['password_auth_failed'] = true;
641
+			if (in_array('bad_password', $post_errors)) {
642
+							$context['password_auth_failed'] = true;
643
+			}
618 644
 		}
619 645
 
620 646
 		// Change the IP address in the database.
621
-		if ($context['user']['is_owner'])
622
-			$profile_vars['member_ip'] = $user_info['ip'];
647
+		if ($context['user']['is_owner']) {
648
+					$profile_vars['member_ip'] = $user_info['ip'];
649
+		}
623 650
 
624 651
 		// Now call the sub-action function...
625 652
 		if ($current_area == 'activateaccount')
626 653
 		{
627
-			if (empty($post_errors))
628
-				activateAccount($memID);
629
-		}
630
-		elseif ($current_area == 'deleteaccount')
654
+			if (empty($post_errors)) {
655
+							activateAccount($memID);
656
+			}
657
+		} elseif ($current_area == 'deleteaccount')
631 658
 		{
632 659
 			if (empty($post_errors))
633 660
 			{
634 661
 				deleteAccount2($memID);
635 662
 				redirectexit();
636 663
 			}
637
-		}
638
-		elseif ($current_area == 'groupmembership' && empty($post_errors))
664
+		} elseif ($current_area == 'groupmembership' && empty($post_errors))
639 665
 		{
640 666
 			$msg = groupMembership2($profile_vars, $post_errors, $memID);
641 667
 
642 668
 			// Whatever we've done, we have nothing else to do here...
643 669
 			redirectexit('action=profile' . ($context['user']['is_owner'] ? '' : ';u=' . $memID) . ';area=groupmembership' . (!empty($msg) ? ';msg=' . $msg : ''));
644
-		}
645
-		elseif (in_array($current_area, array('account', 'forumprofile', 'theme')))
646
-			saveProfileFields();
647
-		else
670
+		} elseif (in_array($current_area, array('account', 'forumprofile', 'theme'))) {
671
+					saveProfileFields();
672
+		} else
648 673
 		{
649 674
 			$force_redirect = true;
650 675
 			// Ensure we include this.
@@ -660,34 +685,36 @@  discard block
 block discarded – undo
660 685
 			// Load the language file so we can give a nice explanation of the errors.
661 686
 			loadLanguage('Errors');
662 687
 			$context['post_errors'] = $post_errors;
663
-		}
664
-		elseif (!empty($profile_vars))
688
+		} elseif (!empty($profile_vars))
665 689
 		{
666 690
 			// If we've changed the password, notify any integration that may be listening in.
667
-			if (isset($profile_vars['passwd']))
668
-				call_integration_hook('integrate_reset_pass', array($cur_profile['member_name'], $cur_profile['member_name'], $_POST['passwrd2']));
691
+			if (isset($profile_vars['passwd'])) {
692
+							call_integration_hook('integrate_reset_pass', array($cur_profile['member_name'], $cur_profile['member_name'], $_POST['passwrd2']));
693
+			}
669 694
 
670 695
 			updateMemberData($memID, $profile_vars);
671 696
 
672 697
 			// What if this is the newest member?
673
-			if ($modSettings['latestMember'] == $memID)
674
-				updateStats('member');
675
-			elseif (isset($profile_vars['real_name']))
676
-				updateSettings(array('memberlist_updated' => time()));
698
+			if ($modSettings['latestMember'] == $memID) {
699
+							updateStats('member');
700
+			} elseif (isset($profile_vars['real_name'])) {
701
+							updateSettings(array('memberlist_updated' => time()));
702
+			}
677 703
 
678 704
 			// If the member changed his/her birthdate, update calendar statistics.
679
-			if (isset($profile_vars['birthdate']) || isset($profile_vars['real_name']))
680
-				updateSettings(array(
705
+			if (isset($profile_vars['birthdate']) || isset($profile_vars['real_name'])) {
706
+							updateSettings(array(
681 707
 					'calendar_updated' => time(),
682 708
 				));
709
+			}
683 710
 
684 711
 			// Anything worth logging?
685 712
 			if (!empty($context['log_changes']) && !empty($modSettings['modlog_enabled']))
686 713
 			{
687 714
 				$log_changes = array();
688 715
 				require_once($sourcedir . '/Logging.php');
689
-				foreach ($context['log_changes'] as $k => $v)
690
-					$log_changes[] = array(
716
+				foreach ($context['log_changes'] as $k => $v) {
717
+									$log_changes[] = array(
691 718
 						'action' => $k,
692 719
 						'log_type' => 'user',
693 720
 						'extra' => array_merge($v, array(
@@ -695,14 +722,16 @@  discard block
 block discarded – undo
695 722
 							'member_affected' => $memID,
696 723
 						)),
697 724
 					);
725
+				}
698 726
 
699 727
 				logActions($log_changes);
700 728
 			}
701 729
 
702 730
 			// Have we got any post save functions to execute?
703
-			if (!empty($context['profile_execute_on_save']))
704
-				foreach ($context['profile_execute_on_save'] as $saveFunc)
731
+			if (!empty($context['profile_execute_on_save'])) {
732
+							foreach ($context['profile_execute_on_save'] as $saveFunc)
705 733
 					$saveFunc();
734
+			}
706 735
 
707 736
 			// Let them know it worked!
708 737
 			$context['profile_updated'] = $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $cur_profile['member_name']);
@@ -716,27 +745,31 @@  discard block
 block discarded – undo
716 745
 	if (!empty($post_errors))
717 746
 	{
718 747
 		// Set all the errors so the template knows what went wrong.
719
-		foreach ($post_errors as $error_type)
720
-			$context['modify_error'][$error_type] = true;
748
+		foreach ($post_errors as $error_type) {
749
+					$context['modify_error'][$error_type] = true;
750
+		}
721 751
 	}
722 752
 	// If it's you then we should redirect upon save.
723
-	elseif (!empty($profile_vars) && $context['user']['is_owner'] && !$context['do_preview'])
724
-		redirectexit('action=profile;area=' . $current_area . (!empty($current_sa) ? ';sa=' . $current_sa : '') . ';updated');
725
-	elseif (!empty($force_redirect))
726
-		redirectexit('action=profile' . ($context['user']['is_owner'] ? '' : ';u=' . $memID) . ';area=' . $current_area);
753
+	elseif (!empty($profile_vars) && $context['user']['is_owner'] && !$context['do_preview']) {
754
+			redirectexit('action=profile;area=' . $current_area . (!empty($current_sa) ? ';sa=' . $current_sa : '') . ';updated');
755
+	} elseif (!empty($force_redirect)) {
756
+			redirectexit('action=profile' . ($context['user']['is_owner'] ? '' : ';u=' . $memID) . ';area=' . $current_area);
757
+	}
727 758
 
728 759
 
729 760
 	// Get the right callable.
730 761
 	$call = call_helper($profile_include_data['function'], true);
731 762
 
732 763
 	// Is it valid?
733
-	if (!empty($call))
734
-		call_user_func($call, $memID);
764
+	if (!empty($call)) {
765
+			call_user_func($call, $memID);
766
+	}
735 767
 
736 768
 	// Set the page title if it's not already set...
737
-	if (!isset($context['page_title']))
738
-		$context['page_title'] = $txt['profile'] . (isset($txt[$current_area]) ? ' - ' . $txt[$current_area] : '');
739
-}
769
+	if (!isset($context['page_title'])) {
770
+			$context['page_title'] = $txt['profile'] . (isset($txt[$current_area]) ? ' - ' . $txt[$current_area] : '');
771
+	}
772
+	}
740 773
 
741 774
 /**
742 775
  * Set up the requirements for the profile popup - the area that is shown as the popup menu for the current user.
@@ -859,16 +892,18 @@  discard block
 block discarded – undo
859 892
 	if (!allowedTo('admin_forum') && $area != 'register')
860 893
 	{
861 894
 		// If it's the owner they can see two types of private fields, regardless.
862
-		if ($memID == $user_info['id'])
863
-			$where .= $area == 'summary' ? ' AND private < 3' : ' AND (private = 0 OR private = 2)';
864
-		else
865
-			$where .= $area == 'summary' ? ' AND private < 2' : ' AND private = 0';
895
+		if ($memID == $user_info['id']) {
896
+					$where .= $area == 'summary' ? ' AND private < 3' : ' AND (private = 0 OR private = 2)';
897
+		} else {
898
+					$where .= $area == 'summary' ? ' AND private < 2' : ' AND private = 0';
899
+		}
866 900
 	}
867 901
 
868
-	if ($area == 'register')
869
-		$where .= ' AND show_reg != 0';
870
-	elseif ($area != 'summary')
871
-		$where .= ' AND show_profile = {string:area}';
902
+	if ($area == 'register') {
903
+			$where .= ' AND show_reg != 0';
904
+	} elseif ($area != 'summary') {
905
+			$where .= ' AND show_profile = {string:area}';
906
+	}
872 907
 
873 908
 	// Load all the relevant fields - and data.
874 909
 	$request = $smcFunc['db_query']('', '
@@ -894,13 +929,15 @@  discard block
 block discarded – undo
894 929
 		if (isset($_POST['customfield']) && isset($_POST['customfield'][$row['col_name']]))
895 930
 		{
896 931
 			$value = $smcFunc['htmlspecialchars']($_POST['customfield'][$row['col_name']]);
897
-			if (in_array($row['field_type'], array('select', 'radio')))
898
-					$value = ($options = explode(',', $row['field_options'])) && isset($options[$value]) ? $options[$value] : '';
932
+			if (in_array($row['field_type'], array('select', 'radio'))) {
933
+								$value = ($options = explode(',', $row['field_options'])) && isset($options[$value]) ? $options[$value] : '';
934
+			}
899 935
 		}
900 936
 
901 937
 		// Don't show the "disabled" option for the "gender" field if we are on the "summary" area.
902
-		if ($area == 'summary' && $row['col_name'] == 'cust_gender' && $value == 'None')
903
-			continue;
938
+		if ($area == 'summary' && $row['col_name'] == 'cust_gender' && $value == 'None') {
939
+					continue;
940
+		}
904 941
 
905 942
 		// HTML for the input form.
906 943
 		$output_html = $value;
@@ -909,8 +946,7 @@  discard block
 block discarded – undo
909 946
 			$true = (!$exists && $row['default_value']) || $value;
910 947
 			$input_html = '<input type="checkbox" name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . ($true ? ' checked' : '') . '>';
911 948
 			$output_html = $true ? $txt['yes'] : $txt['no'];
912
-		}
913
-		elseif ($row['field_type'] == 'select')
949
+		} elseif ($row['field_type'] == 'select')
914 950
 		{
915 951
 			$input_html = '<select name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"><option value="-1"></option>';
916 952
 			$options = explode(',', $row['field_options']);
@@ -918,13 +954,13 @@  discard block
 block discarded – undo
918 954
 			{
919 955
 				$true = (!$exists && $row['default_value'] == $v) || $value == $v;
920 956
 				$input_html .= '<option value="' . $k . '"' . ($true ? ' selected' : '') . '>' . $v . '</option>';
921
-				if ($true)
922
-					$output_html = $v;
957
+				if ($true) {
958
+									$output_html = $v;
959
+				}
923 960
 			}
924 961
 
925 962
 			$input_html .= '</select>';
926
-		}
927
-		elseif ($row['field_type'] == 'radio')
963
+		} elseif ($row['field_type'] == 'radio')
928 964
 		{
929 965
 			$input_html = '<fieldset>';
930 966
 			$options = explode(',', $row['field_options']);
@@ -932,36 +968,37 @@  discard block
 block discarded – undo
932 968
 			{
933 969
 				$true = (!$exists && $row['default_value'] == $v) || $value == $v;
934 970
 				$input_html .= '<label for="customfield_' . $row['col_name'] . '_' . $k . '"><input type="radio" name="customfield[' . $row['col_name'] . ']" id="customfield_' . $row['col_name'] . '_' . $k . '" value="' . $k . '"' . ($true ? ' checked' : '') . '>' . $v . '</label><br>';
935
-				if ($true)
936
-					$output_html = $v;
971
+				if ($true) {
972
+									$output_html = $v;
973
+				}
937 974
 			}
938 975
 			$input_html .= '</fieldset>';
939
-		}
940
-		elseif ($row['field_type'] == 'text')
976
+		} elseif ($row['field_type'] == 'text')
941 977
 		{
942 978
 			$input_html = '<input type="text" name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . ($row['field_length'] != 0 ? ' maxlength="' . $row['field_length'] . '"' : '') . ' size="' . ($row['field_length'] == 0 || $row['field_length'] >= 50 ? 50 : ($row['field_length'] > 30 ? 30 : ($row['field_length'] > 10 ? 20 : 10))) . '" value="' . un_htmlspecialchars($value) . '"' . ($row['show_reg'] == 2 ? ' required' : '') . '>';
943
-		}
944
-		else
979
+		} else
945 980
 		{
946 981
 			@list ($rows, $cols) = @explode(',', $row['default_value']);
947 982
 			$input_html = '<textarea name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . (!empty($rows) ? ' rows="' . $rows . '"' : '') . (!empty($cols) ? ' cols="' . $cols . '"' : '') . ($row['show_reg'] == 2 ? ' required' : '') . '>' . un_htmlspecialchars($value) . '</textarea>';
948 983
 		}
949 984
 
950 985
 		// Parse BBCode
951
-		if ($row['bbc'])
952
-			$output_html = parse_bbc($output_html);
953
-		elseif ($row['field_type'] == 'textarea')
954
-			// Allow for newlines at least
986
+		if ($row['bbc']) {
987
+					$output_html = parse_bbc($output_html);
988
+		} elseif ($row['field_type'] == 'textarea') {
989
+					// Allow for newlines at least
955 990
 			$output_html = strtr($output_html, array("\n" => '<br>'));
991
+		}
956 992
 
957 993
 		// Enclosing the user input within some other text?
958
-		if (!empty($row['enclose']) && !empty($output_html))
959
-			$output_html = strtr($row['enclose'], array(
994
+		if (!empty($row['enclose']) && !empty($output_html)) {
995
+					$output_html = strtr($row['enclose'], array(
960 996
 				'{SCRIPTURL}' => $scripturl,
961 997
 				'{IMAGES_URL}' => $settings['images_url'],
962 998
 				'{DEFAULT_IMAGES_URL}' => $settings['default_images_url'],
963 999
 				'{INPUT}' => un_htmlspecialchars($output_html),
964 1000
 			));
1001
+		}
965 1002
 
966 1003
 		$context['custom_fields'][] = array(
967 1004
 			'name' => $row['field_name'],
Please login to merge, or discard this patch.