Completed
Push — release-2.1 ( 65d689...40be7d )
by Jeremy
14s
created
Sources/ManageSmileys.php 1 patch
Braces   +299 added lines, -213 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 dispatcher of smileys administration.
@@ -91,8 +92,9 @@  discard block
 block discarded – undo
91 92
 	);
92 93
 
93 94
 	// Some settings may not be enabled, disallow these from the tabs as appropriate.
94
-	if (empty($modSettings['messageIcons_enable']))
95
-		$context[$context['admin_menu_name']]['tab_data']['tabs']['editicons']['disabled'] = true;
95
+	if (empty($modSettings['messageIcons_enable'])) {
96
+			$context[$context['admin_menu_name']]['tab_data']['tabs']['editicons']['disabled'] = true;
97
+	}
96 98
 	if (empty($modSettings['smiley_enable']))
97 99
 	{
98 100
 		$context[$context['admin_menu_name']]['tab_data']['tabs']['addsmiley']['disabled'] = true;
@@ -125,8 +127,9 @@  discard block
 block discarded – undo
125 127
 	$set_names = explode("\n", $modSettings['smiley_sets_names']);
126 128
 
127 129
 	$smiley_context = array();
128
-	foreach ($smiley_sets as $i => $set)
129
-		$smiley_context[$set] = $set_names[$i];
130
+	foreach ($smiley_sets as $i => $set) {
131
+			$smiley_context[$set] = $set_names[$i];
132
+	}
130 133
 
131 134
 	// All the settings for the page...
132 135
 	$config_vars = array(
@@ -147,8 +150,9 @@  discard block
 block discarded – undo
147 150
 
148 151
 	call_integration_hook('integrate_modify_smiley_settings', array(&$config_vars));
149 152
 
150
-	if ($return_config)
151
-		return $config_vars;
153
+	if ($return_config) {
154
+			return $config_vars;
155
+	}
152 156
 
153 157
 	// Setup the basics of the settings template.
154 158
 	require_once($sourcedir . '/ManageServer.php');
@@ -208,8 +212,9 @@  discard block
 block discarded – undo
208 212
 			foreach ($_POST['smiley_set'] as $id => $val)
209 213
 			{
210 214
 				// If this is the set you've marked as default, or the only one remaining, you can't delete it
211
-				if ($modSettings['smiley_sets_default'] != $set_paths[$id] && count($set_paths) != 1 && isset($set_paths[$id], $set_names[$id]))
212
-					unset($set_paths[$id], $set_names[$id], $set_exts[$id]);
215
+				if ($modSettings['smiley_sets_default'] != $set_paths[$id] && count($set_paths) != 1 && isset($set_paths[$id], $set_names[$id])) {
216
+									unset($set_paths[$id], $set_names[$id], $set_exts[$id]);
217
+				}
213 218
 			}
214 219
 
215 220
 			// Shortcut... array_merge() on a single array resets the numeric keys
@@ -225,8 +230,9 @@  discard block
 block discarded – undo
225 230
 			));
226 231
 		}
227 232
 		// Add a new smiley set.
228
-		elseif (!empty($_POST['add']))
229
-			$context['sub_action'] = 'modifyset';
233
+		elseif (!empty($_POST['add'])) {
234
+					$context['sub_action'] = 'modifyset';
235
+		}
230 236
 		// Create or modify a smiley set.
231 237
 		elseif (isset($_POST['set']))
232 238
 		{
@@ -237,8 +243,9 @@  discard block
 block discarded – undo
237 243
 			// Create a new smiley set.
238 244
 			if ($_POST['set'] == -1 && isset($_POST['smiley_sets_path']))
239 245
 			{
240
-				if (in_array($_POST['smiley_sets_path'], $set_paths))
241
-					fatal_lang_error('smiley_set_already_exists');
246
+				if (in_array($_POST['smiley_sets_path'], $set_paths)) {
247
+									fatal_lang_error('smiley_set_already_exists');
248
+				}
242 249
 
243 250
 				updateSettings(array(
244 251
 					'smiley_sets_known' => $modSettings['smiley_sets_known'] . ',' . $_POST['smiley_sets_path'],
@@ -251,12 +258,14 @@  discard block
 block discarded – undo
251 258
 			else
252 259
 			{
253 260
 				// Make sure the smiley set exists.
254
-				if (!isset($set_paths[$_POST['set']]) || !isset($set_names[$_POST['set']]))
255
-					fatal_lang_error('smiley_set_not_found');
261
+				if (!isset($set_paths[$_POST['set']]) || !isset($set_names[$_POST['set']])) {
262
+									fatal_lang_error('smiley_set_not_found');
263
+				}
256 264
 
257 265
 				// Make sure the path is not yet used by another smileyset.
258
-				if (in_array($_POST['smiley_sets_path'], $set_paths) && $_POST['smiley_sets_path'] != $set_paths[$_POST['set']])
259
-					fatal_lang_error('smiley_set_path_already_used');
266
+				if (in_array($_POST['smiley_sets_path'], $set_paths) && $_POST['smiley_sets_path'] != $set_paths[$_POST['set']]) {
267
+									fatal_lang_error('smiley_set_path_already_used');
268
+				}
260 269
 
261 270
 				$set_paths[$_POST['set']] = $_POST['smiley_sets_path'];
262 271
 				$set_exts[$_POST['set']] = $_POST['smiley_sets_ext'];
@@ -270,8 +279,9 @@  discard block
 block discarded – undo
270 279
 			}
271 280
 
272 281
 			// The user might have checked to also import smileys.
273
-			if (!empty($_POST['smiley_sets_import']))
274
-				ImportSmileys($_POST['smiley_sets_path']);
282
+			if (!empty($_POST['smiley_sets_import'])) {
283
+							ImportSmileys($_POST['smiley_sets_path']);
284
+			}
275 285
 		}
276 286
 		cache_put_data('parsing_smileys', null, 480);
277 287
 		cache_put_data('posting_smileys', null, 480);
@@ -281,14 +291,15 @@  discard block
 block discarded – undo
281 291
 	$context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']);
282 292
 	$set_exts = explode(",", $modSettings['smiley_sets_exts']);
283 293
 	$set_names = explode("\n", $modSettings['smiley_sets_names']);
284
-	foreach ($context['smiley_sets'] as $i => $set)
285
-		$context['smiley_sets'][$i] = array(
294
+	foreach ($context['smiley_sets'] as $i => $set) {
295
+			$context['smiley_sets'][$i] = array(
286 296
 			'id' => $i,
287 297
 			'path' => $smcFunc['htmlspecialchars']($set),
288 298
 			'ext' => $smcFunc['htmlspecialchars']($set_exts[$i]),
289 299
 			'name' => $smcFunc['htmlspecialchars']($set_names[$i]),
290 300
 			'selected' => $set == $modSettings['smiley_sets_default']
291 301
 		);
302
+	}
292 303
 
293 304
 	// Importing any smileys from an existing set?
294 305
 	if ($context['sub_action'] == 'import')
@@ -299,8 +310,9 @@  discard block
 block discarded – undo
299 310
 		$_GET['set'] = (int) $_GET['set'];
300 311
 
301 312
 		// Sanity check - then import.
302
-		if (isset($context['smiley_sets'][$_GET['set']]))
303
-			ImportSmileys(un_htmlspecialchars($context['smiley_sets'][$_GET['set']]['path']));
313
+		if (isset($context['smiley_sets'][$_GET['set']])) {
314
+					ImportSmileys(un_htmlspecialchars($context['smiley_sets'][$_GET['set']]['path']));
315
+		}
304 316
 
305 317
 		// Force the process to continue.
306 318
 		$context['sub_action'] = 'modifyset';
@@ -310,8 +322,8 @@  discard block
 block discarded – undo
310 322
 	if ($context['sub_action'] == 'modifyset')
311 323
 	{
312 324
 		$_GET['set'] = !isset($_GET['set']) ? -1 : (int) $_GET['set'];
313
-		if ($_GET['set'] == -1 || !isset($context['smiley_sets'][$_GET['set']]))
314
-			$context['current_set'] = array(
325
+		if ($_GET['set'] == -1 || !isset($context['smiley_sets'][$_GET['set']])) {
326
+					$context['current_set'] = array(
315 327
 				'id' => '-1',
316 328
 				'path' => '',
317 329
 				'ext' => '',
@@ -319,7 +331,7 @@  discard block
 block discarded – undo
319 331
 				'selected' => false,
320 332
 				'is_new' => true,
321 333
 			);
322
-		else
334
+		} else
323 335
 		{
324 336
 			$context['current_set'] = &$context['smiley_sets'][$_GET['set']];
325 337
 			$context['current_set']['is_new'] = false;
@@ -333,13 +345,15 @@  discard block
 block discarded – undo
333 345
 				{
334 346
 					// strip extension before comparison
335 347
 					$filename = pathinfo($entry, PATHINFO_FILENAME);
336
-					if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png', '.svg')))
337
-						$smileys[strtolower($filename)] = $filename;
348
+					if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png', '.svg'))) {
349
+											$smileys[strtolower($filename)] = $filename;
350
+					}
338 351
 				}
339 352
 				$dir->close();
340 353
 
341
-				if (empty($smileys))
342
-					fatal_lang_error('smiley_set_dir_not_found', false, array($context['current_set']['name']));
354
+				if (empty($smileys)) {
355
+									fatal_lang_error('smiley_set_dir_not_found', false, array($context['current_set']['name']));
356
+				}
343 357
 
344 358
 				// Exclude the smileys that are already in the database.
345 359
 				$request = $smcFunc['db_query']('', '
@@ -350,9 +364,10 @@  discard block
 block discarded – undo
350 364
 						'smiley_list' => $smileys,
351 365
 					)
352 366
 				);
353
-				while ($row = $smcFunc['db_fetch_assoc']($request))
354
-					if (isset($smileys[strtolower($row['filename'])]))
367
+				while ($row = $smcFunc['db_fetch_assoc']($request)) {
368
+									if (isset($smileys[strtolower($row['filename'])]))
355 369
 						unset($smileys[strtolower($row['filename'])]);
370
+				}
356 371
 				$smcFunc['db_free_result']($request);
357 372
 
358 373
 				$context['current_set']['can_import'] = count($smileys);
@@ -367,13 +382,14 @@  discard block
 block discarded – undo
367 382
 			$dir = dir($modSettings['smileys_dir']);
368 383
 			while ($entry = $dir->read())
369 384
 			{
370
-				if (!in_array($entry, array('.', '..')) && is_dir($modSettings['smileys_dir'] . '/' . $entry))
371
-					$context['smiley_set_dirs'][] = array(
385
+				if (!in_array($entry, array('.', '..')) && is_dir($modSettings['smileys_dir'] . '/' . $entry)) {
386
+									$context['smiley_set_dirs'][] = array(
372 387
 						'id' => $entry,
373 388
 						'path' => $modSettings['smileys_dir'] . '/' . $entry,
374 389
 						'selectable' => $entry == $context['current_set']['path'] || !in_array($entry, explode(',', $modSettings['smiley_sets_known'])),
375 390
 						'current' => $entry == $context['current_set']['path'],
376 391
 					);
392
+				}
377 393
 			}
378 394
 			$dir->close();
379 395
 		}
@@ -383,8 +399,9 @@  discard block
 block discarded – undo
383 399
 	createToken('admin-mss', 'request');
384 400
 
385 401
 	// In case we need to import smileys, we need to add the token in now.
386
-	if (isset($context['current_set']['import_url']))
387
-		$context['current_set']['import_url'] .= ';' . $context['admin-mss_token_var'] . '=' . $context['admin-mss_token'];
402
+	if (isset($context['current_set']['import_url'])) {
403
+			$context['current_set']['import_url'] .= ';' . $context['admin-mss_token_var'] . '=' . $context['admin-mss_token'];
404
+	}
388 405
 
389 406
 	$listOptions = array(
390 407
 		'id' => 'smiley_set_list',
@@ -537,24 +554,26 @@  discard block
 block discarded – undo
537 554
 		$cols['ext'][] = $set_exts[$i];
538 555
 	}
539 556
 	$sort_flag = strpos($sort, 'DESC') === false ? SORT_ASC : SORT_DESC;
540
-	if (substr($sort, 0, 4) === 'name')
541
-		array_multisort($cols['name'], $sort_flag, SORT_REGULAR, $cols['path'], $cols['selected'], $cols['id'], $cols['ext']);
542
-	elseif (substr($sort, 0, 3) === 'ext')
543
-		array_multisort($cols['ext'], $sort_flag, SORT_REGULAR, $cols['name'], $cols['selected'], $cols['id'], $cols['path']);
544
-	elseif (substr($sort, 0, 4) === 'path')
545
-		array_multisort($cols['path'], $sort_flag, SORT_REGULAR, $cols['name'], $cols['selected'], $cols['id'], $cols['ext']);
546
-	else
547
-		array_multisort($cols['selected'], $sort_flag, SORT_REGULAR, $cols['path'], $cols['name'], $cols['id'], $cols['ext']);
557
+	if (substr($sort, 0, 4) === 'name') {
558
+			array_multisort($cols['name'], $sort_flag, SORT_REGULAR, $cols['path'], $cols['selected'], $cols['id'], $cols['ext']);
559
+	} elseif (substr($sort, 0, 3) === 'ext') {
560
+			array_multisort($cols['ext'], $sort_flag, SORT_REGULAR, $cols['name'], $cols['selected'], $cols['id'], $cols['path']);
561
+	} elseif (substr($sort, 0, 4) === 'path') {
562
+			array_multisort($cols['path'], $sort_flag, SORT_REGULAR, $cols['name'], $cols['selected'], $cols['id'], $cols['ext']);
563
+	} else {
564
+			array_multisort($cols['selected'], $sort_flag, SORT_REGULAR, $cols['path'], $cols['name'], $cols['id'], $cols['ext']);
565
+	}
548 566
 
549 567
 	$smiley_sets = array();
550
-	foreach ($cols['id'] as $i => $id)
551
-		$smiley_sets[] = array(
568
+	foreach ($cols['id'] as $i => $id) {
569
+			$smiley_sets[] = array(
552 570
 			'id' => $id,
553 571
 			'path' => $cols['path'][$i],
554 572
 			'name' => $cols['name'][$i],
555 573
 			'ext' => $cols['ext'][$i],
556 574
 			'selected' => $cols['path'][$i] == $modSettings['smiley_sets_default']
557 575
 		);
576
+	}
558 577
 
559 578
 	return $smiley_sets;
560 579
 }
@@ -584,14 +603,15 @@  discard block
 block discarded – undo
584 603
 	$context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']);
585 604
 	$set_exts = explode(',', $modSettings['smiley_sets_exts']);
586 605
 	$set_names = explode("\n", $modSettings['smiley_sets_names']);
587
-	foreach ($context['smiley_sets'] as $i => $set)
588
-		$context['smiley_sets'][$i] = array(
606
+	foreach ($context['smiley_sets'] as $i => $set) {
607
+			$context['smiley_sets'][$i] = array(
589 608
 			'id' => $i,
590 609
 			'path' => $smcFunc['htmlspecialchars']($set),
591 610
 			'name' => $smcFunc['htmlspecialchars']($set_names[$i]),
592 611
 			'ext' => $smcFunc['htmlspecialchars']($set_exts[$i]),
593 612
 			'selected' => $set == $modSettings['smiley_sets_default']
594 613
 		);
614
+	}
595 615
 
596 616
 	// Submitting a form?
597 617
 	if (isset($_POST[$context['session_var']], $_POST['smiley_code']))
@@ -607,8 +627,9 @@  discard block
 block discarded – undo
607 627
 		$_POST['smiley_filename'] = htmltrim__recursive($_POST['smiley_filename']);
608 628
 
609 629
 		// Make sure some code was entered.
610
-		if (empty($_POST['smiley_code']))
611
-			fatal_lang_error('smiley_has_no_code');
630
+		if (empty($_POST['smiley_code'])) {
631
+					fatal_lang_error('smiley_has_no_code');
632
+		}
612 633
 
613 634
 		// Check whether the new code has duplicates. It should be unique.
614 635
 		$request = $smcFunc['db_query']('', '
@@ -620,8 +641,9 @@  discard block
 block discarded – undo
620 641
 				'smiley_code' => $_POST['smiley_code'],
621 642
 			)
622 643
 		);
623
-		if ($smcFunc['db_num_rows']($request) > 0)
624
-			fatal_lang_error('smiley_not_unique');
644
+		if ($smcFunc['db_num_rows']($request) > 0) {
645
+					fatal_lang_error('smiley_not_unique');
646
+		}
625 647
 		$smcFunc['db_free_result']($request);
626 648
 
627 649
 		// If we are uploading - check all the smiley sets are writable!
@@ -630,38 +652,44 @@  discard block
 block discarded – undo
630 652
 			$writeErrors = array();
631 653
 			foreach ($context['smiley_sets'] as $set)
632 654
 			{
633
-				if (!is_writable($context['smileys_dir'] . '/' . un_htmlspecialchars($set['path'])))
634
-					$writeErrors[] = $set['path'];
655
+				if (!is_writable($context['smileys_dir'] . '/' . un_htmlspecialchars($set['path']))) {
656
+									$writeErrors[] = $set['path'];
657
+				}
658
+			}
659
+			if (!empty($writeErrors)) {
660
+							fatal_lang_error('smileys_upload_error_notwritable', true, array(implode(', ', $writeErrors)));
635 661
 			}
636
-			if (!empty($writeErrors))
637
-				fatal_lang_error('smileys_upload_error_notwritable', true, array(implode(', ', $writeErrors)));
638 662
 		}
639 663
 
640 664
 		// Uploading just one smiley for all of them?
641 665
 		if (isset($_POST['sameall']) && isset($_FILES['uploadSmiley']['name']) && $_FILES['uploadSmiley']['name'] != '')
642 666
 		{
643
-			if (!is_uploaded_file($_FILES['uploadSmiley']['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['uploadSmiley']['tmp_name'])))
644
-				fatal_lang_error('smileys_upload_error');
667
+			if (!is_uploaded_file($_FILES['uploadSmiley']['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['uploadSmiley']['tmp_name']))) {
668
+							fatal_lang_error('smileys_upload_error');
669
+			}
645 670
 
646 671
 			// Sorry, no spaces, dots, or anything else but letters allowed.
647 672
 			$_FILES['uploadSmiley']['name'] = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $_FILES['uploadSmiley']['name']);
648 673
 
649 674
 			// We only allow image files - it's THAT simple - no messing around here...
650
-			if (!in_array(strtolower(substr(strrchr($_FILES['uploadSmiley']['name'], '.'), 1)), $allowedTypes))
651
-				fatal_lang_error('smileys_upload_error_types', false, array(implode(', ', $allowedTypes)));
675
+			if (!in_array(strtolower(substr(strrchr($_FILES['uploadSmiley']['name'], '.'), 1)), $allowedTypes)) {
676
+							fatal_lang_error('smileys_upload_error_types', false, array(implode(', ', $allowedTypes)));
677
+			}
652 678
 
653 679
 			// We only need the filename...
654 680
 			$destName = basename($_FILES['uploadSmiley']['name']);
655 681
 
656 682
 			// Make sure they aren't trying to upload a nasty file - for their own good here!
657
-			if (in_array(strtolower($destName), $disabledFiles))
658
-				fatal_lang_error('smileys_upload_error_illegal');
683
+			if (in_array(strtolower($destName), $disabledFiles)) {
684
+							fatal_lang_error('smileys_upload_error_illegal');
685
+			}
659 686
 
660 687
 			// Check if the file already exists... and if not move it to EVERY smiley set directory.
661 688
 			$i = 0;
662 689
 			// Keep going until we find a set the file doesn't exist in. (or maybe it exists in all of them?)
663
-			while (isset($context['smiley_sets'][$i]) && file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($context['smiley_sets'][$i]['path']) . '/' . $destName))
664
-				$i++;
690
+			while (isset($context['smiley_sets'][$i]) && file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($context['smiley_sets'][$i]['path']) . '/' . $destName)) {
691
+							$i++;
692
+			}
665 693
 
666 694
 			// Okay, we're going to put the smiley right here, since it's not there yet!
667 695
 			if (isset($context['smiley_sets'][$i]['path']))
@@ -676,8 +704,9 @@  discard block
 block discarded – undo
676 704
 					$currentPath = $context['smileys_dir'] . '/' . un_htmlspecialchars($context['smiley_sets'][$i]['path']) . '/' . $destName;
677 705
 
678 706
 					// The file is already there!  Don't overwrite it!
679
-					if (file_exists($currentPath))
680
-						continue;
707
+					if (file_exists($currentPath)) {
708
+											continue;
709
+					}
681 710
 
682 711
 					// Okay, so copy the first one we made to here.
683 712
 					copy($smileyLocation, $currentPath);
@@ -694,13 +723,15 @@  discard block
 block discarded – undo
694 723
 			$newName = '';
695 724
 			foreach ($_FILES as $name => $data)
696 725
 			{
697
-				if ($_FILES[$name]['name'] == '')
698
-					fatal_lang_error('smileys_upload_error_blank');
726
+				if ($_FILES[$name]['name'] == '') {
727
+									fatal_lang_error('smileys_upload_error_blank');
728
+				}
699 729
 
700
-				if (empty($newName))
701
-					$newName = basename($_FILES[$name]['name']);
702
-				elseif (basename($_FILES[$name]['name']) != $newName)
703
-					fatal_lang_error('smileys_upload_error_name');
730
+				if (empty($newName)) {
731
+									$newName = basename($_FILES[$name]['name']);
732
+				} elseif (basename($_FILES[$name]['name']) != $newName) {
733
+									fatal_lang_error('smileys_upload_error_name');
734
+				}
704 735
 			}
705 736
 
706 737
 			foreach ($context['smiley_sets'] as $i => $set)
@@ -708,31 +739,36 @@  discard block
 block discarded – undo
708 739
 				$set['name'] = un_htmlspecialchars($set['name']);
709 740
 				$set['path'] = un_htmlspecialchars($set['path']);
710 741
 
711
-				if (!isset($_FILES['individual_' . $set['name']]['name']) || $_FILES['individual_' . $set['name']]['name'] == '')
712
-					continue;
742
+				if (!isset($_FILES['individual_' . $set['name']]['name']) || $_FILES['individual_' . $set['name']]['name'] == '') {
743
+									continue;
744
+				}
713 745
 
714 746
 				// Got one...
715
-				if (!is_uploaded_file($_FILES['individual_' . $set['name']]['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['individual_' . $set['name']]['tmp_name'])))
716
-					fatal_lang_error('smileys_upload_error');
747
+				if (!is_uploaded_file($_FILES['individual_' . $set['name']]['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['individual_' . $set['name']]['tmp_name']))) {
748
+									fatal_lang_error('smileys_upload_error');
749
+				}
717 750
 
718 751
 				// Sorry, no spaces, dots, or anything else but letters allowed.
719 752
 				$_FILES['individual_' . $set['name']]['name'] = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $_FILES['individual_' . $set['name']]['name']);
720 753
 
721 754
 				// We only allow image files - it's THAT simple - no messing around here...
722
-				if (!in_array(strtolower(substr(strrchr($_FILES['individual_' . $set['name']]['name'], '.'), 1)), $allowedTypes))
723
-					fatal_lang_error('smileys_upload_error_types', false, array(implode(', ', $allowedTypes)));
755
+				if (!in_array(strtolower(substr(strrchr($_FILES['individual_' . $set['name']]['name'], '.'), 1)), $allowedTypes)) {
756
+									fatal_lang_error('smileys_upload_error_types', false, array(implode(', ', $allowedTypes)));
757
+				}
724 758
 
725 759
 				// We only need the filename...
726 760
 				$destName = basename($_FILES['individual_' . $set['name']]['name']);
727 761
 
728 762
 				// Make sure they aren't trying to upload a nasty file - for their own good here!
729
-				if (in_array(strtolower($destName), $disabledFiles))
730
-					fatal_lang_error('smileys_upload_error_illegal');
763
+				if (in_array(strtolower($destName), $disabledFiles)) {
764
+									fatal_lang_error('smileys_upload_error_illegal');
765
+				}
731 766
 
732 767
 				// If the file exists - ignore it.
733 768
 				$smileyLocation = $context['smileys_dir'] . '/' . $set['path'] . '/' . $destName;
734
-				if (file_exists($smileyLocation))
735
-					continue;
769
+				if (file_exists($smileyLocation)) {
770
+									continue;
771
+				}
736 772
 
737 773
 				// Finally - move the image!
738 774
 				move_uploaded_file($_FILES['individual_' . $set['name']]['tmp_name'], $smileyLocation);
@@ -744,8 +780,9 @@  discard block
 block discarded – undo
744 780
 		}
745 781
 
746 782
 		// Also make sure a filename was given.
747
-		if (empty($_POST['smiley_filename']))
748
-			fatal_lang_error('smiley_has_no_filename');
783
+		if (empty($_POST['smiley_filename'])) {
784
+					fatal_lang_error('smiley_has_no_filename');
785
+		}
749 786
 
750 787
 		// Find the position on the right.
751 788
 		$smiley_order = '0';
@@ -764,8 +801,9 @@  discard block
 block discarded – undo
764 801
 			list ($smiley_order) = $smcFunc['db_fetch_row']($request);
765 802
 			$smcFunc['db_free_result']($request);
766 803
 
767
-			if (empty($smiley_order))
768
-				$smiley_order = '0';
804
+			if (empty($smiley_order)) {
805
+							$smiley_order = '0';
806
+			}
769 807
 		}
770 808
 		$smcFunc['db_insert']('',
771 809
 			'{db_prefix}smileys',
@@ -793,19 +831,21 @@  discard block
 block discarded – undo
793 831
 	{
794 832
 		foreach ($context['smiley_sets'] as $smiley_set)
795 833
 		{
796
-			if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path'])))
797
-				continue;
834
+			if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']))) {
835
+							continue;
836
+			}
798 837
 
799 838
 			$dir = dir($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']));
800 839
 			while ($entry = $dir->read())
801 840
 			{
802 841
 				// Strip extension
803 842
 				$filename = pathinfo($entry, PATHINFO_FILENAME);
804
-				if (!in_array($filename, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png', '.svg')))
805
-					$context['filenames'][strtolower($filename)] = array(
843
+				if (!in_array($filename, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png', '.svg'))) {
844
+									$context['filenames'][strtolower($filename)] = array(
806 845
 						'id' => $smcFunc['htmlspecialchars']($filename),
807 846
 						'selected' => false,
808 847
 					);
848
+				}
809 849
 			}
810 850
 			$dir->close();
811 851
 		}
@@ -843,17 +883,19 @@  discard block
 block discarded – undo
843 883
 		// Changing the selected smileys?
844 884
 		if (isset($_POST['smiley_action']) && !empty($_POST['checked_smileys']))
845 885
 		{
846
-			foreach ($_POST['checked_smileys'] as $id => $smiley_id)
847
-				$_POST['checked_smileys'][$id] = (int) $smiley_id;
886
+			foreach ($_POST['checked_smileys'] as $id => $smiley_id) {
887
+							$_POST['checked_smileys'][$id] = (int) $smiley_id;
888
+			}
848 889
 
849
-			if ($_POST['smiley_action'] == 'delete')
850
-				$smcFunc['db_query']('', '
890
+			if ($_POST['smiley_action'] == 'delete') {
891
+							$smcFunc['db_query']('', '
851 892
 					DELETE FROM {db_prefix}smileys
852 893
 					WHERE id_smiley IN ({array_int:checked_smileys})',
853 894
 					array(
854 895
 						'checked_smileys' => $_POST['checked_smileys'],
855 896
 					)
856 897
 				);
898
+			}
857 899
 			// Changing the status of the smiley?
858 900
 			else
859 901
 			{
@@ -863,8 +905,8 @@  discard block
 block discarded – undo
863 905
 					'hidden' => 1,
864 906
 					'popup' => 2
865 907
 				);
866
-				if (isset($displayTypes[$_POST['smiley_action']]))
867
-					$smcFunc['db_query']('', '
908
+				if (isset($displayTypes[$_POST['smiley_action']])) {
909
+									$smcFunc['db_query']('', '
868 910
 						UPDATE {db_prefix}smileys
869 911
 						SET hidden = {int:display_type}
870 912
 						WHERE id_smiley IN ({array_int:checked_smileys})',
@@ -873,6 +915,7 @@  discard block
 block discarded – undo
873 915
 							'display_type' => $displayTypes[$_POST['smiley_action']],
874 916
 						)
875 917
 					);
918
+				}
876 919
 			}
877 920
 		}
878 921
 		// Create/modify a smiley.
@@ -898,12 +941,14 @@  discard block
 block discarded – undo
898 941
 				$_POST['smiley_location'] = empty($_POST['smiley_location']) || $_POST['smiley_location'] > 2 || $_POST['smiley_location'] < 0 ? 0 : (int) $_POST['smiley_location'];
899 942
 
900 943
 				// Make sure some code was entered.
901
-				if (empty($_POST['smiley_code']))
902
-					fatal_lang_error('smiley_has_no_code');
944
+				if (empty($_POST['smiley_code'])) {
945
+									fatal_lang_error('smiley_has_no_code');
946
+				}
903 947
 
904 948
 				// Also make sure a filename was given.
905
-				if (empty($_POST['smiley_filename']))
906
-					fatal_lang_error('smiley_has_no_filename');
949
+				if (empty($_POST['smiley_filename'])) {
950
+									fatal_lang_error('smiley_has_no_filename');
951
+				}
907 952
 
908 953
 				// Check whether the new code has duplicates. It should be unique.
909 954
 				$request = $smcFunc['db_query']('', '
@@ -917,8 +962,9 @@  discard block
 block discarded – undo
917 962
 						'smiley_code' => $_POST['smiley_code'],
918 963
 					)
919 964
 				);
920
-				if ($smcFunc['db_num_rows']($request) > 0)
921
-					fatal_lang_error('smiley_not_unique');
965
+				if ($smcFunc['db_num_rows']($request) > 0) {
966
+									fatal_lang_error('smiley_not_unique');
967
+				}
922 968
 				$smcFunc['db_free_result']($request);
923 969
 
924 970
 				$smcFunc['db_query']('', '
@@ -948,14 +994,15 @@  discard block
 block discarded – undo
948 994
 	$context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']);
949 995
 	$set_exts = explode(',', $modSettings['smiley_sets_exts']);
950 996
 	$set_names = explode("\n", $modSettings['smiley_sets_names']);
951
-	foreach ($context['smiley_sets'] as $i => $set)
952
-		$context['smiley_sets'][$i] = array(
997
+	foreach ($context['smiley_sets'] as $i => $set) {
998
+			$context['smiley_sets'][$i] = array(
953 999
 			'id' => $i,
954 1000
 			'path' => $smcFunc['htmlspecialchars']($set),
955 1001
 			'name' => $smcFunc['htmlspecialchars']($set_names[$i]),
956 1002
 			'ext' => $smcFunc['htmlspecialchars']($set_exts[$i]),
957 1003
 			'selected' => $set == $modSettings['smiley_sets_default']
958 1004
 		);
1005
+	}
959 1006
 
960 1007
 	// Prepare overview of all (custom) smileys.
961 1008
 	if ($context['sub_action'] == 'editsmileys')
@@ -971,9 +1018,10 @@  discard block
 block discarded – undo
971 1018
 		// Create a list of options for selecting smiley sets.
972 1019
 		$smileyset_option_list = '
973 1020
 			<select name="set" onchange="changeSet(this.options[this.selectedIndex].value);">';
974
-		foreach ($context['smiley_sets'] as $smiley_set)
975
-			$smileyset_option_list .= '
1021
+		foreach ($context['smiley_sets'] as $smiley_set) {
1022
+					$smileyset_option_list .= '
976 1023
 				<option value="' . $smiley_set['path'] . '"' . ($modSettings['smiley_sets_default'] == $smiley_set['path'] ? ' selected' : '') . '>' . $smiley_set['name'] . '</option>';
1024
+		}
977 1025
 		$smileyset_option_list .= '
978 1026
 			</select>';
979 1027
 
@@ -1035,12 +1083,13 @@  discard block
 block discarded – undo
1035 1083
 					'data' => array(
1036 1084
 						'function' => function ($rowData) use ($txt)
1037 1085
 						{
1038
-							if (empty($rowData['hidden']))
1039
-								return $txt['smileys_location_form'];
1040
-							elseif ($rowData['hidden'] == 1)
1041
-								return $txt['smileys_location_hidden'];
1042
-							else
1043
-								return $txt['smileys_location_popup'];
1086
+							if (empty($rowData['hidden'])) {
1087
+															return $txt['smileys_location_form'];
1088
+							} elseif ($rowData['hidden'] == 1) {
1089
+															return $txt['smileys_location_hidden'];
1090
+							} else {
1091
+															return $txt['smileys_location_popup'];
1092
+							}
1044 1093
 						},
1045 1094
 					),
1046 1095
 					'sort' => array(
@@ -1055,19 +1104,22 @@  discard block
 block discarded – undo
1055 1104
 					'data' => array(
1056 1105
 						'function' => function ($rowData) use ($context, $txt, $modSettings, $smcFunc)
1057 1106
 						{
1058
-							if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir']))
1059
-								return $smcFunc['htmlspecialchars']($rowData['description']);
1107
+							if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'])) {
1108
+															return $smcFunc['htmlspecialchars']($rowData['description']);
1109
+							}
1060 1110
 
1061 1111
 							// Check if there are smileys missing in some sets.
1062 1112
 							$missing_sets = array();
1063
-							foreach ($context['smiley_sets'] as $smiley_set)
1064
-								if (!file_exists(sprintf('%1$s/%2$s/%3$s', $modSettings['smileys_dir'], $smiley_set['path'], $rowData['filename'])))
1113
+							foreach ($context['smiley_sets'] as $smiley_set) {
1114
+															if (!file_exists(sprintf('%1$s/%2$s/%3$s', $modSettings['smileys_dir'], $smiley_set['path'], $rowData['filename'])))
1065 1115
 									$missing_sets[] = $smiley_set['path'];
1116
+							}
1066 1117
 
1067 1118
 							$description = $smcFunc['htmlspecialchars']($rowData['description']);
1068 1119
 
1069
-							if (!empty($missing_sets))
1070
-								$description .= sprintf('<br><span class="smalltext"><strong>%1$s:</strong> %2$s</span>', $txt['smileys_not_found_in_set'], implode(', ', $missing_sets));
1120
+							if (!empty($missing_sets)) {
1121
+															$description .= sprintf('<br><span class="smalltext"><strong>%1$s:</strong> %2$s</span>', $txt['smileys_not_found_in_set'], implode(', ', $missing_sets));
1122
+							}
1071 1123
 
1072 1124
 							return $description;
1073 1125
 						},
@@ -1186,14 +1238,15 @@  discard block
 block discarded – undo
1186 1238
 		$context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']);
1187 1239
 		$set_exts = explode(',', $modSettings['smiley_sets_exts']);
1188 1240
 		$set_names = explode("\n", $modSettings['smiley_sets_names']);
1189
-		foreach ($context['smiley_sets'] as $i => $set)
1190
-			$context['smiley_sets'][$i] = array(
1241
+		foreach ($context['smiley_sets'] as $i => $set) {
1242
+					$context['smiley_sets'][$i] = array(
1191 1243
 				'id' => $i,
1192 1244
 				'path' => $smcFunc['htmlspecialchars']($set),
1193 1245
 				'name' => $smcFunc['htmlspecialchars']($set_names[$i]),
1194 1246
 				'ext' => $smcFunc['htmlspecialchars']($set_exts[$i]),
1195 1247
 				'selected' => $set == $modSettings['smiley_sets_default']
1196 1248
 			);
1249
+		}
1197 1250
 
1198 1251
 		$context['selected_set'] = $modSettings['smiley_sets_default'];
1199 1252
 
@@ -1203,19 +1256,21 @@  discard block
 block discarded – undo
1203 1256
 		{
1204 1257
 			foreach ($context['smiley_sets'] as $smiley_set)
1205 1258
 			{
1206
-				if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path'])))
1207
-					continue;
1259
+				if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']))) {
1260
+									continue;
1261
+				}
1208 1262
 
1209 1263
 				$dir = dir($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']));
1210 1264
 				while ($entry = $dir->read())
1211 1265
 				{
1212 1266
 					// Strip extension
1213 1267
 					$filename = pathinfo($entry, PATHINFO_FILENAME);
1214
-					if (!in_array($filename, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png', '.svg')))
1215
-						$context['filenames'][strtolower($filename)] = array(
1268
+					if (!in_array($filename, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png', '.svg'))) {
1269
+											$context['filenames'][strtolower($filename)] = array(
1216 1270
 							'id' => $smcFunc['htmlspecialchars']($filename),
1217 1271
 							'selected' => false,
1218 1272
 						);
1273
+					}
1219 1274
 				}
1220 1275
 				$dir->close();
1221 1276
 			}
@@ -1230,8 +1285,9 @@  discard block
 block discarded – undo
1230 1285
 				'current_smiley' => (int) $_REQUEST['smiley'],
1231 1286
 			)
1232 1287
 		);
1233
-		if ($smcFunc['db_num_rows']($request) != 1)
1234
-			fatal_lang_error('smiley_not_found');
1288
+		if ($smcFunc['db_num_rows']($request) != 1) {
1289
+					fatal_lang_error('smiley_not_found');
1290
+		}
1235 1291
 		$context['current_smiley'] = $smcFunc['db_fetch_assoc']($request);
1236 1292
 		$smcFunc['db_free_result']($request);
1237 1293
 
@@ -1239,8 +1295,9 @@  discard block
 block discarded – undo
1239 1295
 		$context['current_smiley']['filename'] = $smcFunc['htmlspecialchars']($context['current_smiley']['filename']);
1240 1296
 		$context['current_smiley']['description'] = $smcFunc['htmlspecialchars']($context['current_smiley']['description']);
1241 1297
 
1242
-		if (isset($context['filenames'][strtolower($context['current_smiley']['filename'])]))
1243
-			$context['filenames'][strtolower($context['current_smiley']['filename'])]['selected'] = true;
1298
+		if (isset($context['filenames'][strtolower($context['current_smiley']['filename'])])) {
1299
+					$context['filenames'][strtolower($context['current_smiley']['filename'])]['selected'] = true;
1300
+		}
1244 1301
 	}
1245 1302
 }
1246 1303
 
@@ -1265,8 +1322,9 @@  discard block
 block discarded – undo
1265 1322
 		)
1266 1323
 	);
1267 1324
 	$smileys = array();
1268
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1269
-		$smileys[] = $row;
1325
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1326
+			$smileys[] = $row;
1327
+	}
1270 1328
 	$smcFunc['db_free_result']($request);
1271 1329
 
1272 1330
 	return $smileys;
@@ -1306,8 +1364,9 @@  discard block
 block discarded – undo
1306 1364
 		$_GET['location'] = empty($_GET['location']) || $_GET['location'] != 'popup' ? 0 : 2;
1307 1365
 		$_GET['source'] = empty($_GET['source']) ? 0 : (int) $_GET['source'];
1308 1366
 
1309
-		if (empty($_GET['source']))
1310
-			fatal_lang_error('smiley_not_found');
1367
+		if (empty($_GET['source'])) {
1368
+					fatal_lang_error('smiley_not_found');
1369
+		}
1311 1370
 
1312 1371
 		if (!empty($_GET['after']))
1313 1372
 		{
@@ -1323,12 +1382,12 @@  discard block
 block discarded – undo
1323 1382
 					'after_smiley' => $_GET['after'],
1324 1383
 				)
1325 1384
 			);
1326
-			if ($smcFunc['db_num_rows']($request) != 1)
1327
-				fatal_lang_error('smiley_not_found');
1385
+			if ($smcFunc['db_num_rows']($request) != 1) {
1386
+							fatal_lang_error('smiley_not_found');
1387
+			}
1328 1388
 			list ($smiley_row, $smiley_order, $smileyLocation) = $smcFunc['db_fetch_row']($request);
1329 1389
 			$smcFunc['db_free_result']($request);
1330
-		}
1331
-		else
1390
+		} else
1332 1391
 		{
1333 1392
 			$smiley_row = (int) $_GET['row'];
1334 1393
 			$smiley_order = -1;
@@ -1402,14 +1461,15 @@  discard block
 block discarded – undo
1402 1461
 	$context['move_smiley'] = empty($_REQUEST['move']) ? 0 : (int) $_REQUEST['move'];
1403 1462
 
1404 1463
 	// Make sure all rows are sequential.
1405
-	foreach (array_keys($context['smileys']) as $location)
1406
-		$context['smileys'][$location] = array(
1464
+	foreach (array_keys($context['smileys']) as $location) {
1465
+			$context['smileys'][$location] = array(
1407 1466
 			'id' => $location,
1408 1467
 			'title' => $location == 'postform' ? $txt['smileys_location_form'] : $txt['smileys_location_popup'],
1409 1468
 			'description' => $location == 'postform' ? $txt['smileys_location_form_description'] : $txt['smileys_location_popup_description'],
1410 1469
 			'last_row' => count($context['smileys'][$location]['rows']),
1411 1470
 			'rows' => array_values($context['smileys'][$location]['rows']),
1412 1471
 		);
1472
+	}
1413 1473
 
1414 1474
 	// Check & fix smileys that are not ordered properly in the database.
1415 1475
 	foreach (array_keys($context['smileys']) as $location)
@@ -1434,8 +1494,8 @@  discard block
 block discarded – undo
1434 1494
 				$context['smileys'][$location]['rows'][$id][0]['row'] = $id;
1435 1495
 			}
1436 1496
 			// Make sure the smiley order is always sequential.
1437
-			foreach ($smiley_row as $order_id => $smiley)
1438
-				if ($order_id != $smiley['order'])
1497
+			foreach ($smiley_row as $order_id => $smiley) {
1498
+							if ($order_id != $smiley['order'])
1439 1499
 					$smcFunc['db_query']('', '
1440 1500
 						UPDATE {db_prefix}smileys
1441 1501
 						SET smiley_order = {int:new_order}
@@ -1445,6 +1505,7 @@  discard block
 block discarded – undo
1445 1505
 							'current_smiley' => $smiley['id'],
1446 1506
 						)
1447 1507
 					);
1508
+			}
1448 1509
 		}
1449 1510
 	}
1450 1511
 
@@ -1478,19 +1539,20 @@  discard block
 block discarded – undo
1478 1539
 
1479 1540
 		// Check that the smiley is from simplemachines.org, for now... maybe add mirroring later.
1480 1541
 		// @ TODO: Our current xml files serve http links.  Allowing both for now until we serve https.
1481
-		if (preg_match('~^https?://[\w_\-]+\.simplemachines\.org/~', $_REQUEST['set_gz']) == 0 || strpos($_REQUEST['set_gz'], 'dlattach') !== false)
1482
-			fatal_lang_error('not_on_simplemachines');
1542
+		if (preg_match('~^https?://[\w_\-]+\.simplemachines\.org/~', $_REQUEST['set_gz']) == 0 || strpos($_REQUEST['set_gz'], 'dlattach') !== false) {
1543
+					fatal_lang_error('not_on_simplemachines');
1544
+		}
1483 1545
 
1484 1546
 		$destination = $packagesdir . '/' . $base_name;
1485 1547
 
1486
-		if (file_exists($destination))
1487
-			fatal_lang_error('package_upload_error_exists');
1548
+		if (file_exists($destination)) {
1549
+					fatal_lang_error('package_upload_error_exists');
1550
+		}
1488 1551
 
1489 1552
 		// Let's copy it to the Packages directory
1490 1553
 		file_put_contents($destination, fetch_web_data($_REQUEST['set_gz']));
1491 1554
 		$testing = true;
1492
-	}
1493
-	elseif (isset($_REQUEST['package']))
1555
+	} elseif (isset($_REQUEST['package']))
1494 1556
 	{
1495 1557
 		$base_name = basename($_REQUEST['package']);
1496 1558
 		$name = $smcFunc['htmlspecialchars'](strtok(basename($_REQUEST['package']), '.'));
@@ -1499,12 +1561,14 @@  discard block
 block discarded – undo
1499 1561
 		$destination = $packagesdir . '/' . basename($_REQUEST['package']);
1500 1562
 	}
1501 1563
 
1502
-	if (empty($destination) || !file_exists($destination))
1503
-		fatal_lang_error('package_no_file', false);
1564
+	if (empty($destination) || !file_exists($destination)) {
1565
+			fatal_lang_error('package_no_file', false);
1566
+	}
1504 1567
 
1505 1568
 	// Make sure temp directory exists and is empty.
1506
-	if (file_exists($packagesdir . '/temp'))
1507
-		deltree($packagesdir . '/temp', false);
1569
+	if (file_exists($packagesdir . '/temp')) {
1570
+			deltree($packagesdir . '/temp', false);
1571
+	}
1508 1572
 
1509 1573
 	if (!mktree($packagesdir . '/temp', 0755))
1510 1574
 	{
@@ -1516,31 +1580,37 @@  discard block
 block discarded – undo
1516 1580
 			create_chmod_control(array($packagesdir . '/temp/delme.tmp'), array('destination_url' => $scripturl . '?action=admin;area=smileys;sa=install;set_gz=' . $_REQUEST['set_gz'], 'crash_on_error' => true));
1517 1581
 
1518 1582
 			deltree($packagesdir . '/temp', false);
1519
-			if (!mktree($packagesdir . '/temp', 0777))
1520
-				fatal_lang_error('package_cant_download', false);
1583
+			if (!mktree($packagesdir . '/temp', 0777)) {
1584
+							fatal_lang_error('package_cant_download', false);
1585
+			}
1521 1586
 		}
1522 1587
 	}
1523 1588
 
1524 1589
 	$extracted = read_tgz_file($destination, $packagesdir . '/temp');
1525
-	if (!$extracted)
1526
-		fatal_lang_error('packageget_unable', false, array('https://custom.simplemachines.org/mods/index.php?action=search;type=12;basic_search=' . $name));
1527
-	if ($extracted && !file_exists($packagesdir . '/temp/package-info.xml'))
1528
-		foreach ($extracted as $file)
1590
+	if (!$extracted) {
1591
+			fatal_lang_error('packageget_unable', false, array('https://custom.simplemachines.org/mods/index.php?action=search;type=12;basic_search=' . $name));
1592
+	}
1593
+	if ($extracted && !file_exists($packagesdir . '/temp/package-info.xml')) {
1594
+			foreach ($extracted as $file)
1529 1595
 			if (basename($file['filename']) == 'package-info.xml')
1530 1596
 			{
1531 1597
 				$base_path = dirname($file['filename']) . '/';
1598
+	}
1532 1599
 				break;
1533 1600
 			}
1534 1601
 
1535
-	if (!isset($base_path))
1536
-		$base_path = '';
1602
+	if (!isset($base_path)) {
1603
+			$base_path = '';
1604
+	}
1537 1605
 
1538
-	if (!file_exists($packagesdir . '/temp/' . $base_path . 'package-info.xml'))
1539
-		fatal_lang_error('package_get_error_missing_xml', false);
1606
+	if (!file_exists($packagesdir . '/temp/' . $base_path . 'package-info.xml')) {
1607
+			fatal_lang_error('package_get_error_missing_xml', false);
1608
+	}
1540 1609
 
1541 1610
 	$smileyInfo = getPackageInfo($context['filename']);
1542
-	if (!is_array($smileyInfo))
1543
-		fatal_lang_error($smileyInfo);
1611
+	if (!is_array($smileyInfo)) {
1612
+			fatal_lang_error($smileyInfo);
1613
+	}
1544 1614
 
1545 1615
 	// See if it is installed?
1546 1616
 	$request = $smcFunc['db_query']('', '
@@ -1556,8 +1626,9 @@  discard block
 block discarded – undo
1556 1626
 		)
1557 1627
 	);
1558 1628
 
1559
-	if ($smcFunc['db_num_rows']($request) > 0)
1560
-		fatal_lang_error('package_installed_warning1');
1629
+	if ($smcFunc['db_num_rows']($request) > 0) {
1630
+			fatal_lang_error('package_installed_warning1');
1631
+	}
1561 1632
 
1562 1633
 	// Everything is fine, now it's time to do something
1563 1634
 	$actions = parsePackageInfo($smileyInfo['xml'], true, 'install');
@@ -1572,23 +1643,23 @@  discard block
 block discarded – undo
1572 1643
 		if ($action['type'] == 'readme' || $action['type'] == 'license')
1573 1644
 		{
1574 1645
 			$type = 'package_' . $action['type'];
1575
-			if (file_exists($packagesdir . '/temp/' . $base_path . $action['filename']))
1576
-				$context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($packagesdir . '/temp/' . $base_path . $action['filename']), "\n\r"));
1577
-			elseif (file_exists($action['filename']))
1578
-				$context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($action['filename']), "\n\r"));
1646
+			if (file_exists($packagesdir . '/temp/' . $base_path . $action['filename'])) {
1647
+							$context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($packagesdir . '/temp/' . $base_path . $action['filename']), "\n\r"));
1648
+			} elseif (file_exists($action['filename'])) {
1649
+							$context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($action['filename']), "\n\r"));
1650
+			}
1579 1651
 
1580 1652
 			if (!empty($action['parse_bbc']))
1581 1653
 			{
1582 1654
 				require_once($sourcedir . '/Subs-Post.php');
1583 1655
 				preparsecode($context[$type]);
1584 1656
 				$context[$type] = parse_bbc($context[$type]);
1657
+			} else {
1658
+							$context[$type] = nl2br($context[$type]);
1585 1659
 			}
1586
-			else
1587
-				$context[$type] = nl2br($context[$type]);
1588 1660
 
1589 1661
 			continue;
1590
-		}
1591
-		elseif ($action['type'] == 'require-dir')
1662
+		} elseif ($action['type'] == 'require-dir')
1592 1663
 		{
1593 1664
 			// Do this one...
1594 1665
 			$thisAction = array(
@@ -1607,12 +1678,12 @@  discard block
 block discarded – undo
1607 1678
 				);
1608 1679
 			}
1609 1680
 			// @todo None given?
1610
-			if (empty($thisAction['description']))
1611
-				$thisAction['description'] = isset($action['description']) ? $action['description'] : '';
1681
+			if (empty($thisAction['description'])) {
1682
+							$thisAction['description'] = isset($action['description']) ? $action['description'] : '';
1683
+			}
1612 1684
 
1613 1685
 			$context['actions'][] = $thisAction;
1614
-		}
1615
-		elseif ($action['type'] == 'credits')
1686
+		} elseif ($action['type'] == 'credits')
1616 1687
 		{
1617 1688
 			// Time to build the billboard
1618 1689
 			$credits_tag = array(
@@ -1672,12 +1743,14 @@  discard block
 block discarded – undo
1672 1743
 		cache_put_data('posting_smileys', null, 480);
1673 1744
 	}
1674 1745
 
1675
-	if (file_exists($packagesdir . '/temp'))
1676
-		deltree($packagesdir . '/temp');
1746
+	if (file_exists($packagesdir . '/temp')) {
1747
+			deltree($packagesdir . '/temp');
1748
+	}
1677 1749
 
1678
-	if (!$testing)
1679
-		redirectexit('action=admin;area=smileys');
1680
-}
1750
+	if (!$testing) {
1751
+			redirectexit('action=admin;area=smileys');
1752
+	}
1753
+	}
1681 1754
 
1682 1755
 /**
1683 1756
  * A function to import new smileys from an existing directory into the database.
@@ -1688,16 +1761,18 @@  discard block
 block discarded – undo
1688 1761
 {
1689 1762
 	global $modSettings, $smcFunc;
1690 1763
 
1691
-	if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'] . '/' . $smileyPath))
1692
-		fatal_lang_error('smiley_set_unable_to_import');
1764
+	if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'] . '/' . $smileyPath)) {
1765
+			fatal_lang_error('smiley_set_unable_to_import');
1766
+	}
1693 1767
 
1694 1768
 	$smileys = array();
1695 1769
 	$dir = dir($modSettings['smileys_dir'] . '/' . $smileyPath);
1696 1770
 	while ($entry = $dir->read())
1697 1771
 	{
1698 1772
 		$filename = pathinfo($entry, PATHINFO_FILENAME);
1699
-		if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png', '.svg')))
1700
-			$smileys[strtolower($filename)] = $filename;
1773
+		if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png', '.svg'))) {
1774
+					$smileys[strtolower($filename)] = $filename;
1775
+		}
1701 1776
 	}
1702 1777
 	$dir->close();
1703 1778
 
@@ -1710,9 +1785,10 @@  discard block
 block discarded – undo
1710 1785
 			'smiley_list' => $smileys,
1711 1786
 		)
1712 1787
 	);
1713
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1714
-		if (isset($smileys[strtolower($row['filename'])]))
1788
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1789
+			if (isset($smileys[strtolower($row['filename'])]))
1715 1790
 			unset($smileys[strtolower($row['filename'])]);
1791
+	}
1716 1792
 	$smcFunc['db_free_result']($request);
1717 1793
 
1718 1794
 	$request = $smcFunc['db_query']('', '
@@ -1729,9 +1805,10 @@  discard block
 block discarded – undo
1729 1805
 	$smcFunc['db_free_result']($request);
1730 1806
 
1731 1807
 	$new_smileys = array();
1732
-	foreach ($smileys as $smiley)
1733
-		if (strlen($smiley) <= 48)
1808
+	foreach ($smileys as $smiley) {
1809
+			if (strlen($smiley) <= 48)
1734 1810
 			$new_smileys[] = array(':' . strtok($smiley, '.') . ':', $smiley, strtok($smiley, '.'), 0, ++$smiley_order);
1811
+	}
1735 1812
 
1736 1813
 	if (!empty($new_smileys))
1737 1814
 	{
@@ -1796,8 +1873,9 @@  discard block
 block discarded – undo
1796 1873
 		if (isset($_POST['delete']) && !empty($_POST['checked_icons']))
1797 1874
 		{
1798 1875
 			$deleteIcons = array();
1799
-			foreach ($_POST['checked_icons'] as $icon)
1800
-				$deleteIcons[] = (int) $icon;
1876
+			foreach ($_POST['checked_icons'] as $icon) {
1877
+							$deleteIcons[] = (int) $icon;
1878
+			}
1801 1879
 
1802 1880
 			// Do the actual delete!
1803 1881
 			$smcFunc['db_query']('', '
@@ -1814,35 +1892,41 @@  discard block
 block discarded – undo
1814 1892
 			$_GET['icon'] = (int) $_GET['icon'];
1815 1893
 
1816 1894
 			// Do some preperation with the data... like check the icon exists *somewhere*
1817
-			if (strpos($_POST['icon_filename'], '.png') !== false)
1818
-				$_POST['icon_filename'] = substr($_POST['icon_filename'], 0, -4);
1819
-			if (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon_filename'] . '.png'))
1820
-				fatal_lang_error('icon_not_found');
1895
+			if (strpos($_POST['icon_filename'], '.png') !== false) {
1896
+							$_POST['icon_filename'] = substr($_POST['icon_filename'], 0, -4);
1897
+			}
1898
+			if (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon_filename'] . '.png')) {
1899
+							fatal_lang_error('icon_not_found');
1900
+			}
1821 1901
 			// There is a 16 character limit on message icons...
1822
-			elseif (strlen($_POST['icon_filename']) > 16)
1823
-				fatal_lang_error('icon_name_too_long');
1824
-			elseif ($_POST['icon_location'] == $_GET['icon'] && !empty($_GET['icon']))
1825
-				fatal_lang_error('icon_after_itself');
1902
+			elseif (strlen($_POST['icon_filename']) > 16) {
1903
+							fatal_lang_error('icon_name_too_long');
1904
+			} elseif ($_POST['icon_location'] == $_GET['icon'] && !empty($_GET['icon'])) {
1905
+							fatal_lang_error('icon_after_itself');
1906
+			}
1826 1907
 
1827 1908
 			// First do the sorting... if this is an edit reduce the order of everything after it by one ;)
1828 1909
 			if ($_GET['icon'] != 0)
1829 1910
 			{
1830 1911
 				$oldOrder = $context['icons'][$_GET['icon']]['true_order'];
1831
-				foreach ($context['icons'] as $id => $data)
1832
-					if ($data['true_order'] > $oldOrder)
1912
+				foreach ($context['icons'] as $id => $data) {
1913
+									if ($data['true_order'] > $oldOrder)
1833 1914
 						$context['icons'][$id]['true_order']--;
1915
+				}
1834 1916
 			}
1835 1917
 
1836 1918
 			// If there are no existing icons and this is a new one, set the id to 1 (mainly for non-mysql)
1837
-			if (empty($_GET['icon']) && empty($context['icons']))
1838
-				$_GET['icon'] = 1;
1919
+			if (empty($_GET['icon']) && empty($context['icons'])) {
1920
+							$_GET['icon'] = 1;
1921
+			}
1839 1922
 
1840 1923
 			// Get the new order.
1841 1924
 			$newOrder = $_POST['icon_location'] == 0 ? 0 : $context['icons'][$_POST['icon_location']]['true_order'] + 1;
1842 1925
 			// Do the same, but with the one that used to be after this icon, done to avoid conflict.
1843
-			foreach ($context['icons'] as $id => $data)
1844
-				if ($data['true_order'] >= $newOrder)
1926
+			foreach ($context['icons'] as $id => $data) {
1927
+							if ($data['true_order'] >= $newOrder)
1845 1928
 					$context['icons'][$id]['true_order']++;
1929
+			}
1846 1930
 
1847 1931
 			// Finally set the current icon's position!
1848 1932
 			$context['icons'][$_GET['icon']]['true_order'] = $newOrder;
@@ -1860,8 +1944,7 @@  discard block
 block discarded – undo
1860 1944
 				if ($id != 0)
1861 1945
 				{
1862 1946
 					$iconInsert[] = array($id, $icon['board_id'], $icon['title'], $icon['filename'], $icon['true_order']);
1863
-				}
1864
-				else
1947
+				} else
1865 1948
 				{
1866 1949
 					$iconInsert_new[] = array($icon['board_id'], $icon['title'], $icon['filename'], $icon['true_order']);
1867 1950
 				}
@@ -1886,8 +1969,9 @@  discard block
 block discarded – undo
1886 1969
 		}
1887 1970
 
1888 1971
 		// Unless we're adding a new thing, we'll escape
1889
-		if (!isset($_POST['add']))
1890
-			redirectexit('action=admin;area=smileys;sa=editicons');
1972
+		if (!isset($_POST['add'])) {
1973
+					redirectexit('action=admin;area=smileys;sa=editicons');
1974
+		}
1891 1975
 	}
1892 1976
 
1893 1977
 	$context[$context['admin_menu_name']]['current_subsection'] = 'editicons';
@@ -1997,8 +2081,9 @@  discard block
 block discarded – undo
1997 2081
 		$context['new_icon'] = !isset($_GET['icon']);
1998 2082
 
1999 2083
 		// Get the properties of the current icon from the icon list.
2000
-		if (!$context['new_icon'])
2001
-			$context['icon'] = $context['icons'][$_GET['icon']];
2084
+		if (!$context['new_icon']) {
2085
+					$context['icon'] = $context['icons'][$_GET['icon']];
2086
+		}
2002 2087
 
2003 2088
 		// Get a list of boards needed for assigning this icon to a specific board.
2004 2089
 		$boardListOptions = array(
@@ -2032,8 +2117,9 @@  discard block
 block discarded – undo
2032 2117
 	);
2033 2118
 
2034 2119
 	$message_icons = array();
2035
-	while ($row = $smcFunc['db_fetch_assoc']($request))
2036
-		$message_icons[] = $row;
2120
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
2121
+			$message_icons[] = $row;
2122
+	}
2037 2123
 	$smcFunc['db_free_result']($request);
2038 2124
 
2039 2125
 	return $message_icons;
Please login to merge, or discard this patch.
Sources/tasks/CreatePost-Notify.php 1 patch
Braces   +74 added lines, -54 removed lines patch added patch discarded remove patch
@@ -96,8 +96,9 @@  discard block
 block discarded – undo
96 96
 		while ($row = $smcFunc['db_fetch_assoc']($request))
97 97
 		{
98 98
 			$groups = array_merge(array($row['id_group'], $row['id_post_group']), (empty($row['additional_groups']) ? array() : explode(',', $row['additional_groups'])));
99
-			if (!in_array(1, $groups) && count(array_intersect($groups, explode(',', $row['member_groups']))) == 0)
100
-				continue;
99
+			if (!in_array(1, $groups) && count(array_intersect($groups, explode(',', $row['member_groups']))) == 0) {
100
+							continue;
101
+			}
101 102
 
102 103
 			$members[] = $row['id_member'];
103 104
 			$watched[$row['id_member']] = $row;
@@ -105,8 +106,9 @@  discard block
 block discarded – undo
105 106
 
106 107
 		$smcFunc['db_free_result']($request);
107 108
 
108
-		if (empty($members))
109
-			return true;
109
+		if (empty($members)) {
110
+					return true;
111
+		}
110 112
 
111 113
 		$members = array_unique($members);
112 114
 		$prefs = getNotifyPrefs($members, '', true);
@@ -122,8 +124,9 @@  discard block
 block discarded – undo
122 124
 		self::handleQuoteNotifications($msgOptions, $posterOptions, $quotedMembers, $prefs, $done_members, $alert_rows);
123 125
 
124 126
 		// Save ourselves a bit of work in the big loop below
125
-		foreach ($done_members as $done_member)
126
-			unset($watched[$done_member]);
127
+		foreach ($done_members as $done_member) {
128
+					unset($watched[$done_member]);
129
+		}
127 130
 
128 131
 		// Handle rest of the notifications for watched topics and boards
129 132
 		foreach ($watched as $member => $data)
@@ -132,26 +135,31 @@  discard block
 block discarded – undo
132 135
 			$notify_types = !empty($prefs[$member]['msg_notify_type']) ? $prefs[$member]['msg_notify_type'] : self::NOTIFY_TYPE_REPLY_AND_MODIFY;
133 136
 
134 137
 			// Don't send a notification if the watching member ignored the member who made the action.
135
-			if (!empty($data['pm_ignore_list']) && in_array($data['id_member_updated'], explode(',', $data['pm_ignore_list'])))
136
-				continue;
137
-			if (!in_array($type, array('reply', 'topic')) && $notify_types == self::NOTIFY_TYPE_REPLY_AND_TOPIC_START_FOLLOWING && $member != $data['id_member_started'])
138
-				continue;
139
-			elseif (in_array($type, array('reply', 'topic')) && $member == $posterOptions['id'])
140
-				continue;
141
-			elseif (!in_array($type, array('reply', 'topic')) && $notify_types == self::NOTIFY_TYPE_ONLY_REPLIES)
142
-				continue;
143
-			elseif ($notify_types == self::NOTIFY_TYPE_NOTHING)
144
-				continue;
138
+			if (!empty($data['pm_ignore_list']) && in_array($data['id_member_updated'], explode(',', $data['pm_ignore_list']))) {
139
+							continue;
140
+			}
141
+			if (!in_array($type, array('reply', 'topic')) && $notify_types == self::NOTIFY_TYPE_REPLY_AND_TOPIC_START_FOLLOWING && $member != $data['id_member_started']) {
142
+							continue;
143
+			} elseif (in_array($type, array('reply', 'topic')) && $member == $posterOptions['id']) {
144
+							continue;
145
+			} elseif (!in_array($type, array('reply', 'topic')) && $notify_types == self::NOTIFY_TYPE_ONLY_REPLIES) {
146
+							continue;
147
+			} elseif ($notify_types == self::NOTIFY_TYPE_NOTHING) {
148
+							continue;
149
+			}
145 150
 
146 151
 			// Don't send a notification if they don't want any...
147
-			if (in_array($frequency, array(self::FREQUENCY_NOTHING, self::FREQUENCY_DAILY_DIGEST, self::FREQUENCY_WEEKLY_DIGEST)))
148
-				continue;
152
+			if (in_array($frequency, array(self::FREQUENCY_NOTHING, self::FREQUENCY_DAILY_DIGEST, self::FREQUENCY_WEEKLY_DIGEST))) {
153
+							continue;
154
+			}
149 155
 			// ... or if we already sent one and they don't want more...
150
-			elseif ($frequency === self::FREQUENCY_FIRST_UNREAD_MSG && $data['sent'])
151
-				continue;
156
+			elseif ($frequency === self::FREQUENCY_FIRST_UNREAD_MSG && $data['sent']) {
157
+							continue;
158
+			}
152 159
 			// ... or if they aren't on the bouncer's list.
153
-			elseif (!empty($this->_details['members_only']) && !in_array($member, $this->_details['members_only']))
154
-				continue;
160
+			elseif (!empty($this->_details['members_only']) && !in_array($member, $this->_details['members_only'])) {
161
+							continue;
162
+			}
155 163
 
156 164
 			// Watched topic?
157 165
 			if (!empty($data['id_topic']) && $type != 'topic' && !empty($prefs[$member]))
@@ -161,10 +169,12 @@  discard block
 block discarded – undo
161 169
 
162 170
 				if ($type == 'reply')
163 171
 				{
164
-					if (!empty($prefs[$member]['msg_receive_body']))
165
-						$message_type .= '_body';
166
-					if (!empty($frequency))
167
-						$message_type .= '_once';
172
+					if (!empty($prefs[$member]['msg_receive_body'])) {
173
+											$message_type .= '_body';
174
+					}
175
+					if (!empty($frequency)) {
176
+											$message_type .= '_once';
177
+					}
168 178
 				}
169 179
 
170 180
 				$content_type = 'topic';
@@ -177,12 +187,14 @@  discard block
 block discarded – undo
177 187
 				$content_type = 'board';
178 188
 
179 189
 				$message_type = !empty($frequency) ? 'notify_boards_once' : 'notify_boards';
180
-				if (!empty($prefs[$member]['msg_receive_body']))
181
-					$message_type .= '_body';
190
+				if (!empty($prefs[$member]['msg_receive_body'])) {
191
+									$message_type .= '_body';
192
+				}
182 193
 			}
183 194
 			// If neither of the above, this might be a redundent row due to the OR clause in our SQL query, skip
184
-			else
185
-				continue;
195
+			else {
196
+							continue;
197
+			}
186 198
 
187 199
 			// Bitwise check: Receiving a email notification?
188 200
 			if ($pref & self::RECEIVE_NOTIFY_EMAIL)
@@ -199,8 +211,9 @@  discard block
 block discarded – undo
199 211
 				$mail_result = sendmail($data['email_address'], $emaildata['subject'], $emaildata['body'], null, 'm' . $topicOptions['id'], $emaildata['is_html']);
200 212
 
201 213
 				// We failed, don't trigger a alert as we don't have a way to attempt to resend just the email currently.
202
-				if ($mail_result === false)
203
-					continue;
214
+				if ($mail_result === false) {
215
+									continue;
216
+				}
204 217
 			}
205 218
 
206 219
 			// Bitwise check: Receiving a alert?
@@ -251,14 +264,15 @@  discard block
 block discarded – undo
251 264
 		);
252 265
 
253 266
 		// Insert the alerts if any
254
-		if (!empty($alert_rows))
255
-			$smcFunc['db_insert']('',
267
+		if (!empty($alert_rows)) {
268
+					$smcFunc['db_insert']('',
256 269
 				'{db_prefix}user_alerts',
257 270
 				array('alert_time' => 'int', 'id_member' => 'int', 'id_member_started' => 'int', 'member_name' => 'string',
258 271
 					'content_type' => 'string', 'content_id' => 'int', 'content_action' => 'string', 'is_read' => 'int', 'extra' => 'string'),
259 272
 				$alert_rows,
260 273
 				array()
261 274
 			);
275
+		}
262 276
 
263 277
 		return true;
264 278
 	}
@@ -269,8 +283,9 @@  discard block
 block discarded – undo
269 283
 
270 284
 		foreach ($quotedMembers as $id => $member)
271 285
 		{
272
-			if (!isset($prefs[$id]) || $id == $posterOptions['id'] || empty($prefs[$id]['msg_quote']))
273
-				continue;
286
+			if (!isset($prefs[$id]) || $id == $posterOptions['id'] || empty($prefs[$id]['msg_quote'])) {
287
+							continue;
288
+			}
274 289
 
275 290
 			$done_members[] = $id;
276 291
 
@@ -324,32 +339,35 @@  discard block
 block discarded – undo
324 339
 		{
325 340
 			if (preg_match('/\[quote(.*)?\]/i', $block, $matches))
326 341
 			{
327
-				if ($quote_level == 0)
328
-					$message .= '[quote' . $matches[1] . ']';
342
+				if ($quote_level == 0) {
343
+									$message .= '[quote' . $matches[1] . ']';
344
+				}
329 345
 				$quote_level++;
330
-			}
331
-			elseif (preg_match('/\[\/quote\]/i', $block))
346
+			} elseif (preg_match('/\[\/quote\]/i', $block))
332 347
 			{
333
-				if ($quote_level <= 1)
334
-					$message .= '[/quote]';
348
+				if ($quote_level <= 1) {
349
+									$message .= '[/quote]';
350
+				}
335 351
 				if ($quote_level >= 1)
336 352
 				{
337 353
 					$quote_level--;
338 354
 					$message .= "\n";
339 355
 				}
356
+			} elseif ($quote_level <= 1) {
357
+							$message .= $block;
340 358
 			}
341
-			elseif ($quote_level <= 1)
342
-				$message .= $block;
343 359
 		}
344 360
 
345 361
 		preg_match_all('/\[quote.*?link=msg=([0-9]+).*?\]/i', $message, $matches);
346 362
 
347 363
 		$id_msgs = $matches[1];
348
-		foreach ($id_msgs as $k => $id_msg)
349
-			$id_msgs[$k] = (int) $id_msg;
364
+		foreach ($id_msgs as $k => $id_msg) {
365
+					$id_msgs[$k] = (int) $id_msg;
366
+		}
350 367
 
351
-		if (empty($id_msgs))
352
-			return array();
368
+		if (empty($id_msgs)) {
369
+					return array();
370
+		}
353 371
 
354 372
 		// Get the messages
355 373
 		$request = $smcFunc['db_query']('', '
@@ -367,8 +385,9 @@  discard block
 block discarded – undo
367 385
 		$members = array();
368 386
 		while ($row = $smcFunc['db_fetch_assoc']($request))
369 387
 		{
370
-			if ($posterOptions['id'] == $row['id_member'])
371
-				continue;
388
+			if ($posterOptions['id'] == $row['id_member']) {
389
+							continue;
390
+			}
372 391
 
373 392
 			$members[$row['id_member']] = $row;
374 393
 		}
@@ -382,10 +401,11 @@  discard block
 block discarded – undo
382 401
 
383 402
 		foreach ($members as $id => $member)
384 403
 		{
385
-			if (!empty($prefs[$id]['msg_mention']))
386
-				$done_members[] = $id;
387
-			else
388
-				continue;
404
+			if (!empty($prefs[$id]['msg_mention'])) {
405
+							$done_members[] = $id;
406
+			} else {
407
+							continue;
408
+			}
389 409
 
390 410
 			// Alerts' emails are always instant
391 411
 			if ($prefs[$id]['msg_mention'] & self::RECEIVE_NOTIFY_EMAIL)
Please login to merge, or discard this patch.
Sources/Post.php 1 patch
Braces   +677 added lines, -523 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
  * Handles showing the post screen, loading the post to be modified, and loading any post quoted.
@@ -35,12 +36,14 @@  discard block
 block discarded – undo
35 36
 	global $sourcedir, $smcFunc, $language;
36 37
 
37 38
 	loadLanguage('Post');
38
-	if (!empty($modSettings['drafts_post_enabled']))
39
-		loadLanguage('Drafts');
39
+	if (!empty($modSettings['drafts_post_enabled'])) {
40
+			loadLanguage('Drafts');
41
+	}
40 42
 
41 43
 	// You can't reply with a poll... hacker.
42
-	if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg']))
43
-		unset($_REQUEST['poll']);
44
+	if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg'])) {
45
+			unset($_REQUEST['poll']);
46
+	}
44 47
 
45 48
 	// Posting an event?
46 49
 	$context['make_event'] = isset($_REQUEST['calendar']);
@@ -60,12 +63,14 @@  discard block
 block discarded – undo
60 63
 	{
61 64
 		// Get ids of all the boards they can post in.
62 65
 		$post_permissions = array('post_new');
63
-		if ($modSettings['postmod_active'])
64
-			$post_permissions[] = 'post_unapproved_topics';
66
+		if ($modSettings['postmod_active']) {
67
+					$post_permissions[] = 'post_unapproved_topics';
68
+		}
65 69
 
66 70
 		$boards = boardsAllowedTo($post_permissions);
67
-		if (empty($boards))
68
-			fatal_lang_error('cannot_post_new', false);
71
+		if (empty($boards)) {
72
+					fatal_lang_error('cannot_post_new', false);
73
+		}
69 74
 
70 75
 		// Get a list of boards for the select menu
71 76
 		require_once($sourcedir . '/Subs-MessageIndex.php');
@@ -78,8 +83,9 @@  discard block
 block discarded – undo
78 83
 		$board_list = getBoardList($boardListOptions);
79 84
 	}
80 85
 	// Let's keep things simple for ourselves below
81
-	else
82
-		$boards = array($board);
86
+	else {
87
+			$boards = array($board);
88
+	}
83 89
 
84 90
 	require_once($sourcedir . '/Subs-Post.php');
85 91
 
@@ -102,10 +108,11 @@  discard block
 block discarded – undo
102 108
 			array(
103 109
 				'msg' => (int) $_REQUEST['msg'],
104 110
 		));
105
-		if ($smcFunc['db_num_rows']($request) != 1)
106
-			unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']);
107
-		else
108
-			list ($topic) = $smcFunc['db_fetch_row']($request);
111
+		if ($smcFunc['db_num_rows']($request) != 1) {
112
+					unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']);
113
+		} else {
114
+					list ($topic) = $smcFunc['db_fetch_row']($request);
115
+		}
109 116
 		$smcFunc['db_free_result']($request);
110 117
 	}
111 118
 
@@ -132,33 +139,36 @@  discard block
 block discarded – undo
132 139
 		$smcFunc['db_free_result']($request);
133 140
 
134 141
 		// If this topic already has a poll, they sure can't add another.
135
-		if (isset($_REQUEST['poll']) && $pollID > 0)
136
-			unset($_REQUEST['poll']);
142
+		if (isset($_REQUEST['poll']) && $pollID > 0) {
143
+					unset($_REQUEST['poll']);
144
+		}
137 145
 
138 146
 		if (empty($_REQUEST['msg']))
139 147
 		{
140
-			if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any')))
141
-				is_not_guest();
148
+			if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) {
149
+							is_not_guest();
150
+			}
142 151
 
143 152
 			// By default the reply will be approved...
144 153
 			$context['becomes_approved'] = true;
145 154
 			if ($id_member_poster != $user_info['id'] || $user_info['is_guest'])
146 155
 			{
147
-				if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any'))
148
-					$context['becomes_approved'] = false;
149
-				else
150
-					isAllowedTo('post_reply_any');
151
-			}
152
-			elseif (!allowedTo('post_reply_any'))
156
+				if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) {
157
+									$context['becomes_approved'] = false;
158
+				} else {
159
+									isAllowedTo('post_reply_any');
160
+				}
161
+			} elseif (!allowedTo('post_reply_any'))
153 162
 			{
154
-				if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any')))
155
-					$context['becomes_approved'] = false;
156
-				else
157
-					isAllowedTo('post_reply_own');
163
+				if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) {
164
+									$context['becomes_approved'] = false;
165
+				} else {
166
+									isAllowedTo('post_reply_own');
167
+				}
158 168
 			}
169
+		} else {
170
+					$context['becomes_approved'] = true;
159 171
 		}
160
-		else
161
-			$context['becomes_approved'] = true;
162 172
 
163 173
 		$context['can_lock'] = allowedTo('lock_any') || ($user_info['id'] == $id_member_poster && allowedTo('lock_own'));
164 174
 		$context['can_sticky'] = allowedTo('make_sticky');
@@ -173,17 +183,18 @@  discard block
 block discarded – undo
173 183
 		$context['sticky'] = isset($_REQUEST['sticky']) ? !empty($_REQUEST['sticky']) : $sticky;
174 184
 
175 185
 		// Check whether this is a really old post being bumped...
176
-		if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject']))
177
-			$post_errors[] = array('old_topic', array($modSettings['oldTopicDays']));
178
-	}
179
-	else
186
+		if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) {
187
+					$post_errors[] = array('old_topic', array($modSettings['oldTopicDays']));
188
+		}
189
+	} else
180 190
 	{
181 191
 		// @todo Should use JavaScript to hide and show the warning based on the selection in the board select menu
182 192
 		$context['becomes_approved'] = true;
183
-		if ($modSettings['postmod_active'] && !allowedTo('post_new', $boards, true) && allowedTo('post_unapproved_topics', $boards, true))
184
-			$context['becomes_approved'] = false;
185
-		else
186
-			isAllowedTo('post_new', $boards, true);
193
+		if ($modSettings['postmod_active'] && !allowedTo('post_new', $boards, true) && allowedTo('post_unapproved_topics', $boards, true)) {
194
+					$context['becomes_approved'] = false;
195
+		} else {
196
+					isAllowedTo('post_new', $boards, true);
197
+		}
187 198
 
188 199
 		$locked = 0;
189 200
 		$context['already_locked'] = 0;
@@ -213,27 +224,32 @@  discard block
 block discarded – undo
213 224
 	if (empty($_REQUEST['message']) && empty($_REQUEST['preview']) && !empty($_SESSION['already_attached']))
214 225
 	{
215 226
 		require_once($sourcedir . '/ManageAttachments.php');
216
-		foreach ($_SESSION['already_attached'] as $attachID => $attachment)
217
-			removeAttachments(array('id_attach' => $attachID));
227
+		foreach ($_SESSION['already_attached'] as $attachID => $attachment) {
228
+					removeAttachments(array('id_attach' => $attachID));
229
+		}
218 230
 
219 231
 		unset($_SESSION['already_attached']);
220 232
 	}
221 233
 
222 234
 	// Don't allow a post if it's locked and you aren't all powerful.
223
-	if ($locked && !allowedTo('moderate_board'))
224
-		fatal_lang_error('topic_locked', false);
235
+	if ($locked && !allowedTo('moderate_board')) {
236
+			fatal_lang_error('topic_locked', false);
237
+	}
225 238
 	// Check the users permissions - is the user allowed to add or post a poll?
226 239
 	if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1')
227 240
 	{
228 241
 		// New topic, new poll.
229
-		if (empty($topic))
230
-			isAllowedTo('poll_post');
242
+		if (empty($topic)) {
243
+					isAllowedTo('poll_post');
244
+		}
231 245
 		// This is an old topic - but it is yours!  Can you add to it?
232
-		elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any'))
233
-			isAllowedTo('poll_add_own');
246
+		elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) {
247
+					isAllowedTo('poll_add_own');
248
+		}
234 249
 		// If you're not the owner, can you add to any poll?
235
-		else
236
-			isAllowedTo('poll_add_any');
250
+		else {
251
+					isAllowedTo('poll_add_any');
252
+		}
237 253
 
238 254
 		if (!empty($board))
239 255
 		{
@@ -242,8 +258,9 @@  discard block
 block discarded – undo
242 258
 			$guest_vote_enabled = in_array(-1, $allowedVoteGroups['allowed']);
243 259
 		}
244 260
 		// No board, so we'll have to check this again in Post2
245
-		else
246
-			$guest_vote_enabled = true;
261
+		else {
262
+					$guest_vote_enabled = true;
263
+		}
247 264
 
248 265
 		// Set up the poll options.
249 266
 		$context['poll_options'] = array(
@@ -269,8 +286,9 @@  discard block
 block discarded – undo
269 286
 	if ($context['make_event'])
270 287
 	{
271 288
 		// They might want to pick a board.
272
-		if (!isset($context['current_board']))
273
-			$context['current_board'] = 0;
289
+		if (!isset($context['current_board'])) {
290
+					$context['current_board'] = 0;
291
+		}
274 292
 
275 293
 		// Start loading up the event info.
276 294
 		$context['event'] = array();
@@ -284,10 +302,11 @@  discard block
 block discarded – undo
284 302
 		isAllowedTo('calendar_post');
285 303
 
286 304
 		// We want a fairly compact version of the time, but as close as possible to the user's settings.
287
-		if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0]))
288
-			$time_string = '%k:%M';
289
-		else
290
-			$time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]);
305
+		if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) {
306
+					$time_string = '%k:%M';
307
+		} else {
308
+					$time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]);
309
+		}
291 310
 
292 311
 		$js_time_string = str_replace(
293 312
 			array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r',      '%R',  '%S', '%T',    '%X'),
@@ -309,8 +328,7 @@  discard block
 block discarded – undo
309 328
 			require_once($sourcedir . '/Subs-Calendar.php');
310 329
 			$eventProperties = getEventProperties($context['event']['id']);
311 330
 			$context['event'] = array_merge($context['event'], $eventProperties);
312
-		}
313
-		else
331
+		} else
314 332
 		{
315 333
 			// Get the current event information.
316 334
 			require_once($sourcedir . '/Subs-Calendar.php');
@@ -318,10 +336,12 @@  discard block
 block discarded – undo
318 336
 			$context['event'] = array_merge($context['event'], $eventProperties);
319 337
 
320 338
 			// Make sure the year and month are in the valid range.
321
-			if ($context['event']['month'] < 1 || $context['event']['month'] > 12)
322
-				fatal_lang_error('invalid_month', false);
323
-			if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear'])
324
-				fatal_lang_error('invalid_year', false);
339
+			if ($context['event']['month'] < 1 || $context['event']['month'] > 12) {
340
+							fatal_lang_error('invalid_month', false);
341
+			}
342
+			if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) {
343
+							fatal_lang_error('invalid_year', false);
344
+			}
325 345
 
326 346
 			$context['event']['categories'] = $board_list;
327 347
 		}
@@ -432,10 +452,11 @@  discard block
 block discarded – undo
432 452
 
433 453
 			if (!empty($context['new_replies']))
434 454
 			{
435
-				if ($context['new_replies'] == 1)
436
-					$txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply'];
437
-				else
438
-					$txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']);
455
+				if ($context['new_replies'] == 1) {
456
+									$txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply'];
457
+				} else {
458
+									$txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']);
459
+				}
439 460
 
440 461
 				$post_errors[] = 'new_replies';
441 462
 
@@ -447,9 +468,9 @@  discard block
 block discarded – undo
447 468
 	// Get a response prefix (like 'Re:') in the default forum language.
448 469
 	if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix')))
449 470
 	{
450
-		if ($language === $user_info['language'])
451
-			$context['response_prefix'] = $txt['response_prefix'];
452
-		else
471
+		if ($language === $user_info['language']) {
472
+					$context['response_prefix'] = $txt['response_prefix'];
473
+		} else
453 474
 		{
454 475
 			loadLanguage('index', $language, false);
455 476
 			$context['response_prefix'] = $txt['response_prefix'];
@@ -462,23 +483,26 @@  discard block
 block discarded – undo
462 483
 	// Do we have a body, but an error happened.
463 484
 	if (isset($_REQUEST['message']) || isset($_REQUEST['quickReply']) || !empty($context['post_error']))
464 485
 	{
465
-		if (isset($_REQUEST['quickReply']))
466
-			$_REQUEST['message'] = $_REQUEST['quickReply'];
486
+		if (isset($_REQUEST['quickReply'])) {
487
+					$_REQUEST['message'] = $_REQUEST['quickReply'];
488
+		}
467 489
 
468 490
 		// Validate inputs.
469 491
 		if (empty($context['post_error']))
470 492
 		{
471 493
 			// This means they didn't click Post and get an error.
472 494
 			$really_previewing = true;
473
-		}
474
-		else
495
+		} else
475 496
 		{
476
-			if (!isset($_REQUEST['subject']))
477
-				$_REQUEST['subject'] = '';
478
-			if (!isset($_REQUEST['message']))
479
-				$_REQUEST['message'] = '';
480
-			if (!isset($_REQUEST['icon']))
481
-				$_REQUEST['icon'] = 'xx';
497
+			if (!isset($_REQUEST['subject'])) {
498
+							$_REQUEST['subject'] = '';
499
+			}
500
+			if (!isset($_REQUEST['message'])) {
501
+							$_REQUEST['message'] = '';
502
+			}
503
+			if (!isset($_REQUEST['icon'])) {
504
+							$_REQUEST['icon'] = 'xx';
505
+			}
482 506
 
483 507
 			// They are previewing if they asked to preview (i.e. came from quick reply).
484 508
 			$really_previewing = !empty($_POST['preview']);
@@ -494,8 +518,9 @@  discard block
 block discarded – undo
494 518
 		$form_message = $smcFunc['htmlspecialchars']($_REQUEST['message'], ENT_QUOTES);
495 519
 
496 520
 		// Make sure the subject isn't too long - taking into account special characters.
497
-		if ($smcFunc['strlen']($form_subject) > 100)
498
-			$form_subject = $smcFunc['substr']($form_subject, 0, 100);
521
+		if ($smcFunc['strlen']($form_subject) > 100) {
522
+					$form_subject = $smcFunc['substr']($form_subject, 0, 100);
523
+		}
499 524
 
500 525
 		if (isset($_REQUEST['poll']))
501 526
 		{
@@ -507,8 +532,9 @@  discard block
 block discarded – undo
507 532
 			$_POST['options'] = empty($_POST['options']) ? array() : htmlspecialchars__recursive($_POST['options']);
508 533
 			foreach ($_POST['options'] as $option)
509 534
 			{
510
-				if (trim($option) == '')
511
-					continue;
535
+				if (trim($option) == '') {
536
+									continue;
537
+				}
512 538
 
513 539
 				$context['choices'][] = array(
514 540
 					'id' => $choice_id++,
@@ -570,13 +596,14 @@  discard block
 block discarded – undo
570 596
 				$context['preview_subject'] = $form_subject;
571 597
 
572 598
 				censorText($context['preview_subject']);
599
+			} else {
600
+							$context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>';
573 601
 			}
574
-			else
575
-				$context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>';
576 602
 
577 603
 			// Protect any CDATA blocks.
578
-			if (isset($_REQUEST['xml']))
579
-				$context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]><![CDATA[>'));
604
+			if (isset($_REQUEST['xml'])) {
605
+							$context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]><![CDATA[>'));
606
+			}
580 607
 		}
581 608
 
582 609
 		// Set up the checkboxes.
@@ -615,29 +642,32 @@  discard block
 block discarded – undo
615 642
 			);
616 643
 			// The message they were trying to edit was most likely deleted.
617 644
 			// @todo Change this error message?
618
-			if ($smcFunc['db_num_rows']($request) == 0)
619
-				fatal_lang_error('no_board', false);
645
+			if ($smcFunc['db_num_rows']($request) == 0) {
646
+							fatal_lang_error('no_board', false);
647
+			}
620 648
 			$row = $smcFunc['db_fetch_assoc']($request);
621 649
 
622 650
 			$attachment_stuff = array($row);
623
-			while ($row2 = $smcFunc['db_fetch_assoc']($request))
624
-				$attachment_stuff[] = $row2;
651
+			while ($row2 = $smcFunc['db_fetch_assoc']($request)) {
652
+							$attachment_stuff[] = $row2;
653
+			}
625 654
 			$smcFunc['db_free_result']($request);
626 655
 
627 656
 			if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any'))
628 657
 			{
629 658
 				// Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public.
630
-				if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time())
631
-					fatal_lang_error('modify_post_time_passed', false);
632
-				elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own'))
633
-					isAllowedTo('modify_replies');
634
-				else
635
-					isAllowedTo('modify_own');
659
+				if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) {
660
+									fatal_lang_error('modify_post_time_passed', false);
661
+				} elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) {
662
+									isAllowedTo('modify_replies');
663
+				} else {
664
+									isAllowedTo('modify_own');
665
+				}
666
+			} elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) {
667
+							isAllowedTo('modify_replies');
668
+			} else {
669
+							isAllowedTo('modify_any');
636 670
 			}
637
-			elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any'))
638
-				isAllowedTo('modify_replies');
639
-			else
640
-				isAllowedTo('modify_any');
641 671
 
642 672
 			if ($context['can_announce'] && !empty($row['id_action']))
643 673
 			{
@@ -661,8 +691,9 @@  discard block
 block discarded – undo
661 691
 
662 692
 				while ($row = $smcFunc['db_fetch_assoc']($request))
663 693
 				{
664
-					if ($row['filesize'] <= 0)
665
-						continue;
694
+					if ($row['filesize'] <= 0) {
695
+											continue;
696
+					}
666 697
 					$context['current_attachments'][$row['id_attach']] = array(
667 698
 						'name' => $smcFunc['htmlspecialchars']($row['filename']),
668 699
 						'size' => $row['filesize'],
@@ -732,29 +763,32 @@  discard block
 block discarded – undo
732 763
 			)
733 764
 		);
734 765
 		// The message they were trying to edit was most likely deleted.
735
-		if ($smcFunc['db_num_rows']($request) == 0)
736
-			fatal_lang_error('no_message', false);
766
+		if ($smcFunc['db_num_rows']($request) == 0) {
767
+					fatal_lang_error('no_message', false);
768
+		}
737 769
 		$row = $smcFunc['db_fetch_assoc']($request);
738 770
 
739 771
 		$attachment_stuff = array($row);
740
-		while ($row2 = $smcFunc['db_fetch_assoc']($request))
741
-			$attachment_stuff[] = $row2;
772
+		while ($row2 = $smcFunc['db_fetch_assoc']($request)) {
773
+					$attachment_stuff[] = $row2;
774
+		}
742 775
 		$smcFunc['db_free_result']($request);
743 776
 
744 777
 		if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any'))
745 778
 		{
746 779
 			// Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public.
747
-			if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time())
748
-				fatal_lang_error('modify_post_time_passed', false);
749
-			elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own'))
750
-				isAllowedTo('modify_replies');
751
-			else
752
-				isAllowedTo('modify_own');
780
+			if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) {
781
+							fatal_lang_error('modify_post_time_passed', false);
782
+			} elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) {
783
+							isAllowedTo('modify_replies');
784
+			} else {
785
+							isAllowedTo('modify_own');
786
+			}
787
+		} elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) {
788
+					isAllowedTo('modify_replies');
789
+		} else {
790
+					isAllowedTo('modify_any');
753 791
 		}
754
-		elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any'))
755
-			isAllowedTo('modify_replies');
756
-		else
757
-			isAllowedTo('modify_any');
758 792
 
759 793
 		if ($context['can_announce'] && !empty($row['id_action']))
760 794
 		{
@@ -781,15 +815,17 @@  discard block
 block discarded – undo
781 815
 		$context['icon'] = $row['icon'];
782 816
 
783 817
 		// Show an "approve" box if the user can approve it, and the message isn't approved.
784
-		if (!$row['approved'] && !$context['show_approval'])
785
-			$context['show_approval'] = allowedTo('approve_posts');
818
+		if (!$row['approved'] && !$context['show_approval']) {
819
+					$context['show_approval'] = allowedTo('approve_posts');
820
+		}
786 821
 
787 822
 		// Sort the attachments so they are in the order saved
788 823
 		$temp = array();
789 824
 		foreach ($attachment_stuff as $attachment)
790 825
 		{
791
-			if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable']))
792
-				$temp[$attachment['id_attach']] = $attachment;
826
+			if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) {
827
+							$temp[$attachment['id_attach']] = $attachment;
828
+			}
793 829
 		}
794 830
 		ksort($temp);
795 831
 
@@ -850,14 +886,16 @@  discard block
 block discarded – undo
850 886
 					'is_approved' => 1,
851 887
 				)
852 888
 			);
853
-			if ($smcFunc['db_num_rows']($request) == 0)
854
-				fatal_lang_error('quoted_post_deleted', false);
889
+			if ($smcFunc['db_num_rows']($request) == 0) {
890
+							fatal_lang_error('quoted_post_deleted', false);
891
+			}
855 892
 			list ($form_subject, $mname, $mdate, $form_message) = $smcFunc['db_fetch_row']($request);
856 893
 			$smcFunc['db_free_result']($request);
857 894
 
858 895
 			// Add 'Re: ' to the front of the quoted subject.
859
-			if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0)
860
-				$form_subject = $context['response_prefix'] . $form_subject;
896
+			if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) {
897
+							$form_subject = $context['response_prefix'] . $form_subject;
898
+			}
861 899
 
862 900
 			// Censor the message and subject.
863 901
 			censorText($form_message);
@@ -870,10 +908,11 @@  discard block
 block discarded – undo
870 908
 				for ($i = 0, $n = count($parts); $i < $n; $i++)
871 909
 				{
872 910
 					// It goes 0 = outside, 1 = begin tag, 2 = inside, 3 = close tag, repeat.
873
-					if ($i % 4 == 0)
874
-						$parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m)
911
+					if ($i % 4 == 0) {
912
+											$parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m)
875 913
 						{
876 914
 							return '[html]' . preg_replace('~<br\s?/?' . '>~i', '&lt;br /&gt;<br>', "$m[1]") . '[/html]';
915
+					}
877 916
 						}, $parts[$i]);
878 917
 				}
879 918
 				$form_message = implode('', $parts);
@@ -882,8 +921,9 @@  discard block
 block discarded – undo
882 921
 			$form_message = preg_replace('~<br ?/?' . '>~i', "\n", $form_message);
883 922
 
884 923
 			// Remove any nested quotes, if necessary.
885
-			if (!empty($modSettings['removeNestedQuotes']))
886
-				$form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message);
924
+			if (!empty($modSettings['removeNestedQuotes'])) {
925
+							$form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message);
926
+			}
887 927
 
888 928
 			// Add a quote string on the front and end.
889 929
 			$form_message = '[quote author=' . $mname . ' link=msg=' . (int) $_REQUEST['quote'] . ' date=' . $mdate . ']' . "\n" . rtrim($form_message) . "\n" . '[/quote]';
@@ -895,15 +935,15 @@  discard block
 block discarded – undo
895 935
 			$form_subject = $first_subject;
896 936
 
897 937
 			// Add 'Re: ' to the front of the subject.
898
-			if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0)
899
-				$form_subject = $context['response_prefix'] . $form_subject;
938
+			if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) {
939
+							$form_subject = $context['response_prefix'] . $form_subject;
940
+			}
900 941
 
901 942
 			// Censor the subject.
902 943
 			censorText($form_subject);
903 944
 
904 945
 			$form_message = '';
905
-		}
906
-		else
946
+		} else
907 947
 		{
908 948
 			$form_subject = isset($_GET['subject']) ? $_GET['subject'] : '';
909 949
 			$form_message = '';
@@ -922,13 +962,15 @@  discard block
 block discarded – undo
922 962
 		if (isset($_REQUEST['msg']))
923 963
 		{
924 964
 			$context['attachments']['quantity'] = count($context['current_attachments']);
925
-			foreach ($context['current_attachments'] as $attachment)
926
-				$context['attachments']['total_size'] += $attachment['size'];
965
+			foreach ($context['current_attachments'] as $attachment) {
966
+							$context['attachments']['total_size'] += $attachment['size'];
967
+			}
927 968
 		}
928 969
 
929 970
 		// A bit of house keeping first.
930
-		if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1)
931
-			unset($_SESSION['temp_attachments']);
971
+		if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) {
972
+					unset($_SESSION['temp_attachments']);
973
+		}
932 974
 
933 975
 		if (!empty($_SESSION['temp_attachments']))
934 976
 		{
@@ -937,9 +979,10 @@  discard block
 block discarded – undo
937 979
 			{
938 980
 				foreach ($_SESSION['temp_attachments'] as $attachID => $attachment)
939 981
 				{
940
-					if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false)
941
-						if (file_exists($attachment['tmp_name']))
982
+					if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) {
983
+											if (file_exists($attachment['tmp_name']))
942 984
 							unlink($attachment['tmp_name']);
985
+					}
943 986
 				}
944 987
 				$post_errors[] = 'temp_attachments_gone';
945 988
 				$_SESSION['temp_attachments'] = array();
@@ -953,8 +996,9 @@  discard block
 block discarded – undo
953 996
 					// See if any files still exist before showing the warning message and the files attached.
954 997
 					foreach ($_SESSION['temp_attachments'] as $attachID => $attachment)
955 998
 					{
956
-						if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false)
957
-							continue;
999
+						if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) {
1000
+													continue;
1001
+						}
958 1002
 
959 1003
 						if (file_exists($attachment['tmp_name']))
960 1004
 						{
@@ -964,20 +1008,21 @@  discard block
 block discarded – undo
964 1008
 							break;
965 1009
 						}
966 1010
 					}
967
-				}
968
-				else
1011
+				} else
969 1012
 				{
970 1013
 					// Since, they don't belong here. Let's inform the user that they exist..
971
-					if (!empty($topic))
972
-						$delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp';
973
-					else
974
-						$delete_url = $scripturl . '?action=post' . (!empty($board) ? ';board=' . $board : '') . ';delete_temp';
1014
+					if (!empty($topic)) {
1015
+											$delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp';
1016
+					} else {
1017
+											$delete_url = $scripturl . '?action=post' . (!empty($board) ? ';board=' . $board : '') . ';delete_temp';
1018
+					}
975 1019
 
976 1020
 					// Compile a list of the files to show the user.
977 1021
 					$file_list = array();
978
-					foreach ($_SESSION['temp_attachments'] as $attachID => $attachment)
979
-						if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false)
1022
+					foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) {
1023
+											if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false)
980 1024
 							$file_list[] = $attachment['name'];
1025
+					}
981 1026
 
982 1027
 					$_SESSION['temp_attachments']['post']['files'] = $file_list;
983 1028
 					$file_list = '<div class="attachments">' . implode('<br>', $file_list) . '</div>';
@@ -989,8 +1034,7 @@  discard block
 block discarded – undo
989 1034
 
990 1035
 						$post_errors[] = array('temp_attachments_found', array($delete_url, $goback_url, $file_list));
991 1036
 						$context['ignore_temp_attachments'] = true;
992
-					}
993
-					else
1037
+					} else
994 1038
 					{
995 1039
 						$post_errors[] = array('temp_attachments_lost', array($delete_url, $file_list));
996 1040
 						$context['ignore_temp_attachments'] = true;
@@ -998,16 +1042,19 @@  discard block
 block discarded – undo
998 1042
 				}
999 1043
 			}
1000 1044
 
1001
-			if (!empty($context['we_are_history']))
1002
-				$post_errors[] = $context['we_are_history'];
1045
+			if (!empty($context['we_are_history'])) {
1046
+							$post_errors[] = $context['we_are_history'];
1047
+			}
1003 1048
 
1004 1049
 			foreach ($_SESSION['temp_attachments'] as $attachID => $attachment)
1005 1050
 			{
1006
-				if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files']))
1007
-					break;
1051
+				if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) {
1052
+									break;
1053
+				}
1008 1054
 
1009
-				if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false)
1010
-					continue;
1055
+				if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) {
1056
+									continue;
1057
+				}
1011 1058
 
1012 1059
 				if ($attachID == 'initial_error')
1013 1060
 				{
@@ -1022,15 +1069,17 @@  discard block
 block discarded – undo
1022 1069
 				{
1023 1070
 					$txt['error_attach_errors'] = empty($txt['error_attach_errors']) ? '<br>' : '';
1024 1071
 					$txt['error_attach_errors'] .= vsprintf($txt['attach_warning'], $attachment['name']) . '<div style="padding: 0 1em;">';
1025
-					foreach ($attachment['errors'] as $error)
1026
-						$txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >';
1072
+					foreach ($attachment['errors'] as $error) {
1073
+											$txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >';
1074
+					}
1027 1075
 					$txt['error_attach_errors'] .= '</div>';
1028 1076
 					$post_errors[] = 'attach_errors';
1029 1077
 
1030 1078
 					// Take out the trash.
1031 1079
 					unset($_SESSION['temp_attachments'][$attachID]);
1032
-					if (file_exists($attachment['tmp_name']))
1033
-						unlink($attachment['tmp_name']);
1080
+					if (file_exists($attachment['tmp_name'])) {
1081
+											unlink($attachment['tmp_name']);
1082
+					}
1034 1083
 					continue;
1035 1084
 				}
1036 1085
 
@@ -1043,8 +1092,9 @@  discard block
 block discarded – undo
1043 1092
 
1044 1093
 				$context['attachments']['quantity']++;
1045 1094
 				$context['attachments']['total_size'] += $attachment['size'];
1046
-				if (!isset($context['files_in_session_warning']))
1047
-					$context['files_in_session_warning'] = $txt['attached_files_in_session'];
1095
+				if (!isset($context['files_in_session_warning'])) {
1096
+									$context['files_in_session_warning'] = $txt['attached_files_in_session'];
1097
+				}
1048 1098
 
1049 1099
 				$context['current_attachments'][$attachID] = array(
1050 1100
 					'name' => '<u>' . $smcFunc['htmlspecialchars']($attachment['name']) . '</u>',
@@ -1072,8 +1122,9 @@  discard block
 block discarded – undo
1072 1122
 	}
1073 1123
 
1074 1124
 	// If they came from quick reply, and have to enter verification details, give them some notice.
1075
-	if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification']))
1076
-		$post_errors[] = 'need_qr_verification';
1125
+	if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) {
1126
+			$post_errors[] = 'need_qr_verification';
1127
+	}
1077 1128
 
1078 1129
 	/*
1079 1130
 	 * There are two error types: serious and minor. Serious errors
@@ -1090,52 +1141,56 @@  discard block
 block discarded – undo
1090 1141
 	{
1091 1142
 		loadLanguage('Errors');
1092 1143
 		$context['error_type'] = 'minor';
1093
-		foreach ($post_errors as $post_error)
1094
-			if (is_array($post_error))
1144
+		foreach ($post_errors as $post_error) {
1145
+					if (is_array($post_error))
1095 1146
 			{
1096 1147
 				$post_error_id = $post_error[0];
1148
+		}
1097 1149
 				$context['post_error'][$post_error_id] = vsprintf($txt['error_' . $post_error_id], $post_error[1]);
1098 1150
 
1099 1151
 				// If it's not a minor error flag it as such.
1100
-				if (!in_array($post_error_id, $minor_errors))
1101
-					$context['error_type'] = 'serious';
1102
-			}
1103
-			else
1152
+				if (!in_array($post_error_id, $minor_errors)) {
1153
+									$context['error_type'] = 'serious';
1154
+				}
1155
+			} else
1104 1156
 			{
1105 1157
 				$context['post_error'][$post_error] = $txt['error_' . $post_error];
1106 1158
 
1107 1159
 				// If it's not a minor error flag it as such.
1108
-				if (!in_array($post_error, $minor_errors))
1109
-					$context['error_type'] = 'serious';
1160
+				if (!in_array($post_error, $minor_errors)) {
1161
+									$context['error_type'] = 'serious';
1162
+				}
1110 1163
 			}
1111 1164
 	}
1112 1165
 
1113 1166
 	// What are you doing? Posting a poll, modifying, previewing, new post, or reply...
1114
-	if (isset($_REQUEST['poll']))
1115
-		$context['page_title'] = $txt['new_poll'];
1116
-	elseif ($context['make_event'])
1117
-		$context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit'];
1118
-	elseif (isset($_REQUEST['msg']))
1119
-		$context['page_title'] = $txt['modify_msg'];
1120
-	elseif (isset($_REQUEST['subject'], $context['preview_subject']))
1121
-		$context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']);
1122
-	elseif (empty($topic))
1123
-		$context['page_title'] = $txt['start_new_topic'];
1124
-	else
1125
-		$context['page_title'] = $txt['post_reply'];
1167
+	if (isset($_REQUEST['poll'])) {
1168
+			$context['page_title'] = $txt['new_poll'];
1169
+	} elseif ($context['make_event']) {
1170
+			$context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit'];
1171
+	} elseif (isset($_REQUEST['msg'])) {
1172
+			$context['page_title'] = $txt['modify_msg'];
1173
+	} elseif (isset($_REQUEST['subject'], $context['preview_subject'])) {
1174
+			$context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']);
1175
+	} elseif (empty($topic)) {
1176
+			$context['page_title'] = $txt['start_new_topic'];
1177
+	} else {
1178
+			$context['page_title'] = $txt['post_reply'];
1179
+	}
1126 1180
 
1127 1181
 	// Build the link tree.
1128
-	if (empty($topic))
1129
-		$context['linktree'][] = array(
1182
+	if (empty($topic)) {
1183
+			$context['linktree'][] = array(
1130 1184
 			'name' => '<em>' . $txt['start_new_topic'] . '</em>'
1131 1185
 		);
1132
-	else
1133
-		$context['linktree'][] = array(
1186
+	} else {
1187
+			$context['linktree'][] = array(
1134 1188
 			'url' => $scripturl . '?topic=' . $topic . '.' . $_REQUEST['start'],
1135 1189
 			'name' => $form_subject,
1136 1190
 			'extra_before' => '<span><strong class="nav">' . $context['page_title'] . ' (</strong></span>',
1137 1191
 			'extra_after' => '<span><strong class="nav">)</strong></span>'
1138 1192
 		);
1193
+	}
1139 1194
 
1140 1195
 	$context['subject'] = addcslashes($form_subject, '"');
1141 1196
 	$context['message'] = str_replace(array('"', '<', '>', '&nbsp;'), array('&quot;', '&lt;', '&gt;', ' '), $form_message);
@@ -1179,8 +1234,9 @@  discard block
 block discarded – undo
1179 1234
 	// Message icons - customized icons are off?
1180 1235
 	$context['icons'] = getMessageIcons(!empty($board) ? $board : 0);
1181 1236
 
1182
-	if (!empty($context['icons']))
1183
-		$context['icons'][count($context['icons']) - 1]['is_last'] = true;
1237
+	if (!empty($context['icons'])) {
1238
+			$context['icons'][count($context['icons']) - 1]['is_last'] = true;
1239
+	}
1184 1240
 
1185 1241
 	// Are we starting a poll? if set the poll icon as selected if its available
1186 1242
 	if (isset($_REQUEST['poll']))
@@ -1200,8 +1256,9 @@  discard block
 block discarded – undo
1200 1256
 	for ($i = 0, $n = count($context['icons']); $i < $n; $i++)
1201 1257
 	{
1202 1258
 		$context['icons'][$i]['selected'] = $context['icon'] == $context['icons'][$i]['value'];
1203
-		if ($context['icons'][$i]['selected'])
1204
-			$context['icon_url'] = $context['icons'][$i]['url'];
1259
+		if ($context['icons'][$i]['selected']) {
1260
+					$context['icon_url'] = $context['icons'][$i]['url'];
1261
+		}
1205 1262
 	}
1206 1263
 	if (empty($context['icon_url']))
1207 1264
 	{
@@ -1215,8 +1272,9 @@  discard block
 block discarded – undo
1215 1272
 		));
1216 1273
 	}
1217 1274
 
1218
-	if (!empty($topic) && !empty($modSettings['topicSummaryPosts']))
1219
-		getTopic();
1275
+	if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) {
1276
+			getTopic();
1277
+	}
1220 1278
 
1221 1279
 	// If the user can post attachments prepare the warning labels.
1222 1280
 	if ($context['can_post_attachment'])
@@ -1227,12 +1285,13 @@  discard block
 block discarded – undo
1227 1285
 		$context['attachment_restrictions'] = array();
1228 1286
 		$context['allowed_extensions'] = strtr(strtolower($modSettings['attachmentExtensions']), array(',' => ', '));
1229 1287
 		$attachmentRestrictionTypes = array('attachmentNumPerPostLimit', 'attachmentPostLimit', 'attachmentSizeLimit');
1230
-		foreach ($attachmentRestrictionTypes as $type)
1231
-			if (!empty($modSettings[$type]))
1288
+		foreach ($attachmentRestrictionTypes as $type) {
1289
+					if (!empty($modSettings[$type]))
1232 1290
 			{
1233 1291
 				// Show the max number of attachments if not 0.
1234 1292
 				if ($type == 'attachmentNumPerPostLimit')
1235 1293
 					$context['attachment_restrictions'][] = sprintf($txt['attach_remaining'], $modSettings['attachmentNumPerPostLimit'] - $context['attachments']['quantity']);
1294
+		}
1236 1295
 			}
1237 1296
 	}
1238 1297
 
@@ -1266,8 +1325,8 @@  discard block
 block discarded – undo
1266 1325
 
1267 1326
 	if (!empty($context['current_attachments']))
1268 1327
 	{
1269
-		foreach ($context['current_attachments'] as $key => $mock)
1270
-			addInlineJavaScript('
1328
+		foreach ($context['current_attachments'] as $key => $mock) {
1329
+					addInlineJavaScript('
1271 1330
 	current_attachments.push({
1272 1331
 		name: '. JavaScriptEscape($mock['name']) . ',
1273 1332
 		size: '. $mock['size'] . ',
@@ -1276,6 +1335,7 @@  discard block
 block discarded – undo
1276 1335
 		type: '. JavaScriptEscape(!empty($mock['mime_type']) ? $mock['mime_type'] : '') . ',
1277 1336
 		thumbID: '. (!empty($mock['thumb']) ? $mock['thumb'] : 0) . '
1278 1337
 	});');
1338
+		}
1279 1339
 	}
1280 1340
 
1281 1341
 	// File Upload.
@@ -1374,12 +1434,13 @@  discard block
 block discarded – undo
1374 1434
 		{
1375 1435
 			$context['posting_fields']['board']['input']['options'][$category['name']] = array('options' => array());
1376 1436
 
1377
-			foreach ($category['boards'] as $brd)
1378
-				$context['posting_fields']['board']['input']['options'][$category['name']]['options'][$brd['name']]['attributes'] = array(
1437
+			foreach ($category['boards'] as $brd) {
1438
+							$context['posting_fields']['board']['input']['options'][$category['name']]['options'][$brd['name']]['attributes'] = array(
1379 1439
 					'value' => $brd['id'],
1380 1440
 					'selected' => (bool) $brd['selected'],
1381 1441
 					'label' => ($brd['child_level'] > 0 ? str_repeat('==', $brd['child_level'] - 1) . '=&gt;' : '') . ' ' . $brd['name'],
1382 1442
 				);
1443
+			}
1383 1444
 		}
1384 1445
 	}
1385 1446
 
@@ -1425,8 +1486,9 @@  discard block
 block discarded – undo
1425 1486
 
1426 1487
 
1427 1488
 	// Finally, load the template.
1428
-	if (!isset($_REQUEST['xml']))
1429
-		loadTemplate('Post');
1489
+	if (!isset($_REQUEST['xml'])) {
1490
+			loadTemplate('Post');
1491
+	}
1430 1492
 
1431 1493
 	call_integration_hook('integrate_post_end');
1432 1494
 }
@@ -1447,13 +1509,14 @@  discard block
 block discarded – undo
1447 1509
 	// Sneaking off, are we?
1448 1510
 	if (empty($_POST) && empty($topic))
1449 1511
 	{
1450
-		if (empty($_SERVER['CONTENT_LENGTH']))
1451
-			redirectexit('action=post;board=' . $board . '.0');
1452
-		else
1453
-			fatal_lang_error('post_upload_error', false);
1512
+		if (empty($_SERVER['CONTENT_LENGTH'])) {
1513
+					redirectexit('action=post;board=' . $board . '.0');
1514
+		} else {
1515
+					fatal_lang_error('post_upload_error', false);
1516
+		}
1517
+	} elseif (empty($_POST) && !empty($topic)) {
1518
+			redirectexit('action=post;topic=' . $topic . '.0');
1454 1519
 	}
1455
-	elseif (empty($_POST) && !empty($topic))
1456
-		redirectexit('action=post;topic=' . $topic . '.0');
1457 1520
 
1458 1521
 	// No need!
1459 1522
 	$context['robot_no_index'] = true;
@@ -1465,8 +1528,9 @@  discard block
 block discarded – undo
1465 1528
 	$post_errors = array();
1466 1529
 
1467 1530
 	// If the session has timed out, let the user re-submit their form.
1468
-	if (checkSession('post', '', false) != '')
1469
-		$post_errors[] = 'session_timeout';
1531
+	if (checkSession('post', '', false) != '') {
1532
+			$post_errors[] = 'session_timeout';
1533
+	}
1470 1534
 
1471 1535
 	// Wrong verification code?
1472 1536
 	if (!$user_info['is_admin'] && !$user_info['is_mod'] && !empty($modSettings['posts_require_captcha']) && ($user_info['posts'] < $modSettings['posts_require_captcha'] || ($user_info['is_guest'] && $modSettings['posts_require_captcha'] == -1)))
@@ -1476,8 +1540,9 @@  discard block
 block discarded – undo
1476 1540
 			'id' => 'post',
1477 1541
 		);
1478 1542
 		$context['require_verification'] = create_control_verification($verificationOptions, true);
1479
-		if (is_array($context['require_verification']))
1480
-			$post_errors = array_merge($post_errors, $context['require_verification']);
1543
+		if (is_array($context['require_verification'])) {
1544
+					$post_errors = array_merge($post_errors, $context['require_verification']);
1545
+		}
1481 1546
 	}
1482 1547
 
1483 1548
 	require_once($sourcedir . '/Subs-Post.php');
@@ -1486,25 +1551,29 @@  discard block
 block discarded – undo
1486 1551
 	call_integration_hook('integrate_post2_start');
1487 1552
 
1488 1553
 	// Drafts enabled and needed?
1489
-	if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft'])))
1490
-		require_once($sourcedir . '/Drafts.php');
1554
+	if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) {
1555
+			require_once($sourcedir . '/Drafts.php');
1556
+	}
1491 1557
 
1492 1558
 	// First check to see if they are trying to delete any current attachments.
1493 1559
 	if (isset($_POST['attach_del']))
1494 1560
 	{
1495 1561
 		$keep_temp = array();
1496 1562
 		$keep_ids = array();
1497
-		foreach ($_POST['attach_del'] as $dummy)
1498
-			if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false)
1563
+		foreach ($_POST['attach_del'] as $dummy) {
1564
+					if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false)
1499 1565
 				$keep_temp[] = $dummy;
1500
-			else
1501
-				$keep_ids[] = (int) $dummy;
1566
+		}
1567
+			else {
1568
+							$keep_ids[] = (int) $dummy;
1569
+			}
1502 1570
 
1503
-		if (isset($_SESSION['temp_attachments']))
1504
-			foreach ($_SESSION['temp_attachments'] as $attachID => $attachment)
1571
+		if (isset($_SESSION['temp_attachments'])) {
1572
+					foreach ($_SESSION['temp_attachments'] as $attachID => $attachment)
1505 1573
 			{
1506 1574
 				if ((isset($_SESSION['temp_attachments']['post']['files'], $attachment['name']) && in_array($attachment['name'], $_SESSION['temp_attachments']['post']['files'])) || in_array($attachID, $keep_temp) || strpos($attachID, 'post_tmp_' . $user_info['id']) === false)
1507 1575
 					continue;
1576
+		}
1508 1577
 
1509 1578
 				unset($_SESSION['temp_attachments'][$attachID]);
1510 1579
 				unlink($attachment['tmp_name']);
@@ -1536,8 +1605,9 @@  discard block
 block discarded – undo
1536 1605
 	{
1537 1606
 		require_once($sourcedir . '/ManageAttachments.php');
1538 1607
 
1539
-		foreach ($_SESSION['already_attached'] as $attachID => $attachment)
1540
-			removeAttachments(array('id_attach' => $attachID));
1608
+		foreach ($_SESSION['already_attached'] as $attachID => $attachment) {
1609
+					removeAttachments(array('id_attach' => $attachID));
1610
+		}
1541 1611
 
1542 1612
 		unset($_SESSION['already_attached']);
1543 1613
 
@@ -1560,12 +1630,14 @@  discard block
 block discarded – undo
1560 1630
 		$smcFunc['db_free_result']($request);
1561 1631
 
1562 1632
 		// Though the topic should be there, it might have vanished.
1563
-		if (!is_array($topic_info))
1564
-			fatal_lang_error('topic_doesnt_exist', 404);
1633
+		if (!is_array($topic_info)) {
1634
+					fatal_lang_error('topic_doesnt_exist', 404);
1635
+		}
1565 1636
 
1566 1637
 		// Did this topic suddenly move? Just checking...
1567
-		if ($topic_info['id_board'] != $board)
1568
-			fatal_lang_error('not_a_topic');
1638
+		if ($topic_info['id_board'] != $board) {
1639
+					fatal_lang_error('not_a_topic');
1640
+		}
1569 1641
 
1570 1642
 		// Do the permissions and approval stuff...
1571 1643
 		$becomesApproved = true;
@@ -1588,49 +1660,50 @@  discard block
 block discarded – undo
1588 1660
 	if (!empty($topic) && !isset($_REQUEST['msg']))
1589 1661
 	{
1590 1662
 		// Don't allow a post if it's locked.
1591
-		if ($topic_info['locked'] != 0 && !allowedTo('moderate_board'))
1592
-			fatal_lang_error('topic_locked', false);
1663
+		if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) {
1664
+					fatal_lang_error('topic_locked', false);
1665
+		}
1593 1666
 
1594 1667
 		// Sorry, multiple polls aren't allowed... yet.  You should stop giving me ideas :P.
1595
-		if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0)
1596
-			unset($_REQUEST['poll']);
1597
-
1598
-		elseif ($topic_info['id_member_started'] != $user_info['id'])
1599
-		{
1600
-			if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any'))
1601
-				$becomesApproved = false;
1602
-
1603
-			else
1604
-				isAllowedTo('post_reply_any');
1605
-		}
1606
-		elseif (!allowedTo('post_reply_any'))
1668
+		if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) {
1669
+					unset($_REQUEST['poll']);
1670
+		} elseif ($topic_info['id_member_started'] != $user_info['id'])
1671
+		{
1672
+			if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) {
1673
+							$becomesApproved = false;
1674
+			} else {
1675
+							isAllowedTo('post_reply_any');
1676
+			}
1677
+		} elseif (!allowedTo('post_reply_any'))
1607 1678
 		{
1608
-			if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own'))
1609
-				$becomesApproved = false;
1610
-
1611
-			else
1612
-				isAllowedTo('post_reply_own');
1679
+			if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) {
1680
+							$becomesApproved = false;
1681
+			} else {
1682
+							isAllowedTo('post_reply_own');
1683
+			}
1613 1684
 		}
1614 1685
 
1615 1686
 		if (isset($_POST['lock']))
1616 1687
 		{
1617 1688
 			// Nothing is changed to the lock.
1618
-			if (empty($topic_info['locked']) == empty($_POST['lock']))
1619
-				unset($_POST['lock']);
1689
+			if (empty($topic_info['locked']) == empty($_POST['lock'])) {
1690
+							unset($_POST['lock']);
1691
+			}
1620 1692
 
1621 1693
 			// You're have no permission to lock this topic.
1622
-			elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started']))
1623
-				unset($_POST['lock']);
1694
+			elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) {
1695
+							unset($_POST['lock']);
1696
+			}
1624 1697
 
1625 1698
 			// You are allowed to (un)lock your own topic only.
1626 1699
 			elseif (!allowedTo('lock_any'))
1627 1700
 			{
1628 1701
 				// You cannot override a moderator lock.
1629
-				if ($topic_info['locked'] == 1)
1630
-					unset($_POST['lock']);
1631
-
1632
-				else
1633
-					$_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
1702
+				if ($topic_info['locked'] == 1) {
1703
+									unset($_POST['lock']);
1704
+				} else {
1705
+									$_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
1706
+				}
1634 1707
 			}
1635 1708
 			// Hail mighty moderator, (un)lock this topic immediately.
1636 1709
 			else
@@ -1638,19 +1711,21 @@  discard block
 block discarded – undo
1638 1711
 				$_POST['lock'] = empty($_POST['lock']) ? 0 : 1;
1639 1712
 
1640 1713
 				// Did someone (un)lock this while you were posting?
1641
-				if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked'])
1642
-					$post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked';
1714
+				if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) {
1715
+									$post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked';
1716
+				}
1643 1717
 			}
1644 1718
 		}
1645 1719
 
1646 1720
 		// So you wanna (un)sticky this...let's see.
1647
-		if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky')))
1648
-			unset($_POST['sticky']);
1649
-		elseif (isset($_POST['sticky']))
1721
+		if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) {
1722
+					unset($_POST['sticky']);
1723
+		} elseif (isset($_POST['sticky']))
1650 1724
 		{
1651 1725
 			// Did someone (un)sticky this while you were posting?
1652
-			if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky'])
1653
-				$post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky';
1726
+			if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) {
1727
+							$post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky';
1728
+			}
1654 1729
 		}
1655 1730
 
1656 1731
 		// If drafts are enabled, then pass this off
@@ -1677,26 +1752,31 @@  discard block
 block discarded – undo
1677 1752
 
1678 1753
 		// Do like, the permissions, for safety and stuff...
1679 1754
 		$becomesApproved = true;
1680
-		if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics'))
1681
-			$becomesApproved = false;
1682
-		else
1683
-			isAllowedTo('post_new');
1755
+		if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) {
1756
+					$becomesApproved = false;
1757
+		} else {
1758
+					isAllowedTo('post_new');
1759
+		}
1684 1760
 
1685 1761
 		if (isset($_POST['lock']))
1686 1762
 		{
1687 1763
 			// New topics are by default not locked.
1688
-			if (empty($_POST['lock']))
1689
-				unset($_POST['lock']);
1764
+			if (empty($_POST['lock'])) {
1765
+							unset($_POST['lock']);
1766
+			}
1690 1767
 			// Besides, you need permission.
1691
-			elseif (!allowedTo(array('lock_any', 'lock_own')))
1692
-				unset($_POST['lock']);
1768
+			elseif (!allowedTo(array('lock_any', 'lock_own'))) {
1769
+							unset($_POST['lock']);
1770
+			}
1693 1771
 			// A moderator-lock (1) can override a user-lock (2).
1694
-			else
1695
-				$_POST['lock'] = allowedTo('lock_any') ? 1 : 2;
1772
+			else {
1773
+							$_POST['lock'] = allowedTo('lock_any') ? 1 : 2;
1774
+			}
1696 1775
 		}
1697 1776
 
1698
-		if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky')))
1699
-			unset($_POST['sticky']);
1777
+		if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) {
1778
+					unset($_POST['sticky']);
1779
+		}
1700 1780
 
1701 1781
 		// Saving your new topic as a draft first?
1702 1782
 		if (!empty($modSettings['drafts_post_enabled']) && isset($_POST['save_draft']))
@@ -1721,31 +1801,37 @@  discard block
 block discarded – undo
1721 1801
 				'id_msg' => $_REQUEST['msg'],
1722 1802
 			)
1723 1803
 		);
1724
-		if ($smcFunc['db_num_rows']($request) == 0)
1725
-			fatal_lang_error('cant_find_messages', false);
1804
+		if ($smcFunc['db_num_rows']($request) == 0) {
1805
+					fatal_lang_error('cant_find_messages', false);
1806
+		}
1726 1807
 		$row = $smcFunc['db_fetch_assoc']($request);
1727 1808
 		$smcFunc['db_free_result']($request);
1728 1809
 
1729
-		if (!empty($topic_info['locked']) && !allowedTo('moderate_board'))
1730
-			fatal_lang_error('topic_locked', false);
1810
+		if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) {
1811
+					fatal_lang_error('topic_locked', false);
1812
+		}
1731 1813
 
1732 1814
 		if (isset($_POST['lock']))
1733 1815
 		{
1734 1816
 			// Nothing changes to the lock status.
1735
-			if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked'])))
1736
-				unset($_POST['lock']);
1817
+			if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) {
1818
+							unset($_POST['lock']);
1819
+			}
1737 1820
 			// You're simply not allowed to (un)lock this.
1738
-			elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started']))
1739
-				unset($_POST['lock']);
1821
+			elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) {
1822
+							unset($_POST['lock']);
1823
+			}
1740 1824
 			// You're only allowed to lock your own topics.
1741 1825
 			elseif (!allowedTo('lock_any'))
1742 1826
 			{
1743 1827
 				// You're not allowed to break a moderator's lock.
1744
-				if ($topic_info['locked'] == 1)
1745
-					unset($_POST['lock']);
1828
+				if ($topic_info['locked'] == 1) {
1829
+									unset($_POST['lock']);
1830
+				}
1746 1831
 				// Lock it with a soft lock or unlock it.
1747
-				else
1748
-					$_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
1832
+				else {
1833
+									$_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
1834
+				}
1749 1835
 			}
1750 1836
 			// You must be the moderator.
1751 1837
 			else
@@ -1753,44 +1839,46 @@  discard block
 block discarded – undo
1753 1839
 				$_POST['lock'] = empty($_POST['lock']) ? 0 : 1;
1754 1840
 
1755 1841
 				// Did someone (un)lock this while you were posting?
1756
-				if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked'])
1757
-					$post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked';
1842
+				if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) {
1843
+									$post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked';
1844
+				}
1758 1845
 			}
1759 1846
 		}
1760 1847
 
1761 1848
 		// Change the sticky status of this topic?
1762
-		if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky']))
1763
-			unset($_POST['sticky']);
1764
-		elseif (isset($_POST['sticky']))
1849
+		if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) {
1850
+					unset($_POST['sticky']);
1851
+		} elseif (isset($_POST['sticky']))
1765 1852
 		{
1766 1853
 			// Did someone (un)sticky this while you were posting?
1767
-			if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky'])
1768
-				$post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied';
1854
+			if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) {
1855
+							$post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied';
1856
+			}
1769 1857
 		}
1770 1858
 
1771 1859
 		if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any'))
1772 1860
 		{
1773
-			if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time())
1774
-				fatal_lang_error('modify_post_time_passed', false);
1775
-			elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own'))
1776
-				isAllowedTo('modify_replies');
1777
-			else
1778
-				isAllowedTo('modify_own');
1779
-		}
1780
-		elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any'))
1861
+			if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) {
1862
+							fatal_lang_error('modify_post_time_passed', false);
1863
+			} elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) {
1864
+							isAllowedTo('modify_replies');
1865
+			} else {
1866
+							isAllowedTo('modify_own');
1867
+			}
1868
+		} elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any'))
1781 1869
 		{
1782 1870
 			isAllowedTo('modify_replies');
1783 1871
 
1784 1872
 			// If you're modifying a reply, I say it better be logged...
1785 1873
 			$moderationAction = true;
1786
-		}
1787
-		else
1874
+		} else
1788 1875
 		{
1789 1876
 			isAllowedTo('modify_any');
1790 1877
 
1791 1878
 			// Log it, assuming you're not modifying your own post.
1792
-			if ($row['id_member'] != $user_info['id'])
1793
-				$moderationAction = true;
1879
+			if ($row['id_member'] != $user_info['id']) {
1880
+							$moderationAction = true;
1881
+			}
1794 1882
 		}
1795 1883
 
1796 1884
 		// If drafts are enabled, then lets send this off to save
@@ -1817,8 +1905,9 @@  discard block
 block discarded – undo
1817 1905
 		// Update search api
1818 1906
 		require_once($sourcedir . '/Search.php');
1819 1907
 		$searchAPI = findSearchAPI();
1820
-		if ($searchAPI->supportsMethod('postRemoved'))
1821
-			$searchAPI->postRemoved($_REQUEST['msg']);
1908
+		if ($searchAPI->supportsMethod('postRemoved')) {
1909
+					$searchAPI->postRemoved($_REQUEST['msg']);
1910
+		}
1822 1911
 
1823 1912
 	}
1824 1913
 
@@ -1836,20 +1925,24 @@  discard block
 block discarded – undo
1836 1925
 		$_POST['guestname'] = !isset($_POST['guestname']) ? '' : trim($_POST['guestname']);
1837 1926
 		$_POST['email'] = !isset($_POST['email']) ? '' : trim($_POST['email']);
1838 1927
 
1839
-		if ($_POST['guestname'] == '' || $_POST['guestname'] == '_')
1840
-			$post_errors[] = 'no_name';
1841
-		if ($smcFunc['strlen']($_POST['guestname']) > 25)
1842
-			$post_errors[] = 'long_name';
1928
+		if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') {
1929
+					$post_errors[] = 'no_name';
1930
+		}
1931
+		if ($smcFunc['strlen']($_POST['guestname']) > 25) {
1932
+					$post_errors[] = 'long_name';
1933
+		}
1843 1934
 
1844 1935
 		if (empty($modSettings['guest_post_no_email']))
1845 1936
 		{
1846 1937
 			// Only check if they changed it!
1847 1938
 			if (!isset($row) || $row['poster_email'] != $_POST['email'])
1848 1939
 			{
1849
-				if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == ''))
1850
-					$post_errors[] = 'no_email';
1851
-				if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL))
1852
-					$post_errors[] = 'bad_email';
1940
+				if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) {
1941
+									$post_errors[] = 'no_email';
1942
+				}
1943
+				if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
1944
+									$post_errors[] = 'bad_email';
1945
+				}
1853 1946
 			}
1854 1947
 
1855 1948
 			// Now make sure this email address is not banned from posting.
@@ -1865,76 +1958,90 @@  discard block
 block discarded – undo
1865 1958
 	}
1866 1959
 
1867 1960
 	// Coming from the quickReply?
1868
-	if (isset($_POST['quickReply']))
1869
-		$_POST['message'] = $_POST['quickReply'];
1961
+	if (isset($_POST['quickReply'])) {
1962
+			$_POST['message'] = $_POST['quickReply'];
1963
+	}
1870 1964
 
1871 1965
 	// Check the subject and message.
1872
-	if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '')
1873
-		$post_errors[] = 'no_subject';
1874
-	if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '')
1875
-		$post_errors[] = 'no_message';
1876
-	elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength'])
1877
-		$post_errors[] = array('long_message', array($modSettings['max_messageLength']));
1878
-	else
1966
+	if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') {
1967
+			$post_errors[] = 'no_subject';
1968
+	}
1969
+	if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') {
1970
+			$post_errors[] = 'no_message';
1971
+	} elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) {
1972
+			$post_errors[] = array('long_message', array($modSettings['max_messageLength']));
1973
+	} else
1879 1974
 	{
1880 1975
 		// Prepare the message a bit for some additional testing.
1881 1976
 		$_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES);
1882 1977
 
1883 1978
 		// Preparse code. (Zef)
1884
-		if ($user_info['is_guest'])
1885
-			$user_info['name'] = $_POST['guestname'];
1979
+		if ($user_info['is_guest']) {
1980
+					$user_info['name'] = $_POST['guestname'];
1981
+		}
1886 1982
 		preparsecode($_POST['message']);
1887 1983
 
1888 1984
 		// Let's see if there's still some content left without the tags.
1889
-		if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false))
1890
-			$post_errors[] = 'no_message';
1985
+		if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) {
1986
+					$post_errors[] = 'no_message';
1987
+		}
1891 1988
 
1892 1989
 	}
1893
-	if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '')
1894
-		$post_errors[] = 'no_event';
1990
+	if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') {
1991
+			$post_errors[] = 'no_event';
1992
+	}
1895 1993
 	// You are not!
1896
-	if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin'])
1897
-		fatal_error('Knave! Masquerader! Charlatan!', false);
1994
+	if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) {
1995
+			fatal_error('Knave! Masquerader! Charlatan!', false);
1996
+	}
1898 1997
 
1899 1998
 	// Validate the poll...
1900 1999
 	if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1')
1901 2000
 	{
1902
-		if (!empty($topic) && !isset($_REQUEST['msg']))
1903
-			fatal_lang_error('no_access', false);
2001
+		if (!empty($topic) && !isset($_REQUEST['msg'])) {
2002
+					fatal_lang_error('no_access', false);
2003
+		}
1904 2004
 
1905 2005
 		// This is a new topic... so it's a new poll.
1906
-		if (empty($topic))
1907
-			isAllowedTo('poll_post');
2006
+		if (empty($topic)) {
2007
+					isAllowedTo('poll_post');
2008
+		}
1908 2009
 		// Can you add to your own topics?
1909
-		elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any'))
1910
-			isAllowedTo('poll_add_own');
2010
+		elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) {
2011
+					isAllowedTo('poll_add_own');
2012
+		}
1911 2013
 		// Can you add polls to any topic, then?
1912
-		else
1913
-			isAllowedTo('poll_add_any');
2014
+		else {
2015
+					isAllowedTo('poll_add_any');
2016
+		}
1914 2017
 
1915
-		if (!isset($_POST['question']) || trim($_POST['question']) == '')
1916
-			$post_errors[] = 'no_question';
2018
+		if (!isset($_POST['question']) || trim($_POST['question']) == '') {
2019
+					$post_errors[] = 'no_question';
2020
+		}
1917 2021
 
1918 2022
 		$_POST['options'] = empty($_POST['options']) ? array() : htmltrim__recursive($_POST['options']);
1919 2023
 
1920 2024
 		// Get rid of empty ones.
1921
-		foreach ($_POST['options'] as $k => $option)
1922
-			if ($option == '')
2025
+		foreach ($_POST['options'] as $k => $option) {
2026
+					if ($option == '')
1923 2027
 				unset($_POST['options'][$k], $_POST['options'][$k]);
2028
+		}
1924 2029
 
1925 2030
 		// What are you going to vote between with one choice?!?
1926
-		if (count($_POST['options']) < 2)
1927
-			$post_errors[] = 'poll_few';
1928
-		elseif (count($_POST['options']) > 256)
1929
-			$post_errors[] = 'poll_many';
2031
+		if (count($_POST['options']) < 2) {
2032
+					$post_errors[] = 'poll_few';
2033
+		} elseif (count($_POST['options']) > 256) {
2034
+					$post_errors[] = 'poll_many';
2035
+		}
1930 2036
 	}
1931 2037
 
1932 2038
 	if ($posterIsGuest)
1933 2039
 	{
1934 2040
 		// If user is a guest, make sure the chosen name isn't taken.
1935 2041
 		require_once($sourcedir . '/Subs-Members.php');
1936
-		if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name']))
1937
-			$post_errors[] = 'bad_name';
2042
+		if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) {
2043
+					$post_errors[] = 'bad_name';
2044
+		}
1938 2045
 	}
1939 2046
 	// If the user isn't a guest, get his or her name and email.
1940 2047
 	elseif (!isset($_REQUEST['msg']))
@@ -1965,8 +2072,9 @@  discard block
 block discarded – undo
1965 2072
 	}
1966 2073
 
1967 2074
 	// Make sure the user isn't spamming the board.
1968
-	if (!isset($_REQUEST['msg']))
1969
-		spamProtection('post');
2075
+	if (!isset($_REQUEST['msg'])) {
2076
+			spamProtection('post');
2077
+	}
1970 2078
 
1971 2079
 	// At about this point, we're posting and that's that.
1972 2080
 	ignore_user_abort(true);
@@ -1979,32 +2087,36 @@  discard block
 block discarded – undo
1979 2087
 	$_POST['modify_reason'] = empty($_POST['modify_reason']) ? '' : strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => ''));
1980 2088
 
1981 2089
 	// At this point, we want to make sure the subject isn't too long.
1982
-	if ($smcFunc['strlen']($_POST['subject']) > 100)
1983
-		$_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100);
2090
+	if ($smcFunc['strlen']($_POST['subject']) > 100) {
2091
+			$_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100);
2092
+	}
1984 2093
 
1985 2094
 	// Same with the "why did you edit this" text.
1986
-	if ($smcFunc['strlen']($_POST['modify_reason']) > 100)
1987
-		$_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100);
2095
+	if ($smcFunc['strlen']($_POST['modify_reason']) > 100) {
2096
+			$_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100);
2097
+	}
1988 2098
 
1989 2099
 	// Make the poll...
1990 2100
 	if (isset($_REQUEST['poll']))
1991 2101
 	{
1992 2102
 		// Make sure that the user has not entered a ridiculous number of options..
1993
-		if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0)
1994
-			$_POST['poll_max_votes'] = 1;
1995
-		elseif ($_POST['poll_max_votes'] > count($_POST['options']))
1996
-			$_POST['poll_max_votes'] = count($_POST['options']);
1997
-		else
1998
-			$_POST['poll_max_votes'] = (int) $_POST['poll_max_votes'];
2103
+		if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) {
2104
+					$_POST['poll_max_votes'] = 1;
2105
+		} elseif ($_POST['poll_max_votes'] > count($_POST['options'])) {
2106
+					$_POST['poll_max_votes'] = count($_POST['options']);
2107
+		} else {
2108
+					$_POST['poll_max_votes'] = (int) $_POST['poll_max_votes'];
2109
+		}
1999 2110
 
2000 2111
 		$_POST['poll_expire'] = (int) $_POST['poll_expire'];
2001 2112
 		$_POST['poll_expire'] = $_POST['poll_expire'] > 9999 ? 9999 : ($_POST['poll_expire'] < 0 ? 0 : $_POST['poll_expire']);
2002 2113
 
2003 2114
 		// Just set it to zero if it's not there..
2004
-		if (!isset($_POST['poll_hide']))
2005
-			$_POST['poll_hide'] = 0;
2006
-		else
2007
-			$_POST['poll_hide'] = (int) $_POST['poll_hide'];
2115
+		if (!isset($_POST['poll_hide'])) {
2116
+					$_POST['poll_hide'] = 0;
2117
+		} else {
2118
+					$_POST['poll_hide'] = (int) $_POST['poll_hide'];
2119
+		}
2008 2120
 		$_POST['poll_change_vote'] = isset($_POST['poll_change_vote']) ? 1 : 0;
2009 2121
 
2010 2122
 		$_POST['poll_guest_vote'] = isset($_POST['poll_guest_vote']) ? 1 : 0;
@@ -2013,16 +2125,19 @@  discard block
 block discarded – undo
2013 2125
 		{
2014 2126
 			require_once($sourcedir . '/Subs-Members.php');
2015 2127
 			$allowedVoteGroups = groupsAllowedTo('poll_vote', $board);
2016
-			if (!in_array(-1, $allowedVoteGroups['allowed']))
2017
-				$_POST['poll_guest_vote'] = 0;
2128
+			if (!in_array(-1, $allowedVoteGroups['allowed'])) {
2129
+							$_POST['poll_guest_vote'] = 0;
2130
+			}
2018 2131
 		}
2019 2132
 
2020 2133
 		// If the user tries to set the poll too far in advance, don't let them.
2021
-		if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1)
2022
-			fatal_lang_error('poll_range_error', false);
2134
+		if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) {
2135
+					fatal_lang_error('poll_range_error', false);
2136
+		}
2023 2137
 		// Don't allow them to select option 2 for hidden results if it's not time limited.
2024
-		elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2)
2025
-			$_POST['poll_hide'] = 1;
2138
+		elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) {
2139
+					$_POST['poll_hide'] = 1;
2140
+		}
2026 2141
 
2027 2142
 		// Clean up the question and answers.
2028 2143
 		$_POST['question'] = $smcFunc['htmlspecialchars']($_POST['question']);
@@ -2036,13 +2151,15 @@  discard block
 block discarded – undo
2036 2151
 	{
2037 2152
 		$attachIDs = array();
2038 2153
 		$attach_errors = array();
2039
-		if (!empty($context['we_are_history']))
2040
-			$attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>';
2154
+		if (!empty($context['we_are_history'])) {
2155
+					$attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>';
2156
+		}
2041 2157
 
2042 2158
 		foreach ($_SESSION['temp_attachments'] as  $attachID => $attachment)
2043 2159
 		{
2044
-			if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false)
2045
-				continue;
2160
+			if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) {
2161
+							continue;
2162
+			}
2046 2163
 
2047 2164
 			// If there was an initial error just show that message.
2048 2165
 			if ($attachID == 'initial_error')
@@ -2071,12 +2188,13 @@  discard block
 block discarded – undo
2071 2188
 				if (createAttachment($attachmentOptions))
2072 2189
 				{
2073 2190
 					$attachIDs[] = $attachmentOptions['id'];
2074
-					if (!empty($attachmentOptions['thumb']))
2075
-						$attachIDs[] = $attachmentOptions['thumb'];
2191
+					if (!empty($attachmentOptions['thumb'])) {
2192
+											$attachIDs[] = $attachmentOptions['thumb'];
2193
+					}
2076 2194
 				}
2195
+			} else {
2196
+							$attach_errors[] = '<dt>&nbsp;</dt>';
2077 2197
 			}
2078
-			else
2079
-				$attach_errors[] = '<dt>&nbsp;</dt>';
2080 2198
 
2081 2199
 			if (!empty($attachmentOptions['errors']))
2082 2200
 			{
@@ -2088,14 +2206,16 @@  discard block
 block discarded – undo
2088 2206
 					if (!is_array($error))
2089 2207
 					{
2090 2208
 						$attach_errors[] = '<dd>' . $txt[$error] . '</dd>';
2091
-						if (in_array($error, $log_these))
2092
-							log_error($attachment['name'] . ': ' . $txt[$error], 'critical');
2209
+						if (in_array($error, $log_these)) {
2210
+													log_error($attachment['name'] . ': ' . $txt[$error], 'critical');
2211
+						}
2212
+					} else {
2213
+											$attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>';
2093 2214
 					}
2094
-					else
2095
-						$attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>';
2096 2215
 				}
2097
-				if (file_exists($attachment['tmp_name']))
2098
-					unlink($attachment['tmp_name']);
2216
+				if (file_exists($attachment['tmp_name'])) {
2217
+									unlink($attachment['tmp_name']);
2218
+				}
2099 2219
 			}
2100 2220
 		}
2101 2221
 		unset($_SESSION['temp_attachments']);
@@ -2136,24 +2256,24 @@  discard block
 block discarded – undo
2136 2256
 		);
2137 2257
 
2138 2258
 		call_integration_hook('integrate_poll_add_edit', array($id_poll, false));
2259
+	} else {
2260
+			$id_poll = 0;
2139 2261
 	}
2140
-	else
2141
-		$id_poll = 0;
2142 2262
 
2143 2263
 	// Creating a new topic?
2144 2264
 	$newTopic = empty($_REQUEST['msg']) && empty($topic);
2145 2265
 
2146 2266
 	// Check the icon.
2147
-	if (!isset($_POST['icon']))
2148
-		$_POST['icon'] = 'xx';
2149
-
2150
-	else
2267
+	if (!isset($_POST['icon'])) {
2268
+			$_POST['icon'] = 'xx';
2269
+	} else
2151 2270
 	{
2152 2271
 		$_POST['icon'] = $smcFunc['htmlspecialchars']($_POST['icon']);
2153 2272
 
2154 2273
 		// Need to figure it out if this is a valid icon name.
2155
-		if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')))
2156
-			$_POST['icon'] = 'xx';
2274
+		if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) {
2275
+					$_POST['icon'] = 'xx';
2276
+		}
2157 2277
 	}
2158 2278
 
2159 2279
 	// Collect all parameters for the creation or modification of a post.
@@ -2194,8 +2314,9 @@  discard block
 block discarded – undo
2194 2314
 		}
2195 2315
 
2196 2316
 		// This will save some time...
2197
-		if (empty($approve_has_changed))
2198
-			unset($msgOptions['approved']);
2317
+		if (empty($approve_has_changed)) {
2318
+					unset($msgOptions['approved']);
2319
+		}
2199 2320
 
2200 2321
 		modifyPost($msgOptions, $topicOptions, $posterOptions);
2201 2322
 	}
@@ -2204,8 +2325,9 @@  discard block
 block discarded – undo
2204 2325
 	{
2205 2326
 		createPost($msgOptions, $topicOptions, $posterOptions);
2206 2327
 
2207
-		if (isset($topicOptions['id']))
2208
-			$topic = $topicOptions['id'];
2328
+		if (isset($topicOptions['id'])) {
2329
+					$topic = $topicOptions['id'];
2330
+		}
2209 2331
 	}
2210 2332
 
2211 2333
 	// Are there attachments already uploaded and waiting to be assigned?
@@ -2217,8 +2339,9 @@  discard block
 block discarded – undo
2217 2339
 	}
2218 2340
 
2219 2341
 	// If we had a draft for this, its time to remove it since it was just posted
2220
-	if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft']))
2221
-		DeleteDraft($_POST['id_draft']);
2342
+	if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) {
2343
+			DeleteDraft($_POST['id_draft']);
2344
+	}
2222 2345
 
2223 2346
 	// Editing or posting an event?
2224 2347
 	if (isset($_POST['calendar']) && (!isset($_REQUEST['eventid']) || $_REQUEST['eventid'] == -1))
@@ -2237,8 +2360,7 @@  discard block
 block discarded – undo
2237 2360
 			'member' => $user_info['id'],
2238 2361
 		);
2239 2362
 		insertEvent($eventOptions);
2240
-	}
2241
-	elseif (isset($_POST['calendar']))
2363
+	} elseif (isset($_POST['calendar']))
2242 2364
 	{
2243 2365
 		$_REQUEST['eventid'] = (int) $_REQUEST['eventid'];
2244 2366
 
@@ -2266,14 +2388,15 @@  discard block
 block discarded – undo
2266 2388
 		}
2267 2389
 
2268 2390
 		// Delete it?
2269
-		if (isset($_REQUEST['deleteevent']))
2270
-			$smcFunc['db_query']('', '
2391
+		if (isset($_REQUEST['deleteevent'])) {
2392
+					$smcFunc['db_query']('', '
2271 2393
 				DELETE FROM {db_prefix}calendar
2272 2394
 				WHERE id_event = {int:id_event}',
2273 2395
 				array(
2274 2396
 					'id_event' => $_REQUEST['eventid'],
2275 2397
 				)
2276 2398
 			);
2399
+		}
2277 2400
 		// ... or just update it?
2278 2401
 		else
2279 2402
 		{
@@ -2315,9 +2438,8 @@  discard block
 block discarded – undo
2315 2438
 			array($user_info['id'], $topic, 0),
2316 2439
 			array('id_member', 'id_topic', 'id_board')
2317 2440
 		);
2318
-	}
2319
-	elseif (!$newTopic)
2320
-		$smcFunc['db_query']('', '
2441
+	} elseif (!$newTopic) {
2442
+			$smcFunc['db_query']('', '
2321 2443
 			DELETE FROM {db_prefix}log_notify
2322 2444
 			WHERE id_member = {int:current_member}
2323 2445
 				AND id_topic = {int:current_topic}',
@@ -2326,16 +2448,20 @@  discard block
 block discarded – undo
2326 2448
 				'current_topic' => $topic,
2327 2449
 			)
2328 2450
 		);
2451
+	}
2329 2452
 
2330 2453
 	// Log an act of moderation - modifying.
2331
-	if (!empty($moderationAction))
2332
-		logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board));
2454
+	if (!empty($moderationAction)) {
2455
+			logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board));
2456
+	}
2333 2457
 
2334
-	if (isset($_POST['lock']) && $_POST['lock'] != 2)
2335
-		logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board']));
2458
+	if (isset($_POST['lock']) && $_POST['lock'] != 2) {
2459
+			logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board']));
2460
+	}
2336 2461
 
2337
-	if (isset($_POST['sticky']))
2338
-		logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board']));
2462
+	if (isset($_POST['sticky'])) {
2463
+			logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board']));
2464
+	}
2339 2465
 
2340 2466
 	// Returning to the topic?
2341 2467
 	if (!empty($_REQUEST['goback']))
@@ -2354,26 +2480,31 @@  discard block
 block discarded – undo
2354 2480
 		);
2355 2481
 	}
2356 2482
 
2357
-	if ($board_info['num_topics'] == 0)
2358
-		cache_put_data('board-' . $board, null, 120);
2483
+	if ($board_info['num_topics'] == 0) {
2484
+			cache_put_data('board-' . $board, null, 120);
2485
+	}
2359 2486
 
2360 2487
 	call_integration_hook('integrate_post2_end');
2361 2488
 
2362
-	if (!empty($_POST['announce_topic']) && allowedTo('announce_topic'))
2363
-		redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback'));
2489
+	if (!empty($_POST['announce_topic']) && allowedTo('announce_topic')) {
2490
+			redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback'));
2491
+	}
2364 2492
 
2365
-	if (!empty($_POST['move']) && allowedTo('move_any'))
2366
-		redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback'));
2493
+	if (!empty($_POST['move']) && allowedTo('move_any')) {
2494
+			redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback'));
2495
+	}
2367 2496
 
2368 2497
 	// Return to post if the mod is on.
2369
-	if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback']))
2370
-		redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie'));
2371
-	elseif (!empty($_REQUEST['goback']))
2372
-		redirectexit('topic=' . $topic . '.new#new', isBrowser('ie'));
2498
+	if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) {
2499
+			redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie'));
2500
+	} elseif (!empty($_REQUEST['goback'])) {
2501
+			redirectexit('topic=' . $topic . '.new#new', isBrowser('ie'));
2502
+	}
2373 2503
 	// Dut-dut-duh-duh-DUH-duh-dut-duh-duh!  *dances to the Final Fantasy Fanfare...*
2374
-	else
2375
-		redirectexit('board=' . $board . '.0');
2376
-}
2504
+	else {
2505
+			redirectexit('board=' . $board . '.0');
2506
+	}
2507
+	}
2377 2508
 
2378 2509
 /**
2379 2510
  * Handle the announce topic function (action=announce).
@@ -2391,8 +2522,9 @@  discard block
 block discarded – undo
2391 2522
 
2392 2523
 	validateSession();
2393 2524
 
2394
-	if (empty($topic))
2395
-		fatal_lang_error('topic_gone', false);
2525
+	if (empty($topic)) {
2526
+			fatal_lang_error('topic_gone', false);
2527
+	}
2396 2528
 
2397 2529
 	loadLanguage('Post');
2398 2530
 	loadTemplate('Post');
@@ -2419,8 +2551,9 @@  discard block
 block discarded – undo
2419 2551
 	global $txt, $context, $topic, $board_info, $smcFunc;
2420 2552
 
2421 2553
 	$groups = array_merge($board_info['groups'], array(1));
2422
-	foreach ($groups as $id => $group)
2423
-		$groups[$id] = (int) $group;
2554
+	foreach ($groups as $id => $group) {
2555
+			$groups[$id] = (int) $group;
2556
+	}
2424 2557
 
2425 2558
 	$context['groups'] = array();
2426 2559
 	if (in_array(0, $groups))
@@ -2463,8 +2596,9 @@  discard block
 block discarded – undo
2463 2596
 			'group_list' => $groups,
2464 2597
 		)
2465 2598
 	);
2466
-	while ($row = $smcFunc['db_fetch_assoc']($request))
2467
-		$context['groups'][$row['id_group']]['name'] = $row['group_name'];
2599
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
2600
+			$context['groups'][$row['id_group']]['name'] = $row['group_name'];
2601
+	}
2468 2602
 	$smcFunc['db_free_result']($request);
2469 2603
 
2470 2604
 	// Get the subject of the topic we're about to announce.
@@ -2506,16 +2640,19 @@  discard block
 block discarded – undo
2506 2640
 	$context['start'] = empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start'];
2507 2641
 	$groups = array_merge($board_info['groups'], array(1));
2508 2642
 
2509
-	if (isset($_POST['membergroups']))
2510
-		$_POST['who'] = explode(',', $_POST['membergroups']);
2643
+	if (isset($_POST['membergroups'])) {
2644
+			$_POST['who'] = explode(',', $_POST['membergroups']);
2645
+	}
2511 2646
 
2512 2647
 	// Check whether at least one membergroup was selected.
2513
-	if (empty($_POST['who']))
2514
-		fatal_lang_error('no_membergroup_selected');
2648
+	if (empty($_POST['who'])) {
2649
+			fatal_lang_error('no_membergroup_selected');
2650
+	}
2515 2651
 
2516 2652
 	// Make sure all membergroups are integers and can access the board of the announcement.
2517
-	foreach ($_POST['who'] as $id => $mg)
2518
-		$_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0;
2653
+	foreach ($_POST['who'] as $id => $mg) {
2654
+			$_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0;
2655
+	}
2519 2656
 
2520 2657
 	// Get the topic subject and censor it.
2521 2658
 	$request = $smcFunc['db_query']('', '
@@ -2561,12 +2698,13 @@  discard block
 block discarded – undo
2561 2698
 	if ($smcFunc['db_num_rows']($request) == 0)
2562 2699
 	{
2563 2700
 		logAction('announce_topic', array('topic' => $topic), 'user');
2564
-		if (!empty($_REQUEST['move']) && allowedTo('move_any'))
2565
-			redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback'));
2566
-		elseif (!empty($_REQUEST['goback']))
2567
-			redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie'));
2568
-		else
2569
-			redirectexit('board=' . $board . '.0');
2701
+		if (!empty($_REQUEST['move']) && allowedTo('move_any')) {
2702
+					redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback'));
2703
+		} elseif (!empty($_REQUEST['goback'])) {
2704
+					redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie'));
2705
+		} else {
2706
+					redirectexit('board=' . $board . '.0');
2707
+		}
2570 2708
 	}
2571 2709
 
2572 2710
 	$announcements = array();
@@ -2585,8 +2723,9 @@  discard block
 block discarded – undo
2585 2723
 	foreach ($rows as $row)
2586 2724
 	{
2587 2725
 		// Force them to have it?
2588
-		if (empty($prefs[$row['id_member']]['announcements']))
2589
-			continue;
2726
+		if (empty($prefs[$row['id_member']]['announcements'])) {
2727
+					continue;
2728
+		}
2590 2729
 
2591 2730
 		$cur_language = empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile'];
2592 2731
 
@@ -2614,8 +2753,9 @@  discard block
 block discarded – undo
2614 2753
 	}
2615 2754
 
2616 2755
 	// For each language send a different mail - low priority...
2617
-	foreach ($announcements as $lang => $mail)
2618
-		sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5);
2756
+	foreach ($announcements as $lang => $mail) {
2757
+			sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5);
2758
+	}
2619 2759
 
2620 2760
 	$context['percentage_done'] = round(100 * $context['start'] / $modSettings['latestMember'], 1);
2621 2761
 
@@ -2625,9 +2765,10 @@  discard block
 block discarded – undo
2625 2765
 	$context['sub_template'] = 'announcement_send';
2626 2766
 
2627 2767
 	// Go back to the correct language for the user ;).
2628
-	if (!empty($modSettings['userLanguage']))
2629
-		loadLanguage('Post');
2630
-}
2768
+	if (!empty($modSettings['userLanguage'])) {
2769
+			loadLanguage('Post');
2770
+	}
2771
+	}
2631 2772
 
2632 2773
 /**
2633 2774
  * Get the topic for display purposes.
@@ -2640,12 +2781,13 @@  discard block
 block discarded – undo
2640 2781
 {
2641 2782
 	global $topic, $modSettings, $context, $smcFunc, $counter, $options;
2642 2783
 
2643
-	if (isset($_REQUEST['xml']))
2644
-		$limit = '
2784
+	if (isset($_REQUEST['xml'])) {
2785
+			$limit = '
2645 2786
 		LIMIT ' . (empty($context['new_replies']) ? '0' : $context['new_replies']);
2646
-	else
2647
-		$limit = empty($modSettings['topicSummaryPosts']) ? '' : '
2787
+	} else {
2788
+			$limit = empty($modSettings['topicSummaryPosts']) ? '' : '
2648 2789
 		LIMIT ' . (int) $modSettings['topicSummaryPosts'];
2790
+	}
2649 2791
 
2650 2792
 	// If you're modifying, get only those posts before the current one. (otherwise get all.)
2651 2793
 	$request = $smcFunc['db_query']('', '
@@ -2683,8 +2825,9 @@  discard block
 block discarded – undo
2683 2825
 			'is_ignored' => !empty($modSettings['enable_buddylist']) && !empty($options['posts_apply_ignore_list']) && in_array($row['id_member'], $context['user']['ignoreusers']),
2684 2826
 		);
2685 2827
 
2686
-		if (!empty($context['new_replies']))
2687
-			$context['new_replies']--;
2828
+		if (!empty($context['new_replies'])) {
2829
+					$context['new_replies']--;
2830
+		}
2688 2831
 	}
2689 2832
 	$smcFunc['db_free_result']($request);
2690 2833
 }
@@ -2701,8 +2844,9 @@  discard block
 block discarded – undo
2701 2844
 	global $sourcedir, $smcFunc;
2702 2845
 
2703 2846
 	loadLanguage('Post');
2704
-	if (!isset($_REQUEST['xml']))
2705
-		loadTemplate('Post');
2847
+	if (!isset($_REQUEST['xml'])) {
2848
+			loadTemplate('Post');
2849
+	}
2706 2850
 
2707 2851
 	include_once($sourcedir . '/Subs-Post.php');
2708 2852
 
@@ -2733,8 +2877,9 @@  discard block
 block discarded – undo
2733 2877
 	$smcFunc['db_free_result']($request);
2734 2878
 
2735 2879
 	$context['sub_template'] = 'quotefast';
2736
-	if (!empty($row))
2737
-		$can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']);
2880
+	if (!empty($row)) {
2881
+			$can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']);
2882
+	}
2738 2883
 
2739 2884
 	if (!empty($can_view_post))
2740 2885
 	{
@@ -2767,8 +2912,9 @@  discard block
 block discarded – undo
2767 2912
 		}
2768 2913
 
2769 2914
 		// Remove any nested quotes.
2770
-		if (!empty($modSettings['removeNestedQuotes']))
2771
-			$row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']);
2915
+		if (!empty($modSettings['removeNestedQuotes'])) {
2916
+					$row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']);
2917
+		}
2772 2918
 
2773 2919
 		$lb = "\n";
2774 2920
 
@@ -2794,14 +2940,14 @@  discard block
 block discarded – undo
2794 2940
 				'time' => '',
2795 2941
 			),
2796 2942
 		);
2797
-	}
2798
-	else
2799
-		$context['quote'] = array(
2943
+	} else {
2944
+			$context['quote'] = array(
2800 2945
 			'xml' => '',
2801 2946
 			'mozilla' => '',
2802 2947
 			'text' => '',
2803 2948
 		);
2804
-}
2949
+	}
2950
+	}
2805 2951
 
2806 2952
 /**
2807 2953
  * Used to edit the body or subject of a message inline
@@ -2813,8 +2959,9 @@  discard block
 block discarded – undo
2813 2959
 	global $user_info, $context, $smcFunc, $language, $board_info;
2814 2960
 
2815 2961
 	// We have to have a topic!
2816
-	if (empty($topic))
2817
-		obExit(false);
2962
+	if (empty($topic)) {
2963
+			obExit(false);
2964
+	}
2818 2965
 
2819 2966
 	checkSession('get');
2820 2967
 	require_once($sourcedir . '/Subs-Post.php');
@@ -2840,31 +2987,35 @@  discard block
 block discarded – undo
2840 2987
 			'guest_id' => 0,
2841 2988
 		)
2842 2989
 	);
2843
-	if ($smcFunc['db_num_rows']($request) == 0)
2844
-		fatal_lang_error('no_board', false);
2990
+	if ($smcFunc['db_num_rows']($request) == 0) {
2991
+			fatal_lang_error('no_board', false);
2992
+	}
2845 2993
 	$row = $smcFunc['db_fetch_assoc']($request);
2846 2994
 	$smcFunc['db_free_result']($request);
2847 2995
 
2848 2996
 	// Change either body or subject requires permissions to modify messages.
2849 2997
 	if (isset($_POST['message']) || isset($_POST['subject']) || isset($_REQUEST['icon']))
2850 2998
 	{
2851
-		if (!empty($row['locked']))
2852
-			isAllowedTo('moderate_board');
2999
+		if (!empty($row['locked'])) {
3000
+					isAllowedTo('moderate_board');
3001
+		}
2853 3002
 
2854 3003
 		if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any'))
2855 3004
 		{
2856
-			if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time())
2857
-				fatal_lang_error('modify_post_time_passed', false);
2858
-			elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own'))
2859
-				isAllowedTo('modify_replies');
2860
-			else
2861
-				isAllowedTo('modify_own');
3005
+			if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) {
3006
+							fatal_lang_error('modify_post_time_passed', false);
3007
+			} elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) {
3008
+							isAllowedTo('modify_replies');
3009
+			} else {
3010
+							isAllowedTo('modify_own');
3011
+			}
2862 3012
 		}
2863 3013
 		// Otherwise, they're locked out; someone who can modify the replies is needed.
2864
-		elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any'))
2865
-			isAllowedTo('modify_replies');
2866
-		else
2867
-			isAllowedTo('modify_any');
3014
+		elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) {
3015
+					isAllowedTo('modify_replies');
3016
+		} else {
3017
+					isAllowedTo('modify_any');
3018
+		}
2868 3019
 
2869 3020
 		// Only log this action if it wasn't your message.
2870 3021
 		$moderationAction = $row['id_member'] != $user_info['id'];
@@ -2876,10 +3027,10 @@  discard block
 block discarded – undo
2876 3027
 		$_POST['subject'] = strtr($smcFunc['htmlspecialchars']($_POST['subject']), array("\r" => '', "\n" => '', "\t" => ''));
2877 3028
 
2878 3029
 		// Maximum number of characters.
2879
-		if ($smcFunc['strlen']($_POST['subject']) > 100)
2880
-			$_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100);
2881
-	}
2882
-	elseif (isset($_POST['subject']))
3030
+		if ($smcFunc['strlen']($_POST['subject']) > 100) {
3031
+					$_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100);
3032
+		}
3033
+	} elseif (isset($_POST['subject']))
2883 3034
 	{
2884 3035
 		$post_errors[] = 'no_subject';
2885 3036
 		unset($_POST['subject']);
@@ -2891,13 +3042,11 @@  discard block
 block discarded – undo
2891 3042
 		{
2892 3043
 			$post_errors[] = 'no_message';
2893 3044
 			unset($_POST['message']);
2894
-		}
2895
-		elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength'])
3045
+		} elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength'])
2896 3046
 		{
2897 3047
 			$post_errors[] = 'long_message';
2898 3048
 			unset($_POST['message']);
2899
-		}
2900
-		else
3049
+		} else
2901 3050
 		{
2902 3051
 			$_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES);
2903 3052
 
@@ -2913,31 +3062,34 @@  discard block
 block discarded – undo
2913 3062
 
2914 3063
 	if (isset($_POST['lock']))
2915 3064
 	{
2916
-		if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member']))
2917
-			unset($_POST['lock']);
2918
-		elseif (!allowedTo('lock_any'))
3065
+		if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) {
3066
+					unset($_POST['lock']);
3067
+		} elseif (!allowedTo('lock_any'))
2919 3068
 		{
2920
-			if ($row['locked'] == 1)
2921
-				unset($_POST['lock']);
2922
-			else
2923
-				$_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
3069
+			if ($row['locked'] == 1) {
3070
+							unset($_POST['lock']);
3071
+			} else {
3072
+							$_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
3073
+			}
3074
+		} elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) {
3075
+					unset($_POST['lock']);
3076
+		} else {
3077
+					$_POST['lock'] = empty($_POST['lock']) ? 0 : 1;
2924 3078
 		}
2925
-		elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked'])
2926
-			unset($_POST['lock']);
2927
-		else
2928
-			$_POST['lock'] = empty($_POST['lock']) ? 0 : 1;
2929 3079
 	}
2930 3080
 
2931
-	if (isset($_POST['sticky']) && !allowedTo('make_sticky'))
2932
-		unset($_POST['sticky']);
3081
+	if (isset($_POST['sticky']) && !allowedTo('make_sticky')) {
3082
+			unset($_POST['sticky']);
3083
+	}
2933 3084
 
2934 3085
 	if (isset($_POST['modify_reason']))
2935 3086
 	{
2936 3087
 		$_POST['modify_reason'] = strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => ''));
2937 3088
 
2938 3089
 		// Maximum number of characters.
2939
-		if ($smcFunc['strlen']($_POST['modify_reason']) > 100)
2940
-			$_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100);
3090
+		if ($smcFunc['strlen']($_POST['modify_reason']) > 100) {
3091
+					$_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100);
3092
+		}
2941 3093
 	}
2942 3094
 
2943 3095
 	if (empty($post_errors))
@@ -2974,8 +3126,9 @@  discard block
 block discarded – undo
2974 3126
 			}
2975 3127
 		}
2976 3128
 		// If nothing was changed there's no need to add an entry to the moderation log.
2977
-		else
2978
-			$moderationAction = false;
3129
+		else {
3130
+					$moderationAction = false;
3131
+		}
2979 3132
 
2980 3133
 		modifyPost($msgOptions, $topicOptions, $posterOptions);
2981 3134
 
@@ -2993,9 +3146,9 @@  discard block
 block discarded – undo
2993 3146
 			// Get the proper (default language) response prefix first.
2994 3147
 			if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix')))
2995 3148
 			{
2996
-				if ($language === $user_info['language'])
2997
-					$context['response_prefix'] = $txt['response_prefix'];
2998
-				else
3149
+				if ($language === $user_info['language']) {
3150
+									$context['response_prefix'] = $txt['response_prefix'];
3151
+				} else
2999 3152
 				{
3000 3153
 					loadLanguage('index', $language, false);
3001 3154
 					$context['response_prefix'] = $txt['response_prefix'];
@@ -3017,8 +3170,9 @@  discard block
 block discarded – undo
3017 3170
 			);
3018 3171
 		}
3019 3172
 
3020
-		if (!empty($moderationAction))
3021
-			logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board));
3173
+		if (!empty($moderationAction)) {
3174
+					logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board));
3175
+		}
3022 3176
 	}
3023 3177
 
3024 3178
 	if (isset($_REQUEST['xml']))
@@ -3059,8 +3213,7 @@  discard block
 block discarded – undo
3059 3213
 			);
3060 3214
 
3061 3215
 			censorText($context['message']['subject']);
3062
-		}
3063
-		else
3216
+		} else
3064 3217
 		{
3065 3218
 			$context['message'] = array(
3066 3219
 				'id' => $row['id_msg'],
@@ -3072,15 +3225,16 @@  discard block
 block discarded – undo
3072 3225
 			loadLanguage('Errors');
3073 3226
 			foreach ($post_errors as $post_error)
3074 3227
 			{
3075
-				if ($post_error == 'long_message')
3076
-					$context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']);
3077
-				else
3078
-					$context['message']['errors'][] = $txt['error_' . $post_error];
3228
+				if ($post_error == 'long_message') {
3229
+									$context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']);
3230
+				} else {
3231
+									$context['message']['errors'][] = $txt['error_' . $post_error];
3232
+				}
3079 3233
 			}
3080 3234
 		}
3235
+	} else {
3236
+			obExit(false);
3237
+	}
3081 3238
 	}
3082
-	else
3083
-		obExit(false);
3084
-}
3085 3239
 
3086 3240
 ?>
3087 3241
\ No newline at end of file
Please login to merge, or discard this patch.
Themes/default/ManageSmileys.template.php 1 patch
Braces   +56 added lines, -41 removed lines patch added patch discarded remove patch
@@ -34,11 +34,12 @@  discard block
 block discarded – undo
34 34
 		</div>';
35 35
 
36 36
 	// If this is an existing set, and there are still un-added smileys - offer an import opportunity.
37
-	if (!empty($context['current_set']['can_import']))
38
-		echo '
37
+	if (!empty($context['current_set']['can_import'])) {
38
+			echo '
39 39
 		<div class="information noup">
40 40
 			', $context['current_set']['can_import'] == 1 ? sprintf($txt['smiley_set_import_single'], $context['current_set']['import_url']) : sprintf($txt['smiley_set_import_multiple'], $context['current_set']['can_import'], $context['current_set']['import_url']), '
41 41
 		</div>';
42
+	}
42 43
 
43 44
 	echo '
44 45
 		<div class="windowbg noup">
@@ -67,17 +68,18 @@  discard block
 block discarded – undo
67 68
 				<dd>
68 69
 					', $modSettings['smileys_url'], '/';
69 70
 
70
-	if (empty($context['smiley_set_dirs']))
71
-		echo '
71
+	if (empty($context['smiley_set_dirs'])) {
72
+			echo '
72 73
 					<input type="text" name="smiley_sets_path" id="smiley_sets_path" value="', $context['current_set']['path'], '"> ';
73
-	else
74
+	} else
74 75
 	{
75 76
 		echo '
76 77
 					<select name="smiley_sets_path" id="smiley_sets_path">';
77 78
 
78
-		foreach ($context['smiley_set_dirs'] as $smiley_set_dir)
79
-			echo '
79
+		foreach ($context['smiley_set_dirs'] as $smiley_set_dir) {
80
+					echo '
80 81
 						<option value="', $smiley_set_dir['id'], '"', $smiley_set_dir['current'] ? ' selected' : '', $smiley_set_dir['selectable'] ? '' : ' disabled', '>', $smiley_set_dir['id'], '</option>';
82
+		}
81 83
 		echo '
82 84
 					</select> ';
83 85
 	}
@@ -92,14 +94,15 @@  discard block
 block discarded – undo
92 94
 				</dd>';
93 95
 
94 96
 	// If this is a new smiley set they have the option to import smileys already in the directory.
95
-	if ($context['current_set']['is_new'] && !empty($modSettings['smiley_enable']))
96
-		echo '
97
+	if ($context['current_set']['is_new'] && !empty($modSettings['smiley_enable'])) {
98
+			echo '
97 99
 				<dt>
98 100
 					<strong><label for="smiley_sets_import">', $txt['smiley_set_import_directory'], '</label>: </strong>
99 101
 				</dt>
100 102
 				<dd>
101 103
 					<input type="checkbox" name="smiley_sets_import" id="smiley_sets_import" value="1">
102 104
 				</dd>';
105
+	}
103 106
 
104 107
 	echo '
105 108
 			</dl>
@@ -131,9 +134,10 @@  discard block
 block discarded – undo
131 134
 				<dd>
132 135
 					<img src="', $modSettings['smileys_url'], '/', $modSettings['smiley_sets_default'], '/', $context['current_smiley']['filename'] . $context['user']['smiley_set_default_ext'], '" id="preview" alt=""> ', $txt['smiley_preview_using'], ': <select id="set" onchange="updatePreview();">';
133 136
 
134
-	foreach ($context['smiley_sets'] as $smiley_set)
135
-		echo '
137
+	foreach ($context['smiley_sets'] as $smiley_set) {
138
+			echo '
136 139
 					<option value="', $smiley_set['path'], '"', $context['selected_set'] == $smiley_set['path'] ? ' selected' : '', '>', $smiley_set['name'], '</option>';
140
+	}
137 141
 
138 142
 	echo '
139 143
 					</select>
@@ -149,17 +153,18 @@  discard block
 block discarded – undo
149 153
 				</dt>
150 154
 				<dd>';
151 155
 
152
-	if (empty($context['filenames']))
153
-		echo '
156
+	if (empty($context['filenames'])) {
157
+			echo '
154 158
 					<input type="text" name="smiley_filename" id="smiley_filename" value="', $context['current_smiley']['filename'], '">';
155
-	else
159
+	} else
156 160
 	{
157 161
 		echo '
158 162
 					<select name="smiley_filename" id="smiley_filename" onchange="updatePreview();">';
159 163
 
160
-		foreach ($context['filenames'] as $filename)
161
-			echo '
164
+		foreach ($context['filenames'] as $filename) {
165
+					echo '
162 166
 						<option value="', $filename['id'], '"', $filename['selected'] ? ' selected' : '', '>', $filename['id'], '</option>';
167
+		}
163 168
 		echo '
164 169
 					</select>';
165 170
 	}
@@ -226,9 +231,10 @@  discard block
 block discarded – undo
226 231
 					<dd>
227 232
 						', $txt['smiley_preview_using'], ': <select id="set" onchange="updatePreview();selectMethod(\'existing\');">';
228 233
 
229
-	foreach ($context['smiley_sets'] as $smiley_set)
230
-		echo '
234
+	foreach ($context['smiley_sets'] as $smiley_set) {
235
+			echo '
231 236
 							<option value="', $smiley_set['path'], '"', $context['selected_set'] == $smiley_set['path'] ? ' selected' : '', '>', $smiley_set['name'], '</option>';
237
+	}
232 238
 
233 239
 	echo '
234 240
 						</select>
@@ -238,17 +244,18 @@  discard block
 block discarded – undo
238 244
 					</dt>
239 245
 					<dd>';
240 246
 
241
-	if (empty($context['filenames']))
242
-		echo '
247
+	if (empty($context['filenames'])) {
248
+			echo '
243 249
 						<input type="text" name="smiley_filename" id="smiley_filename" value="', $context['current_smiley']['filename'], '" onchange="selectMethod(\'existing\');">';
244
-	else
250
+	} else
245 251
 	{
246 252
 		echo '
247 253
 						<select name="smiley_filename" id="smiley_filename" onchange="updatePreview();selectMethod(\'existing\');">';
248 254
 
249
-		foreach ($context['filenames'] as $filename)
250
-			echo '
255
+		foreach ($context['filenames'] as $filename) {
256
+					echo '
251 257
 							<option value="', $filename['id'], '"', $filename['selected'] ? ' selected' : '', '>', $filename['id'], '</option>';
258
+		}
252 259
 		echo '
253 260
 						</select>';
254 261
 	}
@@ -261,14 +268,15 @@  discard block
 block discarded – undo
261 268
 
262 269
 			<dl id="uploadMore" class="settings">';
263 270
 
264
-	foreach ($context['smiley_sets'] as $smiley_set)
265
-		echo '
271
+	foreach ($context['smiley_sets'] as $smiley_set) {
272
+			echo '
266 273
 				<dt>
267 274
 					', sprintf($txt['smileys_add_upload_for'], '<strong>' . $smiley_set['name'] . '</strong>'), ':
268 275
 				</dt>
269 276
 				<dd>
270 277
 					<input type="file" name="individual_', $smiley_set['name'], '" onchange="selectMethod(\'upload\');">
271 278
 				</dd>';
279
+	}
272 280
 
273 281
 	echo '
274 282
 			</dl>
@@ -336,27 +344,30 @@  discard block
 block discarded – undo
336 344
 
337 345
 		foreach ($location['rows'] as $row)
338 346
 		{
339
-			if (!empty($context['move_smiley']))
340
-				echo '
347
+			if (!empty($context['move_smiley'])) {
348
+							echo '
341 349
 			<a href="', $scripturl, '?action=admin;area=smileys;sa=setorder;location=', $location['id'], ';source=', $context['move_smiley'], ';row=', $row[0]['row'], ';reorder=1;', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons select_below" title="', $txt['smileys_move_here'], '"></span></a>';
350
+			}
342 351
 
343 352
 			foreach ($row as $smiley)
344 353
 			{
345
-				if (empty($context['move_smiley']))
346
-					echo '
354
+				if (empty($context['move_smiley'])) {
355
+									echo '
347 356
 			<a href="', $scripturl, '?action=admin;area=smileys;sa=setorder;move=', $smiley['id'], '"><img src="', $modSettings['smileys_url'], '/', $modSettings['smiley_sets_default'], '/', $smiley['filename'], '" alt="', $smiley['description'], '"></a>';
348
-				else
349
-					echo '
357
+				} else {
358
+									echo '
350 359
 			<img src="', $modSettings['smileys_url'], '/', $modSettings['smiley_sets_default'], '/', $smiley['filename'], '" alt="', $smiley['description'], '" ', $smiley['selected'] ? 'class="selected_item"' : '', '>
351 360
 			<a href="', $scripturl, '?action=admin;area=smileys;sa=setorder;location=', $location['id'], ';source=', $context['move_smiley'], ';after=', $smiley['id'], ';reorder=1;', $context['session_var'], '=', $context['session_id'], '" title="', $txt['smileys_move_here'], '"><span class="generic_icons select_below" title="', $txt['smileys_move_here'], '"></span></a>';
361
+				}
352 362
 			}
353 363
 
354 364
 			echo '
355 365
 			<br>';
356 366
 		}
357
-		if (!empty($context['move_smiley']))
358
-			echo '
367
+		if (!empty($context['move_smiley'])) {
368
+					echo '
359 369
 			<a href="', $scripturl, '?action=admin;area=smileys;sa=setorder;location=', $location['id'], ';source=', $context['move_smiley'], ';row=', $location['last_row'], ';reorder=1;', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons select_below" title="', $txt['smileys_move_here'], '"></span></a>';
370
+		}
360 371
 		echo '
361 372
 		</div><!-- .windowbg -->
362 373
 		<input type="hidden" name="reorder" value="1">
@@ -389,14 +400,15 @@  discard block
 block discarded – undo
389 400
 		<div class="windowbg">
390 401
 			<dl class="settings">';
391 402
 
392
-	if (!$context['new_icon'])
393
-		echo '
403
+	if (!$context['new_icon']) {
404
+			echo '
394 405
 				<dt>
395 406
 					<strong>', $txt['smiley_preview'], ': </strong>
396 407
 				</dt>
397 408
 				<dd>
398 409
 					<img src="', $context['icon']['image_url'], '" alt="', $context['icon']['title'], '">
399 410
 				</dd>';
411
+	}
400 412
 
401 413
 	echo '
402 414
 				<dt>
@@ -423,9 +435,10 @@  discard block
 block discarded – undo
423 435
 		echo '
424 436
 						<optgroup label="', $category['name'], '">';
425 437
 
426
-		foreach ($category['boards'] as $board)
427
-			echo '
438
+		foreach ($category['boards'] as $board) {
439
+					echo '
428 440
 							<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=&gt;' : '', ' ', $board['name'], '</option>';
441
+		}
429 442
 
430 443
 		echo '
431 444
 						</optgroup>';
@@ -442,19 +455,21 @@  discard block
 block discarded – undo
442 455
 						<option value="0"', empty($context['icon']['after']) ? ' selected' : '', '>', $txt['icons_location_first_icon'], '</option>';
443 456
 
444 457
 	// Print the list of all the icons it can be put after...
445
-	foreach ($context['icons'] as $id => $data)
446
-		if (empty($context['icon']['id']) || $id != $context['icon']['id'])
458
+	foreach ($context['icons'] as $id => $data) {
459
+			if (empty($context['icon']['id']) || $id != $context['icon']['id'])
447 460
 			echo '
448 461
 						<option value="', $id, '"', !empty($context['icon']['after']) && $id == $context['icon']['after'] ? ' selected' : '', '>', $txt['icons_location_after'], ': ', $data['title'], '</option>';
462
+	}
449 463
 
450 464
 	echo '
451 465
 					</select>
452 466
 				</dd>
453 467
 			</dl>';
454 468
 
455
-	if (!$context['new_icon'])
456
-		echo '
469
+	if (!$context['new_icon']) {
470
+			echo '
457 471
 			<input type="hidden" name="icon" value="', $context['icon']['id'], '">';
472
+	}
458 473
 
459 474
 	echo '
460 475
 			<input type="submit" name="icons_save" value="', $txt['smileys_save'], '" class="button">
Please login to merge, or discard this patch.
Sources/LogInOut.php 1 patch
Braces   +154 added lines, -121 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 4
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * Ask them for their login information. (shows a page for the user to type
@@ -29,8 +30,9 @@  discard block
 block discarded – undo
29 30
 	global $txt, $context, $scripturl, $user_info;
30 31
 
31 32
 	// You are already logged in, go take a tour of the boards
32
-	if (!empty($user_info['id']))
33
-		redirectexit();
33
+	if (!empty($user_info['id'])) {
34
+			redirectexit();
35
+	}
34 36
 
35 37
 	// We need to load the Login template/language file.
36 38
 	loadLanguage('Login');
@@ -57,10 +59,11 @@  discard block
 block discarded – undo
57 59
 	);
58 60
 
59 61
 	// Set the login URL - will be used when the login process is done (but careful not to send us to an attachment).
60
-	if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0)
61
-		$_SESSION['login_url'] = $_SESSION['old_url'];
62
-	elseif (isset($_SESSION['login_url']) && strpos($_SESSION['login_url'], 'dlattach') !== false)
63
-		unset($_SESSION['login_url']);
62
+	if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) {
63
+			$_SESSION['login_url'] = $_SESSION['old_url'];
64
+	} elseif (isset($_SESSION['login_url']) && strpos($_SESSION['login_url'], 'dlattach') !== false) {
65
+			unset($_SESSION['login_url']);
66
+	}
64 67
 
65 68
 	// Create a one time token.
66 69
 	createToken('login');
@@ -83,8 +86,9 @@  discard block
 block discarded – undo
83 86
 	global $cookiename, $modSettings, $context, $sourcedir, $maintenance;
84 87
 
85 88
 	// Check to ensure we're forcing SSL for authentication
86
-	if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn())
87
-		fatal_lang_error('login_ssl_required');
89
+	if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) {
90
+			fatal_lang_error('login_ssl_required');
91
+	}
88 92
 
89 93
 	// Load cookie authentication stuff.
90 94
 	require_once($sourcedir . '/Subs-Auth.php');
@@ -98,23 +102,26 @@  discard block
 block discarded – undo
98 102
 	if (isset($_GET['sa']) && $_GET['sa'] == 'salt' && !$user_info['is_guest'])
99 103
 	{
100 104
 		// First check for 2.1 json-format cookie in $_COOKIE
101
-		if (isset($_COOKIE[$cookiename]) && preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+~', $_COOKIE[$cookiename]) === 1)
102
-			list (,, $timeout) = $smcFunc['json_decode']($_COOKIE[$cookiename], true);
105
+		if (isset($_COOKIE[$cookiename]) && preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+~', $_COOKIE[$cookiename]) === 1) {
106
+					list (,, $timeout) = $smcFunc['json_decode']($_COOKIE[$cookiename], true);
107
+		}
103 108
 
104 109
 		// Try checking for 2.1 json-format cookie in $_SESSION
105
-		elseif (isset($_SESSION['login_' . $cookiename]) && preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+~', $_SESSION['login_' . $cookiename]) === 1)
106
-			list (,, $timeout) = $smcFunc['json_decode']($_SESSION['login_' . $cookiename]);
110
+		elseif (isset($_SESSION['login_' . $cookiename]) && preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+~', $_SESSION['login_' . $cookiename]) === 1) {
111
+					list (,, $timeout) = $smcFunc['json_decode']($_SESSION['login_' . $cookiename]);
112
+		}
107 113
 
108 114
 		// Next, try checking for 2.0 serialized string cookie in $_COOKIE
109
-		elseif (isset($_COOKIE[$cookiename]) && preg_match('~^a:[34]:\{i:0;i:\d+;i:1;s:(0|128):"([a-fA-F0-9]{128})?";i:2;[id]:\d+;~', $_COOKIE[$cookiename]) === 1)
110
-			list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]);
115
+		elseif (isset($_COOKIE[$cookiename]) && preg_match('~^a:[34]:\{i:0;i:\d+;i:1;s:(0|128):"([a-fA-F0-9]{128})?";i:2;[id]:\d+;~', $_COOKIE[$cookiename]) === 1) {
116
+					list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]);
117
+		}
111 118
 
112 119
 		// Last, see if you need to fall back on checking for 2.0 serialized string cookie in $_SESSION
113
-		elseif (isset($_SESSION['login_' . $cookiename]) && preg_match('~^a:[34]:\{i:0;i:\d+;i:1;s:(0|128):"([a-fA-F0-9]{128})?";i:2;[id]:\d+;~', $_SESSION['login_' . $cookiename]) === 1)
114
-			list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]);
115
-
116
-		else
117
-			trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR);
120
+		elseif (isset($_SESSION['login_' . $cookiename]) && preg_match('~^a:[34]:\{i:0;i:\d+;i:1;s:(0|128):"([a-fA-F0-9]{128})?";i:2;[id]:\d+;~', $_SESSION['login_' . $cookiename]) === 1) {
121
+					list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]);
122
+		} else {
123
+					trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR);
124
+		}
118 125
 
119 126
 		$user_settings['password_salt'] = substr(md5(mt_rand()), 0, 4);
120 127
 		updateMemberData($user_info['id'], array('password_salt' => $user_settings['password_salt']));
@@ -134,24 +141,23 @@  discard block
 block discarded – undo
134 141
 	elseif (isset($_GET['sa']) && $_GET['sa'] == 'check')
135 142
 	{
136 143
 		// Strike!  You're outta there!
137
-		if ($_GET['member'] != $user_info['id'])
138
-			fatal_lang_error('login_cookie_error', false);
144
+		if ($_GET['member'] != $user_info['id']) {
145
+					fatal_lang_error('login_cookie_error', false);
146
+		}
139 147
 
140 148
 		$user_info['can_mod'] = allowedTo('access_mod_center') || (!$user_info['is_guest'] && ($user_info['mod_cache']['gq'] != '0=1' || $user_info['mod_cache']['bq'] != '0=1' || ($modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap']))));
141 149
 
142 150
 		// Some whitelisting for login_url...
143
-		if (empty($_SESSION['login_url']))
144
-			redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa');
145
-		elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false))
151
+		if (empty($_SESSION['login_url'])) {
152
+					redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa');
153
+		} elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false))
146 154
 		{
147 155
 			unset ($_SESSION['login_url']);
148 156
 			redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa');
149
-		}
150
-		elseif (!empty($user_settings['tfa_secret']))
157
+		} elseif (!empty($user_settings['tfa_secret']))
151 158
 		{
152 159
 			redirectexit('action=logintfa');
153
-		}
154
-		else
160
+		} else
155 161
 		{
156 162
 			// Best not to clutter the session data too much...
157 163
 			$temp = $_SESSION['login_url'];
@@ -162,8 +168,9 @@  discard block
 block discarded – undo
162 168
 	}
163 169
 
164 170
 	// Beyond this point you are assumed to be a guest trying to login.
165
-	if (!$user_info['is_guest'])
166
-		redirectexit();
171
+	if (!$user_info['is_guest']) {
172
+			redirectexit();
173
+	}
167 174
 
168 175
 	// Are you guessing with a script?
169 176
 	checkSession();
@@ -171,18 +178,21 @@  discard block
 block discarded – undo
171 178
 	spamProtection('login');
172 179
 
173 180
 	// Set the login_url if it's not already set (but careful not to send us to an attachment).
174
-	if ((empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) || (isset($_GET['quicklogin']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'login') === false))
175
-		$_SESSION['login_url'] = $_SESSION['old_url'];
181
+	if ((empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) || (isset($_GET['quicklogin']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'login') === false)) {
182
+			$_SESSION['login_url'] = $_SESSION['old_url'];
183
+	}
176 184
 
177 185
 	// Been guessing a lot, haven't we?
178
-	if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3)
179
-		fatal_lang_error('login_threshold_fail', 'login');
186
+	if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3) {
187
+			fatal_lang_error('login_threshold_fail', 'login');
188
+	}
180 189
 
181 190
 	// Set up the cookie length.  (if it's invalid, just fall through and use the default.)
182
-	if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1))
183
-		$modSettings['cookieTime'] = 3153600;
184
-	elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 3153600))
185
-		$modSettings['cookieTime'] = (int) $_POST['cookielength'];
191
+	if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1)) {
192
+			$modSettings['cookieTime'] = 3153600;
193
+	} elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 3153600)) {
194
+			$modSettings['cookieTime'] = (int) $_POST['cookielength'];
195
+	}
186 196
 
187 197
 	loadLanguage('Login');
188 198
 	// Load the template stuff.
@@ -302,8 +312,9 @@  discard block
 block discarded – undo
302 312
 			$other_passwords[] = crypt(md5($_POST['passwrd']), md5($_POST['passwrd']));
303 313
 
304 314
 			// Snitz style - SHA-256.  Technically, this is a downgrade, but most PHP configurations don't support sha256 anyway.
305
-			if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256'))
306
-				$other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd']));
315
+			if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256')) {
316
+							$other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd']));
317
+			}
307 318
 
308 319
 			// phpBB3 users new hashing.  We now support it as well ;).
309 320
 			$other_passwords[] = phpBB3_password_check($_POST['passwrd'], $user_settings['passwd']);
@@ -323,27 +334,29 @@  discard block
 block discarded – undo
323 334
 			// Some common md5 ones.
324 335
 			$other_passwords[] = md5($user_settings['password_salt'] . $_POST['passwrd']);
325 336
 			$other_passwords[] = md5($_POST['passwrd'] . $user_settings['password_salt']);
326
-		}
327
-		elseif (strlen($user_settings['passwd']) == 40)
337
+		} elseif (strlen($user_settings['passwd']) == 40)
328 338
 		{
329 339
 			// Maybe they are using a hash from before the password fix.
330 340
 			// This is also valid for SMF 1.1 to 2.0 style of hashing, changed to bcrypt in SMF 2.1
331 341
 			$other_passwords[] = sha1(strtolower($user_settings['member_name']) . un_htmlspecialchars($_POST['passwrd']));
332 342
 
333 343
 			// BurningBoard3 style of hashing.
334
-			if (!empty($modSettings['enable_password_conversion']))
335
-				$other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd'])));
344
+			if (!empty($modSettings['enable_password_conversion'])) {
345
+							$other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd'])));
346
+			}
336 347
 
337 348
 			// Perhaps we converted to UTF-8 and have a valid password being hashed differently.
338 349
 			if ($context['character_set'] == 'UTF-8' && !empty($modSettings['previousCharacterSet']) && $modSettings['previousCharacterSet'] != 'utf8')
339 350
 			{
340 351
 				// Try iconv first, for no particular reason.
341
-				if (function_exists('iconv'))
342
-					$other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd'])));
352
+				if (function_exists('iconv')) {
353
+									$other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd'])));
354
+				}
343 355
 
344 356
 				// Say it aint so, iconv failed!
345
-				if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding'))
346
-					$other_passwords[] = sha1(strtolower(mb_convert_encoding($user_settings['member_name'], 'UTF-8', $modSettings['previousCharacterSet'])) . un_htmlspecialchars(mb_convert_encoding($_POST['passwrd'], 'UTF-8', $modSettings['previousCharacterSet'])));
357
+				if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding')) {
358
+									$other_passwords[] = sha1(strtolower(mb_convert_encoding($user_settings['member_name'], 'UTF-8', $modSettings['previousCharacterSet'])) . un_htmlspecialchars(mb_convert_encoding($_POST['passwrd'], 'UTF-8', $modSettings['previousCharacterSet'])));
359
+				}
347 360
 			}
348 361
 		}
349 362
 
@@ -373,8 +386,9 @@  discard block
 block discarded – undo
373 386
 			$_SESSION['failed_login'] = isset($_SESSION['failed_login']) ? ($_SESSION['failed_login'] + 1) : 1;
374 387
 
375 388
 			// Hmm... don't remember it, do you?  Here, try the password reminder ;).
376
-			if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold'])
377
-				redirectexit('action=reminder');
389
+			if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold']) {
390
+							redirectexit('action=reminder');
391
+			}
378 392
 			// We'll give you another chance...
379 393
 			else
380 394
 			{
@@ -385,8 +399,7 @@  discard block
 block discarded – undo
385 399
 				return;
386 400
 			}
387 401
 		}
388
-	}
389
-	elseif (!empty($user_settings['passwd_flood']))
402
+	} elseif (!empty($user_settings['passwd_flood']))
390 403
 	{
391 404
 		// Let's be sure they weren't a little hacker.
392 405
 		validatePasswordFlood($user_settings['id_member'], $user_settings['member_name'], $user_settings['passwd_flood'], true);
@@ -403,8 +416,9 @@  discard block
 block discarded – undo
403 416
 	}
404 417
 
405 418
 	// Check their activation status.
406
-	if (!checkActivation())
407
-		return;
419
+	if (!checkActivation()) {
420
+			return;
421
+	}
408 422
 
409 423
 	DoLogin();
410 424
 }
@@ -416,8 +430,9 @@  discard block
 block discarded – undo
416 430
 {
417 431
 	global $sourcedir, $txt, $context, $user_info, $modSettings, $scripturl;
418 432
 
419
-	if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode']))
420
-		fatal_lang_error('no_access', false);
433
+	if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode'])) {
434
+			fatal_lang_error('no_access', false);
435
+	}
421 436
 
422 437
 	loadLanguage('Profile');
423 438
 	require_once($sourcedir . '/Class-TOTP.php');
@@ -425,8 +440,9 @@  discard block
 block discarded – undo
425 440
 	$member = $context['tfa_member'];
426 441
 
427 442
 	// Prevent replay attacks by limiting at least 2 minutes before they can log in again via 2FA
428
-	if (time() - $member['last_login'] < 120)
429
-		fatal_lang_error('tfa_wait', false);
443
+	if (time() - $member['last_login'] < 120) {
444
+			fatal_lang_error('tfa_wait', false);
445
+	}
430 446
 
431 447
 	$totp = new \TOTP\Auth($member['tfa_secret']);
432 448
 	$totp->setRange(1);
@@ -440,8 +456,9 @@  discard block
 block discarded – undo
440 456
 	if (!empty($_POST['tfa_code']) && empty($_POST['tfa_backup']))
441 457
 	{
442 458
 		// Check to ensure we're forcing SSL for authentication
443
-		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn())
444
-			fatal_lang_error('login_ssl_required');
459
+		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) {
460
+					fatal_lang_error('login_ssl_required');
461
+		}
445 462
 
446 463
 		$code = $_POST['tfa_code'];
447 464
 
@@ -451,20 +468,19 @@  discard block
 block discarded – undo
451 468
 
452 469
 			setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt']));
453 470
 			redirectexit();
454
-		}
455
-		else
471
+		} else
456 472
 		{
457 473
 			validatePasswordFlood($member['id_member'], $member['member_name'], $member['passwd_flood'], false, true);
458 474
 
459 475
 			$context['tfa_error'] = true;
460 476
 			$context['tfa_value'] = $_POST['tfa_code'];
461 477
 		}
462
-	}
463
-	elseif (!empty($_POST['tfa_backup']))
478
+	} elseif (!empty($_POST['tfa_backup']))
464 479
 	{
465 480
 		// Check to ensure we're forcing SSL for authentication
466
-		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn())
467
-			fatal_lang_error('login_ssl_required');
481
+		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) {
482
+					fatal_lang_error('login_ssl_required');
483
+		}
468 484
 
469 485
 		$backup = $_POST['tfa_backup'];
470 486
 
@@ -478,8 +494,7 @@  discard block
 block discarded – undo
478 494
 			));
479 495
 			setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt']));
480 496
 			redirectexit('action=profile;area=tfasetup;backup');
481
-		}
482
-		else
497
+		} else
483 498
 		{
484 499
 			validatePasswordFlood($member['id_member'], $member['member_name'], $member['passwd_flood'], false, true);
485 500
 
@@ -502,8 +517,9 @@  discard block
 block discarded – undo
502 517
 {
503 518
 	global $context, $txt, $scripturl, $user_settings, $modSettings;
504 519
 
505
-	if (!isset($context['login_errors']))
506
-		$context['login_errors'] = array();
520
+	if (!isset($context['login_errors'])) {
521
+			$context['login_errors'] = array();
522
+	}
507 523
 
508 524
 	// What is the true activation status of this account?
509 525
 	$activation_status = $user_settings['is_activated'] > 10 ? $user_settings['is_activated'] - 10 : $user_settings['is_activated'];
@@ -515,8 +531,9 @@  discard block
 block discarded – undo
515 531
 		return false;
516 532
 	}
517 533
 	// Awaiting approval still?
518
-	elseif ($activation_status == 3)
519
-		fatal_lang_error('still_awaiting_approval', 'user');
534
+	elseif ($activation_status == 3) {
535
+			fatal_lang_error('still_awaiting_approval', 'user');
536
+	}
520 537
 	// Awaiting deletion, changed their mind?
521 538
 	elseif ($activation_status == 4)
522 539
 	{
@@ -524,8 +541,7 @@  discard block
 block discarded – undo
524 541
 		{
525 542
 			updateMemberData($user_settings['id_member'], array('is_activated' => 1));
526 543
 			updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 0 ? $modSettings['unapprovedMembers'] - 1 : 0)));
527
-		}
528
-		else
544
+		} else
529 545
 		{
530 546
 			$context['disable_login_hashing'] = true;
531 547
 			$context['login_errors'][] = $txt['awaiting_delete_account'];
@@ -565,8 +581,9 @@  discard block
 block discarded – undo
565 581
 	setLoginCookie(60 * $modSettings['cookieTime'], $user_settings['id_member'], hash_salt($user_settings['passwd'], $user_settings['password_salt']));
566 582
 
567 583
 	// Reset the login threshold.
568
-	if (isset($_SESSION['failed_login']))
569
-		unset($_SESSION['failed_login']);
584
+	if (isset($_SESSION['failed_login'])) {
585
+			unset($_SESSION['failed_login']);
586
+	}
570 587
 
571 588
 	$user_info['is_guest'] = false;
572 589
 	$user_settings['additional_groups'] = explode(',', $user_settings['additional_groups']);
@@ -588,16 +605,18 @@  discard block
 block discarded – undo
588 605
 			'id_member' => $user_info['id'],
589 606
 		)
590 607
 	);
591
-	if ($smcFunc['db_num_rows']($request) == 1)
592
-		$_SESSION['first_login'] = true;
593
-	else
594
-		unset($_SESSION['first_login']);
608
+	if ($smcFunc['db_num_rows']($request) == 1) {
609
+			$_SESSION['first_login'] = true;
610
+	} else {
611
+			unset($_SESSION['first_login']);
612
+	}
595 613
 	$smcFunc['db_free_result']($request);
596 614
 
597 615
 	// You've logged in, haven't you?
598 616
 	$update = array('member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP']);
599
-	if (empty($user_settings['tfa_secret']))
600
-		$update['last_login'] = time();
617
+	if (empty($user_settings['tfa_secret'])) {
618
+			$update['last_login'] = time();
619
+	}
601 620
 	updateMemberData($user_info['id'], $update);
602 621
 
603 622
 	// Get rid of the online entry for that old guest....
@@ -611,8 +630,8 @@  discard block
 block discarded – undo
611 630
 	$_SESSION['log_time'] = 0;
612 631
 
613 632
 	// Log this entry, only if we have it enabled.
614
-	if (!empty($modSettings['loginHistoryDays']))
615
-		$smcFunc['db_insert']('insert',
633
+	if (!empty($modSettings['loginHistoryDays'])) {
634
+			$smcFunc['db_insert']('insert',
616 635
 			'{db_prefix}member_logins',
617 636
 			array(
618 637
 				'id_member' => 'int', 'time' => 'int', 'ip' => 'inet', 'ip2' => 'inet',
@@ -624,13 +643,15 @@  discard block
 block discarded – undo
624 643
 				'id_member', 'time'
625 644
 			)
626 645
 		);
646
+	}
627 647
 
628 648
 	// Just log you back out if it's in maintenance mode and you AREN'T an admin.
629
-	if (empty($maintenance) || allowedTo('admin_forum'))
630
-		redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']);
631
-	else
632
-		redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']);
633
-}
649
+	if (empty($maintenance) || allowedTo('admin_forum')) {
650
+			redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']);
651
+	} else {
652
+			redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']);
653
+	}
654
+	}
634 655
 
635 656
 /**
636 657
  * Logs the current user out of their account.
@@ -646,13 +667,15 @@  discard block
 block discarded – undo
646 667
 	global $sourcedir, $user_info, $user_settings, $context, $smcFunc, $cookiename, $modSettings;
647 668
 
648 669
 	// Make sure they aren't being auto-logged out.
649
-	if (!$internal)
650
-		checkSession('get');
670
+	if (!$internal) {
671
+			checkSession('get');
672
+	}
651 673
 
652 674
 	require_once($sourcedir . '/Subs-Auth.php');
653 675
 
654
-	if (isset($_SESSION['pack_ftp']))
655
-		$_SESSION['pack_ftp'] = null;
676
+	if (isset($_SESSION['pack_ftp'])) {
677
+			$_SESSION['pack_ftp'] = null;
678
+	}
656 679
 
657 680
 	// It won't be first login anymore.
658 681
 	unset($_SESSION['first_login']);
@@ -680,8 +703,9 @@  discard block
 block discarded – undo
680 703
 
681 704
 	// And some other housekeeping while we're at it.
682 705
 	$salt = substr(md5(mt_rand()), 0, 4);
683
-	if (!empty($user_info['id']))
684
-		updateMemberData($user_info['id'], array('password_salt' => $salt));
706
+	if (!empty($user_info['id'])) {
707
+			updateMemberData($user_info['id'], array('password_salt' => $salt));
708
+	}
685 709
 
686 710
 	if (!empty($modSettings['tfa_mode']) && !empty($user_info['id']) && !empty($_COOKIE[$cookiename . '_tfa']))
687 711
 	{
@@ -694,14 +718,13 @@  discard block
 block discarded – undo
694 718
 	// Off to the merry board index we go!
695 719
 	if ($redirect)
696 720
 	{
697
-		if (empty($_SESSION['logout_url']))
698
-			redirectexit('', $context['server']['needs_login_fix']);
699
-		elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false))
721
+		if (empty($_SESSION['logout_url'])) {
722
+					redirectexit('', $context['server']['needs_login_fix']);
723
+		} elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false))
700 724
 		{
701 725
 			unset ($_SESSION['logout_url']);
702 726
 			redirectexit();
703
-		}
704
-		else
727
+		} else
705 728
 		{
706 729
 			$temp = $_SESSION['logout_url'];
707 730
 			unset($_SESSION['logout_url']);
@@ -734,8 +757,9 @@  discard block
 block discarded – undo
734 757
 function phpBB3_password_check($passwd, $passwd_hash)
735 758
 {
736 759
 	// Too long or too short?
737
-	if (strlen($passwd_hash) != 34)
738
-		return;
760
+	if (strlen($passwd_hash) != 34) {
761
+			return;
762
+	}
739 763
 
740 764
 	// Range of characters allowed.
741 765
 	$range = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
@@ -746,8 +770,9 @@  discard block
 block discarded – undo
746 770
 	$salt = substr($passwd_hash, 4, 8);
747 771
 
748 772
 	$hash = md5($salt . $passwd, true);
749
-	for (; $count != 0; --$count)
750
-		$hash = md5($hash . $passwd, true);
773
+	for (; $count != 0; --$count) {
774
+			$hash = md5($hash . $passwd, true);
775
+	}
751 776
 
752 777
 	$output = substr($passwd_hash, 0, 12);
753 778
 	$i = 0;
@@ -756,21 +781,25 @@  discard block
 block discarded – undo
756 781
 		$value = ord($hash[$i++]);
757 782
 		$output .= $range[$value & 0x3f];
758 783
 
759
-		if ($i < 16)
760
-			$value |= ord($hash[$i]) << 8;
784
+		if ($i < 16) {
785
+					$value |= ord($hash[$i]) << 8;
786
+		}
761 787
 
762 788
 		$output .= $range[($value >> 6) & 0x3f];
763 789
 
764
-		if ($i++ >= 16)
765
-			break;
790
+		if ($i++ >= 16) {
791
+					break;
792
+		}
766 793
 
767
-		if ($i < 16)
768
-			$value |= ord($hash[$i]) << 16;
794
+		if ($i < 16) {
795
+					$value |= ord($hash[$i]) << 16;
796
+		}
769 797
 
770 798
 		$output .= $range[($value >> 12) & 0x3f];
771 799
 
772
-		if ($i++ >= 16)
773
-			break;
800
+		if ($i++ >= 16) {
801
+					break;
802
+		}
774 803
 
775 804
 		$output .= $range[($value >> 18) & 0x3f];
776 805
 	}
@@ -802,8 +831,9 @@  discard block
 block discarded – undo
802 831
 		require_once($sourcedir . '/Subs-Auth.php');
803 832
 		setLoginCookie(-3600, 0);
804 833
 
805
-		if (isset($_SESSION['login_' . $cookiename]))
806
-			unset($_SESSION['login_' . $cookiename]);
834
+		if (isset($_SESSION['login_' . $cookiename])) {
835
+					unset($_SESSION['login_' . $cookiename]);
836
+		}
807 837
 	}
808 838
 
809 839
 	// We need a member!
@@ -817,8 +847,9 @@  discard block
 block discarded – undo
817 847
 	}
818 848
 
819 849
 	// Right, have we got a flood value?
820
-	if ($password_flood_value !== false)
821
-		@list ($time_stamp, $number_tries) = explode('|', $password_flood_value);
850
+	if ($password_flood_value !== false) {
851
+			@list ($time_stamp, $number_tries) = explode('|', $password_flood_value);
852
+	}
822 853
 
823 854
 	// Timestamp or number of tries invalid?
824 855
 	if (empty($number_tries) || empty($time_stamp))
@@ -834,15 +865,17 @@  discard block
 block discarded – undo
834 865
 		$number_tries = $time_stamp < time() - 20 ? 2 : $number_tries;
835 866
 
836 867
 		// They are trying too fast, make them wait longer
837
-		if ($time_stamp < time() - 10)
838
-			$time_stamp = time();
868
+		if ($time_stamp < time() - 10) {
869
+					$time_stamp = time();
870
+		}
839 871
 	}
840 872
 
841 873
 	$number_tries++;
842 874
 
843 875
 	// Broken the law?
844
-	if ($number_tries > 5)
845
-		fatal_lang_error('login_threshold_brute_fail', 'login', [$member_name]);
876
+	if ($number_tries > 5) {
877
+			fatal_lang_error('login_threshold_brute_fail', 'login', [$member_name]);
878
+	}
846 879
 
847 880
 	// Otherwise set the members data. If they correct on their first attempt then we actually clear it, otherwise we set it!
848 881
 	updateMemberData($id_member, array('passwd_flood' => $was_correct && $number_tries == 1 ? '' : $time_stamp . '|' . $number_tries));
Please login to merge, or discard this patch.
other/install.php 1 patch
Braces   +472 added lines, -350 removed lines patch added patch discarded remove patch
@@ -20,8 +20,9 @@  discard block
 block discarded – undo
20 20
 // ><html dir="ltr"><head><title>Error!</title></head><body>Sorry, this installer requires PHP!<div style="display: none;">
21 21
 
22 22
 // Let's pull in useful classes
23
-if (!defined('SMF'))
23
+if (!defined('SMF')) {
24 24
 	define('SMF', 1);
25
+}
25 26
 
26 27
 require_once('Sources/Class-Package.php');
27 28
 
@@ -63,10 +64,11 @@  discard block
 block discarded – undo
63 64
 
64 65
 			list ($charcode) = pg_fetch_row($request);
65 66
 
66
-			if ($charcode == 'UTF8')
67
-				return true;
68
-			else
69
-				return false;
67
+			if ($charcode == 'UTF8') {
68
+							return true;
69
+			} else {
70
+							return false;
71
+			}
70 72
 		},
71 73
 		'utf8_version' => '8.0',
72 74
 		'utf8_version_check' => '$request = pg_query(\'SELECT version()\'); list ($version) = pg_fetch_row($request); list($pgl, $version) = explode(" ", $version); return $version;',
@@ -76,12 +78,14 @@  discard block
 block discarded – undo
76 78
 			$value = preg_replace('~[^A-Za-z0-9_\$]~', '', $value);
77 79
 
78 80
 			// Is it reserved?
79
-			if ($value == 'pg_')
80
-				return $txt['error_db_prefix_reserved'];
81
+			if ($value == 'pg_') {
82
+							return $txt['error_db_prefix_reserved'];
83
+			}
81 84
 
82 85
 			// Is the prefix numeric?
83
-			if (preg_match('~^\d~', $value))
84
-				return $txt['error_db_prefix_numeric'];
86
+			if (preg_match('~^\d~', $value)) {
87
+							return $txt['error_db_prefix_numeric'];
88
+			}
85 89
 
86 90
 			return true;
87 91
 		},
@@ -128,10 +132,11 @@  discard block
 block discarded – undo
128 132
 		$incontext['skip'] = false;
129 133
 
130 134
 		// Call the step and if it returns false that means pause!
131
-		if (function_exists($step[2]) && $step[2]() === false)
132
-			break;
133
-		elseif (function_exists($step[2]))
134
-			$incontext['current_step']++;
135
+		if (function_exists($step[2]) && $step[2]() === false) {
136
+					break;
137
+		} elseif (function_exists($step[2])) {
138
+					$incontext['current_step']++;
139
+		}
135 140
 
136 141
 		// No warnings pass on.
137 142
 		$incontext['warning'] = '';
@@ -147,8 +152,9 @@  discard block
 block discarded – undo
147 152
 	global $databases;
148 153
 
149 154
 	// Just so people using older versions of PHP aren't left in the cold.
150
-	if (!isset($_SERVER['PHP_SELF']))
151
-		$_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php';
155
+	if (!isset($_SERVER['PHP_SELF'])) {
156
+			$_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php';
157
+	}
152 158
 
153 159
 	// Enable error reporting for fatal errors.
154 160
 	error_reporting(E_ERROR | E_PARSE);
@@ -164,21 +170,23 @@  discard block
 block discarded – undo
164 170
 	{
165 171
 		ob_start();
166 172
 
167
-		if (ini_get('session.save_handler') == 'user')
168
-			@ini_set('session.save_handler', 'files');
169
-		if (function_exists('session_start'))
170
-			@session_start();
171
-	}
172
-	else
173
+		if (ini_get('session.save_handler') == 'user') {
174
+					@ini_set('session.save_handler', 'files');
175
+		}
176
+		if (function_exists('session_start')) {
177
+					@session_start();
178
+		}
179
+	} else
173 180
 	{
174 181
 		ob_start('ob_gzhandler');
175 182
 
176
-		if (ini_get('session.save_handler') == 'user')
177
-			@ini_set('session.save_handler', 'files');
183
+		if (ini_get('session.save_handler') == 'user') {
184
+					@ini_set('session.save_handler', 'files');
185
+		}
178 186
 		session_start();
179 187
 
180
-		if (!headers_sent())
181
-			echo '<!DOCTYPE html>
188
+		if (!headers_sent()) {
189
+					echo '<!DOCTYPE html>
182 190
 <html>
183 191
 	<head>
184 192
 		<title>', htmlspecialchars($_GET['pass_string']), '</title>
@@ -187,14 +195,16 @@  discard block
 block discarded – undo
187 195
 		<strong>', htmlspecialchars($_GET['pass_string']), '</strong>
188 196
 	</body>
189 197
 </html>';
198
+		}
190 199
 		exit;
191 200
 	}
192 201
 
193 202
 	// Add slashes, as long as they aren't already being added.
194
-	if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0)
195
-		foreach ($_POST as $k => $v)
203
+	if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) {
204
+			foreach ($_POST as $k => $v)
196 205
 			if (strpos($k, 'password') === false && strpos($k, 'db_passwd') === false)
197 206
 				$_POST[$k] = addslashes($v);
207
+	}
198 208
 
199 209
 	// This is really quite simple; if ?delete is on the URL, delete the installer...
200 210
 	if (isset($_GET['delete']))
@@ -215,8 +225,7 @@  discard block
 block discarded – undo
215 225
 			$ftp->close();
216 226
 
217 227
 			unset($_SESSION['installer_temp_ftp']);
218
-		}
219
-		else
228
+		} else
220 229
 		{
221 230
 			@unlink(__FILE__);
222 231
 
@@ -230,10 +239,11 @@  discard block
 block discarded – undo
230 239
 		// Now just redirect to a blank.png...
231 240
 		$secure = false;
232 241
 
233
-		if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on')
234
-			$secure = true;
235
-		elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on')
236
-			$secure = true;
242
+		if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
243
+					$secure = true;
244
+		} elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') {
245
+					$secure = true;
246
+		}
237 247
 
238 248
 		header('location: http' . ($secure ? 's' : '') . '://' . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT']) . dirname($_SERVER['PHP_SELF']) . '/Themes/default/images/blank.png');
239 249
 		exit;
@@ -244,10 +254,11 @@  discard block
 block discarded – undo
244 254
 	{
245 255
 		// Get PHP's default timezone, if set
246 256
 		$ini_tz = ini_get('date.timezone');
247
-		if (!empty($ini_tz))
248
-			$timezone_id = $ini_tz;
249
-		else
250
-			$timezone_id = '';
257
+		if (!empty($ini_tz)) {
258
+					$timezone_id = $ini_tz;
259
+		} else {
260
+					$timezone_id = '';
261
+		}
251 262
 
252 263
 		// If date.timezone is unset, invalid, or just plain weird, make a best guess
253 264
 		if (!in_array($timezone_id, timezone_identifiers_list()))
@@ -277,8 +288,9 @@  discard block
 block discarded – undo
277 288
 		$dir = dir(dirname(__FILE__) . '/Themes/default/languages');
278 289
 		while ($entry = $dir->read())
279 290
 		{
280
-			if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php')
281
-				$incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12));
291
+			if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') {
292
+							$incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12));
293
+			}
282 294
 		}
283 295
 		$dir->close();
284 296
 	}
@@ -325,10 +337,11 @@  discard block
 block discarded – undo
325 337
 	}
326 338
 
327 339
 	// Override the language file?
328
-	if (isset($_GET['lang_file']))
329
-		$_SESSION['installer_temp_lang'] = $_GET['lang_file'];
330
-	elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file']))
331
-		$_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file'];
340
+	if (isset($_GET['lang_file'])) {
341
+			$_SESSION['installer_temp_lang'] = $_GET['lang_file'];
342
+	} elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) {
343
+			$_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file'];
344
+	}
332 345
 
333 346
 	// Make sure it exists, if it doesn't reset it.
334 347
 	if (!isset($_SESSION['installer_temp_lang']) || preg_match('~[^\\w_\\-.]~', $_SESSION['installer_temp_lang']) === 1 || !file_exists(dirname(__FILE__) . '/Themes/default/languages/' . $_SESSION['installer_temp_lang']))
@@ -337,8 +350,9 @@  discard block
 block discarded – undo
337 350
 		list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
338 351
 
339 352
 		// If we have english and some other language, use the other language.  We Americans hate english :P.
340
-		if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1)
341
-			list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
353
+		if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) {
354
+					list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
355
+		}
342 356
 	}
343 357
 
344 358
 	// And now include the actual language file itself.
@@ -355,15 +369,18 @@  discard block
 block discarded – undo
355 369
 	global $db_prefix, $db_connection, $sourcedir, $smcFunc, $modSettings, $db_port;
356 370
 	global $db_server, $db_passwd, $db_type, $db_name, $db_user, $db_persist, $db_mb4;
357 371
 
358
-	if (empty($sourcedir))
359
-		$sourcedir = dirname(__FILE__) . '/Sources';
372
+	if (empty($sourcedir)) {
373
+			$sourcedir = dirname(__FILE__) . '/Sources';
374
+	}
360 375
 
361 376
 	// Need this to check whether we need the database password.
362 377
 	require(dirname(__FILE__) . '/Settings.php');
363
-	if (!defined('SMF'))
364
-		define('SMF', 1);
365
-	if (empty($smcFunc))
366
-		$smcFunc = array();
378
+	if (!defined('SMF')) {
379
+			define('SMF', 1);
380
+	}
381
+	if (empty($smcFunc)) {
382
+			$smcFunc = array();
383
+	}
367 384
 
368 385
 	$modSettings['disableQueryCheck'] = true;
369 386
 
@@ -374,14 +391,17 @@  discard block
 block discarded – undo
374 391
 
375 392
 		$options = array('persist' => $db_persist);
376 393
 
377
-		if (!empty($db_port))
378
-			$options['port'] = $db_port;
394
+		if (!empty($db_port)) {
395
+					$options['port'] = $db_port;
396
+		}
379 397
 
380
-		if (!empty($db_mb4))
381
-			$options['db_mb4'] = $db_mb4;
398
+		if (!empty($db_mb4)) {
399
+					$options['db_mb4'] = $db_mb4;
400
+		}
382 401
 
383
-		if (!$db_connection)
384
-			$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $options);
402
+		if (!$db_connection) {
403
+					$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $options);
404
+		}
385 405
 	}
386 406
 }
387 407
 
@@ -409,8 +429,9 @@  discard block
 block discarded – undo
409 429
 		// @todo REMOVE THIS!!
410 430
 		else
411 431
 		{
412
-			if (function_exists('doStep' . $_GET['step']))
413
-				call_user_func('doStep' . $_GET['step']);
432
+			if (function_exists('doStep' . $_GET['step'])) {
433
+							call_user_func('doStep' . $_GET['step']);
434
+			}
414 435
 		}
415 436
 		// Show the footer.
416 437
 		template_install_below();
@@ -428,8 +449,9 @@  discard block
 block discarded – undo
428 449
 	$incontext['sub_template'] = 'welcome_message';
429 450
 
430 451
 	// Done the submission?
431
-	if (isset($_POST['contbutt']))
432
-		return true;
452
+	if (isset($_POST['contbutt'])) {
453
+			return true;
454
+	}
433 455
 
434 456
 	// See if we think they have already installed it?
435 457
 	if (is_readable(dirname(__FILE__) . '/Settings.php'))
@@ -437,14 +459,17 @@  discard block
 block discarded – undo
437 459
 		$probably_installed = 0;
438 460
 		foreach (file(dirname(__FILE__) . '/Settings.php') as $line)
439 461
 		{
440
-			if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line))
441
-				$probably_installed++;
442
-			if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line))
443
-				$probably_installed++;
462
+			if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) {
463
+							$probably_installed++;
464
+			}
465
+			if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) {
466
+							$probably_installed++;
467
+			}
444 468
 		}
445 469
 
446
-		if ($probably_installed == 2)
447
-			$incontext['warning'] = $txt['error_already_installed'];
470
+		if ($probably_installed == 2) {
471
+					$incontext['warning'] = $txt['error_already_installed'];
472
+		}
448 473
 	}
449 474
 
450 475
 	// Is some database support even compiled in?
@@ -459,45 +484,54 @@  discard block
 block discarded – undo
459 484
 				$databases[$key]['supported'] = false;
460 485
 				$notFoundSQLFile = true;
461 486
 				$txt['error_db_script_missing'] = sprintf($txt['error_db_script_missing'], 'install_' . $GLOBALS['db_script_version'] . '_' . $type . '.sql');
487
+			} else {
488
+							$incontext['supported_databases'][] = $db;
462 489
 			}
463
-			else
464
-				$incontext['supported_databases'][] = $db;
465 490
 		}
466 491
 	}
467 492
 
468 493
 	// Check the PHP version.
469
-	if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>=')))
470
-		$error = 'error_php_too_low';
494
+	if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>='))) {
495
+			$error = 'error_php_too_low';
496
+	}
471 497
 	// Make sure we have a supported database
472
-	elseif (empty($incontext['supported_databases']))
473
-		$error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing';
498
+	elseif (empty($incontext['supported_databases'])) {
499
+			$error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing';
500
+	}
474 501
 	// How about session support?  Some crazy sysadmin remove it?
475
-	elseif (!function_exists('session_start'))
476
-		$error = 'error_session_missing';
502
+	elseif (!function_exists('session_start')) {
503
+			$error = 'error_session_missing';
504
+	}
477 505
 	// Make sure they uploaded all the files.
478
-	elseif (!file_exists(dirname(__FILE__) . '/index.php'))
479
-		$error = 'error_missing_files';
506
+	elseif (!file_exists(dirname(__FILE__) . '/index.php')) {
507
+			$error = 'error_missing_files';
508
+	}
480 509
 	// Very simple check on the session.save_path for Windows.
481 510
 	// @todo Move this down later if they don't use database-driven sessions?
482
-	elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\')
483
-		$error = 'error_session_save_path';
511
+	elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') {
512
+			$error = 'error_session_save_path';
513
+	}
484 514
 
485 515
 	// Since each of the three messages would look the same, anyway...
486
-	if (isset($error))
487
-		$incontext['error'] = $txt[$error];
516
+	if (isset($error)) {
517
+			$incontext['error'] = $txt[$error];
518
+	}
488 519
 
489 520
 	// Mod_security blocks everything that smells funny. Let SMF handle security.
490
-	if (!fixModSecurity() && !isset($_GET['overmodsecurity']))
491
-		$incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again'];
521
+	if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) {
522
+			$incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again'];
523
+	}
492 524
 
493 525
 	// Confirm mbstring is loaded...
494
-	if (!extension_loaded('mbstring'))
495
-		$incontext['error'] = $txt['install_no_mbstring'];
526
+	if (!extension_loaded('mbstring')) {
527
+			$incontext['error'] = $txt['install_no_mbstring'];
528
+	}
496 529
 
497 530
 	// Check for https stream support.
498 531
 	$supported_streams = stream_get_wrappers();
499
-	if (!in_array('https', $supported_streams))
500
-		$incontext['warning'] = $txt['install_no_https'];
532
+	if (!in_array('https', $supported_streams)) {
533
+			$incontext['warning'] = $txt['install_no_https'];
534
+	}
501 535
 
502 536
 	return false;
503 537
 }
@@ -522,12 +556,14 @@  discard block
 block discarded – undo
522 556
 		'Settings_bak.php',
523 557
 	);
524 558
 
525
-	foreach ($incontext['detected_languages'] as $lang => $temp)
526
-		$extra_files[] = 'Themes/default/languages/' . $lang;
559
+	foreach ($incontext['detected_languages'] as $lang => $temp) {
560
+			$extra_files[] = 'Themes/default/languages/' . $lang;
561
+	}
527 562
 
528 563
 	// With mod_security installed, we could attempt to fix it with .htaccess.
529
-	if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules()))
530
-		$writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.';
564
+	if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) {
565
+			$writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.';
566
+	}
531 567
 
532 568
 	$failed_files = array();
533 569
 
@@ -539,20 +575,23 @@  discard block
 block discarded – undo
539 575
 		foreach ($writable_files as $file)
540 576
 		{
541 577
 			// Some files won't exist, try to address up front
542
-			if (!file_exists(dirname(__FILE__) . '/' . $file))
543
-				@touch(dirname(__FILE__) . '/' . $file);
578
+			if (!file_exists(dirname(__FILE__) . '/' . $file)) {
579
+							@touch(dirname(__FILE__) . '/' . $file);
580
+			}
544 581
 			// NOW do the writable check...
545 582
 			if (!is_writable(dirname(__FILE__) . '/' . $file))
546 583
 			{
547 584
 				@chmod(dirname(__FILE__) . '/' . $file, 0755);
548 585
 
549 586
 				// Well, 755 hopefully worked... if not, try 777.
550
-				if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777))
551
-					$failed_files[] = $file;
587
+				if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) {
588
+									$failed_files[] = $file;
589
+				}
552 590
 			}
553 591
 		}
554
-		foreach ($extra_files as $file)
555
-			@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
592
+		foreach ($extra_files as $file) {
593
+					@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
594
+		}
556 595
 	}
557 596
 	// Windows is trickier.  Let's try opening for r+...
558 597
 	else
@@ -562,30 +601,35 @@  discard block
 block discarded – undo
562 601
 		foreach ($writable_files as $file)
563 602
 		{
564 603
 			// Folders can't be opened for write... but the index.php in them can ;)
565
-			if (is_dir(dirname(__FILE__) . '/' . $file))
566
-				$file .= '/index.php';
604
+			if (is_dir(dirname(__FILE__) . '/' . $file)) {
605
+							$file .= '/index.php';
606
+			}
567 607
 
568 608
 			// Funny enough, chmod actually does do something on windows - it removes the read only attribute.
569 609
 			@chmod(dirname(__FILE__) . '/' . $file, 0777);
570 610
 			$fp = @fopen(dirname(__FILE__) . '/' . $file, 'r+');
571 611
 
572 612
 			// Hmm, okay, try just for write in that case...
573
-			if (!is_resource($fp))
574
-				$fp = @fopen(dirname(__FILE__) . '/' . $file, 'w');
613
+			if (!is_resource($fp)) {
614
+							$fp = @fopen(dirname(__FILE__) . '/' . $file, 'w');
615
+			}
575 616
 
576
-			if (!is_resource($fp))
577
-				$failed_files[] = $file;
617
+			if (!is_resource($fp)) {
618
+							$failed_files[] = $file;
619
+			}
578 620
 
579 621
 			@fclose($fp);
580 622
 		}
581
-		foreach ($extra_files as $file)
582
-			@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
623
+		foreach ($extra_files as $file) {
624
+					@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
625
+		}
583 626
 	}
584 627
 
585 628
 	$failure = count($failed_files) >= 1;
586 629
 
587
-	if (!isset($_SERVER))
588
-		return !$failure;
630
+	if (!isset($_SERVER)) {
631
+			return !$failure;
632
+	}
589 633
 
590 634
 	// Put the list into context.
591 635
 	$incontext['failed_files'] = $failed_files;
@@ -633,19 +677,23 @@  discard block
 block discarded – undo
633 677
 
634 678
 		if (!isset($ftp) || $ftp->error !== false)
635 679
 		{
636
-			if (!isset($ftp))
637
-				$ftp = new ftp_connection(null);
680
+			if (!isset($ftp)) {
681
+							$ftp = new ftp_connection(null);
682
+			}
638 683
 			// Save the error so we can mess with listing...
639
-			elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message))
640
-				$incontext['ftp_errors'][] = $ftp->last_message;
684
+			elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) {
685
+							$incontext['ftp_errors'][] = $ftp->last_message;
686
+			}
641 687
 
642 688
 			list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__));
643 689
 
644
-			if (empty($_POST['ftp_path']) && $found_path)
645
-				$_POST['ftp_path'] = $detect_path;
690
+			if (empty($_POST['ftp_path']) && $found_path) {
691
+							$_POST['ftp_path'] = $detect_path;
692
+			}
646 693
 
647
-			if (!isset($_POST['ftp_username']))
648
-				$_POST['ftp_username'] = $username;
694
+			if (!isset($_POST['ftp_username'])) {
695
+							$_POST['ftp_username'] = $username;
696
+			}
649 697
 
650 698
 			// Set the username etc, into context.
651 699
 			$incontext['ftp'] = array(
@@ -657,8 +705,7 @@  discard block
 block discarded – undo
657 705
 			);
658 706
 
659 707
 			return false;
660
-		}
661
-		else
708
+		} else
662 709
 		{
663 710
 			$_SESSION['installer_temp_ftp'] = array(
664 711
 				'server' => $_POST['ftp_server'],
@@ -672,10 +719,12 @@  discard block
 block discarded – undo
672 719
 
673 720
 			foreach ($failed_files as $file)
674 721
 			{
675
-				if (!is_writable(dirname(__FILE__) . '/' . $file))
676
-					$ftp->chmod($file, 0755);
677
-				if (!is_writable(dirname(__FILE__) . '/' . $file))
678
-					$ftp->chmod($file, 0777);
722
+				if (!is_writable(dirname(__FILE__) . '/' . $file)) {
723
+									$ftp->chmod($file, 0755);
724
+				}
725
+				if (!is_writable(dirname(__FILE__) . '/' . $file)) {
726
+									$ftp->chmod($file, 0777);
727
+				}
679 728
 				if (!is_writable(dirname(__FILE__) . '/' . $file))
680 729
 				{
681 730
 					$failed_files_updated[] = $file;
@@ -731,15 +780,17 @@  discard block
 block discarded – undo
731 780
 
732 781
 			if (!$foundOne)
733 782
 			{
734
-				if (isset($db['default_host']))
735
-					$incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost';
783
+				if (isset($db['default_host'])) {
784
+									$incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost';
785
+				}
736 786
 				if (isset($db['default_user']))
737 787
 				{
738 788
 					$incontext['db']['user'] = ini_get($db['default_user']);
739 789
 					$incontext['db']['name'] = ini_get($db['default_user']);
740 790
 				}
741
-				if (isset($db['default_password']))
742
-					$incontext['db']['pass'] = ini_get($db['default_password']);
791
+				if (isset($db['default_password'])) {
792
+									$incontext['db']['pass'] = ini_get($db['default_password']);
793
+				}
743 794
 
744 795
 				// For simplicity and less confusion, leave the port blank by default
745 796
 				$incontext['db']['port'] = '';
@@ -758,10 +809,10 @@  discard block
 block discarded – undo
758 809
 		$incontext['db']['server'] = $_POST['db_server'];
759 810
 		$incontext['db']['prefix'] = $_POST['db_prefix'];
760 811
 
761
-		if (!empty($_POST['db_port']))
762
-			$incontext['db']['port'] = $_POST['db_port'];
763
-	}
764
-	else
812
+		if (!empty($_POST['db_port'])) {
813
+					$incontext['db']['port'] = $_POST['db_port'];
814
+		}
815
+	} else
765 816
 	{
766 817
 		$incontext['db']['prefix'] = 'smf_';
767 818
 	}
@@ -797,10 +848,11 @@  discard block
 block discarded – undo
797 848
 		if (!empty($_POST['db_port']))
798 849
 		{
799 850
 			// For MySQL, we can get the "default port" from PHP. PostgreSQL has no such option though.
800
-			if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port'))
801
-				$vars['db_port'] = (int) $_POST['db_port'];
802
-			elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432)
803
-				$vars['db_port'] = (int) $_POST['db_port'];
851
+			if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) {
852
+							$vars['db_port'] = (int) $_POST['db_port'];
853
+			} elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) {
854
+							$vars['db_port'] = (int) $_POST['db_port'];
855
+			}
804 856
 		}
805 857
 
806 858
 		// God I hope it saved!
@@ -813,8 +865,9 @@  discard block
 block discarded – undo
813 865
 		// Make sure it works.
814 866
 		require(dirname(__FILE__) . '/Settings.php');
815 867
 
816
-		if (empty($sourcedir))
817
-			$sourcedir = dirname(__FILE__) . '/Sources';
868
+		if (empty($sourcedir)) {
869
+					$sourcedir = dirname(__FILE__) . '/Sources';
870
+		}
818 871
 
819 872
 		// Better find the database file!
820 873
 		if (!file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php'))
@@ -824,12 +877,14 @@  discard block
 block discarded – undo
824 877
 		}
825 878
 
826 879
 		// Now include it for database functions!
827
-		if (!defined('SMF'))
828
-			define('SMF', 1);
880
+		if (!defined('SMF')) {
881
+					define('SMF', 1);
882
+		}
829 883
 
830 884
 		$modSettings['disableQueryCheck'] = true;
831
-		if (empty($smcFunc))
832
-			$smcFunc = array();
885
+		if (empty($smcFunc)) {
886
+					$smcFunc = array();
887
+		}
833 888
 
834 889
 		require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
835 890
 
@@ -838,11 +893,13 @@  discard block
 block discarded – undo
838 893
 
839 894
 		$options = array('non_fatal' => true, 'dont_select_db' => !$needsDB);
840 895
 		// Add in the port if needed
841
-		if (!empty($db_port))
842
-			$options['port'] = $db_port;
896
+		if (!empty($db_port)) {
897
+					$options['port'] = $db_port;
898
+		}
843 899
 		
844
-		if (!empty($db_mb4))
845
-			$options['db_mb4'] = $db_mb4;
900
+		if (!empty($db_mb4)) {
901
+					$options['db_mb4'] = $db_mb4;
902
+		}
846 903
 
847 904
 		$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $options);
848 905
 
@@ -928,12 +985,14 @@  discard block
 block discarded – undo
928 985
 	$incontext['page_title'] = $txt['install_settings'];
929 986
 
930 987
 	// Let's see if we got the database type correct.
931
-	if (isset($_POST['db_type'], $databases[$_POST['db_type']]))
932
-		$db_type = $_POST['db_type'];
988
+	if (isset($_POST['db_type'], $databases[$_POST['db_type']])) {
989
+			$db_type = $_POST['db_type'];
990
+	}
933 991
 
934 992
 	// Else we'd better be able to get the connection.
935
-	else
936
-		load_database();
993
+	else {
994
+			load_database();
995
+	}
937 996
 
938 997
 	$db_type = isset($_POST['db_type']) ? $_POST['db_type'] : $db_type;
939 998
 
@@ -942,10 +1001,11 @@  discard block
 block discarded – undo
942 1001
 
943 1002
 		$secure = false;
944 1003
 
945
-		if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on')
946
-			$secure = true;
947
-		elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on')
948
-			$secure = true;
1004
+		if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
1005
+					$secure = true;
1006
+		} elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') {
1007
+					$secure = true;
1008
+		}
949 1009
 
950 1010
 	// Now, to put what we've learned together... and add a path.
951 1011
 	$incontext['detected_url'] = 'http' . ($secure ? 's' : '') . '://' . $host . substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/'));
@@ -977,18 +1037,21 @@  discard block
 block discarded – undo
977 1037
 	// Submitting?
978 1038
 	if (isset($_POST['boardurl']))
979 1039
 	{
980
-		if (substr($_POST['boardurl'], -10) == '/index.php')
981
-			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
982
-		elseif (substr($_POST['boardurl'], -1) == '/')
983
-			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
984
-		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://')
985
-			$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
1040
+		if (substr($_POST['boardurl'], -10) == '/index.php') {
1041
+					$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
1042
+		} elseif (substr($_POST['boardurl'], -1) == '/') {
1043
+					$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
1044
+		}
1045
+		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') {
1046
+					$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
1047
+		}
986 1048
 
987 1049
 		//Make sure boardurl is aligned with ssl setting
988
-		if (empty($_POST['force_ssl']))
989
-			$_POST['boardurl'] = strtr($_POST['boardurl'], array('https://' => 'http://'));
990
-		else
991
-			$_POST['boardurl'] = strtr($_POST['boardurl'], array('http://' => 'https://'));
1050
+		if (empty($_POST['force_ssl'])) {
1051
+					$_POST['boardurl'] = strtr($_POST['boardurl'], array('https://' => 'http://'));
1052
+		} else {
1053
+					$_POST['boardurl'] = strtr($_POST['boardurl'], array('http://' => 'https://'));
1054
+		}
992 1055
 
993 1056
 		// Save these variables.
994 1057
 		$vars = array(
@@ -1027,10 +1090,10 @@  discard block
 block discarded – undo
1027 1090
 			{
1028 1091
 				$incontext['error'] = sprintf($txt['error_utf8_version'], $databases[$db_type]['utf8_version']);
1029 1092
 				return false;
1030
-			}
1031
-			else
1032
-				// Set the character set here.
1093
+			} else {
1094
+							// Set the character set here.
1033 1095
 				updateSettingsFile(array('db_character_set' => 'utf8'));
1096
+			}
1034 1097
 		}
1035 1098
 
1036 1099
 		// Good, skip on.
@@ -1050,8 +1113,9 @@  discard block
 block discarded – undo
1050 1113
 	$incontext['continue'] = 1;
1051 1114
 
1052 1115
 	// Already done?
1053
-	if (isset($_POST['pop_done']))
1054
-		return true;
1116
+	if (isset($_POST['pop_done'])) {
1117
+			return true;
1118
+	}
1055 1119
 
1056 1120
 	// Reload settings.
1057 1121
 	require(dirname(__FILE__) . '/Settings.php');
@@ -1069,8 +1133,9 @@  discard block
 block discarded – undo
1069 1133
 	$modSettings = array();
1070 1134
 	if ($result !== false)
1071 1135
 	{
1072
-		while ($row = $smcFunc['db_fetch_assoc']($result))
1073
-			$modSettings[$row['variable']] = $row['value'];
1136
+		while ($row = $smcFunc['db_fetch_assoc']($result)) {
1137
+					$modSettings[$row['variable']] = $row['value'];
1138
+		}
1074 1139
 		$smcFunc['db_free_result']($result);
1075 1140
 
1076 1141
 		// Do they match?  If so, this is just a refresh so charge on!
@@ -1083,20 +1148,22 @@  discard block
 block discarded – undo
1083 1148
 	$modSettings['disableQueryCheck'] = true;
1084 1149
 
1085 1150
 	// If doing UTF8, select it. PostgreSQL requires passing it as a string...
1086
-	if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support']))
1087
-		$smcFunc['db_query']('', '
1151
+	if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) {
1152
+			$smcFunc['db_query']('', '
1088 1153
 			SET NAMES {string:utf8}',
1089 1154
 			array(
1090 1155
 				'db_error_skip' => true,
1091 1156
 				'utf8' => 'utf8',
1092 1157
 			)
1093 1158
 		);
1159
+	}
1094 1160
 
1095 1161
 	// Windows likes to leave the trailing slash, which yields to C:\path\to\SMF\/attachments...
1096
-	if (substr(__DIR__, -1) == '\\')
1097
-		$attachdir = __DIR__ . 'attachments';
1098
-	else
1099
-		$attachdir = __DIR__ . '/attachments';
1162
+	if (substr(__DIR__, -1) == '\\') {
1163
+			$attachdir = __DIR__ . 'attachments';
1164
+	} else {
1165
+			$attachdir = __DIR__ . '/attachments';
1166
+	}
1100 1167
 
1101 1168
 	$replaces = array(
1102 1169
 		'{$db_prefix}' => $db_prefix,
@@ -1113,8 +1180,9 @@  discard block
 block discarded – undo
1113 1180
 
1114 1181
 	foreach ($txt as $key => $value)
1115 1182
 	{
1116
-		if (substr($key, 0, 8) == 'default_')
1117
-			$replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value);
1183
+		if (substr($key, 0, 8) == 'default_') {
1184
+					$replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value);
1185
+		}
1118 1186
 	}
1119 1187
 	$replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], array('\\\\n' => '\\n'));
1120 1188
 
@@ -1129,8 +1197,9 @@  discard block
 block discarded – undo
1129 1197
 
1130 1198
 		while ($row = $smcFunc['db_fetch_assoc']($get_engines))
1131 1199
 		{
1132
-			if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT')
1133
-				$engines[] = $row['Engine'];
1200
+			if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') {
1201
+							$engines[] = $row['Engine'];
1202
+			}
1134 1203
 		}
1135 1204
 
1136 1205
 		// Done with this now
@@ -1154,8 +1223,7 @@  discard block
 block discarded – undo
1154 1223
 			$replaces['START TRANSACTION;'] = '';
1155 1224
 			$replaces['COMMIT;'] = '';
1156 1225
 		}
1157
-	}
1158
-	else
1226
+	} else
1159 1227
 	{
1160 1228
 		$has_innodb = false;
1161 1229
 	}
@@ -1177,21 +1245,24 @@  discard block
 block discarded – undo
1177 1245
 	foreach ($sql_lines as $count => $line)
1178 1246
 	{
1179 1247
 		// No comments allowed!
1180
-		if (substr(trim($line), 0, 1) != '#')
1181
-			$current_statement .= "\n" . rtrim($line);
1248
+		if (substr(trim($line), 0, 1) != '#') {
1249
+					$current_statement .= "\n" . rtrim($line);
1250
+		}
1182 1251
 
1183 1252
 		// Is this the end of the query string?
1184
-		if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines)))
1185
-			continue;
1253
+		if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) {
1254
+					continue;
1255
+		}
1186 1256
 
1187 1257
 		// Does this table already exist?  If so, don't insert more data into it!
1188 1258
 		if (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) != 0 && in_array($match[1], $exists))
1189 1259
 		{
1190 1260
 			preg_match_all('~\)[,;]~', $current_statement, $matches);
1191
-			if (!empty($matches[0]))
1192
-				$incontext['sql_results']['insert_dups'] += count($matches[0]);
1193
-			else
1194
-				$incontext['sql_results']['insert_dups']++;
1261
+			if (!empty($matches[0])) {
1262
+							$incontext['sql_results']['insert_dups'] += count($matches[0]);
1263
+			} else {
1264
+							$incontext['sql_results']['insert_dups']++;
1265
+			}
1195 1266
 
1196 1267
 			$current_statement = '';
1197 1268
 			continue;
@@ -1200,8 +1271,9 @@  discard block
 block discarded – undo
1200 1271
 		if ($smcFunc['db_query']('', $current_statement, array('security_override' => true, 'db_error_skip' => true), $db_connection) === false)
1201 1272
 		{
1202 1273
 			// Use the appropriate function based on the DB type
1203
-			if ($db_type == 'mysql' || $db_type == 'mysqli')
1204
-				$db_errorno = $db_type . '_errno';
1274
+			if ($db_type == 'mysql' || $db_type == 'mysqli') {
1275
+							$db_errorno = $db_type . '_errno';
1276
+			}
1205 1277
 
1206 1278
 			// Error 1050: Table already exists!
1207 1279
 			// @todo Needs to be made better!
@@ -1216,18 +1288,18 @@  discard block
 block discarded – undo
1216 1288
 				// MySQLi requires a connection object. It's optional with MySQL and Postgres
1217 1289
 				$incontext['failures'][$count] = $smcFunc['db_error']($db_connection);
1218 1290
 			}
1219
-		}
1220
-		else
1291
+		} else
1221 1292
 		{
1222
-			if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1)
1223
-				$incontext['sql_results']['tables']++;
1224
-			elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1)
1293
+			if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) {
1294
+							$incontext['sql_results']['tables']++;
1295
+			} elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1)
1225 1296
 			{
1226 1297
 				preg_match_all('~\)[,;]~', $current_statement, $matches);
1227
-				if (!empty($matches[0]))
1228
-					$incontext['sql_results']['inserts'] += count($matches[0]);
1229
-				else
1230
-					$incontext['sql_results']['inserts']++;
1298
+				if (!empty($matches[0])) {
1299
+									$incontext['sql_results']['inserts'] += count($matches[0]);
1300
+				} else {
1301
+									$incontext['sql_results']['inserts']++;
1302
+				}
1231 1303
 			}
1232 1304
 		}
1233 1305
 
@@ -1240,15 +1312,17 @@  discard block
 block discarded – undo
1240 1312
 	// Sort out the context for the SQL.
1241 1313
 	foreach ($incontext['sql_results'] as $key => $number)
1242 1314
 	{
1243
-		if ($number == 0)
1244
-			unset($incontext['sql_results'][$key]);
1245
-		else
1246
-			$incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number);
1315
+		if ($number == 0) {
1316
+					unset($incontext['sql_results'][$key]);
1317
+		} else {
1318
+					$incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number);
1319
+		}
1247 1320
 	}
1248 1321
 
1249 1322
 	// Make sure UTF will be used globally.
1250
-	if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8'])))
1251
-		$newSettings[] = array('global_character_set', 'UTF-8');
1323
+	if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8']))) {
1324
+			$newSettings[] = array('global_character_set', 'UTF-8');
1325
+	}
1252 1326
 
1253 1327
 	// Auto-detect local & global cookie settings
1254 1328
 	$url_parts = parse_url($boardurl);
@@ -1277,15 +1351,19 @@  discard block
 block discarded – undo
1277 1351
 
1278 1352
 		// Look for subfolder, if found, set localCookie
1279 1353
 		// Checking for len > 1 ensures you don't have just a slash...
1280
-		if (!empty($url_parts['path']) && strlen($url_parts['path']) > 1)
1281
-			$localCookies = '1';
1354
+		if (!empty($url_parts['path']) && strlen($url_parts['path']) > 1) {
1355
+					$localCookies = '1';
1356
+		}
1282 1357
 
1283
-		if (isset($globalCookies))
1284
-			$newSettings[] = array('globalCookies', $globalCookies);
1285
-		if (isset($globalCookiesDomain))
1286
-			$newSettings[] = array('globalCookiesDomain', $globalCookiesDomain);
1287
-		if (isset($localCookies))
1288
-			$newSettings[] = array('localCookies', $localCookies);
1358
+		if (isset($globalCookies)) {
1359
+					$newSettings[] = array('globalCookies', $globalCookies);
1360
+		}
1361
+		if (isset($globalCookiesDomain)) {
1362
+					$newSettings[] = array('globalCookiesDomain', $globalCookiesDomain);
1363
+		}
1364
+		if (isset($localCookies)) {
1365
+					$newSettings[] = array('localCookies', $localCookies);
1366
+		}
1289 1367
 	}
1290 1368
 
1291 1369
 	// Are we allowing stat collection?
@@ -1303,16 +1381,17 @@  discard block
 block discarded – undo
1303 1381
 			fwrite($fp, $out);
1304 1382
 
1305 1383
 			$return_data = '';
1306
-			while (!feof($fp))
1307
-				$return_data .= fgets($fp, 128);
1384
+			while (!feof($fp)) {
1385
+							$return_data .= fgets($fp, 128);
1386
+			}
1308 1387
 
1309 1388
 			fclose($fp);
1310 1389
 
1311 1390
 			// Get the unique site ID.
1312 1391
 			preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID);
1313 1392
 
1314
-			if (!empty($ID[1]))
1315
-				$smcFunc['db_insert']('replace',
1393
+			if (!empty($ID[1])) {
1394
+							$smcFunc['db_insert']('replace',
1316 1395
 					$db_prefix . 'settings',
1317 1396
 					array('variable' => 'string', 'value' => 'string'),
1318 1397
 					array(
@@ -1321,11 +1400,12 @@  discard block
 block discarded – undo
1321 1400
 					),
1322 1401
 					array('variable')
1323 1402
 				);
1403
+			}
1324 1404
 		}
1325 1405
 	}
1326 1406
 	// Don't remove stat collection unless we unchecked the box for real, not from the loop.
1327
-	elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats']))
1328
-		$smcFunc['db_query']('', '
1407
+	elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) {
1408
+			$smcFunc['db_query']('', '
1329 1409
 			DELETE FROM {db_prefix}settings
1330 1410
 			WHERE variable = {string:enable_sm_stats}',
1331 1411
 			array(
@@ -1333,20 +1413,23 @@  discard block
 block discarded – undo
1333 1413
 				'db_error_skip' => true,
1334 1414
 			)
1335 1415
 		);
1416
+	}
1336 1417
 
1337 1418
 	// Are we enabling SSL?
1338
-	if (!empty($_POST['force_ssl']))
1339
-		$newSettings[] = array('force_ssl', 1);
1419
+	if (!empty($_POST['force_ssl'])) {
1420
+			$newSettings[] = array('force_ssl', 1);
1421
+	}
1340 1422
 
1341 1423
 	// Setting a timezone is required.
1342 1424
 	if (!isset($modSettings['default_timezone']) && function_exists('date_default_timezone_set'))
1343 1425
 	{
1344 1426
 		// Get PHP's default timezone, if set
1345 1427
 		$ini_tz = ini_get('date.timezone');
1346
-		if (!empty($ini_tz))
1347
-			$timezone_id = $ini_tz;
1348
-		else
1349
-			$timezone_id = '';
1428
+		if (!empty($ini_tz)) {
1429
+					$timezone_id = $ini_tz;
1430
+		} else {
1431
+					$timezone_id = '';
1432
+		}
1350 1433
 
1351 1434
 		// If date.timezone is unset, invalid, or just plain weird, make a best guess
1352 1435
 		if (!in_array($timezone_id, timezone_identifiers_list()))
@@ -1355,8 +1438,9 @@  discard block
 block discarded – undo
1355 1438
 			$timezone_id = timezone_name_from_abbr('', $server_offset, 0);
1356 1439
 		}
1357 1440
 
1358
-		if (date_default_timezone_set($timezone_id))
1359
-			$newSettings[] = array('default_timezone', $timezone_id);
1441
+		if (date_default_timezone_set($timezone_id)) {
1442
+					$newSettings[] = array('default_timezone', $timezone_id);
1443
+		}
1360 1444
 	}
1361 1445
 
1362 1446
 	if (!empty($newSettings))
@@ -1387,16 +1471,18 @@  discard block
 block discarded – undo
1387 1471
 	}
1388 1472
 
1389 1473
 	// MySQL specific stuff
1390
-	if (substr($db_type, 0, 5) != 'mysql')
1391
-		return false;
1474
+	if (substr($db_type, 0, 5) != 'mysql') {
1475
+			return false;
1476
+	}
1392 1477
 
1393 1478
 	// Find database user privileges.
1394 1479
 	$privs = array();
1395 1480
 	$get_privs = $smcFunc['db_query']('', 'SHOW PRIVILEGES', array());
1396 1481
 	while ($row = $smcFunc['db_fetch_assoc']($get_privs))
1397 1482
 	{
1398
-		if ($row['Privilege'] == 'Alter')
1399
-			$privs[] = $row['Privilege'];
1483
+		if ($row['Privilege'] == 'Alter') {
1484
+					$privs[] = $row['Privilege'];
1485
+		}
1400 1486
 	}
1401 1487
 	$smcFunc['db_free_result']($get_privs);
1402 1488
 
@@ -1426,8 +1512,9 @@  discard block
 block discarded – undo
1426 1512
 	$incontext['continue'] = 1;
1427 1513
 
1428 1514
 	// Skipping?
1429
-	if (!empty($_POST['skip']))
1430
-		return true;
1515
+	if (!empty($_POST['skip'])) {
1516
+			return true;
1517
+	}
1431 1518
 
1432 1519
 	// Need this to check whether we need the database password.
1433 1520
 	require(dirname(__FILE__) . '/Settings.php');
@@ -1444,18 +1531,22 @@  discard block
 block discarded – undo
1444 1531
 	// We need this to properly hash the password for Admin
1445 1532
 	$smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) {
1446 1533
 			global $sourcedir;
1447
-			if (function_exists('mb_strtolower'))
1448
-				return mb_strtolower($string, 'UTF-8');
1534
+			if (function_exists('mb_strtolower')) {
1535
+							return mb_strtolower($string, 'UTF-8');
1536
+			}
1449 1537
 			require_once($sourcedir . '/Subs-Charset.php');
1450 1538
 			return utf8_strtolower($string);
1451 1539
 		};
1452 1540
 
1453
-	if (!isset($_POST['username']))
1454
-		$_POST['username'] = '';
1455
-	if (!isset($_POST['email']))
1456
-		$_POST['email'] = '';
1457
-	if (!isset($_POST['server_email']))
1458
-		$_POST['server_email'] = '';
1541
+	if (!isset($_POST['username'])) {
1542
+			$_POST['username'] = '';
1543
+	}
1544
+	if (!isset($_POST['email'])) {
1545
+			$_POST['email'] = '';
1546
+	}
1547
+	if (!isset($_POST['server_email'])) {
1548
+			$_POST['server_email'] = '';
1549
+	}
1459 1550
 
1460 1551
 	$incontext['username'] = htmlspecialchars(stripslashes($_POST['username']));
1461 1552
 	$incontext['email'] = htmlspecialchars(stripslashes($_POST['email']));
@@ -1474,8 +1565,9 @@  discard block
 block discarded – undo
1474 1565
 			'admin_group' => 1,
1475 1566
 		)
1476 1567
 	);
1477
-	if ($smcFunc['db_num_rows']($request) != 0)
1478
-		$incontext['skip'] = 1;
1568
+	if ($smcFunc['db_num_rows']($request) != 0) {
1569
+			$incontext['skip'] = 1;
1570
+	}
1479 1571
 	$smcFunc['db_free_result']($request);
1480 1572
 
1481 1573
 	// Trying to create an account?
@@ -1506,8 +1598,9 @@  discard block
 block discarded – undo
1506 1598
 		}
1507 1599
 
1508 1600
 		// Update the webmaster's email?
1509
-		if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]'))
1510
-			updateSettingsFile(array('webmaster_email' => $_POST['server_email']));
1601
+		if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) {
1602
+					updateSettingsFile(array('webmaster_email' => $_POST['server_email']));
1603
+		}
1511 1604
 
1512 1605
 		// Work out whether we're going to have dodgy characters and remove them.
1513 1606
 		$invalid_characters = preg_match('~[<>&"\'=\\\]~', $_POST['username']) != 0;
@@ -1530,32 +1623,27 @@  discard block
 block discarded – undo
1530 1623
 			$smcFunc['db_free_result']($result);
1531 1624
 
1532 1625
 			$incontext['account_existed'] = $txt['error_user_settings_taken'];
1533
-		}
1534
-		elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25)
1626
+		} elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25)
1535 1627
 		{
1536 1628
 			// Try the previous step again.
1537 1629
 			$incontext['error'] = $_POST['username'] == '' ? $txt['error_username_left_empty'] : $txt['error_username_too_long'];
1538 1630
 			return false;
1539
-		}
1540
-		elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false)
1631
+		} elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false)
1541 1632
 		{
1542 1633
 			// Try the previous step again.
1543 1634
 			$incontext['error'] = $txt['error_invalid_characters_username'];
1544 1635
 			return false;
1545
-		}
1546
-		elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255)
1636
+		} elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255)
1547 1637
 		{
1548 1638
 			// One step back, this time fill out a proper admin email address.
1549 1639
 			$incontext['error'] = sprintf($txt['error_valid_admin_email_needed'], $_POST['username']);
1550 1640
 			return false;
1551
-		}
1552
-		elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255)
1641
+		} elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255)
1553 1642
 		{
1554 1643
 			// One step back, this time fill out a proper admin email address.
1555 1644
 			$incontext['error'] = $txt['error_valid_server_email_needed'];
1556 1645
 			return false;
1557
-		}
1558
-		elseif ($_POST['username'] != '')
1646
+		} elseif ($_POST['username'] != '')
1559 1647
 		{
1560 1648
 			$incontext['member_salt'] = substr(md5(mt_rand()), 0, 4);
1561 1649
 
@@ -1623,17 +1711,19 @@  discard block
 block discarded – undo
1623 1711
 	reloadSettings();
1624 1712
 
1625 1713
 	// Bring a warning over.
1626
-	if (!empty($incontext['account_existed']))
1627
-		$incontext['warning'] = $incontext['account_existed'];
1714
+	if (!empty($incontext['account_existed'])) {
1715
+			$incontext['warning'] = $incontext['account_existed'];
1716
+	}
1628 1717
 
1629
-	if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support']))
1630
-		$smcFunc['db_query']('', '
1718
+	if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) {
1719
+			$smcFunc['db_query']('', '
1631 1720
 			SET NAMES {string:db_character_set}',
1632 1721
 			array(
1633 1722
 				'db_character_set' => $db_character_set,
1634 1723
 				'db_error_skip' => true,
1635 1724
 			)
1636 1725
 		);
1726
+	}
1637 1727
 
1638 1728
 	// As track stats is by default enabled let's add some activity.
1639 1729
 	$smcFunc['db_insert']('ignore',
@@ -1654,14 +1744,16 @@  discard block
 block discarded – undo
1654 1744
 	// Only proceed if we can load the data.
1655 1745
 	if ($request)
1656 1746
 	{
1657
-		while ($row = $smcFunc['db_fetch_row']($request))
1658
-			$modSettings[$row[0]] = $row[1];
1747
+		while ($row = $smcFunc['db_fetch_row']($request)) {
1748
+					$modSettings[$row[0]] = $row[1];
1749
+		}
1659 1750
 		$smcFunc['db_free_result']($request);
1660 1751
 	}
1661 1752
 
1662 1753
 	// Automatically log them in ;)
1663
-	if (isset($incontext['member_id']) && isset($incontext['member_salt']))
1664
-		setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt']));
1754
+	if (isset($incontext['member_id']) && isset($incontext['member_salt'])) {
1755
+			setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt']));
1756
+	}
1665 1757
 
1666 1758
 	$result = $smcFunc['db_query']('', '
1667 1759
 		SELECT value
@@ -1672,13 +1764,14 @@  discard block
 block discarded – undo
1672 1764
 			'db_error_skip' => true,
1673 1765
 		)
1674 1766
 	);
1675
-	if ($smcFunc['db_num_rows']($result) != 0)
1676
-		list ($db_sessions) = $smcFunc['db_fetch_row']($result);
1767
+	if ($smcFunc['db_num_rows']($result) != 0) {
1768
+			list ($db_sessions) = $smcFunc['db_fetch_row']($result);
1769
+	}
1677 1770
 	$smcFunc['db_free_result']($result);
1678 1771
 
1679
-	if (empty($db_sessions))
1680
-		$_SESSION['admin_time'] = time();
1681
-	else
1772
+	if (empty($db_sessions)) {
1773
+			$_SESSION['admin_time'] = time();
1774
+	} else
1682 1775
 	{
1683 1776
 		$_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211);
1684 1777
 
@@ -1702,8 +1795,9 @@  discard block
 block discarded – undo
1702 1795
 	$smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' :
1703 1796
 		function($string){
1704 1797
 			global $sourcedir;
1705
-			if (function_exists('mb_strtolower'))
1706
-				return mb_strtolower($string, 'UTF-8');
1798
+			if (function_exists('mb_strtolower')) {
1799
+							return mb_strtolower($string, 'UTF-8');
1800
+			}
1707 1801
 			require_once($sourcedir . '/Subs-Charset.php');
1708 1802
 			return utf8_strtolower($string);
1709 1803
 		};
@@ -1719,8 +1813,9 @@  discard block
 block discarded – undo
1719 1813
 		)
1720 1814
 	);
1721 1815
 	$context['utf8'] = $db_character_set === 'utf8' || $txt['lang_character_set'] === 'UTF-8';
1722
-	if ($smcFunc['db_num_rows']($request) > 0)
1723
-		updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject']));
1816
+	if ($smcFunc['db_num_rows']($request) > 0) {
1817
+			updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject']));
1818
+	}
1724 1819
 	$smcFunc['db_free_result']($request);
1725 1820
 
1726 1821
 	// Now is the perfect time to fetch the SM files.
@@ -1739,8 +1834,9 @@  discard block
 block discarded – undo
1739 1834
 
1740 1835
 	// Check if we need some stupid MySQL fix.
1741 1836
 	$server_version = $smcFunc['db_server_info']();
1742
-	if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51')))
1743
-		updateSettings(array('db_mysql_group_by_fix' => '1'));
1837
+	if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) {
1838
+			updateSettings(array('db_mysql_group_by_fix' => '1'));
1839
+	}
1744 1840
 
1745 1841
 	// Some final context for the template.
1746 1842
 	$incontext['dir_still_writable'] = is_writable(dirname(__FILE__)) && substr(__FILE__, 1, 2) != ':\\';
@@ -1760,8 +1856,9 @@  discard block
 block discarded – undo
1760 1856
 	$settingsArray = file(dirname(__FILE__) . '/Settings.php');
1761 1857
 
1762 1858
 	// @todo Do we just want to read the file in clean, and split it this way always?
1763
-	if (count($settingsArray) == 1)
1764
-		$settingsArray = preg_split('~[\r\n]~', $settingsArray[0]);
1859
+	if (count($settingsArray) == 1) {
1860
+			$settingsArray = preg_split('~[\r\n]~', $settingsArray[0]);
1861
+	}
1765 1862
 
1766 1863
 	for ($i = 0, $n = count($settingsArray); $i < $n; $i++)
1767 1864
 	{
@@ -1769,25 +1866,29 @@  discard block
 block discarded – undo
1769 1866
 		if (trim($settingsArray[$i]) == 'if (file_exists(dirname(__FILE__) . \'/install.php\'))' && trim($settingsArray[$i + 1]) == '{' && trim($settingsArray[$i + 9]) == '}')
1770 1867
 		{
1771 1868
 			// Set the ten lines to nothing.
1772
-			for ($j=0; $j < 10; $j++)
1773
-				$settingsArray[$i++] = '';
1869
+			for ($j=0; $j < 10; $j++) {
1870
+							$settingsArray[$i++] = '';
1871
+			}
1774 1872
 
1775 1873
 			continue;
1776 1874
 		}
1777 1875
 
1778
-		if (trim($settingsArray[$i]) == '?' . '>')
1779
-			$settingsArray[$i] = '';
1876
+		if (trim($settingsArray[$i]) == '?' . '>') {
1877
+					$settingsArray[$i] = '';
1878
+		}
1780 1879
 
1781 1880
 		// Don't trim or bother with it if it's not a variable.
1782
-		if (substr($settingsArray[$i], 0, 1) != '$')
1783
-			continue;
1881
+		if (substr($settingsArray[$i], 0, 1) != '$') {
1882
+					continue;
1883
+		}
1784 1884
 
1785 1885
 		$settingsArray[$i] = rtrim($settingsArray[$i]) . "\n";
1786 1886
 
1787
-		foreach ($vars as $var => $val)
1788
-			if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0)
1887
+		foreach ($vars as $var => $val) {
1888
+					if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0)
1789 1889
 			{
1790 1890
 				$comment = strstr($settingsArray[$i], '#');
1891
+		}
1791 1892
 				$settingsArray[$i] = '$' . $var . ' = \'' . $val . '\';' . ($comment != '' ? "\t\t" . $comment : "\n");
1792 1893
 				unset($vars[$var]);
1793 1894
 			}
@@ -1797,36 +1898,41 @@  discard block
 block discarded – undo
1797 1898
 	if (!empty($vars))
1798 1899
 	{
1799 1900
 		$settingsArray[$i++] = '';
1800
-		foreach ($vars as $var => $val)
1801
-			$settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n";
1901
+		foreach ($vars as $var => $val) {
1902
+					$settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n";
1903
+		}
1802 1904
 	}
1803 1905
 
1804 1906
 	// Blank out the file - done to fix a oddity with some servers.
1805 1907
 	$fp = @fopen(dirname(__FILE__) . '/Settings.php', 'w');
1806
-	if (!$fp)
1807
-		return false;
1908
+	if (!$fp) {
1909
+			return false;
1910
+	}
1808 1911
 	fclose($fp);
1809 1912
 
1810 1913
 	$fp = fopen(dirname(__FILE__) . '/Settings.php', 'r+');
1811 1914
 
1812 1915
 	// Gotta have one of these ;)
1813
-	if (trim($settingsArray[0]) != '<?php')
1814
-		fwrite($fp, "<?php\n");
1916
+	if (trim($settingsArray[0]) != '<?php') {
1917
+			fwrite($fp, "<?php\n");
1918
+	}
1815 1919
 
1816 1920
 	$lines = count($settingsArray);
1817 1921
 	for ($i = 0; $i < $lines - 1; $i++)
1818 1922
 	{
1819 1923
 		// Don't just write a bunch of blank lines.
1820
-		if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '')
1821
-			fwrite($fp, strtr($settingsArray[$i], "\r", ''));
1924
+		if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') {
1925
+					fwrite($fp, strtr($settingsArray[$i], "\r", ''));
1926
+		}
1822 1927
 	}
1823 1928
 	fwrite($fp, $settingsArray[$i] . '?' . '>');
1824 1929
 	fclose($fp);
1825 1930
 
1826 1931
 	// Even though on normal installations the filemtime should prevent this being used by the installer incorrectly
1827 1932
 	// it seems that there are times it might not. So let's MAKE it dump the cache.
1828
-	if (function_exists('opcache_invalidate'))
1829
-		opcache_invalidate(dirname(__FILE__) . '/Settings.php', true);
1933
+	if (function_exists('opcache_invalidate')) {
1934
+			opcache_invalidate(dirname(__FILE__) . '/Settings.php', true);
1935
+	}
1830 1936
 
1831 1937
 	return true;
1832 1938
 }
@@ -1836,10 +1942,11 @@  discard block
 block discarded – undo
1836 1942
 	global $cachedir;
1837 1943
 
1838 1944
 	// Write out the db_last_error file with the error timestamp
1839
-	if (!empty($cachedir) && is_writable($cachedir))
1840
-		file_put_contents($cachedir . '/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>');
1841
-	else
1842
-		file_put_contents(dirname(__FILE__) . '/cache/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>');
1945
+	if (!empty($cachedir) && is_writable($cachedir)) {
1946
+			file_put_contents($cachedir . '/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>');
1947
+	} else {
1948
+			file_put_contents(dirname(__FILE__) . '/cache/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>');
1949
+	}
1843 1950
 
1844 1951
 	return true;
1845 1952
 }
@@ -1856,9 +1963,9 @@  discard block
 block discarded – undo
1856 1963
 	SecFilterScanPOST Off
1857 1964
 </IfModule>';
1858 1965
 
1859
-	if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules()))
1860
-		return true;
1861
-	elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess'))
1966
+	if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) {
1967
+			return true;
1968
+	} elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess'))
1862 1969
 	{
1863 1970
 		$current_htaccess = implode('', file(dirname(__FILE__) . '/.htaccess'));
1864 1971
 
@@ -1870,29 +1977,28 @@  discard block
 block discarded – undo
1870 1977
 				fwrite($ht_handle, $htaccess_addition);
1871 1978
 				fclose($ht_handle);
1872 1979
 				return true;
1980
+			} else {
1981
+							return false;
1873 1982
 			}
1874
-			else
1875
-				return false;
1983
+		} else {
1984
+					return true;
1876 1985
 		}
1877
-		else
1878
-			return true;
1879
-	}
1880
-	elseif (file_exists(dirname(__FILE__) . '/.htaccess'))
1881
-		return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false;
1882
-	elseif (is_writable(dirname(__FILE__)))
1986
+	} elseif (file_exists(dirname(__FILE__) . '/.htaccess')) {
1987
+			return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false;
1988
+	} elseif (is_writable(dirname(__FILE__)))
1883 1989
 	{
1884 1990
 		if ($ht_handle = fopen(dirname(__FILE__) . '/.htaccess', 'w'))
1885 1991
 		{
1886 1992
 			fwrite($ht_handle, $htaccess_addition);
1887 1993
 			fclose($ht_handle);
1888 1994
 			return true;
1995
+		} else {
1996
+					return false;
1889 1997
 		}
1890
-		else
1998
+	} else {
1891 1999
 			return false;
1892 2000
 	}
1893
-	else
1894
-		return false;
1895
-}
2001
+	}
1896 2002
 
1897 2003
 function template_install_above()
1898 2004
 {
@@ -1931,9 +2037,10 @@  discard block
 block discarded – undo
1931 2037
 							<label for="installer_language">', $txt['installer_language'], ':</label>
1932 2038
 							<select id="installer_language" name="lang_file" onchange="location.href = \'', $installurl, '?lang_file=\' + this.options[this.selectedIndex].value;">';
1933 2039
 
1934
-		foreach ($incontext['detected_languages'] as $lang => $name)
1935
-			echo '
2040
+		foreach ($incontext['detected_languages'] as $lang => $name) {
2041
+					echo '
1936 2042
 								<option', isset($_SESSION['installer_temp_lang']) && $_SESSION['installer_temp_lang'] == $lang ? ' selected' : '', ' value="', $lang, '">', $name, '</option>';
2043
+		}
1937 2044
 
1938 2045
 		echo '
1939 2046
 							</select>
@@ -1953,9 +2060,10 @@  discard block
 block discarded – undo
1953 2060
 					<h2>', $txt['upgrade_progress'], '</h2>
1954 2061
 					<ul>';
1955 2062
 
1956
-	foreach ($incontext['steps'] as $num => $step)
1957
-		echo '
2063
+	foreach ($incontext['steps'] as $num => $step) {
2064
+			echo '
1958 2065
 						<li class="', $num < $incontext['current_step'] ? 'stepdone' : ($num == $incontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>';
2066
+	}
1959 2067
 
1960 2068
 	echo '
1961 2069
 					</ul>
@@ -1981,20 +2089,23 @@  discard block
 block discarded – undo
1981 2089
 		echo '
1982 2090
 							<div class="floatright">';
1983 2091
 
1984
-		if (!empty($incontext['continue']))
1985
-			echo '
2092
+		if (!empty($incontext['continue'])) {
2093
+					echo '
1986 2094
 								<input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '" onclick="return submitThisOnce(this);" class="button">';
1987
-		if (!empty($incontext['skip']))
1988
-			echo '
2095
+		}
2096
+		if (!empty($incontext['skip'])) {
2097
+					echo '
1989 2098
 								<input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="return submitThisOnce(this);" class="button">';
2099
+		}
1990 2100
 		echo '
1991 2101
 							</div>';
1992 2102
 	}
1993 2103
 
1994 2104
 	// Show the closing form tag and other data only if not in the last step
1995
-	if (count($incontext['steps']) - 1 !== (int) $incontext['current_step'])
1996
-		echo '
2105
+	if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) {
2106
+			echo '
1997 2107
 						</form>';
2108
+	}
1998 2109
 
1999 2110
 	echo '
2000 2111
 					</div><!-- .panel -->
@@ -2027,13 +2138,15 @@  discard block
 block discarded – undo
2027 2138
 		</div>';
2028 2139
 
2029 2140
 	// Show the warnings, or not.
2030
-	if (template_warning_divs())
2031
-		echo '
2141
+	if (template_warning_divs()) {
2142
+			echo '
2032 2143
 		<h3>', $txt['install_all_lovely'], '</h3>';
2144
+	}
2033 2145
 
2034 2146
 	// Say we want the continue button!
2035
-	if (empty($incontext['error']))
2036
-		$incontext['continue'] = 1;
2147
+	if (empty($incontext['error'])) {
2148
+			$incontext['continue'] = 1;
2149
+	}
2037 2150
 
2038 2151
 	// For the latest version stuff.
2039 2152
 	echo '
@@ -2067,19 +2180,21 @@  discard block
 block discarded – undo
2067 2180
 	global $txt, $incontext;
2068 2181
 
2069 2182
 	// Errors are very serious..
2070
-	if (!empty($incontext['error']))
2071
-		echo '
2183
+	if (!empty($incontext['error'])) {
2184
+			echo '
2072 2185
 		<div class="errorbox">
2073 2186
 			<h3>', $txt['upgrade_critical_error'], '</h3>
2074 2187
 			', $incontext['error'], '
2075 2188
 		</div>';
2189
+	}
2076 2190
 	// A warning message?
2077
-	elseif (!empty($incontext['warning']))
2078
-		echo '
2191
+	elseif (!empty($incontext['warning'])) {
2192
+			echo '
2079 2193
 		<div class="errorbox">
2080 2194
 			<h3>', $txt['upgrade_warning'], '</h3>
2081 2195
 			', $incontext['warning'], '
2082 2196
 		</div>';
2197
+	}
2083 2198
 
2084 2199
 	return empty($incontext['error']) && empty($incontext['warning']);
2085 2200
 }
@@ -2095,26 +2210,29 @@  discard block
 block discarded – undo
2095 2210
 			<li>', $incontext['failed_files']), '</li>
2096 2211
 		</ul>';
2097 2212
 
2098
-	if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux')
2099
-		echo '
2213
+	if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') {
2214
+			echo '
2100 2215
 		<hr>
2101 2216
 		<p>', $txt['chmod_linux_info'], '</p>
2102 2217
 		<samp># chmod a+w ', implode(' ' . $incontext['detected_path'] . '/', $incontext['failed_files']), '</samp>';
2218
+	}
2103 2219
 
2104 2220
 	// This is serious!
2105
-	if (!template_warning_divs())
2106
-		return;
2221
+	if (!template_warning_divs()) {
2222
+			return;
2223
+	}
2107 2224
 
2108 2225
 	echo '
2109 2226
 		<hr>
2110 2227
 		<p>', $txt['ftp_setup_info'], '</p>';
2111 2228
 
2112
-	if (!empty($incontext['ftp_errors']))
2113
-		echo '
2229
+	if (!empty($incontext['ftp_errors'])) {
2230
+			echo '
2114 2231
 		<div class="error_message">
2115 2232
 			', $txt['error_ftp_no_connect'], '<br><br>
2116 2233
 			<code>', implode('<br>', $incontext['ftp_errors']), '</code>
2117 2234
 		</div>';
2235
+	}
2118 2236
 
2119 2237
 	echo '
2120 2238
 		<form action="', $incontext['form_url'], '" method="post">
@@ -2183,16 +2301,16 @@  discard block
 block discarded – undo
2183 2301
 			<dd>
2184 2302
 				<select name="db_type" id="db_type_input" onchange="toggleDBInput();">';
2185 2303
 
2186
-	foreach ($incontext['supported_databases'] as $key => $db)
2187
-			echo '
2304
+	foreach ($incontext['supported_databases'] as $key => $db) {
2305
+				echo '
2188 2306
 					<option value="', $key, '"', isset($_POST['db_type']) && $_POST['db_type'] == $key ? ' selected' : '', '>', $db['name'], '</option>';
2307
+	}
2189 2308
 
2190 2309
 	echo '
2191 2310
 				</select>
2192 2311
 				<div class="smalltext">', $txt['db_settings_type_info'], '</div>
2193 2312
 			</dd>';
2194
-	}
2195
-	else
2313
+	} else
2196 2314
 	{
2197 2315
 		echo '
2198 2316
 			<dd>
@@ -2360,9 +2478,10 @@  discard block
 block discarded – undo
2360 2478
 		<div class="red">', $txt['error_db_queries'], '</div>
2361 2479
 		<ul>';
2362 2480
 
2363
-		foreach ($incontext['failures'] as $line => $fail)
2364
-			echo '
2481
+		foreach ($incontext['failures'] as $line => $fail) {
2482
+					echo '
2365 2483
 			<li><strong>', $txt['error_db_queries_line'], $line + 1, ':</strong> ', nl2br(htmlspecialchars($fail)), '</li>';
2484
+		}
2366 2485
 
2367 2486
 		echo '
2368 2487
 		</ul>';
@@ -2427,15 +2546,16 @@  discard block
 block discarded – undo
2427 2546
 			</dd>
2428 2547
 		</dl>';
2429 2548
 
2430
-	if ($incontext['require_db_confirm'])
2431
-		echo '
2549
+	if ($incontext['require_db_confirm']) {
2550
+			echo '
2432 2551
 		<h2>', $txt['user_settings_database'], '</h2>
2433 2552
 		<p>', $txt['user_settings_database_info'], '</p>
2434 2553
 
2435 2554
 		<div class="lefttext">
2436 2555
 			<input type="password" name="password3" size="30">
2437 2556
 		</div>';
2438
-}
2557
+	}
2558
+	}
2439 2559
 
2440 2560
 // Tell them it's done, and to delete.
2441 2561
 function template_delete_install()
@@ -2448,13 +2568,14 @@  discard block
 block discarded – undo
2448 2568
 	template_warning_divs();
2449 2569
 
2450 2570
 	// Install directory still writable?
2451
-	if ($incontext['dir_still_writable'])
2452
-		echo '
2571
+	if ($incontext['dir_still_writable']) {
2572
+			echo '
2453 2573
 		<p><em>', $txt['still_writable'], '</em></p>';
2574
+	}
2454 2575
 
2455 2576
 	// Don't show the box if it's like 99% sure it won't work :P.
2456
-	if ($incontext['probably_delete_install'])
2457
-		echo '
2577
+	if ($incontext['probably_delete_install']) {
2578
+			echo '
2458 2579
 		<label>
2459 2580
 			<input type="checkbox" id="delete_self" onclick="doTheDelete();">
2460 2581
 			<strong>', $txt['delete_installer'], !isset($_SESSION['installer_temp_ftp']) ? ' ' . $txt['delete_installer_maybe'] : '', '</strong>
@@ -2470,6 +2591,7 @@  discard block
 block discarded – undo
2470 2591
 				theCheck.disabled = true;
2471 2592
 			}
2472 2593
 		</script>';
2594
+	}
2473 2595
 
2474 2596
 	echo '
2475 2597
 		<p>', sprintf($txt['go_to_your_forum'], $boardurl . '/index.php'), '</p>
Please login to merge, or discard this patch.
Themes/default/GenericControls.template.php 1 patch
Braces   +74 added lines, -54 removed lines patch added patch discarded remove patch
@@ -23,11 +23,13 @@  discard block
 block discarded – undo
23 23
 
24 24
 	$editor_context = &$context['controls']['richedit'][$editor_id];
25 25
 
26
-	if ($smileyContainer === null)
27
-		$editor_context['sce_options']['emoticonsEnabled'] = false;
26
+	if ($smileyContainer === null) {
27
+			$editor_context['sce_options']['emoticonsEnabled'] = false;
28
+	}
28 29
 
29
-	if ($bbcContainer === null)
30
-		$editor_context['sce_options']['toolbar'] = '';
30
+	if ($bbcContainer === null) {
31
+			$editor_context['sce_options']['toolbar'] = '';
32
+	}
31 33
 
32 34
 	echo '
33 35
 		<textarea class="editor" name="', $editor_id, '" id="', $editor_id, '" cols="600" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);" onchange="storeCaret(this);" tabindex="', $context['tabindex']++, '" style="width: ', $editor_context['width'], '; height: ', $editor_context['height'], ';', isset($context['post_error']['no_message']) || isset($context['post_error']['long_message']) ? 'border: 1px solid red;' : '', '"', !empty($context['editor']['required']) ? ' required' : '', '>', $editor_context['value'], '</textarea>
@@ -40,18 +42,21 @@  discard block
 block discarded – undo
40 42
 				var textarea = $("#', $editor_id, '").get(0);
41 43
 				sceditor.create(textarea, ', $smcFunc['json_encode']($editor_context['sce_options'], JSON_PRETTY_PRINT), ');';
42 44
 
43
-	if ($editor_context['sce_options']['emoticonsEnabled'])
44
-		echo '
45
+	if ($editor_context['sce_options']['emoticonsEnabled']) {
46
+			echo '
45 47
 				sceditor.instance(textarea).createPermanentDropDown();';
48
+	}
46 49
 
47
-	if (empty($editor_context['rich_active']))
48
-		echo '
50
+	if (empty($editor_context['rich_active'])) {
51
+			echo '
49 52
 				sceditor.instance(textarea).toggleSourceMode();';
53
+	}
50 54
 
51
-	if (isset($context['post_error']['no_message']) || isset($context['post_error']['long_message']))
52
-		echo '
55
+	if (isset($context['post_error']['no_message']) || isset($context['post_error']['long_message'])) {
56
+			echo '
53 57
 				$(".sceditor-container").find("textarea").each(function() {$(this).css({border: "1px solid red"})});
54 58
 				$(".sceditor-container").find("iframe").each(function() {$(this).css({border: "1px solid red"})});';
59
+	}
55 60
 
56 61
 	echo '
57 62
 			});';
@@ -88,42 +93,47 @@  discard block
 block discarded – undo
88 93
 
89 94
 	$tempTab = $context['tabindex'];
90 95
 
91
-	if (!empty($context['drafts_pm_save']))
92
-		$tempTab++;
93
-	elseif (!empty($context['drafts_save']))
94
-		$tempTab++;
95
-	elseif ($editor_context['preview_type'])
96
-		$tempTab++;
97
-	elseif ($context['show_spellchecking'])
98
-		$tempTab++;
96
+	if (!empty($context['drafts_pm_save'])) {
97
+			$tempTab++;
98
+	} elseif (!empty($context['drafts_save'])) {
99
+			$tempTab++;
100
+	} elseif ($editor_context['preview_type']) {
101
+			$tempTab++;
102
+	} elseif ($context['show_spellchecking']) {
103
+			$tempTab++;
104
+	}
99 105
 
100 106
 	$tempTab++;
101 107
 	$context['tabindex'] = $tempTab;
102 108
 
103
-	if (!empty($context['drafts_pm_save']))
104
-		echo '
109
+	if (!empty($context['drafts_pm_save'])) {
110
+			echo '
105 111
 		<input type="submit" name="save_draft" value="', $txt['draft_save'], '" tabindex="', --$tempTab, '" onclick="submitThisOnce(this);" accesskey="d" class="button">
106 112
 		<input type="hidden" id="id_pm_draft" name="id_pm_draft" value="', empty($context['id_pm_draft']) ? 0 : $context['id_pm_draft'], '">';
113
+	}
107 114
 
108
-	if (!empty($context['drafts_save']))
109
-		echo '
115
+	if (!empty($context['drafts_save'])) {
116
+			echo '
110 117
 		<input type="submit" name="save_draft" value="', $txt['draft_save'], '" tabindex="', --$tempTab, '" onclick="return confirm(' . JavaScriptEscape($txt['draft_save_note']) . ') && submitThisOnce(this);" accesskey="d" class="button">
111 118
 		<input type="hidden" id="id_draft" name="id_draft" value="', empty($context['id_draft']) ? 0 : $context['id_draft'], '">';
119
+	}
112 120
 
113
-	if ($context['show_spellchecking'])
114
-		echo '
121
+	if ($context['show_spellchecking']) {
122
+			echo '
115 123
 		<input type="button" value="', $txt['spell_check'], '" tabindex="', --$tempTab, '" onclick="oEditorHandle_', $editor_id, '.spellCheckStart();" class="button">';
124
+	}
116 125
 
117
-	if ($editor_context['preview_type'])
118
-		echo '
126
+	if ($editor_context['preview_type']) {
127
+			echo '
119 128
 		<input type="submit" name="preview" value="', isset($editor_context['labels']['preview_button']) ? $editor_context['labels']['preview_button'] : $txt['preview'], '" tabindex="', --$tempTab, '" onclick="', $editor_context['preview_type'] == 2 ? '' : 'return submitThisOnce(this);', '" accesskey="p" class="button">';
129
+	}
120 130
 
121 131
 	echo '
122 132
 		<input type="submit" value="', isset($editor_context['labels']['post_button']) ? $editor_context['labels']['post_button'] : $txt['post'], '" name="post" tabindex="', --$tempTab, '" onclick="return submitThisOnce(this);" accesskey="s" class="button">';
123 133
 
124 134
 	// Load in the PM autosaver if it's enabled
125
-	if (!empty($context['drafts_pm_save']) && !empty($context['drafts_autosave']))
126
-		echo '
135
+	if (!empty($context['drafts_pm_save']) && !empty($context['drafts_autosave'])) {
136
+			echo '
127 137
 		<span class="righttext padding" style="display: block">
128 138
 			<span id="throbber" style="display:none"><img src="' . $settings['images_url'] . '/loading_sm.gif" alt="" class="centericon"></span>
129 139
 			<span id="draft_lastautosave" ></span>
@@ -141,10 +151,11 @@  discard block
 block discarded – undo
141 151
 				iFreq: ', (empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000), '
142 152
 			});
143 153
 		</script>';
154
+	}
144 155
 
145 156
 	// Start an instance of the auto saver if its enabled
146
-	if (!empty($context['drafts_save']) && !empty($context['drafts_autosave']))
147
-		echo '
157
+	if (!empty($context['drafts_save']) && !empty($context['drafts_autosave'])) {
158
+			echo '
148 159
 		<span class="righttext padding" style="display: block">
149 160
 			<span id="throbber" style="display:none"><img src="', $settings['images_url'], '/loading_sm.gif" alt="" class="centericon"></span>
150 161
 			<span id="draft_lastautosave" ></span>
@@ -161,7 +172,8 @@  discard block
 block discarded – undo
161 172
 				iFreq: ', $context['drafts_autosave_frequency'], '
162 173
 			});
163 174
 		</script>';
164
-}
175
+	}
176
+	}
165 177
 
166 178
 /**
167 179
  * This template displays a verification form
@@ -178,51 +190,57 @@  discard block
 block discarded – undo
178 190
 	$verify_context = &$context['controls']['verification'][$verify_id];
179 191
 
180 192
 	// Keep track of where we are.
181
-	if (empty($verify_context['tracking']) || $reset)
182
-		$verify_context['tracking'] = 0;
193
+	if (empty($verify_context['tracking']) || $reset) {
194
+			$verify_context['tracking'] = 0;
195
+	}
183 196
 
184 197
 	// How many items are there to display in total.
185 198
 	$total_items = count($verify_context['questions']) + ($verify_context['show_visual'] || $verify_context['can_recaptcha'] ? 1 : 0);
186 199
 
187 200
 	// If we've gone too far, stop.
188
-	if ($verify_context['tracking'] > $total_items)
189
-		return false;
201
+	if ($verify_context['tracking'] > $total_items) {
202
+			return false;
203
+	}
190 204
 
191 205
 	// Loop through each item to show them.
192 206
 	for ($i = 0; $i < $total_items; $i++)
193 207
 	{
194 208
 		// If we're after a single item only show it if we're in the right place.
195
-		if ($display_type == 'single' && $verify_context['tracking'] != $i)
196
-			continue;
209
+		if ($display_type == 'single' && $verify_context['tracking'] != $i) {
210
+					continue;
211
+		}
197 212
 
198
-		if ($display_type != 'single')
199
-			echo '
213
+		if ($display_type != 'single') {
214
+					echo '
200 215
 			<div id="verification_control_', $i, '" class="verification_control">';
216
+		}
201 217
 
202 218
 		// Display empty field, but only if we have one, and it's the first time.
203
-		if ($verify_context['empty_field'] && empty($i))
204
-			echo '
219
+		if ($verify_context['empty_field'] && empty($i)) {
220
+					echo '
205 221
 				<div class="smalltext vv_special">
206 222
 					', $txt['visual_verification_hidden'], ':
207 223
 					<input type="text" name="', $_SESSION[$verify_id . '_vv']['empty_field'], '" autocomplete="off" size="30" value="">
208 224
 				</div>';
225
+		}
209 226
 
210 227
 		// Do the actual stuff
211 228
 		if ($i == 0 && ($verify_context['show_visual'] || $verify_context['can_recaptcha']))
212 229
 		{
213 230
 			if ($verify_context['show_visual'])
214 231
 			{
215
-				if ($context['use_graphic_library'])
216
-					echo '
232
+				if ($context['use_graphic_library']) {
233
+									echo '
217 234
 				<img src="', $verify_context['image_href'], '" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '">';
218
-				else
219
-					echo '
235
+				} else {
236
+									echo '
220 237
 				<img src="', $verify_context['image_href'], ';letter=1" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_1">
221 238
 				<img src="', $verify_context['image_href'], ';letter=2" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_2">
222 239
 				<img src="', $verify_context['image_href'], ';letter=3" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_3">
223 240
 				<img src="', $verify_context['image_href'], ';letter=4" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_4">
224 241
 				<img src="', $verify_context['image_href'], ';letter=5" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_5">
225 242
 				<img src="', $verify_context['image_href'], ';letter=6" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_6">';
243
+				}
226 244
 
227 245
 				echo '
228 246
 				<div class="smalltext" style="margin: 4px 0 8px 0;">
@@ -240,8 +258,7 @@  discard block
 block discarded – undo
240 258
 				<br>
241 259
 				<script type="text/javascript" src="https://www.google.com/recaptcha/api.js?hl='.$lang.'"></script>';
242 260
 			}
243
-		}
244
-		else
261
+		} else
245 262
 		{
246 263
 			// Where in the question array is this question?
247 264
 			$qIndex = $verify_context['show_visual'] ? $i - 1 : $i;
@@ -253,21 +270,24 @@  discard block
 block discarded – undo
253 270
 				</div>';
254 271
 		}
255 272
 
256
-		if ($display_type != 'single')
257
-			echo '
273
+		if ($display_type != 'single') {
274
+					echo '
258 275
 			</div><!-- #verification_control_[i] -->';
276
+		}
259 277
 
260 278
 		// If we were displaying just one and we did it, break.
261
-		if ($display_type == 'single' && $verify_context['tracking'] == $i)
262
-			break;
279
+		if ($display_type == 'single' && $verify_context['tracking'] == $i) {
280
+					break;
281
+		}
263 282
 	}
264 283
 
265 284
 	// Assume we found something, always.
266 285
 	$verify_context['tracking']++;
267 286
 
268 287
 	// Tell something displaying piecemeal to keep going.
269
-	if ($display_type == 'single')
270
-		return true;
271
-}
288
+	if ($display_type == 'single') {
289
+			return true;
290
+	}
291
+	}
272 292
 
273 293
 ?>
274 294
\ No newline at end of file
Please login to merge, or discard this patch.
Themes/default/Post.template.php 1 patch
Braces   +184 added lines, -131 removed lines patch added patch discarded remove patch
@@ -22,24 +22,26 @@  discard block
 block discarded – undo
22 22
 		<script>';
23 23
 
24 24
 	// When using Go Back due to fatal_error, allow the form to be re-submitted with changes.
25
-	if (isBrowser('is_firefox'))
26
-		echo '
25
+	if (isBrowser('is_firefox')) {
26
+			echo '
27 27
 			window.addEventListener("pageshow", reActivate, false);';
28
+	}
28 29
 
29 30
 	// Start with message icons - and any missing from this theme.
30 31
 	echo '
31 32
 			var icon_urls = {';
32 33
 
33
-	foreach ($context['icons'] as $icon)
34
-		echo '
34
+	foreach ($context['icons'] as $icon) {
35
+			echo '
35 36
 				\'', $icon['value'], '\': \'', $icon['url'], '\'', $icon['is_last'] ? '' : ',';
37
+	}
36 38
 
37 39
 	echo '
38 40
 			};';
39 41
 
40 42
 	// If this is a poll - use some javascript to ensure the user doesn't create a poll with illegal option combinations.
41
-	if ($context['make_poll'])
42
-		echo '
43
+	if ($context['make_poll']) {
44
+			echo '
43 45
 			var pollOptionNum = 0, pollTabIndex;
44 46
 			var pollOptionId = ', $context['last_choice_id'], ';
45 47
 			function addPollOption()
@@ -58,11 +60,13 @@  discard block
 block discarded – undo
58 60
 
59 61
 				setOuterHTML(document.getElementById(\'pollMoreOptions\'), ', JavaScriptEscape('<dt><label for="options-'), ' + pollOptionId + ', JavaScriptEscape('">' . $txt['option'] . ' '), ' + pollOptionNum + ', JavaScriptEscape('</label>:</dt><dd><input type="text" name="options['), ' + pollOptionId + ', JavaScriptEscape(']" id="options-'), ' + pollOptionId + ', JavaScriptEscape('" value="" size="80" maxlength="255" tabindex="'), ' + pollTabIndex + ', JavaScriptEscape('"></dd><p id="pollMoreOptions"></p>'), ');
60 62
 			}';
63
+	}
61 64
 
62 65
 	// If we are making a calendar event we want to ensure we show the current days in a month etc... this is done here.
63
-	if ($context['make_event'])
64
-		echo '
66
+	if ($context['make_event']) {
67
+			echo '
65 68
 			var monthLength = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];';
69
+	}
66 70
 
67 71
 	// End of the javascript, start the form and display the link tree.
68 72
 	echo '
@@ -83,9 +87,10 @@  discard block
 block discarded – undo
83 87
 			</div>
84 88
 			<br>';
85 89
 
86
-	if ($context['make_event'] && (!$context['event']['new'] || !empty($context['current_board'])))
87
-		echo '
90
+	if ($context['make_event'] && (!$context['event']['new'] || !empty($context['current_board']))) {
91
+			echo '
88 92
 			<input type="hidden" name="eventid" value="', $context['event']['id'], '">';
93
+	}
89 94
 
90 95
 	// Start the main table.
91 96
 	echo '
@@ -110,26 +115,29 @@  discard block
 block discarded – undo
110 115
 					</div>';
111 116
 
112 117
 	// If this won't be approved let them know!
113
-	if (!$context['becomes_approved'])
114
-		echo '
118
+	if (!$context['becomes_approved']) {
119
+			echo '
115 120
 					<div class="noticebox">
116 121
 						<em>', $txt['wait_for_approval'], '</em>
117 122
 						<input type="hidden" name="not_approved" value="1">
118 123
 					</div>';
124
+	}
119 125
 
120 126
 	// If it's locked, show a message to warn the replier.
121
-	if (!empty($context['locked']))
122
-	echo '
127
+	if (!empty($context['locked'])) {
128
+		echo '
123 129
 					<div class="errorbox">
124 130
 						', $txt['topic_locked_no_reply'], '
125 131
 					</div>';
132
+	}
126 133
 
127
-	if (!empty($modSettings['drafts_post_enabled']))
128
-		echo '
134
+	if (!empty($modSettings['drafts_post_enabled'])) {
135
+			echo '
129 136
 					<div id="draft_section" class="infobox"', isset($context['draft_saved']) ? '' : ' style="display: none;"', '>',
130 137
 						sprintf($txt['draft_saved'], $scripturl . '?action=profile;u=' . $context['user']['id'] . ';area=showdrafts'), '
131 138
 						', (!empty($modSettings['drafts_keep_days']) ? ' <strong>' . sprintf($txt['draft_save_warning'], $modSettings['drafts_keep_days']) . '</strong>' : ''), '
132 139
 					</div>';
140
+	}
133 141
 
134 142
 	// The post header... important stuff
135 143
 	template_post_header();
@@ -162,9 +170,10 @@  discard block
 block discarded – undo
162 170
 				echo '
163 171
 										<optgroup label="', $category['name'], '">';
164 172
 
165
-				foreach ($category['boards'] as $board)
166
-					echo '
173
+				foreach ($category['boards'] as $board) {
174
+									echo '
167 175
 											<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=&gt;' : '', ' ', $board['name'], '</option>';
176
+				}
168 177
 				echo '
169 178
 										</optgroup>';
170 179
 			}
@@ -200,9 +209,10 @@  discard block
 block discarded – undo
200 209
 									<span class="label">', $txt['calendar_timezone'], '</span>
201 210
 									<select name="tz" id="tz"', !empty($context['event']['allday']) ? ' disabled' : '', '>';
202 211
 
203
-		foreach ($context['all_timezones'] as $tz => $tzname)
204
-			echo '
212
+		foreach ($context['all_timezones'] as $tz => $tzname) {
213
+					echo '
205 214
 										<option', is_numeric($tz) ? ' value="" disabled' : ' value="' . $tz . '"', $tz === $context['event']['tz'] ? ' selected' : '', '>', $tzname, '</option>';
215
+		}
206 216
 
207 217
 		echo '
208 218
 									</select>
@@ -231,14 +241,15 @@  discard block
 block discarded – undo
231 241
 								</dd>';
232 242
 
233 243
 		// Loop through all the choices and print them out.
234
-		foreach ($context['choices'] as $choice)
235
-			echo '
244
+		foreach ($context['choices'] as $choice) {
245
+					echo '
236 246
 								<dt>
237 247
 									<label for="options-', $choice['id'], '">', $txt['option'], ' ', $choice['number'], '</label>:
238 248
 								</dt>
239 249
 								<dd>
240 250
 									<input type="text" name="options[', $choice['id'], ']" id="options-', $choice['id'], '" value="', $choice['label'], '" tabindex="', $context['tabindex']++, '" size="80" maxlength="255">
241 251
 								</dd>';
252
+		}
242 253
 
243 254
 		echo '
244 255
 								<p id="pollMoreOptions"></p>
@@ -268,14 +279,15 @@  discard block
 block discarded – undo
268 279
 									<input type="checkbox" id="poll_change_vote" name="poll_change_vote"', !empty($context['poll']['change_vote']) ? ' checked' : '', '>
269 280
 								</dd>';
270 281
 
271
-		if ($context['poll_options']['guest_vote_enabled'])
272
-			echo '
282
+		if ($context['poll_options']['guest_vote_enabled']) {
283
+					echo '
273 284
 								<dt>
274 285
 									<label for="poll_guest_vote">', $txt['poll_guest_vote'], ':</label>
275 286
 								</dt>
276 287
 								<dd>
277 288
 									<input type="checkbox" id="poll_guest_vote" name="poll_guest_vote"', !empty($context['poll_options']['guest_vote']) ? ' checked' : '', '>
278 289
 								</dd>';
290
+		}
279 291
 
280 292
 		echo '
281 293
 								<dt>
@@ -296,8 +308,8 @@  discard block
 block discarded – undo
296 308
 					', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message');
297 309
 
298 310
 	// If we're editing and displaying edit details, show a box where they can say why
299
-	if (isset($context['editing']) && $modSettings['show_modify'])
300
-		echo '
311
+	if (isset($context['editing']) && $modSettings['show_modify']) {
312
+			echo '
301 313
 					<dl>
302 314
 						<dt class="clear">
303 315
 							<span id="caption_edit_reason">', $txt['reason_for_edit'], ':</span>
@@ -306,20 +318,23 @@  discard block
 block discarded – undo
306 318
 							<input type="text" name="modify_reason"', isset($context['last_modified_reason']) ? ' value="' . $context['last_modified_reason'] . '"' : '', ' tabindex="', $context['tabindex']++, '" size="80" maxlength="80">
307 319
 						</dd>
308 320
 					</dl>';
321
+	}
309 322
 
310 323
 	// If this message has been edited in the past - display when it was.
311
-	if (isset($context['last_modified']))
312
-		echo '
324
+	if (isset($context['last_modified'])) {
325
+			echo '
313 326
 					<div class="padding smalltext">
314 327
 						', $context['last_modified_text'], '
315 328
 					</div>';
329
+	}
316 330
 
317 331
 	// If the admin has enabled the hiding of the additional options - show a link and image for it.
318
-	if (!empty($modSettings['additional_options_collapsable']))
319
-		echo '
332
+	if (!empty($modSettings['additional_options_collapsable'])) {
333
+			echo '
320 334
 					<div id="postAdditionalOptionsHeader">
321 335
 						<strong><a href="#" id="postMoreExpandLink"> ', $context['can_post_attachment'] ? $txt['post_additionalopt_attach'] : $txt['post_additionalopt'], '</a></strong>
322 336
 					</div>';
337
+	}
323 338
 
324 339
 	echo '
325 340
 					<div id="postAdditionalOptions">';
@@ -352,19 +367,21 @@  discard block
 block discarded – undo
352 367
 								', $txt['uncheck_unwatchd_attach'], ':
353 368
 							</dd>';
354 369
 
355
-		foreach ($context['current_attachments'] as $attachment)
356
-			echo '
370
+		foreach ($context['current_attachments'] as $attachment) {
371
+					echo '
357 372
 							<dd class="smalltext">
358 373
 								<label for="attachment_', $attachment['attachID'], '"><input type="checkbox" id="attachment_', $attachment['attachID'], '" name="attach_del[]" value="', $attachment['attachID'], '"', empty($attachment['unchecked']) ? ' checked' : '', '> ', $attachment['name'], (empty($attachment['approved']) ? ' (' . $txt['awaiting_approval'] . ')' : ''),
359 374
 								!empty($modSettings['attachmentPostLimit']) || !empty($modSettings['attachmentSizeLimit']) ? sprintf($txt['attach_kb'], comma_format(round(max($attachment['size'], 1024) / 1024), 0)) : '', '</label>
360 375
 							</dd>';
376
+		}
361 377
 
362 378
 		echo '
363 379
 						</dl>';
364 380
 
365
-		if (!empty($context['files_in_session_warning']))
366
-			echo '
381
+		if (!empty($context['files_in_session_warning'])) {
382
+					echo '
367 383
 						<div class="smalltext">', $context['files_in_session_warning'], '</div>';
384
+		}
368 385
 	}
369 386
 
370 387
 	// Is the user allowed to post any additional ones? If so give them the boxes to do it!
@@ -429,13 +446,14 @@  discard block
 block discarded – undo
429 446
 									<div class="fallback">
430 447
 										<input type="file" multiple="multiple" name="attachment[]" id="attachment1" class="fallback"> (<a href="javascript:void(0);" onclick="cleanFileInput(\'attachment1\');">', $txt['clean_attach'], '</a>)';
431 448
 
432
-		if (!empty($modSettings['attachmentSizeLimit']))
433
-			echo '
449
+		if (!empty($modSettings['attachmentSizeLimit'])) {
450
+					echo '
434 451
 										<input type="hidden" name="MAX_FILE_SIZE" value="' . $modSettings['attachmentSizeLimit'] * 1024 . '">';
452
+		}
435 453
 
436 454
 		// Show more boxes if they aren't approaching that limit.
437
-		if ($context['num_allowed_attachments'] > 1)
438
-			echo '
455
+		if ($context['num_allowed_attachments'] > 1) {
456
+					echo '
439 457
 										<script>
440 458
 											var allowed_attachments = ', $context['num_allowed_attachments'], ';
441 459
 											var current_attachment = 1;
@@ -455,6 +473,7 @@  discard block
 block discarded – undo
455 473
 										<a href="#" onclick="addAttachment(); return false;">(', $txt['more_attachments'], ')</a>
456 474
 									</div><!-- .fallback -->
457 475
 								</div><!-- #attachUpload -->';
476
+		}
458 477
 
459 478
 		echo '
460 479
 							</dd>';
@@ -466,21 +485,25 @@  discard block
 block discarded – undo
466 485
 							<dd class="smalltext">';
467 486
 
468 487
 		// Show some useful information such as allowed extensions, maximum size and amount of attachments allowed.
469
-		if (!empty($modSettings['attachmentCheckExtensions']))
470
-			echo '
488
+		if (!empty($modSettings['attachmentCheckExtensions'])) {
489
+					echo '
471 490
 								', $txt['allowed_types'], ': ', $context['allowed_extensions'], '<br>';
491
+		}
472 492
 
473
-		if (!empty($context['attachment_restrictions']))
474
-			echo '
493
+		if (!empty($context['attachment_restrictions'])) {
494
+					echo '
475 495
 								', $txt['attach_restrictions'], ' ', implode(', ', $context['attachment_restrictions']), '<br>';
496
+		}
476 497
 
477
-		if ($context['num_allowed_attachments'] == 0)
478
-			echo '
498
+		if ($context['num_allowed_attachments'] == 0) {
499
+					echo '
479 500
 								', $txt['attach_limit_nag'], '<br>';
501
+		}
480 502
 
481
-		if (!$context['can_post_attachment_unapproved'])
482
-			echo '
503
+		if (!$context['can_post_attachment_unapproved']) {
504
+					echo '
483 505
 								<span class="alert">', $txt['attachment_requires_approval'], '</span>', '<br>';
506
+		}
484 507
 
485 508
 		echo '
486 509
 							</dd>
@@ -504,24 +527,26 @@  discard block
 block discarded – undo
504 527
 							<dt><strong>', $txt['subject'], '</strong></dt>
505 528
 							<dd><strong>', $txt['draft_saved_on'], '</strong></dd>';
506 529
 
507
-		foreach ($context['drafts'] as $draft)
508
-			echo '
530
+		foreach ($context['drafts'] as $draft) {
531
+					echo '
509 532
 							<dt>', $draft['link'], '</dt>
510 533
 							<dd>', $draft['poster_time'], '</dd>';
534
+		}
511 535
 		echo '
512 536
 						</dl>
513 537
 					</div>';
514 538
 	}
515 539
 
516 540
 	// Is visual verification enabled?
517
-	if ($context['require_verification'])
518
-		echo '
541
+	if ($context['require_verification']) {
542
+			echo '
519 543
 					<div class="post_verification">
520 544
 						<span', !empty($context['post_error']['need_qr_verification']) ? ' class="error"' : '', '>
521 545
 							<strong>', $txt['verification'], ':</strong>
522 546
 						</span>
523 547
 						', template_control_verification($context['visual_verification_id'], 'all'), '
524 548
 					</div>';
549
+	}
525 550
 
526 551
 	// Finally, the submit buttons.
527 552
 	echo '
@@ -530,9 +555,10 @@  discard block
 block discarded – undo
530 555
 						', template_control_richedit_buttons($context['post_box_name']);
531 556
 
532 557
 	// Option to delete an event if user is editing one.
533
-	if ($context['make_event'] && !$context['event']['new'])
534
-		echo '
558
+	if ($context['make_event'] && !$context['event']['new']) {
559
+			echo '
535 560
 						<input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['event_delete_confirm'] ,'" class="button you_sure">';
561
+	}
536 562
 
537 563
 	echo '
538 564
 					</span>
@@ -541,9 +567,10 @@  discard block
 block discarded – undo
541 567
 			<br class="clear">';
542 568
 
543 569
 	// Assuming this isn't a new topic pass across the last message id.
544
-	if (isset($context['topic_last_message']))
545
-		echo '
570
+	if (isset($context['topic_last_message'])) {
571
+			echo '
546 572
 			<input type="hidden" name="last_msg" value="', $context['topic_last_message'], '">';
573
+	}
547 574
 
548 575
 	echo '
549 576
 			<input type="hidden" name="additional_options" id="additional_options" value="', $context['show_additional_options'] ? '1' : '0', '">
@@ -564,13 +591,14 @@  discard block
 block discarded – undo
564 591
 			</h5>
565 592
 			&nbsp;-&nbsp;%PostTime%&nbsp;&#187; <span class="new_posts" id="image_new_%PostID%">' . $txt['new'] . '</span>';
566 593
 
567
-	if ($context['can_quote'])
568
-		$newPostsHTML .= '
594
+	if ($context['can_quote']) {
595
+			$newPostsHTML .= '
569 596
 			<ul class="quickbuttons sf-js-enabled sf-arrows" id="msg_%PostID%_quote" style="touch-action: pan-y;">
570 597
 				<li id="post_modify">
571 598
 					<a href="#postmodify" onclick="return insertQuoteFast(%PostID%);" class="quote_button"><span class="generic_icons quote"></span>' . $txt['quote'] . '</a>
572 599
 				</li>
573 600
 			</ul>';
601
+	}
574 602
 
575 603
 	$newPostsHTML .= '
576 604
 			<br class="clear">
@@ -596,16 +624,17 @@  discard block
 block discarded – undo
596 624
 				sSessionVar: ', JavaScriptEscape($context['session_var']), ',
597 625
 				newPostsTemplate:', JavaScriptEscape($newPostsHTML);
598 626
 
599
-	if (!empty($context['current_board']))
600
-		echo ',
627
+	if (!empty($context['current_board'])) {
628
+			echo ',
601 629
 				iCurrentBoard: ', $context['current_board'], '';
630
+	}
602 631
 
603 632
 	echo '
604 633
 			});';
605 634
 
606 635
 	// Code for showing and hiding additional options.
607
-	if (!empty($modSettings['additional_options_collapsable']))
608
-		echo '
636
+	if (!empty($modSettings['additional_options_collapsable'])) {
637
+			echo '
609 638
 			var oSwapAdditionalOptions = new smc_Toggle({
610 639
 				bToggleEnabled: true,
611 640
 				bCurrentlyCollapsed: ', $context['show_additional_options'] ? 'false' : 'true', ',
@@ -633,10 +662,11 @@  discard block
 block discarded – undo
633 662
 					}
634 663
 				]
635 664
 			});';
665
+	}
636 666
 
637 667
 	// Code for showing and hiding drafts
638
-	if (!empty($context['drafts']))
639
-		echo '
668
+	if (!empty($context['drafts'])) {
669
+			echo '
640 670
 			var oSwapDraftOptions = new smc_Toggle({
641 671
 				bToggleEnabled: true,
642 672
 				bCurrentlyCollapsed: true,
@@ -658,6 +688,7 @@  discard block
 block discarded – undo
658 688
 					}
659 689
 				]
660 690
 			});';
691
+	}
661 692
 
662 693
 	echo '
663 694
 			var oEditorID = "', $context['post_box_name'] ,'";
@@ -678,8 +709,9 @@  discard block
 block discarded – undo
678 709
 		foreach ($context['previous_posts'] as $post)
679 710
 		{
680 711
 			$ignoring = false;
681
-			if (!empty($post['is_ignored']))
682
-				$ignored_posts[] = $ignoring = $post['id'];
712
+			if (!empty($post['is_ignored'])) {
713
+							$ignored_posts[] = $ignoring = $post['id'];
714
+			}
683 715
 
684 716
 			echo '
685 717
 			<div class="windowbg">
@@ -689,22 +721,24 @@  discard block
 block discarded – undo
689 721
 					</h5>
690 722
 					&nbsp;-&nbsp;', $post['time'];
691 723
 
692
-			if ($context['can_quote'])
693
-				echo '
724
+			if ($context['can_quote']) {
725
+							echo '
694 726
 					<ul class="quickbuttons" id="msg_', $post['id'], '_quote">
695 727
 						<li style="display:none;" id="quoteSelected_', $post['id'], '" data-msgid="', $post['id'], '"><a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'] ,'</a></li>
696 728
 						<li id="post_modify"><a href="#postmodify" onclick="return insertQuoteFast(', $post['id'], ');"><span class="generic_icons quote"></span>', $txt['quote'], '</a></li>
697 729
 					</ul>';
730
+			}
698 731
 
699 732
 			echo '
700 733
 					<br class="clear">';
701 734
 
702
-			if ($ignoring)
703
-				echo '
735
+			if ($ignoring) {
736
+							echo '
704 737
 					<div id="msg_', $post['id'], '_ignored_prompt" class="smalltext">
705 738
 						', $txt['ignoring_user'], '
706 739
 						<a href="#" id="msg_', $post['id'], '_ignored_link" style="display: none;">', $txt['show_ignore_user_post'], '</a>
707 740
 					</div>';
741
+			}
708 742
 
709 743
 			echo '
710 744
 					<div class="list_posts smalltext" id="msg_', $post['id'], '_body" data-msgid="', $post['id'], '">', $post['message'], '</div>
@@ -859,10 +893,10 @@  discard block
 block discarded – undo
859 893
 		<div id="temporary_posting_area" style="display: none;"></div>
860 894
 		<script>';
861 895
 
862
-	if ($context['close_window'])
863
-		echo '
896
+	if ($context['close_window']) {
897
+			echo '
864 898
 			window.close();';
865
-	else
899
+	} else
866 900
 	{
867 901
 		// Lucky for us, Internet Explorer has an "innerText" feature which basically converts entities <--> text. Use it if possible ;)
868 902
 		echo '
@@ -916,11 +950,12 @@  discard block
 block discarded – undo
916 950
 				</p>
917 951
 				<ul>';
918 952
 
919
-	foreach ($context['groups'] as $group)
920
-		echo '
953
+	foreach ($context['groups'] as $group) {
954
+			echo '
921 955
 					<li>
922 956
 						<label for="who_', $group['id'], '"><input type="checkbox" name="who[', $group['id'], ']" id="who_', $group['id'], '" value="', $group['id'], '" checked> ', $group['name'], '</label> <em>(', $group['member_count'], ')</em>
923 957
 					</li>';
958
+	}
924 959
 
925 960
 	echo '
926 961
 					<li>
@@ -1027,28 +1062,32 @@  discard block
 block discarded – undo
1027 1062
 	foreach ($context['posting_fields'] as $pfid => $pf)
1028 1063
 	{
1029 1064
 		// We need both a label and an input
1030
-		if (empty($pf['label']) || empty($pf['input']))
1031
-			continue;
1065
+		if (empty($pf['label']) || empty($pf['input'])) {
1066
+					continue;
1067
+		}
1032 1068
 
1033 1069
 		// The labels are pretty simple...
1034 1070
 		echo '
1035 1071
 						<dt class="clear pf_', $pfid, '">';
1036 1072
 
1037 1073
 		// Any leading HTML before the label
1038
-		if (!empty($pf['label']['before']))
1039
-			echo '
1074
+		if (!empty($pf['label']['before'])) {
1075
+					echo '
1040 1076
 							', $pf['label']['before'];
1077
+		}
1041 1078
 
1042
-		if (!empty($pf['label']['html']))
1043
-			echo $pf['label']['html'];
1044
-		else
1045
-			echo '
1079
+		if (!empty($pf['label']['html'])) {
1080
+					echo $pf['label']['html'];
1081
+		} else {
1082
+					echo '
1046 1083
 							<label for="', !empty($pf['input']['attributes']['name']) ? $pf['input']['attributes']['name'] : $pfid, '" id="caption_', $pfid, '"', !empty($pf['label']['class']) ? ' class="' . $pf['label']['class'] . '"' : '', '>', $pf['label']['text'], '</label>';
1084
+		}
1047 1085
 
1048 1086
 		// Any trailing HTML after the label
1049
-		if (!empty($pf['label']['after']))
1050
-			echo '
1087
+		if (!empty($pf['label']['after'])) {
1088
+					echo '
1051 1089
 							', $pf['label']['after'];
1090
+		}
1052 1091
 
1053 1092
 		echo '
1054 1093
 						</dt>';
@@ -1058,9 +1097,10 @@  discard block
 block discarded – undo
1058 1097
 						<dd class="pf_', $pfid, '">';
1059 1098
 
1060 1099
 		// Any leading HTML before the main input
1061
-		if (!empty($pf['input']['before']))
1062
-			echo '
1100
+		if (!empty($pf['input']['before'])) {
1101
+					echo '
1063 1102
 							', $pf['input']['before'];
1103
+		}
1064 1104
 
1065 1105
 		// If there is a literal HTML string already defined, just print it.
1066 1106
 		if (!empty($pf['input']['html']))
@@ -1073,17 +1113,19 @@  discard block
 block discarded – undo
1073 1113
 			echo '
1074 1114
 							<input type="', $pf['input']['type'], '"';
1075 1115
 
1076
-			if (empty($pf['input']['attributes']['name']))
1077
-				echo ' name="', $pfid, '"';
1116
+			if (empty($pf['input']['attributes']['name'])) {
1117
+							echo ' name="', $pfid, '"';
1118
+			}
1078 1119
 
1079 1120
 			if (!empty($pf['input']['attributes']) && is_array($pf['input']['attributes']))
1080 1121
 			{
1081 1122
 				foreach ($pf['input']['attributes'] as $attribute => $value)
1082 1123
 				{
1083
-					if (is_bool($value))
1084
-						echo $value ? ' ' . $attribute : '';
1085
-					else
1086
-						echo ' ', $attribute, '="', $value, '"';
1124
+					if (is_bool($value)) {
1125
+											echo $value ? ' ' . $attribute : '';
1126
+					} else {
1127
+											echo ' ', $attribute, '="', $value, '"';
1128
+					}
1087 1129
 				}
1088 1130
 			}
1089 1131
 
@@ -1095,19 +1137,21 @@  discard block
 block discarded – undo
1095 1137
 			echo '
1096 1138
 							<textarea';
1097 1139
 
1098
-			if (empty($pf['input']['attributes']['name']))
1099
-				echo ' name="', $pfid, '"';
1140
+			if (empty($pf['input']['attributes']['name'])) {
1141
+							echo ' name="', $pfid, '"';
1142
+			}
1100 1143
 
1101 1144
 			if (!empty($pf['input']['attributes']) && is_array($pf['input']['attributes']))
1102 1145
 			{
1103 1146
 				foreach ($pf['input']['attributes'] as $attribute => $value)
1104 1147
 				{
1105
-					if ($attribute === 'value')
1106
-						continue;
1107
-					elseif (is_bool($value))
1108
-						echo $value ? ' ' . $attribute : '';
1109
-					else
1110
-						echo ' ', $attribute, '="', $value, '"';
1148
+					if ($attribute === 'value') {
1149
+											continue;
1150
+					} elseif (is_bool($value)) {
1151
+											echo $value ? ' ' . $attribute : '';
1152
+					} else {
1153
+											echo ' ', $attribute, '="', $value, '"';
1154
+					}
1111 1155
 				}
1112 1156
 			}
1113 1157
 
@@ -1120,17 +1164,19 @@  discard block
 block discarded – undo
1120 1164
 			echo '
1121 1165
 							<select';
1122 1166
 
1123
-			if (empty($pf['input']['attributes']['name']))
1124
-				echo ' name="', $pfid, '"';
1167
+			if (empty($pf['input']['attributes']['name'])) {
1168
+							echo ' name="', $pfid, '"';
1169
+			}
1125 1170
 
1126 1171
 			if (!empty($pf['input']['attributes']) && is_array($pf['input']['attributes']))
1127 1172
 			{
1128 1173
 				foreach ($pf['input']['attributes'] as $attribute => $value)
1129 1174
 				{
1130
-					if (is_bool($value))
1131
-						echo $value ? ' ' . $attribute : '';
1132
-					else
1133
-						echo ' ', $attribute, '="', $value, '"';
1175
+					if (is_bool($value)) {
1176
+											echo $value ? ' ' . $attribute : '';
1177
+					} else {
1178
+											echo ' ', $attribute, '="', $value, '"';
1179
+					}
1134 1180
 				}
1135 1181
 			}
1136 1182
 
@@ -1145,17 +1191,19 @@  discard block
 block discarded – undo
1145 1191
 					echo '
1146 1192
 								<optgroup';
1147 1193
 
1148
-					if (empty($option['attributes']['label']))
1149
-						echo ' label="', $optlabel, '"';
1194
+					if (empty($option['attributes']['label'])) {
1195
+											echo ' label="', $optlabel, '"';
1196
+					}
1150 1197
 
1151 1198
 					if (!empty($option['attributes']) && is_array($option['attributes']))
1152 1199
 					{
1153 1200
 						foreach ($option['attributes'] as $attribute => $value)
1154 1201
 						{
1155
-							if (is_bool($value))
1156
-								echo $value ? ' ' . $attribute : '';
1157
-							else
1158
-								echo ' ', $attribute, '="', $value, '"';
1202
+							if (is_bool($value)) {
1203
+															echo $value ? ' ' . $attribute : '';
1204
+							} else {
1205
+															echo ' ', $attribute, '="', $value, '"';
1206
+							}
1159 1207
 						}
1160 1208
 					}
1161 1209
 
@@ -1168,10 +1216,11 @@  discard block
 block discarded – undo
1168 1216
 
1169 1217
 						foreach ($grouped_option['attributes'] as $attribute => $value)
1170 1218
 						{
1171
-							if (is_bool($value))
1172
-								echo $value ? ' ' . $attribute : '';
1173
-							else
1174
-								echo ' ', $attribute, '="', $value, '"';
1219
+							if (is_bool($value)) {
1220
+															echo $value ? ' ' . $attribute : '';
1221
+							} else {
1222
+															echo ' ', $attribute, '="', $value, '"';
1223
+							}
1175 1224
 						}
1176 1225
 
1177 1226
 						echo '>', $grouped_optlabel, '</option>';
@@ -1189,10 +1238,11 @@  discard block
 block discarded – undo
1189 1238
 
1190 1239
 					foreach ($option['attributes'] as $attribute => $value)
1191 1240
 					{
1192
-						if (is_bool($value))
1193
-							echo $value ? ' ' . $attribute : '';
1194
-						else
1195
-							echo ' ', $attribute, '="', $value, '"';
1241
+						if (is_bool($value)) {
1242
+													echo $value ? ' ' . $attribute : '';
1243
+						} else {
1244
+													echo ' ', $attribute, '="', $value, '"';
1245
+						}
1196 1246
 					}
1197 1247
 
1198 1248
 					echo '>', $optlabel, '</option>';
@@ -1213,12 +1263,13 @@  discard block
 block discarded – undo
1213 1263
 			{
1214 1264
 				foreach ($pf['input']['attributes'] as $attribute => $value)
1215 1265
 				{
1216
-					if ($attribute === 'name')
1217
-						continue;
1218
-					elseif (is_bool($value))
1219
-						echo $value ? ' ' . $attribute : '';
1220
-					else
1221
-						echo ' ', $attribute, '="', $value, '"';
1266
+					if ($attribute === 'name') {
1267
+											continue;
1268
+					} elseif (is_bool($value)) {
1269
+											echo $value ? ' ' . $attribute : '';
1270
+					} else {
1271
+											echo ' ', $attribute, '="', $value, '"';
1272
+					}
1222 1273
 				}
1223 1274
 			}
1224 1275
 
@@ -1231,10 +1282,11 @@  discard block
 block discarded – undo
1231 1282
 
1232 1283
 				foreach ($option['attributes'] as $attribute => $value)
1233 1284
 				{
1234
-					if (is_bool($value))
1235
-						echo $value ? ' ' . $attribute : '';
1236
-					else
1237
-						echo ' ', $attribute, '="', $value, '"';
1285
+					if (is_bool($value)) {
1286
+											echo $value ? ' ' . $attribute : '';
1287
+					} else {
1288
+											echo ' ', $attribute, '="', $value, '"';
1289
+					}
1238 1290
 				}
1239 1291
 
1240 1292
 				echo ' tabindex="', $context['tabindex']++, '">', $optlabel, '</input>';
@@ -1245,9 +1297,10 @@  discard block
 block discarded – undo
1245 1297
 		}
1246 1298
 
1247 1299
 		// Any trailing HTML after the main input
1248
-		if (!empty($pf['input']['after']))
1249
-			echo '
1300
+		if (!empty($pf['input']['after'])) {
1301
+					echo '
1250 1302
 							', $pf['input']['after'];
1303
+		}
1251 1304
 
1252 1305
 		echo '
1253 1306
 						</dd>';
Please login to merge, or discard this patch.
Sources/ManageMembers.php 1 patch
Braces   +165 added lines, -124 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
  * The main entrance point for the Manage Members screen.
@@ -109,12 +110,13 @@  discard block
 block discarded – undo
109 110
 	$context['tabs'][$context['last_tab']]['is_last'] = true;
110 111
 
111 112
 	// Find the active tab.
112
-	if (isset($context['tabs'][$context['current_subaction']]))
113
-		$context['tabs'][$context['current_subaction']]['is_selected'] = true;
114
-	elseif (isset($context['current_subaction']))
115
-		foreach ($context['tabs'] as $id_tab => $tab_data)
113
+	if (isset($context['tabs'][$context['current_subaction']])) {
114
+			$context['tabs'][$context['current_subaction']]['is_selected'] = true;
115
+	} elseif (isset($context['current_subaction'])) {
116
+			foreach ($context['tabs'] as $id_tab => $tab_data)
116 117
 			if (!empty($tab_data['selected_actions']) && in_array($context['current_subaction'], $tab_data['selected_actions']))
117 118
 				$context['tabs'][$id_tab]['is_selected'] = true;
119
+	}
118 120
 
119 121
 	call_helper($subActions[$context['current_subaction']][0]);
120 122
 }
@@ -144,8 +146,9 @@  discard block
 block discarded – undo
144 146
 		foreach ($_POST['delete'] as $key => $value)
145 147
 		{
146 148
 			// Don't delete yourself, idiot.
147
-			if ($value != $user_info['id'])
148
-				$delete[$key] = (int) $value;
149
+			if ($value != $user_info['id']) {
150
+							$delete[$key] = (int) $value;
151
+			}
149 152
 		}
150 153
 
151 154
 		if (!empty($delete))
@@ -181,17 +184,18 @@  discard block
 block discarded – undo
181 184
 		);
182 185
 		while ($row = $smcFunc['db_fetch_assoc']($request))
183 186
 		{
184
-			if ($row['min_posts'] == -1)
185
-				$context['membergroups'][] = array(
187
+			if ($row['min_posts'] == -1) {
188
+							$context['membergroups'][] = array(
186 189
 					'id' => $row['id_group'],
187 190
 					'name' => $row['group_name'],
188 191
 					'can_be_additional' => true
189 192
 				);
190
-			else
191
-				$context['postgroups'][] = array(
193
+			} else {
194
+							$context['postgroups'][] = array(
192 195
 					'id' => $row['id_group'],
193 196
 					'name' => $row['group_name']
194 197
 				);
198
+			}
195 199
 		}
196 200
 		$smcFunc['db_free_result']($request);
197 201
 
@@ -263,14 +267,15 @@  discard block
 block discarded – undo
263 267
 		call_integration_hook('integrate_view_members_params', array(&$params));
264 268
 
265 269
 		$search_params = array();
266
-		if ($context['sub_action'] == 'query' && !empty($_REQUEST['params']) && empty($_POST['types']))
267
-			$search_params = $smcFunc['json_decode'](base64_decode($_REQUEST['params']), true);
268
-		elseif (!empty($_POST))
270
+		if ($context['sub_action'] == 'query' && !empty($_REQUEST['params']) && empty($_POST['types'])) {
271
+					$search_params = $smcFunc['json_decode'](base64_decode($_REQUEST['params']), true);
272
+		} elseif (!empty($_POST))
269 273
 		{
270 274
 			$search_params['types'] = $_POST['types'];
271
-			foreach ($params as $param_name => $param_info)
272
-				if (isset($_POST[$param_name]))
275
+			foreach ($params as $param_name => $param_info) {
276
+							if (isset($_POST[$param_name]))
273 277
 					$search_params[$param_name] = $_POST[$param_name];
278
+			}
274 279
 		}
275 280
 
276 281
 		$search_url_params = isset($search_params) ? base64_encode($smcFunc['json_encode']($search_params)) : null;
@@ -283,34 +288,38 @@  discard block
 block discarded – undo
283 288
 		foreach ($params as $param_name => $param_info)
284 289
 		{
285 290
 			// Not filled in?
286
-			if (!isset($search_params[$param_name]) || $search_params[$param_name] === '')
287
-				continue;
291
+			if (!isset($search_params[$param_name]) || $search_params[$param_name] === '') {
292
+							continue;
293
+			}
288 294
 
289 295
 			// Make sure numeric values are really numeric.
290
-			if (in_array($param_info['type'], array('int', 'age')))
291
-				$search_params[$param_name] = (int) $search_params[$param_name];
296
+			if (in_array($param_info['type'], array('int', 'age'))) {
297
+							$search_params[$param_name] = (int) $search_params[$param_name];
298
+			}
292 299
 			// Date values have to match the specified format.
293 300
 			elseif ($param_info['type'] == 'date')
294 301
 			{
295 302
 				// Check if this date format is valid.
296
-				if (preg_match('/^\d{4}-\d{1,2}-\d{1,2}$/', $search_params[$param_name]) == 0)
297
-					continue;
303
+				if (preg_match('/^\d{4}-\d{1,2}-\d{1,2}$/', $search_params[$param_name]) == 0) {
304
+									continue;
305
+				}
298 306
 
299 307
 				$search_params[$param_name] = strtotime($search_params[$param_name]);
300
-			}
301
-			elseif ($param_info['type'] == 'inet')
308
+			} elseif ($param_info['type'] == 'inet')
302 309
 			{
303 310
 				$search_params[$param_name] = ip2range($search_params[$param_name]);
304
-				if (empty($search_params[$param_name]))
305
-					continue;
311
+				if (empty($search_params[$param_name])) {
312
+									continue;
313
+				}
306 314
 			}
307 315
 
308 316
 			// Those values that are in some kind of range (<, <=, =, >=, >).
309 317
 			if (!empty($param_info['range']))
310 318
 			{
311 319
 				// Default to '=', just in case...
312
-				if (empty($range_trans[$search_params['types'][$param_name]]))
313
-					$search_params['types'][$param_name] = '=';
320
+				if (empty($range_trans[$search_params['types'][$param_name]])) {
321
+									$search_params['types'][$param_name] = '=';
322
+				}
314 323
 
315 324
 				// Handle special case 'age'.
316 325
 				if ($param_info['type'] == 'age')
@@ -338,16 +347,17 @@  discard block
 block discarded – undo
338 347
 				elseif ($param_info['type'] == 'date' && $search_params['types'][$param_name] == '=')
339 348
 				{
340 349
 					$query_parts[] = $param_info['db_fields'][0] . ' > ' . $search_params[$param_name] . ' AND ' . $param_info['db_fields'][0] . ' < ' . ($search_params[$param_name] + 86400);
350
+				} else {
351
+									$query_parts[] = $param_info['db_fields'][0] . ' ' . $range_trans[$search_params['types'][$param_name]] . ' ' . $search_params[$param_name];
341 352
 				}
342
-				else
343
-					$query_parts[] = $param_info['db_fields'][0] . ' ' . $range_trans[$search_params['types'][$param_name]] . ' ' . $search_params[$param_name];
344 353
 			}
345 354
 			// Checkboxes.
346 355
 			elseif ($param_info['type'] == 'checkbox')
347 356
 			{
348 357
 				// Each checkbox or no checkbox at all is checked -> ignore.
349
-				if (!is_array($search_params[$param_name]) || count($search_params[$param_name]) == 0 || count($search_params[$param_name]) == count($param_info['values']))
350
-					continue;
358
+				if (!is_array($search_params[$param_name]) || count($search_params[$param_name]) == 0 || count($search_params[$param_name]) == count($param_info['values'])) {
359
+									continue;
360
+				}
351 361
 
352 362
 				$query_parts[] = ($param_info['db_fields'][0]) . ' IN ({array_string:' . $param_name . '_check})';
353 363
 				$where_params[$param_name . '_check'] = $search_params[$param_name];
@@ -359,24 +369,23 @@  discard block
 block discarded – undo
359 369
 				{
360 370
 					$query_parts[] = '(' . $param_info['db_fields'][0] . ' = {inet:' . $param_name . '})';
361 371
 					$where_params[$param_name] = $search_params[$param_name][0];
362
-				}
363
-				elseif (count($search_params[$param_name]) === 2)
372
+				} elseif (count($search_params[$param_name]) === 2)
364 373
 				{
365 374
 					$query_parts[] = '(' . $param_info['db_fields'][0] . ' <= {inet:' . $param_name . '_high} and ' . $param_info['db_fields'][0] . ' >= {inet:' . $param_name . '_low})';
366 375
 					$where_params[$param_name.'_low'] = $search_params[$param_name]['low'];
367 376
 					$where_params[$param_name.'_high'] = $search_params[$param_name]['high'];
368 377
 				}
369 378
 				
370
-			}
371
-			elseif ($param_info['type'] != 'groups')
379
+			} elseif ($param_info['type'] != 'groups')
372 380
 			{
373 381
 				// Replace the wildcard characters ('*' and '?') into MySQL ones.
374 382
 				$parameter = strtolower(strtr($smcFunc['htmlspecialchars']($search_params[$param_name], ENT_QUOTES), array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_')));
375 383
 
376
-				if ($smcFunc['db_case_sensitive'])
377
-					$query_parts[] = '(LOWER(' . implode(') LIKE {string:' . $param_name . '_normal} OR LOWER(', $param_info['db_fields']) . ') LIKE {string:' . $param_name . '_normal})';
378
-				else
379
-					$query_parts[] = '(' . implode(' LIKE {string:' . $param_name . '_normal} OR ', $param_info['db_fields']) . ' LIKE {string:' . $param_name . '_normal})';
384
+				if ($smcFunc['db_case_sensitive']) {
385
+									$query_parts[] = '(LOWER(' . implode(') LIKE {string:' . $param_name . '_normal} OR LOWER(', $param_info['db_fields']) . ') LIKE {string:' . $param_name . '_normal})';
386
+				} else {
387
+									$query_parts[] = '(' . implode(' LIKE {string:' . $param_name . '_normal} OR ', $param_info['db_fields']) . ' LIKE {string:' . $param_name . '_normal})';
388
+				}
380 389
 				$where_params[$param_name . '_normal'] = '%' . $parameter . '%';
381 390
 			}
382 391
 		}
@@ -392,16 +401,18 @@  discard block
 block discarded – undo
392 401
 		}
393 402
 
394 403
 		// Additional membergroups (these are only relevant if not all primary groups where selected!).
395
-		if (!empty($search_params['membergroups'][2]) && (empty($search_params['membergroups'][1]) || count($context['membergroups']) != count($search_params['membergroups'][1])))
396
-			foreach ($search_params['membergroups'][2] as $mg)
404
+		if (!empty($search_params['membergroups'][2]) && (empty($search_params['membergroups'][1]) || count($context['membergroups']) != count($search_params['membergroups'][1]))) {
405
+					foreach ($search_params['membergroups'][2] as $mg)
397 406
 			{
398 407
 				$mg_query_parts[] = 'FIND_IN_SET({int:add_group_' . $mg . '}, mem.additional_groups) != 0';
408
+		}
399 409
 				$where_params['add_group_' . $mg] = $mg;
400 410
 			}
401 411
 
402 412
 		// Combine the one or two membergroup parts into one query part linked with an OR.
403
-		if (!empty($mg_query_parts))
404
-			$query_parts[] = '(' . implode(' OR ', $mg_query_parts) . ')';
413
+		if (!empty($mg_query_parts)) {
414
+					$query_parts[] = '(' . implode(' OR ', $mg_query_parts) . ')';
415
+		}
405 416
 
406 417
 		// Get all selected post count related membergroups.
407 418
 		if (!empty($search_params['postgroups']) && count($search_params['postgroups']) != count($context['postgroups']))
@@ -413,9 +424,9 @@  discard block
 block discarded – undo
413 424
 		// Construct the where part of the query.
414 425
 		$where = empty($query_parts) ? '1=1' : implode('
415 426
 			AND ', $query_parts);
427
+	} else {
428
+			$search_url_params = null;
416 429
 	}
417
-	else
418
-		$search_url_params = null;
419 430
 
420 431
 	// Construct the additional URL part with the query info in it.
421 432
 	$context['params_url'] = $context['sub_action'] == 'query' ? ';sa=query;params=' . $search_url_params : '';
@@ -538,28 +549,32 @@  discard block
 block discarded – undo
538 549
 					'function' => function($rowData) use ($txt)
539 550
 					{
540 551
 						// Calculate number of days since last online.
541
-						if (empty($rowData['last_login']))
542
-							$difference = $txt['never'];
543
-						else
552
+						if (empty($rowData['last_login'])) {
553
+													$difference = $txt['never'];
554
+						} else
544 555
 						{
545 556
 							$num_days_difference = jeffsdatediff($rowData['last_login']);
546 557
 
547 558
 							// Today.
548
-							if (empty($num_days_difference))
549
-								$difference = $txt['viewmembers_today'];
559
+							if (empty($num_days_difference)) {
560
+															$difference = $txt['viewmembers_today'];
561
+							}
550 562
 
551 563
 							// Yesterday.
552
-							elseif ($num_days_difference == 1)
553
-								$difference = sprintf('1 %1$s', $txt['viewmembers_day_ago']);
564
+							elseif ($num_days_difference == 1) {
565
+															$difference = sprintf('1 %1$s', $txt['viewmembers_day_ago']);
566
+							}
554 567
 
555 568
 							// X days ago.
556
-							else
557
-								$difference = sprintf('%1$d %2$s', $num_days_difference, $txt['viewmembers_days_ago']);
569
+							else {
570
+															$difference = sprintf('%1$d %2$s', $num_days_difference, $txt['viewmembers_days_ago']);
571
+							}
558 572
 						}
559 573
 
560 574
 						// Show it in italics if they're not activated...
561
-						if ($rowData['is_activated'] % 10 != 1)
562
-							$difference = sprintf('<em title="%1$s">%2$s</em>', $txt['not_activated'], $difference);
575
+						if ($rowData['is_activated'] % 10 != 1) {
576
+													$difference = sprintf('<em title="%1$s">%2$s</em>', $txt['not_activated'], $difference);
577
+						}
563 578
 
564 579
 						return $difference;
565 580
 					},
@@ -611,8 +626,9 @@  discard block
 block discarded – undo
611 626
 	);
612 627
 
613 628
 	// Without enough permissions, don't show 'delete members' checkboxes.
614
-	if (!allowedTo('profile_remove_any'))
615
-		unset($listOptions['cols']['check'], $listOptions['form'], $listOptions['additional_rows']);
629
+	if (!allowedTo('profile_remove_any')) {
630
+			unset($listOptions['cols']['check'], $listOptions['form'], $listOptions['additional_rows']);
631
+	}
616 632
 
617 633
 	require_once($sourcedir . '/Subs-List.php');
618 634
 	createList($listOptions);
@@ -655,17 +671,18 @@  discard block
 block discarded – undo
655 671
 	);
656 672
 	while ($row = $smcFunc['db_fetch_assoc']($request))
657 673
 	{
658
-		if ($row['min_posts'] == -1)
659
-			$context['membergroups'][] = array(
674
+		if ($row['min_posts'] == -1) {
675
+					$context['membergroups'][] = array(
660 676
 				'id' => $row['id_group'],
661 677
 				'name' => $row['group_name'],
662 678
 				'can_be_additional' => true
663 679
 			);
664
-		else
665
-			$context['postgroups'][] = array(
680
+		} else {
681
+					$context['postgroups'][] = array(
666 682
 				'id' => $row['id_group'],
667 683
 				'name' => $row['group_name']
668 684
 			);
685
+		}
669 686
 	}
670 687
 	$smcFunc['db_free_result']($request);
671 688
 
@@ -692,8 +709,9 @@  discard block
 block discarded – undo
692 709
 	$context['page_title'] = $txt['admin_members'];
693 710
 	$context['sub_template'] = 'admin_browse';
694 711
 	$context['browse_type'] = isset($_REQUEST['type']) ? $_REQUEST['type'] : (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1 ? 'activate' : 'approve');
695
-	if (isset($context['tabs'][$context['browse_type']]))
696
-		$context['tabs'][$context['browse_type']]['is_selected'] = true;
712
+	if (isset($context['tabs'][$context['browse_type']])) {
713
+			$context['tabs'][$context['browse_type']]['is_selected'] = true;
714
+	}
697 715
 
698 716
 	// Allowed filters are those we can have, in theory.
699 717
 	$context['allowed_filters'] = $context['browse_type'] == 'approve' ? array(3, 4, 5) : array(0, 2);
@@ -704,18 +722,20 @@  discard block
 block discarded – undo
704 722
 	foreach ($context['activation_numbers'] as $type => $amount)
705 723
 	{
706 724
 		// We have some of these...
707
-		if (in_array($type, $context['allowed_filters']) && $amount > 0)
708
-			$context['available_filters'][] = array(
725
+		if (in_array($type, $context['allowed_filters']) && $amount > 0) {
726
+					$context['available_filters'][] = array(
709 727
 				'type' => $type,
710 728
 				'amount' => $amount,
711 729
 				'desc' => isset($txt['admin_browse_filter_type_' . $type]) ? $txt['admin_browse_filter_type_' . $type] : '?',
712 730
 				'selected' => $type == $context['current_filter']
713 731
 			);
732
+		}
714 733
 	}
715 734
 
716 735
 	// If the filter was not sent, set it to whatever has people in it!
717
-	if ($context['current_filter'] == -1 && !empty($context['available_filters'][0]['amount']))
718
-		$context['current_filter'] = $context['available_filters'][0]['type'];
736
+	if ($context['current_filter'] == -1 && !empty($context['available_filters'][0]['amount'])) {
737
+			$context['current_filter'] = $context['available_filters'][0]['type'];
738
+	}
719 739
 
720 740
 	// This little variable is used to determine if we should flag where we are looking.
721 741
 	$context['show_filter'] = ($context['current_filter'] != 0 && $context['current_filter'] != 3) || count($context['available_filters']) > 1;
@@ -730,44 +750,47 @@  discard block
 block discarded – undo
730 750
 	);
731 751
 
732 752
 	// Are we showing duplicate information?
733
-	if (isset($_GET['showdupes']))
734
-		$_SESSION['showdupes'] = (int) $_GET['showdupes'];
753
+	if (isset($_GET['showdupes'])) {
754
+			$_SESSION['showdupes'] = (int) $_GET['showdupes'];
755
+	}
735 756
 	$context['show_duplicates'] = !empty($_SESSION['showdupes']);
736 757
 
737 758
 	// Determine which actions we should allow on this page.
738 759
 	if ($context['browse_type'] == 'approve')
739 760
 	{
740 761
 		// If we are approving deleted accounts we have a slightly different list... actually a mirror ;)
741
-		if ($context['current_filter'] == 4)
742
-			$context['allowed_actions'] = array(
762
+		if ($context['current_filter'] == 4) {
763
+					$context['allowed_actions'] = array(
743 764
 				'reject' => $txt['admin_browse_w_approve_deletion'],
744 765
 				'ok' => $txt['admin_browse_w_reject'],
745 766
 			);
746
-		else
747
-			$context['allowed_actions'] = array(
767
+		} else {
768
+					$context['allowed_actions'] = array(
748 769
 				'ok' => $txt['admin_browse_w_approve'],
749 770
 				'okemail' => $txt['admin_browse_w_approve'] . ' ' . $txt['admin_browse_w_email'],
750 771
 				'require_activation' => $txt['admin_browse_w_approve_require_activate'],
751 772
 				'reject' => $txt['admin_browse_w_reject'],
752 773
 				'rejectemail' => $txt['admin_browse_w_reject'] . ' ' . $txt['admin_browse_w_email'],
753 774
 			);
754
-	}
755
-	elseif ($context['browse_type'] == 'activate')
756
-		$context['allowed_actions'] = array(
775
+		}
776
+	} elseif ($context['browse_type'] == 'activate') {
777
+			$context['allowed_actions'] = array(
757 778
 			'ok' => $txt['admin_browse_w_activate'],
758 779
 			'okemail' => $txt['admin_browse_w_activate'] . ' ' . $txt['admin_browse_w_email'],
759 780
 			'delete' => $txt['admin_browse_w_delete'],
760 781
 			'deleteemail' => $txt['admin_browse_w_delete'] . ' ' . $txt['admin_browse_w_email'],
761 782
 			'remind' => $txt['admin_browse_w_remind'] . ' ' . $txt['admin_browse_w_email'],
762 783
 		);
784
+	}
763 785
 
764 786
 	// Create an option list for actions allowed to be done with selected members.
765 787
 	$allowed_actions = '
766 788
 			<option selected value="">' . $txt['admin_browse_with_selected'] . ':</option>
767 789
 			<option value="" disabled>-----------------------------</option>';
768
-	foreach ($context['allowed_actions'] as $key => $desc)
769
-		$allowed_actions .= '
790
+	foreach ($context['allowed_actions'] as $key => $desc) {
791
+			$allowed_actions .= '
770 792
 			<option value="' . $key . '">' . $desc . '</option>';
793
+	}
771 794
 
772 795
 	// Setup the Javascript function for selecting an action for the list.
773 796
 	$javascript = '
@@ -779,15 +802,16 @@  discard block
 block discarded – undo
779 802
 			var message = "";';
780 803
 
781 804
 	// We have special messages for approving deletion of accounts - it's surprisingly logical - honest.
782
-	if ($context['current_filter'] == 4)
783
-		$javascript .= '
805
+	if ($context['current_filter'] == 4) {
806
+			$javascript .= '
784 807
 			if (document.forms.postForm.todo.value.indexOf("reject") != -1)
785 808
 				message = "' . $txt['admin_browse_w_delete'] . '";
786 809
 			else
787 810
 				message = "' . $txt['admin_browse_w_reject'] . '";';
811
+	}
788 812
 	// Otherwise a nice standard message.
789
-	else
790
-		$javascript .= '
813
+	else {
814
+			$javascript .= '
791 815
 			if (document.forms.postForm.todo.value.indexOf("delete") != -1)
792 816
 				message = "' . $txt['admin_browse_w_delete'] . '";
793 817
 			else if (document.forms.postForm.todo.value.indexOf("reject") != -1)
@@ -796,6 +820,7 @@  discard block
 block discarded – undo
796 820
 				message = "' . $txt['admin_browse_w_remind'] . '";
797 821
 			else
798 822
 				message = "' . ($context['browse_type'] == 'approve' ? $txt['admin_browse_w_approve'] : $txt['admin_browse_w_activate']) . '";';
823
+	}
799 824
 	$javascript .= '
800 825
 			if (confirm(message + " ' . $txt['admin_browse_warn'] . '"))
801 826
 				document.forms.postForm.submit();
@@ -928,10 +953,11 @@  discard block
 block discarded – undo
928 953
 						$member_links = array();
929 954
 						foreach ($rowData['duplicate_members'] as $member)
930 955
 						{
931
-							if ($member['id'])
932
-								$member_links[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '" ' . (!empty($member['is_banned']) ? 'class="red"' : '') . '>' . $member['name'] . '</a>';
933
-							else
934
-								$member_links[] = $member['name'] . ' (' . $txt['guest'] . ')';
956
+							if ($member['id']) {
957
+															$member_links[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '" ' . (!empty($member['is_banned']) ? 'class="red"' : '') . '>' . $member['name'] . '</a>';
958
+							} else {
959
+															$member_links[] = $member['name'] . ' (' . $txt['guest'] . ')';
960
+							}
935 961
 						}
936 962
 						return implode(', ', $member_links);
937 963
 					},
@@ -980,14 +1006,16 @@  discard block
 block discarded – undo
980 1006
 	);
981 1007
 
982 1008
 	// Pick what column to actually include if we're showing duplicates.
983
-	if ($context['show_duplicates'])
984
-		unset($listOptions['columns']['email']);
985
-	else
986
-		unset($listOptions['columns']['duplicates']);
1009
+	if ($context['show_duplicates']) {
1010
+			unset($listOptions['columns']['email']);
1011
+	} else {
1012
+			unset($listOptions['columns']['duplicates']);
1013
+	}
987 1014
 
988 1015
 	// Only show hostname on duplicates as it takes a lot of time.
989
-	if (!$context['show_duplicates'] || !empty($modSettings['disableHostnameLookup']))
990
-		unset($listOptions['columns']['hostname']);
1016
+	if (!$context['show_duplicates'] || !empty($modSettings['disableHostnameLookup'])) {
1017
+			unset($listOptions['columns']['hostname']);
1018
+	}
991 1019
 
992 1020
 	// Is there any need to show filters?
993 1021
 	if (isset($context['available_filters']) && count($context['available_filters']) > 1)
@@ -995,9 +1023,10 @@  discard block
 block discarded – undo
995 1023
 		$filterOptions = '
996 1024
 			<strong>' . $txt['admin_browse_filter_by'] . ':</strong>
997 1025
 			<select name="filter" onchange="this.form.submit();">';
998
-		foreach ($context['available_filters'] as $filter)
999
-			$filterOptions .= '
1026
+		foreach ($context['available_filters'] as $filter) {
1027
+					$filterOptions .= '
1000 1028
 				<option value="' . $filter['type'] . '"' . ($filter['selected'] ? ' selected' : '') . '>' . $filter['desc'] . ' - ' . $filter['amount'] . ' ' . ($filter['amount'] == 1 ? $txt['user'] : $txt['users']) . '</option>';
1029
+		}
1001 1030
 		$filterOptions .= '
1002 1031
 			</select>
1003 1032
 			<noscript><input type="submit" value="' . $txt['go'] . '" name="filter" class="button"></noscript>';
@@ -1009,12 +1038,13 @@  discard block
 block discarded – undo
1009 1038
 	}
1010 1039
 
1011 1040
 	// What about if we only have one filter, but it's not the "standard" filter - show them what they are looking at.
1012
-	if (!empty($context['show_filter']) && !empty($context['available_filters']))
1013
-		$listOptions['additional_rows'][] = array(
1041
+	if (!empty($context['show_filter']) && !empty($context['available_filters'])) {
1042
+			$listOptions['additional_rows'][] = array(
1014 1043
 			'position' => 'above_column_headers',
1015 1044
 			'value' => '<strong>' . $txt['admin_browse_filter_show'] . ':</strong> ' . $context['available_filters'][0]['desc'],
1016 1045
 			'class' => 'smalltext floatright',
1017 1046
 		);
1047
+	}
1018 1048
 
1019 1049
 	// Now that we have all the options, create the list.
1020 1050
 	require_once($sourcedir . '/Subs-List.php');
@@ -1044,12 +1074,14 @@  discard block
 block discarded – undo
1044 1074
 	$current_filter = (int) $_REQUEST['orig_filter'];
1045 1075
 
1046 1076
 	// If we are applying a filter do just that - then redirect.
1047
-	if (isset($_REQUEST['filter']) && $_REQUEST['filter'] != $_REQUEST['orig_filter'])
1048
-		redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $_REQUEST['filter'] . ';start=' . $_REQUEST['start']);
1077
+	if (isset($_REQUEST['filter']) && $_REQUEST['filter'] != $_REQUEST['orig_filter']) {
1078
+			redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $_REQUEST['filter'] . ';start=' . $_REQUEST['start']);
1079
+	}
1049 1080
 
1050 1081
 	// Nothing to do?
1051
-	if (!isset($_POST['todoAction']) && !isset($_POST['time_passed']))
1052
-		redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']);
1082
+	if (!isset($_POST['todoAction']) && !isset($_POST['time_passed'])) {
1083
+			redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']);
1084
+	}
1053 1085
 
1054 1086
 	// Are we dealing with members who have been waiting for > set amount of time?
1055 1087
 	if (isset($_POST['time_passed']))
@@ -1062,8 +1094,9 @@  discard block
 block discarded – undo
1062 1094
 	else
1063 1095
 	{
1064 1096
 		$members = array();
1065
-		foreach ($_POST['todoAction'] as $id)
1066
-			$members[] = (int) $id;
1097
+		foreach ($_POST['todoAction'] as $id) {
1098
+					$members[] = (int) $id;
1099
+		}
1067 1100
 		$condition = '
1068 1101
 			AND id_member IN ({array_int:members})';
1069 1102
 	}
@@ -1084,8 +1117,9 @@  discard block
 block discarded – undo
1084 1117
 	$member_count = $smcFunc['db_num_rows']($request);
1085 1118
 
1086 1119
 	// If no results then just return!
1087
-	if ($member_count == 0)
1088
-		redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']);
1120
+	if ($member_count == 0) {
1121
+			redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']);
1122
+	}
1089 1123
 
1090 1124
 	$member_info = array();
1091 1125
 	$members = array();
@@ -1124,8 +1158,9 @@  discard block
 block discarded – undo
1124 1158
 		// Do we have to let the integration code know about the activations?
1125 1159
 		if (!empty($modSettings['integrate_activate']))
1126 1160
 		{
1127
-			foreach ($member_info as $member)
1128
-				call_integration_hook('integrate_activate', array($member['username']));
1161
+			foreach ($member_info as $member) {
1162
+							call_integration_hook('integrate_activate', array($member['username']));
1163
+			}
1129 1164
 		}
1130 1165
 
1131 1166
 		// Check for email.
@@ -1255,20 +1290,23 @@  discard block
 block discarded – undo
1255 1290
 		$log_action = $_POST['todo'] == 'remind' ? 'remind_member' : 'approve_member';
1256 1291
 
1257 1292
 		require_once($sourcedir . '/Logging.php');
1258
-		foreach ($member_info as $member)
1259
-			logAction($log_action, array('member' => $member['id']), 'admin');
1293
+		foreach ($member_info as $member) {
1294
+					logAction($log_action, array('member' => $member['id']), 'admin');
1295
+		}
1260 1296
 	}
1261 1297
 
1262 1298
 	// Although updateStats *may* catch this, best to do it manually just in case (Doesn't always sort out unapprovedMembers).
1263
-	if (in_array($current_filter, array(3, 4, 5)))
1264
-		updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > $member_count ? $modSettings['unapprovedMembers'] - $member_count : 0)));
1299
+	if (in_array($current_filter, array(3, 4, 5))) {
1300
+			updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > $member_count ? $modSettings['unapprovedMembers'] - $member_count : 0)));
1301
+	}
1265 1302
 
1266 1303
 	// Update the member's stats. (but, we know the member didn't change their name.)
1267 1304
 	updateStats('member', false);
1268 1305
 
1269 1306
 	// If they haven't been deleted, update the post group statistics on them...
1270
-	if (!in_array($_POST['todo'], array('delete', 'deleteemail', 'reject', 'rejectemail', 'remind')))
1271
-		updateStats('postgroups', $members);
1307
+	if (!in_array($_POST['todo'], array('delete', 'deleteemail', 'reject', 'rejectemail', 'remind'))) {
1308
+			updateStats('postgroups', $members);
1309
+	}
1272 1310
 
1273 1311
 	redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']);
1274 1312
 }
@@ -1293,10 +1331,11 @@  discard block
 block discarded – undo
1293 1331
 	$dis = time() - $old;
1294 1332
 
1295 1333
 	// Before midnight?
1296
-	if ($dis < $sinceMidnight)
1297
-		return 0;
1298
-	else
1299
-		$dis -= $sinceMidnight;
1334
+	if ($dis < $sinceMidnight) {
1335
+			return 0;
1336
+	} else {
1337
+			$dis -= $sinceMidnight;
1338
+	}
1300 1339
 
1301 1340
 	// Divide out the seconds in a day to get the number of days.
1302 1341
 	return ceil($dis / (24 * 60 * 60));
@@ -1323,16 +1362,18 @@  discard block
 block discarded – undo
1323 1362
 	$context['activation_numbers'] = array();
1324 1363
 	$context['awaiting_activation'] = 0;
1325 1364
 	$context['awaiting_approval'] = 0;
1326
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1327
-		$context['activation_numbers'][$row['is_activated']] = $row['total_members'];
1365
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1366
+			$context['activation_numbers'][$row['is_activated']] = $row['total_members'];
1367
+	}
1328 1368
 	$smcFunc['db_free_result']($request);
1329 1369
 
1330 1370
 	foreach ($context['activation_numbers'] as $activation_type => $total_members)
1331 1371
 	{
1332
-		if (in_array($activation_type, array(0, 2)))
1333
-			$context['awaiting_activation'] += $total_members;
1334
-		elseif (in_array($activation_type, array(3, 4, 5)))
1335
-			$context['awaiting_approval'] += $total_members;
1372
+		if (in_array($activation_type, array(0, 2))) {
1373
+					$context['awaiting_activation'] += $total_members;
1374
+		} elseif (in_array($activation_type, array(3, 4, 5))) {
1375
+					$context['awaiting_approval'] += $total_members;
1376
+		}
1336 1377
 	}
1337 1378
 
1338 1379
 }
Please login to merge, or discard this patch.