Completed
Push — release-2.1 ( db4ee6...3cff84 )
by Colin
07:54
created
Sources/Logging.php 1 patch
Braces   +140 added lines, -101 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
  * Truncate the GET array to a specified length
@@ -26,14 +27,15 @@  discard block
 block discarded – undo
26 27
 function truncateArray($arr, $max_length=1900)
27 28
 {
28 29
 	$curr_length = array_sum(array_map("strlen", $arr));
29
-	if ($curr_length <= $max_length)
30
-		return $arr;
31
-	else
30
+	if ($curr_length <= $max_length) {
31
+			return $arr;
32
+	} else
32 33
 	{
33 34
 		// Truncate each element's value to a reasonable length
34 35
 		$param_max = floor($max_length/count($arr));
35
-		foreach ($arr as $key => &$value)
36
-			$value = substr($value, 0, $param_max - strlen($key) - 5);
36
+		foreach ($arr as $key => &$value) {
37
+					$value = substr($value, 0, $param_max - strlen($key) - 5);
38
+		}
37 39
 		return $arr;
38 40
 	}
39 41
 }
@@ -55,8 +57,9 @@  discard block
 block discarded – undo
55 57
 		// Don't update for every page - this isn't wholly accurate but who cares.
56 58
 		if ($topic)
57 59
 		{
58
-			if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic)
59
-				$force = false;
60
+			if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic) {
61
+							$force = false;
62
+			}
60 63
 			$_SESSION['last_topic_id'] = $topic;
61 64
 		}
62 65
 	}
@@ -69,22 +72,24 @@  discard block
 block discarded – undo
69 72
 	}
70 73
 
71 74
 	// Don't mark them as online more than every so often.
72
-	if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force)
73
-		return;
75
+	if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force) {
76
+			return;
77
+	}
74 78
 
75 79
 	if (!empty($modSettings['who_enabled']))
76 80
 	{
77 81
 		$encoded_get = truncateArray($_GET) + array('USER_AGENT' => $_SERVER['HTTP_USER_AGENT']);
78 82
 
79 83
 		// In the case of a dlattach action, session_var may not be set.
80
-		if (!isset($context['session_var']))
81
-			$context['session_var'] = $_SESSION['session_var'];
84
+		if (!isset($context['session_var'])) {
85
+					$context['session_var'] = $_SESSION['session_var'];
86
+		}
82 87
 
83 88
 		unset($encoded_get['sesc'], $encoded_get[$context['session_var']]);
84 89
 		$encoded_get = $smcFunc['json_encode']($encoded_get);
90
+	} else {
91
+			$encoded_get = '';
85 92
 	}
86
-	else
87
-		$encoded_get = '';
88 93
 
89 94
 	// Guests use 0, members use their session ID.
90 95
 	$session_id = $user_info['is_guest'] ? 'ip' . $user_info['ip'] : session_id();
@@ -124,17 +129,18 @@  discard block
 block discarded – undo
124 129
 		);
125 130
 
126 131
 		// Guess it got deleted.
127
-		if ($smcFunc['db_affected_rows']() == 0)
132
+		if ($smcFunc['db_affected_rows']() == 0) {
133
+					$_SESSION['log_time'] = 0;
134
+		}
135
+	} else {
128 136
 			$_SESSION['log_time'] = 0;
129 137
 	}
130
-	else
131
-		$_SESSION['log_time'] = 0;
132 138
 
133 139
 	// Otherwise, we have to delete and insert.
134 140
 	if (empty($_SESSION['log_time']))
135 141
 	{
136
-		if ($do_delete || !empty($user_info['id']))
137
-			$smcFunc['db_query']('', '
142
+		if ($do_delete || !empty($user_info['id'])) {
143
+					$smcFunc['db_query']('', '
138 144
 				DELETE FROM {db_prefix}log_online
139 145
 				WHERE ' . ($do_delete ? 'log_time < {int:log_time}' : '') . ($do_delete && !empty($user_info['id']) ? ' OR ' : '') . (empty($user_info['id']) ? '' : 'id_member = {int:current_member}'),
140 146
 				array(
@@ -142,6 +148,7 @@  discard block
 block discarded – undo
142 148
 					'log_time' => time() - $modSettings['lastActive'] * 60,
143 149
 				)
144 150
 			);
151
+		}
145 152
 
146 153
 		$smcFunc['db_insert']($do_delete ? 'ignore' : 'replace',
147 154
 			'{db_prefix}log_online',
@@ -155,21 +162,24 @@  discard block
 block discarded – undo
155 162
 	$_SESSION['log_time'] = time();
156 163
 
157 164
 	// Well, they are online now.
158
-	if (empty($_SESSION['timeOnlineUpdated']))
159
-		$_SESSION['timeOnlineUpdated'] = time();
165
+	if (empty($_SESSION['timeOnlineUpdated'])) {
166
+			$_SESSION['timeOnlineUpdated'] = time();
167
+	}
160 168
 
161 169
 	// Set their login time, if not already done within the last minute.
162 170
 	if (SMF != 'SSI' && !empty($user_info['last_login']) && $user_info['last_login'] < time() - 60 && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('.xml', 'login2', 'logintfa'))))
163 171
 	{
164 172
 		// Don't count longer than 15 minutes.
165
-		if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15)
166
-			$_SESSION['timeOnlineUpdated'] = time();
173
+		if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15) {
174
+					$_SESSION['timeOnlineUpdated'] = time();
175
+		}
167 176
 
168 177
 		$user_settings['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated'];
169 178
 		updateMemberData($user_info['id'], array('last_login' => time(), 'member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP'], 'total_time_logged_in' => $user_settings['total_time_logged_in']));
170 179
 
171
-		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
172
-			cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60);
180
+		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
181
+					cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60);
182
+		}
173 183
 
174 184
 		$user_info['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated'];
175 185
 		$_SESSION['timeOnlineUpdated'] = time();
@@ -206,8 +216,7 @@  discard block
 block discarded – undo
206 216
 			// Oops. maybe we have no more disk space left, or some other troubles, troubles...
207 217
 			// Copy the file back and run for your life!
208 218
 			@copy($boarddir . '/db_last_error_bak.php', $boarddir . '/db_last_error.php');
209
-		}
210
-		else
219
+		} else
211 220
 		{
212 221
 			@touch($boarddir . '/' . 'Settings.php');
213 222
 			return true;
@@ -227,22 +236,27 @@  discard block
 block discarded – undo
227 236
 	global $db_cache, $db_count, $cache_misses, $cache_count_misses, $db_show_debug, $cache_count, $cache_hits, $smcFunc, $txt;
228 237
 
229 238
 	// Add to Settings.php if you want to show the debugging information.
230
-	if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery'))
231
-		return;
239
+	if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery')) {
240
+			return;
241
+	}
232 242
 
233
-	if (empty($_SESSION['view_queries']))
234
-		$_SESSION['view_queries'] = 0;
235
-	if (empty($context['debug']['language_files']))
236
-		$context['debug']['language_files'] = array();
237
-	if (empty($context['debug']['sheets']))
238
-		$context['debug']['sheets'] = array();
243
+	if (empty($_SESSION['view_queries'])) {
244
+			$_SESSION['view_queries'] = 0;
245
+	}
246
+	if (empty($context['debug']['language_files'])) {
247
+			$context['debug']['language_files'] = array();
248
+	}
249
+	if (empty($context['debug']['sheets'])) {
250
+			$context['debug']['sheets'] = array();
251
+	}
239 252
 
240 253
 	$files = get_included_files();
241 254
 	$total_size = 0;
242 255
 	for ($i = 0, $n = count($files); $i < $n; $i++)
243 256
 	{
244
-		if (file_exists($files[$i]))
245
-			$total_size += filesize($files[$i]);
257
+		if (file_exists($files[$i])) {
258
+					$total_size += filesize($files[$i]);
259
+		}
246 260
 		$files[$i] = strtr($files[$i], array($boarddir => '.', $sourcedir => '(Sources)', $cachedir => '(Cache)', $settings['actual_theme_dir'] => '(Current Theme)'));
247 261
 	}
248 262
 
@@ -251,8 +265,9 @@  discard block
 block discarded – undo
251 265
 	{
252 266
 		foreach ($db_cache as $q => $qq)
253 267
 		{
254
-			if (!empty($qq['w']))
255
-				$warnings += count($qq['w']);
268
+			if (!empty($qq['w'])) {
269
+							$warnings += count($qq['w']);
270
+			}
256 271
 		}
257 272
 
258 273
 		$_SESSION['debug'] = &$db_cache;
@@ -273,12 +288,14 @@  discard block
 block discarded – undo
273 288
 	',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">'. $txt['debug_show'] .'</a><span id="debug_instances" style="display: none;"><em>'. implode('</em>, <em>', array_keys($context['debug']['instances'])) .'</em></span>)'. '<br>') : ''),'
274 289
 	', $txt['debug_files_included'], count($files), ' - ', round($total_size / 1024), $txt['debug_kb'], ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_include_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_include_info" style="display: none;"><em>', implode('</em>, <em>', $files), '</em></span>)<br>';
275 290
 
276
-	if (function_exists('memory_get_peak_usage'))
277
-		echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>';
291
+	if (function_exists('memory_get_peak_usage')) {
292
+			echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>';
293
+	}
278 294
 
279 295
 	// What tokens are active?
280
-	if (isset($_SESSION['token']))
281
-		echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>';
296
+	if (isset($_SESSION['token'])) {
297
+			echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>';
298
+	}
282 299
 
283 300
 	if (!empty($modSettings['cache_enable']) && !empty($cache_hits))
284 301
 	{
@@ -292,10 +309,12 @@  discard block
 block discarded – undo
292 309
 			$total_t += $cache_hit['t'];
293 310
 			$total_s += $cache_hit['s'];
294 311
 		}
295
-		if (!isset($cache_misses))
296
-			$cache_misses = array();
297
-		foreach ($cache_misses as $missed)
298
-			$missed_entries[] = $missed['d'] . ' ' . $missed['k'];
312
+		if (!isset($cache_misses)) {
313
+					$cache_misses = array();
314
+		}
315
+		foreach ($cache_misses as $missed) {
316
+					$missed_entries[] = $missed['d'] . ' ' . $missed['k'];
317
+		}
299 318
 
300 319
 		echo '
301 320
 	', $txt['debug_cache_hits'], $cache_count, ': ', sprintf($txt['debug_cache_seconds_bytes_total'], comma_format($total_t, 5), comma_format($total_s)), ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_cache_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_cache_info" style="display: none;"><em>', implode('</em>, <em>', $entries), '</em></span>)<br>
@@ -306,38 +325,44 @@  discard block
 block discarded – undo
306 325
 	<a href="', $scripturl, '?action=viewquery" target="_blank" rel="noopener">', $warnings == 0 ? sprintf($txt['debug_queries_used'], (int) $db_count) : sprintf($txt['debug_queries_used_and_warnings'], (int) $db_count, $warnings), '</a><br>
307 326
 	<br>';
308 327
 
309
-	if ($_SESSION['view_queries'] == 1 && !empty($db_cache))
310
-		foreach ($db_cache as $q => $qq)
328
+	if ($_SESSION['view_queries'] == 1 && !empty($db_cache)) {
329
+			foreach ($db_cache as $q => $qq)
311 330
 		{
312 331
 			$is_select = strpos(trim($qq['q']), 'SELECT') === 0 || preg_match('~^INSERT(?: IGNORE)? INTO \w+(?:\s+\([^)]+\))?\s+SELECT .+$~s', trim($qq['q'])) != 0;
332
+	}
313 333
 			// Temporary tables created in earlier queries are not explainable.
314 334
 			if ($is_select)
315 335
 			{
316
-				foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp)
317
-					if (strpos(trim($qq['q']), $tmp) !== false)
336
+				foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) {
337
+									if (strpos(trim($qq['q']), $tmp) !== false)
318 338
 					{
319 339
 						$is_select = false;
340
+				}
320 341
 						break;
321 342
 					}
322 343
 			}
323 344
 			// But actual creation of the temporary tables are.
324
-			elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($qq['q'])) != 0)
325
-				$is_select = true;
345
+			elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($qq['q'])) != 0) {
346
+							$is_select = true;
347
+			}
326 348
 
327 349
 			// Make the filenames look a bit better.
328
-			if (isset($qq['f']))
329
-				$qq['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $qq['f']);
350
+			if (isset($qq['f'])) {
351
+							$qq['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $qq['f']);
352
+			}
330 353
 
331 354
 			echo '
332 355
 	<strong>', $is_select ? '<a href="' . $scripturl . '?action=viewquery;qq=' . ($q + 1) . '#qq' . $q . '" target="_blank" rel="noopener" style="text-decoration: none;">' : '', nl2br(str_replace("\t", '&nbsp;&nbsp;&nbsp;', $smcFunc['htmlspecialchars'](ltrim($qq['q'], "\n\r")))) . ($is_select ? '</a></strong>' : '</strong>') . '<br>
333 356
 	&nbsp;&nbsp;&nbsp;';
334
-			if (!empty($qq['f']) && !empty($qq['l']))
335
-				echo sprintf($txt['debug_query_in_line'], $qq['f'], $qq['l']);
357
+			if (!empty($qq['f']) && !empty($qq['l'])) {
358
+							echo sprintf($txt['debug_query_in_line'], $qq['f'], $qq['l']);
359
+			}
336 360
 
337
-			if (isset($qq['s'], $qq['t']) && isset($txt['debug_query_which_took_at']))
338
-				echo sprintf($txt['debug_query_which_took_at'], round($qq['t'], 8), round($qq['s'], 8)) . '<br>';
339
-			elseif (isset($qq['t']))
340
-				echo sprintf($txt['debug_query_which_took'], round($qq['t'], 8)) . '<br>';
361
+			if (isset($qq['s'], $qq['t']) && isset($txt['debug_query_which_took_at'])) {
362
+							echo sprintf($txt['debug_query_which_took_at'], round($qq['t'], 8), round($qq['s'], 8)) . '<br>';
363
+			} elseif (isset($qq['t'])) {
364
+							echo sprintf($txt['debug_query_which_took'], round($qq['t'], 8)) . '<br>';
365
+			}
341 366
 			echo '
342 367
 	<br>';
343 368
 		}
@@ -362,12 +387,14 @@  discard block
 block discarded – undo
362 387
 	global $modSettings, $smcFunc;
363 388
 	static $cache_stats = array();
364 389
 
365
-	if (empty($modSettings['trackStats']))
366
-		return false;
367
-	if (!empty($stats))
368
-		return $cache_stats = array_merge($cache_stats, $stats);
369
-	elseif (empty($cache_stats))
370
-		return false;
390
+	if (empty($modSettings['trackStats'])) {
391
+			return false;
392
+	}
393
+	if (!empty($stats)) {
394
+			return $cache_stats = array_merge($cache_stats, $stats);
395
+	} elseif (empty($cache_stats)) {
396
+			return false;
397
+	}
371 398
 
372 399
 	$setStringUpdate = '';
373 400
 	$insert_keys = array();
@@ -380,10 +407,11 @@  discard block
 block discarded – undo
380 407
 		$setStringUpdate .= '
381 408
 			' . $field . ' = ' . ($change === '+' ? $field . ' + 1' : '{int:' . $field . '}') . ',';
382 409
 
383
-		if ($change === '+')
384
-			$cache_stats[$field] = 1;
385
-		else
386
-			$update_parameters[$field] = $change;
410
+		if ($change === '+') {
411
+					$cache_stats[$field] = 1;
412
+		} else {
413
+					$update_parameters[$field] = $change;
414
+		}
387 415
 		$insert_keys[$field] = 'int';
388 416
 	}
389 417
 
@@ -447,43 +475,50 @@  discard block
 block discarded – undo
447 475
 	);
448 476
 
449 477
 	// Make sure this particular log is enabled first...
450
-	if (empty($modSettings['modlog_enabled']))
451
-		unset ($log_types['moderate']);
452
-	if (empty($modSettings['userlog_enabled']))
453
-		unset ($log_types['user']);
454
-	if (empty($modSettings['adminlog_enabled']))
455
-		unset ($log_types['admin']);
478
+	if (empty($modSettings['modlog_enabled'])) {
479
+			unset ($log_types['moderate']);
480
+	}
481
+	if (empty($modSettings['userlog_enabled'])) {
482
+			unset ($log_types['user']);
483
+	}
484
+	if (empty($modSettings['adminlog_enabled'])) {
485
+			unset ($log_types['admin']);
486
+	}
456 487
 
457 488
 	call_integration_hook('integrate_log_types', array(&$log_types));
458 489
 
459 490
 	foreach ($logs as $log)
460 491
 	{
461
-		if (!isset($log_types[$log['log_type']]))
462
-			return false;
492
+		if (!isset($log_types[$log['log_type']])) {
493
+					return false;
494
+		}
463 495
 
464
-		if (!is_array($log['extra']))
465
-			trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE);
496
+		if (!is_array($log['extra'])) {
497
+					trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE);
498
+		}
466 499
 
467 500
 		// Pull out the parts we want to store separately, but also make sure that the data is proper
468 501
 		if (isset($log['extra']['topic']))
469 502
 		{
470
-			if (!is_numeric($log['extra']['topic']))
471
-				trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE);
503
+			if (!is_numeric($log['extra']['topic'])) {
504
+							trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE);
505
+			}
472 506
 			$topic_id = empty($log['extra']['topic']) ? 0 : (int) $log['extra']['topic'];
473 507
 			unset($log['extra']['topic']);
508
+		} else {
509
+					$topic_id = 0;
474 510
 		}
475
-		else
476
-			$topic_id = 0;
477 511
 
478 512
 		if (isset($log['extra']['message']))
479 513
 		{
480
-			if (!is_numeric($log['extra']['message']))
481
-				trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE);
514
+			if (!is_numeric($log['extra']['message'])) {
515
+							trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE);
516
+			}
482 517
 			$msg_id = empty($log['extra']['message']) ? 0 : (int) $log['extra']['message'];
483 518
 			unset($log['extra']['message']);
519
+		} else {
520
+					$msg_id = 0;
484 521
 		}
485
-		else
486
-			$msg_id = 0;
487 522
 
488 523
 		// @todo cache this?
489 524
 		// Is there an associated report on this?
@@ -510,23 +545,26 @@  discard block
 block discarded – undo
510 545
 			$smcFunc['db_free_result']($request);
511 546
 		}
512 547
 
513
-		if (isset($log['extra']['member']) && !is_numeric($log['extra']['member']))
514
-			trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE);
548
+		if (isset($log['extra']['member']) && !is_numeric($log['extra']['member'])) {
549
+					trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE);
550
+		}
515 551
 
516 552
 		if (isset($log['extra']['board']))
517 553
 		{
518
-			if (!is_numeric($log['extra']['board']))
519
-				trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE);
554
+			if (!is_numeric($log['extra']['board'])) {
555
+							trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE);
556
+			}
520 557
 			$board_id = empty($log['extra']['board']) ? 0 : (int) $log['extra']['board'];
521 558
 			unset($log['extra']['board']);
559
+		} else {
560
+					$board_id = 0;
522 561
 		}
523
-		else
524
-			$board_id = 0;
525 562
 
526 563
 		if (isset($log['extra']['board_to']))
527 564
 		{
528
-			if (!is_numeric($log['extra']['board_to']))
529
-				trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE);
565
+			if (!is_numeric($log['extra']['board_to'])) {
566
+							trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE);
567
+			}
530 568
 			if (empty($board_id))
531 569
 			{
532 570
 				$board_id = empty($log['extra']['board_to']) ? 0 : (int) $log['extra']['board_to'];
@@ -534,10 +572,11 @@  discard block
 block discarded – undo
534 572
 			}
535 573
 		}
536 574
 
537
-		if (isset($log['extra']['member_affected']))
538
-			$memID = $log['extra']['member_affected'];
539
-		else
540
-			$memID = $user_info['id'];
575
+		if (isset($log['extra']['member_affected'])) {
576
+					$memID = $log['extra']['member_affected'];
577
+		} else {
578
+					$memID = $user_info['id'];
579
+		}
541 580
 
542 581
 		$inserts[] = array(
543 582
 			time(), $log_types[$log['log_type']], $memID, $user_info['ip'], $log['action'],
Please login to merge, or discard this patch.
Sources/Profile-Actions.php 1 patch
Braces   +117 added lines, -86 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
  * Activate an account.
@@ -48,8 +49,9 @@  discard block
 block discarded – undo
48 49
 		logAction('approve_member', array('member' => $memID), 'admin');
49 50
 
50 51
 		// If we are doing approval, update the stats for the member just in case.
51
-		if (in_array($user_profile[$memID]['is_activated'], array(3, 4, 5, 13, 14, 15)))
52
-			updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 1 ? $modSettings['unapprovedMembers'] - 1 : 0)));
52
+		if (in_array($user_profile[$memID]['is_activated'], array(3, 4, 5, 13, 14, 15))) {
53
+					updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 1 ? $modSettings['unapprovedMembers'] - 1 : 0)));
54
+		}
53 55
 
54 56
 		// Make sure we update the stats too.
55 57
 		updateStats('member', false);
@@ -76,8 +78,9 @@  discard block
 block discarded – undo
76 78
 	$issueErrors = array();
77 79
 
78 80
 	// Doesn't hurt to be overly cautious.
79
-	if (empty($modSettings['warning_enable']) || ($context['user']['is_owner'] && !$cur_profile['warning']) || !allowedTo('issue_warning'))
80
-		fatal_lang_error('no_access', false);
81
+	if (empty($modSettings['warning_enable']) || ($context['user']['is_owner'] && !$cur_profile['warning']) || !allowedTo('issue_warning')) {
82
+			fatal_lang_error('no_access', false);
83
+	}
81 84
 
82 85
 	// Get the base (errors related) stuff done.
83 86
 	loadLanguage('Errors');
@@ -135,16 +138,18 @@  discard block
 block discarded – undo
135 138
 
136 139
 		// This cannot be empty!
137 140
 		$_POST['warn_reason'] = isset($_POST['warn_reason']) ? trim($_POST['warn_reason']) : '';
138
-		if ($_POST['warn_reason'] == '' && !$context['user']['is_owner'])
139
-			$issueErrors[] = 'warning_no_reason';
141
+		if ($_POST['warn_reason'] == '' && !$context['user']['is_owner']) {
142
+					$issueErrors[] = 'warning_no_reason';
143
+		}
140 144
 		$_POST['warn_reason'] = $smcFunc['htmlspecialchars']($_POST['warn_reason']);
141 145
 
142 146
 		$_POST['warning_level'] = (int) $_POST['warning_level'];
143 147
 		$_POST['warning_level'] = max(0, min(100, $_POST['warning_level']));
144
-		if ($_POST['warning_level'] < $context['min_allowed'])
145
-			$_POST['warning_level'] = $context['min_allowed'];
146
-		elseif ($_POST['warning_level'] > $context['max_allowed'])
147
-			$_POST['warning_level'] = $context['max_allowed'];
148
+		if ($_POST['warning_level'] < $context['min_allowed']) {
149
+					$_POST['warning_level'] = $context['min_allowed'];
150
+		} elseif ($_POST['warning_level'] > $context['max_allowed']) {
151
+					$_POST['warning_level'] = $context['max_allowed'];
152
+		}
148 153
 
149 154
 		// Do we actually have to issue them with a PM?
150 155
 		$id_notice = 0;
@@ -152,8 +157,9 @@  discard block
 block discarded – undo
152 157
 		{
153 158
 			$_POST['warn_sub'] = trim($_POST['warn_sub']);
154 159
 			$_POST['warn_body'] = trim($_POST['warn_body']);
155
-			if (empty($_POST['warn_sub']) || empty($_POST['warn_body']))
156
-				$issueErrors[] = 'warning_notify_blank';
160
+			if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) {
161
+							$issueErrors[] = 'warning_notify_blank';
162
+			}
157 163
 			// Send the PM?
158 164
 			else
159 165
 			{
@@ -190,8 +196,8 @@  discard block
 block discarded – undo
190 196
 		if (empty($issueErrors))
191 197
 		{
192 198
 			// Log what we've done!
193
-			if (!$context['user']['is_owner'])
194
-				$smcFunc['db_insert']('',
199
+			if (!$context['user']['is_owner']) {
200
+							$smcFunc['db_insert']('',
195 201
 					'{db_prefix}log_comments',
196 202
 					array(
197 203
 						'id_member' => 'int', 'member_name' => 'string', 'comment_type' => 'string', 'id_recipient' => 'int', 'recipient_name' => 'string-255',
@@ -203,14 +209,14 @@  discard block
 block discarded – undo
203 209
 					),
204 210
 					array('id_comment')
205 211
 				);
212
+			}
206 213
 
207 214
 			// Make the change.
208 215
 			updateMemberData($memID, array('warning' => $_POST['warning_level']));
209 216
 
210 217
 			// Leave a lovely message.
211 218
 			$context['profile_updated'] = $context['user']['is_owner'] ? $txt['profile_updated_own'] : $txt['profile_warning_success'];
212
-		}
213
-		else
219
+		} else
214 220
 		{
215 221
 			// Try to remember some bits.
216 222
 			$context['warning_data'] = array(
@@ -229,8 +235,9 @@  discard block
 block discarded – undo
229 235
 	{
230 236
 		$warning_body = !empty($_POST['warn_body']) ? trim(censorText($_POST['warn_body'])) : '';
231 237
 		$context['preview_subject'] = !empty($_POST['warn_sub']) ? trim($smcFunc['htmlspecialchars']($_POST['warn_sub'])) : '';
232
-		if (empty($_POST['warn_sub']) || empty($_POST['warn_body']))
233
-			$issueErrors[] = 'warning_notify_blank';
238
+		if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) {
239
+					$issueErrors[] = 'warning_notify_blank';
240
+		}
234 241
 
235 242
 		if (!empty($_POST['warn_body']))
236 243
 		{
@@ -254,8 +261,9 @@  discard block
 block discarded – undo
254 261
 	{
255 262
 		// Fill in the suite of errors.
256 263
 		$context['post_errors'] = array();
257
-		foreach ($issueErrors as $error)
258
-			$context['post_errors'][] = $txt[$error];
264
+		foreach ($issueErrors as $error) {
265
+					$context['post_errors'][] = $txt[$error];
266
+		}
259 267
 	}
260 268
 
261 269
 
@@ -272,9 +280,10 @@  discard block
 block discarded – undo
272 280
 		$modSettings['warning_mute'] => $txt['profile_warning_effect_mute'],
273 281
 	);
274 282
 	$context['current_level'] = 0;
275
-	foreach ($context['level_effects'] as $limit => $dummy)
276
-		if ($context['member']['warning'] >= $limit)
283
+	foreach ($context['level_effects'] as $limit => $dummy) {
284
+			if ($context['member']['warning'] >= $limit)
277 285
 			$context['current_level'] = $limit;
286
+	}
278 287
 
279 288
 	$listOptions = array(
280 289
 		'id' => 'view_warnings',
@@ -337,11 +346,12 @@  discard block
 block discarded – undo
337 346
 							' . $warning['reason'] . '
338 347
 						</div>';
339 348
 
340
-						if (!empty($warning['id_notice']))
341
-							$ret .= '
349
+						if (!empty($warning['id_notice'])) {
350
+													$ret .= '
342 351
 						<div class="floatright">
343 352
 							<a href="' . $scripturl . '?action=moderate;area=notice;nid=' . $warning['id_notice'] . '" onclick="window.open(this.href, \'\', \'scrollbars=yes,resizable=yes,width=400,height=250\');return false;" target="_blank" rel="noopener" title="' . $txt['profile_warning_previous_notice'] . '"><span class="generic_icons filter centericon"></span></a>
344 353
 						</div>';
354
+						}
345 355
 
346 356
 						return $ret;
347 357
 					},
@@ -413,8 +423,9 @@  discard block
 block discarded – undo
413 423
 	while ($row = $smcFunc['db_fetch_assoc']($request))
414 424
 	{
415 425
 		// If we're not warning for a message skip any that are.
416
-		if (!$context['warning_for_message'] && strpos($row['body'], '{MESSAGE}') !== false)
417
-			continue;
426
+		if (!$context['warning_for_message'] && strpos($row['body'], '{MESSAGE}') !== false) {
427
+					continue;
428
+		}
418 429
 
419 430
 		$context['notification_templates'][] = array(
420 431
 			'title' => $row['template_title'],
@@ -424,16 +435,18 @@  discard block
 block discarded – undo
424 435
 	$smcFunc['db_free_result']($request);
425 436
 
426 437
 	// Setup the "default" templates.
427
-	foreach (array('spamming', 'offence', 'insulting') as $type)
428
-		$context['notification_templates'][] = array(
438
+	foreach (array('spamming', 'offence', 'insulting') as $type) {
439
+			$context['notification_templates'][] = array(
429 440
 			'title' => $txt['profile_warning_notify_title_' . $type],
430 441
 			'body' => sprintf($txt['profile_warning_notify_template_outline' . (!empty($context['warning_for_message']) ? '_post' : '')], $txt['profile_warning_notify_for_' . $type]),
431 442
 		);
443
+	}
432 444
 
433 445
 	// Replace all the common variables in the templates.
434
-	foreach ($context['notification_templates'] as $k => $name)
435
-		$context['notification_templates'][$k]['body'] = strtr($name['body'], array('{MEMBER}' => un_htmlspecialchars($context['member']['name']), '{MESSAGE}' => '[url=' . $scripturl . '?msg=' . $context['warning_for_message'] . ']' . un_htmlspecialchars($context['warned_message_subject']) . '[/url]', '{SCRIPTURL}' => $scripturl, '{FORUMNAME}' => $mbname, '{REGARDS}' => $txt['regards_team']));
436
-}
446
+	foreach ($context['notification_templates'] as $k => $name) {
447
+			$context['notification_templates'][$k]['body'] = strtr($name['body'], array('{MEMBER}' => un_htmlspecialchars($context['member']['name']), '{MESSAGE}' => '[url=' . $scripturl . '?msg=' . $context['warning_for_message'] . ']' . un_htmlspecialchars($context['warned_message_subject']) . '[/url]', '{SCRIPTURL}' => $scripturl, '{FORUMNAME}' => $mbname, '{REGARDS}' => $txt['regards_team']));
448
+	}
449
+	}
437 450
 
438 451
 /**
439 452
  * Get the number of warnings a user has. Callback for $listOptions['get_count'] in issueWarning()
@@ -517,10 +530,11 @@  discard block
 block discarded – undo
517 530
 {
518 531
 	global $txt, $context, $modSettings, $cur_profile;
519 532
 
520
-	if (!$context['user']['is_owner'])
521
-		isAllowedTo('profile_remove_any');
522
-	elseif (!allowedTo('profile_remove_any'))
523
-		isAllowedTo('profile_remove_own');
533
+	if (!$context['user']['is_owner']) {
534
+			isAllowedTo('profile_remove_any');
535
+	} elseif (!allowedTo('profile_remove_any')) {
536
+			isAllowedTo('profile_remove_own');
537
+	}
524 538
 
525 539
 	// Permissions for removing stuff...
526 540
 	$context['can_delete_posts'] = !$context['user']['is_owner'] && allowedTo('moderate_forum');
@@ -547,10 +561,11 @@  discard block
 block discarded – undo
547 561
 
548 562
 	// @todo Add a way to delete pms as well?
549 563
 
550
-	if (!$context['user']['is_owner'])
551
-		isAllowedTo('profile_remove_any');
552
-	elseif (!allowedTo('profile_remove_any'))
553
-		isAllowedTo('profile_remove_own');
564
+	if (!$context['user']['is_owner']) {
565
+			isAllowedTo('profile_remove_any');
566
+	} elseif (!allowedTo('profile_remove_any')) {
567
+			isAllowedTo('profile_remove_own');
568
+	}
554 569
 
555 570
 	checkSession();
556 571
 
@@ -576,8 +591,9 @@  discard block
 block discarded – undo
576 591
 		list ($another) = $smcFunc['db_fetch_row']($request);
577 592
 		$smcFunc['db_free_result']($request);
578 593
 
579
-		if (empty($another))
580
-			fatal_lang_error('at_least_one_admin', 'critical');
594
+		if (empty($another)) {
595
+					fatal_lang_error('at_least_one_admin', 'critical');
596
+		}
581 597
 	}
582 598
 
583 599
 	// This file is needed for the deleteMembers function.
@@ -656,8 +672,9 @@  discard block
 block discarded – undo
656 672
 					)
657 673
 				);
658 674
 				$topicIDs = array();
659
-				while ($row = $smcFunc['db_fetch_assoc']($request))
660
-					$topicIDs[] = $row['id_topic'];
675
+				while ($row = $smcFunc['db_fetch_assoc']($request)) {
676
+									$topicIDs[] = $row['id_topic'];
677
+				}
661 678
 				$smcFunc['db_free_result']($request);
662 679
 
663 680
 				// Actually remove the topics. Ignore recycling if we want to perma-delete things...
@@ -680,8 +697,9 @@  discard block
 block discarded – undo
680 697
 			// This could take a while... but ya know it's gonna be worth it in the end.
681 698
 			while ($row = $smcFunc['db_fetch_assoc']($request))
682 699
 			{
683
-				if (function_exists('apache_reset_timeout'))
684
-					@apache_reset_timeout();
700
+				if (function_exists('apache_reset_timeout')) {
701
+									@apache_reset_timeout();
702
+				}
685 703
 
686 704
 				removeMessage($row['id_msg']);
687 705
 			}
@@ -689,8 +707,9 @@  discard block
 block discarded – undo
689 707
 		}
690 708
 
691 709
 		// Only delete this poor members account if they are actually being booted out of camp.
692
-		if (isset($_POST['deleteAccount']))
693
-			deleteMembers($memID);
710
+		if (isset($_POST['deleteAccount'])) {
711
+					deleteMembers($memID);
712
+		}
694 713
 	}
695 714
 	// Do they need approval to delete?
696 715
 	elseif (!empty($modSettings['approveAccountDeletion']) && !allowedTo('moderate_forum'))
@@ -741,18 +760,18 @@  discard block
 block discarded – undo
741 760
 		{
742 761
 			foreach ($costs as $duration => $cost)
743 762
 			{
744
-				if ($cost != 0)
745
-					$cost_array[$duration] = $cost;
763
+				if ($cost != 0) {
764
+									$cost_array[$duration] = $cost;
765
+				}
746 766
 			}
747
-		}
748
-		else
767
+		} else
749 768
 		{
750 769
 			$cost_array['fixed'] = $costs['fixed'];
751 770
 		}
752 771
 
753
-		if (empty($cost_array))
754
-			unset($context['subscriptions'][$id]);
755
-		else
772
+		if (empty($cost_array)) {
773
+					unset($context['subscriptions'][$id]);
774
+		} else
756 775
 		{
757 776
 			$context['subscriptions'][$id]['member'] = 0;
758 777
 			$context['subscriptions'][$id]['subscribed'] = false;
@@ -765,13 +784,15 @@  discard block
 block discarded – undo
765 784
 	foreach ($gateways as $id => $gateway)
766 785
 	{
767 786
 		$gateways[$id] = new $gateway['display_class']();
768
-		if (!$gateways[$id]->gatewayEnabled())
769
-			unset($gateways[$id]);
787
+		if (!$gateways[$id]->gatewayEnabled()) {
788
+					unset($gateways[$id]);
789
+		}
770 790
 	}
771 791
 
772 792
 	// No gateways yet?
773
-	if (empty($gateways))
774
-		fatal_error($txt['paid_admin_not_setup_gateway']);
793
+	if (empty($gateways)) {
794
+			fatal_error($txt['paid_admin_not_setup_gateway']);
795
+	}
775 796
 
776 797
 	// Get the current subscriptions.
777 798
 	$request = $smcFunc['db_query']('', '
@@ -786,8 +807,9 @@  discard block
 block discarded – undo
786 807
 	while ($row = $smcFunc['db_fetch_assoc']($request))
787 808
 	{
788 809
 		// The subscription must exist!
789
-		if (!isset($context['subscriptions'][$row['id_subscribe']]))
790
-			continue;
810
+		if (!isset($context['subscriptions'][$row['id_subscribe']])) {
811
+					continue;
812
+		}
791 813
 
792 814
 		$context['current'][$row['id_subscribe']] = array(
793 815
 			'id' => $row['id_sublog'],
@@ -801,8 +823,9 @@  discard block
 block discarded – undo
801 823
 			'status_text' => $row['status'] == 0 ? ($row['payments_pending'] ? $txt['paid_pending'] : $txt['paid_finished']) : $txt['paid_active'],
802 824
 		);
803 825
 
804
-		if ($row['status'] == 1)
805
-			$context['subscriptions'][$row['id_subscribe']]['subscribed'] = true;
826
+		if ($row['status'] == 1) {
827
+					$context['subscriptions'][$row['id_subscribe']]['subscribed'] = true;
828
+		}
806 829
 	}
807 830
 	$smcFunc['db_free_result']($request);
808 831
 
@@ -853,21 +876,25 @@  discard block
 block discarded – undo
853 876
 	if (isset($_GET['confirm']) && isset($_POST['sub_id']) && is_array($_POST['sub_id']))
854 877
 	{
855 878
 		// Hopefully just one.
856
-		foreach ($_POST['sub_id'] as $k => $v)
857
-			$ID_SUB = (int) $k;
879
+		foreach ($_POST['sub_id'] as $k => $v) {
880
+					$ID_SUB = (int) $k;
881
+		}
858 882
 
859
-		if (!isset($context['subscriptions'][$ID_SUB]) || $context['subscriptions'][$ID_SUB]['active'] == 0)
860
-			fatal_lang_error('paid_sub_not_active');
883
+		if (!isset($context['subscriptions'][$ID_SUB]) || $context['subscriptions'][$ID_SUB]['active'] == 0) {
884
+					fatal_lang_error('paid_sub_not_active');
885
+		}
861 886
 
862 887
 		// Simplify...
863 888
 		$context['sub'] = $context['subscriptions'][$ID_SUB];
864 889
 		$period = 'xx';
865
-		if ($context['sub']['flexible'])
866
-			$period = isset($_POST['cur'][$ID_SUB]) && isset($context['sub']['costs'][$_POST['cur'][$ID_SUB]]) ? $_POST['cur'][$ID_SUB] : 'xx';
890
+		if ($context['sub']['flexible']) {
891
+					$period = isset($_POST['cur'][$ID_SUB]) && isset($context['sub']['costs'][$_POST['cur'][$ID_SUB]]) ? $_POST['cur'][$ID_SUB] : 'xx';
892
+		}
867 893
 
868 894
 		// Check we have a valid cost.
869
-		if ($context['sub']['flexible'] && $period == 'xx')
870
-			fatal_lang_error('paid_sub_not_active');
895
+		if ($context['sub']['flexible'] && $period == 'xx') {
896
+					fatal_lang_error('paid_sub_not_active');
897
+		}
871 898
 
872 899
 		// Sort out the cost/currency.
873 900
 		$context['currency'] = $modSettings['paid_currency_code'];
@@ -880,8 +907,7 @@  discard block
 block discarded – undo
880 907
 			$context['cost'] = sprintf($modSettings['paid_currency_symbol'], $context['value']) . '/' . $txt[$_POST['cur'][$ID_SUB]];
881 908
 			// The period value for paypal.
882 909
 			$context['paypal_period'] = strtoupper(substr($_POST['cur'][$ID_SUB], 0, 1));
883
-		}
884
-		else
910
+		} else
885 911
 		{
886 912
 			// Real cost...
887 913
 			$context['value'] = $context['sub']['costs']['fixed'];
@@ -898,13 +924,15 @@  discard block
 block discarded – undo
898 924
 		foreach ($gateways as $id => $gateway)
899 925
 		{
900 926
 			$fields = $gateways[$id]->fetchGatewayFields($context['sub']['id'] . '+' . $memID, $context['sub'], $context['value'], $period, $scripturl . '?action=profile;u=' . $memID . ';area=subscriptions;sub_id=' . $context['sub']['id'] . ';done');
901
-			if (!empty($fields['form']))
902
-				$context['gateways'][] = $fields;
927
+			if (!empty($fields['form'])) {
928
+							$context['gateways'][] = $fields;
929
+			}
903 930
 		}
904 931
 
905 932
 		// Bugger?!
906
-		if (empty($context['gateways']))
907
-			fatal_error($txt['paid_admin_not_setup_gateway']);
933
+		if (empty($context['gateways'])) {
934
+					fatal_error($txt['paid_admin_not_setup_gateway']);
935
+		}
908 936
 
909 937
 		// Now we are going to assume they want to take this out ;)
910 938
 		$new_data = array($context['sub']['id'], $context['value'], $period, 'prepay');
@@ -912,16 +940,19 @@  discard block
 block discarded – undo
912 940
 		{
913 941
 			// What are the details like?
914 942
 			$current_pending = array();
915
-			if ($context['current'][$context['sub']['id']]['pending_details'] != '')
916
-				$current_pending = $smcFunc['json_decode']($context['current'][$context['sub']['id']]['pending_details'], true);
943
+			if ($context['current'][$context['sub']['id']]['pending_details'] != '') {
944
+							$current_pending = $smcFunc['json_decode']($context['current'][$context['sub']['id']]['pending_details'], true);
945
+			}
917 946
 			// Don't get silly.
918
-			if (count($current_pending) > 9)
919
-				$current_pending = array();
947
+			if (count($current_pending) > 9) {
948
+							$current_pending = array();
949
+			}
920 950
 			$pending_count = 0;
921 951
 			// Only record real pending payments as will otherwise confuse the admin!
922
-			foreach ($current_pending as $pending)
923
-				if ($pending[3] == 'payback')
952
+			foreach ($current_pending as $pending) {
953
+							if ($pending[3] == 'payback')
924 954
 					$pending_count++;
955
+			}
925 956
 
926 957
 			if (!in_array($new_data, $current_pending))
927 958
 			{
@@ -966,9 +997,9 @@  discard block
 block discarded – undo
966 997
 
967 998
 		// Quit.
968 999
 		return;
1000
+	} else {
1001
+			$context['sub_template'] = 'user_subscription';
1002
+	}
969 1003
 	}
970
-	else
971
-		$context['sub_template'] = 'user_subscription';
972
-}
973 1004
 
974 1005
 ?>
975 1006
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/Subs.php 2 patches
Spacing   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 			{
387 387
 				$val = 'CASE ';
388 388
 				foreach ($members as $k => $v)
389
-					$val .= 'WHEN id_member = ' . $v . ' THEN '. count(fetch_alerts($v, false, 0, array(), false)) . ' ';
389
+					$val .= 'WHEN id_member = ' . $v . ' THEN ' . count(fetch_alerts($v, false, 0, array(), false)) . ' ';
390 390
 				$val = $val . ' END';
391 391
 				$type = 'raw';
392 392
 			}
@@ -817,7 +817,7 @@  discard block
 block discarded – undo
817 817
 			$unsupportedFormats = (array) cache_get_data('unsupportedtimeformats', 86400);
818 818
 		if (empty($unsupportedFormats))
819 819
 		{
820
-			foreach($strftimeFormatSubstitutions as $format => $substitution)
820
+			foreach ($strftimeFormatSubstitutions as $format => $substitution)
821 821
 			{
822 822
 				$value = @strftime('%' . $format);
823 823
 
@@ -1182,7 +1182,7 @@  discard block
 block discarded – undo
1182 1182
 					'height' => array('optional' => true, 'match' => '(\d+)'),
1183 1183
 				),
1184 1184
 				'content' => '$1',
1185
-				'validate' => function (&$tag, &$data, $disabled, $params) use ($modSettings, $context, $sourcedir, $txt)
1185
+				'validate' => function(&$tag, &$data, $disabled, $params) use ($modSettings, $context, $sourcedir, $txt)
1186 1186
 				{
1187 1187
 					$returnContext = '';
1188 1188
 
@@ -1217,7 +1217,7 @@  discard block
 block discarded – undo
1217 1217
 						}
1218 1218
 
1219 1219
 						if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}']))
1220
-							$returnContext .= '<a href="'. $currentAttachment['href']. ';image" id="link_'. $currentAttachment['id']. '" onclick="'. $currentAttachment['thumbnail']['javascript']. '"><img src="'. $currentAttachment['thumbnail']['href']. '"' . $alt . $title . ' id="thumb_'. $currentAttachment['id']. '" class="atc_img"></a>';
1220
+							$returnContext .= '<a href="' . $currentAttachment['href'] . ';image" id="link_' . $currentAttachment['id'] . '" onclick="' . $currentAttachment['thumbnail']['javascript'] . '"><img src="' . $currentAttachment['thumbnail']['href'] . '"' . $alt . $title . ' id="thumb_' . $currentAttachment['id'] . '" class="atc_img"></a>';
1221 1221
 						else
1222 1222
 							$returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>';
1223 1223
 					}
@@ -1246,7 +1246,7 @@  discard block
 block discarded – undo
1246 1246
 				'type' => 'unparsed_content',
1247 1247
 				'content' => '<div class="codeheader"><span class="code floatleft">' . $txt['code'] . '</span> <a class="codeoperation smf_select_text">' . $txt['code_select'] . '</a></div><code class="bbc_code">$1</code>',
1248 1248
 				// @todo Maybe this can be simplified?
1249
-				'validate' => isset($disabled['code']) ? null : function (&$tag, &$data, $disabled) use ($context)
1249
+				'validate' => isset($disabled['code']) ? null : function(&$tag, &$data, $disabled) use ($context)
1250 1250
 				{
1251 1251
 					if (!isset($disabled['code']))
1252 1252
 					{
@@ -1283,7 +1283,7 @@  discard block
 block discarded – undo
1283 1283
 				'type' => 'unparsed_equals_content',
1284 1284
 				'content' => '<div class="codeheader"><span class="code floatleft">' . $txt['code'] . '</span> ($2) <a class="codeoperation smf_select_text">' . $txt['code_select'] . '</a></div><code class="bbc_code">$1</code>',
1285 1285
 				// @todo Maybe this can be simplified?
1286
-				'validate' => isset($disabled['code']) ? null : function (&$tag, &$data, $disabled) use ($context)
1286
+				'validate' => isset($disabled['code']) ? null : function(&$tag, &$data, $disabled) use ($context)
1287 1287
 				{
1288 1288
 					if (!isset($disabled['code']))
1289 1289
 					{
@@ -1327,7 +1327,7 @@  discard block
 block discarded – undo
1327 1327
 				'type' => 'unparsed_content',
1328 1328
 				'content' => '<a href="mailto:$1" class="bbc_email">$1</a>',
1329 1329
 				// @todo Should this respect guest_hideContacts?
1330
-				'validate' => function (&$tag, &$data, $disabled)
1330
+				'validate' => function(&$tag, &$data, $disabled)
1331 1331
 				{
1332 1332
 					$data = strtr($data, array('<br>' => ''));
1333 1333
 				},
@@ -1346,7 +1346,7 @@  discard block
 block discarded – undo
1346 1346
 				'type' => 'unparsed_commas_content',
1347 1347
 				'test' => '\d+,\d+\]',
1348 1348
 				'content' => '<embed type="application/x-shockwave-flash" src="$1" width="$2" height="$3" play="true" loop="true" quality="high" AllowScriptAccess="never">',
1349
-				'validate' => function (&$tag, &$data, $disabled)
1349
+				'validate' => function(&$tag, &$data, $disabled)
1350 1350
 				{
1351 1351
 					if (isset($disabled['url']))
1352 1352
 						$tag['content'] = '$1';
@@ -1362,7 +1362,7 @@  discard block
 block discarded – undo
1362 1362
 				'test' => '(left|right)(\s+max=\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)?\]',
1363 1363
 				'before' => '<div $1>',
1364 1364
 				'after' => '</div>',
1365
-				'validate' => function (&$tag, &$data, $disabled)
1365
+				'validate' => function(&$tag, &$data, $disabled)
1366 1366
 				{
1367 1367
 					$class = 'class="bbc_float float' . (strpos($data, 'left') === 0 ? 'left' : 'right') . '"';
1368 1368
 
@@ -1411,7 +1411,7 @@  discard block
 block discarded – undo
1411 1411
 					'height' => array('optional' => true, 'value' => ' height="$1"', 'match' => '(\d+)'),
1412 1412
 				),
1413 1413
 				'content' => '<img src="$1" alt="{alt}" title="{title}"{width}{height} class="bbc_img resized">',
1414
-				'validate' => function (&$tag, &$data, $disabled)
1414
+				'validate' => function(&$tag, &$data, $disabled)
1415 1415
 				{
1416 1416
 					global $image_proxy_enabled, $image_proxy_secret, $boardurl;
1417 1417
 
@@ -1434,7 +1434,7 @@  discard block
 block discarded – undo
1434 1434
 				'tag' => 'img',
1435 1435
 				'type' => 'unparsed_content',
1436 1436
 				'content' => '<img src="$1" alt="" class="bbc_img">',
1437
-				'validate' => function (&$tag, &$data, $disabled)
1437
+				'validate' => function(&$tag, &$data, $disabled)
1438 1438
 				{
1439 1439
 					global $image_proxy_enabled, $image_proxy_secret, $boardurl;
1440 1440
 
@@ -1457,7 +1457,7 @@  discard block
 block discarded – undo
1457 1457
 				'tag' => 'iurl',
1458 1458
 				'type' => 'unparsed_content',
1459 1459
 				'content' => '<a href="$1" class="bbc_link">$1</a>',
1460
-				'validate' => function (&$tag, &$data, $disabled)
1460
+				'validate' => function(&$tag, &$data, $disabled)
1461 1461
 				{
1462 1462
 					$data = strtr($data, array('<br>' => ''));
1463 1463
 					$scheme = parse_url($data, PHP_URL_SCHEME);
@@ -1471,7 +1471,7 @@  discard block
 block discarded – undo
1471 1471
 				'quoted' => 'optional',
1472 1472
 				'before' => '<a href="$1" class="bbc_link">',
1473 1473
 				'after' => '</a>',
1474
-				'validate' => function (&$tag, &$data, $disabled)
1474
+				'validate' => function(&$tag, &$data, $disabled)
1475 1475
 				{
1476 1476
 					if (substr($data, 0, 1) == '#')
1477 1477
 						$data = '#post_' . substr($data, 1);
@@ -1551,7 +1551,7 @@  discard block
 block discarded – undo
1551 1551
 				'tag' => 'php',
1552 1552
 				'type' => 'unparsed_content',
1553 1553
 				'content' => '<span class="phpcode">$1</span>',
1554
-				'validate' => isset($disabled['php']) ? null : function (&$tag, &$data, $disabled)
1554
+				'validate' => isset($disabled['php']) ? null : function(&$tag, &$data, $disabled)
1555 1555
 				{
1556 1556
 					if (!isset($disabled['php']))
1557 1557
 					{
@@ -1649,7 +1649,7 @@  discard block
 block discarded – undo
1649 1649
 				'test' => '[1-7]\]',
1650 1650
 				'before' => '<span style="font-size: $1;" class="bbc_size">',
1651 1651
 				'after' => '</span>',
1652
-				'validate' => function (&$tag, &$data, $disabled)
1652
+				'validate' => function(&$tag, &$data, $disabled)
1653 1653
 				{
1654 1654
 					$sizes = array(1 => 0.7, 2 => 1.0, 3 => 1.35, 4 => 1.45, 5 => 2.0, 6 => 2.65, 7 => 3.95);
1655 1655
 					$data = $sizes[$data] . 'em';
@@ -1687,7 +1687,7 @@  discard block
 block discarded – undo
1687 1687
 				'tag' => 'time',
1688 1688
 				'type' => 'unparsed_content',
1689 1689
 				'content' => '$1',
1690
-				'validate' => function (&$tag, &$data, $disabled)
1690
+				'validate' => function(&$tag, &$data, $disabled)
1691 1691
 				{
1692 1692
 					if (is_numeric($data))
1693 1693
 						$data = timeformat($data);
@@ -1715,7 +1715,7 @@  discard block
 block discarded – undo
1715 1715
 				'tag' => 'url',
1716 1716
 				'type' => 'unparsed_content',
1717 1717
 				'content' => '<a href="$1" class="bbc_link" target="_blank" rel="noopener">$1</a>',
1718
-				'validate' => function (&$tag, &$data, $disabled)
1718
+				'validate' => function(&$tag, &$data, $disabled)
1719 1719
 				{
1720 1720
 					$data = strtr($data, array('<br>' => ''));
1721 1721
 					$scheme = parse_url($data, PHP_URL_SCHEME);
@@ -1729,7 +1729,7 @@  discard block
 block discarded – undo
1729 1729
 				'quoted' => 'optional',
1730 1730
 				'before' => '<a href="$1" class="bbc_link" target="_blank" rel="noopener">',
1731 1731
 				'after' => '</a>',
1732
-				'validate' => function (&$tag, &$data, $disabled)
1732
+				'validate' => function(&$tag, &$data, $disabled)
1733 1733
 				{
1734 1734
 					$scheme = parse_url($data, PHP_URL_SCHEME);
1735 1735
 					if (empty($scheme))
@@ -1755,7 +1755,7 @@  discard block
 block discarded – undo
1755 1755
 		{
1756 1756
 			if (isset($temp_bbc))
1757 1757
 				$bbc_codes = $temp_bbc;
1758
-			usort($codes, function ($a, $b) {
1758
+			usort($codes, function($a, $b) {
1759 1759
 				return strcmp($a['tag'], $b['tag']);
1760 1760
 			});
1761 1761
 			return $codes;
@@ -1992,7 +1992,7 @@  discard block
 block discarded – undo
1992 1992
 										# a run of Unicode domain name characters and a dot
1993 1993
 										[\p{L}\p{M}\p{N}\-.:@]+\.
1994 1994
 										# and then a TLD valid in the DNS or the reserved "local" TLD
1995
-										(?:'. $modSettings['tld_regex'] .'|local)
1995
+										(?:'. $modSettings['tld_regex'] . '|local)
1996 1996
 									)
1997 1997
 									# followed by a non-domain character or end of line
1998 1998
 									(?=[^\p{L}\p{N}\-.]|$)
@@ -2060,7 +2060,7 @@  discard block
 block discarded – undo
2060 2060
 						)?
2061 2061
 						';
2062 2062
 
2063
-						$data = preg_replace_callback('~' . $url_regex . '~xi' . ($context['utf8'] ? 'u' : ''), function ($matches) {
2063
+						$data = preg_replace_callback('~' . $url_regex . '~xi' . ($context['utf8'] ? 'u' : ''), function($matches) {
2064 2064
 							$url = array_shift($matches);
2065 2065
 
2066 2066
 							$scheme = parse_url($url, PHP_URL_SCHEME);
@@ -2800,7 +2800,7 @@  discard block
 block discarded – undo
2800 2800
 		for ($i = 0, $n = count($smileysfrom); $i < $n; $i++)
2801 2801
 		{
2802 2802
 			$specialChars = $smcFunc['htmlspecialchars']($smileysfrom[$i], ENT_QUOTES);
2803
-			$smileyCode = '<img src="' . $smileys_path . $smileysto[$i] . '" alt="' . strtr($specialChars, array(':' => '&#58;', '(' => '&#40;', ')' => '&#41;', '$' => '&#36;', '[' => '&#091;')). '" title="' . strtr($smcFunc['htmlspecialchars']($smileysdescs[$i]), array(':' => '&#58;', '(' => '&#40;', ')' => '&#41;', '$' => '&#36;', '[' => '&#091;')) . '" class="smiley">';
2803
+			$smileyCode = '<img src="' . $smileys_path . $smileysto[$i] . '" alt="' . strtr($specialChars, array(':' => '&#58;', '(' => '&#40;', ')' => '&#41;', '$' => '&#36;', '[' => '&#091;')) . '" title="' . strtr($smcFunc['htmlspecialchars']($smileysdescs[$i]), array(':' => '&#58;', '(' => '&#40;', ')' => '&#41;', '$' => '&#36;', '[' => '&#091;')) . '" class="smiley">';
2804 2804
 
2805 2805
 			$smileyPregReplacements[$smileysfrom[$i]] = $smileyCode;
2806 2806
 
@@ -2817,7 +2817,7 @@  discard block
 block discarded – undo
2817 2817
 
2818 2818
 	// Replace away!
2819 2819
 	$message = preg_replace_callback($smileyPregSearch,
2820
-		function ($matches) use ($smileyPregReplacements)
2820
+		function($matches) use ($smileyPregReplacements)
2821 2821
 		{
2822 2822
 			return $smileyPregReplacements[$matches[1]];
2823 2823
 		}, $message);
@@ -2883,13 +2883,13 @@  discard block
 block discarded – undo
2883 2883
 	{
2884 2884
 		if (defined('SID') && SID != '')
2885 2885
 			$setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&amp;))((?:board|topic)=[^#]+?)(#[^"]*?)?$~',
2886
-				function ($m) use ($scripturl)
2886
+				function($m) use ($scripturl)
2887 2887
 				{
2888
-					return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : "");
2888
+					return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID . (isset($m[2]) ? "$m[2]" : "");
2889 2889
 				}, $setLocation);
2890 2890
 		else
2891 2891
 			$setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~',
2892
-				function ($m) use ($scripturl)
2892
+				function($m) use ($scripturl)
2893 2893
 				{
2894 2894
 					return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : "");
2895 2895
 				}, $setLocation);
@@ -3212,7 +3212,7 @@  discard block
 block discarded – undo
3212 3212
 
3213 3213
 	// Add a generic "Are you sure?" confirmation message.
3214 3214
 	addInlineJavaScript('
3215
-	var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';');
3215
+	var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) . ';');
3216 3216
 
3217 3217
 	// Now add the capping code for avatars.
3218 3218
 	if (!empty($modSettings['avatar_max_width_external']) && !empty($modSettings['avatar_max_height_external']) && !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_css_resize')
@@ -3573,7 +3573,7 @@  discard block
 block discarded – undo
3573 3573
 
3574 3574
 		else
3575 3575
 			echo '
3576
-	<script src="', $settings['theme_url'] ,'/scripts/minified', ($do_deferred ? '_deferred' : '') ,'.js', $minSeed ,'"></script>';
3576
+	<script src="', $settings['theme_url'], '/scripts/minified', ($do_deferred ? '_deferred' : ''), '.js', $minSeed, '"></script>';
3577 3577
 	}
3578 3578
 
3579 3579
 	// Inline JavaScript - Actually useful some times!
@@ -3651,14 +3651,14 @@  discard block
 block discarded – undo
3651 3651
 
3652 3652
 		else
3653 3653
 			echo '
3654
-	<link rel="stylesheet" href="', $settings['theme_url'] ,'/css/minified.css', $minSeed ,'">';
3654
+	<link rel="stylesheet" href="', $settings['theme_url'], '/css/minified.css', $minSeed, '">';
3655 3655
 	}
3656 3656
 
3657 3657
 	// Print the rest after the minified files.
3658 3658
 	if (!empty($normal))
3659 3659
 		foreach ($normal as $nf)
3660 3660
 			echo '
3661
-	<link rel="stylesheet" href="', $nf ,'">';
3661
+	<link rel="stylesheet" href="', $nf, '">';
3662 3662
 
3663 3663
 	if ($db_show_debug === true)
3664 3664
 	{
@@ -3674,7 +3674,7 @@  discard block
 block discarded – undo
3674 3674
 	<style>';
3675 3675
 
3676 3676
 		foreach ($context['css_header'] as $css)
3677
-			echo $css .'
3677
+			echo $css . '
3678 3678
 	';
3679 3679
 
3680 3680
 		echo'
@@ -3703,27 +3703,27 @@  discard block
 block discarded – undo
3703 3703
 		return false;
3704 3704
 
3705 3705
 	// Did we already did this?
3706
-	$toCache = cache_get_data('minimized_'. $settings['theme_id'] .'_'. $type, 86400);
3706
+	$toCache = cache_get_data('minimized_' . $settings['theme_id'] . '_' . $type, 86400);
3707 3707
 
3708 3708
 	// Already done?
3709 3709
 	if (!empty($toCache))
3710 3710
 		return true;
3711 3711
 
3712 3712
 	// No namespaces, sorry!
3713
-	$classType = 'MatthiasMullie\\Minify\\'. strtoupper($type);
3713
+	$classType = 'MatthiasMullie\\Minify\\' . strtoupper($type);
3714 3714
 
3715 3715
 	// Temp path.
3716
-	$cTempPath = $settings['theme_dir'] .'/'. ($type == 'css' ? 'css' : 'scripts') .'/';
3716
+	$cTempPath = $settings['theme_dir'] . '/' . ($type == 'css' ? 'css' : 'scripts') . '/';
3717 3717
 
3718 3718
 	// What kind of file are we going to create?
3719
-	$toCreate = $cTempPath .'minified'. ($do_deferred ? '_deferred' : '') .'.'. $type;
3719
+	$toCreate = $cTempPath . 'minified' . ($do_deferred ? '_deferred' : '') . '.' . $type;
3720 3720
 
3721 3721
 	// File has to exists, if it isn't try to create it.
3722 3722
 	if ((!file_exists($toCreate) && @fopen($toCreate, 'w') === false) || !smf_chmod($toCreate))
3723 3723
 	{
3724 3724
 		loadLanguage('Errors');
3725 3725
 		log_error(sprintf($txt['file_not_created'], $toCreate), 'general');
3726
-		cache_put_data('minimized_'. $settings['theme_id'] .'_'. $type, null);
3726
+		cache_put_data('minimized_' . $settings['theme_id'] . '_' . $type, null);
3727 3727
 
3728 3728
 		// The process failed so roll back to print each individual file.
3729 3729
 		return $data;
@@ -3758,14 +3758,14 @@  discard block
 block discarded – undo
3758 3758
 	{
3759 3759
 		loadLanguage('Errors');
3760 3760
 		log_error(sprintf($txt['file_not_created'], $toCreate), 'general');
3761
-		cache_put_data('minimized_'. $settings['theme_id'] .'_'. $type, null);
3761
+		cache_put_data('minimized_' . $settings['theme_id'] . '_' . $type, null);
3762 3762
 
3763 3763
 		// The process failed so roll back to print each individual file.
3764 3764
 		return $data;
3765 3765
 	}
3766 3766
 
3767 3767
 	// And create a long lived cache entry.
3768
-	cache_put_data('minimized_'. $settings['theme_id'] .'_'. $type, $toCreate, 86400);
3768
+	cache_put_data('minimized_' . $settings['theme_id'] . '_' . $type, $toCreate, 86400);
3769 3769
 
3770 3770
 	return true;
3771 3771
 }
@@ -3825,7 +3825,7 @@  discard block
 block discarded – undo
3825 3825
 	else
3826 3826
 		$path = $modSettings['attachmentUploadDir'];
3827 3827
 
3828
-	return $path . '/' . $attachment_id . '_' . $file_hash .'.dat';
3828
+	return $path . '/' . $attachment_id . '_' . $file_hash . '.dat';
3829 3829
 }
3830 3830
 
3831 3831
 /**
@@ -3869,10 +3869,10 @@  discard block
 block discarded – undo
3869 3869
 		$valid_low = isValidIP($ip_parts[0]);
3870 3870
 		$valid_high = isValidIP($ip_parts[1]);
3871 3871
 		$count = 0;
3872
-		$mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.');
3872
+		$mode = (preg_match('/:/', $ip_parts[0]) > 0 ? ':' : '.');
3873 3873
 		$max = ($mode == ':' ? 'ffff' : '255');
3874 3874
 		$min = 0;
3875
-		if(!$valid_low)
3875
+		if (!$valid_low)
3876 3876
 		{
3877 3877
 			$ip_parts[0] = preg_replace('/\*/', '0', $ip_parts[0]);
3878 3878
 			$valid_low = isValidIP($ip_parts[0]);
@@ -3886,7 +3886,7 @@  discard block
 block discarded – undo
3886 3886
 		}
3887 3887
 
3888 3888
 		$count = 0;
3889
-		if(!$valid_high)
3889
+		if (!$valid_high)
3890 3890
 		{
3891 3891
 			$ip_parts[1] = preg_replace('/\*/', $max, $ip_parts[1]);
3892 3892
 			$valid_high = isValidIP($ip_parts[1]);
@@ -3899,7 +3899,7 @@  discard block
 block discarded – undo
3899 3899
 			}
3900 3900
 		}
3901 3901
 
3902
-		if($valid_high && $valid_low)
3902
+		if ($valid_high && $valid_low)
3903 3903
 		{
3904 3904
 			$ip_array['low'] = $ip_parts[0];
3905 3905
 			$ip_array['high'] = $ip_parts[1];
@@ -4081,7 +4081,7 @@  discard block
 block discarded – undo
4081 4081
 		addInlineJavaScript('
4082 4082
 	var user_menus = new smc_PopupMenu();
4083 4083
 	user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup");
4084
-	user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true);
4084
+	user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u=' . $context['user']['id'] . '");', true);
4085 4085
 		if ($context['allow_pm'])
4086 4086
 			addInlineJavaScript('
4087 4087
 	user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true);
@@ -4701,7 +4701,7 @@  discard block
 block discarded – undo
4701 4701
 		// No? try a fallback to $sourcedir
4702 4702
 		else
4703 4703
 		{
4704
-			$absPath = $sourcedir .'/'. $file;
4704
+			$absPath = $sourcedir . '/' . $file;
4705 4705
 
4706 4706
 			if (file_exists($absPath))
4707 4707
 				require_once($absPath);
@@ -4782,15 +4782,15 @@  discard block
 block discarded – undo
4782 4782
 
4783 4783
 	// UTF-8 occurences of MS special characters
4784 4784
 	$findchars_utf8 = array(
4785
-		"\xe2\x80\x9a",	// single low-9 quotation mark
4786
-		"\xe2\x80\x9e",	// double low-9 quotation mark
4787
-		"\xe2\x80\xa6",	// horizontal ellipsis
4788
-		"\xe2\x80\x98",	// left single curly quote
4789
-		"\xe2\x80\x99",	// right single curly quote
4790
-		"\xe2\x80\x9c",	// left double curly quote
4791
-		"\xe2\x80\x9d",	// right double curly quote
4792
-		"\xe2\x80\x93",	// en dash
4793
-		"\xe2\x80\x94",	// em dash
4785
+		"\xe2\x80\x9a", // single low-9 quotation mark
4786
+		"\xe2\x80\x9e", // double low-9 quotation mark
4787
+		"\xe2\x80\xa6", // horizontal ellipsis
4788
+		"\xe2\x80\x98", // left single curly quote
4789
+		"\xe2\x80\x99", // right single curly quote
4790
+		"\xe2\x80\x9c", // left double curly quote
4791
+		"\xe2\x80\x9d", // right double curly quote
4792
+		"\xe2\x80\x93", // en dash
4793
+		"\xe2\x80\x94", // em dash
4794 4794
 	);
4795 4795
 
4796 4796
 	// windows 1252 / iso equivalents
@@ -4808,15 +4808,15 @@  discard block
 block discarded – undo
4808 4808
 
4809 4809
 	// safe replacements
4810 4810
 	$replacechars = array(
4811
-		',',	// &sbquo;
4812
-		',,',	// &bdquo;
4813
-		'...',	// &hellip;
4814
-		"'",	// &lsquo;
4815
-		"'",	// &rsquo;
4816
-		'"',	// &ldquo;
4817
-		'"',	// &rdquo;
4818
-		'-',	// &ndash;
4819
-		'--',	// &mdash;
4811
+		',', // &sbquo;
4812
+		',,', // &bdquo;
4813
+		'...', // &hellip;
4814
+		"'", // &lsquo;
4815
+		"'", // &rsquo;
4816
+		'"', // &ldquo;
4817
+		'"', // &rdquo;
4818
+		'-', // &ndash;
4819
+		'--', // &mdash;
4820 4820
 	);
4821 4821
 
4822 4822
 	if ($context['utf8'])
@@ -5234,7 +5234,7 @@  discard block
 block discarded – undo
5234 5234
  */
5235 5235
 function inet_dtop($bin)
5236 5236
 {
5237
-	if(empty($bin))
5237
+	if (empty($bin))
5238 5238
 		return '';
5239 5239
 
5240 5240
 	global $db_type;
@@ -5265,28 +5265,28 @@  discard block
 block discarded – undo
5265 5265
  */
5266 5266
 function _safe_serialize($value)
5267 5267
 {
5268
-	if(is_null($value))
5268
+	if (is_null($value))
5269 5269
 		return 'N;';
5270 5270
 
5271
-	if(is_bool($value))
5272
-		return 'b:'. (int) $value .';';
5271
+	if (is_bool($value))
5272
+		return 'b:' . (int) $value . ';';
5273 5273
 
5274
-	if(is_int($value))
5275
-		return 'i:'. $value .';';
5274
+	if (is_int($value))
5275
+		return 'i:' . $value . ';';
5276 5276
 
5277
-	if(is_float($value))
5278
-		return 'd:'. str_replace(',', '.', $value) .';';
5277
+	if (is_float($value))
5278
+		return 'd:' . str_replace(',', '.', $value) . ';';
5279 5279
 
5280
-	if(is_string($value))
5281
-		return 's:'. strlen($value) .':"'. $value .'";';
5280
+	if (is_string($value))
5281
+		return 's:' . strlen($value) . ':"' . $value . '";';
5282 5282
 
5283
-	if(is_array($value))
5283
+	if (is_array($value))
5284 5284
 	{
5285 5285
 		$out = '';
5286
-		foreach($value as $k => $v)
5286
+		foreach ($value as $k => $v)
5287 5287
 			$out .= _safe_serialize($k) . _safe_serialize($v);
5288 5288
 
5289
-		return 'a:'. count($value) .':{'. $out .'}';
5289
+		return 'a:' . count($value) . ':{' . $out . '}';
5290 5290
 	}
5291 5291
 
5292 5292
 	// safe_serialize cannot serialize resources or objects.
@@ -5328,7 +5328,7 @@  discard block
 block discarded – undo
5328 5328
 function _safe_unserialize($str)
5329 5329
 {
5330 5330
 	// Input  is not a string.
5331
-	if(empty($str) || !is_string($str))
5331
+	if (empty($str) || !is_string($str))
5332 5332
 		return false;
5333 5333
 
5334 5334
 	$stack = array();
@@ -5342,40 +5342,40 @@  discard block
 block discarded – undo
5342 5342
 	 *   3 - in array, expecting value or another array
5343 5343
 	 */
5344 5344
 	$state = 0;
5345
-	while($state != 1)
5345
+	while ($state != 1)
5346 5346
 	{
5347 5347
 		$type = isset($str[0]) ? $str[0] : '';
5348
-		if($type == '}')
5348
+		if ($type == '}')
5349 5349
 			$str = substr($str, 1);
5350 5350
 
5351
-		else if($type == 'N' && $str[1] == ';')
5351
+		else if ($type == 'N' && $str[1] == ';')
5352 5352
 		{
5353 5353
 			$value = null;
5354 5354
 			$str = substr($str, 2);
5355 5355
 		}
5356
-		else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches))
5356
+		else if ($type == 'b' && preg_match('/^b:([01]);/', $str, $matches))
5357 5357
 		{
5358 5358
 			$value = $matches[1] == '1' ? true : false;
5359 5359
 			$str = substr($str, 4);
5360 5360
 		}
5361
-		else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches))
5361
+		else if ($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches))
5362 5362
 		{
5363
-			$value = (int)$matches[1];
5363
+			$value = (int) $matches[1];
5364 5364
 			$str = $matches[2];
5365 5365
 		}
5366
-		else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches))
5366
+		else if ($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches))
5367 5367
 		{
5368
-			$value = (float)$matches[1];
5368
+			$value = (float) $matches[1];
5369 5369
 			$str = $matches[3];
5370 5370
 		}
5371
-		else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";')
5371
+		else if ($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int) $matches[1], 2) == '";')
5372 5372
 		{
5373
-			$value = substr($matches[2], 0, (int)$matches[1]);
5374
-			$str = substr($matches[2], (int)$matches[1] + 2);
5373
+			$value = substr($matches[2], 0, (int) $matches[1]);
5374
+			$str = substr($matches[2], (int) $matches[1] + 2);
5375 5375
 		}
5376
-		else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches))
5376
+		else if ($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches))
5377 5377
 		{
5378
-			$expectedLength = (int)$matches[1];
5378
+			$expectedLength = (int) $matches[1];
5379 5379
 			$str = $matches[2];
5380 5380
 		}
5381 5381
 
@@ -5383,10 +5383,10 @@  discard block
 block discarded – undo
5383 5383
 		else
5384 5384
 			return false;
5385 5385
 
5386
-		switch($state)
5386
+		switch ($state)
5387 5387
 		{
5388 5388
 			case 3: // In array, expecting value or another array.
5389
-				if($type == 'a')
5389
+				if ($type == 'a')
5390 5390
 				{
5391 5391
 					$stack[] = &$list;
5392 5392
 					$list[$key] = array();
@@ -5395,7 +5395,7 @@  discard block
 block discarded – undo
5395 5395
 					$state = 2;
5396 5396
 					break;
5397 5397
 				}
5398
-				if($type != '}')
5398
+				if ($type != '}')
5399 5399
 				{
5400 5400
 					$list[$key] = $value;
5401 5401
 					$state = 2;
@@ -5406,29 +5406,29 @@  discard block
 block discarded – undo
5406 5406
 				return false;
5407 5407
 
5408 5408
 			case 2: // in array, expecting end of array or a key
5409
-				if($type == '}')
5409
+				if ($type == '}')
5410 5410
 				{
5411 5411
 					// Array size is less than expected.
5412
-					if(count($list) < end($expected))
5412
+					if (count($list) < end($expected))
5413 5413
 						return false;
5414 5414
 
5415 5415
 					unset($list);
5416
-					$list = &$stack[count($stack)-1];
5416
+					$list = &$stack[count($stack) - 1];
5417 5417
 					array_pop($stack);
5418 5418
 
5419 5419
 					// Go to terminal state if we're at the end of the root array.
5420 5420
 					array_pop($expected);
5421 5421
 
5422
-					if(count($expected) == 0)
5422
+					if (count($expected) == 0)
5423 5423
 						$state = 1;
5424 5424
 
5425 5425
 					break;
5426 5426
 				}
5427 5427
 
5428
-				if($type == 'i' || $type == 's')
5428
+				if ($type == 'i' || $type == 's')
5429 5429
 				{
5430 5430
 					// Array size exceeds expected length.
5431
-					if(count($list) >= end($expected))
5431
+					if (count($list) >= end($expected))
5432 5432
 						return false;
5433 5433
 
5434 5434
 					$key = $value;
@@ -5441,7 +5441,7 @@  discard block
 block discarded – undo
5441 5441
 
5442 5442
 			// Expecting array or value.
5443 5443
 			case 0:
5444
-				if($type == 'a')
5444
+				if ($type == 'a')
5445 5445
 				{
5446 5446
 					$data = array();
5447 5447
 					$list = &$data;
@@ -5450,7 +5450,7 @@  discard block
 block discarded – undo
5450 5450
 					break;
5451 5451
 				}
5452 5452
 
5453
-				if($type != '}')
5453
+				if ($type != '}')
5454 5454
 				{
5455 5455
 					$data = $value;
5456 5456
 					$state = 1;
@@ -5463,7 +5463,7 @@  discard block
 block discarded – undo
5463 5463
 	}
5464 5464
 
5465 5465
 	// Trailing data in input.
5466
-	if(!empty($str))
5466
+	if (!empty($str))
5467 5467
 		return false;
5468 5468
 
5469 5469
 	return $data;
@@ -5517,7 +5517,7 @@  discard block
 block discarded – undo
5517 5517
 	// Set different modes.
5518 5518
 	$chmodValues = $isDir ? array(0750, 0755, 0775, 0777) : array(0644, 0664, 0666);
5519 5519
 
5520
-	foreach($chmodValues as $val)
5520
+	foreach ($chmodValues as $val)
5521 5521
 	{
5522 5522
 		// If it's writable, break out of the loop.
5523 5523
 		if (is_writable($file))
@@ -5552,13 +5552,13 @@  discard block
 block discarded – undo
5552 5552
 	$returnArray = @json_decode($json, $returnAsArray);
5553 5553
 
5554 5554
 	// PHP 5.3 so no json_last_error_msg()
5555
-	switch(json_last_error())
5555
+	switch (json_last_error())
5556 5556
 	{
5557 5557
 		case JSON_ERROR_NONE:
5558 5558
 			$jsonError = false;
5559 5559
 			break;
5560 5560
 		case JSON_ERROR_DEPTH:
5561
-			$jsonError =  'JSON_ERROR_DEPTH';
5561
+			$jsonError = 'JSON_ERROR_DEPTH';
5562 5562
 			break;
5563 5563
 		case JSON_ERROR_STATE_MISMATCH:
5564 5564
 			$jsonError = 'JSON_ERROR_STATE_MISMATCH';
@@ -5586,10 +5586,10 @@  discard block
 block discarded – undo
5586 5586
 		loadLanguage('Errors');
5587 5587
 
5588 5588
 		if (!empty($jsonDebug))
5589
-			log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']);
5589
+			log_error($txt['json_' . $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']);
5590 5590
 
5591 5591
 		else
5592
-			log_error($txt['json_'. $jsonError], 'critical');
5592
+			log_error($txt['json_' . $jsonError], 'critical');
5593 5593
 
5594 5594
 		// Everyone expects an array.
5595 5595
 		return array();
@@ -5701,7 +5701,7 @@  discard block
 block discarded – undo
5701 5701
 		});
5702 5702
 
5703 5703
 		// Convert Punycode to Unicode
5704
-		$tlds = array_map(function ($input) {
5704
+		$tlds = array_map(function($input) {
5705 5705
 			$prefix = 'xn--';
5706 5706
 			$safe_char = 0xFFFC;
5707 5707
 			$base = 36;
@@ -5717,7 +5717,7 @@  discard block
 block discarded – undo
5717 5717
 
5718 5718
 			foreach ($enco_parts as $encoded)
5719 5719
 			{
5720
-				if (strpos($encoded,$prefix) !== 0 || strlen(trim(str_replace($prefix,'',$encoded))) == 0)
5720
+				if (strpos($encoded, $prefix) !== 0 || strlen(trim(str_replace($prefix, '', $encoded))) == 0)
5721 5721
 				{
5722 5722
 					$output_parts[] = $encoded;
5723 5723
 					continue;
@@ -5728,7 +5728,7 @@  discard block
 block discarded – undo
5728 5728
 				$idx = 0;
5729 5729
 				$char = 0x80;
5730 5730
 				$decoded = array();
5731
-				$output='';
5731
+				$output = '';
5732 5732
 				$delim_pos = strrpos($encoded, '-');
5733 5733
 
5734 5734
 				if ($delim_pos > strlen($prefix))
@@ -5744,7 +5744,7 @@  discard block
 block discarded – undo
5744 5744
 
5745 5745
 				for ($enco_idx = $delim_pos ? ($delim_pos + 1) : 0; $enco_idx < $enco_len; ++$deco_len)
5746 5746
 				{
5747
-					for ($old_idx = $idx, $w = 1, $k = $base; 1 ; $k += $base)
5747
+					for ($old_idx = $idx, $w = 1, $k = $base; 1; $k += $base)
5748 5748
 					{
5749 5749
 						$cp = ord($encoded{$enco_idx++});
5750 5750
 						$digit = ($cp - 48 < 10) ? $cp - 22 : (($cp - 65 < 26) ? $cp - 65 : (($cp - 97 < 26) ? $cp - 97 : $base));
@@ -5785,15 +5785,15 @@  discard block
 block discarded – undo
5785 5785
 
5786 5786
 					// 2 bytes
5787 5787
 					elseif ($v < (1 << 11))
5788
-						$output .= chr(192+($v >> 6)) . chr(128+($v & 63));
5788
+						$output .= chr(192 + ($v >> 6)) . chr(128 + ($v & 63));
5789 5789
 
5790 5790
 					// 3 bytes
5791 5791
 					elseif ($v < (1 << 16))
5792
-						$output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63));
5792
+						$output .= chr(224 + ($v >> 12)) . chr(128 + (($v >> 6) & 63)) . chr(128 + ($v & 63));
5793 5793
 
5794 5794
 					// 4 bytes
5795 5795
 					elseif ($v < (1 << 21))
5796
-						$output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63));
5796
+						$output .= chr(240 + ($v >> 18)) . chr(128 + (($v >> 12) & 63)) . chr(128 + (($v >> 6) & 63)) . chr(128 + ($v & 63));
5797 5797
 
5798 5798
 					//  'Conversion from UCS-4 to UTF-8 failed: malformed input at byte '.$k
5799 5799
 					else
@@ -5898,7 +5898,7 @@  discard block
 block discarded – undo
5898 5898
 	}
5899 5899
 
5900 5900
 	// This recursive function creates the index array from the strings
5901
-	$add_string_to_index = function ($string, $index) use (&$strlen, &$substr, &$add_string_to_index)
5901
+	$add_string_to_index = function($string, $index) use (&$strlen, &$substr, &$add_string_to_index)
5902 5902
 	{
5903 5903
 		static $depth = 0;
5904 5904
 		$depth++;
@@ -5925,7 +5925,7 @@  discard block
 block discarded – undo
5925 5925
 	};
5926 5926
 
5927 5927
 	// This recursive function turns the index array into a regular expression
5928
-	$index_to_regex = function (&$index, $delim) use (&$strlen, &$index_to_regex)
5928
+	$index_to_regex = function(&$index, $delim) use (&$strlen, &$index_to_regex)
5929 5929
 	{
5930 5930
 		static $depth = 0;
5931 5931
 		$depth++;
@@ -5949,11 +5949,11 @@  discard block
 block discarded – undo
5949 5949
 
5950 5950
 				if (count(array_keys($value)) == 1)
5951 5951
 				{
5952
-					$new_key_array = explode('(?'.'>', $sub_regex);
5952
+					$new_key_array = explode('(?' . '>', $sub_regex);
5953 5953
 					$new_key .= $new_key_array[0];
5954 5954
 				}
5955 5955
 				else
5956
-					$sub_regex = '(?'.'>' . $sub_regex . ')';
5956
+					$sub_regex = '(?' . '>' . $sub_regex . ')';
5957 5957
 			}
5958 5958
 
5959 5959
 			if ($depth > 1)
@@ -5996,10 +5996,10 @@  discard block
 block discarded – undo
5996 5996
 	{
5997 5997
 		$regex = array();
5998 5998
 		while (!empty($index))
5999
-			$regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')';
5999
+			$regex[] = '(?' . '>' . $index_to_regex($index, $delim) . ')';
6000 6000
 	}
6001 6001
 	else
6002
-		$regex = '(?'.'>' . $index_to_regex($index, $delim) . ')';
6002
+		$regex = '(?' . '>' . $index_to_regex($index, $delim) . ')';
6003 6003
 
6004 6004
 	// Restore PHP's internal character encoding to whatever it was originally
6005 6005
 	if (!empty($current_encoding))
Please login to merge, or discard this patch.
Braces   +1345 added lines, -1001 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
  * Update some basic statistics.
@@ -122,10 +123,11 @@  discard block
 block discarded – undo
122 123
 						$smcFunc['db_free_result']($result);
123 124
 
124 125
 						// Add this to the number of unapproved members
125
-						if (!empty($changes['unapprovedMembers']))
126
-							$changes['unapprovedMembers'] += $coppa_approvals;
127
-						else
128
-							$changes['unapprovedMembers'] = $coppa_approvals;
126
+						if (!empty($changes['unapprovedMembers'])) {
127
+													$changes['unapprovedMembers'] += $coppa_approvals;
128
+						} else {
129
+													$changes['unapprovedMembers'] = $coppa_approvals;
130
+						}
129 131
 					}
130 132
 				}
131 133
 			}
@@ -133,9 +135,9 @@  discard block
 block discarded – undo
133 135
 			break;
134 136
 
135 137
 		case 'message':
136
-			if ($parameter1 === true && $parameter2 !== null)
137
-				updateSettings(array('totalMessages' => true, 'maxMsgID' => $parameter2), true);
138
-			else
138
+			if ($parameter1 === true && $parameter2 !== null) {
139
+							updateSettings(array('totalMessages' => true, 'maxMsgID' => $parameter2), true);
140
+			} else
139 141
 			{
140 142
 				// SUM and MAX on a smaller table is better for InnoDB tables.
141 143
 				$result = $smcFunc['db_query']('', '
@@ -175,23 +177,25 @@  discard block
 block discarded – undo
175 177
 				$parameter2 = text2words($parameter2);
176 178
 
177 179
 				$inserts = array();
178
-				foreach ($parameter2 as $word)
179
-					$inserts[] = array($word, $parameter1);
180
+				foreach ($parameter2 as $word) {
181
+									$inserts[] = array($word, $parameter1);
182
+				}
180 183
 
181
-				if (!empty($inserts))
182
-					$smcFunc['db_insert']('ignore',
184
+				if (!empty($inserts)) {
185
+									$smcFunc['db_insert']('ignore',
183 186
 						'{db_prefix}log_search_subjects',
184 187
 						array('word' => 'string', 'id_topic' => 'int'),
185 188
 						$inserts,
186 189
 						array('word', 'id_topic')
187 190
 					);
191
+				}
188 192
 			}
189 193
 			break;
190 194
 
191 195
 		case 'topic':
192
-			if ($parameter1 === true)
193
-				updateSettings(array('totalTopics' => true), true);
194
-			else
196
+			if ($parameter1 === true) {
197
+							updateSettings(array('totalTopics' => true), true);
198
+			} else
195 199
 			{
196 200
 				// Get the number of topics - a SUM is better for InnoDB tables.
197 201
 				// We also ignore the recycle bin here because there will probably be a bunch of one-post topics there.
@@ -212,8 +216,9 @@  discard block
 block discarded – undo
212 216
 
213 217
 		case 'postgroups':
214 218
 			// Parameter two is the updated columns: we should check to see if we base groups off any of these.
215
-			if ($parameter2 !== null && !in_array('posts', $parameter2))
216
-				return;
219
+			if ($parameter2 !== null && !in_array('posts', $parameter2)) {
220
+							return;
221
+			}
217 222
 
218 223
 			$postgroups = cache_get_data('updateStats:postgroups', 360);
219 224
 			if ($postgroups == null || $parameter1 == null)
@@ -228,8 +233,9 @@  discard block
 block discarded – undo
228 233
 					)
229 234
 				);
230 235
 				$postgroups = array();
231
-				while ($row = $smcFunc['db_fetch_assoc']($request))
232
-					$postgroups[$row['id_group']] = $row['min_posts'];
236
+				while ($row = $smcFunc['db_fetch_assoc']($request)) {
237
+									$postgroups[$row['id_group']] = $row['min_posts'];
238
+				}
233 239
 				$smcFunc['db_free_result']($request);
234 240
 
235 241
 				// Sort them this way because if it's done with MySQL it causes a filesort :(.
@@ -239,8 +245,9 @@  discard block
 block discarded – undo
239 245
 			}
240 246
 
241 247
 			// Oh great, they've screwed their post groups.
242
-			if (empty($postgroups))
243
-				return;
248
+			if (empty($postgroups)) {
249
+							return;
250
+			}
244 251
 
245 252
 			// Set all membergroups from most posts to least posts.
246 253
 			$conditions = '';
@@ -298,10 +305,9 @@  discard block
 block discarded – undo
298 305
 	{
299 306
 		$condition = 'id_member IN ({array_int:members})';
300 307
 		$parameters['members'] = $members;
301
-	}
302
-	elseif ($members === null)
303
-		$condition = '1=1';
304
-	else
308
+	} elseif ($members === null) {
309
+			$condition = '1=1';
310
+	} else
305 311
 	{
306 312
 		$condition = 'id_member = {int:member}';
307 313
 		$parameters['member'] = $members;
@@ -341,9 +347,9 @@  discard block
 block discarded – undo
341 347
 		if (count($vars_to_integrate) != 0)
342 348
 		{
343 349
 			// Fetch a list of member_names if necessary
344
-			if ((!is_array($members) && $members === $user_info['id']) || (is_array($members) && count($members) == 1 && in_array($user_info['id'], $members)))
345
-				$member_names = array($user_info['username']);
346
-			else
350
+			if ((!is_array($members) && $members === $user_info['id']) || (is_array($members) && count($members) == 1 && in_array($user_info['id'], $members))) {
351
+							$member_names = array($user_info['username']);
352
+			} else
347 353
 			{
348 354
 				$member_names = array();
349 355
 				$request = $smcFunc['db_query']('', '
@@ -352,14 +358,16 @@  discard block
 block discarded – undo
352 358
 					WHERE ' . $condition,
353 359
 					$parameters
354 360
 				);
355
-				while ($row = $smcFunc['db_fetch_assoc']($request))
356
-					$member_names[] = $row['member_name'];
361
+				while ($row = $smcFunc['db_fetch_assoc']($request)) {
362
+									$member_names[] = $row['member_name'];
363
+				}
357 364
 				$smcFunc['db_free_result']($request);
358 365
 			}
359 366
 
360
-			if (!empty($member_names))
361
-				foreach ($vars_to_integrate as $var)
367
+			if (!empty($member_names)) {
368
+							foreach ($vars_to_integrate as $var)
362 369
 					call_integration_hook('integrate_change_member_data', array($member_names, $var, &$data[$var], &$knownInts, &$knownFloats));
370
+			}
363 371
 		}
364 372
 	}
365 373
 
@@ -367,16 +375,17 @@  discard block
 block discarded – undo
367 375
 	foreach ($data as $var => $val)
368 376
 	{
369 377
 		$type = 'string';
370
-		if (in_array($var, $knownInts))
371
-			$type = 'int';
372
-		elseif (in_array($var, $knownFloats))
373
-			$type = 'float';
374
-		elseif ($var == 'birthdate')
375
-			$type = 'date';
376
-		elseif ($var == 'member_ip')
377
-			$type = 'inet';
378
-		elseif ($var == 'member_ip2')
379
-			$type = 'inet';
378
+		if (in_array($var, $knownInts)) {
379
+					$type = 'int';
380
+		} elseif (in_array($var, $knownFloats)) {
381
+					$type = 'float';
382
+		} elseif ($var == 'birthdate') {
383
+					$type = 'date';
384
+		} elseif ($var == 'member_ip') {
385
+					$type = 'inet';
386
+		} elseif ($var == 'member_ip2') {
387
+					$type = 'inet';
388
+		}
380 389
 
381 390
 		// Doing an increment?
382 391
 		if ($var == 'alerts' && ($val === '+' || $val === '-'))
@@ -385,18 +394,17 @@  discard block
 block discarded – undo
385 394
 			if (is_array($members))
386 395
 			{
387 396
 				$val = 'CASE ';
388
-				foreach ($members as $k => $v)
389
-					$val .= 'WHEN id_member = ' . $v . ' THEN '. count(fetch_alerts($v, false, 0, array(), false)) . ' ';
397
+				foreach ($members as $k => $v) {
398
+									$val .= 'WHEN id_member = ' . $v . ' THEN '. count(fetch_alerts($v, false, 0, array(), false)) . ' ';
399
+				}
390 400
 				$val = $val . ' END';
391 401
 				$type = 'raw';
392
-			}
393
-			else
402
+			} else
394 403
 			{
395 404
 				$blub = fetch_alerts($members, false, 0, array(), false);
396 405
 				$val = count($blub);
397 406
 			}
398
-		}
399
-		else if ($type == 'int' && ($val === '+' || $val === '-'))
407
+		} else if ($type == 'int' && ($val === '+' || $val === '-'))
400 408
 		{
401 409
 			$val = $var . ' ' . $val . ' 1';
402 410
 			$type = 'raw';
@@ -407,8 +415,9 @@  discard block
 block discarded – undo
407 415
 		{
408 416
 			if (preg_match('~^' . $var . ' (\+ |- |\+ -)([\d]+)~', $val, $match))
409 417
 			{
410
-				if ($match[1] != '+ ')
411
-					$val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END';
418
+				if ($match[1] != '+ ') {
419
+									$val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END';
420
+				}
412 421
 				$type = 'raw';
413 422
 			}
414 423
 		}
@@ -429,8 +438,9 @@  discard block
 block discarded – undo
429 438
 	// Clear any caching?
430 439
 	if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && !empty($members))
431 440
 	{
432
-		if (!is_array($members))
433
-			$members = array($members);
441
+		if (!is_array($members)) {
442
+					$members = array($members);
443
+		}
434 444
 
435 445
 		foreach ($members as $member)
436 446
 		{
@@ -463,29 +473,32 @@  discard block
 block discarded – undo
463 473
 {
464 474
 	global $modSettings, $smcFunc;
465 475
 
466
-	if (empty($changeArray) || !is_array($changeArray))
467
-		return;
476
+	if (empty($changeArray) || !is_array($changeArray)) {
477
+			return;
478
+	}
468 479
 
469 480
 	$toRemove = array();
470 481
 
471 482
 	// Go check if there is any setting to be removed.
472
-	foreach ($changeArray as $k => $v)
473
-		if ($v === null)
483
+	foreach ($changeArray as $k => $v) {
484
+			if ($v === null)
474 485
 		{
475 486
 			// Found some, remove them from the original array and add them to ours.
476 487
 			unset($changeArray[$k]);
488
+	}
477 489
 			$toRemove[] = $k;
478 490
 		}
479 491
 
480 492
 	// Proceed with the deletion.
481
-	if (!empty($toRemove))
482
-		$smcFunc['db_query']('', '
493
+	if (!empty($toRemove)) {
494
+			$smcFunc['db_query']('', '
483 495
 			DELETE FROM {db_prefix}settings
484 496
 			WHERE variable IN ({array_string:remove})',
485 497
 			array(
486 498
 				'remove' => $toRemove,
487 499
 			)
488 500
 		);
501
+	}
489 502
 
490 503
 	// In some cases, this may be better and faster, but for large sets we don't want so many UPDATEs.
491 504
 	if ($update)
@@ -514,19 +527,22 @@  discard block
 block discarded – undo
514 527
 	foreach ($changeArray as $variable => $value)
515 528
 	{
516 529
 		// Don't bother if it's already like that ;).
517
-		if (isset($modSettings[$variable]) && $modSettings[$variable] == $value)
518
-			continue;
530
+		if (isset($modSettings[$variable]) && $modSettings[$variable] == $value) {
531
+					continue;
532
+		}
519 533
 		// If the variable isn't set, but would only be set to nothing'ness, then don't bother setting it.
520
-		elseif (!isset($modSettings[$variable]) && empty($value))
521
-			continue;
534
+		elseif (!isset($modSettings[$variable]) && empty($value)) {
535
+					continue;
536
+		}
522 537
 
523 538
 		$replaceArray[] = array($variable, $value);
524 539
 
525 540
 		$modSettings[$variable] = $value;
526 541
 	}
527 542
 
528
-	if (empty($replaceArray))
529
-		return;
543
+	if (empty($replaceArray)) {
544
+			return;
545
+	}
530 546
 
531 547
 	$smcFunc['db_insert']('replace',
532 548
 		'{db_prefix}settings',
@@ -572,14 +588,17 @@  discard block
 block discarded – undo
572 588
 	$start_invalid = $start < 0;
573 589
 
574 590
 	// Make sure $start is a proper variable - not less than 0.
575
-	if ($start_invalid)
576
-		$start = 0;
591
+	if ($start_invalid) {
592
+			$start = 0;
593
+	}
577 594
 	// Not greater than the upper bound.
578
-	elseif ($start >= $max_value)
579
-		$start = max(0, (int) $max_value - (((int) $max_value % (int) $num_per_page) == 0 ? $num_per_page : ((int) $max_value % (int) $num_per_page)));
595
+	elseif ($start >= $max_value) {
596
+			$start = max(0, (int) $max_value - (((int) $max_value % (int) $num_per_page) == 0 ? $num_per_page : ((int) $max_value % (int) $num_per_page)));
597
+	}
580 598
 	// And it has to be a multiple of $num_per_page!
581
-	else
582
-		$start = max(0, (int) $start - ((int) $start % (int) $num_per_page));
599
+	else {
600
+			$start = max(0, (int) $start - ((int) $start % (int) $num_per_page));
601
+	}
583 602
 
584 603
 	$context['current_page'] = $start / $num_per_page;
585 604
 
@@ -609,77 +628,87 @@  discard block
 block discarded – undo
609 628
 
610 629
 		// Show all the pages.
611 630
 		$display_page = 1;
612
-		for ($counter = 0; $counter < $max_value; $counter += $num_per_page)
613
-			$pageindex .= $start == $counter && !$start_invalid ? sprintf($settings['page_index']['current_page'], $display_page++) : sprintf($base_link, $counter, $display_page++);
631
+		for ($counter = 0; $counter < $max_value; $counter += $num_per_page) {
632
+					$pageindex .= $start == $counter && !$start_invalid ? sprintf($settings['page_index']['current_page'], $display_page++) : sprintf($base_link, $counter, $display_page++);
633
+		}
614 634
 
615 635
 		// Show the right arrow.
616 636
 		$display_page = ($start + $num_per_page) > $max_value ? $max_value : ($start + $num_per_page);
617
-		if ($start != $counter - $max_value && !$start_invalid)
618
-			$pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link, $display_page, $settings['page_index']['next_page']);
619
-	}
620
-	else
637
+		if ($start != $counter - $max_value && !$start_invalid) {
638
+					$pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link, $display_page, $settings['page_index']['next_page']);
639
+		}
640
+	} else
621 641
 	{
622 642
 		// If they didn't enter an odd value, pretend they did.
623 643
 		$PageContiguous = (int) ($modSettings['compactTopicPagesContiguous'] - ($modSettings['compactTopicPagesContiguous'] % 2)) / 2;
624 644
 
625 645
 		// Show the "prev page" link. (>prev page< 1 ... 6 7 [8] 9 10 ... 15 next page)
626
-		if (!empty($start) && $show_prevnext)
627
-			$pageindex .= sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']);
628
-		else
629
-			$pageindex .= '';
646
+		if (!empty($start) && $show_prevnext) {
647
+					$pageindex .= sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']);
648
+		} else {
649
+					$pageindex .= '';
650
+		}
630 651
 
631 652
 		// Show the first page. (prev page >1< ... 6 7 [8] 9 10 ... 15)
632
-		if ($start > $num_per_page * $PageContiguous)
633
-			$pageindex .= sprintf($base_link, 0, '1');
653
+		if ($start > $num_per_page * $PageContiguous) {
654
+					$pageindex .= sprintf($base_link, 0, '1');
655
+		}
634 656
 
635 657
 		// Show the ... after the first page.  (prev page 1 >...< 6 7 [8] 9 10 ... 15 next page)
636
-		if ($start > $num_per_page * ($PageContiguous + 1))
637
-			$pageindex .= strtr($settings['page_index']['expand_pages'], array(
658
+		if ($start > $num_per_page * ($PageContiguous + 1)) {
659
+					$pageindex .= strtr($settings['page_index']['expand_pages'], array(
638 660
 				'{LINK}' => JavaScriptEscape($smcFunc['htmlspecialchars']($base_link)),
639 661
 				'{FIRST_PAGE}' => $num_per_page,
640 662
 				'{LAST_PAGE}' => $start - $num_per_page * $PageContiguous,
641 663
 				'{PER_PAGE}' => $num_per_page,
642 664
 			));
665
+		}
643 666
 
644 667
 		// Show the pages before the current one. (prev page 1 ... >6 7< [8] 9 10 ... 15 next page)
645
-		for ($nCont = $PageContiguous; $nCont >= 1; $nCont--)
646
-			if ($start >= $num_per_page * $nCont)
668
+		for ($nCont = $PageContiguous; $nCont >= 1; $nCont--) {
669
+					if ($start >= $num_per_page * $nCont)
647 670
 			{
648 671
 				$tmpStart = $start - $num_per_page * $nCont;
672
+		}
649 673
 				$pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1);
650 674
 			}
651 675
 
652 676
 		// Show the current page. (prev page 1 ... 6 7 >[8]< 9 10 ... 15 next page)
653
-		if (!$start_invalid)
654
-			$pageindex .= sprintf($settings['page_index']['current_page'], $start / $num_per_page + 1);
655
-		else
656
-			$pageindex .= sprintf($base_link, $start, $start / $num_per_page + 1);
677
+		if (!$start_invalid) {
678
+					$pageindex .= sprintf($settings['page_index']['current_page'], $start / $num_per_page + 1);
679
+		} else {
680
+					$pageindex .= sprintf($base_link, $start, $start / $num_per_page + 1);
681
+		}
657 682
 
658 683
 		// Show the pages after the current one... (prev page 1 ... 6 7 [8] >9 10< ... 15 next page)
659 684
 		$tmpMaxPages = (int) (($max_value - 1) / $num_per_page) * $num_per_page;
660
-		for ($nCont = 1; $nCont <= $PageContiguous; $nCont++)
661
-			if ($start + $num_per_page * $nCont <= $tmpMaxPages)
685
+		for ($nCont = 1; $nCont <= $PageContiguous; $nCont++) {
686
+					if ($start + $num_per_page * $nCont <= $tmpMaxPages)
662 687
 			{
663 688
 				$tmpStart = $start + $num_per_page * $nCont;
689
+		}
664 690
 				$pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1);
665 691
 			}
666 692
 
667 693
 		// Show the '...' part near the end. (prev page 1 ... 6 7 [8] 9 10 >...< 15 next page)
668
-		if ($start + $num_per_page * ($PageContiguous + 1) < $tmpMaxPages)
669
-			$pageindex .= strtr($settings['page_index']['expand_pages'], array(
694
+		if ($start + $num_per_page * ($PageContiguous + 1) < $tmpMaxPages) {
695
+					$pageindex .= strtr($settings['page_index']['expand_pages'], array(
670 696
 				'{LINK}' => JavaScriptEscape($smcFunc['htmlspecialchars']($base_link)),
671 697
 				'{FIRST_PAGE}' => $start + $num_per_page * ($PageContiguous + 1),
672 698
 				'{LAST_PAGE}' => $tmpMaxPages,
673 699
 				'{PER_PAGE}' => $num_per_page,
674 700
 			));
701
+		}
675 702
 
676 703
 		// Show the last number in the list. (prev page 1 ... 6 7 [8] 9 10 ... >15<  next page)
677
-		if ($start + $num_per_page * $PageContiguous < $tmpMaxPages)
678
-			$pageindex .= sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1);
704
+		if ($start + $num_per_page * $PageContiguous < $tmpMaxPages) {
705
+					$pageindex .= sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1);
706
+		}
679 707
 
680 708
 		// Show the "next page" link. (prev page 1 ... 6 7 [8] 9 10 ... 15 >next page<)
681
-		if ($start != $tmpMaxPages && $show_prevnext)
682
-			$pageindex .= sprintf($base_link, $start + $num_per_page, $settings['page_index']['next_page']);
709
+		if ($start != $tmpMaxPages && $show_prevnext) {
710
+					$pageindex .= sprintf($base_link, $start + $num_per_page, $settings['page_index']['next_page']);
711
+		}
683 712
 	}
684 713
 	$pageindex .= $settings['page_index']['extra_after'];
685 714
 
@@ -705,8 +734,9 @@  discard block
 block discarded – undo
705 734
 	if ($decimal_separator === null)
706 735
 	{
707 736
 		// Not set for whatever reason?
708
-		if (empty($txt['number_format']) || preg_match('~^1([^\d]*)?234([^\d]*)(0*?)$~', $txt['number_format'], $matches) != 1)
709
-			return $number;
737
+		if (empty($txt['number_format']) || preg_match('~^1([^\d]*)?234([^\d]*)(0*?)$~', $txt['number_format'], $matches) != 1) {
738
+					return $number;
739
+		}
710 740
 
711 741
 		// Cache these each load...
712 742
 		$thousands_separator = $matches[1];
@@ -740,17 +770,20 @@  discard block
 block discarded – undo
740 770
 	static $unsupportedFormats, $finalizedFormats;
741 771
 
742 772
 	// Offset the time.
743
-	if (!$offset_type)
744
-		$time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600;
773
+	if (!$offset_type) {
774
+			$time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600;
775
+	}
745 776
 	// Just the forum offset?
746
-	elseif ($offset_type == 'forum')
747
-		$time = $log_time + $modSettings['time_offset'] * 3600;
748
-	else
749
-		$time = $log_time;
777
+	elseif ($offset_type == 'forum') {
778
+			$time = $log_time + $modSettings['time_offset'] * 3600;
779
+	} else {
780
+			$time = $log_time;
781
+	}
750 782
 
751 783
 	// We can't have a negative date (on Windows, at least.)
752
-	if ($log_time < 0)
753
-		$log_time = 0;
784
+	if ($log_time < 0) {
785
+			$log_time = 0;
786
+	}
754 787
 
755 788
 	// Today and Yesterday?
756 789
 	if ($modSettings['todayMod'] >= 1 && $show_today === true)
@@ -767,24 +800,27 @@  discard block
 block discarded – undo
767 800
 		{
768 801
 			$h = strpos($user_info['time_format'], '%l') === false ? '%I' : '%l';
769 802
 			$today_fmt = $h . ':%M' . $s . ' %p';
803
+		} else {
804
+					$today_fmt = '%H:%M' . $s;
770 805
 		}
771
-		else
772
-			$today_fmt = '%H:%M' . $s;
773 806
 
774 807
 		// Same day of the year, same year.... Today!
775
-		if ($then['yday'] == $now['yday'] && $then['year'] == $now['year'])
776
-			return $txt['today'] . timeformat($log_time, $today_fmt, $offset_type);
808
+		if ($then['yday'] == $now['yday'] && $then['year'] == $now['year']) {
809
+					return $txt['today'] . timeformat($log_time, $today_fmt, $offset_type);
810
+		}
777 811
 
778 812
 		// Day-of-year is one less and same year, or it's the first of the year and that's the last of the year...
779
-		if ($modSettings['todayMod'] == '2' && (($then['yday'] == $now['yday'] - 1 && $then['year'] == $now['year']) || ($now['yday'] == 0 && $then['year'] == $now['year'] - 1) && $then['mon'] == 12 && $then['mday'] == 31))
780
-			return $txt['yesterday'] . timeformat($log_time, $today_fmt, $offset_type);
813
+		if ($modSettings['todayMod'] == '2' && (($then['yday'] == $now['yday'] - 1 && $then['year'] == $now['year']) || ($now['yday'] == 0 && $then['year'] == $now['year'] - 1) && $then['mon'] == 12 && $then['mday'] == 31)) {
814
+					return $txt['yesterday'] . timeformat($log_time, $today_fmt, $offset_type);
815
+		}
781 816
 	}
782 817
 
783 818
 	$str = !is_bool($show_today) ? $show_today : $user_info['time_format'];
784 819
 
785 820
 	// Use the cached formats if available
786
-	if (is_null($finalizedFormats))
787
-		$finalizedFormats = (array) cache_get_data('timeformatstrings', 86400);
821
+	if (is_null($finalizedFormats)) {
822
+			$finalizedFormats = (array) cache_get_data('timeformatstrings', 86400);
823
+	}
788 824
 
789 825
 	// Make a supported version for this format if we don't already have one
790 826
 	if (empty($finalizedFormats[$str]))
@@ -813,8 +849,9 @@  discard block
 block discarded – undo
813 849
 		);
814 850
 
815 851
 		// No need to do this part again if we already did it once
816
-		if (is_null($unsupportedFormats))
817
-			$unsupportedFormats = (array) cache_get_data('unsupportedtimeformats', 86400);
852
+		if (is_null($unsupportedFormats)) {
853
+					$unsupportedFormats = (array) cache_get_data('unsupportedtimeformats', 86400);
854
+		}
818 855
 		if (empty($unsupportedFormats))
819 856
 		{
820 857
 			foreach($strftimeFormatSubstitutions as $format => $substitution)
@@ -823,20 +860,23 @@  discard block
 block discarded – undo
823 860
 
824 861
 				// Windows will return false for unsupported formats
825 862
 				// Other operating systems return the format string as a literal
826
-				if ($value === false || $value === $format)
827
-					$unsupportedFormats[] = $format;
863
+				if ($value === false || $value === $format) {
864
+									$unsupportedFormats[] = $format;
865
+				}
828 866
 			}
829 867
 			cache_put_data('unsupportedtimeformats', $unsupportedFormats, 86400);
830 868
 		}
831 869
 
832 870
 		// Windows needs extra help if $timeformat contains something completely invalid, e.g. '%Q'
833
-		if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN')
834
-			$timeformat = preg_replace('~%(?!' . implode('|', array_keys($strftimeFormatSubstitutions)) . ')~', '&#37;', $timeformat);
871
+		if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
872
+					$timeformat = preg_replace('~%(?!' . implode('|', array_keys($strftimeFormatSubstitutions)) . ')~', '&#37;', $timeformat);
873
+		}
835 874
 
836 875
 		// Substitute unsupported formats with supported ones
837
-		if (!empty($unsupportedFormats))
838
-			while (preg_match('~%(' . implode('|', $unsupportedFormats) . ')~', $timeformat, $matches))
876
+		if (!empty($unsupportedFormats)) {
877
+					while (preg_match('~%(' . implode('|', $unsupportedFormats) . ')~', $timeformat, $matches))
839 878
 				$timeformat = str_replace($matches[0], $strftimeFormatSubstitutions[$matches[1]], $timeformat);
879
+		}
840 880
 
841 881
 		// Remember this so we don't need to do it again
842 882
 		$finalizedFormats[$str] = $timeformat;
@@ -845,33 +885,39 @@  discard block
 block discarded – undo
845 885
 
846 886
 	$str = $finalizedFormats[$str];
847 887
 
848
-	if (!isset($locale_cache))
849
-		$locale_cache = setlocale(LC_TIME, $txt['lang_locale']);
888
+	if (!isset($locale_cache)) {
889
+			$locale_cache = setlocale(LC_TIME, $txt['lang_locale']);
890
+	}
850 891
 
851 892
 	if ($locale_cache !== false)
852 893
 	{
853 894
 		// Check if another process changed the locale
854
-		if ($process_safe === true && setlocale(LC_TIME, '0') != $locale_cache)
855
-			setlocale(LC_TIME, $txt['lang_locale']);
895
+		if ($process_safe === true && setlocale(LC_TIME, '0') != $locale_cache) {
896
+					setlocale(LC_TIME, $txt['lang_locale']);
897
+		}
856 898
 
857
-		if (!isset($non_twelve_hour))
858
-			$non_twelve_hour = trim(strftime('%p')) === '';
859
-		if ($non_twelve_hour && strpos($str, '%p') !== false)
860
-			$str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str);
899
+		if (!isset($non_twelve_hour)) {
900
+					$non_twelve_hour = trim(strftime('%p')) === '';
901
+		}
902
+		if ($non_twelve_hour && strpos($str, '%p') !== false) {
903
+					$str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str);
904
+		}
861 905
 
862
-		foreach (array('%a', '%A', '%b', '%B') as $token)
863
-			if (strpos($str, $token) !== false)
906
+		foreach (array('%a', '%A', '%b', '%B') as $token) {
907
+					if (strpos($str, $token) !== false)
864 908
 				$str = str_replace($token, strftime($token, $time), $str);
865
-	}
866
-	else
909
+		}
910
+	} else
867 911
 	{
868 912
 		// Do-it-yourself time localization.  Fun.
869
-		foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label)
870
-			if (strpos($str, $token) !== false)
913
+		foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label) {
914
+					if (strpos($str, $token) !== false)
871 915
 				$str = str_replace($token, $txt[$text_label][(int) strftime($token === '%a' || $token === '%A' ? '%w' : '%m', $time)], $str);
916
+		}
872 917
 
873
-		if (strpos($str, '%p') !== false)
874
-			$str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str);
918
+		if (strpos($str, '%p') !== false) {
919
+					$str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str);
920
+		}
875 921
 	}
876 922
 
877 923
 	// Format the time and then restore any literal percent characters
@@ -894,16 +940,19 @@  discard block
 block discarded – undo
894 940
 	static $translation = array();
895 941
 
896 942
 	// Determine the character set... Default to UTF-8
897
-	if (empty($context['character_set']))
898
-		$charset = 'UTF-8';
943
+	if (empty($context['character_set'])) {
944
+			$charset = 'UTF-8';
945
+	}
899 946
 	// Use ISO-8859-1 in place of non-supported ISO-8859 charsets...
900
-	elseif (strpos($context['character_set'], 'ISO-8859-') !== false && !in_array($context['character_set'], array('ISO-8859-5', 'ISO-8859-15')))
901
-		$charset = 'ISO-8859-1';
902
-	else
903
-		$charset = $context['character_set'];
947
+	elseif (strpos($context['character_set'], 'ISO-8859-') !== false && !in_array($context['character_set'], array('ISO-8859-5', 'ISO-8859-15'))) {
948
+			$charset = 'ISO-8859-1';
949
+	} else {
950
+			$charset = $context['character_set'];
951
+	}
904 952
 
905
-	if (empty($translation))
906
-		$translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES, $charset)) + array('&#039;' => '\'', '&#39;' => '\'', '&nbsp;' => ' ');
953
+	if (empty($translation)) {
954
+			$translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES, $charset)) + array('&#039;' => '\'', '&#39;' => '\'', '&nbsp;' => ' ');
955
+	}
907 956
 
908 957
 	return strtr($string, $translation);
909 958
 }
@@ -925,8 +974,9 @@  discard block
 block discarded – undo
925 974
 	global $smcFunc;
926 975
 
927 976
 	// It was already short enough!
928
-	if ($smcFunc['strlen']($subject) <= $len)
929
-		return $subject;
977
+	if ($smcFunc['strlen']($subject) <= $len) {
978
+			return $subject;
979
+	}
930 980
 
931 981
 	// Shorten it by the length it was too long, and strip off junk from the end.
932 982
 	return $smcFunc['substr']($subject, 0, $len) . '...';
@@ -945,10 +995,11 @@  discard block
 block discarded – undo
945 995
 {
946 996
 	global $user_info, $modSettings;
947 997
 
948
-	if ($timestamp === null)
949
-		$timestamp = time();
950
-	elseif ($timestamp == 0)
951
-		return 0;
998
+	if ($timestamp === null) {
999
+			$timestamp = time();
1000
+	} elseif ($timestamp == 0) {
1001
+			return 0;
1002
+	}
952 1003
 
953 1004
 	return $timestamp + ($modSettings['time_offset'] + ($use_user_offset ? $user_info['time_offset'] : 0)) * 3600;
954 1005
 }
@@ -977,8 +1028,9 @@  discard block
 block discarded – undo
977 1028
 		$array[$i] = $array[$j];
978 1029
 		$array[$j] = $temp;
979 1030
 
980
-		for ($i = 1; $p[$i] == 0; $i++)
981
-			$p[$i] = 1;
1031
+		for ($i = 1; $p[$i] == 0; $i++) {
1032
+					$p[$i] = 1;
1033
+		}
982 1034
 
983 1035
 		$orders[] = $array;
984 1036
 	}
@@ -1010,12 +1062,14 @@  discard block
 block discarded – undo
1010 1062
 	static $disabled;
1011 1063
 
1012 1064
 	// Don't waste cycles
1013
-	if ($message === '')
1014
-		return '';
1065
+	if ($message === '') {
1066
+			return '';
1067
+	}
1015 1068
 
1016 1069
 	// Just in case it wasn't determined yet whether UTF-8 is enabled.
1017
-	if (!isset($context['utf8']))
1018
-		$context['utf8'] = (empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8';
1070
+	if (!isset($context['utf8'])) {
1071
+			$context['utf8'] = (empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8';
1072
+	}
1019 1073
 
1020 1074
 	// Clean up any cut/paste issues we may have
1021 1075
 	$message = sanitizeMSCutPaste($message);
@@ -1027,13 +1081,15 @@  discard block
 block discarded – undo
1027 1081
 		return $message;
1028 1082
 	}
1029 1083
 
1030
-	if ($smileys !== null && ($smileys == '1' || $smileys == '0'))
1031
-		$smileys = (bool) $smileys;
1084
+	if ($smileys !== null && ($smileys == '1' || $smileys == '0')) {
1085
+			$smileys = (bool) $smileys;
1086
+	}
1032 1087
 
1033 1088
 	if (empty($modSettings['enableBBC']) && $message !== false)
1034 1089
 	{
1035
-		if ($smileys === true)
1036
-			parsesmileys($message);
1090
+		if ($smileys === true) {
1091
+					parsesmileys($message);
1092
+		}
1037 1093
 
1038 1094
 		return $message;
1039 1095
 	}
@@ -1046,8 +1102,9 @@  discard block
 block discarded – undo
1046 1102
 	}
1047 1103
 
1048 1104
 	// Ensure $modSettings['tld_regex'] contains a valid regex for the autolinker
1049
-	if (!empty($modSettings['autoLinkUrls']))
1050
-		set_tld_regex();
1105
+	if (!empty($modSettings['autoLinkUrls'])) {
1106
+			set_tld_regex();
1107
+	}
1051 1108
 
1052 1109
 	// Allow mods access before entering the main parse_bbc loop
1053 1110
 	call_integration_hook('integrate_pre_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags));
@@ -1061,12 +1118,14 @@  discard block
 block discarded – undo
1061 1118
 
1062 1119
 			$temp = explode(',', strtolower($modSettings['disabledBBC']));
1063 1120
 
1064
-			foreach ($temp as $tag)
1065
-				$disabled[trim($tag)] = true;
1121
+			foreach ($temp as $tag) {
1122
+							$disabled[trim($tag)] = true;
1123
+			}
1066 1124
 		}
1067 1125
 
1068
-		if (empty($modSettings['enableEmbeddedFlash']))
1069
-			$disabled['flash'] = true;
1126
+		if (empty($modSettings['enableEmbeddedFlash'])) {
1127
+					$disabled['flash'] = true;
1128
+		}
1070 1129
 
1071 1130
 		/* The following bbc are formatted as an array, with keys as follows:
1072 1131
 
@@ -1187,8 +1246,9 @@  discard block
 block discarded – undo
1187 1246
 					$returnContext = '';
1188 1247
 
1189 1248
 					// BBC or the entire attachments feature is disabled
1190
-					if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach']))
1191
-						return $data;
1249
+					if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach'])) {
1250
+											return $data;
1251
+					}
1192 1252
 
1193 1253
 					// Save the attach ID.
1194 1254
 					$attachID = $data;
@@ -1199,8 +1259,9 @@  discard block
 block discarded – undo
1199 1259
 					$currentAttachment = parseAttachBBC($attachID);
1200 1260
 
1201 1261
 					// parseAttachBBC will return a string ($txt key) rather than diying with a fatal_error. Up to you to decide what to do.
1202
-					if (is_string($currentAttachment))
1203
-						return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment;
1262
+					if (is_string($currentAttachment)) {
1263
+											return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment;
1264
+					}
1204 1265
 
1205 1266
 					if (!empty($currentAttachment['is_image']))
1206 1267
 					{
@@ -1216,15 +1277,17 @@  discard block
 block discarded – undo
1216 1277
 							$height = ' height="' . $currentAttachment['height'] . '"';
1217 1278
 						}
1218 1279
 
1219
-						if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}']))
1220
-							$returnContext .= '<a href="'. $currentAttachment['href']. ';image" id="link_'. $currentAttachment['id']. '" onclick="'. $currentAttachment['thumbnail']['javascript']. '"><img src="'. $currentAttachment['thumbnail']['href']. '"' . $alt . $title . ' id="thumb_'. $currentAttachment['id']. '" class="atc_img"></a>';
1221
-						else
1222
-							$returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>';
1280
+						if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) {
1281
+													$returnContext .= '<a href="'. $currentAttachment['href']. ';image" id="link_'. $currentAttachment['id']. '" onclick="'. $currentAttachment['thumbnail']['javascript']. '"><img src="'. $currentAttachment['thumbnail']['href']. '"' . $alt . $title . ' id="thumb_'. $currentAttachment['id']. '" class="atc_img"></a>';
1282
+						} else {
1283
+													$returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>';
1284
+						}
1223 1285
 					}
1224 1286
 
1225 1287
 					// No image. Show a link.
1226
-					else
1227
-						$returnContext .= $currentAttachment['link'];
1288
+					else {
1289
+											$returnContext .= $currentAttachment['link'];
1290
+					}
1228 1291
 
1229 1292
 					// Gotta append what we just did.
1230 1293
 					$data = $returnContext;
@@ -1255,8 +1318,9 @@  discard block
 block discarded – undo
1255 1318
 						for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++)
1256 1319
 						{
1257 1320
 							// Do PHP code coloring?
1258
-							if ($php_parts[$php_i] != '&lt;?php')
1259
-								continue;
1321
+							if ($php_parts[$php_i] != '&lt;?php') {
1322
+															continue;
1323
+							}
1260 1324
 
1261 1325
 							$php_string = '';
1262 1326
 							while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?&gt;')
@@ -1272,8 +1336,9 @@  discard block
 block discarded – undo
1272 1336
 						$data = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data);
1273 1337
 
1274 1338
 						// Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection.
1275
-						if ($context['browser']['is_opera'])
1276
-							$data .= '&nbsp;';
1339
+						if ($context['browser']['is_opera']) {
1340
+													$data .= '&nbsp;';
1341
+						}
1277 1342
 					}
1278 1343
 				},
1279 1344
 				'block_level' => true,
@@ -1292,8 +1357,9 @@  discard block
 block discarded – undo
1292 1357
 						for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++)
1293 1358
 						{
1294 1359
 							// Do PHP code coloring?
1295
-							if ($php_parts[$php_i] != '&lt;?php')
1296
-								continue;
1360
+							if ($php_parts[$php_i] != '&lt;?php') {
1361
+															continue;
1362
+							}
1297 1363
 
1298 1364
 							$php_string = '';
1299 1365
 							while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?&gt;')
@@ -1309,8 +1375,9 @@  discard block
 block discarded – undo
1309 1375
 						$data[0] = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data[0]);
1310 1376
 
1311 1377
 						// Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection.
1312
-						if ($context['browser']['is_opera'])
1313
-							$data[0] .= '&nbsp;';
1378
+						if ($context['browser']['is_opera']) {
1379
+													$data[0] .= '&nbsp;';
1380
+						}
1314 1381
 					}
1315 1382
 				},
1316 1383
 				'block_level' => true,
@@ -1348,11 +1415,13 @@  discard block
 block discarded – undo
1348 1415
 				'content' => '<embed type="application/x-shockwave-flash" src="$1" width="$2" height="$3" play="true" loop="true" quality="high" AllowScriptAccess="never">',
1349 1416
 				'validate' => function (&$tag, &$data, $disabled)
1350 1417
 				{
1351
-					if (isset($disabled['url']))
1352
-						$tag['content'] = '$1';
1418
+					if (isset($disabled['url'])) {
1419
+											$tag['content'] = '$1';
1420
+					}
1353 1421
 					$scheme = parse_url($data[0], PHP_URL_SCHEME);
1354
-					if (empty($scheme))
1355
-						$data[0] = '//' . ltrim($data[0], ':/');
1422
+					if (empty($scheme)) {
1423
+											$data[0] = '//' . ltrim($data[0], ':/');
1424
+					}
1356 1425
 				},
1357 1426
 				'disabled_content' => '<a href="$1" target="_blank" rel="noopener">$1</a>',
1358 1427
 			),
@@ -1366,10 +1435,11 @@  discard block
 block discarded – undo
1366 1435
 				{
1367 1436
 					$class = 'class="bbc_float float' . (strpos($data, 'left') === 0 ? 'left' : 'right') . '"';
1368 1437
 
1369
-					if (preg_match('~\bmax=(\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)~', $data, $matches))
1370
-						$css = ' style="max-width:' . $matches[1] . (is_numeric($matches[1]) ? 'px' : '') . '"';
1371
-					else
1372
-						$css = '';
1438
+					if (preg_match('~\bmax=(\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)~', $data, $matches)) {
1439
+											$css = ' style="max-width:' . $matches[1] . (is_numeric($matches[1]) ? 'px' : '') . '"';
1440
+					} else {
1441
+											$css = '';
1442
+					}
1373 1443
 
1374 1444
 					$data = $class . $css;
1375 1445
 				},
@@ -1419,14 +1489,16 @@  discard block
 block discarded – undo
1419 1489
 					$scheme = parse_url($data, PHP_URL_SCHEME);
1420 1490
 					if ($image_proxy_enabled)
1421 1491
 					{
1422
-						if (empty($scheme))
1423
-							$data = 'http://' . ltrim($data, ':/');
1492
+						if (empty($scheme)) {
1493
+													$data = 'http://' . ltrim($data, ':/');
1494
+						}
1424 1495
 
1425
-						if ($scheme != 'https')
1426
-							$data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret);
1496
+						if ($scheme != 'https') {
1497
+													$data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret);
1498
+						}
1499
+					} elseif (empty($scheme)) {
1500
+											$data = '//' . ltrim($data, ':/');
1427 1501
 					}
1428
-					elseif (empty($scheme))
1429
-						$data = '//' . ltrim($data, ':/');
1430 1502
 				},
1431 1503
 				'disabled_content' => '($1)',
1432 1504
 			),
@@ -1442,14 +1514,16 @@  discard block
 block discarded – undo
1442 1514
 					$scheme = parse_url($data, PHP_URL_SCHEME);
1443 1515
 					if ($image_proxy_enabled)
1444 1516
 					{
1445
-						if (empty($scheme))
1446
-							$data = 'http://' . ltrim($data, ':/');
1517
+						if (empty($scheme)) {
1518
+													$data = 'http://' . ltrim($data, ':/');
1519
+						}
1447 1520
 
1448
-						if ($scheme != 'https')
1449
-							$data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret);
1521
+						if ($scheme != 'https') {
1522
+													$data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret);
1523
+						}
1524
+					} elseif (empty($scheme)) {
1525
+											$data = '//' . ltrim($data, ':/');
1450 1526
 					}
1451
-					elseif (empty($scheme))
1452
-						$data = '//' . ltrim($data, ':/');
1453 1527
 				},
1454 1528
 				'disabled_content' => '($1)',
1455 1529
 			),
@@ -1461,8 +1535,9 @@  discard block
 block discarded – undo
1461 1535
 				{
1462 1536
 					$data = strtr($data, array('<br>' => ''));
1463 1537
 					$scheme = parse_url($data, PHP_URL_SCHEME);
1464
-					if (empty($scheme))
1465
-						$data = '//' . ltrim($data, ':/');
1538
+					if (empty($scheme)) {
1539
+											$data = '//' . ltrim($data, ':/');
1540
+					}
1466 1541
 				},
1467 1542
 			),
1468 1543
 			array(
@@ -1473,13 +1548,14 @@  discard block
 block discarded – undo
1473 1548
 				'after' => '</a>',
1474 1549
 				'validate' => function (&$tag, &$data, $disabled)
1475 1550
 				{
1476
-					if (substr($data, 0, 1) == '#')
1477
-						$data = '#post_' . substr($data, 1);
1478
-					else
1551
+					if (substr($data, 0, 1) == '#') {
1552
+											$data = '#post_' . substr($data, 1);
1553
+					} else
1479 1554
 					{
1480 1555
 						$scheme = parse_url($data, PHP_URL_SCHEME);
1481
-						if (empty($scheme))
1482
-							$data = '//' . ltrim($data, ':/');
1556
+						if (empty($scheme)) {
1557
+													$data = '//' . ltrim($data, ':/');
1558
+						}
1483 1559
 					}
1484 1560
 				},
1485 1561
 				'disallow_children' => array('email', 'ftp', 'url', 'iurl'),
@@ -1557,8 +1633,9 @@  discard block
 block discarded – undo
1557 1633
 					{
1558 1634
 						$add_begin = substr(trim($data), 0, 5) != '&lt;?';
1559 1635
 						$data = highlight_php_code($add_begin ? '&lt;?php ' . $data . '?&gt;' : $data);
1560
-						if ($add_begin)
1561
-							$data = preg_replace(array('~^(.+?)&lt;\?.{0,40}?php(?:&nbsp;|\s)~', '~\?&gt;((?:</(font|span)>)*)$~'), '$1', $data, 2);
1636
+						if ($add_begin) {
1637
+													$data = preg_replace(array('~^(.+?)&lt;\?.{0,40}?php(?:&nbsp;|\s)~', '~\?&gt;((?:</(font|span)>)*)$~'), '$1', $data, 2);
1638
+						}
1562 1639
 					}
1563 1640
 				},
1564 1641
 				'block_level' => false,
@@ -1689,10 +1766,11 @@  discard block
 block discarded – undo
1689 1766
 				'content' => '$1',
1690 1767
 				'validate' => function (&$tag, &$data, $disabled)
1691 1768
 				{
1692
-					if (is_numeric($data))
1693
-						$data = timeformat($data);
1694
-					else
1695
-						$tag['content'] = '[time]$1[/time]';
1769
+					if (is_numeric($data)) {
1770
+											$data = timeformat($data);
1771
+					} else {
1772
+											$tag['content'] = '[time]$1[/time]';
1773
+					}
1696 1774
 				},
1697 1775
 			),
1698 1776
 			array(
@@ -1719,8 +1797,9 @@  discard block
 block discarded – undo
1719 1797
 				{
1720 1798
 					$data = strtr($data, array('<br>' => ''));
1721 1799
 					$scheme = parse_url($data, PHP_URL_SCHEME);
1722
-					if (empty($scheme))
1723
-						$data = '//' . ltrim($data, ':/');
1800
+					if (empty($scheme)) {
1801
+											$data = '//' . ltrim($data, ':/');
1802
+					}
1724 1803
 				},
1725 1804
 			),
1726 1805
 			array(
@@ -1732,8 +1811,9 @@  discard block
 block discarded – undo
1732 1811
 				'validate' => function (&$tag, &$data, $disabled)
1733 1812
 				{
1734 1813
 					$scheme = parse_url($data, PHP_URL_SCHEME);
1735
-					if (empty($scheme))
1736
-						$data = '//' . ltrim($data, ':/');
1814
+					if (empty($scheme)) {
1815
+											$data = '//' . ltrim($data, ':/');
1816
+					}
1737 1817
 				},
1738 1818
 				'disallow_children' => array('email', 'ftp', 'url', 'iurl'),
1739 1819
 				'disabled_after' => ' ($1)',
@@ -1753,8 +1833,9 @@  discard block
 block discarded – undo
1753 1833
 		// This is mainly for the bbc manager, so it's easy to add tags above.  Custom BBC should be added above this line.
1754 1834
 		if ($message === false)
1755 1835
 		{
1756
-			if (isset($temp_bbc))
1757
-				$bbc_codes = $temp_bbc;
1836
+			if (isset($temp_bbc)) {
1837
+							$bbc_codes = $temp_bbc;
1838
+			}
1758 1839
 			usort($codes, function ($a, $b) {
1759 1840
 				return strcmp($a['tag'], $b['tag']);
1760 1841
 			});
@@ -1774,8 +1855,9 @@  discard block
 block discarded – undo
1774 1855
 		);
1775 1856
 		if (!isset($disabled['li']) && !isset($disabled['list']))
1776 1857
 		{
1777
-			foreach ($itemcodes as $c => $dummy)
1778
-				$bbc_codes[$c] = array();
1858
+			foreach ($itemcodes as $c => $dummy) {
1859
+							$bbc_codes[$c] = array();
1860
+			}
1779 1861
 		}
1780 1862
 
1781 1863
 		// Shhhh!
@@ -1796,12 +1878,14 @@  discard block
 block discarded – undo
1796 1878
 		foreach ($codes as $code)
1797 1879
 		{
1798 1880
 			// Make it easier to process parameters later
1799
-			if (!empty($code['parameters']))
1800
-				ksort($code['parameters'], SORT_STRING);
1881
+			if (!empty($code['parameters'])) {
1882
+							ksort($code['parameters'], SORT_STRING);
1883
+			}
1801 1884
 
1802 1885
 			// If we are not doing every tag only do ones we are interested in.
1803
-			if (empty($parse_tags) || in_array($code['tag'], $parse_tags))
1804
-				$bbc_codes[substr($code['tag'], 0, 1)][] = $code;
1886
+			if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) {
1887
+							$bbc_codes[substr($code['tag'], 0, 1)][] = $code;
1888
+			}
1805 1889
 		}
1806 1890
 		$codes = null;
1807 1891
 	}
@@ -1812,8 +1896,9 @@  discard block
 block discarded – undo
1812 1896
 		// It's likely this will change if the message is modified.
1813 1897
 		$cache_key = 'parse:' . $cache_id . '-' . md5(md5($message) . '-' . $smileys . (empty($disabled) ? '' : implode(',', array_keys($disabled))) . $smcFunc['json_encode']($context['browser']) . $txt['lang_locale'] . $user_info['time_offset'] . $user_info['time_format']);
1814 1898
 
1815
-		if (($temp = cache_get_data($cache_key, 240)) != null)
1816
-			return $temp;
1899
+		if (($temp = cache_get_data($cache_key, 240)) != null) {
1900
+					return $temp;
1901
+		}
1817 1902
 
1818 1903
 		$cache_t = microtime();
1819 1904
 	}
@@ -1845,8 +1930,9 @@  discard block
 block discarded – undo
1845 1930
 		$disabled['flash'] = true;
1846 1931
 
1847 1932
 		// @todo Change maybe?
1848
-		if (!isset($_GET['images']))
1849
-			$disabled['img'] = true;
1933
+		if (!isset($_GET['images'])) {
1934
+					$disabled['img'] = true;
1935
+		}
1850 1936
 
1851 1937
 		// @todo Interface/setting to add more?
1852 1938
 	}
@@ -1870,8 +1956,9 @@  discard block
 block discarded – undo
1870 1956
 		$pos = isset($matches[0][1]) ? $matches[0][1] : false;
1871 1957
 
1872 1958
 		// Failsafe.
1873
-		if ($pos === false || $last_pos > $pos)
1874
-			$pos = strlen($message) + 1;
1959
+		if ($pos === false || $last_pos > $pos) {
1960
+					$pos = strlen($message) + 1;
1961
+		}
1875 1962
 
1876 1963
 		// Can't have a one letter smiley, URL, or email! (sorry.)
1877 1964
 		if ($last_pos < $pos - 1)
@@ -1889,8 +1976,9 @@  discard block
 block discarded – undo
1889 1976
 
1890 1977
 				// <br> should be empty.
1891 1978
 				$empty_tags = array('br', 'hr');
1892
-				foreach ($empty_tags as $tag)
1893
-					$data = str_replace(array('&lt;' . $tag . '&gt;', '&lt;' . $tag . '/&gt;', '&lt;' . $tag . ' /&gt;'), '<' . $tag . '>', $data);
1979
+				foreach ($empty_tags as $tag) {
1980
+									$data = str_replace(array('&lt;' . $tag . '&gt;', '&lt;' . $tag . '/&gt;', '&lt;' . $tag . ' /&gt;'), '<' . $tag . '>', $data);
1981
+				}
1894 1982
 
1895 1983
 				// b, u, i, s, pre... basic tags.
1896 1984
 				$closable_tags = array('b', 'u', 'i', 's', 'em', 'ins', 'del', 'pre', 'blockquote', 'strong');
@@ -1899,8 +1987,9 @@  discard block
 block discarded – undo
1899 1987
 					$diff = substr_count($data, '&lt;' . $tag . '&gt;') - substr_count($data, '&lt;/' . $tag . '&gt;');
1900 1988
 					$data = strtr($data, array('&lt;' . $tag . '&gt;' => '<' . $tag . '>', '&lt;/' . $tag . '&gt;' => '</' . $tag . '>'));
1901 1989
 
1902
-					if ($diff > 0)
1903
-						$data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1);
1990
+					if ($diff > 0) {
1991
+											$data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1);
1992
+					}
1904 1993
 				}
1905 1994
 
1906 1995
 				// Do <img ...> - with security... action= -> action-.
@@ -1913,8 +2002,9 @@  discard block
 block discarded – undo
1913 2002
 						$alt = empty($matches[3][$match]) ? '' : ' alt=' . preg_replace('~^&quot;|&quot;$~', '', $matches[3][$match]);
1914 2003
 
1915 2004
 						// Remove action= from the URL - no funny business, now.
1916
-						if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0)
1917
-							$imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag);
2005
+						if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0) {
2006
+													$imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag);
2007
+						}
1918 2008
 
1919 2009
 						// Check if the image is larger than allowed.
1920 2010
 						if (!empty($modSettings['max_image_width']) && !empty($modSettings['max_image_height']))
@@ -1935,9 +2025,9 @@  discard block
 block discarded – undo
1935 2025
 
1936 2026
 							// Set the new image tag.
1937 2027
 							$replaces[$matches[0][$match]] = '[img width=' . $width . ' height=' . $height . $alt . ']' . $imgtag . '[/img]';
2028
+						} else {
2029
+													$replaces[$matches[0][$match]] = '[img' . $alt . ']' . $imgtag . '[/img]';
1938 2030
 						}
1939
-						else
1940
-							$replaces[$matches[0][$match]] = '[img' . $alt . ']' . $imgtag . '[/img]';
1941 2031
 					}
1942 2032
 
1943 2033
 					$data = strtr($data, $replaces);
@@ -1950,16 +2040,18 @@  discard block
 block discarded – undo
1950 2040
 				$no_autolink_area = false;
1951 2041
 				if (!empty($open_tags))
1952 2042
 				{
1953
-					foreach ($open_tags as $open_tag)
1954
-						if (in_array($open_tag['tag'], $no_autolink_tags))
2043
+					foreach ($open_tags as $open_tag) {
2044
+											if (in_array($open_tag['tag'], $no_autolink_tags))
1955 2045
 							$no_autolink_area = true;
2046
+					}
1956 2047
 				}
1957 2048
 
1958 2049
 				// Don't go backwards.
1959 2050
 				// @todo Don't think is the real solution....
1960 2051
 				$lastAutoPos = isset($lastAutoPos) ? $lastAutoPos : 0;
1961
-				if ($pos < $lastAutoPos)
1962
-					$no_autolink_area = true;
2052
+				if ($pos < $lastAutoPos) {
2053
+									$no_autolink_area = true;
2054
+				}
1963 2055
 				$lastAutoPos = $pos;
1964 2056
 
1965 2057
 				if (!$no_autolink_area)
@@ -2068,17 +2160,19 @@  discard block
 block discarded – undo
2068 2160
 							if ($scheme == 'mailto')
2069 2161
 							{
2070 2162
 								$email_address = str_replace('mailto:', '', $url);
2071
-								if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false)
2072
-									return '[email=' . $email_address . ']' . $url . '[/email]';
2073
-								else
2074
-									return $url;
2163
+								if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false) {
2164
+																	return '[email=' . $email_address . ']' . $url . '[/email]';
2165
+								} else {
2166
+																	return $url;
2167
+								}
2075 2168
 							}
2076 2169
 
2077 2170
 							// Are we linking a schemeless URL or naked domain name (e.g. "example.com")?
2078
-							if (empty($scheme))
2079
-								$fullUrl = '//' . ltrim($url, ':/');
2080
-							else
2081
-								$fullUrl = $url;
2171
+							if (empty($scheme)) {
2172
+															$fullUrl = '//' . ltrim($url, ':/');
2173
+							} else {
2174
+															$fullUrl = $url;
2175
+							}
2082 2176
 
2083 2177
 							return '[url=&quot;' . str_replace(array('[', ']'), array('&#91;', '&#93;'), $fullUrl) . '&quot;]' . $url . '[/url]';
2084 2178
 						}, $data);
@@ -2127,16 +2221,18 @@  discard block
 block discarded – undo
2127 2221
 		}
2128 2222
 
2129 2223
 		// Are we there yet?  Are we there yet?
2130
-		if ($pos >= strlen($message) - 1)
2131
-			break;
2224
+		if ($pos >= strlen($message) - 1) {
2225
+					break;
2226
+		}
2132 2227
 
2133 2228
 		$tags = strtolower($message[$pos + 1]);
2134 2229
 
2135 2230
 		if ($tags == '/' && !empty($open_tags))
2136 2231
 		{
2137 2232
 			$pos2 = strpos($message, ']', $pos + 1);
2138
-			if ($pos2 == $pos + 2)
2139
-				continue;
2233
+			if ($pos2 == $pos + 2) {
2234
+							continue;
2235
+			}
2140 2236
 
2141 2237
 			$look_for = strtolower(substr($message, $pos + 2, $pos2 - $pos - 2));
2142 2238
 
@@ -2146,8 +2242,9 @@  discard block
 block discarded – undo
2146 2242
 			do
2147 2243
 			{
2148 2244
 				$tag = array_pop($open_tags);
2149
-				if (!$tag)
2150
-					break;
2245
+				if (!$tag) {
2246
+									break;
2247
+				}
2151 2248
 
2152 2249
 				if (!empty($tag['block_level']))
2153 2250
 				{
@@ -2161,10 +2258,11 @@  discard block
 block discarded – undo
2161 2258
 					// The idea is, if we are LOOKING for a block level tag, we can close them on the way.
2162 2259
 					if (strlen($look_for) > 0 && isset($bbc_codes[$look_for[0]]))
2163 2260
 					{
2164
-						foreach ($bbc_codes[$look_for[0]] as $temp)
2165
-							if ($temp['tag'] == $look_for)
2261
+						foreach ($bbc_codes[$look_for[0]] as $temp) {
2262
+													if ($temp['tag'] == $look_for)
2166 2263
 							{
2167 2264
 								$block_level = !empty($temp['block_level']);
2265
+						}
2168 2266
 								break;
2169 2267
 							}
2170 2268
 					}
@@ -2186,15 +2284,15 @@  discard block
 block discarded – undo
2186 2284
 			{
2187 2285
 				$open_tags = $to_close;
2188 2286
 				continue;
2189
-			}
2190
-			elseif (!empty($to_close) && $tag['tag'] != $look_for)
2287
+			} elseif (!empty($to_close) && $tag['tag'] != $look_for)
2191 2288
 			{
2192 2289
 				if ($block_level === null && isset($look_for[0], $bbc_codes[$look_for[0]]))
2193 2290
 				{
2194
-					foreach ($bbc_codes[$look_for[0]] as $temp)
2195
-						if ($temp['tag'] == $look_for)
2291
+					foreach ($bbc_codes[$look_for[0]] as $temp) {
2292
+											if ($temp['tag'] == $look_for)
2196 2293
 						{
2197 2294
 							$block_level = !empty($temp['block_level']);
2295
+					}
2198 2296
 							break;
2199 2297
 						}
2200 2298
 				}
@@ -2202,8 +2300,9 @@  discard block
 block discarded – undo
2202 2300
 				// We're not looking for a block level tag (or maybe even a tag that exists...)
2203 2301
 				if (!$block_level)
2204 2302
 				{
2205
-					foreach ($to_close as $tag)
2206
-						array_push($open_tags, $tag);
2303
+					foreach ($to_close as $tag) {
2304
+											array_push($open_tags, $tag);
2305
+					}
2207 2306
 					continue;
2208 2307
 				}
2209 2308
 			}
@@ -2216,14 +2315,17 @@  discard block
 block discarded – undo
2216 2315
 
2217 2316
 				// See the comment at the end of the big loop - just eating whitespace ;).
2218 2317
 				$whitespace_regex = '';
2219
-				if (!empty($tag['block_level']))
2220
-					$whitespace_regex .= '(&nbsp;|\s)*(<br>)?';
2318
+				if (!empty($tag['block_level'])) {
2319
+									$whitespace_regex .= '(&nbsp;|\s)*(<br>)?';
2320
+				}
2221 2321
 				// Trim one line of whitespace after unnested tags, but all of it after nested ones
2222
-				if (!empty($tag['trim']) && $tag['trim'] != 'inside')
2223
-					$whitespace_regex .= empty($tag['require_parents']) ? '(&nbsp;|\s)*' : '(<br>|&nbsp;|\s)*';
2322
+				if (!empty($tag['trim']) && $tag['trim'] != 'inside') {
2323
+									$whitespace_regex .= empty($tag['require_parents']) ? '(&nbsp;|\s)*' : '(<br>|&nbsp;|\s)*';
2324
+				}
2224 2325
 
2225
-				if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0)
2226
-					$message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0]));
2326
+				if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) {
2327
+									$message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0]));
2328
+				}
2227 2329
 			}
2228 2330
 
2229 2331
 			if (!empty($to_close))
@@ -2236,8 +2338,9 @@  discard block
 block discarded – undo
2236 2338
 		}
2237 2339
 
2238 2340
 		// No tags for this character, so just keep going (fastest possible course.)
2239
-		if (!isset($bbc_codes[$tags]))
2240
-			continue;
2341
+		if (!isset($bbc_codes[$tags])) {
2342
+					continue;
2343
+		}
2241 2344
 
2242 2345
 		$inside = empty($open_tags) ? null : $open_tags[count($open_tags) - 1];
2243 2346
 		$tag = null;
@@ -2246,44 +2349,52 @@  discard block
 block discarded – undo
2246 2349
 			$pt_strlen = strlen($possible['tag']);
2247 2350
 
2248 2351
 			// Not a match?
2249
-			if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag'])
2250
-				continue;
2352
+			if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag']) {
2353
+							continue;
2354
+			}
2251 2355
 
2252 2356
 			$next_c = $message[$pos + 1 + $pt_strlen];
2253 2357
 
2254 2358
 			// A test validation?
2255
-			if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0)
2256
-				continue;
2359
+			if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0) {
2360
+							continue;
2361
+			}
2257 2362
 			// Do we want parameters?
2258 2363
 			elseif (!empty($possible['parameters']))
2259 2364
 			{
2260
-				if ($next_c != ' ')
2261
-					continue;
2262
-			}
2263
-			elseif (isset($possible['type']))
2365
+				if ($next_c != ' ') {
2366
+									continue;
2367
+				}
2368
+			} elseif (isset($possible['type']))
2264 2369
 			{
2265 2370
 				// Do we need an equal sign?
2266
-				if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=')
2267
-					continue;
2371
+				if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=') {
2372
+									continue;
2373
+				}
2268 2374
 				// Maybe we just want a /...
2269
-				if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]')
2270
-					continue;
2375
+				if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]') {
2376
+									continue;
2377
+				}
2271 2378
 				// An immediate ]?
2272
-				if ($possible['type'] == 'unparsed_content' && $next_c != ']')
2273
-					continue;
2379
+				if ($possible['type'] == 'unparsed_content' && $next_c != ']') {
2380
+									continue;
2381
+				}
2274 2382
 			}
2275 2383
 			// No type means 'parsed_content', which demands an immediate ] without parameters!
2276
-			elseif ($next_c != ']')
2277
-				continue;
2384
+			elseif ($next_c != ']') {
2385
+							continue;
2386
+			}
2278 2387
 
2279 2388
 			// Check allowed tree?
2280
-			if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents'])))
2281
-				continue;
2282
-			elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children']))
2283
-				continue;
2389
+			if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents']))) {
2390
+							continue;
2391
+			} elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children'])) {
2392
+							continue;
2393
+			}
2284 2394
 			// If this is in the list of disallowed child tags, don't parse it.
2285
-			elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children']))
2286
-				continue;
2395
+			elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children'])) {
2396
+							continue;
2397
+			}
2287 2398
 
2288 2399
 			$pos1 = $pos + 1 + $pt_strlen + 1;
2289 2400
 
@@ -2295,8 +2406,9 @@  discard block
 block discarded – undo
2295 2406
 				foreach ($open_tags as $open_quote)
2296 2407
 				{
2297 2408
 					// Every parent quote this quote has flips the styling
2298
-					if ($open_quote['tag'] == 'quote')
2299
-						$quote_alt = !$quote_alt;
2409
+					if ($open_quote['tag'] == 'quote') {
2410
+											$quote_alt = !$quote_alt;
2411
+					}
2300 2412
 				}
2301 2413
 				// Add a class to the quote to style alternating blockquotes
2302 2414
 				$possible['before'] = strtr($possible['before'], array('<blockquote>' => '<blockquote class="bbc_' . ($quote_alt ? 'alternate' : 'standard') . '_quote">'));
@@ -2307,8 +2419,9 @@  discard block
 block discarded – undo
2307 2419
 			{
2308 2420
 				// Build a regular expression for each parameter for the current tag.
2309 2421
 				$preg = array();
2310
-				foreach ($possible['parameters'] as $p => $info)
2311
-					$preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '&quot;') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '&quot;') . '\s*)' . (empty($info['optional']) ? '' : '?');
2422
+				foreach ($possible['parameters'] as $p => $info) {
2423
+									$preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '&quot;') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '&quot;') . '\s*)' . (empty($info['optional']) ? '' : '?');
2424
+				}
2312 2425
 
2313 2426
 				// Extract the string that potentially holds our parameters.
2314 2427
 				$blob = preg_split('~\[/?(?:' . $alltags_regex . ')~i', substr($message, $pos));
@@ -2328,24 +2441,27 @@  discard block
 block discarded – undo
2328 2441
 
2329 2442
 					$match = preg_match('~^' . implode('', $preg) . '$~i', implode(' ', $given_params), $matches) !== 0;
2330 2443
 
2331
-					if ($match)
2332
-						$blob_counter = count($blobs) + 1;
2444
+					if ($match) {
2445
+											$blob_counter = count($blobs) + 1;
2446
+					}
2333 2447
 				}
2334 2448
 
2335 2449
 				// Didn't match our parameter list, try the next possible.
2336
-				if (!$match)
2337
-					continue;
2450
+				if (!$match) {
2451
+									continue;
2452
+				}
2338 2453
 
2339 2454
 				$params = array();
2340 2455
 				for ($i = 1, $n = count($matches); $i < $n; $i += 2)
2341 2456
 				{
2342 2457
 					$key = strtok(ltrim($matches[$i]), '=');
2343
-					if (isset($possible['parameters'][$key]['value']))
2344
-						$params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1]));
2345
-					elseif (isset($possible['parameters'][$key]['validate']))
2346
-						$params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]);
2347
-					else
2348
-						$params['{' . $key . '}'] = $matches[$i + 1];
2458
+					if (isset($possible['parameters'][$key]['value'])) {
2459
+											$params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1]));
2460
+					} elseif (isset($possible['parameters'][$key]['validate'])) {
2461
+											$params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]);
2462
+					} else {
2463
+											$params['{' . $key . '}'] = $matches[$i + 1];
2464
+					}
2349 2465
 
2350 2466
 					// Just to make sure: replace any $ or { so they can't interpolate wrongly.
2351 2467
 					$params['{' . $key . '}'] = strtr($params['{' . $key . '}'], array('$' => '&#036;', '{' => '&#123;'));
@@ -2353,23 +2469,26 @@  discard block
 block discarded – undo
2353 2469
 
2354 2470
 				foreach ($possible['parameters'] as $p => $info)
2355 2471
 				{
2356
-					if (!isset($params['{' . $p . '}']))
2357
-						$params['{' . $p . '}'] = '';
2472
+					if (!isset($params['{' . $p . '}'])) {
2473
+											$params['{' . $p . '}'] = '';
2474
+					}
2358 2475
 				}
2359 2476
 
2360 2477
 				$tag = $possible;
2361 2478
 
2362 2479
 				// Put the parameters into the string.
2363
-				if (isset($tag['before']))
2364
-					$tag['before'] = strtr($tag['before'], $params);
2365
-				if (isset($tag['after']))
2366
-					$tag['after'] = strtr($tag['after'], $params);
2367
-				if (isset($tag['content']))
2368
-					$tag['content'] = strtr($tag['content'], $params);
2480
+				if (isset($tag['before'])) {
2481
+									$tag['before'] = strtr($tag['before'], $params);
2482
+				}
2483
+				if (isset($tag['after'])) {
2484
+									$tag['after'] = strtr($tag['after'], $params);
2485
+				}
2486
+				if (isset($tag['content'])) {
2487
+									$tag['content'] = strtr($tag['content'], $params);
2488
+				}
2369 2489
 
2370 2490
 				$pos1 += strlen($given_param_string);
2371
-			}
2372
-			else
2491
+			} else
2373 2492
 			{
2374 2493
 				$tag = $possible;
2375 2494
 				$params = array();
@@ -2380,8 +2499,9 @@  discard block
 block discarded – undo
2380 2499
 		// Item codes are complicated buggers... they are implicit [li]s and can make [list]s!
2381 2500
 		if ($smileys !== false && $tag === null && isset($itemcodes[$message[$pos + 1]]) && $message[$pos + 2] == ']' && !isset($disabled['list']) && !isset($disabled['li']))
2382 2501
 		{
2383
-			if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>')))
2384
-				continue;
2502
+			if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>'))) {
2503
+							continue;
2504
+			}
2385 2505
 
2386 2506
 			$tag = $itemcodes[$message[$pos + 1]];
2387 2507
 
@@ -2402,9 +2522,9 @@  discard block
 block discarded – undo
2402 2522
 			{
2403 2523
 				array_pop($open_tags);
2404 2524
 				$code = '</li>';
2525
+			} else {
2526
+							$code = '';
2405 2527
 			}
2406
-			else
2407
-				$code = '';
2408 2528
 
2409 2529
 			// Now we open a new tag.
2410 2530
 			$open_tags[] = array(
@@ -2451,12 +2571,14 @@  discard block
 block discarded – undo
2451 2571
 		}
2452 2572
 
2453 2573
 		// No tag?  Keep looking, then.  Silly people using brackets without actual tags.
2454
-		if ($tag === null)
2455
-			continue;
2574
+		if ($tag === null) {
2575
+					continue;
2576
+		}
2456 2577
 
2457 2578
 		// Propagate the list to the child (so wrapping the disallowed tag won't work either.)
2458
-		if (isset($inside['disallow_children']))
2459
-			$tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children'];
2579
+		if (isset($inside['disallow_children'])) {
2580
+					$tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children'];
2581
+		}
2460 2582
 
2461 2583
 		// Is this tag disabled?
2462 2584
 		if (isset($disabled[$tag['tag']]))
@@ -2466,14 +2588,13 @@  discard block
 block discarded – undo
2466 2588
 				$tag['before'] = !empty($tag['block_level']) ? '<div>' : '';
2467 2589
 				$tag['after'] = !empty($tag['block_level']) ? '</div>' : '';
2468 2590
 				$tag['content'] = isset($tag['type']) && $tag['type'] == 'closed' ? '' : (!empty($tag['block_level']) ? '<div>$1</div>' : '$1');
2469
-			}
2470
-			elseif (isset($tag['disabled_before']) || isset($tag['disabled_after']))
2591
+			} elseif (isset($tag['disabled_before']) || isset($tag['disabled_after']))
2471 2592
 			{
2472 2593
 				$tag['before'] = isset($tag['disabled_before']) ? $tag['disabled_before'] : (!empty($tag['block_level']) ? '<div>' : '');
2473 2594
 				$tag['after'] = isset($tag['disabled_after']) ? $tag['disabled_after'] : (!empty($tag['block_level']) ? '</div>' : '');
2595
+			} else {
2596
+							$tag['content'] = $tag['disabled_content'];
2474 2597
 			}
2475
-			else
2476
-				$tag['content'] = $tag['disabled_content'];
2477 2598
 		}
2478 2599
 
2479 2600
 		// we use this a lot
@@ -2483,8 +2604,9 @@  discard block
 block discarded – undo
2483 2604
 		if (!empty($tag['block_level']) && $tag['tag'] != 'html' && empty($inside['block_level']))
2484 2605
 		{
2485 2606
 			$n = count($open_tags) - 1;
2486
-			while (empty($open_tags[$n]['block_level']) && $n >= 0)
2487
-				$n--;
2607
+			while (empty($open_tags[$n]['block_level']) && $n >= 0) {
2608
+							$n--;
2609
+			}
2488 2610
 
2489 2611
 			// Close all the non block level tags so this tag isn't surrounded by them.
2490 2612
 			for ($i = count($open_tags) - 1; $i > $n; $i--)
@@ -2496,12 +2618,15 @@  discard block
 block discarded – undo
2496 2618
 
2497 2619
 				// Trim or eat trailing stuff... see comment at the end of the big loop.
2498 2620
 				$whitespace_regex = '';
2499
-				if (!empty($tag['block_level']))
2500
-					$whitespace_regex .= '(&nbsp;|\s)*(<br>)?';
2501
-				if (!empty($tag['trim']) && $tag['trim'] != 'inside')
2502
-					$whitespace_regex .= empty($tag['require_parents']) ? '(&nbsp;|\s)*' : '(<br>|&nbsp;|\s)*';
2503
-				if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0)
2504
-					$message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0]));
2621
+				if (!empty($tag['block_level'])) {
2622
+									$whitespace_regex .= '(&nbsp;|\s)*(<br>)?';
2623
+				}
2624
+				if (!empty($tag['trim']) && $tag['trim'] != 'inside') {
2625
+									$whitespace_regex .= empty($tag['require_parents']) ? '(&nbsp;|\s)*' : '(<br>|&nbsp;|\s)*';
2626
+				}
2627
+				if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) {
2628
+									$message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0]));
2629
+				}
2505 2630
 
2506 2631
 				array_pop($open_tags);
2507 2632
 			}
@@ -2522,16 +2647,19 @@  discard block
 block discarded – undo
2522 2647
 		elseif ($tag['type'] == 'unparsed_content')
2523 2648
 		{
2524 2649
 			$pos2 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos1);
2525
-			if ($pos2 === false)
2526
-				continue;
2650
+			if ($pos2 === false) {
2651
+							continue;
2652
+			}
2527 2653
 
2528 2654
 			$data = substr($message, $pos1, $pos2 - $pos1);
2529 2655
 
2530
-			if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>')
2531
-				$data = substr($data, 4);
2656
+			if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>') {
2657
+							$data = substr($data, 4);
2658
+			}
2532 2659
 
2533
-			if (isset($tag['validate']))
2534
-				$tag['validate']($tag, $data, $disabled, $params);
2660
+			if (isset($tag['validate'])) {
2661
+							$tag['validate']($tag, $data, $disabled, $params);
2662
+			}
2535 2663
 
2536 2664
 			$code = strtr($tag['content'], array('$1' => $data));
2537 2665
 			$message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 3 + $tag_strlen);
@@ -2547,34 +2675,40 @@  discard block
 block discarded – undo
2547 2675
 			if (isset($tag['quoted']))
2548 2676
 			{
2549 2677
 				$quoted = substr($message, $pos1, 6) == '&quot;';
2550
-				if ($tag['quoted'] != 'optional' && !$quoted)
2551
-					continue;
2678
+				if ($tag['quoted'] != 'optional' && !$quoted) {
2679
+									continue;
2680
+				}
2552 2681
 
2553
-				if ($quoted)
2554
-					$pos1 += 6;
2682
+				if ($quoted) {
2683
+									$pos1 += 6;
2684
+				}
2685
+			} else {
2686
+							$quoted = false;
2555 2687
 			}
2556
-			else
2557
-				$quoted = false;
2558 2688
 
2559 2689
 			$pos2 = strpos($message, $quoted == false ? ']' : '&quot;]', $pos1);
2560
-			if ($pos2 === false)
2561
-				continue;
2690
+			if ($pos2 === false) {
2691
+							continue;
2692
+			}
2562 2693
 
2563 2694
 			$pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2);
2564
-			if ($pos3 === false)
2565
-				continue;
2695
+			if ($pos3 === false) {
2696
+							continue;
2697
+			}
2566 2698
 
2567 2699
 			$data = array(
2568 2700
 				substr($message, $pos2 + ($quoted == false ? 1 : 7), $pos3 - ($pos2 + ($quoted == false ? 1 : 7))),
2569 2701
 				substr($message, $pos1, $pos2 - $pos1)
2570 2702
 			);
2571 2703
 
2572
-			if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>')
2573
-				$data[0] = substr($data[0], 4);
2704
+			if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>') {
2705
+							$data[0] = substr($data[0], 4);
2706
+			}
2574 2707
 
2575 2708
 			// Validation for my parking, please!
2576
-			if (isset($tag['validate']))
2577
-				$tag['validate']($tag, $data, $disabled, $params);
2709
+			if (isset($tag['validate'])) {
2710
+							$tag['validate']($tag, $data, $disabled, $params);
2711
+			}
2578 2712
 
2579 2713
 			$code = strtr($tag['content'], array('$1' => $data[0], '$2' => $data[1]));
2580 2714
 			$message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen);
@@ -2591,23 +2725,27 @@  discard block
 block discarded – undo
2591 2725
 		elseif ($tag['type'] == 'unparsed_commas_content')
2592 2726
 		{
2593 2727
 			$pos2 = strpos($message, ']', $pos1);
2594
-			if ($pos2 === false)
2595
-				continue;
2728
+			if ($pos2 === false) {
2729
+							continue;
2730
+			}
2596 2731
 
2597 2732
 			$pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2);
2598
-			if ($pos3 === false)
2599
-				continue;
2733
+			if ($pos3 === false) {
2734
+							continue;
2735
+			}
2600 2736
 
2601 2737
 			// We want $1 to be the content, and the rest to be csv.
2602 2738
 			$data = explode(',', ',' . substr($message, $pos1, $pos2 - $pos1));
2603 2739
 			$data[0] = substr($message, $pos2 + 1, $pos3 - $pos2 - 1);
2604 2740
 
2605
-			if (isset($tag['validate']))
2606
-				$tag['validate']($tag, $data, $disabled, $params);
2741
+			if (isset($tag['validate'])) {
2742
+							$tag['validate']($tag, $data, $disabled, $params);
2743
+			}
2607 2744
 
2608 2745
 			$code = $tag['content'];
2609
-			foreach ($data as $k => $d)
2610
-				$code = strtr($code, array('$' . ($k + 1) => trim($d)));
2746
+			foreach ($data as $k => $d) {
2747
+							$code = strtr($code, array('$' . ($k + 1) => trim($d)));
2748
+			}
2611 2749
 			$message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen);
2612 2750
 			$pos += strlen($code) - 1 + 2;
2613 2751
 		}
@@ -2615,24 +2753,28 @@  discard block
 block discarded – undo
2615 2753
 		elseif ($tag['type'] == 'unparsed_commas')
2616 2754
 		{
2617 2755
 			$pos2 = strpos($message, ']', $pos1);
2618
-			if ($pos2 === false)
2619
-				continue;
2756
+			if ($pos2 === false) {
2757
+							continue;
2758
+			}
2620 2759
 
2621 2760
 			$data = explode(',', substr($message, $pos1, $pos2 - $pos1));
2622 2761
 
2623
-			if (isset($tag['validate']))
2624
-				$tag['validate']($tag, $data, $disabled, $params);
2762
+			if (isset($tag['validate'])) {
2763
+							$tag['validate']($tag, $data, $disabled, $params);
2764
+			}
2625 2765
 
2626 2766
 			// Fix after, for disabled code mainly.
2627
-			foreach ($data as $k => $d)
2628
-				$tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d)));
2767
+			foreach ($data as $k => $d) {
2768
+							$tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d)));
2769
+			}
2629 2770
 
2630 2771
 			$open_tags[] = $tag;
2631 2772
 
2632 2773
 			// Replace them out, $1, $2, $3, $4, etc.
2633 2774
 			$code = $tag['before'];
2634
-			foreach ($data as $k => $d)
2635
-				$code = strtr($code, array('$' . ($k + 1) => trim($d)));
2775
+			foreach ($data as $k => $d) {
2776
+							$code = strtr($code, array('$' . ($k + 1) => trim($d)));
2777
+			}
2636 2778
 			$message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 1);
2637 2779
 			$pos += strlen($code) - 1 + 2;
2638 2780
 		}
@@ -2643,28 +2785,33 @@  discard block
 block discarded – undo
2643 2785
 			if (isset($tag['quoted']))
2644 2786
 			{
2645 2787
 				$quoted = substr($message, $pos1, 6) == '&quot;';
2646
-				if ($tag['quoted'] != 'optional' && !$quoted)
2647
-					continue;
2788
+				if ($tag['quoted'] != 'optional' && !$quoted) {
2789
+									continue;
2790
+				}
2648 2791
 
2649
-				if ($quoted)
2650
-					$pos1 += 6;
2792
+				if ($quoted) {
2793
+									$pos1 += 6;
2794
+				}
2795
+			} else {
2796
+							$quoted = false;
2651 2797
 			}
2652
-			else
2653
-				$quoted = false;
2654 2798
 
2655 2799
 			$pos2 = strpos($message, $quoted == false ? ']' : '&quot;]', $pos1);
2656
-			if ($pos2 === false)
2657
-				continue;
2800
+			if ($pos2 === false) {
2801
+							continue;
2802
+			}
2658 2803
 
2659 2804
 			$data = substr($message, $pos1, $pos2 - $pos1);
2660 2805
 
2661 2806
 			// Validation for my parking, please!
2662
-			if (isset($tag['validate']))
2663
-				$tag['validate']($tag, $data, $disabled, $params);
2807
+			if (isset($tag['validate'])) {
2808
+							$tag['validate']($tag, $data, $disabled, $params);
2809
+			}
2664 2810
 
2665 2811
 			// For parsed content, we must recurse to avoid security problems.
2666
-			if ($tag['type'] != 'unparsed_equals')
2667
-				$data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array());
2812
+			if ($tag['type'] != 'unparsed_equals') {
2813
+							$data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array());
2814
+			}
2668 2815
 
2669 2816
 			$tag['after'] = strtr($tag['after'], array('$1' => $data));
2670 2817
 
@@ -2676,34 +2823,40 @@  discard block
 block discarded – undo
2676 2823
 		}
2677 2824
 
2678 2825
 		// If this is block level, eat any breaks after it.
2679
-		if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>')
2680
-			$message = substr($message, 0, $pos + 1) . substr($message, $pos + 5);
2826
+		if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>') {
2827
+					$message = substr($message, 0, $pos + 1) . substr($message, $pos + 5);
2828
+		}
2681 2829
 
2682 2830
 		// Are we trimming outside this tag?
2683
-		if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>|&nbsp;|\s)*~', substr($message, $pos + 1), $matches) != 0)
2684
-			$message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0]));
2831
+		if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>|&nbsp;|\s)*~', substr($message, $pos + 1), $matches) != 0) {
2832
+					$message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0]));
2833
+		}
2685 2834
 	}
2686 2835
 
2687 2836
 	// Close any remaining tags.
2688
-	while ($tag = array_pop($open_tags))
2689
-		$message .= "\n" . $tag['after'] . "\n";
2837
+	while ($tag = array_pop($open_tags)) {
2838
+			$message .= "\n" . $tag['after'] . "\n";
2839
+	}
2690 2840
 
2691 2841
 	// Parse the smileys within the parts where it can be done safely.
2692 2842
 	if ($smileys === true)
2693 2843
 	{
2694 2844
 		$message_parts = explode("\n", $message);
2695
-		for ($i = 0, $n = count($message_parts); $i < $n; $i += 2)
2696
-			parsesmileys($message_parts[$i]);
2845
+		for ($i = 0, $n = count($message_parts); $i < $n; $i += 2) {
2846
+					parsesmileys($message_parts[$i]);
2847
+		}
2697 2848
 
2698 2849
 		$message = implode('', $message_parts);
2699 2850
 	}
2700 2851
 
2701 2852
 	// No smileys, just get rid of the markers.
2702
-	else
2703
-		$message = strtr($message, array("\n" => ''));
2853
+	else {
2854
+			$message = strtr($message, array("\n" => ''));
2855
+	}
2704 2856
 
2705
-	if ($message !== '' && $message[0] === ' ')
2706
-		$message = '&nbsp;' . substr($message, 1);
2857
+	if ($message !== '' && $message[0] === ' ') {
2858
+			$message = '&nbsp;' . substr($message, 1);
2859
+	}
2707 2860
 
2708 2861
 	// Cleanup whitespace.
2709 2862
 	$message = strtr($message, array('  ' => ' &nbsp;', "\r" => '', "\n" => '<br>', '<br> ' => '<br>&nbsp;', '&#13;' => "\n"));
@@ -2712,15 +2865,16 @@  discard block
 block discarded – undo
2712 2865
 	call_integration_hook('integrate_post_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags));
2713 2866
 
2714 2867
 	// Cache the output if it took some time...
2715
-	if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05)
2716
-		cache_put_data($cache_key, $message, 240);
2868
+	if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05) {
2869
+			cache_put_data($cache_key, $message, 240);
2870
+	}
2717 2871
 
2718 2872
 	// If this was a force parse revert if needed.
2719 2873
 	if (!empty($parse_tags))
2720 2874
 	{
2721
-		if (empty($temp_bbc))
2722
-			$bbc_codes = array();
2723
-		else
2875
+		if (empty($temp_bbc)) {
2876
+					$bbc_codes = array();
2877
+		} else
2724 2878
 		{
2725 2879
 			$bbc_codes = $temp_bbc;
2726 2880
 			unset($temp_bbc);
@@ -2747,8 +2901,9 @@  discard block
 block discarded – undo
2747 2901
 	static $smileyPregSearch = null, $smileyPregReplacements = array();
2748 2902
 
2749 2903
 	// No smiley set at all?!
2750
-	if ($user_info['smiley_set'] == 'none' || trim($message) == '')
2751
-		return;
2904
+	if ($user_info['smiley_set'] == 'none' || trim($message) == '') {
2905
+			return;
2906
+	}
2752 2907
 
2753 2908
 	// If smileyPregSearch hasn't been set, do it now.
2754 2909
 	if (empty($smileyPregSearch))
@@ -2759,8 +2914,7 @@  discard block
 block discarded – undo
2759 2914
 			$smileysfrom = array('>:D', ':D', '::)', '>:(', ':))', ':)', ';)', ';D', ':(', ':o', '8)', ':P', '???', ':-[', ':-X', ':-*', ':\'(', ':-\\', '^-^', 'O0', 'C:-)', '0:)');
2760 2915
 			$smileysto = array('evil.gif', 'cheesy.gif', 'rolleyes.gif', 'angry.gif', 'laugh.gif', 'smiley.gif', 'wink.gif', 'grin.gif', 'sad.gif', 'shocked.gif', 'cool.gif', 'tongue.gif', 'huh.gif', 'embarrassed.gif', 'lipsrsealed.gif', 'kiss.gif', 'cry.gif', 'undecided.gif', 'azn.gif', 'afro.gif', 'police.gif', 'angel.gif');
2761 2916
 			$smileysdescs = array('', $txt['icon_cheesy'], $txt['icon_rolleyes'], $txt['icon_angry'], '', $txt['icon_smiley'], $txt['icon_wink'], $txt['icon_grin'], $txt['icon_sad'], $txt['icon_shocked'], $txt['icon_cool'], $txt['icon_tongue'], $txt['icon_huh'], $txt['icon_embarrassed'], $txt['icon_lips'], $txt['icon_kiss'], $txt['icon_cry'], $txt['icon_undecided'], '', '', '', '');
2762
-		}
2763
-		else
2917
+		} else
2764 2918
 		{
2765 2919
 			// Load the smileys in reverse order by length so they don't get parsed wrong.
2766 2920
 			if (($temp = cache_get_data('parsing_smileys', 480)) == null)
@@ -2784,9 +2938,9 @@  discard block
 block discarded – undo
2784 2938
 				$smcFunc['db_free_result']($result);
2785 2939
 
2786 2940
 				cache_put_data('parsing_smileys', array($smileysfrom, $smileysto, $smileysdescs), 480);
2941
+			} else {
2942
+							list ($smileysfrom, $smileysto, $smileysdescs) = $temp;
2787 2943
 			}
2788
-			else
2789
-				list ($smileysfrom, $smileysto, $smileysdescs) = $temp;
2790 2944
 		}
2791 2945
 
2792 2946
 		// The non-breaking-space is a complex thing...
@@ -2863,35 +3017,41 @@  discard block
 block discarded – undo
2863 3017
 	global $scripturl, $context, $modSettings, $db_show_debug, $db_cache;
2864 3018
 
2865 3019
 	// In case we have mail to send, better do that - as obExit doesn't always quite make it...
2866
-	if (!empty($context['flush_mail']))
2867
-		// @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\
3020
+	if (!empty($context['flush_mail'])) {
3021
+			// @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\
2868 3022
 		AddMailQueue(true);
3023
+	}
2869 3024
 
2870 3025
 	$add = preg_match('~^(ftp|http)[s]?://~', $setLocation) == 0 && substr($setLocation, 0, 6) != 'about:';
2871 3026
 
2872
-	if ($add)
2873
-		$setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : '');
3027
+	if ($add) {
3028
+			$setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : '');
3029
+	}
2874 3030
 
2875 3031
 	// Put the session ID in.
2876
-	if (defined('SID') && SID != '')
2877
-		$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation);
3032
+	if (defined('SID') && SID != '') {
3033
+			$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation);
3034
+	}
2878 3035
 	// Keep that debug in their for template debugging!
2879
-	elseif (isset($_GET['debug']))
2880
-		$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation);
3036
+	elseif (isset($_GET['debug'])) {
3037
+			$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation);
3038
+	}
2881 3039
 
2882 3040
 	if (!empty($modSettings['queryless_urls']) && (empty($context['server']['is_cgi']) || ini_get('cgi.fix_pathinfo') == 1 || @get_cfg_var('cgi.fix_pathinfo') == 1) && (!empty($context['server']['is_apache']) || !empty($context['server']['is_lighttpd']) || !empty($context['server']['is_litespeed'])))
2883 3041
 	{
2884
-		if (defined('SID') && SID != '')
2885
-			$setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&amp;))((?:board|topic)=[^#]+?)(#[^"]*?)?$~',
3042
+		if (defined('SID') && SID != '') {
3043
+					$setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&amp;))((?:board|topic)=[^#]+?)(#[^"]*?)?$~',
2886 3044
 				function ($m) use ($scripturl)
2887 3045
 				{
2888 3046
 					return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : "");
3047
+		}
2889 3048
 				}, $setLocation);
2890
-		else
2891
-			$setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~',
3049
+		else {
3050
+					$setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~',
2892 3051
 				function ($m) use ($scripturl)
2893 3052
 				{
2894 3053
 					return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : "");
3054
+		}
2895 3055
 				}, $setLocation);
2896 3056
 	}
2897 3057
 
@@ -2902,8 +3062,9 @@  discard block
 block discarded – undo
2902 3062
 	header('Location: ' . str_replace(' ', '%20', $setLocation), true, $permanent ? 301 : 302);
2903 3063
 
2904 3064
 	// Debugging.
2905
-	if (isset($db_show_debug) && $db_show_debug === true)
2906
-		$_SESSION['debug_redirect'] = $db_cache;
3065
+	if (isset($db_show_debug) && $db_show_debug === true) {
3066
+			$_SESSION['debug_redirect'] = $db_cache;
3067
+	}
2907 3068
 
2908 3069
 	obExit(false);
2909 3070
 }
@@ -2922,51 +3083,60 @@  discard block
 block discarded – undo
2922 3083
 
2923 3084
 	// Attempt to prevent a recursive loop.
2924 3085
 	++$level;
2925
-	if ($level > 1 && !$from_fatal_error && !$has_fatal_error)
2926
-		exit;
2927
-	if ($from_fatal_error)
2928
-		$has_fatal_error = true;
3086
+	if ($level > 1 && !$from_fatal_error && !$has_fatal_error) {
3087
+			exit;
3088
+	}
3089
+	if ($from_fatal_error) {
3090
+			$has_fatal_error = true;
3091
+	}
2929 3092
 
2930 3093
 	// Clear out the stat cache.
2931 3094
 	trackStats();
2932 3095
 
2933 3096
 	// If we have mail to send, send it.
2934
-	if (!empty($context['flush_mail']))
2935
-		// @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\
3097
+	if (!empty($context['flush_mail'])) {
3098
+			// @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\
2936 3099
 		AddMailQueue(true);
3100
+	}
2937 3101
 
2938 3102
 	$do_header = $header === null ? !$header_done : $header;
2939
-	if ($do_footer === null)
2940
-		$do_footer = $do_header;
3103
+	if ($do_footer === null) {
3104
+			$do_footer = $do_header;
3105
+	}
2941 3106
 
2942 3107
 	// Has the template/header been done yet?
2943 3108
 	if ($do_header)
2944 3109
 	{
2945 3110
 		// Was the page title set last minute? Also update the HTML safe one.
2946
-		if (!empty($context['page_title']) && empty($context['page_title_html_safe']))
2947
-			$context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : '');
3111
+		if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) {
3112
+					$context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : '');
3113
+		}
2948 3114
 
2949 3115
 		// Start up the session URL fixer.
2950 3116
 		ob_start('ob_sessrewrite');
2951 3117
 
2952
-		if (!empty($settings['output_buffers']) && is_string($settings['output_buffers']))
2953
-			$buffers = explode(',', $settings['output_buffers']);
2954
-		elseif (!empty($settings['output_buffers']))
2955
-			$buffers = $settings['output_buffers'];
2956
-		else
2957
-			$buffers = array();
3118
+		if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) {
3119
+					$buffers = explode(',', $settings['output_buffers']);
3120
+		} elseif (!empty($settings['output_buffers'])) {
3121
+					$buffers = $settings['output_buffers'];
3122
+		} else {
3123
+					$buffers = array();
3124
+		}
2958 3125
 
2959
-		if (isset($modSettings['integrate_buffer']))
2960
-			$buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers);
3126
+		if (isset($modSettings['integrate_buffer'])) {
3127
+					$buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers);
3128
+		}
2961 3129
 
2962
-		if (!empty($buffers))
2963
-			foreach ($buffers as $function)
3130
+		if (!empty($buffers)) {
3131
+					foreach ($buffers as $function)
2964 3132
 			{
2965 3133
 				$call = call_helper($function, true);
3134
+		}
2966 3135
 
2967 3136
 				// Is it valid?
2968
-				if (!empty($call))
2969
-					ob_start($call);
3137
+				if (!empty($call)) {
3138
+									ob_start($call);
3139
+				}
2970 3140
 			}
2971 3141
 
2972 3142
 		// Display the screen in the logical order.
@@ -2978,8 +3148,9 @@  discard block
 block discarded – undo
2978 3148
 		loadSubTemplate(isset($context['sub_template']) ? $context['sub_template'] : 'main');
2979 3149
 
2980 3150
 		// Anything special to put out?
2981
-		if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml']))
2982
-			echo $context['insert_after_template'];
3151
+		if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) {
3152
+					echo $context['insert_after_template'];
3153
+		}
2983 3154
 
2984 3155
 		// Just so we don't get caught in an endless loop of errors from the footer...
2985 3156
 		if (!$footer_done)
@@ -2988,14 +3159,16 @@  discard block
 block discarded – undo
2988 3159
 			template_footer();
2989 3160
 
2990 3161
 			// (since this is just debugging... it's okay that it's after </html>.)
2991
-			if (!isset($_REQUEST['xml']))
2992
-				displayDebug();
3162
+			if (!isset($_REQUEST['xml'])) {
3163
+							displayDebug();
3164
+			}
2993 3165
 		}
2994 3166
 	}
2995 3167
 
2996 3168
 	// Remember this URL in case someone doesn't like sending HTTP_REFERER.
2997
-	if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false)
2998
-		$_SESSION['old_url'] = $_SERVER['REQUEST_URL'];
3169
+	if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) {
3170
+			$_SESSION['old_url'] = $_SERVER['REQUEST_URL'];
3171
+	}
2999 3172
 
3000 3173
 	// For session check verification.... don't switch browsers...
3001 3174
 	$_SESSION['USER_AGENT'] = empty($_SERVER['HTTP_USER_AGENT']) ? '' : $_SERVER['HTTP_USER_AGENT'];
@@ -3004,9 +3177,10 @@  discard block
 block discarded – undo
3004 3177
 	call_integration_hook('integrate_exit', array($do_footer));
3005 3178
 
3006 3179
 	// Don't exit if we're coming from index.php; that will pass through normally.
3007
-	if (!$from_index)
3008
-		exit;
3009
-}
3180
+	if (!$from_index) {
3181
+			exit;
3182
+	}
3183
+	}
3010 3184
 
3011 3185
 /**
3012 3186
  * Get the size of a specified image with better error handling.
@@ -3025,8 +3199,9 @@  discard block
 block discarded – undo
3025 3199
 	$url = str_replace(' ', '%20', $url);
3026 3200
 
3027 3201
 	// Can we pull this from the cache... please please?
3028
-	if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null)
3029
-		return $temp;
3202
+	if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null) {
3203
+			return $temp;
3204
+	}
3030 3205
 	$t = microtime();
3031 3206
 
3032 3207
 	// Get the host to pester...
@@ -3036,12 +3211,10 @@  discard block
 block discarded – undo
3036 3211
 	if ($url == '' || $url == 'http://' || $url == 'https://')
3037 3212
 	{
3038 3213
 		return false;
3039
-	}
3040
-	elseif (!isset($match[1]))
3214
+	} elseif (!isset($match[1]))
3041 3215
 	{
3042 3216
 		$size = @getimagesize($url);
3043
-	}
3044
-	else
3217
+	} else
3045 3218
 	{
3046 3219
 		// Try to connect to the server... give it half a second.
3047 3220
 		$temp = 0;
@@ -3080,12 +3253,14 @@  discard block
 block discarded – undo
3080 3253
 	}
3081 3254
 
3082 3255
 	// If we didn't get it, we failed.
3083
-	if (!isset($size))
3084
-		$size = false;
3256
+	if (!isset($size)) {
3257
+			$size = false;
3258
+	}
3085 3259
 
3086 3260
 	// If this took a long time, we may never have to do it again, but then again we might...
3087
-	if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8)
3088
-		cache_put_data('url_image_size-' . md5($url), $size, 240);
3261
+	if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8) {
3262
+			cache_put_data('url_image_size-' . md5($url), $size, 240);
3263
+	}
3089 3264
 
3090 3265
 	// Didn't work.
3091 3266
 	return $size;
@@ -3103,8 +3278,9 @@  discard block
 block discarded – undo
3103 3278
 
3104 3279
 	// Under SSI this function can be called more then once.  That can cause some problems.
3105 3280
 	//   So only run the function once unless we are forced to run it again.
3106
-	if ($loaded && !$forceload)
3107
-		return;
3281
+	if ($loaded && !$forceload) {
3282
+			return;
3283
+	}
3108 3284
 
3109 3285
 	$loaded = true;
3110 3286
 
@@ -3116,14 +3292,16 @@  discard block
 block discarded – undo
3116 3292
 	$context['news_lines'] = array_filter(explode("\n", str_replace("\r", '', trim(addslashes($modSettings['news'])))));
3117 3293
 	for ($i = 0, $n = count($context['news_lines']); $i < $n; $i++)
3118 3294
 	{
3119
-		if (trim($context['news_lines'][$i]) == '')
3120
-			continue;
3295
+		if (trim($context['news_lines'][$i]) == '') {
3296
+					continue;
3297
+		}
3121 3298
 
3122 3299
 		// Clean it up for presentation ;).
3123 3300
 		$context['news_lines'][$i] = parse_bbc(stripslashes(trim($context['news_lines'][$i])), true, 'news' . $i);
3124 3301
 	}
3125
-	if (!empty($context['news_lines']))
3126
-		$context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)];
3302
+	if (!empty($context['news_lines'])) {
3303
+			$context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)];
3304
+	}
3127 3305
 
3128 3306
 	if (!$user_info['is_guest'])
3129 3307
 	{
@@ -3132,40 +3310,48 @@  discard block
 block discarded – undo
3132 3310
 		$context['user']['alerts'] = &$user_info['alerts'];
3133 3311
 
3134 3312
 		// Personal message popup...
3135
-		if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0))
3136
-			$context['user']['popup_messages'] = true;
3137
-		else
3138
-			$context['user']['popup_messages'] = false;
3313
+		if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) {
3314
+					$context['user']['popup_messages'] = true;
3315
+		} else {
3316
+					$context['user']['popup_messages'] = false;
3317
+		}
3139 3318
 		$_SESSION['unread_messages'] = $user_info['unread_messages'];
3140 3319
 
3141
-		if (allowedTo('moderate_forum'))
3142
-			$context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0;
3320
+		if (allowedTo('moderate_forum')) {
3321
+					$context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0;
3322
+		}
3143 3323
 
3144 3324
 		$context['user']['avatar'] = array();
3145 3325
 
3146 3326
 		// Check for gravatar first since we might be forcing them...
3147 3327
 		if (($modSettings['gravatarEnabled'] && substr($user_info['avatar']['url'], 0, 11) == 'gravatar://') || !empty($modSettings['gravatarOverride']))
3148 3328
 		{
3149
-			if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11)
3150
-				$context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11));
3151
-			else
3152
-				$context['user']['avatar']['href'] = get_gravatar_url($user_info['email']);
3329
+			if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11) {
3330
+							$context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11));
3331
+			} else {
3332
+							$context['user']['avatar']['href'] = get_gravatar_url($user_info['email']);
3333
+			}
3153 3334
 		}
3154 3335
 		// Uploaded?
3155
-		elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach']))
3156
-			$context['user']['avatar']['href'] = $user_info['avatar']['custom_dir'] ? $modSettings['custom_avatar_url'] . '/' . $user_info['avatar']['filename'] : $scripturl . '?action=dlattach;attach=' . $user_info['avatar']['id_attach'] . ';type=avatar';
3336
+		elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) {
3337
+					$context['user']['avatar']['href'] = $user_info['avatar']['custom_dir'] ? $modSettings['custom_avatar_url'] . '/' . $user_info['avatar']['filename'] : $scripturl . '?action=dlattach;attach=' . $user_info['avatar']['id_attach'] . ';type=avatar';
3338
+		}
3157 3339
 		// Full URL?
3158
-		elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0)
3159
-			$context['user']['avatar']['href'] = $user_info['avatar']['url'];
3340
+		elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0) {
3341
+					$context['user']['avatar']['href'] = $user_info['avatar']['url'];
3342
+		}
3160 3343
 		// Otherwise we assume it's server stored.
3161
-		elseif ($user_info['avatar']['url'] != '')
3162
-			$context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']);
3344
+		elseif ($user_info['avatar']['url'] != '') {
3345
+					$context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']);
3346
+		}
3163 3347
 		// No avatar at all? Fine, we have a big fat default avatar ;)
3164
-		else
3165
-			$context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png';
3348
+		else {
3349
+					$context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png';
3350
+		}
3166 3351
 
3167
-		if (!empty($context['user']['avatar']))
3168
-			$context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">';
3352
+		if (!empty($context['user']['avatar'])) {
3353
+					$context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">';
3354
+		}
3169 3355
 
3170 3356
 		// Figure out how long they've been logged in.
3171 3357
 		$context['user']['total_time_logged_in'] = array(
@@ -3173,8 +3359,7 @@  discard block
 block discarded – undo
3173 3359
 			'hours' => floor(($user_info['total_time_logged_in'] % 86400) / 3600),
3174 3360
 			'minutes' => floor(($user_info['total_time_logged_in'] % 3600) / 60)
3175 3361
 		);
3176
-	}
3177
-	else
3362
+	} else
3178 3363
 	{
3179 3364
 		$context['user']['messages'] = 0;
3180 3365
 		$context['user']['unread_messages'] = 0;
@@ -3182,12 +3367,14 @@  discard block
 block discarded – undo
3182 3367
 		$context['user']['total_time_logged_in'] = array('days' => 0, 'hours' => 0, 'minutes' => 0);
3183 3368
 		$context['user']['popup_messages'] = false;
3184 3369
 
3185
-		if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1)
3186
-			$txt['welcome_guest'] .= $txt['welcome_guest_activate'];
3370
+		if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) {
3371
+					$txt['welcome_guest'] .= $txt['welcome_guest_activate'];
3372
+		}
3187 3373
 
3188 3374
 		// If we've upgraded recently, go easy on the passwords.
3189
-		if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime']))
3190
-			$context['disable_login_hashing'] = true;
3375
+		if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) {
3376
+					$context['disable_login_hashing'] = true;
3377
+		}
3191 3378
 	}
3192 3379
 
3193 3380
 	// Setup the main menu items.
@@ -3200,8 +3387,8 @@  discard block
 block discarded – undo
3200 3387
 	$context['show_pm_popup'] = $context['user']['popup_messages'] && !empty($options['popup_messages']) && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'pm');
3201 3388
 
3202 3389
 	// 2.1+: Add the PM popup here instead. Theme authors can still override it simply by editing/removing the 'fPmPopup' in the array.
3203
-	if ($context['show_pm_popup'])
3204
-		addInlineJavaScript('
3390
+	if ($context['show_pm_popup']) {
3391
+			addInlineJavaScript('
3205 3392
 		jQuery(document).ready(function($) {
3206 3393
 			new smc_Popup({
3207 3394
 				heading: ' . JavaScriptEscape($txt['show_personal_messages_heading']) . ',
@@ -3209,15 +3396,17 @@  discard block
 block discarded – undo
3209 3396
 				icon_class: \'generic_icons mail_new\'
3210 3397
 			});
3211 3398
 		});');
3399
+	}
3212 3400
 
3213 3401
 	// Add a generic "Are you sure?" confirmation message.
3214 3402
 	addInlineJavaScript('
3215 3403
 	var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';');
3216 3404
 
3217 3405
 	// Now add the capping code for avatars.
3218
-	if (!empty($modSettings['avatar_max_width_external']) && !empty($modSettings['avatar_max_height_external']) && !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_css_resize')
3219
-		addInlineCss('
3406
+	if (!empty($modSettings['avatar_max_width_external']) && !empty($modSettings['avatar_max_height_external']) && !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_css_resize') {
3407
+			addInlineCss('
3220 3408
 img.avatar { max-width: ' . $modSettings['avatar_max_width_external'] . 'px; max-height: ' . $modSettings['avatar_max_height_external'] . 'px; }');
3409
+	}
3221 3410
 
3222 3411
 	// This looks weird, but it's because BoardIndex.php references the variable.
3223 3412
 	$context['common_stats']['latest_member'] = array(
@@ -3234,11 +3423,13 @@  discard block
 block discarded – undo
3234 3423
 	);
3235 3424
 	$context['common_stats']['boardindex_total_posts'] = sprintf($txt['boardindex_total_posts'], $context['common_stats']['total_posts'], $context['common_stats']['total_topics'], $context['common_stats']['total_members']);
3236 3425
 
3237
-	if (empty($settings['theme_version']))
3238
-		addJavaScriptVar('smf_scripturl', $scripturl);
3426
+	if (empty($settings['theme_version'])) {
3427
+			addJavaScriptVar('smf_scripturl', $scripturl);
3428
+	}
3239 3429
 
3240
-	if (!isset($context['page_title']))
3241
-		$context['page_title'] = '';
3430
+	if (!isset($context['page_title'])) {
3431
+			$context['page_title'] = '';
3432
+	}
3242 3433
 
3243 3434
 	// Set some specific vars.
3244 3435
 	$context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : '');
@@ -3248,21 +3439,23 @@  discard block
 block discarded – undo
3248 3439
 	$context['meta_tags'][] = array('property' => 'og:site_name', 'content' => $context['forum_name']);
3249 3440
 	$context['meta_tags'][] = array('property' => 'og:title', 'content' => $context['page_title_html_safe']);
3250 3441
 
3251
-	if (!empty($context['meta_keywords']))
3252
-		$context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']);
3442
+	if (!empty($context['meta_keywords'])) {
3443
+			$context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']);
3444
+	}
3253 3445
 
3254
-	if (!empty($context['canonical_url']))
3255
-		$context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']);
3446
+	if (!empty($context['canonical_url'])) {
3447
+			$context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']);
3448
+	}
3256 3449
 
3257
-	if (!empty($settings['og_image']))
3258
-		$context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']);
3450
+	if (!empty($settings['og_image'])) {
3451
+			$context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']);
3452
+	}
3259 3453
 
3260 3454
 	if (!empty($context['meta_description']))
3261 3455
 	{
3262 3456
 		$context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['meta_description']);
3263 3457
 		$context['meta_tags'][] = array('name' => 'description', 'content' => $context['meta_description']);
3264
-	}
3265
-	else
3458
+	} else
3266 3459
 	{
3267 3460
 		$context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['page_title_html_safe']);
3268 3461
 		$context['meta_tags'][] = array('name' => 'description', 'content' => $context['page_title_html_safe']);
@@ -3287,8 +3480,9 @@  discard block
 block discarded – undo
3287 3480
 	$memory_needed = memoryReturnBytes($needed);
3288 3481
 
3289 3482
 	// should we account for how much is currently being used?
3290
-	if ($in_use)
3291
-		$memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576);
3483
+	if ($in_use) {
3484
+			$memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576);
3485
+	}
3292 3486
 
3293 3487
 	// if more is needed, request it
3294 3488
 	if ($memory_current < $memory_needed)
@@ -3311,8 +3505,9 @@  discard block
 block discarded – undo
3311 3505
  */
3312 3506
 function memoryReturnBytes($val)
3313 3507
 {
3314
-	if (is_integer($val))
3315
-		return $val;
3508
+	if (is_integer($val)) {
3509
+			return $val;
3510
+	}
3316 3511
 
3317 3512
 	// Separate the number from the designator
3318 3513
 	$val = trim($val);
@@ -3348,10 +3543,11 @@  discard block
 block discarded – undo
3348 3543
 		header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
3349 3544
 
3350 3545
 		// Are we debugging the template/html content?
3351
-		if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie'))
3352
-			header('Content-Type: application/xhtml+xml');
3353
-		elseif (!isset($_REQUEST['xml']))
3354
-			header('Content-Type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
3546
+		if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie')) {
3547
+					header('Content-Type: application/xhtml+xml');
3548
+		} elseif (!isset($_REQUEST['xml'])) {
3549
+					header('Content-Type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
3550
+		}
3355 3551
 	}
3356 3552
 
3357 3553
 	header('Content-Type: text/' . (isset($_REQUEST['xml']) ? 'xml' : 'html') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
@@ -3360,8 +3556,9 @@  discard block
 block discarded – undo
3360 3556
 	if ($context['in_maintenance'] && $context['user']['is_admin'])
3361 3557
 	{
3362 3558
 		$position = array_search('body', $context['template_layers']);
3363
-		if ($position === false)
3364
-			$position = array_search('main', $context['template_layers']);
3559
+		if ($position === false) {
3560
+					$position = array_search('main', $context['template_layers']);
3561
+		}
3365 3562
 
3366 3563
 		if ($position !== false)
3367 3564
 		{
@@ -3389,23 +3586,25 @@  discard block
 block discarded – undo
3389 3586
 
3390 3587
 			foreach ($securityFiles as $i => $securityFile)
3391 3588
 			{
3392
-				if (!file_exists($boarddir . '/' . $securityFile))
3393
-					unset($securityFiles[$i]);
3589
+				if (!file_exists($boarddir . '/' . $securityFile)) {
3590
+									unset($securityFiles[$i]);
3591
+				}
3394 3592
 			}
3395 3593
 
3396 3594
 			// We are already checking so many files...just few more doesn't make any difference! :P
3397
-			if (!empty($modSettings['currentAttachmentUploadDir']))
3398
-				$path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']];
3399
-
3400
-			else
3401
-				$path = $modSettings['attachmentUploadDir'];
3595
+			if (!empty($modSettings['currentAttachmentUploadDir'])) {
3596
+							$path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']];
3597
+			} else {
3598
+							$path = $modSettings['attachmentUploadDir'];
3599
+			}
3402 3600
 
3403 3601
 			secureDirectory($path, true);
3404 3602
 			secureDirectory($cachedir);
3405 3603
 
3406 3604
 			// If agreement is enabled, at least the english version shall exists
3407
-			if ($modSettings['requireAgreement'])
3408
-				$agreement = !file_exists($boarddir . '/agreement.txt');
3605
+			if ($modSettings['requireAgreement']) {
3606
+							$agreement = !file_exists($boarddir . '/agreement.txt');
3607
+			}
3409 3608
 
3410 3609
 			if (!empty($securityFiles) || (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) || !empty($agreement))
3411 3610
 			{
@@ -3420,18 +3619,21 @@  discard block
 block discarded – undo
3420 3619
 					echo '
3421 3620
 				', $txt['not_removed'], '<strong>', $securityFile, '</strong>!<br>';
3422 3621
 
3423
-					if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~')
3424
-						echo '
3622
+					if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~') {
3623
+											echo '
3425 3624
 				', sprintf($txt['not_removed_extra'], $securityFile, substr($securityFile, 0, -1)), '<br>';
3625
+					}
3426 3626
 				}
3427 3627
 
3428
-				if (!empty($modSettings['cache_enable']) && !is_writable($cachedir))
3429
-					echo '
3628
+				if (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) {
3629
+									echo '
3430 3630
 				<strong>', $txt['cache_writable'], '</strong><br>';
3631
+				}
3431 3632
 
3432
-				if (!empty($agreement))
3433
-					echo '
3633
+				if (!empty($agreement)) {
3634
+									echo '
3434 3635
 				<strong>', $txt['agreement_missing'], '</strong><br>';
3636
+				}
3435 3637
 
3436 3638
 				echo '
3437 3639
 			</p>
@@ -3446,16 +3648,18 @@  discard block
 block discarded – undo
3446 3648
 				<div class="windowbg alert" style="margin: 2ex; padding: 2ex; border: 2px dashed red;">
3447 3649
 					', sprintf($txt['you_are_post_banned'], $user_info['is_guest'] ? $txt['guest_title'] : $user_info['name']);
3448 3650
 
3449
-			if (!empty($_SESSION['ban']['cannot_post']['reason']))
3450
-				echo '
3651
+			if (!empty($_SESSION['ban']['cannot_post']['reason'])) {
3652
+							echo '
3451 3653
 					<div style="padding-left: 4ex; padding-top: 1ex;">', $_SESSION['ban']['cannot_post']['reason'], '</div>';
3654
+			}
3452 3655
 
3453
-			if (!empty($_SESSION['ban']['expire_time']))
3454
-				echo '
3656
+			if (!empty($_SESSION['ban']['expire_time'])) {
3657
+							echo '
3455 3658
 					<div>', sprintf($txt['your_ban_expires'], timeformat($_SESSION['ban']['expire_time'], false)), '</div>';
3456
-			else
3457
-				echo '
3659
+			} else {
3660
+							echo '
3458 3661
 					<div>', $txt['your_ban_expires_never'], '</div>';
3662
+			}
3459 3663
 
3460 3664
 			echo '
3461 3665
 				</div>';
@@ -3471,8 +3675,9 @@  discard block
 block discarded – undo
3471 3675
 	global $forum_copyright, $software_year, $forum_version;
3472 3676
 
3473 3677
 	// Don't display copyright for things like SSI.
3474
-	if (!isset($forum_version) || !isset($software_year))
3475
-		return;
3678
+	if (!isset($forum_version) || !isset($software_year)) {
3679
+			return;
3680
+	}
3476 3681
 
3477 3682
 	// Put in the version...
3478 3683
 	printf($forum_copyright, $forum_version, $software_year);
@@ -3490,9 +3695,10 @@  discard block
 block discarded – undo
3490 3695
 	$context['load_time'] = round(microtime(true) - $time_start, 3);
3491 3696
 	$context['load_queries'] = $db_count;
3492 3697
 
3493
-	foreach (array_reverse($context['template_layers']) as $layer)
3494
-		loadSubTemplate($layer . '_below', true);
3495
-}
3698
+	foreach (array_reverse($context['template_layers']) as $layer) {
3699
+			loadSubTemplate($layer . '_below', true);
3700
+	}
3701
+	}
3496 3702
 
3497 3703
 /**
3498 3704
  * Output the Javascript files
@@ -3523,8 +3729,7 @@  discard block
 block discarded – undo
3523 3729
 			{
3524 3730
 				echo '
3525 3731
 		var ', $key, ';';
3526
-			}
3527
-			else
3732
+			} else
3528 3733
 			{
3529 3734
 				echo '
3530 3735
 		var ', $key, ' = ', $value, ';';
@@ -3539,26 +3744,27 @@  discard block
 block discarded – undo
3539 3744
 	foreach ($context['javascript_files'] as $id => $js_file)
3540 3745
 	{
3541 3746
 		// Last minute call! allow theme authors to disable single files.
3542
-		if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files']))
3543
-			continue;
3747
+		if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) {
3748
+					continue;
3749
+		}
3544 3750
 
3545 3751
 		// By default all files don't get minimized unless the file explicitly says so!
3546 3752
 		if (!empty($js_file['options']['minimize']) && !empty($modSettings['minimize_files']))
3547 3753
 		{
3548
-			if ($do_deferred && !empty($js_file['options']['defer']))
3549
-				$toMinifyDefer[] = $js_file;
3550
-
3551
-			elseif (!$do_deferred && empty($js_file['options']['defer']))
3552
-				$toMinify[] = $js_file;
3754
+			if ($do_deferred && !empty($js_file['options']['defer'])) {
3755
+							$toMinifyDefer[] = $js_file;
3756
+			} elseif (!$do_deferred && empty($js_file['options']['defer'])) {
3757
+							$toMinify[] = $js_file;
3758
+			}
3553 3759
 
3554 3760
 			// Grab a random seed.
3555
-			if (!isset($minSeed))
3556
-				$minSeed = $js_file['options']['seed'];
3557
-		}
3558
-
3559
-		elseif ((!$do_deferred && empty($js_file['options']['defer'])) || ($do_deferred && !empty($js_file['options']['defer'])))
3560
-			echo '
3761
+			if (!isset($minSeed)) {
3762
+							$minSeed = $js_file['options']['seed'];
3763
+			}
3764
+		} elseif ((!$do_deferred && empty($js_file['options']['defer'])) || ($do_deferred && !empty($js_file['options']['defer']))) {
3765
+					echo '
3561 3766
 	<script src="', $js_file['fileUrl'], '"', !empty($js_file['options']['async']) ? ' async="async"' : '', '></script>';
3767
+		}
3562 3768
 	}
3563 3769
 
3564 3770
 	if ((!$do_deferred && !empty($toMinify)) || ($do_deferred && !empty($toMinifyDefer)))
@@ -3566,14 +3772,14 @@  discard block
 block discarded – undo
3566 3772
 		$result = custMinify(($do_deferred ? $toMinifyDefer : $toMinify), 'js', $do_deferred);
3567 3773
 
3568 3774
 		// Minify process couldn't work, print each individual files.
3569
-		if (!empty($result) && is_array($result))
3570
-			foreach ($result as $minFailedFile)
3775
+		if (!empty($result) && is_array($result)) {
3776
+					foreach ($result as $minFailedFile)
3571 3777
 				echo '
3572 3778
 	<script src="', $minFailedFile['fileUrl'], '"', !empty($minFailedFile['options']['async']) ? ' async="async"' : '', '></script>';
3573
-
3574
-		else
3575
-			echo '
3779
+		} else {
3780
+					echo '
3576 3781
 	<script src="', $settings['theme_url'] ,'/scripts/minified', ($do_deferred ? '_deferred' : '') ,'.js', $minSeed ,'"></script>';
3782
+		}
3577 3783
 	}
3578 3784
 
3579 3785
 	// Inline JavaScript - Actually useful some times!
@@ -3584,8 +3790,9 @@  discard block
 block discarded – undo
3584 3790
 			echo '
3585 3791
 <script>';
3586 3792
 
3587
-			foreach ($context['javascript_inline']['defer'] as $js_code)
3588
-				echo $js_code;
3793
+			foreach ($context['javascript_inline']['defer'] as $js_code) {
3794
+							echo $js_code;
3795
+			}
3589 3796
 
3590 3797
 			echo '
3591 3798
 </script>';
@@ -3596,8 +3803,9 @@  discard block
 block discarded – undo
3596 3803
 			echo '
3597 3804
 	<script>';
3598 3805
 
3599
-			foreach ($context['javascript_inline']['standard'] as $js_code)
3600
-				echo $js_code;
3806
+			foreach ($context['javascript_inline']['standard'] as $js_code) {
3807
+							echo $js_code;
3808
+			}
3601 3809
 
3602 3810
 			echo '
3603 3811
 	</script>';
@@ -3622,8 +3830,9 @@  discard block
 block discarded – undo
3622 3830
 	foreach ($context['css_files'] as $id => $file)
3623 3831
 	{
3624 3832
 		// Last minute call! allow theme authors to disable single files.
3625
-		if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files']))
3626
-			continue;
3833
+		if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) {
3834
+					continue;
3835
+		}
3627 3836
 
3628 3837
 		// By default all files don't get minimized unless the file explicitly says so!
3629 3838
 		if (!empty($file['options']['minimize']) && !empty($modSettings['minimize_files']))
@@ -3631,12 +3840,12 @@  discard block
 block discarded – undo
3631 3840
 			$toMinify[] = $file;
3632 3841
 
3633 3842
 			// Grab a random seed.
3634
-			if (!isset($minSeed))
3635
-				$minSeed = $file['options']['seed'];
3843
+			if (!isset($minSeed)) {
3844
+							$minSeed = $file['options']['seed'];
3845
+			}
3846
+		} else {
3847
+					$normal[] = $file['fileUrl'];
3636 3848
 		}
3637
-
3638
-		else
3639
-			$normal[] = $file['fileUrl'];
3640 3849
 	}
3641 3850
 
3642 3851
 	if (!empty($toMinify))
@@ -3644,28 +3853,30 @@  discard block
 block discarded – undo
3644 3853
 		$result = custMinify($toMinify, 'css');
3645 3854
 
3646 3855
 		// Minify process couldn't work, print each individual files.
3647
-		if (!empty($result) && is_array($result))
3648
-			foreach ($result as $minFailedFile)
3856
+		if (!empty($result) && is_array($result)) {
3857
+					foreach ($result as $minFailedFile)
3649 3858
 				echo '
3650 3859
 	<link rel="stylesheet" href="', $minFailedFile['fileUrl'], '">';
3651
-
3652
-		else
3653
-			echo '
3860
+		} else {
3861
+					echo '
3654 3862
 	<link rel="stylesheet" href="', $settings['theme_url'] ,'/css/minified.css', $minSeed ,'">';
3863
+		}
3655 3864
 	}
3656 3865
 
3657 3866
 	// Print the rest after the minified files.
3658
-	if (!empty($normal))
3659
-		foreach ($normal as $nf)
3867
+	if (!empty($normal)) {
3868
+			foreach ($normal as $nf)
3660 3869
 			echo '
3661 3870
 	<link rel="stylesheet" href="', $nf ,'">';
3871
+	}
3662 3872
 
3663 3873
 	if ($db_show_debug === true)
3664 3874
 	{
3665 3875
 		// Try to keep only what's useful.
3666 3876
 		$repl = array($boardurl . '/Themes/' => '', $boardurl . '/' => '');
3667
-		foreach ($context['css_files'] as $file)
3668
-			$context['debug']['sheets'][] = strtr($file['fileName'], $repl);
3877
+		foreach ($context['css_files'] as $file) {
3878
+					$context['debug']['sheets'][] = strtr($file['fileName'], $repl);
3879
+		}
3669 3880
 	}
3670 3881
 
3671 3882
 	if (!empty($context['css_header']))
@@ -3673,9 +3884,10 @@  discard block
 block discarded – undo
3673 3884
 		echo '
3674 3885
 	<style>';
3675 3886
 
3676
-		foreach ($context['css_header'] as $css)
3677
-			echo $css .'
3887
+		foreach ($context['css_header'] as $css) {
3888
+					echo $css .'
3678 3889
 	';
3890
+		}
3679 3891
 
3680 3892
 		echo'
3681 3893
 	</style>';
@@ -3699,15 +3911,17 @@  discard block
 block discarded – undo
3699 3911
 	$type = !empty($type) && in_array($type, $types) ? $type : false;
3700 3912
 	$data = !empty($data) ? $data : false;
3701 3913
 
3702
-	if (empty($type) || empty($data))
3703
-		return false;
3914
+	if (empty($type) || empty($data)) {
3915
+			return false;
3916
+	}
3704 3917
 
3705 3918
 	// Did we already did this?
3706 3919
 	$toCache = cache_get_data('minimized_'. $settings['theme_id'] .'_'. $type, 86400);
3707 3920
 
3708 3921
 	// Already done?
3709
-	if (!empty($toCache))
3710
-		return true;
3922
+	if (!empty($toCache)) {
3923
+			return true;
3924
+	}
3711 3925
 
3712 3926
 	// No namespaces, sorry!
3713 3927
 	$classType = 'MatthiasMullie\\Minify\\'. strtoupper($type);
@@ -3789,8 +4003,9 @@  discard block
 block discarded – undo
3789 4003
 	global $modSettings, $smcFunc;
3790 4004
 
3791 4005
 	// Just make up a nice hash...
3792
-	if ($new)
3793
-		return sha1(md5($filename . time()) . mt_rand());
4006
+	if ($new) {
4007
+			return sha1(md5($filename . time()) . mt_rand());
4008
+	}
3794 4009
 
3795 4010
 	// Just make sure that attachment id is only a int
3796 4011
 	$attachment_id = (int) $attachment_id;
@@ -3807,23 +4022,25 @@  discard block
 block discarded – undo
3807 4022
 				'id_attach' => $attachment_id,
3808 4023
 			));
3809 4024
 
3810
-		if ($smcFunc['db_num_rows']($request) === 0)
3811
-			return false;
4025
+		if ($smcFunc['db_num_rows']($request) === 0) {
4026
+					return false;
4027
+		}
3812 4028
 
3813 4029
 		list ($file_hash) = $smcFunc['db_fetch_row']($request);
3814 4030
 		$smcFunc['db_free_result']($request);
3815 4031
 	}
3816 4032
 
3817 4033
 	// Still no hash? mmm...
3818
-	if (empty($file_hash))
3819
-		$file_hash = sha1(md5($filename . time()) . mt_rand());
4034
+	if (empty($file_hash)) {
4035
+			$file_hash = sha1(md5($filename . time()) . mt_rand());
4036
+	}
3820 4037
 
3821 4038
 	// Are we using multiple directories?
3822
-	if (is_array($modSettings['attachmentUploadDir']))
3823
-		$path = $modSettings['attachmentUploadDir'][$dir];
3824
-
3825
-	else
3826
-		$path = $modSettings['attachmentUploadDir'];
4039
+	if (is_array($modSettings['attachmentUploadDir'])) {
4040
+			$path = $modSettings['attachmentUploadDir'][$dir];
4041
+	} else {
4042
+			$path = $modSettings['attachmentUploadDir'];
4043
+	}
3827 4044
 
3828 4045
 	return $path . '/' . $attachment_id . '_' . $file_hash .'.dat';
3829 4046
 }
@@ -3838,8 +4055,9 @@  discard block
 block discarded – undo
3838 4055
 function ip2range($fullip)
3839 4056
 {
3840 4057
 	// Pretend that 'unknown' is 255.255.255.255. (since that can't be an IP anyway.)
3841
-	if ($fullip == 'unknown')
3842
-		$fullip = '255.255.255.255';
4058
+	if ($fullip == 'unknown') {
4059
+			$fullip = '255.255.255.255';
4060
+	}
3843 4061
 
3844 4062
 	$ip_parts = explode('-', $fullip);
3845 4063
 	$ip_array = array();
@@ -3863,10 +4081,11 @@  discard block
 block discarded – undo
3863 4081
 		$ip_array['low'] = $ip_parts[0];
3864 4082
 		$ip_array['high'] = $ip_parts[1];
3865 4083
 		return $ip_array;
3866
-	}
3867
-	elseif (count($ip_parts) == 2) // if ip 22.22.*-22.22.*
4084
+	} elseif (count($ip_parts) == 2) {
4085
+		// if ip 22.22.*-22.22.*
3868 4086
 	{
3869 4087
 		$valid_low = isValidIP($ip_parts[0]);
4088
+	}
3870 4089
 		$valid_high = isValidIP($ip_parts[1]);
3871 4090
 		$count = 0;
3872 4091
 		$mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.');
@@ -3881,7 +4100,9 @@  discard block
 block discarded – undo
3881 4100
 				$ip_parts[0] .= $mode . $min;
3882 4101
 				$valid_low = isValidIP($ip_parts[0]);
3883 4102
 				$count++;
3884
-				if ($count > 9) break;
4103
+				if ($count > 9) {
4104
+					break;
4105
+				}
3885 4106
 			}
3886 4107
 		}
3887 4108
 
@@ -3895,7 +4116,9 @@  discard block
 block discarded – undo
3895 4116
 				$ip_parts[1] .= $mode . $max;
3896 4117
 				$valid_high = isValidIP($ip_parts[1]);
3897 4118
 				$count++;
3898
-				if ($count > 9) break;
4119
+				if ($count > 9) {
4120
+					break;
4121
+				}
3899 4122
 			}
3900 4123
 		}
3901 4124
 
@@ -3920,46 +4143,54 @@  discard block
 block discarded – undo
3920 4143
 {
3921 4144
 	global $modSettings;
3922 4145
 
3923
-	if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null)
3924
-		return $host;
4146
+	if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null) {
4147
+			return $host;
4148
+	}
3925 4149
 	$t = microtime();
3926 4150
 
3927 4151
 	// Try the Linux host command, perhaps?
3928 4152
 	if (!isset($host) && (strpos(strtolower(PHP_OS), 'win') === false || strpos(strtolower(PHP_OS), 'darwin') !== false) && mt_rand(0, 1) == 1)
3929 4153
 	{
3930
-		if (!isset($modSettings['host_to_dis']))
3931
-			$test = @shell_exec('host -W 1 ' . @escapeshellarg($ip));
3932
-		else
3933
-			$test = @shell_exec('host ' . @escapeshellarg($ip));
4154
+		if (!isset($modSettings['host_to_dis'])) {
4155
+					$test = @shell_exec('host -W 1 ' . @escapeshellarg($ip));
4156
+		} else {
4157
+					$test = @shell_exec('host ' . @escapeshellarg($ip));
4158
+		}
3934 4159
 
3935 4160
 		// Did host say it didn't find anything?
3936
-		if (strpos($test, 'not found') !== false)
3937
-			$host = '';
4161
+		if (strpos($test, 'not found') !== false) {
4162
+					$host = '';
4163
+		}
3938 4164
 		// Invalid server option?
3939
-		elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis']))
3940
-			updateSettings(array('host_to_dis' => 1));
4165
+		elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis'])) {
4166
+					updateSettings(array('host_to_dis' => 1));
4167
+		}
3941 4168
 		// Maybe it found something, after all?
3942
-		elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1)
3943
-			$host = $match[1];
4169
+		elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1) {
4170
+					$host = $match[1];
4171
+		}
3944 4172
 	}
3945 4173
 
3946 4174
 	// This is nslookup; usually only Windows, but possibly some Unix?
3947 4175
 	if (!isset($host) && stripos(PHP_OS, 'win') !== false && strpos(strtolower(PHP_OS), 'darwin') === false && mt_rand(0, 1) == 1)
3948 4176
 	{
3949 4177
 		$test = @shell_exec('nslookup -timeout=1 ' . @escapeshellarg($ip));
3950
-		if (strpos($test, 'Non-existent domain') !== false)
3951
-			$host = '';
3952
-		elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1)
3953
-			$host = $match[1];
4178
+		if (strpos($test, 'Non-existent domain') !== false) {
4179
+					$host = '';
4180
+		} elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1) {
4181
+					$host = $match[1];
4182
+		}
3954 4183
 	}
3955 4184
 
3956 4185
 	// This is the last try :/.
3957
-	if (!isset($host) || $host === false)
3958
-		$host = @gethostbyaddr($ip);
4186
+	if (!isset($host) || $host === false) {
4187
+			$host = @gethostbyaddr($ip);
4188
+	}
3959 4189
 
3960 4190
 	// It took a long time, so let's cache it!
3961
-	if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5)
3962
-		cache_put_data('hostlookup-' . $ip, $host, 600);
4191
+	if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5) {
4192
+			cache_put_data('hostlookup-' . $ip, $host, 600);
4193
+	}
3963 4194
 
3964 4195
 	return $host;
3965 4196
 }
@@ -3995,20 +4226,21 @@  discard block
 block discarded – undo
3995 4226
 			{
3996 4227
 				$encrypted = substr(crypt($word, 'uk'), 2, $max_chars);
3997 4228
 				$total = 0;
3998
-				for ($i = 0; $i < $max_chars; $i++)
3999
-					$total += $possible_chars[ord($encrypted{$i})] * pow(63, $i);
4229
+				for ($i = 0; $i < $max_chars; $i++) {
4230
+									$total += $possible_chars[ord($encrypted{$i})] * pow(63, $i);
4231
+				}
4000 4232
 				$returned_ints[] = $max_chars == 4 ? min($total, 16777215) : $total;
4001 4233
 			}
4002 4234
 		}
4003 4235
 		return array_unique($returned_ints);
4004
-	}
4005
-	else
4236
+	} else
4006 4237
 	{
4007 4238
 		// Trim characters before and after and add slashes for database insertion.
4008 4239
 		$returned_words = array();
4009
-		foreach ($words as $word)
4010
-			if (($word = trim($word, '-_\'')) !== '')
4240
+		foreach ($words as $word) {
4241
+					if (($word = trim($word, '-_\'')) !== '')
4011 4242
 				$returned_words[] = $max_chars === null ? $word : substr($word, 0, $max_chars);
4243
+		}
4012 4244
 
4013 4245
 		// Filter out all words that occur more than once.
4014 4246
 		return array_unique($returned_words);
@@ -4030,16 +4262,18 @@  discard block
 block discarded – undo
4030 4262
 	global $settings, $txt;
4031 4263
 
4032 4264
 	// Does the current loaded theme have this and we are not forcing the usage of this function?
4033
-	if (function_exists('template_create_button') && !$force_use)
4034
-		return template_create_button($name, $alt, $label = '', $custom = '');
4265
+	if (function_exists('template_create_button') && !$force_use) {
4266
+			return template_create_button($name, $alt, $label = '', $custom = '');
4267
+	}
4035 4268
 
4036
-	if (!$settings['use_image_buttons'])
4037
-		return $txt[$alt];
4038
-	elseif (!empty($settings['use_buttons']))
4039
-		return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? '&nbsp;<strong>' . $txt[$label] . '</strong>' : '');
4040
-	else
4041
-		return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>';
4042
-}
4269
+	if (!$settings['use_image_buttons']) {
4270
+			return $txt[$alt];
4271
+	} elseif (!empty($settings['use_buttons'])) {
4272
+			return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? '&nbsp;<strong>' . $txt[$label] . '</strong>' : '');
4273
+	} else {
4274
+			return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>';
4275
+	}
4276
+	}
4043 4277
 
4044 4278
 /**
4045 4279
  * Sets up all of the top menu buttons
@@ -4082,9 +4316,10 @@  discard block
 block discarded – undo
4082 4316
 	var user_menus = new smc_PopupMenu();
4083 4317
 	user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup");
4084 4318
 	user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true);
4085
-		if ($context['allow_pm'])
4086
-			addInlineJavaScript('
4319
+		if ($context['allow_pm']) {
4320
+					addInlineJavaScript('
4087 4321
 	user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true);
4322
+		}
4088 4323
 
4089 4324
 		if (!empty($modSettings['enable_ajax_alerts']))
4090 4325
 		{
@@ -4244,88 +4479,96 @@  discard block
 block discarded – undo
4244 4479
 
4245 4480
 		// Now we put the buttons in the context so the theme can use them.
4246 4481
 		$menu_buttons = array();
4247
-		foreach ($buttons as $act => $button)
4248
-			if (!empty($button['show']))
4482
+		foreach ($buttons as $act => $button) {
4483
+					if (!empty($button['show']))
4249 4484
 			{
4250 4485
 				$button['active_button'] = false;
4486
+		}
4251 4487
 
4252 4488
 				// This button needs some action.
4253
-				if (isset($button['action_hook']))
4254
-					$needs_action_hook = true;
4489
+				if (isset($button['action_hook'])) {
4490
+									$needs_action_hook = true;
4491
+				}
4255 4492
 
4256 4493
 				// Make sure the last button truly is the last button.
4257 4494
 				if (!empty($button['is_last']))
4258 4495
 				{
4259
-					if (isset($last_button))
4260
-						unset($menu_buttons[$last_button]['is_last']);
4496
+					if (isset($last_button)) {
4497
+											unset($menu_buttons[$last_button]['is_last']);
4498
+					}
4261 4499
 					$last_button = $act;
4262 4500
 				}
4263 4501
 
4264 4502
 				// Go through the sub buttons if there are any.
4265
-				if (!empty($button['sub_buttons']))
4266
-					foreach ($button['sub_buttons'] as $key => $subbutton)
4503
+				if (!empty($button['sub_buttons'])) {
4504
+									foreach ($button['sub_buttons'] as $key => $subbutton)
4267 4505
 					{
4268 4506
 						if (empty($subbutton['show']))
4269 4507
 							unset($button['sub_buttons'][$key]);
4508
+				}
4270 4509
 
4271 4510
 						// 2nd level sub buttons next...
4272 4511
 						if (!empty($subbutton['sub_buttons']))
4273 4512
 						{
4274 4513
 							foreach ($subbutton['sub_buttons'] as $key2 => $sub_button2)
4275 4514
 							{
4276
-								if (empty($sub_button2['show']))
4277
-									unset($button['sub_buttons'][$key]['sub_buttons'][$key2]);
4515
+								if (empty($sub_button2['show'])) {
4516
+																	unset($button['sub_buttons'][$key]['sub_buttons'][$key2]);
4517
+								}
4278 4518
 							}
4279 4519
 						}
4280 4520
 					}
4281 4521
 
4282 4522
 				// Does this button have its own icon?
4283
-				if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon']))
4284
-					$button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">';
4285
-				elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon']))
4286
-					$button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">';
4287
-				elseif (isset($button['icon']))
4288
-					$button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>';
4289
-				else
4290
-					$button['icon'] = '<span class="generic_icons ' . $act . '"></span>';
4523
+				if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon'])) {
4524
+									$button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">';
4525
+				} elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon'])) {
4526
+									$button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">';
4527
+				} elseif (isset($button['icon'])) {
4528
+									$button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>';
4529
+				} else {
4530
+									$button['icon'] = '<span class="generic_icons ' . $act . '"></span>';
4531
+				}
4291 4532
 
4292 4533
 				$menu_buttons[$act] = $button;
4293 4534
 			}
4294 4535
 
4295
-		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
4296
-			cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime);
4536
+		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
4537
+					cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime);
4538
+		}
4297 4539
 	}
4298 4540
 
4299 4541
 	$context['menu_buttons'] = $menu_buttons;
4300 4542
 
4301 4543
 	// Logging out requires the session id in the url.
4302
-	if (isset($context['menu_buttons']['logout']))
4303
-		$context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']);
4544
+	if (isset($context['menu_buttons']['logout'])) {
4545
+			$context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']);
4546
+	}
4304 4547
 
4305 4548
 	// Figure out which action we are doing so we can set the active tab.
4306 4549
 	// Default to home.
4307 4550
 	$current_action = 'home';
4308 4551
 
4309
-	if (isset($context['menu_buttons'][$context['current_action']]))
4310
-		$current_action = $context['current_action'];
4311
-	elseif ($context['current_action'] == 'search2')
4312
-		$current_action = 'search';
4313
-	elseif ($context['current_action'] == 'theme')
4314
-		$current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin';
4315
-	elseif ($context['current_action'] == 'register2')
4316
-		$current_action = 'register';
4317
-	elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder'))
4318
-		$current_action = 'login';
4319
-	elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center'])
4320
-		$current_action = 'moderate';
4552
+	if (isset($context['menu_buttons'][$context['current_action']])) {
4553
+			$current_action = $context['current_action'];
4554
+	} elseif ($context['current_action'] == 'search2') {
4555
+			$current_action = 'search';
4556
+	} elseif ($context['current_action'] == 'theme') {
4557
+			$current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin';
4558
+	} elseif ($context['current_action'] == 'register2') {
4559
+			$current_action = 'register';
4560
+	} elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder')) {
4561
+			$current_action = 'login';
4562
+	} elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) {
4563
+			$current_action = 'moderate';
4564
+	}
4321 4565
 
4322 4566
 	// There are certain exceptions to the above where we don't want anything on the menu highlighted.
4323 4567
 	if ($context['current_action'] == 'profile' && !empty($context['user']['is_owner']))
4324 4568
 	{
4325 4569
 		$current_action = !empty($_GET['area']) && $_GET['area'] == 'showalerts' ? 'self_alerts' : 'self_profile';
4326 4570
 		$context[$current_action] = true;
4327
-	}
4328
-	elseif ($context['current_action'] == 'pm')
4571
+	} elseif ($context['current_action'] == 'pm')
4329 4572
 	{
4330 4573
 		$current_action = 'self_pm';
4331 4574
 		$context['self_pm'] = true;
@@ -4366,12 +4609,14 @@  discard block
 block discarded – undo
4366 4609
 	}
4367 4610
 
4368 4611
 	// Not all actions are simple.
4369
-	if (!empty($needs_action_hook))
4370
-		call_integration_hook('integrate_current_action', array(&$current_action));
4612
+	if (!empty($needs_action_hook)) {
4613
+			call_integration_hook('integrate_current_action', array(&$current_action));
4614
+	}
4371 4615
 
4372
-	if (isset($context['menu_buttons'][$current_action]))
4373
-		$context['menu_buttons'][$current_action]['active_button'] = true;
4374
-}
4616
+	if (isset($context['menu_buttons'][$current_action])) {
4617
+			$context['menu_buttons'][$current_action]['active_button'] = true;
4618
+	}
4619
+	}
4375 4620
 
4376 4621
 /**
4377 4622
  * Generate a random seed and ensure it's stored in settings.
@@ -4395,30 +4640,35 @@  discard block
 block discarded – undo
4395 4640
 	global $modSettings, $settings, $boarddir, $sourcedir, $db_show_debug;
4396 4641
 	global $context, $txt;
4397 4642
 
4398
-	if ($db_show_debug === true)
4399
-		$context['debug']['hooks'][] = $hook;
4643
+	if ($db_show_debug === true) {
4644
+			$context['debug']['hooks'][] = $hook;
4645
+	}
4400 4646
 
4401 4647
 	// Need to have some control.
4402
-	if (!isset($context['instances']))
4403
-		$context['instances'] = array();
4648
+	if (!isset($context['instances'])) {
4649
+			$context['instances'] = array();
4650
+	}
4404 4651
 
4405 4652
 	$results = array();
4406
-	if (empty($modSettings[$hook]))
4407
-		return $results;
4653
+	if (empty($modSettings[$hook])) {
4654
+			return $results;
4655
+	}
4408 4656
 
4409 4657
 	$functions = explode(',', $modSettings[$hook]);
4410 4658
 	// Loop through each function.
4411 4659
 	foreach ($functions as $function)
4412 4660
 	{
4413 4661
 		// Hook has been marked as "disabled". Skip it!
4414
-		if (strpos($function, '!') !== false)
4415
-			continue;
4662
+		if (strpos($function, '!') !== false) {
4663
+					continue;
4664
+		}
4416 4665
 
4417 4666
 		$call = call_helper($function, true);
4418 4667
 
4419 4668
 		// Is it valid?
4420
-		if (!empty($call))
4421
-			$results[$function] = call_user_func_array($call, $parameters);
4669
+		if (!empty($call)) {
4670
+					$results[$function] = call_user_func_array($call, $parameters);
4671
+		}
4422 4672
 
4423 4673
 		// Whatever it was suppose to call, it failed :(
4424 4674
 		elseif (!empty($function))
@@ -4434,8 +4684,9 @@  discard block
 block discarded – undo
4434 4684
 			}
4435 4685
 
4436 4686
 			// "Assume" the file resides on $boarddir somewhere...
4437
-			else
4438
-				log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general');
4687
+			else {
4688
+							log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general');
4689
+			}
4439 4690
 		}
4440 4691
 	}
4441 4692
 
@@ -4457,12 +4708,14 @@  discard block
 block discarded – undo
4457 4708
 	global $smcFunc, $modSettings;
4458 4709
 
4459 4710
 	// Any objects?
4460
-	if ($object)
4461
-		$function = $function . '#';
4711
+	if ($object) {
4712
+			$function = $function . '#';
4713
+	}
4462 4714
 
4463 4715
 	// Any files  to load?
4464
-	if (!empty($file) && is_string($file))
4465
-		$function = $file . (!empty($function) ? '|' . $function : '');
4716
+	if (!empty($file) && is_string($file)) {
4717
+			$function = $file . (!empty($function) ? '|' . $function : '');
4718
+	}
4466 4719
 
4467 4720
 	// Get the correct string.
4468 4721
 	$integration_call = $function;
@@ -4484,13 +4737,14 @@  discard block
 block discarded – undo
4484 4737
 		if (!empty($current_functions))
4485 4738
 		{
4486 4739
 			$current_functions = explode(',', $current_functions);
4487
-			if (in_array($integration_call, $current_functions))
4488
-				return;
4740
+			if (in_array($integration_call, $current_functions)) {
4741
+							return;
4742
+			}
4489 4743
 
4490 4744
 			$permanent_functions = array_merge($current_functions, array($integration_call));
4745
+		} else {
4746
+					$permanent_functions = array($integration_call);
4491 4747
 		}
4492
-		else
4493
-			$permanent_functions = array($integration_call);
4494 4748
 
4495 4749
 		updateSettings(array($hook => implode(',', $permanent_functions)));
4496 4750
 	}
@@ -4499,8 +4753,9 @@  discard block
 block discarded – undo
4499 4753
 	$functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]);
4500 4754
 
4501 4755
 	// Do nothing, if it's already there.
4502
-	if (in_array($integration_call, $functions))
4503
-		return;
4756
+	if (in_array($integration_call, $functions)) {
4757
+			return;
4758
+	}
4504 4759
 
4505 4760
 	$functions[] = $integration_call;
4506 4761
 	$modSettings[$hook] = implode(',', $functions);
@@ -4523,12 +4778,14 @@  discard block
 block discarded – undo
4523 4778
 	global $smcFunc, $modSettings;
4524 4779
 
4525 4780
 	// Any objects?
4526
-	if ($object)
4527
-		$function = $function . '#';
4781
+	if ($object) {
4782
+			$function = $function . '#';
4783
+	}
4528 4784
 
4529 4785
 	// Any files  to load?
4530
-	if (!empty($file) && is_string($file))
4531
-		$function = $file . '|' . $function;
4786
+	if (!empty($file) && is_string($file)) {
4787
+			$function = $file . '|' . $function;
4788
+	}
4532 4789
 
4533 4790
 	// Get the correct string.
4534 4791
 	$integration_call = $function;
@@ -4549,16 +4806,18 @@  discard block
 block discarded – undo
4549 4806
 	{
4550 4807
 		$current_functions = explode(',', $current_functions);
4551 4808
 
4552
-		if (in_array($integration_call, $current_functions))
4553
-			updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call)))));
4809
+		if (in_array($integration_call, $current_functions)) {
4810
+					updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call)))));
4811
+		}
4554 4812
 	}
4555 4813
 
4556 4814
 	// Turn the function list into something usable.
4557 4815
 	$functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]);
4558 4816
 
4559 4817
 	// You can only remove it if it's available.
4560
-	if (!in_array($integration_call, $functions))
4561
-		return;
4818
+	if (!in_array($integration_call, $functions)) {
4819
+			return;
4820
+	}
4562 4821
 
4563 4822
 	$functions = array_diff($functions, array($integration_call));
4564 4823
 	$modSettings[$hook] = implode(',', $functions);
@@ -4579,17 +4838,20 @@  discard block
 block discarded – undo
4579 4838
 	global $context, $smcFunc, $txt, $db_show_debug;
4580 4839
 
4581 4840
 	// Really?
4582
-	if (empty($string))
4583
-		return false;
4841
+	if (empty($string)) {
4842
+			return false;
4843
+	}
4584 4844
 
4585 4845
 	// An array? should be a "callable" array IE array(object/class, valid_callable).
4586 4846
 	// A closure? should be a callable one.
4587
-	if (is_array($string) || $string instanceof Closure)
4588
-		return $return ? $string : (is_callable($string) ? call_user_func($string) : false);
4847
+	if (is_array($string) || $string instanceof Closure) {
4848
+			return $return ? $string : (is_callable($string) ? call_user_func($string) : false);
4849
+	}
4589 4850
 
4590 4851
 	// No full objects, sorry! pass a method or a property instead!
4591
-	if (is_object($string))
4592
-		return false;
4852
+	if (is_object($string)) {
4853
+			return false;
4854
+	}
4593 4855
 
4594 4856
 	// Stay vitaminized my friends...
4595 4857
 	$string = $smcFunc['htmlspecialchars']($smcFunc['htmltrim']($string));
@@ -4598,8 +4860,9 @@  discard block
 block discarded – undo
4598 4860
 	$string = load_file($string);
4599 4861
 
4600 4862
 	// Loaded file failed
4601
-	if (empty($string))
4602
-		return false;
4863
+	if (empty($string)) {
4864
+			return false;
4865
+	}
4603 4866
 
4604 4867
 	// Found a method.
4605 4868
 	if (strpos($string, '::') !== false)
@@ -4620,8 +4883,9 @@  discard block
 block discarded – undo
4620 4883
 				// Add another one to the list.
4621 4884
 				if ($db_show_debug === true)
4622 4885
 				{
4623
-					if (!isset($context['debug']['instances']))
4624
-						$context['debug']['instances'] = array();
4886
+					if (!isset($context['debug']['instances'])) {
4887
+											$context['debug']['instances'] = array();
4888
+					}
4625 4889
 
4626 4890
 					$context['debug']['instances'][$class] = $class;
4627 4891
 				}
@@ -4631,13 +4895,15 @@  discard block
 block discarded – undo
4631 4895
 		}
4632 4896
 
4633 4897
 		// Right then. This is a call to a static method.
4634
-		else
4635
-			$func = array($class, $method);
4898
+		else {
4899
+					$func = array($class, $method);
4900
+		}
4636 4901
 	}
4637 4902
 
4638 4903
 	// Nope! just a plain regular function.
4639
-	else
4640
-		$func = $string;
4904
+	else {
4905
+			$func = $string;
4906
+	}
4641 4907
 
4642 4908
 	// Right, we got what we need, time to do some checks.
4643 4909
 	if (!is_callable($func, false, $callable_name))
@@ -4653,17 +4919,18 @@  discard block
 block discarded – undo
4653 4919
 	else
4654 4920
 	{
4655 4921
 		// What are we gonna do about it?
4656
-		if ($return)
4657
-			return $func;
4922
+		if ($return) {
4923
+					return $func;
4924
+		}
4658 4925
 
4659 4926
 		// If this is a plain function, avoid the heat of calling call_user_func().
4660 4927
 		else
4661 4928
 		{
4662
-			if (is_array($func))
4663
-				call_user_func($func);
4664
-
4665
-			else
4666
-				$func();
4929
+			if (is_array($func)) {
4930
+							call_user_func($func);
4931
+			} else {
4932
+							$func();
4933
+			}
4667 4934
 		}
4668 4935
 	}
4669 4936
 }
@@ -4680,31 +4947,34 @@  discard block
 block discarded – undo
4680 4947
 {
4681 4948
 	global $sourcedir, $txt, $boarddir, $settings;
4682 4949
 
4683
-	if (empty($string))
4684
-		return false;
4950
+	if (empty($string)) {
4951
+			return false;
4952
+	}
4685 4953
 
4686 4954
 	if (strpos($string, '|') !== false)
4687 4955
 	{
4688 4956
 		list ($file, $string) = explode('|', $string);
4689 4957
 
4690 4958
 		// Match the wildcards to their regular vars.
4691
-		if (empty($settings['theme_dir']))
4692
-			$absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir));
4693
-
4694
-		else
4695
-			$absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir']));
4959
+		if (empty($settings['theme_dir'])) {
4960
+					$absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir));
4961
+		} else {
4962
+					$absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir']));
4963
+		}
4696 4964
 
4697 4965
 		// Load the file if it can be loaded.
4698
-		if (file_exists($absPath))
4699
-			require_once($absPath);
4966
+		if (file_exists($absPath)) {
4967
+					require_once($absPath);
4968
+		}
4700 4969
 
4701 4970
 		// No? try a fallback to $sourcedir
4702 4971
 		else
4703 4972
 		{
4704 4973
 			$absPath = $sourcedir .'/'. $file;
4705 4974
 
4706
-			if (file_exists($absPath))
4707
-				require_once($absPath);
4975
+			if (file_exists($absPath)) {
4976
+							require_once($absPath);
4977
+			}
4708 4978
 
4709 4979
 			// Sorry, can't do much for you at this point.
4710 4980
 			else
@@ -4731,8 +5001,9 @@  discard block
 block discarded – undo
4731 5001
 	global $user_info, $smcFunc;
4732 5002
 
4733 5003
 	// Make sure we have something to work with.
4734
-	if (empty($topic))
4735
-		return array();
5004
+	if (empty($topic)) {
5005
+			return array();
5006
+	}
4736 5007
 
4737 5008
 
4738 5009
 	// We already know the number of likes per message, we just want to know whether the current user liked it or not.
@@ -4755,8 +5026,9 @@  discard block
 block discarded – undo
4755 5026
 				'topic' => $topic,
4756 5027
 			)
4757 5028
 		);
4758
-		while ($row = $smcFunc['db_fetch_assoc']($request))
4759
-			$temp[] = (int) $row['content_id'];
5029
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
5030
+					$temp[] = (int) $row['content_id'];
5031
+		}
4760 5032
 
4761 5033
 		cache_put_data($cache_key, $temp, $ttl);
4762 5034
 	}
@@ -4777,8 +5049,9 @@  discard block
 block discarded – undo
4777 5049
 {
4778 5050
 	global $context;
4779 5051
 
4780
-	if (empty($string))
4781
-		return $string;
5052
+	if (empty($string)) {
5053
+			return $string;
5054
+	}
4782 5055
 
4783 5056
 	// UTF-8 occurences of MS special characters
4784 5057
 	$findchars_utf8 = array(
@@ -4819,10 +5092,11 @@  discard block
 block discarded – undo
4819 5092
 		'--',	// &mdash;
4820 5093
 	);
4821 5094
 
4822
-	if ($context['utf8'])
4823
-		$string = str_replace($findchars_utf8, $replacechars, $string);
4824
-	else
4825
-		$string = str_replace($findchars_iso, $replacechars, $string);
5095
+	if ($context['utf8']) {
5096
+			$string = str_replace($findchars_utf8, $replacechars, $string);
5097
+	} else {
5098
+			$string = str_replace($findchars_iso, $replacechars, $string);
5099
+	}
4826 5100
 
4827 5101
 	return $string;
4828 5102
 }
@@ -4841,49 +5115,59 @@  discard block
 block discarded – undo
4841 5115
 {
4842 5116
 	global $context;
4843 5117
 
4844
-	if (!isset($matches[2]))
4845
-		return '';
5118
+	if (!isset($matches[2])) {
5119
+			return '';
5120
+	}
4846 5121
 
4847 5122
 	$num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2];
4848 5123
 
4849 5124
 	// remove left to right / right to left overrides
4850
-	if ($num === 0x202D || $num === 0x202E)
4851
-		return '';
5125
+	if ($num === 0x202D || $num === 0x202E) {
5126
+			return '';
5127
+	}
4852 5128
 
4853 5129
 	// Quote, Ampersand, Apostrophe, Less/Greater Than get html replaced
4854
-	if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E)))
4855
-		return '&#' . $num . ';';
5130
+	if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) {
5131
+			return '&#' . $num . ';';
5132
+	}
4856 5133
 
4857 5134
 	if (empty($context['utf8']))
4858 5135
 	{
4859 5136
 		// no control characters
4860
-		if ($num < 0x20)
4861
-			return '';
5137
+		if ($num < 0x20) {
5138
+					return '';
5139
+		}
4862 5140
 		// text is text
4863
-		elseif ($num < 0x80)
4864
-			return chr($num);
5141
+		elseif ($num < 0x80) {
5142
+					return chr($num);
5143
+		}
4865 5144
 		// all others get html-ised
4866
-		else
4867
-			return '&#' . $matches[2] . ';';
4868
-	}
4869
-	else
5145
+		else {
5146
+					return '&#' . $matches[2] . ';';
5147
+		}
5148
+	} else
4870 5149
 	{
4871 5150
 		// <0x20 are control characters, 0x20 is a space, > 0x10FFFF is past the end of the utf8 character set
4872 5151
 		// 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text)
4873
-		if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF))
4874
-			return '';
5152
+		if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF)) {
5153
+					return '';
5154
+		}
4875 5155
 		// <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation
4876
-		elseif ($num < 0x80)
4877
-			return chr($num);
5156
+		elseif ($num < 0x80) {
5157
+					return chr($num);
5158
+		}
4878 5159
 		// <0x800 (2048)
4879
-		elseif ($num < 0x800)
4880
-			return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
5160
+		elseif ($num < 0x800) {
5161
+					return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
5162
+		}
4881 5163
 		// < 0x10000 (65536)
4882
-		elseif ($num < 0x10000)
4883
-			return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5164
+		elseif ($num < 0x10000) {
5165
+					return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5166
+		}
4884 5167
 		// <= 0x10FFFF (1114111)
4885
-		else
4886
-			return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5168
+		else {
5169
+					return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5170
+		}
4887 5171
 	}
4888 5172
 }
4889 5173
 
@@ -4899,28 +5183,34 @@  discard block
 block discarded – undo
4899 5183
  */
4900 5184
 function fixchar__callback($matches)
4901 5185
 {
4902
-	if (!isset($matches[1]))
4903
-		return '';
5186
+	if (!isset($matches[1])) {
5187
+			return '';
5188
+	}
4904 5189
 
4905 5190
 	$num = $matches[1][0] === 'x' ? hexdec(substr($matches[1], 1)) : (int) $matches[1];
4906 5191
 
4907 5192
 	// <0x20 are control characters, > 0x10FFFF is past the end of the utf8 character set
4908 5193
 	// 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text), 0x202D-E are left to right overrides
4909
-	if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E)
4910
-		return '';
5194
+	if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E) {
5195
+			return '';
5196
+	}
4911 5197
 	// <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation
4912
-	elseif ($num < 0x80)
4913
-		return chr($num);
5198
+	elseif ($num < 0x80) {
5199
+			return chr($num);
5200
+	}
4914 5201
 	// <0x800 (2048)
4915
-	elseif ($num < 0x800)
4916
-		return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
5202
+	elseif ($num < 0x800) {
5203
+			return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
5204
+	}
4917 5205
 	// < 0x10000 (65536)
4918
-	elseif ($num < 0x10000)
4919
-		return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5206
+	elseif ($num < 0x10000) {
5207
+			return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5208
+	}
4920 5209
 	// <= 0x10FFFF (1114111)
4921
-	else
4922
-		return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
4923
-}
5210
+	else {
5211
+			return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
5212
+	}
5213
+	}
4924 5214
 
4925 5215
 /**
4926 5216
  * Strips out invalid html entities, replaces others with html style &#123; codes
@@ -4933,17 +5223,19 @@  discard block
 block discarded – undo
4933 5223
  */
4934 5224
 function entity_fix__callback($matches)
4935 5225
 {
4936
-	if (!isset($matches[2]))
4937
-		return '';
5226
+	if (!isset($matches[2])) {
5227
+			return '';
5228
+	}
4938 5229
 
4939 5230
 	$num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2];
4940 5231
 
4941 5232
 	// we don't allow control characters, characters out of range, byte markers, etc
4942
-	if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E)
4943
-		return '';
4944
-	else
4945
-		return '&#' . $num . ';';
4946
-}
5233
+	if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E) {
5234
+			return '';
5235
+	} else {
5236
+			return '&#' . $num . ';';
5237
+	}
5238
+	}
4947 5239
 
4948 5240
 /**
4949 5241
  * Return a Gravatar URL based on
@@ -4967,18 +5259,23 @@  discard block
 block discarded – undo
4967 5259
 		$ratings = array('G', 'PG', 'R', 'X');
4968 5260
 		$defaults = array('mm', 'identicon', 'monsterid', 'wavatar', 'retro', 'blank');
4969 5261
 		$url_params = array();
4970
-		if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings))
4971
-			$url_params[] = 'rating=' . $modSettings['gravatarMaxRating'];
4972
-		if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults))
4973
-			$url_params[] = 'default=' . $modSettings['gravatarDefault'];
4974
-		if (!empty($modSettings['avatar_max_width_external']))
4975
-			$size_string = (int) $modSettings['avatar_max_width_external'];
4976
-		if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string))
4977
-			if ((int) $modSettings['avatar_max_height_external'] < $size_string)
5262
+		if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings)) {
5263
+					$url_params[] = 'rating=' . $modSettings['gravatarMaxRating'];
5264
+		}
5265
+		if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults)) {
5266
+					$url_params[] = 'default=' . $modSettings['gravatarDefault'];
5267
+		}
5268
+		if (!empty($modSettings['avatar_max_width_external'])) {
5269
+					$size_string = (int) $modSettings['avatar_max_width_external'];
5270
+		}
5271
+		if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string)) {
5272
+					if ((int) $modSettings['avatar_max_height_external'] < $size_string)
4978 5273
 				$size_string = $modSettings['avatar_max_height_external'];
5274
+		}
4979 5275
 
4980
-		if (!empty($size_string))
4981
-			$url_params[] = 's=' . $size_string;
5276
+		if (!empty($size_string)) {
5277
+					$url_params[] = 's=' . $size_string;
5278
+		}
4982 5279
 	}
4983 5280
 	$http_method = !empty($modSettings['force_ssl']) && $modSettings['force_ssl'] == 2 ? 'https://secure' : 'http://www';
4984 5281
 
@@ -4997,22 +5294,26 @@  discard block
 block discarded – undo
4997 5294
 	static $timezones = null, $lastwhen = null;
4998 5295
 
4999 5296
 	// No point doing this over if we already did it once
5000
-	if (!empty($timezones) && $when == $lastwhen)
5001
-		return $timezones;
5002
-	else
5003
-		$lastwhen = $when;
5297
+	if (!empty($timezones) && $when == $lastwhen) {
5298
+			return $timezones;
5299
+	} else {
5300
+			$lastwhen = $when;
5301
+	}
5004 5302
 
5005 5303
 	// Parseable datetime string?
5006
-	if (is_int($timestamp = strtotime($when)))
5007
-		$when = $timestamp;
5304
+	if (is_int($timestamp = strtotime($when))) {
5305
+			$when = $timestamp;
5306
+	}
5008 5307
 
5009 5308
 	// A Unix timestamp?
5010
-	elseif (is_numeric($when))
5011
-		$when = intval($when);
5309
+	elseif (is_numeric($when)) {
5310
+			$when = intval($when);
5311
+	}
5012 5312
 
5013 5313
 	// Invalid value? Just get current Unix timestamp.
5014
-	else
5015
-		$when = time();
5314
+	else {
5315
+			$when = time();
5316
+	}
5016 5317
 
5017 5318
 	// We'll need these too
5018 5319
 	$date_when = date_create('@' . $when);
@@ -5076,8 +5377,9 @@  discard block
 block discarded – undo
5076 5377
 	foreach ($priority_countries as $country)
5077 5378
 	{
5078 5379
 		$country_tzids = @timezone_identifiers_list(DateTimeZone::PER_COUNTRY, strtoupper(trim($country)));
5079
-		if (!empty($country_tzids))
5080
-			$priority_tzids = array_merge($priority_tzids, $country_tzids);
5380
+		if (!empty($country_tzids)) {
5381
+					$priority_tzids = array_merge($priority_tzids, $country_tzids);
5382
+		}
5081 5383
 	}
5082 5384
 
5083 5385
 	// Process the preferred timezones first, then the rest.
@@ -5087,8 +5389,9 @@  discard block
 block discarded – undo
5087 5389
 	foreach ($tzids as $tzid)
5088 5390
 	{
5089 5391
 		// We don't want UTC right now
5090
-		if ($tzid == 'UTC')
5091
-			continue;
5392
+		if ($tzid == 'UTC') {
5393
+					continue;
5394
+		}
5092 5395
 
5093 5396
 		$tz = timezone_open($tzid);
5094 5397
 
@@ -5109,8 +5412,9 @@  discard block
 block discarded – undo
5109 5412
 		}
5110 5413
 
5111 5414
 		// A time zone from a prioritized country?
5112
-		if (in_array($tzid, $priority_tzids))
5113
-			$priority_zones[$tzkey] = true;
5415
+		if (in_array($tzid, $priority_tzids)) {
5416
+					$priority_zones[$tzkey] = true;
5417
+		}
5114 5418
 
5115 5419
 		// Keep track of the location and offset for this tzid
5116 5420
 		$tzid_parts = explode('/', $tzid);
@@ -5129,15 +5433,17 @@  discard block
 block discarded – undo
5129 5433
 	{
5130 5434
 		date_timezone_set($date_when, timezone_open($tzvalue['tzid']));
5131 5435
 
5132
-		if (!empty($timezone_descriptions[$tzvalue['tzid']]))
5133
-			$desc = $timezone_descriptions[$tzvalue['tzid']];
5134
-		else
5135
-			$desc = implode(', ', array_unique($tzvalue['locations']));
5436
+		if (!empty($timezone_descriptions[$tzvalue['tzid']])) {
5437
+					$desc = $timezone_descriptions[$tzvalue['tzid']];
5438
+		} else {
5439
+					$desc = implode(', ', array_unique($tzvalue['locations']));
5440
+		}
5136 5441
 
5137
-		if (isset($priority_zones[$tzkey]))
5138
-			$priority_timezones[$tzvalue['tzid']] = $tzvalue['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']';
5139
-		else
5140
-			$timezones[$tzvalue['tzid']] = $tzvalue['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']';
5442
+		if (isset($priority_zones[$tzkey])) {
5443
+					$priority_timezones[$tzvalue['tzid']] = $tzvalue['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']';
5444
+		} else {
5445
+					$timezones[$tzvalue['tzid']] = $tzvalue['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']';
5446
+		}
5141 5447
 	}
5142 5448
 
5143 5449
 	$timezones = array_merge(
@@ -5191,9 +5497,9 @@  discard block
 block discarded – undo
5191 5497
 			'Indian/Kerguelen' => 'TFT',
5192 5498
 		);
5193 5499
 
5194
-		if (!empty($missing_tz_abbrs[$tzid]))
5195
-			$tz_abbrev = $missing_tz_abbrs[$tzid];
5196
-		else
5500
+		if (!empty($missing_tz_abbrs[$tzid])) {
5501
+					$tz_abbrev = $missing_tz_abbrs[$tzid];
5502
+		} else
5197 5503
 		{
5198 5504
 			// Russia likes to experiment with time zones often, and names them as offsets from Moscow
5199 5505
 			$tz_location = timezone_location_get(timezone_open($tzid));
@@ -5221,8 +5527,9 @@  discard block
 block discarded – undo
5221 5527
  */
5222 5528
 function inet_ptod($ip_address)
5223 5529
 {
5224
-	if (!isValidIP($ip_address))
5225
-		return $ip_address;
5530
+	if (!isValidIP($ip_address)) {
5531
+			return $ip_address;
5532
+	}
5226 5533
 
5227 5534
 	$bin = inet_pton($ip_address);
5228 5535
 	return $bin;
@@ -5234,13 +5541,15 @@  discard block
 block discarded – undo
5234 5541
  */
5235 5542
 function inet_dtop($bin)
5236 5543
 {
5237
-	if(empty($bin))
5238
-		return '';
5544
+	if(empty($bin)) {
5545
+			return '';
5546
+	}
5239 5547
 
5240 5548
 	global $db_type;
5241 5549
 
5242
-	if ($db_type == 'postgresql')
5243
-		return $bin;
5550
+	if ($db_type == 'postgresql') {
5551
+			return $bin;
5552
+	}
5244 5553
 
5245 5554
 	$ip_address = inet_ntop($bin);
5246 5555
 
@@ -5265,26 +5574,32 @@  discard block
 block discarded – undo
5265 5574
  */
5266 5575
 function _safe_serialize($value)
5267 5576
 {
5268
-	if(is_null($value))
5269
-		return 'N;';
5577
+	if(is_null($value)) {
5578
+			return 'N;';
5579
+	}
5270 5580
 
5271
-	if(is_bool($value))
5272
-		return 'b:'. (int) $value .';';
5581
+	if(is_bool($value)) {
5582
+			return 'b:'. (int) $value .';';
5583
+	}
5273 5584
 
5274
-	if(is_int($value))
5275
-		return 'i:'. $value .';';
5585
+	if(is_int($value)) {
5586
+			return 'i:'. $value .';';
5587
+	}
5276 5588
 
5277
-	if(is_float($value))
5278
-		return 'd:'. str_replace(',', '.', $value) .';';
5589
+	if(is_float($value)) {
5590
+			return 'd:'. str_replace(',', '.', $value) .';';
5591
+	}
5279 5592
 
5280
-	if(is_string($value))
5281
-		return 's:'. strlen($value) .':"'. $value .'";';
5593
+	if(is_string($value)) {
5594
+			return 's:'. strlen($value) .':"'. $value .'";';
5595
+	}
5282 5596
 
5283 5597
 	if(is_array($value))
5284 5598
 	{
5285 5599
 		$out = '';
5286
-		foreach($value as $k => $v)
5287
-			$out .= _safe_serialize($k) . _safe_serialize($v);
5600
+		foreach($value as $k => $v) {
5601
+					$out .= _safe_serialize($k) . _safe_serialize($v);
5602
+		}
5288 5603
 
5289 5604
 		return 'a:'. count($value) .':{'. $out .'}';
5290 5605
 	}
@@ -5310,8 +5625,9 @@  discard block
 block discarded – undo
5310 5625
 
5311 5626
 	$out = _safe_serialize($value);
5312 5627
 
5313
-	if (isset($mbIntEnc))
5314
-		mb_internal_encoding($mbIntEnc);
5628
+	if (isset($mbIntEnc)) {
5629
+			mb_internal_encoding($mbIntEnc);
5630
+	}
5315 5631
 
5316 5632
 	return $out;
5317 5633
 }
@@ -5328,8 +5644,9 @@  discard block
 block discarded – undo
5328 5644
 function _safe_unserialize($str)
5329 5645
 {
5330 5646
 	// Input  is not a string.
5331
-	if(empty($str) || !is_string($str))
5332
-		return false;
5647
+	if(empty($str) || !is_string($str)) {
5648
+			return false;
5649
+	}
5333 5650
 
5334 5651
 	$stack = array();
5335 5652
 	$expected = array();
@@ -5345,43 +5662,38 @@  discard block
 block discarded – undo
5345 5662
 	while($state != 1)
5346 5663
 	{
5347 5664
 		$type = isset($str[0]) ? $str[0] : '';
5348
-		if($type == '}')
5349
-			$str = substr($str, 1);
5350
-
5351
-		else if($type == 'N' && $str[1] == ';')
5665
+		if($type == '}') {
5666
+					$str = substr($str, 1);
5667
+		} else if($type == 'N' && $str[1] == ';')
5352 5668
 		{
5353 5669
 			$value = null;
5354 5670
 			$str = substr($str, 2);
5355
-		}
5356
-		else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches))
5671
+		} else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches))
5357 5672
 		{
5358 5673
 			$value = $matches[1] == '1' ? true : false;
5359 5674
 			$str = substr($str, 4);
5360
-		}
5361
-		else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches))
5675
+		} else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches))
5362 5676
 		{
5363 5677
 			$value = (int)$matches[1];
5364 5678
 			$str = $matches[2];
5365
-		}
5366
-		else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches))
5679
+		} else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches))
5367 5680
 		{
5368 5681
 			$value = (float)$matches[1];
5369 5682
 			$str = $matches[3];
5370
-		}
5371
-		else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";')
5683
+		} else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";')
5372 5684
 		{
5373 5685
 			$value = substr($matches[2], 0, (int)$matches[1]);
5374 5686
 			$str = substr($matches[2], (int)$matches[1] + 2);
5375
-		}
5376
-		else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches))
5687
+		} else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches))
5377 5688
 		{
5378 5689
 			$expectedLength = (int)$matches[1];
5379 5690
 			$str = $matches[2];
5380 5691
 		}
5381 5692
 
5382 5693
 		// Object or unknown/malformed type.
5383
-		else
5384
-			return false;
5694
+		else {
5695
+					return false;
5696
+		}
5385 5697
 
5386 5698
 		switch($state)
5387 5699
 		{
@@ -5409,8 +5721,9 @@  discard block
 block discarded – undo
5409 5721
 				if($type == '}')
5410 5722
 				{
5411 5723
 					// Array size is less than expected.
5412
-					if(count($list) < end($expected))
5413
-						return false;
5724
+					if(count($list) < end($expected)) {
5725
+											return false;
5726
+					}
5414 5727
 
5415 5728
 					unset($list);
5416 5729
 					$list = &$stack[count($stack)-1];
@@ -5419,8 +5732,9 @@  discard block
 block discarded – undo
5419 5732
 					// Go to terminal state if we're at the end of the root array.
5420 5733
 					array_pop($expected);
5421 5734
 
5422
-					if(count($expected) == 0)
5423
-						$state = 1;
5735
+					if(count($expected) == 0) {
5736
+											$state = 1;
5737
+					}
5424 5738
 
5425 5739
 					break;
5426 5740
 				}
@@ -5428,8 +5742,9 @@  discard block
 block discarded – undo
5428 5742
 				if($type == 'i' || $type == 's')
5429 5743
 				{
5430 5744
 					// Array size exceeds expected length.
5431
-					if(count($list) >= end($expected))
5432
-						return false;
5745
+					if(count($list) >= end($expected)) {
5746
+											return false;
5747
+					}
5433 5748
 
5434 5749
 					$key = $value;
5435 5750
 					$state = 3;
@@ -5463,8 +5778,9 @@  discard block
 block discarded – undo
5463 5778
 	}
5464 5779
 
5465 5780
 	// Trailing data in input.
5466
-	if(!empty($str))
5467
-		return false;
5781
+	if(!empty($str)) {
5782
+			return false;
5783
+	}
5468 5784
 
5469 5785
 	return $data;
5470 5786
 }
@@ -5487,8 +5803,9 @@  discard block
 block discarded – undo
5487 5803
 
5488 5804
 	$out = _safe_unserialize($str);
5489 5805
 
5490
-	if (isset($mbIntEnc))
5491
-		mb_internal_encoding($mbIntEnc);
5806
+	if (isset($mbIntEnc)) {
5807
+			mb_internal_encoding($mbIntEnc);
5808
+	}
5492 5809
 
5493 5810
 	return $out;
5494 5811
 }
@@ -5503,12 +5820,14 @@  discard block
 block discarded – undo
5503 5820
 function smf_chmod($file, $value = 0)
5504 5821
 {
5505 5822
 	// No file? no checks!
5506
-	if (empty($file))
5507
-		return false;
5823
+	if (empty($file)) {
5824
+			return false;
5825
+	}
5508 5826
 
5509 5827
 	// Already writable?
5510
-	if (is_writable($file))
5511
-		return true;
5828
+	if (is_writable($file)) {
5829
+			return true;
5830
+	}
5512 5831
 
5513 5832
 	// Do we have a file or a dir?
5514 5833
 	$isDir = is_dir($file);
@@ -5524,10 +5843,9 @@  discard block
 block discarded – undo
5524 5843
 		{
5525 5844
 			$isWritable = true;
5526 5845
 			break;
5846
+		} else {
5847
+					@chmod($file, $val);
5527 5848
 		}
5528
-
5529
-		else
5530
-			@chmod($file, $val);
5531 5849
 	}
5532 5850
 
5533 5851
 	return $isWritable;
@@ -5546,8 +5864,9 @@  discard block
 block discarded – undo
5546 5864
 	global $txt;
5547 5865
 
5548 5866
 	// Come on...
5549
-	if (empty($json) || !is_string($json))
5550
-		return array();
5867
+	if (empty($json) || !is_string($json)) {
5868
+			return array();
5869
+	}
5551 5870
 
5552 5871
 	$returnArray = @json_decode($json, $returnAsArray);
5553 5872
 
@@ -5585,11 +5904,11 @@  discard block
 block discarded – undo
5585 5904
 		$jsonDebug = $jsonDebug[0];
5586 5905
 		loadLanguage('Errors');
5587 5906
 
5588
-		if (!empty($jsonDebug))
5589
-			log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']);
5590
-
5591
-		else
5592
-			log_error($txt['json_'. $jsonError], 'critical');
5907
+		if (!empty($jsonDebug)) {
5908
+					log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']);
5909
+		} else {
5910
+					log_error($txt['json_'. $jsonError], 'critical');
5911
+		}
5593 5912
 
5594 5913
 		// Everyone expects an array.
5595 5914
 		return array();
@@ -5623,8 +5942,9 @@  discard block
 block discarded – undo
5623 5942
 	global $db_show_debug, $modSettings;
5624 5943
 
5625 5944
 	// Defensive programming anyone?
5626
-	if (empty($data))
5627
-		return false;
5945
+	if (empty($data)) {
5946
+			return false;
5947
+	}
5628 5948
 
5629 5949
 	// Don't need extra stuff...
5630 5950
 	$db_show_debug = false;
@@ -5632,11 +5952,11 @@  discard block
 block discarded – undo
5632 5952
 	// Kill anything else.
5633 5953
 	ob_end_clean();
5634 5954
 
5635
-	if (!empty($modSettings['CompressedOutput']))
5636
-		@ob_start('ob_gzhandler');
5637
-
5638
-	else
5639
-		ob_start();
5955
+	if (!empty($modSettings['CompressedOutput'])) {
5956
+			@ob_start('ob_gzhandler');
5957
+	} else {
5958
+			ob_start();
5959
+	}
5640 5960
 
5641 5961
 	// Set the header.
5642 5962
 	header($type);
@@ -5668,8 +5988,9 @@  discard block
 block discarded – undo
5668 5988
 	static $done = false;
5669 5989
 
5670 5990
 	// If we don't need to do anything, don't
5671
-	if (!$update && $done)
5672
-		return;
5991
+	if (!$update && $done) {
5992
+			return;
5993
+	}
5673 5994
 
5674 5995
 	// Should we get a new copy of the official list of TLDs?
5675 5996
 	if ($update)
@@ -5678,8 +5999,9 @@  discard block
 block discarded – undo
5678 5999
 		$tlds = fetch_web_data('https://data.iana.org/TLD/tlds-alpha-by-domain.txt');
5679 6000
 
5680 6001
 		// If the Internet Assigned Numbers Authority can't be reached, the Internet is gone. We're probably running on a server hidden in a bunker deep underground to protect it from marauding bandits roaming on the surface. We don't want to waste precious electricity on pointlessly repeating background tasks, so we'll wait until the next regularly scheduled update to see if civilization has been restored.
5681
-		if ($tlds === false)
5682
-			$postapocalypticNightmare = true;
6002
+		if ($tlds === false) {
6003
+					$postapocalypticNightmare = true;
6004
+		}
5683 6005
 	}
5684 6006
 	// If we aren't updating and the regex is valid, we're done
5685 6007
 	elseif (!empty($modSettings['tld_regex']) && @preg_match('~' . $modSettings['tld_regex'] . '~', null) !== false)
@@ -5694,10 +6016,11 @@  discard block
 block discarded – undo
5694 6016
 		// Clean $tlds and convert it to an array
5695 6017
 		$tlds = array_filter(explode("\n", strtolower($tlds)), function($line) {
5696 6018
 			$line = trim($line);
5697
-			if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false)
5698
-				return false;
5699
-			else
5700
-				return true;
6019
+			if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false) {
6020
+							return false;
6021
+			} else {
6022
+							return true;
6023
+			}
5701 6024
 		});
5702 6025
 
5703 6026
 		// Convert Punycode to Unicode
@@ -5751,8 +6074,9 @@  discard block
 block discarded – undo
5751 6074
 						$idx += $digit * $w;
5752 6075
 						$t = ($k <= $bias) ? $tmin : (($k >= $bias + $tmax) ? $tmax : ($k - $bias));
5753 6076
 
5754
-						if ($digit < $t)
5755
-							break;
6077
+						if ($digit < $t) {
6078
+													break;
6079
+						}
5756 6080
 
5757 6081
 						$w = (int) ($w * ($base - $t));
5758 6082
 					}
@@ -5761,8 +6085,9 @@  discard block
 block discarded – undo
5761 6085
 					$delta = intval($is_first ? ($delta / $damp) : ($delta / 2));
5762 6086
 					$delta += intval($delta / ($deco_len + 1));
5763 6087
 
5764
-					for ($k = 0; $delta > (($base - $tmin) * $tmax) / 2; $k += $base)
5765
-						$delta = intval($delta / ($base - $tmin));
6088
+					for ($k = 0; $delta > (($base - $tmin) * $tmax) / 2; $k += $base) {
6089
+											$delta = intval($delta / ($base - $tmin));
6090
+					}
5766 6091
 
5767 6092
 					$bias = intval($k + ($base - $tmin + 1) * $delta / ($delta + $skew));
5768 6093
 					$is_first = false;
@@ -5771,8 +6096,9 @@  discard block
 block discarded – undo
5771 6096
 
5772 6097
 					if ($deco_len > 0)
5773 6098
 					{
5774
-						for ($i = $deco_len; $i > $idx; $i--)
5775
-							$decoded[$i] = $decoded[($i - 1)];
6099
+						for ($i = $deco_len; $i > $idx; $i--) {
6100
+													$decoded[$i] = $decoded[($i - 1)];
6101
+						}
5776 6102
 					}
5777 6103
 					$decoded[$idx++] = $char;
5778 6104
 				}
@@ -5780,24 +6106,29 @@  discard block
 block discarded – undo
5780 6106
 				foreach ($decoded as $k => $v)
5781 6107
 				{
5782 6108
 					// 7bit are transferred literally
5783
-					if ($v < 128)
5784
-						$output .= chr($v);
6109
+					if ($v < 128) {
6110
+											$output .= chr($v);
6111
+					}
5785 6112
 
5786 6113
 					// 2 bytes
5787
-					elseif ($v < (1 << 11))
5788
-						$output .= chr(192+($v >> 6)) . chr(128+($v & 63));
6114
+					elseif ($v < (1 << 11)) {
6115
+											$output .= chr(192+($v >> 6)) . chr(128+($v & 63));
6116
+					}
5789 6117
 
5790 6118
 					// 3 bytes
5791
-					elseif ($v < (1 << 16))
5792
-						$output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63));
6119
+					elseif ($v < (1 << 16)) {
6120
+											$output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63));
6121
+					}
5793 6122
 
5794 6123
 					// 4 bytes
5795
-					elseif ($v < (1 << 21))
5796
-						$output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63));
6124
+					elseif ($v < (1 << 21)) {
6125
+											$output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63));
6126
+					}
5797 6127
 
5798 6128
 					//  'Conversion from UCS-4 to UTF-8 failed: malformed input at byte '.$k
5799
-					else
5800
-						$output .= $safe_char;
6129
+					else {
6130
+											$output .= $safe_char;
6131
+					}
5801 6132
 				}
5802 6133
 
5803 6134
 				$output_parts[] = $output;
@@ -5890,8 +6221,7 @@  discard block
 block discarded – undo
5890 6221
 
5891 6222
 		$strlen = 'mb_strlen';
5892 6223
 		$substr = 'mb_substr';
5893
-	}
5894
-	else
6224
+	} else
5895 6225
 	{
5896 6226
 		$strlen = $smcFunc['strlen'];
5897 6227
 		$substr = $smcFunc['substr'];
@@ -5905,20 +6235,21 @@  discard block
 block discarded – undo
5905 6235
 
5906 6236
 		$first = $substr($string, 0, 1);
5907 6237
 
5908
-		if (empty($index[$first]))
5909
-			$index[$first] = array();
6238
+		if (empty($index[$first])) {
6239
+					$index[$first] = array();
6240
+		}
5910 6241
 
5911 6242
 		if ($strlen($string) > 1)
5912 6243
 		{
5913 6244
 			// Sanity check on recursion
5914
-			if ($depth > 99)
5915
-				$index[$first][$substr($string, 1)] = '';
5916
-
5917
-			else
5918
-				$index[$first] = $add_string_to_index($substr($string, 1), $index[$first]);
6245
+			if ($depth > 99) {
6246
+							$index[$first][$substr($string, 1)] = '';
6247
+			} else {
6248
+							$index[$first] = $add_string_to_index($substr($string, 1), $index[$first]);
6249
+			}
6250
+		} else {
6251
+					$index[$first][''] = '';
5919 6252
 		}
5920
-		else
5921
-			$index[$first][''] = '';
5922 6253
 
5923 6254
 		$depth--;
5924 6255
 		return $index;
@@ -5941,9 +6272,9 @@  discard block
 block discarded – undo
5941 6272
 			$key_regex = preg_quote($key, $delim);
5942 6273
 			$new_key = $key;
5943 6274
 
5944
-			if (empty($value))
5945
-				$sub_regex = '';
5946
-			else
6275
+			if (empty($value)) {
6276
+							$sub_regex = '';
6277
+			} else
5947 6278
 			{
5948 6279
 				$sub_regex = $index_to_regex($value, $delim);
5949 6280
 
@@ -5951,22 +6282,22 @@  discard block
 block discarded – undo
5951 6282
 				{
5952 6283
 					$new_key_array = explode('(?'.'>', $sub_regex);
5953 6284
 					$new_key .= $new_key_array[0];
6285
+				} else {
6286
+									$sub_regex = '(?'.'>' . $sub_regex . ')';
5954 6287
 				}
5955
-				else
5956
-					$sub_regex = '(?'.'>' . $sub_regex . ')';
5957 6288
 			}
5958 6289
 
5959
-			if ($depth > 1)
5960
-				$regex[$new_key] = $key_regex . $sub_regex;
5961
-			else
6290
+			if ($depth > 1) {
6291
+							$regex[$new_key] = $key_regex . $sub_regex;
6292
+			} else
5962 6293
 			{
5963 6294
 				if (($length += strlen($key_regex) + 1) < $max_length || empty($regex))
5964 6295
 				{
5965 6296
 					$regex[$new_key] = $key_regex . $sub_regex;
5966 6297
 					unset($index[$key]);
6298
+				} else {
6299
+									break;
5967 6300
 				}
5968
-				else
5969
-					break;
5970 6301
 			}
5971 6302
 		}
5972 6303
 
@@ -5975,10 +6306,11 @@  discard block
 block discarded – undo
5975 6306
 			$l1 = $strlen($k1);
5976 6307
 			$l2 = $strlen($k2);
5977 6308
 
5978
-			if ($l1 == $l2)
5979
-				return strcmp($k1, $k2) > 0 ? 1 : -1;
5980
-			else
5981
-				return $l1 > $l2 ? -1 : 1;
6309
+			if ($l1 == $l2) {
6310
+							return strcmp($k1, $k2) > 0 ? 1 : -1;
6311
+			} else {
6312
+							return $l1 > $l2 ? -1 : 1;
6313
+			}
5982 6314
 		});
5983 6315
 
5984 6316
 		$depth--;
@@ -5989,21 +6321,24 @@  discard block
 block discarded – undo
5989 6321
 	$index = array();
5990 6322
 	$regex = '';
5991 6323
 
5992
-	foreach ($strings as $string)
5993
-		$index = $add_string_to_index($string, $index);
6324
+	foreach ($strings as $string) {
6325
+			$index = $add_string_to_index($string, $index);
6326
+	}
5994 6327
 
5995 6328
 	if ($returnArray === true)
5996 6329
 	{
5997 6330
 		$regex = array();
5998
-		while (!empty($index))
5999
-			$regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')';
6331
+		while (!empty($index)) {
6332
+					$regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')';
6333
+		}
6334
+	} else {
6335
+			$regex = '(?'.'>' . $index_to_regex($index, $delim) . ')';
6000 6336
 	}
6001
-	else
6002
-		$regex = '(?'.'>' . $index_to_regex($index, $delim) . ')';
6003 6337
 
6004 6338
 	// Restore PHP's internal character encoding to whatever it was originally
6005
-	if (!empty($current_encoding))
6006
-		mb_internal_encoding($current_encoding);
6339
+	if (!empty($current_encoding)) {
6340
+			mb_internal_encoding($current_encoding);
6341
+	}
6007 6342
 
6008 6343
 	return $regex;
6009 6344
 }
@@ -6046,13 +6381,15 @@  discard block
 block discarded – undo
6046 6381
 	// Need to add the trailing slash, or it puts it there & thinks there's a redirect when there isn't...
6047 6382
 	$url = str_ireplace('https://', 'http://', $url) . '/';
6048 6383
 	$headers = @get_headers($url);
6049
-	if ($headers === false)
6050
-		return false;
6384
+	if ($headers === false) {
6385
+			return false;
6386
+	}
6051 6387
 
6052 6388
 	// Now to see if it came back https...
6053 6389
 	// First check for a redirect status code in first row (301, 302, 307)
6054
-	if (strstr($headers[0], '301') === false && strstr($headers[0], '302') === false && strstr($headers[0], '307') === false)
6055
-		return false;
6390
+	if (strstr($headers[0], '301') === false && strstr($headers[0], '302') === false && strstr($headers[0], '307') === false) {
6391
+			return false;
6392
+	}
6056 6393
 
6057 6394
 	// Search for the location entry to confirm https
6058 6395
 	$result = false;
@@ -6088,8 +6425,7 @@  discard block
 block discarded – undo
6088 6425
 		$is_admin = $user_info['is_admin'];
6089 6426
 		$mod_cache = !empty($user_info['mod_cache']) ? $user_info['mod_cache'] : null;
6090 6427
 		$ignoreboards = !empty($user_info['ignoreboards']) ? $user_info['ignoreboards'] : null;
6091
-	}
6092
-	else
6428
+	} else
6093 6429
 	{
6094 6430
 		$request = $smcFunc['db_query']('', '
6095 6431
 				SELECT mem.ignore_boards, mem.id_group, mem.additional_groups, mem.id_post_group
@@ -6103,17 +6439,19 @@  discard block
 block discarded – undo
6103 6439
 
6104 6440
 		$row = $smcFunc['db_fetch_assoc']($request);
6105 6441
 
6106
-		if (empty($row['additional_groups']))
6107
-			$groups = array($row['id_group'], $row['id_post_group']);
6108
-		else
6109
-			$groups = array_merge(
6442
+		if (empty($row['additional_groups'])) {
6443
+					$groups = array($row['id_group'], $row['id_post_group']);
6444
+		} else {
6445
+					$groups = array_merge(
6110 6446
 					array($row['id_group'], $row['id_post_group']),
6111 6447
 					explode(',', $row['additional_groups'])
6112 6448
 			);
6449
+		}
6113 6450
 
6114 6451
 		// Because history has proven that it is possible for groups to go bad - clean up in case.
6115
-		foreach ($groups as $k => $v)
6116
-			$groups[$k] = (int) $v;
6452
+		foreach ($groups as $k => $v) {
6453
+					$groups[$k] = (int) $v;
6454
+		}
6117 6455
 
6118 6456
 		$is_admin = in_array(1, $groups);
6119 6457
 
@@ -6130,8 +6468,9 @@  discard block
 block discarded – undo
6130 6468
 				'current_member' => $userid,
6131 6469
 			)
6132 6470
 		);
6133
-		while ($row = $smcFunc['db_fetch_assoc']($request))
6134
-			$boards_mod[] = $row['id_board'];
6471
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
6472
+					$boards_mod[] = $row['id_board'];
6473
+		}
6135 6474
 		$smcFunc['db_free_result']($request);
6136 6475
 
6137 6476
 		// Can any of the groups they're in moderate any of the boards?
@@ -6143,8 +6482,9 @@  discard block
 block discarded – undo
6143 6482
 				'groups' => $groups,
6144 6483
 			)
6145 6484
 		);
6146
-		while ($row = $smcFunc['db_fetch_assoc']($request))
6147
-			$boards_mod[] = $row['id_board'];
6485
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
6486
+					$boards_mod[] = $row['id_board'];
6487
+		}
6148 6488
 		$smcFunc['db_free_result']($request);
6149 6489
 
6150 6490
 		// Just in case we've got duplicates here...
@@ -6154,21 +6494,25 @@  discard block
 block discarded – undo
6154 6494
 	}
6155 6495
 	
6156 6496
 	// Just build this here, it makes it easier to change/use - administrators can see all boards.
6157
-	if ($is_admin)
6158
-		$query_part['query_see_board'] = '1=1';
6497
+	if ($is_admin) {
6498
+			$query_part['query_see_board'] = '1=1';
6499
+	}
6159 6500
 	// Otherwise just the groups in $user_info['groups'].
6160
-	else
6161
-		$query_part['query_see_board'] = '((FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $groups) . ', b.member_groups) != 0)' . (!empty($deny_boards_access) ? ' AND (FIND_IN_SET(' . implode(', b.deny_member_groups) = 0 AND FIND_IN_SET(', $groups) . ', b.deny_member_groups) = 0)' : '') . (isset($mod_cache) ? ' OR ' . $mod_cache['mq'] : '') . ')';
6501
+	else {
6502
+			$query_part['query_see_board'] = '((FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $groups) . ', b.member_groups) != 0)' . (!empty($deny_boards_access) ? ' AND (FIND_IN_SET(' . implode(', b.deny_member_groups) = 0 AND FIND_IN_SET(', $groups) . ', b.deny_member_groups) = 0)' : '') . (isset($mod_cache) ? ' OR ' . $mod_cache['mq'] : '') . ')';
6503
+	}
6162 6504
 
6163 6505
 	// Build the list of boards they WANT to see.
6164 6506
 	// This will take the place of query_see_boards in certain spots, so it better include the boards they can see also
6165 6507
 
6166 6508
 	// If they aren't ignoring any boards then they want to see all the boards they can see
6167
-	if (empty($ignoreboards))
6168
-		$query_part['query_wanna_see_board'] = $query_part['query_see_board'];
6509
+	if (empty($ignoreboards)) {
6510
+			$query_part['query_wanna_see_board'] = $query_part['query_see_board'];
6511
+	}
6169 6512
 	// Ok I guess they don't want to see all the boards
6170
-	else
6171
-		$query_part['query_wanna_see_board'] = '(' . $query_part['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $ignoreboards) . '))';
6513
+	else {
6514
+			$query_part['query_wanna_see_board'] = '(' . $query_part['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $ignoreboards) . '))';
6515
+	}
6172 6516
 
6173 6517
 	return $query_part;
6174 6518
 }
Please login to merge, or discard this patch.
Sources/ModerationCenter.php 1 patch
Braces   +136 added lines, -100 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
  * Entry point for the moderation center.
@@ -26,8 +27,9 @@  discard block
 block discarded – undo
26 27
 	global $smcFunc, $txt, $context, $scripturl, $modSettings, $user_info, $sourcedir, $options;
27 28
 
28 29
 	// Don't run this twice... and don't conflict with the admin bar.
29
-	if (isset($context['admin_area']))
30
-		return;
30
+	if (isset($context['admin_area'])) {
31
+			return;
32
+	}
31 33
 
32 34
 	$context['can_moderate_boards'] = $user_info['mod_cache']['bq'] != '0=1';
33 35
 	$context['can_moderate_groups'] = $user_info['mod_cache']['gq'] != '0=1';
@@ -35,8 +37,9 @@  discard block
 block discarded – undo
35 37
 	$context['can_moderate_users'] = allowedTo('moderate_forum');
36 38
 
37 39
 	// Everyone using this area must be allowed here!
38
-	if (!$context['can_moderate_boards'] && !$context['can_moderate_groups'] && !$context['can_moderate_approvals'] && !$context['can_moderate_users'])
39
-		isAllowedTo('access_mod_center');
40
+	if (!$context['can_moderate_boards'] && !$context['can_moderate_groups'] && !$context['can_moderate_approvals'] && !$context['can_moderate_users']) {
41
+			isAllowedTo('access_mod_center');
42
+	}
40 43
 
41 44
 	// We're gonna want a menu of some kind.
42 45
 	require_once($sourcedir . '/Subs-Menu.php');
@@ -195,8 +198,9 @@  discard block
 block discarded – undo
195 198
 	unset($moderation_areas);
196 199
 
197 200
 	// We got something - didn't we? DIDN'T WE!
198
-	if ($mod_include_data == false)
199
-		fatal_lang_error('no_access', false);
201
+	if ($mod_include_data == false) {
202
+			fatal_lang_error('no_access', false);
203
+	}
200 204
 
201 205
 	// Retain the ID information in case required by a subaction.
202 206
 	$context['moderation_menu_id'] = $context['max_menu_id'];
@@ -219,22 +223,25 @@  discard block
 block discarded – undo
219 223
 		'url' => $scripturl . '?action=moderate',
220 224
 		'name' => $txt['moderation_center'],
221 225
 	);
222
-	if (isset($mod_include_data['current_area']) && $mod_include_data['current_area'] != 'index')
223
-		$context['linktree'][] = array(
226
+	if (isset($mod_include_data['current_area']) && $mod_include_data['current_area'] != 'index') {
227
+			$context['linktree'][] = array(
224 228
 			'url' => $scripturl . '?action=moderate;area=' . $mod_include_data['current_area'],
225 229
 			'name' => $mod_include_data['label'],
226 230
 		);
227
-	if (!empty($mod_include_data['current_subsection']) && $mod_include_data['subsections'][$mod_include_data['current_subsection']][0] != $mod_include_data['label'])
228
-		$context['linktree'][] = array(
231
+	}
232
+	if (!empty($mod_include_data['current_subsection']) && $mod_include_data['subsections'][$mod_include_data['current_subsection']][0] != $mod_include_data['label']) {
233
+			$context['linktree'][] = array(
229 234
 			'url' => $scripturl . '?action=moderate;area=' . $mod_include_data['current_area'] . ';sa=' . $mod_include_data['current_subsection'],
230 235
 			'name' => $mod_include_data['subsections'][$mod_include_data['current_subsection']][0],
231 236
 		);
237
+	}
232 238
 
233 239
 	// Now - finally - the bit before the encore - the main performance of course!
234 240
 	if (!$dont_call)
235 241
 	{
236
-		if (isset($mod_include_data['file']))
237
-			require_once($sourcedir . '/' . $mod_include_data['file']);
242
+		if (isset($mod_include_data['file'])) {
243
+					require_once($sourcedir . '/' . $mod_include_data['file']);
244
+		}
238 245
 
239 246
 		call_helper($mod_include_data['function']);
240 247
 	}
@@ -259,8 +266,9 @@  discard block
 block discarded – undo
259 266
 	// Load what blocks the user actually can see...
260 267
 	$valid_blocks = array();
261 268
 
262
-	if ($context['can_moderate_groups'])
263
-		$valid_blocks['g'] = 'GroupRequests';
269
+	if ($context['can_moderate_groups']) {
270
+			$valid_blocks['g'] = 'GroupRequests';
271
+	}
264 272
 	if ($context['can_moderate_boards'])
265 273
 	{
266 274
 		$valid_blocks['r'] = 'ReportedPosts';
@@ -269,8 +277,9 @@  discard block
 block discarded – undo
269 277
 	if ($context['can_moderate_users'])
270 278
 	{
271 279
 		// This falls under the category of moderating users as well...
272
-		if (!$context['can_moderate_boards'])
273
-			$valid_blocks['w'] = 'WatchedUsers';
280
+		if (!$context['can_moderate_boards']) {
281
+					$valid_blocks['w'] = 'WatchedUsers';
282
+		}
274 283
 
275 284
 		$valid_blocks['rm'] = 'ReportedMembers';
276 285
 	}
@@ -281,8 +290,9 @@  discard block
 block discarded – undo
281 290
 	foreach ($valid_blocks as $k => $block)
282 291
 	{
283 292
 		$block = 'ModBlock' . $block;
284
-		if (function_exists($block))
285
-			$context['mod_blocks'][] = $block();
293
+		if (function_exists($block)) {
294
+					$context['mod_blocks'][] = $block();
295
+		}
286 296
 	}
287 297
 
288 298
 	$context['admin_prefs'] = !empty($options['admin_preferences']) ? $smcFunc['json_decode']($options['admin_preferences'], true) : array();
@@ -309,8 +319,9 @@  discard block
 block discarded – undo
309 319
 			)
310 320
 		);
311 321
 		$watched_users = array();
312
-		while ($row = $smcFunc['db_fetch_assoc']($request))
313
-			$watched_users[] = $row;
322
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
323
+					$watched_users[] = $row;
324
+		}
314 325
 		$smcFunc['db_free_result']($request);
315 326
 
316 327
 		cache_put_data('recent_user_watches', $watched_users, 240);
@@ -402,8 +413,9 @@  discard block
 block discarded – undo
402 413
 			$note_owner = $smcFunc['db_num_rows']($get_owner);
403 414
 			$smcFunc['db_free_result']($get_owner);
404 415
 
405
-			if (empty($note_owner))
406
-				fatal_lang_error('mc_notes_delete_own', false);
416
+			if (empty($note_owner)) {
417
+							fatal_lang_error('mc_notes_delete_own', false);
418
+			}
407 419
 		}
408 420
 
409 421
 		// Lets delete it.
@@ -460,12 +472,14 @@  discard block
 block discarded – undo
460 472
 			)
461 473
 		);
462 474
 		$moderator_notes = array();
463
-		while ($row = $smcFunc['db_fetch_assoc']($request))
464
-			$moderator_notes[] = $row;
475
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
476
+					$moderator_notes[] = $row;
477
+		}
465 478
 		$smcFunc['db_free_result']($request);
466 479
 
467
-		if ($offset == 0)
468
-			cache_put_data('moderator_notes', $moderator_notes, 240);
480
+		if ($offset == 0) {
481
+					cache_put_data('moderator_notes', $moderator_notes, 240);
482
+		}
469 483
 	}
470 484
 
471 485
 	// Lets construct a page index.
@@ -504,8 +518,9 @@  discard block
 block discarded – undo
504 518
 	// Got the info already?
505 519
 	$cachekey = md5($smcFunc['json_encode']($user_info['mod_cache']['bq']));
506 520
 	$context['reported_posts'] = array();
507
-	if ($user_info['mod_cache']['bq'] == '0=1')
508
-		return 'reported_posts_block';
521
+	if ($user_info['mod_cache']['bq'] == '0=1') {
522
+			return 'reported_posts_block';
523
+	}
509 524
 
510 525
 	if (($reported_posts = cache_get_data('reported_posts_' . $cachekey, 90)) === null)
511 526
 	{
@@ -529,8 +544,9 @@  discard block
 block discarded – undo
529 544
 			)
530 545
 		);
531 546
 		$reported_posts = array();
532
-		while ($row = $smcFunc['db_fetch_assoc']($request))
533
-			$reported_posts[] = $row;
547
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
548
+					$reported_posts[] = $row;
549
+		}
534 550
 		$smcFunc['db_free_result']($request);
535 551
 
536 552
 		// Cache it.
@@ -568,8 +584,9 @@  discard block
 block discarded – undo
568 584
 
569 585
 	$context['group_requests'] = array();
570 586
 	// Make sure they can even moderate someone!
571
-	if ($user_info['mod_cache']['gq'] == '0=1')
572
-		return 'group_requests_block';
587
+	if ($user_info['mod_cache']['gq'] == '0=1') {
588
+			return 'group_requests_block';
589
+	}
573 590
 
574 591
 	// What requests are outstanding?
575 592
 	$request = $smcFunc['db_query']('', '
@@ -618,8 +635,9 @@  discard block
 block discarded – undo
618 635
 	// Got the info already?
619 636
 	$cachekey = md5($smcFunc['json_encode']((int) allowedTo('moderate_forum')));
620 637
 	$context['reported_users'] = array();
621
-	if (!allowedTo('moderate_forum'))
622
-		return 'reported_users_block';
638
+	if (!allowedTo('moderate_forum')) {
639
+			return 'reported_users_block';
640
+	}
623 641
 
624 642
 	if (($reported_users = cache_get_data('reported_users_' . $cachekey, 90)) === null)
625 643
 	{
@@ -642,8 +660,9 @@  discard block
 block discarded – undo
642 660
 			)
643 661
 		);
644 662
 		$reported_users = array();
645
-		while ($row = $smcFunc['db_fetch_assoc']($request))
646
-			$reported_users[] = $row;
663
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
664
+					$reported_users[] = $row;
665
+		}
647 666
 		$smcFunc['db_free_result']($request);
648 667
 
649 668
 		// Cache it.
@@ -742,15 +761,15 @@  discard block
 block discarded – undo
742 761
 		// Time to update.
743 762
 		updateSettings(array('last_mod_report_action' => time()));
744 763
 		recountOpenReports('members');
745
-	}
746
-	elseif (isset($_POST['close']) && isset($_POST['close_selected']))
764
+	} elseif (isset($_POST['close']) && isset($_POST['close_selected']))
747 765
 	{
748 766
 		checkSession();
749 767
 
750 768
 		// All the ones to update...
751 769
 		$toClose = array();
752
-		foreach ($_POST['close'] as $rid)
753
-			$toClose[] = (int) $rid;
770
+		foreach ($_POST['close'] as $rid) {
771
+					$toClose[] = (int) $rid;
772
+		}
754 773
 
755 774
 		if (!empty($toClose))
756 775
 		{
@@ -903,8 +922,9 @@  discard block
 block discarded – undo
903 922
 	global $context, $user_info;
904 923
 
905 924
 	// You need to be allowed to moderate groups...
906
-	if ($user_info['mod_cache']['gq'] == '0=1')
907
-		isAllowedTo('manage_membergroups');
925
+	if ($user_info['mod_cache']['gq'] == '0=1') {
926
+			isAllowedTo('manage_membergroups');
927
+	}
908 928
 
909 929
 	// Load the group templates.
910 930
 	loadTemplate('ModerationCenter');
@@ -915,8 +935,9 @@  discard block
 block discarded – undo
915 935
 		'view' => 'ViewGroups',
916 936
 	);
917 937
 
918
-	if (!isset($_GET['sa']) || !isset($subActions[$_GET['sa']]))
919
-		$_GET['sa'] = 'view';
938
+	if (!isset($_GET['sa']) || !isset($subActions[$_GET['sa']])) {
939
+			$_GET['sa'] = 'view';
940
+	}
920 941
 	$context['sub_action'] = $_GET['sa'];
921 942
 
922 943
 	// Call the relevant function.
@@ -946,8 +967,9 @@  discard block
 block discarded – undo
946 967
 			'id_notice' => $id_notice,
947 968
 		)
948 969
 	);
949
-	if ($smcFunc['db_num_rows']($request) == 0)
950
-		fatal_lang_error('no_access', false);
970
+	if ($smcFunc['db_num_rows']($request) == 0) {
971
+			fatal_lang_error('no_access', false);
972
+	}
951 973
 	list ($context['notice_body'], $context['notice_subject']) = $smcFunc['db_fetch_row']($request);
952 974
 	$smcFunc['db_free_result']($request);
953 975
 
@@ -984,18 +1006,20 @@  discard block
 block discarded – undo
984 1006
 		checkSession(!is_array($_REQUEST['delete']) ? 'get' : 'post');
985 1007
 
986 1008
 		$toDelete = array();
987
-		if (!is_array($_REQUEST['delete']))
988
-			$toDelete[] = (int) $_REQUEST['delete'];
989
-		else
990
-			foreach ($_REQUEST['delete'] as $did)
1009
+		if (!is_array($_REQUEST['delete'])) {
1010
+					$toDelete[] = (int) $_REQUEST['delete'];
1011
+		} else {
1012
+					foreach ($_REQUEST['delete'] as $did)
991 1013
 				$toDelete[] = (int) $did;
1014
+		}
992 1015
 
993 1016
 		if (!empty($toDelete))
994 1017
 		{
995 1018
 			require_once($sourcedir . '/RemoveTopic.php');
996 1019
 			// If they don't have permission we'll let it error - either way no chance of a security slip here!
997
-			foreach ($toDelete as $did)
998
-				removeMessage($did);
1020
+			foreach ($toDelete as $did) {
1021
+							removeMessage($did);
1022
+			}
999 1023
 		}
1000 1024
 	}
1001 1025
 
@@ -1004,20 +1028,21 @@  discard block
 block discarded – undo
1004 1028
 	{
1005 1029
 		$approve_query = '';
1006 1030
 		$delete_boards = array();
1007
-	}
1008
-	else
1031
+	} else
1009 1032
 	{
1010 1033
 		// Still obey permissions!
1011 1034
 		$approve_boards = boardsAllowedTo('approve_posts');
1012 1035
 		$delete_boards = boardsAllowedTo('delete_any');
1013 1036
 
1014
-		if ($approve_boards == array(0))
1015
-			$approve_query = '';
1016
-		elseif (!empty($approve_boards))
1017
-			$approve_query = ' AND m.id_board IN (' . implode(',', $approve_boards) . ')';
1037
+		if ($approve_boards == array(0)) {
1038
+					$approve_query = '';
1039
+		} elseif (!empty($approve_boards)) {
1040
+					$approve_query = ' AND m.id_board IN (' . implode(',', $approve_boards) . ')';
1041
+		}
1018 1042
 		// Nada, zip, etc...
1019
-		else
1020
-			$approve_query = ' AND 1=0';
1043
+		else {
1044
+					$approve_query = ' AND 1=0';
1045
+		}
1021 1046
 	}
1022 1047
 
1023 1048
 	require_once($sourcedir . '/Subs-List.php');
@@ -1116,10 +1141,11 @@  discard block
 block discarded – undo
1116 1141
 				'data' => array(
1117 1142
 					'function' => function($member) use ($scripturl)
1118 1143
 					{
1119
-						if ($member['last_post_id'])
1120
-							return '<a href="' . $scripturl . '?msg=' . $member['last_post_id'] . '">' . $member['last_post'] . '</a>';
1121
-						else
1122
-							return $member['last_post'];
1144
+						if ($member['last_post_id']) {
1145
+													return '<a href="' . $scripturl . '?msg=' . $member['last_post_id'] . '">' . $member['last_post'] . '</a>';
1146
+						} else {
1147
+													return $member['last_post'];
1148
+						}
1123 1149
 					},
1124 1150
 				),
1125 1151
 			),
@@ -1247,8 +1273,9 @@  discard block
 block discarded – undo
1247 1273
 			)
1248 1274
 		);
1249 1275
 		$latest_posts = array();
1250
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1251
-			$latest_posts[$row['id_member']] = $row['last_post_id'];
1276
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1277
+					$latest_posts[$row['id_member']] = $row['last_post_id'];
1278
+		}
1252 1279
 
1253 1280
 		if (!empty($latest_posts))
1254 1281
 		{
@@ -1439,15 +1466,17 @@  discard block
 block discarded – undo
1439 1466
 	// Setup the direction stuff...
1440 1467
 	$context['order'] = isset($_REQUEST['sort']) && isset($sort_types[$_REQUEST['sort']]) ? $_REQUEST['sort'] : 'member';
1441 1468
 
1442
-	if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search']))
1443
-		$search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search'];
1444
-	else
1445
-		$search_params_string = $search_params['string'];
1469
+	if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) {
1470
+			$search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search'];
1471
+	} else {
1472
+			$search_params_string = $search_params['string'];
1473
+	}
1446 1474
 
1447
-	if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']]))
1448
-		$search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member');
1449
-	else
1450
-		$search_params_type = $search_params['type'];
1475
+	if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) {
1476
+			$search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member');
1477
+	} else {
1478
+			$search_params_type = $search_params['type'];
1479
+	}
1451 1480
 
1452 1481
 	$search_params = array(
1453 1482
 		'string' => $search_params_string,
@@ -1530,9 +1559,10 @@  discard block
 block discarded – undo
1530 1559
 								' . $rowData['reason'] . '
1531 1560
 							</div>';
1532 1561
 
1533
-						if (!empty($rowData['id_notice']))
1534
-							$output .= '
1562
+						if (!empty($rowData['id_notice'])) {
1563
+													$output .= '
1535 1564
 								&nbsp;<a href="' . $scripturl . '?action=moderate;area=notice;nid=' . $rowData['id_notice'] . '" onclick="window.open(this.href, \'\', \'scrollbars=yes,resizable=yes,width=400,height=250\');return false;" target="_blank" rel="noopener" title="' . $txt['profile_warning_previous_notice'] . '"><span class="generic_icons filter centericon"></span></a>';
1565
+						}
1536 1566
 						return $output;
1537 1567
 					},
1538 1568
 				),
@@ -1650,9 +1680,9 @@  discard block
 block discarded – undo
1650 1680
 	global $smcFunc, $modSettings, $context, $txt, $scripturl, $sourcedir, $user_info;
1651 1681
 
1652 1682
 	// Submitting a new one?
1653
-	if (isset($_POST['add']))
1654
-		return ModifyWarningTemplate();
1655
-	elseif (isset($_POST['delete']) && !empty($_POST['deltpl']))
1683
+	if (isset($_POST['add'])) {
1684
+			return ModifyWarningTemplate();
1685
+	} elseif (isset($_POST['delete']) && !empty($_POST['deltpl']))
1656 1686
 	{
1657 1687
 		checkSession();
1658 1688
 		validateToken('mod-wt');
@@ -1671,8 +1701,9 @@  discard block
 block discarded – undo
1671 1701
 				'current_member' => $user_info['id'],
1672 1702
 			)
1673 1703
 		);
1674
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1675
-			logAction('delete_warn_template', array('template' => $row['recipient_name']));
1704
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1705
+					logAction('delete_warn_template', array('template' => $row['recipient_name']));
1706
+		}
1676 1707
 		$smcFunc['db_free_result']($request);
1677 1708
 
1678 1709
 		// Do the deletes.
@@ -1963,16 +1994,18 @@  discard block
 block discarded – undo
1963 1994
 				);
1964 1995
 
1965 1996
 				// If it wasn't visible and now is they've effectively added it.
1966
-				if ($context['template_data']['personal'] && !$recipient_id)
1967
-					logAction('add_warn_template', array('template' => $_POST['template_title']));
1997
+				if ($context['template_data']['personal'] && !$recipient_id) {
1998
+									logAction('add_warn_template', array('template' => $_POST['template_title']));
1999
+				}
1968 2000
 				// Conversely if they made it personal it's a delete.
1969
-				elseif (!$context['template_data']['personal'] && $recipient_id)
1970
-					logAction('delete_warn_template', array('template' => $_POST['template_title']));
2001
+				elseif (!$context['template_data']['personal'] && $recipient_id) {
2002
+									logAction('delete_warn_template', array('template' => $_POST['template_title']));
2003
+				}
1971 2004
 				// Otherwise just an edit.
1972
-				else
1973
-					logAction('modify_warn_template', array('template' => $_POST['template_title']));
1974
-			}
1975
-			else
2005
+				else {
2006
+									logAction('modify_warn_template', array('template' => $_POST['template_title']));
2007
+				}
2008
+			} else
1976 2009
 			{
1977 2010
 				$smcFunc['db_insert']('',
1978 2011
 					'{db_prefix}log_comments',
@@ -1992,17 +2025,18 @@  discard block
 block discarded – undo
1992 2025
 
1993 2026
 			// Get out of town...
1994 2027
 			redirectexit('action=moderate;area=warnings;sa=templates');
1995
-		}
1996
-		else
2028
+		} else
1997 2029
 		{
1998 2030
 			$context['warning_errors'] = array();
1999 2031
 			$context['template_data']['title'] = !empty($_POST['template_title']) ? $_POST['template_title'] : '';
2000 2032
 			$context['template_data']['body'] = !empty($_POST['template_body']) ? $_POST['template_body'] : $txt['mc_warning_template_body_default'];
2001 2033
 			$context['template_data']['personal'] = !empty($_POST['make_personal']);
2002
-			if (empty($_POST['template_title']))
2003
-				$context['warning_errors'][] = $txt['mc_warning_template_error_no_title'];
2004
-			if (empty($_POST['template_body']))
2005
-				$context['warning_errors'][] = $txt['mc_warning_template_error_no_body'];
2034
+			if (empty($_POST['template_title'])) {
2035
+							$context['warning_errors'][] = $txt['mc_warning_template_error_no_title'];
2036
+			}
2037
+			if (empty($_POST['template_body'])) {
2038
+							$context['warning_errors'][] = $txt['mc_warning_template_error_no_body'];
2039
+			}
2006 2040
 		}
2007 2041
 	}
2008 2042
 
@@ -2047,8 +2081,9 @@  discard block
 block discarded – undo
2047 2081
 		// Now check other options!
2048 2082
 		$pref_binary = 0;
2049 2083
 
2050
-		if ($context['can_moderate_approvals'] && !empty($_POST['mod_notify_approval']))
2051
-			$pref_binary |= 4;
2084
+		if ($context['can_moderate_approvals'] && !empty($_POST['mod_notify_approval'])) {
2085
+					$pref_binary |= 4;
2086
+		}
2052 2087
 
2053 2088
 		// Put it all together.
2054 2089
 		$mod_prefs = '0||' . $pref_binary;
@@ -2072,9 +2107,10 @@  discard block
 block discarded – undo
2072 2107
 	unset($_SESSION['moderate_time']);
2073 2108
 
2074 2109
 	// Clean any moderator tokens as well.
2075
-	foreach ($_SESSION['token'] as $key => $token)
2076
-		if (strpos($key, '-mod') !== false)
2110
+	foreach ($_SESSION['token'] as $key => $token) {
2111
+			if (strpos($key, '-mod') !== false)
2077 2112
 			unset($_SESSION['token'][$key]);
2113
+	}
2078 2114
 
2079 2115
 	redirectexit();
2080 2116
 }
Please login to merge, or discard this patch.
Themes/default/MoveTopic.template.php 1 patch
Braces   +32 added lines, -23 removed lines patch added patch discarded remove patch
@@ -37,9 +37,10 @@  discard block
 block discarded – undo
37 37
 		echo '
38 38
 								<optgroup label="', $category['name'], '">';
39 39
 
40
-		foreach ($category['boards'] as $board)
41
-			echo '
40
+		foreach ($category['boards'] as $board) {
41
+					echo '
42 42
 									<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', $board['id'] == $context['current_board'] ? ' disabled' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level']-1) . '=&gt; ' : '', $board['name'], '</option>';
43
+		}
43 44
 		echo '
44 45
 								</optgroup>';
45 46
 	}
@@ -70,9 +71,10 @@  discard block
 block discarded – undo
70 71
 				</div><!-- .move_topic -->
71 72
 			</div><!-- .windowbg -->';
72 73
 
73
-	if ($context['back_to_topic'])
74
-		echo '
74
+	if ($context['back_to_topic']) {
75
+			echo '
75 76
 			<input type="hidden" name="goback" value="1">';
77
+	}
76 78
 
77 79
 	echo '
78 80
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -125,10 +127,10 @@  discard block
 block discarded – undo
125 127
 									<option value="86400">', $txt['two_months'], '</option>
126 128
 								</select>
127 129
 							</dd>';
128
-	}
129
-	else
130
-		echo '
130
+	} else {
131
+			echo '
131 132
 							<input type="hidden" name="redirect_expires" value="0">';
133
+	}
132 134
 
133 135
 	echo '
134 136
 						</dl>
@@ -207,9 +209,10 @@  discard block
 block discarded – undo
207 209
 			echo '
208 210
 							<optgroup label="', $cat['name'], '">';
209 211
 
210
-			foreach ($cat['boards'] as $board)
211
-				echo '
212
+			foreach ($cat['boards'] as $board) {
213
+							echo '
212 214
 								<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=&gt;' : '', ' ', $board['name'], '</option>';
215
+			}
213 216
 
214 217
 			echo '
215 218
 							</optgroup>';
@@ -220,9 +223,9 @@  discard block
 block discarded – undo
220 223
 						<input type="submit" value="', $txt['go'], '" class="button">
221 224
 					</form>';
222 225
 
226
+	} else {
227
+			echo $txt['target_below'];
223 228
 	}
224
-	else
225
-		echo $txt['target_below'];
226 229
 
227 230
 	echo '		</h4>
228 231
 			</div><!-- .title_bar -->';
@@ -240,12 +243,13 @@  discard block
 block discarded – undo
240 243
 
241 244
 		$merge_button = create_button('merge', 'merge', '');
242 245
 
243
-		foreach ($context['topics'] as $topic)
244
-			echo '
246
+		foreach ($context['topics'] as $topic) {
247
+					echo '
245 248
 						<li>
246 249
 							<a href="', $scripturl, '?action=mergetopics;sa=options;board=', $context['current_board'], '.0;from=', $context['origin_topic'], ';to=', $topic['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $merge_button, '</a>
247 250
 							<a href="', $scripturl, '?topic=', $topic['id'], '.0" target="_blank" rel="noopener">', $topic['subject'], '</a> ', $txt['started_by'], ' ', $topic['poster']['link'], '
248 251
 						</li>';
252
+		}
249 253
 
250 254
 		echo '
251 255
 					</ul>
@@ -256,9 +260,10 @@  discard block
 block discarded – undo
256 260
 				</div>';
257 261
 	}
258 262
 	// Just a nice "There aren't any topics" message
259
-	else
260
-		echo '
263
+	else {
264
+			echo '
261 265
 				<div class="windowbg2">', $txt['topic_alert_none'], '</div>';
266
+	}
262 267
 
263 268
 	echo '
264 269
 				<br>
@@ -308,8 +313,8 @@  discard block
 block discarded – undo
308 313
 				</thead>
309 314
 				<tbody>';
310 315
 
311
-	foreach ($context['topics'] as $topic)
312
-		echo '
316
+	foreach ($context['topics'] as $topic) {
317
+			echo '
313 318
 					<tr class="windowbg">
314 319
 						<td>
315 320
 							<input type="checkbox" name="topics[]" value="' . $topic['id'] . '" checked>
@@ -329,6 +334,7 @@  discard block
 block discarded – undo
329 334
 							<input type="checkbox" name="notifications[]" value="' . $topic['id'] . '" checked>
330 335
 						</td>
331 336
 					</tr>';
337
+	}
332 338
 	echo '
333 339
 				</tbody>
334 340
 			</table>
@@ -338,9 +344,10 @@  discard block
 block discarded – undo
338 344
 					<legend>', $txt['merge_select_subject'], '</legend>
339 345
 					<select name="subject" onchange="this.form.custom_subject.style.display = (this.options[this.selectedIndex].value != 0) ? \'none\': \'\' ;">';
340 346
 
341
-	foreach ($context['topics'] as $topic)
342
-		echo '
347
+	foreach ($context['topics'] as $topic) {
348
+			echo '
343 349
 						<option value="', $topic['id'], '"' . ($topic['selected'] ? ' selected' : '') . '>', $topic['subject'], '</option>';
350
+	}
344 351
 	echo '
345 352
 						<option value="0">', $txt['merge_custom_subject'], ':</option>
346 353
 					</select>
@@ -359,11 +366,12 @@  discard block
 block discarded – undo
359 366
 					<legend>', $txt['merge_select_target_board'], '</legend>
360 367
 					<ul>';
361 368
 
362
-		foreach ($context['boards'] as $board)
363
-			echo '
369
+		foreach ($context['boards'] as $board) {
370
+					echo '
364 371
 						<li>
365 372
 							<input type="radio" name="board" value="' . $board['id'] . '"' . ($board['selected'] ? ' checked' : '') . '> ' . $board['name'] . '
366 373
 						</li>';
374
+		}
367 375
 		echo '
368 376
 					</ul>
369 377
 				</fieldset>';
@@ -375,11 +383,12 @@  discard block
 block discarded – undo
375 383
 					<legend>' . $txt['merge_select_poll'] . '</legend>
376 384
 					<ul>';
377 385
 
378
-		foreach ($context['polls'] as $poll)
379
-			echo '
386
+		foreach ($context['polls'] as $poll) {
387
+					echo '
380 388
 						<li>
381 389
 							<input type="radio" name="poll" value="' . $poll['id'] . '"' . ($poll['selected'] ? ' checked' : '') . '> ' . $poll['question'] . ' (' . $txt['topic'] . ': <a href="' . $scripturl . '?topic=' . $poll['topic']['id'] . '.0" target="_blank" rel="noopener">' . $poll['topic']['subject'] . '</a>)
382 390
 						</li>';
391
+		}
383 392
 		echo '
384 393
 						<li>
385 394
 							<input type="radio" name="poll" value="-1"> (' . $txt['merge_no_poll'] . ')
Please login to merge, or discard this patch.
Themes/default/Profile.template.php 1 patch
Braces   +508 added lines, -392 removed lines patch added patch discarded remove patch
@@ -18,23 +18,25 @@  discard block
 block discarded – undo
18 18
 	global $context;
19 19
 
20 20
 	// Prevent Chrome from auto completing fields when viewing/editing other members profiles
21
-	if (isBrowser('is_chrome') && !$context['user']['is_owner'])
22
-		echo '
21
+	if (isBrowser('is_chrome') && !$context['user']['is_owner']) {
22
+			echo '
23 23
 			<script>
24 24
 				disableAutoComplete();
25 25
 			</script>';
26
+	}
26 27
 
27 28
 	// If an error occurred while trying to save previously, give the user a clue!
28 29
 	echo '
29 30
 			', template_error_message();
30 31
 
31 32
 	// If the profile was update successfully, let the user know this.
32
-	if (!empty($context['profile_updated']))
33
-		echo '
33
+	if (!empty($context['profile_updated'])) {
34
+			echo '
34 35
 			<div class="infobox">
35 36
 				', $context['profile_updated'], '
36 37
 			</div>';
37
-}
38
+	}
39
+	}
38 40
 
39 41
 /**
40 42
  * Template for any HTML needed below the profile (closing off divs/tables, etc.)
@@ -99,19 +101,19 @@  discard block
 block discarded – undo
99 101
 		</div>
100 102
 		<div class="alerts_unread">';
101 103
 
102
-	if (empty($context['unread_alerts']))
103
-		template_alerts_all_read();
104
-
105
-	else
104
+	if (empty($context['unread_alerts'])) {
105
+			template_alerts_all_read();
106
+	} else
106 107
 	{
107
-		foreach ($context['unread_alerts'] as $id_alert => $details)
108
-			echo '
108
+		foreach ($context['unread_alerts'] as $id_alert => $details) {
109
+					echo '
109 110
 			<div class="unread">
110 111
 				', !empty($details['sender']) ? $details['sender']['avatar']['image'] : '', '
111 112
 				<div class="details">
112 113
 					', !empty($details['icon']) ? $details['icon'] : '', '<span>', $details['text'], '</span> - ', $details['time'], '
113 114
 				</div>
114 115
 			</div>';
116
+		}
115 117
 	}
116 118
 
117 119
 	echo '
@@ -161,10 +163,11 @@  discard block
 block discarded – undo
161 163
 			<div class="custom_fields_above_name">
162 164
 				<ul>';
163 165
 
164
-		foreach ($context['print_custom_fields']['above_member'] as $field)
165
-			if (!empty($field['output_html']))
166
+		foreach ($context['print_custom_fields']['above_member'] as $field) {
167
+					if (!empty($field['output_html']))
166 168
 				echo '
167 169
 					<li>', $field['output_html'], '</li>';
170
+		}
168 171
 
169 172
 		echo '
170 173
 				</ul>
@@ -176,20 +179,22 @@  discard block
 block discarded – undo
176 179
 			<div class="username clear">
177 180
 				<h4>';
178 181
 
179
-	if (!empty($context['print_custom_fields']['before_member']))
180
-		foreach ($context['print_custom_fields']['before_member'] as $field)
182
+	if (!empty($context['print_custom_fields']['before_member'])) {
183
+			foreach ($context['print_custom_fields']['before_member'] as $field)
181 184
 			if (!empty($field['output_html']))
182 185
 				echo '
183 186
 					<span>', $field['output_html'], '</span>';
187
+	}
184 188
 
185 189
 	echo '
186 190
 					', $context['member']['name'];
187 191
 
188
-	if (!empty($context['print_custom_fields']['after_member']))
189
-		foreach ($context['print_custom_fields']['after_member'] as $field)
192
+	if (!empty($context['print_custom_fields']['after_member'])) {
193
+			foreach ($context['print_custom_fields']['after_member'] as $field)
190 194
 			if (!empty($field['output_html']))
191 195
 				echo '
192 196
 					<span>', $field['output_html'], '</span>';
197
+	}
193 198
 
194 199
 
195 200
 	echo '
@@ -205,10 +210,11 @@  discard block
 block discarded – undo
205 210
 			<div class="custom_fields_below_avatar">
206 211
 				<ul>';
207 212
 
208
-		foreach ($context['print_custom_fields']['below_avatar'] as $field)
209
-			if (!empty($field['output_html']))
213
+		foreach ($context['print_custom_fields']['below_avatar'] as $field) {
214
+					if (!empty($field['output_html']))
210 215
 				echo '
211 216
 					<li>', $field['output_html'], '</li>';
217
+		}
212 218
 
213 219
 		echo '
214 220
 				</ul>
@@ -220,22 +226,25 @@  discard block
 block discarded – undo
220 226
 			<ul class="clear">';
221 227
 
222 228
 	// Email is only visible if it's your profile or you have the moderate_forum permission
223
-	if ($context['member']['show_email'])
224
-		echo '
229
+	if ($context['member']['show_email']) {
230
+			echo '
225 231
 				<li><a href="mailto:', $context['member']['email'], '" title="', $context['member']['email'], '" rel="nofollow"><span class="generic_icons mail" title="' . $txt['email'] . '"></span></a></li>';
232
+	}
226 233
 
227 234
 	// Don't show an icon if they haven't specified a website.
228
-	if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website']))
229
-		echo '
235
+	if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website'])) {
236
+			echo '
230 237
 				<li><a href="', $context['member']['website']['url'], '" title="' . $context['member']['website']['title'] . '" target="_blank" rel="noopener">', ($settings['use_image_buttons'] ? '<span class="generic_icons www" title="' . $context['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>';
238
+	}
231 239
 
232 240
 	// Are there any custom profile fields as icons?
233 241
 	if (!empty($context['print_custom_fields']['icons']))
234 242
 	{
235
-		foreach ($context['print_custom_fields']['icons'] as $field)
236
-			if (!empty($field['output_html']))
243
+		foreach ($context['print_custom_fields']['icons'] as $field) {
244
+					if (!empty($field['output_html']))
237 245
 				echo '
238 246
 				<li class="custom_field">', $field['output_html'], '</li>';
247
+		}
239 248
 	}
240 249
 
241 250
 	echo '
@@ -244,24 +253,27 @@  discard block
 block discarded – undo
244 253
 				', $context['can_send_pm'] ? '<a href="' . $context['member']['online']['href'] . '" title="' . $context['member']['online']['text'] . '" rel="nofollow">' : '', $settings['use_image_buttons'] ? '<span class="' . ($context['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $context['member']['online']['text'] . '"></span>' : $context['member']['online']['label'], $context['can_send_pm'] ? '</a>' : '', $settings['use_image_buttons'] ? '<span class="smalltext"> ' . $context['member']['online']['label'] . '</span>' : '';
245 254
 
246 255
 	// Can they add this member as a buddy?
247
-	if (!empty($context['can_have_buddy']) && !$context['user']['is_owner'])
248
-		echo '
256
+	if (!empty($context['can_have_buddy']) && !$context['user']['is_owner']) {
257
+			echo '
249 258
 				<br>
250 259
 				<a href="', $scripturl, '?action=buddy;u=', $context['id_member'], ';', $context['session_var'], '=', $context['session_id'], '">[', $txt['buddy_' . ($context['member']['is_buddy'] ? 'remove' : 'add')], ']</a>';
260
+	}
251 261
 
252 262
 	echo '
253 263
 			</span>';
254 264
 
255
-	if (!$context['user']['is_owner'] && $context['can_send_pm'])
256
-		echo '
265
+	if (!$context['user']['is_owner'] && $context['can_send_pm']) {
266
+			echo '
257 267
 			<a href="', $scripturl, '?action=pm;sa=send;u=', $context['id_member'], '" class="infolinks">', $txt['profile_sendpm_short'], '</a>';
268
+	}
258 269
 
259 270
 	echo '
260 271
 			<a href="', $scripturl, '?action=profile;area=showposts;u=', $context['id_member'], '" class="infolinks">', $txt['showPosts'], '</a>';
261 272
 
262
-	if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled']))
263
-		echo '
273
+	if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled'])) {
274
+			echo '
264 275
 			<a href="', $scripturl, '?action=profile;area=showdrafts;u=', $context['id_member'], '" class="infolinks">', $txt['drafts_show'], '</a>';
276
+	}
265 277
 
266 278
 	echo '
267 279
 			<a href="', $scripturl, '?action=profile;area=statistics;u=', $context['id_member'], '" class="infolinks">', $txt['statPanel'], '</a>';
@@ -273,10 +285,11 @@  discard block
 block discarded – undo
273 285
 			<div class="custom_fields_bottom">
274 286
 				<ul class="nolist">';
275 287
 
276
-		foreach ($context['print_custom_fields']['bottom_poster'] as $field)
277
-			if (!empty($field['output_html']))
288
+		foreach ($context['print_custom_fields']['bottom_poster'] as $field) {
289
+					if (!empty($field['output_html']))
278 290
 				echo '
279 291
 					<li>', $field['output_html'], '</li>';
292
+		}
280 293
 
281 294
 		echo '
282 295
 				</ul>
@@ -289,30 +302,35 @@  discard block
 block discarded – undo
289 302
 		<div id="detailedinfo">
290 303
 			<dl class="settings">';
291 304
 
292
-	if ($context['user']['is_owner'] || $context['user']['is_admin'])
293
-		echo '
305
+	if ($context['user']['is_owner'] || $context['user']['is_admin']) {
306
+			echo '
294 307
 				<dt>', $txt['username'], ': </dt>
295 308
 				<dd>', $context['member']['username'], '</dd>';
309
+	}
296 310
 
297
-	if (!isset($context['disabled_fields']['posts']))
298
-		echo '
311
+	if (!isset($context['disabled_fields']['posts'])) {
312
+			echo '
299 313
 				<dt>', $txt['profile_posts'], ': </dt>
300 314
 				<dd>', $context['member']['posts'], ' (', $context['member']['posts_per_day'], ' ', $txt['posts_per_day'], ')</dd>';
315
+	}
301 316
 
302
-	if ($context['member']['show_email'])
303
-		echo '
317
+	if ($context['member']['show_email']) {
318
+			echo '
304 319
 				<dt>', $txt['email'], ': </dt>
305 320
 				<dd><a href="mailto:', $context['member']['email'], '">', $context['member']['email'], '</a></dd>';
321
+	}
306 322
 
307
-	if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title']))
308
-		echo '
323
+	if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title'])) {
324
+			echo '
309 325
 				<dt>', $txt['custom_title'], ': </dt>
310 326
 				<dd>', $context['member']['title'], '</dd>';
327
+	}
311 328
 
312
-	if (!empty($context['member']['blurb']))
313
-		echo '
329
+	if (!empty($context['member']['blurb'])) {
330
+			echo '
314 331
 				<dt>', $txt['personal_text'], ': </dt>
315 332
 				<dd>', $context['member']['blurb'], '</dd>';
333
+	}
316 334
 
317 335
 	echo '
318 336
 				<dt>', $txt['age'], ':</dt>
@@ -326,19 +344,21 @@  discard block
 block discarded – undo
326 344
 	{
327 345
 		$fields = array();
328 346
 
329
-		foreach ($context['print_custom_fields']['standard'] as $field)
330
-			if (!empty($field['output_html']))
347
+		foreach ($context['print_custom_fields']['standard'] as $field) {
348
+					if (!empty($field['output_html']))
331 349
 				$fields[] = $field;
350
+		}
332 351
 
333 352
 		if (count($fields) > 0)
334 353
 		{
335 354
 			echo '
336 355
 			<dl class="settings">';
337 356
 
338
-			foreach ($fields as $field)
339
-				echo '
357
+			foreach ($fields as $field) {
358
+							echo '
340 359
 				<dt>', $field['name'], ':</dt>
341 360
 				<dd>', $field['output_html'], '</dd>';
361
+			}
342 362
 
343 363
 			echo '
344 364
 			</dl>';
@@ -358,9 +378,10 @@  discard block
 block discarded – undo
358 378
 					<a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=', ($context['can_issue_warning'] && !$context['user']['is_owner'] ? 'issuewarning' : 'viewwarning'), '">', $context['member']['warning'], '%</a>';
359 379
 
360 380
 		// Can we provide information on what this means?
361
-		if (!empty($context['warning_status']))
362
-			echo '
381
+		if (!empty($context['warning_status'])) {
382
+					echo '
363 383
 					<span class="smalltext">(', $context['warning_status'], ')</span>';
384
+		}
364 385
 
365 386
 		echo '
366 387
 				</dd>';
@@ -371,11 +392,12 @@  discard block
 block discarded – undo
371 392
 	{
372 393
 
373 394
 		// If the person looking at the summary has permission, and the account isn't activated, give the viewer the ability to do it themselves.
374
-		if (!empty($context['activate_message']))
375
-			echo '
395
+		if (!empty($context['activate_message'])) {
396
+					echo '
376 397
 				<dt class="clear">
377 398
 					<span class="alert">', $context['activate_message'], '</span> (<a href="', $context['activate_link'], '"', ($context['activate_type'] == 4 ? ' class="you_sure" data-confirm="' . $txt['profileConfirm'] . '"' : ''), '>', $context['activate_link_text'], '</a>)
378 399
 				</dt>';
400
+		}
379 401
 
380 402
 		// If the current member is banned, show a message and possibly a link to the ban.
381 403
 		if (!empty($context['member']['bans']))
@@ -387,10 +409,11 @@  discard block
 block discarded – undo
387 409
 				<dt class="clear" id="ban_info" style="display: none;">
388 410
 					<strong>', $txt['user_banned_by_following'], ':</strong>';
389 411
 
390
-			foreach ($context['member']['bans'] as $ban)
391
-				echo '
412
+			foreach ($context['member']['bans'] as $ban) {
413
+							echo '
392 414
 					<br>
393 415
 					<span class="smalltext">', $ban['explanation'], '</span>';
416
+			}
394 417
 
395 418
 			echo '
396 419
 				</dt>';
@@ -404,30 +427,34 @@  discard block
 block discarded – undo
404 427
 	// If the person looking is allowed, they can check the members IP address and hostname.
405 428
 	if ($context['can_see_ip'])
406 429
 	{
407
-		if (!empty($context['member']['ip']))
408
-		echo '
430
+		if (!empty($context['member']['ip'])) {
431
+				echo '
409 432
 				<dt>', $txt['ip'], ': </dt>
410 433
 				<dd><a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['member']['ip'], ';u=', $context['member']['id'], '">', $context['member']['ip'], '</a></dd>';
434
+		}
411 435
 
412
-		if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip']))
413
-			echo '
436
+		if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip'])) {
437
+					echo '
414 438
 				<dt>', $txt['hostname'], ': </dt>
415 439
 				<dd>', $context['member']['hostname'], '</dd>';
440
+		}
416 441
 	}
417 442
 
418 443
 	echo '
419 444
 				<dt>', $txt['local_time'], ':</dt>
420 445
 				<dd>', $context['member']['local_time'], '</dd>';
421 446
 
422
-	if (!empty($modSettings['userLanguage']) && !empty($context['member']['language']))
423
-		echo '
447
+	if (!empty($modSettings['userLanguage']) && !empty($context['member']['language'])) {
448
+			echo '
424 449
 				<dt>', $txt['language'], ':</dt>
425 450
 				<dd>', $context['member']['language'], '</dd>';
451
+	}
426 452
 
427
-	if ($context['member']['show_last_login'])
428
-		echo '
453
+	if ($context['member']['show_last_login']) {
454
+			echo '
429 455
 				<dt>', $txt['lastLoggedIn'], ': </dt>
430 456
 				<dd>', $context['member']['last_login'], (!empty($context['member']['is_hidden']) ? ' (' . $txt['hidden'] . ')' : ''), '</dd>';
457
+	}
431 458
 
432 459
 	echo '
433 460
 			</dl>';
@@ -439,10 +466,11 @@  discard block
 block discarded – undo
439 466
 			<div class="custom_fields_above_signature">
440 467
 				<ul class="nolist">';
441 468
 
442
-		foreach ($context['print_custom_fields']['above_signature'] as $field)
443
-			if (!empty($field['output_html']))
469
+		foreach ($context['print_custom_fields']['above_signature'] as $field) {
470
+					if (!empty($field['output_html']))
444 471
 				echo '
445 472
 					<li>', $field['output_html'], '</li>';
473
+		}
446 474
 
447 475
 		echo '
448 476
 				</ul>
@@ -450,12 +478,13 @@  discard block
 block discarded – undo
450 478
 	}
451 479
 
452 480
 	// Show the users signature.
453
-	if ($context['signature_enabled'] && !empty($context['member']['signature']))
454
-		echo '
481
+	if ($context['signature_enabled'] && !empty($context['member']['signature'])) {
482
+			echo '
455 483
 			<div class="signature">
456 484
 				<h5>', $txt['signature'], ':</h5>
457 485
 				', $context['member']['signature'], '
458 486
 			</div>';
487
+	}
459 488
 
460 489
 	// Are there any custom profile fields for below the signature?
461 490
 	if (!empty($context['print_custom_fields']['below_signature']))
@@ -464,10 +493,11 @@  discard block
 block discarded – undo
464 493
 			<div class="custom_fields_below_signature">
465 494
 				<ul class="nolist">';
466 495
 
467
-		foreach ($context['print_custom_fields']['below_signature'] as $field)
468
-			if (!empty($field['output_html']))
496
+		foreach ($context['print_custom_fields']['below_signature'] as $field) {
497
+					if (!empty($field['output_html']))
469 498
 				echo '
470 499
 					<li>', $field['output_html'], '</li>';
500
+		}
471 501
 
472 502
 		echo '
473 503
 				</ul>
@@ -513,62 +543,70 @@  discard block
 block discarded – undo
513 543
 			</div>
514 544
 			<div class="list_posts">';
515 545
 
516
-			if (!$post['approved'])
517
-				echo '
546
+			if (!$post['approved']) {
547
+							echo '
518 548
 				<div class="approve_post">
519 549
 					<em>', $txt['post_awaiting_approval'], '</em>
520 550
 				</div>';
551
+			}
521 552
 
522 553
 			echo '
523 554
 				', $post['body'], '
524 555
 			</div>';
525 556
 
526
-			if ($post['can_reply'] || $post['can_quote'] || $post['can_delete'])
527
-				echo '
557
+			if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) {
558
+							echo '
528 559
 			<div class="floatright">
529 560
 				<ul class="quickbuttons">';
561
+			}
530 562
 
531 563
 			// If they *can* reply?
532
-			if ($post['can_reply'])
533
-				echo '
564
+			if ($post['can_reply']) {
565
+							echo '
534 566
 					<li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>';
567
+			}
535 568
 
536 569
 			// If they *can* quote?
537
-			if ($post['can_quote'])
538
-				echo '
570
+			if ($post['can_quote']) {
571
+							echo '
539 572
 					<li><a href="', $scripturl . '?action=post;topic=', $post['topic'], '.', $post['start'], ';quote=', $post['id'], '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>';
573
+			}
540 574
 
541 575
 			// How about... even... remove it entirely?!
542
-			if ($post['can_delete'])
543
-				echo '
576
+			if ($post['can_delete']) {
577
+							echo '
544 578
 					<li><a href="', $scripturl, '?action=deletemsg;msg=', $post['id'], ';topic=', $post['topic'], ';profile;u=', $context['member']['id'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>';
579
+			}
545 580
 
546
-			if ($post['can_reply'] || $post['can_quote'] || $post['can_delete'])
547
-				echo '
581
+			if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) {
582
+							echo '
548 583
 				</ul>
549 584
 			</div><!-- .floatright -->';
585
+			}
550 586
 
551 587
 			echo '
552 588
 		</div><!-- $post[css_class] -->';
553 589
 		}
590
+	} else {
591
+			template_show_list('attachments');
554 592
 	}
555
-	else
556
-		template_show_list('attachments');
557 593
 
558 594
 	// No posts? Just end with a informative message.
559
-	if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts'])))
560
-		echo '
595
+	if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts']))) {
596
+			echo '
561 597
 		<div class="windowbg2">
562 598
 			', isset($context['attachments']) ? $txt['show_attachments_none'] : ($context['is_topics'] ? $txt['show_topics_none'] : $txt['show_posts_none']), '
563 599
 		</div>';
600
+	}
564 601
 
565 602
 	// Show more page numbers.
566
-	if (!empty($context['page_index']))
567
-		echo '
603
+	if (!empty($context['page_index'])) {
604
+			echo '
568 605
 		<div class="pagesection">
569 606
 			<div class="pagelinks">', $context['page_index'], '</div>
570 607
 		</div>';
571
-}
608
+	}
609
+	}
572 610
 
573 611
 /**
574 612
  * Template for showing alerts within the alerts popup
@@ -578,11 +616,12 @@  discard block
 block discarded – undo
578 616
 	global $context, $txt, $scripturl;
579 617
 
580 618
 	// Do we have an update message?
581
-	if (!empty($context['update_message']))
582
-		echo '
619
+	if (!empty($context['update_message'])) {
620
+			echo '
583 621
 		<div class="infobox">
584 622
 			', $context['update_message'], '.
585 623
 		</div>';
624
+	}
586 625
 
587 626
 	echo '
588 627
 		<div class="cat_bar">
@@ -591,13 +630,12 @@  discard block
 block discarded – undo
591 630
 			</h3>
592 631
 		</div>';
593 632
 
594
-	if (empty($context['alerts']))
595
-		echo '
633
+	if (empty($context['alerts'])) {
634
+			echo '
596 635
 		<div class="information">
597 636
 			', $txt['alerts_none'], '
598 637
 		</div>';
599
-
600
-	else
638
+	} else
601 639
 	{
602 640
 		// Start the form.
603 641
 		echo '
@@ -659,12 +697,12 @@  discard block
 block discarded – undo
659 697
 		</div>' : '';
660 698
 
661 699
 	// No drafts? Just show an informative message.
662
-	if (empty($context['drafts']))
663
-		echo '
700
+	if (empty($context['drafts'])) {
701
+			echo '
664 702
 		<div class="windowbg2 centertext">
665 703
 			', $txt['draft_none'], '
666 704
 		</div>';
667
-	else
705
+	} else
668 706
 	{
669 707
 		// For every draft to be displayed, give it its own div, and show the important details of the draft.
670 708
 		foreach ($context['drafts'] as $draft)
@@ -676,13 +714,15 @@  discard block
 block discarded – undo
676 714
 				<h5>
677 715
 					<strong><a href="', $scripturl, '?board=', $draft['board']['id'], '.0">', $draft['board']['name'], '</a> / ', $draft['topic']['link'], '</strong> &nbsp; &nbsp;';
678 716
 
679
-			if (!empty($draft['sticky']))
680
-				echo '
717
+			if (!empty($draft['sticky'])) {
718
+							echo '
681 719
 					<span class="generic_icons sticky" title="', $txt['sticky_topic'], '"></span>';
720
+			}
682 721
 
683
-			if (!empty($draft['locked']))
684
-				echo '
722
+			if (!empty($draft['locked'])) {
723
+							echo '
685 724
 					<span class="generic_icons lock" title="', $txt['locked_topic'], '"></span>';
725
+			}
686 726
 
687 727
 			echo '
688 728
 				</h5>
@@ -715,13 +755,13 @@  discard block
 block discarded – undo
715 755
 {
716 756
 	global $context, $scripturl, $txt;
717 757
 
718
-	if (!empty($context['saved_successful']))
719
-		echo '
758
+	if (!empty($context['saved_successful'])) {
759
+			echo '
720 760
 	<div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>';
721
-
722
-	elseif (!empty($context['saved_failed']))
723
-		echo '
761
+	} elseif (!empty($context['saved_failed'])) {
762
+			echo '
724 763
 	<div class="errorbox">', $context['saved_failed'], '</div>';
764
+	}
725 765
 
726 766
 	echo '
727 767
 	<div id="edit_buddies">
@@ -736,14 +776,16 @@  discard block
 block discarded – undo
736 776
 					<th scope="col" class="quarter_table">', $txt['name'], '</th>
737 777
 					<th scope="col">', $txt['status'], '</th>';
738 778
 
739
-	if (allowedTo('moderate_forum'))
740
-		echo '
779
+	if (allowedTo('moderate_forum')) {
780
+			echo '
741 781
 					<th scope="col">', $txt['email'], '</th>';
782
+	}
742 783
 
743
-	if (!empty($context['custom_pf']))
744
-		foreach ($context['custom_pf'] as $column)
784
+	if (!empty($context['custom_pf'])) {
785
+			foreach ($context['custom_pf'] as $column)
745 786
 				echo '
746 787
 					<th scope="col">', $column['label'], '</th>';
788
+	}
747 789
 
748 790
 	echo '
749 791
 					<th scope="col">', $txt['remove'], '</th>
@@ -752,13 +794,14 @@  discard block
 block discarded – undo
752 794
 			<tbody>';
753 795
 
754 796
 	// If they don't have any buddies don't list them!
755
-	if (empty($context['buddies']))
756
-		echo '
797
+	if (empty($context['buddies'])) {
798
+			echo '
757 799
 				<tr class="windowbg">
758 800
 					<td colspan="', allowedTo('moderate_forum') ? '10' : '9', '">
759 801
 						<strong>', $txt['no_buddies'], '</strong>
760 802
 					</td>
761 803
 				</tr>';
804
+	}
762 805
 
763 806
 		// Now loop through each buddy showing info on each.
764 807
 	else
@@ -772,17 +815,19 @@  discard block
 block discarded – undo
772 815
 						<a href="', $buddy['online']['href'], '"><span class="' . ($buddy['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $buddy['online']['text'] . '"></span></a>
773 816
 					</td>';
774 817
 
775
-			if ($buddy['show_email'])
776
-				echo '
818
+			if ($buddy['show_email']) {
819
+							echo '
777 820
 					<td>
778 821
 						<a href="mailto:' . $buddy['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $buddy['name'] . '"></span></a>
779 822
 					</td>';
823
+			}
780 824
 
781 825
 			// Show the custom profile fields for this user.
782
-			if (!empty($context['custom_pf']))
783
-				foreach ($context['custom_pf'] as $key => $column)
826
+			if (!empty($context['custom_pf'])) {
827
+							foreach ($context['custom_pf'] as $key => $column)
784 828
 					echo '
785 829
 					<td class="lefttext">', $buddy['options'][$key], '</td>';
830
+			}
786 831
 
787 832
 			echo '
788 833
 					<td>
@@ -815,9 +860,10 @@  discard block
 block discarded – undo
815 860
 			</dl>
816 861
 		</div>';
817 862
 
818
-	if (!empty($context['token_check']))
819
-		echo '
863
+	if (!empty($context['token_check'])) {
864
+			echo '
820 865
 		<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
866
+	}
821 867
 
822 868
 	echo '
823 869
 		<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -843,13 +889,13 @@  discard block
 block discarded – undo
843 889
 {
844 890
 	global $context, $scripturl, $txt;
845 891
 
846
-	if (!empty($context['saved_successful']))
847
-		echo '
892
+	if (!empty($context['saved_successful'])) {
893
+			echo '
848 894
 	<div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>';
849
-
850
-	elseif (!empty($context['saved_failed']))
851
-		echo '
895
+	} elseif (!empty($context['saved_failed'])) {
896
+			echo '
852 897
 	<div class="errorbox">', $context['saved_failed'], '</div>';
898
+	}
853 899
 
854 900
 	echo '
855 901
 	<div id="edit_buddies">
@@ -864,9 +910,10 @@  discard block
 block discarded – undo
864 910
 					<th scope="col" class="quarter_table">', $txt['name'], '</th>
865 911
 					<th scope="col">', $txt['status'], '</th>';
866 912
 
867
-	if (allowedTo('moderate_forum'))
868
-		echo '
913
+	if (allowedTo('moderate_forum')) {
914
+			echo '
869 915
 					<th scope="col">', $txt['email'], '</th>';
916
+	}
870 917
 
871 918
 	echo '
872 919
 					<th scope="col">', $txt['ignore_remove'], '</th>
@@ -875,13 +922,14 @@  discard block
 block discarded – undo
875 922
 			<tbody>';
876 923
 
877 924
 	// If they don't have anyone on their ignore list, don't list it!
878
-	if (empty($context['ignore_list']))
879
-		echo '
925
+	if (empty($context['ignore_list'])) {
926
+			echo '
880 927
 				<tr class="windowbg">
881 928
 					<td colspan="', allowedTo('moderate_forum') ? '4' : '3', '">
882 929
 						<strong>', $txt['no_ignore'], '</strong>
883 930
 					</td>
884 931
 				</tr>';
932
+	}
885 933
 
886 934
 	// Now loop through each buddy showing info on each.
887 935
 	foreach ($context['ignore_list'] as $member)
@@ -893,11 +941,12 @@  discard block
 block discarded – undo
893 941
 						<a href="', $member['online']['href'], '"><span class="' . ($member['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $member['online']['text'] . '"></span></a>
894 942
 					</td>';
895 943
 
896
-		if ($member['show_email'])
897
-			echo '
944
+		if ($member['show_email']) {
945
+					echo '
898 946
 					<td>
899 947
 						<a href="mailto:' . $member['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $member['name'] . '"></span></a>
900 948
 					</td>';
949
+		}
901 950
 		echo '
902 951
 					<td>
903 952
 						<a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=lists;sa=ignore;remove=', $member['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons delete" title="', $txt['ignore_remove'], '"></span></a>
@@ -927,9 +976,10 @@  discard block
 block discarded – undo
927 976
 			</dl>
928 977
 		</div>';
929 978
 
930
-	if (!empty($context['token_check']))
931
-		echo '
979
+	if (!empty($context['token_check'])) {
980
+			echo '
932 981
 		<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
982
+	}
933 983
 
934 984
 	echo '
935 985
 		<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -975,9 +1025,10 @@  discard block
 block discarded – undo
975 1025
 					<a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip'], ';u=', $context['member']['id'], '">', $context['last_ip'], '</a>';
976 1026
 
977 1027
 	// Second address detected?
978
-	if (!empty($context['last_ip2']))
979
-		echo '
1028
+	if (!empty($context['last_ip2'])) {
1029
+			echo '
980 1030
 					, <a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip2'], ';u=', $context['member']['id'], '">', $context['last_ip2'], '</a>';
1031
+	}
981 1032
 
982 1033
 	echo '
983 1034
 				</dd>';
@@ -1043,9 +1094,10 @@  discard block
 block discarded – undo
1043 1094
 		</div>
1044 1095
 		<div class="windowbg2 noup">';
1045 1096
 
1046
-		foreach ($context['whois_servers'] as $server)
1047
-			echo '
1097
+		foreach ($context['whois_servers'] as $server) {
1098
+					echo '
1048 1099
 			<a href="', $server['url'], '" target="_blank" rel="noopener"', isset($context['auto_whois_server']) && $context['auto_whois_server']['name'] == $server['name'] ? ' style="font-weight: bold;"' : '', '>', $server['name'], '</a><br>';
1100
+		}
1049 1101
 		echo '
1050 1102
 		</div>
1051 1103
 		<br>';
@@ -1057,13 +1109,12 @@  discard block
 block discarded – undo
1057 1109
 			<h3 class="catbg">', $txt['members_from_ip'], ' ', $context['ip'], '</h3>
1058 1110
 		</div>';
1059 1111
 
1060
-	if (empty($context['ips']))
1061
-		echo '
1112
+	if (empty($context['ips'])) {
1113
+			echo '
1062 1114
 		<p class="windowbg2 description">
1063 1115
 			<em>', $txt['no_members_from_ip'], '</em>
1064 1116
 		</p>';
1065
-
1066
-	else
1117
+	} else
1067 1118
 	{
1068 1119
 		echo '
1069 1120
 		<table class="table_grid">
@@ -1076,12 +1127,13 @@  discard block
 block discarded – undo
1076 1127
 			<tbody>';
1077 1128
 
1078 1129
 		// Loop through each of the members and display them.
1079
-		foreach ($context['ips'] as $ip => $memberlist)
1080
-			echo '
1130
+		foreach ($context['ips'] as $ip => $memberlist) {
1131
+					echo '
1081 1132
 				<tr class="windowbg">
1082 1133
 					<td><a href="', $context['base_url'], ';searchip=', $ip, '">', $ip, '</a></td>
1083 1134
 					<td>', implode(', ', $memberlist), '</td>
1084 1135
 				</tr>';
1136
+		}
1085 1137
 
1086 1138
 		echo '
1087 1139
 			</tbody>
@@ -1123,11 +1175,10 @@  discard block
 block discarded – undo
1123 1175
 			</h3>
1124 1176
 		</div>';
1125 1177
 
1126
-	if ($context['member']['has_all_permissions'])
1127
-		echo '
1178
+	if ($context['member']['has_all_permissions']) {
1179
+			echo '
1128 1180
 		<div class="information">', $txt['showPermissions_all'], '</div>';
1129
-
1130
-	else
1181
+	} else
1131 1182
 	{
1132 1183
 		echo '
1133 1184
 		<div class="information">',$txt['showPermissions_help'], '</div>
@@ -1142,9 +1193,10 @@  discard block
 block discarded – undo
1142 1193
 			<div class="windowbg smalltext">
1143 1194
 				', $txt['showPermissions_restricted_boards_desc'], ':<br>';
1144 1195
 
1145
-			foreach ($context['no_access_boards'] as $no_access_board)
1146
-				echo '
1196
+			foreach ($context['no_access_boards'] as $no_access_board) {
1197
+							echo '
1147 1198
 				<a href="', $scripturl, '?board=', $no_access_board['id'], '.0">', $no_access_board['name'], '</a>', $no_access_board['is_last'] ? '' : ', ';
1199
+			}
1148 1200
 			echo '
1149 1201
 			</div>';
1150 1202
 		}
@@ -1176,12 +1228,13 @@  discard block
 block discarded – undo
1176 1228
 							</td>
1177 1229
 							<td class="smalltext">';
1178 1230
 
1179
-				if ($permission['is_denied'])
1180
-					echo '
1231
+				if ($permission['is_denied']) {
1232
+									echo '
1181 1233
 								<span class="alert">', $txt['showPermissions_denied'], ': ', implode(', ', $permission['groups']['denied']), '</span>';
1182
-				else
1183
-					echo '
1234
+				} else {
1235
+									echo '
1184 1236
 								', $txt['showPermissions_given'], ': ', implode(', ', $permission['groups']['allowed']);
1237
+				}
1185 1238
 
1186 1239
 				echo '
1187 1240
 							</td>
@@ -1192,10 +1245,10 @@  discard block
 block discarded – undo
1192 1245
 				</table>
1193 1246
 			</div><!-- .tborder -->
1194 1247
 			<br>';
1195
-		}
1196
-		else
1197
-			echo '
1248
+		} else {
1249
+					echo '
1198 1250
 			<p class="windowbg2">', $txt['showPermissions_none_general'], '</p>';
1251
+		}
1199 1252
 
1200 1253
 		// Board permission section.
1201 1254
 		echo '
@@ -1206,14 +1259,16 @@  discard block
 block discarded – undo
1206 1259
 						<select name="board" onchange="if (this.options[this.selectedIndex].value) this.form.submit();">
1207 1260
 							<option value="0"', $context['board'] == 0 ? ' selected' : '', '>', $txt['showPermissions_global'], '</option>';
1208 1261
 
1209
-		if (!empty($context['boards']))
1210
-			echo '
1262
+		if (!empty($context['boards'])) {
1263
+					echo '
1211 1264
 							<option value="" disabled>---------------------------</option>';
1265
+		}
1212 1266
 
1213 1267
 		// Fill the box with any local permission boards.
1214
-		foreach ($context['boards'] as $board)
1215
-			echo '
1268
+		foreach ($context['boards'] as $board) {
1269
+					echo '
1216 1270
 							<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['name'], ' (', $board['profile_name'], ')</option>';
1271
+		}
1217 1272
 
1218 1273
 		echo '
1219 1274
 						</select>
@@ -1242,13 +1297,13 @@  discard block
 block discarded – undo
1242 1297
 						</td>
1243 1298
 						<td class="smalltext">';
1244 1299
 
1245
-				if ($permission['is_denied'])
1246
-					echo '
1300
+				if ($permission['is_denied']) {
1301
+									echo '
1247 1302
 							<span class="alert">', $txt['showPermissions_denied'], ': ', implode(', ', $permission['groups']['denied']), '</span>';
1248
-
1249
-				else
1250
-					echo '
1303
+				} else {
1304
+									echo '
1251 1305
 							', $txt['showPermissions_given'], ': ', implode(', ', $permission['groups']['allowed']);
1306
+				}
1252 1307
 
1253 1308
 				echo '
1254 1309
 						</td>
@@ -1257,10 +1312,10 @@  discard block
 block discarded – undo
1257 1312
 			echo '
1258 1313
 				</tbody>
1259 1314
 			</table>';
1260
-		}
1261
-		else
1262
-			echo '
1315
+		} else {
1316
+					echo '
1263 1317
 			<p class="windowbg2">', $txt['showPermissions_none_board'], '</p>';
1318
+		}
1264 1319
 	echo '
1265 1320
 		</div><!-- #permissions -->';
1266 1321
 	}
@@ -1301,9 +1356,10 @@  discard block
 block discarded – undo
1301 1356
 			</div>';
1302 1357
 
1303 1358
 	// If they haven't post at all, don't draw the graph.
1304
-	if (empty($context['posts_by_time']))
1305
-		echo '
1359
+	if (empty($context['posts_by_time'])) {
1360
+			echo '
1306 1361
 			<p class="centertext padding">', $txt['statPanel_noPosts'], '</p>';
1362
+	}
1307 1363
 
1308 1364
 	// Otherwise do!
1309 1365
 	else
@@ -1312,8 +1368,8 @@  discard block
 block discarded – undo
1312 1368
 			<ul class="activity_stats flow_hidden">';
1313 1369
 
1314 1370
 		// The labels.
1315
-		foreach ($context['posts_by_time'] as $time_of_day)
1316
-			echo '
1371
+		foreach ($context['posts_by_time'] as $time_of_day) {
1372
+					echo '
1317 1373
 				<li', $time_of_day['is_last'] ? ' class="last"' : '', '>
1318 1374
 					<div class="bar" style="padding-top: ', ((int) (100 - $time_of_day['relative_percent'])), 'px;" title="', sprintf($txt['statPanel_activityTime_posts'], $time_of_day['posts'], $time_of_day['posts_percent']), '">
1319 1375
 						<div style="height: ', (int) $time_of_day['relative_percent'], 'px;">
@@ -1322,6 +1378,7 @@  discard block
 block discarded – undo
1322 1378
 					</div>
1323 1379
 					<span class="stats_hour">', $time_of_day['hour_format'], '</span>
1324 1380
 				</li>';
1381
+		}
1325 1382
 
1326 1383
 		echo '
1327 1384
 			</ul>';
@@ -1340,11 +1397,10 @@  discard block
 block discarded – undo
1340 1397
 					</h3>
1341 1398
 				</div>';
1342 1399
 
1343
-	if (empty($context['popular_boards']))
1344
-		echo '
1400
+	if (empty($context['popular_boards'])) {
1401
+			echo '
1345 1402
 				<p class="centertext padding">', $txt['statPanel_noPosts'], '</p>';
1346
-
1347
-	else
1403
+	} else
1348 1404
 	{
1349 1405
 		echo '
1350 1406
 				<dl class="stats">';
@@ -1374,10 +1430,10 @@  discard block
 block discarded – undo
1374 1430
 					</h3>
1375 1431
 				</div>';
1376 1432
 
1377
-	if (empty($context['board_activity']))
1378
-		echo '
1433
+	if (empty($context['board_activity'])) {
1434
+			echo '
1379 1435
 				<p class="centertext padding">', $txt['statPanel_noPosts'], '</p>';
1380
-	else
1436
+	} else
1381 1437
 	{
1382 1438
 		echo '
1383 1439
 				<dl class="stats">';
@@ -1428,90 +1484,97 @@  discard block
 block discarded – undo
1428 1484
 				<h3 class="catbg profile_hd">';
1429 1485
 
1430 1486
 		// Don't say "Profile" if this isn't the profile...
1431
-		if (!empty($context['profile_header_text']))
1432
-			echo '
1487
+		if (!empty($context['profile_header_text'])) {
1488
+					echo '
1433 1489
 					', $context['profile_header_text'];
1434
-		else
1435
-			echo '
1490
+		} else {
1491
+					echo '
1436 1492
 					', $txt['profile'];
1493
+		}
1437 1494
 
1438 1495
 		echo '
1439 1496
 				</h3>
1440 1497
 			</div>';
1441 1498
 
1442 1499
 	// Have we some description?
1443
-	if ($context['page_desc'])
1444
-		echo '
1500
+	if ($context['page_desc']) {
1501
+			echo '
1445 1502
 			<p class="information">', $context['page_desc'], '</p>';
1503
+	}
1446 1504
 
1447 1505
 	echo '
1448 1506
 			<div class="roundframe">';
1449 1507
 
1450 1508
 	// Any bits at the start?
1451
-	if (!empty($context['profile_prehtml']))
1452
-		echo '
1509
+	if (!empty($context['profile_prehtml'])) {
1510
+			echo '
1453 1511
 				<div>', $context['profile_prehtml'], '</div>';
1512
+	}
1454 1513
 
1455
-	if (!empty($context['profile_fields']))
1456
-		echo '
1514
+	if (!empty($context['profile_fields'])) {
1515
+			echo '
1457 1516
 				<dl class="settings">';
1517
+	}
1458 1518
 
1459 1519
 	// Start the big old loop 'of love.
1460 1520
 	$lastItem = 'hr';
1461 1521
 	foreach ($context['profile_fields'] as $key => $field)
1462 1522
 	{
1463 1523
 		// We add a little hack to be sure we never get more than one hr in a row!
1464
-		if ($lastItem == 'hr' && $field['type'] == 'hr')
1465
-			continue;
1524
+		if ($lastItem == 'hr' && $field['type'] == 'hr') {
1525
+					continue;
1526
+		}
1466 1527
 
1467 1528
 		$lastItem = $field['type'];
1468
-		if ($field['type'] == 'hr')
1469
-			echo '
1529
+		if ($field['type'] == 'hr') {
1530
+					echo '
1470 1531
 				</dl>
1471 1532
 				<hr>
1472 1533
 				<dl class="settings">';
1473
-
1474
-		elseif ($field['type'] == 'callback')
1534
+		} elseif ($field['type'] == 'callback')
1475 1535
 		{
1476 1536
 			if (isset($field['callback_func']) && function_exists('template_profile_' . $field['callback_func']))
1477 1537
 			{
1478 1538
 				$callback_func = 'template_profile_' . $field['callback_func'];
1479 1539
 				$callback_func();
1480 1540
 			}
1481
-		}
1482
-		else
1541
+		} else
1483 1542
 		{
1484 1543
 			echo '
1485 1544
 					<dt>
1486 1545
 						<strong', !empty($field['is_error']) ? ' class="error"' : '', '>', $field['type'] !== 'label' ? '<label for="' . $key . '">' : '', $field['label'], $field['type'] !== 'label' ? '</label>' : '', '</strong>';
1487 1546
 
1488 1547
 			// Does it have any subtext to show?
1489
-			if (!empty($field['subtext']))
1490
-				echo '
1548
+			if (!empty($field['subtext'])) {
1549
+							echo '
1491 1550
 						<br>
1492 1551
 						<span class="smalltext">', $field['subtext'], '</span>';
1552
+			}
1493 1553
 
1494 1554
 			echo '
1495 1555
 					</dt>
1496 1556
 					<dd>';
1497 1557
 
1498 1558
 			// Want to put something infront of the box?
1499
-			if (!empty($field['preinput']))
1500
-				echo '
1559
+			if (!empty($field['preinput'])) {
1560
+							echo '
1501 1561
 						', $field['preinput'];
1562
+			}
1502 1563
 
1503 1564
 			// What type of data are we showing?
1504
-			if ($field['type'] == 'label')
1505
-				echo '
1565
+			if ($field['type'] == 'label') {
1566
+							echo '
1506 1567
 						', $field['value'];
1568
+			}
1507 1569
 
1508 1570
 			// Maybe it's a text box - very likely!
1509 1571
 			elseif (in_array($field['type'], array('int', 'float', 'text', 'password', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'number', 'time', 'url')))
1510 1572
 			{
1511
-				if ($field['type'] == 'int' || $field['type'] == 'float')
1512
-					$type = 'number';
1513
-				else
1514
-					$type = $field['type'];
1573
+				if ($field['type'] == 'int' || $field['type'] == 'float') {
1574
+									$type = 'number';
1575
+				} else {
1576
+									$type = $field['type'];
1577
+				}
1515 1578
 				$step = $field['type'] == 'float' ? ' step="0.1"' : '';
1516 1579
 
1517 1580
 
@@ -1519,10 +1582,11 @@  discard block
 block discarded – undo
1519 1582
 						<input type="', $type, '" name="', $key, '" id="', $key, '" size="', empty($field['size']) ? 30 : $field['size'], '" value="', $field['value'], '" ', $field['input_attr'], ' ', $step, '>';
1520 1583
 			}
1521 1584
 			// You "checking" me out? ;)
1522
-			elseif ($field['type'] == 'check')
1523
-				echo '
1585
+			elseif ($field['type'] == 'check') {
1586
+							echo '
1524 1587
 						<input type="hidden" name="', $key, '" value="0">
1525 1588
 						<input type="checkbox" name="', $key, '" id="', $key, '"', !empty($field['value']) ? ' checked' : '', ' value="1" ', $field['input_attr'], '>';
1589
+			}
1526 1590
 
1527 1591
 			// Always fun - select boxes!
1528 1592
 			elseif ($field['type'] == 'select')
@@ -1533,14 +1597,16 @@  discard block
 block discarded – undo
1533 1597
 				if (isset($field['options']))
1534 1598
 				{
1535 1599
 					// Is this some code to generate the options?
1536
-					if (!is_array($field['options']))
1537
-						$field['options'] = $field['options']();
1600
+					if (!is_array($field['options'])) {
1601
+											$field['options'] = $field['options']();
1602
+					}
1538 1603
 
1539 1604
 					// Assuming we now have some!
1540
-					if (is_array($field['options']))
1541
-						foreach ($field['options'] as $value => $name)
1605
+					if (is_array($field['options'])) {
1606
+											foreach ($field['options'] as $value => $name)
1542 1607
 							echo '
1543 1608
 							<option value="', $value, '"', $value == $field['value'] ? ' selected' : '', '>', $name, '</option>';
1609
+					}
1544 1610
 				}
1545 1611
 
1546 1612
 				echo '
@@ -1548,31 +1614,34 @@  discard block
 block discarded – undo
1548 1614
 			}
1549 1615
 
1550 1616
 			// Something to end with?
1551
-			if (!empty($field['postinput']))
1552
-				echo '
1617
+			if (!empty($field['postinput'])) {
1618
+							echo '
1553 1619
 						', $field['postinput'];
1620
+			}
1554 1621
 
1555 1622
 			echo '
1556 1623
 					</dd>';
1557 1624
 		}
1558 1625
 	}
1559 1626
 
1560
-	if (!empty($context['profile_fields']))
1561
-		echo '
1627
+	if (!empty($context['profile_fields'])) {
1628
+			echo '
1562 1629
 				</dl>';
1630
+	}
1563 1631
 
1564 1632
 	// Are there any custom profile fields - if so print them!
1565 1633
 	if (!empty($context['custom_fields']))
1566 1634
 	{
1567
-		if ($lastItem != 'hr')
1568
-			echo '
1635
+		if ($lastItem != 'hr') {
1636
+					echo '
1569 1637
 				<hr>';
1638
+		}
1570 1639
 
1571 1640
 		echo '
1572 1641
 				<dl class="settings">';
1573 1642
 
1574
-		foreach ($context['custom_fields'] as $field)
1575
-			echo '
1643
+		foreach ($context['custom_fields'] as $field) {
1644
+					echo '
1576 1645
 					<dt>
1577 1646
 						<strong>', $field['name'], ': </strong><br>
1578 1647
 						<span class="smalltext">', $field['desc'], '</span>
@@ -1580,6 +1649,7 @@  discard block
 block discarded – undo
1580 1649
 					<dd>
1581 1650
 						', $field['input_html'], '
1582 1651
 					</dd>';
1652
+		}
1583 1653
 
1584 1654
 		echo '
1585 1655
 				</dl>';
@@ -1587,13 +1657,14 @@  discard block
 block discarded – undo
1587 1657
 	}
1588 1658
 
1589 1659
 	// Any closing HTML?
1590
-	if (!empty($context['profile_posthtml']))
1591
-		echo '
1660
+	if (!empty($context['profile_posthtml'])) {
1661
+			echo '
1592 1662
 				<div>', $context['profile_posthtml'], '</div>';
1663
+	}
1593 1664
 
1594 1665
 	// Only show the password box if it's actually needed.
1595
-	if ($context['require_password'])
1596
-		echo '
1666
+	if ($context['require_password']) {
1667
+			echo '
1597 1668
 				<dl class="settings">
1598 1669
 					<dt>
1599 1670
 						<strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '><label for="oldpasswrd">', $txt['current_password'], ': </label></strong><br>
@@ -1603,18 +1674,21 @@  discard block
 block discarded – undo
1603 1674
 						<input type="password" name="oldpasswrd" id="oldpasswrd" size="20">
1604 1675
 					</dd>
1605 1676
 				</dl>';
1677
+	}
1606 1678
 
1607 1679
 	// The button shouldn't say "Change profile" unless we're changing the profile...
1608
-	if (!empty($context['submit_button_text']))
1609
-		echo '
1680
+	if (!empty($context['submit_button_text'])) {
1681
+			echo '
1610 1682
 				<input type="submit" name="save" value="', $context['submit_button_text'], '" class="button">';
1611
-	else
1612
-		echo '
1683
+	} else {
1684
+			echo '
1613 1685
 				<input type="submit" name="save" value="', $txt['change_profile'], '" class="button">';
1686
+	}
1614 1687
 
1615
-	if (!empty($context['token_check']))
1616
-		echo '
1688
+	if (!empty($context['token_check'])) {
1689
+			echo '
1617 1690
 				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
1691
+	}
1618 1692
 
1619 1693
 	echo '
1620 1694
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -1624,10 +1698,11 @@  discard block
 block discarded – undo
1624 1698
 		</form>';
1625 1699
 
1626 1700
 	// Any final spellchecking stuff?
1627
-	if (!empty($context['show_spellchecking']))
1628
-		echo '
1701
+	if (!empty($context['show_spellchecking'])) {
1702
+			echo '
1629 1703
 		<form name="spell_form" id="spell_form" method="post" accept-charset="', $context['character_set'], '" target="spellWindow" action="', $scripturl, '?action=spellcheck"><input type="hidden" name="spellstring" value=""></form>';
1630
-}
1704
+	}
1705
+	}
1631 1706
 
1632 1707
 /**
1633 1708
  * Personal Message settings.
@@ -1664,10 +1739,11 @@  discard block
 block discarded – undo
1664 1739
 						<select name="pm_receive_from" id="pm_receive_from">
1665 1740
 							<option value="0"', empty($context['receive_from']) || (empty($modSettings['enable_buddylist']) && $context['receive_from'] < 3) ? ' selected' : '', '>', $txt['pm_receive_from_everyone'], '</option>';
1666 1741
 
1667
-	if (!empty($modSettings['enable_buddylist']))
1668
-		echo '
1742
+	if (!empty($modSettings['enable_buddylist'])) {
1743
+			echo '
1669 1744
 							<option value="1"', !empty($context['receive_from']) && $context['receive_from'] == 1 ? ' selected' : '', '>', $txt['pm_receive_from_ignore'], '</option>
1670 1745
 							<option value="2"', !empty($context['receive_from']) && $context['receive_from'] == 2 ? ' selected' : '', '>', $txt['pm_receive_from_buddies'], '</option>';
1746
+	}
1671 1747
 
1672 1748
 	echo '
1673 1749
 							<option value="3"', !empty($context['receive_from']) && $context['receive_from'] > 2 ? ' selected' : '', '>', $txt['pm_receive_from_admins'], '</option>
@@ -1710,11 +1786,12 @@  discard block
 block discarded – undo
1710 1786
 		if (empty($setting) || !is_array($setting))
1711 1787
 		{
1712 1788
 			// Insert a separator (unless this is the first item in the list)
1713
-			if ($i !== $first_option_key)
1714
-				echo '
1789
+			if ($i !== $first_option_key) {
1790
+							echo '
1715 1791
 				</dl>
1716 1792
 				<hr>
1717 1793
 				<dl class="settings">';
1794
+			}
1718 1795
 
1719 1796
 			// Should we give a name to this section?
1720 1797
 			if (is_string($setting) && !empty($setting))
@@ -1723,69 +1800,67 @@  discard block
 block discarded – undo
1723 1800
 				echo '
1724 1801
 					<dt><strong>' . $setting . '</strong></dt>
1725 1802
 					<dd></dd>';
1803
+			} else {
1804
+							$titled_section = false;
1726 1805
 			}
1727
-			else
1728
-				$titled_section = false;
1729 1806
 
1730 1807
 			continue;
1731 1808
 		}
1732 1809
 
1733 1810
 		// Is this disabled?
1734
-		if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled']))
1735
-			continue;
1736
-
1737
-		elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage']))
1738
-			continue;
1739
-
1740
-		elseif ($setting['id'] == 'show_no_censored' && empty($modSettings['allow_no_censored']))
1741
-			continue;
1742
-
1743
-		elseif ($setting['id'] == 'posts_apply_ignore_list' && empty($modSettings['enable_buddylist']))
1744
-			continue;
1745
-
1746
-		elseif ($setting['id'] == 'wysiwyg_default' && !empty($modSettings['disable_wysiwyg']))
1747
-			continue;
1748
-
1749
-		elseif ($setting['id'] == 'drafts_autosave_enabled' && (empty($modSettings['drafts_autosave_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled']))))
1750
-			continue;
1751
-
1752
-		elseif ($setting['id'] == 'drafts_show_saved_enabled' && (empty($modSettings['drafts_show_saved_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled']))))
1753
-			continue;
1811
+		if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled'])) {
1812
+					continue;
1813
+		} elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) {
1814
+					continue;
1815
+		} elseif ($setting['id'] == 'show_no_censored' && empty($modSettings['allow_no_censored'])) {
1816
+					continue;
1817
+		} elseif ($setting['id'] == 'posts_apply_ignore_list' && empty($modSettings['enable_buddylist'])) {
1818
+					continue;
1819
+		} elseif ($setting['id'] == 'wysiwyg_default' && !empty($modSettings['disable_wysiwyg'])) {
1820
+					continue;
1821
+		} elseif ($setting['id'] == 'drafts_autosave_enabled' && (empty($modSettings['drafts_autosave_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) {
1822
+					continue;
1823
+		} elseif ($setting['id'] == 'drafts_show_saved_enabled' && (empty($modSettings['drafts_show_saved_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) {
1824
+					continue;
1825
+		}
1754 1826
 
1755 1827
 		// Some of these may not be set...  Set to defaults here
1756 1828
 		$opts = array('topics_per_page', 'messages_per_page', 'display_quick_mod');
1757
-		if (in_array($setting['id'], $opts) && !isset($context['member']['options'][$setting['id']]))
1758
-			$context['member']['options'][$setting['id']] = 0;
1759
-
1760
-		if (!isset($setting['type']) || $setting['type'] == 'bool')
1761
-			$setting['type'] = 'checkbox';
1762
-
1763
-		elseif ($setting['type'] == 'int' || $setting['type'] == 'integer')
1764
-			$setting['type'] = 'number';
1829
+		if (in_array($setting['id'], $opts) && !isset($context['member']['options'][$setting['id']])) {
1830
+					$context['member']['options'][$setting['id']] = 0;
1831
+		}
1765 1832
 
1766
-		elseif ($setting['type'] == 'string')
1767
-			$setting['type'] = 'text';
1833
+		if (!isset($setting['type']) || $setting['type'] == 'bool') {
1834
+					$setting['type'] = 'checkbox';
1835
+		} elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') {
1836
+					$setting['type'] = 'number';
1837
+		} elseif ($setting['type'] == 'string') {
1838
+					$setting['type'] = 'text';
1839
+		}
1768 1840
 
1769
-		if (isset($setting['options']))
1770
-			$setting['type'] = 'list';
1841
+		if (isset($setting['options'])) {
1842
+					$setting['type'] = 'list';
1843
+		}
1771 1844
 
1772 1845
 		echo '
1773 1846
 					<dt>
1774 1847
 						<label for="', $setting['id'], '">', !$titled_section ? '<strong>' : '', $setting['label'], !$titled_section ? '</strong>' : '', '</label>';
1775 1848
 
1776
-		if (isset($setting['description']))
1777
-			echo '
1849
+		if (isset($setting['description'])) {
1850
+					echo '
1778 1851
 						<br>
1779 1852
 						<span class="smalltext">', $setting['description'], '</span>';
1853
+		}
1780 1854
 		echo '
1781 1855
 					</dt>
1782 1856
 					<dd>';
1783 1857
 
1784 1858
 		// Display checkbox options
1785
-		if ($setting['type'] == 'checkbox')
1786
-			echo '
1859
+		if ($setting['type'] == 'checkbox') {
1860
+					echo '
1787 1861
 						<input type="hidden" name="default_options[' . $setting['id'] . ']" value="0">
1788 1862
 						<input type="checkbox" name="default_options[', $setting['id'], ']" id="', $setting['id'], '"', !empty($context['member']['options'][$setting['id']]) ? ' checked' : '', ' value="1">';
1863
+		}
1789 1864
 
1790 1865
 		// How about selection lists, we all love them
1791 1866
 		elseif ($setting['type'] == 'list')
@@ -1793,9 +1868,10 @@  discard block
 block discarded – undo
1793 1868
 			echo '
1794 1869
 						<select name="default_options[', $setting['id'], ']" id="', $setting['id'], '"', '>';
1795 1870
 
1796
-			foreach ($setting['options'] as $value => $label)
1797
-				echo '
1871
+			foreach ($setting['options'] as $value => $label) {
1872
+							echo '
1798 1873
 							<option value="', $value, '"', $value == $context['member']['options'][$setting['id']] ? ' selected' : '', '>', $label, '</option>';
1874
+			}
1799 1875
 
1800 1876
 			echo '
1801 1877
 						</select>';
@@ -1811,14 +1887,13 @@  discard block
 block discarded – undo
1811 1887
 
1812 1888
 				echo '
1813 1889
 						<input type="number"', $min . $max . $step;
1814
-			}
1815
-			elseif (isset($setting['type']) && $setting['type'] == 'url')
1816
-				echo'
1890
+			} elseif (isset($setting['type']) && $setting['type'] == 'url') {
1891
+							echo'
1817 1892
 						<input type="url"';
1818
-
1819
-			else
1820
-				echo '
1893
+			} else {
1894
+							echo '
1821 1895
 						<input type="text"';
1896
+			}
1822 1897
 
1823 1898
 			echo ' name="default_options[', $setting['id'], ']" id="', $setting['id'], '" value="', isset($context['member']['options'][$setting['id']]) ? $context['member']['options'][$setting['id']] : $setting['value'], '"', $setting['type'] == 'number' ? ' size="5"' : '', '>';
1824 1899
 		}
@@ -1855,8 +1930,8 @@  discard block
 block discarded – undo
1855 1930
 				<dl class="settings">';
1856 1931
 
1857 1932
 	// Allow notification on announcements to be disabled?
1858
-	if (!empty($modSettings['allow_disableAnnounce']))
1859
-		echo '
1933
+	if (!empty($modSettings['allow_disableAnnounce'])) {
1934
+			echo '
1860 1935
 					<dt>
1861 1936
 						<label for="notify_announcements">', $txt['notify_important_email'], '</label>
1862 1937
 					</dt>
@@ -1864,15 +1939,17 @@  discard block
 block discarded – undo
1864 1939
 						<input type="hidden" name="notify_announcements" value="0">
1865 1940
 						<input type="checkbox" id="notify_announcements" name="notify_announcements" value="1"', !empty($context['member']['notify_announcements']) ? ' checked' : '', '>
1866 1941
 					</dd>';
1942
+	}
1867 1943
 
1868
-	if (!empty($modSettings['enable_ajax_alerts']))
1869
-		echo '
1944
+	if (!empty($modSettings['enable_ajax_alerts'])) {
1945
+			echo '
1870 1946
 					<dt>
1871 1947
 						<label for="notify_send_body">', $txt['notify_alert_timeout'], '</label>
1872 1948
 					</dt>
1873 1949
 					<dd>
1874 1950
 						<input type="number" size="4" id="notify_alert_timeout" name="opt_alert_timeout" min="0" value="', $context['member']['alert_timeout'], '">
1875 1951
 					</dd>';
1952
+	}
1876 1953
 
1877 1954
 	echo '
1878 1955
 				</dl>
@@ -1904,9 +1981,10 @@  discard block
 block discarded – undo
1904 1981
 
1905 1982
 				$label = $txt['alert_opt_' . $opts[1]];
1906 1983
 				$label_pos = isset($opts['label']) ? $opts['label'] : '';
1907
-				if ($label_pos == 'before')
1908
-					echo '
1984
+				if ($label_pos == 'before') {
1985
+									echo '
1909 1986
 						<label for="opt_', $opts[1], '">', $label, '</label>';
1987
+				}
1910 1988
 
1911 1989
 				$this_value = isset($context['alert_prefs'][$opts[1]]) ? $context['alert_prefs'][$opts[1]] : 0;
1912 1990
 				switch ($opts[0])
@@ -1920,17 +1998,19 @@  discard block
 block discarded – undo
1920 1998
 						echo '
1921 1999
 						<select name="opt_', $opts[1], '" id="opt_', $opts[1], '">';
1922 2000
 
1923
-						foreach ($opts['opts'] as $k => $v)
1924
-							echo '
2001
+						foreach ($opts['opts'] as $k => $v) {
2002
+													echo '
1925 2003
 							<option value="', $k, '"', $this_value == $k ? ' selected' : '', '>', $v, '</option>';
2004
+						}
1926 2005
 						echo '
1927 2006
 						</select>';
1928 2007
 						break;
1929 2008
 				}
1930 2009
 
1931
-				if ($label_pos == 'after')
1932
-					echo '
2010
+				if ($label_pos == 'after') {
2011
+									echo '
1933 2012
 						<label for="opt_', $opts[1], '">', $label, '</label>';
2013
+				}
1934 2014
 
1935 2015
 				echo '
1936 2016
 					</td>
@@ -2047,11 +2127,12 @@  discard block
 block discarded – undo
2047 2127
 			<p class="information">', $txt['groupMembership_info'], '</p>';
2048 2128
 
2049 2129
 	// Do we have an update message?
2050
-	if (!empty($context['update_message']))
2051
-		echo '
2130
+	if (!empty($context['update_message'])) {
2131
+			echo '
2052 2132
 			<div class="infobox">
2053 2133
 				', $context['update_message'], '.
2054 2134
 			</div>';
2135
+	}
2055 2136
 
2056 2137
 	echo '
2057 2138
 			<div id="groups">';
@@ -2073,8 +2154,7 @@  discard block
 block discarded – undo
2073 2154
 						</div>
2074 2155
 					</div>
2075 2156
 				</div><!-- .groupmembership -->';
2076
-	}
2077
-	else
2157
+	} else
2078 2158
 	{
2079 2159
 		echo '
2080 2160
 				<div class="title_bar">
@@ -2086,27 +2166,30 @@  discard block
 block discarded – undo
2086 2166
 			echo '
2087 2167
 				<div class="windowbg" id="primdiv_', $group['id'], '">';
2088 2168
 
2089
-				if ($context['can_edit_primary'])
2090
-					echo '
2169
+				if ($context['can_edit_primary']) {
2170
+									echo '
2091 2171
 					<input type="radio" name="primary" id="primary_', $group['id'], '" value="', $group['id'], '"', $group['is_primary'] ? ' checked' : '', ' onclick="highlightSelected(\'primdiv_' . $group['id'] . '\');"', $group['can_be_primary'] ? '' : ' disabled', '>';
2172
+				}
2092 2173
 
2093 2174
 				echo '
2094 2175
 					<label for="primary_', $group['id'], '"><strong>', (empty($group['color']) ? $group['name'] : '<span style="color: ' . $group['color'] . '">' . $group['name'] . '</span>'), '</strong>', (!empty($group['desc']) ? '<br><span class="smalltext">' . $group['desc'] . '</span>' : ''), '</label>';
2095 2176
 
2096 2177
 				// Can they leave their group?
2097
-				if ($group['can_leave'])
2098
-					echo '
2178
+				if ($group['can_leave']) {
2179
+									echo '
2099 2180
 					<a href="' . $scripturl . '?action=profile;save;u=' . $context['id_member'] . ';area=groupmembership;' . $context['session_var'] . '=' . $context['session_id'] . ';gid=' . $group['id'] . ';', $context[$context['token_check'] . '_token_var'], '=', $context[$context['token_check'] . '_token'], '">' . $txt['leave_group'] . '</a>';
2181
+				}
2100 2182
 
2101 2183
 				echo '
2102 2184
 				</div><!-- .windowbg -->';
2103 2185
 		}
2104 2186
 
2105
-		if ($context['can_edit_primary'])
2106
-			echo '
2187
+		if ($context['can_edit_primary']) {
2188
+					echo '
2107 2189
 				<div class="padding righttext">
2108 2190
 					<input type="submit" value="', $txt['make_primary'], '" class="button">
2109 2191
 				</div>';
2192
+		}
2110 2193
 
2111 2194
 		// Any groups they can join?
2112 2195
 		if (!empty($context['groups']['available']))
@@ -2122,17 +2205,16 @@  discard block
 block discarded – undo
2122 2205
 				<div class="windowbg">
2123 2206
 					<strong>', (empty($group['color']) ? $group['name'] : '<span style="color: ' . $group['color'] . '">' . $group['name'] . '</span>'), '</strong>', (!empty($group['desc']) ? '<br><span class="smalltext">' . $group['desc'] . '</span>' : ''), '';
2124 2207
 
2125
-				if ($group['type'] == 3)
2126
-					echo '
2208
+				if ($group['type'] == 3) {
2209
+									echo '
2127 2210
 					<a href="', $scripturl, '?action=profile;save;u=', $context['id_member'], ';area=groupmembership;', $context['session_var'], '=', $context['session_id'], ';gid=', $group['id'], ';', $context[$context['token_check'] . '_token_var'], '=', $context[$context['token_check'] . '_token'], '" class="button floatright">', $txt['join_group'], '</a>';
2128
-
2129
-				elseif ($group['type'] == 2 && $group['pending'])
2130
-					echo '
2211
+				} elseif ($group['type'] == 2 && $group['pending']) {
2212
+									echo '
2131 2213
 					<span class="floatright">', $txt['approval_pending'], '</span>';
2132
-
2133
-				elseif ($group['type'] == 2)
2134
-					echo '
2214
+				} elseif ($group['type'] == 2) {
2215
+									echo '
2135 2216
 					<a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=groupmembership;request=', $group['id'], '" class="button floatright">', $txt['request_group'], '</a>';
2217
+				}
2136 2218
 
2137 2219
 				echo '
2138 2220
 				</div><!-- .windowbg -->';
@@ -2155,9 +2237,10 @@  discard block
 block discarded – undo
2155 2237
 
2156 2238
 						prevDiv.className = "windowbg";
2157 2239
 					}';
2158
-		if (isset($context['groups']['member'][$context['primary_group']]))
2159
-			echo '
2240
+		if (isset($context['groups']['member'][$context['primary_group']])) {
2241
+					echo '
2160 2242
 					highlightSelected("primdiv_' . $context['primary_group'] . '");';
2243
+		}
2161 2244
 
2162 2245
 		echo '
2163 2246
 				</script>';
@@ -2166,9 +2249,10 @@  discard block
 block discarded – undo
2166 2249
 	echo '
2167 2250
 			</div><!-- #groups -->';
2168 2251
 
2169
-	if (!empty($context['token_check']))
2170
-		echo '
2252
+	if (!empty($context['token_check'])) {
2253
+			echo '
2171 2254
 			<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2255
+	}
2172 2256
 
2173 2257
 	echo '
2174 2258
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -2216,14 +2300,15 @@  discard block
 block discarded – undo
2216 2300
 
2217 2301
 		foreach ($category['boards'] as $board)
2218 2302
 		{
2219
-			if ($i == $limit)
2220
-				echo '
2303
+			if ($i == $limit) {
2304
+							echo '
2221 2305
 						</ul>
2222 2306
 					</li>
2223 2307
 				</ul>
2224 2308
 				<ul class="ignoreboards floatright">
2225 2309
 					<li class="category">
2226 2310
 						<ul>';
2311
+			}
2227 2312
 
2228 2313
 			echo '
2229 2314
 							<li class="board" style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'], 'em;">
@@ -2269,10 +2354,11 @@  discard block
 block discarded – undo
2269 2354
 
2270 2355
 	// Work out the starting color.
2271 2356
 	$context['current_color'] = $context['colors'][0];
2272
-	foreach ($context['colors'] as $limit => $color)
2273
-		if ($context['member']['warning'] >= $limit)
2357
+	foreach ($context['colors'] as $limit => $color) {
2358
+			if ($context['member']['warning'] >= $limit)
2274 2359
 			$context['current_color'] = $color;
2275
-}
2360
+	}
2361
+	}
2276 2362
 
2277 2363
 // Show all warnings of a user?
2278 2364
 function template_viewWarning()
@@ -2311,14 +2397,15 @@  discard block
 block discarded – undo
2311 2397
 				</dd>';
2312 2398
 
2313 2399
 	// There's some impact of this?
2314
-	if (!empty($context['level_effects'][$context['current_level']]))
2315
-		echo '
2400
+	if (!empty($context['level_effects'][$context['current_level']])) {
2401
+			echo '
2316 2402
 				<dt>
2317 2403
 					<strong>', $txt['profile_viewwarning_impact'], ':</strong>
2318 2404
 				</dt>
2319 2405
 				<dd>
2320 2406
 					', $context['level_effects'][$context['current_level']], '
2321 2407
 				</dd>';
2408
+	}
2322 2409
 
2323 2410
 	echo '
2324 2411
 			</dl>
@@ -2356,10 +2443,11 @@  discard block
 block discarded – undo
2356 2443
 
2357 2444
 			// Otherwise see what we can do...';
2358 2445
 
2359
-	foreach ($context['notification_templates'] as $k => $type)
2360
-		echo '
2446
+	foreach ($context['notification_templates'] as $k => $type) {
2447
+			echo '
2361 2448
 			if (index == ', $k, ')
2362 2449
 				document.getElementById(\'warn_body\').value = "', strtr($type['body'], array('"' => "'", "\n" => '\\n', "\r" => '')), '";';
2450
+	}
2363 2451
 
2364 2452
 	echo '
2365 2453
 		}
@@ -2369,10 +2457,11 @@  discard block
 block discarded – undo
2369 2457
 			// Also set the right effect.
2370 2458
 			effectText = "";';
2371 2459
 
2372
-	foreach ($context['level_effects'] as $limit => $text)
2373
-		echo '
2460
+	foreach ($context['level_effects'] as $limit => $text) {
2461
+			echo '
2374 2462
 			if (slideAmount >= ', $limit, ')
2375 2463
 				effectText = "', $text, '";';
2464
+	}
2376 2465
 
2377 2466
 	echo '
2378 2467
 			setInnerHTML(document.getElementById(\'cur_level_div\'), slideAmount + \'% (\' + effectText + \')\');
@@ -2387,32 +2476,35 @@  discard block
 block discarded – undo
2387 2476
 			</h3>
2388 2477
 		</div>';
2389 2478
 
2390
-	if (!$context['user']['is_owner'])
2391
-		echo '
2479
+	if (!$context['user']['is_owner']) {
2480
+			echo '
2392 2481
 		<p class="information">', $txt['profile_warning_desc'], '</p>';
2482
+	}
2393 2483
 
2394 2484
 	echo '
2395 2485
 		<div class="windowbg">
2396 2486
 			<dl class="settings">';
2397 2487
 
2398
-	if (!$context['user']['is_owner'])
2399
-		echo '
2488
+	if (!$context['user']['is_owner']) {
2489
+			echo '
2400 2490
 				<dt>
2401 2491
 					<strong>', $txt['profile_warning_name'], ':</strong>
2402 2492
 				</dt>
2403 2493
 				<dd>
2404 2494
 					<strong>', $context['member']['name'], '</strong>
2405 2495
 				</dd>';
2496
+	}
2406 2497
 
2407 2498
 	echo '
2408 2499
 				<dt>
2409 2500
 					<strong>', $txt['profile_warning_level'], ':</strong>';
2410 2501
 
2411 2502
 	// Is there only so much they can apply?
2412
-	if ($context['warning_limit'])
2413
-		echo '
2503
+	if ($context['warning_limit']) {
2504
+			echo '
2414 2505
 					<br>
2415 2506
 					<span class="smalltext">', sprintf($txt['profile_warning_limit_attribute'], $context['warning_limit']), '</span>';
2507
+	}
2416 2508
 
2417 2509
 	echo '
2418 2510
 				</dt>
@@ -2467,9 +2559,10 @@  discard block
 block discarded – undo
2467 2559
 						<option value="-1">', $txt['profile_warning_notify_template'], '</option>
2468 2560
 						<option value="-1" disabled>------------------------------</option>';
2469 2561
 
2470
-		foreach ($context['notification_templates'] as $id_template => $template)
2471
-			echo '
2562
+		foreach ($context['notification_templates'] as $id_template => $template) {
2563
+					echo '
2472 2564
 						<option value="', $id_template, '">', $template['title'], '</option>';
2565
+		}
2473 2566
 
2474 2567
 		echo '
2475 2568
 					</select>
@@ -2482,9 +2575,10 @@  discard block
 block discarded – undo
2482 2575
 			</dl>
2483 2576
 			<div class="righttext">';
2484 2577
 
2485
-	if (!empty($context['token_check']))
2486
-		echo '
2578
+	if (!empty($context['token_check'])) {
2579
+			echo '
2487 2580
 				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2581
+	}
2488 2582
 
2489 2583
 	echo '
2490 2584
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -2500,8 +2594,8 @@  discard block
 block discarded – undo
2500 2594
 	echo '
2501 2595
 	<script>';
2502 2596
 
2503
-	if (!$context['user']['is_owner'])
2504
-		echo '
2597
+	if (!$context['user']['is_owner']) {
2598
+			echo '
2505 2599
 		modifyWarnNotify();
2506 2600
 		$(document).ready(function() {
2507 2601
 			$("#preview_button").click(function() {
@@ -2540,6 +2634,7 @@  discard block
 block discarded – undo
2540 2634
 			});
2541 2635
 			return false;
2542 2636
 		}';
2637
+	}
2543 2638
 
2544 2639
 	echo '
2545 2640
 	</script>';
@@ -2562,17 +2657,19 @@  discard block
 block discarded – undo
2562 2657
 			</div>';
2563 2658
 
2564 2659
 	// If deleting another account give them a lovely info box.
2565
-	if (!$context['user']['is_owner'])
2566
-		echo '
2660
+	if (!$context['user']['is_owner']) {
2661
+			echo '
2567 2662
 			<p class="information">', $txt['deleteAccount_desc'], '</p>';
2663
+	}
2568 2664
 
2569 2665
 	echo '
2570 2666
 			<div class="windowbg2">';
2571 2667
 
2572 2668
 	// If they are deleting their account AND the admin needs to approve it - give them another piece of info ;)
2573
-	if ($context['needs_approval'])
2574
-		echo '
2669
+	if ($context['needs_approval']) {
2670
+			echo '
2575 2671
 				<div class="errorbox">', $txt['deleteAccount_approval'], '</div>';
2672
+	}
2576 2673
 
2577 2674
 	// If the user is deleting their own account warn them first - and require a password!
2578 2675
 	if ($context['user']['is_owner'])
@@ -2584,9 +2681,10 @@  discard block
 block discarded – undo
2584 2681
 					<input type="password" name="oldpasswrd" size="20">
2585 2682
 					<input type="submit" value="', $txt['yes'], '" class="button">';
2586 2683
 
2587
-		if (!empty($context['token_check']))
2588
-			echo '
2684
+		if (!empty($context['token_check'])) {
2685
+					echo '
2589 2686
 					<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2687
+		}
2590 2688
 
2591 2689
 		echo '
2592 2690
 					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -2616,10 +2714,11 @@  discard block
 block discarded – undo
2616 2714
 						<option value="topics">', $txt['deleteAccount_topics'], '</option>
2617 2715
 					</select>';
2618 2716
 
2619
-			if ($context['show_perma_delete'])
2620
-				echo '
2717
+			if ($context['show_perma_delete']) {
2718
+							echo '
2621 2719
 					<br>
2622 2720
 					<label for="perma_delete"><input type="checkbox" name="perma_delete" id="perma_delete" value="1">', $txt['deleteAccount_permanent'], ':</label>';
2721
+			}
2623 2722
 
2624 2723
 			echo '
2625 2724
 				</div>';
@@ -2632,9 +2731,10 @@  discard block
 block discarded – undo
2632 2731
 				<div>
2633 2732
 					<input type="submit" value="', $txt['delete'], '" class="button">';
2634 2733
 
2635
-		if (!empty($context['token_check']))
2636
-			echo '
2734
+		if (!empty($context['token_check'])) {
2735
+					echo '
2637 2736
 				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2737
+		}
2638 2738
 
2639 2739
 		echo '
2640 2740
 					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -2660,8 +2760,8 @@  discard block
 block discarded – undo
2660 2760
 					<hr>';
2661 2761
 
2662 2762
 	// Only show the password box if it's actually needed.
2663
-	if ($context['require_password'])
2664
-		echo '
2763
+	if ($context['require_password']) {
2764
+			echo '
2665 2765
 					<dl class="settings">
2666 2766
 						<dt>
2667 2767
 							<strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '>', $txt['current_password'], ': </strong><br>
@@ -2671,13 +2771,15 @@  discard block
 block discarded – undo
2671 2771
 							<input type="password" name="oldpasswrd" size="20">
2672 2772
 						</dd>
2673 2773
 					</dl>';
2774
+	}
2674 2775
 
2675 2776
 	echo '
2676 2777
 					<div class="righttext">';
2677 2778
 
2678
-	if (!empty($context['token_check']))
2679
-		echo '
2779
+	if (!empty($context['token_check'])) {
2780
+			echo '
2680 2781
 						<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
2782
+	}
2681 2783
 
2682 2784
 	echo '
2683 2785
 						<input type="submit" value="', $txt['change_profile'], '" class="button">
@@ -2704,9 +2806,10 @@  discard block
 block discarded – undo
2704 2806
 			<ul id="list_errors">';
2705 2807
 
2706 2808
 		// Cycle through each error and display an error message.
2707
-		foreach ($context['post_errors'] as $error)
2708
-			echo '
2809
+		foreach ($context['post_errors'] as $error) {
2810
+					echo '
2709 2811
 				<li>', isset($txt['profile_error_' . $error]) ? $txt['profile_error_' . $error] : $error, '</li>';
2812
+		}
2710 2813
 
2711 2814
 		echo '
2712 2815
 			</ul>';
@@ -2732,12 +2835,13 @@  discard block
 block discarded – undo
2732 2835
 								<select name="id_group" ', ($context['user']['is_owner'] && $context['member']['group_id'] == 1 ? 'onchange="if (this.value != 1 &amp;&amp; !confirm(\'' . $txt['deadmin_confirm'] . '\')) this.value = 1;"' : ''), '>';
2733 2836
 
2734 2837
 	// Fill the select box with all primary member groups that can be assigned to a member.
2735
-	foreach ($context['member_groups'] as $member_group)
2736
-		if (!empty($member_group['can_be_primary']))
2838
+	foreach ($context['member_groups'] as $member_group) {
2839
+			if (!empty($member_group['can_be_primary']))
2737 2840
 			echo '
2738 2841
 									<option value="', $member_group['id'], '"', $member_group['is_primary'] ? ' selected' : '', '>
2739 2842
 										', $member_group['name'], '
2740 2843
 									</option>';
2844
+	}
2741 2845
 
2742 2846
 	echo '
2743 2847
 								</select>
@@ -2750,10 +2854,11 @@  discard block
 block discarded – undo
2750 2854
 									<input type="hidden" name="additional_groups[]" value="0">';
2751 2855
 
2752 2856
 	// For each membergroup show a checkbox so members can be assigned to more than one group.
2753
-	foreach ($context['member_groups'] as $member_group)
2754
-		if ($member_group['can_be_additional'])
2857
+	foreach ($context['member_groups'] as $member_group) {
2858
+			if ($member_group['can_be_additional'])
2755 2859
 			echo '
2756 2860
 									<label for="additional_groups-', $member_group['id'], '"><input type="checkbox" name="additional_groups[]" value="', $member_group['id'], '" id="additional_groups-', $member_group['id'], '"', $member_group['is_additional'] ? ' checked' : '', '> ', $member_group['name'], '</label><br>';
2861
+	}
2757 2862
 
2758 2863
 	echo '
2759 2864
 								</span>
@@ -2813,9 +2918,10 @@  discard block
 block discarded – undo
2813 2918
 								<span class="smalltext">', $txt['sig_info'], '</span><br>
2814 2919
 								<br>';
2815 2920
 
2816
-	if ($context['show_spellchecking'])
2817
-		echo '
2921
+	if ($context['show_spellchecking']) {
2922
+			echo '
2818 2923
 								<input type="button" value="', $txt['spell_check'], '" onclick="spellCheck(\'creator\', \'signature\');" class="button">';
2924
+	}
2819 2925
 
2820 2926
 	echo '
2821 2927
 							</dt>
@@ -2823,17 +2929,20 @@  discard block
 block discarded – undo
2823 2929
 								<textarea class="editor" onkeyup="calcCharLeft();" id="signature" name="signature" rows="5" cols="50">', $context['member']['signature'], '</textarea><br>';
2824 2930
 
2825 2931
 	// If there is a limit at all!
2826
-	if (!empty($context['signature_limits']['max_length']))
2827
-		echo '
2932
+	if (!empty($context['signature_limits']['max_length'])) {
2933
+			echo '
2828 2934
 								<span class="smalltext">', sprintf($txt['max_sig_characters'], $context['signature_limits']['max_length']), ' <span id="signatureLeft">', $context['signature_limits']['max_length'], '</span></span><br>';
2935
+	}
2829 2936
 
2830
-	if (!empty($context['show_preview_button']))
2831
-		echo '
2937
+	if (!empty($context['show_preview_button'])) {
2938
+			echo '
2832 2939
 								<input type="button" name="preview_signature" id="preview_button" value="', $txt['preview_signature'], '" class="button">';
2940
+	}
2833 2941
 
2834
-	if ($context['signature_warning'])
2835
-		echo '
2942
+	if ($context['signature_warning']) {
2943
+			echo '
2836 2944
 								<span class="smalltext">', $context['signature_warning'], '</span>';
2945
+	}
2837 2946
 
2838 2947
 	// Some javascript used to count how many characters have been used so far in the signature.
2839 2948
 	echo '
@@ -2878,9 +2987,10 @@  discard block
 block discarded – undo
2878 2987
 										<select name="cat" id="cat" size="10" onchange="changeSel(\'\');" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'server_stored\');">';
2879 2988
 
2880 2989
 		// This lists all the file categories.
2881
-		foreach ($context['avatars'] as $avatar)
2882
-			echo '
2990
+		foreach ($context['avatars'] as $avatar) {
2991
+					echo '
2883 2992
 											<option value="', $avatar['filename'] . ($avatar['is_dir'] ? '/' : ''), '"', ($avatar['checked'] ? ' selected' : ''), '>', $avatar['name'], '</option>';
2993
+		}
2884 2994
 
2885 2995
 		echo '
2886 2996
 										</select>
@@ -2912,20 +3022,22 @@  discard block
 block discarded – undo
2912 3022
 	}
2913 3023
 
2914 3024
 	// If the user can link to an off server avatar, show them a box to input the address.
2915
-	if (!empty($context['member']['avatar']['allow_external']))
2916
-		echo '
3025
+	if (!empty($context['member']['avatar']['allow_external'])) {
3026
+			echo '
2917 3027
 								<div id="avatar_external">
2918 3028
 									<div class="smalltext">', $txt['avatar_by_url'], '</div>', !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_download_and_resize' ? template_max_size('external') : '', '
2919 3029
 									<input type="text" name="userpicpersonal" size="45" value="', ((stristr($context['member']['avatar']['external'], 'http://') || stristr($context['member']['avatar']['external'], 'https://')) ? $context['member']['avatar']['external'] : 'http://'), '" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'external\');" onchange="if (typeof(previewExternalAvatar) != \'undefined\') previewExternalAvatar(this.value);">
2920 3030
 								</div>';
3031
+	}
2921 3032
 
2922 3033
 	// If the user is able to upload avatars to the server show them an upload box.
2923
-	if (!empty($context['member']['avatar']['allow_upload']))
2924
-		echo '
3034
+	if (!empty($context['member']['avatar']['allow_upload'])) {
3035
+			echo '
2925 3036
 								<div id="avatar_upload">
2926 3037
 									<input type="file" size="44" name="attachment" id="avatar_upload_box" value="" onchange="readfromUpload(this)"  onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'upload\');" accept="image/gif, image/jpeg, image/jpg, image/png">', template_max_size('upload'), '
2927 3038
 									', (!empty($context['member']['avatar']['id_attach']) ? '<br><img src="' . $context['member']['avatar']['href'] . (strpos($context['member']['avatar']['href'], '?') === false ? '?' : '&amp;') . 'time=' . time() . '" alt="" id="attached_image"><input type="hidden" name="id_attach" value="' . $context['member']['avatar']['id_attach'] . '">' : ''), '
2928 3039
 								</div>';
3040
+	}
2929 3041
 
2930 3042
 	// if the user is able to use Gravatar avatars show then the image preview
2931 3043
 	if (!empty($context['member']['avatar']['allow_gravatar']))
@@ -2934,16 +3046,17 @@  discard block
 block discarded – undo
2934 3046
 								<div id="avatar_gravatar">
2935 3047
 									<img src="' . $context['member']['avatar']['href'] . '" alt="">';
2936 3048
 
2937
-		if (empty($modSettings['gravatarAllowExtraEmail']))
2938
-			echo '
3049
+		if (empty($modSettings['gravatarAllowExtraEmail'])) {
3050
+					echo '
2939 3051
 									<div class="smalltext">', $txt['gravatar_noAlternateEmail'], '</div>';
2940
-		else
3052
+		} else
2941 3053
 		{
2942 3054
 			// Depending on other stuff, the stored value here might have some odd things in it from other areas.
2943
-			if ($context['member']['avatar']['external'] == $context['member']['email'])
2944
-				$textbox_value = '';
2945
-			else
2946
-				$textbox_value = $context['member']['avatar']['external'];
3055
+			if ($context['member']['avatar']['external'] == $context['member']['email']) {
3056
+							$textbox_value = '';
3057
+			} else {
3058
+							$textbox_value = $context['member']['avatar']['external'];
3059
+			}
2947 3060
 
2948 3061
 			echo '
2949 3062
 									<div class="smalltext">', $txt['gravatar_alternateEmail'], '</div>
@@ -3015,8 +3128,9 @@  discard block
 block discarded – undo
3015 3128
 	$h = !empty($modSettings['avatar_max_height_' . $type]) ? comma_format($modSettings['avatar_max_height_' . $type]) : 0;
3016 3129
 
3017 3130
 	$suffix = (!empty($w) ? 'w' : '') . (!empty($h) ? 'h' : '');
3018
-	if (empty($suffix))
3019
-		return;
3131
+	if (empty($suffix)) {
3132
+			return;
3133
+	}
3020 3134
 
3021 3135
 	echo '
3022 3136
 								<div class="smalltext">', sprintf($txt['avatar_max_size_' . $suffix], $w, $h), '</div>';
@@ -3041,9 +3155,10 @@  discard block
 block discarded – undo
3041 3155
 								<select name="easyformat" id="easyformat" onchange="document.forms.creator.time_format.value = this.options[this.selectedIndex].value;">';
3042 3156
 
3043 3157
 	// Help the user by showing a list of common time formats.
3044
-	foreach ($context['easy_timeformats'] as $time_format)
3045
-		echo '
3158
+	foreach ($context['easy_timeformats'] as $time_format) {
3159
+			echo '
3046 3160
 									<option value="', $time_format['format'], '"', $time_format['format'] == $context['member']['time_format'] ? ' selected' : '', '>', $time_format['title'], '</option>';
3161
+	}
3047 3162
 
3048 3163
 	echo '
3049 3164
 								</select><br>
@@ -3081,9 +3196,10 @@  discard block
 block discarded – undo
3081 3196
 							<dd>
3082 3197
 								<select name="smiley_set" id="smiley_set" onchange="document.getElementById(\'smileypr\').src = this.selectedIndex == 0 ? \'', $settings['images_url'], '/blank.png\' : \'', $modSettings['smileys_url'], '/\' + (this.selectedIndex != 1 ? this.options[this.selectedIndex].value : \'', !empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default'], '\') + \'/smiley.gif\';">';
3083 3198
 
3084
-	foreach ($context['smiley_sets'] as $set)
3085
-		echo '
3199
+	foreach ($context['smiley_sets'] as $set) {
3200
+			echo '
3086 3201
 									<option value="', $set['id'], '"', $set['selected'] ? ' selected' : '', '>', $set['name'], '</option>';
3202
+	}
3087 3203
 
3088 3204
 	echo '
3089 3205
 								</select>
@@ -3135,10 +3251,11 @@  discard block
 block discarded – undo
3135 3251
 										<img src="', $context['tfa_qr_url'], '" alt="">
3136 3252
 									</div>';
3137 3253
 
3138
-	if (!empty($context['from_ajax']))
3139
-		echo '
3254
+	if (!empty($context['from_ajax'])) {
3255
+			echo '
3140 3256
 					<br>
3141 3257
 					<a href="javascript:self.close();"></a>';
3258
+	}
3142 3259
 
3143 3260
 	echo '
3144 3261
 				</div>
@@ -3178,17 +3295,16 @@  discard block
 block discarded – undo
3178 3295
 							</dt>
3179 3296
 							<dd>';
3180 3297
 
3181
-	if (!$context['tfa_enabled'] && $context['user']['is_owner'])
3182
-		echo '
3298
+	if (!$context['tfa_enabled'] && $context['user']['is_owner']) {
3299
+			echo '
3183 3300
 								<a href="', !empty($modSettings['force_ssl']) && $modSettings['force_ssl'] < 2 ? strtr($scripturl, array('http://' => 'https://')) : $scripturl, '?action=profile;area=tfasetup" id="enable_tfa">', $txt['tfa_profile_enable'], '</a>';
3184
-
3185
-	elseif (!$context['tfa_enabled'])
3186
-		echo '
3301
+	} elseif (!$context['tfa_enabled']) {
3302
+			echo '
3187 3303
 								', $txt['tfa_profile_disabled'];
3188
-
3189
-	else
3190
-		echo '
3304
+	} else {
3305
+			echo '
3191 3306
 								', sprintf($txt['tfa_profile_enabled'], $scripturl . '?action=profile;u=' . $context['id_member'] . ';area=tfasetup;disable');
3307
+	}
3192 3308
 
3193 3309
 	echo '
3194 3310
 							</dd>';
Please login to merge, or discard this patch.
Themes/default/PersonalMessage.template.php 1 patch
Braces   +291 added lines, -203 removed lines patch added patch discarded remove patch
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
 	<div id="personal_messages">';
22 22
 
23 23
 	// Show the capacity bar, if available.
24
-	if (!empty($context['limit_bar']))
25
-		echo '
24
+	if (!empty($context['limit_bar'])) {
25
+			echo '
26 26
 		<div class="cat_bar">
27 27
 			<h3 class="catbg">
28 28
 				<span class="floatleft">', $txt['pm_capacity'], ':</span>
@@ -32,14 +32,16 @@  discard block
 block discarded – undo
32 32
 				<span class="floatright', $context['limit_bar']['percent'] > 90 ? ' alert' : '', '">', $context['limit_bar']['text'], '</span>
33 33
 			</h3>
34 34
 		</div>';
35
+	}
35 36
 
36 37
 	// Message sent? Show a small indication.
37
-	if (isset($context['pm_sent']))
38
-		echo '
38
+	if (isset($context['pm_sent'])) {
39
+			echo '
39 40
 		<div class="infobox">
40 41
 			', $txt['pm_sent'], '
41 42
 		</div>';
42
-}
43
+	}
44
+	}
43 45
 
44 46
 /**
45 47
  * Just the end of the index bar, nothing special.
@@ -68,13 +70,13 @@  discard block
 block discarded – undo
68 70
 		</div>
69 71
 		<div class="pm_unread">';
70 72
 
71
-	if (empty($context['unread_pms']))
72
-		echo '
73
+	if (empty($context['unread_pms'])) {
74
+			echo '
73 75
 			<div class="no_unread">', $txt['pm_no_unread'], '</div>';
74
-	else
76
+	} else
75 77
 	{
76
-		foreach ($context['unread_pms'] as $id_pm => $pm_details)
77
-			echo '
78
+		foreach ($context['unread_pms'] as $id_pm => $pm_details) {
79
+					echo '
78 80
 			<div class="unread">
79 81
 				', !empty($pm_details['member']) ? $pm_details['member']['avatar']['image'] : '', '
80 82
 				<div class="details">
@@ -85,6 +87,7 @@  discard block
 block discarded – undo
85 87
 					</div>
86 88
 				</div>
87 89
 			</div>';
90
+		}
88 91
 	}
89 92
 
90 93
 	echo '
@@ -193,14 +196,15 @@  discard block
 block discarded – undo
193 196
 	if ($context['get_pmessage']('message', true))
194 197
 	{
195 198
 		// Show the helpful titlebar - generally.
196
-		if ($context['display_mode'] != 1)
197
-			echo '
199
+		if ($context['display_mode'] != 1) {
200
+					echo '
198 201
 			<div class="cat_bar">
199 202
 				<h3 class="catbg">
200 203
 					<span id="author">', $txt['author'], '</span>
201 204
 					<span id="topic_title">', $txt[$context['display_mode'] == 0 ? 'messages' : 'conversation'], '</span>
202 205
 				</h3>
203 206
 			</div>';
207
+		}
204 208
 
205 209
 		// Show a few buttons if we are in conversation mode and outputting the first message.
206 210
 		if ($context['display_mode'] == 2)
@@ -229,9 +233,10 @@  discard block
 block discarded – undo
229 233
 					<div class="custom_fields_above_member">
230 234
 						<ul class="nolist">';
231 235
 
232
-				foreach ($message['custom_fields']['above_member'] as $custom)
233
-					echo '
236
+				foreach ($message['custom_fields']['above_member'] as $custom) {
237
+									echo '
234 238
 							<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
239
+				}
235 240
 
236 241
 				echo '
237 242
 						</ul>
@@ -243,25 +248,28 @@  discard block
 block discarded – undo
243 248
 						<a id="msg', $message['id'], '"></a>';
244 249
 
245 250
 			// Show online and offline buttons?
246
-			if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest'])
247
-				echo '
251
+			if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) {
252
+							echo '
248 253
 						<span class="' . ($message['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $message['member']['online']['text'] . '"></span>';
254
+			}
249 255
 
250 256
 			// Custom fields BEFORE the username?
251
-			if (!empty($message['custom_fields']['before_member']))
252
-				foreach ($message['custom_fields']['before_member'] as $custom)
257
+			if (!empty($message['custom_fields']['before_member'])) {
258
+							foreach ($message['custom_fields']['before_member'] as $custom)
253 259
 					echo '
254 260
 						<span class="custom ', $custom['col_name'], '">', $custom['value'], '</span>';
261
+			}
255 262
 
256 263
 			// Show a link to the member's profile.
257 264
 			echo '
258 265
 				', $message['member']['link'];
259 266
 
260 267
 				// Custom fields AFTER the username?
261
-				if (!empty($message['custom_fields']['after_member']))
262
-					foreach ($message['custom_fields']['after_member'] as $custom)
268
+				if (!empty($message['custom_fields']['after_member'])) {
269
+									foreach ($message['custom_fields']['after_member'] as $custom)
263 270
 						echo '
264 271
 						<span class="custom ', $custom['col_name'], '">', $custom['value'], '</span>';
272
+				}
265 273
 
266 274
 			echo '
267 275
 					</h4>';
@@ -270,48 +278,56 @@  discard block
 block discarded – undo
270 278
 					<ul class="user_info">';
271 279
 
272 280
 			// Show the user's avatar.
273
-			if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image']))
274
-				echo '
281
+			if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) {
282
+							echo '
275 283
 						<li class="avatar">
276 284
 							<a href="', $scripturl, '?action=profile;u=', $message['member']['id'], '">', $message['member']['avatar']['image'], '</a>
277 285
 						</li>';
286
+			}
278 287
 
279 288
 			// Are there any custom fields below the avatar?
280
-			if (!empty($message['custom_fields']['below_avatar']))
281
-				foreach ($message['custom_fields']['below_avatar'] as $custom)
289
+			if (!empty($message['custom_fields']['below_avatar'])) {
290
+							foreach ($message['custom_fields']['below_avatar'] as $custom)
282 291
 					echo '
283 292
 						<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
293
+			}
284 294
 
285
-			if (!$message['member']['is_guest'])
286
-				echo '
295
+			if (!$message['member']['is_guest']) {
296
+							echo '
287 297
 						<li class="icons">', $message['member']['group_icons'], '</li>';
298
+			}
288 299
 			// Show the member's primary group (like 'Administrator') if they have one.
289
-			if (isset($message['member']['group']) && $message['member']['group'] != '')
290
-				echo '
300
+			if (isset($message['member']['group']) && $message['member']['group'] != '') {
301
+							echo '
291 302
 						<li class="membergroup">', $message['member']['group'], '</li>';
303
+			}
292 304
 
293 305
 			// Show the member's custom title, if they have one.
294
-			if (isset($message['member']['title']) && $message['member']['title'] != '')
295
-				echo '
306
+			if (isset($message['member']['title']) && $message['member']['title'] != '') {
307
+							echo '
296 308
 						<li class="title">', $message['member']['title'], '</li>';
309
+			}
297 310
 
298 311
 			// Don't show these things for guests.
299 312
 			if (!$message['member']['is_guest'])
300 313
 			{
301 314
 				// 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.
302
-				if ((empty($modSettings['hide_post_group']) || $message['member']['group'] == '') && $message['member']['post_group'] != '')
303
-					echo '
315
+				if ((empty($modSettings['hide_post_group']) || $message['member']['group'] == '') && $message['member']['post_group'] != '') {
316
+									echo '
304 317
 						<li class="postgroup">', $message['member']['post_group'], '</li>';
318
+				}
305 319
 
306 320
 				// Show how many posts they have made.
307
-				if (!isset($context['disabled_fields']['posts']))
308
-					echo '
321
+				if (!isset($context['disabled_fields']['posts'])) {
322
+									echo '
309 323
 						<li class="postcount">', $txt['member_postcount'], ': ', $message['member']['posts'], '</li>';
324
+				}
310 325
 
311 326
 				// Show their personal text?
312
-				if (!empty($modSettings['show_blurb']) && $message['member']['blurb'] != '')
313
-					echo '
327
+				if (!empty($modSettings['show_blurb']) && $message['member']['blurb'] != '') {
328
+									echo '
314 329
 						<li class="blurb">', $message['member']['blurb'], '</li>';
330
+				}
315 331
 
316 332
 				// Any custom fields to show as icons?
317 333
 				if (!empty($message['custom_fields']['icons']))
@@ -320,9 +336,10 @@  discard block
 block discarded – undo
320 336
 						<li class="im_icons">
321 337
 							<ol>';
322 338
 
323
-					foreach ($message['custom_fields']['icons'] as $custom)
324
-						echo '
339
+					foreach ($message['custom_fields']['icons'] as $custom) {
340
+											echo '
325 341
 								<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
342
+					}
326 343
 
327 344
 					echo '
328 345
 							</ol>
@@ -330,25 +347,28 @@  discard block
 block discarded – undo
330 347
 				}
331 348
 
332 349
 				// Show the IP to this user for this post - because you can moderate?
333
-				if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip']))
334
-					echo '
350
+				if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) {
351
+									echo '
335 352
 						<li class="poster_ip">
336 353
 							<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>
337 354
 						</li>';
355
+				}
338 356
 
339 357
 				// Or, should we show it because this is you?
340
-				elseif ($message['can_see_ip'])
341
-					echo '
358
+				elseif ($message['can_see_ip']) {
359
+									echo '
342 360
 						<li class="poster_ip">
343 361
 							<a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $message['member']['ip'], '</a>
344 362
 						</li>';
363
+				}
345 364
 
346 365
 				// Okay, you are logged in, then we can show something about why IPs are logged...
347
-				else
348
-					echo '
366
+				else {
367
+									echo '
349 368
 						<li class="poster_ip">
350 369
 							<a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $txt['logged'], '</a>
351 370
 						</li>';
371
+				}
352 372
 
353 373
 				// Show the profile, website, email address, and personal message buttons.
354 374
 				if ($message['member']['show_profile_buttons'])
@@ -358,24 +378,28 @@  discard block
 block discarded – undo
358 378
 							<ol class="profile_icons">';
359 379
 
360 380
 					// Show the profile button
361
-					if ($message['member']['can_view_profile'])
362
-						echo '
381
+					if ($message['member']['can_view_profile']) {
382
+											echo '
363 383
 								<li><a href="', $message['member']['href'], '">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/icons/profile_sm.png" alt="' . $txt['view_profile'] . '" title="' . $txt['view_profile'] . '">' : $txt['view_profile']), '</a></li>';
384
+					}
364 385
 
365 386
 					// Don't show an icon if they haven't specified a website.
366
-					if ($message['member']['website']['url'] != '' && !isset($context['disabled_fields']['website']))
367
-						echo '
387
+					if ($message['member']['website']['url'] != '' && !isset($context['disabled_fields']['website'])) {
388
+											echo '
368 389
 								<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>';
390
+					}
369 391
 
370 392
 					// Don't show the email address if they want it hidden.
371
-					if ($message['member']['show_email'])
372
-						echo '
393
+					if ($message['member']['show_email']) {
394
+											echo '
373 395
 								<li><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>';
396
+					}
374 397
 
375 398
 					// Since we know this person isn't a guest, you *can* message them.
376
-					if ($context['can_send_pm'])
377
-						echo '
399
+					if ($context['can_send_pm']) {
400
+											echo '
378 401
 								<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>';
402
+					}
379 403
 
380 404
 					echo '
381 405
 							</ol>
@@ -383,21 +407,24 @@  discard block
 block discarded – undo
383 407
 				}
384 408
 
385 409
 				// Any custom fields for standard placement?
386
-				if (!empty($message['custom_fields']['standard']))
387
-					foreach ($message['custom_fields']['standard'] as $custom)
410
+				if (!empty($message['custom_fields']['standard'])) {
411
+									foreach ($message['custom_fields']['standard'] as $custom)
388 412
 						echo '
389 413
 						<li class="custom ', $custom['col_name'] ,'">', $custom['title'], ': ', $custom['value'], '</li>';
414
+				}
390 415
 
391 416
 				// Are we showing the warning status?
392
-				if ($message['member']['can_see_warning'])
393
-					echo '
417
+				if ($message['member']['can_see_warning']) {
418
+									echo '
394 419
 						<li class="warning">', $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></li>';
420
+				}
395 421
 
396 422
 				// Are there any custom fields to show at the bottom of the poster info?
397
-				if (!empty($message['custom_fields']['bottom_poster']))
398
-					foreach ($message['custom_fields']['bottom_poster'] as $custom)
423
+				if (!empty($message['custom_fields']['bottom_poster'])) {
424
+									foreach ($message['custom_fields']['bottom_poster'] as $custom)
399 425
 						echo '
400 426
 						<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
427
+				}
401 428
 			}
402 429
 
403 430
 			// Done with the information about the poster... on to the post itself.
@@ -416,25 +443,29 @@  discard block
 block discarded – undo
416 443
 							<span class="smalltext">&#171; <strong> ', $txt['sent_to'], ':</strong> ';
417 444
 
418 445
 			// People it was sent directly to....
419
-			if (!empty($message['recipients']['to']))
420
-				echo implode(', ', $message['recipients']['to']);
446
+			if (!empty($message['recipients']['to'])) {
447
+							echo implode(', ', $message['recipients']['to']);
448
+			}
421 449
 
422 450
 			// Otherwise, we're just going to say "some people"...
423
-			elseif ($context['folder'] != 'sent')
424
-				echo '(', $txt['pm_undisclosed_recipients'], ')';
451
+			elseif ($context['folder'] != 'sent') {
452
+							echo '(', $txt['pm_undisclosed_recipients'], ')';
453
+			}
425 454
 
426 455
 			echo '
427 456
 								<strong> ', $txt['on'], ':</strong> ', $message['time'], ' &#187;
428 457
 							</span>';
429 458
 
430 459
 			// If we're in the sent items, show who it was sent to besides the "To:" people.
431
-			if (!empty($message['recipients']['bcc']))
432
-				echo '<br>
460
+			if (!empty($message['recipients']['bcc'])) {
461
+							echo '<br>
433 462
 							<span class="smalltext">&#171; <strong> ', $txt['pm_bcc'], ':</strong> ', implode(', ', $message['recipients']['bcc']), ' &#187;</span>';
463
+			}
434 464
 
435
-			if (!empty($message['is_replied_to']))
436
-				echo '<br>
465
+			if (!empty($message['is_replied_to'])) {
466
+							echo '<br>
437 467
 							<span class="smalltext">&#171; ', $context['folder'] == 'sent' ? $txt['pm_sent_is_replied_to'] : $txt['pm_is_replied_to'], ' &#187;</span>';
468
+			}
438 469
 
439 470
 			echo '
440 471
 						</div><!-- .keyinfo -->
@@ -444,13 +475,15 @@  discard block
 block discarded – undo
444 475
 							', $message['body'], '
445 476
 						</div>';
446 477
 
447
-			if ($message['can_report'] || $context['can_send_pm'])
448
-				echo '
478
+			if ($message['can_report'] || $context['can_send_pm']) {
479
+							echo '
449 480
 						<div class="under_message">';
481
+			}
450 482
 
451
-			if ($message['can_report'])
452
-				echo '
483
+			if ($message['can_report']) {
484
+							echo '
453 485
 							<a href="' . $scripturl . '?action=pm;sa=report;l=' . $context['current_label_id'] . ';pmsg=' . $message['id'] . '" class="floatright">' . $txt['pm_report_to_admin'] . '</a>';
486
+			}
454 487
 
455 488
 			echo '
456 489
 							<ul class="quickbuttons">';
@@ -462,32 +495,36 @@  discard block
 block discarded – undo
462 495
 				if (!$message['member']['is_guest'])
463 496
 				{
464 497
 					// Is there than more than one recipient you can reply to?
465
-					if ($message['number_recipients'] > 1)
466
-						echo '
498
+					if ($message['number_recipients'] > 1) {
499
+											echo '
467 500
 								<li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote;u=all"><span class="generic_icons reply_all_button"></span>', $txt['reply_to_all'], '</a></li>';
501
+					}
468 502
 
469 503
 					echo '
470 504
 								<li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';u=', $message['member']['id'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>
471 505
 								<li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote', $context['folder'] == 'sent' ? '' : ';u=' . $message['member']['id'], '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>';
472 506
 				}
473 507
 				// This is for "forwarding" - even if the member is gone.
474
-				else
475
-					echo '
508
+				else {
509
+									echo '
476 510
 								<li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote"><span class="generic_icons quote"></span>', $txt['reply_quote'], '</a></li>';
511
+				}
477 512
 			}
478 513
 			echo '
479 514
 								<li><a href="', $scripturl, '?action=pm;sa=pmactions;pm_actions%5b', $message['id'], '%5D=delete;f=', $context['folder'], ';start=', $context['start'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', addslashes($txt['remove_message_question']), '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['delete'], '</a></li>';
480 515
 
481
-			if (empty($context['display_mode']))
482
-				echo '
516
+			if (empty($context['display_mode'])) {
517
+							echo '
483 518
 								<li><input type="checkbox" name="pms[]" id="deletedisplay', $message['id'], '" value="', $message['id'], '" onclick="document.getElementById(\'deletelisting', $message['id'], '\').checked = this.checked;"></li>';
519
+			}
484 520
 
485 521
 			echo '
486 522
 							</ul>';
487 523
 
488
-			if ($message['can_report'] || $context['can_send_pm'])
489
-			echo '
524
+			if ($message['can_report'] || $context['can_send_pm']) {
525
+						echo '
490 526
 						</div><!-- .under_message -->';
527
+			}
491 528
 
492 529
 			// Are there any custom profile fields for above the signature?
493 530
 			if (!empty($message['custom_fields']['above_signature']))
@@ -496,9 +533,10 @@  discard block
 block discarded – undo
496 533
 						<div class="custom_fields_above_signature">
497 534
 							<ul class="nolist">';
498 535
 
499
-				foreach ($message['custom_fields']['above_signature'] as $custom)
500
-					echo '
536
+				foreach ($message['custom_fields']['above_signature'] as $custom) {
537
+									echo '
501 538
 								<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
539
+				}
502 540
 
503 541
 				echo '
504 542
 							</ul>
@@ -506,11 +544,12 @@  discard block
 block discarded – undo
506 544
 			}
507 545
 
508 546
 			// Show the member's signature?
509
-			if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled'])
510
-				echo '
547
+			if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) {
548
+							echo '
511 549
 						<div class="signature">
512 550
 							', $message['member']['signature'], '
513 551
 						</div>';
552
+			}
514 553
 
515 554
 			// Are there any custom profile fields for below the signature?
516 555
 			if (!empty($message['custom_fields']['below_signature']))
@@ -519,9 +558,10 @@  discard block
 block discarded – undo
519 558
 						<div class="custom_fields_below_signature">
520 559
 							<ul class="nolist">';
521 560
 
522
-				foreach ($message['custom_fields']['below_signature'] as $custom)
523
-					echo '
561
+				foreach ($message['custom_fields']['below_signature'] as $custom) {
562
+									echo '
524 563
 								<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
564
+				}
525 565
 
526 566
 				echo '
527 567
 							</ul>
@@ -548,10 +588,11 @@  discard block
 block discarded – undo
548 588
 						echo '
549 589
 								<option value="" disabled>', $txt['pm_msg_label_apply'], ':</option>';
550 590
 
551
-						foreach ($context['labels'] as $label)
552
-							if (!isset($message['labels'][$label['id']]))
591
+						foreach ($context['labels'] as $label) {
592
+													if (!isset($message['labels'][$label['id']]))
553 593
 								echo '
554 594
 								<option value="', $label['id'], '">', $label['name'], '</option>';
595
+						}
555 596
 					}
556 597
 
557 598
 					// ... and are there any that can be removed?
@@ -560,9 +601,10 @@  discard block
 block discarded – undo
560 601
 						echo '
561 602
 								<option value="" disabled>', $txt['pm_msg_label_remove'], ':</option>';
562 603
 
563
-						foreach ($message['labels'] as $label)
564
-							echo '
604
+						foreach ($message['labels'] as $label) {
605
+													echo '
565 606
 								<option value="', $label['id'], '">&nbsp;', $label['name'], '</option>';
607
+						}
566 608
 					}
567 609
 					echo '
568 610
 							</select>
@@ -581,14 +623,15 @@  discard block
 block discarded – undo
581 623
 			</div><!-- .windowbg -->';
582 624
 		}
583 625
 
584
-		if (empty($context['display_mode']))
585
-			echo '
626
+		if (empty($context['display_mode'])) {
627
+					echo '
586 628
 			<div class="pagesection">
587 629
 				<div class="floatleft">', $context['page_index'], '</div>
588 630
 				<div class="floatright">
589 631
 					<input type="submit" name="del_selected" value="', $txt['quickmod_delete_selected'], '" onclick="if (!confirm(\'', $txt['delete_selected_confirm'], '\')) return false;" class="button">
590 632
 				</div>
591 633
 			</div>';
634
+		}
592 635
 
593 636
 		// Show a few buttons if we are in conversation mode and outputting the first message.
594 637
 		elseif ($context['display_mode'] == 2 && isset($context['conversation_buttons']))
@@ -648,11 +691,12 @@  discard block
 block discarded – undo
648 691
 		</thead>
649 692
 		<tbody>';
650 693
 
651
-	if (!$context['show_delete'])
652
-		echo '
694
+	if (!$context['show_delete']) {
695
+			echo '
653 696
 			<tr class="windowbg">
654 697
 				<td colspan="5">', $txt['pm_alert_none'], '</td>
655 698
 			</tr>';
699
+	}
656 700
 
657 701
 	while ($message = $context['get_pmessage']('subject'))
658 702
 	{
@@ -710,17 +754,19 @@  discard block
 block discarded – undo
710 754
 
711 755
 			foreach ($context['labels'] as $label)
712 756
 			{
713
-				if ($label['id'] != $context['current_label_id'])
714
-					echo '
757
+				if ($label['id'] != $context['current_label_id']) {
758
+									echo '
715 759
 				<option value="add_', $label['id'], '">&nbsp;', $label['name'], '</option>';
760
+				}
716 761
 			}
717 762
 
718 763
 			echo '
719 764
 				<option value="" disabled>', $txt['pm_msg_label_remove'], ':</option>';
720 765
 
721
-			foreach ($context['labels'] as $label)
722
-				echo '
766
+			foreach ($context['labels'] as $label) {
767
+							echo '
723 768
 				<option value="rem_', $label['id'], '">&nbsp;', $label['name'], '</option>';
769
+			}
724 770
 
725 771
 			echo '
726 772
 			</select>
@@ -751,11 +797,12 @@  discard block
 block discarded – undo
751 797
 			<h3 class="catbg">', $txt['pm_search_title'], '</h3>
752 798
 		</div>';
753 799
 
754
-	if (!empty($context['search_errors']))
755
-		echo '
800
+	if (!empty($context['search_errors'])) {
801
+			echo '
756 802
 		<div class="errorbox">
757 803
 			', implode('<br>', $context['search_errors']['messages']), '
758 804
 		</div>';
805
+	}
759 806
 
760 807
 
761 808
 	echo '
@@ -804,9 +851,10 @@  discard block
 block discarded – undo
804 851
 					</dd>
805 852
 				</dl>';
806 853
 
807
-	if (!$context['currently_using_labels'])
808
-		echo '
854
+	if (!$context['currently_using_labels']) {
855
+			echo '
809 856
 				<input type="submit" name="pm_search" value="', $txt['pm_search_go'], '" class="button">';
857
+	}
810 858
 
811 859
 	echo '
812 860
 				<br class="clear_right">
@@ -827,12 +875,13 @@  discard block
 block discarded – undo
827 875
 				<div id="advanced_panel_div">
828 876
 					<ul id="searchLabelsExpand">';
829 877
 
830
-		foreach ($context['search_labels'] as $label)
831
-			echo '
878
+		foreach ($context['search_labels'] as $label) {
879
+					echo '
832 880
 						<li>
833 881
 							<label for="searchlabel_', $label['id'], '"><input type="checkbox" id="searchlabel_', $label['id'], '" name="searchlabel[', $label['id'], ']" value="', $label['id'], '"', $label['checked'] ? ' checked' : '', '>
834 882
 							', $label['name'], '</label>
835 883
 						</li>';
884
+		}
836 885
 
837 886
 		echo '
838 887
 					</ul>
@@ -894,8 +943,8 @@  discard block
 block discarded – undo
894 943
 		</div>';
895 944
 
896 945
 	// Complete results?
897
-	if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages']))
898
-		echo '
946
+	if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages'])) {
947
+			echo '
899 948
 		<table class="table_grid">
900 949
 			<thead>
901 950
 				<tr class="title_bar">
@@ -905,6 +954,7 @@  discard block
 block discarded – undo
905 954
 				</tr>
906 955
 			</thead>
907 956
 			<tbody>';
957
+	}
908 958
 
909 959
 	// Print each message out...
910 960
 	foreach ($context['personal_messages'] as $message)
@@ -924,12 +974,14 @@  discard block
 block discarded – undo
924 974
 
925 975
 			// Show the recipients.
926 976
 			// @todo This doesn't deal with the sent item searching quite right for bcc.
927
-			if (!empty($message['recipients']['to']))
928
-				echo implode(', ', $message['recipients']['to']);
977
+			if (!empty($message['recipients']['to'])) {
978
+							echo implode(', ', $message['recipients']['to']);
979
+			}
929 980
 
930 981
 			// Otherwise, we're just going to say "some people"...
931
-			elseif ($context['folder'] != 'sent')
932
-				echo '(', $txt['pm_undisclosed_recipients'], ')';
982
+			elseif ($context['folder'] != 'sent') {
983
+							echo '(', $txt['pm_undisclosed_recipients'], ')';
984
+			}
933 985
 
934 986
 			echo '
935 987
 				</h3>
@@ -944,15 +996,17 @@  discard block
 block discarded – undo
944 996
 				$reply_button = create_button('im_reply.png', 'reply', 'reply', 'class="centericon"');
945 997
 
946 998
 				// You can only reply if they are not a guest...
947
-				if (!$message['member']['is_guest'])
948
-					echo '
999
+				if (!$message['member']['is_guest']) {
1000
+									echo '
949 1001
 					<a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote;u=', $context['folder'] == 'sent' ? '' : $message['member']['id'], '">', $quote_button , '</a>', $context['menu_separator'], '
950 1002
 					<a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';u=', $message['member']['id'], '">', $reply_button , '</a> ', $context['menu_separator'];
1003
+				}
951 1004
 
952 1005
 				// This is for "forwarding" - even if the member is gone.
953
-				else
954
-					echo '
1006
+				else {
1007
+									echo '
955 1008
 					<a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote">', $quote_button , '</a>', $context['menu_separator'];
1009
+				}
956 1010
 			}
957 1011
 
958 1012
 			echo '
@@ -961,27 +1015,30 @@  discard block
 block discarded – undo
961 1015
 		}
962 1016
 		// Otherwise just a simple list!
963 1017
 		// @todo No context at all of the search?
964
-		else
965
-			echo '
1018
+		else {
1019
+					echo '
966 1020
 				<tr class="windowbg">
967 1021
 					<td>', $message['time'], '</td>
968 1022
 					<td>', $message['link'], '</td>
969 1023
 					<td>', $message['member']['link'], '</td>
970 1024
 				</tr>';
1025
+		}
971 1026
 	}
972 1027
 
973 1028
 	// Finish off the page...
974
-	if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages']))
975
-		echo '
1029
+	if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages'])) {
1030
+			echo '
976 1031
 			</tbody>
977 1032
 		</table>';
1033
+	}
978 1034
 
979 1035
 	// No results?
980
-	if (empty($context['personal_messages']))
981
-		echo '
1036
+	if (empty($context['personal_messages'])) {
1037
+			echo '
982 1038
 		<div class="windowbg">
983 1039
 			<p class="centertext">', $txt['pm_search_none_found'], '</p>
984 1040
 		</div>';
1041
+	}
985 1042
 
986 1043
 	echo '
987 1044
 		<div class="pagesection">
@@ -1006,15 +1063,17 @@  discard block
 block discarded – undo
1006 1063
 		</div>
1007 1064
 		<div class="windowbg">';
1008 1065
 
1009
-		if (!empty($context['send_log']['sent']))
1010
-			foreach ($context['send_log']['sent'] as $log_entry)
1066
+		if (!empty($context['send_log']['sent'])) {
1067
+					foreach ($context['send_log']['sent'] as $log_entry)
1011 1068
 				echo '
1012 1069
 			<span class="error">', $log_entry, '</span><br>';
1070
+		}
1013 1071
 
1014
-		if (!empty($context['send_log']['failed']))
1015
-			foreach ($context['send_log']['failed'] as $log_entry)
1072
+		if (!empty($context['send_log']['failed'])) {
1073
+					foreach ($context['send_log']['failed'] as $log_entry)
1016 1074
 				echo '
1017 1075
 			<span class="error">', $log_entry, '</span><br>';
1076
+		}
1018 1077
 
1019 1078
 		echo '
1020 1079
 		</div>
@@ -1063,12 +1122,13 @@  discard block
 block discarded – undo
1063 1122
 					</dl>
1064 1123
 				</div>';
1065 1124
 
1066
-	if (!empty($modSettings['drafts_pm_enabled']))
1067
-		echo '
1125
+	if (!empty($modSettings['drafts_pm_enabled'])) {
1126
+			echo '
1068 1127
 				<div id="draft_section" class="infobox"', isset($context['draft_saved']) ? '' : ' style="display: none;"', '>',
1069 1128
 					sprintf($txt['draft_pm_saved'], $scripturl . '?action=pm;sa=showpmdrafts'), '
1070 1129
 					', (!empty($modSettings['drafts_keep_days']) ? ' <strong>' . sprintf($txt['draft_save_warning'], $modSettings['drafts_keep_days']) . '</strong>' : ''), '
1071 1130
 				</div>';
1131
+	}
1072 1132
 
1073 1133
 	echo '
1074 1134
 				<dl id="post_header">';
@@ -1117,26 +1177,29 @@  discard block
 block discarded – undo
1117 1177
 				<hr>';
1118 1178
 
1119 1179
 	// Showing BBC?
1120
-	if ($context['show_bbc'])
1121
-		echo '
1180
+	if ($context['show_bbc']) {
1181
+			echo '
1122 1182
 				<div id="bbcBox_message"></div>';
1183
+	}
1123 1184
 
1124 1185
 	// What about smileys?
1125
-	if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup']))
1126
-		echo '
1186
+	if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup'])) {
1187
+			echo '
1127 1188
 				<div id="smileyBox_message"></div>';
1189
+	}
1128 1190
 
1129 1191
 	// Show BBC buttons, smileys and textbox.
1130 1192
 	echo '
1131 1193
 				', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message');
1132 1194
 
1133 1195
 	// Require an image to be typed to save spamming?
1134
-	if ($context['require_verification'])
1135
-		echo '
1196
+	if ($context['require_verification']) {
1197
+			echo '
1136 1198
 				<div class="post_verification">
1137 1199
 					<strong>', $txt['pm_visual_verification_label'], ':</strong>
1138 1200
 					', template_control_verification($context['visual_verification_id'], 'all'), '
1139 1201
 				</div>';
1202
+	}
1140 1203
 
1141 1204
 	// Send, Preview, spellcheck buttons.
1142 1205
 	echo '
@@ -1169,10 +1232,11 @@  discard block
 block discarded – undo
1169 1232
 				<dt><strong>', $txt['subject'], '</strong></dt>
1170 1233
 				<dd><strong>', $txt['draft_saved_on'], '</strong></dd>';
1171 1234
 
1172
-		foreach ($context['drafts'] as $draft)
1173
-			echo '
1235
+		foreach ($context['drafts'] as $draft) {
1236
+					echo '
1174 1237
 				<dt>', $draft['link'], '</dt>
1175 1238
 				<dd>', $draft['poster_time'], '</dd>';
1239
+		}
1176 1240
 		echo '
1177 1241
 			</dl>
1178 1242
 		</div>';
@@ -1279,8 +1343,8 @@  discard block
 block discarded – undo
1279 1343
 			}';
1280 1344
 
1281 1345
 	// Code for showing and hiding drafts
1282
-	if (!empty($context['drafts']))
1283
-		echo '
1346
+	if (!empty($context['drafts'])) {
1347
+			echo '
1284 1348
 			var oSwapDraftOptions = new smc_Toggle({
1285 1349
 				bToggleEnabled: true,
1286 1350
 				bCurrentlyCollapsed: true,
@@ -1302,13 +1366,14 @@  discard block
 block discarded – undo
1302 1366
 					}
1303 1367
 				]
1304 1368
 			});';
1369
+	}
1305 1370
 
1306 1371
 	echo '
1307 1372
 		</script>';
1308 1373
 
1309 1374
 	// Show the message you're replying to.
1310
-	if ($context['reply'])
1311
-		echo '
1375
+	if ($context['reply']) {
1376
+			echo '
1312 1377
 		<br><br>
1313 1378
 		<div class="cat_bar">
1314 1379
 			<h3 class="catbg">', $txt['subject'], ': ', $context['quoted_message']['subject'], '</h3>
@@ -1322,6 +1387,7 @@  discard block
 block discarded – undo
1322 1387
 			', $context['quoted_message']['body'], '
1323 1388
 		</div>
1324 1389
 		<br class="clear">';
1390
+	}
1325 1391
 
1326 1392
 	echo '
1327 1393
 		<script>
@@ -1333,23 +1399,25 @@  discard block
 block discarded – undo
1333 1399
 				sToControlId: \'to_control\',
1334 1400
 				aToRecipients: [';
1335 1401
 
1336
-	foreach ($context['recipients']['to'] as $i => $member)
1337
-		echo '
1402
+	foreach ($context['recipients']['to'] as $i => $member) {
1403
+			echo '
1338 1404
 					{
1339 1405
 						sItemId: ', JavaScriptEscape($member['id']), ',
1340 1406
 						sItemName: ', JavaScriptEscape($member['name']), '
1341 1407
 					}', $i == count($context['recipients']['to']) - 1 ? '' : ',';
1408
+	}
1342 1409
 
1343 1410
 	echo '
1344 1411
 				],
1345 1412
 				aBccRecipients: [';
1346 1413
 
1347
-	foreach ($context['recipients']['bcc'] as $i => $member)
1348
-		echo '
1414
+	foreach ($context['recipients']['bcc'] as $i => $member) {
1415
+			echo '
1349 1416
 					{
1350 1417
 						sItemId: ', JavaScriptEscape($member['id']), ',
1351 1418
 						sItemName: ', JavaScriptEscape($member['name']), '
1352 1419
 					}', $i == count($context['recipients']['bcc']) - 1 ? '' : ',';
1420
+	}
1353 1421
 
1354 1422
 	echo '
1355 1423
 				],
@@ -1438,26 +1506,28 @@  discard block
 block discarded – undo
1438 1506
 					</th>
1439 1507
 					<th class="centertext table_icon">';
1440 1508
 
1441
-	if (count($context['labels']) > 2)
1442
-		echo '
1509
+	if (count($context['labels']) > 2) {
1510
+			echo '
1443 1511
 						<input type="checkbox" onclick="invertAll(this, this.form);">';
1512
+	}
1444 1513
 
1445 1514
 	echo '
1446 1515
 					</th>
1447 1516
 				</tr>
1448 1517
 			</thead>
1449 1518
 			<tbody>';
1450
-	if (count($context['labels']) < 2)
1451
-		echo '
1519
+	if (count($context['labels']) < 2) {
1520
+			echo '
1452 1521
 				<tr class="windowbg">
1453 1522
 					<td colspan="2">', $txt['pm_labels_no_exist'], '</td>
1454 1523
 				</tr>';
1455
-	else
1524
+	} else
1456 1525
 	{
1457 1526
 		foreach ($context['labels'] as $label)
1458 1527
 		{
1459
-			if ($label['id'] == -1)
1460
-				continue;
1528
+			if ($label['id'] == -1) {
1529
+							continue;
1530
+			}
1461 1531
 
1462 1532
 				echo '
1463 1533
 				<tr class="windowbg">
@@ -1472,12 +1542,13 @@  discard block
 block discarded – undo
1472 1542
 			</tbody>
1473 1543
 		</table>';
1474 1544
 
1475
-	if (!count($context['labels']) < 2)
1476
-		echo '
1545
+	if (!count($context['labels']) < 2) {
1546
+			echo '
1477 1547
 		<div class="padding">
1478 1548
 			<input type="submit" name="save" value="', $txt['save'], '" class="button">
1479 1549
 			<input type="submit" name="delete" value="', $txt['quickmod_delete_selected'], '" data-confirm="', $txt['pm_labels_delete'] ,'" class="button you_sure">
1480 1550
 		</div>';
1551
+	}
1481 1552
 
1482 1553
 	echo '
1483 1554
 		<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -1534,9 +1605,10 @@  discard block
 block discarded – undo
1534 1605
 					<select name="id_admin">
1535 1606
 						<option value="0">', $txt['pm_report_all_admins'], '</option>';
1536 1607
 
1537
-		foreach ($context['admins'] as $id => $name)
1538
-			echo '
1608
+		foreach ($context['admins'] as $id => $name) {
1609
+					echo '
1539 1610
 						<option value="', $id, '">', $name, '</option>';
1611
+		}
1540 1612
 
1541 1613
 		echo '
1542 1614
 					</select>
@@ -1599,9 +1671,10 @@  discard block
 block discarded – undo
1599 1671
 					</th>
1600 1672
 					<th class="centertext table_icon">';
1601 1673
 
1602
-	if (!empty($context['rules']))
1603
-		echo '
1674
+	if (!empty($context['rules'])) {
1675
+			echo '
1604 1676
 						<input type="checkbox" onclick="invertAll(this, this.form);">';
1677
+	}
1605 1678
 
1606 1679
 	echo '
1607 1680
 					</th>
@@ -1609,16 +1682,17 @@  discard block
 block discarded – undo
1609 1682
 			</thead>
1610 1683
 			<tbody>';
1611 1684
 
1612
-	if (empty($context['rules']))
1613
-		echo '
1685
+	if (empty($context['rules'])) {
1686
+			echo '
1614 1687
 				<tr class="windowbg">
1615 1688
 					<td colspan="2">
1616 1689
 						', $txt['pm_rules_none'], '
1617 1690
 					</td>
1618 1691
 				</tr>';
1692
+	}
1619 1693
 
1620
-	foreach ($context['rules'] as $rule)
1621
-		echo '
1694
+	foreach ($context['rules'] as $rule) {
1695
+			echo '
1622 1696
 				<tr class="windowbg">
1623 1697
 					<td>
1624 1698
 						<a href="', $scripturl, '?action=pm;sa=manrules;add;rid=', $rule['id'], '">', $rule['name'], '</a>
@@ -1627,6 +1701,7 @@  discard block
 block discarded – undo
1627 1701
 						<input type="checkbox" name="delrule[', $rule['id'], ']">
1628 1702
 					</td>
1629 1703
 				</tr>';
1704
+	}
1630 1705
 
1631 1706
 	echo '
1632 1707
 			</tbody>
@@ -1634,14 +1709,16 @@  discard block
 block discarded – undo
1634 1709
 		<div class="righttext">
1635 1710
 			<a class="button" href="', $scripturl, '?action=pm;sa=manrules;add;rid=0">', $txt['pm_add_rule'], '</a>';
1636 1711
 
1637
-	if (!empty($context['rules']))
1638
-		echo '
1712
+	if (!empty($context['rules'])) {
1713
+			echo '
1639 1714
 			[<a href="', $scripturl, '?action=pm;sa=manrules;apply;', $context['session_var'], '=', $context['session_id'], '" onclick="return confirm(\'', $txt['pm_js_apply_rules_confirm'], '\');">', $txt['pm_apply_rules'], '</a>]';
1715
+	}
1640 1716
 
1641
-	if (!empty($context['rules']))
1642
-		echo '
1717
+	if (!empty($context['rules'])) {
1718
+			echo '
1643 1719
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1644 1720
 			<input type="submit" name="delselected" value="', $txt['pm_delete_selected_rule'], '" data-confirm="', $txt['pm_js_delete_rule_confirm'] ,'" class="button smalltext you_sure">';
1721
+	}
1645 1722
 
1646 1723
 	echo '
1647 1724
 		</div>
@@ -1663,14 +1740,16 @@  discard block
 block discarded – undo
1663 1740
 		var groups = new Array()
1664 1741
 		var labels = new Array()';
1665 1742
 
1666
-	foreach ($context['groups'] as $id => $title)
1667
-		echo '
1743
+	foreach ($context['groups'] as $id => $title) {
1744
+			echo '
1668 1745
 		groups[', $id, '] = "', addslashes($title), '";';
1746
+	}
1669 1747
 
1670
-	foreach ($context['labels'] as $label)
1671
-		if ($label['id'] != -1)
1748
+	foreach ($context['labels'] as $label) {
1749
+			if ($label['id'] != -1)
1672 1750
 			echo '
1673 1751
 		labels[', ($label['id']), '] = "', addslashes($label['name']), '";';
1752
+	}
1674 1753
 
1675 1754
 	echo '
1676 1755
 		function addCriteriaOption()
@@ -1685,8 +1764,9 @@  discard block
 block discarded – undo
1685 1764
 
1686 1765
 			setOuterHTML(document.getElementById("criteriaAddHere"), \'<br><select name="ruletype[\' + criteriaNum + \']" id="ruletype\' + criteriaNum + \'" onchange="updateRuleDef(\' + criteriaNum + \'); rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_criteria_pick']), ':<\' + \'/option><option value="mid">', addslashes($txt['pm_rule_mid']), '<\' + \'/option><option value="gid">', addslashes($txt['pm_rule_gid']), '<\' + \'/option><option value="sub">', addslashes($txt['pm_rule_sub']), '<\' + \'/option><option value="msg">', addslashes($txt['pm_rule_msg']), '<\' + \'/option><option value="bud">', addslashes($txt['pm_rule_bud']), '<\' + \'/option><\' + \'/select>&nbsp;<span id="defdiv\' + criteriaNum + \'" style="display: none;"><input type="text" name="ruledef[\' + criteriaNum + \']" id="ruledef\' + criteriaNum + \'" onkeyup="rebuildRuleDesc();" value=""><\' + \'/span><span id="defseldiv\' + criteriaNum + \'" style="display: none;"><select name="ruledefgroup[\' + criteriaNum + \']" id="ruledefgroup\' + criteriaNum + \'" onchange="rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_sel_group']), '<\' + \'/option>';
1687 1766
 
1688
-	foreach ($context['groups'] as $id => $group)
1689
-		echo '<option value="', $id, '">', strtr($group, array("'" => "\'")), '<\' + \'/option>';
1767
+	foreach ($context['groups'] as $id => $group) {
1768
+			echo '<option value="', $id, '">', strtr($group, array("'" => "\'")), '<\' + \'/option>';
1769
+	}
1690 1770
 
1691 1771
 	echo '<\' + \'/select><\' + \'/span><span id="criteriaAddHere"><\' + \'/span>\');
1692 1772
 			}
@@ -1703,9 +1783,10 @@  discard block
 block discarded – undo
1703 1783
 
1704 1784
 				setOuterHTML(document.getElementById("actionAddHere"), \'<br><select name="acttype[\' + actionNum + \']" id="acttype\' + actionNum + \'" onchange="updateActionDef(\' + actionNum + \'); rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_sel_action']), ':<\' + \'/option><option value="lab">', addslashes($txt['pm_rule_label']), '<\' + \'/option><option value="del">', addslashes($txt['pm_rule_delete']), '<\' + \'/option><\' + \'/select>&nbsp;<span id="labdiv\' + actionNum + \'" style="display: none;"><select name="labdef[\' + actionNum + \']" id="labdef\' + actionNum + \'" onchange="rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_sel_label']), '<\' + \'/option>';
1705 1785
 
1706
-	foreach ($context['labels'] as $label)
1707
-		if ($label['id'] != -1)
1786
+	foreach ($context['labels'] as $label) {
1787
+			if ($label['id'] != -1)
1708 1788
 			echo '<option value="', ($label['id']), '">', addslashes($label['name']), '<\' + \'/option>';
1789
+	}
1709 1790
 
1710 1791
 	echo '<\' + \'/select><\' + \'/span><span id="actionAddHere"><\' + \'/span>\');
1711 1792
 			}
@@ -1819,19 +1900,20 @@  discard block
 block discarded – undo
1819 1900
 	$isFirst = true;
1820 1901
 	foreach ($context['rule']['criteria'] as $k => $criteria)
1821 1902
 	{
1822
-		if (!$isFirst && $criteria['t'] == '')
1823
-			echo '<div id="removeonjs1">';
1824
-
1825
-		elseif (!$isFirst)
1826
-			echo '<br>';
1903
+		if (!$isFirst && $criteria['t'] == '') {
1904
+					echo '<div id="removeonjs1">';
1905
+		} elseif (!$isFirst) {
1906
+					echo '<br>';
1907
+		}
1827 1908
 
1828 1909
 		echo '
1829 1910
 				<select name="ruletype[', $k, ']" id="ruletype', $k, '" onchange="updateRuleDef(', $k, '); rebuildRuleDesc();">
1830 1911
 					<option value="">', $txt['pm_rule_criteria_pick'], ':</option>';
1831 1912
 
1832
-		foreach (array('mid', 'gid', 'sub', 'msg', 'bud') as $cr)
1833
-			echo '
1913
+		foreach (array('mid', 'gid', 'sub', 'msg', 'bud') as $cr) {
1914
+					echo '
1834 1915
 					<option value="', $cr, '"', $criteria['t'] == $cr ? ' selected' : '', '>', $txt['pm_rule_' . $cr], '</option>';
1916
+		}
1835 1917
 
1836 1918
 		echo '
1837 1919
 				</select>
@@ -1842,19 +1924,20 @@  discard block
 block discarded – undo
1842 1924
 					<select name="ruledefgroup[', $k, ']" id="ruledefgroup', $k, '" onchange="rebuildRuleDesc();">
1843 1925
 						<option value="">', $txt['pm_rule_sel_group'], '</option>';
1844 1926
 
1845
-		foreach ($context['groups'] as $id => $group)
1846
-			echo '
1927
+		foreach ($context['groups'] as $id => $group) {
1928
+					echo '
1847 1929
 						<option value="', $id, '"', $criteria['t'] == 'gid' && $criteria['v'] == $id ? ' selected' : '', '>', $group, '</option>';
1930
+		}
1848 1931
 		echo '
1849 1932
 					</select>
1850 1933
 				</span>';
1851 1934
 
1852 1935
 		// If this is the dummy we add a means to hide for non js users.
1853
-		if ($isFirst)
1854
-			$isFirst = false;
1855
-
1856
-		elseif ($criteria['t'] == '')
1857
-			echo '</div><!-- .removeonjs1 -->';
1936
+		if ($isFirst) {
1937
+					$isFirst = false;
1938
+		} elseif ($criteria['t'] == '') {
1939
+					echo '</div><!-- .removeonjs1 -->';
1940
+		}
1858 1941
 	}
1859 1942
 
1860 1943
 	echo '
@@ -1877,10 +1960,11 @@  discard block
 block discarded – undo
1877 1960
 	$isFirst = true;
1878 1961
 	foreach ($context['rule']['actions'] as $k => $action)
1879 1962
 	{
1880
-		if (!$isFirst && $action['t'] == '')
1881
-			echo '<div id="removeonjs2">';
1882
-		elseif (!$isFirst)
1883
-			echo '<br>';
1963
+		if (!$isFirst && $action['t'] == '') {
1964
+					echo '<div id="removeonjs2">';
1965
+		} elseif (!$isFirst) {
1966
+					echo '<br>';
1967
+		}
1884 1968
 
1885 1969
 		echo '
1886 1970
 				<select name="acttype[', $k, ']" id="acttype', $k, '" onchange="updateActionDef(', $k, '); rebuildRuleDesc();">
@@ -1892,20 +1976,21 @@  discard block
 block discarded – undo
1892 1976
 					<select name="labdef[', $k, ']" id="labdef', $k, '" onchange="rebuildRuleDesc();">
1893 1977
 						<option value="">', $txt['pm_rule_sel_label'], '</option>';
1894 1978
 
1895
-		foreach ($context['labels'] as $label)
1896
-			if ($label['id'] != -1)
1979
+		foreach ($context['labels'] as $label) {
1980
+					if ($label['id'] != -1)
1897 1981
 				echo '
1898 1982
 						<option value="', ($label['id']), '"', $action['t'] == 'lab' && $action['v'] == $label['id'] ? ' selected' : '', '>', $label['name'], '</option>';
1983
+		}
1899 1984
 
1900 1985
 		echo '
1901 1986
 					</select>
1902 1987
 				</span>';
1903 1988
 
1904
-		if ($isFirst)
1905
-			$isFirst = false;
1906
-
1907
-		elseif ($action['t'] == '')
1908
-			echo '</div><!-- .removeonjs2 -->';
1989
+		if ($isFirst) {
1990
+					$isFirst = false;
1991
+		} elseif ($action['t'] == '') {
1992
+					echo '</div><!-- .removeonjs2 -->';
1993
+		}
1909 1994
 	}
1910 1995
 
1911 1996
 	echo '
@@ -1929,22 +2014,25 @@  discard block
 block discarded – undo
1929 2014
 		echo '
1930 2015
 	<script>';
1931 2016
 
1932
-	foreach ($context['rule']['criteria'] as $k => $c)
1933
-		echo '
2017
+	foreach ($context['rule']['criteria'] as $k => $c) {
2018
+			echo '
1934 2019
 			updateRuleDef(', $k, ');';
2020
+	}
1935 2021
 
1936
-	foreach ($context['rule']['actions'] as $k => $c)
1937
-		echo '
2022
+	foreach ($context['rule']['actions'] as $k => $c) {
2023
+			echo '
1938 2024
 			updateActionDef(', $k, ');';
2025
+	}
1939 2026
 
1940 2027
 	echo '
1941 2028
 			rebuildRuleDesc();';
1942 2029
 
1943 2030
 	// If this isn't a new rule and we have JS enabled remove the JS compatibility stuff.
1944
-	if ($context['rid'])
1945
-		echo '
2031
+	if ($context['rid']) {
2032
+			echo '
1946 2033
 			document.getElementById("removeonjs1").style.display = "none";
1947 2034
 			document.getElementById("removeonjs2").style.display = "none";';
2035
+	}
1948 2036
 
1949 2037
 	echo '
1950 2038
 			document.getElementById("addonjs1").style.display = "";
@@ -1972,12 +2060,12 @@  discard block
 block discarded – undo
1972 2060
 		</div>';
1973 2061
 
1974 2062
 	// No drafts? Just show an informative message.
1975
-	if (empty($context['drafts']))
1976
-		echo '
2063
+	if (empty($context['drafts'])) {
2064
+			echo '
1977 2065
 		<div class="windowbg2 centertext">
1978 2066
 			', $txt['draft_none'], '
1979 2067
 		</div>';
1980
-	else
2068
+	} else
1981 2069
 	{
1982 2070
 		// For every draft to be displayed, give it its own div, and show the important details of the draft.
1983 2071
 		foreach ($context['drafts'] as $draft)
Please login to merge, or discard this patch.
Themes/default/Memberlist.template.php 1 patch
Braces   +30 added lines, -20 removed lines patch added patch discarded remove patch
@@ -27,9 +27,10 @@  discard block
 block discarded – undo
27 27
 			<h3 class="catbg">
28 28
 				<span class="floatleft">', $txt['members_list'], '</span>';
29 29
 
30
-	if (!isset($context['old_search']))
31
-		echo '
30
+	if (!isset($context['old_search'])) {
31
+			echo '
32 32
 				<span class="floatright">', $context['letter_links'], '</span>';
33
+	}
33 34
 	echo '
34 35
 			</h3>
35 36
 		</div>';
@@ -44,20 +45,23 @@  discard block
 block discarded – undo
44 45
 	foreach ($context['columns'] as $key => $column)
45 46
 	{
46 47
 		// @TODO maybe find something nicer?
47
-		if ($key == 'email_address' && !$context['can_send_email'])
48
-			continue;
48
+		if ($key == 'email_address' && !$context['can_send_email']) {
49
+					continue;
50
+		}
49 51
 
50 52
 		// This is a selected column, so underline it or some such.
51
-		if ($column['selected'])
52
-			echo '
53
+		if ($column['selected']) {
54
+					echo '
53 55
 						<th scope="col" class="', $key, isset($column['class']) ? ' ' . $column['class'] : '', ' selected" style="width: auto;"' . (isset($column['colspan']) ? ' colspan="' . $column['colspan'] . '"' : '') . '>
54 56
 							<a href="' . $column['href'] . '" rel="nofollow">' . $column['label'] . '</a><span class="generic_icons sort_' . $context['sort_direction'] . '"></span></th>';
57
+		}
55 58
 
56 59
 		// This is just some column... show the link and be done with it.
57
-		else
58
-			echo '
60
+		else {
61
+					echo '
59 62
 						<th scope="col" class="', $key, isset($column['class']) ? ' ' . $column['class'] : '', '"', isset($column['width']) ? ' style="width: ' . $column['width'] . '"' : '', isset($column['colspan']) ? ' colspan="' . $column['colspan'] . '"' : '', '>
60 63
 						', $column['link'], '</th>';
64
+		}
61 65
 	}
62 66
 
63 67
 	echo '
@@ -77,9 +81,10 @@  discard block
 block discarded – undo
77 81
 						</td>
78 82
 						<td class="lefttext">', $member['link'], '</td>';
79 83
 
80
-			if (!isset($context['disabled_fields']['website']))
81
-				echo '
84
+			if (!isset($context['disabled_fields']['website'])) {
85
+							echo '
82 86
 						<td class="centertext website_url">', $member['website']['url'] != '' ? '<a href="' . $member['website']['url'] . '" target="_blank" rel="noopener"><span class="generic_icons www" title="' . $member['website']['title'] . '"></span></a>' : '', '</td>';
87
+			}
83 88
 
84 89
 			// Group and date.
85 90
 			echo '
@@ -92,32 +97,35 @@  discard block
 block discarded – undo
92 97
 						<td class="centertext" style="white-space: nowrap; width: 15px">', $member['posts'], '</td>
93 98
 						<td class="centertext statsbar" style="width: 120px">';
94 99
 
95
-				if (!empty($member['post_percent']))
96
-					echo '
100
+				if (!empty($member['post_percent'])) {
101
+									echo '
97 102
 							<div class="bar" style="width: ', $member['post_percent'] + 4, 'px;">
98 103
 								<div style="width: ', $member['post_percent'], 'px;"></div>
99 104
 							</div>';
105
+				}
100 106
 
101 107
 				echo '
102 108
 						</td>';
103 109
 			}
104 110
 
105 111
 			// Show custom fields marked to be shown here
106
-			if (!empty($context['custom_profile_fields']['columns']))
107
-				foreach ($context['custom_profile_fields']['columns'] as $key => $column)
112
+			if (!empty($context['custom_profile_fields']['columns'])) {
113
+							foreach ($context['custom_profile_fields']['columns'] as $key => $column)
108 114
 					echo '
109 115
 						<td class="righttext">', $member['options'][$key], '</td>';
116
+			}
110 117
 
111 118
 			echo '
112 119
 					</tr>';
113 120
 		}
114 121
 	}
115 122
 	// No members?
116
-	else
117
-		echo '
123
+	else {
124
+			echo '
118 125
 					<tr>
119 126
 						<td colspan="', $context['colspan'], '" class="windowbg">', $txt['search_no_results'], '</td>
120 127
 					</tr>';
128
+	}
121 129
 
122 130
 	echo '
123 131
 				</tbody>
@@ -130,9 +138,10 @@  discard block
 block discarded – undo
130 138
 			<div class="pagelinks floatleft">', $context['page_index'], '</div>';
131 139
 
132 140
 	// If it is displaying the result of a search show a "search again" link to edit their criteria.
133
-	if (isset($context['old_search']))
134
-		echo '
141
+	if (isset($context['old_search'])) {
142
+			echo '
135 143
 			<a class="button" href="', $scripturl, '?action=mlist;sa=search;search=', $context['old_search_value'], '">', $txt['mlist_search_again'], '</a>';
144
+	}
136 145
 	echo '
137 146
 		</div>
138 147
 	</div><!-- #memberlist -->';
@@ -172,12 +181,13 @@  discard block
 block discarded – undo
172 181
 					<dd>
173 182
 						<ul>';
174 183
 
175
-	foreach ($context['search_fields'] as $id => $title)
176
-		echo '
184
+	foreach ($context['search_fields'] as $id => $title) {
185
+			echo '
177 186
 							<li>
178 187
 								<input type="checkbox" name="fields[]" id="fields-', $id, '" value="', $id, '"', in_array($id, $context['search_defaults']) ? ' checked' : '', '>
179 188
 								<label for="fields-', $id, '">', $title, '</label>
180 189
 							</li>';
190
+	}
181 191
 
182 192
 	echo '
183 193
 						</ul>
Please login to merge, or discard this patch.
Themes/default/Display.template.php 1 patch
Braces   +236 added lines, -162 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', $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>';
@@ -250,8 +265,9 @@  discard block
 block discarded – undo
250 265
 	$context['removableMessageIDs'] = array();
251 266
 
252 267
 	// Get all the messages...
253
-	while ($message = $context['get_message']())
254
-		template_single_post($message);
268
+	while ($message = $context['get_message']()) {
269
+			template_single_post($message);
270
+	}
255 271
 
256 272
 	echo '
257 273
 			</form>
@@ -289,8 +305,9 @@  discard block
 block discarded – undo
289 305
 		<div id="display_jump_to"></div>';
290 306
 
291 307
 	// Show quickreply
292
-	if ($context['can_reply'])
293
-		template_quickreply();
308
+	if ($context['can_reply']) {
309
+			template_quickreply();
310
+	}
294 311
 
295 312
 	// User action pop on mobile screen (or actually small screen), this uses responsive css does not check mobile device.
296 313
 	echo '
@@ -305,8 +322,8 @@  discard block
 block discarded – undo
305 322
 		</div>';
306 323
 
307 324
 	// Show the moderation button & pop only if user can moderate
308
-	if ($context['can_moderate_forum'] || $context['user']['is_mod'])
309
-		echo '
325
+	if ($context['can_moderate_forum'] || $context['user']['is_mod']) {
326
+			echo '
310 327
 		<div id="mobile_moderation" class="popup_container">
311 328
 			<div class="popup_window description">
312 329
 				<div class="popup_heading">
@@ -318,6 +335,7 @@  discard block
 block discarded – undo
318 335
 				</div>
319 336
 			</div>
320 337
 		</div>';
338
+	}
321 339
 
322 340
 	echo '
323 341
 		<script>';
@@ -441,9 +459,10 @@  discard block
 block discarded – undo
441 459
 				});
442 460
 			}';
443 461
 
444
-	if (!empty($context['ignoredMsgs']))
445
-		echo '
462
+	if (!empty($context['ignoredMsgs'])) {
463
+			echo '
446 464
 			ignore_toggles([', implode(', ', $context['ignoredMsgs']), '], ', JavaScriptEscape($txt['show_ignore_user_post']), ');';
465
+	}
447 466
 
448 467
 	echo '
449 468
 		</script>';
@@ -460,8 +479,9 @@  discard block
 block discarded – undo
460 479
 
461 480
 	$ignoring = false;
462 481
 
463
-	if ($message['can_remove'])
464
-		$context['removableMessageIDs'][] = $message['id'];
482
+	if ($message['can_remove']) {
483
+			$context['removableMessageIDs'][] = $message['id'];
484
+	}
465 485
 
466 486
 	// Are we ignoring this message?
467 487
 	if (!empty($message['is_ignored']))
@@ -488,9 +508,10 @@  discard block
 block discarded – undo
488 508
 							<div class="custom_fields_above_member">
489 509
 								<ul class="nolist">';
490 510
 
491
-		foreach ($message['custom_fields']['above_member'] as $custom)
492
-			echo '
511
+		foreach ($message['custom_fields']['above_member'] as $custom) {
512
+					echo '
493 513
 									<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
514
+		}
494 515
 
495 516
 		echo '
496 517
 								</ul>
@@ -501,25 +522,28 @@  discard block
 block discarded – undo
501 522
 							<h4>';
502 523
 
503 524
 	// Show online and offline buttons?
504
-	if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest'])
505
-		echo '
525
+	if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) {
526
+			echo '
506 527
 								', $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>' : '';
528
+	}
507 529
 
508 530
 	// Custom fields BEFORE the username?
509
-	if (!empty($message['custom_fields']['before_member']))
510
-		foreach ($message['custom_fields']['before_member'] as $custom)
531
+	if (!empty($message['custom_fields']['before_member'])) {
532
+			foreach ($message['custom_fields']['before_member'] as $custom)
511 533
 			echo '
512 534
 								<span class="custom ', $custom['col_name'], '">', $custom['value'], '</span>';
535
+	}
513 536
 
514 537
 	// Show a link to the member's profile.
515 538
 	echo '
516 539
 								', $message['member']['link'];
517 540
 
518 541
 	// Custom fields AFTER the username?
519
-	if (!empty($message['custom_fields']['after_member']))
520
-		foreach ($message['custom_fields']['after_member'] as $custom)
542
+	if (!empty($message['custom_fields']['after_member'])) {
543
+			foreach ($message['custom_fields']['after_member'] as $custom)
521 544
 			echo '
522 545
 								<span class="custom ', $custom['col_name'], '">', $custom['value'], '</span>';
546
+	}
523 547
 
524 548
 	// Begin display of user info
525 549
 	echo '
@@ -527,51 +551,59 @@  discard block
 block discarded – undo
527 551
 							<ul class="user_info">';
528 552
 
529 553
 	// Show the user's avatar.
530
-	if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image']))
531
-		echo '
554
+	if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) {
555
+			echo '
532 556
 								<li class="avatar">
533 557
 									<a href="', $message['member']['href'], '">', $message['member']['avatar']['image'], '</a>
534 558
 								</li>';
559
+	}
535 560
 
536 561
 	// Are there any custom fields below the avatar?
537
-	if (!empty($message['custom_fields']['below_avatar']))
538
-		foreach ($message['custom_fields']['below_avatar'] as $custom)
562
+	if (!empty($message['custom_fields']['below_avatar'])) {
563
+			foreach ($message['custom_fields']['below_avatar'] as $custom)
539 564
 			echo '
540 565
 								<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
566
+	}
541 567
 
542 568
 	// Show the post group icons, but not for guests.
543
-	if (!$message['member']['is_guest'])
544
-		echo '
569
+	if (!$message['member']['is_guest']) {
570
+			echo '
545 571
 								<li class="icons">', $message['member']['group_icons'], '</li>';
572
+	}
546 573
 
547 574
 	// Show the member's primary group (like 'Administrator') if they have one.
548
-	if (!empty($message['member']['group']))
549
-		echo '
575
+	if (!empty($message['member']['group'])) {
576
+			echo '
550 577
 								<li class="membergroup">', $message['member']['group'], '</li>';
578
+	}
551 579
 
552 580
 	// Show the member's custom title, if they have one.
553
-	if (!empty($message['member']['title']))
554
-		echo '
581
+	if (!empty($message['member']['title'])) {
582
+			echo '
555 583
 								<li class="title">', $message['member']['title'], '</li>';
584
+	}
556 585
 
557 586
 	// Don't show these things for guests.
558 587
 	if (!$message['member']['is_guest'])
559 588
 	{
560 589
 
561 590
 		// 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.
562
-		if ((empty($modSettings['hide_post_group']) || empty($message['member']['group'])) && !empty($message['member']['post_group']))
563
-			echo '
591
+		if ((empty($modSettings['hide_post_group']) || empty($message['member']['group'])) && !empty($message['member']['post_group'])) {
592
+					echo '
564 593
 								<li class="postgroup">', $message['member']['post_group'], '</li>';
594
+		}
565 595
 
566 596
 		// Show how many posts they have made.
567
-		if (!isset($context['disabled_fields']['posts']))
568
-			echo '
597
+		if (!isset($context['disabled_fields']['posts'])) {
598
+					echo '
569 599
 								<li class="postcount">', $txt['member_postcount'], ': ', $message['member']['posts'], '</li>';
600
+		}
570 601
 
571 602
 		// Show their personal text?
572
-		if (!empty($modSettings['show_blurb']) && !empty($message['member']['blurb']))
573
-			echo '
603
+		if (!empty($modSettings['show_blurb']) && !empty($message['member']['blurb'])) {
604
+					echo '
574 605
 								<li class="blurb">', $message['member']['blurb'], '</li>';
606
+		}
575 607
 
576 608
 		// Any custom fields to show as icons?
577 609
 		if (!empty($message['custom_fields']['icons']))
@@ -580,9 +612,10 @@  discard block
 block discarded – undo
580 612
 								<li class="im_icons">
581 613
 									<ol>';
582 614
 
583
-			foreach ($message['custom_fields']['icons'] as $custom)
584
-				echo '
615
+			foreach ($message['custom_fields']['icons'] as $custom) {
616
+							echo '
585 617
 										<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
618
+			}
586 619
 
587 620
 			echo '
588 621
 									</ol>
@@ -597,19 +630,22 @@  discard block
 block discarded – undo
597 630
 									<ol class="profile_icons">';
598 631
 
599 632
 			// Don't show an icon if they haven't specified a website.
600
-			if (!empty($message['member']['website']['url']) && !isset($context['disabled_fields']['website']))
601
-				echo '
633
+			if (!empty($message['member']['website']['url']) && !isset($context['disabled_fields']['website'])) {
634
+							echo '
602 635
 										<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>';
636
+			}
603 637
 
604 638
 			// Since we know this person isn't a guest, you *can* message them.
605
-			if ($context['can_send_pm'])
606
-				echo '
639
+			if ($context['can_send_pm']) {
640
+							echo '
607 641
 										<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>';
642
+			}
608 643
 
609 644
 			// Show the email if necessary
610
-			if (!empty($message['member']['email']) && $message['member']['show_email'])
611
-				echo '
645
+			if (!empty($message['member']['email']) && $message['member']['show_email']) {
646
+							echo '
612 647
 										<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>';
648
+			}
613 649
 
614 650
 			echo '
615 651
 									</ol>
@@ -617,58 +653,66 @@  discard block
 block discarded – undo
617 653
 		}
618 654
 
619 655
 		// Any custom fields for standard placement?
620
-		if (!empty($message['custom_fields']['standard']))
621
-			foreach ($message['custom_fields']['standard'] as $custom)
656
+		if (!empty($message['custom_fields']['standard'])) {
657
+					foreach ($message['custom_fields']['standard'] as $custom)
622 658
 				echo '
623 659
 								<li class="custom ', $custom['col_name'], '">', $custom['title'], ': ', $custom['value'], '</li>';
660
+		}
624 661
 
625 662
 	}
626 663
 	// Otherwise, show the guest's email.
627
-	elseif (!empty($message['member']['email']) && $message['member']['show_email'])
628
-		echo '
664
+	elseif (!empty($message['member']['email']) && $message['member']['show_email']) {
665
+			echo '
629 666
 								<li class="email">
630 667
 									<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 668
 								</li>';
669
+	}
632 670
 
633 671
 	// 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 '
672
+	if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) {
673
+			echo '
636 674
 								<li class="poster_ip">
637 675
 									<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 676
 								</li>';
677
+	}
639 678
 
640 679
 	// Or, should we show it because this is you?
641
-	elseif ($message['can_see_ip'])
642
-		echo '
680
+	elseif ($message['can_see_ip']) {
681
+			echo '
643 682
 								<li class="poster_ip">
644 683
 									<a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $message['member']['ip'], '</a>
645 684
 								</li>';
685
+	}
646 686
 
647 687
 	// 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 '
688
+	elseif (!$context['user']['is_guest']) {
689
+			echo '
650 690
 								<li class="poster_ip">
651 691
 									<a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $txt['logged'], '</a>
652 692
 								</li>';
693
+	}
653 694
 
654 695
 	// Otherwise, you see NOTHING!
655
-	else
656
-		echo '
696
+	else {
697
+			echo '
657 698
 								<li class="poster_ip">', $txt['logged'], '</li>';
699
+	}
658 700
 
659 701
 	// Are we showing the warning status?
660 702
 	// Don't show these things for guests.
661
-	if (!$message['member']['is_guest'] && $message['member']['can_see_warning'])
662
-		echo '
703
+	if (!$message['member']['is_guest'] && $message['member']['can_see_warning']) {
704
+			echo '
663 705
 								<li class="warning">
664 706
 									', $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 707
 								</li>';
708
+	}
666 709
 
667 710
 	// 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)
711
+	if (!empty($message['custom_fields']['bottom_poster'])) {
712
+			foreach ($message['custom_fields']['bottom_poster'] as $custom)
670 713
 			echo '
671 714
 								<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
715
+	}
672 716
 
673 717
 	// Poster info ends.
674 718
 	echo '
@@ -698,9 +742,10 @@  discard block
 block discarded – undo
698 742
 	echo '
699 743
 									<span class="smalltext modified floatright', !empty($modSettings['show_modify']) && !empty($message['modified']['name']) ? ' mvisible' : '','" id="modified_', $message['id'], '">';
700 744
 
701
-	if (!empty($modSettings['show_modify']) && !empty($message['modified']['name']))
702
-		echo
745
+	if (!empty($modSettings['show_modify']) && !empty($message['modified']['name'])) {
746
+			echo
703 747
 										$message['modified']['last_edit_text'];
748
+	}
704 749
 
705 750
 	echo '
706 751
 									</span>
@@ -709,22 +754,24 @@  discard block
 block discarded – undo
709 754
 							</div><!-- .keyinfo -->';
710 755
 
711 756
 	// Ignoring this user? Hide the post.
712
-	if ($ignoring)
713
-		echo '
757
+	if ($ignoring) {
758
+			echo '
714 759
 							<div id="msg_', $message['id'], '_ignored_prompt">
715 760
 								', $txt['ignoring_user'], '
716 761
 								<a href="#" id="msg_', $message['id'], '_ignored_link" style="display: none;">', $txt['show_ignore_user_post'], '</a>
717 762
 							</div>';
763
+	}
718 764
 
719 765
 	// Show the post itself, finally!
720 766
 	echo '
721 767
 							<div class="post">';
722 768
 
723
-	if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id'])
724
-		echo '
769
+	if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id']) {
770
+			echo '
725 771
 								<div class="approve_post">
726 772
 									', $txt['post_awaiting_approval'], '
727 773
 								</div>';
774
+	}
728 775
 	echo '
729 776
 								<div class="inner" data-msgid="', $message['id'], '" id="msg_', $message['id'], '"', $ignoring ? ' style="display:none;"' : '', '>
730 777
 									', $message['body'], '
@@ -743,9 +790,9 @@  discard block
 block discarded – undo
743 790
 		foreach ($message['attachment'] as $attachment)
744 791
 		{
745 792
 			// 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)
793
+			if (!empty($modSettings['dont_show_attach_under_post']) && !empty($context['show_attach_under_post'][$attachment['id']])) {
794
+							continue;
795
+			} elseif (!$div_output)
749 796
 			{
750 797
 				$div_output = true;
751 798
 
@@ -762,9 +809,10 @@  discard block
 block discarded – undo
762 809
 									<legend>
763 810
 										', $txt['attach_awaiting_approve'];
764 811
 
765
-				if ($context['can_approve'])
766
-					echo '
812
+				if ($context['can_approve']) {
813
+									echo '
767 814
 										&nbsp;[<a href="', $scripturl, '?action=attachapprove;sa=all;mid=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve_all'], '</a>]';
815
+				}
768 816
 
769 817
 				echo '
770 818
 									</legend>';
@@ -778,12 +826,13 @@  discard block
 block discarded – undo
778 826
 				echo '
779 827
 										<div class="attachments_top">';
780 828
 
781
-				if ($attachment['thumbnail']['has_thumb'])
782
-					echo '
829
+				if ($attachment['thumbnail']['has_thumb']) {
830
+									echo '
783 831
 											<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 '
832
+				} else {
833
+									echo '
786 834
 											<img src="' . $attachment['href'] . ';image" alt="" width="' . $attachment['width'] . '" height="' . $attachment['height'] . '" class="atc_img">';
835
+				}
787 836
 
788 837
 				echo '
789 838
 										</div><!-- .attachments_top -->';
@@ -793,9 +842,10 @@  discard block
 block discarded – undo
793 842
 										<div class="attachments_bot">
794 843
 											<a href="' . $attachment['href'] . '"><img src="' . $settings['images_url'] . '/icons/clip.png" class="centericon" alt="*">&nbsp;' . $attachment['name'] . '</a> ';
795 844
 
796
-			if (!$attachment['is_approved'] && $context['can_approve'])
797
-				echo '
845
+			if (!$attachment['is_approved'] && $context['can_approve']) {
846
+							echo '
798 847
 											[<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>] ';
848
+			}
799 849
 			echo '
800 850
 											<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 851
 										</div><!-- .attachments_bot -->';
@@ -804,35 +854,40 @@  discard block
 block discarded – undo
804 854
 									</div><!-- .attached -->';
805 855
 
806 856
 			// Next attachment line ?
807
-			if (++$i % $attachments_per_line === 0)
808
-				echo '
857
+			if (++$i % $attachments_per_line === 0) {
858
+							echo '
809 859
 									<br>';
860
+			}
810 861
 		}
811 862
 
812 863
 		// If we had unapproved attachments clean up.
813
-		if ($last_approved_state == 0)
814
-			echo '
864
+		if ($last_approved_state == 0) {
865
+					echo '
815 866
 								</fieldset>';
867
+		}
816 868
 
817 869
 		// Only do this if we output a div above - otherwise it'll break things
818
-		if ($div_output)
819
-			echo '
870
+		if ($div_output) {
871
+					echo '
820 872
 							</div><!-- #msg_[id]_footer -->';
873
+		}
821 874
 	}
822 875
 
823 876
 	// 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 '
877
+	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']) {
878
+			echo '
826 879
 							<div class="under_message">';
880
+	}
827 881
 
828 882
 	// Maybe they want to report this post to the moderator(s)?
829
-	if ($context['can_report_moderator'])
830
-		echo '
883
+	if ($context['can_report_moderator']) {
884
+			echo '
831 885
 								<ul class="floatright smalltext">
832 886
 									<li class="report_link">
833 887
 										<a href="', $scripturl, '?action=reporttm;topic=', $context['current_topic'], '.', $message['counter'], ';msg=', $message['id'], '">', $txt['report_to_mod'], '</a>
834 888
 									</li>
835 889
 								</ul>';
890
+	}
836 891
 
837 892
 	// What about likes?
838 893
 	if (!empty($modSettings['enable_likes']))
@@ -879,83 +934,95 @@  discard block
 block discarded – undo
879 934
 								<ul class="quickbuttons">';
880 935
 
881 936
 		// Can they quote? if so they can select and quote as well!
882
-		if ($context['can_quote'])
883
-			echo '
937
+		if ($context['can_quote']) {
938
+					echo '
884 939
 									<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 940
 									<li style="display:none;" id="quoteSelected_', $message['id'], '">
886 941
 										<a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'], '</a>
887 942
 									</li>';
943
+		}
888 944
 
889 945
 		// Can the user modify the contents of this post? Show the modify inline image.
890
-		if ($message['can_modify'])
891
-			echo '
946
+		if ($message['can_modify']) {
947
+					echo '
892 948
 									<li class="quick_edit">
893 949
 										<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 950
 									</li>';
951
+		}
895 952
 
896
-		if ($message['can_approve'] || $message['can_unapprove'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'])
897
-			echo '
953
+		if ($message['can_approve'] || $message['can_unapprove'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) {
954
+					echo '
898 955
 									<li class="post_options">', $txt['post_options'];
956
+		}
899 957
 
900 958
 		echo '
901 959
 										<ul>';
902 960
 
903 961
 		// Can the user modify the contents of this post?
904
-		if ($message['can_modify'])
905
-			echo '
962
+		if ($message['can_modify']) {
963
+					echo '
906 964
 											<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>';
965
+		}
907 966
 
908 967
 		// How about... even... remove it entirely?!
909
-		if ($context['can_delete'] && ($context['topic_first_message'] == $message['id']))
910
-			echo '
968
+		if ($context['can_delete'] && ($context['topic_first_message'] == $message['id'])) {
969
+					echo '
911 970
 											<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 '
971
+		} elseif ($message['can_remove'] && ($context['topic_first_message'] != $message['id'])) {
972
+					echo '
915 973
 											<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>';
974
+		}
916 975
 
917 976
 		// What about splitting it off the rest of the topic?
918
-		if ($context['can_split'] && !empty($context['real_num_replies']))
919
-			echo '
977
+		if ($context['can_split'] && !empty($context['real_num_replies'])) {
978
+					echo '
920 979
 											<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>';
980
+		}
921 981
 
922 982
 		// 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 '
983
+		if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest']) {
984
+					echo '
925 985
 											<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>';
986
+		}
926 987
 
927 988
 		// Can we restore topics?
928
-		if ($context['can_restore_msg'])
929
-			echo '
989
+		if ($context['can_restore_msg']) {
990
+					echo '
930 991
 											<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>';
992
+		}
931 993
 
932 994
 		// Maybe we can approve it, maybe we should?
933
-		if ($message['can_approve'])
934
-			echo '
995
+		if ($message['can_approve']) {
996
+					echo '
935 997
 											<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>';
998
+		}
936 999
 
937 1000
 		// Maybe we can unapprove it?
938
-		if ($message['can_unapprove'])
939
-			echo '
1001
+		if ($message['can_unapprove']) {
1002
+					echo '
940 1003
 											<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>';
1004
+		}
941 1005
 
942 1006
 		echo '
943 1007
 										</ul>
944 1008
 									</li>';
945 1009
 
946 1010
 		// Show a checkbox for quick moderation?
947
-		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove'])
948
-			echo '
1011
+		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove']) {
1012
+					echo '
949 1013
 									<li style="display: none;" id="in_topic_mod_check_', $message['id'], '"></li>';
1014
+		}
950 1015
 
951
-		if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'])
952
-			echo '
1016
+		if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) {
1017
+					echo '
953 1018
 								</ul><!-- .quickbuttons -->';
1019
+		}
954 1020
 	}
955 1021
 
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 '
1022
+	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']) {
1023
+			echo '
958 1024
 							</div><!-- .under_message -->';
1025
+	}
959 1026
 
960 1027
 	echo '
961 1028
 						</div><!-- .postarea -->
@@ -968,9 +1035,10 @@  discard block
 block discarded – undo
968 1035
 							<div class="custom_fields_above_signature">
969 1036
 								<ul class="nolist">';
970 1037
 
971
-		foreach ($message['custom_fields']['above_signature'] as $custom)
972
-			echo '
1038
+		foreach ($message['custom_fields']['above_signature'] as $custom) {
1039
+					echo '
973 1040
 									<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
1041
+		}
974 1042
 
975 1043
 		echo '
976 1044
 								</ul>
@@ -978,11 +1046,12 @@  discard block
 block discarded – undo
978 1046
 	}
979 1047
 
980 1048
 	// Show the member's signature?
981
-	if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled'])
982
-		echo '
1049
+	if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) {
1050
+			echo '
983 1051
 							<div class="signature" id="msg_', $message['id'], '_signature"', $ignoring ? ' style="display:none;"' : '', '>
984 1052
 								', $message['member']['signature'], '
985 1053
 							</div>';
1054
+	}
986 1055
 
987 1056
 
988 1057
 	// Are there any custom profile fields for below the signature?
@@ -992,9 +1061,10 @@  discard block
 block discarded – undo
992 1061
 							<div class="custom_fields_below_signature">
993 1062
 								<ul class="nolist">';
994 1063
 
995
-		foreach ($message['custom_fields']['below_signature'] as $custom)
996
-			echo '
1064
+		foreach ($message['custom_fields']['below_signature'] as $custom) {
1065
+					echo '
997 1066
 									<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
1067
+		}
998 1068
 
999 1069
 		echo '
1000 1070
 								</ul>
@@ -1044,8 +1114,8 @@  discard block
 block discarded – undo
1044 1114
 						<input type="hidden" name="seqnum" value="', $context['form_sequence_number'], '">';
1045 1115
 
1046 1116
 	// Guests just need more.
1047
-	if ($context['user']['is_guest'])
1048
-		echo '
1117
+	if ($context['user']['is_guest']) {
1118
+			echo '
1049 1119
 						<dl id="post_header">
1050 1120
 							<dt>
1051 1121
 								', $txt['name'], ':
@@ -1060,6 +1130,7 @@  discard block
 block discarded – undo
1060 1130
 								<input type="email" name="email" size="25" value="', $context['email'], '" tabindex="', $context['tabindex']++, '" required>
1061 1131
 							</dd>
1062 1132
 						</dl>';
1133
+	}
1063 1134
 
1064 1135
 	echo '
1065 1136
 						', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message'), '
@@ -1084,12 +1155,13 @@  discard block
 block discarded – undo
1084 1155
 						</script>';
1085 1156
 
1086 1157
 	// Is visual verification enabled?
1087
-	if ($context['require_verification'])
1088
-		echo '
1158
+	if ($context['require_verification']) {
1159
+			echo '
1089 1160
 						<div class="post_verification">
1090 1161
 							<strong>', $txt['verification'], ':</strong>
1091 1162
 							', template_control_verification($context['visual_verification_id'], 'all'), '
1092 1163
 						</div>';
1164
+	}
1093 1165
 
1094 1166
 	// Finally, the submit buttons.
1095 1167
 	echo '
@@ -1105,8 +1177,8 @@  discard block
 block discarded – undo
1105 1177
 		<br class="clear">';
1106 1178
 
1107 1179
 	// Draft autosave available and the user has it enabled?
1108
-	if (!empty($context['drafts_autosave']))
1109
-		echo '
1180
+	if (!empty($context['drafts_autosave'])) {
1181
+			echo '
1110 1182
 		<script>
1111 1183
 			var oDraftAutoSave = new smf_DraftAutoSave({
1112 1184
 				sSelf: \'oDraftAutoSave\',
@@ -1118,12 +1190,14 @@  discard block
 block discarded – undo
1118 1190
 				iFreq: ', (empty($modSettings['masterAutoSaveDraftsDelay']) ? 60000 : $modSettings['masterAutoSaveDraftsDelay'] * 1000), '
1119 1191
 			});
1120 1192
 		</script>';
1193
+	}
1121 1194
 
1122
-	if ($context['show_spellchecking'])
1123
-		echo '
1195
+	if ($context['show_spellchecking']) {
1196
+			echo '
1124 1197
 		<form action="', $scripturl, '?action=spellcheck" method="post" accept-charset="', $context['character_set'], '" name="spell_form" id="spell_form" target="spellWindow">
1125 1198
 			<input type="hidden" name="spellstring" value="">
1126 1199
 		</form>';
1200
+	}
1127 1201
 
1128 1202
 	echo '
1129 1203
 		<script>
Please login to merge, or discard this patch.