Completed
Push — release-2.1 ( 0c47ec...0c190a )
by Jeremy
19:40 queued 12:01
created
Sources/Subs-Db-postgresql.php 1 patch
Braces   +238 added lines, -175 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Maps the implementations in this file (smf_db_function_name)
@@ -34,8 +35,8 @@  discard block
 block discarded – undo
34 35
 	global $smcFunc;
35 36
 
36 37
 	// Map some database specific functions, only do this once.
37
-	if (!isset($smcFunc['db_fetch_assoc']))
38
-		$smcFunc += array(
38
+	if (!isset($smcFunc['db_fetch_assoc'])) {
39
+			$smcFunc += array(
39 40
 			'db_query'					=> 'smf_db_query',
40 41
 			'db_quote'					=> 'smf_db_quote',
41 42
 			'db_insert'					=> 'smf_db_insert',
@@ -65,15 +66,18 @@  discard block
 block discarded – undo
65 66
 			'db_custom_order'			=> 'smf_db_custom_order',
66 67
 			'db_native_replace'			=> 'smf_db_native_replace',
67 68
 		);
69
+	}
68 70
 
69 71
 	// We are not going to make it very far without these.
70
-	if (!function_exists('pg_pconnect'))
71
-		display_db_error();
72
+	if (!function_exists('pg_pconnect')) {
73
+			display_db_error();
74
+	}
72 75
 
73
-	if (!empty($db_options['persist']))
74
-		$connection = @pg_pconnect((empty($db_server) ? '' : 'host=' . $db_server . ' ') . 'dbname=' . $db_name . ' user=\'' . $db_user . '\' password=\'' . $db_passwd . '\'' . (empty($db_options['port']) ? '' : ' port=\'' . $db_options['port'] . '\''));
75
-	else
76
-		$connection = @pg_connect((empty($db_server) ? '' : 'host=' . $db_server . ' ') . 'dbname=' . $db_name . ' user=\'' . $db_user . '\' password=\'' . $db_passwd . '\'' . (empty($db_options['port']) ? '' : ' port=\'' . $db_options['port'] . '\''));
76
+	if (!empty($db_options['persist'])) {
77
+			$connection = @pg_pconnect((empty($db_server) ? '' : 'host=' . $db_server . ' ') . 'dbname=' . $db_name . ' user=\'' . $db_user . '\' password=\'' . $db_passwd . '\'' . (empty($db_options['port']) ? '' : ' port=\'' . $db_options['port'] . '\''));
78
+	} else {
79
+			$connection = @pg_connect((empty($db_server) ? '' : 'host=' . $db_server . ' ') . 'dbname=' . $db_name . ' user=\'' . $db_user . '\' password=\'' . $db_passwd . '\'' . (empty($db_options['port']) ? '' : ' port=\'' . $db_options['port'] . '\''));
80
+	}
77 81
 
78 82
 	// Something's wrong, show an error if its fatal (which we assume it is)
79 83
 	if (!$connection)
@@ -81,15 +85,15 @@  discard block
 block discarded – undo
81 85
 		if (!empty($db_options['non_fatal']))
82 86
 		{
83 87
 			return null;
84
-		}
85
-		else
88
+		} else
86 89
 		{
87 90
 			display_db_error();
88 91
 		}
89 92
 	}
90 93
 
91
-	if (!empty($db_options['db_mb4']))
92
-		$smcFunc['db_mb4'] = (bool) $db_options['db_mb4'];
94
+	if (!empty($db_options['db_mb4'])) {
95
+			$smcFunc['db_mb4'] = (bool) $db_options['db_mb4'];
96
+	}
93 97
 
94 98
 	return $connection;
95 99
 }
@@ -136,31 +140,38 @@  discard block
 block discarded – undo
136 140
 
137 141
 	list ($values, $connection) = $db_callback;
138 142
 
139
-	if ($matches[1] === 'db_prefix')
140
-		return $db_prefix;
143
+	if ($matches[1] === 'db_prefix') {
144
+			return $db_prefix;
145
+	}
141 146
 
142
-	if (isset($user_info[$matches[1]]) && strpos($matches[1], 'query_') !== false)
143
-		return $user_info[$matches[1]];
147
+	if (isset($user_info[$matches[1]]) && strpos($matches[1], 'query_') !== false) {
148
+			return $user_info[$matches[1]];
149
+	}
144 150
 
145
-	if ($matches[1] === 'empty')
146
-		return '\'\'';
151
+	if ($matches[1] === 'empty') {
152
+			return '\'\'';
153
+	}
147 154
 
148
-	if (!isset($matches[2]))
149
-		smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__);
155
+	if (!isset($matches[2])) {
156
+			smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__);
157
+	}
150 158
 
151
-	if ($matches[1] === 'literal')
152
-		return '\'' . pg_escape_string($matches[2]) . '\'';
159
+	if ($matches[1] === 'literal') {
160
+			return '\'' . pg_escape_string($matches[2]) . '\'';
161
+	}
153 162
 
154
-	if (!isset($values[$matches[2]]))
155
-		smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__);
163
+	if (!isset($values[$matches[2]])) {
164
+			smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__);
165
+	}
156 166
 
157 167
 	$replacement = $values[$matches[2]];
158 168
 
159 169
 	switch ($matches[1])
160 170
 	{
161 171
 		case 'int':
162
-			if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement)
163
-				smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
172
+			if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) {
173
+							smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
174
+			}
164 175
 			return (string) (int) $replacement;
165 176
 		break;
166 177
 
@@ -172,65 +183,73 @@  discard block
 block discarded – undo
172 183
 		case 'array_int':
173 184
 			if (is_array($replacement))
174 185
 			{
175
-				if (empty($replacement))
176
-					smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
186
+				if (empty($replacement)) {
187
+									smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
188
+				}
177 189
 
178 190
 				foreach ($replacement as $key => $value)
179 191
 				{
180
-					if (!is_numeric($value) || (string) $value !== (string) (int) $value)
181
-						smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
192
+					if (!is_numeric($value) || (string) $value !== (string) (int) $value) {
193
+											smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
194
+					}
182 195
 
183 196
 					$replacement[$key] = (string) (int) $value;
184 197
 				}
185 198
 
186 199
 				return implode(', ', $replacement);
200
+			} else {
201
+							smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
187 202
 			}
188
-			else
189
-				smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
190 203
 
191 204
 		break;
192 205
 
193 206
 		case 'array_string':
194 207
 			if (is_array($replacement))
195 208
 			{
196
-				if (empty($replacement))
197
-					smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
209
+				if (empty($replacement)) {
210
+									smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
211
+				}
198 212
 
199
-				foreach ($replacement as $key => $value)
200
-					$replacement[$key] = sprintf('\'%1$s\'', pg_escape_string($value));
213
+				foreach ($replacement as $key => $value) {
214
+									$replacement[$key] = sprintf('\'%1$s\'', pg_escape_string($value));
215
+				}
201 216
 
202 217
 				return implode(', ', $replacement);
218
+			} else {
219
+							smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
203 220
 			}
204
-			else
205
-				smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
206 221
 		break;
207 222
 
208 223
 		case 'date':
209
-			if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1)
210
-				return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]).'::date';
211
-			else
212
-				smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
224
+			if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) {
225
+							return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]).'::date';
226
+			} else {
227
+							smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
228
+			}
213 229
 		break;
214 230
 
215 231
 		case 'time':
216
-			if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1)
217
-				return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]).'::time';
218
-			else
219
-				smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
232
+			if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) {
233
+							return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]).'::time';
234
+			} else {
235
+							smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
236
+			}
220 237
 		break;
221 238
 
222 239
 		case 'datetime':
223
-			if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1)
224
-				return 'to_timestamp('.
240
+			if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1) {
241
+							return 'to_timestamp('.
225 242
 					sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5] ,$datetime_matches[6]).
226 243
 					',\'YYYY-MM-DD HH24:MI:SS\')';
227
-			else
228
-				smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
244
+			} else {
245
+							smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
246
+			}
229 247
 		break;
230 248
 
231 249
 		case 'float':
232
-			if (!is_numeric($replacement))
233
-				smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
250
+			if (!is_numeric($replacement)) {
251
+							smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
252
+			}
234 253
 			return (string) (float) $replacement;
235 254
 		break;
236 255
 
@@ -243,31 +262,36 @@  discard block
 block discarded – undo
243 262
 		break;
244 263
 
245 264
 		case 'inet':
246
-			if ($replacement == 'null' || $replacement == '')
247
-				return 'null';
248
-			if (inet_pton($replacement) === false)
249
-				smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
265
+			if ($replacement == 'null' || $replacement == '') {
266
+							return 'null';
267
+			}
268
+			if (inet_pton($replacement) === false) {
269
+							smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
270
+			}
250 271
 			return sprintf('\'%1$s\'::inet', pg_escape_string($replacement));
251 272
 
252 273
 		case 'array_inet':
253 274
 			if (is_array($replacement))
254 275
 			{
255
-				if (empty($replacement))
256
-					smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
276
+				if (empty($replacement)) {
277
+									smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
278
+				}
257 279
 
258 280
 				foreach ($replacement as $key => $value)
259 281
 				{
260
-					if ($replacement == 'null' || $replacement == '')
261
-						$replacement[$key] = 'null';
262
-					if (!isValidIP($value))
263
-						smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
282
+					if ($replacement == 'null' || $replacement == '') {
283
+											$replacement[$key] = 'null';
284
+					}
285
+					if (!isValidIP($value)) {
286
+											smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
287
+					}
264 288
 					$replacement[$key] = sprintf('\'%1$s\'::inet', pg_escape_string($value));
265 289
 				}
266 290
 
267 291
 				return implode(', ', $replacement);
292
+			} else {
293
+							smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
268 294
 			}
269
-			else
270
-				smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
271 295
 		break;
272 296
 
273 297
 		default:
@@ -355,14 +379,16 @@  discard block
 block discarded – undo
355 379
 		),
356 380
 	);
357 381
 
358
-	if (isset($replacements[$identifier]))
359
-		$db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string);
382
+	if (isset($replacements[$identifier])) {
383
+			$db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string);
384
+	}
360 385
 
361 386
 	// Limits need to be a little different.
362 387
 	$db_string = preg_replace('~\sLIMIT\s(\d+|{int:.+}),\s*(\d+|{int:.+})\s*$~i', 'LIMIT $2 OFFSET $1', $db_string);
363 388
 
364
-	if (trim($db_string) == '')
365
-		return false;
389
+	if (trim($db_string) == '') {
390
+			return false;
391
+	}
366 392
 
367 393
 	// Comments that are allowed in a query are preg_removed.
368 394
 	static $allowed_comments_from = array(
@@ -382,8 +408,9 @@  discard block
 block discarded – undo
382 408
 	$db_count = !isset($db_count) ? 1 : $db_count + 1;
383 409
 	$db_replace_result = 0;
384 410
 
385
-	if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override']))
386
-		smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__);
411
+	if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) {
412
+			smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__);
413
+	}
387 414
 
388 415
 	if (empty($db_values['security_override']) && (!empty($db_values) || strpos($db_string, '{db_prefix}') !== false))
389 416
 	{
@@ -408,17 +435,18 @@  discard block
 block discarded – undo
408 435
 		while (true)
409 436
 		{
410 437
 			$pos = strpos($db_string_1, '\'', $pos + 1);
411
-			if ($pos === false)
412
-				break;
438
+			if ($pos === false) {
439
+							break;
440
+			}
413 441
 			$clean .= substr($db_string_1, $old_pos, $pos - $old_pos);
414 442
 
415 443
 			while (true)
416 444
 			{
417 445
 				$pos1 = strpos($db_string_1, '\'', $pos + 1);
418 446
 				$pos2 = strpos($db_string_1, '\\', $pos + 1);
419
-				if ($pos1 === false)
420
-					break;
421
-				elseif ($pos2 === false || $pos2 > $pos1)
447
+				if ($pos1 === false) {
448
+									break;
449
+				} elseif ($pos2 === false || $pos2 > $pos1)
422 450
 				{
423 451
 					$pos = $pos1;
424 452
 					break;
@@ -434,16 +462,19 @@  discard block
 block discarded – undo
434 462
 		$clean = trim(strtolower(preg_replace($allowed_comments_from, $allowed_comments_to, $clean)));
435 463
 
436 464
 		// Comments?  We don't use comments in our queries, we leave 'em outside!
437
-		if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false)
438
-			$fail = true;
465
+		if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) {
466
+					$fail = true;
467
+		}
439 468
 		// Trying to change passwords, slow us down, or something?
440
-		elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0)
441
-			$fail = true;
442
-		elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0)
443
-			$fail = true;
469
+		elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) {
470
+					$fail = true;
471
+		} elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) {
472
+					$fail = true;
473
+		}
444 474
 
445
-		if (!empty($fail) && function_exists('log_error'))
446
-			smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__);
475
+		if (!empty($fail) && function_exists('log_error')) {
476
+					smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__);
477
+		}
447 478
 	}
448 479
 
449 480
 	// Set optimize stuff
@@ -470,8 +501,9 @@  discard block
 block discarded – undo
470 501
 		list ($file, $line) = smf_db_error_backtrace('', '', 'return', __FILE__, __LINE__);
471 502
 
472 503
 		// Initialize $db_cache if not already initialized.
473
-		if (!isset($db_cache))
474
-			$db_cache = array();
504
+		if (!isset($db_cache)) {
505
+					$db_cache = array();
506
+		}
475 507
 
476 508
 		if (!empty($_SESSION['debug_redirect']))
477 509
 		{
@@ -489,12 +521,14 @@  discard block
 block discarded – undo
489 521
 
490 522
 	$db_last_result = @pg_query($connection, $db_string);
491 523
 
492
-	if ($db_last_result === false && empty($db_values['db_error_skip']))
493
-		$db_last_result = smf_db_error($db_string, $connection);
524
+	if ($db_last_result === false && empty($db_values['db_error_skip'])) {
525
+			$db_last_result = smf_db_error($db_string, $connection);
526
+	}
494 527
 
495 528
 	// Debugging.
496
-	if (isset($db_show_debug) && $db_show_debug === true)
497
-		$db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));
529
+	if (isset($db_show_debug) && $db_show_debug === true) {
530
+			$db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));
531
+	}
498 532
 
499 533
 	return $db_last_result;
500 534
 }
@@ -511,10 +545,11 @@  discard block
 block discarded – undo
511 545
 {
512 546
 	global $db_last_result, $db_replace_result;
513 547
 
514
-	if ($db_replace_result)
515
-		return $db_replace_result;
516
-	elseif ($result === null && !$db_last_result)
517
-		return 0;
548
+	if ($db_replace_result) {
549
+			return $db_replace_result;
550
+	} elseif ($result === null && !$db_last_result) {
551
+			return 0;
552
+	}
518 553
 
519 554
 	return pg_affected_rows($result === null ? $db_last_result : $result);
520 555
 }
@@ -538,8 +573,9 @@  discard block
 block discarded – undo
538 573
 		array(
539 574
 		)
540 575
 	);
541
-	if (!$request)
542
-		return false;
576
+	if (!$request) {
577
+			return false;
578
+	}
543 579
 	list ($lastID) = $smcFunc['db_fetch_row']($request);
544 580
 	$smcFunc['db_free_result']($request);
545 581
 
@@ -560,12 +596,13 @@  discard block
 block discarded – undo
560 596
 	// Decide which connection to use
561 597
 	$connection = $connection === null ? $db_connection : $connection;
562 598
 
563
-	if ($type == 'begin')
564
-		return @pg_query($connection, 'BEGIN');
565
-	elseif ($type == 'rollback')
566
-		return @pg_query($connection, 'ROLLBACK');
567
-	elseif ($type == 'commit')
568
-		return @pg_query($connection, 'COMMIT');
599
+	if ($type == 'begin') {
600
+			return @pg_query($connection, 'BEGIN');
601
+	} elseif ($type == 'rollback') {
602
+			return @pg_query($connection, 'ROLLBACK');
603
+	} elseif ($type == 'commit') {
604
+			return @pg_query($connection, 'COMMIT');
605
+	}
569 606
 
570 607
 	return false;
571 608
 }
@@ -593,19 +630,22 @@  discard block
 block discarded – undo
593 630
 	$query_error = @pg_last_error($connection);
594 631
 
595 632
 	// Log the error.
596
-	if (function_exists('log_error'))
597
-		log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n" . $db_string : ''), 'database', $file, $line);
633
+	if (function_exists('log_error')) {
634
+			log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n" . $db_string : ''), 'database', $file, $line);
635
+	}
598 636
 
599 637
 	// Nothing's defined yet... just die with it.
600
-	if (empty($context) || empty($txt))
601
-		die($query_error);
638
+	if (empty($context) || empty($txt)) {
639
+			die($query_error);
640
+	}
602 641
 
603 642
 	// Show an error message, if possible.
604 643
 	$context['error_title'] = $txt['database_error'];
605
-	if (allowedTo('admin_forum'))
606
-		$context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line;
607
-	else
608
-		$context['error_message'] = $txt['try_again'];
644
+	if (allowedTo('admin_forum')) {
645
+			$context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line;
646
+	} else {
647
+			$context['error_message'] = $txt['try_again'];
648
+	}
609 649
 
610 650
 	if (allowedTo('admin_forum') && isset($db_show_debug) && $db_show_debug === true)
611 651
 	{
@@ -627,12 +667,14 @@  discard block
 block discarded – undo
627 667
 {
628 668
 	global $db_row_count;
629 669
 
630
-	if ($counter !== false)
631
-		return pg_fetch_row($request, $counter);
670
+	if ($counter !== false) {
671
+			return pg_fetch_row($request, $counter);
672
+	}
632 673
 
633 674
 	// Reset the row counter...
634
-	if (!isset($db_row_count[(int) $request]))
635
-		$db_row_count[(int) $request] = 0;
675
+	if (!isset($db_row_count[(int) $request])) {
676
+			$db_row_count[(int) $request] = 0;
677
+	}
636 678
 
637 679
 	// Return the right row.
638 680
 	return @pg_fetch_row($request, $db_row_count[(int) $request]++);
@@ -649,12 +691,14 @@  discard block
 block discarded – undo
649 691
 {
650 692
 	global $db_row_count;
651 693
 
652
-	if ($counter !== false)
653
-		return pg_fetch_assoc($request, $counter);
694
+	if ($counter !== false) {
695
+			return pg_fetch_assoc($request, $counter);
696
+	}
654 697
 
655 698
 	// Reset the row counter...
656
-	if (!isset($db_row_count[(int) $request]))
657
-		$db_row_count[(int) $request] = 0;
699
+	if (!isset($db_row_count[(int) $request])) {
700
+			$db_row_count[(int) $request] = 0;
701
+	}
658 702
 
659 703
 	// Return the right row.
660 704
 	return @pg_fetch_assoc($request, $db_row_count[(int) $request]++);
@@ -707,11 +751,13 @@  discard block
 block discarded – undo
707 751
 
708 752
 	$replace = '';
709 753
 
710
-	if (empty($data))
711
-		return;
754
+	if (empty($data)) {
755
+			return;
756
+	}
712 757
 
713
-	if (!is_array($data[array_rand($data)]))
714
-		$data = array($data);
758
+	if (!is_array($data[array_rand($data)])) {
759
+			$data = array($data);
760
+	}
715 761
 
716 762
 	// Replace the prefix holder with the actual prefix.
717 763
 	$table = str_replace('{db_prefix}', $db_prefix, $table);
@@ -737,32 +783,35 @@  discard block
 block discarded – undo
737 783
 					$key_str .= ($count_pk > 0 ? ',' : '');
738 784
 					$key_str .= $columnName;
739 785
 					$count_pk++;
740
-				}
741
-				else if ($method == 'replace') //normal field
786
+				} else if ($method == 'replace') {
787
+					//normal field
742 788
 				{
743 789
 					$col_str .= ($count > 0 ? ',' : '');
790
+				}
744 791
 					$col_str .= $columnName . ' = EXCLUDED.' . $columnName;
745 792
 					$count++;
746 793
 				}
747 794
 			}
748
-			if ($method == 'replace')
749
-				$replace = ' ON CONFLICT (' . $key_str . ') DO UPDATE SET ' . $col_str;
750
-			else
751
-				$replace = ' ON CONFLICT (' . $key_str . ') DO NOTHING';
752
-		}
753
-		else if ($method == 'replace')
795
+			if ($method == 'replace') {
796
+							$replace = ' ON CONFLICT (' . $key_str . ') DO UPDATE SET ' . $col_str;
797
+			} else {
798
+							$replace = ' ON CONFLICT (' . $key_str . ') DO NOTHING';
799
+			}
800
+		} else if ($method == 'replace')
754 801
 		{
755 802
 			foreach ($columns as $columnName => $type)
756 803
 			{
757 804
 				// Are we restricting the length?
758
-				if (strpos($type, 'string-') !== false)
759
-					$actualType = sprintf($columnName . ' = SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $count);
760
-				else
761
-					$actualType = sprintf($columnName . ' = {%1$s:%2$s}, ', $type, $count);
805
+				if (strpos($type, 'string-') !== false) {
806
+									$actualType = sprintf($columnName . ' = SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $count);
807
+				} else {
808
+									$actualType = sprintf($columnName . ' = {%1$s:%2$s}, ', $type, $count);
809
+				}
762 810
 
763 811
 				// A key? That's what we were looking for.
764
-				if (in_array($columnName, $keys))
765
-					$where .= (empty($where) ? '' : ' AND ') . substr($actualType, 0, -2);
812
+				if (in_array($columnName, $keys)) {
813
+									$where .= (empty($where) ? '' : ' AND ') . substr($actualType, 0, -2);
814
+				}
766 815
 				$count++;
767 816
 			}
768 817
 
@@ -798,10 +847,11 @@  discard block
 block discarded – undo
798 847
 		foreach ($columns as $columnName => $type)
799 848
 		{
800 849
 			// Are we restricting the length?
801
-			if (strpos($type, 'string-') !== false)
802
-				$insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName);
803
-			else
804
-				$insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName);
850
+			if (strpos($type, 'string-') !== false) {
851
+							$insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName);
852
+			} else {
853
+							$insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName);
854
+			}
805 855
 		}
806 856
 		$insertData = substr($insertData, 0, -2) . ')';
807 857
 
@@ -810,8 +860,9 @@  discard block
 block discarded – undo
810 860
 
811 861
 		// Here's where the variables are injected to the query.
812 862
 		$insertRows = array();
813
-		foreach ($data as $dataRow)
814
-			$insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection);
863
+		foreach ($data as $dataRow) {
864
+					$insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection);
865
+		}
815 866
 
816 867
 		// Do the insert.
817 868
 		$request = $smcFunc['db_query']('', '
@@ -828,19 +879,21 @@  discard block
 block discarded – undo
828 879
 
829 880
 		if ($with_returning && $request !== false)
830 881
 		{
831
-			if ($returnmode === 2)
832
-				$return_var = array();
882
+			if ($returnmode === 2) {
883
+							$return_var = array();
884
+			}
833 885
 
834 886
 			while(($row = $smcFunc['db_fetch_row']($request)) && $with_returning)
835 887
 			{
836
-				if (is_numeric($row[0])) // try to emulate mysql limitation
888
+				if (is_numeric($row[0])) {
889
+					// try to emulate mysql limitation
837 890
 				{
838 891
 					if ($returnmode === 1)
839 892
 						$return_var = $row[0];
840
-					elseif ($returnmode === 2)
841
-						$return_var[] = $row[0];
842
-				}
843
-				else
893
+				} elseif ($returnmode === 2) {
894
+											$return_var[] = $row[0];
895
+					}
896
+				} else
844 897
 				{
845 898
 					$with_returning = false;
846 899
 					trigger_error('trying to returning ID Field which is not a Int field', E_USER_ERROR);
@@ -849,9 +902,10 @@  discard block
 block discarded – undo
849 902
 		}
850 903
 	}
851 904
 
852
-	if ($with_returning && !empty($return_var))
853
-		return $return_var;
854
-}
905
+	if ($with_returning && !empty($return_var)) {
906
+			return $return_var;
907
+	}
908
+	}
855 909
 
856 910
 /**
857 911
  * Dummy function really. Doesn't do anything on PostgreSQL.
@@ -888,8 +942,9 @@  discard block
 block discarded – undo
888 942
  */
889 943
 function smf_db_error_backtrace($error_message, $log_message = '', $error_type = false, $file = null, $line = null)
890 944
 {
891
-	if (empty($log_message))
892
-		$log_message = $error_message;
945
+	if (empty($log_message)) {
946
+			$log_message = $error_message;
947
+	}
893 948
 
894 949
 	foreach (debug_backtrace() as $step)
895 950
 	{
@@ -908,12 +963,14 @@  discard block
 block discarded – undo
908 963
 	}
909 964
 
910 965
 	// A special case - we want the file and line numbers for debugging.
911
-	if ($error_type == 'return')
912
-		return array($file, $line);
966
+	if ($error_type == 'return') {
967
+			return array($file, $line);
968
+	}
913 969
 
914 970
 	// Is always a critical error.
915
-	if (function_exists('log_error'))
916
-		log_error($log_message, 'critical', $file, $line);
971
+	if (function_exists('log_error')) {
972
+			log_error($log_message, 'critical', $file, $line);
973
+	}
917 974
 
918 975
 	if (function_exists('fatal_error'))
919 976
 	{
@@ -921,12 +978,12 @@  discard block
 block discarded – undo
921 978
 
922 979
 		// Cannot continue...
923 980
 		exit;
981
+	} elseif ($error_type) {
982
+			trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type);
983
+	} else {
984
+			trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''));
985
+	}
924 986
 	}
925
-	elseif ($error_type)
926
-		trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type);
927
-	else
928
-		trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''));
929
-}
930 987
 
931 988
 /**
932 989
  * Escape the LIKE wildcards so that they match the character and not the wildcard.
@@ -943,10 +1000,11 @@  discard block
 block discarded – undo
943 1000
 		'\\' => '\\\\',
944 1001
 	);
945 1002
 
946
-	if ($translate_human_wildcards)
947
-		$replacements += array(
1003
+	if ($translate_human_wildcards) {
1004
+			$replacements += array(
948 1005
 			'*' => '%',
949 1006
 		);
1007
+	}
950 1008
 
951 1009
 	return strtr($string, $replacements);
952 1010
 }
@@ -975,14 +1033,16 @@  discard block
 block discarded – undo
975 1033
 	static $pg_error_data_prep;
976 1034
 
977 1035
 	// without database we can't do anything
978
-	if (empty($db_connection))
979
-		return;
1036
+	if (empty($db_connection)) {
1037
+			return;
1038
+	}
980 1039
 
981
-	if (empty($pg_error_data_prep))
982
-			$pg_error_data_prep = pg_prepare($db_connection, 'smf_log_errors',
1040
+	if (empty($pg_error_data_prep)) {
1041
+				$pg_error_data_prep = pg_prepare($db_connection, 'smf_log_errors',
983 1042
 				'INSERT INTO ' . $db_prefix . 'log_errors(id_member, log_time, ip, url, message, session, error_type, file, line, backtrace)
984 1043
 													VALUES(		$1,		$2,		$3, $4, 	$5,		$6,			$7,		$8,	$9, $10)'
985 1044
 			);
1045
+	}
986 1046
 
987 1047
 	pg_execute($db_connection, 'smf_log_errors', $error_array);
988 1048
 }
@@ -1002,8 +1062,9 @@  discard block
 block discarded – undo
1002 1062
 	$count = count($array_values);
1003 1063
 	$then = ($desc ? ' THEN -' : ' THEN ');
1004 1064
 
1005
-	for ($i = 0; $i < $count; $i++)
1006
-		$return .= 'WHEN ' . (int) $array_values[$i] . $then . $i . ' ';
1065
+	for ($i = 0; $i < $count; $i++) {
1066
+			$return .= 'WHEN ' . (int) $array_values[$i] . $then . $i . ' ';
1067
+	}
1007 1068
 
1008 1069
 	$return .= 'END';
1009 1070
 	return $return;
@@ -1026,11 +1087,13 @@  discard block
 block discarded – undo
1026 1087
 		//pg 9.5 got replace support
1027 1088
 		$pg_version = $smcFunc['db_get_version']();
1028 1089
 		// if we got a Beta Version
1029
-		if (stripos($pg_version, 'beta') !== false)
1030
-			$pg_version = substr($pg_version, 0, stripos($pg_version, 'beta')) . '.0';
1090
+		if (stripos($pg_version, 'beta') !== false) {
1091
+					$pg_version = substr($pg_version, 0, stripos($pg_version, 'beta')) . '.0';
1092
+		}
1031 1093
 		// or RC
1032
-		if (stripos($pg_version, 'rc') !== false)
1033
-			$pg_version = substr($pg_version, 0, stripos($pg_version, 'rc')) . '.0';
1094
+		if (stripos($pg_version, 'rc') !== false) {
1095
+					$pg_version = substr($pg_version, 0, stripos($pg_version, 'rc')) . '.0';
1096
+		}
1034 1097
 
1035 1098
 		$replace_support = (version_compare($pg_version, '9.5.0', '>=') ? true : false);
1036 1099
 	}
Please login to merge, or discard this patch.
Sources/ScheduledTasks.php 1 patch
Braces   +280 added lines, -203 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * This function works out what to do!
@@ -24,9 +25,9 @@  discard block
 block discarded – undo
24 25
 	global $time_start, $smcFunc;
25 26
 
26 27
 	// Special case for doing the mail queue.
27
-	if (isset($_GET['scheduled']) && $_GET['scheduled'] == 'mailq')
28
-		ReduceMailQueue();
29
-	else
28
+	if (isset($_GET['scheduled']) && $_GET['scheduled'] == 'mailq') {
29
+			ReduceMailQueue();
30
+	} else
30 31
 	{
31 32
 		$task_string = '';
32 33
 
@@ -53,18 +54,20 @@  discard block
 block discarded – undo
53 54
 
54 55
 			// How long in seconds it the gap?
55 56
 			$duration = $row['time_regularity'];
56
-			if ($row['time_unit'] == 'm')
57
-				$duration *= 60;
58
-			elseif ($row['time_unit'] == 'h')
59
-				$duration *= 3600;
60
-			elseif ($row['time_unit'] == 'd')
61
-				$duration *= 86400;
62
-			elseif ($row['time_unit'] == 'w')
63
-				$duration *= 604800;
57
+			if ($row['time_unit'] == 'm') {
58
+							$duration *= 60;
59
+			} elseif ($row['time_unit'] == 'h') {
60
+							$duration *= 3600;
61
+			} elseif ($row['time_unit'] == 'd') {
62
+							$duration *= 86400;
63
+			} elseif ($row['time_unit'] == 'w') {
64
+							$duration *= 604800;
65
+			}
64 66
 
65 67
 			// If we were really late running this task actually skip the next one.
66
-			if (time() + ($duration / 2) > $next_time)
67
-				$next_time += $duration;
68
+			if (time() + ($duration / 2) > $next_time) {
69
+							$next_time += $duration;
70
+			}
68 71
 
69 72
 			// Update it now, so no others run this!
70 73
 			$smcFunc['db_query']('', '
@@ -81,16 +84,19 @@  discard block
 block discarded – undo
81 84
 			$affected_rows = $smcFunc['db_affected_rows']();
82 85
 
83 86
 			// What kind of task are we handling?
84
-			if (!empty($row['callable']))
85
-				$task_string = $row['callable'];
87
+			if (!empty($row['callable'])) {
88
+							$task_string = $row['callable'];
89
+			}
86 90
 
87 91
 			// Default SMF task or old mods?
88
-			elseif (function_exists('scheduled_' . $row['task']))
89
-				$task_string = 'scheduled_' . $row['task'];
92
+			elseif (function_exists('scheduled_' . $row['task'])) {
93
+							$task_string = 'scheduled_' . $row['task'];
94
+			}
90 95
 
91 96
 			// One last resource, the task name.
92
-			elseif (!empty($row['task']))
93
-				$task_string = $row['task'];
97
+			elseif (!empty($row['task'])) {
98
+							$task_string = $row['task'];
99
+			}
94 100
 
95 101
 			// The function must exist or we are wasting our time, plus do some timestamp checking, and database check!
96 102
 			if (!empty($task_string) && (!isset($_GET['ts']) || $_GET['ts'] == $row['next_time']) && $affected_rows)
@@ -101,11 +107,11 @@  discard block
 block discarded – undo
101 107
 				$callable_task = call_helper($task_string, true);
102 108
 
103 109
 				// Perform the task.
104
-				if (!empty($callable_task))
105
-					$completed = call_user_func($callable_task);
106
-
107
-				else
108
-					$completed = false;
110
+				if (!empty($callable_task)) {
111
+									$completed = call_user_func($callable_task);
112
+				} else {
113
+									$completed = false;
114
+				}
109 115
 
110 116
 				// Log that we did it ;)
111 117
 				if ($completed)
@@ -138,18 +144,20 @@  discard block
 block discarded – undo
138 144
 			)
139 145
 		);
140 146
 		// No new task scheduled yet?
141
-		if ($smcFunc['db_num_rows']($request) === 0)
142
-			$nextEvent = time() + 86400;
143
-		else
144
-			list ($nextEvent) = $smcFunc['db_fetch_row']($request);
147
+		if ($smcFunc['db_num_rows']($request) === 0) {
148
+					$nextEvent = time() + 86400;
149
+		} else {
150
+					list ($nextEvent) = $smcFunc['db_fetch_row']($request);
151
+		}
145 152
 		$smcFunc['db_free_result']($request);
146 153
 
147 154
 		updateSettings(array('next_task_time' => $nextEvent));
148 155
 	}
149 156
 
150 157
 	// Shall we return?
151
-	if (!isset($_GET['scheduled']))
152
-		return true;
158
+	if (!isset($_GET['scheduled'])) {
159
+			return true;
160
+	}
153 161
 
154 162
 	// Finally, send some stuff...
155 163
 	header('expires: Mon, 26 Jul 1997 05:00:00 GMT');
@@ -181,16 +189,18 @@  discard block
 block discarded – undo
181 189
 	while ($row = $smcFunc['db_fetch_assoc']($request))
182 190
 	{
183 191
 		// If this is no longer around we'll ignore it.
184
-		if (empty($row['id_topic']))
185
-			continue;
192
+		if (empty($row['id_topic'])) {
193
+					continue;
194
+		}
186 195
 
187 196
 		// What type is it?
188
-		if ($row['id_first_msg'] && $row['id_first_msg'] == $row['id_msg'])
189
-			$type = 'topic';
190
-		elseif ($row['id_attach'])
191
-			$type = 'attach';
192
-		else
193
-			$type = 'msg';
197
+		if ($row['id_first_msg'] && $row['id_first_msg'] == $row['id_msg']) {
198
+					$type = 'topic';
199
+		} elseif ($row['id_attach']) {
200
+					$type = 'attach';
201
+		} else {
202
+					$type = 'msg';
203
+		}
194 204
 
195 205
 		// Add it to the array otherwise.
196 206
 		$notices[$row['id_board']][$type][] = array(
@@ -211,8 +221,9 @@  discard block
 block discarded – undo
211 221
 	);
212 222
 
213 223
 	// If nothing quit now.
214
-	if (empty($notices))
215
-		return true;
224
+	if (empty($notices)) {
225
+			return true;
226
+	}
216 227
 
217 228
 	// Now we need to think about finding out *who* can approve - this is hard!
218 229
 
@@ -231,14 +242,16 @@  discard block
 block discarded – undo
231 242
 	while ($row = $smcFunc['db_fetch_assoc']($request))
232 243
 	{
233 244
 		// Sorry guys, but we have to ignore guests AND members - it would be too many otherwise.
234
-		if ($row['id_group'] < 2)
235
-			continue;
245
+		if ($row['id_group'] < 2) {
246
+					continue;
247
+		}
236 248
 
237 249
 		$perms[$row['id_profile']][$row['add_deny'] ? 'add' : 'deny'][] = $row['id_group'];
238 250
 
239 251
 		// Anyone who can access has to be considered.
240
-		if ($row['add_deny'])
241
-			$addGroups[] = $row['id_group'];
252
+		if ($row['add_deny']) {
253
+					$addGroups[] = $row['id_group'];
254
+		}
242 255
 	}
243 256
 	$smcFunc['db_free_result']($request);
244 257
 
@@ -283,8 +296,9 @@  discard block
 block discarded – undo
283 296
 		if (!empty($row['mod_prefs']))
284 297
 		{
285 298
 			list(,, $pref_binary) = explode('|', $row['mod_prefs']);
286
-			if (!($pref_binary & 4))
287
-				continue;
299
+			if (!($pref_binary & 4)) {
300
+							continue;
301
+			}
288 302
 		}
289 303
 
290 304
 		$members[$row['id_member']] = array(
@@ -309,8 +323,9 @@  discard block
 block discarded – undo
309 323
 		$emailbody = '';
310 324
 
311 325
 		// Load the language file as required.
312
-		if (empty($current_language) || $current_language != $member['language'])
313
-			$current_language = loadLanguage('EmailTemplates', $member['language'], false);
326
+		if (empty($current_language) || $current_language != $member['language']) {
327
+					$current_language = loadLanguage('EmailTemplates', $member['language'], false);
328
+		}
314 329
 
315 330
 		// Loop through each notice...
316 331
 		foreach ($notices as $board => $notice)
@@ -318,29 +333,34 @@  discard block
 block discarded – undo
318 333
 			$access = false;
319 334
 
320 335
 			// Can they mod in this board?
321
-			if (isset($mods[$id][$board]))
322
-				$access = true;
336
+			if (isset($mods[$id][$board])) {
337
+							$access = true;
338
+			}
323 339
 
324 340
 			// Do the group check...
325 341
 			if (!$access && isset($perms[$profiles[$board]]['add']))
326 342
 			{
327 343
 				// They can access?!
328
-				if (array_intersect($perms[$profiles[$board]]['add'], $member['groups']))
329
-					$access = true;
344
+				if (array_intersect($perms[$profiles[$board]]['add'], $member['groups'])) {
345
+									$access = true;
346
+				}
330 347
 
331 348
 				// If they have deny rights don't consider them!
332
-				if (isset($perms[$profiles[$board]]['deny']))
333
-					if (array_intersect($perms[$profiles[$board]]['deny'], $member['groups']))
349
+				if (isset($perms[$profiles[$board]]['deny'])) {
350
+									if (array_intersect($perms[$profiles[$board]]['deny'], $member['groups']))
334 351
 						$access = false;
352
+				}
335 353
 			}
336 354
 
337 355
 			// Finally, fix it for admins!
338
-			if (in_array(1, $member['groups']))
339
-				$access = true;
356
+			if (in_array(1, $member['groups'])) {
357
+							$access = true;
358
+			}
340 359
 
341 360
 			// If they can't access it then give it a break!
342
-			if (!$access)
343
-				continue;
361
+			if (!$access) {
362
+							continue;
363
+			}
344 364
 
345 365
 			foreach ($notice as $type => $items)
346 366
 			{
@@ -348,15 +368,17 @@  discard block
 block discarded – undo
348 368
 				$emailbody .= $txt['scheduled_approval_email_' . $type] . "\n" .
349 369
 					'------------------------------------------------------' . "\n";
350 370
 
351
-				foreach ($items as $item)
352
-					$emailbody .= $item['subject'] . ' - ' . $item['href'] . "\n";
371
+				foreach ($items as $item) {
372
+									$emailbody .= $item['subject'] . ' - ' . $item['href'] . "\n";
373
+				}
353 374
 
354 375
 				$emailbody .= "\n";
355 376
 			}
356 377
 		}
357 378
 
358
-		if ($emailbody == '')
359
-			continue;
379
+		if ($emailbody == '') {
380
+					continue;
381
+		}
360 382
 
361 383
 		$replacements = array(
362 384
 			'REALNAME' => $member['name'],
@@ -397,8 +419,9 @@  discard block
 block discarded – undo
397 419
 			)
398 420
 		);
399 421
 		$members = array();
400
-		while ($row = $smcFunc['db_fetch_assoc']($request))
401
-			$members[$row['id_member']] = $row['warning'];
422
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
423
+					$members[$row['id_member']] = $row['warning'];
424
+		}
402 425
 		$smcFunc['db_free_result']($request);
403 426
 
404 427
 		// Have some members to check?
@@ -420,17 +443,18 @@  discard block
 block discarded – undo
420 443
 			while ($row = $smcFunc['db_fetch_assoc']($request))
421 444
 			{
422 445
 				// More than 24 hours ago?
423
-				if ($row['last_warning'] <= time() - 86400)
424
-					$member_changes[] = array(
446
+				if ($row['last_warning'] <= time() - 86400) {
447
+									$member_changes[] = array(
425 448
 						'id' => $row['id_recipient'],
426 449
 						'warning' => $members[$row['id_recipient']] >= $modSettings['warning_decrement'] ? $members[$row['id_recipient']] - $modSettings['warning_decrement'] : 0,
427 450
 					);
451
+				}
428 452
 			}
429 453
 			$smcFunc['db_free_result']($request);
430 454
 
431 455
 			// Have some members to change?
432
-			if (!empty($member_changes))
433
-				foreach ($member_changes as $change)
456
+			if (!empty($member_changes)) {
457
+							foreach ($member_changes as $change)
434 458
 					$smcFunc['db_query']('', '
435 459
 						UPDATE {db_prefix}members
436 460
 						SET warning = {int:warning}
@@ -440,6 +464,7 @@  discard block
 block discarded – undo
440 464
 							'id_member' => $change['id'],
441 465
 						)
442 466
 					);
467
+			}
443 468
 		}
444 469
 	}
445 470
 
@@ -519,15 +544,17 @@  discard block
 block discarded – undo
519 544
 
520 545
 		// Store this useful data!
521 546
 		$boards[$row['id_board']] = $row['id_board'];
522
-		if ($row['id_topic'])
523
-			$notify['topics'][$row['id_topic']][] = $row['id_member'];
524
-		else
525
-			$notify['boards'][$row['id_board']][] = $row['id_member'];
547
+		if ($row['id_topic']) {
548
+					$notify['topics'][$row['id_topic']][] = $row['id_member'];
549
+		} else {
550
+					$notify['boards'][$row['id_board']][] = $row['id_member'];
551
+		}
526 552
 	}
527 553
 	$smcFunc['db_free_result']($request);
528 554
 
529
-	if (empty($boards))
530
-		return true;
555
+	if (empty($boards)) {
556
+			return true;
557
+	}
531 558
 
532 559
 	// Just get the board names.
533 560
 	$request = $smcFunc['db_query']('', '
@@ -539,12 +566,14 @@  discard block
 block discarded – undo
539 566
 		)
540 567
 	);
541 568
 	$boards = array();
542
-	while ($row = $smcFunc['db_fetch_assoc']($request))
543
-		$boards[$row['id_board']] = $row['name'];
569
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
570
+			$boards[$row['id_board']] = $row['name'];
571
+	}
544 572
 	$smcFunc['db_free_result']($request);
545 573
 
546
-	if (empty($boards))
547
-		return true;
574
+	if (empty($boards)) {
575
+			return true;
576
+	}
548 577
 
549 578
 	// Get the actual topics...
550 579
 	$request = $smcFunc['db_query']('', '
@@ -564,52 +593,57 @@  discard block
 block discarded – undo
564 593
 	$types = array();
565 594
 	while ($row = $smcFunc['db_fetch_assoc']($request))
566 595
 	{
567
-		if (!isset($types[$row['note_type']][$row['id_board']]))
568
-			$types[$row['note_type']][$row['id_board']] = array(
596
+		if (!isset($types[$row['note_type']][$row['id_board']])) {
597
+					$types[$row['note_type']][$row['id_board']] = array(
569 598
 				'lines' => array(),
570 599
 				'name' => $row['board_name'],
571 600
 				'id' => $row['id_board'],
572 601
 			);
602
+		}
573 603
 
574 604
 		if ($row['note_type'] == 'reply')
575 605
 		{
576
-			if (isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]))
577
-				$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['count']++;
578
-			else
579
-				$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array(
606
+			if (isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) {
607
+							$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['count']++;
608
+			} else {
609
+							$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array(
580 610
 					'id' => $row['id_topic'],
581 611
 					'subject' => un_htmlspecialchars($row['subject']),
582 612
 					'count' => 1,
583 613
 				);
584
-		}
585
-		elseif ($row['note_type'] == 'topic')
614
+			}
615
+		} elseif ($row['note_type'] == 'topic')
586 616
 		{
587
-			if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]))
588
-				$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array(
617
+			if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) {
618
+							$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array(
589 619
 					'id' => $row['id_topic'],
590 620
 					'subject' => un_htmlspecialchars($row['subject']),
591 621
 				);
592
-		}
593
-		else
622
+			}
623
+		} else
594 624
 		{
595
-			if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]))
596
-				$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array(
625
+			if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) {
626
+							$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array(
597 627
 					'id' => $row['id_topic'],
598 628
 					'subject' => un_htmlspecialchars($row['subject']),
599 629
 					'starter' => $row['id_member_started'],
600 630
 				);
631
+			}
601 632
 		}
602 633
 
603 634
 		$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array();
604
-		if (!empty($notify['topics'][$row['id_topic']]))
605
-			$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['topics'][$row['id_topic']]);
606
-		if (!empty($notify['boards'][$row['id_board']]))
607
-			$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['boards'][$row['id_board']]);
635
+		if (!empty($notify['topics'][$row['id_topic']])) {
636
+					$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['topics'][$row['id_topic']]);
637
+		}
638
+		if (!empty($notify['boards'][$row['id_board']])) {
639
+					$types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['boards'][$row['id_board']]);
640
+		}
608 641
 	}
609 642
 	$smcFunc['db_free_result']($request);
610 643
 
611
-	if (empty($types))
612
-		return true;
644
+	if (empty($types)) {
645
+			return true;
646
+	}
613 647
 
614 648
 	// Let's load all the languages into a cache thingy.
615 649
 	$langtxt = array();
@@ -651,8 +685,9 @@  discard block
 block discarded – undo
651 685
 		$notify_types = !empty($prefs[$mid]['msg_notify_type']) ? $prefs[$mid]['msg_notify_type'] : 1;
652 686
 
653 687
 		// Did they not elect to choose this?
654
-		if ($frequency < 3 || $frequency == 4 && !$is_weekly || $frequency == 3 && $is_weekly || $notify_types == 4)
655
-			continue;
688
+		if ($frequency < 3 || $frequency == 4 && !$is_weekly || $frequency == 3 && $is_weekly || $notify_types == 4) {
689
+					continue;
690
+		}
656 691
 
657 692
 		// Right character set!
658 693
 		$context['character_set'] = empty($modSettings['global_character_set']) ? $langtxt[$lang]['char_set'] : $modSettings['global_character_set'];
@@ -668,39 +703,43 @@  discard block
 block discarded – undo
668 703
 		if (isset($types['topic']))
669 704
 		{
670 705
 			$titled = false;
671
-			foreach ($types['topic'] as $id => $board)
672
-				foreach ($board['lines'] as $topic)
706
+			foreach ($types['topic'] as $id => $board) {
707
+							foreach ($board['lines'] as $topic)
673 708
 					if (in_array($mid, $topic['members']))
674 709
 					{
675 710
 						if (!$titled)
676 711
 						{
677 712
 							$email['body'] .= "\n" . $langtxt[$lang]['new_topics'] . ':' . "\n" . '-----------------------------------------------';
713
+			}
678 714
 							$titled = true;
679 715
 						}
680 716
 						$email['body'] .= "\n" . sprintf($langtxt[$lang]['topic_lines'], $topic['subject'], $board['name']);
681 717
 					}
682
-			if ($titled)
683
-				$email['body'] .= "\n";
718
+			if ($titled) {
719
+							$email['body'] .= "\n";
720
+			}
684 721
 		}
685 722
 
686 723
 		// What about replies?
687 724
 		if (isset($types['reply']))
688 725
 		{
689 726
 			$titled = false;
690
-			foreach ($types['reply'] as $id => $board)
691
-				foreach ($board['lines'] as $topic)
727
+			foreach ($types['reply'] as $id => $board) {
728
+							foreach ($board['lines'] as $topic)
692 729
 					if (in_array($mid, $topic['members']))
693 730
 					{
694 731
 						if (!$titled)
695 732
 						{
696 733
 							$email['body'] .= "\n" . $langtxt[$lang]['new_replies'] . ':' . "\n" . '-----------------------------------------------';
734
+			}
697 735
 							$titled = true;
698 736
 						}
699 737
 						$email['body'] .= "\n" . ($topic['count'] == 1 ? sprintf($langtxt[$lang]['replies_one'], $topic['subject']) : sprintf($langtxt[$lang]['replies_many'], $topic['count'], $topic['subject']));
700 738
 					}
701 739
 
702
-			if ($titled)
703
-				$email['body'] .= "\n";
740
+			if ($titled) {
741
+							$email['body'] .= "\n";
742
+			}
704 743
 		}
705 744
 
706 745
 		// Finally, moderation actions!
@@ -709,24 +748,27 @@  discard block
 block discarded – undo
709 748
 			$titled = false;
710 749
 			foreach ($types as $note_type => $type)
711 750
 			{
712
-				if ($note_type == 'topic' || $note_type == 'reply')
713
-					continue;
751
+				if ($note_type == 'topic' || $note_type == 'reply') {
752
+									continue;
753
+				}
714 754
 
715
-				foreach ($type as $id => $board)
716
-					foreach ($board['lines'] as $topic)
755
+				foreach ($type as $id => $board) {
756
+									foreach ($board['lines'] as $topic)
717 757
 						if (in_array($mid, $topic['members']))
718 758
 						{
719 759
 							if (!$titled)
720 760
 							{
721 761
 								$email['body'] .= "\n" . $langtxt[$lang]['mod_actions'] . ':' . "\n" . '-----------------------------------------------';
762
+				}
722 763
 								$titled = true;
723 764
 							}
724 765
 							$email['body'] .= "\n" . sprintf($langtxt[$lang][$note_type], $topic['subject']);
725 766
 						}
726 767
 			}
727 768
 		}
728
-		if ($titled)
729
-			$email['body'] .= "\n";
769
+		if ($titled) {
770
+					$email['body'] .= "\n";
771
+		}
730 772
 
731 773
 		// Then just say our goodbyes!
732 774
 		$email['body'] .= "\n\n" . $txt['regards_team'];
@@ -756,8 +798,7 @@  discard block
 block discarded – undo
756 798
 				'not_daily' => 0,
757 799
 			)
758 800
 		);
759
-	}
760
-	else
801
+	} else
761 802
 	{
762 803
 		// Clear any only weekly ones, and stop us from sending daily again.
763 804
 		$smcFunc['db_query']('', '
@@ -821,16 +862,19 @@  discard block
 block discarded – undo
821 862
 	global $modSettings, $smcFunc, $sourcedir;
822 863
 
823 864
 	// Are we intending another script to be sending out the queue?
824
-	if (!empty($modSettings['mail_queue_use_cron']) && empty($force_send))
825
-		return false;
865
+	if (!empty($modSettings['mail_queue_use_cron']) && empty($force_send)) {
866
+			return false;
867
+	}
826 868
 
827 869
 	// By default send 5 at once.
828
-	if (!$number)
829
-		$number = empty($modSettings['mail_quantity']) ? 5 : $modSettings['mail_quantity'];
870
+	if (!$number) {
871
+			$number = empty($modSettings['mail_quantity']) ? 5 : $modSettings['mail_quantity'];
872
+	}
830 873
 
831 874
 	// If we came with a timestamp, and that doesn't match the next event, then someone else has beaten us.
832
-	if (isset($_GET['ts']) && $_GET['ts'] != $modSettings['mail_next_send'] && empty($force_send))
833
-		return false;
875
+	if (isset($_GET['ts']) && $_GET['ts'] != $modSettings['mail_next_send'] && empty($force_send)) {
876
+			return false;
877
+	}
834 878
 
835 879
 	// By default move the next sending on by 10 seconds, and require an affected row.
836 880
 	if (!$override_limit)
@@ -847,8 +891,9 @@  discard block
 block discarded – undo
847 891
 				'last_send' => $modSettings['mail_next_send'],
848 892
 			)
849 893
 		);
850
-		if ($smcFunc['db_affected_rows']() == 0)
851
-			return false;
894
+		if ($smcFunc['db_affected_rows']() == 0) {
895
+					return false;
896
+		}
852 897
 		$modSettings['mail_next_send'] = time() + $delay;
853 898
 	}
854 899
 
@@ -869,8 +914,9 @@  discard block
 block discarded – undo
869 914
 			$mn += $number;
870 915
 		}
871 916
 		// No more I'm afraid, return!
872
-		else
873
-			return false;
917
+		else {
918
+					return false;
919
+		}
874 920
 
875 921
 		// Reflect that we're about to send some, do it now to be safe.
876 922
 		updateSettings(array('mail_recent' => $mt . '|' . $mn));
@@ -905,14 +951,15 @@  discard block
 block discarded – undo
905 951
 	$smcFunc['db_free_result']($request);
906 952
 
907 953
 	// Delete, delete, delete!!!
908
-	if (!empty($ids))
909
-		$smcFunc['db_query']('', '
954
+	if (!empty($ids)) {
955
+			$smcFunc['db_query']('', '
910 956
 			DELETE FROM {db_prefix}mail_queue
911 957
 			WHERE id_mail IN ({array_int:mail_list})',
912 958
 			array(
913 959
 				'mail_list' => $ids,
914 960
 			)
915 961
 		);
962
+	}
916 963
 
917 964
 	// Don't believe we have any left?
918 965
 	if (count($ids) < $number)
@@ -930,11 +977,13 @@  discard block
 block discarded – undo
930 977
 		);
931 978
 	}
932 979
 
933
-	if (empty($ids))
934
-		return false;
980
+	if (empty($ids)) {
981
+			return false;
982
+	}
935 983
 
936
-	if (!empty($modSettings['mail_type']) && $modSettings['smtp_host'] != '')
937
-		require_once($sourcedir . '/Subs-Post.php');
984
+	if (!empty($modSettings['mail_type']) && $modSettings['smtp_host'] != '') {
985
+			require_once($sourcedir . '/Subs-Post.php');
986
+	}
938 987
 
939 988
 	// Send each email, yea!
940 989
 	$failed_emails = array();
@@ -954,15 +1003,17 @@  discard block
 block discarded – undo
954 1003
 
955 1004
 			// Try to stop a timeout, this would be bad...
956 1005
 			@set_time_limit(300);
957
-			if (function_exists('apache_reset_timeout'))
958
-				@apache_reset_timeout();
1006
+			if (function_exists('apache_reset_timeout')) {
1007
+							@apache_reset_timeout();
1008
+			}
1009
+		} else {
1010
+					$result = smtp_mail(array($email['to']), $email['subject'], $email['body'], $email['headers']);
959 1011
 		}
960
-		else
961
-			$result = smtp_mail(array($email['to']), $email['subject'], $email['body'], $email['headers']);
962 1012
 
963 1013
 		// Hopefully it sent?
964
-		if (!$result)
965
-			$failed_emails[] = array($email['to'], $email['body'], $email['subject'], $email['headers'], $email['send_html'], $email['time_sent'], $email['private']);
1014
+		if (!$result) {
1015
+					$failed_emails[] = array($email['to'], $email['body'], $email['subject'], $email['headers'], $email['send_html'], $email['time_sent'], $email['private']);
1016
+		}
966 1017
 	}
967 1018
 
968 1019
 	// Any emails that didn't send?
@@ -977,8 +1028,8 @@  discard block
 block discarded – undo
977 1028
 		);
978 1029
 
979 1030
 		// If we have failed to many times, tell mail to wait a bit and try again.
980
-		if ($modSettings['mail_failed_attempts'] > 5)
981
-			$smcFunc['db_query']('', '
1031
+		if ($modSettings['mail_failed_attempts'] > 5) {
1032
+					$smcFunc['db_query']('', '
982 1033
 				UPDATE {db_prefix}settings
983 1034
 				SET value = {string:next_mail_send}
984 1035
 				WHERE variable = {literal:mail_next_send}
@@ -987,6 +1038,7 @@  discard block
 block discarded – undo
987 1038
 					'next_mail_send' => time() + 60,
988 1039
 					'last_send' => $modSettings['mail_next_send'],
989 1040
 			));
1041
+		}
990 1042
 
991 1043
 		// Add our email back to the queue, manually.
992 1044
 		$smcFunc['db_insert']('insert',
@@ -999,8 +1051,8 @@  discard block
 block discarded – undo
999 1051
 		return false;
1000 1052
 	}
1001 1053
 	// We where unable to send the email, clear our failed attempts.
1002
-	elseif (!empty($modSettings['mail_failed_attempts']))
1003
-		$smcFunc['db_query']('', '
1054
+	elseif (!empty($modSettings['mail_failed_attempts'])) {
1055
+			$smcFunc['db_query']('', '
1004 1056
 			UPDATE {db_prefix}settings
1005 1057
 			SET value = {string:zero}
1006 1058
 			WHERE variable = {string:mail_failed_attempts}',
@@ -1008,6 +1060,7 @@  discard block
 block discarded – undo
1008 1060
 				'zero' => '0',
1009 1061
 				'mail_failed_attempts' => 'mail_failed_attempts',
1010 1062
 		));
1063
+	}
1011 1064
 
1012 1065
 	// Had something to send...
1013 1066
 	return true;
@@ -1024,16 +1077,18 @@  discard block
 block discarded – undo
1024 1077
 	global $modSettings, $smcFunc;
1025 1078
 
1026 1079
 	$task_query = '';
1027
-	if (!is_array($tasks))
1028
-		$tasks = array($tasks);
1080
+	if (!is_array($tasks)) {
1081
+			$tasks = array($tasks);
1082
+	}
1029 1083
 
1030 1084
 	// Actually have something passed?
1031 1085
 	if (!empty($tasks))
1032 1086
 	{
1033
-		if (!isset($tasks[0]) || is_numeric($tasks[0]))
1034
-			$task_query = ' AND id_task IN ({array_int:tasks})';
1035
-		else
1036
-			$task_query = ' AND task IN ({array_string:tasks})';
1087
+		if (!isset($tasks[0]) || is_numeric($tasks[0])) {
1088
+					$task_query = ' AND id_task IN ({array_int:tasks})';
1089
+		} else {
1090
+					$task_query = ' AND task IN ({array_string:tasks})';
1091
+		}
1037 1092
 	}
1038 1093
 	$nextTaskTime = empty($tasks) ? time() + 86400 : $modSettings['next_task_time'];
1039 1094
 
@@ -1054,20 +1109,22 @@  discard block
 block discarded – undo
1054 1109
 		$next_time = next_time($row['time_regularity'], $row['time_unit'], $row['time_offset']);
1055 1110
 
1056 1111
 		// Only bother moving the task if it's out of place or we're forcing it!
1057
-		if ($forceUpdate || $next_time < $row['next_time'] || $row['next_time'] < time())
1058
-			$tasks[$row['id_task']] = $next_time;
1059
-		else
1060
-			$next_time = $row['next_time'];
1112
+		if ($forceUpdate || $next_time < $row['next_time'] || $row['next_time'] < time()) {
1113
+					$tasks[$row['id_task']] = $next_time;
1114
+		} else {
1115
+					$next_time = $row['next_time'];
1116
+		}
1061 1117
 
1062 1118
 		// If this is sooner than the current next task, make this the next task.
1063
-		if ($next_time < $nextTaskTime)
1064
-			$nextTaskTime = $next_time;
1119
+		if ($next_time < $nextTaskTime) {
1120
+					$nextTaskTime = $next_time;
1121
+		}
1065 1122
 	}
1066 1123
 	$smcFunc['db_free_result']($request);
1067 1124
 
1068 1125
 	// Now make the changes!
1069
-	foreach ($tasks as $id => $time)
1070
-		$smcFunc['db_query']('', '
1126
+	foreach ($tasks as $id => $time) {
1127
+			$smcFunc['db_query']('', '
1071 1128
 			UPDATE {db_prefix}scheduled_tasks
1072 1129
 			SET next_time = {int:next_time}
1073 1130
 			WHERE id_task = {int:id_task}',
@@ -1076,11 +1133,13 @@  discard block
 block discarded – undo
1076 1133
 				'id_task' => $id,
1077 1134
 			)
1078 1135
 		);
1136
+	}
1079 1137
 
1080 1138
 	// If the next task is now different update.
1081
-	if ($modSettings['next_task_time'] != $nextTaskTime)
1082
-		updateSettings(array('next_task_time' => $nextTaskTime));
1083
-}
1139
+	if ($modSettings['next_task_time'] != $nextTaskTime) {
1140
+			updateSettings(array('next_task_time' => $nextTaskTime));
1141
+	}
1142
+	}
1084 1143
 
1085 1144
 /**
1086 1145
  * Simply returns a time stamp of the next instance of these time parameters.
@@ -1093,8 +1152,9 @@  discard block
 block discarded – undo
1093 1152
 function next_time($regularity, $unit, $offset)
1094 1153
 {
1095 1154
 	// Just in case!
1096
-	if ($regularity == 0)
1097
-		$regularity = 2;
1155
+	if ($regularity == 0) {
1156
+			$regularity = 2;
1157
+	}
1098 1158
 
1099 1159
 	$curMin = date('i', time());
1100 1160
 
@@ -1104,15 +1164,16 @@  discard block
 block discarded – undo
1104 1164
 		$off = date('i', $offset);
1105 1165
 
1106 1166
 		// If it's now just pretend it ain't,
1107
-		if ($off == $curMin)
1108
-			$next_time = time() + $regularity;
1109
-		else
1167
+		if ($off == $curMin) {
1168
+					$next_time = time() + $regularity;
1169
+		} else
1110 1170
 		{
1111 1171
 			// Make sure that the offset is always in the past.
1112 1172
 			$off = $off > $curMin ? $off - 60 : $off;
1113 1173
 
1114
-			while ($off <= $curMin)
1115
-				$off += $regularity;
1174
+			while ($off <= $curMin) {
1175
+							$off += $regularity;
1176
+			}
1116 1177
 
1117 1178
 			// Now we know when the time should be!
1118 1179
 			$next_time = time() + 60 * ($off - $curMin);
@@ -1132,11 +1193,13 @@  discard block
 block discarded – undo
1132 1193
 		// Default we'll jump in hours.
1133 1194
 		$applyOffset = 3600;
1134 1195
 		// 24 hours = 1 day.
1135
-		if ($unit == 'd')
1136
-			$applyOffset = 86400;
1196
+		if ($unit == 'd') {
1197
+					$applyOffset = 86400;
1198
+		}
1137 1199
 		// Otherwise a week.
1138
-		if ($unit == 'w')
1139
-			$applyOffset = 604800;
1200
+		if ($unit == 'w') {
1201
+					$applyOffset = 604800;
1202
+		}
1140 1203
 
1141 1204
 		$applyOffset *= $regularity;
1142 1205
 
@@ -1173,8 +1236,9 @@  discard block
 block discarded – undo
1173 1236
 		$settings[$row['variable']] = $row['value'];
1174 1237
 
1175 1238
 		// Is this the default theme?
1176
-		if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1')
1177
-			$settings['default_' . $row['variable']] = $row['value'];
1239
+		if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1') {
1240
+					$settings['default_' . $row['variable']] = $row['value'];
1241
+		}
1178 1242
 	}
1179 1243
 	$smcFunc['db_free_result']($result);
1180 1244
 
@@ -1184,12 +1248,14 @@  discard block
 block discarded – undo
1184 1248
 		$settings['template_dirs'] = array($settings['theme_dir']);
1185 1249
 
1186 1250
 		// Based on theme (if there is one).
1187
-		if (!empty($settings['base_theme_dir']))
1188
-			$settings['template_dirs'][] = $settings['base_theme_dir'];
1251
+		if (!empty($settings['base_theme_dir'])) {
1252
+					$settings['template_dirs'][] = $settings['base_theme_dir'];
1253
+		}
1189 1254
 
1190 1255
 		// Lastly the default theme.
1191
-		if ($settings['theme_dir'] != $settings['default_theme_dir'])
1192
-			$settings['template_dirs'][] = $settings['default_theme_dir'];
1256
+		if ($settings['theme_dir'] != $settings['default_theme_dir']) {
1257
+					$settings['template_dirs'][] = $settings['default_theme_dir'];
1258
+		}
1193 1259
 	}
1194 1260
 
1195 1261
 	// Assume we want this.
@@ -1333,8 +1399,9 @@  discard block
 block discarded – undo
1333 1399
 	// Ok should we prune the logs?
1334 1400
 	if (!empty($modSettings['pruningOptions']))
1335 1401
 	{
1336
-		if (!empty($modSettings['pruningOptions']) && strpos($modSettings['pruningOptions'], ',') !== false)
1337
-			list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']);
1402
+		if (!empty($modSettings['pruningOptions']) && strpos($modSettings['pruningOptions'], ',') !== false) {
1403
+					list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']);
1404
+		}
1338 1405
 
1339 1406
 		if (!empty($modSettings['pruneErrorLog']))
1340 1407
 		{
@@ -1400,8 +1467,9 @@  discard block
 block discarded – undo
1400 1467
 				)
1401 1468
 			);
1402 1469
 
1403
-			while ($row = $smcFunc['db_fetch_row']($result))
1404
-				$reports[] = $row[0];
1470
+			while ($row = $smcFunc['db_fetch_row']($result)) {
1471
+							$reports[] = $row[0];
1472
+			}
1405 1473
 
1406 1474
 			$smcFunc['db_free_result']($result);
1407 1475
 
@@ -1486,8 +1554,9 @@  discard block
 block discarded – undo
1486 1554
 	);
1487 1555
 
1488 1556
 	// Run Cache housekeeping
1489
-	if (!empty($cache_enable) && !empty($cacheAPI))
1490
-		$cacheAPI->housekeeping();
1557
+	if (!empty($cache_enable) && !empty($cacheAPI)) {
1558
+			$cacheAPI->housekeeping();
1559
+	}
1491 1560
 
1492 1561
 	// Prevent stale minimized CSS and JavaScript from cluttering up the theme directories
1493 1562
 	deleteAllMinified();
@@ -1570,8 +1639,9 @@  discard block
 block discarded – undo
1570 1639
 		$emaildata = loadEmailTemplate('paid_subscription_reminder', $replacements, empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']);
1571 1640
 
1572 1641
 		// Send the actual email.
1573
-		if ($notifyPrefs[$row['id_member']] & 0x02)
1574
-			sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], null, 'paid_sub_remind', $emaildata['is_html'], 2);
1642
+		if ($notifyPrefs[$row['id_member']] & 0x02) {
1643
+					sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], null, 'paid_sub_remind', $emaildata['is_html'], 2);
1644
+		}
1575 1645
 
1576 1646
 		if ($notifyPrefs[$row['id_member']] & 0x01)
1577 1647
 		{
@@ -1594,18 +1664,19 @@  discard block
 block discarded – undo
1594 1664
 	}
1595 1665
 
1596 1666
 	// Insert the alerts if any
1597
-	if (!empty($alert_rows))
1598
-		$smcFunc['db_insert']('',
1667
+	if (!empty($alert_rows)) {
1668
+			$smcFunc['db_insert']('',
1599 1669
 			'{db_prefix}user_alerts',
1600 1670
 			array('alert_time' => 'int', 'id_member' => 'int', 'id_member_started' => 'int', 'member_name' => 'string',
1601 1671
 				'content_type' => 'string', 'content_id' => 'int', 'content_action' => 'string', 'is_read' => 'int', 'extra' => 'string'),
1602 1672
 			$alert_rows,
1603 1673
 			array()
1604 1674
 		);
1675
+	}
1605 1676
 
1606 1677
 	// Mark the reminder as sent.
1607
-	if (!empty($subs_reminded))
1608
-		$smcFunc['db_query']('', '
1678
+	if (!empty($subs_reminded)) {
1679
+			$smcFunc['db_query']('', '
1609 1680
 			UPDATE {db_prefix}log_subscribed
1610 1681
 			SET reminder_sent = {int:reminder_sent}
1611 1682
 			WHERE id_sublog IN ({array_int:subscription_list})',
@@ -1614,6 +1685,7 @@  discard block
 block discarded – undo
1614 1685
 				'reminder_sent' => 1,
1615 1686
 			)
1616 1687
 		);
1688
+	}
1617 1689
 
1618 1690
 	return true;
1619 1691
 }
@@ -1629,13 +1701,13 @@  discard block
 block discarded – undo
1629 1701
 	// We need to know where this thing is going.
1630 1702
 	if (!empty($modSettings['currentAttachmentUploadDir']))
1631 1703
 	{
1632
-		if (!is_array($modSettings['attachmentUploadDir']))
1633
-			$modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true);
1704
+		if (!is_array($modSettings['attachmentUploadDir'])) {
1705
+					$modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true);
1706
+		}
1634 1707
 
1635 1708
 		// Just use the current path for temp files.
1636 1709
 		$attach_dirs = $modSettings['attachmentUploadDir'];
1637
-	}
1638
-	else
1710
+	} else
1639 1711
 	{
1640 1712
 		$attach_dirs = array($modSettings['attachmentUploadDir']);
1641 1713
 	}
@@ -1654,14 +1726,16 @@  discard block
 block discarded – undo
1654 1726
 
1655 1727
 		while ($file = readdir($dir))
1656 1728
 		{
1657
-			if ($file == '.' || $file == '..')
1658
-				continue;
1729
+			if ($file == '.' || $file == '..') {
1730
+							continue;
1731
+			}
1659 1732
 
1660 1733
 			if (strpos($file, 'post_tmp_') !== false)
1661 1734
 			{
1662 1735
 				// Temp file is more than 5 hours old!
1663
-				if (filemtime($attach_dir . '/' . $file) < time() - 18000)
1664
-					@unlink($attach_dir . '/' . $file);
1736
+				if (filemtime($attach_dir . '/' . $file) < time() - 18000) {
1737
+									@unlink($attach_dir . '/' . $file);
1738
+				}
1665 1739
 			}
1666 1740
 		}
1667 1741
 		closedir($dir);
@@ -1694,8 +1768,9 @@  discard block
 block discarded – undo
1694 1768
 		)
1695 1769
 	);
1696 1770
 
1697
-	while ($row = $smcFunc['db_fetch_row']($request))
1698
-		$topics[] = $row[0];
1771
+	while ($row = $smcFunc['db_fetch_row']($request)) {
1772
+			$topics[] = $row[0];
1773
+	}
1699 1774
 	$smcFunc['db_free_result']($request);
1700 1775
 
1701 1776
 	// Zap, your gone
@@ -1715,8 +1790,9 @@  discard block
 block discarded – undo
1715 1790
 {
1716 1791
 	global $smcFunc, $sourcedir, $modSettings;
1717 1792
 
1718
-	if (empty($modSettings['drafts_keep_days']))
1719
-		return true;
1793
+	if (empty($modSettings['drafts_keep_days'])) {
1794
+			return true;
1795
+	}
1720 1796
 
1721 1797
 	// init
1722 1798
 	$drafts = array();
@@ -1734,8 +1810,9 @@  discard block
 block discarded – undo
1734 1810
 		)
1735 1811
 	);
1736 1812
 
1737
-	while ($row = $smcFunc['db_fetch_row']($request))
1738
-		$drafts[] = (int) $row[0];
1813
+	while ($row = $smcFunc['db_fetch_row']($request)) {
1814
+			$drafts[] = (int) $row[0];
1815
+	}
1739 1816
 	$smcFunc['db_free_result']($request);
1740 1817
 
1741 1818
 	// If we have old one, remove them
Please login to merge, or discard this patch.
Sources/tasks/CreatePost-Notify.php 1 patch
Braces   +65 added lines, -48 removed lines patch added patch discarded remove patch
@@ -73,8 +73,9 @@  discard block
 block discarded – undo
73 73
 		while ($row = $smcFunc['db_fetch_assoc']($request))
74 74
 		{
75 75
 			$groups = array_merge(array($row['id_group'], $row['id_post_group']), (empty($row['additional_groups']) ? array() : explode(',', $row['additional_groups'])));
76
-			if (!in_array(1, $groups) && count(array_intersect($groups, explode(',', $row['member_groups']))) == 0)
77
-				continue;
76
+			if (!in_array(1, $groups) && count(array_intersect($groups, explode(',', $row['member_groups']))) == 0) {
77
+							continue;
78
+			}
78 79
 
79 80
 			$members[] = $row['id_member'];
80 81
 			$watched[$row['id_member']] = $row;
@@ -82,8 +83,9 @@  discard block
 block discarded – undo
82 83
 
83 84
 		$smcFunc['db_free_result']($request);
84 85
 
85
-		if (empty($members))
86
-			return true;
86
+		if (empty($members)) {
87
+					return true;
88
+		}
87 89
 
88 90
 		$members = array_unique($members);
89 91
 		$prefs = getNotifyPrefs($members, '', true);
@@ -99,8 +101,9 @@  discard block
 block discarded – undo
99 101
 		self::handleQuoteNotifications($msgOptions, $posterOptions, $quotedMembers, $prefs, $done_members, $alert_rows);
100 102
 
101 103
 		// Save ourselves a bit of work in the big loop below
102
-		foreach ($done_members as $done_member)
103
-			unset($watched[$done_member]);
104
+		foreach ($done_members as $done_member) {
105
+					unset($watched[$done_member]);
106
+		}
104 107
 
105 108
 		// Handle rest of the notifications for watched topics and boards
106 109
 		foreach ($watched as $member => $data)
@@ -109,20 +112,23 @@  discard block
 block discarded – undo
109 112
 			$notify_types = !empty($prefs[$member]['msg_notify_type']) ? $prefs[$member]['msg_notify_type'] : 1;
110 113
 
111 114
 			// Don't send a notification if the watching member ignored the member who made the action.
112
-			if (!empty($data['pm_ignore_list']) && in_array($data['id_member_updated'], explode(',', $data['pm_ignore_list'])))
113
-			    continue;
114
-			if (!in_array($type, array('reply', 'topic')) && $notify_types == 2 && $member != $data['id_member_started'])
115
-				continue;
116
-			elseif (in_array($type, array('reply', 'topic')) && $member == $posterOptions['id'])
117
-				continue;
118
-			elseif (!in_array($type, array('reply', 'topic')) && $notify_types == 3)
119
-				continue;
120
-			elseif ($notify_types == 4)
121
-				continue;
115
+			if (!empty($data['pm_ignore_list']) && in_array($data['id_member_updated'], explode(',', $data['pm_ignore_list']))) {
116
+						    continue;
117
+			}
118
+			if (!in_array($type, array('reply', 'topic')) && $notify_types == 2 && $member != $data['id_member_started']) {
119
+							continue;
120
+			} elseif (in_array($type, array('reply', 'topic')) && $member == $posterOptions['id']) {
121
+							continue;
122
+			} elseif (!in_array($type, array('reply', 'topic')) && $notify_types == 3) {
123
+							continue;
124
+			} elseif ($notify_types == 4) {
125
+							continue;
126
+			}
122 127
 
123 128
 			if (empty($frequency) || $frequency > 2 || $data['sent']
124
-				|| (!empty($this->_details['members_only']) && !in_array($member, $this->_details['members_only'])))
125
-				continue;
129
+				|| (!empty($this->_details['members_only']) && !in_array($member, $this->_details['members_only']))) {
130
+							continue;
131
+			}
126 132
 
127 133
 			// Watched topic?
128 134
 			if (!empty($data['id_topic']) && $type != 'topic' && !empty($prefs[$member]))
@@ -132,10 +138,12 @@  discard block
 block discarded – undo
132 138
 
133 139
 				if ($type == 'reply')
134 140
 				{
135
-					if (!empty($prefs[$member]['msg_receive_body']))
136
-						$message_type .= '_body';
137
-					if (!empty($frequency))
138
-						$message_type .= '_once';
141
+					if (!empty($prefs[$member]['msg_receive_body'])) {
142
+											$message_type .= '_body';
143
+					}
144
+					if (!empty($frequency)) {
145
+											$message_type .= '_once';
146
+					}
139 147
 				}
140 148
 
141 149
 				$content_type = 'topic';
@@ -148,12 +156,14 @@  discard block
 block discarded – undo
148 156
 				$content_type = 'board';
149 157
 
150 158
 				$message_type = !empty($frequency) ? 'notify_boards_once' : 'notify_boards';
151
-				if (!empty($prefs[$member]['msg_receive_body']))
152
-					$message_type .= '_body';
159
+				if (!empty($prefs[$member]['msg_receive_body'])) {
160
+									$message_type .= '_body';
161
+				}
153 162
 			}
154 163
 			// If neither of the above, this might be a redundent row due to the OR clause in our SQL query, skip
155
-			else
156
-				continue;
164
+			else {
165
+							continue;
166
+			}
157 167
 
158 168
 			if ($pref & 0x02)
159 169
 			{
@@ -216,14 +226,15 @@  discard block
 block discarded – undo
216 226
 		);
217 227
 
218 228
 		// Insert the alerts if any
219
-		if (!empty($alert_rows))
220
-			$smcFunc['db_insert']('',
229
+		if (!empty($alert_rows)) {
230
+					$smcFunc['db_insert']('',
221 231
 				'{db_prefix}user_alerts',
222 232
 				array('alert_time' => 'int', 'id_member' => 'int', 'id_member_started' => 'int', 'member_name' => 'string',
223 233
 					'content_type' => 'string', 'content_id' => 'int', 'content_action' => 'string', 'is_read' => 'int', 'extra' => 'string'),
224 234
 				$alert_rows,
225 235
 				array()
226 236
 			);
237
+		}
227 238
 
228 239
 		return true;
229 240
 	}
@@ -234,8 +245,9 @@  discard block
 block discarded – undo
234 245
 
235 246
 		foreach ($quotedMembers as $id => $member)
236 247
 		{
237
-			if (!isset($prefs[$id]) || $id == $posterOptions['id'] || empty($prefs[$id]['msg_quote']))
238
-				continue;
248
+			if (!isset($prefs[$id]) || $id == $posterOptions['id'] || empty($prefs[$id]['msg_quote'])) {
249
+							continue;
250
+			}
239 251
 
240 252
 			$done_members[] = $id;
241 253
 
@@ -287,32 +299,35 @@  discard block
 block discarded – undo
287 299
 		{
288 300
 			if (preg_match('/\[quote(.*)?\]/i', $block, $matches))
289 301
 			{
290
-				if ($quote_level == 0)
291
-					$message .= '[quote' . $matches[1] . ']';
302
+				if ($quote_level == 0) {
303
+									$message .= '[quote' . $matches[1] . ']';
304
+				}
292 305
 				$quote_level++;
293
-			}
294
-			elseif (preg_match('/\[\/quote\]/i', $block))
306
+			} elseif (preg_match('/\[\/quote\]/i', $block))
295 307
 			{
296
-				if ($quote_level <= 1)
297
-					$message .= '[/quote]';
308
+				if ($quote_level <= 1) {
309
+									$message .= '[/quote]';
310
+				}
298 311
 				if ($quote_level >= 1)
299 312
 				{
300 313
 					$quote_level--;
301 314
 					$message .= "\n";
302 315
 				}
316
+			} elseif ($quote_level <= 1) {
317
+							$message .= $block;
303 318
 			}
304
-			elseif ($quote_level <= 1)
305
-				$message .= $block;
306 319
 		}
307 320
 
308 321
 		preg_match_all('/\[quote.*?link=msg=([0-9]+).*?\]/i', $message, $matches);
309 322
 
310 323
 		$id_msgs = $matches[1];
311
-		foreach ($id_msgs as $k => $id_msg)
312
-			$id_msgs[$k] = (int) $id_msg;
324
+		foreach ($id_msgs as $k => $id_msg) {
325
+					$id_msgs[$k] = (int) $id_msg;
326
+		}
313 327
 
314
-		if (empty($id_msgs))
315
-			return array();
328
+		if (empty($id_msgs)) {
329
+					return array();
330
+		}
316 331
 
317 332
 		// Get the messages
318 333
 		$request = $smcFunc['db_query']('', '
@@ -330,8 +345,9 @@  discard block
 block discarded – undo
330 345
 		$members = array();
331 346
 		while ($row = $smcFunc['db_fetch_assoc']($request))
332 347
 		{
333
-			if ($posterOptions['id'] == $row['id_member'])
334
-				continue;
348
+			if ($posterOptions['id'] == $row['id_member']) {
349
+							continue;
350
+			}
335 351
 
336 352
 			$members[$row['id_member']] = $row;
337 353
 		}
@@ -345,10 +361,11 @@  discard block
 block discarded – undo
345 361
 
346 362
 		foreach ($members as $id => $member)
347 363
 		{
348
-			if (!empty($prefs[$id]['msg_mention']))
349
-				$done_members[] = $id;
350
-			else
351
-				continue;
364
+			if (!empty($prefs[$id]['msg_mention'])) {
365
+							$done_members[] = $id;
366
+			} else {
367
+							continue;
368
+			}
352 369
 
353 370
 			// Alerts' emails are always instant
354 371
 			if ($prefs[$id]['msg_mention'] & 0x02)
Please login to merge, or discard this patch.
Sources/Profile-Modify.php 1 patch
Braces   +710 added lines, -533 removed lines patch added patch discarded remove patch
@@ -15,8 +15,9 @@  discard block
 block discarded – undo
15 15
  * @version 2.1 Beta 4
16 16
  */
17 17
 
18
-if (!defined('SMF'))
18
+if (!defined('SMF')) {
19 19
 	die('No direct access...');
20
+}
20 21
 
21 22
 /**
22 23
  * This defines every profile field known to man.
@@ -29,8 +30,9 @@  discard block
 block discarded – undo
29 30
 	global $sourcedir, $profile_vars;
30 31
 
31 32
 	// Don't load this twice!
32
-	if (!empty($profile_fields) && !$force_reload)
33
-		return;
33
+	if (!empty($profile_fields) && !$force_reload) {
34
+			return;
35
+	}
34 36
 
35 37
 	/* This horrific array defines all the profile fields in the whole world!
36 38
 		In general each "field" has one array - the key of which is the database column name associated with said field. Each item
@@ -103,13 +105,14 @@  discard block
 block discarded – undo
103 105
 				if (isset($_POST['bday2'], $_POST['bday3']) && $value > 0 && $_POST['bday2'] > 0)
104 106
 				{
105 107
 					// Set to blank?
106
-					if ((int) $_POST['bday3'] == 1 && (int) $_POST['bday2'] == 1 && (int) $value == 1)
107
-						$value = '1004-01-01';
108
-					else
109
-						$value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '1004-01-01';
108
+					if ((int) $_POST['bday3'] == 1 && (int) $_POST['bday2'] == 1 && (int) $value == 1) {
109
+											$value = '1004-01-01';
110
+					} else {
111
+											$value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '1004-01-01';
112
+					}
113
+				} else {
114
+									$value = '1004-01-01';
110 115
 				}
111
-				else
112
-					$value = '1004-01-01';
113 116
 
114 117
 				$profile_vars['birthdate'] = $value;
115 118
 				$cur_profile['birthdate'] = $value;
@@ -127,8 +130,7 @@  discard block
 block discarded – undo
127 130
 				{
128 131
 					$value = checkdate($dates[2], $dates[3], $dates[1] < 4 ? 4 : $dates[1]) ? sprintf('%04d-%02d-%02d', $dates[1] < 4 ? 4 : $dates[1], $dates[2], $dates[3]) : '1004-01-01';
129 132
 					return true;
130
-				}
131
-				else
133
+				} else
132 134
 				{
133 135
 					$value = empty($cur_profile['birthdate']) ? '1004-01-01' : $cur_profile['birthdate'];
134 136
 					return false;
@@ -150,10 +152,11 @@  discard block
 block discarded – undo
150 152
 					return $txt['invalid_registration'] . ' ' . strftime('%d %b %Y ' . (strpos($user_info['time_format'], '%H') !== false ? '%I:%M:%S %p' : '%H:%M:%S'), forum_time(false));
151 153
 				}
152 154
 				// As long as it doesn't equal "N/A"...
153
-				elseif ($value != $txt['not_applicable'] && $value != strtotime(strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600)))
154
-					$value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600;
155
-				else
156
-					$value = $cur_profile['date_registered'];
155
+				elseif ($value != $txt['not_applicable'] && $value != strtotime(strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600))) {
156
+									$value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600;
157
+				} else {
158
+									$value = $cur_profile['date_registered'];
159
+				}
157 160
 
158 161
 				return true;
159 162
 			},
@@ -177,8 +180,9 @@  discard block
 block discarded – undo
177 180
 			{
178 181
 				global $context, $old_profile, $profile_vars, $sourcedir, $modSettings;
179 182
 
180
-				if (strtolower($value) == strtolower($old_profile['email_address']))
181
-					return false;
183
+				if (strtolower($value) == strtolower($old_profile['email_address'])) {
184
+									return false;
185
+				}
182 186
 
183 187
 				$isValid = profileValidateEmail($value, $context['id_member']);
184 188
 
@@ -254,11 +258,11 @@  discard block
 block discarded – undo
254 258
 
255 259
 				if (isset($context['profile_languages'][$value]))
256 260
 				{
257
-					if ($context['user']['is_owner'] && empty($context['password_auth_failed']))
258
-						$_SESSION['language'] = $value;
261
+					if ($context['user']['is_owner'] && empty($context['password_auth_failed'])) {
262
+											$_SESSION['language'] = $value;
263
+					}
259 264
 					return true;
260
-				}
261
-				else
265
+				} else
262 266
 				{
263 267
 					$value = $cur_profile['lngfile'];
264 268
 					return false;
@@ -282,13 +286,14 @@  discard block
 block discarded – undo
282 286
 
283 287
 					// Maybe they are trying to change their password as well?
284 288
 					$resetPassword = true;
285
-					if (isset($_POST['passwrd1']) && $_POST['passwrd1'] != '' && isset($_POST['passwrd2']) && $_POST['passwrd1'] == $_POST['passwrd2'] && validatePassword($_POST['passwrd1'], $value, array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])) == null)
286
-						$resetPassword = false;
289
+					if (isset($_POST['passwrd1']) && $_POST['passwrd1'] != '' && isset($_POST['passwrd2']) && $_POST['passwrd1'] == $_POST['passwrd2'] && validatePassword($_POST['passwrd1'], $value, array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])) == null) {
290
+											$resetPassword = false;
291
+					}
287 292
 
288 293
 					// Do the reset... this will send them an email too.
289
-					if ($resetPassword)
290
-						resetPassword($context['id_member'], $value);
291
-					elseif ($value !== null)
294
+					if ($resetPassword) {
295
+											resetPassword($context['id_member'], $value);
296
+					} elseif ($value !== null)
292 297
 					{
293 298
 						validateUsername($context['id_member'], trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $value)));
294 299
 						updateMemberData($context['id_member'], array('member_name' => $value));
@@ -312,20 +317,23 @@  discard block
 block discarded – undo
312 317
 			'input_validate' => function(&$value) use ($sourcedir, $user_info, $smcFunc, $cur_profile)
313 318
 			{
314 319
 				// If we didn't try it then ignore it!
315
-				if ($value == '')
316
-					return false;
320
+				if ($value == '') {
321
+									return false;
322
+				}
317 323
 
318 324
 				// Do the two entries for the password even match?
319
-				if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2'])
320
-					return 'bad_new_password';
325
+				if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2']) {
326
+									return 'bad_new_password';
327
+				}
321 328
 
322 329
 				// Let's get the validation function into play...
323 330
 				require_once($sourcedir . '/Subs-Auth.php');
324 331
 				$passwordErrors = validatePassword($value, $cur_profile['member_name'], array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email']));
325 332
 
326 333
 				// Were there errors?
327
-				if ($passwordErrors != null)
328
-					return 'password_' . $passwordErrors;
334
+				if ($passwordErrors != null) {
335
+									return 'password_' . $passwordErrors;
336
+				}
329 337
 
330 338
 				// Set up the new password variable... ready for storage.
331 339
 				$value = hash_password($cur_profile['member_name'], un_htmlspecialchars($value));
@@ -350,8 +358,9 @@  discard block
 block discarded – undo
350 358
 			'permission' => 'profile_blurb',
351 359
 			'input_validate' => function(&$value) use ($smcFunc)
352 360
 			{
353
-				if ($smcFunc['strlen']($value) > 50)
354
-					return 'personal_text_too_long';
361
+				if ($smcFunc['strlen']($value) > 50) {
362
+									return 'personal_text_too_long';
363
+				}
355 364
 
356 365
 				return true;
357 366
 			},
@@ -386,10 +395,11 @@  discard block
 block discarded – undo
386 395
 			'permission' => 'moderate_forum',
387 396
 			'input_validate' => function(&$value)
388 397
 			{
389
-				if (!is_numeric($value))
390
-					return 'digits_only';
391
-				else
392
-					$value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0;
398
+				if (!is_numeric($value)) {
399
+									return 'digits_only';
400
+				} else {
401
+									$value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0;
402
+				}
393 403
 				return true;
394 404
 			},
395 405
 		),
@@ -405,15 +415,16 @@  discard block
 block discarded – undo
405 415
 			{
406 416
 				$value = trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $value));
407 417
 
408
-				if (trim($value) == '')
409
-					return 'no_name';
410
-				elseif ($smcFunc['strlen']($value) > 60)
411
-					return 'name_too_long';
412
-				elseif ($cur_profile['real_name'] != $value)
418
+				if (trim($value) == '') {
419
+									return 'no_name';
420
+				} elseif ($smcFunc['strlen']($value) > 60) {
421
+									return 'name_too_long';
422
+				} elseif ($cur_profile['real_name'] != $value)
413 423
 				{
414 424
 					require_once($sourcedir . '/Subs-Members.php');
415
-					if (isReservedName($value, $context['id_member']))
416
-						return 'name_taken';
425
+					if (isReservedName($value, $context['id_member'])) {
426
+											return 'name_taken';
427
+					}
417 428
 				}
418 429
 				return true;
419 430
 			},
@@ -471,8 +482,9 @@  discard block
 block discarded – undo
471 482
 						'selected' => $set == $context['member']['smiley_set']['id']
472 483
 					);
473 484
 
474
-					if ($context['smiley_sets'][$i]['selected'])
475
-						$context['member']['smiley_set']['name'] = $set_names[$i];
485
+					if ($context['smiley_sets'][$i]['selected']) {
486
+											$context['member']['smiley_set']['name'] = $set_names[$i];
487
+					}
476 488
 				}
477 489
 				return true;
478 490
 			},
@@ -481,8 +493,9 @@  discard block
 block discarded – undo
481 493
 				global $modSettings;
482 494
 
483 495
 				$smiley_sets = explode(',', $modSettings['smiley_sets_known']);
484
-				if (!in_array($value, $smiley_sets) && $value != 'none')
485
-					$value = '';
496
+				if (!in_array($value, $smiley_sets) && $value != 'none') {
497
+									$value = '';
498
+				}
486 499
 				return true;
487 500
 			},
488 501
 		),
@@ -497,8 +510,9 @@  discard block
 block discarded – undo
497 510
 				loadLanguage('Settings');
498 511
 
499 512
 				$context['allow_no_censored'] = false;
500
-				if ($user_info['is_admin'] || $context['user']['is_owner'])
501
-					$context['allow_no_censored'] = !empty($modSettings['allow_no_censored']);
513
+				if ($user_info['is_admin'] || $context['user']['is_owner']) {
514
+									$context['allow_no_censored'] = !empty($modSettings['allow_no_censored']);
515
+				}
502 516
 
503 517
 				return true;
504 518
 			},
@@ -545,8 +559,9 @@  discard block
 block discarded – undo
545 559
 			'input_validate' => function($value)
546 560
 			{
547 561
 				$tz = smf_list_timezones();
548
-				if (!isset($tz[$value]))
549
-					return 'bad_timezone';
562
+				if (!isset($tz[$value])) {
563
+									return 'bad_timezone';
564
+				}
550 565
 
551 566
 				return true;
552 567
 			},
@@ -561,8 +576,9 @@  discard block
 block discarded – undo
561 576
 			'enabled' => !empty($modSettings['titlesEnable']),
562 577
 			'input_validate' => function(&$value) use ($smcFunc)
563 578
 			{
564
-				if ($smcFunc['strlen']($value) > 50)
565
-					return 'user_title_too_long';
579
+				if ($smcFunc['strlen']($value) > 50) {
580
+									return 'user_title_too_long';
581
+				}
566 582
 
567 583
 				return true;
568 584
 			},
@@ -584,10 +600,12 @@  discard block
 block discarded – undo
584 600
 			// Fix the URL...
585 601
 			'input_validate' => function(&$value)
586 602
 			{
587
-				if (strlen(trim($value)) > 0 && strpos($value, '://') === false)
588
-					$value = 'http://' . $value;
589
-				if (strlen($value) < 8 || (substr($value, 0, 7) !== 'http://' && substr($value, 0, 8) !== 'https://'))
590
-					$value = '';
603
+				if (strlen(trim($value)) > 0 && strpos($value, '://') === false) {
604
+									$value = 'http://' . $value;
605
+				}
606
+				if (strlen($value) < 8 || (substr($value, 0, 7) !== 'http://' && substr($value, 0, 8) !== 'https://')) {
607
+									$value = '';
608
+				}
591 609
 				$value = (string) validate_iri(sanitize_iri($value));
592 610
 				return true;
593 611
 			},
@@ -602,16 +620,19 @@  discard block
 block discarded – undo
602 620
 	foreach ($profile_fields as $key => $field)
603 621
 	{
604 622
 		// Do we have permission to do this?
605
-		if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission']))
606
-			unset($profile_fields[$key]);
623
+		if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission'])) {
624
+					unset($profile_fields[$key]);
625
+		}
607 626
 
608 627
 		// Is it enabled?
609
-		if (isset($field['enabled']) && !$field['enabled'])
610
-			unset($profile_fields[$key]);
628
+		if (isset($field['enabled']) && !$field['enabled']) {
629
+					unset($profile_fields[$key]);
630
+		}
611 631
 
612 632
 		// Is it specifically disabled?
613
-		if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields)))
614
-			unset($profile_fields[$key]);
633
+		if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields))) {
634
+					unset($profile_fields[$key]);
635
+		}
615 636
 	}
616 637
 }
617 638
 
@@ -636,9 +657,10 @@  discard block
 block discarded – undo
636 657
 	loadProfileFields(true);
637 658
 
638 659
 	// First check for any linked sets.
639
-	foreach ($profile_fields as $key => $field)
640
-		if (isset($field['link_with']) && in_array($field['link_with'], $fields))
660
+	foreach ($profile_fields as $key => $field) {
661
+			if (isset($field['link_with']) && in_array($field['link_with'], $fields))
641 662
 			$fields[] = $key;
663
+	}
642 664
 
643 665
 	$i = 0;
644 666
 	$last_type = '';
@@ -650,38 +672,46 @@  discard block
 block discarded – undo
650 672
 			$cur_field = &$profile_fields[$field];
651 673
 
652 674
 			// Does it have a preload and does that preload succeed?
653
-			if (isset($cur_field['preload']) && !$cur_field['preload']())
654
-				continue;
675
+			if (isset($cur_field['preload']) && !$cur_field['preload']()) {
676
+							continue;
677
+			}
655 678
 
656 679
 			// If this is anything but complex we need to do more cleaning!
657 680
 			if ($cur_field['type'] != 'callback' && $cur_field['type'] != 'hidden')
658 681
 			{
659
-				if (!isset($cur_field['label']))
660
-					$cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field;
682
+				if (!isset($cur_field['label'])) {
683
+									$cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field;
684
+				}
661 685
 
662 686
 				// Everything has a value!
663
-				if (!isset($cur_field['value']))
664
-					$cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : '';
687
+				if (!isset($cur_field['value'])) {
688
+									$cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : '';
689
+				}
665 690
 
666 691
 				// Any input attributes?
667 692
 				$cur_field['input_attr'] = !empty($cur_field['input_attr']) ? implode(',', $cur_field['input_attr']) : '';
668 693
 			}
669 694
 
670 695
 			// Was there an error with this field on posting?
671
-			if (isset($context['profile_errors'][$field]))
672
-				$cur_field['is_error'] = true;
696
+			if (isset($context['profile_errors'][$field])) {
697
+							$cur_field['is_error'] = true;
698
+			}
673 699
 
674 700
 			// Any javascript stuff?
675
-			if (!empty($cur_field['js_submit']))
676
-				$context['profile_onsubmit_javascript'] .= $cur_field['js_submit'];
677
-			if (!empty($cur_field['js']))
678
-				$context['profile_javascript'] .= $cur_field['js'];
701
+			if (!empty($cur_field['js_submit'])) {
702
+							$context['profile_onsubmit_javascript'] .= $cur_field['js_submit'];
703
+			}
704
+			if (!empty($cur_field['js'])) {
705
+							$context['profile_javascript'] .= $cur_field['js'];
706
+			}
679 707
 
680 708
 			// Any template stuff?
681
-			if (!empty($cur_field['prehtml']))
682
-				$context['profile_prehtml'] .= $cur_field['prehtml'];
683
-			if (!empty($cur_field['posthtml']))
684
-				$context['profile_posthtml'] .= $cur_field['posthtml'];
709
+			if (!empty($cur_field['prehtml'])) {
710
+							$context['profile_prehtml'] .= $cur_field['prehtml'];
711
+			}
712
+			if (!empty($cur_field['posthtml'])) {
713
+							$context['profile_posthtml'] .= $cur_field['posthtml'];
714
+			}
685 715
 
686 716
 			// Finally put it into context?
687 717
 			if ($cur_field['type'] != 'hidden')
@@ -714,12 +744,14 @@  discard block
 block discarded – undo
714 744
 	}, false);' : ''), true);
715 745
 
716 746
 	// Any onsubmit javascript?
717
-	if (!empty($context['profile_onsubmit_javascript']))
718
-		addInlineJavaScript($context['profile_onsubmit_javascript'], true);
747
+	if (!empty($context['profile_onsubmit_javascript'])) {
748
+			addInlineJavaScript($context['profile_onsubmit_javascript'], true);
749
+	}
719 750
 
720 751
 	// Any totally custom stuff?
721
-	if (!empty($context['profile_javascript']))
722
-		addInlineJavaScript($context['profile_javascript'], true);
752
+	if (!empty($context['profile_javascript'])) {
753
+			addInlineJavaScript($context['profile_javascript'], true);
754
+	}
723 755
 
724 756
 	// Free up some memory.
725 757
 	unset($profile_fields);
@@ -740,8 +772,9 @@  discard block
 block discarded – undo
740 772
 
741 773
 	// This allows variables to call activities when they save - by default just to reload their settings
742 774
 	$context['profile_execute_on_save'] = array();
743
-	if ($context['user']['is_owner'])
744
-		$context['profile_execute_on_save']['reload_user'] = 'profileReloadUser';
775
+	if ($context['user']['is_owner']) {
776
+			$context['profile_execute_on_save']['reload_user'] = 'profileReloadUser';
777
+	}
745 778
 
746 779
 	// Assume we log nothing.
747 780
 	$context['log_changes'] = array();
@@ -749,8 +782,9 @@  discard block
 block discarded – undo
749 782
 	// Cycle through the profile fields working out what to do!
750 783
 	foreach ($profile_fields as $key => $field)
751 784
 	{
752
-		if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature'))
753
-			continue;
785
+		if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature')) {
786
+					continue;
787
+		}
754 788
 
755 789
 		// What gets updated?
756 790
 		$db_key = isset($field['save_key']) ? $field['save_key'] : $key;
@@ -778,12 +812,13 @@  discard block
 block discarded – undo
778 812
 		$field['cast_type'] = empty($field['cast_type']) ? $field['type'] : $field['cast_type'];
779 813
 
780 814
 		// Finally, clean up certain types.
781
-		if ($field['cast_type'] == 'int')
782
-			$_POST[$key] = (int) $_POST[$key];
783
-		elseif ($field['cast_type'] == 'float')
784
-			$_POST[$key] = (float) $_POST[$key];
785
-		elseif ($field['cast_type'] == 'check')
786
-			$_POST[$key] = !empty($_POST[$key]) ? 1 : 0;
815
+		if ($field['cast_type'] == 'int') {
816
+					$_POST[$key] = (int) $_POST[$key];
817
+		} elseif ($field['cast_type'] == 'float') {
818
+					$_POST[$key] = (float) $_POST[$key];
819
+		} elseif ($field['cast_type'] == 'check') {
820
+					$_POST[$key] = !empty($_POST[$key]) ? 1 : 0;
821
+		}
787 822
 
788 823
 		// If we got here we're doing OK.
789 824
 		if ($field['type'] != 'hidden' && (!isset($old_profile[$key]) || $_POST[$key] != $old_profile[$key]))
@@ -794,11 +829,12 @@  discard block
 block discarded – undo
794 829
 			$cur_profile[$key] = $_POST[$key];
795 830
 
796 831
 			// Are we logging it?
797
-			if (!empty($field['log_change']) && isset($old_profile[$key]))
798
-				$context['log_changes'][$key] = array(
832
+			if (!empty($field['log_change']) && isset($old_profile[$key])) {
833
+							$context['log_changes'][$key] = array(
799 834
 					'previous' => $old_profile[$key],
800 835
 					'new' => $_POST[$key],
801 836
 				);
837
+			}
802 838
 		}
803 839
 
804 840
 		// Logging group changes are a bit different...
@@ -831,10 +867,11 @@  discard block
 block discarded – undo
831 867
 				{
832 868
 					foreach ($groups as $id => $group)
833 869
 					{
834
-						if (isset($context['member_groups'][$group]))
835
-							$additional_groups[$type][$id] = $context['member_groups'][$group]['name'];
836
-						else
837
-							unset($additional_groups[$type][$id]);
870
+						if (isset($context['member_groups'][$group])) {
871
+													$additional_groups[$type][$id] = $context['member_groups'][$group]['name'];
872
+						} else {
873
+													unset($additional_groups[$type][$id]);
874
+						}
838 875
 					}
839 876
 					$additional_groups[$type] = implode(', ', $additional_groups[$type]);
840 877
 				}
@@ -845,10 +882,11 @@  discard block
 block discarded – undo
845 882
 	}
846 883
 
847 884
 	// @todo Temporary
848
-	if ($context['user']['is_owner'])
849
-		$changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own'));
850
-	else
851
-		$changeOther = allowedTo('profile_extra_any');
885
+	if ($context['user']['is_owner']) {
886
+			$changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own'));
887
+	} else {
888
+			$changeOther = allowedTo('profile_extra_any');
889
+	}
852 890
 	if ($changeOther && empty($post_errors))
853 891
 	{
854 892
 		makeThemeChanges($context['id_member'], isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']);
@@ -856,8 +894,9 @@  discard block
 block discarded – undo
856 894
 		{
857 895
 			$custom_fields_errors = makeCustomFieldChanges($context['id_member'], $_REQUEST['sa'], false, true);
858 896
 
859
-			if (!empty($custom_fields_errors))
860
-				$post_errors = array_merge($post_errors, $custom_fields_errors);
897
+			if (!empty($custom_fields_errors)) {
898
+							$post_errors = array_merge($post_errors, $custom_fields_errors);
899
+			}
861 900
 		}
862 901
 	}
863 902
 
@@ -883,9 +922,9 @@  discard block
 block discarded – undo
883 922
 	if ($context['user']['is_owner'])
884 923
 	{
885 924
 		$changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own', 'profile_website_any', 'profile_website_own', 'profile_signature_any', 'profile_signature_own'));
925
+	} else {
926
+			$changeOther = allowedTo(array('profile_extra_any', 'profile_website_any', 'profile_signature_any'));
886 927
 	}
887
-	else
888
-		$changeOther = allowedTo(array('profile_extra_any', 'profile_website_any', 'profile_signature_any'));
889 928
 
890 929
 	// Arrays of all the changes - makes things easier.
891 930
 	$profile_bools = array();
@@ -896,22 +935,25 @@  discard block
 block discarded – undo
896 935
 		'ignore_boards',
897 936
 	);
898 937
 
899
-	if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd']))
900
-		$_POST['ignore_brd'] = array();
938
+	if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd'])) {
939
+			$_POST['ignore_brd'] = array();
940
+	}
901 941
 
902 942
 	unset($_POST['ignore_boards']); // Whatever it is set to is a dirty filthy thing.  Kinda like our minds.
903 943
 	if (isset($_POST['ignore_brd']))
904 944
 	{
905
-		if (!is_array($_POST['ignore_brd']))
906
-			$_POST['ignore_brd'] = array($_POST['ignore_brd']);
945
+		if (!is_array($_POST['ignore_brd'])) {
946
+					$_POST['ignore_brd'] = array($_POST['ignore_brd']);
947
+		}
907 948
 
908 949
 		foreach ($_POST['ignore_brd'] as $k => $d)
909 950
 		{
910 951
 			$d = (int) $d;
911
-			if ($d != 0)
912
-				$_POST['ignore_brd'][$k] = $d;
913
-			else
914
-				unset($_POST['ignore_brd'][$k]);
952
+			if ($d != 0) {
953
+							$_POST['ignore_brd'][$k] = $d;
954
+			} else {
955
+							unset($_POST['ignore_brd'][$k]);
956
+			}
915 957
 		}
916 958
 		$_POST['ignore_boards'] = implode(',', $_POST['ignore_brd']);
917 959
 		unset($_POST['ignore_brd']);
@@ -923,21 +965,26 @@  discard block
 block discarded – undo
923 965
 		makeThemeChanges($memID, isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']);
924 966
 		//makeAvatarChanges($memID, $post_errors);
925 967
 
926
-		if (!empty($_REQUEST['sa']))
927
-			makeCustomFieldChanges($memID, $_REQUEST['sa'], false);
968
+		if (!empty($_REQUEST['sa'])) {
969
+					makeCustomFieldChanges($memID, $_REQUEST['sa'], false);
970
+		}
928 971
 
929
-		foreach ($profile_bools as $var)
930
-			if (isset($_POST[$var]))
972
+		foreach ($profile_bools as $var) {
973
+					if (isset($_POST[$var]))
931 974
 				$profile_vars[$var] = empty($_POST[$var]) ? '0' : '1';
932
-		foreach ($profile_ints as $var)
933
-			if (isset($_POST[$var]))
975
+		}
976
+		foreach ($profile_ints as $var) {
977
+					if (isset($_POST[$var]))
934 978
 				$profile_vars[$var] = $_POST[$var] != '' ? (int) $_POST[$var] : '';
935
-		foreach ($profile_floats as $var)
936
-			if (isset($_POST[$var]))
979
+		}
980
+		foreach ($profile_floats as $var) {
981
+					if (isset($_POST[$var]))
937 982
 				$profile_vars[$var] = (float) $_POST[$var];
938
-		foreach ($profile_strings as $var)
939
-			if (isset($_POST[$var]))
983
+		}
984
+		foreach ($profile_strings as $var) {
985
+					if (isset($_POST[$var]))
940 986
 				$profile_vars[$var] = $_POST[$var];
987
+		}
941 988
 	}
942 989
 }
943 990
 
@@ -971,8 +1018,9 @@  discard block
 block discarded – undo
971 1018
 	);
972 1019
 
973 1020
 	// Can't change reserved vars.
974
-	if ((isset($_POST['options']) && count(array_intersect(array_keys($_POST['options']), $reservedVars)) != 0) || (isset($_POST['default_options']) && count(array_intersect(array_keys($_POST['default_options']), $reservedVars)) != 0))
975
-		fatal_lang_error('no_access', false);
1021
+	if ((isset($_POST['options']) && count(array_intersect(array_keys($_POST['options']), $reservedVars)) != 0) || (isset($_POST['default_options']) && count(array_intersect(array_keys($_POST['default_options']), $reservedVars)) != 0)) {
1022
+			fatal_lang_error('no_access', false);
1023
+	}
976 1024
 
977 1025
 	// Don't allow any overriding of custom fields with default or non-default options.
978 1026
 	$request = $smcFunc['db_query']('', '
@@ -984,8 +1032,9 @@  discard block
 block discarded – undo
984 1032
 		)
985 1033
 	);
986 1034
 	$custom_fields = array();
987
-	while ($row = $smcFunc['db_fetch_assoc']($request))
988
-		$custom_fields[] = $row['col_name'];
1035
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1036
+			$custom_fields[] = $row['col_name'];
1037
+	}
989 1038
 	$smcFunc['db_free_result']($request);
990 1039
 
991 1040
 	// These are the theme changes...
@@ -994,33 +1043,39 @@  discard block
 block discarded – undo
994 1043
 	{
995 1044
 		foreach ($_POST['options'] as $opt => $val)
996 1045
 		{
997
-			if (in_array($opt, $custom_fields))
998
-				continue;
1046
+			if (in_array($opt, $custom_fields)) {
1047
+							continue;
1048
+			}
999 1049
 
1000 1050
 			// These need to be controlled.
1001
-			if ($opt == 'topics_per_page' || $opt == 'messages_per_page')
1002
-				$val = max(0, min($val, 50));
1051
+			if ($opt == 'topics_per_page' || $opt == 'messages_per_page') {
1052
+							$val = max(0, min($val, 50));
1053
+			}
1003 1054
 			// We don't set this per theme anymore.
1004
-			elseif ($opt == 'allow_no_censored')
1005
-				continue;
1055
+			elseif ($opt == 'allow_no_censored') {
1056
+							continue;
1057
+			}
1006 1058
 
1007 1059
 			$themeSetArray[] = array($memID, $id_theme, $opt, is_array($val) ? implode(',', $val) : $val);
1008 1060
 		}
1009 1061
 	}
1010 1062
 
1011 1063
 	$erase_options = array();
1012
-	if (isset($_POST['default_options']) && is_array($_POST['default_options']))
1013
-		foreach ($_POST['default_options'] as $opt => $val)
1064
+	if (isset($_POST['default_options']) && is_array($_POST['default_options'])) {
1065
+			foreach ($_POST['default_options'] as $opt => $val)
1014 1066
 		{
1015 1067
 			if (in_array($opt, $custom_fields))
1016 1068
 				continue;
1069
+	}
1017 1070
 
1018 1071
 			// These need to be controlled.
1019
-			if ($opt == 'topics_per_page' || $opt == 'messages_per_page')
1020
-				$val = max(0, min($val, 50));
1072
+			if ($opt == 'topics_per_page' || $opt == 'messages_per_page') {
1073
+							$val = max(0, min($val, 50));
1074
+			}
1021 1075
 			// Only let admins and owners change the censor.
1022
-			elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner'])
1023
-					continue;
1076
+			elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner']) {
1077
+								continue;
1078
+			}
1024 1079
 
1025 1080
 			$themeSetArray[] = array($memID, 1, $opt, is_array($val) ? implode(',', $val) : $val);
1026 1081
 			$erase_options[] = $opt;
@@ -1056,8 +1111,9 @@  discard block
 block discarded – undo
1056 1111
 
1057 1112
 		// Admins can choose any theme, even if it's not enabled...
1058 1113
 		$themes = allowedTo('admin_forum') ? explode(',', $modSettings['knownThemes']) : explode(',', $modSettings['enableThemes']);
1059
-		foreach ($themes as $t)
1060
-			cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60);
1114
+		foreach ($themes as $t) {
1115
+					cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60);
1116
+		}
1061 1117
 	}
1062 1118
 }
1063 1119
 
@@ -1076,8 +1132,9 @@  discard block
 block discarded – undo
1076 1132
 	if (isset($_POST['edit_notify_boards']) && !empty($_POST['notify_boards']))
1077 1133
 	{
1078 1134
 		// Make sure only integers are deleted.
1079
-		foreach ($_POST['notify_boards'] as $index => $id)
1080
-			$_POST['notify_boards'][$index] = (int) $id;
1135
+		foreach ($_POST['notify_boards'] as $index => $id) {
1136
+					$_POST['notify_boards'][$index] = (int) $id;
1137
+		}
1081 1138
 
1082 1139
 		// id_board = 0 is reserved for topic notifications.
1083 1140
 		$_POST['notify_boards'] = array_diff($_POST['notify_boards'], array(0));
@@ -1096,8 +1153,9 @@  discard block
 block discarded – undo
1096 1153
 	// We are editing topic notifications......
1097 1154
 	elseif (isset($_POST['edit_notify_topics']) && !empty($_POST['notify_topics']))
1098 1155
 	{
1099
-		foreach ($_POST['notify_topics'] as $index => $id)
1100
-			$_POST['notify_topics'][$index] = (int) $id;
1156
+		foreach ($_POST['notify_topics'] as $index => $id) {
1157
+					$_POST['notify_topics'][$index] = (int) $id;
1158
+		}
1101 1159
 
1102 1160
 		// Make sure there are no zeros left.
1103 1161
 		$_POST['notify_topics'] = array_diff($_POST['notify_topics'], array(0));
@@ -1111,16 +1169,18 @@  discard block
 block discarded – undo
1111 1169
 				'selected_member' => $memID,
1112 1170
 			)
1113 1171
 		);
1114
-		foreach ($_POST['notify_topics'] as $topic)
1115
-			setNotifyPrefs($memID, array('topic_notify_' . $topic => 0));
1172
+		foreach ($_POST['notify_topics'] as $topic) {
1173
+					setNotifyPrefs($memID, array('topic_notify_' . $topic => 0));
1174
+		}
1116 1175
 	}
1117 1176
 
1118 1177
 	// We are removing topic preferences
1119 1178
 	elseif (isset($_POST['remove_notify_topics']) && !empty($_POST['notify_topics']))
1120 1179
 	{
1121 1180
 		$prefs = array();
1122
-		foreach ($_POST['notify_topics'] as $topic)
1123
-			$prefs[] = 'topic_notify_' . $topic;
1181
+		foreach ($_POST['notify_topics'] as $topic) {
1182
+					$prefs[] = 'topic_notify_' . $topic;
1183
+		}
1124 1184
 		deleteNotifyPrefs($memID, $prefs);
1125 1185
 	}
1126 1186
 
@@ -1128,8 +1188,9 @@  discard block
 block discarded – undo
1128 1188
 	elseif (isset($_POST['remove_notify_board']) && !empty($_POST['notify_boards']))
1129 1189
 	{
1130 1190
 		$prefs = array();
1131
-		foreach ($_POST['notify_boards'] as $board)
1132
-			$prefs[] = 'board_notify_' . $board;
1191
+		foreach ($_POST['notify_boards'] as $board) {
1192
+					$prefs[] = 'board_notify_' . $board;
1193
+		}
1133 1194
 		deleteNotifyPrefs($memID, $prefs);
1134 1195
 	}
1135 1196
 }
@@ -1150,8 +1211,9 @@  discard block
 block discarded – undo
1150 1211
 
1151 1212
 	$errors = array();
1152 1213
 
1153
-	if ($sanitize && isset($_POST['customfield']))
1154
-		$_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']);
1214
+	if ($sanitize && isset($_POST['customfield'])) {
1215
+			$_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']);
1216
+	}
1155 1217
 
1156 1218
 	$where = $area == 'register' ? 'show_reg != 0' : 'show_profile = {string:area}';
1157 1219
 
@@ -1177,26 +1239,29 @@  discard block
 block discarded – undo
1177 1239
 			- The data is not invisible to users but editable by the owner (or if it is the user is not the owner)
1178 1240
 			- The area isn't registration, and if it is that the field is not supposed to be shown there.
1179 1241
 		*/
1180
-		if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0))
1181
-			continue;
1242
+		if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0)) {
1243
+					continue;
1244
+		}
1182 1245
 
1183 1246
 		// Validate the user data.
1184
-		if ($row['field_type'] == 'check')
1185
-			$value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0;
1186
-		elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio')
1247
+		if ($row['field_type'] == 'check') {
1248
+					$value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0;
1249
+		} elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio')
1187 1250
 		{
1188 1251
 			$value = $row['default_value'];
1189
-			foreach (explode(',', $row['field_options']) as $k => $v)
1190
-				if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k)
1252
+			foreach (explode(',', $row['field_options']) as $k => $v) {
1253
+							if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k)
1191 1254
 					$value = $v;
1255
+			}
1192 1256
 		}
1193 1257
 		// Otherwise some form of text!
1194 1258
 		else
1195 1259
 		{
1196 1260
 			$value = isset($_POST['customfield'][$row['col_name']]) ? $_POST['customfield'][$row['col_name']] : '';
1197 1261
 
1198
-			if ($row['field_length'])
1199
-				$value = $smcFunc['substr']($value, 0, $row['field_length']);
1262
+			if ($row['field_length']) {
1263
+							$value = $smcFunc['substr']($value, 0, $row['field_length']);
1264
+			}
1200 1265
 
1201 1266
 			// Any masks?
1202 1267
 			if ($row['field_type'] == 'text' && !empty($row['mask']) && $row['mask'] != 'none')
@@ -1205,36 +1270,34 @@  discard block
 block discarded – undo
1205 1270
 				$valueReference = un_htmlspecialchars($value);
1206 1271
 
1207 1272
 				// Try and avoid some checks. '0' could be a valid non-empty value.
1208
-				if (empty($value) && !is_numeric($value))
1209
-					$value = '';
1273
+				if (empty($value) && !is_numeric($value)) {
1274
+									$value = '';
1275
+				}
1210 1276
 
1211 1277
 				if ($row['mask'] == 'nohtml' && ($valueReference != strip_tags($valueReference) || $value != filter_var($value, FILTER_SANITIZE_STRING) || preg_match('/<(.+?)[\s]*\/?[\s]*>/si', $valueReference)))
1212 1278
 				{
1213
-					if ($returnErrors)
1214
-						$errors[] = 'custom_field_nohtml_fail';
1215
-
1216
-					else
1217
-						$value = '';
1218
-				}
1219
-				elseif ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255))
1279
+					if ($returnErrors) {
1280
+											$errors[] = 'custom_field_nohtml_fail';
1281
+					} else {
1282
+											$value = '';
1283
+					}
1284
+				} elseif ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255))
1220 1285
 				{
1221
-					if ($returnErrors)
1222
-						$errors[] = 'custom_field_mail_fail';
1223
-
1224
-					else
1225
-						$value = '';
1226
-				}
1227
-				elseif ($row['mask'] == 'number')
1286
+					if ($returnErrors) {
1287
+											$errors[] = 'custom_field_mail_fail';
1288
+					} else {
1289
+											$value = '';
1290
+					}
1291
+				} elseif ($row['mask'] == 'number')
1228 1292
 				{
1229 1293
 					$value = (int) $value;
1230
-				}
1231
-				elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0)
1294
+				} elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0)
1232 1295
 				{
1233
-					if ($returnErrors)
1234
-						$errors[] = 'custom_field_regex_fail';
1235
-
1236
-					else
1237
-						$value = '';
1296
+					if ($returnErrors) {
1297
+											$errors[] = 'custom_field_regex_fail';
1298
+					} else {
1299
+											$value = '';
1300
+					}
1238 1301
 				}
1239 1302
 
1240 1303
 				unset($valueReference);
@@ -1258,8 +1321,7 @@  discard block
 block discarded – undo
1258 1321
 			{
1259 1322
 				$deletes = array('id_theme' => 1 , 'variable' => $row['col_name'], 'id_member' => $memID);
1260 1323
 				unset($user_profile[$memID]['options'][$row['col_name']]);
1261
-			}
1262
-			else
1324
+			} else
1263 1325
 			{
1264 1326
 				$changes[] = array(1, $row['col_name'], $value, $memID);
1265 1327
 				$user_profile[$memID]['options'][$row['col_name']] = $value;
@@ -1270,27 +1332,30 @@  discard block
 block discarded – undo
1270 1332
 
1271 1333
 	$hook_errors = call_integration_hook('integrate_save_custom_profile_fields', array(&$changes, &$log_changes, &$errors, $returnErrors, $memID, $area, $sanitize, &$deletes));
1272 1334
 
1273
-	if (!empty($hook_errors) && is_array($hook_errors))
1274
-		$errors = array_merge($errors, $hook_errors);
1335
+	if (!empty($hook_errors) && is_array($hook_errors)) {
1336
+			$errors = array_merge($errors, $hook_errors);
1337
+	}
1275 1338
 
1276 1339
 	// Make those changes!
1277 1340
 	if ((!empty($changes) || !empty($deletes)) && empty($context['password_auth_failed']) && empty($errors))
1278 1341
 	{
1279
-		if (!empty($changes))
1280
-			$smcFunc['db_insert']('replace',
1342
+		if (!empty($changes)) {
1343
+					$smcFunc['db_insert']('replace',
1281 1344
 				'{db_prefix}themes',
1282 1345
 				array('id_theme' => 'int', 'variable' => 'string-255', 'value' => 'string-65534', 'id_member' => 'int'),
1283 1346
 				$changes,
1284 1347
 				array('id_theme', 'variable', 'id_member')
1285 1348
 			);
1286
-		if (!empty($deletes))
1287
-			$smcFunc['db_query']('','
1349
+		}
1350
+		if (!empty($deletes)) {
1351
+					$smcFunc['db_query']('','
1288 1352
 				DELETE FROM {db_prefix}themes
1289 1353
 				WHERE id_theme = {int:id_theme} AND
1290 1354
 						variable = {string:variable} AND
1291 1355
 						id_member = {int:id_member}',
1292 1356
 				$deletes
1293 1357
 				);
1358
+		}
1294 1359
 		if (!empty($log_changes) && !empty($modSettings['modlog_enabled']))
1295 1360
 		{
1296 1361
 			require_once($sourcedir . '/Logging.php');
@@ -1298,9 +1363,10 @@  discard block
 block discarded – undo
1298 1363
 		}
1299 1364
 	}
1300 1365
 
1301
-	if ($returnErrors)
1302
-		return $errors;
1303
-}
1366
+	if ($returnErrors) {
1367
+			return $errors;
1368
+	}
1369
+	}
1304 1370
 
1305 1371
 /**
1306 1372
  * Show all the users buddies, as well as a add/delete interface.
@@ -1312,8 +1378,9 @@  discard block
 block discarded – undo
1312 1378
 	global $context, $txt, $modSettings;
1313 1379
 
1314 1380
 	// Do a quick check to ensure people aren't getting here illegally!
1315
-	if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist']))
1316
-		fatal_lang_error('no_access', false);
1381
+	if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist'])) {
1382
+			fatal_lang_error('no_access', false);
1383
+	}
1317 1384
 
1318 1385
 	// Can we email the user direct?
1319 1386
 	$context['can_moderate_forum'] = allowedTo('moderate_forum');
@@ -1343,9 +1410,10 @@  discard block
 block discarded – undo
1343 1410
 	$context['sub_template'] = $subActions[$context['list_area']][0];
1344 1411
 	$call = call_helper($subActions[$context['list_area']][0], true);
1345 1412
 
1346
-	if (!empty($call))
1347
-		call_user_func($call, $memID);
1348
-}
1413
+	if (!empty($call)) {
1414
+			call_user_func($call, $memID);
1415
+	}
1416
+	}
1349 1417
 
1350 1418
 /**
1351 1419
  * Show all the users buddies, as well as a add/delete interface.
@@ -1359,9 +1427,10 @@  discard block
 block discarded – undo
1359 1427
 
1360 1428
 	// For making changes!
1361 1429
 	$buddiesArray = explode(',', $user_profile[$memID]['buddy_list']);
1362
-	foreach ($buddiesArray as $k => $dummy)
1363
-		if ($dummy == '')
1430
+	foreach ($buddiesArray as $k => $dummy) {
1431
+			if ($dummy == '')
1364 1432
 			unset($buddiesArray[$k]);
1433
+	}
1365 1434
 
1366 1435
 	// Removing a buddy?
1367 1436
 	if (isset($_GET['remove']))
@@ -1373,10 +1442,11 @@  discard block
 block discarded – undo
1373 1442
 		$_SESSION['prf-save'] = $txt['could_not_remove_person'];
1374 1443
 
1375 1444
 		// Heh, I'm lazy, do it the easy way...
1376
-		foreach ($buddiesArray as $key => $buddy)
1377
-			if ($buddy == (int) $_GET['remove'])
1445
+		foreach ($buddiesArray as $key => $buddy) {
1446
+					if ($buddy == (int) $_GET['remove'])
1378 1447
 			{
1379 1448
 				unset($buddiesArray[$key]);
1449
+		}
1380 1450
 				$_SESSION['prf-save'] = true;
1381 1451
 			}
1382 1452
 
@@ -1386,8 +1456,7 @@  discard block
 block discarded – undo
1386 1456
 
1387 1457
 		// Redirect off the page because we don't like all this ugly query stuff to stick in the history.
1388 1458
 		redirectexit('action=profile;area=lists;sa=buddies;u=' . $memID);
1389
-	}
1390
-	elseif (isset($_POST['new_buddy']))
1459
+	} elseif (isset($_POST['new_buddy']))
1391 1460
 	{
1392 1461
 		checkSession();
1393 1462
 
@@ -1400,8 +1469,9 @@  discard block
 block discarded – undo
1400 1469
 		{
1401 1470
 			$new_buddies[$k] = strtr(trim($new_buddies[$k]), array('\'' => '&#039;'));
1402 1471
 
1403
-			if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name'])))
1404
-				unset($new_buddies[$k]);
1472
+			if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) {
1473
+							unset($new_buddies[$k]);
1474
+			}
1405 1475
 		}
1406 1476
 
1407 1477
 		call_integration_hook('integrate_add_buddies', array($memID, &$new_buddies));
@@ -1421,16 +1491,18 @@  discard block
 block discarded – undo
1421 1491
 				)
1422 1492
 			);
1423 1493
 
1424
-			if ($smcFunc['db_num_rows']($request) != 0)
1425
-				$_SESSION['prf-save'] = true;
1494
+			if ($smcFunc['db_num_rows']($request) != 0) {
1495
+							$_SESSION['prf-save'] = true;
1496
+			}
1426 1497
 
1427 1498
 			// Add the new member to the buddies array.
1428 1499
 			while ($row = $smcFunc['db_fetch_assoc']($request))
1429 1500
 			{
1430
-				if (in_array($row['id_member'], $buddiesArray))
1431
-					continue;
1432
-				else
1433
-					$buddiesArray[] = (int) $row['id_member'];
1501
+				if (in_array($row['id_member'], $buddiesArray)) {
1502
+									continue;
1503
+				} else {
1504
+									$buddiesArray[] = (int) $row['id_member'];
1505
+				}
1434 1506
 			}
1435 1507
 			$smcFunc['db_free_result']($request);
1436 1508
 
@@ -1460,18 +1532,20 @@  discard block
 block discarded – undo
1460 1532
 
1461 1533
 	$context['custom_pf'] = array();
1462 1534
 	$disabled_fields = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array();
1463
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1464
-		if (!isset($disabled_fields[$row['col_name']]))
1535
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1536
+			if (!isset($disabled_fields[$row['col_name']]))
1465 1537
 			$context['custom_pf'][$row['col_name']] = array(
1466 1538
 				'label' => $row['field_name'],
1467 1539
 				'type' => $row['field_type'],
1468 1540
 				'bbc' => !empty($row['bbc']),
1469 1541
 				'enclose' => $row['enclose'],
1470 1542
 			);
1543
+	}
1471 1544
 
1472 1545
 	// Gotta disable the gender option.
1473
-	if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'None')
1474
-		unset($context['custom_pf']['cust_gender']);
1546
+	if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'None') {
1547
+			unset($context['custom_pf']['cust_gender']);
1548
+	}
1475 1549
 
1476 1550
 	$smcFunc['db_free_result']($request);
1477 1551
 
@@ -1488,8 +1562,9 @@  discard block
 block discarded – undo
1488 1562
 				'buddy_list_count' => substr_count($user_profile[$memID]['buddy_list'], ',') + 1,
1489 1563
 			)
1490 1564
 		);
1491
-		while ($row = $smcFunc['db_fetch_assoc']($result))
1492
-			$buddies[] = $row['id_member'];
1565
+		while ($row = $smcFunc['db_fetch_assoc']($result)) {
1566
+					$buddies[] = $row['id_member'];
1567
+		}
1493 1568
 		$smcFunc['db_free_result']($result);
1494 1569
 	}
1495 1570
 
@@ -1517,30 +1592,32 @@  discard block
 block discarded – undo
1517 1592
 					continue;
1518 1593
 				}
1519 1594
 
1520
-				if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key]))
1521
-					$context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key]));
1522
-
1523
-				elseif ($column['type'] == 'check')
1524
-					$context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes'];
1595
+				if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key])) {
1596
+									$context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key]));
1597
+				} elseif ($column['type'] == 'check') {
1598
+									$context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes'];
1599
+				}
1525 1600
 
1526 1601
 				// Enclosing the user input within some other text?
1527
-				if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key]))
1528
-					$context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array(
1602
+				if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key])) {
1603
+									$context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array(
1529 1604
 						'{SCRIPTURL}' => $scripturl,
1530 1605
 						'{IMAGES_URL}' => $settings['images_url'],
1531 1606
 						'{DEFAULT_IMAGES_URL}' => $settings['default_images_url'],
1532 1607
 						'{INPUT}' => $context['buddies'][$buddy]['options'][$key],
1533 1608
 					));
1609
+				}
1534 1610
 			}
1535 1611
 		}
1536 1612
 	}
1537 1613
 
1538 1614
 	if (isset($_SESSION['prf-save']))
1539 1615
 	{
1540
-		if ($_SESSION['prf-save'] === true)
1541
-			$context['saved_successful'] = true;
1542
-		else
1543
-			$context['saved_failed'] = $_SESSION['prf-save'];
1616
+		if ($_SESSION['prf-save'] === true) {
1617
+					$context['saved_successful'] = true;
1618
+		} else {
1619
+					$context['saved_failed'] = $_SESSION['prf-save'];
1620
+		}
1544 1621
 
1545 1622
 		unset($_SESSION['prf-save']);
1546 1623
 	}
@@ -1560,9 +1637,10 @@  discard block
 block discarded – undo
1560 1637
 
1561 1638
 	// For making changes!
1562 1639
 	$ignoreArray = explode(',', $user_profile[$memID]['pm_ignore_list']);
1563
-	foreach ($ignoreArray as $k => $dummy)
1564
-		if ($dummy == '')
1640
+	foreach ($ignoreArray as $k => $dummy) {
1641
+			if ($dummy == '')
1565 1642
 			unset($ignoreArray[$k]);
1643
+	}
1566 1644
 
1567 1645
 	// Removing a member from the ignore list?
1568 1646
 	if (isset($_GET['remove']))
@@ -1572,10 +1650,11 @@  discard block
 block discarded – undo
1572 1650
 		$_SESSION['prf-save'] = $txt['could_not_remove_person'];
1573 1651
 
1574 1652
 		// Heh, I'm lazy, do it the easy way...
1575
-		foreach ($ignoreArray as $key => $id_remove)
1576
-			if ($id_remove == (int) $_GET['remove'])
1653
+		foreach ($ignoreArray as $key => $id_remove) {
1654
+					if ($id_remove == (int) $_GET['remove'])
1577 1655
 			{
1578 1656
 				unset($ignoreArray[$key]);
1657
+		}
1579 1658
 				$_SESSION['prf-save'] = true;
1580 1659
 			}
1581 1660
 
@@ -1585,8 +1664,7 @@  discard block
 block discarded – undo
1585 1664
 
1586 1665
 		// Redirect off the page because we don't like all this ugly query stuff to stick in the history.
1587 1666
 		redirectexit('action=profile;area=lists;sa=ignore;u=' . $memID);
1588
-	}
1589
-	elseif (isset($_POST['new_ignore']))
1667
+	} elseif (isset($_POST['new_ignore']))
1590 1668
 	{
1591 1669
 		checkSession();
1592 1670
 		// Prepare the string for extraction...
@@ -1598,8 +1676,9 @@  discard block
 block discarded – undo
1598 1676
 		{
1599 1677
 			$new_entries[$k] = strtr(trim($new_entries[$k]), array('\'' => '&#039;'));
1600 1678
 
1601
-			if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name'])))
1602
-				unset($new_entries[$k]);
1679
+			if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) {
1680
+							unset($new_entries[$k]);
1681
+			}
1603 1682
 		}
1604 1683
 
1605 1684
 		$_SESSION['prf-save'] = $txt['could_not_add_person'];
@@ -1617,16 +1696,18 @@  discard block
 block discarded – undo
1617 1696
 				)
1618 1697
 			);
1619 1698
 
1620
-			if ($smcFunc['db_num_rows']($request) != 0)
1621
-				$_SESSION['prf-save'] = true;
1699
+			if ($smcFunc['db_num_rows']($request) != 0) {
1700
+							$_SESSION['prf-save'] = true;
1701
+			}
1622 1702
 
1623 1703
 			// Add the new member to the buddies array.
1624 1704
 			while ($row = $smcFunc['db_fetch_assoc']($request))
1625 1705
 			{
1626
-				if (in_array($row['id_member'], $ignoreArray))
1627
-					continue;
1628
-				else
1629
-					$ignoreArray[] = (int) $row['id_member'];
1706
+				if (in_array($row['id_member'], $ignoreArray)) {
1707
+									continue;
1708
+				} else {
1709
+									$ignoreArray[] = (int) $row['id_member'];
1710
+				}
1630 1711
 			}
1631 1712
 			$smcFunc['db_free_result']($request);
1632 1713
 
@@ -1655,8 +1736,9 @@  discard block
 block discarded – undo
1655 1736
 				'ignore_list_count' => substr_count($user_profile[$memID]['pm_ignore_list'], ',') + 1,
1656 1737
 			)
1657 1738
 		);
1658
-		while ($row = $smcFunc['db_fetch_assoc']($result))
1659
-			$ignored[] = $row['id_member'];
1739
+		while ($row = $smcFunc['db_fetch_assoc']($result)) {
1740
+					$ignored[] = $row['id_member'];
1741
+		}
1660 1742
 		$smcFunc['db_free_result']($result);
1661 1743
 	}
1662 1744
 
@@ -1675,10 +1757,11 @@  discard block
 block discarded – undo
1675 1757
 
1676 1758
 	if (isset($_SESSION['prf-save']))
1677 1759
 	{
1678
-		if ($_SESSION['prf-save'] === true)
1679
-			$context['saved_successful'] = true;
1680
-		else
1681
-			$context['saved_failed'] = $_SESSION['prf-save'];
1760
+		if ($_SESSION['prf-save'] === true) {
1761
+					$context['saved_successful'] = true;
1762
+		} else {
1763
+					$context['saved_failed'] = $_SESSION['prf-save'];
1764
+		}
1682 1765
 
1683 1766
 		unset($_SESSION['prf-save']);
1684 1767
 	}
@@ -1694,8 +1777,9 @@  discard block
 block discarded – undo
1694 1777
 	global $context, $txt;
1695 1778
 
1696 1779
 	loadThemeOptions($memID);
1697
-	if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any')))
1698
-		loadCustomFields($memID, 'account');
1780
+	if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any'))) {
1781
+			loadCustomFields($memID, 'account');
1782
+	}
1699 1783
 
1700 1784
 	$context['sub_template'] = 'edit_options';
1701 1785
 	$context['page_desc'] = $txt['account_info'];
@@ -1722,8 +1806,9 @@  discard block
 block discarded – undo
1722 1806
 	global $context, $txt;
1723 1807
 
1724 1808
 	loadThemeOptions($memID);
1725
-	if (allowedTo(array('profile_forum_own', 'profile_forum_any')))
1726
-		loadCustomFields($memID, 'forumprofile');
1809
+	if (allowedTo(array('profile_forum_own', 'profile_forum_any'))) {
1810
+			loadCustomFields($memID, 'forumprofile');
1811
+	}
1727 1812
 
1728 1813
 	$context['sub_template'] = 'edit_options';
1729 1814
 	$context['page_desc'] = $txt['forumProfile_info'];
@@ -1756,18 +1841,21 @@  discard block
 block discarded – undo
1756 1841
 	$dirs = array();
1757 1842
 	$files = array();
1758 1843
 
1759
-	if (!$dir)
1760
-		return array();
1844
+	if (!$dir) {
1845
+			return array();
1846
+	}
1761 1847
 
1762 1848
 	while ($line = $dir->read())
1763 1849
 	{
1764
-		if (in_array($line, array('.', '..', 'blank.png', 'index.php')))
1765
-			continue;
1850
+		if (in_array($line, array('.', '..', 'blank.png', 'index.php'))) {
1851
+					continue;
1852
+		}
1766 1853
 
1767
-		if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line))
1768
-			$dirs[] = $line;
1769
-		else
1770
-			$files[] = $line;
1854
+		if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line)) {
1855
+					$dirs[] = $line;
1856
+		} else {
1857
+					$files[] = $line;
1858
+		}
1771 1859
 	}
1772 1860
 	$dir->close();
1773 1861
 
@@ -1788,14 +1876,15 @@  discard block
 block discarded – undo
1788 1876
 	foreach ($dirs as $line)
1789 1877
 	{
1790 1878
 		$tmp = getAvatars($directory . (!empty($directory) ? '/' : '') . $line, $level + 1);
1791
-		if (!empty($tmp))
1792
-			$result[] = array(
1879
+		if (!empty($tmp)) {
1880
+					$result[] = array(
1793 1881
 				'filename' => $smcFunc['htmlspecialchars']($line),
1794 1882
 				'checked' => strpos($context['member']['avatar']['server_pic'], $line . '/') !== false,
1795 1883
 				'name' => '[' . $smcFunc['htmlspecialchars'](str_replace('_', ' ', $line)) . ']',
1796 1884
 				'is_dir' => true,
1797 1885
 				'files' => $tmp
1798 1886
 		);
1887
+		}
1799 1888
 		unset($tmp);
1800 1889
 	}
1801 1890
 
@@ -1805,8 +1894,9 @@  discard block
 block discarded – undo
1805 1894
 		$extension = substr(strrchr($line, '.'), 1);
1806 1895
 
1807 1896
 		// Make sure it is an image.
1808
-		if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0)
1809
-			continue;
1897
+		if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0) {
1898
+					continue;
1899
+		}
1810 1900
 
1811 1901
 		$result[] = array(
1812 1902
 			'filename' => $smcFunc['htmlspecialchars']($line),
@@ -1814,8 +1904,9 @@  discard block
 block discarded – undo
1814 1904
 			'name' => $smcFunc['htmlspecialchars'](str_replace('_', ' ', $filename)),
1815 1905
 			'is_dir' => false
1816 1906
 		);
1817
-		if ($level == 1)
1818
-			$context['avatar_list'][] = $directory . '/' . $line;
1907
+		if ($level == 1) {
1908
+					$context['avatar_list'][] = $directory . '/' . $line;
1909
+		}
1819 1910
 	}
1820 1911
 
1821 1912
 	return $result;
@@ -1837,8 +1928,9 @@  discard block
 block discarded – undo
1837 1928
 	call_integration_hook('integrate_theme_options');
1838 1929
 
1839 1930
 	loadThemeOptions($memID);
1840
-	if (allowedTo(array('profile_extra_own', 'profile_extra_any')))
1841
-		loadCustomFields($memID, 'theme');
1931
+	if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) {
1932
+			loadCustomFields($memID, 'theme');
1933
+	}
1842 1934
 
1843 1935
 	$context['sub_template'] = 'edit_options';
1844 1936
 	$context['page_desc'] = $txt['theme_info'];
@@ -1892,16 +1984,19 @@  discard block
 block discarded – undo
1892 1984
 {
1893 1985
 	global $txt, $context, $modSettings, $smcFunc, $sourcedir;
1894 1986
 
1895
-	if (!isset($context['token_check']))
1896
-		$context['token_check'] = 'profile-nt' . $memID;
1987
+	if (!isset($context['token_check'])) {
1988
+			$context['token_check'] = 'profile-nt' . $memID;
1989
+	}
1897 1990
 
1898 1991
 	is_not_guest();
1899
-	if (!$context['user']['is_owner'])
1900
-		isAllowedTo('profile_extra_any');
1992
+	if (!$context['user']['is_owner']) {
1993
+			isAllowedTo('profile_extra_any');
1994
+	}
1901 1995
 
1902 1996
 	// Set the post action if we're coming from the profile...
1903
-	if (!isset($context['action']))
1904
-		$context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID;
1997
+	if (!isset($context['action'])) {
1998
+			$context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID;
1999
+	}
1905 2000
 
1906 2001
 	// What options are set
1907 2002
 	loadThemeOptions($memID);
@@ -1988,28 +2083,34 @@  discard block
 block discarded – undo
1988 2083
 	);
1989 2084
 
1990 2085
 	// There are certain things that are disabled at the group level.
1991
-	if (empty($modSettings['cal_enabled']))
1992
-		unset($alert_types['calendar']);
2086
+	if (empty($modSettings['cal_enabled'])) {
2087
+			unset($alert_types['calendar']);
2088
+	}
1993 2089
 
1994 2090
 	// Disable paid subscriptions at group level if they're disabled
1995
-	if (empty($modSettings['paid_enabled']))
1996
-		unset($alert_types['paidsubs']);
2091
+	if (empty($modSettings['paid_enabled'])) {
2092
+			unset($alert_types['paidsubs']);
2093
+	}
1997 2094
 
1998 2095
 	// Disable membergroup requests at group level if they're disabled
1999
-	if (empty($modSettings['show_group_membership']))
2000
-		unset($alert_types['groupr'], $alert_types['members']['request_group']);
2096
+	if (empty($modSettings['show_group_membership'])) {
2097
+			unset($alert_types['groupr'], $alert_types['members']['request_group']);
2098
+	}
2001 2099
 
2002 2100
 	// Disable mentions if they're disabled
2003
-	if (empty($modSettings['enable_mentions']))
2004
-		unset($alert_types['msg']['msg_mention']);
2101
+	if (empty($modSettings['enable_mentions'])) {
2102
+			unset($alert_types['msg']['msg_mention']);
2103
+	}
2005 2104
 
2006 2105
 	// Disable likes if they're disabled
2007
-	if (empty($modSettings['enable_likes']))
2008
-		unset($alert_types['msg']['msg_like']);
2106
+	if (empty($modSettings['enable_likes'])) {
2107
+			unset($alert_types['msg']['msg_like']);
2108
+	}
2009 2109
 
2010 2110
 	// Disable buddy requests if they're disabled
2011
-	if (empty($modSettings['enable_buddylist']))
2012
-		unset($alert_types['members']['buddy_request']);
2111
+	if (empty($modSettings['enable_buddylist'])) {
2112
+			unset($alert_types['members']['buddy_request']);
2113
+	}
2013 2114
 
2014 2115
 	// Now, now, we could pass this through global but we should really get into the habit of
2015 2116
 	// passing content to hooks, not expecting hooks to splatter everything everywhere.
@@ -2037,15 +2138,17 @@  discard block
 block discarded – undo
2037 2138
 			$perms_cache['manage_membergroups'] = in_array($memID, $members);
2038 2139
 		}
2039 2140
 
2040
-		if (!($perms_cache['manage_membergroups'] || $can_mod != 0))
2041
-			unset($alert_types['members']['request_group']);
2141
+		if (!($perms_cache['manage_membergroups'] || $can_mod != 0)) {
2142
+					unset($alert_types['members']['request_group']);
2143
+		}
2042 2144
 
2043 2145
 		foreach ($alert_types as $group => $items)
2044 2146
 		{
2045 2147
 			foreach ($items as $alert_key => $alert_value)
2046 2148
 			{
2047
-				if (!isset($alert_value['permission']))
2048
-					continue;
2149
+				if (!isset($alert_value['permission'])) {
2150
+									continue;
2151
+				}
2049 2152
 				if (!isset($perms_cache[$alert_value['permission']['name']]))
2050 2153
 				{
2051 2154
 					$in_board = !empty($alert_value['permission']['is_board']) ? 0 : null;
@@ -2053,12 +2156,14 @@  discard block
 block discarded – undo
2053 2156
 					$perms_cache[$alert_value['permission']['name']] = in_array($memID, $members);
2054 2157
 				}
2055 2158
 
2056
-				if (!$perms_cache[$alert_value['permission']['name']])
2057
-					unset ($alert_types[$group][$alert_key]);
2159
+				if (!$perms_cache[$alert_value['permission']['name']]) {
2160
+									unset ($alert_types[$group][$alert_key]);
2161
+				}
2058 2162
 			}
2059 2163
 
2060
-			if (empty($alert_types[$group]))
2061
-				unset ($alert_types[$group]);
2164
+			if (empty($alert_types[$group])) {
2165
+							unset ($alert_types[$group]);
2166
+			}
2062 2167
 		}
2063 2168
 	}
2064 2169
 
@@ -2090,9 +2195,9 @@  discard block
 block discarded – undo
2090 2195
 						$update_prefs[$this_option[1]] = !empty($_POST['opt_' . $this_option[1]]) ? 1 : 0;
2091 2196
 						break;
2092 2197
 					case 'select':
2093
-						if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]]))
2094
-							$update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]];
2095
-						else
2198
+						if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]])) {
2199
+													$update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]];
2200
+						} else
2096 2201
 						{
2097 2202
 							// We didn't have a sane value. Let's grab the first item from the possibles.
2098 2203
 							$keys = array_keys($this_option['opts']);
@@ -2112,23 +2217,28 @@  discard block
 block discarded – undo
2112 2217
 				$this_value = 0;
2113 2218
 				foreach ($context['alert_bits'] as $type => $bitvalue)
2114 2219
 				{
2115
-					if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always')
2116
-						$this_value |= $bitvalue;
2220
+					if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always') {
2221
+											$this_value |= $bitvalue;
2222
+					}
2223
+				}
2224
+				if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value) {
2225
+									$update_prefs[$item_key] = $this_value;
2117 2226
 				}
2118
-				if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value)
2119
-					$update_prefs[$item_key] = $this_value;
2120 2227
 			}
2121 2228
 		}
2122 2229
 
2123
-		if (!empty($_POST['opt_alert_timeout']))
2124
-			$update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout'];
2230
+		if (!empty($_POST['opt_alert_timeout'])) {
2231
+					$update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout'];
2232
+		}
2125 2233
 
2126
-		if (!empty($_POST['notify_announcements']))
2127
-			$update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements'];
2234
+		if (!empty($_POST['notify_announcements'])) {
2235
+					$update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements'];
2236
+		}
2128 2237
 
2129 2238
 		setNotifyPrefs((int) $memID, $update_prefs);
2130
-		foreach ($update_prefs as $pref => $value)
2131
-			$context['alert_prefs'][$pref] = $value;
2239
+		foreach ($update_prefs as $pref => $value) {
2240
+					$context['alert_prefs'][$pref] = $value;
2241
+		}
2132 2242
 
2133 2243
 		makeNotificationChanges($memID);
2134 2244
 
@@ -2158,8 +2268,9 @@  discard block
 block discarded – undo
2158 2268
 
2159 2269
 	// Now we're all set up.
2160 2270
 	is_not_guest();
2161
-	if (!$context['user']['is_owner'])
2162
-		fatal_error('no_access');
2271
+	if (!$context['user']['is_owner']) {
2272
+			fatal_error('no_access');
2273
+	}
2163 2274
 
2164 2275
 	checkSession('get');
2165 2276
 
@@ -2191,8 +2302,9 @@  discard block
 block discarded – undo
2191 2302
 {
2192 2303
 	global $smcFunc;
2193 2304
 
2194
-	if (empty($toMark) || empty($memID))
2195
-		return false;
2305
+	if (empty($toMark) || empty($memID)) {
2306
+			return false;
2307
+	}
2196 2308
 
2197 2309
 	$toMark = (array) $toMark;
2198 2310
 
@@ -2226,8 +2338,9 @@  discard block
 block discarded – undo
2226 2338
 {
2227 2339
 	global $smcFunc;
2228 2340
 
2229
-	if (empty($toDelete))
2230
-		return false;
2341
+	if (empty($toDelete)) {
2342
+			return false;
2343
+	}
2231 2344
 
2232 2345
 	$toDelete = (array) $toDelete;
2233 2346
 
@@ -2262,8 +2375,9 @@  discard block
 block discarded – undo
2262 2375
 {
2263 2376
 	global $smcFunc;
2264 2377
 
2265
-	if (empty($memID))
2266
-		return false;
2378
+	if (empty($memID)) {
2379
+			return false;
2380
+	}
2267 2381
 
2268 2382
 	$request = $smcFunc['db_query']('', '
2269 2383
 		SELECT id_alert
@@ -2340,8 +2454,9 @@  discard block
 block discarded – undo
2340 2454
 					{
2341 2455
 						$link = $topic['link'];
2342 2456
 
2343
-						if ($topic['new'])
2344
-							$link .= ' <a href="' . $topic['new_href'] . '" class="new_posts">' . $txt['new'] . '</a>';
2457
+						if ($topic['new']) {
2458
+													$link .= ' <a href="' . $topic['new_href'] . '" class="new_posts">' . $txt['new'] . '</a>';
2459
+						}
2345 2460
 
2346 2461
 						$link .= '<br><span class="smalltext"><em>' . $txt['in'] . ' ' . $topic['board_link'] . '</em></span>';
2347 2462
 
@@ -2492,8 +2607,9 @@  discard block
 block discarded – undo
2492 2607
 					{
2493 2608
 						$link = $board['link'];
2494 2609
 
2495
-						if ($board['new'])
2496
-							$link .= ' <a href="' . $board['href'] . '" class="new_posts">' . $txt['new'] . '</a>';
2610
+						if ($board['new']) {
2611
+													$link .= ' <a href="' . $board['href'] . '" class="new_posts">' . $txt['new'] . '</a>';
2612
+						}
2497 2613
 
2498 2614
 						return $link;
2499 2615
 					},
@@ -2693,8 +2809,8 @@  discard block
 block discarded – undo
2693 2809
 		)
2694 2810
 	);
2695 2811
 	$notification_boards = array();
2696
-	while ($row = $smcFunc['db_fetch_assoc']($request))
2697
-		$notification_boards[] = array(
2812
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
2813
+			$notification_boards[] = array(
2698 2814
 			'id' => $row['id_board'],
2699 2815
 			'name' => $row['name'],
2700 2816
 			'href' => $scripturl . '?board=' . $row['id_board'] . '.0',
@@ -2702,6 +2818,7 @@  discard block
 block discarded – undo
2702 2818
 			'new' => $row['board_read'] < $row['id_msg_updated'],
2703 2819
 			'notify_pref' => isset($prefs['board_notify_' . $row['id_board']]) ? $prefs['board_notify_' . $row['id_board']] : (!empty($prefs['board_notify']) ? $prefs['board_notify'] : 0),
2704 2820
 		);
2821
+	}
2705 2822
 	$smcFunc['db_free_result']($request);
2706 2823
 
2707 2824
 	return $notification_boards;
@@ -2716,17 +2833,18 @@  discard block
 block discarded – undo
2716 2833
 {
2717 2834
 	global $context, $options, $cur_profile, $smcFunc;
2718 2835
 
2719
-	if (isset($_POST['default_options']))
2720
-		$_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options'];
2836
+	if (isset($_POST['default_options'])) {
2837
+			$_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options'];
2838
+	}
2721 2839
 
2722 2840
 	if ($context['user']['is_owner'])
2723 2841
 	{
2724 2842
 		$context['member']['options'] = $options;
2725
-		if (isset($_POST['options']) && is_array($_POST['options']))
2726
-			foreach ($_POST['options'] as $k => $v)
2843
+		if (isset($_POST['options']) && is_array($_POST['options'])) {
2844
+					foreach ($_POST['options'] as $k => $v)
2727 2845
 				$context['member']['options'][$k] = $v;
2728
-	}
2729
-	else
2846
+		}
2847
+	} else
2730 2848
 	{
2731 2849
 		$request = $smcFunc['db_query']('', '
2732 2850
 			SELECT id_member, variable, value
@@ -2747,8 +2865,9 @@  discard block
 block discarded – undo
2747 2865
 				continue;
2748 2866
 			}
2749 2867
 
2750
-			if (isset($_POST['options'][$row['variable']]))
2751
-				$row['value'] = $_POST['options'][$row['variable']];
2868
+			if (isset($_POST['options'][$row['variable']])) {
2869
+							$row['value'] = $_POST['options'][$row['variable']];
2870
+			}
2752 2871
 			$context['member']['options'][$row['variable']] = $row['value'];
2753 2872
 		}
2754 2873
 		$smcFunc['db_free_result']($request);
@@ -2756,8 +2875,9 @@  discard block
 block discarded – undo
2756 2875
 		// Load up the default theme options for any missing.
2757 2876
 		foreach ($temp as $k => $v)
2758 2877
 		{
2759
-			if (!isset($context['member']['options'][$k]))
2760
-				$context['member']['options'][$k] = $v;
2878
+			if (!isset($context['member']['options'][$k])) {
2879
+							$context['member']['options'][$k] = $v;
2880
+			}
2761 2881
 		}
2762 2882
 	}
2763 2883
 }
@@ -2772,8 +2892,9 @@  discard block
 block discarded – undo
2772 2892
 	global $context, $modSettings, $smcFunc, $cur_profile, $sourcedir;
2773 2893
 
2774 2894
 	// Have the admins enabled this option?
2775
-	if (empty($modSettings['allow_ignore_boards']))
2776
-		fatal_lang_error('ignoreboards_disallowed', 'user');
2895
+	if (empty($modSettings['allow_ignore_boards'])) {
2896
+			fatal_lang_error('ignoreboards_disallowed', 'user');
2897
+	}
2777 2898
 
2778 2899
 	// Find all the boards this user is allowed to see.
2779 2900
 	$request = $smcFunc['db_query']('order_by_board_order', '
@@ -2793,12 +2914,13 @@  discard block
 block discarded – undo
2793 2914
 	while ($row = $smcFunc['db_fetch_assoc']($request))
2794 2915
 	{
2795 2916
 		// This category hasn't been set up yet..
2796
-		if (!isset($context['categories'][$row['id_cat']]))
2797
-			$context['categories'][$row['id_cat']] = array(
2917
+		if (!isset($context['categories'][$row['id_cat']])) {
2918
+					$context['categories'][$row['id_cat']] = array(
2798 2919
 				'id' => $row['id_cat'],
2799 2920
 				'name' => $row['cat_name'],
2800 2921
 				'boards' => array()
2801 2922
 			);
2923
+		}
2802 2924
 
2803 2925
 		// Set this board up, and let the template know when it's a child.  (indent them..)
2804 2926
 		$context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array(
@@ -2828,18 +2950,20 @@  discard block
 block discarded – undo
2828 2950
 	}
2829 2951
 
2830 2952
 	$max_boards = ceil(count($temp_boards) / 2);
2831
-	if ($max_boards == 1)
2832
-		$max_boards = 2;
2953
+	if ($max_boards == 1) {
2954
+			$max_boards = 2;
2955
+	}
2833 2956
 
2834 2957
 	// Now, alternate them so they can be shown left and right ;).
2835 2958
 	$context['board_columns'] = array();
2836 2959
 	for ($i = 0; $i < $max_boards; $i++)
2837 2960
 	{
2838 2961
 		$context['board_columns'][] = $temp_boards[$i];
2839
-		if (isset($temp_boards[$i + $max_boards]))
2840
-			$context['board_columns'][] = $temp_boards[$i + $max_boards];
2841
-		else
2842
-			$context['board_columns'][] = array();
2962
+		if (isset($temp_boards[$i + $max_boards])) {
2963
+					$context['board_columns'][] = $temp_boards[$i + $max_boards];
2964
+		} else {
2965
+					$context['board_columns'][] = array();
2966
+		}
2843 2967
 	}
2844 2968
 
2845 2969
 	loadThemeOptions($memID);
@@ -2908,8 +3032,9 @@  discard block
 block discarded – undo
2908 3032
 	while ($row = $smcFunc['db_fetch_assoc']($request))
2909 3033
 	{
2910 3034
 		// We should skip the administrator group if they don't have the admin_forum permission!
2911
-		if ($row['id_group'] == 1 && !allowedTo('admin_forum'))
2912
-			continue;
3035
+		if ($row['id_group'] == 1 && !allowedTo('admin_forum')) {
3036
+					continue;
3037
+		}
2913 3038
 
2914 3039
 		$context['member_groups'][$row['id_group']] = array(
2915 3040
 			'id' => $row['id_group'],
@@ -2955,16 +3080,17 @@  discard block
 block discarded – undo
2955 3080
 	$context['max_signature_length'] = $context['signature_limits']['max_length'];
2956 3081
 	// Warning message for signature image limits?
2957 3082
 	$context['signature_warning'] = '';
2958
-	if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height'])
2959
-		$context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']);
2960
-	elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height'])
2961
-		$context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_' . ($context['signature_limits']['max_image_width'] ? 'width' : 'height')], $context['signature_limits'][$context['signature_limits']['max_image_width'] ? 'max_image_width' : 'max_image_height']);
3083
+	if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height']) {
3084
+			$context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']);
3085
+	} elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height']) {
3086
+			$context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_' . ($context['signature_limits']['max_image_width'] ? 'width' : 'height')], $context['signature_limits'][$context['signature_limits']['max_image_width'] ? 'max_image_width' : 'max_image_height']);
3087
+	}
2962 3088
 
2963 3089
 	$context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv'))));
2964 3090
 
2965
-	if (empty($context['do_preview']))
2966
-		$context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '&lt;', '&gt;', '&quot;', '&#039;'), $cur_profile['signature']);
2967
-	else
3091
+	if (empty($context['do_preview'])) {
3092
+			$context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '&lt;', '&gt;', '&quot;', '&#039;'), $cur_profile['signature']);
3093
+	} else
2968 3094
 	{
2969 3095
 		$signature = !empty($_POST['signature']) ? $_POST['signature'] : '';
2970 3096
 		$validation = profileValidateSignature($signature);
@@ -2974,8 +3100,9 @@  discard block
 block discarded – undo
2974 3100
 			$context['post_errors'] = array();
2975 3101
 		}
2976 3102
 		$context['post_errors'][] = 'signature_not_yet_saved';
2977
-		if ($validation !== true && $validation !== false)
2978
-			$context['post_errors'][] = $validation;
3103
+		if ($validation !== true && $validation !== false) {
3104
+					$context['post_errors'][] = $validation;
3105
+		}
2979 3106
 
2980 3107
 		censorText($context['member']['signature']);
2981 3108
 		$context['member']['current_signature'] = $context['member']['signature'];
@@ -2985,8 +3112,9 @@  discard block
 block discarded – undo
2985 3112
 	}
2986 3113
 
2987 3114
 	// Load the spell checker?
2988
-	if ($context['show_spellchecking'])
2989
-		loadJavaScriptFile('spellcheck.js', array('defer' => false, 'minimize' => true), 'smf_spellcheck');
3115
+	if ($context['show_spellchecking']) {
3116
+			loadJavaScriptFile('spellcheck.js', array('defer' => false, 'minimize' => true), 'smf_spellcheck');
3117
+	}
2990 3118
 
2991 3119
 	return true;
2992 3120
 }
@@ -3020,8 +3148,7 @@  discard block
 block discarded – undo
3020 3148
 			'external' => $cur_profile['avatar'] == 'gravatar://' || empty($modSettings['gravatarAllowExtraEmail']) || !empty($modSettings['gravatarOverride']) ? $cur_profile['email_address'] : substr($cur_profile['avatar'], 11)
3021 3149
 		);
3022 3150
 		$context['member']['avatar']['href'] = get_gravatar_url($context['member']['avatar']['external']);
3023
-	}
3024
-	elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload'])
3151
+	} elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload'])
3025 3152
 	{
3026 3153
 		$context['member']['avatar'] += array(
3027 3154
 			'choice' => 'upload',
@@ -3031,33 +3158,34 @@  discard block
 block discarded – undo
3031 3158
 		$context['member']['avatar']['href'] = empty($cur_profile['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $cur_profile['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $cur_profile['filename'];
3032 3159
 	}
3033 3160
 	// Use "avatar_original" here so we show what the user entered even if the image proxy is enabled
3034
-	elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external'])
3035
-		$context['member']['avatar'] += array(
3161
+	elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external']) {
3162
+			$context['member']['avatar'] += array(
3036 3163
 			'choice' => 'external',
3037 3164
 			'server_pic' => 'blank.png',
3038 3165
 			'external' => $cur_profile['avatar_original']
3039 3166
 		);
3040
-	elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored'])
3041
-		$context['member']['avatar'] += array(
3167
+	} elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored']) {
3168
+			$context['member']['avatar'] += array(
3042 3169
 			'choice' => 'server_stored',
3043 3170
 			'server_pic' => $cur_profile['avatar'] == '' ? 'blank.png' : $cur_profile['avatar'],
3044 3171
 			'external' => 'http://'
3045 3172
 		);
3046
-	else
3047
-		$context['member']['avatar'] += array(
3173
+	} else {
3174
+			$context['member']['avatar'] += array(
3048 3175
 			'choice' => 'none',
3049 3176
 			'server_pic' => 'blank.png',
3050 3177
 			'external' => 'http://'
3051 3178
 		);
3179
+	}
3052 3180
 
3053 3181
 	// Get a list of all the avatars.
3054 3182
 	if ($context['member']['avatar']['allow_server_stored'])
3055 3183
 	{
3056 3184
 		$context['avatar_list'] = array();
3057 3185
 		$context['avatars'] = is_dir($modSettings['avatar_directory']) ? getAvatars('', 0) : array();
3186
+	} else {
3187
+			$context['avatars'] = array();
3058 3188
 	}
3059
-	else
3060
-		$context['avatars'] = array();
3061 3189
 
3062 3190
 	// Second level selected avatar...
3063 3191
 	$context['avatar_selected'] = substr(strrchr($context['member']['avatar']['server_pic'], '/'), 1);
@@ -3086,19 +3214,22 @@  discard block
 block discarded – undo
3086 3214
 			)
3087 3215
 		);
3088 3216
 		$protected_groups = array(1);
3089
-		while ($row = $smcFunc['db_fetch_assoc']($request))
3090
-			$protected_groups[] = $row['id_group'];
3217
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
3218
+					$protected_groups[] = $row['id_group'];
3219
+		}
3091 3220
 		$smcFunc['db_free_result']($request);
3092 3221
 
3093 3222
 		$protected_groups = array_unique($protected_groups);
3094 3223
 	}
3095 3224
 
3096 3225
 	// The account page allows the change of your id_group - but not to a protected group!
3097
-	if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0)
3098
-		$value = (int) $value;
3226
+	if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0) {
3227
+			$value = (int) $value;
3228
+	}
3099 3229
 	// ... otherwise it's the old group sir.
3100
-	else
3101
-		$value = $old_profile['id_group'];
3230
+	else {
3231
+			$value = $old_profile['id_group'];
3232
+	}
3102 3233
 
3103 3234
 	// Find the additional membergroups (if any)
3104 3235
 	if (isset($_POST['additional_groups']) && is_array($_POST['additional_groups']))
@@ -3107,16 +3238,18 @@  discard block
 block discarded – undo
3107 3238
 		foreach ($_POST['additional_groups'] as $group_id)
3108 3239
 		{
3109 3240
 			$group_id = (int) $group_id;
3110
-			if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups)))
3111
-				$additional_groups[] = $group_id;
3241
+			if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups))) {
3242
+							$additional_groups[] = $group_id;
3243
+			}
3112 3244
 		}
3113 3245
 
3114 3246
 		// Put the protected groups back in there if you don't have permission to take them away.
3115 3247
 		$old_additional_groups = explode(',', $old_profile['additional_groups']);
3116 3248
 		foreach ($old_additional_groups as $group_id)
3117 3249
 		{
3118
-			if (!empty($protected_groups) && in_array($group_id, $protected_groups))
3119
-				$additional_groups[] = $group_id;
3250
+			if (!empty($protected_groups) && in_array($group_id, $protected_groups)) {
3251
+							$additional_groups[] = $group_id;
3252
+			}
3120 3253
 		}
3121 3254
 
3122 3255
 		if (implode(',', $additional_groups) !== $old_profile['additional_groups'])
@@ -3148,18 +3281,20 @@  discard block
 block discarded – undo
3148 3281
 			list ($another) = $smcFunc['db_fetch_row']($request);
3149 3282
 			$smcFunc['db_free_result']($request);
3150 3283
 
3151
-			if (empty($another))
3152
-				fatal_lang_error('at_least_one_admin', 'critical');
3284
+			if (empty($another)) {
3285
+							fatal_lang_error('at_least_one_admin', 'critical');
3286
+			}
3153 3287
 		}
3154 3288
 	}
3155 3289
 
3156 3290
 	// If we are changing group status, update permission cache as necessary.
3157 3291
 	if ($value != $old_profile['id_group'] || isset($profile_vars['additional_groups']))
3158 3292
 	{
3159
-		if ($context['user']['is_owner'])
3160
-			$_SESSION['mc']['time'] = 0;
3161
-		else
3162
-			updateSettings(array('settings_updated' => time()));
3293
+		if ($context['user']['is_owner']) {
3294
+					$_SESSION['mc']['time'] = 0;
3295
+		} else {
3296
+					updateSettings(array('settings_updated' => time()));
3297
+		}
3163 3298
 	}
3164 3299
 
3165 3300
 	// Announce to any hooks that we have changed groups, but don't allow them to change it.
@@ -3180,8 +3315,9 @@  discard block
 block discarded – undo
3180 3315
 	global $modSettings, $sourcedir, $smcFunc, $profile_vars, $cur_profile, $context;
3181 3316
 
3182 3317
 	$memID = $context['id_member'];
3183
-	if (empty($memID) && !empty($context['password_auth_failed']))
3184
-		return false;
3318
+	if (empty($memID) && !empty($context['password_auth_failed'])) {
3319
+			return false;
3320
+	}
3185 3321
 
3186 3322
 	require_once($sourcedir . '/ManageAttachments.php');
3187 3323
 
@@ -3192,8 +3328,9 @@  discard block
 block discarded – undo
3192 3328
 	$downloadedExternalAvatar = false;
3193 3329
 	if ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && strlen($_POST['userpicpersonal']) > 7 && !empty($modSettings['avatar_download_external']))
3194 3330
 	{
3195
-		if (!is_writable($uploadDir))
3196
-			fatal_lang_error('attachments_no_write', 'critical');
3331
+		if (!is_writable($uploadDir)) {
3332
+					fatal_lang_error('attachments_no_write', 'critical');
3333
+		}
3197 3334
 
3198 3335
 		$url = parse_url($_POST['userpicpersonal']);
3199 3336
 		$contents = fetch_web_data($url['scheme'] . '://' . $url['host'] . (empty($url['port']) ? '' : ':' . $url['port']) . str_replace(' ', '%20', trim($url['path'])));
@@ -3235,19 +3372,18 @@  discard block
 block discarded – undo
3235 3372
 
3236 3373
 		// Get rid of their old avatar. (if uploaded.)
3237 3374
 		removeAttachments(array('id_member' => $memID));
3238
-	}
3239
-	elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled']))
3375
+	} elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled']))
3240 3376
 	{
3241 3377
 		// One wasn't specified, or it's not allowed to use extra email addresses, or it's not a valid one, reset to default Gravatar.
3242
-		if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL))
3243
-			$profile_vars['avatar'] = 'gravatar://';
3244
-		else
3245
-			$profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : '');
3378
+		if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL)) {
3379
+					$profile_vars['avatar'] = 'gravatar://';
3380
+		} else {
3381
+					$profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : '');
3382
+		}
3246 3383
 
3247 3384
 		// Get rid of their old avatar. (if uploaded.)
3248 3385
 		removeAttachments(array('id_member' => $memID));
3249
-	}
3250
-	elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external']))
3386
+	} elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external']))
3251 3387
 	{
3252 3388
 		// We need these clean...
3253 3389
 		$cur_profile['id_attach'] = 0;
@@ -3259,11 +3395,13 @@  discard block
 block discarded – undo
3259 3395
 
3260 3396
 		$profile_vars['avatar'] = str_replace(' ', '%20', preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $_POST['userpicpersonal']));
3261 3397
 
3262
-		if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///')
3263
-			$profile_vars['avatar'] = '';
3398
+		if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///') {
3399
+					$profile_vars['avatar'] = '';
3400
+		}
3264 3401
 		// Trying to make us do something we'll regret?
3265
-		elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://')
3266
-			return 'bad_avatar_invalid_url';
3402
+		elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://') {
3403
+					return 'bad_avatar_invalid_url';
3404
+		}
3267 3405
 		// Should we check dimensions?
3268 3406
 		elseif (!empty($modSettings['avatar_max_height_external']) || !empty($modSettings['avatar_max_width_external']))
3269 3407
 		{
@@ -3273,9 +3411,9 @@  discard block
 block discarded – undo
3273 3411
 			if (is_array($sizes) && (($sizes[0] > $modSettings['avatar_max_width_external'] && !empty($modSettings['avatar_max_width_external'])) || ($sizes[1] > $modSettings['avatar_max_height_external'] && !empty($modSettings['avatar_max_height_external']))))
3274 3412
 			{
3275 3413
 				// Houston, we have a problem. The avatar is too large!!
3276
-				if ($modSettings['avatar_action_too_large'] == 'option_refuse')
3277
-					return 'bad_avatar_too_large';
3278
-				elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize')
3414
+				if ($modSettings['avatar_action_too_large'] == 'option_refuse') {
3415
+									return 'bad_avatar_too_large';
3416
+				} elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize')
3279 3417
 				{
3280 3418
 					// @todo remove this if appropriate
3281 3419
 					require_once($sourcedir . '/Subs-Graphics.php');
@@ -3285,26 +3423,27 @@  discard block
 block discarded – undo
3285 3423
 						$cur_profile['id_attach'] = $modSettings['new_avatar_data']['id'];
3286 3424
 						$cur_profile['filename'] = $modSettings['new_avatar_data']['filename'];
3287 3425
 						$cur_profile['attachment_type'] = $modSettings['new_avatar_data']['type'];
3426
+					} else {
3427
+											return 'bad_avatar';
3288 3428
 					}
3289
-					else
3290
-						return 'bad_avatar';
3291 3429
 				}
3292 3430
 			}
3293 3431
 		}
3294
-	}
3295
-	elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar)
3432
+	} elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar)
3296 3433
 	{
3297 3434
 		if ((isset($_FILES['attachment']['name']) && $_FILES['attachment']['name'] != '') || $downloadedExternalAvatar)
3298 3435
 		{
3299 3436
 			// Get the dimensions of the image.
3300 3437
 			if (!$downloadedExternalAvatar)
3301 3438
 			{
3302
-				if (!is_writable($uploadDir))
3303
-					fatal_lang_error('attachments_no_write', 'critical');
3439
+				if (!is_writable($uploadDir)) {
3440
+									fatal_lang_error('attachments_no_write', 'critical');
3441
+				}
3304 3442
 
3305 3443
 				$new_filename = $uploadDir . '/' . getAttachmentFilename('avatar_tmp_' . $memID, false, null, true);
3306
-				if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename))
3307
-					fatal_lang_error('attach_timeout', 'critical');
3444
+				if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename)) {
3445
+									fatal_lang_error('attach_timeout', 'critical');
3446
+				}
3308 3447
 
3309 3448
 				$_FILES['attachment']['tmp_name'] = $new_filename;
3310 3449
 			}
@@ -3417,17 +3556,19 @@  discard block
 block discarded – undo
3417 3556
 			$profile_vars['avatar'] = '';
3418 3557
 
3419 3558
 			// Delete any temporary file.
3420
-			if (file_exists($_FILES['attachment']['tmp_name']))
3421
-				@unlink($_FILES['attachment']['tmp_name']);
3559
+			if (file_exists($_FILES['attachment']['tmp_name'])) {
3560
+							@unlink($_FILES['attachment']['tmp_name']);
3561
+			}
3422 3562
 		}
3423 3563
 		// Selected the upload avatar option and had one already uploaded before or didn't upload one.
3424
-		else
3564
+		else {
3565
+					$profile_vars['avatar'] = '';
3566
+		}
3567
+	} elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar')) {
3568
+			$profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address'])));
3569
+	} else {
3425 3570
 			$profile_vars['avatar'] = '';
3426 3571
 	}
3427
-	elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar'))
3428
-		$profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address'])));
3429
-	else
3430
-		$profile_vars['avatar'] = '';
3431 3572
 
3432 3573
 	// Setup the profile variables so it shows things right on display!
3433 3574
 	$cur_profile['avatar'] = $profile_vars['avatar'];
@@ -3475,9 +3616,9 @@  discard block
 block discarded – undo
3475 3616
 		$smiley_parsed = $unparsed_signature;
3476 3617
 		parsesmileys($smiley_parsed);
3477 3618
 		$smiley_count = substr_count(strtolower($smiley_parsed), '<img') - substr_count(strtolower($unparsed_signature), '<img');
3478
-		if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0)
3479
-			return 'signature_allow_smileys';
3480
-		elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4])
3619
+		if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0) {
3620
+					return 'signature_allow_smileys';
3621
+		} elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4])
3481 3622
 		{
3482 3623
 			$txt['profile_error_signature_max_smileys'] = sprintf($txt['profile_error_signature_max_smileys'], $sig_limits[4]);
3483 3624
 			return 'signature_max_smileys';
@@ -3490,14 +3631,15 @@  discard block
 block discarded – undo
3490 3631
 			{
3491 3632
 				$limit_broke = 0;
3492 3633
 				// Attempt to allow all sizes of abuse, so to speak.
3493
-				if ($matches[2][$ind] == 'px' && $size > $sig_limits[7])
3494
-					$limit_broke = $sig_limits[7] . 'px';
3495
-				elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75))
3496
-					$limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt';
3497
-				elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16))
3498
-					$limit_broke = ((float) $sig_limits[7] / 16) . 'em';
3499
-				elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18)
3500
-					$limit_broke = 'large';
3634
+				if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) {
3635
+									$limit_broke = $sig_limits[7] . 'px';
3636
+				} elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) {
3637
+									$limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt';
3638
+				} elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) {
3639
+									$limit_broke = ((float) $sig_limits[7] / 16) . 'em';
3640
+				} elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) {
3641
+									$limit_broke = 'large';
3642
+				}
3501 3643
 
3502 3644
 				if ($limit_broke)
3503 3645
 				{
@@ -3539,24 +3681,26 @@  discard block
 block discarded – undo
3539 3681
 					$width = -1; $height = -1;
3540 3682
 
3541 3683
 					// Does it have predefined restraints? Width first.
3542
-					if ($matches[6][$key])
3543
-						$matches[2][$key] = $matches[6][$key];
3684
+					if ($matches[6][$key]) {
3685
+											$matches[2][$key] = $matches[6][$key];
3686
+					}
3544 3687
 					if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5])
3545 3688
 					{
3546 3689
 						$width = $sig_limits[5];
3547 3690
 						$matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]);
3691
+					} elseif ($matches[2][$key]) {
3692
+											$width = $matches[2][$key];
3548 3693
 					}
3549
-					elseif ($matches[2][$key])
3550
-						$width = $matches[2][$key];
3551 3694
 					// ... and height.
3552 3695
 					if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6])
3553 3696
 					{
3554 3697
 						$height = $sig_limits[6];
3555
-						if ($width != -1)
3556
-							$width = $width * ($height / $matches[4][$key]);
3698
+						if ($width != -1) {
3699
+													$width = $width * ($height / $matches[4][$key]);
3700
+						}
3701
+					} elseif ($matches[4][$key]) {
3702
+											$height = $matches[4][$key];
3557 3703
 					}
3558
-					elseif ($matches[4][$key])
3559
-						$height = $matches[4][$key];
3560 3704
 
3561 3705
 					// If the dimensions are still not fixed - we need to check the actual image.
3562 3706
 					if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6]))
@@ -3574,21 +3718,24 @@  discard block
 block discarded – undo
3574 3718
 							if ($sizes[1] > $sig_limits[6] && $sig_limits[6])
3575 3719
 							{
3576 3720
 								$height = $sig_limits[6];
3577
-								if ($width == -1)
3578
-									$width = $sizes[0];
3721
+								if ($width == -1) {
3722
+																	$width = $sizes[0];
3723
+								}
3579 3724
 								$width = $width * ($height / $sizes[1]);
3725
+							} elseif ($width != -1) {
3726
+															$height = $sizes[1];
3580 3727
 							}
3581
-							elseif ($width != -1)
3582
-								$height = $sizes[1];
3583 3728
 						}
3584 3729
 					}
3585 3730
 
3586 3731
 					// Did we come up with some changes? If so remake the string.
3587
-					if ($width != -1 || $height != -1)
3588
-						$replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]';
3732
+					if ($width != -1 || $height != -1) {
3733
+											$replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]';
3734
+					}
3735
+				}
3736
+				if (!empty($replaces)) {
3737
+									$value = str_replace(array_keys($replaces), array_values($replaces), $value);
3589 3738
 				}
3590
-				if (!empty($replaces))
3591
-					$value = str_replace(array_keys($replaces), array_values($replaces), $value);
3592 3739
 			}
3593 3740
 		}
3594 3741
 
@@ -3632,10 +3779,12 @@  discard block
 block discarded – undo
3632 3779
 	$email = strtr($email, array('&#039;' => '\''));
3633 3780
 
3634 3781
 	// Check the name and email for validity.
3635
-	if (trim($email) == '')
3636
-		return 'no_email';
3637
-	if (!filter_var($email, FILTER_VALIDATE_EMAIL))
3638
-		return 'bad_email';
3782
+	if (trim($email) == '') {
3783
+			return 'no_email';
3784
+	}
3785
+	if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
3786
+			return 'bad_email';
3787
+	}
3639 3788
 
3640 3789
 	// Email addresses should be and stay unique.
3641 3790
 	$request = $smcFunc['db_query']('', '
@@ -3650,8 +3799,9 @@  discard block
 block discarded – undo
3650 3799
 		)
3651 3800
 	);
3652 3801
 
3653
-	if ($smcFunc['db_num_rows']($request) > 0)
3654
-		return 'email_taken';
3802
+	if ($smcFunc['db_num_rows']($request) > 0) {
3803
+			return 'email_taken';
3804
+	}
3655 3805
 	$smcFunc['db_free_result']($request);
3656 3806
 
3657 3807
 	return true;
@@ -3664,8 +3814,9 @@  discard block
 block discarded – undo
3664 3814
 {
3665 3815
 	global $modSettings, $context, $cur_profile;
3666 3816
 
3667
-	if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '')
3668
-		setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt']));
3817
+	if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '') {
3818
+			setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt']));
3819
+	}
3669 3820
 
3670 3821
 	loadUserSettings();
3671 3822
 	writeLog();
@@ -3681,8 +3832,9 @@  discard block
 block discarded – undo
3681 3832
 	require_once($sourcedir . '/Subs-Post.php');
3682 3833
 
3683 3834
 	// Shouldn't happen but just in case.
3684
-	if (empty($profile_vars['email_address']))
3685
-		return;
3835
+	if (empty($profile_vars['email_address'])) {
3836
+			return;
3837
+	}
3686 3838
 
3687 3839
 	$replacements = array(
3688 3840
 		'ACTIVATIONLINK' => $scripturl . '?action=activate;u=' . $context['id_member'] . ';code=' . $profile_vars['validation_code'],
@@ -3705,8 +3857,9 @@  discard block
 block discarded – undo
3705 3857
 	$_SESSION['log_time'] = 0;
3706 3858
 	$_SESSION['login_' . $cookiename] = $smcFunc['json_encode'](array(0, '', 0));
3707 3859
 
3708
-	if (isset($_COOKIE[$cookiename]))
3709
-		$_COOKIE[$cookiename] = '';
3860
+	if (isset($_COOKIE[$cookiename])) {
3861
+			$_COOKIE[$cookiename] = '';
3862
+	}
3710 3863
 
3711 3864
 	loadUserSettings();
3712 3865
 
@@ -3739,11 +3892,13 @@  discard block
 block discarded – undo
3739 3892
 	$groups[] = $curMember['id_group'];
3740 3893
 
3741 3894
 	// Ensure the query doesn't croak!
3742
-	if (empty($groups))
3743
-		$groups = array(0);
3895
+	if (empty($groups)) {
3896
+			$groups = array(0);
3897
+	}
3744 3898
 	// Just to be sure...
3745
-	foreach ($groups as $k => $v)
3746
-		$groups[$k] = (int) $v;
3899
+	foreach ($groups as $k => $v) {
3900
+			$groups[$k] = (int) $v;
3901
+	}
3747 3902
 
3748 3903
 	// Get all the membergroups they can join.
3749 3904
 	$request = $smcFunc['db_query']('', '
@@ -3773,12 +3928,14 @@  discard block
 block discarded – undo
3773 3928
 	while ($row = $smcFunc['db_fetch_assoc']($request))
3774 3929
 	{
3775 3930
 		// Can they edit their primary group?
3776
-		if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups)))
3777
-			$context['can_edit_primary'] = true;
3931
+		if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups))) {
3932
+					$context['can_edit_primary'] = true;
3933
+		}
3778 3934
 
3779 3935
 		// If they can't manage (protected) groups, and it's not publically joinable or already assigned, they can't see it.
3780
-		if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group'])
3781
-			continue;
3936
+		if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group']) {
3937
+					continue;
3938
+		}
3782 3939
 
3783 3940
 		$context['groups'][in_array($row['id_group'], $groups) ? 'member' : 'available'][$row['id_group']] = array(
3784 3941
 			'id' => $row['id_group'],
@@ -3807,13 +3964,15 @@  discard block
 block discarded – undo
3807 3964
 	);
3808 3965
 
3809 3966
 	// No changing primary one unless you have enough groups!
3810
-	if (count($context['groups']['member']) < 2)
3811
-		$context['can_edit_primary'] = false;
3967
+	if (count($context['groups']['member']) < 2) {
3968
+			$context['can_edit_primary'] = false;
3969
+	}
3812 3970
 
3813 3971
 	// In the special case that someone is requesting membership of a group, setup some special context vars.
3814
-	if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2)
3815
-		$context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']];
3816
-}
3972
+	if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2) {
3973
+			$context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']];
3974
+	}
3975
+	}
3817 3976
 
3818 3977
 /**
3819 3978
  * This function actually makes all the group changes
@@ -3828,10 +3987,12 @@  discard block
 block discarded – undo
3828 3987
 	global $user_info, $context, $user_profile, $modSettings, $smcFunc;
3829 3988
 
3830 3989
 	// Let's be extra cautious...
3831
-	if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership']))
3832
-		isAllowedTo('manage_membergroups');
3833
-	if (!isset($_REQUEST['gid']) && !isset($_POST['primary']))
3834
-		fatal_lang_error('no_access', false);
3990
+	if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership'])) {
3991
+			isAllowedTo('manage_membergroups');
3992
+	}
3993
+	if (!isset($_REQUEST['gid']) && !isset($_POST['primary'])) {
3994
+			fatal_lang_error('no_access', false);
3995
+	}
3835 3996
 
3836 3997
 	checkSession(isset($_GET['gid']) ? 'get' : 'post');
3837 3998
 
@@ -3850,8 +4011,9 @@  discard block
 block discarded – undo
3850 4011
 	$foundTarget = $changeType == 'primary' && $group_id == 0 ? true : false;
3851 4012
 
3852 4013
 	// Sanity check!!
3853
-	if ($group_id == 1)
3854
-		isAllowedTo('admin_forum');
4014
+	if ($group_id == 1) {
4015
+			isAllowedTo('admin_forum');
4016
+	}
3855 4017
 	// Protected groups too!
3856 4018
 	else
3857 4019
 	{
@@ -3868,8 +4030,9 @@  discard block
 block discarded – undo
3868 4030
 		list ($is_protected) = $smcFunc['db_fetch_row']($request);
3869 4031
 		$smcFunc['db_free_result']($request);
3870 4032
 
3871
-		if ($is_protected == 1)
3872
-			isAllowedTo('admin_forum');
4033
+		if ($is_protected == 1) {
4034
+					isAllowedTo('admin_forum');
4035
+		}
3873 4036
 	}
3874 4037
 
3875 4038
 	// What ever we are doing, we need to determine if changing primary is possible!
@@ -3891,36 +4054,43 @@  discard block
 block discarded – undo
3891 4054
 			$group_name = $row['group_name'];
3892 4055
 
3893 4056
 			// Does the group type match what we're doing - are we trying to request a non-requestable group?
3894
-			if ($changeType == 'request' && $row['group_type'] != 2)
3895
-				fatal_lang_error('no_access', false);
4057
+			if ($changeType == 'request' && $row['group_type'] != 2) {
4058
+							fatal_lang_error('no_access', false);
4059
+			}
3896 4060
 			// What about leaving a requestable group we are not a member of?
3897
-			elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']]))
3898
-				fatal_lang_error('no_access', false);
3899
-			elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2)
3900
-				fatal_lang_error('no_access', false);
4061
+			elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']])) {
4062
+							fatal_lang_error('no_access', false);
4063
+			} elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2) {
4064
+							fatal_lang_error('no_access', false);
4065
+			}
3901 4066
 
3902 4067
 			// We can't change the primary group if this is hidden!
3903
-			if ($row['hidden'] == 2)
3904
-				$canChangePrimary = false;
4068
+			if ($row['hidden'] == 2) {
4069
+							$canChangePrimary = false;
4070
+			}
3905 4071
 		}
3906 4072
 
3907 4073
 		// If this is their old primary, can we change it?
3908
-		if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false)
3909
-			$canChangePrimary = 1;
4074
+		if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false) {
4075
+					$canChangePrimary = 1;
4076
+		}
3910 4077
 
3911 4078
 		// If we are not doing a force primary move, don't do it automatically if current primary is not 0.
3912
-		if ($changeType != 'primary' && $old_profile['id_group'] != 0)
3913
-			$canChangePrimary = false;
4079
+		if ($changeType != 'primary' && $old_profile['id_group'] != 0) {
4080
+					$canChangePrimary = false;
4081
+		}
3914 4082
 
3915 4083
 		// If this is the one we are acting on, can we even act?
3916
-		if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0))
3917
-			$canChangePrimary = false;
4084
+		if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) {
4085
+					$canChangePrimary = false;
4086
+		}
3918 4087
 	}
3919 4088
 	$smcFunc['db_free_result']($request);
3920 4089
 
3921 4090
 	// Didn't find the target?
3922
-	if (!$foundTarget)
3923
-		fatal_lang_error('no_access', false);
4091
+	if (!$foundTarget) {
4092
+			fatal_lang_error('no_access', false);
4093
+	}
3924 4094
 
3925 4095
 	// Final security check, don't allow users to promote themselves to admin.
3926 4096
 	if ($context['can_manage_membergroups'] && !allowedTo('admin_forum'))
@@ -3940,8 +4110,9 @@  discard block
 block discarded – undo
3940 4110
 		list ($disallow) = $smcFunc['db_fetch_row']($request);
3941 4111
 		$smcFunc['db_free_result']($request);
3942 4112
 
3943
-		if ($disallow)
3944
-			isAllowedTo('admin_forum');
4113
+		if ($disallow) {
4114
+					isAllowedTo('admin_forum');
4115
+		}
3945 4116
 	}
3946 4117
 
3947 4118
 	// If we're requesting, add the note then return.
@@ -3959,8 +4130,9 @@  discard block
 block discarded – undo
3959 4130
 				'status_open' => 0,
3960 4131
 			)
3961 4132
 		);
3962
-		if ($smcFunc['db_num_rows']($request) != 0)
3963
-			fatal_lang_error('profile_error_already_requested_group');
4133
+		if ($smcFunc['db_num_rows']($request) != 0) {
4134
+					fatal_lang_error('profile_error_already_requested_group');
4135
+		}
3964 4136
 		$smcFunc['db_free_result']($request);
3965 4137
 
3966 4138
 		// Log the request.
@@ -3994,10 +4166,11 @@  discard block
 block discarded – undo
3994 4166
 		// Are we leaving?
3995 4167
 		if ($old_profile['id_group'] == $group_id || isset($addGroups[$group_id]))
3996 4168
 		{
3997
-			if ($old_profile['id_group'] == $group_id)
3998
-				$newPrimary = 0;
3999
-			else
4000
-				unset($addGroups[$group_id]);
4169
+			if ($old_profile['id_group'] == $group_id) {
4170
+							$newPrimary = 0;
4171
+			} else {
4172
+							unset($addGroups[$group_id]);
4173
+			}
4001 4174
 		}
4002 4175
 		// ... if not, must be joining.
4003 4176
 		else
@@ -4005,36 +4178,42 @@  discard block
 block discarded – undo
4005 4178
 			// Can we change the primary, and do we want to?
4006 4179
 			if ($canChangePrimary)
4007 4180
 			{
4008
-				if ($old_profile['id_group'] != 0)
4009
-					$addGroups[$old_profile['id_group']] = -1;
4181
+				if ($old_profile['id_group'] != 0) {
4182
+									$addGroups[$old_profile['id_group']] = -1;
4183
+				}
4010 4184
 				$newPrimary = $group_id;
4011 4185
 			}
4012 4186
 			// Otherwise it's an additional group...
4013
-			else
4014
-				$addGroups[$group_id] = -1;
4187
+			else {
4188
+							$addGroups[$group_id] = -1;
4189
+			}
4015 4190
 		}
4016 4191
 	}
4017 4192
 	// Finally, we must be setting the primary.
4018 4193
 	elseif ($canChangePrimary)
4019 4194
 	{
4020
-		if ($old_profile['id_group'] != 0)
4021
-			$addGroups[$old_profile['id_group']] = -1;
4022
-		if (isset($addGroups[$group_id]))
4023
-			unset($addGroups[$group_id]);
4195
+		if ($old_profile['id_group'] != 0) {
4196
+					$addGroups[$old_profile['id_group']] = -1;
4197
+		}
4198
+		if (isset($addGroups[$group_id])) {
4199
+					unset($addGroups[$group_id]);
4200
+		}
4024 4201
 		$newPrimary = $group_id;
4025 4202
 	}
4026 4203
 
4027 4204
 	// Finally, we can make the changes!
4028
-	foreach ($addGroups as $id => $dummy)
4029
-		if (empty($id))
4205
+	foreach ($addGroups as $id => $dummy) {
4206
+			if (empty($id))
4030 4207
 			unset($addGroups[$id]);
4208
+	}
4031 4209
 	$addGroups = implode(',', array_flip($addGroups));
4032 4210
 
4033 4211
 	// Ensure that we don't cache permissions if the group is changing.
4034
-	if ($context['user']['is_owner'])
4035
-		$_SESSION['mc']['time'] = 0;
4036
-	else
4037
-		updateSettings(array('settings_updated' => time()));
4212
+	if ($context['user']['is_owner']) {
4213
+			$_SESSION['mc']['time'] = 0;
4214
+	} else {
4215
+			updateSettings(array('settings_updated' => time()));
4216
+	}
4038 4217
 
4039 4218
 	updateMemberData($memID, array('id_group' => $newPrimary, 'additional_groups' => $addGroups));
4040 4219
 
@@ -4057,8 +4236,9 @@  discard block
 block discarded – undo
4057 4236
 	if (empty($user_settings['tfa_secret']) && $context['user']['is_owner'])
4058 4237
 	{
4059 4238
 		// Check to ensure we're forcing SSL for authentication
4060
-		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn())
4061
-			fatal_lang_error('login_ssl_required');
4239
+		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) {
4240
+					fatal_lang_error('login_ssl_required');
4241
+		}
4062 4242
 
4063 4243
 		// In some cases (forced 2FA or backup code) they would be forced to be redirected here,
4064 4244
 		// we do not want too much AJAX to confuse them.
@@ -4095,8 +4275,7 @@  discard block
 block discarded – undo
4095 4275
 				$context['sub_template'] = 'tfasetup_backup';
4096 4276
 
4097 4277
 				return;
4098
-			}
4099
-			else
4278
+			} else
4100 4279
 			{
4101 4280
 				$context['tfa_secret'] = $_SESSION['tfa_secret'];
4102 4281
 				$context['tfa_error'] = !$valid_code;
@@ -4104,8 +4283,7 @@  discard block
 block discarded – undo
4104 4283
 				$context['tfa_pass_value'] = $_POST['passwd'];
4105 4284
 				$context['tfa_value'] = $_POST['tfa_code'];
4106 4285
 			}
4107
-		}
4108
-		else
4286
+		} else
4109 4287
 		{
4110 4288
 			$totp = new \TOTP\Auth();
4111 4289
 			$secret = $totp->generateCode();
@@ -4115,17 +4293,16 @@  discard block
 block discarded – undo
4115 4293
 		}
4116 4294
 
4117 4295
 		$context['tfa_qr_url'] = $totp->getQrCodeUrl($context['forum_name'] . ':' . $user_info['name'], $context['tfa_secret']);
4118
-	}
4119
-	elseif (isset($_REQUEST['disable']))
4296
+	} elseif (isset($_REQUEST['disable']))
4120 4297
 	{
4121 4298
 		updateMemberData($memID, array(
4122 4299
 			'tfa_secret' => '',
4123 4300
 			'tfa_backup' => '',
4124 4301
 		));
4125 4302
 		redirectexit('action=profile;area=account;u=' . $memID);
4303
+	} else {
4304
+			redirectexit('action=profile;area=account;u=' . $memID);
4305
+	}
4126 4306
 	}
4127
-	else
4128
-		redirectexit('action=profile;area=account;u=' . $memID);
4129
-}
4130 4307
 
4131 4308
 ?>
4132 4309
\ No newline at end of file
Please login to merge, or discard this patch.
Themes/default/Post.template.php 1 patch
Braces   +108 added lines, -73 removed lines patch added patch discarded remove patch
@@ -22,24 +22,26 @@  discard block
 block discarded – undo
22 22
 		<script>';
23 23
 
24 24
 	// When using Go Back due to fatal_error, allow the form to be re-submitted with changes.
25
-	if (isBrowser('is_firefox'))
26
-		echo '
25
+	if (isBrowser('is_firefox')) {
26
+			echo '
27 27
 			window.addEventListener("pageshow", reActivate, false);';
28
+	}
28 29
 
29 30
 	// Start with message icons - and any missing from this theme.
30 31
 	echo '
31 32
 			var icon_urls = {';
32 33
 
33
-	foreach ($context['icons'] as $icon)
34
-		echo '
34
+	foreach ($context['icons'] as $icon) {
35
+			echo '
35 36
 				\'', $icon['value'], '\': \'', $icon['url'], '\'', $icon['is_last'] ? '' : ',';
37
+	}
36 38
 
37 39
 	echo '
38 40
 			};';
39 41
 
40 42
 	// If this is a poll - use some javascript to ensure the user doesn't create a poll with illegal option combinations.
41
-	if ($context['make_poll'])
42
-		echo '
43
+	if ($context['make_poll']) {
44
+			echo '
43 45
 			var pollOptionNum = 0, pollTabIndex;
44 46
 			var pollOptionId = ', $context['last_choice_id'], ';
45 47
 			function addPollOption()
@@ -58,11 +60,13 @@  discard block
 block discarded – undo
58 60
 
59 61
 				setOuterHTML(document.getElementById(\'pollMoreOptions\'), ', JavaScriptEscape('<dt><label for="options-'), ' + pollOptionId + ', JavaScriptEscape('">' . $txt['option'] . ' '), ' + pollOptionNum + ', JavaScriptEscape('</label>:</dt><dd><input type="text" name="options['), ' + pollOptionId + ', JavaScriptEscape(']" id="options-'), ' + pollOptionId + ', JavaScriptEscape('" value="" size="80" maxlength="255" tabindex="'), ' + pollTabIndex + ', JavaScriptEscape('"></dd><p id="pollMoreOptions"></p>'), ');
60 62
 			}';
63
+	}
61 64
 
62 65
 	// If we are making a calendar event we want to ensure we show the current days in a month etc... this is done here.
63
-	if ($context['make_event'])
64
-		echo '
66
+	if ($context['make_event']) {
67
+			echo '
65 68
 			var monthLength = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];';
69
+	}
66 70
 
67 71
 	// End of the javascript, start the form and display the link tree.
68 72
 	echo '
@@ -83,9 +87,10 @@  discard block
 block discarded – undo
83 87
 			</div>
84 88
 			<br>';
85 89
 
86
-	if ($context['make_event'] && (!$context['event']['new'] || !empty($context['current_board'])))
87
-		echo '
90
+	if ($context['make_event'] && (!$context['event']['new'] || !empty($context['current_board']))) {
91
+			echo '
88 92
 			<input type="hidden" name="eventid" value="', $context['event']['id'], '">';
93
+	}
89 94
 
90 95
 	// Start the main table.
91 96
 	echo '
@@ -110,26 +115,29 @@  discard block
 block discarded – undo
110 115
 					</div>';
111 116
 
112 117
 	// If this won't be approved let them know!
113
-	if (!$context['becomes_approved'])
114
-		echo '
118
+	if (!$context['becomes_approved']) {
119
+			echo '
115 120
 					<div class="noticebox">
116 121
 						<em>', $txt['wait_for_approval'], '</em>
117 122
 						<input type="hidden" name="not_approved" value="1">
118 123
 					</div>';
124
+	}
119 125
 
120 126
 	// If it's locked, show a message to warn the replier.
121
-	if (!empty($context['locked']))
122
-	echo '
127
+	if (!empty($context['locked'])) {
128
+		echo '
123 129
 					<div class="errorbox">
124 130
 						', $txt['topic_locked_no_reply'], '
125 131
 					</div>';
132
+	}
126 133
 
127
-	if (!empty($modSettings['drafts_post_enabled']))
128
-		echo '
134
+	if (!empty($modSettings['drafts_post_enabled'])) {
135
+			echo '
129 136
 					<div id="draft_section" class="infobox"', isset($context['draft_saved']) ? '' : ' style="display: none;"', '>',
130 137
 						sprintf($txt['draft_saved'], $scripturl . '?action=profile;u=' . $context['user']['id'] . ';area=showdrafts'), '
131 138
 						', (!empty($modSettings['drafts_keep_days']) ? ' <strong>' . sprintf($txt['draft_save_warning'], $modSettings['drafts_keep_days']) . '</strong>' : ''), '
132 139
 					</div>';
140
+	}
133 141
 
134 142
 	// The post header... important stuff
135 143
 	echo '
@@ -139,14 +147,15 @@  discard block
 block discarded – undo
139 147
 	// Mod & theme authors can use the 'integrate_post_end' hook to modify or add to these (see Post.php)
140 148
 	if (!empty($context['posting_fields']) && is_array($context['posting_fields']))
141 149
 	{
142
-		foreach ($context['posting_fields'] as $pfid => $pf)
143
-			echo '
150
+		foreach ($context['posting_fields'] as $pfid => $pf) {
151
+					echo '
144 152
 						<dt class="clear', !is_numeric($pfid) ? ' pf_' . $pfid : '', '">
145 153
 							', $pf['dt'], '
146 154
 						</dt>
147 155
 						<dd', !is_numeric($pfid) ? ' class="pf_' . $pfid . '"' : '', '>
148 156
 							', preg_replace('~<(input|select|textarea|button|area|a|object)\b~', '<$1 tabindex="' . $context['tabindex']++ . '"', $pf['dd']), '
149 157
 						</dd>';
158
+		}
150 159
 	}
151 160
 
152 161
 	echo '
@@ -180,9 +189,10 @@  discard block
 block discarded – undo
180 189
 				echo '
181 190
 										<optgroup label="', $category['name'], '">';
182 191
 
183
-				foreach ($category['boards'] as $board)
184
-					echo '
192
+				foreach ($category['boards'] as $board) {
193
+									echo '
185 194
 											<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=&gt;' : '', ' ', $board['name'], '</option>';
195
+				}
186 196
 				echo '
187 197
 										</optgroup>';
188 198
 			}
@@ -218,9 +228,10 @@  discard block
 block discarded – undo
218 228
 									<span class="label">', $txt['calendar_timezone'], '</span>
219 229
 									<select name="tz" id="tz"', !empty($context['event']['allday']) ? ' disabled' : '', '>';
220 230
 
221
-		foreach ($context['all_timezones'] as $tz => $tzname)
222
-			echo '
231
+		foreach ($context['all_timezones'] as $tz => $tzname) {
232
+					echo '
223 233
 										<option', is_numeric($tz) ? ' value="" disabled' : ' value="' . $tz . '"', $tz === $context['event']['tz'] ? ' selected' : '', '>', $tzname, '</option>';
234
+		}
224 235
 
225 236
 		echo '
226 237
 									</select>
@@ -249,14 +260,15 @@  discard block
 block discarded – undo
249 260
 								</dd>';
250 261
 
251 262
 		// Loop through all the choices and print them out.
252
-		foreach ($context['choices'] as $choice)
253
-			echo '
263
+		foreach ($context['choices'] as $choice) {
264
+					echo '
254 265
 								<dt>
255 266
 									<label for="options-', $choice['id'], '">', $txt['option'], ' ', $choice['number'], '</label>:
256 267
 								</dt>
257 268
 								<dd>
258 269
 									<input type="text" name="options[', $choice['id'], ']" id="options-', $choice['id'], '" value="', $choice['label'], '" tabindex="', $context['tabindex']++, '" size="80" maxlength="255">
259 270
 								</dd>';
271
+		}
260 272
 
261 273
 		echo '
262 274
 								<p id="pollMoreOptions"></p>
@@ -286,14 +298,15 @@  discard block
 block discarded – undo
286 298
 									<input type="checkbox" id="poll_change_vote" name="poll_change_vote"', !empty($context['poll']['change_vote']) ? ' checked' : '', '>
287 299
 								</dd>';
288 300
 
289
-		if ($context['poll_options']['guest_vote_enabled'])
290
-			echo '
301
+		if ($context['poll_options']['guest_vote_enabled']) {
302
+					echo '
291 303
 								<dt>
292 304
 									<label for="poll_guest_vote">', $txt['poll_guest_vote'], ':</label>
293 305
 								</dt>
294 306
 								<dd>
295 307
 									<input type="checkbox" id="poll_guest_vote" name="poll_guest_vote"', !empty($context['poll_options']['guest_vote']) ? ' checked' : '', '>
296 308
 								</dd>';
309
+		}
297 310
 
298 311
 		echo '
299 312
 								<dt>
@@ -314,8 +327,8 @@  discard block
 block discarded – undo
314 327
 					', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message');
315 328
 
316 329
 	// If we're editing and displaying edit details, show a box where they can say why
317
-	if (isset($context['editing']) && $modSettings['show_modify'])
318
-		echo '
330
+	if (isset($context['editing']) && $modSettings['show_modify']) {
331
+			echo '
319 332
 					<dl>
320 333
 						<dt class="clear">
321 334
 							<span id="caption_edit_reason">', $txt['reason_for_edit'], ':</span>
@@ -324,20 +337,23 @@  discard block
 block discarded – undo
324 337
 							<input type="text" name="modify_reason"', isset($context['last_modified_reason']) ? ' value="' . $context['last_modified_reason'] . '"' : '', ' tabindex="', $context['tabindex']++, '" size="80" maxlength="80">
325 338
 						</dd>
326 339
 					</dl>';
340
+	}
327 341
 
328 342
 	// If this message has been edited in the past - display when it was.
329
-	if (isset($context['last_modified']))
330
-		echo '
343
+	if (isset($context['last_modified'])) {
344
+			echo '
331 345
 					<div class="padding smalltext">
332 346
 						', $context['last_modified_text'], '
333 347
 					</div>';
348
+	}
334 349
 
335 350
 	// If the admin has enabled the hiding of the additional options - show a link and image for it.
336
-	if (!empty($modSettings['additional_options_collapsable']))
337
-		echo '
351
+	if (!empty($modSettings['additional_options_collapsable'])) {
352
+			echo '
338 353
 					<div id="postAdditionalOptionsHeader">
339 354
 						<strong><a href="#" id="postMoreExpandLink"> ', $context['can_post_attachment'] ? $txt['post_additionalopt_attach'] : $txt['post_additionalopt'], '</a></strong>
340 355
 					</div>';
356
+	}
341 357
 
342 358
 	echo '
343 359
 					<div id="postAdditionalOptions">';
@@ -370,19 +386,21 @@  discard block
 block discarded – undo
370 386
 								', $txt['uncheck_unwatchd_attach'], ':
371 387
 							</dd>';
372 388
 
373
-		foreach ($context['current_attachments'] as $attachment)
374
-			echo '
389
+		foreach ($context['current_attachments'] as $attachment) {
390
+					echo '
375 391
 							<dd class="smalltext">
376 392
 								<label for="attachment_', $attachment['attachID'], '"><input type="checkbox" id="attachment_', $attachment['attachID'], '" name="attach_del[]" value="', $attachment['attachID'], '"', empty($attachment['unchecked']) ? ' checked' : '', '> ', $attachment['name'], (empty($attachment['approved']) ? ' (' . $txt['awaiting_approval'] . ')' : ''),
377 393
 								!empty($modSettings['attachmentPostLimit']) || !empty($modSettings['attachmentSizeLimit']) ? sprintf($txt['attach_kb'], comma_format(round(max($attachment['size'], 1024) / 1024), 0)) : '', '</label>
378 394
 							</dd>';
395
+		}
379 396
 
380 397
 		echo '
381 398
 						</dl>';
382 399
 
383
-		if (!empty($context['files_in_session_warning']))
384
-			echo '
400
+		if (!empty($context['files_in_session_warning'])) {
401
+					echo '
385 402
 						<div class="smalltext">', $context['files_in_session_warning'], '</div>';
403
+		}
386 404
 	}
387 405
 
388 406
 	// Is the user allowed to post any additional ones? If so give them the boxes to do it!
@@ -447,13 +465,14 @@  discard block
 block discarded – undo
447 465
 									<div class="fallback">
448 466
 										<input type="file" multiple="multiple" name="attachment[]" id="attachment1" class="fallback"> (<a href="javascript:void(0);" onclick="cleanFileInput(\'attachment1\');">', $txt['clean_attach'], '</a>)';
449 467
 
450
-		if (!empty($modSettings['attachmentSizeLimit']))
451
-			echo '
468
+		if (!empty($modSettings['attachmentSizeLimit'])) {
469
+					echo '
452 470
 										<input type="hidden" name="MAX_FILE_SIZE" value="' . $modSettings['attachmentSizeLimit'] * 1024 . '">';
471
+		}
453 472
 
454 473
 		// Show more boxes if they aren't approaching that limit.
455
-		if ($context['num_allowed_attachments'] > 1)
456
-			echo '
474
+		if ($context['num_allowed_attachments'] > 1) {
475
+					echo '
457 476
 										<script>
458 477
 											var allowed_attachments = ', $context['num_allowed_attachments'], ';
459 478
 											var current_attachment = 1;
@@ -473,6 +492,7 @@  discard block
 block discarded – undo
473 492
 										<a href="#" onclick="addAttachment(); return false;">(', $txt['more_attachments'], ')</a>
474 493
 									</div><!-- .fallback -->
475 494
 								</div><!-- #attachUpload -->';
495
+		}
476 496
 
477 497
 		echo '
478 498
 							</dd>';
@@ -484,21 +504,25 @@  discard block
 block discarded – undo
484 504
 							<dd class="smalltext">';
485 505
 
486 506
 		// Show some useful information such as allowed extensions, maximum size and amount of attachments allowed.
487
-		if (!empty($modSettings['attachmentCheckExtensions']))
488
-			echo '
507
+		if (!empty($modSettings['attachmentCheckExtensions'])) {
508
+					echo '
489 509
 								', $txt['allowed_types'], ': ', $context['allowed_extensions'], '<br>';
510
+		}
490 511
 
491
-		if (!empty($context['attachment_restrictions']))
492
-			echo '
512
+		if (!empty($context['attachment_restrictions'])) {
513
+					echo '
493 514
 								', $txt['attach_restrictions'], ' ', implode(', ', $context['attachment_restrictions']), '<br>';
515
+		}
494 516
 
495
-		if ($context['num_allowed_attachments'] == 0)
496
-			echo '
517
+		if ($context['num_allowed_attachments'] == 0) {
518
+					echo '
497 519
 								', $txt['attach_limit_nag'], '<br>';
520
+		}
498 521
 
499
-		if (!$context['can_post_attachment_unapproved'])
500
-			echo '
522
+		if (!$context['can_post_attachment_unapproved']) {
523
+					echo '
501 524
 								<span class="alert">', $txt['attachment_requires_approval'], '</span>', '<br>';
525
+		}
502 526
 
503 527
 		echo '
504 528
 							</dd>
@@ -522,24 +546,26 @@  discard block
 block discarded – undo
522 546
 							<dt><strong>', $txt['subject'], '</strong></dt>
523 547
 							<dd><strong>', $txt['draft_saved_on'], '</strong></dd>';
524 548
 
525
-		foreach ($context['drafts'] as $draft)
526
-			echo '
549
+		foreach ($context['drafts'] as $draft) {
550
+					echo '
527 551
 							<dt>', $draft['link'], '</dt>
528 552
 							<dd>', $draft['poster_time'], '</dd>';
553
+		}
529 554
 		echo '
530 555
 						</dl>
531 556
 					</div>';
532 557
 	}
533 558
 
534 559
 	// Is visual verification enabled?
535
-	if ($context['require_verification'])
536
-		echo '
560
+	if ($context['require_verification']) {
561
+			echo '
537 562
 					<div class="post_verification">
538 563
 						<span', !empty($context['post_error']['need_qr_verification']) ? ' class="error"' : '', '>
539 564
 							<strong>', $txt['verification'], ':</strong>
540 565
 						</span>
541 566
 						', template_control_verification($context['visual_verification_id'], 'all'), '
542 567
 					</div>';
568
+	}
543 569
 
544 570
 	// Finally, the submit buttons.
545 571
 	echo '
@@ -548,9 +574,10 @@  discard block
 block discarded – undo
548 574
 						', template_control_richedit_buttons($context['post_box_name']);
549 575
 
550 576
 	// Option to delete an event if user is editing one.
551
-	if ($context['make_event'] && !$context['event']['new'])
552
-		echo '
577
+	if ($context['make_event'] && !$context['event']['new']) {
578
+			echo '
553 579
 						<input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['event_delete_confirm'] ,'" class="button you_sure">';
580
+	}
554 581
 
555 582
 	echo '
556 583
 					</span>
@@ -559,9 +586,10 @@  discard block
 block discarded – undo
559 586
 			<br class="clear">';
560 587
 
561 588
 	// Assuming this isn't a new topic pass across the last message id.
562
-	if (isset($context['topic_last_message']))
563
-		echo '
589
+	if (isset($context['topic_last_message'])) {
590
+			echo '
564 591
 			<input type="hidden" name="last_msg" value="', $context['topic_last_message'], '">';
592
+	}
565 593
 
566 594
 	echo '
567 595
 			<input type="hidden" name="additional_options" id="additional_options" value="', $context['show_additional_options'] ? '1' : '0', '">
@@ -704,9 +732,10 @@  discard block
 block discarded – undo
704 732
 
705 733
 						newPostsHTML += \'<div class="windowbg\' + (++reply_counter % 2 == 0 ? \'2\' : \'\') + \'"><div id="msg\' + newPosts[i].getAttribute("id") + \'"><div class="floatleft"><h5>', $txt['posted_by'], ': \' + newPosts[i].getElementsByTagName("poster")[0].firstChild.nodeValue + \'</h5><span class="smalltext">&#171;&nbsp;<strong>', $txt['on'], ':</strong> \' + newPosts[i].getElementsByTagName("time")[0].firstChild.nodeValue + \'&nbsp;&#187;</span> <span class="new_posts" id="image_new_\' + newPosts[i].getAttribute("id") + \'">', $txt['new'], '</span></div>\';';
706 734
 
707
-	if ($context['can_quote'])
708
-		echo '
735
+	if ($context['can_quote']) {
736
+			echo '
709 737
 						newPostsHTML += \'<ul class="quickbuttons" id="msg_\' + newPosts[i].getAttribute("id") + \'_quote"><li><a href="#postmodify" onclick="return insertQuoteFast(\\\'\' + newPosts[i].getAttribute("id") + \'\\\');" class="quote_button"><span>', $txt['quote'], '</span><\' + \'/a></li></ul>\';';
738
+	}
710 739
 
711 740
 	echo '
712 741
 						newPostsHTML += \'<br class="clear">\';
@@ -749,8 +778,8 @@  discard block
 block discarded – undo
749 778
 			}';
750 779
 
751 780
 	// Code for showing and hiding additional options.
752
-	if (!empty($modSettings['additional_options_collapsable']))
753
-		echo '
781
+	if (!empty($modSettings['additional_options_collapsable'])) {
782
+			echo '
754 783
 			var oSwapAdditionalOptions = new smc_Toggle({
755 784
 				bToggleEnabled: true,
756 785
 				bCurrentlyCollapsed: ', $context['show_additional_options'] ? 'false' : 'true', ',
@@ -778,10 +807,11 @@  discard block
 block discarded – undo
778 807
 					}
779 808
 				]
780 809
 			});';
810
+	}
781 811
 
782 812
 	// Code for showing and hiding drafts
783
-	if (!empty($context['drafts']))
784
-		echo '
813
+	if (!empty($context['drafts'])) {
814
+			echo '
785 815
 			var oSwapDraftOptions = new smc_Toggle({
786 816
 				bToggleEnabled: true,
787 817
 				bCurrentlyCollapsed: true,
@@ -803,6 +833,7 @@  discard block
 block discarded – undo
803 833
 					}
804 834
 				]
805 835
 			});';
836
+	}
806 837
 
807 838
 	echo '
808 839
 			var oEditorID = "', $context['post_box_name'] ,'";
@@ -823,8 +854,9 @@  discard block
 block discarded – undo
823 854
 		foreach ($context['previous_posts'] as $post)
824 855
 		{
825 856
 			$ignoring = false;
826
-			if (!empty($post['is_ignored']))
827
-				$ignored_posts[] = $ignoring = $post['id'];
857
+			if (!empty($post['is_ignored'])) {
858
+							$ignored_posts[] = $ignoring = $post['id'];
859
+			}
828 860
 
829 861
 			echo '
830 862
 			<div class="windowbg">
@@ -834,22 +866,24 @@  discard block
 block discarded – undo
834 866
 					</h5>
835 867
 					&nbsp;-&nbsp;', $post['time'];
836 868
 
837
-			if ($context['can_quote'])
838
-				echo '
869
+			if ($context['can_quote']) {
870
+							echo '
839 871
 					<ul class="quickbuttons" id="msg_', $post['id'], '_quote">
840 872
 						<li style="display:none;" id="quoteSelected_', $post['id'], '" data-msgid="', $post['id'], '"><a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'] ,'</a></li>
841 873
 						<li id="post_modify"><a href="#postmodify" onclick="return insertQuoteFast(', $post['id'], ');"><span class="generic_icons quote"></span>', $txt['quote'], '</a></li>
842 874
 					</ul>';
875
+			}
843 876
 
844 877
 			echo '
845 878
 					<br class="clear">';
846 879
 
847
-			if ($ignoring)
848
-				echo '
880
+			if ($ignoring) {
881
+							echo '
849 882
 					<div id="msg_', $post['id'], '_ignored_prompt" class="smalltext">
850 883
 						', $txt['ignoring_user'], '
851 884
 						<a href="#" id="msg_', $post['id'], '_ignored_link" style="display: none;">', $txt['show_ignore_user_post'], '</a>
852 885
 					</div>';
886
+			}
853 887
 
854 888
 			echo '
855 889
 					<div class="list_posts smalltext" id="msg_', $post['id'], '_body" data-msgid="', $post['id'], '">', $post['message'], '</div>
@@ -1004,10 +1038,10 @@  discard block
 block discarded – undo
1004 1038
 		<div id="temporary_posting_area" style="display: none;"></div>
1005 1039
 		<script>';
1006 1040
 
1007
-	if ($context['close_window'])
1008
-		echo '
1041
+	if ($context['close_window']) {
1042
+			echo '
1009 1043
 			window.close();';
1010
-	else
1044
+	} else
1011 1045
 	{
1012 1046
 		// Lucky for us, Internet Explorer has an "innerText" feature which basically converts entities <--> text. Use it if possible ;)
1013 1047
 		echo '
@@ -1061,11 +1095,12 @@  discard block
 block discarded – undo
1061 1095
 				</p>
1062 1096
 				<ul>';
1063 1097
 
1064
-	foreach ($context['groups'] as $group)
1065
-		echo '
1098
+	foreach ($context['groups'] as $group) {
1099
+			echo '
1066 1100
 					<li>
1067 1101
 						<label for="who_', $group['id'], '"><input type="checkbox" name="who[', $group['id'], ']" id="who_', $group['id'], '" value="', $group['id'], '" checked> ', $group['name'], '</label> <em>(', $group['member_count'], ')</em>
1068 1102
 					</li>';
1103
+	}
1069 1104
 
1070 1105
 	echo '
1071 1106
 					<li>
Please login to merge, or discard this patch.
Themes/default/MessageIndex.template.php 1 patch
Braces   +103 added lines, -72 removed lines patch added patch discarded remove patch
@@ -18,11 +18,12 @@  discard block
 block discarded – undo
18 18
 	global $context, $settings, $options, $scripturl, $modSettings, $txt;
19 19
 
20 20
 	// Let them know why their message became unapproved.
21
-	if ($context['becomesUnapproved'])
22
-		echo '
21
+	if ($context['becomesUnapproved']) {
22
+			echo '
23 23
 	<div class="noticebox">
24 24
 		', $txt['post_becomesUnapproved'], '
25 25
 	</div>';
26
+	}
26 27
 
27 28
 	if (!empty($context['boards']) && (!empty($options['show_children']) || $context['start'] == 0))
28 29
 	{
@@ -46,17 +47,19 @@  discard block
 block discarded – undo
46 47
 				</a>';
47 48
 
48 49
 			// Has it outstanding posts for approval?
49
-			if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics']))
50
-				echo '
50
+			if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) {
51
+							echo '
51 52
 				<a href="', $scripturl, '?action=moderate;area=postmod;sa=', ($board['unapproved_topics'] > 0 ? 'topics' : 'posts'), ';brd=', $board['id'], ';', $context['session_var'], '=', $context['session_id'], '" title="', sprintf($txt['unapproved_posts'], $board['unapproved_topics'], $board['unapproved_posts']), '" class="moderation_link">(!)</a>';
53
+			}
52 54
 
53 55
 			echo '
54 56
 				<p class="board_description">', $board['description'], '</p>';
55 57
 
56 58
 			// Show the "Moderators: ". Each has name, href, link, and id. (but we're gonna use link_moderators.)
57
-			if (!empty($board['moderators']) || !empty($board['moderator_groups']))
58
-				echo '
59
+			if (!empty($board['moderators']) || !empty($board['moderator_groups'])) {
60
+							echo '
59 61
 				<p class="moderators">', count($board['link_moderators']) === 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $board['link_moderators']), '</p>';
62
+			}
60 63
 
61 64
 			// Show some basic information about the number of posts, etc.
62 65
 			echo '
@@ -68,9 +71,10 @@  discard block
 block discarded – undo
68 71
 			</div>
69 72
 			<div class="lastpost lpr_border">';
70 73
 
71
-			if (!empty($board['last_post']['id']))
72
-				echo '
74
+			if (!empty($board['last_post']['id'])) {
75
+							echo '
73 76
 				<p>', $board['last_post']['last_post_message'], '</p>';
77
+			}
74 78
 
75 79
 			echo '
76 80
 			</div>';
@@ -84,14 +88,16 @@  discard block
 block discarded – undo
84 88
 					id, name, description, new (is it new?), topics (#), posts (#), href, link, and last_post. */
85 89
 				foreach ($board['children'] as $child)
86 90
 				{
87
-					if (!$child['is_redirect'])
88
-						$child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')" class="new_posts">' . $txt['new'] . '</a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>';
89
-					else
90
-						$child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . '">' . $child['name'] . '</a>';
91
+					if (!$child['is_redirect']) {
92
+											$child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')" class="new_posts">' . $txt['new'] . '</a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>';
93
+					} else {
94
+											$child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . '">' . $child['name'] . '</a>';
95
+					}
91 96
 
92 97
 					// Has it posts awaiting approval?
93
-					if ($child['can_approve_posts'] && ($child['unapproved_posts'] | $child['unapproved_topics']))
94
-						$child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>';
98
+					if ($child['can_approve_posts'] && ($child['unapproved_posts'] | $child['unapproved_topics'])) {
99
+											$child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>';
100
+					}
95 101
 
96 102
 					$children[] = $child['new'] ? '<span class="strong">' . $child['link'] . '</span>' : '<span>' . $child['link'] . '</span>';
97 103
 				}
@@ -113,11 +119,12 @@  discard block
 block discarded – undo
113 119
 	if (!$context['no_topic_listing'])
114 120
 	{
115 121
 		// Mobile action buttons (top)
116
-		if (!empty($context['normal_buttons']))
117
-		echo '
122
+		if (!empty($context['normal_buttons'])) {
123
+				echo '
118 124
 	<div class="mobile_buttons floatright">
119 125
 		<a class="button mobile_act">', $txt['mobile_action'], '</a>
120 126
 	</div>';
127
+		}
121 128
 
122 129
 		echo '
123 130
 	<div class="pagesection">
@@ -136,13 +143,15 @@  discard block
 block discarded – undo
136 143
 		<h3>', $context['name'], '</h3>
137 144
 		<p>';
138 145
 
139
-			if ($context['description'] != '')
140
-				echo '
146
+			if ($context['description'] != '') {
147
+							echo '
141 148
 			', $context['description'];
149
+			}
142 150
 
143
-			if (!empty($context['moderators']))
144
-				echo '
151
+			if (!empty($context['moderators'])) {
152
+							echo '
145 153
 			', count($context['moderators']) === 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $context['link_moderators']), '.';
154
+			}
146 155
 
147 156
 			echo '
148 157
 		</p>
@@ -150,9 +159,10 @@  discard block
 block discarded – undo
150 159
 		}
151 160
 
152 161
 		// If Quick Moderation is enabled start the form.
153
-		if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics']))
154
-			echo '
162
+		if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) {
163
+					echo '
155 164
 	<form action="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], '" method="post" accept-charset="', $context['character_set'], '" class="clear" name="quickModForm" id="quickModForm">';
165
+		}
156 166
 
157 167
 		echo '
158 168
 		<div id="messageindex">';
@@ -162,11 +172,11 @@  discard block
 block discarded – undo
162 172
 			echo '
163 173
 			<div class="information">';
164 174
 
165
-			if ($settings['display_who_viewing'] == 1)
166
-				echo count($context['view_members']), ' ', count($context['view_members']) === 1 ? $txt['who_member'] : $txt['members'];
167
-
168
-			else
169
-				echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . (empty($context['view_num_hidden']) || $context['can_moderate_forum'] ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')');
175
+			if ($settings['display_who_viewing'] == 1) {
176
+							echo count($context['view_members']), ' ', count($context['view_members']) === 1 ? $txt['who_member'] : $txt['members'];
177
+			} else {
178
+							echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . (empty($context['view_num_hidden']) || $context['can_moderate_forum'] ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')');
179
+			}
170 180
 			echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['guest'] : $txt['guests'], $txt['who_viewing_board'];
171 181
 
172 182
 		echo '
@@ -186,32 +196,36 @@  discard block
 block discarded – undo
186 196
 				<div class="lastpost">', $context['topics_headers']['last_post'], '</div>';
187 197
 
188 198
 			// Show a "select all" box for quick moderation?
189
-			if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1)
190
-				echo '
199
+			if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) {
200
+							echo '
191 201
 				<div class="moderation">
192 202
 					<input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');">
193 203
 				</div>';
204
+			}
194 205
 
195 206
 			// If it's on in "image" mode, don't show anything but the column.
196
-			elseif (!empty($context['can_quick_mod']))
197
-				echo '
207
+			elseif (!empty($context['can_quick_mod'])) {
208
+							echo '
198 209
 				<div class="moderation"></div>';
210
+			}
199 211
 		}
200 212
 
201 213
 		// No topics... just say, "sorry bub".
202
-		else
203
-			echo '
214
+		else {
215
+					echo '
204 216
 				<h3 class="titlebg">', $txt['topic_alert_none'], '</h3>';
217
+		}
205 218
 
206 219
 		echo '
207 220
 			</div><!-- #topic_header -->';
208 221
 
209 222
 		// If this person can approve items and we have some awaiting approval tell them.
210
-		if (!empty($context['unapproved_posts_message']))
211
-			echo '
223
+		if (!empty($context['unapproved_posts_message'])) {
224
+					echo '
212 225
 			<div class="information">
213 226
 				<span class="alert">!</span> ', $context['unapproved_posts_message'], '
214 227
 			</div>';
228
+		}
215 229
 
216 230
 		// Contain the topic list
217 231
 		echo '
@@ -232,25 +246,30 @@  discard block
 block discarded – undo
232 246
 			echo '
233 247
 							<div class="icons floatright">';
234 248
 
235
-			if ($topic['is_watched'])
236
-				echo '
249
+			if ($topic['is_watched']) {
250
+							echo '
237 251
 								<span class="generic_icons watch" title="', $txt['watching_this_topic'], '"></span>';
252
+			}
238 253
 
239
-			if ($topic['is_locked'])
240
-				echo '
254
+			if ($topic['is_locked']) {
255
+							echo '
241 256
 								<span class="generic_icons lock"></span>';
257
+			}
242 258
 
243
-			if ($topic['is_sticky'])
244
-				echo '
259
+			if ($topic['is_sticky']) {
260
+							echo '
245 261
 								<span class="generic_icons sticky"></span>';
262
+			}
246 263
 
247
-			if ($topic['is_redirect'])
248
-				echo '
264
+			if ($topic['is_redirect']) {
265
+							echo '
249 266
 								<span class="generic_icons move"></span>';
267
+			}
250 268
 
251
-			if ($topic['is_poll'])
252
-				echo '
269
+			if ($topic['is_poll']) {
270
+							echo '
253 271
 								<span class="generic_icons poll"></span>';
272
+			}
254 273
 
255 274
 			echo '
256 275
 							</div>';
@@ -282,26 +301,31 @@  discard block
 block discarded – undo
282 301
 				echo '
283 302
 					<div class="moderation">';
284 303
 
285
-				if ($options['display_quick_mod'] == 1)
286
-					echo '
304
+				if ($options['display_quick_mod'] == 1) {
305
+									echo '
287 306
 						<input type="checkbox" name="topics[]" value="', $topic['id'], '">';
288
-				else
307
+				} else
289 308
 				{
290 309
 					// Check permissions on each and show only the ones they are allowed to use.
291
-					if ($topic['quick_mod']['remove'])
292
-						echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=remove;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons delete" title="', $txt['remove_topic'], '"></span></a>';
310
+					if ($topic['quick_mod']['remove']) {
311
+											echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=remove;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons delete" title="', $txt['remove_topic'], '"></span></a>';
312
+					}
293 313
 
294
-					if ($topic['quick_mod']['lock'])
295
-						echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=lock;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons lock" title="', $topic['is_locked'] ? $txt['set_unlock'] : $txt['set_lock'], '"></span></a>';
314
+					if ($topic['quick_mod']['lock']) {
315
+											echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=lock;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons lock" title="', $topic['is_locked'] ? $txt['set_unlock'] : $txt['set_lock'], '"></span></a>';
316
+					}
296 317
 
297
-					if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove'])
298
-						echo '<br>';
318
+					if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) {
319
+											echo '<br>';
320
+					}
299 321
 
300
-					if ($topic['quick_mod']['sticky'])
301
-						echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=sticky;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons sticky" title="', $topic['is_sticky'] ? $txt['set_nonsticky'] : $txt['set_sticky'], '"></span></a>';
322
+					if ($topic['quick_mod']['sticky']) {
323
+											echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=sticky;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons sticky" title="', $topic['is_sticky'] ? $txt['set_nonsticky'] : $txt['set_sticky'], '"></span></a>';
324
+					}
302 325
 
303
-					if ($topic['quick_mod']['move'])
304
-						echo '<a href="', $scripturl, '?action=movetopic;current_board=', $context['current_board'], ';board=', $context['current_board'], '.', $context['start'], ';topic=', $topic['id'], '.0"><span class="generic_icons move" title="', $txt['move_topic'], '"></span></a>';
326
+					if ($topic['quick_mod']['move']) {
327
+											echo '<a href="', $scripturl, '?action=movetopic;current_board=', $context['current_board'], ';board=', $context['current_board'], '.', $context['start'], ';topic=', $topic['id'], '.0"><span class="generic_icons move" title="', $txt['move_topic'], '"></span></a>';
328
+					}
305 329
 				}
306 330
 				echo '
307 331
 					</div><!-- .moderation -->';
@@ -319,18 +343,20 @@  discard block
 block discarded – undo
319 343
 				<select class="qaction" name="qaction"', $context['can_move'] ? ' onchange="this.form.move_to.disabled = (this.options[this.selectedIndex].value != \'move\');"' : '', '>
320 344
 					<option value="">--------</option>';
321 345
 
322
-			foreach ($context['qmod_actions'] as $qmod_action)
323
-				if ($context['can_' . $qmod_action])
346
+			foreach ($context['qmod_actions'] as $qmod_action) {
347
+							if ($context['can_' . $qmod_action])
324 348
 					echo '
325 349
 					<option value="' . $qmod_action . '">' . $txt['quick_mod_' . $qmod_action] . '</option>';
350
+			}
326 351
 
327 352
 			echo '
328 353
 				</select>';
329 354
 
330 355
 			// Show a list of boards they can move the topic to.
331
-			if ($context['can_move'])
332
-				echo '
356
+			if ($context['can_move']) {
357
+							echo '
333 358
 				<span id="quick_mod_jump_to"></span>';
359
+			}
334 360
 
335 361
 			echo '
336 362
 				<input type="submit" value="', $txt['quick_mod_go'], '" onclick="return document.forms.quickModForm.qaction.value != \'\' &amp;&amp; confirm(\'', $txt['quickmod_confirm'], '\');" class="button qaction">
@@ -341,17 +367,19 @@  discard block
 block discarded – undo
341 367
 		</div><!-- #messageindex -->';
342 368
 
343 369
 		// Finish off the form - again.
344
-		if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics']))
345
-			echo '
370
+		if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) {
371
+					echo '
346 372
 		<input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '">
347 373
 	</form>';
374
+		}
348 375
 
349 376
 		// Mobile action buttons (bottom)
350
-		if (!empty($context['normal_buttons']))
351
-		echo '
377
+		if (!empty($context['normal_buttons'])) {
378
+				echo '
352 379
 	<div class="mobile_buttons floatright">
353 380
 		<a class="button mobile_act">', $txt['mobile_action'], '</a>
354 381
 	</div>';
382
+		}
355 383
 
356 384
 		echo '
357 385
 	<div class="pagesection">
@@ -367,8 +395,8 @@  discard block
 block discarded – undo
367 395
 	// Show breadcrumbs at the bottom too.
368 396
 	theme_linktree();
369 397
 
370
-	if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move'])
371
-		echo '
398
+	if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) {
399
+			echo '
372 400
 	<script>
373 401
 		if (typeof(window.XMLHttpRequest) != "undefined")
374 402
 			aJumpTo[aJumpTo.length] = new JumpTo({
@@ -387,6 +415,7 @@  discard block
 block discarded – undo
387 415
 				sCustomName: "move_to"
388 416
 			});
389 417
 	</script>';
418
+	}
390 419
 
391 420
 	// Javascript for inline editing.
392 421
 	echo '
@@ -423,8 +452,8 @@  discard block
 block discarded – undo
423 452
 		<div class="information">
424 453
 			<p class="floatright" id="message_index_jump_to"></p>';
425 454
 
426
-	if (empty($context['no_topic_listing']))
427
-		echo '
455
+	if (empty($context['no_topic_listing'])) {
456
+			echo '
428 457
 			<p class="floatleft">', !empty($modSettings['enableParticipation']) && $context['user']['is_logged'] ? '
429 458
 				<img src="' . $settings['images_url'] . '/icons/profile_sm.png" alt="" class="centericon"> ' . $txt['participation_caption'] . '<br>' : '', '
430 459
 				'. ($modSettings['pollMode'] == '1' ? '<span class="generic_icons poll centericon"></span> ' . $txt['poll'] : '') . '<br>
@@ -434,9 +463,10 @@  discard block
 block discarded – undo
434 463
 				<span class="generic_icons lock centericon"></span> ' . $txt['locked_topic'] . '<br>
435 464
 				<span class="generic_icons sticky centericon"></span> ' . $txt['sticky_topic'] . '<br>
436 465
 			</p>';
466
+	}
437 467
 
438
-	if (!empty($context['jump_to']))
439
-		echo '
468
+	if (!empty($context['jump_to'])) {
469
+			echo '
440 470
 			<script>
441 471
 				if (typeof(window.XMLHttpRequest) != "undefined")
442 472
 					aJumpTo[aJumpTo.length] = new JumpTo({
@@ -452,6 +482,7 @@  discard block
 block discarded – undo
452 482
 						sGoButtonLabel: "', $txt['quick_mod_go'], '"
453 483
 					});
454 484
 			</script>';
485
+	}
455 486
 
456 487
 	echo '
457 488
 			<br class="clear">
Please login to merge, or discard this patch.
Themes/default/Display.template.php 1 patch
Braces   +254 added lines, -174 removed lines patch added patch discarded remove patch
@@ -18,18 +18,20 @@  discard block
 block discarded – undo
18 18
 	global $context, $settings, $options, $txt, $scripturl, $modSettings;
19 19
 
20 20
 	// Let them know, if their report was a success!
21
-	if ($context['report_sent'])
22
-		echo '
21
+	if ($context['report_sent']) {
22
+			echo '
23 23
 		<div class="infobox">
24 24
 			', $txt['report_sent'], '
25 25
 		</div>';
26
+	}
26 27
 
27 28
 	// Let them know why their message became unapproved.
28
-	if ($context['becomesUnapproved'])
29
-		echo '
29
+	if ($context['becomesUnapproved']) {
30
+			echo '
30 31
 		<div class="noticebox">
31 32
 			', $txt['post_becomesUnapproved'], '
32 33
 		</div>';
34
+	}
33 35
 
34 36
 	// Show new topic info here?
35 37
 	echo '
@@ -49,11 +51,13 @@  discard block
 block discarded – undo
49 51
 			<p>';
50 52
 
51 53
 		// Show just numbers...?
52
-		if ($settings['display_who_viewing'] == 1)
53
-			echo count($context['view_members']), ' ', count($context['view_members']) == 1 ? $txt['who_member'] : $txt['members'];
54
+		if ($settings['display_who_viewing'] == 1) {
55
+					echo count($context['view_members']), ' ', count($context['view_members']) == 1 ? $txt['who_member'] : $txt['members'];
56
+		}
54 57
 		// Or show the actual people viewing the topic?
55
-		else
56
-			echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . ((empty($context['view_num_hidden']) || $context['can_moderate_forum']) ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')');
58
+		else {
59
+					echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . ((empty($context['view_num_hidden']) || $context['can_moderate_forum']) ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')');
60
+		}
57 61
 
58 62
 		// Now show how many guests are here too.
59 63
 		echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['guest'] : $txt['guests'], $txt['who_viewing_topic'], '
@@ -91,10 +95,11 @@  discard block
 block discarded – undo
91 95
 						<dt class="', $option['voted_this'] ? ' voted' : '', '">', $option['option'], '</dt>
92 96
 						<dd class="statsbar generic_bar', $option['voted_this'] ? ' voted' : '', '">';
93 97
 
94
-				if ($context['allow_results_view'])
95
-					echo '
98
+				if ($context['allow_results_view']) {
99
+									echo '
96 100
 							', $option['bar_ndt'], '
97 101
 							<span class="percentage">', $option['votes'], ' (', $option['percent'], '%)</span>';
102
+				}
98 103
 
99 104
 				echo '
100 105
 						</dd>';
@@ -103,9 +108,10 @@  discard block
 block discarded – undo
103 108
 			echo '
104 109
 					</dl>';
105 110
 
106
-			if ($context['allow_results_view'])
107
-				echo '
111
+			if ($context['allow_results_view']) {
112
+							echo '
108 113
 					<p><strong>', $txt['poll_total_voters'], ':</strong> ', $context['poll']['total_votes'], '</p>';
114
+			}
109 115
 		}
110 116
 		// They are allowed to vote! Go to it!
111 117
 		else
@@ -114,17 +120,19 @@  discard block
 block discarded – undo
114 120
 					<form action="', $scripturl, '?action=vote;topic=', $context['current_topic'], '.', $context['start'], ';poll=', $context['poll']['id'], '" method="post" accept-charset="', $context['character_set'], '">';
115 121
 
116 122
 			// Show a warning if they are allowed more than one option.
117
-			if ($context['poll']['allowed_warning'])
118
-				echo '
123
+			if ($context['poll']['allowed_warning']) {
124
+							echo '
119 125
 						<p class="smallpadding">', $context['poll']['allowed_warning'], '</p>';
126
+			}
120 127
 
121 128
 			echo '
122 129
 						<ul class="options">';
123 130
 
124 131
 			// Show each option with its button - a radio likely.
125
-			foreach ($context['poll']['options'] as $option)
126
-				echo '
132
+			foreach ($context['poll']['options'] as $option) {
133
+							echo '
127 134
 							<li>', $option['vote_button'], ' <label for="', $option['id'], '">', $option['option'], '</label></li>';
135
+			}
128 136
 
129 137
 			echo '
130 138
 						</ul>
@@ -136,9 +144,10 @@  discard block
 block discarded – undo
136 144
 		}
137 145
 
138 146
 		// Is the clock ticking?
139
-		if (!empty($context['poll']['expire_time']))
140
-			echo '
147
+		if (!empty($context['poll']['expire_time'])) {
148
+					echo '
141 149
 					<p><strong>', ($context['poll']['is_expired'] ? $txt['poll_expired_on'] : $txt['poll_expires_on']), ':</strong> ', $context['poll']['expire_time'], '</p>';
150
+		}
142 151
 
143 152
 		echo '
144 153
 				</div><!-- #poll_options -->
@@ -168,11 +177,13 @@  discard block
 block discarded – undo
168 177
 				<li>
169 178
 					<strong class="event_title"><a href="', $scripturl, '?action=calendar;event=', $event['id'], '">', $event['title'], '</a></strong>';
170 179
 
171
-			if ($event['can_edit'])
172
-				echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>';
180
+			if ($event['can_edit']) {
181
+							echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>';
182
+			}
173 183
 
174
-			if ($event['can_export'])
175
-				echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>';
184
+			if ($event['can_export']) {
185
+							echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>';
186
+			}
176 187
 
177 188
 			echo '
178 189
 					<br>';
@@ -180,14 +191,14 @@  discard block
 block discarded – undo
180 191
 			if (!empty($event['allday']))
181 192
 			{
182 193
 				echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), '</time>', ($event['start_date'] != $event['end_date']) ? ' &ndash; <time datetime="' . $event['end_iso_gmdate'] . '">' . trim($event['end_date_local']) . '</time>' : '';
183
-			}
184
-			else
194
+			} else
185 195
 			{
186 196
 				// Display event info relative to user's local timezone
187 197
 				echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), ', ', trim($event['start_time_local']), '</time> &ndash; <time datetime="' . $event['end_iso_gmdate'] . '">';
188 198
 
189
-				if ($event['start_date_local'] != $event['end_date_local'])
190
-					echo trim($event['end_date_local']) . ', ';
199
+				if ($event['start_date_local'] != $event['end_date_local']) {
200
+									echo trim($event['end_date_local']) . ', ';
201
+				}
191 202
 
192 203
 				echo trim($event['end_time_local']);
193 204
 
@@ -196,24 +207,28 @@  discard block
 block discarded – undo
196 207
 				{
197 208
 					echo '</time> (<time datetime="' . $event['start_iso_gmdate'] . '">';
198 209
 
199
-					if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig'])
200
-						echo trim($event['start_date_orig']), ', ';
210
+					if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) {
211
+											echo trim($event['start_date_orig']), ', ';
212
+					}
201 213
 
202 214
 					echo trim($event['start_time_orig']), '</time> &ndash; <time datetime="' . $event['end_iso_gmdate'] . '">';
203 215
 
204
-					if ($event['start_date_orig'] != $event['end_date_orig'])
205
-						echo trim($event['end_date_orig']) . ', ';
216
+					if ($event['start_date_orig'] != $event['end_date_orig']) {
217
+											echo trim($event['end_date_orig']) . ', ';
218
+					}
206 219
 
207 220
 					echo trim($event['end_time_orig']), ' ', $event['tz_abbrev'], '</time>)';
208 221
 				}
209 222
 				// Event is scheduled in the user's own timezone? Let 'em know, just to avoid confusion
210
-				else
211
-					echo ' ', $event['tz_abbrev'], '</time>';
223
+				else {
224
+									echo ' ', $event['tz_abbrev'], '</time>';
225
+				}
212 226
 			}
213 227
 
214
-			if (!empty($event['location']))
215
-				echo '
228
+			if (!empty($event['location'])) {
229
+							echo '
216 230
 					<br>', $event['location'];
231
+			}
217 232
 
218 233
 			echo '
219 234
 				</li>';
@@ -235,12 +250,13 @@  discard block
 block discarded – undo
235 250
 		</div>';
236 251
 
237 252
 	// Mobile action - moderation buttons (top)
238
-	if (!empty($context['normal_buttons']))
239
-	echo '
253
+	if (!empty($context['normal_buttons'])) {
254
+		echo '
240 255
 		<div class="mobile_buttons floatright">
241 256
 			<a class="button mobile_act">', $txt['mobile_action'], '</a>
242 257
 			', !empty($context['mod_buttons']) ? '<a class="button mobile_mod">' . $txt['mobile_moderation'] . '</a>' : '', '
243 258
 		</div>';
259
+	}
244 260
 
245 261
 	// Show the topic information - icon, subject, etc.
246 262
 	echo '
@@ -251,20 +267,22 @@  discard block
 block discarded – undo
251 267
 	$context['removableMessageIDs'] = array();
252 268
 
253 269
 	// Get all the messages...
254
-	while ($message = $context['get_message']())
255
-		template_single_post($message);
270
+	while ($message = $context['get_message']()) {
271
+			template_single_post($message);
272
+	}
256 273
 
257 274
 	echo '
258 275
 			</form>
259 276
 		</div><!-- #forumposts -->';
260 277
 
261 278
 	// Mobile action - moderation buttons (bottom)
262
-	if (!empty($context['normal_buttons']))
263
-	echo '
279
+	if (!empty($context['normal_buttons'])) {
280
+		echo '
264 281
 		<div class="mobile_buttons floatright">
265 282
 			<a class="button mobile_act">', $txt['mobile_action'], '</a>
266 283
 			', !empty($context['mod_buttons']) ? '<a class="button mobile_mod">' . $txt['mobile_moderation'] . '</a>' : '', '
267 284
 		</div>';
285
+	}
268 286
 
269 287
 	// Show the page index... "Pages: [1]".
270 288
 	echo '
@@ -291,8 +309,9 @@  discard block
 block discarded – undo
291 309
 		<div id="display_jump_to"></div>';
292 310
 
293 311
 	// Show quickreply
294
-	if ($context['can_reply'])
295
-		template_quickreply();
312
+	if ($context['can_reply']) {
313
+			template_quickreply();
314
+	}
296 315
 
297 316
 	// User action pop on mobile screen (or actually small screen), this uses responsive css does not check mobile device.
298 317
 	echo '
@@ -307,8 +326,8 @@  discard block
 block discarded – undo
307 326
 		</div>';
308 327
 
309 328
 	// Show the moderation button & pop (if there is anything to show)
310
-	if (!empty($context['mod_buttons']))
311
-		echo '
329
+	if (!empty($context['mod_buttons'])) {
330
+			echo '
312 331
 		<div id="mobile_moderation" class="popup_container">
313 332
 			<div class="popup_window description">
314 333
 				<div class="popup_heading">
@@ -320,6 +339,7 @@  discard block
 block discarded – undo
320 339
 				</div>
321 340
 			</div>
322 341
 		</div>';
342
+	}
323 343
 
324 344
 	echo '
325 345
 		<script>';
@@ -443,9 +463,10 @@  discard block
 block discarded – undo
443 463
 				});
444 464
 			}';
445 465
 
446
-	if (!empty($context['ignoredMsgs']))
447
-		echo '
466
+	if (!empty($context['ignoredMsgs'])) {
467
+			echo '
448 468
 			ignore_toggles([', implode(', ', $context['ignoredMsgs']), '], ', JavaScriptEscape($txt['show_ignore_user_post']), ');';
469
+	}
449 470
 
450 471
 	echo '
451 472
 		</script>';
@@ -462,8 +483,9 @@  discard block
 block discarded – undo
462 483
 
463 484
 	$ignoring = false;
464 485
 
465
-	if ($message['can_remove'])
466
-		$context['removableMessageIDs'][] = $message['id'];
486
+	if ($message['can_remove']) {
487
+			$context['removableMessageIDs'][] = $message['id'];
488
+	}
467 489
 
468 490
 	// Are we ignoring this message?
469 491
 	if (!empty($message['is_ignored']))
@@ -490,9 +512,10 @@  discard block
 block discarded – undo
490 512
 							<div class="custom_fields_above_member">
491 513
 								<ul class="nolist">';
492 514
 
493
-		foreach ($message['custom_fields']['above_member'] as $custom)
494
-			echo '
515
+		foreach ($message['custom_fields']['above_member'] as $custom) {
516
+					echo '
495 517
 									<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
518
+		}
496 519
 
497 520
 		echo '
498 521
 								</ul>
@@ -503,25 +526,28 @@  discard block
 block discarded – undo
503 526
 							<h4>';
504 527
 
505 528
 	// Show online and offline buttons?
506
-	if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest'])
507
-		echo '
529
+	if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) {
530
+			echo '
508 531
 								', $context['can_send_pm'] ? '<a href="' . $message['member']['online']['href'] . '" title="' . $message['member']['online']['label'] . '">' : '', '<span class="' . ($message['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $message['member']['online']['text'] . '"></span>', $context['can_send_pm'] ? '</a>' : '';
532
+	}
509 533
 
510 534
 	// Custom fields BEFORE the username?
511
-	if (!empty($message['custom_fields']['before_member']))
512
-		foreach ($message['custom_fields']['before_member'] as $custom)
535
+	if (!empty($message['custom_fields']['before_member'])) {
536
+			foreach ($message['custom_fields']['before_member'] as $custom)
513 537
 			echo '
514 538
 								<span class="custom ', $custom['col_name'], '">', $custom['value'], '</span>';
539
+	}
515 540
 
516 541
 	// Show a link to the member's profile.
517 542
 	echo '
518 543
 								', $message['member']['link'];
519 544
 
520 545
 	// Custom fields AFTER the username?
521
-	if (!empty($message['custom_fields']['after_member']))
522
-		foreach ($message['custom_fields']['after_member'] as $custom)
546
+	if (!empty($message['custom_fields']['after_member'])) {
547
+			foreach ($message['custom_fields']['after_member'] as $custom)
523 548
 			echo '
524 549
 								<span class="custom ', $custom['col_name'], '">', $custom['value'], '</span>';
550
+	}
525 551
 
526 552
 	// Begin display of user info
527 553
 	echo '
@@ -529,50 +555,58 @@  discard block
 block discarded – undo
529 555
 							<ul class="user_info">';
530 556
 
531 557
 	// Show the user's avatar.
532
-	if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image']))
533
-		echo '
558
+	if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) {
559
+			echo '
534 560
 								<li class="avatar">
535 561
 									<a href="', $message['member']['href'], '">', $message['member']['avatar']['image'], '</a>
536 562
 								</li>';
563
+	}
537 564
 
538 565
 	// Are there any custom fields below the avatar?
539
-	if (!empty($message['custom_fields']['below_avatar']))
540
-		foreach ($message['custom_fields']['below_avatar'] as $custom)
566
+	if (!empty($message['custom_fields']['below_avatar'])) {
567
+			foreach ($message['custom_fields']['below_avatar'] as $custom)
541 568
 			echo '
542 569
 								<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
570
+	}
543 571
 
544 572
 	// Show the post group icons, but not for guests.
545
-	if (!$message['member']['is_guest'])
546
-		echo '
573
+	if (!$message['member']['is_guest']) {
574
+			echo '
547 575
 								<li class="icons">', $message['member']['group_icons'], '</li>';
576
+	}
548 577
 
549 578
 	// Show the member's primary group (like 'Administrator') if they have one.
550
-	if (!empty($message['member']['group']))
551
-		echo '
579
+	if (!empty($message['member']['group'])) {
580
+			echo '
552 581
 								<li class="membergroup">', $message['member']['group'], '</li>';
582
+	}
553 583
 
554 584
 	// Show the member's custom title, if they have one.
555
-	if (!empty($message['member']['title']))
556
-		echo '
585
+	if (!empty($message['member']['title'])) {
586
+			echo '
557 587
 								<li class="title">', $message['member']['title'], '</li>';
588
+	}
558 589
 
559 590
 	// Don't show these things for guests.
560 591
 	if (!$message['member']['is_guest'])
561 592
 	{
562 593
 		// Show the post group if and only if they have no other group or the option is on, and they are in a post group.
563
-		if ((empty($modSettings['hide_post_group']) || empty($message['member']['group'])) && !empty($message['member']['post_group']))
564
-			echo '
594
+		if ((empty($modSettings['hide_post_group']) || empty($message['member']['group'])) && !empty($message['member']['post_group'])) {
595
+					echo '
565 596
 								<li class="postgroup">', $message['member']['post_group'], '</li>';
597
+		}
566 598
 
567 599
 		// Show how many posts they have made.
568
-		if (!isset($context['disabled_fields']['posts']))
569
-			echo '
600
+		if (!isset($context['disabled_fields']['posts'])) {
601
+					echo '
570 602
 								<li class="postcount">', $txt['member_postcount'], ': ', $message['member']['posts'], '</li>';
603
+		}
571 604
 
572 605
 		// Show their personal text?
573
-		if (!empty($modSettings['show_blurb']) && !empty($message['member']['blurb']))
574
-			echo '
606
+		if (!empty($modSettings['show_blurb']) && !empty($message['member']['blurb'])) {
607
+					echo '
575 608
 								<li class="blurb">', $message['member']['blurb'], '</li>';
609
+		}
576 610
 
577 611
 		// Any custom fields to show as icons?
578 612
 		if (!empty($message['custom_fields']['icons']))
@@ -581,9 +615,10 @@  discard block
 block discarded – undo
581 615
 								<li class="im_icons">
582 616
 									<ol>';
583 617
 
584
-			foreach ($message['custom_fields']['icons'] as $custom)
585
-				echo '
618
+			foreach ($message['custom_fields']['icons'] as $custom) {
619
+							echo '
586 620
 										<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
621
+			}
587 622
 
588 623
 			echo '
589 624
 									</ol>
@@ -598,19 +633,22 @@  discard block
 block discarded – undo
598 633
 									<ol class="profile_icons">';
599 634
 
600 635
 			// Don't show an icon if they haven't specified a website.
601
-			if (!empty($message['member']['website']['url']) && !isset($context['disabled_fields']['website']))
602
-				echo '
636
+			if (!empty($message['member']['website']['url']) && !isset($context['disabled_fields']['website'])) {
637
+							echo '
603 638
 										<li><a href="', $message['member']['website']['url'], '" title="' . $message['member']['website']['title'] . '" target="_blank" rel="noopener">', ($settings['use_image_buttons'] ? '<span class="generic_icons www centericon" title="' . $message['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>';
639
+			}
604 640
 
605 641
 			// Since we know this person isn't a guest, you *can* message them.
606
-			if ($context['can_send_pm'])
607
-				echo '
642
+			if ($context['can_send_pm']) {
643
+							echo '
608 644
 										<li><a href="', $scripturl, '?action=pm;sa=send;u=', $message['member']['id'], '" title="', $message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline'], '">', $settings['use_image_buttons'] ? '<span class="generic_icons im_' . ($message['member']['online']['is_online'] ? 'on' : 'off') . ' centericon" title="' . ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']) . '"></span> ' : ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']), '</a></li>';
645
+			}
609 646
 
610 647
 			// Show the email if necessary
611
-			if (!empty($message['member']['email']) && $message['member']['show_email'])
612
-				echo '
648
+			if (!empty($message['member']['email']) && $message['member']['show_email']) {
649
+							echo '
613 650
 										<li class="email"><a href="mailto:' . $message['member']['email'] . '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>';
651
+			}
614 652
 
615 653
 			echo '
616 654
 									</ol>
@@ -618,57 +656,65 @@  discard block
 block discarded – undo
618 656
 		}
619 657
 
620 658
 		// Any custom fields for standard placement?
621
-		if (!empty($message['custom_fields']['standard']))
622
-			foreach ($message['custom_fields']['standard'] as $custom)
659
+		if (!empty($message['custom_fields']['standard'])) {
660
+					foreach ($message['custom_fields']['standard'] as $custom)
623 661
 				echo '
624 662
 								<li class="custom ', $custom['col_name'], '">', $custom['title'], ': ', $custom['value'], '</li>';
663
+		}
625 664
 	}
626 665
 	// Otherwise, show the guest's email.
627
-	elseif (!empty($message['member']['email']) && $message['member']['show_email'])
628
-		echo '
666
+	elseif (!empty($message['member']['email']) && $message['member']['show_email']) {
667
+			echo '
629 668
 								<li class="email">
630 669
 									<a href="mailto:' . $message['member']['email'] . '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a>
631 670
 								</li>';
671
+	}
632 672
 
633 673
 	// Show the IP to this user for this post - because you can moderate?
634
-	if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip']))
635
-		echo '
674
+	if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) {
675
+			echo '
636 676
 								<li class="poster_ip">
637 677
 									<a href="', $scripturl, '?action=', !empty($message['member']['is_guest']) ? 'trackip' : 'profile;area=tracking;sa=ip;u=' . $message['member']['id'], ';searchip=', $message['member']['ip'], '">', $message['member']['ip'], '</a> <a href="', $scripturl, '?action=helpadmin;help=see_admin_ip" onclick="return reqOverlayDiv(this.href);" class="help">(?)</a>
638 678
 								</li>';
679
+	}
639 680
 
640 681
 	// Or, should we show it because this is you?
641
-	elseif ($message['can_see_ip'])
642
-		echo '
682
+	elseif ($message['can_see_ip']) {
683
+			echo '
643 684
 								<li class="poster_ip">
644 685
 									<a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $message['member']['ip'], '</a>
645 686
 								</li>';
687
+	}
646 688
 
647 689
 	// Okay, are you at least logged in? Then we can show something about why IPs are logged...
648
-	elseif (!$context['user']['is_guest'])
649
-		echo '
690
+	elseif (!$context['user']['is_guest']) {
691
+			echo '
650 692
 								<li class="poster_ip">
651 693
 									<a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $txt['logged'], '</a>
652 694
 								</li>';
695
+	}
653 696
 
654 697
 	// Otherwise, you see NOTHING!
655
-	else
656
-		echo '
698
+	else {
699
+			echo '
657 700
 								<li class="poster_ip">', $txt['logged'], '</li>';
701
+	}
658 702
 
659 703
 	// Are we showing the warning status?
660 704
 	// Don't show these things for guests.
661
-	if (!$message['member']['is_guest'] && $message['member']['can_see_warning'])
662
-		echo '
705
+	if (!$message['member']['is_guest'] && $message['member']['can_see_warning']) {
706
+			echo '
663 707
 								<li class="warning">
664 708
 									', $context['can_issue_warning'] ? '<a href="' . $scripturl . '?action=profile;area=issuewarning;u=' . $message['member']['id'] . '">' : '', '<span class="generic_icons warning_', $message['member']['warning_status'], '"></span> ', $context['can_issue_warning'] ? '</a>' : '', '<span class="warn_', $message['member']['warning_status'], '">', $txt['warn_' . $message['member']['warning_status']], '</span>
665 709
 								</li>';
710
+	}
666 711
 
667 712
 	// Are there any custom fields to show at the bottom of the poster info?
668
-	if (!empty($message['custom_fields']['bottom_poster']))
669
-		foreach ($message['custom_fields']['bottom_poster'] as $custom)
713
+	if (!empty($message['custom_fields']['bottom_poster'])) {
714
+			foreach ($message['custom_fields']['bottom_poster'] as $custom)
670 715
 			echo '
671 716
 								<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
717
+	}
672 718
 
673 719
 	// Poster info ends.
674 720
 	echo '
@@ -698,9 +744,10 @@  discard block
 block discarded – undo
698 744
 	echo '
699 745
 									<span class="smalltext modified floatright', !empty($modSettings['show_modify']) && !empty($message['modified']['name']) ? ' mvisible' : '','" id="modified_', $message['id'], '">';
700 746
 
701
-	if (!empty($modSettings['show_modify']) && !empty($message['modified']['name']))
702
-		echo
747
+	if (!empty($modSettings['show_modify']) && !empty($message['modified']['name'])) {
748
+			echo
703 749
 										$message['modified']['last_edit_text'];
750
+	}
704 751
 
705 752
 	echo '
706 753
 									</span>
@@ -709,22 +756,24 @@  discard block
 block discarded – undo
709 756
 							</div><!-- .keyinfo -->';
710 757
 
711 758
 	// Ignoring this user? Hide the post.
712
-	if ($ignoring)
713
-		echo '
759
+	if ($ignoring) {
760
+			echo '
714 761
 							<div id="msg_', $message['id'], '_ignored_prompt">
715 762
 								', $txt['ignoring_user'], '
716 763
 								<a href="#" id="msg_', $message['id'], '_ignored_link" style="display: none;">', $txt['show_ignore_user_post'], '</a>
717 764
 							</div>';
765
+	}
718 766
 
719 767
 	// Show the post itself, finally!
720 768
 	echo '
721 769
 							<div class="post">';
722 770
 
723
-	if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id'])
724
-		echo '
771
+	if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id']) {
772
+			echo '
725 773
 								<div class="approve_post">
726 774
 									', $txt['post_awaiting_approval'], '
727 775
 								</div>';
776
+	}
728 777
 	echo '
729 778
 								<div class="inner" data-msgid="', $message['id'], '" id="msg_', $message['id'], '"', $ignoring ? ' style="display:none;"' : '', '>
730 779
 									', $message['body'], '
@@ -743,9 +792,9 @@  discard block
 block discarded – undo
743 792
 		foreach ($message['attachment'] as $attachment)
744 793
 		{
745 794
 			// Do we want this attachment to not be showed here?
746
-			if (!empty($modSettings['dont_show_attach_under_post']) && !empty($context['show_attach_under_post'][$attachment['id']]))
747
-				continue;
748
-			elseif (!$div_output)
795
+			if (!empty($modSettings['dont_show_attach_under_post']) && !empty($context['show_attach_under_post'][$attachment['id']])) {
796
+							continue;
797
+			} elseif (!$div_output)
749 798
 			{
750 799
 				$div_output = true;
751 800
 
@@ -762,9 +811,10 @@  discard block
 block discarded – undo
762 811
 									<legend>
763 812
 										', $txt['attach_awaiting_approve'];
764 813
 
765
-				if ($context['can_approve'])
766
-					echo '
814
+				if ($context['can_approve']) {
815
+									echo '
767 816
 										&nbsp;[<a href="', $scripturl, '?action=attachapprove;sa=all;mid=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve_all'], '</a>]';
817
+				}
768 818
 
769 819
 				echo '
770 820
 									</legend>';
@@ -778,12 +828,13 @@  discard block
 block discarded – undo
778 828
 				echo '
779 829
 										<div class="attachments_top">';
780 830
 
781
-				if ($attachment['thumbnail']['has_thumb'])
782
-					echo '
831
+				if ($attachment['thumbnail']['has_thumb']) {
832
+									echo '
783 833
 											<a href="', $attachment['href'], ';image" id="link_', $attachment['id'], '" onclick="', $attachment['thumbnail']['javascript'], '"><img src="', $attachment['thumbnail']['href'], '" alt="" id="thumb_', $attachment['id'], '" class="atc_img"></a>';
784
-				else
785
-					echo '
834
+				} else {
835
+									echo '
786 836
 											<img src="' . $attachment['href'] . ';image" alt="" width="' . $attachment['width'] . '" height="' . $attachment['height'] . '" class="atc_img">';
837
+				}
787 838
 
788 839
 				echo '
789 840
 										</div><!-- .attachments_top -->';
@@ -793,9 +844,10 @@  discard block
 block discarded – undo
793 844
 										<div class="attachments_bot">
794 845
 											<a href="' . $attachment['href'] . '"><img src="' . $settings['images_url'] . '/icons/clip.png" class="centericon" alt="*">&nbsp;' . $attachment['name'] . '</a> ';
795 846
 
796
-			if (!$attachment['is_approved'] && $context['can_approve'])
797
-				echo '
847
+			if (!$attachment['is_approved'] && $context['can_approve']) {
848
+							echo '
798 849
 											[<a href="', $scripturl, '?action=attachapprove;sa=approve;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve'], '</a>] [<a href="', $scripturl, '?action=attachapprove;sa=reject;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['delete'], '</a>] ';
850
+			}
799 851
 			echo '
800 852
 											<br>', $attachment['size'], ($attachment['is_image'] ? ', ' . $attachment['real_width'] . 'x' . $attachment['real_height'] . '<br>' . sprintf($txt['attach_viewed'], $attachment['downloads']) : '<br>' . sprintf($txt['attach_downloaded'], $attachment['downloads'])), '
801 853
 										</div><!-- .attachments_bot -->';
@@ -804,35 +856,40 @@  discard block
 block discarded – undo
804 856
 									</div><!-- .attached -->';
805 857
 
806 858
 			// Next attachment line ?
807
-			if (++$i % $attachments_per_line === 0)
808
-				echo '
859
+			if (++$i % $attachments_per_line === 0) {
860
+							echo '
809 861
 									<br>';
862
+			}
810 863
 		}
811 864
 
812 865
 		// If we had unapproved attachments clean up.
813
-		if ($last_approved_state == 0)
814
-			echo '
866
+		if ($last_approved_state == 0) {
867
+					echo '
815 868
 								</fieldset>';
869
+		}
816 870
 
817 871
 		// Only do this if we output a div above - otherwise it'll break things
818
-		if ($div_output)
819
-			echo '
872
+		if ($div_output) {
873
+					echo '
820 874
 							</div><!-- #msg_[id]_footer -->';
875
+		}
821 876
 	}
822 877
 
823 878
 	// And stuff below the attachments.
824
-	if ($context['can_report_moderator'] || !empty($modSettings['enable_likes']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote'])
825
-		echo '
879
+	if ($context['can_report_moderator'] || !empty($modSettings['enable_likes']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) {
880
+			echo '
826 881
 							<div class="under_message">';
882
+	}
827 883
 
828 884
 	// Maybe they want to report this post to the moderator(s)?
829
-	if ($context['can_report_moderator'])
830
-		echo '
885
+	if ($context['can_report_moderator']) {
886
+			echo '
831 887
 								<ul class="floatright smalltext">
832 888
 									<li class="report_link">
833 889
 										<a href="', $scripturl, '?action=reporttm;topic=', $context['current_topic'], '.', $message['counter'], ';msg=', $message['id'], '">', $txt['report_to_mod'], '</a>
834 890
 									</li>
835 891
 								</ul>';
892
+	}
836 893
 
837 894
 	// What about likes?
838 895
 	if (!empty($modSettings['enable_likes']))
@@ -879,83 +936,95 @@  discard block
 block discarded – undo
879 936
 								<ul class="quickbuttons">';
880 937
 
881 938
 		// Can they quote? if so they can select and quote as well!
882
-		if ($context['can_quote'])
883
-			echo '
939
+		if ($context['can_quote']) {
940
+					echo '
884 941
 									<li><a href="', $scripturl, '?action=post;quote=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], ';last_msg=', $context['topic_last_message'], '" onclick="return oQuickReply.quote(', $message['id'], ');"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>
885 942
 									<li style="display:none;" id="quoteSelected_', $message['id'], '">
886 943
 										<a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'], '</a>
887 944
 									</li>';
945
+		}
888 946
 
889 947
 		// Can the user modify the contents of this post? Show the modify inline image.
890
-		if ($message['can_modify'])
891
-			echo '
948
+		if ($message['can_modify']) {
949
+					echo '
892 950
 									<li class="quick_edit">
893 951
 										<a title="', $txt['modify_msg'], '" class="modifybutton" id="modify_button_', $message['id'], '" onclick="oQuickModify.modifyMsg(\'', $message['id'], '\', \'', !empty($modSettings['toggle_subject']), '\')"><span class="generic_icons quick_edit_button"></span>', $txt['quick_edit'], '</a>
894 952
 									</li>';
953
+		}
895 954
 
896
-		if ($message['can_approve'] || $message['can_unapprove'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'])
897
-			echo '
955
+		if ($message['can_approve'] || $message['can_unapprove'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) {
956
+					echo '
898 957
 									<li class="post_options">', $txt['post_options'];
958
+		}
899 959
 
900 960
 		echo '
901 961
 										<ul>';
902 962
 
903 963
 		// Can the user modify the contents of this post?
904
-		if ($message['can_modify'])
905
-			echo '
964
+		if ($message['can_modify']) {
965
+					echo '
906 966
 											<li><a href="', $scripturl, '?action=post;msg=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], '"><span class="generic_icons modify_button"></span>', $txt['modify'], '</a></li>';
967
+		}
907 968
 
908 969
 		// How about... even... remove it entirely?!
909
-		if ($context['can_delete'] && ($context['topic_first_message'] == $message['id']))
910
-			echo '
970
+		if ($context['can_delete'] && ($context['topic_first_message'] == $message['id'])) {
971
+					echo '
911 972
 											<li><a href="', $scripturl, '?action=removetopic2;topic=', $context['current_topic'], '.', $context['start'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['are_sure_remove_topic'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove_topic'], '</a></li>';
912
-
913
-		elseif ($message['can_remove'] && ($context['topic_first_message'] != $message['id']))
914
-			echo '
973
+		} elseif ($message['can_remove'] && ($context['topic_first_message'] != $message['id'])) {
974
+					echo '
915 975
 											<li><a href="', $scripturl, '?action=deletemsg;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message_question'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>';
976
+		}
916 977
 
917 978
 		// What about splitting it off the rest of the topic?
918
-		if ($context['can_split'] && !empty($context['real_num_replies']))
919
-			echo '
979
+		if ($context['can_split'] && !empty($context['real_num_replies'])) {
980
+					echo '
920 981
 											<li><a href="', $scripturl, '?action=splittopics;topic=', $context['current_topic'], '.0;at=', $message['id'], '"><span class="generic_icons split_button"></span>', $txt['split'], '</a></li>';
982
+		}
921 983
 
922 984
 		// Can we issue a warning because of this post? Remember, we can't give guests warnings.
923
-		if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest'])
924
-			echo '
985
+		if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest']) {
986
+					echo '
925 987
 											<li><a href="', $scripturl, '?action=profile;area=issuewarning;u=', $message['member']['id'], ';msg=', $message['id'], '"><span class="generic_icons warn_button"></span>', $txt['issue_warning'], '</a></li>';
988
+		}
926 989
 
927 990
 		// Can we restore topics?
928
-		if ($context['can_restore_msg'])
929
-			echo '
991
+		if ($context['can_restore_msg']) {
992
+					echo '
930 993
 											<li><a href="', $scripturl, '?action=restoretopic;msgs=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons restore_button"></span>', $txt['restore_message'], '</a></li>';
994
+		}
931 995
 
932 996
 		// Maybe we can approve it, maybe we should?
933
-		if ($message['can_approve'])
934
-			echo '
997
+		if ($message['can_approve']) {
998
+					echo '
935 999
 											<li><a href="', $scripturl, '?action=moderate;area=postmod;sa=approve;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons approve_button"></span>', $txt['approve'], '</a></li>';
1000
+		}
936 1001
 
937 1002
 		// Maybe we can unapprove it?
938
-		if ($message['can_unapprove'])
939
-			echo '
1003
+		if ($message['can_unapprove']) {
1004
+					echo '
940 1005
 											<li><a href="', $scripturl, '?action=moderate;area=postmod;sa=approve;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons unapprove_button"></span>', $txt['unapprove'], '</a></li>';
1006
+		}
941 1007
 
942 1008
 		echo '
943 1009
 										</ul>
944 1010
 									</li>';
945 1011
 
946 1012
 		// Show a checkbox for quick moderation?
947
-		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove'])
948
-			echo '
1013
+		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove']) {
1014
+					echo '
949 1015
 									<li style="display: none;" id="in_topic_mod_check_', $message['id'], '"></li>';
1016
+		}
950 1017
 
951
-		if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'])
952
-			echo '
1018
+		if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) {
1019
+					echo '
953 1020
 								</ul><!-- .quickbuttons -->';
1021
+		}
954 1022
 	}
955 1023
 
956
-	if ($context['can_report_moderator'] || !empty($modSettings['enable_likes']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote'])
957
-		echo '
1024
+	if ($context['can_report_moderator'] || !empty($modSettings['enable_likes']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) {
1025
+			echo '
958 1026
 							</div><!-- .under_message -->';
1027
+	}
959 1028
 
960 1029
 	echo '
961 1030
 						</div><!-- .postarea -->
@@ -968,9 +1037,10 @@  discard block
 block discarded – undo
968 1037
 							<div class="custom_fields_above_signature">
969 1038
 								<ul class="nolist">';
970 1039
 
971
-		foreach ($message['custom_fields']['above_signature'] as $custom)
972
-			echo '
1040
+		foreach ($message['custom_fields']['above_signature'] as $custom) {
1041
+					echo '
973 1042
 									<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
1043
+		}
974 1044
 
975 1045
 		echo '
976 1046
 								</ul>
@@ -978,11 +1048,12 @@  discard block
 block discarded – undo
978 1048
 	}
979 1049
 
980 1050
 	// Show the member's signature?
981
-	if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled'])
982
-		echo '
1051
+	if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) {
1052
+			echo '
983 1053
 							<div class="signature" id="msg_', $message['id'], '_signature"', $ignoring ? ' style="display:none;"' : '', '>
984 1054
 								', $message['member']['signature'], '
985 1055
 							</div>';
1056
+	}
986 1057
 
987 1058
 
988 1059
 	// Are there any custom profile fields for below the signature?
@@ -992,9 +1063,10 @@  discard block
 block discarded – undo
992 1063
 							<div class="custom_fields_below_signature">
993 1064
 								<ul class="nolist">';
994 1065
 
995
-		foreach ($message['custom_fields']['below_signature'] as $custom)
996
-			echo '
1066
+		foreach ($message['custom_fields']['below_signature'] as $custom) {
1067
+					echo '
997 1068
 									<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
1069
+		}
998 1070
 
999 1071
 		echo '
1000 1072
 								</ul>
@@ -1027,24 +1099,28 @@  discard block
 block discarded – undo
1027 1099
 				<div class="roundframe">';
1028 1100
 
1029 1101
 	// Are we hiding the full editor?
1030
-	if (empty($options['use_editor_quick_reply']))
1031
-		echo '
1102
+	if (empty($options['use_editor_quick_reply'])) {
1103
+			echo '
1032 1104
 					<p class="smalltext lefttext">', $txt['quick_reply_desc'], '</p>';
1105
+	}
1033 1106
 
1034 1107
 	// Is the topic locked?
1035
-	if ($context['is_locked'])
1036
-		echo '
1108
+	if ($context['is_locked']) {
1109
+			echo '
1037 1110
 					<p class="alert smalltext">', $txt['quick_reply_warning'], '</p>';
1111
+	}
1038 1112
 
1039 1113
 	// Show a warning if the topic is old
1040
-	if (!empty($context['oldTopicError']))
1041
-		echo '
1114
+	if (!empty($context['oldTopicError'])) {
1115
+			echo '
1042 1116
 					<p class="alert smalltext">', sprintf($txt['error_old_topic'], $modSettings['oldTopicDays']), '</p>';
1117
+	}
1043 1118
 
1044 1119
 	// Does the post need approval?
1045
-	if (!$context['can_reply_approved'])
1046
-		echo '
1120
+	if (!$context['can_reply_approved']) {
1121
+			echo '
1047 1122
 					<p><em>', $txt['wait_for_approval'], '</em></p>';
1123
+	}
1048 1124
 
1049 1125
 	echo '
1050 1126
 					<form action="', $scripturl, '?board=', $context['current_board'], ';action=post2" method="post" accept-charset="', $context['character_set'], '" name="postmodify" id="postmodify" onsubmit="submitonce(this);">
@@ -1060,8 +1136,8 @@  discard block
 block discarded – undo
1060 1136
 						<input type="hidden" name="seqnum" value="', $context['form_sequence_number'], '">';
1061 1137
 
1062 1138
 	// Guests just need more.
1063
-	if ($context['user']['is_guest'])
1064
-		echo '
1139
+	if ($context['user']['is_guest']) {
1140
+			echo '
1065 1141
 						<dl id="post_header">
1066 1142
 							<dt>
1067 1143
 								', $txt['name'], ':
@@ -1076,6 +1152,7 @@  discard block
 block discarded – undo
1076 1152
 								<input type="email" name="email" size="25" value="', $context['email'], '" tabindex="', $context['tabindex']++, '" required>
1077 1153
 							</dd>
1078 1154
 						</dl>';
1155
+	}
1079 1156
 
1080 1157
 	echo '
1081 1158
 						', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message'), '
@@ -1100,12 +1177,13 @@  discard block
 block discarded – undo
1100 1177
 						</script>';
1101 1178
 
1102 1179
 	// Is visual verification enabled?
1103
-	if ($context['require_verification'])
1104
-		echo '
1180
+	if ($context['require_verification']) {
1181
+			echo '
1105 1182
 						<div class="post_verification">
1106 1183
 							<strong>', $txt['verification'], ':</strong>
1107 1184
 							', template_control_verification($context['visual_verification_id'], 'all'), '
1108 1185
 						</div>';
1186
+	}
1109 1187
 
1110 1188
 	// Finally, the submit buttons.
1111 1189
 	echo '
@@ -1121,8 +1199,8 @@  discard block
 block discarded – undo
1121 1199
 		<br class="clear">';
1122 1200
 
1123 1201
 	// Draft autosave available and the user has it enabled?
1124
-	if (!empty($context['drafts_autosave']))
1125
-		echo '
1202
+	if (!empty($context['drafts_autosave'])) {
1203
+			echo '
1126 1204
 		<script>
1127 1205
 			var oDraftAutoSave = new smf_DraftAutoSave({
1128 1206
 				sSelf: \'oDraftAutoSave\',
@@ -1134,12 +1212,14 @@  discard block
 block discarded – undo
1134 1212
 				iFreq: ', (empty($modSettings['masterAutoSaveDraftsDelay']) ? 60000 : $modSettings['masterAutoSaveDraftsDelay'] * 1000), '
1135 1213
 			});
1136 1214
 		</script>';
1215
+	}
1137 1216
 
1138
-	if ($context['show_spellchecking'])
1139
-		echo '
1217
+	if ($context['show_spellchecking']) {
1218
+			echo '
1140 1219
 		<form action="', $scripturl, '?action=spellcheck" method="post" accept-charset="', $context['character_set'], '" name="spell_form" id="spell_form" target="spellWindow">
1141 1220
 			<input type="hidden" name="spellstring" value="">
1142 1221
 		</form>';
1222
+	}
1143 1223
 
1144 1224
 	echo '
1145 1225
 		<script>
Please login to merge, or discard this patch.
Sources/Stats.php 1 patch
Braces   +112 added lines, -78 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Display some useful/interesting board statistics.
@@ -30,8 +31,9 @@  discard block
 block discarded – undo
30 31
 
31 32
 	isAllowedTo('view_stats');
32 33
 	// Page disabled - redirect them out
33
-	if (empty($modSettings['trackStats']))
34
-		fatal_lang_error('feature_disabled', true);
34
+	if (empty($modSettings['trackStats'])) {
35
+			fatal_lang_error('feature_disabled', true);
36
+	}
35 37
 
36 38
 	if (!empty($_REQUEST['expand']))
37 39
 	{
@@ -39,31 +41,34 @@  discard block
 block discarded – undo
39 41
 
40 42
 		$month = (int) substr($_REQUEST['expand'], 4);
41 43
 		$year = (int) substr($_REQUEST['expand'], 0, 4);
42
-		if ($year > 1900 && $year < 2200 && $month >= 1 && $month <= 12)
43
-			$_SESSION['expanded_stats'][$year][] = $month;
44
-	}
45
-	elseif (!empty($_REQUEST['collapse']))
44
+		if ($year > 1900 && $year < 2200 && $month >= 1 && $month <= 12) {
45
+					$_SESSION['expanded_stats'][$year][] = $month;
46
+		}
47
+	} elseif (!empty($_REQUEST['collapse']))
46 48
 	{
47 49
 		$context['robot_no_index'] = true;
48 50
 
49 51
 		$month = (int) substr($_REQUEST['collapse'], 4);
50 52
 		$year = (int) substr($_REQUEST['collapse'], 0, 4);
51
-		if (!empty($_SESSION['expanded_stats'][$year]))
52
-			$_SESSION['expanded_stats'][$year] = array_diff($_SESSION['expanded_stats'][$year], array($month));
53
+		if (!empty($_SESSION['expanded_stats'][$year])) {
54
+					$_SESSION['expanded_stats'][$year] = array_diff($_SESSION['expanded_stats'][$year], array($month));
55
+		}
53 56
 	}
54 57
 
55 58
 	// Handle the XMLHttpRequest.
56 59
 	if (isset($_REQUEST['xml']))
57 60
 	{
58 61
 		// Collapsing stats only needs adjustments of the session variables.
59
-		if (!empty($_REQUEST['collapse']))
60
-			obExit(false);
62
+		if (!empty($_REQUEST['collapse'])) {
63
+					obExit(false);
64
+		}
61 65
 
62 66
 		$context['sub_template'] = 'stats';
63 67
 		$context['yearly'] = array();
64 68
 
65
-		if (empty($month) || empty($year))
66
-			return;
69
+		if (empty($month) || empty($year)) {
70
+					return;
71
+		}
67 72
 
68 73
 		getDailyStats('YEAR(date) = {int:year} AND MONTH(date) = {int:month}', array('year' => $year, 'month' => $month));
69 74
 		$context['yearly'][$year]['months'][$month]['date'] = array(
@@ -221,8 +226,9 @@  discard block
 block discarded – undo
221 226
 			'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>'
222 227
 		);
223 228
 
224
-		if ($max_num_posts < $row_members['posts'])
225
-			$max_num_posts = $row_members['posts'];
229
+		if ($max_num_posts < $row_members['posts']) {
230
+					$max_num_posts = $row_members['posts'];
231
+		}
226 232
 	}
227 233
 	$smcFunc['db_free_result']($members_result);
228 234
 
@@ -258,8 +264,9 @@  discard block
 block discarded – undo
258 264
 			'link' => '<a href="' . $scripturl . '?board=' . $row_board['id_board'] . '.0">' . $row_board['name'] . '</a>'
259 265
 		);
260 266
 
261
-		if ($max_num_posts < $row_board['num_posts'])
262
-			$max_num_posts = $row_board['num_posts'];
267
+		if ($max_num_posts < $row_board['num_posts']) {
268
+					$max_num_posts = $row_board['num_posts'];
269
+		}
263 270
 	}
264 271
 	$smcFunc['db_free_result']($boards_result);
265 272
 
@@ -285,12 +292,13 @@  discard block
 block discarded – undo
285 292
 			)
286 293
 		);
287 294
 		$topic_ids = array();
288
-		while ($row = $smcFunc['db_fetch_assoc']($request))
289
-			$topic_ids[] = $row['id_topic'];
295
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
296
+					$topic_ids[] = $row['id_topic'];
297
+		}
290 298
 		$smcFunc['db_free_result']($request);
299
+	} else {
300
+			$topic_ids = array();
291 301
 	}
292
-	else
293
-		$topic_ids = array();
294 302
 
295 303
 	// Topic replies top 10.
296 304
 	$topic_reply_result = $smcFunc['db_query']('', '
@@ -330,8 +338,9 @@  discard block
 block discarded – undo
330 338
 			'link' => '<a href="' . $scripturl . '?topic=' . $row_topic_reply['id_topic'] . '.0">' . $row_topic_reply['subject'] . '</a>'
331 339
 		);
332 340
 
333
-		if ($max_num_replies < $row_topic_reply['num_replies'])
334
-			$max_num_replies = $row_topic_reply['num_replies'];
341
+		if ($max_num_replies < $row_topic_reply['num_replies']) {
342
+					$max_num_replies = $row_topic_reply['num_replies'];
343
+		}
335 344
 	}
336 345
 	$smcFunc['db_free_result']($topic_reply_result);
337 346
 
@@ -355,12 +364,13 @@  discard block
 block discarded – undo
355 364
 			)
356 365
 		);
357 366
 		$topic_ids = array();
358
-		while ($row = $smcFunc['db_fetch_assoc']($request))
359
-			$topic_ids[] = $row['id_topic'];
367
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
368
+					$topic_ids[] = $row['id_topic'];
369
+		}
360 370
 		$smcFunc['db_free_result']($request);
371
+	} else {
372
+			$topic_ids = array();
361 373
 	}
362
-	else
363
-		$topic_ids = array();
364 374
 
365 375
 	// Topic views top 10.
366 376
 	$topic_view_result = $smcFunc['db_query']('', '
@@ -400,8 +410,9 @@  discard block
 block discarded – undo
400 410
 			'link' => '<a href="' . $scripturl . '?topic=' . $row_topic_views['id_topic'] . '.0">' . $row_topic_views['subject'] . '</a>'
401 411
 		);
402 412
 
403
-		if ($max_num < $row_topic_views['num_views'])
404
-			$max_num = $row_topic_views['num_views'];
413
+		if ($max_num < $row_topic_views['num_views']) {
414
+					$max_num = $row_topic_views['num_views'];
415
+		}
405 416
 	}
406 417
 	$smcFunc['db_free_result']($topic_view_result);
407 418
 
@@ -426,15 +437,17 @@  discard block
 block discarded – undo
426 437
 			)
427 438
 		);
428 439
 		$members = array();
429
-		while ($row = $smcFunc['db_fetch_assoc']($request))
430
-			$members[$row['id_member_started']] = $row['hits'];
440
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
441
+					$members[$row['id_member_started']] = $row['hits'];
442
+		}
431 443
 		$smcFunc['db_free_result']($request);
432 444
 
433 445
 		cache_put_data('stats_top_starters', $members, 360);
434 446
 	}
435 447
 
436
-	if (empty($members))
437
-		$members = array(0 => 0);
448
+	if (empty($members)) {
449
+			$members = array(0 => 0);
450
+	}
438 451
 
439 452
 	// Topic poster top 10.
440 453
 	$members_result = $smcFunc['db_query']('', '
@@ -459,8 +472,9 @@  discard block
 block discarded – undo
459 472
 			'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>'
460 473
 		);
461 474
 
462
-		if ($max_num < $members[$row_members['id_member']])
463
-			$max_num = $members[$row_members['id_member']];
475
+		if ($max_num < $members[$row_members['id_member']]) {
476
+					$max_num = $members[$row_members['id_member']];
477
+		}
464 478
 	}
465 479
 	ksort($context['stats_blocks']['starters']);
466 480
 	$smcFunc['db_free_result']($members_result);
@@ -489,8 +503,9 @@  discard block
 block discarded – undo
489 503
 	while ($row_members = $smcFunc['db_fetch_assoc']($members_result))
490 504
 	{
491 505
 		$temp2[] = (int) $row_members['id_member'];
492
-		if (count($context['stats_blocks']['time_online']) >= 10)
493
-			continue;
506
+		if (count($context['stats_blocks']['time_online']) >= 10) {
507
+					continue;
508
+		}
494 509
 
495 510
 		// Figure out the days, hours and minutes.
496 511
 		$timeDays = floor($row_members['total_time_logged_in'] / 86400);
@@ -498,10 +513,12 @@  discard block
 block discarded – undo
498 513
 
499 514
 		// Figure out which things to show... (days, hours, minutes, etc.)
500 515
 		$timelogged = '';
501
-		if ($timeDays > 0)
502
-			$timelogged .= $timeDays . $txt['totalTimeLogged5'];
503
-		if ($timeHours > 0)
504
-			$timelogged .= $timeHours . $txt['totalTimeLogged6'];
516
+		if ($timeDays > 0) {
517
+					$timelogged .= $timeDays . $txt['totalTimeLogged5'];
518
+		}
519
+		if ($timeHours > 0) {
520
+					$timelogged .= $timeHours . $txt['totalTimeLogged6'];
521
+		}
505 522
 		$timelogged .= floor(($row_members['total_time_logged_in'] % 3600) / 60) . $txt['totalTimeLogged7'];
506 523
 
507 524
 		$context['stats_blocks']['time_online'][] = array(
@@ -513,17 +530,20 @@  discard block
 block discarded – undo
513 530
 			'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>'
514 531
 		);
515 532
 
516
-		if ($max_time_online < $row_members['total_time_logged_in'])
517
-			$max_time_online = $row_members['total_time_logged_in'];
533
+		if ($max_time_online < $row_members['total_time_logged_in']) {
534
+					$max_time_online = $row_members['total_time_logged_in'];
535
+		}
518 536
 	}
519 537
 	$smcFunc['db_free_result']($members_result);
520 538
 
521
-	foreach ($context['stats_blocks']['time_online'] as $i => $member)
522
-		$context['stats_blocks']['time_online'][$i]['percent'] = round(($member['seconds_online'] * 100) / $max_time_online);
539
+	foreach ($context['stats_blocks']['time_online'] as $i => $member) {
540
+			$context['stats_blocks']['time_online'][$i]['percent'] = round(($member['seconds_online'] * 100) / $max_time_online);
541
+	}
523 542
 
524 543
 	// Cache the ones we found for a bit, just so we don't have to look again.
525
-	if ($temp !== $temp2)
526
-		cache_put_data('stats_total_time_members', $temp2, 480);
544
+	if ($temp !== $temp2) {
545
+			cache_put_data('stats_total_time_members', $temp2, 480);
546
+	}
527 547
 
528 548
 	// Likes.
529 549
 	if (!empty($modSettings['enable_likes']))
@@ -559,13 +579,15 @@  discard block
 block discarded – undo
559 579
 				'link' => '<a href="' . $scripturl . '?msg=' . $row_liked_message['id_msg'] .'">' . $row_liked_message['subject'] . '</a>'
560 580
 			);
561 581
 
562
-			if ($max_liked_message < $row_liked_message['likes'])
563
-				$max_liked_message = $row_liked_message['likes'];
582
+			if ($max_liked_message < $row_liked_message['likes']) {
583
+							$max_liked_message = $row_liked_message['likes'];
584
+			}
564 585
 		}
565 586
 		$smcFunc['db_free_result']($liked_messages);
566 587
 
567
-		foreach ($context['stats_blocks']['liked_messages'] as $i => $liked_messages)
568
-			$context['stats_blocks']['liked_messages'][$i]['percent'] = round(($liked_messages['num'] * 100) / $max_liked_message);
588
+		foreach ($context['stats_blocks']['liked_messages'] as $i => $liked_messages) {
589
+					$context['stats_blocks']['liked_messages'][$i]['percent'] = round(($liked_messages['num'] * 100) / $max_liked_message);
590
+		}
569 591
 
570 592
 		// Liked users top 10.
571 593
 		$context['stats_blocks']['liked_users'] = array();
@@ -596,14 +618,16 @@  discard block
 block discarded – undo
596 618
 				'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_liked_users['liked_user'] . '">' . $row_liked_users['real_name'] . '</a>',
597 619
 			);
598 620
 
599
-			if ($max_liked_users < $row_liked_users['count'])
600
-				$max_liked_users = $row_liked_users['count'];
621
+			if ($max_liked_users < $row_liked_users['count']) {
622
+							$max_liked_users = $row_liked_users['count'];
623
+			}
601 624
 		}
602 625
 
603 626
 		$smcFunc['db_free_result']($liked_users);
604 627
 
605
-		foreach ($context['stats_blocks']['liked_users'] as $i => $liked_users)
606
-			$context['stats_blocks']['liked_users'][$i]['percent'] = round(($liked_users['num'] * 100) / $max_liked_users);
628
+		foreach ($context['stats_blocks']['liked_users'] as $i => $liked_users) {
629
+					$context['stats_blocks']['liked_users'][$i]['percent'] = round(($liked_users['num'] * 100) / $max_liked_users);
630
+		}
607 631
 	}
608 632
 
609 633
 	// Activity by month.
@@ -621,8 +645,8 @@  discard block
 block discarded – undo
621 645
 		$ID_MONTH = $row_months['stats_year'] . sprintf('%02d', $row_months['stats_month']);
622 646
 		$expanded = !empty($_SESSION['expanded_stats'][$row_months['stats_year']]) && in_array($row_months['stats_month'], $_SESSION['expanded_stats'][$row_months['stats_year']]);
623 647
 
624
-		if (!isset($context['yearly'][$row_months['stats_year']]))
625
-			$context['yearly'][$row_months['stats_year']] = array(
648
+		if (!isset($context['yearly'][$row_months['stats_year']])) {
649
+					$context['yearly'][$row_months['stats_year']] = array(
626 650
 				'year' => $row_months['stats_year'],
627 651
 				'new_topics' => 0,
628 652
 				'new_posts' => 0,
@@ -634,6 +658,7 @@  discard block
 block discarded – undo
634 658
 				'expanded' => false,
635 659
 				'current_year' => $row_months['stats_year'] == date('Y'),
636 660
 			);
661
+		}
637 662
 
638 663
 		$context['yearly'][$row_months['stats_year']]['months'][(int) $row_months['stats_month']] = array(
639 664
 			'id' => $ID_MONTH,
@@ -679,29 +704,33 @@  discard block
 block discarded – undo
679 704
 		$context['yearly'][$year]['hits'] = comma_format($data['hits']);
680 705
 
681 706
 		// Keep a list of collapsed years.
682
-		if (!$data['expanded'] && !$data['current_year'])
683
-			$context['collapsed_years'][] = $year;
707
+		if (!$data['expanded'] && !$data['current_year']) {
708
+					$context['collapsed_years'][] = $year;
709
+		}
684 710
 	}
685 711
 
686 712
 	// Custom stats (just add a template_layer to add it to the template!)
687 713
 	call_integration_hook('integrate_forum_stats');
688 714
 
689
-	if (empty($_SESSION['expanded_stats']))
690
-		return;
715
+	if (empty($_SESSION['expanded_stats'])) {
716
+			return;
717
+	}
691 718
 
692 719
 	$condition_text = array();
693 720
 	$condition_params = array();
694
-	foreach ($_SESSION['expanded_stats'] as $year => $months)
695
-		if (!empty($months))
721
+	foreach ($_SESSION['expanded_stats'] as $year => $months) {
722
+			if (!empty($months))
696 723
 		{
697 724
 			$condition_text[] = 'YEAR(date) = {int:year_' . $year . '} AND MONTH(date) IN ({array_int:months_' . $year . '})';
725
+	}
698 726
 			$condition_params['year_' . $year] = $year;
699 727
 			$condition_params['months_' . $year] = $months;
700 728
 		}
701 729
 
702 730
 	// No daily stats to even look at?
703
-	if (empty($condition_text))
704
-		return;
731
+	if (empty($condition_text)) {
732
+			return;
733
+	}
705 734
 
706 735
 	getDailyStats(implode(' OR ', $condition_text), $condition_params);
707 736
 }
@@ -724,8 +753,8 @@  discard block
 block discarded – undo
724 753
 		ORDER BY stats_day ASC',
725 754
 		$condition_parameters
726 755
 	);
727
-	while ($row_days = $smcFunc['db_fetch_assoc']($days_result))
728
-		$context['yearly'][$row_days['stats_year']]['months'][(int) $row_days['stats_month']]['days'][] = array(
756
+	while ($row_days = $smcFunc['db_fetch_assoc']($days_result)) {
757
+			$context['yearly'][$row_days['stats_year']]['months'][(int) $row_days['stats_month']]['days'][] = array(
729 758
 			'day' => sprintf('%02d', $row_days['stats_day']),
730 759
 			'month' => sprintf('%02d', $row_days['stats_month']),
731 760
 			'year' => $row_days['stats_year'],
@@ -735,6 +764,7 @@  discard block
 block discarded – undo
735 764
 			'most_members_online' => comma_format($row_days['most_on']),
736 765
 			'hits' => comma_format($row_days['hits'])
737 766
 		);
767
+	}
738 768
 	$smcFunc['db_free_result']($days_result);
739 769
 }
740 770
 
@@ -752,16 +782,19 @@  discard block
 block discarded – undo
752 782
 	global $modSettings, $user_info, $forum_version, $sourcedir;
753 783
 
754 784
 	// First, is it disabled?
755
-	if (empty($modSettings['enable_sm_stats']) || empty($modSettings['sm_stats_key']))
756
-		die();
785
+	if (empty($modSettings['enable_sm_stats']) || empty($modSettings['sm_stats_key'])) {
786
+			die();
787
+	}
757 788
 
758 789
 	// Are we saying who we are, and are we right? (OR an admin)
759
-	if (!$user_info['is_admin'] && (!isset($_GET['sid']) || $_GET['sid'] != $modSettings['sm_stats_key']))
760
-		die();
790
+	if (!$user_info['is_admin'] && (!isset($_GET['sid']) || $_GET['sid'] != $modSettings['sm_stats_key'])) {
791
+			die();
792
+	}
761 793
 
762 794
 	// Verify the referer...
763
-	if (!$user_info['is_admin'] && (!isset($_SERVER['HTTP_REFERER']) || md5($_SERVER['HTTP_REFERER']) != '746cb59a1a0d5cf4bd240e5a67c73085'))
764
-		die();
795
+	if (!$user_info['is_admin'] && (!isset($_SERVER['HTTP_REFERER']) || md5($_SERVER['HTTP_REFERER']) != '746cb59a1a0d5cf4bd240e5a67c73085')) {
796
+			die();
797
+	}
765 798
 
766 799
 	// Get some server versions.
767 800
 	require_once($sourcedir . '/Subs-Admin.php');
@@ -787,16 +820,17 @@  discard block
 block discarded – undo
787 820
 	);
788 821
 
789 822
 	// Encode all the data, for security.
790
-	foreach ($stats_to_send as $k => $v)
791
-		$stats_to_send[$k] = urlencode($k) . '=' . urlencode($v);
823
+	foreach ($stats_to_send as $k => $v) {
824
+			$stats_to_send[$k] = urlencode($k) . '=' . urlencode($v);
825
+	}
792 826
 
793 827
 	// Turn this into the query string!
794 828
 	$stats_to_send = implode('&', $stats_to_send);
795 829
 
796 830
 	// If we're an admin, just plonk them out.
797
-	if ($user_info['is_admin'])
798
-		echo $stats_to_send;
799
-	else
831
+	if ($user_info['is_admin']) {
832
+			echo $stats_to_send;
833
+	} else
800 834
 	{
801 835
 		// Connect to the collection script.
802 836
 		$fp = @fsockopen('www.simplemachines.org', 80, $errno, $errstr);
Please login to merge, or discard this patch.
Sources/ManageServer.php 1 patch
Braces   +315 added lines, -243 removed lines patch added patch discarded remove patch
@@ -59,8 +59,9 @@  discard block
 block discarded – undo
59 59
  * @version 2.1 Beta 4
60 60
  */
61 61
 
62
-if (!defined('SMF'))
62
+if (!defined('SMF')) {
63 63
 	die('No direct access...');
64
+}
64 65
 
65 66
 /**
66 67
  * This is the main dispatcher. Sets up all the available sub-actions, all the tabs and selects
@@ -111,10 +112,11 @@  discard block
 block discarded – undo
111 112
 	$settings_not_writable = !is_writable($boarddir . '/Settings.php');
112 113
 	$settings_backup_fail = !@is_writable($boarddir . '/Settings_bak.php') || !@copy($boarddir . '/Settings.php', $boarddir . '/Settings_bak.php');
113 114
 
114
-	if ($settings_not_writable)
115
-		$context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>';
116
-	elseif ($settings_backup_fail)
117
-		$context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>';
115
+	if ($settings_not_writable) {
116
+			$context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>';
117
+	} elseif ($settings_backup_fail) {
118
+			$context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>';
119
+	}
118 120
 
119 121
 	$context['settings_not_writable'] = $settings_not_writable;
120 122
 
@@ -142,10 +144,11 @@  discard block
 block discarded – undo
142 144
 
143 145
 	// If no cert, force_ssl must remain 0
144 146
 	require_once($sourcedir . '/Subs.php');
145
-	if (!ssl_cert_found($boardurl) && empty($modSettings['force_ssl']))
146
-		$disable_force_ssl = true;
147
-	else
148
-		$disable_force_ssl = false;
147
+	if (!ssl_cert_found($boardurl) && empty($modSettings['force_ssl'])) {
148
+			$disable_force_ssl = true;
149
+	} else {
150
+			$disable_force_ssl = false;
151
+	}
149 152
 
150 153
 	/* If you're writing a mod, it's a bad idea to add things here....
151 154
 	For each option:
@@ -174,8 +177,9 @@  discard block
 block discarded – undo
174 177
 
175 178
 	call_integration_hook('integrate_general_settings', array(&$config_vars));
176 179
 
177
-	if ($return_config)
178
-		return $config_vars;
180
+	if ($return_config) {
181
+			return $config_vars;
182
+	}
179 183
 
180 184
 	// Setup the template stuff.
181 185
 	$context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=general;save';
@@ -192,16 +196,18 @@  discard block
 block discarded – undo
192 196
 			$registerSMStats = registerSMStats();
193 197
 
194 198
 			// Failed to register, disable it again.
195
-			if (empty($registerSMStats))
196
-				$_POST['enable_sm_stats'] = 0;
199
+			if (empty($registerSMStats)) {
200
+							$_POST['enable_sm_stats'] = 0;
201
+			}
197 202
 		}
198 203
 
199 204
 		// Ensure all URLs are aligned with the new force_ssl setting
200 205
 		// Treat unset like 0
201
-		if (isset($_POST['force_ssl']))
202
-			AlignURLsWithSSLSetting($_POST['force_ssl']);
203
-		else
204
-			AlignURLsWithSSLSetting(0);
206
+		if (isset($_POST['force_ssl'])) {
207
+					AlignURLsWithSSLSetting($_POST['force_ssl']);
208
+		} else {
209
+					AlignURLsWithSSLSetting(0);
210
+		}
205 211
 
206 212
 		saveSettings($config_vars);
207 213
 		$_SESSION['adm-save'] = true;
@@ -254,10 +260,11 @@  discard block
 block discarded – undo
254 260
 	require_once($sourcedir . '/Subs-Admin.php');
255 261
 
256 262
 	// Check $boardurl
257
-	if (!empty($new_force_ssl))
258
-		$newval = strtr($boardurl, array('http://' => 'https://'));
259
-	else
260
-		$newval = strtr($boardurl, array('https://' => 'http://'));
263
+	if (!empty($new_force_ssl)) {
264
+			$newval = strtr($boardurl, array('http://' => 'https://'));
265
+	} else {
266
+			$newval = strtr($boardurl, array('https://' => 'http://'));
267
+	}
261 268
 	updateSettingsFile(array('boardurl' => '\'' . addslashes($newval) . '\''));
262 269
 
263 270
 	$new_settings = array();
@@ -265,20 +272,22 @@  discard block
 block discarded – undo
265 272
 	// Check $smileys_url, but only if it points to a subfolder of $boardurl
266 273
 	if (BoardurlMatch($modSettings['smileys_url']))
267 274
 	{
268
-		if (!empty($new_force_ssl))
269
-			$newval = strtr($modSettings['smileys_url'], array('http://' => 'https://'));
270
-		else
271
-			$newval = strtr($modSettings['smileys_url'], array('https://' => 'http://'));
275
+		if (!empty($new_force_ssl)) {
276
+					$newval = strtr($modSettings['smileys_url'], array('http://' => 'https://'));
277
+		} else {
278
+					$newval = strtr($modSettings['smileys_url'], array('https://' => 'http://'));
279
+		}
272 280
 		$new_settings['smileys_url'] = $newval;
273 281
 	}
274 282
 
275 283
 	// Check $avatar_url, but only if it points to a subfolder of $boardurl
276 284
 	if (BoardurlMatch($modSettings['avatar_url']))
277 285
 	{
278
-		if (!empty($new_force_ssl))
279
-			$newval = strtr($modSettings['avatar_url'], array('http://' => 'https://'));
280
-		else
281
-			$newval = strtr($modSettings['avatar_url'], array('https://' => 'http://'));
286
+		if (!empty($new_force_ssl)) {
287
+					$newval = strtr($modSettings['avatar_url'], array('http://' => 'https://'));
288
+		} else {
289
+					$newval = strtr($modSettings['avatar_url'], array('https://' => 'http://'));
290
+		}
282 291
 		$new_settings['avatar_url'] = $newval;
283 292
 	}
284 293
 
@@ -286,16 +295,18 @@  discard block
 block discarded – undo
286 295
 	// This one had been optional in the past, make sure it is set first
287 296
 	if (isset($modSettings['custom_avatar_url']) && BoardurlMatch($modSettings['custom_avatar_url']))
288 297
 	{
289
-		if (!empty($new_force_ssl))
290
-			$newval = strtr($modSettings['custom_avatar_url'], array('http://' => 'https://'));
291
-		else
292
-			$newval = strtr($modSettings['custom_avatar_url'], array('https://' => 'http://'));
298
+		if (!empty($new_force_ssl)) {
299
+					$newval = strtr($modSettings['custom_avatar_url'], array('http://' => 'https://'));
300
+		} else {
301
+					$newval = strtr($modSettings['custom_avatar_url'], array('https://' => 'http://'));
302
+		}
293 303
 		$new_settings['custom_avatar_url'] = $newval;
294 304
 	}
295 305
 
296 306
 	// Save updates to the settings table
297
-	if (!empty($new_settings))
298
-		updateSettings($new_settings, true);
307
+	if (!empty($new_settings)) {
308
+			updateSettings($new_settings, true);
309
+	}
299 310
 
300 311
 	// Now we move onto the themes.
301 312
 	// First, get a list of theme URLs...
@@ -316,10 +327,11 @@  discard block
 block discarded – undo
316 327
 		// First check to see if it points to a subfolder of $boardurl
317 328
 		if (BoardurlMatch($row['value']))
318 329
 		{
319
-			if (!empty($new_force_ssl))
320
-				$newval = strtr($row['value'], array('http://' => 'https://'));
321
-			else
322
-				$newval = strtr($row['value'], array('https://' => 'http://'));
330
+			if (!empty($new_force_ssl)) {
331
+							$newval = strtr($row['value'], array('http://' => 'https://'));
332
+			} else {
333
+							$newval = strtr($row['value'], array('https://' => 'http://'));
334
+			}
323 335
 			$smcFunc['db_query']('', '
324 336
 				UPDATE {db_prefix}themes
325 337
 				   SET value = {string:theme_val}
@@ -359,11 +371,12 @@  discard block
 block discarded – undo
359 371
 
360 372
 	// If leftmost portion of path matches boardurl, return true
361 373
 	$result = strpos($urlpath, $boardurlpath);
362
-	if ($result === false || $result != 0)
363
-		return false;
364
-	else
365
-		return true;
366
-}
374
+	if ($result === false || $result != 0) {
375
+			return false;
376
+	} else {
377
+			return true;
378
+	}
379
+	}
367 380
 
368 381
 /**
369 382
  * Basic database and paths settings - database name, host, etc.
@@ -402,8 +415,9 @@  discard block
 block discarded – undo
402 415
 		$request = $smcFunc['db_query']('', 'SELECT cfgname FROM pg_ts_config', array());
403 416
 		$fts_language = array();
404 417
 
405
-		while ($row = $smcFunc['db_fetch_assoc']($request))
406
-			$fts_language[$row['cfgname']] = $row['cfgname'];
418
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
419
+					$fts_language[$row['cfgname']] = $row['cfgname'];
420
+		}
407 421
 
408 422
 		$config_vars = array_merge ($config_vars, array(
409 423
 				'',
@@ -415,20 +429,22 @@  discard block
 block discarded – undo
415 429
 
416 430
 	call_integration_hook('integrate_database_settings', array(&$config_vars));
417 431
 
418
-	if ($return_config)
419
-		return $config_vars;
432
+	if ($return_config) {
433
+			return $config_vars;
434
+	}
420 435
 
421 436
 	// Setup the template stuff.
422 437
 	$context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=database;save';
423 438
 	$context['settings_title'] = $txt['database_settings'];
424 439
 	$context['save_disabled'] = $context['settings_not_writable'];
425 440
 
426
-	if (!$smcFunc['db_allow_persistent']())
427
-		addInlineJavaScript('
441
+	if (!$smcFunc['db_allow_persistent']()) {
442
+			addInlineJavaScript('
428 443
 			$(function()
429 444
 			{
430 445
 				$("#db_persist").prop("disabled", true);
431 446
 			});', true);
447
+	}
432 448
 
433 449
 	// Saving settings?
434 450
 	if (isset($_REQUEST['save']))
@@ -498,13 +514,15 @@  discard block
 block discarded – undo
498 514
 		hideGlobalCookies();
499 515
 	});', true);
500 516
 
501
-	if (empty($user_settings['tfa_secret']))
502
-		addInlineJavaScript('');
517
+	if (empty($user_settings['tfa_secret'])) {
518
+			addInlineJavaScript('');
519
+	}
503 520
 
504 521
 	call_integration_hook('integrate_cookie_settings', array(&$config_vars));
505 522
 
506
-	if ($return_config)
507
-		return $config_vars;
523
+	if ($return_config) {
524
+			return $config_vars;
525
+	}
508 526
 
509 527
 	$context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=cookie;save';
510 528
 	$context['settings_title'] = $txt['cookies_sessions_settings'];
@@ -515,14 +533,17 @@  discard block
 block discarded – undo
515 533
 		call_integration_hook('integrate_save_cookie_settings');
516 534
 
517 535
 		// Local and global do not play nicely together.
518
-		if (!empty($_POST['localCookies']) && empty($_POST['globalCookies']))
519
-			unset ($_POST['globalCookies']);
536
+		if (!empty($_POST['localCookies']) && empty($_POST['globalCookies'])) {
537
+					unset ($_POST['globalCookies']);
538
+		}
520 539
 
521
-		if (empty($modSettings['localCookies']) != empty($_POST['localCookies']) || empty($modSettings['globalCookies']) != empty($_POST['globalCookies']))
522
-			$scope_changed = true;
540
+		if (empty($modSettings['localCookies']) != empty($_POST['localCookies']) || empty($modSettings['globalCookies']) != empty($_POST['globalCookies'])) {
541
+					$scope_changed = true;
542
+		}
523 543
 
524
-		if (!empty($_POST['globalCookiesDomain']) && strpos($boardurl, $_POST['globalCookiesDomain']) === false)
525
-			fatal_lang_error('invalid_cookie_domain', false);
544
+		if (!empty($_POST['globalCookiesDomain']) && strpos($boardurl, $_POST['globalCookiesDomain']) === false) {
545
+					fatal_lang_error('invalid_cookie_domain', false);
546
+		}
526 547
 
527 548
 		saveSettings($config_vars);
528 549
 
@@ -605,8 +626,9 @@  discard block
 block discarded – undo
605 626
 
606 627
 	call_integration_hook('integrate_general_security_settings', array(&$config_vars));
607 628
 
608
-	if ($return_config)
609
-		return $config_vars;
629
+	if ($return_config) {
630
+			return $config_vars;
631
+	}
610 632
 
611 633
 	// Saving?
612 634
 	if (isset($_GET['save']))
@@ -645,8 +667,7 @@  discard block
 block discarded – undo
645 667
 		$txt['cache_settings_message'] = $txt['detected_no_caching'];
646 668
 		$cache_level = array($txt['cache_off']);
647 669
 		$detected['none'] = $txt['cache_off'];
648
-	}
649
-	else
670
+	} else
650 671
 	{
651 672
 		$txt['cache_settings_message'] = sprintf($txt['detected_accelerators'], implode(', ', $detected));
652 673
 		$cache_level = array($txt['cache_off'], $txt['cache_level1'], $txt['cache_level2'], $txt['cache_level3']);
@@ -683,8 +704,9 @@  discard block
 block discarded – undo
683 704
 			}
684 705
 		}
685 706
 	}
686
-	if ($return_config)
687
-		return $config_vars;
707
+	if ($return_config) {
708
+			return $config_vars;
709
+	}
688 710
 
689 711
 	// Saving again?
690 712
 	if (isset($_GET['save']))
@@ -712,8 +734,9 @@  discard block
 block discarded – undo
712 734
 	$context['save_disabled'] = $context['settings_not_writable'];
713 735
 
714 736
 	// Decide what message to show.
715
-	if (!$context['save_disabled'])
716
-		$context['settings_message'] = $txt['caching_information'];
737
+	if (!$context['save_disabled']) {
738
+			$context['settings_message'] = $txt['caching_information'];
739
+	}
717 740
 
718 741
 	// Prepare the template.
719 742
 	prepareServerSettingsContext($config_vars);
@@ -736,24 +759,25 @@  discard block
 block discarded – undo
736 759
 	if (stripos(PHP_OS, 'win') === 0)
737 760
 	{
738 761
 		$context['settings_message'] = $txt['loadavg_disabled_windows'];
739
-		if (isset($_GET['save']))
740
-			$_SESSION['adm-save'] = $txt['loadavg_disabled_windows'];
741
-	}
742
-	elseif (stripos(PHP_OS, 'darwin') === 0)
762
+		if (isset($_GET['save'])) {
763
+					$_SESSION['adm-save'] = $txt['loadavg_disabled_windows'];
764
+		}
765
+	} elseif (stripos(PHP_OS, 'darwin') === 0)
743 766
 	{
744 767
 		$context['settings_message'] = $txt['loadavg_disabled_osx'];
745
-		if (isset($_GET['save']))
746
-			$_SESSION['adm-save'] = $txt['loadavg_disabled_osx'];
747
-	}
748
-	else
768
+		if (isset($_GET['save'])) {
769
+					$_SESSION['adm-save'] = $txt['loadavg_disabled_osx'];
770
+		}
771
+	} else
749 772
 	{
750 773
 		$modSettings['load_average'] = @file_get_contents('/proc/loadavg');
751
-		if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) !== 0)
752
-			$modSettings['load_average'] = (float) $matches[1];
753
-		elseif (($modSettings['load_average'] = @`uptime`) !== null && preg_match('~load averages?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) !== 0)
754
-			$modSettings['load_average'] = (float) $matches[1];
755
-		else
756
-			unset($modSettings['load_average']);
774
+		if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) !== 0) {
775
+					$modSettings['load_average'] = (float) $matches[1];
776
+		} elseif (($modSettings['load_average'] = @`uptime`) !== null && preg_match('~load averages?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) !== 0) {
777
+					$modSettings['load_average'] = (float) $matches[1];
778
+		} else {
779
+					unset($modSettings['load_average']);
780
+		}
757 781
 
758 782
 		if (!empty($modSettings['load_average']) || (isset($modSettings['load_average']) && $modSettings['load_average'] === 0.0))
759 783
 		{
@@ -789,8 +813,9 @@  discard block
 block discarded – undo
789 813
 
790 814
 	call_integration_hook('integrate_loadavg_settings', array(&$config_vars));
791 815
 
792
-	if ($return_config)
793
-		return $config_vars;
816
+	if ($return_config) {
817
+			return $config_vars;
818
+	}
794 819
 
795 820
 	$context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=loads;save';
796 821
 	$context['settings_title'] = $txt['load_balancing_settings'];
@@ -801,24 +826,27 @@  discard block
 block discarded – undo
801 826
 		// Stupidity is not allowed.
802 827
 		foreach ($_POST as $key => $value)
803 828
 		{
804
-			if (strpos($key, 'loadavg') === 0 || $key === 'loadavg_enable' || !in_array($key, array_keys($default_values)))
805
-				continue;
806
-			else
807
-				$_POST[$key] = (float) $value;
808
-
809
-			if ($key == 'loadavg_auto_opt' && $value <= 1)
810
-				$_POST['loadavg_auto_opt'] = 1.0;
811
-			elseif ($key == 'loadavg_forum' && $value < 10)
812
-				$_POST['loadavg_forum'] = 10.0;
813
-			elseif ($value < 2)
814
-				$_POST[$key] = 2.0;
829
+			if (strpos($key, 'loadavg') === 0 || $key === 'loadavg_enable' || !in_array($key, array_keys($default_values))) {
830
+							continue;
831
+			} else {
832
+							$_POST[$key] = (float) $value;
833
+			}
834
+
835
+			if ($key == 'loadavg_auto_opt' && $value <= 1) {
836
+							$_POST['loadavg_auto_opt'] = 1.0;
837
+			} elseif ($key == 'loadavg_forum' && $value < 10) {
838
+							$_POST['loadavg_forum'] = 10.0;
839
+			} elseif ($value < 2) {
840
+							$_POST[$key] = 2.0;
841
+			}
815 842
 		}
816 843
 
817 844
 		call_integration_hook('integrate_save_loadavg_settings');
818 845
 
819 846
 		saveDBSettings($config_vars);
820
-		if (!isset($_SESSION['adm-save']))
821
-			$_SESSION['adm-save'] = true;
847
+		if (!isset($_SESSION['adm-save'])) {
848
+					$_SESSION['adm-save'] = true;
849
+		}
822 850
 		redirectexit('action=admin;area=serversettings;sa=loads;' . $context['session_var'] . '=' . $context['session_id']);
823 851
 	}
824 852
 
@@ -854,10 +882,11 @@  discard block
 block discarded – undo
854 882
 
855 883
 	if (isset($_SESSION['adm-save']))
856 884
 	{
857
-		if ($_SESSION['adm-save'] === true)
858
-			$context['saved_successful'] = true;
859
-		else
860
-			$context['saved_failed'] = $_SESSION['adm-save'];
885
+		if ($_SESSION['adm-save'] === true) {
886
+					$context['saved_successful'] = true;
887
+		} else {
888
+					$context['saved_failed'] = $_SESSION['adm-save'];
889
+		}
861 890
 
862 891
 		unset($_SESSION['adm-save']);
863 892
 	}
@@ -865,9 +894,9 @@  discard block
 block discarded – undo
865 894
 	$context['config_vars'] = array();
866 895
 	foreach ($config_vars as $identifier => $config_var)
867 896
 	{
868
-		if (!is_array($config_var) || !isset($config_var[1]))
869
-			$context['config_vars'][] = $config_var;
870
-		else
897
+		if (!is_array($config_var) || !isset($config_var[1])) {
898
+					$context['config_vars'][] = $config_var;
899
+		} else
871 900
 		{
872 901
 			$varname = $config_var[0];
873 902
 			global $$varname;
@@ -902,16 +931,19 @@  discard block
 block discarded – undo
902 931
 			if ($config_var[3] == 'int' || $config_var[3] == 'float')
903 932
 			{
904 933
 				// Default to a min of 0 if one isn't set
905
-				if (isset($config_var['min']))
906
-					$context['config_vars'][$config_var[0]]['min'] = $config_var['min'];
907
-				else
908
-					$context['config_vars'][$config_var[0]]['min'] = 0;
934
+				if (isset($config_var['min'])) {
935
+									$context['config_vars'][$config_var[0]]['min'] = $config_var['min'];
936
+				} else {
937
+									$context['config_vars'][$config_var[0]]['min'] = 0;
938
+				}
909 939
 
910
-				if (isset($config_var['max']))
911
-					$context['config_vars'][$config_var[0]]['max'] = $config_var['max'];
940
+				if (isset($config_var['max'])) {
941
+									$context['config_vars'][$config_var[0]]['max'] = $config_var['max'];
942
+				}
912 943
 
913
-				if (isset($config_var['step']))
914
-					$context['config_vars'][$config_var[0]]['step'] = $config_var['step'];
944
+				if (isset($config_var['step'])) {
945
+									$context['config_vars'][$config_var[0]]['step'] = $config_var['step'];
946
+				}
915 947
 			}
916 948
 
917 949
 			// If this is a select box handle any data.
@@ -919,12 +951,13 @@  discard block
 block discarded – undo
919 951
 			{
920 952
 				// If it's associative
921 953
 				$config_values = array_values($config_var[4]);
922
-				if (isset($config_values[0]) && is_array($config_values[0]))
923
-					$context['config_vars'][$config_var[0]]['data'] = $config_var[4];
924
-				else
954
+				if (isset($config_values[0]) && is_array($config_values[0])) {
955
+									$context['config_vars'][$config_var[0]]['data'] = $config_var[4];
956
+				} else
925 957
 				{
926
-					foreach ($config_var[4] as $key => $item)
927
-						$context['config_vars'][$config_var[0]]['data'][] = array($key, $item);
958
+					foreach ($config_var[4] as $key => $item) {
959
+											$context['config_vars'][$config_var[0]]['data'][] = array($key, $item);
960
+					}
928 961
 				}
929 962
 			}
930 963
 		}
@@ -949,10 +982,11 @@  discard block
 block discarded – undo
949 982
 
950 983
 	if (isset($_SESSION['adm-save']))
951 984
 	{
952
-		if ($_SESSION['adm-save'] === true)
953
-			$context['saved_successful'] = true;
954
-		else
955
-			$context['saved_failed'] = $_SESSION['adm-save'];
985
+		if ($_SESSION['adm-save'] === true) {
986
+					$context['saved_successful'] = true;
987
+		} else {
988
+					$context['saved_failed'] = $_SESSION['adm-save'];
989
+		}
956 990
 
957 991
 		unset($_SESSION['adm-save']);
958 992
 	}
@@ -964,26 +998,30 @@  discard block
 block discarded – undo
964 998
 	foreach ($config_vars as $config_var)
965 999
 	{
966 1000
 		// HR?
967
-		if (!is_array($config_var))
968
-			$context['config_vars'][] = $config_var;
969
-		else
1001
+		if (!is_array($config_var)) {
1002
+					$context['config_vars'][] = $config_var;
1003
+		} else
970 1004
 		{
971 1005
 			// If it has no name it doesn't have any purpose!
972
-			if (empty($config_var[1]))
973
-				continue;
1006
+			if (empty($config_var[1])) {
1007
+							continue;
1008
+			}
974 1009
 
975 1010
 			// Special case for inline permissions
976
-			if ($config_var[0] == 'permissions' && allowedTo('manage_permissions'))
977
-				$inlinePermissions[] = $config_var[1];
978
-			elseif ($config_var[0] == 'permissions')
979
-				continue;
1011
+			if ($config_var[0] == 'permissions' && allowedTo('manage_permissions')) {
1012
+							$inlinePermissions[] = $config_var[1];
1013
+			} elseif ($config_var[0] == 'permissions') {
1014
+							continue;
1015
+			}
980 1016
 
981
-			if ($config_var[0] == 'boards')
982
-				$board_list = true;
1017
+			if ($config_var[0] == 'boards') {
1018
+							$board_list = true;
1019
+			}
983 1020
 
984 1021
 			// Are we showing the BBC selection box?
985
-			if ($config_var[0] == 'bbc')
986
-				$bbcChoice[] = $config_var[1];
1022
+			if ($config_var[0] == 'bbc') {
1023
+							$bbcChoice[] = $config_var[1];
1024
+			}
987 1025
 
988 1026
 			// We need to do some parsing of the value before we pass it in.
989 1027
 			if (isset($modSettings[$config_var[1]]))
@@ -1002,8 +1040,7 @@  discard block
 block discarded – undo
1002 1040
 					default:
1003 1041
 						$value = $smcFunc['htmlspecialchars']($modSettings[$config_var[1]]);
1004 1042
 				}
1005
-			}
1006
-			else
1043
+			} else
1007 1044
 			{
1008 1045
 				// Darn, it's empty. What type is expected?
1009 1046
 				switch ($config_var[0])
@@ -1043,16 +1080,19 @@  discard block
 block discarded – undo
1043 1080
 			if ($config_var[0] == 'int' || $config_var[0] == 'float')
1044 1081
 			{
1045 1082
 				// Default to a min of 0 if one isn't set
1046
-				if (isset($config_var['min']))
1047
-					$context['config_vars'][$config_var[1]]['min'] = $config_var['min'];
1048
-				else
1049
-					$context['config_vars'][$config_var[1]]['min'] = 0;
1083
+				if (isset($config_var['min'])) {
1084
+									$context['config_vars'][$config_var[1]]['min'] = $config_var['min'];
1085
+				} else {
1086
+									$context['config_vars'][$config_var[1]]['min'] = 0;
1087
+				}
1050 1088
 
1051
-				if (isset($config_var['max']))
1052
-					$context['config_vars'][$config_var[1]]['max'] = $config_var['max'];
1089
+				if (isset($config_var['max'])) {
1090
+									$context['config_vars'][$config_var[1]]['max'] = $config_var['max'];
1091
+				}
1053 1092
 
1054
-				if (isset($config_var['step']))
1055
-					$context['config_vars'][$config_var[1]]['step'] = $config_var['step'];
1093
+				if (isset($config_var['step'])) {
1094
+									$context['config_vars'][$config_var[1]]['step'] = $config_var['step'];
1095
+				}
1056 1096
 			}
1057 1097
 
1058 1098
 			// If this is a select box handle any data.
@@ -1066,12 +1106,13 @@  discard block
 block discarded – undo
1066 1106
 				}
1067 1107
 
1068 1108
 				// If it's associative
1069
-				if (isset($config_var[2][0]) && is_array($config_var[2][0]))
1070
-					$context['config_vars'][$config_var[1]]['data'] = $config_var[2];
1071
-				else
1109
+				if (isset($config_var[2][0]) && is_array($config_var[2][0])) {
1110
+									$context['config_vars'][$config_var[1]]['data'] = $config_var[2];
1111
+				} else
1072 1112
 				{
1073
-					foreach ($config_var[2] as $key => $item)
1074
-						$context['config_vars'][$config_var[1]]['data'][] = array($key, $item);
1113
+					foreach ($config_var[2] as $key => $item) {
1114
+											$context['config_vars'][$config_var[1]]['data'][] = array($key, $item);
1115
+					}
1075 1116
 				}
1076 1117
 			}
1077 1118
 
@@ -1080,17 +1121,19 @@  discard block
 block discarded – undo
1080 1121
 			{
1081 1122
 				if (!is_numeric($k))
1082 1123
 				{
1083
-					if (substr($k, 0, 2) == 'on')
1084
-						$context['config_vars'][$config_var[1]]['javascript'] .= ' ' . $k . '="' . $v . '"';
1085
-					else
1086
-						$context['config_vars'][$config_var[1]][$k] = $v;
1124
+					if (substr($k, 0, 2) == 'on') {
1125
+											$context['config_vars'][$config_var[1]]['javascript'] .= ' ' . $k . '="' . $v . '"';
1126
+					} else {
1127
+											$context['config_vars'][$config_var[1]][$k] = $v;
1128
+					}
1087 1129
 				}
1088 1130
 
1089 1131
 				// See if there are any other labels that might fit?
1090
-				if (isset($txt['setting_' . $config_var[1]]))
1091
-					$context['config_vars'][$config_var[1]]['label'] = $txt['setting_' . $config_var[1]];
1092
-				elseif (isset($txt['groups_' . $config_var[1]]))
1093
-					$context['config_vars'][$config_var[1]]['label'] = $txt['groups_' . $config_var[1]];
1132
+				if (isset($txt['setting_' . $config_var[1]])) {
1133
+									$context['config_vars'][$config_var[1]]['label'] = $txt['setting_' . $config_var[1]];
1134
+				} elseif (isset($txt['groups_' . $config_var[1]])) {
1135
+									$context['config_vars'][$config_var[1]]['label'] = $txt['groups_' . $config_var[1]];
1136
+				}
1094 1137
 			}
1095 1138
 
1096 1139
 			// Set the subtext in case it's part of the label.
@@ -1123,8 +1166,9 @@  discard block
 block discarded – undo
1123 1166
 		// What are the options, eh?
1124 1167
 		$temp = parse_bbc(false);
1125 1168
 		$bbcTags = array();
1126
-		foreach ($temp as $tag)
1127
-			$bbcTags[] = $tag['tag'];
1169
+		foreach ($temp as $tag) {
1170
+					$bbcTags[] = $tag['tag'];
1171
+		}
1128 1172
 
1129 1173
 		$bbcTags = array_unique($bbcTags);
1130 1174
 		$totalTags = count($bbcTags);
@@ -1139,8 +1183,9 @@  discard block
 block discarded – undo
1139 1183
 		$col = 0; $i = 0;
1140 1184
 		foreach ($bbcTags as $tag)
1141 1185
 		{
1142
-			if ($i % $tagsPerColumn == 0 && $i != 0)
1143
-				$col++;
1186
+			if ($i % $tagsPerColumn == 0 && $i != 0) {
1187
+							$col++;
1188
+			}
1144 1189
 
1145 1190
 			$context['bbc_columns'][$col][] = array(
1146 1191
 				'tag' => $tag,
@@ -1183,18 +1228,21 @@  discard block
 block discarded – undo
1183 1228
 	validateToken('admin-ssc');
1184 1229
 
1185 1230
 	// Fix the darn stupid cookiename! (more may not be allowed, but these for sure!)
1186
-	if (isset($_POST['cookiename']))
1187
-		$_POST['cookiename'] = preg_replace('~[,;\s\.$]+~' . ($context['utf8'] ? 'u' : ''), '', $_POST['cookiename']);
1231
+	if (isset($_POST['cookiename'])) {
1232
+			$_POST['cookiename'] = preg_replace('~[,;\s\.$]+~' . ($context['utf8'] ? 'u' : ''), '', $_POST['cookiename']);
1233
+	}
1188 1234
 
1189 1235
 	// Fix the forum's URL if necessary.
1190 1236
 	if (isset($_POST['boardurl']))
1191 1237
 	{
1192
-		if (substr($_POST['boardurl'], -10) == '/index.php')
1193
-			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
1194
-		elseif (substr($_POST['boardurl'], -1) == '/')
1195
-			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
1196
-		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://')
1197
-			$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
1238
+		if (substr($_POST['boardurl'], -10) == '/index.php') {
1239
+					$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
1240
+		} elseif (substr($_POST['boardurl'], -1) == '/') {
1241
+					$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
1242
+		}
1243
+		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') {
1244
+					$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
1245
+		}
1198 1246
 	}
1199 1247
 
1200 1248
 	// Any passwords?
@@ -1229,21 +1277,21 @@  discard block
 block discarded – undo
1229 1277
 	// Figure out which config vars we're saving here...
1230 1278
 	foreach ($config_vars as $var)
1231 1279
 	{
1232
-		if (!is_array($var) || $var[2] != 'file' || (!in_array($var[0], $config_bools) && !isset($_POST[$var[0]])))
1233
-			continue;
1280
+		if (!is_array($var) || $var[2] != 'file' || (!in_array($var[0], $config_bools) && !isset($_POST[$var[0]]))) {
1281
+					continue;
1282
+		}
1234 1283
 
1235 1284
 		$config_var = $var[0];
1236 1285
 
1237 1286
 		if (in_array($config_var, $config_passwords))
1238 1287
 		{
1239
-			if (isset($_POST[$config_var][1]) && $_POST[$config_var][0] == $_POST[$config_var][1])
1240
-				$new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var][0], '\'\\') . '\'';
1241
-		}
1242
-		elseif (in_array($config_var, $config_strs))
1288
+			if (isset($_POST[$config_var][1]) && $_POST[$config_var][0] == $_POST[$config_var][1]) {
1289
+							$new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var][0], '\'\\') . '\'';
1290
+			}
1291
+		} elseif (in_array($config_var, $config_strs))
1243 1292
 		{
1244 1293
 			$new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var], '\'\\') . '\'';
1245
-		}
1246
-		elseif (in_array($config_var, $config_ints))
1294
+		} elseif (in_array($config_var, $config_ints))
1247 1295
 		{
1248 1296
 			$new_settings[$config_var] = (int) $_POST[$config_var];
1249 1297
 
@@ -1252,17 +1300,17 @@  discard block
 block discarded – undo
1252 1300
 			$new_settings[$config_var] = max($min, $new_settings[$config_var]);
1253 1301
 
1254 1302
 			// Is there a max value for this as well?
1255
-			if (isset($var['max']))
1256
-				$new_settings[$config_var] = min($var['max'], $new_settings[$config_var]);
1257
-		}
1258
-		elseif (in_array($config_var, $config_bools))
1303
+			if (isset($var['max'])) {
1304
+							$new_settings[$config_var] = min($var['max'], $new_settings[$config_var]);
1305
+			}
1306
+		} elseif (in_array($config_var, $config_bools))
1259 1307
 		{
1260
-			if (!empty($_POST[$config_var]))
1261
-				$new_settings[$config_var] = '1';
1262
-			else
1263
-				$new_settings[$config_var] = '0';
1264
-		}
1265
-		else
1308
+			if (!empty($_POST[$config_var])) {
1309
+							$new_settings[$config_var] = '1';
1310
+			} else {
1311
+							$new_settings[$config_var] = '0';
1312
+			}
1313
+		} else
1266 1314
 		{
1267 1315
 			// This shouldn't happen, but it might...
1268 1316
 			fatal_error('Unknown config_var \'' . $config_var . '\'');
@@ -1278,30 +1326,35 @@  discard block
 block discarded – undo
1278 1326
 	foreach ($config_vars as $config_var)
1279 1327
 	{
1280 1328
 		// We just saved the file-based settings, so skip their definitions.
1281
-		if (!is_array($config_var) || $config_var[2] == 'file')
1282
-			continue;
1329
+		if (!is_array($config_var) || $config_var[2] == 'file') {
1330
+					continue;
1331
+		}
1283 1332
 
1284 1333
 		$new_setting = array($config_var[3], $config_var[0]);
1285 1334
 
1286 1335
 		// Select options need carried over, too.
1287
-		if (isset($config_var[4]))
1288
-			$new_setting[] = $config_var[4];
1336
+		if (isset($config_var[4])) {
1337
+					$new_setting[] = $config_var[4];
1338
+		}
1289 1339
 
1290 1340
 		// Include min and max if necessary
1291
-		if (isset($config_var['min']))
1292
-			$new_setting['min'] = $config_var['min'];
1341
+		if (isset($config_var['min'])) {
1342
+					$new_setting['min'] = $config_var['min'];
1343
+		}
1293 1344
 
1294
-		if (isset($config_var['max']))
1295
-			$new_setting['max'] = $config_var['max'];
1345
+		if (isset($config_var['max'])) {
1346
+					$new_setting['max'] = $config_var['max'];
1347
+		}
1296 1348
 
1297 1349
 		// Rewrite the definition a bit.
1298 1350
 		$new_settings[] = $new_setting;
1299 1351
 	}
1300 1352
 
1301 1353
 	// Save the new database-based settings, if any.
1302
-	if (!empty($new_settings))
1303
-		saveDBSettings($new_settings);
1304
-}
1354
+	if (!empty($new_settings)) {
1355
+			saveDBSettings($new_settings);
1356
+	}
1357
+	}
1305 1358
 
1306 1359
 /**
1307 1360
  * Helper function for saving database settings.
@@ -1319,22 +1372,25 @@  discard block
 block discarded – undo
1319 1372
 	$inlinePermissions = array();
1320 1373
 	foreach ($config_vars as $var)
1321 1374
 	{
1322
-		if (!isset($var[1]) || (!isset($_POST[$var[1]]) && $var[0] != 'check' && $var[0] != 'permissions' && $var[0] != 'boards' && ($var[0] != 'bbc' || !isset($_POST[$var[1] . '_enabledTags']))))
1323
-			continue;
1375
+		if (!isset($var[1]) || (!isset($_POST[$var[1]]) && $var[0] != 'check' && $var[0] != 'permissions' && $var[0] != 'boards' && ($var[0] != 'bbc' || !isset($_POST[$var[1] . '_enabledTags'])))) {
1376
+					continue;
1377
+		}
1324 1378
 
1325 1379
 		// Checkboxes!
1326
-		elseif ($var[0] == 'check')
1327
-			$setArray[$var[1]] = !empty($_POST[$var[1]]) ? '1' : '0';
1380
+		elseif ($var[0] == 'check') {
1381
+					$setArray[$var[1]] = !empty($_POST[$var[1]]) ? '1' : '0';
1382
+		}
1328 1383
 		// Select boxes!
1329
-		elseif ($var[0] == 'select' && in_array($_POST[$var[1]], array_keys($var[2])))
1330
-			$setArray[$var[1]] = $_POST[$var[1]];
1331
-		elseif ($var[0] == 'select' && !empty($var['multiple']) && array_intersect($_POST[$var[1]], array_keys($var[2])) != array())
1384
+		elseif ($var[0] == 'select' && in_array($_POST[$var[1]], array_keys($var[2]))) {
1385
+					$setArray[$var[1]] = $_POST[$var[1]];
1386
+		} elseif ($var[0] == 'select' && !empty($var['multiple']) && array_intersect($_POST[$var[1]], array_keys($var[2])) != array())
1332 1387
 		{
1333 1388
 			// For security purposes we validate this line by line.
1334 1389
 			$lOptions = array();
1335
-			foreach ($_POST[$var[1]] as $invar)
1336
-				if (in_array($invar, array_keys($var[2])))
1390
+			foreach ($_POST[$var[1]] as $invar) {
1391
+							if (in_array($invar, array_keys($var[2])))
1337 1392
 					$lOptions[] = $invar;
1393
+			}
1338 1394
 
1339 1395
 			$setArray[$var[1]] = $smcFunc['json_encode']($lOptions);
1340 1396
 		}
@@ -1348,18 +1404,20 @@  discard block
 block discarded – undo
1348 1404
 				$request = $smcFunc['db_query']('', '
1349 1405
 					SELECT id_board
1350 1406
 					FROM {db_prefix}boards');
1351
-				while ($row = $smcFunc['db_fetch_row']($request))
1352
-					$board_list[$row[0]] = true;
1407
+				while ($row = $smcFunc['db_fetch_row']($request)) {
1408
+									$board_list[$row[0]] = true;
1409
+				}
1353 1410
 
1354 1411
 				$smcFunc['db_free_result']($request);
1355 1412
 			}
1356 1413
 
1357 1414
 			$lOptions = array();
1358 1415
 
1359
-			if (!empty($_POST[$var[1]]))
1360
-				foreach ($_POST[$var[1]] as $invar => $dummy)
1416
+			if (!empty($_POST[$var[1]])) {
1417
+							foreach ($_POST[$var[1]] as $invar => $dummy)
1361 1418
 					if (isset($board_list[$invar]))
1362 1419
 						$lOptions[] = $invar;
1420
+			}
1363 1421
 
1364 1422
 			$setArray[$var[1]] = !empty($lOptions) ? implode(',', $lOptions) : '';
1365 1423
 		}
@@ -1373,8 +1431,9 @@  discard block
 block discarded – undo
1373 1431
 			$setArray[$var[1]] = max($min, $setArray[$var[1]]);
1374 1432
 
1375 1433
 			// Do we have a max value for this as well?
1376
-			if (isset($var['max']))
1377
-				$setArray[$var[1]] = min($var['max'], $setArray[$var[1]]);
1434
+			if (isset($var['max'])) {
1435
+							$setArray[$var[1]] = min($var['max'], $setArray[$var[1]]);
1436
+			}
1378 1437
 		}
1379 1438
 		// Floating point!
1380 1439
 		elseif ($var[0] == 'float')
@@ -1386,39 +1445,46 @@  discard block
 block discarded – undo
1386 1445
 			$setArray[$var[1]] = max($min, $setArray[$var[1]]);
1387 1446
 
1388 1447
 			// Do we have a max value for this as well?
1389
-			if (isset($var['max']))
1390
-				$setArray[$var[1]] = min($var['max'], $setArray[$var[1]]);
1448
+			if (isset($var['max'])) {
1449
+							$setArray[$var[1]] = min($var['max'], $setArray[$var[1]]);
1450
+			}
1391 1451
 		}
1392 1452
 		// Text!
1393
-		elseif (in_array($var[0], array('text', 'large_text', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time')))
1394
-			$setArray[$var[1]] = $_POST[$var[1]];
1453
+		elseif (in_array($var[0], array('text', 'large_text', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'))) {
1454
+					$setArray[$var[1]] = $_POST[$var[1]];
1455
+		}
1395 1456
 		// Passwords!
1396 1457
 		elseif ($var[0] == 'password')
1397 1458
 		{
1398
-			if (isset($_POST[$var[1]][1]) && $_POST[$var[1]][0] == $_POST[$var[1]][1])
1399
-				$setArray[$var[1]] = $_POST[$var[1]][0];
1459
+			if (isset($_POST[$var[1]][1]) && $_POST[$var[1]][0] == $_POST[$var[1]][1]) {
1460
+							$setArray[$var[1]] = $_POST[$var[1]][0];
1461
+			}
1400 1462
 		}
1401 1463
 		// BBC.
1402 1464
 		elseif ($var[0] == 'bbc')
1403 1465
 		{
1404 1466
 			$bbcTags = array();
1405
-			foreach (parse_bbc(false) as $tag)
1406
-				$bbcTags[] = $tag['tag'];
1467
+			foreach (parse_bbc(false) as $tag) {
1468
+							$bbcTags[] = $tag['tag'];
1469
+			}
1407 1470
 
1408
-			if (!isset($_POST[$var[1] . '_enabledTags']))
1409
-				$_POST[$var[1] . '_enabledTags'] = array();
1410
-			elseif (!is_array($_POST[$var[1] . '_enabledTags']))
1411
-				$_POST[$var[1] . '_enabledTags'] = array($_POST[$var[1] . '_enabledTags']);
1471
+			if (!isset($_POST[$var[1] . '_enabledTags'])) {
1472
+							$_POST[$var[1] . '_enabledTags'] = array();
1473
+			} elseif (!is_array($_POST[$var[1] . '_enabledTags'])) {
1474
+							$_POST[$var[1] . '_enabledTags'] = array($_POST[$var[1] . '_enabledTags']);
1475
+			}
1412 1476
 
1413 1477
 			$setArray[$var[1]] = implode(',', array_diff($bbcTags, $_POST[$var[1] . '_enabledTags']));
1414 1478
 		}
1415 1479
 		// Permissions?
1416
-		elseif ($var[0] == 'permissions')
1417
-			$inlinePermissions[] = $var[1];
1480
+		elseif ($var[0] == 'permissions') {
1481
+					$inlinePermissions[] = $var[1];
1482
+		}
1418 1483
 	}
1419 1484
 
1420
-	if (!empty($setArray))
1421
-		updateSettings($setArray);
1485
+	if (!empty($setArray)) {
1486
+			updateSettings($setArray);
1487
+	}
1422 1488
 
1423 1489
 	// If we have inline permissions we need to save them.
1424 1490
 	if (!empty($inlinePermissions) && allowedTo('manage_permissions'))
@@ -1455,18 +1521,21 @@  discard block
 block discarded – undo
1455 1521
 	// put all of it into an array
1456 1522
 	foreach ($info_lines as $line)
1457 1523
 	{
1458
-		if (preg_match('~(' . $remove . ')~', $line))
1459
-			continue;
1524
+		if (preg_match('~(' . $remove . ')~', $line)) {
1525
+					continue;
1526
+		}
1460 1527
 
1461 1528
 		// new category?
1462
-		if (strpos($line, '<h2>') !== false)
1463
-			$category = preg_match('~<h2>(.*)</h2>~', $line, $title) ? $category = $title[1] : $category;
1529
+		if (strpos($line, '<h2>') !== false) {
1530
+					$category = preg_match('~<h2>(.*)</h2>~', $line, $title) ? $category = $title[1] : $category;
1531
+		}
1464 1532
 
1465 1533
 		// load it as setting => value or the old setting local master
1466
-		if (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val))
1467
-			$pinfo[$category][$val[1]] = $val[2];
1468
-		elseif (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val))
1469
-			$pinfo[$category][$val[1]] = array($txt['phpinfo_localsettings'] => $val[2], $txt['phpinfo_defaultsettings'] => $val[3]);
1534
+		if (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) {
1535
+					$pinfo[$category][$val[1]] = $val[2];
1536
+		} elseif (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) {
1537
+					$pinfo[$category][$val[1]] = array($txt['phpinfo_localsettings'] => $val[2], $txt['phpinfo_defaultsettings'] => $val[3]);
1538
+		}
1470 1539
 	}
1471 1540
 
1472 1541
 	// load it in to context and display it
@@ -1501,8 +1570,9 @@  discard block
 block discarded – undo
1501 1570
 				$testAPI = new $cache_class_name();
1502 1571
 
1503 1572
 				// No Support?  NEXT!
1504
-				if (!$testAPI->isSupported(true))
1505
-					continue;
1573
+				if (!$testAPI->isSupported(true)) {
1574
+									continue;
1575
+				}
1506 1576
 
1507 1577
 				$apis[$tryCache] = isset($txt[$tryCache . '_cache']) ? $txt[$tryCache . '_cache'] : $tryCache;
1508 1578
 			}
@@ -1527,8 +1597,9 @@  discard block
 block discarded – undo
1527 1597
 	global $modSettings, $boardurl, $smcFunc;
1528 1598
 
1529 1599
 	// Already have a key?  Can't register again.
1530
-	if (!empty($modSettings['sm_stats_key']))
1531
-		return true;
1600
+	if (!empty($modSettings['sm_stats_key'])) {
1601
+			return true;
1602
+	}
1532 1603
 
1533 1604
 	$fp = @fsockopen('www.simplemachines.org', 80, $errno, $errstr);
1534 1605
 	if ($fp)
@@ -1539,8 +1610,9 @@  discard block
 block discarded – undo
1539 1610
 		fwrite($fp, $out);
1540 1611
 
1541 1612
 		$return_data = '';
1542
-		while (!feof($fp))
1543
-			$return_data .= fgets($fp, 128);
1613
+		while (!feof($fp)) {
1614
+					$return_data .= fgets($fp, 128);
1615
+		}
1544 1616
 
1545 1617
 		fclose($fp);
1546 1618
 
Please login to merge, or discard this patch.