Completed
Push — release-2.1 ( 15f485...0da2ef )
by Mathias
07:51
created
SSI.php 2 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1717,7 +1717,7 @@  discard block
 block discarded – undo
1717 1717
 /**
1718 1718
  * Show today's birthdays.
1719 1719
  * @param string $output_method The output method. If 'echo', displays a list of users, otherwise returns an array of info about them.
1720
- * @return void|array Displays a list of users or returns an array of info about them depending on output_method.
1720
+ * @return null|string Displays a list of users or returns an array of info about them depending on output_method.
1721 1721
  */
1722 1722
 function ssi_todaysBirthdays($output_method = 'echo')
1723 1723
 {
@@ -1746,7 +1746,7 @@  discard block
 block discarded – undo
1746 1746
 /**
1747 1747
  * Shows today's holidays.
1748 1748
  * @param string $output_method The output method. If 'echo', displays a list of holidays, otherwise returns an array of info about them.
1749
- * @return void|array Displays a list of holidays or returns an array of info about them depending on output_method
1749
+ * @return null|string Displays a list of holidays or returns an array of info about them depending on output_method
1750 1750
  */
1751 1751
 function ssi_todaysHolidays($output_method = 'echo')
1752 1752
 {
@@ -1773,7 +1773,7 @@  discard block
 block discarded – undo
1773 1773
 
1774 1774
 /**
1775 1775
  * @param string $output_method The output method. If 'echo', displays a list of events, otherwise returns an array of info about them.
1776
- * @return void|array Displays a list of events or returns an array of info about them depending on output_method
1776
+ * @return null|string Displays a list of events or returns an array of info about them depending on output_method
1777 1777
  */
1778 1778
 function ssi_todaysEvents($output_method = 'echo')
1779 1779
 {
@@ -1807,7 +1807,7 @@  discard block
 block discarded – undo
1807 1807
 /**
1808 1808
  * Shows today's calendar items (events, birthdays and holidays)
1809 1809
  * @param string $output_method The output method. If 'echo', displays a list of calendar items, otherwise returns an array of info about them.
1810
- * @return void|array Displays a list of calendar items or returns an array of info about them depending on output_method
1810
+ * @return null|string Displays a list of calendar items or returns an array of info about them depending on output_method
1811 1811
  */
1812 1812
 function ssi_todaysCalendar($output_method = 'echo')
1813 1813
 {
@@ -2198,7 +2198,7 @@  discard block
 block discarded – undo
2198 2198
  * @param int|string $id The ID or username of a user
2199 2199
  * @param string $password The password to check
2200 2200
  * @param bool $is_username If true, treats $id as a username rather than a user ID
2201
- * @return bool Whether or not the password is correct.
2201
+ * @return null|boolean Whether or not the password is correct.
2202 2202
  */
2203 2203
 function ssi_checkPassword($id = null, $password = null, $is_username = false)
2204 2204
 {
Please login to merge, or discard this patch.
Braces   +430 added lines, -306 removed lines patch added patch discarded remove patch
@@ -12,8 +12,9 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Don't do anything if SMF is already loaded.
15
-if (defined('SMF'))
15
+if (defined('SMF')) {
16 16
 	return true;
17
+}
17 18
 
18 19
 define('SMF', 'SSI');
19 20
 
@@ -26,21 +27,24 @@  discard block
 block discarded – undo
26 27
 
27 28
 // Remember the current configuration so it can be set back.
28 29
 $ssi_magic_quotes_runtime = function_exists('get_magic_quotes_gpc') && get_magic_quotes_runtime();
29
-if (function_exists('set_magic_quotes_runtime'))
30
+if (function_exists('set_magic_quotes_runtime')) {
30 31
 	@set_magic_quotes_runtime(0);
32
+}
31 33
 $time_start = microtime();
32 34
 
33 35
 // Just being safe...
34
-foreach (array('db_character_set', 'cachedir') as $variable)
36
+foreach (array('db_character_set', 'cachedir') as $variable) {
35 37
 	if (isset($GLOBALS[$variable]))
36 38
 		unset($GLOBALS[$variable]);
39
+}
37 40
 
38 41
 // Get the forum's settings for database and file paths.
39 42
 require_once(dirname(__FILE__) . '/Settings.php');
40 43
 
41 44
 // Make absolutely sure the cache directory is defined.
42
-if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache'))
45
+if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) {
43 46
 	$cachedir = $boarddir . '/cache';
47
+}
44 48
 
45 49
 $ssi_error_reporting = error_reporting(defined('E_STRICT') ? E_ALL | E_STRICT : E_ALL);
46 50
 /* Set this to one of three values depending on what you want to happen in the case of a fatal error.
@@ -51,12 +55,14 @@  discard block
 block discarded – undo
51 55
 $ssi_on_error_method = false;
52 56
 
53 57
 // Don't do john didley if the forum's been shut down completely.
54
-if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true))
58
+if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true)) {
55 59
 	die($mmessage);
60
+}
56 61
 
57 62
 // Fix for using the current directory as a path.
58
-if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.')
63
+if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') {
59 64
 	$sourcedir = dirname(__FILE__) . substr($sourcedir, 1);
65
+}
60 66
 
61 67
 // Load the important includes.
62 68
 require_once($sourcedir . '/QueryString.php');
@@ -81,34 +87,38 @@  discard block
 block discarded – undo
81 87
 cleanRequest();
82 88
 
83 89
 // Seed the random generator?
84
-if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69)
90
+if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) {
85 91
 	smf_seed_generator();
92
+}
86 93
 
87 94
 // Check on any hacking attempts.
88
-if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS']))
95
+if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) {
89 96
 	die('No direct access...');
90
-elseif (isset($_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme)
97
+} elseif (isset($_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme) {
91 98
 	die('No direct access...');
92
-elseif (isset($_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme)
99
+} elseif (isset($_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme) {
93 100
 	die('No direct access...');
94
-elseif (isset($_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers)
101
+} elseif (isset($_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers) {
95 102
 	die('No direct access...');
96
-if (isset($_REQUEST['context']))
103
+}
104
+if (isset($_REQUEST['context'])) {
97 105
 	die('No direct access...');
106
+}
98 107
 
99 108
 // Gzip output? (because it must be boolean and true, this can't be hacked.)
100
-if (isset($ssi_gzip) && $ssi_gzip === true && ini_get('zlib.output_compression') != '1' && ini_get('output_handler') != 'ob_gzhandler' && version_compare(PHP_VERSION, '4.2.0', '>='))
109
+if (isset($ssi_gzip) && $ssi_gzip === true && ini_get('zlib.output_compression') != '1' && ini_get('output_handler') != 'ob_gzhandler' && version_compare(PHP_VERSION, '4.2.0', '>=')) {
101 110
 	ob_start('ob_gzhandler');
102
-else
111
+} else {
103 112
 	$modSettings['enableCompressedOutput'] = '0';
113
+}
104 114
 
105 115
 // Primarily, this is to fix the URLs...
106 116
 ob_start('ob_sessrewrite');
107 117
 
108 118
 // Start the session... known to scramble SSI includes in cases...
109
-if (!headers_sent())
119
+if (!headers_sent()) {
110 120
 	loadSession();
111
-else
121
+} else
112 122
 {
113 123
 	if (isset($_COOKIE[session_name()]) || isset($_REQUEST[session_name()]))
114 124
 	{
@@ -142,12 +152,14 @@  discard block
 block discarded – undo
142 152
 loadTheme(isset($ssi_theme) ? (int) $ssi_theme : 0);
143 153
 
144 154
 // @todo: probably not the best place, but somewhere it should be set...
145
-if (!headers_sent())
155
+if (!headers_sent()) {
146 156
 	header('Content-Type: text/html; charset=' . (empty($modSettings['global_character_set']) ? (empty($txt['lang_character_set']) ? 'ISO-8859-1' : $txt['lang_character_set']) : $modSettings['global_character_set']));
157
+}
147 158
 
148 159
 // Take care of any banning that needs to be done.
149
-if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true))
160
+if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true)) {
150 161
 	is_not_banned();
162
+}
151 163
 
152 164
 // Do we allow guests in here?
153 165
 if (empty($ssi_guest_access) && empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && basename($_SERVER['PHP_SELF']) != 'SSI.php')
@@ -162,17 +174,19 @@  discard block
 block discarded – undo
162 174
 {
163 175
 	$context['template_layers'] = $ssi_layers;
164 176
 	template_header();
165
-}
166
-else
177
+} else {
167 178
 	setupThemeContext();
179
+}
168 180
 
169 181
 // Make sure they didn't muss around with the settings... but only if it's not cli.
170
-if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '')
182
+if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '') {
171 183
 	trigger_error($txt['ssi_session_broken'], E_USER_NOTICE);
184
+}
172 185
 
173 186
 // Without visiting the forum this session variable might not be set on submit.
174
-if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote'))
187
+if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote')) {
175 188
 	$_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT'];
189
+}
176 190
 
177 191
 // Have the ability to easily add functions to SSI.
178 192
 call_integration_hook('integrate_SSI');
@@ -181,11 +195,13 @@  discard block
 block discarded – undo
181 195
 if (basename($_SERVER['PHP_SELF']) == 'SSI.php')
182 196
 {
183 197
 	// You shouldn't just access SSI.php directly by URL!!
184
-	if (!isset($_GET['ssi_function']))
185
-		die(sprintf($txt['ssi_not_direct'], $user_info['is_admin'] ? '\'' . addslashes(__FILE__) . '\'' : '\'SSI.php\''));
198
+	if (!isset($_GET['ssi_function'])) {
199
+			die(sprintf($txt['ssi_not_direct'], $user_info['is_admin'] ? '\'' . addslashes(__FILE__) . '\'' : '\'SSI.php\''));
200
+	}
186 201
 	// Call a function passed by GET.
187
-	if (function_exists('ssi_' . $_GET['ssi_function']) && (!empty($modSettings['allow_guestAccess']) || !$user_info['is_guest']))
188
-		call_user_func('ssi_' . $_GET['ssi_function']);
202
+	if (function_exists('ssi_' . $_GET['ssi_function']) && (!empty($modSettings['allow_guestAccess']) || !$user_info['is_guest'])) {
203
+			call_user_func('ssi_' . $_GET['ssi_function']);
204
+	}
189 205
 	exit;
190 206
 }
191 207
 
@@ -193,8 +209,9 @@  discard block
 block discarded – undo
193 209
 unset($_GET['ssi_function']);
194 210
 
195 211
 error_reporting($ssi_error_reporting);
196
-if (function_exists('set_magic_quotes_runtime'))
212
+if (function_exists('set_magic_quotes_runtime')) {
197 213
 	@set_magic_quotes_runtime($ssi_magic_quotes_runtime);
214
+}
198 215
 
199 216
 return true;
200 217
 
@@ -204,9 +221,10 @@  discard block
 block discarded – undo
204 221
  */
205 222
 function ssi_shutdown()
206 223
 {
207
-	if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown')
208
-		template_footer();
209
-}
224
+	if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown') {
225
+			template_footer();
226
+	}
227
+	}
210 228
 
211 229
 /**
212 230
  * Display a welcome message, like: Hey, User, you have 0 messages, 0 are new.
@@ -219,15 +237,17 @@  discard block
 block discarded – undo
219 237
 
220 238
 	if ($output_method == 'echo')
221 239
 	{
222
-		if ($context['user']['is_guest'])
223
-			echo sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup');
224
-		else
225
-			echo $txt['hello_member'], ' <strong>', $context['user']['name'], '</strong>', allowedTo('pm_read') ? ', ' . (empty($context['user']['messages']) ? $txt['msg_alert_no_messages'] : (($context['user']['messages'] == 1 ? sprintf($txt['msg_alert_one_message'], $scripturl . '?action=pm') : sprintf($txt['msg_alert_many_message'], $scripturl . '?action=pm', $context['user']['messages'])) . ', ' . ($context['user']['unread_messages'] == 1 ? $txt['msg_alert_one_new'] : sprintf($txt['msg_alert_many_new'], $context['user']['unread_messages'])))) : '';
240
+		if ($context['user']['is_guest']) {
241
+					echo sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup');
242
+		} else {
243
+					echo $txt['hello_member'], ' <strong>', $context['user']['name'], '</strong>', allowedTo('pm_read') ? ', ' . (empty($context['user']['messages']) ? $txt['msg_alert_no_messages'] : (($context['user']['messages'] == 1 ? sprintf($txt['msg_alert_one_message'], $scripturl . '?action=pm') : sprintf($txt['msg_alert_many_message'], $scripturl . '?action=pm', $context['user']['messages'])) . ', ' . ($context['user']['unread_messages'] == 1 ? $txt['msg_alert_one_new'] : sprintf($txt['msg_alert_many_new'], $context['user']['unread_messages'])))) : '';
244
+		}
226 245
 	}
227 246
 	// Don't echo... then do what?!
228
-	else
229
-		return $context['user'];
230
-}
247
+	else {
248
+			return $context['user'];
249
+	}
250
+	}
231 251
 
232 252
 /**
233 253
  * Display a menu bar, like is displayed at the top of the forum.
@@ -238,12 +258,14 @@  discard block
 block discarded – undo
238 258
 {
239 259
 	global $context;
240 260
 
241
-	if ($output_method == 'echo')
242
-		template_menu();
261
+	if ($output_method == 'echo') {
262
+			template_menu();
263
+	}
243 264
 	// What else could this do?
244
-	else
245
-		return $context['menu_buttons'];
246
-}
265
+	else {
266
+			return $context['menu_buttons'];
267
+	}
268
+	}
247 269
 
248 270
 /**
249 271
  * Show a logout link.
@@ -255,20 +277,23 @@  discard block
 block discarded – undo
255 277
 {
256 278
 	global $context, $txt, $scripturl;
257 279
 
258
-	if ($redirect_to != '')
259
-		$_SESSION['logout_url'] = $redirect_to;
280
+	if ($redirect_to != '') {
281
+			$_SESSION['logout_url'] = $redirect_to;
282
+	}
260 283
 
261 284
 	// Guests can't log out.
262
-	if ($context['user']['is_guest'])
263
-		return false;
285
+	if ($context['user']['is_guest']) {
286
+			return false;
287
+	}
264 288
 
265 289
 	$link = '<a href="' . $scripturl . '?action=logout;' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['logout'] . '</a>';
266 290
 
267
-	if ($output_method == 'echo')
268
-		echo $link;
269
-	else
270
-		return $link;
271
-}
291
+	if ($output_method == 'echo') {
292
+			echo $link;
293
+	} else {
294
+			return $link;
295
+	}
296
+	}
272 297
 
273 298
 /**
274 299
  * Recent post list:   [board] Subject by Poster    Date
@@ -284,17 +309,17 @@  discard block
 block discarded – undo
284 309
 	global $modSettings, $context;
285 310
 
286 311
 	// Excluding certain boards...
287
-	if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0)
288
-		$exclude_boards = array($modSettings['recycle_board']);
289
-	else
290
-		$exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards));
312
+	if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) {
313
+			$exclude_boards = array($modSettings['recycle_board']);
314
+	} else {
315
+			$exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards));
316
+	}
291 317
 
292 318
 	// What about including certain boards - note we do some protection here as pre-2.0 didn't have this parameter.
293 319
 	if (is_array($include_boards) || (int) $include_boards === $include_boards)
294 320
 	{
295 321
 		$include_boards = is_array($include_boards) ? $include_boards : array($include_boards);
296
-	}
297
-	elseif ($include_boards != null)
322
+	} elseif ($include_boards != null)
298 323
 	{
299 324
 		$include_boards = array();
300 325
 	}
@@ -331,8 +356,9 @@  discard block
 block discarded – undo
331 356
 {
332 357
 	global $modSettings;
333 358
 
334
-	if (empty($post_ids))
335
-		return;
359
+	if (empty($post_ids)) {
360
+			return;
361
+	}
336 362
 
337 363
 	// Allow the user to request more than one - why not?
338 364
 	$post_ids = is_array($post_ids) ? $post_ids : array($post_ids);
@@ -367,8 +393,9 @@  discard block
 block discarded – undo
367 393
 	global $scripturl, $txt, $user_info;
368 394
 	global $modSettings, $smcFunc, $context;
369 395
 
370
-	if (!empty($modSettings['enable_likes']))
371
-		$context['can_like'] = allowedTo('likes_like');
396
+	if (!empty($modSettings['enable_likes'])) {
397
+			$context['can_like'] = allowedTo('likes_like');
398
+	}
372 399
 
373 400
 	// Find all the posts. Newer ones will have higher IDs.
374 401
 	$request = $smcFunc['db_query']('substring', '
@@ -434,12 +461,13 @@  discard block
 block discarded – undo
434 461
 		);
435 462
 
436 463
 		// Get the likes for each message.
437
-		if (!empty($modSettings['enable_likes']))
438
-			$posts[$row['id_msg']]['likes'] = array(
464
+		if (!empty($modSettings['enable_likes'])) {
465
+					$posts[$row['id_msg']]['likes'] = array(
439 466
 				'count' => $row['likes'],
440 467
 				'you' => in_array($row['id_msg'], prepareLikesContext($row['id_topic'])),
441 468
 				'can_like' => !$context['user']['is_guest'] && $row['id_member'] != $context['user']['id'] && !empty($context['can_like']),
442 469
 			);
470
+		}
443 471
 	}
444 472
 	$smcFunc['db_free_result']($request);
445 473
 
@@ -447,13 +475,14 @@  discard block
 block discarded – undo
447 475
 	call_integration_hook('integrate_ssi_queryPosts', array(&$posts));
448 476
 
449 477
 	// Just return it.
450
-	if ($output_method != 'echo' || empty($posts))
451
-		return $posts;
478
+	if ($output_method != 'echo' || empty($posts)) {
479
+			return $posts;
480
+	}
452 481
 
453 482
 	echo '
454 483
 		<table style="border: none" class="ssi_table">';
455
-	foreach ($posts as $post)
456
-		echo '
484
+	foreach ($posts as $post) {
485
+			echo '
457 486
 			<tr>
458 487
 				<td style="text-align: right; vertical-align: top; white-space: nowrap">
459 488
 					[', $post['board']['link'], ']
@@ -467,6 +496,7 @@  discard block
 block discarded – undo
467 496
 					', $post['time'], '
468 497
 				</td>
469 498
 			</tr>';
499
+	}
470 500
 	echo '
471 501
 		</table>';
472 502
 }
@@ -484,25 +514,26 @@  discard block
 block discarded – undo
484 514
 	global $settings, $scripturl, $txt, $user_info;
485 515
 	global $modSettings, $smcFunc, $context;
486 516
 
487
-	if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0)
488
-		$exclude_boards = array($modSettings['recycle_board']);
489
-	else
490
-		$exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards));
517
+	if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) {
518
+			$exclude_boards = array($modSettings['recycle_board']);
519
+	} else {
520
+			$exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards));
521
+	}
491 522
 
492 523
 	// Only some boards?.
493 524
 	if (is_array($include_boards) || (int) $include_boards === $include_boards)
494 525
 	{
495 526
 		$include_boards = is_array($include_boards) ? $include_boards : array($include_boards);
496
-	}
497
-	elseif ($include_boards != null)
527
+	} elseif ($include_boards != null)
498 528
 	{
499 529
 		$output_method = $include_boards;
500 530
 		$include_boards = array();
501 531
 	}
502 532
 
503 533
 	$icon_sources = array();
504
-	foreach ($context['stable_icons'] as $icon)
505
-		$icon_sources[$icon] = 'images_url';
534
+	foreach ($context['stable_icons'] as $icon) {
535
+			$icon_sources[$icon] = 'images_url';
536
+	}
506 537
 
507 538
 	// Find all the posts in distinct topics.  Newer ones will have higher IDs.
508 539
 	$request = $smcFunc['db_query']('substring', '
@@ -527,13 +558,15 @@  discard block
 block discarded – undo
527 558
 		)
528 559
 	);
529 560
 	$topics = array();
530
-	while ($row = $smcFunc['db_fetch_assoc']($request))
531
-		$topics[$row['id_topic']] = $row;
561
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
562
+			$topics[$row['id_topic']] = $row;
563
+	}
532 564
 	$smcFunc['db_free_result']($request);
533 565
 
534 566
 	// Did we find anything? If not, bail.
535
-	if (empty($topics))
536
-		return array();
567
+	if (empty($topics)) {
568
+			return array();
569
+	}
537 570
 
538 571
 	$recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0;
539 572
 
@@ -561,19 +594,22 @@  discard block
 block discarded – undo
561 594
 	while ($row = $smcFunc['db_fetch_assoc']($request))
562 595
 	{
563 596
 		$row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br>' => '&#10;')));
564
-		if ($smcFunc['strlen']($row['body']) > 128)
565
-			$row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...';
597
+		if ($smcFunc['strlen']($row['body']) > 128) {
598
+					$row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...';
599
+		}
566 600
 
567 601
 		// Censor the subject.
568 602
 		censorText($row['subject']);
569 603
 		censorText($row['body']);
570 604
 
571 605
 		// Recycled icon
572
-		if (!empty($recycle_board) && $topics[$row['id_topic']]['id_board'])
573
-			$row['icon'] = 'recycled';
606
+		if (!empty($recycle_board) && $topics[$row['id_topic']]['id_board']) {
607
+					$row['icon'] = 'recycled';
608
+		}
574 609
 
575
-		if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']]))
576
-			$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url';
610
+		if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) {
611
+					$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url';
612
+		}
577 613
 
578 614
 		// Build the array.
579 615
 		$posts[] = array(
@@ -612,13 +648,14 @@  discard block
 block discarded – undo
612 648
 	call_integration_hook('integrate_ssi_recentTopics', array(&$posts));
613 649
 
614 650
 	// Just return it.
615
-	if ($output_method != 'echo' || empty($posts))
616
-		return $posts;
651
+	if ($output_method != 'echo' || empty($posts)) {
652
+			return $posts;
653
+	}
617 654
 
618 655
 	echo '
619 656
 		<table style="border: none" class="ssi_table">';
620
-	foreach ($posts as $post)
621
-		echo '
657
+	foreach ($posts as $post) {
658
+			echo '
622 659
 			<tr>
623 660
 				<td style="text-align: right; vertical-align: top; white-space: nowrap">
624 661
 					[', $post['board']['link'], ']
@@ -632,6 +669,7 @@  discard block
 block discarded – undo
632 669
 					', $post['time'], '
633 670
 				</td>
634 671
 			</tr>';
672
+	}
635 673
 	echo '
636 674
 		</table>';
637 675
 }
@@ -656,27 +694,30 @@  discard block
 block discarded – undo
656 694
 		)
657 695
 	);
658 696
 	$return = array();
659
-	while ($row = $smcFunc['db_fetch_assoc']($request))
660
-		$return[] = array(
697
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
698
+			$return[] = array(
661 699
 			'id' => $row['id_member'],
662 700
 			'name' => $row['real_name'],
663 701
 			'href' => $scripturl . '?action=profile;u=' . $row['id_member'],
664 702
 			'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>',
665 703
 			'posts' => $row['posts']
666 704
 		);
705
+	}
667 706
 	$smcFunc['db_free_result']($request);
668 707
 
669 708
 	// If mods want to do somthing with this list of members, let them do that now.
670 709
 	call_integration_hook('integrate_ssi_topPoster', array(&$return));
671 710
 
672 711
 	// Just return all the top posters.
673
-	if ($output_method != 'echo')
674
-		return $return;
712
+	if ($output_method != 'echo') {
713
+			return $return;
714
+	}
675 715
 
676 716
 	// Make a quick array to list the links in.
677 717
 	$temp_array = array();
678
-	foreach ($return as $member)
679
-		$temp_array[] = $member['link'];
718
+	foreach ($return as $member) {
719
+			$temp_array[] = $member['link'];
720
+	}
680 721
 
681 722
 	echo implode(', ', $temp_array);
682 723
 }
@@ -708,8 +749,8 @@  discard block
 block discarded – undo
708 749
 		)
709 750
 	);
710 751
 	$boards = array();
711
-	while ($row = $smcFunc['db_fetch_assoc']($request))
712
-		$boards[] = array(
752
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
753
+			$boards[] = array(
713 754
 			'id' => $row['id_board'],
714 755
 			'num_posts' => $row['num_posts'],
715 756
 			'num_topics' => $row['num_topics'],
@@ -718,14 +759,16 @@  discard block
 block discarded – undo
718 759
 			'href' => $scripturl . '?board=' . $row['id_board'] . '.0',
719 760
 			'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'
720 761
 		);
762
+	}
721 763
 	$smcFunc['db_free_result']($request);
722 764
 
723 765
 	// If mods want to do somthing with this list of boards, let them do that now.
724 766
 	call_integration_hook('integrate_ssi_topBoards', array(&$boards));
725 767
 
726 768
 	// If we shouldn't output or have nothing to output, just jump out.
727
-	if ($output_method != 'echo' || empty($boards))
728
-		return $boards;
769
+	if ($output_method != 'echo' || empty($boards)) {
770
+			return $boards;
771
+	}
729 772
 
730 773
 	echo '
731 774
 		<table class="ssi_table">
@@ -734,13 +777,14 @@  discard block
 block discarded – undo
734 777
 				<th style="text-align: left">', $txt['board_topics'], '</th>
735 778
 				<th style="text-align: left">', $txt['posts'], '</th>
736 779
 			</tr>';
737
-	foreach ($boards as $sBoard)
738
-		echo '
780
+	foreach ($boards as $sBoard) {
781
+			echo '
739 782
 			<tr>
740 783
 				<td>', $sBoard['link'], $sBoard['new'] ? ' <a href="' . $sBoard['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>' : '', '</td>
741 784
 				<td style="text-align: right">', comma_format($sBoard['num_topics']), '</td>
742 785
 				<td style="text-align: right">', comma_format($sBoard['num_posts']), '</td>
743 786
 			</tr>';
787
+	}
744 788
 	echo '
745 789
 		</table>';
746 790
 }
@@ -773,12 +817,13 @@  discard block
 block discarded – undo
773 817
 			)
774 818
 		);
775 819
 		$topic_ids = array();
776
-		while ($row = $smcFunc['db_fetch_assoc']($request))
777
-			$topic_ids[] = $row['id_topic'];
820
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
821
+					$topic_ids[] = $row['id_topic'];
822
+		}
778 823
 		$smcFunc['db_free_result']($request);
824
+	} else {
825
+			$topic_ids = array();
779 826
 	}
780
-	else
781
-		$topic_ids = array();
782 827
 
783 828
 	$request = $smcFunc['db_query']('', '
784 829
 		SELECT m.subject, m.id_topic, t.num_views, t.num_replies
@@ -817,8 +862,9 @@  discard block
 block discarded – undo
817 862
 	// If mods want to do somthing with this list of topics, let them do that now.
818 863
 	call_integration_hook('integrate_ssi_topTopics', array(&$topics, $type));
819 864
 
820
-	if ($output_method != 'echo' || empty($topics))
821
-		return $topics;
865
+	if ($output_method != 'echo' || empty($topics)) {
866
+			return $topics;
867
+	}
822 868
 
823 869
 	echo '
824 870
 		<table class="ssi_table">
@@ -827,8 +873,8 @@  discard block
 block discarded – undo
827 873
 				<th style="text-align: left">', $txt['views'], '</th>
828 874
 				<th style="text-align: left">', $txt['replies'], '</th>
829 875
 			</tr>';
830
-	foreach ($topics as $sTopic)
831
-		echo '
876
+	foreach ($topics as $sTopic) {
877
+			echo '
832 878
 			<tr>
833 879
 				<td style="text-align: left">
834 880
 					', $sTopic['link'], '
@@ -836,6 +882,7 @@  discard block
 block discarded – undo
836 882
 				<td style="text-align: right">', comma_format($sTopic['num_views']), '</td>
837 883
 				<td style="text-align: right">', comma_format($sTopic['num_replies']), '</td>
838 884
 			</tr>';
885
+	}
839 886
 	echo '
840 887
 		</table>';
841 888
 }
@@ -871,12 +918,13 @@  discard block
 block discarded – undo
871 918
 {
872 919
 	global $txt, $context;
873 920
 
874
-	if ($output_method == 'echo')
875
-		echo '
921
+	if ($output_method == 'echo') {
922
+			echo '
876 923
 	', sprintf($txt['welcome_newest_member'], $context['common_stats']['latest_member']['link']), '<br>';
877
-	else
878
-		return $context['common_stats']['latest_member'];
879
-}
924
+	} else {
925
+			return $context['common_stats']['latest_member'];
926
+	}
927
+	}
880 928
 
881 929
 /**
882 930
  * Fetches a random member.
@@ -925,8 +973,9 @@  discard block
 block discarded – undo
925 973
 	}
926 974
 
927 975
 	// Just to be sure put the random generator back to something... random.
928
-	if ($random_type != '')
929
-		mt_srand(time());
976
+	if ($random_type != '') {
977
+			mt_srand(time());
978
+	}
930 979
 
931 980
 	return $result;
932 981
 }
@@ -939,8 +988,9 @@  discard block
 block discarded – undo
939 988
  */
940 989
 function ssi_fetchMember($member_ids = array(), $output_method = 'echo')
941 990
 {
942
-	if (empty($member_ids))
943
-		return;
991
+	if (empty($member_ids)) {
992
+			return;
993
+	}
944 994
 
945 995
 	// Can have more than one member if you really want...
946 996
 	$member_ids = is_array($member_ids) ? $member_ids : array($member_ids);
@@ -965,8 +1015,9 @@  discard block
 block discarded – undo
965 1015
  */
966 1016
 function ssi_fetchGroupMembers($group_id = null, $output_method = 'echo')
967 1017
 {
968
-	if ($group_id === null)
969
-		return;
1018
+	if ($group_id === null) {
1019
+			return;
1020
+	}
970 1021
 
971 1022
 	$query_where = '
972 1023
 		id_group = {int:id_group}
@@ -993,8 +1044,9 @@  discard block
 block discarded – undo
993 1044
 {
994 1045
 	global $smcFunc, $memberContext;
995 1046
 
996
-	if ($query_where === null)
997
-		return;
1047
+	if ($query_where === null) {
1048
+			return;
1049
+	}
998 1050
 
999 1051
 	// Fetch the members in question.
1000 1052
 	$request = $smcFunc['db_query']('', '
@@ -1007,12 +1059,14 @@  discard block
 block discarded – undo
1007 1059
 		))
1008 1060
 	);
1009 1061
 	$members = array();
1010
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1011
-		$members[] = $row['id_member'];
1062
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1063
+			$members[] = $row['id_member'];
1064
+	}
1012 1065
 	$smcFunc['db_free_result']($request);
1013 1066
 
1014
-	if (empty($members))
1015
-		return array();
1067
+	if (empty($members)) {
1068
+			return array();
1069
+	}
1016 1070
 
1017 1071
 	// If mods want to do somthing with this list of members, let them do that now.
1018 1072
 	call_integration_hook('integrate_ssi_queryMembers', array(&$members));
@@ -1021,23 +1075,25 @@  discard block
 block discarded – undo
1021 1075
 	loadMemberData($members);
1022 1076
 
1023 1077
 	// Draw the table!
1024
-	if ($output_method == 'echo')
1025
-		echo '
1078
+	if ($output_method == 'echo') {
1079
+			echo '
1026 1080
 		<table style="border: none" class="ssi_table">';
1081
+	}
1027 1082
 
1028 1083
 	$query_members = array();
1029 1084
 	foreach ($members as $member)
1030 1085
 	{
1031 1086
 		// Load their context data.
1032
-		if (!loadMemberContext($member))
1033
-			continue;
1087
+		if (!loadMemberContext($member)) {
1088
+					continue;
1089
+		}
1034 1090
 
1035 1091
 		// Store this member's information.
1036 1092
 		$query_members[$member] = $memberContext[$member];
1037 1093
 
1038 1094
 		// Only do something if we're echo'ing.
1039
-		if ($output_method == 'echo')
1040
-			echo '
1095
+		if ($output_method == 'echo') {
1096
+					echo '
1041 1097
 			<tr>
1042 1098
 				<td style="text-align: right; vertical-align: top; white-space: nowrap">
1043 1099
 					', $query_members[$member]['link'], '
@@ -1045,12 +1101,14 @@  discard block
 block discarded – undo
1045 1101
 					<br>', $query_members[$member]['avatar']['image'], '
1046 1102
 				</td>
1047 1103
 			</tr>';
1104
+		}
1048 1105
 	}
1049 1106
 
1050 1107
 	// End the table if appropriate.
1051
-	if ($output_method == 'echo')
1052
-		echo '
1108
+	if ($output_method == 'echo') {
1109
+			echo '
1053 1110
 		</table>';
1111
+	}
1054 1112
 
1055 1113
 	// Send back the data.
1056 1114
 	return $query_members;
@@ -1065,8 +1123,9 @@  discard block
 block discarded – undo
1065 1123
 {
1066 1124
 	global $txt, $scripturl, $modSettings, $smcFunc;
1067 1125
 
1068
-	if (!allowedTo('view_stats'))
1069
-		return;
1126
+	if (!allowedTo('view_stats')) {
1127
+			return;
1128
+	}
1070 1129
 
1071 1130
 	$totals = array(
1072 1131
 		'members' => $modSettings['totalMembers'],
@@ -1095,8 +1154,9 @@  discard block
 block discarded – undo
1095 1154
 	// If mods want to do somthing with the board stats, let them do that now.
1096 1155
 	call_integration_hook('integrate_ssi_boardStats', array(&$totals));
1097 1156
 
1098
-	if ($output_method != 'echo')
1099
-		return $totals;
1157
+	if ($output_method != 'echo') {
1158
+			return $totals;
1159
+	}
1100 1160
 
1101 1161
 	echo '
1102 1162
 		', $txt['total_members'], ': <a href="', $scripturl . '?action=mlist">', comma_format($totals['members']), '</a><br>
@@ -1125,8 +1185,8 @@  discard block
 block discarded – undo
1125 1185
 	call_integration_hook('integrate_ssi_whosOnline', array(&$return));
1126 1186
 
1127 1187
 	// Add some redundancy for backwards compatibility reasons.
1128
-	if ($output_method != 'echo')
1129
-		return $return + array(
1188
+	if ($output_method != 'echo') {
1189
+			return $return + array(
1130 1190
 			'users' => $return['users_online'],
1131 1191
 			'guests' => $return['num_guests'],
1132 1192
 			'hidden' => $return['num_users_hidden'],
@@ -1134,29 +1194,35 @@  discard block
 block discarded – undo
1134 1194
 			'num_users' => $return['num_users_online'],
1135 1195
 			'total_users' => $return['num_users_online'] + $return['num_guests'],
1136 1196
 		);
1197
+	}
1137 1198
 
1138 1199
 	echo '
1139 1200
 		', comma_format($return['num_guests']), ' ', $return['num_guests'] == 1 ? $txt['guest'] : $txt['guests'], ', ', comma_format($return['num_users_online']), ' ', $return['num_users_online'] == 1 ? $txt['user'] : $txt['users'];
1140 1201
 
1141 1202
 	$bracketList = array();
1142
-	if (!empty($user_info['buddies']))
1143
-		$bracketList[] = comma_format($return['num_buddies']) . ' ' . ($return['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']);
1144
-	if (!empty($return['num_spiders']))
1145
-		$bracketList[] = comma_format($return['num_spiders']) . ' ' . ($return['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']);
1146
-	if (!empty($return['num_users_hidden']))
1147
-		$bracketList[] = comma_format($return['num_users_hidden']) . ' ' . $txt['hidden'];
1203
+	if (!empty($user_info['buddies'])) {
1204
+			$bracketList[] = comma_format($return['num_buddies']) . ' ' . ($return['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']);
1205
+	}
1206
+	if (!empty($return['num_spiders'])) {
1207
+			$bracketList[] = comma_format($return['num_spiders']) . ' ' . ($return['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']);
1208
+	}
1209
+	if (!empty($return['num_users_hidden'])) {
1210
+			$bracketList[] = comma_format($return['num_users_hidden']) . ' ' . $txt['hidden'];
1211
+	}
1148 1212
 
1149
-	if (!empty($bracketList))
1150
-		echo ' (' . implode(', ', $bracketList) . ')';
1213
+	if (!empty($bracketList)) {
1214
+			echo ' (' . implode(', ', $bracketList) . ')';
1215
+	}
1151 1216
 
1152 1217
 	echo '<br>
1153 1218
 			', implode(', ', $return['list_users_online']);
1154 1219
 
1155 1220
 	// Showing membergroups?
1156
-	if (!empty($settings['show_group_key']) && !empty($return['membergroups']))
1157
-		echo '<br>
1221
+	if (!empty($settings['show_group_key']) && !empty($return['membergroups'])) {
1222
+			echo '<br>
1158 1223
 			[' . implode(']&nbsp;&nbsp;[', $return['membergroups']) . ']';
1159
-}
1224
+	}
1225
+	}
1160 1226
 
1161 1227
 /**
1162 1228
  * Just like whosOnline except it also logs the online presence.
@@ -1167,11 +1233,12 @@  discard block
 block discarded – undo
1167 1233
 {
1168 1234
 	writeLog();
1169 1235
 
1170
-	if ($output_method != 'echo')
1171
-		return ssi_whosOnline($output_method);
1172
-	else
1173
-		ssi_whosOnline($output_method);
1174
-}
1236
+	if ($output_method != 'echo') {
1237
+			return ssi_whosOnline($output_method);
1238
+	} else {
1239
+			ssi_whosOnline($output_method);
1240
+	}
1241
+	}
1175 1242
 
1176 1243
 // Shows a login box.
1177 1244
 /**
@@ -1184,11 +1251,13 @@  discard block
 block discarded – undo
1184 1251
 {
1185 1252
 	global $scripturl, $txt, $user_info, $context;
1186 1253
 
1187
-	if ($redirect_to != '')
1188
-		$_SESSION['login_url'] = $redirect_to;
1254
+	if ($redirect_to != '') {
1255
+			$_SESSION['login_url'] = $redirect_to;
1256
+	}
1189 1257
 
1190
-	if ($output_method != 'echo' || !$user_info['is_guest'])
1191
-		return $user_info['is_guest'];
1258
+	if ($output_method != 'echo' || !$user_info['is_guest']) {
1259
+			return $user_info['is_guest'];
1260
+	}
1192 1261
 
1193 1262
 	// Create a login token
1194 1263
 	createToken('login');
@@ -1240,8 +1309,9 @@  discard block
 block discarded – undo
1240 1309
 
1241 1310
 	$boardsAllowed = array_intersect(boardsAllowedTo('poll_view'), boardsAllowedTo('poll_vote'));
1242 1311
 
1243
-	if (empty($boardsAllowed))
1244
-		return array();
1312
+	if (empty($boardsAllowed)) {
1313
+			return array();
1314
+	}
1245 1315
 
1246 1316
 	$request = $smcFunc['db_query']('', '
1247 1317
 		SELECT p.id_poll, p.question, t.id_topic, p.max_votes, p.guest_vote, p.hide_results, p.expire_time
@@ -1274,12 +1344,14 @@  discard block
 block discarded – undo
1274 1344
 	$smcFunc['db_free_result']($request);
1275 1345
 
1276 1346
 	// This user has voted on all the polls.
1277
-	if (empty($row) || !is_array($row))
1278
-		return array();
1347
+	if (empty($row) || !is_array($row)) {
1348
+			return array();
1349
+	}
1279 1350
 
1280 1351
 	// If this is a guest who's voted we'll through ourselves to show poll to show the results.
1281
-	if ($user_info['is_guest'] && (!$row['guest_vote'] || (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote'])))))
1282
-		return ssi_showPoll($row['id_topic'], $output_method);
1352
+	if ($user_info['is_guest'] && (!$row['guest_vote'] || (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))))) {
1353
+			return ssi_showPoll($row['id_topic'], $output_method);
1354
+	}
1283 1355
 
1284 1356
 	$request = $smcFunc['db_query']('', '
1285 1357
 		SELECT COUNT(DISTINCT id_member)
@@ -1343,8 +1415,9 @@  discard block
 block discarded – undo
1343 1415
 	// If mods want to do somthing with this list of polls, let them do that now.
1344 1416
 	call_integration_hook('integrate_ssi_recentPoll', array(&$return, $topPollInstead));
1345 1417
 
1346
-	if ($output_method != 'echo')
1347
-		return $return;
1418
+	if ($output_method != 'echo') {
1419
+			return $return;
1420
+	}
1348 1421
 
1349 1422
 	if ($allow_view_results)
1350 1423
 	{
@@ -1353,19 +1426,20 @@  discard block
 block discarded – undo
1353 1426
 			<strong>', $return['question'], '</strong><br>
1354 1427
 			', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '<br>' : '';
1355 1428
 
1356
-		foreach ($return['options'] as $option)
1357
-			echo '
1429
+		foreach ($return['options'] as $option) {
1430
+					echo '
1358 1431
 			<label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label><br>';
1432
+		}
1359 1433
 
1360 1434
 		echo '
1361 1435
 			<input type="submit" value="', $txt['poll_vote'], '" class="button_submit">
1362 1436
 			<input type="hidden" name="poll" value="', $return['id'], '">
1363 1437
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1364 1438
 		</form>';
1439
+	} else {
1440
+			echo $txt['poll_cannot_see'];
1441
+	}
1365 1442
 	}
1366
-	else
1367
-		echo $txt['poll_cannot_see'];
1368
-}
1369 1443
 
1370 1444
 /**
1371 1445
  * Shows the poll from the specified topic
@@ -1379,13 +1453,15 @@  discard block
 block discarded – undo
1379 1453
 
1380 1454
 	$boardsAllowed = boardsAllowedTo('poll_view');
1381 1455
 
1382
-	if (empty($boardsAllowed))
1383
-		return array();
1456
+	if (empty($boardsAllowed)) {
1457
+			return array();
1458
+	}
1384 1459
 
1385
-	if ($topic === null && isset($_REQUEST['ssi_topic']))
1386
-		$topic = (int) $_REQUEST['ssi_topic'];
1387
-	else
1388
-		$topic = (int) $topic;
1460
+	if ($topic === null && isset($_REQUEST['ssi_topic'])) {
1461
+			$topic = (int) $_REQUEST['ssi_topic'];
1462
+	} else {
1463
+			$topic = (int) $topic;
1464
+	}
1389 1465
 
1390 1466
 	$request = $smcFunc['db_query']('', '
1391 1467
 		SELECT
@@ -1406,17 +1482,18 @@  discard block
 block discarded – undo
1406 1482
 	);
1407 1483
 
1408 1484
 	// Either this topic has no poll, or the user cannot view it.
1409
-	if ($smcFunc['db_num_rows']($request) == 0)
1410
-		return array();
1485
+	if ($smcFunc['db_num_rows']($request) == 0) {
1486
+			return array();
1487
+	}
1411 1488
 
1412 1489
 	$row = $smcFunc['db_fetch_assoc']($request);
1413 1490
 	$smcFunc['db_free_result']($request);
1414 1491
 
1415 1492
 	// Check if they can vote.
1416 1493
 	$already_voted = false;
1417
-	if (!empty($row['expire_time']) && $row['expire_time'] < time())
1418
-		$allow_vote = false;
1419
-	elseif ($user_info['is_guest'])
1494
+	if (!empty($row['expire_time']) && $row['expire_time'] < time()) {
1495
+			$allow_vote = false;
1496
+	} elseif ($user_info['is_guest'])
1420 1497
 	{
1421 1498
 		// There's a difference between "allowed to vote" and "already voted"...
1422 1499
 		$allow_vote = $row['guest_vote'];
@@ -1426,10 +1503,9 @@  discard block
 block discarded – undo
1426 1503
 		{
1427 1504
 			$already_voted = true;
1428 1505
 		}
1429
-	}
1430
-	elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board']))
1431
-		$allow_vote = false;
1432
-	else
1506
+	} elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board'])) {
1507
+			$allow_vote = false;
1508
+	} else
1433 1509
 	{
1434 1510
 		$request = $smcFunc['db_query']('', '
1435 1511
 			SELECT id_member
@@ -1511,8 +1587,9 @@  discard block
 block discarded – undo
1511 1587
 	// If mods want to do somthing with this poll, let them do that now.
1512 1588
 	call_integration_hook('integrate_ssi_showPoll', array(&$return));
1513 1589
 
1514
-	if ($output_method != 'echo')
1515
-		return $return;
1590
+	if ($output_method != 'echo') {
1591
+			return $return;
1592
+	}
1516 1593
 
1517 1594
 	if ($return['allow_vote'])
1518 1595
 	{
@@ -1521,17 +1598,17 @@  discard block
 block discarded – undo
1521 1598
 				<strong>', $return['question'], '</strong><br>
1522 1599
 				', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '<br>' : '';
1523 1600
 
1524
-		foreach ($return['options'] as $option)
1525
-			echo '
1601
+		foreach ($return['options'] as $option) {
1602
+					echo '
1526 1603
 				<label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label><br>';
1604
+		}
1527 1605
 
1528 1606
 		echo '
1529 1607
 				<input type="submit" value="', $txt['poll_vote'], '" class="button_submit">
1530 1608
 				<input type="hidden" name="poll" value="', $return['id'], '">
1531 1609
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1532 1610
 			</form>';
1533
-	}
1534
-	else
1611
+	} else
1535 1612
 	{
1536 1613
 		echo '
1537 1614
 			<div class="ssi_poll">
@@ -1611,27 +1688,32 @@  discard block
 block discarded – undo
1611 1688
 			'is_approved' => 1,
1612 1689
 		)
1613 1690
 	);
1614
-	if ($smcFunc['db_num_rows']($request) == 0)
1615
-		die;
1691
+	if ($smcFunc['db_num_rows']($request) == 0) {
1692
+			die;
1693
+	}
1616 1694
 	$row = $smcFunc['db_fetch_assoc']($request);
1617 1695
 	$smcFunc['db_free_result']($request);
1618 1696
 
1619
-	if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time']))
1620
-		redirectexit('topic=' . $row['id_topic'] . '.0');
1697
+	if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) {
1698
+			redirectexit('topic=' . $row['id_topic'] . '.0');
1699
+	}
1621 1700
 
1622 1701
 	// Too many options checked?
1623
-	if (count($_REQUEST['options']) > $row['max_votes'])
1624
-		redirectexit('topic=' . $row['id_topic'] . '.0');
1702
+	if (count($_REQUEST['options']) > $row['max_votes']) {
1703
+			redirectexit('topic=' . $row['id_topic'] . '.0');
1704
+	}
1625 1705
 
1626 1706
 	// It's a guest who has already voted?
1627 1707
 	if ($user_info['is_guest'])
1628 1708
 	{
1629 1709
 		// Guest voting disabled?
1630
-		if (!$row['guest_vote'])
1631
-			redirectexit('topic=' . $row['id_topic'] . '.0');
1710
+		if (!$row['guest_vote']) {
1711
+					redirectexit('topic=' . $row['id_topic'] . '.0');
1712
+		}
1632 1713
 		// Already voted?
1633
-		elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote'])))
1634
-			redirectexit('topic=' . $row['id_topic'] . '.0');
1714
+		elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))) {
1715
+					redirectexit('topic=' . $row['id_topic'] . '.0');
1716
+		}
1635 1717
 	}
1636 1718
 
1637 1719
 	$sOptions = array();
@@ -1685,11 +1767,13 @@  discard block
 block discarded – undo
1685 1767
 {
1686 1768
 	global $scripturl, $txt, $context;
1687 1769
 
1688
-	if (!allowedTo('search_posts'))
1689
-		return;
1770
+	if (!allowedTo('search_posts')) {
1771
+			return;
1772
+	}
1690 1773
 
1691
-	if ($output_method != 'echo')
1692
-		return $scripturl . '?action=search';
1774
+	if ($output_method != 'echo') {
1775
+			return $scripturl . '?action=search';
1776
+	}
1693 1777
 
1694 1778
 	echo '
1695 1779
 		<form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '">
@@ -1711,8 +1795,9 @@  discard block
 block discarded – undo
1711 1795
 	// If mods want to do somthing with the news, let them do that now. Don't need to pass the news line itself, since it is already in $context.
1712 1796
 	call_integration_hook('integrate_ssi_news');
1713 1797
 
1714
-	if ($output_method != 'echo')
1715
-		return $context['random_news_line'];
1798
+	if ($output_method != 'echo') {
1799
+			return $context['random_news_line'];
1800
+	}
1716 1801
 
1717 1802
 	echo $context['random_news_line'];
1718 1803
 }
@@ -1726,8 +1811,9 @@  discard block
 block discarded – undo
1726 1811
 {
1727 1812
 	global $scripturl, $modSettings, $user_info;
1728 1813
 
1729
-	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view') || !allowedTo('profile_view'))
1730
-		return;
1814
+	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view') || !allowedTo('profile_view')) {
1815
+			return;
1816
+	}
1731 1817
 
1732 1818
 	$eventOptions = array(
1733 1819
 		'include_birthdays' => true,
@@ -1738,13 +1824,15 @@  discard block
 block discarded – undo
1738 1824
 	// The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary
1739 1825
 	call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions));
1740 1826
 
1741
-	if ($output_method != 'echo')
1742
-		return $return['calendar_birthdays'];
1827
+	if ($output_method != 'echo') {
1828
+			return $return['calendar_birthdays'];
1829
+	}
1743 1830
 
1744
-	foreach ($return['calendar_birthdays'] as $member)
1745
-		echo '
1831
+	foreach ($return['calendar_birthdays'] as $member) {
1832
+			echo '
1746 1833
 			<a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">' . $member['name'] . '</span>' . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>' . (!$member['is_last'] ? ', ' : '');
1747
-}
1834
+	}
1835
+	}
1748 1836
 
1749 1837
 /**
1750 1838
  * Shows today's holidays.
@@ -1755,8 +1843,9 @@  discard block
 block discarded – undo
1755 1843
 {
1756 1844
 	global $modSettings, $user_info;
1757 1845
 
1758
-	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view'))
1759
-		return;
1846
+	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) {
1847
+			return;
1848
+	}
1760 1849
 
1761 1850
 	$eventOptions = array(
1762 1851
 		'include_holidays' => true,
@@ -1767,8 +1856,9 @@  discard block
 block discarded – undo
1767 1856
 	// The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary
1768 1857
 	call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions));
1769 1858
 
1770
-	if ($output_method != 'echo')
1771
-		return $return['calendar_holidays'];
1859
+	if ($output_method != 'echo') {
1860
+			return $return['calendar_holidays'];
1861
+	}
1772 1862
 
1773 1863
 	echo '
1774 1864
 		', implode(', ', $return['calendar_holidays']);
@@ -1782,8 +1872,9 @@  discard block
 block discarded – undo
1782 1872
 {
1783 1873
 	global $modSettings, $user_info;
1784 1874
 
1785
-	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view'))
1786
-		return;
1875
+	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) {
1876
+			return;
1877
+	}
1787 1878
 
1788 1879
 	$eventOptions = array(
1789 1880
 		'include_events' => true,
@@ -1794,14 +1885,16 @@  discard block
 block discarded – undo
1794 1885
 	// The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary
1795 1886
 	call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions));
1796 1887
 
1797
-	if ($output_method != 'echo')
1798
-		return $return['calendar_events'];
1888
+	if ($output_method != 'echo') {
1889
+			return $return['calendar_events'];
1890
+	}
1799 1891
 
1800 1892
 	foreach ($return['calendar_events'] as $event)
1801 1893
 	{
1802
-		if ($event['can_edit'])
1803
-			echo '
1894
+		if ($event['can_edit']) {
1895
+					echo '
1804 1896
 	<a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> ';
1897
+		}
1805 1898
 		echo '
1806 1899
 	' . $event['link'] . (!$event['is_last'] ? ', ' : '');
1807 1900
 	}
@@ -1816,8 +1909,9 @@  discard block
 block discarded – undo
1816 1909
 {
1817 1910
 	global $modSettings, $txt, $scripturl, $user_info;
1818 1911
 
1819
-	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view'))
1820
-		return;
1912
+	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) {
1913
+			return;
1914
+	}
1821 1915
 
1822 1916
 	$eventOptions = array(
1823 1917
 		'include_birthdays' => allowedTo('profile_view'),
@@ -1830,19 +1924,22 @@  discard block
 block discarded – undo
1830 1924
 	// The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary
1831 1925
 	call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions));
1832 1926
 
1833
-	if ($output_method != 'echo')
1834
-		return $return;
1927
+	if ($output_method != 'echo') {
1928
+			return $return;
1929
+	}
1835 1930
 
1836
-	if (!empty($return['calendar_holidays']))
1837
-		echo '
1931
+	if (!empty($return['calendar_holidays'])) {
1932
+			echo '
1838 1933
 			<span class="holiday">' . $txt['calendar_prompt'] . ' ' . implode(', ', $return['calendar_holidays']) . '<br></span>';
1934
+	}
1839 1935
 	if (!empty($return['calendar_birthdays']))
1840 1936
 	{
1841 1937
 		echo '
1842 1938
 			<span class="birthday">' . $txt['birthdays_upcoming'] . '</span> ';
1843
-		foreach ($return['calendar_birthdays'] as $member)
1844
-			echo '
1939
+		foreach ($return['calendar_birthdays'] as $member) {
1940
+					echo '
1845 1941
 			<a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">', $member['name'], '</span>', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', !$member['is_last'] ? ', ' : '';
1942
+		}
1846 1943
 		echo '
1847 1944
 			<br>';
1848 1945
 	}
@@ -1852,9 +1949,10 @@  discard block
 block discarded – undo
1852 1949
 			<span class="event">' . $txt['events_upcoming'] . '</span> ';
1853 1950
 		foreach ($return['calendar_events'] as $event)
1854 1951
 		{
1855
-			if ($event['can_edit'])
1856
-				echo '
1952
+			if ($event['can_edit']) {
1953
+							echo '
1857 1954
 			<a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> ';
1955
+			}
1858 1956
 			echo '
1859 1957
 			' . $event['link'] . (!$event['is_last'] ? ', ' : '');
1860 1958
 		}
@@ -1878,25 +1976,29 @@  discard block
 block discarded – undo
1878 1976
 	loadLanguage('Stats');
1879 1977
 
1880 1978
 	// Must be integers....
1881
-	if ($limit === null)
1882
-		$limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5;
1883
-	else
1884
-		$limit = (int) $limit;
1885
-
1886
-	if ($start === null)
1887
-		$start = isset($_GET['start']) ? (int) $_GET['start'] : 0;
1888
-	else
1889
-		$start = (int) $start;
1890
-
1891
-	if ($board !== null)
1892
-		$board = (int) $board;
1893
-	elseif (isset($_GET['board']))
1894
-		$board = (int) $_GET['board'];
1895
-
1896
-	if ($length === null)
1897
-		$length = isset($_GET['length']) ? (int) $_GET['length'] : 0;
1898
-	else
1899
-		$length = (int) $length;
1979
+	if ($limit === null) {
1980
+			$limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5;
1981
+	} else {
1982
+			$limit = (int) $limit;
1983
+	}
1984
+
1985
+	if ($start === null) {
1986
+			$start = isset($_GET['start']) ? (int) $_GET['start'] : 0;
1987
+	} else {
1988
+			$start = (int) $start;
1989
+	}
1990
+
1991
+	if ($board !== null) {
1992
+			$board = (int) $board;
1993
+	} elseif (isset($_GET['board'])) {
1994
+			$board = (int) $_GET['board'];
1995
+	}
1996
+
1997
+	if ($length === null) {
1998
+			$length = isset($_GET['length']) ? (int) $_GET['length'] : 0;
1999
+	} else {
2000
+			$length = (int) $length;
2001
+	}
1900 2002
 
1901 2003
 	$limit = max(0, $limit);
1902 2004
 	$start = max(0, $start);
@@ -1914,17 +2016,19 @@  discard block
 block discarded – undo
1914 2016
 	);
1915 2017
 	if ($smcFunc['db_num_rows']($request) == 0)
1916 2018
 	{
1917
-		if ($output_method == 'echo')
1918
-			die($txt['ssi_no_guests']);
1919
-		else
1920
-			return array();
2019
+		if ($output_method == 'echo') {
2020
+					die($txt['ssi_no_guests']);
2021
+		} else {
2022
+					return array();
2023
+		}
1921 2024
 	}
1922 2025
 	list ($board) = $smcFunc['db_fetch_row']($request);
1923 2026
 	$smcFunc['db_free_result']($request);
1924 2027
 
1925 2028
 	$icon_sources = array();
1926
-	foreach ($context['stable_icons'] as $icon)
1927
-		$icon_sources[$icon] = 'images_url';
2029
+	foreach ($context['stable_icons'] as $icon) {
2030
+			$icon_sources[$icon] = 'images_url';
2031
+	}
1928 2032
 
1929 2033
 	if (!empty($modSettings['enable_likes']))
1930 2034
 	{
@@ -1948,12 +2052,14 @@  discard block
 block discarded – undo
1948 2052
 		)
1949 2053
 	);
1950 2054
 	$posts = array();
1951
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1952
-		$posts[] = $row['id_first_msg'];
2055
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
2056
+			$posts[] = $row['id_first_msg'];
2057
+	}
1953 2058
 	$smcFunc['db_free_result']($request);
1954 2059
 
1955
-	if (empty($posts))
1956
-		return array();
2060
+	if (empty($posts)) {
2061
+			return array();
2062
+	}
1957 2063
 
1958 2064
 	// Find the posts.
1959 2065
 	$request = $smcFunc['db_query']('', '
@@ -1983,24 +2089,28 @@  discard block
 block discarded – undo
1983 2089
 			$last_space = strrpos($row['body'], ' ');
1984 2090
 			$last_open = strrpos($row['body'], '<');
1985 2091
 			$last_close = strrpos($row['body'], '>');
1986
-			if (empty($last_space) || ($last_space == $last_open + 3 && (empty($last_close) || (!empty($last_close) && $last_close < $last_open))) || $last_space < $last_open || $last_open == $length - 6)
1987
-				$cutoff = $last_open;
1988
-			elseif (empty($last_close) || $last_close < $last_open)
1989
-				$cutoff = $last_space;
2092
+			if (empty($last_space) || ($last_space == $last_open + 3 && (empty($last_close) || (!empty($last_close) && $last_close < $last_open))) || $last_space < $last_open || $last_open == $length - 6) {
2093
+							$cutoff = $last_open;
2094
+			} elseif (empty($last_close) || $last_close < $last_open) {
2095
+							$cutoff = $last_space;
2096
+			}
1990 2097
 
1991
-			if ($cutoff !== false)
1992
-				$row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff);
2098
+			if ($cutoff !== false) {
2099
+							$row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff);
2100
+			}
1993 2101
 			$row['body'] .= '...';
1994 2102
 		}
1995 2103
 
1996 2104
 		$row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']);
1997 2105
 
1998
-		if (!empty($recycle_board) && $row['id_board'] == $recycle_board)
1999
-			$row['icon'] = 'recycled';
2106
+		if (!empty($recycle_board) && $row['id_board'] == $recycle_board) {
2107
+					$row['icon'] = 'recycled';
2108
+		}
2000 2109
 
2001 2110
 		// Check that this message icon is there...
2002
-		if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']]))
2003
-			$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url';
2111
+		if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) {
2112
+					$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url';
2113
+		}
2004 2114
 
2005 2115
 		censorText($row['subject']);
2006 2116
 		censorText($row['body']);
@@ -2037,16 +2147,18 @@  discard block
 block discarded – undo
2037 2147
 	}
2038 2148
 	$smcFunc['db_free_result']($request);
2039 2149
 
2040
-	if (empty($return))
2041
-		return $return;
2150
+	if (empty($return)) {
2151
+			return $return;
2152
+	}
2042 2153
 
2043 2154
 	$return[count($return) - 1]['is_last'] = true;
2044 2155
 
2045 2156
 	// If mods want to do somthing with this list of posts, let them do that now.
2046 2157
 	call_integration_hook('integrate_ssi_boardNews', array(&$return));
2047 2158
 
2048
-	if ($output_method != 'echo')
2049
-		return $return;
2159
+	if ($output_method != 'echo') {
2160
+			return $return;
2161
+	}
2050 2162
 
2051 2163
 	foreach ($return as $news)
2052 2164
 	{
@@ -2098,9 +2210,10 @@  discard block
 block discarded – undo
2098 2210
 		echo '
2099 2211
 			</div>';
2100 2212
 
2101
-		if (!$news['is_last'])
2102
-			echo '
2213
+		if (!$news['is_last']) {
2214
+					echo '
2103 2215
 			<hr>';
2216
+		}
2104 2217
 	}
2105 2218
 }
2106 2219
 
@@ -2114,8 +2227,9 @@  discard block
 block discarded – undo
2114 2227
 {
2115 2228
 	global $user_info, $scripturl, $modSettings, $txt, $context, $smcFunc;
2116 2229
 
2117
-	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view'))
2118
-		return;
2230
+	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) {
2231
+			return;
2232
+	}
2119 2233
 
2120 2234
 	// Find all events which are happening in the near future that the member can see.
2121 2235
 	$request = $smcFunc['db_query']('', '
@@ -2141,20 +2255,23 @@  discard block
 block discarded – undo
2141 2255
 	while ($row = $smcFunc['db_fetch_assoc']($request))
2142 2256
 	{
2143 2257
 		// Check if we've already come by an event linked to this same topic with the same title... and don't display it if we have.
2144
-		if (!empty($duplicates[$row['title'] . $row['id_topic']]))
2145
-			continue;
2258
+		if (!empty($duplicates[$row['title'] . $row['id_topic']])) {
2259
+					continue;
2260
+		}
2146 2261
 
2147 2262
 		// Censor the title.
2148 2263
 		censorText($row['title']);
2149 2264
 
2150
-		if ($row['start_date'] < strftime('%Y-%m-%d', forum_time(false)))
2151
-			$date = strftime('%Y-%m-%d', forum_time(false));
2152
-		else
2153
-			$date = $row['start_date'];
2265
+		if ($row['start_date'] < strftime('%Y-%m-%d', forum_time(false))) {
2266
+					$date = strftime('%Y-%m-%d', forum_time(false));
2267
+		} else {
2268
+					$date = $row['start_date'];
2269
+		}
2154 2270
 
2155 2271
 		// If the topic it is attached to is not approved then don't link it.
2156
-		if (!empty($row['id_first_msg']) && !$row['approved'])
2157
-			$row['id_board'] = $row['id_topic'] = $row['id_first_msg'] = 0;
2272
+		if (!empty($row['id_first_msg']) && !$row['approved']) {
2273
+					$row['id_board'] = $row['id_topic'] = $row['id_first_msg'] = 0;
2274
+		}
2158 2275
 
2159 2276
 		$allday = (empty($row['start_time']) || empty($row['end_time']) || empty($row['timezone']) || !in_array($row['timezone'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) ? true : false;
2160 2277
 
@@ -2180,24 +2297,27 @@  discard block
 block discarded – undo
2180 2297
 	}
2181 2298
 	$smcFunc['db_free_result']($request);
2182 2299
 
2183
-	foreach ($return as $mday => $array)
2184
-		$return[$mday][count($array) - 1]['is_last'] = true;
2300
+	foreach ($return as $mday => $array) {
2301
+			$return[$mday][count($array) - 1]['is_last'] = true;
2302
+	}
2185 2303
 
2186 2304
 	// If mods want to do somthing with this list of events, let them do that now.
2187 2305
 	call_integration_hook('integrate_ssi_recentEvents', array(&$return));
2188 2306
 
2189
-	if ($output_method != 'echo' || empty($return))
2190
-		return $return;
2307
+	if ($output_method != 'echo' || empty($return)) {
2308
+			return $return;
2309
+	}
2191 2310
 
2192 2311
 	// Well the output method is echo.
2193 2312
 	echo '
2194 2313
 			<span class="event">' . $txt['events'] . '</span> ';
2195
-	foreach ($return as $mday => $array)
2196
-		foreach ($array as $event)
2314
+	foreach ($return as $mday => $array) {
2315
+			foreach ($array as $event)
2197 2316
 		{
2198 2317
 			if ($event['can_edit'])
2199 2318
 				echo '
2200 2319
 				<a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> ';
2320
+	}
2201 2321
 
2202 2322
 			echo '
2203 2323
 				' . $event['link'] . (!$event['is_last'] ? ', ' : '');
@@ -2216,8 +2336,9 @@  discard block
 block discarded – undo
2216 2336
 	global $smcFunc;
2217 2337
 
2218 2338
 	// If $id is null, this was most likely called from a query string and should do nothing.
2219
-	if ($id === null)
2220
-		return;
2339
+	if ($id === null) {
2340
+			return;
2341
+	}
2221 2342
 
2222 2343
 	$request = $smcFunc['db_query']('', '
2223 2344
 		SELECT passwd, member_name, is_activated
@@ -2249,8 +2370,9 @@  discard block
 block discarded – undo
2249 2370
 	$attachments_boards = boardsAllowedTo('view_attachments');
2250 2371
 
2251 2372
 	// No boards?  Adios amigo.
2252
-	if (empty($attachments_boards))
2253
-		return array();
2373
+	if (empty($attachments_boards)) {
2374
+			return array();
2375
+	}
2254 2376
 
2255 2377
 	// Is it an array?
2256 2378
 	$attachment_ext = (array) $attachment_ext;
@@ -2334,8 +2456,9 @@  discard block
 block discarded – undo
2334 2456
 	call_integration_hook('integrate_ssi_recentAttachments', array(&$attachments));
2335 2457
 
2336 2458
 	// So you just want an array?  Here you can have it.
2337
-	if ($output_method == 'array' || empty($attachments))
2338
-		return $attachments;
2459
+	if ($output_method == 'array' || empty($attachments)) {
2460
+			return $attachments;
2461
+	}
2339 2462
 
2340 2463
 	// Give them the default.
2341 2464
 	echo '
@@ -2346,14 +2469,15 @@  discard block
 block discarded – undo
2346 2469
 				<th style="text-align: left; padding: 2">', $txt['downloads'], '</th>
2347 2470
 				<th style="text-align: left; padding: 2">', $txt['filesize'], '</th>
2348 2471
 			</tr>';
2349
-	foreach ($attachments as $attach)
2350
-		echo '
2472
+	foreach ($attachments as $attach) {
2473
+			echo '
2351 2474
 			<tr>
2352 2475
 				<td>', $attach['file']['link'], '</td>
2353 2476
 				<td>', $attach['member']['link'], '</td>
2354 2477
 				<td style="text-align: center">', $attach['file']['downloads'], '</td>
2355 2478
 				<td>', $attach['file']['filesize'], '</td>
2356 2479
 			</tr>';
2480
+	}
2357 2481
 	echo '
2358 2482
 		</table>';
2359 2483
 }
Please login to merge, or discard this patch.
Themes/default/GenericControls.template.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -227,7 +227,7 @@
 block discarded – undo
227 227
  * @param int|string $verify_id The verification control ID
228 228
  * @param string $display_type What type to display. Can be 'single' to only show one verification option or 'all' to show all of them
229 229
  * @param bool $reset Whether to reset the internal tracking counter
230
- * @return bool False if there's nothing else to show, true if $display_type is 'single', nothing otherwise
230
+ * @return boolean|null False if there's nothing else to show, true if $display_type is 'single', nothing otherwise
231 231
  */
232 232
 function template_control_verification($verify_id, $display_type = 'all', $reset = false)
233 233
 {
Please login to merge, or discard this patch.
Braces   +76 added lines, -58 removed lines patch added patch discarded remove patch
@@ -53,14 +53,15 @@  discard block
 block discarded – undo
53 53
 			foreach ($context['smileys'] as $location => $smileyRows)
54 54
 			{
55 55
 				$countLocations--;
56
-				if ($location == 'postform')
57
-					echo '
56
+				if ($location == 'postform') {
57
+									echo '
58 58
 						dropdown:
59 59
 						{';
60
-				elseif ($location == 'popup')
61
-					echo '
60
+				} elseif ($location == 'popup') {
61
+									echo '
62 62
 						popup:
63 63
 						{';
64
+				}
64 65
 
65 66
 				$numRows = count($smileyRows);
66 67
 				// This is needed because otherwise the editor will remove all the duplicate (empty) keys and leave only 1 additional line
@@ -72,21 +73,22 @@  discard block
 block discarded – undo
72 73
 						echo '
73 74
 								', JavaScriptEscape($smiley['code']), ': ', JavaScriptEscape($settings['smileys_url'] . '/' . $smiley['filename']), empty($smiley['isLast']) ? ',' : '';
74 75
 					}
75
-					if (empty($smileyRow['isLast']) && $numRows != 1)
76
-						echo ',
76
+					if (empty($smileyRow['isLast']) && $numRows != 1) {
77
+											echo ',
77 78
 						\'-', $emptyPlaceholder++, '\': \'\',';
79
+					}
78 80
 				}
79 81
 				echo '
80 82
 						}', $countLocations != 0 ? ',' : '';
81 83
 			}
82 84
 			echo '
83 85
 					}';
84
-		}
85
-		else
86
-			echo ',
86
+		} else {
87
+					echo ',
87 88
 					emoticons:
88 89
 					{},
89 90
 					emoticonsEnabled:false';
91
+		}
90 92
 
91 93
 		if ($context['show_bbc'] && $bbcContainer !== null)
92 94
 		{
@@ -97,15 +99,16 @@  discard block
 block discarded – undo
97 99
 			{
98 100
 				echo implode('|', $buttonRow);
99 101
 				$count_tags--;
100
-				if (!empty($count_tags))
101
-					echo '||';
102
+				if (!empty($count_tags)) {
103
+									echo '||';
104
+				}
102 105
 			}
103 106
 
104 107
 			echo '",';
105
-		}
106
-		else
107
-			echo ',
108
+		} else {
109
+					echo ',
108 110
 					toolbar: "",';
111
+		}
109 112
 
110 113
 		echo '
111 114
 				});
@@ -146,43 +149,48 @@  discard block
 block discarded – undo
146 149
 		</span>';
147 150
 
148 151
 	$tempTab = $context['tabindex'];
149
-	if (!empty($context['drafts_pm_save']))
150
-		$tempTab++;
151
-	elseif (!empty($context['drafts_save']))
152
-		$tempTab++;
153
-	elseif ($editor_context['preview_type'])
154
-		$tempTab++;
155
-	elseif ($context['show_spellchecking'])
156
-		$tempTab++;
152
+	if (!empty($context['drafts_pm_save'])) {
153
+			$tempTab++;
154
+	} elseif (!empty($context['drafts_save'])) {
155
+			$tempTab++;
156
+	} elseif ($editor_context['preview_type']) {
157
+			$tempTab++;
158
+	} elseif ($context['show_spellchecking']) {
159
+			$tempTab++;
160
+	}
157 161
 
158 162
 	$tempTab++;
159 163
 	$context['tabindex'] = $tempTab;
160 164
 
161
-	if (!empty($context['drafts_pm_save']))
162
-		echo '
165
+	if (!empty($context['drafts_pm_save'])) {
166
+			echo '
163 167
 		<input type="submit" name="save_draft" value="', $txt['draft_save'], '" tabindex="', --$tempTab, '" onclick="submitThisOnce(this);" accesskey="d" class="button_submit">
164 168
 		<input type="hidden" id="id_pm_draft" name="id_pm_draft" value="', empty($context['id_pm_draft']) ? 0 : $context['id_pm_draft'], '">';
169
+	}
165 170
 
166
-	if (!empty($context['drafts_save']))
167
-		echo '
171
+	if (!empty($context['drafts_save'])) {
172
+			echo '
168 173
 		<input type="submit" name="save_draft" value="', $txt['draft_save'], '" tabindex="', --$tempTab, '" onclick="return confirm(' . JavaScriptEscape($txt['draft_save_note']) . ') && submitThisOnce(this);" accesskey="d" class="button_submit">
169 174
 		<input type="hidden" id="id_draft" name="id_draft" value="', empty($context['id_draft']) ? 0 : $context['id_draft'], '">';
175
+	}
170 176
 
171
-	if ($context['show_spellchecking'])
172
-		echo '
177
+	if ($context['show_spellchecking']) {
178
+			echo '
173 179
 		<input type="button" value="', $txt['spell_check'], '" tabindex="', --$tempTab, '" onclick="oEditorHandle_', $editor_id, '.spellCheckStart();" class="button_submit">';
180
+	}
174 181
 
175
-	if ($editor_context['preview_type'])
176
-		echo '
182
+	if ($editor_context['preview_type']) {
183
+			echo '
177 184
 		<input type="submit" name="preview" value="', isset($editor_context['labels']['preview_button']) ? $editor_context['labels']['preview_button'] : $txt['preview'], '" tabindex="', --$tempTab, '" onclick="', $editor_context['preview_type'] == 2 ? 'return event.ctrlKey || previewPost();' : 'return submitThisOnce(this);', '" accesskey="p" class="button_submit">';
185
+	}
178 186
 
179 187
 
180 188
 	echo '
181 189
 		<input type="submit" value="', isset($editor_context['labels']['post_button']) ? $editor_context['labels']['post_button'] : $txt['post'], '" name="post" tabindex="', --$tempTab, '" onclick="return submitThisOnce(this);" accesskey="s" class="button_submit">';
182 190
 
183 191
 	// Load in the PM autosaver if it's enabled
184
-	if (!empty($context['drafts_pm_save']) && !empty($context['drafts_autosave']))
185
-		echo '
192
+	if (!empty($context['drafts_pm_save']) && !empty($context['drafts_autosave'])) {
193
+			echo '
186 194
 		<span class="righttext padding" style="display: block">
187 195
 			<span id="throbber" style="display:none"><img src="' . $settings['images_url'] . '/loading_sm.gif" alt="" class="centericon">&nbsp;</span>
188 196
 			<span id="draft_lastautosave" ></span>
@@ -200,10 +208,11 @@  discard block
 block discarded – undo
200 208
 				iFreq: ', (empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000), '
201 209
 			});
202 210
 		</script>';
211
+	}
203 212
 
204 213
 	// Start an instance of the auto saver if its enabled
205
-	if (!empty($context['drafts_save']) && !empty($context['drafts_autosave']))
206
-		echo '
214
+	if (!empty($context['drafts_save']) && !empty($context['drafts_autosave'])) {
215
+			echo '
207 216
 		<span class="righttext padding" style="display: block">
208 217
 			<span id="throbber" style="display:none"><img src="' . $settings['images_url'] . '/loading_sm.gif" alt="" class="centericon">&nbsp;</span>
209 218
 			<span id="draft_lastautosave" ></span>
@@ -220,7 +229,8 @@  discard block
 block discarded – undo
220 229
 				iFreq: ', $context['drafts_autosave_frequency'], '
221 230
 			});
222 231
 		</script>';
223
-}
232
+	}
233
+	}
224 234
 
225 235
 /**
226 236
  * This template displays a verification form
@@ -237,51 +247,57 @@  discard block
 block discarded – undo
237 247
 	$verify_context = &$context['controls']['verification'][$verify_id];
238 248
 
239 249
 	// Keep track of where we are.
240
-	if (empty($verify_context['tracking']) || $reset)
241
-		$verify_context['tracking'] = 0;
250
+	if (empty($verify_context['tracking']) || $reset) {
251
+			$verify_context['tracking'] = 0;
252
+	}
242 253
 
243 254
 	// How many items are there to display in total.
244 255
 	$total_items = count($verify_context['questions']) + ($verify_context['show_visual'] || $verify_context['can_recaptcha'] ? 1 : 0);
245 256
 
246 257
 	// If we've gone too far, stop.
247
-	if ($verify_context['tracking'] > $total_items)
248
-		return false;
258
+	if ($verify_context['tracking'] > $total_items) {
259
+			return false;
260
+	}
249 261
 
250 262
 	// Loop through each item to show them.
251 263
 	for ($i = 0; $i < $total_items; $i++)
252 264
 	{
253 265
 		// If we're after a single item only show it if we're in the right place.
254
-		if ($display_type == 'single' && $verify_context['tracking'] != $i)
255
-			continue;
266
+		if ($display_type == 'single' && $verify_context['tracking'] != $i) {
267
+					continue;
268
+		}
256 269
 
257
-		if ($display_type != 'single')
258
-			echo '
270
+		if ($display_type != 'single') {
271
+					echo '
259 272
 			<div id="verification_control_', $i, '" class="verification_control">';
273
+		}
260 274
 
261 275
 		// Display empty field, but only if we have one, and it's the first time.
262
-		if ($verify_context['empty_field'] && empty($i))
263
-			echo '
276
+		if ($verify_context['empty_field'] && empty($i)) {
277
+					echo '
264 278
 				<div class="smalltext vv_special">
265 279
 					', $txt['visual_verification_hidden'], ':
266 280
 					<input type="text" name="', $_SESSION[$verify_id . '_vv']['empty_field'], '" autocomplete="off" size="30" value="">
267 281
 				</div>';
282
+		}
268 283
 
269 284
 		// Do the actual stuff
270 285
 		if ($i == 0 && ($verify_context['show_visual'] || $verify_context['can_recaptcha']))
271 286
 		{
272 287
 			if ($verify_context['show_visual'])
273 288
 			{
274
-				if ($context['use_graphic_library'])
275
-					echo '
289
+				if ($context['use_graphic_library']) {
290
+									echo '
276 291
 				<img src="', $verify_context['image_href'], '" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '">';
277
-				else
278
-					echo '
292
+				} else {
293
+									echo '
279 294
 				<img src="', $verify_context['image_href'], ';letter=1" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_1">
280 295
 				<img src="', $verify_context['image_href'], ';letter=2" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_2">
281 296
 				<img src="', $verify_context['image_href'], ';letter=3" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_3">
282 297
 				<img src="', $verify_context['image_href'], ';letter=4" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_4">
283 298
 				<img src="', $verify_context['image_href'], ';letter=5" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_5">
284 299
 				<img src="', $verify_context['image_href'], ';letter=6" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_6">';
300
+				}
285 301
 
286 302
 				echo '
287 303
 				<div class="smalltext" style="margin: 4px 0 8px 0;">
@@ -297,8 +313,7 @@  discard block
 block discarded – undo
297 313
 				<div class="g-recaptcha centertext" data-sitekey="' . $verify_context['recaptcha_site_key'] . '" data-theme="' . $verify_context['recaptcha_theme'] . '"></div><br>
298 314
 				<script type="text/javascript" src="https://www.google.com/recaptcha/api.js"></script>';
299 315
 			}
300
-		}
301
-		else
316
+		} else
302 317
 		{
303 318
 			// Where in the question array is this question?
304 319
 			$qIndex = $verify_context['show_visual'] ? $i - 1 : $i;
@@ -310,21 +325,24 @@  discard block
 block discarded – undo
310 325
 				</div>';
311 326
 		}
312 327
 
313
-		if ($display_type != 'single')
314
-			echo '
328
+		if ($display_type != 'single') {
329
+					echo '
315 330
 			</div>';
331
+		}
316 332
 
317 333
 		// If we were displaying just one and we did it, break.
318
-		if ($display_type == 'single' && $verify_context['tracking'] == $i)
319
-			break;
334
+		if ($display_type == 'single' && $verify_context['tracking'] == $i) {
335
+					break;
336
+		}
320 337
 	}
321 338
 
322 339
 	// Assume we found something, always,
323 340
 	$verify_context['tracking']++;
324 341
 
325 342
 	// Tell something displaying piecemeal to keep going.
326
-	if ($display_type == 'single')
327
-		return true;
328
-}
343
+	if ($display_type == 'single') {
344
+			return true;
345
+	}
346
+	}
329 347
 
330 348
 ?>
331 349
\ No newline at end of file
Please login to merge, or discard this patch.
Themes/default/MoveTopic.template.php 4 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -83,6 +83,7 @@
 block discarded – undo
83 83
  * Redirection topic options
84 84
  *
85 85
  * @var string $type What type of topic this is for - currently 'merge' or 'move'. Used to display appropriate text strings...
86
+ * @param string $type
86 87
  */
87 88
 function template_redirect_options($type)
88 89
 {
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	// Stick our "create a redirection topic" template in here...
64 64
 	template_redirect_options('move');
65 65
 
66
-    echo '
66
+	echo '
67 67
 					<input type="submit" value="', $txt['move_topic'], '" onclick="return submitThisOnce(this);" accesskey="s" class="button_submit">
68 68
 				</div>
69 69
 			</div>';
@@ -86,9 +86,9 @@  discard block
 block discarded – undo
86 86
  */
87 87
 function template_redirect_options($type)
88 88
 {
89
-    global $txt, $context, $modSettings;
89
+	global $txt, $context, $modSettings;
90 90
 
91
-    echo '
91
+	echo '
92 92
 					<label for="postRedirect"><input type="checkbox" name="postRedirect" id="postRedirect"', $context['is_approved'] ? ' checked' : '', ' onclick="', $context['is_approved'] ? '' : 'if (this.checked && !confirm(\'' . $txt[$type . '_topic_unapproved_js'] . '\')) return false; ', 'document.getElementById(\'reasonArea\').style.display = this.checked ? \'block\' : \'none\';" class="input_check"> ', $txt['post_redirection'], '.</label>
93 93
 					<fieldset id="reasonArea" style="margin-top: 1ex;', $context['is_approved'] ? '' : 'display: none;', '">
94 94
 						<dl class="settings">
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
 
40 40
 		foreach ($category['boards'] as $board)
41 41
 			echo '
42
-									<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', $board['id'] == $context['current_board'] ? ' disabled' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level']-1) . '=&gt; ' : '', $board['name'], '</option>';
42
+									<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', $board['id'] == $context['current_board'] ? ' disabled' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=&gt; ' : '', $board['name'], '</option>';
43 43
 		echo '
44 44
 								</optgroup>';
45 45
 	}
Please login to merge, or discard this patch.
Braces   +25 added lines, -20 removed lines patch added patch discarded remove patch
@@ -37,9 +37,10 @@  discard block
 block discarded – undo
37 37
 		echo '
38 38
 								<optgroup label="', $category['name'], '">';
39 39
 
40
-		foreach ($category['boards'] as $board)
41
-			echo '
40
+		foreach ($category['boards'] as $board) {
41
+					echo '
42 42
 									<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', $board['id'] == $context['current_board'] ? ' disabled' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level']-1) . '=&gt; ' : '', $board['name'], '</option>';
43
+		}
43 44
 		echo '
44 45
 								</optgroup>';
45 46
 	}
@@ -68,9 +69,10 @@  discard block
 block discarded – undo
68 69
 				</div>
69 70
 			</div>';
70 71
 
71
-	if ($context['back_to_topic'])
72
-		echo '
72
+	if ($context['back_to_topic']) {
73
+			echo '
73 74
 			<input type="hidden" name="goback" value="1">';
75
+	}
74 76
 
75 77
 	echo '
76 78
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -120,8 +122,7 @@  discard block
 block discarded – undo
120 122
 									<option value="86400">', $txt['two_months'], '</option>
121 123
 								</select>
122 124
 							</dd>';
123
-	}
124
-	else
125
+	} else
125 126
 	{
126 127
 		echo '
127 128
 							<input type="hidden" name="redirect_expires" value="0">';
@@ -217,9 +218,9 @@  discard block
 block discarded – undo
217 218
 						<input type="submit" value="', $txt['go'], '" class="button_submit">
218 219
 					</form>';
219 220
 
221
+	} else {
222
+			echo $txt['target_below'];
220 223
 	}
221
-	else
222
-		echo $txt['target_below'];
223 224
 
224 225
 	echo '				</h4>
225 226
 			</div>';
@@ -237,12 +238,13 @@  discard block
 block discarded – undo
237 238
 
238 239
 		$merge_button = create_button('merge', 'merge', '');
239 240
 
240
-		foreach ($context['topics'] as $topic)
241
-			echo '
241
+		foreach ($context['topics'] as $topic) {
242
+					echo '
242 243
 						<li>
243 244
 							<a href="', $scripturl, '?action=mergetopics;sa=options;board=', $context['current_board'], '.0;from=', $context['origin_topic'], ';to=', $topic['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $merge_button, '</a>&nbsp;
244 245
 							<a href="', $scripturl, '?topic=', $topic['id'], '.0" target="_blank" class="new_win">', $topic['subject'], '</a> ', $txt['started_by'], ' ', $topic['poster']['link'], '
245 246
 						</li>';
247
+		}
246 248
 
247 249
 		echo '
248 250
 					</ul>
@@ -251,8 +253,7 @@  discard block
 block discarded – undo
251 253
 				<div class="pagesection">
252 254
 					', $context['page_index'], '
253 255
 				</div>';
254
-	}
255
-	else
256
+	} else
256 257
 	{
257 258
 		// Just a nice "There aren't any topics" message
258 259
 		echo '
@@ -306,8 +307,8 @@  discard block
 block discarded – undo
306 307
 					</tr>
307 308
 				</thead>
308 309
 				<tbody>';
309
-		foreach ($context['topics'] as $topic)
310
-			echo '
310
+		foreach ($context['topics'] as $topic) {
311
+					echo '
311 312
 					<tr class="windowbg">
312 313
 						<td>
313 314
 							<input type="checkbox" class="input_check" name="topics[]" value="' . $topic['id'] . '" checked>
@@ -327,6 +328,7 @@  discard block
 block discarded – undo
327 328
 							<input type="checkbox" class="input_check" name="notifications[]" value="' . $topic['id'] . '" checked>
328 329
 						</td>
329 330
 					</tr>';
331
+		}
330 332
 		echo '
331 333
 				</tbody>
332 334
 			</table>
@@ -337,9 +339,10 @@  discard block
 block discarded – undo
337 339
 				<fieldset id="merge_subject" class="merge_options">
338 340
 					<legend>', $txt['merge_select_subject'], '</legend>
339 341
 					<select name="subject" onchange="this.form.custom_subject.style.display = (this.options[this.selectedIndex].value != 0) ? \'none\': \'\' ;">';
340
-	foreach ($context['topics'] as $topic)
341
-		echo '
342
+	foreach ($context['topics'] as $topic) {
343
+			echo '
342 344
 						<option value="', $topic['id'], '"' . ($topic['selected'] ? ' selected' : '') . '>', $topic['subject'], '</option>';
345
+	}
343 346
 	echo '
344 347
 						<option value="0">', $txt['merge_custom_subject'], ':</option>
345 348
 					</select>
@@ -357,11 +360,12 @@  discard block
 block discarded – undo
357 360
 				<fieldset id="merge_board" class="merge_options">
358 361
 					<legend>', $txt['merge_select_target_board'], '</legend>
359 362
 					<ul>';
360
-		foreach ($context['boards'] as $board)
361
-			echo '
363
+		foreach ($context['boards'] as $board) {
364
+					echo '
362 365
 						<li>
363 366
 							<input type="radio" name="board" value="' . $board['id'] . '"' . ($board['selected'] ? ' checked' : '') . ' class="input_radio"> ' . $board['name'] . '
364 367
 						</li>';
368
+		}
365 369
 		echo '
366 370
 					</ul>
367 371
 				</fieldset>';
@@ -372,11 +376,12 @@  discard block
 block discarded – undo
372 376
 				<fieldset id="merge_poll" class="merge_options">
373 377
 					<legend>' . $txt['merge_select_poll'] . '</legend>
374 378
 					<ul>';
375
-		foreach ($context['polls'] as $poll)
376
-			echo '
379
+		foreach ($context['polls'] as $poll) {
380
+					echo '
377 381
 						<li>
378 382
 							<input type="radio" name="poll" value="' . $poll['id'] . '"' . ($poll['selected'] ? ' checked' : '') . ' class="input_radio"> ' . $poll['question'] . ' (' . $txt['topic'] . ': <a href="' . $scripturl . '?topic=' . $poll['topic']['id'] . '.0" target="_blank" class="new_win">' . $poll['topic']['subject'] . '</a>)
379 383
 						</li>';
384
+		}
380 385
 		echo '
381 386
 						<li>
382 387
 							<input type="radio" name="poll" value="-1" class="input_radio"> (' . $txt['merge_no_poll'] . ')
Please login to merge, or discard this patch.
Themes/default/Packages.template.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1096,7 +1096,7 @@
 block discarded – undo
1096 1096
 /**
1097 1097
  * CHMOD control form
1098 1098
  *
1099
- * @return bool False if nothing to do.
1099
+ * @return false|null False if nothing to do.
1100 1100
  */
1101 1101
 function template_control_chmod()
1102 1102
 {
Please login to merge, or discard this patch.
Braces   +144 added lines, -104 removed lines patch added patch discarded remove patch
@@ -31,12 +31,13 @@  discard block
 block discarded – undo
31 31
 		</div>
32 32
 		<div class="information">';
33 33
 
34
-	if ($context['is_installed'])
35
-		echo '
34
+	if ($context['is_installed']) {
35
+			echo '
36 36
 			<strong>', $txt['package_installed_warning1'], '</strong><br>
37 37
 			<br>
38 38
 			', $txt['package_installed_warning2'], '<br>
39 39
 			<br>';
40
+	}
40 41
 
41 42
 	echo $txt['package_installed_warning3'], '
42 43
 		</div><br>';
@@ -63,8 +64,9 @@  discard block
 block discarded – undo
63 64
 				', $context['package_readme'], '
64 65
 				<span class="floatright">', $txt['package_available_readme_language'], '
65 66
 					<select name="readme_language" id="readme_language" onchange="if (this.options[this.selectedIndex].value) window.location.href = smf_prepareScriptUrl(smf_scripturl + \'', '?action=admin;area=packages;sa=', $context['uninstalling'] ? 'uninstall' : 'install', ';package=', $context['filename'], ';readme=\' + this.options[this.selectedIndex].value + \';license=\' + get_selected(\'license_language\'));">';
66
-						foreach ($context['readmes'] as $a => $b)
67
-							echo '<option value="', $b, '"', $a === 'selected' ? ' selected' : '', '>', $b == 'default' ? $txt['package_readme_default'] : ucfirst($b), '</option>';
67
+						foreach ($context['readmes'] as $a => $b) {
68
+													echo '<option value="', $b, '"', $a === 'selected' ? ' selected' : '', '>', $b == 'default' ? $txt['package_readme_default'] : ucfirst($b), '</option>';
69
+						}
68 70
 			echo '
69 71
 					</select>
70 72
 				</span>
@@ -83,8 +85,9 @@  discard block
 block discarded – undo
83 85
 				', $context['package_license'], '
84 86
 				<span class="floatright">', $txt['package_available_license_language'], '
85 87
 					<select name="license_language" id="license_language" onchange="if (this.options[this.selectedIndex].value) window.location.href = smf_prepareScriptUrl(smf_scripturl + \'', '?action=admin;area=packages;sa=install', ';package=', $context['filename'], ';license=\' + this.options[this.selectedIndex].value + \';readme=\' + get_selected(\'readme_language\'));">';
86
-						foreach ($context['licenses'] as $a => $b)
87
-							echo '<option value="', $b, '"', $a === 'selected' ? ' selected' : '', '>', $b == 'default' ? $txt['package_license_default'] : ucfirst($b), '</option>';
88
+						foreach ($context['licenses'] as $a => $b) {
89
+													echo '<option value="', $b, '"', $a === 'selected' ? ' selected' : '', '>', $b == 'default' ? $txt['package_license_default'] : ucfirst($b), '</option>';
90
+						}
88 91
 			echo '
89 92
 					</select>
90 93
 				</span>
@@ -110,9 +113,10 @@  discard block
 block discarded – undo
110 113
 					', $txt['package_db_uninstall_actions'], ':
111 114
 					<ul>';
112 115
 
113
-		foreach ($context['database_changes'] as $change)
114
-			echo '
116
+		foreach ($context['database_changes'] as $change) {
117
+					echo '
115 118
 						<li>', $change, '</li>';
119
+		}
116 120
 		echo '
117 121
 					</ul>
118 122
 				</div>
@@ -122,14 +126,14 @@  discard block
 block discarded – undo
122 126
 	echo '
123 127
 			<div class="information">';
124 128
 
125
-	if (empty($context['actions']) && empty($context['database_changes']))
126
-		echo '
129
+	if (empty($context['actions']) && empty($context['database_changes'])) {
130
+			echo '
127 131
 				<br>
128 132
 				<div class="errorbox">
129 133
 					', $txt['corrupt_compatible'], '
130 134
 				</div>
131 135
 			</div>';
132
-	else
136
+	} else
133 137
 	{
134 138
 		echo '
135 139
 					', $txt['perform_actions'], '
@@ -229,9 +233,10 @@  discard block
 block discarded – undo
229 233
 					<tr class="title_bar">
230 234
 						<td></td>
231 235
 						<td>';
232
-				if (!empty($context['themes_locked']))
233
-					echo '
236
+				if (!empty($context['themes_locked'])) {
237
+									echo '
234 238
 							<input type="hidden" name="custom_theme[]" value="', $id, '">';
239
+				}
235 240
 				echo '
236 241
 							<input type="checkbox" name="custom_theme[]" id="custom_theme_', $id, '" value="', $id, '" class="input_check" onclick="', (!empty($theme['has_failure']) ? 'if (this.form.custom_theme_' . $id . '.checked && !confirm(\'' . $txt['package_theme_failure_warning'] . '\')) return false;' : ''), 'invertAll(this, this.form, \'dummy_theme_', $id, '\', true);"', !empty($context['themes_locked']) ? ' disabled checked' : '', '>
237 242
 						</td>
@@ -372,14 +377,15 @@  discard block
 block discarded – undo
372 377
 	</script>';
373 378
 
374 379
 	// And a bit more for database changes.
375
-	if (!empty($context['database_changes']))
376
-		echo '
380
+	if (!empty($context['database_changes'])) {
381
+			echo '
377 382
 	<script>
378 383
 		var database_changes_area = document.getElementById(\'db_changes_div\');
379 384
 		var db_vis = false;
380 385
 		database_changes_area.style.display = "none";
381 386
 	</script>';
382
-}
387
+	}
388
+	}
383 389
 
384 390
 /**
385 391
  * Extract package contents
@@ -411,12 +417,12 @@  discard block
 block discarded – undo
411 417
 				<h3 class="catbg">', $context['uninstalling'] ? $txt['uninstall'] : $txt['extracting'], '</h3>
412 418
 			</div>
413 419
 			<div class="information">', $txt['package_installed_extract'], '</div>';
414
-	}
415
-	else
416
-		echo '
420
+	} else {
421
+			echo '
417 422
 			<div class="cat_bar">
418 423
 				<h3 class="catbg">', $txt['package_installed_redirecting'], '</h3>
419 424
 			</div>';
425
+	}
420 426
 
421 427
 	echo '
422 428
 		<div class="windowbg">';
@@ -427,25 +433,25 @@  discard block
 block discarded – undo
427 433
 		echo '
428 434
 			', $context['redirect_text'], '<br><br>
429 435
 			<a href="', $context['redirect_url'], '">', $txt['package_installed_redirect_go_now'], '</a> | <a href="', $scripturl, '?action=admin;area=packages;sa=browse">', $txt['package_installed_redirect_cancel'], '</a>';
430
-	}
431
-	elseif ($context['uninstalling'])
432
-		echo '
436
+	} elseif ($context['uninstalling']) {
437
+			echo '
433 438
 			', $txt['package_uninstall_done'];
434
-	elseif ($context['install_finished'])
439
+	} elseif ($context['install_finished'])
435 440
 	{
436
-		if ($context['extract_type'] == 'avatar')
437
-			echo '
441
+		if ($context['extract_type'] == 'avatar') {
442
+					echo '
438 443
 				', $txt['avatars_extracted'];
439
-		elseif ($context['extract_type'] == 'language')
440
-			echo '
444
+		} elseif ($context['extract_type'] == 'language') {
445
+					echo '
441 446
 				', $txt['language_extracted'];
442
-		else
443
-			echo '
447
+		} else {
448
+					echo '
444 449
 				', $txt['package_installed_done'];
445
-	}
446
-	else
447
-		echo '
450
+		}
451
+	} else {
452
+			echo '
448 453
 			', $txt['corrupt_compatible'];
454
+	}
449 455
 
450 456
 	echo '
451 457
 		</div>';
@@ -479,9 +485,10 @@  discard block
 block discarded – undo
479 485
 		<div class="windowbg">
480 486
 			<ol>';
481 487
 
482
-	foreach ($context['files'] as $fileinfo)
483
-		echo '
488
+	foreach ($context['files'] as $fileinfo) {
489
+			echo '
484 490
 				<li><a href="', $scripturl, '?action=admin;area=packages;sa=examine;package=', $context['filename'], ';file=', $fileinfo['filename'], '" title="', $txt['view'], '">', $fileinfo['filename'], '</a> (', $fileinfo['size'], ' ', $txt['package_bytes'], ')</li>';
491
+	}
485 492
 
486 493
 	echo '
487 494
 			</ol>
@@ -545,9 +552,10 @@  discard block
 block discarded – undo
545 552
 			</script>
546 553
 			<div id="yourVersion" style="display:none">', $context['forum_version'], '</div>';
547 554
 
548
-	if (empty($modSettings['disable_smf_js']))
549
-		echo '
555
+	if (empty($modSettings['disable_smf_js'])) {
556
+			echo '
550 557
 			<script src="', $scripturl, '?action=viewsmfile;filename=latest-news.js"></script>';
558
+	}
551 559
 
552 560
 	// This sets the announcements and current versions themselves ;).
553 561
 	echo '
@@ -586,12 +594,13 @@  discard block
 block discarded – undo
586 594
 		}
587 595
 	}
588 596
 
589
-	if (!$mods_available)
590
-		echo '
597
+	if (!$mods_available) {
598
+			echo '
591 599
 		<div class="noticebox">', $txt['no_packages'], '</div>';
592
-	else
593
-		echo '
600
+	} else {
601
+			echo '
594 602
 		<br>';
603
+	}
595 604
 
596 605
 	// the advanced (emulation) box, collapsed by default
597 606
 	echo '
@@ -680,11 +689,12 @@  discard block
 block discarded – undo
680 689
 {
681 690
 	global $context, $txt, $scripturl;
682 691
 
683
-	if (!empty($context['package_ftp']['error']))
684
-			echo '
692
+	if (!empty($context['package_ftp']['error'])) {
693
+				echo '
685 694
 					<div class="errorbox">
686 695
 						<pre>', $context['package_ftp']['error'], '</pre>
687 696
 					</div>';
697
+	}
688 698
 
689 699
 	echo '
690 700
 	<div id="admin_form_wrapper">
@@ -765,13 +775,14 @@  discard block
 block discarded – undo
765 775
 				<fieldset>
766 776
 					<legend>' . $txt['package_servers'] . '</legend>
767 777
 					<ul class="package_servers">';
768
-	foreach ($context['servers'] as $server)
769
-		echo '
778
+	foreach ($context['servers'] as $server) {
779
+			echo '
770 780
 						<li class="flow_auto">
771 781
 							<span class="floatleft">' . $server['name'] . '</span>
772 782
 							<span class="package_server floatright"><a href="' . $scripturl . '?action=admin;area=packages;get;sa=remove;server=' . $server['id'] . ';', $context['session_var'], '=', $context['session_id'], '">[ ' . $txt['delete'] . ' ]</a></span>
773 783
 							<span class="package_server floatright"><a href="' . $scripturl . '?action=admin;area=packages;get;sa=browse;server=' . $server['id'] . '">[ ' . $txt['package_browse'] . ' ]</a></span>
774 784
 						</li>';
785
+	}
775 786
 	echo '
776 787
 					</ul>
777 788
 				</fieldset>
@@ -858,11 +869,12 @@  discard block
 block discarded – undo
858 869
 		<div class="windowbg2">';
859 870
 
860 871
 	// No packages, as yet.
861
-	if (empty($context['package_list']))
862
-		echo '
872
+	if (empty($context['package_list'])) {
873
+			echo '
863 874
 			<ul>
864 875
 				<li>', $txt['no_packages'], '</li>
865 876
 			</ul>';
877
+	}
866 878
 	// List out the packages...
867 879
 	else
868 880
 	{
@@ -874,11 +886,12 @@  discard block
 block discarded – undo
874 886
 				<li>
875 887
 					<strong><span id="ps_img_', $i, '" class="toggle_up" alt="*" style="display: none;"></span> ', $packageSection['title'], '</strong>';
876 888
 
877
-			if (!empty($packageSection['text']))
878
-				echo '
889
+			if (!empty($packageSection['text'])) {
890
+							echo '
879 891
 					<div class="sub_bar">
880 892
 						<h3 class="subbg">', $packageSection['text'], '</h3>
881 893
 					</div>';
894
+			}
882 895
 
883 896
 			echo '
884 897
 					<', $context['list_type'], ' id="package_section_', $i, '" class="packages">';
@@ -888,13 +901,15 @@  discard block
 block discarded – undo
888 901
 				echo '
889 902
 						<li>';
890 903
 				// Textual message. Could be empty just for a blank line...
891
-				if ($package['is_text'])
892
-					echo '
904
+				if ($package['is_text']) {
905
+									echo '
893 906
 							', empty($package['name']) ? '&nbsp;' : $package['name'];
907
+				}
894 908
 				// This is supposed to be a rule..
895
-				elseif ($package['is_line'])
896
-					echo '
909
+				elseif ($package['is_line']) {
910
+									echo '
897 911
 						<hr>';
912
+				}
898 913
 				// A remote link.
899 914
 				elseif ($package['is_remote'])
900 915
 				{
@@ -916,21 +931,25 @@  discard block
 block discarded – undo
916 931
 						<ul id="package_section_', $i, '_pkg_', $id, '" class="package_section">';
917 932
 
918 933
 					// Show the mod type?
919
-					if ($package['type'] != '')
920
-						echo '
934
+					if ($package['type'] != '') {
935
+											echo '
921 936
 							<li class="package_section">', $txt['package_type'], ':&nbsp; ', $smcFunc['ucwords']($smcFunc['strtolower']($package['type'])), '</li>';
937
+					}
922 938
 					// Show the version number?
923
-					if ($package['version'] != '')
924
-						echo '
939
+					if ($package['version'] != '') {
940
+											echo '
925 941
 							<li class="package_section">', $txt['mod_version'], ':&nbsp; ', $package['version'], '</li>';
942
+					}
926 943
 					// How 'bout the author?
927
-					if (!empty($package['author']) && $package['author']['name'] != '' && isset($package['author']['link']))
928
-						echo '
944
+					if (!empty($package['author']) && $package['author']['name'] != '' && isset($package['author']['link'])) {
945
+											echo '
929 946
 							<li class="package_section">', $txt['mod_author'], ':&nbsp; ', $package['author']['link'], '</li>';
947
+					}
930 948
 					// The homepage....
931
-					if ($package['author']['website']['link'] != '')
932
-						echo '
949
+					if ($package['author']['website']['link'] != '') {
950
+											echo '
933 951
 							<li class="package_section">', $txt['author_website'], ':&nbsp; ', $package['author']['website']['link'], '</li>';
952
+					}
934 953
 
935 954
 					// Desciption: bleh bleh!
936 955
 					// Location of file: http://someplace/.
@@ -983,8 +1002,8 @@  discard block
 block discarded – undo
983 1002
 
984 1003
 				foreach ($ps['items'] as $id => $package)
985 1004
 				{
986
-					if (!$package['is_text'] && !$package['is_line'] && !$package['is_remote'])
987
-						echo '
1005
+					if (!$package['is_text'] && !$package['is_line'] && !$package['is_remote']) {
1006
+											echo '
988 1007
 				var oPackageToggle_', $section, '_pkg_', $id, ' = new smc_Toggle({
989 1008
 					bToggleEnabled: true,
990 1009
 					bCurrentlyCollapsed: true,
@@ -999,6 +1018,7 @@  discard block
 block discarded – undo
999 1018
 						}
1000 1019
 					]
1001 1020
 				});';
1021
+					}
1002 1022
 				}
1003 1023
 			}
1004 1024
 			echo '
@@ -1039,9 +1059,10 @@  discard block
 block discarded – undo
1039 1059
 {
1040 1060
 	global $context, $txt, $scripturl;
1041 1061
 
1042
-	if (!empty($context['saved_successful']))
1043
-		echo '
1062
+	if (!empty($context['saved_successful'])) {
1063
+			echo '
1044 1064
 	<div class="infobox">', $txt['settings_saved'], '</div>';
1065
+	}
1045 1066
 
1046 1067
 	echo '
1047 1068
 	<div id="admincenter">
@@ -1103,8 +1124,9 @@  discard block
 block discarded – undo
1103 1124
 	global $context, $txt;
1104 1125
 
1105 1126
 	// Nothing to do? Brilliant!
1106
-	if (empty($context['package_ftp']))
1107
-		return false;
1127
+	if (empty($context['package_ftp'])) {
1128
+			return false;
1129
+	}
1108 1130
 
1109 1131
 	if (empty($context['package_ftp']['form_elements_only']))
1110 1132
 	{
@@ -1113,19 +1135,21 @@  discard block
 block discarded – undo
1113 1135
 				<div id="need_writable_list" class="smalltext">
1114 1136
 					', $txt['package_ftp_why_file_list'], '
1115 1137
 					<ul style="display: inline;">';
1116
-		if (!empty($context['notwritable_files']))
1117
-			foreach ($context['notwritable_files'] as $file)
1138
+		if (!empty($context['notwritable_files'])) {
1139
+					foreach ($context['notwritable_files'] as $file)
1118 1140
 				echo '
1119 1141
 						<li>', $file, '</li>';
1142
+		}
1120 1143
 
1121 1144
 		echo '
1122 1145
 					</ul>';
1123 1146
 
1124
-		if (!$context['server']['is_windows'])
1125
-			echo '
1147
+		if (!$context['server']['is_windows']) {
1148
+					echo '
1126 1149
 				<hr>
1127 1150
 				', $txt['package_chmod_linux'], '<br />
1128 1151
 				<tt># chmod a+w ', implode(' ', $context['notwritable_files']), '</tt>';
1152
+		}
1129 1153
 
1130 1154
 		echo '
1131 1155
 				</div>';
@@ -1136,9 +1160,10 @@  discard block
 block discarded – undo
1136 1160
 					<tt id="ftp_error_message">', !empty($context['package_ftp']['error']) ? $context['package_ftp']['error'] : '', '</tt>
1137 1161
 				</div></div>';
1138 1162
 
1139
-	if (!empty($context['package_ftp']['destination']))
1140
-		echo '
1163
+	if (!empty($context['package_ftp']['destination'])) {
1164
+			echo '
1141 1165
 				<form action="', $context['package_ftp']['destination'], '" method="post" accept-charset="', $context['character_set'], '" style="margin: 0;">';
1166
+	}
1142 1167
 
1143 1168
 	echo '
1144 1169
 					<fieldset>
@@ -1171,25 +1196,28 @@  discard block
 block discarded – undo
1171 1196
 					</dl>
1172 1197
 					</fieldset>';
1173 1198
 
1174
-	if (empty($context['package_ftp']['form_elements_only']))
1175
-		echo '
1199
+	if (empty($context['package_ftp']['form_elements_only'])) {
1200
+			echo '
1176 1201
 
1177 1202
 					<div class="righttext" style="margin: 1ex;">
1178 1203
 						<span id="test_ftp_placeholder_full"></span>
1179 1204
 						<input type="submit" value="', $txt['package_proceed'], '" class="button_submit">
1180 1205
 					</div>';
1206
+	}
1181 1207
 
1182
-	if (!empty($context['package_ftp']['destination']))
1183
-		echo '
1208
+	if (!empty($context['package_ftp']['destination'])) {
1209
+			echo '
1184 1210
 					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1185 1211
 				</form>';
1212
+	}
1186 1213
 
1187 1214
 	// Hide the details of the list.
1188
-	if (empty($context['package_ftp']['form_elements_only']))
1189
-		echo '
1215
+	if (empty($context['package_ftp']['form_elements_only'])) {
1216
+			echo '
1190 1217
 		<script>
1191 1218
 			document.getElementById(\'need_writable_list\').style.display = \'none\';
1192 1219
 		</script>';
1220
+	}
1193 1221
 
1194 1222
 	// Quick generate the test button.
1195 1223
 	echo '
@@ -1545,9 +1573,10 @@  discard block
 block discarded – undo
1545 1573
 				<tr class="windowbg">
1546 1574
 					<td width="30%"><strong>';
1547 1575
 
1548
-				if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive'))
1549
-					echo '
1576
+				if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) {
1577
+									echo '
1550 1578
 						<span class="generic_icons folder"></span>';
1579
+				}
1551 1580
 
1552 1581
 				echo '
1553 1582
 						', $name, '
@@ -1564,8 +1593,9 @@  discard block
 block discarded – undo
1564 1593
 				</tr>
1565 1594
 			';
1566 1595
 
1567
-		if (!empty($dir['contents']))
1568
-			template_permission_show_contents($name, $dir['contents'], 1);
1596
+		if (!empty($dir['contents'])) {
1597
+					template_permission_show_contents($name, $dir['contents'], 1);
1598
+		}
1569 1599
 	}
1570 1600
 
1571 1601
 	echo '
@@ -1601,13 +1631,14 @@  discard block
 block discarded – undo
1601 1631
 			</fieldset>';
1602 1632
 
1603 1633
 	// Likely to need FTP?
1604
-	if (empty($context['ftp_connected']))
1605
-		echo '
1634
+	if (empty($context['ftp_connected'])) {
1635
+			echo '
1606 1636
 			<p>
1607 1637
 				', $txt['package_file_perms_ftp_details'], ':
1608 1638
 			</p>
1609 1639
 			', template_control_chmod(), '
1610 1640
 			<div class="noticebox">', $txt['package_file_perms_ftp_retain'], '</div>';
1641
+	}
1611 1642
 
1612 1643
 	echo '
1613 1644
 			<span id="test_ftp_placeholder_full"></span>
@@ -1616,9 +1647,10 @@  discard block
 block discarded – undo
1616 1647
 		</div>';
1617 1648
 
1618 1649
 	// Any looks fors we've already done?
1619
-	foreach ($context['look_for'] as $path)
1620
-		echo '
1650
+	foreach ($context['look_for'] as $path) {
1651
+			echo '
1621 1652
 			<input type="hidden" name="back_look[]" value="', $path, '">';
1653
+	}
1622 1654
 	echo '
1623 1655
 	</form><br>';
1624 1656
 }
@@ -1657,9 +1689,10 @@  discard block
 block discarded – undo
1657 1689
 				<td class="smalltext" width="30%">' . str_repeat('&nbsp;', $level * 5), '
1658 1690
 					', (!empty($dir['type']) && $dir['type'] == 'dir_recursive') || !empty($dir['list_contents']) ? '<a id="link_' . $cur_ident . '" href="' . $scripturl . '?action=admin;area=packages;sa=perms;find=' . base64_encode($ident . '/' . $name) . ';back_look=' . $context['back_look_data'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '#fol_' . $cur_ident . '" onclick="return expandFolder(\'' . $cur_ident . '\', \'' . addcslashes($ident . '/' . $name, "'\\") . '\');">' : '';
1659 1691
 
1660
-			if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive'))
1661
-				echo '
1692
+			if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) {
1693
+							echo '
1662 1694
 						<span class="generic_icons folder"></span>';
1695
+			}
1663 1696
 
1664 1697
 			echo '
1665 1698
 					', $name, '
@@ -1685,14 +1718,15 @@  discard block
 block discarded – undo
1685 1718
 	}
1686 1719
 
1687 1720
 	// We have more files to show?
1688
-	if ($has_more)
1689
-		echo '
1721
+	if ($has_more) {
1722
+			echo '
1690 1723
 	<tr class="windowbg" id="content_', $js_ident, '_more">
1691 1724
 		<td class="smalltext" width="40%">' . str_repeat('&nbsp;', $level * 5), '
1692 1725
 			&#171; <a href="' . $scripturl . '?action=admin;area=packages;sa=perms;find=' . base64_encode($ident) . ';fileoffset=', ($context['file_offset'] + $context['file_limit']), ';' . $context['session_var'] . '=' . $context['session_id'] . '#fol_' . preg_replace('~[^A-Za-z0-9_\-=:]~', ':-:', $ident) . '">', $txt['package_file_perms_more_files'], '</a> &#187;
1693 1726
 		</td>
1694 1727
 		<td colspan="6"></td>
1695 1728
 	</tr>';
1729
+	}
1696 1730
 
1697 1731
 	if ($drawn_div)
1698 1732
 	{
@@ -1700,15 +1734,17 @@  discard block
 block discarded – undo
1700 1734
 		$isFound = false;
1701 1735
 		foreach ($context['look_for'] as $tree)
1702 1736
 		{
1703
-			if (substr($tree, 0, strlen($ident)) == $ident)
1704
-				$isFound = true;
1737
+			if (substr($tree, 0, strlen($ident)) == $ident) {
1738
+							$isFound = true;
1739
+			}
1705 1740
 		}
1706 1741
 
1707
-		if ($level > 1 && !$isFound)
1708
-			echo '
1742
+		if ($level > 1 && !$isFound) {
1743
+					echo '
1709 1744
 		<script>
1710 1745
 			expandFolder(\'', $js_ident, '\', \'\');
1711 1746
 		</script>';
1747
+		}
1712 1748
 	}
1713 1749
 }
1714 1750
 
@@ -1728,11 +1764,12 @@  discard block
 block discarded – undo
1728 1764
 				<h3 class="catbg">', $txt['package_file_perms_applying'], '</h3>
1729 1765
 			</div>';
1730 1766
 
1731
-	if (!empty($context['skip_ftp']))
1732
-		echo '
1767
+	if (!empty($context['skip_ftp'])) {
1768
+			echo '
1733 1769
 			<div class="errorbox">
1734 1770
 				', $txt['package_file_perms_skipping_ftp'], '
1735 1771
 			</div>';
1772
+	}
1736 1773
 
1737 1774
 	// How many have we done?
1738 1775
 	$remaining_items = count($context['method'] == 'individual' ? $context['to_process'] : $context['directory_list']);
@@ -1770,28 +1807,31 @@  discard block
 block discarded – undo
1770 1807
 				<br>';
1771 1808
 
1772 1809
 	// Put out the right hidden data.
1773
-	if ($context['method'] == 'individual')
1774
-		echo '
1810
+	if ($context['method'] == 'individual') {
1811
+			echo '
1775 1812
 				<input type="hidden" name="custom_value" value="', $context['custom_value'], '">
1776 1813
 				<input type="hidden" name="totalItems" value="', $context['total_items'], '">
1777 1814
 				<input type="hidden" name="toProcess" value="', base64_encode(json_encode($context['to_process'])), '">';
1778
-	else
1779
-		echo '
1815
+	} else {
1816
+			echo '
1780 1817
 				<input type="hidden" name="predefined" value="', $context['predefined_type'], '">
1781 1818
 				<input type="hidden" name="fileOffset" value="', $context['file_offset'], '">
1782 1819
 				<input type="hidden" name="totalItems" value="', $context['total_items'], '">
1783 1820
 				<input type="hidden" name="dirList" value="', base64_encode(json_encode($context['directory_list'])), '">
1784 1821
 				<input type="hidden" name="specialFiles" value="', base64_encode(json_encode($context['special_files'])), '">';
1822
+	}
1785 1823
 
1786 1824
 	// Are we not using FTP for whatever reason.
1787
-	if (!empty($context['skip_ftp']))
1788
-		echo '
1825
+	if (!empty($context['skip_ftp'])) {
1826
+			echo '
1789 1827
 				<input type="hidden" name="skip_ftp" value="1">';
1828
+	}
1790 1829
 
1791 1830
 	// Retain state.
1792
-	foreach ($context['back_look_data'] as $path)
1793
-		echo '
1831
+	foreach ($context['back_look_data'] as $path) {
1832
+			echo '
1794 1833
 				<input type="hidden" name="back_look[]" value="', $path, '">';
1834
+	}
1795 1835
 
1796 1836
 	echo '
1797 1837
 				<input type="hidden" name="method" value="', $context['method'], '">
Please login to merge, or discard this patch.
Sources/index.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,8 @@
 block discarded – undo
12 12
 	header('Location: ' . $boardurl);
13 13
 }
14 14
 // Can't find it... just forget it.
15
-else
15
+else {
16 16
 	exit;
17
+}
17 18
 
18 19
 ?>
19 20
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/Subs-Recent.php 1 patch
Braces   +5 added lines, -3 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 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
  * Get the latest posts of a forum.
@@ -59,8 +60,9 @@  discard block
 block discarded – undo
59 60
 		censorText($row['body']);
60 61
 
61 62
 		$row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br>' => '&#10;')));
62
-		if ($smcFunc['strlen']($row['body']) > 128)
63
-			$row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...';
63
+		if ($smcFunc['strlen']($row['body']) > 128) {
64
+					$row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...';
65
+		}
64 66
 
65 67
 		// Build the array.
66 68
 		$posts[] = array(
Please login to merge, or discard this patch.
Sources/Attachments.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 		// Just send a generic message.
77 77
 		else
78 78
 			$this->setResponse(array(
79
-				'text' => $this->_sa == 'add' ? 'attach_error_title' :   'attached_file_deleted_error',
79
+				'text' => $this->_sa == 'add' ? 'attach_error_title' : 'attached_file_deleted_error',
80 80
 				'type' => 'error',
81 81
 				'data' => false,
82 82
 			));
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 			// Gotta urlencode the filename.
405 405
 			if ($this->_attachResults)
406 406
 				foreach ($this->_attachResults as $k => $v)
407
-					$this->_attachResults[$k]['name'] =  urlencode($this->_attachResults[$k]['name']);
407
+					$this->_attachResults[$k]['name'] = urlencode($this->_attachResults[$k]['name']);
408 408
 
409 409
 			$this->_response = array(
410 410
 				'files' => $this->_attachResults ? $this->_attachResults : false,
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
 			ob_start();
432 432
 
433 433
 		// Set the header.
434
-		header('Content-Type: application/json; charset='. $context['character_set'] .'');
434
+		header('Content-Type: application/json; charset=' . $context['character_set'] . '');
435 435
 
436 436
 		echo json_encode($this->_response ? $this->_response : array());
437 437
 
Please login to merge, or discard this patch.
Braces   +102 added lines, -75 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
 class Attachments
20 21
 {
@@ -70,16 +71,18 @@  discard block
 block discarded – undo
70 71
 
71 72
 		$this->_sa = !empty($_REQUEST['sa']) ? $smcFunc['htmlspecialchars']($smcFunc['htmltrim']($_REQUEST['sa'])) : false;
72 73
 
73
-		if ($this->_canPostAttachment && $this->_sa && in_array($this->_sa, $this->_subActions))
74
-			$this->{$this->_sa}();
74
+		if ($this->_canPostAttachment && $this->_sa && in_array($this->_sa, $this->_subActions)) {
75
+					$this->{$this->_sa}();
76
+		}
75 77
 
76 78
 		// Just send a generic message.
77
-		else
78
-			$this->setResponse(array(
79
+		else {
80
+					$this->setResponse(array(
79 81
 				'text' => $this->_sa == 'add' ? 'attach_error_title' :   'attached_file_deleted_error',
80 82
 				'type' => 'error',
81 83
 				'data' => false,
82 84
 			));
85
+		}
83 86
 
84 87
 		// Back to the future, oh, to the browser!
85 88
 		$this->sendResponse();
@@ -95,12 +98,13 @@  discard block
 block discarded – undo
95 98
 		$attachID = !empty($_REQUEST['attach']) && is_numeric($_REQUEST['attach']) ? (int) $_REQUEST['attach'] : 0;
96 99
 
97 100
 		// Need something to work with.
98
-		if (!$attachID || (!empty($_SESSION['already_attached']) && !isset($_SESSION['already_attached'][$attachID])))
99
-			return $this->setResponse(array(
101
+		if (!$attachID || (!empty($_SESSION['already_attached']) && !isset($_SESSION['already_attached'][$attachID]))) {
102
+					return $this->setResponse(array(
100 103
 				'text' => 'attached_file_deleted_error',
101 104
 				'type' => 'error',
102 105
 				'data' => false,
103 106
 			));
107
+		}
104 108
 
105 109
 		// Lets pass some params and see what happens :P
106 110
 		$affectedMessage = removeAttachments(array('id_attach' => $attachID), '', true, true);
@@ -119,19 +123,21 @@  discard block
 block discarded – undo
119 123
 	public function add()
120 124
 	{
121 125
 		// You gotta be able to post attachments.
122
-		if (!$this->_canPostAttachment)
123
-			return $this->setResponse(array(
126
+		if (!$this->_canPostAttachment) {
127
+					return $this->setResponse(array(
124 128
 				'text' => 'attached_file_cannot',
125 129
 				'type' => 'error',
126 130
 				'data' => false,
127 131
 			));
132
+		}
128 133
 
129 134
 		// Process them at once!
130 135
 		$this->processAttachments();
131 136
 
132 137
 		// The attachments was created and moved the the right folder, time to update the DB.
133
-		if (!empty($_SESSION['temp_attachments']))
134
-			$this->createAtttach();
138
+		if (!empty($_SESSION['temp_attachments'])) {
139
+					$this->createAtttach();
140
+		}
135 141
 
136 142
 		// Set the response.
137 143
 		$this->setResponse();
@@ -144,8 +150,9 @@  discard block
 block discarded – undo
144 150
 	{
145 151
 		global $context, $modSettings, $smcFunc, $user_info, $txt;
146 152
 
147
-		if (!isset($_FILES['attachment']['name']))
148
-			$_FILES['attachment']['tmp_name'] = array();
153
+		if (!isset($_FILES['attachment']['name'])) {
154
+					$_FILES['attachment']['tmp_name'] = array();
155
+		}
149 156
 
150 157
 		// If there are attachments, calculate the total size and how many.
151 158
 		$context['attachments']['total_size'] = 0;
@@ -155,25 +162,30 @@  discard block
 block discarded – undo
155 162
 		if (isset($_REQUEST['msg']))
156 163
 		{
157 164
 			$context['attachments']['quantity'] = count($context['current_attachments']);
158
-			foreach ($context['current_attachments'] as $attachment)
159
-				$context['attachments']['total_size'] += $attachment['size'];
165
+			foreach ($context['current_attachments'] as $attachment) {
166
+							$context['attachments']['total_size'] += $attachment['size'];
167
+			}
160 168
 		}
161 169
 
162 170
 		// A bit of house keeping first.
163
-		if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1)
164
-			unset($_SESSION['temp_attachments']);
171
+		if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) {
172
+					unset($_SESSION['temp_attachments']);
173
+		}
165 174
 
166 175
 		// Our infamous SESSION var, we are gonna have soo much fun with it!
167
-		if (!isset($_SESSION['temp_attachments']))
168
-			$_SESSION['temp_attachments'] = array();
176
+		if (!isset($_SESSION['temp_attachments'])) {
177
+					$_SESSION['temp_attachments'] = array();
178
+		}
169 179
 
170 180
 		// Make sure we're uploading to the right place.
171
-		if (!empty($modSettings['automanage_attachments']))
172
-			automanage_attachments_check_directory();
181
+		if (!empty($modSettings['automanage_attachments'])) {
182
+					automanage_attachments_check_directory();
183
+		}
173 184
 
174 185
 		// Is the attachments folder actually there?
175
-		if (!empty($context['dir_creation_error']))
176
-			$this->_generalErrors[] = $context['dir_creation_error'];
186
+		if (!empty($context['dir_creation_error'])) {
187
+					$this->_generalErrors[] = $context['dir_creation_error'];
188
+		}
177 189
 
178 190
 		// The current attach folder ha some issues...
179 191
 		elseif (!is_dir($this->_attchDir))
@@ -198,13 +210,12 @@  discard block
 block discarded – undo
198 210
 			);
199 211
 			list ($context['attachments']['quantity'], $context['attachments']['total_size']) = $smcFunc['db_fetch_row']($request);
200 212
 			$smcFunc['db_free_result']($request);
201
-		}
202
-
203
-		else
204
-			$context['attachments'] = array(
213
+		} else {
214
+					$context['attachments'] = array(
205 215
 				'quantity' => 0,
206 216
 				'total_size' => 0,
207 217
 			);
218
+		}
208 219
 
209 220
 		// Check for other general errors here.
210 221
 
@@ -212,9 +223,10 @@  discard block
 block discarded – undo
212 223
 		if (!empty($this->_generalErrors))
213 224
 		{
214 225
 			// And delete the files 'cos they ain't going nowhere.
215
-			foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy)
216
-				if (file_exists($_FILES['attachment']['tmp_name'][$n]))
226
+			foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) {
227
+							if (file_exists($_FILES['attachment']['tmp_name'][$n]))
217 228
 					unlink($_FILES['attachment']['tmp_name'][$n]);
229
+			}
218 230
 
219 231
 			$_FILES['attachment']['tmp_name'] = array();
220 232
 
@@ -225,26 +237,29 @@  discard block
 block discarded – undo
225 237
 		// Loop through $_FILES['attachment'] array and move each file to the current attachments folder.
226 238
 		foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy)
227 239
 		{
228
-			if ($_FILES['attachment']['name'][$n] == '')
229
-				continue;
240
+			if ($_FILES['attachment']['name'][$n] == '') {
241
+							continue;
242
+			}
230 243
 
231 244
 			// First, let's first check for PHP upload errors.
232 245
 			$errors = array();
233 246
 			if (!empty($_FILES['attachment']['error'][$n]))
234 247
 			{
235
-				if ($_FILES['attachment']['error'][$n] == 2)
236
-					$errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit']));
237
-
238
-				else
239
-					log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]);
248
+				if ($_FILES['attachment']['error'][$n] == 2) {
249
+									$errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit']));
250
+				} else {
251
+									log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]);
252
+				}
240 253
 
241 254
 				// Log this one, because...
242
-				if ($_FILES['attachment']['error'][$n] == 6)
243
-					log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical');
255
+				if ($_FILES['attachment']['error'][$n] == 6) {
256
+									log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical');
257
+				}
244 258
 
245 259
 				// Weird, no errors were cached, still fill out a generic one.
246
-				if (empty($errors))
247
-					$errors[] = 'attach_php_error';
260
+				if (empty($errors)) {
261
+									$errors[] = 'attach_php_error';
262
+				}
248 263
 			}
249 264
 
250 265
 			// Try to move and rename the file before doing any more checks on it.
@@ -256,8 +271,9 @@  discard block
 block discarded – undo
256 271
 			{
257 272
 				// The reported MIME type of the attachment might not be reliable.
258 273
 				// Fortunately, PHP 5.3+ lets us easily verify the real MIME type.
259
-				if (function_exists('mime_content_type'))
260
-					$_FILES['attachment']['type'][$n] = mime_content_type($_FILES['attachment']['tmp_name'][$n]);
274
+				if (function_exists('mime_content_type')) {
275
+									$_FILES['attachment']['type'][$n] = mime_content_type($_FILES['attachment']['tmp_name'][$n]);
276
+				}
261 277
 
262 278
 				$_SESSION['temp_attachments'][$attachID] = array(
263 279
 					'name' => $smcFunc['htmlspecialchars'](basename($_FILES['attachment']['name'][$n])),
@@ -269,16 +285,18 @@  discard block
 block discarded – undo
269 285
 				);
270 286
 
271 287
 				// Move the file to the attachments folder with a temp name for now.
272
-				if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName))
273
-					smf_chmod($destName, 0644);
288
+				if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName)) {
289
+									smf_chmod($destName, 0644);
290
+				}
274 291
 
275 292
 				// This is madness!!
276 293
 				else
277 294
 				{
278 295
 					// File couldn't be moved.
279 296
 					$_SESSION['temp_attachments'][$attachID]['errors'][] = 'attach_timeout';
280
-					if (file_exists($_FILES['attachment']['tmp_name'][$n]))
281
-						unlink($_FILES['attachment']['tmp_name'][$n]);
297
+					if (file_exists($_FILES['attachment']['tmp_name'][$n])) {
298
+											unlink($_FILES['attachment']['tmp_name'][$n]);
299
+					}
282 300
 				}
283 301
 			}
284 302
 
@@ -291,13 +309,15 @@  discard block
 block discarded – undo
291 309
 					'errors' => $errors,
292 310
 				);
293 311
 
294
-				if (file_exists($_FILES['attachment']['tmp_name'][$n]))
295
-					unlink($_FILES['attachment']['tmp_name'][$n]);
312
+				if (file_exists($_FILES['attachment']['tmp_name'][$n])) {
313
+									unlink($_FILES['attachment']['tmp_name'][$n]);
314
+				}
296 315
 			}
297 316
 
298 317
 			// If there's no errors to this point. We still do need to apply some additional checks before we are finished.
299
-			if (empty($_SESSION['temp_attachments'][$attachID]['errors']))
300
-				attachmentChecks($attachID);
318
+			if (empty($_SESSION['temp_attachments'][$attachID]['errors'])) {
319
+							attachmentChecks($attachID);
320
+			}
301 321
 		}
302 322
 
303 323
 		// Mod authors, finally a hook to hang an alternate attachment upload system upon
@@ -344,14 +364,15 @@  discard block
 block discarded – undo
344 364
 
345 365
 					$_SESSION['already_attached'][$attachmentOptions['attachID']] = $attachmentOptions['attachID'];
346 366
 
347
-					if (!empty($attachmentOptions['thumb']))
348
-						$_SESSION['already_attached'][$attachmentOptions['thumb']] = $attachmentOptions['thumb'];
367
+					if (!empty($attachmentOptions['thumb'])) {
368
+											$_SESSION['already_attached'][$attachmentOptions['thumb']] = $attachmentOptions['thumb'];
369
+					}
349 370
 
350
-					if ($this->_msg)
351
-						assignAttachments($_SESSION['already_attached'], $this->_msg);
371
+					if ($this->_msg) {
372
+											assignAttachments($_SESSION['already_attached'], $this->_msg);
373
+					}
352 374
 				}
353
-			}
354
-			else
375
+			} else
355 376
 			{
356 377
 				// Sort out the errors for display and delete any associated files.
357 378
 				$log_these = array('attachments_no_create', 'attachments_no_write', 'attach_timeout', 'ran_out_of_space', 'cant_access_upload_path', 'attach_0_byte_file');
@@ -363,14 +384,16 @@  discard block
 block discarded – undo
363 384
 					if (!is_array($error))
364 385
 					{
365 386
 						$attachmentOptions['errors'][] = $txt[$error];
366
-						if (in_array($error, $log_these))
367
-							log_error($attachment['name'] . ': ' . $txt[$error], 'critical');
387
+						if (in_array($error, $log_these)) {
388
+													log_error($attachment['name'] . ': ' . $txt[$error], 'critical');
389
+						}
390
+					} else {
391
+											$attachmentOptions['errors'][] = vsprintf($txt[$error[0]], $error[1]);
368 392
 					}
369
-					else
370
-						$attachmentOptions['errors'][] = vsprintf($txt[$error[0]], $error[1]);
371 393
 				}
372
-				if (file_exists($attachment['tmp_name']))
373
-					unlink($attachment['tmp_name']);
394
+				if (file_exists($attachment['tmp_name'])) {
395
+									unlink($attachment['tmp_name']);
396
+				}
374 397
 			}
375 398
 
376 399
 			// Regardless of errors, pass the results.
@@ -378,8 +401,9 @@  discard block
 block discarded – undo
378 401
 		}
379 402
 
380 403
 		// Temp save this on the db.
381
-		if (!empty($_SESSION['already_attached']))
382
-			$this->_attachSuccess = $_SESSION['already_attached'];
404
+		if (!empty($_SESSION['already_attached'])) {
405
+					$this->_attachSuccess = $_SESSION['already_attached'];
406
+		}
383 407
 
384 408
 		unset($_SESSION['temp_attachments']);
385 409
 	}
@@ -399,14 +423,16 @@  discard block
 block discarded – undo
399 423
 		if ($this->_sa == 'add')
400 424
 		{
401 425
 			// Is there any generic errors? made some sense out of them!
402
-			if ($this->_generalErrors)
403
-				foreach ($this->_generalErrors as $k => $v)
426
+			if ($this->_generalErrors) {
427
+							foreach ($this->_generalErrors as $k => $v)
404 428
 					$this->_generalErrors[$k] = (is_array($v) ? vsprintf($txt[$v[0]], $v[1]) : $txt[$v]);
429
+			}
405 430
 
406 431
 			// Gotta urlencode the filename.
407
-			if ($this->_attachResults)
408
-				foreach ($this->_attachResults as $k => $v)
432
+			if ($this->_attachResults) {
433
+							foreach ($this->_attachResults as $k => $v)
409 434
 					$this->_attachResults[$k]['name'] =  urlencode($this->_attachResults[$k]['name']);
435
+			}
410 436
 
411 437
 			$this->_response = array(
412 438
 				'files' => $this->_attachResults ? $this->_attachResults : false,
@@ -415,9 +441,10 @@  discard block
 block discarded – undo
415 441
 		}
416 442
 
417 443
 		// Rest of us mere mortals gets no special treatment...
418
-		elseif (!empty($data))
419
-			if (!empty($data['text']) && !empty($txt[$data['text']]))
444
+		elseif (!empty($data)) {
445
+					if (!empty($data['text']) && !empty($txt[$data['text']]))
420 446
 				$this->_response['text'] = $txt[$data['text']];
447
+		}
421 448
 	}
422 449
 
423 450
 	protected function sendResponse()
@@ -426,11 +453,11 @@  discard block
 block discarded – undo
426 453
 
427 454
 		ob_end_clean();
428 455
 
429
-		if (!empty($modSettings['CompressedOutput']))
430
-			@ob_start('ob_gzhandler');
431
-
432
-		else
433
-			ob_start();
456
+		if (!empty($modSettings['CompressedOutput'])) {
457
+					@ob_start('ob_gzhandler');
458
+		} else {
459
+					ob_start();
460
+		}
434 461
 
435 462
 		// Set the header.
436 463
 		header('Content-Type: application/json; charset='. $context['character_set'] .'');
Please login to merge, or discard this patch.
Sources/Logging.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 	if (filemtime($boarddir . '/db_last_error.php') === $last_db_error_change)
176 176
 	{
177 177
 		// Write the change
178
-		$write_db_change =  '<' . '?' . "php\n" . '$db_last_error = ' . time() . ';' . "\n" . '?' . '>';
178
+		$write_db_change = '<' . '?' . "php\n" . '$db_last_error = ' . time() . ';' . "\n" . '?' . '>';
179 179
 		$written_bytes = file_put_contents($boarddir . '/db_last_error.php', $write_db_change, LOCK_EX);
180 180
 
181 181
 		// survey says ...
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 	', $txt['debug_language_files'], count($context['debug']['language_files']), ': <em>', implode('</em>, <em>', $context['debug']['language_files']), '</em>.<br>
249 249
 	', $txt['debug_stylesheets'], count($context['debug']['sheets']), ': <em>', implode('</em>, <em>', $context['debug']['sheets']), '</em>.<br>
250 250
 	', $txt['debug_hooks'], empty($context['debug']['hooks']) ? 0 : count($context['debug']['hooks']) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_hooks\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_hooks" style="display: none;"><em>' . implode('</em>, <em>', $context['debug']['hooks']), '</em></span>)', '<br>
251
-	',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">'. $txt['debug_show'] .'</a><span id="debug_instances" style="display: none;"><em>'. implode('</em>, <em>', array_keys($context['debug']['instances'])) .'</em></span>)'. '<br>') : ''),'
251
+	',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">' . $txt['debug_show'] . '</a><span id="debug_instances" style="display: none;"><em>' . implode('</em>, <em>', array_keys($context['debug']['instances'])) . '</em></span>)' . '<br>') : ''), '
252 252
 	', $txt['debug_files_included'], count($files), ' - ', round($total_size / 1024), $txt['debug_kb'], ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_include_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_include_info" style="display: none;"><em>', implode('</em>, <em>', $files), '</em></span>)<br>';
253 253
 
254 254
 	if (function_exists('memory_get_peak_usage'))
Please login to merge, or discard this patch.
Braces   +134 added lines, -96 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
  * Put this user in the online log.
@@ -33,8 +34,9 @@  discard block
 block discarded – undo
33 34
 		// Don't update for every page - this isn't wholly accurate but who cares.
34 35
 		if ($topic)
35 36
 		{
36
-			if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic)
37
-				$force = false;
37
+			if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic) {
38
+							$force = false;
39
+			}
38 40
 			$_SESSION['last_topic_id'] = $topic;
39 41
 		}
40 42
 	}
@@ -47,22 +49,24 @@  discard block
 block discarded – undo
47 49
 	}
48 50
 
49 51
 	// Don't mark them as online more than every so often.
50
-	if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force)
51
-		return;
52
+	if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force) {
53
+			return;
54
+	}
52 55
 
53 56
 	if (!empty($modSettings['who_enabled']))
54 57
 	{
55 58
 		$serialized = $_GET + array('USER_AGENT' => $_SERVER['HTTP_USER_AGENT']);
56 59
 
57 60
 		// In the case of a dlattach action, session_var may not be set.
58
-		if (!isset($context['session_var']))
59
-			$context['session_var'] = $_SESSION['session_var'];
61
+		if (!isset($context['session_var'])) {
62
+					$context['session_var'] = $_SESSION['session_var'];
63
+		}
60 64
 
61 65
 		unset($serialized['sesc'], $serialized[$context['session_var']]);
62 66
 		$serialized = json_encode($serialized);
67
+	} else {
68
+			$serialized = '';
63 69
 	}
64
-	else
65
-		$serialized = '';
66 70
 
67 71
 	// Guests use 0, members use their session ID.
68 72
 	$session_id = $user_info['is_guest'] ? 'ip' . $user_info['ip'] : session_id();
@@ -102,17 +106,18 @@  discard block
 block discarded – undo
102 106
 		);
103 107
 
104 108
 		// Guess it got deleted.
105
-		if ($smcFunc['db_affected_rows']() == 0)
109
+		if ($smcFunc['db_affected_rows']() == 0) {
110
+					$_SESSION['log_time'] = 0;
111
+		}
112
+	} else {
106 113
 			$_SESSION['log_time'] = 0;
107 114
 	}
108
-	else
109
-		$_SESSION['log_time'] = 0;
110 115
 
111 116
 	// Otherwise, we have to delete and insert.
112 117
 	if (empty($_SESSION['log_time']))
113 118
 	{
114
-		if ($do_delete || !empty($user_info['id']))
115
-			$smcFunc['db_query']('', '
119
+		if ($do_delete || !empty($user_info['id'])) {
120
+					$smcFunc['db_query']('', '
116 121
 				DELETE FROM {db_prefix}log_online
117 122
 				WHERE ' . ($do_delete ? 'log_time < {int:log_time}' : '') . ($do_delete && !empty($user_info['id']) ? ' OR ' : '') . (empty($user_info['id']) ? '' : 'id_member = {int:current_member}'),
118 123
 				array(
@@ -120,6 +125,7 @@  discard block
 block discarded – undo
120 125
 					'log_time' => time() - $modSettings['lastActive'] * 60,
121 126
 				)
122 127
 			);
128
+		}
123 129
 
124 130
 		$smcFunc['db_insert']($do_delete ? 'ignore' : 'replace',
125 131
 			'{db_prefix}log_online',
@@ -133,21 +139,24 @@  discard block
 block discarded – undo
133 139
 	$_SESSION['log_time'] = time();
134 140
 
135 141
 	// Well, they are online now.
136
-	if (empty($_SESSION['timeOnlineUpdated']))
137
-		$_SESSION['timeOnlineUpdated'] = time();
142
+	if (empty($_SESSION['timeOnlineUpdated'])) {
143
+			$_SESSION['timeOnlineUpdated'] = time();
144
+	}
138 145
 
139 146
 	// Set their login time, if not already done within the last minute.
140 147
 	if (SMF != 'SSI' && !empty($user_info['last_login']) && $user_info['last_login'] < time() - 60 && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('.xml', 'login2', 'logintfa'))))
141 148
 	{
142 149
 		// Don't count longer than 15 minutes.
143
-		if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15)
144
-			$_SESSION['timeOnlineUpdated'] = time();
150
+		if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15) {
151
+					$_SESSION['timeOnlineUpdated'] = time();
152
+		}
145 153
 
146 154
 		$user_settings['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated'];
147 155
 		updateMemberData($user_info['id'], array('last_login' => time(), 'member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP'], 'total_time_logged_in' => $user_settings['total_time_logged_in']));
148 156
 
149
-		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
150
-			cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60);
157
+		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
158
+					cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60);
159
+		}
151 160
 
152 161
 		$user_info['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated'];
153 162
 		$_SESSION['timeOnlineUpdated'] = time();
@@ -184,8 +193,7 @@  discard block
 block discarded – undo
184 193
 			// Oops. maybe we have no more disk space left, or some other troubles, troubles...
185 194
 			// Copy the file back and run for your life!
186 195
 			@copy($boarddir . '/db_last_error_bak.php', $boarddir . '/db_last_error.php');
187
-		}
188
-		else
196
+		} else
189 197
 		{
190 198
 			@touch($boarddir . '/' . 'Settings.php');
191 199
 			return true;
@@ -205,22 +213,27 @@  discard block
 block discarded – undo
205 213
 	global $db_cache, $db_count, $cache_misses, $cache_count_misses, $db_show_debug, $cache_count, $cache_hits, $smcFunc, $txt;
206 214
 
207 215
 	// Add to Settings.php if you want to show the debugging information.
208
-	if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery'))
209
-		return;
216
+	if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery')) {
217
+			return;
218
+	}
210 219
 
211
-	if (empty($_SESSION['view_queries']))
212
-		$_SESSION['view_queries'] = 0;
213
-	if (empty($context['debug']['language_files']))
214
-		$context['debug']['language_files'] = array();
215
-	if (empty($context['debug']['sheets']))
216
-		$context['debug']['sheets'] = array();
220
+	if (empty($_SESSION['view_queries'])) {
221
+			$_SESSION['view_queries'] = 0;
222
+	}
223
+	if (empty($context['debug']['language_files'])) {
224
+			$context['debug']['language_files'] = array();
225
+	}
226
+	if (empty($context['debug']['sheets'])) {
227
+			$context['debug']['sheets'] = array();
228
+	}
217 229
 
218 230
 	$files = get_included_files();
219 231
 	$total_size = 0;
220 232
 	for ($i = 0, $n = count($files); $i < $n; $i++)
221 233
 	{
222
-		if (file_exists($files[$i]))
223
-			$total_size += filesize($files[$i]);
234
+		if (file_exists($files[$i])) {
235
+					$total_size += filesize($files[$i]);
236
+		}
224 237
 		$files[$i] = strtr($files[$i], array($boarddir => '.', $sourcedir => '(Sources)', $cachedir => '(Cache)', $settings['actual_theme_dir'] => '(Current Theme)'));
225 238
 	}
226 239
 
@@ -229,8 +242,9 @@  discard block
 block discarded – undo
229 242
 	{
230 243
 		foreach ($db_cache as $q => $qq)
231 244
 		{
232
-			if (!empty($qq['w']))
233
-				$warnings += count($qq['w']);
245
+			if (!empty($qq['w'])) {
246
+							$warnings += count($qq['w']);
247
+			}
234 248
 		}
235 249
 
236 250
 		$_SESSION['debug'] = &$db_cache;
@@ -251,12 +265,14 @@  discard block
 block discarded – undo
251 265
 	',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">'. $txt['debug_show'] .'</a><span id="debug_instances" style="display: none;"><em>'. implode('</em>, <em>', array_keys($context['debug']['instances'])) .'</em></span>)'. '<br>') : ''),'
252 266
 	', $txt['debug_files_included'], count($files), ' - ', round($total_size / 1024), $txt['debug_kb'], ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_include_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_include_info" style="display: none;"><em>', implode('</em>, <em>', $files), '</em></span>)<br>';
253 267
 
254
-	if (function_exists('memory_get_peak_usage'))
255
-		echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>';
268
+	if (function_exists('memory_get_peak_usage')) {
269
+			echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>';
270
+	}
256 271
 
257 272
 	// What tokens are active?
258
-	if (isset($_SESSION['token']))
259
-		echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>';
273
+	if (isset($_SESSION['token'])) {
274
+			echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>';
275
+	}
260 276
 
261 277
 	if (!empty($modSettings['cache_enable']) && !empty($cache_hits))
262 278
 	{
@@ -269,10 +285,12 @@  discard block
 block discarded – undo
269 285
 			$total_t += $cache_hit['t'];
270 286
 			$total_s += $cache_hit['s'];
271 287
 		}
272
-		if (!isset($cache_misses))
273
-			$cache_misses = array();
274
-		foreach ($cache_misses as $missed)
275
-			$missed_entires[] = $missed['d'] . ' ' . $missed['k'];
288
+		if (!isset($cache_misses)) {
289
+					$cache_misses = array();
290
+		}
291
+		foreach ($cache_misses as $missed) {
292
+					$missed_entires[] = $missed['d'] . ' ' . $missed['k'];
293
+		}
276 294
 
277 295
 		echo '
278 296
 	', $txt['debug_cache_hits'], $cache_count, ': ', sprintf($txt['debug_cache_seconds_bytes_total'], comma_format($total_t, 5), comma_format($total_s)), ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_cache_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_cache_info" style="display: none;"><em>', implode('</em>, <em>', $entries), '</em></span>)<br>
@@ -283,38 +301,44 @@  discard block
 block discarded – undo
283 301
 	<a href="', $scripturl, '?action=viewquery" target="_blank" class="new_win">', $warnings == 0 ? sprintf($txt['debug_queries_used'], (int) $db_count) : sprintf($txt['debug_queries_used_and_warnings'], (int) $db_count, $warnings), '</a><br>
284 302
 	<br>';
285 303
 
286
-	if ($_SESSION['view_queries'] == 1 && !empty($db_cache))
287
-		foreach ($db_cache as $q => $qq)
304
+	if ($_SESSION['view_queries'] == 1 && !empty($db_cache)) {
305
+			foreach ($db_cache as $q => $qq)
288 306
 		{
289 307
 			$is_select = strpos(trim($qq['q']), 'SELECT') === 0 || preg_match('~^INSERT(?: IGNORE)? INTO \w+(?:\s+\([^)]+\))?\s+SELECT .+$~s', trim($qq['q'])) != 0;
308
+	}
290 309
 			// Temporary tables created in earlier queries are not explainable.
291 310
 			if ($is_select)
292 311
 			{
293
-				foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp)
294
-					if (strpos(trim($qq['q']), $tmp) !== false)
312
+				foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) {
313
+									if (strpos(trim($qq['q']), $tmp) !== false)
295 314
 					{
296 315
 						$is_select = false;
316
+				}
297 317
 						break;
298 318
 					}
299 319
 			}
300 320
 			// But actual creation of the temporary tables are.
301
-			elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($qq['q'])) != 0)
302
-				$is_select = true;
321
+			elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($qq['q'])) != 0) {
322
+							$is_select = true;
323
+			}
303 324
 
304 325
 			// Make the filenames look a bit better.
305
-			if (isset($qq['f']))
306
-				$qq['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $qq['f']);
326
+			if (isset($qq['f'])) {
327
+							$qq['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $qq['f']);
328
+			}
307 329
 
308 330
 			echo '
309 331
 	<strong>', $is_select ? '<a href="' . $scripturl . '?action=viewquery;qq=' . ($q + 1) . '#qq' . $q . '" target="_blank" class="new_win" style="text-decoration: none;">' : '', nl2br(str_replace("\t", '&nbsp;&nbsp;&nbsp;', $smcFunc['htmlspecialchars'](ltrim($qq['q'], "\n\r")))) . ($is_select ? '</a></strong>' : '</strong>') . '<br>
310 332
 	&nbsp;&nbsp;&nbsp;';
311
-			if (!empty($qq['f']) && !empty($qq['l']))
312
-				echo sprintf($txt['debug_query_in_line'], $qq['f'], $qq['l']);
333
+			if (!empty($qq['f']) && !empty($qq['l'])) {
334
+							echo sprintf($txt['debug_query_in_line'], $qq['f'], $qq['l']);
335
+			}
313 336
 
314
-			if (isset($qq['s'], $qq['t']) && isset($txt['debug_query_which_took_at']))
315
-				echo sprintf($txt['debug_query_which_took_at'], round($qq['t'], 8), round($qq['s'], 8)) . '<br>';
316
-			elseif (isset($qq['t']))
317
-				echo sprintf($txt['debug_query_which_took'], round($qq['t'], 8)) . '<br>';
337
+			if (isset($qq['s'], $qq['t']) && isset($txt['debug_query_which_took_at'])) {
338
+							echo sprintf($txt['debug_query_which_took_at'], round($qq['t'], 8), round($qq['s'], 8)) . '<br>';
339
+			} elseif (isset($qq['t'])) {
340
+							echo sprintf($txt['debug_query_which_took'], round($qq['t'], 8)) . '<br>';
341
+			}
318 342
 			echo '
319 343
 	<br>';
320 344
 		}
@@ -339,12 +363,14 @@  discard block
 block discarded – undo
339 363
 	global $modSettings, $smcFunc;
340 364
 	static $cache_stats = array();
341 365
 
342
-	if (empty($modSettings['trackStats']))
343
-		return false;
344
-	if (!empty($stats))
345
-		return $cache_stats = array_merge($cache_stats, $stats);
346
-	elseif (empty($cache_stats))
347
-		return false;
366
+	if (empty($modSettings['trackStats'])) {
367
+			return false;
368
+	}
369
+	if (!empty($stats)) {
370
+			return $cache_stats = array_merge($cache_stats, $stats);
371
+	} elseif (empty($cache_stats)) {
372
+			return false;
373
+	}
348 374
 
349 375
 	$setStringUpdate = '';
350 376
 	$insert_keys = array();
@@ -357,10 +383,11 @@  discard block
 block discarded – undo
357 383
 		$setStringUpdate .= '
358 384
 			' . $field . ' = ' . ($change === '+' ? $field . ' + 1' : '{int:' . $field . '}') . ',';
359 385
 
360
-		if ($change === '+')
361
-			$cache_stats[$field] = 1;
362
-		else
363
-			$update_parameters[$field] = $change;
386
+		if ($change === '+') {
387
+					$cache_stats[$field] = 1;
388
+		} else {
389
+					$update_parameters[$field] = $change;
390
+		}
364 391
 		$insert_keys[$field] = 'int';
365 392
 	}
366 393
 
@@ -424,43 +451,50 @@  discard block
 block discarded – undo
424 451
 	);
425 452
 
426 453
 	// Make sure this particular log is enabled first...
427
-	if (empty($modSettings['modlog_enabled']))
428
-		unset ($log_types['moderate']);
429
-	if (empty($modSettings['userlog_enabled']))
430
-		unset ($log_types['user']);
431
-	if (empty($modSettings['adminlog_enabled']))
432
-		unset ($log_types['admin']);
454
+	if (empty($modSettings['modlog_enabled'])) {
455
+			unset ($log_types['moderate']);
456
+	}
457
+	if (empty($modSettings['userlog_enabled'])) {
458
+			unset ($log_types['user']);
459
+	}
460
+	if (empty($modSettings['adminlog_enabled'])) {
461
+			unset ($log_types['admin']);
462
+	}
433 463
 
434 464
 	call_integration_hook('integrate_log_types', array(&$log_types));
435 465
 
436 466
 	foreach ($logs as $log)
437 467
 	{
438
-		if (!isset($log_types[$log['log_type']]))
439
-			return false;
468
+		if (!isset($log_types[$log['log_type']])) {
469
+					return false;
470
+		}
440 471
 
441
-		if (!is_array($log['extra']))
442
-			trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE);
472
+		if (!is_array($log['extra'])) {
473
+					trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE);
474
+		}
443 475
 
444 476
 		// Pull out the parts we want to store separately, but also make sure that the data is proper
445 477
 		if (isset($log['extra']['topic']))
446 478
 		{
447
-			if (!is_numeric($log['extra']['topic']))
448
-				trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE);
479
+			if (!is_numeric($log['extra']['topic'])) {
480
+							trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE);
481
+			}
449 482
 			$topic_id = empty($log['extra']['topic']) ? 0 : (int) $log['extra']['topic'];
450 483
 			unset($log['extra']['topic']);
484
+		} else {
485
+					$topic_id = 0;
451 486
 		}
452
-		else
453
-			$topic_id = 0;
454 487
 
455 488
 		if (isset($log['extra']['message']))
456 489
 		{
457
-			if (!is_numeric($log['extra']['message']))
458
-				trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE);
490
+			if (!is_numeric($log['extra']['message'])) {
491
+							trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE);
492
+			}
459 493
 			$msg_id = empty($log['extra']['message']) ? 0 : (int) $log['extra']['message'];
460 494
 			unset($log['extra']['message']);
495
+		} else {
496
+					$msg_id = 0;
461 497
 		}
462
-		else
463
-			$msg_id = 0;
464 498
 
465 499
 		// @todo cache this?
466 500
 		// Is there an associated report on this?
@@ -487,23 +521,26 @@  discard block
 block discarded – undo
487 521
 			$smcFunc['db_free_result']($request);
488 522
 		}
489 523
 
490
-		if (isset($log['extra']['member']) && !is_numeric($log['extra']['member']))
491
-			trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE);
524
+		if (isset($log['extra']['member']) && !is_numeric($log['extra']['member'])) {
525
+					trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE);
526
+		}
492 527
 
493 528
 		if (isset($log['extra']['board']))
494 529
 		{
495
-			if (!is_numeric($log['extra']['board']))
496
-				trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE);
530
+			if (!is_numeric($log['extra']['board'])) {
531
+							trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE);
532
+			}
497 533
 			$board_id = empty($log['extra']['board']) ? 0 : (int) $log['extra']['board'];
498 534
 			unset($log['extra']['board']);
535
+		} else {
536
+					$board_id = 0;
499 537
 		}
500
-		else
501
-			$board_id = 0;
502 538
 
503 539
 		if (isset($log['extra']['board_to']))
504 540
 		{
505
-			if (!is_numeric($log['extra']['board_to']))
506
-				trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE);
541
+			if (!is_numeric($log['extra']['board_to'])) {
542
+							trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE);
543
+			}
507 544
 			if (empty($board_id))
508 545
 			{
509 546
 				$board_id = empty($log['extra']['board_to']) ? 0 : (int) $log['extra']['board_to'];
@@ -511,10 +548,11 @@  discard block
 block discarded – undo
511 548
 			}
512 549
 		}
513 550
 
514
-		if (isset($log['extra']['member_affected']))
515
-			$memID = $log['extra']['member_affected'];
516
-		else
517
-			$memID = $user_info['id'];
551
+		if (isset($log['extra']['member_affected'])) {
552
+					$memID = $log['extra']['member_affected'];
553
+		} else {
554
+					$memID = $user_info['id'];
555
+		}
518 556
 
519 557
 		$inserts[] = array(
520 558
 			time(), $log_types[$log['log_type']], $memID, $user_info['ip'], $log['action'],
Please login to merge, or discard this patch.
Sources/SearchAPI-Custom.php 1 patch
Braces   +48 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
  * Used for the "custom search index" option
@@ -54,8 +55,9 @@  discard block
 block discarded – undo
54 55
 			return;
55 56
 		}
56 57
 
57
-		if (empty($modSettings['search_custom_index_config']))
58
-			return;
58
+		if (empty($modSettings['search_custom_index_config'])) {
59
+					return;
60
+		}
59 61
 
60 62
 		$this->indexSettings = smf_json_decode($modSettings['search_custom_index_config'], true);
61 63
 
@@ -118,21 +120,23 @@  discard block
 block discarded – undo
118 120
 
119 121
 		$subwords = text2words($word, $this->min_word_length, true);
120 122
 
121
-		if (empty($modSettings['search_force_index']))
122
-			$wordsSearch['words'][] = $word;
123
+		if (empty($modSettings['search_force_index'])) {
124
+					$wordsSearch['words'][] = $word;
125
+		}
123 126
 
124 127
 		// Excluded phrases don't benefit from being split into subwords.
125
-		if (count($subwords) > 1 && $isExcluded)
126
-			return;
127
-		else
128
+		if (count($subwords) > 1 && $isExcluded) {
129
+					return;
130
+		} else
128 131
 		{
129 132
 			foreach ($subwords as $subword)
130 133
 			{
131 134
 				if ($smcFunc['strlen']($subword) >= $this->min_word_length && !in_array($subword, $this->bannedWords))
132 135
 				{
133 136
 					$wordsSearch['indexed_words'][] = $subword;
134
-					if ($isExcluded)
135
-						$wordsExclude[] = $subword;
137
+					if ($isExcluded) {
138
+											$wordsExclude[] = $subword;
139
+					}
136 140
 				}
137 141
 			}
138 142
 		}
@@ -153,8 +157,9 @@  discard block
 block discarded – undo
153 157
 		$query_where = array();
154 158
 		$query_params = $search_data['params'];
155 159
 
156
-		if ($query_params['id_search'])
157
-			$query_select['id_search'] = '{int:id_search}';
160
+		if ($query_params['id_search']) {
161
+					$query_select['id_search'] = '{int:id_search}';
162
+		}
158 163
 
159 164
 		$count = 0;
160 165
 		foreach ($words['words'] as $regularWord)
@@ -163,30 +168,37 @@  discard block
 block discarded – undo
163 168
 			$query_params['complex_body_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]';
164 169
 		}
165 170
 
166
-		if ($query_params['user_query'])
167
-			$query_where[] = '{raw:user_query}';
168
-		if ($query_params['board_query'])
169
-			$query_where[] = 'm.id_board {raw:board_query}';
171
+		if ($query_params['user_query']) {
172
+					$query_where[] = '{raw:user_query}';
173
+		}
174
+		if ($query_params['board_query']) {
175
+					$query_where[] = 'm.id_board {raw:board_query}';
176
+		}
170 177
 
171
-		if ($query_params['topic'])
172
-			$query_where[] = 'm.id_topic = {int:topic}';
173
-		if ($query_params['min_msg_id'])
174
-			$query_where[] = 'm.id_msg >= {int:min_msg_id}';
175
-		if ($query_params['max_msg_id'])
176
-			$query_where[] = 'm.id_msg <= {int:max_msg_id}';
178
+		if ($query_params['topic']) {
179
+					$query_where[] = 'm.id_topic = {int:topic}';
180
+		}
181
+		if ($query_params['min_msg_id']) {
182
+					$query_where[] = 'm.id_msg >= {int:min_msg_id}';
183
+		}
184
+		if ($query_params['max_msg_id']) {
185
+					$query_where[] = 'm.id_msg <= {int:max_msg_id}';
186
+		}
177 187
 
178 188
 		$count = 0;
179
-		if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index']))
180
-			foreach ($query_params['excluded_phrases'] as $phrase)
189
+		if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) {
190
+					foreach ($query_params['excluded_phrases'] as $phrase)
181 191
 			{
182 192
 				$query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : ' RLIKE ') . '{string:exclude_subject_phrase_' . $count . '}';
193
+		}
183 194
 				$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), '\\\'') . '[[:>:]]';
184 195
 			}
185 196
 		$count = 0;
186
-		if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index']))
187
-			foreach ($query_params['excluded_subject_words'] as $excludedWord)
197
+		if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) {
198
+					foreach ($query_params['excluded_subject_words'] as $excludedWord)
188 199
 			{
189 200
 				$query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : ' RLIKE ') . '{string:exclude_subject_words_' . $count . '}';
201
+		}
190 202
 				$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), '\\\'') . '[[:>:]]';
191 203
 			}
192 204
 
@@ -199,8 +211,7 @@  discard block
 block discarded – undo
199 211
 			{
200 212
 				$query_left_join[] = '{db_prefix}log_search_words AS lsw' . $numTables . ' ON (lsw' . $numTables . '.id_word = ' . $indexedWord . ' AND lsw' . $numTables . '.id_msg = m.id_msg)';
201 213
 				$query_where[] = '(lsw' . $numTables . '.id_word IS NULL)';
202
-			}
203
-			else
214
+			} else
204 215
 			{
205 216
 				$query_inner_join[] = '{db_prefix}log_search_words AS lsw' . $numTables . ' ON (lsw' . $numTables . '.id_msg = ' . ($prev_join === 0 ? 'm' : 'lsw' . $prev_join) . '.id_msg)';
206 217
 				$query_where[] = 'lsw' . $numTables . '.id_word = ' . $indexedWord;
@@ -236,16 +247,18 @@  discard block
 block discarded – undo
236 247
 		$customIndexSettings = smf_json_decode($modSettings['search_custom_index_config'], true);
237 248
 
238 249
 		$inserts = array();
239
-		foreach (text2words($msgOptions['body'], $customIndexSettings['bytes_per_word'], true) as $word)
240
-			$inserts[] = array($word, $msgOptions['id']);
250
+		foreach (text2words($msgOptions['body'], $customIndexSettings['bytes_per_word'], true) as $word) {
251
+					$inserts[] = array($word, $msgOptions['id']);
252
+		}
241 253
 
242
-		if (!empty($inserts))
243
-			$smcFunc['db_insert']('ignore',
254
+		if (!empty($inserts)) {
255
+					$smcFunc['db_insert']('ignore',
244 256
 				'{db_prefix}log_search_words',
245 257
 				array('id_word' => 'int', 'id_msg' => 'int'),
246 258
 				$inserts,
247 259
 				array('id_word', 'id_msg')
248 260
 			);
261
+		}
249 262
 	}
250 263
 
251 264
 	/**
@@ -288,8 +301,9 @@  discard block
 block discarded – undo
288 301
 			if (!empty($inserted_words))
289 302
 			{
290 303
 				$inserts = array();
291
-				foreach ($inserted_words as $word)
292
-					$inserts[] = array($word, $msgOptions['id']);
304
+				foreach ($inserted_words as $word) {
305
+									$inserts[] = array($word, $msgOptions['id']);
306
+				}
293 307
 				$smcFunc['db_insert']('insert',
294 308
 					'{db_prefix}log_search_words',
295 309
 					array('id_word' => 'string', 'id_msg' => 'int'),
Please login to merge, or discard this patch.