Completed
Branch release-2.1 (e49a83)
by Michael
08:59
created
Sources/Logging.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 	if (filemtime($boarddir . '/db_last_error.php') === $last_db_error_change)
176 176
 	{
177 177
 		// Write the change
178
-		$write_db_change =  '<' . '?' . "php\n" . '$db_last_error = ' . time() . ';' . "\n" . '?' . '>';
178
+		$write_db_change = '<' . '?' . "php\n" . '$db_last_error = ' . time() . ';' . "\n" . '?' . '>';
179 179
 		$written_bytes = file_put_contents($boarddir . '/db_last_error.php', $write_db_change, LOCK_EX);
180 180
 
181 181
 		// survey says ...
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 	', $txt['debug_language_files'], count($context['debug']['language_files']), ': <em>', implode('</em>, <em>', $context['debug']['language_files']), '</em>.<br>
249 249
 	', $txt['debug_stylesheets'], count($context['debug']['sheets']), ': <em>', implode('</em>, <em>', $context['debug']['sheets']), '</em>.<br>
250 250
 	', $txt['debug_hooks'], empty($context['debug']['hooks']) ? 0 : count($context['debug']['hooks']) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_hooks\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_hooks" style="display: none;"><em>' . implode('</em>, <em>', $context['debug']['hooks']), '</em></span>)', '<br>
251
-	',(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>') : ''),'
251
+	',(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>') : ''), '
252 252
 	', $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>';
253 253
 
254 254
 	if (function_exists('memory_get_peak_usage'))
Please login to merge, or discard this patch.
Braces   +134 added lines, -96 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
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
  * Put this user in the online log.
@@ -33,8 +34,9 @@  discard block
 block discarded – undo
33 34
 		// Don't update for every page - this isn't wholly accurate but who cares.
34 35
 		if ($topic)
35 36
 		{
36
-			if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic)
37
-				$force = false;
37
+			if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic) {
38
+							$force = false;
39
+			}
38 40
 			$_SESSION['last_topic_id'] = $topic;
39 41
 		}
40 42
 	}
@@ -47,22 +49,24 @@  discard block
 block discarded – undo
47 49
 	}
48 50
 
49 51
 	// Don't mark them as online more than every so often.
50
-	if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force)
51
-		return;
52
+	if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force) {
53
+			return;
54
+	}
52 55
 
53 56
 	if (!empty($modSettings['who_enabled']))
54 57
 	{
55 58
 		$serialized = $_GET + array('USER_AGENT' => $_SERVER['HTTP_USER_AGENT']);
56 59
 
57 60
 		// In the case of a dlattach action, session_var may not be set.
58
-		if (!isset($context['session_var']))
59
-			$context['session_var'] = $_SESSION['session_var'];
61
+		if (!isset($context['session_var'])) {
62
+					$context['session_var'] = $_SESSION['session_var'];
63
+		}
60 64
 
61 65
 		unset($serialized['sesc'], $serialized[$context['session_var']]);
62 66
 		$serialized = json_encode($serialized);
67
+	} else {
68
+			$serialized = '';
63 69
 	}
64
-	else
65
-		$serialized = '';
66 70
 
67 71
 	// Guests use 0, members use their session ID.
68 72
 	$session_id = $user_info['is_guest'] ? 'ip' . $user_info['ip'] : session_id();
@@ -102,17 +106,18 @@  discard block
 block discarded – undo
102 106
 		);
103 107
 
104 108
 		// Guess it got deleted.
105
-		if ($smcFunc['db_affected_rows']() == 0)
109
+		if ($smcFunc['db_affected_rows']() == 0) {
110
+					$_SESSION['log_time'] = 0;
111
+		}
112
+	} else {
106 113
 			$_SESSION['log_time'] = 0;
107 114
 	}
108
-	else
109
-		$_SESSION['log_time'] = 0;
110 115
 
111 116
 	// Otherwise, we have to delete and insert.
112 117
 	if (empty($_SESSION['log_time']))
113 118
 	{
114
-		if ($do_delete || !empty($user_info['id']))
115
-			$smcFunc['db_query']('', '
119
+		if ($do_delete || !empty($user_info['id'])) {
120
+					$smcFunc['db_query']('', '
116 121
 				DELETE FROM {db_prefix}log_online
117 122
 				WHERE ' . ($do_delete ? 'log_time < {int:log_time}' : '') . ($do_delete && !empty($user_info['id']) ? ' OR ' : '') . (empty($user_info['id']) ? '' : 'id_member = {int:current_member}'),
118 123
 				array(
@@ -120,6 +125,7 @@  discard block
 block discarded – undo
120 125
 					'log_time' => time() - $modSettings['lastActive'] * 60,
121 126
 				)
122 127
 			);
128
+		}
123 129
 
124 130
 		$smcFunc['db_insert']($do_delete ? 'ignore' : 'replace',
125 131
 			'{db_prefix}log_online',
@@ -133,21 +139,24 @@  discard block
 block discarded – undo
133 139
 	$_SESSION['log_time'] = time();
134 140
 
135 141
 	// Well, they are online now.
136
-	if (empty($_SESSION['timeOnlineUpdated']))
137
-		$_SESSION['timeOnlineUpdated'] = time();
142
+	if (empty($_SESSION['timeOnlineUpdated'])) {
143
+			$_SESSION['timeOnlineUpdated'] = time();
144
+	}
138 145
 
139 146
 	// Set their login time, if not already done within the last minute.
140 147
 	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'))))
141 148
 	{
142 149
 		// Don't count longer than 15 minutes.
143
-		if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15)
144
-			$_SESSION['timeOnlineUpdated'] = time();
150
+		if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15) {
151
+					$_SESSION['timeOnlineUpdated'] = time();
152
+		}
145 153
 
146 154
 		$user_settings['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated'];
147 155
 		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']));
148 156
 
149
-		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
150
-			cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60);
157
+		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
158
+					cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60);
159
+		}
151 160
 
152 161
 		$user_info['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated'];
153 162
 		$_SESSION['timeOnlineUpdated'] = time();
@@ -184,8 +193,7 @@  discard block
 block discarded – undo
184 193
 			// Oops. maybe we have no more disk space left, or some other troubles, troubles...
185 194
 			// Copy the file back and run for your life!
186 195
 			@copy($boarddir . '/db_last_error_bak.php', $boarddir . '/db_last_error.php');
187
-		}
188
-		else
196
+		} else
189 197
 		{
190 198
 			@touch($boarddir . '/' . 'Settings.php');
191 199
 			return true;
@@ -205,22 +213,27 @@  discard block
 block discarded – undo
205 213
 	global $db_cache, $db_count, $cache_misses, $cache_count_misses, $db_show_debug, $cache_count, $cache_hits, $smcFunc, $txt;
206 214
 
207 215
 	// Add to Settings.php if you want to show the debugging information.
208
-	if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery'))
209
-		return;
216
+	if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery')) {
217
+			return;
218
+	}
210 219
 
211
-	if (empty($_SESSION['view_queries']))
212
-		$_SESSION['view_queries'] = 0;
213
-	if (empty($context['debug']['language_files']))
214
-		$context['debug']['language_files'] = array();
215
-	if (empty($context['debug']['sheets']))
216
-		$context['debug']['sheets'] = array();
220
+	if (empty($_SESSION['view_queries'])) {
221
+			$_SESSION['view_queries'] = 0;
222
+	}
223
+	if (empty($context['debug']['language_files'])) {
224
+			$context['debug']['language_files'] = array();
225
+	}
226
+	if (empty($context['debug']['sheets'])) {
227
+			$context['debug']['sheets'] = array();
228
+	}
217 229
 
218 230
 	$files = get_included_files();
219 231
 	$total_size = 0;
220 232
 	for ($i = 0, $n = count($files); $i < $n; $i++)
221 233
 	{
222
-		if (file_exists($files[$i]))
223
-			$total_size += filesize($files[$i]);
234
+		if (file_exists($files[$i])) {
235
+					$total_size += filesize($files[$i]);
236
+		}
224 237
 		$files[$i] = strtr($files[$i], array($boarddir => '.', $sourcedir => '(Sources)', $cachedir => '(Cache)', $settings['actual_theme_dir'] => '(Current Theme)'));
225 238
 	}
226 239
 
@@ -229,8 +242,9 @@  discard block
 block discarded – undo
229 242
 	{
230 243
 		foreach ($db_cache as $q => $qq)
231 244
 		{
232
-			if (!empty($qq['w']))
233
-				$warnings += count($qq['w']);
245
+			if (!empty($qq['w'])) {
246
+							$warnings += count($qq['w']);
247
+			}
234 248
 		}
235 249
 
236 250
 		$_SESSION['debug'] = &$db_cache;
@@ -251,12 +265,14 @@  discard block
 block discarded – undo
251 265
 	',(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>') : ''),'
252 266
 	', $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>';
253 267
 
254
-	if (function_exists('memory_get_peak_usage'))
255
-		echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>';
268
+	if (function_exists('memory_get_peak_usage')) {
269
+			echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>';
270
+	}
256 271
 
257 272
 	// What tokens are active?
258
-	if (isset($_SESSION['token']))
259
-		echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>';
273
+	if (isset($_SESSION['token'])) {
274
+			echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>';
275
+	}
260 276
 
261 277
 	if (!empty($modSettings['cache_enable']) && !empty($cache_hits))
262 278
 	{
@@ -269,10 +285,12 @@  discard block
 block discarded – undo
269 285
 			$total_t += $cache_hit['t'];
270 286
 			$total_s += $cache_hit['s'];
271 287
 		}
272
-		if (!isset($cache_misses))
273
-			$cache_misses = array();
274
-		foreach ($cache_misses as $missed)
275
-			$missed_entires[] = $missed['d'] . ' ' . $missed['k'];
288
+		if (!isset($cache_misses)) {
289
+					$cache_misses = array();
290
+		}
291
+		foreach ($cache_misses as $missed) {
292
+					$missed_entires[] = $missed['d'] . ' ' . $missed['k'];
293
+		}
276 294
 
277 295
 		echo '
278 296
 	', $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>
@@ -283,38 +301,44 @@  discard block
 block discarded – undo
283 301
 	<a href="', $scripturl, '?action=viewquery" target="_blank" class="new_win">', $warnings == 0 ? sprintf($txt['debug_queries_used'], (int) $db_count) : sprintf($txt['debug_queries_used_and_warnings'], (int) $db_count, $warnings), '</a><br>
284 302
 	<br>';
285 303
 
286
-	if ($_SESSION['view_queries'] == 1 && !empty($db_cache))
287
-		foreach ($db_cache as $q => $qq)
304
+	if ($_SESSION['view_queries'] == 1 && !empty($db_cache)) {
305
+			foreach ($db_cache as $q => $qq)
288 306
 		{
289 307
 			$is_select = strpos(trim($qq['q']), 'SELECT') === 0 || preg_match('~^INSERT(?: IGNORE)? INTO \w+(?:\s+\([^)]+\))?\s+SELECT .+$~s', trim($qq['q'])) != 0;
308
+	}
290 309
 			// Temporary tables created in earlier queries are not explainable.
291 310
 			if ($is_select)
292 311
 			{
293
-				foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp)
294
-					if (strpos(trim($qq['q']), $tmp) !== false)
312
+				foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) {
313
+									if (strpos(trim($qq['q']), $tmp) !== false)
295 314
 					{
296 315
 						$is_select = false;
316
+				}
297 317
 						break;
298 318
 					}
299 319
 			}
300 320
 			// But actual creation of the temporary tables are.
301
-			elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($qq['q'])) != 0)
302
-				$is_select = true;
321
+			elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($qq['q'])) != 0) {
322
+							$is_select = true;
323
+			}
303 324
 
304 325
 			// Make the filenames look a bit better.
305
-			if (isset($qq['f']))
306
-				$qq['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $qq['f']);
326
+			if (isset($qq['f'])) {
327
+							$qq['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $qq['f']);
328
+			}
307 329
 
308 330
 			echo '
309 331
 	<strong>', $is_select ? '<a href="' . $scripturl . '?action=viewquery;qq=' . ($q + 1) . '#qq' . $q . '" target="_blank" class="new_win" style="text-decoration: none;">' : '', nl2br(str_replace("\t", '&nbsp;&nbsp;&nbsp;', $smcFunc['htmlspecialchars'](ltrim($qq['q'], "\n\r")))) . ($is_select ? '</a></strong>' : '</strong>') . '<br>
310 332
 	&nbsp;&nbsp;&nbsp;';
311
-			if (!empty($qq['f']) && !empty($qq['l']))
312
-				echo sprintf($txt['debug_query_in_line'], $qq['f'], $qq['l']);
333
+			if (!empty($qq['f']) && !empty($qq['l'])) {
334
+							echo sprintf($txt['debug_query_in_line'], $qq['f'], $qq['l']);
335
+			}
313 336
 
314
-			if (isset($qq['s'], $qq['t']) && isset($txt['debug_query_which_took_at']))
315
-				echo sprintf($txt['debug_query_which_took_at'], round($qq['t'], 8), round($qq['s'], 8)) . '<br>';
316
-			elseif (isset($qq['t']))
317
-				echo sprintf($txt['debug_query_which_took'], round($qq['t'], 8)) . '<br>';
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>';
341
+			}
318 342
 			echo '
319 343
 	<br>';
320 344
 		}
@@ -339,12 +363,14 @@  discard block
 block discarded – undo
339 363
 	global $modSettings, $smcFunc;
340 364
 	static $cache_stats = array();
341 365
 
342
-	if (empty($modSettings['trackStats']))
343
-		return false;
344
-	if (!empty($stats))
345
-		return $cache_stats = array_merge($cache_stats, $stats);
346
-	elseif (empty($cache_stats))
347
-		return false;
366
+	if (empty($modSettings['trackStats'])) {
367
+			return false;
368
+	}
369
+	if (!empty($stats)) {
370
+			return $cache_stats = array_merge($cache_stats, $stats);
371
+	} elseif (empty($cache_stats)) {
372
+			return false;
373
+	}
348 374
 
349 375
 	$setStringUpdate = '';
350 376
 	$insert_keys = array();
@@ -357,10 +383,11 @@  discard block
 block discarded – undo
357 383
 		$setStringUpdate .= '
358 384
 			' . $field . ' = ' . ($change === '+' ? $field . ' + 1' : '{int:' . $field . '}') . ',';
359 385
 
360
-		if ($change === '+')
361
-			$cache_stats[$field] = 1;
362
-		else
363
-			$update_parameters[$field] = $change;
386
+		if ($change === '+') {
387
+					$cache_stats[$field] = 1;
388
+		} else {
389
+					$update_parameters[$field] = $change;
390
+		}
364 391
 		$insert_keys[$field] = 'int';
365 392
 	}
366 393
 
@@ -424,43 +451,50 @@  discard block
 block discarded – undo
424 451
 	);
425 452
 
426 453
 	// Make sure this particular log is enabled first...
427
-	if (empty($modSettings['modlog_enabled']))
428
-		unset ($log_types['moderate']);
429
-	if (empty($modSettings['userlog_enabled']))
430
-		unset ($log_types['user']);
431
-	if (empty($modSettings['adminlog_enabled']))
432
-		unset ($log_types['admin']);
454
+	if (empty($modSettings['modlog_enabled'])) {
455
+			unset ($log_types['moderate']);
456
+	}
457
+	if (empty($modSettings['userlog_enabled'])) {
458
+			unset ($log_types['user']);
459
+	}
460
+	if (empty($modSettings['adminlog_enabled'])) {
461
+			unset ($log_types['admin']);
462
+	}
433 463
 
434 464
 	call_integration_hook('integrate_log_types', array(&$log_types));
435 465
 
436 466
 	foreach ($logs as $log)
437 467
 	{
438
-		if (!isset($log_types[$log['log_type']]))
439
-			return false;
468
+		if (!isset($log_types[$log['log_type']])) {
469
+					return false;
470
+		}
440 471
 
441
-		if (!is_array($log['extra']))
442
-			trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE);
472
+		if (!is_array($log['extra'])) {
473
+					trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE);
474
+		}
443 475
 
444 476
 		// Pull out the parts we want to store separately, but also make sure that the data is proper
445 477
 		if (isset($log['extra']['topic']))
446 478
 		{
447
-			if (!is_numeric($log['extra']['topic']))
448
-				trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE);
479
+			if (!is_numeric($log['extra']['topic'])) {
480
+							trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE);
481
+			}
449 482
 			$topic_id = empty($log['extra']['topic']) ? 0 : (int) $log['extra']['topic'];
450 483
 			unset($log['extra']['topic']);
484
+		} else {
485
+					$topic_id = 0;
451 486
 		}
452
-		else
453
-			$topic_id = 0;
454 487
 
455 488
 		if (isset($log['extra']['message']))
456 489
 		{
457
-			if (!is_numeric($log['extra']['message']))
458
-				trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE);
490
+			if (!is_numeric($log['extra']['message'])) {
491
+							trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE);
492
+			}
459 493
 			$msg_id = empty($log['extra']['message']) ? 0 : (int) $log['extra']['message'];
460 494
 			unset($log['extra']['message']);
495
+		} else {
496
+					$msg_id = 0;
461 497
 		}
462
-		else
463
-			$msg_id = 0;
464 498
 
465 499
 		// @todo cache this?
466 500
 		// Is there an associated report on this?
@@ -487,23 +521,26 @@  discard block
 block discarded – undo
487 521
 			$smcFunc['db_free_result']($request);
488 522
 		}
489 523
 
490
-		if (isset($log['extra']['member']) && !is_numeric($log['extra']['member']))
491
-			trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE);
524
+		if (isset($log['extra']['member']) && !is_numeric($log['extra']['member'])) {
525
+					trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE);
526
+		}
492 527
 
493 528
 		if (isset($log['extra']['board']))
494 529
 		{
495
-			if (!is_numeric($log['extra']['board']))
496
-				trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE);
530
+			if (!is_numeric($log['extra']['board'])) {
531
+							trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE);
532
+			}
497 533
 			$board_id = empty($log['extra']['board']) ? 0 : (int) $log['extra']['board'];
498 534
 			unset($log['extra']['board']);
535
+		} else {
536
+					$board_id = 0;
499 537
 		}
500
-		else
501
-			$board_id = 0;
502 538
 
503 539
 		if (isset($log['extra']['board_to']))
504 540
 		{
505
-			if (!is_numeric($log['extra']['board_to']))
506
-				trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE);
541
+			if (!is_numeric($log['extra']['board_to'])) {
542
+							trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE);
543
+			}
507 544
 			if (empty($board_id))
508 545
 			{
509 546
 				$board_id = empty($log['extra']['board_to']) ? 0 : (int) $log['extra']['board_to'];
@@ -511,10 +548,11 @@  discard block
 block discarded – undo
511 548
 			}
512 549
 		}
513 550
 
514
-		if (isset($log['extra']['member_affected']))
515
-			$memID = $log['extra']['member_affected'];
516
-		else
517
-			$memID = $user_info['id'];
551
+		if (isset($log['extra']['member_affected'])) {
552
+					$memID = $log['extra']['member_affected'];
553
+		} else {
554
+					$memID = $user_info['id'];
555
+		}
518 556
 
519 557
 		$inserts[] = array(
520 558
 			time(), $log_types[$log['log_type']], $memID, $user_info['ip'], $log['action'],
Please login to merge, or discard this patch.
Sources/Recent.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 	else
238 238
 	{
239 239
 		$query_this_board = '{query_wanna_see_board}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? '
240
-					AND b.id_board != {int:recycle_board}' : ''). '
240
+					AND b.id_board != {int:recycle_board}' : '') . '
241 241
 					AND m.id_msg >= {int:max_id_msg}';
242 242
 		$query_parameters['max_id_msg'] = max(0, $modSettings['maxMsgID'] - 100 - $_REQUEST['start'] * 6);
243 243
 		$query_parameters['recycle_board'] = $modSettings['recycle_board'];
@@ -1124,7 +1124,7 @@  discard block
 block discarded – undo
1124 1124
 			);
1125 1125
 		else
1126 1126
 			$request = $smcFunc['db_query']('', '
1127
-				SELECT DISTINCT t.id_topic,'.$_REQUEST['sort'].'
1127
+				SELECT DISTINCT t.id_topic,'.$_REQUEST['sort'] . '
1128 1128
 				FROM {db_prefix}topics AS t
1129 1129
 					INNER JOIN {db_prefix}messages AS m ON (m.id_topic = t.id_topic AND m.id_member = {int:current_member})' . (strpos($_REQUEST['sort'], 'ms.') === false ? '' : '
1130 1130
 					INNER JOIN {db_prefix}messages AS ms ON (ms.id_msg = t.id_first_msg)') . (strpos($_REQUEST['sort'], 'mems.') === false ? '' : '
@@ -1391,7 +1391,7 @@  discard block
 block discarded – undo
1391 1391
 	if ($is_topics)
1392 1392
 	{
1393 1393
 		$context['recent_buttons'] = array(
1394
-			'markread' => array('text' => !empty($context['no_board_limits']) ? 'mark_as_read' : 'mark_read_short', 'image' => 'markread.png', 'custom' => 'data-confirm="'.  $txt['are_sure_mark_read'] .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=' . (!empty($context['no_board_limits']) ? 'all' : 'board' . $context['querystring_board_limits']) . ';' . $context['session_var'] . '=' . $context['session_id']),
1394
+			'markread' => array('text' => !empty($context['no_board_limits']) ? 'mark_as_read' : 'mark_read_short', 'image' => 'markread.png', 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=' . (!empty($context['no_board_limits']) ? 'all' : 'board' . $context['querystring_board_limits']) . ';' . $context['session_var'] . '=' . $context['session_id']),
1395 1395
 		);
1396 1396
 
1397 1397
 		if ($context['showCheckboxes'])
@@ -1407,7 +1407,7 @@  discard block
 block discarded – undo
1407 1407
 	elseif (!$is_topics && isset($context['topics_to_mark']))
1408 1408
 	{
1409 1409
 		$context['recent_buttons'] = array(
1410
-			'markread' => array('text' => 'mark_as_read', 'image' => 'markread.png', 'custom' => 'data-confirm="'. $txt['are_sure_mark_read']  .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=unreadreplies;topics=' . $context['topics_to_mark'] . ';' . $context['session_var'] . '=' . $context['session_id']),
1410
+			'markread' => array('text' => 'mark_as_read', 'image' => 'markread.png', 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=unreadreplies;topics=' . $context['topics_to_mark'] . ';' . $context['session_var'] . '=' . $context['session_id']),
1411 1411
 		);
1412 1412
 
1413 1413
 		if ($context['showCheckboxes'])
Please login to merge, or discard this patch.
Braces   +208 added lines, -170 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
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
  * Get the latest post made on the system
@@ -44,8 +45,9 @@  discard block
 block discarded – undo
44 45
 			'is_approved' => 1,
45 46
 		)
46 47
 	);
47
-	if ($smcFunc['db_num_rows']($request) == 0)
48
-		return array();
48
+	if ($smcFunc['db_num_rows']($request) == 0) {
49
+			return array();
50
+	}
49 51
 	$row = $smcFunc['db_fetch_assoc']($request);
50 52
 	$smcFunc['db_free_result']($request);
51 53
 
@@ -54,8 +56,9 @@  discard block
 block discarded – undo
54 56
 	censorText($row['body']);
55 57
 
56 58
 	$row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled']), array('<br>' => '&#10;')));
57
-	if ($smcFunc['strlen']($row['body']) > 128)
58
-		$row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...';
59
+	if ($smcFunc['strlen']($row['body']) > 128) {
60
+			$row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...';
61
+	}
59 62
 
60 63
 	// Send the data.
61 64
 	return array(
@@ -83,15 +86,17 @@  discard block
 block discarded – undo
83 86
 
84 87
 	$context['is_redirect'] = false;
85 88
 
86
-	if (isset($_REQUEST['start']) && $_REQUEST['start'] > 95)
87
-		$_REQUEST['start'] = 95;
89
+	if (isset($_REQUEST['start']) && $_REQUEST['start'] > 95) {
90
+			$_REQUEST['start'] = 95;
91
+	}
88 92
 
89 93
 	$query_parameters = array();
90 94
 	if (!empty($_REQUEST['c']) && empty($board))
91 95
 	{
92 96
 		$_REQUEST['c'] = explode(',', $_REQUEST['c']);
93
-		foreach ($_REQUEST['c'] as $i => $c)
94
-			$_REQUEST['c'][$i] = (int) $c;
97
+		foreach ($_REQUEST['c'] as $i => $c) {
98
+					$_REQUEST['c'][$i] = (int) $c;
99
+		}
95 100
 
96 101
 		if (count($_REQUEST['c']) == 1)
97 102
 		{
@@ -107,8 +112,9 @@  discard block
 block discarded – undo
107 112
 			list ($name) = $smcFunc['db_fetch_row']($request);
108 113
 			$smcFunc['db_free_result']($request);
109 114
 
110
-			if (empty($name))
111
-				fatal_lang_error('no_access', false);
115
+			if (empty($name)) {
116
+							fatal_lang_error('no_access', false);
117
+			}
112 118
 
113 119
 			$context['linktree'][] = array(
114 120
 				'url' => $scripturl . '#c' . (int) $_REQUEST['c'],
@@ -140,8 +146,9 @@  discard block
 block discarded – undo
140 146
 		}
141 147
 		$smcFunc['db_free_result']($request);
142 148
 
143
-		if (empty($boards))
144
-			fatal_lang_error('error_no_boards_selected');
149
+		if (empty($boards)) {
150
+					fatal_lang_error('error_no_boards_selected');
151
+		}
145 152
 
146 153
 		$query_this_board = 'b.id_board IN ({array_int:boards})';
147 154
 		$query_parameters['boards'] = $boards;
@@ -155,12 +162,12 @@  discard block
 block discarded – undo
155 162
 		}
156 163
 
157 164
 		$context['page_index'] = constructPageIndex($scripturl . '?action=recent;c=' . implode(',', $_REQUEST['c']), $_REQUEST['start'], min(100, $total_cat_posts), 10, false);
158
-	}
159
-	elseif (!empty($_REQUEST['boards']))
165
+	} elseif (!empty($_REQUEST['boards']))
160 166
 	{
161 167
 		$_REQUEST['boards'] = explode(',', $_REQUEST['boards']);
162
-		foreach ($_REQUEST['boards'] as $i => $b)
163
-			$_REQUEST['boards'][$i] = (int) $b;
168
+		foreach ($_REQUEST['boards'] as $i => $b) {
169
+					$_REQUEST['boards'][$i] = (int) $b;
170
+		}
164 171
 
165 172
 		$request = $smcFunc['db_query']('', '
166 173
 			SELECT b.id_board, b.num_posts
@@ -184,8 +191,9 @@  discard block
 block discarded – undo
184 191
 		}
185 192
 		$smcFunc['db_free_result']($request);
186 193
 
187
-		if (empty($boards))
188
-			fatal_lang_error('error_no_boards_selected');
194
+		if (empty($boards)) {
195
+					fatal_lang_error('error_no_boards_selected');
196
+		}
189 197
 
190 198
 		$query_this_board = 'b.id_board IN ({array_int:boards})';
191 199
 		$query_parameters['boards'] = $boards;
@@ -199,8 +207,7 @@  discard block
 block discarded – undo
199 207
 		}
200 208
 
201 209
 		$context['page_index'] = constructPageIndex($scripturl . '?action=recent;boards=' . implode(',', $_REQUEST['boards']), $_REQUEST['start'], min(100, $total_posts), 10, false);
202
-	}
203
-	elseif (!empty($board))
210
+	} elseif (!empty($board))
204 211
 	{
205 212
 		$request = $smcFunc['db_query']('', '
206 213
 			SELECT num_posts, redirect
@@ -233,8 +240,7 @@  discard block
 block discarded – undo
233 240
 		}
234 241
 
235 242
 		$context['page_index'] = constructPageIndex($scripturl . '?action=recent;board=' . $board . '.%1$d', $_REQUEST['start'], min(100, $total_posts), 10, true);
236
-	}
237
-	else
243
+	} else
238 244
 	{
239 245
 		$query_this_board = '{query_wanna_see_board}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? '
240 246
 					AND b.id_board != {int:recycle_board}' : ''). '
@@ -269,8 +275,9 @@  discard block
 block discarded – undo
269 275
 	);
270 276
 
271 277
 	// If you selected a redirection board, don't try getting posts for it...
272
-	if ($context['is_redirect'])
273
-		$messages = 0;
278
+	if ($context['is_redirect']) {
279
+			$messages = 0;
280
+	}
274 281
 
275 282
 	$key = 'recent-' . $user_info['id'] . '-' . md5(json_encode(array_diff_key($query_parameters, array('max_id_msg' => 0)))) . '-' . (int) $_REQUEST['start'];
276 283
 	if (!$context['is_redirect'] && (empty($modSettings['cache_enable']) || ($messages = cache_get_data($key, 120)) == null))
@@ -301,16 +308,18 @@  discard block
 block discarded – undo
301 308
 				$query_this_board = str_replace('AND m.id_msg >= {int:max_id_msg}', '', $query_this_board);
302 309
 				$cache_results = true;
303 310
 				unset($query_parameters['max_id_msg']);
311
+			} else {
312
+							$done = true;
304 313
 			}
305
-			else
306
-				$done = true;
307 314
 		}
308 315
 		$messages = array();
309
-		while ($row = $smcFunc['db_fetch_assoc']($request))
310
-			$messages[] = $row['id_msg'];
316
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
317
+					$messages[] = $row['id_msg'];
318
+		}
311 319
 		$smcFunc['db_free_result']($request);
312
-		if (!empty($cache_results))
313
-			cache_put_data($key, $messages, 120);
320
+		if (!empty($cache_results)) {
321
+					cache_put_data($key, $messages, 120);
322
+		}
314 323
 	}
315 324
 
316 325
 	// Nothing here... Or at least, nothing you can see...
@@ -397,8 +406,9 @@  discard block
 block discarded – undo
397 406
 			'css_class' => 'windowbg',
398 407
 		);
399 408
 
400
-		if ($user_info['id'] == $row['id_first_member'])
401
-			$board_ids['own'][$row['id_board']][] = $row['id_msg'];
409
+		if ($user_info['id'] == $row['id_first_member']) {
410
+					$board_ids['own'][$row['id_board']][] = $row['id_msg'];
411
+		}
402 412
 		$board_ids['any'][$row['id_board']][] = $row['id_msg'];
403 413
 	}
404 414
 	$smcFunc['db_free_result']($request);
@@ -424,20 +434,23 @@  discard block
 block discarded – undo
424 434
 			$boards = boardsAllowedTo($permission);
425 435
 
426 436
 			// If 0 is the only thing in the array, they can do it everywhere!
427
-			if (!empty($boards) && $boards[0] == 0)
428
-				$boards = array_keys($board_ids[$type]);
437
+			if (!empty($boards) && $boards[0] == 0) {
438
+							$boards = array_keys($board_ids[$type]);
439
+			}
429 440
 
430 441
 			// Go through the boards, and look for posts they can do this on.
431 442
 			foreach ($boards as $board_id)
432 443
 			{
433 444
 				// Hmm, they have permission, but there are no topics from that board on this page.
434
-				if (!isset($board_ids[$type][$board_id]))
435
-					continue;
445
+				if (!isset($board_ids[$type][$board_id])) {
446
+									continue;
447
+				}
436 448
 
437 449
 				// Okay, looks like they can do it for these posts.
438
-				foreach ($board_ids[$type][$board_id] as $counter)
439
-					if ($type == 'any' || $context['posts'][$counter]['poster']['id'] == $user_info['id'])
450
+				foreach ($board_ids[$type][$board_id] as $counter) {
451
+									if ($type == 'any' || $context['posts'][$counter]['poster']['id'] == $user_info['id'])
440 452
 						$context['posts'][$counter][$allowed] = true;
453
+				}
441 454
 			}
442 455
 		}
443 456
 	}
@@ -480,17 +493,19 @@  discard block
 block discarded – undo
480 493
 	$context['showing_all_topics'] = isset($_GET['all']);
481 494
 	$context['start'] = (int) $_REQUEST['start'];
482 495
 	$context['topics_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics'];
483
-	if ($_REQUEST['action'] == 'unread')
484
-		$context['page_title'] = $context['showing_all_topics'] ? $txt['unread_topics_all'] : $txt['unread_topics_visit'];
485
-	else
486
-		$context['page_title'] = $txt['unread_replies'];
496
+	if ($_REQUEST['action'] == 'unread') {
497
+			$context['page_title'] = $context['showing_all_topics'] ? $txt['unread_topics_all'] : $txt['unread_topics_visit'];
498
+	} else {
499
+			$context['page_title'] = $txt['unread_replies'];
500
+	}
487 501
 
488
-	if ($context['showing_all_topics'] && !empty($context['load_average']) && !empty($modSettings['loadavg_allunread']) && $context['load_average'] >= $modSettings['loadavg_allunread'])
489
-		fatal_lang_error('loadavg_allunread_disabled', false);
490
-	elseif ($_REQUEST['action'] != 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unreadreplies']) && $context['load_average'] >= $modSettings['loadavg_unreadreplies'])
491
-		fatal_lang_error('loadavg_unreadreplies_disabled', false);
492
-	elseif (!$context['showing_all_topics'] && $_REQUEST['action'] == 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unread']) && $context['load_average'] >= $modSettings['loadavg_unread'])
493
-		fatal_lang_error('loadavg_unread_disabled', false);
502
+	if ($context['showing_all_topics'] && !empty($context['load_average']) && !empty($modSettings['loadavg_allunread']) && $context['load_average'] >= $modSettings['loadavg_allunread']) {
503
+			fatal_lang_error('loadavg_allunread_disabled', false);
504
+	} elseif ($_REQUEST['action'] != 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unreadreplies']) && $context['load_average'] >= $modSettings['loadavg_unreadreplies']) {
505
+			fatal_lang_error('loadavg_unreadreplies_disabled', false);
506
+	} elseif (!$context['showing_all_topics'] && $_REQUEST['action'] == 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unread']) && $context['load_average'] >= $modSettings['loadavg_unread']) {
507
+			fatal_lang_error('loadavg_unread_disabled', false);
508
+	}
494 509
 
495 510
 	// Parameters for the main query.
496 511
 	$query_parameters = array();
@@ -503,12 +518,14 @@  discard block
 block discarded – undo
503 518
 		if (!empty($_REQUEST['boards']))
504 519
 		{
505 520
 			$_REQUEST['boards'] = explode(',', $_REQUEST['boards']);
506
-			foreach ($_REQUEST['boards'] as $b)
507
-				$boards[] = (int) $b;
521
+			foreach ($_REQUEST['boards'] as $b) {
522
+							$boards[] = (int) $b;
523
+			}
508 524
 		}
509 525
 
510
-		if (!empty($board))
511
-			$boards[] = (int) $board;
526
+		if (!empty($board)) {
527
+					$boards[] = (int) $board;
528
+		}
512 529
 
513 530
 		// The easiest thing is to just get all the boards they can see, but since we've specified the top of tree we ignore some of them
514 531
 		$request = $smcFunc['db_query']('', '
@@ -525,30 +542,31 @@  discard block
 block discarded – undo
525 542
 			)
526 543
 		);
527 544
 
528
-		while ($row = $smcFunc['db_fetch_assoc']($request))
529
-			if (in_array($row['id_parent'], $boards))
545
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
546
+					if (in_array($row['id_parent'], $boards))
530 547
 				$boards[] = $row['id_board'];
548
+		}
531 549
 
532 550
 		$smcFunc['db_free_result']($request);
533 551
 
534
-		if (empty($boards))
535
-			fatal_lang_error('error_no_boards_selected');
552
+		if (empty($boards)) {
553
+					fatal_lang_error('error_no_boards_selected');
554
+		}
536 555
 
537 556
 		$query_this_board = 'id_board IN ({array_int:boards})';
538 557
 		$query_parameters['boards'] = $boards;
539 558
 		$context['querystring_board_limits'] = ';boards=' . implode(',', $boards) . ';start=%d';
540
-	}
541
-	elseif (!empty($board))
559
+	} elseif (!empty($board))
542 560
 	{
543 561
 		$query_this_board = 'id_board = {int:board}';
544 562
 		$query_parameters['board'] = $board;
545 563
 		$context['querystring_board_limits'] = ';board=' . $board . '.%1$d';
546
-	}
547
-	elseif (!empty($_REQUEST['boards']))
564
+	} elseif (!empty($_REQUEST['boards']))
548 565
 	{
549 566
 		$_REQUEST['boards'] = explode(',', $_REQUEST['boards']);
550
-		foreach ($_REQUEST['boards'] as $i => $b)
551
-			$_REQUEST['boards'][$i] = (int) $b;
567
+		foreach ($_REQUEST['boards'] as $i => $b) {
568
+					$_REQUEST['boards'][$i] = (int) $b;
569
+		}
552 570
 
553 571
 		$request = $smcFunc['db_query']('', '
554 572
 			SELECT b.id_board
@@ -560,22 +578,24 @@  discard block
 block discarded – undo
560 578
 			)
561 579
 		);
562 580
 		$boards = array();
563
-		while ($row = $smcFunc['db_fetch_assoc']($request))
564
-			$boards[] = $row['id_board'];
581
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
582
+					$boards[] = $row['id_board'];
583
+		}
565 584
 		$smcFunc['db_free_result']($request);
566 585
 
567
-		if (empty($boards))
568
-			fatal_lang_error('error_no_boards_selected');
586
+		if (empty($boards)) {
587
+					fatal_lang_error('error_no_boards_selected');
588
+		}
569 589
 
570 590
 		$query_this_board = 'id_board IN ({array_int:boards})';
571 591
 		$query_parameters['boards'] = $boards;
572 592
 		$context['querystring_board_limits'] = ';boards=' . implode(',', $boards) . ';start=%1$d';
573
-	}
574
-	elseif (!empty($_REQUEST['c']))
593
+	} elseif (!empty($_REQUEST['c']))
575 594
 	{
576 595
 		$_REQUEST['c'] = explode(',', $_REQUEST['c']);
577
-		foreach ($_REQUEST['c'] as $i => $c)
578
-			$_REQUEST['c'][$i] = (int) $c;
596
+		foreach ($_REQUEST['c'] as $i => $c) {
597
+					$_REQUEST['c'][$i] = (int) $c;
598
+		}
579 599
 
580 600
 		$see_board = isset($_REQUEST['action']) && $_REQUEST['action'] == 'unreadreplies' ? 'query_see_board' : 'query_wanna_see_board';
581 601
 		$request = $smcFunc['db_query']('', '
@@ -588,18 +608,19 @@  discard block
 block discarded – undo
588 608
 			)
589 609
 		);
590 610
 		$boards = array();
591
-		while ($row = $smcFunc['db_fetch_assoc']($request))
592
-			$boards[] = $row['id_board'];
611
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
612
+					$boards[] = $row['id_board'];
613
+		}
593 614
 		$smcFunc['db_free_result']($request);
594 615
 
595
-		if (empty($boards))
596
-			fatal_lang_error('error_no_boards_selected');
616
+		if (empty($boards)) {
617
+					fatal_lang_error('error_no_boards_selected');
618
+		}
597 619
 
598 620
 		$query_this_board = 'id_board IN ({array_int:boards})';
599 621
 		$query_parameters['boards'] = $boards;
600 622
 		$context['querystring_board_limits'] = ';c=' . implode(',', $_REQUEST['c']) . ';start=%1$d';
601
-	}
602
-	else
623
+	} else
603 624
 	{
604 625
 		$see_board = isset($_REQUEST['action']) && $_REQUEST['action'] == 'unreadreplies' ? 'query_see_board' : 'query_wanna_see_board';
605 626
 		// Don't bother to show deleted posts!
@@ -613,12 +634,14 @@  discard block
 block discarded – undo
613 634
 			)
614 635
 		);
615 636
 		$boards = array();
616
-		while ($row = $smcFunc['db_fetch_assoc']($request))
617
-			$boards[] = $row['id_board'];
637
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
638
+					$boards[] = $row['id_board'];
639
+		}
618 640
 		$smcFunc['db_free_result']($request);
619 641
 
620
-		if (empty($boards))
621
-			fatal_lang_error('error_no_boards_available', false);
642
+		if (empty($boards)) {
643
+					fatal_lang_error('error_no_boards_available', false);
644
+		}
622 645
 
623 646
 		$query_this_board = 'id_board IN ({array_int:boards})';
624 647
 		$query_parameters['boards'] = $boards;
@@ -680,13 +703,14 @@  discard block
 block discarded – undo
680 703
 		'name' => $_REQUEST['action'] == 'unread' ? $txt['unread_topics_visit'] : $txt['unread_replies']
681 704
 	);
682 705
 
683
-	if ($context['showing_all_topics'])
684
-		$context['linktree'][] = array(
706
+	if ($context['showing_all_topics']) {
707
+			$context['linktree'][] = array(
685 708
 			'url' => $scripturl . '?action=' . $_REQUEST['action'] . ';all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'],
686 709
 			'name' => $txt['unread_topics_all']
687 710
 		);
688
-	else
689
-		$txt['unread_topics_visit_none'] = strtr($txt['unread_topics_visit_none'], array('?action=unread;all' => '?action=unread;all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits']));
711
+	} else {
712
+			$txt['unread_topics_visit_none'] = strtr($txt['unread_topics_visit_none'], array('?action=unread;all' => '?action=unread;all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits']));
713
+	}
690 714
 
691 715
 	loadTemplate('Recent');
692 716
 	loadTemplate('MessageIndex');
@@ -694,8 +718,9 @@  discard block
 block discarded – undo
694 718
 
695 719
 	// Setup the default topic icons... for checking they exist and the like ;)
696 720
 	$context['icon_sources'] = array();
697
-	foreach ($context['stable_icons'] as $icon)
698
-		$context['icon_sources'][$icon] = 'images_url';
721
+	foreach ($context['stable_icons'] as $icon) {
722
+			$context['icon_sources'][$icon] = 'images_url';
723
+	}
699 724
 
700 725
 	$is_topics = $_REQUEST['action'] == 'unread';
701 726
 
@@ -725,8 +750,7 @@  discard block
 block discarded – undo
725 750
 			);
726 751
 			list ($earliest_msg) = $smcFunc['db_fetch_row']($request);
727 752
 			$smcFunc['db_free_result']($request);
728
-		}
729
-		else
753
+		} else
730 754
 		{
731 755
 			$request = $smcFunc['db_query']('', '
732 756
 				SELECT MIN(lmr.id_msg)
@@ -742,14 +766,14 @@  discard block
 block discarded – undo
742 766
 		}
743 767
 
744 768
 		// This is needed in case of topics marked unread.
745
-		if (empty($earliest_msg))
746
-			$earliest_msg = 0;
747
-		else
769
+		if (empty($earliest_msg)) {
770
+					$earliest_msg = 0;
771
+		} else
748 772
 		{
749 773
 			// Using caching, when possible, to ignore the below slow query.
750
-			if (isset($_SESSION['cached_log_time']) && $_SESSION['cached_log_time'][0] + 45 > time())
751
-				$earliest_msg2 = $_SESSION['cached_log_time'][1];
752
-			else
774
+			if (isset($_SESSION['cached_log_time']) && $_SESSION['cached_log_time'][0] + 45 > time()) {
775
+							$earliest_msg2 = $_SESSION['cached_log_time'][1];
776
+			} else
753 777
 			{
754 778
 				// This query is pretty slow, but it's needed to ensure nothing crucial is ignored.
755 779
 				$request = $smcFunc['db_query']('', '
@@ -764,8 +788,9 @@  discard block
 block discarded – undo
764 788
 				$smcFunc['db_free_result']($request);
765 789
 
766 790
 				// In theory this could be zero, if the first ever post is unread, so fudge it ;)
767
-				if ($earliest_msg2 == 0)
768
-					$earliest_msg2 = -1;
791
+				if ($earliest_msg2 == 0) {
792
+									$earliest_msg2 = -1;
793
+				}
769 794
 
770 795
 				$_SESSION['cached_log_time'] = array(time(), $earliest_msg2);
771 796
 			}
@@ -803,9 +828,9 @@  discard block
 block discarded – undo
803 828
 				'db_error_skip' => true,
804 829
 			))
805 830
 		) !== false;
831
+	} else {
832
+			$have_temp_table = false;
806 833
 	}
807
-	else
808
-		$have_temp_table = false;
809 834
 
810 835
 	if ($context['showing_all_topics'] && $have_temp_table)
811 836
 	{
@@ -851,14 +876,15 @@  discard block
 block discarded – undo
851 876
 
852 877
 			$context['topics'] = array();
853 878
 			$context['no_topic_listing'] = true;
854
-			if ($context['querystring_board_limits'] == ';start=%1$d')
855
-				$context['querystring_board_limits'] = '';
856
-			else
857
-				$context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']);
879
+			if ($context['querystring_board_limits'] == ';start=%1$d') {
880
+							$context['querystring_board_limits'] = '';
881
+			} else {
882
+							$context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']);
883
+			}
858 884
 			return;
885
+		} else {
886
+					$min_message = (int) $min_message;
859 887
 		}
860
-		else
861
-			$min_message = (int) $min_message;
862 888
 
863 889
 		$request = $smcFunc['db_query']('substring', '
864 890
 			SELECT ' . $select_clause . '
@@ -887,8 +913,7 @@  discard block
 block discarded – undo
887 913
 				'limit' => $context['topics_per_page'],
888 914
 			))
889 915
 		);
890
-	}
891
-	elseif ($is_topics)
916
+	} elseif ($is_topics)
892 917
 	{
893 918
 		$request = $smcFunc['db_query']('', '
894 919
 			SELECT COUNT(*), MIN(t.id_last_msg)
@@ -939,14 +964,15 @@  discard block
 block discarded – undo
939 964
 
940 965
 			$context['topics'] = array();
941 966
 			$context['no_topic_listing'] = true;
942
-			if ($context['querystring_board_limits'] == ';start=%d')
943
-				$context['querystring_board_limits'] = '';
944
-			else
945
-				$context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']);
967
+			if ($context['querystring_board_limits'] == ';start=%d') {
968
+							$context['querystring_board_limits'] = '';
969
+			} else {
970
+							$context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']);
971
+			}
946 972
 			return;
973
+		} else {
974
+					$min_message = (int) $min_message;
947 975
 		}
948
-		else
949
-			$min_message = (int) $min_message;
950 976
 
951 977
 		$request = $smcFunc['db_query']('substring', '
952 978
 			SELECT ' . $select_clause . '
@@ -976,8 +1002,7 @@  discard block
 block discarded – undo
976 1002
 				'limit' => $context['topics_per_page'],
977 1003
 			))
978 1004
 		);
979
-	}
980
-	else
1005
+	} else
981 1006
 	{
982 1007
 		if ($modSettings['totalMessages'] > 100000)
983 1008
 		{
@@ -1029,8 +1054,8 @@  discard block
 block discarded – undo
1029 1054
 			) !== false;
1030 1055
 
1031 1056
 			// If that worked, create a sample of the log_topics table too.
1032
-			if ($have_temp_table)
1033
-				$have_temp_table = $smcFunc['db_query']('', '
1057
+			if ($have_temp_table) {
1058
+							$have_temp_table = $smcFunc['db_query']('', '
1034 1059
 					CREATE TEMPORARY TABLE {db_prefix}log_topics_posted_in (
1035 1060
 						PRIMARY KEY (id_topic)
1036 1061
 					)
@@ -1043,6 +1068,7 @@  discard block
 block discarded – undo
1043 1068
 						'db_error_skip' => true,
1044 1069
 					)
1045 1070
 				) !== false;
1071
+			}
1046 1072
 		}
1047 1073
 
1048 1074
 		if (!empty($have_temp_table))
@@ -1058,8 +1084,7 @@  discard block
 block discarded – undo
1058 1084
 			);
1059 1085
 			list ($num_topics) = $smcFunc['db_fetch_row']($request);
1060 1086
 			$smcFunc['db_free_result']($request);
1061
-		}
1062
-		else
1087
+		} else
1063 1088
 		{
1064 1089
 			$request = $smcFunc['db_query']('unread_fetch_topic_count', '
1065 1090
 				SELECT COUNT(DISTINCT t.id_topic), MIN(t.id_last_msg)
@@ -1100,15 +1125,16 @@  discard block
 block discarded – undo
1100 1125
 		{
1101 1126
 			$context['topics'] = array();
1102 1127
 			$context['no_topic_listing'] = true;
1103
-			if ($context['querystring_board_limits'] == ';start=%d')
1104
-				$context['querystring_board_limits'] = '';
1105
-			else
1106
-				$context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']);
1128
+			if ($context['querystring_board_limits'] == ';start=%d') {
1129
+							$context['querystring_board_limits'] = '';
1130
+			} else {
1131
+							$context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']);
1132
+			}
1107 1133
 			return;
1108 1134
 		}
1109 1135
 
1110
-		if (!empty($have_temp_table))
1111
-			$request = $smcFunc['db_query']('', '
1136
+		if (!empty($have_temp_table)) {
1137
+					$request = $smcFunc['db_query']('', '
1112 1138
 				SELECT t.id_topic
1113 1139
 				FROM {db_prefix}topics_posted_in AS t
1114 1140
 					LEFT JOIN {db_prefix}log_topics_posted_in AS lt ON (lt.id_topic = t.id_topic)
@@ -1122,8 +1148,8 @@  discard block
 block discarded – undo
1122 1148
 					'limit' => $context['topics_per_page'],
1123 1149
 				))
1124 1150
 			);
1125
-		else
1126
-			$request = $smcFunc['db_query']('', '
1151
+		} else {
1152
+					$request = $smcFunc['db_query']('', '
1127 1153
 				SELECT DISTINCT t.id_topic,'.$_REQUEST['sort'].'
1128 1154
 				FROM {db_prefix}topics AS t
1129 1155
 					INNER JOIN {db_prefix}messages AS m ON (m.id_topic = t.id_topic AND m.id_member = {int:current_member})' . (strpos($_REQUEST['sort'], 'ms.') === false ? '' : '
@@ -1147,10 +1173,12 @@  discard block
 block discarded – undo
1147 1173
 					'sort' => $_REQUEST['sort'],
1148 1174
 				))
1149 1175
 			);
1176
+		}
1150 1177
 
1151 1178
 		$topics = array();
1152
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1153
-			$topics[] = $row['id_topic'];
1179
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1180
+					$topics[] = $row['id_topic'];
1181
+		}
1154 1182
 		$smcFunc['db_free_result']($request);
1155 1183
 
1156 1184
 		// Sanity... where have you gone?
@@ -1158,10 +1186,11 @@  discard block
 block discarded – undo
1158 1186
 		{
1159 1187
 			$context['topics'] = array();
1160 1188
 			$context['no_topic_listing'] = true;
1161
-			if ($context['querystring_board_limits'] == ';start=%d')
1162
-				$context['querystring_board_limits'] = '';
1163
-			else
1164
-				$context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']);
1189
+			if ($context['querystring_board_limits'] == ';start=%d') {
1190
+							$context['querystring_board_limits'] = '';
1191
+			} else {
1192
+							$context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']);
1193
+			}
1165 1194
 			return;
1166 1195
 		}
1167 1196
 
@@ -1195,8 +1224,9 @@  discard block
 block discarded – undo
1195 1224
 
1196 1225
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1197 1226
 	{
1198
-		if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0')
1199
-			continue;
1227
+		if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') {
1228
+					continue;
1229
+		}
1200 1230
 
1201 1231
 		$topic_ids[] = $row['id_topic'];
1202 1232
 
@@ -1204,11 +1234,13 @@  discard block
 block discarded – undo
1204 1234
 		{
1205 1235
 			// Limit them to 128 characters - do this FIRST because it's a lot of wasted censoring otherwise.
1206 1236
 			$row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br>' => '&#10;')));
1207
-			if ($smcFunc['strlen']($row['first_body']) > 128)
1208
-				$row['first_body'] = $smcFunc['substr']($row['first_body'], 0, 128) . '...';
1237
+			if ($smcFunc['strlen']($row['first_body']) > 128) {
1238
+							$row['first_body'] = $smcFunc['substr']($row['first_body'], 0, 128) . '...';
1239
+			}
1209 1240
 			$row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => '&#10;')));
1210
-			if ($smcFunc['strlen']($row['last_body']) > 128)
1211
-				$row['last_body'] = $smcFunc['substr']($row['last_body'], 0, 128) . '...';
1241
+			if ($smcFunc['strlen']($row['last_body']) > 128) {
1242
+							$row['last_body'] = $smcFunc['substr']($row['last_body'], 0, 128) . '...';
1243
+			}
1212 1244
 
1213 1245
 			// Censor the subject and message preview.
1214 1246
 			censorText($row['first_subject']);
@@ -1219,23 +1251,22 @@  discard block
 block discarded – undo
1219 1251
 			{
1220 1252
 				$row['last_subject'] = $row['first_subject'];
1221 1253
 				$row['last_body'] = $row['first_body'];
1222
-			}
1223
-			else
1254
+			} else
1224 1255
 			{
1225 1256
 				censorText($row['last_subject']);
1226 1257
 				censorText($row['last_body']);
1227 1258
 			}
1228
-		}
1229
-		else
1259
+		} else
1230 1260
 		{
1231 1261
 			$row['first_body'] = '';
1232 1262
 			$row['last_body'] = '';
1233 1263
 			censorText($row['first_subject']);
1234 1264
 
1235
-			if ($row['id_first_msg'] == $row['id_last_msg'])
1236
-				$row['last_subject'] = $row['first_subject'];
1237
-			else
1238
-				censorText($row['last_subject']);
1265
+			if ($row['id_first_msg'] == $row['id_last_msg']) {
1266
+							$row['last_subject'] = $row['first_subject'];
1267
+			} else {
1268
+							censorText($row['last_subject']);
1269
+			}
1239 1270
 		}
1240 1271
 
1241 1272
 		// Decide how many pages the topic should have.
@@ -1247,22 +1278,24 @@  discard block
 block discarded – undo
1247 1278
 			$pages = constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $topic_length, $messages_per_page, true, false);
1248 1279
 
1249 1280
 			// If we can use all, show all.
1250
-			if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages'])
1251
-				$pages .= ' &nbsp;<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>';
1281
+			if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages']) {
1282
+							$pages .= ' &nbsp;<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>';
1283
+			}
1284
+		} else {
1285
+					$pages = '';
1252 1286
 		}
1253 1287
 
1254
-		else
1255
-			$pages = '';
1256
-
1257 1288
 		// We need to check the topic icons exist... you can never be too sure!
1258 1289
 		if (!empty($modSettings['messageIconChecks_enable']))
1259 1290
 		{
1260 1291
 			// First icon first... as you'd expect.
1261
-			if (!isset($context['icon_sources'][$row['first_icon']]))
1262
-				$context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url';
1292
+			if (!isset($context['icon_sources'][$row['first_icon']])) {
1293
+							$context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url';
1294
+			}
1263 1295
 			// Last icon... last... duh.
1264
-			if (!isset($context['icon_sources'][$row['last_icon']]))
1265
-				$context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url';
1296
+			if (!isset($context['icon_sources'][$row['last_icon']])) {
1297
+							$context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url';
1298
+			}
1266 1299
 		}
1267 1300
 
1268 1301
 		// Force the recycling icon if appropriate
@@ -1276,12 +1309,14 @@  discard block
 block discarded – undo
1276 1309
 		$colorClass = 'windowbg';
1277 1310
 
1278 1311
 		// Sticky topics should get a different color, too.
1279
-		if ($row['is_sticky'])
1280
-			$colorClass .= ' sticky';
1312
+		if ($row['is_sticky']) {
1313
+					$colorClass .= ' sticky';
1314
+		}
1281 1315
 
1282 1316
 		// Locked topics get special treatment as well.
1283
-		if ($row['locked'])
1284
-			$colorClass .= ' locked';
1317
+		if ($row['locked']) {
1318
+					$colorClass .= ' locked';
1319
+		}
1285 1320
 
1286 1321
 		// And build the array.
1287 1322
 		$context['topics'][$row['id_topic']] = array(
@@ -1378,8 +1413,9 @@  discard block
 block discarded – undo
1378 1413
 		);
1379 1414
 		while ($row = $smcFunc['db_fetch_assoc']($result))
1380 1415
 		{
1381
-			if (empty($context['topics'][$row['id_topic']]['is_posted_in']))
1382
-				$context['topics'][$row['id_topic']]['is_posted_in'] = true;
1416
+			if (empty($context['topics'][$row['id_topic']]['is_posted_in'])) {
1417
+							$context['topics'][$row['id_topic']]['is_posted_in'] = true;
1418
+			}
1383 1419
 		}
1384 1420
 		$smcFunc['db_free_result']($result);
1385 1421
 	}
@@ -1394,28 +1430,30 @@  discard block
 block discarded – undo
1394 1430
 			'markread' => array('text' => !empty($context['no_board_limits']) ? 'mark_as_read' : 'mark_read_short', 'image' => 'markread.png', 'custom' => 'data-confirm="'.  $txt['are_sure_mark_read'] .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=' . (!empty($context['no_board_limits']) ? 'all' : 'board' . $context['querystring_board_limits']) . ';' . $context['session_var'] . '=' . $context['session_id']),
1395 1431
 		);
1396 1432
 
1397
-		if ($context['showCheckboxes'])
1398
-			$context['recent_buttons']['markselectread'] = array(
1433
+		if ($context['showCheckboxes']) {
1434
+					$context['recent_buttons']['markselectread'] = array(
1399 1435
 				'text' => 'quick_mod_markread',
1400 1436
 				'image' => 'markselectedread.png',
1401 1437
 				'url' => 'javascript:document.quickModForm.submit();',
1402 1438
 			);
1439
+		}
1403 1440
 
1404
-		if (!empty($context['topics']) && !$context['showing_all_topics'])
1405
-			$context['recent_buttons']['readall'] = array('text' => 'unread_topics_all', 'image' => 'markreadall.png', 'url' => $scripturl . '?action=unread;all' . $context['querystring_board_limits'], 'active' => true);
1406
-	}
1407
-	elseif (!$is_topics && isset($context['topics_to_mark']))
1441
+		if (!empty($context['topics']) && !$context['showing_all_topics']) {
1442
+					$context['recent_buttons']['readall'] = array('text' => 'unread_topics_all', 'image' => 'markreadall.png', 'url' => $scripturl . '?action=unread;all' . $context['querystring_board_limits'], 'active' => true);
1443
+		}
1444
+	} elseif (!$is_topics && isset($context['topics_to_mark']))
1408 1445
 	{
1409 1446
 		$context['recent_buttons'] = array(
1410 1447
 			'markread' => array('text' => 'mark_as_read', 'image' => 'markread.png', 'custom' => 'data-confirm="'. $txt['are_sure_mark_read']  .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=unreadreplies;topics=' . $context['topics_to_mark'] . ';' . $context['session_var'] . '=' . $context['session_id']),
1411 1448
 		);
1412 1449
 
1413
-		if ($context['showCheckboxes'])
1414
-			$context['recent_buttons']['markselectread'] = array(
1450
+		if ($context['showCheckboxes']) {
1451
+					$context['recent_buttons']['markselectread'] = array(
1415 1452
 				'text' => 'quick_mod_markread',
1416 1453
 				'image' => 'markselectedread.png',
1417 1454
 				'url' => 'javascript:document.quickModForm.submit();',
1418 1455
 			);
1456
+		}
1419 1457
 	}
1420 1458
 
1421 1459
 	// Allow mods to add additional buttons here
Please login to merge, or discard this patch.
Sources/Modlog.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 					'class' => 'centercol',
257 257
 				),
258 258
 				'data' => array(
259
-					'function' => function ($entry)
259
+					'function' => function($entry)
260 260
 					{
261 261
 						return '<input type="checkbox" class="input_check" name="delete[]" value="' . $entry['id'] . '"' . ($entry['editable'] ? '' : ' disabled') . '>';
262 262
 					},
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
 		if (empty($entries[$k]['action_text']))
639 639
 			$entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action'];
640 640
 		$entries[$k]['action_text'] = preg_replace_callback('~\{([A-Za-z\d_]+)\}~i',
641
-			function ($matches) use ($entries, $k)
641
+			function($matches) use ($entries, $k)
642 642
 			{
643 643
 				return isset($entries[$k]['extra'][$matches[1]]) ? $entries[$k]['extra'][$matches[1]] : '';
644 644
 			}, $entries[$k]['action_text']);
Please login to merge, or discard this patch.
Braces   +97 added lines, -73 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 3
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * Prepares the information from the moderation log for viewing.
@@ -32,14 +33,16 @@  discard block
 block discarded – undo
32 33
 
33 34
 	// Are we looking at the moderation log or the administration log.
34 35
 	$context['log_type'] = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 3 : 1;
35
-	if ($context['log_type'] == 3)
36
-		isAllowedTo('admin_forum');
36
+	if ($context['log_type'] == 3) {
37
+			isAllowedTo('admin_forum');
38
+	}
37 39
 
38 40
 	// These change dependant on whether we are viewing the moderation or admin log.
39
-	if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin')
40
-		$context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type'];
41
-	else
42
-		$context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type'];
41
+	if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin') {
42
+			$context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type'];
43
+	} else {
44
+			$context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type'];
45
+	}
43 46
 
44 47
 	$context['can_delete'] = allowedTo('admin_forum');
45 48
 
@@ -67,8 +70,7 @@  discard block
 block discarded – undo
67 70
 		$log_type = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 'admin' : 'moderate';
68 71
 		logAction('clearlog_' . $log_type, array(), $log_type);
69 72
 
70
-	}
71
-	elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete'])
73
+	} elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete'])
72 74
 	{
73 75
 		checkSession();
74 76
 		validateToken('mod-ml');
@@ -114,15 +116,17 @@  discard block
 block discarded – undo
114 116
 		'ip' => array('sql' => 'lm.ip', 'label' => $txt['modlog_ip'])
115 117
 	);
116 118
 
117
-	if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search']))
118
-		$search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search'];
119
-	else
120
-		$search_params_string = $search_params['string'];
119
+	if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) {
120
+			$search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search'];
121
+	} else {
122
+			$search_params_string = $search_params['string'];
123
+	}
121 124
 
122
-	if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']]))
123
-		$search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member');
124
-	else
125
-		$search_params_type = $search_params['type'];
125
+	if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) {
126
+			$search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member');
127
+	} else {
128
+			$search_params_type = $search_params['type'];
129
+	}
126 130
 
127 131
 	$search_params_column = $searchTypes[$search_params_type]['sql'];
128 132
 	$search_params = array(
@@ -297,13 +301,14 @@  discard block
 block discarded – undo
297 301
 	$context['sub_template'] = 'show_list';
298 302
 	$context['default_list'] = 'moderation_log_list';
299 303
 
300
-	if (isset($context['moderation_menu_name']))
301
-		$context[$context['moderation_menu_name']]['tab_data'] = array(
304
+	if (isset($context['moderation_menu_name'])) {
305
+			$context[$context['moderation_menu_name']]['tab_data'] = array(
302 306
 			'title' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log'],
303 307
 			'help' => $context['log_type'] == 3 ? 'adminlog' : 'modlog',
304 308
 			'description' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log_desc']
305 309
 		);
306
-}
310
+	}
311
+	}
307 312
 
308 313
 /**
309 314
  * Get the number of mod log entries.
@@ -407,30 +412,35 @@  discard block
 block discarded – undo
407 412
 		// Add on some of the column stuff info
408 413
 		if (!empty($row['id_board']))
409 414
 		{
410
-			if ($row['action'] == 'move')
411
-				$row['extra']['board_to'] = $row['id_board'];
412
-			else
413
-				$row['extra']['board'] = $row['id_board'];
415
+			if ($row['action'] == 'move') {
416
+							$row['extra']['board_to'] = $row['id_board'];
417
+			} else {
418
+							$row['extra']['board'] = $row['id_board'];
419
+			}
414 420
 		}
415 421
 
416
-		if (!empty($row['id_topic']))
417
-			$row['extra']['topic'] = $row['id_topic'];
418
-		if (!empty($row['id_msg']))
419
-			$row['extra']['message'] = $row['id_msg'];
422
+		if (!empty($row['id_topic'])) {
423
+					$row['extra']['topic'] = $row['id_topic'];
424
+		}
425
+		if (!empty($row['id_msg'])) {
426
+					$row['extra']['message'] = $row['id_msg'];
427
+		}
420 428
 
421 429
 		// Is this associated with a topic?
422
-		if (isset($row['extra']['topic']))
423
-			$topics[(int) $row['extra']['topic']][] = $row['id_action'];
424
-		if (isset($row['extra']['new_topic']))
425
-			$topics[(int) $row['extra']['new_topic']][] = $row['id_action'];
430
+		if (isset($row['extra']['topic'])) {
431
+					$topics[(int) $row['extra']['topic']][] = $row['id_action'];
432
+		}
433
+		if (isset($row['extra']['new_topic'])) {
434
+					$topics[(int) $row['extra']['new_topic']][] = $row['id_action'];
435
+		}
426 436
 
427 437
 		// How about a member?
428 438
 		if (isset($row['extra']['member']))
429 439
 		{
430 440
 			// Guests don't have names!
431
-			if (empty($row['extra']['member']))
432
-				$row['extra']['member'] = $txt['modlog_parameter_guest'];
433
-			else
441
+			if (empty($row['extra']['member'])) {
442
+							$row['extra']['member'] = $txt['modlog_parameter_guest'];
443
+			} else
434 444
 			{
435 445
 				// Try to find it...
436 446
 				$members[(int) $row['extra']['member']][] = $row['id_action'];
@@ -438,35 +448,42 @@  discard block
 block discarded – undo
438 448
 		}
439 449
 
440 450
 		// Associated with a board?
441
-		if (isset($row['extra']['board_to']))
442
-			$boards[(int) $row['extra']['board_to']][] = $row['id_action'];
443
-		if (isset($row['extra']['board_from']))
444
-			$boards[(int) $row['extra']['board_from']][] = $row['id_action'];
445
-		if (isset($row['extra']['board']))
446
-			$boards[(int) $row['extra']['board']][] = $row['id_action'];
451
+		if (isset($row['extra']['board_to'])) {
452
+					$boards[(int) $row['extra']['board_to']][] = $row['id_action'];
453
+		}
454
+		if (isset($row['extra']['board_from'])) {
455
+					$boards[(int) $row['extra']['board_from']][] = $row['id_action'];
456
+		}
457
+		if (isset($row['extra']['board'])) {
458
+					$boards[(int) $row['extra']['board']][] = $row['id_action'];
459
+		}
447 460
 
448 461
 		// A message?
449
-		if (isset($row['extra']['message']))
450
-			$messages[(int) $row['extra']['message']][] = $row['id_action'];
462
+		if (isset($row['extra']['message'])) {
463
+					$messages[(int) $row['extra']['message']][] = $row['id_action'];
464
+		}
451 465
 
452 466
 		// IP Info?
453
-		if (isset($row['extra']['ip_range']))
454
-			if ($seeIP)
467
+		if (isset($row['extra']['ip_range'])) {
468
+					if ($seeIP)
455 469
 				$row['extra']['ip_range'] = '<a href="' . $scripturl . '?action=trackip;searchip=' . $row['extra']['ip_range'] . '">' . $row['extra']['ip_range'] . '</a>';
456
-			else
457
-				$row['extra']['ip_range'] = $txt['logged'];
470
+		} else {
471
+							$row['extra']['ip_range'] = $txt['logged'];
472
+			}
458 473
 
459 474
 		// Email?
460
-		if (isset($row['extra']['email']))
461
-			$row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>';
475
+		if (isset($row['extra']['email'])) {
476
+					$row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>';
477
+		}
462 478
 
463 479
 		// Bans are complex.
464 480
 		if ($row['action'] == 'ban' || $row['action'] == 'banremove')
465 481
 		{
466 482
 			$row['action_text'] = $txt['modlog_ac_ban' . ($row['action'] == 'banremove' ? '_remove' : '')];
467
-			foreach (array('member', 'email', 'ip_range', 'hostname') as $type)
468
-				if (isset($row['extra'][$type]))
483
+			foreach (array('member', 'email', 'ip_range', 'hostname') as $type) {
484
+							if (isset($row['extra'][$type]))
469 485
 					$row['action_text'] .= $txt['modlog_ac_ban_trigger_' . $type];
486
+			}
470 487
 		}
471 488
 
472 489
 		// The array to go to the template. Note here that action is set to a "default" value of the action doesn't match anything in the descriptions. Allows easy adding of logging events with basic details.
@@ -502,12 +519,13 @@  discard block
 block discarded – undo
502 519
 			foreach ($boards[$row['id_board']] as $action)
503 520
 			{
504 521
 				// Make the board number into a link - dealing with moving too.
505
-				if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board'])
506
-					$entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
507
-				elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board'])
508
-					$entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
509
-				elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board'])
510
-					$entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
522
+				if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) {
523
+									$entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
524
+				} elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) {
525
+									$entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
526
+				} elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) {
527
+									$entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
528
+				}
511 529
 			}
512 530
 		}
513 531
 		$smcFunc['db_free_result']($request);
@@ -541,10 +559,11 @@  discard block
 block discarded – undo
541 559
 				);
542 560
 
543 561
 				// Make the topic number into a link - dealing with splitting too.
544
-				if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic'])
545
-					$this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>';
546
-				elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic'])
547
-					$this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>';
562
+				if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic']) {
563
+									$this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>';
564
+				} elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic']) {
565
+									$this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>';
566
+				}
548 567
 			}
549 568
 		}
550 569
 		$smcFunc['db_free_result']($request);
@@ -577,8 +596,9 @@  discard block
 block discarded – undo
577 596
 				);
578 597
 
579 598
 				// Make the message number into a link.
580
-				if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg'])
581
-					$this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>';
599
+				if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg']) {
600
+									$this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>';
601
+				}
582 602
 			}
583 603
 		}
584 604
 		$smcFunc['db_free_result']($request);
@@ -618,25 +638,29 @@  discard block
 block discarded – undo
618 638
 	foreach ($entries as $k => $entry)
619 639
 	{
620 640
 		// Make any message info links so its easier to go find that message.
621
-		if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id'])))
622
-			$entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>';
641
+		if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id']))) {
642
+					$entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>';
643
+		}
623 644
 
624 645
 		// Mark up any deleted members, topics and boards.
625
-		foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type)
626
-			if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type]))
646
+		foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type) {
647
+					if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type]))
627 648
 				$entries[$k]['extra'][$type] = sprintf($txt['modlog_id'], $entry['extra'][$type]);
649
+		}
628 650
 
629 651
 		if (isset($entry['extra']['report']))
630 652
 		{
631 653
 			// Member profile reports go in a different area
632
-			if (stristr($entry['action'], 'user_report'))
633
-				$entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>';
634
-			else
635
-				$entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>';
654
+			if (stristr($entry['action'], 'user_report')) {
655
+							$entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>';
656
+			} else {
657
+							$entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>';
658
+			}
636 659
 		}
637 660
 
638
-		if (empty($entries[$k]['action_text']))
639
-			$entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action'];
661
+		if (empty($entries[$k]['action_text'])) {
662
+					$entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action'];
663
+		}
640 664
 		$entries[$k]['action_text'] = preg_replace_callback('~\{([A-Za-z\d_]+)\}~i',
641 665
 			function ($matches) use ($entries, $k)
642 666
 			{
Please login to merge, or discard this patch.
Sources/Class-BrowserDetect.php 2 patches
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
 	}
102 102
 
103 103
 	/**
104
-	* Determine if the browser is Opera or not
105
-	* @return boolean Whether or not this is Opera
106
-	*/
104
+	 * Determine if the browser is Opera or not
105
+	 * @return boolean Whether or not this is Opera
106
+	 */
107 107
 	function isOpera()
108 108
 	{
109 109
 		if (!isset($this->_browsers['is_opera']))
@@ -112,9 +112,9 @@  discard block
 block discarded – undo
112 112
 	}
113 113
 
114 114
 	/**
115
-	* Determine if the browser is IE or not
116
-	* @return boolean true Whether or not the browser is IE
117
-	*/
115
+	 * Determine if the browser is IE or not
116
+	 * @return boolean true Whether or not the browser is IE
117
+	 */
118 118
 	function isIe()
119 119
 	{
120 120
 		// I'm IE, Yes I'm the real IE; All you other IEs are just imitating.
@@ -124,9 +124,9 @@  discard block
 block discarded – undo
124 124
 	}
125 125
 
126 126
 	/**
127
-	* Determine if the browser is IE11 or not
128
-	* @return boolean Whether or not the browser is IE11
129
-	*/
127
+	 * Determine if the browser is IE11 or not
128
+	 * @return boolean Whether or not the browser is IE11
129
+	 */
130 130
 	function isIe11()
131 131
 	{
132 132
 		// IE11 is a bit different than earlier versions
@@ -137,9 +137,9 @@  discard block
 block discarded – undo
137 137
  	}
138 138
 
139 139
 	/**
140
-	* Determine if the browser is Edge or not
141
-	* @return boolean Whether or not the browser is Edge
142
-	*/
140
+	 * Determine if the browser is Edge or not
141
+	 * @return boolean Whether or not the browser is Edge
142
+	 */
143 143
 	function isEdge()
144 144
 	{
145 145
 		if (!isset($this->_browsers['is_edge']))
@@ -148,9 +148,9 @@  discard block
 block discarded – undo
148 148
 	}
149 149
 
150 150
 	/**
151
-	* Determine if the browser is a Webkit based one or not
152
-	* @return boolean Whether or not this is a Webkit-based browser
153
-	*/
151
+	 * Determine if the browser is a Webkit based one or not
152
+	 * @return boolean Whether or not this is a Webkit-based browser
153
+	 */
154 154
 	function isWebkit()
155 155
 	{
156 156
 		if (!isset($this->_browsers['is_webkit']))
@@ -159,9 +159,9 @@  discard block
 block discarded – undo
159 159
 	}
160 160
 
161 161
 	/**
162
-	* Determine if the browser is Firefox or one of its variants
163
-	* @return boolean Whether or not this is Firefox (or one of its variants)
164
-	*/
162
+	 * Determine if the browser is Firefox or one of its variants
163
+	 * @return boolean Whether or not this is Firefox (or one of its variants)
164
+	 */
165 165
 	function isFirefox()
166 166
 	{
167 167
 		if (!isset($this->_browsers['is_firefox']))
@@ -170,9 +170,9 @@  discard block
 block discarded – undo
170 170
 	}
171 171
 
172 172
 	/**
173
-	* Determine if the browser is WebTv or not
174
-	* @return boolean Whether or not this is WebTV
175
-	*/
173
+	 * Determine if the browser is WebTv or not
174
+	 * @return boolean Whether or not this is WebTV
175
+	 */
176 176
 	function isWebTv()
177 177
 	{
178 178
 		if (!isset($this->_browsers['is_web_tv']))
@@ -181,9 +181,9 @@  discard block
 block discarded – undo
181 181
 	}
182 182
 
183 183
 	/**
184
-	* Determine if the browser is konqueror or not
185
-	* @return boolean Whether or not this is Konqueror
186
-	*/
184
+	 * Determine if the browser is konqueror or not
185
+	 * @return boolean Whether or not this is Konqueror
186
+	 */
187 187
 	function isKonqueror()
188 188
 	{
189 189
 		if (!isset($this->_browsers['is_konqueror']))
@@ -192,9 +192,9 @@  discard block
 block discarded – undo
192 192
 	}
193 193
 
194 194
 	/**
195
-	* Determine if the browser is Gecko or not
196
-	* @return boolean Whether or not this is a Gecko-based browser
197
-	*/
195
+	 * Determine if the browser is Gecko or not
196
+	 * @return boolean Whether or not this is a Gecko-based browser
197
+	 */
198 198
 	function isGecko()
199 199
 	{
200 200
 		if (!isset($this->_browsers['is_gecko']))
@@ -203,9 +203,9 @@  discard block
 block discarded – undo
203 203
 	}
204 204
 
205 205
 	/**
206
-	* Determine if the browser is Opera Mini or not
207
-	* @return boolean Whether or not this is Opera Mini
208
-	*/
206
+	 * Determine if the browser is Opera Mini or not
207
+	 * @return boolean Whether or not this is Opera Mini
208
+	 */
209 209
 	function isOperaMini()
210 210
 	{
211 211
 		if (!isset($this->_browsers['is_opera_mini']))
@@ -216,9 +216,9 @@  discard block
 block discarded – undo
216 216
 	}
217 217
 
218 218
 	/**
219
-	* Determine if the browser is Opera Mobile or not
220
-	* @return boolean Whether or not this is Opera Mobile
221
-	*/
219
+	 * Determine if the browser is Opera Mobile or not
220
+	 * @return boolean Whether or not this is Opera Mobile
221
+	 */
222 222
 	function isOperaMobi()
223 223
 	{
224 224
 		if (!isset($this->_browsers['is_opera_mobi']))
Please login to merge, or discard this patch.
Braces   +88 added lines, -60 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
  * @version 2.1 Beta 3
12 12
  */
13 13
 
14
-if (!defined('SMF'))
14
+if (!defined('SMF')) {
15 15
 	die('No direct access...');
16
+}
16 17
 
17 18
 /**
18 19
  * Class browser_detector
@@ -55,20 +56,25 @@  discard block
 block discarded – undo
55 56
 		$this->_browsers['needs_size_fix'] = false;
56 57
 
57 58
 		// One at a time, one at a time, and in this order too
58
-		if ($this->isOpera())
59
-			$this->setupOpera();
59
+		if ($this->isOpera()) {
60
+					$this->setupOpera();
61
+		}
60 62
 		// Meh...
61
-		elseif ($this->isEdge())
62
-			$this->setupEdge();
63
+		elseif ($this->isEdge()) {
64
+					$this->setupEdge();
65
+		}
63 66
 		// Them webkits need to be set up too
64
-		elseif ($this->isWebkit())
65
-			$this->setupWebkit();
67
+		elseif ($this->isWebkit()) {
68
+					$this->setupWebkit();
69
+		}
66 70
 		// We may have work to do on Firefox...
67
-		elseif ($this->isFirefox())
68
-			$this->setupFirefox();
71
+		elseif ($this->isFirefox()) {
72
+					$this->setupFirefox();
73
+		}
69 74
 		// Old friend, old frenemy
70
-		elseif ($this->isIe())
71
-			$this->setupIe();
75
+		elseif ($this->isIe()) {
76
+					$this->setupIe();
77
+		}
72 78
 
73 79
 		// Just a few mobile checks
74 80
 		$this->isOperaMini();
@@ -84,11 +90,12 @@  discard block
 block discarded – undo
84 90
 			$this->_browsers['possibly_robot'] = !empty($user_info['possibly_robot']);
85 91
 
86 92
 			// Robots shouldn't be logging in or registering.  So, they aren't a bot.  Better to be wrong than sorry (or people won't be able to log in!), anyway.
87
-			if ((isset($_REQUEST['action']) && in_array($_REQUEST['action'], array('login', 'login2', 'register', 'signup'))) || !$user_info['is_guest'])
88
-				$this->_browsers['possibly_robot'] = false;
93
+			if ((isset($_REQUEST['action']) && in_array($_REQUEST['action'], array('login', 'login2', 'register', 'signup'))) || !$user_info['is_guest']) {
94
+							$this->_browsers['possibly_robot'] = false;
95
+			}
96
+		} else {
97
+					$this->_browsers['possibly_robot'] = false;
89 98
 		}
90
-		else
91
-			$this->_browsers['possibly_robot'] = false;
92 99
 
93 100
 		// Fill out the historical array as needed to support old mods that don't use isBrowser
94 101
 		$this->fillInformation();
@@ -106,8 +113,9 @@  discard block
 block discarded – undo
106 113
 	*/
107 114
 	function isOpera()
108 115
 	{
109
-		if (!isset($this->_browsers['is_opera']))
110
-			$this->_browsers['is_opera'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false;
116
+		if (!isset($this->_browsers['is_opera'])) {
117
+					$this->_browsers['is_opera'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false;
118
+		}
111 119
 		return $this->_browsers['is_opera'];
112 120
 	}
113 121
 
@@ -118,8 +126,9 @@  discard block
 block discarded – undo
118 126
 	function isIe()
119 127
 	{
120 128
 		// I'm IE, Yes I'm the real IE; All you other IEs are just imitating.
121
-		if (!isset($this->_browsers['is_ie']))
122
-			$this->_browsers['is_ie'] = !$this->isOpera() && !$this->isGecko() && !$this->isWebTv() && preg_match('~MSIE \d+~', $_SERVER['HTTP_USER_AGENT']) === 1;
129
+		if (!isset($this->_browsers['is_ie'])) {
130
+					$this->_browsers['is_ie'] = !$this->isOpera() && !$this->isGecko() && !$this->isWebTv() && preg_match('~MSIE \d+~', $_SERVER['HTTP_USER_AGENT']) === 1;
131
+		}
123 132
 		return $this->_browsers['is_ie'];
124 133
 	}
125 134
 
@@ -131,8 +140,9 @@  discard block
 block discarded – undo
131 140
 	{
132 141
 		// IE11 is a bit different than earlier versions
133 142
 		// The isGecko() part is to ensure we get this right...
134
-		if (!isset($this->_browsers['is_ie11']))
135
-			$this->_browsers['is_ie11'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Trident') !== false && $this->isGecko();
143
+		if (!isset($this->_browsers['is_ie11'])) {
144
+					$this->_browsers['is_ie11'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Trident') !== false && $this->isGecko();
145
+		}
136 146
 		return $this->_browsers['is_ie11'];
137 147
  	}
138 148
 
@@ -142,8 +152,9 @@  discard block
 block discarded – undo
142 152
 	*/
143 153
 	function isEdge()
144 154
 	{
145
-		if (!isset($this->_browsers['is_edge']))
146
-			$this->_browsers['is_edge'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Edge') !== false;
155
+		if (!isset($this->_browsers['is_edge'])) {
156
+					$this->_browsers['is_edge'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Edge') !== false;
157
+		}
147 158
 		return $this->_browsers['is_edge'];
148 159
 	}
149 160
 
@@ -153,8 +164,9 @@  discard block
 block discarded – undo
153 164
 	*/
154 165
 	function isWebkit()
155 166
 	{
156
-		if (!isset($this->_browsers['is_webkit']))
157
-			$this->_browsers['is_webkit'] = strpos($_SERVER['HTTP_USER_AGENT'], 'AppleWebKit') !== false;
167
+		if (!isset($this->_browsers['is_webkit'])) {
168
+					$this->_browsers['is_webkit'] = strpos($_SERVER['HTTP_USER_AGENT'], 'AppleWebKit') !== false;
169
+		}
158 170
 		return $this->_browsers['is_webkit'];
159 171
 	}
160 172
 
@@ -164,8 +176,9 @@  discard block
 block discarded – undo
164 176
 	*/
165 177
 	function isFirefox()
166 178
 	{
167
-		if (!isset($this->_browsers['is_firefox']))
168
-			$this->_browsers['is_firefox'] = preg_match('~(?:Firefox|Ice[wW]easel|IceCat|Shiretoko|Minefield)/~', $_SERVER['HTTP_USER_AGENT']) === 1 && $this->isGecko();
179
+		if (!isset($this->_browsers['is_firefox'])) {
180
+					$this->_browsers['is_firefox'] = preg_match('~(?:Firefox|Ice[wW]easel|IceCat|Shiretoko|Minefield)/~', $_SERVER['HTTP_USER_AGENT']) === 1 && $this->isGecko();
181
+		}
169 182
 		return $this->_browsers['is_firefox'];
170 183
 	}
171 184
 
@@ -175,8 +188,9 @@  discard block
 block discarded – undo
175 188
 	*/
176 189
 	function isWebTv()
177 190
 	{
178
-		if (!isset($this->_browsers['is_web_tv']))
179
-			$this->_browsers['is_web_tv'] = strpos($_SERVER['HTTP_USER_AGENT'], 'WebTV') !== false;
191
+		if (!isset($this->_browsers['is_web_tv'])) {
192
+					$this->_browsers['is_web_tv'] = strpos($_SERVER['HTTP_USER_AGENT'], 'WebTV') !== false;
193
+		}
180 194
 		return $this->_browsers['is_web_tv'];
181 195
 	}
182 196
 
@@ -186,8 +200,9 @@  discard block
 block discarded – undo
186 200
 	*/
187 201
 	function isKonqueror()
188 202
 	{
189
-		if (!isset($this->_browsers['is_konqueror']))
190
-			$this->_browsers['is_konqueror'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Konqueror') !== false;
203
+		if (!isset($this->_browsers['is_konqueror'])) {
204
+					$this->_browsers['is_konqueror'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Konqueror') !== false;
205
+		}
191 206
 		return $this->_browsers['is_konqueror'];
192 207
 	}
193 208
 
@@ -197,8 +212,9 @@  discard block
 block discarded – undo
197 212
 	*/
198 213
 	function isGecko()
199 214
 	{
200
-		if (!isset($this->_browsers['is_gecko']))
201
-			$this->_browsers['is_gecko'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false && !$this->isWebkit() && !$this->isKonqueror();
215
+		if (!isset($this->_browsers['is_gecko'])) {
216
+					$this->_browsers['is_gecko'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false && !$this->isWebkit() && !$this->isKonqueror();
217
+		}
202 218
 		return $this->_browsers['is_gecko'];
203 219
 	}
204 220
 
@@ -208,10 +224,12 @@  discard block
 block discarded – undo
208 224
 	*/
209 225
 	function isOperaMini()
210 226
 	{
211
-		if (!isset($this->_browsers['is_opera_mini']))
212
-			$this->_browsers['is_opera_mini'] = (isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA']) || stripos($_SERVER['HTTP_USER_AGENT'], 'opera mini') !== false);
213
-		if ($this->_browsers['is_opera_mini'])
214
-			$this->_is_mobile = true;
227
+		if (!isset($this->_browsers['is_opera_mini'])) {
228
+					$this->_browsers['is_opera_mini'] = (isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA']) || stripos($_SERVER['HTTP_USER_AGENT'], 'opera mini') !== false);
229
+		}
230
+		if ($this->_browsers['is_opera_mini']) {
231
+					$this->_is_mobile = true;
232
+		}
215 233
 		return $this->_browsers['is_opera_mini'];
216 234
 	}
217 235
 
@@ -221,10 +239,12 @@  discard block
 block discarded – undo
221 239
 	*/
222 240
 	function isOperaMobi()
223 241
 	{
224
-		if (!isset($this->_browsers['is_opera_mobi']))
225
-			$this->_browsers['is_opera_mobi'] = stripos($_SERVER['HTTP_USER_AGENT'], 'opera mobi') !== false;
226
-		if ($this->_browsers['is_opera_mobi'])
227
-			$this->_is_mobile = true;
242
+		if (!isset($this->_browsers['is_opera_mobi'])) {
243
+					$this->_browsers['is_opera_mobi'] = stripos($_SERVER['HTTP_USER_AGENT'], 'opera mobi') !== false;
244
+		}
245
+		if ($this->_browsers['is_opera_mobi']) {
246
+					$this->_is_mobile = true;
247
+		}
228 248
 		return $this->_browsers['is_opera_mini'];
229 249
 	}
230 250
 
@@ -244,8 +264,9 @@  discard block
 block discarded – undo
244 264
 		);
245 265
 
246 266
 		// blackberry, playbook, iphone, nokia, android and ipods set a mobile flag
247
-		if ($this->_browsers['is_iphone'] || $this->_browsers['is_blackberry'] || $this->_browsers['is_android'] || $this->_browsers['is_nokia'])
248
-			$this->_is_mobile = true;
267
+		if ($this->_browsers['is_iphone'] || $this->_browsers['is_blackberry'] || $this->_browsers['is_android'] || $this->_browsers['is_nokia']) {
268
+					$this->_is_mobile = true;
269
+		}
249 270
 
250 271
 		// @todo what to do with the blaPad? ... for now leave it detected as Safari ...
251 272
 		$this->_browsers['is_safari'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Safari') !== false && !$this->_browsers['is_chrome'] && !$this->_browsers['is_iphone'];
@@ -254,15 +275,17 @@  discard block
 block discarded – undo
254 275
 		// if Chrome, get the major version
255 276
 		if ($this->_browsers['is_chrome'])
256 277
 		{
257
-			if (preg_match('~chrome[/]([0-9][0-9]?[.])~i', $_SERVER['HTTP_USER_AGENT'], $match) === 1)
258
-				$this->_browsers['is_chrome' . (int) $match[1]] = true;
278
+			if (preg_match('~chrome[/]([0-9][0-9]?[.])~i', $_SERVER['HTTP_USER_AGENT'], $match) === 1) {
279
+							$this->_browsers['is_chrome' . (int) $match[1]] = true;
280
+			}
259 281
 		}
260 282
 
261 283
 		// or if Safari get its major version
262 284
 		if ($this->_browsers['is_safari'])
263 285
 		{
264
-			if (preg_match('~version/?(.*)safari.*~i', $_SERVER['HTTP_USER_AGENT'], $match) === 1)
265
-				$this->_browsers['is_safari' . (int) trim($match[1])] = true;
286
+			if (preg_match('~version/?(.*)safari.*~i', $_SERVER['HTTP_USER_AGENT'], $match) === 1) {
287
+							$this->_browsers['is_safari' . (int) trim($match[1])] = true;
288
+			}
266 289
 		}
267 290
 	}
268 291
 
@@ -291,8 +314,9 @@  discard block
 block discarded – undo
291 314
 			$this->_browsers['is_ie' . ((int) $trident_match[1] + 4)] = true;
292 315
 
293 316
 			// If trident is set, see the (if any) msie tag in the user agent matches ... if not its in some compatibility view
294
-			if (isset($msie_match[1]) && ($msie_match[1] < $trident_match[1] + 4))
295
-				$this->_browsers['is_ie_compat_view'] = true;
317
+			if (isset($msie_match[1]) && ($msie_match[1] < $trident_match[1] + 4)) {
318
+							$this->_browsers['is_ie_compat_view'] = true;
319
+			}
296 320
 		}
297 321
 
298 322
 		// Detect true IE6 and IE7 and not IE in compat mode.
@@ -326,8 +350,9 @@  discard block
 block discarded – undo
326 350
 	 */
327 351
 	private function setupFirefox()
328 352
 	{
329
-		if (preg_match('~(?:Firefox|Ice[wW]easel|IceCat|Shiretoko|Minefield)[\/ \(]([^ ;\)]+)~', $_SERVER['HTTP_USER_AGENT'], $match) === 1)
330
-			$this->_browsers['is_firefox' . (int) $match[1]] = true;
353
+		if (preg_match('~(?:Firefox|Ice[wW]easel|IceCat|Shiretoko|Minefield)[\/ \(]([^ ;\)]+)~', $_SERVER['HTTP_USER_AGENT'], $match) === 1) {
354
+					$this->_browsers['is_firefox' . (int) $match[1]] = true;
355
+		}
331 356
 	}
332 357
 
333 358
 	/**
@@ -338,11 +363,13 @@  discard block
 block discarded – undo
338 363
 	private function setupOpera()
339 364
 	{
340 365
 		// Opera 10+ uses the version tag at the end of the string
341
-		if (preg_match('~\sVersion/([0-9]+)\.[0-9]+(?:\s*|$)~', $_SERVER['HTTP_USER_AGENT'], $match))
342
-			$this->_browsers['is_opera' . (int) $match[1]] = true;
366
+		if (preg_match('~\sVersion/([0-9]+)\.[0-9]+(?:\s*|$)~', $_SERVER['HTTP_USER_AGENT'], $match)) {
367
+					$this->_browsers['is_opera' . (int) $match[1]] = true;
368
+		}
343 369
 		// Opera pre 10 is supposed to uses the Opera tag alone, as do some spoofers
344
-		elseif (preg_match('~Opera[ /]([0-9]+)(?!\\.[89])~', $_SERVER['HTTP_USER_AGENT'], $match))
345
-			$this->_browsers['is_opera' . (int) $match[1]] = true;
370
+		elseif (preg_match('~Opera[ /]([0-9]+)(?!\\.[89])~', $_SERVER['HTTP_USER_AGENT'], $match)) {
371
+					$this->_browsers['is_opera' . (int) $match[1]] = true;
372
+		}
346 373
 
347 374
 		// Needs size fix?
348 375
 		$this->_browsers['needs_size_fix'] = !empty($this->_browsers['is_opera6']);
@@ -353,8 +380,9 @@  discard block
 block discarded – undo
353 380
 	 */
354 381
 	private function setupEdge()
355 382
 	{
356
-		if (preg_match('~Edge[\/]([0-9][0-9]?[\.][0-9][0-9])~i', $_SERVER['HTTP_USER_AGENT'], $match) === 1)
357
-			$this->_browsers['is_edge' . (int) $match[1]] = true;
383
+		if (preg_match('~Edge[\/]([0-9][0-9]?[\.][0-9][0-9])~i', $_SERVER['HTTP_USER_AGENT'], $match) === 1) {
384
+					$this->_browsers['is_edge' . (int) $match[1]] = true;
385
+		}
358 386
 	}
359 387
 
360 388
 	/**
@@ -367,9 +395,9 @@  discard block
 block discarded – undo
367 395
 	{
368 396
 		global $context;
369 397
 
370
-		if ($this->_is_mobile)
371
-			$context['browser_body_id'] = 'mobile';
372
-		else
398
+		if ($this->_is_mobile) {
399
+					$context['browser_body_id'] = 'mobile';
400
+		} else
373 401
 		{
374 402
 			// add in any specific detection conversions here if you want a special body id e.g. 'is_opera9' => 'opera9'
375 403
 			$browser_priority = array(
Please login to merge, or discard this patch.
Sources/Likes.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 	public function get($property = '')
168 168
 	{
169 169
 		// All properties inside Likes are protected, thus, an underscore is used.
170
-		$property = '_'. $property;
170
+		$property = '_' . $property;
171 171
 		return property_exists($this, $property) ? $this->$property : false;
172 172
 	}
173 173
 
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
 
572 572
 			// Nope?  then just do a redirect to whatever URL was provided.
573 573
 			else
574
-				redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] .';error='. $this->_error : '');
574
+				redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] . ';error=' . $this->_error : '');
575 575
 
576 576
 			return;
577 577
 		}
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
 			if (in_array($this->_sa, $generic))
589 589
 			{
590 590
 				$context['sub_template'] = 'generic';
591
-				$context['data'] = isset($txt['like_'. $this->_data]) ? $txt['like_'. $this->_data] : $this->_data;
591
+				$context['data'] = isset($txt['like_' . $this->_data]) ? $txt['like_' . $this->_data] : $this->_data;
592 592
 			}
593 593
 
594 594
 			// Directly pass the current called sub-action and the data generated by its associated Method.
Please login to merge, or discard this patch.
Braces   +106 added lines, -77 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
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
  * Class Likes
@@ -108,8 +109,9 @@  discard block
 block discarded – undo
108 109
 		$this->_extra = isset($_GET['extra']) ? $_GET['extra'] : false;
109 110
 
110 111
 		// We do not want to output debug information here.
111
-		if ($this->_js)
112
-			$db_show_debug = false;
112
+		if ($this->_js) {
113
+					$db_show_debug = false;
114
+		}
113 115
 	}
114 116
 
115 117
 	/**
@@ -143,8 +145,9 @@  discard block
 block discarded – undo
143 145
 			$call = $this->_sa;
144 146
 
145 147
 			// Guest can only view likes.
146
-			if ($call != 'view')
147
-				is_not_guest();
148
+			if ($call != 'view') {
149
+							is_not_guest();
150
+			}
148 151
 
149 152
 			checkSession('get');
150 153
 
@@ -182,15 +185,17 @@  discard block
 block discarded – undo
182 185
 		global $smcFunc, $modSettings;
183 186
 
184 187
 		// This feature is currently disable.
185
-		if (empty($modSettings['enable_likes']))
186
-			return $this->_error = 'like_disable';
188
+		if (empty($modSettings['enable_likes'])) {
189
+					return $this->_error = 'like_disable';
190
+		}
187 191
 
188 192
 		// Zerothly, they did indicate some kind of content to like, right?
189 193
 		preg_match('~^([a-z0-9\-\_]{1,6})~i', $this->_type, $matches);
190 194
 		$this->_type = isset($matches[1]) ? $matches[1] : '';
191 195
 
192
-		if ($this->_type == '' || $this->_content <= 0)
193
-			return $this->_error = 'cannot_';
196
+		if ($this->_type == '' || $this->_content <= 0) {
197
+					return $this->_error = 'cannot_';
198
+		}
194 199
 
195 200
 		// First we need to verify if the user can see the type of content or not. This is set up to be extensible,
196 201
 		// so we'll check for the one type we do know about, and if it's not that, we'll defer to any hooks.
@@ -209,12 +214,14 @@  discard block
 block discarded – undo
209 214
 					'msg' => $this->_content,
210 215
 				)
211 216
 			);
212
-			if ($smcFunc['db_num_rows']($request) == 1)
213
-				list ($this->_idTopic, $topicOwner) = $smcFunc['db_fetch_row']($request);
217
+			if ($smcFunc['db_num_rows']($request) == 1) {
218
+							list ($this->_idTopic, $topicOwner) = $smcFunc['db_fetch_row']($request);
219
+			}
214 220
 
215 221
 			$smcFunc['db_free_result']($request);
216
-			if (empty($this->_idTopic))
217
-				return $this->_error = 'cannot_';
222
+			if (empty($this->_idTopic)) {
223
+							return $this->_error = 'cannot_';
224
+			}
218 225
 
219 226
 			// So we know what topic it's in and more importantly we know the user can see it.
220 227
 			// If we're not viewing, we need some info set up.
@@ -224,9 +231,7 @@  discard block
 block discarded – undo
224 231
 			$this->_validLikes['can_see'] = allowedTo('likes_view') ? true : 'cannot_view_likes';
225 232
 
226 233
 			$this->_validLikes['can_like'] = ($this->_user['id'] == $topicOwner ? 'cannot_like_content' : (allowedTo('likes_like') ? true : 'cannot_like_content'));
227
-		}
228
-
229
-		else
234
+		} else
230 235
 		{
231 236
 			// Modders: This will give you whatever the user offers up in terms of liking, e.g. $this->_type=msg, $this->_content=1
232 237
 			// When you hook this, check $this->_type first. If it is not something your mod worries about, return false.
@@ -244,8 +249,9 @@  discard block
 block discarded – undo
244 249
 					if ($result !== false)
245 250
 					{
246 251
 						// Match the type with what we already have.
247
-						if (!isset($result['type']) || $result['type'] != $this->_type)
248
-							return $this->_error = 'not_valid_like_type';
252
+						if (!isset($result['type']) || $result['type'] != $this->_type) {
253
+													return $this->_error = 'not_valid_like_type';
254
+						}
249 255
 
250 256
 						// Fill out the rest.
251 257
 						$this->_type = $result['type'];
@@ -256,17 +262,20 @@  discard block
 block discarded – undo
256 262
 				}
257 263
 			}
258 264
 
259
-			if (!$found)
260
-				return $this->_error = 'cannot_';
265
+			if (!$found) {
266
+							return $this->_error = 'cannot_';
267
+			}
261 268
 		}
262 269
 
263 270
 		// Does the user can see this?
264
-		if (isset($this->_validLikes['can_see']) && is_string($this->_validLikes['can_see']))
265
-			return $this->_error = $this->_validLikes['can_see'];
271
+		if (isset($this->_validLikes['can_see']) && is_string($this->_validLikes['can_see'])) {
272
+					return $this->_error = $this->_validLikes['can_see'];
273
+		}
266 274
 
267 275
 		// Does the user can like this? Viewing a list of likes doesn't require this permission.
268
-			if ($this->_sa != 'view' && isset($this->_validLikes['can_like']) && is_string($this->_validLikes['can_like']))
269
-				return $this->_error = $this->_validLikes['can_like'];
276
+			if ($this->_sa != 'view' && isset($this->_validLikes['can_like']) && is_string($this->_validLikes['can_like'])) {
277
+							return $this->_error = $this->_validLikes['can_like'];
278
+			}
270 279
 	}
271 280
 
272 281
 	/**
@@ -291,8 +300,9 @@  discard block
 block discarded – undo
291 300
 		);
292 301
 
293 302
 		// Are we calling this directly? if so, set a proper data for the response. Do note that __METHOD__ returns both the class name and the function name.
294
-		if ($this->_sa == __FUNCTION__)
295
-			$this->_data = __FUNCTION__;
303
+		if ($this->_sa == __FUNCTION__) {
304
+					$this->_data = __FUNCTION__;
305
+		}
296 306
 	}
297 307
 
298 308
 	/**
@@ -322,8 +332,8 @@  discard block
 block discarded – undo
322 332
 
323 333
 		// Add a background task to process sending alerts.
324 334
 		// Mod author, you can add your own background task for your own custom like event using the "integrate_issue_like" hook or your callback, both are immediately called after this.
325
-		if ($this->_type == 'msg')
326
-			$smcFunc['db_insert']('insert',
335
+		if ($this->_type == 'msg') {
336
+					$smcFunc['db_insert']('insert',
327 337
 				'{db_prefix}background_tasks',
328 338
 				array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'),
329 339
 				array('$sourcedir/tasks/Likes-Notify.php', 'Likes_Notify_Background', json_encode(array(
@@ -335,10 +345,12 @@  discard block
 block discarded – undo
335 345
 				)), 0),
336 346
 				array('id_task')
337 347
 			);
348
+		}
338 349
 
339 350
 		// Are we calling this directly? if so, set a proper data for the response. Do note that __METHOD__ returns both the class name and the function name.
340
-		if ($this->_sa == __FUNCTION__)
341
-			$this->_data = __FUNCTION__;
351
+		if ($this->_sa == __FUNCTION__) {
352
+					$this->_data = __FUNCTION__;
353
+		}
342 354
 	}
343 355
 
344 356
 	/**
@@ -364,8 +376,9 @@  discard block
 block discarded – undo
364 376
 		$smcFunc['db_free_result']($request);
365 377
 
366 378
 		// If you want to call this directly, fill out _data property too.
367
-		if ($this->_sa == __FUNCTION__)
368
-			$this->_data = $this->_numLikes;
379
+		if ($this->_sa == __FUNCTION__) {
380
+					$this->_data = $this->_numLikes;
381
+		}
369 382
 	}
370 383
 
371 384
 	/**
@@ -378,8 +391,9 @@  discard block
 block discarded – undo
378 391
 		global $smcFunc;
379 392
 
380 393
 		// Safety first!
381
-		if (empty($this->_type) || empty($this->_content))
382
-			return $this->_error = 'cannot_';
394
+		if (empty($this->_type) || empty($this->_content)) {
395
+					return $this->_error = 'cannot_';
396
+		}
383 397
 
384 398
 		// Do we already like this?
385 399
 		$request = $smcFunc['db_query']('', '
@@ -397,26 +411,28 @@  discard block
 block discarded – undo
397 411
 		$this->_alreadyLiked = (bool) $smcFunc['db_num_rows']($request) != 0;
398 412
 		$smcFunc['db_free_result']($request);
399 413
 
400
-		if ($this->_alreadyLiked)
401
-			$this->delete();
402
-
403
-		else
404
-			$this->insert();
414
+		if ($this->_alreadyLiked) {
415
+					$this->delete();
416
+		} else {
417
+					$this->insert();
418
+		}
405 419
 
406 420
 		// Now, how many people like this content now? We *could* just +1 / -1 the relevant container but that has proven to become unstable.
407 421
 		$this->_count();
408 422
 
409 423
 		// Update the likes count for messages.
410
-		if ($this->_type == 'msg')
411
-			$this->msgIssueLike();
424
+		if ($this->_type == 'msg') {
425
+					$this->msgIssueLike();
426
+		}
412 427
 
413 428
 		// Any callbacks?
414 429
 		elseif (!empty($this->_validLikes['callback']))
415 430
 		{
416 431
 			$call = call_helper($this->_validLikes['callback'], true);
417 432
 
418
-			if (!empty($call))
419
-				call_user_func_array($call, array($this));
433
+			if (!empty($call)) {
434
+							call_user_func_array($call, array($this));
435
+			}
420 436
 		}
421 437
 
422 438
 		// Sometimes there might be other things that need updating after we do this like.
@@ -425,8 +441,9 @@  discard block
 block discarded – undo
425 441
 		// Now some clean up. This is provided here for any like handlers that want to do any cache flushing.
426 442
 		// This way a like handler doesn't need to explicitly declare anything in integrate_issue_like, but do so
427 443
 		// in integrate_valid_likes where it absolutely has to exist.
428
-		if (!empty($this->_validLikes['flush_cache']))
429
-			cache_put_data($this->_validLikes['flush_cache'], null);
444
+		if (!empty($this->_validLikes['flush_cache'])) {
445
+					cache_put_data($this->_validLikes['flush_cache'], null);
446
+		}
430 447
 
431 448
 		// All done, start building the data to pass as response.
432 449
 		$this->_data = array(
@@ -450,8 +467,9 @@  discard block
 block discarded – undo
450 467
 	{
451 468
 		global $smcFunc;
452 469
 
453
-		if ($this->_type !== 'msg')
454
-			return;
470
+		if ($this->_type !== 'msg') {
471
+					return;
472
+		}
455 473
 
456 474
 		$smcFunc['db_query']('', '
457 475
 			UPDATE {db_prefix}messages
@@ -492,8 +510,9 @@  discard block
 block discarded – undo
492 510
 				'like_type' => $this->_type,
493 511
 			)
494 512
 		);
495
-		while ($row = $smcFunc['db_fetch_assoc']($request))
496
-			$context['likers'][$row['id_member']] = array('timestamp' => $row['like_time']);
513
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
514
+					$context['likers'][$row['id_member']] = array('timestamp' => $row['like_time']);
515
+		}
497 516
 
498 517
 		// Now to get member data, including avatars and so on.
499 518
 		$members = array_keys($context['likers']);
@@ -501,8 +520,9 @@  discard block
 block discarded – undo
501 520
 		if (count($loaded) != count($members))
502 521
 		{
503 522
 			$members = array_diff($members, $loaded);
504
-			foreach ($members as $not_loaded)
505
-				unset ($context['likers'][$not_loaded]);
523
+			foreach ($members as $not_loaded) {
524
+							unset ($context['likers'][$not_loaded]);
525
+			}
506 526
 		}
507 527
 
508 528
 		foreach ($context['likers'] as $liker => $dummy)
@@ -544,12 +564,14 @@  discard block
 block discarded – undo
544 564
 		global $context, $txt;
545 565
 
546 566
 		// Don't do anything if someone else has already take care of the response.
547
-		if (!$this->_setResponse)
548
-			return;
567
+		if (!$this->_setResponse) {
568
+					return;
569
+		}
549 570
 
550 571
 		// Want a json response huh?
551
-		if ($this->_validLikes['json'])
552
-			return $this->jsonResponse();
572
+		if ($this->_validLikes['json']) {
573
+					return $this->jsonResponse();
574
+		}
553 575
 
554 576
 		// Set everything up for display.
555 577
 		loadTemplate('Likes');
@@ -559,8 +581,9 @@  discard block
 block discarded – undo
559 581
 		if ($this->_error)
560 582
 		{
561 583
 			// If this is a generic error, set it up good.
562
-			if ($this->_error == 'cannot_')
563
-				$this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content';
584
+			if ($this->_error == 'cannot_') {
585
+							$this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content';
586
+			}
564 587
 
565 588
 			// Is this request coming from an ajax call?
566 589
 			if ($this->_js)
@@ -570,8 +593,9 @@  discard block
 block discarded – undo
570 593
 			}
571 594
 
572 595
 			// Nope?  then just do a redirect to whatever URL was provided.
573
-			else
574
-				redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] .';error='. $this->_error : '');
596
+			else {
597
+							redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] .';error='. $this->_error : '');
598
+			}
575 599
 
576 600
 			return;
577 601
 		}
@@ -580,8 +604,9 @@  discard block
 block discarded – undo
580 604
 		else
581 605
 		{
582 606
 			// Not an ajax request so send the user back to the previous location or the main page.
583
-			if (!$this->_js)
584
-				redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] : '');
607
+			if (!$this->_js) {
608
+							redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] : '');
609
+			}
585 610
 
586 611
 			// These fine gentlemen all share the same template.
587 612
 			$generic = array('delete', 'insert', '_count');
@@ -612,8 +637,9 @@  discard block
 block discarded – undo
612 637
 		// If there is an error, send it.
613 638
 		if ($this->_error)
614 639
 		{
615
-			if ($this->_error == 'cannot_')
616
-				$this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content';
640
+			if ($this->_error == 'cannot_') {
641
+							$this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content';
642
+			}
617 643
 
618 644
 			$print['error'] = $this->_error;
619 645
 		}
@@ -649,33 +675,36 @@  discard block
 block discarded – undo
649 675
 	<body style="background-color: #444455; color: white; font-style: italic; font-family: serif;">
650 676
 		<div style="margin-top: 12%; font-size: 1.1em; line-height: 1.4; text-align: center;">';
651 677
 
652
-	if (!isset($_GET['verse']) || ($_GET['verse'] != '2:18' && $_GET['verse'] != '22:1-2'))
653
-		$_GET['verse'] = '4:16';
678
+	if (!isset($_GET['verse']) || ($_GET['verse'] != '2:18' && $_GET['verse'] != '22:1-2')) {
679
+			$_GET['verse'] = '4:16';
680
+	}
654 681
 
655
-	if ($_GET['verse'] == '2:18')
656
-		echo '
682
+	if ($_GET['verse'] == '2:18') {
683
+			echo '
657 684
 			Woe, it was that his name wasn\'t <em>known</em>, that he came in mystery, and was recognized by none.&nbsp;And it became to be in those days <em>something</em>.&nbsp; Something not yet <em id="unknown" name="[Unknown]">unknown</em> to mankind.&nbsp; And thus what was to be known the <em>secret project</em> began into its existence.&nbsp; Henceforth the opposition was only <em>weary</em> and <em>fearful</em>, for now their match was at arms against them.';
658
-	elseif ($_GET['verse'] == '4:16')
659
-		echo '
685
+	} elseif ($_GET['verse'] == '4:16') {
686
+			echo '
660 687
 			And it came to pass that the <em>unbelievers</em> dwindled in number and saw rise of many <em>proselytizers</em>, and the opposition found fear in the face of the <em>x</em> and the <em>j</em> while those who stood with the <em>something</em> grew stronger and came together.&nbsp; Still, this was only the <em>beginning</em>, and what lay in the future was <em id="unknown" name="[Unknown]">unknown</em> to all, even those on the right side.';
661
-	elseif ($_GET['verse'] == '22:1-2')
662
-		echo '
688
+	} elseif ($_GET['verse'] == '22:1-2') {
689
+			echo '
663 690
 			<p>Now <em>behold</em>, that which was once the secret project was <em id="unknown" name="[Unknown]">unknown</em> no longer.&nbsp; Alas, it needed more than <em>only one</em>, but yet even thought otherwise.&nbsp; It became that the opposition <em>rumored</em> and lied, but still to no avail.&nbsp; Their match, though not <em>perfect</em>, had them outdone.</p>
664 691
 			<p style="margin: 2ex 1ex 0 1ex; font-size: 1.05em; line-height: 1.5; text-align: center;">Let it continue.&nbsp; <em>The end</em>.</p>';
692
+	}
665 693
 
666 694
 	echo '
667 695
 		</div>
668 696
 		<div style="margin-top: 2ex; font-size: 2em; text-align: right;">';
669 697
 
670
-	if ($_GET['verse'] == '2:18')
671
-		echo '
698
+	if ($_GET['verse'] == '2:18') {
699
+			echo '
672 700
 			from <span style="font-family: Georgia, serif;"><strong><a href="', $scripturl, '?action=about:unknown;verse=4:16" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 2:18</span>';
673
-	elseif ($_GET['verse'] == '4:16')
674
-		echo '
701
+	} elseif ($_GET['verse'] == '4:16') {
702
+			echo '
675 703
 			from <span style="font-family: Georgia, serif;"><strong><a href="', $scripturl, '?action=about:unknown;verse=22:1-2" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 4:16</span>';
676
-	elseif ($_GET['verse'] == '22:1-2')
677
-		echo '
704
+	} elseif ($_GET['verse'] == '22:1-2') {
705
+			echo '
678 706
 			from <span style="font-family: Georgia, serif;"><strong>The Book of Unknown</strong>, 22:1-2</span>';
707
+	}
679 708
 
680 709
 	echo '
681 710
 		</div>
Please login to merge, or discard this patch.
Sources/Themes.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -837,7 +837,7 @@  discard block
 block discarded – undo
837 837
 		remove_dir($theme_info['theme_dir']);
838 838
 
839 839
 	// Go back to the list page.
840
-	redirectexit('action=admin;area=theme;sa=list;' . $context['session_var'] . '=' . $context['session_id'] .';done=removing');
840
+	redirectexit('action=admin;area=theme;sa=list;' . $context['session_var'] . '=' . $context['session_id'] . ';done=removing');
841 841
 }
842 842
 
843 843
 /**
@@ -871,7 +871,7 @@  discard block
 block discarded – undo
871 871
 	updateSettings(array('enableThemes' => $enableThemes));
872 872
 
873 873
 	// Done!
874
-	redirectexit('action=admin;area=theme;sa=list;' . $context['session_var'] . '=' . $context['session_id'] .';done='. (isset($_GET['disabled']) ? 'disabling' : 'enabling'));
874
+	redirectexit('action=admin;area=theme;sa=list;' . $context['session_var'] . '=' . $context['session_id'] . ';done=' . (isset($_GET['disabled']) ? 'disabling' : 'enabling'));
875 875
 }
876 876
 
877 877
 /**
@@ -1106,7 +1106,7 @@  discard block
 block discarded – undo
1106 1106
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1107 1107
 	{
1108 1108
 		// Figure out which theme it is they are REALLY using.
1109
-		if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',',$modSettings['knownThemes'])))
1109
+		if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',', $modSettings['knownThemes'])))
1110 1110
 			$row['id_theme'] = $guest_theme;
1111 1111
 		elseif (empty($modSettings['theme_allow']))
1112 1112
 			$row['id_theme'] = $guest_theme;
@@ -1254,10 +1254,10 @@  discard block
 block discarded – undo
1254 1254
 		$action = $smcFunc['htmlspecialchars'](trim($_GET['do']));
1255 1255
 
1256 1256
 		// Got any info from the specific form?
1257
-		if (!isset($_POST['save_'. $action]))
1257
+		if (!isset($_POST['save_' . $action]))
1258 1258
 			fatal_lang_error('theme_install_no_action', false);
1259 1259
 
1260
-		validateToken('admin-t-'. $action);
1260
+		validateToken('admin-t-' . $action);
1261 1261
 
1262 1262
 		// Hopefully the themes directory is writable, or we might have a problem.
1263 1263
 		if (!is_writable($themedir))
@@ -1291,7 +1291,7 @@  discard block
 block discarded – undo
1291 1291
 	global $themedir, $themeurl, $context;
1292 1292
 
1293 1293
 	// Set a temp dir for dumping all required files on it.
1294
-	$dirtemp = $themedir .'/temp';
1294
+	$dirtemp = $themedir . '/temp';
1295 1295
 
1296 1296
 	// Make sure the temp dir doesn't already exist
1297 1297
 	if (file_exists($dirtemp))
@@ -1317,7 +1317,7 @@  discard block
 block discarded – undo
1317 1317
 
1318 1318
 	// Another error check layer, something went wrong with the upload.
1319 1319
 	if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0)
1320
-		fatal_lang_error('theme_install_error_file_'. $_FILES['theme_gz']['error'], false);
1320
+		fatal_lang_error('theme_install_error_file_' . $_FILES['theme_gz']['error'], false);
1321 1321
 
1322 1322
 	// Get the theme's name.
1323 1323
 	$name = pathinfo($_FILES['theme_gz']['name'], PATHINFO_FILENAME);
@@ -1373,7 +1373,7 @@  discard block
 block discarded – undo
1373 1373
 	$name = preg_replace('~[^A-Za-z0-9_\- ]~', '', $_REQUEST['copy']);
1374 1374
 
1375 1375
 	// Is there a theme already named like this?
1376
-	if (file_exists($themedir .'/'. $name))
1376
+	if (file_exists($themedir . '/' . $name))
1377 1377
 		fatal_lang_error('theme_install_already_dir', false);
1378 1378
 
1379 1379
 	// This is a brand new theme so set all possible values.
@@ -1383,7 +1383,7 @@  discard block
 block discarded – undo
1383 1383
 		'name' => $name,
1384 1384
 		'images_url' => $themeurl . '/' . $name . '/images',
1385 1385
 		'version' => '1.0',
1386
-		'install_for' => '2.1 - 2.1.99, '. strtr($forum_version, array('SMF ' => '')),
1386
+		'install_for' => '2.1 - 2.1.99, ' . strtr($forum_version, array('SMF ' => '')),
1387 1387
 		'based_on' => '',
1388 1388
 		'based_on_dir' => $themedir . '/default',
1389 1389
 	);
@@ -1454,7 +1454,7 @@  discard block
 block discarded – undo
1454 1454
 <!-- The theme\'s version, please try to use semantic versioning. -->
1455 1455
 <version>1.0</version>
1456 1456
 <!-- Install for, the SMF versions this theme was designed for. Uses the same wildcards used in the packager manager. This field is mandatory. -->
1457
-<install for="'. $context['to_install']['install_for'] .'" />
1457
+<install for="'. $context['to_install']['install_for'] . '" />
1458 1458
 <!-- Theme name, used purely for aesthetics. -->
1459 1459
 <name>' . $context['to_install']['name'] . '</name>
1460 1460
 <!-- Author: your email address or contact information. The name attribute is optional. -->
Please login to merge, or discard this patch.
Braces   +345 added lines, -269 removed lines patch added patch discarded remove patch
@@ -30,8 +30,9 @@  discard block
 block discarded – undo
30 30
  * @version 2.1 Beta 3
31 31
  */
32 32
 
33
-if (!defined('SMF'))
33
+if (!defined('SMF')) {
34 34
 	die('No direct access...');
35
+}
35 36
 
36 37
 /**
37 38
  * Subaction handler - manages the action and delegates control to the proper
@@ -103,12 +104,12 @@  discard block
 block discarded – undo
103 104
 	cache_put_data('minimized_css', null);
104 105
 
105 106
 	// Follow the sa or just go to administration.
106
-	if (isset($_GET['sa']) && !empty($subActions[$_GET['sa']]))
107
-		call_helper($subActions[$_GET['sa']]);
108
-
109
-	else
110
-		call_helper($subActions['admin']);
111
-}
107
+	if (isset($_GET['sa']) && !empty($subActions[$_GET['sa']])) {
108
+			call_helper($subActions[$_GET['sa']]);
109
+	} else {
110
+			call_helper($subActions['admin']);
111
+	}
112
+	}
112 113
 
113 114
 /**
114 115
  * This function allows administration of themes and their settings,
@@ -130,15 +131,16 @@  discard block
 block discarded – undo
130 131
 		checkSession();
131 132
 		validateToken('admin-tm');
132 133
 
133
-		if (isset($_POST['options']['known_themes']))
134
-			foreach ($_POST['options']['known_themes'] as $key => $id)
134
+		if (isset($_POST['options']['known_themes'])) {
135
+					foreach ($_POST['options']['known_themes'] as $key => $id)
135 136
 				$_POST['options']['known_themes'][$key] = (int) $id;
137
+		} else {
138
+					fatal_lang_error('themes_none_selectable', false);
139
+		}
136 140
 
137
-		else
138
-			fatal_lang_error('themes_none_selectable', false);
139
-
140
-		if (!in_array($_POST['options']['theme_guests'], $_POST['options']['known_themes']))
141
-			fatal_lang_error('themes_default_selectable', false);
141
+		if (!in_array($_POST['options']['theme_guests'], $_POST['options']['known_themes'])) {
142
+					fatal_lang_error('themes_default_selectable', false);
143
+		}
142 144
 
143 145
 		// Commit the new settings.
144 146
 		updateSettings(array(
@@ -146,8 +148,9 @@  discard block
 block discarded – undo
146 148
 			'theme_guests' => $_POST['options']['theme_guests'],
147 149
 			'knownThemes' => implode(',', $_POST['options']['known_themes']),
148 150
 		));
149
-		if ((int) $_POST['theme_reset'] == 0 || in_array($_POST['theme_reset'], $_POST['options']['known_themes']))
150
-			updateMemberData(null, array('id_theme' => (int) $_POST['theme_reset']));
151
+		if ((int) $_POST['theme_reset'] == 0 || in_array($_POST['theme_reset'], $_POST['options']['known_themes'])) {
152
+					updateMemberData(null, array('id_theme' => (int) $_POST['theme_reset']));
153
+		}
151 154
 
152 155
 		redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=admin');
153 156
 	}
@@ -166,8 +169,9 @@  discard block
 block discarded – undo
166 169
 	// Look for a non existent theme directory. (ie theme87.)
167 170
 	$theme_dir = $boarddir . '/Themes/theme';
168 171
 	$i = 1;
169
-	while (file_exists($theme_dir . $i))
170
-		$i++;
172
+	while (file_exists($theme_dir . $i)) {
173
+			$i++;
174
+	}
171 175
 
172 176
 	$context['new_theme_name'] = 'theme' . $i;
173 177
 
@@ -189,8 +193,9 @@  discard block
 block discarded – undo
189 193
 	loadLanguage('Admin');
190 194
 	isAllowedTo('admin_forum');
191 195
 
192
-	if (isset($_REQUEST['th']))
193
-		return SetThemeSettings();
196
+	if (isset($_REQUEST['th'])) {
197
+			return SetThemeSettings();
198
+	}
194 199
 
195 200
 	if (isset($_POST['save']))
196 201
 	{
@@ -274,12 +279,13 @@  discard block
 block discarded – undo
274 279
 		$context['themes'] = array();
275 280
 		while ($row = $smcFunc['db_fetch_assoc']($request))
276 281
 		{
277
-			if (!isset($context['themes'][$row['id_theme']]))
278
-				$context['themes'][$row['id_theme']] = array(
282
+			if (!isset($context['themes'][$row['id_theme']])) {
283
+							$context['themes'][$row['id_theme']] = array(
279 284
 					'id' => $row['id_theme'],
280 285
 					'num_default_options' => 0,
281 286
 					'num_members' => 0,
282 287
 				);
288
+			}
283 289
 			$context['themes'][$row['id_theme']][$row['variable']] = $row['value'];
284 290
 		}
285 291
 		$smcFunc['db_free_result']($request);
@@ -293,8 +299,9 @@  discard block
 block discarded – undo
293 299
 				'guest_member' => -1,
294 300
 			)
295 301
 		);
296
-		while ($row = $smcFunc['db_fetch_assoc']($request))
297
-			$context['themes'][$row['id_theme']]['num_default_options'] = $row['value'];
302
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
303
+					$context['themes'][$row['id_theme']]['num_default_options'] = $row['value'];
304
+		}
298 305
 		$smcFunc['db_free_result']($request);
299 306
 
300 307
 		// Need to make sure we don't do custom fields.
@@ -305,8 +312,9 @@  discard block
 block discarded – undo
305 312
 			)
306 313
 		);
307 314
 		$customFields = array();
308
-		while ($row = $smcFunc['db_fetch_assoc']($request))
309
-			$customFields[] = $row['col_name'];
315
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
316
+					$customFields[] = $row['col_name'];
317
+		}
310 318
 		$smcFunc['db_free_result']($request);
311 319
 		$customFieldsQuery = empty($customFields) ? '' : ('AND variable NOT IN ({array_string:custom_fields})');
312 320
 
@@ -321,14 +329,16 @@  discard block
 block discarded – undo
321 329
 				'custom_fields' => empty($customFields) ? array() : $customFields,
322 330
 			)
323 331
 		);
324
-		while ($row = $smcFunc['db_fetch_assoc']($request))
325
-			$context['themes'][$row['id_theme']]['num_members'] = $row['value'];
332
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
333
+					$context['themes'][$row['id_theme']]['num_members'] = $row['value'];
334
+		}
326 335
 		$smcFunc['db_free_result']($request);
327 336
 
328 337
 		// There has to be a Settings template!
329
-		foreach ($context['themes'] as $k => $v)
330
-			if (empty($v['theme_dir']) || (!file_exists($v['theme_dir'] . '/Settings.template.php') && empty($v['num_members'])))
338
+		foreach ($context['themes'] as $k => $v) {
339
+					if (empty($v['theme_dir']) || (!file_exists($v['theme_dir'] . '/Settings.template.php') && empty($v['num_members'])))
331 340
 				unset($context['themes'][$k]);
341
+		}
332 342
 
333 343
 		loadTemplate('Themes');
334 344
 		$context['sub_template'] = 'reset_list';
@@ -343,16 +353,19 @@  discard block
 block discarded – undo
343 353
 		checkSession();
344 354
 		validateToken('admin-sto');
345 355
 
346
-		if (empty($_POST['options']))
347
-			$_POST['options'] = array();
348
-		if (empty($_POST['default_options']))
349
-			$_POST['default_options'] = array();
356
+		if (empty($_POST['options'])) {
357
+					$_POST['options'] = array();
358
+		}
359
+		if (empty($_POST['default_options'])) {
360
+					$_POST['default_options'] = array();
361
+		}
350 362
 
351 363
 		// Set up the sql query.
352 364
 		$setValues = array();
353 365
 
354
-		foreach ($_POST['options'] as $opt => $val)
355
-			$setValues[] = array(-1, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val);
366
+		foreach ($_POST['options'] as $opt => $val) {
367
+					$setValues[] = array(-1, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val);
368
+		}
356 369
 
357 370
 		$old_settings = array();
358 371
 		foreach ($_POST['default_options'] as $opt => $val)
@@ -366,8 +379,8 @@  discard block
 block discarded – undo
366 379
 		if (!empty($setValues))
367 380
 		{
368 381
 			// Are there options in non-default themes set that should be cleared?
369
-			if (!empty($old_settings))
370
-				$smcFunc['db_query']('', '
382
+			if (!empty($old_settings)) {
383
+							$smcFunc['db_query']('', '
371 384
 					DELETE FROM {db_prefix}themes
372 385
 					WHERE id_theme != {int:default_theme}
373 386
 						AND id_member = {int:guest_member}
@@ -378,6 +391,7 @@  discard block
 block discarded – undo
378 391
 						'old_settings' => $old_settings,
379 392
 					)
380 393
 				);
394
+			}
381 395
 
382 396
 			$smcFunc['db_insert']('replace',
383 397
 				'{db_prefix}themes',
@@ -391,8 +405,7 @@  discard block
 block discarded – undo
391 405
 		cache_put_data('theme_settings-1', null, 90);
392 406
 
393 407
 		redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=reset');
394
-	}
395
-	elseif (isset($_POST['submit']) && $_POST['who'] == 1)
408
+	} elseif (isset($_POST['submit']) && $_POST['who'] == 1)
396 409
 	{
397 410
 		checkSession();
398 411
 		validateToken('admin-sto');
@@ -405,9 +418,9 @@  discard block
 block discarded – undo
405 418
 		$old_settings = array();
406 419
 		foreach ($_POST['default_options'] as $opt => $val)
407 420
 		{
408
-			if ($_POST['default_options_master'][$opt] == 0)
409
-				continue;
410
-			elseif ($_POST['default_options_master'][$opt] == 1)
421
+			if ($_POST['default_options_master'][$opt] == 0) {
422
+							continue;
423
+			} elseif ($_POST['default_options_master'][$opt] == 1)
411 424
 			{
412 425
 				// Delete then insert for ease of database compatibility!
413 426
 				$smcFunc['db_query']('substring', '
@@ -433,8 +446,7 @@  discard block
 block discarded – undo
433 446
 				);
434 447
 
435 448
 				$old_settings[] = $opt;
436
-			}
437
-			elseif ($_POST['default_options_master'][$opt] == 2)
449
+			} elseif ($_POST['default_options_master'][$opt] == 2)
438 450
 			{
439 451
 				$smcFunc['db_query']('', '
440 452
 					DELETE FROM {db_prefix}themes
@@ -449,8 +461,8 @@  discard block
 block discarded – undo
449 461
 		}
450 462
 
451 463
 		// Delete options from other themes.
452
-		if (!empty($old_settings))
453
-			$smcFunc['db_query']('', '
464
+		if (!empty($old_settings)) {
465
+					$smcFunc['db_query']('', '
454 466
 				DELETE FROM {db_prefix}themes
455 467
 				WHERE id_theme != {int:default_theme}
456 468
 					AND id_member > {int:no_member}
@@ -461,12 +473,13 @@  discard block
 block discarded – undo
461 473
 					'old_settings' => $old_settings,
462 474
 				)
463 475
 			);
476
+		}
464 477
 
465 478
 		foreach ($_POST['options'] as $opt => $val)
466 479
 		{
467
-			if ($_POST['options_master'][$opt] == 0)
468
-				continue;
469
-			elseif ($_POST['options_master'][$opt] == 1)
480
+			if ($_POST['options_master'][$opt] == 0) {
481
+							continue;
482
+			} elseif ($_POST['options_master'][$opt] == 1)
470 483
 			{
471 484
 				// Delete then insert for ease of database compatibility - again!
472 485
 				$smcFunc['db_query']('substring', '
@@ -491,8 +504,7 @@  discard block
 block discarded – undo
491 504
 						'value' => (is_array($val) ? implode(',', $val) : $val),
492 505
 					)
493 506
 				);
494
-			}
495
-			elseif ($_POST['options_master'][$opt] == 2)
507
+			} elseif ($_POST['options_master'][$opt] == 2)
496 508
 			{
497 509
 				$smcFunc['db_query']('', '
498 510
 					DELETE FROM {db_prefix}themes
@@ -509,8 +521,7 @@  discard block
 block discarded – undo
509 521
 		}
510 522
 
511 523
 		redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=reset');
512
-	}
513
-	elseif (!empty($_GET['who']) && $_GET['who'] == 2)
524
+	} elseif (!empty($_GET['who']) && $_GET['who'] == 2)
514 525
 	{
515 526
 		checkSession('get');
516 527
 		validateToken('admin-stor', 'request');
@@ -525,8 +536,9 @@  discard block
 block discarded – undo
525 536
 				)
526 537
 			);
527 538
 			$customFields = array();
528
-			while ($row = $smcFunc['db_fetch_assoc']($request))
529
-				$customFields[] = $row['col_name'];
539
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
540
+							$customFields[] = $row['col_name'];
541
+			}
530 542
 			$smcFunc['db_free_result']($request);
531 543
 		}
532 544
 		$customFieldsQuery = empty($customFields) ? '' : ('AND variable NOT IN ({array_string:custom_fields})');
@@ -578,13 +590,13 @@  discard block
 block discarded – undo
578 590
 			)
579 591
 		);
580 592
 		$context['theme_options'] = array();
581
-		while ($row = $smcFunc['db_fetch_assoc']($request))
582
-			$context['theme_options'][$row['variable']] = $row['value'];
593
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
594
+					$context['theme_options'][$row['variable']] = $row['value'];
595
+		}
583 596
 		$smcFunc['db_free_result']($request);
584 597
 
585 598
 		$context['theme_options_reset'] = false;
586
-	}
587
-	else
599
+	} else
588 600
 	{
589 601
 		$context['theme_options'] = array();
590 602
 		$context['theme_options_reset'] = true;
@@ -597,22 +609,23 @@  discard block
 block discarded – undo
597 609
 		{
598 610
 			unset($context['options'][$i]);
599 611
 			continue;
600
-		}
601
-		elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage']))
612
+		} elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage']))
602 613
 		{
603 614
 			unset($context['options'][$i]);
604 615
 			continue;
605 616
 		}
606 617
 
607
-		if (!isset($setting['type']) || $setting['type'] == 'bool')
608
-			$context['options'][$i]['type'] = 'checkbox';
609
-		elseif ($setting['type'] == 'int' || $setting['type'] == 'integer')
610
-			$context['options'][$i]['type'] = 'number';
611
-		elseif ($setting['type'] == 'string')
612
-			$context['options'][$i]['type'] = 'text';
618
+		if (!isset($setting['type']) || $setting['type'] == 'bool') {
619
+					$context['options'][$i]['type'] = 'checkbox';
620
+		} elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') {
621
+					$context['options'][$i]['type'] = 'number';
622
+		} elseif ($setting['type'] == 'string') {
623
+					$context['options'][$i]['type'] = 'text';
624
+		}
613 625
 
614
-		if (isset($setting['options']))
615
-			$context['options'][$i]['type'] = 'list';
626
+		if (isset($setting['options'])) {
627
+					$context['options'][$i]['type'] = 'list';
628
+		}
616 629
 
617 630
 		$context['options'][$i]['value'] = !isset($context['theme_options'][$setting['id']]) ? '' : $context['theme_options'][$setting['id']];
618 631
 	}
@@ -637,8 +650,9 @@  discard block
 block discarded – undo
637 650
 {
638 651
 	global $txt, $context, $settings, $modSettings, $smcFunc;
639 652
 
640
-	if (empty($_GET['th']) && empty($_GET['id']))
641
-		return ThemeAdmin();
653
+	if (empty($_GET['th']) && empty($_GET['id'])) {
654
+			return ThemeAdmin();
655
+	}
642 656
 
643 657
 	$_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id'];
644 658
 
@@ -649,8 +663,9 @@  discard block
 block discarded – undo
649 663
 	isAllowedTo('admin_forum');
650 664
 
651 665
 	// Validate inputs/user.
652
-	if (empty($_GET['th']))
653
-		fatal_lang_error('no_theme', false);
666
+	if (empty($_GET['th'])) {
667
+			fatal_lang_error('no_theme', false);
668
+	}
654 669
 
655 670
 	// Fetch the smiley sets...
656 671
 	$sets = explode(',', 'none,' . $modSettings['smiley_sets_known']);
@@ -658,8 +673,9 @@  discard block
 block discarded – undo
658 673
 	$context['smiley_sets'] = array(
659 674
 		'' => $txt['smileys_no_default']
660 675
 	);
661
-	foreach ($sets as $i => $set)
662
-		$context['smiley_sets'][$set] = $smcFunc['htmlspecialchars']($set_names[$i]);
676
+	foreach ($sets as $i => $set) {
677
+			$context['smiley_sets'][$set] = $smcFunc['htmlspecialchars']($set_names[$i]);
678
+	}
663 679
 
664 680
 	$old_id = $settings['theme_id'];
665 681
 	$old_settings = $settings;
@@ -684,8 +700,9 @@  discard block
 block discarded – undo
684 700
 	if (file_exists($settings['theme_dir'] . '/index.template.php'))
685 701
 	{
686 702
 		$file_contents = implode('', file($settings['theme_dir'] . '/index.template.php'));
687
-		if (preg_match('~\$settings\[\'theme_variants\'\]\s*=(.+?);~', $file_contents, $matches))
688
-				eval('global $settings;' . $matches[0]);
703
+		if (preg_match('~\$settings\[\'theme_variants\'\]\s*=(.+?);~', $file_contents, $matches)) {
704
+						eval('global $settings;' . $matches[0]);
705
+		}
689 706
 	}
690 707
 
691 708
 	// Submitting!
@@ -694,37 +711,45 @@  discard block
 block discarded – undo
694 711
 		checkSession();
695 712
 		validateToken('admin-sts');
696 713
 
697
-		if (empty($_POST['options']))
698
-			$_POST['options'] = array();
699
-		if (empty($_POST['default_options']))
700
-			$_POST['default_options'] = array();
714
+		if (empty($_POST['options'])) {
715
+					$_POST['options'] = array();
716
+		}
717
+		if (empty($_POST['default_options'])) {
718
+					$_POST['default_options'] = array();
719
+		}
701 720
 
702 721
 		// Make sure items are cast correctly.
703 722
 		foreach ($context['theme_settings'] as $item)
704 723
 		{
705 724
 			// Disregard this item if this is just a separator.
706
-			if (!is_array($item))
707
-				continue;
725
+			if (!is_array($item)) {
726
+							continue;
727
+			}
708 728
 
709 729
 			foreach (array('options', 'default_options') as $option)
710 730
 			{
711
-				if (!isset($_POST[$option][$item['id']]))
712
-					continue;
731
+				if (!isset($_POST[$option][$item['id']])) {
732
+									continue;
733
+				}
713 734
 				// Checkbox.
714
-				elseif (empty($item['type']))
715
-					$_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0;
735
+				elseif (empty($item['type'])) {
736
+									$_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0;
737
+				}
716 738
 				// Number
717
-				elseif ($item['type'] == 'number')
718
-					$_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']];
739
+				elseif ($item['type'] == 'number') {
740
+									$_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']];
741
+				}
719 742
 			}
720 743
 		}
721 744
 
722 745
 		// Set up the sql query.
723 746
 		$inserts = array();
724
-		foreach ($_POST['options'] as $opt => $val)
725
-			$inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val);
726
-		foreach ($_POST['default_options'] as $opt => $val)
727
-			$inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val);
747
+		foreach ($_POST['options'] as $opt => $val) {
748
+					$inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val);
749
+		}
750
+		foreach ($_POST['default_options'] as $opt => $val) {
751
+					$inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val);
752
+		}
728 753
 		// If we're actually inserting something..
729 754
 		if (!empty($inserts))
730 755
 		{
@@ -750,8 +775,9 @@  discard block
 block discarded – undo
750 775
 
751 776
 	foreach ($settings as $setting => $dummy)
752 777
 	{
753
-		if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs')))
754
-			$settings[$setting] = htmlspecialchars__recursive($settings[$setting]);
778
+		if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs'))) {
779
+					$settings[$setting] = htmlspecialchars__recursive($settings[$setting]);
780
+		}
755 781
 	}
756 782
 
757 783
 	$context['settings'] = $context['theme_settings'];
@@ -760,18 +786,21 @@  discard block
 block discarded – undo
760 786
 	foreach ($context['settings'] as $i => $setting)
761 787
 	{
762 788
 		// Separators are dummies, so leave them alone.
763
-		if (!is_array($setting))
764
-			continue;
789
+		if (!is_array($setting)) {
790
+					continue;
791
+		}
765 792
 
766
-		if (!isset($setting['type']) || $setting['type'] == 'bool')
767
-			$context['settings'][$i]['type'] = 'checkbox';
768
-		elseif ($setting['type'] == 'int' || $setting['type'] == 'integer')
769
-			$context['settings'][$i]['type'] = 'number';
770
-		elseif ($setting['type'] == 'string')
771
-			$context['settings'][$i]['type'] = 'text';
793
+		if (!isset($setting['type']) || $setting['type'] == 'bool') {
794
+					$context['settings'][$i]['type'] = 'checkbox';
795
+		} elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') {
796
+					$context['settings'][$i]['type'] = 'number';
797
+		} elseif ($setting['type'] == 'string') {
798
+					$context['settings'][$i]['type'] = 'text';
799
+		}
772 800
 
773
-		if (isset($setting['options']))
774
-			$context['settings'][$i]['type'] = 'list';
801
+		if (isset($setting['options'])) {
802
+					$context['settings'][$i]['type'] = 'list';
803
+		}
775 804
 
776 805
 		$context['settings'][$i]['value'] = !isset($settings[$setting['id']]) ? '' : $settings[$setting['id']];
777 806
 	}
@@ -824,8 +853,9 @@  discard block
 block discarded – undo
824 853
 	$themeID = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id'];
825 854
 
826 855
 	// You can't delete the default theme!
827
-	if ($themeID == 1)
828
-		fatal_lang_error('no_access', false);
856
+	if ($themeID == 1) {
857
+			fatal_lang_error('no_access', false);
858
+	}
829 859
 
830 860
 	$theme_info = get_single_theme($themeID);
831 861
 
@@ -833,8 +863,9 @@  discard block
 block discarded – undo
833 863
 	remove_theme($themeID);
834 864
 
835 865
 	// And remove all its files and folders too.
836
-	if (!empty($theme_info) && !empty($theme_info['theme_dir']))
837
-		remove_dir($theme_info['theme_dir']);
866
+	if (!empty($theme_info) && !empty($theme_info['theme_dir'])) {
867
+			remove_dir($theme_info['theme_dir']);
868
+	}
838 869
 
839 870
 	// Go back to the list page.
840 871
 	redirectexit('action=admin;area=theme;sa=list;' . $context['session_var'] . '=' . $context['session_id'] .';done=removing');
@@ -859,12 +890,14 @@  discard block
 block discarded – undo
859 890
 	$enableThemes = explode(',', $modSettings['enableThemes']);
860 891
 
861 892
 	// Are we disabling it?
862
-	if (isset($_GET['disabled']))
863
-		$enableThemes = array_diff($enableThemes, array($themeID));
893
+	if (isset($_GET['disabled'])) {
894
+			$enableThemes = array_diff($enableThemes, array($themeID));
895
+	}
864 896
 
865 897
 	// Nope? then enable it!
866
-	else
867
-		$enableThemes[] = (string) $themeID;
898
+	else {
899
+			$enableThemes[] = (string) $themeID;
900
+	}
868 901
 
869 902
 	// Update the setting.
870 903
 	$enableThemes = strtr(implode(',', $enableThemes), array(',,' => ','));
@@ -899,18 +932,21 @@  discard block
 block discarded – undo
899 932
 
900 933
 	$_SESSION['id_theme'] = 0;
901 934
 
902
-	if (isset($_GET['id']))
903
-		$_GET['th'] = $_GET['id'];
935
+	if (isset($_GET['id'])) {
936
+			$_GET['th'] = $_GET['id'];
937
+	}
904 938
 
905 939
 	// Saving a variant cause JS doesn't work - pretend it did ;)
906 940
 	if (isset($_POST['save']))
907 941
 	{
908 942
 		// Which theme?
909
-		foreach ($_POST['save'] as $k => $v)
910
-			$_GET['th'] = (int) $k;
943
+		foreach ($_POST['save'] as $k => $v) {
944
+					$_GET['th'] = (int) $k;
945
+		}
911 946
 
912
-		if (isset($_POST['vrt'][$k]))
913
-			$_GET['vrt'] = $_POST['vrt'][$k];
947
+		if (isset($_POST['vrt'][$k])) {
948
+					$_GET['vrt'] = $_POST['vrt'][$k];
949
+		}
914 950
 	}
915 951
 
916 952
 	// Have we made a decision, or are we just browsing?
@@ -988,8 +1024,9 @@  discard block
 block discarded – undo
988 1024
 		else
989 1025
 		{
990 1026
 			// The forum's default theme is always 0 and we
991
-			if (isset($_GET['th']) && $_GET['th'] == 0)
992
-					$_GET['th'] = $modSettings['theme_guests'];
1027
+			if (isset($_GET['th']) && $_GET['th'] == 0) {
1028
+								$_GET['th'] = $modSettings['theme_guests'];
1029
+			}
993 1030
 
994 1031
 			updateMemberData((int) $_REQUEST['u'], array('id_theme' => (int) $_GET['th']));
995 1032
 
@@ -1003,8 +1040,9 @@  discard block
 block discarded – undo
1003 1040
 				);
1004 1041
 				cache_put_data('theme_settings-' . $_GET['th'] . ':' . (int) $_REQUEST['u'], null, 90);
1005 1042
 
1006
-				if ($user_info['id'] == $_REQUEST['u'])
1007
-					$_SESSION['id_variant'] = 0;
1043
+				if ($user_info['id'] == $_REQUEST['u']) {
1044
+									$_SESSION['id_variant'] = 0;
1045
+				}
1008 1046
 			}
1009 1047
 
1010 1048
 			redirectexit('action=profile;u=' . (int) $_REQUEST['u'] . ';area=theme');
@@ -1073,12 +1111,13 @@  discard block
 block discarded – undo
1073 1111
 		);
1074 1112
 		while ($row = $smcFunc['db_fetch_assoc']($request))
1075 1113
 		{
1076
-			if (!isset($context['available_themes'][$row['id_theme']]))
1077
-				$context['available_themes'][$row['id_theme']] = array(
1114
+			if (!isset($context['available_themes'][$row['id_theme']])) {
1115
+							$context['available_themes'][$row['id_theme']] = array(
1078 1116
 					'id' => $row['id_theme'],
1079 1117
 					'selected' => $context['current_theme'] == $row['id_theme'],
1080 1118
 					'num_users' => 0
1081 1119
 				);
1120
+			}
1082 1121
 			$context['available_themes'][$row['id_theme']][$row['variable']] = $row['value'];
1083 1122
 		}
1084 1123
 		$smcFunc['db_free_result']($request);
@@ -1091,9 +1130,9 @@  discard block
 block discarded – undo
1091 1130
 			'num_users' => 0
1092 1131
 		);
1093 1132
 		$guest_theme = 0;
1133
+	} else {
1134
+			$guest_theme = $modSettings['theme_guests'];
1094 1135
 	}
1095
-	else
1096
-		$guest_theme = $modSettings['theme_guests'];
1097 1136
 
1098 1137
 	$request = $smcFunc['db_query']('', '
1099 1138
 		SELECT id_theme, COUNT(*) AS the_count
@@ -1106,15 +1145,17 @@  discard block
 block discarded – undo
1106 1145
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1107 1146
 	{
1108 1147
 		// Figure out which theme it is they are REALLY using.
1109
-		if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',',$modSettings['knownThemes'])))
1110
-			$row['id_theme'] = $guest_theme;
1111
-		elseif (empty($modSettings['theme_allow']))
1112
-			$row['id_theme'] = $guest_theme;
1148
+		if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',',$modSettings['knownThemes']))) {
1149
+					$row['id_theme'] = $guest_theme;
1150
+		} elseif (empty($modSettings['theme_allow'])) {
1151
+					$row['id_theme'] = $guest_theme;
1152
+		}
1113 1153
 
1114
-		if (isset($context['available_themes'][$row['id_theme']]))
1115
-			$context['available_themes'][$row['id_theme']]['num_users'] += $row['the_count'];
1116
-		else
1117
-			$context['available_themes'][$guest_theme]['num_users'] += $row['the_count'];
1154
+		if (isset($context['available_themes'][$row['id_theme']])) {
1155
+					$context['available_themes'][$row['id_theme']]['num_users'] += $row['the_count'];
1156
+		} else {
1157
+					$context['available_themes'][$guest_theme]['num_users'] += $row['the_count'];
1158
+		}
1118 1159
 	}
1119 1160
 	$smcFunc['db_free_result']($request);
1120 1161
 
@@ -1133,8 +1174,9 @@  discard block
 block discarded – undo
1133 1174
 				'id_member' => isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? array(-1, $context['current_member']) : array(-1),
1134 1175
 			)
1135 1176
 		);
1136
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1137
-			$variant_preferences[$row['id_theme']] = $row['value'];
1177
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1178
+					$variant_preferences[$row['id_theme']] = $row['value'];
1179
+		}
1138 1180
 		$smcFunc['db_free_result']($request);
1139 1181
 	}
1140 1182
 
@@ -1145,17 +1187,18 @@  discard block
 block discarded – undo
1145 1187
 	foreach ($context['available_themes'] as $id_theme => $theme_data)
1146 1188
 	{
1147 1189
 		// Don't try to load the forum or board default theme's data... it doesn't have any!
1148
-		if ($id_theme == 0)
1149
-			continue;
1190
+		if ($id_theme == 0) {
1191
+					continue;
1192
+		}
1150 1193
 
1151 1194
 		// The thumbnail needs the correct path.
1152 1195
 		$settings['images_url'] = &$theme_data['images_url'];
1153 1196
 
1154
-		if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php'))
1155
-			include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php');
1156
-		elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php'))
1157
-			include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php');
1158
-		else
1197
+		if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php')) {
1198
+					include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php');
1199
+		} elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php')) {
1200
+					include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php');
1201
+		} else
1159 1202
 		{
1160 1203
 			$txt['theme_thumbnail_href'] = $theme_data['images_url'] . '/thumbnail.png';
1161 1204
 			$txt['theme_description'] = '';
@@ -1180,15 +1223,17 @@  discard block
 block discarded – undo
1180 1223
 					loadLanguage('Settings');
1181 1224
 
1182 1225
 					$context['available_themes'][$id_theme]['variants'] = array();
1183
-					foreach ($settings['theme_variants'] as $variant)
1184
-						$context['available_themes'][$id_theme]['variants'][$variant] = array(
1226
+					foreach ($settings['theme_variants'] as $variant) {
1227
+											$context['available_themes'][$id_theme]['variants'][$variant] = array(
1185 1228
 							'label' => isset($txt['variant_' . $variant]) ? $txt['variant_' . $variant] : $variant,
1186 1229
 							'thumbnail' => !file_exists($theme_data['theme_dir'] . '/images/thumbnail.png') || file_exists($theme_data['theme_dir'] . '/images/thumbnail_' . $variant . '.png') ? $theme_data['images_url'] . '/thumbnail_' . $variant . '.png' : ($theme_data['images_url'] . '/thumbnail.png'),
1187 1230
 						);
1231
+					}
1188 1232
 
1189 1233
 					$context['available_themes'][$id_theme]['selected_variant'] = isset($_GET['vrt']) ? $_GET['vrt'] : (!empty($variant_preferences[$id_theme]) ? $variant_preferences[$id_theme] : (!empty($settings['default_variant']) ? $settings['default_variant'] : $settings['theme_variants'][0]));
1190
-					if (!isset($context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail']))
1191
-						$context['available_themes'][$id_theme]['selected_variant'] = $settings['theme_variants'][0];
1234
+					if (!isset($context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail'])) {
1235
+											$context['available_themes'][$id_theme]['selected_variant'] = $settings['theme_variants'][0];
1236
+					}
1192 1237
 
1193 1238
 					$context['available_themes'][$id_theme]['thumbnail_href'] = $context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail'];
1194 1239
 					// Allow themes to override the text.
@@ -1204,8 +1249,9 @@  discard block
 block discarded – undo
1204 1249
 	// As long as we're not doing the default theme...
1205 1250
 	if (!isset($_REQUEST['u']) || $_REQUEST['u'] >= 0)
1206 1251
 	{
1207
-		if ($guest_theme != 0)
1208
-			$context['available_themes'][0] = $context['available_themes'][$guest_theme];
1252
+		if ($guest_theme != 0) {
1253
+					$context['available_themes'][0] = $context['available_themes'][$guest_theme];
1254
+		}
1209 1255
 
1210 1256
 		$context['available_themes'][0]['id'] = 0;
1211 1257
 		$context['available_themes'][0]['name'] = $txt['theme_forum_default'];
@@ -1254,14 +1300,16 @@  discard block
 block discarded – undo
1254 1300
 		$action = $smcFunc['htmlspecialchars'](trim($_GET['do']));
1255 1301
 
1256 1302
 		// Got any info from the specific form?
1257
-		if (!isset($_POST['save_'. $action]))
1258
-			fatal_lang_error('theme_install_no_action', false);
1303
+		if (!isset($_POST['save_'. $action])) {
1304
+					fatal_lang_error('theme_install_no_action', false);
1305
+		}
1259 1306
 
1260 1307
 		validateToken('admin-t-'. $action);
1261 1308
 
1262 1309
 		// Hopefully the themes directory is writable, or we might have a problem.
1263
-		if (!is_writable($themedir))
1264
-			fatal_lang_error('theme_install_write_error', 'critical');
1310
+		if (!is_writable($themedir)) {
1311
+					fatal_lang_error('theme_install_write_error', 'critical');
1312
+		}
1265 1313
 
1266 1314
 		// Call the function and handle the result.
1267 1315
 		$result = $subActions[$action]();
@@ -1276,9 +1324,10 @@  discard block
 block discarded – undo
1276 1324
 	}
1277 1325
 
1278 1326
 	// Nope, show a nice error.
1279
-	else
1280
-		fatal_lang_error('theme_install_no_action', false);
1281
-}
1327
+	else {
1328
+			fatal_lang_error('theme_install_no_action', false);
1329
+	}
1330
+	}
1282 1331
 
1283 1332
 /**
1284 1333
  * Installs a theme from a theme package.
@@ -1294,8 +1343,9 @@  discard block
 block discarded – undo
1294 1343
 	$dirtemp = $themedir .'/temp';
1295 1344
 
1296 1345
 	// Make sure the temp dir doesn't already exist
1297
-	if (file_exists($dirtemp))
1298
-		remove_dir($dirtemp);
1346
+	if (file_exists($dirtemp)) {
1347
+			remove_dir($dirtemp);
1348
+	}
1299 1349
 
1300 1350
 	// Create the temp dir.
1301 1351
 	mkdir($dirtemp, 0777);
@@ -1307,17 +1357,20 @@  discard block
 block discarded – undo
1307 1357
 		smf_chmod($dirtemp, '0755');
1308 1358
 
1309 1359
 		// How about now?
1310
-		if (!is_writable($dirtemp))
1311
-			fatal_lang_error('theme_install_write_error', 'critical');
1360
+		if (!is_writable($dirtemp)) {
1361
+					fatal_lang_error('theme_install_write_error', 'critical');
1362
+		}
1312 1363
 	}
1313 1364
 
1314 1365
 	// This happens when the admin session is gone and the user has to login again.
1315
-	if (!isset($_FILES) || !isset($_FILES['theme_gz']) || empty($_FILES['theme_gz']))
1316
-		redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']);
1366
+	if (!isset($_FILES) || !isset($_FILES['theme_gz']) || empty($_FILES['theme_gz'])) {
1367
+			redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']);
1368
+	}
1317 1369
 
1318 1370
 	// Another error check layer, something went wrong with the upload.
1319
-	if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0)
1320
-		fatal_lang_error('theme_install_error_file_'. $_FILES['theme_gz']['error'], false);
1371
+	if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0) {
1372
+			fatal_lang_error('theme_install_error_file_'. $_FILES['theme_gz']['error'], false);
1373
+	}
1321 1374
 
1322 1375
 	// Get the theme's name.
1323 1376
 	$name = pathinfo($_FILES['theme_gz']['name'], PATHINFO_FILENAME);
@@ -1348,11 +1401,10 @@  discard block
 block discarded – undo
1348 1401
 
1349 1402
 		// return all the info.
1350 1403
 		return $context['to_install'];
1404
+	} else {
1405
+			fatal_lang_error('theme_install_error_title', false);
1406
+	}
1351 1407
 	}
1352
-
1353
-	else
1354
-		fatal_lang_error('theme_install_error_title', false);
1355
-}
1356 1408
 
1357 1409
 /**
1358 1410
  * Makes a copy from the default theme, assigns a name for it and installs it.
@@ -1366,15 +1418,17 @@  discard block
 block discarded – undo
1366 1418
 	global $forum_version;
1367 1419
 
1368 1420
 	// There's gotta be something to work with.
1369
-	if (!isset($_REQUEST['copy']) || empty($_REQUEST['copy']))
1370
-		fatal_lang_error('theme_install_error_title', false);
1421
+	if (!isset($_REQUEST['copy']) || empty($_REQUEST['copy'])) {
1422
+			fatal_lang_error('theme_install_error_title', false);
1423
+	}
1371 1424
 
1372 1425
 	// Get a cleaner version.
1373 1426
 	$name = preg_replace('~[^A-Za-z0-9_\- ]~', '', $_REQUEST['copy']);
1374 1427
 
1375 1428
 	// Is there a theme already named like this?
1376
-	if (file_exists($themedir .'/'. $name))
1377
-		fatal_lang_error('theme_install_already_dir', false);
1429
+	if (file_exists($themedir .'/'. $name)) {
1430
+			fatal_lang_error('theme_install_already_dir', false);
1431
+	}
1378 1432
 
1379 1433
 	// This is a brand new theme so set all possible values.
1380 1434
 	$context['to_install'] = array(
@@ -1394,8 +1448,9 @@  discard block
 block discarded – undo
1394 1448
 
1395 1449
 	// Buy some time.
1396 1450
 	@set_time_limit(600);
1397
-	if (function_exists('apache_reset_timeout'))
1398
-		@apache_reset_timeout();
1451
+	if (function_exists('apache_reset_timeout')) {
1452
+			@apache_reset_timeout();
1453
+	}
1399 1454
 
1400 1455
 	// Create subdirectories for css and javascript files.
1401 1456
 	mkdir($context['to_install']['theme_dir'] . '/css', 0777);
@@ -1431,12 +1486,13 @@  discard block
 block discarded – undo
1431 1486
 
1432 1487
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1433 1488
 	{
1434
-		if ($row['variable'] == 'theme_templates')
1435
-			$theme_templates = $row['value'];
1436
-		elseif ($row['variable'] == 'theme_layers')
1437
-			$theme_layers = $row['value'];
1438
-		else
1439
-			continue;
1489
+		if ($row['variable'] == 'theme_templates') {
1490
+					$theme_templates = $row['value'];
1491
+		} elseif ($row['variable'] == 'theme_layers') {
1492
+					$theme_layers = $row['value'];
1493
+		} else {
1494
+					continue;
1495
+		}
1440 1496
 	}
1441 1497
 
1442 1498
 	$smcFunc['db_free_result']($request);
@@ -1495,12 +1551,14 @@  discard block
 block discarded – undo
1495 1551
 	global $themedir, $themeurl, $context;
1496 1552
 
1497 1553
 	// Cannot use the theme dir as a theme dir.
1498
-	if (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir))
1499
-		fatal_lang_error('theme_install_invalid_dir', false);
1554
+	if (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir)) {
1555
+			fatal_lang_error('theme_install_invalid_dir', false);
1556
+	}
1500 1557
 
1501 1558
 	// Check is there is "something" on the dir.
1502
-	elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml'))
1503
-		fatal_lang_error('theme_install_error', false);
1559
+	elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml')) {
1560
+			fatal_lang_error('theme_install_error', false);
1561
+	}
1504 1562
 
1505 1563
 	$name = basename($_REQUEST['theme_dir']);
1506 1564
 	$name = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $name);
@@ -1544,24 +1602,27 @@  discard block
 block discarded – undo
1544 1602
 	}
1545 1603
 
1546 1604
 	// Any special layers?
1547
-	if (isset($settings['catch_action']['layers']))
1548
-		$context['template_layers'] = $settings['catch_action']['layers'];
1605
+	if (isset($settings['catch_action']['layers'])) {
1606
+			$context['template_layers'] = $settings['catch_action']['layers'];
1607
+	}
1549 1608
 
1550 1609
 	// Any function to call?
1551 1610
 	if (isset($settings['catch_action']['function']))
1552 1611
 	{
1553 1612
 		$hook = $settings['catch_action']['function'];
1554 1613
 
1555
-		if (!isset($settings['catch_action']['filename']))
1556
-			$settings['catch_action']['filename'] = '';
1614
+		if (!isset($settings['catch_action']['filename'])) {
1615
+					$settings['catch_action']['filename'] = '';
1616
+		}
1557 1617
 
1558 1618
 		add_integration_function('integrate_wrap_action', $hook, false, $settings['catch_action']['filename'], false);
1559 1619
 		call_integration_hook('integrate_wrap_action');
1560 1620
 	}
1561 1621
 	// And finally, the main sub template ;).
1562
-	if (isset($settings['catch_action']['sub_template']))
1563
-		$context['sub_template'] = $settings['catch_action']['sub_template'];
1564
-}
1622
+	if (isset($settings['catch_action']['sub_template'])) {
1623
+			$context['sub_template'] = $settings['catch_action']['sub_template'];
1624
+	}
1625
+	}
1565 1626
 
1566 1627
 /**
1567 1628
  * Set an option via javascript.
@@ -1580,12 +1641,14 @@  discard block
 block discarded – undo
1580 1641
 	checkSession('get');
1581 1642
 
1582 1643
 	// This good-for-nothing pixel is being used to keep the session alive.
1583
-	if (empty($_GET['var']) || !isset($_GET['val']))
1584
-		redirectexit($settings['images_url'] . '/blank.png');
1644
+	if (empty($_GET['var']) || !isset($_GET['val'])) {
1645
+			redirectexit($settings['images_url'] . '/blank.png');
1646
+	}
1585 1647
 
1586 1648
 	// Sorry, guests can't go any further than this.
1587
-	if ($user_info['is_guest'] || $user_info['id'] == 0)
1588
-		obExit(false);
1649
+	if ($user_info['is_guest'] || $user_info['id'] == 0) {
1650
+			obExit(false);
1651
+	}
1589 1652
 
1590 1653
 	$reservedVars = array(
1591 1654
 		'actual_theme_url',
@@ -1608,8 +1671,9 @@  discard block
 block discarded – undo
1608 1671
 	);
1609 1672
 
1610 1673
 	// Can't change reserved vars.
1611
-	if (in_array(strtolower($_GET['var']), $reservedVars))
1612
-		redirectexit($settings['images_url'] . '/blank.png');
1674
+	if (in_array(strtolower($_GET['var']), $reservedVars)) {
1675
+			redirectexit($settings['images_url'] . '/blank.png');
1676
+	}
1613 1677
 
1614 1678
 	// Use a specific theme?
1615 1679
 	if (isset($_GET['th']) || isset($_GET['id']))
@@ -1625,8 +1689,9 @@  discard block
 block discarded – undo
1625 1689
 	{
1626 1690
 		$options['admin_preferences'] = !empty($options['admin_preferences']) ? smf_json_decode($options['admin_preferences'], true) : array();
1627 1691
 		// New thingy...
1628
-		if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5)
1629
-			$options['admin_preferences'][$_GET['admin_key']] = $_GET['val'];
1692
+		if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5) {
1693
+					$options['admin_preferences'][$_GET['admin_key']] = $_GET['val'];
1694
+		}
1630 1695
 
1631 1696
 		// Change the value to be something nice,
1632 1697
 		$_GET['val'] = json_encode($options['admin_preferences']);
@@ -1656,8 +1721,9 @@  discard block
 block discarded – undo
1656 1721
 	global $context, $scripturl, $boarddir, $smcFunc, $txt;
1657 1722
 
1658 1723
 	// @todo Should this be removed?
1659
-	if (isset($_REQUEST['preview']))
1660
-		die('die() with fire');
1724
+	if (isset($_REQUEST['preview'])) {
1725
+			die('die() with fire');
1726
+	}
1661 1727
 
1662 1728
 	isAllowedTo('admin_forum');
1663 1729
 	loadTemplate('Themes');
@@ -1671,11 +1737,11 @@  discard block
 block discarded – undo
1671 1737
 		foreach ($context['themes'] as $key => $theme)
1672 1738
 		{
1673 1739
 			// There has to be a Settings template!
1674
-			if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css'))
1675
-				unset($context['themes'][$key]);
1676
-
1677
-			else
1678
-				$context['themes'][$key]['can_edit_style'] = file_exists($theme['theme_dir'] . '/css/index.css');
1740
+			if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css')) {
1741
+							unset($context['themes'][$key]);
1742
+			} else {
1743
+							$context['themes'][$key]['can_edit_style'] = file_exists($theme['theme_dir'] . '/css/index.css');
1744
+			}
1679 1745
 		}
1680 1746
 
1681 1747
 		$context['sub_template'] = 'edit_list';
@@ -1690,22 +1756,24 @@  discard block
 block discarded – undo
1690 1756
 	$context['theme_id'] = $currentTheme['id'];
1691 1757
 	$context['browse_title'] = sprintf($txt['themeadmin_browsing_theme'], $currentTheme['name']);
1692 1758
 
1693
-	if (!file_exists($currentTheme['theme_dir'] . '/index.template.php') && !file_exists($currentTheme['theme_dir'] . '/css/index.css'))
1694
-		fatal_lang_error('theme_edit_missing', false);
1759
+	if (!file_exists($currentTheme['theme_dir'] . '/index.template.php') && !file_exists($currentTheme['theme_dir'] . '/css/index.css')) {
1760
+			fatal_lang_error('theme_edit_missing', false);
1761
+	}
1695 1762
 
1696 1763
 	if (!isset($_REQUEST['filename']))
1697 1764
 	{
1698 1765
 		if (isset($_GET['directory']))
1699 1766
 		{
1700
-			if (substr($_GET['directory'], 0, 1) == '.')
1701
-				$_GET['directory'] = '';
1702
-			else
1767
+			if (substr($_GET['directory'], 0, 1) == '.') {
1768
+							$_GET['directory'] = '';
1769
+			} else
1703 1770
 			{
1704 1771
 				$_GET['directory'] = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $_GET['directory']);
1705 1772
 
1706 1773
 				$temp = realpath($currentTheme['theme_dir'] . '/' . $_GET['directory']);
1707
-				if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir']))
1708
-					$_GET['directory'] = '';
1774
+				if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) {
1775
+									$_GET['directory'] = '';
1776
+				}
1709 1777
 			}
1710 1778
 		}
1711 1779
 
@@ -1724,37 +1792,39 @@  discard block
 block discarded – undo
1724 1792
 				'href' => $scripturl . '?action=admin;area=theme;th=' . $_GET['th'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=edit;directory=' . $temp,
1725 1793
 				'size' => '',
1726 1794
 			));
1795
+		} else {
1796
+					$context['theme_files'] = get_file_listing($currentTheme['theme_dir'], '');
1727 1797
 		}
1728
-		else
1729
-			$context['theme_files'] = get_file_listing($currentTheme['theme_dir'], '');
1730 1798
 
1731 1799
 		$context['sub_template'] = 'edit_browse';
1732 1800
 
1733 1801
 		return;
1734
-	}
1735
-	else
1802
+	} else
1736 1803
 	{
1737
-		if (substr($_REQUEST['filename'], 0, 1) == '.')
1738
-			$_REQUEST['filename'] = '';
1739
-		else
1804
+		if (substr($_REQUEST['filename'], 0, 1) == '.') {
1805
+					$_REQUEST['filename'] = '';
1806
+		} else
1740 1807
 		{
1741 1808
 			$_REQUEST['filename'] = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $_REQUEST['filename']);
1742 1809
 
1743 1810
 			$temp = realpath($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']);
1744
-			if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir']))
1745
-				$_REQUEST['filename'] = '';
1811
+			if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) {
1812
+							$_REQUEST['filename'] = '';
1813
+			}
1746 1814
 		}
1747 1815
 
1748
-		if (empty($_REQUEST['filename']))
1749
-			fatal_lang_error('theme_edit_missing', false);
1816
+		if (empty($_REQUEST['filename'])) {
1817
+					fatal_lang_error('theme_edit_missing', false);
1818
+		}
1750 1819
 	}
1751 1820
 
1752 1821
 	if (isset($_POST['save']))
1753 1822
 	{
1754 1823
 		if (checkSession('post', '', false) == '' && validateToken('admin-te-' . md5($_GET['th'] . '-' . $_REQUEST['filename']), 'post', false) == true)
1755 1824
 		{
1756
-			if (is_array($_POST['entire_file']))
1757
-				$_POST['entire_file'] = implode("\n", $_POST['entire_file']);
1825
+			if (is_array($_POST['entire_file'])) {
1826
+							$_POST['entire_file'] = implode("\n", $_POST['entire_file']);
1827
+			}
1758 1828
 
1759 1829
 			$_POST['entire_file'] = rtrim(strtr($_POST['entire_file'], array("\r" => '', '   ' => "\t")));
1760 1830
 
@@ -1766,10 +1836,11 @@  discard block
 block discarded – undo
1766 1836
 				fclose($fp);
1767 1837
 
1768 1838
 				$error = @file_get_contents($currentTheme['theme_url'] . '/tmp_' . session_id() . '.php');
1769
-				if (preg_match('~ <b>(\d+)</b><br( /)?' . '>$~i', $error) != 0)
1770
-					$error_file = $currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php';
1771
-				else
1772
-					unlink($currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php');
1839
+				if (preg_match('~ <b>(\d+)</b><br( /)?' . '>$~i', $error) != 0) {
1840
+									$error_file = $currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php';
1841
+				} else {
1842
+									unlink($currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php');
1843
+				}
1773 1844
 			}
1774 1845
 
1775 1846
 			if (!isset($error_file))
@@ -1790,10 +1861,11 @@  discard block
 block discarded – undo
1790 1861
 			$context['sub_template'] = 'edit_file';
1791 1862
 
1792 1863
 			// Recycle the submitted data.
1793
-			if (is_array($_POST['entire_file']))
1794
-				$context['entire_file'] = $smcFunc['htmlspecialchars'](implode("\n", $_POST['entire_file']));
1795
-			else
1796
-				$context['entire_file'] = $smcFunc['htmlspecialchars']($_POST['entire_file']);
1864
+			if (is_array($_POST['entire_file'])) {
1865
+							$context['entire_file'] = $smcFunc['htmlspecialchars'](implode("\n", $_POST['entire_file']));
1866
+			} else {
1867
+							$context['entire_file'] = $smcFunc['htmlspecialchars']($_POST['entire_file']);
1868
+			}
1797 1869
 
1798 1870
 			$context['edit_filename'] = $smcFunc['htmlspecialchars']($_POST['filename']);
1799 1871
 
@@ -1816,17 +1888,17 @@  discard block
 block discarded – undo
1816 1888
 		$context['sub_template'] = 'edit_style';
1817 1889
 
1818 1890
 		$context['entire_file'] = $smcFunc['htmlspecialchars'](strtr(file_get_contents($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']), array("\t" => '   ')));
1819
-	}
1820
-	elseif (substr($_REQUEST['filename'], -13) == '.template.php')
1891
+	} elseif (substr($_REQUEST['filename'], -13) == '.template.php')
1821 1892
 	{
1822 1893
 		$context['sub_template'] = 'edit_template';
1823 1894
 
1824
-		if (!isset($error_file))
1825
-			$file_data = file($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']);
1826
-		else
1895
+		if (!isset($error_file)) {
1896
+					$file_data = file($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']);
1897
+		} else
1827 1898
 		{
1828
-			if (preg_match('~(<b>.+?</b>:.+?<b>).+?(</b>.+?<b>\d+</b>)<br( /)?' . '>$~i', $error, $match) != 0)
1829
-				$context['parse_error'] = $match[1] . $_REQUEST['filename'] . $match[2];
1899
+			if (preg_match('~(<b>.+?</b>:.+?<b>).+?(</b>.+?<b>\d+</b>)<br( /)?' . '>$~i', $error, $match) != 0) {
1900
+							$context['parse_error'] = $match[1] . $_REQUEST['filename'] . $match[2];
1901
+			}
1830 1902
 			$file_data = file($error_file);
1831 1903
 			unlink($error_file);
1832 1904
 		}
@@ -1840,8 +1912,9 @@  discard block
 block discarded – undo
1840 1912
 				// Try to format the functions a little nicer...
1841 1913
 				$context['file_parts'][$j]['data'] = trim($context['file_parts'][$j]['data']) . "\n";
1842 1914
 
1843
-				if (empty($context['file_parts'][$j]['lines']))
1844
-					unset($context['file_parts'][$j]);
1915
+				if (empty($context['file_parts'][$j]['lines'])) {
1916
+									unset($context['file_parts'][$j]);
1917
+				}
1845 1918
 				$context['file_parts'][++$j] = array('lines' => 0, 'line' => $i + 1, 'data' => '');
1846 1919
 			}
1847 1920
 
@@ -1850,8 +1923,7 @@  discard block
 block discarded – undo
1850 1923
 		}
1851 1924
 
1852 1925
 		$context['entire_file'] = $smcFunc['htmlspecialchars'](strtr(implode('', $file_data), array("\t" => '   ')));
1853
-	}
1854
-	else
1926
+	} else
1855 1927
 	{
1856 1928
 		$context['sub_template'] = 'edit_file';
1857 1929
 
@@ -1877,8 +1949,9 @@  discard block
 block discarded – undo
1877 1949
 
1878 1950
 	$_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id'];
1879 1951
 
1880
-	if (empty($_GET['th']))
1881
-		fatal_lang_error('theme_install_invalid_id');
1952
+	if (empty($_GET['th'])) {
1953
+			fatal_lang_error('theme_install_invalid_id');
1954
+	}
1882 1955
 
1883 1956
 	// Get the theme info.
1884 1957
 	$theme = get_single_theme($_GET['th']);
@@ -1886,25 +1959,24 @@  discard block
 block discarded – undo
1886 1959
 
1887 1960
 	if (isset($_REQUEST['template']) && preg_match('~[\./\\\\:\0]~', $_REQUEST['template']) == 0)
1888 1961
 	{
1889
-		if (file_exists($settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php'))
1890
-			$filename = $settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php';
1891
-
1892
-		else
1893
-			fatal_lang_error('no_access', false);
1962
+		if (file_exists($settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php')) {
1963
+					$filename = $settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php';
1964
+		} else {
1965
+					fatal_lang_error('no_access', false);
1966
+		}
1894 1967
 
1895 1968
 		$fp = fopen($theme['theme_dir'] . '/' . $_REQUEST['template'] . '.template.php', 'w');
1896 1969
 		fwrite($fp, file_get_contents($filename));
1897 1970
 		fclose($fp);
1898 1971
 
1899 1972
 		redirectexit('action=admin;area=theme;th=' . $context['theme_id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=copy');
1900
-	}
1901
-	elseif (isset($_REQUEST['lang_file']) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $_REQUEST['lang_file']) != 0)
1973
+	} elseif (isset($_REQUEST['lang_file']) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $_REQUEST['lang_file']) != 0)
1902 1974
 	{
1903
-		if (file_exists($settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php'))
1904
-			$filename = $settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php';
1905
-
1906
-		else
1907
-			fatal_lang_error('no_access', false);
1975
+		if (file_exists($settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php')) {
1976
+					$filename = $settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php';
1977
+		} else {
1978
+					fatal_lang_error('no_access', false);
1979
+		}
1908 1980
 
1909 1981
 		$fp = fopen($theme['theme_dir'] . '/languages/' . $_REQUEST['lang_file'] . '.php', 'w');
1910 1982
 		fwrite($fp, file_get_contents($filename));
@@ -1919,16 +1991,18 @@  discard block
 block discarded – undo
1919 1991
 	$dir = dir($settings['default_theme_dir']);
1920 1992
 	while ($entry = $dir->read())
1921 1993
 	{
1922
-		if (substr($entry, -13) == '.template.php')
1923
-			$templates[] = substr($entry, 0, -13);
1994
+		if (substr($entry, -13) == '.template.php') {
1995
+					$templates[] = substr($entry, 0, -13);
1996
+		}
1924 1997
 	}
1925 1998
 	$dir->close();
1926 1999
 
1927 2000
 	$dir = dir($settings['default_theme_dir'] . '/languages');
1928 2001
 	while ($entry = $dir->read())
1929 2002
 	{
1930
-		if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches))
1931
-			$lang_files[] = $matches[1];
2003
+		if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches)) {
2004
+					$lang_files[] = $matches[1];
2005
+		}
1932 2006
 	}
1933 2007
 	$dir->close();
1934 2008
 
@@ -1936,21 +2010,23 @@  discard block
 block discarded – undo
1936 2010
 	natcasesort($lang_files);
1937 2011
 
1938 2012
 	$context['available_templates'] = array();
1939
-	foreach ($templates as $template)
1940
-		$context['available_templates'][$template] = array(
2013
+	foreach ($templates as $template) {
2014
+			$context['available_templates'][$template] = array(
1941 2015
 			'filename' => $template . '.template.php',
1942 2016
 			'value' => $template,
1943 2017
 			'already_exists' => false,
1944 2018
 			'can_copy' => is_writable($theme['theme_dir']),
1945 2019
 		);
2020
+	}
1946 2021
 	$context['available_language_files'] = array();
1947
-	foreach ($lang_files as $file)
1948
-		$context['available_language_files'][$file] = array(
2022
+	foreach ($lang_files as $file) {
2023
+			$context['available_language_files'][$file] = array(
1949 2024
 			'filename' => $file . '.php',
1950 2025
 			'value' => $file,
1951 2026
 			'already_exists' => false,
1952 2027
 			'can_copy' => file_exists($theme['theme_dir'] . '/languages') ? is_writable($theme['theme_dir'] . '/languages') : is_writable($theme['theme_dir']),
1953 2028
 		);
2029
+	}
1954 2030
 
1955 2031
 	$dir = dir($theme['theme_dir']);
1956 2032
 	while ($entry = $dir->read())
Please login to merge, or discard this patch.
Sources/DbSearch-postgresql.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -37,12 +37,12 @@  discard block
 block discarded – undo
37 37
 	$version = $smcFunc['db_get_version']();
38 38
 	// if we got a Beta Version
39 39
 	if (stripos($version, 'beta') !== false)
40
-		$version = substr($version, 0, stripos($version, 'beta')).'.0';
40
+		$version = substr($version, 0, stripos($version, 'beta')) . '.0';
41 41
 	// or RC
42 42
 	if (stripos($version, 'rc') !== false)
43
-		$version = substr($version, 0, stripos($version, 'rc')).'.0';
43
+		$version = substr($version, 0, stripos($version, 'rc')) . '.0';
44 44
 
45
-	if (version_compare($version,'9.5.0','>='))
45
+	if (version_compare($version, '9.5.0', '>='))
46 46
 		$smcFunc['db_support_ignore'] = true;
47 47
 }
48 48
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
  */
55 55
 function smf_db_search_support($search_type)
56 56
 {
57
-	$supported_types = array('custom','fulltext');
57
+	$supported_types = array('custom', 'fulltext');
58 58
 
59 59
 	return in_array($search_type, $supported_types);
60 60
 }
@@ -108,9 +108,9 @@  discard block
 block discarded – undo
108 108
 	if (preg_match('~^\s*INSERT\sIGNORE~i', $db_string) != 0)
109 109
 	{
110 110
 		$db_string = preg_replace('~^\s*INSERT\sIGNORE~i', 'INSERT', $db_string);
111
-		if ($smcFunc['db_support_ignore']){
111
+		if ($smcFunc['db_support_ignore']) {
112 112
 			//pg style "INSERT INTO.... ON CONFLICT DO NOTHING"
113
-			$db_string = $db_string.' ON CONFLICT DO NOTHING';
113
+			$db_string = $db_string . ' ON CONFLICT DO NOTHING';
114 114
 		}
115 115
 		else
116 116
 		{
Please login to merge, or discard this patch.
Braces   +19 added lines, -14 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
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
  *  Add the file functions to the $smcFunc array.
@@ -23,28 +24,32 @@  discard block
 block discarded – undo
23 24
 {
24 25
 	global $smcFunc;
25 26
 
26
-	if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_search_query')
27
-		$smcFunc += array(
27
+	if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_search_query') {
28
+			$smcFunc += array(
28 29
 			'db_search_query' => 'smf_db_search_query',
29 30
 			'db_search_support' => 'smf_db_search_support',
30 31
 			'db_create_word_search' => 'smf_db_create_word_search',
31 32
 			'db_support_ignore' => false,
32 33
 		);
34
+	}
33 35
 
34 36
 	db_extend();
35 37
 
36 38
 	//pg 9.5 got ignore support
37 39
 	$version = $smcFunc['db_get_version']();
38 40
 	// if we got a Beta Version
39
-	if (stripos($version, 'beta') !== false)
40
-		$version = substr($version, 0, stripos($version, 'beta')).'.0';
41
+	if (stripos($version, 'beta') !== false) {
42
+			$version = substr($version, 0, stripos($version, 'beta')).'.0';
43
+	}
41 44
 	// or RC
42
-	if (stripos($version, 'rc') !== false)
43
-		$version = substr($version, 0, stripos($version, 'rc')).'.0';
45
+	if (stripos($version, 'rc') !== false) {
46
+			$version = substr($version, 0, stripos($version, 'rc')).'.0';
47
+	}
44 48
 
45
-	if (version_compare($version,'9.5.0','>='))
46
-		$smcFunc['db_support_ignore'] = true;
47
-}
49
+	if (version_compare($version,'9.5.0','>=')) {
50
+			$smcFunc['db_support_ignore'] = true;
51
+	}
52
+	}
48 53
 
49 54
 /**
50 55
  * This function will tell you whether this database type supports this search type.
@@ -103,16 +108,16 @@  discard block
 block discarded – undo
103 108
 		),
104 109
 	);
105 110
 
106
-	if (isset($replacements[$identifier]))
107
-		$db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string);
111
+	if (isset($replacements[$identifier])) {
112
+			$db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string);
113
+	}
108 114
 	if (preg_match('~^\s*INSERT\sIGNORE~i', $db_string) != 0)
109 115
 	{
110 116
 		$db_string = preg_replace('~^\s*INSERT\sIGNORE~i', 'INSERT', $db_string);
111 117
 		if ($smcFunc['db_support_ignore']){
112 118
 			//pg style "INSERT INTO.... ON CONFLICT DO NOTHING"
113 119
 			$db_string = $db_string.' ON CONFLICT DO NOTHING';
114
-		}
115
-		else
120
+		} else
116 121
 		{
117 122
 			// Don't error on multi-insert.
118 123
 			$db_values['db_error_skip'] = true;
Please login to merge, or discard this patch.
Sources/ManageMail.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 					'value' => $txt['mailqueue_subject'],
115 115
 				),
116 116
 				'data' => array(
117
-					'function' => function ($rowData) use ($smcFunc)
117
+					'function' => function($rowData) use ($smcFunc)
118 118
 					{
119 119
 						return $smcFunc['strlen']($rowData['subject']) > 50 ? sprintf('%1$s...', $smcFunc['htmlspecialchars']($smcFunc['substr']($rowData['subject'], 0, 47))) : $smcFunc['htmlspecialchars']($rowData['subject']);
120 120
 					},
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 					'value' => $txt['mailqueue_priority'],
149 149
 				),
150 150
 				'data' => array(
151
-					'function' => function ($rowData) use ($txt)
151
+					'function' => function($rowData) use ($txt)
152 152
 					{
153 153
 						// We probably have a text label with your priority.
154 154
 						$txtKey = sprintf('mq_mpriority_%1$s', $rowData['priority']);
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 					'value' => $txt['mailqueue_age'],
169 169
 				),
170 170
 				'data' => array(
171
-					'function' => function ($rowData)
171
+					'function' => function($rowData)
172 172
 					{
173 173
 						return time_since(time() - $rowData['time_sent']);
174 174
 					},
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 					'value' => '<input type="checkbox" onclick="invertAll(this, this.form);" class="input_check">',
185 185
 				),
186 186
 				'data' => array(
187
-					'function' => function ($rowData)
187
+					'function' => function($rowData)
188 188
 					{
189 189
 						return '<input type="checkbox" name="delete[]" value="' . $rowData['id_mail'] . '" class="input_check">';
190 190
 					},
Please login to merge, or discard this patch.
Braces   +26 added lines, -18 removed lines patch added patch discarded remove patch
@@ -15,8 +15,9 @@  discard block
 block discarded – undo
15 15
  * @version 2.1 Beta 3
16 16
  */
17 17
 
18
-if (!defined('SMF'))
18
+if (!defined('SMF')) {
19 19
 	die('No direct access...');
20
+}
20 21
 
21 22
 /**
22 23
  * Main dispatcher. This function checks permissions and passes control through to the relevant section.
@@ -245,8 +246,9 @@  discard block
 block discarded – undo
245 246
 	while ($row = $smcFunc['db_fetch_assoc']($request))
246 247
 	{
247 248
 		// Private PM/email subjects and similar shouldn't be shown in the mailbox area.
248
-		if (!empty($row['private']))
249
-			$row['subject'] = $txt['personal_message'];
249
+		if (!empty($row['private'])) {
250
+					$row['subject'] = $txt['personal_message'];
251
+		}
250 252
 
251 253
 		$mails[] = $row;
252 254
 	}
@@ -300,8 +302,9 @@  discard block
 block discarded – undo
300 302
 		$element = substr($key, strrpos($key, '_') + 1);
301 303
 		$processedBirthdayEmails[$index][$element] = $value;
302 304
 	}
303
-	foreach ($processedBirthdayEmails as $index => $dummy)
304
-		$emails[$index] = $index;
305
+	foreach ($processedBirthdayEmails as $index => $dummy) {
306
+			$emails[$index] = $index;
307
+	}
305 308
 
306 309
 	$config_vars = array(
307 310
 			// Mail queue stuff, this rocks ;)
@@ -322,8 +325,9 @@  discard block
 block discarded – undo
322 325
 
323 326
 	call_integration_hook('integrate_modify_mail_settings', array(&$config_vars));
324 327
 
325
-	if ($return_config)
326
-		return $config_vars;
328
+	if ($return_config) {
329
+			return $config_vars;
330
+	}
327 331
 
328 332
 	// Saving?
329 333
 	if (isset($_GET['save']))
@@ -398,9 +402,9 @@  discard block
 block discarded – undo
398 402
 		);
399 403
 		list ($_GET['te']) = $smcFunc['db_fetch_row']($request);
400 404
 		$smcFunc['db_free_result']($request);
405
+	} else {
406
+			$_GET['te'] = (int) $_GET['te'];
401 407
 	}
402
-	else
403
-		$_GET['te'] = (int) $_GET['te'];
404 408
 
405 409
 	$_GET['sent'] = isset($_GET['sent']) ? (int) $_GET['sent'] : 0;
406 410
 
@@ -424,12 +428,14 @@  discard block
 block discarded – undo
424 428
 
425 429
 	// Try get more time...
426 430
 	@set_time_limit(600);
427
-	if (function_exists('apache_reset_timeout'))
428
-		@apache_reset_timeout();
431
+	if (function_exists('apache_reset_timeout')) {
432
+			@apache_reset_timeout();
433
+	}
429 434
 
430 435
 	// Have we already used our maximum time?
431
-	if (time() - array_sum(explode(' ', $time_start)) < 5)
432
-		return;
436
+	if (time() - array_sum(explode(' ', $time_start)) < 5) {
437
+			return;
438
+	}
433 439
 
434 440
 	$context['continue_get_data'] = '?action=admin;area=mailqueue;sa=clear;te=' . $_GET['te'] . ';sent=' . $_GET['sent'] . ';' . $context['session_var'] . '=' . $context['session_id'];
435 441
 	$context['page_title'] = $txt['not_done_title'];
@@ -459,8 +465,9 @@  discard block
 block discarded – undo
459 465
 {
460 466
 	global $txt;
461 467
 
462
-	if ($time_diff < 0)
463
-		$time_diff = 0;
468
+	if ($time_diff < 0) {
469
+			$time_diff = 0;
470
+	}
464 471
 
465 472
 	// Just do a bit of an if fest...
466 473
 	if ($time_diff > 86400)
@@ -481,8 +488,9 @@  discard block
 block discarded – undo
481 488
 		return sprintf($minutes == 1 ? $txt['mq_minute'] : $txt['mq_minutes'], $minutes);
482 489
 	}
483 490
 	// Otherwise must be second
484
-	else
485
-		return sprintf($time_diff == 1 ? $txt['mq_second'] : $txt['mq_seconds'], $time_diff);
486
-}
491
+	else {
492
+			return sprintf($time_diff == 1 ? $txt['mq_second'] : $txt['mq_seconds'], $time_diff);
493
+	}
494
+	}
487 495
 
488 496
 ?>
Please login to merge, or discard this patch.
Sources/ManageRegistration.php 1 patch
Braces   +27 added lines, -19 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 3
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * Entrance point for the registration center, it checks permissions and forwards
@@ -31,8 +32,9 @@  discard block
 block discarded – undo
31 32
 	global $context, $txt;
32 33
 
33 34
 	// Old templates might still request this.
34
-	if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'browse')
35
-		redirectexit('action=admin;area=viewmembers;sa=browse' . (isset($_REQUEST['type']) ? ';type=' . $_REQUEST['type'] : ''));
35
+	if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'browse') {
36
+			redirectexit('action=admin;area=viewmembers;sa=browse' . (isset($_REQUEST['type']) ? ';type=' . $_REQUEST['type'] : ''));
37
+	}
36 38
 
37 39
 	$subActions = array(
38 40
 		'register' => array('AdminRegister', 'moderate_forum'),
@@ -99,9 +101,10 @@  discard block
 block discarded – undo
99 101
 		checkSession();
100 102
 		validateToken('admin-regc');
101 103
 
102
-		foreach ($_POST as $key => $value)
103
-			if (!is_array($_POST[$key]))
104
+		foreach ($_POST as $key => $value) {
105
+					if (!is_array($_POST[$key]))
104 106
 				$_POST[$key] = htmltrim__recursive(str_replace(array("\n", "\r"), '', $_POST[$key]));
107
+		}
105 108
 
106 109
 		$regOptions = array(
107 110
 			'interface' => 'admin',
@@ -161,12 +164,13 @@  discard block
 block discarded – undo
161 164
 			)
162 165
 		);
163 166
 		$context['member_groups'] = array(0 => $txt['admin_register_group_none']);
164
-		while ($row = $smcFunc['db_fetch_assoc']($request))
165
-			$context['member_groups'][$row['id_group']] = $row['group_name'];
167
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
168
+					$context['member_groups'][$row['id_group']] = $row['group_name'];
169
+		}
166 170
 		$smcFunc['db_free_result']($request);
171
+	} else {
172
+			$context['member_groups'] = array();
167 173
 	}
168
-	else
169
-		$context['member_groups'] = array();
170 174
 
171 175
 	// Basic stuff.
172 176
 	$context['sub_template'] = 'admin_register';
@@ -207,8 +211,9 @@  discard block
 block discarded – undo
207 211
 		{
208 212
 			$context['editable_agreements']['.' . $lang['filename']] = $lang['name'];
209 213
 			// Are we editing this?
210
-			if (isset($_POST['agree_lang']) && $_POST['agree_lang'] == '.' . $lang['filename'])
211
-				$context['current_agreement'] = '.' . $lang['filename'];
214
+			if (isset($_POST['agree_lang']) && $_POST['agree_lang'] == '.' . $lang['filename']) {
215
+							$context['current_agreement'] = '.' . $lang['filename'];
216
+			}
212 217
 		}
213 218
 	}
214 219
 
@@ -223,10 +228,11 @@  discard block
 block discarded – undo
223 228
 
224 229
 		updateSettings(array('requireAgreement' => !empty($_POST['requireAgreement'])));
225 230
 
226
-		if ($bytes == strlen($to_write))
227
-			$context['saved_successful'] = true;
228
-		else
229
-			$context['could_not_save'] = true;
231
+		if ($bytes == strlen($to_write)) {
232
+					$context['saved_successful'] = true;
233
+		} else {
234
+					$context['could_not_save'] = true;
235
+		}
230 236
 	}
231 237
 
232 238
 	$context['agreement'] = file_exists($boarddir . '/agreement' . $context['current_agreement'] . '.txt') ? $smcFunc['htmlspecialchars'](file_get_contents($boarddir . '/agreement' . $context['current_agreement'] . '.txt')) : '';
@@ -310,8 +316,9 @@  discard block
 block discarded – undo
310 316
 
311 317
 	call_integration_hook('integrate_modify_registration_settings', array(&$config_vars));
312 318
 
313
-	if ($return_config)
314
-		return $config_vars;
319
+	if ($return_config) {
320
+			return $config_vars;
321
+	}
315 322
 
316 323
 	// Setup the template
317 324
 	$context['sub_template'] = 'show_settings';
@@ -322,8 +329,9 @@  discard block
 block discarded – undo
322 329
 		checkSession();
323 330
 
324 331
 		// Are there some contacts missing?
325
-		if (!empty($_POST['coppaAge']) && !empty($_POST['coppaType']) && empty($_POST['coppaPost']) && empty($_POST['coppaFax']))
326
-			fatal_lang_error('admin_setting_coppa_require_contact');
332
+		if (!empty($_POST['coppaAge']) && !empty($_POST['coppaType']) && empty($_POST['coppaPost']) && empty($_POST['coppaFax'])) {
333
+					fatal_lang_error('admin_setting_coppa_require_contact');
334
+		}
327 335
 
328 336
 		// Post needs to take into account line breaks.
329 337
 		$_POST['coppaPost'] = str_replace("\n", '<br>', empty($_POST['coppaPost']) ? '' : $_POST['coppaPost']);
Please login to merge, or discard this patch.