Completed
Push — release-2.1 ( cfdc59...af3d3b )
by Jeremy
12:06 queued 05:35
created
Sources/Themes.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1744,9 +1744,9 @@
 block discarded – undo
1744 1744
 			$context['theme_files'] = get_file_listing($currentTheme['theme_dir'], '');
1745 1745
 		
1746 1746
 		// Do not list minified_ files
1747
-		foreach($context['theme_files'] as $key=>$file)
1747
+		foreach ($context['theme_files'] as $key=>$file)
1748 1748
 		{
1749
-			if(strpos($file['filename'], 'minified_') !== FALSE)
1749
+			if (strpos($file['filename'], 'minified_') !== FALSE)
1750 1750
 				unset($context['theme_files'][$key]);
1751 1751
 		}
1752 1752
 
Please login to merge, or discard this patch.
Braces   +348 added lines, -271 removed lines patch added patch discarded remove patch
@@ -30,8 +30,9 @@  discard block
 block discarded – undo
30 30
  * @version 2.1 Beta 4
31 31
  */
32 32
 
33
-if (!defined('SMF'))
33
+if (!defined('SMF')) {
34 34
 	die('No direct access...');
35
+}
35 36
 
36 37
 /**
37 38
  * Subaction handler - manages the action and delegates control to the proper
@@ -103,12 +104,12 @@  discard block
 block discarded – undo
103 104
 	cache_put_data('minimized_css', null);
104 105
 
105 106
 	// Follow the sa or just go to administration.
106
-	if (isset($_GET['sa']) && !empty($subActions[$_GET['sa']]))
107
-		call_helper($subActions[$_GET['sa']]);
108
-
109
-	else
110
-		call_helper($subActions['admin']);
111
-}
107
+	if (isset($_GET['sa']) && !empty($subActions[$_GET['sa']])) {
108
+			call_helper($subActions[$_GET['sa']]);
109
+	} else {
110
+			call_helper($subActions['admin']);
111
+	}
112
+	}
112 113
 
113 114
 /**
114 115
  * This function allows administration of themes and their settings,
@@ -130,15 +131,16 @@  discard block
 block discarded – undo
130 131
 		checkSession();
131 132
 		validateToken('admin-tm');
132 133
 
133
-		if (isset($_POST['options']['known_themes']))
134
-			foreach ($_POST['options']['known_themes'] as $key => $id)
134
+		if (isset($_POST['options']['known_themes'])) {
135
+					foreach ($_POST['options']['known_themes'] as $key => $id)
135 136
 				$_POST['options']['known_themes'][$key] = (int) $id;
137
+		} else {
138
+					fatal_lang_error('themes_none_selectable', false);
139
+		}
136 140
 
137
-		else
138
-			fatal_lang_error('themes_none_selectable', false);
139
-
140
-		if (!in_array($_POST['options']['theme_guests'], $_POST['options']['known_themes']))
141
-			fatal_lang_error('themes_default_selectable', false);
141
+		if (!in_array($_POST['options']['theme_guests'], $_POST['options']['known_themes'])) {
142
+					fatal_lang_error('themes_default_selectable', false);
143
+		}
142 144
 
143 145
 		// Commit the new settings.
144 146
 		updateSettings(array(
@@ -146,8 +148,9 @@  discard block
 block discarded – undo
146 148
 			'theme_guests' => $_POST['options']['theme_guests'],
147 149
 			'knownThemes' => implode(',', $_POST['options']['known_themes']),
148 150
 		));
149
-		if ((int) $_POST['theme_reset'] == 0 || in_array($_POST['theme_reset'], $_POST['options']['known_themes']))
150
-			updateMemberData(null, array('id_theme' => (int) $_POST['theme_reset']));
151
+		if ((int) $_POST['theme_reset'] == 0 || in_array($_POST['theme_reset'], $_POST['options']['known_themes'])) {
152
+					updateMemberData(null, array('id_theme' => (int) $_POST['theme_reset']));
153
+		}
151 154
 
152 155
 		redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=admin');
153 156
 	}
@@ -166,8 +169,9 @@  discard block
 block discarded – undo
166 169
 	// Look for a non existent theme directory. (ie theme87.)
167 170
 	$theme_dir = $boarddir . '/Themes/theme';
168 171
 	$i = 1;
169
-	while (file_exists($theme_dir . $i))
170
-		$i++;
172
+	while (file_exists($theme_dir . $i)) {
173
+			$i++;
174
+	}
171 175
 
172 176
 	$context['new_theme_name'] = 'theme' . $i;
173 177
 
@@ -189,8 +193,9 @@  discard block
 block discarded – undo
189 193
 	loadLanguage('Admin');
190 194
 	isAllowedTo('admin_forum');
191 195
 
192
-	if (isset($_REQUEST['th']))
193
-		return SetThemeSettings();
196
+	if (isset($_REQUEST['th'])) {
197
+			return SetThemeSettings();
198
+	}
194 199
 
195 200
 	if (isset($_POST['save']))
196 201
 	{
@@ -274,12 +279,13 @@  discard block
 block discarded – undo
274 279
 		$context['themes'] = array();
275 280
 		while ($row = $smcFunc['db_fetch_assoc']($request))
276 281
 		{
277
-			if (!isset($context['themes'][$row['id_theme']]))
278
-				$context['themes'][$row['id_theme']] = array(
282
+			if (!isset($context['themes'][$row['id_theme']])) {
283
+							$context['themes'][$row['id_theme']] = array(
279 284
 					'id' => $row['id_theme'],
280 285
 					'num_default_options' => 0,
281 286
 					'num_members' => 0,
282 287
 				);
288
+			}
283 289
 			$context['themes'][$row['id_theme']][$row['variable']] = $row['value'];
284 290
 		}
285 291
 		$smcFunc['db_free_result']($request);
@@ -293,8 +299,9 @@  discard block
 block discarded – undo
293 299
 				'guest_member' => -1,
294 300
 			)
295 301
 		);
296
-		while ($row = $smcFunc['db_fetch_assoc']($request))
297
-			$context['themes'][$row['id_theme']]['num_default_options'] = $row['value'];
302
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
303
+					$context['themes'][$row['id_theme']]['num_default_options'] = $row['value'];
304
+		}
298 305
 		$smcFunc['db_free_result']($request);
299 306
 
300 307
 		// Need to make sure we don't do custom fields.
@@ -305,8 +312,9 @@  discard block
 block discarded – undo
305 312
 			)
306 313
 		);
307 314
 		$customFields = array();
308
-		while ($row = $smcFunc['db_fetch_assoc']($request))
309
-			$customFields[] = $row['col_name'];
315
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
316
+					$customFields[] = $row['col_name'];
317
+		}
310 318
 		$smcFunc['db_free_result']($request);
311 319
 		$customFieldsQuery = empty($customFields) ? '' : ('AND variable NOT IN ({array_string:custom_fields})');
312 320
 
@@ -321,14 +329,16 @@  discard block
 block discarded – undo
321 329
 				'custom_fields' => empty($customFields) ? array() : $customFields,
322 330
 			)
323 331
 		);
324
-		while ($row = $smcFunc['db_fetch_assoc']($request))
325
-			$context['themes'][$row['id_theme']]['num_members'] = $row['value'];
332
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
333
+					$context['themes'][$row['id_theme']]['num_members'] = $row['value'];
334
+		}
326 335
 		$smcFunc['db_free_result']($request);
327 336
 
328 337
 		// There has to be a Settings template!
329
-		foreach ($context['themes'] as $k => $v)
330
-			if (empty($v['theme_dir']) || (!file_exists($v['theme_dir'] . '/Settings.template.php') && empty($v['num_members'])))
338
+		foreach ($context['themes'] as $k => $v) {
339
+					if (empty($v['theme_dir']) || (!file_exists($v['theme_dir'] . '/Settings.template.php') && empty($v['num_members'])))
331 340
 				unset($context['themes'][$k]);
341
+		}
332 342
 
333 343
 		loadTemplate('Themes');
334 344
 		$context['sub_template'] = 'reset_list';
@@ -343,16 +353,19 @@  discard block
 block discarded – undo
343 353
 		checkSession();
344 354
 		validateToken('admin-sto');
345 355
 
346
-		if (empty($_POST['options']))
347
-			$_POST['options'] = array();
348
-		if (empty($_POST['default_options']))
349
-			$_POST['default_options'] = array();
356
+		if (empty($_POST['options'])) {
357
+					$_POST['options'] = array();
358
+		}
359
+		if (empty($_POST['default_options'])) {
360
+					$_POST['default_options'] = array();
361
+		}
350 362
 
351 363
 		// Set up the sql query.
352 364
 		$setValues = array();
353 365
 
354
-		foreach ($_POST['options'] as $opt => $val)
355
-			$setValues[] = array(-1, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val);
366
+		foreach ($_POST['options'] as $opt => $val) {
367
+					$setValues[] = array(-1, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val);
368
+		}
356 369
 
357 370
 		$old_settings = array();
358 371
 		foreach ($_POST['default_options'] as $opt => $val)
@@ -366,8 +379,8 @@  discard block
 block discarded – undo
366 379
 		if (!empty($setValues))
367 380
 		{
368 381
 			// Are there options in non-default themes set that should be cleared?
369
-			if (!empty($old_settings))
370
-				$smcFunc['db_query']('', '
382
+			if (!empty($old_settings)) {
383
+							$smcFunc['db_query']('', '
371 384
 					DELETE FROM {db_prefix}themes
372 385
 					WHERE id_theme != {int:default_theme}
373 386
 						AND id_member = {int:guest_member}
@@ -378,6 +391,7 @@  discard block
 block discarded – undo
378 391
 						'old_settings' => $old_settings,
379 392
 					)
380 393
 				);
394
+			}
381 395
 
382 396
 			$smcFunc['db_insert']('replace',
383 397
 				'{db_prefix}themes',
@@ -391,8 +405,7 @@  discard block
 block discarded – undo
391 405
 		cache_put_data('theme_settings-1', null, 90);
392 406
 
393 407
 		redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=reset');
394
-	}
395
-	elseif (isset($_POST['submit']) && $_POST['who'] == 1)
408
+	} elseif (isset($_POST['submit']) && $_POST['who'] == 1)
396 409
 	{
397 410
 		checkSession();
398 411
 		validateToken('admin-sto');
@@ -405,9 +418,9 @@  discard block
 block discarded – undo
405 418
 		$old_settings = array();
406 419
 		foreach ($_POST['default_options'] as $opt => $val)
407 420
 		{
408
-			if ($_POST['default_options_master'][$opt] == 0)
409
-				continue;
410
-			elseif ($_POST['default_options_master'][$opt] == 1)
421
+			if ($_POST['default_options_master'][$opt] == 0) {
422
+							continue;
423
+			} elseif ($_POST['default_options_master'][$opt] == 1)
411 424
 			{
412 425
 				// Delete then insert for ease of database compatibility!
413 426
 				$smcFunc['db_query']('substring', '
@@ -433,8 +446,7 @@  discard block
 block discarded – undo
433 446
 				);
434 447
 
435 448
 				$old_settings[] = $opt;
436
-			}
437
-			elseif ($_POST['default_options_master'][$opt] == 2)
449
+			} elseif ($_POST['default_options_master'][$opt] == 2)
438 450
 			{
439 451
 				$smcFunc['db_query']('', '
440 452
 					DELETE FROM {db_prefix}themes
@@ -449,8 +461,8 @@  discard block
 block discarded – undo
449 461
 		}
450 462
 
451 463
 		// Delete options from other themes.
452
-		if (!empty($old_settings))
453
-			$smcFunc['db_query']('', '
464
+		if (!empty($old_settings)) {
465
+					$smcFunc['db_query']('', '
454 466
 				DELETE FROM {db_prefix}themes
455 467
 				WHERE id_theme != {int:default_theme}
456 468
 					AND id_member > {int:no_member}
@@ -461,12 +473,13 @@  discard block
 block discarded – undo
461 473
 					'old_settings' => $old_settings,
462 474
 				)
463 475
 			);
476
+		}
464 477
 
465 478
 		foreach ($_POST['options'] as $opt => $val)
466 479
 		{
467
-			if ($_POST['options_master'][$opt] == 0)
468
-				continue;
469
-			elseif ($_POST['options_master'][$opt] == 1)
480
+			if ($_POST['options_master'][$opt] == 0) {
481
+							continue;
482
+			} elseif ($_POST['options_master'][$opt] == 1)
470 483
 			{
471 484
 				// Delete then insert for ease of database compatibility - again!
472 485
 				$smcFunc['db_query']('substring', '
@@ -491,8 +504,7 @@  discard block
 block discarded – undo
491 504
 						'value' => (is_array($val) ? implode(',', $val) : $val),
492 505
 					)
493 506
 				);
494
-			}
495
-			elseif ($_POST['options_master'][$opt] == 2)
507
+			} elseif ($_POST['options_master'][$opt] == 2)
496 508
 			{
497 509
 				$smcFunc['db_query']('', '
498 510
 					DELETE FROM {db_prefix}themes
@@ -509,8 +521,7 @@  discard block
 block discarded – undo
509 521
 		}
510 522
 
511 523
 		redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=reset');
512
-	}
513
-	elseif (!empty($_GET['who']) && $_GET['who'] == 2)
524
+	} elseif (!empty($_GET['who']) && $_GET['who'] == 2)
514 525
 	{
515 526
 		checkSession('get');
516 527
 		validateToken('admin-stor', 'request');
@@ -525,8 +536,9 @@  discard block
 block discarded – undo
525 536
 				)
526 537
 			);
527 538
 			$customFields = array();
528
-			while ($row = $smcFunc['db_fetch_assoc']($request))
529
-				$customFields[] = $row['col_name'];
539
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
540
+							$customFields[] = $row['col_name'];
541
+			}
530 542
 			$smcFunc['db_free_result']($request);
531 543
 		}
532 544
 		$customFieldsQuery = empty($customFields) ? '' : ('AND variable NOT IN ({array_string:custom_fields})');
@@ -581,13 +593,13 @@  discard block
 block discarded – undo
581 593
 			)
582 594
 		);
583 595
 		$context['theme_options'] = array();
584
-		while ($row = $smcFunc['db_fetch_assoc']($request))
585
-			$context['theme_options'][$row['variable']] = $row['value'];
596
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
597
+					$context['theme_options'][$row['variable']] = $row['value'];
598
+		}
586 599
 		$smcFunc['db_free_result']($request);
587 600
 
588 601
 		$context['theme_options_reset'] = false;
589
-	}
590
-	else
602
+	} else
591 603
 	{
592 604
 		$context['theme_options'] = array();
593 605
 		$context['theme_options_reset'] = true;
@@ -596,8 +608,9 @@  discard block
 block discarded – undo
596 608
 	foreach ($context['options'] as $i => $setting)
597 609
 	{
598 610
 		// Just skip separators
599
-		if (!is_array($setting))
600
-			continue;
611
+		if (!is_array($setting)) {
612
+					continue;
613
+		}
601 614
 
602 615
 		// Is this disabled?
603 616
 		if (isset($setting['enabled']) && $setting['enabled'] === false)
@@ -606,15 +619,17 @@  discard block
 block discarded – undo
606 619
 			continue;
607 620
 		}
608 621
 
609
-		if (!isset($setting['type']) || $setting['type'] == 'bool')
610
-			$context['options'][$i]['type'] = 'checkbox';
611
-		elseif ($setting['type'] == 'int' || $setting['type'] == 'integer')
612
-			$context['options'][$i]['type'] = 'number';
613
-		elseif ($setting['type'] == 'string')
614
-			$context['options'][$i]['type'] = 'text';
622
+		if (!isset($setting['type']) || $setting['type'] == 'bool') {
623
+					$context['options'][$i]['type'] = 'checkbox';
624
+		} elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') {
625
+					$context['options'][$i]['type'] = 'number';
626
+		} elseif ($setting['type'] == 'string') {
627
+					$context['options'][$i]['type'] = 'text';
628
+		}
615 629
 
616
-		if (isset($setting['options']))
617
-			$context['options'][$i]['type'] = 'list';
630
+		if (isset($setting['options'])) {
631
+					$context['options'][$i]['type'] = 'list';
632
+		}
618 633
 
619 634
 		$context['options'][$i]['value'] = !isset($context['theme_options'][$setting['id']]) ? '' : $context['theme_options'][$setting['id']];
620 635
 	}
@@ -639,8 +654,9 @@  discard block
 block discarded – undo
639 654
 {
640 655
 	global $txt, $context, $settings, $modSettings, $smcFunc;
641 656
 
642
-	if (empty($_GET['th']) && empty($_GET['id']))
643
-		return ThemeAdmin();
657
+	if (empty($_GET['th']) && empty($_GET['id'])) {
658
+			return ThemeAdmin();
659
+	}
644 660
 
645 661
 	$_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id'];
646 662
 
@@ -651,8 +667,9 @@  discard block
 block discarded – undo
651 667
 	isAllowedTo('admin_forum');
652 668
 
653 669
 	// Validate inputs/user.
654
-	if (empty($_GET['th']))
655
-		fatal_lang_error('no_theme', false);
670
+	if (empty($_GET['th'])) {
671
+			fatal_lang_error('no_theme', false);
672
+	}
656 673
 
657 674
 	// Fetch the smiley sets...
658 675
 	$sets = explode(',', 'none,' . $modSettings['smiley_sets_known']);
@@ -660,8 +677,9 @@  discard block
 block discarded – undo
660 677
 	$context['smiley_sets'] = array(
661 678
 		'' => $txt['smileys_no_default']
662 679
 	);
663
-	foreach ($sets as $i => $set)
664
-		$context['smiley_sets'][$set] = $smcFunc['htmlspecialchars']($set_names[$i]);
680
+	foreach ($sets as $i => $set) {
681
+			$context['smiley_sets'][$set] = $smcFunc['htmlspecialchars']($set_names[$i]);
682
+	}
665 683
 
666 684
 	$old_id = $settings['theme_id'];
667 685
 	$old_settings = $settings;
@@ -686,8 +704,9 @@  discard block
 block discarded – undo
686 704
 	if (file_exists($settings['theme_dir'] . '/index.template.php'))
687 705
 	{
688 706
 		$file_contents = implode('', file($settings['theme_dir'] . '/index.template.php'));
689
-		if (preg_match('~\$settings\[\'theme_variants\'\]\s*=(.+?);~', $file_contents, $matches))
690
-				eval('global $settings;' . $matches[0]);
707
+		if (preg_match('~\$settings\[\'theme_variants\'\]\s*=(.+?);~', $file_contents, $matches)) {
708
+						eval('global $settings;' . $matches[0]);
709
+		}
691 710
 	}
692 711
 
693 712
 	// Let mods hook into the theme settings.
@@ -699,37 +718,45 @@  discard block
 block discarded – undo
699 718
 		checkSession();
700 719
 		validateToken('admin-sts');
701 720
 
702
-		if (empty($_POST['options']))
703
-			$_POST['options'] = array();
704
-		if (empty($_POST['default_options']))
705
-			$_POST['default_options'] = array();
721
+		if (empty($_POST['options'])) {
722
+					$_POST['options'] = array();
723
+		}
724
+		if (empty($_POST['default_options'])) {
725
+					$_POST['default_options'] = array();
726
+		}
706 727
 
707 728
 		// Make sure items are cast correctly.
708 729
 		foreach ($context['theme_settings'] as $item)
709 730
 		{
710 731
 			// Disregard this item if this is just a separator.
711
-			if (!is_array($item))
712
-				continue;
732
+			if (!is_array($item)) {
733
+							continue;
734
+			}
713 735
 
714 736
 			foreach (array('options', 'default_options') as $option)
715 737
 			{
716
-				if (!isset($_POST[$option][$item['id']]))
717
-					continue;
738
+				if (!isset($_POST[$option][$item['id']])) {
739
+									continue;
740
+				}
718 741
 				// Checkbox.
719
-				elseif (empty($item['type']))
720
-					$_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0;
742
+				elseif (empty($item['type'])) {
743
+									$_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0;
744
+				}
721 745
 				// Number
722
-				elseif ($item['type'] == 'number')
723
-					$_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']];
746
+				elseif ($item['type'] == 'number') {
747
+									$_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']];
748
+				}
724 749
 			}
725 750
 		}
726 751
 
727 752
 		// Set up the sql query.
728 753
 		$inserts = array();
729
-		foreach ($_POST['options'] as $opt => $val)
730
-			$inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val);
731
-		foreach ($_POST['default_options'] as $opt => $val)
732
-			$inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val);
754
+		foreach ($_POST['options'] as $opt => $val) {
755
+					$inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val);
756
+		}
757
+		foreach ($_POST['default_options'] as $opt => $val) {
758
+					$inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val);
759
+		}
733 760
 		// If we're actually inserting something..
734 761
 		if (!empty($inserts))
735 762
 		{
@@ -755,8 +782,9 @@  discard block
 block discarded – undo
755 782
 
756 783
 	foreach ($settings as $setting => $dummy)
757 784
 	{
758
-		if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs')))
759
-			$settings[$setting] = htmlspecialchars__recursive($settings[$setting]);
785
+		if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs'))) {
786
+					$settings[$setting] = htmlspecialchars__recursive($settings[$setting]);
787
+		}
760 788
 	}
761 789
 
762 790
 	$context['settings'] = $context['theme_settings'];
@@ -765,18 +793,21 @@  discard block
 block discarded – undo
765 793
 	foreach ($context['settings'] as $i => $setting)
766 794
 	{
767 795
 		// Separators are dummies, so leave them alone.
768
-		if (!is_array($setting))
769
-			continue;
796
+		if (!is_array($setting)) {
797
+					continue;
798
+		}
770 799
 
771
-		if (!isset($setting['type']) || $setting['type'] == 'bool')
772
-			$context['settings'][$i]['type'] = 'checkbox';
773
-		elseif ($setting['type'] == 'int' || $setting['type'] == 'integer')
774
-			$context['settings'][$i]['type'] = 'number';
775
-		elseif ($setting['type'] == 'string')
776
-			$context['settings'][$i]['type'] = 'text';
800
+		if (!isset($setting['type']) || $setting['type'] == 'bool') {
801
+					$context['settings'][$i]['type'] = 'checkbox';
802
+		} elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') {
803
+					$context['settings'][$i]['type'] = 'number';
804
+		} elseif ($setting['type'] == 'string') {
805
+					$context['settings'][$i]['type'] = 'text';
806
+		}
777 807
 
778
-		if (isset($setting['options']))
779
-			$context['settings'][$i]['type'] = 'list';
808
+		if (isset($setting['options'])) {
809
+					$context['settings'][$i]['type'] = 'list';
810
+		}
780 811
 
781 812
 		$context['settings'][$i]['value'] = !isset($settings[$setting['id']]) ? '' : $settings[$setting['id']];
782 813
 	}
@@ -829,8 +860,9 @@  discard block
 block discarded – undo
829 860
 	$themeID = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id'];
830 861
 
831 862
 	// You can't delete the default theme!
832
-	if ($themeID == 1)
833
-		fatal_lang_error('no_access', false);
863
+	if ($themeID == 1) {
864
+			fatal_lang_error('no_access', false);
865
+	}
834 866
 
835 867
 	$theme_info = get_single_theme($themeID);
836 868
 
@@ -838,8 +870,9 @@  discard block
 block discarded – undo
838 870
 	remove_theme($themeID);
839 871
 
840 872
 	// And remove all its files and folders too.
841
-	if (!empty($theme_info) && !empty($theme_info['theme_dir']))
842
-		remove_dir($theme_info['theme_dir']);
873
+	if (!empty($theme_info) && !empty($theme_info['theme_dir'])) {
874
+			remove_dir($theme_info['theme_dir']);
875
+	}
843 876
 
844 877
 	// Go back to the list page.
845 878
 	redirectexit('action=admin;area=theme;sa=list;' . $context['session_var'] . '=' . $context['session_id'] . ';done=removing');
@@ -864,12 +897,14 @@  discard block
 block discarded – undo
864 897
 	$enableThemes = explode(',', $modSettings['enableThemes']);
865 898
 
866 899
 	// Are we disabling it?
867
-	if (isset($_GET['disabled']))
868
-		$enableThemes = array_diff($enableThemes, array($themeID));
900
+	if (isset($_GET['disabled'])) {
901
+			$enableThemes = array_diff($enableThemes, array($themeID));
902
+	}
869 903
 
870 904
 	// Nope? then enable it!
871
-	else
872
-		$enableThemes[] = (string) $themeID;
905
+	else {
906
+			$enableThemes[] = (string) $themeID;
907
+	}
873 908
 
874 909
 	// Update the setting.
875 910
 	$enableThemes = strtr(implode(',', $enableThemes), array(',,' => ','));
@@ -904,18 +939,21 @@  discard block
 block discarded – undo
904 939
 
905 940
 	$_SESSION['id_theme'] = 0;
906 941
 
907
-	if (isset($_GET['id']))
908
-		$_GET['th'] = $_GET['id'];
942
+	if (isset($_GET['id'])) {
943
+			$_GET['th'] = $_GET['id'];
944
+	}
909 945
 
910 946
 	// Saving a variant cause JS doesn't work - pretend it did ;)
911 947
 	if (isset($_POST['save']))
912 948
 	{
913 949
 		// Which theme?
914
-		foreach ($_POST['save'] as $k => $v)
915
-			$_GET['th'] = (int) $k;
950
+		foreach ($_POST['save'] as $k => $v) {
951
+					$_GET['th'] = (int) $k;
952
+		}
916 953
 
917
-		if (isset($_POST['vrt'][$k]))
918
-			$_GET['vrt'] = $_POST['vrt'][$k];
954
+		if (isset($_POST['vrt'][$k])) {
955
+					$_GET['vrt'] = $_POST['vrt'][$k];
956
+		}
919 957
 	}
920 958
 
921 959
 	// Have we made a decision, or are we just browsing?
@@ -1004,10 +1042,10 @@  discard block
 block discarded – undo
1004 1042
 				);
1005 1043
 				cache_put_data('theme_settings-' . $_GET['th'] . ':' . (int) $_REQUEST['u'], null, 90);
1006 1044
 
1007
-				if ($user_info['id'] == $_REQUEST['u'])
1008
-					$_SESSION['id_variant'] = 0;
1009
-			}
1010
-			elseif ($_GET['th'] == 0)
1045
+				if ($user_info['id'] == $_REQUEST['u']) {
1046
+									$_SESSION['id_variant'] = 0;
1047
+				}
1048
+			} elseif ($_GET['th'] == 0)
1011 1049
 			{
1012 1050
 				// Remove any custom variants.
1013 1051
 				$smcFunc['db_query']('', '
@@ -1088,12 +1126,13 @@  discard block
 block discarded – undo
1088 1126
 		);
1089 1127
 		while ($row = $smcFunc['db_fetch_assoc']($request))
1090 1128
 		{
1091
-			if (!isset($context['available_themes'][$row['id_theme']]))
1092
-				$context['available_themes'][$row['id_theme']] = array(
1129
+			if (!isset($context['available_themes'][$row['id_theme']])) {
1130
+							$context['available_themes'][$row['id_theme']] = array(
1093 1131
 					'id' => $row['id_theme'],
1094 1132
 					'selected' => $context['current_theme'] == $row['id_theme'],
1095 1133
 					'num_users' => 0
1096 1134
 				);
1135
+			}
1097 1136
 			$context['available_themes'][$row['id_theme']][$row['variable']] = $row['value'];
1098 1137
 		}
1099 1138
 		$smcFunc['db_free_result']($request);
@@ -1106,9 +1145,9 @@  discard block
 block discarded – undo
1106 1145
 			'num_users' => 0
1107 1146
 		);
1108 1147
 		$guest_theme = 0;
1148
+	} else {
1149
+			$guest_theme = $modSettings['theme_guests'];
1109 1150
 	}
1110
-	else
1111
-		$guest_theme = $modSettings['theme_guests'];
1112 1151
 
1113 1152
 	$request = $smcFunc['db_query']('', '
1114 1153
 		SELECT id_theme, COUNT(*) AS the_count
@@ -1121,15 +1160,17 @@  discard block
 block discarded – undo
1121 1160
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1122 1161
 	{
1123 1162
 		// Figure out which theme it is they are REALLY using.
1124
-		if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',', $modSettings['knownThemes'])))
1125
-			$row['id_theme'] = $guest_theme;
1126
-		elseif (empty($modSettings['theme_allow']))
1127
-			$row['id_theme'] = $guest_theme;
1163
+		if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',', $modSettings['knownThemes']))) {
1164
+					$row['id_theme'] = $guest_theme;
1165
+		} elseif (empty($modSettings['theme_allow'])) {
1166
+					$row['id_theme'] = $guest_theme;
1167
+		}
1128 1168
 
1129
-		if (isset($context['available_themes'][$row['id_theme']]))
1130
-			$context['available_themes'][$row['id_theme']]['num_users'] += $row['the_count'];
1131
-		else
1132
-			$context['available_themes'][$guest_theme]['num_users'] += $row['the_count'];
1169
+		if (isset($context['available_themes'][$row['id_theme']])) {
1170
+					$context['available_themes'][$row['id_theme']]['num_users'] += $row['the_count'];
1171
+		} else {
1172
+					$context['available_themes'][$guest_theme]['num_users'] += $row['the_count'];
1173
+		}
1133 1174
 	}
1134 1175
 	$smcFunc['db_free_result']($request);
1135 1176
 
@@ -1148,8 +1189,9 @@  discard block
 block discarded – undo
1148 1189
 				'id_member' => isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? array(-1, $context['current_member']) : array(-1),
1149 1190
 			)
1150 1191
 		);
1151
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1152
-			$variant_preferences[$row['id_theme']] = $row['value'];
1192
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1193
+					$variant_preferences[$row['id_theme']] = $row['value'];
1194
+		}
1153 1195
 		$smcFunc['db_free_result']($request);
1154 1196
 	}
1155 1197
 
@@ -1160,17 +1202,18 @@  discard block
 block discarded – undo
1160 1202
 	foreach ($context['available_themes'] as $id_theme => $theme_data)
1161 1203
 	{
1162 1204
 		// Don't try to load the forum or board default theme's data... it doesn't have any!
1163
-		if ($id_theme == 0)
1164
-			continue;
1205
+		if ($id_theme == 0) {
1206
+					continue;
1207
+		}
1165 1208
 
1166 1209
 		// The thumbnail needs the correct path.
1167 1210
 		$settings['images_url'] = &$theme_data['images_url'];
1168 1211
 
1169
-		if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php'))
1170
-			include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php');
1171
-		elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php'))
1172
-			include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php');
1173
-		else
1212
+		if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php')) {
1213
+					include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php');
1214
+		} elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php')) {
1215
+					include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php');
1216
+		} else
1174 1217
 		{
1175 1218
 			$txt['theme_thumbnail_href'] = $theme_data['images_url'] . '/thumbnail.png';
1176 1219
 			$txt['theme_description'] = '';
@@ -1195,15 +1238,17 @@  discard block
 block discarded – undo
1195 1238
 					loadLanguage('Settings');
1196 1239
 
1197 1240
 					$context['available_themes'][$id_theme]['variants'] = array();
1198
-					foreach ($settings['theme_variants'] as $variant)
1199
-						$context['available_themes'][$id_theme]['variants'][$variant] = array(
1241
+					foreach ($settings['theme_variants'] as $variant) {
1242
+											$context['available_themes'][$id_theme]['variants'][$variant] = array(
1200 1243
 							'label' => isset($txt['variant_' . $variant]) ? $txt['variant_' . $variant] : $variant,
1201 1244
 							'thumbnail' => !file_exists($theme_data['theme_dir'] . '/images/thumbnail.png') || file_exists($theme_data['theme_dir'] . '/images/thumbnail_' . $variant . '.png') ? $theme_data['images_url'] . '/thumbnail_' . $variant . '.png' : ($theme_data['images_url'] . '/thumbnail.png'),
1202 1245
 						);
1246
+					}
1203 1247
 
1204 1248
 					$context['available_themes'][$id_theme]['selected_variant'] = isset($_GET['vrt']) ? $_GET['vrt'] : (!empty($variant_preferences[$id_theme]) ? $variant_preferences[$id_theme] : (!empty($settings['default_variant']) ? $settings['default_variant'] : $settings['theme_variants'][0]));
1205
-					if (!isset($context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail']))
1206
-						$context['available_themes'][$id_theme]['selected_variant'] = $settings['theme_variants'][0];
1249
+					if (!isset($context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail'])) {
1250
+											$context['available_themes'][$id_theme]['selected_variant'] = $settings['theme_variants'][0];
1251
+					}
1207 1252
 
1208 1253
 					$context['available_themes'][$id_theme]['thumbnail_href'] = $context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail'];
1209 1254
 					// Allow themes to override the text.
@@ -1219,8 +1264,9 @@  discard block
 block discarded – undo
1219 1264
 	// As long as we're not doing the default theme...
1220 1265
 	if (!isset($_REQUEST['u']) || $_REQUEST['u'] >= 0)
1221 1266
 	{
1222
-		if ($guest_theme != 0)
1223
-			$context['available_themes'][0] = $context['available_themes'][$guest_theme];
1267
+		if ($guest_theme != 0) {
1268
+					$context['available_themes'][0] = $context['available_themes'][$guest_theme];
1269
+		}
1224 1270
 
1225 1271
 		$context['available_themes'][0]['id'] = 0;
1226 1272
 		$context['available_themes'][0]['name'] = $txt['theme_forum_default'];
@@ -1269,14 +1315,16 @@  discard block
 block discarded – undo
1269 1315
 		$action = $smcFunc['htmlspecialchars'](trim($_GET['do']));
1270 1316
 
1271 1317
 		// Got any info from the specific form?
1272
-		if (!isset($_POST['save_' . $action]))
1273
-			fatal_lang_error('theme_install_no_action', false);
1318
+		if (!isset($_POST['save_' . $action])) {
1319
+					fatal_lang_error('theme_install_no_action', false);
1320
+		}
1274 1321
 
1275 1322
 		validateToken('admin-t-' . $action);
1276 1323
 
1277 1324
 		// Hopefully the themes directory is writable, or we might have a problem.
1278
-		if (!is_writable($themedir))
1279
-			fatal_lang_error('theme_install_write_error', 'critical');
1325
+		if (!is_writable($themedir)) {
1326
+					fatal_lang_error('theme_install_write_error', 'critical');
1327
+		}
1280 1328
 
1281 1329
 		// Call the function and handle the result.
1282 1330
 		$result = $subActions[$action]();
@@ -1291,9 +1339,10 @@  discard block
 block discarded – undo
1291 1339
 	}
1292 1340
 
1293 1341
 	// Nope, show a nice error.
1294
-	else
1295
-		fatal_lang_error('theme_install_no_action', false);
1296
-}
1342
+	else {
1343
+			fatal_lang_error('theme_install_no_action', false);
1344
+	}
1345
+	}
1297 1346
 
1298 1347
 /**
1299 1348
  * Installs a theme from a theme package.
@@ -1309,8 +1358,9 @@  discard block
 block discarded – undo
1309 1358
 	$dirtemp = $themedir . '/temp';
1310 1359
 
1311 1360
 	// Make sure the temp dir doesn't already exist
1312
-	if (file_exists($dirtemp))
1313
-		remove_dir($dirtemp);
1361
+	if (file_exists($dirtemp)) {
1362
+			remove_dir($dirtemp);
1363
+	}
1314 1364
 
1315 1365
 	// Create the temp dir.
1316 1366
 	mkdir($dirtemp, 0777);
@@ -1322,17 +1372,20 @@  discard block
 block discarded – undo
1322 1372
 		smf_chmod($dirtemp, '0755');
1323 1373
 
1324 1374
 		// How about now?
1325
-		if (!is_writable($dirtemp))
1326
-			fatal_lang_error('theme_install_write_error', 'critical');
1375
+		if (!is_writable($dirtemp)) {
1376
+					fatal_lang_error('theme_install_write_error', 'critical');
1377
+		}
1327 1378
 	}
1328 1379
 
1329 1380
 	// This happens when the admin session is gone and the user has to login again.
1330
-	if (!isset($_FILES) || !isset($_FILES['theme_gz']) || empty($_FILES['theme_gz']))
1331
-		redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']);
1381
+	if (!isset($_FILES) || !isset($_FILES['theme_gz']) || empty($_FILES['theme_gz'])) {
1382
+			redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']);
1383
+	}
1332 1384
 
1333 1385
 	// Another error check layer, something went wrong with the upload.
1334
-	if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0)
1335
-		fatal_lang_error('theme_install_error_file_' . $_FILES['theme_gz']['error'], false);
1386
+	if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0) {
1387
+			fatal_lang_error('theme_install_error_file_' . $_FILES['theme_gz']['error'], false);
1388
+	}
1336 1389
 
1337 1390
 	// Get the theme's name.
1338 1391
 	$name = pathinfo($_FILES['theme_gz']['name'], PATHINFO_FILENAME);
@@ -1363,11 +1416,10 @@  discard block
 block discarded – undo
1363 1416
 
1364 1417
 		// return all the info.
1365 1418
 		return $context['to_install'];
1419
+	} else {
1420
+			fatal_lang_error('theme_install_error_title', false);
1421
+	}
1366 1422
 	}
1367
-
1368
-	else
1369
-		fatal_lang_error('theme_install_error_title', false);
1370
-}
1371 1423
 
1372 1424
 /**
1373 1425
  * Makes a copy from the default theme, assigns a name for it and installs it.
@@ -1381,15 +1433,17 @@  discard block
 block discarded – undo
1381 1433
 	global $forum_version;
1382 1434
 
1383 1435
 	// There's gotta be something to work with.
1384
-	if (!isset($_REQUEST['copy']) || empty($_REQUEST['copy']))
1385
-		fatal_lang_error('theme_install_error_title', false);
1436
+	if (!isset($_REQUEST['copy']) || empty($_REQUEST['copy'])) {
1437
+			fatal_lang_error('theme_install_error_title', false);
1438
+	}
1386 1439
 
1387 1440
 	// Get a cleaner version.
1388 1441
 	$name = preg_replace('~[^A-Za-z0-9_\- ]~', '', $_REQUEST['copy']);
1389 1442
 
1390 1443
 	// Is there a theme already named like this?
1391
-	if (file_exists($themedir . '/' . $name))
1392
-		fatal_lang_error('theme_install_already_dir', false);
1444
+	if (file_exists($themedir . '/' . $name)) {
1445
+			fatal_lang_error('theme_install_already_dir', false);
1446
+	}
1393 1447
 
1394 1448
 	// This is a brand new theme so set all possible values.
1395 1449
 	$context['to_install'] = array(
@@ -1409,8 +1463,9 @@  discard block
 block discarded – undo
1409 1463
 
1410 1464
 	// Buy some time.
1411 1465
 	@set_time_limit(600);
1412
-	if (function_exists('apache_reset_timeout'))
1413
-		@apache_reset_timeout();
1466
+	if (function_exists('apache_reset_timeout')) {
1467
+			@apache_reset_timeout();
1468
+	}
1414 1469
 
1415 1470
 	// Create subdirectories for css and javascript files.
1416 1471
 	mkdir($context['to_install']['theme_dir'] . '/css', 0777);
@@ -1446,12 +1501,13 @@  discard block
 block discarded – undo
1446 1501
 
1447 1502
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1448 1503
 	{
1449
-		if ($row['variable'] == 'theme_templates')
1450
-			$theme_templates = $row['value'];
1451
-		elseif ($row['variable'] == 'theme_layers')
1452
-			$theme_layers = $row['value'];
1453
-		else
1454
-			continue;
1504
+		if ($row['variable'] == 'theme_templates') {
1505
+					$theme_templates = $row['value'];
1506
+		} elseif ($row['variable'] == 'theme_layers') {
1507
+					$theme_layers = $row['value'];
1508
+		} else {
1509
+					continue;
1510
+		}
1455 1511
 	}
1456 1512
 
1457 1513
 	$smcFunc['db_free_result']($request);
@@ -1510,12 +1566,14 @@  discard block
 block discarded – undo
1510 1566
 	global $themedir, $themeurl, $context;
1511 1567
 
1512 1568
 	// Cannot use the theme dir as a theme dir.
1513
-	if (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir))
1514
-		fatal_lang_error('theme_install_invalid_dir', false);
1569
+	if (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir)) {
1570
+			fatal_lang_error('theme_install_invalid_dir', false);
1571
+	}
1515 1572
 
1516 1573
 	// Check is there is "something" on the dir.
1517
-	elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml'))
1518
-		fatal_lang_error('theme_install_error', false);
1574
+	elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml')) {
1575
+			fatal_lang_error('theme_install_error', false);
1576
+	}
1519 1577
 
1520 1578
 	$name = basename($_REQUEST['theme_dir']);
1521 1579
 	$name = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $name);
@@ -1559,24 +1617,27 @@  discard block
 block discarded – undo
1559 1617
 	}
1560 1618
 
1561 1619
 	// Any special layers?
1562
-	if (isset($settings['catch_action']['layers']))
1563
-		$context['template_layers'] = $settings['catch_action']['layers'];
1620
+	if (isset($settings['catch_action']['layers'])) {
1621
+			$context['template_layers'] = $settings['catch_action']['layers'];
1622
+	}
1564 1623
 
1565 1624
 	// Any function to call?
1566 1625
 	if (isset($settings['catch_action']['function']))
1567 1626
 	{
1568 1627
 		$hook = $settings['catch_action']['function'];
1569 1628
 
1570
-		if (!isset($settings['catch_action']['filename']))
1571
-			$settings['catch_action']['filename'] = '';
1629
+		if (!isset($settings['catch_action']['filename'])) {
1630
+					$settings['catch_action']['filename'] = '';
1631
+		}
1572 1632
 
1573 1633
 		add_integration_function('integrate_wrap_action', $hook, false, $settings['catch_action']['filename'], false);
1574 1634
 		call_integration_hook('integrate_wrap_action');
1575 1635
 	}
1576 1636
 	// And finally, the main sub template ;).
1577
-	if (isset($settings['catch_action']['sub_template']))
1578
-		$context['sub_template'] = $settings['catch_action']['sub_template'];
1579
-}
1637
+	if (isset($settings['catch_action']['sub_template'])) {
1638
+			$context['sub_template'] = $settings['catch_action']['sub_template'];
1639
+	}
1640
+	}
1580 1641
 
1581 1642
 /**
1582 1643
  * Set an option via javascript.
@@ -1595,12 +1656,14 @@  discard block
 block discarded – undo
1595 1656
 	checkSession('get');
1596 1657
 
1597 1658
 	// This good-for-nothing pixel is being used to keep the session alive.
1598
-	if (empty($_GET['var']) || !isset($_GET['val']))
1599
-		redirectexit($settings['images_url'] . '/blank.png');
1659
+	if (empty($_GET['var']) || !isset($_GET['val'])) {
1660
+			redirectexit($settings['images_url'] . '/blank.png');
1661
+	}
1600 1662
 
1601 1663
 	// Sorry, guests can't go any further than this.
1602
-	if ($user_info['is_guest'] || $user_info['id'] == 0)
1603
-		obExit(false);
1664
+	if ($user_info['is_guest'] || $user_info['id'] == 0) {
1665
+			obExit(false);
1666
+	}
1604 1667
 
1605 1668
 	$reservedVars = array(
1606 1669
 		'actual_theme_url',
@@ -1623,8 +1686,9 @@  discard block
 block discarded – undo
1623 1686
 	);
1624 1687
 
1625 1688
 	// Can't change reserved vars.
1626
-	if (in_array(strtolower($_GET['var']), $reservedVars))
1627
-		redirectexit($settings['images_url'] . '/blank.png');
1689
+	if (in_array(strtolower($_GET['var']), $reservedVars)) {
1690
+			redirectexit($settings['images_url'] . '/blank.png');
1691
+	}
1628 1692
 
1629 1693
 	// Use a specific theme?
1630 1694
 	if (isset($_GET['th']) || isset($_GET['id']))
@@ -1640,8 +1704,9 @@  discard block
 block discarded – undo
1640 1704
 	{
1641 1705
 		$options['admin_preferences'] = !empty($options['admin_preferences']) ? $smcFunc['json_decode']($options['admin_preferences'], true) : array();
1642 1706
 		// New thingy...
1643
-		if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5)
1644
-			$options['admin_preferences'][$_GET['admin_key']] = $_GET['val'];
1707
+		if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5) {
1708
+					$options['admin_preferences'][$_GET['admin_key']] = $_GET['val'];
1709
+		}
1645 1710
 
1646 1711
 		// Change the value to be something nice,
1647 1712
 		$_GET['val'] = $smcFunc['json_encode']($options['admin_preferences']);
@@ -1671,8 +1736,9 @@  discard block
 block discarded – undo
1671 1736
 	global $context, $scripturl, $boarddir, $smcFunc, $txt;
1672 1737
 
1673 1738
 	// @todo Should this be removed?
1674
-	if (isset($_REQUEST['preview']))
1675
-		die('die() with fire');
1739
+	if (isset($_REQUEST['preview'])) {
1740
+			die('die() with fire');
1741
+	}
1676 1742
 
1677 1743
 	isAllowedTo('admin_forum');
1678 1744
 	loadTemplate('Themes');
@@ -1686,11 +1752,11 @@  discard block
 block discarded – undo
1686 1752
 		foreach ($context['themes'] as $key => $theme)
1687 1753
 		{
1688 1754
 			// There has to be a Settings template!
1689
-			if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css'))
1690
-				unset($context['themes'][$key]);
1691
-
1692
-			else
1693
-				$context['themes'][$key]['can_edit_style'] = file_exists($theme['theme_dir'] . '/css/index.css');
1755
+			if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css')) {
1756
+							unset($context['themes'][$key]);
1757
+			} else {
1758
+							$context['themes'][$key]['can_edit_style'] = file_exists($theme['theme_dir'] . '/css/index.css');
1759
+			}
1694 1760
 		}
1695 1761
 
1696 1762
 		$context['sub_template'] = 'edit_list';
@@ -1705,22 +1771,24 @@  discard block
 block discarded – undo
1705 1771
 	$context['theme_id'] = $currentTheme['id'];
1706 1772
 	$context['browse_title'] = sprintf($txt['themeadmin_browsing_theme'], $currentTheme['name']);
1707 1773
 
1708
-	if (!file_exists($currentTheme['theme_dir'] . '/index.template.php') && !file_exists($currentTheme['theme_dir'] . '/css/index.css'))
1709
-		fatal_lang_error('theme_edit_missing', false);
1774
+	if (!file_exists($currentTheme['theme_dir'] . '/index.template.php') && !file_exists($currentTheme['theme_dir'] . '/css/index.css')) {
1775
+			fatal_lang_error('theme_edit_missing', false);
1776
+	}
1710 1777
 
1711 1778
 	if (!isset($_REQUEST['filename']))
1712 1779
 	{
1713 1780
 		if (isset($_GET['directory']))
1714 1781
 		{
1715
-			if (substr($_GET['directory'], 0, 1) == '.')
1716
-				$_GET['directory'] = '';
1717
-			else
1782
+			if (substr($_GET['directory'], 0, 1) == '.') {
1783
+							$_GET['directory'] = '';
1784
+			} else
1718 1785
 			{
1719 1786
 				$_GET['directory'] = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $_GET['directory']);
1720 1787
 
1721 1788
 				$temp = realpath($currentTheme['theme_dir'] . '/' . $_GET['directory']);
1722
-				if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir']))
1723
-					$_GET['directory'] = '';
1789
+				if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) {
1790
+									$_GET['directory'] = '';
1791
+				}
1724 1792
 			}
1725 1793
 		}
1726 1794
 
@@ -1739,44 +1807,47 @@  discard block
 block discarded – undo
1739 1807
 				'href' => $scripturl . '?action=admin;area=theme;th=' . $_GET['th'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=edit;directory=' . $temp,
1740 1808
 				'size' => '',
1741 1809
 			));
1810
+		} else {
1811
+					$context['theme_files'] = get_file_listing($currentTheme['theme_dir'], '');
1742 1812
 		}
1743
-		else
1744
-			$context['theme_files'] = get_file_listing($currentTheme['theme_dir'], '');
1745 1813
 		
1746 1814
 		// Do not list minified_ files
1747 1815
 		foreach($context['theme_files'] as $key=>$file)
1748 1816
 		{
1749
-			if(strpos($file['filename'], 'minified_') !== FALSE)
1750
-				unset($context['theme_files'][$key]);
1817
+			if(strpos($file['filename'], 'minified_') !== FALSE) {
1818
+							unset($context['theme_files'][$key]);
1819
+			}
1751 1820
 		}
1752 1821
 
1753 1822
 		$context['sub_template'] = 'edit_browse';
1754 1823
 
1755 1824
 		return;
1756
-	}
1757
-	else
1825
+	} else
1758 1826
 	{
1759
-		if (substr($_REQUEST['filename'], 0, 1) == '.')
1760
-			$_REQUEST['filename'] = '';
1761
-		else
1827
+		if (substr($_REQUEST['filename'], 0, 1) == '.') {
1828
+					$_REQUEST['filename'] = '';
1829
+		} else
1762 1830
 		{
1763 1831
 			$_REQUEST['filename'] = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $_REQUEST['filename']);
1764 1832
 
1765 1833
 			$temp = realpath($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']);
1766
-			if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir']))
1767
-				$_REQUEST['filename'] = '';
1834
+			if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) {
1835
+							$_REQUEST['filename'] = '';
1836
+			}
1768 1837
 		}
1769 1838
 
1770
-		if (empty($_REQUEST['filename']))
1771
-			fatal_lang_error('theme_edit_missing', false);
1839
+		if (empty($_REQUEST['filename'])) {
1840
+					fatal_lang_error('theme_edit_missing', false);
1841
+		}
1772 1842
 	}
1773 1843
 
1774 1844
 	if (isset($_POST['save']))
1775 1845
 	{
1776 1846
 		if (checkSession('post', '', false) == '' && validateToken('admin-te-' . md5($_GET['th'] . '-' . $_REQUEST['filename']), 'post', false) == true)
1777 1847
 		{
1778
-			if (is_array($_POST['entire_file']))
1779
-				$_POST['entire_file'] = implode("\n", $_POST['entire_file']);
1848
+			if (is_array($_POST['entire_file'])) {
1849
+							$_POST['entire_file'] = implode("\n", $_POST['entire_file']);
1850
+			}
1780 1851
 
1781 1852
 			$_POST['entire_file'] = rtrim(strtr($_POST['entire_file'], array("\r" => '', '   ' => "\t")));
1782 1853
 
@@ -1788,10 +1859,11 @@  discard block
 block discarded – undo
1788 1859
 				fclose($fp);
1789 1860
 
1790 1861
 				$error = @file_get_contents($currentTheme['theme_url'] . '/tmp_' . session_id() . '.php');
1791
-				if (preg_match('~ <b>(\d+)</b><br( /)?' . '>$~i', $error) != 0)
1792
-					$error_file = $currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php';
1793
-				else
1794
-					unlink($currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php');
1862
+				if (preg_match('~ <b>(\d+)</b><br( /)?' . '>$~i', $error) != 0) {
1863
+									$error_file = $currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php';
1864
+				} else {
1865
+									unlink($currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php');
1866
+				}
1795 1867
 			}
1796 1868
 
1797 1869
 			if (!isset($error_file))
@@ -1812,10 +1884,11 @@  discard block
 block discarded – undo
1812 1884
 			$context['sub_template'] = 'edit_file';
1813 1885
 
1814 1886
 			// Recycle the submitted data.
1815
-			if (is_array($_POST['entire_file']))
1816
-				$context['entire_file'] = $smcFunc['htmlspecialchars'](implode("\n", $_POST['entire_file']));
1817
-			else
1818
-				$context['entire_file'] = $smcFunc['htmlspecialchars']($_POST['entire_file']);
1887
+			if (is_array($_POST['entire_file'])) {
1888
+							$context['entire_file'] = $smcFunc['htmlspecialchars'](implode("\n", $_POST['entire_file']));
1889
+			} else {
1890
+							$context['entire_file'] = $smcFunc['htmlspecialchars']($_POST['entire_file']);
1891
+			}
1819 1892
 
1820 1893
 			$context['edit_filename'] = $smcFunc['htmlspecialchars']($_POST['filename']);
1821 1894
 
@@ -1838,17 +1911,17 @@  discard block
 block discarded – undo
1838 1911
 		$context['sub_template'] = 'edit_style';
1839 1912
 
1840 1913
 		$context['entire_file'] = $smcFunc['htmlspecialchars'](strtr(file_get_contents($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']), array("\t" => '   ')));
1841
-	}
1842
-	elseif (substr($_REQUEST['filename'], -13) == '.template.php')
1914
+	} elseif (substr($_REQUEST['filename'], -13) == '.template.php')
1843 1915
 	{
1844 1916
 		$context['sub_template'] = 'edit_template';
1845 1917
 
1846
-		if (!isset($error_file))
1847
-			$file_data = file($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']);
1848
-		else
1918
+		if (!isset($error_file)) {
1919
+					$file_data = file($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']);
1920
+		} else
1849 1921
 		{
1850
-			if (preg_match('~(<b>.+?</b>:.+?<b>).+?(</b>.+?<b>\d+</b>)<br( /)?' . '>$~i', $error, $match) != 0)
1851
-				$context['parse_error'] = $match[1] . $_REQUEST['filename'] . $match[2];
1922
+			if (preg_match('~(<b>.+?</b>:.+?<b>).+?(</b>.+?<b>\d+</b>)<br( /)?' . '>$~i', $error, $match) != 0) {
1923
+							$context['parse_error'] = $match[1] . $_REQUEST['filename'] . $match[2];
1924
+			}
1852 1925
 			$file_data = file($error_file);
1853 1926
 			unlink($error_file);
1854 1927
 		}
@@ -1862,8 +1935,9 @@  discard block
 block discarded – undo
1862 1935
 				// Try to format the functions a little nicer...
1863 1936
 				$context['file_parts'][$j]['data'] = trim($context['file_parts'][$j]['data']) . "\n";
1864 1937
 
1865
-				if (empty($context['file_parts'][$j]['lines']))
1866
-					unset($context['file_parts'][$j]);
1938
+				if (empty($context['file_parts'][$j]['lines'])) {
1939
+									unset($context['file_parts'][$j]);
1940
+				}
1867 1941
 				$context['file_parts'][++$j] = array('lines' => 0, 'line' => $i + 1, 'data' => '');
1868 1942
 			}
1869 1943
 
@@ -1872,8 +1946,7 @@  discard block
 block discarded – undo
1872 1946
 		}
1873 1947
 
1874 1948
 		$context['entire_file'] = $smcFunc['htmlspecialchars'](strtr(implode('', $file_data), array("\t" => '   ')));
1875
-	}
1876
-	else
1949
+	} else
1877 1950
 	{
1878 1951
 		$context['sub_template'] = 'edit_file';
1879 1952
 
@@ -1899,8 +1972,9 @@  discard block
 block discarded – undo
1899 1972
 
1900 1973
 	$_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id'];
1901 1974
 
1902
-	if (empty($_GET['th']))
1903
-		fatal_lang_error('theme_install_invalid_id');
1975
+	if (empty($_GET['th'])) {
1976
+			fatal_lang_error('theme_install_invalid_id');
1977
+	}
1904 1978
 
1905 1979
 	// Get the theme info.
1906 1980
 	$theme = get_single_theme($_GET['th']);
@@ -1908,25 +1982,24 @@  discard block
 block discarded – undo
1908 1982
 
1909 1983
 	if (isset($_REQUEST['template']) && preg_match('~[\./\\\\:\0]~', $_REQUEST['template']) == 0)
1910 1984
 	{
1911
-		if (file_exists($settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php'))
1912
-			$filename = $settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php';
1913
-
1914
-		else
1915
-			fatal_lang_error('no_access', false);
1985
+		if (file_exists($settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php')) {
1986
+					$filename = $settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php';
1987
+		} else {
1988
+					fatal_lang_error('no_access', false);
1989
+		}
1916 1990
 
1917 1991
 		$fp = fopen($theme['theme_dir'] . '/' . $_REQUEST['template'] . '.template.php', 'w');
1918 1992
 		fwrite($fp, file_get_contents($filename));
1919 1993
 		fclose($fp);
1920 1994
 
1921 1995
 		redirectexit('action=admin;area=theme;th=' . $context['theme_id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=copy');
1922
-	}
1923
-	elseif (isset($_REQUEST['lang_file']) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $_REQUEST['lang_file']) != 0)
1996
+	} elseif (isset($_REQUEST['lang_file']) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $_REQUEST['lang_file']) != 0)
1924 1997
 	{
1925
-		if (file_exists($settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php'))
1926
-			$filename = $settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php';
1927
-
1928
-		else
1929
-			fatal_lang_error('no_access', false);
1998
+		if (file_exists($settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php')) {
1999
+					$filename = $settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php';
2000
+		} else {
2001
+					fatal_lang_error('no_access', false);
2002
+		}
1930 2003
 
1931 2004
 		$fp = fopen($theme['theme_dir'] . '/languages/' . $_REQUEST['lang_file'] . '.php', 'w');
1932 2005
 		fwrite($fp, file_get_contents($filename));
@@ -1941,16 +2014,18 @@  discard block
 block discarded – undo
1941 2014
 	$dir = dir($settings['default_theme_dir']);
1942 2015
 	while ($entry = $dir->read())
1943 2016
 	{
1944
-		if (substr($entry, -13) == '.template.php')
1945
-			$templates[] = substr($entry, 0, -13);
2017
+		if (substr($entry, -13) == '.template.php') {
2018
+					$templates[] = substr($entry, 0, -13);
2019
+		}
1946 2020
 	}
1947 2021
 	$dir->close();
1948 2022
 
1949 2023
 	$dir = dir($settings['default_theme_dir'] . '/languages');
1950 2024
 	while ($entry = $dir->read())
1951 2025
 	{
1952
-		if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches))
1953
-			$lang_files[] = $matches[1];
2026
+		if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches)) {
2027
+					$lang_files[] = $matches[1];
2028
+		}
1954 2029
 	}
1955 2030
 	$dir->close();
1956 2031
 
@@ -1958,21 +2033,23 @@  discard block
 block discarded – undo
1958 2033
 	natcasesort($lang_files);
1959 2034
 
1960 2035
 	$context['available_templates'] = array();
1961
-	foreach ($templates as $template)
1962
-		$context['available_templates'][$template] = array(
2036
+	foreach ($templates as $template) {
2037
+			$context['available_templates'][$template] = array(
1963 2038
 			'filename' => $template . '.template.php',
1964 2039
 			'value' => $template,
1965 2040
 			'already_exists' => false,
1966 2041
 			'can_copy' => is_writable($theme['theme_dir']),
1967 2042
 		);
2043
+	}
1968 2044
 	$context['available_language_files'] = array();
1969
-	foreach ($lang_files as $file)
1970
-		$context['available_language_files'][$file] = array(
2045
+	foreach ($lang_files as $file) {
2046
+			$context['available_language_files'][$file] = array(
1971 2047
 			'filename' => $file . '.php',
1972 2048
 			'value' => $file,
1973 2049
 			'already_exists' => false,
1974 2050
 			'can_copy' => file_exists($theme['theme_dir'] . '/languages') ? is_writable($theme['theme_dir'] . '/languages') : is_writable($theme['theme_dir']),
1975 2051
 		);
2052
+	}
1976 2053
 
1977 2054
 	$dir = dir($theme['theme_dir']);
1978 2055
 	while ($entry = $dir->read())
Please login to merge, or discard this patch.
Themes/default/GenericMenu.template.php 1 patch
Braces   +54 added lines, -39 removed lines patch added patch discarded remove patch
@@ -83,16 +83,18 @@  discard block
 block discarded – undo
83 83
 		foreach ($section['areas'] as $i => $area)
84 84
 		{
85 85
 			// Not supposed to be printed?
86
-			if (empty($area['label']))
87
-				continue;
86
+			if (empty($area['label'])) {
87
+							continue;
88
+			}
88 89
 
89 90
 			echo '
90 91
 								<li', !empty($area['subsections']) ? ' class="subsections"' : '', '>
91 92
 									<a class="', $area['icon_class'], !empty($area['selected']) ? ' chosen ' : '', '" href="', (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i), $menu_context['extra_parameters'], '">', $area['icon'], $area['label'], !empty($area['amt']) ? ' <span class="amt">' . $area['amt'] . '</span>' : '', '</a>';
92 93
 
93 94
 			// Is this the current area, or just some area?
94
-			if (!empty($area['selected']) && empty($context['tabs']))
95
-					$context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array();
95
+			if (!empty($area['selected']) && empty($context['tabs'])) {
96
+								$context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array();
97
+			}
96 98
 
97 99
 			// Are there any subsections?
98 100
 			if (!empty($area['subsections']))
@@ -102,8 +104,9 @@  discard block
 block discarded – undo
102 104
 
103 105
 				foreach ($area['subsections'] as $sa => $sub)
104 106
 				{
105
-					if (!empty($sub['disabled']))
106
-						continue;
107
+					if (!empty($sub['disabled'])) {
108
+											continue;
109
+					}
107 110
 
108 111
 					$url = isset($sub['url']) ? $sub['url'] : (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i) . ';sa=' . $sa;
109 112
 
@@ -150,8 +153,9 @@  discard block
 block discarded – undo
150 153
 							<h3 class="catbg">';
151 154
 
152 155
 		// The function is in Admin.template.php, but since this template is used elsewhere too better check if the function is available
153
-		if (function_exists('template_admin_quick_search'))
154
-			template_admin_quick_search();
156
+		if (function_exists('template_admin_quick_search')) {
157
+					template_admin_quick_search();
158
+		}
155 159
 
156 160
 		// Exactly how many tabs do we have?
157 161
 		if (!empty($context['tabs']))
@@ -166,30 +170,36 @@  discard block
 block discarded – undo
166 170
 				}
167 171
 
168 172
 				// Did this not even exist - or do we not have a label?
169
-				if (!isset($tab_context['tabs'][$id]))
170
-					$tab_context['tabs'][$id] = array('label' => $tab['label']);
171
-				elseif (!isset($tab_context['tabs'][$id]['label']))
172
-					$tab_context['tabs'][$id]['label'] = $tab['label'];
173
+				if (!isset($tab_context['tabs'][$id])) {
174
+									$tab_context['tabs'][$id] = array('label' => $tab['label']);
175
+				} elseif (!isset($tab_context['tabs'][$id]['label'])) {
176
+									$tab_context['tabs'][$id]['label'] = $tab['label'];
177
+				}
173 178
 
174 179
 				// Has a custom URL defined in the main admin structure?
175
-				if (isset($tab['url']) && !isset($tab_context['tabs'][$id]['url']))
176
-					$tab_context['tabs'][$id]['url'] = $tab['url'];
180
+				if (isset($tab['url']) && !isset($tab_context['tabs'][$id]['url'])) {
181
+									$tab_context['tabs'][$id]['url'] = $tab['url'];
182
+				}
177 183
 
178 184
 				// Any additional paramaters for the url?
179
-				if (isset($tab['add_params']) && !isset($tab_context['tabs'][$id]['add_params']))
180
-					$tab_context['tabs'][$id]['add_params'] = $tab['add_params'];
185
+				if (isset($tab['add_params']) && !isset($tab_context['tabs'][$id]['add_params'])) {
186
+									$tab_context['tabs'][$id]['add_params'] = $tab['add_params'];
187
+				}
181 188
 
182 189
 				// Has it been deemed selected?
183
-				if (!empty($tab['is_selected']))
184
-					$tab_context['tabs'][$id]['is_selected'] = true;
190
+				if (!empty($tab['is_selected'])) {
191
+									$tab_context['tabs'][$id]['is_selected'] = true;
192
+				}
185 193
 
186 194
 				// Does it have its own help?
187
-				if (!empty($tab['help']))
188
-					$tab_context['tabs'][$id]['help'] = $tab['help'];
195
+				if (!empty($tab['help'])) {
196
+									$tab_context['tabs'][$id]['help'] = $tab['help'];
197
+				}
189 198
 
190 199
 				// Is this the last one?
191
-				if (!empty($tab['is_last']) && !isset($tab_context['override_last']))
192
-					$tab_context['tabs'][$id]['is_last'] = true;
200
+				if (!empty($tab['is_last']) && !isset($tab_context['override_last'])) {
201
+									$tab_context['tabs'][$id]['is_last'] = true;
202
+				}
193 203
 			}
194 204
 
195 205
 			// Find the selected tab
@@ -206,22 +216,24 @@  discard block
 block discarded – undo
206 216
 		// Show an icon and/or a help item?
207 217
 		if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class']) || !empty($selected_tab['icon']) || !empty($tab_context['icon']) || !empty($selected_tab['help']) || !empty($tab_context['help']))
208 218
 		{
209
-			if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class']))
210
-				echo '
219
+			if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class'])) {
220
+							echo '
211 221
 								<span class="', !empty($selected_tab['icon_class']) ? $selected_tab['icon_class'] : $tab_context['icon_class'], ' icon"></span>';
212
-			elseif (!empty($selected_tab['icon']) || !empty($tab_context['icon']))
213
-				echo '
222
+			} elseif (!empty($selected_tab['icon']) || !empty($tab_context['icon'])) {
223
+							echo '
214 224
 								<img src="', $settings['images_url'], '/icons/', !empty($selected_tab['icon']) ? $selected_tab['icon'] : $tab_context['icon'], '" alt="" class="icon">';
225
+			}
215 226
 
216
-			if (!empty($selected_tab['help']) || !empty($tab_context['help']))
217
-				echo '
227
+			if (!empty($selected_tab['help']) || !empty($tab_context['help'])) {
228
+							echo '
218 229
 								<a href="', $scripturl, '?action=helpadmin;help=', !empty($selected_tab['help']) ? $selected_tab['help'] : $tab_context['help'], '" onclick="return reqOverlayDiv(this.href);" class="help"><span class="generic_icons help" title="', $txt['help'], '"></span></a>';
230
+			}
219 231
 
220 232
 			echo $tab_context['title'];
221
-		}
222
-		else
223
-			echo '
233
+		} else {
234
+					echo '
224 235
 								', $tab_context['title'];
236
+		}
225 237
 
226 238
 		echo '
227 239
 							</h3>', (function_exists('template_admin_quick_search') ? '
@@ -230,11 +242,12 @@  discard block
 block discarded – undo
230 242
 	}
231 243
 
232 244
 	// Shall we use the tabs? Yes, it's the only known way!
233
-	if (!empty($selected_tab['description']) || !empty($tab_context['description']))
234
-		echo '
245
+	if (!empty($selected_tab['description']) || !empty($tab_context['description'])) {
246
+			echo '
235 247
 					<p class="information">
236 248
 						', !empty($selected_tab['description']) ? $selected_tab['description'] : $tab_context['description'], '
237 249
 					</p>';
250
+	}
238 251
 
239 252
 	// Print out all the items in this tab (if any).
240 253
 	if (!empty($context['tabs']))
@@ -246,19 +259,21 @@  discard block
 block discarded – undo
246 259
 
247 260
 		foreach ($tab_context['tabs'] as $sa => $tab)
248 261
 		{
249
-			if (!empty($tab['disabled']))
250
-				continue;
262
+			if (!empty($tab['disabled'])) {
263
+							continue;
264
+			}
251 265
 
252
-			if (!empty($tab['is_selected']))
253
-				echo '
266
+			if (!empty($tab['is_selected'])) {
267
+							echo '
254 268
 							<li>
255 269
 								<a class="active" href="', isset($tab['url']) ? $tab['url'] : $menu_context['base_url'] . ';area=' . $menu_context['current_area'] . ';sa=' . $sa, $menu_context['extra_parameters'], isset($tab['add_params']) ? $tab['add_params'] : '', '">', $tab['label'], '</a>
256 270
 							</li>';
257
-			else
258
-				echo '
271
+			} else {
272
+							echo '
259 273
 							<li>
260 274
 								<a href="', isset($tab['url']) ? $tab['url'] : $menu_context['base_url'] . ';area=' . $menu_context['current_area'] . ';sa=' . $sa, $menu_context['extra_parameters'], isset($tab['add_params']) ? $tab['add_params'] : '', '">', $tab['label'], '</a>
261 275
 							</li>';
276
+			}
262 277
 		}
263 278
 
264 279
 		// The end of tabs
Please login to merge, or discard this patch.
Sources/Subs-Editor.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1112,7 +1112,7 @@
 block discarded – undo
1112 1112
 		$lastlen = strlen($text = preg_replace($backToBackPattern, '', $text));
1113 1113
 
1114 1114
 	// Need to sort the tags by name length.
1115
-	uksort($valid_tags, function ($a, $b) {
1115
+	uksort($valid_tags, function($a, $b) {
1116 1116
 		return strlen($a) < strlen($b) ? 1 : -1;
1117 1117
 	});
1118 1118
 
Please login to merge, or discard this 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
  * As of SMF 2.1, this is unused. But it is available if any mod wants to use it.
@@ -30,8 +31,9 @@  discard block
 block discarded – undo
30 31
 {
31 32
 	global $modSettings;
32 33
 
33
-	if (!$compat_mode)
34
-		return $text;
34
+	if (!$compat_mode) {
35
+			return $text;
36
+	}
35 37
 
36 38
 	// Turn line breaks back into br's.
37 39
 	$text = strtr($text, array("\r" => '', "\n" => '<br>'));
@@ -48,8 +50,9 @@  discard block
 block discarded – undo
48 50
 			for ($i = 0, $n = count($parts); $i < $n; $i++)
49 51
 			{
50 52
 				// Value of 2 means we're inside the tag.
51
-				if ($i % 4 == 2)
52
-					$parts[$i] = strtr($parts[$i], array('[' => '&#91;', ']' => '&#93;', "'" => "'"));
53
+				if ($i % 4 == 2) {
54
+									$parts[$i] = strtr($parts[$i], array('[' => '&#91;', ']' => '&#93;', "'" => "'"));
55
+				}
53 56
 			}
54 57
 			// Put our humpty dumpty message back together again.
55 58
 			$text = implode('', $parts);
@@ -104,8 +107,9 @@  discard block
 block discarded – undo
104 107
 	$text = preg_replace('~</p>\s*(?!<)~i', '</p><br>', $text);
105 108
 
106 109
 	// Safari/webkit wraps lines in Wysiwyg in <div>'s.
107
-	if (isBrowser('webkit'))
108
-		$text = preg_replace(array('~<div(?:\s(?:[^<>]*?))?' . '>~i', '</div>'), array('<br>', ''), $text);
110
+	if (isBrowser('webkit')) {
111
+			$text = preg_replace(array('~<div(?:\s(?:[^<>]*?))?' . '>~i', '</div>'), array('<br>', ''), $text);
112
+	}
109 113
 
110 114
 	// If there's a trailing break get rid of it - Firefox tends to add one.
111 115
 	$text = preg_replace('~<br\s?/?' . '>$~i', '', $text);
@@ -120,8 +124,9 @@  discard block
 block discarded – undo
120 124
 		for ($i = 0, $n = count($parts); $i < $n; $i++)
121 125
 		{
122 126
 			// Value of 2 means we're inside the tag.
123
-			if ($i % 4 == 2)
124
-				$parts[$i] = strip_tags($parts[$i]);
127
+			if ($i % 4 == 2) {
128
+							$parts[$i] = strip_tags($parts[$i]);
129
+			}
125 130
 		}
126 131
 
127 132
 		$text = strtr(implode('', $parts), array('#smf_br_spec_grudge_cool!#' => '<br>'));
@@ -147,18 +152,19 @@  discard block
 block discarded – undo
147 152
 			{
148 153
 				$found = array_search($file, $smileysto);
149 154
 				// Note the weirdness here is to stop double spaces between smileys.
150
-				if ($found)
151
-					$matches[1][$k] = '-[]-smf_smily_start#|#' . $smcFunc['htmlspecialchars']($smileysfrom[$found]) . '-[]-smf_smily_end#|#';
152
-				else
153
-					$matches[1][$k] = '';
155
+				if ($found) {
156
+									$matches[1][$k] = '-[]-smf_smily_start#|#' . $smcFunc['htmlspecialchars']($smileysfrom[$found]) . '-[]-smf_smily_end#|#';
157
+				} else {
158
+									$matches[1][$k] = '';
159
+				}
154 160
 			}
155
-		}
156
-		else
161
+		} else
157 162
 		{
158 163
 			// Load all the smileys.
159 164
 			$names = array();
160
-			foreach ($matches[1] as $file)
161
-				$names[] = $file;
165
+			foreach ($matches[1] as $file) {
166
+							$names[] = $file;
167
+			}
162 168
 			$names = array_unique($names);
163 169
 
164 170
 			if (!empty($names))
@@ -172,13 +178,15 @@  discard block
 block discarded – undo
172 178
 					)
173 179
 				);
174 180
 				$mappings = array();
175
-				while ($row = $smcFunc['db_fetch_assoc']($request))
176
-					$mappings[$row['filename']] = $smcFunc['htmlspecialchars']($row['code']);
181
+				while ($row = $smcFunc['db_fetch_assoc']($request)) {
182
+									$mappings[$row['filename']] = $smcFunc['htmlspecialchars']($row['code']);
183
+				}
177 184
 				$smcFunc['db_free_result']($request);
178 185
 
179
-				foreach ($matches[1] as $k => $file)
180
-					if (isset($mappings[$file]))
186
+				foreach ($matches[1] as $k => $file) {
187
+									if (isset($mappings[$file]))
181 188
 						$matches[1][$k] = '-[]-smf_smily_start#|#' . $mappings[$file] . '-[]-smf_smily_end#|#';
189
+				}
182 190
 			}
183 191
 		}
184 192
 
@@ -190,8 +198,9 @@  discard block
 block discarded – undo
190 198
 	}
191 199
 
192 200
 	// Only try to buy more time if the client didn't quit.
193
-	if (connection_aborted() && $context['server']['is_apache'])
194
-		@apache_reset_timeout();
201
+	if (connection_aborted() && $context['server']['is_apache']) {
202
+			@apache_reset_timeout();
203
+	}
195 204
 
196 205
 	$parts = preg_split('~(<[A-Za-z]+\s*[^<>]*?style="?[^<>"]+"?[^<>]*?(?:/?)>|</[A-Za-z]+>)~', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
197 206
 	$replacement = '';
@@ -202,9 +211,9 @@  discard block
 block discarded – undo
202 211
 		if (preg_match('~(<([A-Za-z]+)\s*[^<>]*?)style="?([^<>"]+)"?([^<>]*?(/?)>)~', $part, $matches) === 1)
203 212
 		{
204 213
 			// If it's being closed instantly, we can't deal with it...yet.
205
-			if ($matches[5] === '/')
206
-				continue;
207
-			else
214
+			if ($matches[5] === '/') {
215
+							continue;
216
+			} else
208 217
 			{
209 218
 				// Get an array of styles that apply to this element. (The strtr is there to combat HTML generated by Word.)
210 219
 				$styles = explode(';', strtr($matches[3], array('&quot;' => '')));
@@ -220,8 +229,9 @@  discard block
 block discarded – undo
220 229
 					$clean_type_value_pair = strtolower(strtr(trim($type_value_pair), '=', ':'));
221 230
 
222 231
 					// Something like 'font-weight: bold' is expected here.
223
-					if (strpos($clean_type_value_pair, ':') === false)
224
-						continue;
232
+					if (strpos($clean_type_value_pair, ':') === false) {
233
+											continue;
234
+					}
225 235
 
226 236
 					// Capture the elements of a single style item (e.g. 'font-weight' and 'bold').
227 237
 					list ($style_type, $style_value) = explode(':', $type_value_pair);
@@ -243,8 +253,7 @@  discard block
 block discarded – undo
243 253
 							{
244 254
 								$curCloseTags .= '[/u]';
245 255
 								$replacement .= '[u]';
246
-							}
247
-							elseif ($style_value == 'line-through')
256
+							} elseif ($style_value == 'line-through')
248 257
 							{
249 258
 								$curCloseTags .= '[/s]';
250 259
 								$replacement .= '[s]';
@@ -256,13 +265,11 @@  discard block
 block discarded – undo
256 265
 							{
257 266
 								$curCloseTags .= '[/left]';
258 267
 								$replacement .= '[left]';
259
-							}
260
-							elseif ($style_value == 'center')
268
+							} elseif ($style_value == 'center')
261 269
 							{
262 270
 								$curCloseTags .= '[/center]';
263 271
 								$replacement .= '[center]';
264
-							}
265
-							elseif ($style_value == 'right')
272
+							} elseif ($style_value == 'right')
266 273
 							{
267 274
 								$curCloseTags .= '[/right]';
268 275
 								$replacement .= '[right]';
@@ -284,8 +291,9 @@  discard block
 block discarded – undo
284 291
 
285 292
 						case 'font-size':
286 293
 							// Sometimes people put decimals where decimals should not be.
287
-							if (preg_match('~(\d)+\.\d+(p[xt])~i', $style_value, $dec_matches) === 1)
288
-								$style_value = $dec_matches[1] . $dec_matches[2];
294
+							if (preg_match('~(\d)+\.\d+(p[xt])~i', $style_value, $dec_matches) === 1) {
295
+															$style_value = $dec_matches[1] . $dec_matches[2];
296
+							}
289 297
 
290 298
 							$curCloseTags .= '[/size]';
291 299
 							$replacement .= '[size=' . $style_value . ']';
@@ -293,8 +301,9 @@  discard block
 block discarded – undo
293 301
 
294 302
 						case 'font-family':
295 303
 							// Only get the first freaking font if there's a list!
296
-							if (strpos($style_value, ',') !== false)
297
-								$style_value = substr($style_value, 0, strpos($style_value, ','));
304
+							if (strpos($style_value, ',') !== false) {
305
+															$style_value = substr($style_value, 0, strpos($style_value, ','));
306
+							}
298 307
 
299 308
 							$curCloseTags .= '[/font]';
300 309
 							$replacement .= '[font=' . strtr($style_value, array("'" => '')) . ']';
@@ -303,13 +312,15 @@  discard block
 block discarded – undo
303 312
 						// This is a hack for images with dimensions embedded.
304 313
 						case 'width':
305 314
 						case 'height':
306
-							if (preg_match('~[1-9]\d*~i', $style_value, $dimension) === 1)
307
-								$extra_attr .= ' ' . $style_type . '="' . $dimension[0] . '"';
315
+							if (preg_match('~[1-9]\d*~i', $style_value, $dimension) === 1) {
316
+															$extra_attr .= ' ' . $style_type . '="' . $dimension[0] . '"';
317
+							}
308 318
 						break;
309 319
 
310 320
 						case 'list-style-type':
311
-							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)
312
-								$extra_attr .= ' listtype="' . $listType[0] . '"';
321
+							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) {
322
+															$extra_attr .= ' listtype="' . $listType[0] . '"';
323
+							}
313 324
 						break;
314 325
 					}
315 326
 				}
@@ -322,18 +333,17 @@  discard block
 block discarded – undo
322 333
 				}
323 334
 
324 335
 				// If there's something that still needs closing, push it to the stack.
325
-				if (!empty($curCloseTags))
326
-					array_push($stack, array(
336
+				if (!empty($curCloseTags)) {
337
+									array_push($stack, array(
327 338
 							'element' => strtolower($curElement),
328 339
 							'closeTags' => $curCloseTags
329 340
 						)
330 341
 					);
331
-				elseif (!empty($extra_attr))
332
-					$replacement .= $precedingStyle . $extra_attr . $afterStyle;
342
+				} elseif (!empty($extra_attr)) {
343
+									$replacement .= $precedingStyle . $extra_attr . $afterStyle;
344
+				}
333 345
 			}
334
-		}
335
-
336
-		elseif (preg_match('~</([A-Za-z]+)>~', $part, $matches) === 1)
346
+		} elseif (preg_match('~</([A-Za-z]+)>~', $part, $matches) === 1)
337 347
 		{
338 348
 			// Is this the element that we've been waiting for to be closed?
339 349
 			if (!empty($stack) && strtolower($matches[1]) === $stack[count($stack) - 1]['element'])
@@ -343,28 +353,32 @@  discard block
 block discarded – undo
343 353
 			}
344 354
 
345 355
 			// Must've been something else.
346
-			else
347
-				$replacement .= $part;
356
+			else {
357
+							$replacement .= $part;
358
+			}
348 359
 		}
349 360
 		// In all other cases, just add the part to the replacement.
350
-		else
351
-			$replacement .= $part;
361
+		else {
362
+					$replacement .= $part;
363
+		}
352 364
 	}
353 365
 
354 366
 	// Now put back the replacement in the text.
355 367
 	$text = $replacement;
356 368
 
357 369
 	// We are not finished yet, request more time.
358
-	if (connection_aborted() && $context['server']['is_apache'])
359
-		@apache_reset_timeout();
370
+	if (connection_aborted() && $context['server']['is_apache']) {
371
+			@apache_reset_timeout();
372
+	}
360 373
 
361 374
 	// Let's pull out any legacy alignments.
362 375
 	while (preg_match('~<([A-Za-z]+)\s+[^<>]*?(align="*(left|center|right)"*)[^<>]*?(/?)>~i', $text, $matches) === 1)
363 376
 	{
364 377
 		// Find the position in the text of this tag over again.
365 378
 		$start_pos = strpos($text, $matches[0]);
366
-		if ($start_pos === false)
367
-			break;
379
+		if ($start_pos === false) {
380
+					break;
381
+		}
368 382
 
369 383
 		// End tag?
370 384
 		if ($matches[4] != '/' && strpos($text, '</' . $matches[1] . '>', $start_pos) !== false)
@@ -378,8 +392,7 @@  discard block
 block discarded – undo
378 392
 
379 393
 			// Put the tags back into the body.
380 394
 			$text = substr($text, 0, $start_pos) . $tag . '[' . $matches[3] . ']' . $content . '[/' . $matches[3] . ']' . substr($text, $end_pos);
381
-		}
382
-		else
395
+		} else
383 396
 		{
384 397
 			// Just get rid of this evil tag.
385 398
 			$text = substr($text, 0, $start_pos) . substr($text, $start_pos + strlen($matches[0]));
@@ -392,8 +405,9 @@  discard block
 block discarded – undo
392 405
 		// Find the position of this again.
393 406
 		$start_pos = strpos($text, $matches[0]);
394 407
 		$end_pos = false;
395
-		if ($start_pos === false)
396
-			break;
408
+		if ($start_pos === false) {
409
+					break;
410
+		}
397 411
 
398 412
 		// This must have an end tag - and we must find the right one.
399 413
 		$lower_text = strtolower($text);
@@ -426,8 +440,9 @@  discard block
 block discarded – undo
426 440
 				break;
427 441
 			}
428 442
 		}
429
-		if ($end_pos === false)
430
-			break;
443
+		if ($end_pos === false) {
444
+					break;
445
+		}
431 446
 
432 447
 		// Now work out what the attributes are.
433 448
 		$attribs = fetchTagAttributes($matches[1]);
@@ -441,11 +456,11 @@  discard block
 block discarded – undo
441 456
 				$v = (int) trim($v);
442 457
 				$v = empty($v) ? 1 : $v;
443 458
 				$tags[] = array('[size=' . $sizes_equivalence[$v] . ']', '[/size]');
459
+			} elseif ($s == 'face') {
460
+							$tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]');
461
+			} elseif ($s == 'color') {
462
+							$tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]');
444 463
 			}
445
-			elseif ($s == 'face')
446
-				$tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]');
447
-			elseif ($s == 'color')
448
-				$tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]');
449 464
 		}
450 465
 
451 466
 		// As before add in our tags.
@@ -453,8 +468,9 @@  discard block
 block discarded – undo
453 468
 		foreach ($tags as $tag)
454 469
 		{
455 470
 			$before .= $tag[0];
456
-			if (isset($tag[1]))
457
-				$after = $tag[1] . $after;
471
+			if (isset($tag[1])) {
472
+							$after = $tag[1] . $after;
473
+			}
458 474
 		}
459 475
 
460 476
 		// Remove the tag so it's never checked again.
@@ -465,8 +481,9 @@  discard block
 block discarded – undo
465 481
 	}
466 482
 
467 483
 	// Almost there, just a little more time.
468
-	if (connection_aborted() && $context['server']['is_apache'])
469
-		@apache_reset_timeout();
484
+	if (connection_aborted() && $context['server']['is_apache']) {
485
+			@apache_reset_timeout();
486
+	}
470 487
 
471 488
 	if (count($parts = preg_split('~<(/?)(li|ol|ul)([^>]*)>~i', $text, null, PREG_SPLIT_DELIM_CAPTURE)) > 1)
472 489
 	{
@@ -522,12 +539,13 @@  discard block
 block discarded – undo
522 539
 						{
523 540
 							$inList = true;
524 541
 
525
-							if ($tag === 'ol')
526
-								$listType = 'decimal';
527
-							elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1)
528
-								$listType = $listTypeMapping[$match[1]];
529
-							else
530
-								$listType = null;
542
+							if ($tag === 'ol') {
543
+															$listType = 'decimal';
544
+							} elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1) {
545
+															$listType = $listTypeMapping[$match[1]];
546
+							} else {
547
+															$listType = null;
548
+							}
531 549
 
532 550
 							$listDepth++;
533 551
 
@@ -591,9 +609,7 @@  discard block
 block discarded – undo
591 609
 							$parts[$i + 1] = '';
592 610
 							$parts[$i + 2] = str_repeat("\t", $listDepth) . '[/list]';
593 611
 							$parts[$i + 3] = '';
594
-						}
595
-
596
-						else
612
+						} else
597 613
 						{
598 614
 							// We're in a list item.
599 615
 							if ($listDepth > 0)
@@ -630,9 +646,7 @@  discard block
 block discarded – undo
630 646
 							$parts[$i + 1] = '';
631 647
 							$parts[$i + 2] = '';
632 648
 							$parts[$i + 3] = '';
633
-						}
634
-
635
-						else
649
+						} else
636 650
 						{
637 651
 							// Remove the trailing breaks from the list item.
638 652
 							$parts[$i] = preg_replace('~\s*<br\s*' . '/?' . '>\s*$~', '', $parts[$i]);
@@ -670,8 +684,9 @@  discard block
 block discarded – undo
670 684
 			$text .= str_repeat("\t", $listDepth) . '[/list]';
671 685
 		}
672 686
 
673
-		for ($i = $listDepth; $i > 0; $i--)
674
-			$text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]';
687
+		for ($i = $listDepth; $i > 0; $i--) {
688
+					$text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]';
689
+		}
675 690
 	}
676 691
 
677 692
 	// I love my own image...
@@ -679,8 +694,9 @@  discard block
 block discarded – undo
679 694
 	{
680 695
 		// Find the position of the image.
681 696
 		$start_pos = strpos($text, $matches[0]);
682
-		if ($start_pos === false)
683
-			break;
697
+		if ($start_pos === false) {
698
+					break;
699
+		}
684 700
 		$end_pos = $start_pos + strlen($matches[0]);
685 701
 
686 702
 		$params = '';
@@ -689,12 +705,13 @@  discard block
 block discarded – undo
689 705
 		$attrs = fetchTagAttributes($matches[1]);
690 706
 		foreach ($attrs as $attrib => $value)
691 707
 		{
692
-			if (in_array($attrib, array('width', 'height')))
693
-				$params .= ' ' . $attrib . '=' . (int) $value;
694
-			elseif ($attrib == 'alt' && trim($value) != '')
695
-				$params .= ' alt=' . trim($value);
696
-			elseif ($attrib == 'src')
697
-				$src = trim($value);
708
+			if (in_array($attrib, array('width', 'height'))) {
709
+							$params .= ' ' . $attrib . '=' . (int) $value;
710
+			} elseif ($attrib == 'alt' && trim($value) != '') {
711
+							$params .= ' alt=' . trim($value);
712
+			} elseif ($attrib == 'src') {
713
+							$src = trim($value);
714
+			}
698 715
 		}
699 716
 
700 717
 		$tag = '';
@@ -705,10 +722,11 @@  discard block
 block discarded – undo
705 722
 			{
706 723
 				$baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']);
707 724
 
708
-				if (substr($src, 0, 1) === '/')
709
-					$src = $baseURL . $src;
710
-				else
711
-					$src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src;
725
+				if (substr($src, 0, 1) === '/') {
726
+									$src = $baseURL . $src;
727
+				} else {
728
+									$src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src;
729
+				}
712 730
 			}
713 731
 
714 732
 			$tag = '[img' . $params . ']' . $src . '[/img]';
@@ -886,20 +904,23 @@  discard block
 block discarded – undo
886 904
 		},
887 905
 	);
888 906
 
889
-	foreach ($tags as $tag => $replace)
890
-		$text = preg_replace_callback($tag, $replace, $text);
907
+	foreach ($tags as $tag => $replace) {
908
+			$text = preg_replace_callback($tag, $replace, $text);
909
+	}
891 910
 
892 911
 	// Please give us just a little more time.
893
-	if (connection_aborted() && $context['server']['is_apache'])
894
-		@apache_reset_timeout();
912
+	if (connection_aborted() && $context['server']['is_apache']) {
913
+			@apache_reset_timeout();
914
+	}
895 915
 
896 916
 	// What about URL's - the pain in the ass of the tag world.
897 917
 	while (preg_match('~<a\s+([^<>]*)>([^<>]*)</a>~i', $text, $matches) === 1)
898 918
 	{
899 919
 		// Find the position of the URL.
900 920
 		$start_pos = strpos($text, $matches[0]);
901
-		if ($start_pos === false)
902
-			break;
921
+		if ($start_pos === false) {
922
+					break;
923
+		}
903 924
 		$end_pos = $start_pos + strlen($matches[0]);
904 925
 
905 926
 		$tag_type = 'url';
@@ -913,8 +934,9 @@  discard block
 block discarded – undo
913 934
 				$href = trim($value);
914 935
 
915 936
 				// Are we dealing with an FTP link?
916
-				if (preg_match('~^ftps?://~', $href) === 1)
917
-					$tag_type = 'ftp';
937
+				if (preg_match('~^ftps?://~', $href) === 1) {
938
+									$tag_type = 'ftp';
939
+				}
918 940
 
919 941
 				// Or is this a link to an email address?
920 942
 				elseif (substr($href, 0, 7) == 'mailto:')
@@ -928,28 +950,31 @@  discard block
 block discarded – undo
928 950
 				{
929 951
 					$baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']);
930 952
 
931
-					if (substr($href, 0, 1) === '/')
932
-						$href = $baseURL . $href;
933
-					else
934
-						$href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href;
953
+					if (substr($href, 0, 1) === '/') {
954
+											$href = $baseURL . $href;
955
+					} else {
956
+											$href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href;
957
+					}
935 958
 				}
936 959
 			}
937 960
 
938 961
 			// External URL?
939 962
 			if ($attrib == 'target' && $tag_type == 'url')
940 963
 			{
941
-				if (trim($value) == '_blank')
942
-					$tag_type == 'iurl';
964
+				if (trim($value) == '_blank') {
965
+									$tag_type == 'iurl';
966
+				}
943 967
 			}
944 968
 		}
945 969
 
946 970
 		$tag = '';
947 971
 		if ($href != '')
948 972
 		{
949
-			if ($matches[2] == $href)
950
-				$tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']';
951
-			else
952
-				$tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']';
973
+			if ($matches[2] == $href) {
974
+							$tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']';
975
+			} else {
976
+							$tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']';
977
+			}
953 978
 		}
954 979
 
955 980
 		// Replace the tag
@@ -985,17 +1010,18 @@  discard block
 block discarded – undo
985 1010
 		// We're either moving from the key to the attribute or we're in a string and this is fine.
986 1011
 		if ($text[$i] == '=')
987 1012
 		{
988
-			if ($tag_state == 0)
989
-				$tag_state = 1;
990
-			elseif ($tag_state == 2)
991
-				$value .= '=';
1013
+			if ($tag_state == 0) {
1014
+							$tag_state = 1;
1015
+			} elseif ($tag_state == 2) {
1016
+							$value .= '=';
1017
+			}
992 1018
 		}
993 1019
 		// A space is either moving from an attribute back to a potential key or in a string is fine.
994 1020
 		elseif ($text[$i] == ' ')
995 1021
 		{
996
-			if ($tag_state == 2)
997
-				$value .= ' ';
998
-			elseif ($tag_state == 1)
1022
+			if ($tag_state == 2) {
1023
+							$value .= ' ';
1024
+			} elseif ($tag_state == 1)
999 1025
 			{
1000 1026
 				$attribs[$key] = $value;
1001 1027
 				$key = $value = '';
@@ -1006,24 +1032,27 @@  discard block
 block discarded – undo
1006 1032
 		elseif ($text[$i] == '"')
1007 1033
 		{
1008 1034
 			// Must be either going into or out of a string.
1009
-			if ($tag_state == 1)
1010
-				$tag_state = 2;
1011
-			else
1012
-				$tag_state = 1;
1035
+			if ($tag_state == 1) {
1036
+							$tag_state = 2;
1037
+			} else {
1038
+							$tag_state = 1;
1039
+			}
1013 1040
 		}
1014 1041
 		// Otherwise it's fine.
1015 1042
 		else
1016 1043
 		{
1017
-			if ($tag_state == 0)
1018
-				$key .= $text[$i];
1019
-			else
1020
-				$value .= $text[$i];
1044
+			if ($tag_state == 0) {
1045
+							$key .= $text[$i];
1046
+			} else {
1047
+							$value .= $text[$i];
1048
+			}
1021 1049
 		}
1022 1050
 	}
1023 1051
 
1024 1052
 	// Anything left?
1025
-	if ($key != '' && $value != '')
1026
-		$attribs[$key] = $value;
1053
+	if ($key != '' && $value != '') {
1054
+			$attribs[$key] = $value;
1055
+	}
1027 1056
 
1028 1057
 	return $attribs;
1029 1058
 }
@@ -1039,8 +1068,9 @@  discard block
 block discarded – undo
1039 1068
 	global $modSettings;
1040 1069
 
1041 1070
 	// Don't care about the texts that are too short.
1042
-	if (strlen($text) < 3)
1043
-		return $text;
1071
+	if (strlen($text) < 3) {
1072
+			return $text;
1073
+	}
1044 1074
 
1045 1075
 	// A list of tags that's disabled by the admin.
1046 1076
 	$disabled = empty($modSettings['disabledBBC']) ? array() : array_flip(explode(',', strtolower($modSettings['disabledBBC'])));
@@ -1051,10 +1081,12 @@  discard block
 block discarded – undo
1051 1081
 	$self_closing_tags = array();
1052 1082
 	foreach ($all_tags as $tag)
1053 1083
 	{
1054
-		if (!isset($disabled[$tag['tag']]))
1055
-			$valid_tags[$tag['tag']] = !empty($tag['block_level']);
1056
-		if (isset($tag['type']) && $tag['type'] == 'closed')
1057
-			$self_closing_tags[] = $tag['tag'];
1084
+		if (!isset($disabled[$tag['tag']])) {
1085
+					$valid_tags[$tag['tag']] = !empty($tag['block_level']);
1086
+		}
1087
+		if (isset($tag['type']) && $tag['type'] == 'closed') {
1088
+					$self_closing_tags[] = $tag['tag'];
1089
+		}
1058 1090
 	}
1059 1091
 
1060 1092
 	// 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!
@@ -1081,16 +1113,19 @@  discard block
 block discarded – undo
1081 1113
 				$tagName = substr($match, $isClosingTag ? 2 : 1, -1);
1082 1114
 
1083 1115
 				// We're closing the exact same tag that we opened.
1084
-				if ($isClosingTag && $insideTag === $tagName)
1085
-					$insideTag = null;
1116
+				if ($isClosingTag && $insideTag === $tagName) {
1117
+									$insideTag = null;
1118
+				}
1086 1119
 
1087 1120
 				// We're opening a tag and we're not yet inside one either
1088
-				elseif (!$isClosingTag && $insideTag === null)
1089
-					$insideTag = $tagName;
1121
+				elseif (!$isClosingTag && $insideTag === null) {
1122
+									$insideTag = $tagName;
1123
+				}
1090 1124
 
1091 1125
 				// In all other cases, this tag must be invalid
1092
-				else
1093
-					unset($matches[$i]);
1126
+				else {
1127
+									unset($matches[$i]);
1128
+				}
1094 1129
 			}
1095 1130
 
1096 1131
 			// The next one is gonna be the other one.
@@ -1098,8 +1133,9 @@  discard block
 block discarded – undo
1098 1133
 		}
1099 1134
 
1100 1135
 		// We're still inside a tag and had no chance for closure?
1101
-		if ($insideTag !== null)
1102
-			$matches[] = '[/' . $insideTag . ']';
1136
+		if ($insideTag !== null) {
1137
+					$matches[] = '[/' . $insideTag . ']';
1138
+		}
1103 1139
 
1104 1140
 		// And a complete text string again.
1105 1141
 		$text = implode('', $matches);
@@ -1108,8 +1144,9 @@  discard block
 block discarded – undo
1108 1144
 	// Quickly remove any tags which are back to back.
1109 1145
 	$backToBackPattern = '~\\[(' . implode('|', array_diff(array_keys($valid_tags), array('td', 'anchor'))) . ')[^<>\\[\\]]*\\]\s*\\[/\\1\\]~';
1110 1146
 	$lastlen = 0;
1111
-	while (strlen($text) !== $lastlen)
1112
-		$lastlen = strlen($text = preg_replace($backToBackPattern, '', $text));
1147
+	while (strlen($text) !== $lastlen) {
1148
+			$lastlen = strlen($text = preg_replace($backToBackPattern, '', $text));
1149
+	}
1113 1150
 
1114 1151
 	// Need to sort the tags by name length.
1115 1152
 	uksort($valid_tags, function ($a, $b) {
@@ -1148,8 +1185,9 @@  discard block
 block discarded – undo
1148 1185
 			$isCompetingTag = in_array($tag, $competing_tags);
1149 1186
 
1150 1187
 			// Check if this might be one of those cleaned out tags.
1151
-			if ($tag === '')
1152
-				continue;
1188
+			if ($tag === '') {
1189
+							continue;
1190
+			}
1153 1191
 
1154 1192
 			// Special case: inside [code] blocks any code is left untouched.
1155 1193
 			elseif ($tag === 'code')
@@ -1160,8 +1198,9 @@  discard block
 block discarded – undo
1160 1198
 					$inCode = false;
1161 1199
 
1162 1200
 					// Reopen tags that were closed before the code block.
1163
-					if (!empty($inlineElements))
1164
-						$parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']';
1201
+					if (!empty($inlineElements)) {
1202
+											$parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']';
1203
+					}
1165 1204
 				}
1166 1205
 
1167 1206
 				// We're outside a coding and nobbc block and opening it.
@@ -1190,8 +1229,9 @@  discard block
 block discarded – undo
1190 1229
 					$inNoBbc = false;
1191 1230
 
1192 1231
 					// Some inline elements might've been closed that need reopening.
1193
-					if (!empty($inlineElements))
1194
-						$parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']';
1232
+					if (!empty($inlineElements)) {
1233
+											$parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']';
1234
+					}
1195 1235
 				}
1196 1236
 
1197 1237
 				// We're outside a nobbc and coding block and opening it.
@@ -1211,8 +1251,9 @@  discard block
 block discarded – undo
1211 1251
 			}
1212 1252
 
1213 1253
 			// So, we're inside one of the special blocks: ignore any tag.
1214
-			elseif ($inCode || $inNoBbc)
1215
-				continue;
1254
+			elseif ($inCode || $inNoBbc) {
1255
+							continue;
1256
+			}
1216 1257
 
1217 1258
 			// We're dealing with an opening tag.
1218 1259
 			if ($isOpeningTag)
@@ -1253,8 +1294,9 @@  discard block
 block discarded – undo
1253 1294
 							if ($parts[$j + 3] === $tag)
1254 1295
 							{
1255 1296
 								// If it's an opening tag, increase the level.
1256
-								if ($parts[$j + 2] === '')
1257
-									$curLevel++;
1297
+								if ($parts[$j + 2] === '') {
1298
+																	$curLevel++;
1299
+								}
1258 1300
 
1259 1301
 								// A closing tag, decrease the level.
1260 1302
 								else
@@ -1277,13 +1319,15 @@  discard block
 block discarded – undo
1277 1319
 					{
1278 1320
 						if ($isCompetingTag)
1279 1321
 						{
1280
-							if (!isset($competingElements[$tag]))
1281
-								$competingElements[$tag] = array();
1322
+							if (!isset($competingElements[$tag])) {
1323
+															$competingElements[$tag] = array();
1324
+							}
1282 1325
 
1283 1326
 							$competingElements[$tag][] = $parts[$i + 4];
1284 1327
 
1285
-							if (count($competingElements[$tag]) > 1)
1286
-								$parts[$i] .= '[/' . $tag . ']';
1328
+							if (count($competingElements[$tag]) > 1) {
1329
+															$parts[$i] .= '[/' . $tag . ']';
1330
+							}
1287 1331
 						}
1288 1332
 
1289 1333
 						$inlineElements[$elementContent] = $tag;
@@ -1303,15 +1347,17 @@  discard block
 block discarded – undo
1303 1347
 						$addClosingTags = array();
1304 1348
 						while ($element = array_pop($blockElements))
1305 1349
 						{
1306
-							if ($element === $tag)
1307
-								break;
1350
+							if ($element === $tag) {
1351
+															break;
1352
+							}
1308 1353
 
1309 1354
 							// Still a block tag was open not equal to this tag.
1310 1355
 							$addClosingTags[] = $element['type'];
1311 1356
 						}
1312 1357
 
1313
-						if (!empty($addClosingTags))
1314
-							$parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1];
1358
+						if (!empty($addClosingTags)) {
1359
+													$parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1];
1360
+						}
1315 1361
 
1316 1362
 						// Apparently the closing tag was not found on the stack.
1317 1363
 						if (!is_string($element) || $element !== $tag)
@@ -1321,8 +1367,7 @@  discard block
 block discarded – undo
1321 1367
 							$parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = '';
1322 1368
 							continue;
1323 1369
 						}
1324
-					}
1325
-					else
1370
+					} else
1326 1371
 					{
1327 1372
 						// Get rid of this closing tag!
1328 1373
 						$parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = '';
@@ -1351,53 +1396,62 @@  discard block
 block discarded – undo
1351 1396
 							unset($inlineElements[$tagContentToBeClosed]);
1352 1397
 
1353 1398
 							// Was this the tag we were looking for?
1354
-							if ($tagToBeClosed === $tag)
1355
-								break;
1399
+							if ($tagToBeClosed === $tag) {
1400
+															break;
1401
+							}
1356 1402
 
1357 1403
 							// Nope, close it and look further!
1358
-							else
1359
-								$parts[$i] .= '[/' . $tagToBeClosed . ']';
1404
+							else {
1405
+															$parts[$i] .= '[/' . $tagToBeClosed . ']';
1406
+							}
1360 1407
 						}
1361 1408
 
1362 1409
 						if ($isCompetingTag && !empty($competingElements[$tag]))
1363 1410
 						{
1364 1411
 							array_pop($competingElements[$tag]);
1365 1412
 
1366
-							if (count($competingElements[$tag]) > 0)
1367
-								$parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5];
1413
+							if (count($competingElements[$tag]) > 0) {
1414
+															$parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5];
1415
+							}
1368 1416
 						}
1369 1417
 					}
1370 1418
 
1371 1419
 					// Unexpected closing tag, ex-ter-mi-nate.
1372
-					else
1373
-						$parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = '';
1420
+					else {
1421
+											$parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = '';
1422
+					}
1374 1423
 				}
1375 1424
 			}
1376 1425
 		}
1377 1426
 
1378 1427
 		// Close the code tags.
1379
-		if ($inCode)
1380
-			$parts[$i] .= '[/code]';
1428
+		if ($inCode) {
1429
+					$parts[$i] .= '[/code]';
1430
+		}
1381 1431
 
1382 1432
 		// The same for nobbc tags.
1383
-		elseif ($inNoBbc)
1384
-			$parts[$i] .= '[/nobbc]';
1433
+		elseif ($inNoBbc) {
1434
+					$parts[$i] .= '[/nobbc]';
1435
+		}
1385 1436
 
1386 1437
 		// Still inline tags left unclosed? Close them now, better late than never.
1387
-		elseif (!empty($inlineElements))
1388
-			$parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']';
1438
+		elseif (!empty($inlineElements)) {
1439
+					$parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']';
1440
+		}
1389 1441
 
1390 1442
 		// Now close the block elements.
1391
-		if (!empty($blockElements))
1392
-			$parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']';
1443
+		if (!empty($blockElements)) {
1444
+					$parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']';
1445
+		}
1393 1446
 
1394 1447
 		$text = implode('', $parts);
1395 1448
 	}
1396 1449
 
1397 1450
 	// Final clean up of back to back tags.
1398 1451
 	$lastlen = 0;
1399
-	while (strlen($text) !== $lastlen)
1400
-		$lastlen = strlen($text = preg_replace($backToBackPattern, '', $text));
1452
+	while (strlen($text) !== $lastlen) {
1453
+			$lastlen = strlen($text = preg_replace($backToBackPattern, '', $text));
1454
+	}
1401 1455
 
1402 1456
 	return $text;
1403 1457
 }
@@ -1414,22 +1468,25 @@  discard block
 block discarded – undo
1414 1468
 	$context['template_layers'] = array();
1415 1469
 	// Lets make sure we aren't going to output anything nasty.
1416 1470
 	@ob_end_clean();
1417
-	if (!empty($modSettings['enableCompressedOutput']))
1418
-		@ob_start('ob_gzhandler');
1419
-	else
1420
-		@ob_start();
1471
+	if (!empty($modSettings['enableCompressedOutput'])) {
1472
+			@ob_start('ob_gzhandler');
1473
+	} else {
1474
+			@ob_start();
1475
+	}
1421 1476
 
1422 1477
 	// If we don't have any locale better avoid broken js
1423
-	if (empty($txt['lang_locale']))
1424
-		die();
1478
+	if (empty($txt['lang_locale'])) {
1479
+			die();
1480
+	}
1425 1481
 
1426 1482
 	$file_data = '(function ($) {
1427 1483
 	\'use strict\';
1428 1484
 
1429 1485
 	$.sceditor.locale[' . JavaScriptEscape($txt['lang_locale']) . '] = {';
1430
-	foreach ($editortxt as $key => $val)
1431
-		$file_data .= '
1486
+	foreach ($editortxt as $key => $val) {
1487
+			$file_data .= '
1432 1488
 		' . JavaScriptEscape($key) . ': ' . JavaScriptEscape($val) . ',';
1489
+	}
1433 1490
 
1434 1491
 	$file_data .= '
1435 1492
 		dateFormat: "day.month.year"
@@ -1497,8 +1554,9 @@  discard block
 block discarded – undo
1497 1554
 				)
1498 1555
 			);
1499 1556
 			$icon_data = array();
1500
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1501
-				$icon_data[] = $row;
1557
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
1558
+							$icon_data[] = $row;
1559
+			}
1502 1560
 			$smcFunc['db_free_result']($request);
1503 1561
 
1504 1562
 			$icons = array();
@@ -1513,9 +1571,9 @@  discard block
 block discarded – undo
1513 1571
 			}
1514 1572
 
1515 1573
 			cache_put_data('posting_icons-' . $board_id, $icons, 480);
1574
+		} else {
1575
+					$icons = $temp;
1516 1576
 		}
1517
-		else
1518
-			$icons = $temp;
1519 1577
 	}
1520 1578
 	call_integration_hook('integrate_load_message_icons', array(&$icons));
1521 1579
 
@@ -1544,8 +1602,9 @@  discard block
 block discarded – undo
1544 1602
 	{
1545 1603
 		// Some general stuff.
1546 1604
 		$settings['smileys_url'] = $modSettings['smileys_url'] . '/' . $user_info['smiley_set'];
1547
-		if (!empty($context['drafts_autosave']))
1548
-			$context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000;
1605
+		if (!empty($context['drafts_autosave'])) {
1606
+					$context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000;
1607
+		}
1549 1608
 
1550 1609
 		// This really has some WYSIWYG stuff.
1551 1610
 		loadCSSFile('jquery.sceditor.css', array('force_current' => false, 'validate' => true), 'smf_jquery_sceditor');
@@ -1562,8 +1621,9 @@  discard block
 block discarded – undo
1562 1621
 		var bbc_quote = \'' . addcslashes($txt['quote'], "'") . '\';
1563 1622
 		var bbc_search_on = \'' . addcslashes($txt['search_on'], "'") . '\';');
1564 1623
 		// editor language file
1565
-		if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US')
1566
-			loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language');
1624
+		if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US') {
1625
+					loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language');
1626
+		}
1567 1627
 
1568 1628
 		$context['shortcuts_text'] = $txt['shortcuts' . (!empty($context['drafts_save']) ? '_drafts' : '') . (stripos($_SERVER['HTTP_USER_AGENT'], 'Macintosh') !== false ? '_mac' : (isBrowser('is_firefox') ? '_firefox' : ''))];
1569 1629
 		$context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_character_set'] == 'UTF-8' || function_exists('iconv'))));
@@ -1572,11 +1632,12 @@  discard block
 block discarded – undo
1572 1632
 			loadJavaScriptFile('spellcheck.js', array('minimize' => true), 'smf_spellcheck');
1573 1633
 
1574 1634
 			// Some hidden information is needed in order to make the spell checking work.
1575
-			if (!isset($_REQUEST['xml']))
1576
-				$context['insert_after_template'] .= '
1635
+			if (!isset($_REQUEST['xml'])) {
1636
+							$context['insert_after_template'] .= '
1577 1637
 		<form name="spell_form" id="spell_form" method="post" accept-charset="' . $context['character_set'] . '" target="spellWindow" action="' . $scripturl . '?action=spellcheck">
1578 1638
 			<input type="hidden" name="spellstring" value="">
1579 1639
 		</form>';
1640
+			}
1580 1641
 		}
1581 1642
 	}
1582 1643
 
@@ -1768,8 +1829,9 @@  discard block
 block discarded – undo
1768 1829
 
1769 1830
 		// Generate a list of buttons that shouldn't be shown - this should be the fastest way to do this.
1770 1831
 		$disabled_tags = array();
1771
-		if (!empty($modSettings['disabledBBC']))
1772
-			$disabled_tags = explode(',', $modSettings['disabledBBC']);
1832
+		if (!empty($modSettings['disabledBBC'])) {
1833
+					$disabled_tags = explode(',', $modSettings['disabledBBC']);
1834
+		}
1773 1835
 
1774 1836
 		foreach ($disabled_tags as $tag)
1775 1837
 		{
@@ -1781,9 +1843,10 @@  discard block
 block discarded – undo
1781 1843
 				$context['disabled_tags']['orderedlist'] = true;
1782 1844
 			}
1783 1845
 
1784
-			foreach ($editor_tag_map as $thisTag => $tagNameBBC)
1785
-				if ($tag === $thisTag)
1846
+			foreach ($editor_tag_map as $thisTag => $tagNameBBC) {
1847
+							if ($tag === $thisTag)
1786 1848
 					$context['disabled_tags'][$tagNameBBC] = true;
1849
+			}
1787 1850
 
1788 1851
 			$context['disabled_tags'][$tag] = true;
1789 1852
 		}
@@ -1794,8 +1857,9 @@  discard block
 block discarded – undo
1794 1857
 
1795 1858
 		foreach ($context['bbc_tags'] as $row => $tagRow)
1796 1859
 		{
1797
-			if (!isset($context['bbc_toolbar'][$row]))
1798
-				$context['bbc_toolbar'][$row] = array();
1860
+			if (!isset($context['bbc_toolbar'][$row])) {
1861
+							$context['bbc_toolbar'][$row] = array();
1862
+			}
1799 1863
 
1800 1864
 			$tagsRow = array();
1801 1865
 
@@ -1831,20 +1895,21 @@  discard block
 block discarded – undo
1831 1895
 
1832 1896
 					$context['bbcodes_handlers'] .= '
1833 1897
 						});';
1834
-				}
1835
-				else
1898
+				} else
1836 1899
 				{
1837 1900
 					$context['bbc_toolbar'][$row][] = implode(',', $tagsRow);
1838 1901
 					$tagsRow = array();
1839 1902
 				}
1840 1903
 			}
1841 1904
 
1842
-			if (!empty($tagsRow))
1843
-				$context['bbc_toolbar'][$row][] = implode(',', $tagsRow);
1905
+			if (!empty($tagsRow)) {
1906
+							$context['bbc_toolbar'][$row][] = implode(',', $tagsRow);
1907
+			}
1844 1908
 		}
1845 1909
 
1846
-		if (!empty($bbcodes_styles))
1847
-			addInlineCss($bbcodes_styles);
1910
+		if (!empty($bbcodes_styles)) {
1911
+					addInlineCss($bbcodes_styles);
1912
+		}
1848 1913
 	}
1849 1914
 
1850 1915
 	// Initialize smiley array... if not loaded before.
@@ -1856,8 +1921,8 @@  discard block
 block discarded – undo
1856 1921
 		);
1857 1922
 
1858 1923
 		// Load smileys - don't bother to run a query if we're not using the database's ones anyhow.
1859
-		if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none')
1860
-			$context['smileys']['postform'][] = array(
1924
+		if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none') {
1925
+					$context['smileys']['postform'][] = array(
1861 1926
 				'smileys' => array(
1862 1927
 					array(
1863 1928
 						'code' => ':)',
@@ -1943,7 +2008,7 @@  discard block
 block discarded – undo
1943 2008
 				),
1944 2009
 				'isLast' => true,
1945 2010
 			);
1946
-		elseif ($user_info['smiley_set'] != 'none')
2011
+		} elseif ($user_info['smiley_set'] != 'none')
1947 2012
 		{
1948 2013
 			if (($temp = cache_get_data('posting_smileys', 480)) == null)
1949 2014
 			{
@@ -1966,17 +2031,19 @@  discard block
 block discarded – undo
1966 2031
 
1967 2032
 				foreach ($context['smileys'] as $section => $smileyRows)
1968 2033
 				{
1969
-					foreach ($smileyRows as $rowIndex => $smileys)
1970
-						$context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true;
2034
+					foreach ($smileyRows as $rowIndex => $smileys) {
2035
+											$context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true;
2036
+					}
1971 2037
 
1972
-					if (!empty($smileyRows))
1973
-						$context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true;
2038
+					if (!empty($smileyRows)) {
2039
+											$context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true;
2040
+					}
1974 2041
 				}
1975 2042
 
1976 2043
 				cache_put_data('posting_smileys', $context['smileys'], 480);
2044
+			} else {
2045
+							$context['smileys'] = $temp;
1977 2046
 			}
1978
-			else
1979
-				$context['smileys'] = $temp;
1980 2047
 		}
1981 2048
 	}
1982 2049
 
@@ -1992,12 +2059,15 @@  discard block
 block discarded – undo
1992 2059
 		'plugins' => '',
1993 2060
 		'bbcodeTrim' => true,
1994 2061
 	);
1995
-	if (!empty($context['controls']['richedit'][$editorOptions['id']]['locale']))
1996
-		$sce_options['locale'] = $context['controls']['richedit'][$editorOptions['id']]['locale'];
1997
-	if (!empty($context['right_to_left']))
1998
-		$sce_options['rtl'] = true;
1999
-	if ($editorOptions['id'] != 'quickReply')
2000
-		$sce_options['autofocus'] = true;
2062
+	if (!empty($context['controls']['richedit'][$editorOptions['id']]['locale'])) {
2063
+			$sce_options['locale'] = $context['controls']['richedit'][$editorOptions['id']]['locale'];
2064
+	}
2065
+	if (!empty($context['right_to_left'])) {
2066
+			$sce_options['rtl'] = true;
2067
+	}
2068
+	if ($editorOptions['id'] != 'quickReply') {
2069
+			$sce_options['autofocus'] = true;
2070
+	}
2001 2071
 
2002 2072
 	$sce_options['emoticons'] = array();
2003 2073
 	$sce_options['emoticonsDescriptions'] = array();
@@ -2014,10 +2084,11 @@  discard block
 block discarded – undo
2014 2084
 			$countLocations--;
2015 2085
 
2016 2086
 			unset($smiley_location);
2017
-			if ($location == 'postform')
2018
-				$smiley_location = &$sce_options['emoticons']['dropdown'];
2019
-			elseif ($location == 'popup')
2020
-				$smiley_location = &$sce_options['emoticons']['popup'];
2087
+			if ($location == 'postform') {
2088
+							$smiley_location = &$sce_options['emoticons']['dropdown'];
2089
+			} elseif ($location == 'popup') {
2090
+							$smiley_location = &$sce_options['emoticons']['popup'];
2091
+			}
2021 2092
 
2022 2093
 			$numRows = count($smileyRows);
2023 2094
 
@@ -2031,8 +2102,9 @@  discard block
 block discarded – undo
2031 2102
 					$sce_options['emoticonsDescriptions'][$smiley['code']] = $smiley['description'];
2032 2103
 				}
2033 2104
 
2034
-				if (empty($smileyRow['isLast']) && $numRows != 1)
2035
-					$smiley_location['-' . $emptyPlaceholder++] = '';
2105
+				if (empty($smileyRow['isLast']) && $numRows != 1) {
2106
+									$smiley_location['-' . $emptyPlaceholder++] = '';
2107
+				}
2036 2108
 			}
2037 2109
 		}
2038 2110
 	}
@@ -2047,8 +2119,9 @@  discard block
 block discarded – undo
2047 2119
 
2048 2120
 			$count_tags--;
2049 2121
 
2050
-			if (!empty($count_tags))
2051
-				$sce_options['toolbar'] .= '||';
2122
+			if (!empty($count_tags)) {
2123
+							$sce_options['toolbar'] .= '||';
2124
+			}
2052 2125
 		}
2053 2126
 	}
2054 2127
 
@@ -2076,8 +2149,9 @@  discard block
 block discarded – undo
2076 2149
 		loadTemplate('GenericControls');
2077 2150
 
2078 2151
 		// Some javascript ma'am?
2079
-		if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual'])))
2080
-			loadJavaScriptFile('captcha.js', array('minimize' => true), 'smf_captcha');
2152
+		if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual']))) {
2153
+					loadJavaScriptFile('captcha.js', array('minimize' => true), 'smf_captcha');
2154
+		}
2081 2155
 
2082 2156
 		$context['use_graphic_library'] = in_array('gd', get_loaded_extensions());
2083 2157
 
@@ -2090,8 +2164,8 @@  discard block
 block discarded – undo
2090 2164
 	$isNew = !isset($context['controls']['verification'][$verificationOptions['id']]);
2091 2165
 
2092 2166
 	// Log this into our collection.
2093
-	if ($isNew)
2094
-		$context['controls']['verification'][$verificationOptions['id']] = array(
2167
+	if ($isNew) {
2168
+			$context['controls']['verification'][$verificationOptions['id']] = array(
2095 2169
 			'id' => $verificationOptions['id'],
2096 2170
 			'empty_field' => empty($verificationOptions['no_empty_field']),
2097 2171
 			'show_visual' => !empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual'])),
@@ -2102,13 +2176,15 @@  discard block
 block discarded – undo
2102 2176
 			'questions' => array(),
2103 2177
 			'can_recaptcha' => !empty($modSettings['recaptcha_enabled']) && !empty($modSettings['recaptcha_site_key']) && !empty($modSettings['recaptcha_secret_key']),
2104 2178
 		);
2179
+	}
2105 2180
 	$thisVerification = &$context['controls']['verification'][$verificationOptions['id']];
2106 2181
 
2107 2182
 	// Is there actually going to be anything?
2108
-	if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha']))
2109
-		return false;
2110
-	elseif (!$isNew && !$do_test)
2111
-		return true;
2183
+	if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha'])) {
2184
+			return false;
2185
+	} elseif (!$isNew && !$do_test) {
2186
+			return true;
2187
+	}
2112 2188
 
2113 2189
 	// Sanitize reCAPTCHA fields?
2114 2190
 	if ($thisVerification['can_recaptcha'])
@@ -2121,11 +2197,12 @@  discard block
 block discarded – undo
2121 2197
 	}
2122 2198
 
2123 2199
 	// Add javascript for the object.
2124
-	if ($context['controls']['verification'][$verificationOptions['id']]['show_visual'])
2125
-		$context['insert_after_template'] .= '
2200
+	if ($context['controls']['verification'][$verificationOptions['id']]['show_visual']) {
2201
+			$context['insert_after_template'] .= '
2126 2202
 			<script>
2127 2203
 				var verification' . $verificationOptions['id'] . 'Handle = new smfCaptcha("' . $thisVerification['image_href'] . '", "' . $verificationOptions['id'] . '", ' . ($context['use_graphic_library'] ? 1 : 0) . ');
2128 2204
 			</script>';
2205
+	}
2129 2206
 
2130 2207
 	// If we want questions do we have a cache of all the IDs?
2131 2208
 	if (!empty($thisVerification['number_questions']) && empty($modSettings['question_id_cache']))
@@ -2148,8 +2225,9 @@  discard block
 block discarded – undo
2148 2225
 				unset ($row['id_question']);
2149 2226
 				// Make them all lowercase. We can't directly use $smcFunc['strtolower'] with array_walk, so do it manually, eh?
2150 2227
 				$row['answers'] = $smcFunc['json_decode']($row['answers'], true);
2151
-				foreach ($row['answers'] as $k => $v)
2152
-					$row['answers'][$k] = $smcFunc['strtolower']($v);
2228
+				foreach ($row['answers'] as $k => $v) {
2229
+									$row['answers'][$k] = $smcFunc['strtolower']($v);
2230
+				}
2153 2231
 
2154 2232
 				$modSettings['question_id_cache']['questions'][$id_question] = $row;
2155 2233
 				$modSettings['question_id_cache']['langs'][$row['lngfile']][] = $id_question;
@@ -2160,35 +2238,42 @@  discard block
 block discarded – undo
2160 2238
 		}
2161 2239
 	}
2162 2240
 
2163
-	if (!isset($_SESSION[$verificationOptions['id'] . '_vv']))
2164
-		$_SESSION[$verificationOptions['id'] . '_vv'] = array();
2241
+	if (!isset($_SESSION[$verificationOptions['id'] . '_vv'])) {
2242
+			$_SESSION[$verificationOptions['id'] . '_vv'] = array();
2243
+	}
2165 2244
 
2166 2245
 	// Do we need to refresh the verification?
2167
-	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']))
2168
-		$force_refresh = true;
2169
-	else
2170
-		$force_refresh = false;
2246
+	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'])) {
2247
+			$force_refresh = true;
2248
+	} else {
2249
+			$force_refresh = false;
2250
+	}
2171 2251
 
2172 2252
 	// This can also force a fresh, although unlikely.
2173
-	if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q'])))
2174
-		$force_refresh = true;
2253
+	if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q']))) {
2254
+			$force_refresh = true;
2255
+	}
2175 2256
 
2176 2257
 	$verification_errors = array();
2177 2258
 	// Start with any testing.
2178 2259
 	if ($do_test)
2179 2260
 	{
2180 2261
 		// This cannot happen!
2181
-		if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count']))
2182
-			fatal_lang_error('no_access', false);
2262
+		if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count'])) {
2263
+					fatal_lang_error('no_access', false);
2264
+		}
2183 2265
 		// ... nor this!
2184
-		if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q'])))
2185
-			fatal_lang_error('no_access', false);
2266
+		if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q']))) {
2267
+					fatal_lang_error('no_access', false);
2268
+		}
2186 2269
 		// Hmm, it's requested but not actually declared. This shouldn't happen.
2187
-		if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']))
2188
-			fatal_lang_error('no_access', false);
2270
+		if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) {
2271
+					fatal_lang_error('no_access', false);
2272
+		}
2189 2273
 		// While we're here, did the user do something bad?
2190
-		if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']]))
2191
-			$verification_errors[] = 'wrong_verification_answer';
2274
+		if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']])) {
2275
+					$verification_errors[] = 'wrong_verification_answer';
2276
+		}
2192 2277
 
2193 2278
 		if ($thisVerification['can_recaptcha'])
2194 2279
 		{
@@ -2199,22 +2284,25 @@  discard block
 block discarded – undo
2199 2284
 			{
2200 2285
 				$resp = $reCaptcha->verify($_POST['g-recaptcha-response'], $user_info['ip']);
2201 2286
 
2202
-				if (!$resp->isSuccess())
2203
-					$verification_errors[] = 'wrong_verification_code';
2287
+				if (!$resp->isSuccess()) {
2288
+									$verification_errors[] = 'wrong_verification_code';
2289
+				}
2290
+			} else {
2291
+							$verification_errors[] = 'wrong_verification_code';
2204 2292
 			}
2205
-			else
2206
-				$verification_errors[] = 'wrong_verification_code';
2207 2293
 		}
2208
-		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']))
2209
-			$verification_errors[] = 'wrong_verification_code';
2294
+		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'])) {
2295
+					$verification_errors[] = 'wrong_verification_code';
2296
+		}
2210 2297
 		if ($thisVerification['number_questions'])
2211 2298
 		{
2212 2299
 			$incorrectQuestions = array();
2213 2300
 			foreach ($_SESSION[$verificationOptions['id'] . '_vv']['q'] as $q)
2214 2301
 			{
2215 2302
 				// We don't have this question any more, thus no answers.
2216
-				if (!isset($modSettings['question_id_cache']['questions'][$q]))
2217
-					continue;
2303
+				if (!isset($modSettings['question_id_cache']['questions'][$q])) {
2304
+									continue;
2305
+				}
2218 2306
 				// This is quite complex. We have our question but it might have multiple answers.
2219 2307
 				// First, did they actually answer this question?
2220 2308
 				if (!isset($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) || trim($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) == '')
@@ -2226,24 +2314,28 @@  discard block
 block discarded – undo
2226 2314
 				else
2227 2315
 				{
2228 2316
 					$given_answer = trim($smcFunc['htmlspecialchars'](strtolower($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q])));
2229
-					if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers']))
2230
-						$incorrectQuestions[] = $q;
2317
+					if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers'])) {
2318
+											$incorrectQuestions[] = $q;
2319
+					}
2231 2320
 				}
2232 2321
 			}
2233 2322
 
2234
-			if (!empty($incorrectQuestions))
2235
-				$verification_errors[] = 'wrong_verification_answer';
2323
+			if (!empty($incorrectQuestions)) {
2324
+							$verification_errors[] = 'wrong_verification_answer';
2325
+			}
2236 2326
 		}
2237 2327
 	}
2238 2328
 
2239 2329
 	// Any errors means we refresh potentially.
2240 2330
 	if (!empty($verification_errors))
2241 2331
 	{
2242
-		if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors']))
2243
-			$_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0;
2332
+		if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors'])) {
2333
+					$_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0;
2334
+		}
2244 2335
 		// Too many errors?
2245
-		elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors'])
2246
-			$force_refresh = true;
2336
+		elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors']) {
2337
+					$force_refresh = true;
2338
+		}
2247 2339
 
2248 2340
 		// Keep a track of these.
2249 2341
 		$_SESSION[$verificationOptions['id'] . '_vv']['errors']++;
@@ -2276,8 +2368,9 @@  discard block
 block discarded – undo
2276 2368
 			// Are we overriding the range?
2277 2369
 			$character_range = !empty($verificationOptions['override_range']) ? $verificationOptions['override_range'] : $context['standard_captcha_range'];
2278 2370
 
2279
-			for ($i = 0; $i < 6; $i++)
2280
-				$_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)];
2371
+			for ($i = 0; $i < 6; $i++) {
2372
+							$_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)];
2373
+			}
2281 2374
 		}
2282 2375
 
2283 2376
 		// Getting some new questions?
@@ -2285,8 +2378,9 @@  discard block
 block discarded – undo
2285 2378
 		{
2286 2379
 			// Attempt to try the current page's language, followed by the user's preference, followed by the site default.
2287 2380
 			$possible_langs = array();
2288
-			if (isset($_SESSION['language']))
2289
-				$possible_langs[] = strtr($_SESSION['language'], array('-utf8' => ''));
2381
+			if (isset($_SESSION['language'])) {
2382
+							$possible_langs[] = strtr($_SESSION['language'], array('-utf8' => ''));
2383
+			}
2290 2384
 			if (!empty($user_info['language']));
2291 2385
 			$possible_langs[] = $user_info['language'];
2292 2386
 			$possible_langs[] = $language;
@@ -2305,8 +2399,7 @@  discard block
 block discarded – undo
2305 2399
 				}
2306 2400
 			}
2307 2401
 		}
2308
-	}
2309
-	else
2402
+	} else
2310 2403
 	{
2311 2404
 		// Same questions as before.
2312 2405
 		$questionIDs = !empty($_SESSION[$verificationOptions['id'] . '_vv']['q']) ? $_SESSION[$verificationOptions['id'] . '_vv']['q'] : array();
@@ -2316,8 +2409,9 @@  discard block
 block discarded – undo
2316 2409
 	// If we do have an empty field, it would be nice to hide it from legitimate users who shouldn't be populating it anyway.
2317 2410
 	if (!empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']))
2318 2411
 	{
2319
-		if (!isset($context['html_headers']))
2320
-			$context['html_headers'] = '';
2412
+		if (!isset($context['html_headers'])) {
2413
+					$context['html_headers'] = '';
2414
+		}
2321 2415
 		$context['html_headers'] .= '<style>.vv_special { display:none; }</style>';
2322 2416
 	}
2323 2417
 
@@ -2343,11 +2437,13 @@  discard block
 block discarded – undo
2343 2437
 	$_SESSION[$verificationOptions['id'] . '_vv']['count'] = empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) ? 1 : $_SESSION[$verificationOptions['id'] . '_vv']['count'] + 1;
2344 2438
 
2345 2439
 	// Return errors if we have them.
2346
-	if (!empty($verification_errors))
2347
-		return $verification_errors;
2440
+	if (!empty($verification_errors)) {
2441
+			return $verification_errors;
2442
+	}
2348 2443
 	// If we had a test that one, make a note.
2349
-	elseif ($do_test)
2350
-		$_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true;
2444
+	elseif ($do_test) {
2445
+			$_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true;
2446
+	}
2351 2447
 
2352 2448
 	// Say that everything went well chaps.
2353 2449
 	return true;
@@ -2372,8 +2468,9 @@  discard block
 block discarded – undo
2372 2468
 	call_integration_hook('integrate_autosuggest', array(&$searchTypes));
2373 2469
 
2374 2470
 	// If we're just checking the callback function is registered return true or false.
2375
-	if ($checkRegistered != null)
2376
-		return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered);
2471
+	if ($checkRegistered != null) {
2472
+			return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered);
2473
+	}
2377 2474
 
2378 2475
 	checkSession('get');
2379 2476
 	loadTemplate('Xml');
@@ -2524,24 +2621,27 @@  discard block
 block discarded – undo
2524 2621
 		foreach ($possible_versions as $ver)
2525 2622
 		{
2526 2623
 			$ver = trim($ver);
2527
-			if (strpos($ver, 'SMF') === 0)
2528
-				$versions[] = $ver;
2624
+			if (strpos($ver, 'SMF') === 0) {
2625
+							$versions[] = $ver;
2626
+			}
2529 2627
 		}
2530 2628
 	}
2531 2629
 	$smcFunc['db_free_result']($request);
2532 2630
 
2533 2631
 	// Just in case we don't have ANYthing.
2534
-	if (empty($versions))
2535
-		$versions = array('SMF 2.0');
2632
+	if (empty($versions)) {
2633
+			$versions = array('SMF 2.0');
2634
+	}
2536 2635
 
2537
-	foreach ($versions as $id => $version)
2538
-		if (strpos($version, strtoupper($_REQUEST['search'])) !== false)
2636
+	foreach ($versions as $id => $version) {
2637
+			if (strpos($version, strtoupper($_REQUEST['search'])) !== false)
2539 2638
 			$xml_data['items']['children'][] = array(
2540 2639
 				'attributes' => array(
2541 2640
 					'id' => $id,
2542 2641
 				),
2543 2642
 				'value' => $version,
2544 2643
 			);
2644
+	}
2545 2645
 
2546 2646
 	return $xml_data;
2547 2647
 }
Please login to merge, or discard this patch.
Themes/default/ReportToMod.template.php 1 patch
Braces   +6 added lines, -5 removed lines patch added patch discarded remove patch
@@ -62,16 +62,17 @@
 block discarded – undo
62 62
 				<div id="error_box" class="errorbox">
63 63
 					<ul id="error_list">';
64 64
 
65
-		foreach ($context['post_errors'] as $key => $error)
66
-			echo '
65
+		foreach ($context['post_errors'] as $key => $error) {
66
+					echo '
67 67
 						<li id="error_', $key, '" class="error">', $error, '</li>';
68
+		}
68 69
 
69 70
 		echo '
70 71
 					</ul>';
71
-	}
72
-	else
73
-		echo '
72
+	} else {
73
+			echo '
74 74
 				<div id="error_box" class="errorbox hidden">';
75
+	}
75 76
 
76 77
 	echo '
77 78
 				</div>';
Please login to merge, or discard this patch.
Themes/default/ManageMembergroups.template.php 1 patch
Braces   +104 added lines, -74 removed lines patch added patch discarded remove patch
@@ -54,9 +54,10 @@  discard block
 block discarded – undo
54 54
 							<legend>', $txt['membergroups_edit_select_group_type'], '</legend>
55 55
 							<label for="group_type_private"><input type="radio" name="group_type" id="group_type_private" value="0" checked onclick="swapPostGroup(0);">', $txt['membergroups_group_type_private'], '</label><br>';
56 56
 
57
-		if ($context['allow_protected'])
58
-			echo '
57
+		if ($context['allow_protected']) {
58
+					echo '
59 59
 							<label for="group_type_protected"><input type="radio" name="group_type" id="group_type_protected" value="1" onclick="swapPostGroup(0);">', $txt['membergroups_group_type_protected'], '</label><br>';
60
+		}
60 61
 
61 62
 		echo '
62 63
 							<label for="group_type_request"><input type="radio" name="group_type" id="group_type_request" value="2" onclick="swapPostGroup(0);">', $txt['membergroups_group_type_request'], '</label><br>
@@ -66,14 +67,15 @@  discard block
 block discarded – undo
66 67
 					</dd>';
67 68
 	}
68 69
 
69
-	if ($context['post_group'] || $context['undefined_group'])
70
-		echo '
70
+	if ($context['post_group'] || $context['undefined_group']) {
71
+			echo '
71 72
 					<dt id="min_posts_text">
72 73
 						<strong>', $txt['membergroups_min_posts'], ':</strong>
73 74
 					</dt>
74 75
 					<dd>
75 76
 						<input type="number" name="min_posts" id="min_posts_input" size="5">
76 77
 					</dd>';
78
+	}
77 79
 
78 80
 	if (!$context['post_group'] || !empty($modSettings['permission_enable_postgroups']))
79 81
 	{
@@ -91,9 +93,10 @@  discard block
 block discarded – undo
91 93
 								<option value="-1">', $txt['membergroups_guests'], '</option>
92 94
 								<option value="0" selected>', $txt['membergroups_members'], '</option>';
93 95
 
94
-		foreach ($context['groups'] as $group)
95
-			echo '
96
+		foreach ($context['groups'] as $group) {
97
+					echo '
96 98
 								<option value="', $group['id'], '">', $group['name'], '</option>';
99
+		}
97 100
 
98 101
 		echo '
99 102
 							</select>
@@ -104,9 +107,10 @@  discard block
 block discarded – undo
104 107
 								<option value="-1">', $txt['membergroups_guests'], '</option>
105 108
 								<option value="0" selected>', $txt['membergroups_members'], '</option>';
106 109
 
107
-		foreach ($context['groups'] as $group)
108
-			echo '
110
+		foreach ($context['groups'] as $group) {
111
+					echo '
109 112
 								<option value="', $group['id'], '">', $group['name'], '</option>';
113
+		}
110 114
 
111 115
 		echo '
112 116
 							</select>
@@ -138,8 +142,8 @@  discard block
 block discarded – undo
138 142
 				<input type="submit" value="', $txt['membergroups_add_group'], '" class="button">
139 143
 			</div><!-- .windowbg -->';
140 144
 
141
-	if ($context['undefined_group'])
142
-		echo '
145
+	if ($context['undefined_group']) {
146
+			echo '
143 147
 			<script>
144 148
 				function swapPostGroup(isChecked)
145 149
 				{
@@ -149,6 +153,7 @@  discard block
 block discarded – undo
149 153
 				}
150 154
 				swapPostGroup(', $context['post_group'] ? 'true' : 'false', ');
151 155
 			</script>';
156
+	}
152 157
 
153 158
 	echo '
154 159
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -178,14 +183,15 @@  discard block
 block discarded – undo
178 183
 						<input type="text" name="group_name" id="group_name_input" value="', $context['group']['editable_name'], '" size="30">
179 184
 					</dd>';
180 185
 
181
-	if ($context['group']['id'] != 3 && $context['group']['id'] != 4)
182
-		echo '
186
+	if ($context['group']['id'] != 3 && $context['group']['id'] != 4) {
187
+			echo '
183 188
 					<dt id="group_desc_text">
184 189
 						<label for="group_desc_input"><strong>', $txt['membergroups_edit_desc'], ':</strong></label>
185 190
 					</dt>
186 191
 					<dd>
187 192
 						<textarea name="group_desc" id="group_desc_input" rows="4" cols="40">', $context['group']['description'], '</textarea>
188 193
 					</dd>';
194
+	}
189 195
 
190 196
 	// Group type...
191 197
 	if ($context['group']['allow_post_group'])
@@ -199,9 +205,10 @@  discard block
 block discarded – undo
199 205
 							<legend>', $txt['membergroups_edit_select_group_type'], '</legend>
200 206
 							<label for="group_type_private"><input type="radio" name="group_type" id="group_type_private" value="0"', !$context['group']['is_post_group'] && $context['group']['type'] == 0 ? ' checked' : '', ' onclick="swapPostGroup(0);">', $txt['membergroups_group_type_private'], '</label><br>';
201 207
 
202
-		if ($context['group']['allow_protected'])
203
-			echo '
208
+		if ($context['group']['allow_protected']) {
209
+					echo '
204 210
 							<label for="group_type_protected"><input type="radio" name="group_type" id="group_type_protected" value="1"', $context['group']['type'] == 1 ? ' checked' : '', ' onclick="swapPostGroup(0);">', $txt['membergroups_group_type_protected'], '</label><br>';
211
+		}
205 212
 
206 213
 		echo '
207 214
 							<label for="group_type_request"><input type="radio" name="group_type" id="group_type_request" value="2"', $context['group']['type'] == 2 ? ' checked' : '', ' onclick="swapPostGroup(0);">', $txt['membergroups_group_type_request'], '</label><br>
@@ -211,8 +218,8 @@  discard block
 block discarded – undo
211 218
 					</dd>';
212 219
 	}
213 220
 
214
-	if ($context['group']['id'] != 3 && $context['group']['id'] != 4)
215
-		echo '
221
+	if ($context['group']['id'] != 3 && $context['group']['id'] != 4) {
222
+			echo '
216 223
 					<dt id="group_moderators_text">
217 224
 						<label for="group_moderators"><strong>', $txt['moderators'], ':</strong></label>
218 225
 					</dt>
@@ -230,6 +237,7 @@  discard block
 block discarded – undo
230 237
 							<option value="2"', $context['group']['hidden'] == 2 ? ' selected' : '', '>', $txt['membergroups_edit_hidden_all'], '</option>
231 238
 						</select>
232 239
 					</dd>';
240
+	}
233 241
 
234 242
 	// Can they inherit permissions?
235 243
 	if ($context['group']['id'] > 1 && $context['group']['id'] != 3)
@@ -246,9 +254,10 @@  discard block
 block discarded – undo
246 254
 							<option value="0"', $context['group']['inherited_from'] == 0 ? ' selected' : '', '>', $txt['membergroups_edit_inherit_permissions_from'], ': ', $txt['membergroups_members'], '</option>';
247 255
 
248 256
 		// For all the inheritable groups show an option.
249
-		foreach ($context['inheritable_groups'] as $id => $group)
250
-			echo '
257
+		foreach ($context['inheritable_groups'] as $id => $group) {
258
+					echo '
251 259
 							<option value="', $id, '"', $context['group']['inherited_from'] == $id ? ' selected' : '', '>', $txt['membergroups_edit_inherit_permissions_from'], ': ', $group, '</option>';
260
+		}
252 261
 
253 262
 		echo '
254 263
 						</select>
@@ -256,8 +265,8 @@  discard block
 block discarded – undo
256 265
 					</dd>';
257 266
 	}
258 267
 
259
-	if ($context['group']['allow_post_group'])
260
-		echo '
268
+	if ($context['group']['allow_post_group']) {
269
+			echo '
261 270
 
262 271
 					<dt id="min_posts_text">
263 272
 						<label for="min_posts_input"><strong>', $txt['membergroups_min_posts'], ':</strong></label>
@@ -265,6 +274,7 @@  discard block
 block discarded – undo
265 274
 					<dd>
266 275
 						<input type="number" name="min_posts" id="min_posts_input"', $context['group']['is_post_group'] ? ' value="' . $context['group']['min_posts'] . '"' : '', ' size="6">
267 276
 					</dd>';
277
+	}
268 278
 
269 279
 	echo '
270 280
 					<dt>
@@ -294,9 +304,10 @@  discard block
 block discarded – undo
294 304
 						<select name="icon_image" id="icon_image_input">';
295 305
 
296 306
 		// For every possible icon, create an option.
297
-		foreach ($context['possible_icons'] as $icon)
298
-			echo '
307
+		foreach ($context['possible_icons'] as $icon) {
308
+					echo '
299 309
 							<option value="', $icon, '"', $context['group']['icon_image'] == $icon ? ' selected' : '', '>', $icon, '</option>';
310
+		}
300 311
 
301 312
 		echo '
302 313
 						</select>
@@ -305,9 +316,10 @@  discard block
 block discarded – undo
305 316
 	}
306 317
 
307 318
 	// No? Hide the entire control.
308
-	else
309
-		echo '
319
+	else {
320
+			echo '
310 321
 					<input type="hidden" name="icon_image" value="">';
322
+	}
311 323
 
312 324
 	echo '
313 325
 					<dt>
@@ -319,8 +331,8 @@  discard block
 block discarded – undo
319 331
 					</dd>';
320 332
 
321 333
 	// Force 2FA for this membergroup?
322
-	if (!empty($modSettings['tfa_mode']) && $modSettings['tfa_mode'] == 2)
323
-		echo '
334
+	if (!empty($modSettings['tfa_mode']) && $modSettings['tfa_mode'] == 2) {
335
+			echo '
324 336
 					<dt>
325 337
 						<label for="group_tfa_force_input"><strong>', $txt['membergroups_tfa_force'], ':</strong></label><br>
326 338
 						<span class="smalltext">', $txt['membergroups_tfa_force_note'], '</span>
@@ -328,6 +340,7 @@  discard block
 block discarded – undo
328 340
 					<dd>
329 341
 						<input type="checkbox" name="group_tfa_force"', $context['group']['tfa_required'] ? ' checked' : '', '>
330 342
 					</dd>';
343
+	}
331 344
 
332 345
 	if (!empty($context['categories']))
333 346
 	{
@@ -338,11 +351,11 @@  discard block
 block discarded – undo
338 351
 					</dt>
339 352
 					<dd>';
340 353
 
341
-		if (!empty($context['can_manage_boards']))
342
-			echo $txt['membergroups_can_manage_access'];
343
-
344
-		else
345
-			template_add_edit_group_boards_list();
354
+		if (!empty($context['can_manage_boards'])) {
355
+					echo $txt['membergroups_can_manage_access'];
356
+		} else {
357
+					template_add_edit_group_boards_list();
358
+		}
346 359
 
347 360
 		echo '
348 361
 					</dd>';
@@ -371,20 +384,21 @@  discard block
 block discarded – undo
371 384
 			sItemListContainerId: \'moderator_container\',
372 385
 			aListItems: [';
373 386
 
374
-	foreach ($context['group']['moderators'] as $id_member => $member_name)
375
-		echo '
387
+	foreach ($context['group']['moderators'] as $id_member => $member_name) {
388
+			echo '
376 389
 				{
377 390
 					sItemId: ', JavaScriptEscape($id_member), ',
378 391
 					sItemName: ', JavaScriptEscape($member_name), '
379 392
 				}', $id_member == $context['group']['last_moderator_id'] ? '' : ',';
393
+	}
380 394
 
381 395
 	echo '
382 396
 			]
383 397
 		});
384 398
 	</script>';
385 399
 
386
-	if ($context['group']['allow_post_group'])
387
-		echo '
400
+	if ($context['group']['allow_post_group']) {
401
+			echo '
388 402
 	<script>
389 403
 		function swapPostGroup(isChecked)
390 404
 		{
@@ -432,7 +446,8 @@  discard block
 block discarded – undo
432 446
 
433 447
 		swapPostGroup(', $context['group']['is_post_group'] ? 'true' : 'false', ');
434 448
 	</script>';
435
-}
449
+	}
450
+	}
436 451
 
437 452
 /**
438 453
  * The template for determining which boards a group has access to.
@@ -450,13 +465,13 @@  discard block
 block discarded – undo
450 465
 
451 466
 	foreach ($context['categories'] as $category)
452 467
 	{
453
-		if (empty($modSettings['deny_boards_access']))
454
-			echo '
468
+		if (empty($modSettings['deny_boards_access'])) {
469
+					echo '
455 470
 									<li class="category">
456 471
 										<a href="javascript:void(0);" onclick="selectBoards([', implode(', ', $category['child_ids']), '], \'new_group\'); return false;"><strong>', $category['name'], '</strong></a>
457 472
 										<ul>';
458
-		else
459
-			echo '
473
+		} else {
474
+					echo '
460 475
 									<li class="category">
461 476
 										<strong>', $category['name'], '</strong>
462 477
 										<span class="select_all_box">
@@ -469,16 +484,17 @@  discard block
 block discarded – undo
469 484
 											</select>
470 485
 										</span>
471 486
 										<ul id="boards_list_', $category['id'], '">';
487
+		}
472 488
 
473 489
 		foreach ($category['boards'] as $board)
474 490
 		{
475
-			if (empty($modSettings['deny_boards_access']))
476
-				echo '
491
+			if (empty($modSettings['deny_boards_access'])) {
492
+							echo '
477 493
 											<li class="board" style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'], 'em;">
478 494
 												<input type="checkbox" name="boardaccess[', $board['id'], ']" id="brd', $board['id'], '" value="allow"', $board['allow'] ? ' checked' : '', '> <label for="brd', $board['id'], '">', $board['name'], '</label>
479 495
 											</li>';
480
-			else
481
-				echo '
496
+			} else {
497
+							echo '
482 498
 											<li class="board" style="width:100%">
483 499
 												<span style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'], 'em;">', $board['name'], ': </span>
484 500
 												<span style="width:50%;float:right">
@@ -487,6 +503,7 @@  discard block
 block discarded – undo
487 503
 													<input type="radio" name="boardaccess[', $board['id'], ']" id="deny_brd', $board['id'], '" value="deny"', $board['deny'] ? ' checked' : '', '> <label for="deny_brd', $board['id'], '">', $txt['permissions_option_deny'], '</label>
488 504
 												</span>
489 505
 											</li>';
506
+			}
490 507
 		}
491 508
 
492 509
 		echo '
@@ -497,14 +514,14 @@  discard block
 block discarded – undo
497 514
 	echo '
498 515
 								</ul>';
499 516
 
500
-	if (empty($modSettings['deny_boards_access']))
501
-		echo '
517
+	if (empty($modSettings['deny_boards_access'])) {
518
+			echo '
502 519
 								<br class="clear"><br>
503 520
 								<input type="checkbox" id="checkall_check" onclick="invertAll(this, this.form, \'boardaccess\');">
504 521
 								<label for="checkall_check"><em>', $txt['check_all'], '</em></label>
505 522
 							</fieldset>';
506
-	else
507
-		echo '
523
+	} else {
524
+			echo '
508 525
 								<br class="clear">
509 526
 								<span class="select_all_box">
510 527
 									<em>', $txt['all'], ': </em>
@@ -520,15 +537,17 @@  discard block
 block discarded – undo
520 537
 									});
521 538
 								});
522 539
 							</script>';
540
+	}
523 541
 
524
-	if ($collapse)
525
-		echo '
542
+	if ($collapse) {
543
+			echo '
526 544
 							<a href="javascript:void(0);" onclick="document.getElementById(\'visible_boards\').classList.remove(\'hidden\'); document.getElementById(\'visible_boards_link\').classList.add(\'hidden\'); return false;" id="visible_boards_link" class="hidden">[ ', $txt['membergroups_select_visible_boards'], ' ]</a>
527 545
 							<script>
528 546
 								document.getElementById("visible_boards_link").classList.remove(\'hidden\');
529 547
 								document.getElementById("visible_boards").classList.add(\'hidden\');
530 548
 							</script>';
531
-}
549
+	}
550
+	}
532 551
 
533 552
 /**
534 553
  * Templatine for viewing the members of a group.
@@ -552,14 +571,15 @@  discard block
 block discarded – undo
552 571
 					</dd>';
553 572
 
554 573
 	// Any description to show?
555
-	if (!empty($context['group']['description']))
556
-		echo '
574
+	if (!empty($context['group']['description'])) {
575
+			echo '
557 576
 					<dt>
558 577
 						<strong>' . $txt['membergroups_members_description'] . ':</strong>
559 578
 					</dt>
560 579
 					<dd>
561 580
 						', $context['group']['description'], '
562 581
 					</dd>';
582
+	}
563 583
 
564 584
 	echo '
565 585
 					<dt>
@@ -573,8 +593,9 @@  discard block
 block discarded – undo
573 593
 	if (!empty($context['group']['moderators']))
574 594
 	{
575 595
 		$moderators = array();
576
-		foreach ($context['group']['moderators'] as $moderator)
577
-			$moderators[] = '<a href="' . $scripturl . '?action=profile;u=' . $moderator['id'] . '">' . $moderator['name'] . '</a>';
596
+		foreach ($context['group']['moderators'] as $moderator) {
597
+					$moderators[] = '<a href="' . $scripturl . '?action=profile;u=' . $moderator['id'] . '">' . $moderator['name'] . '</a>';
598
+		}
578 599
 
579 600
 		echo '
580 601
 					<dt>
@@ -599,9 +620,10 @@  discard block
 block discarded – undo
599 620
 					<tr class="title_bar">
600 621
 						<th><a href="', $scripturl, '?action=', $context['current_action'], (isset($context['admin_area']) ? ';area=' . $context['admin_area'] : ''), ';sa=members;start=', $context['start'], ';sort=name', $context['sort_by'] == 'name' && $context['sort_direction'] == 'up' ? ';desc' : '', ';group=', $context['group']['id'], '">', $txt['name'], $context['sort_by'] == 'name' ? ' <span class="generic_icons sort_' . $context['sort_direction'] . '"></span>' : '', '</a></th>';
601 622
 
602
-	if ($context['can_send_email'])
603
-		echo '
623
+	if ($context['can_send_email']) {
624
+			echo '
604 625
 						<th><a href="', $scripturl, '?action=', $context['current_action'], (isset($context['admin_area']) ? ';area=' . $context['admin_area'] : ''), ';sa=members;start=', $context['start'], ';sort=email', $context['sort_by'] == 'email' && $context['sort_direction'] == 'up' ? ';desc' : '', ';group=', $context['group']['id'], '">', $txt['email'], $context['sort_by'] == 'email' ? ' <span class="generic_icons sort_' . $context['sort_direction'] . '"></span>' : '', '</a></th>';
626
+	}
605 627
 
606 628
 	echo '
607 629
 						<th><a href="', $scripturl, '?action=', $context['current_action'], (isset($context['admin_area']) ? ';area=' . $context['admin_area'] : ''), ';sa=members;start=', $context['start'], ';sort=active', $context['sort_by'] == 'active' && $context['sort_direction'] == 'up' ? ';desc' : '', ';group=', $context['group']['id'], '">', $txt['membergroups_members_last_active'], $context['sort_by'] == 'active' ? '<span class="generic_icons sort_' . $context['sort_direction'] . '"></span>' : '', '</a></th>
@@ -610,20 +632,22 @@  discard block
 block discarded – undo
610 632
 							<a href="', $scripturl, '?action=', $context['current_action'], (isset($context['admin_area']) ? ';area=' . $context['admin_area'] : ''), ';sa=members;start=', $context['start'], ';sort=posts', $context['sort_by'] == 'posts' && $context['sort_direction'] == 'up' ? ';desc' : '', ';group=', $context['group']['id'], '">', $txt['posts'], $context['sort_by'] == 'posts' ? ' <span class="generic_icons sort_' . $context['sort_direction'] . '"></span>' : '', '</a>
611 633
 						</th>';
612 634
 
613
-	if (!empty($context['group']['assignable']))
614
-		echo '
635
+	if (!empty($context['group']['assignable'])) {
636
+			echo '
615 637
 						<th style="width: 4%"><input type="checkbox" onclick="invertAll(this, this.form);"></th>';
638
+	}
616 639
 
617 640
 	echo '
618 641
 					</tr>
619 642
 				</thead>
620 643
 				<tbody>';
621 644
 
622
-	if (empty($context['members']))
623
-		echo '
645
+	if (empty($context['members'])) {
646
+			echo '
624 647
 					<tr class="windowbg">
625 648
 						<td colspan="6">', $txt['membergroups_members_no_members'], '</td>
626 649
 					</tr>';
650
+	}
627 651
 
628 652
 	foreach ($context['members'] as $member)
629 653
 	{
@@ -631,20 +655,22 @@  discard block
 block discarded – undo
631 655
 					<tr class="windowbg">
632 656
 						<td>', $member['name'], '</td>';
633 657
 
634
-		if ($context['can_send_email'])
635
-			echo '
658
+		if ($context['can_send_email']) {
659
+					echo '
636 660
 						<td>
637 661
 								<a href="mailto:', $member['email'], '">', $member['email'], '</a>
638 662
 						</td>';
663
+		}
639 664
 
640 665
 		echo '
641 666
 						<td>', $member['last_online'], '</td>
642 667
 						<td>', $member['registered'], '</td>
643 668
 						<td', empty($context['group']['assignable']) ? ' colspan="2"' : '', '>', $member['posts'], '</td>';
644 669
 
645
-		if (!empty($context['group']['assignable']))
646
-			echo '
670
+		if (!empty($context['group']['assignable'])) {
671
+					echo '
647 672
 						<td style="width: 4%"><input type="checkbox" name="rem[]" value="', $member['id'], '" ', ($context['user']['id'] == $member['id'] && $context['group']['id'] == 1 ? 'onclick="if (this.checked) return confirm(\'' . $txt['membergroups_members_deadmin_confirm'] . '\')" ' : ''), '/></td>';
673
+		}
648 674
 
649 675
 		echo '
650 676
 					</tr>';
@@ -654,11 +680,12 @@  discard block
 block discarded – undo
654 680
 				</tbody>
655 681
 			</table>';
656 682
 
657
-	if (!empty($context['group']['assignable']))
658
-		echo '
683
+	if (!empty($context['group']['assignable'])) {
684
+			echo '
659 685
 			<div class="floatright">
660 686
 				<input type="submit" name="remove" value="', $txt['membergroups_members_remove'], '" class="button ">
661 687
 			</div>';
688
+	}
662 689
 
663 690
 	echo '
664 691
 			<div class="pagesection flow_hidden">
@@ -666,8 +693,8 @@  discard block
 block discarded – undo
666 693
 			</div>
667 694
 			<br>';
668 695
 
669
-	if (!empty($context['group']['assignable']))
670
-		echo '
696
+	if (!empty($context['group']['assignable'])) {
697
+			echo '
671 698
 			<div class="cat_bar">
672 699
 				<h3 class="catbg">', $txt['membergroups_members_add_title'], '</h3>
673 700
 			</div>
@@ -683,14 +710,15 @@  discard block
 block discarded – undo
683 710
 				</dl>
684 711
 				<input type="submit" name="add" value="', $txt['membergroups_members_add'], '" class="button">
685 712
 			</div>';
713
+	}
686 714
 
687 715
 	echo '
688 716
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
689 717
 			<input type="hidden" name="', $context['mod-mgm_token_var'], '" value="', $context['mod-mgm_token'], '">
690 718
 		</form>';
691 719
 
692
-	if (!empty($context['group']['assignable']))
693
-		echo '
720
+	if (!empty($context['group']['assignable'])) {
721
+			echo '
694 722
 	<script>
695 723
 		var oAddMemberSuggest = new smc_AutoSuggest({
696 724
 			sSelf: \'oAddMemberSuggest\',
@@ -706,7 +734,8 @@  discard block
 block discarded – undo
706 734
 			sItemListContainerId: \'toAddItemContainer\'
707 735
 		});
708 736
 	</script>';
709
-}
737
+	}
738
+	}
710 739
 
711 740
 /**
712 741
  * Allow the moderator to enter a reason to each user being rejected.
@@ -726,8 +755,8 @@  discard block
 block discarded – undo
726 755
 				<dl class="settings">';
727 756
 
728 757
 	// Loop through and print out a reason box for each...
729
-	foreach ($context['group_requests'] as $request)
730
-		echo '
758
+	foreach ($context['group_requests'] as $request) {
759
+			echo '
731 760
 					<dt>
732 761
 						<strong>', sprintf($txt['mc_groupr_reason_desc'], $request['member_link'], $request['group_link']), ':</strong>
733 762
 					</dt>
@@ -735,6 +764,7 @@  discard block
 block discarded – undo
735 764
 						<input type="hidden" name="groupr[]" value="', $request['id'], '">
736 765
 						<textarea name="groupreason[', $request['id'], ']" rows="3" cols="40"></textarea>
737 766
 					</dd>';
767
+	}
738 768
 
739 769
 	echo '
740 770
 				</dl>
Please login to merge, or discard this patch.
Themes/default/ManageBoards.template.php 1 patch
Braces   +99 added lines, -68 removed lines patch added patch discarded remove patch
@@ -25,18 +25,20 @@  discard block
 block discarded – undo
25 25
 		</div>
26 26
 		<div class="windowbg">';
27 27
 
28
-	if (!empty($context['move_board']))
29
-		echo '
28
+	if (!empty($context['move_board'])) {
29
+			echo '
30 30
 			<div class="noticebox">
31 31
 				', $context['move_title'], ' [<a href="', $scripturl, '?action=admin;area=manageboards">', $txt['mboards_cancel_moving'], '</a>]', '
32 32
 			</div>';
33
+	}
33 34
 
34 35
 	// No categories so show a label.
35
-	if (empty($context['categories']))
36
-		echo '
36
+	if (empty($context['categories'])) {
37
+			echo '
37 38
 			<div class="windowbg centertext">
38 39
 				', $txt['mboards_no_cats'], '
39 40
 			</div>';
41
+	}
40 42
 
41 43
 	// Loop through every category, listing the boards in each as we go.
42 44
 	foreach ($context['categories'] as $category)
@@ -54,9 +56,10 @@  discard block
 block discarded – undo
54 56
 			<form action="', $scripturl, '?action=admin;area=manageboards;sa=newboard;cat=', $category['id'], '" method="post" accept-charset="', $context['character_set'], '">
55 57
 				<ul id="category_', $category['id'], '" class="nolist">';
56 58
 
57
-		if (!empty($category['move_link']))
58
-			echo '
59
+		if (!empty($category['move_link'])) {
60
+					echo '
59 61
 					<li><a href="', $category['move_link']['href'], '" title="', $category['move_link']['label'], '"><span class="generic_icons select_above"></span></a></li>';
62
+		}
60 63
 
61 64
 		$recycle_board = '<a href="' . $scripturl . '?action=admin;area=manageboards;sa=settings"> <img src="' . $settings['images_url'] . '/post/recycled.png" alt="' . $txt['recycle_board'] . '" title="' . $txt['recycle_board'] . '"></a>';
62 65
 		$redirect_board = '<img src="' . $settings['images_url'] . '/new_redirect.png" alt="' . $txt['redirect_board_desc'] . '" title="' . $txt['redirect_board_desc'] . '">';
@@ -79,9 +82,10 @@  discard block
 block discarded – undo
79 82
 				echo '
80 83
 					<li class="windowbg" style="padding-', $context['right_to_left'] ? 'right' : 'left', ': ', 5 + 30 * $board['move_links'][0]['child_level'], 'px;">';
81 84
 
82
-				foreach ($board['move_links'] as $link)
83
-					echo '
85
+				foreach ($board['move_links'] as $link) {
86
+									echo '
84 87
 						<a href="', $link['href'], '" class="move_links" title="', $link['label'], '"><span class="generic_icons select_', $link['class'], '" title="', $link['label'], '"></span></a>';
88
+				}
85 89
 
86 90
 				echo '
87 91
 					</li>';
@@ -130,9 +134,10 @@  discard block
 block discarded – undo
130 134
 						<select name="cat_order">';
131 135
 
132 136
 		// Print every existing category into a select box.
133
-		foreach ($context['category_order'] as $order)
134
-			echo '
137
+		foreach ($context['category_order'] as $order) {
138
+					echo '
135 139
 							<option', $order['selected'] ? ' selected' : '', ' value="', $order['id'], '">', $order['name'], '</option>';
140
+		}
136 141
 		echo '
137 142
 						</select>
138 143
 					</dd>';
@@ -167,14 +172,15 @@  discard block
 block discarded – undo
167 172
 	{
168 173
 		foreach ($context['custom_category_settings'] as $catset_id => $catset)
169 174
 		{
170
-			if (!empty($catset['dt']) && !empty($catset['dd']))
171
-				echo '
175
+			if (!empty($catset['dt']) && !empty($catset['dd'])) {
176
+							echo '
172 177
 					<dt class="clear', !is_numeric($catset_id) ? ' catset_' . $catset_id : '', '">
173 178
 						', $catset['dt'], '
174 179
 					</dt>
175 180
 					<dd', !is_numeric($catset_id) ? ' class="catset_' . $catset_id . '"' : '', '>
176 181
 						', $catset['dd'], '
177 182
 					</dd>';
183
+			}
178 184
 		}
179 185
 	}
180 186
 
@@ -182,21 +188,23 @@  discard block
 block discarded – undo
182 188
 	echo '
183 189
 				</dl>';
184 190
 
185
-	if (isset($context['category']['is_new']))
186
-		echo '
191
+	if (isset($context['category']['is_new'])) {
192
+			echo '
187 193
 				<input type="submit" name="add" value="', $txt['mboards_add_cat_button'], '" onclick="return !isEmptyText(this.form.cat_name);" tabindex="', $context['tabindex']++, '" class="button">';
188
-	else
189
-		echo '
194
+	} else {
195
+			echo '
190 196
 				<input type="submit" name="edit" value="', $txt['modify'], '" onclick="return !isEmptyText(this.form.cat_name);" tabindex="', $context['tabindex']++, '" class="button">
191 197
 				<input type="submit" name="delete" value="', $txt['mboards_delete_cat'], '" data-confirm="', $txt['catConfirm'], '" class="button you_sure">';
198
+	}
192 199
 	echo '
193 200
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
194 201
 				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
195 202
 
196 203
 	// If this category is empty we don't bother with the next confirmation screen.
197
-	if ($context['category']['is_empty'])
198
-		echo '
204
+	if ($context['category']['is_empty']) {
205
+			echo '
199 206
 				<input type="hidden" name="empty" value="1">';
207
+	}
200 208
 
201 209
 	echo '
202 210
 			</div><!-- .windowbg -->
@@ -223,9 +231,10 @@  discard block
 block discarded – undo
223 231
 				<p>', $txt['mboards_delete_cat_contains'], ':</p>
224 232
 				<ul>';
225 233
 
226
-	foreach ($context['category']['children'] as $child)
227
-		echo '
234
+	foreach ($context['category']['children'] as $child) {
235
+			echo '
228 236
 					<li>', $child, '</li>';
237
+	}
229 238
 
230 239
 	echo '
231 240
 				</ul>
@@ -239,10 +248,11 @@  discard block
 block discarded – undo
239 248
 					<label for="delete_action1"><input type="radio" id="delete_action1" name="delete_action" value="1"', count($context['category_order']) == 1 ? ' disabled' : '', '>', $txt['mboards_delete_option2'], '</label>:
240 249
 					<select name="cat_to"', count($context['category_order']) == 1 ? ' disabled' : '', '>';
241 250
 
242
-	foreach ($context['category_order'] as $cat)
243
-		if ($cat['id'] != 0)
251
+	foreach ($context['category_order'] as $cat) {
252
+			if ($cat['id'] != 0)
244 253
 			echo '
245 254
 						<option value="', $cat['id'], '">', $cat['true_name'], '</option>';
255
+	}
246 256
 
247 257
 	echo '
248 258
 					</select>
@@ -285,9 +295,10 @@  discard block
 block discarded – undo
285 295
 					<dd>
286 296
 						<select name="new_cat" onchange="if (this.form.order) {this.form.order.disabled = this.options[this.selectedIndex].value != 0; this.form.board_order.disabled = this.options[this.selectedIndex].value != 0 || this.form.order.options[this.form.order.selectedIndex].value == \'\';}">';
287 297
 
288
-	foreach ($context['categories'] as $category)
289
-		echo '
298
+	foreach ($context['categories'] as $category) {
299
+			echo '
290 300
 							<option', $category['selected'] ? ' selected' : '', ' value="', $category['id'], '">', $category['name'], '</option>';
301
+	}
291 302
 	echo '
292 303
 						</select>
293 304
 					</dd>';
@@ -315,9 +326,10 @@  discard block
 block discarded – undo
315 326
 						<select id="board_order" name="board_order"', !isset($context['board']['is_new']) ? ' disabled' : '', '>
316 327
 							', !isset($context['board']['is_new']) ? '<option value="">(' . $txt['mboards_unchanged'] . ')</option>' : '';
317 328
 
318
-		foreach ($context['board_order'] as $order)
319
-			echo '
329
+		foreach ($context['board_order'] as $order) {
330
+					echo '
320 331
 							<option', $order['selected'] ? ' selected' : '', ' value="', $order['id'], '">', $order['name'], '</option>';
332
+		}
321 333
 		echo '
322 334
 						</select>
323 335
 					</dd>';
@@ -346,13 +358,15 @@  discard block
 block discarded – undo
346 358
 					<dd>
347 359
 						<select name="profile">';
348 360
 
349
-	if (isset($context['board']['is_new']))
350
-		echo '
361
+	if (isset($context['board']['is_new'])) {
362
+			echo '
351 363
 							<option value="-1">[', $txt['permission_profile_inherit'], ']</option>';
364
+	}
352 365
 
353
-	foreach ($context['profiles'] as $id => $profile)
354
-		echo '
366
+	foreach ($context['profiles'] as $id => $profile) {
367
+			echo '
355 368
 							<option value="', $id, '"', $id == $context['board']['profile'] ? ' selected' : '', '>', $profile['name'], '</option>';
369
+	}
356 370
 
357 371
 	echo '
358 372
 						</select>
@@ -365,8 +379,8 @@  discard block
 block discarded – undo
365 379
 					</dt>
366 380
 					<dd>';
367 381
 
368
-	if (!empty($modSettings['deny_boards_access']))
369
-		echo '
382
+	if (!empty($modSettings['deny_boards_access'])) {
383
+			echo '
370 384
 						<table>
371 385
 							<tr>
372 386
 								<td></td>
@@ -374,10 +388,11 @@  discard block
 block discarded – undo
374 388
 								<th>', $txt['permissions_option_off'], '</th>
375 389
 								<th>', $txt['permissions_option_deny'], '</th>
376 390
 							</tr>';
391
+	}
377 392
 
378 393
 	// List all the membergroups so the user can choose who may access this board.
379
-	foreach ($context['groups'] as $group)
380
-		if (empty($modSettings['deny_boards_access']))
394
+	foreach ($context['groups'] as $group) {
395
+			if (empty($modSettings['deny_boards_access']))
381 396
 			echo '
382 397
 						<label for="groups_', $group['id'], '">
383 398
 							<input type="checkbox" name="groups[', $group['id'], ']" value="allow" id="groups_', $group['id'], '"', in_array($group['id'], $context['board_managers']) ? ' checked disabled' : ($group['allow'] ? ' checked' : ''), '>
@@ -385,8 +400,9 @@  discard block
 block discarded – undo
385 400
 								', $group['name'], '
386 401
 							</span>
387 402
 						</label><br>';
388
-		else
389
-			echo '
403
+	}
404
+		else {
405
+					echo '
390 406
 							<tr>
391 407
 								<td>
392 408
 									<label for="groups_', $group['id'], '_a">
@@ -406,16 +422,17 @@  discard block
 block discarded – undo
406 422
 								</td>
407 423
 								<td></td>
408 424
 							</tr>';
425
+		}
409 426
 
410
-	if (empty($modSettings['deny_boards_access']))
411
-		echo '
427
+	if (empty($modSettings['deny_boards_access'])) {
428
+			echo '
412 429
 						<span class="select_all_box">
413 430
 							<em>', $txt['check_all'], '</em> <input type="checkbox" onclick="invertAll(this, this.form, \'groups[\');">
414 431
 						</span>
415 432
 						<br><br>
416 433
 					</dd>';
417
-	else
418
-		echo '
434
+	} else {
435
+			echo '
419 436
 							<tr class="select_all_box">
420 437
 								<td>
421 438
 								</td>
@@ -434,6 +451,7 @@  discard block
 block discarded – undo
434 451
 							</tr>
435 452
 						</table>
436 453
 					</dd>';
454
+	}
437 455
 
438 456
 	// Options to choose moderators, specify as announcement board and choose whether to count posts here.
439 457
 	echo '
@@ -488,8 +506,8 @@  discard block
 block discarded – undo
488 506
 					</dl>
489 507
 				</div>';
490 508
 
491
-		if ($context['board']['redirect'])
492
-			echo '
509
+		if ($context['board']['redirect']) {
510
+					echo '
493 511
 				<div id="reset_redirect_div">
494 512
 					<dl class="settings">
495 513
 						<dt>
@@ -502,6 +520,7 @@  discard block
 block discarded – undo
502 520
 						</dd>
503 521
 					</dl>
504 522
 				</div>';
523
+		}
505 524
 	}
506 525
 
507 526
 	echo '
@@ -529,9 +548,10 @@  discard block
 block discarded – undo
529 548
 							<select name="boardtheme" id="boardtheme" onchange="refreshOptions();">
530 549
 								<option value="0"', $context['board']['theme'] == 0 ? ' selected' : '', '>', $txt['mboards_theme_default'], '</option>';
531 550
 
532
-	foreach ($context['themes'] as $theme)
533
-		echo '
551
+	foreach ($context['themes'] as $theme) {
552
+			echo '
534 553
 									<option value="', $theme['id'], '"', $context['board']['theme'] == $theme['id'] ? ' selected' : '', '>', $theme['name'], '</option>';
554
+	}
535 555
 
536 556
 	echo '
537 557
 							</select>
@@ -560,14 +580,15 @@  discard block
 block discarded – undo
560 580
 
561 581
 		foreach ($context['custom_board_settings'] as $cbs_id => $cbs)
562 582
 		{
563
-			if (!empty($cbs['dt']) && !empty($cbs['dd']))
564
-				echo '
583
+			if (!empty($cbs['dt']) && !empty($cbs['dd'])) {
584
+							echo '
565 585
 						<dt class="clear', !is_numeric($cbs_id) ? ' cbs_' . $cbs_id : '', '">
566 586
 							', $cbs['dt'], '
567 587
 						</dt>
568 588
 						<dd', !is_numeric($cbs_id) ? ' class="cbs_' . $cbs_id . '"' : '', '>
569 589
 							', $cbs['dd'], '
570 590
 						</dd>';
591
+			}
571 592
 		}
572 593
 
573 594
 		echo '
@@ -575,9 +596,10 @@  discard block
 block discarded – undo
575 596
 				</div>';
576 597
 	}
577 598
 
578
-	if (!empty($context['board']['is_recycle']))
579
-		echo '
599
+	if (!empty($context['board']['is_recycle'])) {
600
+			echo '
580 601
 				<div class="noticebox">', $txt['mboards_recycle_disabled_delete'], '</div>';
602
+	}
581 603
 
582 604
 	echo '
583 605
 				<input type="hidden" name="rid" value="', $context['redirect_location'], '">
@@ -585,21 +607,24 @@  discard block
 block discarded – undo
585 607
 				<input type="hidden" name="', $context['admin-be-' . $context['board']['id'] . '_token_var'], '" value="', $context['admin-be-' . $context['board']['id'] . '_token'], '">';
586 608
 
587 609
 	// If this board has no children don't bother with the next confirmation screen.
588
-	if ($context['board']['no_children'])
589
-		echo '
610
+	if ($context['board']['no_children']) {
611
+			echo '
590 612
 				<input type="hidden" name="no_children" value="1">';
613
+	}
591 614
 
592
-	if (isset($context['board']['is_new']))
593
-		echo '
615
+	if (isset($context['board']['is_new'])) {
616
+			echo '
594 617
 				<input type="hidden" name="cur_cat" value="', $context['board']['category'], '">
595 618
 				<input type="submit" name="add" value="', $txt['mboards_new_board'], '" onclick="return !isEmptyText(this.form.board_name);" class="button">';
596
-	else
597
-		echo '
619
+	} else {
620
+			echo '
598 621
 				<input type="submit" name="edit" value="', $txt['modify'], '" onclick="return !isEmptyText(this.form.board_name);" class="button">';
622
+	}
599 623
 
600
-	if (!isset($context['board']['is_new']) && empty($context['board']['is_recycle']))
601
-		echo '
624
+	if (!isset($context['board']['is_new']) && empty($context['board']['is_recycle'])) {
625
+			echo '
602 626
 				<input type="submit" name="delete" value="', $txt['mboards_delete_board'], '" data-confirm="', $txt['boardConfirm'], '" class="button you_sure">';
627
+	}
603 628
 	echo '
604 629
 			</div><!-- .windowbg -->
605 630
 		</form>
@@ -620,12 +645,13 @@  discard block
 block discarded – undo
620 645
 			sItemListContainerId: \'moderator_container\',
621 646
 			aListItems: [';
622 647
 
623
-	foreach ($context['board']['moderators'] as $id_member => $member_name)
624
-		echo '
648
+	foreach ($context['board']['moderators'] as $id_member => $member_name) {
649
+			echo '
625 650
 				{
626 651
 					sItemId: ', JavaScriptEscape($id_member), ',
627 652
 					sItemName: ', JavaScriptEscape($member_name), '
628 653
 				}', $id_member == $context['board']['last_moderator_id'] ? '' : ',';
654
+	}
629 655
 
630 656
 	echo '
631 657
 			]
@@ -645,12 +671,13 @@  discard block
 block discarded – undo
645 671
 			sItemListContainerId: \'moderator_group_container\',
646 672
 			aListItems: [';
647 673
 
648
-	foreach ($context['board']['moderator_groups'] as $id_group => $group_name)
649
-		echo '
674
+	foreach ($context['board']['moderator_groups'] as $id_group => $group_name) {
675
+			echo '
650 676
 				{
651 677
 					sItemId: ', JavaScriptEscape($id_group), ',
652 678
 					sItemName: ', JavaScriptEscape($group_name), '
653 679
 				}', $id_group == $context['board']['last_moderator_group_id'] ? '' : ',';
680
+	}
654 681
 
655 682
 		echo '
656 683
 			]
@@ -689,20 +716,22 @@  discard block
 block discarded – undo
689 716
 			else 
690 717
 				document.getElementById("redirect_address_div").classList.add(\'hidden\');';
691 718
 
692
-		if ($context['board']['redirect'])
693
-			echo '
719
+		if ($context['board']['redirect']) {
720
+					echo '
694 721
 			if(redirectEnabled)
695 722
 				document.getElementById("reset_redirect_div").classList.remove(\'hidden\');
696 723
 			else 
697 724
 				document.getElementById("reset_redirect_div").classList.add(\'hidden\');';
725
+		}
698 726
 	}
699 727
 
700 728
 	// Include any JavaScript added by mods using the 'integrate_edit_board' hook.
701 729
 	if (!empty($context['custom_refreshOptions']) && is_array($context['custom_refreshOptions']))
702 730
 	{
703
-		foreach ($context['custom_refreshOptions'] as $refreshOption)
704
-			echo '
731
+		foreach ($context['custom_refreshOptions'] as $refreshOption) {
732
+					echo '
705 733
 			', $refreshOption;
734
+		}
706 735
 	}
707 736
 
708 737
 	echo '
@@ -731,9 +760,10 @@  discard block
 block discarded – undo
731 760
 				<p>', $txt['mboards_delete_board_contains'], '</p>
732 761
 				<ul>';
733 762
 
734
-	foreach ($context['children'] as $child)
735
-		echo '
763
+	foreach ($context['children'] as $child) {
764
+			echo '
736 765
 					<li>', $child['node']['name'], '</li>';
766
+	}
737 767
 
738 768
 	echo '
739 769
 				</ul>
@@ -747,10 +777,11 @@  discard block
 block discarded – undo
747 777
 					<label for="delete_action1"><input type="radio" id="delete_action1" name="delete_action" value="1"', empty($context['can_move_children']) ? ' disabled' : '', '>', $txt['mboards_delete_board_option2'], '</label>:
748 778
 					<select name="board_to"', empty($context['can_move_children']) ? ' disabled' : '', '>';
749 779
 
750
-	foreach ($context['board_order'] as $board)
751
-		if ($board['id'] != $context['board']['id'] && empty($board['is_child']))
780
+	foreach ($context['board_order'] as $board) {
781
+			if ($board['id'] != $context['board']['id'] && empty($board['is_child']))
752 782
 			echo '
753 783
 						<option value="', $board['id'], '">', $board['name'], '</option>';
784
+	}
754 785
 
755 786
 	echo '
756 787
 					</select>
Please login to merge, or discard this patch.