Completed
Push — release-2.1 ( 08aa48...ab4516 )
by Mathias
06:51
created
Sources/Subs-Notify.php 1 patch
Braces   +17 added lines, -11 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
  * @version 2.1 Beta 3
12 12
  */
13 13
 
14
-if (!defined('SMF'))
14
+if (!defined('SMF')) {
15 15
 	die('No direct access...');
16
+}
16 17
 
17 18
 /**
18 19
  * Fetches the list of preferences (or a single/subset of preferences) for
@@ -30,8 +31,9 @@  discard block
 block discarded – undo
30 31
 	// We want this as an array whether it is or not.
31 32
 	$members = is_array($members) ? $members : (array) $members;
32 33
 
33
-	if (!empty($prefs))
34
-		$prefs = is_array($prefs) ? $prefs : (array) $prefs;
34
+	if (!empty($prefs)) {
35
+			$prefs = is_array($prefs) ? $prefs : (array) $prefs;
36
+	}
35 37
 
36 38
 	$result = array();
37 39
 
@@ -56,9 +58,10 @@  discard block
 block discarded – undo
56 58
 	// We may want to keep the default values separate from a given user's. Or we might not.
57 59
 	if ($process_default && isset($result[0]))
58 60
 	{
59
-		foreach ($members as $member)
60
-			if (!isset($result[$member]))
61
+		foreach ($members as $member) {
62
+					if (!isset($result[$member]))
61 63
 				$result[$member] = $result[0];
64
+		}
62 65
 
63 66
 		unset ($result[0]);
64 67
 	}
@@ -76,12 +79,14 @@  discard block
 block discarded – undo
76 79
 {
77 80
 	global $smcFunc;
78 81
 
79
-	if (empty($prefs) || !is_int($memID))
80
-		return;
82
+	if (empty($prefs) || !is_int($memID)) {
83
+			return;
84
+	}
81 85
 
82 86
 	$update_rows = array();
83
-	foreach ($prefs as $k => $v)
84
-		$update_rows[] = array($memID, $k, $v);
87
+	foreach ($prefs as $k => $v) {
88
+			$update_rows[] = array($memID, $k, $v);
89
+	}
85 90
 
86 91
 	$smcFunc['db_insert']('replace',
87 92
 		'{db_prefix}user_alerts_prefs',
@@ -101,8 +106,9 @@  discard block
 block discarded – undo
101 106
 {
102 107
 	global $smcFunc;
103 108
 
104
-	if (empty($prefs) || empty($memID))
105
-		return;
109
+	if (empty($prefs) || empty($memID)) {
110
+			return;
111
+	}
106 112
 
107 113
 	$smcFunc['db_query']('', '
108 114
 		DELETE FROM {db_prefix}user_alerts_prefs
Please login to merge, or discard this patch.
Sources/ManageMaintenance.php 1 patch
Braces   +266 added lines, -197 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
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
  * Main dispatcher, the maintenance access point.
@@ -96,14 +97,16 @@  discard block
 block discarded – undo
96 97
 	call_integration_hook('integrate_manage_maintenance', array(&$subActions));
97 98
 
98 99
 	// Yep, sub-action time!
99
-	if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]))
100
-		$subAction = $_REQUEST['sa'];
101
-	else
102
-		$subAction = 'routine';
100
+	if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) {
101
+			$subAction = $_REQUEST['sa'];
102
+	} else {
103
+			$subAction = 'routine';
104
+	}
103 105
 
104 106
 	// Doing something special?
105
-	if (isset($_REQUEST['activity']) && isset($subActions[$subAction]['activities'][$_REQUEST['activity']]))
106
-		$activity = $_REQUEST['activity'];
107
+	if (isset($_REQUEST['activity']) && isset($subActions[$subAction]['activities'][$_REQUEST['activity']])) {
108
+			$activity = $_REQUEST['activity'];
109
+	}
107 110
 
108 111
 	// Set a few things.
109 112
 	$context['page_title'] = $txt['maintain_title'];
@@ -114,12 +117,14 @@  discard block
 block discarded – undo
114 117
 	call_helper($subActions[$subAction]['function']);
115 118
 
116 119
 	// Any special activity?
117
-	if (isset($activity))
118
-		call_helper($subActions[$subAction]['activities'][$activity]);
120
+	if (isset($activity)) {
121
+			call_helper($subActions[$subAction]['activities'][$activity]);
122
+	}
119 123
 
120 124
 	//converted to UTF-8? show a small maintenance info
121
-	if (isset($_GET['done']) && $_GET['done'] == 'convertutf8')
122
-		$context['maintenance_finished'] = $txt['utf8_title'];
125
+	if (isset($_GET['done']) && $_GET['done'] == 'convertutf8') {
126
+			$context['maintenance_finished'] = $txt['utf8_title'];
127
+	}
123 128
 
124 129
 	// Create a maintenance token.  Kinda hard to do it any other way.
125 130
 	createToken('admin-maint');
@@ -141,19 +146,22 @@  discard block
 block discarded – undo
141 146
 		db_extend('packages');
142 147
 
143 148
 		$colData = $smcFunc['db_list_columns']('{db_prefix}messages', true);
144
-		foreach ($colData as $column)
145
-			if ($column['name'] == 'body')
149
+		foreach ($colData as $column) {
150
+					if ($column['name'] == 'body')
146 151
 				$body_type = $column['type'];
152
+		}
147 153
 
148 154
 		$context['convert_to'] = $body_type == 'text' ? 'mediumtext' : 'text';
149 155
 		$context['convert_to_suggest'] = ($body_type != 'text' && !empty($modSettings['max_messageLength']) && $modSettings['max_messageLength'] < 65536);
150 156
 	}
151 157
 
152
-	if (isset($_GET['done']) && $_GET['done'] == 'convertutf8')
153
-		$context['maintenance_finished'] = $txt['utf8_title'];
154
-	if (isset($_GET['done']) && $_GET['done'] == 'convertentities')
155
-		$context['maintenance_finished'] = $txt['entity_convert_title'];
156
-}
158
+	if (isset($_GET['done']) && $_GET['done'] == 'convertutf8') {
159
+			$context['maintenance_finished'] = $txt['utf8_title'];
160
+	}
161
+	if (isset($_GET['done']) && $_GET['done'] == 'convertentities') {
162
+			$context['maintenance_finished'] = $txt['entity_convert_title'];
163
+	}
164
+	}
157 165
 
158 166
 /**
159 167
  * Supporting function for the routine maintenance area.
@@ -162,9 +170,10 @@  discard block
 block discarded – undo
162 170
 {
163 171
 	global $context, $txt;
164 172
 
165
-	if (isset($_GET['done']) && $_GET['done'] == 'recount')
166
-		$context['maintenance_finished'] = $txt['maintain_recount'];
167
-}
173
+	if (isset($_GET['done']) && $_GET['done'] == 'recount') {
174
+			$context['maintenance_finished'] = $txt['maintain_recount'];
175
+	}
176
+	}
168 177
 
169 178
 /**
170 179
  * Supporting function for the members maintenance area.
@@ -195,8 +204,9 @@  discard block
 block discarded – undo
195 204
 	}
196 205
 	$smcFunc['db_free_result']($result);
197 206
 
198
-	if (isset($_GET['done']) && $_GET['done'] == 'recountposts')
199
-		$context['maintenance_finished'] = $txt['maintain_recountposts'];
207
+	if (isset($_GET['done']) && $_GET['done'] == 'recountposts') {
208
+			$context['maintenance_finished'] = $txt['maintain_recountposts'];
209
+	}
200 210
 
201 211
 	loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest');
202 212
 }
@@ -222,11 +232,12 @@  discard block
 block discarded – undo
222 232
 	$context['categories'] = array();
223 233
 	while ($row = $smcFunc['db_fetch_assoc']($result))
224 234
 	{
225
-		if (!isset($context['categories'][$row['id_cat']]))
226
-			$context['categories'][$row['id_cat']] = array(
235
+		if (!isset($context['categories'][$row['id_cat']])) {
236
+					$context['categories'][$row['id_cat']] = array(
227 237
 				'name' => $row['cat_name'],
228 238
 				'boards' => array()
229 239
 			);
240
+		}
230 241
 
231 242
 		$context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array(
232 243
 			'id' => $row['id_board'],
@@ -239,11 +250,12 @@  discard block
 block discarded – undo
239 250
 	require_once($sourcedir . '/Subs-Boards.php');
240 251
 	sortCategories($context['categories']);
241 252
 
242
-	if (isset($_GET['done']) && $_GET['done'] == 'purgeold')
243
-		$context['maintenance_finished'] = $txt['maintain_old'];
244
-	elseif (isset($_GET['done']) && $_GET['done'] == 'massmove')
245
-		$context['maintenance_finished'] = $txt['move_topics_maintenance'];
246
-}
253
+	if (isset($_GET['done']) && $_GET['done'] == 'purgeold') {
254
+			$context['maintenance_finished'] = $txt['maintain_old'];
255
+	} elseif (isset($_GET['done']) && $_GET['done'] == 'massmove') {
256
+			$context['maintenance_finished'] = $txt['move_topics_maintenance'];
257
+	}
258
+	}
247 259
 
248 260
 /**
249 261
  * Find and fix all errors on the forum.
@@ -351,15 +363,17 @@  discard block
 block discarded – undo
351 363
 	// Show me your badge!
352 364
 	isAllowedTo('admin_forum');
353 365
 
354
-	if ($db_type != 'mysql' && $db_type != 'mysqli')
355
-		return;
366
+	if ($db_type != 'mysql' && $db_type != 'mysqli') {
367
+			return;
368
+	}
356 369
 
357 370
 	db_extend('packages');
358 371
 
359 372
 	$colData = $smcFunc['db_list_columns']('{db_prefix}messages', true);
360
-	foreach ($colData as $column)
361
-		if ($column['name'] == 'body')
373
+	foreach ($colData as $column) {
374
+			if ($column['name'] == 'body')
362 375
 			$body_type = $column['type'];
376
+	}
363 377
 
364 378
 	$context['convert_to'] = $body_type == 'text' ? 'mediumtext' : 'text';
365 379
 
@@ -369,19 +383,22 @@  discard block
 block discarded – undo
369 383
 		validateToken('admin-maint');
370 384
 
371 385
 		// Make it longer so we can do their limit.
372
-		if ($body_type == 'text')
373
-			$smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'mediumtext'));
386
+		if ($body_type == 'text') {
387
+					$smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'mediumtext'));
388
+		}
374 389
 		// Shorten the column so we can have a bit (literally per record) less space occupied
375
-		else
376
-			$smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'text'));
390
+		else {
391
+					$smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'text'));
392
+		}
377 393
 
378 394
 		// 3rd party integrations may be interested in knowning about this.
379 395
 		call_integration_hook('integrate_convert_msgbody', array($body_type));
380 396
 
381 397
 		$colData = $smcFunc['db_list_columns']('{db_prefix}messages', true);
382
-		foreach ($colData as $column)
383
-			if ($column['name'] == 'body')
398
+		foreach ($colData as $column) {
399
+					if ($column['name'] == 'body')
384 400
 				$body_type = $column['type'];
401
+		}
385 402
 
386 403
 		$context['maintenance_finished'] = $txt[$context['convert_to'] . '_title'];
387 404
 		$context['convert_to'] = $body_type == 'text' ? 'mediumtext' : 'text';
@@ -389,14 +406,14 @@  discard block
 block discarded – undo
389 406
 
390 407
 		return;
391 408
 		redirectexit('action=admin;area=maintain;sa=database');
392
-	}
393
-	elseif ($body_type != 'text' && (!isset($_POST['do_conversion']) || isset($_POST['cont'])))
409
+	} elseif ($body_type != 'text' && (!isset($_POST['do_conversion']) || isset($_POST['cont'])))
394 410
 	{
395 411
 		checkSession();
396
-		if (empty($_REQUEST['start']))
397
-			validateToken('admin-maint');
398
-		else
399
-			validateToken('admin-convertMsg');
412
+		if (empty($_REQUEST['start'])) {
413
+					validateToken('admin-maint');
414
+		} else {
415
+					validateToken('admin-convertMsg');
416
+		}
400 417
 
401 418
 		$context['page_title'] = $txt['not_done_title'];
402 419
 		$context['continue_post_data'] = '';
@@ -428,8 +445,9 @@  discard block
 block discarded – undo
428 445
 					'increment' => $increment - 1,
429 446
 				)
430 447
 			);
431
-			while ($row = $smcFunc['db_fetch_assoc']($request))
432
-				$id_msg_exceeding[] = $row['id_msg'];
448
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
449
+							$id_msg_exceeding[] = $row['id_msg'];
450
+			}
433 451
 			$smcFunc['db_free_result']($request);
434 452
 
435 453
 			$_REQUEST['start'] += $increment;
@@ -458,9 +476,9 @@  discard block
 block discarded – undo
458 476
 			{
459 477
 				$query_msg = array_slice($id_msg_exceeding, 0, 100);
460 478
 				$context['exceeding_messages_morethan'] = sprintf($txt['exceeding_messages_morethan'], count($id_msg_exceeding));
479
+			} else {
480
+							$query_msg = $id_msg_exceeding;
461 481
 			}
462
-			else
463
-				$query_msg = $id_msg_exceeding;
464 482
 
465 483
 			$context['exceeding_messages'] = array();
466 484
 			$request = $smcFunc['db_query']('', '
@@ -471,8 +489,9 @@  discard block
 block discarded – undo
471 489
 					'messages' => $query_msg,
472 490
 				)
473 491
 			);
474
-			while ($row = $smcFunc['db_fetch_assoc']($request))
475
-				$context['exceeding_messages'][] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>';
492
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
493
+							$context['exceeding_messages'][] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>';
494
+			}
476 495
 			$smcFunc['db_free_result']($request);
477 496
 		}
478 497
 	}
@@ -496,8 +515,9 @@  discard block
 block discarded – undo
496 515
 	isAllowedTo('admin_forum');
497 516
 
498 517
 	// Check to see if UTF-8 is currently the default character set.
499
-	if ($modSettings['global_character_set'] !== 'UTF-8' || !isset($db_character_set) || $db_character_set !== 'utf8')
500
-		fatal_lang_error('entity_convert_only_utf8');
518
+	if ($modSettings['global_character_set'] !== 'UTF-8' || !isset($db_character_set) || $db_character_set !== 'utf8') {
519
+			fatal_lang_error('entity_convert_only_utf8');
520
+	}
501 521
 
502 522
 	// Some starting values.
503 523
 	$context['table'] = empty($_REQUEST['table']) ? 0 : (int) $_REQUEST['table'];
@@ -559,8 +579,9 @@  discard block
 block discarded – undo
559 579
 		// Make sure we keep stuff unique!
560 580
 		$primary_keys = array();
561 581
 
562
-		if (function_exists('apache_reset_timeout'))
563
-			@apache_reset_timeout();
582
+		if (function_exists('apache_reset_timeout')) {
583
+					@apache_reset_timeout();
584
+		}
564 585
 
565 586
 		// Get a list of text columns.
566 587
 		$columns = array();
@@ -571,9 +592,10 @@  discard block
 block discarded – undo
571 592
 				'cur_table' => $cur_table,
572 593
 			)
573 594
 		);
574
-		while ($column_info = $smcFunc['db_fetch_assoc']($request))
575
-			if (strpos($column_info['Type'], 'text') !== false || strpos($column_info['Type'], 'char') !== false)
595
+		while ($column_info = $smcFunc['db_fetch_assoc']($request)) {
596
+					if (strpos($column_info['Type'], 'text') !== false || strpos($column_info['Type'], 'char') !== false)
576 597
 				$columns[] = strtolower($column_info['Field']);
598
+		}
577 599
 
578 600
 		// Get the column with the (first) primary key.
579 601
 		$request = $smcFunc['db_query']('', '
@@ -587,8 +609,9 @@  discard block
 block discarded – undo
587 609
 		{
588 610
 			if ($row['Key_name'] === 'PRIMARY')
589 611
 			{
590
-				if (empty($primary_key) || ($row['Seq_in_index'] == 1 && !in_array(strtolower($row['Column_name']), $columns)))
591
-					$primary_key = $row['Column_name'];
612
+				if (empty($primary_key) || ($row['Seq_in_index'] == 1 && !in_array(strtolower($row['Column_name']), $columns))) {
613
+									$primary_key = $row['Column_name'];
614
+				}
592 615
 
593 616
 				$primary_keys[] = $row['Column_name'];
594 617
 			}
@@ -597,8 +620,9 @@  discard block
 block discarded – undo
597 620
 
598 621
 		// No primary key, no glory.
599 622
 		// Same for columns. Just to be sure we've work to do!
600
-		if (empty($primary_key) || empty($columns))
601
-			continue;
623
+		if (empty($primary_key) || empty($columns)) {
624
+					continue;
625
+		}
602 626
 
603 627
 		// Get the maximum value for the primary key.
604 628
 		$request = $smcFunc['db_query']('', '
@@ -612,8 +636,9 @@  discard block
 block discarded – undo
612 636
 		list($max_value) = $smcFunc['db_fetch_row']($request);
613 637
 		$smcFunc['db_free_result']($request);
614 638
 
615
-		if (empty($max_value))
616
-			continue;
639
+		if (empty($max_value)) {
640
+					continue;
641
+		}
617 642
 
618 643
 		while ($context['start'] <= $max_value)
619 644
 		{
@@ -637,10 +662,11 @@  discard block
 block discarded – undo
637 662
 			{
638 663
 				$insertion_variables = array();
639 664
 				$changes = array();
640
-				foreach ($row as $column_name => $column_value)
641
-					if ($column_name !== $primary_key && strpos($column_value, '&#') !== false)
665
+				foreach ($row as $column_name => $column_value) {
666
+									if ($column_name !== $primary_key && strpos($column_value, '&#') !== false)
642 667
 					{
643 668
 						$changes[] = $column_name . ' = {string:changes_' . $column_name . '}';
669
+				}
644 670
 						$insertion_variables['changes_' . $column_name] = preg_replace_callback('~&#(\d{1,7}|x[0-9a-fA-F]{1,6});~', 'fixchar__callback', $column_value);
645 671
 					}
646 672
 
@@ -652,8 +678,8 @@  discard block
 block discarded – undo
652 678
 				}
653 679
 
654 680
 				// Update the row.
655
-				if (!empty($changes))
656
-					$smcFunc['db_query']('', '
681
+				if (!empty($changes)) {
682
+									$smcFunc['db_query']('', '
657 683
 						UPDATE {db_prefix}' . $cur_table . '
658 684
 						SET
659 685
 							' . implode(',
@@ -661,6 +687,7 @@  discard block
 block discarded – undo
661 687
 						WHERE ' . implode(' AND ', $where),
662 688
 						$insertion_variables
663 689
 					);
690
+				}
664 691
 			}
665 692
 			$smcFunc['db_free_result']($request);
666 693
 			$context['start'] += 500;
@@ -705,10 +732,11 @@  discard block
 block discarded – undo
705 732
 
706 733
 	checkSession('request');
707 734
 
708
-	if (!isset($_SESSION['optimized_tables']))
709
-		validateToken('admin-maint');
710
-	else
711
-		validateToken('admin-optimize', 'post', false);
735
+	if (!isset($_SESSION['optimized_tables'])) {
736
+			validateToken('admin-maint');
737
+	} else {
738
+			validateToken('admin-optimize', 'post', false);
739
+	}
712 740
 
713 741
 	ignore_user_abort(true);
714 742
 	db_extend();
@@ -727,13 +755,15 @@  discard block
 block discarded – undo
727 755
 	// Get a list of tables, as well as how many there are.
728 756
 	$temp_tables = $smcFunc['db_list_tables'](false, $real_prefix . '%');
729 757
 	$tables = array();
730
-	foreach ($temp_tables as $table)
731
-		$tables[] = array('table_name' => $table);
758
+	foreach ($temp_tables as $table) {
759
+			$tables[] = array('table_name' => $table);
760
+	}
732 761
 
733 762
 	// If there aren't any tables then I believe that would mean the world has exploded...
734 763
 	$context['num_tables'] = count($tables);
735
-	if ($context['num_tables'] == 0)
736
-		fatal_error('You appear to be running SMF in a flat file mode... fantastic!', false);
764
+	if ($context['num_tables'] == 0) {
765
+			fatal_error('You appear to be running SMF in a flat file mode... fantastic!', false);
766
+	}
737 767
 
738 768
 	$_REQUEST['start'] = empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start'];
739 769
 
@@ -744,8 +774,9 @@  discard block
 block discarded – undo
744 774
 	$_SESSION['optimized_tables'] = !empty($_SESSION['optimized_tables']) ? $_SESSION['optimized_tables'] : array();
745 775
 	for ($key=$_REQUEST['start']; $context['num_tables']-1; $key++)
746 776
 	{
747
-		if (empty($tables[$key]))
748
-			break;
777
+		if (empty($tables[$key])) {
778
+					break;
779
+		}
749 780
 
750 781
 		// Continue?
751 782
 		if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $time_start)) > 10)
@@ -759,8 +790,9 @@  discard block
 block discarded – undo
759 790
 			createToken('admin-optimize');
760 791
 			$context['continue_post_data'] = '<input type="hidden" name="' . $context['admin-optimize_token_var'] . '" value="' . $context['admin-optimize_token'] . '">';
761 792
 
762
-			if (function_exists('apache_reset_timeout'))
763
-				apache_reset_timeout();
793
+			if (function_exists('apache_reset_timeout')) {
794
+							apache_reset_timeout();
795
+			}
764 796
 
765 797
 			return;
766 798
 		}
@@ -768,11 +800,12 @@  discard block
 block discarded – undo
768 800
 		// Optimize the table!  We use backticks here because it might be a custom table.
769 801
 		$data_freed = $smcFunc['db_optimize_table']($tables[$key]['table_name']);
770 802
 
771
-		if ($data_freed > 0)
772
-			$_SESSION['optimized_tables'][] = array(
803
+		if ($data_freed > 0) {
804
+					$_SESSION['optimized_tables'][] = array(
773 805
 				'name' => $tables[$key]['table_name'],
774 806
 				'data_freed' => $data_freed,
775 807
 			);
808
+		}
776 809
 	}
777 810
 
778 811
 	// Number of tables, etc...
@@ -807,10 +840,11 @@  discard block
 block discarded – undo
807 840
 	checkSession('request');
808 841
 
809 842
 	// validate the request or the loop
810
-	if (!isset($_REQUEST['step']))
811
-		validateToken('admin-maint');
812
-	else
813
-		validateToken('admin-boardrecount');
843
+	if (!isset($_REQUEST['step'])) {
844
+			validateToken('admin-maint');
845
+	} else {
846
+			validateToken('admin-boardrecount');
847
+	}
814 848
 
815 849
 	$context['page_title'] = $txt['not_done_title'];
816 850
 	$context['continue_post_data'] = '';
@@ -831,8 +865,9 @@  discard block
 block discarded – undo
831 865
 	$smcFunc['db_free_result']($request);
832 866
 
833 867
 	$increment = min(max(50, ceil($max_topics / 4)), 2000);
834
-	if (empty($_REQUEST['start']))
835
-		$_REQUEST['start'] = 0;
868
+	if (empty($_REQUEST['start'])) {
869
+			$_REQUEST['start'] = 0;
870
+	}
836 871
 
837 872
 	$total_steps = 8;
838 873
 
@@ -859,8 +894,8 @@  discard block
 block discarded – undo
859 894
 					'max_id' => $_REQUEST['start'] + $increment,
860 895
 				)
861 896
 			);
862
-			while ($row = $smcFunc['db_fetch_assoc']($request))
863
-				$smcFunc['db_query']('', '
897
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
898
+							$smcFunc['db_query']('', '
864 899
 					UPDATE {db_prefix}topics
865 900
 					SET num_replies = {int:num_replies}
866 901
 					WHERE id_topic = {int:id_topic}',
@@ -869,6 +904,7 @@  discard block
 block discarded – undo
869 904
 						'id_topic' => $row['id_topic'],
870 905
 					)
871 906
 				);
907
+			}
872 908
 			$smcFunc['db_free_result']($request);
873 909
 
874 910
 			// Recount unapproved messages
@@ -887,8 +923,8 @@  discard block
 block discarded – undo
887 923
 					'max_id' => $_REQUEST['start'] + $increment,
888 924
 				)
889 925
 			);
890
-			while ($row = $smcFunc['db_fetch_assoc']($request))
891
-				$smcFunc['db_query']('', '
926
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
927
+							$smcFunc['db_query']('', '
892 928
 					UPDATE {db_prefix}topics
893 929
 					SET unapproved_posts = {int:unapproved_posts}
894 930
 					WHERE id_topic = {int:id_topic}',
@@ -897,6 +933,7 @@  discard block
 block discarded – undo
897 933
 						'id_topic' => $row['id_topic'],
898 934
 					)
899 935
 				);
936
+			}
900 937
 			$smcFunc['db_free_result']($request);
901 938
 
902 939
 			$_REQUEST['start'] += $increment;
@@ -919,8 +956,8 @@  discard block
 block discarded – undo
919 956
 	// Update the post count of each board.
920 957
 	if ($_REQUEST['step'] <= 1)
921 958
 	{
922
-		if (empty($_REQUEST['start']))
923
-			$smcFunc['db_query']('', '
959
+		if (empty($_REQUEST['start'])) {
960
+					$smcFunc['db_query']('', '
924 961
 				UPDATE {db_prefix}boards
925 962
 				SET num_posts = {int:num_posts}
926 963
 				WHERE redirect = {string:redirect}',
@@ -929,6 +966,7 @@  discard block
 block discarded – undo
929 966
 					'redirect' => '',
930 967
 				)
931 968
 			);
969
+		}
932 970
 
933 971
 		while ($_REQUEST['start'] < $max_topics)
934 972
 		{
@@ -945,8 +983,8 @@  discard block
 block discarded – undo
945 983
 					'is_approved' => 1,
946 984
 				)
947 985
 			);
948
-			while ($row = $smcFunc['db_fetch_assoc']($request))
949
-				$smcFunc['db_query']('', '
986
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
987
+							$smcFunc['db_query']('', '
950 988
 					UPDATE {db_prefix}boards
951 989
 					SET num_posts = num_posts + {int:real_num_posts}
952 990
 					WHERE id_board = {int:id_board}',
@@ -955,6 +993,7 @@  discard block
 block discarded – undo
955 993
 						'real_num_posts' => $row['real_num_posts'],
956 994
 					)
957 995
 				);
996
+			}
958 997
 			$smcFunc['db_free_result']($request);
959 998
 
960 999
 			$_REQUEST['start'] += $increment;
@@ -977,14 +1016,15 @@  discard block
 block discarded – undo
977 1016
 	// Update the topic count of each board.
978 1017
 	if ($_REQUEST['step'] <= 2)
979 1018
 	{
980
-		if (empty($_REQUEST['start']))
981
-			$smcFunc['db_query']('', '
1019
+		if (empty($_REQUEST['start'])) {
1020
+					$smcFunc['db_query']('', '
982 1021
 				UPDATE {db_prefix}boards
983 1022
 				SET num_topics = {int:num_topics}',
984 1023
 				array(
985 1024
 					'num_topics' => 0,
986 1025
 				)
987 1026
 			);
1027
+		}
988 1028
 
989 1029
 		while ($_REQUEST['start'] < $max_topics)
990 1030
 		{
@@ -1001,8 +1041,8 @@  discard block
 block discarded – undo
1001 1041
 					'id_topic_max' => $_REQUEST['start'] + $increment,
1002 1042
 				)
1003 1043
 			);
1004
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1005
-				$smcFunc['db_query']('', '
1044
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
1045
+							$smcFunc['db_query']('', '
1006 1046
 					UPDATE {db_prefix}boards
1007 1047
 					SET num_topics = num_topics + {int:real_num_topics}
1008 1048
 					WHERE id_board = {int:id_board}',
@@ -1011,6 +1051,7 @@  discard block
 block discarded – undo
1011 1051
 						'real_num_topics' => $row['real_num_topics'],
1012 1052
 					)
1013 1053
 				);
1054
+			}
1014 1055
 			$smcFunc['db_free_result']($request);
1015 1056
 
1016 1057
 			$_REQUEST['start'] += $increment;
@@ -1033,14 +1074,15 @@  discard block
 block discarded – undo
1033 1074
 	// Update the unapproved post count of each board.
1034 1075
 	if ($_REQUEST['step'] <= 3)
1035 1076
 	{
1036
-		if (empty($_REQUEST['start']))
1037
-			$smcFunc['db_query']('', '
1077
+		if (empty($_REQUEST['start'])) {
1078
+					$smcFunc['db_query']('', '
1038 1079
 				UPDATE {db_prefix}boards
1039 1080
 				SET unapproved_posts = {int:unapproved_posts}',
1040 1081
 				array(
1041 1082
 					'unapproved_posts' => 0,
1042 1083
 				)
1043 1084
 			);
1085
+		}
1044 1086
 
1045 1087
 		while ($_REQUEST['start'] < $max_topics)
1046 1088
 		{
@@ -1057,8 +1099,8 @@  discard block
 block discarded – undo
1057 1099
 					'is_approved' => 0,
1058 1100
 				)
1059 1101
 			);
1060
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1061
-				$smcFunc['db_query']('', '
1102
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
1103
+							$smcFunc['db_query']('', '
1062 1104
 					UPDATE {db_prefix}boards
1063 1105
 					SET unapproved_posts = unapproved_posts + {int:unapproved_posts}
1064 1106
 					WHERE id_board = {int:id_board}',
@@ -1067,6 +1109,7 @@  discard block
 block discarded – undo
1067 1109
 						'unapproved_posts' => $row['real_unapproved_posts'],
1068 1110
 					)
1069 1111
 				);
1112
+			}
1070 1113
 			$smcFunc['db_free_result']($request);
1071 1114
 
1072 1115
 			$_REQUEST['start'] += $increment;
@@ -1089,14 +1132,15 @@  discard block
 block discarded – undo
1089 1132
 	// Update the unapproved topic count of each board.
1090 1133
 	if ($_REQUEST['step'] <= 4)
1091 1134
 	{
1092
-		if (empty($_REQUEST['start']))
1093
-			$smcFunc['db_query']('', '
1135
+		if (empty($_REQUEST['start'])) {
1136
+					$smcFunc['db_query']('', '
1094 1137
 				UPDATE {db_prefix}boards
1095 1138
 				SET unapproved_topics = {int:unapproved_topics}',
1096 1139
 				array(
1097 1140
 					'unapproved_topics' => 0,
1098 1141
 				)
1099 1142
 			);
1143
+		}
1100 1144
 
1101 1145
 		while ($_REQUEST['start'] < $max_topics)
1102 1146
 		{
@@ -1113,8 +1157,8 @@  discard block
 block discarded – undo
1113 1157
 					'id_topic_max' => $_REQUEST['start'] + $increment,
1114 1158
 				)
1115 1159
 			);
1116
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1117
-				$smcFunc['db_query']('', '
1160
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
1161
+							$smcFunc['db_query']('', '
1118 1162
 					UPDATE {db_prefix}boards
1119 1163
 					SET unapproved_topics = unapproved_topics + {int:real_unapproved_topics}
1120 1164
 					WHERE id_board = {int:id_board}',
@@ -1123,6 +1167,7 @@  discard block
 block discarded – undo
1123 1167
 						'real_unapproved_topics' => $row['real_unapproved_topics'],
1124 1168
 					)
1125 1169
 				);
1170
+			}
1126 1171
 			$smcFunc['db_free_result']($request);
1127 1172
 
1128 1173
 			$_REQUEST['start'] += $increment;
@@ -1156,8 +1201,9 @@  discard block
 block discarded – undo
1156 1201
 				'is_not_deleted' => 0,
1157 1202
 			)
1158 1203
 		);
1159
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1160
-			updateMemberData($row['id_member'], array('instant_messages' => $row['real_num']));
1204
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1205
+					updateMemberData($row['id_member'], array('instant_messages' => $row['real_num']));
1206
+		}
1161 1207
 		$smcFunc['db_free_result']($request);
1162 1208
 
1163 1209
 		$request = $smcFunc['db_query']('', '
@@ -1172,8 +1218,9 @@  discard block
 block discarded – undo
1172 1218
 				'is_not_read' => 0,
1173 1219
 			)
1174 1220
 		);
1175
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1176
-			updateMemberData($row['id_member'], array('unread_messages' => $row['real_num']));
1221
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1222
+					updateMemberData($row['id_member'], array('unread_messages' => $row['real_num']));
1223
+		}
1177 1224
 		$smcFunc['db_free_result']($request);
1178 1225
 
1179 1226
 		if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $time_start)) > 3)
@@ -1205,12 +1252,13 @@  discard block
 block discarded – undo
1205 1252
 				)
1206 1253
 			);
1207 1254
 			$boards = array();
1208
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1209
-				$boards[$row['id_board']][] = $row['id_msg'];
1255
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
1256
+							$boards[$row['id_board']][] = $row['id_msg'];
1257
+			}
1210 1258
 			$smcFunc['db_free_result']($request);
1211 1259
 
1212
-			foreach ($boards as $board_id => $messages)
1213
-				$smcFunc['db_query']('', '
1260
+			foreach ($boards as $board_id => $messages) {
1261
+							$smcFunc['db_query']('', '
1214 1262
 					UPDATE {db_prefix}messages
1215 1263
 					SET id_board = {int:id_board}
1216 1264
 					WHERE id_msg IN ({array_int:id_msg_array})',
@@ -1219,6 +1267,7 @@  discard block
 block discarded – undo
1219 1267
 						'id_board' => $board_id,
1220 1268
 					)
1221 1269
 				);
1270
+			}
1222 1271
 
1223 1272
 			$_REQUEST['start'] += $increment;
1224 1273
 
@@ -1248,8 +1297,9 @@  discard block
 block discarded – undo
1248 1297
 		)
1249 1298
 	);
1250 1299
 	$realBoardCounts = array();
1251
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1252
-		$realBoardCounts[$row['id_board']] = $row['local_last_msg'];
1300
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1301
+			$realBoardCounts[$row['id_board']] = $row['local_last_msg'];
1302
+	}
1253 1303
 	$smcFunc['db_free_result']($request);
1254 1304
 
1255 1305
 	$request = $smcFunc['db_query']('', '
@@ -1269,18 +1319,20 @@  discard block
 block discarded – undo
1269 1319
 	krsort($resort_me);
1270 1320
 
1271 1321
 	$lastModifiedMsg = array();
1272
-	foreach ($resort_me as $rows)
1273
-		foreach ($rows as $row)
1322
+	foreach ($resort_me as $rows) {
1323
+			foreach ($rows as $row)
1274 1324
 		{
1275 1325
 			// The latest message is the latest of the current board and its children.
1276 1326
 			if (isset($lastModifiedMsg[$row['id_board']]))
1277 1327
 				$curLastModifiedMsg = max($row['local_last_msg'], $lastModifiedMsg[$row['id_board']]);
1278
-			else
1279
-				$curLastModifiedMsg = $row['local_last_msg'];
1328
+	}
1329
+			else {
1330
+							$curLastModifiedMsg = $row['local_last_msg'];
1331
+			}
1280 1332
 
1281 1333
 			// If what is and what should be the latest message differ, an update is necessary.
1282
-			if ($row['local_last_msg'] != $row['id_last_msg'] || $curLastModifiedMsg != $row['id_msg_updated'])
1283
-				$smcFunc['db_query']('', '
1334
+			if ($row['local_last_msg'] != $row['id_last_msg'] || $curLastModifiedMsg != $row['id_msg_updated']) {
1335
+							$smcFunc['db_query']('', '
1284 1336
 					UPDATE {db_prefix}boards
1285 1337
 					SET id_last_msg = {int:id_last_msg}, id_msg_updated = {int:id_msg_updated}
1286 1338
 					WHERE id_board = {int:id_board}',
@@ -1290,12 +1342,14 @@  discard block
 block discarded – undo
1290 1342
 						'id_board' => $row['id_board'],
1291 1343
 					)
1292 1344
 				);
1345
+			}
1293 1346
 
1294 1347
 			// Parent boards inherit the latest modified message of their children.
1295
-			if (isset($lastModifiedMsg[$row['id_parent']]))
1296
-				$lastModifiedMsg[$row['id_parent']] = max($row['local_last_msg'], $lastModifiedMsg[$row['id_parent']]);
1297
-			else
1298
-				$lastModifiedMsg[$row['id_parent']] = $row['local_last_msg'];
1348
+			if (isset($lastModifiedMsg[$row['id_parent']])) {
1349
+							$lastModifiedMsg[$row['id_parent']] = max($row['local_last_msg'], $lastModifiedMsg[$row['id_parent']]);
1350
+			} else {
1351
+							$lastModifiedMsg[$row['id_parent']] = $row['local_last_msg'];
1352
+			}
1299 1353
 		}
1300 1354
 
1301 1355
 	// Update all the basic statistics.
@@ -1367,8 +1421,9 @@  discard block
 block discarded – undo
1367 1421
 	require_once($sourcedir . '/Subs-Auth.php');
1368 1422
 	$members = findMembers($_POST['to']);
1369 1423
 
1370
-	if (empty($members))
1371
-		fatal_lang_error('reattribute_cannot_find_member');
1424
+	if (empty($members)) {
1425
+			fatal_lang_error('reattribute_cannot_find_member');
1426
+	}
1372 1427
 
1373 1428
 	$memID = array_shift($members);
1374 1429
 	$memID = $memID['id'];
@@ -1398,8 +1453,9 @@  discard block
 block discarded – undo
1398 1453
 		validateToken('admin-maint');
1399 1454
 
1400 1455
 		$groups = array();
1401
-		foreach ($_POST['groups'] as $id => $dummy)
1402
-			$groups[] = (int) $id;
1456
+		foreach ($_POST['groups'] as $id => $dummy) {
1457
+					$groups[] = (int) $id;
1458
+		}
1403 1459
 		$time_limit = (time() - ($_POST['maxdays'] * 24 * 3600));
1404 1460
 		$where_vars = array(
1405 1461
 			'time_limit' => $time_limit,
@@ -1408,9 +1464,9 @@  discard block
 block discarded – undo
1408 1464
 		{
1409 1465
 			$where = 'mem.date_registered < {int:time_limit} AND mem.is_activated = {int:is_activated}';
1410 1466
 			$where_vars['is_activated'] = 0;
1467
+		} else {
1468
+					$where = 'mem.last_login < {int:time_limit} AND (mem.last_login != 0 OR mem.date_registered < {int:time_limit})';
1411 1469
 		}
1412
-		else
1413
-			$where = 'mem.last_login < {int:time_limit} AND (mem.last_login != 0 OR mem.date_registered < {int:time_limit})';
1414 1470
 
1415 1471
 		// Need to get *all* groups then work out which (if any) we avoid.
1416 1472
 		$request = $smcFunc['db_query']('', '
@@ -1429,8 +1485,7 @@  discard block
 block discarded – undo
1429 1485
 				{
1430 1486
 					$where .= ' AND mem.id_post_group != {int:id_post_group_' . $row['id_group'] . '}';
1431 1487
 					$where_vars['id_post_group_' . $row['id_group']] = $row['id_group'];
1432
-				}
1433
-				else
1488
+				} else
1434 1489
 				{
1435 1490
 					$where .= ' AND mem.id_group != {int:id_group_' . $row['id_group'] . '} AND FIND_IN_SET({int:id_group_' . $row['id_group'] . '}, mem.additional_groups) = 0';
1436 1491
 					$where_vars['id_group_' . $row['id_group']] = $row['id_group'];
@@ -1457,8 +1512,9 @@  discard block
 block discarded – undo
1457 1512
 		$members = array();
1458 1513
 		while ($row = $smcFunc['db_fetch_assoc']($request))
1459 1514
 		{
1460
-			if (!$row['is_mod'] || !in_array(3, $groups))
1461
-				$members[] = $row['id_member'];
1515
+			if (!$row['is_mod'] || !in_array(3, $groups)) {
1516
+							$members[] = $row['id_member'];
1517
+			}
1462 1518
 		}
1463 1519
 		$smcFunc['db_free_result']($request);
1464 1520
 
@@ -1505,8 +1561,9 @@  discard block
 block discarded – undo
1505 1561
 		)
1506 1562
 	);
1507 1563
 
1508
-	while ($row = $smcFunc['db_fetch_row']($request))
1509
-		$drafts[] = (int) $row[0];
1564
+	while ($row = $smcFunc['db_fetch_row']($request)) {
1565
+			$drafts[] = (int) $row[0];
1566
+	}
1510 1567
 	$smcFunc['db_free_result']($request);
1511 1568
 
1512 1569
 	// If we have old drafts, remove them
@@ -1549,8 +1606,9 @@  discard block
 block discarded – undo
1549 1606
 	$sticky = isset($_POST['move_type_sticky']) || isset($_GET['sticky']);
1550 1607
 
1551 1608
 	// No boards then this is your stop.
1552
-	if (empty($id_board_from) || empty($id_board_to))
1553
-		return;
1609
+	if (empty($id_board_from) || empty($id_board_to)) {
1610
+			return;
1611
+	}
1554 1612
 
1555 1613
 	// The big WHERE clause
1556 1614
 	$conditions = 'WHERE t.id_board = {int:id_board_from}
@@ -1598,18 +1656,20 @@  discard block
 block discarded – undo
1598 1656
 		);
1599 1657
 		list ($total_topics) = $smcFunc['db_fetch_row']($request);
1600 1658
 		$smcFunc['db_free_result']($request);
1659
+	} else {
1660
+			$total_topics = (int) $_REQUEST['totaltopics'];
1601 1661
 	}
1602
-	else
1603
-		$total_topics = (int) $_REQUEST['totaltopics'];
1604 1662
 
1605 1663
 	// Seems like we need this here.
1606 1664
 	$context['continue_get_data'] = '?action=admin;area=maintain;sa=topics;activity=massmove;id_board_from=' . $id_board_from . ';id_board_to=' . $id_board_to . ';totaltopics=' . $total_topics . ';max_days=' . $max_days;
1607 1665
 
1608
-	if ($locked)
1609
-		$context['continue_get_data'] .= ';locked';
1666
+	if ($locked) {
1667
+			$context['continue_get_data'] .= ';locked';
1668
+	}
1610 1669
 
1611
-	if ($sticky)
1612
-		$context['continue_get_data'] .= ';sticky';
1670
+	if ($sticky) {
1671
+			$context['continue_get_data'] .= ';sticky';
1672
+	}
1613 1673
 
1614 1674
 	$context['continue_get_data'] .= ';start=' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id'];
1615 1675
 
@@ -1630,8 +1690,9 @@  discard block
 block discarded – undo
1630 1690
 
1631 1691
 			// Get the ids.
1632 1692
 			$topics = array();
1633
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1634
-				$topics[] = $row['id_topic'];
1693
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
1694
+							$topics[] = $row['id_topic'];
1695
+			}
1635 1696
 
1636 1697
 			// Just return if we don't have any topics left to move.
1637 1698
 			if (empty($topics))
@@ -1722,9 +1783,9 @@  discard block
 block discarded – undo
1722 1783
 		// save it so we don't do this again for this task
1723 1784
 		list ($_SESSION['total_members']) = $smcFunc['db_fetch_row']($request);
1724 1785
 		$smcFunc['db_free_result']($request);
1786
+	} else {
1787
+			validateToken('admin-recountposts');
1725 1788
 	}
1726
-	else
1727
-		validateToken('admin-recountposts');
1728 1789
 
1729 1790
 	// Lets get a group of members and determine their post count (from the boards that have post count enabled of course).
1730 1791
 	$request = $smcFunc['db_query']('', '
@@ -1770,8 +1831,9 @@  discard block
 block discarded – undo
1770 1831
 		createToken('admin-recountposts');
1771 1832
 		$context['continue_post_data'] = '<input type="hidden" name="' . $context['admin-recountposts_token_var'] . '" value="' . $context['admin-recountposts_token'] . '">';
1772 1833
 
1773
-		if (function_exists('apache_reset_timeout'))
1774
-			apache_reset_timeout();
1834
+		if (function_exists('apache_reset_timeout')) {
1835
+					apache_reset_timeout();
1836
+		}
1775 1837
 		return;
1776 1838
 	}
1777 1839
 
@@ -1857,10 +1919,9 @@  discard block
 block discarded – undo
1857 1919
 		checkSession('request');
1858 1920
 		validateToken('admin-hook', 'request');
1859 1921
 
1860
-		if ($_REQUEST['do'] == 'remove')
1861
-			remove_integration_function($_REQUEST['hook'], urldecode($_REQUEST['function']));
1862
-
1863
-		else
1922
+		if ($_REQUEST['do'] == 'remove') {
1923
+					remove_integration_function($_REQUEST['hook'], urldecode($_REQUEST['function']));
1924
+		} else
1864 1925
 		{
1865 1926
 			$function_remove = urldecode($_REQUEST['function']) . (($_REQUEST['do'] == 'disable') ? '' : '!');
1866 1927
 			$function_add = urldecode($_REQUEST['function']) . (($_REQUEST['do'] == 'disable') ? '!' : '');
@@ -1910,11 +1971,11 @@  discard block
 block discarded – undo
1910 1971
 						// Show a nice icon to indicate this is an instance.
1911 1972
 						$instance = (!empty($data['instance']) ? '<span class="generic_icons news" title="'. $txt['hooks_field_function_method'] .'"></span> ' : '');
1912 1973
 
1913
-						if (!empty($data['included_file']))
1914
-							return $instance . $txt['hooks_field_function'] . ': ' . $data['real_function'] . '<br>' . $txt['hooks_field_included_file'] . ': ' . $data['included_file'];
1915
-
1916
-						else
1917
-							return $instance . $data['real_function'];
1974
+						if (!empty($data['included_file'])) {
1975
+													return $instance . $txt['hooks_field_function'] . ': ' . $data['real_function'] . '<br>' . $txt['hooks_field_included_file'] . ': ' . $data['included_file'];
1976
+						} else {
1977
+													return $instance . $data['real_function'];
1978
+						}
1918 1979
 					},
1919 1980
 				),
1920 1981
 				'sort' =>  array(
@@ -1979,11 +2040,12 @@  discard block
 block discarded – undo
1979 2040
 		'data' => array(
1980 2041
 			'function' => function ($data) use ($txt, $scripturl, $context)
1981 2042
 			{
1982
-				if (!$data['hook_exists'])
1983
-					return '
2043
+				if (!$data['hook_exists']) {
2044
+									return '
1984 2045
 					<a href="' . $scripturl . '?action=admin;area=maintain;sa=hooks;do=remove;hook=' . $data['hook_name'] . ';function=' . urlencode($data['function_name']) . $context['filter_url'] . ';' . $context['admin-hook_token_var'] . '=' . $context['admin-hook_token'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" data-confirm="' . $txt['quickmod_confirm'] . '" class="you_sure">
1985 2046
 						<span class="generic_icons delete" title="' . $txt['hooks_button_remove'] . '"></span>
1986 2047
 					</a>';
2048
+				}
1987 2049
 			},
1988 2050
 			'class' => 'centertext',
1989 2051
 		),
@@ -2018,10 +2080,11 @@  discard block
 block discarded – undo
2018 2080
 		{
2019 2081
 			if ($file != '.' && $file != '..')
2020 2082
 			{
2021
-				if (is_dir($dir_path . '/' . $file))
2022
-					$files = array_merge($files, get_files_recursive($dir_path . '/' . $file));
2023
-				else
2024
-					$files[] = array('dir' => $dir_path, 'name' => $file);
2083
+				if (is_dir($dir_path . '/' . $file)) {
2084
+									$files = array_merge($files, get_files_recursive($dir_path . '/' . $file));
2085
+				} else {
2086
+									$files[] = array('dir' => $dir_path, 'name' => $file);
2087
+				}
2025 2088
 			}
2026 2089
 		}
2027 2090
 	}
@@ -2070,16 +2133,16 @@  discard block
 block discarded – undo
2070 2133
 							// I need to know if there is at least one function called in this file.
2071 2134
 							$temp_data['include'][$hookParsedData['pureFunc']] = array('hook' => $hook, 'function' => $hookParsedData['pureFunc']);
2072 2135
 							unset($temp_hooks[$hook][$rawFunc]);
2073
-						}
2074
-						elseif (strpos(str_replace(' (', '(', $fc), 'function ' . trim($hookParsedData['pureFunc']) . '(') !== false)
2136
+						} elseif (strpos(str_replace(' (', '(', $fc), 'function ' . trim($hookParsedData['pureFunc']) . '(') !== false)
2075 2137
 						{
2076 2138
 							$hook_status[$hook][$hookParsedData['pureFunc']] = $hookParsedData;
2077 2139
 							$hook_status[$hook][$hookParsedData['pureFunc']]['exists'] = true;
2078 2140
 							$hook_status[$hook][$hookParsedData['pureFunc']]['in_file'] = (!empty($file['name']) ? $file['name'] : (!empty($hookParsedData['hookFile']) ? $hookParsedData['hookFile'] : ''));
2079 2141
 
2080 2142
 							// Does the hook has its own file?
2081
-							if (!empty($hookParsedData['hookFile']))
2082
-								$temp_data['include'][$hookParsedData['pureFunc']] = array('hook' => $hook, 'function' => $hookParsedData['pureFunc']);
2143
+							if (!empty($hookParsedData['hookFile'])) {
2144
+															$temp_data['include'][$hookParsedData['pureFunc']] = array('hook' => $hook, 'function' => $hookParsedData['pureFunc']);
2145
+							}
2083 2146
 
2084 2147
 							// I want to remember all the functions called within this file (to check later if they are enabled or disabled and decide if the integrare_*_include of that file can be disabled too)
2085 2148
 							$temp_data['function'][$file['name']][$hookParsedData['pureFunc']] = $hookParsedData['enabled'];
@@ -2106,15 +2169,17 @@  discard block
 block discarded – undo
2106 2169
 	$sort = array();
2107 2170
 	$hooks_filters = array();
2108 2171
 
2109
-	foreach ($hooks as $hook => $functions)
2110
-		$hooks_filters[] = '<option' . ($context['current_filter'] == $hook ? ' selected ' : '') . ' value="' . $hook . '">' . $hook . '</option>';
2172
+	foreach ($hooks as $hook => $functions) {
2173
+			$hooks_filters[] = '<option' . ($context['current_filter'] == $hook ? ' selected ' : '') . ' value="' . $hook . '">' . $hook . '</option>';
2174
+	}
2111 2175
 
2112
-	if (!empty($hooks_filters))
2113
-		$context['insert_after_template'] .= '
2176
+	if (!empty($hooks_filters)) {
2177
+			$context['insert_after_template'] .= '
2114 2178
 		<script>
2115 2179
 			var hook_name_header = document.getElementById(\'header_list_integration_hooks_hook_name\');
2116 2180
 			hook_name_header.innerHTML += ' . JavaScriptEscape('<select style="margin-left:15px;" onchange="window.location=(\'' . $scripturl . '?action=admin;area=maintain;sa=hooks\' + (this.value ? \';filter=\' + this.value : \'\'));"><option value="">' . $txt['hooks_reset_filter'] . '</option>' . implode('', $hooks_filters) . '</select>'). ';
2117 2181
 		</script>';
2182
+	}
2118 2183
 
2119 2184
 	$temp_data = array();
2120 2185
 	$id = 0;
@@ -2157,10 +2222,11 @@  discard block
 block discarded – undo
2157 2222
 
2158 2223
 	foreach ($temp_data as $data)
2159 2224
 	{
2160
-		if (++$counter < $start)
2161
-			continue;
2162
-		elseif ($counter == $start + $per_page)
2163
-			break;
2225
+		if (++$counter < $start) {
2226
+					continue;
2227
+		} elseif ($counter == $start + $per_page) {
2228
+					break;
2229
+		}
2164 2230
 
2165 2231
 		$hooks_data[] = $data;
2166 2232
 	}
@@ -2182,13 +2248,15 @@  discard block
 block discarded – undo
2182 2248
 	$hooks_count = 0;
2183 2249
 
2184 2250
 	$context['filter'] = false;
2185
-	if (isset($_GET['filter']))
2186
-		$context['filter'] = $_GET['filter'];
2251
+	if (isset($_GET['filter'])) {
2252
+			$context['filter'] = $_GET['filter'];
2253
+	}
2187 2254
 
2188 2255
 	foreach ($hooks as $hook => $functions)
2189 2256
 	{
2190
-		if (empty($context['filter']) || (!empty($context['filter']) && $context['filter'] == $hook))
2191
-			$hooks_count += count($functions);
2257
+		if (empty($context['filter']) || (!empty($context['filter']) && $context['filter'] == $hook)) {
2258
+					$hooks_count += count($functions);
2259
+		}
2192 2260
 	}
2193 2261
 
2194 2262
 	return $hooks_count;
@@ -2209,8 +2277,9 @@  discard block
 block discarded – undo
2209 2277
 		$integration_hooks = array();
2210 2278
 		foreach ($modSettings as $key => $value)
2211 2279
 		{
2212
-			if (!empty($value) && substr($key, 0, 10) === 'integrate_')
2213
-				$integration_hooks[$key] = explode(',', $value);
2280
+			if (!empty($value) && substr($key, 0, 10) === 'integrate_') {
2281
+							$integration_hooks[$key] = explode(',', $value);
2282
+			}
2214 2283
 		}
2215 2284
 	}
2216 2285
 
@@ -2241,8 +2310,9 @@  discard block
 block discarded – undo
2241 2310
 	);
2242 2311
 
2243 2312
 	// Meh...
2244
-	if (empty($rawData))
2245
-		return $hookData;
2313
+	if (empty($rawData)) {
2314
+			return $hookData;
2315
+	}
2246 2316
 
2247 2317
 	// For convenience purposes only!
2248 2318
 	$modFunc = $rawData;
@@ -2253,11 +2323,11 @@  discard block
 block discarded – undo
2253 2323
 		list ($hookData['hookFile'], $modFunc) = explode('|', $modFunc);
2254 2324
 
2255 2325
 		// Does the file exists? who knows!
2256
-		if (empty($settings['theme_dir']))
2257
-			$hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir));
2258
-
2259
-		else
2260
-			$hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir']));
2326
+		if (empty($settings['theme_dir'])) {
2327
+					$hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir));
2328
+		} else {
2329
+					$hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir']));
2330
+		}
2261 2331
 
2262 2332
 		$hookData['fileExists'] = file_exists($hookData['absPath']);
2263 2333
 		$hookData['hookFile'] = basename($hookData['hookFile']);
@@ -2282,11 +2352,10 @@  discard block
 block discarded – undo
2282 2352
 	{
2283 2353
 		list ($hookData['class'], $hookData['method']) = explode('::', $modFunc);
2284 2354
 		$hookData['pureFunc'] = $hookData['method'];
2355
+	} else {
2356
+			$hookData['pureFunc'] = $modFunc;
2285 2357
 	}
2286 2358
 
2287
-	else
2288
-		$hookData['pureFunc'] = $modFunc;
2289
-
2290 2359
 	return $hookData;
2291 2360
 }
2292 2361
 
Please login to merge, or discard this patch.
Sources/Subscriptions-PayPal.php 1 patch
Braces   +83 added lines, -61 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
 // This won't be dedicated without this - this must exist in each gateway!
15 15
 // SMF Payment Gateway: paypal
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * Class for returning available form data for this gateway
@@ -118,8 +119,7 @@  discard block
 block discarded – undo
118 119
 		{
119 120
 			$return_data['hidden']['p3'] = 1;
120 121
 			$return_data['hidden']['t3'] = strtoupper(substr($period, 0, 1));
121
-		}
122
-		else
122
+		} else
123 123
 		{
124 124
 			preg_match('~(\d*)(\w)~', $sub_data['real_length'], $match);
125 125
 			$unit = $match[1];
@@ -130,14 +130,15 @@  discard block
 block discarded – undo
130 130
 		}
131 131
 
132 132
 		// If it's repeatable do some javascript to respect this idea.
133
-		if (!empty($sub_data['repeatable']))
134
-			$return_data['javascript'] = '
133
+		if (!empty($sub_data['repeatable'])) {
134
+					$return_data['javascript'] = '
135 135
 				document.write(\'<label for="do_paypal_recur"><input type="checkbox" name="do_paypal_recur" id="do_paypal_recur" checked onclick="switchPaypalRecur();" class="input_check">' . $txt['paid_make_recurring'] . '</label><br>\');
136 136
 
137 137
 				function switchPaypalRecur()
138 138
 				{
139 139
 					document.getElementById("paypal_cmd").value = document.getElementById("do_paypal_recur").checked ? "_xclick-subscriptions" : "_xclick";
140 140
 				}';
141
+		}
141 142
 
142 143
 		return $return_data;
143 144
 	}
@@ -160,20 +161,24 @@  discard block
 block discarded – undo
160 161
 		global $modSettings;
161 162
 
162 163
 		// Has the user set up an email address?
163
-		if ((empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_email'])) || (!empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_sandbox_email'])))
164
-			return false;
164
+		if ((empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_email'])) || (!empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_sandbox_email']))) {
165
+					return false;
166
+		}
165 167
 		// Check the correct transaction types are even here.
166
-		if ((!isset($_POST['txn_type']) && !isset($_POST['payment_status'])) || (!isset($_POST['business']) && !isset($_POST['receiver_email'])))
167
-			return false;
168
+		if ((!isset($_POST['txn_type']) && !isset($_POST['payment_status'])) || (!isset($_POST['business']) && !isset($_POST['receiver_email']))) {
169
+					return false;
170
+		}
168 171
 		// Correct email address?
169
-		if (!isset($_POST['business']))
170
-			$_POST['business'] = $_POST['receiver_email'];
172
+		if (!isset($_POST['business'])) {
173
+					$_POST['business'] = $_POST['receiver_email'];
174
+		}
171 175
 
172 176
 		// Are we testing?
173
-		if (empty($modSettings['paidsubs_test']) && strtolower($modSettings['paypal_sandbox_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails'])))))
174
-			return false;
175
-		elseif (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', $modSettings['paypal_additional_emails']))))
176
-			return false;
177
+		if (empty($modSettings['paidsubs_test']) && strtolower($modSettings['paypal_sandbox_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails']))))) {
178
+					return false;
179
+		} elseif (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', $modSettings['paypal_additional_emails'])))) {
180
+					return false;
181
+		}
177 182
 		return true;
178 183
 	}
179 184
 
@@ -192,15 +197,17 @@  discard block
 block discarded – undo
192 197
 		global $modSettings, $txt;
193 198
 
194 199
 		// Put this to some default value.
195
-		if (!isset($_POST['txn_type']))
196
-			$_POST['txn_type'] = '';
200
+		if (!isset($_POST['txn_type'])) {
201
+					$_POST['txn_type'] = '';
202
+		}
197 203
 
198 204
 		// Build the request string - starting with the minimum requirement.
199 205
 		$requestString = 'cmd=_notify-validate';
200 206
 
201 207
 		// Now my dear, add all the posted bits in the order we got them
202
-		foreach ($_POST as $k => $v)
203
-			$requestString .= '&' . $k . '=' . urlencode($v);
208
+		foreach ($_POST as $k => $v) {
209
+					$requestString .= '&' . $k . '=' . urlencode($v);
210
+		}
204 211
 
205 212
 		// Can we use curl?
206 213
 		if (function_exists('curl_init') && $curl = curl_init((!empty($modSettings['paidsubs_test']) ? 'https://www.sandbox.' : 'http://www.') . 'paypal.com/cgi-bin/webscr'))
@@ -240,14 +247,16 @@  discard block
 block discarded – undo
240 247
 			$header .= 'Connection: close' . "\r\n\r\n";
241 248
 
242 249
 			// Open the connection.
243
-			if (!empty($modSettings['paidsubs_test']))
244
-				$fp = fsockopen('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
245
-			else
246
-				$fp = fsockopen('www.paypal.com', 80, $errno, $errstr, 30);
250
+			if (!empty($modSettings['paidsubs_test'])) {
251
+							$fp = fsockopen('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
252
+			} else {
253
+							$fp = fsockopen('www.paypal.com', 80, $errno, $errstr, 30);
254
+			}
247 255
 
248 256
 			// Did it work?
249
-			if (!$fp)
250
-				generateSubscriptionError($txt['paypal_could_not_connect']);
257
+			if (!$fp) {
258
+							generateSubscriptionError($txt['paypal_could_not_connect']);
259
+			}
251 260
 
252 261
 			// Put the data to the port.
253 262
 			fputs($fp, $header . $requestString);
@@ -256,8 +265,9 @@  discard block
 block discarded – undo
256 265
 			while (!feof($fp))
257 266
 			{
258 267
 				$this->return_data = fgets($fp, 1024);
259
-				if (strcmp(trim($this->return_data), 'VERIFIED') === 0)
260
-					break;
268
+				if (strcmp(trim($this->return_data), 'VERIFIED') === 0) {
269
+									break;
270
+				}
261 271
 			}
262 272
 
263 273
 			// Clean up.
@@ -265,28 +275,34 @@  discard block
 block discarded – undo
265 275
 		}
266 276
 
267 277
 		// If this isn't verified then give up...
268
-		if (strcmp(trim($this->return_data), 'VERIFIED') !== 0)
269
-			exit;
278
+		if (strcmp(trim($this->return_data), 'VERIFIED') !== 0) {
279
+					exit;
280
+		}
270 281
 
271 282
 		// Check that this is intended for us.
272
-		if (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails'])))))
273
-			exit;
283
+		if (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails']))))) {
284
+					exit;
285
+		}
274 286
 
275 287
 		// Is this a subscription - and if so is it a secondary payment that we need to process?
276 288
 		// If so, make sure we get it in the expected format. Seems PayPal sometimes sends it without urlencoding.
277
-		if (!empty($_POST['item_number']) && strpos($_POST['item_number'], ' ') !== false)
278
-			$_POST['item_number'] = str_replace(' ', '+', $_POST['item_number']);
279
-		if ($this->isSubscription() && (empty($_POST['item_number']) || strpos($_POST['item_number'], '+') === false))
280
-			// Calculate the subscription it relates to!
289
+		if (!empty($_POST['item_number']) && strpos($_POST['item_number'], ' ') !== false) {
290
+					$_POST['item_number'] = str_replace(' ', '+', $_POST['item_number']);
291
+		}
292
+		if ($this->isSubscription() && (empty($_POST['item_number']) || strpos($_POST['item_number'], '+') === false)) {
293
+					// Calculate the subscription it relates to!
281 294
 			$this->_findSubscription();
295
+		}
282 296
 
283 297
 		// Verify the currency!
284
-		if (strtolower($_POST['mc_currency']) !== strtolower($modSettings['paid_currency_code']))
285
-			exit;
298
+		if (strtolower($_POST['mc_currency']) !== strtolower($modSettings['paid_currency_code'])) {
299
+					exit;
300
+		}
286 301
 
287 302
 		// Can't exist if it doesn't contain anything.
288
-		if (empty($_POST['item_number']))
289
-			exit;
303
+		if (empty($_POST['item_number'])) {
304
+					exit;
305
+		}
290 306
 
291 307
 		// Return the id_sub and id_member
292 308
 		return explode('+', $_POST['item_number']);
@@ -299,10 +315,11 @@  discard block
 block discarded – undo
299 315
 	 */
300 316
 	public function isRefund()
301 317
 	{
302
-		if ($_POST['payment_status'] === 'Refunded' || $_POST['payment_status'] === 'Reversed' || $_POST['txn_type'] === 'Refunded' || ($_POST['txn_type'] === 'reversal' && $_POST['payment_status'] === 'Completed'))
303
-			return true;
304
-		else
305
-			return false;
318
+		if ($_POST['payment_status'] === 'Refunded' || $_POST['payment_status'] === 'Reversed' || $_POST['txn_type'] === 'Refunded' || ($_POST['txn_type'] === 'reversal' && $_POST['payment_status'] === 'Completed')) {
319
+					return true;
320
+		} else {
321
+					return false;
322
+		}
306 323
 	}
307 324
 
308 325
 	/**
@@ -312,10 +329,11 @@  discard block
 block discarded – undo
312 329
 	 */
313 330
 	public function isSubscription()
314 331
 	{
315
-		if (substr($_POST['txn_type'], 0, 14) === 'subscr_payment' && $_POST['payment_status'] === 'Completed')
316
-			return true;
317
-		else
318
-			return false;
332
+		if (substr($_POST['txn_type'], 0, 14) === 'subscr_payment' && $_POST['payment_status'] === 'Completed') {
333
+					return true;
334
+		} else {
335
+					return false;
336
+		}
319 337
 	}
320 338
 
321 339
 	/**
@@ -325,10 +343,11 @@  discard block
 block discarded – undo
325 343
 	 */
326 344
 	public function isPayment()
327 345
 	{
328
-		if ($_POST['payment_status'] === 'Completed' && $_POST['txn_type'] === 'web_accept')
329
-			return true;
330
-		else
331
-			return false;
346
+		if ($_POST['payment_status'] === 'Completed' && $_POST['txn_type'] === 'web_accept') {
347
+					return true;
348
+		} else {
349
+					return false;
350
+		}
332 351
 	}
333 352
 
334 353
 	/**
@@ -341,10 +360,11 @@  discard block
 block discarded – undo
341 360
 		// subscr_cancel is sent when the user cancels, subscr_eot is sent when the subscription reaches final payment
342 361
 		// Neither require us to *do* anything as per performCancel().
343 362
 		// subscr_eot, if sent, indicates an end of payments term.
344
-		if (substr($_POST['txn_type'], 0, 13) === 'subscr_cancel' || substr($_POST['txn_type'], 0, 10) === 'subscr_eot')
345
-			return true;
346
-		else
347
-			return false;
363
+		if (substr($_POST['txn_type'], 0, 13) === 'subscr_cancel' || substr($_POST['txn_type'], 0, 10) === 'subscr_eot') {
364
+					return true;
365
+		} else {
366
+					return false;
367
+		}
348 368
 	}
349 369
 
350 370
 	/**
@@ -409,8 +429,9 @@  discard block
 block discarded – undo
409 429
 		global $smcFunc;
410 430
 
411 431
 		// Assume we have this?
412
-		if (empty($_POST['subscr_id']))
413
-			return false;
432
+		if (empty($_POST['subscr_id'])) {
433
+					return false;
434
+		}
414 435
 
415 436
 		// Do we have this in the database?
416 437
 		$request = $smcFunc['db_query']('', '
@@ -439,11 +460,12 @@  discard block
 block discarded – undo
439 460
 						'payer_email' => $_POST['payer_email'],
440 461
 					)
441 462
 				);
442
-				if ($smcFunc['db_num_rows']($request) === 0)
443
-					return false;
463
+				if ($smcFunc['db_num_rows']($request) === 0) {
464
+									return false;
465
+				}
466
+			} else {
467
+							return false;
444 468
 			}
445
-			else
446
-				return false;
447 469
 		}
448 470
 		list ($member_id, $subscription_id) = $smcFunc['db_fetch_row']($request);
449 471
 		$_POST['item_number'] = $member_id . '+' . $subscription_id;
Please login to merge, or discard this patch.
Sources/Class-CurlFetchWeb.php 1 patch
Braces   +30 added lines, -24 removed lines patch added patch discarded remove patch
@@ -10,8 +10,9 @@  discard block
 block discarded – undo
10 10
  * @version 2.1 Beta 3
11 11
  */
12 12
 
13
-if (!defined('SMF'))
13
+if (!defined('SMF')) {
14 14
 	die('No direct access...');
15
+}
15 16
 
16 17
 /**
17 18
  * Class curl_fetch_web_data
@@ -87,10 +88,11 @@  discard block
 block discarded – undo
87 88
 	public function get_url_data($url, $post_data = array())
88 89
 	{
89 90
 		// POSTing some data perhaps?
90
-		if (!empty($post_data) && is_array($post_data))
91
-			$this->post_data = $this->build_post_data($post_data);
92
-		elseif (!empty($post_data))
93
-			$this->post_data = trim($post_data);
91
+		if (!empty($post_data) && is_array($post_data)) {
92
+					$this->post_data = $this->build_post_data($post_data);
93
+		} elseif (!empty($post_data)) {
94
+					$this->post_data = trim($post_data);
95
+		}
94 96
 
95 97
 		// set the options and get it
96 98
 		$this->set_options();
@@ -111,10 +113,11 @@  discard block
 block discarded – undo
111 113
 	private function curl_request($url, $redirect = false)
112 114
 	{
113 115
 		// we do have a url I hope
114
-		if ($url == '')
115
-			return false;
116
-		else
117
-			$this->options[CURLOPT_URL] = $url;
116
+		if ($url == '') {
117
+					return false;
118
+		} else {
119
+					$this->options[CURLOPT_URL] = $url;
120
+		}
118 121
 
119 122
 		// if we have not already been redirected, set it up so we can if needed
120 123
 		if (!$redirect)
@@ -194,10 +197,11 @@  discard block
 block discarded – undo
194 197
 		$max_result = count($this->response) - 1;
195 198
 
196 199
 		// just return a specifed area or the entire result?
197
-		if ($area == '')
198
-			return $this->response[$max_result];
199
-		else
200
-			return isset($this->response[$max_result][$area]) ? $this->response[$max_result][$area] : $this->response[$max_result];
200
+		if ($area == '') {
201
+					return $this->response[$max_result];
202
+		} else {
203
+					return isset($this->response[$max_result][$area]) ? $this->response[$max_result][$area] : $this->response[$max_result];
204
+		}
201 205
 	}
202 206
 
203 207
 	/**
@@ -210,9 +214,9 @@  discard block
 block discarded – undo
210 214
 	*/
211 215
 	public function result_raw($response_number = '')
212 216
 	{
213
-		if (!is_numeric($response_number))
214
-			return $this->response;
215
-		else
217
+		if (!is_numeric($response_number)) {
218
+					return $this->response;
219
+		} else
216 220
 		{
217 221
 			$response_number = min($response_number, count($this->response) - 1);
218 222
 			return $this->response[$response_number];
@@ -234,13 +238,14 @@  discard block
 block discarded – undo
234 238
 			$postvars = array();
235 239
 
236 240
 			// build the post data, drop ones with leading @'s since those can be used to send files, we don't support that.
237
-			foreach ($post_data as $name => $value)
238
-				$postvars[] = $name . '=' . urlencode($value[0] == '@' ? '' : $value);
241
+			foreach ($post_data as $name => $value) {
242
+							$postvars[] = $name . '=' . urlencode($value[0] == '@' ? '' : $value);
243
+			}
239 244
 
240 245
 			return implode('&', $postvars);
246
+		} else {
247
+					return $post_data;
241 248
 		}
242
-		else
243
-			return $post_data;
244 249
 
245 250
 	}
246 251
 
@@ -261,9 +266,9 @@  discard block
 block discarded – undo
261 266
 			$keys = array_merge(array_keys($this->default_options), array_keys($this->user_options));
262 267
 			$vals = array_merge($this->default_options, $this->user_options);
263 268
 			$this->options = array_combine($keys, $vals);
269
+		} else {
270
+					$this->options = $this->default_options;
264 271
 		}
265
-		else
266
-			$this->options = $this->default_options;
267 272
 
268 273
 		// POST data options, here we don't allow any overide
269 274
 		if (isset($this->post_data))
@@ -302,8 +307,9 @@  discard block
 block discarded – undo
302 307
 		$temp = explode(': ', $_header, 2);
303 308
 
304 309
 		// set proper headers only
305
-		if (isset($temp[0]) && isset($temp[1]))
306
-			$this->headers[strtolower($temp[0])] = strtolower(trim($temp[1]));
310
+		if (isset($temp[0]) && isset($temp[1])) {
311
+					$this->headers[strtolower($temp[0])] = strtolower(trim($temp[1]));
312
+		}
307 313
 
308 314
 		// return the length of what was passed unless you want a Failed writing header error ;)
309 315
 		return strlen($header);
Please login to merge, or discard this patch.
Sources/Notify.php 1 patch
Braces   +23 added lines, -20 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 3
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * Turn off/on notification for a particular board.
@@ -34,8 +35,9 @@  discard block
 block discarded – undo
34 35
 	is_not_guest();
35 36
 
36 37
 	// You have to specify a board to turn notifications on!
37
-	if (empty($board))
38
-		fatal_lang_error('no_board', false);
38
+	if (empty($board)) {
39
+			fatal_lang_error('no_board', false);
40
+	}
39 41
 
40 42
 	// No subaction: find out what to do.
41 43
 	if (isset($_GET['mode']))
@@ -48,16 +50,16 @@  discard block
 block discarded – undo
48 50
 		require_once($sourcedir . '/Subs-Notify.php');
49 51
 		setNotifyPrefs($user_info['id'], array('board_notify_' . $board => $alertPref));
50 52
 
51
-		if ($mode > 1)
52
-			// Turn notification on.  (note this just blows smoke if it's already on.)
53
+		if ($mode > 1) {
54
+					// Turn notification on.  (note this just blows smoke if it's already on.)
53 55
 			$smcFunc['db_insert']('ignore',
54 56
 				'{db_prefix}log_notify',
55 57
 				array('id_member' => 'int', 'id_board' => 'int'),
56 58
 				array($user_info['id'], $board),
57 59
 				array('id_member', 'id_board')
58 60
 			);
59
-		else
60
-			$smcFunc['db_query']('', '
61
+		} else {
62
+					$smcFunc['db_query']('', '
61 63
 				DELETE FROM {db_prefix}log_notify
62 64
 				WHERE id_member = {int:current_member}
63 65
 				AND id_board = {int:current_board}',
@@ -66,6 +68,7 @@  discard block
 block discarded – undo
66 68
 					'current_member' => $user_info['id'],
67 69
 				)
68 70
 			);
71
+		}
69 72
 
70 73
 	}
71 74
 
@@ -81,10 +84,10 @@  discard block
 block discarded – undo
81 84
 			),
82 85
 		);
83 86
 		$context['sub_template'] = 'generic_xml';
87
+	} else {
88
+			redirectexit('board=' . $board . '.' . $_REQUEST['start']);
89
+	}
84 90
 	}
85
-	else
86
-		redirectexit('board=' . $board . '.' . $_REQUEST['start']);
87
-}
88 91
 
89 92
 /**
90 93
  * Turn off/on unread replies subscription for a topic as well as sets individual topic's alert preferences
@@ -108,8 +111,9 @@  discard block
 block discarded – undo
108 111
 			$mode = (int) $_GET['mode'];
109 112
 			$alertPref = $mode <= 1 ? 0 : ($mode == 2 ? 1 : 3);
110 113
 
111
-			if (empty($mode))
112
-				$mode = 1;
114
+			if (empty($mode)) {
115
+							$mode = 1;
116
+			}
113 117
 
114 118
 			$request = $smcFunc['db_query']('', '
115 119
 				SELECT id_member, id_topic, id_msg, unwatched
@@ -132,8 +136,7 @@  discard block
 block discarded – undo
132 136
 					'id_msg' => 0,
133 137
 					'unwatched' => empty($mode) ? 1 : 0,
134 138
 				);
135
-			}
136
-			else
139
+			} else
137 140
 			{
138 141
 				$insert = false;
139 142
 				$log['unwatched'] = empty($mode) ? 1 : 0;
@@ -160,9 +163,8 @@  discard block
 block discarded – undo
160 163
 					array($user_info['id'], $log['id_topic']),
161 164
 					array('id_member', 'id_board')
162 165
 				);
163
-			}
164
-			else
165
-				$smcFunc['db_query']('', '
166
+			} else {
167
+							$smcFunc['db_query']('', '
166 168
 					DELETE FROM {db_prefix}log_notify
167 169
 					WHERE id_topic = {int:topic}
168 170
 						AND id_member = {int:member}',
@@ -170,6 +172,7 @@  discard block
 block discarded – undo
170 172
 						'topic' => $log['id_topic'],
171 173
 						'member' => $user_info['id'],
172 174
 					));
175
+			}
173 176
 
174 177
 		}
175 178
 	}
@@ -186,9 +189,9 @@  discard block
 block discarded – undo
186 189
 			),
187 190
 		);
188 191
 		$context['sub_template'] = 'generic_xml';
192
+	} else {
193
+			redirectexit('topic=' . $topic . '.' . $_REQUEST['start']);
194
+	}
189 195
 	}
190
-	else
191
-		redirectexit('topic=' . $topic . '.' . $_REQUEST['start']);
192
-}
193 196
 
194 197
 ?>
195 198
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/RepairBoards.php 1 patch
Braces   +119 added lines, -85 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Finds or repairs errors in the database to fix possible problems.
@@ -50,8 +51,9 @@  discard block
 block discarded – undo
50 51
 	);
51 52
 
52 53
 	// Start displaying errors without fixing them.
53
-	if (isset($_GET['fixErrors']))
54
-		checkSession('get');
54
+	if (isset($_GET['fixErrors'])) {
55
+			checkSession('get');
56
+	}
55 57
 
56 58
 	// Will want this.
57 59
 	loadForumTests();
@@ -69,11 +71,11 @@  discard block
 block discarded – undo
69 71
 			$_SESSION['repairboards_to_fix'] = $context['to_fix'];
70 72
 			$_SESSION['repairboards_to_fix2'] = null;
71 73
 
72
-			if (empty($context['repair_errors']))
73
-				$context['repair_errors'][] = '???';
74
+			if (empty($context['repair_errors'])) {
75
+							$context['repair_errors'][] = '???';
76
+			}
74 77
 		}
75
-	}
76
-	else
78
+	} else
77 79
 	{
78 80
 		$context['error_search'] = false;
79 81
 		$context['to_fix'] = isset($_SESSION['repairboards_to_fix']) ? $_SESSION['repairboards_to_fix'] : array();
@@ -120,16 +122,19 @@  discard block
 block discarded – undo
120 122
 
121 123
 	// More time, I need more time!
122 124
 	@set_time_limit(600);
123
-	if (function_exists('apache_reset_timeout'))
124
-		@apache_reset_timeout();
125
+	if (function_exists('apache_reset_timeout')) {
126
+			@apache_reset_timeout();
127
+	}
125 128
 
126 129
 	// Errr, wait.  How much time has this taken already?
127
-	if (!$force && time() - array_sum(explode(' ', $time_start)) < 3)
128
-		return;
130
+	if (!$force && time() - array_sum(explode(' ', $time_start)) < 3) {
131
+			return;
132
+	}
129 133
 
130 134
 	// Restore the query cache if interested.
131
-	if (!empty($db_temp_cache))
132
-		$db_cache = $db_temp_cache;
135
+	if (!empty($db_temp_cache)) {
136
+			$db_cache = $db_temp_cache;
137
+	}
133 138
 
134 139
 	$context['continue_get_data'] = '?action=admin;area=repairboards' . (isset($_GET['fixErrors']) ? ';fixErrors' : '') . ';step=' . $_GET['step'] . ';substep=' . $_GET['substep'] . ';' . $context['session_var'] . '=' . $context['session_id'];
135 140
 	$context['page_title'] = $txt['not_done_title'];
@@ -138,10 +143,11 @@  discard block
 block discarded – undo
138 143
 	$context['sub_template'] = 'not_done';
139 144
 
140 145
 	// Change these two if more steps are added!
141
-	if (empty($max_substep))
142
-		$context['continue_percent'] = round(($_GET['step'] * 100) / $context['total_steps']);
143
-	else
144
-		$context['continue_percent'] = round((($_GET['step'] + ($_GET['substep'] / $max_substep)) * 100) / $context['total_steps']);
146
+	if (empty($max_substep)) {
147
+			$context['continue_percent'] = round(($_GET['step'] * 100) / $context['total_steps']);
148
+	} else {
149
+			$context['continue_percent'] = round((($_GET['step'] + ($_GET['substep'] / $max_substep)) * 100) / $context['total_steps']);
150
+	}
145 151
 
146 152
 	// Never more than 100%!
147 153
 	$context['continue_percent'] = min($context['continue_percent'], 100);
@@ -617,8 +623,9 @@  discard block
 block discarded – undo
617 623
 				$row['myid_last_msg'] = (int) $row['myid_last_msg'];
618 624
 
619 625
 				// Not really a problem?
620
-				if ($row['myid_first_msg'] == $row['myid_first_msg'] && $row['myid_first_msg'] == $row['myid_first_msg'] && $row['approved'] == $row['firstmsg_approved'])
621
-					return false;
626
+				if ($row['myid_first_msg'] == $row['myid_first_msg'] && $row['myid_first_msg'] == $row['myid_first_msg'] && $row['approved'] == $row['firstmsg_approved']) {
627
+									return false;
628
+				}
622 629
 
623 630
 				$memberStartedID = (int) getMsgMemberID($row['myid_first_msg']);
624 631
 				$memberUpdatedID = (int) getMsgMemberID($row['myid_last_msg']);
@@ -642,15 +649,19 @@  discard block
 block discarded – undo
642 649
 			'message_function' => function ($row) use ($txt, &$context)
643 650
 			{
644 651
 				// A pretend error?
645
-				if ($row['myid_first_msg'] == $row['myid_first_msg'] && $row['myid_first_msg'] == $row['myid_first_msg'] && $row['approved'] == $row['firstmsg_approved'])
646
-					return false;
652
+				if ($row['myid_first_msg'] == $row['myid_first_msg'] && $row['myid_first_msg'] == $row['myid_first_msg'] && $row['approved'] == $row['firstmsg_approved']) {
653
+									return false;
654
+				}
647 655
 
648
-				if ($row['id_first_msg'] != $row['myid_first_msg'])
649
-					$context['repair_errors'][] = sprintf($txt['repair_stats_topics_1'], $row['id_topic'], $row['id_first_msg']);
650
-				if ($row['id_last_msg'] != $row['myid_last_msg'])
651
-					$context['repair_errors'][] = sprintf($txt['repair_stats_topics_2'], $row['id_topic'], $row['id_last_msg']);
652
-				if ($row['approved'] != $row['firstmsg_approved'])
653
-					$context['repair_errors'][] = sprintf($txt['repair_stats_topics_5'], $row['id_topic']);
656
+				if ($row['id_first_msg'] != $row['myid_first_msg']) {
657
+									$context['repair_errors'][] = sprintf($txt['repair_stats_topics_1'], $row['id_topic'], $row['id_first_msg']);
658
+				}
659
+				if ($row['id_last_msg'] != $row['myid_last_msg']) {
660
+									$context['repair_errors'][] = sprintf($txt['repair_stats_topics_2'], $row['id_topic'], $row['id_last_msg']);
661
+				}
662
+				if ($row['approved'] != $row['firstmsg_approved']) {
663
+									$context['repair_errors'][] = sprintf($txt['repair_stats_topics_5'], $row['id_topic']);
664
+				}
654 665
 
655 666
 				return true;
656 667
 			},
@@ -680,8 +691,9 @@  discard block
 block discarded – undo
680 691
 				$row['my_num_replies'] = (int) $row['my_num_replies'];
681 692
 
682 693
 				// Not really a problem?
683
-				if ($row['my_num_replies'] == $row['num_replies'])
684
-					return false;
694
+				if ($row['my_num_replies'] == $row['num_replies']) {
695
+									return false;
696
+				}
685 697
 
686 698
 				$smcFunc['db_query']('', '
687 699
 					UPDATE {db_prefix}topics
@@ -700,11 +712,13 @@  discard block
 block discarded – undo
700 712
 				global $txt, $context;
701 713
 
702 714
 				// Just joking?
703
-				if ($row['my_num_replies'] == $row['num_replies'])
704
-					return false;
715
+				if ($row['my_num_replies'] == $row['num_replies']) {
716
+									return false;
717
+				}
705 718
 
706
-				if ($row['num_replies'] != $row['my_num_replies'])
707
-					$context['repair_errors'][] = sprintf($txt['repair_stats_topics_3'], $row['id_topic'], $row['num_replies']);
719
+				if ($row['num_replies'] != $row['my_num_replies']) {
720
+									$context['repair_errors'][] = sprintf($txt['repair_stats_topics_3'], $row['id_topic'], $row['num_replies']);
721
+				}
708 722
 
709 723
 				return true;
710 724
 
@@ -1295,8 +1309,9 @@  discard block
 block discarded – undo
1295 1309
 				$inserts = array();
1296 1310
 				while ($row = $smcFunc['db_fetch_assoc']($result))
1297 1311
 				{
1298
-					foreach (text2words($row['subject']) as $word)
1299
-						$inserts[] = array($word, $row['id_topic']);
1312
+					foreach (text2words($row['subject']) as $word) {
1313
+											$inserts[] = array($word, $row['id_topic']);
1314
+					}
1300 1315
 					if (count($inserts) > 500)
1301 1316
 					{
1302 1317
 						$smcFunc['db_insert']('ignore',
@@ -1310,13 +1325,14 @@  discard block
 block discarded – undo
1310 1325
 
1311 1326
 				}
1312 1327
 
1313
-				if (!empty($inserts))
1314
-					$smcFunc['db_insert']('ignore',
1328
+				if (!empty($inserts)) {
1329
+									$smcFunc['db_insert']('ignore',
1315 1330
 						'{db_prefix}log_search_subjects',
1316 1331
 						array('word' => 'string', 'id_topic' => 'int'),
1317 1332
 						$inserts,
1318 1333
 						array('word', 'id_topic')
1319 1334
 					);
1335
+				}
1320 1336
 
1321 1337
 		},
1322 1338
 			'message_function' => function ($row)
@@ -1586,8 +1602,9 @@  discard block
 block discarded – undo
1586 1602
 		$current_step++;
1587 1603
 
1588 1604
 		// Already done this?
1589
-		if ($_GET['step'] > $current_step)
1590
-			continue;
1605
+		if ($_GET['step'] > $current_step) {
1606
+					continue;
1607
+		}
1591 1608
 
1592 1609
 		// If we're fixing it but it ain't broke why try?
1593 1610
 		if ($do_fix && !in_array($error_type, $to_fix))
@@ -1616,14 +1633,16 @@  discard block
 block discarded – undo
1616 1633
 		while (!$done)
1617 1634
 		{
1618 1635
 			// Make sure there's at least one ID to test.
1619
-			if (isset($test['substeps']) && empty($step_max))
1620
-				break;
1636
+			if (isset($test['substeps']) && empty($step_max)) {
1637
+							break;
1638
+			}
1621 1639
 
1622 1640
 			// What is the testing query (Changes if we are testing or fixing)
1623
-			if (!$do_fix)
1624
-				$test_query = 'check_query';
1625
-			else
1626
-				$test_query = isset($test['fix_query']) ? 'fix_query' : 'check_query';
1641
+			if (!$do_fix) {
1642
+							$test_query = 'check_query';
1643
+			} else {
1644
+							$test_query = isset($test['fix_query']) ? 'fix_query' : 'check_query';
1645
+			}
1627 1646
 
1628 1647
 			// Do the test...
1629 1648
 			$request = $smcFunc['db_query']('',
@@ -1634,10 +1653,11 @@  discard block
 block discarded – undo
1634 1653
 			$needs_fix = false;
1635 1654
 
1636 1655
 			// Does it need a fix?
1637
-			if (!empty($test['check_type']) && $test['check_type'] == 'count')
1638
-				list ($needs_fix) = $smcFunc['db_fetch_row']($request);
1639
-			else
1640
-				$needs_fix = $smcFunc['db_num_rows']($request);
1656
+			if (!empty($test['check_type']) && $test['check_type'] == 'count') {
1657
+							list ($needs_fix) = $smcFunc['db_fetch_row']($request);
1658
+			} else {
1659
+							$needs_fix = $smcFunc['db_num_rows']($request);
1660
+			}
1641 1661
 
1642 1662
 			$total_queries++;
1643 1663
 
@@ -1649,8 +1669,9 @@  discard block
 block discarded – undo
1649 1669
 					// Assume need to fix.
1650 1670
 					$found_errors = true;
1651 1671
 
1652
-					if (isset($test['message']))
1653
-						$context['repair_errors'][] = $txt[$test['message']];
1672
+					if (isset($test['message'])) {
1673
+											$context['repair_errors'][] = $txt[$test['message']];
1674
+					}
1654 1675
 
1655 1676
 					// One per row!
1656 1677
 					elseif (isset($test['messages']))
@@ -1660,10 +1681,11 @@  discard block
 block discarded – undo
1660 1681
 							$variables = $test['messages'];
1661 1682
 							foreach ($variables as $k => $v)
1662 1683
 							{
1663
-								if ($k == 0 && isset($txt[$v]))
1664
-									$variables[$k] = $txt[$v];
1665
-								elseif ($k > 0 && isset($row[$v]))
1666
-									$variables[$k] = $row[$v];
1684
+								if ($k == 0 && isset($txt[$v])) {
1685
+																	$variables[$k] = $txt[$v];
1686
+								} elseif ($k > 0 && isset($row[$v])) {
1687
+																	$variables[$k] = $row[$v];
1688
+								}
1667 1689
 							}
1668 1690
 							$context['repair_errors'][] = call_user_func_array('sprintf', $variables);
1669 1691
 						}
@@ -1674,13 +1696,15 @@  discard block
 block discarded – undo
1674 1696
 					{
1675 1697
 						// Find out if there are actually errors.
1676 1698
 						$found_errors = false;
1677
-						while ($row = $smcFunc['db_fetch_assoc']($request))
1678
-							$found_errors |= $test['message_function']($row);
1699
+						while ($row = $smcFunc['db_fetch_assoc']($request)) {
1700
+													$found_errors |= $test['message_function']($row);
1701
+						}
1679 1702
 					}
1680 1703
 
1681 1704
 					// Actually have something to fix?
1682
-					if ($found_errors)
1683
-						$to_fix[] = $error_type;
1705
+					if ($found_errors) {
1706
+											$to_fix[] = $error_type;
1707
+					}
1684 1708
 				}
1685 1709
 
1686 1710
 				// We want to fix, we need to fix - so work out what exactly to do!
@@ -1690,8 +1714,9 @@  discard block
 block discarded – undo
1690 1714
 					if (isset($test['fix_collect']))
1691 1715
 					{
1692 1716
 						$ids = array();
1693
-						while ($row = $smcFunc['db_fetch_assoc']($request))
1694
-							$ids[] = $row[$test['fix_collect']['index']];
1717
+						while ($row = $smcFunc['db_fetch_assoc']($request)) {
1718
+													$ids[] = $row[$test['fix_collect']['index']];
1719
+						}
1695 1720
 						if (!empty($ids))
1696 1721
 						{
1697 1722
 							// Fix it!
@@ -1700,30 +1725,34 @@  discard block
 block discarded – undo
1700 1725
 					}
1701 1726
 
1702 1727
 					// Simply executing a fix it query?
1703
-					elseif (isset($test['fix_it_query']))
1704
-						$smcFunc['db_query']('',
1728
+					elseif (isset($test['fix_it_query'])) {
1729
+											$smcFunc['db_query']('',
1705 1730
 							$test['fix_it_query'],
1706 1731
 							array(
1707 1732
 							)
1708 1733
 						);
1734
+					}
1709 1735
 
1710 1736
 					// Do we have some processing to do?
1711 1737
 					elseif (isset($test['fix_processing']))
1712 1738
 					{
1713
-						while ($row = $smcFunc['db_fetch_assoc']($request))
1714
-							$test['fix_processing']($row);
1739
+						while ($row = $smcFunc['db_fetch_assoc']($request)) {
1740
+													$test['fix_processing']($row);
1741
+						}
1715 1742
 					}
1716 1743
 
1717 1744
 					// What about the full set of processing?
1718
-					elseif (isset($test['fix_full_processing']))
1719
-						$test['fix_full_processing']($request);
1745
+					elseif (isset($test['fix_full_processing'])) {
1746
+											$test['fix_full_processing']($request);
1747
+					}
1720 1748
 
1721 1749
 					// Do we have other things we need to fix as a result?
1722 1750
 					if (!empty($test['force_fix']))
1723 1751
 					{
1724
-						foreach ($test['force_fix'] as $item)
1725
-							if (!in_array($item, $to_fix))
1752
+						foreach ($test['force_fix'] as $item) {
1753
+													if (!in_array($item, $to_fix))
1726 1754
 								$to_fix[] = $item;
1755
+						}
1727 1756
 					}
1728 1757
 				}
1729 1758
 			}
@@ -1741,16 +1770,17 @@  discard block
 block discarded – undo
1741 1770
 				if ($_GET['substep'] <= $step_max)
1742 1771
 				{
1743 1772
 					pauseRepairProcess($to_fix, $error_type, $step_max);
1773
+				} else {
1774
+									$done = true;
1744 1775
 				}
1745
-				else
1746
-					$done = true;
1776
+			} else {
1777
+							$done = true;
1747 1778
 			}
1748
-			else
1749
-				$done = true;
1750 1779
 
1751 1780
 			// Don't allow more than 1000 queries at a time.
1752
-			if ($total_queries >= 1000)
1753
-				pauseRepairProcess($to_fix, $error_type, $step_max, true);
1781
+			if ($total_queries >= 1000) {
1782
+							pauseRepairProcess($to_fix, $error_type, $step_max, true);
1783
+			}
1754 1784
 		}
1755 1785
 
1756 1786
 		// Keep going.
@@ -1763,8 +1793,9 @@  discard block
 block discarded – undo
1763 1793
 		if ($do_fix)
1764 1794
 		{
1765 1795
 			$key = array_search($error_type, $to_fix);
1766
-			if ($key !== false && isset($to_fix[$key]))
1767
-				unset($to_fix[$key]);
1796
+			if ($key !== false && isset($to_fix[$key])) {
1797
+							unset($to_fix[$key]);
1798
+			}
1768 1799
 		}
1769 1800
 
1770 1801
 		// Are we done?
@@ -1787,10 +1818,11 @@  discard block
 block discarded – undo
1787 1818
 	static $createOnce = false;
1788 1819
 
1789 1820
 	// Have we already created it?
1790
-	if ($createOnce)
1791
-		return;
1792
-	else
1793
-		$createOnce = true;
1821
+	if ($createOnce) {
1822
+			return;
1823
+	} else {
1824
+			$createOnce = true;
1825
+	}
1794 1826
 
1795 1827
 	// Back to the forum's default language.
1796 1828
 	loadLanguage('Admin', $language);
@@ -1805,8 +1837,9 @@  discard block
 block discarded – undo
1805 1837
 			'cat_name' => $txt['salvaged_category_name'],
1806 1838
 		)
1807 1839
 	);
1808
-	if ($smcFunc['db_num_rows']($result) != 0)
1809
-		list ($salvageCatID) = $smcFunc['db_fetch_row']($result);
1840
+	if ($smcFunc['db_num_rows']($result) != 0) {
1841
+			list ($salvageCatID) = $smcFunc['db_fetch_row']($result);
1842
+	}
1810 1843
 	$smcFunc['db_free_result']($result);
1811 1844
 
1812 1845
 	if (empty($salvageCatID))
@@ -1839,8 +1872,9 @@  discard block
 block discarded – undo
1839 1872
 			'board_name' => $txt['salvaged_board_name'],
1840 1873
 		)
1841 1874
 	);
1842
-	if ($smcFunc['db_num_rows']($result) != 0)
1843
-		list ($salvageBoardID) = $smcFunc['db_fetch_row']($result);
1875
+	if ($smcFunc['db_num_rows']($result) != 0) {
1876
+			list ($salvageBoardID) = $smcFunc['db_fetch_row']($result);
1877
+	}
1844 1878
 	$smcFunc['db_free_result']($result);
1845 1879
 
1846 1880
 	if (empty($salvageBoardID))
Please login to merge, or discard this patch.
Sources/Xml.php 1 patch
Braces   +55 added lines, -42 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
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 handler and designator for AJAX stuff - jumpto, message icons and previews
@@ -32,8 +33,9 @@  discard block
 block discarded – undo
32 33
 	// Easy adding of sub actions.
33 34
 	call_integration_hook('integrate_XMLhttpMain_subActions', array(&$subActions));
34 35
 
35
-	if (!isset($_REQUEST['sa'], $subActions[$_REQUEST['sa']]))
36
-		fatal_lang_error('no_access', false);
36
+	if (!isset($_REQUEST['sa'], $subActions[$_REQUEST['sa']])) {
37
+			fatal_lang_error('no_access', false);
38
+	}
37 39
 
38 40
 	call_helper($subActions[$_REQUEST['sa']]);
39 41
 }
@@ -57,8 +59,9 @@  discard block
 block discarded – undo
57 59
 	foreach ($context['jump_to'] as $id_cat => $cat)
58 60
 	{
59 61
 		$context['jump_to'][$id_cat]['name'] = un_htmlspecialchars(strip_tags($cat['name']));
60
-		foreach ($cat['boards'] as $id_board => $board)
61
-			$context['jump_to'][$id_cat]['boards'][$id_board]['name'] = un_htmlspecialchars(strip_tags($board['name']));
62
+		foreach ($cat['boards'] as $id_board => $board) {
63
+					$context['jump_to'][$id_cat]['boards'][$id_board]['name'] = un_htmlspecialchars(strip_tags($board['name']));
64
+		}
62 65
 	}
63 66
 
64 67
 	$context['sub_template'] = 'jump_to';
@@ -95,8 +98,9 @@  discard block
 block discarded – undo
95 98
 
96 99
 	$context['sub_template'] = 'generic_xml';
97 100
 
98
-	if (!isset($_POST['item']) || !in_array($_POST['item'], $items))
99
-		return false;
101
+	if (!isset($_POST['item']) || !in_array($_POST['item'], $items)) {
102
+			return false;
103
+	}
100 104
 
101 105
 	$_POST['item']();
102 106
 }
@@ -112,10 +116,11 @@  discard block
 block discarded – undo
112 116
 
113 117
 	$errors = array();
114 118
 	$news = !isset($_POST['news'])? '' : $smcFunc['htmlspecialchars']($_POST['news'], ENT_QUOTES);
115
-	if (empty($news))
116
-		$errors[] = array('value' => 'no_news');
117
-	else
118
-		preparsecode($news);
119
+	if (empty($news)) {
120
+			$errors[] = array('value' => 'no_news');
121
+	} else {
122
+			preparsecode($news);
123
+	}
119 124
 
120 125
 	$context['xml_data'] = array(
121 126
 		'news' => array(
@@ -148,10 +153,12 @@  discard block
 block discarded – undo
148 153
 	$context['send_pm'] = !empty($_POST['send_pm']) ? 1 : 0;
149 154
 	$context['send_html'] = !empty($_POST['send_html']) ? 1 : 0;
150 155
 
151
-	if (empty($_POST['subject']))
152
-		$context['post_error']['messages'][] = $txt['error_no_subject'];
153
-	if (empty($_POST['message']))
154
-		$context['post_error']['messages'][] = $txt['error_no_message'];
156
+	if (empty($_POST['subject'])) {
157
+			$context['post_error']['messages'][] = $txt['error_no_subject'];
158
+	}
159
+	if (empty($_POST['message'])) {
160
+			$context['post_error']['messages'][] = $txt['error_no_message'];
161
+	}
155 162
 
156 163
 	prepareMailingForPreview();
157 164
 
@@ -196,38 +203,41 @@  discard block
 block discarded – undo
196 203
 		$preview_signature = !empty($_POST['signature']) ? $_POST['signature'] : $txt['no_signature_preview'];
197 204
 		$validation = profileValidateSignature($preview_signature);
198 205
 
199
-		if ($validation !== true && $validation !== false)
200
-			$errors[] = array('value' => $txt['profile_error_' . $validation], 'attributes' => array('type' => 'error'));
206
+		if ($validation !== true && $validation !== false) {
207
+					$errors[] = array('value' => $txt['profile_error_' . $validation], 'attributes' => array('type' => 'error'));
208
+		}
201 209
 
202 210
 		censorText($preview_signature);
203 211
 		$preview_signature = parse_bbc($preview_signature, true, 'sig' . $user);
204
-	}
205
-	elseif (!$can_change)
212
+	} elseif (!$can_change)
206 213
 	{
207
-		if ($is_owner)
208
-			$errors[] = array('value' => $txt['cannot_profile_extra_own'], 'attributes' => array('type' => 'error'));
209
-		else
210
-			$errors[] = array('value' => $txt['cannot_profile_extra_any'], 'attributes' => array('type' => 'error'));
214
+		if ($is_owner) {
215
+					$errors[] = array('value' => $txt['cannot_profile_extra_own'], 'attributes' => array('type' => 'error'));
216
+		} else {
217
+					$errors[] = array('value' => $txt['cannot_profile_extra_any'], 'attributes' => array('type' => 'error'));
218
+		}
219
+	} else {
220
+			$errors[] = array('value' => $txt['no_user_selected'], 'attributes' => array('type' => 'error'));
211 221
 	}
212
-	else
213
-		$errors[] = array('value' => $txt['no_user_selected'], 'attributes' => array('type' => 'error'));
214 222
 
215 223
 	$context['xml_data']['signatures'] = array(
216 224
 			'identifier' => 'signature',
217 225
 			'children' => array()
218 226
 		);
219
-	if (isset($current_signature))
220
-		$context['xml_data']['signatures']['children'][] = array(
227
+	if (isset($current_signature)) {
228
+			$context['xml_data']['signatures']['children'][] = array(
221 229
 					'value' => $current_signature,
222 230
 					'attributes' => array('type' => 'current'),
223 231
 				);
224
-	if (isset($preview_signature))
225
-		$context['xml_data']['signatures']['children'][] = array(
232
+	}
233
+	if (isset($preview_signature)) {
234
+			$context['xml_data']['signatures']['children'][] = array(
226 235
 					'value' => $preview_signature,
227 236
 					'attributes' => array('type' => 'preview'),
228 237
 				);
229
-	if (!empty($errors))
230
-		$context['xml_data']['errors'] = array(
238
+	}
239
+	if (!empty($errors)) {
240
+			$context['xml_data']['errors'] = array(
231 241
 			'identifier' => 'error',
232 242
 			'children' => array_merge(
233 243
 				array(
@@ -239,7 +249,8 @@  discard block
 block discarded – undo
239 249
 				$errors
240 250
 			),
241 251
 		);
242
-}
252
+	}
253
+	}
243 254
 
244 255
 /**
245 256
  * Handles previewing user warnings
@@ -261,15 +272,17 @@  discard block
 block discarded – undo
261 272
 		$context['preview_subject'] = !empty($_POST['title']) ? trim($smcFunc['htmlspecialchars']($_POST['title'])) : '';
262 273
 		if (isset($_POST['issuing']))
263 274
 		{
264
-			if (empty($_POST['title']) || empty($_POST['body']))
265
-				$context['post_error']['messages'][] = $txt['warning_notify_blank'];
266
-		}
267
-		else
275
+			if (empty($_POST['title']) || empty($_POST['body'])) {
276
+							$context['post_error']['messages'][] = $txt['warning_notify_blank'];
277
+			}
278
+		} else
268 279
 		{
269
-			if (empty($_POST['title']))
270
-				$context['post_error']['messages'][] = $txt['mc_warning_template_error_no_title'];
271
-			if (empty($_POST['body']))
272
-				$context['post_error']['messages'][] = $txt['mc_warning_template_error_no_body'];
280
+			if (empty($_POST['title'])) {
281
+							$context['post_error']['messages'][] = $txt['mc_warning_template_error_no_title'];
282
+			}
283
+			if (empty($_POST['body'])) {
284
+							$context['post_error']['messages'][] = $txt['mc_warning_template_error_no_body'];
285
+			}
273 286
 			// Add in few replacements.
274 287
 			/**
275 288
 			* These are the defaults:
@@ -300,9 +313,9 @@  discard block
 block discarded – undo
300 313
 			$warning_body = parse_bbc($warning_body, true);
301 314
 		}
302 315
 		$context['preview_message'] = $warning_body;
316
+	} else {
317
+			$context['post_error']['messages'][] = array('value' => $txt['cannot_issue_warning'], 'attributes' => array('type' => 'error'));
303 318
 	}
304
-	else
305
-		$context['post_error']['messages'][] = array('value' => $txt['cannot_issue_warning'], 'attributes' => array('type' => 'error'));
306 319
 
307 320
 	$context['sub_template'] = 'warning';
308 321
 }
Please login to merge, or discard this patch.
Sources/DbSearch-mysql.php 1 patch
Braces   +13 added lines, -10 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
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
  *  Add the file functions to the $smcFunc array.
@@ -23,14 +24,15 @@  discard block
 block discarded – undo
23 24
 {
24 25
 	global $smcFunc;
25 26
 
26
-	if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_query')
27
-		$smcFunc += array(
27
+	if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_query') {
28
+			$smcFunc += array(
28 29
 			'db_search_query' => 'smf_db_query',
29 30
 			'db_search_support' => 'smf_db_search_support',
30 31
 			'db_create_word_search' => 'smf_db_create_word_search',
31 32
 			'db_support_ignore' => true,
32 33
 		);
33
-}
34
+	}
35
+	}
34 36
 
35 37
 /**
36 38
  * This function will tell you whether this database type supports this search type.
@@ -54,12 +56,13 @@  discard block
 block discarded – undo
54 56
 {
55 57
 	global $smcFunc;
56 58
 
57
-	if ($size == 'small')
58
-		$size = 'smallint(5)';
59
-	elseif ($size == 'medium')
60
-		$size = 'mediumint(8)';
61
-	else
62
-		$size = 'int(10)';
59
+	if ($size == 'small') {
60
+			$size = 'smallint(5)';
61
+	} elseif ($size == 'medium') {
62
+			$size = 'mediumint(8)';
63
+	} else {
64
+			$size = 'int(10)';
65
+	}
63 66
 
64 67
 	$smcFunc['db_query']('', '
65 68
 		CREATE TABLE {db_prefix}log_search_words (
Please login to merge, or discard this patch.
Sources/SearchAPI-Fulltext.php 1 patch
Braces   +44 added lines, -34 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
  * @version 2.1 Beta 3
12 12
  */
13 13
 
14
-if (!defined('SMF'))
14
+if (!defined('SMF')) {
15 15
 	die('No direct access...');
16
+}
16 17
 
17 18
 /**
18 19
  * Class fulltext_search
@@ -98,8 +99,9 @@  discard block
 block discarded – undo
98 99
 			$smcFunc['db_free_result']($request);
99 100
 		}
100 101
 		// 4 is the MySQL default...
101
-		else
102
-			$min_word_length = 4;
102
+		else {
103
+					$min_word_length = 4;
104
+		}
103 105
 
104 106
 		return $min_word_length;
105 107
 	}
@@ -138,8 +140,7 @@  discard block
 block discarded – undo
138 140
 					$wordsSearch['words'][] = trim($word, "/*- ");
139 141
 					$wordsSearch['complex_words'][] = count($subwords) === 1 ? $word : '"' . $word . '"';
140 142
 				}
141
-			}
142
-			elseif ($smcFunc['strlen'](trim($word, "/*- ")) < $this->min_word_length)
143
+			} elseif ($smcFunc['strlen'](trim($word, "/*- ")) < $this->min_word_length)
143 144
 			{
144 145
 				// short words have feelings too
145 146
 				$wordsSearch['words'][] = trim($word, "/*- ");
@@ -149,8 +150,9 @@  discard block
 block discarded – undo
149 150
 
150 151
 		$fulltextWord = count($subwords) === 1 ? $word : '"' . $word . '"';
151 152
 		$wordsSearch['indexed_words'][] = $fulltextWord;
152
-		if ($isExcluded)
153
-			$wordsExclude[] = $fulltextWord;
153
+		if ($isExcluded) {
154
+					$wordsExclude[] = $fulltextWord;
155
+		}
154 156
 	}
155 157
 
156 158
 	/**
@@ -166,41 +168,50 @@  discard block
 block discarded – undo
166 168
 		$query_where = array();
167 169
 		$query_params = $search_data['params'];
168 170
 
169
-		if ($query_params['id_search'])
170
-			$query_select['id_search'] = '{int:id_search}';
171
+		if ($query_params['id_search']) {
172
+					$query_select['id_search'] = '{int:id_search}';
173
+		}
171 174
 
172 175
 		$count = 0;
173
-		if (empty($modSettings['search_simple_fulltext']))
174
-			foreach ($words['words'] as $regularWord)
176
+		if (empty($modSettings['search_simple_fulltext'])) {
177
+					foreach ($words['words'] as $regularWord)
175 178
 			{
176 179
 				$query_where[] = 'm.body' . (in_array($regularWord, $query_params['excluded_words']) ? ' NOT' : '') . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:complex_body_' . $count . '}';
180
+		}
177 181
 				$query_params['complex_body_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]';
178 182
 			}
179 183
 
180
-		if ($query_params['user_query'])
181
-			$query_where[] = '{raw:user_query}';
182
-		if ($query_params['board_query'])
183
-			$query_where[] = 'm.id_board {raw:board_query}';
184
+		if ($query_params['user_query']) {
185
+					$query_where[] = '{raw:user_query}';
186
+		}
187
+		if ($query_params['board_query']) {
188
+					$query_where[] = 'm.id_board {raw:board_query}';
189
+		}
184 190
 
185
-		if ($query_params['topic'])
186
-			$query_where[] = 'm.id_topic = {int:topic}';
187
-		if ($query_params['min_msg_id'])
188
-			$query_where[] = 'm.id_msg >= {int:min_msg_id}';
189
-		if ($query_params['max_msg_id'])
190
-			$query_where[] = 'm.id_msg <= {int:max_msg_id}';
191
+		if ($query_params['topic']) {
192
+					$query_where[] = 'm.id_topic = {int:topic}';
193
+		}
194
+		if ($query_params['min_msg_id']) {
195
+					$query_where[] = 'm.id_msg >= {int:min_msg_id}';
196
+		}
197
+		if ($query_params['max_msg_id']) {
198
+					$query_where[] = 'm.id_msg <= {int:max_msg_id}';
199
+		}
191 200
 
192 201
 		$count = 0;
193
-		if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index']))
194
-			foreach ($query_params['excluded_phrases'] as $phrase)
202
+		if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) {
203
+					foreach ($query_params['excluded_phrases'] as $phrase)
195 204
 			{
196 205
 				$query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:exclude_subject_phrase_' . $count . '}';
206
+		}
197 207
 				$query_params['exclude_subject_phrase_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($phrase, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $phrase), '\\\'') . '[[:>:]]';
198 208
 			}
199 209
 		$count = 0;
200
-		if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index']))
201
-			foreach ($query_params['excluded_subject_words'] as $excludedWord)
210
+		if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) {
211
+					foreach ($query_params['excluded_subject_words'] as $excludedWord)
202 212
 			{
203 213
 				$query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:exclude_subject_words_' . $count . '}';
214
+		}
204 215
 				$query_params['exclude_subject_words_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($excludedWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $excludedWord), '\\\'') . '[[:>:]]';
205 216
 			}
206 217
 
@@ -223,12 +234,11 @@  discard block
 block discarded – undo
223 234
 				}
224 235
 				$query_where[] = 'to_tsvector({string:language_ftx},body) @@ to_tsquery({string:language_ftx},{string:body_match})';
225 236
 				$query_params['language_ftx'] = $language_ftx;
237
+			} else {
238
+							$query_where[] = 'MATCH (body) AGAINST ({string:body_match})';
226 239
 			}
227
-			else
228
-				$query_where[] = 'MATCH (body) AGAINST ({string:body_match})';
229 240
 			$query_params['body_match'] = implode(' ', array_diff($words['indexed_words'], $query_params['excluded_index_words']));
230
-		}
231
-		else
241
+		} else
232 242
 		{
233 243
 			$query_params['boolean_match'] = '';
234 244
 
@@ -242,10 +252,10 @@  discard block
 block discarded – undo
242 252
 					$query_params['boolean_match'] .= (in_array($fulltextWord, $query_params['excluded_index_words']) ? '!' : '') . $fulltextWord . ' ';
243 253
 					$row++;
244 254
 				}
245
-			}
246
-			else
247
-				foreach ($words['indexed_words'] as $fulltextWord)
255
+			} else {
256
+							foreach ($words['indexed_words'] as $fulltextWord)
248 257
 					$query_params['boolean_match'] .= (in_array($fulltextWord, $query_params['excluded_index_words']) ? '-' : '+') . $fulltextWord . ' ';
258
+			}
249 259
 
250 260
 			$query_params['boolean_match'] = substr($query_params['boolean_match'], 0, -1);
251 261
 
@@ -268,9 +278,9 @@  discard block
 block discarded – undo
268 278
 					}
269 279
 					$query_where[] = 'to_tsvector({string:language_ftx},body) @@ to_tsquery({string:language_ftx},{string:boolean_match})';
270 280
 					$query_params['language_ftx'] = $language_ftx;
281
+				} else {
282
+									$query_where[] = 'MATCH (body) AGAINST ({string:boolean_match} IN BOOLEAN MODE)';
271 283
 				}
272
-				else
273
-					$query_where[] = 'MATCH (body) AGAINST ({string:boolean_match} IN BOOLEAN MODE)';
274 284
 			}
275 285
 
276 286
 		}
Please login to merge, or discard this patch.