Completed
Pull Request — release-2.1 (#5058)
by 01
120:18 queued 71:00
created
Sources/Profile-View.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2605,7 +2605,7 @@
 block discarded – undo
2605 2605
  * @param int $start Which item to start with (for pagination purposes)
2606 2606
  * @param int $items_per_page How many items to show on each page
2607 2607
  * @param string $sort A string indicating how to sort the results
2608
- * @param int $memID The ID of the member
2608
+ * @param string $memID The ID of the member
2609 2609
  * @return array An array of information about the user's group requests
2610 2610
  */
2611 2611
 function list_getGroupRequests($start, $items_per_page, $sort, $memID)
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 	}
251 251
 	$smcFunc['db_free_result']($request);
252 252
 
253
-	if($withSender)
253
+	if ($withSender)
254 254
 	{
255 255
 		$senders = loadMemberData($senders);
256 256
 		foreach ($senders as $member)
@@ -1896,7 +1896,7 @@  discard block
 block discarded – undo
1896 1896
 	if (count($context['ip']) !== 2)
1897 1897
 		fatal_lang_error('invalid_tracking_ip', false);
1898 1898
 
1899
-	$ip_string = array('{inet:ip_address_low}','{inet:ip_address_high}');
1899
+	$ip_string = array('{inet:ip_address_low}', '{inet:ip_address_high}');
1900 1900
 	$fields = array(
1901 1901
 			'ip_address_low' => $context['ip']['low'],
1902 1902
 			'ip_address_high' => $context['ip']['high'],
@@ -1904,7 +1904,7 @@  discard block
 block discarded – undo
1904 1904
 
1905 1905
 	$ip_var = $context['ip'];
1906 1906
 
1907
-	if ($context['ip']['low'] !==  $context['ip']['high'])
1907
+	if ($context['ip']['low'] !== $context['ip']['high'])
1908 1908
 		$context['ip'] = $context['ip']['low'] . ' - ' . $context['ip']['high'];
1909 1909
 	else
1910 1910
 		$context['ip'] = $context['ip']['low'];
Please login to merge, or discard this patch.
Braces   +313 added lines, -229 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
  * @version 2.1 Beta 4
12 12
  */
13 13
 
14
-if (!defined('SMF'))
14
+if (!defined('SMF')) {
15 15
 	die('No direct access...');
16
+}
16 17
 
17 18
 /**
18 19
  * View a summary.
@@ -23,8 +24,9 @@  discard block
 block discarded – undo
23 24
 	global $context, $memberContext, $txt, $modSettings, $user_profile, $sourcedir, $scripturl, $smcFunc;
24 25
 
25 26
 	// Attempt to load the member's profile data.
26
-	if (!loadMemberContext($memID) || !isset($memberContext[$memID]))
27
-		fatal_lang_error('not_a_user', false, 404);
27
+	if (!loadMemberContext($memID) || !isset($memberContext[$memID])) {
28
+			fatal_lang_error('not_a_user', false, 404);
29
+	}
28 30
 
29 31
 	// Set up the stuff and load the user.
30 32
 	$context += array(
@@ -49,19 +51,21 @@  discard block
 block discarded – undo
49 51
 
50 52
 	// See if they have broken any warning levels...
51 53
 	list ($modSettings['warning_enable'], $modSettings['user_limit']) = explode(',', $modSettings['warning_settings']);
52
-	if (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $context['member']['warning'])
53
-		$context['warning_status'] = $txt['profile_warning_is_muted'];
54
-	elseif (!empty($modSettings['warning_moderate']) && $modSettings['warning_moderate'] <= $context['member']['warning'])
55
-		$context['warning_status'] = $txt['profile_warning_is_moderation'];
56
-	elseif (!empty($modSettings['warning_watch']) && $modSettings['warning_watch'] <= $context['member']['warning'])
57
-		$context['warning_status'] = $txt['profile_warning_is_watch'];
54
+	if (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $context['member']['warning']) {
55
+			$context['warning_status'] = $txt['profile_warning_is_muted'];
56
+	} elseif (!empty($modSettings['warning_moderate']) && $modSettings['warning_moderate'] <= $context['member']['warning']) {
57
+			$context['warning_status'] = $txt['profile_warning_is_moderation'];
58
+	} elseif (!empty($modSettings['warning_watch']) && $modSettings['warning_watch'] <= $context['member']['warning']) {
59
+			$context['warning_status'] = $txt['profile_warning_is_watch'];
60
+	}
58 61
 
59 62
 	// They haven't even been registered for a full day!?
60 63
 	$days_registered = (int) ((time() - $user_profile[$memID]['date_registered']) / (3600 * 24));
61
-	if (empty($user_profile[$memID]['date_registered']) || $days_registered < 1)
62
-		$context['member']['posts_per_day'] = $txt['not_applicable'];
63
-	else
64
-		$context['member']['posts_per_day'] = comma_format($context['member']['real_posts'] / $days_registered, 3);
64
+	if (empty($user_profile[$memID]['date_registered']) || $days_registered < 1) {
65
+			$context['member']['posts_per_day'] = $txt['not_applicable'];
66
+	} else {
67
+			$context['member']['posts_per_day'] = comma_format($context['member']['real_posts'] / $days_registered, 3);
68
+	}
65 69
 
66 70
 	// Set the age...
67 71
 	if (empty($context['member']['birth_date']) || substr($context['member']['birth_date'], 0, 4) < 1002)
@@ -70,8 +74,7 @@  discard block
 block discarded – undo
70 74
 			'age' => $txt['not_applicable'],
71 75
 			'today_is_birthday' => false
72 76
 		);
73
-	}
74
-	else
77
+	} else
75 78
 	{
76 79
 		list ($birth_year, $birth_month, $birth_day) = sscanf($context['member']['birth_date'], '%d-%d-%d');
77 80
 		$datearray = getdate(forum_time());
@@ -84,15 +87,16 @@  discard block
 block discarded – undo
84 87
 	if (allowedTo('moderate_forum'))
85 88
 	{
86 89
 		// Make sure it's a valid ip address; otherwise, don't bother...
87
-		if (preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $memberContext[$memID]['ip']) == 1 && empty($modSettings['disableHostnameLookup']))
88
-			$context['member']['hostname'] = host_from_ip($memberContext[$memID]['ip']);
89
-		else
90
-			$context['member']['hostname'] = '';
90
+		if (preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $memberContext[$memID]['ip']) == 1 && empty($modSettings['disableHostnameLookup'])) {
91
+					$context['member']['hostname'] = host_from_ip($memberContext[$memID]['ip']);
92
+		} else {
93
+					$context['member']['hostname'] = '';
94
+		}
91 95
 
92 96
 		$context['can_see_ip'] = true;
97
+	} else {
98
+			$context['can_see_ip'] = false;
93 99
 	}
94
-	else
95
-		$context['can_see_ip'] = false;
96 100
 
97 101
 	// Are they hidden?
98 102
 	$context['member']['is_hidden'] = empty($user_profile[$memID]['show_online']);
@@ -103,8 +107,9 @@  discard block
 block discarded – undo
103 107
 		include_once($sourcedir . '/Who.php');
104 108
 		$action = determineActions($user_profile[$memID]['url']);
105 109
 
106
-		if ($action !== false)
107
-			$context['member']['action'] = $action;
110
+		if ($action !== false) {
111
+					$context['member']['action'] = $action;
112
+		}
108 113
 	}
109 114
 
110 115
 	// If the user is awaiting activation, and the viewer has permission - setup some activation context messages.
@@ -133,9 +138,10 @@  discard block
 block discarded – undo
133 138
 		list ($sig_limits, $sig_bbc) = explode(':', $modSettings['signature_settings']);
134 139
 		$sig_limits = explode(',', $sig_limits);
135 140
 
136
-		if (!empty($sig_limits[5]) || !empty($sig_limits[6]))
137
-			addInlineCss('
141
+		if (!empty($sig_limits[5]) || !empty($sig_limits[6])) {
142
+					addInlineCss('
138 143
 	.signature img { ' . (!empty($sig_limits[5]) ? 'max-width: ' . (int) $sig_limits[5] . 'px; ' : '') . (!empty($sig_limits[6]) ? 'max-height: ' . (int) $sig_limits[6] . 'px; ' : '') . '}');
144
+		}
139 145
 	}
140 146
 
141 147
 	// How about, are they banned?
@@ -178,13 +184,15 @@  discard block
 block discarded – undo
178 184
 		{
179 185
 			// Work out what restrictions we actually have.
180 186
 			$ban_restrictions = array();
181
-			foreach (array('access', 'login', 'post') as $type)
182
-				if ($row['cannot_' . $type])
187
+			foreach (array('access', 'login', 'post') as $type) {
188
+							if ($row['cannot_' . $type])
183 189
 					$ban_restrictions[] = $txt['ban_type_' . $type];
190
+			}
184 191
 
185 192
 			// No actual ban in place?
186
-			if (empty($ban_restrictions))
187
-				continue;
193
+			if (empty($ban_restrictions)) {
194
+							continue;
195
+			}
188 196
 
189 197
 			// Prepare the link for context.
190 198
 			$ban_explanation = sprintf($txt['user_cannot_due_to'], implode(', ', $ban_restrictions), '<a href="' . $scripturl . '?action=admin;area=ban;sa=edit;bg=' . $row['id_ban_group'] . '">' . $row['name'] . '</a>');
@@ -206,9 +214,10 @@  discard block
 block discarded – undo
206 214
 	$context['print_custom_fields'] = array();
207 215
 
208 216
 	// Any custom profile fields?
209
-	if (!empty($context['custom_fields']))
210
-		foreach ($context['custom_fields'] as $custom)
217
+	if (!empty($context['custom_fields'])) {
218
+			foreach ($context['custom_fields'] as $custom)
211 219
 			$context['print_custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom;
220
+	}
212 221
 
213 222
 }
214 223
 
@@ -233,8 +242,9 @@  discard block
 block discarded – undo
233 242
 	// are we someone else?
234 243
 	if (empty($user_info) || $user_info['id'] != $memID)
235 244
 	{
236
-		if (empty($user_profile[$memID]))
237
-			loadMemberData($memID, false, 'profile');
245
+		if (empty($user_profile[$memID])) {
246
+					loadMemberData($memID, false, 'profile');
247
+		}
238 248
 		$user_info = $user_profile[$memID];
239 249
 	}
240 250
 
@@ -265,16 +275,18 @@  discard block
 block discarded – undo
265 275
 		$row['extra'] = !empty($row['extra']) ? $smcFunc['json_decode']($row['extra'], true) : array();
266 276
 		$alerts[$id_alert] = $row;
267 277
 
268
-		if (!empty($row['sender_id']))
269
-			$senders[] = $row['sender_id'];
278
+		if (!empty($row['sender_id'])) {
279
+					$senders[] = $row['sender_id'];
280
+		}
270 281
 	}
271 282
 	$smcFunc['db_free_result']($request);
272 283
 
273 284
 	if($withSender)
274 285
 	{
275 286
 		$senders = loadMemberData($senders);
276
-		foreach ($senders as $member)
277
-			loadMemberContext($member);
287
+		foreach ($senders as $member) {
288
+					loadMemberContext($member);
289
+		}
278 290
 	}
279 291
 
280 292
 	// Now go through and actually make with the text.
@@ -289,12 +301,15 @@  discard block
 block discarded – undo
289 301
 	$msgs = array();
290 302
 	foreach ($alerts as $id_alert => $alert)
291 303
 	{
292
-		if (isset($alert['extra']['board']))
293
-			$boards[$alert['extra']['board']] = $txt['board_na'];
294
-		if (isset($alert['extra']['topic']))
295
-			$topics[$alert['extra']['topic']] = $txt['topic_na'];
296
-		if ($alert['content_type'] == 'msg')
297
-			$msgs[$alert['content_id']] = $txt['topic_na'];
304
+		if (isset($alert['extra']['board'])) {
305
+					$boards[$alert['extra']['board']] = $txt['board_na'];
306
+		}
307
+		if (isset($alert['extra']['topic'])) {
308
+					$topics[$alert['extra']['topic']] = $txt['topic_na'];
309
+		}
310
+		if ($alert['content_type'] == 'msg') {
311
+					$msgs[$alert['content_id']] = $txt['topic_na'];
312
+		}
298 313
 	}
299 314
 
300 315
 	// Having figured out what boards etc. there are, let's now get the names of them if we can see them. If not, there's already a fallback set up.
@@ -309,8 +324,9 @@  discard block
 block discarded – undo
309 324
 				'boards' => array_keys($boards),
310 325
 			)
311 326
 		);
312
-		while ($row = $smcFunc['db_fetch_assoc']($request))
313
-			$boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
327
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
328
+					$boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
329
+		}
314 330
 	}
315 331
 	if (!empty($topics))
316 332
 	{
@@ -325,8 +341,9 @@  discard block
 block discarded – undo
325 341
 				'topics' => array_keys($topics),
326 342
 			)
327 343
 		);
328
-		while ($row = $smcFunc['db_fetch_assoc']($request))
329
-			$topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>';
344
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
345
+					$topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>';
346
+		}
330 347
 	}
331 348
 	if (!empty($msgs))
332 349
 	{
@@ -341,44 +358,51 @@  discard block
 block discarded – undo
341 358
 				'msgs' => array_keys($msgs),
342 359
 			)
343 360
 		);
344
-		while ($row = $smcFunc['db_fetch_assoc']($request))
345
-			$msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>';
361
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
362
+					$msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>';
363
+		}
346 364
 	}
347 365
 
348 366
 	// Now to go back through the alerts, reattach this extra information and then try to build the string out of it (if a hook didn't already)
349 367
 	foreach ($alerts as $id_alert => $alert)
350 368
 	{
351
-		if (!empty($alert['text']))
352
-			continue;
353
-		if (isset($alert['extra']['board']))
354
-			if ($boards[$alert['extra']['board']] == $txt['board_na'])
369
+		if (!empty($alert['text'])) {
370
+					continue;
371
+		}
372
+		if (isset($alert['extra']['board'])) {
373
+					if ($boards[$alert['extra']['board']] == $txt['board_na'])
355 374
 			{
356 375
 				unset($alerts[$id_alert]);
376
+		}
357 377
 				continue;
378
+			} else {
379
+							$alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']];
358 380
 			}
359
-			else
360
-				$alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']];
361
-		if (isset($alert['extra']['topic']))
362
-			if ($alert['extra']['topic'] == $txt['topic_na'])
381
+		if (isset($alert['extra']['topic'])) {
382
+					if ($alert['extra']['topic'] == $txt['topic_na'])
363 383
 			{
364 384
 				unset($alerts[$id_alert]);
385
+		}
365 386
 				continue;
387
+			} else {
388
+							$alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']];
366 389
 			}
367
-			else
368
-				$alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']];
369
-		if ($alert['content_type'] == 'msg')
370
-			if ($msgs[$alert['content_id']] == $txt['topic_na'])
390
+		if ($alert['content_type'] == 'msg') {
391
+					if ($msgs[$alert['content_id']] == $txt['topic_na'])
371 392
 			{
372 393
 				unset($alerts[$id_alert]);
394
+		}
373 395
 				continue;
396
+			} else {
397
+							$alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']];
374 398
 			}
375
-			else
376
-				$alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']];
377
-		if ($alert['content_type'] == 'profile')
378
-			$alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>';
399
+		if ($alert['content_type'] == 'profile') {
400
+					$alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>';
401
+		}
379 402
 
380
-		if (!empty($memberContext[$alert['sender_id']]))
381
-			$alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']];
403
+		if (!empty($memberContext[$alert['sender_id']])) {
404
+					$alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']];
405
+		}
382 406
 
383 407
 		$string = 'alert_' . $alert['content_type'] . '_' . $alert['content_action'];
384 408
 		if (isset($txt[$string]))
@@ -428,8 +452,8 @@  discard block
 block discarded – undo
428 452
 	$context['pagination'] = constructPageIndex($scripturl . '?action=profile;area=showalerts;u=' . $memID, $start, $count, $maxIndex, false);
429 453
 
430 454
 	// Set some JavaScript for checking all alerts at once.
431
-	if ($context['showCheckboxes'])
432
-		addInlineJavaScript('
455
+	if ($context['showCheckboxes']) {
456
+			addInlineJavaScript('
433 457
 		$(function(){
434 458
 			$(\'#select_all\').on(\'change\', function() {
435 459
 				var checkboxes = $(\'ul.quickbuttons\').find(\':checkbox\');
@@ -441,6 +465,7 @@  discard block
 block discarded – undo
441 465
 				}
442 466
 			});
443 467
 		});', true);
468
+	}
444 469
 
445 470
 	// Set a nice message.
446 471
 	if (!empty($_SESSION['update_message']))
@@ -472,11 +497,11 @@  discard block
 block discarded – undo
472 497
 		checkSession('request');
473 498
 
474 499
 		// Call it!
475
-		if ($action == 'remove')
476
-			alert_delete($toMark, $memID);
477
-
478
-		else
479
-			alert_mark($memID, $toMark, $action == 'read' ? 1 : 0);
500
+		if ($action == 'remove') {
501
+					alert_delete($toMark, $memID);
502
+		} else {
503
+					alert_mark($memID, $toMark, $action == 'read' ? 1 : 0);
504
+		}
480 505
 
481 506
 		// Set a nice update message.
482 507
 		$_SESSION['update_message'] = true;
@@ -526,23 +551,27 @@  discard block
 block discarded – undo
526 551
 	);
527 552
 
528 553
 	// Set the page title
529
-	if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title))
530
-		$context['page_title'] = $txt['show' . $title[$_GET['sa']]];
531
-	else
532
-		$context['page_title'] = $txt['showPosts'];
554
+	if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title)) {
555
+			$context['page_title'] = $txt['show' . $title[$_GET['sa']]];
556
+	} else {
557
+			$context['page_title'] = $txt['showPosts'];
558
+	}
533 559
 
534 560
 	$context['page_title'] .= ' - ' . $user_profile[$memID]['real_name'];
535 561
 
536 562
 	// Is the load average too high to allow searching just now?
537
-	if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts'])
538
-		fatal_lang_error('loadavg_show_posts_disabled', false);
563
+	if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts']) {
564
+			fatal_lang_error('loadavg_show_posts_disabled', false);
565
+	}
539 566
 
540 567
 	// If we're specifically dealing with attachments use that function!
541
-	if (isset($_GET['sa']) && $_GET['sa'] == 'attach')
542
-		return showAttachments($memID);
568
+	if (isset($_GET['sa']) && $_GET['sa'] == 'attach') {
569
+			return showAttachments($memID);
570
+	}
543 571
 	// Instead, if we're dealing with unwatched topics (and the feature is enabled) use that other function.
544
-	elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics')
545
-		return showUnwatched($memID);
572
+	elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics') {
573
+			return showUnwatched($memID);
574
+	}
546 575
 
547 576
 	// Are we just viewing topics?
548 577
 	$context['is_topics'] = isset($_GET['sa']) && $_GET['sa'] == 'topics' ? true : false;
@@ -565,27 +594,30 @@  discard block
 block discarded – undo
565 594
 		$smcFunc['db_free_result']($request);
566 595
 
567 596
 		// Trying to remove a message that doesn't exist.
568
-		if (empty($info))
569
-			redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']);
597
+		if (empty($info)) {
598
+					redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']);
599
+		}
570 600
 
571 601
 		// We can be lazy, since removeMessage() will check the permissions for us.
572 602
 		require_once($sourcedir . '/RemoveTopic.php');
573 603
 		removeMessage((int) $_GET['delete']);
574 604
 
575 605
 		// Add it to the mod log.
576
-		if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id']))
577
-			logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3]));
606
+		if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) {
607
+					logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3]));
608
+		}
578 609
 
579 610
 		// Back to... where we are now ;).
580 611
 		redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']);
581 612
 	}
582 613
 
583 614
 	// Default to 10.
584
-	if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount']))
585
-		$_REQUEST['viewscount'] = '10';
615
+	if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) {
616
+			$_REQUEST['viewscount'] = '10';
617
+	}
586 618
 
587
-	if ($context['is_topics'])
588
-		$request = $smcFunc['db_query']('', '
619
+	if ($context['is_topics']) {
620
+			$request = $smcFunc['db_query']('', '
589 621
 			SELECT COUNT(*)
590 622
 			FROM {db_prefix}topics AS t' . ($user_info['query_see_board'] == '1=1' ? '' : '
591 623
 				INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board AND {query_see_board})') . '
@@ -598,8 +630,8 @@  discard block
 block discarded – undo
598 630
 				'board' => $board,
599 631
 			)
600 632
 		);
601
-	else
602
-		$request = $smcFunc['db_query']('', '
633
+	} else {
634
+			$request = $smcFunc['db_query']('', '
603 635
 			SELECT COUNT(*)
604 636
 			FROM {db_prefix}messages AS m' . ($user_info['query_see_board'] == '1=1' ? '' : '
605 637
 				INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board AND {query_see_board})') . '
@@ -612,6 +644,7 @@  discard block
 block discarded – undo
612 644
 				'board' => $board,
613 645
 			)
614 646
 		);
647
+	}
615 648
 	list ($msgCount) = $smcFunc['db_fetch_row']($request);
616 649
 	$smcFunc['db_free_result']($request);
617 650
 
@@ -632,10 +665,11 @@  discard block
 block discarded – undo
632 665
 
633 666
 	$range_limit = '';
634 667
 
635
-	if ($context['is_topics'])
636
-		$maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics'];
637
-	else
638
-		$maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages'];
668
+	if ($context['is_topics']) {
669
+			$maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics'];
670
+	} else {
671
+			$maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages'];
672
+	}
639 673
 
640 674
 	$maxIndex = $maxPerPage;
641 675
 
@@ -661,9 +695,9 @@  discard block
 block discarded – undo
661 695
 		{
662 696
 			$margin *= 5;
663 697
 			$range_limit = $reverse ? 't.id_first_msg < ' . ($min_msg_member + $margin) : 't.id_first_msg > ' . ($max_msg_member - $margin);
698
+		} else {
699
+					$range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin);
664 700
 		}
665
-		else
666
-			$range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin);
667 701
 	}
668 702
 
669 703
 	// Find this user's posts.  The left join on categories somehow makes this faster, weird as it looks.
@@ -695,8 +729,7 @@  discard block
 block discarded – undo
695 729
 					'max' => $maxIndex,
696 730
 				)
697 731
 			);
698
-		}
699
-		else
732
+		} else
700 733
 		{
701 734
 			$request = $smcFunc['db_query']('', '
702 735
 				SELECT
@@ -725,8 +758,9 @@  discard block
 block discarded – undo
725 758
 		}
726 759
 
727 760
 		// Make sure we quit this loop.
728
-		if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped || $range_limit == '')
729
-			break;
761
+		if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped || $range_limit == '') {
762
+					break;
763
+		}
730 764
 		$looped = true;
731 765
 		$range_limit = '';
732 766
 	}
@@ -770,19 +804,21 @@  discard block
 block discarded – undo
770 804
 			'css_class' => $row['approved'] ? 'windowbg' : 'approvebg',
771 805
 		);
772 806
 
773
-		if ($user_info['id'] == $row['id_member_started'])
774
-			$board_ids['own'][$row['id_board']][] = $counter;
807
+		if ($user_info['id'] == $row['id_member_started']) {
808
+					$board_ids['own'][$row['id_board']][] = $counter;
809
+		}
775 810
 		$board_ids['any'][$row['id_board']][] = $counter;
776 811
 	}
777 812
 	$smcFunc['db_free_result']($request);
778 813
 
779 814
 	// All posts were retrieved in reverse order, get them right again.
780
-	if ($reverse)
781
-		$context['posts'] = array_reverse($context['posts'], true);
815
+	if ($reverse) {
816
+			$context['posts'] = array_reverse($context['posts'], true);
817
+	}
782 818
 
783 819
 	// These are all the permissions that are different from board to board..
784
-	if ($context['is_topics'])
785
-		$permissions = array(
820
+	if ($context['is_topics']) {
821
+			$permissions = array(
786 822
 			'own' => array(
787 823
 				'post_reply_own' => 'can_reply',
788 824
 			),
@@ -790,8 +826,8 @@  discard block
 block discarded – undo
790 826
 				'post_reply_any' => 'can_reply',
791 827
 			)
792 828
 		);
793
-	else
794
-		$permissions = array(
829
+	} else {
830
+			$permissions = array(
795 831
 			'own' => array(
796 832
 				'post_reply_own' => 'can_reply',
797 833
 				'delete_own' => 'can_delete',
@@ -801,6 +837,7 @@  discard block
 block discarded – undo
801 837
 				'delete_any' => 'can_delete',
802 838
 			)
803 839
 		);
840
+	}
804 841
 
805 842
 	// For every permission in the own/any lists...
806 843
 	foreach ($permissions as $type => $list)
@@ -811,19 +848,22 @@  discard block
 block discarded – undo
811 848
 			$boards = boardsAllowedTo($permission);
812 849
 
813 850
 			// Hmm, they can do it on all boards, can they?
814
-			if (!empty($boards) && $boards[0] == 0)
815
-				$boards = array_keys($board_ids[$type]);
851
+			if (!empty($boards) && $boards[0] == 0) {
852
+							$boards = array_keys($board_ids[$type]);
853
+			}
816 854
 
817 855
 			// Now go through each board they can do the permission on.
818 856
 			foreach ($boards as $board_id)
819 857
 			{
820 858
 				// There aren't any posts displayed from this board.
821
-				if (!isset($board_ids[$type][$board_id]))
822
-					continue;
859
+				if (!isset($board_ids[$type][$board_id])) {
860
+									continue;
861
+				}
823 862
 
824 863
 				// Set the permission to true ;).
825
-				foreach ($board_ids[$type][$board_id] as $counter)
826
-					$context['posts'][$counter][$allowed] = true;
864
+				foreach ($board_ids[$type][$board_id] as $counter) {
865
+									$context['posts'][$counter][$allowed] = true;
866
+				}
827 867
 			}
828 868
 		}
829 869
 	}
@@ -854,8 +894,9 @@  discard block
 block discarded – undo
854 894
 	$boardsAllowed = boardsAllowedTo('view_attachments');
855 895
 
856 896
 	// Make sure we can't actually see anything...
857
-	if (empty($boardsAllowed))
858
-		$boardsAllowed = array(-1);
897
+	if (empty($boardsAllowed)) {
898
+			$boardsAllowed = array(-1);
899
+	}
859 900
 
860 901
 	require_once($sourcedir . '/Subs-List.php');
861 902
 
@@ -1006,8 +1047,8 @@  discard block
 block discarded – undo
1006 1047
 		)
1007 1048
 	);
1008 1049
 	$attachments = array();
1009
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1010
-		$attachments[] = array(
1050
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1051
+			$attachments[] = array(
1011 1052
 			'id' => $row['id_attach'],
1012 1053
 			'filename' => $row['filename'],
1013 1054
 			'downloads' => $row['downloads'],
@@ -1019,6 +1060,7 @@  discard block
 block discarded – undo
1019 1060
 			'board_name' => $row['name'],
1020 1061
 			'approved' => $row['approved'],
1021 1062
 		);
1063
+	}
1022 1064
 
1023 1065
 	$smcFunc['db_free_result']($request);
1024 1066
 
@@ -1073,8 +1115,9 @@  discard block
 block discarded – undo
1073 1115
 	global $txt, $user_info, $scripturl, $modSettings, $context, $sourcedir;
1074 1116
 
1075 1117
 	// Only the owner can see the list (if the function is enabled of course)
1076
-	if ($user_info['id'] != $memID)
1077
-		return;
1118
+	if ($user_info['id'] != $memID) {
1119
+			return;
1120
+	}
1078 1121
 
1079 1122
 	require_once($sourcedir . '/Subs-List.php');
1080 1123
 
@@ -1220,8 +1263,9 @@  discard block
 block discarded – undo
1220 1263
 	);
1221 1264
 
1222 1265
 	$topics = array();
1223
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1224
-		$topics[] = $row['id_topic'];
1266
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1267
+			$topics[] = $row['id_topic'];
1268
+	}
1225 1269
 
1226 1270
 	$smcFunc['db_free_result']($request);
1227 1271
 
@@ -1241,8 +1285,9 @@  discard block
 block discarded – undo
1241 1285
 				'topics' => $topics,
1242 1286
 			)
1243 1287
 		);
1244
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1245
-			$topicsInfo[] = $row;
1288
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1289
+					$topicsInfo[] = $row;
1290
+		}
1246 1291
 		$smcFunc['db_free_result']($request);
1247 1292
 	}
1248 1293
 
@@ -1290,8 +1335,9 @@  discard block
 block discarded – undo
1290 1335
 	$context['page_title'] = $txt['statPanel_showStats'] . ' ' . $user_profile[$memID]['real_name'];
1291 1336
 
1292 1337
 	// Is the load average too high to allow searching just now?
1293
-	if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats'])
1294
-		fatal_lang_error('loadavg_userstats_disabled', false);
1338
+	if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats']) {
1339
+			fatal_lang_error('loadavg_userstats_disabled', false);
1340
+	}
1295 1341
 
1296 1342
 	// General user statistics.
1297 1343
 	$timeDays = floor($user_profile[$memID]['total_time_logged_in'] / 86400);
@@ -1434,11 +1480,13 @@  discard block
 block discarded – undo
1434 1480
 	}
1435 1481
 	$smcFunc['db_free_result']($result);
1436 1482
 
1437
-	if ($maxPosts > 0)
1438
-		for ($hour = 0; $hour < 24; $hour++)
1483
+	if ($maxPosts > 0) {
1484
+			for ($hour = 0;
1485
+	}
1486
+	$hour < 24; $hour++)
1439 1487
 		{
1440
-			if (!isset($context['posts_by_time'][$hour]))
1441
-				$context['posts_by_time'][$hour] = array(
1488
+			if (!isset($context['posts_by_time'][$hour])) {
1489
+							$context['posts_by_time'][$hour] = array(
1442 1490
 					'hour' => $hour,
1443 1491
 					'hour_format' => stripos($user_info['time_format'], '%p') === false ? $hour : date('g a', mktime($hour)),
1444 1492
 					'posts' => 0,
@@ -1446,7 +1494,7 @@  discard block
 block discarded – undo
1446 1494
 					'relative_percent' => 0,
1447 1495
 					'is_last' => $hour == 23,
1448 1496
 				);
1449
-			else
1497
+			} else
1450 1498
 			{
1451 1499
 				$context['posts_by_time'][$hour]['posts_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $realPosts);
1452 1500
 				$context['posts_by_time'][$hour]['relative_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $maxPosts);
@@ -1479,8 +1527,9 @@  discard block
 block discarded – undo
1479 1527
 
1480 1528
 	foreach ($subActions as $sa => $action)
1481 1529
 	{
1482
-		if (!allowedTo($action[2]))
1483
-			unset($subActions[$sa]);
1530
+		if (!allowedTo($action[2])) {
1531
+					unset($subActions[$sa]);
1532
+		}
1484 1533
 	}
1485 1534
 
1486 1535
 	// Create the tabs for the template.
@@ -1498,15 +1547,18 @@  discard block
 block discarded – undo
1498 1547
 	);
1499 1548
 
1500 1549
 	// Moderation must be on to track edits.
1501
-	if (empty($modSettings['userlog_enabled']))
1502
-		unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']);
1550
+	if (empty($modSettings['userlog_enabled'])) {
1551
+			unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']);
1552
+	}
1503 1553
 
1504 1554
 	// Group requests must be active to show it...
1505
-	if (empty($modSettings['show_group_membership']))
1506
-		unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']);
1555
+	if (empty($modSettings['show_group_membership'])) {
1556
+			unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']);
1557
+	}
1507 1558
 
1508
-	if (empty($subActions))
1509
-		fatal_lang_error('no_access', false);
1559
+	if (empty($subActions)) {
1560
+			fatal_lang_error('no_access', false);
1561
+	}
1510 1562
 
1511 1563
 	$keys = array_keys($subActions);
1512 1564
 	$default = array_shift($keys);
@@ -1519,9 +1571,10 @@  discard block
 block discarded – undo
1519 1571
 	$context['sub_template'] = $subActions[$context['tracking_area']][0];
1520 1572
 	$call = call_helper($subActions[$context['tracking_area']][0], true);
1521 1573
 
1522
-	if (!empty($call))
1523
-		call_user_func($call, $memID);
1524
-}
1574
+	if (!empty($call)) {
1575
+			call_user_func($call, $memID);
1576
+	}
1577
+	}
1525 1578
 
1526 1579
 /**
1527 1580
  * Handles tracking a user's activity
@@ -1537,8 +1590,9 @@  discard block
 block discarded – undo
1537 1590
 	isAllowedTo('moderate_forum');
1538 1591
 
1539 1592
 	$context['last_ip'] = $user_profile[$memID]['member_ip'];
1540
-	if ($context['last_ip'] != $user_profile[$memID]['member_ip2'])
1541
-		$context['last_ip2'] = $user_profile[$memID]['member_ip2'];
1593
+	if ($context['last_ip'] != $user_profile[$memID]['member_ip2']) {
1594
+			$context['last_ip2'] = $user_profile[$memID]['member_ip2'];
1595
+	}
1542 1596
 	$context['member']['name'] = $user_profile[$memID]['real_name'];
1543 1597
 
1544 1598
 	// Set the options for the list component.
@@ -1705,8 +1759,9 @@  discard block
 block discarded – undo
1705 1759
 			)
1706 1760
 		);
1707 1761
 		$message_members = array();
1708
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1709
-			$message_members[] = $row['id_member'];
1762
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1763
+					$message_members[] = $row['id_member'];
1764
+		}
1710 1765
 		$smcFunc['db_free_result']($request);
1711 1766
 
1712 1767
 		// Fetch their names, cause of the GROUP BY doesn't like giving us that normally.
@@ -1721,8 +1776,9 @@  discard block
 block discarded – undo
1721 1776
 					'ip_list' => $ips,
1722 1777
 				)
1723 1778
 			);
1724
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1725
-				$context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
1779
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
1780
+							$context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
1781
+			}
1726 1782
 			$smcFunc['db_free_result']($request);
1727 1783
 		}
1728 1784
 
@@ -1736,8 +1792,9 @@  discard block
 block discarded – undo
1736 1792
 				'ip_list' => $ips,
1737 1793
 			)
1738 1794
 		);
1739
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1740
-			$context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
1795
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1796
+					$context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
1797
+		}
1741 1798
 		$smcFunc['db_free_result']($request);
1742 1799
 	}
1743 1800
 }
@@ -1797,8 +1854,8 @@  discard block
 block discarded – undo
1797 1854
 		))
1798 1855
 	);
1799 1856
 	$error_messages = array();
1800
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1801
-		$error_messages[] = array(
1857
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1858
+			$error_messages[] = array(
1802 1859
 			'ip' => inet_dtop($row['ip']),
1803 1860
 			'member_link' => $row['id_member'] > 0 ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>' : $row['display_name'],
1804 1861
 			'message' => strtr($row['message'], array('&lt;span class=&quot;remove&quot;&gt;' => '', '&lt;/span&gt;' => '')),
@@ -1806,6 +1863,7 @@  discard block
 block discarded – undo
1806 1863
 			'time' => timeformat($row['log_time']),
1807 1864
 			'timestamp' => forum_time(true, $row['log_time']),
1808 1865
 		);
1866
+	}
1809 1867
 	$smcFunc['db_free_result']($request);
1810 1868
 
1811 1869
 	return $error_messages;
@@ -1868,8 +1926,8 @@  discard block
 block discarded – undo
1868 1926
 		))
1869 1927
 	);
1870 1928
 	$messages = array();
1871
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1872
-		$messages[] = array(
1929
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1930
+			$messages[] = array(
1873 1931
 			'ip' => inet_dtop($row['poster_ip']),
1874 1932
 			'member_link' => empty($row['id_member']) ? $row['display_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>',
1875 1933
 			'board' => array(
@@ -1882,6 +1940,7 @@  discard block
 block discarded – undo
1882 1940
 			'time' => timeformat($row['poster_time']),
1883 1941
 			'timestamp' => forum_time(true, $row['poster_time'])
1884 1942
 		);
1943
+	}
1885 1944
 	$smcFunc['db_free_result']($request);
1886 1945
 
1887 1946
 	return $messages;
@@ -1908,19 +1967,20 @@  discard block
 block discarded – undo
1908 1967
 		$context['sub_template'] = 'trackIP';
1909 1968
 		$context['page_title'] = $txt['profile'];
1910 1969
 		$context['base_url'] = $scripturl . '?action=trackip';
1911
-	}
1912
-	else
1970
+	} else
1913 1971
 	{
1914 1972
 		$context['ip'] = ip2range($user_profile[$memID]['member_ip']);
1915 1973
 		$context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID;
1916 1974
 	}
1917 1975
 
1918 1976
 	// Searching?
1919
-	if (isset($_REQUEST['searchip']))
1920
-		$context['ip'] = ip2range(trim($_REQUEST['searchip']));
1977
+	if (isset($_REQUEST['searchip'])) {
1978
+			$context['ip'] = ip2range(trim($_REQUEST['searchip']));
1979
+	}
1921 1980
 
1922
-	if (count($context['ip']) !== 2)
1923
-		fatal_lang_error('invalid_tracking_ip', false);
1981
+	if (count($context['ip']) !== 2) {
1982
+			fatal_lang_error('invalid_tracking_ip', false);
1983
+	}
1924 1984
 
1925 1985
 	$ip_string = array('{inet:ip_address_low}','{inet:ip_address_high}');
1926 1986
 	$fields = array(
@@ -1930,13 +1990,15 @@  discard block
 block discarded – undo
1930 1990
 
1931 1991
 	$ip_var = $context['ip'];
1932 1992
 
1933
-	if ($context['ip']['low'] !==  $context['ip']['high'])
1934
-		$context['ip'] = $context['ip']['low'] . ' - ' . $context['ip']['high'];
1935
-	else
1936
-		$context['ip'] = $context['ip']['low'];
1993
+	if ($context['ip']['low'] !==  $context['ip']['high']) {
1994
+			$context['ip'] = $context['ip']['low'] . ' - ' . $context['ip']['high'];
1995
+	} else {
1996
+			$context['ip'] = $context['ip']['low'];
1997
+	}
1937 1998
 
1938
-	if (empty($context['tracking_area']))
1939
-		$context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip'];
1999
+	if (empty($context['tracking_area'])) {
2000
+			$context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip'];
2001
+	}
1940 2002
 
1941 2003
 	$request = $smcFunc['db_query']('', '
1942 2004
 		SELECT id_member, real_name AS display_name, member_ip
@@ -1945,8 +2007,9 @@  discard block
 block discarded – undo
1945 2007
 		$fields
1946 2008
 	);
1947 2009
 	$context['ips'] = array();
1948
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1949
-		$context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>';
2010
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
2011
+			$context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>';
2012
+	}
1950 2013
 	$smcFunc['db_free_result']($request);
1951 2014
 
1952 2015
 	ksort($context['ips']);
@@ -2176,10 +2239,11 @@  discard block
 block discarded – undo
2176 2239
 	// Gonna want this for the list.
2177 2240
 	require_once($sourcedir . '/Subs-List.php');
2178 2241
 
2179
-	if ($memID == 0)
2180
-		$context['base_url'] = $scripturl . '?action=trackip';
2181
-	else
2182
-		$context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID;
2242
+	if ($memID == 0) {
2243
+			$context['base_url'] = $scripturl . '?action=trackip';
2244
+	} else {
2245
+			$context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID;
2246
+	}
2183 2247
 
2184 2248
 	// Start with the user messages.
2185 2249
 	$listOptions = array(
@@ -2289,12 +2353,13 @@  discard block
 block discarded – undo
2289 2353
 		)
2290 2354
 	);
2291 2355
 	$logins = array();
2292
-	while ($row = $smcFunc['db_fetch_assoc']($request))
2293
-		$logins[] = array(
2356
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
2357
+			$logins[] = array(
2294 2358
 			'time' => timeformat($row['time']),
2295 2359
 			'ip' => inet_dtop($row['ip']),
2296 2360
 			'ip2' => inet_dtop($row['ip2']),
2297 2361
 		);
2362
+	}
2298 2363
 	$smcFunc['db_free_result']($request);
2299 2364
 
2300 2365
 	return $logins;
@@ -2319,11 +2384,12 @@  discard block
 block discarded – undo
2319 2384
 		)
2320 2385
 	);
2321 2386
 	$context['custom_field_titles'] = array();
2322
-	while ($row = $smcFunc['db_fetch_assoc']($request))
2323
-		$context['custom_field_titles']['customfield_' . $row['col_name']] = array(
2387
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
2388
+			$context['custom_field_titles']['customfield_' . $row['col_name']] = array(
2324 2389
 			'title' => $row['field_name'],
2325 2390
 			'parse_bbc' => $row['bbc'],
2326 2391
 		);
2392
+	}
2327 2393
 	$smcFunc['db_free_result']($request);
2328 2394
 
2329 2395
 	// Set the options for the error lists.
@@ -2462,19 +2528,22 @@  discard block
 block discarded – undo
2462 2528
 	while ($row = $smcFunc['db_fetch_assoc']($request))
2463 2529
 	{
2464 2530
 		$extra = $smcFunc['json_decode']($row['extra'], true);
2465
-		if (!empty($extra['applicator']))
2466
-			$members[] = $extra['applicator'];
2531
+		if (!empty($extra['applicator'])) {
2532
+					$members[] = $extra['applicator'];
2533
+		}
2467 2534
 
2468 2535
 		// Work out what the name of the action is.
2469
-		if (isset($txt['trackEdit_action_' . $row['action']]))
2470
-			$action_text = $txt['trackEdit_action_' . $row['action']];
2471
-		elseif (isset($txt[$row['action']]))
2472
-			$action_text = $txt[$row['action']];
2536
+		if (isset($txt['trackEdit_action_' . $row['action']])) {
2537
+					$action_text = $txt['trackEdit_action_' . $row['action']];
2538
+		} elseif (isset($txt[$row['action']])) {
2539
+					$action_text = $txt[$row['action']];
2540
+		}
2473 2541
 		// Custom field?
2474
-		elseif (isset($context['custom_field_titles'][$row['action']]))
2475
-			$action_text = $context['custom_field_titles'][$row['action']]['title'];
2476
-		else
2477
-			$action_text = $row['action'];
2542
+		elseif (isset($context['custom_field_titles'][$row['action']])) {
2543
+					$action_text = $context['custom_field_titles'][$row['action']]['title'];
2544
+		} else {
2545
+					$action_text = $row['action'];
2546
+		}
2478 2547
 
2479 2548
 		// Parse BBC?
2480 2549
 		$parse_bbc = isset($context['custom_field_titles'][$row['action']]) && $context['custom_field_titles'][$row['action']]['parse_bbc'] ? true : false;
@@ -2506,13 +2575,15 @@  discard block
 block discarded – undo
2506 2575
 			)
2507 2576
 		);
2508 2577
 		$members = array();
2509
-		while ($row = $smcFunc['db_fetch_assoc']($request))
2510
-			$members[$row['id_member']] = $row['real_name'];
2578
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
2579
+					$members[$row['id_member']] = $row['real_name'];
2580
+		}
2511 2581
 		$smcFunc['db_free_result']($request);
2512 2582
 
2513
-		foreach ($edits as $key => $value)
2514
-			if (isset($members[$value['id_member']]))
2583
+		foreach ($edits as $key => $value) {
2584
+					if (isset($members[$value['id_member']]))
2515 2585
 				$edits[$key]['member_link'] = '<a href="' . $scripturl . '?action=profile;u=' . $value['id_member'] . '">' . $members[$value['id_member']] . '</a>';
2586
+		}
2516 2587
 	}
2517 2588
 
2518 2589
 	return $edits;
@@ -2713,10 +2784,11 @@  discard block
 block discarded – undo
2713 2784
 	$context['board'] = $board;
2714 2785
 
2715 2786
 	// Determine which groups this user is in.
2716
-	if (empty($user_profile[$memID]['additional_groups']))
2717
-		$curGroups = array();
2718
-	else
2719
-		$curGroups = explode(',', $user_profile[$memID]['additional_groups']);
2787
+	if (empty($user_profile[$memID]['additional_groups'])) {
2788
+			$curGroups = array();
2789
+	} else {
2790
+			$curGroups = explode(',', $user_profile[$memID]['additional_groups']);
2791
+	}
2720 2792
 	$curGroups[] = $user_profile[$memID]['id_group'];
2721 2793
 	$curGroups[] = $user_profile[$memID]['id_post_group'];
2722 2794
 
@@ -2736,28 +2808,30 @@  discard block
 block discarded – undo
2736 2808
 	$context['no_access_boards'] = array();
2737 2809
 	while ($row = $smcFunc['db_fetch_assoc']($request))
2738 2810
 	{
2739
-		if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod'])
2740
-			$context['no_access_boards'][] = array(
2811
+		if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod']) {
2812
+					$context['no_access_boards'][] = array(
2741 2813
 				'id' => $row['id_board'],
2742 2814
 				'name' => $row['name'],
2743 2815
 				'is_last' => false,
2744 2816
 			);
2745
-		elseif ($row['id_profile'] != 1 || $row['is_mod'])
2746
-			$context['boards'][$row['id_board']] = array(
2817
+		} elseif ($row['id_profile'] != 1 || $row['is_mod']) {
2818
+					$context['boards'][$row['id_board']] = array(
2747 2819
 				'id' => $row['id_board'],
2748 2820
 				'name' => $row['name'],
2749 2821
 				'selected' => $board == $row['id_board'],
2750 2822
 				'profile' => $row['id_profile'],
2751 2823
 				'profile_name' => $context['profiles'][$row['id_profile']]['name'],
2752 2824
 			);
2825
+		}
2753 2826
 	}
2754 2827
 	$smcFunc['db_free_result']($request);
2755 2828
 
2756 2829
 	require_once($sourcedir . '/Subs-Boards.php');
2757 2830
 	sortBoards($context['boards']);
2758 2831
 
2759
-	if (!empty($context['no_access_boards']))
2760
-		$context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true;
2832
+	if (!empty($context['no_access_boards'])) {
2833
+			$context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true;
2834
+	}
2761 2835
 
2762 2836
 	$context['member']['permissions'] = array(
2763 2837
 		'general' => array(),
@@ -2766,8 +2840,9 @@  discard block
 block discarded – undo
2766 2840
 
2767 2841
 	// If you're an admin we know you can do everything, we might as well leave.
2768 2842
 	$context['member']['has_all_permissions'] = in_array(1, $curGroups);
2769
-	if ($context['member']['has_all_permissions'])
2770
-		return;
2843
+	if ($context['member']['has_all_permissions']) {
2844
+			return;
2845
+	}
2771 2846
 
2772 2847
 	$denied = array();
2773 2848
 
@@ -2786,21 +2861,24 @@  discard block
 block discarded – undo
2786 2861
 	while ($row = $smcFunc['db_fetch_assoc']($result))
2787 2862
 	{
2788 2863
 		// We don't know about this permission, it doesn't exist :P.
2789
-		if (!isset($txt['permissionname_' . $row['permission']]))
2790
-			continue;
2864
+		if (!isset($txt['permissionname_' . $row['permission']])) {
2865
+					continue;
2866
+		}
2791 2867
 
2792
-		if (empty($row['add_deny']))
2793
-			$denied[] = $row['permission'];
2868
+		if (empty($row['add_deny'])) {
2869
+					$denied[] = $row['permission'];
2870
+		}
2794 2871
 
2795 2872
 		// Permissions that end with _own or _any consist of two parts.
2796
-		if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)]))
2797
-			$name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']];
2798
-		else
2799
-			$name = $txt['permissionname_' . $row['permission']];
2873
+		if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) {
2874
+					$name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']];
2875
+		} else {
2876
+					$name = $txt['permissionname_' . $row['permission']];
2877
+		}
2800 2878
 
2801 2879
 		// Add this permission if it doesn't exist yet.
2802
-		if (!isset($context['member']['permissions']['general'][$row['permission']]))
2803
-			$context['member']['permissions']['general'][$row['permission']] = array(
2880
+		if (!isset($context['member']['permissions']['general'][$row['permission']])) {
2881
+					$context['member']['permissions']['general'][$row['permission']] = array(
2804 2882
 				'id' => $row['permission'],
2805 2883
 				'groups' => array(
2806 2884
 					'allowed' => array(),
@@ -2810,6 +2888,7 @@  discard block
 block discarded – undo
2810 2888
 				'is_denied' => false,
2811 2889
 				'is_global' => true,
2812 2890
 			);
2891
+		}
2813 2892
 
2814 2893
 		// Add the membergroup to either the denied or the allowed groups.
2815 2894
 		$context['member']['permissions']['general'][$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name'];
@@ -2843,18 +2922,20 @@  discard block
 block discarded – undo
2843 2922
 	while ($row = $smcFunc['db_fetch_assoc']($request))
2844 2923
 	{
2845 2924
 		// We don't know about this permission, it doesn't exist :P.
2846
-		if (!isset($txt['permissionname_' . $row['permission']]))
2847
-			continue;
2925
+		if (!isset($txt['permissionname_' . $row['permission']])) {
2926
+					continue;
2927
+		}
2848 2928
 
2849 2929
 		// The name of the permission using the format 'permission name' - 'own/any topic/event/etc.'.
2850
-		if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)]))
2851
-			$name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']];
2852
-		else
2853
-			$name = $txt['permissionname_' . $row['permission']];
2930
+		if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) {
2931
+					$name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']];
2932
+		} else {
2933
+					$name = $txt['permissionname_' . $row['permission']];
2934
+		}
2854 2935
 
2855 2936
 		// Create the structure for this permission.
2856
-		if (!isset($context['member']['permissions']['board'][$row['permission']]))
2857
-			$context['member']['permissions']['board'][$row['permission']] = array(
2937
+		if (!isset($context['member']['permissions']['board'][$row['permission']])) {
2938
+					$context['member']['permissions']['board'][$row['permission']] = array(
2858 2939
 				'id' => $row['permission'],
2859 2940
 				'groups' => array(
2860 2941
 					'allowed' => array(),
@@ -2864,6 +2945,7 @@  discard block
 block discarded – undo
2864 2945
 				'is_denied' => false,
2865 2946
 				'is_global' => empty($board),
2866 2947
 			);
2948
+		}
2867 2949
 
2868 2950
 		$context['member']['permissions']['board'][$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][$row['id_group']] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name'];
2869 2951
 
@@ -2882,8 +2964,9 @@  discard block
 block discarded – undo
2882 2964
 	global $modSettings, $context, $sourcedir, $txt, $scripturl;
2883 2965
 
2884 2966
 	// Firstly, can we actually even be here?
2885
-	if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum'))
2886
-		fatal_lang_error('no_access', false);
2967
+	if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum')) {
2968
+			fatal_lang_error('no_access', false);
2969
+	}
2887 2970
 
2888 2971
 	// Make sure things which are disabled stay disabled.
2889 2972
 	$modSettings['warning_watch'] = !empty($modSettings['warning_watch']) ? $modSettings['warning_watch'] : 110;
@@ -2970,9 +3053,10 @@  discard block
 block discarded – undo
2970 3053
 		$modSettings['warning_mute'] => $txt['profile_warning_effect_own_muted'],
2971 3054
 	);
2972 3055
 	$context['current_level'] = 0;
2973
-	foreach ($context['level_effects'] as $limit => $dummy)
2974
-		if ($context['member']['warning'] >= $limit)
3056
+	foreach ($context['level_effects'] as $limit => $dummy) {
3057
+			if ($context['member']['warning'] >= $limit)
2975 3058
 			$context['current_level'] = $limit;
2976
-}
3059
+	}
3060
+	}
2977 3061
 
2978 3062
 ?>
2979 3063
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/RemoveTopic.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1491,7 +1491,7 @@
 block discarded – undo
1491 1491
 
1492 1492
 /**
1493 1493
  * Try to determine if the topic has already been deleted by another user.
1494
- * @return bool False if it can't be deleted (recycling not enabled or no recycling board set), true if we've confirmed it can be deleted. Dies with an error if it's already been deleted.
1494
+ * @return boolean|null False if it can't be deleted (recycling not enabled or no recycling board set), true if we've confirmed it can be deleted. Dies with an error if it's already been deleted.
1495 1495
  */
1496 1496
 function removeDeleteConcurrence()
1497 1497
 {
Please login to merge, or discard this patch.
Braces   +267 added lines, -200 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 4
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /*	The contents of this file handle the deletion of topics, posts, and related
21 22
 	paraphernalia.  It has the following functions:
@@ -37,8 +38,9 @@  discard block
 block discarded – undo
37 38
 	require_once($sourcedir . '/Subs-Post.php');
38 39
 
39 40
 	// Trying to fool us around, are we?
40
-	if (empty($topic))
41
-		redirectexit();
41
+	if (empty($topic)) {
42
+			redirectexit();
43
+	}
42 44
 
43 45
 	removeDeleteConcurrence();
44 46
 
@@ -55,20 +57,23 @@  discard block
 block discarded – undo
55 57
 	list ($starter, $subject, $approved, $locked) = $smcFunc['db_fetch_row']($request);
56 58
 	$smcFunc['db_free_result']($request);
57 59
 
58
-	if ($starter == $user_info['id'] && !allowedTo('remove_any'))
59
-		isAllowedTo('remove_own');
60
-	else
61
-		isAllowedTo('remove_any');
60
+	if ($starter == $user_info['id'] && !allowedTo('remove_any')) {
61
+			isAllowedTo('remove_own');
62
+	} else {
63
+			isAllowedTo('remove_any');
64
+	}
62 65
 
63 66
 	// Can they see the topic?
64
-	if ($modSettings['postmod_active'] && !$approved && $starter != $user_info['id'])
65
-		isAllowedTo('approve_posts');
67
+	if ($modSettings['postmod_active'] && !$approved && $starter != $user_info['id']) {
68
+			isAllowedTo('approve_posts');
69
+	}
66 70
 
67 71
 	// Ok, we got that far, but is it locked?
68 72
 	if ($locked)
69 73
 	{
70
-		if (!($locked == 1 && $starter == $user_info['id'] || allowedTo('lock_any')))
71
-			fatal_lang_error('cannot_remove_locked', 'user');
74
+		if (!($locked == 1 && $starter == $user_info['id'] || allowedTo('lock_any'))) {
75
+					fatal_lang_error('cannot_remove_locked', 'user');
76
+		}
72 77
 	}
73 78
 
74 79
 	// Notify people that this topic has been removed.
@@ -77,8 +82,9 @@  discard block
 block discarded – undo
77 82
 	removeTopics($topic);
78 83
 
79 84
 	// Note, only log topic ID in native form if it's not gone forever.
80
-	if (allowedTo('remove_any') || (allowedTo('remove_own') && $starter == $user_info['id']))
81
-		logAction('remove', array((empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $board ? 'topic' : 'old_topic_id') => $topic, 'subject' => $subject, 'member' => $starter, 'board' => $board));
85
+	if (allowedTo('remove_any') || (allowedTo('remove_own') && $starter == $user_info['id'])) {
86
+			logAction('remove', array((empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $board ? 'topic' : 'old_topic_id') => $topic, 'subject' => $subject, 'member' => $starter, 'board' => $board));
87
+	}
82 88
 
83 89
 	redirectexit('board=' . $board . '.0');
84 90
 }
@@ -96,8 +102,9 @@  discard block
 block discarded – undo
96 102
 	$_REQUEST['msg'] = (int) $_REQUEST['msg'];
97 103
 
98 104
 	// Is $topic set?
99
-	if (empty($topic) && isset($_REQUEST['topic']))
100
-		$topic = (int) $_REQUEST['topic'];
105
+	if (empty($topic) && isset($_REQUEST['topic'])) {
106
+			$topic = (int) $_REQUEST['topic'];
107
+	}
101 108
 
102 109
 	removeDeleteConcurrence();
103 110
 
@@ -116,44 +123,48 @@  discard block
 block discarded – undo
116 123
 	$smcFunc['db_free_result']($request);
117 124
 
118 125
 	// Verify they can see this!
119
-	if ($modSettings['postmod_active'] && !$approved && !empty($poster) && $poster != $user_info['id'])
120
-		isAllowedTo('approve_posts');
126
+	if ($modSettings['postmod_active'] && !$approved && !empty($poster) && $poster != $user_info['id']) {
127
+			isAllowedTo('approve_posts');
128
+	}
121 129
 
122 130
 	if ($poster == $user_info['id'])
123 131
 	{
124 132
 		if (!allowedTo('delete_own'))
125 133
 		{
126
-			if ($starter == $user_info['id'] && !allowedTo('delete_any'))
127
-				isAllowedTo('delete_replies');
128
-			elseif (!allowedTo('delete_any'))
129
-				isAllowedTo('delete_own');
134
+			if ($starter == $user_info['id'] && !allowedTo('delete_any')) {
135
+							isAllowedTo('delete_replies');
136
+			} elseif (!allowedTo('delete_any')) {
137
+							isAllowedTo('delete_own');
138
+			}
139
+		} elseif (!allowedTo('delete_any') && ($starter != $user_info['id'] || !allowedTo('delete_replies')) && !empty($modSettings['edit_disable_time']) && $post_time + $modSettings['edit_disable_time'] * 60 < time()) {
140
+					fatal_lang_error('modify_post_time_passed', false);
130 141
 		}
131
-		elseif (!allowedTo('delete_any') && ($starter != $user_info['id'] || !allowedTo('delete_replies')) && !empty($modSettings['edit_disable_time']) && $post_time + $modSettings['edit_disable_time'] * 60 < time())
132
-			fatal_lang_error('modify_post_time_passed', false);
142
+	} elseif ($starter == $user_info['id'] && !allowedTo('delete_any')) {
143
+			isAllowedTo('delete_replies');
144
+	} else {
145
+			isAllowedTo('delete_any');
133 146
 	}
134
-	elseif ($starter == $user_info['id'] && !allowedTo('delete_any'))
135
-		isAllowedTo('delete_replies');
136
-	else
137
-		isAllowedTo('delete_any');
138 147
 
139 148
 	// If the full topic was removed go back to the board.
140 149
 	$full_topic = removeMessage($_REQUEST['msg']);
141 150
 
142
-	if (allowedTo('delete_any') && (!allowedTo('delete_own') || $poster != $user_info['id']))
143
-		logAction('delete', array('topic' => $topic, 'subject' => $subject, 'member' => $poster, 'board' => $board));
151
+	if (allowedTo('delete_any') && (!allowedTo('delete_own') || $poster != $user_info['id'])) {
152
+			logAction('delete', array('topic' => $topic, 'subject' => $subject, 'member' => $poster, 'board' => $board));
153
+	}
144 154
 
145 155
 	// We want to redirect back to recent action.
146
-	if (isset($_REQUEST['modcenter']))
147
-		redirectexit('action=moderate;area=reportedposts;done');
148
-	elseif (isset($_REQUEST['recent']))
149
-		redirectexit('action=recent');
150
-	elseif (isset($_REQUEST['profile'], $_REQUEST['start'], $_REQUEST['u']))
151
-		redirectexit('action=profile;u=' . $_REQUEST['u'] . ';area=showposts;start=' . $_REQUEST['start']);
152
-	elseif ($full_topic)
153
-		redirectexit('board=' . $board . '.0');
154
-	else
155
-		redirectexit('topic=' . $topic . '.' . $_REQUEST['start']);
156
-}
156
+	if (isset($_REQUEST['modcenter'])) {
157
+			redirectexit('action=moderate;area=reportedposts;done');
158
+	} elseif (isset($_REQUEST['recent'])) {
159
+			redirectexit('action=recent');
160
+	} elseif (isset($_REQUEST['profile'], $_REQUEST['start'], $_REQUEST['u'])) {
161
+			redirectexit('action=profile;u=' . $_REQUEST['u'] . ';area=showposts;start=' . $_REQUEST['start']);
162
+	} elseif ($full_topic) {
163
+			redirectexit('board=' . $board . '.0');
164
+	} else {
165
+			redirectexit('topic=' . $topic . '.' . $_REQUEST['start']);
166
+	}
167
+	}
157 168
 
158 169
 /**
159 170
  * So long as you are sure... all old posts will be gone.
@@ -167,8 +178,9 @@  discard block
 block discarded – undo
167 178
 	checkSession('post', 'admin');
168 179
 
169 180
 	// No boards at all?  Forget it then :/.
170
-	if (empty($_POST['boards']))
171
-		redirectexit('action=admin;area=maintain;sa=topics');
181
+	if (empty($_POST['boards'])) {
182
+			redirectexit('action=admin;area=maintain;sa=topics');
183
+	}
172 184
 
173 185
 	// This should exist, but we can make sure.
174 186
 	$_POST['delete_type'] = isset($_POST['delete_type']) ? $_POST['delete_type'] : 'nothing';
@@ -222,8 +234,9 @@  discard block
 block discarded – undo
222 234
 		$condition_params
223 235
 	);
224 236
 	$topics = array();
225
-	while ($row = $smcFunc['db_fetch_assoc']($request))
226
-		$topics[] = $row['id_topic'];
237
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
238
+			$topics[] = $row['id_topic'];
239
+	}
227 240
 	$smcFunc['db_free_result']($request);
228 241
 
229 242
 	removeTopics($topics, false, true);
@@ -247,11 +260,13 @@  discard block
 block discarded – undo
247 260
 	global $sourcedir, $modSettings, $smcFunc;
248 261
 
249 262
 	// Nothing to do?
250
-	if (empty($topics))
251
-		return;
263
+	if (empty($topics)) {
264
+			return;
265
+	}
252 266
 	// Only a single topic.
253
-	if (is_numeric($topics))
254
-		$topics = array($topics);
267
+	if (is_numeric($topics)) {
268
+			$topics = array($topics);
269
+	}
255 270
 
256 271
 	$recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0;
257 272
 
@@ -276,8 +291,9 @@  discard block
 block discarded – undo
276 291
 		);
277 292
 		if ($smcFunc['db_num_rows']($requestMembers) > 0)
278 293
 		{
279
-			while ($rowMembers = $smcFunc['db_fetch_assoc']($requestMembers))
280
-				updateMemberData($rowMembers['id_member'], array('posts' => 'posts - ' . $rowMembers['posts']));
294
+			while ($rowMembers = $smcFunc['db_fetch_assoc']($requestMembers)) {
295
+							updateMemberData($rowMembers['id_member'], array('posts' => 'posts - ' . $rowMembers['posts']));
296
+			}
281 297
 		}
282 298
 		$smcFunc['db_free_result']($requestMembers);
283 299
 	}
@@ -303,8 +319,9 @@  discard block
 block discarded – undo
303 319
 			$recycleTopics = array();
304 320
 			while ($row = $smcFunc['db_fetch_assoc']($request))
305 321
 			{
306
-				if (function_exists('apache_reset_timeout'))
307
-					@apache_reset_timeout();
322
+				if (function_exists('apache_reset_timeout')) {
323
+									@apache_reset_timeout();
324
+				}
308 325
 
309 326
 				$recycleTopics[] = $row['id_topic'];
310 327
 
@@ -346,20 +363,22 @@  discard block
 block discarded – undo
346 363
 
347 364
 			// Topics that were recycled don't need to be deleted, so subtract them.
348 365
 			$topics = array_diff($topics, $recycleTopics);
366
+		} else {
367
+					$smcFunc['db_free_result']($request);
349 368
 		}
350
-		else
351
-			$smcFunc['db_free_result']($request);
352 369
 	}
353 370
 
354 371
 	// Still topics left to delete?
355
-	if (empty($topics))
356
-		return;
372
+	if (empty($topics)) {
373
+			return;
374
+	}
357 375
 
358 376
 	// Callback for search APIs to do their thing
359 377
 	require_once($sourcedir . '/Search.php');
360 378
 	$searchAPI = findSearchAPI();
361
-	if ($searchAPI->supportsMethod('topicsRemoved'))
362
-		$searchAPI->topicsRemoved($topics);
379
+	if ($searchAPI->supportsMethod('topicsRemoved')) {
380
+			$searchAPI->topicsRemoved($topics);
381
+	}
363 382
 
364 383
 	$adjustBoards = array();
365 384
 
@@ -391,10 +410,11 @@  discard block
 block discarded – undo
391 410
 		$adjustBoards[$row['id_board']]['unapproved_posts'] += $row['unapproved_posts'];
392 411
 
393 412
 		// Add the topics to the right type.
394
-		if ($row['approved'])
395
-			$adjustBoards[$row['id_board']]['num_topics'] += $row['num_topics'];
396
-		else
397
-			$adjustBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics'];
413
+		if ($row['approved']) {
414
+					$adjustBoards[$row['id_board']]['num_topics'] += $row['num_topics'];
415
+		} else {
416
+					$adjustBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics'];
417
+		}
398 418
 	}
399 419
 	$smcFunc['db_free_result']($request);
400 420
 
@@ -403,8 +423,9 @@  discard block
 block discarded – undo
403 423
 		// Decrease the posts/topics...
404 424
 		foreach ($adjustBoards as $stats)
405 425
 		{
406
-			if (function_exists('apache_reset_timeout'))
407
-				@apache_reset_timeout();
426
+			if (function_exists('apache_reset_timeout')) {
427
+							@apache_reset_timeout();
428
+			}
408 429
 
409 430
 			$smcFunc['db_query']('', '
410 431
 				UPDATE {db_prefix}boards
@@ -438,8 +459,9 @@  discard block
 block discarded – undo
438 459
 		)
439 460
 	);
440 461
 	$polls = array();
441
-	while ($row = $smcFunc['db_fetch_assoc']($request))
442
-		$polls[] = $row['id_poll'];
462
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
463
+			$polls[] = $row['id_poll'];
464
+	}
443 465
 	$smcFunc['db_free_result']($request);
444 466
 
445 467
 	if (!empty($polls))
@@ -492,8 +514,9 @@  discard block
 block discarded – undo
492 514
 		);
493 515
 		while ($row = $smcFunc['db_fetch_assoc']($request))
494 516
 		{
495
-			if (function_exists('apache_reset_timeout'))
496
-				@apache_reset_timeout();
517
+			if (function_exists('apache_reset_timeout')) {
518
+							@apache_reset_timeout();
519
+			}
497 520
 
498 521
 			$words = array_merge($words, text2words($row['body'], $customIndexSettings['bytes_per_word'], true));
499 522
 			$messages[] = $row['id_msg'];
@@ -501,8 +524,8 @@  discard block
 block discarded – undo
501 524
 		$smcFunc['db_free_result']($request);
502 525
 		$words = array_unique($words);
503 526
 
504
-		if (!empty($words) && !empty($messages))
505
-			$smcFunc['db_query']('', '
527
+		if (!empty($words) && !empty($messages)) {
528
+					$smcFunc['db_query']('', '
506 529
 				DELETE FROM {db_prefix}log_search_words
507 530
 				WHERE id_word IN ({array_int:word_list})
508 531
 					AND id_msg IN ({array_int:message_list})',
@@ -511,6 +534,7 @@  discard block
 block discarded – undo
511 534
 					'message_list' => $messages,
512 535
 				)
513 536
 			);
537
+		}
514 538
 	}
515 539
 
516 540
 	// Delete anything related to the topic.
@@ -569,8 +593,9 @@  discard block
 block discarded – undo
569 593
 
570 594
 	require_once($sourcedir . '/Subs-Post.php');
571 595
 	$updates = array();
572
-	foreach ($adjustBoards as $stats)
573
-		$updates[] = $stats['id_board'];
596
+	foreach ($adjustBoards as $stats) {
597
+			$updates[] = $stats['id_board'];
598
+	}
574 599
 	updateLastMessages($updates);
575 600
 }
576 601
 
@@ -587,8 +612,9 @@  discard block
 block discarded – undo
587 612
 {
588 613
 	global $board, $sourcedir, $modSettings, $user_info, $smcFunc;
589 614
 
590
-	if (empty($message) || !is_numeric($message))
591
-		return false;
615
+	if (empty($message) || !is_numeric($message)) {
616
+			return false;
617
+	}
592 618
 
593 619
 	$recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0;
594 620
 
@@ -607,8 +633,9 @@  discard block
 block discarded – undo
607 633
 			'id_msg' => $message,
608 634
 		)
609 635
 	);
610
-	if ($smcFunc['db_num_rows']($request) == 0)
611
-		return false;
636
+	if ($smcFunc['db_num_rows']($request) == 0) {
637
+			return false;
638
+	}
612 639
 	$row = $smcFunc['db_fetch_assoc']($request);
613 640
 	$smcFunc['db_free_result']($request);
614 641
 
@@ -629,54 +656,57 @@  discard block
 block discarded – undo
629 656
 				{
630 657
 					if ($row['id_member_poster'] == $user_info['id'])
631 658
 					{
632
-						if (!$delete_replies)
633
-							fatal_lang_error('cannot_delete_replies', 'permission');
659
+						if (!$delete_replies) {
660
+													fatal_lang_error('cannot_delete_replies', 'permission');
661
+						}
662
+					} else {
663
+											fatal_lang_error('cannot_delete_own', 'permission');
634 664
 					}
635
-					else
636
-						fatal_lang_error('cannot_delete_own', 'permission');
665
+				} elseif (($row['id_member_poster'] != $user_info['id'] || !$delete_replies) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) {
666
+									fatal_lang_error('modify_post_time_passed', false);
637 667
 				}
638
-				elseif (($row['id_member_poster'] != $user_info['id'] || !$delete_replies) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time())
639
-					fatal_lang_error('modify_post_time_passed', false);
640
-			}
641
-			elseif ($row['id_member_poster'] == $user_info['id'])
668
+			} elseif ($row['id_member_poster'] == $user_info['id'])
642 669
 			{
643
-				if (!$delete_replies)
644
-					fatal_lang_error('cannot_delete_replies', 'permission');
670
+				if (!$delete_replies) {
671
+									fatal_lang_error('cannot_delete_replies', 'permission');
672
+				}
673
+			} else {
674
+							fatal_lang_error('cannot_delete_any', 'permission');
645 675
 			}
646
-			else
647
-				fatal_lang_error('cannot_delete_any', 'permission');
648 676
 		}
649 677
 
650 678
 		// Can't delete an unapproved message, if you can't see it!
651 679
 		if ($modSettings['postmod_active'] && !$row['approved'] && $row['id_member'] != $user_info['id'] && !(in_array(0, $delete_any) || in_array($row['id_board'], $delete_any)))
652 680
 		{
653 681
 			$approve_posts = boardsAllowedTo('approve_posts');
654
-			if (!in_array(0, $approve_posts) && !in_array($row['id_board'], $approve_posts))
655
-				return false;
682
+			if (!in_array(0, $approve_posts) && !in_array($row['id_board'], $approve_posts)) {
683
+							return false;
684
+			}
656 685
 		}
657
-	}
658
-	else
686
+	} else
659 687
 	{
660 688
 		// Check permissions to delete this message.
661 689
 		if ($row['id_member'] == $user_info['id'])
662 690
 		{
663 691
 			if (!allowedTo('delete_own'))
664 692
 			{
665
-				if ($row['id_member_poster'] == $user_info['id'] && !allowedTo('delete_any'))
666
-					isAllowedTo('delete_replies');
667
-				elseif (!allowedTo('delete_any'))
668
-					isAllowedTo('delete_own');
693
+				if ($row['id_member_poster'] == $user_info['id'] && !allowedTo('delete_any')) {
694
+									isAllowedTo('delete_replies');
695
+				} elseif (!allowedTo('delete_any')) {
696
+									isAllowedTo('delete_own');
697
+				}
698
+			} elseif (!allowedTo('delete_any') && ($row['id_member_poster'] != $user_info['id'] || !allowedTo('delete_replies')) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) {
699
+							fatal_lang_error('modify_post_time_passed', false);
669 700
 			}
670
-			elseif (!allowedTo('delete_any') && ($row['id_member_poster'] != $user_info['id'] || !allowedTo('delete_replies')) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time())
671
-				fatal_lang_error('modify_post_time_passed', false);
701
+		} elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('delete_any')) {
702
+					isAllowedTo('delete_replies');
703
+		} else {
704
+					isAllowedTo('delete_any');
672 705
 		}
673
-		elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('delete_any'))
674
-			isAllowedTo('delete_replies');
675
-		else
676
-			isAllowedTo('delete_any');
677 706
 
678
-		if ($modSettings['postmod_active'] && !$row['approved'] && $row['id_member'] != $user_info['id'] && !allowedTo('delete_own'))
679
-			isAllowedTo('approve_posts');
707
+		if ($modSettings['postmod_active'] && !$row['approved'] && $row['id_member'] != $user_info['id'] && !allowedTo('delete_own')) {
708
+					isAllowedTo('approve_posts');
709
+		}
680 710
 	}
681 711
 
682 712
 	// Delete the *whole* topic, but only if the topic consists of one message.
@@ -692,31 +722,34 @@  discard block
 block discarded – undo
692 722
 				$remove_own = in_array(0, $remove_own) || in_array($row['id_board'], $remove_own);
693 723
 			}
694 724
 
695
-			if ($row['id_member'] != $user_info['id'] && !$remove_any)
696
-				fatal_lang_error('cannot_remove_any', 'permission');
697
-			elseif (!$remove_any && !$remove_own)
698
-				fatal_lang_error('cannot_remove_own', 'permission');
699
-		}
700
-		else
725
+			if ($row['id_member'] != $user_info['id'] && !$remove_any) {
726
+							fatal_lang_error('cannot_remove_any', 'permission');
727
+			} elseif (!$remove_any && !$remove_own) {
728
+							fatal_lang_error('cannot_remove_own', 'permission');
729
+			}
730
+		} else
701 731
 		{
702 732
 			// Check permissions to delete a whole topic.
703
-			if ($row['id_member'] != $user_info['id'])
704
-				isAllowedTo('remove_any');
705
-			elseif (!allowedTo('remove_any'))
706
-				isAllowedTo('remove_own');
733
+			if ($row['id_member'] != $user_info['id']) {
734
+							isAllowedTo('remove_any');
735
+			} elseif (!allowedTo('remove_any')) {
736
+							isAllowedTo('remove_own');
737
+			}
707 738
 		}
708 739
 
709 740
 		// ...if there is only one post.
710
-		if (!empty($row['num_replies']))
711
-			fatal_lang_error('delFirstPost', false);
741
+		if (!empty($row['num_replies'])) {
742
+					fatal_lang_error('delFirstPost', false);
743
+		}
712 744
 
713 745
 		removeTopics($row['id_topic']);
714 746
 		return true;
715 747
 	}
716 748
 
717 749
 	// Deleting a recycled message can not lower anyone's post count.
718
-	if (!empty($recycle_board) && $row['id_board'] == $recycle_board)
719
-		$decreasePostCount = false;
750
+	if (!empty($recycle_board) && $row['id_board'] == $recycle_board) {
751
+			$decreasePostCount = false;
752
+	}
720 753
 
721 754
 	// This is the last post, update the last post on the board.
722 755
 	if ($row['id_last_msg'] == $message)
@@ -755,8 +788,8 @@  discard block
 block discarded – undo
755 788
 		);
756 789
 	}
757 790
 	// Only decrease post counts.
758
-	else
759
-		$smcFunc['db_query']('', '
791
+	else {
792
+			$smcFunc['db_query']('', '
760 793
 			UPDATE {db_prefix}topics
761 794
 			SET ' . ($row['approved'] ? '
762 795
 				num_replies = CASE WHEN num_replies = {int:no_replies} THEN 0 ELSE num_replies - 1 END' : '
@@ -768,6 +801,7 @@  discard block
 block discarded – undo
768 801
 				'id_topic' => $row['id_topic'],
769 802
 			)
770 803
 		);
804
+	}
771 805
 
772 806
 	// Default recycle to false.
773 807
 	$recycle = false;
@@ -787,8 +821,9 @@  discard block
 block discarded – undo
787 821
 				'recycle_board' => $modSettings['recycle_board'],
788 822
 			)
789 823
 		);
790
-		if ($smcFunc['db_num_rows']($request) == 0)
791
-			fatal_lang_error('recycle_no_valid_board');
824
+		if ($smcFunc['db_num_rows']($request) == 0) {
825
+					fatal_lang_error('recycle_no_valid_board');
826
+		}
792 827
 		list ($isRead, $last_board_msg) = $smcFunc['db_fetch_row']($request);
793 828
 		$smcFunc['db_free_result']($request);
794 829
 
@@ -807,8 +842,8 @@  discard block
 block discarded – undo
807 842
 		$smcFunc['db_free_result']($request);
808 843
 
809 844
 		// Insert a new topic in the recycle board if $id_recycle_topic is empty.
810
-		if (empty($id_recycle_topic))
811
-			$id_topic = $smcFunc['db_insert']('',
845
+		if (empty($id_recycle_topic)) {
846
+					$id_topic = $smcFunc['db_insert']('',
812 847
 				'{db_prefix}topics',
813 848
 				array(
814 849
 					'id_board' => 'int', 'id_member_started' => 'int', 'id_member_updated' => 'int', 'id_first_msg' => 'int',
@@ -821,6 +856,7 @@  discard block
 block discarded – undo
821 856
 				array('id_topic'),
822 857
 				1
823 858
 			);
859
+		}
824 860
 
825 861
 		// Capture the ID of the new topic...
826 862
 		$topicID = empty($id_recycle_topic) ? $id_topic : $id_recycle_topic;
@@ -858,22 +894,24 @@  discard block
 block discarded – undo
858 894
 			);
859 895
 
860 896
 			// Mark recycled topic as read.
861
-			if (!$user_info['is_guest'])
862
-				$smcFunc['db_insert']('replace',
897
+			if (!$user_info['is_guest']) {
898
+							$smcFunc['db_insert']('replace',
863 899
 					'{db_prefix}log_topics',
864 900
 					array('id_topic' => 'int', 'id_member' => 'int', 'id_msg' => 'int', 'unwatched' => 'int'),
865 901
 					array($topicID, $user_info['id'], $modSettings['maxMsgID'], 0),
866 902
 					array('id_topic', 'id_member')
867 903
 				);
904
+			}
868 905
 
869 906
 			// Mark recycle board as seen, if it was marked as seen before.
870
-			if (!empty($isRead) && !$user_info['is_guest'])
871
-				$smcFunc['db_insert']('replace',
907
+			if (!empty($isRead) && !$user_info['is_guest']) {
908
+							$smcFunc['db_insert']('replace',
872 909
 					'{db_prefix}log_boards',
873 910
 					array('id_board' => 'int', 'id_member' => 'int', 'id_msg' => 'int'),
874 911
 					array($modSettings['recycle_board'], $user_info['id'], $modSettings['maxMsgID']),
875 912
 					array('id_board', 'id_member')
876 913
 				);
914
+			}
877 915
 
878 916
 			// Add one topic and post to the recycle bin board.
879 917
 			$smcFunc['db_query']('', '
@@ -891,8 +929,8 @@  discard block
 block discarded – undo
891 929
 			);
892 930
 
893 931
 			// Lets increase the num_replies, and the first/last message ID as appropriate.
894
-			if (!empty($id_recycle_topic))
895
-				$smcFunc['db_query']('', '
932
+			if (!empty($id_recycle_topic)) {
933
+							$smcFunc['db_query']('', '
896 934
 					UPDATE {db_prefix}topics
897 935
 					SET num_replies = num_replies + 1' .
898 936
 						($message > $last_topic_msg ? ', id_last_msg = {int:id_merged_msg}' : '') .
@@ -903,6 +941,7 @@  discard block
 block discarded – undo
903 941
 						'id_merged_msg' => $message,
904 942
 					)
905 943
 				);
944
+			}
906 945
 
907 946
 			// Make sure this message isn't getting deleted later on.
908 947
 			$recycle = true;
@@ -912,8 +951,8 @@  discard block
 block discarded – undo
912 951
 		}
913 952
 
914 953
 		// If it wasn't approved don't keep it in the queue.
915
-		if (!$row['approved'])
916
-			$smcFunc['db_query']('', '
954
+		if (!$row['approved']) {
955
+					$smcFunc['db_query']('', '
917 956
 				DELETE FROM {db_prefix}approval_queue
918 957
 				WHERE id_msg = {int:id_msg}
919 958
 					AND id_attach = {int:id_attach}',
@@ -922,6 +961,7 @@  discard block
 block discarded – undo
922 961
 					'id_attach' => 0,
923 962
 				)
924 963
 			);
964
+		}
925 965
 	}
926 966
 
927 967
 	$smcFunc['db_query']('', '
@@ -939,8 +979,9 @@  discard block
 block discarded – undo
939 979
 
940 980
 	// If the poster was registered and the board this message was on incremented
941 981
 	// the member's posts when it was posted, decrease his or her post count.
942
-	if (!empty($row['id_member']) && $decreasePostCount && empty($row['count_posts']) && $row['approved'])
943
-		updateMemberData($row['id_member'], array('posts' => '-'));
982
+	if (!empty($row['id_member']) && $decreasePostCount && empty($row['count_posts']) && $row['approved']) {
983
+			updateMemberData($row['id_member'], array('posts' => '-'));
984
+	}
944 985
 
945 986
 	// Only remove posts if they're not recycled.
946 987
 	if (!$recycle)
@@ -948,8 +989,9 @@  discard block
 block discarded – undo
948 989
 		// Callback for search APIs to do their thing
949 990
 		require_once($sourcedir . '/Search.php');
950 991
 		$searchAPI = findSearchAPI();
951
-		if ($searchAPI->supportsMethod('postRemoved'))
952
-			$searchAPI->postRemoved($message);
992
+		if ($searchAPI->supportsMethod('postRemoved')) {
993
+					$searchAPI->postRemoved($message);
994
+		}
953 995
 
954 996
 		// Remove the message!
955 997
 		$smcFunc['db_query']('', '
@@ -964,8 +1006,8 @@  discard block
 block discarded – undo
964 1006
 		{
965 1007
 			$customIndexSettings = $smcFunc['json_decode']($modSettings['search_custom_index_config'], true);
966 1008
 			$words = text2words($row['body'], $customIndexSettings['bytes_per_word'], true);
967
-			if (!empty($words))
968
-				$smcFunc['db_query']('', '
1009
+			if (!empty($words)) {
1010
+							$smcFunc['db_query']('', '
969 1011
 					DELETE FROM {db_prefix}log_search_words
970 1012
 					WHERE id_word IN ({array_int:word_list})
971 1013
 						AND id_msg = {int:id_msg}',
@@ -974,6 +1016,7 @@  discard block
 block discarded – undo
974 1016
 						'id_msg' => $message,
975 1017
 					)
976 1018
 				);
1019
+			}
977 1020
 		}
978 1021
 
979 1022
 		// Delete attachment(s) if they exist.
@@ -997,10 +1040,11 @@  discard block
 block discarded – undo
997 1040
 
998 1041
 	// And now to update the last message of each board we messed with.
999 1042
 	require_once($sourcedir . '/Subs-Post.php');
1000
-	if ($recycle)
1001
-		updateLastMessages(array($row['id_board'], $modSettings['recycle_board']));
1002
-	else
1003
-		updateLastMessages($row['id_board']);
1043
+	if ($recycle) {
1044
+			updateLastMessages(array($row['id_board'], $modSettings['recycle_board']));
1045
+	} else {
1046
+			updateLastMessages($row['id_board']);
1047
+	}
1004 1048
 
1005 1049
 	// Close any moderation reports for this message.
1006 1050
 	$smcFunc['db_query']('', '
@@ -1033,8 +1077,9 @@  discard block
 block discarded – undo
1033 1077
 	checkSession('get');
1034 1078
 
1035 1079
 	// Is recycled board enabled?
1036
-	if (empty($modSettings['recycle_enable']))
1037
-		fatal_lang_error('restored_disabled', 'critical');
1080
+	if (empty($modSettings['recycle_enable'])) {
1081
+			fatal_lang_error('restored_disabled', 'critical');
1082
+	}
1038 1083
 
1039 1084
 	// Can we be in here?
1040 1085
 	isAllowedTo('move_any', $modSettings['recycle_board']);
@@ -1049,8 +1094,9 @@  discard block
 block discarded – undo
1049 1094
 	if (!empty($_REQUEST['msgs']))
1050 1095
 	{
1051 1096
 		$msgs = explode(',', $_REQUEST['msgs']);
1052
-		foreach ($msgs as $k => $msg)
1053
-			$msgs[$k] = (int) $msg;
1097
+		foreach ($msgs as $k => $msg) {
1098
+					$msgs[$k] = (int) $msg;
1099
+		}
1054 1100
 
1055 1101
 		// Get the id_previous_board and id_previous_topic.
1056 1102
 		$request = $smcFunc['db_query']('', '
@@ -1084,8 +1130,8 @@  discard block
 block discarded – undo
1084 1130
 			}
1085 1131
 
1086 1132
 			$previous_topics[] = $row['id_previous_topic'];
1087
-			if (empty($actioned_messages[$row['id_previous_topic']]))
1088
-				$actioned_messages[$row['id_previous_topic']] = array(
1133
+			if (empty($actioned_messages[$row['id_previous_topic']])) {
1134
+							$actioned_messages[$row['id_previous_topic']] = array(
1089 1135
 					'msgs' => array(),
1090 1136
 					'count_posts' => $row['count_posts'],
1091 1137
 					'subject' => $row['subject'],
@@ -1095,17 +1141,20 @@  discard block
 block discarded – undo
1095 1141
 					'current_board' => $row['id_board'],
1096 1142
 					'members' => array(),
1097 1143
 				);
1144
+			}
1098 1145
 
1099 1146
 			$actioned_messages[$row['id_previous_topic']]['msgs'][$row['id_msg']] = $row['subject'];
1100
-			if ($row['id_member'])
1101
-				$actioned_messages[$row['id_previous_topic']]['members'][] = $row['id_member'];
1147
+			if ($row['id_member']) {
1148
+							$actioned_messages[$row['id_previous_topic']]['members'][] = $row['id_member'];
1149
+			}
1102 1150
 		}
1103 1151
 		$smcFunc['db_free_result']($request);
1104 1152
 
1105 1153
 		// Check for topics we are going to fully restore.
1106
-		foreach ($actioned_messages as $topic => $data)
1107
-			if (in_array($topic, $topics_to_restore))
1154
+		foreach ($actioned_messages as $topic => $data) {
1155
+					if (in_array($topic, $topics_to_restore))
1108 1156
 				unset($actioned_messages[$topic]);
1157
+		}
1109 1158
 
1110 1159
 		// Load any previous topics to check they exist.
1111 1160
 		if (!empty($previous_topics))
@@ -1120,11 +1169,12 @@  discard block
 block discarded – undo
1120 1169
 				)
1121 1170
 			);
1122 1171
 			$previous_topics = array();
1123
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1124
-				$previous_topics[$row['id_topic']] = array(
1172
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
1173
+							$previous_topics[$row['id_topic']] = array(
1125 1174
 					'board' => $row['id_board'],
1126 1175
 					'subject' => $row['subject'],
1127 1176
 				);
1177
+			}
1128 1178
 			$smcFunc['db_free_result']($request);
1129 1179
 		}
1130 1180
 
@@ -1146,11 +1196,11 @@  discard block
 block discarded – undo
1146 1196
 				// Log em.
1147 1197
 				logAction('restore_posts', array('topic' => $topic, 'subject' => $previous_topics[$topic]['subject'], 'board' => empty($data['previous_board']) ? $data['possible_prev_board'] : $data['previous_board']));
1148 1198
 				$messages = array_merge(array_keys($data['msgs']), $messages);
1149
-			}
1150
-			else
1199
+			} else
1151 1200
 			{
1152
-				foreach ($data['msgs'] as $msg)
1153
-					$unfound_messages[$msg['id']] = $msg['subject'];
1201
+				foreach ($data['msgs'] as $msg) {
1202
+									$unfound_messages[$msg['id']] = $msg['subject'];
1203
+				}
1154 1204
 			}
1155 1205
 		}
1156 1206
 	}
@@ -1159,8 +1209,9 @@  discard block
 block discarded – undo
1159 1209
 	if (!empty($_REQUEST['topics']))
1160 1210
 	{
1161 1211
 		$topics = explode(',', $_REQUEST['topics']);
1162
-		foreach ($topics as $id)
1163
-			$topics_to_restore[] = (int) $id;
1212
+		foreach ($topics as $id) {
1213
+					$topics_to_restore[] = (int) $id;
1214
+		}
1164 1215
 	}
1165 1216
 
1166 1217
 	if (!empty($topics_to_restore))
@@ -1214,8 +1265,9 @@  discard block
 block discarded – undo
1214 1265
 					)
1215 1266
 				);
1216 1267
 
1217
-				while ($member = $smcFunc['db_fetch_assoc']($request2))
1218
-					updateMemberData($member['id_member'], array('posts' => 'posts + ' . $member['post_count']));
1268
+				while ($member = $smcFunc['db_fetch_assoc']($request2)) {
1269
+									updateMemberData($member['id_member'], array('posts' => 'posts + ' . $member['post_count']));
1270
+				}
1219 1271
 				$smcFunc['db_free_result']($request2);
1220 1272
 			}
1221 1273
 
@@ -1226,8 +1278,9 @@  discard block
 block discarded – undo
1226 1278
 	}
1227 1279
 
1228 1280
 	// Didn't find some things?
1229
-	if (!empty($unfound_messages))
1230
-		fatal_lang_error('restore_not_found', false, array(implode('<br>', $unfound_messages)));
1281
+	if (!empty($unfound_messages)) {
1282
+			fatal_lang_error('restore_not_found', false, array(implode('<br>', $unfound_messages)));
1283
+	}
1231 1284
 
1232 1285
 	// Just send them to the index if they get here.
1233 1286
 	redirectexit();
@@ -1247,12 +1300,14 @@  discard block
 block discarded – undo
1247 1300
 	//!!! This really needs to be rewritten to take a load of messages from ANY topic, it's also inefficient.
1248 1301
 
1249 1302
 	// Is it an array?
1250
-	if (!is_array($msgs))
1251
-		$msgs = array($msgs);
1303
+	if (!is_array($msgs)) {
1304
+			$msgs = array($msgs);
1305
+	}
1252 1306
 
1253 1307
 	// Lets make sure they are int.
1254
-	foreach ($msgs as $key => $msg)
1255
-		$msgs[$key] = (int) $msg;
1308
+	foreach ($msgs as $key => $msg) {
1309
+			$msgs[$key] = (int) $msg;
1310
+	}
1256 1311
 
1257 1312
 	// Get the source information.
1258 1313
 	$request = $smcFunc['db_query']('', '
@@ -1295,8 +1350,9 @@  discard block
 block discarded – undo
1295 1350
 			)
1296 1351
 		);
1297 1352
 
1298
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1299
-			updateMemberData($row['id_member'], array('posts' => '+'));
1353
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1354
+					updateMemberData($row['id_member'], array('posts' => '+'));
1355
+		}
1300 1356
 	}
1301 1357
 
1302 1358
 	// Time to move the messages.
@@ -1332,13 +1388,15 @@  discard block
 block discarded – undo
1332 1388
 	);
1333 1389
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1334 1390
 	{
1335
-		if ($row['id_first_msg'] < $target_topic_data['id_first_msg'])
1336
-			$target_topic_data['id_first_msg'] = $row['id_first_msg'];
1391
+		if ($row['id_first_msg'] < $target_topic_data['id_first_msg']) {
1392
+					$target_topic_data['id_first_msg'] = $row['id_first_msg'];
1393
+		}
1337 1394
 		$target_topic_data['id_last_msg'] = $row['id_last_msg'];
1338
-		if (!$row['approved'])
1339
-			$target_topic_data['unapproved_posts'] = $row['message_count'];
1340
-		else
1341
-			$target_topic_data['num_replies'] = max(0, $row['message_count'] - 1);
1395
+		if (!$row['approved']) {
1396
+					$target_topic_data['unapproved_posts'] = $row['message_count'];
1397
+		} else {
1398
+					$target_topic_data['num_replies'] = max(0, $row['message_count'] - 1);
1399
+		}
1342 1400
 	}
1343 1401
 	$smcFunc['db_free_result']($request);
1344 1402
 
@@ -1397,13 +1455,15 @@  discard block
 block discarded – undo
1397 1455
 		);
1398 1456
 		while ($row = $smcFunc['db_fetch_assoc']($request))
1399 1457
 		{
1400
-			if ($row['id_first_msg'] < $source_topic_data['id_first_msg'])
1401
-				$source_topic_data['id_first_msg'] = $row['id_first_msg'];
1458
+			if ($row['id_first_msg'] < $source_topic_data['id_first_msg']) {
1459
+							$source_topic_data['id_first_msg'] = $row['id_first_msg'];
1460
+			}
1402 1461
 			$source_topic_data['id_last_msg'] = $row['id_last_msg'];
1403
-			if (!$row['approved'])
1404
-				$source_topic_data['unapproved_posts'] = $row['message_count'];
1405
-			else
1406
-				$source_topic_data['num_replies'] = max(0, $row['message_count'] - 1);
1462
+			if (!$row['approved']) {
1463
+							$source_topic_data['unapproved_posts'] = $row['message_count'];
1464
+			} else {
1465
+							$source_topic_data['num_replies'] = max(0, $row['message_count'] - 1);
1466
+			}
1407 1467
 		}
1408 1468
 		$smcFunc['db_free_result']($request);
1409 1469
 
@@ -1467,10 +1527,12 @@  discard block
 block discarded – undo
1467 1527
 
1468 1528
 	// Subject cache?
1469 1529
 	$cache_updates = array();
1470
-	if ($target_first_msg != $target_topic_data['id_first_msg'])
1471
-		$cache_updates[] = $target_topic_data['id_first_msg'];
1472
-	if (!empty($source_topic_data['id_first_msg']) && $from_first_msg != $source_topic_data['id_first_msg'])
1473
-		$cache_updates[] = $source_topic_data['id_first_msg'];
1530
+	if ($target_first_msg != $target_topic_data['id_first_msg']) {
1531
+			$cache_updates[] = $target_topic_data['id_first_msg'];
1532
+	}
1533
+	if (!empty($source_topic_data['id_first_msg']) && $from_first_msg != $source_topic_data['id_first_msg']) {
1534
+			$cache_updates[] = $source_topic_data['id_first_msg'];
1535
+	}
1474 1536
 
1475 1537
 	if (!empty($cache_updates))
1476 1538
 	{
@@ -1482,8 +1544,9 @@  discard block
 block discarded – undo
1482 1544
 				'first_messages' => $cache_updates,
1483 1545
 			)
1484 1546
 		);
1485
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1486
-			updateStats('subject', $row['id_topic'], $row['subject']);
1547
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1548
+					updateStats('subject', $row['id_topic'], $row['subject']);
1549
+		}
1487 1550
 		$smcFunc['db_free_result']($request);
1488 1551
 	}
1489 1552
 
@@ -1499,22 +1562,26 @@  discard block
 block discarded – undo
1499 1562
 	global $modSettings, $board, $scripturl, $context;
1500 1563
 
1501 1564
 	// No recycle no need to go further
1502
-	if (empty($modSettings['recycle_enable']) || empty($modSettings['recycle_board']))
1503
-		return false;
1565
+	if (empty($modSettings['recycle_enable']) || empty($modSettings['recycle_board'])) {
1566
+			return false;
1567
+	}
1504 1568
 
1505 1569
 	// If it's confirmed go on and delete (from recycle)
1506
-	if (isset($_GET['confirm_delete']))
1507
-		return true;
1570
+	if (isset($_GET['confirm_delete'])) {
1571
+			return true;
1572
+	}
1508 1573
 
1509
-	if (empty($board))
1510
-		return false;
1574
+	if (empty($board)) {
1575
+			return false;
1576
+	}
1511 1577
 
1512
-	if ($modSettings['recycle_board'] != $board)
1513
-		return true;
1514
-	elseif (isset($_REQUEST['msg']))
1515
-		$confirm_url = $scripturl . '?action=deletemsg;confirm_delete;topic=' . $context['current_topic'] . '.0;msg=' . $_REQUEST['msg'] . ';' . $context['session_var'] . '=' . $context['session_id'];
1516
-	else
1517
-		$confirm_url = $scripturl . '?action=removetopic2;confirm_delete;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id'];
1578
+	if ($modSettings['recycle_board'] != $board) {
1579
+			return true;
1580
+	} elseif (isset($_REQUEST['msg'])) {
1581
+			$confirm_url = $scripturl . '?action=deletemsg;confirm_delete;topic=' . $context['current_topic'] . '.0;msg=' . $_REQUEST['msg'] . ';' . $context['session_var'] . '=' . $context['session_id'];
1582
+	} else {
1583
+			$confirm_url = $scripturl . '?action=removetopic2;confirm_delete;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id'];
1584
+	}
1518 1585
 
1519 1586
 	fatal_lang_error('post_already_deleted', false, array($confirm_url));
1520 1587
 }
Please login to merge, or discard this patch.
Sources/Reports.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1013,7 +1013,7 @@
 block discarded – undo
1013 1013
  * @param string $title The title of the separator
1014 1014
  * @param null|string $custom_table The ID of the custom table
1015 1015
  *
1016
- * @return void|bool Returns false if there are no tables
1016
+ * @return null|false Returns false if there are no tables
1017 1017
  */
1018 1018
 function addSeparator($title = '', $custom_table = null)
1019 1019
 {
Please login to merge, or discard this patch.
Braces   +199 added lines, -148 removed lines patch added patch discarded remove patch
@@ -21,8 +21,9 @@  discard block
 block discarded – undo
21 21
  * @version 2.1 Beta 4
22 22
  */
23 23
 
24
-if (!defined('SMF'))
24
+if (!defined('SMF')) {
25 25
 	die('No direct access...');
26
+}
26 27
 
27 28
 /**
28 29
  * Handling function for generating reports.
@@ -69,14 +70,15 @@  discard block
 block discarded – undo
69 70
 	);
70 71
 
71 72
 	$is_first = 0;
72
-	foreach ($context['report_types'] as $k => $temp)
73
-		$context['report_types'][$k] = array(
73
+	foreach ($context['report_types'] as $k => $temp) {
74
+			$context['report_types'][$k] = array(
74 75
 			'id' => $k,
75 76
 			'title' => isset($txt['gr_type_' . $k]) ? $txt['gr_type_' . $k] : $k,
76 77
 			'description' => isset($txt['gr_type_desc_' . $k]) ? $txt['gr_type_desc_' . $k] : null,
77 78
 			'function' => $temp,
78 79
 			'is_first' => $is_first++ == 0,
79 80
 		);
81
+	}
80 82
 
81 83
 	// If they haven't chosen a report type which is valid, send them off to the report type chooser!
82 84
 	if (empty($_REQUEST['rt']) || !isset($context['report_types'][$_REQUEST['rt']]))
@@ -102,8 +104,9 @@  discard block
 block discarded – undo
102 104
 		$context['sub_template'] = $_REQUEST['st'];
103 105
 
104 106
 		// Are we disabling the other layers - print friendly for example?
105
-		if ($reportTemplates[$_REQUEST['st']]['layers'] !== null)
106
-			$context['template_layers'] = $reportTemplates[$_REQUEST['st']]['layers'];
107
+		if ($reportTemplates[$_REQUEST['st']]['layers'] !== null) {
108
+					$context['template_layers'] = $reportTemplates[$_REQUEST['st']]['layers'];
109
+		}
107 110
 	}
108 111
 
109 112
 	// Make the page title more descriptive.
@@ -151,8 +154,9 @@  discard block
 block discarded – undo
151 154
 		)
152 155
 	);
153 156
 	$moderators = array();
154
-	while ($row = $smcFunc['db_fetch_assoc']($request))
155
-		$moderators[$row['id_board']][] = $row['real_name'];
157
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
158
+			$moderators[$row['id_board']][] = $row['real_name'];
159
+	}
156 160
 	$smcFunc['db_free_result']($request);
157 161
 
158 162
 	// Get every moderator gruop.
@@ -164,8 +168,9 @@  discard block
 block discarded – undo
164 168
 		)
165 169
 	);
166 170
 	$moderator_groups = array();
167
-	while ($row = $smcFunc['db_fetch_assoc']($request))
168
-		$moderator_groups[$row['id_board']][] = $row['group_name'];
171
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
172
+			$moderator_groups[$row['id_board']][] = $row['group_name'];
173
+	}
169 174
 	$smcFunc['db_free_result']($request);
170 175
 
171 176
 	// Get all the possible membergroups!
@@ -176,8 +181,9 @@  discard block
 block discarded – undo
176 181
 		)
177 182
 	);
178 183
 	$groups = array(-1 => $txt['guest_title'], 0 => $txt['full_member']);
179
-	while ($row = $smcFunc['db_fetch_assoc']($request))
180
-		$groups[$row['id_group']] = empty($row['online_color']) ? $row['group_name'] : '<span style="color: ' . $row['online_color'] . '">' . $row['group_name'] . '</span>';
184
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
185
+			$groups[$row['id_group']] = empty($row['online_color']) ? $row['group_name'] : '<span style="color: ' . $row['online_color'] . '">' . $row['group_name'] . '</span>';
186
+	}
181 187
 	$smcFunc['db_free_result']($request);
182 188
 
183 189
 	// All the fields we'll show.
@@ -195,8 +201,9 @@  discard block
 block discarded – undo
195 201
 		'moderator_groups' => $txt['board_moderator_groups'],
196 202
 		'groups' => $txt['board_groups'],
197 203
 	);
198
-	if (!empty($modSettings['deny_boards_access']))
199
-		$boardSettings['disallowed_groups'] = $txt['board_disallowed_groups'];
204
+	if (!empty($modSettings['deny_boards_access'])) {
205
+			$boardSettings['disallowed_groups'] = $txt['board_disallowed_groups'];
206
+	}
200 207
 
201 208
 	// Do it in columns, it's just easier.
202 209
 	setKeys('cols');
@@ -222,8 +229,9 @@  discard block
 block discarded – undo
222 229
 		newTable($row['name'], '', 'left', 'auto', 'left', 200, 'left');
223 230
 
224 231
 		$this_boardSettings = $boardSettings;
225
-		if (empty($row['redirect']))
226
-			unset($this_boardSettings['redirect']);
232
+		if (empty($row['redirect'])) {
233
+					unset($this_boardSettings['redirect']);
234
+		}
227 235
 
228 236
 		// First off, add in the side key.
229 237
 		addData($this_boardSettings);
@@ -250,10 +258,11 @@  discard block
 block discarded – undo
250 258
 		$allowedGroups = explode(',', $row['member_groups']);
251 259
 		foreach ($allowedGroups as $key => $group)
252 260
 		{
253
-			if (isset($groups[$group]))
254
-				$allowedGroups[$key] = $groups[$group];
255
-			else
256
-				unset($allowedGroups[$key]);
261
+			if (isset($groups[$group])) {
262
+							$allowedGroups[$key] = $groups[$group];
263
+			} else {
264
+							unset($allowedGroups[$key]);
265
+			}
257 266
 		}
258 267
 		$boardData['groups'] = implode(', ', $allowedGroups);
259 268
 		if (!empty($modSettings['deny_boards_access']))
@@ -261,16 +270,18 @@  discard block
 block discarded – undo
261 270
 			$disallowedGroups = explode(',', $row['deny_member_groups']);
262 271
 			foreach ($disallowedGroups as $key => $group)
263 272
 			{
264
-				if (isset($groups[$group]))
265
-					$disallowedGroups[$key] = $groups[$group];
266
-				else
267
-					unset($disallowedGroups[$key]);
273
+				if (isset($groups[$group])) {
274
+									$disallowedGroups[$key] = $groups[$group];
275
+				} else {
276
+									unset($disallowedGroups[$key]);
277
+				}
268 278
 			}
269 279
 			$boardData['disallowed_groups'] = implode(', ', $disallowedGroups);
270 280
 		}
271 281
 
272
-		if (empty($row['redirect']))
273
-			unset ($boardData['redirect']);
282
+		if (empty($row['redirect'])) {
283
+					unset ($boardData['redirect']);
284
+		}
274 285
 
275 286
 		// Next add the main data.
276 287
 		addData($boardData);
@@ -295,27 +306,31 @@  discard block
 block discarded – undo
295 306
 
296 307
 	if (isset($_REQUEST['boards']))
297 308
 	{
298
-		if (!is_array($_REQUEST['boards']))
299
-			$_REQUEST['boards'] = explode(',', $_REQUEST['boards']);
300
-		foreach ($_REQUEST['boards'] as $k => $dummy)
301
-			$_REQUEST['boards'][$k] = (int) $dummy;
309
+		if (!is_array($_REQUEST['boards'])) {
310
+					$_REQUEST['boards'] = explode(',', $_REQUEST['boards']);
311
+		}
312
+		foreach ($_REQUEST['boards'] as $k => $dummy) {
313
+					$_REQUEST['boards'][$k] = (int) $dummy;
314
+		}
302 315
 
303 316
 		$board_clause = 'id_board IN ({array_int:boards})';
317
+	} else {
318
+			$board_clause = '1=1';
304 319
 	}
305
-	else
306
-		$board_clause = '1=1';
307 320
 
308 321
 	if (isset($_REQUEST['groups']))
309 322
 	{
310
-		if (!is_array($_REQUEST['groups']))
311
-			$_REQUEST['groups'] = explode(',', $_REQUEST['groups']);
312
-		foreach ($_REQUEST['groups'] as $k => $dummy)
313
-			$_REQUEST['groups'][$k] = (int) $dummy;
323
+		if (!is_array($_REQUEST['groups'])) {
324
+					$_REQUEST['groups'] = explode(',', $_REQUEST['groups']);
325
+		}
326
+		foreach ($_REQUEST['groups'] as $k => $dummy) {
327
+					$_REQUEST['groups'][$k] = (int) $dummy;
328
+		}
314 329
 
315 330
 		$group_clause = 'id_group IN ({array_int:groups})';
331
+	} else {
332
+			$group_clause = '1=1';
316 333
 	}
317
-	else
318
-		$group_clause = '1=1';
319 334
 
320 335
 	// Fetch all the board names.
321 336
 	$request = $smcFunc['db_query']('', '
@@ -369,12 +384,14 @@  discard block
 block discarded – undo
369 384
 			'groups' => isset($_REQUEST['groups']) ? $_REQUEST['groups'] : array(),
370 385
 		)
371 386
 	);
372
-	if (!isset($_REQUEST['groups']) || in_array(-1, $_REQUEST['groups']) || in_array(0, $_REQUEST['groups']))
373
-		$member_groups = array('col' => '', -1 => $txt['membergroups_guests'], 0 => $txt['membergroups_members']);
374
-	else
375
-		$member_groups = array('col' => '');
376
-	while ($row = $smcFunc['db_fetch_assoc']($request))
377
-		$member_groups[$row['id_group']] = $row['group_name'];
387
+	if (!isset($_REQUEST['groups']) || in_array(-1, $_REQUEST['groups']) || in_array(0, $_REQUEST['groups'])) {
388
+			$member_groups = array('col' => '', -1 => $txt['membergroups_guests'], 0 => $txt['membergroups_members']);
389
+	} else {
390
+			$member_groups = array('col' => '');
391
+	}
392
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
393
+			$member_groups[$row['id_group']] = $row['group_name'];
394
+	}
378 395
 	$smcFunc['db_free_result']($request);
379 396
 
380 397
 	// Make sure that every group is represented - plus in rows!
@@ -411,12 +428,14 @@  discard block
 block discarded – undo
411 428
 	);
412 429
 	while ($row = $smcFunc['db_fetch_assoc']($request))
413 430
 	{
414
-		if (in_array($row['permission'], $disabled_permissions))
415
-			continue;
431
+		if (in_array($row['permission'], $disabled_permissions)) {
432
+					continue;
433
+		}
416 434
 
417
-		foreach ($boards as $id => $board)
418
-			if ($board['profile'] == $row['id_profile'])
435
+		foreach ($boards as $id => $board) {
436
+					if ($board['profile'] == $row['id_profile'])
419 437
 				$board_permissions[$id][$row['id_group']][$row['permission']] = $row['add_deny'];
438
+		}
420 439
 
421 440
 		// Make sure we get every permission.
422 441
 		if (!isset($permissions[$row['permission']]))
@@ -451,8 +470,9 @@  discard block
 block discarded – undo
451 470
 			foreach ($member_groups as $id_group => $name)
452 471
 			{
453 472
 				// Don't overwrite the key column!
454
-				if ($id_group === 'col')
455
-					continue;
473
+				if ($id_group === 'col') {
474
+									continue;
475
+				}
456 476
 
457 477
 				$group_permissions = isset($groups[$id_group]) ? $groups[$id_group] : array();
458 478
 
@@ -474,16 +494,18 @@  discard block
 block discarded – undo
474 494
 				}
475 495
 
476 496
 				// Now actually make the data for the group look right.
477
-				if (empty($curData[$id_group]))
478
-					$curData[$id_group] = '<span class="red">' . $txt['board_perms_deny'] . '</span>';
479
-				elseif ($curData[$id_group] == 1)
480
-					$curData[$id_group] = '<span style="color: darkgreen;">' . $txt['board_perms_allow'] . '</span>';
481
-				else
482
-					$curData[$id_group] = 'x';
497
+				if (empty($curData[$id_group])) {
498
+									$curData[$id_group] = '<span class="red">' . $txt['board_perms_deny'] . '</span>';
499
+				} elseif ($curData[$id_group] == 1) {
500
+									$curData[$id_group] = '<span style="color: darkgreen;">' . $txt['board_perms_allow'] . '</span>';
501
+				} else {
502
+									$curData[$id_group] = 'x';
503
+				}
483 504
 
484 505
 				// Embolden those permissions different from global (makes it a lot easier!)
485
-				if (@$board_permissions[0][$id_group][$ID_PERM] != @$group_permissions[$ID_PERM])
486
-					$curData[$id_group] = '<strong>' . $curData[$id_group] . '</strong>';
506
+				if (@$board_permissions[0][$id_group][$ID_PERM] != @$group_permissions[$ID_PERM]) {
507
+									$curData[$id_group] = '<strong>' . $curData[$id_group] . '</strong>';
508
+				}
487 509
 			}
488 510
 
489 511
 			// Now add the data for this permission.
@@ -513,15 +535,17 @@  discard block
 block discarded – undo
513 535
 	);
514 536
 	while ($row = $smcFunc['db_fetch_assoc']($request))
515 537
 	{
516
-		if (trim($row['member_groups']) == '')
517
-			$groups = array(1);
518
-		else
519
-			$groups = array_merge(array(1), explode(',', $row['member_groups']));
538
+		if (trim($row['member_groups']) == '') {
539
+					$groups = array(1);
540
+		} else {
541
+					$groups = array_merge(array(1), explode(',', $row['member_groups']));
542
+		}
520 543
 
521
-		if (trim($row['deny_member_groups']) == '')
522
-			$denyGroups = array();
523
-		else
524
-			$denyGroups = explode(',', $row['deny_member_groups']);
544
+		if (trim($row['deny_member_groups']) == '') {
545
+					$denyGroups = array();
546
+		} else {
547
+					$denyGroups = explode(',', $row['deny_member_groups']);
548
+		}
525 549
 
526 550
 		$boards[$row['id_board']] = array(
527 551
 			'id' => $row['id_board'],
@@ -545,8 +569,9 @@  discard block
 block discarded – undo
545 569
 	);
546 570
 
547 571
 	// Add on the boards!
548
-	foreach ($boards as $board)
549
-		$mgSettings['board_' . $board['id']] = $board['name'];
572
+	foreach ($boards as $board) {
573
+			$mgSettings['board_' . $board['id']] = $board['name'];
574
+	}
550 575
 
551 576
 	// Add all the membergroup settings, plus we'll be adding in columns!
552 577
 	setKeys('cols', $mgSettings);
@@ -591,8 +616,9 @@  discard block
 block discarded – undo
591 616
 			'icons' => ''
592 617
 		),
593 618
 	);
594
-	while ($row = $smcFunc['db_fetch_assoc']($request))
595
-		$rows[] = $row;
619
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
620
+			$rows[] = $row;
621
+	}
596 622
 	$smcFunc['db_free_result']($request);
597 623
 
598 624
 	foreach ($rows as $row)
@@ -608,8 +634,9 @@  discard block
 block discarded – undo
608 634
 		);
609 635
 
610 636
 		// Board permissions.
611
-		foreach ($boards as $board)
612
-			$group['board_' . $board['id']] = in_array($row['id_group'], $board['groups']) ? '<span class="success">' . $txt['board_perms_allow'] . '</span>' : (!empty($modSettings['deny_boards_access']) && in_array($row['id_group'], $board['deny_groups']) ? '<span class="alert">' . $txt['board_perms_deny'] . '</span>' : 'x');
637
+		foreach ($boards as $board) {
638
+					$group['board_' . $board['id']] = in_array($row['id_group'], $board['groups']) ? '<span class="success">' . $txt['board_perms_allow'] . '</span>' : (!empty($modSettings['deny_boards_access']) && in_array($row['id_group'], $board['deny_groups']) ? '<span class="alert">' . $txt['board_perms_deny'] . '</span>' : 'x');
639
+		}
613 640
 
614 641
 		addData($group);
615 642
 	}
@@ -629,16 +656,18 @@  discard block
 block discarded – undo
629 656
 
630 657
 	if (isset($_REQUEST['groups']))
631 658
 	{
632
-		if (!is_array($_REQUEST['groups']))
633
-			$_REQUEST['groups'] = explode(',', $_REQUEST['groups']);
634
-		foreach ($_REQUEST['groups'] as $k => $dummy)
635
-			$_REQUEST['groups'][$k] = (int) $dummy;
659
+		if (!is_array($_REQUEST['groups'])) {
660
+					$_REQUEST['groups'] = explode(',', $_REQUEST['groups']);
661
+		}
662
+		foreach ($_REQUEST['groups'] as $k => $dummy) {
663
+					$_REQUEST['groups'][$k] = (int) $dummy;
664
+		}
636 665
 		$_REQUEST['groups'] = array_diff($_REQUEST['groups'], array(3));
637 666
 
638 667
 		$clause = 'id_group IN ({array_int:groups})';
668
+	} else {
669
+			$clause = 'id_group != {int:moderator_group}';
639 670
 	}
640
-	else
641
-		$clause = 'id_group != {int:moderator_group}';
642 671
 
643 672
 	// Get all the possible membergroups, except admin!
644 673
 	$request = $smcFunc['db_query']('', '
@@ -656,12 +685,14 @@  discard block
 block discarded – undo
656 685
 			'groups' => isset($_REQUEST['groups']) ? $_REQUEST['groups'] : array(),
657 686
 		)
658 687
 	);
659
-	if (!isset($_REQUEST['groups']) || in_array(-1, $_REQUEST['groups']) || in_array(0, $_REQUEST['groups']))
660
-		$groups = array('col' => '', -1 => $txt['membergroups_guests'], 0 => $txt['membergroups_members']);
661
-	else
662
-		$groups = array('col' => '');
663
-	while ($row = $smcFunc['db_fetch_assoc']($request))
664
-		$groups[$row['id_group']] = $row['group_name'];
688
+	if (!isset($_REQUEST['groups']) || in_array(-1, $_REQUEST['groups']) || in_array(0, $_REQUEST['groups'])) {
689
+			$groups = array('col' => '', -1 => $txt['membergroups_guests'], 0 => $txt['membergroups_members']);
690
+	} else {
691
+			$groups = array('col' => '');
692
+	}
693
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
694
+			$groups[$row['id_group']] = $row['group_name'];
695
+	}
665 696
 	$smcFunc['db_free_result']($request);
666 697
 
667 698
 	// Make sure that every group is represented!
@@ -685,8 +716,9 @@  discard block
 block discarded – undo
685 716
 		$disabled_permissions[] = 'calendar_edit_own';
686 717
 		$disabled_permissions[] = 'calendar_edit_any';
687 718
 	}
688
-	if (empty($modSettings['warning_settings']) || $modSettings['warning_settings'][0] == 0)
689
-		$disabled_permissions[] = 'issue_warning';
719
+	if (empty($modSettings['warning_settings']) || $modSettings['warning_settings'][0] == 0) {
720
+			$disabled_permissions[] = 'issue_warning';
721
+	}
690 722
 
691 723
 	call_integration_hook('integrate_reports_groupperm', array(&$disabled_permissions));
692 724
 
@@ -707,15 +739,17 @@  discard block
 block discarded – undo
707 739
 	$curData = array();
708 740
 	while ($row = $smcFunc['db_fetch_assoc']($request))
709 741
 	{
710
-		if (in_array($row['permission'], $disabled_permissions))
711
-			continue;
742
+		if (in_array($row['permission'], $disabled_permissions)) {
743
+					continue;
744
+		}
712 745
 
713 746
 		// If this is a new permission flush the last row.
714 747
 		if ($row['permission'] != $lastPermission)
715 748
 		{
716 749
 			// Send the data!
717
-			if ($lastPermission !== null)
718
-				addData($curData);
750
+			if ($lastPermission !== null) {
751
+							addData($curData);
752
+			}
719 753
 
720 754
 			// Add the permission name in the left column.
721 755
 			$curData = array('col' => isset($txt['group_perms_name_' . $row['permission']]) ? $txt['group_perms_name_' . $row['permission']] : $row['permission']);
@@ -724,10 +758,11 @@  discard block
 block discarded – undo
724 758
 		}
725 759
 
726 760
 		// Good stuff - add the permission to the list!
727
-		if ($row['add_deny'])
728
-			$curData[$row['id_group']] = '<span style="color: darkgreen;">' . $txt['board_perms_allow'] . '</span>';
729
-		else
730
-			$curData[$row['id_group']] = '<span class="red">' . $txt['board_perms_deny'] . '</span>';
761
+		if ($row['add_deny']) {
762
+					$curData[$row['id_group']] = '<span style="color: darkgreen;">' . $txt['board_perms_allow'] . '</span>';
763
+		} else {
764
+					$curData[$row['id_group']] = '<span class="red">' . $txt['board_perms_deny'] . '</span>';
765
+		}
731 766
 	}
732 767
 	$smcFunc['db_free_result']($request);
733 768
 
@@ -757,8 +792,9 @@  discard block
 block discarded – undo
757 792
 		)
758 793
 	);
759 794
 	$boards = array();
760
-	while ($row = $smcFunc['db_fetch_assoc']($request))
761
-		$boards[$row['id_board']] = $row['name'];
795
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
796
+			$boards[$row['id_board']] = $row['name'];
797
+	}
762 798
 	$smcFunc['db_free_result']($request);
763 799
 
764 800
 	// Get every moderator.
@@ -790,12 +826,14 @@  discard block
 block discarded – undo
790 826
 	while ($row = $smcFunc['db_fetch_assoc']($request))
791 827
 	{
792 828
 		// Either we don't have them as a moderator at all or at least not as a moderator of this board
793
-		if (!array_key_exists($row['id_member'], $moderators) || !in_array($row['id_board'], $moderators[$row['id_member']]))
794
-			$moderators[$row['id_member']][] = $row['id_board'];
829
+		if (!array_key_exists($row['id_member'], $moderators) || !in_array($row['id_board'], $moderators[$row['id_member']])) {
830
+					$moderators[$row['id_member']][] = $row['id_board'];
831
+		}
795 832
 
796 833
 		// We don't have them listed as a moderator yet
797
-		if (!array_key_exists($row['id_member'], $local_mods))
798
-			$local_mods[$row['id_member']] = $row['id_member'];
834
+		if (!array_key_exists($row['id_member'], $local_mods)) {
835
+					$local_mods[$row['id_member']] = $row['id_member'];
836
+		}
799 837
 	}
800 838
 
801 839
 	// Get a list of global moderators (i.e. members with moderation powers).
@@ -808,8 +846,9 @@  discard block
 block discarded – undo
808 846
 	$allStaff = array_unique($allStaff);
809 847
 
810 848
 	// This is a bit of a cop out - but we're protecting their forum, really!
811
-	if (count($allStaff) > 300)
812
-		fatal_lang_error('report_error_too_many_staff');
849
+	if (count($allStaff) > 300) {
850
+			fatal_lang_error('report_error_too_many_staff');
851
+	}
813 852
 
814 853
 	// Get all the possible membergroups!
815 854
 	$request = $smcFunc['db_query']('', '
@@ -819,8 +858,9 @@  discard block
 block discarded – undo
819 858
 		)
820 859
 	);
821 860
 	$groups = array(0 => $txt['full_member']);
822
-	while ($row = $smcFunc['db_fetch_assoc']($request))
823
-		$groups[$row['id_group']] = empty($row['online_color']) ? $row['group_name'] : '<span style="color: ' . $row['online_color'] . '">' . $row['group_name'] . '</span>';
861
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
862
+			$groups[$row['id_group']] = empty($row['online_color']) ? $row['group_name'] : '<span style="color: ' . $row['online_color'] . '">' . $row['group_name'] . '</span>';
863
+	}
824 864
 	$smcFunc['db_free_result']($request);
825 865
 
826 866
 	// All the fields we'll show.
@@ -861,19 +901,20 @@  discard block
 block discarded – undo
861 901
 		);
862 902
 
863 903
 		// What do they moderate?
864
-		if (in_array($row['id_member'], $global_mods))
865
-			$staffData['moderates'] = '<em>' . $txt['report_staff_all_boards'] . '</em>';
866
-		elseif (isset($moderators[$row['id_member']]))
904
+		if (in_array($row['id_member'], $global_mods)) {
905
+					$staffData['moderates'] = '<em>' . $txt['report_staff_all_boards'] . '</em>';
906
+		} elseif (isset($moderators[$row['id_member']]))
867 907
 		{
868 908
 			// Get the names
869
-			foreach ($moderators[$row['id_member']] as $board)
870
-				if (isset($boards[$board]))
909
+			foreach ($moderators[$row['id_member']] as $board) {
910
+							if (isset($boards[$board]))
871 911
 					$staffData['moderates'][] = $boards[$board];
912
+			}
872 913
 
873 914
 			$staffData['moderates'] = implode(', ', $staffData['moderates']);
915
+		} else {
916
+					$staffData['moderates'] = '<em>' . $txt['report_staff_no_boards'] . '</em>';
874 917
 		}
875
-		else
876
-			$staffData['moderates'] = '<em>' . $txt['report_staff_no_boards'] . '</em>';
877 918
 
878 919
 		// Next add the main data.
879 920
 		addData($staffData);
@@ -901,8 +942,9 @@  discard block
 block discarded – undo
901 942
 	global $context;
902 943
 
903 944
 	// Set the table count if needed.
904
-	if (empty($context['table_count']))
905
-		$context['table_count'] = 0;
945
+	if (empty($context['table_count'])) {
946
+			$context['table_count'] = 0;
947
+	}
906 948
 
907 949
 	// Create the table!
908 950
 	$context['tables'][$context['table_count']] = array(
@@ -952,16 +994,18 @@  discard block
 block discarded – undo
952 994
 	global $context;
953 995
 
954 996
 	// No tables? Create one even though we are probably already in a bad state!
955
-	if (empty($context['table_count']))
956
-		newTable();
997
+	if (empty($context['table_count'])) {
998
+			newTable();
999
+	}
957 1000
 
958 1001
 	// Specific table?
959
-	if ($custom_table !== null && !isset($context['tables'][$custom_table]))
960
-		return false;
961
-	elseif ($custom_table !== null)
962
-		$table = $custom_table;
963
-	else
964
-		$table = $context['current_table'];
1002
+	if ($custom_table !== null && !isset($context['tables'][$custom_table])) {
1003
+			return false;
1004
+	} elseif ($custom_table !== null) {
1005
+			$table = $custom_table;
1006
+	} else {
1007
+			$table = $context['current_table'];
1008
+	}
965 1009
 
966 1010
 	// If we have keys, sanitise the data...
967 1011
 	if (!empty($context['keys']))
@@ -973,11 +1017,11 @@  discard block
 block discarded – undo
973 1017
 				'v' => empty($inc_data[$key]) ? $context['tables'][$table]['default_value'] : $inc_data[$key],
974 1018
 			);
975 1019
 			// Special "hack" the adding separators when doing data by column.
976
-			if (substr($key, 0, 5) == '#sep#')
977
-				$data[$key]['separator'] = true;
1020
+			if (substr($key, 0, 5) == '#sep#') {
1021
+							$data[$key]['separator'] = true;
1022
+			}
978 1023
 		}
979
-	}
980
-	else
1024
+	} else
981 1025
 	{
982 1026
 		$data = $inc_data;
983 1027
 		foreach ($data as $key => $value)
@@ -985,8 +1029,9 @@  discard block
 block discarded – undo
985 1029
 			$data[$key] = array(
986 1030
 				'v' => $value,
987 1031
 			);
988
-			if (substr($key, 0, 5) == '#sep#')
989
-				$data[$key]['separator'] = true;
1032
+			if (substr($key, 0, 5) == '#sep#') {
1033
+							$data[$key]['separator'] = true;
1034
+			}
990 1035
 		}
991 1036
 	}
992 1037
 
@@ -999,8 +1044,9 @@  discard block
 block discarded – undo
999 1044
 	// Otherwise, tricky!
1000 1045
 	else
1001 1046
 	{
1002
-		foreach ($data as $key => $item)
1003
-			$context['tables'][$table]['data'][$key][] = $item;
1047
+		foreach ($data as $key => $item) {
1048
+					$context['tables'][$table]['data'][$key][] = $item;
1049
+		}
1004 1050
 	}
1005 1051
 }
1006 1052
 
@@ -1017,16 +1063,18 @@  discard block
 block discarded – undo
1017 1063
 	global $context;
1018 1064
 
1019 1065
 	// No tables - return?
1020
-	if (empty($context['table_count']))
1021
-		return;
1066
+	if (empty($context['table_count'])) {
1067
+			return;
1068
+	}
1022 1069
 
1023 1070
 	// Specific table?
1024
-	if ($custom_table !== null && !isset($context['tables'][$table]))
1025
-		return false;
1026
-	elseif ($custom_table !== null)
1027
-		$table = $custom_table;
1028
-	else
1029
-		$table = $context['current_table'];
1071
+	if ($custom_table !== null && !isset($context['tables'][$table])) {
1072
+			return false;
1073
+	} elseif ($custom_table !== null) {
1074
+			$table = $custom_table;
1075
+	} else {
1076
+			$table = $context['current_table'];
1077
+	}
1030 1078
 
1031 1079
 	// Plumb in the separator
1032 1080
 	$context['tables'][$table]['data'][] = array(0 => array(
@@ -1047,8 +1095,9 @@  discard block
 block discarded – undo
1047 1095
 {
1048 1096
 	global $context;
1049 1097
 
1050
-	if (empty($context['tables']))
1051
-		return;
1098
+	if (empty($context['tables'])) {
1099
+			return;
1100
+	}
1052 1101
 
1053 1102
 	// Loop through each table counting up some basic values, to help with the templating.
1054 1103
 	foreach ($context['tables'] as $id => $table)
@@ -1059,12 +1108,13 @@  discard block
 block discarded – undo
1059 1108
 		$context['tables'][$id]['column_count'] = count($curElement);
1060 1109
 
1061 1110
 		// Work out the rough width - for templates like the print template. Without this we might get funny tables.
1062
-		if ($table['shading']['left'] && $table['width']['shaded'] != 'auto' && $table['width']['normal'] != 'auto')
1063
-			$context['tables'][$id]['max_width'] = $table['width']['shaded'] + ($context['tables'][$id]['column_count'] - 1) * $table['width']['normal'];
1064
-		elseif ($table['width']['normal'] != 'auto')
1065
-			$context['tables'][$id]['max_width'] = $context['tables'][$id]['column_count'] * $table['width']['normal'];
1066
-		else
1067
-			$context['tables'][$id]['max_width'] = 'auto';
1111
+		if ($table['shading']['left'] && $table['width']['shaded'] != 'auto' && $table['width']['normal'] != 'auto') {
1112
+					$context['tables'][$id]['max_width'] = $table['width']['shaded'] + ($context['tables'][$id]['column_count'] - 1) * $table['width']['normal'];
1113
+		} elseif ($table['width']['normal'] != 'auto') {
1114
+					$context['tables'][$id]['max_width'] = $context['tables'][$id]['column_count'] * $table['width']['normal'];
1115
+		} else {
1116
+					$context['tables'][$id]['max_width'] = 'auto';
1117
+		}
1068 1118
 	}
1069 1119
 }
1070 1120
 
@@ -1089,10 +1139,11 @@  discard block
 block discarded – undo
1089 1139
 	global $context;
1090 1140
 
1091 1141
 	// Do we want to use the keys of the keys as the keys? :P
1092
-	if ($reverse)
1093
-		$context['keys'] = array_flip($keys);
1094
-	else
1095
-		$context['keys'] = $keys;
1142
+	if ($reverse) {
1143
+			$context['keys'] = array_flip($keys);
1144
+	} else {
1145
+			$context['keys'] = $keys;
1146
+	}
1096 1147
 
1097 1148
 	// Rows or columns?
1098 1149
 	$context['key_method'] = $method == 'rows' ? 'rows' : 'cols';
Please login to merge, or discard this patch.
Sources/ScheduledTasks.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -807,7 +807,7 @@
 block discarded – undo
807 807
 /**
808 808
  * Send a group of emails from the mail queue.
809 809
  *
810
- * @param bool|int $number The number to send each loop through or false to use the standard limits
810
+ * @param integer $number The number to send each loop through or false to use the standard limits
811 811
  * @param bool $override_limit Whether to bypass the limit
812 812
  * @param bool $force_send Whether to forcibly send the messages now (useful when using cron jobs)
813 813
  * @return bool Whether things were sent
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -384,7 +384,7 @@
 block discarded – undo
384 384
 	clean_cache();
385 385
 
386 386
 	// If warning decrement is enabled and we have people who have not had a new warning in 24 hours, lower their warning level.
387
-	list (, , $modSettings['warning_decrement']) = explode(',', $modSettings['warning_settings']);
387
+	list (,, $modSettings['warning_decrement']) = explode(',', $modSettings['warning_settings']);
388 388
 	if ($modSettings['warning_decrement'])
389 389
 	{
390 390
 		// Find every member who has a warning level...
Please login to merge, or discard this patch.
Braces   +280 added lines, -203 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * This function works out what to do!
@@ -24,9 +25,9 @@  discard block
 block discarded – undo
24 25
 	global $time_start, $smcFunc;
25 26
 
26 27
 	// Special case for doing the mail queue.
27
-	if (isset($_GET['scheduled']) && $_GET['scheduled'] == 'mailq')
28
-		ReduceMailQueue();
29
-	else
28
+	if (isset($_GET['scheduled']) && $_GET['scheduled'] == 'mailq') {
29
+			ReduceMailQueue();
30
+	} else
30 31
 	{
31 32
 		$task_string = '';
32 33
 
@@ -53,18 +54,20 @@  discard block
 block discarded – undo
53 54
 
54 55
 			// How long in seconds it the gap?
55 56
 			$duration = $row['time_regularity'];
56
-			if ($row['time_unit'] == 'm')
57
-				$duration *= 60;
58
-			elseif ($row['time_unit'] == 'h')
59
-				$duration *= 3600;
60
-			elseif ($row['time_unit'] == 'd')
61
-				$duration *= 86400;
62
-			elseif ($row['time_unit'] == 'w')
63
-				$duration *= 604800;
57
+			if ($row['time_unit'] == 'm') {
58
+							$duration *= 60;
59
+			} elseif ($row['time_unit'] == 'h') {
60
+							$duration *= 3600;
61
+			} elseif ($row['time_unit'] == 'd') {
62
+							$duration *= 86400;
63
+			} elseif ($row['time_unit'] == 'w') {
64
+							$duration *= 604800;
65
+			}
64 66
 
65 67
 			// If we were really late running this task actually skip the next one.
66
-			if (time() + ($duration / 2) > $next_time)
67
-				$next_time += $duration;
68
+			if (time() + ($duration / 2) > $next_time) {
69
+							$next_time += $duration;
70
+			}
68 71
 
69 72
 			// Update it now, so no others run this!
70 73
 			$smcFunc['db_query']('', '
@@ -81,16 +84,19 @@  discard block
 block discarded – undo
81 84
 			$affected_rows = $smcFunc['db_affected_rows']();
82 85
 
83 86
 			// What kind of task are we handling?
84
-			if (!empty($row['callable']))
85
-				$task_string = $row['callable'];
87
+			if (!empty($row['callable'])) {
88
+							$task_string = $row['callable'];
89
+			}
86 90
 
87 91
 			// Default SMF task or old mods?
88
-			elseif (function_exists('scheduled_' . $row['task']))
89
-				$task_string = 'scheduled_' . $row['task'];
92
+			elseif (function_exists('scheduled_' . $row['task'])) {
93
+							$task_string = 'scheduled_' . $row['task'];
94
+			}
90 95
 
91 96
 			// One last resource, the task name.
92
-			elseif (!empty($row['task']))
93
-				$task_string = $row['task'];
97
+			elseif (!empty($row['task'])) {
98
+							$task_string = $row['task'];
99
+			}
94 100
 
95 101
 			// The function must exist or we are wasting our time, plus do some timestamp checking, and database check!
96 102
 			if (!empty($task_string) && (!isset($_GET['ts']) || $_GET['ts'] == $row['next_time']) && $affected_rows)
@@ -101,11 +107,11 @@  discard block
 block discarded – undo
101 107
 				$callable_task = call_helper($task_string, true);
102 108
 
103 109
 				// Perform the task.
104
-				if (!empty($callable_task))
105
-					$completed = call_user_func($callable_task);
106
-
107
-				else
108
-					$completed = false;
110
+				if (!empty($callable_task)) {
111
+									$completed = call_user_func($callable_task);
112
+				} else {
113
+									$completed = false;
114
+				}
109 115
 
110 116
 				// Log that we did it ;)
111 117
 				if ($completed)
@@ -138,18 +144,20 @@  discard block
 block discarded – undo
138 144
 			)
139 145
 		);
140 146
 		// No new task scheduled yet?
141
-		if ($smcFunc['db_num_rows']($request) === 0)
142
-			$nextEvent = time() + 86400;
143
-		else
144
-			list ($nextEvent) = $smcFunc['db_fetch_row']($request);
147
+		if ($smcFunc['db_num_rows']($request) === 0) {
148
+					$nextEvent = time() + 86400;
149
+		} else {
150
+					list ($nextEvent) = $smcFunc['db_fetch_row']($request);
151
+		}
145 152
 		$smcFunc['db_free_result']($request);
146 153
 
147 154
 		updateSettings(array('next_task_time' => $nextEvent));
148 155
 	}
149 156
 
150 157
 	// Shall we return?
151
-	if (!isset($_GET['scheduled']))
152
-		return true;
158
+	if (!isset($_GET['scheduled'])) {
159
+			return true;
160
+	}
153 161
 
154 162
 	// Finally, send some stuff...
155 163
 	header('expires: Mon, 26 Jul 1997 05:00:00 GMT');
@@ -181,16 +189,18 @@  discard block
 block discarded – undo
181 189
 	while ($row = $smcFunc['db_fetch_assoc']($request))
182 190
 	{
183 191
 		// If this is no longer around we'll ignore it.
184
-		if (empty($row['id_topic']))
185
-			continue;
192
+		if (empty($row['id_topic'])) {
193
+					continue;
194
+		}
186 195
 
187 196
 		// What type is it?
188
-		if ($row['id_first_msg'] && $row['id_first_msg'] == $row['id_msg'])
189
-			$type = 'topic';
190
-		elseif ($row['id_attach'])
191
-			$type = 'attach';
192
-		else
193
-			$type = 'msg';
197
+		if ($row['id_first_msg'] && $row['id_first_msg'] == $row['id_msg']) {
198
+					$type = 'topic';
199
+		} elseif ($row['id_attach']) {
200
+					$type = 'attach';
201
+		} else {
202
+					$type = 'msg';
203
+		}
194 204
 
195 205
 		// Add it to the array otherwise.
196 206
 		$notices[$row['id_board']][$type][] = array(
@@ -211,8 +221,9 @@  discard block
 block discarded – undo
211 221
 	);
212 222
 
213 223
 	// If nothing quit now.
214
-	if (empty($notices))
215
-		return true;
224
+	if (empty($notices)) {
225
+			return true;
226
+	}
216 227
 
217 228
 	// Now we need to think about finding out *who* can approve - this is hard!
218 229
 
@@ -231,14 +242,16 @@  discard block
 block discarded – undo
231 242
 	while ($row = $smcFunc['db_fetch_assoc']($request))
232 243
 	{
233 244
 		// Sorry guys, but we have to ignore guests AND members - it would be too many otherwise.
234
-		if ($row['id_group'] < 2)
235
-			continue;
245
+		if ($row['id_group'] < 2) {
246
+					continue;
247
+		}
236 248
 
237 249
 		$perms[$row['id_profile']][$row['add_deny'] ? 'add' : 'deny'][] = $row['id_group'];
238 250
 
239 251
 		// Anyone who can access has to be considered.
240
-		if ($row['add_deny'])
241
-			$addGroups[] = $row['id_group'];
252
+		if ($row['add_deny']) {
253
+					$addGroups[] = $row['id_group'];
254
+		}
242 255
 	}
243 256
 	$smcFunc['db_free_result']($request);
244 257
 
@@ -283,8 +296,9 @@  discard block
 block discarded – undo
283 296
 		if (!empty($row['mod_prefs']))
284 297
 		{
285 298
 			list(,, $pref_binary) = explode('|', $row['mod_prefs']);
286
-			if (!($pref_binary & 4))
287
-				continue;
299
+			if (!($pref_binary & 4)) {
300
+							continue;
301
+			}
288 302
 		}
289 303
 
290 304
 		$members[$row['id_member']] = array(
@@ -309,8 +323,9 @@  discard block
 block discarded – undo
309 323
 		$emailbody = '';
310 324
 
311 325
 		// Load the language file as required.
312
-		if (empty($current_language) || $current_language != $member['language'])
313
-			$current_language = loadLanguage('EmailTemplates', $member['language'], false);
326
+		if (empty($current_language) || $current_language != $member['language']) {
327
+					$current_language = loadLanguage('EmailTemplates', $member['language'], false);
328
+		}
314 329
 
315 330
 		// Loop through each notice...
316 331
 		foreach ($notices as $board => $notice)
@@ -318,29 +333,34 @@  discard block
 block discarded – undo
318 333
 			$access = false;
319 334
 
320 335
 			// Can they mod in this board?
321
-			if (isset($mods[$id][$board]))
322
-				$access = true;
336
+			if (isset($mods[$id][$board])) {
337
+							$access = true;
338
+			}
323 339
 
324 340
 			// Do the group check...
325 341
 			if (!$access && isset($perms[$profiles[$board]]['add']))
326 342
 			{
327 343
 				// They can access?!
328
-				if (array_intersect($perms[$profiles[$board]]['add'], $member['groups']))
329
-					$access = true;
344
+				if (array_intersect($perms[$profiles[$board]]['add'], $member['groups'])) {
345
+									$access = true;
346
+				}
330 347
 
331 348
 				// If they have deny rights don't consider them!
332
-				if (isset($perms[$profiles[$board]]['deny']))
333
-					if (array_intersect($perms[$profiles[$board]]['deny'], $member['groups']))
349
+				if (isset($perms[$profiles[$board]]['deny'])) {
350
+									if (array_intersect($perms[$profiles[$board]]['deny'], $member['groups']))
334 351
 						$access = false;
352
+				}
335 353
 			}
336 354
 
337 355
 			// Finally, fix it for admins!
338
-			if (in_array(1, $member['groups']))
339
-				$access = true;
356
+			if (in_array(1, $member['groups'])) {
357
+							$access = true;
358
+			}
340 359
 
341 360
 			// If they can't access it then give it a break!
342
-			if (!$access)
343
-				continue;
361
+			if (!$access) {
362
+							continue;
363
+			}
344 364
 
345 365
 			foreach ($notice as $type => $items)
346 366
 			{
@@ -348,15 +368,17 @@  discard block
 block discarded – undo
348 368
 				$emailbody .= $txt['scheduled_approval_email_' . $type] . "\n" .
349 369
 					'------------------------------------------------------' . "\n";
350 370
 
351
-				foreach ($items as $item)
352
-					$emailbody .= $item['subject'] . ' - ' . $item['href'] . "\n";
371
+				foreach ($items as $item) {
372
+									$emailbody .= $item['subject'] . ' - ' . $item['href'] . "\n";
373
+				}
353 374
 
354 375
 				$emailbody .= "\n";
355 376
 			}
356 377
 		}
357 378
 
358
-		if ($emailbody == '')
359
-			continue;
379
+		if ($emailbody == '') {
380
+					continue;
381
+		}
360 382
 
361 383
 		$replacements = array(
362 384
 			'REALNAME' => $member['name'],
@@ -397,8 +419,9 @@  discard block
 block discarded – undo
397 419
 			)
398 420
 		);
399 421
 		$members = array();
400
-		while ($row = $smcFunc['db_fetch_assoc']($request))
401
-			$members[$row['id_member']] = $row['warning'];
422
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
423
+					$members[$row['id_member']] = $row['warning'];
424
+		}
402 425
 		$smcFunc['db_free_result']($request);
403 426
 
404 427
 		// Have some members to check?
@@ -420,17 +443,18 @@  discard block
 block discarded – undo
420 443
 			while ($row = $smcFunc['db_fetch_assoc']($request))
421 444
 			{
422 445
 				// More than 24 hours ago?
423
-				if ($row['last_warning'] <= time() - 86400)
424
-					$member_changes[] = array(
446
+				if ($row['last_warning'] <= time() - 86400) {
447
+									$member_changes[] = array(
425 448
 						'id' => $row['id_recipient'],
426 449
 						'warning' => $members[$row['id_recipient']] >= $modSettings['warning_decrement'] ? $members[$row['id_recipient']] - $modSettings['warning_decrement'] : 0,
427 450
 					);
451
+				}
428 452
 			}
429 453
 			$smcFunc['db_free_result']($request);
430 454
 
431 455
 			// Have some members to change?
432
-			if (!empty($member_changes))
433
-				foreach ($member_changes as $change)
456
+			if (!empty($member_changes)) {
457
+							foreach ($member_changes as $change)
434 458
 					$smcFunc['db_query']('', '
435 459
 						UPDATE {db_prefix}members
436 460
 						SET warning = {int:warning}
@@ -440,6 +464,7 @@  discard block
 block discarded – undo
440 464
 							'id_member' => $change['id'],
441 465
 						)
442 466
 					);
467
+			}
443 468
 		}
444 469
 	}
445 470
 
@@ -519,15 +544,17 @@  discard block
 block discarded – undo
519 544
 
520 545
 		// Store this useful data!
521 546
 		$boards[$row['id_board']] = $row['id_board'];
522
-		if ($row['id_topic'])
523
-			$notify['topics'][$row['id_topic']][] = $row['id_member'];
524
-		else
525
-			$notify['boards'][$row['id_board']][] = $row['id_member'];
547
+		if ($row['id_topic']) {
548
+					$notify['topics'][$row['id_topic']][] = $row['id_member'];
549
+		} else {
550
+					$notify['boards'][$row['id_board']][] = $row['id_member'];
551
+		}
526 552
 	}
527 553
 	$smcFunc['db_free_result']($request);
528 554
 
529
-	if (empty($boards))
530
-		return true;
555
+	if (empty($boards)) {
556
+			return true;
557
+	}
531 558
 
532 559
 	// Just get the board names.
533 560
 	$request = $smcFunc['db_query']('', '
@@ -539,12 +566,14 @@  discard block
 block discarded – undo
539 566
 		)
540 567
 	);
541 568
 	$boards = array();
542
-	while ($row = $smcFunc['db_fetch_assoc']($request))
543
-		$boards[$row['id_board']] = $row['name'];
569
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
570
+			$boards[$row['id_board']] = $row['name'];
571
+	}
544 572
 	$smcFunc['db_free_result']($request);
545 573
 
546
-	if (empty($boards))
547
-		return true;
574
+	if (empty($boards)) {
575
+			return true;
576
+	}
548 577
 
549 578
 	// Get the actual topics...
550 579
 	$request = $smcFunc['db_query']('', '
@@ -564,52 +593,57 @@  discard block
 block discarded – undo
564 593
 	$types = array();
565 594
 	while ($row = $smcFunc['db_fetch_assoc']($request))
566 595
 	{
567
-		if (!isset($types[$row['note_type']][$row['id_board']]))
568
-			$types[$row['note_type']][$row['id_board']] = array(
596
+		if (!isset($types[$row['note_type']][$row['id_board']])) {
597
+					$types[$row['note_type']][$row['id_board']] = array(
569 598
 				'lines' => array(),
570 599
 				'name' => $row['board_name'],
571 600
 				'id' => $row['id_board'],
572 601
 			);
602
+		}
573 603
 
574 604
 		if ($row['note_type'] == 'reply')
575 605
 		{
576
-			if (isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]))
577
-				$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['count']++;
578
-			else
579
-				$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array(
606
+			if (isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) {
607
+							$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['count']++;
608
+			} else {
609
+							$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array(
580 610
 					'id' => $row['id_topic'],
581 611
 					'subject' => un_htmlspecialchars($row['subject']),
582 612
 					'count' => 1,
583 613
 				);
584
-		}
585
-		elseif ($row['note_type'] == 'topic')
614
+			}
615
+		} elseif ($row['note_type'] == 'topic')
586 616
 		{
587
-			if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]))
588
-				$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array(
617
+			if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) {
618
+							$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array(
589 619
 					'id' => $row['id_topic'],
590 620
 					'subject' => un_htmlspecialchars($row['subject']),
591 621
 				);
592
-		}
593
-		else
622
+			}
623
+		} else
594 624
 		{
595
-			if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]))
596
-				$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array(
625
+			if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) {
626
+							$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array(
597 627
 					'id' => $row['id_topic'],
598 628
 					'subject' => un_htmlspecialchars($row['subject']),
599 629
 					'starter' => $row['id_member_started'],
600 630
 				);
631
+			}
601 632
 		}
602 633
 
603 634
 		$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array();
604
-		if (!empty($notify['topics'][$row['id_topic']]))
605
-			$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['topics'][$row['id_topic']]);
606
-		if (!empty($notify['boards'][$row['id_board']]))
607
-			$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['boards'][$row['id_board']]);
635
+		if (!empty($notify['topics'][$row['id_topic']])) {
636
+					$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['topics'][$row['id_topic']]);
637
+		}
638
+		if (!empty($notify['boards'][$row['id_board']])) {
639
+					$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['boards'][$row['id_board']]);
640
+		}
608 641
 	}
609 642
 	$smcFunc['db_free_result']($request);
610 643
 
611
-	if (empty($types))
612
-		return true;
644
+	if (empty($types)) {
645
+			return true;
646
+	}
613 647
 
614 648
 	// Let's load all the languages into a cache thingy.
615 649
 	$langtxt = array();
@@ -651,8 +685,9 @@  discard block
 block discarded – undo
651 685
 		$notify_types = !empty($prefs[$mid]['msg_notify_type']) ? $prefs[$mid]['msg_notify_type'] : 1;
652 686
 
653 687
 		// Did they not elect to choose this?
654
-		if ($frequency < 3 || $frequency == 4 && !$is_weekly || $frequency == 3 && $is_weekly || $notify_types == 4)
655
-			continue;
688
+		if ($frequency < 3 || $frequency == 4 && !$is_weekly || $frequency == 3 && $is_weekly || $notify_types == 4) {
689
+					continue;
690
+		}
656 691
 
657 692
 		// Right character set!
658 693
 		$context['character_set'] = empty($modSettings['global_character_set']) ? $langtxt[$lang]['char_set'] : $modSettings['global_character_set'];
@@ -668,39 +703,43 @@  discard block
 block discarded – undo
668 703
 		if (isset($types['topic']))
669 704
 		{
670 705
 			$titled = false;
671
-			foreach ($types['topic'] as $id => $board)
672
-				foreach ($board['lines'] as $topic)
706
+			foreach ($types['topic'] as $id => $board) {
707
+							foreach ($board['lines'] as $topic)
673 708
 					if (in_array($mid, $topic['members']))
674 709
 					{
675 710
 						if (!$titled)
676 711
 						{
677 712
 							$email['body'] .= "\n" . $langtxt[$lang]['new_topics'] . ':' . "\n" . '-----------------------------------------------';
713
+			}
678 714
 							$titled = true;
679 715
 						}
680 716
 						$email['body'] .= "\n" . sprintf($langtxt[$lang]['topic_lines'], $topic['subject'], $board['name']);
681 717
 					}
682
-			if ($titled)
683
-				$email['body'] .= "\n";
718
+			if ($titled) {
719
+							$email['body'] .= "\n";
720
+			}
684 721
 		}
685 722
 
686 723
 		// What about replies?
687 724
 		if (isset($types['reply']))
688 725
 		{
689 726
 			$titled = false;
690
-			foreach ($types['reply'] as $id => $board)
691
-				foreach ($board['lines'] as $topic)
727
+			foreach ($types['reply'] as $id => $board) {
728
+							foreach ($board['lines'] as $topic)
692 729
 					if (in_array($mid, $topic['members']))
693 730
 					{
694 731
 						if (!$titled)
695 732
 						{
696 733
 							$email['body'] .= "\n" . $langtxt[$lang]['new_replies'] . ':' . "\n" . '-----------------------------------------------';
734
+			}
697 735
 							$titled = true;
698 736
 						}
699 737
 						$email['body'] .= "\n" . ($topic['count'] == 1 ? sprintf($langtxt[$lang]['replies_one'], $topic['subject']) : sprintf($langtxt[$lang]['replies_many'], $topic['count'], $topic['subject']));
700 738
 					}
701 739
 
702
-			if ($titled)
703
-				$email['body'] .= "\n";
740
+			if ($titled) {
741
+							$email['body'] .= "\n";
742
+			}
704 743
 		}
705 744
 
706 745
 		// Finally, moderation actions!
@@ -709,24 +748,27 @@  discard block
 block discarded – undo
709 748
 			$titled = false;
710 749
 			foreach ($types as $note_type => $type)
711 750
 			{
712
-				if ($note_type == 'topic' || $note_type == 'reply')
713
-					continue;
751
+				if ($note_type == 'topic' || $note_type == 'reply') {
752
+									continue;
753
+				}
714 754
 
715
-				foreach ($type as $id => $board)
716
-					foreach ($board['lines'] as $topic)
755
+				foreach ($type as $id => $board) {
756
+									foreach ($board['lines'] as $topic)
717 757
 						if (in_array($mid, $topic['members']))
718 758
 						{
719 759
 							if (!$titled)
720 760
 							{
721 761
 								$email['body'] .= "\n" . $langtxt[$lang]['mod_actions'] . ':' . "\n" . '-----------------------------------------------';
762
+				}
722 763
 								$titled = true;
723 764
 							}
724 765
 							$email['body'] .= "\n" . sprintf($langtxt[$lang][$note_type], $topic['subject']);
725 766
 						}
726 767
 			}
727 768
 		}
728
-		if ($titled)
729
-			$email['body'] .= "\n";
769
+		if ($titled) {
770
+					$email['body'] .= "\n";
771
+		}
730 772
 
731 773
 		// Then just say our goodbyes!
732 774
 		$email['body'] .= "\n\n" . $txt['regards_team'];
@@ -756,8 +798,7 @@  discard block
 block discarded – undo
756 798
 				'not_daily' => 0,
757 799
 			)
758 800
 		);
759
-	}
760
-	else
801
+	} else
761 802
 	{
762 803
 		// Clear any only weekly ones, and stop us from sending daily again.
763 804
 		$smcFunc['db_query']('', '
@@ -821,16 +862,19 @@  discard block
 block discarded – undo
821 862
 	global $modSettings, $smcFunc, $sourcedir;
822 863
 
823 864
 	// Are we intending another script to be sending out the queue?
824
-	if (!empty($modSettings['mail_queue_use_cron']) && empty($force_send))
825
-		return false;
865
+	if (!empty($modSettings['mail_queue_use_cron']) && empty($force_send)) {
866
+			return false;
867
+	}
826 868
 
827 869
 	// By default send 5 at once.
828
-	if (!$number)
829
-		$number = empty($modSettings['mail_quantity']) ? 5 : $modSettings['mail_quantity'];
870
+	if (!$number) {
871
+			$number = empty($modSettings['mail_quantity']) ? 5 : $modSettings['mail_quantity'];
872
+	}
830 873
 
831 874
 	// If we came with a timestamp, and that doesn't match the next event, then someone else has beaten us.
832
-	if (isset($_GET['ts']) && $_GET['ts'] != $modSettings['mail_next_send'] && empty($force_send))
833
-		return false;
875
+	if (isset($_GET['ts']) && $_GET['ts'] != $modSettings['mail_next_send'] && empty($force_send)) {
876
+			return false;
877
+	}
834 878
 
835 879
 	// By default move the next sending on by 10 seconds, and require an affected row.
836 880
 	if (!$override_limit)
@@ -847,8 +891,9 @@  discard block
 block discarded – undo
847 891
 				'last_send' => $modSettings['mail_next_send'],
848 892
 			)
849 893
 		);
850
-		if ($smcFunc['db_affected_rows']() == 0)
851
-			return false;
894
+		if ($smcFunc['db_affected_rows']() == 0) {
895
+					return false;
896
+		}
852 897
 		$modSettings['mail_next_send'] = time() + $delay;
853 898
 	}
854 899
 
@@ -869,8 +914,9 @@  discard block
 block discarded – undo
869 914
 			$mn += $number;
870 915
 		}
871 916
 		// No more I'm afraid, return!
872
-		else
873
-			return false;
917
+		else {
918
+					return false;
919
+		}
874 920
 
875 921
 		// Reflect that we're about to send some, do it now to be safe.
876 922
 		updateSettings(array('mail_recent' => $mt . '|' . $mn));
@@ -905,14 +951,15 @@  discard block
 block discarded – undo
905 951
 	$smcFunc['db_free_result']($request);
906 952
 
907 953
 	// Delete, delete, delete!!!
908
-	if (!empty($ids))
909
-		$smcFunc['db_query']('', '
954
+	if (!empty($ids)) {
955
+			$smcFunc['db_query']('', '
910 956
 			DELETE FROM {db_prefix}mail_queue
911 957
 			WHERE id_mail IN ({array_int:mail_list})',
912 958
 			array(
913 959
 				'mail_list' => $ids,
914 960
 			)
915 961
 		);
962
+	}
916 963
 
917 964
 	// Don't believe we have any left?
918 965
 	if (count($ids) < $number)
@@ -930,11 +977,13 @@  discard block
 block discarded – undo
930 977
 		);
931 978
 	}
932 979
 
933
-	if (empty($ids))
934
-		return false;
980
+	if (empty($ids)) {
981
+			return false;
982
+	}
935 983
 
936
-	if (!empty($modSettings['mail_type']) && $modSettings['smtp_host'] != '')
937
-		require_once($sourcedir . '/Subs-Post.php');
984
+	if (!empty($modSettings['mail_type']) && $modSettings['smtp_host'] != '') {
985
+			require_once($sourcedir . '/Subs-Post.php');
986
+	}
938 987
 
939 988
 	// Send each email, yea!
940 989
 	$failed_emails = array();
@@ -954,15 +1003,17 @@  discard block
 block discarded – undo
954 1003
 
955 1004
 			// Try to stop a timeout, this would be bad...
956 1005
 			@set_time_limit(300);
957
-			if (function_exists('apache_reset_timeout'))
958
-				@apache_reset_timeout();
1006
+			if (function_exists('apache_reset_timeout')) {
1007
+							@apache_reset_timeout();
1008
+			}
1009
+		} else {
1010
+					$result = smtp_mail(array($email['to']), $email['subject'], $email['body'], $email['headers']);
959 1011
 		}
960
-		else
961
-			$result = smtp_mail(array($email['to']), $email['subject'], $email['body'], $email['headers']);
962 1012
 
963 1013
 		// Hopefully it sent?
964
-		if (!$result)
965
-			$failed_emails[] = array($email['to'], $email['body'], $email['subject'], $email['headers'], $email['send_html'], $email['time_sent'], $email['private']);
1014
+		if (!$result) {
1015
+					$failed_emails[] = array($email['to'], $email['body'], $email['subject'], $email['headers'], $email['send_html'], $email['time_sent'], $email['private']);
1016
+		}
966 1017
 	}
967 1018
 
968 1019
 	// Any emails that didn't send?
@@ -977,8 +1028,8 @@  discard block
 block discarded – undo
977 1028
 		);
978 1029
 
979 1030
 		// If we have failed to many times, tell mail to wait a bit and try again.
980
-		if ($modSettings['mail_failed_attempts'] > 5)
981
-			$smcFunc['db_query']('', '
1031
+		if ($modSettings['mail_failed_attempts'] > 5) {
1032
+					$smcFunc['db_query']('', '
982 1033
 				UPDATE {db_prefix}settings
983 1034
 				SET value = {string:next_mail_send}
984 1035
 				WHERE variable = {literal:mail_next_send}
@@ -987,6 +1038,7 @@  discard block
 block discarded – undo
987 1038
 					'next_mail_send' => time() + 60,
988 1039
 					'last_send' => $modSettings['mail_next_send'],
989 1040
 			));
1041
+		}
990 1042
 
991 1043
 		// Add our email back to the queue, manually.
992 1044
 		$smcFunc['db_insert']('insert',
@@ -999,8 +1051,8 @@  discard block
 block discarded – undo
999 1051
 		return false;
1000 1052
 	}
1001 1053
 	// We where unable to send the email, clear our failed attempts.
1002
-	elseif (!empty($modSettings['mail_failed_attempts']))
1003
-		$smcFunc['db_query']('', '
1054
+	elseif (!empty($modSettings['mail_failed_attempts'])) {
1055
+			$smcFunc['db_query']('', '
1004 1056
 			UPDATE {db_prefix}settings
1005 1057
 			SET value = {string:zero}
1006 1058
 			WHERE variable = {string:mail_failed_attempts}',
@@ -1008,6 +1060,7 @@  discard block
 block discarded – undo
1008 1060
 				'zero' => '0',
1009 1061
 				'mail_failed_attempts' => 'mail_failed_attempts',
1010 1062
 		));
1063
+	}
1011 1064
 
1012 1065
 	// Had something to send...
1013 1066
 	return true;
@@ -1024,16 +1077,18 @@  discard block
 block discarded – undo
1024 1077
 	global $modSettings, $smcFunc;
1025 1078
 
1026 1079
 	$task_query = '';
1027
-	if (!is_array($tasks))
1028
-		$tasks = array($tasks);
1080
+	if (!is_array($tasks)) {
1081
+			$tasks = array($tasks);
1082
+	}
1029 1083
 
1030 1084
 	// Actually have something passed?
1031 1085
 	if (!empty($tasks))
1032 1086
 	{
1033
-		if (!isset($tasks[0]) || is_numeric($tasks[0]))
1034
-			$task_query = ' AND id_task IN ({array_int:tasks})';
1035
-		else
1036
-			$task_query = ' AND task IN ({array_string:tasks})';
1087
+		if (!isset($tasks[0]) || is_numeric($tasks[0])) {
1088
+					$task_query = ' AND id_task IN ({array_int:tasks})';
1089
+		} else {
1090
+					$task_query = ' AND task IN ({array_string:tasks})';
1091
+		}
1037 1092
 	}
1038 1093
 	$nextTaskTime = empty($tasks) ? time() + 86400 : $modSettings['next_task_time'];
1039 1094
 
@@ -1054,20 +1109,22 @@  discard block
 block discarded – undo
1054 1109
 		$next_time = next_time($row['time_regularity'], $row['time_unit'], $row['time_offset']);
1055 1110
 
1056 1111
 		// Only bother moving the task if it's out of place or we're forcing it!
1057
-		if ($forceUpdate || $next_time < $row['next_time'] || $row['next_time'] < time())
1058
-			$tasks[$row['id_task']] = $next_time;
1059
-		else
1060
-			$next_time = $row['next_time'];
1112
+		if ($forceUpdate || $next_time < $row['next_time'] || $row['next_time'] < time()) {
1113
+					$tasks[$row['id_task']] = $next_time;
1114
+		} else {
1115
+					$next_time = $row['next_time'];
1116
+		}
1061 1117
 
1062 1118
 		// If this is sooner than the current next task, make this the next task.
1063
-		if ($next_time < $nextTaskTime)
1064
-			$nextTaskTime = $next_time;
1119
+		if ($next_time < $nextTaskTime) {
1120
+					$nextTaskTime = $next_time;
1121
+		}
1065 1122
 	}
1066 1123
 	$smcFunc['db_free_result']($request);
1067 1124
 
1068 1125
 	// Now make the changes!
1069
-	foreach ($tasks as $id => $time)
1070
-		$smcFunc['db_query']('', '
1126
+	foreach ($tasks as $id => $time) {
1127
+			$smcFunc['db_query']('', '
1071 1128
 			UPDATE {db_prefix}scheduled_tasks
1072 1129
 			SET next_time = {int:next_time}
1073 1130
 			WHERE id_task = {int:id_task}',
@@ -1076,11 +1133,13 @@  discard block
 block discarded – undo
1076 1133
 				'id_task' => $id,
1077 1134
 			)
1078 1135
 		);
1136
+	}
1079 1137
 
1080 1138
 	// If the next task is now different update.
1081
-	if ($modSettings['next_task_time'] != $nextTaskTime)
1082
-		updateSettings(array('next_task_time' => $nextTaskTime));
1083
-}
1139
+	if ($modSettings['next_task_time'] != $nextTaskTime) {
1140
+			updateSettings(array('next_task_time' => $nextTaskTime));
1141
+	}
1142
+	}
1084 1143
 
1085 1144
 /**
1086 1145
  * Simply returns a time stamp of the next instance of these time parameters.
@@ -1093,8 +1152,9 @@  discard block
 block discarded – undo
1093 1152
 function next_time($regularity, $unit, $offset)
1094 1153
 {
1095 1154
 	// Just in case!
1096
-	if ($regularity == 0)
1097
-		$regularity = 2;
1155
+	if ($regularity == 0) {
1156
+			$regularity = 2;
1157
+	}
1098 1158
 
1099 1159
 	$curMin = date('i', time());
1100 1160
 
@@ -1104,15 +1164,16 @@  discard block
 block discarded – undo
1104 1164
 		$off = date('i', $offset);
1105 1165
 
1106 1166
 		// If it's now just pretend it ain't,
1107
-		if ($off == $curMin)
1108
-			$next_time = time() + $regularity;
1109
-		else
1167
+		if ($off == $curMin) {
1168
+					$next_time = time() + $regularity;
1169
+		} else
1110 1170
 		{
1111 1171
 			// Make sure that the offset is always in the past.
1112 1172
 			$off = $off > $curMin ? $off - 60 : $off;
1113 1173
 
1114
-			while ($off <= $curMin)
1115
-				$off += $regularity;
1174
+			while ($off <= $curMin) {
1175
+							$off += $regularity;
1176
+			}
1116 1177
 
1117 1178
 			// Now we know when the time should be!
1118 1179
 			$next_time = time() + 60 * ($off - $curMin);
@@ -1132,11 +1193,13 @@  discard block
 block discarded – undo
1132 1193
 		// Default we'll jump in hours.
1133 1194
 		$applyOffset = 3600;
1134 1195
 		// 24 hours = 1 day.
1135
-		if ($unit == 'd')
1136
-			$applyOffset = 86400;
1196
+		if ($unit == 'd') {
1197
+					$applyOffset = 86400;
1198
+		}
1137 1199
 		// Otherwise a week.
1138
-		if ($unit == 'w')
1139
-			$applyOffset = 604800;
1200
+		if ($unit == 'w') {
1201
+					$applyOffset = 604800;
1202
+		}
1140 1203
 
1141 1204
 		$applyOffset *= $regularity;
1142 1205
 
@@ -1173,8 +1236,9 @@  discard block
 block discarded – undo
1173 1236
 		$settings[$row['variable']] = $row['value'];
1174 1237
 
1175 1238
 		// Is this the default theme?
1176
-		if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1')
1177
-			$settings['default_' . $row['variable']] = $row['value'];
1239
+		if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1') {
1240
+					$settings['default_' . $row['variable']] = $row['value'];
1241
+		}
1178 1242
 	}
1179 1243
 	$smcFunc['db_free_result']($result);
1180 1244
 
@@ -1184,12 +1248,14 @@  discard block
 block discarded – undo
1184 1248
 		$settings['template_dirs'] = array($settings['theme_dir']);
1185 1249
 
1186 1250
 		// Based on theme (if there is one).
1187
-		if (!empty($settings['base_theme_dir']))
1188
-			$settings['template_dirs'][] = $settings['base_theme_dir'];
1251
+		if (!empty($settings['base_theme_dir'])) {
1252
+					$settings['template_dirs'][] = $settings['base_theme_dir'];
1253
+		}
1189 1254
 
1190 1255
 		// Lastly the default theme.
1191
-		if ($settings['theme_dir'] != $settings['default_theme_dir'])
1192
-			$settings['template_dirs'][] = $settings['default_theme_dir'];
1256
+		if ($settings['theme_dir'] != $settings['default_theme_dir']) {
1257
+					$settings['template_dirs'][] = $settings['default_theme_dir'];
1258
+		}
1193 1259
 	}
1194 1260
 
1195 1261
 	// Assume we want this.
@@ -1333,8 +1399,9 @@  discard block
 block discarded – undo
1333 1399
 	// Ok should we prune the logs?
1334 1400
 	if (!empty($modSettings['pruningOptions']))
1335 1401
 	{
1336
-		if (!empty($modSettings['pruningOptions']) && strpos($modSettings['pruningOptions'], ',') !== false)
1337
-			list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']);
1402
+		if (!empty($modSettings['pruningOptions']) && strpos($modSettings['pruningOptions'], ',') !== false) {
1403
+					list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']);
1404
+		}
1338 1405
 
1339 1406
 		if (!empty($modSettings['pruneErrorLog']))
1340 1407
 		{
@@ -1400,8 +1467,9 @@  discard block
 block discarded – undo
1400 1467
 				)
1401 1468
 			);
1402 1469
 
1403
-			while ($row = $smcFunc['db_fetch_row']($result))
1404
-				$reports[] = $row[0];
1470
+			while ($row = $smcFunc['db_fetch_row']($result)) {
1471
+							$reports[] = $row[0];
1472
+			}
1405 1473
 
1406 1474
 			$smcFunc['db_free_result']($result);
1407 1475
 
@@ -1486,8 +1554,9 @@  discard block
 block discarded – undo
1486 1554
 	);
1487 1555
 
1488 1556
 	// Run Cache housekeeping
1489
-	if (!empty($cache_enable) && !empty($cacheAPI))
1490
-		$cacheAPI->housekeeping();
1557
+	if (!empty($cache_enable) && !empty($cacheAPI)) {
1558
+			$cacheAPI->housekeeping();
1559
+	}
1491 1560
 
1492 1561
 	// Prevent stale minimized CSS and JavaScript from cluttering up the theme directories
1493 1562
 	deleteAllMinified();
@@ -1570,8 +1639,9 @@  discard block
 block discarded – undo
1570 1639
 		$emaildata = loadEmailTemplate('paid_subscription_reminder', $replacements, empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']);
1571 1640
 
1572 1641
 		// Send the actual email.
1573
-		if ($notifyPrefs[$row['id_member']] & 0x02)
1574
-			sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], null, 'paid_sub_remind', $emaildata['is_html'], 2);
1642
+		if ($notifyPrefs[$row['id_member']] & 0x02) {
1643
+					sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], null, 'paid_sub_remind', $emaildata['is_html'], 2);
1644
+		}
1575 1645
 
1576 1646
 		if ($notifyPrefs[$row['id_member']] & 0x01)
1577 1647
 		{
@@ -1594,18 +1664,19 @@  discard block
 block discarded – undo
1594 1664
 	}
1595 1665
 
1596 1666
 	// Insert the alerts if any
1597
-	if (!empty($alert_rows))
1598
-		$smcFunc['db_insert']('',
1667
+	if (!empty($alert_rows)) {
1668
+			$smcFunc['db_insert']('',
1599 1669
 			'{db_prefix}user_alerts',
1600 1670
 			array('alert_time' => 'int', 'id_member' => 'int', 'id_member_started' => 'int', 'member_name' => 'string',
1601 1671
 				'content_type' => 'string', 'content_id' => 'int', 'content_action' => 'string', 'is_read' => 'int', 'extra' => 'string'),
1602 1672
 			$alert_rows,
1603 1673
 			array()
1604 1674
 		);
1675
+	}
1605 1676
 
1606 1677
 	// Mark the reminder as sent.
1607
-	if (!empty($subs_reminded))
1608
-		$smcFunc['db_query']('', '
1678
+	if (!empty($subs_reminded)) {
1679
+			$smcFunc['db_query']('', '
1609 1680
 			UPDATE {db_prefix}log_subscribed
1610 1681
 			SET reminder_sent = {int:reminder_sent}
1611 1682
 			WHERE id_sublog IN ({array_int:subscription_list})',
@@ -1614,6 +1685,7 @@  discard block
 block discarded – undo
1614 1685
 				'reminder_sent' => 1,
1615 1686
 			)
1616 1687
 		);
1688
+	}
1617 1689
 
1618 1690
 	return true;
1619 1691
 }
@@ -1629,13 +1701,13 @@  discard block
 block discarded – undo
1629 1701
 	// We need to know where this thing is going.
1630 1702
 	if (!empty($modSettings['currentAttachmentUploadDir']))
1631 1703
 	{
1632
-		if (!is_array($modSettings['attachmentUploadDir']))
1633
-			$modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true);
1704
+		if (!is_array($modSettings['attachmentUploadDir'])) {
1705
+					$modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true);
1706
+		}
1634 1707
 
1635 1708
 		// Just use the current path for temp files.
1636 1709
 		$attach_dirs = $modSettings['attachmentUploadDir'];
1637
-	}
1638
-	else
1710
+	} else
1639 1711
 	{
1640 1712
 		$attach_dirs = array($modSettings['attachmentUploadDir']);
1641 1713
 	}
@@ -1654,14 +1726,16 @@  discard block
 block discarded – undo
1654 1726
 
1655 1727
 		while ($file = readdir($dir))
1656 1728
 		{
1657
-			if ($file == '.' || $file == '..')
1658
-				continue;
1729
+			if ($file == '.' || $file == '..') {
1730
+							continue;
1731
+			}
1659 1732
 
1660 1733
 			if (strpos($file, 'post_tmp_') !== false)
1661 1734
 			{
1662 1735
 				// Temp file is more than 5 hours old!
1663
-				if (filemtime($attach_dir . '/' . $file) < time() - 18000)
1664
-					@unlink($attach_dir . '/' . $file);
1736
+				if (filemtime($attach_dir . '/' . $file) < time() - 18000) {
1737
+									@unlink($attach_dir . '/' . $file);
1738
+				}
1665 1739
 			}
1666 1740
 		}
1667 1741
 		closedir($dir);
@@ -1694,8 +1768,9 @@  discard block
 block discarded – undo
1694 1768
 		)
1695 1769
 	);
1696 1770
 
1697
-	while ($row = $smcFunc['db_fetch_row']($request))
1698
-		$topics[] = $row[0];
1771
+	while ($row = $smcFunc['db_fetch_row']($request)) {
1772
+			$topics[] = $row[0];
1773
+	}
1699 1774
 	$smcFunc['db_free_result']($request);
1700 1775
 
1701 1776
 	// Zap, your gone
@@ -1715,8 +1790,9 @@  discard block
 block discarded – undo
1715 1790
 {
1716 1791
 	global $smcFunc, $sourcedir, $modSettings;
1717 1792
 
1718
-	if (empty($modSettings['drafts_keep_days']))
1719
-		return true;
1793
+	if (empty($modSettings['drafts_keep_days'])) {
1794
+			return true;
1795
+	}
1720 1796
 
1721 1797
 	// init
1722 1798
 	$drafts = array();
@@ -1734,8 +1810,9 @@  discard block
 block discarded – undo
1734 1810
 		)
1735 1811
 	);
1736 1812
 
1737
-	while ($row = $smcFunc['db_fetch_row']($request))
1738
-		$drafts[] = (int) $row[0];
1813
+	while ($row = $smcFunc['db_fetch_row']($request)) {
1814
+			$drafts[] = (int) $row[0];
1815
+	}
1739 1816
 	$smcFunc['db_free_result']($request);
1740 1817
 
1741 1818
 	// If we have old one, remove them
Please login to merge, or discard this patch.
Sources/Subs-Admin.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
 
19 19
 /**
20 20
  * Get a list of versions that are currently installed on the server.
21
- * @param array $checkFor An array of what to check versions for - can contain one or more of 'gd', 'imagemagick', 'db_server', 'phpa', 'memcache', 'xcache', 'apc', 'php' or 'server'
21
+ * @param string[] $checkFor An array of what to check versions for - can contain one or more of 'gd', 'imagemagick', 'db_server', 'phpa', 'memcache', 'xcache', 'apc', 'php' or 'server'
22 22
  * @return array An array of versions (keys are same as what was in $checkFor, values are the versions)
23 23
  */
24 24
 function getServerVersions($checkFor)
Please login to merge, or discard this patch.
Braces   +124 added lines, -89 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Get a list of versions that are currently installed on the server.
@@ -45,8 +46,7 @@  discard block
 block discarded – undo
45 46
 			$temp2 = $temp->getVersion();
46 47
 			$im_version = $temp2['versionString'];
47 48
 			$extension_version = 'Imagick ' . phpversion('Imagick');
48
-		}
49
-		else
49
+		} else
50 50
 		{
51 51
 			$im_version = MagickGetVersionString();
52 52
 			$extension_version = 'MagickWand ' . phpversion('MagickWand');
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
 	if (in_array('db_server', $checkFor))
62 62
 	{
63 63
 		db_extend();
64
-		if (!isset($db_connection) || $db_connection === false)
65
-			trigger_error('getServerVersions(): you need to be connected to the database in order to get its server version', E_USER_NOTICE);
66
-		else
64
+		if (!isset($db_connection) || $db_connection === false) {
65
+					trigger_error('getServerVersions(): you need to be connected to the database in order to get its server version', E_USER_NOTICE);
66
+		} else
67 67
 		{
68 68
 			$versions['db_engine'] = array('title' => sprintf($txt['support_versions_db_engine'], $smcFunc['db_title']), 'version' => '');
69 69
 			$versions['db_engine']['version'] = $smcFunc['db_get_vendor']();
@@ -75,24 +75,31 @@  discard block
 block discarded – undo
75 75
 
76 76
 	// If we're using memcache we need the server info.
77 77
 	$memcache_version = '???';
78
-	if (!empty($cache_accelerator) && ($cache_accelerator == 'memcached' || $cache_accelerator == 'memcache') && !empty($cache_memcached) && !empty($cacheAPI))
79
-		$memcache_version = $cacheAPI->getVersion();
78
+	if (!empty($cache_accelerator) && ($cache_accelerator == 'memcached' || $cache_accelerator == 'memcache') && !empty($cache_memcached) && !empty($cacheAPI)) {
79
+			$memcache_version = $cacheAPI->getVersion();
80
+	}
80 81
 
81 82
 	// Check to see if we have any accelerators installed...
82
-	if (in_array('phpa', $checkFor) && isset($_PHPA))
83
-		$versions['phpa'] = array('title' => 'ionCube PHP-Accelerator', 'version' => $_PHPA['VERSION']);
84
-	if (in_array('apc', $checkFor) && extension_loaded('apc'))
85
-		$versions['apc'] = array('title' => 'Alternative PHP Cache', 'version' => phpversion('apc'));
86
-	if (in_array('memcache', $checkFor) && function_exists('memcache_set'))
87
-		$versions['memcache'] = array('title' => 'Memcached', 'version' => $memcache_version);
88
-	if (in_array('xcache', $checkFor) && function_exists('xcache_set'))
89
-		$versions['xcache'] = array('title' => 'XCache', 'version' => XCACHE_VERSION);
83
+	if (in_array('phpa', $checkFor) && isset($_PHPA)) {
84
+			$versions['phpa'] = array('title' => 'ionCube PHP-Accelerator', 'version' => $_PHPA['VERSION']);
85
+	}
86
+	if (in_array('apc', $checkFor) && extension_loaded('apc')) {
87
+			$versions['apc'] = array('title' => 'Alternative PHP Cache', 'version' => phpversion('apc'));
88
+	}
89
+	if (in_array('memcache', $checkFor) && function_exists('memcache_set')) {
90
+			$versions['memcache'] = array('title' => 'Memcached', 'version' => $memcache_version);
91
+	}
92
+	if (in_array('xcache', $checkFor) && function_exists('xcache_set')) {
93
+			$versions['xcache'] = array('title' => 'XCache', 'version' => XCACHE_VERSION);
94
+	}
90 95
 
91
-	if (in_array('php', $checkFor))
92
-		$versions['php'] = array('title' => 'PHP', 'version' => PHP_VERSION, 'more' => '?action=admin;area=serversettings;sa=phpinfo');
96
+	if (in_array('php', $checkFor)) {
97
+			$versions['php'] = array('title' => 'PHP', 'version' => PHP_VERSION, 'more' => '?action=admin;area=serversettings;sa=phpinfo');
98
+	}
93 99
 
94
-	if (in_array('server', $checkFor))
95
-		$versions['server'] = array('title' => $txt['support_versions_server'], 'version' => $_SERVER['SERVER_SOFTWARE']);
100
+	if (in_array('server', $checkFor)) {
101
+			$versions['server'] = array('title' => $txt['support_versions_server'], 'version' => $_SERVER['SERVER_SOFTWARE']);
102
+	}
96 103
 
97 104
 	return $versions;
98 105
 }
@@ -132,11 +139,13 @@  discard block
 block discarded – undo
132 139
 		fclose($fp);
133 140
 
134 141
 		// The comment looks rougly like... that.
135
-		if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1)
136
-			$version_info['file_versions']['SSI.php'] = $match[1];
142
+		if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) {
143
+					$version_info['file_versions']['SSI.php'] = $match[1];
144
+		}
137 145
 		// Not found!  This is bad.
138
-		else
139
-			$version_info['file_versions']['SSI.php'] = '??';
146
+		else {
147
+					$version_info['file_versions']['SSI.php'] = '??';
148
+		}
140 149
 	}
141 150
 
142 151
 	// Do the paid subscriptions handler?
@@ -147,11 +156,13 @@  discard block
 block discarded – undo
147 156
 		fclose($fp);
148 157
 
149 158
 		// Found it?
150
-		if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1)
151
-			$version_info['file_versions']['subscriptions.php'] = $match[1];
159
+		if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) {
160
+					$version_info['file_versions']['subscriptions.php'] = $match[1];
161
+		}
152 162
 		// If we haven't how do we all get paid?
153
-		else
154
-			$version_info['file_versions']['subscriptions.php'] = '??';
163
+		else {
164
+					$version_info['file_versions']['subscriptions.php'] = '??';
165
+		}
155 166
 	}
156 167
 
157 168
 	// Load all the files in the Sources directory, except this file and the redirect.
@@ -166,11 +177,13 @@  discard block
 block discarded – undo
166 177
 			fclose($fp);
167 178
 
168 179
 			// Look for the version comment in the file header.
169
-			if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1)
170
-				$version_info['file_versions'][$entry] = $match[1];
180
+			if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) {
181
+							$version_info['file_versions'][$entry] = $match[1];
182
+			}
171 183
 			// It wasn't found, but the file was... show a '??'.
172
-			else
173
-				$version_info['file_versions'][$entry] = '??';
184
+			else {
185
+							$version_info['file_versions'][$entry] = '??';
186
+			}
174 187
 		}
175 188
 	}
176 189
 	$sources_dir->close();
@@ -189,11 +202,13 @@  discard block
 block discarded – undo
189 202
 				fclose($fp);
190 203
 
191 204
 				// Look for the version comment in the file header.
192
-				if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1)
193
-					$version_info['tasks_versions'][$entry] = $match[1];
205
+				if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) {
206
+									$version_info['tasks_versions'][$entry] = $match[1];
207
+				}
194 208
 				// It wasn't found, but the file was... show a '??'.
195
-				else
196
-					$version_info['tasks_versions'][$entry] = '??';
209
+				else {
210
+									$version_info['tasks_versions'][$entry] = '??';
211
+				}
197 212
 			}
198 213
 		}
199 214
 		$tasks_dir->close();
@@ -201,8 +216,9 @@  discard block
 block discarded – undo
201 216
 
202 217
 	// Load all the files in the default template directory - and the current theme if applicable.
203 218
 	$directories = array('default_template_versions' => $settings['default_theme_dir']);
204
-	if ($settings['theme_id'] != 1)
205
-		$directories += array('template_versions' => $settings['theme_dir']);
219
+	if ($settings['theme_id'] != 1) {
220
+			$directories += array('template_versions' => $settings['theme_dir']);
221
+	}
206 222
 
207 223
 	foreach ($directories as $type => $dirname)
208 224
 	{
@@ -217,11 +233,13 @@  discard block
 block discarded – undo
217 233
 				fclose($fp);
218 234
 
219 235
 				// Look for the version comment in the file header.
220
-				if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1)
221
-					$version_info[$type][$entry] = $match[1];
236
+				if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) {
237
+									$version_info[$type][$entry] = $match[1];
238
+				}
222 239
 				// It wasn't found, but the file was... show a '??'.
223
-				else
224
-					$version_info[$type][$entry] = '??';
240
+				else {
241
+									$version_info[$type][$entry] = '??';
242
+				}
225 243
 			}
226 244
 		}
227 245
 		$this_dir->close();
@@ -242,11 +260,13 @@  discard block
 block discarded – undo
242 260
 			list ($name, $language) = explode('.', $entry);
243 261
 
244 262
 			// Look for the version comment in the file header.
245
-			if (preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '(?:[\s]{2}|\*/)~i', $header, $match) == 1)
246
-				$version_info['default_language_versions'][$language][$name] = $match[1];
263
+			if (preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '(?:[\s]{2}|\*/)~i', $header, $match) == 1) {
264
+							$version_info['default_language_versions'][$language][$name] = $match[1];
265
+			}
247 266
 			// It wasn't found, but the file was... show a '??'.
248
-			else
249
-				$version_info['default_language_versions'][$language][$name] = '??';
267
+			else {
268
+							$version_info['default_language_versions'][$language][$name] = '??';
269
+			}
250 270
 		}
251 271
 	}
252 272
 	$this_dir->close();
@@ -261,8 +281,9 @@  discard block
 block discarded – undo
261 281
 		ksort($version_info['tasks_versions']);
262 282
 
263 283
 		// For languages sort each language too.
264
-		foreach ($version_info['default_language_versions'] as $language => $dummy)
265
-			ksort($version_info['default_language_versions'][$language]);
284
+		foreach ($version_info['default_language_versions'] as $language => $dummy) {
285
+					ksort($version_info['default_language_versions'][$language]);
286
+		}
266 287
 	}
267 288
 	return $version_info;
268 289
 }
@@ -304,27 +325,31 @@  discard block
 block discarded – undo
304 325
 	$settingsArray = trim(file_get_contents($boarddir . '/Settings.php'));
305 326
 
306 327
 	// Break it up based on \r or \n, and then clean out extra characters.
307
-	if (strpos($settingsArray, "\n") !== false)
308
-		$settingsArray = explode("\n", $settingsArray);
309
-	elseif (strpos($settingsArray, "\r") !== false)
310
-		$settingsArray = explode("\r", $settingsArray);
311
-	else
312
-		return;
328
+	if (strpos($settingsArray, "\n") !== false) {
329
+			$settingsArray = explode("\n", $settingsArray);
330
+	} elseif (strpos($settingsArray, "\r") !== false) {
331
+			$settingsArray = explode("\r", $settingsArray);
332
+	} else {
333
+			return;
334
+	}
313 335
 
314 336
 	// Presumably, the file has to have stuff in it for this function to be called :P.
315
-	if (count($settingsArray) < 10)
316
-		return;
337
+	if (count($settingsArray) < 10) {
338
+			return;
339
+	}
317 340
 
318 341
 	// remove any /r's that made there way in here
319
-	foreach ($settingsArray as $k => $dummy)
320
-		$settingsArray[$k] = strtr($dummy, array("\r" => '')) . "\n";
342
+	foreach ($settingsArray as $k => $dummy) {
343
+			$settingsArray[$k] = strtr($dummy, array("\r" => '')) . "\n";
344
+	}
321 345
 
322 346
 	// go line by line and see whats changing
323 347
 	for ($i = 0, $n = count($settingsArray); $i < $n; $i++)
324 348
 	{
325 349
 		// Don't trim or bother with it if it's not a variable.
326
-		if (substr($settingsArray[$i], 0, 1) != '$')
327
-			continue;
350
+		if (substr($settingsArray[$i], 0, 1) != '$') {
351
+					continue;
352
+		}
328 353
 
329 354
 		$settingsArray[$i] = trim($settingsArray[$i]) . "\n";
330 355
 
@@ -336,8 +361,7 @@  discard block
 block discarded – undo
336 361
 			{
337 362
 				updateDbLastError($val);
338 363
 				unset($config_vars[$var]);
339
-			}
340
-			elseif (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0)
364
+			} elseif (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0)
341 365
 			{
342 366
 				$comment = strstr(substr($settingsArray[$i], strpos($settingsArray[$i], ';')), '#');
343 367
 				$settingsArray[$i] = '$' . $var . ' = ' . $val . ';' . ($comment == '' ? '' : "\t\t" . rtrim($comment)) . "\n";
@@ -348,34 +372,39 @@  discard block
 block discarded – undo
348 372
 		}
349 373
 
350 374
 		// End of the file ... maybe
351
-		if (substr(trim($settingsArray[$i]), 0, 2) == '?' . '>')
352
-			$end = $i;
375
+		if (substr(trim($settingsArray[$i]), 0, 2) == '?' . '>') {
376
+					$end = $i;
377
+		}
353 378
 	}
354 379
 
355 380
 	// This should never happen, but apparently it is happening.
356
-	if (empty($end) || $end < 10)
357
-		$end = count($settingsArray) - 1;
381
+	if (empty($end) || $end < 10) {
382
+			$end = count($settingsArray) - 1;
383
+	}
358 384
 
359 385
 	// Still more variables to go?  Then lets add them at the end.
360 386
 	if (!empty($config_vars))
361 387
 	{
362
-		if (trim($settingsArray[$end]) == '?' . '>')
363
-			$settingsArray[$end++] = '';
364
-		else
365
-			$end++;
388
+		if (trim($settingsArray[$end]) == '?' . '>') {
389
+					$settingsArray[$end++] = '';
390
+		} else {
391
+					$end++;
392
+		}
366 393
 
367 394
 		// Add in any newly defined vars that were passed
368
-		foreach ($config_vars as $var => $val)
369
-			$settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n";
395
+		foreach ($config_vars as $var => $val) {
396
+					$settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n";
397
+		}
370 398
 
371 399
 		$settingsArray[$end] = '?' . '>';
400
+	} else {
401
+			$settingsArray[$end] = trim($settingsArray[$end]);
372 402
 	}
373
-	else
374
-		$settingsArray[$end] = trim($settingsArray[$end]);
375 403
 
376 404
 	// Sanity error checking: the file needs to be at least 12 lines.
377
-	if (count($settingsArray) < 12)
378
-		return;
405
+	if (count($settingsArray) < 12) {
406
+			return;
407
+	}
379 408
 
380 409
 	// Try to avoid a few pitfalls:
381 410
 	//  - like a possible race condition,
@@ -383,8 +412,9 @@  discard block
 block discarded – undo
383 412
 	//
384 413
 	// Check before you act: if cache is enabled, we can do a simple write test
385 414
 	// to validate that we even write things on this filesystem.
386
-	if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache'))
387
-		$cachedir = $boarddir . '/cache';
415
+	if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) {
416
+			$cachedir = $boarddir . '/cache';
417
+	}
388 418
 
389 419
 	$test_fp = @fopen($cachedir . '/settings_update.tmp', "w+");
390 420
 	if ($test_fp)
@@ -419,16 +449,18 @@  discard block
 block discarded – undo
419 449
 			// Well this is not good at all, lets see if we can save this
420 450
 			$context['settings_message'] = 'settings_error';
421 451
 
422
-			if (file_exists($boarddir . '/Settings_bak.php'))
423
-				@copy($boarddir . '/Settings_bak.php', $boarddir . '/Settings.php');
452
+			if (file_exists($boarddir . '/Settings_bak.php')) {
453
+							@copy($boarddir . '/Settings_bak.php', $boarddir . '/Settings.php');
454
+			}
424 455
 		}
425 456
 	}
426 457
 
427 458
 	// Even though on normal installations the filemtime should prevent this being used by the installer incorrectly
428 459
 	// it seems that there are times it might not. So let's MAKE it dump the cache.
429
-	if (function_exists('opcache_invalidate'))
430
-		opcache_invalidate($boarddir . '/Settings.php', true);
431
-}
460
+	if (function_exists('opcache_invalidate')) {
461
+			opcache_invalidate($boarddir . '/Settings.php', true);
462
+	}
463
+	}
432 464
 
433 465
 /**
434 466
  * Saves the time of the last db error for the error log
@@ -454,8 +486,9 @@  discard block
 block discarded – undo
454 486
 	global $options, $context, $smcFunc, $settings, $user_info;
455 487
 
456 488
 	// This must exist!
457
-	if (!isset($context['admin_preferences']))
458
-		return false;
489
+	if (!isset($context['admin_preferences'])) {
490
+			return false;
491
+	}
459 492
 
460 493
 	// This is what we'll be saving.
461 494
 	$options['admin_preferences'] = $smcFunc['json_encode']($context['admin_preferences']);
@@ -519,8 +552,9 @@  discard block
 block discarded – undo
519 552
 	$emails_sent = array();
520 553
 	while ($row = $smcFunc['db_fetch_assoc']($request))
521 554
 	{
522
-		if (empty($prefs[$row['id_member']]['announcements']))
523
-			continue;
555
+		if (empty($prefs[$row['id_member']]['announcements'])) {
556
+					continue;
557
+		}
524 558
 
525 559
 		// Stick their particulars in the replacement data.
526 560
 		$replacements['IDMEMBER'] = $row['id_member'];
@@ -539,11 +573,12 @@  discard block
 block discarded – undo
539 573
 	$smcFunc['db_free_result']($request);
540 574
 
541 575
 	// Any additional users we must email this to?
542
-	if (!empty($additional_recipients))
543
-		foreach ($additional_recipients as $recipient)
576
+	if (!empty($additional_recipients)) {
577
+			foreach ($additional_recipients as $recipient)
544 578
 		{
545 579
 			if (in_array($recipient['email'], $emails_sent))
546 580
 				continue;
581
+	}
547 582
 
548 583
 			$replacements['IDMEMBER'] = $recipient['id'];
549 584
 			$replacements['REALNAME'] = $recipient['name'];
Please login to merge, or discard this patch.
Sources/Subs-Graphics.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -170,7 +170,7 @@
 block discarded – undo
170 170
  *
171 171
  * @param string $fileName The path to the file
172 172
  * @param int $preferred_format The preferred format - 0 to automatically determine, 1 for gif, 2 for jpg, 3 for png, 6 for bmp and 15 for wbmp
173
- * @return boolean Whether the reencoding was successful
173
+ * @return false|null Whether the reencoding was successful
174 174
  */
175 175
 function reencodeImage($fileName, $preferred_format = 0)
176 176
 {
Please login to merge, or discard this patch.
Indentation   -2 removed lines patch added patch discarded remove patch
@@ -523,7 +523,6 @@  discard block
 block discarded – undo
523 523
 /**
524 524
  * Copy image.
525 525
  * Used when imagecopyresample() is not available.
526
-
527 526
  * @param resource $dst_img The destination image - a GD image resource
528 527
  * @param resource $src_img The source image - a GD image resource
529 528
  * @param int $dst_x The "x" coordinate of the destination image
@@ -754,7 +753,6 @@  discard block
 block discarded – undo
754 753
 
755 754
 /**
756 755
  * Writes a gif file to disk as a png file.
757
-
758 756
  * @param resource $gif A gif image resource
759 757
  * @param string $lpszFileName The name of the file
760 758
  * @param int $background_color The background color
Please login to merge, or discard this patch.
Braces   +240 added lines, -196 removed lines patch added patch discarded remove patch
@@ -18,8 +18,9 @@  discard block
 block discarded – undo
18 18
  * @version 2.1 Beta 4
19 19
  */
20 20
 
21
-if (!defined('SMF'))
21
+if (!defined('SMF')) {
22 22
 	die('No direct access...');
23
+}
23 24
 
24 25
 /**
25 26
  * downloads a file from a url and stores it locally for avatar use by id_member.
@@ -44,8 +45,9 @@  discard block
 block discarded – undo
44 45
 	$destName = 'avatar_' . $memID . '_' . time() . '.' . $ext;
45 46
 
46 47
 	// Just making sure there is a non-zero member.
47
-	if (empty($memID))
48
-		return false;
48
+	if (empty($memID)) {
49
+			return false;
50
+	}
49 51
 
50 52
 	require_once($sourcedir . '/ManageAttachments.php');
51 53
 	removeAttachments(array('id_member' => $memID));
@@ -76,10 +78,11 @@  discard block
 block discarded – undo
76 78
 	$destName = $modSettings['custom_avatar_dir'] . '/' . $destName . '.tmp';
77 79
 
78 80
 	// Resize it.
79
-	if (!empty($modSettings['avatar_download_png']))
80
-		$success = resizeImageFile($url, $destName, $max_width, $max_height, 3);
81
-	else
82
-		$success = resizeImageFile($url, $destName, $max_width, $max_height);
81
+	if (!empty($modSettings['avatar_download_png'])) {
82
+			$success = resizeImageFile($url, $destName, $max_width, $max_height, 3);
83
+	} else {
84
+			$success = resizeImageFile($url, $destName, $max_width, $max_height);
85
+	}
83 86
 
84 87
 	// Remove the .tmp extension.
85 88
 	$destName = substr($destName, 0, -4);
@@ -108,11 +111,10 @@  discard block
 block discarded – undo
108 111
 				)
109 112
 			);
110 113
 			return true;
114
+		} else {
115
+					return false;
111 116
 		}
112
-		else
113
-			return false;
114
-	}
115
-	else
117
+	} else
116 118
 	{
117 119
 		$smcFunc['db_query']('', '
118 120
 			DELETE FROM {db_prefix}attachments
@@ -144,17 +146,18 @@  discard block
 block discarded – undo
144 146
 	$destName = $source . '_thumb.tmp';
145 147
 
146 148
 	// Do the actual resize.
147
-	if (!empty($modSettings['attachment_thumb_png']))
148
-		$success = resizeImageFile($source, $destName, $max_width, $max_height, 3);
149
-	else
150
-		$success = resizeImageFile($source, $destName, $max_width, $max_height);
149
+	if (!empty($modSettings['attachment_thumb_png'])) {
150
+			$success = resizeImageFile($source, $destName, $max_width, $max_height, 3);
151
+	} else {
152
+			$success = resizeImageFile($source, $destName, $max_width, $max_height);
153
+	}
151 154
 
152 155
 	// Okay, we're done with the temporary stuff.
153 156
 	$destName = substr($destName, 0, -4);
154 157
 
155
-	if ($success && @rename($destName . '.tmp', $destName))
156
-		return true;
157
-	else
158
+	if ($success && @rename($destName . '.tmp', $destName)) {
159
+			return true;
160
+	} else
158 161
 	{
159 162
 		@unlink($destName . '.tmp');
160 163
 		@touch($destName);
@@ -176,18 +179,21 @@  discard block
 block discarded – undo
176 179
 {
177 180
 	if (!resizeImageFile($fileName, $fileName . '.tmp', null, null, $preferred_format))
178 181
 	{
179
-		if (file_exists($fileName . '.tmp'))
180
-			unlink($fileName . '.tmp');
182
+		if (file_exists($fileName . '.tmp')) {
183
+					unlink($fileName . '.tmp');
184
+		}
181 185
 
182 186
 		return false;
183 187
 	}
184 188
 
185
-	if (!unlink($fileName))
186
-		return false;
189
+	if (!unlink($fileName)) {
190
+			return false;
191
+	}
187 192
 
188
-	if (!rename($fileName . '.tmp', $fileName))
189
-		return false;
190
-}
193
+	if (!rename($fileName . '.tmp', $fileName)) {
194
+			return false;
195
+	}
196
+	}
191 197
 
192 198
 /**
193 199
  * Searches through the file to see if there's potentially harmful non-binary content.
@@ -200,8 +206,9 @@  discard block
 block discarded – undo
200 206
 function checkImageContents($fileName, $extensiveCheck = false)
201 207
 {
202 208
 	$fp = fopen($fileName, 'rb');
203
-	if (!$fp)
204
-		fatal_lang_error('attach_timeout');
209
+	if (!$fp) {
210
+			fatal_lang_error('attach_timeout');
211
+	}
205 212
 
206 213
 	$prev_chunk = '';
207 214
 	while (!feof($fp))
@@ -218,8 +225,7 @@  discard block
 block discarded – undo
218 225
 				fclose($fp);
219 226
 				return false;
220 227
 			}
221
-		}
222
-		else
228
+		} else
223 229
 		{
224 230
 			// Check for potential infection - focus on clues for inline php & flash.
225 231
 			// Will result in significantly fewer false positives than the paranoid check.
@@ -247,8 +253,9 @@  discard block
 block discarded – undo
247 253
 	global $gd2;
248 254
 
249 255
 	// Check to see if GD is installed and what version.
250
-	if (($extensionFunctions = get_extension_funcs('gd')) === false)
251
-		return false;
256
+	if (($extensionFunctions = get_extension_funcs('gd')) === false) {
257
+			return false;
258
+	}
252 259
 
253 260
 	// Also determine if GD2 is installed and store it in a global.
254 261
 	$gd2 = in_array('imagecreatetruecolor', $extensionFunctions) && function_exists('imagecreatetruecolor');
@@ -320,8 +327,9 @@  discard block
 block discarded – undo
320 327
 	global $sourcedir;
321 328
 
322 329
 	// Nothing to do without GD or IM/MW
323
-	if (!checkGD() && !checkImagick() && !checkMagickWand())
324
-		return false;
330
+	if (!checkGD() && !checkImagick() && !checkMagickWand()) {
331
+			return false;
332
+	}
325 333
 
326 334
 	static $default_formats = array(
327 335
 		'1' => 'gif',
@@ -341,38 +349,39 @@  discard block
 block discarded – undo
341 349
 		fclose($fp_destination);
342 350
 
343 351
 		$sizes = @getimagesize($destination);
344
-	}
345
-	elseif ($fp_destination)
352
+	} elseif ($fp_destination)
346 353
 	{
347 354
 		$sizes = @getimagesize($source);
348 355
 
349 356
 		$fp_source = fopen($source, 'rb');
350 357
 		if ($fp_source !== false)
351 358
 		{
352
-			while (!feof($fp_source))
353
-				fwrite($fp_destination, fread($fp_source, 8192));
359
+			while (!feof($fp_source)) {
360
+							fwrite($fp_destination, fread($fp_source, 8192));
361
+			}
354 362
 			fclose($fp_source);
363
+		} else {
364
+					$sizes = array(-1, -1, -1);
355 365
 		}
356
-		else
357
-			$sizes = array(-1, -1, -1);
358 366
 		fclose($fp_destination);
359 367
 	}
360 368
 	// We can't get to the file.
361
-	else
362
-		$sizes = array(-1, -1, -1);
369
+	else {
370
+			$sizes = array(-1, -1, -1);
371
+	}
363 372
 
364 373
 	// See if we have -or- can get the needed memory for this operation
365 374
 	// ImageMagick isn't subject to PHP's memory limits :)
366
-	if (!(checkIMagick() || checkMagickWand()) && checkGD() && !imageMemoryCheck($sizes))
367
-		return false;
375
+	if (!(checkIMagick() || checkMagickWand()) && checkGD() && !imageMemoryCheck($sizes)) {
376
+			return false;
377
+	}
368 378
 
369 379
 	// A known and supported format?
370 380
 	// @todo test PSD and gif.
371 381
 	if ((checkImagick() || checkMagickWand()) && isset($default_formats[$sizes[2]]))
372 382
 	{
373 383
 		return resizeImage(null, $destination, null, null, $max_width, $max_height, true, $preferred_format);
374
-	}
375
-	elseif (checkGD() && isset($default_formats[$sizes[2]]) && function_exists('imagecreatefrom' . $default_formats[$sizes[2]]))
384
+	} elseif (checkGD() && isset($default_formats[$sizes[2]]) && function_exists('imagecreatefrom' . $default_formats[$sizes[2]]))
376 385
 	{
377 386
 		$imagecreatefrom = 'imagecreatefrom' . $default_formats[$sizes[2]];
378 387
 		if ($src_img = @$imagecreatefrom($destination))
@@ -425,14 +434,14 @@  discard block
 block discarded – undo
425 434
 			$dest_width = empty($max_width) ? $src_width : $max_width;
426 435
 			$dest_height = empty($max_height) ? $src_height : $max_height;
427 436
 
428
-			if ($default_formats[$preferred_format] == 'jpeg')
429
-				$imagick->setCompressionQuality(!empty($modSettings['avatar_jpeg_quality']) ? $modSettings['avatar_jpeg_quality'] : 82);
437
+			if ($default_formats[$preferred_format] == 'jpeg') {
438
+							$imagick->setCompressionQuality(!empty($modSettings['avatar_jpeg_quality']) ? $modSettings['avatar_jpeg_quality'] : 82);
439
+			}
430 440
 
431 441
 			$imagick->setImageFormat($default_formats[$preferred_format]);
432 442
 			$imagick->resizeImage($dest_width, $dest_height, Imagick::FILTER_LANCZOS, 1, true);
433 443
 			$success = $imagick->writeImage($destName);
434
-		}
435
-		else
444
+		} else
436 445
 		{
437 446
 			$magick_wand = newMagickWand();
438 447
 			MagickReadImage($magick_wand, $destName);
@@ -441,8 +450,9 @@  discard block
 block discarded – undo
441 450
 			$dest_width = empty($max_width) ? $src_width : $max_width;
442 451
 			$dest_height = empty($max_height) ? $src_height : $max_height;
443 452
 
444
-			if ($default_formats[$preferred_format] == 'jpeg')
445
-				MagickSetCompressionQuality($magick_wand, !empty($modSettings['avatar_jpeg_quality']) ? $modSettings['avatar_jpeg_quality'] : 82);
453
+			if ($default_formats[$preferred_format] == 'jpeg') {
454
+							MagickSetCompressionQuality($magick_wand, !empty($modSettings['avatar_jpeg_quality']) ? $modSettings['avatar_jpeg_quality'] : 82);
455
+			}
446 456
 
447 457
 			MagickSetImageFormat($magick_wand, $default_formats[$preferred_format]);
448 458
 			MagickResizeImage($magick_wand, $dest_width, $dest_height, MW_LanczosFilter, 1, true);
@@ -450,8 +460,7 @@  discard block
 block discarded – undo
450 460
 		}
451 461
 
452 462
 		return !empty($success);
453
-	}
454
-	elseif (checkGD())
463
+	} elseif (checkGD())
455 464
 	{
456 465
 		$success = false;
457 466
 
@@ -462,8 +471,7 @@  discard block
 block discarded – undo
462 471
 			{
463 472
 				$dst_width = $max_width;
464 473
 				$dst_height = round($src_height * $max_width / $src_width);
465
-			}
466
-			elseif (!empty($max_height))
474
+			} elseif (!empty($max_height))
467 475
 			{
468 476
 				$dst_width = round($src_width * $max_height / $src_height);
469 477
 				$dst_height = $max_height;
@@ -481,44 +489,48 @@  discard block
 block discarded – undo
481 489
 					if ((!empty($preferred_format)) && ($preferred_format == 3))
482 490
 					{
483 491
 						imagealphablending($dst_img, false);
484
-						if (function_exists('imagesavealpha'))
485
-							imagesavealpha($dst_img, true);
492
+						if (function_exists('imagesavealpha')) {
493
+													imagesavealpha($dst_img, true);
494
+						}
486 495
 					}
496
+				} else {
497
+									$dst_img = imagecreate($dst_width, $dst_height);
487 498
 				}
488
-				else
489
-					$dst_img = imagecreate($dst_width, $dst_height);
490 499
 
491 500
 				// Resize it!
492
-				if ($gd2)
493
-					imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $dst_width, $dst_height, $src_width, $src_height);
494
-				else
495
-					imagecopyresamplebicubic($dst_img, $src_img, 0, 0, 0, 0, $dst_width, $dst_height, $src_width, $src_height);
501
+				if ($gd2) {
502
+									imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $dst_width, $dst_height, $src_width, $src_height);
503
+				} else {
504
+									imagecopyresamplebicubic($dst_img, $src_img, 0, 0, 0, 0, $dst_width, $dst_height, $src_width, $src_height);
505
+				}
506
+			} else {
507
+							$dst_img = $src_img;
496 508
 			}
497
-			else
498
-				$dst_img = $src_img;
509
+		} else {
510
+					$dst_img = $src_img;
499 511
 		}
500
-		else
501
-			$dst_img = $src_img;
502 512
 
503 513
 		// Save the image as ...
504
-		if (!empty($preferred_format) && ($preferred_format == 3) && function_exists('imagepng'))
505
-			$success = imagepng($dst_img, $destName);
506
-		elseif (!empty($preferred_format) && ($preferred_format == 1) && function_exists('imagegif'))
507
-			$success = imagegif($dst_img, $destName);
508
-		elseif (function_exists('imagejpeg'))
509
-			$success = imagejpeg($dst_img, $destName, !empty($modSettings['avatar_jpeg_quality']) ? $modSettings['avatar_jpeg_quality'] : 82);
514
+		if (!empty($preferred_format) && ($preferred_format == 3) && function_exists('imagepng')) {
515
+					$success = imagepng($dst_img, $destName);
516
+		} elseif (!empty($preferred_format) && ($preferred_format == 1) && function_exists('imagegif')) {
517
+					$success = imagegif($dst_img, $destName);
518
+		} elseif (function_exists('imagejpeg')) {
519
+					$success = imagejpeg($dst_img, $destName, !empty($modSettings['avatar_jpeg_quality']) ? $modSettings['avatar_jpeg_quality'] : 82);
520
+		}
510 521
 
511 522
 		// Free the memory.
512 523
 		imagedestroy($src_img);
513
-		if ($dst_img != $src_img)
514
-			imagedestroy($dst_img);
524
+		if ($dst_img != $src_img) {
525
+					imagedestroy($dst_img);
526
+		}
515 527
 
516 528
 		return $success;
517
-	}
518
-	else
519
-		// Without GD, no image resizing at all.
529
+	} else {
530
+			// Without GD, no image resizing at all.
520 531
 		return false;
521
-}
532
+	}
533
+	}
522 534
 
523 535
 /**
524 536
  * Copy image.
@@ -572,8 +584,9 @@  discard block
 block discarded – undo
572 584
 			$color = imagecolorresolve($dst_img, $red, $green, $blue);
573 585
 			if ($color == -1)
574 586
 			{
575
-				if ($palsize++ < 256)
576
-					imagecolorallocate($dst_img, $red, $green, $blue);
587
+				if ($palsize++ < 256) {
588
+									imagecolorallocate($dst_img, $red, $green, $blue);
589
+				}
577 590
 				$color = imagecolorclosest($dst_img, $red, $green, $blue);
578 591
 			}
579 592
 
@@ -603,13 +616,15 @@  discard block
 block discarded – undo
603 616
 		$header = unpack('vtype/Vsize/Vreserved/Voffset', fread($fp, 14));
604 617
 		$info = unpack('Vsize/Vwidth/Vheight/vplanes/vbits/Vcompression/Vimagesize/Vxres/Vyres/Vncolor/Vcolorimportant', fread($fp, 40));
605 618
 
606
-		if ($header['type'] != 0x4D42)
607
-			return false;
619
+		if ($header['type'] != 0x4D42) {
620
+					return false;
621
+		}
608 622
 
609
-		if ($gd2)
610
-			$dst_img = imagecreatetruecolor($info['width'], $info['height']);
611
-		else
612
-			$dst_img = imagecreate($info['width'], $info['height']);
623
+		if ($gd2) {
624
+					$dst_img = imagecreatetruecolor($info['width'], $info['height']);
625
+		} else {
626
+					$dst_img = imagecreate($info['width'], $info['height']);
627
+		}
613 628
 
614 629
 		$palette_size = $header['offset'] - 54;
615 630
 		$info['ncolor'] = $palette_size / 4;
@@ -635,8 +650,9 @@  discard block
 block discarded – undo
635 650
 			fseek($fp, $header['offset'] + ($scan_line_size + $scan_line_align) * $l);
636 651
 			$scan_line = fread($fp, $scan_line_size);
637 652
 
638
-			if (strlen($scan_line) < $scan_line_size)
639
-				continue;
653
+			if (strlen($scan_line) < $scan_line_size) {
654
+							continue;
655
+			}
640 656
 
641 657
 			if ($info['bits'] == 32)
642 658
 			{
@@ -654,14 +670,14 @@  discard block
 block discarded – undo
654 670
 						$color = imagecolorallocate($dst_img, $r, $g, $b);
655 671
 
656 672
 						// Gah!  Out of colors?  Stupid GD 1... try anyhow.
657
-						if ($color == -1)
658
-							$color = imagecolorclosest($dst_img, $r, $g, $b);
673
+						if ($color == -1) {
674
+													$color = imagecolorclosest($dst_img, $r, $g, $b);
675
+						}
659 676
 					}
660 677
 
661 678
 					imagesetpixel($dst_img, $x, $y, $color);
662 679
 				}
663
-			}
664
-			elseif ($info['bits'] == 24)
680
+			} elseif ($info['bits'] == 24)
665 681
 			{
666 682
 				$x = 0;
667 683
 				for ($j = 0; $j < $scan_line_size; $x++)
@@ -676,14 +692,14 @@  discard block
 block discarded – undo
676 692
 						$color = imagecolorallocate($dst_img, $r, $g, $b);
677 693
 
678 694
 						// Gah!  Out of colors?  Stupid GD 1... try anyhow.
679
-						if ($color == -1)
680
-							$color = imagecolorclosest($dst_img, $r, $g, $b);
695
+						if ($color == -1) {
696
+													$color = imagecolorclosest($dst_img, $r, $g, $b);
697
+						}
681 698
 					}
682 699
 
683 700
 					imagesetpixel($dst_img, $x, $y, $color);
684 701
 				}
685
-			}
686
-			elseif ($info['bits'] == 16)
702
+			} elseif ($info['bits'] == 16)
687 703
 			{
688 704
 				$x = 0;
689 705
 				for ($j = 0; $j < $scan_line_size; $x++)
@@ -704,20 +720,20 @@  discard block
 block discarded – undo
704 720
 						$color = imagecolorallocate($dst_img, $r, $g, $b);
705 721
 
706 722
 						// Gah!  Out of colors?  Stupid GD 1... try anyhow.
707
-						if ($color == -1)
708
-							$color = imagecolorclosest($dst_img, $r, $g, $b);
723
+						if ($color == -1) {
724
+													$color = imagecolorclosest($dst_img, $r, $g, $b);
725
+						}
709 726
 					}
710 727
 
711 728
 					imagesetpixel($dst_img, $x, $y, $color);
712 729
 				}
713
-			}
714
-			elseif ($info['bits'] == 8)
730
+			} elseif ($info['bits'] == 8)
715 731
 			{
716 732
 				$x = 0;
717
-				for ($j = 0; $j < $scan_line_size; $x++)
718
-					imagesetpixel($dst_img, $x, $y, $palette[ord($scan_line{$j++})]);
719
-			}
720
-			elseif ($info['bits'] == 4)
733
+				for ($j = 0; $j < $scan_line_size; $x++) {
734
+									imagesetpixel($dst_img, $x, $y, $palette[ord($scan_line{$j++})]);
735
+				}
736
+			} elseif ($info['bits'] == 4)
721 737
 			{
722 738
 				$x = 0;
723 739
 				for ($j = 0; $j < $scan_line_size; $x++)
@@ -726,11 +742,11 @@  discard block
 block discarded – undo
726 742
 
727 743
 					imagesetpixel($dst_img, $x, $y, $palette[(int) ($byte / 16)]);
728 744
 
729
-					if (++$x < $info['width'])
730
-						imagesetpixel($dst_img, $x, $y, $palette[$byte & 15]);
745
+					if (++$x < $info['width']) {
746
+											imagesetpixel($dst_img, $x, $y, $palette[$byte & 15]);
747
+					}
731 748
 				}
732
-			}
733
-			elseif ($info['bits'] == 1)
749
+			} elseif ($info['bits'] == 1)
734 750
 			{
735 751
 				$x = 0;
736 752
 				for ($j = 0; $j < $scan_line_size; $x++)
@@ -741,8 +757,9 @@  discard block
 block discarded – undo
741 757
 
742 758
 					for ($shift = 1; $shift < 8; $shift++)
743 759
 					{
744
-						if (++$x < $info['width'])
745
-							imagesetpixel($dst_img, $x, $y, $palette[(($byte << $shift) & 128) != 0]);
760
+						if (++$x < $info['width']) {
761
+													imagesetpixel($dst_img, $x, $y, $palette[(($byte << $shift) & 128) != 0]);
762
+						}
746 763
 					}
747 764
 				}
748 765
 			}
@@ -766,15 +783,18 @@  discard block
 block discarded – undo
766 783
  */
767 784
 function gif_outputAsPng($gif, $lpszFileName, $background_color = -1)
768 785
 {
769
-	if (!isset($gif) || @get_class($gif) != 'cgif' || !$gif->loaded || $lpszFileName == '')
770
-		return false;
786
+	if (!isset($gif) || @get_class($gif) != 'cgif' || !$gif->loaded || $lpszFileName == '') {
787
+			return false;
788
+	}
771 789
 
772 790
 	$fd = $gif->get_png_data($background_color);
773
-	if (strlen($fd) <= 0)
774
-		return false;
791
+	if (strlen($fd) <= 0) {
792
+			return false;
793
+	}
775 794
 
776
-	if (!($fh = @fopen($lpszFileName, 'wb')))
777
-		return false;
795
+	if (!($fh = @fopen($lpszFileName, 'wb'))) {
796
+			return false;
797
+	}
778 798
 
779 799
 	@fwrite($fh, $fd, strlen($fd));
780 800
 	@fflush($fh);
@@ -801,8 +821,9 @@  discard block
 block discarded – undo
801 821
 	// What type are we going to be doing?
802 822
 	$imageType = $modSettings['visual_verification_type'];
803 823
 	// Special case to allow the admin center to show samples.
804
-	if ($user_info['is_admin'] && isset($_GET['type']))
805
-		$imageType = (int) $_GET['type'];
824
+	if ($user_info['is_admin'] && isset($_GET['type'])) {
825
+			$imageType = (int) $_GET['type'];
826
+	}
806 827
 
807 828
 	// Some quick references for what we do.
808 829
 	// Do we show no, low or high noise?
@@ -836,25 +857,28 @@  discard block
 block discarded – undo
836 857
 	$character_spacing = 1;
837 858
 
838 859
 	// What color is the background - generally white unless we're on "hard".
839
-	if ($simpleBGColor)
840
-		$background_color = array(255, 255, 255);
841
-	else
842
-		$background_color = isset($settings['verification_background']) ? $settings['verification_background'] : array(236, 237, 243);
860
+	if ($simpleBGColor) {
861
+			$background_color = array(255, 255, 255);
862
+	} else {
863
+			$background_color = isset($settings['verification_background']) ? $settings['verification_background'] : array(236, 237, 243);
864
+	}
843 865
 
844 866
 	// The color of the characters shown (red, green, blue).
845
-	if ($simpleFGColor)
846
-		$foreground_color = array(0, 0, 0);
847
-	else
867
+	if ($simpleFGColor) {
868
+			$foreground_color = array(0, 0, 0);
869
+	} else
848 870
 	{
849 871
 		$foreground_color = array(64, 101, 136);
850 872
 
851 873
 		// Has the theme author requested a custom color?
852
-		if (isset($settings['verification_foreground']))
853
-			$foreground_color = $settings['verification_foreground'];
874
+		if (isset($settings['verification_foreground'])) {
875
+					$foreground_color = $settings['verification_foreground'];
876
+		}
854 877
 	}
855 878
 
856
-	if (!is_dir($settings['default_theme_dir'] . '/fonts'))
857
-		return false;
879
+	if (!is_dir($settings['default_theme_dir'] . '/fonts')) {
880
+			return false;
881
+	}
858 882
 
859 883
 	// Get a list of the available fonts.
860 884
 	$font_dir = dir($settings['default_theme_dir'] . '/fonts');
@@ -865,25 +889,28 @@  discard block
 block discarded – undo
865 889
 	{
866 890
 		if (preg_match('~^(.+)\.gdf$~', $entry, $matches) === 1)
867 891
 		{
868
-			if ($endian ^ (strpos($entry, '_end.gdf') === false))
869
-				$font_list[] = $entry;
892
+			if ($endian ^ (strpos($entry, '_end.gdf') === false)) {
893
+							$font_list[] = $entry;
894
+			}
895
+		} elseif (preg_match('~^(.+)\.ttf$~', $entry, $matches) === 1) {
896
+					$ttfont_list[] = $entry;
870 897
 		}
871
-		elseif (preg_match('~^(.+)\.ttf$~', $entry, $matches) === 1)
872
-			$ttfont_list[] = $entry;
873 898
 	}
874 899
 
875
-	if (empty($font_list))
876
-		return false;
900
+	if (empty($font_list)) {
901
+			return false;
902
+	}
877 903
 
878 904
 	// For non-hard things don't even change fonts.
879 905
 	if (!$varyFonts)
880 906
 	{
881 907
 		$font_list = array($font_list[0]);
882 908
 		// Try use Screenge if we can - it looks good!
883
-		if (in_array('AnonymousPro.ttf', $ttfont_list))
884
-			$ttfont_list = array('AnonymousPro.ttf');
885
-		else
886
-			$ttfont_list = empty($ttfont_list) ? array() : array($ttfont_list[0]);
909
+		if (in_array('AnonymousPro.ttf', $ttfont_list)) {
910
+					$ttfont_list = array('AnonymousPro.ttf');
911
+		} else {
912
+					$ttfont_list = empty($ttfont_list) ? array() : array($ttfont_list[0]);
913
+		}
887 914
 	}
888 915
 
889 916
 	// Create a list of characters to be shown.
@@ -900,14 +927,16 @@  discard block
 block discarded – undo
900 927
 	}
901 928
 
902 929
 	// Load all fonts and determine the maximum font height.
903
-	foreach ($loaded_fonts as $font_index => $dummy)
904
-		$loaded_fonts[$font_index] = imageloadfont($settings['default_theme_dir'] . '/fonts/' . $font_list[$font_index]);
930
+	foreach ($loaded_fonts as $font_index => $dummy) {
931
+			$loaded_fonts[$font_index] = imageloadfont($settings['default_theme_dir'] . '/fonts/' . $font_list[$font_index]);
932
+	}
905 933
 
906 934
 	// Determine the dimensions of each character.
907
-	if ($imageType == 4 || $imageType == 5)
908
-		$extra = 80;
909
-	else
910
-		$extra = 45;
935
+	if ($imageType == 4 || $imageType == 5) {
936
+			$extra = 80;
937
+	} else {
938
+			$extra = 45;
939
+	}
911 940
 
912 941
 	$total_width = $character_spacing * strlen($code) + $extra;
913 942
 	$max_height = 0;
@@ -928,13 +957,15 @@  discard block
 block discarded – undo
928 957
 	imagefilledrectangle($code_image, 0, 0, $total_width - 1, $max_height - 1, $bg_color);
929 958
 
930 959
 	// Randomize the foreground color a little.
931
-	for ($i = 0; $i < 3; $i++)
932
-		$foreground_color[$i] = mt_rand(max($foreground_color[$i] - 3, 0), min($foreground_color[$i] + 3, 255));
960
+	for ($i = 0; $i < 3; $i++) {
961
+			$foreground_color[$i] = mt_rand(max($foreground_color[$i] - 3, 0), min($foreground_color[$i] + 3, 255));
962
+	}
933 963
 	$fg_color = imagecolorallocate($code_image, $foreground_color[0], $foreground_color[1], $foreground_color[2]);
934 964
 
935 965
 	// Color for the dots.
936
-	for ($i = 0; $i < 3; $i++)
937
-		$dotbgcolor[$i] = $background_color[$i] < $foreground_color[$i] ? mt_rand(0, max($foreground_color[$i] - 20, 0)) : mt_rand(min($foreground_color[$i] + 20, 255), 255);
966
+	for ($i = 0; $i < 3; $i++) {
967
+			$dotbgcolor[$i] = $background_color[$i] < $foreground_color[$i] ? mt_rand(0, max($foreground_color[$i] - 20, 0)) : mt_rand(min($foreground_color[$i] + 20, 255), 255);
968
+	}
938 969
 	$randomness_color = imagecolorallocate($code_image, $dotbgcolor[0], $dotbgcolor[1], $dotbgcolor[2]);
939 970
 
940 971
 	// Some squares/rectanges for new extreme level
@@ -960,10 +991,11 @@  discard block
 block discarded – undo
960 991
 			$can_do_ttf = function_exists('imagettftext');
961 992
 
962 993
 			// How much rotation will we give?
963
-			if ($rotationType == 'none')
964
-				$angle = 0;
965
-			else
966
-				$angle = mt_rand(-100, 100) / ($rotationType == 'high' ? 6 : 10);
994
+			if ($rotationType == 'none') {
995
+							$angle = 0;
996
+			} else {
997
+							$angle = mt_rand(-100, 100) / ($rotationType == 'high' ? 6 : 10);
998
+			}
967 999
 
968 1000
 			// What color shall we do it?
969 1001
 			if ($fontColorType == 'cyclic')
@@ -977,51 +1009,56 @@  discard block
 block discarded – undo
977 1009
 					array(0, 0, 0),
978 1010
 					array(143, 39, 31),
979 1011
 				);
980
-				if (!isset($last_index))
981
-					$last_index = -1;
1012
+				if (!isset($last_index)) {
1013
+									$last_index = -1;
1014
+				}
982 1015
 				$new_index = $last_index;
983
-				while ($last_index == $new_index)
984
-					$new_index = mt_rand(0, count($colors) - 1);
1016
+				while ($last_index == $new_index) {
1017
+									$new_index = mt_rand(0, count($colors) - 1);
1018
+				}
985 1019
 				$char_fg_color = $colors[$new_index];
986 1020
 				$last_index = $new_index;
1021
+			} elseif ($fontColorType == 'random') {
1022
+							$char_fg_color = array(mt_rand(max($foreground_color[0] - 2, 0), $foreground_color[0]), mt_rand(max($foreground_color[1] - 2, 0), $foreground_color[1]), mt_rand(max($foreground_color[2] - 2, 0), $foreground_color[2]));
1023
+			} else {
1024
+							$char_fg_color = array($foreground_color[0], $foreground_color[1], $foreground_color[2]);
987 1025
 			}
988
-			elseif ($fontColorType == 'random')
989
-				$char_fg_color = array(mt_rand(max($foreground_color[0] - 2, 0), $foreground_color[0]), mt_rand(max($foreground_color[1] - 2, 0), $foreground_color[1]), mt_rand(max($foreground_color[2] - 2, 0), $foreground_color[2]));
990
-			else
991
-				$char_fg_color = array($foreground_color[0], $foreground_color[1], $foreground_color[2]);
992 1026
 
993 1027
 			if (!empty($can_do_ttf))
994 1028
 			{
995 1029
 				// GD2 handles font size differently.
996
-				if ($fontSizeRandom)
997
-					$font_size = $gd2 ? mt_rand(17, 19) : mt_rand(18, 25);
998
-				else
999
-					$font_size = $gd2 ? 18 : 24;
1030
+				if ($fontSizeRandom) {
1031
+									$font_size = $gd2 ? mt_rand(17, 19) : mt_rand(18, 25);
1032
+				} else {
1033
+									$font_size = $gd2 ? 18 : 24;
1034
+				}
1000 1035
 
1001 1036
 				// Work out the sizes - also fix the character width cause TTF not quite so wide!
1002 1037
 				$font_x = $fontHorSpace == 'minus' && $cur_x > 0 ? $cur_x - 3 : $cur_x + 5;
1003 1038
 				$font_y = $max_height - ($fontVerPos == 'vrandom' ? mt_rand(2, 8) : ($fontVerPos == 'random' ? mt_rand(3, 5) : 5));
1004 1039
 
1005 1040
 				// What font face?
1006
-				if (!empty($ttfont_list))
1007
-					$fontface = $settings['default_theme_dir'] . '/fonts/' . $ttfont_list[mt_rand(0, count($ttfont_list) - 1)];
1041
+				if (!empty($ttfont_list)) {
1042
+									$fontface = $settings['default_theme_dir'] . '/fonts/' . $ttfont_list[mt_rand(0, count($ttfont_list) - 1)];
1043
+				}
1008 1044
 
1009 1045
 				// What color are we to do it in?
1010 1046
 				$is_reverse = $showReverseChars ? mt_rand(0, 1) : false;
1011 1047
 				$char_color = function_exists('imagecolorallocatealpha') && $fontTrans ? imagecolorallocatealpha($code_image, $char_fg_color[0], $char_fg_color[1], $char_fg_color[2], 50) : imagecolorallocate($code_image, $char_fg_color[0], $char_fg_color[1], $char_fg_color[2]);
1012 1048
 
1013 1049
 				$fontcord = @imagettftext($code_image, $font_size, $angle, $font_x, $font_y, $char_color, $fontface, $character['id']);
1014
-				if (empty($fontcord))
1015
-					$can_do_ttf = false;
1016
-				elseif ($is_reverse)
1050
+				if (empty($fontcord)) {
1051
+									$can_do_ttf = false;
1052
+				} elseif ($is_reverse)
1017 1053
 				{
1018 1054
 					imagefilledpolygon($code_image, $fontcord, 4, $fg_color);
1019 1055
 					// Put the character back!
1020 1056
 					imagettftext($code_image, $font_size, $angle, $font_x, $font_y, $randomness_color, $fontface, $character['id']);
1021 1057
 				}
1022 1058
 
1023
-				if ($can_do_ttf)
1024
-					$cur_x = max($fontcord[2], $fontcord[4]) + ($angle == 0 ? 0 : 3);
1059
+				if ($can_do_ttf) {
1060
+									$cur_x = max($fontcord[2], $fontcord[4]) + ($angle == 0 ? 0 : 3);
1061
+				}
1025 1062
 			}
1026 1063
 
1027 1064
 			if (!$can_do_ttf)
@@ -1040,8 +1077,9 @@  discard block
 block discarded – undo
1040 1077
 				}
1041 1078
 
1042 1079
 				// Sorry, no rotation available.
1043
-				else
1044
-					imagechar($code_image, $loaded_fonts[$character['font']], $cur_x, floor(($max_height - $character['height']) / 2), $character['id'], imagecolorallocate($code_image, $char_fg_color[0], $char_fg_color[1], $char_fg_color[2]));
1080
+				else {
1081
+									imagechar($code_image, $loaded_fonts[$character['font']], $cur_x, floor(($max_height - $character['height']) / 2), $character['id'], imagecolorallocate($code_image, $char_fg_color[0], $char_fg_color[1], $char_fg_color[2]));
1082
+				}
1045 1083
 				$cur_x += $character['width'] + $character_spacing;
1046 1084
 			}
1047 1085
 		}
@@ -1054,17 +1092,22 @@  discard block
 block discarded – undo
1054 1092
 	}
1055 1093
 
1056 1094
 	// Make the background color transparent on the hard image.
1057
-	if (!$simpleBGColor)
1058
-		imagecolortransparent($code_image, $bg_color);
1059
-	if ($hasBorder)
1060
-		imagerectangle($code_image, 0, 0, $total_width - 1, $max_height - 1, $fg_color);
1095
+	if (!$simpleBGColor) {
1096
+			imagecolortransparent($code_image, $bg_color);
1097
+	}
1098
+	if ($hasBorder) {
1099
+			imagerectangle($code_image, 0, 0, $total_width - 1, $max_height - 1, $fg_color);
1100
+	}
1061 1101
 
1062 1102
 	// Add some noise to the background?
1063 1103
 	if ($noiseType != 'none')
1064 1104
 	{
1065
-		for ($i = mt_rand(0, 2); $i < $max_height; $i += mt_rand(1, 2))
1066
-			for ($j = mt_rand(0, 10); $j < $total_width; $j += mt_rand(1, 10))
1067
-				imagesetpixel($code_image, $j, $i, mt_rand(0, 1) ? $fg_color : $randomness_color);
1105
+		for ($i = mt_rand(0, 2); $i < $max_height; $i += mt_rand(1, 2)) {
1106
+					for ($j = mt_rand(0, 10);
1107
+		}
1108
+		$j < $total_width; $j += mt_rand(1, 10)) {
1109
+							imagesetpixel($code_image, $j, $i, mt_rand(0, 1) ? $fg_color : $randomness_color);
1110
+			}
1068 1111
 
1069 1112
 		// Put in some lines too?
1070 1113
 		if ($noiseType != 'extreme')
@@ -1077,8 +1120,7 @@  discard block
 block discarded – undo
1077 1120
 					$x1 = mt_rand(0, $total_width);
1078 1121
 					$x2 = mt_rand(0, $total_width);
1079 1122
 					$y1 = 0; $y2 = $max_height;
1080
-				}
1081
-				else
1123
+				} else
1082 1124
 				{
1083 1125
 					$y1 = mt_rand(0, $max_height);
1084 1126
 					$y2 = mt_rand(0, $max_height);
@@ -1087,8 +1129,7 @@  discard block
 block discarded – undo
1087 1129
 				imagesetthickness($code_image, mt_rand(1, 2));
1088 1130
 				imageline($code_image, $x1, $y1, $x2, $y2, mt_rand(0, 1) ? $fg_color : $randomness_color);
1089 1131
 			}
1090
-		}
1091
-		else
1132
+		} else
1092 1133
 		{
1093 1134
 			// Put in some ellipse
1094 1135
 			$num_ellipse = $noiseType == 'extreme' ? mt_rand(6, 12) : mt_rand(2, 6);
@@ -1108,8 +1149,7 @@  discard block
 block discarded – undo
1108 1149
 	{
1109 1150
 		header('content-type: image/gif');
1110 1151
 		imagegif($code_image);
1111
-	}
1112
-	else
1152
+	} else
1113 1153
 	{
1114 1154
 		header('content-type: image/png');
1115 1155
 		imagepng($code_image);
@@ -1132,25 +1172,29 @@  discard block
 block discarded – undo
1132 1172
 {
1133 1173
 	global $settings;
1134 1174
 
1135
-	if (!is_dir($settings['default_theme_dir'] . '/fonts'))
1136
-		return false;
1175
+	if (!is_dir($settings['default_theme_dir'] . '/fonts')) {
1176
+			return false;
1177
+	}
1137 1178
 
1138 1179
 	// Get a list of the available font directories.
1139 1180
 	$font_dir = dir($settings['default_theme_dir'] . '/fonts');
1140 1181
 	$font_list = array();
1141
-	while ($entry = $font_dir->read())
1142
-		if ($entry[0] !== '.' && is_dir($settings['default_theme_dir'] . '/fonts/' . $entry) && file_exists($settings['default_theme_dir'] . '/fonts/' . $entry . '.gdf'))
1182
+	while ($entry = $font_dir->read()) {
1183
+			if ($entry[0] !== '.' && is_dir($settings['default_theme_dir'] . '/fonts/' . $entry) && file_exists($settings['default_theme_dir'] . '/fonts/' . $entry . '.gdf'))
1143 1184
 			$font_list[] = $entry;
1185
+	}
1144 1186
 
1145
-	if (empty($font_list))
1146
-		return false;
1187
+	if (empty($font_list)) {
1188
+			return false;
1189
+	}
1147 1190
 
1148 1191
 	// Pick a random font.
1149 1192
 	$random_font = $font_list[array_rand($font_list)];
1150 1193
 
1151 1194
 	// Check if the given letter exists.
1152
-	if (!file_exists($settings['default_theme_dir'] . '/fonts/' . $random_font . '/' . $letter . '.png'))
1153
-		return false;
1195
+	if (!file_exists($settings['default_theme_dir'] . '/fonts/' . $random_font . '/' . $letter . '.png')) {
1196
+			return false;
1197
+	}
1154 1198
 
1155 1199
 	// Include it!
1156 1200
 	header('content-type: image/png');
Please login to merge, or discard this patch.
Sources/Subs-Membergroups.php 2 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -243,6 +243,7 @@
 block discarded – undo
243 243
  * @param null|array The groups to remove the member(s) from. If null, the specified members are stripped from all their membergroups.
244 244
  * @param bool $permissionCheckDone Whether we've already checked permissions prior to calling this function
245 245
  * @param bool $ignoreProtected Whether to ignore protected groups
246
+ * @param integer $groups
246 247
  * @return bool Whether the operation was successful
247 248
  */
248 249
 function removeMembersFromGroups($members, $groups = null, $permissionCheckDone = false, $ignoreProtected = false)
Please login to merge, or discard this patch.
Braces   +149 added lines, -112 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Delete one of more membergroups.
@@ -31,15 +32,16 @@  discard block
 block discarded – undo
31 32
 	global $smcFunc, $modSettings, $txt;
32 33
 
33 34
 	// Make sure it's an array.
34
-	if (!is_array($groups))
35
-		$groups = array((int) $groups);
36
-	else
35
+	if (!is_array($groups)) {
36
+			$groups = array((int) $groups);
37
+	} else
37 38
 	{
38 39
 		$groups = array_unique($groups);
39 40
 
40 41
 		// Make sure all groups are integer.
41
-		foreach ($groups as $key => $value)
42
-			$groups[$key] = (int) $value;
42
+		foreach ($groups as $key => $value) {
43
+					$groups[$key] = (int) $value;
44
+		}
43 45
 	}
44 46
 
45 47
 	// Some groups are protected (guests, administrators, moderators, newbies).
@@ -56,15 +58,17 @@  discard block
 block discarded – undo
56 58
 				'is_protected' => 1,
57 59
 			)
58 60
 		);
59
-		while ($row = $smcFunc['db_fetch_assoc']($request))
60
-			$protected_groups[] = $row['id_group'];
61
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
62
+					$protected_groups[] = $row['id_group'];
63
+		}
61 64
 		$smcFunc['db_free_result']($request);
62 65
 	}
63 66
 
64 67
 	// Make sure they don't delete protected groups!
65 68
 	$groups = array_diff($groups, array_unique($protected_groups));
66
-	if (empty($groups))
67
-		return 'no_group_found';
69
+	if (empty($groups)) {
70
+			return 'no_group_found';
71
+	}
68 72
 
69 73
 	// Make sure they don't try to delete a group attached to a paid subscription.
70 74
 	$subscriptions = array();
@@ -74,13 +78,14 @@  discard block
 block discarded – undo
74 78
 		ORDER BY name');
75 79
 	while ($row = $smcFunc['db_fetch_assoc']($request))
76 80
 	{
77
-		if (in_array($row['id_group'], $groups))
78
-			$subscriptions[] = $row['name'];
79
-		else
81
+		if (in_array($row['id_group'], $groups)) {
82
+					$subscriptions[] = $row['name'];
83
+		} else
80 84
 		{
81 85
 			$add_groups = explode(',', $row['add_groups']);
82
-			if (count(array_intersect($add_groups, $groups)) != 0)
83
-				$subscriptions[] = $row['name'];
86
+			if (count(array_intersect($add_groups, $groups)) != 0) {
87
+							$subscriptions[] = $row['name'];
88
+			}
84 89
 		}
85 90
 	}
86 91
 	$smcFunc['db_free_result']($request);
@@ -101,8 +106,9 @@  discard block
 block discarded – undo
101 106
 			'group_list' => $groups,
102 107
 		)
103 108
 	);
104
-	while ($row = $smcFunc['db_fetch_assoc']($request))
105
-		logAction('delete_group', array('group' => $row['group_name']), 'admin');
109
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
110
+			logAction('delete_group', array('group' => $row['group_name']), 'admin');
111
+	}
106 112
 	$smcFunc['db_free_result']($request);
107 113
 
108 114
 	call_integration_hook('integrate_delete_membergroups', array($groups));
@@ -187,12 +193,14 @@  discard block
 block discarded – undo
187 193
 		)
188 194
 	);
189 195
 	$updates = array();
190
-	while ($row = $smcFunc['db_fetch_assoc']($request))
191
-		$updates[$row['additional_groups']][] = $row['id_member'];
196
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
197
+			$updates[$row['additional_groups']][] = $row['id_member'];
198
+	}
192 199
 	$smcFunc['db_free_result']($request);
193 200
 
194
-	foreach ($updates as $additional_groups => $memberArray)
195
-		updateMemberData($memberArray, array('additional_groups' => implode(',', array_diff(explode(',', $additional_groups), $groups))));
201
+	foreach ($updates as $additional_groups => $memberArray) {
202
+			updateMemberData($memberArray, array('additional_groups' => implode(',', array_diff(explode(',', $additional_groups), $groups))));
203
+	}
196 204
 
197 205
 	// No boards can provide access to these membergroups anymore.
198 206
 	$request = $smcFunc['db_query']('', '
@@ -204,12 +212,13 @@  discard block
 block discarded – undo
204 212
 		)
205 213
 	);
206 214
 	$updates = array();
207
-	while ($row = $smcFunc['db_fetch_assoc']($request))
208
-		$updates[$row['member_groups']][] = $row['id_board'];
215
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
216
+			$updates[$row['member_groups']][] = $row['id_board'];
217
+	}
209 218
 	$smcFunc['db_free_result']($request);
210 219
 
211
-	foreach ($updates as $member_groups => $boardArray)
212
-		$smcFunc['db_query']('', '
220
+	foreach ($updates as $member_groups => $boardArray) {
221
+			$smcFunc['db_query']('', '
213 222
 			UPDATE {db_prefix}boards
214 223
 			SET member_groups = {string:member_groups}
215 224
 			WHERE id_board IN ({array_int:board_lists})',
@@ -218,6 +227,7 @@  discard block
 block discarded – undo
218 227
 				'member_groups' => implode(',', array_diff(explode(',', $member_groups), $groups)),
219 228
 			)
220 229
 		);
230
+	}
221 231
 
222 232
 	// Recalculate the post groups, as they likely changed.
223 233
 	updateStats('postgroups');
@@ -225,8 +235,9 @@  discard block
 block discarded – undo
225 235
 	// Make a note of the fact that the cache may be wrong.
226 236
 	$settings_update = array('settings_updated' => time());
227 237
 	// Have we deleted the spider group?
228
-	if (isset($modSettings['spider_group']) && in_array($modSettings['spider_group'], $groups))
229
-		$settings_update['spider_group'] = 0;
238
+	if (isset($modSettings['spider_group']) && in_array($modSettings['spider_group'], $groups)) {
239
+			$settings_update['spider_group'] = 0;
240
+	}
230 241
 
231 242
 	updateSettings($settings_update);
232 243
 
@@ -250,22 +261,24 @@  discard block
 block discarded – undo
250 261
 	global $smcFunc, $modSettings, $sourcedir;
251 262
 
252 263
 	// You're getting nowhere without this permission, unless of course you are the group's moderator.
253
-	if (!$permissionCheckDone)
254
-		isAllowedTo('manage_membergroups');
264
+	if (!$permissionCheckDone) {
265
+			isAllowedTo('manage_membergroups');
266
+	}
255 267
 
256 268
 	// Assume something will happen.
257 269
 	updateSettings(array('settings_updated' => time()));
258 270
 
259 271
 	// Cleaning the input.
260
-	if (!is_array($members))
261
-		$members = array((int) $members);
262
-	else
272
+	if (!is_array($members)) {
273
+			$members = array((int) $members);
274
+	} else
263 275
 	{
264 276
 		$members = array_unique($members);
265 277
 
266 278
 		// Cast the members to integer.
267
-		foreach ($members as $key => $value)
268
-			$members[$key] = (int) $value;
279
+		foreach ($members as $key => $value) {
280
+					$members[$key] = (int) $value;
281
+		}
269 282
 	}
270 283
 
271 284
 	// Before we get started, let's check we won't leave the admin group empty!
@@ -277,14 +290,15 @@  discard block
 block discarded – undo
277 290
 		// Remove any admins if there are too many.
278 291
 		$non_changing_admins = array_diff(array_keys($admins), $members);
279 292
 
280
-		if (empty($non_changing_admins))
281
-			$members = array_diff($members, array_keys($admins));
293
+		if (empty($non_changing_admins)) {
294
+					$members = array_diff($members, array_keys($admins));
295
+		}
282 296
 	}
283 297
 
284 298
 	// Just in case.
285
-	if (empty($members))
286
-		return false;
287
-	elseif ($groups === null)
299
+	if (empty($members)) {
300
+			return false;
301
+	} elseif ($groups === null)
288 302
 	{
289 303
 		// Wanna remove all groups from these members? That's easy.
290 304
 		$smcFunc['db_query']('', '
@@ -306,20 +320,21 @@  discard block
 block discarded – undo
306 320
 		updateStats('postgroups', $members);
307 321
 
308 322
 		// Log what just happened.
309
-		foreach ($members as $member)
310
-			logAction('removed_all_groups', array('member' => $member), 'admin');
323
+		foreach ($members as $member) {
324
+					logAction('removed_all_groups', array('member' => $member), 'admin');
325
+		}
311 326
 
312 327
 		return true;
313
-	}
314
-	elseif (!is_array($groups))
315
-		$groups = array((int) $groups);
316
-	else
328
+	} elseif (!is_array($groups)) {
329
+			$groups = array((int) $groups);
330
+	} else
317 331
 	{
318 332
 		$groups = array_unique($groups);
319 333
 
320 334
 		// Make sure all groups are integer.
321
-		foreach ($groups as $key => $value)
322
-			$groups[$key] = (int) $value;
335
+		foreach ($groups as $key => $value) {
336
+					$groups[$key] = (int) $value;
337
+		}
323 338
 	}
324 339
 
325 340
 	// Fetch a list of groups members cannot be assigned to explicitly, and the group names of the ones we want.
@@ -335,10 +350,11 @@  discard block
 block discarded – undo
335 350
 	$group_names = array();
336 351
 	while ($row = $smcFunc['db_fetch_assoc']($request))
337 352
 	{
338
-		if ($row['min_posts'] != -1)
339
-			$implicitGroups[] = $row['id_group'];
340
-		else
341
-			$group_names[$row['id_group']] = $row['group_name'];
353
+		if ($row['min_posts'] != -1) {
354
+					$implicitGroups[] = $row['id_group'];
355
+		} else {
356
+					$group_names[$row['id_group']] = $row['group_name'];
357
+		}
342 358
 	}
343 359
 	$smcFunc['db_free_result']($request);
344 360
 
@@ -357,8 +373,9 @@  discard block
 block discarded – undo
357 373
 			)
358 374
 		);
359 375
 		$protected_groups = array(1);
360
-		while ($row = $smcFunc['db_fetch_assoc']($request))
361
-			$protected_groups[] = $row['id_group'];
376
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
377
+					$protected_groups[] = $row['id_group'];
378
+		}
362 379
 		$smcFunc['db_free_result']($request);
363 380
 
364 381
 		// If you're not an admin yourself, you can't touch protected groups!
@@ -366,8 +383,9 @@  discard block
 block discarded – undo
366 383
 	}
367 384
 
368 385
 	// Only continue if there are still groups and members left.
369
-	if (empty($groups) || empty($members))
370
-		return false;
386
+	if (empty($groups) || empty($members)) {
387
+			return false;
388
+	}
371 389
 
372 390
 	// First, reset those who have this as their primary group - this is the easy one.
373 391
 	$log_inserts = array();
@@ -381,8 +399,9 @@  discard block
 block discarded – undo
381 399
 			'member_list' => $members,
382 400
 		)
383 401
 	);
384
-	while ($row = $smcFunc['db_fetch_assoc']($request))
385
-		$log_inserts[] = array('group' => $group_names[$row['id_group']], 'member' => $row['id_member']);
402
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
403
+			$log_inserts[] = array('group' => $group_names[$row['id_group']], 'member' => $row['id_member']);
404
+	}
386 405
 	$smcFunc['db_free_result']($request);
387 406
 
388 407
 	$smcFunc['db_query']('', '
@@ -414,16 +433,17 @@  discard block
 block discarded – undo
414 433
 	while ($row = $smcFunc['db_fetch_assoc']($request))
415 434
 	{
416 435
 		// What log entries must we make for this one, eh?
417
-		foreach (explode(',', $row['additional_groups']) as $group)
418
-			if (in_array($group, $groups))
436
+		foreach (explode(',', $row['additional_groups']) as $group) {
437
+					if (in_array($group, $groups))
419 438
 				$log_inserts[] = array('group' => $group_names[$group], 'member' => $row['id_member']);
439
+		}
420 440
 
421 441
 		$updates[$row['additional_groups']][] = $row['id_member'];
422 442
 	}
423 443
 	$smcFunc['db_free_result']($request);
424 444
 
425
-	foreach ($updates as $additional_groups => $memberArray)
426
-		$smcFunc['db_query']('', '
445
+	foreach ($updates as $additional_groups => $memberArray) {
446
+			$smcFunc['db_query']('', '
427 447
 			UPDATE {db_prefix}members
428 448
 			SET additional_groups = {string:additional_groups}
429 449
 			WHERE id_member IN ({array_int:member_list})',
@@ -432,6 +452,7 @@  discard block
 block discarded – undo
432 452
 				'additional_groups' => implode(',', array_diff(explode(',', $additional_groups), $groups)),
433 453
 			)
434 454
 		);
455
+	}
435 456
 
436 457
 	// Their post groups may have changed now...
437 458
 	updateStats('postgroups', $members);
@@ -440,8 +461,9 @@  discard block
 block discarded – undo
440 461
 	if (!empty($log_inserts) && !empty($modSettings['modlog_enabled']))
441 462
 	{
442 463
 		require_once($sourcedir . '/Logging.php');
443
-		foreach ($log_inserts as $extra)
444
-			logAction('removed_from_group', $extra, 'admin');
464
+		foreach ($log_inserts as $extra) {
465
+					logAction('removed_from_group', $extra, 'admin');
466
+		}
445 467
 	}
446 468
 
447 469
 	// Mission successful.
@@ -477,21 +499,23 @@  discard block
 block discarded – undo
477 499
 	global $smcFunc, $sourcedir;
478 500
 
479 501
 	// Show your licence, but only if it hasn't been done yet.
480
-	if (!$permissionCheckDone)
481
-		isAllowedTo('manage_membergroups');
502
+	if (!$permissionCheckDone) {
503
+			isAllowedTo('manage_membergroups');
504
+	}
482 505
 
483 506
 	// Make sure we don't keep old stuff cached.
484 507
 	updateSettings(array('settings_updated' => time()));
485 508
 
486
-	if (!is_array($members))
487
-		$members = array((int) $members);
488
-	else
509
+	if (!is_array($members)) {
510
+			$members = array((int) $members);
511
+	} else
489 512
 	{
490 513
 		$members = array_unique($members);
491 514
 
492 515
 		// Make sure all members are integer.
493
-		foreach ($members as $key => $value)
494
-			$members[$key] = (int) $value;
516
+		foreach ($members as $key => $value) {
517
+					$members[$key] = (int) $value;
518
+		}
495 519
 	}
496 520
 	$group = (int) $group;
497 521
 
@@ -508,20 +532,23 @@  discard block
 block discarded – undo
508 532
 	$group_names = array();
509 533
 	while ($row = $smcFunc['db_fetch_assoc']($request))
510 534
 	{
511
-		if ($row['min_posts'] != -1)
512
-			$implicitGroups[] = $row['id_group'];
513
-		else
514
-			$group_names[$row['id_group']] = $row['group_name'];
535
+		if ($row['min_posts'] != -1) {
536
+					$implicitGroups[] = $row['id_group'];
537
+		} else {
538
+					$group_names[$row['id_group']] = $row['group_name'];
539
+		}
515 540
 	}
516 541
 	$smcFunc['db_free_result']($request);
517 542
 
518 543
 	// Sorry, you can't join an implicit group.
519
-	if (in_array($group, $implicitGroups) || empty($members))
520
-		return false;
544
+	if (in_array($group, $implicitGroups) || empty($members)) {
545
+			return false;
546
+	}
521 547
 
522 548
 	// Only admins can add admins...
523
-	if (!allowedTo('admin_forum') && $group == 1)
524
-		return false;
549
+	if (!allowedTo('admin_forum') && $group == 1) {
550
+			return false;
551
+	}
525 552
 	// ... and assign protected groups!
526 553
 	elseif (!allowedTo('admin_forum') && !$ignoreProtected)
527 554
 	{
@@ -539,13 +566,14 @@  discard block
 block discarded – undo
539 566
 		$smcFunc['db_free_result']($request);
540 567
 
541 568
 		// Is it protected?
542
-		if ($is_protected == 1)
543
-			return false;
569
+		if ($is_protected == 1) {
570
+					return false;
571
+		}
544 572
 	}
545 573
 
546 574
 	// Do the actual updates.
547
-	if ($type == 'only_additional')
548
-		$smcFunc['db_query']('', '
575
+	if ($type == 'only_additional') {
576
+			$smcFunc['db_query']('', '
549 577
 			UPDATE {db_prefix}members
550 578
 			SET additional_groups = CASE WHEN additional_groups = {string:blank_string} THEN {string:id_group_string} ELSE CONCAT(additional_groups, {string:id_group_string_extend}) END
551 579
 			WHERE id_member IN ({array_int:member_list})
@@ -559,8 +587,8 @@  discard block
 block discarded – undo
559 587
 				'blank_string' => '',
560 588
 			)
561 589
 		);
562
-	elseif ($type == 'only_primary' || $type == 'force_primary')
563
-		$smcFunc['db_query']('', '
590
+	} elseif ($type == 'only_primary' || $type == 'force_primary') {
591
+			$smcFunc['db_query']('', '
564 592
 			UPDATE {db_prefix}members
565 593
 			SET id_group = {int:id_group}
566 594
 			WHERE id_member IN ({array_int:member_list})' . ($type == 'force_primary' ? '' : '
@@ -572,8 +600,8 @@  discard block
 block discarded – undo
572 600
 				'regular_group' => 0,
573 601
 			)
574 602
 		);
575
-	elseif ($type == 'auto')
576
-		$smcFunc['db_query']('', '
603
+	} elseif ($type == 'auto') {
604
+			$smcFunc['db_query']('', '
577 605
 			UPDATE {db_prefix}members
578 606
 			SET
579 607
 				id_group = CASE WHEN id_group = {int:regular_group} THEN {int:id_group} ELSE id_group END,
@@ -592,9 +620,11 @@  discard block
 block discarded – undo
592 620
 				'id_group_string_extend' => ',' . $group,
593 621
 			)
594 622
 		);
623
+	}
595 624
 	// Ack!!?  What happened?
596
-	else
597
-		trigger_error('addMembersToGroup(): Unknown type \'' . $type . '\'', E_USER_WARNING);
625
+	else {
626
+			trigger_error('addMembersToGroup(): Unknown type \'' . $type . '\'', E_USER_WARNING);
627
+	}
598 628
 
599 629
 	call_integration_hook('integrate_add_members_to_group', array($members, $group, &$group_names));
600 630
 
@@ -603,8 +633,9 @@  discard block
 block discarded – undo
603 633
 
604 634
 	// Log the data.
605 635
 	require_once($sourcedir . '/Logging.php');
606
-	foreach ($members as $member)
607
-		logAction('added_to_group', array('group' => $group_names[$group], 'member_affected' => $member), 'admin');
636
+	foreach ($members as $member) {
637
+			logAction('added_to_group', array('group' => $group_names[$group], 'member_affected' => $member), 'admin');
638
+	}
608 639
 
609 640
 	return true;
610 641
 }
@@ -632,8 +663,9 @@  discard block
 block discarded – undo
632 663
 		)
633 664
 	);
634 665
 	$members = array();
635
-	while ($row = $smcFunc['db_fetch_assoc']($request))
636
-		$members[$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
666
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
667
+			$members[$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
668
+	}
637 669
 	$smcFunc['db_free_result']($request);
638 670
 
639 671
 	// If there are more than $limit members, add a 'more' link.
@@ -641,10 +673,10 @@  discard block
 block discarded – undo
641 673
 	{
642 674
 		array_pop($members);
643 675
 		return true;
676
+	} else {
677
+			return false;
678
+	}
644 679
 	}
645
-	else
646
-		return false;
647
-}
648 680
 
649 681
 /**
650 682
  * Retrieve a list of (visible) membergroups used by the cache.
@@ -669,8 +701,9 @@  discard block
 block discarded – undo
669 701
 		)
670 702
 	);
671 703
 	$groupCache = array();
672
-	while ($row = $smcFunc['db_fetch_assoc']($request))
673
-		$groupCache[] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_group'] . '" ' . ($row['online_color'] ? 'style="color: ' . $row['online_color'] . '"' : '') . '>' . $row['group_name'] . '</a>';
704
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
705
+			$groupCache[] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_group'] . '" ' . ($row['online_color'] ? 'style="color: ' . $row['online_color'] . '"' : '') . '>' . $row['group_name'] . '</a>';
706
+	}
674 707
 	$smcFunc['db_free_result']($request);
675 708
 
676 709
 	return array(
@@ -716,8 +749,9 @@  discard block
 block discarded – undo
716 749
 	while ($row = $smcFunc['db_fetch_assoc']($request))
717 750
 	{
718 751
 		// We only list the groups they can see.
719
-		if ($row['hidden'] && !$row['can_moderate'] && !allowedTo('manage_membergroups'))
720
-			continue;
752
+		if ($row['hidden'] && !$row['can_moderate'] && !allowedTo('manage_membergroups')) {
753
+					continue;
754
+		}
721 755
 
722 756
 		$row['icons'] = explode('#', $row['icons']);
723 757
 
@@ -752,12 +786,11 @@  discard block
 block discarded – undo
752 786
 					'group_list' => $group_ids,
753 787
 				)
754 788
 			);
755
-			while ($row = $smcFunc['db_fetch_assoc']($query))
756
-				$groups[$row['id_group']]['num_members'] += $row['num_members'];
789
+			while ($row = $smcFunc['db_fetch_assoc']($query)) {
790
+							$groups[$row['id_group']]['num_members'] += $row['num_members'];
791
+			}
757 792
 			$smcFunc['db_free_result']($query);
758
-		}
759
-
760
-		else
793
+		} else
761 794
 		{
762 795
 			$query = $smcFunc['db_query']('', '
763 796
 				SELECT id_group, COUNT(*) AS num_members
@@ -768,8 +801,9 @@  discard block
 block discarded – undo
768 801
 					'group_list' => $group_ids,
769 802
 				)
770 803
 			);
771
-			while ($row = $smcFunc['db_fetch_assoc']($query))
772
-				$groups[$row['id_group']]['num_members'] += $row['num_members'];
804
+			while ($row = $smcFunc['db_fetch_assoc']($query)) {
805
+							$groups[$row['id_group']]['num_members'] += $row['num_members'];
806
+			}
773 807
 			$smcFunc['db_free_result']($query);
774 808
 
775 809
 			// Only do additional groups if we can moderate...
@@ -788,8 +822,9 @@  discard block
 block discarded – undo
788 822
 						'blank_string' => '',
789 823
 					)
790 824
 				);
791
-				while ($row = $smcFunc['db_fetch_assoc']($query))
792
-					$groups[$row['id_group']]['num_members'] += $row['num_members'];
825
+				while ($row = $smcFunc['db_fetch_assoc']($query)) {
826
+									$groups[$row['id_group']]['num_members'] += $row['num_members'];
827
+				}
793 828
 				$smcFunc['db_free_result']($query);
794 829
 			}
795 830
 		}
@@ -803,8 +838,9 @@  discard block
 block discarded – undo
803 838
 				'group_list' => $group_ids,
804 839
 			)
805 840
 		);
806
-		while ($row = $smcFunc['db_fetch_assoc']($query))
807
-			$groups[$row['id_group']]['moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
841
+		while ($row = $smcFunc['db_fetch_assoc']($query)) {
842
+					$groups[$row['id_group']]['moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
843
+		}
808 844
 		$smcFunc['db_free_result']($query);
809 845
 	}
810 846
 
@@ -813,8 +849,9 @@  discard block
 block discarded – undo
813 849
 	{
814 850
 		$sort_ascending = strpos($sort, 'DESC') === false;
815 851
 
816
-		foreach ($groups as $group)
817
-			$sort_array[] = $group['id_group'] != 3 ? (int) $group['num_members'] : -1;
852
+		foreach ($groups as $group) {
853
+					$sort_array[] = $group['id_group'] != 3 ? (int) $group['num_members'] : -1;
854
+		}
818 855
 
819 856
 		array_multisort($sort_array, $sort_ascending ? SORT_ASC : SORT_DESC, SORT_REGULAR, $groups);
820 857
 	}
Please login to merge, or discard this patch.
Sources/Subs-Menu.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -286,7 +286,7 @@
 block discarded – undo
286 286
 /**
287 287
  * Delete a menu.
288 288
  * @param string $menu_id The ID of the menu to destroy or 'last' for the most recent one
289
- * @return bool|void False if the menu doesn't exist, nothing otherwise
289
+ * @return false|null False if the menu doesn't exist, nothing otherwise
290 290
  */
291 291
 function destroyMenu($menu_id = 'last')
292 292
 {
Please login to merge, or discard this patch.
Braces   +84 added lines, -63 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Create a menu.
@@ -64,22 +65,26 @@  discard block
 block discarded – undo
64 65
 	$menu_context['current_action'] = isset($menuOptions['action']) ? $menuOptions['action'] : $context['current_action'];
65 66
 
66 67
 	// Allow extend *any* menu with a single hook
67
-	if (!empty($menu_context['current_action']))
68
-		call_integration_hook('integrate_' . $menu_context['current_action'] . '_areas', array(&$menuData));
68
+	if (!empty($menu_context['current_action'])) {
69
+			call_integration_hook('integrate_' . $menu_context['current_action'] . '_areas', array(&$menuData));
70
+	}
69 71
 
70 72
 	// What is the current area selected?
71
-	if (isset($menuOptions['current_area']) || isset($_GET['area']))
72
-		$menu_context['current_area'] = isset($menuOptions['current_area']) ? $menuOptions['current_area'] : $_GET['area'];
73
+	if (isset($menuOptions['current_area']) || isset($_GET['area'])) {
74
+			$menu_context['current_area'] = isset($menuOptions['current_area']) ? $menuOptions['current_area'] : $_GET['area'];
75
+	}
73 76
 
74 77
 	// Build a list of additional parameters that should go in the URL.
75 78
 	$menu_context['extra_parameters'] = '';
76
-	if (!empty($menuOptions['extra_url_parameters']))
77
-		foreach ($menuOptions['extra_url_parameters'] as $key => $value)
79
+	if (!empty($menuOptions['extra_url_parameters'])) {
80
+			foreach ($menuOptions['extra_url_parameters'] as $key => $value)
78 81
 			$menu_context['extra_parameters'] .= ';' . $key . '=' . $value;
82
+	}
79 83
 
80 84
 	// Only include the session ID in the URL if it's strictly necessary.
81
-	if (empty($menuOptions['disable_url_session_check']))
82
-		$menu_context['extra_parameters'] .= ';' . $context['session_var'] . '=' . $context['session_id'];
85
+	if (empty($menuOptions['disable_url_session_check'])) {
86
+			$menu_context['extra_parameters'] .= ';' . $context['session_var'] . '=' . $context['session_id'];
87
+	}
83 88
 
84 89
 	$include_data = array();
85 90
 
@@ -87,8 +92,9 @@  discard block
 block discarded – undo
87 92
 	foreach ($menuData as $section_id => $section)
88 93
 	{
89 94
 		// Is this enabled - or has as permission check - which fails?
90
-		if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($section['permission']) && !allowedTo($section['permission'])))
91
-			continue;
95
+		if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($section['permission']) && !allowedTo($section['permission']))) {
96
+					continue;
97
+		}
92 98
 
93 99
 		// Now we cycle through the sections to pick the right area.
94 100
 		foreach ($section['areas'] as $area_id => $area)
@@ -110,67 +116,67 @@  discard block
 block discarded – undo
110 116
 					if (empty($area['hidden']))
111 117
 					{
112 118
 						// First time this section?
113
-						if (!isset($menu_context['sections'][$section_id]))
114
-							$menu_context['sections'][$section_id]['title'] = $section['title'];
119
+						if (!isset($menu_context['sections'][$section_id])) {
120
+													$menu_context['sections'][$section_id]['title'] = $section['title'];
121
+						}
115 122
 
116 123
 						// Is there a counter amount to show for this section?
117
-						if (!empty($section['amt']))
118
-							$menu_context['sections'][$section_id]['amt'] = $section['amt'];
124
+						if (!empty($section['amt'])) {
125
+													$menu_context['sections'][$section_id]['amt'] = $section['amt'];
126
+						}
119 127
 
120 128
 						$menu_context['sections'][$section_id]['areas'][$area_id] = array('label' => isset($area['label']) ? $area['label'] : $txt[$area_id]);
121 129
 						// We'll need the ID as well...
122 130
 						$menu_context['sections'][$section_id]['id'] = $section_id;
123 131
 						// Does it have a custom URL?
124
-						if (isset($area['custom_url']))
125
-							$menu_context['sections'][$section_id]['areas'][$area_id]['url'] = $area['custom_url'];
132
+						if (isset($area['custom_url'])) {
133
+													$menu_context['sections'][$section_id]['areas'][$area_id]['url'] = $area['custom_url'];
134
+						}
126 135
 
127 136
 						// Is there a counter amount to show for this area?
128
-						if (!empty($area['amt']))
129
-							$menu_context['sections'][$section_id]['areas'][$area_id]['amt'] = $area['amt'];
137
+						if (!empty($area['amt'])) {
138
+													$menu_context['sections'][$section_id]['areas'][$area_id]['amt'] = $area['amt'];
139
+						}
130 140
 
131 141
 						// Does this area have its own icon?
132 142
 						if (!isset($area['force_menu_into_arms_of_another_menu']) && $user_info['name'] == 'iamanoompaloompa')
133 143
 						{
134 144
 							$menu_context['sections'][$section_id]['areas'][$area_id] = $smcFunc['json_decode'](base64_decode('eyJsYWJlbCI6Ik9vbXBhIExvb21wYSIsInVybCI6Imh0dHBzOlwvXC9lbi53aWtpcGVkaWEub3JnXC93aWtpXC9Pb21wYV9Mb29tcGFzPyIsImljb24iOiI8aW1nIHNyYz1cImh0dHBzOlwvXC93d3cuc2ltcGxlbWFjaGluZXMub3JnXC9pbWFnZXNcL29vbXBhLmdpZlwiIGFsdD1cIkknbSBhbiBPb21wYSBMb29tcGFcIiBcLz4ifQ=='), true);
135
-						}
136
-						elseif (isset($area['icon']))
145
+						} elseif (isset($area['icon']))
137 146
 						{
138 147
 							if (file_exists($settings['theme_dir'] . '/images/admin/' . $area['icon']))
139 148
 							{
140 149
 								$menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<img src="' . $settings['images_url'] . '/admin/' . $area['icon'] . '" alt="">';
141
-							}
142
-							elseif (file_exists($settings['default_theme_dir'] . '/images/admin/' . $area['icon']))
150
+							} elseif (file_exists($settings['default_theme_dir'] . '/images/admin/' . $area['icon']))
143 151
 							{
144 152
 								$menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<img src="' . $settings['default_images_url'] . '/admin/' . $area['icon'] . '" alt="">';
153
+							} else {
154
+															$menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area['icon'] . '"></span>';
145 155
 							}
146
-							else
147
-								$menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area['icon'] . '"></span>';
156
+						} else {
157
+													$menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area_id . '"></span>';
148 158
 						}
149
-						else
150
-							$menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area_id . '"></span>';
151 159
 
152 160
 						if (isset($area['icon_class']) && empty($menu_context['sections'][$section_id]['areas'][$area_id]['icon']))
153 161
 						{
154 162
 							$menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . $area['icon_class'];
155
-						}
156
-						elseif (isset($area['icon']))
163
+						} elseif (isset($area['icon']))
157 164
 						{
158 165
 							if (substr($area['icon'], -4) === '.png' || substr($area['icon'], -4) === '.gif')
159 166
 							{
160 167
 								if (file_exists($settings['theme_dir'] . '/images/admin/big/' . $area['icon']))
161 168
 								{
162 169
 									$menu_context['sections'][$section_id]['areas'][$area_id]['icon_file'] = $settings['theme_url'] . '/images/admin/big/' . $area['icon'];
163
-								}
164
-								elseif (file_exists($settings['default_theme_dir'] . '/images/admin/big/' . $area['icon']))
170
+								} elseif (file_exists($settings['default_theme_dir'] . '/images/admin/big/' . $area['icon']))
165 171
 								{
166 172
 									$menu_context['sections'][$section_id]['areas'][$area_id]['icon_file'] = $settings['default_theme_url'] . '/images/admin/big/' . $area['icon'];
167 173
 								}
168 174
 							}
169 175
 
170 176
 							$menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . str_replace(array('.png', '.gif'), '', $area['icon']);
177
+						} else {
178
+													$menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . str_replace(array('.png', '.gif'), '', $area_id);
171 179
 						}
172
-						else
173
-							$menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . str_replace(array('.png', '.gif'), '', $area_id);
174 180
 
175 181
 						// This is a shortcut for Font-Icon users so they don't have to re-do whole CSS.
176 182
 						$menu_context['sections'][$section_id]['areas'][$area_id]['plain_class'] = !empty($area['icon']) ? $area['icon'] : '';
@@ -187,39 +193,46 @@  discard block
 block discarded – undo
187 193
 							{
188 194
 								if ((empty($sub[1]) || allowedTo($sub[1])) && (!isset($sub['enabled']) || !empty($sub['enabled'])))
189 195
 								{
190
-									if ($first_sa == null)
191
-										$first_sa = $sa;
196
+									if ($first_sa == null) {
197
+																			$first_sa = $sa;
198
+									}
192 199
 
193 200
 									$menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa] = array('label' => $sub[0]);
194 201
 									// Custom URL?
195
-									if (isset($sub['url']))
196
-										$menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['url'] = $sub['url'];
202
+									if (isset($sub['url'])) {
203
+																			$menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['url'] = $sub['url'];
204
+									}
197 205
 
198 206
 									// Is there a counter amount to show for this subsection?
199
-									if (!empty($sub['amt']))
200
-										$menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['amt'] = $sub['amt'];
207
+									if (!empty($sub['amt'])) {
208
+																			$menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['amt'] = $sub['amt'];
209
+									}
201 210
 
202 211
 									// A bit complicated - but is this set?
203 212
 									if ($menu_context['current_area'] == $area_id)
204 213
 									{
205 214
 										// Save which is the first...
206
-										if (empty($first_sa))
207
-											$first_sa = $sa;
215
+										if (empty($first_sa)) {
216
+																					$first_sa = $sa;
217
+										}
208 218
 
209 219
 										// Is this the current subsection?
210
-										if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == $sa)
211
-											$menu_context['current_subsection'] = $sa;
220
+										if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == $sa) {
221
+																					$menu_context['current_subsection'] = $sa;
222
+										}
212 223
 										// Otherwise is it the default?
213
-										elseif (!isset($menu_context['current_subsection']) && !empty($sub[2]))
214
-											$menu_context['current_subsection'] = $sa;
224
+										elseif (!isset($menu_context['current_subsection']) && !empty($sub[2])) {
225
+																					$menu_context['current_subsection'] = $sa;
226
+										}
215 227
 									}
216 228
 
217 229
 									// Let's assume this is the last, for now.
218 230
 									$last_sa = $sa;
219 231
 								}
220 232
 								// Mark it as disabled...
221
-								else
222
-									$menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['disabled'] = true;
233
+								else {
234
+																	$menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['disabled'] = true;
235
+								}
223 236
 							}
224 237
 
225 238
 							// Set which one is first, last and selected in the group.
@@ -228,8 +241,9 @@  discard block
 block discarded – undo
228 241
 								$menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$context['right_to_left'] ? $last_sa : $first_sa]['is_first'] = true;
229 242
 								$menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$context['right_to_left'] ? $first_sa : $last_sa]['is_last'] = true;
230 243
 
231
-								if ($menu_context['current_area'] == $area_id && !isset($menu_context['current_subsection']))
232
-									$menu_context['current_subsection'] = $first_sa;
244
+								if ($menu_context['current_area'] == $area_id && !isset($menu_context['current_subsection'])) {
245
+																	$menu_context['current_subsection'] = $first_sa;
246
+								}
233 247
 							}
234 248
 						}
235 249
 					}
@@ -263,23 +277,26 @@  discard block
 block discarded – undo
263 277
 	$menu_context['base_url'] = isset($menuOptions['base_url']) ? $menuOptions['base_url'] : $scripturl . '?action=' . $menu_context['current_action'];
264 278
 
265 279
 	// If we didn't find the area we were looking for go to a default one.
266
-	if (isset($backup_area) && empty($found_section))
267
-		$menu_context['current_area'] = $backup_area;
280
+	if (isset($backup_area) && empty($found_section)) {
281
+			$menu_context['current_area'] = $backup_area;
282
+	}
268 283
 
269 284
 	// If there are sections quickly goes through all the sections to check if the base menu has an url
270 285
 	if (!empty($menu_context['current_section']))
271 286
 	{
272 287
 		$menu_context['sections'][$menu_context['current_section']]['selected'] = true;
273 288
 		$menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['selected'] = true;
274
-		if (!empty($menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']]))
275
-			$menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']]['selected'] = true;
289
+		if (!empty($menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']])) {
290
+					$menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']]['selected'] = true;
291
+		}
276 292
 
277
-		foreach ($menu_context['sections'] as $section_id => $section)
278
-			foreach ($section['areas'] as $area_id => $area)
293
+		foreach ($menu_context['sections'] as $section_id => $section) {
294
+					foreach ($section['areas'] as $area_id => $area)
279 295
 			{
280 296
 				if (!isset($menu_context['sections'][$section_id]['url']))
281 297
 				{
282 298
 					$menu_context['sections'][$section_id]['url'] = isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $area_id;
299
+		}
283 300
 					break;
284 301
 				}
285 302
 			}
@@ -290,8 +307,9 @@  discard block
 block discarded – undo
290 307
 	{
291 308
 		// Never happened!
292 309
 		$context['max_menu_id']--;
293
-		if ($context['max_menu_id'] == 0)
294
-			unset($context['max_menu_id']);
310
+		if ($context['max_menu_id'] == 0) {
311
+					unset($context['max_menu_id']);
312
+		}
295 313
 
296 314
 		return false;
297 315
 	}
@@ -302,8 +320,9 @@  discard block
 block discarded – undo
302 320
 	$context['template_layers'][] = $menu_context['layer_name'];
303 321
 
304 322
 	// Check we had something - for sanity sake.
305
-	if (empty($include_data))
306
-		return false;
323
+	if (empty($include_data)) {
324
+			return false;
325
+	}
307 326
 
308 327
 	// Finally - return information on the selected item.
309 328
 	$include_data += array(
@@ -326,12 +345,14 @@  discard block
 block discarded – undo
326 345
 	global $context;
327 346
 
328 347
 	$menu_name = $menu_id == 'last' && isset($context['max_menu_id']) && isset($context['menu_data_' . $context['max_menu_id']]) ? 'menu_data_' . $context['max_menu_id'] : 'menu_data_' . $menu_id;
329
-	if (!isset($context[$menu_name]))
330
-		return false;
348
+	if (!isset($context[$menu_name])) {
349
+			return false;
350
+	}
331 351
 
332 352
 	$layer_index = array_search($context[$menu_name]['layer_name'], $context['template_layers']);
333
-	if ($layer_index !== false)
334
-		unset($context['template_layers'][$layer_index]);
353
+	if ($layer_index !== false) {
354
+			unset($context['template_layers'][$layer_index]);
355
+	}
335 356
 
336 357
 	unset($context[$menu_name]);
337 358
 }
Please login to merge, or discard this patch.
Sources/Subs-Post.php 3 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1451,7 +1451,7 @@  discard block
 block discarded – undo
1451 1451
  * @param resource $socket Socket to send on
1452 1452
  * @param string $code The expected response code
1453 1453
  * @param string $response The response from the SMTP server
1454
- * @return bool Whether it responded as such.
1454
+ * @return string|boolean Whether it responded as such.
1455 1455
  */
1456 1456
 function server_parse($message, $socket, $code, &$response = null)
1457 1457
 {
@@ -2265,7 +2265,7 @@  discard block
 block discarded – undo
2265 2265
  * @param array $msgs Array of message ids
2266 2266
  * @param bool $approve Whether to approve the posts (if false, posts are unapproved)
2267 2267
  * @param bool $notify Whether to notify users
2268
- * @return bool Whether the operation was successful
2268
+ * @return null|boolean Whether the operation was successful
2269 2269
  */
2270 2270
 function approvePosts($msgs, $approve = true, $notify = true)
2271 2271
 {
@@ -2518,7 +2518,7 @@  discard block
 block discarded – undo
2518 2518
  *
2519 2519
  * @param array $topics Array of topic ids
2520 2520
  * @param bool $approve Whether to approve the topics. If false, unapproves them instead
2521
- * @return bool Whether the operation was successful
2521
+ * @return null|boolean Whether the operation was successful
2522 2522
  */
2523 2523
 function approveTopics($topics, $approve = true)
2524 2524
 {
@@ -2908,7 +2908,7 @@  discard block
 block discarded – undo
2908 2908
  *
2909 2909
  * @param resource $dict An enchant or pspell dictionary resource set up by {@link spell_init()}
2910 2910
  * @param string $word A word to check the spelling of
2911
- * @return bool Whether or not the specified word is spelled properly
2911
+ * @return boolean|null Whether or not the specified word is spelled properly
2912 2912
  */
2913 2913
 function spell_check($dict, $word)
2914 2914
 {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -704,7 +704,7 @@
 block discarded – undo
704 704
 					$mail_result = false;
705 705
 				}
706 706
 			}
707
-			catch(ErrorException $e)
707
+			catch (ErrorException $e)
708 708
 			{
709 709
 				log_error($e->getMessage(), 'general', $e->getFile(), $e->getLine());
710 710
 				log_error(sprintf($txt['mail_send_unable'], $to));
Please login to merge, or discard this patch.
Braces   +527 added lines, -393 removed lines patch added patch discarded remove patch
@@ -15,8 +15,9 @@  discard block
 block discarded – undo
15 15
  * @version 2.1 Beta 4
16 16
  */
17 17
 
18
-if (!defined('SMF'))
18
+if (!defined('SMF')) {
19 19
 	die('No direct access...');
20
+}
20 21
 
21 22
 /**
22 23
  * Takes a message and parses it, returning nothing.
@@ -31,8 +32,9 @@  discard block
 block discarded – undo
31 32
 	global $user_info, $modSettings, $context, $sourcedir;
32 33
 
33 34
 	// This line makes all languages *theoretically* work even with the wrong charset ;).
34
-	if (empty($context['utf8']))
35
-		$message = preg_replace('~&amp;#(\d{4,5}|[2-9]\d{2,4}|1[2-9]\d);~', '&#$1;', $message);
35
+	if (empty($context['utf8'])) {
36
+			$message = preg_replace('~&amp;#(\d{4,5}|[2-9]\d{2,4}|1[2-9]\d);~', '&#$1;', $message);
37
+	}
36 38
 
37 39
 	// Clean up after nobbc ;).
38 40
 	$message = preg_replace_callback('~\[nobbc\](.+?)\[/nobbc\]~is', function($a)
@@ -47,17 +49,19 @@  discard block
 block discarded – undo
47 49
 	$message = preg_replace('~\.{100,}~', '...', $message);
48 50
 
49 51
 	// Trim off trailing quotes - these often happen by accident.
50
-	while (substr($message, -7) == '[quote]')
51
-		$message = substr($message, 0, -7);
52
-	while (substr($message, 0, 8) == '[/quote]')
53
-		$message = substr($message, 8);
52
+	while (substr($message, -7) == '[quote]') {
53
+			$message = substr($message, 0, -7);
54
+	}
55
+	while (substr($message, 0, 8) == '[/quote]') {
56
+			$message = substr($message, 8);
57
+	}
54 58
 
55 59
 	// Find all code blocks, work out whether we'd be parsing them, then ensure they are all closed.
56 60
 	$in_tag = false;
57 61
 	$had_tag = false;
58 62
 	$codeopen = 0;
59
-	if (preg_match_all('~(\[(/)*code(?:=[^\]]+)?\])~is', $message, $matches))
60
-		foreach ($matches[0] as $index => $dummy)
63
+	if (preg_match_all('~(\[(/)*code(?:=[^\]]+)?\])~is', $message, $matches)) {
64
+			foreach ($matches[0] as $index => $dummy)
61 65
 		{
62 66
 			// Closing?
63 67
 			if (!empty($matches[2][$index]))
@@ -65,6 +69,7 @@  discard block
 block discarded – undo
65 69
 				// If it's closing and we're not in a tag we need to open it...
66 70
 				if (!$in_tag)
67 71
 					$codeopen = true;
72
+	}
68 73
 				// Either way we ain't in one any more.
69 74
 				$in_tag = false;
70 75
 			}
@@ -73,17 +78,20 @@  discard block
 block discarded – undo
73 78
 			{
74 79
 				$had_tag = true;
75 80
 				// If we're in a tag don't do nought!
76
-				if (!$in_tag)
77
-					$in_tag = true;
81
+				if (!$in_tag) {
82
+									$in_tag = true;
83
+				}
78 84
 			}
79 85
 		}
80 86
 
81 87
 	// If we have an open tag, close it.
82
-	if ($in_tag)
83
-		$message .= '[/code]';
88
+	if ($in_tag) {
89
+			$message .= '[/code]';
90
+	}
84 91
 	// Open any ones that need to be open, only if we've never had a tag.
85
-	if ($codeopen && !$had_tag)
86
-		$message = '[code]' . $message;
92
+	if ($codeopen && !$had_tag) {
93
+			$message = '[code]' . $message;
94
+	}
87 95
 
88 96
 	// Replace code BBC with placeholders. We'll restore them at the end.
89 97
 	$parts = preg_split('~(\[/code\]|\[code(?:=[^\]]+)?\])~i', $message, -1, PREG_SPLIT_DELIM_CAPTURE);
@@ -108,23 +116,26 @@  discard block
 block discarded – undo
108 116
 	fixTags($message);
109 117
 
110 118
 	// Replace /me.+?\n with [me=name]dsf[/me]\n.
111
-	if (strpos($user_info['name'], '[') !== false || strpos($user_info['name'], ']') !== false || strpos($user_info['name'], '\'') !== false || strpos($user_info['name'], '"') !== false)
112
-		$message = preg_replace('~(\A|\n)/me(?: |&nbsp;)([^\n]*)(?:\z)?~i', '$1[me=&quot;' . $user_info['name'] . '&quot;]$2[/me]', $message);
113
-	else
114
-		$message = preg_replace('~(\A|\n)/me(?: |&nbsp;)([^\n]*)(?:\z)?~i', '$1[me=' . $user_info['name'] . ']$2[/me]', $message);
119
+	if (strpos($user_info['name'], '[') !== false || strpos($user_info['name'], ']') !== false || strpos($user_info['name'], '\'') !== false || strpos($user_info['name'], '"') !== false) {
120
+			$message = preg_replace('~(\A|\n)/me(?: |&nbsp;)([^\n]*)(?:\z)?~i', '$1[me=&quot;' . $user_info['name'] . '&quot;]$2[/me]', $message);
121
+	} else {
122
+			$message = preg_replace('~(\A|\n)/me(?: |&nbsp;)([^\n]*)(?:\z)?~i', '$1[me=' . $user_info['name'] . ']$2[/me]', $message);
123
+	}
115 124
 
116 125
 	if (!$previewing && strpos($message, '[html]') !== false)
117 126
 	{
118
-		if (allowedTo('admin_forum'))
119
-			$message = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) {
127
+		if (allowedTo('admin_forum')) {
128
+					$message = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) {
120 129
 				return '[html]' . strtr(un_htmlspecialchars($m[1]), array("\n" => '&#13;', '  ' => ' &#32;', '[' => '&#91;', ']' => '&#93;')) . '[/html]';
130
+		}
121 131
 			}, $message);
122 132
 
123 133
 		// We should edit them out, or else if an admin edits the message they will get shown...
124 134
 		else
125 135
 		{
126
-			while (strpos($message, '[html]') !== false)
127
-				$message = preg_replace('~\[[/]?html\]~i', '', $message);
136
+			while (strpos($message, '[html]') !== false) {
137
+							$message = preg_replace('~\[[/]?html\]~i', '', $message);
138
+			}
128 139
 		}
129 140
 	}
130 141
 
@@ -146,10 +157,12 @@  discard block
 block discarded – undo
146 157
 
147 158
 	$list_open = substr_count($message, '[list]') + substr_count($message, '[list ');
148 159
 	$list_close = substr_count($message, '[/list]');
149
-	if ($list_close - $list_open > 0)
150
-		$message = str_repeat('[list]', $list_close - $list_open) . $message;
151
-	if ($list_open - $list_close > 0)
152
-		$message = $message . str_repeat('[/list]', $list_open - $list_close);
160
+	if ($list_close - $list_open > 0) {
161
+			$message = str_repeat('[list]', $list_close - $list_open) . $message;
162
+	}
163
+	if ($list_open - $list_close > 0) {
164
+			$message = $message . str_repeat('[/list]', $list_open - $list_close);
165
+	}
153 166
 
154 167
 	$mistake_fixes = array(
155 168
 		// Find [table]s not followed by [tr].
@@ -198,8 +211,9 @@  discard block
 block discarded – undo
198 211
 	);
199 212
 
200 213
 	// Fix up some use of tables without [tr]s, etc. (it has to be done more than once to catch it all.)
201
-	for ($j = 0; $j < 3; $j++)
202
-		$message = preg_replace(array_keys($mistake_fixes), $mistake_fixes, $message);
214
+	for ($j = 0; $j < 3; $j++) {
215
+			$message = preg_replace(array_keys($mistake_fixes), $mistake_fixes, $message);
216
+	}
203 217
 
204 218
 	// Remove empty bbc from the sections outside the code tags
205 219
 	$allowedEmpty = array(
@@ -210,24 +224,28 @@  discard block
 block discarded – undo
210 224
 	require_once($sourcedir . '/Subs.php');
211 225
 
212 226
 	$alltags = array();
213
-	foreach (($codes = parse_bbc(false)) as $code)
214
-		if (!in_array($code['tag'], $allowedEmpty))
227
+	foreach (($codes = parse_bbc(false)) as $code) {
228
+			if (!in_array($code['tag'], $allowedEmpty))
215 229
 			$alltags[] = $code['tag'];
230
+	}
216 231
 
217 232
 	$alltags_regex = '\b' . implode("\b|\b", array_unique($alltags)) . '\b';
218 233
 
219
-	while (preg_match('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', $message))
220
-		$message = preg_replace('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', '', $message);
234
+	while (preg_match('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', $message)) {
235
+			$message = preg_replace('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', '', $message);
236
+	}
221 237
 
222 238
 	// Restore code blocks
223
-	if (!empty($code_tags))
224
-		$message = str_replace(array_keys($code_tags), array_values($code_tags), $message);
239
+	if (!empty($code_tags)) {
240
+			$message = str_replace(array_keys($code_tags), array_values($code_tags), $message);
241
+	}
225 242
 
226 243
 	// Restore white space entities
227
-	if (!$previewing)
228
-		$message = strtr($message, array('  ' => '&nbsp; ', "\n" => '<br>', $context['utf8'] ? "\xC2\xA0" : "\xA0" => '&nbsp;'));
229
-	else
230
-		$message = strtr($message, array('  ' => '&nbsp; ', $context['utf8'] ? "\xC2\xA0" : "\xA0" => '&nbsp;'));
244
+	if (!$previewing) {
245
+			$message = strtr($message, array('  ' => '&nbsp; ', "\n" => '<br>', $context['utf8'] ? "\xC2\xA0" : "\xA0" => '&nbsp;'));
246
+	} else {
247
+			$message = strtr($message, array('  ' => '&nbsp; ', $context['utf8'] ? "\xC2\xA0" : "\xA0" => '&nbsp;'));
248
+	}
231 249
 
232 250
 	// Now let's quickly clean up things that will slow our parser (which are common in posted code.)
233 251
 	$message = strtr($message, array('[]' => '&#91;]', '[&#039;' => '&#91;&#039;'));
@@ -270,8 +288,9 @@  discard block
 block discarded – undo
270 288
 		return "[time]" . timeformat("$m[1]", false) . "[/time]";
271 289
 	}, $message);
272 290
 
273
-	if (!empty($code_tags))
274
-		$message = str_replace(array_keys($code_tags), array_values($code_tags), $message);
291
+	if (!empty($code_tags)) {
292
+			$message = str_replace(array_keys($code_tags), array_values($code_tags), $message);
293
+	}
275 294
 
276 295
 	// Change breaks back to \n's and &nsbp; back to spaces.
277 296
 	return preg_replace('~<br( /)?' . '>~', "\n", str_replace('&nbsp;', ' ', $message));
@@ -352,8 +371,9 @@  discard block
 block discarded – undo
352 371
 	);
353 372
 
354 373
 	// Fix each type of tag.
355
-	foreach ($fixArray as $param)
356
-		fixTag($message, $param['tag'], $param['protocols'], $param['embeddedUrl'], $param['hasEqualSign'], !empty($param['hasExtra']));
374
+	foreach ($fixArray as $param) {
375
+			fixTag($message, $param['tag'], $param['protocols'], $param['embeddedUrl'], $param['hasEqualSign'], !empty($param['hasExtra']));
376
+	}
357 377
 
358 378
 	// Now fix possible security problems with images loading links automatically...
359 379
 	$message = preg_replace_callback('~(\[img.*?\])(.+?)\[/img\]~is', function($m)
@@ -378,10 +398,11 @@  discard block
 block discarded – undo
378 398
 {
379 399
 	global $boardurl, $scripturl;
380 400
 
381
-	if (preg_match('~^([^:]+://[^/]+)~', $boardurl, $match) != 0)
382
-		$domain_url = $match[1];
383
-	else
384
-		$domain_url = $boardurl . '/';
401
+	if (preg_match('~^([^:]+://[^/]+)~', $boardurl, $match) != 0) {
402
+			$domain_url = $match[1];
403
+	} else {
404
+			$domain_url = $boardurl . '/';
405
+	}
385 406
 
386 407
 	$replaces = array();
387 408
 
@@ -389,11 +410,11 @@  discard block
 block discarded – undo
389 410
 	{
390 411
 		$quoted = preg_match('~\[(' . $myTag . ')=&quot;~', $message);
391 412
 		preg_match_all('~\[(' . $myTag . ')=' . ($quoted ? '&quot;(.*?)&quot;' : '([^\]]*?)') . '\](?:(.+?)\[/(' . $myTag . ')\])?~is', $message, $matches);
413
+	} elseif ($hasEqualSign) {
414
+			preg_match_all('~\[(' . $myTag . ')=([^\]]*?)\](?:(.+?)\[/(' . $myTag . ')\])?~is', $message, $matches);
415
+	} else {
416
+			preg_match_all('~\[(' . $myTag . ($hasExtra ? '(?:[^\]]*?)' : '') . ')\](.+?)\[/(' . $myTag . ')\]~is', $message, $matches);
392 417
 	}
393
-	elseif ($hasEqualSign)
394
-		preg_match_all('~\[(' . $myTag . ')=([^\]]*?)\](?:(.+?)\[/(' . $myTag . ')\])?~is', $message, $matches);
395
-	else
396
-		preg_match_all('~\[(' . $myTag . ($hasExtra ? '(?:[^\]]*?)' : '') . ')\](.+?)\[/(' . $myTag . ')\]~is', $message, $matches);
397 418
 
398 419
 	foreach ($matches[0] as $k => $dummy)
399 420
 	{
@@ -406,49 +427,53 @@  discard block
 block discarded – undo
406 427
 		foreach ($protocols as $protocol)
407 428
 		{
408 429
 			$found = strncasecmp($replace, $protocol . '://', strlen($protocol) + 3) === 0;
409
-			if ($found)
410
-				break;
430
+			if ($found) {
431
+							break;
432
+			}
411 433
 		}
412 434
 
413 435
 		if (!$found && $protocols[0] == 'http')
414 436
 		{
415
-			if (substr($replace, 0, 1) == '/' && substr($replace, 0, 2) != '//')
416
-				$replace = $domain_url . $replace;
417
-			elseif (substr($replace, 0, 1) == '?')
418
-				$replace = $scripturl . $replace;
419
-			elseif (substr($replace, 0, 1) == '#' && $embeddedUrl)
437
+			if (substr($replace, 0, 1) == '/' && substr($replace, 0, 2) != '//') {
438
+							$replace = $domain_url . $replace;
439
+			} elseif (substr($replace, 0, 1) == '?') {
440
+							$replace = $scripturl . $replace;
441
+			} elseif (substr($replace, 0, 1) == '#' && $embeddedUrl)
420 442
 			{
421 443
 				$replace = '#' . preg_replace('~[^A-Za-z0-9_\-#]~', '', substr($replace, 1));
422 444
 				$this_tag = 'iurl';
423 445
 				$this_close = 'iurl';
446
+			} elseif (substr($replace, 0, 2) != '//') {
447
+							$replace = $protocols[0] . '://' . $replace;
424 448
 			}
425
-			elseif (substr($replace, 0, 2) != '//')
426
-				$replace = $protocols[0] . '://' . $replace;
427
-		}
428
-		elseif (!$found && $protocols[0] == 'ftp')
429
-			$replace = $protocols[0] . '://' . preg_replace('~^(?!ftps?)[^:]+://~', '', $replace);
430
-		elseif (!$found)
431
-			$replace = $protocols[0] . '://' . $replace;
432
-
433
-		if ($hasEqualSign && $embeddedUrl)
434
-			$replaces[$matches[0][$k]] = '[' . $this_tag . '=&quot;' . $replace . '&quot;]' . (empty($matches[4][$k]) ? '' : $matches[3][$k] . '[/' . $this_close . ']');
435
-		elseif ($hasEqualSign)
436
-			$replaces['[' . $matches[1][$k] . '=' . $matches[2][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']';
437
-		elseif ($embeddedUrl)
438
-			$replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']' . $matches[2][$k] . '[/' . $this_close . ']';
439
-		else
440
-			$replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . ']' . $replace . '[/' . $this_close . ']';
449
+		} elseif (!$found && $protocols[0] == 'ftp') {
450
+					$replace = $protocols[0] . '://' . preg_replace('~^(?!ftps?)[^:]+://~', '', $replace);
451
+		} elseif (!$found) {
452
+					$replace = $protocols[0] . '://' . $replace;
453
+		}
454
+
455
+		if ($hasEqualSign && $embeddedUrl) {
456
+					$replaces[$matches[0][$k]] = '[' . $this_tag . '=&quot;' . $replace . '&quot;]' . (empty($matches[4][$k]) ? '' : $matches[3][$k] . '[/' . $this_close . ']');
457
+		} elseif ($hasEqualSign) {
458
+					$replaces['[' . $matches[1][$k] . '=' . $matches[2][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']';
459
+		} elseif ($embeddedUrl) {
460
+					$replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']' . $matches[2][$k] . '[/' . $this_close . ']';
461
+		} else {
462
+					$replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . ']' . $replace . '[/' . $this_close . ']';
463
+		}
441 464
 	}
442 465
 
443 466
 	foreach ($replaces as $k => $v)
444 467
 	{
445
-		if ($k == $v)
446
-			unset($replaces[$k]);
468
+		if ($k == $v) {
469
+					unset($replaces[$k]);
470
+		}
447 471
 	}
448 472
 
449
-	if (!empty($replaces))
450
-		$message = strtr($message, $replaces);
451
-}
473
+	if (!empty($replaces)) {
474
+			$message = strtr($message, $replaces);
475
+	}
476
+	}
452 477
 
453 478
 /**
454 479
  * This function sends an email to the specified recipient(s).
@@ -492,8 +517,9 @@  discard block
 block discarded – undo
492 517
 	}
493 518
 
494 519
 	// Nothing left? Nothing else to do
495
-	if (empty($to_array))
496
-		return true;
520
+	if (empty($to_array)) {
521
+			return true;
522
+	}
497 523
 
498 524
 	// Once upon a time, Hotmail could not interpret non-ASCII mails.
499 525
 	// In honour of those days, it's still called the 'hotmail fix'.
@@ -510,15 +536,17 @@  discard block
 block discarded – undo
510 536
 		}
511 537
 
512 538
 		// Call this function recursively for the hotmail addresses.
513
-		if (!empty($hotmail_to))
514
-			$mail_result = sendmail($hotmail_to, $subject, $message, $from, $message_id, $send_html, $priority, true, $is_private);
539
+		if (!empty($hotmail_to)) {
540
+					$mail_result = sendmail($hotmail_to, $subject, $message, $from, $message_id, $send_html, $priority, true, $is_private);
541
+		}
515 542
 
516 543
 		// The remaining addresses no longer need the fix.
517 544
 		$hotmail_fix = false;
518 545
 
519 546
 		// No other addresses left? Return instantly.
520
-		if (empty($to_array))
521
-			return $mail_result;
547
+		if (empty($to_array)) {
548
+					return $mail_result;
549
+		}
522 550
 	}
523 551
 
524 552
 	// Get rid of entities.
@@ -543,13 +571,15 @@  discard block
 block discarded – undo
543 571
 	$headers .= 'Return-Path: ' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . $line_break;
544 572
 	$headers .= 'Date: ' . gmdate('D, d M Y H:i:s') . ' -0000' . $line_break;
545 573
 
546
-	if ($message_id !== null && empty($modSettings['mail_no_message_id']))
547
-		$headers .= 'Message-ID: <' . md5($scripturl . microtime()) . '-' . $message_id . strstr(empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from'], '@') . '>' . $line_break;
574
+	if ($message_id !== null && empty($modSettings['mail_no_message_id'])) {
575
+			$headers .= 'Message-ID: <' . md5($scripturl . microtime()) . '-' . $message_id . strstr(empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from'], '@') . '>' . $line_break;
576
+	}
548 577
 	$headers .= 'X-Mailer: SMF' . $line_break;
549 578
 
550 579
 	// Pass this to the integration before we start modifying the output -- it'll make it easier later.
551
-	if (in_array(false, call_integration_hook('integrate_outgoing_email', array(&$subject, &$message, &$headers, &$to_array)), true))
552
-		return false;
580
+	if (in_array(false, call_integration_hook('integrate_outgoing_email', array(&$subject, &$message, &$headers, &$to_array)), true)) {
581
+			return false;
582
+	}
553 583
 
554 584
 	// Save the original message...
555 585
 	$orig_message = $message;
@@ -598,17 +628,19 @@  discard block
 block discarded – undo
598 628
 	}
599 629
 
600 630
 	// Are we using the mail queue, if so this is where we butt in...
601
-	if ($priority != 0)
602
-		return AddMailQueue(false, $to_array, $subject, $message, $headers, $send_html, $priority, $is_private);
631
+	if ($priority != 0) {
632
+			return AddMailQueue(false, $to_array, $subject, $message, $headers, $send_html, $priority, $is_private);
633
+	}
603 634
 
604 635
 	// If it's a priority mail, send it now - note though that this should NOT be used for sending many at once.
605 636
 	elseif (!empty($modSettings['mail_limit']))
606 637
 	{
607 638
 		list ($last_mail_time, $mails_this_minute) = @explode('|', $modSettings['mail_recent']);
608
-		if (empty($mails_this_minute) || time() > $last_mail_time + 60)
609
-			$new_queue_stat = time() . '|' . 1;
610
-		else
611
-			$new_queue_stat = $last_mail_time . '|' . ((int) $mails_this_minute + 1);
639
+		if (empty($mails_this_minute) || time() > $last_mail_time + 60) {
640
+					$new_queue_stat = time() . '|' . 1;
641
+		} else {
642
+					$new_queue_stat = $last_mail_time . '|' . ((int) $mails_this_minute + 1);
643
+		}
612 644
 
613 645
 		updateSettings(array('mail_recent' => $new_queue_stat));
614 646
 	}
@@ -642,8 +674,7 @@  discard block
 block discarded – undo
642 674
 					log_error(sprintf($txt['mail_send_unable'], $to));
643 675
 					$mail_result = false;
644 676
 				}
645
-			}
646
-			catch(ErrorException $e)
677
+			} catch(ErrorException $e)
647 678
 			{
648 679
 				log_error($e->getMessage(), 'general', $e->getFile(), $e->getLine());
649 680
 				log_error(sprintf($txt['mail_send_unable'], $to));
@@ -653,12 +684,13 @@  discard block
 block discarded – undo
653 684
 
654 685
 			// Wait, wait, I'm still sending here!
655 686
 			@set_time_limit(300);
656
-			if (function_exists('apache_reset_timeout'))
657
-				@apache_reset_timeout();
687
+			if (function_exists('apache_reset_timeout')) {
688
+							@apache_reset_timeout();
689
+			}
658 690
 		}
691
+	} else {
692
+			$mail_result = $mail_result && smtp_mail($to_array, $subject, $message, $headers);
659 693
 	}
660
-	else
661
-		$mail_result = $mail_result && smtp_mail($to_array, $subject, $message, $headers);
662 694
 
663 695
 	// Everything go smoothly?
664 696
 	return $mail_result;
@@ -684,8 +716,9 @@  discard block
 block discarded – undo
684 716
 	static $cur_insert = array();
685 717
 	static $cur_insert_len = 0;
686 718
 
687
-	if ($cur_insert_len == 0)
688
-		$cur_insert = array();
719
+	if ($cur_insert_len == 0) {
720
+			$cur_insert = array();
721
+	}
689 722
 
690 723
 	// If we're flushing, make the final inserts - also if we're near the MySQL length limit!
691 724
 	if (($flush || $cur_insert_len > 800000) && !empty($cur_insert))
@@ -760,8 +793,9 @@  discard block
 block discarded – undo
760 793
 	}
761 794
 
762 795
 	// If they are using SSI there is a good chance obExit will never be called.  So lets be nice and flush it for them.
763
-	if (SMF === 'SSI' || SMF === 'BACKGROUND')
764
-		return AddMailQueue(true);
796
+	if (SMF === 'SSI' || SMF === 'BACKGROUND') {
797
+			return AddMailQueue(true);
798
+	}
765 799
 
766 800
 	return true;
767 801
 }
@@ -792,23 +826,26 @@  discard block
 block discarded – undo
792 826
 		'sent' => array()
793 827
 	);
794 828
 
795
-	if ($from === null)
796
-		$from = array(
829
+	if ($from === null) {
830
+			$from = array(
797 831
 			'id' => $user_info['id'],
798 832
 			'name' => $user_info['name'],
799 833
 			'username' => $user_info['username']
800 834
 		);
835
+	}
801 836
 
802 837
 	// This is the one that will go in their inbox.
803 838
 	$htmlmessage = $smcFunc['htmlspecialchars']($message, ENT_QUOTES);
804 839
 	preparsecode($htmlmessage);
805 840
 	$htmlsubject = strtr($smcFunc['htmlspecialchars']($subject), array("\r" => '', "\n" => '', "\t" => ''));
806
-	if ($smcFunc['strlen']($htmlsubject) > 100)
807
-		$htmlsubject = $smcFunc['substr']($htmlsubject, 0, 100);
841
+	if ($smcFunc['strlen']($htmlsubject) > 100) {
842
+			$htmlsubject = $smcFunc['substr']($htmlsubject, 0, 100);
843
+	}
808 844
 
809 845
 	// Make sure is an array
810
-	if (!is_array($recipients))
811
-		$recipients = array($recipients);
846
+	if (!is_array($recipients)) {
847
+			$recipients = array($recipients);
848
+	}
812 849
 
813 850
 	// Integrated PMs
814 851
 	call_integration_hook('integrate_personal_message', array(&$recipients, &$from, &$subject, &$message));
@@ -836,21 +873,23 @@  discard block
 block discarded – undo
836 873
 				'usernames' => array_keys($usernames),
837 874
 			)
838 875
 		);
839
-		while ($row = $smcFunc['db_fetch_assoc']($request))
840
-			if (isset($usernames[$smcFunc['strtolower']($row['member_name'])]))
876
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
877
+					if (isset($usernames[$smcFunc['strtolower']($row['member_name'])]))
841 878
 				$usernames[$smcFunc['strtolower']($row['member_name'])] = $row['id_member'];
879
+		}
842 880
 		$smcFunc['db_free_result']($request);
843 881
 
844 882
 		// Replace the usernames with IDs. Drop usernames that couldn't be found.
845
-		foreach ($recipients as $rec_type => $rec)
846
-			foreach ($rec as $id => $member)
883
+		foreach ($recipients as $rec_type => $rec) {
884
+					foreach ($rec as $id => $member)
847 885
 			{
848 886
 				if (is_numeric($recipients[$rec_type][$id]))
849 887
 					continue;
888
+		}
850 889
 
851
-				if (!empty($usernames[$member]))
852
-					$recipients[$rec_type][$id] = $usernames[$member];
853
-				else
890
+				if (!empty($usernames[$member])) {
891
+									$recipients[$rec_type][$id] = $usernames[$member];
892
+				} else
854 893
 				{
855 894
 					$log['failed'][$id] = sprintf($txt['pm_error_user_not_found'], $recipients[$rec_type][$id]);
856 895
 					unset($recipients[$rec_type][$id]);
@@ -888,8 +927,9 @@  discard block
 block discarded – undo
888 927
 		$delete = false;
889 928
 		foreach ($criteria as $criterium)
890 929
 		{
891
-			if (($criterium['t'] == 'mid' && $criterium['v'] == $from['id']) || ($criterium['t'] == 'gid' && in_array($criterium['v'], $user_info['groups'])) || ($criterium['t'] == 'sub' && strpos($subject, $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($message, $criterium['v']) !== false))
892
-				$delete = true;
930
+			if (($criterium['t'] == 'mid' && $criterium['v'] == $from['id']) || ($criterium['t'] == 'gid' && in_array($criterium['v'], $user_info['groups'])) || ($criterium['t'] == 'sub' && strpos($subject, $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($message, $criterium['v']) !== false)) {
931
+							$delete = true;
932
+			}
893 933
 			// If we're adding and one criteria don't match then we stop!
894 934
 			elseif (!$row['is_or'])
895 935
 			{
@@ -897,8 +937,9 @@  discard block
 block discarded – undo
897 937
 				break;
898 938
 			}
899 939
 		}
900
-		if ($delete)
901
-			$deletes[$row['id_member']] = 1;
940
+		if ($delete) {
941
+					$deletes[$row['id_member']] = 1;
942
+		}
902 943
 	}
903 944
 	$smcFunc['db_free_result']($request);
904 945
 
@@ -913,8 +954,9 @@  discard block
 block discarded – undo
913 954
 			array(
914 955
 			)
915 956
 		);
916
-		while ($row = $smcFunc['db_fetch_assoc']($request))
917
-			$message_limit_cache[$row['id_group']] = $row['max_messages'];
957
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
958
+					$message_limit_cache[$row['id_group']] = $row['max_messages'];
959
+		}
918 960
 		$smcFunc['db_free_result']($request);
919 961
 	}
920 962
 
@@ -922,8 +964,9 @@  discard block
 block discarded – undo
922 964
 	require_once($sourcedir . '/Subs-Members.php');
923 965
 	$pmReadGroups = groupsAllowedTo('pm_read');
924 966
 
925
-	if (empty($modSettings['permission_enable_deny']))
926
-		$pmReadGroups['denied'] = array();
967
+	if (empty($modSettings['permission_enable_deny'])) {
968
+			$pmReadGroups['denied'] = array();
969
+	}
927 970
 
928 971
 	// Load their alert preferences
929 972
 	require_once($sourcedir . '/Subs-Notify.php');
@@ -955,8 +998,9 @@  discard block
 block discarded – undo
955 998
 	while ($row = $smcFunc['db_fetch_assoc']($request))
956 999
 	{
957 1000
 		// Don't do anything for members to be deleted!
958
-		if (isset($deletes[$row['id_member']]))
959
-			continue;
1001
+		if (isset($deletes[$row['id_member']])) {
1002
+					continue;
1003
+		}
960 1004
 
961 1005
 		// Load the preferences for this member (if any)
962 1006
 		$prefs = !empty($notifyPrefs[$row['id_member']]) ? $notifyPrefs[$row['id_member']] : array();
@@ -977,8 +1021,9 @@  discard block
 block discarded – undo
977 1021
 		{
978 1022
 			foreach ($groups as $id)
979 1023
 			{
980
-				if (isset($message_limit_cache[$id]) && $message_limit != 0 && $message_limit < $message_limit_cache[$id])
981
-					$message_limit = $message_limit_cache[$id];
1024
+				if (isset($message_limit_cache[$id]) && $message_limit != 0 && $message_limit < $message_limit_cache[$id]) {
1025
+									$message_limit = $message_limit_cache[$id];
1026
+				}
982 1027
 			}
983 1028
 
984 1029
 			if ($message_limit > 0 && $message_limit <= $row['instant_messages'])
@@ -1026,8 +1071,9 @@  discard block
 block discarded – undo
1026 1071
 	$smcFunc['db_free_result']($request);
1027 1072
 
1028 1073
 	// Only 'send' the message if there are any recipients left.
1029
-	if (empty($all_to))
1030
-		return $log;
1074
+	if (empty($all_to)) {
1075
+			return $log;
1076
+	}
1031 1077
 
1032 1078
 	// Insert the message itself and then grab the last insert id.
1033 1079
 	$id_pm = $smcFunc['db_insert']('',
@@ -1048,8 +1094,8 @@  discard block
 block discarded – undo
1048 1094
 	if (!empty($id_pm))
1049 1095
 	{
1050 1096
 		// If this is new we need to set it part of it's own conversation.
1051
-		if (empty($pm_head))
1052
-			$smcFunc['db_query']('', '
1097
+		if (empty($pm_head)) {
1098
+					$smcFunc['db_query']('', '
1053 1099
 				UPDATE {db_prefix}personal_messages
1054 1100
 				SET id_pm_head = {int:id_pm_head}
1055 1101
 				WHERE id_pm = {int:id_pm_head}',
@@ -1057,6 +1103,7 @@  discard block
 block discarded – undo
1057 1103
 					'id_pm_head' => $id_pm,
1058 1104
 				)
1059 1105
 			);
1106
+		}
1060 1107
 
1061 1108
 		// Some people think manually deleting personal_messages is fun... it's not. We protect against it though :)
1062 1109
 		$smcFunc['db_query']('', '
@@ -1072,8 +1119,9 @@  discard block
 block discarded – undo
1072 1119
 		foreach ($all_to as $to)
1073 1120
 		{
1074 1121
 			$insertRows[] = array($id_pm, $to, in_array($to, $recipients['bcc']) ? 1 : 0, isset($deletes[$to]) ? 1 : 0, 1);
1075
-			if (!in_array($to, $recipients['bcc']))
1076
-				$to_list[] = $to;
1122
+			if (!in_array($to, $recipients['bcc'])) {
1123
+							$to_list[] = $to;
1124
+			}
1077 1125
 		}
1078 1126
 
1079 1127
 		$smcFunc['db_insert']('insert',
@@ -1091,9 +1139,9 @@  discard block
 block discarded – undo
1091 1139
 	{
1092 1140
 		censorText($message);
1093 1141
 		$message = trim(un_htmlspecialchars(strip_tags(strtr(parse_bbc($smcFunc['htmlspecialchars']($message), false), array('<br>' => "\n", '</div>' => "\n", '</li>' => "\n", '&#91;' => '[', '&#93;' => ']')))));
1142
+	} else {
1143
+			$message = '';
1094 1144
 	}
1095
-	else
1096
-		$message = '';
1097 1145
 
1098 1146
 	$to_names = array();
1099 1147
 	if (count($to_list) > 1)
@@ -1106,8 +1154,9 @@  discard block
 block discarded – undo
1106 1154
 				'to_members' => $to_list,
1107 1155
 			)
1108 1156
 		);
1109
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1110
-			$to_names[] = un_htmlspecialchars($row['real_name']);
1157
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1158
+					$to_names[] = un_htmlspecialchars($row['real_name']);
1159
+		}
1111 1160
 		$smcFunc['db_free_result']($request);
1112 1161
 	}
1113 1162
 	$replacements = array(
@@ -1135,11 +1184,13 @@  discard block
 block discarded – undo
1135 1184
 	loadLanguage('index+PersonalMessage');
1136 1185
 
1137 1186
 	// Add one to their unread and read message counts.
1138
-	foreach ($all_to as $k => $id)
1139
-		if (isset($deletes[$id]))
1187
+	foreach ($all_to as $k => $id) {
1188
+			if (isset($deletes[$id]))
1140 1189
 			unset($all_to[$k]);
1141
-	if (!empty($all_to))
1142
-		updateMemberData($all_to, array('instant_messages' => '+', 'unread_messages' => '+', 'new_pm' => 1));
1190
+	}
1191
+	if (!empty($all_to)) {
1192
+			updateMemberData($all_to, array('instant_messages' => '+', 'unread_messages' => '+', 'new_pm' => 1));
1193
+	}
1143 1194
 
1144 1195
 	return $log;
1145 1196
 }
@@ -1169,15 +1220,17 @@  discard block
 block discarded – undo
1169 1220
 		// Let's, for now, assume there are only &#021;'ish characters.
1170 1221
 		$simple = true;
1171 1222
 
1172
-		foreach ($matches[1] as $entity)
1173
-			if ($entity > 128)
1223
+		foreach ($matches[1] as $entity) {
1224
+					if ($entity > 128)
1174 1225
 				$simple = false;
1226
+		}
1175 1227
 		unset($matches);
1176 1228
 
1177
-		if ($simple)
1178
-			$string = preg_replace_callback('~&#(\d{3,8});~', function($m)
1229
+		if ($simple) {
1230
+					$string = preg_replace_callback('~&#(\d{3,8});~', function($m)
1179 1231
 			{
1180 1232
 				return chr("$m[1]");
1233
+		}
1181 1234
 			}, $string);
1182 1235
 		else
1183 1236
 		{
@@ -1185,8 +1238,9 @@  discard block
 block discarded – undo
1185 1238
 			if (!$context['utf8'] && function_exists('iconv'))
1186 1239
 			{
1187 1240
 				$newstring = @iconv($context['character_set'], 'UTF-8', $string);
1188
-				if ($newstring)
1189
-					$string = $newstring;
1241
+				if ($newstring) {
1242
+									$string = $newstring;
1243
+				}
1190 1244
 			}
1191 1245
 
1192 1246
 			$string = preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $string);
@@ -1202,23 +1256,25 @@  discard block
 block discarded – undo
1202 1256
 		if (!$context['utf8'] && function_exists('iconv'))
1203 1257
 		{
1204 1258
 			$newstring = @iconv($context['character_set'], 'UTF-8', $string);
1205
-			if ($newstring)
1206
-				$string = $newstring;
1259
+			if ($newstring) {
1260
+							$string = $newstring;
1261
+			}
1207 1262
 		}
1208 1263
 
1209 1264
 		$entityConvert = function($m)
1210 1265
 		{
1211 1266
 			$c = $m[1];
1212
-			if (strlen($c) === 1 && ord($c[0]) <= 0x7F)
1213
-				return $c;
1214
-			elseif (strlen($c) === 2 && ord($c[0]) >= 0xC0 && ord($c[0]) <= 0xDF)
1215
-				return "&#" . (((ord($c[0]) ^ 0xC0) << 6) + (ord($c[1]) ^ 0x80)) . ";";
1216
-			elseif (strlen($c) === 3 && ord($c[0]) >= 0xE0 && ord($c[0]) <= 0xEF)
1217
-				return "&#" . (((ord($c[0]) ^ 0xE0) << 12) + ((ord($c[1]) ^ 0x80) << 6) + (ord($c[2]) ^ 0x80)) . ";";
1218
-			elseif (strlen($c) === 4 && ord($c[0]) >= 0xF0 && ord($c[0]) <= 0xF7)
1219
-				return "&#" . (((ord($c[0]) ^ 0xF0) << 18) + ((ord($c[1]) ^ 0x80) << 12) + ((ord($c[2]) ^ 0x80) << 6) + (ord($c[3]) ^ 0x80)) . ";";
1220
-			else
1221
-				return "";
1267
+			if (strlen($c) === 1 && ord($c[0]) <= 0x7F) {
1268
+							return $c;
1269
+			} elseif (strlen($c) === 2 && ord($c[0]) >= 0xC0 && ord($c[0]) <= 0xDF) {
1270
+							return "&#" . (((ord($c[0]) ^ 0xC0) << 6) + (ord($c[1]) ^ 0x80)) . ";";
1271
+			} elseif (strlen($c) === 3 && ord($c[0]) >= 0xE0 && ord($c[0]) <= 0xEF) {
1272
+							return "&#" . (((ord($c[0]) ^ 0xE0) << 12) + ((ord($c[1]) ^ 0x80) << 6) + (ord($c[2]) ^ 0x80)) . ";";
1273
+			} elseif (strlen($c) === 4 && ord($c[0]) >= 0xF0 && ord($c[0]) <= 0xF7) {
1274
+							return "&#" . (((ord($c[0]) ^ 0xF0) << 18) + ((ord($c[1]) ^ 0x80) << 12) + ((ord($c[2]) ^ 0x80) << 6) + (ord($c[3]) ^ 0x80)) . ";";
1275
+			} else {
1276
+							return "";
1277
+			}
1222 1278
 		};
1223 1279
 
1224 1280
 		// Convert all 'special' characters to HTML entities.
@@ -1232,19 +1288,20 @@  discard block
 block discarded – undo
1232 1288
 		$string = base64_encode($string);
1233 1289
 
1234 1290
 		// Show the characterset and the transfer-encoding for header strings.
1235
-		if ($with_charset)
1236
-			$string = '=?' . $charset . '?B?' . $string . '?=';
1291
+		if ($with_charset) {
1292
+					$string = '=?' . $charset . '?B?' . $string . '?=';
1293
+		}
1237 1294
 
1238 1295
 		// Break it up in lines (mail body).
1239
-		else
1240
-			$string = chunk_split($string, 76, $line_break);
1296
+		else {
1297
+					$string = chunk_split($string, 76, $line_break);
1298
+		}
1241 1299
 
1242 1300
 		return array($charset, $string, 'base64');
1301
+	} else {
1302
+			return array($charset, $string, '7bit');
1303
+	}
1243 1304
 	}
1244
-
1245
-	else
1246
-		return array($charset, $string, '7bit');
1247
-}
1248 1305
 
1249 1306
 /**
1250 1307
  * Sends mail, like mail() but over SMTP.
@@ -1270,8 +1327,9 @@  discard block
 block discarded – undo
1270 1327
 	if ($modSettings['mail_type'] == 3 && $modSettings['smtp_username'] != '' && $modSettings['smtp_password'] != '')
1271 1328
 	{
1272 1329
 		$socket = fsockopen($modSettings['smtp_host'], 110, $errno, $errstr, 2);
1273
-		if (!$socket && (substr($modSettings['smtp_host'], 0, 5) == 'smtp.' || substr($modSettings['smtp_host'], 0, 11) == 'ssl://smtp.'))
1274
-			$socket = fsockopen(strtr($modSettings['smtp_host'], array('smtp.' => 'pop.')), 110, $errno, $errstr, 2);
1330
+		if (!$socket && (substr($modSettings['smtp_host'], 0, 5) == 'smtp.' || substr($modSettings['smtp_host'], 0, 11) == 'ssl://smtp.')) {
1331
+					$socket = fsockopen(strtr($modSettings['smtp_host'], array('smtp.' => 'pop.')), 110, $errno, $errstr, 2);
1332
+		}
1275 1333
 
1276 1334
 		if ($socket)
1277 1335
 		{
@@ -1293,11 +1351,13 @@  discard block
 block discarded – undo
1293 1351
 		if (substr($modSettings['smtp_host'], 0, 4) == 'ssl:' && (empty($modSettings['smtp_port']) || $modSettings['smtp_port'] == 25))
1294 1352
 		{
1295 1353
 			// ssl:hostname can cause fsocketopen to fail with a lookup failure, ensure it exists for this test.
1296
-			if (substr($modSettings['smtp_host'], 0, 6) != 'ssl://')
1297
-				$modSettings['smtp_host'] = str_replace('ssl:', 'ss://', $modSettings['smtp_host']);
1354
+			if (substr($modSettings['smtp_host'], 0, 6) != 'ssl://') {
1355
+							$modSettings['smtp_host'] = str_replace('ssl:', 'ss://', $modSettings['smtp_host']);
1356
+			}
1298 1357
 
1299
-			if ($socket = fsockopen($modSettings['smtp_host'], 465, $errno, $errstr, 3))
1300
-				log_error($txt['smtp_port_ssl']);
1358
+			if ($socket = fsockopen($modSettings['smtp_host'], 465, $errno, $errstr, 3)) {
1359
+							log_error($txt['smtp_port_ssl']);
1360
+			}
1301 1361
 		}
1302 1362
 
1303 1363
 		// Unable to connect!  Don't show any error message, but just log one and try to continue anyway.
@@ -1309,26 +1369,30 @@  discard block
 block discarded – undo
1309 1369
 	}
1310 1370
 
1311 1371
 	// Wait for a response of 220, without "-" continuer.
1312
-	if (!server_parse(null, $socket, '220'))
1313
-		return false;
1372
+	if (!server_parse(null, $socket, '220')) {
1373
+			return false;
1374
+	}
1314 1375
 
1315 1376
 	// Try to determine the server's fully qualified domain name
1316 1377
 	// Can't rely on $_SERVER['SERVER_NAME'] because it can be spoofed on Apache
1317 1378
 	if (empty($helo))
1318 1379
 	{
1319 1380
 		// See if we can get the domain name from the host itself
1320
-		if (function_exists('gethostname'))
1321
-			$helo = gethostname();
1322
-		elseif (function_exists('php_uname'))
1323
-			$helo = php_uname('n');
1381
+		if (function_exists('gethostname')) {
1382
+					$helo = gethostname();
1383
+		} elseif (function_exists('php_uname')) {
1384
+					$helo = php_uname('n');
1385
+		}
1324 1386
 
1325 1387
 		// If the hostname isn't a fully qualified domain name, we can use the host name from $boardurl instead
1326
-		if (empty($helo) || strpos($helo, '.') === false || substr_compare($helo, '.local', -6) === 0 || (!empty($modSettings['tld_regex']) && !preg_match('/\.' . $modSettings['tld_regex'] . '$/u', $helo)))
1327
-			$helo = parse_url($boardurl, PHP_URL_HOST);
1388
+		if (empty($helo) || strpos($helo, '.') === false || substr_compare($helo, '.local', -6) === 0 || (!empty($modSettings['tld_regex']) && !preg_match('/\.' . $modSettings['tld_regex'] . '$/u', $helo))) {
1389
+					$helo = parse_url($boardurl, PHP_URL_HOST);
1390
+		}
1328 1391
 
1329 1392
 		// This is one of those situations where 'www.' is undesirable
1330
-		if (strpos($helo, 'www.') === 0)
1331
-			$helo = substr($helo, 4);
1393
+		if (strpos($helo, 'www.') === 0) {
1394
+					$helo = substr($helo, 4);
1395
+		}
1332 1396
 	}
1333 1397
 
1334 1398
 	// SMTP = 1, SMTP - STARTTLS = 2
@@ -1341,8 +1405,9 @@  discard block
 block discarded – undo
1341 1405
 			if ($modSettings['mail_type'] == 2 && preg_match("~250( |-)STARTTLS~mi", $response))
1342 1406
 			{
1343 1407
 				// Send STARTTLS to enable encryption
1344
-				if (!server_parse('STARTTLS', $socket, '220'))
1345
-					return false;
1408
+				if (!server_parse('STARTTLS', $socket, '220')) {
1409
+									return false;
1410
+				}
1346 1411
 				// Enable the encryption
1347 1412
 				// php 5.6+ fix
1348 1413
 				$crypto_method = STREAM_CRYPTO_METHOD_TLS_CLIENT;
@@ -1353,30 +1418,35 @@  discard block
 block discarded – undo
1353 1418
 					$crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT;
1354 1419
 				}
1355 1420
 
1356
-				if (!@stream_socket_enable_crypto($socket, true, $crypto_method))
1357
-					return false;
1421
+				if (!@stream_socket_enable_crypto($socket, true, $crypto_method)) {
1422
+									return false;
1423
+				}
1358 1424
 				// Send the EHLO command again
1359
-				if (!server_parse('EHLO ' . $helo, $socket, null) == '250')
1360
-					return false;
1425
+				if (!server_parse('EHLO ' . $helo, $socket, null) == '250') {
1426
+									return false;
1427
+				}
1361 1428
 			}
1362 1429
 
1363
-			if (!server_parse('AUTH LOGIN', $socket, '334'))
1364
-				return false;
1430
+			if (!server_parse('AUTH LOGIN', $socket, '334')) {
1431
+							return false;
1432
+			}
1365 1433
 			// Send the username and password, encoded.
1366
-			if (!server_parse(base64_encode($modSettings['smtp_username']), $socket, '334'))
1367
-				return false;
1434
+			if (!server_parse(base64_encode($modSettings['smtp_username']), $socket, '334')) {
1435
+							return false;
1436
+			}
1368 1437
 			// The password is already encoded ;)
1369
-			if (!server_parse($modSettings['smtp_password'], $socket, '235'))
1370
-				return false;
1438
+			if (!server_parse($modSettings['smtp_password'], $socket, '235')) {
1439
+							return false;
1440
+			}
1441
+		} elseif (!server_parse('HELO ' . $helo, $socket, '250')) {
1442
+					return false;
1371 1443
 		}
1372
-		elseif (!server_parse('HELO ' . $helo, $socket, '250'))
1373
-			return false;
1374
-	}
1375
-	else
1444
+	} else
1376 1445
 	{
1377 1446
 		// Just say "helo".
1378
-		if (!server_parse('HELO ' . $helo, $socket, '250'))
1379
-			return false;
1447
+		if (!server_parse('HELO ' . $helo, $socket, '250')) {
1448
+					return false;
1449
+		}
1380 1450
 	}
1381 1451
 
1382 1452
 	// Fix the message for any lines beginning with a period! (the first is ignored, you see.)
@@ -1389,31 +1459,38 @@  discard block
 block discarded – undo
1389 1459
 		// Reset the connection to send another email.
1390 1460
 		if ($i != 0)
1391 1461
 		{
1392
-			if (!server_parse('RSET', $socket, '250'))
1393
-				return false;
1462
+			if (!server_parse('RSET', $socket, '250')) {
1463
+							return false;
1464
+			}
1394 1465
 		}
1395 1466
 
1396 1467
 		// From, to, and then start the data...
1397
-		if (!server_parse('MAIL FROM: <' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . '>', $socket, '250'))
1398
-			return false;
1399
-		if (!server_parse('RCPT TO: <' . $mail_to . '>', $socket, '250'))
1400
-			return false;
1401
-		if (!server_parse('DATA', $socket, '354'))
1402
-			return false;
1468
+		if (!server_parse('MAIL FROM: <' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . '>', $socket, '250')) {
1469
+					return false;
1470
+		}
1471
+		if (!server_parse('RCPT TO: <' . $mail_to . '>', $socket, '250')) {
1472
+					return false;
1473
+		}
1474
+		if (!server_parse('DATA', $socket, '354')) {
1475
+					return false;
1476
+		}
1403 1477
 		fputs($socket, 'Subject: ' . $subject . "\r\n");
1404
-		if (strlen($mail_to) > 0)
1405
-			fputs($socket, 'To: <' . $mail_to . '>' . "\r\n");
1478
+		if (strlen($mail_to) > 0) {
1479
+					fputs($socket, 'To: <' . $mail_to . '>' . "\r\n");
1480
+		}
1406 1481
 		fputs($socket, $headers . "\r\n\r\n");
1407 1482
 		fputs($socket, $message . "\r\n");
1408 1483
 
1409 1484
 		// Send a ., or in other words "end of data".
1410
-		if (!server_parse('.', $socket, '250'))
1411
-			return false;
1485
+		if (!server_parse('.', $socket, '250')) {
1486
+					return false;
1487
+		}
1412 1488
 
1413 1489
 		// Almost done, almost done... don't stop me just yet!
1414 1490
 		@set_time_limit(300);
1415
-		if (function_exists('apache_reset_timeout'))
1416
-			@apache_reset_timeout();
1491
+		if (function_exists('apache_reset_timeout')) {
1492
+					@apache_reset_timeout();
1493
+		}
1417 1494
 	}
1418 1495
 	fputs($socket, 'QUIT' . "\r\n");
1419 1496
 	fclose($socket);
@@ -1437,8 +1514,9 @@  discard block
 block discarded – undo
1437 1514
 {
1438 1515
 	global $txt;
1439 1516
 
1440
-	if ($message !== null)
1441
-		fputs($socket, $message . "\r\n");
1517
+	if ($message !== null) {
1518
+			fputs($socket, $message . "\r\n");
1519
+	}
1442 1520
 
1443 1521
 	// No response yet.
1444 1522
 	$server_response = '';
@@ -1454,8 +1532,9 @@  discard block
 block discarded – undo
1454 1532
 		$response .= $server_response;
1455 1533
 	}
1456 1534
 
1457
-	if ($code === null)
1458
-		return substr($server_response, 0, 3);
1535
+	if ($code === null) {
1536
+			return substr($server_response, 0, 3);
1537
+	}
1459 1538
 
1460 1539
 	if (substr($server_response, 0, 3) != $code)
1461 1540
 	{
@@ -1485,8 +1564,9 @@  discard block
 block discarded – undo
1485 1564
 	// Create a pspell or enchant dictionary resource
1486 1565
 	$dict = spell_init();
1487 1566
 
1488
-	if (!isset($_POST['spellstring']) || !$dict)
1489
-		die;
1567
+	if (!isset($_POST['spellstring']) || !$dict) {
1568
+			die;
1569
+	}
1490 1570
 
1491 1571
 	// Construct a bit of Javascript code.
1492 1572
 	$context['spell_js'] = '
@@ -1504,8 +1584,9 @@  discard block
 block discarded – undo
1504 1584
 		$check_word = explode('|', $alphas[$i]);
1505 1585
 
1506 1586
 		// If the word is a known word, or spelled right...
1507
-		if (in_array($smcFunc['strtolower']($check_word[0]), $known_words) || spell_check($dict, $check_word[0]) || !isset($check_word[2]))
1508
-			continue;
1587
+		if (in_array($smcFunc['strtolower']($check_word[0]), $known_words) || spell_check($dict, $check_word[0]) || !isset($check_word[2])) {
1588
+					continue;
1589
+		}
1509 1590
 
1510 1591
 		// Find the word, and move up the "last occurrence" to here.
1511 1592
 		$found_words = true;
@@ -1519,20 +1600,23 @@  discard block
 block discarded – undo
1519 1600
 		if (!empty($suggestions))
1520 1601
 		{
1521 1602
 			// But first check they aren't going to be censored - no naughty words!
1522
-			foreach ($suggestions as $k => $word)
1523
-				if ($suggestions[$k] != censorText($word))
1603
+			foreach ($suggestions as $k => $word) {
1604
+							if ($suggestions[$k] != censorText($word))
1524 1605
 					unset($suggestions[$k]);
1606
+			}
1525 1607
 
1526
-			if (!empty($suggestions))
1527
-				$context['spell_js'] .= '"' . implode('", "', $suggestions) . '"';
1608
+			if (!empty($suggestions)) {
1609
+							$context['spell_js'] .= '"' . implode('", "', $suggestions) . '"';
1610
+			}
1528 1611
 		}
1529 1612
 
1530 1613
 		$context['spell_js'] .= ']),';
1531 1614
 	}
1532 1615
 
1533 1616
 	// If words were found, take off the last comma.
1534
-	if ($found_words)
1535
-		$context['spell_js'] = substr($context['spell_js'], 0, -1);
1617
+	if ($found_words) {
1618
+			$context['spell_js'] = substr($context['spell_js'], 0, -1);
1619
+	}
1536 1620
 
1537 1621
 	$context['spell_js'] .= '
1538 1622
 		);';
@@ -1567,11 +1651,13 @@  discard block
 block discarded – undo
1567 1651
 	global $user_info, $smcFunc;
1568 1652
 
1569 1653
 	// Can't do it if there's no topics.
1570
-	if (empty($topics))
1571
-		return;
1654
+	if (empty($topics)) {
1655
+			return;
1656
+	}
1572 1657
 	// It must be an array - it must!
1573
-	if (!is_array($topics))
1574
-		$topics = array($topics);
1658
+	if (!is_array($topics)) {
1659
+			$topics = array($topics);
1660
+	}
1575 1661
 
1576 1662
 	// Get the subject and body...
1577 1663
 	$result = $smcFunc['db_query']('', '
@@ -1619,14 +1705,15 @@  discard block
 block discarded – undo
1619 1705
 	}
1620 1706
 	$smcFunc['db_free_result']($result);
1621 1707
 
1622
-	if (!empty($task_rows))
1623
-		$smcFunc['db_insert']('',
1708
+	if (!empty($task_rows)) {
1709
+			$smcFunc['db_insert']('',
1624 1710
 			'{db_prefix}background_tasks',
1625 1711
 			array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'),
1626 1712
 			$task_rows,
1627 1713
 			array('id_task')
1628 1714
 		);
1629
-}
1715
+	}
1716
+	}
1630 1717
 
1631 1718
 /**
1632 1719
  * Create a post, either as new topic (id_topic = 0) or in an existing one.
@@ -1664,9 +1751,9 @@  discard block
 block discarded – undo
1664 1751
 	$msgOptions['send_notifications'] = isset($msgOptions['send_notifications']) ? (bool) $msgOptions['send_notifications'] : true;
1665 1752
 
1666 1753
 	// We need to know if the topic is approved. If we're told that's great - if not find out.
1667
-	if (!$modSettings['postmod_active'])
1668
-		$topicOptions['is_approved'] = true;
1669
-	elseif (!empty($topicOptions['id']) && !isset($topicOptions['is_approved']))
1754
+	if (!$modSettings['postmod_active']) {
1755
+			$topicOptions['is_approved'] = true;
1756
+	} elseif (!empty($topicOptions['id']) && !isset($topicOptions['is_approved']))
1670 1757
 	{
1671 1758
 		$request = $smcFunc['db_query']('', '
1672 1759
 			SELECT approved
@@ -1689,8 +1776,7 @@  discard block
 block discarded – undo
1689 1776
 			$posterOptions['id'] = 0;
1690 1777
 			$posterOptions['name'] = $txt['guest_title'];
1691 1778
 			$posterOptions['email'] = '';
1692
-		}
1693
-		elseif ($posterOptions['id'] != $user_info['id'])
1779
+		} elseif ($posterOptions['id'] != $user_info['id'])
1694 1780
 		{
1695 1781
 			$request = $smcFunc['db_query']('', '
1696 1782
 				SELECT member_name, email_address
@@ -1708,12 +1794,11 @@  discard block
 block discarded – undo
1708 1794
 				$posterOptions['id'] = 0;
1709 1795
 				$posterOptions['name'] = $txt['guest_title'];
1710 1796
 				$posterOptions['email'] = '';
1797
+			} else {
1798
+							list ($posterOptions['name'], $posterOptions['email']) = $smcFunc['db_fetch_row']($request);
1711 1799
 			}
1712
-			else
1713
-				list ($posterOptions['name'], $posterOptions['email']) = $smcFunc['db_fetch_row']($request);
1714 1800
 			$smcFunc['db_free_result']($request);
1715
-		}
1716
-		else
1801
+		} else
1717 1802
 		{
1718 1803
 			$posterOptions['name'] = $user_info['name'];
1719 1804
 			$posterOptions['email'] = $user_info['email'];
@@ -1723,8 +1808,9 @@  discard block
 block discarded – undo
1723 1808
 	if (!empty($modSettings['enable_mentions']))
1724 1809
 	{
1725 1810
 		$msgOptions['mentioned_members'] = Mentions::getMentionedMembers($msgOptions['body']);
1726
-		if (!empty($msgOptions['mentioned_members']))
1727
-			$msgOptions['body'] = Mentions::getBody($msgOptions['body'], $msgOptions['mentioned_members']);
1811
+		if (!empty($msgOptions['mentioned_members'])) {
1812
+					$msgOptions['body'] = Mentions::getBody($msgOptions['body'], $msgOptions['mentioned_members']);
1813
+		}
1728 1814
 	}
1729 1815
 
1730 1816
 	// It's do or die time: forget any user aborts!
@@ -1757,12 +1843,13 @@  discard block
 block discarded – undo
1757 1843
 	);
1758 1844
 
1759 1845
 	// Something went wrong creating the message...
1760
-	if (empty($msgOptions['id']))
1761
-		return false;
1846
+	if (empty($msgOptions['id'])) {
1847
+			return false;
1848
+	}
1762 1849
 
1763 1850
 	// Fix the attachments.
1764
-	if (!empty($msgOptions['attachments']))
1765
-		$smcFunc['db_query']('', '
1851
+	if (!empty($msgOptions['attachments'])) {
1852
+			$smcFunc['db_query']('', '
1766 1853
 			UPDATE {db_prefix}attachments
1767 1854
 			SET id_msg = {int:id_msg}
1768 1855
 			WHERE id_attach IN ({array_int:attachment_list})',
@@ -1771,6 +1858,7 @@  discard block
 block discarded – undo
1771 1858
 				'id_msg' => $msgOptions['id'],
1772 1859
 			)
1773 1860
 		);
1861
+	}
1774 1862
 
1775 1863
 	// What if we want to export new posts out to a CMS?
1776 1864
 	call_integration_hook('integrate_after_create_post', array($msgOptions, $topicOptions, $posterOptions, $message_columns, $message_parameters));
@@ -1847,20 +1935,23 @@  discard block
 block discarded – undo
1847 1935
 			'id_topic' => $topicOptions['id'],
1848 1936
 			'counter_increment' => 1,
1849 1937
 		);
1850
-		if ($msgOptions['approved'])
1851
-			$topics_columns = array(
1938
+		if ($msgOptions['approved']) {
1939
+					$topics_columns = array(
1852 1940
 				'id_member_updated = {int:poster_id}',
1853 1941
 				'id_last_msg = {int:id_msg}',
1854 1942
 				'num_replies = num_replies + {int:counter_increment}',
1855 1943
 			);
1856
-		else
1857
-			$topics_columns = array(
1944
+		} else {
1945
+					$topics_columns = array(
1858 1946
 				'unapproved_posts = unapproved_posts + {int:counter_increment}',
1859 1947
 			);
1860
-		if ($topicOptions['lock_mode'] !== null)
1861
-			$topics_columns[] = 'locked = {int:locked}';
1862
-		if ($topicOptions['sticky_mode'] !== null)
1863
-			$topics_columns[] = 'is_sticky = {int:is_sticky}';
1948
+		}
1949
+		if ($topicOptions['lock_mode'] !== null) {
1950
+					$topics_columns[] = 'locked = {int:locked}';
1951
+		}
1952
+		if ($topicOptions['sticky_mode'] !== null) {
1953
+					$topics_columns[] = 'is_sticky = {int:is_sticky}';
1954
+		}
1864 1955
 
1865 1956
 		call_integration_hook('integrate_modify_topic', array(&$topics_columns, &$update_parameters, &$msgOptions, &$topicOptions, &$posterOptions));
1866 1957
 
@@ -1889,8 +1980,8 @@  discard block
 block discarded – undo
1889 1980
 	);
1890 1981
 
1891 1982
 	// Increase the number of posts and topics on the board.
1892
-	if ($msgOptions['approved'])
1893
-		$smcFunc['db_query']('', '
1983
+	if ($msgOptions['approved']) {
1984
+			$smcFunc['db_query']('', '
1894 1985
 			UPDATE {db_prefix}boards
1895 1986
 			SET num_posts = num_posts + 1' . ($new_topic ? ', num_topics = num_topics + 1' : '') . '
1896 1987
 			WHERE id_board = {int:id_board}',
@@ -1898,7 +1989,7 @@  discard block
 block discarded – undo
1898 1989
 				'id_board' => $topicOptions['board'],
1899 1990
 			)
1900 1991
 		);
1901
-	else
1992
+	} else
1902 1993
 	{
1903 1994
 		$smcFunc['db_query']('', '
1904 1995
 			UPDATE {db_prefix}boards
@@ -1968,8 +2059,8 @@  discard block
 block discarded – undo
1968 2059
 		}
1969 2060
 	}
1970 2061
 
1971
-	if ($msgOptions['approved'] && empty($topicOptions['is_approved']))
1972
-		$smcFunc['db_insert']('',
2062
+	if ($msgOptions['approved'] && empty($topicOptions['is_approved'])) {
2063
+			$smcFunc['db_insert']('',
1973 2064
 			'{db_prefix}background_tasks',
1974 2065
 			array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'),
1975 2066
 			array(
@@ -1981,19 +2072,22 @@  discard block
 block discarded – undo
1981 2072
 			),
1982 2073
 			array('id_task')
1983 2074
 		);
2075
+	}
1984 2076
 
1985 2077
 	// If there's a custom search index, it may need updating...
1986 2078
 	require_once($sourcedir . '/Search.php');
1987 2079
 	$searchAPI = findSearchAPI();
1988
-	if (is_callable(array($searchAPI, 'postCreated')))
1989
-		$searchAPI->postCreated($msgOptions, $topicOptions, $posterOptions);
2080
+	if (is_callable(array($searchAPI, 'postCreated'))) {
2081
+			$searchAPI->postCreated($msgOptions, $topicOptions, $posterOptions);
2082
+	}
1990 2083
 
1991 2084
 	// Increase the post counter for the user that created the post.
1992 2085
 	if (!empty($posterOptions['update_post_count']) && !empty($posterOptions['id']) && $msgOptions['approved'])
1993 2086
 	{
1994 2087
 		// Are you the one that happened to create this post?
1995
-		if ($user_info['id'] == $posterOptions['id'])
1996
-			$user_info['posts']++;
2088
+		if ($user_info['id'] == $posterOptions['id']) {
2089
+					$user_info['posts']++;
2090
+		}
1997 2091
 		updateMemberData($posterOptions['id'], array('posts' => '+'));
1998 2092
 	}
1999 2093
 
@@ -2001,19 +2095,21 @@  discard block
 block discarded – undo
2001 2095
 	$_SESSION['last_read_topic'] = 0;
2002 2096
 
2003 2097
 	// Better safe than sorry.
2004
-	if (isset($_SESSION['topicseen_cache'][$topicOptions['board']]))
2005
-		$_SESSION['topicseen_cache'][$topicOptions['board']]--;
2098
+	if (isset($_SESSION['topicseen_cache'][$topicOptions['board']])) {
2099
+			$_SESSION['topicseen_cache'][$topicOptions['board']]--;
2100
+	}
2006 2101
 
2007 2102
 	// Update all the stats so everyone knows about this new topic and message.
2008 2103
 	updateStats('message', true, $msgOptions['id']);
2009 2104
 
2010 2105
 	// Update the last message on the board assuming it's approved AND the topic is.
2011
-	if ($msgOptions['approved'])
2012
-		updateLastMessages($topicOptions['board'], $new_topic || !empty($topicOptions['is_approved']) ? $msgOptions['id'] : 0);
2106
+	if ($msgOptions['approved']) {
2107
+			updateLastMessages($topicOptions['board'], $new_topic || !empty($topicOptions['is_approved']) ? $msgOptions['id'] : 0);
2108
+	}
2013 2109
 
2014 2110
 	// Queue createPost background notification
2015
-	if ($msgOptions['send_notifications'] && $msgOptions['approved'])
2016
-		$smcFunc['db_insert']('',
2111
+	if ($msgOptions['send_notifications'] && $msgOptions['approved']) {
2112
+			$smcFunc['db_insert']('',
2017 2113
 			'{db_prefix}background_tasks',
2018 2114
 			array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'),
2019 2115
 			array('$sourcedir/tasks/CreatePost-Notify.php', 'CreatePost_Notify_Background', $smcFunc['json_encode'](array(
@@ -2024,6 +2120,7 @@  discard block
 block discarded – undo
2024 2120
 			)), 0),
2025 2121
 			array('id_task')
2026 2122
 		);
2123
+	}
2027 2124
 
2028 2125
 	// Alright, done now... we can abort now, I guess... at least this much is done.
2029 2126
 	ignore_user_abort($previous_ignore_user_abort);
@@ -2050,14 +2147,18 @@  discard block
 block discarded – undo
2050 2147
 
2051 2148
 	// This is longer than it has to be, but makes it so we only set/change what we have to.
2052 2149
 	$messages_columns = array();
2053
-	if (isset($posterOptions['name']))
2054
-		$messages_columns['poster_name'] = $posterOptions['name'];
2055
-	if (isset($posterOptions['email']))
2056
-		$messages_columns['poster_email'] = $posterOptions['email'];
2057
-	if (isset($msgOptions['icon']))
2058
-		$messages_columns['icon'] = $msgOptions['icon'];
2059
-	if (isset($msgOptions['subject']))
2060
-		$messages_columns['subject'] = $msgOptions['subject'];
2150
+	if (isset($posterOptions['name'])) {
2151
+			$messages_columns['poster_name'] = $posterOptions['name'];
2152
+	}
2153
+	if (isset($posterOptions['email'])) {
2154
+			$messages_columns['poster_email'] = $posterOptions['email'];
2155
+	}
2156
+	if (isset($msgOptions['icon'])) {
2157
+			$messages_columns['icon'] = $msgOptions['icon'];
2158
+	}
2159
+	if (isset($msgOptions['subject'])) {
2160
+			$messages_columns['subject'] = $msgOptions['subject'];
2161
+	}
2061 2162
 	if (isset($msgOptions['body']))
2062 2163
 	{
2063 2164
 		$messages_columns['body'] = $msgOptions['body'];
@@ -2084,8 +2185,9 @@  discard block
 block discarded – undo
2084 2185
 		$messages_columns['modified_reason'] = $msgOptions['modify_reason'];
2085 2186
 		$messages_columns['id_msg_modified'] = $modSettings['maxMsgID'];
2086 2187
 	}
2087
-	if (isset($msgOptions['smileys_enabled']))
2088
-		$messages_columns['smileys_enabled'] = empty($msgOptions['smileys_enabled']) ? 0 : 1;
2188
+	if (isset($msgOptions['smileys_enabled'])) {
2189
+			$messages_columns['smileys_enabled'] = empty($msgOptions['smileys_enabled']) ? 0 : 1;
2190
+	}
2089 2191
 
2090 2192
 	// Which columns need to be ints?
2091 2193
 	$messageInts = array('modified_time', 'id_msg_modified', 'smileys_enabled');
@@ -2096,8 +2198,9 @@  discard block
 block discarded – undo
2096 2198
 	// Update search api
2097 2199
 	require_once($sourcedir . '/Search.php');
2098 2200
 	$searchAPI = findSearchAPI();
2099
-	if ($searchAPI->supportsMethod('postRemoved'))
2100
-		$searchAPI->postRemoved($msgOptions['id']);
2201
+	if ($searchAPI->supportsMethod('postRemoved')) {
2202
+			$searchAPI->postRemoved($msgOptions['id']);
2203
+	}
2101 2204
 
2102 2205
 	if (!empty($modSettings['enable_mentions']) && isset($msgOptions['body']))
2103 2206
 	{
@@ -2109,23 +2212,27 @@  discard block
 block discarded – undo
2109 2212
 		{
2110 2213
 			preg_match_all('/\[member\=([0-9]+)\]([^\[]*)\[\/member\]/U', $msgOptions['old_body'], $match);
2111 2214
 
2112
-			if (isset($match[1]) && isset($match[2]) && is_array($match[1]) && is_array($match[2]))
2113
-				foreach ($match[1] as $i => $oldID)
2215
+			if (isset($match[1]) && isset($match[2]) && is_array($match[1]) && is_array($match[2])) {
2216
+							foreach ($match[1] as $i => $oldID)
2114 2217
 					$oldmentions[$oldID] = array('id' => $oldID, 'real_name' => $match[2][$i]);
2218
+			}
2115 2219
 
2116
-			if (empty($modSettings['search_custom_index_config']))
2117
-				unset($msgOptions['old_body']);
2220
+			if (empty($modSettings['search_custom_index_config'])) {
2221
+							unset($msgOptions['old_body']);
2222
+			}
2118 2223
 		}
2119 2224
 
2120 2225
 		$mentions = Mentions::getMentionedMembers($msgOptions['body']);
2121 2226
 		$messages_columns['body'] = $msgOptions['body'] = Mentions::getBody($msgOptions['body'], $mentions);
2122 2227
 
2123 2228
 		// Remove the poster.
2124
-		if (isset($mentions[$user_info['id']]))
2125
-			unset($mentions[$user_info['id']]);
2229
+		if (isset($mentions[$user_info['id']])) {
2230
+					unset($mentions[$user_info['id']]);
2231
+		}
2126 2232
 
2127
-		if (isset($oldmentions[$user_info['id']]))
2128
-			unset($oldmentions[$user_info['id']]);
2233
+		if (isset($oldmentions[$user_info['id']])) {
2234
+					unset($oldmentions[$user_info['id']]);
2235
+		}
2129 2236
 
2130 2237
 		if (is_array($mentions) && is_array($oldmentions) && count(array_diff_key($mentions, $oldmentions)) > 0 && count($mentions) > count($oldmentions))
2131 2238
 		{
@@ -2155,8 +2262,9 @@  discard block
 block discarded – undo
2155 2262
 	}
2156 2263
 
2157 2264
 	// Nothing to do?
2158
-	if (empty($messages_columns))
2159
-		return true;
2265
+	if (empty($messages_columns)) {
2266
+			return true;
2267
+	}
2160 2268
 
2161 2269
 	// Change the post.
2162 2270
 	$smcFunc['db_query']('', '
@@ -2217,8 +2325,9 @@  discard block
 block discarded – undo
2217 2325
 	// If there's a custom search index, it needs to be modified...
2218 2326
 	require_once($sourcedir . '/Search.php');
2219 2327
 	$searchAPI = findSearchAPI();
2220
-	if (is_callable(array($searchAPI, 'postModified')))
2221
-		$searchAPI->postModified($msgOptions, $topicOptions, $posterOptions);
2328
+	if (is_callable(array($searchAPI, 'postModified'))) {
2329
+			$searchAPI->postModified($msgOptions, $topicOptions, $posterOptions);
2330
+	}
2222 2331
 
2223 2332
 	if (isset($msgOptions['subject']))
2224 2333
 	{
@@ -2232,14 +2341,16 @@  discard block
 block discarded – undo
2232 2341
 				'id_first_msg' => $msgOptions['id'],
2233 2342
 			)
2234 2343
 		);
2235
-		if ($smcFunc['db_num_rows']($request) == 1)
2236
-			updateStats('subject', $topicOptions['id'], $msgOptions['subject']);
2344
+		if ($smcFunc['db_num_rows']($request) == 1) {
2345
+					updateStats('subject', $topicOptions['id'], $msgOptions['subject']);
2346
+		}
2237 2347
 		$smcFunc['db_free_result']($request);
2238 2348
 	}
2239 2349
 
2240 2350
 	// Finally, if we are setting the approved state we need to do much more work :(
2241
-	if ($modSettings['postmod_active'] && isset($msgOptions['approved']))
2242
-		approvePosts($msgOptions['id'], $msgOptions['approved']);
2351
+	if ($modSettings['postmod_active'] && isset($msgOptions['approved'])) {
2352
+			approvePosts($msgOptions['id'], $msgOptions['approved']);
2353
+	}
2243 2354
 
2244 2355
 	return true;
2245 2356
 }
@@ -2256,11 +2367,13 @@  discard block
 block discarded – undo
2256 2367
 {
2257 2368
 	global $smcFunc;
2258 2369
 
2259
-	if (!is_array($msgs))
2260
-		$msgs = array($msgs);
2370
+	if (!is_array($msgs)) {
2371
+			$msgs = array($msgs);
2372
+	}
2261 2373
 
2262
-	if (empty($msgs))
2263
-		return false;
2374
+	if (empty($msgs)) {
2375
+			return false;
2376
+	}
2264 2377
 
2265 2378
 	// May as well start at the beginning, working out *what* we need to change.
2266 2379
 	$request = $smcFunc['db_query']('', '
@@ -2292,20 +2405,22 @@  discard block
 block discarded – undo
2292 2405
 		$topics[] = $row['id_topic'];
2293 2406
 
2294 2407
 		// Ensure our change array exists already.
2295
-		if (!isset($topic_changes[$row['id_topic']]))
2296
-			$topic_changes[$row['id_topic']] = array(
2408
+		if (!isset($topic_changes[$row['id_topic']])) {
2409
+					$topic_changes[$row['id_topic']] = array(
2297 2410
 				'id_last_msg' => $row['id_last_msg'],
2298 2411
 				'approved' => $row['topic_approved'],
2299 2412
 				'replies' => 0,
2300 2413
 				'unapproved_posts' => 0,
2301 2414
 			);
2302
-		if (!isset($board_changes[$row['id_board']]))
2303
-			$board_changes[$row['id_board']] = array(
2415
+		}
2416
+		if (!isset($board_changes[$row['id_board']])) {
2417
+					$board_changes[$row['id_board']] = array(
2304 2418
 				'posts' => 0,
2305 2419
 				'topics' => 0,
2306 2420
 				'unapproved_posts' => 0,
2307 2421
 				'unapproved_topics' => 0,
2308 2422
 			);
2423
+		}
2309 2424
 
2310 2425
 		// If it's the first message then the topic state changes!
2311 2426
 		if ($row['id_msg'] == $row['id_first_msg'])
@@ -2326,14 +2441,13 @@  discard block
 block discarded – undo
2326 2441
 				'poster' => $row['id_member'],
2327 2442
 				'new_topic' => true,
2328 2443
 			);
2329
-		}
2330
-		else
2444
+		} else
2331 2445
 		{
2332 2446
 			$topic_changes[$row['id_topic']]['replies'] += $approve ? 1 : -1;
2333 2447
 
2334 2448
 			// This will be a post... but don't notify unless it's not followed by approved ones.
2335
-			if ($row['id_msg'] > $row['id_last_msg'])
2336
-				$notification_posts[$row['id_topic']] = array(
2449
+			if ($row['id_msg'] > $row['id_last_msg']) {
2450
+							$notification_posts[$row['id_topic']] = array(
2337 2451
 					'id' => $row['id_msg'],
2338 2452
 					'body' => $row['body'],
2339 2453
 					'subject' => $row['subject'],
@@ -2344,28 +2458,33 @@  discard block
 block discarded – undo
2344 2458
 					'new_topic' => false,
2345 2459
 					'msg' => $row['id_msg'],
2346 2460
 				);
2461
+			}
2347 2462
 		}
2348 2463
 
2349 2464
 		// If this is being approved and id_msg is higher than the current id_last_msg then it changes.
2350
-		if ($approve && $row['id_msg'] > $topic_changes[$row['id_topic']]['id_last_msg'])
2351
-			$topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_msg'];
2465
+		if ($approve && $row['id_msg'] > $topic_changes[$row['id_topic']]['id_last_msg']) {
2466
+					$topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_msg'];
2467
+		}
2352 2468
 		// If this is being unapproved, and it's equal to the id_last_msg we need to find a new one!
2353
-		elseif (!$approve)
2354
-			// Default to the first message and then we'll override in a bit ;)
2469
+		elseif (!$approve) {
2470
+					// Default to the first message and then we'll override in a bit ;)
2355 2471
 			$topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_first_msg'];
2472
+		}
2356 2473
 
2357 2474
 		$topic_changes[$row['id_topic']]['unapproved_posts'] += $approve ? -1 : 1;
2358 2475
 		$board_changes[$row['id_board']]['unapproved_posts'] += $approve ? -1 : 1;
2359 2476
 		$board_changes[$row['id_board']]['posts'] += $approve ? 1 : -1;
2360 2477
 
2361 2478
 		// Post count for the user?
2362
-		if ($row['id_member'] && empty($row['count_posts']))
2363
-			$member_post_changes[$row['id_member']] = isset($member_post_changes[$row['id_member']]) ? $member_post_changes[$row['id_member']] + 1 : 1;
2479
+		if ($row['id_member'] && empty($row['count_posts'])) {
2480
+					$member_post_changes[$row['id_member']] = isset($member_post_changes[$row['id_member']]) ? $member_post_changes[$row['id_member']] + 1 : 1;
2481
+		}
2364 2482
 	}
2365 2483
 	$smcFunc['db_free_result']($request);
2366 2484
 
2367
-	if (empty($msgs))
2368
-		return;
2485
+	if (empty($msgs)) {
2486
+			return;
2487
+	}
2369 2488
 
2370 2489
 	// Now we have the differences make the changes, first the easy one.
2371 2490
 	$smcFunc['db_query']('', '
@@ -2392,14 +2511,15 @@  discard block
 block discarded – undo
2392 2511
 				'approved' => 1,
2393 2512
 			)
2394 2513
 		);
2395
-		while ($row = $smcFunc['db_fetch_assoc']($request))
2396
-			$topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_last_msg'];
2514
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
2515
+					$topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_last_msg'];
2516
+		}
2397 2517
 		$smcFunc['db_free_result']($request);
2398 2518
 	}
2399 2519
 
2400 2520
 	// ... next the topics...
2401
-	foreach ($topic_changes as $id => $changes)
2402
-		$smcFunc['db_query']('', '
2521
+	foreach ($topic_changes as $id => $changes) {
2522
+			$smcFunc['db_query']('', '
2403 2523
 			UPDATE {db_prefix}topics
2404 2524
 			SET approved = {int:approved}, unapproved_posts = unapproved_posts + {int:unapproved_posts},
2405 2525
 				num_replies = num_replies + {int:num_replies}, id_last_msg = {int:id_last_msg}
@@ -2412,10 +2532,11 @@  discard block
 block discarded – undo
2412 2532
 				'id_topic' => $id,
2413 2533
 			)
2414 2534
 		);
2535
+	}
2415 2536
 
2416 2537
 	// ... finally the boards...
2417
-	foreach ($board_changes as $id => $changes)
2418
-		$smcFunc['db_query']('', '
2538
+	foreach ($board_changes as $id => $changes) {
2539
+			$smcFunc['db_query']('', '
2419 2540
 			UPDATE {db_prefix}boards
2420 2541
 			SET num_posts = num_posts + {int:num_posts}, unapproved_posts = unapproved_posts + {int:unapproved_posts},
2421 2542
 				num_topics = num_topics + {int:num_topics}, unapproved_topics = unapproved_topics + {int:unapproved_topics}
@@ -2428,13 +2549,14 @@  discard block
 block discarded – undo
2428 2549
 				'id_board' => $id,
2429 2550
 			)
2430 2551
 		);
2552
+	}
2431 2553
 
2432 2554
 	// Finally, least importantly, notifications!
2433 2555
 	if ($approve)
2434 2556
 	{
2435 2557
 		$task_rows = array();
2436
-		foreach (array_merge($notification_topics, $notification_posts) as $topic)
2437
-			$task_rows[] = array(
2558
+		foreach (array_merge($notification_topics, $notification_posts) as $topic) {
2559
+					$task_rows[] = array(
2438 2560
 				'$sourcedir/tasks/CreatePost-Notify.php', 'CreatePost_Notify_Background', $smcFunc['json_encode'](array(
2439 2561
 					'msgOptions' => array(
2440 2562
 						'id' => $topic['msg'],
@@ -2452,14 +2574,16 @@  discard block
 block discarded – undo
2452 2574
 					'type' => $topic['new_topic'] ? 'topic' : 'reply',
2453 2575
 				)), 0
2454 2576
 			);
2577
+		}
2455 2578
 
2456
-		if ($notify)
2457
-			$smcFunc['db_insert']('',
2579
+		if ($notify) {
2580
+					$smcFunc['db_insert']('',
2458 2581
 				'{db_prefix}background_tasks',
2459 2582
 				array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'),
2460 2583
 				$task_rows,
2461 2584
 				array('id_task')
2462 2585
 			);
2586
+		}
2463 2587
 
2464 2588
 		$smcFunc['db_query']('', '
2465 2589
 			DELETE FROM {db_prefix}approval_queue
@@ -2475,8 +2599,9 @@  discard block
 block discarded – undo
2475 2599
 	else
2476 2600
 	{
2477 2601
 		$msgInserts = array();
2478
-		foreach ($msgs as $msg)
2479
-			$msgInserts[] = array($msg);
2602
+		foreach ($msgs as $msg) {
2603
+					$msgInserts[] = array($msg);
2604
+		}
2480 2605
 
2481 2606
 		$smcFunc['db_insert']('ignore',
2482 2607
 			'{db_prefix}approval_queue',
@@ -2490,9 +2615,10 @@  discard block
 block discarded – undo
2490 2615
 	updateLastMessages(array_keys($board_changes));
2491 2616
 
2492 2617
 	// Post count for the members?
2493
-	if (!empty($member_post_changes))
2494
-		foreach ($member_post_changes as $id_member => $count_change)
2618
+	if (!empty($member_post_changes)) {
2619
+			foreach ($member_post_changes as $id_member => $count_change)
2495 2620
 			updateMemberData($id_member, array('posts' => 'posts ' . ($approve ? '+' : '-') . ' ' . $count_change));
2621
+	}
2496 2622
 
2497 2623
 	return true;
2498 2624
 }
@@ -2509,11 +2635,13 @@  discard block
 block discarded – undo
2509 2635
 {
2510 2636
 	global $smcFunc;
2511 2637
 
2512
-	if (!is_array($topics))
2513
-		$topics = array($topics);
2638
+	if (!is_array($topics)) {
2639
+			$topics = array($topics);
2640
+	}
2514 2641
 
2515
-	if (empty($topics))
2516
-		return false;
2642
+	if (empty($topics)) {
2643
+			return false;
2644
+	}
2517 2645
 
2518 2646
 	$approve_type = $approve ? 0 : 1;
2519 2647
 
@@ -2529,8 +2657,9 @@  discard block
 block discarded – undo
2529 2657
 		)
2530 2658
 	);
2531 2659
 	$msgs = array();
2532
-	while ($row = $smcFunc['db_fetch_assoc']($request))
2533
-		$msgs[] = $row['id_msg'];
2660
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
2661
+			$msgs[] = $row['id_msg'];
2662
+	}
2534 2663
 	$smcFunc['db_free_result']($request);
2535 2664
 
2536 2665
 	return approvePosts($msgs, $approve);
@@ -2553,11 +2682,13 @@  discard block
 block discarded – undo
2553 2682
 	global $board_info, $board, $smcFunc;
2554 2683
 
2555 2684
 	// Please - let's be sane.
2556
-	if (empty($setboards))
2557
-		return false;
2685
+	if (empty($setboards)) {
2686
+			return false;
2687
+	}
2558 2688
 
2559
-	if (!is_array($setboards))
2560
-		$setboards = array($setboards);
2689
+	if (!is_array($setboards)) {
2690
+			$setboards = array($setboards);
2691
+	}
2561 2692
 
2562 2693
 	// If we don't know the id_msg we need to find it.
2563 2694
 	if (!$id_msg)
@@ -2575,15 +2706,16 @@  discard block
 block discarded – undo
2575 2706
 			)
2576 2707
 		);
2577 2708
 		$lastMsg = array();
2578
-		while ($row = $smcFunc['db_fetch_assoc']($request))
2579
-			$lastMsg[$row['id_board']] = $row['id_msg'];
2709
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
2710
+					$lastMsg[$row['id_board']] = $row['id_msg'];
2711
+		}
2580 2712
 		$smcFunc['db_free_result']($request);
2581
-	}
2582
-	else
2713
+	} else
2583 2714
 	{
2584 2715
 		// Just to note - there should only be one board passed if we are doing this.
2585
-		foreach ($setboards as $id_board)
2586
-			$lastMsg[$id_board] = $id_msg;
2716
+		foreach ($setboards as $id_board) {
2717
+					$lastMsg[$id_board] = $id_msg;
2718
+		}
2587 2719
 	}
2588 2720
 
2589 2721
 	$parent_boards = array();
@@ -2598,10 +2730,11 @@  discard block
 block discarded – undo
2598 2730
 			$lastModified[$id_board] = 0;
2599 2731
 		}
2600 2732
 
2601
-		if (!empty($board) && $id_board == $board)
2602
-			$parents = $board_info['parent_boards'];
2603
-		else
2604
-			$parents = getBoardParents($id_board);
2733
+		if (!empty($board) && $id_board == $board) {
2734
+					$parents = $board_info['parent_boards'];
2735
+		} else {
2736
+					$parents = getBoardParents($id_board);
2737
+		}
2605 2738
 
2606 2739
 		// Ignore any parents on the top child level.
2607 2740
 		// @todo Why?
@@ -2610,10 +2743,11 @@  discard block
 block discarded – undo
2610 2743
 			if ($parent['level'] != 0)
2611 2744
 			{
2612 2745
 				// If we're already doing this one as a board, is this a higher last modified?
2613
-				if (isset($lastModified[$id]) && $lastModified[$id_board] > $lastModified[$id])
2614
-					$lastModified[$id] = $lastModified[$id_board];
2615
-				elseif (!isset($lastModified[$id]) && (!isset($parent_boards[$id]) || $parent_boards[$id] < $lastModified[$id_board]))
2616
-					$parent_boards[$id] = $lastModified[$id_board];
2746
+				if (isset($lastModified[$id]) && $lastModified[$id_board] > $lastModified[$id]) {
2747
+									$lastModified[$id] = $lastModified[$id_board];
2748
+				} elseif (!isset($lastModified[$id]) && (!isset($parent_boards[$id]) || $parent_boards[$id] < $lastModified[$id_board])) {
2749
+									$parent_boards[$id] = $lastModified[$id_board];
2750
+				}
2617 2751
 			}
2618 2752
 		}
2619 2753
 	}
@@ -2626,23 +2760,24 @@  discard block
 block discarded – undo
2626 2760
 	// Finally, to save on queries make the changes...
2627 2761
 	foreach ($parent_boards as $id => $msg)
2628 2762
 	{
2629
-		if (!isset($parent_updates[$msg]))
2630
-			$parent_updates[$msg] = array($id);
2631
-		else
2632
-			$parent_updates[$msg][] = $id;
2763
+		if (!isset($parent_updates[$msg])) {
2764
+					$parent_updates[$msg] = array($id);
2765
+		} else {
2766
+					$parent_updates[$msg][] = $id;
2767
+		}
2633 2768
 	}
2634 2769
 
2635 2770
 	foreach ($lastMsg as $id => $msg)
2636 2771
 	{
2637
-		if (!isset($board_updates[$msg . '-' . $lastModified[$id]]))
2638
-			$board_updates[$msg . '-' . $lastModified[$id]] = array(
2772
+		if (!isset($board_updates[$msg . '-' . $lastModified[$id]])) {
2773
+					$board_updates[$msg . '-' . $lastModified[$id]] = array(
2639 2774
 				'id' => $msg,
2640 2775
 				'updated' => $lastModified[$id],
2641 2776
 				'boards' => array($id)
2642 2777
 			);
2643
-
2644
-		else
2645
-			$board_updates[$msg . '-' . $lastModified[$id]]['boards'][] = $id;
2778
+		} else {
2779
+					$board_updates[$msg . '-' . $lastModified[$id]]['boards'][] = $id;
2780
+		}
2646 2781
 	}
2647 2782
 
2648 2783
 	// Now commit the changes!
@@ -2734,11 +2869,13 @@  discard block
 block discarded – undo
2734 2869
 	global $txt, $mbname, $scripturl, $settings;
2735 2870
 
2736 2871
 	// First things first, load up the email templates language file, if we need to.
2737
-	if ($loadLang)
2738
-		loadLanguage('EmailTemplates', $lang);
2872
+	if ($loadLang) {
2873
+			loadLanguage('EmailTemplates', $lang);
2874
+	}
2739 2875
 
2740
-	if (!isset($txt[$template . '_subject']) || !isset($txt[$template . '_body']))
2741
-		fatal_lang_error('email_no_template', 'template', array($template));
2876
+	if (!isset($txt[$template . '_subject']) || !isset($txt[$template . '_body'])) {
2877
+			fatal_lang_error('email_no_template', 'template', array($template));
2878
+	}
2742 2879
 
2743 2880
 	$ret = array(
2744 2881
 		'subject' => $txt[$template . '_subject'],
@@ -2788,17 +2925,18 @@  discard block
 block discarded – undo
2788 2925
 function user_info_callback($matches)
2789 2926
 {
2790 2927
 	global $user_info;
2791
-	if (empty($matches[1]))
2792
-		return '';
2928
+	if (empty($matches[1])) {
2929
+			return '';
2930
+	}
2793 2931
 
2794 2932
 	$use_ref = true;
2795 2933
 	$ref = &$user_info;
2796 2934
 
2797 2935
 	foreach (explode('.', $matches[1]) as $index)
2798 2936
 	{
2799
-		if ($use_ref && isset($ref[$index]))
2800
-			$ref = &$ref[$index];
2801
-		else
2937
+		if ($use_ref && isset($ref[$index])) {
2938
+					$ref = &$ref[$index];
2939
+		} else
2802 2940
 		{
2803 2941
 			$use_ref = false;
2804 2942
 			break;
@@ -2835,8 +2973,7 @@  discard block
 block discarded – undo
2835 2973
 		if (!empty($lang_locale) && enchant_broker_dict_exists($context['enchant_broker'], $lang_locale))
2836 2974
 		{
2837 2975
 			$enchant_link = enchant_broker_request_dict($context['enchant_broker'], $lang_locale);
2838
-		}
2839
-		elseif (enchant_broker_dict_exists($context['enchant_broker'], $txt['lang_dictionary']))
2976
+		} elseif (enchant_broker_dict_exists($context['enchant_broker'], $txt['lang_dictionary']))
2840 2977
 		{
2841 2978
 			$enchant_link = enchant_broker_request_dict($context['enchant_broker'], $txt['lang_dictionary']);
2842 2979
 		}
@@ -2846,8 +2983,7 @@  discard block
 block discarded – undo
2846 2983
 		{
2847 2984
 			$context['provider'] = 'enchant';
2848 2985
 			return $enchant_link;
2849
-		}
2850
-		else
2986
+		} else
2851 2987
 		{
2852 2988
 			// Free up any resources used...
2853 2989
 			@enchant_broker_free($context['enchant_broker']);
@@ -2868,8 +3004,9 @@  discard block
 block discarded – undo
2868 3004
 		$pspell_link = pspell_new($txt['lang_dictionary'], $txt['lang_spelling'], '', strtr($context['character_set'], array('iso-' => 'iso', 'ISO-' => 'iso')), PSPELL_FAST | PSPELL_RUN_TOGETHER);
2869 3005
 
2870 3006
 		// Most people don't have anything but English installed... So we use English as a last resort.
2871
-		if (!$pspell_link)
2872
-			$pspell_link = pspell_new('en', '', '', '', PSPELL_FAST | PSPELL_RUN_TOGETHER);
3007
+		if (!$pspell_link) {
3008
+					$pspell_link = pspell_new('en', '', '', '', PSPELL_FAST | PSPELL_RUN_TOGETHER);
3009
+		}
2873 3010
 
2874 3011
 		error_reporting($old);
2875 3012
 		ob_end_clean();
@@ -2909,8 +3046,7 @@  discard block
 block discarded – undo
2909 3046
 			$word = iconv($txt['lang_character_set'], 'UTF-8', $word);
2910 3047
 		}
2911 3048
 		return enchant_dict_check($dict, $word);
2912
-	}
2913
-	elseif ($context['provider'] == 'pspell')
3049
+	} elseif ($context['provider'] == 'pspell')
2914 3050
 	{
2915 3051
 		return pspell_check($dict, $word);
2916 3052
 	}
@@ -2946,13 +3082,11 @@  discard block
 block discarded – undo
2946 3082
 			}
2947 3083
 
2948 3084
 			return $suggestions;
2949
-		}
2950
-		else
3085
+		} else
2951 3086
 		{
2952 3087
 			return enchant_dict_suggest($dict, $word);
2953 3088
 		}
2954
-	}
2955
-	elseif ($context['provider'] == 'pspell')
3089
+	} elseif ($context['provider'] == 'pspell')
2956 3090
 	{
2957 3091
 		return pspell_suggest($dict, $word);
2958 3092
 	}
Please login to merge, or discard this patch.