Passed
Push — patch_1-1-9 ( d927f0...e2616d )
by Spuds
01:06 queued 27s
created
sources/subs/MentionType/MentionMessageAbstract.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -235,7 +235,9 @@  discard block
 block discarded – undo
235 235
 		if (!empty($lang_files) && $lang !== $user_info['language'])
236 236
 		{
237 237
 			foreach ($lang_files as $file)
238
-				loadLanguage($file);
238
+			{
239
+							loadLanguage($file);
240
+			}
239 241
 		}
240 242
 
241 243
 		return $langtxt;
@@ -273,7 +275,9 @@  discard block
 block discarded – undo
273 275
 		);
274 276
 		$existing = array();
275 277
 		while ($row = $this->_db->fetch_assoc($request))
276
-			$existing[] = $row['id_member'];
278
+		{
279
+					$existing[] = $row['id_member'];
280
+		}
277 281
 		$this->_db->free_result($request);
278 282
 
279 283
 		$actually_mentioned = array();
Please login to merge, or discard this patch.
sources/subs/ManageFeatures.subs.php 2 patches
Braces   +78 added lines, -28 removed lines patch added patch discarded remove patch
@@ -94,7 +94,9 @@  discard block
 block discarded – undo
94 94
 		$update_sigs = getSignatureFromMembers($applied_sigs);
95 95
 
96 96
 		if (empty($update_sigs))
97
-			$done = true;
97
+		{
98
+					$done = true;
99
+		}
98 100
 
99 101
 		foreach ($update_sigs as $row)
100 102
 		{
@@ -103,7 +105,9 @@  discard block
 block discarded – undo
103 105
 
104 106
 			// Max characters...
105 107
 			if (!empty($sig_limits[1]))
106
-				$sig = Util::substr($sig, 0, $sig_limits[1]);
108
+			{
109
+							$sig = Util::substr($sig, 0, $sig_limits[1]);
110
+			}
107 111
 
108 112
 			// Max lines...
109 113
 			if (!empty($sig_limits[2]))
@@ -116,7 +120,9 @@  discard block
 block discarded – undo
116 120
 					{
117 121
 						$count++;
118 122
 						if ($count >= $sig_limits[2])
119
-							$sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' '));
123
+						{
124
+													$sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' '));
125
+						}
120 126
 					}
121 127
 				}
122 128
 			}
@@ -140,16 +146,26 @@  discard block
 block discarded – undo
140 146
 
141 147
 					// Attempt to allow all sizes of abuse, so to speak.
142 148
 					if ($matches[2][$ind] == 'px' && $size > $sig_limits[7])
143
-						$limit_broke = $sig_limits[7] . 'px';
149
+					{
150
+											$limit_broke = $sig_limits[7] . 'px';
151
+					}
144 152
 					elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75))
145
-						$limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt';
153
+					{
154
+											$limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt';
155
+					}
146 156
 					elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16))
147
-						$limit_broke = ((float) $sig_limits[7] / 16) . 'em';
157
+					{
158
+											$limit_broke = ((float) $sig_limits[7] / 16) . 'em';
159
+					}
148 160
 					elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18)
149
-						$limit_broke = 'large';
161
+					{
162
+											$limit_broke = 'large';
163
+					}
150 164
 
151 165
 					if ($limit_broke)
152
-						$sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig);
166
+					{
167
+											$sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig);
168
+					}
153 169
 				}
154 170
 			}
155 171
 
@@ -213,15 +229,18 @@  discard block
 block discarded – undo
213 229
 									}
214 230
 								}
215 231
 							}
216
-							else
217
-								$replaces[$image] = '';
232
+							else {
233
+															$replaces[$image] = '';
234
+							}
218 235
 
219 236
 							continue;
220 237
 						}
221 238
 
222 239
 						// Does it have predefined restraints? Width first.
223 240
 						if ($matches[6][$key])
224
-							$matches[2][$key] = $matches[6][$key];
241
+						{
242
+													$matches[2][$key] = $matches[6][$key];
243
+						}
225 244
 
226 245
 						if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5])
227 246
 						{
@@ -229,17 +248,23 @@  discard block
 block discarded – undo
229 248
 							$matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]);
230 249
 						}
231 250
 						elseif ($matches[2][$key])
232
-							$width = $matches[2][$key];
251
+						{
252
+													$width = $matches[2][$key];
253
+						}
233 254
 
234 255
 						// ... and height.
235 256
 						if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6])
236 257
 						{
237 258
 							$height = $sig_limits[6];
238 259
 							if ($width != -1)
239
-								$width = $width * ($height / $matches[4][$key]);
260
+							{
261
+															$width = $width * ($height / $matches[4][$key]);
262
+							}
240 263
 						}
241 264
 						elseif ($matches[4][$key])
242
-							$height = $matches[4][$key];
265
+						{
266
+													$height = $matches[4][$key];
267
+						}
243 268
 
244 269
 						// If the dimensions are still not fixed - we need to check the actual image.
245 270
 						if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6]))
@@ -262,24 +287,32 @@  discard block
 block discarded – undo
262 287
 								{
263 288
 									$height = $sig_limits[6];
264 289
 									if ($width == -1)
265
-										$width = $sizes[0];
290
+									{
291
+																			$width = $sizes[0];
292
+									}
266 293
 									$width = $width * ($height / $sizes[1]);
267 294
 								}
268 295
 								elseif ($width != -1)
269
-									$height = $sizes[1];
296
+								{
297
+																	$height = $sizes[1];
298
+								}
270 299
 							}
271 300
 						}
272 301
 
273 302
 						// Did we come up with some changes? If so remake the string.
274 303
 						if ($width != -1 || $height != -1)
275
-							$replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]';
304
+						{
305
+													$replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]';
306
+						}
276 307
 
277 308
 						// Record that we got one.
278 309
 						$image_count_holder[$image] = isset($image_count_holder[$image]) ? $image_count_holder[$image] + 1 : 1;
279 310
 					}
280 311
 
281 312
 					if (!empty($replaces))
282
-						$sig = str_replace(array_keys($replaces), array_values($replaces), $sig);
313
+					{
314
+											$sig = str_replace(array_keys($replaces), array_values($replaces), $sig);
315
+					}
283 316
 				}
284 317
 			}
285 318
 
@@ -293,19 +326,25 @@  discard block
 block discarded – undo
293 326
 			$sig = strtr($sig, array("\n" => '<br />'));
294 327
 			call_integration_hook('integrate_apply_signature_settings', array(&$sig, $sig_limits, $disabledTags));
295 328
 			if ($sig != $row['signature'])
296
-				$changes[$row['id_member']] = $sig;
329
+			{
330
+							$changes[$row['id_member']] = $sig;
331
+			}
297 332
 		}
298 333
 
299 334
 		// Do we need to delete what we have?
300 335
 		if (!empty($changes))
301 336
 		{
302 337
 			foreach ($changes as $id => $sig)
303
-				updateSignature($id, $sig);
338
+			{
339
+							updateSignature($id, $sig);
340
+			}
304 341
 		}
305 342
 
306 343
 		$applied_sigs += 50;
307 344
 		if (!$done)
308
-			pauseSignatureApplySettings($applied_sigs);
345
+		{
346
+					pauseSignatureApplySettings($applied_sigs);
347
+		}
309 348
 	}
310 349
 }
311 350
 
@@ -334,13 +373,15 @@  discard block
 block discarded – undo
334 373
 		$registration_fields = isset($modSettings['registration_fields']) ? explode(',', $modSettings['registration_fields']) : array();
335 374
 
336 375
 		foreach ($standard_fields as $field)
337
-			$list[] = array(
376
+		{
377
+					$list[] = array(
338 378
 				'id' => $field,
339 379
 				'label' => isset($txt['standard_profile_field_' . $field]) ? $txt['standard_profile_field_' . $field] : (isset($txt[$field]) ? $txt[$field] : $field),
340 380
 				'disabled' => in_array($field, $disabled_fields),
341 381
 				'on_register' => in_array($field, $registration_fields) && !in_array($field, $fields_no_registration),
342 382
 				'can_show_register' => !in_array($field, $fields_no_registration),
343 383
 			);
384
+		}
344 385
 	}
345 386
 	else
346 387
 	{
@@ -469,9 +510,12 @@  discard block
 block discarded – undo
469 510
 			)
470 511
 		);
471 512
 		if ($db->num_rows($request) == 0)
472
-			$unique = true;
473
-		else
474
-			$colname = $initial_colname . $i;
513
+		{
514
+					$unique = true;
515
+		}
516
+		else {
517
+					$colname = $initial_colname . $i;
518
+		}
475 519
 			$db->free_result($request);
476 520
 	}
477 521
 
@@ -831,7 +875,9 @@  discard block
 block discarded – undo
831 875
 	{
832 876
 		$options = $class_name::frontPageOptions();
833 877
 		if (!empty($options))
834
-			$config_vars = array_merge($config_vars, $options);
878
+		{
879
+					$config_vars = array_merge($config_vars, $options);
880
+		}
835 881
 	}
836 882
 
837 883
 	return $config_vars;
@@ -859,14 +905,18 @@  discard block
 block discarded – undo
859 905
 			$class_name = $file->getBasename('.controller.php') . '_Controller';
860 906
 
861 907
 			if (!class_exists($class_name))
862
-				continue;
908
+			{
909
+							continue;
910
+			}
863 911
 		}
864 912
 
865 913
 		if (is_subclass_of($class_name, 'Action_Controller') && $class_name::canFrontPage())
866 914
 		{
867 915
 			// Temporary
868 916
 			if (!isset($txt[$class_name]))
869
-				continue;
917
+			{
918
+							continue;
919
+			}
870 920
 
871 921
 			$types[$class_name] = $txt[$class_name];
872 922
 		}
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -703,7 +703,7 @@
 block discarded – undo
703 703
 			'not_owner_only' => 2,
704 704
 			'not_admin_only' => 3,
705 705
 		),
706
-		function ($row)
706
+		function($row)
707 707
 		{
708 708
 			return array(
709 709
 				'colname' => strtr($row['col_name'], array('|' => '', ';' => '')),
Please login to merge, or discard this patch.
sources/subs/Members.subs.php 2 patches
Braces   +313 added lines, -122 removed lines patch added patch discarded remove patch
@@ -53,29 +53,39 @@  discard block
 block discarded – undo
53 53
 
54 54
 	// If it's not an array, make it so!
55 55
 	if (!is_array($users))
56
-		$users = array($users);
57
-	else
58
-		$users = array_unique($users);
56
+	{
57
+			$users = array($users);
58
+	}
59
+	else {
60
+			$users = array_unique($users);
61
+	}
59 62
 
60 63
 	// Make sure there's no void user in here.
61 64
 	$users = array_diff($users, array(0));
62 65
 
63 66
 	// How many are they deleting?
64 67
 	if (empty($users))
65
-		return;
68
+	{
69
+			return;
70
+	}
66 71
 	elseif (count($users) == 1)
67 72
 	{
68 73
 		list ($user) = $users;
69 74
 
70 75
 		if ($user == $user_info['id'])
71
-			isAllowedTo('profile_remove_own');
72
-		else
73
-			isAllowedTo('profile_remove_any');
76
+		{
77
+					isAllowedTo('profile_remove_own');
78
+		}
79
+		else {
80
+					isAllowedTo('profile_remove_any');
81
+		}
74 82
 	}
75 83
 	else
76 84
 	{
77 85
 		foreach ($users as $k => $v)
78
-			$users[$k] = (int) $v;
86
+		{
87
+					$users[$k] = (int) $v;
88
+		}
79 89
 
80 90
 		// Deleting more than one?  You can't have more than one account...
81 91
 		isAllowedTo('profile_remove_any');
@@ -98,26 +108,34 @@  discard block
 block discarded – undo
98 108
 	while ($row = $db->fetch_assoc($request))
99 109
 	{
100 110
 		if ($row['is_admin'])
101
-			$admins[] = $row['id_member'];
111
+		{
112
+					$admins[] = $row['id_member'];
113
+		}
102 114
 		$user_log_details[$row['id_member']] = array($row['id_member'], $row['member_name']);
103 115
 		$emails[] = $row['email_address'];
104 116
 	}
105 117
 	$db->free_result($request);
106 118
 
107 119
 	if (empty($user_log_details))
108
-		return;
120
+	{
121
+			return;
122
+	}
109 123
 
110 124
 	// Make sure they aren't trying to delete administrators if they aren't one.  But don't bother checking if it's just themselves.
111 125
 	if (!empty($admins) && ($check_not_admin || (!allowedTo('admin_forum') && (count($users) != 1 || $users[0] != $user_info['id']))))
112 126
 	{
113 127
 		$users = array_diff($users, $admins);
114 128
 		foreach ($admins as $id)
115
-			unset($user_log_details[$id]);
129
+		{
130
+					unset($user_log_details[$id]);
131
+		}
116 132
 	}
117 133
 
118 134
 	// No one left?
119 135
 	if (empty($users))
120
-		return;
136
+	{
137
+			return;
138
+	}
121 139
 
122 140
 	// Log the action - regardless of who is deleting it.
123 141
 	$log_changes = array();
@@ -493,9 +511,12 @@  discard block
 block discarded – undo
493 511
 	if (empty($regOptions['auth_method']) || !in_array($regOptions['auth_method'], array('password', 'openid')))
494 512
 	{
495 513
 		if (!empty($regOptions['openid']))
496
-			$regOptions['auth_method'] = 'openid';
497
-		else
498
-			$regOptions['auth_method'] = 'password';
514
+		{
515
+					$regOptions['auth_method'] = 'openid';
516
+		}
517
+		else {
518
+					$regOptions['auth_method'] = 'password';
519
+		}
499 520
 	}
500 521
 
501 522
 	// Spaces and other odd characters are evil...
@@ -503,7 +524,9 @@  discard block
 block discarded – undo
503 524
 
504 525
 	// Valid emails only
505 526
 	if (!Data_Validator::is_valid($regOptions, array('email' => 'valid_email|required|max_length[255]'), array('email' => 'trim')))
506
-		$reg_errors->addError('bad_email');
527
+	{
528
+			$reg_errors->addError('bad_email');
529
+	}
507 530
 
508 531
 	validateUsername(0, $regOptions['username'], $ErrorContext, !empty($regOptions['check_reserved_name']));
509 532
 
@@ -512,15 +535,20 @@  discard block
 block discarded – undo
512 535
 
513 536
 	// Does the first password match the second?
514 537
 	if ($regOptions['password'] != $regOptions['password_check'] && $regOptions['auth_method'] == 'password')
515
-		$reg_errors->addError('passwords_dont_match');
538
+	{
539
+			$reg_errors->addError('passwords_dont_match');
540
+	}
516 541
 
517 542
 	// That's kind of easy to guess...
518 543
 	if ($regOptions['password'] == '')
519 544
 	{
520 545
 		if ($regOptions['auth_method'] == 'password')
521
-			$reg_errors->addError('no_password');
522
-		else
523
-			$regOptions['password'] = sha1(mt_rand());
546
+		{
547
+					$reg_errors->addError('no_password');
548
+		}
549
+		else {
550
+					$regOptions['password'] = sha1(mt_rand());
551
+		}
524 552
 	}
525 553
 
526 554
 	// Now perform hard password validation as required.
@@ -530,13 +558,17 @@  discard block
 block discarded – undo
530 558
 
531 559
 		// Password isn't legal?
532 560
 		if ($passwordError !== null)
533
-			$reg_errors->addError('profile_error_password_' . $passwordError);
561
+		{
562
+					$reg_errors->addError('profile_error_password_' . $passwordError);
563
+		}
534 564
 	}
535 565
 
536 566
 	// @todo move to controller
537 567
 	// You may not be allowed to register this email.
538 568
 	if (!empty($regOptions['check_email_ban']))
539
-		isBannedEmail($regOptions['email'], 'cannot_register', $txt['ban_register_prohibited']);
569
+	{
570
+			isBannedEmail($regOptions['email'], 'cannot_register', $txt['ban_register_prohibited']);
571
+	}
540 572
 
541 573
 	// Check if the email address is in use.
542 574
 	if (userByEmail($regOptions['email'], $regOptions['username']))
@@ -549,7 +581,9 @@  discard block
 block discarded – undo
549 581
 
550 582
 	// If there's any errors left return them at once!
551 583
 	if ($reg_errors->hasErrors())
552
-		return false;
584
+	{
585
+			return false;
586
+	}
553 587
 
554 588
 	$reservedVars = array(
555 589
 		'actual_theme_url',
@@ -572,7 +606,9 @@  discard block
 block discarded – undo
572 606
 
573 607
 	// Can't change reserved vars.
574 608
 	if (isset($regOptions['theme_vars']) && count(array_intersect(array_keys($regOptions['theme_vars']), $reservedVars)) != 0)
575
-		throw new Elk_Exception('no_theme');
609
+	{
610
+			throw new Elk_Exception('no_theme');
611
+	}
576 612
 
577 613
 	$tokenizer = new Token_Hash();
578 614
 
@@ -625,13 +661,18 @@  discard block
 block discarded – undo
625 661
 	}
626 662
 	// Maybe it can be activated right away?
627 663
 	elseif ($regOptions['require'] == 'nothing')
628
-		$regOptions['register_vars']['is_activated'] = 1;
664
+	{
665
+			$regOptions['register_vars']['is_activated'] = 1;
666
+	}
629 667
 	// Maybe it must be activated by email?
630 668
 	elseif ($regOptions['require'] == 'activation')
631
-		$regOptions['register_vars']['is_activated'] = 0;
669
+	{
670
+			$regOptions['register_vars']['is_activated'] = 0;
671
+	}
632 672
 	// Otherwise it must be awaiting approval!
633
-	else
634
-		$regOptions['register_vars']['is_activated'] = 3;
673
+	else {
674
+			$regOptions['register_vars']['is_activated'] = 3;
675
+	}
635 676
 
636 677
 	if (isset($regOptions['memberGroup']))
637 678
 	{
@@ -644,19 +685,25 @@  discard block
 block discarded – undo
644 685
 		$unassignableGroups = getUnassignableGroups(allowedTo('admin_forum'));
645 686
 
646 687
 		if (in_array($regOptions['register_vars']['id_group'], $unassignableGroups))
647
-			$regOptions['register_vars']['id_group'] = 0;
688
+		{
689
+					$regOptions['register_vars']['id_group'] = 0;
690
+		}
648 691
 	}
649 692
 
650 693
 	// Integrate optional member settings to be set.
651 694
 	if (!empty($regOptions['extra_register_vars']))
652
-		foreach ($regOptions['extra_register_vars'] as $var => $value)
695
+	{
696
+			foreach ($regOptions['extra_register_vars'] as $var => $value)
653 697
 			$regOptions['register_vars'][$var] = $value;
698
+	}
654 699
 
655 700
 	// Integrate optional user theme options to be set.
656 701
 	$theme_vars = array();
657 702
 	if (!empty($regOptions['theme_vars']))
658
-		foreach ($regOptions['theme_vars'] as $var => $value)
703
+	{
704
+			foreach ($regOptions['theme_vars'] as $var => $value)
659 705
 			$theme_vars[$var] = $value;
706
+	}
660 707
 
661 708
 	// Right, now let's prepare for insertion.
662 709
 	$knownInts = array(
@@ -678,11 +725,17 @@  discard block
 block discarded – undo
678 725
 	{
679 726
 		$type = 'string';
680 727
 		if (in_array($var, $knownInts))
681
-			$type = 'int';
728
+		{
729
+					$type = 'int';
730
+		}
682 731
 		elseif (in_array($var, $knownFloats))
683
-			$type = 'float';
732
+		{
733
+					$type = 'float';
734
+		}
684 735
 		elseif ($var == 'birthdate')
685
-			$type = 'date';
736
+		{
737
+					$type = 'date';
738
+		}
686 739
 
687 740
 		$column_names[$var] = $type;
688 741
 		$values[$var] = $val;
@@ -699,9 +752,12 @@  discard block
 block discarded – undo
699 752
 
700 753
 	// Update the number of members and latest member's info - and pass the name, but remove the 's.
701 754
 	if ($regOptions['register_vars']['is_activated'] == 1)
702
-		updateMemberStats($memberID, $regOptions['register_vars']['real_name']);
703
-	else
704
-		updateMemberStats();
755
+	{
756
+			updateMemberStats($memberID, $regOptions['register_vars']['real_name']);
757
+	}
758
+	else {
759
+			updateMemberStats();
760
+	}
705 761
 
706 762
 	// @todo there's got to be a method that does this
707 763
 	// Theme variables too?
@@ -709,7 +765,9 @@  discard block
 block discarded – undo
709 765
 	{
710 766
 		$inserts = array();
711 767
 		foreach ($theme_vars as $var => $val)
712
-			$inserts[] = array($memberID, $var, $val);
768
+		{
769
+					$inserts[] = array($memberID, $var, $val);
770
+		}
713 771
 		$db->insert('insert',
714 772
 			'{db_prefix}themes',
715 773
 			array('id_member' => 'int', 'variable' => 'string-255', 'value' => 'string-65534'),
@@ -740,9 +798,13 @@  discard block
 block discarded – undo
740 798
 	if ($regOptions['interface'] == 'admin')
741 799
 	{
742 800
 		if ($regOptions['require'] == 'activation')
743
-			$email_message = 'admin_register_activate';
801
+		{
802
+					$email_message = 'admin_register_activate';
803
+		}
744 804
 		elseif (!empty($regOptions['send_welcome_email']))
745
-			$email_message = 'admin_register_immediate';
805
+		{
806
+					$email_message = 'admin_register_immediate';
807
+		}
746 808
 
747 809
 		if (isset($email_message))
748 810
 		{
@@ -855,38 +917,51 @@  discard block
 block discarded – undo
855 917
 		foreach ($reservedNames as $reserved)
856 918
 		{
857 919
 			if ($reserved == '')
858
-				continue;
920
+			{
921
+							continue;
922
+			}
859 923
 
860 924
 			// The admin might've used entities too, level the playing field.
861 925
 			$reservedCheck = preg_replace_callback('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'replaceEntities__callback', $reserved);
862 926
 
863 927
 			// Case sensitive name?
864 928
 			if (empty($modSettings['reserveCase']))
865
-				$reservedCheck = Util::strtolower($reservedCheck);
929
+			{
930
+							$reservedCheck = Util::strtolower($reservedCheck);
931
+			}
866 932
 
867 933
 			// If it's not just entire word, check for it in there somewhere...
868 934
 			if ($checkMe == $reservedCheck || (Util::strpos($checkMe, $reservedCheck) !== false && empty($modSettings['reserveWord'])))
869
-				if ($fatal)
935
+			{
936
+							if ($fatal)
870 937
 					throw new Elk_Exception('username_reserved', 'password', array($reserved));
871
-				else
872
-					return true;
938
+			}
939
+				else {
940
+									return true;
941
+				}
873 942
 		}
874 943
 
875 944
 		$censor_name = $name;
876 945
 		if (censor($censor_name) != $name)
877
-			if ($fatal)
946
+		{
947
+					if ($fatal)
878 948
 				throw new Elk_Exception('name_censored', 'password', array($name));
879
-			else
880
-				return true;
949
+		}
950
+			else {
951
+							return true;
952
+			}
881 953
 	}
882 954
 
883 955
 	// Characters we just shouldn't allow, regardless.
884 956
 	foreach (array('*') as $char)
885
-		if (strpos($checkName, $char) !== false)
957
+	{
958
+			if (strpos($checkName, $char) !== false)
886 959
 			if ($fatal)
887 960
 				throw new Elk_Exception('username_reserved', 'password', array($char));
888
-			else
889
-				return true;
961
+	}
962
+			else {
963
+							return true;
964
+			}
890 965
 
891 966
 	// Get rid of any SQL parts of the reserved name...
892 967
 	$checkName = strtr($name, array('_' => '\\_', '%' => '\\%'));
@@ -972,7 +1047,9 @@  discard block
 block discarded – undo
972 1047
 			)
973 1048
 		);
974 1049
 		while ($row = $db->fetch_assoc($request))
975
-			$member_groups[$row['add_deny'] === '1' ? 'allowed' : 'denied'][] = $row['id_group'];
1050
+		{
1051
+					$member_groups[$row['add_deny'] === '1' ? 'allowed' : 'denied'][] = $row['id_group'];
1052
+		}
976 1053
 		$db->free_result($request);
977 1054
 	}
978 1055
 
@@ -981,18 +1058,23 @@  discard block
 block discarded – undo
981 1058
 	{
982 1059
 		// First get the profile of the given board.
983 1060
 		if (isset($board_info['id']) && $board_info['id'] == $board_id)
984
-			$profile_id = $board_info['profile'];
1061
+		{
1062
+					$profile_id = $board_info['profile'];
1063
+		}
985 1064
 		elseif ($board_id !== 0)
986 1065
 		{
987 1066
 			require_once(SUBSDIR . '/Boards.subs.php');
988 1067
 			$board_data = fetchBoardsInfo(array('boards' => $board_id), array('selects' => 'permissions'));
989 1068
 
990 1069
 			if (empty($board_data))
991
-				throw new Elk_Exception('no_board');
1070
+			{
1071
+							throw new Elk_Exception('no_board');
1072
+			}
992 1073
 			$profile_id = $board_data[$board_id]['id_profile'];
993 1074
 		}
994
-		else
995
-			$profile_id = 1;
1075
+		else {
1076
+					$profile_id = 1;
1077
+		}
996 1078
 
997 1079
 		$request = $db->query('', '
998 1080
 			SELECT bp.id_group, bp.add_deny
@@ -1005,7 +1087,9 @@  discard block
 block discarded – undo
1005 1087
 			)
1006 1088
 		);
1007 1089
 		while ($row = $db->fetch_assoc($request))
1008
-			$member_groups[$row['add_deny'] === '1' ? 'allowed' : 'denied'][] = $row['id_group'];
1090
+		{
1091
+					$member_groups[$row['add_deny'] === '1' ? 'allowed' : 'denied'][] = $row['id_group'];
1092
+		}
1009 1093
 		$db->free_result($request);
1010 1094
 	}
1011 1095
 
@@ -1117,9 +1201,13 @@  discard block
 block discarded – undo
1117 1201
 
1118 1202
 	$query_parts = array();
1119 1203
 	if (!empty($email))
1120
-		$query_parts[] = 'poster_email = {string:email_address}';
1204
+	{
1205
+			$query_parts[] = 'poster_email = {string:email_address}';
1206
+	}
1121 1207
 	if (!empty($membername))
1122
-		$query_parts[] = 'poster_name = {string:member_name}';
1208
+	{
1209
+			$query_parts[] = 'poster_name = {string:member_name}';
1210
+	}
1123 1211
 	$query = implode(' AND ', $query_parts);
1124 1212
 
1125 1213
 	// Finally, update the posts themselves!
@@ -1182,7 +1270,9 @@  discard block
 block discarded – undo
1182 1270
 
1183 1271
 	// If we want duplicates pass the members array off.
1184 1272
 	if ($get_duplicates)
1185
-		populateDuplicateMembers($members);
1273
+	{
1274
+			populateDuplicateMembers($members);
1275
+	}
1186 1276
 
1187 1277
 	return $members;
1188 1278
 }
@@ -1202,7 +1292,9 @@  discard block
 block discarded – undo
1202 1292
 
1203 1293
 	// We know how many members there are in total.
1204 1294
 	if (empty($where) || $where == '1=1')
1205
-		$num_members = $modSettings['totalMembers'];
1295
+	{
1296
+			$num_members = $modSettings['totalMembers'];
1297
+	}
1206 1298
 
1207 1299
 	// The database knows the amount when there are extra conditions.
1208 1300
 	else
@@ -1240,15 +1332,21 @@  discard block
 block discarded – undo
1240 1332
 
1241 1333
 		// Store the IPs.
1242 1334
 		if (!empty($member['member_ip']))
1243
-			$ips[] = $member['member_ip'];
1335
+		{
1336
+					$ips[] = $member['member_ip'];
1337
+		}
1244 1338
 		if (!empty($member['member_ip2']))
1245
-			$ips[] = $member['member_ip2'];
1339
+		{
1340
+					$ips[] = $member['member_ip2'];
1341
+		}
1246 1342
 	}
1247 1343
 
1248 1344
 	$ips = array_unique($ips);
1249 1345
 
1250 1346
 	if (empty($ips))
1251
-		return false;
1347
+	{
1348
+			return false;
1349
+	}
1252 1350
 
1253 1351
 	// Fetch all members with this IP address, we'll filter out the current ones in a sec.
1254 1352
 	$potential_dupes = membersByIP($ips, 'exact', true);
@@ -1269,9 +1367,13 @@  discard block
 block discarded – undo
1269 1367
 		);
1270 1368
 
1271 1369
 		if (in_array($row['member_ip'], $ips))
1272
-			$duplicate_members[$row['member_ip']][] = $member_context;
1370
+		{
1371
+					$duplicate_members[$row['member_ip']][] = $member_context;
1372
+		}
1273 1373
 		if ($row['member_ip'] != $row['member_ip2'] && in_array($row['member_ip2'], $ips))
1274
-			$duplicate_members[$row['member_ip2']][] = $member_context;
1374
+		{
1375
+					$duplicate_members[$row['member_ip2']][] = $member_context;
1376
+		}
1275 1377
 	}
1276 1378
 
1277 1379
 	// Also try to get a list of messages using these ips.
@@ -1294,7 +1396,9 @@  discard block
 block discarded – undo
1294 1396
 	{
1295 1397
 		// Don't collect lots of the same.
1296 1398
 		if (isset($had_ips[$row['poster_ip']]) && in_array($row['id_member'], $had_ips[$row['poster_ip']]))
1297
-			continue;
1399
+		{
1400
+					continue;
1401
+		}
1298 1402
 		$had_ips[$row['poster_ip']][] = $row['id_member'];
1299 1403
 
1300 1404
 		$duplicate_members[$row['poster_ip']][] = array(
@@ -1314,9 +1418,13 @@  discard block
 block discarded – undo
1314 1418
 		foreach ($members as $key => $member)
1315 1419
 		{
1316 1420
 			if (isset($duplicate_members[$member['member_ip']]))
1317
-				$members[$key]['duplicate_members'] = $duplicate_members[$member['member_ip']];
1421
+			{
1422
+							$members[$key]['duplicate_members'] = $duplicate_members[$member['member_ip']];
1423
+			}
1318 1424
 			if ($member['member_ip'] != $member['member_ip2'] && isset($duplicate_members[$member['member_ip2']]))
1319
-				$members[$key]['duplicate_members'] = array_merge($member['duplicate_members'], $duplicate_members[$member['member_ip2']]);
1425
+			{
1426
+							$members[$key]['duplicate_members'] = array_merge($member['duplicate_members'], $duplicate_members[$member['member_ip2']]);
1427
+			}
1320 1428
 
1321 1429
 			// Check we don't have lots of the same member.
1322 1430
 			$member_track = array($member['id_member']);
@@ -1352,10 +1460,14 @@  discard block
 block discarded – undo
1352 1460
 	foreach (array($ip1, $ip2) as $id => $ip)
1353 1461
 	{
1354 1462
 		if ($ip === false)
1355
-			continue;
1463
+		{
1464
+					continue;
1465
+		}
1356 1466
 
1357 1467
 		if ($match === 'exact')
1358
-			$ip_params['ips'] = array_merge($ip_params['ips'], (array) $ip);
1468
+		{
1469
+					$ip_params['ips'] = array_merge($ip_params['ips'], (array) $ip);
1470
+		}
1359 1471
 		else
1360 1472
 		{
1361 1473
 			$ip = (array) $ip;
@@ -1372,15 +1484,19 @@  discard block
 block discarded – undo
1372 1484
 	{
1373 1485
 		$where = 'member_ip IN ({array_string:ips})';
1374 1486
 		if ($ip2 !== false)
1375
-			$where .= '
1487
+		{
1488
+					$where .= '
1376 1489
 			OR member_ip2 IN ({array_string:ips})';
1490
+		}
1377 1491
 	}
1378 1492
 	else
1379 1493
 	{
1380 1494
 		$where = 'member_ip ' . implode(' OR member_ip', $ip_query);
1381 1495
 		if ($ip2 !== false)
1382
-			$where .= '
1496
+		{
1497
+					$where .= '
1383 1498
 			OR member_ip2 ' . implode(' OR member_ip', $ip_query);
1499
+		}
1384 1500
 	}
1385 1501
 
1386 1502
 	return $db->fetchQuery('
@@ -1451,13 +1567,17 @@  discard block
 block discarded – undo
1451 1567
 	if ($details)
1452 1568
 	{
1453 1569
 		while ($row = $db->fetch_assoc($request))
1454
-			$members[$row['id_member']] = $row;
1570
+		{
1571
+					$members[$row['id_member']] = $row;
1572
+		}
1455 1573
 	}
1456 1574
 	// Or just a int[] of found member id's
1457 1575
 	else
1458 1576
 	{
1459 1577
 		while ($row = $db->fetch_assoc($request))
1460
-			$members[] = $row['id_member'];
1578
+		{
1579
+					$members[] = $row['id_member'];
1580
+		}
1461 1581
 	}
1462 1582
 	$db->free_result($request);
1463 1583
 
@@ -1538,9 +1658,12 @@  discard block
 block discarded – undo
1538 1658
 				foreach ($query_conditions as $condition => $query_condition)
1539 1659
 				{
1540 1660
 					if ($query_condition == 'member_names')
1541
-						$query_parts[$condition === 'or' ? 'or' : 'and'][] = $allowed_conditions[$query_condition]($query_params);
1542
-					else
1543
-						$query_parts[$condition === 'or' ? 'or' : 'and'][] = isset($allowed_conditions[$query_condition]) ? $allowed_conditions[$query_condition] : $query_condition;
1661
+					{
1662
+											$query_parts[$condition === 'or' ? 'or' : 'and'][] = $allowed_conditions[$query_condition]($query_params);
1663
+					}
1664
+					else {
1665
+											$query_parts[$condition === 'or' ? 'or' : 'and'][] = isset($allowed_conditions[$query_condition]) ? $allowed_conditions[$query_condition] : $query_condition;
1666
+					}
1544 1667
 				}
1545 1668
 			}
1546 1669
 			elseif ($query_conditions == 'member_names')
@@ -1554,7 +1677,9 @@  discard block
 block discarded – undo
1554 1677
 		}
1555 1678
 
1556 1679
 		if (!empty($query_parts['or']))
1557
-			$query_parts['and'][] = implode("\n\t\t\tOR ", $query_parts['or']);
1680
+		{
1681
+					$query_parts['and'][] = implode("\n\t\t\tOR ", $query_parts['or']);
1682
+		}
1558 1683
 
1559 1684
 		$query_where = implode("\n\t\t\tAND ", $query_parts['and']);
1560 1685
 	}
@@ -1562,17 +1687,23 @@  discard block
 block discarded – undo
1562 1687
 	elseif (isset($allowed_conditions[$query]))
1563 1688
 	{
1564 1689
 		if ($query == 'member_names')
1565
-			$query_where = $allowed_conditions[$query]($query_params);
1566
-		else
1567
-			$query_where = $allowed_conditions[$query];
1690
+		{
1691
+					$query_where = $allowed_conditions[$query]($query_params);
1692
+		}
1693
+		else {
1694
+					$query_where = $allowed_conditions[$query];
1695
+		}
1568 1696
 	}
1569 1697
 	// Something else, be careful ;)
1570
-	else
1571
-		$query_where = $query;
1698
+	else {
1699
+			$query_where = $query;
1700
+	}
1572 1701
 
1573 1702
 	// Lazy loading, our favorite
1574 1703
 	if (empty($query_where))
1575
-		return false;
1704
+	{
1705
+			return false;
1706
+	}
1576 1707
 
1577 1708
 	// Only want active members
1578 1709
 	if ($only_active)
@@ -1613,7 +1744,9 @@  discard block
 block discarded – undo
1613 1744
 
1614 1745
 	$admins = array();
1615 1746
 	while ($row = $db->fetch_assoc($request))
1616
-		$admins[$row['id_member']] = array($row['real_name'], $row['lngfile']);
1747
+	{
1748
+			$admins[$row['id_member']] = array($row['real_name'], $row['lngfile']);
1749
+	}
1617 1750
 	$db->free_result($request);
1618 1751
 
1619 1752
 	return $admins;
@@ -1663,7 +1796,9 @@  discard block
 block discarded – undo
1663 1796
 	$members = array();
1664 1797
 
1665 1798
 	if (empty($member_ids))
1666
-		return false;
1799
+	{
1800
+			return false;
1801
+	}
1667 1802
 
1668 1803
 	if (!is_array($member_ids))
1669 1804
 	{
@@ -1703,12 +1838,17 @@  discard block
 block discarded – undo
1703 1838
 	while ($row = $db->fetch_assoc($request))
1704 1839
 	{
1705 1840
 		if (empty($row['lngfile']))
1706
-			$row['lngfile'] = $language;
1841
+		{
1842
+					$row['lngfile'] = $language;
1843
+		}
1707 1844
 
1708 1845
 		if (!empty($single))
1709
-			$members = $row;
1710
-		else
1711
-			$members[$row['id_member']] = $row;
1846
+		{
1847
+					$members = $row;
1848
+		}
1849
+		else {
1850
+					$members[$row['id_member']] = $row;
1851
+		}
1712 1852
 	}
1713 1853
 	$db->free_result($request);
1714 1854
 
@@ -1738,7 +1878,9 @@  discard block
 block discarded – undo
1738 1878
 	);
1739 1879
 
1740 1880
 	while ($row = $db->fetch_assoc($request))
1741
-		$inactive_members[$row['is_activated']] = $row['total_members'];
1881
+	{
1882
+			$inactive_members[$row['is_activated']] = $row['total_members'];
1883
+	}
1742 1884
 	$db->free_result($request);
1743 1885
 
1744 1886
 	return $inactive_members;
@@ -1769,7 +1911,9 @@  discard block
 block discarded – undo
1769 1911
 		)
1770 1912
 	);
1771 1913
 	if ($db->num_rows($request) == 0)
1772
-		return false;
1914
+	{
1915
+			return false;
1916
+	}
1773 1917
 	$member = $db->fetch_assoc($request);
1774 1918
 	$db->free_result($request);
1775 1919
 
@@ -1873,16 +2017,22 @@  discard block
 block discarded – undo
1873 2017
 
1874 2018
 	$query_cond = array();
1875 2019
 	foreach ($conditions as $key => $dummy)
1876
-		if (isset($available_conditions[$key]))
2020
+	{
2021
+			if (isset($available_conditions[$key]))
1877 2022
 			$query_cond[] = $available_conditions[$key];
2023
+	}
1878 2024
 
1879 2025
 	if (isset($conditions['group_list']))
1880
-		$conditions['additional_group_list'] = implode(', additional_groups) != 0 OR FIND_IN_SET(', $conditions['group_list']);
2026
+	{
2027
+			$conditions['additional_group_list'] = implode(', additional_groups) != 0 OR FIND_IN_SET(', $conditions['group_list']);
2028
+	}
1881 2029
 
1882 2030
 	$data = array();
1883 2031
 
1884 2032
 	if (!isset($conditions['order_by']))
1885
-		$conditions['order_by'] = 'lngfile';
2033
+	{
2034
+			$conditions['order_by'] = 'lngfile';
2035
+	}
1886 2036
 
1887 2037
 	$limit = (isset($conditions['limit'])) ? '
1888 2038
 		LIMIT {int:limit}' : '';
@@ -1899,7 +2049,9 @@  discard block
 block discarded – undo
1899 2049
 	$data['member_count'] = $db->num_rows($request);
1900 2050
 
1901 2051
 	if ($data['member_count'] == 0)
1902
-		return $data;
2052
+	{
2053
+			return $data;
2054
+	}
1903 2055
 
1904 2056
 	// Fill the info array.
1905 2057
 	while ($row = $db->fetch_assoc($request))
@@ -1951,7 +2103,9 @@  discard block
 block discarded – undo
1951 2103
 		if (isset($available_conditions[$key]))
1952 2104
 		{
1953 2105
 			if ($key === 'time_before')
1954
-				$query = true;
2106
+			{
2107
+							$query = true;
2108
+			}
1955 2109
 			$query_cond[] = $available_conditions[$key];
1956 2110
 		}
1957 2111
 	}
@@ -1961,7 +2115,9 @@  discard block
 block discarded – undo
1961 2115
 		$data = retrieveMemberData($conditions);
1962 2116
 		$members_id = array();
1963 2117
 		foreach ($data['member_info'] as $member)
1964
-			$members_id[] = $member['username'];
2118
+		{
2119
+					$members_id[] = $member['username'];
2120
+		}
1965 2121
 	}
1966 2122
 	else
1967 2123
 	{
@@ -1981,7 +2137,9 @@  discard block
 block discarded – undo
1981 2137
 
1982 2138
 	// Let the integration know that they've been activated!
1983 2139
 	foreach ($members_id as $member_id)
1984
-		call_integration_hook('integrate_activate', array($member_id, $conditions['activated_status'], $conditions['is_activated']));
2140
+	{
2141
+			call_integration_hook('integrate_activate', array($member_id, $conditions['activated_status'], $conditions['is_activated']));
2142
+	}
1985 2143
 
1986 2144
 	return $conditions['is_activated'];
1987 2145
 }
@@ -2232,16 +2390,22 @@  discard block
 block discarded – undo
2232 2390
 				$row['additional_groups'] = $group_changes[$row['id_member']]['add'];
2233 2391
 				$row['primary_group'] = $group_changes[$row['id_member']]['primary'];
2234 2392
 			}
2235
-			else
2236
-				$row['additional_groups'] = explode(',', $row['additional_groups']);
2393
+			else {
2394
+							$row['additional_groups'] = explode(',', $row['additional_groups']);
2395
+			}
2237 2396
 				// Don't have it already?
2238 2397
 			if ($row['primary_group'] == $row['id_group'] || in_array($row['id_group'], $row['additional_groups']))
2239
-				continue;
2398
+			{
2399
+							continue;
2400
+			}
2240 2401
 				// Should it become their primary?
2241 2402
 			if ($row['primary_group'] == 0 && $row['hidden'] == 0)
2242
-				$row['primary_group'] = $row['id_group'];
2243
-			else
2244
-				$row['additional_groups'][] = $row['id_group'];
2403
+			{
2404
+							$row['primary_group'] = $row['id_group'];
2405
+			}
2406
+			else {
2407
+							$row['additional_groups'][] = $row['id_group'];
2408
+			}
2245 2409
 
2246 2410
 			// Add them to the group master list.
2247 2411
 			$group_changes[$row['id_member']] = array(
@@ -2252,7 +2416,8 @@  discard block
 block discarded – undo
2252 2416
 
2253 2417
 		// Add required information to email them.
2254 2418
 		if ($row['notify_types'] != 4)
2255
-			$email_details[] = array(
2419
+		{
2420
+					$email_details[] = array(
2256 2421
 				'rid' => $row['id_request'],
2257 2422
 				'member_id' => $row['id_member'],
2258 2423
 				'member_name' => $row['member_name'],
@@ -2261,6 +2426,7 @@  discard block
 block discarded – undo
2261 2426
 				'email' => $row['email_address'],
2262 2427
 				'language' => $row['lngfile'],
2263 2428
 			);
2429
+		}
2264 2430
 	}
2265 2431
 	$db->free_result($request);
2266 2432
 
@@ -2300,17 +2466,24 @@  discard block
 block discarded – undo
2300 2466
 
2301 2467
 	// 0 = all members
2302 2468
 	if ($receive_from == 0)
2303
-		return true;
2469
+	{
2470
+			return true;
2471
+	}
2304 2472
 	// 1 = all except ignore
2305 2473
 	elseif ($receive_from == 1)
2306
-		return !(!empty($ignore_list) && in_array($user_info['id'], $ignore_list));
2474
+	{
2475
+			return !(!empty($ignore_list) && in_array($user_info['id'], $ignore_list));
2476
+	}
2307 2477
 	// 2 = buddies and admin
2308 2478
 	elseif ($receive_from == 2)
2309
-		return ($user_info['is_admin'] || (!empty($buddy_list) && in_array($user_info['id'], $buddy_list)));
2479
+	{
2480
+			return ($user_info['is_admin'] || (!empty($buddy_list) && in_array($user_info['id'], $buddy_list)));
2481
+	}
2310 2482
 	// 3 = admin only
2311
-	else
2312
-		return (bool) $user_info['is_admin'];
2313
-}
2483
+	else {
2484
+			return (bool) $user_info['is_admin'];
2485
+	}
2486
+	}
2314 2487
 
2315 2488
 /**
2316 2489
  * This function updates the latest member, the total membercount, and the
@@ -2458,7 +2631,9 @@  discard block
 block discarded – undo
2458 2631
 		$parameters['members'] = $members;
2459 2632
 	}
2460 2633
 	elseif ($members === null)
2461
-		$condition = '1=1';
2634
+	{
2635
+			$condition = '1=1';
2636
+	}
2462 2637
 	else
2463 2638
 	{
2464 2639
 		$condition = 'id_member = {int:member}';
@@ -2501,7 +2676,9 @@  discard block
 block discarded – undo
2501 2676
 		{
2502 2677
 			// Fetch a list of member_names if necessary
2503 2678
 			if ((!is_array($members) && $members === $user_info['id']) || (is_array($members) && count($members) == 1 && in_array($user_info['id'], $members)))
2504
-				$member_names = array($user_info['username']);
2679
+			{
2680
+							$member_names = array($user_info['username']);
2681
+			}
2505 2682
 			else
2506 2683
 			{
2507 2684
 				$member_names = $db->fetchQueryCallback('
@@ -2517,8 +2694,10 @@  discard block
 block discarded – undo
2517 2694
 			}
2518 2695
 
2519 2696
 			if (!empty($member_names))
2520
-				foreach ($vars_to_integrate as $var)
2697
+			{
2698
+							foreach ($vars_to_integrate as $var)
2521 2699
 					call_integration_hook('integrate_change_member_data', array($member_names, &$var, &$data[$var], &$knownInts, &$knownFloats));
2700
+			}
2522 2701
 		}
2523 2702
 	}
2524 2703
 
@@ -2528,11 +2707,17 @@  discard block
 block discarded – undo
2528 2707
 		$type = 'string';
2529 2708
 
2530 2709
 		if (in_array($var, $knownInts))
2531
-			$type = 'int';
2710
+		{
2711
+					$type = 'int';
2712
+		}
2532 2713
 		elseif (in_array($var, $knownFloats))
2533
-			$type = 'float';
2714
+		{
2715
+					$type = 'float';
2716
+		}
2534 2717
 		elseif ($var == 'birthdate')
2535
-			$type = 'date';
2718
+		{
2719
+					$type = 'date';
2720
+		}
2536 2721
 
2537 2722
 		// Doing an increment?
2538 2723
 		if ($type == 'int' && ($val === '+' || $val === '-'))
@@ -2547,7 +2732,9 @@  discard block
 block discarded – undo
2547 2732
 			if (preg_match('~^' . $var . ' (\+ |- |\+ -)([\d]+)~', $val, $match))
2548 2733
 			{
2549 2734
 				if ($match[1] != '+ ')
2550
-					$val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END';
2735
+				{
2736
+									$val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END';
2737
+				}
2551 2738
 				$type = 'raw';
2552 2739
 			}
2553 2740
 		}
@@ -2572,7 +2759,9 @@  discard block
 block discarded – undo
2572 2759
 	if ($cache->levelHigherThan(1) && !empty($members))
2573 2760
 	{
2574 2761
 		if (!is_array($members))
2575
-			$members = array($members);
2762
+		{
2763
+					$members = array($members);
2764
+		}
2576 2765
 
2577 2766
 		foreach ($members as $member)
2578 2767
 		{
@@ -2611,7 +2800,9 @@  discard block
 block discarded – undo
2611 2800
 	);
2612 2801
 	$ips = array();
2613 2802
 	while ($row = $db->fetch_assoc($request))
2614
-		$ips[$row['member_ip']][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>';
2803
+	{
2804
+			$ips[$row['member_ip']][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>';
2805
+	}
2615 2806
 	$db->free_result($request);
2616 2807
 
2617 2808
 	ksort($ips);
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
 			'pm_ignore_list' => implode(', pm_ignore_list) != 0 OR FIND_IN_SET(', $users),
431 431
 			'buddy_list' => implode(', buddy_list) != 0 OR FIND_IN_SET(', $users),
432 432
 		),
433
-		function ($row) use ($users)
433
+		function($row) use ($users)
434 434
 		{
435 435
 			updateMemberData($row['id_member'], array(
436 436
 				'pm_ignore_list' => implode(',', array_diff(explode(',', $row['pm_ignore_list']), $users)),
@@ -1054,7 +1054,7 @@  discard block
 block discarded – undo
1054 1054
 			'member_group_allowed_implode' => implode(', mem.additional_groups) != 0 OR FIND_IN_SET(', $member_groups['allowed']),
1055 1055
 			'member_group_denied_implode' => implode(', mem.additional_groups) != 0 OR FIND_IN_SET(', $member_groups['denied']),
1056 1056
 		),
1057
-		function ($row)
1057
+		function($row)
1058 1058
 		{
1059 1059
 			return $row['id_member'];
1060 1060
 		}
@@ -1509,7 +1509,7 @@  discard block
 block discarded – undo
1509 1509
 {
1510 1510
 	$allowed_conditions = array(
1511 1511
 		'member_ids'   => 'id_member IN ({array_int:member_ids})',
1512
-		'member_names' => function (&$members)
1512
+		'member_names' => function(&$members)
1513 1513
 		{
1514 1514
 			$mem_query = array();
1515 1515
 
@@ -1811,7 +1811,7 @@  discard block
 block discarded – undo
1811 1811
 			'activation_status' => array(1, 12),
1812 1812
 			'limit' => Util::strlen($search) <= 2 ? 100 : 200,
1813 1813
 		),
1814
-		function ($row)
1814
+		function($row)
1815 1815
 		{
1816 1816
 			$row['real_name'] = strtr($row['real_name'], array('&amp;' => '&#038;', '&lt;' => '&#060;', '&gt;' => '&#062;', '&quot;' => '&#034;'));
1817 1817
 
@@ -2509,7 +2509,7 @@  discard block
 block discarded – undo
2509 2509
 					FROM {db_prefix}members
2510 2510
 					WHERE ' . $condition,
2511 2511
 					$parameters,
2512
-					function ($row)
2512
+					function($row)
2513 2513
 					{
2514 2514
 						return $row['member_name'];
2515 2515
 					}
Please login to merge, or discard this patch.
sources/subs/Attachments.subs.php 1 patch
Braces   +320 added lines, -126 removed lines patch added patch discarded remove patch
@@ -30,11 +30,17 @@  discard block
 block discarded – undo
30 30
 	// Not pretty, but since we don't want folders created for every post.
31 31
 	// It'll do unless a better solution can be found.
32 32
 	if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'admin')
33
-		$doit = true;
33
+	{
34
+			$doit = true;
35
+	}
34 36
 	elseif (empty($modSettings['automanage_attachments']))
35
-		return;
37
+	{
38
+			return;
39
+	}
36 40
 	elseif (!isset($_FILES))
37
-		return;
41
+	{
42
+			return;
43
+	}
38 44
 	elseif (isset($_FILES['attachment']))
39 45
 	{
40 46
 		foreach ($_FILES['attachment']['tmp_name'] as $dummy)
@@ -48,7 +54,9 @@  discard block
 block discarded – undo
48 54
 	}
49 55
 
50 56
 	if (!isset($doit))
51
-		return;
57
+	{
58
+			return;
59
+	}
52 60
 
53 61
 	// Get our date and random numbers for the directory choices
54 62
 	$year = date('Y');
@@ -61,21 +69,30 @@  discard block
 block discarded – undo
61 69
 	if (!empty($modSettings['attachment_basedirectories']) && !empty($modSettings['use_subdirectories_for_attachments']))
62 70
 	{
63 71
 		if (!is_array($modSettings['attachment_basedirectories']))
64
-			$modSettings['attachment_basedirectories'] = Util::unserialize($modSettings['attachment_basedirectories']);
72
+		{
73
+					$modSettings['attachment_basedirectories'] = Util::unserialize($modSettings['attachment_basedirectories']);
74
+		}
65 75
 
66 76
 		$base_dir = array_search($modSettings['basedirectory_for_attachments'], $modSettings['attachment_basedirectories']);
67 77
 	}
68
-	else
69
-		$base_dir = 0;
78
+	else {
79
+			$base_dir = 0;
80
+	}
70 81
 
71 82
 	if ($modSettings['automanage_attachments'] == 1)
72 83
 	{
73 84
 		if (!isset($modSettings['last_attachments_directory']))
74
-			$modSettings['last_attachments_directory'] = array();
85
+		{
86
+					$modSettings['last_attachments_directory'] = array();
87
+		}
75 88
 		if (!is_array($modSettings['last_attachments_directory']))
76
-			$modSettings['last_attachments_directory'] = Util::unserialize($modSettings['last_attachments_directory']);
89
+		{
90
+					$modSettings['last_attachments_directory'] = Util::unserialize($modSettings['last_attachments_directory']);
91
+		}
77 92
 		if (!isset($modSettings['last_attachments_directory'][$base_dir]))
78
-			$modSettings['last_attachments_directory'][$base_dir] = 0;
93
+		{
94
+					$modSettings['last_attachments_directory'][$base_dir] = 0;
95
+		}
79 96
 	}
80 97
 
81 98
 	$basedirectory = (!empty($modSettings['use_subdirectories_for_attachments']) ? ($modSettings['basedirectory_for_attachments']) : BOARDDIR);
@@ -106,12 +123,18 @@  discard block
 block discarded – undo
106 123
 	}
107 124
 
108 125
 	if (!is_array($modSettings['attachmentUploadDir']))
109
-		$modSettings['attachmentUploadDir'] = Util::unserialize($modSettings['attachmentUploadDir']);
126
+	{
127
+			$modSettings['attachmentUploadDir'] = Util::unserialize($modSettings['attachmentUploadDir']);
128
+	}
110 129
 
111 130
 	if (!in_array($updir, $modSettings['attachmentUploadDir']) && !empty($updir))
112
-		$outputCreation = automanage_attachments_create_directory($updir);
131
+	{
132
+			$outputCreation = automanage_attachments_create_directory($updir);
133
+	}
113 134
 	elseif (in_array($updir, $modSettings['attachmentUploadDir']))
114
-		$outputCreation = true;
135
+	{
136
+			$outputCreation = true;
137
+	}
115 138
 
116 139
 	if ($outputCreation)
117 140
 	{
@@ -153,7 +176,9 @@  discard block
 block discarded – undo
153 176
 
154 177
 		$directory = !empty($tree) ? attachments_init_dir($tree, $count) : false;
155 178
 		if ($directory === false)
156
-			return false;
179
+		{
180
+					return false;
181
+		}
157 182
 	}
158 183
 
159 184
 	$directory .= DIRECTORY_SEPARATOR . array_shift($tree);
@@ -194,7 +219,9 @@  discard block
 block discarded – undo
194 219
 
195 220
 	// Everything seems fine...let's create the .htaccess
196 221
 	if (!file_exists($directory . DIRECTORY_SEPARATOR . '.htaccess'))
197
-		secureDirectory($updir, true);
222
+	{
223
+			secureDirectory($updir, true);
224
+	}
198 225
 
199 226
 	$sep = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? '\/' : DIRECTORY_SEPARATOR;
200 227
 	$updir = rtrim($updir, $sep);
@@ -231,7 +258,9 @@  discard block
 block discarded – undo
231 258
 	global $modSettings;
232 259
 
233 260
 	if (!isset($modSettings['automanage_attachments']) || (!empty($modSettings['automanage_attachments']) && $modSettings['automanage_attachments'] != 1))
234
-		return;
261
+	{
262
+			return;
263
+	}
235 264
 
236 265
 	$basedirectory = (!empty($modSettings['use_subdirectories_for_attachments']) ? ($modSettings['basedirectory_for_attachments']) : BOARDDIR);
237 266
 
@@ -245,12 +274,15 @@  discard block
 block discarded – undo
245 274
 		$base_dir = array_search($modSettings['basedirectory_for_attachments'], $modSettings['attachment_basedirectories']);
246 275
 		$base_dir = !empty($modSettings['automanage_attachments']) ? $base_dir : 0;
247 276
 	}
248
-	else
249
-		$base_dir = 0;
277
+	else {
278
+			$base_dir = 0;
279
+	}
250 280
 
251 281
 	// Get the last attachment directory for that base directory
252 282
 	if (empty($modSettings['last_attachments_directory'][$base_dir]))
253
-		$modSettings['last_attachments_directory'][$base_dir] = 0;
283
+	{
284
+			$modSettings['last_attachments_directory'][$base_dir] = 0;
285
+	}
254 286
 
255 287
 	// And increment it.
256 288
 	$modSettings['last_attachments_directory'][$base_dir]++;
@@ -269,9 +301,10 @@  discard block
 block discarded – undo
269 301
 
270 302
 		return true;
271 303
 	}
272
-	else
273
-		return false;
274
-}
304
+	else {
305
+			return false;
306
+	}
307
+	}
275 308
 
276 309
 /**
277 310
  * Finds the current directory tree for the supplied base directory
@@ -290,11 +323,15 @@  discard block
 block discarded – undo
290 323
 			* while in linux should be safe to explode only for / (aka DIRECTORY_SEPARATOR)
291 324
 	*/
292 325
 	if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
293
-		$tree = preg_split('#[\\\/]#', $directory);
326
+	{
327
+			$tree = preg_split('#[\\\/]#', $directory);
328
+	}
294 329
 	else
295 330
 	{
296 331
 		if (substr($directory, 0, 1) != DIRECTORY_SEPARATOR)
297
-			return false;
332
+		{
333
+					return false;
334
+		}
298 335
 
299 336
 		$tree = explode(DIRECTORY_SEPARATOR, trim($directory, DIRECTORY_SEPARATOR));
300 337
 	}
@@ -324,9 +361,12 @@  discard block
 block discarded – undo
324 361
 		// ...even if, I should check this in the admin page...isn't it?
325 362
 		// ...NHAAA Let's leave space for users' complains! :P
326 363
 		if (preg_match('/^[a-z]:$/i', $tree[0]))
327
-			$directory = array_shift($tree);
328
-		else
329
-			return false;
364
+		{
365
+					$directory = array_shift($tree);
366
+		}
367
+		else {
368
+					return false;
369
+		}
330 370
 
331 371
 		$count--;
332 372
 	}
@@ -356,7 +396,9 @@  discard block
 block discarded – undo
356 396
 
357 397
 	// Make sure we're uploading to the right place.
358 398
 	if (!empty($modSettings['automanage_attachments']))
359
-		automanage_attachments_check_directory();
399
+	{
400
+			automanage_attachments_check_directory();
401
+	}
360 402
 
361 403
 	if (!is_array($modSettings['attachmentUploadDir']))
362 404
 	{
@@ -371,7 +413,9 @@  discard block
 block discarded – undo
371 413
 
372 414
 	// Is the attachments folder actually there?
373 415
 	if (!empty($context['dir_creation_error']))
374
-		$initial_error = $context['dir_creation_error'];
416
+	{
417
+			$initial_error = $context['dir_creation_error'];
418
+	}
375 419
 	elseif (!is_dir($context['attach_dir']))
376 420
 	{
377 421
 		$initial_error = 'attach_folder_warning';
@@ -382,7 +426,9 @@  discard block
 block discarded – undo
382 426
 	{
383 427
 		// If this isn't a new post, check the current attachments.
384 428
 		if (!empty($id_msg))
385
-			list ($context['attachments']['quantity'], $context['attachments']['total_size']) = attachmentsSizeForMessage($id_msg);
429
+		{
430
+					list ($context['attachments']['quantity'], $context['attachments']['total_size']) = attachmentsSizeForMessage($id_msg);
431
+		}
386 432
 		else
387 433
 		{
388 434
 			$context['attachments']['quantity'] = 0;
@@ -416,7 +462,9 @@  discard block
 block discarded – undo
416 462
 			foreach ($_SESSION['temp_attachments'] as $attachID => $attachment)
417 463
 			{
418 464
 				if (strpos($attachID, 'post_tmp_' . $user_info['id'] . '_') !== false)
419
-					@unlink($attachment['tmp_name']);
465
+				{
466
+									@unlink($attachment['tmp_name']);
467
+				}
420 468
 			}
421 469
 
422 470
 			$attach_errors->activate()->addError('temp_attachments_flushed');
@@ -425,25 +473,33 @@  discard block
 block discarded – undo
425 473
 	}
426 474
 
427 475
 	if (!isset($_FILES['attachment']['name']))
428
-		$_FILES['attachment']['tmp_name'] = array();
476
+	{
477
+			$_FILES['attachment']['tmp_name'] = array();
478
+	}
429 479
 
430 480
 	if (!isset($_SESSION['temp_attachments']))
431
-		$_SESSION['temp_attachments'] = array();
481
+	{
482
+			$_SESSION['temp_attachments'] = array();
483
+	}
432 484
 
433 485
 	// Remember where we are at. If it's anywhere at all.
434 486
 	if (!$ignore_temp)
435
-		$_SESSION['temp_attachments']['post'] = array(
487
+	{
488
+			$_SESSION['temp_attachments']['post'] = array(
436 489
 			'msg' => !empty($id_msg) ? $id_msg : 0,
437 490
 			'last_msg' => !empty($_REQUEST['last_msg']) ? $_REQUEST['last_msg'] : 0,
438 491
 			'topic' => !empty($topic) ? $topic : 0,
439 492
 			'board' => !empty($board) ? $board : 0,
440 493
 		);
494
+	}
441 495
 
442 496
 	// Loop through $_FILES['attachment'] array and move each file to the current attachments folder.
443 497
 	foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy)
444 498
 	{
445 499
 		if ($_FILES['attachment']['name'][$n] == '')
446
-			continue;
500
+		{
501
+					continue;
502
+		}
447 503
 
448 504
 		// If we have an initial error, lets just display it.
449 505
 		if (!empty($initial_error) && $added_initial_error === false)
@@ -464,7 +520,9 @@  discard block
 block discarded – undo
464 520
 			foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy)
465 521
 			{
466 522
 				if (file_exists($_FILES['attachment']['tmp_name'][$n]))
467
-					unlink($_FILES['attachment']['tmp_name'][$n]);
523
+				{
524
+									unlink($_FILES['attachment']['tmp_name'][$n]);
525
+				}
468 526
 			}
469 527
 
470 528
 			$_FILES['attachment']['tmp_name'] = array();
@@ -493,12 +551,16 @@  discard block
 block discarded – undo
493 551
 
494 552
 			// Move the file to the attachments folder with a temp name for now.
495 553
 			if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName))
496
-				@chmod($destName, 0644);
554
+			{
555
+							@chmod($destName, 0644);
556
+			}
497 557
 			else
498 558
 			{
499 559
 				$_SESSION['temp_attachments'][$attachID]['errors'][] = 'attach_timeout';
500 560
 				if (file_exists($_FILES['attachment']['tmp_name'][$n]))
501
-					unlink($_FILES['attachment']['tmp_name'][$n]);
561
+				{
562
+									unlink($_FILES['attachment']['tmp_name'][$n]);
563
+				}
502 564
 			}
503 565
 		}
504 566
 		// Upload error(s) were detected, flag the error, remove the file
@@ -511,12 +573,16 @@  discard block
 block discarded – undo
511 573
 			);
512 574
 
513 575
 			if (file_exists($_FILES['attachment']['tmp_name'][$n]))
514
-				unlink($_FILES['attachment']['tmp_name'][$n]);
576
+			{
577
+							unlink($_FILES['attachment']['tmp_name'][$n]);
578
+			}
515 579
 		}
516 580
 
517 581
 		// If there were no errors to this point, we apply some additional checks
518 582
 		if (empty($_SESSION['temp_attachments'][$attachID]['errors']))
519
-			attachmentChecks($attachID);
583
+		{
584
+					attachmentChecks($attachID);
585
+		}
520 586
 
521 587
 		// Want to correct for phonetographer photos?
522 588
 		if (!empty($modSettings['attachment_autorotate']) && empty($_SESSION['temp_attachments'][$attachID]['errors']) && substr($_SESSION['temp_attachments'][$attachID]['type'], 0, 5) === 'image')
@@ -548,8 +614,9 @@  discard block
 block discarded – undo
548 614
 						unset($_SESSION['temp_attachments'][$attachID]);
549 615
 					}
550 616
 				}
551
-				else
552
-					$attach_errors->addError(array($error[0], $error[1]));
617
+				else {
618
+									$attach_errors->addError(array($error[0], $error[1]));
619
+				}
553 620
 			}
554 621
 		}
555 622
 	}
@@ -589,8 +656,9 @@  discard block
 block discarded – undo
589 656
 				return true;
590 657
 			}
591 658
 			// Nope can't delete it if we can't find it
592
-			else
593
-				return 'attachment_not_found';
659
+			else {
660
+							return 'attachment_not_found';
661
+			}
594 662
 		}
595 663
 	}
596 664
 
@@ -642,18 +710,25 @@  discard block
 block discarded – undo
642 710
 
643 711
 	// Permissions: only temporary attachments
644 712
 	if (substr($id_attach, 0, 8) !== 'post_tmp')
645
-		throw new \Exception('no_access');
713
+	{
714
+			throw new \Exception('no_access');
715
+	}
646 716
 
647 717
 	// Permissions: only author is allowed.
648 718
 	$pieces = explode('_', substr($id_attach, 9));
649 719
 
650 720
 	if (!isset($pieces[0]) || $pieces[0] != $user_info['id'])
651
-		throw new \Exception('no_access');
721
+	{
722
+			throw new \Exception('no_access');
723
+	}
652 724
 
653 725
 	if (is_array($modSettings['attachmentUploadDir']))
654
-		$dirs = $modSettings['attachmentUploadDir'];
655
-	else
656
-		$dirs = unserialize($modSettings['attachmentUploadDir']);
726
+	{
727
+			$dirs = $modSettings['attachmentUploadDir'];
728
+	}
729
+	else {
730
+			$dirs = unserialize($modSettings['attachmentUploadDir']);
731
+	}
657 732
 
658 733
 	$attach_dir = $dirs[$modSettings['currentAttachmentUploadDir']];
659 734
 
@@ -687,21 +762,30 @@  discard block
 block discarded – undo
687 762
 	{
688 763
 		// The file exceeds the max_filesize directive in php.ini
689 764
 		if ($_FILES['attachment']['error'][$attachID] == 1)
690
-			$errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit']));
765
+		{
766
+					$errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit']));
767
+		}
691 768
 		// The uploaded file exceeds the MAX_FILE_SIZE directive in the HTML form.
692 769
 		elseif ($_FILES['attachment']['error'][$attachID] == 2)
693
-			$errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit']));
770
+		{
771
+					$errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit']));
772
+		}
694 773
 		// Missing or a full a temp directory on the server
695 774
 		elseif ($_FILES['attachment']['error'][$attachID] == 6)
696
-			Errors::instance()->log_error($_FILES['attachment']['name'][$attachID] . ': ' . $txt['php_upload_error_6'], 'critical');
775
+		{
776
+					Errors::instance()->log_error($_FILES['attachment']['name'][$attachID] . ': ' . $txt['php_upload_error_6'], 'critical');
777
+		}
697 778
 		// One of many errors such as (3)partially uploaded, (4)empty file,
698
-		else
699
-			Errors::instance()->log_error($_FILES['attachment']['name'][$attachID] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$attachID]]);
779
+		else {
780
+					Errors::instance()->log_error($_FILES['attachment']['name'][$attachID] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$attachID]]);
781
+		}
700 782
 
701 783
 		// If we did not set an user error (3,4,6,7,8) to show then give them a generic one as there is
702 784
 		// no need to provide back specifics of a server error, those are logged
703 785
 		if (empty($errors))
704
-			$errors[] = 'attach_php_error';
786
+		{
787
+					$errors[] = 'attach_php_error';
788
+		}
705 789
 	}
706 790
 
707 791
 	return $errors;
@@ -731,17 +815,27 @@  discard block
 block discarded – undo
731 815
 
732 816
 	// No data or missing data .... Not necessarily needed, but in case a mod author missed something.
733 817
 	if (empty($_SESSION['temp_attachments'][$attachID]))
734
-		$error = '$_SESSION[\'temp_attachments\'][$attachID]';
818
+	{
819
+			$error = '$_SESSION[\'temp_attachments\'][$attachID]';
820
+	}
735 821
 	elseif (empty($attachID))
736
-		$error = '$attachID';
822
+	{
823
+			$error = '$attachID';
824
+	}
737 825
 	elseif (empty($context['attachments']))
738
-		$error = '$context[\'attachments\']';
826
+	{
827
+			$error = '$context[\'attachments\']';
828
+	}
739 829
 	elseif (empty($context['attach_dir']))
740
-		$error = '$context[\'attach_dir\']';
830
+	{
831
+			$error = '$context[\'attach_dir\']';
832
+	}
741 833
 
742 834
 	// Let's get their attention.
743 835
 	if (!empty($error))
744
-		throw new Elk_Exception('attach_check_nag', 'debug', array($error));
836
+	{
837
+			throw new Elk_Exception('attach_check_nag', 'debug', array($error));
838
+	}
745 839
 
746 840
 	// Just in case this slipped by the first checks, we stop it here and now
747 841
 	if ($_SESSION['temp_attachments'][$attachID]['size'] == 0)
@@ -859,41 +953,55 @@  discard block
 block discarded – undo
859 953
 				else
860 954
 				{
861 955
 					if (isset($context['dir_creation_error']))
862
-						$_SESSION['temp_attachments'][$attachID]['errors'][] = $context['dir_creation_error'];
863
-					else
864
-						$_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space';
956
+					{
957
+											$_SESSION['temp_attachments'][$attachID]['errors'][] = $context['dir_creation_error'];
958
+					}
959
+					else {
960
+											$_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space';
961
+					}
865 962
 				}
866 963
 			}
867
-			else
868
-				$_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space';
964
+			else {
965
+							$_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space';
966
+			}
869 967
 		}
870 968
 	}
871 969
 
872 970
 	// Is the file too big?
873 971
 	if (!empty($modSettings['attachmentSizeLimit']) && $_SESSION['temp_attachments'][$attachID]['size'] > $modSettings['attachmentSizeLimit'] * 1024)
874
-		$_SESSION['temp_attachments'][$attachID]['errors'][] = array('file_too_big', array(comma_format($modSettings['attachmentSizeLimit'], 0)));
972
+	{
973
+			$_SESSION['temp_attachments'][$attachID]['errors'][] = array('file_too_big', array(comma_format($modSettings['attachmentSizeLimit'], 0)));
974
+	}
875 975
 
876 976
 	// Check the total upload size for this post...
877 977
 	$context['attachments']['total_size'] += $_SESSION['temp_attachments'][$attachID]['size'];
878 978
 	if (!empty($modSettings['attachmentPostLimit']) && $context['attachments']['total_size'] > $modSettings['attachmentPostLimit'] * 1024)
879
-		$_SESSION['temp_attachments'][$attachID]['errors'][] = array('attach_max_total_file_size', array(comma_format($modSettings['attachmentPostLimit'], 0), comma_format($modSettings['attachmentPostLimit'] - (($context['attachments']['total_size'] - $_SESSION['temp_attachments'][$attachID]['size']) / 1024), 0)));
979
+	{
980
+			$_SESSION['temp_attachments'][$attachID]['errors'][] = array('attach_max_total_file_size', array(comma_format($modSettings['attachmentPostLimit'], 0), comma_format($modSettings['attachmentPostLimit'] - (($context['attachments']['total_size'] - $_SESSION['temp_attachments'][$attachID]['size']) / 1024), 0)));
981
+	}
880 982
 
881 983
 	// Have we reached the maximum number of files we are allowed?
882 984
 	$context['attachments']['quantity']++;
883 985
 
884 986
 	// Set a max limit if none exists
885 987
 	if (empty($modSettings['attachmentNumPerPostLimit']) && $context['attachments']['quantity'] >= 50)
886
-		$modSettings['attachmentNumPerPostLimit'] = 50;
988
+	{
989
+			$modSettings['attachmentNumPerPostLimit'] = 50;
990
+	}
887 991
 
888 992
 	if (!empty($modSettings['attachmentNumPerPostLimit']) && $context['attachments']['quantity'] > $modSettings['attachmentNumPerPostLimit'])
889
-		$_SESSION['temp_attachments'][$attachID]['errors'][] = array('attachments_limit_per_post', array($modSettings['attachmentNumPerPostLimit']));
993
+	{
994
+			$_SESSION['temp_attachments'][$attachID]['errors'][] = array('attachments_limit_per_post', array($modSettings['attachmentNumPerPostLimit']));
995
+	}
890 996
 
891 997
 	// File extension check
892 998
 	if (!empty($modSettings['attachmentCheckExtensions']))
893 999
 	{
894 1000
 		$allowed = explode(',', strtolower($modSettings['attachmentExtensions']));
895 1001
 		foreach ($allowed as $k => $dummy)
896
-			$allowed[$k] = trim($dummy);
1002
+		{
1003
+					$allowed[$k] = trim($dummy);
1004
+		}
897 1005
 
898 1006
 		if (!in_array(strtolower(substr(strrchr($_SESSION['temp_attachments'][$attachID]['name'], '.'), 1)), $allowed))
899 1007
 		{
@@ -906,9 +1014,13 @@  discard block
 block discarded – undo
906 1014
 	if (!empty($_SESSION['temp_attachments'][$attachID]['errors']))
907 1015
 	{
908 1016
 		if (isset($context['dir_size']))
909
-			$context['dir_size'] -= $_SESSION['temp_attachments'][$attachID]['size'];
1017
+		{
1018
+					$context['dir_size'] -= $_SESSION['temp_attachments'][$attachID]['size'];
1019
+		}
910 1020
 		if (isset($context['dir_files']))
911
-			$context['dir_files']--;
1021
+		{
1022
+					$context['dir_files']--;
1023
+		}
912 1024
 
913 1025
 		$context['attachments']['total_size'] -= $_SESSION['temp_attachments'][$attachID]['size'];
914 1026
 		$context['attachments']['quantity']--;
@@ -970,14 +1082,18 @@  discard block
 block discarded – undo
970 1082
 
971 1083
 	// Get the hash if no hash has been given yet.
972 1084
 	if (empty($attachmentOptions['file_hash']))
973
-		$attachmentOptions['file_hash'] = getAttachmentFilename($attachmentOptions['name'], 0, null, true);
1085
+	{
1086
+			$attachmentOptions['file_hash'] = getAttachmentFilename($attachmentOptions['name'], 0, null, true);
1087
+	}
974 1088
 
975 1089
 	// Assuming no-one set the extension let's take a look at it.
976 1090
 	if (empty($attachmentOptions['fileext']))
977 1091
 	{
978 1092
 		$attachmentOptions['fileext'] = strtolower(strrpos($attachmentOptions['name'], '.') !== false ? substr($attachmentOptions['name'], strrpos($attachmentOptions['name'], '.') + 1) : '');
979 1093
 		if (strlen($attachmentOptions['fileext']) > 8 || '.' . $attachmentOptions['fileext'] == $attachmentOptions['name'])
980
-			$attachmentOptions['fileext'] = '';
1094
+		{
1095
+					$attachmentOptions['fileext'] = '';
1096
+		}
981 1097
 	}
982 1098
 
983 1099
 	$db->insert('',
@@ -998,7 +1114,9 @@  discard block
 block discarded – undo
998 1114
 
999 1115
 	// @todo Add an error here maybe?
1000 1116
 	if (empty($attachmentOptions['id']))
1001
-		return false;
1117
+	{
1118
+			return false;
1119
+	}
1002 1120
 
1003 1121
 	// Now that we have the attach id, let's rename this and finish up.
1004 1122
 	$attachmentOptions['destination'] = getAttachmentFilename(basename($attachmentOptions['name']), $attachmentOptions['id'], $attachmentOptions['id_folder'], false, $attachmentOptions['file_hash']);
@@ -1006,7 +1124,8 @@  discard block
 block discarded – undo
1006 1124
 
1007 1125
 	// If it's not approved then add to the approval queue.
1008 1126
 	if (!$attachmentOptions['approved'])
1009
-		$db->insert('',
1127
+	{
1128
+			$db->insert('',
1010 1129
 			'{db_prefix}approval_queue',
1011 1130
 			array(
1012 1131
 				'id_attach' => 'int', 'id_msg' => 'int',
@@ -1016,9 +1135,12 @@  discard block
 block discarded – undo
1016 1135
 			),
1017 1136
 			array()
1018 1137
 		);
1138
+	}
1019 1139
 
1020 1140
 	if (empty($modSettings['attachmentThumbnails']) || (empty($attachmentOptions['width']) && empty($attachmentOptions['height'])))
1021
-		return true;
1141
+	{
1142
+			return true;
1143
+	}
1022 1144
 
1023 1145
 	// Like thumbnails, do we?
1024 1146
 	if (!empty($modSettings['attachmentThumbWidth']) && !empty($modSettings['attachmentThumbHeight']) && ($attachmentOptions['width'] > $modSettings['attachmentThumbWidth'] || $attachmentOptions['height'] > $modSettings['attachmentThumbHeight']))
@@ -1123,7 +1245,9 @@  discard block
 block discarded – undo
1123 1245
 	// Use our cache when possible
1124 1246
 	$cache = array();
1125 1247
 	if (Cache::instance()->getVar($cache, 'getAvatar_id-' . $id_attach))
1126
-		$avatarData = $cache;
1248
+	{
1249
+			$avatarData = $cache;
1250
+	}
1127 1251
 	else
1128 1252
 	{
1129 1253
 		$request = $db->query('', '
@@ -1139,7 +1263,9 @@  discard block
 block discarded – undo
1139 1263
 		);
1140 1264
 		$avatarData = array();
1141 1265
 		if ($db->num_rows($request) != 0)
1142
-			$avatarData = $db->fetch_row($request);
1266
+		{
1267
+					$avatarData = $db->fetch_row($request);
1268
+		}
1143 1269
 		$db->free_result($request);
1144 1270
 
1145 1271
 		Cache::instance()->put('getAvatar_id-' . $id_attach, $avatarData, 900);
@@ -1365,7 +1491,9 @@  discard block
 block discarded – undo
1365 1491
 
1366 1492
 	// Just making sure there is a non-zero member.
1367 1493
 	if (empty($memID))
1368
-		return false;
1494
+	{
1495
+			return false;
1496
+	}
1369 1497
 
1370 1498
 	require_once(SUBSDIR . '/Graphics.subs.php');
1371 1499
 	require_once(SUBSDIR . '/ManageAttachments.subs.php');
@@ -1441,8 +1569,9 @@  discard block
 block discarded – undo
1441 1569
 			);
1442 1570
 			return true;
1443 1571
 		}
1444
-		else
1445
-			return false;
1572
+		else {
1573
+					return false;
1574
+		}
1446 1575
 	}
1447 1576
 	else
1448 1577
 	{
@@ -1481,7 +1610,9 @@  discard block
 block discarded – undo
1481 1610
 	// Can we pull this from the cache... please please?
1482 1611
 	$temp = array();
1483 1612
 	if (Cache::instance()->getVar($temp, 'url_image_size-' . md5($url), 240))
1484
-		return $temp;
1613
+	{
1614
+			return $temp;
1615
+	}
1485 1616
 
1486 1617
 	$t = microtime(true);
1487 1618
 
@@ -1490,9 +1621,13 @@  discard block
 block discarded – undo
1490 1621
 
1491 1622
 	// Can't figure it out, just try the image size.
1492 1623
 	if ($url == '' || $url == 'http://' || $url == 'https://')
1493
-		return false;
1624
+	{
1625
+			return false;
1626
+	}
1494 1627
 	elseif (!isset($match[1]))
1495
-		$size = elk_getimagesize($url, false);
1628
+	{
1629
+			$size = elk_getimagesize($url, false);
1630
+	}
1496 1631
 	else
1497 1632
 	{
1498 1633
 		// Try to connect to the server... give it half a second.
@@ -1533,11 +1668,15 @@  discard block
 block discarded – undo
1533 1668
 
1534 1669
 	// If we didn't get it, we failed.
1535 1670
 	if (!isset($size))
1536
-		$size = false;
1671
+	{
1672
+			$size = false;
1673
+	}
1537 1674
 
1538 1675
 	// If this took a long time, we may never have to do it again, but then again we might...
1539 1676
 	if (microtime(true) - $t > 0.8)
1540
-		Cache::instance()->put('url_image_size-' . md5($url), $size, 240);
1677
+	{
1678
+			Cache::instance()->put('url_image_size-' . md5($url), $size, 240);
1679
+	}
1541 1680
 
1542 1681
 	// Didn't work.
1543 1682
 	return $size;
@@ -1561,7 +1700,9 @@  discard block
 block discarded – undo
1561 1700
 
1562 1701
 	// Make sure this thing exists and it is unserialized
1563 1702
 	if (empty($modSettings['attachmentUploadDir']))
1564
-		$attachmentDir = BOARDDIR . '/attachments';
1703
+	{
1704
+			$attachmentDir = BOARDDIR . '/attachments';
1705
+	}
1565 1706
 	elseif (!empty($modSettings['currentAttachmentUploadDir']) && !is_array($modSettings['attachmentUploadDir']) && (@unserialize($modSettings['attachmentUploadDir']) !== false))
1566 1707
 	{
1567 1708
 		// @todo this is here to prevent the package manager to die when complete the installation of the patch (the new Util class has not yet been loaded so we need the normal one)
@@ -1574,8 +1715,9 @@  discard block
 block discarded – undo
1574 1715
 			$attachmentDir = unserialize($modSettings['attachmentUploadDir']);
1575 1716
 		}
1576 1717
 	}
1577
-	else
1578
-		$attachmentDir = $modSettings['attachmentUploadDir'];
1718
+	else {
1719
+			$attachmentDir = $modSettings['attachmentUploadDir'];
1720
+	}
1579 1721
 
1580 1722
 	return is_array($attachmentDir) ? $attachmentDir[$modSettings['currentAttachmentUploadDir']] : $attachmentDir;
1581 1723
 }
@@ -1628,10 +1770,13 @@  discard block
 block discarded – undo
1628 1770
 
1629 1771
 	// Little utility function for the endless $id_folder computation for avatars.
1630 1772
 	if (!empty($modSettings['custom_avatar_enabled']))
1631
-		return 1;
1632
-	else
1633
-		return getAttachmentPathID();
1634
-}
1773
+	{
1774
+			return 1;
1775
+	}
1776
+	else {
1777
+			return getAttachmentPathID();
1778
+	}
1779
+	}
1635 1780
 
1636 1781
 /**
1637 1782
  * Get all attachments associated with a set of posts.
@@ -1670,12 +1815,16 @@  discard block
 block discarded – undo
1670 1815
 	while ($row = $db->fetch_assoc($request))
1671 1816
 	{
1672 1817
 		if (!$row['approved'] && !$includeUnapproved && (empty($filter) || !call_user_func($filter, $row, $all_posters)))
1673
-			continue;
1818
+		{
1819
+					continue;
1820
+		}
1674 1821
 
1675 1822
 		$temp[$row['id_attach']] = $row;
1676 1823
 
1677 1824
 		if (!isset($attachments[$row['id_msg']]))
1678
-			$attachments[$row['id_msg']] = array();
1825
+		{
1826
+					$attachments[$row['id_msg']] = array();
1827
+		}
1679 1828
 	}
1680 1829
 	$db->free_result($request);
1681 1830
 
@@ -1683,7 +1832,9 @@  discard block
 block discarded – undo
1683 1832
 	ksort($temp);
1684 1833
 
1685 1834
 	foreach ($temp as $row)
1686
-		$attachments[$row['id_msg']][] = $row;
1835
+	{
1836
+			$attachments[$row['id_msg']][] = $row;
1837
+	}
1687 1838
 
1688 1839
 	return $attachments;
1689 1840
 }
@@ -1732,17 +1883,24 @@  discard block
 block discarded – undo
1732 1883
 	$files = array();
1733 1884
 
1734 1885
 	if (!$dir)
1735
-		return array();
1886
+	{
1887
+			return array();
1888
+	}
1736 1889
 
1737 1890
 	while ($line = $dir->read())
1738 1891
 	{
1739 1892
 		if (in_array($line, array('.', '..', 'blank.png', 'index.php')))
1740
-			continue;
1893
+		{
1894
+					continue;
1895
+		}
1741 1896
 
1742 1897
 		if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line))
1743
-			$dirs[] = $line;
1744
-		else
1745
-			$files[] = $line;
1898
+		{
1899
+					$dirs[] = $line;
1900
+		}
1901
+		else {
1902
+					$files[] = $line;
1903
+		}
1746 1904
 	}
1747 1905
 	$dir->close();
1748 1906
 
@@ -1764,13 +1922,15 @@  discard block
 block discarded – undo
1764 1922
 	{
1765 1923
 		$tmp = getServerStoredAvatars($directory . (!empty($directory) ? '/' : '') . $line, $level + 1);
1766 1924
 		if (!empty($tmp))
1767
-			$result[] = array(
1925
+		{
1926
+					$result[] = array(
1768 1927
 				'filename' => htmlspecialchars($line, ENT_COMPAT, 'UTF-8'),
1769 1928
 				'checked' => strpos($context['member']['avatar']['server_pic'], $line . '/') !== false,
1770 1929
 				'name' => '[' . htmlspecialchars(str_replace('_', ' ', $line), ENT_COMPAT, 'UTF-8') . ']',
1771 1930
 				'is_dir' => true,
1772 1931
 				'files' => $tmp
1773 1932
 		);
1933
+		}
1774 1934
 		unset($tmp);
1775 1935
 	}
1776 1936
 
@@ -1781,7 +1941,9 @@  discard block
 block discarded – undo
1781 1941
 
1782 1942
 		// Make sure it is an image.
1783 1943
 		if (getValidMimeImageType($extension) === '')
1784
-			continue;
1944
+		{
1945
+					continue;
1946
+		}
1785 1947
 
1786 1948
 		$result[] = array(
1787 1949
 			'filename' => htmlspecialchars($line, ENT_COMPAT, 'UTF-8'),
@@ -1790,7 +1952,9 @@  discard block
 block discarded – undo
1790 1952
 			'is_dir' => false
1791 1953
 		);
1792 1954
 		if ($level == 1)
1793
-			$context['avatar_list'][] = $directory . '/' . $line;
1955
+		{
1956
+					$context['avatar_list'][] = $directory . '/' . $line;
1957
+		}
1794 1958
 	}
1795 1959
 
1796 1960
 	return $result;
@@ -1960,10 +2124,14 @@  discard block
 block discarded – undo
1960 2124
 
1961 2125
 			// If something is unapproved we'll note it so we can sort them.
1962 2126
 			if (!$attachment['approved'])
1963
-				$have_unapproved = true;
2127
+			{
2128
+							$have_unapproved = true;
2129
+			}
1964 2130
 
1965 2131
 			if (!$attachmentData[$i]['is_image'])
1966
-				continue;
2132
+			{
2133
+							continue;
2134
+			}
1967 2135
 
1968 2136
 			$attachmentData[$i]['real_width'] = $attachment['width'];
1969 2137
 			$attachmentData[$i]['width'] = $attachment['width'];
@@ -1977,9 +2145,11 @@  discard block
 block discarded – undo
1977 2145
 				if (empty($attachment['id_thumb'])
1978 2146
 					|| $attachment['thumb_width'] > $modSettings['attachmentThumbWidth']
1979 2147
 					|| $attachment['thumb_height'] > $modSettings['attachmentThumbHeight'])
1980
-					//|| ($attachment['thumb_width'] < $modSettings['attachmentThumbWidth'] && $attachment['thumb_height'] < $modSettings['attachmentThumbHeight']))
2148
+				{
2149
+									//|| ($attachment['thumb_width'] < $modSettings['attachmentThumbWidth'] && $attachment['thumb_height'] < $modSettings['attachmentThumbHeight']))
1981 2150
 				{
1982 2151
 					$filename = getAttachmentFilename($attachment['filename'], $attachment['id_attach'], $attachment['id_folder'], false, $attachment['file_hash']);
2152
+				}
1983 2153
 					$attachment = array_merge($attachment, updateAttachmentThumbnail($filename, $attachment['id_attach'], $id_msg, $attachment['id_thumb'], $attachment['filename']));
1984 2154
 				}
1985 2155
 
@@ -2022,19 +2192,26 @@  discard block
 block discarded – undo
2022 2192
 				// If the image is too large to show inline, make it a popup.
2023 2193
 				// @todo this needs to be removed or depreciated
2024 2194
 				if (((!empty($modSettings['max_image_width']) && $attachmentData[$i]['real_width'] > $modSettings['max_image_width']) || (!empty($modSettings['max_image_height']) && $attachmentData[$i]['real_height'] > $modSettings['max_image_height'])))
2025
-					$attachmentData[$i]['thumbnail']['javascript'] = 'return reqWin(\'' . $attachmentData[$i]['href'] . ';image\', ' . ($attachment['width'] + 20) . ', ' . ($attachment['height'] + 20) . ', true);';
2026
-				else
2027
-					$attachmentData[$i]['thumbnail']['javascript'] = 'return expandThumb(' . $attachment['id_attach'] . ');';
2195
+				{
2196
+									$attachmentData[$i]['thumbnail']['javascript'] = 'return reqWin(\'' . $attachmentData[$i]['href'] . ';image\', ' . ($attachment['width'] + 20) . ', ' . ($attachment['height'] + 20) . ', true);';
2197
+				}
2198
+				else {
2199
+									$attachmentData[$i]['thumbnail']['javascript'] = 'return expandThumb(' . $attachment['id_attach'] . ');';
2200
+				}
2028 2201
 			}
2029 2202
 
2030 2203
 			if (!$attachmentData[$i]['thumbnail']['has_thumb'])
2031
-				$attachmentData[$i]['downloads']++;
2204
+			{
2205
+							$attachmentData[$i]['downloads']++;
2206
+			}
2032 2207
 		}
2033 2208
 	}
2034 2209
 
2035 2210
 	// Do we need to instigate a sort?
2036 2211
 	if ($have_unapproved)
2037
-		usort($attachmentData, 'approved_attach_sort');
2212
+	{
2213
+			usort($attachmentData, 'approved_attach_sort');
2214
+	}
2038 2215
 
2039 2216
 	return $attachmentData;
2040 2217
 }
@@ -2050,7 +2227,9 @@  discard block
 block discarded – undo
2050 2227
 function approved_attach_sort($a, $b)
2051 2228
 {
2052 2229
 	if ($a['is_approved'] == $b['is_approved'])
2053
-		return 0;
2230
+	{
2231
+			return 0;
2232
+	}
2054 2233
 
2055 2234
 	return $a['is_approved'] > $b['is_approved'] ? -1 : 1;
2056 2235
 }
@@ -2096,24 +2275,34 @@  discard block
 block discarded – undo
2096 2275
 	$clean_name = preg_replace('~\.[\.]+~', '.', $clean_name);
2097 2276
 
2098 2277
 	if (empty($attachment_id) || ($new && empty($modSettings['attachmentEncryptFilenames'])))
2099
-		return $clean_name;
2278
+	{
2279
+			return $clean_name;
2280
+	}
2100 2281
 	elseif ($new)
2101
-		return $enc_name;
2282
+	{
2283
+			return $enc_name;
2284
+	}
2102 2285
 
2103 2286
 	// Are we using multiple directories?
2104 2287
 	if (!empty($modSettings['currentAttachmentUploadDir']))
2105 2288
 	{
2106 2289
 		if (!is_array($modSettings['attachmentUploadDir']))
2107
-			$modSettings['attachmentUploadDir'] = Util::unserialize($modSettings['attachmentUploadDir']);
2290
+		{
2291
+					$modSettings['attachmentUploadDir'] = Util::unserialize($modSettings['attachmentUploadDir']);
2292
+		}
2108 2293
 		$path = $modSettings['attachmentUploadDir'][$dir];
2109 2294
 	}
2110
-	else
2111
-		$path = $modSettings['attachmentUploadDir'];
2295
+	else {
2296
+			$path = $modSettings['attachmentUploadDir'];
2297
+	}
2112 2298
 
2113 2299
 	if (file_exists($path . '/' . $enc_name))
2114
-		$filename = $path . '/' . $enc_name;
2115
-	else
2116
-		$filename = $path . '/' . $clean_name;
2300
+	{
2301
+			$filename = $path . '/' . $enc_name;
2302
+	}
2303
+	else {
2304
+			$filename = $path . '/' . $clean_name;
2305
+	}
2117 2306
 
2118 2307
 	return $filename;
2119 2308
 }
@@ -2164,7 +2353,9 @@  discard block
 block discarded – undo
2164 2353
 
2165 2354
 	// Just make up a nice hash...
2166 2355
 	if ($new)
2167
-		return hash('sha1', hash('md5', $filename . time()) . mt_rand());
2356
+	{
2357
+			return hash('sha1', hash('md5', $filename . time()) . mt_rand());
2358
+	}
2168 2359
 
2169 2360
 	// In case of files from the old system, do a legacy call.
2170 2361
 	if (empty($file_hash))
@@ -2176,11 +2367,14 @@  discard block
 block discarded – undo
2176 2367
 	if (!empty($modSettings['currentAttachmentUploadDir']))
2177 2368
 	{
2178 2369
 		if (!is_array($modSettings['attachmentUploadDir']))
2179
-			$modSettings['attachmentUploadDir'] = Util::unserialize($modSettings['attachmentUploadDir']);
2370
+		{
2371
+					$modSettings['attachmentUploadDir'] = Util::unserialize($modSettings['attachmentUploadDir']);
2372
+		}
2180 2373
 		$path = isset($modSettings['attachmentUploadDir'][$dir]) ? $modSettings['attachmentUploadDir'][$dir] : $modSettings['basedirectory_for_attachments'];
2181 2374
 	}
2182
-	else
2183
-		$path = $modSettings['attachmentUploadDir'];
2375
+	else {
2376
+			$path = $modSettings['attachmentUploadDir'];
2377
+	}
2184 2378
 
2185 2379
 	return $path . '/' . $attachment_id . '_' . $file_hash . '.elk';
2186 2380
 }
Please login to merge, or discard this patch.
sources/subs/Post.subs.php 1 patch
Braces   +171 added lines, -61 removed lines patch added patch discarded remove patch
@@ -82,7 +82,9 @@  discard block
 block discarded – undo
82 82
 
83 83
 	// We need to know if the topic is approved. If we're told that's great - if not find out.
84 84
 	if (!$modSettings['postmod_active'])
85
-		$topicOptions['is_approved'] = true;
85
+	{
86
+			$topicOptions['is_approved'] = true;
87
+	}
86 88
 	elseif (!empty($topicOptions['id']) && !isset($topicOptions['is_approved']))
87 89
 	{
88 90
 		require_once(SUBSDIR . '/Topic.subs.php');
@@ -175,7 +177,9 @@  discard block
 block discarded – undo
175 177
 
176 178
 	// Something went wrong creating the message...
177 179
 	if (empty($msgOptions['id']))
178
-		return false;
180
+	{
181
+			return false;
182
+	}
179 183
 
180 184
 	// What if we want to export new posts out to a CMS?
181 185
 	call_integration_hook('integrate_create_post', array($msgOptions, $topicOptions, $posterOptions, $message_columns, $message_parameters));
@@ -269,21 +273,28 @@  discard block
 block discarded – undo
269 273
 		);
270 274
 
271 275
 		if ($msgOptions['approved'])
272
-			$topics_columns = array(
276
+		{
277
+					$topics_columns = array(
273 278
 				'id_member_updated = {int:poster_id}',
274 279
 				'id_last_msg = {int:id_msg}',
275 280
 				'num_replies = num_replies + {int:counter_increment}',
276 281
 			);
277
-		else
278
-			$topics_columns = array(
282
+		}
283
+		else {
284
+					$topics_columns = array(
279 285
 				'unapproved_posts = unapproved_posts + {int:counter_increment}',
280 286
 			);
287
+		}
281 288
 
282 289
 		if ($topicOptions['lock_mode'] !== null)
283
-			$topics_columns[] = 'locked = {int:locked}';
290
+		{
291
+					$topics_columns[] = 'locked = {int:locked}';
292
+		}
284 293
 
285 294
 		if ($topicOptions['sticky_mode'] !== null)
286
-			$topics_columns[] = 'is_sticky = {int:is_sticky}';
295
+		{
296
+					$topics_columns[] = 'is_sticky = {int:is_sticky}';
297
+		}
287 298
 
288 299
 		call_integration_hook('integrate_before_modify_topic', array(&$topics_columns, &$update_parameters, &$msgOptions, &$topicOptions, &$posterOptions));
289 300
 
@@ -314,7 +325,8 @@  discard block
 block discarded – undo
314 325
 
315 326
 	// Increase the number of posts and topics on the board.
316 327
 	if ($msgOptions['approved'])
317
-		$db->query('', '
328
+	{
329
+			$db->query('', '
318 330
 			UPDATE {db_prefix}boards
319 331
 			SET num_posts = num_posts + 1' . ($new_topic ? ', num_topics = num_topics + 1' : '') . '
320 332
 			WHERE id_board = {int:id_board}',
@@ -322,6 +334,7 @@  discard block
 block discarded – undo
322 334
 				'id_board' => $topicOptions['board'],
323 335
 			)
324 336
 		);
337
+	}
325 338
 	else
326 339
 	{
327 340
 		$db->query('', '
@@ -378,14 +391,18 @@  discard block
 block discarded – undo
378 391
 	$search = new \ElkArte\Search\Search;
379 392
 	$searchAPI = $search->findSearchAPI();
380 393
 	if (is_callable(array($searchAPI, 'postCreated')))
381
-		$searchAPI->postCreated($msgOptions, $topicOptions, $posterOptions);
394
+	{
395
+			$searchAPI->postCreated($msgOptions, $topicOptions, $posterOptions);
396
+	}
382 397
 
383 398
 	// Increase the post counter for the user that created the post.
384 399
 	if (!empty($posterOptions['update_post_count']) && !empty($posterOptions['id']) && $msgOptions['approved'])
385 400
 	{
386 401
 		// Are you the one that happened to create this post?
387 402
 		if ($user_info['id'] == $posterOptions['id'])
388
-			$user_info['posts']++;
403
+		{
404
+					$user_info['posts']++;
405
+		}
389 406
 
390 407
 		require_once(SUBSDIR . '/Members.subs.php');
391 408
 		updateMemberData($posterOptions['id'], array('posts' => '+'));
@@ -396,7 +413,9 @@  discard block
 block discarded – undo
396 413
 
397 414
 	// Better safe than sorry.
398 415
 	if (isset($_SESSION['topicseen_cache'][$topicOptions['board']]))
399
-		$_SESSION['topicseen_cache'][$topicOptions['board']]--;
416
+	{
417
+			$_SESSION['topicseen_cache'][$topicOptions['board']]--;
418
+	}
400 419
 
401 420
 	// Update all the stats so everyone knows about this new topic and message.
402 421
 	require_once(SUBSDIR . '/Messages.subs.php');
@@ -404,7 +423,9 @@  discard block
 block discarded – undo
404 423
 
405 424
 	// Update the last message on the board assuming it's approved AND the topic is.
406 425
 	if ($msgOptions['approved'])
407
-		updateLastMessages($topicOptions['board'], $new_topic || !empty($topicOptions['is_approved']) ? $msgOptions['id'] : 0);
426
+	{
427
+			updateLastMessages($topicOptions['board'], $new_topic || !empty($topicOptions['is_approved']) ? $msgOptions['id'] : 0);
428
+	}
408 429
 
409 430
 	// Alright, done now... we can abort now, I guess... at least this much is done.
410 431
 	ignore_user_abort($previous_ignore_user_abort);
@@ -435,13 +456,21 @@  discard block
 block discarded – undo
435 456
 	// This is longer than it has to be, but makes it so we only set/change what we have to.
436 457
 	$messages_columns = array();
437 458
 	if (isset($posterOptions['name']))
438
-		$messages_columns['poster_name'] = $posterOptions['name'];
459
+	{
460
+			$messages_columns['poster_name'] = $posterOptions['name'];
461
+	}
439 462
 	if (isset($posterOptions['email']))
440
-		$messages_columns['poster_email'] = $posterOptions['email'];
463
+	{
464
+			$messages_columns['poster_email'] = $posterOptions['email'];
465
+	}
441 466
 	if (isset($msgOptions['icon']))
442
-		$messages_columns['icon'] = $msgOptions['icon'];
467
+	{
468
+			$messages_columns['icon'] = $msgOptions['icon'];
469
+	}
443 470
 	if (isset($msgOptions['subject']))
444
-		$messages_columns['subject'] = $msgOptions['subject'];
471
+	{
472
+			$messages_columns['subject'] = $msgOptions['subject'];
473
+	}
445 474
 	if (isset($msgOptions['body']))
446 475
 	{
447 476
 		$messages_columns['body'] = $msgOptions['body'];
@@ -461,7 +490,9 @@  discard block
 block discarded – undo
461 490
 		$messages_columns['id_msg_modified'] = $modSettings['maxMsgID'];
462 491
 	}
463 492
 	if (isset($msgOptions['smileys_enabled']))
464
-		$messages_columns['smileys_enabled'] = empty($msgOptions['smileys_enabled']) ? 0 : 1;
493
+	{
494
+			$messages_columns['smileys_enabled'] = empty($msgOptions['smileys_enabled']) ? 0 : 1;
495
+	}
465 496
 
466 497
 	// Which columns need to be ints?
467 498
 	$messageInts = array('modified_time', 'id_msg_modified', 'smileys_enabled');
@@ -479,7 +510,9 @@  discard block
 block discarded – undo
479 510
 
480 511
 	// Nothing to do?
481 512
 	if (empty($messages_columns))
482
-		return true;
513
+	{
514
+			return true;
515
+	}
483 516
 
484 517
 	// Change the post.
485 518
 	$db->query('', '
@@ -492,15 +525,23 @@  discard block
 block discarded – undo
492 525
 	$attributes = array();
493 526
 	// Lock and or sticky the post.
494 527
 	if ($topicOptions['sticky_mode'] !== null)
495
-		$attributes['is_sticky'] = $topicOptions['sticky_mode'];
528
+	{
529
+			$attributes['is_sticky'] = $topicOptions['sticky_mode'];
530
+	}
496 531
 	if ($topicOptions['lock_mode'] !== null)
497
-		$attributes['locked'] = $topicOptions['lock_mode'];
532
+	{
533
+			$attributes['locked'] = $topicOptions['lock_mode'];
534
+	}
498 535
 	if ($topicOptions['poll'] !== null)
499
-		$attributes['id_poll'] = $topicOptions['poll'];
536
+	{
537
+			$attributes['id_poll'] = $topicOptions['poll'];
538
+	}
500 539
 
501 540
 	// If anything to do, do it.
502 541
 	if (!empty($attributes))
503
-		setTopicAttribute($topicOptions['id'], $attributes);
542
+	{
543
+			setTopicAttribute($topicOptions['id'], $attributes);
544
+	}
504 545
 
505 546
 	// Mark the edited post as read.
506 547
 	if (!empty($topicOptions['mark_as_read']) && !$user_info['is_guest'])
@@ -531,7 +572,9 @@  discard block
 block discarded – undo
531 572
 	$search = new \ElkArte\Search\Search;
532 573
 	$searchAPI = $search->findSearchAPI();
533 574
 	if (is_callable(array($searchAPI, 'postModified')))
534
-		$searchAPI->postModified($msgOptions, $topicOptions, $posterOptions);
575
+	{
576
+			$searchAPI->postModified($msgOptions, $topicOptions, $posterOptions);
577
+	}
535 578
 
536 579
 	if (isset($msgOptions['subject']))
537 580
 	{
@@ -555,7 +598,9 @@  discard block
 block discarded – undo
555 598
 
556 599
 	// Finally, if we are setting the approved state we need to do much more work :(
557 600
 	if ($modSettings['postmod_active'] && isset($msgOptions['approved']))
558
-		approvePosts($msgOptions['id'], $msgOptions['approved']);
601
+	{
602
+			approvePosts($msgOptions['id'], $msgOptions['approved']);
603
+	}
559 604
 
560 605
 	return true;
561 606
 }
@@ -575,10 +620,14 @@  discard block
 block discarded – undo
575 620
 	$db = database();
576 621
 
577 622
 	if (!is_array($msgs))
578
-		$msgs = array($msgs);
623
+	{
624
+			$msgs = array($msgs);
625
+	}
579 626
 
580 627
 	if (empty($msgs))
581
-		return false;
628
+	{
629
+			return false;
630
+	}
582 631
 
583 632
 	// May as well start at the beginning, working out *what* we need to change.
584 633
 	$request = $db->query('', '
@@ -611,19 +660,23 @@  discard block
 block discarded – undo
611 660
 
612 661
 		// Ensure our change array exists already.
613 662
 		if (!isset($topic_changes[$row['id_topic']]))
614
-			$topic_changes[$row['id_topic']] = array(
663
+		{
664
+					$topic_changes[$row['id_topic']] = array(
615 665
 				'id_last_msg' => $row['id_last_msg'],
616 666
 				'approved' => $row['topic_approved'],
617 667
 				'replies' => 0,
618 668
 				'unapproved_posts' => 0,
619 669
 			);
670
+		}
620 671
 		if (!isset($board_changes[$row['id_board']]))
621
-			$board_changes[$row['id_board']] = array(
672
+		{
673
+					$board_changes[$row['id_board']] = array(
622 674
 				'posts' => 0,
623 675
 				'topics' => 0,
624 676
 				'unapproved_posts' => 0,
625 677
 				'unapproved_topics' => 0,
626 678
 			);
679
+		}
627 680
 
628 681
 		// If it's the first message then the topic state changes!
629 682
 		if ($row['id_msg'] == $row['id_first_msg'])
@@ -651,7 +704,8 @@  discard block
 block discarded – undo
651 704
 
652 705
 			// This will be a post... but don't notify unless it's not followed by approved ones.
653 706
 			if ($row['id_msg'] > $row['id_last_msg'])
654
-				$notification_posts[$row['id_topic']][] = array(
707
+			{
708
+							$notification_posts[$row['id_topic']][] = array(
655 709
 					'id' => $row['id_msg'],
656 710
 					'body' => $row['body'],
657 711
 					'subject' => $row['subject'],
@@ -659,15 +713,20 @@  discard block
 block discarded – undo
659 713
 					'topic' => $row['id_topic'],
660 714
 					'signature' => $row['signature'],
661 715
 				);
716
+			}
662 717
 		}
663 718
 
664 719
 		// If this is being approved and id_msg is higher than the current id_last_msg then it changes.
665 720
 		if ($approve && $row['id_msg'] > $topic_changes[$row['id_topic']]['id_last_msg'])
666
-			$topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_msg'];
721
+		{
722
+					$topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_msg'];
723
+		}
667 724
 		// If this is being unapproved, and it's equal to the id_last_msg we need to find a new one!
668 725
 		elseif (!$approve)
669
-			// Default to the first message and then we'll override in a bit ;)
726
+		{
727
+					// Default to the first message and then we'll override in a bit ;)
670 728
 			$topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_first_msg'];
729
+		}
671 730
 
672 731
 		$topic_changes[$row['id_topic']]['unapproved_posts'] += $approve ? -1 : 1;
673 732
 		$board_changes[$row['id_board']]['unapproved_posts'] += $approve ? -1 : 1;
@@ -675,12 +734,16 @@  discard block
 block discarded – undo
675 734
 
676 735
 		// Post count for the user?
677 736
 		if ($row['id_member'] && empty($row['count_posts']))
678
-			$member_post_changes[$row['id_member']] = isset($member_post_changes[$row['id_member']]) ? $member_post_changes[$row['id_member']] + 1 : 1;
737
+		{
738
+					$member_post_changes[$row['id_member']] = isset($member_post_changes[$row['id_member']]) ? $member_post_changes[$row['id_member']] + 1 : 1;
739
+		}
679 740
 	}
680 741
 	$db->free_result($request);
681 742
 
682 743
 	if (empty($msgs))
683
-		return;
744
+	{
745
+			return;
746
+	}
684 747
 
685 748
 	// Now we have the differences make the changes, first the easy one.
686 749
 	$db->query('', '
@@ -708,13 +771,16 @@  discard block
 block discarded – undo
708 771
 			)
709 772
 		);
710 773
 		while ($row = $db->fetch_assoc($request))
711
-			$topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_last_msg'];
774
+		{
775
+					$topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_last_msg'];
776
+		}
712 777
 		$db->free_result($request);
713 778
 	}
714 779
 
715 780
 	// ... next the topics...
716 781
 	foreach ($topic_changes as $id => $changes)
717
-		$db->query('', '
782
+	{
783
+			$db->query('', '
718 784
 			UPDATE {db_prefix}topics
719 785
 			SET
720 786
 				approved = {int:approved},
@@ -730,10 +796,12 @@  discard block
 block discarded – undo
730 796
 				'id_topic' => $id,
731 797
 			)
732 798
 		);
799
+	}
733 800
 
734 801
 	// ... finally the boards...
735 802
 	foreach ($board_changes as $id => $changes)
736
-		$db->query('', '
803
+	{
804
+			$db->query('', '
737 805
 			UPDATE {db_prefix}boards
738 806
 			SET
739 807
 				num_posts = num_posts + {int:num_posts},
@@ -749,6 +817,7 @@  discard block
 block discarded – undo
749 817
 				'id_board' => $id,
750 818
 			)
751 819
 		);
820
+	}
752 821
 
753 822
 	// Finally, least importantly, notifications!
754 823
 	if ($approve)
@@ -756,10 +825,14 @@  discard block
 block discarded – undo
756 825
 		require_once(SUBSDIR . '/Notification.subs.php');
757 826
 
758 827
 		if (!empty($notification_topics))
759
-			sendBoardNotifications($notification_topics);
828
+		{
829
+					sendBoardNotifications($notification_topics);
830
+		}
760 831
 
761 832
 		if (!empty($notification_posts))
762
-			sendApprovalNotifications($notification_posts);
833
+		{
834
+					sendApprovalNotifications($notification_posts);
835
+		}
763 836
 
764 837
 		$db->query('', '
765 838
 			DELETE FROM {db_prefix}approval_queue
@@ -776,7 +849,9 @@  discard block
 block discarded – undo
776 849
 	{
777 850
 		$msgInserts = array();
778 851
 		foreach ($msgs as $msg)
779
-			$msgInserts[] = array($msg);
852
+		{
853
+					$msgInserts[] = array($msg);
854
+		}
780 855
 
781 856
 		$db->insert('ignore',
782 857
 			'{db_prefix}approval_queue',
@@ -800,7 +875,9 @@  discard block
 block discarded – undo
800 875
 	{
801 876
 		require_once(SUBSDIR . '/Members.subs.php');
802 877
 		foreach ($member_post_changes as $id_member => $count_change)
803
-			updateMemberData($id_member, array('posts' => 'posts ' . ($approve ? '+' : '-') . ' ' . $count_change));
878
+		{
879
+					updateMemberData($id_member, array('posts' => 'posts ' . ($approve ? '+' : '-') . ' ' . $count_change));
880
+		}
804 881
 	}
805 882
 
806 883
 	return true;
@@ -827,10 +904,14 @@  discard block
 block discarded – undo
827 904
 
828 905
 	// Please - let's be sane.
829 906
 	if (empty($setboards))
830
-		return false;
907
+	{
908
+			return false;
909
+	}
831 910
 
832 911
 	if (!is_array($setboards))
833
-		$setboards = array($setboards);
912
+	{
913
+			$setboards = array($setboards);
914
+	}
834 915
 
835 916
 	$lastMsg = array();
836 917
 
@@ -850,14 +931,18 @@  discard block
 block discarded – undo
850 931
 			)
851 932
 		);
852 933
 		while ($row = $db->fetch_assoc($request))
853
-			$lastMsg[$row['id_board']] = $row['id_msg'];
934
+		{
935
+					$lastMsg[$row['id_board']] = $row['id_msg'];
936
+		}
854 937
 		$db->free_result($request);
855 938
 	}
856 939
 	else
857 940
 	{
858 941
 		// Just to note - there should only be one board passed if we are doing this.
859 942
 		foreach ($setboards as $id_board)
860
-			$lastMsg[$id_board] = $id_msg;
943
+		{
944
+					$lastMsg[$id_board] = $id_msg;
945
+		}
861 946
 	}
862 947
 
863 948
 	$parent_boards = array();
@@ -875,9 +960,12 @@  discard block
 block discarded – undo
875 960
 		}
876 961
 
877 962
 		if (!empty($board) && $id_board == $board)
878
-			$parents = $board_info['parent_boards'];
879
-		else
880
-			$parents = getBoardParents($id_board);
963
+		{
964
+					$parents = $board_info['parent_boards'];
965
+		}
966
+		else {
967
+					$parents = getBoardParents($id_board);
968
+		}
881 969
 
882 970
 		// Ignore any parents on the top child level.
883 971
 		foreach ($parents as $id => $parent)
@@ -886,9 +974,13 @@  discard block
 block discarded – undo
886 974
 			{
887 975
 				// If we're already doing this one as a board, is this a higher last modified?
888 976
 				if (isset($lastModified[$id]) && $lastModified[$id_board] > $lastModified[$id])
889
-					$lastModified[$id] = $lastModified[$id_board];
977
+				{
978
+									$lastModified[$id] = $lastModified[$id_board];
979
+				}
890 980
 				elseif (!isset($lastModified[$id]) && (!isset($parent_boards[$id]) || $parent_boards[$id] < $lastModified[$id_board]))
891
-					$parent_boards[$id] = $lastModified[$id_board];
981
+				{
982
+									$parent_boards[$id] = $lastModified[$id_board];
983
+				}
892 984
 			}
893 985
 		}
894 986
 	}
@@ -902,22 +994,28 @@  discard block
 block discarded – undo
902 994
 	foreach ($parent_boards as $id => $msg)
903 995
 	{
904 996
 		if (!isset($parent_updates[$msg]))
905
-			$parent_updates[$msg] = array($id);
906
-		else
907
-			$parent_updates[$msg][] = $id;
997
+		{
998
+					$parent_updates[$msg] = array($id);
999
+		}
1000
+		else {
1001
+					$parent_updates[$msg][] = $id;
1002
+		}
908 1003
 	}
909 1004
 
910 1005
 	foreach ($lastMsg as $id => $msg)
911 1006
 	{
912 1007
 		if (!isset($board_updates[$msg . '-' . $lastModified[$id]]))
913
-			$board_updates[$msg . '-' . $lastModified[$id]] = array(
1008
+		{
1009
+					$board_updates[$msg . '-' . $lastModified[$id]] = array(
914 1010
 				'id' => $msg,
915 1011
 				'updated' => $lastModified[$id],
916 1012
 				'boards' => array($id)
917 1013
 			);
1014
+		}
918 1015
 
919
-		else
920
-			$board_updates[$msg . '-' . $lastModified[$id]]['boards'][] = $id;
1016
+		else {
1017
+					$board_updates[$msg . '-' . $lastModified[$id]]['boards'][] = $id;
1018
+		}
921 1019
 	}
922 1020
 
923 1021
 	// Now commit the changes!
@@ -980,7 +1078,9 @@  discard block
 block discarded – undo
980 1078
 		)
981 1079
 	);
982 1080
 	if ($db->num_rows($request) == 0)
983
-		return array();
1081
+	{
1082
+			return array();
1083
+	}
984 1084
 	$row = $db->fetch_assoc($request);
985 1085
 	$db->free_result($request);
986 1086
 
@@ -1044,14 +1144,18 @@  discard block
 block discarded – undo
1044 1144
 
1045 1145
 			// The message they were trying to edit was most likely deleted.
1046 1146
 			if ($message === false)
1047
-				return false;
1147
+			{
1148
+							return false;
1149
+			}
1048 1150
 
1049 1151
 			$errors = checkMessagePermissions($message['message']);
1050 1152
 
1051 1153
 			prepareMessageContext($message);
1052 1154
 
1053 1155
 			if (!empty($errors))
1054
-				$message['errors'] = $errors;
1156
+			{
1157
+							$message['errors'] = $errors;
1158
+			}
1055 1159
 
1056 1160
 			return $message;
1057 1161
 		// Posting a quoted reply?
@@ -1074,14 +1178,18 @@  discard block
 block discarded – undo
1074 1178
 				)
1075 1179
 			);
1076 1180
 			if ($db->num_rows($request) == 0)
1077
-				throw new Elk_Exception('quoted_post_deleted', false);
1181
+			{
1182
+							throw new Elk_Exception('quoted_post_deleted', false);
1183
+			}
1078 1184
 			list ($form_subject, $mname, $mdate, $form_message) = $db->fetch_row($request);
1079 1185
 			$db->free_result($request);
1080 1186
 
1081 1187
 			// Add 'Re: ' to the front of the quoted subject.
1082 1188
 			$response_prefix = response_prefix();
1083 1189
 			if (trim($response_prefix) != '' && Util::strpos($form_subject, trim($response_prefix)) !== 0)
1084
-				$form_subject = $response_prefix . $form_subject;
1190
+			{
1191
+							$form_subject = $response_prefix . $form_subject;
1192
+			}
1085 1193
 
1086 1194
 			// Censor the message and subject.
1087 1195
 			$form_message = censor($form_message);
@@ -1102,7 +1210,9 @@  discard block
 block discarded – undo
1102 1210
 			// Add 'Re: ' to the front of the subject.
1103 1211
 			$response_prefix = response_prefix();
1104 1212
 			if (trim($response_prefix) != '' && $form_subject != '' && Util::strpos($form_subject, trim($response_prefix)) !== 0)
1105
-				$form_subject = $response_prefix . $form_subject;
1213
+			{
1214
+							$form_subject = $response_prefix . $form_subject;
1215
+			}
1106 1216
 
1107 1217
 			// Censor the subject.
1108 1218
 			$form_subject = censor($form_subject);
Please login to merge, or discard this patch.
sources/subs/ScheduledTasks.subs.php 1 patch
Braces   +97 added lines, -39 removed lines patch added patch discarded remove patch
@@ -27,15 +27,20 @@  discard block
 block discarded – undo
27 27
 	$task_query = '';
28 28
 
29 29
 	if (!is_array($tasks))
30
-		$tasks = array($tasks);
30
+	{
31
+			$tasks = array($tasks);
32
+	}
31 33
 
32 34
 	// Actually have something passed?
33 35
 	if (!empty($tasks))
34 36
 	{
35 37
 		if (!isset($tasks[0]) || is_numeric($tasks[0]))
36
-			$task_query = ' AND id_task IN ({array_int:tasks})';
37
-		else
38
-			$task_query = ' AND task IN ({array_string:tasks})';
38
+		{
39
+					$task_query = ' AND id_task IN ({array_int:tasks})';
40
+		}
41
+		else {
42
+					$task_query = ' AND task IN ({array_string:tasks})';
43
+		}
39 44
 	}
40 45
 
41 46
 	$nextTaskTime = empty($tasks) ? time() + 86400 : $modSettings['next_task_time'];
@@ -57,25 +62,34 @@  discard block
 block discarded – undo
57 62
 	{
58 63
 		// scheduleTaskImmediate is a way to speed up scheduled tasks and fire them as fast as possible
59 64
 		if (!empty($scheduleTaskImmediate) && isset($scheduleTaskImmediate[$row['task']]))
60
-			$next_time = next_time(1, '', rand(0, 60), true);
61
-		else
62
-			$next_time = next_time($row['time_regularity'], $row['time_unit'], $row['time_offset']);
65
+		{
66
+					$next_time = next_time(1, '', rand(0, 60), true);
67
+		}
68
+		else {
69
+					$next_time = next_time($row['time_regularity'], $row['time_unit'], $row['time_offset']);
70
+		}
63 71
 
64 72
 		// Only bother moving the task if it's out of place or we're forcing it!
65 73
 		if ($forceUpdate || $next_time < $row['next_time'] || $row['next_time'] < time())
66
-			$tasks[$row['id_task']] = $next_time;
67
-		else
68
-			$next_time = $row['next_time'];
74
+		{
75
+					$tasks[$row['id_task']] = $next_time;
76
+		}
77
+		else {
78
+					$next_time = $row['next_time'];
79
+		}
69 80
 
70 81
 		// If this is sooner than the current next task, make this the next task.
71 82
 		if ($next_time < $nextTaskTime)
72
-			$nextTaskTime = $next_time;
83
+		{
84
+					$nextTaskTime = $next_time;
85
+		}
73 86
 	}
74 87
 	$db->free_result($request);
75 88
 
76 89
 	// Now make the changes!
77 90
 	foreach ($tasks as $id => $time)
78
-		$db->query('', '
91
+	{
92
+			$db->query('', '
79 93
 			UPDATE {db_prefix}scheduled_tasks
80 94
 			SET next_time = {int:next_time}
81 95
 			WHERE id_task = {int:id_task}',
@@ -84,11 +98,14 @@  discard block
 block discarded – undo
84 98
 				'id_task' => $id,
85 99
 			)
86 100
 		);
101
+	}
87 102
 
88 103
 	// If the next task is now different update.
89 104
 	if ($modSettings['next_task_time'] != $nextTaskTime)
90
-		updateSettings(array('next_task_time' => $nextTaskTime));
91
-}
105
+	{
106
+			updateSettings(array('next_task_time' => $nextTaskTime));
107
+	}
108
+	}
92 109
 
93 110
 /**
94 111
  * Returns a time stamp of the next instance of these time parameters.
@@ -104,13 +121,17 @@  discard block
 block discarded – undo
104 121
 {
105 122
 	// Just in case!
106 123
 	if ($regularity == 0)
107
-		$regularity = 2;
124
+	{
125
+			$regularity = 2;
126
+	}
108 127
 
109 128
 	$curMin = date('i', time());
110 129
 
111 130
 	// If we have scheduleTaskImmediate running, then it's 10 seconds
112 131
 	if (empty($unit) && $immediate)
113
-		$next_time = time() + 10;
132
+	{
133
+			$next_time = time() + 10;
134
+	}
114 135
 	// If the unit is minutes only check regularity in minutes.
115 136
 	elseif ($unit == 'm')
116 137
 	{
@@ -118,14 +139,18 @@  discard block
 block discarded – undo
118 139
 
119 140
 		// If it's now just pretend it ain't,
120 141
 		if ($off == $curMin)
121
-			$next_time = time() + $regularity;
142
+		{
143
+					$next_time = time() + $regularity;
144
+		}
122 145
 		else
123 146
 		{
124 147
 			// Make sure that the offset is always in the past.
125 148
 			$off = $off > $curMin ? $off - 60 : $off;
126 149
 
127 150
 			while ($off <= $curMin)
128
-				$off += $regularity;
151
+			{
152
+							$off += $regularity;
153
+			}
129 154
 
130 155
 			// Now we know when the time should be!
131 156
 			$next_time = time() + 60 * ($off - $curMin);
@@ -138,24 +163,32 @@  discard block
 block discarded – undo
138 163
 
139 164
 		// Make the time offset in the past!
140 165
 		if ($next_time > time())
141
-			$next_time -= 86400;
166
+		{
167
+					$next_time -= 86400;
168
+		}
142 169
 
143 170
 		// Default we'll jump in hours.
144 171
 		$applyOffset = 3600;
145 172
 
146 173
 		// 24 hours = 1 day.
147 174
 		if ($unit == 'd')
148
-			$applyOffset = 86400;
175
+		{
176
+					$applyOffset = 86400;
177
+		}
149 178
 
150 179
 		// Otherwise a week.
151 180
 		if ($unit == 'w')
152
-			$applyOffset = 604800;
181
+		{
182
+					$applyOffset = 604800;
183
+		}
153 184
 
154 185
 		$applyOffset *= $regularity;
155 186
 
156 187
 		// Just add on the offset.
157 188
 		while ($next_time <= time())
158
-			$next_time += $applyOffset;
189
+		{
190
+					$next_time += $applyOffset;
191
+		}
159 192
 	}
160 193
 
161 194
 	return $next_time;
@@ -183,7 +216,9 @@  discard block
 block discarded – undo
183 216
 	);
184 217
 	$task = array();
185 218
 	while ($row = $db->fetch_assoc($request))
186
-		$task[$row['id_task']] = $row['task'];
219
+	{
220
+			$task[$row['id_task']] = $row['task'];
221
+	}
187 222
 	$db->free_result($request);
188 223
 
189 224
 	return $task;
@@ -294,8 +329,10 @@  discard block
 block discarded – undo
294 329
 
295 330
 	$updates = array();
296 331
 	foreach ($sets as $key => $set)
297
-		if (isset($$key))
332
+	{
333
+			if (isset($$key))
298 334
 			$updates[] = $set;
335
+	}
299 336
 
300 337
 	$db->query('', '
301 338
 		UPDATE {db_prefix}scheduled_tasks
@@ -340,7 +377,9 @@  discard block
 block discarded – undo
340 377
 	);
341 378
 	// Should never, ever, happen!
342 379
 	if ($db->num_rows($request) == 0)
343
-		throw new Elk_Exception('no_access', false);
380
+	{
381
+			throw new Elk_Exception('no_access', false);
382
+	}
344 383
 	while ($row = $db->fetch_assoc($request))
345 384
 	{
346 385
 		$task = array(
@@ -433,7 +472,8 @@  discard block
 block discarded – undo
433 472
 	);
434 473
 	$log_entries = array();
435 474
 	while ($row = $db->fetch_assoc($request))
436
-		$log_entries[] = array(
475
+	{
476
+			$log_entries[] = array(
437 477
 			'id' => $row['id_log'],
438 478
 			'name' => isset($txt['scheduled_task_' . $row['task']]) ? $txt['scheduled_task_' . $row['task']] : $row['task'],
439 479
 			'time_run' => $row['time_run'],
@@ -441,6 +481,7 @@  discard block
 block discarded – undo
441 481
 			'time_taken' => $row['time_taken'] == -1 ? 0 : $row['time_taken'],
442 482
 			'task_completed' => $row['time_taken'] != -1,
443 483
 		);
484
+	}
444 485
 	$db->free_result($request);
445 486
 
446 487
 	return $log_entries;
@@ -518,17 +559,27 @@  discard block
 block discarded – undo
518 559
 		// How long in seconds is the gap?
519 560
 		$duration = $row['time_regularity'];
520 561
 		if ($row['time_unit'] == 'm')
521
-			$duration *= 60;
562
+		{
563
+					$duration *= 60;
564
+		}
522 565
 		elseif ($row['time_unit'] == 'h')
523
-			$duration *= 3600;
566
+		{
567
+					$duration *= 3600;
568
+		}
524 569
 		elseif ($row['time_unit'] == 'd')
525
-			$duration *= 86400;
570
+		{
571
+					$duration *= 86400;
572
+		}
526 573
 		elseif ($row['time_unit'] == 'w')
527
-			$duration *= 604800;
574
+		{
575
+					$duration *= 604800;
576
+		}
528 577
 
529 578
 		// If we were really late running this task actually skip the next one.
530 579
 		if (time() + ($duration / 2) > $next_time)
531
-			$next_time += $duration;
580
+		{
581
+					$next_time += $duration;
582
+		}
532 583
 
533 584
 		// Update it now, so no others run this!
534 585
 		$db->query('', '
@@ -582,8 +633,9 @@  discard block
 block discarded – undo
582 633
 
583 634
 		$completed = $task->run();
584 635
 	}
585
-	else
586
-		$completed = run_this_task_compat($task_name);
636
+	else {
637
+			$completed = run_this_task_compat($task_name);
638
+	}
587 639
 
588 640
 	$scheduleTaskImmediate = !empty($modSettings['scheduleTaskImmediate']) ? Util::unserialize($modSettings['scheduleTaskImmediate']) : array();
589 641
 	// Log that we did it ;)
@@ -595,9 +647,12 @@  discard block
 block discarded – undo
595 647
 			$scheduleTaskImmediate[$task_name]++;
596 648
 
597 649
 			if ($scheduleTaskImmediate[$task_name] > 9)
598
-				removeScheduleTaskImmediate($task_name, false);
599
-			else
600
-				updateSettings(array('scheduleTaskImmediate' => serialize($scheduleTaskImmediate)));
650
+			{
651
+							removeScheduleTaskImmediate($task_name, false);
652
+			}
653
+			else {
654
+							updateSettings(array('scheduleTaskImmediate' => serialize($scheduleTaskImmediate)));
655
+			}
601 656
 		}
602 657
 
603 658
 		$total_time = round(microtime(true) - $time_start, 3);
@@ -673,9 +728,12 @@  discard block
 block discarded – undo
673 728
 	);
674 729
 	// No new task scheduled?
675 730
 	if ($db->num_rows($request) === 0)
676
-		$result = false;
677
-	else
678
-		list ($result) = $db->fetch_row($request);
731
+	{
732
+			$result = false;
733
+	}
734
+	else {
735
+			list ($result) = $db->fetch_row($request);
736
+	}
679 737
 
680 738
 	$db->free_result($request);
681 739
 
Please login to merge, or discard this patch.
sources/subs/Action.class.php 1 patch
Braces   +42 added lines, -18 removed lines patch added patch discarded remove patch
@@ -96,17 +96,23 @@  discard block
 block discarded – undo
96 96
 	public function initialize(&$subactions, $default = '', $requestParam = 'sa')
97 97
 	{
98 98
 		if ($this->_name !== null)
99
-			call_integration_hook('integrate_sa_' . $this->_name, array(&$subactions));
99
+		{
100
+					call_integration_hook('integrate_sa_' . $this->_name, array(&$subactions));
101
+		}
100 102
 
101 103
 		$this->_subActions = array();
102 104
 
103 105
 		if (!is_array($subactions))
104
-			$subactions = array($subactions);
106
+		{
107
+					$subactions = array($subactions);
108
+		}
105 109
 
106 110
 		$this->_subActions = $subactions;
107 111
 
108 112
 		if (isset($subactions[$default]))
109
-			$this->_default = $default;
113
+		{
114
+					$this->_default = $default;
115
+		}
110 116
 
111 117
 		return isset($_REQUEST[$requestParam]) && isset($this->_subActions[$_REQUEST[$requestParam]]) ? $_REQUEST[$requestParam] : $this->_default;
112 118
 	}
@@ -133,23 +139,31 @@  discard block
 block discarded – undo
133 139
 
134 140
 		// Unless it's disabled, then we redirect to the default action
135 141
 		if (isset($subAction['enabled']) && !$subAction['enabled'])
136
-			if (!empty($this->_default))
142
+		{
143
+					if (!empty($this->_default))
137 144
 				$subAction = $this->_subActions[$this->_default];
138
-			else
139
-				// No dice
145
+		}
146
+			else {
147
+							// No dice
140 148
 				throw new Elk_Exception('error_sa_not_set');
149
+			}
141 150
 
142 151
 		// Are you even permitted to?
143 152
 		if (isset($subAction['permission']))
144
-			isAllowedTo($subAction['permission']);
153
+		{
154
+					isAllowedTo($subAction['permission']);
155
+		}
145 156
 
146 157
 		// Is it in a file we need to load?
147 158
 		if (isset($subAction['file']))
148 159
 		{
149 160
 			if (isset($subAction['dir']))
150
-				require_once($subAction['dir'] . '/' . $subAction['file']);
151
-			else
152
-				require_once(ADMINDIR . '/' . $subAction['file']);
161
+			{
162
+							require_once($subAction['dir'] . '/' . $subAction['file']);
163
+			}
164
+			else {
165
+							require_once(ADMINDIR . '/' . $subAction['file']);
166
+			}
153 167
 
154 168
 			// A brand new controller... so be it.
155 169
 			if (isset($subAction['controller']))
@@ -173,7 +187,9 @@  discard block
 block discarded – undo
173 187
 			{
174 188
 				// An OOP controller, call it over
175 189
 				if (is_object($subAction['controller']))
176
-					$subAction['controller']->{$subAction['function']}();
190
+				{
191
+									$subAction['controller']->{$subAction['function']}();
192
+				}
177 193
 				else
178 194
 				{
179 195
 					$controller = new $subAction['controller'](new Event_Manager());
@@ -192,9 +208,12 @@  discard block
 block discarded – undo
192 208
 			{
193 209
 				// A function
194 210
 				if (isset($subAction['function']))
195
-					$subAction['function']();
196
-				else
197
-					$subAction();
211
+				{
212
+									$subAction['function']();
213
+				}
214
+				else {
215
+									$subAction();
216
+				}
198 217
 			}
199 218
 		}
200 219
 	}
@@ -220,10 +239,13 @@  discard block
 block discarded – undo
220 239
 		if (isset($subAction['enabled']) && !$subAction['enabled'])
221 240
 		{
222 241
 			if (!empty($this->_default))
223
-				$sa = $this->_default;
224
-			else
225
-				// No dice
242
+			{
243
+							$sa = $this->_default;
244
+			}
245
+			else {
246
+							// No dice
226 247
 				throw new Elk_Exception('error_sa_not_set');
248
+			}
227 249
 		}
228 250
 
229 251
 		return $sa;
@@ -249,7 +271,9 @@  discard block
 block discarded – undo
249 271
 		if (is_array($this->_subActions) && array_key_exists($sa, $this->_subActions))
250 272
 		{
251 273
 			if (isset($this->_subActions[$sa]['permission']))
252
-				isAllowedTo($this->_subActions[$sa]['permission']);
274
+			{
275
+							isAllowedTo($this->_subActions[$sa]['permission']);
276
+			}
253 277
 
254 278
 			return true;
255 279
 		}
Please login to merge, or discard this patch.
sources/subs/TopicUtil.class.php 1 patch
Braces   +15 added lines, -7 removed lines patch added patch discarded remove patch
@@ -42,7 +42,9 @@  discard block
 block discarded – undo
42 42
 		$topics = array();
43 43
 		$preview_length = (int) $preview_length;
44 44
 		if (empty($preview_length))
45
-			$preview_length = 128;
45
+		{
46
+					$preview_length = 128;
47
+		}
46 48
 
47 49
 		$messages_per_page = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages'];
48 50
 		$topicseen = $topicseen ? ';topicseen' : '';
@@ -62,7 +64,9 @@  discard block
 block discarded – undo
62 64
 
63 65
 				// No reply then they are the same, no need to process it again
64 66
 				if ($row['num_replies'] == 0)
65
-					$row['last_body'] = $row['first_body'];
67
+				{
68
+									$row['last_body'] = $row['first_body'];
69
+				}
66 70
 				else
67 71
 				{
68 72
 					$row['last_body'] = strtr($parser->parseMessage($row['last_body'], $row['last_smileys']), array('<br />' => "\n", '&nbsp;' => ' '));
@@ -92,9 +96,12 @@  discard block
 block discarded – undo
92 96
 				$row['first_subject'] = censor($row['first_subject']);
93 97
 
94 98
 				if ($row['id_first_msg'] == $row['id_last_msg'])
95
-					$row['last_subject'] = $row['first_subject'];
96
-				else
97
-					$row['last_subject'] = censor($row['last_subject']);
99
+				{
100
+									$row['last_subject'] = $row['first_subject'];
101
+				}
102
+				else {
103
+									$row['last_subject'] = censor($row['last_subject']);
104
+				}
98 105
 			}
99 106
 
100 107
 			// Decide how many pages the topic should have.
@@ -106,8 +113,9 @@  discard block
 block discarded – undo
106 113
 				$show_all = !empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages'];
107 114
 				$pages = constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d' . $topicseen, $start, $topic_length, $messages_per_page, true, array('prev_next' => false, 'all' => $show_all));
108 115
 			}
109
-			else
110
-				$pages = '';
116
+			else {
117
+							$pages = '';
118
+			}
111 119
 
112 120
 			if ($user_info['is_guest'])
113 121
 			{
Please login to merge, or discard this patch.
sources/subs/AddonSettings.subs.php 1 patch
Braces   +27 added lines, -10 removed lines patch added patch discarded remove patch
@@ -37,7 +37,9 @@  discard block
 block discarded – undo
37 37
 		foreach ($iterator as $file)
38 38
 		{
39 39
 			if ($file->isFile())
40
-				$files[] = array('dir' => $file->getPath(), 'name' => $file->getFilename());
40
+			{
41
+							$files[] = array('dir' => $file->getPath(), 'name' => $file->getFilename());
42
+			}
41 43
 		}
42 44
 	}
43 45
 	catch (UnexpectedValueException $e)
@@ -108,9 +110,12 @@  discard block
 block discarded – undo
108 110
 							$real_path = parse_path(trim($hook_name));
109 111
 
110 112
 							if ($real_path == $hook_name)
111
-								$hook_status[$hook][$hook_name]['exists'] = false;
112
-							else
113
-								$hook_status[$hook][$hook_name]['exists'] = file_exists(parse_path(ltrim($real_path, '|')));
113
+							{
114
+															$hook_status[$hook][$hook_name]['exists'] = false;
115
+							}
116
+							else {
117
+															$hook_status[$hook][$hook_name]['exists'] = file_exists(parse_path(ltrim($real_path, '|')));
118
+							}
114 119
 
115 120
 							// I need to know if there is at least one function called in this file.
116 121
 							$temp_data['include'][basename($function)] = array('hook' => $hook, 'function' => $function);
@@ -175,10 +180,14 @@  discard block
 block discarded – undo
175 180
 				// Checking all the functions within this particular file
176 181
 				// if any of them is enable then the file *must* be included and the integrate_*_include hook cannot be disabled
177 182
 				foreach ($temp_data['function'][$hook_status[$hook][$function]['in_file']] as $func)
178
-					$enabled = $enabled || strstr($func, ']') !== false;
183
+				{
184
+									$enabled = $enabled || strstr($func, ']') !== false;
185
+				}
179 186
 
180 187
 				if (!$enabled && !empty($current_hook))
181
-					$hook_status[$current_hook['hook']][$current_hook['function']]['enabled'] = true;
188
+				{
189
+									$hook_status[$current_hook['hook']][$current_hook['function']]['enabled'] = true;
190
+				}
182 191
 			}
183 192
 		}
184 193
 	}
@@ -241,9 +250,13 @@  discard block
 block discarded – undo
241 250
 	foreach ($temp_data as $data)
242 251
 	{
243 252
 		if (++$counter < $start)
244
-			continue;
253
+		{
254
+					continue;
255
+		}
245 256
 		elseif ($counter == $start + $items_per_page)
246
-			break;
257
+		{
258
+					break;
259
+		}
247 260
 
248 261
 		$hooks_data[] = $data;
249 262
 	}
@@ -270,7 +283,9 @@  discard block
 block discarded – undo
270 283
 	foreach ($hooks as $hook => $functions)
271 284
 	{
272 285
 		if (empty($filter) || ($filter == $hook))
273
-			$hooks_count += count($functions);
286
+		{
287
+					$hooks_count += count($functions);
288
+		}
274 289
 	}
275 290
 
276 291
 	return $hooks_count;
@@ -298,7 +313,9 @@  discard block
 block discarded – undo
298 313
 		foreach ($modSettings as $key => $value)
299 314
 		{
300 315
 			if (!empty($value) && substr($key, 0, 10) === 'integrate_')
301
-				$integration_hooks[$key] = explode(',', $value);
316
+			{
317
+							$integration_hooks[$key] = explode(',', $value);
318
+			}
302 319
 		}
303 320
 	}
304 321
 
Please login to merge, or discard this patch.