Completed
Pull Request — release-2.1 (#4995)
by Jeremy
06:49
created
Themes/default/PersonalMessage.template.php 2 patches
Braces   +285 added lines, -199 removed lines patch added patch discarded remove patch
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
 	<div id="personal_messages">';
22 22
 
23 23
 	// Show the capacity bar, if available.
24
-	if (!empty($context['limit_bar']))
25
-		echo '
24
+	if (!empty($context['limit_bar'])) {
25
+			echo '
26 26
 		<div class="cat_bar">
27 27
 			<h3 class="catbg">
28 28
 				<span class="floatleft">', $txt['pm_capacity'], ':</span>
@@ -32,14 +32,16 @@  discard block
 block discarded – undo
32 32
 				<span class="floatright', $context['limit_bar']['percent'] > 90 ? ' alert' : '', '">', $context['limit_bar']['text'], '</span>
33 33
 			</h3>
34 34
 		</div>';
35
+	}
35 36
 
36 37
 	// Message sent? Show a small indication.
37
-	if (isset($context['pm_sent']))
38
-		echo '
38
+	if (isset($context['pm_sent'])) {
39
+			echo '
39 40
 		<div class="infobox">
40 41
 			', $txt['pm_sent'], '
41 42
 		</div>';
42
-}
43
+	}
44
+	}
43 45
 
44 46
 /**
45 47
  * Just the end of the index bar, nothing special.
@@ -68,13 +70,13 @@  discard block
 block discarded – undo
68 70
 		</div>
69 71
 		<div class="pm_unread">';
70 72
 
71
-	if (empty($context['unread_pms']))
72
-		echo '
73
+	if (empty($context['unread_pms'])) {
74
+			echo '
73 75
 			<div class="no_unread">', $txt['pm_no_unread'], '</div>';
74
-	else
76
+	} else
75 77
 	{
76
-		foreach ($context['unread_pms'] as $id_pm => $pm_details)
77
-			echo '
78
+		foreach ($context['unread_pms'] as $id_pm => $pm_details) {
79
+					echo '
78 80
 			<div class="unread">
79 81
 				', !empty($pm_details['member']) ? $pm_details['member']['avatar']['image'] : '', '
80 82
 				<div class="details">
@@ -85,6 +87,7 @@  discard block
 block discarded – undo
85 87
 					</div>
86 88
 				</div>
87 89
 			</div>';
90
+		}
88 91
 	}
89 92
 
90 93
 	echo '
@@ -193,14 +196,15 @@  discard block
 block discarded – undo
193 196
 	if ($context['get_pmessage']('message', true))
194 197
 	{
195 198
 		// Show the helpful titlebar - generally.
196
-		if ($context['display_mode'] != 1)
197
-			echo '
199
+		if ($context['display_mode'] != 1) {
200
+					echo '
198 201
 			<div class="cat_bar">
199 202
 				<h3 class="catbg">
200 203
 					<span id="author">', $txt['author'], '</span>
201 204
 					<span id="topic_title">', $txt[$context['display_mode'] == 0 ? 'messages' : 'conversation'], '</span>
202 205
 				</h3>
203 206
 			</div>';
207
+		}
204 208
 
205 209
 		// Show a few buttons if we are in conversation mode and outputting the first message.
206 210
 		if ($context['display_mode'] == 2)
@@ -228,9 +232,10 @@  discard block
 block discarded – undo
228 232
 					<div class="custom_fields_above_member">
229 233
 						<ul class="nolist">';
230 234
 
231
-				foreach ($message['custom_fields']['above_member'] as $custom)
232
-					echo '
235
+				foreach ($message['custom_fields']['above_member'] as $custom) {
236
+									echo '
233 237
 							<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
238
+				}
234 239
 
235 240
 				echo '
236 241
 						</ul>
@@ -242,25 +247,28 @@  discard block
 block discarded – undo
242 247
 						<a id="msg', $message['id'], '"></a>';
243 248
 
244 249
 			// Show online and offline buttons?
245
-			if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest'])
246
-				echo '
250
+			if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) {
251
+							echo '
247 252
 						<span class="' . ($message['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $message['member']['online']['text'] . '"></span>';
253
+			}
248 254
 
249 255
 			// Custom fields BEFORE the username?
250
-			if (!empty($message['custom_fields']['before_member']))
251
-				foreach ($message['custom_fields']['before_member'] as $custom)
256
+			if (!empty($message['custom_fields']['before_member'])) {
257
+							foreach ($message['custom_fields']['before_member'] as $custom)
252 258
 					echo '
253 259
 						<span class="custom ', $custom['col_name'], '">', $custom['value'], '</span>';
260
+			}
254 261
 
255 262
 			// Show a link to the member's profile.
256 263
 			echo '
257 264
 				', $message['member']['link'];
258 265
 
259 266
 				// Custom fields AFTER the username?
260
-				if (!empty($message['custom_fields']['after_member']))
261
-					foreach ($message['custom_fields']['after_member'] as $custom)
267
+				if (!empty($message['custom_fields']['after_member'])) {
268
+									foreach ($message['custom_fields']['after_member'] as $custom)
262 269
 						echo '
263 270
 						<span class="custom ', $custom['col_name'], '">', $custom['value'], '</span>';
271
+				}
264 272
 
265 273
 			echo '
266 274
 					</h4>';
@@ -269,48 +277,56 @@  discard block
 block discarded – undo
269 277
 					<ul class="user_info">';
270 278
 
271 279
 			// Show the user's avatar.
272
-			if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image']))
273
-				echo '
280
+			if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) {
281
+							echo '
274 282
 						<li class="avatar">
275 283
 							<a href="', $scripturl, '?action=profile;u=', $message['member']['id'], '">', $message['member']['avatar']['image'], '</a>
276 284
 						</li>';
285
+			}
277 286
 
278 287
 			// Are there any custom fields below the avatar?
279
-			if (!empty($message['custom_fields']['below_avatar']))
280
-				foreach ($message['custom_fields']['below_avatar'] as $custom)
288
+			if (!empty($message['custom_fields']['below_avatar'])) {
289
+							foreach ($message['custom_fields']['below_avatar'] as $custom)
281 290
 					echo '
282 291
 						<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
292
+			}
283 293
 
284
-			if (!$message['member']['is_guest'])
285
-				echo '
294
+			if (!$message['member']['is_guest']) {
295
+							echo '
286 296
 						<li class="icons">', $message['member']['group_icons'], '</li>';
297
+			}
287 298
 			// Show the member's primary group (like 'Administrator') if they have one.
288
-			if (isset($message['member']['group']) && $message['member']['group'] != '')
289
-				echo '
299
+			if (isset($message['member']['group']) && $message['member']['group'] != '') {
300
+							echo '
290 301
 						<li class="membergroup">', $message['member']['group'], '</li>';
302
+			}
291 303
 
292 304
 			// Show the member's custom title, if they have one.
293
-			if (isset($message['member']['title']) && $message['member']['title'] != '')
294
-				echo '
305
+			if (isset($message['member']['title']) && $message['member']['title'] != '') {
306
+							echo '
295 307
 						<li class="title">', $message['member']['title'], '</li>';
308
+			}
296 309
 
297 310
 			// Don't show these things for guests.
298 311
 			if (!$message['member']['is_guest'])
299 312
 			{
300 313
 				// Show the post group if and only if they have no other group or the option is on, and they are in a post group.
301
-				if ((empty($modSettings['hide_post_group']) || $message['member']['group'] == '') && $message['member']['post_group'] != '')
302
-					echo '
314
+				if ((empty($modSettings['hide_post_group']) || $message['member']['group'] == '') && $message['member']['post_group'] != '') {
315
+									echo '
303 316
 						<li class="postgroup">', $message['member']['post_group'], '</li>';
317
+				}
304 318
 
305 319
 				// Show how many posts they have made.
306
-				if (!isset($context['disabled_fields']['posts']))
307
-					echo '
320
+				if (!isset($context['disabled_fields']['posts'])) {
321
+									echo '
308 322
 						<li class="postcount">', $txt['member_postcount'], ': ', $message['member']['posts'], '</li>';
323
+				}
309 324
 
310 325
 				// Show their personal text?
311
-				if (!empty($modSettings['show_blurb']) && $message['member']['blurb'] != '')
312
-					echo '
326
+				if (!empty($modSettings['show_blurb']) && $message['member']['blurb'] != '') {
327
+									echo '
313 328
 						<li class="blurb">', $message['member']['blurb'], '</li>';
329
+				}
314 330
 
315 331
 				// Any custom fields to show as icons?
316 332
 				if (!empty($message['custom_fields']['icons']))
@@ -319,9 +335,10 @@  discard block
 block discarded – undo
319 335
 						<li class="im_icons">
320 336
 							<ol>';
321 337
 
322
-					foreach ($message['custom_fields']['icons'] as $custom)
323
-						echo '
338
+					foreach ($message['custom_fields']['icons'] as $custom) {
339
+											echo '
324 340
 								<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
341
+					}
325 342
 
326 343
 					echo '
327 344
 							</ol>
@@ -329,25 +346,28 @@  discard block
 block discarded – undo
329 346
 				}
330 347
 
331 348
 				// Show the IP to this user for this post - because you can moderate?
332
-				if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip']))
333
-					echo '
349
+				if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) {
350
+									echo '
334 351
 						<li class="poster_ip">
335 352
 							<a href="', $scripturl, '?action=', !empty($message['member']['is_guest']) ? 'trackip' : 'profile;area=tracking;sa=ip;u=' . $message['member']['id'], ';searchip=', $message['member']['ip'], '">', $message['member']['ip'], '</a> <a href="', $scripturl, '?action=helpadmin;help=see_admin_ip" onclick="return reqOverlayDiv(this.href);" class="help">(?)</a>
336 353
 						</li>';
354
+				}
337 355
 
338 356
 				// Or, should we show it because this is you?
339
-				elseif ($message['can_see_ip'])
340
-					echo '
357
+				elseif ($message['can_see_ip']) {
358
+									echo '
341 359
 						<li class="poster_ip">
342 360
 							<a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $message['member']['ip'], '</a>
343 361
 						</li>';
362
+				}
344 363
 
345 364
 				// Okay, you are logged in, then we can show something about why IPs are logged...
346
-				else
347
-					echo '
365
+				else {
366
+									echo '
348 367
 						<li class="poster_ip">
349 368
 							<a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $txt['logged'], '</a>
350 369
 						</li>';
370
+				}
351 371
 
352 372
 				// Show the profile, website, email address, and personal message buttons.
353 373
 				if ($message['member']['show_profile_buttons'])
@@ -357,24 +377,28 @@  discard block
 block discarded – undo
357 377
 							<ol class="profile_icons">';
358 378
 
359 379
 					// Show the profile button
360
-					if ($message['member']['can_view_profile'])
361
-						echo '
380
+					if ($message['member']['can_view_profile']) {
381
+											echo '
362 382
 								<li><a href="', $message['member']['href'], '">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/icons/profile_sm.png" alt="' . $txt['view_profile'] . '" title="' . $txt['view_profile'] . '">' : $txt['view_profile']), '</a></li>';
383
+					}
363 384
 
364 385
 					// Don't show an icon if they haven't specified a website.
365
-					if ($message['member']['website']['url'] != '' && !isset($context['disabled_fields']['website']))
366
-						echo '
386
+					if ($message['member']['website']['url'] != '' && !isset($context['disabled_fields']['website'])) {
387
+											echo '
367 388
 								<li><a href="', $message['member']['website']['url'], '" title="' . $message['member']['website']['title'] . '" target="_blank" rel="noopener">', ($settings['use_image_buttons'] ? '<span class="generic_icons www centericon" title="' . $message['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>';
389
+					}
368 390
 
369 391
 					// Don't show the email address if they want it hidden.
370
-					if ($message['member']['show_email'])
371
-						echo '
392
+					if ($message['member']['show_email']) {
393
+											echo '
372 394
 								<li><a href="mailto:', $message['member']['email'], '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>';
395
+					}
373 396
 
374 397
 					// Since we know this person isn't a guest, you *can* message them.
375
-					if ($context['can_send_pm'])
376
-						echo '
398
+					if ($context['can_send_pm']) {
399
+											echo '
377 400
 								<li><a href="', $scripturl, '?action=pm;sa=send;u=', $message['member']['id'], '" title="', $message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline'], '">', $settings['use_image_buttons'] ? '<span class="generic_icons im_' . ($message['member']['online']['is_online'] ? 'on' : 'off') . ' centericon" title="' . ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']) . '"></span> ' : ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']), '</a></li>';
401
+					}
378 402
 
379 403
 					echo '
380 404
 							</ol>
@@ -382,21 +406,24 @@  discard block
 block discarded – undo
382 406
 				}
383 407
 
384 408
 				// Any custom fields for standard placement?
385
-				if (!empty($message['custom_fields']['standard']))
386
-					foreach ($message['custom_fields']['standard'] as $custom)
409
+				if (!empty($message['custom_fields']['standard'])) {
410
+									foreach ($message['custom_fields']['standard'] as $custom)
387 411
 						echo '
388 412
 						<li class="custom ', $custom['col_name'] ,'">', $custom['title'], ': ', $custom['value'], '</li>';
413
+				}
389 414
 
390 415
 				// Are we showing the warning status?
391
-				if ($message['member']['can_see_warning'])
392
-					echo '
416
+				if ($message['member']['can_see_warning']) {
417
+									echo '
393 418
 						<li class="warning">', $context['can_issue_warning'] ? '<a href="' . $scripturl . '?action=profile;area=issuewarning;u=' . $message['member']['id'] . '">' : '', '<span class="generic_icons warning_', $message['member']['warning_status'], '"></span>', $context['can_issue_warning'] ? '</a>' : '', '<span class="warn_', $message['member']['warning_status'], '">', $txt['warn_' . $message['member']['warning_status']], '</span></li>';
419
+				}
394 420
 
395 421
 				// Are there any custom fields to show at the bottom of the poster info?
396
-				if (!empty($message['custom_fields']['bottom_poster']))
397
-					foreach ($message['custom_fields']['bottom_poster'] as $custom)
422
+				if (!empty($message['custom_fields']['bottom_poster'])) {
423
+									foreach ($message['custom_fields']['bottom_poster'] as $custom)
398 424
 						echo '
399 425
 						<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
426
+				}
400 427
 			}
401 428
 
402 429
 			// Done with the information about the poster... on to the post itself.
@@ -415,25 +442,29 @@  discard block
 block discarded – undo
415 442
 							<span class="smalltext">&#171; <strong> ', $txt['sent_to'], ':</strong> ';
416 443
 
417 444
 			// People it was sent directly to....
418
-			if (!empty($message['recipients']['to']))
419
-				echo implode(', ', $message['recipients']['to']);
445
+			if (!empty($message['recipients']['to'])) {
446
+							echo implode(', ', $message['recipients']['to']);
447
+			}
420 448
 
421 449
 			// Otherwise, we're just going to say "some people"...
422
-			elseif ($context['folder'] != 'sent')
423
-				echo '(', $txt['pm_undisclosed_recipients'], ')';
450
+			elseif ($context['folder'] != 'sent') {
451
+							echo '(', $txt['pm_undisclosed_recipients'], ')';
452
+			}
424 453
 
425 454
 			echo '
426 455
 								<strong> ', $txt['on'], ':</strong> ', $message['time'], ' &#187;
427 456
 							</span>';
428 457
 
429 458
 			// If we're in the sent items, show who it was sent to besides the "To:" people.
430
-			if (!empty($message['recipients']['bcc']))
431
-				echo '<br>
459
+			if (!empty($message['recipients']['bcc'])) {
460
+							echo '<br>
432 461
 							<span class="smalltext">&#171; <strong> ', $txt['pm_bcc'], ':</strong> ', implode(', ', $message['recipients']['bcc']), ' &#187;</span>';
462
+			}
433 463
 
434
-			if (!empty($message['is_replied_to']))
435
-				echo '<br>
464
+			if (!empty($message['is_replied_to'])) {
465
+							echo '<br>
436 466
 							<span class="smalltext">&#171; ', $context['folder'] == 'sent' ? $txt['pm_sent_is_replied_to'] : $txt['pm_is_replied_to'], ' &#187;</span>';
467
+			}
437 468
 
438 469
 			echo '
439 470
 						</div><!-- .keyinfo -->
@@ -443,13 +474,15 @@  discard block
 block discarded – undo
443 474
 							', $message['body'], '
444 475
 						</div>';
445 476
 
446
-			if ($message['can_report'] || $context['can_send_pm'])
447
-				echo '
477
+			if ($message['can_report'] || $context['can_send_pm']) {
478
+							echo '
448 479
 						<div class="under_message">';
480
+			}
449 481
 
450
-			if ($message['can_report'])
451
-				echo '
482
+			if ($message['can_report']) {
483
+							echo '
452 484
 							<a href="' . $scripturl . '?action=pm;sa=report;l=' . $context['current_label_id'] . ';pmsg=' . $message['id'] . '" class="floatright">' . $txt['pm_report_to_admin'] . '</a>';
485
+			}
453 486
 
454 487
 			echo '
455 488
 							<ul class="quickbuttons">';
@@ -461,32 +494,36 @@  discard block
 block discarded – undo
461 494
 				if (!$message['member']['is_guest'])
462 495
 				{
463 496
 					// Is there than more than one recipient you can reply to?
464
-					if ($message['number_recipients'] > 1)
465
-						echo '
497
+					if ($message['number_recipients'] > 1) {
498
+											echo '
466 499
 								<li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote;u=all"><span class="generic_icons reply_all_button"></span>', $txt['reply_to_all'], '</a></li>';
500
+					}
467 501
 
468 502
 					echo '
469 503
 								<li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';u=', $message['member']['id'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>
470 504
 								<li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote', $context['folder'] == 'sent' ? '' : ';u=' . $message['member']['id'], '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>';
471 505
 				}
472 506
 				// This is for "forwarding" - even if the member is gone.
473
-				else
474
-					echo '
507
+				else {
508
+									echo '
475 509
 								<li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote"><span class="generic_icons quote"></span>', $txt['reply_quote'], '</a></li>';
510
+				}
476 511
 			}
477 512
 			echo '
478 513
 								<li><a href="', $scripturl, '?action=pm;sa=pmactions;pm_actions%5b', $message['id'], '%5D=delete;f=', $context['folder'], ';start=', $context['start'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', addslashes($txt['remove_message_question']), '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['delete'], '</a></li>';
479 514
 
480
-			if (empty($context['display_mode']))
481
-				echo '
515
+			if (empty($context['display_mode'])) {
516
+							echo '
482 517
 								<li><input type="checkbox" name="pms[]" id="deletedisplay', $message['id'], '" value="', $message['id'], '" onclick="document.getElementById(\'deletelisting', $message['id'], '\').checked = this.checked;"></li>';
518
+			}
483 519
 
484 520
 			echo '
485 521
 							</ul>';
486 522
 
487
-			if ($message['can_report'] || $context['can_send_pm'])
488
-			echo '
523
+			if ($message['can_report'] || $context['can_send_pm']) {
524
+						echo '
489 525
 						</div><!-- .under_message -->';
526
+			}
490 527
 
491 528
 			// Are there any custom profile fields for above the signature?
492 529
 			if (!empty($message['custom_fields']['above_signature']))
@@ -495,9 +532,10 @@  discard block
 block discarded – undo
495 532
 						<div class="custom_fields_above_signature">
496 533
 							<ul class="nolist">';
497 534
 
498
-				foreach ($message['custom_fields']['above_signature'] as $custom)
499
-					echo '
535
+				foreach ($message['custom_fields']['above_signature'] as $custom) {
536
+									echo '
500 537
 								<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
538
+				}
501 539
 
502 540
 				echo '
503 541
 							</ul>
@@ -505,11 +543,12 @@  discard block
 block discarded – undo
505 543
 			}
506 544
 
507 545
 			// Show the member's signature?
508
-			if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled'])
509
-				echo '
546
+			if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) {
547
+							echo '
510 548
 						<div class="signature">
511 549
 							', $message['member']['signature'], '
512 550
 						</div>';
551
+			}
513 552
 
514 553
 			// Are there any custom profile fields for below the signature?
515 554
 			if (!empty($message['custom_fields']['below_signature']))
@@ -518,9 +557,10 @@  discard block
 block discarded – undo
518 557
 						<div class="custom_fields_below_signature">
519 558
 							<ul class="nolist">';
520 559
 
521
-				foreach ($message['custom_fields']['below_signature'] as $custom)
522
-					echo '
560
+				foreach ($message['custom_fields']['below_signature'] as $custom) {
561
+									echo '
523 562
 								<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
563
+				}
524 564
 
525 565
 				echo '
526 566
 							</ul>
@@ -547,10 +587,11 @@  discard block
 block discarded – undo
547 587
 						echo '
548 588
 								<option value="" disabled>', $txt['pm_msg_label_apply'], ':</option>';
549 589
 
550
-						foreach ($context['labels'] as $label)
551
-							if (!isset($message['labels'][$label['id']]))
590
+						foreach ($context['labels'] as $label) {
591
+													if (!isset($message['labels'][$label['id']]))
552 592
 								echo '
553 593
 								<option value="', $label['id'], '">', $label['name'], '</option>';
594
+						}
554 595
 					}
555 596
 
556 597
 					// ... and are there any that can be removed?
@@ -559,9 +600,10 @@  discard block
 block discarded – undo
559 600
 						echo '
560 601
 								<option value="" disabled>', $txt['pm_msg_label_remove'], ':</option>';
561 602
 
562
-						foreach ($message['labels'] as $label)
563
-							echo '
603
+						foreach ($message['labels'] as $label) {
604
+													echo '
564 605
 								<option value="', $label['id'], '">&nbsp;', $label['name'], '</option>';
606
+						}
565 607
 					}
566 608
 					echo '
567 609
 							</select>
@@ -580,14 +622,15 @@  discard block
 block discarded – undo
580 622
 			</div><!-- .windowbg -->';
581 623
 		}
582 624
 
583
-		if (empty($context['display_mode']))
584
-			echo '
625
+		if (empty($context['display_mode'])) {
626
+					echo '
585 627
 			<div class="pagesection">
586 628
 				<div class="floatleft">', $context['page_index'], '</div>
587 629
 				<div class="floatright">
588 630
 					<input type="submit" name="del_selected" value="', $txt['quickmod_delete_selected'], '" onclick="if (!confirm(\'', $txt['delete_selected_confirm'], '\')) return false;" class="button">
589 631
 				</div>
590 632
 			</div>';
633
+		}
591 634
 
592 635
 		// Show a few buttons if we are in conversation mode and outputting the first message.
593 636
 		elseif ($context['display_mode'] == 2 && isset($context['conversation_buttons']))
@@ -647,11 +690,12 @@  discard block
 block discarded – undo
647 690
 		</thead>
648 691
 		<tbody>';
649 692
 
650
-	if (!$context['show_delete'])
651
-		echo '
693
+	if (!$context['show_delete']) {
694
+			echo '
652 695
 			<tr class="windowbg">
653 696
 				<td colspan="5">', $txt['pm_alert_none'], '</td>
654 697
 			</tr>';
698
+	}
655 699
 
656 700
 	while ($message = $context['get_pmessage']('subject'))
657 701
 	{
@@ -709,17 +753,19 @@  discard block
 block discarded – undo
709 753
 
710 754
 			foreach ($context['labels'] as $label)
711 755
 			{
712
-				if ($label['id'] != $context['current_label_id'])
713
-					echo '
756
+				if ($label['id'] != $context['current_label_id']) {
757
+									echo '
714 758
 				<option value="add_', $label['id'], '">&nbsp;', $label['name'], '</option>';
759
+				}
715 760
 			}
716 761
 
717 762
 			echo '
718 763
 				<option value="" disabled>', $txt['pm_msg_label_remove'], ':</option>';
719 764
 
720
-			foreach ($context['labels'] as $label)
721
-				echo '
765
+			foreach ($context['labels'] as $label) {
766
+							echo '
722 767
 				<option value="rem_', $label['id'], '">&nbsp;', $label['name'], '</option>';
768
+			}
723 769
 
724 770
 			echo '
725 771
 			</select>
@@ -744,11 +790,12 @@  discard block
 block discarded – undo
744 790
 {
745 791
 	global $context, $scripturl, $txt;
746 792
 
747
-	if (!empty($context['search_errors']))
748
-		echo '
793
+	if (!empty($context['search_errors'])) {
794
+			echo '
749 795
 		<div class="errorbox">
750 796
 			', implode('<br>', $context['search_errors']['messages']), '
751 797
 		</div>';
798
+	}
752 799
 
753 800
 	echo '
754 801
 	<form action="', $scripturl, '?action=pm;sa=search2" method="post" accept-charset="', $context['character_set'], '" name="searchform" id="searchform">
@@ -816,9 +863,10 @@  discard block
 block discarded – undo
816 863
 				</dd>
817 864
 			</dl>';
818 865
 
819
-	if (!$context['currently_using_labels'])
820
-		echo '
866
+	if (!$context['currently_using_labels']) {
867
+			echo '
821 868
 				<input type="submit" name="pm_search" value="', $txt['pm_search_go'], '" class="button floatright">';
869
+	}
822 870
 
823 871
 	echo '
824 872
 		</div><!-- .roundframe -->';
@@ -837,12 +885,13 @@  discard block
 block discarded – undo
837 885
 				<div id="advanced_panel_div">
838 886
 					<ul id="searchLabelsExpand">';
839 887
 
840
-		foreach ($context['search_labels'] as $label)
841
-			echo '
888
+		foreach ($context['search_labels'] as $label) {
889
+					echo '
842 890
 						<li>
843 891
 							<label for="searchlabel_', $label['id'], '"><input type="checkbox" id="searchlabel_', $label['id'], '" name="searchlabel[', $label['id'], ']" value="', $label['id'], '"', $label['checked'] ? ' checked' : '', '>
844 892
 							', $label['name'], '</label>
845 893
 						</li>';
894
+		}
846 895
 
847 896
 		echo '
848 897
 					</ul>
@@ -904,8 +953,8 @@  discard block
 block discarded – undo
904 953
 		</div>';
905 954
 
906 955
 	// Complete results?
907
-	if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages']))
908
-		echo '
956
+	if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages'])) {
957
+			echo '
909 958
 		<table class="table_grid">
910 959
 			<thead>
911 960
 				<tr class="title_bar">
@@ -915,6 +964,7 @@  discard block
 block discarded – undo
915 964
 				</tr>
916 965
 			</thead>
917 966
 			<tbody>';
967
+	}
918 968
 
919 969
 	// Print each message out...
920 970
 	foreach ($context['personal_messages'] as $message)
@@ -934,12 +984,14 @@  discard block
 block discarded – undo
934 984
 
935 985
 			// Show the recipients.
936 986
 			// @todo This doesn't deal with the sent item searching quite right for bcc.
937
-			if (!empty($message['recipients']['to']))
938
-				echo implode(', ', $message['recipients']['to']);
987
+			if (!empty($message['recipients']['to'])) {
988
+							echo implode(', ', $message['recipients']['to']);
989
+			}
939 990
 
940 991
 			// Otherwise, we're just going to say "some people"...
941
-			elseif ($context['folder'] != 'sent')
942
-				echo '(', $txt['pm_undisclosed_recipients'], ')';
992
+			elseif ($context['folder'] != 'sent') {
993
+							echo '(', $txt['pm_undisclosed_recipients'], ')';
994
+			}
943 995
 
944 996
 			echo '
945 997
 				</h3>
@@ -954,15 +1006,17 @@  discard block
 block discarded – undo
954 1006
 				$reply_button = create_button('im_reply.png', 'reply', 'reply', 'class="centericon"');
955 1007
 
956 1008
 				// You can only reply if they are not a guest...
957
-				if (!$message['member']['is_guest'])
958
-					echo '
1009
+				if (!$message['member']['is_guest']) {
1010
+									echo '
959 1011
 					<a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote;u=', $context['folder'] == 'sent' ? '' : $message['member']['id'], '">', $quote_button , '</a>', $context['menu_separator'], '
960 1012
 					<a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';u=', $message['member']['id'], '">', $reply_button , '</a> ', $context['menu_separator'];
1013
+				}
961 1014
 
962 1015
 				// This is for "forwarding" - even if the member is gone.
963
-				else
964
-					echo '
1016
+				else {
1017
+									echo '
965 1018
 					<a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote">', $quote_button , '</a>', $context['menu_separator'];
1019
+				}
966 1020
 			}
967 1021
 
968 1022
 			echo '
@@ -971,27 +1025,30 @@  discard block
 block discarded – undo
971 1025
 		}
972 1026
 		// Otherwise just a simple list!
973 1027
 		// @todo No context at all of the search?
974
-		else
975
-			echo '
1028
+		else {
1029
+					echo '
976 1030
 				<tr class="windowbg">
977 1031
 					<td>', $message['time'], '</td>
978 1032
 					<td>', $message['link'], '</td>
979 1033
 					<td>', $message['member']['link'], '</td>
980 1034
 				</tr>';
1035
+		}
981 1036
 	}
982 1037
 
983 1038
 	// Finish off the page...
984
-	if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages']))
985
-		echo '
1039
+	if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages'])) {
1040
+			echo '
986 1041
 			</tbody>
987 1042
 		</table>';
1043
+	}
988 1044
 
989 1045
 	// No results?
990
-	if (empty($context['personal_messages']))
991
-		echo '
1046
+	if (empty($context['personal_messages'])) {
1047
+			echo '
992 1048
 		<div class="windowbg">
993 1049
 			<p class="centertext">', $txt['pm_search_none_found'], '</p>
994 1050
 		</div>';
1051
+	}
995 1052
 
996 1053
 	echo '
997 1054
 		<div class="pagesection">
@@ -1016,15 +1073,17 @@  discard block
 block discarded – undo
1016 1073
 		</div>
1017 1074
 		<div class="windowbg">';
1018 1075
 
1019
-		if (!empty($context['send_log']['sent']))
1020
-			foreach ($context['send_log']['sent'] as $log_entry)
1076
+		if (!empty($context['send_log']['sent'])) {
1077
+					foreach ($context['send_log']['sent'] as $log_entry)
1021 1078
 				echo '
1022 1079
 			<span class="error">', $log_entry, '</span><br>';
1080
+		}
1023 1081
 
1024
-		if (!empty($context['send_log']['failed']))
1025
-			foreach ($context['send_log']['failed'] as $log_entry)
1082
+		if (!empty($context['send_log']['failed'])) {
1083
+					foreach ($context['send_log']['failed'] as $log_entry)
1026 1084
 				echo '
1027 1085
 			<span class="error">', $log_entry, '</span><br>';
1086
+		}
1028 1087
 
1029 1088
 		echo '
1030 1089
 		</div>
@@ -1070,12 +1129,13 @@  discard block
 block discarded – undo
1070 1129
 					</dl>
1071 1130
 				</div>';
1072 1131
 
1073
-	if (!empty($modSettings['drafts_pm_enabled']))
1074
-		echo '
1132
+	if (!empty($modSettings['drafts_pm_enabled'])) {
1133
+			echo '
1075 1134
 				<div id="draft_section" class="infobox"', isset($context['draft_saved']) ? '' : ' style="display: none;"', '>',
1076 1135
 					sprintf($txt['draft_pm_saved'], $scripturl . '?action=pm;sa=showpmdrafts'), '
1077 1136
 					', (!empty($modSettings['drafts_keep_days']) ? ' <strong>' . sprintf($txt['draft_save_warning'], $modSettings['drafts_keep_days']) . '</strong>' : ''), '
1078 1137
 				</div>';
1138
+	}
1079 1139
 
1080 1140
 	echo '
1081 1141
 				<dl id="post_header">';
@@ -1141,22 +1201,24 @@  discard block
 block discarded – undo
1141 1201
 						<dt><strong>', $txt['subject'], '</strong></dt>
1142 1202
 						<dd><strong>', $txt['draft_saved_on'], '</strong></dd>';
1143 1203
 
1144
-		foreach ($context['drafts'] as $draft)
1145
-			echo '
1204
+		foreach ($context['drafts'] as $draft) {
1205
+					echo '
1146 1206
 						<dt>', $draft['link'], '</dt>
1147 1207
 						<dd>', $draft['poster_time'], '</dd>';
1208
+		}
1148 1209
 		echo '
1149 1210
 					</dl>
1150 1211
 				</div>';
1151 1212
 	}
1152 1213
 
1153 1214
 	// Require an image to be typed to save spamming?
1154
-	if ($context['require_verification'])
1155
-		echo '
1215
+	if ($context['require_verification']) {
1216
+			echo '
1156 1217
 				<div class="post_verification">
1157 1218
 					<strong>', $txt['pm_visual_verification_label'], ':</strong>
1158 1219
 					', template_control_verification($context['visual_verification_id'], 'all'), '
1159 1220
 				</div>';
1221
+	}
1160 1222
 
1161 1223
 	// Send, Preview, spellcheck buttons.
1162 1224
 	echo '
@@ -1274,8 +1336,8 @@  discard block
 block discarded – undo
1274 1336
 			}';
1275 1337
 
1276 1338
 	// Code for showing and hiding drafts
1277
-	if (!empty($context['drafts']))
1278
-		echo '
1339
+	if (!empty($context['drafts'])) {
1340
+			echo '
1279 1341
 			var oSwapDraftOptions = new smc_Toggle({
1280 1342
 				bToggleEnabled: true,
1281 1343
 				bCurrentlyCollapsed: true,
@@ -1297,13 +1359,14 @@  discard block
 block discarded – undo
1297 1359
 					}
1298 1360
 				]
1299 1361
 			});';
1362
+	}
1300 1363
 
1301 1364
 	echo '
1302 1365
 		</script>';
1303 1366
 
1304 1367
 	// Show the message you're replying to.
1305
-	if ($context['reply'])
1306
-		echo '
1368
+	if ($context['reply']) {
1369
+			echo '
1307 1370
 		<br><br>
1308 1371
 		<div class="cat_bar">
1309 1372
 			<h3 class="catbg">', $txt['subject'], ': ', $context['quoted_message']['subject'], '</h3>
@@ -1317,6 +1380,7 @@  discard block
 block discarded – undo
1317 1380
 			', $context['quoted_message']['body'], '
1318 1381
 		</div>
1319 1382
 		<br class="clear">';
1383
+	}
1320 1384
 
1321 1385
 	echo '
1322 1386
 		<script>
@@ -1328,23 +1392,25 @@  discard block
 block discarded – undo
1328 1392
 				sToControlId: \'to_control\',
1329 1393
 				aToRecipients: [';
1330 1394
 
1331
-	foreach ($context['recipients']['to'] as $i => $member)
1332
-		echo '
1395
+	foreach ($context['recipients']['to'] as $i => $member) {
1396
+			echo '
1333 1397
 					{
1334 1398
 						sItemId: ', JavaScriptEscape($member['id']), ',
1335 1399
 						sItemName: ', JavaScriptEscape($member['name']), '
1336 1400
 					}', $i == count($context['recipients']['to']) - 1 ? '' : ',';
1401
+	}
1337 1402
 
1338 1403
 	echo '
1339 1404
 				],
1340 1405
 				aBccRecipients: [';
1341 1406
 
1342
-	foreach ($context['recipients']['bcc'] as $i => $member)
1343
-		echo '
1407
+	foreach ($context['recipients']['bcc'] as $i => $member) {
1408
+			echo '
1344 1409
 					{
1345 1410
 						sItemId: ', JavaScriptEscape($member['id']), ',
1346 1411
 						sItemName: ', JavaScriptEscape($member['name']), '
1347 1412
 					}', $i == count($context['recipients']['bcc']) - 1 ? '' : ',';
1413
+	}
1348 1414
 
1349 1415
 	echo '
1350 1416
 				],
@@ -1433,26 +1499,28 @@  discard block
 block discarded – undo
1433 1499
 					</th>
1434 1500
 					<th class="centertext table_icon">';
1435 1501
 
1436
-	if (count($context['labels']) > 2)
1437
-		echo '
1502
+	if (count($context['labels']) > 2) {
1503
+			echo '
1438 1504
 						<input type="checkbox" onclick="invertAll(this, this.form);">';
1505
+	}
1439 1506
 
1440 1507
 	echo '
1441 1508
 					</th>
1442 1509
 				</tr>
1443 1510
 			</thead>
1444 1511
 			<tbody>';
1445
-	if (count($context['labels']) < 2)
1446
-		echo '
1512
+	if (count($context['labels']) < 2) {
1513
+			echo '
1447 1514
 				<tr class="windowbg">
1448 1515
 					<td colspan="2">', $txt['pm_labels_no_exist'], '</td>
1449 1516
 				</tr>';
1450
-	else
1517
+	} else
1451 1518
 	{
1452 1519
 		foreach ($context['labels'] as $label)
1453 1520
 		{
1454
-			if ($label['id'] == -1)
1455
-				continue;
1521
+			if ($label['id'] == -1) {
1522
+							continue;
1523
+			}
1456 1524
 
1457 1525
 				echo '
1458 1526
 				<tr class="windowbg">
@@ -1467,12 +1535,13 @@  discard block
 block discarded – undo
1467 1535
 			</tbody>
1468 1536
 		</table>';
1469 1537
 
1470
-	if (!count($context['labels']) < 2)
1471
-		echo '
1538
+	if (!count($context['labels']) < 2) {
1539
+			echo '
1472 1540
 		<div class="block righttext">
1473 1541
 			<input type="submit" name="save" value="', $txt['save'], '" class="button">
1474 1542
 			<input type="submit" name="delete" value="', $txt['quickmod_delete_selected'], '" data-confirm="', $txt['pm_labels_delete'] ,'" class="button you_sure">
1475 1543
 		</div>';
1544
+	}
1476 1545
 
1477 1546
 	echo '
1478 1547
 		<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -1528,9 +1597,10 @@  discard block
 block discarded – undo
1528 1597
 					<select name="id_admin">
1529 1598
 						<option value="0">', $txt['pm_report_all_admins'], '</option>';
1530 1599
 
1531
-		foreach ($context['admins'] as $id => $name)
1532
-			echo '
1600
+		foreach ($context['admins'] as $id => $name) {
1601
+					echo '
1533 1602
 						<option value="', $id, '">', $name, '</option>';
1603
+		}
1534 1604
 
1535 1605
 		echo '
1536 1606
 					</select>
@@ -1593,9 +1663,10 @@  discard block
 block discarded – undo
1593 1663
 					</th>
1594 1664
 					<th class="centertext table_icon">';
1595 1665
 
1596
-	if (!empty($context['rules']))
1597
-		echo '
1666
+	if (!empty($context['rules'])) {
1667
+			echo '
1598 1668
 						<input type="checkbox" onclick="invertAll(this, this.form);">';
1669
+	}
1599 1670
 
1600 1671
 	echo '
1601 1672
 					</th>
@@ -1603,16 +1674,17 @@  discard block
 block discarded – undo
1603 1674
 			</thead>
1604 1675
 			<tbody>';
1605 1676
 
1606
-	if (empty($context['rules']))
1607
-		echo '
1677
+	if (empty($context['rules'])) {
1678
+			echo '
1608 1679
 				<tr class="windowbg">
1609 1680
 					<td colspan="2">
1610 1681
 						', $txt['pm_rules_none'], '
1611 1682
 					</td>
1612 1683
 				</tr>';
1684
+	}
1613 1685
 
1614
-	foreach ($context['rules'] as $rule)
1615
-		echo '
1686
+	foreach ($context['rules'] as $rule) {
1687
+			echo '
1616 1688
 				<tr class="windowbg">
1617 1689
 					<td>
1618 1690
 						<a href="', $scripturl, '?action=pm;sa=manrules;add;rid=', $rule['id'], '">', $rule['name'], '</a>
@@ -1621,6 +1693,7 @@  discard block
 block discarded – undo
1621 1693
 						<input type="checkbox" name="delrule[', $rule['id'], ']">
1622 1694
 					</td>
1623 1695
 				</tr>';
1696
+	}
1624 1697
 
1625 1698
 	echo '
1626 1699
 			</tbody>
@@ -1628,14 +1701,16 @@  discard block
 block discarded – undo
1628 1701
 		<div class="righttext">
1629 1702
 			<a class="button" href="', $scripturl, '?action=pm;sa=manrules;add;rid=0">', $txt['pm_add_rule'], '</a>';
1630 1703
 
1631
-	if (!empty($context['rules']))
1632
-		echo '
1704
+	if (!empty($context['rules'])) {
1705
+			echo '
1633 1706
 			[<a href="', $scripturl, '?action=pm;sa=manrules;apply;', $context['session_var'], '=', $context['session_id'], '" onclick="return confirm(\'', $txt['pm_js_apply_rules_confirm'], '\');">', $txt['pm_apply_rules'], '</a>]';
1707
+	}
1634 1708
 
1635
-	if (!empty($context['rules']))
1636
-		echo '
1709
+	if (!empty($context['rules'])) {
1710
+			echo '
1637 1711
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1638 1712
 			<input type="submit" name="delselected" value="', $txt['pm_delete_selected_rule'], '" data-confirm="', $txt['pm_js_delete_rule_confirm'] ,'" class="button smalltext you_sure">';
1713
+	}
1639 1714
 
1640 1715
 	echo '
1641 1716
 		</div>
@@ -1657,14 +1732,16 @@  discard block
 block discarded – undo
1657 1732
 		var groups = new Array()
1658 1733
 		var labels = new Array()';
1659 1734
 
1660
-	foreach ($context['groups'] as $id => $title)
1661
-		echo '
1735
+	foreach ($context['groups'] as $id => $title) {
1736
+			echo '
1662 1737
 		groups[', $id, '] = "', addslashes($title), '";';
1738
+	}
1663 1739
 
1664
-	foreach ($context['labels'] as $label)
1665
-		if ($label['id'] != -1)
1740
+	foreach ($context['labels'] as $label) {
1741
+			if ($label['id'] != -1)
1666 1742
 			echo '
1667 1743
 		labels[', ($label['id']), '] = "', addslashes($label['name']), '";';
1744
+	}
1668 1745
 
1669 1746
 	echo '
1670 1747
 		function addCriteriaOption()
@@ -1679,8 +1756,9 @@  discard block
 block discarded – undo
1679 1756
 
1680 1757
 			setOuterHTML(document.getElementById("criteriaAddHere"), \'<br><select name="ruletype[\' + criteriaNum + \']" id="ruletype\' + criteriaNum + \'" onchange="updateRuleDef(\' + criteriaNum + \'); rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_criteria_pick']), ':<\' + \'/option><option value="mid">', addslashes($txt['pm_rule_mid']), '<\' + \'/option><option value="gid">', addslashes($txt['pm_rule_gid']), '<\' + \'/option><option value="sub">', addslashes($txt['pm_rule_sub']), '<\' + \'/option><option value="msg">', addslashes($txt['pm_rule_msg']), '<\' + \'/option><option value="bud">', addslashes($txt['pm_rule_bud']), '<\' + \'/option><\' + \'/select>&nbsp;<span id="defdiv\' + criteriaNum + \'" style="display: none;"><input type="text" name="ruledef[\' + criteriaNum + \']" id="ruledef\' + criteriaNum + \'" onkeyup="rebuildRuleDesc();" value=""><\' + \'/span><span id="defseldiv\' + criteriaNum + \'" style="display: none;"><select name="ruledefgroup[\' + criteriaNum + \']" id="ruledefgroup\' + criteriaNum + \'" onchange="rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_sel_group']), '<\' + \'/option>';
1681 1758
 
1682
-	foreach ($context['groups'] as $id => $group)
1683
-		echo '<option value="', $id, '">', strtr($group, array("'" => "\'")), '<\' + \'/option>';
1759
+	foreach ($context['groups'] as $id => $group) {
1760
+			echo '<option value="', $id, '">', strtr($group, array("'" => "\'")), '<\' + \'/option>';
1761
+	}
1684 1762
 
1685 1763
 	echo '<\' + \'/select><\' + \'/span><span id="criteriaAddHere"><\' + \'/span>\');
1686 1764
 			}
@@ -1697,9 +1775,10 @@  discard block
 block discarded – undo
1697 1775
 
1698 1776
 				setOuterHTML(document.getElementById("actionAddHere"), \'<br><select name="acttype[\' + actionNum + \']" id="acttype\' + actionNum + \'" onchange="updateActionDef(\' + actionNum + \'); rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_sel_action']), ':<\' + \'/option><option value="lab">', addslashes($txt['pm_rule_label']), '<\' + \'/option><option value="del">', addslashes($txt['pm_rule_delete']), '<\' + \'/option><\' + \'/select>&nbsp;<span id="labdiv\' + actionNum + \'" style="display: none;"><select name="labdef[\' + actionNum + \']" id="labdef\' + actionNum + \'" onchange="rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_sel_label']), '<\' + \'/option>';
1699 1777
 
1700
-	foreach ($context['labels'] as $label)
1701
-		if ($label['id'] != -1)
1778
+	foreach ($context['labels'] as $label) {
1779
+			if ($label['id'] != -1)
1702 1780
 			echo '<option value="', ($label['id']), '">', addslashes($label['name']), '<\' + \'/option>';
1781
+	}
1703 1782
 
1704 1783
 	echo '<\' + \'/select><\' + \'/span><span id="actionAddHere"><\' + \'/span>\');
1705 1784
 			}
@@ -1813,19 +1892,20 @@  discard block
 block discarded – undo
1813 1892
 	$isFirst = true;
1814 1893
 	foreach ($context['rule']['criteria'] as $k => $criteria)
1815 1894
 	{
1816
-		if (!$isFirst && $criteria['t'] == '')
1817
-			echo '<div id="removeonjs1">';
1818
-
1819
-		elseif (!$isFirst)
1820
-			echo '<br>';
1895
+		if (!$isFirst && $criteria['t'] == '') {
1896
+					echo '<div id="removeonjs1">';
1897
+		} elseif (!$isFirst) {
1898
+					echo '<br>';
1899
+		}
1821 1900
 
1822 1901
 		echo '
1823 1902
 				<select name="ruletype[', $k, ']" id="ruletype', $k, '" onchange="updateRuleDef(', $k, '); rebuildRuleDesc();">
1824 1903
 					<option value="">', $txt['pm_rule_criteria_pick'], ':</option>';
1825 1904
 
1826
-		foreach (array('mid', 'gid', 'sub', 'msg', 'bud') as $cr)
1827
-			echo '
1905
+		foreach (array('mid', 'gid', 'sub', 'msg', 'bud') as $cr) {
1906
+					echo '
1828 1907
 					<option value="', $cr, '"', $criteria['t'] == $cr ? ' selected' : '', '>', $txt['pm_rule_' . $cr], '</option>';
1908
+		}
1829 1909
 
1830 1910
 		echo '
1831 1911
 				</select>
@@ -1836,19 +1916,20 @@  discard block
 block discarded – undo
1836 1916
 					<select name="ruledefgroup[', $k, ']" id="ruledefgroup', $k, '" onchange="rebuildRuleDesc();">
1837 1917
 						<option value="">', $txt['pm_rule_sel_group'], '</option>';
1838 1918
 
1839
-		foreach ($context['groups'] as $id => $group)
1840
-			echo '
1919
+		foreach ($context['groups'] as $id => $group) {
1920
+					echo '
1841 1921
 						<option value="', $id, '"', $criteria['t'] == 'gid' && $criteria['v'] == $id ? ' selected' : '', '>', $group, '</option>';
1922
+		}
1842 1923
 		echo '
1843 1924
 					</select>
1844 1925
 				</span>';
1845 1926
 
1846 1927
 		// If this is the dummy we add a means to hide for non js users.
1847
-		if ($isFirst)
1848
-			$isFirst = false;
1849
-
1850
-		elseif ($criteria['t'] == '')
1851
-			echo '</div><!-- .removeonjs1 -->';
1928
+		if ($isFirst) {
1929
+					$isFirst = false;
1930
+		} elseif ($criteria['t'] == '') {
1931
+					echo '</div><!-- .removeonjs1 -->';
1932
+		}
1852 1933
 	}
1853 1934
 
1854 1935
 	echo '
@@ -1871,10 +1952,11 @@  discard block
 block discarded – undo
1871 1952
 	$isFirst = true;
1872 1953
 	foreach ($context['rule']['actions'] as $k => $action)
1873 1954
 	{
1874
-		if (!$isFirst && $action['t'] == '')
1875
-			echo '<div id="removeonjs2">';
1876
-		elseif (!$isFirst)
1877
-			echo '<br>';
1955
+		if (!$isFirst && $action['t'] == '') {
1956
+					echo '<div id="removeonjs2">';
1957
+		} elseif (!$isFirst) {
1958
+					echo '<br>';
1959
+		}
1878 1960
 
1879 1961
 		echo '
1880 1962
 				<select name="acttype[', $k, ']" id="acttype', $k, '" onchange="updateActionDef(', $k, '); rebuildRuleDesc();">
@@ -1886,20 +1968,21 @@  discard block
 block discarded – undo
1886 1968
 					<select name="labdef[', $k, ']" id="labdef', $k, '" onchange="rebuildRuleDesc();">
1887 1969
 						<option value="">', $txt['pm_rule_sel_label'], '</option>';
1888 1970
 
1889
-		foreach ($context['labels'] as $label)
1890
-			if ($label['id'] != -1)
1971
+		foreach ($context['labels'] as $label) {
1972
+					if ($label['id'] != -1)
1891 1973
 				echo '
1892 1974
 						<option value="', ($label['id']), '"', $action['t'] == 'lab' && $action['v'] == $label['id'] ? ' selected' : '', '>', $label['name'], '</option>';
1975
+		}
1893 1976
 
1894 1977
 		echo '
1895 1978
 					</select>
1896 1979
 				</span>';
1897 1980
 
1898
-		if ($isFirst)
1899
-			$isFirst = false;
1900
-
1901
-		elseif ($action['t'] == '')
1902
-			echo '</div><!-- .removeonjs2 -->';
1981
+		if ($isFirst) {
1982
+					$isFirst = false;
1983
+		} elseif ($action['t'] == '') {
1984
+					echo '</div><!-- .removeonjs2 -->';
1985
+		}
1903 1986
 	}
1904 1987
 
1905 1988
 	echo '
@@ -1923,22 +2006,25 @@  discard block
 block discarded – undo
1923 2006
 		echo '
1924 2007
 	<script>';
1925 2008
 
1926
-	foreach ($context['rule']['criteria'] as $k => $c)
1927
-		echo '
2009
+	foreach ($context['rule']['criteria'] as $k => $c) {
2010
+			echo '
1928 2011
 			updateRuleDef(', $k, ');';
2012
+	}
1929 2013
 
1930
-	foreach ($context['rule']['actions'] as $k => $c)
1931
-		echo '
2014
+	foreach ($context['rule']['actions'] as $k => $c) {
2015
+			echo '
1932 2016
 			updateActionDef(', $k, ');';
2017
+	}
1933 2018
 
1934 2019
 	echo '
1935 2020
 			rebuildRuleDesc();';
1936 2021
 
1937 2022
 	// If this isn't a new rule and we have JS enabled remove the JS compatibility stuff.
1938
-	if ($context['rid'])
1939
-		echo '
2023
+	if ($context['rid']) {
2024
+			echo '
1940 2025
 			document.getElementById("removeonjs1").style.display = "none";
1941 2026
 			document.getElementById("removeonjs2").style.display = "none";';
2027
+	}
1942 2028
 
1943 2029
 	echo '
1944 2030
 			document.getElementById("addonjs1").style.display = "";
@@ -1966,12 +2052,12 @@  discard block
 block discarded – undo
1966 2052
 		</div>';
1967 2053
 
1968 2054
 	// No drafts? Just show an informative message.
1969
-	if (empty($context['drafts']))
1970
-		echo '
2055
+	if (empty($context['drafts'])) {
2056
+			echo '
1971 2057
 		<div class="windowbg centertext">
1972 2058
 			', $txt['draft_none'], '
1973 2059
 		</div>';
1974
-	else
2060
+	} else
1975 2061
 	{
1976 2062
 		// For every draft to be displayed, give it its own div, and show the important details of the draft.
1977 2063
 		foreach ($context['drafts'] as $draft)
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 
231 231
 				foreach ($message['custom_fields']['above_member'] as $custom)
232 232
 					echo '
233
-							<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
233
+							<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
234 234
 
235 235
 				echo '
236 236
 						</ul>
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 			if (!empty($message['custom_fields']['below_avatar']))
280 280
 				foreach ($message['custom_fields']['below_avatar'] as $custom)
281 281
 					echo '
282
-						<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
282
+						<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
283 283
 
284 284
 			if (!$message['member']['is_guest'])
285 285
 				echo '
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 
322 322
 					foreach ($message['custom_fields']['icons'] as $custom)
323 323
 						echo '
324
-								<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
324
+								<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
325 325
 
326 326
 					echo '
327 327
 							</ol>
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 				if (!empty($message['custom_fields']['standard']))
386 386
 					foreach ($message['custom_fields']['standard'] as $custom)
387 387
 						echo '
388
-						<li class="custom ', $custom['col_name'] ,'">', $custom['title'], ': ', $custom['value'], '</li>';
388
+						<li class="custom ', $custom['col_name'], '">', $custom['title'], ': ', $custom['value'], '</li>';
389 389
 
390 390
 				// Are we showing the warning status?
391 391
 				if ($message['member']['can_see_warning'])
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 				if (!empty($message['custom_fields']['bottom_poster']))
397 397
 					foreach ($message['custom_fields']['bottom_poster'] as $custom)
398 398
 						echo '
399
-						<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
399
+						<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
400 400
 			}
401 401
 
402 402
 			// Done with the information about the poster... on to the post itself.
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
 
498 498
 				foreach ($message['custom_fields']['above_signature'] as $custom)
499 499
 					echo '
500
-								<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
500
+								<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
501 501
 
502 502
 				echo '
503 503
 							</ul>
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
 
521 521
 				foreach ($message['custom_fields']['below_signature'] as $custom)
522 522
 					echo '
523
-								<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
523
+								<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
524 524
 
525 525
 				echo '
526 526
 							</ul>
@@ -656,7 +656,7 @@  discard block
 block discarded – undo
656 656
 	while ($message = $context['get_pmessage']('subject'))
657 657
 	{
658 658
 		echo '
659
-			<tr class="windowbg', $message['is_unread'] ? ' unread_pm' : '','">
659
+			<tr class="windowbg', $message['is_unread'] ? ' unread_pm' : '', '">
660 660
 				<td class="table_icon pm_icon">
661 661
 					<script>
662 662
 						currentLabels[', $message['id'], '] = {';
@@ -680,7 +680,7 @@  discard block
 block discarded – undo
680 680
 				<td class="pm_time">', $message['time'], '</td>
681 681
 				<td class="pm_subject">
682 682
 					', ($context['display_mode'] != 0 && $context['current_pm'] == $message['id'] ? '<img src="' . $settings['images_url'] . '/selected.png" alt="*">' : ''), '<a href="', ($context['display_mode'] == 0 || $context['current_pm'] == $message['id'] ? '' : ($scripturl . '?action=pm;pmid=' . $message['id'] . ';kstart;f=' . $context['folder'] . ';start=' . $context['start'] . ';sort=' . $context['sort_by'] . ($context['sort_direction'] == 'up' ? ';' : ';desc') . ($context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : ''))), '#msg', $message['id'], '">', $message['subject'], $message['is_unread'] ? '&nbsp;<span class="new_posts">' . $txt['new'] . '</span>' : '', '</a>
683
-					<span class="pm_inline_time"><span class="generic_icons ', ($context['from_or_to']=='to' && count($message['recipients']['to'])>1) ? 'people' : 'members', '"></span> ', ($context['from_or_to'] == 'from' ? $message['member']['link'] : (empty($message['recipients']['to']) ? '' : implode(', ', $message['recipients']['to']))), '  <span class="generic_icons time_online"></span> ', $message['time'], '</span>
683
+					<span class="pm_inline_time"><span class="generic_icons ', ($context['from_or_to'] == 'to' && count($message['recipients']['to']) > 1) ? 'people' : 'members', '"></span> ', ($context['from_or_to'] == 'from' ? $message['member']['link'] : (empty($message['recipients']['to']) ? '' : implode(', ', $message['recipients']['to']))), '  <span class="generic_icons time_online"></span> ', $message['time'], '</span>
684 684
 				</td>
685 685
 				<td class="pm_from_to">
686 686
 					', ($context['from_or_to'] == 'from' ? $message['member']['link'] : (empty($message['recipients']['to']) ? '' : implode(', ', $message['recipients']['to']))), '
@@ -957,13 +957,13 @@  discard block
 block discarded – undo
957 957
 				// You can only reply if they are not a guest...
958 958
 				if (!$message['member']['is_guest'])
959 959
 					echo '
960
-					<a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote;u=', $context['folder'] == 'sent' ? '' : $message['member']['id'], '">', $quote_button , '</a>', $context['menu_separator'], '
961
-					<a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';u=', $message['member']['id'], '">', $reply_button , '</a> ', $context['menu_separator'];
960
+					<a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote;u=', $context['folder'] == 'sent' ? '' : $message['member']['id'], '">', $quote_button, '</a>', $context['menu_separator'], '
961
+					<a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';u=', $message['member']['id'], '">', $reply_button, '</a> ', $context['menu_separator'];
962 962
 
963 963
 				// This is for "forwarding" - even if the member is gone.
964 964
 				else
965 965
 					echo '
966
-					<a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote">', $quote_button , '</a>', $context['menu_separator'];
966
+					<a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote">', $quote_button, '</a>', $context['menu_separator'];
967 967
 			}
968 968
 
969 969
 			echo '
@@ -1063,7 +1063,7 @@  discard block
 block discarded – undo
1063 1063
 				<div class="', empty($context['error_type']) || $context['error_type'] != 'serious' ? 'noticebox' : 'errorbox', '"', empty($context['post_error']['messages']) ? ' style="display: none"' : '', ' id="errors">
1064 1064
 					<dl>
1065 1065
 						<dt>
1066
-							<strong id="error_serious">', $txt['error_while_submitting'] , '</strong>
1066
+							<strong id="error_serious">', $txt['error_while_submitting'], '</strong>
1067 1067
 						</dt>
1068 1068
 						<dd class="error" id="error_list">
1069 1069
 							', empty($context['post_error']['messages']) ? '' : implode('<br>', $context['post_error']['messages']), '
@@ -1119,7 +1119,7 @@  discard block
 block discarded – undo
1119 1119
 						<span', (isset($context['post_error']['no_subject']) ? ' class="error"' : ''), ' id="caption_subject">', $txt['subject'], ':</span>
1120 1120
 					</dt>
1121 1121
 					<dd id="pm_subject">
1122
-						<input type="text" name="subject" value="', $context['subject'], '" tabindex="', $context['tabindex']++, '" size="80" maxlength="80"',isset($context['post_error']['no_subject']) ? ' class="error"' : '', '>
1122
+						<input type="text" name="subject" value="', $context['subject'], '" tabindex="', $context['tabindex']++, '" size="80" maxlength="80"', isset($context['post_error']['no_subject']) ? ' class="error"' : '', '>
1123 1123
 					</dd>
1124 1124
 				</dl>';
1125 1125
 
@@ -1472,7 +1472,7 @@  discard block
 block discarded – undo
1472 1472
 		echo '
1473 1473
 		<div class="block righttext">
1474 1474
 			<input type="submit" name="save" value="', $txt['save'], '" class="button">
1475
-			<input type="submit" name="delete" value="', $txt['quickmod_delete_selected'], '" data-confirm="', $txt['pm_labels_delete'] ,'" class="button you_sure">
1475
+			<input type="submit" name="delete" value="', $txt['quickmod_delete_selected'], '" data-confirm="', $txt['pm_labels_delete'], '" class="button you_sure">
1476 1476
 		</div>';
1477 1477
 
1478 1478
 	echo '
@@ -1636,7 +1636,7 @@  discard block
 block discarded – undo
1636 1636
 	if (!empty($context['rules']))
1637 1637
 		echo '
1638 1638
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1639
-			<input type="submit" name="delselected" value="', $txt['pm_delete_selected_rule'], '" data-confirm="', $txt['pm_js_delete_rule_confirm'] ,'" class="button smalltext you_sure">';
1639
+			<input type="submit" name="delselected" value="', $txt['pm_delete_selected_rule'], '" data-confirm="', $txt['pm_js_delete_rule_confirm'], '" class="button smalltext you_sure">';
1640 1640
 
1641 1641
 	echo '
1642 1642
 		</div>
@@ -1879,9 +1879,9 @@  discard block
 block discarded – undo
1879 1879
 
1880 1880
 		echo '
1881 1881
 				<select name="acttype[', $k, ']" id="acttype', $k, '" onchange="updateActionDef(', $k, '); rebuildRuleDesc();">
1882
-					<option value="">', $txt['pm_rule_sel_action'] , ':</option>
1883
-					<option value="lab"', $action['t'] == 'lab' ? ' selected' : '', '>', $txt['pm_rule_label'] , '</option>
1884
-					<option value="del"', $action['t'] == 'del' ? ' selected' : '', '>', $txt['pm_rule_delete'] , '</option>
1882
+					<option value="">', $txt['pm_rule_sel_action'], ':</option>
1883
+					<option value="lab"', $action['t'] == 'lab' ? ' selected' : '', '>', $txt['pm_rule_label'], '</option>
1884
+					<option value="del"', $action['t'] == 'del' ? ' selected' : '', '>', $txt['pm_rule_delete'], '</option>
1885 1885
 				</select>
1886 1886
 				<span id="labdiv', $k, '">
1887 1887
 					<select name="labdef[', $k, ']" id="labdef', $k, '" onchange="rebuildRuleDesc();">
@@ -1993,7 +1993,7 @@  discard block
 block discarded – undo
1993 1993
 			</div>
1994 1994
 			<ul class="quickbuttons">
1995 1995
 				<li><a href="', $scripturl, '?action=pm;sa=showpmdrafts;id_draft=', $draft['id_draft'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons modifybutton"></span>', $txt['draft_edit'], '</a></li>
1996
-				<li><a href="', $scripturl, '?action=pm;sa=showpmdrafts;delete=', $draft['id_draft'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['draft_remove'] ,'?" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['draft_delete'], '</a></li>
1996
+				<li><a href="', $scripturl, '?action=pm;sa=showpmdrafts;delete=', $draft['id_draft'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['draft_remove'], '?" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['draft_delete'], '</a></li>
1997 1997
 			</ul>
1998 1998
 		</div><!-- .windowbg -->';
1999 1999
 		}
Please login to merge, or discard this patch.
Sources/Notify.php 1 patch
Braces   +20 added lines, -18 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
  * Turn off/on notification for a particular board.
@@ -34,8 +35,9 @@  discard block
 block discarded – undo
34 35
 	is_not_guest();
35 36
 
36 37
 	// You have to specify a board to turn notifications on!
37
-	if (empty($board))
38
-		fatal_lang_error('no_board', false);
38
+	if (empty($board)) {
39
+			fatal_lang_error('no_board', false);
40
+	}
39 41
 
40 42
 	// No subaction: find out what to do.
41 43
 	if (isset($_GET['mode']))
@@ -48,16 +50,16 @@  discard block
 block discarded – undo
48 50
 		require_once($sourcedir . '/Subs-Notify.php');
49 51
 		setNotifyPrefs($user_info['id'], array('board_notify_' . $board => $alertPref));
50 52
 
51
-		if ($mode > 1)
52
-			// Turn notification on.  (note this just blows smoke if it's already on.)
53
+		if ($mode > 1) {
54
+					// Turn notification on.  (note this just blows smoke if it's already on.)
53 55
 			$smcFunc['db_insert']('ignore',
54 56
 				'{db_prefix}log_notify',
55 57
 				array('id_member' => 'int', 'id_board' => 'int'),
56 58
 				array($user_info['id'], $board),
57 59
 				array('id_member', 'id_board')
58 60
 			);
59
-		else
60
-			$smcFunc['db_query']('', '
61
+		} else {
62
+					$smcFunc['db_query']('', '
61 63
 				DELETE FROM {db_prefix}log_notify
62 64
 				WHERE id_member = {int:current_member}
63 65
 				AND id_board = {int:current_board}',
@@ -66,6 +68,7 @@  discard block
 block discarded – undo
66 68
 					'current_member' => $user_info['id'],
67 69
 				)
68 70
 			);
71
+		}
69 72
 	}
70 73
 
71 74
 	// Back to the board!
@@ -80,10 +83,10 @@  discard block
 block discarded – undo
80 83
 			),
81 84
 		);
82 85
 		$context['sub_template'] = 'generic_xml';
86
+	} else {
87
+			redirectexit('board=' . $board . '.' . $_REQUEST['start']);
88
+	}
83 89
 	}
84
-	else
85
-		redirectexit('board=' . $board . '.' . $_REQUEST['start']);
86
-}
87 90
 
88 91
 /**
89 92
  * Turn off/on unread replies subscription for a topic as well as sets individual topic's alert preferences
@@ -128,8 +131,7 @@  discard block
 block discarded – undo
128 131
 					'id_msg' => 0,
129 132
 					'unwatched' => empty($mode) ? 1 : 0,
130 133
 				);
131
-			}
132
-			else
134
+			} else
133 135
 			{
134 136
 				$insert = false;
135 137
 				$log['unwatched'] = empty($mode) ? 1 : 0;
@@ -156,9 +158,8 @@  discard block
 block discarded – undo
156 158
 					array($user_info['id'], $log['id_topic']),
157 159
 					array('id_member', 'id_board')
158 160
 				);
159
-			}
160
-			else
161
-				$smcFunc['db_query']('', '
161
+			} else {
162
+							$smcFunc['db_query']('', '
162 163
 					DELETE FROM {db_prefix}log_notify
163 164
 					WHERE id_topic = {int:topic}
164 165
 						AND id_member = {int:member}',
@@ -166,6 +167,7 @@  discard block
 block discarded – undo
166 167
 						'topic' => $log['id_topic'],
167 168
 						'member' => $user_info['id'],
168 169
 					));
170
+			}
169 171
 		}
170 172
 	}
171 173
 
@@ -181,9 +183,9 @@  discard block
 block discarded – undo
181 183
 			),
182 184
 		);
183 185
 		$context['sub_template'] = 'generic_xml';
186
+	} else {
187
+			redirectexit('topic=' . $topic . '.' . $_REQUEST['start']);
188
+	}
184 189
 	}
185
-	else
186
-		redirectexit('topic=' . $topic . '.' . $_REQUEST['start']);
187
-}
188 190
 
189 191
 ?>
190 192
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/Subs-Editor.php 1 patch
Braces   +403 added lines, -303 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 4
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * !!!Compatibility!!!
@@ -31,8 +32,9 @@  discard block
 block discarded – undo
31 32
 {
32 33
 	global $modSettings;
33 34
 
34
-	if (!$compat_mode)
35
-		return $text;
35
+	if (!$compat_mode) {
36
+			return $text;
37
+	}
36 38
 
37 39
 	// Turn line breaks back into br's.
38 40
 	$text = strtr($text, array("\r" => '', "\n" => '<br>'));
@@ -49,8 +51,9 @@  discard block
 block discarded – undo
49 51
 			for ($i = 0, $n = count($parts); $i < $n; $i++)
50 52
 			{
51 53
 				// Value of 2 means we're inside the tag.
52
-				if ($i % 4 == 2)
53
-					$parts[$i] = strtr($parts[$i], array('[' => '&#91;', ']' => '&#93;', "'" => "'"));
54
+				if ($i % 4 == 2) {
55
+									$parts[$i] = strtr($parts[$i], array('[' => '&#91;', ']' => '&#93;', "'" => "'"));
56
+				}
54 57
 			}
55 58
 			// Put our humpty dumpty message back together again.
56 59
 			$text = implode('', $parts);
@@ -109,8 +112,9 @@  discard block
 block discarded – undo
109 112
 	$text = preg_replace('~</p>\s*(?!<)~i', '</p><br>', $text);
110 113
 
111 114
 	// Safari/webkit wraps lines in Wysiwyg in <div>'s.
112
-	if (isBrowser('webkit'))
113
-		$text = preg_replace(array('~<div(?:\s(?:[^<>]*?))?' . '>~i', '</div>'), array('<br>', ''), $text);
115
+	if (isBrowser('webkit')) {
116
+			$text = preg_replace(array('~<div(?:\s(?:[^<>]*?))?' . '>~i', '</div>'), array('<br>', ''), $text);
117
+	}
114 118
 
115 119
 	// If there's a trailing break get rid of it - Firefox tends to add one.
116 120
 	$text = preg_replace('~<br\s?/?' . '>$~i', '', $text);
@@ -125,8 +129,9 @@  discard block
 block discarded – undo
125 129
 		for ($i = 0, $n = count($parts); $i < $n; $i++)
126 130
 		{
127 131
 			// Value of 2 means we're inside the tag.
128
-			if ($i % 4 == 2)
129
-				$parts[$i] = strip_tags($parts[$i]);
132
+			if ($i % 4 == 2) {
133
+							$parts[$i] = strip_tags($parts[$i]);
134
+			}
130 135
 		}
131 136
 
132 137
 		$text = strtr(implode('', $parts), array('#smf_br_spec_grudge_cool!#' => '<br>'));
@@ -152,18 +157,19 @@  discard block
 block discarded – undo
152 157
 			{
153 158
 				$found = array_search($file, $smileysto);
154 159
 				// Note the weirdness here is to stop double spaces between smileys.
155
-				if ($found)
156
-					$matches[1][$k] = '-[]-smf_smily_start#|#' . $smcFunc['htmlspecialchars']($smileysfrom[$found]) . '-[]-smf_smily_end#|#';
157
-				else
158
-					$matches[1][$k] = '';
160
+				if ($found) {
161
+									$matches[1][$k] = '-[]-smf_smily_start#|#' . $smcFunc['htmlspecialchars']($smileysfrom[$found]) . '-[]-smf_smily_end#|#';
162
+				} else {
163
+									$matches[1][$k] = '';
164
+				}
159 165
 			}
160
-		}
161
-		else
166
+		} else
162 167
 		{
163 168
 			// Load all the smileys.
164 169
 			$names = array();
165
-			foreach ($matches[1] as $file)
166
-				$names[] = $file;
170
+			foreach ($matches[1] as $file) {
171
+							$names[] = $file;
172
+			}
167 173
 			$names = array_unique($names);
168 174
 
169 175
 			if (!empty($names))
@@ -177,13 +183,15 @@  discard block
 block discarded – undo
177 183
 					)
178 184
 				);
179 185
 				$mappings = array();
180
-				while ($row = $smcFunc['db_fetch_assoc']($request))
181
-					$mappings[$row['filename']] = $smcFunc['htmlspecialchars']($row['code']);
186
+				while ($row = $smcFunc['db_fetch_assoc']($request)) {
187
+									$mappings[$row['filename']] = $smcFunc['htmlspecialchars']($row['code']);
188
+				}
182 189
 				$smcFunc['db_free_result']($request);
183 190
 
184
-				foreach ($matches[1] as $k => $file)
185
-					if (isset($mappings[$file]))
191
+				foreach ($matches[1] as $k => $file) {
192
+									if (isset($mappings[$file]))
186 193
 						$matches[1][$k] = '-[]-smf_smily_start#|#' . $mappings[$file] . '-[]-smf_smily_end#|#';
194
+				}
187 195
 			}
188 196
 		}
189 197
 
@@ -195,8 +203,9 @@  discard block
 block discarded – undo
195 203
 	}
196 204
 
197 205
 	// Only try to buy more time if the client didn't quit.
198
-	if (connection_aborted() && $context['server']['is_apache'])
199
-		@apache_reset_timeout();
206
+	if (connection_aborted() && $context['server']['is_apache']) {
207
+			@apache_reset_timeout();
208
+	}
200 209
 
201 210
 	$parts = preg_split('~(<[A-Za-z]+\s*[^<>]*?style="?[^<>"]+"?[^<>]*?(?:/?)>|</[A-Za-z]+>)~', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
202 211
 	$replacement = '';
@@ -207,9 +216,9 @@  discard block
 block discarded – undo
207 216
 		if (preg_match('~(<([A-Za-z]+)\s*[^<>]*?)style="?([^<>"]+)"?([^<>]*?(/?)>)~', $part, $matches) === 1)
208 217
 		{
209 218
 			// If it's being closed instantly, we can't deal with it...yet.
210
-			if ($matches[5] === '/')
211
-				continue;
212
-			else
219
+			if ($matches[5] === '/') {
220
+							continue;
221
+			} else
213 222
 			{
214 223
 				// Get an array of styles that apply to this element. (The strtr is there to combat HTML generated by Word.)
215 224
 				$styles = explode(';', strtr($matches[3], array('&quot;' => '')));
@@ -225,8 +234,9 @@  discard block
 block discarded – undo
225 234
 					$clean_type_value_pair = strtolower(strtr(trim($type_value_pair), '=', ':'));
226 235
 
227 236
 					// Something like 'font-weight: bold' is expected here.
228
-					if (strpos($clean_type_value_pair, ':') === false)
229
-						continue;
237
+					if (strpos($clean_type_value_pair, ':') === false) {
238
+											continue;
239
+					}
230 240
 
231 241
 					// Capture the elements of a single style item (e.g. 'font-weight' and 'bold').
232 242
 					list ($style_type, $style_value) = explode(':', $type_value_pair);
@@ -248,8 +258,7 @@  discard block
 block discarded – undo
248 258
 							{
249 259
 								$curCloseTags .= '[/u]';
250 260
 								$replacement .= '[u]';
251
-							}
252
-							elseif ($style_value == 'line-through')
261
+							} elseif ($style_value == 'line-through')
253 262
 							{
254 263
 								$curCloseTags .= '[/s]';
255 264
 								$replacement .= '[s]';
@@ -261,13 +270,11 @@  discard block
 block discarded – undo
261 270
 							{
262 271
 								$curCloseTags .= '[/left]';
263 272
 								$replacement .= '[left]';
264
-							}
265
-							elseif ($style_value == 'center')
273
+							} elseif ($style_value == 'center')
266 274
 							{
267 275
 								$curCloseTags .= '[/center]';
268 276
 								$replacement .= '[center]';
269
-							}
270
-							elseif ($style_value == 'right')
277
+							} elseif ($style_value == 'right')
271 278
 							{
272 279
 								$curCloseTags .= '[/right]';
273 280
 								$replacement .= '[right]';
@@ -289,8 +296,9 @@  discard block
 block discarded – undo
289 296
 
290 297
 						case 'font-size':
291 298
 							// Sometimes people put decimals where decimals should not be.
292
-							if (preg_match('~(\d)+\.\d+(p[xt])~i', $style_value, $dec_matches) === 1)
293
-								$style_value = $dec_matches[1] . $dec_matches[2];
299
+							if (preg_match('~(\d)+\.\d+(p[xt])~i', $style_value, $dec_matches) === 1) {
300
+															$style_value = $dec_matches[1] . $dec_matches[2];
301
+							}
294 302
 
295 303
 							$curCloseTags .= '[/size]';
296 304
 							$replacement .= '[size=' . $style_value . ']';
@@ -298,8 +306,9 @@  discard block
 block discarded – undo
298 306
 
299 307
 						case 'font-family':
300 308
 							// Only get the first freaking font if there's a list!
301
-							if (strpos($style_value, ',') !== false)
302
-								$style_value = substr($style_value, 0, strpos($style_value, ','));
309
+							if (strpos($style_value, ',') !== false) {
310
+															$style_value = substr($style_value, 0, strpos($style_value, ','));
311
+							}
303 312
 
304 313
 							$curCloseTags .= '[/font]';
305 314
 							$replacement .= '[font=' . strtr($style_value, array("'" => '')) . ']';
@@ -308,13 +317,15 @@  discard block
 block discarded – undo
308 317
 						// This is a hack for images with dimensions embedded.
309 318
 						case 'width':
310 319
 						case 'height':
311
-							if (preg_match('~[1-9]\d*~i', $style_value, $dimension) === 1)
312
-								$extra_attr .= ' ' . $style_type . '="' . $dimension[0] . '"';
320
+							if (preg_match('~[1-9]\d*~i', $style_value, $dimension) === 1) {
321
+															$extra_attr .= ' ' . $style_type . '="' . $dimension[0] . '"';
322
+							}
313 323
 						break;
314 324
 
315 325
 						case 'list-style-type':
316
-							if (preg_match('~none|disc|circle|square|decimal|decimal-leading-zero|lower-roman|upper-roman|lower-alpha|upper-alpha|lower-greek|lower-latin|upper-latin|hebrew|armenian|georgian|cjk-ideographic|hiragana|katakana|hiragana-iroha|katakana-iroha~i', $style_value, $listType) === 1)
317
-								$extra_attr .= ' listtype="' . $listType[0] . '"';
326
+							if (preg_match('~none|disc|circle|square|decimal|decimal-leading-zero|lower-roman|upper-roman|lower-alpha|upper-alpha|lower-greek|lower-latin|upper-latin|hebrew|armenian|georgian|cjk-ideographic|hiragana|katakana|hiragana-iroha|katakana-iroha~i', $style_value, $listType) === 1) {
327
+															$extra_attr .= ' listtype="' . $listType[0] . '"';
328
+							}
318 329
 						break;
319 330
 					}
320 331
 				}
@@ -327,18 +338,17 @@  discard block
 block discarded – undo
327 338
 				}
328 339
 
329 340
 				// If there's something that still needs closing, push it to the stack.
330
-				if (!empty($curCloseTags))
331
-					array_push($stack, array(
341
+				if (!empty($curCloseTags)) {
342
+									array_push($stack, array(
332 343
 							'element' => strtolower($curElement),
333 344
 							'closeTags' => $curCloseTags
334 345
 						)
335 346
 					);
336
-				elseif (!empty($extra_attr))
337
-					$replacement .= $precedingStyle . $extra_attr . $afterStyle;
347
+				} elseif (!empty($extra_attr)) {
348
+									$replacement .= $precedingStyle . $extra_attr . $afterStyle;
349
+				}
338 350
 			}
339
-		}
340
-
341
-		elseif (preg_match('~</([A-Za-z]+)>~', $part, $matches) === 1)
351
+		} elseif (preg_match('~</([A-Za-z]+)>~', $part, $matches) === 1)
342 352
 		{
343 353
 			// Is this the element that we've been waiting for to be closed?
344 354
 			if (!empty($stack) && strtolower($matches[1]) === $stack[count($stack) - 1]['element'])
@@ -348,28 +358,32 @@  discard block
 block discarded – undo
348 358
 			}
349 359
 
350 360
 			// Must've been something else.
351
-			else
352
-				$replacement .= $part;
361
+			else {
362
+							$replacement .= $part;
363
+			}
353 364
 		}
354 365
 		// In all other cases, just add the part to the replacement.
355
-		else
356
-			$replacement .= $part;
366
+		else {
367
+					$replacement .= $part;
368
+		}
357 369
 	}
358 370
 
359 371
 	// Now put back the replacement in the text.
360 372
 	$text = $replacement;
361 373
 
362 374
 	// We are not finished yet, request more time.
363
-	if (connection_aborted() && $context['server']['is_apache'])
364
-		@apache_reset_timeout();
375
+	if (connection_aborted() && $context['server']['is_apache']) {
376
+			@apache_reset_timeout();
377
+	}
365 378
 
366 379
 	// Let's pull out any legacy alignments.
367 380
 	while (preg_match('~<([A-Za-z]+)\s+[^<>]*?(align="*(left|center|right)"*)[^<>]*?(/?)>~i', $text, $matches) === 1)
368 381
 	{
369 382
 		// Find the position in the text of this tag over again.
370 383
 		$start_pos = strpos($text, $matches[0]);
371
-		if ($start_pos === false)
372
-			break;
384
+		if ($start_pos === false) {
385
+					break;
386
+		}
373 387
 
374 388
 		// End tag?
375 389
 		if ($matches[4] != '/' && strpos($text, '</' . $matches[1] . '>', $start_pos) !== false)
@@ -383,8 +397,7 @@  discard block
 block discarded – undo
383 397
 
384 398
 			// Put the tags back into the body.
385 399
 			$text = substr($text, 0, $start_pos) . $tag . '[' . $matches[3] . ']' . $content . '[/' . $matches[3] . ']' . substr($text, $end_pos);
386
-		}
387
-		else
400
+		} else
388 401
 		{
389 402
 			// Just get rid of this evil tag.
390 403
 			$text = substr($text, 0, $start_pos) . substr($text, $start_pos + strlen($matches[0]));
@@ -397,8 +410,9 @@  discard block
 block discarded – undo
397 410
 		// Find the position of this again.
398 411
 		$start_pos = strpos($text, $matches[0]);
399 412
 		$end_pos = false;
400
-		if ($start_pos === false)
401
-			break;
413
+		if ($start_pos === false) {
414
+					break;
415
+		}
402 416
 
403 417
 		// This must have an end tag - and we must find the right one.
404 418
 		$lower_text = strtolower($text);
@@ -431,8 +445,9 @@  discard block
 block discarded – undo
431 445
 				break;
432 446
 			}
433 447
 		}
434
-		if ($end_pos === false)
435
-			break;
448
+		if ($end_pos === false) {
449
+					break;
450
+		}
436 451
 
437 452
 		// Now work out what the attributes are.
438 453
 		$attribs = fetchTagAttributes($matches[1]);
@@ -446,11 +461,11 @@  discard block
 block discarded – undo
446 461
 				$v = (int) trim($v);
447 462
 				$v = empty($v) ? 1 : $v;
448 463
 				$tags[] = array('[size=' . $sizes_equivalence[$v] . ']', '[/size]');
464
+			} elseif ($s == 'face') {
465
+							$tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]');
466
+			} elseif ($s == 'color') {
467
+							$tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]');
449 468
 			}
450
-			elseif ($s == 'face')
451
-				$tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]');
452
-			elseif ($s == 'color')
453
-				$tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]');
454 469
 		}
455 470
 
456 471
 		// As before add in our tags.
@@ -458,8 +473,9 @@  discard block
 block discarded – undo
458 473
 		foreach ($tags as $tag)
459 474
 		{
460 475
 			$before .= $tag[0];
461
-			if (isset($tag[1]))
462
-				$after = $tag[1] . $after;
476
+			if (isset($tag[1])) {
477
+							$after = $tag[1] . $after;
478
+			}
463 479
 		}
464 480
 
465 481
 		// Remove the tag so it's never checked again.
@@ -470,8 +486,9 @@  discard block
 block discarded – undo
470 486
 	}
471 487
 
472 488
 	// Almost there, just a little more time.
473
-	if (connection_aborted() && $context['server']['is_apache'])
474
-		@apache_reset_timeout();
489
+	if (connection_aborted() && $context['server']['is_apache']) {
490
+			@apache_reset_timeout();
491
+	}
475 492
 
476 493
 	if (count($parts = preg_split('~<(/?)(li|ol|ul)([^>]*)>~i', $text, null, PREG_SPLIT_DELIM_CAPTURE)) > 1)
477 494
 	{
@@ -527,12 +544,13 @@  discard block
 block discarded – undo
527 544
 						{
528 545
 							$inList = true;
529 546
 
530
-							if ($tag === 'ol')
531
-								$listType = 'decimal';
532
-							elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1)
533
-								$listType = $listTypeMapping[$match[1]];
534
-							else
535
-								$listType = null;
547
+							if ($tag === 'ol') {
548
+															$listType = 'decimal';
549
+							} elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1) {
550
+															$listType = $listTypeMapping[$match[1]];
551
+							} else {
552
+															$listType = null;
553
+							}
536 554
 
537 555
 							$listDepth++;
538 556
 
@@ -596,9 +614,7 @@  discard block
 block discarded – undo
596 614
 							$parts[$i + 1] = '';
597 615
 							$parts[$i + 2] = str_repeat("\t", $listDepth) . '[/list]';
598 616
 							$parts[$i + 3] = '';
599
-						}
600
-
601
-						else
617
+						} else
602 618
 						{
603 619
 							// We're in a list item.
604 620
 							if ($listDepth > 0)
@@ -635,9 +651,7 @@  discard block
 block discarded – undo
635 651
 							$parts[$i + 1] = '';
636 652
 							$parts[$i + 2] = '';
637 653
 							$parts[$i + 3] = '';
638
-						}
639
-
640
-						else
654
+						} else
641 655
 						{
642 656
 							// Remove the trailing breaks from the list item.
643 657
 							$parts[$i] = preg_replace('~\s*<br\s*' . '/?' . '>\s*$~', '', $parts[$i]);
@@ -675,8 +689,9 @@  discard block
 block discarded – undo
675 689
 			$text .= str_repeat("\t", $listDepth) . '[/list]';
676 690
 		}
677 691
 
678
-		for ($i = $listDepth; $i > 0; $i--)
679
-			$text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]';
692
+		for ($i = $listDepth; $i > 0; $i--) {
693
+					$text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]';
694
+		}
680 695
 	}
681 696
 
682 697
 	// I love my own image...
@@ -684,8 +699,9 @@  discard block
 block discarded – undo
684 699
 	{
685 700
 		// Find the position of the image.
686 701
 		$start_pos = strpos($text, $matches[0]);
687
-		if ($start_pos === false)
688
-			break;
702
+		if ($start_pos === false) {
703
+					break;
704
+		}
689 705
 		$end_pos = $start_pos + strlen($matches[0]);
690 706
 
691 707
 		$params = '';
@@ -694,12 +710,13 @@  discard block
 block discarded – undo
694 710
 		$attrs = fetchTagAttributes($matches[1]);
695 711
 		foreach ($attrs as $attrib => $value)
696 712
 		{
697
-			if (in_array($attrib, array('width', 'height')))
698
-				$params .= ' ' . $attrib . '=' . (int) $value;
699
-			elseif ($attrib == 'alt' && trim($value) != '')
700
-				$params .= ' alt=' . trim($value);
701
-			elseif ($attrib == 'src')
702
-				$src = trim($value);
713
+			if (in_array($attrib, array('width', 'height'))) {
714
+							$params .= ' ' . $attrib . '=' . (int) $value;
715
+			} elseif ($attrib == 'alt' && trim($value) != '') {
716
+							$params .= ' alt=' . trim($value);
717
+			} elseif ($attrib == 'src') {
718
+							$src = trim($value);
719
+			}
703 720
 		}
704 721
 
705 722
 		$tag = '';
@@ -710,10 +727,11 @@  discard block
 block discarded – undo
710 727
 			{
711 728
 				$baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']);
712 729
 
713
-				if (substr($src, 0, 1) === '/')
714
-					$src = $baseURL . $src;
715
-				else
716
-					$src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src;
730
+				if (substr($src, 0, 1) === '/') {
731
+									$src = $baseURL . $src;
732
+				} else {
733
+									$src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src;
734
+				}
717 735
 			}
718 736
 
719 737
 			$tag = '[img' . $params . ']' . $src . '[/img]';
@@ -891,20 +909,23 @@  discard block
 block discarded – undo
891 909
 		},
892 910
 	);
893 911
 
894
-	foreach ($tags as $tag => $replace)
895
-		$text = preg_replace_callback($tag, $replace, $text);
912
+	foreach ($tags as $tag => $replace) {
913
+			$text = preg_replace_callback($tag, $replace, $text);
914
+	}
896 915
 
897 916
 	// Please give us just a little more time.
898
-	if (connection_aborted() && $context['server']['is_apache'])
899
-		@apache_reset_timeout();
917
+	if (connection_aborted() && $context['server']['is_apache']) {
918
+			@apache_reset_timeout();
919
+	}
900 920
 
901 921
 	// What about URL's - the pain in the ass of the tag world.
902 922
 	while (preg_match('~<a\s+([^<>]*)>([^<>]*)</a>~i', $text, $matches) === 1)
903 923
 	{
904 924
 		// Find the position of the URL.
905 925
 		$start_pos = strpos($text, $matches[0]);
906
-		if ($start_pos === false)
907
-			break;
926
+		if ($start_pos === false) {
927
+					break;
928
+		}
908 929
 		$end_pos = $start_pos + strlen($matches[0]);
909 930
 
910 931
 		$tag_type = 'url';
@@ -918,8 +939,9 @@  discard block
 block discarded – undo
918 939
 				$href = trim($value);
919 940
 
920 941
 				// Are we dealing with an FTP link?
921
-				if (preg_match('~^ftps?://~', $href) === 1)
922
-					$tag_type = 'ftp';
942
+				if (preg_match('~^ftps?://~', $href) === 1) {
943
+									$tag_type = 'ftp';
944
+				}
923 945
 
924 946
 				// Or is this a link to an email address?
925 947
 				elseif (substr($href, 0, 7) == 'mailto:')
@@ -933,28 +955,31 @@  discard block
 block discarded – undo
933 955
 				{
934 956
 					$baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']);
935 957
 
936
-					if (substr($href, 0, 1) === '/')
937
-						$href = $baseURL . $href;
938
-					else
939
-						$href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href;
958
+					if (substr($href, 0, 1) === '/') {
959
+											$href = $baseURL . $href;
960
+					} else {
961
+											$href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href;
962
+					}
940 963
 				}
941 964
 			}
942 965
 
943 966
 			// External URL?
944 967
 			if ($attrib == 'target' && $tag_type == 'url')
945 968
 			{
946
-				if (trim($value) == '_blank')
947
-					$tag_type == 'iurl';
969
+				if (trim($value) == '_blank') {
970
+									$tag_type == 'iurl';
971
+				}
948 972
 			}
949 973
 		}
950 974
 
951 975
 		$tag = '';
952 976
 		if ($href != '')
953 977
 		{
954
-			if ($matches[2] == $href)
955
-				$tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']';
956
-			else
957
-				$tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']';
978
+			if ($matches[2] == $href) {
979
+							$tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']';
980
+			} else {
981
+							$tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']';
982
+			}
958 983
 		}
959 984
 
960 985
 		// Replace the tag
@@ -994,17 +1019,18 @@  discard block
 block discarded – undo
994 1019
 		// We're either moving from the key to the attribute or we're in a string and this is fine.
995 1020
 		if ($text[$i] == '=')
996 1021
 		{
997
-			if ($tag_state == 0)
998
-				$tag_state = 1;
999
-			elseif ($tag_state == 2)
1000
-				$value .= '=';
1022
+			if ($tag_state == 0) {
1023
+							$tag_state = 1;
1024
+			} elseif ($tag_state == 2) {
1025
+							$value .= '=';
1026
+			}
1001 1027
 		}
1002 1028
 		// A space is either moving from an attribute back to a potential key or in a string is fine.
1003 1029
 		elseif ($text[$i] == ' ')
1004 1030
 		{
1005
-			if ($tag_state == 2)
1006
-				$value .= ' ';
1007
-			elseif ($tag_state == 1)
1031
+			if ($tag_state == 2) {
1032
+							$value .= ' ';
1033
+			} elseif ($tag_state == 1)
1008 1034
 			{
1009 1035
 				$attribs[$key] = $value;
1010 1036
 				$key = $value = '';
@@ -1015,24 +1041,27 @@  discard block
 block discarded – undo
1015 1041
 		elseif ($text[$i] == '"')
1016 1042
 		{
1017 1043
 			// Must be either going into or out of a string.
1018
-			if ($tag_state == 1)
1019
-				$tag_state = 2;
1020
-			else
1021
-				$tag_state = 1;
1044
+			if ($tag_state == 1) {
1045
+							$tag_state = 2;
1046
+			} else {
1047
+							$tag_state = 1;
1048
+			}
1022 1049
 		}
1023 1050
 		// Otherwise it's fine.
1024 1051
 		else
1025 1052
 		{
1026
-			if ($tag_state == 0)
1027
-				$key .= $text[$i];
1028
-			else
1029
-				$value .= $text[$i];
1053
+			if ($tag_state == 0) {
1054
+							$key .= $text[$i];
1055
+			} else {
1056
+							$value .= $text[$i];
1057
+			}
1030 1058
 		}
1031 1059
 	}
1032 1060
 
1033 1061
 	// Anything left?
1034
-	if ($key != '' && $value != '')
1035
-		$attribs[$key] = $value;
1062
+	if ($key != '' && $value != '') {
1063
+			$attribs[$key] = $value;
1064
+	}
1036 1065
 
1037 1066
 	return $attribs;
1038 1067
 }
@@ -1050,8 +1079,9 @@  discard block
 block discarded – undo
1050 1079
 	global $modSettings;
1051 1080
 
1052 1081
 	// Don't care about the texts that are too short.
1053
-	if (strlen($text) < 3)
1054
-		return $text;
1082
+	if (strlen($text) < 3) {
1083
+			return $text;
1084
+	}
1055 1085
 
1056 1086
 	// A list of tags that's disabled by the admin.
1057 1087
 	$disabled = empty($modSettings['disabledBBC']) ? array() : array_flip(explode(',', strtolower($modSettings['disabledBBC'])));
@@ -1062,10 +1092,12 @@  discard block
 block discarded – undo
1062 1092
 	$self_closing_tags = array();
1063 1093
 	foreach ($all_tags as $tag)
1064 1094
 	{
1065
-		if (!isset($disabled[$tag['tag']]))
1066
-			$valid_tags[$tag['tag']] = !empty($tag['block_level']);
1067
-		if (isset($tag['type']) && $tag['type'] == 'closed')
1068
-			$self_closing_tags[] = $tag['tag'];
1095
+		if (!isset($disabled[$tag['tag']])) {
1096
+					$valid_tags[$tag['tag']] = !empty($tag['block_level']);
1097
+		}
1098
+		if (isset($tag['type']) && $tag['type'] == 'closed') {
1099
+					$self_closing_tags[] = $tag['tag'];
1100
+		}
1069 1101
 	}
1070 1102
 
1071 1103
 	// Right - we're going to start by going through the whole lot to make sure we don't have align stuff crossed as this happens load and is stupid!
@@ -1092,16 +1124,19 @@  discard block
 block discarded – undo
1092 1124
 				$tagName = substr($match, $isClosingTag ? 2 : 1, -1);
1093 1125
 
1094 1126
 				// We're closing the exact same tag that we opened.
1095
-				if ($isClosingTag && $insideTag === $tagName)
1096
-					$insideTag = null;
1127
+				if ($isClosingTag && $insideTag === $tagName) {
1128
+									$insideTag = null;
1129
+				}
1097 1130
 
1098 1131
 				// We're opening a tag and we're not yet inside one either
1099
-				elseif (!$isClosingTag && $insideTag === null)
1100
-					$insideTag = $tagName;
1132
+				elseif (!$isClosingTag && $insideTag === null) {
1133
+									$insideTag = $tagName;
1134
+				}
1101 1135
 
1102 1136
 				// In all other cases, this tag must be invalid
1103
-				else
1104
-					unset($matches[$i]);
1137
+				else {
1138
+									unset($matches[$i]);
1139
+				}
1105 1140
 			}
1106 1141
 
1107 1142
 			// The next one is gonna be the other one.
@@ -1109,8 +1144,9 @@  discard block
 block discarded – undo
1109 1144
 		}
1110 1145
 
1111 1146
 		// We're still inside a tag and had no chance for closure?
1112
-		if ($insideTag !== null)
1113
-			$matches[] = '[/' . $insideTag . ']';
1147
+		if ($insideTag !== null) {
1148
+					$matches[] = '[/' . $insideTag . ']';
1149
+		}
1114 1150
 
1115 1151
 		// And a complete text string again.
1116 1152
 		$text = implode('', $matches);
@@ -1119,8 +1155,9 @@  discard block
 block discarded – undo
1119 1155
 	// Quickly remove any tags which are back to back.
1120 1156
 	$backToBackPattern = '~\\[(' . implode('|', array_diff(array_keys($valid_tags), array('td', 'anchor'))) . ')[^<>\\[\\]]*\\]\s*\\[/\\1\\]~';
1121 1157
 	$lastlen = 0;
1122
-	while (strlen($text) !== $lastlen)
1123
-		$lastlen = strlen($text = preg_replace($backToBackPattern, '', $text));
1158
+	while (strlen($text) !== $lastlen) {
1159
+			$lastlen = strlen($text = preg_replace($backToBackPattern, '', $text));
1160
+	}
1124 1161
 
1125 1162
 	// Need to sort the tags my name length.
1126 1163
 	uksort($valid_tags, 'sort_array_length');
@@ -1157,8 +1194,9 @@  discard block
 block discarded – undo
1157 1194
 			$isCompetingTag = in_array($tag, $competing_tags);
1158 1195
 
1159 1196
 			// Check if this might be one of those cleaned out tags.
1160
-			if ($tag === '')
1161
-				continue;
1197
+			if ($tag === '') {
1198
+							continue;
1199
+			}
1162 1200
 
1163 1201
 			// Special case: inside [code] blocks any code is left untouched.
1164 1202
 			elseif ($tag === 'code')
@@ -1169,8 +1207,9 @@  discard block
 block discarded – undo
1169 1207
 					$inCode = false;
1170 1208
 
1171 1209
 					// Reopen tags that were closed before the code block.
1172
-					if (!empty($inlineElements))
1173
-						$parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']';
1210
+					if (!empty($inlineElements)) {
1211
+											$parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']';
1212
+					}
1174 1213
 				}
1175 1214
 
1176 1215
 				// We're outside a coding and nobbc block and opening it.
@@ -1199,8 +1238,9 @@  discard block
 block discarded – undo
1199 1238
 					$inNoBbc = false;
1200 1239
 
1201 1240
 					// Some inline elements might've been closed that need reopening.
1202
-					if (!empty($inlineElements))
1203
-						$parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']';
1241
+					if (!empty($inlineElements)) {
1242
+											$parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']';
1243
+					}
1204 1244
 				}
1205 1245
 
1206 1246
 				// We're outside a nobbc and coding block and opening it.
@@ -1220,8 +1260,9 @@  discard block
 block discarded – undo
1220 1260
 			}
1221 1261
 
1222 1262
 			// So, we're inside one of the special blocks: ignore any tag.
1223
-			elseif ($inCode || $inNoBbc)
1224
-				continue;
1263
+			elseif ($inCode || $inNoBbc) {
1264
+							continue;
1265
+			}
1225 1266
 
1226 1267
 			// We're dealing with an opening tag.
1227 1268
 			if ($isOpeningTag)
@@ -1262,8 +1303,9 @@  discard block
 block discarded – undo
1262 1303
 							if ($parts[$j + 3] === $tag)
1263 1304
 							{
1264 1305
 								// If it's an opening tag, increase the level.
1265
-								if ($parts[$j + 2] === '')
1266
-									$curLevel++;
1306
+								if ($parts[$j + 2] === '') {
1307
+																	$curLevel++;
1308
+								}
1267 1309
 
1268 1310
 								// A closing tag, decrease the level.
1269 1311
 								else
@@ -1286,13 +1328,15 @@  discard block
 block discarded – undo
1286 1328
 					{
1287 1329
 						if ($isCompetingTag)
1288 1330
 						{
1289
-							if (!isset($competingElements[$tag]))
1290
-								$competingElements[$tag] = array();
1331
+							if (!isset($competingElements[$tag])) {
1332
+															$competingElements[$tag] = array();
1333
+							}
1291 1334
 
1292 1335
 							$competingElements[$tag][] = $parts[$i + 4];
1293 1336
 
1294
-							if (count($competingElements[$tag]) > 1)
1295
-								$parts[$i] .= '[/' . $tag . ']';
1337
+							if (count($competingElements[$tag]) > 1) {
1338
+															$parts[$i] .= '[/' . $tag . ']';
1339
+							}
1296 1340
 						}
1297 1341
 
1298 1342
 						$inlineElements[$elementContent] = $tag;
@@ -1312,15 +1356,17 @@  discard block
 block discarded – undo
1312 1356
 						$addClosingTags = array();
1313 1357
 						while ($element = array_pop($blockElements))
1314 1358
 						{
1315
-							if ($element === $tag)
1316
-								break;
1359
+							if ($element === $tag) {
1360
+															break;
1361
+							}
1317 1362
 
1318 1363
 							// Still a block tag was open not equal to this tag.
1319 1364
 							$addClosingTags[] = $element['type'];
1320 1365
 						}
1321 1366
 
1322
-						if (!empty($addClosingTags))
1323
-							$parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1];
1367
+						if (!empty($addClosingTags)) {
1368
+													$parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1];
1369
+						}
1324 1370
 
1325 1371
 						// Apparently the closing tag was not found on the stack.
1326 1372
 						if (!is_string($element) || $element !== $tag)
@@ -1330,8 +1376,7 @@  discard block
 block discarded – undo
1330 1376
 							$parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = '';
1331 1377
 							continue;
1332 1378
 						}
1333
-					}
1334
-					else
1379
+					} else
1335 1380
 					{
1336 1381
 						// Get rid of this closing tag!
1337 1382
 						$parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = '';
@@ -1360,53 +1405,62 @@  discard block
 block discarded – undo
1360 1405
 							unset($inlineElements[$tagContentToBeClosed]);
1361 1406
 
1362 1407
 							// Was this the tag we were looking for?
1363
-							if ($tagToBeClosed === $tag)
1364
-								break;
1408
+							if ($tagToBeClosed === $tag) {
1409
+															break;
1410
+							}
1365 1411
 
1366 1412
 							// Nope, close it and look further!
1367
-							else
1368
-								$parts[$i] .= '[/' . $tagToBeClosed . ']';
1413
+							else {
1414
+															$parts[$i] .= '[/' . $tagToBeClosed . ']';
1415
+							}
1369 1416
 						}
1370 1417
 
1371 1418
 						if ($isCompetingTag && !empty($competingElements[$tag]))
1372 1419
 						{
1373 1420
 							array_pop($competingElements[$tag]);
1374 1421
 
1375
-							if (count($competingElements[$tag]) > 0)
1376
-								$parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5];
1422
+							if (count($competingElements[$tag]) > 0) {
1423
+															$parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5];
1424
+							}
1377 1425
 						}
1378 1426
 					}
1379 1427
 
1380 1428
 					// Unexpected closing tag, ex-ter-mi-nate.
1381
-					else
1382
-						$parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = '';
1429
+					else {
1430
+											$parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = '';
1431
+					}
1383 1432
 				}
1384 1433
 			}
1385 1434
 		}
1386 1435
 
1387 1436
 		// Close the code tags.
1388
-		if ($inCode)
1389
-			$parts[$i] .= '[/code]';
1437
+		if ($inCode) {
1438
+					$parts[$i] .= '[/code]';
1439
+		}
1390 1440
 
1391 1441
 		// The same for nobbc tags.
1392
-		elseif ($inNoBbc)
1393
-			$parts[$i] .= '[/nobbc]';
1442
+		elseif ($inNoBbc) {
1443
+					$parts[$i] .= '[/nobbc]';
1444
+		}
1394 1445
 
1395 1446
 		// Still inline tags left unclosed? Close them now, better late than never.
1396
-		elseif (!empty($inlineElements))
1397
-			$parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']';
1447
+		elseif (!empty($inlineElements)) {
1448
+					$parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']';
1449
+		}
1398 1450
 
1399 1451
 		// Now close the block elements.
1400
-		if (!empty($blockElements))
1401
-			$parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']';
1452
+		if (!empty($blockElements)) {
1453
+					$parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']';
1454
+		}
1402 1455
 
1403 1456
 		$text = implode('', $parts);
1404 1457
 	}
1405 1458
 
1406 1459
 	// Final clean up of back to back tags.
1407 1460
 	$lastlen = 0;
1408
-	while (strlen($text) !== $lastlen)
1409
-		$lastlen = strlen($text = preg_replace($backToBackPattern, '', $text));
1461
+	while (strlen($text) !== $lastlen) {
1462
+			$lastlen = strlen($text = preg_replace($backToBackPattern, '', $text));
1463
+	}
1410 1464
 
1411 1465
 	return $text;
1412 1466
 }
@@ -1437,22 +1491,25 @@  discard block
 block discarded – undo
1437 1491
 	$context['template_layers'] = array();
1438 1492
 	// Lets make sure we aren't going to output anything nasty.
1439 1493
 	@ob_end_clean();
1440
-	if (!empty($modSettings['enableCompressedOutput']))
1441
-		@ob_start('ob_gzhandler');
1442
-	else
1443
-		@ob_start();
1494
+	if (!empty($modSettings['enableCompressedOutput'])) {
1495
+			@ob_start('ob_gzhandler');
1496
+	} else {
1497
+			@ob_start();
1498
+	}
1444 1499
 
1445 1500
 	// If we don't have any locale better avoid broken js
1446
-	if (empty($txt['lang_locale']))
1447
-		die();
1501
+	if (empty($txt['lang_locale'])) {
1502
+			die();
1503
+	}
1448 1504
 
1449 1505
 	$file_data = '(function ($) {
1450 1506
 	\'use strict\';
1451 1507
 
1452 1508
 	$.sceditor.locale[' . JavaScriptEscape($txt['lang_locale']) . '] = {';
1453
-	foreach ($editortxt as $key => $val)
1454
-		$file_data .= '
1509
+	foreach ($editortxt as $key => $val) {
1510
+			$file_data .= '
1455 1511
 		' . JavaScriptEscape($key) . ': ' . JavaScriptEscape($val) . ',';
1512
+	}
1456 1513
 
1457 1514
 	$file_data .= '
1458 1515
 		dateFormat: "day.month.year"
@@ -1520,8 +1577,9 @@  discard block
 block discarded – undo
1520 1577
 				)
1521 1578
 			);
1522 1579
 			$icon_data = array();
1523
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1524
-				$icon_data[] = $row;
1580
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
1581
+							$icon_data[] = $row;
1582
+			}
1525 1583
 			$smcFunc['db_free_result']($request);
1526 1584
 
1527 1585
 			$icons = array();
@@ -1536,9 +1594,9 @@  discard block
 block discarded – undo
1536 1594
 			}
1537 1595
 
1538 1596
 			cache_put_data('posting_icons-' . $board_id, $icons, 480);
1597
+		} else {
1598
+					$icons = $temp;
1539 1599
 		}
1540
-		else
1541
-			$icons = $temp;
1542 1600
 	}
1543 1601
 	call_integration_hook('integrate_load_message_icons', array(&$icons));
1544 1602
 
@@ -1581,8 +1639,9 @@  discard block
 block discarded – undo
1581 1639
 	{
1582 1640
 		// Some general stuff.
1583 1641
 		$settings['smileys_url'] = $modSettings['smileys_url'] . '/' . $user_info['smiley_set'];
1584
-		if (!empty($context['drafts_autosave']))
1585
-			$context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000;
1642
+		if (!empty($context['drafts_autosave'])) {
1643
+					$context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000;
1644
+		}
1586 1645
 
1587 1646
 		// This really has some WYSIWYG stuff.
1588 1647
 		loadCSSFile('jquery.sceditor.css', array('force_current' => false, 'validate' => true), 'smf_jquery_sceditor');
@@ -1599,8 +1658,9 @@  discard block
 block discarded – undo
1599 1658
 		var bbc_quote = \'' . addcslashes($txt['quote'], "'") . '\';
1600 1659
 		var bbc_search_on = \'' . addcslashes($txt['search_on'], "'") . '\';');
1601 1660
 		// editor language file
1602
-		if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US')
1603
-			loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language');
1661
+		if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US') {
1662
+					loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language');
1663
+		}
1604 1664
 
1605 1665
 		$context['shortcuts_text'] = $txt['shortcuts' . (!empty($context['drafts_save']) ? '_drafts' : '') . (stripos($_SERVER['HTTP_USER_AGENT'], 'Macintosh') !== false ? '_mac' : (isBrowser('is_firefox') ? '_firefox' : ''))];
1606 1666
 		$context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_character_set'] == 'UTF-8' || function_exists('iconv'))));
@@ -1609,11 +1669,12 @@  discard block
 block discarded – undo
1609 1669
 			loadJavaScriptFile('spellcheck.js', array('minimize' => true), 'smf_spellcheck');
1610 1670
 
1611 1671
 			// Some hidden information is needed in order to make the spell checking work.
1612
-			if (!isset($_REQUEST['xml']))
1613
-				$context['insert_after_template'] .= '
1672
+			if (!isset($_REQUEST['xml'])) {
1673
+							$context['insert_after_template'] .= '
1614 1674
 		<form name="spell_form" id="spell_form" method="post" accept-charset="' . $context['character_set'] . '" target="spellWindow" action="' . $scripturl . '?action=spellcheck">
1615 1675
 			<input type="hidden" name="spellstring" value="">
1616 1676
 		</form>';
1677
+			}
1617 1678
 		}
1618 1679
 	}
1619 1680
 
@@ -1805,8 +1866,9 @@  discard block
 block discarded – undo
1805 1866
 
1806 1867
 		// Generate a list of buttons that shouldn't be shown - this should be the fastest way to do this.
1807 1868
 		$disabled_tags = array();
1808
-		if (!empty($modSettings['disabledBBC']))
1809
-			$disabled_tags = explode(',', $modSettings['disabledBBC']);
1869
+		if (!empty($modSettings['disabledBBC'])) {
1870
+					$disabled_tags = explode(',', $modSettings['disabledBBC']);
1871
+		}
1810 1872
 
1811 1873
 		foreach ($disabled_tags as $tag)
1812 1874
 		{
@@ -1818,9 +1880,10 @@  discard block
 block discarded – undo
1818 1880
 				$context['disabled_tags']['orderedlist'] = true;
1819 1881
 			}
1820 1882
 
1821
-			foreach ($editor_tag_map as $thisTag => $tagNameBBC)
1822
-				if ($tag === $thisTag)
1883
+			foreach ($editor_tag_map as $thisTag => $tagNameBBC) {
1884
+							if ($tag === $thisTag)
1823 1885
 					$context['disabled_tags'][$tagNameBBC] = true;
1886
+			}
1824 1887
 
1825 1888
 			$context['disabled_tags'][$tag] = true;
1826 1889
 		}
@@ -1831,8 +1894,9 @@  discard block
 block discarded – undo
1831 1894
 
1832 1895
 		foreach ($context['bbc_tags'] as $row => $tagRow)
1833 1896
 		{
1834
-			if (!isset($context['bbc_toolbar'][$row]))
1835
-				$context['bbc_toolbar'][$row] = array();
1897
+			if (!isset($context['bbc_toolbar'][$row])) {
1898
+							$context['bbc_toolbar'][$row] = array();
1899
+			}
1836 1900
 
1837 1901
 			$tagsRow = array();
1838 1902
 
@@ -1868,20 +1932,21 @@  discard block
 block discarded – undo
1868 1932
 
1869 1933
 					$context['bbcodes_handlers'] .= '
1870 1934
 						});';
1871
-				}
1872
-				else
1935
+				} else
1873 1936
 				{
1874 1937
 					$context['bbc_toolbar'][$row][] = implode(',', $tagsRow);
1875 1938
 					$tagsRow = array();
1876 1939
 				}
1877 1940
 			}
1878 1941
 
1879
-			if (!empty($tagsRow))
1880
-				$context['bbc_toolbar'][$row][] = implode(',', $tagsRow);
1942
+			if (!empty($tagsRow)) {
1943
+							$context['bbc_toolbar'][$row][] = implode(',', $tagsRow);
1944
+			}
1881 1945
 		}
1882 1946
 
1883
-		if (!empty($bbcodes_styles))
1884
-			addInlineCss($bbcodes_styles);
1947
+		if (!empty($bbcodes_styles)) {
1948
+					addInlineCss($bbcodes_styles);
1949
+		}
1885 1950
 	}
1886 1951
 
1887 1952
 	// Initialize smiley array... if not loaded before.
@@ -1893,8 +1958,8 @@  discard block
 block discarded – undo
1893 1958
 		);
1894 1959
 
1895 1960
 		// Load smileys - don't bother to run a query if we're not using the database's ones anyhow.
1896
-		if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none')
1897
-			$context['smileys']['postform'][] = array(
1961
+		if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none') {
1962
+					$context['smileys']['postform'][] = array(
1898 1963
 				'smileys' => array(
1899 1964
 					array(
1900 1965
 						'code' => ':)',
@@ -1980,7 +2045,7 @@  discard block
 block discarded – undo
1980 2045
 				),
1981 2046
 				'isLast' => true,
1982 2047
 			);
1983
-		elseif ($user_info['smiley_set'] != 'none')
2048
+		} elseif ($user_info['smiley_set'] != 'none')
1984 2049
 		{
1985 2050
 			if (($temp = cache_get_data('posting_smileys', 480)) == null)
1986 2051
 			{
@@ -2003,17 +2068,19 @@  discard block
 block discarded – undo
2003 2068
 
2004 2069
 				foreach ($context['smileys'] as $section => $smileyRows)
2005 2070
 				{
2006
-					foreach ($smileyRows as $rowIndex => $smileys)
2007
-						$context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true;
2071
+					foreach ($smileyRows as $rowIndex => $smileys) {
2072
+											$context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true;
2073
+					}
2008 2074
 
2009
-					if (!empty($smileyRows))
2010
-						$context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true;
2075
+					if (!empty($smileyRows)) {
2076
+											$context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true;
2077
+					}
2011 2078
 				}
2012 2079
 
2013 2080
 				cache_put_data('posting_smileys', $context['smileys'], 480);
2081
+			} else {
2082
+							$context['smileys'] = $temp;
2014 2083
 			}
2015
-			else
2016
-				$context['smileys'] = $temp;
2017 2084
 		}
2018 2085
 	}
2019 2086
 
@@ -2029,12 +2096,15 @@  discard block
 block discarded – undo
2029 2096
 		'plugins' => 'undo',
2030 2097
 		'bbcodeTrim' => true,
2031 2098
 	);
2032
-	if (!empty($context['controls']['richedit'][$editorOptions['id']]['locale']))
2033
-		$sce_options['locale'] = $context['controls']['richedit'][$editorOptions['id']]['locale'];
2034
-	if (!empty($context['right_to_left']))
2035
-		$sce_options['rtl'] = true;
2036
-	if ($editorOptions['id'] != 'quickReply')
2037
-		$sce_options['autofocus'] = true;
2099
+	if (!empty($context['controls']['richedit'][$editorOptions['id']]['locale'])) {
2100
+			$sce_options['locale'] = $context['controls']['richedit'][$editorOptions['id']]['locale'];
2101
+	}
2102
+	if (!empty($context['right_to_left'])) {
2103
+			$sce_options['rtl'] = true;
2104
+	}
2105
+	if ($editorOptions['id'] != 'quickReply') {
2106
+			$sce_options['autofocus'] = true;
2107
+	}
2038 2108
 
2039 2109
 	$sce_options['emoticons'] = array();
2040 2110
 	$sce_options['emoticonsDescriptions'] = array();
@@ -2051,10 +2121,11 @@  discard block
 block discarded – undo
2051 2121
 			$countLocations--;
2052 2122
 
2053 2123
 			unset($smiley_location);
2054
-			if ($location == 'postform')
2055
-				$smiley_location = &$sce_options['emoticons']['dropdown'];
2056
-			elseif ($location == 'popup')
2057
-				$smiley_location = &$sce_options['emoticons']['popup'];
2124
+			if ($location == 'postform') {
2125
+							$smiley_location = &$sce_options['emoticons']['dropdown'];
2126
+			} elseif ($location == 'popup') {
2127
+							$smiley_location = &$sce_options['emoticons']['popup'];
2128
+			}
2058 2129
 
2059 2130
 			$numRows = count($smileyRows);
2060 2131
 
@@ -2068,8 +2139,9 @@  discard block
 block discarded – undo
2068 2139
 					$sce_options['emoticonsDescriptions'][$smiley['code']] = $smiley['description'];
2069 2140
 				}
2070 2141
 
2071
-				if (empty($smileyRow['isLast']) && $numRows != 1)
2072
-					$smiley_location['-' . $emptyPlaceholder++] = '';
2142
+				if (empty($smileyRow['isLast']) && $numRows != 1) {
2143
+									$smiley_location['-' . $emptyPlaceholder++] = '';
2144
+				}
2073 2145
 			}
2074 2146
 		}
2075 2147
 	}
@@ -2084,8 +2156,9 @@  discard block
 block discarded – undo
2084 2156
 
2085 2157
 			$count_tags--;
2086 2158
 
2087
-			if (!empty($count_tags))
2088
-				$sce_options['toolbar'] .= '||';
2159
+			if (!empty($count_tags)) {
2160
+							$sce_options['toolbar'] .= '||';
2161
+			}
2089 2162
 		}
2090 2163
 	}
2091 2164
 
@@ -2113,8 +2186,9 @@  discard block
 block discarded – undo
2113 2186
 		loadTemplate('GenericControls');
2114 2187
 
2115 2188
 		// Some javascript ma'am?
2116
-		if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual'])))
2117
-			loadJavaScriptFile('captcha.js', array('minimize' => true), 'smf_captcha');
2189
+		if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual']))) {
2190
+					loadJavaScriptFile('captcha.js', array('minimize' => true), 'smf_captcha');
2191
+		}
2118 2192
 
2119 2193
 		$context['use_graphic_library'] = in_array('gd', get_loaded_extensions());
2120 2194
 
@@ -2127,8 +2201,8 @@  discard block
 block discarded – undo
2127 2201
 	$isNew = !isset($context['controls']['verification'][$verificationOptions['id']]);
2128 2202
 
2129 2203
 	// Log this into our collection.
2130
-	if ($isNew)
2131
-		$context['controls']['verification'][$verificationOptions['id']] = array(
2204
+	if ($isNew) {
2205
+			$context['controls']['verification'][$verificationOptions['id']] = array(
2132 2206
 			'id' => $verificationOptions['id'],
2133 2207
 			'empty_field' => empty($verificationOptions['no_empty_field']),
2134 2208
 			'show_visual' => !empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual'])),
@@ -2139,13 +2213,15 @@  discard block
 block discarded – undo
2139 2213
 			'questions' => array(),
2140 2214
 			'can_recaptcha' => !empty($modSettings['recaptcha_enabled']) && !empty($modSettings['recaptcha_site_key']) && !empty($modSettings['recaptcha_secret_key']),
2141 2215
 		);
2216
+	}
2142 2217
 	$thisVerification = &$context['controls']['verification'][$verificationOptions['id']];
2143 2218
 
2144 2219
 	// Is there actually going to be anything?
2145
-	if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha']))
2146
-		return false;
2147
-	elseif (!$isNew && !$do_test)
2148
-		return true;
2220
+	if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha'])) {
2221
+			return false;
2222
+	} elseif (!$isNew && !$do_test) {
2223
+			return true;
2224
+	}
2149 2225
 
2150 2226
 	// Sanitize reCAPTCHA fields?
2151 2227
 	if ($thisVerification['can_recaptcha'])
@@ -2158,11 +2234,12 @@  discard block
 block discarded – undo
2158 2234
 	}
2159 2235
 
2160 2236
 	// Add javascript for the object.
2161
-	if ($context['controls']['verification'][$verificationOptions['id']]['show_visual'])
2162
-		$context['insert_after_template'] .= '
2237
+	if ($context['controls']['verification'][$verificationOptions['id']]['show_visual']) {
2238
+			$context['insert_after_template'] .= '
2163 2239
 			<script>
2164 2240
 				var verification' . $verificationOptions['id'] . 'Handle = new smfCaptcha("' . $thisVerification['image_href'] . '", "' . $verificationOptions['id'] . '", ' . ($context['use_graphic_library'] ? 1 : 0) . ');
2165 2241
 			</script>';
2242
+	}
2166 2243
 
2167 2244
 	// If we want questions do we have a cache of all the IDs?
2168 2245
 	if (!empty($thisVerification['number_questions']) && empty($modSettings['question_id_cache']))
@@ -2185,8 +2262,9 @@  discard block
 block discarded – undo
2185 2262
 				unset ($row['id_question']);
2186 2263
 				// Make them all lowercase. We can't directly use $smcFunc['strtolower'] with array_walk, so do it manually, eh?
2187 2264
 				$row['answers'] = $smcFunc['json_decode']($row['answers'], true);
2188
-				foreach ($row['answers'] as $k => $v)
2189
-					$row['answers'][$k] = $smcFunc['strtolower']($v);
2265
+				foreach ($row['answers'] as $k => $v) {
2266
+									$row['answers'][$k] = $smcFunc['strtolower']($v);
2267
+				}
2190 2268
 
2191 2269
 				$modSettings['question_id_cache']['questions'][$id_question] = $row;
2192 2270
 				$modSettings['question_id_cache']['langs'][$row['lngfile']][] = $id_question;
@@ -2197,35 +2275,42 @@  discard block
 block discarded – undo
2197 2275
 		}
2198 2276
 	}
2199 2277
 
2200
-	if (!isset($_SESSION[$verificationOptions['id'] . '_vv']))
2201
-		$_SESSION[$verificationOptions['id'] . '_vv'] = array();
2278
+	if (!isset($_SESSION[$verificationOptions['id'] . '_vv'])) {
2279
+			$_SESSION[$verificationOptions['id'] . '_vv'] = array();
2280
+	}
2202 2281
 
2203 2282
 	// Do we need to refresh the verification?
2204
-	if (!$do_test && (!empty($_SESSION[$verificationOptions['id'] . '_vv']['did_pass']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) || $_SESSION[$verificationOptions['id'] . '_vv']['count'] > 3) && empty($verificationOptions['dont_refresh']))
2205
-		$force_refresh = true;
2206
-	else
2207
-		$force_refresh = false;
2283
+	if (!$do_test && (!empty($_SESSION[$verificationOptions['id'] . '_vv']['did_pass']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) || $_SESSION[$verificationOptions['id'] . '_vv']['count'] > 3) && empty($verificationOptions['dont_refresh'])) {
2284
+			$force_refresh = true;
2285
+	} else {
2286
+			$force_refresh = false;
2287
+	}
2208 2288
 
2209 2289
 	// This can also force a fresh, although unlikely.
2210
-	if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q'])))
2211
-		$force_refresh = true;
2290
+	if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q']))) {
2291
+			$force_refresh = true;
2292
+	}
2212 2293
 
2213 2294
 	$verification_errors = array();
2214 2295
 	// Start with any testing.
2215 2296
 	if ($do_test)
2216 2297
 	{
2217 2298
 		// This cannot happen!
2218
-		if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count']))
2219
-			fatal_lang_error('no_access', false);
2299
+		if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count'])) {
2300
+					fatal_lang_error('no_access', false);
2301
+		}
2220 2302
 		// ... nor this!
2221
-		if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q'])))
2222
-			fatal_lang_error('no_access', false);
2303
+		if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q']))) {
2304
+					fatal_lang_error('no_access', false);
2305
+		}
2223 2306
 		// Hmm, it's requested but not actually declared. This shouldn't happen.
2224
-		if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']))
2225
-			fatal_lang_error('no_access', false);
2307
+		if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) {
2308
+					fatal_lang_error('no_access', false);
2309
+		}
2226 2310
 		// While we're here, did the user do something bad?
2227
-		if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']]))
2228
-			$verification_errors[] = 'wrong_verification_answer';
2311
+		if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']])) {
2312
+					$verification_errors[] = 'wrong_verification_answer';
2313
+		}
2229 2314
 
2230 2315
 		if ($thisVerification['can_recaptcha'])
2231 2316
 		{
@@ -2236,22 +2321,25 @@  discard block
 block discarded – undo
2236 2321
 			{
2237 2322
 				$resp = $reCaptcha->verify($_POST['g-recaptcha-response'], $user_info['ip']);
2238 2323
 
2239
-				if (!$resp->isSuccess())
2240
-					$verification_errors[] = 'wrong_verification_code';
2324
+				if (!$resp->isSuccess()) {
2325
+									$verification_errors[] = 'wrong_verification_code';
2326
+				}
2327
+			} else {
2328
+							$verification_errors[] = 'wrong_verification_code';
2241 2329
 			}
2242
-			else
2243
-				$verification_errors[] = 'wrong_verification_code';
2244 2330
 		}
2245
-		if ($thisVerification['show_visual'] && (empty($_REQUEST[$verificationOptions['id'] . '_vv']['code']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['code']) || strtoupper($_REQUEST[$verificationOptions['id'] . '_vv']['code']) !== $_SESSION[$verificationOptions['id'] . '_vv']['code']))
2246
-			$verification_errors[] = 'wrong_verification_code';
2331
+		if ($thisVerification['show_visual'] && (empty($_REQUEST[$verificationOptions['id'] . '_vv']['code']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['code']) || strtoupper($_REQUEST[$verificationOptions['id'] . '_vv']['code']) !== $_SESSION[$verificationOptions['id'] . '_vv']['code'])) {
2332
+					$verification_errors[] = 'wrong_verification_code';
2333
+		}
2247 2334
 		if ($thisVerification['number_questions'])
2248 2335
 		{
2249 2336
 			$incorrectQuestions = array();
2250 2337
 			foreach ($_SESSION[$verificationOptions['id'] . '_vv']['q'] as $q)
2251 2338
 			{
2252 2339
 				// We don't have this question any more, thus no answers.
2253
-				if (!isset($modSettings['question_id_cache']['questions'][$q]))
2254
-					continue;
2340
+				if (!isset($modSettings['question_id_cache']['questions'][$q])) {
2341
+									continue;
2342
+				}
2255 2343
 				// This is quite complex. We have our question but it might have multiple answers.
2256 2344
 				// First, did they actually answer this question?
2257 2345
 				if (!isset($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) || trim($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) == '')
@@ -2263,24 +2351,28 @@  discard block
 block discarded – undo
2263 2351
 				else
2264 2352
 				{
2265 2353
 					$given_answer = trim($smcFunc['htmlspecialchars'](strtolower($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q])));
2266
-					if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers']))
2267
-						$incorrectQuestions[] = $q;
2354
+					if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers'])) {
2355
+											$incorrectQuestions[] = $q;
2356
+					}
2268 2357
 				}
2269 2358
 			}
2270 2359
 
2271
-			if (!empty($incorrectQuestions))
2272
-				$verification_errors[] = 'wrong_verification_answer';
2360
+			if (!empty($incorrectQuestions)) {
2361
+							$verification_errors[] = 'wrong_verification_answer';
2362
+			}
2273 2363
 		}
2274 2364
 	}
2275 2365
 
2276 2366
 	// Any errors means we refresh potentially.
2277 2367
 	if (!empty($verification_errors))
2278 2368
 	{
2279
-		if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors']))
2280
-			$_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0;
2369
+		if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors'])) {
2370
+					$_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0;
2371
+		}
2281 2372
 		// Too many errors?
2282
-		elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors'])
2283
-			$force_refresh = true;
2373
+		elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors']) {
2374
+					$force_refresh = true;
2375
+		}
2284 2376
 
2285 2377
 		// Keep a track of these.
2286 2378
 		$_SESSION[$verificationOptions['id'] . '_vv']['errors']++;
@@ -2313,8 +2405,9 @@  discard block
 block discarded – undo
2313 2405
 			// Are we overriding the range?
2314 2406
 			$character_range = !empty($verificationOptions['override_range']) ? $verificationOptions['override_range'] : $context['standard_captcha_range'];
2315 2407
 
2316
-			for ($i = 0; $i < 6; $i++)
2317
-				$_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)];
2408
+			for ($i = 0; $i < 6; $i++) {
2409
+							$_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)];
2410
+			}
2318 2411
 		}
2319 2412
 
2320 2413
 		// Getting some new questions?
@@ -2322,8 +2415,9 @@  discard block
 block discarded – undo
2322 2415
 		{
2323 2416
 			// Attempt to try the current page's language, followed by the user's preference, followed by the site default.
2324 2417
 			$possible_langs = array();
2325
-			if (isset($_SESSION['language']))
2326
-				$possible_langs[] = strtr($_SESSION['language'], array('-utf8' => ''));
2418
+			if (isset($_SESSION['language'])) {
2419
+							$possible_langs[] = strtr($_SESSION['language'], array('-utf8' => ''));
2420
+			}
2327 2421
 			if (!empty($user_info['language']));
2328 2422
 			$possible_langs[] = $user_info['language'];
2329 2423
 			$possible_langs[] = $language;
@@ -2342,8 +2436,7 @@  discard block
 block discarded – undo
2342 2436
 				}
2343 2437
 			}
2344 2438
 		}
2345
-	}
2346
-	else
2439
+	} else
2347 2440
 	{
2348 2441
 		// Same questions as before.
2349 2442
 		$questionIDs = !empty($_SESSION[$verificationOptions['id'] . '_vv']['q']) ? $_SESSION[$verificationOptions['id'] . '_vv']['q'] : array();
@@ -2353,8 +2446,9 @@  discard block
 block discarded – undo
2353 2446
 	// If we do have an empty field, it would be nice to hide it from legitimate users who shouldn't be populating it anyway.
2354 2447
 	if (!empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']))
2355 2448
 	{
2356
-		if (!isset($context['html_headers']))
2357
-			$context['html_headers'] = '';
2449
+		if (!isset($context['html_headers'])) {
2450
+					$context['html_headers'] = '';
2451
+		}
2358 2452
 		$context['html_headers'] .= '<style>.vv_special { display:none; }</style>';
2359 2453
 	}
2360 2454
 
@@ -2380,11 +2474,13 @@  discard block
 block discarded – undo
2380 2474
 	$_SESSION[$verificationOptions['id'] . '_vv']['count'] = empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) ? 1 : $_SESSION[$verificationOptions['id'] . '_vv']['count'] + 1;
2381 2475
 
2382 2476
 	// Return errors if we have them.
2383
-	if (!empty($verification_errors))
2384
-		return $verification_errors;
2477
+	if (!empty($verification_errors)) {
2478
+			return $verification_errors;
2479
+	}
2385 2480
 	// If we had a test that one, make a note.
2386
-	elseif ($do_test)
2387
-		$_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true;
2481
+	elseif ($do_test) {
2482
+			$_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true;
2483
+	}
2388 2484
 
2389 2485
 	// Say that everything went well chaps.
2390 2486
 	return true;
@@ -2409,8 +2505,9 @@  discard block
 block discarded – undo
2409 2505
 	call_integration_hook('integrate_autosuggest', array(&$searchTypes));
2410 2506
 
2411 2507
 	// If we're just checking the callback function is registered return true or false.
2412
-	if ($checkRegistered != null)
2413
-		return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered);
2508
+	if ($checkRegistered != null) {
2509
+			return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered);
2510
+	}
2414 2511
 
2415 2512
 	checkSession('get');
2416 2513
 	loadTemplate('Xml');
@@ -2561,24 +2658,27 @@  discard block
 block discarded – undo
2561 2658
 		foreach ($possible_versions as $ver)
2562 2659
 		{
2563 2660
 			$ver = trim($ver);
2564
-			if (strpos($ver, 'SMF') === 0)
2565
-				$versions[] = $ver;
2661
+			if (strpos($ver, 'SMF') === 0) {
2662
+							$versions[] = $ver;
2663
+			}
2566 2664
 		}
2567 2665
 	}
2568 2666
 	$smcFunc['db_free_result']($request);
2569 2667
 
2570 2668
 	// Just in case we don't have ANYthing.
2571
-	if (empty($versions))
2572
-		$versions = array('SMF 2.0');
2669
+	if (empty($versions)) {
2670
+			$versions = array('SMF 2.0');
2671
+	}
2573 2672
 
2574
-	foreach ($versions as $id => $version)
2575
-		if (strpos($version, strtoupper($_REQUEST['search'])) !== false)
2673
+	foreach ($versions as $id => $version) {
2674
+			if (strpos($version, strtoupper($_REQUEST['search'])) !== false)
2576 2675
 			$xml_data['items']['children'][] = array(
2577 2676
 				'attributes' => array(
2578 2677
 					'id' => $id,
2579 2678
 				),
2580 2679
 				'value' => $version,
2581 2680
 			);
2681
+	}
2582 2682
 
2583 2683
 	return $xml_data;
2584 2684
 }
Please login to merge, or discard this patch.
Sources/RepairBoards.php 2 patches
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 					LEFT JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic)
247 247
 				WHERE t.id_topic IS NULL
248 248
 				GROUP BY m.id_topic, m.id_board',
249
-			'fix_processing' => function ($row) use ($smcFunc)
249
+			'fix_processing' => function($row) use ($smcFunc)
250 250
 			{
251 251
 				global $salvageBoardID;
252 252
 
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 			// Remove all topics that have zero messages in the messages table.
333 333
 			'fix_collect' => array(
334 334
 				'index' => 'id_topic',
335
-				'process' => function ($topics) use ($smcFunc)
335
+				'process' => function($topics) use ($smcFunc)
336 336
 				{
337 337
 					$smcFunc['db_query']('', '
338 338
 						DELETE FROM {db_prefix}topics
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 				  AND p.id_poll IS NULL
370 370
 				GROUP BY o.id_poll, t.id_topic, t.id_board, t.id_member_started, m.member_name
371 371
 				  ',
372
-			'fix_processing' => function ($row) use ($smcFunc, $txt)
372
+			'fix_processing' => function($row) use ($smcFunc, $txt)
373 373
 			{
374 374
 				global $salvageBoardID;
375 375
 
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
 					LEFT JOIN {db_prefix}topics AS t ON (t.id_poll = p.id_poll)
507 507
 				WHERE p.id_poll BETWEEN {STEP_LOW} AND {STEP_HIGH}
508 508
 					AND t.id_poll IS NULL',
509
-			'fix_processing' => function ($row) use ($smcFunc, $txt)
509
+			'fix_processing' => function($row) use ($smcFunc, $txt)
510 510
 			{
511 511
 				global $salvageBoardID;
512 512
 
@@ -617,7 +617,7 @@  discard block
 block discarded – undo
617 617
 				WHERE t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH}
618 618
 				GROUP BY t.id_topic, t.id_first_msg, t.id_last_msg, t.approved, mf.approved
619 619
 				ORDER BY t.id_topic',
620
-			'fix_processing' => function ($row) use ($smcFunc)
620
+			'fix_processing' => function($row) use ($smcFunc)
621 621
 			{
622 622
 				$row['firstmsg_approved'] = (int) $row['firstmsg_approved'];
623 623
 				$row['myid_first_msg'] = (int) $row['myid_first_msg'];
@@ -646,7 +646,7 @@  discard block
 block discarded – undo
646 646
 					)
647 647
 				);
648 648
 			},
649
-			'message_function' => function ($row) use ($txt, &$context)
649
+			'message_function' => function($row) use ($txt, &$context)
650 650
 			{
651 651
 				// A pretend error?
652 652
 				if ($row['id_first_msg'] == $row['myid_first_msg'] && $row['id_last_msg'] == $row['myid_last_msg'] && $row['approved'] == $row['firstmsg_approved'])
@@ -680,7 +680,7 @@  discard block
 block discarded – undo
680 680
 				WHERE t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH}
681 681
 				GROUP BY t.id_topic, t.num_replies, mf.approved
682 682
 				ORDER BY t.id_topic',
683
-			'fix_processing' => function ($row)
683
+			'fix_processing' => function($row)
684 684
 			{
685 685
 				global $smcFunc;
686 686
 				$row['my_num_replies'] = (int) $row['my_num_replies'];
@@ -699,7 +699,7 @@  discard block
 block discarded – undo
699 699
 					)
700 700
 				);
701 701
 			},
702
-			'message_function' => function ($row)
702
+			'message_function' => function($row)
703 703
 			{
704 704
 				global $txt, $context;
705 705
 
@@ -730,7 +730,7 @@  discard block
 block discarded – undo
730 730
 				GROUP BY t.id_topic, t.unapproved_posts
731 731
 				HAVING unapproved_posts != COUNT(mu.id_msg)
732 732
 				ORDER BY t.id_topic',
733
-			'fix_processing' => function ($row)
733
+			'fix_processing' => function($row)
734 734
 			{
735 735
 				global $smcFunc;
736 736
 				$row['my_unapproved_posts'] = (int) $row['my_unapproved_posts'];
@@ -770,7 +770,7 @@  discard block
 block discarded – undo
770 770
 				WHERE b.id_board IS NULL
771 771
 					AND t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH}
772 772
 				GROUP BY t.id_board',
773
-			'fix_processing' => function ($row)
773
+			'fix_processing' => function($row)
774 774
 			{
775 775
 				global $smcFunc, $salvageCatID, $txt;
776 776
 				createSalvageArea();
@@ -817,7 +817,7 @@  discard block
 block discarded – undo
817 817
 				ORDER BY b.id_cat, b.id_board',
818 818
 			'fix_collect' => array(
819 819
 				'index' => 'id_cat',
820
-				'process' => function ($cats)
820
+				'process' => function($cats)
821 821
 				{
822 822
 					global $smcFunc, $salvageCatID;
823 823
 					createSalvageArea();
@@ -853,7 +853,7 @@  discard block
 block discarded – undo
853 853
 			// Last step-make sure all non-guest posters still exist.
854 854
 			'fix_collect' => array(
855 855
 				'index' => 'id_msg',
856
-				'process' => function ($msgs)
856
+				'process' => function($msgs)
857 857
 				{
858 858
 					global $smcFunc;
859 859
 					$smcFunc['db_query']('', '
@@ -880,7 +880,7 @@  discard block
 block discarded – undo
880 880
 				ORDER BY b.id_parent, b.id_board',
881 881
 			'fix_collect' => array(
882 882
 				'index' => 'id_parent',
883
-				'process' => function ($parents)
883
+				'process' => function($parents)
884 884
 				{
885 885
 					global $smcFunc, $salvageBoardID, $salvageCatID;
886 886
 
@@ -917,7 +917,7 @@  discard block
 block discarded – undo
917 917
 					AND p.id_poll IS NULL',
918 918
 			'fix_collect' => array(
919 919
 				'index' => 'id_poll',
920
-				'process' => function ($polls)
920
+				'process' => function($polls)
921 921
 				{
922 922
 					global $smcFunc;
923 923
 					$smcFunc['db_query']('', '
@@ -949,7 +949,7 @@  discard block
 block discarded – undo
949 949
 				ORDER BY cal.id_topic',
950 950
 			'fix_collect' => array(
951 951
 				'index' => 'id_topic',
952
-				'process' => function ($events)
952
+				'process' => function($events)
953 953
 				{
954 954
 					global $smcFunc;
955 955
 					$smcFunc['db_query']('', '
@@ -979,7 +979,7 @@  discard block
 block discarded – undo
979 979
 					AND lt.id_member BETWEEN {STEP_LOW} AND {STEP_HIGH}',
980 980
 			'fix_collect' => array(
981 981
 				'index' => 'id_topic',
982
-				'process' => function ($topics)
982
+				'process' => function($topics)
983 983
 				{
984 984
 					global $smcFunc;
985 985
 					$smcFunc['db_query']('', '
@@ -1009,7 +1009,7 @@  discard block
 block discarded – undo
1009 1009
 				GROUP BY lt.id_member',
1010 1010
 			'fix_collect' => array(
1011 1011
 				'index' => 'id_member',
1012
-				'process' => function ($members)
1012
+				'process' => function($members)
1013 1013
 				{
1014 1014
 					global $smcFunc;
1015 1015
 					$smcFunc['db_query']('', '
@@ -1039,7 +1039,7 @@  discard block
 block discarded – undo
1039 1039
 				GROUP BY lb.id_board',
1040 1040
 			'fix_collect' => array(
1041 1041
 				'index' => 'id_board',
1042
-				'process' => function ($boards)
1042
+				'process' => function($boards)
1043 1043
 				{
1044 1044
 					global $smcFunc;
1045 1045
 					$smcFunc['db_query']('', '
@@ -1069,7 +1069,7 @@  discard block
 block discarded – undo
1069 1069
 				GROUP BY lb.id_member',
1070 1070
 			'fix_collect' => array(
1071 1071
 				'index' => 'id_member',
1072
-				'process' => function ($members) use ($smcFunc)
1072
+				'process' => function($members) use ($smcFunc)
1073 1073
 				{
1074 1074
 					$smcFunc['db_query']('', '
1075 1075
 						DELETE FROM {db_prefix}log_boards
@@ -1098,7 +1098,7 @@  discard block
 block discarded – undo
1098 1098
 				GROUP BY lmr.id_board',
1099 1099
 			'fix_collect' => array(
1100 1100
 				'index' => 'id_board',
1101
-				'process' => function ($boards) use ($smcFunc)
1101
+				'process' => function($boards) use ($smcFunc)
1102 1102
 				{
1103 1103
 					$smcFunc['db_query']('', '
1104 1104
 						DELETE FROM {db_prefix}log_mark_read
@@ -1127,7 +1127,7 @@  discard block
 block discarded – undo
1127 1127
 				GROUP BY lmr.id_member',
1128 1128
 			'fix_collect' => array(
1129 1129
 				'index' => 'id_member',
1130
-				'process' => function ($members) use ($smcFunc)
1130
+				'process' => function($members) use ($smcFunc)
1131 1131
 				{
1132 1132
 					$smcFunc['db_query']('', '
1133 1133
 						DELETE FROM {db_prefix}log_mark_read
@@ -1156,7 +1156,7 @@  discard block
 block discarded – undo
1156 1156
 				GROUP BY pmr.id_pm',
1157 1157
 			'fix_collect' => array(
1158 1158
 				'index' => 'id_pm',
1159
-				'process' => function ($pms) use ($smcFunc)
1159
+				'process' => function($pms) use ($smcFunc)
1160 1160
 				{
1161 1161
 					$smcFunc['db_query']('', '
1162 1162
 						DELETE FROM {db_prefix}pm_recipients
@@ -1186,7 +1186,7 @@  discard block
 block discarded – undo
1186 1186
 				GROUP BY pmr.id_member',
1187 1187
 			'fix_collect' => array(
1188 1188
 				'index' => 'id_member',
1189
-				'process' => function ($members)
1189
+				'process' => function($members)
1190 1190
 				{
1191 1191
 					global $smcFunc;
1192 1192
 					$smcFunc['db_query']('', '
@@ -1216,7 +1216,7 @@  discard block
 block discarded – undo
1216 1216
 					AND mem.id_member IS NULL',
1217 1217
 			'fix_collect' => array(
1218 1218
 				'index' => 'id_pm',
1219
-				'process' => function ($guestMessages)
1219
+				'process' => function($guestMessages)
1220 1220
 				{
1221 1221
 					global $smcFunc;
1222 1222
 					$smcFunc['db_query']('', '
@@ -1246,7 +1246,7 @@  discard block
 block discarded – undo
1246 1246
 				GROUP BY ln.id_member',
1247 1247
 			'fix_collect' => array(
1248 1248
 				'index' => 'id_member',
1249
-				'process' => function ($members) use ($smcFunc)
1249
+				'process' => function($members) use ($smcFunc)
1250 1250
 				{
1251 1251
 					$smcFunc['db_query']('', '
1252 1252
 						DELETE FROM {db_prefix}log_notify
@@ -1273,7 +1273,7 @@  discard block
 block discarded – undo
1273 1273
 					LEFT JOIN {db_prefix}log_search_subjects AS lss ON (lss.id_topic = t.id_topic)
1274 1274
 				WHERE t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH}
1275 1275
 					AND lss.id_topic IS NULL',
1276
-			'fix_full_processing' => function ($result)
1276
+			'fix_full_processing' => function($result)
1277 1277
 			{
1278 1278
 				global $smcFunc;
1279 1279
 
@@ -1302,7 +1302,7 @@  discard block
 block discarded – undo
1302 1302
 						array('word', 'id_topic')
1303 1303
 					);
1304 1304
 			},
1305
-			'message_function' => function ($row)
1305
+			'message_function' => function($row)
1306 1306
 			{
1307 1307
 				global $txt, $context;
1308 1308
 
@@ -1330,7 +1330,7 @@  discard block
 block discarded – undo
1330 1330
 					AND t.id_topic IS NULL',
1331 1331
 			'fix_collect' => array(
1332 1332
 				'index' => 'id_topic',
1333
-				'process' => function ($deleteTopics)
1333
+				'process' => function($deleteTopics)
1334 1334
 				{
1335 1335
 					global $smcFunc;
1336 1336
 					$smcFunc['db_query']('', '
@@ -1360,7 +1360,7 @@  discard block
 block discarded – undo
1360 1360
 					AND mem.id_member IS NULL',
1361 1361
 			'fix_collect' => array(
1362 1362
 				'index' => 'id_member',
1363
-				'process' => function ($members)
1363
+				'process' => function($members)
1364 1364
 				{
1365 1365
 					global $smcFunc;
1366 1366
 					$smcFunc['db_query']('', '
@@ -1389,7 +1389,7 @@  discard block
 block discarded – undo
1389 1389
 					AND p.id_poll IS NULL',
1390 1390
 			'fix_collect' => array(
1391 1391
 				'index' => 'id_poll',
1392
-				'process' => function ($polls)
1392
+				'process' => function($polls)
1393 1393
 				{
1394 1394
 					global $smcFunc;
1395 1395
 					$smcFunc['db_query']('', '
@@ -1418,7 +1418,7 @@  discard block
 block discarded – undo
1418 1418
 					AND lrc.id_report IS NULL',
1419 1419
 			'fix_collect' => array(
1420 1420
 				'index' => 'id_report',
1421
-				'process' => function ($reports)
1421
+				'process' => function($reports)
1422 1422
 				{
1423 1423
 					global $smcFunc;
1424 1424
 					$smcFunc['db_query']('', '
@@ -1447,7 +1447,7 @@  discard block
 block discarded – undo
1447 1447
 					AND lr.id_report IS NULL',
1448 1448
 			'fix_collect' => array(
1449 1449
 				'index' => 'id_report',
1450
-				'process' => function ($reports)
1450
+				'process' => function($reports)
1451 1451
 				{
1452 1452
 					global $smcFunc;
1453 1453
 					$smcFunc['db_query']('', '
@@ -1477,7 +1477,7 @@  discard block
 block discarded – undo
1477 1477
 				GROUP BY lgr.id_member',
1478 1478
 			'fix_collect' => array(
1479 1479
 				'index' => 'id_member',
1480
-				'process' => function ($members)
1480
+				'process' => function($members)
1481 1481
 				{
1482 1482
 					global $smcFunc;
1483 1483
 					$smcFunc['db_query']('', '
@@ -1507,7 +1507,7 @@  discard block
 block discarded – undo
1507 1507
 				GROUP BY lgr.id_group',
1508 1508
 			'fix_collect' => array(
1509 1509
 				'index' => 'id_group',
1510
-				'process' => function ($groups)
1510
+				'process' => function($groups)
1511 1511
 				{
1512 1512
 					global $smcFunc;
1513 1513
 					$smcFunc['db_query']('', '
Please login to merge, or discard this patch.
Braces   +119 added lines, -85 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
  * Finds or repairs errors in the database to fix possible problems.
@@ -50,8 +51,9 @@  discard block
 block discarded – undo
50 51
 	);
51 52
 
52 53
 	// Start displaying errors without fixing them.
53
-	if (isset($_GET['fixErrors']))
54
-		checkSession('get');
54
+	if (isset($_GET['fixErrors'])) {
55
+			checkSession('get');
56
+	}
55 57
 
56 58
 	// Will want this.
57 59
 	loadForumTests();
@@ -69,14 +71,14 @@  discard block
 block discarded – undo
69 71
 			$_SESSION['repairboards_to_fix'] = $context['to_fix'];
70 72
 			$_SESSION['repairboards_to_fix2'] = null;
71 73
 
72
-			if (empty($context['repair_errors']))
73
-				$context['repair_errors'][] = '???';
74
+			if (empty($context['repair_errors'])) {
75
+							$context['repair_errors'][] = '???';
76
+			}
74 77
 		}
75 78
 
76 79
 		// Need a token here.
77 80
 		createToken('admin-repairboards', 'request');
78
-	}
79
-	else
81
+	} else
80 82
 	{
81 83
 		// Validate the token, create a new one and tell the not done template.
82 84
 		validateToken('admin-repairboards', 'request');
@@ -134,16 +136,19 @@  discard block
 block discarded – undo
134 136
 
135 137
 	// More time, I need more time!
136 138
 	@set_time_limit(600);
137
-	if (function_exists('apache_reset_timeout'))
138
-		@apache_reset_timeout();
139
+	if (function_exists('apache_reset_timeout')) {
140
+			@apache_reset_timeout();
141
+	}
139 142
 
140 143
 	// Errr, wait.  How much time has this taken already?
141
-	if (!$force && (time() - $time_start) < 3)
142
-		return;
144
+	if (!$force && (time() - $time_start) < 3) {
145
+			return;
146
+	}
143 147
 
144 148
 	// Restore the query cache if interested.
145
-	if (!empty($db_temp_cache))
146
-		$db_cache = $db_temp_cache;
149
+	if (!empty($db_temp_cache)) {
150
+			$db_cache = $db_temp_cache;
151
+	}
147 152
 
148 153
 	$context['continue_get_data'] = '?action=admin;area=repairboards' . (isset($_GET['fixErrors']) ? ';fixErrors' : '') . ';step=' . $_GET['step'] . ';substep=' . $_GET['substep'] . ';' . $context['session_var'] . '=' . $context['session_id'];
149 154
 	$context['page_title'] = $txt['not_done_title'];
@@ -152,10 +157,11 @@  discard block
 block discarded – undo
152 157
 	$context['sub_template'] = 'not_done';
153 158
 
154 159
 	// Change these two if more steps are added!
155
-	if (empty($max_substep))
156
-		$context['continue_percent'] = round(($_GET['step'] * 100) / $context['total_steps']);
157
-	else
158
-		$context['continue_percent'] = round((($_GET['step'] + ($_GET['substep'] / $max_substep)) * 100) / $context['total_steps']);
160
+	if (empty($max_substep)) {
161
+			$context['continue_percent'] = round(($_GET['step'] * 100) / $context['total_steps']);
162
+	} else {
163
+			$context['continue_percent'] = round((($_GET['step'] + ($_GET['substep'] / $max_substep)) * 100) / $context['total_steps']);
164
+	}
159 165
 
160 166
 	// Never more than 100%!
161 167
 	$context['continue_percent'] = min($context['continue_percent'], 100);
@@ -624,8 +630,9 @@  discard block
 block discarded – undo
624 630
 				$row['myid_last_msg'] = (int) $row['myid_last_msg'];
625 631
 
626 632
 				// Not really a problem?
627
-				if ($row['id_first_msg'] == $row['myid_first_msg'] && $row['id_last_msg'] == $row['myid_last_msg'] && $row['approved'] == $row['firstmsg_approved'])
628
-					return false;
633
+				if ($row['id_first_msg'] == $row['myid_first_msg'] && $row['id_last_msg'] == $row['myid_last_msg'] && $row['approved'] == $row['firstmsg_approved']) {
634
+									return false;
635
+				}
629 636
 
630 637
 				$memberStartedID = (int) getMsgMemberID($row['myid_first_msg']);
631 638
 				$memberUpdatedID = (int) getMsgMemberID($row['myid_last_msg']);
@@ -649,15 +656,19 @@  discard block
 block discarded – undo
649 656
 			'message_function' => function ($row) use ($txt, &$context)
650 657
 			{
651 658
 				// A pretend error?
652
-				if ($row['id_first_msg'] == $row['myid_first_msg'] && $row['id_last_msg'] == $row['myid_last_msg'] && $row['approved'] == $row['firstmsg_approved'])
653
-					return false;
659
+				if ($row['id_first_msg'] == $row['myid_first_msg'] && $row['id_last_msg'] == $row['myid_last_msg'] && $row['approved'] == $row['firstmsg_approved']) {
660
+									return false;
661
+				}
654 662
 
655
-				if ($row['id_first_msg'] != $row['myid_first_msg'])
656
-					$context['repair_errors'][] = sprintf($txt['repair_stats_topics_1'], $row['id_topic'], $row['id_first_msg']);
657
-				if ($row['id_last_msg'] != $row['myid_last_msg'])
658
-					$context['repair_errors'][] = sprintf($txt['repair_stats_topics_2'], $row['id_topic'], $row['id_last_msg']);
659
-				if ($row['approved'] != $row['firstmsg_approved'])
660
-					$context['repair_errors'][] = sprintf($txt['repair_stats_topics_5'], $row['id_topic']);
663
+				if ($row['id_first_msg'] != $row['myid_first_msg']) {
664
+									$context['repair_errors'][] = sprintf($txt['repair_stats_topics_1'], $row['id_topic'], $row['id_first_msg']);
665
+				}
666
+				if ($row['id_last_msg'] != $row['myid_last_msg']) {
667
+									$context['repair_errors'][] = sprintf($txt['repair_stats_topics_2'], $row['id_topic'], $row['id_last_msg']);
668
+				}
669
+				if ($row['approved'] != $row['firstmsg_approved']) {
670
+									$context['repair_errors'][] = sprintf($txt['repair_stats_topics_5'], $row['id_topic']);
671
+				}
661 672
 
662 673
 				return true;
663 674
 			},
@@ -686,8 +697,9 @@  discard block
 block discarded – undo
686 697
 				$row['my_num_replies'] = (int) $row['my_num_replies'];
687 698
 
688 699
 				// Not really a problem?
689
-				if ($row['my_num_replies'] == $row['num_replies'])
690
-					return false;
700
+				if ($row['my_num_replies'] == $row['num_replies']) {
701
+									return false;
702
+				}
691 703
 
692 704
 				$smcFunc['db_query']('', '
693 705
 					UPDATE {db_prefix}topics
@@ -704,11 +716,13 @@  discard block
 block discarded – undo
704 716
 				global $txt, $context;
705 717
 
706 718
 				// Just joking?
707
-				if ($row['my_num_replies'] == $row['num_replies'])
708
-					return false;
719
+				if ($row['my_num_replies'] == $row['num_replies']) {
720
+									return false;
721
+				}
709 722
 
710
-				if ($row['num_replies'] != $row['my_num_replies'])
711
-					$context['repair_errors'][] = sprintf($txt['repair_stats_topics_3'], $row['id_topic'], $row['num_replies']);
723
+				if ($row['num_replies'] != $row['my_num_replies']) {
724
+									$context['repair_errors'][] = sprintf($txt['repair_stats_topics_3'], $row['id_topic'], $row['num_replies']);
725
+				}
712 726
 
713 727
 				return true;
714 728
 			},
@@ -1280,8 +1294,9 @@  discard block
 block discarded – undo
1280 1294
 				$inserts = array();
1281 1295
 				while ($row = $smcFunc['db_fetch_assoc']($result))
1282 1296
 				{
1283
-					foreach (text2words($row['subject']) as $word)
1284
-						$inserts[] = array($word, $row['id_topic']);
1297
+					foreach (text2words($row['subject']) as $word) {
1298
+											$inserts[] = array($word, $row['id_topic']);
1299
+					}
1285 1300
 					if (count($inserts) > 500)
1286 1301
 					{
1287 1302
 						$smcFunc['db_insert']('ignore',
@@ -1294,13 +1309,14 @@  discard block
 block discarded – undo
1294 1309
 					}
1295 1310
 				}
1296 1311
 
1297
-				if (!empty($inserts))
1298
-					$smcFunc['db_insert']('ignore',
1312
+				if (!empty($inserts)) {
1313
+									$smcFunc['db_insert']('ignore',
1299 1314
 						'{db_prefix}log_search_subjects',
1300 1315
 						array('word' => 'string', 'id_topic' => 'int'),
1301 1316
 						$inserts,
1302 1317
 						array('word', 'id_topic')
1303 1318
 					);
1319
+				}
1304 1320
 			},
1305 1321
 			'message_function' => function ($row)
1306 1322
 			{
@@ -1559,8 +1575,9 @@  discard block
 block discarded – undo
1559 1575
 		$current_step++;
1560 1576
 
1561 1577
 		// Already done this?
1562
-		if ($_GET['step'] > $current_step)
1563
-			continue;
1578
+		if ($_GET['step'] > $current_step) {
1579
+					continue;
1580
+		}
1564 1581
 
1565 1582
 		// If we're fixing it but it ain't broke why try?
1566 1583
 		if ($do_fix && !in_array($error_type, $to_fix))
@@ -1589,14 +1606,16 @@  discard block
 block discarded – undo
1589 1606
 		while (!$done)
1590 1607
 		{
1591 1608
 			// Make sure there's at least one ID to test.
1592
-			if (isset($test['substeps']) && empty($step_max))
1593
-				break;
1609
+			if (isset($test['substeps']) && empty($step_max)) {
1610
+							break;
1611
+			}
1594 1612
 
1595 1613
 			// What is the testing query (Changes if we are testing or fixing)
1596
-			if (!$do_fix)
1597
-				$test_query = 'check_query';
1598
-			else
1599
-				$test_query = isset($test['fix_query']) ? 'fix_query' : 'check_query';
1614
+			if (!$do_fix) {
1615
+							$test_query = 'check_query';
1616
+			} else {
1617
+							$test_query = isset($test['fix_query']) ? 'fix_query' : 'check_query';
1618
+			}
1600 1619
 
1601 1620
 			// Do the test...
1602 1621
 			$request = $smcFunc['db_query']('',
@@ -1606,10 +1625,11 @@  discard block
 block discarded – undo
1606 1625
 			);
1607 1626
 
1608 1627
 			// Does it need a fix?
1609
-			if (!empty($test['check_type']) && $test['check_type'] == 'count')
1610
-				list ($needs_fix) = $smcFunc['db_fetch_row']($request);
1611
-			else
1612
-				$needs_fix = $smcFunc['db_num_rows']($request);
1628
+			if (!empty($test['check_type']) && $test['check_type'] == 'count') {
1629
+							list ($needs_fix) = $smcFunc['db_fetch_row']($request);
1630
+			} else {
1631
+							$needs_fix = $smcFunc['db_num_rows']($request);
1632
+			}
1613 1633
 
1614 1634
 			$total_queries++;
1615 1635
 
@@ -1621,8 +1641,9 @@  discard block
 block discarded – undo
1621 1641
 					// Assume need to fix.
1622 1642
 					$found_errors = true;
1623 1643
 
1624
-					if (isset($test['message']))
1625
-						$context['repair_errors'][] = $txt[$test['message']];
1644
+					if (isset($test['message'])) {
1645
+											$context['repair_errors'][] = $txt[$test['message']];
1646
+					}
1626 1647
 
1627 1648
 					// One per row!
1628 1649
 					elseif (isset($test['messages']))
@@ -1632,10 +1653,11 @@  discard block
 block discarded – undo
1632 1653
 							$variables = $test['messages'];
1633 1654
 							foreach ($variables as $k => $v)
1634 1655
 							{
1635
-								if ($k == 0 && isset($txt[$v]))
1636
-									$variables[$k] = $txt[$v];
1637
-								elseif ($k > 0 && isset($row[$v]))
1638
-									$variables[$k] = $row[$v];
1656
+								if ($k == 0 && isset($txt[$v])) {
1657
+																	$variables[$k] = $txt[$v];
1658
+								} elseif ($k > 0 && isset($row[$v])) {
1659
+																	$variables[$k] = $row[$v];
1660
+								}
1639 1661
 							}
1640 1662
 							$context['repair_errors'][] = call_user_func_array('sprintf', $variables);
1641 1663
 						}
@@ -1646,13 +1668,15 @@  discard block
 block discarded – undo
1646 1668
 					{
1647 1669
 						// Find out if there are actually errors.
1648 1670
 						$found_errors = false;
1649
-						while ($row = $smcFunc['db_fetch_assoc']($request))
1650
-							$found_errors |= $test['message_function']($row);
1671
+						while ($row = $smcFunc['db_fetch_assoc']($request)) {
1672
+													$found_errors |= $test['message_function']($row);
1673
+						}
1651 1674
 					}
1652 1675
 
1653 1676
 					// Actually have something to fix?
1654
-					if ($found_errors)
1655
-						$to_fix[] = $error_type;
1677
+					if ($found_errors) {
1678
+											$to_fix[] = $error_type;
1679
+					}
1656 1680
 				}
1657 1681
 
1658 1682
 				// We want to fix, we need to fix - so work out what exactly to do!
@@ -1662,8 +1686,9 @@  discard block
 block discarded – undo
1662 1686
 					if (isset($test['fix_collect']))
1663 1687
 					{
1664 1688
 						$ids = array();
1665
-						while ($row = $smcFunc['db_fetch_assoc']($request))
1666
-							$ids[] = $row[$test['fix_collect']['index']];
1689
+						while ($row = $smcFunc['db_fetch_assoc']($request)) {
1690
+													$ids[] = $row[$test['fix_collect']['index']];
1691
+						}
1667 1692
 						if (!empty($ids))
1668 1693
 						{
1669 1694
 							// Fix it!
@@ -1672,30 +1697,34 @@  discard block
 block discarded – undo
1672 1697
 					}
1673 1698
 
1674 1699
 					// Simply executing a fix it query?
1675
-					elseif (isset($test['fix_it_query']))
1676
-						$smcFunc['db_query']('',
1700
+					elseif (isset($test['fix_it_query'])) {
1701
+											$smcFunc['db_query']('',
1677 1702
 							$test['fix_it_query'],
1678 1703
 							array(
1679 1704
 							)
1680 1705
 						);
1706
+					}
1681 1707
 
1682 1708
 					// Do we have some processing to do?
1683 1709
 					elseif (isset($test['fix_processing']))
1684 1710
 					{
1685
-						while ($row = $smcFunc['db_fetch_assoc']($request))
1686
-							$test['fix_processing']($row);
1711
+						while ($row = $smcFunc['db_fetch_assoc']($request)) {
1712
+													$test['fix_processing']($row);
1713
+						}
1687 1714
 					}
1688 1715
 
1689 1716
 					// What about the full set of processing?
1690
-					elseif (isset($test['fix_full_processing']))
1691
-						$test['fix_full_processing']($request);
1717
+					elseif (isset($test['fix_full_processing'])) {
1718
+											$test['fix_full_processing']($request);
1719
+					}
1692 1720
 
1693 1721
 					// Do we have other things we need to fix as a result?
1694 1722
 					if (!empty($test['force_fix']))
1695 1723
 					{
1696
-						foreach ($test['force_fix'] as $item)
1697
-							if (!in_array($item, $to_fix))
1724
+						foreach ($test['force_fix'] as $item) {
1725
+													if (!in_array($item, $to_fix))
1698 1726
 								$to_fix[] = $item;
1727
+						}
1699 1728
 					}
1700 1729
 				}
1701 1730
 			}
@@ -1713,16 +1742,17 @@  discard block
 block discarded – undo
1713 1742
 				if ($_GET['substep'] <= $step_max)
1714 1743
 				{
1715 1744
 					pauseRepairProcess($to_fix, $error_type, $step_max);
1745
+				} else {
1746
+									$done = true;
1716 1747
 				}
1717
-				else
1718
-					$done = true;
1748
+			} else {
1749
+							$done = true;
1719 1750
 			}
1720
-			else
1721
-				$done = true;
1722 1751
 
1723 1752
 			// Don't allow more than 1000 queries at a time.
1724
-			if ($total_queries >= 1000)
1725
-				pauseRepairProcess($to_fix, $error_type, $step_max, true);
1753
+			if ($total_queries >= 1000) {
1754
+							pauseRepairProcess($to_fix, $error_type, $step_max, true);
1755
+			}
1726 1756
 		}
1727 1757
 
1728 1758
 		// Keep going.
@@ -1735,8 +1765,9 @@  discard block
 block discarded – undo
1735 1765
 		if ($do_fix)
1736 1766
 		{
1737 1767
 			$key = array_search($error_type, $to_fix);
1738
-			if ($key !== false && isset($to_fix[$key]))
1739
-				unset($to_fix[$key]);
1768
+			if ($key !== false && isset($to_fix[$key])) {
1769
+							unset($to_fix[$key]);
1770
+			}
1740 1771
 		}
1741 1772
 
1742 1773
 		// Are we done?
@@ -1759,10 +1790,11 @@  discard block
 block discarded – undo
1759 1790
 	static $createOnce = false;
1760 1791
 
1761 1792
 	// Have we already created it?
1762
-	if ($createOnce)
1763
-		return;
1764
-	else
1765
-		$createOnce = true;
1793
+	if ($createOnce) {
1794
+			return;
1795
+	} else {
1796
+			$createOnce = true;
1797
+	}
1766 1798
 
1767 1799
 	// Back to the forum's default language.
1768 1800
 	loadLanguage('Admin', $language);
@@ -1777,8 +1809,9 @@  discard block
 block discarded – undo
1777 1809
 			'cat_name' => $txt['salvaged_category_name'],
1778 1810
 		)
1779 1811
 	);
1780
-	if ($smcFunc['db_num_rows']($result) != 0)
1781
-		list ($salvageCatID) = $smcFunc['db_fetch_row']($result);
1812
+	if ($smcFunc['db_num_rows']($result) != 0) {
1813
+			list ($salvageCatID) = $smcFunc['db_fetch_row']($result);
1814
+	}
1782 1815
 	$smcFunc['db_free_result']($result);
1783 1816
 
1784 1817
 	if (empty($salvageCatID))
@@ -1810,8 +1843,9 @@  discard block
 block discarded – undo
1810 1843
 			'board_name' => $txt['salvaged_board_name'],
1811 1844
 		)
1812 1845
 	);
1813
-	if ($smcFunc['db_num_rows']($result) != 0)
1814
-		list ($salvageBoardID) = $smcFunc['db_fetch_row']($result);
1846
+	if ($smcFunc['db_num_rows']($result) != 0) {
1847
+			list ($salvageBoardID) = $smcFunc['db_fetch_row']($result);
1848
+	}
1815 1849
 	$smcFunc['db_free_result']($result);
1816 1850
 
1817 1851
 	if (empty($salvageBoardID))
Please login to merge, or discard this patch.
Sources/Security.php 1 patch
Braces   +255 added lines, -197 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 4
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * Check if the user is who he/she says he is
@@ -42,12 +43,14 @@  discard block
 block discarded – undo
42 43
 	$refreshTime = isset($_GET['xml']) ? 4200 : 3600;
43 44
 
44 45
 	// Is the security option off?
45
-	if (!empty($modSettings['securityDisable' . ($type != 'admin' ? '_' . $type : '')]))
46
-		return;
46
+	if (!empty($modSettings['securityDisable' . ($type != 'admin' ? '_' . $type : '')])) {
47
+			return;
48
+	}
47 49
 
48 50
 	// Or are they already logged in?, Moderator or admin session is need for this area
49
-	if ((!empty($_SESSION[$type . '_time']) && $_SESSION[$type . '_time'] + $refreshTime >= time()) || (!empty($_SESSION['admin_time']) && $_SESSION['admin_time'] + $refreshTime >= time()))
50
-		return;
51
+	if ((!empty($_SESSION[$type . '_time']) && $_SESSION[$type . '_time'] + $refreshTime >= time()) || (!empty($_SESSION['admin_time']) && $_SESSION['admin_time'] + $refreshTime >= time())) {
52
+			return;
53
+	}
51 54
 
52 55
 	require_once($sourcedir . '/Subs-Auth.php');
53 56
 
@@ -55,8 +58,9 @@  discard block
 block discarded – undo
55 58
 	if (isset($_POST[$type . '_pass']))
56 59
 	{
57 60
 		// Check to ensure we're forcing SSL for authentication
58
-		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn())
59
-			fatal_lang_error('login_ssl_required');
61
+		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) {
62
+					fatal_lang_error('login_ssl_required');
63
+		}
60 64
 
61 65
 		checkSession();
62 66
 
@@ -72,17 +76,19 @@  discard block
 block discarded – undo
72 76
 	}
73 77
 
74 78
 	// Better be sure to remember the real referer
75
-	if (empty($_SESSION['request_referer']))
76
-		$_SESSION['request_referer'] = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array();
77
-	elseif (empty($_POST))
78
-		unset($_SESSION['request_referer']);
79
+	if (empty($_SESSION['request_referer'])) {
80
+			$_SESSION['request_referer'] = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array();
81
+	} elseif (empty($_POST)) {
82
+			unset($_SESSION['request_referer']);
83
+	}
79 84
 
80 85
 	// Need to type in a password for that, man.
81
-	if (!isset($_GET['xml']))
82
-		adminLogin($type);
83
-	else
84
-		return 'session_verify_fail';
85
-}
86
+	if (!isset($_GET['xml'])) {
87
+			adminLogin($type);
88
+	} else {
89
+			return 'session_verify_fail';
90
+	}
91
+	}
86 92
 
87 93
 /**
88 94
  * Require a user who is logged in. (not a guest.)
@@ -96,25 +102,30 @@  discard block
 block discarded – undo
96 102
 	global $user_info, $txt, $context, $scripturl, $modSettings;
97 103
 
98 104
 	// Luckily, this person isn't a guest.
99
-	if (!$user_info['is_guest'])
100
-		return;
105
+	if (!$user_info['is_guest']) {
106
+			return;
107
+	}
101 108
 
102 109
 	// Log what they were trying to do didn't work)
103
-	if (!empty($modSettings['who_enabled']))
104
-		$_GET['error'] = 'guest_login';
110
+	if (!empty($modSettings['who_enabled'])) {
111
+			$_GET['error'] = 'guest_login';
112
+	}
105 113
 	writeLog(true);
106 114
 
107 115
 	// Just die.
108
-	if (isset($_REQUEST['xml']))
109
-		obExit(false);
116
+	if (isset($_REQUEST['xml'])) {
117
+			obExit(false);
118
+	}
110 119
 
111 120
 	// Attempt to detect if they came from dlattach.
112
-	if (SMF != 'SSI' && empty($context['theme_loaded']))
113
-		loadTheme();
121
+	if (SMF != 'SSI' && empty($context['theme_loaded'])) {
122
+			loadTheme();
123
+	}
114 124
 
115 125
 	// Never redirect to an attachment
116
-	if (strpos($_SERVER['REQUEST_URL'], 'dlattach') === false)
117
-		$_SESSION['login_url'] = $_SERVER['REQUEST_URL'];
126
+	if (strpos($_SERVER['REQUEST_URL'], 'dlattach') === false) {
127
+			$_SESSION['login_url'] = $_SERVER['REQUEST_URL'];
128
+	}
118 129
 
119 130
 	// Load the Login template and language file.
120 131
 	loadLanguage('Login');
@@ -124,8 +135,7 @@  discard block
 block discarded – undo
124 135
 	{
125 136
 		$_SESSION['login_url'] = $scripturl . '?' . $_SERVER['QUERY_STRING'];
126 137
 		redirectexit('action=login');
127
-	}
128
-	else
138
+	} else
129 139
 	{
130 140
 		loadTemplate('Login');
131 141
 		$context['sub_template'] = 'kick_guest';
@@ -155,8 +165,9 @@  discard block
 block discarded – undo
155 165
 	global $sourcedir, $cookiename, $user_settings, $smcFunc;
156 166
 
157 167
 	// You cannot be banned if you are an admin - doesn't help if you log out.
158
-	if ($user_info['is_admin'])
159
-		return;
168
+	if ($user_info['is_admin']) {
169
+			return;
170
+	}
160 171
 
161 172
 	// Only check the ban every so often. (to reduce load.)
162 173
 	if ($forceCheck || !isset($_SESSION['ban']) || empty($modSettings['banLastUpdated']) || ($_SESSION['ban']['last_checked'] < $modSettings['banLastUpdated']) || $_SESSION['ban']['id_member'] != $user_info['id'] || $_SESSION['ban']['ip'] != $user_info['ip'] || $_SESSION['ban']['ip2'] != $user_info['ip2'] || (isset($user_info['email'], $_SESSION['ban']['email']) && $_SESSION['ban']['email'] != $user_info['email']))
@@ -177,8 +188,9 @@  discard block
 block discarded – undo
177 188
 		// Check both IP addresses.
178 189
 		foreach (array('ip', 'ip2') as $ip_number)
179 190
 		{
180
-			if ($ip_number == 'ip2' && $user_info['ip2'] == $user_info['ip'])
181
-				continue;
191
+			if ($ip_number == 'ip2' && $user_info['ip2'] == $user_info['ip']) {
192
+							continue;
193
+			}
182 194
 			$ban_query[] = ' {inet:' . $ip_number . '} BETWEEN bi.ip_low and bi.ip_high';
183 195
 			$ban_query_vars[$ip_number] = $user_info[$ip_number];
184 196
 			// IP was valid, maybe there's also a hostname...
@@ -228,24 +240,28 @@  discard block
 block discarded – undo
228 240
 			// Store every type of ban that applies to you in your session.
229 241
 			while ($row = $smcFunc['db_fetch_assoc']($request))
230 242
 			{
231
-				foreach ($restrictions as $restriction)
232
-					if (!empty($row[$restriction]))
243
+				foreach ($restrictions as $restriction) {
244
+									if (!empty($row[$restriction]))
233 245
 					{
234 246
 						$_SESSION['ban'][$restriction]['reason'] = $row['reason'];
247
+				}
235 248
 						$_SESSION['ban'][$restriction]['ids'][] = $row['id_ban'];
236
-						if (!isset($_SESSION['ban']['expire_time']) || ($_SESSION['ban']['expire_time'] != 0 && ($row['expire_time'] == 0 || $row['expire_time'] > $_SESSION['ban']['expire_time'])))
237
-							$_SESSION['ban']['expire_time'] = $row['expire_time'];
249
+						if (!isset($_SESSION['ban']['expire_time']) || ($_SESSION['ban']['expire_time'] != 0 && ($row['expire_time'] == 0 || $row['expire_time'] > $_SESSION['ban']['expire_time']))) {
250
+													$_SESSION['ban']['expire_time'] = $row['expire_time'];
251
+						}
238 252
 
239
-						if (!$user_info['is_guest'] && $restriction == 'cannot_access' && ($row['id_member'] == $user_info['id'] || $row['email_address'] == $user_info['email']))
240
-							$flag_is_activated = true;
253
+						if (!$user_info['is_guest'] && $restriction == 'cannot_access' && ($row['id_member'] == $user_info['id'] || $row['email_address'] == $user_info['email'])) {
254
+													$flag_is_activated = true;
255
+						}
241 256
 					}
242 257
 			}
243 258
 			$smcFunc['db_free_result']($request);
244 259
 		}
245 260
 
246 261
 		// Mark the cannot_access and cannot_post bans as being 'hit'.
247
-		if (isset($_SESSION['ban']['cannot_access']) || isset($_SESSION['ban']['cannot_post']) || isset($_SESSION['ban']['cannot_login']))
248
-			log_ban(array_merge(isset($_SESSION['ban']['cannot_access']) ? $_SESSION['ban']['cannot_access']['ids'] : array(), isset($_SESSION['ban']['cannot_post']) ? $_SESSION['ban']['cannot_post']['ids'] : array(), isset($_SESSION['ban']['cannot_login']) ? $_SESSION['ban']['cannot_login']['ids'] : array()));
262
+		if (isset($_SESSION['ban']['cannot_access']) || isset($_SESSION['ban']['cannot_post']) || isset($_SESSION['ban']['cannot_login'])) {
263
+					log_ban(array_merge(isset($_SESSION['ban']['cannot_access']) ? $_SESSION['ban']['cannot_access']['ids'] : array(), isset($_SESSION['ban']['cannot_post']) ? $_SESSION['ban']['cannot_post']['ids'] : array(), isset($_SESSION['ban']['cannot_login']) ? $_SESSION['ban']['cannot_login']['ids'] : array()));
264
+		}
249 265
 
250 266
 		// If for whatever reason the is_activated flag seems wrong, do a little work to clear it up.
251 267
 		if ($user_info['id'] && (($user_settings['is_activated'] >= 10 && !$flag_is_activated)
@@ -260,8 +276,9 @@  discard block
 block discarded – undo
260 276
 	if (!isset($_SESSION['ban']['cannot_access']) && !empty($_COOKIE[$cookiename . '_']))
261 277
 	{
262 278
 		$bans = explode(',', $_COOKIE[$cookiename . '_']);
263
-		foreach ($bans as $key => $value)
264
-			$bans[$key] = (int) $value;
279
+		foreach ($bans as $key => $value) {
280
+					$bans[$key] = (int) $value;
281
+		}
265 282
 		$request = $smcFunc['db_query']('', '
266 283
 			SELECT bi.id_ban, bg.reason, COALESCE(bg.expire_time, 0) AS expire_time
267 284
 			FROM {db_prefix}ban_items AS bi
@@ -298,14 +315,15 @@  discard block
 block discarded – undo
298 315
 	if (isset($_SESSION['ban']['cannot_access']))
299 316
 	{
300 317
 		// We don't wanna see you!
301
-		if (!$user_info['is_guest'])
302
-			$smcFunc['db_query']('', '
318
+		if (!$user_info['is_guest']) {
319
+					$smcFunc['db_query']('', '
303 320
 				DELETE FROM {db_prefix}log_online
304 321
 				WHERE id_member = {int:current_member}',
305 322
 				array(
306 323
 					'current_member' => $user_info['id'],
307 324
 				)
308 325
 			);
326
+		}
309 327
 
310 328
 		// 'Log' the user out.  Can't have any funny business... (save the name!)
311 329
 		$old_name = isset($user_info['name']) && $user_info['name'] != '' ? $user_info['name'] : $txt['guest_title'];
@@ -391,9 +409,10 @@  discard block
 block discarded – undo
391 409
 	}
392 410
 
393 411
 	// Fix up the banning permissions.
394
-	if (isset($user_info['permissions']))
395
-		banPermissions();
396
-}
412
+	if (isset($user_info['permissions'])) {
413
+			banPermissions();
414
+	}
415
+	}
397 416
 
398 417
 /**
399 418
  * Fix permissions according to ban status.
@@ -404,8 +423,9 @@  discard block
 block discarded – undo
404 423
 	global $user_info, $sourcedir, $modSettings, $context;
405 424
 
406 425
 	// Somehow they got here, at least take away all permissions...
407
-	if (isset($_SESSION['ban']['cannot_access']))
408
-		$user_info['permissions'] = array();
426
+	if (isset($_SESSION['ban']['cannot_access'])) {
427
+			$user_info['permissions'] = array();
428
+	}
409 429
 	// Okay, well, you can watch, but don't touch a thing.
410 430
 	elseif (isset($_SESSION['ban']['cannot_post']) || (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $user_info['warning']))
411 431
 	{
@@ -447,19 +467,20 @@  discard block
 block discarded – undo
447 467
 		call_integration_hook('integrate_warn_permissions', array(&$permission_change));
448 468
 		foreach ($permission_change as $old => $new)
449 469
 		{
450
-			if (!in_array($old, $user_info['permissions']))
451
-				unset($permission_change[$old]);
452
-			else
453
-				$user_info['permissions'][] = $new;
470
+			if (!in_array($old, $user_info['permissions'])) {
471
+							unset($permission_change[$old]);
472
+			} else {
473
+							$user_info['permissions'][] = $new;
474
+			}
454 475
 		}
455 476
 		$user_info['permissions'] = array_diff($user_info['permissions'], array_keys($permission_change));
456 477
 	}
457 478
 
458 479
 	// @todo Find a better place to call this? Needs to be after permissions loaded!
459 480
 	// Finally, some bits we cache in the session because it saves queries.
460
-	if (isset($_SESSION['mc']) && $_SESSION['mc']['time'] > $modSettings['settings_updated'] && $_SESSION['mc']['id'] == $user_info['id'])
461
-		$user_info['mod_cache'] = $_SESSION['mc'];
462
-	else
481
+	if (isset($_SESSION['mc']) && $_SESSION['mc']['time'] > $modSettings['settings_updated'] && $_SESSION['mc']['id'] == $user_info['id']) {
482
+			$user_info['mod_cache'] = $_SESSION['mc'];
483
+	} else
463 484
 	{
464 485
 		require_once($sourcedir . '/Subs-Auth.php');
465 486
 		rebuildModCache();
@@ -470,14 +491,12 @@  discard block
 block discarded – undo
470 491
 	{
471 492
 		$context['open_mod_reports'] = $_SESSION['rc']['reports'];
472 493
 		$context['open_member_reports'] = $_SESSION['rc']['member_reports'];
473
-	}
474
-	elseif ($_SESSION['mc']['bq'] != '0=1')
494
+	} elseif ($_SESSION['mc']['bq'] != '0=1')
475 495
 	{
476 496
 		require_once($sourcedir . '/Subs-ReportedContent.php');
477 497
 		$context['open_mod_reports'] = recountOpenReports('posts');
478 498
 		$context['open_member_reports'] = recountOpenReports('members');
479
-	}
480
-	else
499
+	} else
481 500
 	{
482 501
 		$context['open_mod_reports'] = 0;
483 502
 		$context['open_member_reports'] = 0;
@@ -497,8 +516,9 @@  discard block
 block discarded – undo
497 516
 	global $user_info, $smcFunc;
498 517
 
499 518
 	// Don't log web accelerators, it's very confusing...
500
-	if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch')
501
-		return;
519
+	if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') {
520
+			return;
521
+	}
502 522
 
503 523
 	$smcFunc['db_insert']('',
504 524
 		'{db_prefix}log_banned',
@@ -508,8 +528,8 @@  discard block
 block discarded – undo
508 528
 	);
509 529
 
510 530
 	// One extra point for these bans.
511
-	if (!empty($ban_ids))
512
-		$smcFunc['db_query']('', '
531
+	if (!empty($ban_ids)) {
532
+			$smcFunc['db_query']('', '
513 533
 			UPDATE {db_prefix}ban_items
514 534
 			SET hits = hits + 1
515 535
 			WHERE id_ban IN ({array_int:ban_ids})',
@@ -517,7 +537,8 @@  discard block
 block discarded – undo
517 537
 				'ban_ids' => $ban_ids,
518 538
 			)
519 539
 		);
520
-}
540
+	}
541
+	}
521 542
 
522 543
 /**
523 544
  * Checks if a given email address might be banned.
@@ -533,8 +554,9 @@  discard block
 block discarded – undo
533 554
 	global $txt, $smcFunc;
534 555
 
535 556
 	// Can't ban an empty email
536
-	if (empty($email) || trim($email) == '')
537
-		return;
557
+	if (empty($email) || trim($email) == '') {
558
+			return;
559
+	}
538 560
 
539 561
 	// Let's start with the bans based on your IP/hostname/memberID...
540 562
 	$ban_ids = isset($_SESSION['ban'][$restriction]) ? $_SESSION['ban'][$restriction]['ids'] : array();
@@ -607,16 +629,18 @@  discard block
 block discarded – undo
607 629
 	if ($type == 'post')
608 630
 	{
609 631
 		$check = isset($_POST[$_SESSION['session_var']]) ? $_POST[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_POST['sc']) ? $_POST['sc'] : null);
610
-		if ($check !== $sc)
611
-			$error = 'session_timeout';
632
+		if ($check !== $sc) {
633
+					$error = 'session_timeout';
634
+		}
612 635
 	}
613 636
 
614 637
 	// How about $_GET['sesc']?
615 638
 	elseif ($type == 'get')
616 639
 	{
617 640
 		$check = isset($_GET[$_SESSION['session_var']]) ? $_GET[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_GET['sesc']) ? $_GET['sesc'] : null);
618
-		if ($check !== $sc)
619
-			$error = 'session_verify_fail';
641
+		if ($check !== $sc) {
642
+					$error = 'session_verify_fail';
643
+		}
620 644
 	}
621 645
 
622 646
 	// Or can it be in either?
@@ -624,13 +648,15 @@  discard block
 block discarded – undo
624 648
 	{
625 649
 		$check = isset($_GET[$_SESSION['session_var']]) ? $_GET[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_GET['sesc']) ? $_GET['sesc'] : (isset($_POST[$_SESSION['session_var']]) ? $_POST[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_POST['sc']) ? $_POST['sc'] : null)));
626 650
 
627
-		if ($check !== $sc)
628
-			$error = 'session_verify_fail';
651
+		if ($check !== $sc) {
652
+					$error = 'session_verify_fail';
653
+		}
629 654
 	}
630 655
 
631 656
 	// Verify that they aren't changing user agents on us - that could be bad.
632
-	if ((!isset($_SESSION['USER_AGENT']) || $_SESSION['USER_AGENT'] != $_SERVER['HTTP_USER_AGENT']) && empty($modSettings['disableCheckUA']))
633
-		$error = 'session_verify_fail';
657
+	if ((!isset($_SESSION['USER_AGENT']) || $_SESSION['USER_AGENT'] != $_SERVER['HTTP_USER_AGENT']) && empty($modSettings['disableCheckUA'])) {
658
+			$error = 'session_verify_fail';
659
+	}
634 660
 
635 661
 	// Make sure a page with session check requirement is not being prefetched.
636 662
 	if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch')
@@ -641,30 +667,35 @@  discard block
 block discarded – undo
641 667
 	}
642 668
 
643 669
 	// Check the referring site - it should be the same server at least!
644
-	if (isset($_SESSION['request_referer']))
645
-		$referrer = $_SESSION['request_referer'];
646
-	else
647
-		$referrer = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array();
670
+	if (isset($_SESSION['request_referer'])) {
671
+			$referrer = $_SESSION['request_referer'];
672
+	} else {
673
+			$referrer = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array();
674
+	}
648 675
 	if (!empty($referrer['host']))
649 676
 	{
650
-		if (strpos($_SERVER['HTTP_HOST'], ':') !== false)
651
-			$real_host = substr($_SERVER['HTTP_HOST'], 0, strpos($_SERVER['HTTP_HOST'], ':'));
652
-		else
653
-			$real_host = $_SERVER['HTTP_HOST'];
677
+		if (strpos($_SERVER['HTTP_HOST'], ':') !== false) {
678
+					$real_host = substr($_SERVER['HTTP_HOST'], 0, strpos($_SERVER['HTTP_HOST'], ':'));
679
+		} else {
680
+					$real_host = $_SERVER['HTTP_HOST'];
681
+		}
654 682
 
655 683
 		$parsed_url = parse_url($boardurl);
656 684
 
657 685
 		// Are global cookies on?  If so, let's check them ;).
658 686
 		if (!empty($modSettings['globalCookies']))
659 687
 		{
660
-			if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $parsed_url['host'], $parts) == 1)
661
-				$parsed_url['host'] = $parts[1];
688
+			if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $parsed_url['host'], $parts) == 1) {
689
+							$parsed_url['host'] = $parts[1];
690
+			}
662 691
 
663
-			if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $referrer['host'], $parts) == 1)
664
-				$referrer['host'] = $parts[1];
692
+			if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $referrer['host'], $parts) == 1) {
693
+							$referrer['host'] = $parts[1];
694
+			}
665 695
 
666
-			if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $real_host, $parts) == 1)
667
-				$real_host = $parts[1];
696
+			if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $real_host, $parts) == 1) {
697
+							$real_host = $parts[1];
698
+			}
668 699
 		}
669 700
 
670 701
 		// Okay: referrer must either match parsed_url or real_host.
@@ -682,12 +713,14 @@  discard block
 block discarded – undo
682 713
 		$log_error = true;
683 714
 	}
684 715
 
685
-	if (strtolower($_SERVER['HTTP_USER_AGENT']) == 'hacker')
686
-		fatal_error('Sound the alarm!  It\'s a hacker!  Close the castle gates!!', false);
716
+	if (strtolower($_SERVER['HTTP_USER_AGENT']) == 'hacker') {
717
+			fatal_error('Sound the alarm!  It\'s a hacker!  Close the castle gates!!', false);
718
+	}
687 719
 
688 720
 	// Everything is ok, return an empty string.
689
-	if (!isset($error))
690
-		return '';
721
+	if (!isset($error)) {
722
+			return '';
723
+	}
691 724
 	// A session error occurred, show the error.
692 725
 	elseif ($is_fatal)
693 726
 	{
@@ -696,13 +729,14 @@  discard block
 block discarded – undo
696 729
 			ob_end_clean();
697 730
 			send_http_status(403, 'Forbidden - Session timeout');
698 731
 			die;
732
+		} else {
733
+					fatal_lang_error($error, isset($log_error) ? 'user' : false);
699 734
 		}
700
-		else
701
-			fatal_lang_error($error, isset($log_error) ? 'user' : false);
702 735
 	}
703 736
 	// A session error occurred, return the error to the calling function.
704
-	else
705
-		return $error;
737
+	else {
738
+			return $error;
739
+	}
706 740
 
707 741
 	// We really should never fall through here, for very important reasons.  Let's make sure.
708 742
 	trigger_error('Hacking attempt...', E_USER_ERROR);
@@ -718,10 +752,9 @@  discard block
 block discarded – undo
718 752
 {
719 753
 	global $modSettings;
720 754
 
721
-	if (isset($_GET['confirm']) && isset($_SESSION['confirm_' . $action]) && md5($_GET['confirm'] . $_SERVER['HTTP_USER_AGENT']) == $_SESSION['confirm_' . $action])
722
-		return true;
723
-
724
-	else
755
+	if (isset($_GET['confirm']) && isset($_SESSION['confirm_' . $action]) && md5($_GET['confirm'] . $_SERVER['HTTP_USER_AGENT']) == $_SESSION['confirm_' . $action]) {
756
+			return true;
757
+	} else
725 758
 	{
726 759
 		$token = md5(mt_rand() . session_id() . (string) microtime() . $modSettings['rand_seed']);
727 760
 		$_SESSION['confirm_' . $action] = md5($token . $_SERVER['HTTP_USER_AGENT']);
@@ -772,9 +805,9 @@  discard block
 block discarded – undo
772 805
 			$return = $_SESSION['token'][$type . '-' . $action][3];
773 806
 			unset($_SESSION['token'][$type . '-' . $action]);
774 807
 			return $return;
808
+		} else {
809
+					return '';
775 810
 		}
776
-		else
777
-			return '';
778 811
 	}
779 812
 
780 813
 	// This nasty piece of code validates a token.
@@ -805,12 +838,14 @@  discard block
 block discarded – undo
805 838
 		fatal_lang_error('token_verify_fail', false);
806 839
 	}
807 840
 	// Remove this token as its useless
808
-	else
809
-		unset($_SESSION['token'][$type . '-' . $action]);
841
+	else {
842
+			unset($_SESSION['token'][$type . '-' . $action]);
843
+	}
810 844
 
811 845
 	// Randomly check if we should remove some older tokens.
812
-	if (mt_rand(0, 138) == 23)
813
-		cleanTokens();
846
+	if (mt_rand(0, 138) == 23) {
847
+			cleanTokens();
848
+	}
814 849
 
815 850
 	return false;
816 851
 }
@@ -825,14 +860,16 @@  discard block
 block discarded – undo
825 860
 function cleanTokens($complete = false)
826 861
 {
827 862
 	// We appreciate cleaning up after yourselves.
828
-	if (!isset($_SESSION['token']))
829
-		return;
863
+	if (!isset($_SESSION['token'])) {
864
+			return;
865
+	}
830 866
 
831 867
 	// Clean up tokens, trying to give enough time still.
832
-	foreach ($_SESSION['token'] as $key => $data)
833
-		if ($data[2] + 10800 < time() || $complete)
868
+	foreach ($_SESSION['token'] as $key => $data) {
869
+			if ($data[2] + 10800 < time() || $complete)
834 870
 			unset($_SESSION['token'][$key]);
835
-}
871
+	}
872
+	}
836 873
 
837 874
 /**
838 875
  * Check whether a form has been submitted twice.
@@ -850,37 +887,40 @@  discard block
 block discarded – undo
850 887
 {
851 888
 	global $context;
852 889
 
853
-	if (!isset($_SESSION['forms']))
854
-		$_SESSION['forms'] = array();
890
+	if (!isset($_SESSION['forms'])) {
891
+			$_SESSION['forms'] = array();
892
+	}
855 893
 
856 894
 	// Register a form number and store it in the session stack. (use this on the page that has the form.)
857 895
 	if ($action == 'register')
858 896
 	{
859 897
 		$context['form_sequence_number'] = 0;
860
-		while (empty($context['form_sequence_number']) || in_array($context['form_sequence_number'], $_SESSION['forms']))
861
-			$context['form_sequence_number'] = mt_rand(1, 16000000);
898
+		while (empty($context['form_sequence_number']) || in_array($context['form_sequence_number'], $_SESSION['forms'])) {
899
+					$context['form_sequence_number'] = mt_rand(1, 16000000);
900
+		}
862 901
 	}
863 902
 	// Check whether the submitted number can be found in the session.
864 903
 	elseif ($action == 'check')
865 904
 	{
866
-		if (!isset($_REQUEST['seqnum']))
867
-			return true;
868
-		elseif (!in_array($_REQUEST['seqnum'], $_SESSION['forms']))
905
+		if (!isset($_REQUEST['seqnum'])) {
906
+					return true;
907
+		} elseif (!in_array($_REQUEST['seqnum'], $_SESSION['forms']))
869 908
 		{
870 909
 			$_SESSION['forms'][] = (int) $_REQUEST['seqnum'];
871 910
 			return true;
911
+		} elseif ($is_fatal) {
912
+					fatal_lang_error('error_form_already_submitted', false);
913
+		} else {
914
+					return false;
872 915
 		}
873
-		elseif ($is_fatal)
874
-			fatal_lang_error('error_form_already_submitted', false);
875
-		else
876
-			return false;
877 916
 	}
878 917
 	// Don't check, just free the stack number.
879
-	elseif ($action == 'free' && isset($_REQUEST['seqnum']) && in_array($_REQUEST['seqnum'], $_SESSION['forms']))
880
-		$_SESSION['forms'] = array_diff($_SESSION['forms'], array($_REQUEST['seqnum']));
881
-	elseif ($action != 'free')
882
-		trigger_error('checkSubmitOnce(): Invalid action \'' . $action . '\'', E_USER_WARNING);
883
-}
918
+	elseif ($action == 'free' && isset($_REQUEST['seqnum']) && in_array($_REQUEST['seqnum'], $_SESSION['forms'])) {
919
+			$_SESSION['forms'] = array_diff($_SESSION['forms'], array($_REQUEST['seqnum']));
920
+	} elseif ($action != 'free') {
921
+			trigger_error('checkSubmitOnce(): Invalid action \'' . $action . '\'', E_USER_WARNING);
922
+	}
923
+	}
884 924
 
885 925
 /**
886 926
  * Check the user's permissions.
@@ -899,16 +939,19 @@  discard block
 block discarded – undo
899 939
 	global $user_info, $smcFunc;
900 940
 
901 941
 	// You're always allowed to do nothing. (unless you're a working man, MR. LAZY :P!)
902
-	if (empty($permission))
903
-		return true;
942
+	if (empty($permission)) {
943
+			return true;
944
+	}
904 945
 
905 946
 	// You're never allowed to do something if your data hasn't been loaded yet!
906
-	if (empty($user_info))
907
-		return false;
947
+	if (empty($user_info)) {
948
+			return false;
949
+	}
908 950
 
909 951
 	// Administrators are supermen :P.
910
-	if ($user_info['is_admin'])
911
-		return true;
952
+	if ($user_info['is_admin']) {
953
+			return true;
954
+	}
912 955
 
913 956
 	// Let's ensure this is an array.
914 957
 	$permission = (array) $permission;
@@ -916,14 +959,16 @@  discard block
 block discarded – undo
916 959
 	// Are we checking the _current_ board, or some other boards?
917 960
 	if ($boards === null)
918 961
 	{
919
-		if (count(array_intersect($permission, $user_info['permissions'])) != 0)
920
-			return true;
962
+		if (count(array_intersect($permission, $user_info['permissions'])) != 0) {
963
+					return true;
964
+		}
921 965
 		// You aren't allowed, by default.
922
-		else
923
-			return false;
966
+		else {
967
+					return false;
968
+		}
969
+	} elseif (!is_array($boards)) {
970
+			$boards = array($boards);
924 971
 	}
925
-	elseif (!is_array($boards))
926
-		$boards = array($boards);
927 972
 
928 973
 	$request = $smcFunc['db_query']('', '
929 974
 		SELECT MIN(bp.add_deny) AS add_deny
@@ -951,20 +996,23 @@  discard block
 block discarded – undo
951 996
 		while ($row = $smcFunc['db_fetch_assoc']($request))
952 997
 		{
953 998
 			$result = !empty($row['add_deny']);
954
-			if ($result == true)
955
-				break;
999
+			if ($result == true) {
1000
+							break;
1001
+			}
956 1002
 		}
957 1003
 		$smcFunc['db_free_result']($request);
958 1004
 		return $result;
959 1005
 	}
960 1006
 
961 1007
 	// Make sure they can do it on all of the boards.
962
-	if ($smcFunc['db_num_rows']($request) != count($boards))
963
-		return false;
1008
+	if ($smcFunc['db_num_rows']($request) != count($boards)) {
1009
+			return false;
1010
+	}
964 1011
 
965 1012
 	$result = true;
966
-	while ($row = $smcFunc['db_fetch_assoc']($request))
967
-		$result &= !empty($row['add_deny']);
1013
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1014
+			$result &= !empty($row['add_deny']);
1015
+	}
968 1016
 	$smcFunc['db_free_result']($request);
969 1017
 
970 1018
 	// If the query returned 1, they can do it... otherwise, they can't.
@@ -1031,9 +1079,10 @@  discard block
 block discarded – undo
1031 1079
 
1032 1080
 	// If you're doing something on behalf of some "heavy" permissions, validate your session.
1033 1081
 	// (take out the heavy permissions, and if you can't do anything but those, you need a validated session.)
1034
-	if (!allowedTo(array_diff($permission, $heavy_permissions), $boards))
1035
-		validateSession();
1036
-}
1082
+	if (!allowedTo(array_diff($permission, $heavy_permissions), $boards)) {
1083
+			validateSession();
1084
+	}
1085
+	}
1037 1086
 
1038 1087
 /**
1039 1088
  * Return the boards a user has a certain (board) permission on. (array(0) if all.)
@@ -1064,13 +1113,14 @@  discard block
 block discarded – undo
1064 1113
 	// Administrators are all powerful, sorry.
1065 1114
 	if ($user_info['is_admin'])
1066 1115
 	{
1067
-		if ($simple)
1068
-			return array(0);
1069
-		else
1116
+		if ($simple) {
1117
+					return array(0);
1118
+		} else
1070 1119
 		{
1071 1120
 			$boards = array();
1072
-			foreach ($permissions as $permission)
1073
-				$boards[$permission] = array(0);
1121
+			foreach ($permissions as $permission) {
1122
+							$boards[$permission] = array(0);
1123
+			}
1074 1124
 
1075 1125
 			return $boards;
1076 1126
 		}
@@ -1102,31 +1152,32 @@  discard block
 block discarded – undo
1102 1152
 	{
1103 1153
 		if ($simple)
1104 1154
 		{
1105
-			if (empty($row['add_deny']))
1106
-				$deny_boards[] = $row['id_board'];
1107
-			else
1108
-				$boards[] = $row['id_board'];
1109
-		}
1110
-		else
1155
+			if (empty($row['add_deny'])) {
1156
+							$deny_boards[] = $row['id_board'];
1157
+			} else {
1158
+							$boards[] = $row['id_board'];
1159
+			}
1160
+		} else
1111 1161
 		{
1112
-			if (empty($row['add_deny']))
1113
-				$deny_boards[$row['permission']][] = $row['id_board'];
1114
-			else
1115
-				$boards[$row['permission']][] = $row['id_board'];
1162
+			if (empty($row['add_deny'])) {
1163
+							$deny_boards[$row['permission']][] = $row['id_board'];
1164
+			} else {
1165
+							$boards[$row['permission']][] = $row['id_board'];
1166
+			}
1116 1167
 		}
1117 1168
 	}
1118 1169
 	$smcFunc['db_free_result']($request);
1119 1170
 
1120
-	if ($simple)
1121
-		$boards = array_unique(array_values(array_diff($boards, $deny_boards)));
1122
-	else
1171
+	if ($simple) {
1172
+			$boards = array_unique(array_values(array_diff($boards, $deny_boards)));
1173
+	} else
1123 1174
 	{
1124 1175
 		foreach ($permissions as $permission)
1125 1176
 		{
1126 1177
 			// never had it to start with
1127
-			if (empty($boards[$permission]))
1128
-				$boards[$permission] = array();
1129
-			else
1178
+			if (empty($boards[$permission])) {
1179
+							$boards[$permission] = array();
1180
+			} else
1130 1181
 			{
1131 1182
 				// Or it may have been removed
1132 1183
 				$deny_boards[$permission] = isset($deny_boards[$permission]) ? $deny_boards[$permission] : array();
@@ -1162,10 +1213,11 @@  discard block
 block discarded – undo
1162 1213
 
1163 1214
 
1164 1215
 	// Moderators are free...
1165
-	if (!allowedTo('moderate_board'))
1166
-		$timeLimit = isset($timeOverrides[$error_type]) ? $timeOverrides[$error_type] : $modSettings['spamWaitTime'];
1167
-	else
1168
-		$timeLimit = 2;
1216
+	if (!allowedTo('moderate_board')) {
1217
+			$timeLimit = isset($timeOverrides[$error_type]) ? $timeOverrides[$error_type] : $modSettings['spamWaitTime'];
1218
+	} else {
1219
+			$timeLimit = 2;
1220
+	}
1169 1221
 
1170 1222
 	call_integration_hook('integrate_spam_protection', array(&$timeOverrides, &$timeLimit));
1171 1223
 
@@ -1192,8 +1244,9 @@  discard block
 block discarded – undo
1192 1244
 	if ($smcFunc['db_affected_rows']() != 1)
1193 1245
 	{
1194 1246
 		// Spammer!  You only have to wait a *few* seconds!
1195
-		if (!$only_return_result)
1196
-			fatal_lang_error($error_type . '_WaitTime_broken', false, array($timeLimit));
1247
+		if (!$only_return_result) {
1248
+					fatal_lang_error($error_type . '_WaitTime_broken', false, array($timeLimit));
1249
+		}
1197 1250
 
1198 1251
 		return true;
1199 1252
 	}
@@ -1211,11 +1264,13 @@  discard block
 block discarded – undo
1211 1264
  */
1212 1265
 function secureDirectory($path, $attachments = false)
1213 1266
 {
1214
-	if (empty($path))
1215
-		return 'empty_path';
1267
+	if (empty($path)) {
1268
+			return 'empty_path';
1269
+	}
1216 1270
 
1217
-	if (!is_writable($path))
1218
-		return 'path_not_writable';
1271
+	if (!is_writable($path)) {
1272
+			return 'path_not_writable';
1273
+	}
1219 1274
 
1220 1275
 	$directoryname = basename($path);
1221 1276
 
@@ -1227,9 +1282,9 @@  discard block
 block discarded – undo
1227 1282
 
1228 1283
 RemoveHandler .php .php3 .phtml .cgi .fcgi .pl .fpl .shtml';
1229 1284
 
1230
-	if (file_exists($path . '/.htaccess'))
1231
-		$errors[] = 'htaccess_exists';
1232
-	else
1285
+	if (file_exists($path . '/.htaccess')) {
1286
+			$errors[] = 'htaccess_exists';
1287
+	} else
1233 1288
 	{
1234 1289
 		$fh = @fopen($path . '/.htaccess', 'w');
1235 1290
 		if ($fh)
@@ -1242,9 +1297,9 @@  discard block
 block discarded – undo
1242 1297
 		$errors[] = 'htaccess_cannot_create_file';
1243 1298
 	}
1244 1299
 
1245
-	if (file_exists($path . '/index.php'))
1246
-		$errors[] = 'index-php_exists';
1247
-	else
1300
+	if (file_exists($path . '/index.php')) {
1301
+			$errors[] = 'index-php_exists';
1302
+	} else
1248 1303
 	{
1249 1304
 		$fh = @fopen($path . '/index.php', 'w');
1250 1305
 		if ($fh)
@@ -1272,11 +1327,12 @@  discard block
 block discarded – undo
1272 1327
 		$errors[] = 'index-php_cannot_create_file';
1273 1328
 	}
1274 1329
 
1275
-	if (!empty($errors))
1276
-		return $errors;
1277
-	else
1278
-		return true;
1279
-}
1330
+	if (!empty($errors)) {
1331
+			return $errors;
1332
+	} else {
1333
+			return true;
1334
+	}
1335
+	}
1280 1336
 
1281 1337
 /**
1282 1338
 * This sets the X-Frame-Options header.
@@ -1289,14 +1345,16 @@  discard block
 block discarded – undo
1289 1345
 	global $modSettings;
1290 1346
 
1291 1347
 	$option = 'SAMEORIGIN';
1292
-	if (is_null($override) && !empty($modSettings['frame_security']))
1293
-		$option = $modSettings['frame_security'];
1294
-	elseif (in_array($override, array('SAMEORIGIN', 'DENY')))
1295
-		$option = $override;
1348
+	if (is_null($override) && !empty($modSettings['frame_security'])) {
1349
+			$option = $modSettings['frame_security'];
1350
+	} elseif (in_array($override, array('SAMEORIGIN', 'DENY'))) {
1351
+			$option = $override;
1352
+	}
1296 1353
 
1297 1354
 	// Don't bother setting the header if we have disabled it.
1298
-	if ($option == 'DISABLE')
1299
-		return;
1355
+	if ($option == 'DISABLE') {
1356
+			return;
1357
+	}
1300 1358
 
1301 1359
 	// Finally set it.
1302 1360
 	header('x-frame-options: ' . $option);
Please login to merge, or discard this patch.
Themes/default/ManageSmileys.template.php 1 patch
Braces   +58 added lines, -44 removed lines patch added patch discarded remove patch
@@ -34,11 +34,12 @@  discard block
 block discarded – undo
34 34
 		</div>';
35 35
 
36 36
 	// If this is an existing set, and there are still un-added smileys - offer an import opportunity.
37
-	if (!empty($context['current_set']['can_import']))
38
-		echo '
37
+	if (!empty($context['current_set']['can_import'])) {
38
+			echo '
39 39
 		<div class="information noup">
40 40
 			', $context['current_set']['can_import'] == 1 ? sprintf($txt['smiley_set_import_single'], $context['current_set']['import_url']) : sprintf($txt['smiley_set_import_multiple'], $context['current_set']['can_import'], $context['current_set']['import_url']), '
41 41
 		</div>';
42
+	}
42 43
 
43 44
 	echo '
44 45
 		<div class="windowbg noup">
@@ -54,20 +55,20 @@  discard block
 block discarded – undo
54 55
 				</dt>
55 56
 				<dd>
56 57
 					', $modSettings['smileys_url'], '/';
57
-	if ($context['current_set']['id'] == 'default')
58
-		echo '<strong>default</strong><input type="hidden" name="smiley_sets_path" id="smiley_sets_path" value="default">';
59
-
60
-	elseif (empty($context['smiley_set_dirs']))
61
-		echo '
58
+	if ($context['current_set']['id'] == 'default') {
59
+			echo '<strong>default</strong><input type="hidden" name="smiley_sets_path" id="smiley_sets_path" value="default">';
60
+	} elseif (empty($context['smiley_set_dirs'])) {
61
+			echo '
62 62
 					<input type="text" name="smiley_sets_path" id="smiley_sets_path" value="', $context['current_set']['path'], '"> ';
63
-	else
63
+	} else
64 64
 	{
65 65
 		echo '
66 66
 					<select name="smiley_sets_path" id="smiley_sets_path">';
67 67
 
68
-		foreach ($context['smiley_set_dirs'] as $smiley_set_dir)
69
-			echo '
68
+		foreach ($context['smiley_set_dirs'] as $smiley_set_dir) {
69
+					echo '
70 70
 						<option value="', $smiley_set_dir['id'], '"', $smiley_set_dir['current'] ? ' selected' : '', $smiley_set_dir['selectable'] ? '' : ' disabled', '>', $smiley_set_dir['id'], '</option>';
71
+		}
71 72
 		echo '
72 73
 					</select> ';
73 74
 	}
@@ -82,14 +83,15 @@  discard block
 block discarded – undo
82 83
 				</dd>';
83 84
 
84 85
 	// If this is a new smiley set they have the option to import smileys already in the directory.
85
-	if ($context['current_set']['is_new'] && !empty($modSettings['smiley_enable']))
86
-		echo '
86
+	if ($context['current_set']['is_new'] && !empty($modSettings['smiley_enable'])) {
87
+			echo '
87 88
 				<dt>
88 89
 					<strong><label for="smiley_sets_import">', $txt['smiley_set_import_directory'], '</label>: </strong>
89 90
 				</dt>
90 91
 				<dd>
91 92
 					<input type="checkbox" name="smiley_sets_import" id="smiley_sets_import" value="1">
92 93
 				</dd>';
94
+	}
93 95
 
94 96
 	echo '
95 97
 			</dl>
@@ -121,9 +123,10 @@  discard block
 block discarded – undo
121 123
 				<dd>
122 124
 					<img src="', $modSettings['smileys_url'], '/', $modSettings['smiley_sets_default'], '/', $context['current_smiley']['filename'], '" id="preview" alt=""> ', $txt['smiley_preview_using'], ': <select name="set" onchange="updatePreview();">';
123 125
 
124
-	foreach ($context['smiley_sets'] as $smiley_set)
125
-		echo '
126
+	foreach ($context['smiley_sets'] as $smiley_set) {
127
+			echo '
126 128
 					<option value="', $smiley_set['path'], '"', $context['selected_set'] == $smiley_set['path'] ? ' selected' : '', '>', $smiley_set['name'], '</option>';
129
+	}
127 130
 
128 131
 	echo '
129 132
 					</select>
@@ -139,17 +142,18 @@  discard block
 block discarded – undo
139 142
 				</dt>
140 143
 				<dd>';
141 144
 
142
-	if (empty($context['filenames']))
143
-		echo '
145
+	if (empty($context['filenames'])) {
146
+			echo '
144 147
 					<input type="text" name="smiley_filename" id="smiley_filename" value="', $context['current_smiley']['filename'], '">';
145
-	else
148
+	} else
146 149
 	{
147 150
 		echo '
148 151
 					<select name="smiley_filename" id="smiley_filename" onchange="updatePreview();">';
149 152
 
150
-		foreach ($context['filenames'] as $filename)
151
-			echo '
153
+		foreach ($context['filenames'] as $filename) {
154
+					echo '
152 155
 						<option value="', $filename['id'], '"', $filename['selected'] ? ' selected' : '', '>', $filename['id'], '</option>';
156
+		}
153 157
 		echo '
154 158
 					</select>';
155 159
 	}
@@ -216,9 +220,10 @@  discard block
 block discarded – undo
216 220
 					<dd>
217 221
 						', $txt['smiley_preview_using'], ': <select name="set" onchange="updatePreview();selectMethod(\'existing\');">';
218 222
 
219
-	foreach ($context['smiley_sets'] as $smiley_set)
220
-		echo '
223
+	foreach ($context['smiley_sets'] as $smiley_set) {
224
+			echo '
221 225
 							<option value="', $smiley_set['path'], '"', $context['selected_set'] == $smiley_set['path'] ? ' selected' : '', '>', $smiley_set['name'], '</option>';
226
+	}
222 227
 
223 228
 	echo '
224 229
 						</select>
@@ -228,17 +233,18 @@  discard block
 block discarded – undo
228 233
 					</dt>
229 234
 					<dd>';
230 235
 
231
-	if (empty($context['filenames']))
232
-		echo '
236
+	if (empty($context['filenames'])) {
237
+			echo '
233 238
 						<input type="text" name="smiley_filename" id="smiley_filename" value="', $context['current_smiley']['filename'], '" onchange="selectMethod(\'existing\');">';
234
-	else
239
+	} else
235 240
 	{
236 241
 		echo '
237 242
 						<select name="smiley_filename" id="smiley_filename" onchange="updatePreview();selectMethod(\'existing\');">';
238 243
 
239
-		foreach ($context['filenames'] as $filename)
240
-			echo '
244
+		foreach ($context['filenames'] as $filename) {
245
+					echo '
241 246
 							<option value="', $filename['id'], '"', $filename['selected'] ? ' selected' : '', '>', $filename['id'], '</option>';
247
+		}
242 248
 		echo '
243 249
 						</select>';
244 250
 	}
@@ -267,14 +273,15 @@  discard block
 block discarded – undo
267 273
 
268 274
 			<dl id="uploadMore" style="display: none;" class="settings">';
269 275
 
270
-	foreach ($context['smiley_sets'] as $smiley_set)
271
-		echo '
276
+	foreach ($context['smiley_sets'] as $smiley_set) {
277
+			echo '
272 278
 				<dt>
273 279
 					', sprintf($txt['smileys_add_upload_for'], '<strong>' . $smiley_set['name'] . '</strong>'), ':
274 280
 				</dt>
275 281
 				<dd>
276 282
 					<input type="file" name="individual_', $smiley_set['name'], '" onchange="selectMethod(\'upload\');">
277 283
 				</dd>';
284
+	}
278 285
 
279 286
 	echo '
280 287
 			</dl>
@@ -341,27 +348,30 @@  discard block
 block discarded – undo
341 348
 
342 349
 		foreach ($location['rows'] as $row)
343 350
 		{
344
-			if (!empty($context['move_smiley']))
345
-				echo '
351
+			if (!empty($context['move_smiley'])) {
352
+							echo '
346 353
 			<a href="', $scripturl, '?action=admin;area=smileys;sa=setorder;location=', $location['id'], ';source=', $context['move_smiley'], ';row=', $row[0]['row'], ';reorder=1;', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons select_below" title="', $txt['smileys_move_here'], '"></span></a>';
354
+			}
347 355
 
348 356
 			foreach ($row as $smiley)
349 357
 			{
350
-				if (empty($context['move_smiley']))
351
-					echo '
358
+				if (empty($context['move_smiley'])) {
359
+									echo '
352 360
 			<a href="', $scripturl, '?action=admin;area=smileys;sa=setorder;move=', $smiley['id'], '"><img src="', $modSettings['smileys_url'], '/', $modSettings['smiley_sets_default'], '/', $smiley['filename'], '" alt="', $smiley['description'], '"></a>';
353
-				else
354
-					echo '
361
+				} else {
362
+									echo '
355 363
 			<img src="', $modSettings['smileys_url'], '/', $modSettings['smiley_sets_default'], '/', $smiley['filename'], '" alt="', $smiley['description'], '" ', $smiley['selected'] ? 'class="selected_item"' : '', '>
356 364
 			<a href="', $scripturl, '?action=admin;area=smileys;sa=setorder;location=', $location['id'], ';source=', $context['move_smiley'], ';after=', $smiley['id'], ';reorder=1;', $context['session_var'], '=', $context['session_id'], '" title="', $txt['smileys_move_here'], '"><span class="generic_icons select_below" title="', $txt['smileys_move_here'], '"></span></a>';
365
+				}
357 366
 			}
358 367
 
359 368
 			echo '
360 369
 			<br>';
361 370
 		}
362
-		if (!empty($context['move_smiley']))
363
-			echo '
371
+		if (!empty($context['move_smiley'])) {
372
+					echo '
364 373
 			<a href="', $scripturl, '?action=admin;area=smileys;sa=setorder;location=', $location['id'], ';source=', $context['move_smiley'], ';row=', $location['last_row'], ';reorder=1;', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons select_below" title="', $txt['smileys_move_here'], '"></span></a>';
374
+		}
365 375
 		echo '
366 376
 		</div><!-- .windowbg -->
367 377
 		<input type="hidden" name="reorder" value="1">
@@ -394,14 +404,15 @@  discard block
 block discarded – undo
394 404
 		<div class="windowbg">
395 405
 			<dl class="settings">';
396 406
 
397
-	if (!$context['new_icon'])
398
-		echo '
407
+	if (!$context['new_icon']) {
408
+			echo '
399 409
 				<dt>
400 410
 					<strong>', $txt['smiley_preview'], ': </strong>
401 411
 				</dt>
402 412
 				<dd>
403 413
 					<img src="', $context['icon']['image_url'], '" alt="', $context['icon']['title'], '">
404 414
 				</dd>';
415
+	}
405 416
 
406 417
 	echo '
407 418
 				<dt>
@@ -428,9 +439,10 @@  discard block
 block discarded – undo
428 439
 		echo '
429 440
 						<optgroup label="', $category['name'], '">';
430 441
 
431
-		foreach ($category['boards'] as $board)
432
-			echo '
442
+		foreach ($category['boards'] as $board) {
443
+					echo '
433 444
 							<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=&gt;' : '', ' ', $board['name'], '</option>';
445
+		}
434 446
 
435 447
 		echo '
436 448
 						</optgroup>';
@@ -447,19 +459,21 @@  discard block
 block discarded – undo
447 459
 						<option value="0"', empty($context['icon']['after']) ? ' selected' : '', '>', $txt['icons_location_first_icon'], '</option>';
448 460
 
449 461
 	// Print the list of all the icons it can be put after...
450
-	foreach ($context['icons'] as $id => $data)
451
-		if (empty($context['icon']['id']) || $id != $context['icon']['id'])
462
+	foreach ($context['icons'] as $id => $data) {
463
+			if (empty($context['icon']['id']) || $id != $context['icon']['id'])
452 464
 			echo '
453 465
 						<option value="', $id, '"', !empty($context['icon']['after']) && $id == $context['icon']['after'] ? ' selected' : '', '>', $txt['icons_location_after'], ': ', $data['title'], '</option>';
466
+	}
454 467
 
455 468
 	echo '
456 469
 					</select>
457 470
 				</dd>
458 471
 			</dl>';
459 472
 
460
-	if (!$context['new_icon'])
461
-		echo '
473
+	if (!$context['new_icon']) {
474
+			echo '
462 475
 			<input type="hidden" name="icon" value="', $context['icon']['id'], '">';
476
+	}
463 477
 
464 478
 	echo '
465 479
 			<input type="submit" name="icons_save" value="', $txt['smileys_save'], '" class="button">
Please login to merge, or discard this patch.