Passed
Push — patch_1-1-9 ( d927f0...e2616d )
by Spuds
01:06 queued 27s
created
sources/database/Db-abstract.class.php 1 patch
Braces   +72 added lines, -26 removed lines patch added patch discarded remove patch
@@ -84,22 +84,34 @@  discard block
 block discarded – undo
84 84
 
85 85
 		// Connection gone???  This should *never* happen at this point, yet it does :'(
86 86
 		if (!$this->validConnection($this->_db_callback_connection))
87
-			Errors::instance()->display_db_error();
87
+		{
88
+					Errors::instance()->display_db_error();
89
+		}
88 90
 
89 91
 		if ($matches[1] === 'db_prefix')
90
-			return $db_prefix;
92
+		{
93
+					return $db_prefix;
94
+		}
91 95
 
92 96
 		if ($matches[1] === 'query_see_board')
93
-			return $user_info['query_see_board'];
97
+		{
98
+					return $user_info['query_see_board'];
99
+		}
94 100
 
95 101
 		if ($matches[1] === 'query_wanna_see_board')
96
-			return $user_info['query_wanna_see_board'];
102
+		{
103
+					return $user_info['query_wanna_see_board'];
104
+		}
97 105
 
98 106
 		if (!isset($matches[2]))
99
-			$this->error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__);
107
+		{
108
+					$this->error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__);
109
+		}
100 110
 
101 111
 		if (!isset($this->_db_callback_values[$matches[2]]))
102
-			$this->error_backtrace('The database value you\'re trying to insert does not exist: ' . htmlspecialchars($matches[2], ENT_COMPAT, 'UTF-8'), '', E_USER_ERROR, __FILE__, __LINE__);
112
+		{
113
+					$this->error_backtrace('The database value you\'re trying to insert does not exist: ' . htmlspecialchars($matches[2], ENT_COMPAT, 'UTF-8'), '', E_USER_ERROR, __FILE__, __LINE__);
114
+		}
103 115
 
104 116
 		$replacement = $this->_db_callback_values[$matches[2]];
105 117
 
@@ -174,7 +186,9 @@  discard block
 block discarded – undo
174 186
 
175 187
 		$results = $seeds !== null ? $seeds : array();
176 188
 		while ($row = $this->fetch_assoc($request))
177
-			$results[] = $row;
189
+		{
190
+					$results[] = $row;
191
+		}
178 192
 		$this->free_result($request);
179 193
 
180 194
 		return $results;
@@ -186,13 +200,17 @@  discard block
 block discarded – undo
186 200
 	public function fetchQueryCallback($db_string, $db_values = array(), $callback = '', $seeds = null)
187 201
 	{
188 202
 		if ($callback === '')
189
-			return $this->fetchQuery($db_string, $db_values);
203
+		{
204
+					return $this->fetchQuery($db_string, $db_values);
205
+		}
190 206
 
191 207
 		$request = $this->query('', $db_string, $db_values);
192 208
 
193 209
 		$results = $seeds !== null ? $seeds : array();
194 210
 		while ($row = $this->fetch_assoc($request))
195
-			$results[] = $callback($row);
211
+		{
212
+					$results[] = $callback($row);
213
+		}
196 214
 		$this->free_result($request);
197 215
 
198 216
 		return $results;
@@ -210,14 +228,18 @@  discard block
 block discarded – undo
210 228
 		$is_numeric = array_filter(array_keys($values), 'is_numeric');
211 229
 
212 230
 		if (!empty($is_numeric))
213
-			return array_combine($keys, $values);
231
+		{
232
+					return array_combine($keys, $values);
233
+		}
214 234
 		else
215 235
 		{
216 236
 			$combined = array();
217 237
 			foreach ($keys as $key)
218 238
 			{
219 239
 				if (isset($values[$key]))
220
-					$combined[$key] = $values[$key];
240
+				{
241
+									$combined[$key] = $values[$key];
242
+				}
221 243
 			}
222 244
 
223 245
 			// @todo should throw an E_WARNING if count($combined) != count($keys)
@@ -236,7 +258,9 @@  discard block
 block discarded – undo
236 258
 	protected function _replaceInt($identifier, $replacement)
237 259
 	{
238 260
 		if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement)
239
-			$this->error_backtrace('Wrong value type sent to the database. Integer expected. (' . $identifier . ')', '', E_USER_ERROR, __FILE__, __LINE__);
261
+		{
262
+					$this->error_backtrace('Wrong value type sent to the database. Integer expected. (' . $identifier . ')', '', E_USER_ERROR, __FILE__, __LINE__);
263
+		}
240 264
 		return (string) (int) $replacement;
241 265
 	}
242 266
 
@@ -253,12 +277,16 @@  discard block
 block discarded – undo
253 277
 			if (is_array($replacement))
254 278
 			{
255 279
 				if (empty($replacement))
256
-					$this->error_backtrace('Database error, given array of integer values is empty. (' . $identifier . ')', '', E_USER_ERROR, __FILE__, __LINE__);
280
+				{
281
+									$this->error_backtrace('Database error, given array of integer values is empty. (' . $identifier . ')', '', E_USER_ERROR, __FILE__, __LINE__);
282
+				}
257 283
 
258 284
 				foreach ($replacement as $key => $value)
259 285
 				{
260 286
 					if (!is_numeric($value) || (string) $value !== (string) (int) $value)
261
-						$this->error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $identifier . ')', '', E_USER_ERROR, __FILE__, __LINE__);
287
+					{
288
+											$this->error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $identifier . ')', '', E_USER_ERROR, __FILE__, __LINE__);
289
+					}
262 290
 
263 291
 					$replacement[$key] = (string) (int) $value;
264 292
 				}
@@ -295,10 +323,14 @@  discard block
 block discarded – undo
295 323
 		if (is_array($replacement))
296 324
 		{
297 325
 			if (empty($replacement))
298
-				$this->error_backtrace('Database error, given array of string values is empty. (' . $identifier . ')', '', E_USER_ERROR, __FILE__, __LINE__);
326
+			{
327
+							$this->error_backtrace('Database error, given array of string values is empty. (' . $identifier . ')', '', E_USER_ERROR, __FILE__, __LINE__);
328
+			}
299 329
 
300 330
 			foreach ($replacement as $key => $value)
301
-				$replacement[$key] = sprintf('\'%1$s\'', $this->escape_string($value));
331
+			{
332
+							$replacement[$key] = sprintf('\'%1$s\'', $this->escape_string($value));
333
+			}
302 334
 
303 335
 			return implode(', ', $replacement);
304 336
 		}
@@ -319,9 +351,12 @@  discard block
 block discarded – undo
319 351
 	protected function _replaceDate($identifier, $replacement)
320 352
 	{
321 353
 		if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1)
322
-			return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]);
323
-		else
324
-			$this->error_backtrace('Wrong value type sent to the database. Date expected. (' . $identifier . ')', '', E_USER_ERROR, __FILE__, __LINE__);
354
+		{
355
+					return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]);
356
+		}
357
+		else {
358
+					$this->error_backtrace('Wrong value type sent to the database. Date expected. (' . $identifier . ')', '', E_USER_ERROR, __FILE__, __LINE__);
359
+		}
325 360
 	}
326 361
 
327 362
 	/**
@@ -335,7 +370,9 @@  discard block
 block discarded – undo
335 370
 	protected function _replaceFloat($identifier, $replacement)
336 371
 	{
337 372
 		if (!is_numeric($replacement))
338
-			$this->error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $identifier . ')', '', E_USER_ERROR, __FILE__, __LINE__);
373
+		{
374
+					$this->error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $identifier . ')', '', E_USER_ERROR, __FILE__, __LINE__);
375
+		}
339 376
 		return (string) (float) $replacement;
340 377
 	}
341 378
 
@@ -371,7 +408,9 @@  discard block
 block discarded – undo
371 408
 	public function error_backtrace($error_message, $log_message = '', $error_type = false, $file = null, $line = null)
372 409
 	{
373 410
 		if (empty($log_message))
374
-			$log_message = $error_message;
411
+		{
412
+					$log_message = $error_message;
413
+		}
375 414
 
376 415
 		foreach (debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) as $step)
377 416
 		{
@@ -391,7 +430,9 @@  discard block
 block discarded – undo
391 430
 
392 431
 		// A special case - we want the file and line numbers for debugging.
393 432
 		if ($error_type === 'return')
394
-			return array($file, $line);
433
+		{
434
+					return array($file, $line);
435
+		}
395 436
 
396 437
 		// Is always a critical error.
397 438
 		if (class_exists('Errors'))
@@ -404,9 +445,12 @@  discard block
 block discarded – undo
404 445
 			throw new Elk_Exception($error_message, false);
405 446
 		}
406 447
 		elseif ($error_type)
407
-			trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type);
408
-		else
409
-			trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''));
448
+		{
449
+					trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type);
450
+		}
451
+		else {
452
+					trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''));
453
+		}
410 454
 
411 455
 		return array('', '');
412 456
 	}
@@ -426,9 +470,11 @@  discard block
 block discarded – undo
426 470
 		);
427 471
 
428 472
 		if ($translate_human_wildcards)
429
-			$replacements += array(
473
+		{
474
+					$replacements += array(
430 475
 				'*' => '%',
431 476
 			);
477
+		}
432 478
 
433 479
 		return strtr($string, $replacements);
434 480
 	}
Please login to merge, or discard this patch.
sources/database/DbTable-mysql.php 1 patch
Braces   +111 added lines, -44 removed lines patch added patch discarded remove patch
@@ -51,7 +51,9 @@  discard block
 block discarded – undo
51 51
 			'themes', 'topics');
52 52
 
53 53
 		foreach ($this->_reservedTables as $k => $table_name)
54
-			$this->_reservedTables[$k] = strtolower($db_prefix . $table_name);
54
+		{
55
+					$this->_reservedTables[$k] = strtolower($db_prefix . $table_name);
56
+		}
55 57
 
56 58
 		// let's be sure.
57 59
 		$this->_package_log = array();
@@ -104,7 +106,9 @@  discard block
 block discarded – undo
104 106
 
105 107
 		// First - no way do we touch our tables.
106 108
 		if (in_array(strtolower($table_name), $this->_reservedTables))
107
-			return false;
109
+		{
110
+					return false;
111
+		}
108 112
 
109 113
 		// Log that we'll want to remove this on uninstall.
110 114
 		$this->_package_log[] = array('remove_table', $table_name);
@@ -114,15 +118,20 @@  discard block
 block discarded – undo
114 118
 		{
115 119
 			// This is a sad day... drop the table? If not, return false (error) by default.
116 120
 			if ($if_exists == 'overwrite')
117
-				$this->db_drop_table($table_name);
118
-			else
119
-				return $if_exists == 'ignore';
121
+			{
122
+							$this->db_drop_table($table_name);
123
+			}
124
+			else {
125
+							return $if_exists == 'ignore';
126
+			}
120 127
 		}
121 128
 
122 129
 		// Righty - let's do the damn thing!
123 130
 		$table_query = 'CREATE TABLE ' . $table_name . "\n" . '(';
124 131
 		foreach ($columns as $column)
125
-			$table_query .= "\n\t" . $this->_db_create_query_column($column) . ',';
132
+		{
133
+					$table_query .= "\n\t" . $this->_db_create_query_column($column) . ',';
134
+		}
126 135
 
127 136
 		// Loop through the indexes next...
128 137
 		foreach ($indexes as $index)
@@ -131,18 +140,24 @@  discard block
 block discarded – undo
131 140
 
132 141
 			// Is it the primary?
133 142
 			if (isset($index['type']) && $index['type'] == 'primary')
134
-				$table_query .= "\n\t" . 'PRIMARY KEY (' . $columns . '),';
143
+			{
144
+							$table_query .= "\n\t" . 'PRIMARY KEY (' . $columns . '),';
145
+			}
135 146
 			else
136 147
 			{
137 148
 				if (empty($index['name']))
138
-					$index['name'] = implode('_', $index['columns']);
149
+				{
150
+									$index['name'] = implode('_', $index['columns']);
151
+				}
139 152
 				$table_query .= "\n\t" . (isset($index['type']) && $index['type'] == 'unique' ? 'UNIQUE' : 'KEY') . ' ' . $index['name'] . ' (' . $columns . '),';
140 153
 			}
141 154
 		}
142 155
 
143 156
 		// No trailing commas!
144 157
 		if (substr($table_query, -1) == ',')
145
-			$table_query = substr($table_query, 0, -1);
158
+		{
159
+					$table_query = substr($table_query, 0, -1);
160
+		}
146 161
 
147 162
 		$table_query .= ') DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci';
148 163
 
@@ -176,7 +191,9 @@  discard block
 block discarded – undo
176 191
 
177 192
 		// God no - dropping one of these = bad.
178 193
 		if (in_array(strtolower($table_name), $this->_reservedTables))
179
-			return false;
194
+		{
195
+					return false;
196
+		}
180 197
 
181 198
 		// Does it exist?
182 199
 		if ($this->table_exists($full_table_name))
@@ -219,9 +236,12 @@  discard block
 block discarded – undo
219 236
 		{
220 237
 			// If we're going to overwrite then use change column.
221 238
 			if ($if_exists == 'update')
222
-				return $this->db_change_column($table_name, $column_info['name'], $column_info);
223
-			else
224
-				return false;
239
+			{
240
+							return $this->db_change_column($table_name, $column_info['name'], $column_info);
241
+			}
242
+			else {
243
+							return false;
244
+			}
225 245
 		}
226 246
 
227 247
 		// Now add the thing!
@@ -279,23 +299,39 @@  discard block
 block discarded – undo
279 299
 
280 300
 		// Nothing?
281 301
 		if ($old_info === false)
282
-			return false;
302
+		{
303
+					return false;
304
+		}
283 305
 
284 306
 		// Get the right bits.
285 307
 		if (!isset($column_info['name']))
286
-			$column_info['name'] = $old_column;
308
+		{
309
+					$column_info['name'] = $old_column;
310
+		}
287 311
 		if (!isset($column_info['default']))
288
-			$column_info['default'] = $old_info['default'];
312
+		{
313
+					$column_info['default'] = $old_info['default'];
314
+		}
289 315
 		if (!isset($column_info['null']))
290
-			$column_info['null'] = $old_info['null'];
316
+		{
317
+					$column_info['null'] = $old_info['null'];
318
+		}
291 319
 		if (!isset($column_info['auto']))
292
-			$column_info['auto'] = $old_info['auto'];
320
+		{
321
+					$column_info['auto'] = $old_info['auto'];
322
+		}
293 323
 		if (!isset($column_info['type']))
294
-			$column_info['type'] = $old_info['type'];
324
+		{
325
+					$column_info['type'] = $old_info['type'];
326
+		}
295 327
 		if (!isset($column_info['size']) || !is_numeric($column_info['size']))
296
-			$column_info['size'] = $old_info['size'];
328
+		{
329
+					$column_info['size'] = $old_info['size'];
330
+		}
297 331
 		if (!isset($column_info['unsigned']) || !in_array($column_info['type'], array('int', 'tinyint', 'smallint', 'mediumint', 'bigint')))
298
-			$column_info['unsigned'] = '';
332
+		{
333
+					$column_info['unsigned'] = '';
334
+		}
299 335
 
300 336
 		$this->_alter_table($table_name, '
301 337
 			CHANGE COLUMN `' . $old_column . '` ' . $this->_db_create_query_column($column_info));
@@ -318,7 +354,9 @@  discard block
 block discarded – undo
318 354
 
319 355
 		// No columns = no index.
320 356
 		if (empty($index_info['columns']))
321
-			return false;
357
+		{
358
+					return false;
359
+		}
322 360
 		$columns = implode(',', $index_info['columns']);
323 361
 
324 362
 		// No name - make it up!
@@ -326,9 +364,12 @@  discard block
 block discarded – undo
326 364
 		{
327 365
 			// No need for primary.
328 366
 			if (isset($index_info['type']) && $index_info['type'] == 'primary')
329
-				$index_info['name'] = '';
330
-			else
331
-				$index_info['name'] = implode('_', $index_info['columns']);
367
+			{
368
+							$index_info['name'] = '';
369
+			}
370
+			else {
371
+							$index_info['name'] = implode('_', $index_info['columns']);
372
+			}
332 373
 		}
333 374
 
334 375
 		// Log that we are going to want to remove this!
@@ -344,9 +385,12 @@  discard block
 block discarded – undo
344 385
 			{
345 386
 				// If we want to overwrite simply remove the current one then continue.
346 387
 				if ($if_exists != 'update' || $index['type'] == 'primary')
347
-					return false;
348
-				else
349
-					$this->db_remove_index($table_name, $index_info['name']);
388
+				{
389
+									return false;
390
+				}
391
+				else {
392
+									$this->db_remove_index($table_name, $index_info['name']);
393
+				}
350 394
 			}
351 395
 		}
352 396
 
@@ -477,7 +521,9 @@  discard block
 block discarded – undo
477 521
 					$type = $matches[1];
478 522
 					$size = $matches[2];
479 523
 					if (!empty($matches[3]) && $matches[3] == 'unsigned')
480
-						$unsigned = true;
524
+					{
525
+											$unsigned = true;
526
+					}
481 527
 				}
482 528
 				else
483 529
 				{
@@ -531,18 +577,27 @@  discard block
 block discarded – undo
531 577
 		while ($row = $this->_db->fetch_assoc($result))
532 578
 		{
533 579
 			if (!$detail)
534
-				$indexes[] = $row['Key_name'];
580
+			{
581
+							$indexes[] = $row['Key_name'];
582
+			}
535 583
 			else
536 584
 			{
537 585
 				// What is the type?
538 586
 				if ($row['Key_name'] == 'PRIMARY')
539
-					$type = 'primary';
587
+				{
588
+									$type = 'primary';
589
+				}
540 590
 				elseif (empty($row['Non_unique']))
541
-					$type = 'unique';
591
+				{
592
+									$type = 'unique';
593
+				}
542 594
 				elseif (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT')
543
-					$type = 'fulltext';
544
-				else
545
-					$type = 'index';
595
+				{
596
+									$type = 'fulltext';
597
+				}
598
+				else {
599
+									$type = 'index';
600
+				}
546 601
 
547 602
 				// This is the first column we've seen?
548 603
 				if (empty($indexes[$row['Key_name']]))
@@ -556,9 +611,12 @@  discard block
 block discarded – undo
556 611
 
557 612
 				// Is it a partial index?
558 613
 				if (!empty($row['Sub_part']))
559
-					$indexes[$row['Key_name']]['columns'][] = $row['Column_name'] . '(' . $row['Sub_part'] . ')';
560
-				else
561
-					$indexes[$row['Key_name']]['columns'][] = $row['Column_name'];
614
+				{
615
+									$indexes[$row['Key_name']]['columns'][] = $row['Column_name'] . '(' . $row['Sub_part'] . ')';
616
+				}
617
+				else {
618
+									$indexes[$row['Key_name']]['columns'][] = $row['Column_name'];
619
+				}
562 620
 			}
563 621
 		}
564 622
 		$this->_db->free_result($result);
@@ -579,9 +637,12 @@  discard block
 block discarded – undo
579 637
 			$default = 'auto_increment';
580 638
 		}
581 639
 		elseif (isset($column['default']) && $column['default'] !== null)
582
-			$default = 'default \'' . $this->_db->escape_string($column['default']) . '\'';
583
-		else
584
-			$default = '';
640
+		{
641
+					$default = 'default \'' . $this->_db->escape_string($column['default']) . '\'';
642
+		}
643
+		else {
644
+					$default = '';
645
+		}
585 646
 
586 647
 		// Sort out the size... and stuff...
587 648
 		$column['size'] = isset($column['size']) && is_numeric($column['size']) ? $column['size'] : null;
@@ -591,7 +652,9 @@  discard block
 block discarded – undo
591 652
 		$unsigned = in_array($type, array('int', 'tinyint', 'smallint', 'mediumint', 'bigint', 'float')) && !empty($column['unsigned']) ? 'unsigned ' : '';
592 653
 
593 654
 		if ($size !== null)
594
-			$type = $type . '(' . $size . ')';
655
+		{
656
+					$type = $type . '(' . $size . ')';
657
+		}
595 658
 
596 659
 		// Now just put it together!
597 660
 		return '`' . $column['name'] . '` ' . $type . ' ' . (!empty($unsigned) ? $unsigned : '') . (!empty($column['null']) ? '' : 'NOT NULL') . ' ' . $default;
@@ -631,7 +694,9 @@  discard block
 block discarded – undo
631 694
 				)
632 695
 			);
633 696
 			if (!$request)
634
-				return -1;
697
+			{
698
+							return -1;
699
+			}
635 700
 
636 701
 			// How much left?
637 702
 			$request = $this->_db->query('', '
@@ -670,7 +735,9 @@  discard block
 block discarded – undo
670 735
 	public static function db_table($db)
671 736
 	{
672 737
 		if (is_null(self::$_tbl))
673
-			self::$_tbl = new DbTable_MySQL($db);
738
+		{
739
+					self::$_tbl = new DbTable_MySQL($db);
740
+		}
674 741
 		return self::$_tbl;
675 742
 	}
676 743
 }
677 744
\ No newline at end of file
Please login to merge, or discard this patch.
sources/database/DbTable-postgresql.php 1 patch
Braces   +126 added lines, -52 removed lines patch added patch discarded remove patch
@@ -51,7 +51,9 @@  discard block
 block discarded – undo
51 51
 			'themes', 'topics');
52 52
 
53 53
 		foreach ($this->_reservedTables as $k => $table_name)
54
-			$this->_reservedTables[$k] = strtolower($db_prefix . $table_name);
54
+		{
55
+					$this->_reservedTables[$k] = strtolower($db_prefix . $table_name);
56
+		}
55 57
 
56 58
 		// let's be sure.
57 59
 		$this->_package_log = array();
@@ -104,7 +106,9 @@  discard block
 block discarded – undo
104 106
 
105 107
 		// First - no way do we touch our tables.
106 108
 		if (in_array(strtolower($table_name), $this->_reservedTables))
107
-			return false;
109
+		{
110
+					return false;
111
+		}
108 112
 
109 113
 		// Log that we'll want to remove this on uninstall.
110 114
 		$this->_package_log[] = array('remove_table', $table_name);
@@ -114,9 +118,12 @@  discard block
 block discarded – undo
114 118
 		{
115 119
 			// This is a sad day... drop the table? If not, return false (error) by default.
116 120
 			if ($if_exists == 'overwrite')
117
-				$this->db_drop_table($table_name);
118
-			else
119
-				return $if_exists == 'ignore';
121
+			{
122
+							$this->db_drop_table($table_name);
123
+			}
124
+			else {
125
+							return $if_exists == 'ignore';
126
+			}
120 127
 		}
121 128
 
122 129
 		// If we've got this far - good news - no table exists. We can build our own!
@@ -136,15 +143,20 @@  discard block
 block discarded – undo
136 143
 				$default = 'default nextval(\'' . $table_name . '_seq\')';
137 144
 			}
138 145
 			elseif (isset($column['default']) && $column['default'] !== null)
139
-				$default = 'default \'' . $this->_db->escape_string($column['default']) . '\'';
140
-			else
141
-				$default = '';
146
+			{
147
+							$default = 'default \'' . $this->_db->escape_string($column['default']) . '\'';
148
+			}
149
+			else {
150
+							$default = '';
151
+			}
142 152
 
143 153
 			// Sort out the size...
144 154
 			$column['size'] = isset($column['size']) && is_numeric($column['size']) ? $column['size'] : null;
145 155
 			list ($type, $size) = $this->db_calculate_type($column['type'], $column['size']);
146 156
 			if ($size !== null)
147
-				$type = $type . '(' . $size . ')';
157
+			{
158
+							$type = $type . '(' . $size . ')';
159
+			}
148 160
 
149 161
 			// Now just put it together!
150 162
 			$table_query .= "\n\t\"" . $column['name'] . '" ' . $type . ' ' . (!empty($column['null']) ? '' : 'NOT NULL') . ' ' . $default . ',';
@@ -156,25 +168,33 @@  discard block
 block discarded – undo
156 168
 		{
157 169
 			// MySQL supports a length argument, postgre no
158 170
 			foreach ($index['columns'] as $id => $col)
159
-				if (strpos($col, '(') !== false)
171
+			{
172
+							if (strpos($col, '(') !== false)
160 173
 					$index['columns'][$id] = substr($col, 0, strpos($col, '('));
174
+			}
161 175
 
162 176
 			$columns = implode(',', $index['columns']);
163 177
 
164 178
 			// Primary goes in the table...
165 179
 			if (isset($index['type']) && $index['type'] == 'primary')
166
-				$table_query .= "\n\t" . 'PRIMARY KEY (' . $columns . '),';
180
+			{
181
+							$table_query .= "\n\t" . 'PRIMARY KEY (' . $columns . '),';
182
+			}
167 183
 			else
168 184
 			{
169 185
 				if (empty($index['name']))
170
-					$index['name'] = implode('_', $index['columns']);
186
+				{
187
+									$index['name'] = implode('_', $index['columns']);
188
+				}
171 189
 				$index_queries[] = 'CREATE ' . (isset($index['type']) && $index['type'] == 'unique' ? 'UNIQUE' : '') . ' INDEX ' . $table_name . '_' . $index['name'] . ' ON ' . $table_name . ' (' . $columns . ')';
172 190
 			}
173 191
 		}
174 192
 
175 193
 		// No trailing commas!
176 194
 		if (substr($table_query, -1) == ',')
177
-			$table_query = substr($table_query, 0, -1);
195
+		{
196
+					$table_query = substr($table_query, 0, -1);
197
+		}
178 198
 
179 199
 		$table_query .= ')';
180 200
 
@@ -220,7 +240,9 @@  discard block
 block discarded – undo
220 240
 
221 241
 		// God no - dropping one of these = bad.
222 242
 		if (in_array(strtolower($table_name), $this->_reservedTables))
223
-			return false;
243
+		{
244
+					return false;
245
+		}
224 246
 
225 247
 		// Does it exist?
226 248
 		if ($this->table_exists($full_table_name))
@@ -280,16 +302,21 @@  discard block
 block discarded – undo
280 302
 		{
281 303
 			// If we're going to overwrite then use change column.
282 304
 			if ($if_exists == 'update')
283
-				return $this->db_change_column($table_name, $column_info['name'], $column_info);
284
-			else
285
-				return false;
305
+			{
306
+							return $this->db_change_column($table_name, $column_info['name'], $column_info);
307
+			}
308
+			else {
309
+							return false;
310
+			}
286 311
 		}
287 312
 
288 313
 		// Get the specifics...
289 314
 		$column_info['size'] = isset($column_info['size']) && is_numeric($column_info['size']) ? $column_info['size'] : null;
290 315
 		list ($type, $size) = $this->db_calculate_type($column_info['type'], $column_info['size']);
291 316
 		if ($size !== null)
292
-			$type = $type . '(' . $size . ')';
317
+		{
318
+					$type = $type . '(' . $size . ')';
319
+		}
293 320
 
294 321
 		// Now add the thing!
295 322
 		$this->_alter_table($table_name, '
@@ -299,9 +326,12 @@  discard block
 block discarded – undo
299 326
 		unset($column_info['type'], $column_info['size']);
300 327
 
301 328
 		if (count($column_info) != 1)
302
-			return $this->db_change_column($table_name, $column_info['name'], $column_info);
303
-		else
304
-			return true;
329
+		{
330
+					return $this->db_change_column($table_name, $column_info['name'], $column_info);
331
+		}
332
+		else {
333
+					return true;
334
+		}
305 335
 	}
306 336
 
307 337
 	/**
@@ -324,12 +354,14 @@  discard block
 block discarded – undo
324 354
 		{
325 355
 			// If there is an auto we need remove it!
326 356
 			if ($column['auto'])
327
-				$this->_db->query('',
357
+			{
358
+							$this->_db->query('',
328 359
 					'DROP SEQUENCE ' . $table_name . '_seq',
329 360
 					array(
330 361
 						'security_override' => true,
331 362
 					)
332 363
 				);
364
+			}
333 365
 
334 366
 			$this->_alter_table($table_name, '
335 367
 				DROP COLUMN ' . $column_name);
@@ -361,7 +393,9 @@  discard block
 block discarded – undo
361 393
 
362 394
 		// Nothing?
363 395
 		if ($old_info === false)
364
-			return false;
396
+		{
397
+					return false;
398
+		}
365 399
 
366 400
 		// Now we check each bit individually and ALTER as required.
367 401
 		if (isset($column_info['name']) && $column_info['name'] != $old_column)
@@ -407,7 +441,9 @@  discard block
 block discarded – undo
407 441
 			$column_info['size'] = isset($column_info['size']) && is_numeric($column_info['size']) ? $column_info['size'] : null;
408 442
 			list ($type, $size) = $this->db_calculate_type($column_info['type'], $column_info['size']);
409 443
 			if ($size !== null)
410
-				$type = $type . '(' . $size . ')';
444
+			{
445
+							$type = $type . '(' . $size . ')';
446
+			}
411 447
 
412 448
 			// The alter is a pain.
413 449
 			$this->_db->db_transaction('begin');
@@ -475,12 +511,16 @@  discard block
 block discarded – undo
475 511
 
476 512
 		// No columns = no index.
477 513
 		if (empty($index_info['columns']))
478
-			return false;
514
+		{
515
+					return false;
516
+		}
479 517
 
480 518
 		// MySQL supports a length argument, postgre no
481 519
 		foreach ($index_info['columns'] as $id => $col)
482
-			if (strpos($col, '(') !== false)
520
+		{
521
+					if (strpos($col, '(') !== false)
483 522
 				$index_info['columns'][$id] = substr($col, 0, strpos($col, '('));
523
+		}
484 524
 
485 525
 		$columns = implode(',', $index_info['columns']);
486 526
 
@@ -489,12 +529,16 @@  discard block
 block discarded – undo
489 529
 		{
490 530
 			// No need for primary.
491 531
 			if (isset($index_info['type']) && $index_info['type'] == 'primary')
492
-				$index_info['name'] = '';
493
-			else
494
-				$index_info['name'] = $table_name . implode('_', $index_info['columns']);
532
+			{
533
+							$index_info['name'] = '';
534
+			}
535
+			else {
536
+							$index_info['name'] = $table_name . implode('_', $index_info['columns']);
537
+			}
538
+		}
539
+		else {
540
+					$index_info['name'] = $table_name . $index_info['name'];
495 541
 		}
496
-		else
497
-			$index_info['name'] = $table_name . $index_info['name'];
498 542
 
499 543
 		// Log that we are going to want to remove this!
500 544
 		$this->_package_log[] = array('remove_index', $table_name, $index_info['name']);
@@ -509,9 +553,12 @@  discard block
 block discarded – undo
509 553
 			{
510 554
 				// If we want to overwrite simply remove the current one then continue.
511 555
 				if ($if_exists != 'update' || $index['type'] == 'primary')
512
-					return false;
513
-				else
514
-					$this->db_remove_index($table_name, $index_info['name']);
556
+				{
557
+									return false;
558
+				}
559
+				else {
560
+									$this->db_remove_index($table_name, $index_info['name']);
561
+				}
515 562
 			}
516 563
 		}
517 564
 
@@ -549,7 +596,9 @@  discard block
 block discarded – undo
549 596
 		// Better exist!
550 597
 		$indexes = $this->db_list_indexes($table_name, true);
551 598
 		if ($index_name != 'primary')
552
-			$index_name = $table_name . '_' . $index_name;
599
+		{
600
+					$index_name = $table_name . '_' . $index_name;
601
+		}
553 602
 
554 603
 		foreach ($indexes as $index)
555 604
 		{
@@ -619,13 +668,17 @@  discard block
 block discarded – undo
619 668
 		if (isset($types[$type_name]))
620 669
 		{
621 670
 			if ($type_name == 'tinytext')
622
-				$type_size = 255;
671
+			{
672
+							$type_size = 255;
673
+			}
623 674
 			$type_name = $types[$type_name];
624 675
 		}
625 676
 
626 677
 		// Numbers don't have a size.
627 678
 		if (strpos($type_name, 'int') !== false)
628
-				$type_size = null;
679
+		{
680
+						$type_size = null;
681
+		}
629 682
 
630 683
 		return array($type_name, $type_size);
631 684
 	}
@@ -690,9 +743,12 @@  discard block
 block discarded – undo
690 743
 					$auto = true;
691 744
 				}
692 745
 				elseif (trim($row['column_default']) != '')
693
-					$default = strpos($row['column_default'], '::') === false ? $row['column_default'] : substr($row['column_default'], 0, strpos($row['column_default'], '::'));
694
-				else
695
-					$default = null;
746
+				{
747
+									$default = strpos($row['column_default'], '::') === false ? $row['column_default'] : substr($row['column_default'], 0, strpos($row['column_default'], '::'));
748
+				}
749
+				else {
750
+									$default = null;
751
+				}
696 752
 
697 753
 				// Make the type generic.
698 754
 				list ($type, $size) = $this->db_calculate_type($row['data_type'], $row['character_maximum_length'], true);
@@ -744,24 +800,35 @@  discard block
 block discarded – undo
744 800
 		{
745 801
 			// Try get the columns that make it up.
746 802
 			if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0)
747
-				continue;
803
+			{
804
+							continue;
805
+			}
748 806
 
749 807
 			$columns = explode(',', $matches[1]);
750 808
 
751 809
 			if (empty($columns))
752
-				continue;
810
+			{
811
+							continue;
812
+			}
753 813
 
754 814
 			foreach ($columns as $k => $v)
755
-				$columns[$k] = trim($v);
815
+			{
816
+							$columns[$k] = trim($v);
817
+			}
756 818
 
757 819
 			// Fix up the name to be consistent cross databases
758 820
 			if (substr($row['name'], -5) == '_pkey' && $row['is_primary'] == 1)
759
-				$row['name'] = 'PRIMARY';
760
-			else
761
-				$row['name'] = str_replace($table_name . '_', '', $row['name']);
821
+			{
822
+							$row['name'] = 'PRIMARY';
823
+			}
824
+			else {
825
+							$row['name'] = str_replace($table_name . '_', '', $row['name']);
826
+			}
762 827
 
763 828
 			if (!$detail)
764
-				$indexes[] = $row['name'];
829
+			{
830
+							$indexes[] = $row['name'];
831
+			}
765 832
 			else
766 833
 			{
767 834
 				$indexes[$row['name']] = array(
@@ -796,15 +863,20 @@  discard block
 block discarded – undo
796 863
 			)
797 864
 		);
798 865
 		if (!$request)
799
-			return -1;
866
+		{
867
+					return -1;
868
+		}
800 869
 
801 870
 		$row = $this->_db->fetch_assoc($request);
802 871
 		$this->_db->free_result($request);
803 872
 
804 873
 		if (isset($row['Data_free']))
805
-			return $row['Data_free'] / 1024;
806
-		else
807
-			return 0;
874
+		{
875
+					return $row['Data_free'] / 1024;
876
+		}
877
+		else {
878
+					return 0;
879
+		}
808 880
 	}
809 881
 
810 882
 	/**
@@ -823,7 +895,9 @@  discard block
 block discarded – undo
823 895
 	public static function db_table($db)
824 896
 	{
825 897
 		if (is_null(self::$_tbl))
826
-			self::$_tbl = new DbTable_PostgreSQL($db);
898
+		{
899
+					self::$_tbl = new DbTable_PostgreSQL($db);
900
+		}
827 901
 		return self::$_tbl;
828 902
 	}
829 903
 }
830 904
\ No newline at end of file
Please login to merge, or discard this patch.
sources/database/Database.subs.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -61,7 +61,9 @@
 block discarded – undo
61 61
 function db_table($db = null)
62 62
 {
63 63
 	if ($db === null)
64
-		$db = database();
64
+	{
65
+			$db = database();
66
+	}
65 67
 
66 68
 	require_once(SOURCEDIR . '/database/DbTable.class.php');
67 69
 	require_once(SOURCEDIR . '/database/DbTable-' . strtolower(DB_TYPE) . '.php');
Please login to merge, or discard this patch.
sources/database/DbSearch-mysql.php 1 patch
Braces   +21 added lines, -10 removed lines patch added patch discarded remove patch
@@ -63,7 +63,8 @@  discard block
 block discarded – undo
63 63
 		$table_info = array();
64 64
 
65 65
 		if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0)
66
-			$request = $db->query('', '
66
+		{
67
+					$request = $db->query('', '
67 68
 				SHOW TABLE STATUS
68 69
 				FROM {string:database_name}
69 70
 				LIKE {string:table_name}',
@@ -72,14 +73,16 @@  discard block
 block discarded – undo
72 73
 					'table_name' => str_replace('_', '\_', $match[2]) . 'messages',
73 74
 				)
74 75
 			);
75
-		else
76
-			$request = $db->query('', '
76
+		}
77
+		else {
78
+					$request = $db->query('', '
77 79
 				SHOW TABLE STATUS
78 80
 				LIKE {string:table_name}',
79 81
 				array(
80 82
 					'table_name' => str_replace('_', '\_', $db_prefix) . 'messages',
81 83
 				)
82 84
 			);
85
+		}
83 86
 
84 87
 		if ($request !== false && $db->num_rows($request) == 1)
85 88
 		{
@@ -93,7 +96,8 @@  discard block
 block discarded – undo
93 96
 
94 97
 		// Now check the custom index table, if it exists at all.
95 98
 		if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0)
96
-			$request = $db->query('', '
99
+		{
100
+					$request = $db->query('', '
97 101
 				SHOW TABLE STATUS
98 102
 				FROM {string:database_name}
99 103
 				LIKE {string:table_name}',
@@ -102,14 +106,16 @@  discard block
 block discarded – undo
102 106
 					'table_name' => str_replace('_', '\_', $match[2]) . 'log_search_words',
103 107
 				)
104 108
 			);
105
-		else
106
-			$request = $db->query('', '
109
+		}
110
+		else {
111
+					$request = $db->query('', '
107 112
 				SHOW TABLE STATUS
108 113
 				LIKE {string:table_name}',
109 114
 				array(
110 115
 					'table_name' => str_replace('_', '\_', $db_prefix) . 'log_search_words',
111 116
 				)
112 117
 			);
118
+		}
113 119
 
114 120
 		if ($request !== false && $db->num_rows($request) == 1)
115 121
 		{
@@ -133,11 +139,16 @@  discard block
 block discarded – undo
133 139
 		$db = database();
134 140
 
135 141
 		if ($size == 'small')
136
-			$size = 'smallint(5)';
142
+		{
143
+					$size = 'smallint(5)';
144
+		}
137 145
 		elseif ($size == 'medium')
138
-			$size = 'mediumint(8)';
139
-		else
140
-			$size = 'int(10)';
146
+		{
147
+					$size = 'mediumint(8)';
148
+		}
149
+		else {
150
+					$size = 'int(10)';
151
+		}
141 152
 
142 153
 		$db->query('', '
143 154
 			CREATE TABLE {db_prefix}log_search_words (
Please login to merge, or discard this patch.
sources/DumpDatabase.php 1 patch
Braces   +24 added lines, -9 removed lines patch added patch discarded remove patch
@@ -39,7 +39,9 @@  discard block
 block discarded – undo
39 39
 
40 40
 	// You can't dump nothing!
41 41
 	if (!isset($_REQUEST['struct']) && !isset($_REQUEST['data']))
42
-		$_REQUEST['data'] = true;
42
+	{
43
+			$_REQUEST['data'] = true;
44
+	}
43 45
 
44 46
 	// Attempt to stop from dying...
45 47
 	detectServer()->setTimeLimit(600);
@@ -72,10 +74,14 @@  discard block
 block discarded – undo
72 74
 	{
73 75
 		// Get rid of the gzipping already being done.
74 76
 		if (!empty($modSettings['enableCompressedOutput']))
75
-			@ob_end_clean();
77
+		{
78
+					@ob_end_clean();
79
+		}
76 80
 		// If we can, clean anything already sent from the output buffer...
77 81
 		elseif (ob_get_length() != 0)
78
-			ob_clean();
82
+		{
83
+					ob_clean();
84
+		}
79 85
 
80 86
 		// Tell the client to save this file, even though it's text.
81 87
 		header('Content-Type: ' . (isBrowser('ie') || isBrowser('opera') ? 'application/octetstream' : 'application/octet-stream'));
@@ -124,13 +130,16 @@  discard block
 block discarded – undo
124 130
 				$crlf .
125 131
 				$database->db_table_sql($tableName) . ';' . $crlf;
126 132
 		}
127
-		else
128
-			// This is needed to speedup things later
133
+		else {
134
+					// This is needed to speedup things later
129 135
 			$database->db_table_sql($tableName);
136
+		}
130 137
 
131 138
 		// How about the data?
132 139
 		if (!isset($_REQUEST['data']) || substr($tableName, -10) == 'log_errors')
133
-			continue;
140
+		{
141
+					continue;
142
+		}
134 143
 
135 144
 		$first_round = true;
136 145
 		$close_table = false;
@@ -139,11 +148,15 @@  discard block
 block discarded – undo
139 148
 		while ($get_rows = $database->insert_sql($tableName, $first_round))
140 149
 		{
141 150
 			if (empty($get_rows))
142
-				break;
151
+			{
152
+							break;
153
+			}
143 154
 
144 155
 			// Time is what we need here!
145 156
 			if (function_exists('apache_reset_timeout'))
146
-				@apache_reset_timeout();
157
+			{
158
+							@apache_reset_timeout();
159
+			}
147 160
 			elseif (!empty($time_limit) && (((int) $start_time + (int) $time_limit - 20) > time()))
148 161
 			{
149 162
 				$start_time = time();
@@ -182,8 +195,10 @@  discard block
 block discarded – undo
182 195
 
183 196
 		// No rows to get - skip it.
184 197
 		if ($close_table)
185
-			$db_backup .=
198
+		{
199
+					$db_backup .=
186 200
 			'-- --------------------------------------------------------' . $crlf;
201
+		}
187 202
 	}
188 203
 
189 204
 	// write the last line
Please login to merge, or discard this patch.
sources/Load.php 2 patches
Braces   +453 added lines, -177 removed lines patch added patch discarded remove patch
@@ -52,20 +52,32 @@  discard block
 block discarded – undo
52 52
 		);
53 53
 		$modSettings = array();
54 54
 		if (!$request)
55
-			Errors::instance()->display_db_error();
55
+		{
56
+					Errors::instance()->display_db_error();
57
+		}
56 58
 		while ($row = $db->fetch_row($request))
57
-			$modSettings[$row[0]] = $row[1];
59
+		{
60
+					$modSettings[$row[0]] = $row[1];
61
+		}
58 62
 		$db->free_result($request);
59 63
 
60 64
 		// Do a few things to protect against missing settings or settings with invalid values...
61 65
 		if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999)
62
-			$modSettings['defaultMaxTopics'] = 20;
66
+		{
67
+					$modSettings['defaultMaxTopics'] = 20;
68
+		}
63 69
 		if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999)
64
-			$modSettings['defaultMaxMessages'] = 15;
70
+		{
71
+					$modSettings['defaultMaxMessages'] = 15;
72
+		}
65 73
 		if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999)
66
-			$modSettings['defaultMaxMembers'] = 30;
74
+		{
75
+					$modSettings['defaultMaxMembers'] = 30;
76
+		}
67 77
 		if (empty($modSettings['subject_length']))
68
-			$modSettings['subject_length'] = 24;
78
+		{
79
+					$modSettings['subject_length'] = 24;
80
+		}
69 81
 
70 82
 		$modSettings['warning_enable'] = $modSettings['warning_settings'][0];
71 83
 
@@ -85,7 +97,9 @@  discard block
 block discarded – undo
85 97
 
86 98
 	// Setting the timezone is a requirement for some functions in PHP >= 5.1.
87 99
 	if (isset($modSettings['default_timezone']))
88
-		date_default_timezone_set($modSettings['default_timezone']);
100
+	{
101
+			date_default_timezone_set($modSettings['default_timezone']);
102
+	}
89 103
 
90 104
 	// Check the load averages?
91 105
 	if (!empty($modSettings['loadavg_enable']))
@@ -99,19 +113,27 @@  discard block
 block discarded – undo
99 113
 		}
100 114
 
101 115
 		if ($modSettings['load_average'] !== false)
102
-			call_integration_hook('integrate_load_average', array($modSettings['load_average']));
116
+		{
117
+					call_integration_hook('integrate_load_average', array($modSettings['load_average']));
118
+		}
103 119
 
104 120
 		// Let's have at least a zero
105 121
 		if (empty($modSettings['loadavg_forum']) || $modSettings['load_average'] === false)
106
-			$modSettings['current_load'] = 0;
107
-		else
108
-			$modSettings['current_load'] = $modSettings['load_average'];
122
+		{
123
+					$modSettings['current_load'] = 0;
124
+		}
125
+		else {
126
+					$modSettings['current_load'] = $modSettings['load_average'];
127
+		}
109 128
 
110 129
 		if (!empty($modSettings['loadavg_forum']) && $modSettings['current_load'] >= $modSettings['loadavg_forum'])
111
-			Errors::instance()->display_loadavg_error();
130
+		{
131
+					Errors::instance()->display_loadavg_error();
132
+		}
133
+	}
134
+	else {
135
+			$modSettings['current_load'] = 0;
112 136
 	}
113
-	else
114
-		$modSettings['current_load'] = 0;
115 137
 
116 138
 	// Is post moderation alive and well?
117 139
 	$modSettings['postmod_active'] = isset($modSettings['admin_features']) ? in_array('pm', explode(',', $modSettings['admin_features'])) : true;
@@ -147,7 +169,9 @@  discard block
 block discarded – undo
147 169
 	{
148 170
 		$integration_settings = Util::unserialize(ELK_INTEGRATION_SETTINGS);
149 171
 		foreach ($integration_settings as $hook => $function)
150
-			add_integration_function($hook, $function);
172
+		{
173
+					add_integration_function($hook, $function);
174
+		}
151 175
 	}
152 176
 
153 177
 	// Any files to pre include?
@@ -195,8 +219,9 @@  discard block
 block discarded – undo
195 219
 			}
196 220
 		}
197 221
 	}
198
-	else
199
-		$id_member = 0;
222
+	else {
223
+			$id_member = 0;
224
+	}
200 225
 
201 226
 	// We'll need IPs and user agent and stuff, they came to visit us with!
202 227
 	$req = request();
@@ -247,7 +272,9 @@  discard block
 block discarded – undo
247 272
 			}
248 273
 
249 274
 			if ($cache->levelHigherThan(1))
250
-				$cache->put('user_settings-' . $id_member, $user_settings, 60);
275
+			{
276
+							$cache->put('user_settings-' . $id_member, $user_settings, 60);
277
+			}
251 278
 		}
252 279
 
253 280
 		// Did we find 'im?  If not, junk it.
@@ -255,22 +282,30 @@  discard block
 block discarded – undo
255 282
 		{
256 283
 			// As much as the password should be right, we can assume the integration set things up.
257 284
 			if (!empty($already_verified) && $already_verified === true)
258
-				$check = true;
285
+			{
286
+							$check = true;
287
+			}
259 288
 			// SHA-256 passwords should be 64 characters long.
260 289
 			elseif (strlen($password) == 64)
261
-				$check = hash('sha256', ($user_settings['passwd'] . $user_settings['password_salt'])) == $password;
262
-			else
263
-				$check = false;
290
+			{
291
+							$check = hash('sha256', ($user_settings['passwd'] . $user_settings['password_salt'])) == $password;
292
+			}
293
+			else {
294
+							$check = false;
295
+			}
264 296
 
265 297
 			// Wrong password or not activated - either way, you're going nowhere.
266 298
 			$id_member = $check && ($user_settings['is_activated'] == 1 || $user_settings['is_activated'] == 11) ? (int) $user_settings['id_member'] : 0;
267 299
 		}
268
-		else
269
-			$id_member = 0;
300
+		else {
301
+					$id_member = 0;
302
+		}
270 303
 
271 304
 		// If we no longer have the member maybe they're being all hackey, stop brute force!
272 305
 		if (!$id_member)
273
-			validatePasswordFlood(!empty($user_settings['id_member']) ? $user_settings['id_member'] : $id_member, !empty($user_settings['passwd_flood']) ? $user_settings['passwd_flood'] : false, $id_member != 0);
306
+		{
307
+					validatePasswordFlood(!empty($user_settings['id_member']) ? $user_settings['id_member'] : $id_member, !empty($user_settings['passwd_flood']) ? $user_settings['passwd_flood'] : false, $id_member != 0);
308
+		}
274 309
 	}
275 310
 
276 311
 	// Found 'im, let's set up the variables.
@@ -298,31 +333,40 @@  discard block
 block discarded – undo
298 333
 				$user_settings['last_login'] = time();
299 334
 
300 335
 				if ($cache->levelHigherThan(1))
301
-					$cache->put('user_settings-' . $id_member, $user_settings, 60);
336
+				{
337
+									$cache->put('user_settings-' . $id_member, $user_settings, 60);
338
+				}
302 339
 
303 340
 				$cache->put('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600);
304 341
 			}
305 342
 		}
306 343
 		elseif (empty($_SESSION['id_msg_last_visit']))
307
-			$_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit'];
344
+		{
345
+					$_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit'];
346
+		}
308 347
 
309 348
 		$username = $user_settings['member_name'];
310 349
 
311 350
 		if (empty($user_settings['additional_groups']))
312
-			$user_info = array(
351
+		{
352
+					$user_info = array(
313 353
 				'groups' => array($user_settings['id_group'], $user_settings['id_post_group'])
314 354
 			);
315
-		else
316
-			$user_info = array(
355
+		}
356
+		else {
357
+					$user_info = array(
317 358
 				'groups' => array_merge(
318 359
 					array($user_settings['id_group'], $user_settings['id_post_group']),
319 360
 					explode(',', $user_settings['additional_groups'])
320 361
 				)
321 362
 			);
363
+		}
322 364
 
323 365
 		// Because history has proven that it is possible for groups to go bad - clean up in case.
324 366
 		foreach ($user_info['groups'] as $k => $v)
325
-			$user_info['groups'][$k] = (int) $v;
367
+		{
368
+					$user_info['groups'][$k] = (int) $v;
369
+		}
326 370
 
327 371
 		// This is a logged in user, so definitely not a spider.
328 372
 		$user_info['possibly_robot'] = false;
@@ -344,13 +388,18 @@  discard block
 block discarded – undo
344 388
 		$user_settings = array();
345 389
 
346 390
 		if (isset($_COOKIE[$cookiename]))
347
-			$_COOKIE[$cookiename] = '';
391
+		{
392
+					$_COOKIE[$cookiename] = '';
393
+		}
348 394
 
349 395
 		// Create a login token if it doesn't exist yet.
350 396
 		if (!isset($_SESSION['token']['post-login']))
351
-			createToken('login');
352
-		else
353
-			list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login'];
397
+		{
398
+					createToken('login');
399
+		}
400
+		else {
401
+					list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login'];
402
+		}
354 403
 
355 404
 		// Do we perhaps think this is a search robot? Check every five minutes just in case...
356 405
 		if ((!empty($modSettings['spider_mode']) || !empty($modSettings['spider_group'])) && (!isset($_SESSION['robot_check']) || $_SESSION['robot_check'] < time() - 300))
@@ -359,7 +408,9 @@  discard block
 block discarded – undo
359 408
 			$user_info['possibly_robot'] = spiderCheck();
360 409
 		}
361 410
 		elseif (!empty($modSettings['spider_mode']))
362
-			$user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0;
411
+		{
412
+					$user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0;
413
+		}
363 414
 		// If we haven't turned on proper spider hunts then have a guess!
364 415
 		else
365 416
 		{
@@ -407,11 +458,15 @@  discard block
 block discarded – undo
407 458
 
408 459
 	// Make sure that the last item in the ignore boards array is valid.  If the list was too long it could have an ending comma that could cause problems.
409 460
 	if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1]))
410
-		unset($user_info['ignoreboards'][$tmp]);
461
+	{
462
+			unset($user_info['ignoreboards'][$tmp]);
463
+	}
411 464
 
412 465
 	// Do we have any languages to validate this?
413 466
 	if (!empty($modSettings['userLanguage']) && (!empty($_GET['language']) || !empty($_SESSION['language'])))
414
-		$languages = getLanguages();
467
+	{
468
+			$languages = getLanguages();
469
+	}
415 470
 
416 471
 	// Allow the user to change their language if its valid.
417 472
 	if (!empty($modSettings['userLanguage']) && !empty($_GET['language']) && isset($languages[strtr($_GET['language'], './\\:', '____')]))
@@ -420,23 +475,31 @@  discard block
 block discarded – undo
420 475
 		$_SESSION['language'] = $user_info['language'];
421 476
 	}
422 477
 	elseif (!empty($modSettings['userLanguage']) && !empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')]))
423
-		$user_info['language'] = strtr($_SESSION['language'], './\\:', '____');
478
+	{
479
+			$user_info['language'] = strtr($_SESSION['language'], './\\:', '____');
480
+	}
424 481
 
425 482
 	// Just build this here, it makes it easier to change/use - administrators can see all boards.
426 483
 	if ($user_info['is_admin'])
427
-		$user_info['query_see_board'] = '1=1';
484
+	{
485
+			$user_info['query_see_board'] = '1=1';
486
+	}
428 487
 	// Otherwise just the groups in $user_info['groups'].
429
-	else
430
-		$user_info['query_see_board'] = '((FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $user_info['groups']) . ', b.member_groups) != 0)' . (!empty($modSettings['deny_boards_access']) ? ' AND (FIND_IN_SET(' . implode(', b.deny_member_groups) = 0 AND FIND_IN_SET(', $user_info['groups']) . ', b.deny_member_groups) = 0)' : '') . (isset($user_info['mod_cache']) ? ' OR ' . $user_info['mod_cache']['mq'] : '') . ')';
488
+	else {
489
+			$user_info['query_see_board'] = '((FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $user_info['groups']) . ', b.member_groups) != 0)' . (!empty($modSettings['deny_boards_access']) ? ' AND (FIND_IN_SET(' . implode(', b.deny_member_groups) = 0 AND FIND_IN_SET(', $user_info['groups']) . ', b.deny_member_groups) = 0)' : '') . (isset($user_info['mod_cache']) ? ' OR ' . $user_info['mod_cache']['mq'] : '') . ')';
490
+	}
431 491
 	// Build the list of boards they WANT to see.
432 492
 	// This will take the place of query_see_boards in certain spots, so it better include the boards they can see also
433 493
 
434 494
 	// If they aren't ignoring any boards then they want to see all the boards they can see
435 495
 	if (empty($user_info['ignoreboards']))
436
-		$user_info['query_wanna_see_board'] = $user_info['query_see_board'];
496
+	{
497
+			$user_info['query_wanna_see_board'] = $user_info['query_see_board'];
498
+	}
437 499
 	// Ok I guess they don't want to see all the boards
438
-	else
439
-		$user_info['query_wanna_see_board'] = '(' . $user_info['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $user_info['ignoreboards']) . '))';
500
+	else {
501
+			$user_info['query_wanna_see_board'] = '(' . $user_info['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $user_info['ignoreboards']) . '))';
502
+	}
440 503
 
441 504
 	if ($user_info['is_guest'] === false)
442 505
 	{
@@ -533,7 +596,9 @@  discard block
 block discarded – undo
533 596
 
534 597
 		// Remember redirection is the key to avoiding fallout from your bosses.
535 598
 		if (!empty($topic))
536
-			redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']);
599
+		{
600
+					redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']);
601
+		}
537 602
 		else
538 603
 		{
539 604
 			loadPermissions();
@@ -553,9 +618,12 @@  discard block
 block discarded – undo
553 618
 	{
554 619
 		// @todo SLOW?
555 620
 		if (!empty($topic))
556
-			$temp = $cache->get('topic_board-' . $topic, 120);
557
-		else
558
-			$temp = $cache->get('board-' . $board, 120);
621
+		{
622
+					$temp = $cache->get('topic_board-' . $topic, 120);
623
+		}
624
+		else {
625
+					$temp = $cache->get('board-' . $board, 120);
626
+		}
559 627
 
560 628
 		if (!empty($temp))
561 629
 		{
@@ -597,7 +665,9 @@  discard block
 block discarded – undo
597 665
 
598 666
 			// Set the current board.
599 667
 			if (!empty($row['id_board']))
600
-				$board = (int) $row['id_board'];
668
+			{
669
+							$board = (int) $row['id_board'];
670
+			}
601 671
 
602 672
 			// Basic operating information. (globals... :/)
603 673
 			$board_info = array(
@@ -635,12 +705,14 @@  discard block
 block discarded – undo
635 705
 			do
636 706
 			{
637 707
 				if (!empty($row['id_moderator']))
638
-					$board_info['moderators'][$row['id_moderator']] = array(
708
+				{
709
+									$board_info['moderators'][$row['id_moderator']] = array(
639 710
 						'id' => $row['id_moderator'],
640 711
 						'name' => $row['real_name'],
641 712
 						'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'],
642 713
 						'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>'
643 714
 					);
715
+				}
644 716
 			}
645 717
 			while ($row = $db->fetch_assoc($request));
646 718
 
@@ -673,7 +745,9 @@  discard block
 block discarded – undo
673 745
 			{
674 746
 				// @todo SLOW?
675 747
 				if (!empty($topic))
676
-					$cache->put('topic_board-' . $topic, $board_info, 120);
748
+				{
749
+									$cache->put('topic_board-' . $topic, $board_info, 120);
750
+				}
677 751
 				$cache->put('board-' . $board, $board_info, 120);
678 752
 			}
679 753
 		}
@@ -691,7 +765,9 @@  discard block
 block discarded – undo
691 765
 	}
692 766
 
693 767
 	if (!empty($topic))
694
-		$_GET['board'] = (int) $board;
768
+	{
769
+			$_GET['board'] = (int) $board;
770
+	}
695 771
 
696 772
 	if (!empty($board))
697 773
 	{
@@ -699,9 +775,13 @@  discard block
 block discarded – undo
699 775
 		$user_info['is_mod'] = isset($board_info['moderators'][$user_info['id']]);
700 776
 
701 777
 		if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin'])
702
-			$board_info['error'] = 'access';
778
+		{
779
+					$board_info['error'] = 'access';
780
+		}
703 781
 		if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin'])
704
-			$board_info['error'] = 'access';
782
+		{
783
+					$board_info['error'] = 'access';
784
+		}
705 785
 
706 786
 		// Build up the linktree.
707 787
 		$context['linktree'] = array_merge(
@@ -757,13 +837,16 @@  discard block
 block discarded – undo
757 837
 			loadLanguage('Errors');
758 838
 			is_not_guest($txt['topic_gone']);
759 839
 		}
760
-		else
761
-			throw new Elk_Exception('topic_gone', false);
840
+		else {
841
+					throw new Elk_Exception('topic_gone', false);
842
+		}
762 843
 	}
763 844
 
764 845
 	if ($user_info['is_mod'])
765
-		$user_info['groups'][] = 3;
766
-}
846
+	{
847
+			$user_info['groups'][] = 3;
848
+	}
849
+	}
767 850
 
768 851
 /**
769 852
  * Load this user's permissions.
@@ -801,7 +884,9 @@  discard block
 block discarded – undo
801 884
 
802 885
 		// If it's a spider then cache it different.
803 886
 		if ($user_info['possibly_robot'])
804
-			$cache_groups .= '-spider';
887
+		{
888
+					$cache_groups .= '-spider';
889
+		}
805 890
 
806 891
 		$temp = array();
807 892
 		if ($cache->levelHigherThan(1) && !empty($board) && $cache->getVar($temp, 'permissions:' . $cache_groups . ':' . $board, 240) && time() - 240 > $modSettings['settings_updated'])
@@ -840,14 +925,19 @@  discard block
 block discarded – undo
840 925
 		while ($row = $db->fetch_assoc($request))
841 926
 		{
842 927
 			if (empty($row['add_deny']))
843
-				$removals[] = $row['permission'];
844
-			else
845
-				$user_info['permissions'][] = $row['permission'];
928
+			{
929
+							$removals[] = $row['permission'];
930
+			}
931
+			else {
932
+							$user_info['permissions'][] = $row['permission'];
933
+			}
846 934
 		}
847 935
 		$db->free_result($request);
848 936
 
849 937
 		if (isset($cache_groups))
850
-			$cache->put('permissions:' . $cache_groups, array($user_info['permissions'], !empty($removals) ? $removals : array()), 240);
938
+		{
939
+					$cache->put('permissions:' . $cache_groups, array($user_info['permissions'], !empty($removals) ? $removals : array()), 240);
940
+		}
851 941
 	}
852 942
 
853 943
 	// Get the board permissions.
@@ -855,7 +945,9 @@  discard block
 block discarded – undo
855 945
 	{
856 946
 		// Make sure the board (if any) has been loaded by loadBoard().
857 947
 		if (!isset($board_info['profile']))
858
-			throw new Elk_Exception('no_board');
948
+		{
949
+					throw new Elk_Exception('no_board');
950
+		}
859 951
 
860 952
 		$request = $db->query('', '
861 953
 			SELECT 
@@ -873,19 +965,26 @@  discard block
 block discarded – undo
873 965
 		while ($row = $db->fetch_assoc($request))
874 966
 		{
875 967
 			if (empty($row['add_deny']))
876
-				$removals[] = $row['permission'];
877
-			else
878
-				$user_info['permissions'][] = $row['permission'];
968
+			{
969
+							$removals[] = $row['permission'];
970
+			}
971
+			else {
972
+							$user_info['permissions'][] = $row['permission'];
973
+			}
879 974
 		}
880 975
 		$db->free_result($request);
881 976
 	}
882 977
 
883 978
 	// Remove all the permissions they shouldn't have ;).
884 979
 	if (!empty($modSettings['permission_enable_deny']))
885
-		$user_info['permissions'] = array_diff($user_info['permissions'], $removals);
980
+	{
981
+			$user_info['permissions'] = array_diff($user_info['permissions'], $removals);
982
+	}
886 983
 
887 984
 	if (isset($cache_groups) && !empty($board) && $cache->levelHigherThan(1))
888
-		$cache->put('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240);
985
+	{
986
+			$cache->put('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240);
987
+	}
889 988
 
890 989
 	// Banned?  Watch, don't touch..
891 990
 	banPermissions();
@@ -899,8 +998,9 @@  discard block
 block discarded – undo
899 998
 			require_once(SUBSDIR . '/Auth.subs.php');
900 999
 			rebuildModCache();
901 1000
 		}
902
-		else
903
-			$user_info['mod_cache'] = $_SESSION['mc'];
1001
+		else {
1002
+					$user_info['mod_cache'] = $_SESSION['mc'];
1003
+		}
904 1004
 	}
905 1005
 }
906 1006
 
@@ -927,7 +1027,9 @@  discard block
 block discarded – undo
927 1027
 
928 1028
 	// Can't just look for no users :P.
929 1029
 	if (empty($users))
930
-		return false;
1030
+	{
1031
+			return false;
1032
+	}
931 1033
 
932 1034
 	// Pass the set value
933 1035
 	$context['loadMemberContext_set'] = $set;
@@ -943,7 +1045,9 @@  discard block
 block discarded – undo
943 1045
 		{
944 1046
 			$data = $cache->get('member_data-' . $set . '-' . $users[$i], 240);
945 1047
 			if ($cache->isMiss())
946
-				continue;
1048
+			{
1049
+							continue;
1050
+			}
947 1051
 
948 1052
 			$loaded_ids[] = $data['id_member'];
949 1053
 			$user_profile[$data['id_member']] = $data;
@@ -1048,12 +1152,16 @@  discard block
 block discarded – undo
1048 1152
 
1049 1153
 	// Anything else integration may want to add to the user_profile array
1050 1154
 	if (!empty($new_loaded_ids))
1051
-		call_integration_hook('integrate_add_member_data', array($new_loaded_ids, $set));
1155
+	{
1156
+			call_integration_hook('integrate_add_member_data', array($new_loaded_ids, $set));
1157
+	}
1052 1158
 
1053 1159
 	if (!empty($new_loaded_ids) && $cache->levelHigherThan(2))
1054 1160
 	{
1055 1161
 		for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++)
1056
-			$cache->put('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240);
1162
+		{
1163
+					$cache->put('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240);
1164
+		}
1057 1165
 	}
1058 1166
 
1059 1167
 	// Are we loading any moderators?  If so, fix their group data...
@@ -1072,13 +1180,19 @@  discard block
 block discarded – undo
1072 1180
 		{
1073 1181
 			// By popular demand, don't show admins or global moderators as moderators.
1074 1182
 			if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2)
1075
-				$user_profile[$id]['member_group'] = $group_info['group_name'];
1183
+			{
1184
+							$user_profile[$id]['member_group'] = $group_info['group_name'];
1185
+			}
1076 1186
 
1077 1187
 			// If the Moderator group has no color or icons, but their group does... don't overwrite.
1078 1188
 			if (!empty($group_info['icons']))
1079
-				$user_profile[$id]['icons'] = $group_info['icons'];
1189
+			{
1190
+							$user_profile[$id]['icons'] = $group_info['icons'];
1191
+			}
1080 1192
 			if (!empty($group_info['online_color']))
1081
-				$user_profile[$id]['member_group_color'] = $group_info['online_color'];
1193
+			{
1194
+							$user_profile[$id]['member_group_color'] = $group_info['online_color'];
1195
+			}
1082 1196
 		}
1083 1197
 	}
1084 1198
 
@@ -1110,11 +1224,15 @@  discard block
 block discarded – undo
1110 1224
 
1111 1225
 	// If this person's data is already loaded, skip it.
1112 1226
 	if (isset($dataLoaded[$user]))
1113
-		return true;
1227
+	{
1228
+			return true;
1229
+	}
1114 1230
 
1115 1231
 	// We can't load guests or members not loaded by loadMemberData()!
1116 1232
 	if ($user == 0)
1117
-		return false;
1233
+	{
1234
+			return false;
1235
+	}
1118 1236
 
1119 1237
 	if (!isset($user_profile[$user]))
1120 1238
 	{
@@ -1221,21 +1339,29 @@  discard block
 block discarded – undo
1221 1339
 	if ($display_custom_fields && !empty($modSettings['displayFields']))
1222 1340
 	{
1223 1341
 		if (!isset($context['display_fields']))
1224
-			$context['display_fields'] = Util::unserialize($modSettings['displayFields']);
1342
+		{
1343
+					$context['display_fields'] = Util::unserialize($modSettings['displayFields']);
1344
+		}
1225 1345
 
1226 1346
 		foreach ($context['display_fields'] as $custom)
1227 1347
 		{
1228 1348
 			if (!isset($custom['title']) || trim($custom['title']) == '' || empty($profile['options'][$custom['colname']]))
1229
-				continue;
1349
+			{
1350
+							continue;
1351
+			}
1230 1352
 
1231 1353
 			$value = $profile['options'][$custom['colname']];
1232 1354
 
1233 1355
 			// BBC?
1234 1356
 			if ($custom['bbc'])
1235
-				$value = $parsers->parseCustomFields($value);
1357
+			{
1358
+							$value = $parsers->parseCustomFields($value);
1359
+			}
1236 1360
 			// ... or checkbox?
1237 1361
 			elseif (isset($custom['type']) && $custom['type'] == 'check')
1238
-				$value = $value ? $txt['yes'] : $txt['no'];
1362
+			{
1363
+							$value = $value ? $txt['yes'] : $txt['no'];
1364
+			}
1239 1365
 
1240 1366
 			// Enclosing the user input within some other text?
1241 1367
 			if (!empty($custom['enclose']))
@@ -1291,7 +1417,9 @@  discard block
 block discarded – undo
1291 1417
 
1292 1418
 	// The theme was specified by parameter.
1293 1419
 	if (!empty($id_theme))
1294
-		$id_theme = (int) $id_theme;
1420
+	{
1421
+			$id_theme = (int) $id_theme;
1422
+	}
1295 1423
 	// The theme was specified by REQUEST.
1296 1424
 	elseif (!empty($_REQUEST['theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum')))
1297 1425
 	{
@@ -1300,36 +1428,51 @@  discard block
 block discarded – undo
1300 1428
 	}
1301 1429
 	// The theme was specified by REQUEST... previously.
1302 1430
 	elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum')))
1303
-		$id_theme = (int) $_SESSION['id_theme'];
1431
+	{
1432
+			$id_theme = (int) $_SESSION['id_theme'];
1433
+	}
1304 1434
 	// The theme is just the user's choice. (might use ?board=1;theme=0 to force board theme.)
1305 1435
 	elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum')))
1306
-		$id_theme = $user_info['theme'];
1436
+	{
1437
+			$id_theme = $user_info['theme'];
1438
+	}
1307 1439
 	// The theme was specified by the board.
1308 1440
 	elseif (!empty($board_info['theme']))
1309
-		$id_theme = $board_info['theme'];
1441
+	{
1442
+			$id_theme = $board_info['theme'];
1443
+	}
1310 1444
 	// The theme is the forum's default.
1311
-	else
1312
-		$id_theme = $modSettings['theme_guests'];
1445
+	else {
1446
+			$id_theme = $modSettings['theme_guests'];
1447
+	}
1313 1448
 
1314 1449
 	call_integration_hook('integrate_customize_theme_id', array(&$id_theme));
1315 1450
 
1316 1451
 	// Verify the id_theme... no foul play.
1317 1452
 	// Always allow the board specific theme, if they are overriding.
1318 1453
 	if (!empty($board_info['theme']) && $board_info['override_theme'])
1319
-		$id_theme = $board_info['theme'];
1454
+	{
1455
+			$id_theme = $board_info['theme'];
1456
+	}
1320 1457
 	// If they have specified a particular theme to use with SSI allow it to be used.
1321 1458
 	elseif (!empty($ssi_theme) && $id_theme == $ssi_theme)
1322
-		$id_theme = (int) $id_theme;
1459
+	{
1460
+			$id_theme = (int) $id_theme;
1461
+	}
1323 1462
 	elseif (!empty($modSettings['knownThemes']) && !allowedTo('admin_forum'))
1324 1463
 	{
1325 1464
 		$themes = explode(',', $modSettings['knownThemes']);
1326 1465
 		if (!in_array($id_theme, $themes))
1327
-			$id_theme = $modSettings['theme_guests'];
1328
-		else
1466
+		{
1467
+					$id_theme = $modSettings['theme_guests'];
1468
+		}
1469
+		else {
1470
+					$id_theme = (int) $id_theme;
1471
+		}
1472
+	}
1473
+	else {
1329 1474
 			$id_theme = (int) $id_theme;
1330 1475
 	}
1331
-	else
1332
-		$id_theme = (int) $id_theme;
1333 1476
 
1334 1477
 	return $id_theme;
1335 1478
 }
@@ -1357,10 +1500,13 @@  discard block
 block discarded – undo
1357 1500
 	}
1358 1501
 	// Or do we just have the system wide theme settings cached
1359 1502
 	elseif ($cache->getVar($temp, 'theme_settings-' . $id_theme, 90) && time() - 60 > $modSettings['settings_updated'])
1360
-		$themeData = $temp + array($member => array());
1503
+	{
1504
+			$themeData = $temp + array($member => array());
1505
+	}
1361 1506
 	// Nothing at all then
1362
-	else
1363
-		$themeData = array(-1 => array(), 0 => array(), $member => array());
1507
+	else {
1508
+			$themeData = array(-1 => array(), 0 => array(), $member => array());
1509
+	}
1364 1510
 
1365 1511
 	if (empty($flag))
1366 1512
 	{
@@ -1385,15 +1531,21 @@  discard block
 block discarded – undo
1385 1531
 		{
1386 1532
 			// There are just things we shouldn't be able to change as members.
1387 1533
 			if ($row['id_member'] != 0 && in_array($row['variable'], $immutable_theme_data))
1388
-				continue;
1534
+			{
1535
+							continue;
1536
+			}
1389 1537
 
1390 1538
 			// If this is the theme_dir of the default theme, store it.
1391 1539
 			if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member']))
1392
-				$themeData[0]['default_' . $row['variable']] = $row['value'];
1540
+			{
1541
+							$themeData[0]['default_' . $row['variable']] = $row['value'];
1542
+			}
1393 1543
 
1394 1544
 			// If this isn't set yet, is a theme option, or is not the default theme..
1395 1545
 			if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1')
1396
-				$themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value'];
1546
+			{
1547
+							$themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value'];
1548
+			}
1397 1549
 		}
1398 1550
 		$db->free_result($result);
1399 1551
 
@@ -1414,16 +1566,22 @@  discard block
 block discarded – undo
1414 1566
 			foreach ($themeData[-1] as $k => $v)
1415 1567
 			{
1416 1568
 				if (!isset($themeData[$member][$k]))
1417
-					$themeData[$member][$k] = $v;
1569
+				{
1570
+									$themeData[$member][$k] = $v;
1571
+				}
1418 1572
 			}
1419 1573
 		}
1420 1574
 
1421 1575
 		// If being aggressive we save the site wide and member theme settings
1422 1576
 		if ($cache->levelHigherThan(1))
1423
-			$cache->put('theme_settings-' . $id_theme . ':' . $member, $themeData, 60);
1577
+		{
1578
+					$cache->put('theme_settings-' . $id_theme . ':' . $member, $themeData, 60);
1579
+		}
1424 1580
 		// Only if we didn't already load that part of the cache...
1425 1581
 		elseif (!isset($temp))
1426
-			$cache->put('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90);
1582
+		{
1583
+					$cache->put('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90);
1584
+		}
1427 1585
 	}
1428 1586
 
1429 1587
 	return $themeData;
@@ -1509,7 +1667,9 @@  discard block
 block discarded – undo
1509 1667
 	initTheme($id_theme);
1510 1668
 
1511 1669
 	if (!$initialize)
1512
-		return;
1670
+	{
1671
+			return;
1672
+	}
1513 1673
 
1514 1674
 	loadThemeUrls();
1515 1675
 
@@ -1550,7 +1710,9 @@  discard block
 block discarded – undo
1550 1710
 	}
1551 1711
 	// Guest may have collapsed the header, check the cookie to prevent collapse jumping
1552 1712
 	elseif ($user_info['is_guest'] && isset($_COOKIE['upshrink']))
1553
-		$context['minmax_preferences'] = array('upshrink' => $_COOKIE['upshrink']);
1713
+	{
1714
+			$context['minmax_preferences'] = array('upshrink' => $_COOKIE['upshrink']);
1715
+	}
1554 1716
 
1555 1717
 	// Load the basic layers
1556 1718
 	theme()->loadDefaultLayers();
@@ -1600,25 +1762,33 @@  discard block
 block discarded – undo
1600 1762
 	}
1601 1763
 
1602 1764
 	if (!isset($txt))
1603
-		$txt = array();
1765
+	{
1766
+			$txt = array();
1767
+	}
1604 1768
 
1605 1769
 	// Defaults in case of odd things
1606 1770
 	$settings['avatars_on_indexes'] = 0;
1607 1771
 
1608 1772
 	// Initialize the theme.
1609 1773
 	if (function_exists('template_init'))
1610
-		$settings = array_merge($settings, template_init());
1774
+	{
1775
+			$settings = array_merge($settings, template_init());
1776
+	}
1611 1777
 
1612 1778
 	// Call initialization theme integration functions.
1613 1779
 	call_integration_hook('integrate_init_theme', array($id_theme, &$settings));
1614 1780
 
1615 1781
 	// Guests may still need a name.
1616 1782
 	if ($context['user']['is_guest'] && empty($context['user']['name']))
1617
-		$context['user']['name'] = $txt['guest_title'];
1783
+	{
1784
+			$context['user']['name'] = $txt['guest_title'];
1785
+	}
1618 1786
 
1619 1787
 	// Any theme-related strings that need to be loaded?
1620 1788
 	if (!empty($settings['require_theme_strings']))
1621
-		loadLanguage('ThemeStrings', '', false);
1789
+	{
1790
+			loadLanguage('ThemeStrings', '', false);
1791
+	}
1622 1792
 
1623 1793
 	theme()->loadSupportCSS();
1624 1794
 
@@ -1634,7 +1804,9 @@  discard block
 block discarded – undo
1634 1804
 
1635 1805
 	// Allow overriding the board wide time/number formats.
1636 1806
 	if (empty($user_settings['time_format']) && !empty($txt['time_format']))
1637
-		$user_info['time_format'] = $txt['time_format'];
1807
+	{
1808
+			$user_info['time_format'] = $txt['time_format'];
1809
+	}
1638 1810
 
1639 1811
 	if (isset($settings['use_default_images']) && $settings['use_default_images'] == 'always')
1640 1812
 	{
@@ -1648,19 +1820,25 @@  discard block
 block discarded – undo
1648 1820
 
1649 1821
 	// RTL languages require an additional stylesheet.
1650 1822
 	if ($context['right_to_left'])
1651
-		loadCSSFile('rtl.css');
1823
+	{
1824
+			loadCSSFile('rtl.css');
1825
+	}
1652 1826
 
1653 1827
 	if (!empty($context['theme_variant']) && $context['right_to_left'])
1654
-		loadCSSFile($context['theme_variant'] . '/rtl' . $context['theme_variant'] . '.css');
1828
+	{
1829
+			loadCSSFile($context['theme_variant'] . '/rtl' . $context['theme_variant'] . '.css');
1830
+	}
1655 1831
 
1656 1832
 	// This allows us to change the way things look for the admin.
1657 1833
 	$context['admin_features'] = explode(',', isset($modSettings['admin_features']) ? $modSettings['admin_features'] : 'cd,cp,k,w,rg,ml,pm');
1658 1834
 
1659 1835
 	if (!empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged']))
1660
-		$context['newsfeed_urls'] = array(
1836
+	{
1837
+			$context['newsfeed_urls'] = array(
1661 1838
 			'rss' => $scripturl . '?action=.xml;type=rss2;limit=' . (!empty($modSettings['xmlnews_limit']) ? $modSettings['xmlnews_limit'] : 5),
1662 1839
 			'atom' => $scripturl . '?action=.xml;type=atom;limit=' . (!empty($modSettings['xmlnews_limit']) ? $modSettings['xmlnews_limit'] : 5)
1663 1840
 		);
1841
+	}
1664 1842
 
1665 1843
 	if (!empty($_SESSION['agreement_accepted']))
1666 1844
 	{
@@ -1712,7 +1890,9 @@  discard block
 block discarded – undo
1712 1890
 		$detected_url .= empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST'];
1713 1891
 		$temp = preg_replace('~/' . basename($scripturl) . '(/.+)?$~', '', strtr(dirname($_SERVER['PHP_SELF']), '\\', '/'));
1714 1892
 		if ($temp != '/')
1715
-			$detected_url .= $temp;
1893
+		{
1894
+					$detected_url .= $temp;
1895
+		}
1716 1896
 	}
1717 1897
 
1718 1898
 	if (isset($detected_url) && $detected_url != $boardurl)
@@ -1725,7 +1905,9 @@  discard block
 block discarded – undo
1725 1905
 			{
1726 1906
 				// Rip off all the boring parts, spaces, etc.
1727 1907
 				if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias))
1728
-					$do_fix = true;
1908
+				{
1909
+									$do_fix = true;
1910
+				}
1729 1911
 			}
1730 1912
 		}
1731 1913
 
@@ -1734,17 +1916,23 @@  discard block
 block discarded – undo
1734 1916
 		{
1735 1917
 			// Okay, this seems weird, but we don't want an endless loop - this will make $_GET not empty ;).
1736 1918
 			if (empty($_GET))
1737
-				redirectexit('wwwRedirect');
1919
+			{
1920
+							redirectexit('wwwRedirect');
1921
+			}
1738 1922
 			else
1739 1923
 			{
1740 1924
 				if (key($_GET) !== 'wwwRedirect')
1741
-					redirectexit('wwwRedirect;' . key($_GET) . '=' . current($_GET));
1925
+				{
1926
+									redirectexit('wwwRedirect;' . key($_GET) . '=' . current($_GET));
1927
+				}
1742 1928
 			}
1743 1929
 		}
1744 1930
 
1745 1931
 		// #3 is just a check for SSL...
1746 1932
 		if (strtr($detected_url, array('https://' => 'http://')) == $boardurl)
1747
-			$do_fix = true;
1933
+		{
1934
+					$do_fix = true;
1935
+		}
1748 1936
 
1749 1937
 		// Okay, #4 - perhaps it's an IP address?  We're gonna want to use that one, then. (assuming it's the IP or something...)
1750 1938
 		if (!empty($do_fix) || preg_match('~^http[s]?://(?:[\d\.:]+|\[[\d:]+\](?::\d+)?)(?:$|/)~', $detected_url) == 1)
@@ -1877,8 +2065,10 @@  discard block
 block discarded – undo
1877 2065
 	}
1878 2066
 
1879 2067
 	foreach ($context['linktree'] as $k => $dummy)
1880
-		$context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl));
1881
-}
2068
+	{
2069
+			$context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl));
2070
+	}
2071
+	}
1882 2072
 
1883 2073
 /**
1884 2074
  * Determine the current user's smiley set
@@ -1939,7 +2129,9 @@  discard block
 block discarded – undo
1939 2129
 
1940 2130
 			// Is this the default theme?
1941 2131
 			if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1')
1942
-				$settings['default_' . $row['variable']] = $row['value'];
2132
+			{
2133
+							$settings['default_' . $row['variable']] = $row['value'];
2134
+			}
1943 2135
 		}
1944 2136
 	);
1945 2137
 
@@ -2020,13 +2212,19 @@  discard block
 block discarded – undo
2020 2212
 	global $context;
2021 2213
 
2022 2214
 	if (empty($filenames))
2023
-		return;
2215
+	{
2216
+			return;
2217
+	}
2024 2218
 
2025 2219
 	if (!is_array($filenames))
2026
-		$filenames = array($filenames);
2220
+	{
2221
+			$filenames = array($filenames);
2222
+	}
2027 2223
 
2028 2224
 	if (in_array('admin.css', $filenames))
2029
-		$filenames[] = $context['theme_variant'] . '/admin' . $context['theme_variant'] . '.css';
2225
+	{
2226
+			$filenames[] = $context['theme_variant'] . '/admin' . $context['theme_variant'] . '.css';
2227
+	}
2030 2228
 
2031 2229
 	$params['subdir'] = isset($params['subdir']) ? $params['subdir'] : 'css';
2032 2230
 	$params['extension'] = 'css';
@@ -2063,7 +2261,9 @@  discard block
 block discarded – undo
2063 2261
 function loadJavascriptFile($filenames, $params = array(), $id = '')
2064 2262
 {
2065 2263
 	if (empty($filenames))
2066
-		return;
2264
+	{
2265
+			return;
2266
+	}
2067 2267
 
2068 2268
 	$params['subdir'] = isset($params['subdir']) ? $params['subdir'] : 'scripts';
2069 2269
 	$params['extension'] = 'js';
@@ -2111,20 +2311,29 @@  discard block
 block discarded – undo
2111 2311
 	global $settings, $context, $db_show_debug;
2112 2312
 
2113 2313
 	if (empty($filenames))
2114
-		return;
2314
+	{
2315
+			return;
2316
+	}
2115 2317
 
2116 2318
 	$cache = Cache::instance();
2117 2319
 
2118 2320
 	if (!is_array($filenames))
2119
-		$filenames = array($filenames);
2321
+	{
2322
+			$filenames = array($filenames);
2323
+	}
2120 2324
 
2121 2325
 	// Static values for all these settings
2122 2326
 	if (!isset($params['stale']) || $params['stale'] === true)
2123
-		$staler_string = CACHE_STALE;
2327
+	{
2328
+			$staler_string = CACHE_STALE;
2329
+	}
2124 2330
 	elseif (is_string($params['stale']))
2125
-		$staler_string = ($params['stale'][0] === '?' ? $params['stale'] : '?' . $params['stale']);
2126
-	else
2127
-		$staler_string = '';
2331
+	{
2332
+			$staler_string = ($params['stale'][0] === '?' ? $params['stale'] : '?' . $params['stale']);
2333
+	}
2334
+	else {
2335
+			$staler_string = '';
2336
+	}
2128 2337
 
2129 2338
 	$fallback = (!empty($params['fallback']) && ($params['fallback'] === false)) ? false : true;
2130 2339
 	$dir = '/' . $params['subdir'] . '/';
@@ -2135,7 +2344,9 @@  discard block
 block discarded – undo
2135 2344
 	if ($cache->getVar($temp, $cache_name, 600))
2136 2345
 	{
2137 2346
 		if (empty($context[$params['index_name']]))
2138
-			$context[$params['index_name']] = array();
2347
+		{
2348
+					$context[$params['index_name']] = array();
2349
+		}
2139 2350
 
2140 2351
 		$context[$params['index_name']] += $temp;
2141 2352
 
@@ -2185,11 +2396,13 @@  discard block
 block discarded – undo
2185 2396
 						$params['dir'] = $settings['default_theme_dir'] . $dir;
2186 2397
 						$params['url'] = $settings['default_theme_url'];
2187 2398
 					}
2188
-					else
2189
-						$filename = false;
2399
+					else {
2400
+											$filename = false;
2401
+					}
2402
+				}
2403
+				else {
2404
+									$filename = $settings['theme_url'] . $dir . $params['basename'] . $cache_staler;
2190 2405
 				}
2191
-				else
2192
-					$filename = $settings['theme_url'] . $dir . $params['basename'] . $cache_staler;
2193 2406
 			}
2194 2407
 
2195 2408
 			// Add it to the array for use in the template
@@ -2256,30 +2469,42 @@  discard block
 block discarded – undo
2256 2469
 
2257 2470
 	// Default to the user's language.
2258 2471
 	if ($lang == '')
2259
-		$lang = isset($user_info['language']) ? $user_info['language'] : $language;
2472
+	{
2473
+			$lang = isset($user_info['language']) ? $user_info['language'] : $language;
2474
+	}
2260 2475
 
2261 2476
 	if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang)
2262
-		return $lang;
2477
+	{
2478
+			return $lang;
2479
+	}
2263 2480
 
2264 2481
 	// Do we want the English version of language file as fallback?
2265 2482
 	if (empty($modSettings['disable_language_fallback']) && $lang != 'english')
2266
-		loadLanguage($template_name, 'english', false);
2483
+	{
2484
+			loadLanguage($template_name, 'english', false);
2485
+	}
2267 2486
 
2268 2487
 	// Make sure we have $settings - if not we're in trouble and need to find it!
2269 2488
 	if (empty($settings['default_theme_dir']))
2270
-		loadEssentialThemeData();
2489
+	{
2490
+			loadEssentialThemeData();
2491
+	}
2271 2492
 
2272 2493
 	// What theme are we in?
2273 2494
 	$theme_name = basename($settings['theme_url']);
2274 2495
 	if (empty($theme_name))
2275
-		$theme_name = 'unknown';
2496
+	{
2497
+			$theme_name = 'unknown';
2498
+	}
2276 2499
 
2277 2500
 	$fix_arrays = false;
2278 2501
 	// For each file open it up and write it out!
2279 2502
 	foreach (explode('+', $template_name) as $template)
2280 2503
 	{
2281 2504
 		if ($template === 'index')
2282
-			$fix_arrays = true;
2505
+		{
2506
+					$fix_arrays = true;
2507
+		}
2283 2508
 
2284 2509
 		// Obviously, the current theme is most important to check.
2285 2510
 		$attempts = array(
@@ -2343,7 +2568,9 @@  discard block
 block discarded – undo
2343 2568
 	}
2344 2569
 
2345 2570
 	if ($fix_arrays)
2346
-		fix_calendar_text();
2571
+	{
2572
+			fix_calendar_text();
2573
+	}
2347 2574
 
2348 2575
 	// Keep track of what we're up to soldier.
2349 2576
 	if ($db_show_debug === true)
@@ -2490,7 +2717,8 @@  discard block
 block discarded – undo
2490 2717
 
2491 2718
 				// If a moderator exists for this board, add that moderator for all children too.
2492 2719
 				if (!empty($row['id_moderator']))
2493
-					foreach ($boards as $id => $dummy)
2720
+				{
2721
+									foreach ($boards as $id => $dummy)
2494 2722
 					{
2495 2723
 						$boards[$id]['moderators'][$row['id_moderator']] = array(
2496 2724
 							'id' => $row['id_moderator'],
@@ -2498,6 +2726,7 @@  discard block
 block discarded – undo
2498 2726
 							'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'],
2499 2727
 							'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>'
2500 2728
 						);
2729
+				}
2501 2730
 					}
2502 2731
 			}
2503 2732
 			$db->free_result($result);
@@ -2527,7 +2756,9 @@  discard block
 block discarded – undo
2527 2756
 	{
2528 2757
 		// If we don't have our theme information yet, lets get it.
2529 2758
 		if (empty($settings['default_theme_dir']))
2530
-			loadTheme(0, false);
2759
+		{
2760
+					loadTheme(0, false);
2761
+		}
2531 2762
 
2532 2763
 		// Default language directories to try.
2533 2764
 		$language_directories = array(
@@ -2537,7 +2768,9 @@  discard block
 block discarded – undo
2537 2768
 
2538 2769
 		// We possibly have a base theme directory.
2539 2770
 		if (!empty($settings['base_theme_dir']))
2540
-			$language_directories[] = $settings['base_theme_dir'] . '/languages';
2771
+		{
2772
+					$language_directories[] = $settings['base_theme_dir'] . '/languages';
2773
+		}
2541 2774
 
2542 2775
 		// Remove any duplicates.
2543 2776
 		$language_directories = array_unique($language_directories);
@@ -2546,14 +2779,18 @@  discard block
 block discarded – undo
2546 2779
 		{
2547 2780
 			// Can't look in here... doesn't exist!
2548 2781
 			if (!file_exists($language_dir))
2549
-				continue;
2782
+			{
2783
+							continue;
2784
+			}
2550 2785
 
2551 2786
 			$dir = dir($language_dir);
2552 2787
 			while ($entry = $dir->read())
2553 2788
 			{
2554 2789
 				// Only directories are interesting
2555 2790
 				if ($entry == '..' || !is_dir($dir->path . '/' . $entry))
2556
-					continue;
2791
+				{
2792
+									continue;
2793
+				}
2557 2794
 
2558 2795
 				// @todo at some point we may want to simplify that stuff (I mean scanning all the files just for index)
2559 2796
 				$file_dir = dir($dir->path . '/' . $entry);
@@ -2561,7 +2798,9 @@  discard block
 block discarded – undo
2561 2798
 				{
2562 2799
 					// Look for the index language file....
2563 2800
 					if (!preg_match('~^index\.(.+)\.php$~', $file_entry, $matches))
2564
-						continue;
2801
+					{
2802
+											continue;
2803
+					}
2565 2804
 
2566 2805
 					$languages[$matches[1]] = array(
2567 2806
 						'name' => Util::ucwords(strtr($matches[1], array('_' => ' '))),
@@ -2595,29 +2834,41 @@  discard block
 block discarded – undo
2595 2834
 
2596 2835
 	// Figure out what type of database we are using.
2597 2836
 	if (empty($db_type) || !file_exists(SOURCEDIR . '/database/Db-' . $db_type . '.class.php'))
2598
-		$db_type = 'mysql';
2837
+	{
2838
+			$db_type = 'mysql';
2839
+	}
2599 2840
 
2600 2841
 	// If we are in SSI try them first, but don't worry if it doesn't work, we have the normal username and password we can use.
2601 2842
 	if (ELK === 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd))
2602
-		$connection = elk_db_initiate($db_server, $db_name, $ssi_db_user, $ssi_db_passwd, $db_prefix, array('persist' => $db_persist, 'non_fatal' => true, 'dont_select_db' => true, 'port' => $db_port), $db_type);
2843
+	{
2844
+			$connection = elk_db_initiate($db_server, $db_name, $ssi_db_user, $ssi_db_passwd, $db_prefix, array('persist' => $db_persist, 'non_fatal' => true, 'dont_select_db' => true, 'port' => $db_port), $db_type);
2845
+	}
2603 2846
 
2604 2847
 	// Either we aren't in SSI mode, or it failed.
2605 2848
 	if (empty($connection))
2606
-		$connection = elk_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('persist' => $db_persist, 'dont_select_db' => ELK === 'SSI', 'port' => $db_port), $db_type);
2849
+	{
2850
+			$connection = elk_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('persist' => $db_persist, 'dont_select_db' => ELK === 'SSI', 'port' => $db_port), $db_type);
2851
+	}
2607 2852
 
2608 2853
 	// Safe guard here, if there isn't a valid connection lets put a stop to it.
2609 2854
 	if (!$connection)
2610
-		Errors::instance()->display_db_error();
2855
+	{
2856
+			Errors::instance()->display_db_error();
2857
+	}
2611 2858
 
2612 2859
 	// If in SSI mode fix up the prefix.
2613 2860
 	$db = database();
2614 2861
 	if (ELK === 'SSI')
2615
-		$db_prefix = $db->fix_prefix($db_prefix, $db_name);
2862
+	{
2863
+			$db_prefix = $db->fix_prefix($db_prefix, $db_name);
2864
+	}
2616 2865
 
2617 2866
 	// Case sensitive database? Let's define a constant.
2618 2867
 	if ($db->db_case_sensitive() && !defined('DB_CASE_SENSITIVE'))
2619
-		DEFINE('DB_CASE_SENSITIVE', '1');
2620
-}
2868
+	{
2869
+			DEFINE('DB_CASE_SENSITIVE', '1');
2870
+	}
2871
+	}
2621 2872
 
2622 2873
 /**
2623 2874
  * Determine the user's avatar type and return the information as an array
@@ -2634,7 +2885,9 @@  discard block
 block discarded – undo
2634 2885
 	global $modSettings, $scripturl, $settings;
2635 2886
 
2636 2887
 	if (empty($profile))
2637
-		return array();
2888
+	{
2889
+			return array();
2890
+	}
2638 2891
 
2639 2892
 	$avatar_protocol = empty($profile['avatar']) ? '' : strtolower(substr($profile['avatar'], 0, 7));
2640 2893
 
@@ -2712,13 +2965,14 @@  discard block
 block discarded – undo
2712 2965
 		}
2713 2966
 	}
2714 2967
 	// finally ...
2715
-	else
2716
-		$avatar = array(
2968
+	else {
2969
+			$avatar = array(
2717 2970
 			'name' => '',
2718 2971
 			'image' => '',
2719 2972
 			'href' => '',
2720 2973
 			'url' => ''
2721 2974
 		);
2975
+	}
2722 2976
 
2723 2977
 	// Make sure there's a preview for gravatars available.
2724 2978
 	$avatar['gravatar_preview'] = $gravatar;
@@ -2804,7 +3058,9 @@  discard block
 block discarded – undo
2804 3058
 		}
2805 3059
 
2806 3060
 		if (checkSecurityFiles())
2807
-			$show_warnings = true;
3061
+		{
3062
+					$show_warnings = true;
3063
+		}
2808 3064
 
2809 3065
 		// We are already checking so many files...just few more doesn't make any difference! :P
2810 3066
 		require_once(SUBSDIR . '/Attachments.subs.php');
@@ -2814,11 +3070,15 @@  discard block
 block discarded – undo
2814 3070
 
2815 3071
 		// Active admin session?
2816 3072
 		if (isAdminSessionActive())
2817
-			$context['warning_controls']['admin_session'] = sprintf($txt['admin_session_active'], ($scripturl . '?action=admin;area=adminlogoff;redir;' . $context['session_var'] . '=' . $context['session_id']));
3073
+		{
3074
+					$context['warning_controls']['admin_session'] = sprintf($txt['admin_session_active'], ($scripturl . '?action=admin;area=adminlogoff;redir;' . $context['session_var'] . '=' . $context['session_id']));
3075
+		}
2818 3076
 
2819 3077
 		// Maintenance mode enabled?
2820 3078
 		if (!empty($maintenance))
2821
-			$context['warning_controls']['maintenance'] = sprintf($txt['admin_maintenance_active'], ($scripturl . '?action=admin;area=serversettings;' . $context['session_var'] . '=' . $context['session_id']));
3079
+		{
3080
+					$context['warning_controls']['maintenance'] = sprintf($txt['admin_maintenance_active'], ($scripturl . '?action=admin;area=serversettings;' . $context['session_var'] . '=' . $context['session_id']));
3081
+		}
2822 3082
 
2823 3083
 		// New updates
2824 3084
 		if (defined('FORUM_VERSION'))
@@ -2843,19 +3103,25 @@  discard block
 block discarded – undo
2843 3103
 			$context['security_controls_query']['title'] = $txt['query_command_denied'];
2844 3104
 			$show_warnings = true;
2845 3105
 			foreach ($_SESSION['query_command_denied'] as $command => $error)
2846
-				$context['security_controls_query']['errors'][$command] = '<pre>' . Util::htmlspecialchars($error) . '</pre>';
3106
+			{
3107
+							$context['security_controls_query']['errors'][$command] = '<pre>' . Util::htmlspecialchars($error) . '</pre>';
3108
+			}
2847 3109
 		}
2848 3110
 		else
2849 3111
 		{
2850 3112
 			$context['security_controls_query']['title'] = $txt['query_command_denied_guests'];
2851 3113
 			foreach ($_SESSION['query_command_denied'] as $command => $error)
2852
-				$context['security_controls_query']['errors'][$command] = '<pre>' . sprintf($txt['query_command_denied_guests_msg'], Util::htmlspecialchars($command)) . '</pre>';
3114
+			{
3115
+							$context['security_controls_query']['errors'][$command] = '<pre>' . sprintf($txt['query_command_denied_guests_msg'], Util::htmlspecialchars($command)) . '</pre>';
3116
+			}
2853 3117
 		}
2854 3118
 	}
2855 3119
 
2856 3120
 	// Are there any members waiting for approval?
2857 3121
 	if (allowedTo('moderate_forum') && ((!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 2) || !empty($modSettings['approveAccountDeletion'])) && !empty($modSettings['unapprovedMembers']))
2858
-		$context['warning_controls']['unapproved_members'] = sprintf($txt[$modSettings['unapprovedMembers'] == 1 ? 'approve_one_member_waiting' : 'approve_many_members_waiting'], $scripturl . '?action=admin;area=viewmembers;sa=browse;type=approve', $modSettings['unapprovedMembers']);
3122
+	{
3123
+			$context['warning_controls']['unapproved_members'] = sprintf($txt[$modSettings['unapprovedMembers'] == 1 ? 'approve_one_member_waiting' : 'approve_many_members_waiting'], $scripturl . '?action=admin;area=viewmembers;sa=browse;type=approve', $modSettings['unapprovedMembers']);
3124
+	}
2859 3125
 
2860 3126
 	if (!empty($context['open_mod_reports']) && (empty($user_settings['mod_prefs']) || $user_settings['mod_prefs'][0] == 1))
2861 3127
 	{
@@ -2876,18 +3142,25 @@  discard block
 block discarded – undo
2876 3142
 		$context['security_controls_ban']['errors']['reason'] = '';
2877 3143
 
2878 3144
 		if (!empty($_SESSION['ban']['cannot_post']['reason']))
2879
-			$context['security_controls_ban']['errors']['reason'] = $_SESSION['ban']['cannot_post']['reason'];
3145
+		{
3146
+					$context['security_controls_ban']['errors']['reason'] = $_SESSION['ban']['cannot_post']['reason'];
3147
+		}
2880 3148
 
2881 3149
 		if (!empty($_SESSION['ban']['expire_time']))
2882
-			$context['security_controls_ban']['errors']['reason'] .= '<span class="smalltext">' . sprintf($txt['your_ban_expires'], standardTime($_SESSION['ban']['expire_time'], false)) . '</span>';
2883
-		else
2884
-			$context['security_controls_ban']['errors']['reason'] .= '<span class="smalltext">' . $txt['your_ban_expires_never'] . '</span>';
3150
+		{
3151
+					$context['security_controls_ban']['errors']['reason'] .= '<span class="smalltext">' . sprintf($txt['your_ban_expires'], standardTime($_SESSION['ban']['expire_time'], false)) . '</span>';
3152
+		}
3153
+		else {
3154
+					$context['security_controls_ban']['errors']['reason'] .= '<span class="smalltext">' . $txt['your_ban_expires_never'] . '</span>';
3155
+		}
2885 3156
 	}
2886 3157
 
2887 3158
 	// Finally, let's show the layer.
2888 3159
 	if ($show_warnings || !empty($context['warning_controls']))
2889
-		\Template_Layers::instance()->addAfter('admin_warning', 'body');
2890
-}
3160
+	{
3161
+			\Template_Layers::instance()->addAfter('admin_warning', 'body');
3162
+	}
3163
+	}
2891 3164
 
2892 3165
 /**
2893 3166
  * Load everything necessary for the BBC parsers
@@ -2900,9 +3173,12 @@  discard block
 block discarded – undo
2900 3173
 	if (!empty($modSettings['disabledBBC']))
2901 3174
 	{
2902 3175
 		if (!is_array($modSettings['disabledBBC']))
2903
-			$disabledBBC = explode(',', $modSettings['disabledBBC']);
2904
-		else
2905
-			$disabledBBC = $modSettings['disabledBBC'];
3176
+		{
3177
+					$disabledBBC = explode(',', $modSettings['disabledBBC']);
3178
+		}
3179
+		else {
3180
+					$disabledBBC = $modSettings['disabledBBC'];
3181
+		}
2906 3182
 		\BBC\ParserWrapper::instance()->setDisabled(empty($disabledBBC) ? array() : (array) $disabledBBC);
2907 3183
 	}
2908 3184
 
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 
204 204
 	if (empty($id_member) && isset($_COOKIE[$cookiename]))
205 205
 	{
206
-		list ($id_member, $password) = serializeToJson($_COOKIE[$cookiename], function ($array_from) use ($cookiename) {
206
+		list ($id_member, $password) = serializeToJson($_COOKIE[$cookiename], function($array_from) use ($cookiename) {
207 207
 			global $modSettings;
208 208
 
209 209
 			require_once(SUBSDIR . '/Auth.subs.php');
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 	elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && (!empty($modSettings['disableCheckUA']) || (!empty($_SESSION['USER_AGENT']) && $_SESSION['USER_AGENT'] == $req->user_agent())))
216 216
 	{
217 217
 		// @todo Perhaps we can do some more checking on this, such as on the first octet of the IP?
218
-		list ($id_member, $password, $login_span) = serializeToJson($_SESSION['login_' . $cookiename], function ($array_from) use ($cookiename) {
218
+		list ($id_member, $password, $login_span) = serializeToJson($_SESSION['login_' . $cookiename], function($array_from) use ($cookiename) {
219 219
 			$_SESSION['login_' . $cookiename] = json_encode($array_from);
220 220
 		});
221 221
 		$id_member = !empty($id_member) && strlen($password) == 64 && $login_span > time() ? (int) $id_member : 0;
@@ -1518,7 +1518,7 @@  discard block
 block discarded – undo
1518 1518
 	// Set up some additional interface preference context
1519 1519
 	if (!empty($options['admin_preferences']))
1520 1520
 	{
1521
-		$context['admin_preferences'] = serializeToJson($options['admin_preferences'], function ($array_form) {
1521
+		$context['admin_preferences'] = serializeToJson($options['admin_preferences'], function($array_form) {
1522 1522
 			global $context;
1523 1523
 
1524 1524
 			$context['admin_preferences'] = $array_form;
@@ -1535,7 +1535,7 @@  discard block
 block discarded – undo
1535 1535
 	{
1536 1536
 		if (!empty($options['minmax_preferences']))
1537 1537
 		{
1538
-			$context['minmax_preferences'] = serializeToJson($options['minmax_preferences'], function ($array_form) {
1538
+			$context['minmax_preferences'] = serializeToJson($options['minmax_preferences'], function($array_form) {
1539 1539
 				global $settings, $user_info;
1540 1540
 
1541 1541
 				// Update the option.
@@ -1931,7 +1931,7 @@  discard block
 block discarded – undo
1931 1931
 			'no_member' => 0,
1932 1932
 			'theme_guests' => $modSettings['theme_guests'],
1933 1933
 		),
1934
-		function ($row)
1934
+		function($row)
1935 1935
 		{
1936 1936
 			global $settings;
1937 1937
 
Please login to merge, or discard this patch.
sources/Debug.class.php 1 patch
Braces   +66 added lines, -24 removed lines patch added patch discarded remove patch
@@ -94,12 +94,17 @@  discard block
 block discarded – undo
94 94
 	public function add($type, $value)
95 95
 	{
96 96
 		if (!$this->_track)
97
-			return;
97
+		{
98
+					return;
99
+		}
98 100
 
99 101
 		if (is_array($value))
100
-			$this->_debugs[$type] = array_merge($this->_debugs[$type], $value);
101
-		else
102
-			$this->_debugs[$type][] = $value;
102
+		{
103
+					$this->_debugs[$type] = array_merge($this->_debugs[$type], $value);
104
+		}
105
+		else {
106
+					$this->_debugs[$type][] = $value;
107
+		}
103 108
 	}
104 109
 
105 110
 	/**
@@ -114,7 +119,9 @@  discard block
 block discarded – undo
114 119
 	public function cache($value)
115 120
 	{
116 121
 		if (!$this->_track)
117
-			return;
122
+		{
123
+					return;
124
+		}
118 125
 
119 126
 		$this->_cache_hits[] = $value;
120 127
 		$this->_cache_count++;
@@ -143,7 +150,9 @@  discard block
 block discarded – undo
143 150
 	public function db_query($value)
144 151
 	{
145 152
 		if (!$this->_track)
146
-			return;
153
+		{
154
+					return;
155
+		}
147 156
 
148 157
 		$this->_db_cache[] = $value;
149 158
 		$this->_db_count++;
@@ -157,7 +166,9 @@  discard block
 block discarded – undo
157 166
 	public function merge_db($value)
158 167
 	{
159 168
 		if (!$this->_track)
160
-			return;
169
+		{
170
+					return;
171
+		}
161 172
 
162 173
 		$this->_db_cache = array_merge($value, $this->_db_cache);
163 174
 		$this->_db_count = count($this->_db_cache) + 1;
@@ -171,7 +182,9 @@  discard block
 block discarded – undo
171 182
 	public function get_db()
172 183
 	{
173 184
 		if (!$this->_track)
174
-			return array();
185
+		{
186
+					return array();
187
+		}
175 188
 
176 189
 		return $this->_db_cache;
177 190
 	}
@@ -193,9 +206,12 @@  discard block
 block discarded – undo
193 206
 		}
194 207
 
195 208
 		if ($rusage === null)
196
-			$this->_rusage[$point] = getrusage();
197
-		else
198
-			$this->_rusage[$point] = $rusage;
209
+		{
210
+					$this->_rusage[$point] = getrusage();
211
+		}
212
+		else {
213
+					$this->_rusage[$point] = $rusage;
214
+		}
199 215
 	}
200 216
 
201 217
 	/**
@@ -231,19 +247,25 @@  discard block
 block discarded – undo
231 247
 		global $context;
232 248
 
233 249
 		if (empty($_SESSION['view_queries']))
234
-			$_SESSION['view_queries'] = 0;
250
+		{
251
+					$_SESSION['view_queries'] = 0;
252
+		}
235 253
 
236 254
 		$files = get_included_files();
237 255
 		$total_size = 0;
238 256
 		for ($i = 0, $n = count($files); $i < $n; $i++)
239 257
 		{
240 258
 			if (file_exists($files[$i]))
241
-				$total_size += filesize($files[$i]);
259
+			{
260
+							$total_size += filesize($files[$i]);
261
+			}
242 262
 			$this->add('files_included', strtr($files[$i], array(BOARDDIR => '.')));
243 263
 		}
244 264
 
245 265
 		if (!empty($this->_db_cache))
246
-			$_SESSION['debug'] = $this->_db_cache;
266
+		{
267
+					$_SESSION['debug'] = $this->_db_cache;
268
+		}
247 269
 
248 270
 		// Compute some system info, if we can
249 271
 		$this->_system['system_type'] = php_uname();
@@ -263,7 +285,9 @@  discard block
 block discarded – undo
263 285
 
264 286
 		// What tokens are active?
265 287
 		if (isset($_SESSION['token']))
266
-			$this->add('tokens', array_keys($_SESSION['token']));
288
+		{
289
+					$this->add('tokens', array_keys($_SESSION['token']));
290
+		}
267 291
 	}
268 292
 
269 293
 	/**
@@ -285,9 +309,11 @@  discard block
 block discarded – undo
285 309
 			<div id="debug_logging" class="smalltext">';
286 310
 
287 311
 		foreach ($this->_system as $key => $value)
288
-			if (!empty($value))
312
+		{
313
+					if (!empty($value))
289 314
 				echo '
290 315
 				', $txt['debug_' . $key], $value, '<br />';
316
+		}
291 317
 
292 318
 		$expandable = array('hooks', 'files_included');
293 319
 
@@ -334,7 +360,9 @@  discard block
 block discarded – undo
334 360
 				<a href="', $scripturl, '?action=viewquery" target="_blank" class="new_win">', sprintf($txt['debug_queries_used'], $this->_db_count), '</a><br />';
335 361
 
336 362
 		if ($_SESSION['view_queries'] == 1 && !empty($this->_db_cache))
337
-			$this->_show_queries();
363
+		{
364
+					$this->_show_queries();
365
+		}
338 366
 
339 367
 		// Or show/hide the querys in line with all of this data
340 368
 		echo '
@@ -402,30 +430,42 @@  discard block
 block discarded – undo
402 430
 			if ($is_select)
403 431
 			{
404 432
 				foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp)
405
-					if (strpos(trim($qq['q']), $tmp) !== false)
433
+				{
434
+									if (strpos(trim($qq['q']), $tmp) !== false)
406 435
 					{
407 436
 						$is_select = false;
437
+				}
408 438
 						break;
409 439
 					}
410 440
 			}
411 441
 			// But actual creation of the temporary tables are.
412 442
 			elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($qq['q'])) != 0)
413
-				$is_select = true;
443
+			{
444
+							$is_select = true;
445
+			}
414 446
 
415 447
 			// Make the filenames look a bit better.
416 448
 			if (isset($qq['f']))
417
-				$qq['f'] = preg_replace('~^' . preg_quote(BOARDDIR, '~') . '~', '...', $qq['f']);
449
+			{
450
+							$qq['f'] = preg_replace('~^' . preg_quote(BOARDDIR, '~') . '~', '...', $qq['f']);
451
+			}
418 452
 
419 453
 			echo '
420 454
 		<strong>', $is_select ? '<a href="' . $scripturl . '?action=viewquery;qq=' . ($q + 1) . '#qq' . $q . '" target="_blank" class="new_win">' : '', nl2br(str_replace("\t", '&nbsp;&nbsp;&nbsp;', htmlspecialchars(ltrim($qq['q'], "\n\r"), ENT_COMPAT, 'UTF-8'))) . ($is_select ? '</a></strong>' : '</strong>') . '<br />
421 455
 		&nbsp;&nbsp;&nbsp;';
422 456
 			if (!empty($qq['f']) && !empty($qq['l']))
423
-				echo sprintf($txt['debug_query_in_line'], $qq['f'], $qq['l']);
457
+			{
458
+							echo sprintf($txt['debug_query_in_line'], $qq['f'], $qq['l']);
459
+			}
424 460
 
425 461
 			if (isset($qq['s'], $qq['t']) && isset($txt['debug_query_which_took_at']))
426
-				echo sprintf($txt['debug_query_which_took_at'], round($qq['t'], 8), round($qq['s'], 8)) . '<br />';
462
+			{
463
+							echo sprintf($txt['debug_query_which_took_at'], round($qq['t'], 8), round($qq['s'], 8)) . '<br />';
464
+			}
427 465
 			elseif (isset($qq['t']))
428
-				echo sprintf($txt['debug_query_which_took'], round($qq['t'], 8)) . '<br />';
466
+			{
467
+							echo sprintf($txt['debug_query_which_took'], round($qq['t'], 8)) . '<br />';
468
+			}
429 469
 			echo '
430 470
 		<br />';
431 471
 		}
@@ -438,7 +478,9 @@  discard block
 block discarded – undo
438 478
 	public static function instance()
439 479
 	{
440 480
 		if (self::$_instance === null)
441
-			self::$_instance = new Debug();
481
+		{
482
+					self::$_instance = new Debug();
483
+		}
442 484
 
443 485
 		return self::$_instance;
444 486
 	}
Please login to merge, or discard this patch.
sources/QueryString.php 1 patch
Braces   +53 added lines, -22 removed lines patch added patch discarded remove patch
@@ -68,14 +68,18 @@  discard block
 block discarded – undo
68 68
 
69 69
 	// Check if we have done this already.
70 70
 	if (isset($expanded[$ip]))
71
-		return $expanded[$ip];
71
+	{
72
+			return $expanded[$ip];
73
+	}
72 74
 
73 75
 	// Expand the IP out.
74 76
 	$expanded_ip = explode(':', expandIPv6($ip));
75 77
 
76 78
 	$new_ip = array();
77 79
 	foreach ($expanded_ip as $int)
78
-		$new_ip[] = hexdec($int);
80
+	{
81
+			$new_ip[] = hexdec($int);
82
+	}
79 83
 
80 84
 	// Save this in case of repeated use.
81 85
 	$expanded[$ip] = $new_ip;
@@ -97,7 +101,9 @@  discard block
 block discarded – undo
97 101
 
98 102
 	// Check if we have done this already.
99 103
 	if (isset($converted[$addr]))
100
-		return $converted[$addr];
104
+	{
105
+			return $converted[$addr];
106
+	}
101 107
 
102 108
 	// Check if there are segments missing, insert if necessary.
103 109
 	if (strpos($addr, '::') !== false)
@@ -123,17 +129,22 @@  discard block
 block discarded – undo
123 129
 
124 130
 		$limit = count($part[0]) + count($part[1]);
125 131
 		for ($i = 0; $i < (8 - $limit); $i++)
126
-			array_push($missing, '0000');
132
+		{
133
+					array_push($missing, '0000');
134
+		}
127 135
 
128 136
 		$part = array_merge($part[0], $missing, $part[1]);
129 137
 	}
130
-	else
131
-		$part = explode(':', $addr);
138
+	else {
139
+			$part = explode(':', $addr);
140
+	}
132 141
 
133 142
 	// Pad each segment until it has 4 digits.
134 143
 	foreach ($part as &$p)
135
-		while (strlen($p) < 4)
144
+	{
145
+			while (strlen($p) < 4)
136 146
 			$p = '0' . $p;
147
+	}
137 148
 
138 149
 	unset($p);
139 150
 
@@ -145,10 +156,13 @@  discard block
 block discarded – undo
145 156
 
146 157
 	// Quick check to make sure the length is as expected.
147 158
 	if (!$strict_check || strlen($result) == 39)
148
-		return $result;
149
-	else
150
-		return false;
151
-}
159
+	{
160
+			return $result;
161
+	}
162
+	else {
163
+			return false;
164
+	}
165
+	}
152 166
 
153 167
 /**
154 168
  * Adds html entities to the array/variable.  Uses two underscores to guard against overloading.
@@ -168,11 +182,15 @@  discard block
 block discarded – undo
168 182
 function htmlspecialchars__recursive($var, $level = 0)
169 183
 {
170 184
 	if (!is_array($var))
171
-		return Util::htmlspecialchars($var, ENT_QUOTES);
185
+	{
186
+			return Util::htmlspecialchars($var, ENT_QUOTES);
187
+	}
172 188
 
173 189
 	// Add the htmlspecialchars to every element.
174 190
 	foreach ($var as $k => $v)
175
-		$var[$k] = $level > 25 ? null : htmlspecialchars__recursive($v, $level + 1);
191
+	{
192
+			$var[$k] = $level > 25 ? null : htmlspecialchars__recursive($v, $level + 1);
193
+	}
176 194
 
177 195
 	return $var;
178 196
 }
@@ -197,11 +215,15 @@  discard block
 block discarded – undo
197 215
 {
198 216
 	// Remove spaces (32), tabs (9), returns (13, 10, and 11), nulls (0), and hard spaces. (160)
199 217
 	if (!is_array($var))
200
-		return Util::htmltrim($var);
218
+	{
219
+			return Util::htmltrim($var);
220
+	}
201 221
 
202 222
 	// Go through all the elements and remove the whitespace.
203 223
 	foreach ($var as $k => $v)
204
-		$var[$k] = $level > 25 ? null : htmltrim__recursive($v, $level + 1);
224
+	{
225
+			$var[$k] = $level > 25 ? null : htmltrim__recursive($v, $level + 1);
226
+	}
205 227
 
206 228
 	return $var;
207 229
 }
@@ -270,15 +292,21 @@  discard block
 block discarded – undo
270 292
 
271 293
 	// If $scripturl is set to nothing, or the SID is not defined (SSI?) just quit.
272 294
 	if ($scripturl == '' || !defined('SID'))
273
-		return $buffer;
295
+	{
296
+			return $buffer;
297
+	}
274 298
 
275 299
 	// Do nothing if the session is cookied, or they are a crawler - guests are caught by redirectexit().
276 300
 	if (empty($_COOKIE) && SID != '' && !isBrowser('possibly_robot'))
277
-		$buffer = preg_replace('/(?<!<link rel="canonical" href=)"' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', '"' . $scripturl . '?' . SID . '&amp;', $buffer);
301
+	{
302
+			$buffer = preg_replace('/(?<!<link rel="canonical" href=)"' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', '"' . $scripturl . '?' . SID . '&amp;', $buffer);
303
+	}
278 304
 
279 305
 	// Debugging templates, are we?
280 306
 	elseif (isset($_GET['debug']))
281
-		$buffer = preg_replace('/(?<!<link rel="canonical" href=)"' . preg_quote($scripturl, '/') . '\\??/', '"' . $scripturl . '?debug;', $buffer);
307
+	{
308
+			$buffer = preg_replace('/(?<!<link rel="canonical" href=)"' . preg_quote($scripturl, '/') . '\\??/', '"' . $scripturl . '?debug;', $buffer);
309
+	}
282 310
 
283 311
 	// This should work even in 4.2.x, just not CGI without cgi.fix_pathinfo.
284 312
 	if (!empty($modSettings['queryless_urls']) && detectServer()->supportRewrite())
@@ -301,7 +329,10 @@  discard block
 block discarded – undo
301 329
 	global $scripturl;
302 330
 
303 331
 	if (!isBrowser('possibly_robot') && empty($_COOKIE) && defined('SID') && SID != '')
304
-		return '"' . $scripturl . '/' . strtr($matches[1], '&;=', '//,') . '.html?' . SID . (isset($matches[2]) ? $matches[2] : '') . '"';
305
-	else
306
-		return '"' . $scripturl . '/' . strtr($matches[1], '&;=', '//,') . '.html' . (isset($matches[2]) ? $matches[2] : '') . '"';
307
-}
332
+	{
333
+			return '"' . $scripturl . '/' . strtr($matches[1], '&;=', '//,') . '.html?' . SID . (isset($matches[2]) ? $matches[2] : '') . '"';
334
+	}
335
+	else {
336
+			return '"' . $scripturl . '/' . strtr($matches[1], '&;=', '//,') . '.html' . (isset($matches[2]) ? $matches[2] : '') . '"';
337
+	}
338
+	}
Please login to merge, or discard this patch.