Passed
Push — patch_1-1-9 ( d927f0...e2616d )
by Spuds
01:06 queued 27s
created
sources/subs/Admin.subs.php 2 patches
Braces   +71 added lines, -29 removed lines patch added patch discarded remove patch
@@ -53,7 +53,9 @@  discard block
 block discarded – undo
53 53
 	{
54 54
 		$conn = $db->connection();
55 55
 		if (empty($conn))
56
-			trigger_error('getServerVersions(): you need to be connected to the database in order to get its server version', E_USER_NOTICE);
56
+		{
57
+					trigger_error('getServerVersions(): you need to be connected to the database in order to get its server version', E_USER_NOTICE);
58
+		}
57 59
 		else
58 60
 		{
59 61
 			$versions['db_server'] = array('title' => sprintf($txt['support_versions_db'], $db->db_title()), 'version' => '');
@@ -66,19 +68,25 @@  discard block
 block discarded – undo
66 68
 	foreach ($cache_engines as $name => $details)
67 69
 	{
68 70
 		if (in_array($name, $checkFor))
69
-			$versions[$name] = $details;
71
+		{
72
+					$versions[$name] = $details;
73
+		}
70 74
 	}
71 75
 
72 76
 	if (in_array('opcache', $checkFor) && extension_loaded('Zend OPcache'))
73 77
 	{
74 78
 		$opcache_config = @opcache_get_configuration();
75 79
 		if (!empty($opcache_config['directives']['opcache.enable']))
76
-			$versions['opcache'] = array('title' => $opcache_config['version']['opcache_product_name'], 'version' => $opcache_config['version']['version']);
80
+		{
81
+					$versions['opcache'] = array('title' => $opcache_config['version']['opcache_product_name'], 'version' => $opcache_config['version']['version']);
82
+		}
77 83
 	}
78 84
 
79 85
 	// PHP Version
80 86
 	if (in_array('php', $checkFor))
81
-		$versions['php'] = array('title' => 'PHP', 'version' => PHP_VERSION . ' (' . php_sapi_name() . ')', 'more' => '?action=admin;area=serversettings;sa=phpinfo');
87
+	{
88
+			$versions['php'] = array('title' => 'PHP', 'version' => PHP_VERSION . ' (' . php_sapi_name() . ')', 'more' => '?action=admin;area=serversettings;sa=phpinfo');
89
+	}
82 90
 
83 91
 	// Server info
84 92
 	if (in_array('server', $checkFor))
@@ -91,7 +99,9 @@  discard block
 block discarded – undo
91 99
 		require_once(SUBSDIR . '/Server.subs.php');
92 100
 		$loading = detectServerLoad();
93 101
 		if ($loading !== false)
94
-			$versions['server_load'] = array('title' => $txt['loadavg'], 'version' => $loading);
102
+		{
103
+					$versions['server_load'] = array('title' => $txt['loadavg'], 'version' => $loading);
104
+		}
95 105
 	}
96 106
 
97 107
 	return $versions;
@@ -127,7 +137,9 @@  discard block
 block discarded – undo
127 137
 	foreach ($quick_admin_tasks as $task)
128 138
 	{
129 139
 		if (!empty($task[0]) && !allowedTo($task[0]))
130
-			continue;
140
+		{
141
+					continue;
142
+		}
131 143
 
132 144
 		$available_admin_tasks[] = array(
133 145
 			'href' => $scripturl . '?action=admin;area=' . $task[1],
@@ -209,7 +221,9 @@  discard block
 block discarded – undo
209 221
 
210 222
 	// Find the version in SSI.php's file header.
211 223
 	if (!empty($versionOptions['include_ssi']) && file_exists(BOARDDIR . '/SSI.php'))
212
-		readFileVersions($version_info, array('file_versions' => BOARDDIR), 'SSI.php');
224
+	{
225
+			readFileVersions($version_info, array('file_versions' => BOARDDIR), 'SSI.php');
226
+	}
213 227
 
214 228
 	// Do the paid subscriptions handler?
215 229
 	if (!empty($versionOptions['include_subscriptions']))
@@ -255,7 +269,9 @@  discard block
 block discarded – undo
255 269
 	// Load all the files in the default template directory - and the current theme if applicable.
256 270
 	$directories = array('default_template_versions' => $settings['default_theme_dir']);
257 271
 	if ($settings['theme_id'] != 1)
258
-		$directories += array('template_versions' => $settings['theme_dir']);
272
+	{
273
+			$directories += array('template_versions' => $settings['theme_dir']);
274
+	}
259 275
 	readFileVersions($version_info, $directories, 'template.php');
260 276
 	readFileVersions($version_info, $directories, 'Theme.php');
261 277
 
@@ -265,7 +281,9 @@  discard block
 block discarded – undo
265 281
 	while ($path = $this_dir->read())
266 282
 	{
267 283
 		if ($path == '.' || $path == '..')
268
-			continue;
284
+		{
285
+					continue;
286
+		}
269 287
 
270 288
 		if (is_dir($lang_dir . '/' . $path))
271 289
 		{
@@ -288,10 +306,13 @@  discard block
 block discarded – undo
288 306
 
289 307
 					// Look for the version comment in the file header.
290 308
 					if (preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '(?:[\s]{2}|\*/)~i', $header, $match) == 1)
291
-						$version_info['default_language_versions'][$language][$name] = $match[1];
309
+					{
310
+											$version_info['default_language_versions'][$language][$name] = $match[1];
311
+					}
292 312
 					// It wasn't found, but the file was... show a '??'.
293
-					else
294
-						$version_info['default_language_versions'][$language][$name] = '??';
313
+					else {
314
+											$version_info['default_language_versions'][$language][$name] = '??';
315
+					}
295 316
 				}
296 317
 			}
297 318
 		}
@@ -312,7 +333,9 @@  discard block
 block discarded – undo
312 333
 
313 334
 		// For languages sort each language too.
314 335
 		foreach ($version_info['default_language_versions'] as $language => $dummy)
315
-			ksort($version_info['default_language_versions'][$language]);
336
+		{
337
+					ksort($version_info['default_language_versions'][$language]);
338
+		}
316 339
 	}
317 340
 
318 341
 	return $version_info;
@@ -377,10 +400,13 @@  discard block
 block discarded – undo
377 400
 
378 401
 				// Look for the version comment in the file header.
379 402
 				if (preg_match($version_regex, $header, $match) == 1)
380
-					$version_info[$type][$entry_key] = $match[1];
403
+				{
404
+									$version_info[$type][$entry_key] = $match[1];
405
+				}
381 406
 				// It wasn't found, but the file was... show a $unknown_version.
382
-				else
383
-					$version_info[$type][$entry_key] = $unknown_version;
407
+				else {
408
+									$version_info[$type][$entry_key] = $unknown_version;
409
+				}
384 410
 			}
385 411
 		}
386 412
 	}
@@ -417,7 +443,9 @@  discard block
 block discarded – undo
417 443
 
418 444
 	// This must exist!
419 445
 	if (!isset($context['admin_preferences']))
420
-		return false;
446
+	{
447
+			return false;
448
+	}
421 449
 
422 450
 	// This is what we'll be saving.
423 451
 	$options['admin_preferences'] = json_encode($context['admin_preferences']);
@@ -508,7 +536,9 @@  discard block
 block discarded – undo
508 536
 		foreach ($additional_recipients as $recipient)
509 537
 		{
510 538
 			if (in_array($recipient['email'], $emails_sent))
511
-				continue;
539
+			{
540
+							continue;
541
+			}
512 542
 
513 543
 			$replacements['IDMEMBER'] = $recipient['id'];
514 544
 			$replacements['REALNAME'] = $recipient['name'];
@@ -566,8 +596,10 @@  discard block
 block discarded – undo
566 596
 
567 597
 	// Should we calculate next trigger?
568 598
 	if ($value)
569
-		calculateNextTrigger('paid_subscriptions');
570
-}
599
+	{
600
+			calculateNextTrigger('paid_subscriptions');
601
+	}
602
+	}
571 603
 
572 604
 /**
573 605
  * Callback used in the core features page when the post-by-email feature
@@ -584,8 +616,10 @@  discard block
 block discarded – undo
584 616
 
585 617
 	// Should we calculate next trigger?
586 618
 	if ($value)
587
-		calculateNextTrigger('maillist_fetch_IMAP');
588
-}
619
+	{
620
+			calculateNextTrigger('maillist_fetch_IMAP');
621
+	}
622
+	}
589 623
 
590 624
 /**
591 625
  * Enables a certain module on a set of controllers
@@ -602,9 +636,12 @@  discard block
 block discarded – undo
602 636
 	foreach ((array) $controllers as $controller)
603 637
 	{
604 638
 		if (!empty($modSettings['modules_' . $controller]))
605
-			$existing = explode(',', $modSettings['modules_' . $controller]);
606
-		else
607
-			$existing = array();
639
+		{
640
+					$existing = explode(',', $modSettings['modules_' . $controller]);
641
+		}
642
+		else {
643
+					$existing = array();
644
+		}
608 645
 
609 646
 		$existing[] = $module;
610 647
 		$existing = array_filter(array_unique($existing));
@@ -627,9 +664,12 @@  discard block
 block discarded – undo
627 664
 	foreach ((array) $controllers as $controller)
628 665
 	{
629 666
 		if (!empty($modSettings['modules_' . $controller]))
630
-			$existing = explode(',', $modSettings['modules_' . $controller]);
631
-		else
632
-			$existing = array();
667
+		{
668
+					$existing = explode(',', $modSettings['modules_' . $controller]);
669
+		}
670
+		else {
671
+					$existing = array();
672
+		}
633 673
 
634 674
 		$existing = array_diff($existing, (array) $module);
635 675
 		updateSettings(array('modules_' . $controller => implode(',', $existing)));
@@ -652,7 +692,9 @@  discard block
 block discarded – undo
652 692
 		{
653 693
 			$modules = explode(',', $val);
654 694
 			if (in_array($module, $modules))
655
-				return true;
695
+			{
696
+							return true;
697
+			}
656 698
 		}
657 699
 	}
658 700
 
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 		'file_versions_subs' => SUBSDIR,
242 242
 		'file_versions_modules' => SOURCEDIR . '/modules',
243 243
 	);
244
-	$tmp_version_info = array_combine(array_keys($directories),array_fill(0,count($directories),array()));
244
+	$tmp_version_info = array_combine(array_keys($directories), array_fill(0, count($directories), array()));
245 245
 	readFileVersions($tmp_version_info, $directories, '.php', true);
246 246
 
247 247
 	foreach ($tmp_version_info['file_versions_subs'] as $key => $val)
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
 			'notify_types' => 4,
485 485
 			'group_array_implode' => implode(', additional_groups) != 0 OR FIND_IN_SET(', $groups),
486 486
 		),
487
-		function ($row) use($replacements, $modSettings, $language, $template)
487
+		function($row) use($replacements, $modSettings, $language, $template)
488 488
 		{
489 489
 			// Stick their particulars in the replacement data.
490 490
 			$replacements['IDMEMBER'] = $row['id_member'];
Please login to merge, or discard this patch.
sources/subs/Categories.subs.php 2 patches
Braces   +51 added lines, -18 removed lines patch added patch discarded remove patch
@@ -42,7 +42,9 @@  discard block
 block discarded – undo
42 42
 
43 43
 		// Setting 'move_after' to '0' moves the category to the top.
44 44
 		if ($catOptions['move_after'] == 0)
45
-			$cats[] = $category_id;
45
+		{
46
+					$cats[] = $category_id;
47
+		}
46 48
 
47 49
 		// Grab the categories sorted by cat_order.
48 50
 		$request = $db->query('', '
@@ -55,16 +57,21 @@  discard block
 block discarded – undo
55 57
 		while ($row = $db->fetch_assoc($request))
56 58
 		{
57 59
 			if ($row['id_cat'] != $category_id)
58
-				$cats[] = $row['id_cat'];
60
+			{
61
+							$cats[] = $row['id_cat'];
62
+			}
59 63
 			if ($row['id_cat'] == $catOptions['move_after'])
60
-				$cats[] = $category_id;
64
+			{
65
+							$cats[] = $category_id;
66
+			}
61 67
 			$cat_order[$row['id_cat']] = $row['cat_order'];
62 68
 		}
63 69
 		$db->free_result($request);
64 70
 
65 71
 		// Set the new order for the categories.
66 72
 		foreach ($cats as $index => $cat)
67
-			if ($index != $cat_order[$cat])
73
+		{
74
+					if ($index != $cat_order[$cat])
68 75
 				$db->query('', '
69 76
 					UPDATE {db_prefix}categories
70 77
 					SET cat_order = {int:new_order}
@@ -74,6 +81,7 @@  discard block
 block discarded – undo
74 81
 						'current_category' => $cat,
75 82
 					)
76 83
 				);
84
+		}
77 85
 
78 86
 		// If the category order changed, so did the board order.
79 87
 		require_once(SUBSDIR . '/Boards.subs.php');
@@ -111,7 +119,9 @@  discard block
 block discarded – undo
111 119
 		);
112 120
 
113 121
 		if (empty($catOptions['dont_log']))
114
-			logAction('edit_cat', array('catname' => isset($catOptions['cat_name']) ? $catOptions['cat_name'] : $category_id), 'admin');
122
+		{
123
+					logAction('edit_cat', array('catname' => isset($catOptions['cat_name']) ? $catOptions['cat_name'] : $category_id), 'admin');
124
+		}
115 125
 	}
116 126
 }
117 127
 
@@ -129,13 +139,19 @@  discard block
 block discarded – undo
129 139
 
130 140
 	// Check required values.
131 141
 	if (!isset($catOptions['cat_name']) || trim($catOptions['cat_name']) == '')
132
-		trigger_error('createCategory(): A category name is required', E_USER_ERROR);
142
+	{
143
+			trigger_error('createCategory(): A category name is required', E_USER_ERROR);
144
+	}
133 145
 
134 146
 	// Set default values.
135 147
 	if (!isset($catOptions['move_after']))
136
-		$catOptions['move_after'] = 0;
148
+	{
149
+			$catOptions['move_after'] = 0;
150
+	}
137 151
 	if (!isset($catOptions['is_collapsible']))
138
-		$catOptions['is_collapsible'] = true;
152
+	{
153
+			$catOptions['is_collapsible'] = true;
154
+	}
139 155
 	// Don't log an edit right after.
140 156
 	$catOptions['dont_log'] = true;
141 157
 
@@ -198,14 +214,18 @@  discard block
 block discarded – undo
198 214
 		$boards_inside = array_keys(fetchBoardsInfo(array('categories' => $categories)));
199 215
 
200 216
 		if (!empty($boards_inside))
201
-			deleteBoards($boards_inside, null);
217
+		{
218
+					deleteBoards($boards_inside, null);
219
+		}
202 220
 	}
203 221
 	// Make sure the safe category is really safe.
204 222
 	elseif (in_array($moveBoardsTo, $categories))
205
-		trigger_error('deleteCategories(): You cannot move the boards to a category that\'s being deleted', E_USER_ERROR);
223
+	{
224
+			trigger_error('deleteCategories(): You cannot move the boards to a category that\'s being deleted', E_USER_ERROR);
225
+	}
206 226
 	// Move the boards inside the categories to a safe category.
207
-	else
208
-		$db->query('', '
227
+	else {
228
+			$db->query('', '
209 229
 			UPDATE {db_prefix}boards
210 230
 			SET id_cat = {int:new_parent_cat}
211 231
 			WHERE id_cat IN ({array_int:category_list})',
@@ -214,6 +234,7 @@  discard block
 block discarded – undo
214 234
 				'new_parent_cat' => $moveBoardsTo,
215 235
 			)
216 236
 		);
237
+	}
217 238
 
218 239
 	// No one will ever be able to collapse these categories anymore.
219 240
 	$db->query('', '
@@ -235,7 +256,9 @@  discard block
 block discarded – undo
235 256
 
236 257
 	// Log what we've done.
237 258
 	foreach ($categories as $category)
238
-		logAction('delete_cat', array('catname' => $cat_tree[$category]['node']['name']), 'admin');
259
+	{
260
+			logAction('delete_cat', array('catname' => $cat_tree[$category]['node']['name']), 'admin');
261
+	}
239 262
 
240 263
 	// Get all boards back into the right order.
241 264
 	reorderBoards();
@@ -270,7 +293,8 @@  discard block
 block discarded – undo
270 293
 		);
271 294
 
272 295
 		if ($new_status === 'collapse')
273
-			$db->query('', '
296
+		{
297
+					$db->query('', '
274 298
 				INSERT INTO {db_prefix}collapsed_categories
275 299
 					(id_cat, id_member)
276 300
 				SELECT c.id_cat, mem.id_member
@@ -285,6 +309,7 @@  discard block
 block discarded – undo
285 309
 					'is_collapsible' => 1,
286 310
 				)
287 311
 			);
312
+		}
288 313
 	}
289 314
 
290 315
 	// Toggle the categories: collapsed get expanded and expanded get collapsed.
@@ -309,15 +334,20 @@  discard block
 block discarded – undo
309 334
 			function ($row) use (&$updates, $check_collapsable)
310 335
 			{
311 336
 				if (empty($row['is_collapsed']) && (!empty($row['can_collapse']) || !$check_collapsable))
312
-					$updates['insert'][] = array($row['id_member'], $row['id_cat']);
337
+				{
338
+									$updates['insert'][] = array($row['id_member'], $row['id_cat']);
339
+				}
313 340
 				elseif (!empty($row['is_collapsed']))
314
-					$updates['remove'][] = '(id_member = ' . $row['id_member'] . ' AND id_cat = ' . $row['id_cat'] . ')';
341
+				{
342
+									$updates['remove'][] = '(id_member = ' . $row['id_member'] . ' AND id_cat = ' . $row['id_cat'] . ')';
343
+				}
315 344
 			}
316 345
 		);
317 346
 
318 347
 		// Collapse the ones that were originally expanded...
319 348
 		if (!empty($updates['insert']))
320
-			$db->insert('replace',
349
+		{
350
+					$db->insert('replace',
321 351
 				'{db_prefix}collapsed_categories',
322 352
 				array(
323 353
 					'id_cat' => 'int', 'id_member' => 'int',
@@ -325,15 +355,18 @@  discard block
 block discarded – undo
325 355
 				$updates['insert'],
326 356
 				array('id_cat', 'id_member')
327 357
 			);
358
+		}
328 359
 
329 360
 		// And expand the ones that were originally collapsed.
330 361
 		if (!empty($updates['remove']))
331
-			$db->query('', '
362
+		{
363
+					$db->query('', '
332 364
 				DELETE FROM {db_prefix}collapsed_categories
333 365
 				WHERE ' . implode(' OR ', $updates['remove']),
334 366
 				array(
335 367
 				)
336 368
 			);
369
+		}
337 370
 	}
338 371
 }
339 372
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -306,7 +306,7 @@
 block discarded – undo
306 306
 				'category_list' => $categories,
307 307
 				'member_list' => $members,
308 308
 			),
309
-			function ($row) use (&$updates, $check_collapsable)
309
+			function($row) use (&$updates, $check_collapsable)
310 310
 			{
311 311
 				if (empty($row['is_collapsed']) && (!empty($row['can_collapse']) || !$check_collapsable))
312 312
 					$updates['insert'][] = array($row['id_member'], $row['id_cat']);
Please login to merge, or discard this patch.
sources/subs/Calendar.subs.php 1 patch
Braces   +150 added lines, -59 removed lines patch added patch discarded remove patch
@@ -65,9 +65,12 @@  discard block
 block discarded – undo
65 65
 	while ($row = $db->fetch_assoc($result))
66 66
 	{
67 67
 		if ($year_low != $year_high)
68
-			$age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low;
69
-		else
70
-			$age_year = $year_low;
68
+		{
69
+					$age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low;
70
+		}
71
+		else {
72
+					$age_year = $year_low;
73
+		}
71 74
 
72 75
 		$bday[$age_year . substr($row['birthdate'], 4)][] = array(
73 76
 			'id' => $row['id_member'],
@@ -80,7 +83,9 @@  discard block
 block discarded – undo
80 83
 
81 84
 	// Set is_last, so the themes know when to stop placing separators.
82 85
 	foreach ($bday as $mday => $array)
83
-		$bday[$mday][count($array) - 1]['is_last'] = true;
86
+	{
87
+			$bday[$mday][count($array) - 1]['is_last'] = true;
88
+	}
84 89
 
85 90
 	return $bday;
86 91
 }
@@ -137,7 +142,9 @@  discard block
 block discarded – undo
137 142
 	{
138 143
 		// If the attached topic is not approved then for the moment pretend it doesn't exist
139 144
 		if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved'])
140
-			continue;
145
+		{
146
+					continue;
147
+		}
141 148
 
142 149
 		// Force a censor of the title - as often these are used by others.
143 150
 		$row['title'] = censor($row['title'], $use_permissions ? false : true);
@@ -153,12 +160,15 @@  discard block
 block discarded – undo
153 160
 			// Attempt to avoid DST problems.
154 161
 			// @todo Resolve this properly at some point.
155 162
 			if (Util::strftime('%Y-%m-%d', $date) == $lastDate)
156
-				$date += 3601;
163
+			{
164
+							$date += 3601;
165
+			}
157 166
 			$lastDate = Util::strftime('%Y-%m-%d', $date);
158 167
 
159 168
 			// If we're using permissions (calendar pages?) then just ouput normal contextual style information.
160 169
 			if ($use_permissions)
161
-				$events[Util::strftime('%Y-%m-%d', $date)][] = array(
170
+			{
171
+							$events[Util::strftime('%Y-%m-%d', $date)][] = array(
162 172
 					'id' => $row['id_event'],
163 173
 					'title' => $row['title'],
164 174
 					'start_date' => $row['start_date'],
@@ -173,9 +183,10 @@  discard block
 block discarded – undo
173 183
 					'can_export' => !empty($modSettings['cal_export']) ? true : false,
174 184
 					'export_href' => $scripturl . '?action=calendar;sa=ical;eventid=' . $row['id_event'] . ';' . $context['session_var'] . '=' . $context['session_id'],
175 185
 				);
186
+			}
176 187
 			// Otherwise, this is going to be cached and the VIEWER'S permissions should apply... just put together some info.
177
-			else
178
-				$events[Util::strftime('%Y-%m-%d', $date)][] = array(
188
+			else {
189
+							$events[Util::strftime('%Y-%m-%d', $date)][] = array(
179 190
 					'id' => $row['id_event'],
180 191
 					'title' => $row['title'],
181 192
 					'start_date' => $row['start_date'],
@@ -192,6 +203,7 @@  discard block
 block discarded – undo
192 203
 					'poster' => $row['id_member'],
193 204
 					'allowed_groups' => explode(',', $row['member_groups']),
194 205
 				);
206
+			}
195 207
 		}
196 208
 	}
197 209
 	$db->free_result($result);
@@ -200,7 +212,9 @@  discard block
 block discarded – undo
200 212
 	if ($use_permissions)
201 213
 	{
202 214
 		foreach ($events as $mday => $array)
203
-			$events[$mday][count($array) - 1]['is_last'] = true;
215
+		{
216
+					$events[$mday][count($array) - 1]['is_last'] = true;
217
+		}
204 218
 	}
205 219
 
206 220
 	return $events;
@@ -220,10 +234,13 @@  discard block
 block discarded – undo
220 234
 
221 235
 	// Get the lowest and highest dates for "all years".
222 236
 	if (substr($low_date, 0, 4) != substr($high_date, 0, 4))
223
-		$allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec}
237
+	{
238
+			$allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec}
224 239
 			OR event_date BETWEEN {date:all_year_jan} AND {date:all_year_high}';
225
-	else
226
-		$allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}';
240
+	}
241
+	else {
242
+			$allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}';
243
+	}
227 244
 
228 245
 	// Find some holidays... ;).
229 246
 	$result = $db->query('', '
@@ -244,9 +261,12 @@  discard block
 block discarded – undo
244 261
 	while ($row = $db->fetch_assoc($result))
245 262
 	{
246 263
 		if (substr($low_date, 0, 4) != substr($high_date, 0, 4))
247
-			$event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4);
248
-		else
249
-			$event_year = substr($low_date, 0, 4);
264
+		{
265
+					$event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4);
266
+		}
267
+		else {
268
+					$event_year = substr($low_date, 0, 4);
269
+		}
250 270
 
251 271
 		$holidays[$event_year . substr($row['event_date'], 4)][] = $row['title'];
252 272
 	}
@@ -277,9 +297,13 @@  discard block
 block discarded – undo
277 297
 
278 298
 	// No board?  No topic?!?
279 299
 	if (empty($board))
280
-		throw new Elk_Exception('missing_board_id', false);
300
+	{
301
+			throw new Elk_Exception('missing_board_id', false);
302
+	}
281 303
 	if (empty($topic))
282
-		throw new Elk_Exception('missing_topic_id', false);
304
+	{
305
+			throw new Elk_Exception('missing_topic_id', false);
306
+	}
283 307
 
284 308
 	// Administrator, Moderator, or owner.  Period.
285 309
 	if (!allowedTo('admin_forum') && !allowedTo('moderate_board'))
@@ -290,11 +314,14 @@  discard block
 block discarded – undo
290 314
 		{
291 315
 			// Not the owner of the topic.
292 316
 			if ($row['id_member_started'] != $user_info['id'])
293
-				throw new Elk_Exception('not_your_topic', 'user');
317
+			{
318
+							throw new Elk_Exception('not_your_topic', 'user');
319
+			}
294 320
 		}
295 321
 		// Topic/Board doesn't exist.....
296
-		else
297
-			throw new Elk_Exception('calendar_no_topic', 'general');
322
+		else {
323
+					throw new Elk_Exception('calendar_no_topic', 'general');
324
+		}
298 325
 	}
299 326
 }
300 327
 
@@ -379,13 +406,17 @@  discard block
 block discarded – undo
379 406
 	{
380 407
 		$nShift -= $calendarOptions['start_day'];
381 408
 		if ($nShift < 0)
382
-			$nShift = 7 + $nShift;
409
+		{
410
+					$nShift = 7 + $nShift;
411
+		}
383 412
 	}
384 413
 
385 414
 	// Number of rows required to fit the month.
386 415
 	$nRows = floor(($month_info['last_day']['day_of_month'] + $nShift) / 7);
387 416
 	if (($month_info['last_day']['day_of_month'] + $nShift) % 7)
388
-		$nRows++;
417
+	{
418
+			$nRows++;
419
+	}
389 420
 
390 421
 	// Fetch the arrays for birthdays, posted events, and holidays.
391 422
 	$bday = $calendarOptions['show_birthdays'] ? getBirthdayRange($month_info['first_day']['date'], $month_info['last_day']['date']) : array();
@@ -399,7 +430,9 @@  discard block
 block discarded – undo
399 430
 		$calendarGrid['week_days'][] = $count;
400 431
 		$count++;
401 432
 		if ($count == 7)
402
-			$count = 0;
433
+		{
434
+					$count = 0;
435
+		}
403 436
 	}
404 437
 
405 438
 	// An adjustment value to apply to all calculated week numbers.
@@ -410,7 +443,9 @@  discard block
 block discarded – undo
410 443
 		// a Sunday, then there is a partial week at the start of the year
411 444
 		// that needs to be accounted for.
412 445
 		if ($calendarOptions['start_day'] === 0)
413
-			$nWeekAdjust = $month_info['first_day_of_year'] === 0 ? 0 : 1;
446
+		{
447
+					$nWeekAdjust = $month_info['first_day_of_year'] === 0 ? 0 : 1;
448
+		}
414 449
 		// If we are viewing the weeks, with a starting date other than Sunday,
415 450
 		// then things get complicated! Basically, as PHP is calculating the
416 451
 		// weeks with a Sunday starting date, we need to take this into account
@@ -418,18 +453,22 @@  discard block
 block discarded – undo
418 453
 		// year is above or below our starting date. Note that we offset by
419 454
 		// two, as some of this will get undone quite quickly by the statement
420 455
 		// below.
421
-		else
422
-			$nWeekAdjust = $calendarOptions['start_day'] > $month_info['first_day_of_year'] && $month_info['first_day_of_year'] !== 0 ? 2 : 1;
456
+		else {
457
+					$nWeekAdjust = $calendarOptions['start_day'] > $month_info['first_day_of_year'] && $month_info['first_day_of_year'] !== 0 ? 2 : 1;
458
+		}
423 459
 
424 460
 		// If our week starts on a day greater than the day the month starts
425 461
 		// on, then our week numbers will be one too high. So we need to
426 462
 		// reduce it by one - all these thoughts of offsets makes my head
427 463
 		// hurt...
428 464
 		if ($month_info['first_day']['day_of_week'] < $calendarOptions['start_day'] || $month_info['first_day_of_year'] > 4)
429
-			$nWeekAdjust--;
465
+		{
466
+					$nWeekAdjust--;
467
+		}
468
+	}
469
+	else {
470
+			$nWeekAdjust = 0;
430 471
 	}
431
-	else
432
-		$nWeekAdjust = 0;
433 472
 
434 473
 	// Iterate through each week.
435 474
 	$calendarGrid['weeks'] = array();
@@ -443,7 +482,9 @@  discard block
 block discarded – undo
443 482
 
444 483
 		// Handle the dreaded "week 53", it can happen, but only once in a blue moon ;)
445 484
 		if ($calendarGrid['weeks'][$nRow]['number'] == 53 && $nShift != 4 && $month_info['first_day_of_next_year'] < 4)
446
-			$calendarGrid['weeks'][$nRow]['number'] = 1;
485
+		{
486
+					$calendarGrid['weeks'][$nRow]['number'] = 1;
487
+		}
447 488
 
448 489
 		// And figure out all the days.
449 490
 		for ($nCol = 0; $nCol < 7; $nCol++)
@@ -451,7 +492,9 @@  discard block
 block discarded – undo
451 492
 			$nDay = ($nRow * 7) + $nCol - $nShift + 1;
452 493
 
453 494
 			if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month'])
454
-				$nDay = 0;
495
+			{
496
+							$nDay = 0;
497
+			}
455 498
 
456 499
 			$date = sprintf('%04d-%02d-%02d', $year, $month, $nDay);
457 500
 
@@ -499,7 +542,9 @@  discard block
 block discarded – undo
499 542
 		// Here we offset accordingly to get things to the real start of a week.
500 543
 		$date_diff = $day_of_week - $calendarOptions['start_day'];
501 544
 		if ($date_diff < 0)
502
-			$date_diff += 7;
545
+		{
546
+					$date_diff += 7;
547
+		}
503 548
 		$new_timestamp = mktime(0, 0, 0, $month, $day, $year) - $date_diff * 86400;
504 549
 		$day = (int) Util::strftime('%d', $new_timestamp);
505 550
 		$month = (int) Util::strftime('%m', $new_timestamp);
@@ -545,15 +590,20 @@  discard block
 block discarded – undo
545 590
 
546 591
 		// All this is as getCalendarGrid.
547 592
 		if ($calendarOptions['start_day'] === 0)
548
-			$nWeekAdjust = $first_day_of_year === 0 && $first_day_of_year > 3 ? 0 : 1;
549
-		else
550
-			$nWeekAdjust = $calendarOptions['start_day'] > $first_day_of_year && $first_day_of_year !== 0 ? 2 : 1;
593
+		{
594
+					$nWeekAdjust = $first_day_of_year === 0 && $first_day_of_year > 3 ? 0 : 1;
595
+		}
596
+		else {
597
+					$nWeekAdjust = $calendarOptions['start_day'] > $first_day_of_year && $first_day_of_year !== 0 ? 2 : 1;
598
+		}
551 599
 
552 600
 		$calendarGrid['week_number'] = (int) Util::strftime('%U', mktime(0, 0, 0, $month, $day, $year)) + $nWeekAdjust;
553 601
 
554 602
 		// If this crosses a year boundary and includes january it should be week one.
555 603
 		if ((int) Util::strftime('%Y', $curTimestamp + 518400) != $year && $calendarGrid['week_number'] > 53 && $first_day_of_next_year < 5)
556
-			$calendarGrid['week_number'] = 1;
604
+		{
605
+					$calendarGrid['week_number'] = 1;
606
+		}
557 607
 	}
558 608
 
559 609
 	// This holds all the main data - there is at least one month!
@@ -668,7 +718,9 @@  discard block
 block discarded – undo
668 718
 	for ($i = $now; $i < $now + $days_for_index; $i += 86400)
669 719
 	{
670 720
 		if (isset($cached_data['holidays'][Util::strftime('%Y-%m-%d', $i)]))
671
-			$return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][Util::strftime('%Y-%m-%d', $i)]);
721
+		{
722
+					$return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][Util::strftime('%Y-%m-%d', $i)]);
723
+		}
672 724
 	}
673 725
 
674 726
 	// Happy Birthday, guys and gals!
@@ -678,7 +730,9 @@  discard block
 block discarded – undo
678 730
 		if (isset($cached_data['birthdays'][$loop_date]))
679 731
 		{
680 732
 			foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy)
681
-				$cached_data['birthdays'][Util::strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date'];
733
+			{
734
+							$cached_data['birthdays'][Util::strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date'];
735
+			}
682 736
 			$return_data['calendar_birthdays'] = array_merge($return_data['calendar_birthdays'], $cached_data['birthdays'][$loop_date]);
683 737
 		}
684 738
 	}
@@ -691,7 +745,9 @@  discard block
 block discarded – undo
691 745
 
692 746
 		// No events today? Check the next day.
693 747
 		if (empty($cached_data['events'][$loop_date]))
694
-			continue;
748
+		{
749
+					continue;
750
+		}
695 751
 
696 752
 		// Loop through all events to add a few last-minute values.
697 753
 		foreach ($cached_data['events'][$loop_date] as $ev => $event)
@@ -705,8 +761,9 @@  discard block
 block discarded – undo
705 761
 				unset($cached_data['events'][$loop_date][$ev]);
706 762
 				continue;
707 763
 			}
708
-			else
709
-				$duplicates[$this_event['topic'] . $this_event['title']] = true;
764
+			else {
765
+							$duplicates[$this_event['topic'] . $this_event['title']] = true;
766
+			}
710 767
 
711 768
 			// Might be set to true afterwards, depending on the permissions.
712 769
 			$this_event['can_edit'] = false;
@@ -715,14 +772,20 @@  discard block
 block discarded – undo
715 772
 		}
716 773
 
717 774
 		if (!empty($cached_data['events'][$loop_date]))
718
-			$return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]);
775
+		{
776
+					$return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]);
777
+		}
719 778
 	}
720 779
 
721 780
 	// Mark the last item so that a list separator can be used in the template.
722 781
 	for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++)
723
-		$return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]);
782
+	{
783
+			$return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]);
784
+	}
724 785
 	for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++)
725
-		$return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]);
786
+	{
787
+			$return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]);
788
+	}
726 789
 
727 790
 	return array(
728 791
 		'data' => $return_data,
@@ -781,7 +844,9 @@  discard block
 block discarded – undo
781 844
 
782 845
 	// No results, return false.
783 846
 	if ($db->num_rows($request) === 0)
784
-		return false;
847
+	{
848
+			return false;
849
+	}
785 850
 
786 851
 	// Grab the results and return.
787 852
 	list ($poster) = $db->fetch_row($request);
@@ -818,11 +883,15 @@  discard block
 block discarded – undo
818 883
 	$month = '';
819 884
 	$day = '';
820 885
 	if (($num_results = sscanf($eventOptions['start_date'], '%d-%d-%d', $year, $month, $day)) !== 3)
821
-		trigger_error('insertEvent(): invalid start date format given', E_USER_ERROR);
886
+	{
887
+			trigger_error('insertEvent(): invalid start date format given', E_USER_ERROR);
888
+	}
822 889
 
823 890
 	// Set the end date (if not yet given)
824 891
 	if (!isset($eventOptions['end_date']))
825
-		$eventOptions['end_date'] = Util::strftime('%Y-%m-%d', mktime(0, 0, 0, $month, $day, $year) + $eventOptions['span'] * 86400);
892
+	{
893
+			$eventOptions['end_date'] = Util::strftime('%Y-%m-%d', mktime(0, 0, 0, $month, $day, $year) + $eventOptions['span'] * 86400);
894
+	}
826 895
 
827 896
 	// If no topic and board are given, they are not linked to a topic.
828 897
 	$eventOptions['id_board'] = isset($eventOptions['id_board']) ? (int) $eventOptions['id_board'] : 0;
@@ -878,14 +947,18 @@  discard block
 block discarded – undo
878 947
 	$month = '';
879 948
 	$day = '';
880 949
 	if (($num_results = sscanf($eventOptions['start_date'], '%d-%d-%d', $year, $month, $day)) !== 3)
881
-		trigger_error('modifyEvent(): invalid start date format given', E_USER_ERROR);
950
+	{
951
+			trigger_error('modifyEvent(): invalid start date format given', E_USER_ERROR);
952
+	}
882 953
 
883 954
 	// Default span to 0 days.
884 955
 	$eventOptions['span'] = isset($eventOptions['span']) ? (int) $eventOptions['span'] : 0;
885 956
 
886 957
 	// Set the end date to the start date + span (if the end date wasn't already given).
887 958
 	if (!isset($eventOptions['end_date']))
888
-		$eventOptions['end_date'] = Util::strftime('%Y-%m-%d', mktime(0, 0, 0, $month, $day, $year) + $eventOptions['span'] * 86400);
959
+	{
960
+			$eventOptions['end_date'] = Util::strftime('%Y-%m-%d', mktime(0, 0, 0, $month, $day, $year) + $eventOptions['span'] * 86400);
961
+	}
889 962
 
890 963
 	$event_columns = array(
891 964
 		'start_date' => 'start_date = {date:start_date}',
@@ -901,11 +974,15 @@  discard block
 block discarded – undo
901 974
 
902 975
 	$to_update = array();
903 976
 	foreach ($event_columns as $key => $value)
904
-		if (isset($eventOptions[$key]))
977
+	{
978
+			if (isset($eventOptions[$key]))
905 979
 			$to_update[] = $value;
980
+	}
906 981
 
907 982
 	if (empty($to_update))
908
-		return;
983
+	{
984
+			return;
985
+	}
909 986
 
910 987
 	$db->query('', '
911 988
 		UPDATE {db_prefix}calendar
@@ -979,13 +1056,17 @@  discard block
 block discarded – undo
979 1056
 
980 1057
 	// If nothing returned, we are in poo, poo.
981 1058
 	if ($db->num_rows($request) === 0)
982
-		return false;
1059
+	{
1060
+			return false;
1061
+	}
983 1062
 
984 1063
 	$row = $db->fetch_assoc($request);
985 1064
 	$db->free_result($request);
986 1065
 
987 1066
 	if ($calendar_only)
988
-		$return_value = $row;
1067
+	{
1068
+			$return_value = $row;
1069
+	}
989 1070
 	else
990 1071
 	{
991 1072
 		$return_value = array(
@@ -1094,7 +1175,9 @@  discard block
 block discarded – undo
1094 1175
 	$db = database();
1095 1176
 
1096 1177
 	if (!is_array($holiday_ids))
1097
-		$holiday_ids = array($holiday_ids);
1178
+	{
1179
+			$holiday_ids = array($holiday_ids);
1180
+	}
1098 1181
 
1099 1182
 	$db->query('', '
1100 1183
 		DELETE FROM {db_prefix}calendar_holidays
@@ -1185,13 +1268,15 @@  discard block
 block discarded – undo
1185 1268
 			)
1186 1269
 		);
1187 1270
 	while ($row = $db->fetch_assoc($request))
1188
-		$holiday = array(
1271
+	{
1272
+			$holiday = array(
1189 1273
 			'id' => $row['id_holiday'],
1190 1274
 			'day' => $row['day'],
1191 1275
 			'month' => $row['month'],
1192 1276
 			'year' => $row['year'] <= 4 ? 0 : $row['year'],
1193 1277
 			'title' => $row['title']
1194 1278
 		);
1279
+	}
1195 1280
 	$db->free_result($request);
1196 1281
 
1197 1282
 	return $holiday;
@@ -1219,7 +1304,9 @@  discard block
 block discarded – undo
1219 1304
 	foreach ($title as $id => $line)
1220 1305
 	{
1221 1306
 		if ($id != 0)
1222
-			$title[$id] = ' ' . $title[$id];
1307
+		{
1308
+					$title[$id] = ' ' . $title[$id];
1309
+		}
1223 1310
 		$title[$id] .= "\n";
1224 1311
 	}
1225 1312
 
@@ -1248,11 +1335,15 @@  discard block
 block discarded – undo
1248 1335
 
1249 1336
 	// more than one day
1250 1337
 	if ($event['span'] > 1)
1251
-		$filecontents .= 'DTEND;VALUE=DATE:' . $dateend . "\n";
1338
+	{
1339
+			$filecontents .= 'DTEND;VALUE=DATE:' . $dateend . "\n";
1340
+	}
1252 1341
 
1253 1342
 	// event has changed? advance the sequence for this UID
1254 1343
 	if ($event['sequence'] > 0)
1255
-		$filecontents .= 'SEQUENCE:' . $event['sequence'] . "\n";
1344
+	{
1345
+			$filecontents .= 'SEQUENCE:' . $event['sequence'] . "\n";
1346
+	}
1256 1347
 
1257 1348
 	$filecontents .= 'SUMMARY:' . implode('', $title);
1258 1349
 	$filecontents .= 'UID:' . $event['eventid'] . '@' . str_replace(' ', '-', $mbname) . "\n";
Please login to merge, or discard this patch.
sources/subs/UserNotification.class.php 1 patch
Braces   +12 added lines, -5 removed lines patch added patch discarded remove patch
@@ -141,10 +141,14 @@  discard block
 block discarded – undo
141 141
 
142 142
 		$types = array();
143 143
 		foreach ($this->_valid_types as $val)
144
-			$types[$val] = $txt['usernotif_favicon_shape_' . $val];
144
+		{
145
+					$types[$val] = $txt['usernotif_favicon_shape_' . $val];
146
+		}
145 147
 		$positions = array();
146 148
 		foreach ($this->_valid_positions as $val)
147
-			$positions[$val] = $txt['usernotif_favicon_' . $val];
149
+		{
150
+					$positions[$val] = $txt['usernotif_favicon_' . $val];
151
+		}
148 152
 
149 153
 		$config_vars = array(
150 154
 			array('title', 'usernotif_title'),
@@ -189,9 +193,12 @@  discard block
 block discarded – undo
189 193
 		{
190 194
 			$validation_errors = $validator->validation_errors($key);
191 195
 			if (empty($validation_errors))
192
-				$post[$key] = $validator->{$key};
193
-			else
194
-				$post[$key] = !empty($post[$key]) && isset($this->_modSettings[$key]) ? $this->_modSettings[$key] : '';
196
+			{
197
+							$post[$key] = $validator->{$key};
198
+			}
199
+			else {
200
+							$post[$key] = !empty($post[$key]) && isset($this->_modSettings[$key]) ? $this->_modSettings[$key] : '';
201
+			}
195 202
 		}
196 203
 
197 204
 		return $post;
Please login to merge, or discard this patch.
sources/subs/Recent.subs.php 1 patch
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -189,7 +189,9 @@  discard block
 block discarded – undo
189 189
 		);
190 190
 
191 191
 		if ($user_info['id'] == $row['first_id_member'])
192
-			$board_ids['own'][$row['id_board']][] = $row['id_msg'];
192
+		{
193
+					$board_ids['own'][$row['id_board']][] = $row['id_msg'];
194
+		}
193 195
 		$board_ids['any'][$row['id_board']][] = $row['id_msg'];
194 196
 	}
195 197
 
@@ -237,12 +239,16 @@  discard block
 block discarded – undo
237 239
 
238 240
 	// This is needed in case of topics marked unread.
239 241
 	if (empty($earliest_msg))
240
-		$earliest_msg = 0;
242
+	{
243
+			$earliest_msg = 0;
244
+	}
241 245
 	else
242 246
 	{
243 247
 		// Using caching, when possible, to ignore the below slow query.
244 248
 		if (isset($_SESSION['cached_log_time']) && $_SESSION['cached_log_time'][0] + 45 > time())
245
-			$earliest_msg2 = $_SESSION['cached_log_time'][1];
249
+		{
250
+					$earliest_msg2 = $_SESSION['cached_log_time'][1];
251
+		}
246 252
 		else
247 253
 		{
248 254
 			// This query is pretty slow, but it's needed to ensure nothing crucial is ignored.
@@ -259,7 +265,9 @@  discard block
 block discarded – undo
259 265
 
260 266
 			// In theory this could be zero, if the first ever post is unread, so fudge it ;)
261 267
 			if ($earliest_msg2 == 0)
262
-				$earliest_msg2 = -1;
268
+			{
269
+							$earliest_msg2 = -1;
270
+			}
263 271
 
264 272
 			$_SESSION['cached_log_time'] = array(time(), $earliest_msg2);
265 273
 		}
@@ -377,8 +385,10 @@  discard block
 block discarded – undo
377 385
 			'new_href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['new_from'] . '#new',
378 386
 		);
379 387
 		if ($post['new'])
380
-			$post['link'] .= '
388
+		{
389
+					$post['link'] .= '
381 390
 							<a class="new_posts" href="' . $post['new_href'] . '" id="newicon' . $row['id_msg'] . '">' . $txt['new'] . '</a>';
391
+		}
382 392
 
383 393
 		$posts[] = $post;
384 394
 	}
Please login to merge, or discard this patch.
sources/subs/ManageAttachments.subs.php 2 patches
Braces   +145 added lines, -58 removed lines patch added patch discarded remove patch
@@ -29,7 +29,9 @@  discard block
 block discarded – undo
29 29
 	$db = database();
30 30
 
31 31
 	if (empty($attachments))
32
-		return 0;
32
+	{
33
+			return 0;
34
+	}
33 35
 
34 36
 	// For safety, check for thumbnails...
35 37
 	$request = $db->query('', '
@@ -49,14 +51,18 @@  discard block
 block discarded – undo
49 51
 	{
50 52
 		// Update the thumbnail too...
51 53
 		if (!empty($row['id_thumb']))
52
-			$attachments[] = $row['id_thumb'];
54
+		{
55
+					$attachments[] = $row['id_thumb'];
56
+		}
53 57
 
54 58
 		$attachments[] = $row['id_attach'];
55 59
 	}
56 60
 	$db->free_result($request);
57 61
 
58 62
 	if (empty($attachments))
59
-		return 0;
63
+	{
64
+			return 0;
65
+	}
60 66
 
61 67
 	// Approving an attachment is not hard - it's easy.
62 68
 	$db->query('', '
@@ -144,23 +150,37 @@  discard block
 block discarded – undo
144 150
 			// @todo the !empty($restriction) is a trick to override the checks on $_POST['attach_del'] in Post.controller
145 151
 			// In theory it should not be necessary
146 152
 			if (in_array($type, array('id_member', 'id_attach', 'id_msg')) && !empty($restriction))
147
-				$new_condition[] = 'a.' . $type . ($is_not ? ' NOT' : '') . ' IN (' . (is_array($restriction) ? '{array_int:' . $real_type . '}' : '{int:' . $real_type . '}') . ')';
153
+			{
154
+							$new_condition[] = 'a.' . $type . ($is_not ? ' NOT' : '') . ' IN (' . (is_array($restriction) ? '{array_int:' . $real_type . '}' : '{int:' . $real_type . '}') . ')';
155
+			}
148 156
 			elseif ($type == 'attachment_type')
149
-				$new_condition[] = 'a.attachment_type = {int:' . $real_type . '}';
157
+			{
158
+							$new_condition[] = 'a.attachment_type = {int:' . $real_type . '}';
159
+			}
150 160
 			elseif ($type == 'poster_time')
151
-				$new_condition[] = 'm.poster_time < {int:' . $real_type . '}';
161
+			{
162
+							$new_condition[] = 'm.poster_time < {int:' . $real_type . '}';
163
+			}
152 164
 			elseif ($type == 'last_login')
153
-				$new_condition[] = 'mem.last_login < {int:' . $real_type . '}';
165
+			{
166
+							$new_condition[] = 'mem.last_login < {int:' . $real_type . '}';
167
+			}
154 168
 			elseif ($type == 'size')
155
-				$new_condition[] = 'a.size > {int:' . $real_type . '}';
169
+			{
170
+							$new_condition[] = 'a.size > {int:' . $real_type . '}';
171
+			}
156 172
 			elseif ($type == 'id_topic')
157
-				$new_condition[] = 'm.id_topic IN (' . (is_array($restriction) ? '{array_int:' . $real_type . '}' : '{int:' . $real_type . '}') . ')';
173
+			{
174
+							$new_condition[] = 'm.id_topic IN (' . (is_array($restriction) ? '{array_int:' . $real_type . '}' : '{int:' . $real_type . '}') . ')';
175
+			}
158 176
 
159 177
 			// Add the parameter!
160 178
 			$query_parameter[$real_type] = $restriction;
161 179
 
162 180
 			if ($type == 'do_logging')
163
-				$do_logging = $condition['id_attach'];
181
+			{
182
+							$do_logging = $condition['id_attach'];
183
+			}
164 184
 		}
165 185
 
166 186
 		if (empty($new_condition))
@@ -208,7 +228,9 @@  discard block
 block discarded – undo
208 228
 
209 229
 			// If this was a thumb, the parent attachment should know about it.
210 230
 			if (!empty($row['id_parent']))
211
-				$parents[] = $row['id_parent'];
231
+			{
232
+							$parents[] = $row['id_parent'];
233
+			}
212 234
 
213 235
 			// If this attachments has a thumb, remove it as well.
214 236
 			if (!empty($row['id_thumb']) && $autoThumbRemoval)
@@ -221,7 +243,9 @@  discard block
 block discarded – undo
221 243
 
222 244
 		// Make a list.
223 245
 		if ($return_affected_messages && empty($row['attachment_type']))
224
-			$msgs[] = $row['id_msg'];
246
+		{
247
+					$msgs[] = $row['id_msg'];
248
+		}
225 249
 		$attach[] = $row['id_attach'];
226 250
 	}
227 251
 	$db->free_result($request);
@@ -229,7 +253,8 @@  discard block
 block discarded – undo
229 253
 	// Removed attachments don't have to be updated anymore.
230 254
 	$parents = array_diff($parents, $attach);
231 255
 	if (!empty($parents))
232
-		$db->query('', '
256
+	{
257
+			$db->query('', '
233 258
 			UPDATE {db_prefix}attachments
234 259
 			SET id_thumb = {int:no_thumb}
235 260
 			WHERE id_attach IN ({array_int:parent_attachments})',
@@ -238,6 +263,7 @@  discard block
 block discarded – undo
238 263
 				'no_thumb' => 0,
239 264
 			)
240 265
 		);
266
+	}
241 267
 
242 268
 	if (!empty($do_logging))
243 269
 	{
@@ -266,21 +292,26 @@  discard block
 block discarded – undo
266 292
 	}
267 293
 
268 294
 	if (!empty($attach))
269
-		$db->query('', '
295
+	{
296
+			$db->query('', '
270 297
 			DELETE FROM {db_prefix}attachments
271 298
 			WHERE id_attach IN ({array_int:attachment_list})',
272 299
 			array(
273 300
 				'attachment_list' => $attach,
274 301
 			)
275 302
 		);
303
+	}
276 304
 
277 305
 	call_integration_hook('integrate_remove_attachments', array($attach));
278 306
 
279 307
 	if ($return_affected_messages)
280
-		return array_unique($msgs);
281
-	else
282
-		return true;
283
-}
308
+	{
309
+			return array_unique($msgs);
310
+	}
311
+	else {
312
+			return true;
313
+	}
314
+	}
284 315
 
285 316
 /**
286 317
  * Return an array of attachments directories.
@@ -293,18 +324,23 @@  discard block
 block discarded – undo
293 324
 	global $modSettings;
294 325
 
295 326
 	if (empty($modSettings['attachmentUploadDir']))
296
-		return array(BOARDDIR . '/attachments');
327
+	{
328
+			return array(BOARDDIR . '/attachments');
329
+	}
297 330
 	elseif (!empty($modSettings['currentAttachmentUploadDir']))
298 331
 	{
299 332
 		// we have more directories
300 333
 		if (!is_array($modSettings['attachmentUploadDir']))
301
-			$modSettings['attachmentUploadDir'] = Util::unserialize($modSettings['attachmentUploadDir']);
334
+		{
335
+					$modSettings['attachmentUploadDir'] = Util::unserialize($modSettings['attachmentUploadDir']);
336
+		}
302 337
 
303 338
 		return $modSettings['attachmentUploadDir'];
304 339
 	}
305
-	else
306
-		return array($modSettings['attachmentUploadDir']);
307
-}
340
+	else {
341
+			return array($modSettings['attachmentUploadDir']);
342
+	}
343
+	}
308 344
 
309 345
 /**
310 346
  * How many attachments we have overall.
@@ -396,11 +432,16 @@  discard block
 block discarded – undo
396 432
 	global $modSettings;
397 433
 
398 434
 	if (!empty($modSettings['currentAttachmentUploadDir']))
399
-		$attach_dirs = Util::unserialize($modSettings['attachmentUploadDir']);
435
+	{
436
+			$attach_dirs = Util::unserialize($modSettings['attachmentUploadDir']);
437
+	}
400 438
 	elseif (!empty($modSettings['attachmentUploadDir']))
401
-		$attach_dirs = array($modSettings['attachmentUploadDir']);
402
-	else
403
-		$attach_dirs = array(BOARDDIR . '/attachments');
439
+	{
440
+			$attach_dirs = array($modSettings['attachmentUploadDir']);
441
+	}
442
+	else {
443
+			$attach_dirs = array(BOARDDIR . '/attachments');
444
+	}
404 445
 
405 446
 	return $attach_dirs;
406 447
 }
@@ -707,9 +748,12 @@  discard block
 block discarded – undo
707 748
 	{
708 749
 		// Get the filename.
709 750
 		if ($row['attachment_type'] == 1)
710
-			$filename = $modSettings['custom_avatar_dir'] . '/' . $row['filename'];
711
-		else
712
-			$filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']);
751
+		{
752
+					$filename = $modSettings['custom_avatar_dir'] . '/' . $row['filename'];
753
+		}
754
+		else {
755
+					$filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']);
756
+		}
713 757
 
714 758
 		// File doesn't exist?
715 759
 		if (!file_exists($filename))
@@ -721,7 +765,9 @@  discard block
 block discarded – undo
721 765
 				$attachment_name = !empty($row['file_hash']) ? $row['id_attach'] . '_' . $row['file_hash'] . '.elk' : getLegacyAttachmentFilename($row['filename'], $row['id_attach'], null, true);
722 766
 
723 767
 				if (!is_array($modSettings['attachmentUploadDir']))
724
-					$modSettings['attachmentUploadDir'] = Util::unserialize($modSettings['attachmentUploadDir']);
768
+				{
769
+									$modSettings['attachmentUploadDir'] = Util::unserialize($modSettings['attachmentUploadDir']);
770
+				}
725 771
 
726 772
 				// Loop through the other folders looking for this file
727 773
 				foreach ($modSettings['attachmentUploadDir'] as $id => $dir)
@@ -732,7 +778,9 @@  discard block
 block discarded – undo
732 778
 
733 779
 						// Are we going to fix this now?
734 780
 						if ($fix_errors && in_array('wrong_folder', $to_fix))
735
-							attachment_folder($row['id_attach'], $id);
781
+						{
782
+													attachment_folder($row['id_attach'], $id);
783
+						}
736 784
 
737 785
 						// Found it, on to the next attachment
738 786
 						continue 2;
@@ -745,7 +793,9 @@  discard block
 block discarded – undo
745 793
 					$attachment_name = $row['id_attach'] . '_' . $row['file_hash'];
746 794
 
747 795
 					if (!is_array($modSettings['attachmentUploadDir']))
748
-						$modSettings['attachmentUploadDir'] = Util::unserialize($modSettings['attachmentUploadDir']);
796
+					{
797
+											$modSettings['attachmentUploadDir'] = Util::unserialize($modSettings['attachmentUploadDir']);
798
+					}
749 799
 
750 800
 					// Loop through the other folders looking for this file
751 801
 					foreach ($modSettings['attachmentUploadDir'] as $id => $dir)
@@ -791,14 +841,18 @@  discard block
 block discarded – undo
791 841
 
792 842
 			// Fix it here?
793 843
 			if ($fix_errors && in_array('file_wrong_size', $to_fix))
794
-				attachment_filesize($row['id_attach'], filesize($filename));
844
+			{
845
+							attachment_filesize($row['id_attach'], filesize($filename));
846
+			}
795 847
 		}
796 848
 	}
797 849
 	$db->free_result($result);
798 850
 
799 851
 	// Do we need to delete what we have?
800 852
 	if ($fix_errors && !empty($to_remove) && in_array('file_missing_on_disk', $to_fix))
801
-		removeOrphanAttachments($to_remove);
853
+	{
854
+			removeOrphanAttachments($to_remove);
855
+	}
802 856
 
803 857
 	return $repair_errors;
804 858
 }
@@ -840,9 +894,12 @@  discard block
 block discarded – undo
840 894
 			if ($fix_errors && in_array('avatar_no_member', $to_fix))
841 895
 			{
842 896
 				if ($row['attachment_type'] == 1)
843
-					$filename = $modSettings['custom_avatar_dir'] . '/' . $row['filename'];
844
-				else
845
-					$filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']);
897
+				{
898
+									$filename = $modSettings['custom_avatar_dir'] . '/' . $row['filename'];
899
+				}
900
+				else {
901
+									$filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']);
902
+				}
846 903
 				@unlink($filename);
847 904
 			}
848 905
 
@@ -1217,7 +1274,9 @@  discard block
 block discarded – undo
1217 1274
 	{
1218 1275
 		// If there aren't any attachments in this directory this won't exist.
1219 1276
 		if (!isset($expected_files[$id]))
1220
-			$expected_files[$id] = 0;
1277
+		{
1278
+					$expected_files[$id] = 0;
1279
+		}
1221 1280
 
1222 1281
 		// Check if the directory is doing okay.
1223 1282
 		list ($status, $error, $files) = attachDirStatus($dir, $expected_files[$id]);
@@ -1231,9 +1290,11 @@  discard block
 block discarded – undo
1231 1290
 
1232 1291
 			// Count any sub-folders.
1233 1292
 			foreach ($modSettings['attachmentUploadDir'] as $sid => $sub)
1234
-				if (strpos($sub, $dir . DIRECTORY_SEPARATOR) !== false)
1293
+			{
1294
+							if (strpos($sub, $dir . DIRECTORY_SEPARATOR) !== false)
1235 1295
 				{
1236 1296
 					$expected_files[$id]++;
1297
+			}
1237 1298
 					$sub_dirs++;
1238 1299
 				}
1239 1300
 		}
@@ -1252,7 +1313,8 @@  discard block
 block discarded – undo
1252 1313
 
1253 1314
 	// Just stick a new directory on at the bottom.
1254 1315
 	if (isset($_REQUEST['new_path']))
1255
-		$attachdirs[] = array(
1316
+	{
1317
+			$attachdirs[] = array(
1256 1318
 			'id' => max(array_merge(array_keys($expected_files), array_keys($modSettings['attachmentUploadDir']))) + 1,
1257 1319
 			'current' => false,
1258 1320
 			'path' => '',
@@ -1260,6 +1322,7 @@  discard block
 block discarded – undo
1260 1322
 			'num_files' => '',
1261 1323
 			'status' => '',
1262 1324
 		);
1325
+	}
1263 1326
 
1264 1327
 	return $attachdirs;
1265 1328
 }
@@ -1275,9 +1338,13 @@  discard block
 block discarded – undo
1275 1338
 function attachDirStatus($dir, $expected_files)
1276 1339
 {
1277 1340
 	if (!is_dir($dir))
1278
-		return array('does_not_exist', true, '');
1341
+	{
1342
+			return array('does_not_exist', true, '');
1343
+	}
1279 1344
 	elseif (!is_writable($dir))
1280
-		return array('not_writable', true, '');
1345
+	{
1346
+			return array('not_writable', true, '');
1347
+	}
1281 1348
 
1282 1349
 	// Count the files with a glob, easier and less time consuming
1283 1350
 	$glob = new GlobIterator($dir . '/*.elk', FilesystemIterator::SKIP_DOTS);
@@ -1291,14 +1358,19 @@  discard block
 block discarded – undo
1291 1358
 	}
1292 1359
 
1293 1360
 	if ($num_files < $expected_files)
1294
-		return array('files_missing', true, $num_files);
1361
+	{
1362
+			return array('files_missing', true, $num_files);
1363
+	}
1295 1364
 	// Empty?
1296 1365
 	elseif ($expected_files == 0)
1297
-		return array('unused', false, $num_files);
1366
+	{
1367
+			return array('unused', false, $num_files);
1368
+	}
1298 1369
 	// All good!
1299
-	else
1300
-		return array('ok', false, $num_files);
1301
-}
1370
+	else {
1371
+			return array('ok', false, $num_files);
1372
+	}
1373
+	}
1302 1374
 
1303 1375
 /**
1304 1376
  * Prepare the base directories to be displayed in a list.
@@ -1312,7 +1384,9 @@  discard block
 block discarded – undo
1312 1384
 	global $modSettings, $txt;
1313 1385
 
1314 1386
 	if (empty($modSettings['attachment_basedirectories']))
1315
-		return;
1387
+	{
1388
+			return;
1389
+	}
1316 1390
 
1317 1391
 	// Get a list of the base directories.
1318 1392
 	$basedirs = array();
@@ -1321,15 +1395,22 @@  discard block
 block discarded – undo
1321 1395
 		// Loop through the attach directory array to count any sub-directories
1322 1396
 		$expected_dirs = 0;
1323 1397
 		foreach ($modSettings['attachmentUploadDir'] as $sid => $sub)
1324
-			if (strpos($sub, $dir . DIRECTORY_SEPARATOR) !== false)
1398
+		{
1399
+					if (strpos($sub, $dir . DIRECTORY_SEPARATOR) !== false)
1325 1400
 				$expected_dirs++;
1401
+		}
1326 1402
 
1327 1403
 		if (!is_dir($dir))
1328
-			$status = 'does_not_exist';
1404
+		{
1405
+					$status = 'does_not_exist';
1406
+		}
1329 1407
 		elseif (!is_writeable($dir))
1330
-			$status = 'not_writable';
1331
-		else
1332
-			$status = 'ok';
1408
+		{
1409
+					$status = 'not_writable';
1410
+		}
1411
+		else {
1412
+					$status = 'ok';
1413
+		}
1333 1414
 
1334 1415
 		$basedirs[] = array(
1335 1416
 			'id' => $id,
@@ -1341,13 +1422,15 @@  discard block
 block discarded – undo
1341 1422
 	}
1342 1423
 
1343 1424
 	if (isset($_REQUEST['new_base_path']))
1344
-		$basedirs[] = array(
1425
+	{
1426
+			$basedirs[] = array(
1345 1427
 			'id' => '',
1346 1428
 			'current' => false,
1347 1429
 			'path' => '<input type="text" name="new_base_dir" value="" size="40" />',
1348 1430
 			'num_dirs' => '',
1349 1431
 			'status' => '',
1350 1432
 		);
1433
+	}
1351 1434
 
1352 1435
 	return $basedirs;
1353 1436
 }
@@ -1558,12 +1641,15 @@  discard block
 block discarded – undo
1558 1641
 		$filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']);
1559 1642
 
1560 1643
 		if (rename($filename, $modSettings['custom_avatar_dir'] . '/' . $row['filename']))
1561
-			$updatedAvatars[] = $row['id_attach'];
1644
+		{
1645
+					$updatedAvatars[] = $row['id_attach'];
1646
+		}
1562 1647
 	}
1563 1648
 	$db->free_result($request);
1564 1649
 
1565 1650
 	if (!empty($updatedAvatars))
1566
-		$db->query('', '
1651
+	{
1652
+			$db->query('', '
1567 1653
 			UPDATE {db_prefix}attachments
1568 1654
 			SET attachment_type = {int:attachment_type}
1569 1655
 			WHERE id_attach IN ({array_int:updated_avatars})',
@@ -1572,7 +1658,8 @@  discard block
 block discarded – undo
1572 1658
 				'attachment_type' => 1,
1573 1659
 			)
1574 1660
 		);
1575
-}
1661
+	}
1662
+	}
1576 1663
 
1577 1664
 /**
1578 1665
  * Select a group of attachments to move to a new destination
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 			'attachments' => $attachments,
81 81
 			'attachment_type' => 0,
82 82
 		),
83
-		function ($row)
83
+		function($row)
84 84
 		{
85 85
 			logAction(
86 86
 				'approve_attach',
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 				'attachments' => $do_logging,
253 253
 				'attachment_type' => 0,
254 254
 			),
255
-			function ($row)
255
+			function($row)
256 256
 			{
257 257
 				logAction(
258 258
 					'remove_attach',
@@ -643,7 +643,7 @@  discard block
 block discarded – undo
643 643
 			'no_thumb' => 0,
644 644
 			'substep' => $start,
645 645
 		),
646
-		function ($row)
646
+		function($row)
647 647
 		{
648 648
 			return $row['id_attach'];
649 649
 		}
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
 			'no_msg' => 0,
835 835
 			'substep' => $start,
836 836
 		),
837
-		function ($row) use ($fix_errors, $to_fix, $modSettings)
837
+		function($row) use ($fix_errors, $to_fix, $modSettings)
838 838
 		{
839 839
 			// If we are repairing remove the file from disk now.
840 840
 			if ($fix_errors && in_array('avatar_no_member', $to_fix))
@@ -896,7 +896,7 @@  discard block
 block discarded – undo
896 896
 			'no_msg' => 0,
897 897
 			'substep' => $start,
898 898
 		),
899
-		function ($row) use ($fix_errors, $to_fix)
899
+		function($row) use ($fix_errors, $to_fix)
900 900
 		{
901 901
 			// If we are repairing remove the file from disk now.
902 902
 			if ($fix_errors && in_array('attachment_no_msg', $to_fix))
@@ -999,7 +999,7 @@  discard block
 block discarded – undo
999 999
 			'not_approved' => 0,
1000 1000
 			'attachment_type' => 0,
1001 1001
 		),
1002
-		function ($row)
1002
+		function($row)
1003 1003
 		{
1004 1004
 			return $row['id_attach'];
1005 1005
 		}
@@ -1107,7 +1107,7 @@  discard block
 block discarded – undo
1107 1107
 			'items_per_page' => $items_per_page,
1108 1108
 			'approve_query' => $approve_query,
1109 1109
 		),
1110
-		function ($row) use ($scripturl, $bbc_parser)
1110
+		function($row) use ($scripturl, $bbc_parser)
1111 1111
 		{
1112 1112
 			return array(
1113 1113
 				'id' => $row['id_attach'],
@@ -1675,7 +1675,7 @@  discard block
 block discarded – undo
1675 1675
 			'is_approved' => 0,
1676 1676
 			'attachment_type' => 0,
1677 1677
 		),
1678
-		function ($row)
1678
+		function($row)
1679 1679
 		{
1680 1680
 			return $row['id_attach'];
1681 1681
 		}
Please login to merge, or discard this patch.
sources/subs/Server.subs.php 1 patch
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -23,7 +23,9 @@  discard block
 block discarded – undo
23 23
 function detectServerLoad()
24 24
 {
25 25
 	if (stristr(PHP_OS, 'win'))
26
-		return false;
26
+	{
27
+			return false;
28
+	}
27 29
 
28 30
 	$cores = detectServerCores();
29 31
 
@@ -39,9 +41,13 @@  discard block
 block discarded – undo
39 41
 		$load_average = @file_get_contents('/proc/loadavg');
40 42
 
41 43
 		if (!empty($load_average) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $load_average, $matches) != 0)
42
-			return (float) $matches[1] / $cores;
44
+		{
45
+					return (float) $matches[1] / $cores;
46
+		}
43 47
 		elseif (($load_average = @`uptime`) !== null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $load_average, $matches) != 0)
44
-			return (float) $matches[1] / $cores;
48
+		{
49
+					return (float) $matches[1] / $cores;
50
+		}
45 51
 
46 52
 		return false;
47 53
 	}
@@ -62,7 +68,9 @@  discard block
 block discarded – undo
62 68
 	{
63 69
 		$cores = preg_match_all('~^physical id~m', $cores, $matches);
64 70
 		if (!empty($cores))
65
-			return (int) $cores;
71
+		{
72
+					return (int) $cores;
73
+		}
66 74
 	}
67 75
 
68 76
 	return 1;
Please login to merge, or discard this patch.
sources/subs/OpenID.subs.php 1 patch
Braces   +90 added lines, -35 removed lines patch added patch discarded remove patch
@@ -53,11 +53,15 @@  discard block
 block discarded – undo
53 53
 
54 54
 		// We can't do anything without the proper response data.
55 55
 		if ($response_data === false || empty($response_data['provider']))
56
-			return 'no_data';
56
+		{
57
+					return 'no_data';
58
+		}
57 59
 
58 60
 		// Is there an existing association?
59 61
 		if (($assoc = $this->getAssociation($response_data['provider'])) === null)
60
-			$assoc = $this->makeAssociation($response_data['provider']);
62
+		{
63
+					$assoc = $this->makeAssociation($response_data['provider']);
64
+		}
61 65
 
62 66
 		// Include file for member existence
63 67
 		require_once(SUBSDIR . '/Members.subs.php');
@@ -67,7 +71,9 @@  discard block
 block discarded – undo
67 71
 
68 72
 		// Just in case they are doing something else at this time.
69 73
 		while (isset($_SESSION['openid']['saved_data'][$request_time]))
70
-			$request_time = md5($request_time);
74
+		{
75
+					$request_time = md5($request_time);
76
+		}
71 77
 
72 78
 		$_SESSION['openid']['saved_data'][$request_time] = array(
73 79
 			'get' => $_GET,
@@ -85,9 +91,12 @@  discard block
 block discarded – undo
85 91
 		{
86 92
 			$openid_identity = urlencode(empty($response_data['delegate']) ? $openid_url : $response_data['delegate']);
87 93
 			if (strpos($openid_identity, 'https') === 0)
88
-				$openid_claimedid = str_replace('http://', 'https://', $openid_url);
89
-			else
90
-				$openid_claimedid = $openid_url;
94
+			{
95
+							$openid_claimedid = str_replace('http://', 'https://', $openid_url);
96
+			}
97
+			else {
98
+							$openid_claimedid = $openid_url;
99
+			}
91 100
 		}
92 101
 
93 102
 		// Prepare parameters for the OpenID setup.
@@ -104,14 +113,19 @@  discard block
 block discarded – undo
104 113
 
105 114
 		// If they are logging in but don't yet have an account or they are registering, let's request some additional information
106 115
 		if (($_REQUEST['action'] == 'login2' && !memberExists($openid_url)) || $_REQUEST['action'] == 'register')
107
-			$parameters[] = 'openid.sreg.optional=nickname,dob';
116
+		{
117
+					$parameters[] = 'openid.sreg.optional=nickname,dob';
118
+		}
108 119
 
109 120
 		$redir_url = $response_data['server'] . '?' . implode('&', $parameters);
110 121
 
111 122
 		if ($return)
112
-			return $redir_url;
113
-		else
114
-			redirectexit($redir_url);
123
+		{
124
+					return $redir_url;
125
+		}
126
+		else {
127
+					redirectexit($redir_url);
128
+		}
115 129
 	}
116 130
 
117 131
 	/**
@@ -131,8 +145,9 @@  discard block
 block discarded – undo
131 145
 			unset($_SESSION['openid_revalidate_time']);
132 146
 			return true;
133 147
 		}
134
-		else
135
-			$this->validate($user_settings['openid_uri'], false, null, 'revalidate');
148
+		else {
149
+					$this->validate($user_settings['openid_uri'], false, null, 'revalidate');
150
+		}
136 151
 
137 152
 		// We shouldn't get here.
138 153
 		trigger_error('Hacking attempt...', E_USER_ERROR);
@@ -178,7 +193,9 @@  discard block
 block discarded – undo
178 193
 		);
179 194
 
180 195
 		if ($db->num_rows($request) == 0)
181
-			return null;
196
+		{
197
+					return null;
198
+		}
182 199
 
183 200
 		$return = $db->fetch_assoc($request);
184 201
 		$return['server_url'] = $server;
@@ -209,7 +226,9 @@  discard block
 block discarded – undo
209 226
 
210 227
 		// If we don't support DH we'll have to see if the provider will accept no encryption.
211 228
 		if ($dh_keys === false)
212
-			$parameters[] = 'openid.session_type=';
229
+		{
230
+					$parameters[] = 'openid.session_type=';
231
+		}
213 232
 		else
214 233
 		{
215 234
 			$parameters[] = 'openid.session_type=DH-SHA1';
@@ -226,10 +245,14 @@  discard block
 block discarded – undo
226 245
 		$assoc_data = array();
227 246
 
228 247
 		foreach ($matches[1] as $key => $match)
229
-			$assoc_data[$match] = $matches[2][$key];
248
+		{
249
+					$assoc_data[$match] = $matches[2][$key];
250
+		}
230 251
 
231 252
 		if (!isset($assoc_data['assoc_type']) || (empty($assoc_data['mac_key']) && empty($assoc_data['enc_mac_key'])))
232
-			throw new Elk_Exception('openid_server_bad_response');
253
+		{
254
+					throw new Elk_Exception('openid_server_bad_response');
255
+		}
233 256
 
234 257
 		// Clean things up a bit.
235 258
 		$handle = isset($assoc_data['assoc_handle']) ? $assoc_data['assoc_handle'] : '';
@@ -239,8 +262,10 @@  discard block
 block discarded – undo
239 262
 
240 263
 		// @todo Is this really needed?
241 264
 		foreach (array('dh_server_public', 'enc_mac_key') as $key)
242
-			if (isset($assoc_data[$key]))
265
+		{
266
+					if (isset($assoc_data[$key]))
243 267
 				$assoc_data[$key] = str_replace(' ', '+', $assoc_data[$key]);
268
+		}
244 269
 
245 270
 		// Figure out the Diffie-Hellman secret.
246 271
 		if (!empty($assoc_data['enc_mac_key']))
@@ -248,8 +273,9 @@  discard block
 block discarded – undo
248 273
 			$dh_secret = bcpowmod(binary_to_long(base64_decode($assoc_data['dh_server_public'])), $dh_keys['private'], $this->p);
249 274
 			$secret = base64_encode(binary_xor(sha1(long_to_binary($dh_secret), true), base64_decode($assoc_data['enc_mac_key'])));
250 275
 		}
251
-		else
252
-			$secret = $assoc_data['mac_key'];
276
+		else {
277
+					$secret = $assoc_data['mac_key'];
278
+		}
253 279
 
254 280
 		// Store the data
255 281
 		$db->insert('replace',
@@ -300,7 +326,9 @@  discard block
 block discarded – undo
300 326
 
301 327
 		// Strip http:// and https:// and if there is no / in what is left, add one
302 328
 		if (strpos(strtr($uri, array('http://' => '', 'https://' => '')), '/') === false)
303
-			$uri .= '/';
329
+		{
330
+					$uri .= '/';
331
+		}
304 332
 
305 333
 		return $uri;
306 334
 	}
@@ -316,7 +344,9 @@  discard block
 block discarded – undo
316 344
 	{
317 345
 		// First off, do we have BC Math available?
318 346
 		if (!function_exists('bcpow'))
319
-			return false;
347
+		{
348
+					return false;
349
+		}
320 350
 
321 351
 		// Make sure the scale is set.
322 352
 		bcscale(0);
@@ -375,7 +405,9 @@  discard block
 block discarded – undo
375 405
 		$byte_string = long_to_binary($this->p);
376 406
 
377 407
 		if (isset($cache[$byte_string]))
378
-			list ($dup, $num_bytes) = $cache[$byte_string];
408
+		{
409
+					list ($dup, $num_bytes) = $cache[$byte_string];
410
+		}
379 411
 		else
380 412
 		{
381 413
 			$num_bytes = strlen($byte_string) - ($byte_string[0] == "\x00" ? 1 : 0);
@@ -391,7 +423,9 @@  discard block
 block discarded – undo
391 423
 		{
392 424
 			$str = '';
393 425
 			for ($i = 0; $i < $num_bytes; $i += 4)
394
-				$str .= pack('L', mt_rand());
426
+			{
427
+							$str .= pack('L', mt_rand());
428
+			}
395 429
 
396 430
 			$bytes = "\x00" . $str;
397 431
 
@@ -417,7 +451,9 @@  discard block
 block discarded – undo
417 451
 		$webdata = fetch_web_data($openid_url);
418 452
 
419 453
 		if (empty($webdata))
420
-			return false;
454
+		{
455
+					return false;
456
+		}
421 457
 
422 458
 		$response_data = array();
423 459
 
@@ -432,23 +468,32 @@  discard block
 block discarded – undo
432 468
 
433 469
 		// Some OpenID servers have strange but still valid HTML which makes our job hard.
434 470
 		if (preg_match_all('~<link([\s\S]*?)/?>~i', $webdata, $link_matches) == 0)
435
-			throw new Elk_Exception('openid_server_bad_response');
471
+		{
472
+					throw new Elk_Exception('openid_server_bad_response');
473
+		}
436 474
 
437 475
 		foreach ($link_matches[1] as $link_match)
438 476
 		{
439 477
 			if (preg_match('~rel="([\s\S]*?)"~i', $link_match, $rel_match) == 0 || preg_match('~href="([\s\S]*?)"~i', $link_match, $href_match) == 0)
440
-				continue;
478
+			{
479
+							continue;
480
+			}
441 481
 
442 482
 			$rels = preg_split('~\s+~', $rel_match[1]);
443 483
 			foreach ($rels as $rel)
444
-				if (preg_match('~openid2?\.(server|delegate|provider)~i', $rel, $match) != 0)
484
+			{
485
+							if (preg_match('~openid2?\.(server|delegate|provider)~i', $rel, $match) != 0)
445 486
 					$response_data[$match[1]] = $href_match[1];
487
+			}
446 488
 		}
447 489
 
448 490
 		if (empty($response_data['provider']))
449
-			$response_data['server'] = $openid_url;
450
-		else
451
-			$response_data['server'] = $response_data['provider'];
491
+		{
492
+					$response_data['server'] = $openid_url;
493
+		}
494
+		else {
495
+					$response_data['server'] = $response_data['provider'];
496
+		}
452 497
 
453 498
 		return $response_data;
454 499
 	}
@@ -491,10 +536,14 @@  discard block
 block discarded – undo
491 536
 {
492 537
 	$cmp = bccomp($value, 0);
493 538
 	if ($cmp < 0)
494
-		throw new Elk_Exception('Only non-negative integers allowed.');
539
+	{
540
+			throw new Elk_Exception('Only non-negative integers allowed.');
541
+	}
495 542
 
496 543
 	if ($cmp == 0)
497
-		return "\x00";
544
+	{
545
+			return "\x00";
546
+	}
498 547
 
499 548
 	$bytes = array();
500 549
 
@@ -505,11 +554,15 @@  discard block
 block discarded – undo
505 554
 	}
506 555
 
507 556
 	if (!empty($bytes) && ($bytes[0] > 127))
508
-		array_unshift($bytes, 0);
557
+	{
558
+			array_unshift($bytes, 0);
559
+	}
509 560
 
510 561
 	$return = '';
511 562
 	foreach ($bytes as $byte)
512
-		$return .= pack('C', $byte);
563
+	{
564
+			$return .= pack('C', $byte);
565
+	}
513 566
 
514 567
 	return $return;
515 568
 }
@@ -530,7 +583,9 @@  discard block
 block discarded – undo
530 583
 
531 584
 	$str_len = strlen($num2);
532 585
 	for ($i = 0; $i < $str_len; $i++)
533
-		$return .= $num1[$i] ^ $num2[$i];
586
+	{
587
+			$return .= $num1[$i] ^ $num2[$i];
588
+	}
534 589
 
535 590
 	return $return;
536 591
 }
Please login to merge, or discard this patch.
sources/subs/SearchEngines.subs.php 1 patch
Braces   +86 added lines, -33 removed lines patch added patch discarded remove patch
@@ -28,7 +28,9 @@  discard block
 block discarded – undo
28 28
 	$db = database();
29 29
 
30 30
 	if (isset($_SESSION['id_robot']))
31
-		unset($_SESSION['id_robot']);
31
+	{
32
+			unset($_SESSION['id_robot']);
33
+	}
32 34
 
33 35
 	$_SESSION['robot_check'] = time();
34 36
 
@@ -45,7 +47,9 @@  discard block
 block discarded – undo
45 47
 			)
46 48
 		);
47 49
 		while ($row = $db->fetch_assoc($request))
48
-			$spider_data[] = $row;
50
+		{
51
+					$spider_data[] = $row;
52
+		}
49 53
 		$db->free_result($request);
50 54
 
51 55
 		// Save it in the cache
@@ -53,23 +57,30 @@  discard block
 block discarded – undo
53 57
 	}
54 58
 
55 59
 	if (empty($spider_data))
56
-		return false;
60
+	{
61
+			return false;
62
+	}
57 63
 
58 64
 	// We need the user agent
59 65
 	$req = request();
60 66
 
61 67
 	// Always attempt IPv6 first.
62 68
 	if (strpos($_SERVER['REMOTE_ADDR'], ':') !== false)
63
-		$ip_parts = convertIPv6toInts($_SERVER['REMOTE_ADDR']);
69
+	{
70
+			$ip_parts = convertIPv6toInts($_SERVER['REMOTE_ADDR']);
71
+	}
64 72
 	// Then xxx.xxx.xxx.xxx next
65
-	else
66
-		preg_match('/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/', $_SERVER['REMOTE_ADDR'], $ip_parts);
73
+	else {
74
+			preg_match('/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/', $_SERVER['REMOTE_ADDR'], $ip_parts);
75
+	}
67 76
 
68 77
 	foreach ($spider_data as $spider)
69 78
 	{
70 79
 		// User agent is easy.
71 80
 		if (!empty($spider['user_agent']) && strpos(strtolower($req->user_agent()), strtolower($spider['user_agent'])) !== false)
72
-			$_SESSION['id_robot'] = $spider['id_spider'];
81
+		{
82
+					$_SESSION['id_robot'] = $spider['id_spider'];
83
+		}
73 84
 		// IP stuff is harder.
74 85
 		elseif (!empty($ip_parts))
75 86
 		{
@@ -82,21 +93,29 @@  discard block
 block discarded – undo
82 93
 					foreach ($ip as $key => $value)
83 94
 					{
84 95
 						if ($value['low'] > $ip_parts[$key + 1] || $value['high'] < $ip_parts[$key + 1])
85
-							break;
96
+						{
97
+													break;
98
+						}
86 99
 						elseif (($key == 7 && strpos($_SERVER['REMOTE_ADDR'], ':') !== false) || ($key == 3 && strpos($_SERVER['REMOTE_ADDR'], ':') === false))
87
-							$_SESSION['id_robot'] = $spider['id_spider'];
100
+						{
101
+													$_SESSION['id_robot'] = $spider['id_spider'];
102
+						}
88 103
 					}
89 104
 				}
90 105
 			}
91 106
 		}
92 107
 
93 108
 		if (isset($_SESSION['id_robot']))
94
-			break;
109
+		{
110
+					break;
111
+		}
95 112
 	}
96 113
 
97 114
 	// If this is low server tracking then log the spider here as opposed to the main logging function.
98 115
 	if (!empty($modSettings['spider_mode']) && $modSettings['spider_mode'] == 1 && !empty($_SESSION['id_robot']))
99
-		logSpider();
116
+	{
117
+			logSpider();
118
+	}
100 119
 
101 120
 	return !empty($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0;
102 121
 }
@@ -113,7 +132,9 @@  discard block
 block discarded – undo
113 132
 	$db = database();
114 133
 
115 134
 	if (empty($modSettings['spider_mode']) || empty($_SESSION['id_robot']))
116
-		return;
135
+	{
136
+			return;
137
+	}
117 138
 
118 139
 	// Attempt to update today's entry.
119 140
 	if ($modSettings['spider_mode'] == 1)
@@ -152,13 +173,17 @@  discard block
 block discarded – undo
152 173
 		{
153 174
 			$url = $_GET;
154 175
 			if (isset($context['session_var']))
155
-				unset($url['sesc'], $url[$context['session_var']]);
156
-			else
157
-				unset($url['sesc']);
176
+			{
177
+							unset($url['sesc'], $url[$context['session_var']]);
178
+			}
179
+			else {
180
+							unset($url['sesc']);
181
+			}
158 182
 			$url = serialize($url);
159 183
 		}
160
-		else
161
-			$url = '';
184
+		else {
185
+					$url = '';
186
+		}
162 187
 
163 188
 		$db->insert('insert',
164 189
 			'{db_prefix}log_spider_hits',
@@ -189,11 +214,15 @@  discard block
 block discarded – undo
189 214
 	);
190 215
 	$spider_hits = array();
191 216
 	while ($row = $db->fetch_assoc($request))
192
-		$spider_hits[] = $row;
217
+	{
218
+			$spider_hits[] = $row;
219
+	}
193 220
 	$db->free_result($request);
194 221
 
195 222
 	if (empty($spider_hits))
196
-		return;
223
+	{
224
+			return;
225
+	}
197 226
 
198 227
 	// Attempt to update the master data.
199 228
 	$stat_inserts = array();
@@ -214,17 +243,21 @@  discard block
 block discarded – undo
214 243
 			)
215 244
 		);
216 245
 		if ($db->affected_rows() == 0)
217
-			$stat_inserts[] = array($date, $stat['id_spider'], $stat['num_hits'], $stat['last_seen']);
246
+		{
247
+					$stat_inserts[] = array($date, $stat['id_spider'], $stat['num_hits'], $stat['last_seen']);
248
+		}
218 249
 	}
219 250
 
220 251
 	// New stats?
221 252
 	if (!empty($stat_inserts))
222
-		$db->insert('ignore',
253
+	{
254
+			$db->insert('ignore',
223 255
 			'{db_prefix}log_spider_stats',
224 256
 			array('stat_date' => 'date', 'id_spider' => 'int', 'page_hits' => 'int', 'last_seen' => 'int'),
225 257
 			$stat_inserts,
226 258
 			array('stat_date', 'id_spider')
227 259
 		);
260
+	}
228 261
 
229 262
 	// All processed.
230 263
 	$db->query('', '
@@ -255,7 +288,9 @@  discard block
 block discarded – undo
255 288
 	);
256 289
 	$spiders = array();
257 290
 	while ($row = $db->fetch_assoc($request))
258
-		$spiders[$row['id_spider']] = $row['spider_name'];
291
+	{
292
+			$spiders[$row['id_spider']] = $row['spider_name'];
293
+	}
259 294
 	$db->free_result($request);
260 295
 
261 296
 	updateSettings(array('spider_name_cache' => serialize($spiders)));
@@ -306,7 +341,9 @@  discard block
 block discarded – undo
306 341
 	);
307 342
 	$spiders = array();
308 343
 	while ($row = $db->fetch_assoc($request))
309
-		$spiders[$row['id_spider']] = $row;
344
+	{
345
+			$spiders[$row['id_spider']] = $row;
346
+	}
310 347
 	$db->free_result($request);
311 348
 
312 349
 	return $spiders;
@@ -386,7 +423,9 @@  discard block
 block discarded – undo
386 423
 	);
387 424
 	$spider_logs = array();
388 425
 	while ($row = $db->fetch_assoc($request))
389
-		$spider_logs[] = $row;
426
+	{
427
+			$spider_logs[] = $row;
428
+	}
390 429
 	$db->free_result($request);
391 430
 
392 431
 	return $spider_logs;
@@ -440,7 +479,9 @@  discard block
 block discarded – undo
440 479
 	);
441 480
 	$spider_stats = array();
442 481
 	while ($row = $db->fetch_assoc($request))
443
-		$spider_stats[] = $row;
482
+	{
483
+			$spider_stats[] = $row;
484
+	}
444 485
 	$db->free_result($request);
445 486
 
446 487
 	return $spider_stats;
@@ -564,7 +605,9 @@  discard block
 block discarded – undo
564 605
 
565 606
 	$spider_last_seen = array();
566 607
 	while ($row = $db->fetch_assoc($request))
567
-		$spider_last_seen[$row['id_spider']] = $row['last_seen_time'];
608
+	{
609
+			$spider_last_seen[$row['id_spider']] = $row['last_seen_time'];
610
+	}
568 611
 	$db->free_result($request);
569 612
 
570 613
 	return $spider_last_seen;
@@ -600,13 +643,20 @@  discard block
 block discarded – undo
600 643
 	// Prepare the dates for the drop down.
601 644
 	$date_choices = array();
602 645
 	for ($y = $min_year; $y <= $max_year; $y++)
603
-		for ($m = 1; $m <= 12; $m++)
646
+	{
647
+			for ($m = 1;
648
+	}
649
+	$m <= 12; $m++)
604 650
 		{
605 651
 			// This doesn't count?
606 652
 			if ($y == $min_year && $m < $min_month)
607
-				continue;
653
+			{
654
+							continue;
655
+			}
608 656
 			if ($y == $max_year && $m > $max_month)
609
-				break;
657
+			{
658
+							break;
659
+			}
610 660
 
611 661
 			$date_choices[$y . $m] = $txt['months_short'][$m] . ' ' . $y;
612 662
 		}
@@ -629,7 +679,8 @@  discard block
 block discarded – undo
629 679
 
630 680
 	// New spider, insert
631 681
 	if (empty($id))
632
-		$db->insert('insert',
682
+	{
683
+			$db->insert('insert',
633 684
 			'{db_prefix}spiders',
634 685
 			array(
635 686
 				'spider_name' => 'string', 'user_agent' => 'string', 'ip_info' => 'string',
@@ -639,9 +690,10 @@  discard block
 block discarded – undo
639 690
 			),
640 691
 			array('id_spider')
641 692
 		);
693
+	}
642 694
 	// Existing spider update
643
-	else
644
-		$db->query('', '
695
+	else {
696
+			$db->query('', '
645 697
 			UPDATE {db_prefix}spiders
646 698
 			SET spider_name = {string:spider_name}, user_agent = {string:spider_agent},
647 699
 				ip_info = {string:ip_info}
@@ -653,4 +705,5 @@  discard block
 block discarded – undo
653 705
 				'ip_info' => $info_ip,
654 706
 			)
655 707
 		);
656
-}
657 708
\ No newline at end of file
709
+	}
710
+	}
658 711
\ No newline at end of file
Please login to merge, or discard this patch.