Completed
Pull Request — release-2.1 (#4156)
by 01
13:04 queued 03:20
created
Sources/Subs-Notify.php 1 patch
Braces   +17 added lines, -11 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
  * @version 2.1 Beta 4
12 12
  */
13 13
 
14
-if (!defined('SMF'))
14
+if (!defined('SMF')) {
15 15
 	die('No direct access...');
16
+}
16 17
 
17 18
 /**
18 19
  * Fetches the list of preferences (or a single/subset of preferences) for
@@ -30,8 +31,9 @@  discard block
 block discarded – undo
30 31
 	// We want this as an array whether it is or not.
31 32
 	$members = is_array($members) ? $members : (array) $members;
32 33
 
33
-	if (!empty($prefs))
34
-		$prefs = is_array($prefs) ? $prefs : (array) $prefs;
34
+	if (!empty($prefs)) {
35
+			$prefs = is_array($prefs) ? $prefs : (array) $prefs;
36
+	}
35 37
 
36 38
 	$result = array();
37 39
 
@@ -56,9 +58,10 @@  discard block
 block discarded – undo
56 58
 	// We may want to keep the default values separate from a given user's. Or we might not.
57 59
 	if ($process_default && isset($result[0]))
58 60
 	{
59
-		foreach ($members as $member)
60
-			if (!isset($result[$member]))
61
+		foreach ($members as $member) {
62
+					if (!isset($result[$member]))
61 63
 				$result[$member] = $result[0];
64
+		}
62 65
 
63 66
 		unset ($result[0]);
64 67
 	}
@@ -76,12 +79,14 @@  discard block
 block discarded – undo
76 79
 {
77 80
 	global $smcFunc;
78 81
 
79
-	if (empty($prefs) || !is_int($memID))
80
-		return;
82
+	if (empty($prefs) || !is_int($memID)) {
83
+			return;
84
+	}
81 85
 
82 86
 	$update_rows = array();
83
-	foreach ($prefs as $k => $v)
84
-		$update_rows[] = array($memID, $k, $v);
87
+	foreach ($prefs as $k => $v) {
88
+			$update_rows[] = array($memID, $k, $v);
89
+	}
85 90
 
86 91
 	$smcFunc['db_insert']('replace',
87 92
 		'{db_prefix}user_alerts_prefs',
@@ -101,8 +106,9 @@  discard block
 block discarded – undo
101 106
 {
102 107
 	global $smcFunc;
103 108
 
104
-	if (empty($prefs) || empty($memID))
105
-		return;
109
+	if (empty($prefs) || empty($memID)) {
110
+			return;
111
+	}
106 112
 
107 113
 	$smcFunc['db_query']('', '
108 114
 		DELETE FROM {db_prefix}user_alerts_prefs
Please login to merge, or discard this patch.
Sources/ManageLanguages.php 1 patch
Braces   +190 added lines, -142 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * This is the main function for the languages area.
@@ -153,11 +154,11 @@  discard block
 block discarded – undo
153 154
 	$language_list = new xmlArray(fetch_web_data($url), true);
154 155
 
155 156
 	// Check that the site responded and that the language exists.
156
-	if (!$language_list->exists('languages'))
157
-		$context['smf_error'] = 'no_response';
158
-	elseif (!$language_list->exists('languages/language'))
159
-		$context['smf_error'] = 'no_files';
160
-	else
157
+	if (!$language_list->exists('languages')) {
158
+			$context['smf_error'] = 'no_response';
159
+	} elseif (!$language_list->exists('languages/language')) {
160
+			$context['smf_error'] = 'no_files';
161
+	} else
161 162
 	{
162 163
 		$language_list = $language_list->path('languages[0]');
163 164
 		$lang_files = $language_list->set('language');
@@ -165,8 +166,9 @@  discard block
 block discarded – undo
165 166
 		foreach ($lang_files as $file)
166 167
 		{
167 168
 			// Were we searching?
168
-			if (!empty($context['smf_search_term']) && strpos($file->fetch('name'), $smcFunc['strtolower']($context['smf_search_term'])) === false)
169
-				continue;
169
+			if (!empty($context['smf_search_term']) && strpos($file->fetch('name'), $smcFunc['strtolower']($context['smf_search_term'])) === false) {
170
+							continue;
171
+			}
170 172
 
171 173
 			$smf_languages[] = array(
172 174
 				'id' => $file->fetch('id'),
@@ -177,10 +179,11 @@  discard block
 block discarded – undo
177 179
 				'install_link' => '<a href="' . $scripturl . '?action=admin;area=languages;sa=downloadlang;did=' . $file->fetch('id') . ';' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['add_language_smf_install'] . '</a>',
178 180
 			);
179 181
 		}
180
-		if (empty($smf_languages))
181
-			$context['smf_error'] = 'no_files';
182
-		else
183
-			return $smf_languages;
182
+		if (empty($smf_languages)) {
183
+					$context['smf_error'] = 'no_files';
184
+		} else {
185
+					return $smf_languages;
186
+		}
184 187
 	}
185 188
 }
186 189
 
@@ -202,8 +205,9 @@  discard block
 block discarded – undo
202 205
 	require_once($sourcedir . '/Subs-Package.php');
203 206
 
204 207
 	// Clearly we need to know what to request.
205
-	if (!isset($_GET['did']))
206
-		fatal_lang_error('no_access', false);
208
+	if (!isset($_GET['did'])) {
209
+			fatal_lang_error('no_access', false);
210
+	}
207 211
 
208 212
 	// Some lovely context.
209 213
 	$context['download_id'] = $_GET['did'];
@@ -223,8 +227,9 @@  discard block
 block discarded – undo
223 227
 		foreach ($_POST['copy_file'] as $file)
224 228
 		{
225 229
 			// Check it's not very bad.
226
-			if (strpos($file, '..') !== false || (strpos($file, 'Themes') !== 0 && !preg_match('~agreement\.[A-Za-z-_0-9]+\.txt$~', $file)))
227
-				fatal_error($txt['languages_download_illegal_paths']);
230
+			if (strpos($file, '..') !== false || (strpos($file, 'Themes') !== 0 && !preg_match('~agreement\.[A-Za-z-_0-9]+\.txt$~', $file))) {
231
+							fatal_error($txt['languages_download_illegal_paths']);
232
+			}
228 233
 
229 234
 			$chmod_files[] = $boarddir . '/' . $file;
230 235
 			$install_files[] = $file;
@@ -235,8 +240,9 @@  discard block
 block discarded – undo
235 240
 		$files_left = $file_status['files']['notwritable'];
236 241
 
237 242
 		// Something not writable?
238
-		if (!empty($files_left))
239
-			$context['error_message'] = $txt['languages_download_not_chmod'];
243
+		if (!empty($files_left)) {
244
+					$context['error_message'] = $txt['languages_download_not_chmod'];
245
+		}
240 246
 		// Otherwise, go go go!
241 247
 		elseif (!empty($install_files))
242 248
 		{
@@ -251,11 +257,13 @@  discard block
 block discarded – undo
251 257
 	}
252 258
 
253 259
 	// Open up the old china.
254
-	if (!isset($archive_content))
255
-		$archive_content = read_tgz_file('https://download.simplemachines.org/fetch_language.php?version=' . urlencode(strtr($forum_version, array('SMF ' => ''))) . ';fetch=' . urlencode($_GET['did']), null);
260
+	if (!isset($archive_content)) {
261
+			$archive_content = read_tgz_file('https://download.simplemachines.org/fetch_language.php?version=' . urlencode(strtr($forum_version, array('SMF ' => ''))) . ';fetch=' . urlencode($_GET['did']), null);
262
+	}
256 263
 
257
-	if (empty($archive_content))
258
-		fatal_error($txt['add_language_error_no_response']);
264
+	if (empty($archive_content)) {
265
+			fatal_error($txt['add_language_error_no_response']);
266
+	}
259 267
 
260 268
 	// Now for each of the files, let's do some *stuff*
261 269
 	$context['files'] = array(
@@ -270,8 +278,9 @@  discard block
 block discarded – undo
270 278
 		$extension = substr($filename, strrpos($filename, '.') + 1);
271 279
 
272 280
 		// Don't do anything with files we don't understand.
273
-		if (!in_array($extension, array('php', 'jpg', 'gif', 'jpeg', 'png', 'txt')))
274
-			continue;
281
+		if (!in_array($extension, array('php', 'jpg', 'gif', 'jpeg', 'png', 'txt'))) {
282
+					continue;
283
+		}
275 284
 
276 285
 		// Basic data.
277 286
 		$context_data = array(
@@ -290,8 +299,9 @@  discard block
 block discarded – undo
290 299
 		// Does the file exist, is it different and can we overwrite?
291 300
 		if (file_exists($boarddir . '/' . $file['filename']))
292 301
 		{
293
-			if (is_writable($boarddir . '/' . $file['filename']))
294
-				$context_data['writable'] = true;
302
+			if (is_writable($boarddir . '/' . $file['filename'])) {
303
+							$context_data['writable'] = true;
304
+			}
295 305
 
296 306
 			// Finally, do we actually think the content has changed?
297 307
 			if ($file['size'] == filesize($boarddir . '/' . $file['filename']) && $file['md5'] == md5_file($boarddir . '/' . $file['filename']))
@@ -304,16 +314,17 @@  discard block
 block discarded – undo
304 314
 			{
305 315
 				$context_data['exists'] = 'same';
306 316
 				$context_data['default_copy'] = false;
317
+			} else {
318
+							$context_data['exists'] = 'different';
307 319
 			}
308
-			else
309
-				$context_data['exists'] = 'different';
310 320
 		}
311 321
 		// No overwrite?
312 322
 		else
313 323
 		{
314 324
 			// Can we at least stick it in the directory...
315
-			if (is_writable($boarddir . '/' . $dirname))
316
-				$context_data['writable'] = true;
325
+			if (is_writable($boarddir . '/' . $dirname)) {
326
+							$context_data['writable'] = true;
327
+			}
317 328
 		}
318 329
 
319 330
 		// I love PHP files, that's why I'm a developer and not an artistic type spending my time drinking absinth and living a life of sin...
@@ -328,8 +339,9 @@  discard block
 block discarded – undo
328 339
 			list ($name, $language) = explode('.', $filename);
329 340
 
330 341
 			// Let's get the new version, I like versions, they tell me that I'm up to date.
331
-			if (preg_match('~\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '~i', $file['preview'], $match) == 1)
332
-				$context_data['version'] = $match[1];
342
+			if (preg_match('~\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '~i', $file['preview'], $match) == 1) {
343
+							$context_data['version'] = $match[1];
344
+			}
333 345
 
334 346
 			// Now does the old file exist - if so what is it's version?
335 347
 			if (file_exists($boarddir . '/' . $file['filename']))
@@ -345,34 +357,35 @@  discard block
 block discarded – undo
345 357
 					$context_data['cur_version'] = $match[1];
346 358
 
347 359
 					// How does this compare?
348
-					if ($context_data['cur_version'] == $context_data['version'])
349
-						$context_data['version_compare'] = 'same';
350
-					elseif ($context_data['cur_version'] > $context_data['version'])
351
-						$context_data['version_compare'] = 'older';
360
+					if ($context_data['cur_version'] == $context_data['version']) {
361
+											$context_data['version_compare'] = 'same';
362
+					} elseif ($context_data['cur_version'] > $context_data['version']) {
363
+											$context_data['version_compare'] = 'older';
364
+					}
352 365
 
353 366
 					// Don't recommend copying if the version is the same.
354
-					if ($context_data['version_compare'] != 'newer')
355
-						$context_data['default_copy'] = false;
367
+					if ($context_data['version_compare'] != 'newer') {
368
+											$context_data['default_copy'] = false;
369
+					}
356 370
 				}
357 371
 			}
358 372
 
359 373
 			// Add the context data to the main set.
360 374
 			$context['files']['lang'][] = $context_data;
361
-		}
362
-		elseif ($extension == '.txt' && stripos($filename, 'agreement') !== false)
375
+		} elseif ($extension == '.txt' && stripos($filename, 'agreement') !== false)
363 376
 		{
364 377
 			// Registration agreement is a primary file
365 378
 			$context['files']['lang'][] = $context_data;
366
-		}
367
-		else
379
+		} else
368 380
 		{
369 381
 			// There shouldn't be anything else, but load this into "other" in case we decide to handle it in the future
370 382
 			$context['files']['other'][] = $context_data;
371 383
 		}
372 384
 
373 385
 		// Collect together all non-writable areas.
374
-		if (!$context_data['writable'])
375
-			$context['make_writable'][] = $context_data['destination'];
386
+		if (!$context_data['writable']) {
387
+					$context['make_writable'][] = $context_data['destination'];
388
+		}
376 389
 	}
377 390
 
378 391
 	// Before we go to far can we make anything writable, eh, eh?
@@ -387,22 +400,24 @@  discard block
 block discarded – undo
387 400
 		{
388 401
 			if ($type == 'lang')
389 402
 			{
390
-				foreach ($data as $k => $file)
391
-					if (!$file['writable'] && !in_array($file['destination'], $context['still_not_writable']))
403
+				foreach ($data as $k => $file) {
404
+									if (!$file['writable'] && !in_array($file['destination'], $context['still_not_writable']))
392 405
 						$context['files'][$type][$k]['writable'] = true;
393
-			}
394
-			else
406
+				}
407
+			} else
395 408
 			{
396
-				foreach ($data as $theme => $files)
397
-					foreach ($files as $k => $file)
409
+				foreach ($data as $theme => $files) {
410
+									foreach ($files as $k => $file)
398 411
 						if (!$file['writable'] && !in_array($file['destination'], $context['still_not_writable']))
399 412
 							$context['files'][$type][$theme][$k]['writable'] = true;
413
+				}
400 414
 			}
401 415
 		}
402 416
 
403 417
 		// Are we going to need more language stuff?
404
-		if (!empty($context['still_not_writable']))
405
-			loadLanguage('Packages');
418
+		if (!empty($context['still_not_writable'])) {
419
+					loadLanguage('Packages');
420
+		}
406 421
 	}
407 422
 
408 423
 	// This is the list for the main files.
@@ -615,12 +630,13 @@  discard block
 block discarded – undo
615 630
 	highlightSelected("list_language_list_' . ($language == '' ? 'english' : $language) . '");', true);
616 631
 
617 632
 	// Display a warning if we cannot edit the default setting.
618
-	if (!is_writable($boarddir . '/Settings.php'))
619
-		$listOptions['additional_rows'][] = array(
633
+	if (!is_writable($boarddir . '/Settings.php')) {
634
+			$listOptions['additional_rows'][] = array(
620 635
 				'position' => 'after_title',
621 636
 				'value' => $txt['language_settings_writable'],
622 637
 				'class' => 'smalltext alert',
623 638
 			);
639
+	}
624 640
 
625 641
 	require_once($sourcedir . '/Subs-List.php');
626 642
 	createList($listOptions);
@@ -662,10 +678,11 @@  discard block
 block discarded – undo
662 678
 
663 679
 	// Put them back.
664 680
 	$settings['actual_theme_dir'] = $backup_actual_theme_dir;
665
-	if (!empty($backup_base_theme_dir))
666
-		$settings['base_theme_dir'] = $backup_base_theme_dir;
667
-	else
668
-		unset($settings['base_theme_dir']);
681
+	if (!empty($backup_base_theme_dir)) {
682
+			$settings['base_theme_dir'] = $backup_base_theme_dir;
683
+	} else {
684
+			unset($settings['base_theme_dir']);
685
+	}
669 686
 
670 687
 	// Get the language files and data...
671 688
 	foreach ($context['languages'] as $lang)
@@ -694,13 +711,15 @@  discard block
 block discarded – undo
694 711
 	while ($row = $smcFunc['db_fetch_assoc']($request))
695 712
 	{
696 713
 		// Default?
697
-		if (empty($row['lngfile']) || !isset($languages[$row['lngfile']]))
698
-			$row['lngfile'] = $language;
714
+		if (empty($row['lngfile']) || !isset($languages[$row['lngfile']])) {
715
+					$row['lngfile'] = $language;
716
+		}
699 717
 
700
-		if (!isset($languages[$row['lngfile']]) && isset($languages['english']))
701
-			$languages['english']['count'] += $row['num_users'];
702
-		elseif (isset($languages[$row['lngfile']]))
703
-			$languages[$row['lngfile']]['count'] += $row['num_users'];
718
+		if (!isset($languages[$row['lngfile']]) && isset($languages['english'])) {
719
+					$languages['english']['count'] += $row['num_users'];
720
+		} elseif (isset($languages[$row['lngfile']])) {
721
+					$languages[$row['lngfile']]['count'] += $row['num_users'];
722
+		}
704 723
 	}
705 724
 	$smcFunc['db_free_result']($request);
706 725
 
@@ -740,13 +759,15 @@  discard block
 block discarded – undo
740 759
 
741 760
 	call_integration_hook('integrate_language_settings', array(&$config_vars));
742 761
 
743
-	if ($return_config)
744
-		return $config_vars;
762
+	if ($return_config) {
763
+			return $config_vars;
764
+	}
745 765
 
746 766
 	// Get our languages. No cache
747 767
 	getLanguages(false);
748
-	foreach ($context['languages'] as $lang)
749
-		$config_vars['language'][4][$lang['filename']] = array($lang['filename'], $lang['name']);
768
+	foreach ($context['languages'] as $lang) {
769
+			$config_vars['language'][4][$lang['filename']] = array($lang['filename'], $lang['name']);
770
+	}
750 771
 
751 772
 	// Saving settings?
752 773
 	if (isset($_REQUEST['save']))
@@ -756,8 +777,9 @@  discard block
 block discarded – undo
756 777
 		call_integration_hook('integrate_save_language_settings', array(&$config_vars));
757 778
 
758 779
 		saveSettings($config_vars);
759
-		if (!$settings_not_writable && !$settings_backup_fail)
760
-			$_SESSION['adm-save'] = true;
780
+		if (!$settings_not_writable && !$settings_backup_fail) {
781
+					$_SESSION['adm-save'] = true;
782
+		}
761 783
 		redirectexit('action=admin;area=languages;sa=settings');
762 784
 	}
763 785
 
@@ -766,10 +788,11 @@  discard block
 block discarded – undo
766 788
 	$context['settings_title'] = $txt['language_settings'];
767 789
 	$context['save_disabled'] = $settings_not_writable;
768 790
 
769
-	if ($settings_not_writable)
770
-		$context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>';
771
-	elseif ($settings_backup_fail)
772
-		$context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>';
791
+	if ($settings_not_writable) {
792
+			$context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>';
793
+	} elseif ($settings_backup_fail) {
794
+			$context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>';
795
+	}
773 796
 
774 797
 	// Fill the config array.
775 798
 	prepareServerSettingsContext($config_vars);
@@ -816,8 +839,9 @@  discard block
 block discarded – undo
816 839
 			'theme_dir' => $settings['default_theme_dir'],
817 840
 		),
818 841
 	);
819
-	while ($row = $smcFunc['db_fetch_assoc']($request))
820
-		$themes[$row['id_theme']][$row['variable']] = $row['value'];
842
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
843
+			$themes[$row['id_theme']][$row['variable']] = $row['value'];
844
+	}
821 845
 	$smcFunc['db_free_result']($request);
822 846
 
823 847
 	// This will be where we look
@@ -829,14 +853,16 @@  discard block
 block discarded – undo
829 853
 	// Check we have themes with a path and a name - just in case - and add the path.
830 854
 	foreach ($themes as $id => $data)
831 855
 	{
832
-		if (count($data) != 2)
833
-			unset($themes[$id]);
834
-		elseif (is_dir($data['theme_dir'] . '/languages'))
835
-			$lang_dirs[$id] = $data['theme_dir'] . '/languages';
856
+		if (count($data) != 2) {
857
+					unset($themes[$id]);
858
+		} elseif (is_dir($data['theme_dir'] . '/languages')) {
859
+					$lang_dirs[$id] = $data['theme_dir'] . '/languages';
860
+		}
836 861
 
837 862
 		// How about image directories?
838
-		if (is_dir($data['theme_dir'] . '/images/' . $context['lang_id']))
839
-			$images_dirs[$id] = $data['theme_dir'] . '/images/' . $context['lang_id'];
863
+		if (is_dir($data['theme_dir'] . '/images/' . $context['lang_id'])) {
864
+					$images_dirs[$id] = $data['theme_dir'] . '/images/' . $context['lang_id'];
865
+		}
840 866
 	}
841 867
 
842 868
 	$current_file = $file_id ? $lang_dirs[$theme_id] . '/' . $file_id . '.' . $context['lang_id'] . '.php' : '';
@@ -850,15 +876,17 @@  discard block
 block discarded – undo
850 876
 		while ($entry = $dir->read())
851 877
 		{
852 878
 			// We're only after the files for this language.
853
-			if (preg_match('~^([A-Za-z]+)\.' . $context['lang_id'] . '\.php$~', $entry, $matches) == 0)
854
-				continue;
879
+			if (preg_match('~^([A-Za-z]+)\.' . $context['lang_id'] . '\.php$~', $entry, $matches) == 0) {
880
+							continue;
881
+			}
855 882
 
856
-			if (!isset($context['possible_files'][$theme]))
857
-				$context['possible_files'][$theme] = array(
883
+			if (!isset($context['possible_files'][$theme])) {
884
+							$context['possible_files'][$theme] = array(
858 885
 					'id' => $theme,
859 886
 					'name' => $themes[$theme]['name'],
860 887
 					'files' => array(),
861 888
 				);
889
+			}
862 890
 
863 891
 			$context['possible_files'][$theme]['files'][] = array(
864 892
 				'id' => $matches[1],
@@ -887,31 +915,36 @@  discard block
 block discarded – undo
887 915
 		{
888 916
 			$_SESSION['last_backup_for'] = $context['lang_id'] . '$$$';
889 917
 			$result = package_create_backup('backup_lang_' . $context['lang_id']);
890
-			if (!$result)
891
-				fatal_lang_error('could_not_language_backup', false);
918
+			if (!$result) {
919
+							fatal_lang_error('could_not_language_backup', false);
920
+			}
892 921
 		}
893 922
 
894 923
 		// Second, loop through the array to remove the files.
895 924
 		foreach ($lang_dirs as $curPath)
896 925
 		{
897
-			foreach ($context['possible_files'][1]['files'] as $lang)
898
-				if (file_exists($curPath . '/' . $lang['id'] . '.' . $context['lang_id'] . '.php'))
926
+			foreach ($context['possible_files'][1]['files'] as $lang) {
927
+							if (file_exists($curPath . '/' . $lang['id'] . '.' . $context['lang_id'] . '.php'))
899 928
 					unlink($curPath . '/' . $lang['id'] . '.' . $context['lang_id'] . '.php');
929
+			}
900 930
 
901 931
 			// Check for the email template.
902
-			if (file_exists($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php'))
903
-				unlink($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php');
932
+			if (file_exists($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php')) {
933
+							unlink($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php');
934
+			}
904 935
 		}
905 936
 
906 937
 		// Third, the agreement file.
907
-		if (file_exists($boarddir . '/agreement.' . $context['lang_id'] . '.txt'))
908
-			unlink($boarddir . '/agreement.' . $context['lang_id'] . '.txt');
938
+		if (file_exists($boarddir . '/agreement.' . $context['lang_id'] . '.txt')) {
939
+					unlink($boarddir . '/agreement.' . $context['lang_id'] . '.txt');
940
+		}
909 941
 
910 942
 		// Fourth, a related images folder, if it exists...
911
-		if (!empty($images_dirs))
912
-			foreach ($images_dirs as $curPath)
943
+		if (!empty($images_dirs)) {
944
+					foreach ($images_dirs as $curPath)
913 945
 				if (is_dir($curPath))
914 946
 					deltree($curPath);
947
+		}
915 948
 
916 949
 		// Members can no longer use this language.
917 950
 		$smcFunc['db_query']('', '
@@ -995,8 +1028,9 @@  discard block
 block discarded – undo
995 1028
 		foreach ($_POST['entry'] as $k => $v)
996 1029
 		{
997 1030
 			// Only try to save if it's changed!
998
-			if ($_POST['entry'][$k] != $_POST['comp'][$k])
999
-				$save_strings[$k] = cleanLangString($v, false);
1031
+			if ($_POST['entry'][$k] != $_POST['comp'][$k]) {
1032
+							$save_strings[$k] = cleanLangString($v, false);
1033
+			}
1000 1034
 		}
1001 1035
 	}
1002 1036
 
@@ -1030,12 +1064,13 @@  discard block
 block discarded – undo
1030 1064
 		if ($multiline_cache)
1031 1065
 		{
1032 1066
 			preg_match('~\$(helptxt|txt|editortxt)\[\'(.+)\'\]\s?=\s?(.+);~ms', strtr($multiline_cache, array("\r" => '')), $matches);
1033
-			if (!empty($matches[3]))
1034
-				$entries[$matches[2]] = array(
1067
+			if (!empty($matches[3])) {
1068
+							$entries[$matches[2]] = array(
1035 1069
 					'type' => $matches[1],
1036 1070
 					'full' => $matches[0],
1037 1071
 					'entry' => $matches[3],
1038 1072
 				);
1073
+			}
1039 1074
 		}
1040 1075
 
1041 1076
 		// These are the entries we can definitely save.
@@ -1046,8 +1081,9 @@  discard block
 block discarded – undo
1046 1081
 		{
1047 1082
 			// Ignore some things we set separately.
1048 1083
 			$ignore_files = array('lang_character_set', 'lang_locale', 'lang_dictionary', 'lang_spelling', 'lang_rtl');
1049
-			if (in_array($entryKey, $ignore_files))
1050
-				continue;
1084
+			if (in_array($entryKey, $ignore_files)) {
1085
+							continue;
1086
+			}
1051 1087
 
1052 1088
 			// These are arrays that need breaking out.
1053 1089
 			$arrays = array('days', 'days_short', 'months', 'months_titles', 'months_short', 'happy_birthday_author', 'karlbenson1_author', 'nite0859_author', 'zwaldowski_author', 'geezmo_author', 'karlbenson2_author');
@@ -1080,9 +1116,9 @@  discard block
 block discarded – undo
1080 1116
 					{
1081 1117
 						$save_cache['entries'][$cur_index] = strtr($save_strings[$entryKey . '-+- ' . $cur_index], array('\'' => ''));
1082 1118
 						$save_cache['enabled'] = true;
1119
+					} else {
1120
+											$save_cache['entries'][$cur_index] = $subValue;
1083 1121
 					}
1084
-					else
1085
-						$save_cache['entries'][$cur_index] = $subValue;
1086 1122
 
1087 1123
 					$context['file_entries'][] = array(
1088 1124
 						'key' => $entryKey . '-+- ' . $cur_index,
@@ -1105,9 +1141,9 @@  discard block
 block discarded – undo
1105 1141
 						{
1106 1142
 							$items[] = $k2 . ' => \'' . $v2 . '\'';
1107 1143
 							$cur_index = $k2;
1144
+						} else {
1145
+													$items[] = '\'' . $v2 . '\'';
1108 1146
 						}
1109
-						else
1110
-							$items[] = '\'' . $v2 . '\'';
1111 1147
 
1112 1148
 						$cur_index++;
1113 1149
 					}
@@ -1117,15 +1153,15 @@  discard block
 block discarded – undo
1117 1153
 						'replace' => '$' . $entryValue['type'] . '[\'' . $entryKey . '\'] = array(' . implode(', ', $items) . ');',
1118 1154
 					);
1119 1155
 				}
1120
-			}
1121
-			else
1156
+			} else
1122 1157
 			{
1123 1158
 				// Saving?
1124 1159
 				if (isset($save_strings[$entryKey]) && $save_strings[$entryKey] != $entryValue['entry'])
1125 1160
 				{
1126 1161
 					// @todo Fix this properly.
1127
-					if ($save_strings[$entryKey] == '')
1128
-						$save_strings[$entryKey] = '\'\'';
1162
+					if ($save_strings[$entryKey] == '') {
1163
+											$save_strings[$entryKey] = '\'\'';
1164
+					}
1129 1165
 
1130 1166
 					// Set the new value.
1131 1167
 					$entryValue['entry'] = $save_strings[$entryKey];
@@ -1151,8 +1187,9 @@  discard block
 block discarded – undo
1151 1187
 			checkSession();
1152 1188
 
1153 1189
 			$file_contents = implode('', file($current_file));
1154
-			foreach ($final_saves as $save)
1155
-				$file_contents = strtr($file_contents, array($save['find'] => $save['replace']));
1190
+			foreach ($final_saves as $save) {
1191
+							$file_contents = strtr($file_contents, array($save['find'] => $save['replace']));
1192
+			}
1156 1193
 
1157 1194
 			// Save the actual changes.
1158 1195
 			$fp = fopen($current_file, 'w+');
@@ -1167,8 +1204,9 @@  discard block
 block discarded – undo
1167 1204
 	}
1168 1205
 
1169 1206
 	// If we saved, redirect.
1170
-	if ($madeSave)
1171
-		redirectexit('action=admin;area=languages;sa=editlang;lid=' . $context['lang_id']);
1207
+	if ($madeSave) {
1208
+			redirectexit('action=admin;area=languages;sa=editlang;lid=' . $context['lang_id']);
1209
+	}
1172 1210
 
1173 1211
 	createToken('admin-mlang');
1174 1212
 }
@@ -1200,8 +1238,9 @@  discard block
 block discarded – undo
1200 1238
 				// Toggle the escape.
1201 1239
 				$is_escape = !$is_escape;
1202 1240
 				// If we're now escaped don't add this string.
1203
-				if ($is_escape)
1204
-					continue;
1241
+				if ($is_escape) {
1242
+									continue;
1243
+				}
1205 1244
 			}
1206 1245
 			// Special case - parsed string with line break etc?
1207 1246
 			elseif (($string{$i} == 'n' || $string{$i} == 't') && $in_string == 2 && $is_escape)
@@ -1218,11 +1257,13 @@  discard block
 block discarded – undo
1218 1257
 				if ($in_string != 2 && ($in_string != 1 || !$is_escape))
1219 1258
 				{
1220 1259
 					// Is it the end of a single quote string?
1221
-					if ($in_string == 1)
1222
-						$in_string = 0;
1260
+					if ($in_string == 1) {
1261
+											$in_string = 0;
1262
+					}
1223 1263
 					// Otherwise it's the start!
1224
-					else
1225
-						$in_string = 1;
1264
+					else {
1265
+											$in_string = 1;
1266
+					}
1226 1267
 
1227 1268
 					// Don't actually include this character!
1228 1269
 					continue;
@@ -1235,19 +1276,22 @@  discard block
 block discarded – undo
1235 1276
 				if ($in_string != 1 && ($in_string != 2 || !$is_escape))
1236 1277
 				{
1237 1278
 					// Is it the end of a double quote string?
1238
-					if ($in_string == 2)
1239
-						$in_string = 0;
1279
+					if ($in_string == 2) {
1280
+											$in_string = 0;
1281
+					}
1240 1282
 					// Otherwise it's the start!
1241
-					else
1242
-						$in_string = 2;
1283
+					else {
1284
+											$in_string = 2;
1285
+					}
1243 1286
 
1244 1287
 					// Don't actually include this character!
1245 1288
 					continue;
1246 1289
 				}
1247 1290
 			}
1248 1291
 			// A join/space outside of a string is simply removed.
1249
-			elseif ($in_string == 0 && (empty($string{$i}) || $string{$i} == '.'))
1250
-				continue;
1292
+			elseif ($in_string == 0 && (empty($string{$i}) || $string{$i} == '.')) {
1293
+							continue;
1294
+			}
1251 1295
 			// Start of a variable?
1252 1296
 			elseif ($in_string == 0 && $string{$i} == '$')
1253 1297
 			{
@@ -1281,8 +1325,7 @@  discard block
 block discarded – undo
1281 1325
 
1282 1326
 		// Unhtml then rehtml the whole thing!
1283 1327
 		$new_string = $smcFunc['htmlspecialchars'](un_htmlspecialchars($new_string));
1284
-	}
1285
-	else
1328
+	} else
1286 1329
 	{
1287 1330
 		// Keep track of what we're doing...
1288 1331
 		$in_string = 0;
@@ -1311,10 +1354,11 @@  discard block
 block discarded – undo
1311 1354
 				preg_match('~\{%([\$A-Za-z0-9\'\[\]_-]+)%\}~', substr($string, $i), $matches);
1312 1355
 				if (!empty($matches[1]))
1313 1356
 				{
1314
-					if ($in_string == 1)
1315
-						$new_string .= '\' . ';
1316
-					elseif ($new_string)
1317
-						$new_string .= ' . ';
1357
+					if ($in_string == 1) {
1358
+											$new_string .= '\' . ';
1359
+					} elseif ($new_string) {
1360
+											$new_string .= ' . ';
1361
+					}
1318 1362
 
1319 1363
 					$new_string .= $matches[1];
1320 1364
 					$i += strlen($matches[1]) + 3;
@@ -1327,8 +1371,9 @@  discard block
 block discarded – undo
1327 1371
 			elseif ($string{$i} == '<')
1328 1372
 			{
1329 1373
 				// Probably HTML?
1330
-				if ($string{$i + 1} != ' ')
1331
-					$in_html = true;
1374
+				if ($string{$i + 1} != ' ') {
1375
+									$in_html = true;
1376
+				}
1332 1377
 				// Assume we need an entity...
1333 1378
 				else
1334 1379
 				{
@@ -1340,8 +1385,9 @@  discard block
 block discarded – undo
1340 1385
 			elseif ($string{$i} == '>')
1341 1386
 			{
1342 1387
 				// Will it be HTML?
1343
-				if ($in_html)
1344
-					$in_html = false;
1388
+				if ($in_html) {
1389
+									$in_html = false;
1390
+				}
1345 1391
 				// Otherwise we need an entity...
1346 1392
 				else
1347 1393
 				{
@@ -1350,8 +1396,9 @@  discard block
 block discarded – undo
1350 1396
 				}
1351 1397
 			}
1352 1398
 			// Is it a slash? If so escape it...
1353
-			if ($string{$i} == '\\')
1354
-				$new_string .= '\\';
1399
+			if ($string{$i} == '\\') {
1400
+							$new_string .= '\\';
1401
+			}
1355 1402
 			// The infamous double quote?
1356 1403
 			elseif ($string{$i} == '"')
1357 1404
 			{
@@ -1374,10 +1421,11 @@  discard block
 block discarded – undo
1374 1421
 		}
1375 1422
 
1376 1423
 		// If we ended as a string then close it off.
1377
-		if ($in_string == 1)
1378
-			$new_string .= '\'';
1379
-		elseif ($in_string == 2)
1380
-			$new_string .= '"';
1424
+		if ($in_string == 1) {
1425
+					$new_string .= '\'';
1426
+		} elseif ($in_string == 2) {
1427
+					$new_string .= '"';
1428
+		}
1381 1429
 	}
1382 1430
 
1383 1431
 	return $new_string;
Please login to merge, or discard this patch.
Sources/Profile-Actions.php 1 patch
Braces   +117 added lines, -86 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Activate an account.
@@ -48,8 +49,9 @@  discard block
 block discarded – undo
48 49
 		logAction('approve_member', array('member' => $memID), 'admin');
49 50
 
50 51
 		// If we are doing approval, update the stats for the member just in case.
51
-		if (in_array($user_profile[$memID]['is_activated'], array(3, 4, 5, 13, 14, 15)))
52
-			updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 1 ? $modSettings['unapprovedMembers'] - 1 : 0)));
52
+		if (in_array($user_profile[$memID]['is_activated'], array(3, 4, 5, 13, 14, 15))) {
53
+					updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 1 ? $modSettings['unapprovedMembers'] - 1 : 0)));
54
+		}
53 55
 
54 56
 		// Make sure we update the stats too.
55 57
 		updateStats('member', false);
@@ -76,8 +78,9 @@  discard block
 block discarded – undo
76 78
 	$issueErrors = array();
77 79
 
78 80
 	// Doesn't hurt to be overly cautious.
79
-	if (empty($modSettings['warning_enable']) || ($context['user']['is_owner'] && !$cur_profile['warning']) || !allowedTo('issue_warning'))
80
-		fatal_lang_error('no_access', false);
81
+	if (empty($modSettings['warning_enable']) || ($context['user']['is_owner'] && !$cur_profile['warning']) || !allowedTo('issue_warning')) {
82
+			fatal_lang_error('no_access', false);
83
+	}
81 84
 
82 85
 	// Get the base (errors related) stuff done.
83 86
 	loadLanguage('Errors');
@@ -135,16 +138,18 @@  discard block
 block discarded – undo
135 138
 
136 139
 		// This cannot be empty!
137 140
 		$_POST['warn_reason'] = isset($_POST['warn_reason']) ? trim($_POST['warn_reason']) : '';
138
-		if ($_POST['warn_reason'] == '' && !$context['user']['is_owner'])
139
-			$issueErrors[] = 'warning_no_reason';
141
+		if ($_POST['warn_reason'] == '' && !$context['user']['is_owner']) {
142
+					$issueErrors[] = 'warning_no_reason';
143
+		}
140 144
 		$_POST['warn_reason'] = $smcFunc['htmlspecialchars']($_POST['warn_reason']);
141 145
 
142 146
 		$_POST['warning_level'] = (int) $_POST['warning_level'];
143 147
 		$_POST['warning_level'] = max(0, min(100, $_POST['warning_level']));
144
-		if ($_POST['warning_level'] < $context['min_allowed'])
145
-			$_POST['warning_level'] = $context['min_allowed'];
146
-		elseif ($_POST['warning_level'] > $context['max_allowed'])
147
-			$_POST['warning_level'] = $context['max_allowed'];
148
+		if ($_POST['warning_level'] < $context['min_allowed']) {
149
+					$_POST['warning_level'] = $context['min_allowed'];
150
+		} elseif ($_POST['warning_level'] > $context['max_allowed']) {
151
+					$_POST['warning_level'] = $context['max_allowed'];
152
+		}
148 153
 
149 154
 		// Do we actually have to issue them with a PM?
150 155
 		$id_notice = 0;
@@ -152,8 +157,9 @@  discard block
 block discarded – undo
152 157
 		{
153 158
 			$_POST['warn_sub'] = trim($_POST['warn_sub']);
154 159
 			$_POST['warn_body'] = trim($_POST['warn_body']);
155
-			if (empty($_POST['warn_sub']) || empty($_POST['warn_body']))
156
-				$issueErrors[] = 'warning_notify_blank';
160
+			if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) {
161
+							$issueErrors[] = 'warning_notify_blank';
162
+			}
157 163
 			// Send the PM?
158 164
 			else
159 165
 			{
@@ -190,8 +196,8 @@  discard block
 block discarded – undo
190 196
 		if (empty($issueErrors))
191 197
 		{
192 198
 			// Log what we've done!
193
-			if (!$context['user']['is_owner'])
194
-				$smcFunc['db_insert']('',
199
+			if (!$context['user']['is_owner']) {
200
+							$smcFunc['db_insert']('',
195 201
 					'{db_prefix}log_comments',
196 202
 					array(
197 203
 						'id_member' => 'int', 'member_name' => 'string', 'comment_type' => 'string', 'id_recipient' => 'int', 'recipient_name' => 'string-255',
@@ -203,14 +209,14 @@  discard block
 block discarded – undo
203 209
 					),
204 210
 					array('id_comment')
205 211
 				);
212
+			}
206 213
 
207 214
 			// Make the change.
208 215
 			updateMemberData($memID, array('warning' => $_POST['warning_level']));
209 216
 
210 217
 			// Leave a lovely message.
211 218
 			$context['profile_updated'] = $context['user']['is_owner'] ? $txt['profile_updated_own'] : $txt['profile_warning_success'];
212
-		}
213
-		else
219
+		} else
214 220
 		{
215 221
 			// Try to remember some bits.
216 222
 			$context['warning_data'] = array(
@@ -229,8 +235,9 @@  discard block
 block discarded – undo
229 235
 	{
230 236
 		$warning_body = !empty($_POST['warn_body']) ? trim(censorText($_POST['warn_body'])) : '';
231 237
 		$context['preview_subject'] = !empty($_POST['warn_sub']) ? trim($smcFunc['htmlspecialchars']($_POST['warn_sub'])) : '';
232
-		if (empty($_POST['warn_sub']) || empty($_POST['warn_body']))
233
-			$issueErrors[] = 'warning_notify_blank';
238
+		if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) {
239
+					$issueErrors[] = 'warning_notify_blank';
240
+		}
234 241
 
235 242
 		if (!empty($_POST['warn_body']))
236 243
 		{
@@ -254,8 +261,9 @@  discard block
 block discarded – undo
254 261
 	{
255 262
 		// Fill in the suite of errors.
256 263
 		$context['post_errors'] = array();
257
-		foreach ($issueErrors as $error)
258
-			$context['post_errors'][] = $txt[$error];
264
+		foreach ($issueErrors as $error) {
265
+					$context['post_errors'][] = $txt[$error];
266
+		}
259 267
 	}
260 268
 
261 269
 
@@ -272,9 +280,10 @@  discard block
 block discarded – undo
272 280
 		$modSettings['warning_mute'] => $txt['profile_warning_effect_mute'],
273 281
 	);
274 282
 	$context['current_level'] = 0;
275
-	foreach ($context['level_effects'] as $limit => $dummy)
276
-		if ($context['member']['warning'] >= $limit)
283
+	foreach ($context['level_effects'] as $limit => $dummy) {
284
+			if ($context['member']['warning'] >= $limit)
277 285
 			$context['current_level'] = $limit;
286
+	}
278 287
 
279 288
 	$listOptions = array(
280 289
 		'id' => 'view_warnings',
@@ -337,11 +346,12 @@  discard block
 block discarded – undo
337 346
 							' . $warning['reason'] . '
338 347
 						</div>';
339 348
 
340
-						if (!empty($warning['id_notice']))
341
-							$ret .= '
349
+						if (!empty($warning['id_notice'])) {
350
+													$ret .= '
342 351
 						<div class="floatright">
343 352
 							<a href="' . $scripturl . '?action=moderate;area=notice;nid=' . $warning['id_notice'] . '" onclick="window.open(this.href, \'\', \'scrollbars=yes,resizable=yes,width=400,height=250\');return false;" target="_blank" class="new_win" title="' . $txt['profile_warning_previous_notice'] . '"><span class="generic_icons filter centericon"></span></a>
344 353
 						</div>';
354
+						}
345 355
 
346 356
 						return $ret;
347 357
 					},
@@ -413,8 +423,9 @@  discard block
 block discarded – undo
413 423
 	while ($row = $smcFunc['db_fetch_assoc']($request))
414 424
 	{
415 425
 		// If we're not warning for a message skip any that are.
416
-		if (!$context['warning_for_message'] && strpos($row['body'], '{MESSAGE}') !== false)
417
-			continue;
426
+		if (!$context['warning_for_message'] && strpos($row['body'], '{MESSAGE}') !== false) {
427
+					continue;
428
+		}
418 429
 
419 430
 		$context['notification_templates'][] = array(
420 431
 			'title' => $row['template_title'],
@@ -424,16 +435,18 @@  discard block
 block discarded – undo
424 435
 	$smcFunc['db_free_result']($request);
425 436
 
426 437
 	// Setup the "default" templates.
427
-	foreach (array('spamming', 'offence', 'insulting') as $type)
428
-		$context['notification_templates'][] = array(
438
+	foreach (array('spamming', 'offence', 'insulting') as $type) {
439
+			$context['notification_templates'][] = array(
429 440
 			'title' => $txt['profile_warning_notify_title_' . $type],
430 441
 			'body' => sprintf($txt['profile_warning_notify_template_outline' . (!empty($context['warning_for_message']) ? '_post' : '')], $txt['profile_warning_notify_for_' . $type]),
431 442
 		);
443
+	}
432 444
 
433 445
 	// Replace all the common variables in the templates.
434
-	foreach ($context['notification_templates'] as $k => $name)
435
-		$context['notification_templates'][$k]['body'] = strtr($name['body'], array('{MEMBER}' => un_htmlspecialchars($context['member']['name']), '{MESSAGE}' => '[url=' . $scripturl . '?msg=' . $context['warning_for_message'] . ']' . un_htmlspecialchars($context['warned_message_subject']) . '[/url]', '{SCRIPTURL}' => $scripturl, '{FORUMNAME}' => $mbname, '{REGARDS}' => $txt['regards_team']));
436
-}
446
+	foreach ($context['notification_templates'] as $k => $name) {
447
+			$context['notification_templates'][$k]['body'] = strtr($name['body'], array('{MEMBER}' => un_htmlspecialchars($context['member']['name']), '{MESSAGE}' => '[url=' . $scripturl . '?msg=' . $context['warning_for_message'] . ']' . un_htmlspecialchars($context['warned_message_subject']) . '[/url]', '{SCRIPTURL}' => $scripturl, '{FORUMNAME}' => $mbname, '{REGARDS}' => $txt['regards_team']));
448
+	}
449
+	}
437 450
 
438 451
 /**
439 452
  * Get the number of warnings a user has. Callback for $listOptions['get_count'] in issueWarning()
@@ -517,10 +530,11 @@  discard block
 block discarded – undo
517 530
 {
518 531
 	global $txt, $context, $modSettings, $cur_profile;
519 532
 
520
-	if (!$context['user']['is_owner'])
521
-		isAllowedTo('profile_remove_any');
522
-	elseif (!allowedTo('profile_remove_any'))
523
-		isAllowedTo('profile_remove_own');
533
+	if (!$context['user']['is_owner']) {
534
+			isAllowedTo('profile_remove_any');
535
+	} elseif (!allowedTo('profile_remove_any')) {
536
+			isAllowedTo('profile_remove_own');
537
+	}
524 538
 
525 539
 	// Permissions for removing stuff...
526 540
 	$context['can_delete_posts'] = !$context['user']['is_owner'] && allowedTo('moderate_forum');
@@ -547,10 +561,11 @@  discard block
 block discarded – undo
547 561
 
548 562
 	// @todo Add a way to delete pms as well?
549 563
 
550
-	if (!$context['user']['is_owner'])
551
-		isAllowedTo('profile_remove_any');
552
-	elseif (!allowedTo('profile_remove_any'))
553
-		isAllowedTo('profile_remove_own');
564
+	if (!$context['user']['is_owner']) {
565
+			isAllowedTo('profile_remove_any');
566
+	} elseif (!allowedTo('profile_remove_any')) {
567
+			isAllowedTo('profile_remove_own');
568
+	}
554 569
 
555 570
 	checkSession();
556 571
 
@@ -576,8 +591,9 @@  discard block
 block discarded – undo
576 591
 		list ($another) = $smcFunc['db_fetch_row']($request);
577 592
 		$smcFunc['db_free_result']($request);
578 593
 
579
-		if (empty($another))
580
-			fatal_lang_error('at_least_one_admin', 'critical');
594
+		if (empty($another)) {
595
+					fatal_lang_error('at_least_one_admin', 'critical');
596
+		}
581 597
 	}
582 598
 
583 599
 	// This file is needed for the deleteMembers function.
@@ -656,8 +672,9 @@  discard block
 block discarded – undo
656 672
 					)
657 673
 				);
658 674
 				$topicIDs = array();
659
-				while ($row = $smcFunc['db_fetch_assoc']($request))
660
-					$topicIDs[] = $row['id_topic'];
675
+				while ($row = $smcFunc['db_fetch_assoc']($request)) {
676
+									$topicIDs[] = $row['id_topic'];
677
+				}
661 678
 				$smcFunc['db_free_result']($request);
662 679
 
663 680
 				// Actually remove the topics. Ignore recycling if we want to perma-delete things...
@@ -680,8 +697,9 @@  discard block
 block discarded – undo
680 697
 			// This could take a while... but ya know it's gonna be worth it in the end.
681 698
 			while ($row = $smcFunc['db_fetch_assoc']($request))
682 699
 			{
683
-				if (function_exists('apache_reset_timeout'))
684
-					@apache_reset_timeout();
700
+				if (function_exists('apache_reset_timeout')) {
701
+									@apache_reset_timeout();
702
+				}
685 703
 
686 704
 				removeMessage($row['id_msg']);
687 705
 			}
@@ -689,8 +707,9 @@  discard block
 block discarded – undo
689 707
 		}
690 708
 
691 709
 		// Only delete this poor members account if they are actually being booted out of camp.
692
-		if (isset($_POST['deleteAccount']))
693
-			deleteMembers($memID);
710
+		if (isset($_POST['deleteAccount'])) {
711
+					deleteMembers($memID);
712
+		}
694 713
 	}
695 714
 	// Do they need approval to delete?
696 715
 	elseif (!empty($modSettings['approveAccountDeletion']) && !allowedTo('moderate_forum'))
@@ -741,18 +760,18 @@  discard block
 block discarded – undo
741 760
 		{
742 761
 			foreach ($costs as $duration => $cost)
743 762
 			{
744
-				if ($cost != 0)
745
-					$cost_array[$duration] = $cost;
763
+				if ($cost != 0) {
764
+									$cost_array[$duration] = $cost;
765
+				}
746 766
 			}
747
-		}
748
-		else
767
+		} else
749 768
 		{
750 769
 			$cost_array['fixed'] = $costs['fixed'];
751 770
 		}
752 771
 
753
-		if (empty($cost_array))
754
-			unset($context['subscriptions'][$id]);
755
-		else
772
+		if (empty($cost_array)) {
773
+					unset($context['subscriptions'][$id]);
774
+		} else
756 775
 		{
757 776
 			$context['subscriptions'][$id]['member'] = 0;
758 777
 			$context['subscriptions'][$id]['subscribed'] = false;
@@ -765,13 +784,15 @@  discard block
 block discarded – undo
765 784
 	foreach ($gateways as $id => $gateway)
766 785
 	{
767 786
 		$gateways[$id] = new $gateway['display_class']();
768
-		if (!$gateways[$id]->gatewayEnabled())
769
-			unset($gateways[$id]);
787
+		if (!$gateways[$id]->gatewayEnabled()) {
788
+					unset($gateways[$id]);
789
+		}
770 790
 	}
771 791
 
772 792
 	// No gateways yet?
773
-	if (empty($gateways))
774
-		fatal_error($txt['paid_admin_not_setup_gateway']);
793
+	if (empty($gateways)) {
794
+			fatal_error($txt['paid_admin_not_setup_gateway']);
795
+	}
775 796
 
776 797
 	// Get the current subscriptions.
777 798
 	$request = $smcFunc['db_query']('', '
@@ -786,8 +807,9 @@  discard block
 block discarded – undo
786 807
 	while ($row = $smcFunc['db_fetch_assoc']($request))
787 808
 	{
788 809
 		// The subscription must exist!
789
-		if (!isset($context['subscriptions'][$row['id_subscribe']]))
790
-			continue;
810
+		if (!isset($context['subscriptions'][$row['id_subscribe']])) {
811
+					continue;
812
+		}
791 813
 
792 814
 		$context['current'][$row['id_subscribe']] = array(
793 815
 			'id' => $row['id_sublog'],
@@ -801,8 +823,9 @@  discard block
 block discarded – undo
801 823
 			'status_text' => $row['status'] == 0 ? ($row['payments_pending'] ? $txt['paid_pending'] : $txt['paid_finished']) : $txt['paid_active'],
802 824
 		);
803 825
 
804
-		if ($row['status'] == 1)
805
-			$context['subscriptions'][$row['id_subscribe']]['subscribed'] = true;
826
+		if ($row['status'] == 1) {
827
+					$context['subscriptions'][$row['id_subscribe']]['subscribed'] = true;
828
+		}
806 829
 	}
807 830
 	$smcFunc['db_free_result']($request);
808 831
 
@@ -853,21 +876,25 @@  discard block
 block discarded – undo
853 876
 	if (isset($_GET['confirm']) && isset($_POST['sub_id']) && is_array($_POST['sub_id']))
854 877
 	{
855 878
 		// Hopefully just one.
856
-		foreach ($_POST['sub_id'] as $k => $v)
857
-			$ID_SUB = (int) $k;
879
+		foreach ($_POST['sub_id'] as $k => $v) {
880
+					$ID_SUB = (int) $k;
881
+		}
858 882
 
859
-		if (!isset($context['subscriptions'][$ID_SUB]) || $context['subscriptions'][$ID_SUB]['active'] == 0)
860
-			fatal_lang_error('paid_sub_not_active');
883
+		if (!isset($context['subscriptions'][$ID_SUB]) || $context['subscriptions'][$ID_SUB]['active'] == 0) {
884
+					fatal_lang_error('paid_sub_not_active');
885
+		}
861 886
 
862 887
 		// Simplify...
863 888
 		$context['sub'] = $context['subscriptions'][$ID_SUB];
864 889
 		$period = 'xx';
865
-		if ($context['sub']['flexible'])
866
-			$period = isset($_POST['cur'][$ID_SUB]) && isset($context['sub']['costs'][$_POST['cur'][$ID_SUB]]) ? $_POST['cur'][$ID_SUB] : 'xx';
890
+		if ($context['sub']['flexible']) {
891
+					$period = isset($_POST['cur'][$ID_SUB]) && isset($context['sub']['costs'][$_POST['cur'][$ID_SUB]]) ? $_POST['cur'][$ID_SUB] : 'xx';
892
+		}
867 893
 
868 894
 		// Check we have a valid cost.
869
-		if ($context['sub']['flexible'] && $period == 'xx')
870
-			fatal_lang_error('paid_sub_not_active');
895
+		if ($context['sub']['flexible'] && $period == 'xx') {
896
+					fatal_lang_error('paid_sub_not_active');
897
+		}
871 898
 
872 899
 		// Sort out the cost/currency.
873 900
 		$context['currency'] = $modSettings['paid_currency_code'];
@@ -880,8 +907,7 @@  discard block
 block discarded – undo
880 907
 			$context['cost'] = sprintf($modSettings['paid_currency_symbol'], $context['value']) . '/' . $txt[$_POST['cur'][$ID_SUB]];
881 908
 			// The period value for paypal.
882 909
 			$context['paypal_period'] = strtoupper(substr($_POST['cur'][$ID_SUB], 0, 1));
883
-		}
884
-		else
910
+		} else
885 911
 		{
886 912
 			// Real cost...
887 913
 			$context['value'] = $context['sub']['costs']['fixed'];
@@ -898,13 +924,15 @@  discard block
 block discarded – undo
898 924
 		foreach ($gateways as $id => $gateway)
899 925
 		{
900 926
 			$fields = $gateways[$id]->fetchGatewayFields($context['sub']['id'] . '+' . $memID, $context['sub'], $context['value'], $period, $scripturl . '?action=profile;u=' . $memID . ';area=subscriptions;sub_id=' . $context['sub']['id'] . ';done');
901
-			if (!empty($fields['form']))
902
-				$context['gateways'][] = $fields;
927
+			if (!empty($fields['form'])) {
928
+							$context['gateways'][] = $fields;
929
+			}
903 930
 		}
904 931
 
905 932
 		// Bugger?!
906
-		if (empty($context['gateways']))
907
-			fatal_error($txt['paid_admin_not_setup_gateway']);
933
+		if (empty($context['gateways'])) {
934
+					fatal_error($txt['paid_admin_not_setup_gateway']);
935
+		}
908 936
 
909 937
 		// Now we are going to assume they want to take this out ;)
910 938
 		$new_data = array($context['sub']['id'], $context['value'], $period, 'prepay');
@@ -912,16 +940,19 @@  discard block
 block discarded – undo
912 940
 		{
913 941
 			// What are the details like?
914 942
 			$current_pending = array();
915
-			if ($context['current'][$context['sub']['id']]['pending_details'] != '')
916
-				$current_pending = smf_json_decode($context['current'][$context['sub']['id']]['pending_details'], true);
943
+			if ($context['current'][$context['sub']['id']]['pending_details'] != '') {
944
+							$current_pending = smf_json_decode($context['current'][$context['sub']['id']]['pending_details'], true);
945
+			}
917 946
 			// Don't get silly.
918
-			if (count($current_pending) > 9)
919
-				$current_pending = array();
947
+			if (count($current_pending) > 9) {
948
+							$current_pending = array();
949
+			}
920 950
 			$pending_count = 0;
921 951
 			// Only record real pending payments as will otherwise confuse the admin!
922
-			foreach ($current_pending as $pending)
923
-				if ($pending[3] == 'payback')
952
+			foreach ($current_pending as $pending) {
953
+							if ($pending[3] == 'payback')
924 954
 					$pending_count++;
955
+			}
925 956
 
926 957
 			if (!in_array($new_data, $current_pending))
927 958
 			{
@@ -966,9 +997,9 @@  discard block
 block discarded – undo
966 997
 
967 998
 		// Quit.
968 999
 		return;
1000
+	} else {
1001
+			$context['sub_template'] = 'user_subscription';
1002
+	}
969 1003
 	}
970
-	else
971
-		$context['sub_template'] = 'user_subscription';
972
-}
973 1004
 
974 1005
 ?>
975 1006
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/Themes.php 1 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})');
@@ -578,13 +590,13 @@  discard block
 block discarded – undo
578 590
 			)
579 591
 		);
580 592
 		$context['theme_options'] = array();
581
-		while ($row = $smcFunc['db_fetch_assoc']($request))
582
-			$context['theme_options'][$row['variable']] = $row['value'];
593
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
594
+					$context['theme_options'][$row['variable']] = $row['value'];
595
+		}
583 596
 		$smcFunc['db_free_result']($request);
584 597
 
585 598
 		$context['theme_options_reset'] = false;
586
-	}
587
-	else
599
+	} else
588 600
 	{
589 601
 		$context['theme_options'] = array();
590 602
 		$context['theme_options_reset'] = true;
@@ -593,30 +605,32 @@  discard block
 block discarded – undo
593 605
 	foreach ($context['options'] as $i => $setting)
594 606
 	{
595 607
 		// Just skip separators
596
-		if (!is_array($setting))
597
-			continue;
608
+		if (!is_array($setting)) {
609
+					continue;
610
+		}
598 611
 
599 612
 		// Is this disabled?
600 613
 		if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled']))
601 614
 		{
602 615
 			unset($context['options'][$i]);
603 616
 			continue;
604
-		}
605
-		elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage']))
617
+		} elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage']))
606 618
 		{
607 619
 			unset($context['options'][$i]);
608 620
 			continue;
609 621
 		}
610 622
 
611
-		if (!isset($setting['type']) || $setting['type'] == 'bool')
612
-			$context['options'][$i]['type'] = 'checkbox';
613
-		elseif ($setting['type'] == 'int' || $setting['type'] == 'integer')
614
-			$context['options'][$i]['type'] = 'number';
615
-		elseif ($setting['type'] == 'string')
616
-			$context['options'][$i]['type'] = 'text';
623
+		if (!isset($setting['type']) || $setting['type'] == 'bool') {
624
+					$context['options'][$i]['type'] = 'checkbox';
625
+		} elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') {
626
+					$context['options'][$i]['type'] = 'number';
627
+		} elseif ($setting['type'] == 'string') {
628
+					$context['options'][$i]['type'] = 'text';
629
+		}
617 630
 
618
-		if (isset($setting['options']))
619
-			$context['options'][$i]['type'] = 'list';
631
+		if (isset($setting['options'])) {
632
+					$context['options'][$i]['type'] = 'list';
633
+		}
620 634
 
621 635
 		$context['options'][$i]['value'] = !isset($context['theme_options'][$setting['id']]) ? '' : $context['theme_options'][$setting['id']];
622 636
 	}
@@ -641,8 +655,9 @@  discard block
 block discarded – undo
641 655
 {
642 656
 	global $txt, $context, $settings, $modSettings, $smcFunc;
643 657
 
644
-	if (empty($_GET['th']) && empty($_GET['id']))
645
-		return ThemeAdmin();
658
+	if (empty($_GET['th']) && empty($_GET['id'])) {
659
+			return ThemeAdmin();
660
+	}
646 661
 
647 662
 	$_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id'];
648 663
 
@@ -653,8 +668,9 @@  discard block
 block discarded – undo
653 668
 	isAllowedTo('admin_forum');
654 669
 
655 670
 	// Validate inputs/user.
656
-	if (empty($_GET['th']))
657
-		fatal_lang_error('no_theme', false);
671
+	if (empty($_GET['th'])) {
672
+			fatal_lang_error('no_theme', false);
673
+	}
658 674
 
659 675
 	// Fetch the smiley sets...
660 676
 	$sets = explode(',', 'none,' . $modSettings['smiley_sets_known']);
@@ -662,8 +678,9 @@  discard block
 block discarded – undo
662 678
 	$context['smiley_sets'] = array(
663 679
 		'' => $txt['smileys_no_default']
664 680
 	);
665
-	foreach ($sets as $i => $set)
666
-		$context['smiley_sets'][$set] = $smcFunc['htmlspecialchars']($set_names[$i]);
681
+	foreach ($sets as $i => $set) {
682
+			$context['smiley_sets'][$set] = $smcFunc['htmlspecialchars']($set_names[$i]);
683
+	}
667 684
 
668 685
 	$old_id = $settings['theme_id'];
669 686
 	$old_settings = $settings;
@@ -688,8 +705,9 @@  discard block
 block discarded – undo
688 705
 	if (file_exists($settings['theme_dir'] . '/index.template.php'))
689 706
 	{
690 707
 		$file_contents = implode('', file($settings['theme_dir'] . '/index.template.php'));
691
-		if (preg_match('~\$settings\[\'theme_variants\'\]\s*=(.+?);~', $file_contents, $matches))
692
-				eval('global $settings;' . $matches[0]);
708
+		if (preg_match('~\$settings\[\'theme_variants\'\]\s*=(.+?);~', $file_contents, $matches)) {
709
+						eval('global $settings;' . $matches[0]);
710
+		}
693 711
 	}
694 712
 
695 713
 	// Submitting!
@@ -698,37 +716,45 @@  discard block
 block discarded – undo
698 716
 		checkSession();
699 717
 		validateToken('admin-sts');
700 718
 
701
-		if (empty($_POST['options']))
702
-			$_POST['options'] = array();
703
-		if (empty($_POST['default_options']))
704
-			$_POST['default_options'] = array();
719
+		if (empty($_POST['options'])) {
720
+					$_POST['options'] = array();
721
+		}
722
+		if (empty($_POST['default_options'])) {
723
+					$_POST['default_options'] = array();
724
+		}
705 725
 
706 726
 		// Make sure items are cast correctly.
707 727
 		foreach ($context['theme_settings'] as $item)
708 728
 		{
709 729
 			// Disregard this item if this is just a separator.
710
-			if (!is_array($item))
711
-				continue;
730
+			if (!is_array($item)) {
731
+							continue;
732
+			}
712 733
 
713 734
 			foreach (array('options', 'default_options') as $option)
714 735
 			{
715
-				if (!isset($_POST[$option][$item['id']]))
716
-					continue;
736
+				if (!isset($_POST[$option][$item['id']])) {
737
+									continue;
738
+				}
717 739
 				// Checkbox.
718
-				elseif (empty($item['type']))
719
-					$_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0;
740
+				elseif (empty($item['type'])) {
741
+									$_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0;
742
+				}
720 743
 				// Number
721
-				elseif ($item['type'] == 'number')
722
-					$_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']];
744
+				elseif ($item['type'] == 'number') {
745
+									$_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']];
746
+				}
723 747
 			}
724 748
 		}
725 749
 
726 750
 		// Set up the sql query.
727 751
 		$inserts = array();
728
-		foreach ($_POST['options'] as $opt => $val)
729
-			$inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val);
730
-		foreach ($_POST['default_options'] as $opt => $val)
731
-			$inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val);
752
+		foreach ($_POST['options'] as $opt => $val) {
753
+					$inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val);
754
+		}
755
+		foreach ($_POST['default_options'] as $opt => $val) {
756
+					$inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val);
757
+		}
732 758
 		// If we're actually inserting something..
733 759
 		if (!empty($inserts))
734 760
 		{
@@ -754,8 +780,9 @@  discard block
 block discarded – undo
754 780
 
755 781
 	foreach ($settings as $setting => $dummy)
756 782
 	{
757
-		if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs')))
758
-			$settings[$setting] = htmlspecialchars__recursive($settings[$setting]);
783
+		if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs'))) {
784
+					$settings[$setting] = htmlspecialchars__recursive($settings[$setting]);
785
+		}
759 786
 	}
760 787
 
761 788
 	$context['settings'] = $context['theme_settings'];
@@ -764,18 +791,21 @@  discard block
 block discarded – undo
764 791
 	foreach ($context['settings'] as $i => $setting)
765 792
 	{
766 793
 		// Separators are dummies, so leave them alone.
767
-		if (!is_array($setting))
768
-			continue;
794
+		if (!is_array($setting)) {
795
+					continue;
796
+		}
769 797
 
770
-		if (!isset($setting['type']) || $setting['type'] == 'bool')
771
-			$context['settings'][$i]['type'] = 'checkbox';
772
-		elseif ($setting['type'] == 'int' || $setting['type'] == 'integer')
773
-			$context['settings'][$i]['type'] = 'number';
774
-		elseif ($setting['type'] == 'string')
775
-			$context['settings'][$i]['type'] = 'text';
798
+		if (!isset($setting['type']) || $setting['type'] == 'bool') {
799
+					$context['settings'][$i]['type'] = 'checkbox';
800
+		} elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') {
801
+					$context['settings'][$i]['type'] = 'number';
802
+		} elseif ($setting['type'] == 'string') {
803
+					$context['settings'][$i]['type'] = 'text';
804
+		}
776 805
 
777
-		if (isset($setting['options']))
778
-			$context['settings'][$i]['type'] = 'list';
806
+		if (isset($setting['options'])) {
807
+					$context['settings'][$i]['type'] = 'list';
808
+		}
779 809
 
780 810
 		$context['settings'][$i]['value'] = !isset($settings[$setting['id']]) ? '' : $settings[$setting['id']];
781 811
 	}
@@ -828,8 +858,9 @@  discard block
 block discarded – undo
828 858
 	$themeID = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id'];
829 859
 
830 860
 	// You can't delete the default theme!
831
-	if ($themeID == 1)
832
-		fatal_lang_error('no_access', false);
861
+	if ($themeID == 1) {
862
+			fatal_lang_error('no_access', false);
863
+	}
833 864
 
834 865
 	$theme_info = get_single_theme($themeID);
835 866
 
@@ -837,8 +868,9 @@  discard block
 block discarded – undo
837 868
 	remove_theme($themeID);
838 869
 
839 870
 	// And remove all its files and folders too.
840
-	if (!empty($theme_info) && !empty($theme_info['theme_dir']))
841
-		remove_dir($theme_info['theme_dir']);
871
+	if (!empty($theme_info) && !empty($theme_info['theme_dir'])) {
872
+			remove_dir($theme_info['theme_dir']);
873
+	}
842 874
 
843 875
 	// Go back to the list page.
844 876
 	redirectexit('action=admin;area=theme;sa=list;' . $context['session_var'] . '=' . $context['session_id'] . ';done=removing');
@@ -863,12 +895,14 @@  discard block
 block discarded – undo
863 895
 	$enableThemes = explode(',', $modSettings['enableThemes']);
864 896
 
865 897
 	// Are we disabling it?
866
-	if (isset($_GET['disabled']))
867
-		$enableThemes = array_diff($enableThemes, array($themeID));
898
+	if (isset($_GET['disabled'])) {
899
+			$enableThemes = array_diff($enableThemes, array($themeID));
900
+	}
868 901
 
869 902
 	// Nope? then enable it!
870
-	else
871
-		$enableThemes[] = (string) $themeID;
903
+	else {
904
+			$enableThemes[] = (string) $themeID;
905
+	}
872 906
 
873 907
 	// Update the setting.
874 908
 	$enableThemes = strtr(implode(',', $enableThemes), array(',,' => ','));
@@ -903,18 +937,21 @@  discard block
 block discarded – undo
903 937
 
904 938
 	$_SESSION['id_theme'] = 0;
905 939
 
906
-	if (isset($_GET['id']))
907
-		$_GET['th'] = $_GET['id'];
940
+	if (isset($_GET['id'])) {
941
+			$_GET['th'] = $_GET['id'];
942
+	}
908 943
 
909 944
 	// Saving a variant cause JS doesn't work - pretend it did ;)
910 945
 	if (isset($_POST['save']))
911 946
 	{
912 947
 		// Which theme?
913
-		foreach ($_POST['save'] as $k => $v)
914
-			$_GET['th'] = (int) $k;
948
+		foreach ($_POST['save'] as $k => $v) {
949
+					$_GET['th'] = (int) $k;
950
+		}
915 951
 
916
-		if (isset($_POST['vrt'][$k]))
917
-			$_GET['vrt'] = $_POST['vrt'][$k];
952
+		if (isset($_POST['vrt'][$k])) {
953
+					$_GET['vrt'] = $_POST['vrt'][$k];
954
+		}
918 955
 	}
919 956
 
920 957
 	// Have we made a decision, or are we just browsing?
@@ -992,8 +1029,9 @@  discard block
 block discarded – undo
992 1029
 		else
993 1030
 		{
994 1031
 			// The forum's default theme is always 0 and we
995
-			if (isset($_GET['th']) && $_GET['th'] == 0)
996
-					$_GET['th'] = $modSettings['theme_guests'];
1032
+			if (isset($_GET['th']) && $_GET['th'] == 0) {
1033
+								$_GET['th'] = $modSettings['theme_guests'];
1034
+			}
997 1035
 
998 1036
 			updateMemberData((int) $_REQUEST['u'], array('id_theme' => (int) $_GET['th']));
999 1037
 
@@ -1007,8 +1045,9 @@  discard block
 block discarded – undo
1007 1045
 				);
1008 1046
 				cache_put_data('theme_settings-' . $_GET['th'] . ':' . (int) $_REQUEST['u'], null, 90);
1009 1047
 
1010
-				if ($user_info['id'] == $_REQUEST['u'])
1011
-					$_SESSION['id_variant'] = 0;
1048
+				if ($user_info['id'] == $_REQUEST['u']) {
1049
+									$_SESSION['id_variant'] = 0;
1050
+				}
1012 1051
 			}
1013 1052
 
1014 1053
 			redirectexit('action=profile;u=' . (int) $_REQUEST['u'] . ';area=theme');
@@ -1077,12 +1116,13 @@  discard block
 block discarded – undo
1077 1116
 		);
1078 1117
 		while ($row = $smcFunc['db_fetch_assoc']($request))
1079 1118
 		{
1080
-			if (!isset($context['available_themes'][$row['id_theme']]))
1081
-				$context['available_themes'][$row['id_theme']] = array(
1119
+			if (!isset($context['available_themes'][$row['id_theme']])) {
1120
+							$context['available_themes'][$row['id_theme']] = array(
1082 1121
 					'id' => $row['id_theme'],
1083 1122
 					'selected' => $context['current_theme'] == $row['id_theme'],
1084 1123
 					'num_users' => 0
1085 1124
 				);
1125
+			}
1086 1126
 			$context['available_themes'][$row['id_theme']][$row['variable']] = $row['value'];
1087 1127
 		}
1088 1128
 		$smcFunc['db_free_result']($request);
@@ -1095,9 +1135,9 @@  discard block
 block discarded – undo
1095 1135
 			'num_users' => 0
1096 1136
 		);
1097 1137
 		$guest_theme = 0;
1138
+	} else {
1139
+			$guest_theme = $modSettings['theme_guests'];
1098 1140
 	}
1099
-	else
1100
-		$guest_theme = $modSettings['theme_guests'];
1101 1141
 
1102 1142
 	$request = $smcFunc['db_query']('', '
1103 1143
 		SELECT id_theme, COUNT(*) AS the_count
@@ -1110,15 +1150,17 @@  discard block
 block discarded – undo
1110 1150
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1111 1151
 	{
1112 1152
 		// Figure out which theme it is they are REALLY using.
1113
-		if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',', $modSettings['knownThemes'])))
1114
-			$row['id_theme'] = $guest_theme;
1115
-		elseif (empty($modSettings['theme_allow']))
1116
-			$row['id_theme'] = $guest_theme;
1153
+		if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',', $modSettings['knownThemes']))) {
1154
+					$row['id_theme'] = $guest_theme;
1155
+		} elseif (empty($modSettings['theme_allow'])) {
1156
+					$row['id_theme'] = $guest_theme;
1157
+		}
1117 1158
 
1118
-		if (isset($context['available_themes'][$row['id_theme']]))
1119
-			$context['available_themes'][$row['id_theme']]['num_users'] += $row['the_count'];
1120
-		else
1121
-			$context['available_themes'][$guest_theme]['num_users'] += $row['the_count'];
1159
+		if (isset($context['available_themes'][$row['id_theme']])) {
1160
+					$context['available_themes'][$row['id_theme']]['num_users'] += $row['the_count'];
1161
+		} else {
1162
+					$context['available_themes'][$guest_theme]['num_users'] += $row['the_count'];
1163
+		}
1122 1164
 	}
1123 1165
 	$smcFunc['db_free_result']($request);
1124 1166
 
@@ -1137,8 +1179,9 @@  discard block
 block discarded – undo
1137 1179
 				'id_member' => isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? array(-1, $context['current_member']) : array(-1),
1138 1180
 			)
1139 1181
 		);
1140
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1141
-			$variant_preferences[$row['id_theme']] = $row['value'];
1182
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1183
+					$variant_preferences[$row['id_theme']] = $row['value'];
1184
+		}
1142 1185
 		$smcFunc['db_free_result']($request);
1143 1186
 	}
1144 1187
 
@@ -1149,17 +1192,18 @@  discard block
 block discarded – undo
1149 1192
 	foreach ($context['available_themes'] as $id_theme => $theme_data)
1150 1193
 	{
1151 1194
 		// Don't try to load the forum or board default theme's data... it doesn't have any!
1152
-		if ($id_theme == 0)
1153
-			continue;
1195
+		if ($id_theme == 0) {
1196
+					continue;
1197
+		}
1154 1198
 
1155 1199
 		// The thumbnail needs the correct path.
1156 1200
 		$settings['images_url'] = &$theme_data['images_url'];
1157 1201
 
1158
-		if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php'))
1159
-			include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php');
1160
-		elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php'))
1161
-			include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php');
1162
-		else
1202
+		if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php')) {
1203
+					include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php');
1204
+		} elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php')) {
1205
+					include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php');
1206
+		} else
1163 1207
 		{
1164 1208
 			$txt['theme_thumbnail_href'] = $theme_data['images_url'] . '/thumbnail.png';
1165 1209
 			$txt['theme_description'] = '';
@@ -1184,15 +1228,17 @@  discard block
 block discarded – undo
1184 1228
 					loadLanguage('Settings');
1185 1229
 
1186 1230
 					$context['available_themes'][$id_theme]['variants'] = array();
1187
-					foreach ($settings['theme_variants'] as $variant)
1188
-						$context['available_themes'][$id_theme]['variants'][$variant] = array(
1231
+					foreach ($settings['theme_variants'] as $variant) {
1232
+											$context['available_themes'][$id_theme]['variants'][$variant] = array(
1189 1233
 							'label' => isset($txt['variant_' . $variant]) ? $txt['variant_' . $variant] : $variant,
1190 1234
 							'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'),
1191 1235
 						);
1236
+					}
1192 1237
 
1193 1238
 					$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]));
1194
-					if (!isset($context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail']))
1195
-						$context['available_themes'][$id_theme]['selected_variant'] = $settings['theme_variants'][0];
1239
+					if (!isset($context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail'])) {
1240
+											$context['available_themes'][$id_theme]['selected_variant'] = $settings['theme_variants'][0];
1241
+					}
1196 1242
 
1197 1243
 					$context['available_themes'][$id_theme]['thumbnail_href'] = $context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail'];
1198 1244
 					// Allow themes to override the text.
@@ -1208,8 +1254,9 @@  discard block
 block discarded – undo
1208 1254
 	// As long as we're not doing the default theme...
1209 1255
 	if (!isset($_REQUEST['u']) || $_REQUEST['u'] >= 0)
1210 1256
 	{
1211
-		if ($guest_theme != 0)
1212
-			$context['available_themes'][0] = $context['available_themes'][$guest_theme];
1257
+		if ($guest_theme != 0) {
1258
+					$context['available_themes'][0] = $context['available_themes'][$guest_theme];
1259
+		}
1213 1260
 
1214 1261
 		$context['available_themes'][0]['id'] = 0;
1215 1262
 		$context['available_themes'][0]['name'] = $txt['theme_forum_default'];
@@ -1258,14 +1305,16 @@  discard block
 block discarded – undo
1258 1305
 		$action = $smcFunc['htmlspecialchars'](trim($_GET['do']));
1259 1306
 
1260 1307
 		// Got any info from the specific form?
1261
-		if (!isset($_POST['save_' . $action]))
1262
-			fatal_lang_error('theme_install_no_action', false);
1308
+		if (!isset($_POST['save_' . $action])) {
1309
+					fatal_lang_error('theme_install_no_action', false);
1310
+		}
1263 1311
 
1264 1312
 		validateToken('admin-t-' . $action);
1265 1313
 
1266 1314
 		// Hopefully the themes directory is writable, or we might have a problem.
1267
-		if (!is_writable($themedir))
1268
-			fatal_lang_error('theme_install_write_error', 'critical');
1315
+		if (!is_writable($themedir)) {
1316
+					fatal_lang_error('theme_install_write_error', 'critical');
1317
+		}
1269 1318
 
1270 1319
 		// Call the function and handle the result.
1271 1320
 		$result = $subActions[$action]();
@@ -1280,9 +1329,10 @@  discard block
 block discarded – undo
1280 1329
 	}
1281 1330
 
1282 1331
 	// Nope, show a nice error.
1283
-	else
1284
-		fatal_lang_error('theme_install_no_action', false);
1285
-}
1332
+	else {
1333
+			fatal_lang_error('theme_install_no_action', false);
1334
+	}
1335
+	}
1286 1336
 
1287 1337
 /**
1288 1338
  * Installs a theme from a theme package.
@@ -1298,8 +1348,9 @@  discard block
 block discarded – undo
1298 1348
 	$dirtemp = $themedir . '/temp';
1299 1349
 
1300 1350
 	// Make sure the temp dir doesn't already exist
1301
-	if (file_exists($dirtemp))
1302
-		remove_dir($dirtemp);
1351
+	if (file_exists($dirtemp)) {
1352
+			remove_dir($dirtemp);
1353
+	}
1303 1354
 
1304 1355
 	// Create the temp dir.
1305 1356
 	mkdir($dirtemp, 0777);
@@ -1311,17 +1362,20 @@  discard block
 block discarded – undo
1311 1362
 		smf_chmod($dirtemp, '0755');
1312 1363
 
1313 1364
 		// How about now?
1314
-		if (!is_writable($dirtemp))
1315
-			fatal_lang_error('theme_install_write_error', 'critical');
1365
+		if (!is_writable($dirtemp)) {
1366
+					fatal_lang_error('theme_install_write_error', 'critical');
1367
+		}
1316 1368
 	}
1317 1369
 
1318 1370
 	// This happens when the admin session is gone and the user has to login again.
1319
-	if (!isset($_FILES) || !isset($_FILES['theme_gz']) || empty($_FILES['theme_gz']))
1320
-		redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']);
1371
+	if (!isset($_FILES) || !isset($_FILES['theme_gz']) || empty($_FILES['theme_gz'])) {
1372
+			redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']);
1373
+	}
1321 1374
 
1322 1375
 	// Another error check layer, something went wrong with the upload.
1323
-	if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0)
1324
-		fatal_lang_error('theme_install_error_file_' . $_FILES['theme_gz']['error'], false);
1376
+	if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0) {
1377
+			fatal_lang_error('theme_install_error_file_' . $_FILES['theme_gz']['error'], false);
1378
+	}
1325 1379
 
1326 1380
 	// Get the theme's name.
1327 1381
 	$name = pathinfo($_FILES['theme_gz']['name'], PATHINFO_FILENAME);
@@ -1352,11 +1406,10 @@  discard block
 block discarded – undo
1352 1406
 
1353 1407
 		// return all the info.
1354 1408
 		return $context['to_install'];
1409
+	} else {
1410
+			fatal_lang_error('theme_install_error_title', false);
1411
+	}
1355 1412
 	}
1356
-
1357
-	else
1358
-		fatal_lang_error('theme_install_error_title', false);
1359
-}
1360 1413
 
1361 1414
 /**
1362 1415
  * Makes a copy from the default theme, assigns a name for it and installs it.
@@ -1370,15 +1423,17 @@  discard block
 block discarded – undo
1370 1423
 	global $forum_version;
1371 1424
 
1372 1425
 	// There's gotta be something to work with.
1373
-	if (!isset($_REQUEST['copy']) || empty($_REQUEST['copy']))
1374
-		fatal_lang_error('theme_install_error_title', false);
1426
+	if (!isset($_REQUEST['copy']) || empty($_REQUEST['copy'])) {
1427
+			fatal_lang_error('theme_install_error_title', false);
1428
+	}
1375 1429
 
1376 1430
 	// Get a cleaner version.
1377 1431
 	$name = preg_replace('~[^A-Za-z0-9_\- ]~', '', $_REQUEST['copy']);
1378 1432
 
1379 1433
 	// Is there a theme already named like this?
1380
-	if (file_exists($themedir . '/' . $name))
1381
-		fatal_lang_error('theme_install_already_dir', false);
1434
+	if (file_exists($themedir . '/' . $name)) {
1435
+			fatal_lang_error('theme_install_already_dir', false);
1436
+	}
1382 1437
 
1383 1438
 	// This is a brand new theme so set all possible values.
1384 1439
 	$context['to_install'] = array(
@@ -1398,8 +1453,9 @@  discard block
 block discarded – undo
1398 1453
 
1399 1454
 	// Buy some time.
1400 1455
 	@set_time_limit(600);
1401
-	if (function_exists('apache_reset_timeout'))
1402
-		@apache_reset_timeout();
1456
+	if (function_exists('apache_reset_timeout')) {
1457
+			@apache_reset_timeout();
1458
+	}
1403 1459
 
1404 1460
 	// Create subdirectories for css and javascript files.
1405 1461
 	mkdir($context['to_install']['theme_dir'] . '/css', 0777);
@@ -1435,12 +1491,13 @@  discard block
 block discarded – undo
1435 1491
 
1436 1492
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1437 1493
 	{
1438
-		if ($row['variable'] == 'theme_templates')
1439
-			$theme_templates = $row['value'];
1440
-		elseif ($row['variable'] == 'theme_layers')
1441
-			$theme_layers = $row['value'];
1442
-		else
1443
-			continue;
1494
+		if ($row['variable'] == 'theme_templates') {
1495
+					$theme_templates = $row['value'];
1496
+		} elseif ($row['variable'] == 'theme_layers') {
1497
+					$theme_layers = $row['value'];
1498
+		} else {
1499
+					continue;
1500
+		}
1444 1501
 	}
1445 1502
 
1446 1503
 	$smcFunc['db_free_result']($request);
@@ -1499,12 +1556,14 @@  discard block
 block discarded – undo
1499 1556
 	global $themedir, $themeurl, $context;
1500 1557
 
1501 1558
 	// Cannot use the theme dir as a theme dir.
1502
-	if (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir))
1503
-		fatal_lang_error('theme_install_invalid_dir', false);
1559
+	if (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir)) {
1560
+			fatal_lang_error('theme_install_invalid_dir', false);
1561
+	}
1504 1562
 
1505 1563
 	// Check is there is "something" on the dir.
1506
-	elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml'))
1507
-		fatal_lang_error('theme_install_error', false);
1564
+	elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml')) {
1565
+			fatal_lang_error('theme_install_error', false);
1566
+	}
1508 1567
 
1509 1568
 	$name = basename($_REQUEST['theme_dir']);
1510 1569
 	$name = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $name);
@@ -1548,24 +1607,27 @@  discard block
 block discarded – undo
1548 1607
 	}
1549 1608
 
1550 1609
 	// Any special layers?
1551
-	if (isset($settings['catch_action']['layers']))
1552
-		$context['template_layers'] = $settings['catch_action']['layers'];
1610
+	if (isset($settings['catch_action']['layers'])) {
1611
+			$context['template_layers'] = $settings['catch_action']['layers'];
1612
+	}
1553 1613
 
1554 1614
 	// Any function to call?
1555 1615
 	if (isset($settings['catch_action']['function']))
1556 1616
 	{
1557 1617
 		$hook = $settings['catch_action']['function'];
1558 1618
 
1559
-		if (!isset($settings['catch_action']['filename']))
1560
-			$settings['catch_action']['filename'] = '';
1619
+		if (!isset($settings['catch_action']['filename'])) {
1620
+					$settings['catch_action']['filename'] = '';
1621
+		}
1561 1622
 
1562 1623
 		add_integration_function('integrate_wrap_action', $hook, false, $settings['catch_action']['filename'], false);
1563 1624
 		call_integration_hook('integrate_wrap_action');
1564 1625
 	}
1565 1626
 	// And finally, the main sub template ;).
1566
-	if (isset($settings['catch_action']['sub_template']))
1567
-		$context['sub_template'] = $settings['catch_action']['sub_template'];
1568
-}
1627
+	if (isset($settings['catch_action']['sub_template'])) {
1628
+			$context['sub_template'] = $settings['catch_action']['sub_template'];
1629
+	}
1630
+	}
1569 1631
 
1570 1632
 /**
1571 1633
  * Set an option via javascript.
@@ -1584,12 +1646,14 @@  discard block
 block discarded – undo
1584 1646
 	checkSession('get');
1585 1647
 
1586 1648
 	// This good-for-nothing pixel is being used to keep the session alive.
1587
-	if (empty($_GET['var']) || !isset($_GET['val']))
1588
-		redirectexit($settings['images_url'] . '/blank.png');
1649
+	if (empty($_GET['var']) || !isset($_GET['val'])) {
1650
+			redirectexit($settings['images_url'] . '/blank.png');
1651
+	}
1589 1652
 
1590 1653
 	// Sorry, guests can't go any further than this.
1591
-	if ($user_info['is_guest'] || $user_info['id'] == 0)
1592
-		obExit(false);
1654
+	if ($user_info['is_guest'] || $user_info['id'] == 0) {
1655
+			obExit(false);
1656
+	}
1593 1657
 
1594 1658
 	$reservedVars = array(
1595 1659
 		'actual_theme_url',
@@ -1612,8 +1676,9 @@  discard block
 block discarded – undo
1612 1676
 	);
1613 1677
 
1614 1678
 	// Can't change reserved vars.
1615
-	if (in_array(strtolower($_GET['var']), $reservedVars))
1616
-		redirectexit($settings['images_url'] . '/blank.png');
1679
+	if (in_array(strtolower($_GET['var']), $reservedVars)) {
1680
+			redirectexit($settings['images_url'] . '/blank.png');
1681
+	}
1617 1682
 
1618 1683
 	// Use a specific theme?
1619 1684
 	if (isset($_GET['th']) || isset($_GET['id']))
@@ -1629,8 +1694,9 @@  discard block
 block discarded – undo
1629 1694
 	{
1630 1695
 		$options['admin_preferences'] = !empty($options['admin_preferences']) ? smf_json_decode($options['admin_preferences'], true) : array();
1631 1696
 		// New thingy...
1632
-		if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5)
1633
-			$options['admin_preferences'][$_GET['admin_key']] = $_GET['val'];
1697
+		if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5) {
1698
+					$options['admin_preferences'][$_GET['admin_key']] = $_GET['val'];
1699
+		}
1634 1700
 
1635 1701
 		// Change the value to be something nice,
1636 1702
 		$_GET['val'] = json_encode($options['admin_preferences']);
@@ -1660,8 +1726,9 @@  discard block
 block discarded – undo
1660 1726
 	global $context, $scripturl, $boarddir, $smcFunc, $txt;
1661 1727
 
1662 1728
 	// @todo Should this be removed?
1663
-	if (isset($_REQUEST['preview']))
1664
-		die('die() with fire');
1729
+	if (isset($_REQUEST['preview'])) {
1730
+			die('die() with fire');
1731
+	}
1665 1732
 
1666 1733
 	isAllowedTo('admin_forum');
1667 1734
 	loadTemplate('Themes');
@@ -1675,11 +1742,11 @@  discard block
 block discarded – undo
1675 1742
 		foreach ($context['themes'] as $key => $theme)
1676 1743
 		{
1677 1744
 			// There has to be a Settings template!
1678
-			if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css'))
1679
-				unset($context['themes'][$key]);
1680
-
1681
-			else
1682
-				$context['themes'][$key]['can_edit_style'] = file_exists($theme['theme_dir'] . '/css/index.css');
1745
+			if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css')) {
1746
+							unset($context['themes'][$key]);
1747
+			} else {
1748
+							$context['themes'][$key]['can_edit_style'] = file_exists($theme['theme_dir'] . '/css/index.css');
1749
+			}
1683 1750
 		}
1684 1751
 
1685 1752
 		$context['sub_template'] = 'edit_list';
@@ -1694,22 +1761,24 @@  discard block
 block discarded – undo
1694 1761
 	$context['theme_id'] = $currentTheme['id'];
1695 1762
 	$context['browse_title'] = sprintf($txt['themeadmin_browsing_theme'], $currentTheme['name']);
1696 1763
 
1697
-	if (!file_exists($currentTheme['theme_dir'] . '/index.template.php') && !file_exists($currentTheme['theme_dir'] . '/css/index.css'))
1698
-		fatal_lang_error('theme_edit_missing', false);
1764
+	if (!file_exists($currentTheme['theme_dir'] . '/index.template.php') && !file_exists($currentTheme['theme_dir'] . '/css/index.css')) {
1765
+			fatal_lang_error('theme_edit_missing', false);
1766
+	}
1699 1767
 
1700 1768
 	if (!isset($_REQUEST['filename']))
1701 1769
 	{
1702 1770
 		if (isset($_GET['directory']))
1703 1771
 		{
1704
-			if (substr($_GET['directory'], 0, 1) == '.')
1705
-				$_GET['directory'] = '';
1706
-			else
1772
+			if (substr($_GET['directory'], 0, 1) == '.') {
1773
+							$_GET['directory'] = '';
1774
+			} else
1707 1775
 			{
1708 1776
 				$_GET['directory'] = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $_GET['directory']);
1709 1777
 
1710 1778
 				$temp = realpath($currentTheme['theme_dir'] . '/' . $_GET['directory']);
1711
-				if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir']))
1712
-					$_GET['directory'] = '';
1779
+				if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) {
1780
+									$_GET['directory'] = '';
1781
+				}
1713 1782
 			}
1714 1783
 		}
1715 1784
 
@@ -1728,37 +1797,39 @@  discard block
 block discarded – undo
1728 1797
 				'href' => $scripturl . '?action=admin;area=theme;th=' . $_GET['th'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=edit;directory=' . $temp,
1729 1798
 				'size' => '',
1730 1799
 			));
1800
+		} else {
1801
+					$context['theme_files'] = get_file_listing($currentTheme['theme_dir'], '');
1731 1802
 		}
1732
-		else
1733
-			$context['theme_files'] = get_file_listing($currentTheme['theme_dir'], '');
1734 1803
 
1735 1804
 		$context['sub_template'] = 'edit_browse';
1736 1805
 
1737 1806
 		return;
1738
-	}
1739
-	else
1807
+	} else
1740 1808
 	{
1741
-		if (substr($_REQUEST['filename'], 0, 1) == '.')
1742
-			$_REQUEST['filename'] = '';
1743
-		else
1809
+		if (substr($_REQUEST['filename'], 0, 1) == '.') {
1810
+					$_REQUEST['filename'] = '';
1811
+		} else
1744 1812
 		{
1745 1813
 			$_REQUEST['filename'] = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $_REQUEST['filename']);
1746 1814
 
1747 1815
 			$temp = realpath($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']);
1748
-			if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir']))
1749
-				$_REQUEST['filename'] = '';
1816
+			if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) {
1817
+							$_REQUEST['filename'] = '';
1818
+			}
1750 1819
 		}
1751 1820
 
1752
-		if (empty($_REQUEST['filename']))
1753
-			fatal_lang_error('theme_edit_missing', false);
1821
+		if (empty($_REQUEST['filename'])) {
1822
+					fatal_lang_error('theme_edit_missing', false);
1823
+		}
1754 1824
 	}
1755 1825
 
1756 1826
 	if (isset($_POST['save']))
1757 1827
 	{
1758 1828
 		if (checkSession('post', '', false) == '' && validateToken('admin-te-' . md5($_GET['th'] . '-' . $_REQUEST['filename']), 'post', false) == true)
1759 1829
 		{
1760
-			if (is_array($_POST['entire_file']))
1761
-				$_POST['entire_file'] = implode("\n", $_POST['entire_file']);
1830
+			if (is_array($_POST['entire_file'])) {
1831
+							$_POST['entire_file'] = implode("\n", $_POST['entire_file']);
1832
+			}
1762 1833
 
1763 1834
 			$_POST['entire_file'] = rtrim(strtr($_POST['entire_file'], array("\r" => '', '   ' => "\t")));
1764 1835
 
@@ -1770,10 +1841,11 @@  discard block
 block discarded – undo
1770 1841
 				fclose($fp);
1771 1842
 
1772 1843
 				$error = @file_get_contents($currentTheme['theme_url'] . '/tmp_' . session_id() . '.php');
1773
-				if (preg_match('~ <b>(\d+)</b><br( /)?' . '>$~i', $error) != 0)
1774
-					$error_file = $currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php';
1775
-				else
1776
-					unlink($currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php');
1844
+				if (preg_match('~ <b>(\d+)</b><br( /)?' . '>$~i', $error) != 0) {
1845
+									$error_file = $currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php';
1846
+				} else {
1847
+									unlink($currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php');
1848
+				}
1777 1849
 			}
1778 1850
 
1779 1851
 			if (!isset($error_file))
@@ -1794,10 +1866,11 @@  discard block
 block discarded – undo
1794 1866
 			$context['sub_template'] = 'edit_file';
1795 1867
 
1796 1868
 			// Recycle the submitted data.
1797
-			if (is_array($_POST['entire_file']))
1798
-				$context['entire_file'] = $smcFunc['htmlspecialchars'](implode("\n", $_POST['entire_file']));
1799
-			else
1800
-				$context['entire_file'] = $smcFunc['htmlspecialchars']($_POST['entire_file']);
1869
+			if (is_array($_POST['entire_file'])) {
1870
+							$context['entire_file'] = $smcFunc['htmlspecialchars'](implode("\n", $_POST['entire_file']));
1871
+			} else {
1872
+							$context['entire_file'] = $smcFunc['htmlspecialchars']($_POST['entire_file']);
1873
+			}
1801 1874
 
1802 1875
 			$context['edit_filename'] = $smcFunc['htmlspecialchars']($_POST['filename']);
1803 1876
 
@@ -1820,17 +1893,17 @@  discard block
 block discarded – undo
1820 1893
 		$context['sub_template'] = 'edit_style';
1821 1894
 
1822 1895
 		$context['entire_file'] = $smcFunc['htmlspecialchars'](strtr(file_get_contents($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']), array("\t" => '   ')));
1823
-	}
1824
-	elseif (substr($_REQUEST['filename'], -13) == '.template.php')
1896
+	} elseif (substr($_REQUEST['filename'], -13) == '.template.php')
1825 1897
 	{
1826 1898
 		$context['sub_template'] = 'edit_template';
1827 1899
 
1828
-		if (!isset($error_file))
1829
-			$file_data = file($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']);
1830
-		else
1900
+		if (!isset($error_file)) {
1901
+					$file_data = file($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']);
1902
+		} else
1831 1903
 		{
1832
-			if (preg_match('~(<b>.+?</b>:.+?<b>).+?(</b>.+?<b>\d+</b>)<br( /)?' . '>$~i', $error, $match) != 0)
1833
-				$context['parse_error'] = $match[1] . $_REQUEST['filename'] . $match[2];
1904
+			if (preg_match('~(<b>.+?</b>:.+?<b>).+?(</b>.+?<b>\d+</b>)<br( /)?' . '>$~i', $error, $match) != 0) {
1905
+							$context['parse_error'] = $match[1] . $_REQUEST['filename'] . $match[2];
1906
+			}
1834 1907
 			$file_data = file($error_file);
1835 1908
 			unlink($error_file);
1836 1909
 		}
@@ -1844,8 +1917,9 @@  discard block
 block discarded – undo
1844 1917
 				// Try to format the functions a little nicer...
1845 1918
 				$context['file_parts'][$j]['data'] = trim($context['file_parts'][$j]['data']) . "\n";
1846 1919
 
1847
-				if (empty($context['file_parts'][$j]['lines']))
1848
-					unset($context['file_parts'][$j]);
1920
+				if (empty($context['file_parts'][$j]['lines'])) {
1921
+									unset($context['file_parts'][$j]);
1922
+				}
1849 1923
 				$context['file_parts'][++$j] = array('lines' => 0, 'line' => $i + 1, 'data' => '');
1850 1924
 			}
1851 1925
 
@@ -1854,8 +1928,7 @@  discard block
 block discarded – undo
1854 1928
 		}
1855 1929
 
1856 1930
 		$context['entire_file'] = $smcFunc['htmlspecialchars'](strtr(implode('', $file_data), array("\t" => '   ')));
1857
-	}
1858
-	else
1931
+	} else
1859 1932
 	{
1860 1933
 		$context['sub_template'] = 'edit_file';
1861 1934
 
@@ -1881,8 +1954,9 @@  discard block
 block discarded – undo
1881 1954
 
1882 1955
 	$_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id'];
1883 1956
 
1884
-	if (empty($_GET['th']))
1885
-		fatal_lang_error('theme_install_invalid_id');
1957
+	if (empty($_GET['th'])) {
1958
+			fatal_lang_error('theme_install_invalid_id');
1959
+	}
1886 1960
 
1887 1961
 	// Get the theme info.
1888 1962
 	$theme = get_single_theme($_GET['th']);
@@ -1890,25 +1964,24 @@  discard block
 block discarded – undo
1890 1964
 
1891 1965
 	if (isset($_REQUEST['template']) && preg_match('~[\./\\\\:\0]~', $_REQUEST['template']) == 0)
1892 1966
 	{
1893
-		if (file_exists($settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php'))
1894
-			$filename = $settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php';
1895
-
1896
-		else
1897
-			fatal_lang_error('no_access', false);
1967
+		if (file_exists($settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php')) {
1968
+					$filename = $settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php';
1969
+		} else {
1970
+					fatal_lang_error('no_access', false);
1971
+		}
1898 1972
 
1899 1973
 		$fp = fopen($theme['theme_dir'] . '/' . $_REQUEST['template'] . '.template.php', 'w');
1900 1974
 		fwrite($fp, file_get_contents($filename));
1901 1975
 		fclose($fp);
1902 1976
 
1903 1977
 		redirectexit('action=admin;area=theme;th=' . $context['theme_id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=copy');
1904
-	}
1905
-	elseif (isset($_REQUEST['lang_file']) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $_REQUEST['lang_file']) != 0)
1978
+	} elseif (isset($_REQUEST['lang_file']) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $_REQUEST['lang_file']) != 0)
1906 1979
 	{
1907
-		if (file_exists($settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php'))
1908
-			$filename = $settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php';
1909
-
1910
-		else
1911
-			fatal_lang_error('no_access', false);
1980
+		if (file_exists($settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php')) {
1981
+					$filename = $settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php';
1982
+		} else {
1983
+					fatal_lang_error('no_access', false);
1984
+		}
1912 1985
 
1913 1986
 		$fp = fopen($theme['theme_dir'] . '/languages/' . $_REQUEST['lang_file'] . '.php', 'w');
1914 1987
 		fwrite($fp, file_get_contents($filename));
@@ -1923,16 +1996,18 @@  discard block
 block discarded – undo
1923 1996
 	$dir = dir($settings['default_theme_dir']);
1924 1997
 	while ($entry = $dir->read())
1925 1998
 	{
1926
-		if (substr($entry, -13) == '.template.php')
1927
-			$templates[] = substr($entry, 0, -13);
1999
+		if (substr($entry, -13) == '.template.php') {
2000
+					$templates[] = substr($entry, 0, -13);
2001
+		}
1928 2002
 	}
1929 2003
 	$dir->close();
1930 2004
 
1931 2005
 	$dir = dir($settings['default_theme_dir'] . '/languages');
1932 2006
 	while ($entry = $dir->read())
1933 2007
 	{
1934
-		if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches))
1935
-			$lang_files[] = $matches[1];
2008
+		if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches)) {
2009
+					$lang_files[] = $matches[1];
2010
+		}
1936 2011
 	}
1937 2012
 	$dir->close();
1938 2013
 
@@ -1940,21 +2015,23 @@  discard block
 block discarded – undo
1940 2015
 	natcasesort($lang_files);
1941 2016
 
1942 2017
 	$context['available_templates'] = array();
1943
-	foreach ($templates as $template)
1944
-		$context['available_templates'][$template] = array(
2018
+	foreach ($templates as $template) {
2019
+			$context['available_templates'][$template] = array(
1945 2020
 			'filename' => $template . '.template.php',
1946 2021
 			'value' => $template,
1947 2022
 			'already_exists' => false,
1948 2023
 			'can_copy' => is_writable($theme['theme_dir']),
1949 2024
 		);
2025
+	}
1950 2026
 	$context['available_language_files'] = array();
1951
-	foreach ($lang_files as $file)
1952
-		$context['available_language_files'][$file] = array(
2027
+	foreach ($lang_files as $file) {
2028
+			$context['available_language_files'][$file] = array(
1953 2029
 			'filename' => $file . '.php',
1954 2030
 			'value' => $file,
1955 2031
 			'already_exists' => false,
1956 2032
 			'can_copy' => file_exists($theme['theme_dir'] . '/languages') ? is_writable($theme['theme_dir'] . '/languages') : is_writable($theme['theme_dir']),
1957 2033
 		);
2034
+	}
1958 2035
 
1959 2036
 	$dir = dir($theme['theme_dir']);
1960 2037
 	while ($entry = $dir->read())
Please login to merge, or discard this patch.
Sources/ViewQuery.php 1 patch
Braces   +34 added lines, -26 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Show the database queries for debugging
@@ -30,8 +31,9 @@  discard block
 block discarded – undo
30 31
 	global $scripturl, $settings, $context, $db_connection, $boarddir, $smcFunc, $txt, $db_show_debug;
31 32
 
32 33
 	// We should have debug mode enabled, as well as something to display!
33
-	if (!isset($db_show_debug) || $db_show_debug !== true || !isset($_SESSION['debug']))
34
-		fatal_lang_error('no_access', false);
34
+	if (!isset($db_show_debug) || $db_show_debug !== true || !isset($_SESSION['debug'])) {
35
+			fatal_lang_error('no_access', false);
36
+	}
35 37
 
36 38
 	// Don't allow except for administrators.
37 39
 	isAllowedTo('admin_forum');
@@ -41,10 +43,11 @@  discard block
 block discarded – undo
41 43
 	{
42 44
 		$_SESSION['view_queries'] = $_SESSION['view_queries'] == 1 ? 0 : 1;
43 45
 
44
-		if (strpos($_SESSION['old_url'], 'action=viewquery') !== false)
45
-			redirectexit();
46
-		else
47
-			redirectexit($_SESSION['old_url']);
46
+		if (strpos($_SESSION['old_url'], 'action=viewquery') !== false) {
47
+					redirectexit();
48
+		} else {
49
+					redirectexit($_SESSION['old_url']);
50
+		}
48 51
 	}
49 52
 
50 53
 	call_integration_hook('integrate_egg_nog');
@@ -83,26 +86,28 @@  discard block
 block discarded – undo
83 86
 		foreach ($query as $line)
84 87
 		{
85 88
 			preg_match('/^(\t*)/', $line, $temp);
86
-			if (strlen($temp[0]) < $min_indent || $min_indent == 0)
87
-				$min_indent = strlen($temp[0]);
89
+			if (strlen($temp[0]) < $min_indent || $min_indent == 0) {
90
+							$min_indent = strlen($temp[0]);
91
+			}
92
+		}
93
+		foreach ($query as $l => $dummy) {
94
+					$query[$l] = substr($dummy, $min_indent);
88 95
 		}
89
-		foreach ($query as $l => $dummy)
90
-			$query[$l] = substr($dummy, $min_indent);
91 96
 		$query_data['q'] = implode("\n", $query);
92 97
 
93 98
 		// Make the filenames look a bit better.
94
-		if (isset($query_data['f']))
95
-			$query_data['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $query_data['f']);
99
+		if (isset($query_data['f'])) {
100
+					$query_data['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $query_data['f']);
101
+		}
96 102
 
97 103
 		$is_select_query = substr(trim($query_data['q']), 0, 6) == 'SELECT';
98
-		if ($is_select_query)
99
-			$select = $query_data['q'];
100
-		elseif (preg_match('~^INSERT(?: IGNORE)? INTO \w+(?:\s+\([^)]+\))?\s+(SELECT .+)$~s', trim($query_data['q']), $matches) != 0)
104
+		if ($is_select_query) {
105
+					$select = $query_data['q'];
106
+		} elseif (preg_match('~^INSERT(?: IGNORE)? INTO \w+(?:\s+\([^)]+\))?\s+(SELECT .+)$~s', trim($query_data['q']), $matches) != 0)
101 107
 		{
102 108
 			$is_select_query = true;
103 109
 			$select = $matches[1];
104
-		}
105
-		elseif (preg_match('~^CREATE TEMPORARY TABLE .+?(SELECT .+)$~s', trim($query_data['q']), $matches) != 0)
110
+		} elseif (preg_match('~^CREATE TEMPORARY TABLE .+?(SELECT .+)$~s', trim($query_data['q']), $matches) != 0)
106 111
 		{
107 112
 			$is_select_query = true;
108 113
 			$select = $matches[1];
@@ -110,10 +115,11 @@  discard block
 block discarded – undo
110 115
 		// Temporary tables created in earlier queries are not explainable.
111 116
 		if ($is_select_query)
112 117
 		{
113
-			foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp)
114
-				if (strpos($select, $tmp) !== false)
118
+			foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) {
119
+							if (strpos($select, $tmp) !== false)
115 120
 				{
116 121
 					$is_select_query = false;
122
+			}
117 123
 					break;
118 124
 				}
119 125
 		}
@@ -124,13 +130,15 @@  discard block
 block discarded – undo
124 130
 				', nl2br(str_replace("\t", '&nbsp;&nbsp;&nbsp;', $smcFunc['htmlspecialchars']($query_data['q']))), '
125 131
 			</a><br>';
126 132
 
127
-		if (!empty($query_data['f']) && !empty($query_data['l']))
128
-			echo sprintf($txt['debug_query_in_line'], $query_data['f'], $query_data['l']);
133
+		if (!empty($query_data['f']) && !empty($query_data['l'])) {
134
+					echo sprintf($txt['debug_query_in_line'], $query_data['f'], $query_data['l']);
135
+		}
129 136
 
130
-		if (isset($query_data['s'], $query_data['t']) && isset($txt['debug_query_which_took_at']))
131
-			echo sprintf($txt['debug_query_which_took_at'], round($query_data['t'], 8), round($query_data['s'], 8));
132
-		else
133
-			echo sprintf($txt['debug_query_which_took'], round($query_data['t'], 8));
137
+		if (isset($query_data['s'], $query_data['t']) && isset($txt['debug_query_which_took_at'])) {
138
+					echo sprintf($txt['debug_query_which_took_at'], round($query_data['t'], 8), round($query_data['s'], 8));
139
+		} else {
140
+					echo sprintf($txt['debug_query_which_took'], round($query_data['t'], 8));
141
+		}
134 142
 
135 143
 		echo '
136 144
 		</div>';
Please login to merge, or discard this patch.
Sources/ManagePermissions.php 1 patch
Braces   +312 added lines, -223 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Dispatches to the right function based on the given subaction.
@@ -176,8 +177,9 @@  discard block
 block discarded – undo
176 177
 		// If it's inherited, just add it as a child.
177 178
 		if ($row['id_parent'] != -2)
178 179
 		{
179
-			if (isset($context['groups'][$row['id_parent']]))
180
-				$context['groups'][$row['id_parent']]['children'][$row['id_group']] = $row['group_name'];
180
+			if (isset($context['groups'][$row['id_parent']])) {
181
+							$context['groups'][$row['id_parent']]['children'][$row['id_group']] = $row['group_name'];
182
+			}
181 183
 			continue;
182 184
 		}
183 185
 
@@ -202,10 +204,11 @@  discard block
 block discarded – undo
202 204
 			'access' => false,
203 205
 		);
204 206
 
205
-		if ($row['min_posts'] == -1)
206
-			$normalGroups[$row['id_group']] = $row['id_group'];
207
-		else
208
-			$postGroups[$row['id_group']] = $row['id_group'];
207
+		if ($row['min_posts'] == -1) {
208
+					$normalGroups[$row['id_group']] = $row['id_group'];
209
+		} else {
210
+					$postGroups[$row['id_group']] = $row['id_group'];
211
+		}
209 212
 	}
210 213
 	$smcFunc['db_free_result']($query);
211 214
 
@@ -221,8 +224,9 @@  discard block
 block discarded – undo
221 224
 				'post_group_list' => $postGroups,
222 225
 			)
223 226
 		);
224
-		while ($row = $smcFunc['db_fetch_assoc']($query))
225
-			$context['groups'][$row['id_group']]['num_members'] += $row['num_members'];
227
+		while ($row = $smcFunc['db_fetch_assoc']($query)) {
228
+					$context['groups'][$row['id_group']]['num_members'] += $row['num_members'];
229
+		}
226 230
 		$smcFunc['db_free_result']($query);
227 231
 	}
228 232
 
@@ -238,8 +242,9 @@  discard block
 block discarded – undo
238 242
 				'normal_group_list' => $normalGroups,
239 243
 			)
240 244
 		);
241
-		while ($row = $smcFunc['db_fetch_assoc']($query))
242
-			$context['groups'][$row['id_group']]['num_members'] += $row['num_members'];
245
+		while ($row = $smcFunc['db_fetch_assoc']($query)) {
246
+					$context['groups'][$row['id_group']]['num_members'] += $row['num_members'];
247
+		}
243 248
 		$smcFunc['db_free_result']($query);
244 249
 
245 250
 		// This one is slower, but it's okay... careful not to count twice!
@@ -256,15 +261,17 @@  discard block
 block discarded – undo
256 261
 				'blank_string' => '',
257 262
 			)
258 263
 		);
259
-		while ($row = $smcFunc['db_fetch_assoc']($query))
260
-			$context['groups'][$row['id_group']]['num_members'] += $row['num_members'];
264
+		while ($row = $smcFunc['db_fetch_assoc']($query)) {
265
+					$context['groups'][$row['id_group']]['num_members'] += $row['num_members'];
266
+		}
261 267
 		$smcFunc['db_free_result']($query);
262 268
 	}
263 269
 
264 270
 	foreach ($context['groups'] as $id => $data)
265 271
 	{
266
-		if ($data['href'] != '')
267
-			$context['groups'][$id]['link'] = '<a href="' . $data['href'] . '">' . $data['num_members'] . '</a>';
272
+		if ($data['href'] != '') {
273
+					$context['groups'][$id]['link'] = '<a href="' . $data['href'] . '">' . $data['num_members'] . '</a>';
274
+		}
268 275
 	}
269 276
 
270 277
 	if (empty($_REQUEST['pid']))
@@ -278,9 +285,10 @@  discard block
 block discarded – undo
278 285
 				'hidden_permissions' => !empty($context['hidden_permissions']) ? $context['hidden_permissions'] : array(),
279 286
 			)
280 287
 		);
281
-		while ($row = $smcFunc['db_fetch_assoc']($request))
282
-			if (isset($context['groups'][(int) $row['id_group']]) && (!empty($row['add_deny']) || $row['id_group'] != -1))
288
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
289
+					if (isset($context['groups'][(int) $row['id_group']]) && (!empty($row['add_deny']) || $row['id_group'] != -1))
283 290
 				$context['groups'][(int) $row['id_group']]['num_permissions'][empty($row['add_deny']) ? 'denied' : 'allowed'] = $row['num_permissions'];
291
+		}
284 292
 		$smcFunc['db_free_result']($request);
285 293
 
286 294
 		// Get the "default" profile permissions too.
@@ -297,17 +305,18 @@  discard block
 block discarded – undo
297 305
 		);
298 306
 		while ($row = $smcFunc['db_fetch_assoc']($request))
299 307
 		{
300
-			if (isset($context['groups'][(int) $row['id_group']]) && (!empty($row['add_deny']) || $row['id_group'] != -1))
301
-				$context['groups'][(int) $row['id_group']]['num_permissions'][empty($row['add_deny']) ? 'denied' : 'allowed'] += $row['num_permissions'];
308
+			if (isset($context['groups'][(int) $row['id_group']]) && (!empty($row['add_deny']) || $row['id_group'] != -1)) {
309
+							$context['groups'][(int) $row['id_group']]['num_permissions'][empty($row['add_deny']) ? 'denied' : 'allowed'] += $row['num_permissions'];
310
+			}
302 311
 		}
303 312
 		$smcFunc['db_free_result']($request);
304
-	}
305
-	else
313
+	} else
306 314
 	{
307 315
 		$_REQUEST['pid'] = (int) $_REQUEST['pid'];
308 316
 
309
-		if (!isset($context['profiles'][$_REQUEST['pid']]))
310
-			fatal_lang_error('no_access', false);
317
+		if (!isset($context['profiles'][$_REQUEST['pid']])) {
318
+					fatal_lang_error('no_access', false);
319
+		}
311 320
 
312 321
 		// Change the selected tab to better reflect that this really is a board profile.
313 322
 		$context[$context['admin_menu_name']]['current_subsection'] = 'profiles';
@@ -323,8 +332,9 @@  discard block
 block discarded – undo
323 332
 		);
324 333
 		while ($row = $smcFunc['db_fetch_assoc']($request))
325 334
 		{
326
-			if (isset($context['groups'][(int) $row['id_group']]) && (!empty($row['add_deny']) || $row['id_group'] != -1))
327
-				$context['groups'][(int) $row['id_group']]['num_permissions'][empty($row['add_deny']) ? 'denied' : 'allowed'] += $row['num_permissions'];
335
+			if (isset($context['groups'][(int) $row['id_group']]) && (!empty($row['add_deny']) || $row['id_group'] != -1)) {
336
+							$context['groups'][(int) $row['id_group']]['num_permissions'][empty($row['add_deny']) ? 'denied' : 'allowed'] += $row['num_permissions'];
337
+			}
328 338
 		}
329 339
 		$smcFunc['db_free_result']($request);
330 340
 
@@ -366,8 +376,8 @@  discard block
 block discarded – undo
366 376
 
367 377
 		if (!empty($changes))
368 378
 		{
369
-			foreach ($changes as $profile => $boards)
370
-				$smcFunc['db_query']('', '
379
+			foreach ($changes as $profile => $boards) {
380
+							$smcFunc['db_query']('', '
371 381
 					UPDATE {db_prefix}boards
372 382
 					SET id_profile = {int:current_profile}
373 383
 					WHERE id_board IN ({array_int:board_list})',
@@ -376,6 +386,7 @@  discard block
 block discarded – undo
376 386
 						'current_profile' => $profile,
377 387
 					)
378 388
 				);
389
+			}
379 390
 		}
380 391
 
381 392
 		$context['edit_all'] = false;
@@ -400,8 +411,9 @@  discard block
 block discarded – undo
400 411
 		);
401 412
 		foreach ($boardList[$catid] as $boardid)
402 413
 		{
403
-			if (!isset($context['profiles'][$boards[$boardid]['profile']]))
404
-				$boards[$boardid]['profile'] = 1;
414
+			if (!isset($context['profiles'][$boards[$boardid]['profile']])) {
415
+							$boards[$boardid]['profile'] = 1;
416
+			}
405 417
 
406 418
 			$context['categories'][$catid]['boards'][$boardid] = array(
407 419
 				'id' => &$boards[$boardid]['id'],
@@ -433,64 +445,74 @@  discard block
 block discarded – undo
433 445
 	loadIllegalGuestPermissions();
434 446
 
435 447
 	// Make sure only one of the quick options was selected.
436
-	if ((!empty($_POST['predefined']) && ((isset($_POST['copy_from']) && $_POST['copy_from'] != 'empty') || !empty($_POST['permissions']))) || (!empty($_POST['copy_from']) && $_POST['copy_from'] != 'empty' && !empty($_POST['permissions'])))
437
-		fatal_lang_error('permissions_only_one_option', false);
448
+	if ((!empty($_POST['predefined']) && ((isset($_POST['copy_from']) && $_POST['copy_from'] != 'empty') || !empty($_POST['permissions']))) || (!empty($_POST['copy_from']) && $_POST['copy_from'] != 'empty' && !empty($_POST['permissions']))) {
449
+			fatal_lang_error('permissions_only_one_option', false);
450
+	}
438 451
 
439
-	if (empty($_POST['group']) || !is_array($_POST['group']))
440
-		$_POST['group'] = array();
452
+	if (empty($_POST['group']) || !is_array($_POST['group'])) {
453
+			$_POST['group'] = array();
454
+	}
441 455
 
442 456
 	// Only accept numeric values for selected membergroups.
443
-	foreach ($_POST['group'] as $id => $group_id)
444
-		$_POST['group'][$id] = (int) $group_id;
457
+	foreach ($_POST['group'] as $id => $group_id) {
458
+			$_POST['group'][$id] = (int) $group_id;
459
+	}
445 460
 	$_POST['group'] = array_unique($_POST['group']);
446 461
 
447
-	if (empty($_REQUEST['pid']))
448
-		$_REQUEST['pid'] = 0;
449
-	else
450
-		$_REQUEST['pid'] = (int) $_REQUEST['pid'];
462
+	if (empty($_REQUEST['pid'])) {
463
+			$_REQUEST['pid'] = 0;
464
+	} else {
465
+			$_REQUEST['pid'] = (int) $_REQUEST['pid'];
466
+	}
451 467
 
452 468
 	// Fix up the old global to the new default!
453 469
 	$bid = max(1, $_REQUEST['pid']);
454 470
 
455 471
 	// No modifying the predefined profiles.
456
-	if ($_REQUEST['pid'] > 1 && $_REQUEST['pid'] < 5)
457
-		fatal_lang_error('no_access', false);
472
+	if ($_REQUEST['pid'] > 1 && $_REQUEST['pid'] < 5) {
473
+			fatal_lang_error('no_access', false);
474
+	}
458 475
 
459 476
 	// Clear out any cached authority.
460 477
 	updateSettings(array('settings_updated' => time()));
461 478
 
462 479
 	// No groups where selected.
463
-	if (empty($_POST['group']))
464
-		redirectexit('action=admin;area=permissions;pid=' . $_REQUEST['pid']);
480
+	if (empty($_POST['group'])) {
481
+			redirectexit('action=admin;area=permissions;pid=' . $_REQUEST['pid']);
482
+	}
465 483
 
466 484
 	// Set a predefined permission profile.
467 485
 	if (!empty($_POST['predefined']))
468 486
 	{
469 487
 		// Make sure it's a predefined permission set we expect.
470
-		if (!in_array($_POST['predefined'], array('restrict', 'standard', 'moderator', 'maintenance')))
471
-			redirectexit('action=admin;area=permissions;pid=' . $_REQUEST['pid']);
488
+		if (!in_array($_POST['predefined'], array('restrict', 'standard', 'moderator', 'maintenance'))) {
489
+					redirectexit('action=admin;area=permissions;pid=' . $_REQUEST['pid']);
490
+		}
472 491
 
473 492
 		foreach ($_POST['group'] as $group_id)
474 493
 		{
475
-			if (!empty($_REQUEST['pid']))
476
-				setPermissionLevel($_POST['predefined'], $group_id, $_REQUEST['pid']);
477
-			else
478
-				setPermissionLevel($_POST['predefined'], $group_id);
494
+			if (!empty($_REQUEST['pid'])) {
495
+							setPermissionLevel($_POST['predefined'], $group_id, $_REQUEST['pid']);
496
+			} else {
497
+							setPermissionLevel($_POST['predefined'], $group_id);
498
+			}
479 499
 		}
480 500
 	}
481 501
 	// Set a permission profile based on the permissions of a selected group.
482 502
 	elseif ($_POST['copy_from'] != 'empty')
483 503
 	{
484 504
 		// Just checking the input.
485
-		if (!is_numeric($_POST['copy_from']))
486
-			redirectexit('action=admin;area=permissions;pid=' . $_REQUEST['pid']);
505
+		if (!is_numeric($_POST['copy_from'])) {
506
+					redirectexit('action=admin;area=permissions;pid=' . $_REQUEST['pid']);
507
+		}
487 508
 
488 509
 		// Make sure the group we're copying to is never included.
489 510
 		$_POST['group'] = array_diff($_POST['group'], array($_POST['copy_from']));
490 511
 
491 512
 		// No groups left? Too bad.
492
-		if (empty($_POST['group']))
493
-			redirectexit('action=admin;area=permissions;pid=' . $_REQUEST['pid']);
513
+		if (empty($_POST['group'])) {
514
+					redirectexit('action=admin;area=permissions;pid=' . $_REQUEST['pid']);
515
+		}
494 516
 
495 517
 		if (empty($_REQUEST['pid']))
496 518
 		{
@@ -504,22 +526,26 @@  discard block
 block discarded – undo
504 526
 				)
505 527
 			);
506 528
 			$target_perm = array();
507
-			while ($row = $smcFunc['db_fetch_assoc']($request))
508
-				$target_perm[$row['permission']] = $row['add_deny'];
529
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
530
+							$target_perm[$row['permission']] = $row['add_deny'];
531
+			}
509 532
 			$smcFunc['db_free_result']($request);
510 533
 
511 534
 			$inserts = array();
512
-			foreach ($_POST['group'] as $group_id)
513
-				foreach ($target_perm as $perm => $add_deny)
535
+			foreach ($_POST['group'] as $group_id) {
536
+							foreach ($target_perm as $perm => $add_deny)
514 537
 				{
515 538
 					// No dodgy permissions please!
516 539
 					if (!empty($context['illegal_permissions']) && in_array($perm, $context['illegal_permissions']))
517 540
 						continue;
518
-					if ($group_id == -1 && in_array($perm, $context['non_guest_permissions']))
519
-						continue;
541
+			}
542
+					if ($group_id == -1 && in_array($perm, $context['non_guest_permissions'])) {
543
+											continue;
544
+					}
520 545
 
521
-					if ($group_id != 1 && $group_id != 3)
522
-						$inserts[] = array($perm, $group_id, $add_deny);
546
+					if ($group_id != 1 && $group_id != 3) {
547
+											$inserts[] = array($perm, $group_id, $add_deny);
548
+					}
523 549
 				}
524 550
 
525 551
 			// Delete the previous permissions...
@@ -559,17 +585,19 @@  discard block
 block discarded – undo
559 585
 			)
560 586
 		);
561 587
 		$target_perm = array();
562
-		while ($row = $smcFunc['db_fetch_assoc']($request))
563
-			$target_perm[$row['permission']] = $row['add_deny'];
588
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
589
+					$target_perm[$row['permission']] = $row['add_deny'];
590
+		}
564 591
 		$smcFunc['db_free_result']($request);
565 592
 
566 593
 		$inserts = array();
567
-		foreach ($_POST['group'] as $group_id)
568
-			foreach ($target_perm as $perm => $add_deny)
594
+		foreach ($_POST['group'] as $group_id) {
595
+					foreach ($target_perm as $perm => $add_deny)
569 596
 			{
570 597
 				// Are these for guests?
571 598
 				if ($group_id == -1 && in_array($perm, $context['non_guest_permissions']))
572 599
 					continue;
600
+		}
573 601
 
574 602
 				$inserts[] = array($perm, $group_id, $bid, $add_deny);
575 603
 			}
@@ -607,13 +635,14 @@  discard block
 block discarded – undo
607 635
 		list ($permissionType, $permission) = explode('/', $_POST['permissions']);
608 636
 
609 637
 		// Check whether our input is within expected range.
610
-		if (!in_array($_POST['add_remove'], array('add', 'clear', 'deny')) || !in_array($permissionType, array('membergroup', 'board')))
611
-			redirectexit('action=admin;area=permissions;pid=' . $_REQUEST['pid']);
638
+		if (!in_array($_POST['add_remove'], array('add', 'clear', 'deny')) || !in_array($permissionType, array('membergroup', 'board'))) {
639
+					redirectexit('action=admin;area=permissions;pid=' . $_REQUEST['pid']);
640
+		}
612 641
 
613 642
 		if ($_POST['add_remove'] == 'clear')
614 643
 		{
615
-			if ($permissionType == 'membergroup')
616
-				$smcFunc['db_query']('', '
644
+			if ($permissionType == 'membergroup') {
645
+							$smcFunc['db_query']('', '
617 646
 					DELETE FROM {db_prefix}permissions
618 647
 					WHERE id_group IN ({array_int:current_group_list})
619 648
 						AND permission = {string:current_permission}
@@ -624,8 +653,8 @@  discard block
 block discarded – undo
624 653
 						'illegal_permissions' => !empty($context['illegal_permissions']) ? $context['illegal_permissions'] : array(),
625 654
 					)
626 655
 				);
627
-			else
628
-				$smcFunc['db_query']('', '
656
+			} else {
657
+							$smcFunc['db_query']('', '
629 658
 					DELETE FROM {db_prefix}board_permissions
630 659
 					WHERE id_group IN ({array_int:current_group_list})
631 660
 						AND id_profile = {int:current_profile}
@@ -636,6 +665,7 @@  discard block
 block discarded – undo
636 665
 						'current_permission' => $permission,
637 666
 					)
638 667
 				);
668
+			}
639 669
 		}
640 670
 		// Add a permission (either 'set' or 'deny').
641 671
 		else
@@ -644,32 +674,36 @@  discard block
 block discarded – undo
644 674
 			$permChange = array();
645 675
 			foreach ($_POST['group'] as $groupID)
646 676
 			{
647
-				if ($groupID == -1 && in_array($permission, $context['non_guest_permissions']))
648
-					continue;
677
+				if ($groupID == -1 && in_array($permission, $context['non_guest_permissions'])) {
678
+									continue;
679
+				}
649 680
 
650
-				if ($permissionType == 'membergroup' && $groupID != 1 && $groupID != 3 && (empty($context['illegal_permissions']) || !in_array($permission, $context['illegal_permissions'])))
651
-					$permChange[] = array($permission, $groupID, $add_deny);
652
-				elseif ($permissionType != 'membergroup')
653
-					$permChange[] = array($permission, $groupID, $bid, $add_deny);
681
+				if ($permissionType == 'membergroup' && $groupID != 1 && $groupID != 3 && (empty($context['illegal_permissions']) || !in_array($permission, $context['illegal_permissions']))) {
682
+									$permChange[] = array($permission, $groupID, $add_deny);
683
+				} elseif ($permissionType != 'membergroup') {
684
+									$permChange[] = array($permission, $groupID, $bid, $add_deny);
685
+				}
654 686
 			}
655 687
 
656 688
 			if (!empty($permChange))
657 689
 			{
658
-				if ($permissionType == 'membergroup')
659
-					$smcFunc['db_insert']('replace',
690
+				if ($permissionType == 'membergroup') {
691
+									$smcFunc['db_insert']('replace',
660 692
 						'{db_prefix}permissions',
661 693
 						array('permission' => 'string', 'id_group' => 'int', 'add_deny' => 'int'),
662 694
 						$permChange,
663 695
 						array('permission', 'id_group')
664 696
 					);
697
+				}
665 698
 				// Board permissions go into the other table.
666
-				else
667
-					$smcFunc['db_insert']('replace',
699
+				else {
700
+									$smcFunc['db_insert']('replace',
668 701
 						'{db_prefix}board_permissions',
669 702
 						array('permission' => 'string', 'id_group' => 'int', 'id_profile' => 'int', 'add_deny' => 'int'),
670 703
 						$permChange,
671 704
 						array('permission', 'id_group', 'id_profile')
672 705
 					);
706
+				}
673 707
 			}
674 708
 		}
675 709
 
@@ -687,14 +721,16 @@  discard block
 block discarded – undo
687 721
 {
688 722
 	global $context, $txt, $smcFunc, $modSettings;
689 723
 
690
-	if (!isset($_GET['group']))
691
-		fatal_lang_error('no_access', false);
724
+	if (!isset($_GET['group'])) {
725
+			fatal_lang_error('no_access', false);
726
+	}
692 727
 
693 728
 	$context['group']['id'] = (int) $_GET['group'];
694 729
 
695 730
 	// It's not likely you'd end up here with this setting disabled.
696
-	if ($_GET['group'] == 1)
697
-		redirectexit('action=admin;area=permissions');
731
+	if ($_GET['group'] == 1) {
732
+			redirectexit('action=admin;area=permissions');
733
+	}
698 734
 
699 735
 	loadAllPermissions();
700 736
 	loadPermissionProfiles();
@@ -715,13 +751,14 @@  discard block
 block discarded – undo
715 751
 		$smcFunc['db_free_result']($result);
716 752
 
717 753
 		// Cannot edit an inherited group!
718
-		if ($parent != -2)
719
-			fatal_lang_error('cannot_edit_permissions_inherited');
754
+		if ($parent != -2) {
755
+					fatal_lang_error('cannot_edit_permissions_inherited');
756
+		}
757
+	} elseif ($context['group']['id'] == -1) {
758
+			$context['group']['name'] = $txt['membergroups_guests'];
759
+	} else {
760
+			$context['group']['name'] = $txt['membergroups_members'];
720 761
 	}
721
-	elseif ($context['group']['id'] == -1)
722
-		$context['group']['name'] = $txt['membergroups_guests'];
723
-	else
724
-		$context['group']['name'] = $txt['membergroups_members'];
725 762
 
726 763
 	$context['profile']['id'] = empty($_GET['pid']) ? 0 : (int) $_GET['pid'];
727 764
 
@@ -767,8 +804,9 @@  discard block
 block discarded – undo
767 804
 				'current_group' => $_GET['group'],
768 805
 			)
769 806
 		);
770
-		while ($row = $smcFunc['db_fetch_assoc']($result))
771
-			$permissions['membergroup'][empty($row['add_deny']) ? 'denied' : 'allowed'][] = $row['permission'];
807
+		while ($row = $smcFunc['db_fetch_assoc']($result)) {
808
+					$permissions['membergroup'][empty($row['add_deny']) ? 'denied' : 'allowed'][] = $row['permission'];
809
+		}
772 810
 		$smcFunc['db_free_result']($result);
773 811
 	}
774 812
 
@@ -783,8 +821,9 @@  discard block
 block discarded – undo
783 821
 			'current_profile' => $context['permission_type'] == 'membergroup' ? 1 : $context['profile']['id'],
784 822
 		)
785 823
 	);
786
-	while ($row = $smcFunc['db_fetch_assoc']($result))
787
-		$permissions['board'][empty($row['add_deny']) ? 'denied' : 'allowed'][] = $row['permission'];
824
+	while ($row = $smcFunc['db_fetch_assoc']($result)) {
825
+			$permissions['board'][empty($row['add_deny']) ? 'denied' : 'allowed'][] = $row['permission'];
826
+	}
788 827
 	$smcFunc['db_free_result']($result);
789 828
 
790 829
 	// Loop through each permission and set whether it's checked.
@@ -803,9 +842,9 @@  discard block
 block discarded – undo
803 842
 					{
804 843
 						$curPerm['any']['select'] = in_array($perm['id'] . '_any', $permissions[$permissionType]['allowed']) ? 'on' : (in_array($perm['id'] . '_any', $permissions[$permissionType]['denied']) ? 'deny' : 'off');
805 844
 						$curPerm['own']['select'] = in_array($perm['id'] . '_own', $permissions[$permissionType]['allowed']) ? 'on' : (in_array($perm['id'] . '_own', $permissions[$permissionType]['denied']) ? 'deny' : 'off');
845
+					} else {
846
+											$curPerm['select'] = in_array($perm['id'], $permissions[$permissionType]['denied']) ? 'deny' : (in_array($perm['id'], $permissions[$permissionType]['allowed']) ? 'on' : 'off');
806 847
 					}
807
-					else
808
-						$curPerm['select'] = in_array($perm['id'], $permissions[$permissionType]['denied']) ? 'deny' : (in_array($perm['id'], $permissions[$permissionType]['allowed']) ? 'on' : 'off');
809 848
 
810 849
 						// Keep the last value if it's hidden.
811 850
 						if ($perm['hidden'] || $permissionArray['hidden'])
@@ -822,13 +861,13 @@  discard block
 block discarded – undo
822 861
 									$perm['any']['id'],
823 862
 									$curPerm['any']['select'] == 'deny' && !empty($modSettings['permission_enable_deny']) ? 'deny' : $curPerm['any']['select'],
824 863
 								);
825
-							}
826
-							else
827
-								$context['hidden_perms'][] = array(
864
+							} else {
865
+															$context['hidden_perms'][] = array(
828 866
 									$permissionType,
829 867
 									$perm['id'],
830 868
 									$curPerm['select'] == 'deny' && !empty($modSettings['permission_enable_deny']) ? 'deny' : $curPerm['select'],
831 869
 								);
870
+							}
832 871
 						}
833 872
 				}
834 873
 			}
@@ -856,13 +895,14 @@  discard block
 block discarded – undo
856 895
 	$_GET['pid'] = (int) $_GET['pid'];
857 896
 
858 897
 	// Cannot modify predefined profiles.
859
-	if ($_GET['pid'] > 1 && $_GET['pid'] < 5)
860
-		fatal_lang_error('no_access', false);
898
+	if ($_GET['pid'] > 1 && $_GET['pid'] < 5) {
899
+			fatal_lang_error('no_access', false);
900
+	}
861 901
 
862 902
 	// Verify this isn't inherited.
863
-	if ($_GET['group'] == -1 || $_GET['group'] == 0)
864
-		$parent = -2;
865
-	else
903
+	if ($_GET['group'] == -1 || $_GET['group'] == 0) {
904
+			$parent = -2;
905
+	} else
866 906
 	{
867 907
 		$result = $smcFunc['db_query']('', '
868 908
 			SELECT id_parent
@@ -877,8 +917,9 @@  discard block
 block discarded – undo
877 917
 		$smcFunc['db_free_result']($result);
878 918
 	}
879 919
 
880
-	if ($parent != -2)
881
-		fatal_lang_error('cannot_edit_permissions_inherited');
920
+	if ($parent != -2) {
921
+			fatal_lang_error('cannot_edit_permissions_inherited');
922
+	}
882 923
 
883 924
 	$givePerms = array('membergroup' => array(), 'board' => array());
884 925
 
@@ -896,12 +937,13 @@  discard block
 block discarded – undo
896 937
 		{
897 938
 			if (is_array($perm_array))
898 939
 			{
899
-				foreach ($perm_array as $permission => $value)
900
-					if ($value == 'on' || $value == 'deny')
940
+				foreach ($perm_array as $permission => $value) {
941
+									if ($value == 'on' || $value == 'deny')
901 942
 					{
902 943
 						// Don't allow people to escalate themselves!
903 944
 						if (!empty($context['illegal_permissions']) && in_array($permission, $context['illegal_permissions']))
904 945
 							continue;
946
+				}
905 947
 
906 948
 						$givePerms[$perm_type][] = array($_GET['group'], $permission, $value == 'deny' ? 0 : 1);
907 949
 					}
@@ -946,8 +988,9 @@  discard block
 block discarded – undo
946 988
 	);
947 989
 	if (!empty($givePerms['board']))
948 990
 	{
949
-		foreach ($givePerms['board'] as $k => $v)
950
-			$givePerms['board'][$k][] = $profileid;
991
+		foreach ($givePerms['board'] as $k => $v) {
992
+					$givePerms['board'][$k][] = $profileid;
993
+		}
951 994
 		$smcFunc['db_insert']('replace',
952 995
 			'{db_prefix}board_permissions',
953 996
 			array('id_group' => 'int', 'permission' => 'string', 'add_deny' => 'int', 'id_profile' => 'int'),
@@ -988,8 +1031,9 @@  discard block
 block discarded – undo
988 1031
 
989 1032
 	call_integration_hook('integrate_modify_permission_settings', array(&$config_vars));
990 1033
 
991
-	if ($return_config)
992
-		return $config_vars;
1034
+	if ($return_config) {
1035
+			return $config_vars;
1036
+	}
993 1037
 
994 1038
 	$context['page_title'] = $txt['permission_settings_title'];
995 1039
 	$context['sub_template'] = 'show_settings';
@@ -1040,8 +1084,9 @@  discard block
 block discarded – undo
1040 1084
 					'min_posts' => -1,
1041 1085
 				)
1042 1086
 			);
1043
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1044
-				$post_groups[] = $row['id_group'];
1087
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
1088
+							$post_groups[] = $row['id_group'];
1089
+			}
1045 1090
 			$smcFunc['db_free_result']($request);
1046 1091
 
1047 1092
 			// Remove'em.
@@ -1250,16 +1295,19 @@  discard block
 block discarded – undo
1250 1295
 	// Make sure we're not granting someone too many permissions!
1251 1296
 	foreach ($groupLevels['global'][$level] as $k => $permission)
1252 1297
 	{
1253
-		if (!empty($context['illegal_permissions']) && in_array($permission, $context['illegal_permissions']))
1254
-			unset($groupLevels['global'][$level][$k]);
1298
+		if (!empty($context['illegal_permissions']) && in_array($permission, $context['illegal_permissions'])) {
1299
+					unset($groupLevels['global'][$level][$k]);
1300
+		}
1255 1301
 
1256
-		if ($group == -1 && in_array($permission, $context['non_guest_permissions']))
1257
-			unset($groupLevels['global'][$level][$k]);
1302
+		if ($group == -1 && in_array($permission, $context['non_guest_permissions'])) {
1303
+					unset($groupLevels['global'][$level][$k]);
1304
+		}
1258 1305
 	}
1259
-	if ($group == -1)
1260
-		foreach ($groupLevels['board'][$level] as $k => $permission)
1306
+	if ($group == -1) {
1307
+			foreach ($groupLevels['board'][$level] as $k => $permission)
1261 1308
 			if (in_array($permission, $context['non_guest_permissions']))
1262 1309
 				unset($groupLevels['board'][$level][$k]);
1310
+	}
1263 1311
 
1264 1312
 	// Reset all cached permissions.
1265 1313
 	updateSettings(array('settings_updated' => time()));
@@ -1269,8 +1317,9 @@  discard block
 block discarded – undo
1269 1317
 	{
1270 1318
 		$group = (int) $group;
1271 1319
 
1272
-		if (empty($groupLevels['global'][$level]))
1273
-			return;
1320
+		if (empty($groupLevels['global'][$level])) {
1321
+					return;
1322
+		}
1274 1323
 
1275 1324
 		$smcFunc['db_query']('', '
1276 1325
 			DELETE FROM {db_prefix}permissions
@@ -1292,8 +1341,9 @@  discard block
 block discarded – undo
1292 1341
 		);
1293 1342
 
1294 1343
 		$groupInserts = array();
1295
-		foreach ($groupLevels['global'][$level] as $permission)
1296
-			$groupInserts[] = array($group, $permission);
1344
+		foreach ($groupLevels['global'][$level] as $permission) {
1345
+					$groupInserts[] = array($group, $permission);
1346
+		}
1297 1347
 
1298 1348
 		$smcFunc['db_insert']('insert',
1299 1349
 			'{db_prefix}permissions',
@@ -1303,8 +1353,9 @@  discard block
 block discarded – undo
1303 1353
 		);
1304 1354
 
1305 1355
 		$boardInserts = array();
1306
-		foreach ($groupLevels['board'][$level] as $permission)
1307
-			$boardInserts[] = array(1, $group, $permission);
1356
+		foreach ($groupLevels['board'][$level] as $permission) {
1357
+					$boardInserts[] = array(1, $group, $permission);
1358
+		}
1308 1359
 
1309 1360
 		$smcFunc['db_insert']('insert',
1310 1361
 			'{db_prefix}board_permissions',
@@ -1335,8 +1386,9 @@  discard block
 block discarded – undo
1335 1386
 		if (!empty($groupLevels['board'][$level]))
1336 1387
 		{
1337 1388
 			$boardInserts = array();
1338
-			foreach ($groupLevels['board'][$level] as $permission)
1339
-				$boardInserts[] = array($profile, $group, $permission);
1389
+			foreach ($groupLevels['board'][$level] as $permission) {
1390
+							$boardInserts[] = array($profile, $group, $permission);
1391
+			}
1340 1392
 
1341 1393
 			$smcFunc['db_insert']('insert',
1342 1394
 				'{db_prefix}board_permissions',
@@ -1359,8 +1411,9 @@  discard block
 block discarded – undo
1359 1411
 			)
1360 1412
 		);
1361 1413
 
1362
-		if (empty($boardLevels[$level]))
1363
-			return;
1414
+		if (empty($boardLevels[$level])) {
1415
+					return;
1416
+		}
1364 1417
 
1365 1418
 		// Get all the groups...
1366 1419
 		$query = $smcFunc['db_query']('', '
@@ -1378,8 +1431,9 @@  discard block
 block discarded – undo
1378 1431
 			$group = $row[0];
1379 1432
 
1380 1433
 			$boardInserts = array();
1381
-			foreach ($boardLevels[$level] as $permission)
1382
-				$boardInserts[] = array($profile, $group, $permission);
1434
+			foreach ($boardLevels[$level] as $permission) {
1435
+							$boardInserts[] = array($profile, $group, $permission);
1436
+			}
1383 1437
 
1384 1438
 			$smcFunc['db_insert']('insert',
1385 1439
 				'{db_prefix}board_permissions',
@@ -1392,8 +1446,9 @@  discard block
 block discarded – undo
1392 1446
 
1393 1447
 		// Add permissions for ungrouped members.
1394 1448
 		$boardInserts = array();
1395
-		foreach ($boardLevels[$level] as $permission)
1396
-			$boardInserts[] = array($profile, 0, $permission);
1449
+		foreach ($boardLevels[$level] as $permission) {
1450
+					$boardInserts[] = array($profile, 0, $permission);
1451
+		}
1397 1452
 
1398 1453
 		$smcFunc['db_insert']('insert',
1399 1454
 				'{db_prefix}board_permissions',
@@ -1403,9 +1458,10 @@  discard block
 block discarded – undo
1403 1458
 			);
1404 1459
 	}
1405 1460
 	// $profile and $group are both null!
1406
-	else
1407
-		fatal_lang_error('no_access', false);
1408
-}
1461
+	else {
1462
+			fatal_lang_error('no_access', false);
1463
+	}
1464
+	}
1409 1465
 
1410 1466
 /**
1411 1467
  * Load permissions into $context['permissions'].
@@ -1606,15 +1662,17 @@  discard block
 block discarded – undo
1606 1662
 		foreach ($permissionList as $permission => $permissionArray)
1607 1663
 		{
1608 1664
 			// If this is a guest permission we don't do it if it's the guest group.
1609
-			if (isset($context['group']['id']) && $context['group']['id'] == -1 && in_array($permission, $context['non_guest_permissions']))
1610
-				continue;
1665
+			if (isset($context['group']['id']) && $context['group']['id'] == -1 && in_array($permission, $context['non_guest_permissions'])) {
1666
+							continue;
1667
+			}
1611 1668
 
1612 1669
 			// What groups will this permission be in?
1613 1670
 			$own_group = $permissionArray[1];
1614 1671
 
1615 1672
 			// First, Do these groups actually exist - if not add them.
1616
-			if (!isset($permissionGroups[$permissionType][$own_group]))
1617
-				$permissionGroups[$permissionType][$own_group] = true;
1673
+			if (!isset($permissionGroups[$permissionType][$own_group])) {
1674
+							$permissionGroups[$permissionType][$own_group] = true;
1675
+			}
1618 1676
 
1619 1677
 			// What column should this be located into?
1620 1678
 			$position = !in_array($own_group, $leftPermissionGroups) ? 1 : 0;
@@ -1622,8 +1680,8 @@  discard block
 block discarded – undo
1622 1680
 			// If the groups have not yet been created be sure to create them.
1623 1681
 			$bothGroups = array('own' => $own_group);
1624 1682
 
1625
-			foreach ($bothGroups as $group)
1626
-				if (!isset($context['permissions'][$permissionType]['columns'][$position][$group]))
1683
+			foreach ($bothGroups as $group) {
1684
+							if (!isset($context['permissions'][$permissionType]['columns'][$position][$group]))
1627 1685
 					$context['permissions'][$permissionType]['columns'][$position][$group] = array(
1628 1686
 						'type' => $permissionType,
1629 1687
 						'id' => $group,
@@ -1633,6 +1691,7 @@  discard block
 block discarded – undo
1633 1691
 						'hidden' => false,
1634 1692
 						'permissions' => array()
1635 1693
 					);
1694
+			}
1636 1695
 
1637 1696
 			$context['permissions'][$permissionType]['columns'][$position][$own_group]['permissions'][$permission] = array(
1638 1697
 				'id' => $permission,
@@ -1657,27 +1716,30 @@  discard block
 block discarded – undo
1657 1716
 				{
1658 1717
 					$context['hidden_permissions'][] = $permission . '_own';
1659 1718
 					$context['hidden_permissions'][] = $permission . '_any';
1719
+				} else {
1720
+									$context['hidden_permissions'][] = $permission;
1660 1721
 				}
1661
-				else
1662
-					$context['hidden_permissions'][] = $permission;
1663 1722
 			}
1664 1723
 		}
1665 1724
 		ksort($context['permissions'][$permissionType]['columns']);
1666 1725
 
1667 1726
 		// Check we don't leave any empty groups - and mark hidden ones as such.
1668
-		foreach ($context['permissions'][$permissionType]['columns'] as $column => $groups)
1669
-			foreach ($groups as $id => $group)
1727
+		foreach ($context['permissions'][$permissionType]['columns'] as $column => $groups) {
1728
+					foreach ($groups as $id => $group)
1670 1729
 			{
1671 1730
 				if (empty($group['permissions']))
1672 1731
 					unset($context['permissions'][$permissionType]['columns'][$column][$id]);
1732
+		}
1673 1733
 				else
1674 1734
 				{
1675 1735
 					$foundNonHidden = false;
1676
-					foreach ($group['permissions'] as $permission)
1677
-						if (empty($permission['hidden']))
1736
+					foreach ($group['permissions'] as $permission) {
1737
+											if (empty($permission['hidden']))
1678 1738
 							$foundNonHidden = true;
1679
-					if (!$foundNonHidden)
1680
-						$context['permissions'][$permissionType]['columns'][$column][$id]['hidden'] = true;
1739
+					}
1740
+					if (!$foundNonHidden) {
1741
+											$context['permissions'][$permissionType]['columns'][$column][$id]['hidden'] = true;
1742
+					}
1681 1743
 				}
1682 1744
 			}
1683 1745
 	}
@@ -1704,12 +1766,13 @@  discard block
 block discarded – undo
1704 1766
 	$context['can_change_permissions'] = allowedTo('manage_permissions');
1705 1767
 
1706 1768
 	// Nothing to initialize here.
1707
-	if (!$context['can_change_permissions'])
1708
-		return;
1769
+	if (!$context['can_change_permissions']) {
1770
+			return;
1771
+	}
1709 1772
 
1710 1773
 	// Load the permission settings for guests
1711
-	foreach ($permissions as $permission)
1712
-		$context[$permission] = array(
1774
+	foreach ($permissions as $permission) {
1775
+			$context[$permission] = array(
1713 1776
 			-1 => array(
1714 1777
 				'id' => -1,
1715 1778
 				'name' => $txt['membergroups_guests'],
@@ -1723,6 +1786,7 @@  discard block
 block discarded – undo
1723 1786
 				'status' => 'off',
1724 1787
 			),
1725 1788
 		);
1789
+	}
1726 1790
 
1727 1791
 	$request = $smcFunc['db_query']('', '
1728 1792
 		SELECT id_group, CASE WHEN add_deny = {int:denied} THEN {string:deny} ELSE {string:on} END AS status, permission
@@ -1736,8 +1800,9 @@  discard block
 block discarded – undo
1736 1800
 			'on' => 'on',
1737 1801
 		)
1738 1802
 	);
1739
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1740
-		$context[$row['permission']][$row['id_group']]['status'] = $row['status'];
1803
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1804
+			$context[$row['permission']][$row['id_group']]['status'] = $row['status'];
1805
+	}
1741 1806
 	$smcFunc['db_free_result']($request);
1742 1807
 
1743 1808
 	$request = $smcFunc['db_query']('', '
@@ -1758,14 +1823,15 @@  discard block
 block discarded – undo
1758 1823
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1759 1824
 	{
1760 1825
 		// Initialize each permission as being 'off' until proven otherwise.
1761
-		foreach ($permissions as $permission)
1762
-			if (!isset($context[$permission][$row['id_group']]))
1826
+		foreach ($permissions as $permission) {
1827
+					if (!isset($context[$permission][$row['id_group']]))
1763 1828
 				$context[$permission][$row['id_group']] = array(
1764 1829
 					'id' => $row['id_group'],
1765 1830
 					'name' => $row['group_name'],
1766 1831
 					'is_postgroup' => $row['min_posts'] != -1,
1767 1832
 					'status' => 'off',
1768 1833
 				);
1834
+		}
1769 1835
 
1770 1836
 		$context[$row['permission']][$row['id_group']]['status'] = empty($row['status']) ? 'deny' : ($row['status'] == 1 ? 'on' : 'off');
1771 1837
 	}
@@ -1779,8 +1845,9 @@  discard block
 block discarded – undo
1779 1845
 	{
1780 1846
 		foreach ($permissions as $permission)
1781 1847
 		{
1782
-			if (isset($context[$permission][$group]))
1783
-				unset($context[$permission][$group]);
1848
+			if (isset($context[$permission][$group])) {
1849
+							unset($context[$permission][$group]);
1850
+			}
1784 1851
 		}
1785 1852
 	}
1786 1853
 
@@ -1788,8 +1855,9 @@  discard block
 block discarded – undo
1788 1855
 	$non_guest_perms = array_intersect(str_replace(array('_any', '_own'), '', $permissions), $context['non_guest_permissions']);
1789 1856
 	foreach ($non_guest_perms as $permission)
1790 1857
 	{
1791
-		if (isset($context[$permission][-1]))
1792
-			unset($context[$permission][-1]);
1858
+		if (isset($context[$permission][-1])) {
1859
+					unset($context[$permission][-1]);
1860
+		}
1793 1861
 	}
1794 1862
 
1795 1863
 	// Create the token for the separate inline permission verification.
@@ -1824,8 +1892,9 @@  discard block
 block discarded – undo
1824 1892
 	global $context, $smcFunc;
1825 1893
 
1826 1894
 	// No permissions? Not a great deal to do here.
1827
-	if (!allowedTo('manage_permissions'))
1828
-		return;
1895
+	if (!allowedTo('manage_permissions')) {
1896
+			return;
1897
+	}
1829 1898
 
1830 1899
 	// Almighty session check, verify our ways.
1831 1900
 	checkSession();
@@ -1837,13 +1906,15 @@  discard block
 block discarded – undo
1837 1906
 	$insertRows = array();
1838 1907
 	foreach ($permissions as $permission)
1839 1908
 	{
1840
-		if (!isset($_POST[$permission]))
1841
-			continue;
1909
+		if (!isset($_POST[$permission])) {
1910
+					continue;
1911
+		}
1842 1912
 
1843 1913
 		foreach ($_POST[$permission] as $id_group => $value)
1844 1914
 		{
1845
-			if (in_array($value, array('on', 'deny')) && (empty($context['illegal_permissions']) || !in_array($permission, $context['illegal_permissions'])))
1846
-				$insertRows[] = array((int) $id_group, $permission, $value == 'on' ? 1 : 0);
1915
+			if (in_array($value, array('on', 'deny')) && (empty($context['illegal_permissions']) || !in_array($permission, $context['illegal_permissions']))) {
1916
+							$insertRows[] = array((int) $id_group, $permission, $value == 'on' ? 1 : 0);
1917
+			}
1847 1918
 		}
1848 1919
 	}
1849 1920
 
@@ -1859,13 +1930,14 @@  discard block
 block discarded – undo
1859 1930
 	);
1860 1931
 
1861 1932
 	// ...and replace them with new ones.
1862
-	if (!empty($insertRows))
1863
-		$smcFunc['db_insert']('insert',
1933
+	if (!empty($insertRows)) {
1934
+			$smcFunc['db_insert']('insert',
1864 1935
 			'{db_prefix}permissions',
1865 1936
 			array('id_group' => 'int', 'permission' => 'string', 'add_deny' => 'int'),
1866 1937
 			$insertRows,
1867 1938
 			array('id_group', 'permission')
1868 1939
 		);
1940
+	}
1869 1941
 
1870 1942
 	// Do a full child update.
1871 1943
 	updateChildPermissions(array(), -1);
@@ -1892,10 +1964,11 @@  discard block
 block discarded – undo
1892 1964
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1893 1965
 	{
1894 1966
 		// Format the label nicely.
1895
-		if (isset($txt['permissions_profile_' . $row['profile_name']]))
1896
-			$name = $txt['permissions_profile_' . $row['profile_name']];
1897
-		else
1898
-			$name = $row['profile_name'];
1967
+		if (isset($txt['permissions_profile_' . $row['profile_name']])) {
1968
+					$name = $txt['permissions_profile_' . $row['profile_name']];
1969
+		} else {
1970
+					$name = $row['profile_name'];
1971
+		}
1899 1972
 
1900 1973
 		$context['profiles'][$row['id_profile']] = array(
1901 1974
 			'id' => $row['id_profile'],
@@ -1950,17 +2023,19 @@  discard block
 block discarded – undo
1950 2023
 			)
1951 2024
 		);
1952 2025
 		$inserts = array();
1953
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1954
-			$inserts[] = array($profile_id, $row['id_group'], $row['permission'], $row['add_deny']);
2026
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
2027
+					$inserts[] = array($profile_id, $row['id_group'], $row['permission'], $row['add_deny']);
2028
+		}
1955 2029
 		$smcFunc['db_free_result']($request);
1956 2030
 
1957
-		if (!empty($inserts))
1958
-			$smcFunc['db_insert']('insert',
2031
+		if (!empty($inserts)) {
2032
+					$smcFunc['db_insert']('insert',
1959 2033
 				'{db_prefix}board_permissions',
1960 2034
 				array('id_profile' => 'int', 'id_group' => 'int', 'permission' => 'string', 'add_deny' => 'int'),
1961 2035
 				$inserts,
1962 2036
 				array('id_profile', 'id_group', 'permission')
1963 2037
 			);
2038
+		}
1964 2039
 	}
1965 2040
 	// Renaming?
1966 2041
 	elseif (isset($_POST['rename']))
@@ -1969,16 +2044,16 @@  discard block
 block discarded – undo
1969 2044
 		validateToken('admin-mpp');
1970 2045
 
1971 2046
 		// Just showing the boxes?
1972
-		if (!isset($_POST['rename_profile']))
1973
-			$context['show_rename_boxes'] = true;
1974
-		else
2047
+		if (!isset($_POST['rename_profile'])) {
2048
+					$context['show_rename_boxes'] = true;
2049
+		} else
1975 2050
 		{
1976 2051
 			foreach ($_POST['rename_profile'] as $id => $value)
1977 2052
 			{
1978 2053
 				$value = $smcFunc['htmlspecialchars']($value);
1979 2054
 
1980
-				if (trim($value) != '' && $id > 4)
1981
-					$smcFunc['db_query']('', '
2055
+				if (trim($value) != '' && $id > 4) {
2056
+									$smcFunc['db_query']('', '
1982 2057
 						UPDATE {db_prefix}permission_profiles
1983 2058
 						SET profile_name = {string:profile_name}
1984 2059
 						WHERE id_profile = {int:current_profile}',
@@ -1987,6 +2062,7 @@  discard block
 block discarded – undo
1987 2062
 							'profile_name' => $value,
1988 2063
 						)
1989 2064
 					);
2065
+				}
1990 2066
 			}
1991 2067
 		}
1992 2068
 	}
@@ -1997,9 +2073,10 @@  discard block
 block discarded – undo
1997 2073
 		validateToken('admin-mpp');
1998 2074
 
1999 2075
 		$profiles = array();
2000
-		foreach ($_POST['delete_profile'] as $profile)
2001
-			if ($profile > 4)
2076
+		foreach ($_POST['delete_profile'] as $profile) {
2077
+					if ($profile > 4)
2002 2078
 				$profiles[] = (int) $profile;
2079
+		}
2003 2080
 
2004 2081
 		// Verify it's not in use...
2005 2082
 		$request = $smcFunc['db_query']('', '
@@ -2011,8 +2088,9 @@  discard block
 block discarded – undo
2011 2088
 				'profile_list' => $profiles,
2012 2089
 			)
2013 2090
 		);
2014
-		if ($smcFunc['db_num_rows']($request) != 0)
2015
-			fatal_lang_error('no_access', false);
2091
+		if ($smcFunc['db_num_rows']($request) != 0) {
2092
+					fatal_lang_error('no_access', false);
2093
+		}
2016 2094
 		$smcFunc['db_free_result']($request);
2017 2095
 
2018 2096
 		// Oh well, delete.
@@ -2036,10 +2114,11 @@  discard block
 block discarded – undo
2036 2114
 		array(
2037 2115
 		)
2038 2116
 	);
2039
-	while ($row = $smcFunc['db_fetch_assoc']($request))
2040
-		if (isset($context['profiles'][$row['id_profile']]))
2117
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
2118
+			if (isset($context['profiles'][$row['id_profile']]))
2041 2119
 		{
2042 2120
 			$context['profiles'][$row['id_profile']]['in_use'] = true;
2121
+	}
2043 2122
 			$context['profiles'][$row['id_profile']]['boards'] = $row['board_count'];
2044 2123
 			$context['profiles'][$row['id_profile']]['boards_text'] = $row['board_count'] > 1 ? sprintf($txt['permissions_profile_used_by_many'], $row['board_count']) : $txt['permissions_profile_used_by_' . ($row['board_count'] ? 'one' : 'none')];
2045 2124
 		}
@@ -2051,8 +2130,9 @@  discard block
 block discarded – undo
2051 2130
 	{
2052 2131
 		// Can't delete special ones.
2053 2132
 		$context['profiles'][$id]['can_edit'] = isset($txt['permissions_profile_' . $profile['unformatted_name']]) ? false : true;
2054
-		if ($context['profiles'][$id]['can_edit'])
2055
-			$context['can_edit_something'] = true;
2133
+		if ($context['profiles'][$id]['can_edit']) {
2134
+					$context['can_edit_something'] = true;
2135
+		}
2056 2136
 
2057 2137
 		// You can only delete it if you can edit it AND it's not in use.
2058 2138
 		$context['profiles'][$id]['can_delete'] = $context['profiles'][$id]['can_edit'] && empty($profile['in_use']) ? true : false;
@@ -2073,8 +2153,9 @@  discard block
 block discarded – undo
2073 2153
 	global $smcFunc;
2074 2154
 
2075 2155
 	// All the parent groups to sort out.
2076
-	if (!is_array($parents))
2077
-		$parents = array($parents);
2156
+	if (!is_array($parents)) {
2157
+			$parents = array($parents);
2158
+	}
2078 2159
 
2079 2160
 	// Find all the children of this group.
2080 2161
 	$request = $smcFunc['db_query']('', '
@@ -2101,8 +2182,9 @@  discard block
 block discarded – undo
2101 2182
 	$parents = array_unique($parents);
2102 2183
 
2103 2184
 	// Not a sausage, or a child?
2104
-	if (empty($children))
2105
-		return false;
2185
+	if (empty($children)) {
2186
+			return false;
2187
+	}
2106 2188
 
2107 2189
 	// First off, are we doing general permissions?
2108 2190
 	if ($profile < 1 || $profile === null)
@@ -2117,9 +2199,10 @@  discard block
 block discarded – undo
2117 2199
 			)
2118 2200
 		);
2119 2201
 		$permissions = array();
2120
-		while ($row = $smcFunc['db_fetch_assoc']($request))
2121
-			foreach ($children[$row['id_group']] as $child)
2202
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
2203
+					foreach ($children[$row['id_group']] as $child)
2122 2204
 				$permissions[] = array($child, $row['permission'], $row['add_deny']);
2205
+		}
2123 2206
 		$smcFunc['db_free_result']($request);
2124 2207
 
2125 2208
 		$smcFunc['db_query']('', '
@@ -2159,9 +2242,10 @@  discard block
 block discarded – undo
2159 2242
 			)
2160 2243
 		);
2161 2244
 		$permissions = array();
2162
-		while ($row = $smcFunc['db_fetch_assoc']($request))
2163
-			foreach ($children[$row['id_group']] as $child)
2245
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
2246
+					foreach ($children[$row['id_group']] as $child)
2164 2247
 				$permissions[] = array($child, $row['id_profile'], $row['permission'], $row['add_deny']);
2248
+		}
2165 2249
 		$smcFunc['db_free_result']($request);
2166 2250
 
2167 2251
 		$smcFunc['db_query']('', '
@@ -2195,12 +2279,15 @@  discard block
 block discarded – undo
2195 2279
 	global $context;
2196 2280
 
2197 2281
 	$context['illegal_permissions'] = array();
2198
-	if (!allowedTo('admin_forum'))
2199
-		$context['illegal_permissions'][] = 'admin_forum';
2200
-	if (!allowedTo('manage_membergroups'))
2201
-		$context['illegal_permissions'][] = 'manage_membergroups';
2202
-	if (!allowedTo('manage_permissions'))
2203
-		$context['illegal_permissions'][] = 'manage_permissions';
2282
+	if (!allowedTo('admin_forum')) {
2283
+			$context['illegal_permissions'][] = 'admin_forum';
2284
+	}
2285
+	if (!allowedTo('manage_membergroups')) {
2286
+			$context['illegal_permissions'][] = 'manage_membergroups';
2287
+	}
2288
+	if (!allowedTo('manage_permissions')) {
2289
+			$context['illegal_permissions'][] = 'manage_permissions';
2290
+	}
2204 2291
 
2205 2292
 	call_integration_hook('integrate_load_illegal_permissions');
2206 2293
 }
@@ -2349,16 +2436,17 @@  discard block
 block discarded – undo
2349 2436
 				'attachment' => 'disallow',
2350 2437
 				'children' => array(),
2351 2438
 			);
2439
+		} elseif (isset($context['profile_groups'][$row['id_parent']])) {
2440
+					$context['profile_groups'][$row['id_parent']]['children'][] = $row['group_name'];
2352 2441
 		}
2353
-		elseif (isset($context['profile_groups'][$row['id_parent']]))
2354
-			$context['profile_groups'][$row['id_parent']]['children'][] = $row['group_name'];
2355 2442
 	}
2356 2443
 	$smcFunc['db_free_result']($request);
2357 2444
 
2358 2445
 	// What are the permissions we are querying?
2359 2446
 	$all_permissions = array();
2360
-	foreach ($mappings as $perm_set)
2361
-		$all_permissions = array_merge($all_permissions, $perm_set);
2447
+	foreach ($mappings as $perm_set) {
2448
+			$all_permissions = array_merge($all_permissions, $perm_set);
2449
+	}
2362 2450
 
2363 2451
 	// If we're saving the changes then do just that - save them.
2364 2452
 	if (!empty($_POST['save_changes']) && ($context['current_profile'] == 1 || $context['current_profile'] > 4))
@@ -2373,8 +2461,7 @@  discard block
 block discarded – undo
2373 2461
 			{
2374 2462
 				// Turning it on. This seems easy enough.
2375 2463
 				updateSettings(array('postmod_active' => 1));
2376
-			}
2377
-			else
2464
+			} else
2378 2465
 			{
2379 2466
 				// Turning it off. Not so straightforward. We have to turn off warnings to moderation level, and make everything approved.
2380 2467
 				updateSettings(array(
@@ -2385,8 +2472,7 @@  discard block
 block discarded – undo
2385 2472
 				require_once($sourcedir . '/PostModeration.php');
2386 2473
 				approveAllData();
2387 2474
 			}
2388
-		}
2389
-		elseif ($modSettings['postmod_active'])
2475
+		} elseif ($modSettings['postmod_active'])
2390 2476
 		{
2391 2477
 			// We're not saving a new setting - and if it's still enabled we have more work to do.
2392 2478
 
@@ -2416,21 +2502,22 @@  discard block
 block discarded – undo
2416 2502
 							// Give them both sets for fun.
2417 2503
 							$new_permissions[] = array($context['current_profile'], $group['id'], $data[0], 1);
2418 2504
 							$new_permissions[] = array($context['current_profile'], $group['id'], $data[1], 1);
2505
+						} elseif ($_POST[$index][$group['id']] == 'moderate') {
2506
+													$new_permissions[] = array($context['current_profile'], $group['id'], $data[1], 1);
2419 2507
 						}
2420
-						elseif ($_POST[$index][$group['id']] == 'moderate')
2421
-							$new_permissions[] = array($context['current_profile'], $group['id'], $data[1], 1);
2422 2508
 					}
2423 2509
 				}
2424 2510
 			}
2425 2511
 
2426 2512
 			// Insert new permissions.
2427
-			if (!empty($new_permissions))
2428
-				$smcFunc['db_insert']('',
2513
+			if (!empty($new_permissions)) {
2514
+							$smcFunc['db_insert']('',
2429 2515
 					'{db_prefix}board_permissions',
2430 2516
 					array('id_profile' => 'int', 'id_group' => 'int', 'permission' => 'string', 'add_deny' => 'int'),
2431 2517
 					$new_permissions,
2432 2518
 					array('id_profile', 'id_group', 'permission')
2433 2519
 				);
2520
+			}
2434 2521
 		}
2435 2522
 	}
2436 2523
 
@@ -2459,11 +2546,13 @@  discard block
 block discarded – undo
2459 2546
 					if ($row['add_deny'])
2460 2547
 					{
2461 2548
 						// Full allowance?
2462
-						if ($index == 0)
2463
-							$context['profile_groups'][$row['id_group']][$key] = 'allow';
2549
+						if ($index == 0) {
2550
+													$context['profile_groups'][$row['id_group']][$key] = 'allow';
2551
+						}
2464 2552
 						// Otherwise only bother with moderate if not on allow.
2465
-						elseif ($context['profile_groups'][$row['id_group']][$key] != 'allow')
2466
-							$context['profile_groups'][$row['id_group']][$key] = 'moderate';
2553
+						elseif ($context['profile_groups'][$row['id_group']][$key] != 'allow') {
2554
+													$context['profile_groups'][$row['id_group']][$key] = 'moderate';
2555
+						}
2467 2556
 					}
2468 2557
 				}
2469 2558
 			}
Please login to merge, or discard this patch.
Sources/Subs-Recent.php 1 patch
Braces   +5 added lines, -3 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Get the latest posts of a forum.
@@ -59,8 +60,9 @@  discard block
 block discarded – undo
59 60
 		censorText($row['body']);
60 61
 
61 62
 		$row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br>' => '&#10;')));
62
-		if ($smcFunc['strlen']($row['body']) > 128)
63
-			$row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...';
63
+		if ($smcFunc['strlen']($row['body']) > 128) {
64
+					$row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...';
65
+		}
64 66
 
65 67
 		// Build the array.
66 68
 		$posts[] = array(
Please login to merge, or discard this patch.
Sources/Help.php 1 patch
Braces   +29 added lines, -22 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Redirect to the user help ;).
@@ -95,12 +96,13 @@  discard block
 block discarded – undo
95 96
 	);
96 97
 
97 98
 	// Have we got a localized one?
98
-	if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt'))
99
-		$context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']);
100
-	elseif (file_exists($boarddir . '/agreement.txt'))
101
-		$context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement');
102
-	else
103
-		$context['agreement'] = '';
99
+	if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt')) {
100
+			$context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']);
101
+	} elseif (file_exists($boarddir . '/agreement.txt')) {
102
+			$context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement');
103
+	} else {
104
+			$context['agreement'] = '';
105
+	}
104 106
 
105 107
 	// Nothing to show, so let's get out of here
106 108
 	if (empty($context['agreement']))
@@ -128,18 +130,21 @@  discard block
 block discarded – undo
128 130
 {
129 131
 	global $txt, $helptxt, $context, $scripturl;
130 132
 
131
-	if (!isset($_GET['help']) || !is_string($_GET['help']))
132
-		fatal_lang_error('no_access', false);
133
+	if (!isset($_GET['help']) || !is_string($_GET['help'])) {
134
+			fatal_lang_error('no_access', false);
135
+	}
133 136
 
134
-	if (!isset($helptxt))
135
-		$helptxt = array();
137
+	if (!isset($helptxt)) {
138
+			$helptxt = array();
139
+	}
136 140
 
137 141
 	// Load the admin help language file and template.
138 142
 	loadLanguage('Help');
139 143
 
140 144
 	// Permission specific help?
141
-	if (isset($_GET['help']) && substr($_GET['help'], 0, 14) == 'permissionhelp')
142
-		loadLanguage('ManagePermissions');
145
+	if (isset($_GET['help']) && substr($_GET['help'], 0, 14) == 'permissionhelp') {
146
+			loadLanguage('ManagePermissions');
147
+	}
143 148
 
144 149
 	loadTemplate('Help');
145 150
 
@@ -154,16 +159,18 @@  discard block
 block discarded – undo
154 159
 	$context['sub_template'] = 'popup';
155 160
 
156 161
 	// What help string should be used?
157
-	if (isset($helptxt[$_GET['help']]))
158
-		$context['help_text'] = $helptxt[$_GET['help']];
159
-	elseif (isset($txt[$_GET['help']]))
160
-		$context['help_text'] = $txt[$_GET['help']];
161
-	else
162
-		$context['help_text'] = $_GET['help'];
162
+	if (isset($helptxt[$_GET['help']])) {
163
+			$context['help_text'] = $helptxt[$_GET['help']];
164
+	} elseif (isset($txt[$_GET['help']])) {
165
+			$context['help_text'] = $txt[$_GET['help']];
166
+	} else {
167
+			$context['help_text'] = $_GET['help'];
168
+	}
163 169
 
164 170
 	// Does this text contain a link that we should fill in?
165
-	if (preg_match('~%([0-9]+\$)?s\?~', $context['help_text'], $match))
166
-		$context['help_text'] = sprintf($context['help_text'], $scripturl, $context['session_id'], $context['session_var']);
167
-}
171
+	if (preg_match('~%([0-9]+\$)?s\?~', $context['help_text'], $match)) {
172
+			$context['help_text'] = sprintf($context['help_text'], $scripturl, $context['session_id'], $context['session_var']);
173
+	}
174
+	}
168 175
 
169 176
 ?>
170 177
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/ManageRegistration.php 1 patch
Braces   +27 added lines, -19 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
  * Entrance point for the registration center, it checks permissions and forwards
@@ -31,8 +32,9 @@  discard block
 block discarded – undo
31 32
 	global $context, $txt;
32 33
 
33 34
 	// Old templates might still request this.
34
-	if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'browse')
35
-		redirectexit('action=admin;area=viewmembers;sa=browse' . (isset($_REQUEST['type']) ? ';type=' . $_REQUEST['type'] : ''));
35
+	if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'browse') {
36
+			redirectexit('action=admin;area=viewmembers;sa=browse' . (isset($_REQUEST['type']) ? ';type=' . $_REQUEST['type'] : ''));
37
+	}
36 38
 
37 39
 	$subActions = array(
38 40
 		'register' => array('AdminRegister', 'moderate_forum'),
@@ -99,9 +101,10 @@  discard block
 block discarded – undo
99 101
 		checkSession();
100 102
 		validateToken('admin-regc');
101 103
 
102
-		foreach ($_POST as $key => $value)
103
-			if (!is_array($_POST[$key]))
104
+		foreach ($_POST as $key => $value) {
105
+					if (!is_array($_POST[$key]))
104 106
 				$_POST[$key] = htmltrim__recursive(str_replace(array("\n", "\r"), '', $_POST[$key]));
107
+		}
105 108
 
106 109
 		$regOptions = array(
107 110
 			'interface' => 'admin',
@@ -161,12 +164,13 @@  discard block
 block discarded – undo
161 164
 			)
162 165
 		);
163 166
 		$context['member_groups'] = array(0 => $txt['admin_register_group_none']);
164
-		while ($row = $smcFunc['db_fetch_assoc']($request))
165
-			$context['member_groups'][$row['id_group']] = $row['group_name'];
167
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
168
+					$context['member_groups'][$row['id_group']] = $row['group_name'];
169
+		}
166 170
 		$smcFunc['db_free_result']($request);
171
+	} else {
172
+			$context['member_groups'] = array();
167 173
 	}
168
-	else
169
-		$context['member_groups'] = array();
170 174
 
171 175
 	// Basic stuff.
172 176
 	$context['sub_template'] = 'admin_register';
@@ -207,8 +211,9 @@  discard block
 block discarded – undo
207 211
 		{
208 212
 			$context['editable_agreements']['.' . $lang['filename']] = $lang['name'];
209 213
 			// Are we editing this?
210
-			if (isset($_POST['agree_lang']) && $_POST['agree_lang'] == '.' . $lang['filename'])
211
-				$context['current_agreement'] = '.' . $lang['filename'];
214
+			if (isset($_POST['agree_lang']) && $_POST['agree_lang'] == '.' . $lang['filename']) {
215
+							$context['current_agreement'] = '.' . $lang['filename'];
216
+			}
212 217
 		}
213 218
 	}
214 219
 
@@ -223,10 +228,11 @@  discard block
 block discarded – undo
223 228
 
224 229
 		updateSettings(array('requireAgreement' => !empty($_POST['requireAgreement'])));
225 230
 
226
-		if ($bytes == strlen($to_write))
227
-			$context['saved_successful'] = true;
228
-		else
229
-			$context['could_not_save'] = true;
231
+		if ($bytes == strlen($to_write)) {
232
+					$context['saved_successful'] = true;
233
+		} else {
234
+					$context['could_not_save'] = true;
235
+		}
230 236
 	}
231 237
 
232 238
 	$context['agreement'] = file_exists($boarddir . '/agreement' . $context['current_agreement'] . '.txt') ? $smcFunc['htmlspecialchars'](file_get_contents($boarddir . '/agreement' . $context['current_agreement'] . '.txt')) : '';
@@ -310,8 +316,9 @@  discard block
 block discarded – undo
310 316
 
311 317
 	call_integration_hook('integrate_modify_registration_settings', array(&$config_vars));
312 318
 
313
-	if ($return_config)
314
-		return $config_vars;
319
+	if ($return_config) {
320
+			return $config_vars;
321
+	}
315 322
 
316 323
 	// Setup the template
317 324
 	$context['sub_template'] = 'show_settings';
@@ -322,8 +329,9 @@  discard block
 block discarded – undo
322 329
 		checkSession();
323 330
 
324 331
 		// Are there some contacts missing?
325
-		if (!empty($_POST['coppaAge']) && !empty($_POST['coppaType']) && empty($_POST['coppaPost']) && empty($_POST['coppaFax']))
326
-			fatal_lang_error('admin_setting_coppa_require_contact');
332
+		if (!empty($_POST['coppaAge']) && !empty($_POST['coppaType']) && empty($_POST['coppaPost']) && empty($_POST['coppaFax'])) {
333
+					fatal_lang_error('admin_setting_coppa_require_contact');
334
+		}
327 335
 
328 336
 		// Post needs to take into account line breaks.
329 337
 		$_POST['coppaPost'] = str_replace("\n", '<br>', empty($_POST['coppaPost']) ? '' : $_POST['coppaPost']);
Please login to merge, or discard this patch.