Completed
Push — release-2.1 ( eb7be8...e2eda8 )
by Michael
26s
created
Sources/Subs-Compat.php 1 patch
Braces   +27 added lines, -19 removed lines patch added patch discarded remove patch
@@ -16,8 +16,9 @@  discard block
 block discarded – undo
16 16
  * @version 2.1 Beta 4
17 17
  */
18 18
 
19
-if (!defined('SMF'))
19
+if (!defined('SMF')) {
20 20
 	die('No direct access...');
21
+}
21 22
 
22 23
 
23 24
 /**
@@ -28,14 +29,16 @@  discard block
 block discarded – undo
28 29
 function sha1_smf($str)
29 30
 {
30 31
 	// If we have mhash loaded in, use it instead!
31
-	if (function_exists('mhash') && defined('MHASH_SHA1'))
32
-		return bin2hex(mhash(MHASH_SHA1, $str));
32
+	if (function_exists('mhash') && defined('MHASH_SHA1')) {
33
+			return bin2hex(mhash(MHASH_SHA1, $str));
34
+	}
33 35
 
34 36
 	$nblk = (strlen($str) + 8 >> 6) + 1;
35 37
 	$blks = array_pad(array(), $nblk * 16, 0);
36 38
 
37
-	for ($i = 0; $i < strlen($str); $i++)
38
-		$blks[$i >> 2] |= ord($str{$i}) << (24 - ($i % 4) * 8);
39
+	for ($i = 0; $i < strlen($str); $i++) {
40
+			$blks[$i >> 2] |= ord($str{$i}) << (24 - ($i % 4) * 8);
41
+	}
39 42
 
40 43
 	$blks[$i >> 2] |= 0x80 << (24 - ($i % 4) * 8);
41 44
 
@@ -70,10 +73,11 @@  discard block
 block discarded – undo
70 73
 
71 74
 		for ($j = 0; $j < 80; $j++)
72 75
 		{
73
-			if ($j < 16)
74
-				$w[$j] = isset($x[$i + $j]) ? $x[$i + $j] : 0;
75
-			else
76
-				$w[$j] = sha1_rol($w[$j - 3] ^ $w[$j - 8] ^ $w[$j - 14] ^ $w[$j - 16], 1);
76
+			if ($j < 16) {
77
+							$w[$j] = isset($x[$i + $j]) ? $x[$i + $j] : 0;
78
+			} else {
79
+							$w[$j] = sha1_rol($w[$j - 3] ^ $w[$j - 8] ^ $w[$j - 14] ^ $w[$j - 16], 1);
80
+			}
77 81
 
78 82
 			$t = sha1_rol($a, 5) + sha1_ft($j, $b, $c, $d) + $e + $w[$j] + sha1_kt($j);
79 83
 			$e = $d;
@@ -103,12 +107,15 @@  discard block
 block discarded – undo
103 107
  */
104 108
 function sha1_ft($t, $b, $c, $d)
105 109
 {
106
-	if ($t < 20)
107
-		return ($b & $c) | ((~$b) & $d);
108
-	if ($t < 40)
109
-		return $b ^ $c ^ $d;
110
-	if ($t < 60)
111
-		return ($b & $c) | ($b & $d) | ($c & $d);
110
+	if ($t < 20) {
111
+			return ($b & $c) | ((~$b) & $d);
112
+	}
113
+	if ($t < 40) {
114
+			return $b ^ $c ^ $d;
115
+	}
116
+	if ($t < 60) {
117
+			return ($b & $c) | ($b & $d) | ($c & $d);
118
+	}
112 119
 
113 120
 	return $b ^ $c ^ $d;
114 121
 }
@@ -132,10 +139,11 @@  discard block
 block discarded – undo
132 139
 function sha1_rol($num, $cnt)
133 140
 {
134 141
 	// Unfortunately, PHP uses unsigned 32-bit longs only.  So we have to kludge it a bit.
135
-	if ($num & 0x80000000)
136
-		$a = ($num >> 1 & 0x7fffffff) >> (31 - $cnt);
137
-	else
138
-		$a = $num >> (32 - $cnt);
142
+	if ($num & 0x80000000) {
143
+			$a = ($num >> 1 & 0x7fffffff) >> (31 - $cnt);
144
+	} else {
145
+			$a = $num >> (32 - $cnt);
146
+	}
139 147
 
140 148
 	return ($num << $cnt) | $a;
141 149
 }
Please login to merge, or discard this patch.
Sources/ManageErrors.php 1 patch
Braces   +49 added lines, -38 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 4
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
  * View the forum's error log.
@@ -30,8 +31,9 @@  discard block
 block discarded – undo
30 31
 	global $scripturl, $txt, $context, $modSettings, $user_profile, $filter, $smcFunc;
31 32
 
32 33
 	// Viewing contents of a file?
33
-	if (isset($_GET['file']))
34
-		return ViewFile();
34
+	if (isset($_GET['file'])) {
35
+			return ViewFile();
36
+	}
35 37
 
36 38
 	// Check for the administrative permission to do this.
37 39
 	isAllowedTo('admin_forum');
@@ -85,8 +87,8 @@  discard block
 block discarded – undo
85 87
 	);
86 88
 
87 89
 	// Set up the filtering...
88
-	if (isset($_GET['value'], $_GET['filter']) && isset($filters[$_GET['filter']]))
89
-		$filter = array(
90
+	if (isset($_GET['value'], $_GET['filter']) && isset($filters[$_GET['filter']])) {
91
+			$filter = array(
90 92
 			'variable' => $_GET['filter'],
91 93
 			'value' => array(
92 94
 				'sql' => in_array($_GET['filter'], array('message', 'url', 'file')) ? base64_decode(strtr($_GET['value'], array(' ' => '+'))) : $smcFunc['db_escape_wildcard_string']($_GET['value']),
@@ -94,10 +96,12 @@  discard block
 block discarded – undo
94 96
 			'href' => ';filter=' . $_GET['filter'] . ';value=' . $_GET['value'],
95 97
 			'entity' => $filters[$_GET['filter']]['txt']
96 98
 		);
99
+	}
97 100
 
98 101
 	// Deleting, are we?
99
-	if (isset($_POST['delall']) || isset($_POST['delete']))
100
-		deleteErrors();
102
+	if (isset($_POST['delall']) || isset($_POST['delete'])) {
103
+			deleteErrors();
104
+	}
101 105
 
102 106
 	// Just how many errors are there?
103 107
 	$result = $smcFunc['db_query']('', '
@@ -112,12 +116,14 @@  discard block
 block discarded – undo
112 116
 	$smcFunc['db_free_result']($result);
113 117
 
114 118
 	// If this filter is empty...
115
-	if ($num_errors == 0 && isset($filter))
116
-		redirectexit('action=admin;area=logs;sa=errorlog' . (isset($_REQUEST['desc']) ? ';desc' : ''));
119
+	if ($num_errors == 0 && isset($filter)) {
120
+			redirectexit('action=admin;area=logs;sa=errorlog' . (isset($_REQUEST['desc']) ? ';desc' : ''));
121
+	}
117 122
 
118 123
 	// Clean up start.
119
-	if (!isset($_GET['start']) || $_GET['start'] < 0)
120
-		$_GET['start'] = 0;
124
+	if (!isset($_GET['start']) || $_GET['start'] < 0) {
125
+			$_GET['start'] = 0;
126
+	}
121 127
 
122 128
 	// Do we want to reverse error listing?
123 129
 	$context['sort_direction'] = isset($_REQUEST['desc']) ? 'down' : 'up';
@@ -127,9 +133,9 @@  discard block
 block discarded – undo
127 133
 	$context['start'] = $_GET['start'];
128 134
 
129 135
 	// Update the error count
130
-	if (!isset($filter))
131
-		$context['num_errors'] = $num_errors;
132
-	else
136
+	if (!isset($filter)) {
137
+			$context['num_errors'] = $num_errors;
138
+	} else
133 139
 	{
134 140
 		// We want all errors, not just the number of filtered messages...
135 141
 		$query = $smcFunc['db_query']('', '
@@ -161,8 +167,9 @@  discard block
 block discarded – undo
161 167
 	for ($i = 0; $row = $smcFunc['db_fetch_assoc']($request); $i++)
162 168
 	{
163 169
 		$search_message = preg_replace('~&lt;span class=&quot;remove&quot;&gt;(.+?)&lt;/span&gt;~', '%', $smcFunc['db_escape_wildcard_string']($row['message']));
164
-		if ($search_message == $filter['value']['sql'])
165
-			$search_message = $smcFunc['db_escape_wildcard_string']($row['message']);
170
+		if ($search_message == $filter['value']['sql']) {
171
+					$search_message = $smcFunc['db_escape_wildcard_string']($row['message']);
172
+		}
166 173
 		$show_message = strtr(strtr(preg_replace('~&lt;span class=&quot;remove&quot;&gt;(.+?)&lt;/span&gt;~', '$1', $row['message']), array("\r" => '', '<br>' => "\n", '<' => '&lt;', '>' => '&gt;', '"' => '&quot;')), array("\n" => '<br>'));
167 174
 
168 175
 		$context['errors'][$row['id_error']] = array(
@@ -221,8 +228,9 @@  discard block
 block discarded – undo
221 228
 				'members' => count($members),
222 229
 			)
223 230
 		);
224
-		while ($row = $smcFunc['db_fetch_assoc']($request))
225
-			$members[$row['id_member']] = $row;
231
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
232
+					$members[$row['id_member']] = $row;
233
+		}
226 234
 		$smcFunc['db_free_result']($request);
227 235
 
228 236
 		// This is a guest...
@@ -254,20 +262,18 @@  discard block
 block discarded – undo
254 262
 			$id = $filter['value']['sql'];
255 263
 			loadMemberData($id, false, 'minimal');
256 264
 			$context['filter']['value']['html'] = '<a href="' . $scripturl . '?action=profile;u=' . $id . '">' . $user_profile[$id]['real_name'] . '</a>';
257
-		}
258
-		elseif ($filter['variable'] == 'url')
259
-			$context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']((substr($filter['value']['sql'], 0, 1) == '?' ? $scripturl : '') . $filter['value']['sql']), array('\_' => '_')) . '\'';
260
-		elseif ($filter['variable'] == 'message')
265
+		} elseif ($filter['variable'] == 'url') {
266
+					$context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']((substr($filter['value']['sql'], 0, 1) == '?' ? $scripturl : '') . $filter['value']['sql']), array('\_' => '_')) . '\'';
267
+		} elseif ($filter['variable'] == 'message')
261 268
 		{
262 269
 			$context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']($filter['value']['sql']), array("\n" => '<br>', '&lt;br /&gt;' => '<br>', "\t" => '&nbsp;&nbsp;&nbsp;', '\_' => '_', '\\%' => '%', '\\\\' => '\\')) . '\'';
263 270
 			$context['filter']['value']['html'] = preg_replace('~&amp;lt;span class=&amp;quot;remove&amp;quot;&amp;gt;(.+?)&amp;lt;/span&amp;gt;~', '$1', $context['filter']['value']['html']);
264
-		}
265
-		elseif ($filter['variable'] == 'error_type')
271
+		} elseif ($filter['variable'] == 'error_type')
266 272
 		{
267 273
 			$context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']($filter['value']['sql']), array("\n" => '<br>', '&lt;br /&gt;' => '<br>', "\t" => '&nbsp;&nbsp;&nbsp;', '\_' => '_', '\\%' => '%', '\\\\' => '\\')) . '\'';
274
+		} else {
275
+					$context['filter']['value']['html'] = &$filter['value']['sql'];
268 276
 		}
269
-		else
270
-			$context['filter']['value']['html'] = &$filter['value']['sql'];
271 277
 	}
272 278
 
273 279
 	$context['error_types'] = array();
@@ -308,10 +314,11 @@  discard block
 block discarded – undo
308 314
 	$context['error_types']['all']['label'] .= ' (' . $sum . ')';
309 315
 
310 316
 	// Finally, work out what is the last tab!
311
-	if (isset($context['error_types'][$sum]))
312
-		$context['error_types'][$sum]['is_last'] = true;
313
-	else
314
-		$context['error_types']['all']['is_last'] = true;
317
+	if (isset($context['error_types'][$sum])) {
318
+			$context['error_types'][$sum]['is_last'] = true;
319
+	} else {
320
+			$context['error_types']['all']['is_last'] = true;
321
+	}
315 322
 
316 323
 	// And this is pretty basic ;).
317 324
 	$context['page_title'] = $txt['errlog'];
@@ -337,21 +344,23 @@  discard block
 block discarded – undo
337 344
 	validateToken('admin-el');
338 345
 
339 346
 	// Delete all or just some?
340
-	if (isset($_POST['delall']) && !isset($filter))
341
-		$smcFunc['db_query']('truncate_table', '
347
+	if (isset($_POST['delall']) && !isset($filter)) {
348
+			$smcFunc['db_query']('truncate_table', '
342 349
 			TRUNCATE {db_prefix}log_errors',
343 350
 			array(
344 351
 			)
345 352
 		);
353
+	}
346 354
 	// Deleting all with a filter?
347
-	elseif (isset($_POST['delall']) && isset($filter))
348
-		$smcFunc['db_query']('', '
355
+	elseif (isset($_POST['delall']) && isset($filter)) {
356
+			$smcFunc['db_query']('', '
349 357
 			DELETE FROM {db_prefix}log_errors
350 358
 			WHERE ' . $filter['variable'] . ' LIKE {string:filter}',
351 359
 			array(
352 360
 				'filter' => $filter['value']['sql'],
353 361
 			)
354 362
 		);
363
+	}
355 364
 	// Just specific errors?
356 365
 	elseif (!empty($_POST['delete']))
357 366
 	{
@@ -397,15 +406,17 @@  discard block
 block discarded – undo
397 406
 	$line = isset($_REQUEST['line']) ? (int) $_REQUEST['line'] : 0;
398 407
 
399 408
 	// Make sure the file we are looking for is one they are allowed to look at
400
-	if ($ext != '.php' || (strpos($file, $real_board) === false && strpos($file, $real_source) === false) || ($basename == 'settings.php' || $basename == 'settings_bak.php') || strpos($file, $real_cache) !== false || !is_readable($file))
401
-		fatal_lang_error('error_bad_file', true, array($smcFunc['htmlspecialchars']($file)));
409
+	if ($ext != '.php' || (strpos($file, $real_board) === false && strpos($file, $real_source) === false) || ($basename == 'settings.php' || $basename == 'settings_bak.php') || strpos($file, $real_cache) !== false || !is_readable($file)) {
410
+			fatal_lang_error('error_bad_file', true, array($smcFunc['htmlspecialchars']($file)));
411
+	}
402 412
 
403 413
 	// get the min and max lines
404 414
 	$min = $line - 20 <= 0 ? 1 : $line - 20;
405 415
 	$max = $line + 21; // One additional line to make everything work out correctly
406 416
 
407
-	if ($max <= 0 || $min >= $max)
408
-		fatal_lang_error('error_bad_line');
417
+	if ($max <= 0 || $min >= $max) {
418
+			fatal_lang_error('error_bad_line');
419
+	}
409 420
 
410 421
 	$file_data = explode('<br />', highlight_php_code($smcFunc['htmlspecialchars'](implode('', file($file)))));
411 422
 
Please login to merge, or discard this patch.
Sources/Subs-Editor.php 1 patch
Braces   +402 added lines, -303 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 4
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
  * !!!Compatibility!!!
@@ -30,8 +31,9 @@  discard block
 block discarded – undo
30 31
 {
31 32
 	global $modSettings;
32 33
 
33
-	if (!$compat_mode)
34
-		return $text;
34
+	if (!$compat_mode) {
35
+			return $text;
36
+	}
35 37
 
36 38
 	// Turn line breaks back into br's.
37 39
 	$text = strtr($text, array("\r" => '', "\n" => '<br>'));
@@ -48,8 +50,9 @@  discard block
 block discarded – undo
48 50
 			for ($i = 0, $n = count($parts); $i < $n; $i++)
49 51
 			{
50 52
 				// Value of 2 means we're inside the tag.
51
-				if ($i % 4 == 2)
52
-					$parts[$i] = strtr($parts[$i], array('[' => '&#91;', ']' => '&#93;', "'" => "'"));
53
+				if ($i % 4 == 2) {
54
+									$parts[$i] = strtr($parts[$i], array('[' => '&#91;', ']' => '&#93;', "'" => "'"));
55
+				}
53 56
 			}
54 57
 			// Put our humpty dumpty message back together again.
55 58
 			$text = implode('', $parts);
@@ -107,8 +110,9 @@  discard block
 block discarded – undo
107 110
 	$text = preg_replace('~</p>\s*(?!<)~i', '</p><br>', $text);
108 111
 
109 112
 	// Safari/webkit wraps lines in Wysiwyg in <div>'s.
110
-	if (isBrowser('webkit'))
111
-		$text = preg_replace(array('~<div(?:\s(?:[^<>]*?))?' . '>~i', '</div>'), array('<br>', ''), $text);
113
+	if (isBrowser('webkit')) {
114
+			$text = preg_replace(array('~<div(?:\s(?:[^<>]*?))?' . '>~i', '</div>'), array('<br>', ''), $text);
115
+	}
112 116
 
113 117
 	// If there's a trailing break get rid of it - Firefox tends to add one.
114 118
 	$text = preg_replace('~<br\s?/?' . '>$~i', '', $text);
@@ -123,8 +127,9 @@  discard block
 block discarded – undo
123 127
 		for ($i = 0, $n = count($parts); $i < $n; $i++)
124 128
 		{
125 129
 			// Value of 2 means we're inside the tag.
126
-			if ($i % 4 == 2)
127
-				$parts[$i] = strip_tags($parts[$i]);
130
+			if ($i % 4 == 2) {
131
+							$parts[$i] = strip_tags($parts[$i]);
132
+			}
128 133
 		}
129 134
 
130 135
 		$text = strtr(implode('', $parts), array('#smf_br_spec_grudge_cool!#' => '<br>'));
@@ -150,18 +155,19 @@  discard block
 block discarded – undo
150 155
 			{
151 156
 				$found = array_search($file, $smileysto);
152 157
 				// Note the weirdness here is to stop double spaces between smileys.
153
-				if ($found)
154
-					$matches[1][$k] = '-[]-smf_smily_start#|#' . $smcFunc['htmlspecialchars']($smileysfrom[$found]) . '-[]-smf_smily_end#|#';
155
-				else
156
-					$matches[1][$k] = '';
158
+				if ($found) {
159
+									$matches[1][$k] = '-[]-smf_smily_start#|#' . $smcFunc['htmlspecialchars']($smileysfrom[$found]) . '-[]-smf_smily_end#|#';
160
+				} else {
161
+									$matches[1][$k] = '';
162
+				}
157 163
 			}
158
-		}
159
-		else
164
+		} else
160 165
 		{
161 166
 			// Load all the smileys.
162 167
 			$names = array();
163
-			foreach ($matches[1] as $file)
164
-				$names[] = $file;
168
+			foreach ($matches[1] as $file) {
169
+							$names[] = $file;
170
+			}
165 171
 			$names = array_unique($names);
166 172
 
167 173
 			if (!empty($names))
@@ -175,13 +181,15 @@  discard block
 block discarded – undo
175 181
 					)
176 182
 				);
177 183
 				$mappings = array();
178
-				while ($row = $smcFunc['db_fetch_assoc']($request))
179
-					$mappings[$row['filename']] = $smcFunc['htmlspecialchars']($row['code']);
184
+				while ($row = $smcFunc['db_fetch_assoc']($request)) {
185
+									$mappings[$row['filename']] = $smcFunc['htmlspecialchars']($row['code']);
186
+				}
180 187
 				$smcFunc['db_free_result']($request);
181 188
 
182
-				foreach ($matches[1] as $k => $file)
183
-					if (isset($mappings[$file]))
189
+				foreach ($matches[1] as $k => $file) {
190
+									if (isset($mappings[$file]))
184 191
 						$matches[1][$k] = '-[]-smf_smily_start#|#' . $mappings[$file] . '-[]-smf_smily_end#|#';
192
+				}
185 193
 			}
186 194
 		}
187 195
 
@@ -193,8 +201,9 @@  discard block
 block discarded – undo
193 201
 	}
194 202
 
195 203
 	// Only try to buy more time if the client didn't quit.
196
-	if (connection_aborted() && $context['server']['is_apache'])
197
-		@apache_reset_timeout();
204
+	if (connection_aborted() && $context['server']['is_apache']) {
205
+			@apache_reset_timeout();
206
+	}
198 207
 
199 208
 	$parts = preg_split('~(<[A-Za-z]+\s*[^<>]*?style="?[^<>"]+"?[^<>]*?(?:/?)>|</[A-Za-z]+>)~', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
200 209
 	$replacement = '';
@@ -205,9 +214,9 @@  discard block
 block discarded – undo
205 214
 		if (preg_match('~(<([A-Za-z]+)\s*[^<>]*?)style="?([^<>"]+)"?([^<>]*?(/?)>)~', $part, $matches) === 1)
206 215
 		{
207 216
 			// If it's being closed instantly, we can't deal with it...yet.
208
-			if ($matches[5] === '/')
209
-				continue;
210
-			else
217
+			if ($matches[5] === '/') {
218
+							continue;
219
+			} else
211 220
 			{
212 221
 				// Get an array of styles that apply to this element. (The strtr is there to combat HTML generated by Word.)
213 222
 				$styles = explode(';', strtr($matches[3], array('&quot;' => '')));
@@ -223,8 +232,9 @@  discard block
 block discarded – undo
223 232
 					$clean_type_value_pair = strtolower(strtr(trim($type_value_pair), '=', ':'));
224 233
 
225 234
 					// Something like 'font-weight: bold' is expected here.
226
-					if (strpos($clean_type_value_pair, ':') === false)
227
-						continue;
235
+					if (strpos($clean_type_value_pair, ':') === false) {
236
+											continue;
237
+					}
228 238
 
229 239
 					// Capture the elements of a single style item (e.g. 'font-weight' and 'bold').
230 240
 					list ($style_type, $style_value) = explode(':', $type_value_pair);
@@ -246,8 +256,7 @@  discard block
 block discarded – undo
246 256
 							{
247 257
 								$curCloseTags .= '[/u]';
248 258
 								$replacement .= '[u]';
249
-							}
250
-							elseif ($style_value == 'line-through')
259
+							} elseif ($style_value == 'line-through')
251 260
 							{
252 261
 								$curCloseTags .= '[/s]';
253 262
 								$replacement .= '[s]';
@@ -259,13 +268,11 @@  discard block
 block discarded – undo
259 268
 							{
260 269
 								$curCloseTags .= '[/left]';
261 270
 								$replacement .= '[left]';
262
-							}
263
-							elseif ($style_value == 'center')
271
+							} elseif ($style_value == 'center')
264 272
 							{
265 273
 								$curCloseTags .= '[/center]';
266 274
 								$replacement .= '[center]';
267
-							}
268
-							elseif ($style_value == 'right')
275
+							} elseif ($style_value == 'right')
269 276
 							{
270 277
 								$curCloseTags .= '[/right]';
271 278
 								$replacement .= '[right]';
@@ -287,8 +294,9 @@  discard block
 block discarded – undo
287 294
 
288 295
 						case 'font-size':
289 296
 							// Sometimes people put decimals where decimals should not be.
290
-							if (preg_match('~(\d)+\.\d+(p[xt])~i', $style_value, $dec_matches) === 1)
291
-								$style_value = $dec_matches[1] . $dec_matches[2];
297
+							if (preg_match('~(\d)+\.\d+(p[xt])~i', $style_value, $dec_matches) === 1) {
298
+															$style_value = $dec_matches[1] . $dec_matches[2];
299
+							}
292 300
 
293 301
 							$curCloseTags .= '[/size]';
294 302
 							$replacement .= '[size=' . $style_value . ']';
@@ -296,8 +304,9 @@  discard block
 block discarded – undo
296 304
 
297 305
 						case 'font-family':
298 306
 							// Only get the first freaking font if there's a list!
299
-							if (strpos($style_value, ',') !== false)
300
-								$style_value = substr($style_value, 0, strpos($style_value, ','));
307
+							if (strpos($style_value, ',') !== false) {
308
+															$style_value = substr($style_value, 0, strpos($style_value, ','));
309
+							}
301 310
 
302 311
 							$curCloseTags .= '[/font]';
303 312
 							$replacement .= '[font=' . strtr($style_value, array("'" => '')) . ']';
@@ -306,13 +315,15 @@  discard block
 block discarded – undo
306 315
 						// This is a hack for images with dimensions embedded.
307 316
 						case 'width':
308 317
 						case 'height':
309
-							if (preg_match('~[1-9]\d*~i', $style_value, $dimension) === 1)
310
-								$extra_attr .= ' ' . $style_type . '="' . $dimension[0] . '"';
318
+							if (preg_match('~[1-9]\d*~i', $style_value, $dimension) === 1) {
319
+															$extra_attr .= ' ' . $style_type . '="' . $dimension[0] . '"';
320
+							}
311 321
 						break;
312 322
 
313 323
 						case 'list-style-type':
314
-							if (preg_match('~none|disc|circle|square|decimal|decimal-leading-zero|lower-roman|upper-roman|lower-alpha|upper-alpha|lower-greek|lower-latin|upper-latin|hebrew|armenian|georgian|cjk-ideographic|hiragana|katakana|hiragana-iroha|katakana-iroha~i', $style_value, $listType) === 1)
315
-								$extra_attr .= ' listtype="' . $listType[0] . '"';
324
+							if (preg_match('~none|disc|circle|square|decimal|decimal-leading-zero|lower-roman|upper-roman|lower-alpha|upper-alpha|lower-greek|lower-latin|upper-latin|hebrew|armenian|georgian|cjk-ideographic|hiragana|katakana|hiragana-iroha|katakana-iroha~i', $style_value, $listType) === 1) {
325
+															$extra_attr .= ' listtype="' . $listType[0] . '"';
326
+							}
316 327
 						break;
317 328
 					}
318 329
 				}
@@ -325,18 +336,17 @@  discard block
 block discarded – undo
325 336
 				}
326 337
 
327 338
 				// If there's something that still needs closing, push it to the stack.
328
-				if (!empty($curCloseTags))
329
-					array_push($stack, array(
339
+				if (!empty($curCloseTags)) {
340
+									array_push($stack, array(
330 341
 							'element' => strtolower($curElement),
331 342
 							'closeTags' => $curCloseTags
332 343
 						)
333 344
 					);
334
-				elseif (!empty($extra_attr))
335
-					$replacement .= $precedingStyle . $extra_attr . $afterStyle;
345
+				} elseif (!empty($extra_attr)) {
346
+									$replacement .= $precedingStyle . $extra_attr . $afterStyle;
347
+				}
336 348
 			}
337
-		}
338
-
339
-		elseif (preg_match('~</([A-Za-z]+)>~', $part, $matches) === 1)
349
+		} elseif (preg_match('~</([A-Za-z]+)>~', $part, $matches) === 1)
340 350
 		{
341 351
 			// Is this the element that we've been waiting for to be closed?
342 352
 			if (!empty($stack) && strtolower($matches[1]) === $stack[count($stack) - 1]['element'])
@@ -346,28 +356,32 @@  discard block
 block discarded – undo
346 356
 			}
347 357
 
348 358
 			// Must've been something else.
349
-			else
350
-				$replacement .= $part;
359
+			else {
360
+							$replacement .= $part;
361
+			}
351 362
 		}
352 363
 		// In all other cases, just add the part to the replacement.
353
-		else
354
-			$replacement .= $part;
364
+		else {
365
+					$replacement .= $part;
366
+		}
355 367
 	}
356 368
 
357 369
 	// Now put back the replacement in the text.
358 370
 	$text = $replacement;
359 371
 
360 372
 	// We are not finished yet, request more time.
361
-	if (connection_aborted() && $context['server']['is_apache'])
362
-		@apache_reset_timeout();
373
+	if (connection_aborted() && $context['server']['is_apache']) {
374
+			@apache_reset_timeout();
375
+	}
363 376
 
364 377
 	// Let's pull out any legacy alignments.
365 378
 	while (preg_match('~<([A-Za-z]+)\s+[^<>]*?(align="*(left|center|right)"*)[^<>]*?(/?)>~i', $text, $matches) === 1)
366 379
 	{
367 380
 		// Find the position in the text of this tag over again.
368 381
 		$start_pos = strpos($text, $matches[0]);
369
-		if ($start_pos === false)
370
-			break;
382
+		if ($start_pos === false) {
383
+					break;
384
+		}
371 385
 
372 386
 		// End tag?
373 387
 		if ($matches[4] != '/' && strpos($text, '</' . $matches[1] . '>', $start_pos) !== false)
@@ -381,8 +395,7 @@  discard block
 block discarded – undo
381 395
 
382 396
 			// Put the tags back into the body.
383 397
 			$text = substr($text, 0, $start_pos) . $tag . '[' . $matches[3] . ']' . $content . '[/' . $matches[3] . ']' . substr($text, $end_pos);
384
-		}
385
-		else
398
+		} else
386 399
 		{
387 400
 			// Just get rid of this evil tag.
388 401
 			$text = substr($text, 0, $start_pos) . substr($text, $start_pos + strlen($matches[0]));
@@ -395,8 +408,9 @@  discard block
 block discarded – undo
395 408
 		// Find the position of this again.
396 409
 		$start_pos = strpos($text, $matches[0]);
397 410
 		$end_pos = false;
398
-		if ($start_pos === false)
399
-			break;
411
+		if ($start_pos === false) {
412
+					break;
413
+		}
400 414
 
401 415
 		// This must have an end tag - and we must find the right one.
402 416
 		$lower_text = strtolower($text);
@@ -429,8 +443,9 @@  discard block
 block discarded – undo
429 443
 				break;
430 444
 			}
431 445
 		}
432
-		if ($end_pos === false)
433
-			break;
446
+		if ($end_pos === false) {
447
+					break;
448
+		}
434 449
 
435 450
 		// Now work out what the attributes are.
436 451
 		$attribs = fetchTagAttributes($matches[1]);
@@ -444,11 +459,11 @@  discard block
 block discarded – undo
444 459
 				$v = (int) trim($v);
445 460
 				$v = empty($v) ? 1 : $v;
446 461
 				$tags[] = array('[size=' . $sizes_equivalence[$v] . ']', '[/size]');
462
+			} elseif ($s == 'face') {
463
+							$tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]');
464
+			} elseif ($s == 'color') {
465
+							$tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]');
447 466
 			}
448
-			elseif ($s == 'face')
449
-				$tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]');
450
-			elseif ($s == 'color')
451
-				$tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]');
452 467
 		}
453 468
 
454 469
 		// As before add in our tags.
@@ -456,8 +471,9 @@  discard block
 block discarded – undo
456 471
 		foreach ($tags as $tag)
457 472
 		{
458 473
 			$before .= $tag[0];
459
-			if (isset($tag[1]))
460
-				$after = $tag[1] . $after;
474
+			if (isset($tag[1])) {
475
+							$after = $tag[1] . $after;
476
+			}
461 477
 		}
462 478
 
463 479
 		// Remove the tag so it's never checked again.
@@ -468,8 +484,9 @@  discard block
 block discarded – undo
468 484
 	}
469 485
 
470 486
 	// Almost there, just a little more time.
471
-	if (connection_aborted() && $context['server']['is_apache'])
472
-		@apache_reset_timeout();
487
+	if (connection_aborted() && $context['server']['is_apache']) {
488
+			@apache_reset_timeout();
489
+	}
473 490
 
474 491
 	if (count($parts = preg_split('~<(/?)(li|ol|ul)([^>]*)>~i', $text, null, PREG_SPLIT_DELIM_CAPTURE)) > 1)
475 492
 	{
@@ -525,12 +542,13 @@  discard block
 block discarded – undo
525 542
 						{
526 543
 							$inList = true;
527 544
 
528
-							if ($tag === 'ol')
529
-								$listType = 'decimal';
530
-							elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1)
531
-								$listType = $listTypeMapping[$match[1]];
532
-							else
533
-								$listType = null;
545
+							if ($tag === 'ol') {
546
+															$listType = 'decimal';
547
+							} elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1) {
548
+															$listType = $listTypeMapping[$match[1]];
549
+							} else {
550
+															$listType = null;
551
+							}
534 552
 
535 553
 							$listDepth++;
536 554
 
@@ -594,9 +612,7 @@  discard block
 block discarded – undo
594 612
 							$parts[$i + 1] = '';
595 613
 							$parts[$i + 2] = str_repeat("\t", $listDepth) . '[/list]';
596 614
 							$parts[$i + 3] = '';
597
-						}
598
-
599
-						else
615
+						} else
600 616
 						{
601 617
 							// We're in a list item.
602 618
 							if ($listDepth > 0)
@@ -633,9 +649,7 @@  discard block
 block discarded – undo
633 649
 							$parts[$i + 1] = '';
634 650
 							$parts[$i + 2] = '';
635 651
 							$parts[$i + 3] = '';
636
-						}
637
-
638
-						else
652
+						} else
639 653
 						{
640 654
 							// Remove the trailing breaks from the list item.
641 655
 							$parts[$i] = preg_replace('~\s*<br\s*' . '/?' . '>\s*$~', '', $parts[$i]);
@@ -673,8 +687,9 @@  discard block
 block discarded – undo
673 687
 			$text .= str_repeat("\t", $listDepth) . '[/list]';
674 688
 		}
675 689
 
676
-		for ($i = $listDepth; $i > 0; $i--)
677
-			$text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]';
690
+		for ($i = $listDepth; $i > 0; $i--) {
691
+					$text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]';
692
+		}
678 693
 
679 694
 	}
680 695
 
@@ -683,8 +698,9 @@  discard block
 block discarded – undo
683 698
 	{
684 699
 		// Find the position of the image.
685 700
 		$start_pos = strpos($text, $matches[0]);
686
-		if ($start_pos === false)
687
-			break;
701
+		if ($start_pos === false) {
702
+					break;
703
+		}
688 704
 		$end_pos = $start_pos + strlen($matches[0]);
689 705
 
690 706
 		$params = '';
@@ -693,12 +709,13 @@  discard block
 block discarded – undo
693 709
 		$attrs = fetchTagAttributes($matches[1]);
694 710
 		foreach ($attrs as $attrib => $value)
695 711
 		{
696
-			if (in_array($attrib, array('width', 'height')))
697
-				$params .= ' ' . $attrib . '=' . (int) $value;
698
-			elseif ($attrib == 'alt' && trim($value) != '')
699
-				$params .= ' alt=' . trim($value);
700
-			elseif ($attrib == 'src')
701
-				$src = trim($value);
712
+			if (in_array($attrib, array('width', 'height'))) {
713
+							$params .= ' ' . $attrib . '=' . (int) $value;
714
+			} elseif ($attrib == 'alt' && trim($value) != '') {
715
+							$params .= ' alt=' . trim($value);
716
+			} elseif ($attrib == 'src') {
717
+							$src = trim($value);
718
+			}
702 719
 		}
703 720
 
704 721
 		$tag = '';
@@ -709,10 +726,11 @@  discard block
 block discarded – undo
709 726
 			{
710 727
 				$baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']);
711 728
 
712
-				if (substr($src, 0, 1) === '/')
713
-					$src = $baseURL . $src;
714
-				else
715
-					$src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src;
729
+				if (substr($src, 0, 1) === '/') {
730
+									$src = $baseURL . $src;
731
+				} else {
732
+									$src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src;
733
+				}
716 734
 			}
717 735
 
718 736
 			$tag = '[img' . $params . ']' . $src . '[/img]';
@@ -890,20 +908,23 @@  discard block
 block discarded – undo
890 908
 		},
891 909
 	);
892 910
 
893
-	foreach ($tags as $tag => $replace)
894
-		$text = preg_replace_callback($tag, $replace, $text);
911
+	foreach ($tags as $tag => $replace) {
912
+			$text = preg_replace_callback($tag, $replace, $text);
913
+	}
895 914
 
896 915
 	// Please give us just a little more time.
897
-	if (connection_aborted() && $context['server']['is_apache'])
898
-		@apache_reset_timeout();
916
+	if (connection_aborted() && $context['server']['is_apache']) {
917
+			@apache_reset_timeout();
918
+	}
899 919
 
900 920
 	// What about URL's - the pain in the ass of the tag world.
901 921
 	while (preg_match('~<a\s+([^<>]*)>([^<>]*)</a>~i', $text, $matches) === 1)
902 922
 	{
903 923
 		// Find the position of the URL.
904 924
 		$start_pos = strpos($text, $matches[0]);
905
-		if ($start_pos === false)
906
-			break;
925
+		if ($start_pos === false) {
926
+					break;
927
+		}
907 928
 		$end_pos = $start_pos + strlen($matches[0]);
908 929
 
909 930
 		$tag_type = 'url';
@@ -917,8 +938,9 @@  discard block
 block discarded – undo
917 938
 				$href = trim($value);
918 939
 
919 940
 				// Are we dealing with an FTP link?
920
-				if (preg_match('~^ftps?://~', $href) === 1)
921
-					$tag_type = 'ftp';
941
+				if (preg_match('~^ftps?://~', $href) === 1) {
942
+									$tag_type = 'ftp';
943
+				}
922 944
 
923 945
 				// Or is this a link to an email address?
924 946
 				elseif (substr($href, 0, 7) == 'mailto:')
@@ -932,28 +954,31 @@  discard block
 block discarded – undo
932 954
 				{
933 955
 					$baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']);
934 956
 
935
-					if (substr($href, 0, 1) === '/')
936
-						$href = $baseURL . $href;
937
-					else
938
-						$href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href;
957
+					if (substr($href, 0, 1) === '/') {
958
+											$href = $baseURL . $href;
959
+					} else {
960
+											$href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href;
961
+					}
939 962
 				}
940 963
 			}
941 964
 
942 965
 			// External URL?
943 966
 			if ($attrib == 'target' && $tag_type == 'url')
944 967
 			{
945
-				if (trim($value) == '_blank')
946
-					$tag_type == 'iurl';
968
+				if (trim($value) == '_blank') {
969
+									$tag_type == 'iurl';
970
+				}
947 971
 			}
948 972
 		}
949 973
 
950 974
 		$tag = '';
951 975
 		if ($href != '')
952 976
 		{
953
-			if ($matches[2] == $href)
954
-				$tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']';
955
-			else
956
-				$tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']';
977
+			if ($matches[2] == $href) {
978
+							$tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']';
979
+			} else {
980
+							$tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']';
981
+			}
957 982
 		}
958 983
 
959 984
 		// Replace the tag
@@ -992,17 +1017,18 @@  discard block
 block discarded – undo
992 1017
 		// We're either moving from the key to the attribute or we're in a string and this is fine.
993 1018
 		if ($text[$i] == '=')
994 1019
 		{
995
-			if ($tag_state == 0)
996
-				$tag_state = 1;
997
-			elseif ($tag_state == 2)
998
-				$value .= '=';
1020
+			if ($tag_state == 0) {
1021
+							$tag_state = 1;
1022
+			} elseif ($tag_state == 2) {
1023
+							$value .= '=';
1024
+			}
999 1025
 		}
1000 1026
 		// A space is either moving from an attribute back to a potential key or in a string is fine.
1001 1027
 		elseif ($text[$i] == ' ')
1002 1028
 		{
1003
-			if ($tag_state == 2)
1004
-				$value .= ' ';
1005
-			elseif ($tag_state == 1)
1029
+			if ($tag_state == 2) {
1030
+							$value .= ' ';
1031
+			} elseif ($tag_state == 1)
1006 1032
 			{
1007 1033
 				$attribs[$key] = $value;
1008 1034
 				$key = $value = '';
@@ -1013,24 +1039,27 @@  discard block
 block discarded – undo
1013 1039
 		elseif ($text[$i] == '"')
1014 1040
 		{
1015 1041
 			// Must be either going into or out of a string.
1016
-			if ($tag_state == 1)
1017
-				$tag_state = 2;
1018
-			else
1019
-				$tag_state = 1;
1042
+			if ($tag_state == 1) {
1043
+							$tag_state = 2;
1044
+			} else {
1045
+							$tag_state = 1;
1046
+			}
1020 1047
 		}
1021 1048
 		// Otherwise it's fine.
1022 1049
 		else
1023 1050
 		{
1024
-			if ($tag_state == 0)
1025
-				$key .= $text[$i];
1026
-			else
1027
-				$value .= $text[$i];
1051
+			if ($tag_state == 0) {
1052
+							$key .= $text[$i];
1053
+			} else {
1054
+							$value .= $text[$i];
1055
+			}
1028 1056
 		}
1029 1057
 	}
1030 1058
 
1031 1059
 	// Anything left?
1032
-	if ($key != '' && $value != '')
1033
-		$attribs[$key] = $value;
1060
+	if ($key != '' && $value != '') {
1061
+			$attribs[$key] = $value;
1062
+	}
1034 1063
 
1035 1064
 	return $attribs;
1036 1065
 }
@@ -1046,15 +1075,17 @@  discard block
 block discarded – undo
1046 1075
 	global $modSettings;
1047 1076
 
1048 1077
 	// Don't care about the texts that are too short.
1049
-	if (strlen($text) < 3)
1050
-		return $text;
1078
+	if (strlen($text) < 3) {
1079
+			return $text;
1080
+	}
1051 1081
 
1052 1082
 	// A list of tags that's disabled by the admin.
1053 1083
 	$disabled = empty($modSettings['disabledBBC']) ? array() : array_flip(explode(',', strtolower($modSettings['disabledBBC'])));
1054 1084
 
1055 1085
 	// Add flash if it's disabled as embedded tag.
1056
-	if (empty($modSettings['enableEmbeddedFlash']))
1057
-		$disabled['flash'] = true;
1086
+	if (empty($modSettings['enableEmbeddedFlash'])) {
1087
+			$disabled['flash'] = true;
1088
+	}
1058 1089
 
1059 1090
 	// Get a list of all the tags that are not disabled.
1060 1091
 	$all_tags = parse_bbc(false);
@@ -1062,10 +1093,12 @@  discard block
 block discarded – undo
1062 1093
 	$self_closing_tags = array();
1063 1094
 	foreach ($all_tags as $tag)
1064 1095
 	{
1065
-		if (!isset($disabled[$tag['tag']]))
1066
-			$valid_tags[$tag['tag']] = !empty($tag['block_level']);
1067
-		if (isset($tag['type']) && $tag['type'] == 'closed')
1068
-			$self_closing_tags[] = $tag['tag'];
1096
+		if (!isset($disabled[$tag['tag']])) {
1097
+					$valid_tags[$tag['tag']] = !empty($tag['block_level']);
1098
+		}
1099
+		if (isset($tag['type']) && $tag['type'] == 'closed') {
1100
+					$self_closing_tags[] = $tag['tag'];
1101
+		}
1069 1102
 	}
1070 1103
 
1071 1104
 	// Right - we're going to start by going through the whole lot to make sure we don't have align stuff crossed as this happens load and is stupid!
@@ -1092,16 +1125,19 @@  discard block
 block discarded – undo
1092 1125
 				$tagName = substr($match, $isClosingTag ? 2 : 1, -1);
1093 1126
 
1094 1127
 				// We're closing the exact same tag that we opened.
1095
-				if ($isClosingTag && $insideTag === $tagName)
1096
-					$insideTag = null;
1128
+				if ($isClosingTag && $insideTag === $tagName) {
1129
+									$insideTag = null;
1130
+				}
1097 1131
 
1098 1132
 				// We're opening a tag and we're not yet inside one either
1099
-				elseif (!$isClosingTag && $insideTag === null)
1100
-					$insideTag = $tagName;
1133
+				elseif (!$isClosingTag && $insideTag === null) {
1134
+									$insideTag = $tagName;
1135
+				}
1101 1136
 
1102 1137
 				// In all other cases, this tag must be invalid
1103
-				else
1104
-					unset($matches[$i]);
1138
+				else {
1139
+									unset($matches[$i]);
1140
+				}
1105 1141
 			}
1106 1142
 
1107 1143
 			// The next one is gonna be the other one.
@@ -1109,8 +1145,9 @@  discard block
 block discarded – undo
1109 1145
 		}
1110 1146
 
1111 1147
 		// We're still inside a tag and had no chance for closure?
1112
-		if ($insideTag !== null)
1113
-			$matches[] = '[/' . $insideTag . ']';
1148
+		if ($insideTag !== null) {
1149
+					$matches[] = '[/' . $insideTag . ']';
1150
+		}
1114 1151
 
1115 1152
 		// And a complete text string again.
1116 1153
 		$text = implode('', $matches);
@@ -1119,8 +1156,9 @@  discard block
 block discarded – undo
1119 1156
 	// Quickly remove any tags which are back to back.
1120 1157
 	$backToBackPattern = '~\\[(' . implode('|', array_diff(array_keys($valid_tags), array('td', 'anchor'))) . ')[^<>\\[\\]]*\\]\s*\\[/\\1\\]~';
1121 1158
 	$lastlen = 0;
1122
-	while (strlen($text) !== $lastlen)
1123
-		$lastlen = strlen($text = preg_replace($backToBackPattern, '', $text));
1159
+	while (strlen($text) !== $lastlen) {
1160
+			$lastlen = strlen($text = preg_replace($backToBackPattern, '', $text));
1161
+	}
1124 1162
 
1125 1163
 	// Need to sort the tags my name length.
1126 1164
 	uksort($valid_tags, 'sort_array_length');
@@ -1157,8 +1195,9 @@  discard block
 block discarded – undo
1157 1195
 			$isCompetingTag = in_array($tag, $competing_tags);
1158 1196
 
1159 1197
 			// Check if this might be one of those cleaned out tags.
1160
-			if ($tag === '')
1161
-				continue;
1198
+			if ($tag === '') {
1199
+							continue;
1200
+			}
1162 1201
 
1163 1202
 			// Special case: inside [code] blocks any code is left untouched.
1164 1203
 			elseif ($tag === 'code')
@@ -1169,8 +1208,9 @@  discard block
 block discarded – undo
1169 1208
 					$inCode = false;
1170 1209
 
1171 1210
 					// Reopen tags that were closed before the code block.
1172
-					if (!empty($inlineElements))
1173
-						$parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']';
1211
+					if (!empty($inlineElements)) {
1212
+											$parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']';
1213
+					}
1174 1214
 				}
1175 1215
 
1176 1216
 				// We're outside a coding and nobbc block and opening it.
@@ -1199,8 +1239,9 @@  discard block
 block discarded – undo
1199 1239
 					$inNoBbc = false;
1200 1240
 
1201 1241
 					// Some inline elements might've been closed that need reopening.
1202
-					if (!empty($inlineElements))
1203
-						$parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']';
1242
+					if (!empty($inlineElements)) {
1243
+											$parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']';
1244
+					}
1204 1245
 				}
1205 1246
 
1206 1247
 				// We're outside a nobbc and coding block and opening it.
@@ -1220,8 +1261,9 @@  discard block
 block discarded – undo
1220 1261
 			}
1221 1262
 
1222 1263
 			// So, we're inside one of the special blocks: ignore any tag.
1223
-			elseif ($inCode || $inNoBbc)
1224
-				continue;
1264
+			elseif ($inCode || $inNoBbc) {
1265
+							continue;
1266
+			}
1225 1267
 
1226 1268
 			// We're dealing with an opening tag.
1227 1269
 			if ($isOpeningTag)
@@ -1262,8 +1304,9 @@  discard block
 block discarded – undo
1262 1304
 							if ($parts[$j + 3] === $tag)
1263 1305
 							{
1264 1306
 								// If it's an opening tag, increase the level.
1265
-								if ($parts[$j + 2] === '')
1266
-									$curLevel++;
1307
+								if ($parts[$j + 2] === '') {
1308
+																	$curLevel++;
1309
+								}
1267 1310
 
1268 1311
 								// A closing tag, decrease the level.
1269 1312
 								else
@@ -1286,13 +1329,15 @@  discard block
 block discarded – undo
1286 1329
 					{
1287 1330
 						if ($isCompetingTag)
1288 1331
 						{
1289
-							if (!isset($competingElements[$tag]))
1290
-								$competingElements[$tag] = array();
1332
+							if (!isset($competingElements[$tag])) {
1333
+															$competingElements[$tag] = array();
1334
+							}
1291 1335
 
1292 1336
 							$competingElements[$tag][] = $parts[$i + 4];
1293 1337
 
1294
-							if (count($competingElements[$tag]) > 1)
1295
-								$parts[$i] .= '[/' . $tag . ']';
1338
+							if (count($competingElements[$tag]) > 1) {
1339
+															$parts[$i] .= '[/' . $tag . ']';
1340
+							}
1296 1341
 						}
1297 1342
 
1298 1343
 						$inlineElements[$elementContent] = $tag;
@@ -1313,15 +1358,17 @@  discard block
 block discarded – undo
1313 1358
 						$addClosingTags = array();
1314 1359
 						while ($element = array_pop($blockElements))
1315 1360
 						{
1316
-							if ($element === $tag)
1317
-								break;
1361
+							if ($element === $tag) {
1362
+															break;
1363
+							}
1318 1364
 
1319 1365
 							// Still a block tag was open not equal to this tag.
1320 1366
 							$addClosingTags[] = $element['type'];
1321 1367
 						}
1322 1368
 
1323
-						if (!empty($addClosingTags))
1324
-							$parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1];
1369
+						if (!empty($addClosingTags)) {
1370
+													$parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1];
1371
+						}
1325 1372
 
1326 1373
 						// Apparently the closing tag was not found on the stack.
1327 1374
 						if (!is_string($element) || $element !== $tag)
@@ -1331,8 +1378,7 @@  discard block
 block discarded – undo
1331 1378
 							$parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = '';
1332 1379
 							continue;
1333 1380
 						}
1334
-					}
1335
-					else
1381
+					} else
1336 1382
 					{
1337 1383
 						// Get rid of this closing tag!
1338 1384
 						$parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = '';
@@ -1361,53 +1407,62 @@  discard block
 block discarded – undo
1361 1407
 							unset($inlineElements[$tagContentToBeClosed]);
1362 1408
 
1363 1409
 							// Was this the tag we were looking for?
1364
-							if ($tagToBeClosed === $tag)
1365
-								break;
1410
+							if ($tagToBeClosed === $tag) {
1411
+															break;
1412
+							}
1366 1413
 
1367 1414
 							// Nope, close it and look further!
1368
-							else
1369
-								$parts[$i] .= '[/' . $tagToBeClosed . ']';
1415
+							else {
1416
+															$parts[$i] .= '[/' . $tagToBeClosed . ']';
1417
+							}
1370 1418
 						}
1371 1419
 
1372 1420
 						if ($isCompetingTag && !empty($competingElements[$tag]))
1373 1421
 						{
1374 1422
 							array_pop($competingElements[$tag]);
1375 1423
 
1376
-							if (count($competingElements[$tag]) > 0)
1377
-								$parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5];
1424
+							if (count($competingElements[$tag]) > 0) {
1425
+															$parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5];
1426
+							}
1378 1427
 						}
1379 1428
 					}
1380 1429
 
1381 1430
 					// Unexpected closing tag, ex-ter-mi-nate.
1382
-					else
1383
-						$parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = '';
1431
+					else {
1432
+											$parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = '';
1433
+					}
1384 1434
 				}
1385 1435
 			}
1386 1436
 		}
1387 1437
 
1388 1438
 		// Close the code tags.
1389
-		if ($inCode)
1390
-			$parts[$i] .= '[/code]';
1439
+		if ($inCode) {
1440
+					$parts[$i] .= '[/code]';
1441
+		}
1391 1442
 
1392 1443
 		// The same for nobbc tags.
1393
-		elseif ($inNoBbc)
1394
-			$parts[$i] .= '[/nobbc]';
1444
+		elseif ($inNoBbc) {
1445
+					$parts[$i] .= '[/nobbc]';
1446
+		}
1395 1447
 
1396 1448
 		// Still inline tags left unclosed? Close them now, better late than never.
1397
-		elseif (!empty($inlineElements))
1398
-			$parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']';
1449
+		elseif (!empty($inlineElements)) {
1450
+					$parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']';
1451
+		}
1399 1452
 
1400 1453
 		// Now close the block elements.
1401
-		if (!empty($blockElements))
1402
-			$parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']';
1454
+		if (!empty($blockElements)) {
1455
+					$parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']';
1456
+		}
1403 1457
 
1404 1458
 		$text = implode('', $parts);
1405 1459
 	}
1406 1460
 
1407 1461
 	// Final clean up of back to back tags.
1408 1462
 	$lastlen = 0;
1409
-	while (strlen($text) !== $lastlen)
1410
-		$lastlen = strlen($text = preg_replace($backToBackPattern, '', $text));
1463
+	while (strlen($text) !== $lastlen) {
1464
+			$lastlen = strlen($text = preg_replace($backToBackPattern, '', $text));
1465
+	}
1411 1466
 
1412 1467
 	return $text;
1413 1468
 }
@@ -1436,22 +1491,25 @@  discard block
 block discarded – undo
1436 1491
 	$context['template_layers'] = array();
1437 1492
 	// Lets make sure we aren't going to output anything nasty.
1438 1493
 	@ob_end_clean();
1439
-	if (!empty($modSettings['enableCompressedOutput']))
1440
-		@ob_start('ob_gzhandler');
1441
-	else
1442
-		@ob_start();
1494
+	if (!empty($modSettings['enableCompressedOutput'])) {
1495
+			@ob_start('ob_gzhandler');
1496
+	} else {
1497
+			@ob_start();
1498
+	}
1443 1499
 
1444 1500
 	// If we don't have any locale better avoid broken js
1445
-	if (empty($txt['lang_locale']))
1446
-		die();
1501
+	if (empty($txt['lang_locale'])) {
1502
+			die();
1503
+	}
1447 1504
 
1448 1505
 	$file_data = '(function ($) {
1449 1506
 	\'use strict\';
1450 1507
 
1451 1508
 	$.sceditor.locale[' . javaScriptEscape($txt['lang_locale']) . '] = {';
1452
-	foreach ($editortxt as $key => $val)
1453
-		$file_data .= '
1509
+	foreach ($editortxt as $key => $val) {
1510
+			$file_data .= '
1454 1511
 		' . javaScriptEscape($key) . ': ' . javaScriptEscape($val) . ',';
1512
+	}
1455 1513
 
1456 1514
 	$file_data .= '
1457 1515
 		dateFormat: "day.month.year"
@@ -1519,8 +1577,9 @@  discard block
 block discarded – undo
1519 1577
 				)
1520 1578
 			);
1521 1579
 			$icon_data = array();
1522
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1523
-				$icon_data[] = $row;
1580
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
1581
+							$icon_data[] = $row;
1582
+			}
1524 1583
 			$smcFunc['db_free_result']($request);
1525 1584
 
1526 1585
 			$icons = array();
@@ -1535,9 +1594,9 @@  discard block
 block discarded – undo
1535 1594
 			}
1536 1595
 
1537 1596
 			cache_put_data('posting_icons-' . $board_id, $icons, 480);
1597
+		} else {
1598
+					$icons = $temp;
1538 1599
 		}
1539
-		else
1540
-			$icons = $temp;
1541 1600
 	}
1542 1601
 	call_integration_hook('integrate_load_message_icons', array(&$icons));
1543 1602
 
@@ -1578,8 +1637,9 @@  discard block
 block discarded – undo
1578 1637
 	{
1579 1638
 		// Some general stuff.
1580 1639
 		$settings['smileys_url'] = $modSettings['smileys_url'] . '/' . $user_info['smiley_set'];
1581
-		if (!empty($context['drafts_autosave']))
1582
-			$context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000;
1640
+		if (!empty($context['drafts_autosave'])) {
1641
+					$context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000;
1642
+		}
1583 1643
 
1584 1644
 		// This really has some WYSIWYG stuff.
1585 1645
 		loadCSSFile('jquery.sceditor.css', array('force_current' => false, 'validate' => true), 'smf_jquery_sceditor');
@@ -1595,8 +1655,9 @@  discard block
 block discarded – undo
1595 1655
 		var bbc_quote = \'' . addcslashes($txt['quote'], "'") . '\';
1596 1656
 		var bbc_search_on = \'' . addcslashes($txt['search_on'], "'") . '\';');
1597 1657
 		// editor language file
1598
-		if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US')
1599
-			loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language');
1658
+		if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US') {
1659
+					loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language');
1660
+		}
1600 1661
 
1601 1662
 		$context['shortcuts_text'] = $txt['shortcuts' . (!empty($context['drafts_save']) ? '_drafts' : '') . (stripos($_SERVER['HTTP_USER_AGENT'], 'Macintosh') !== false ? '_mac' : (isBrowser('is_firefox') ? '_firefox' : ''))];
1602 1663
 		$context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv'))));
@@ -1605,11 +1666,12 @@  discard block
 block discarded – undo
1605 1666
 			loadJavaScriptFile('spellcheck.js', array(), 'smf_spellcheck');
1606 1667
 
1607 1668
 			// Some hidden information is needed in order to make the spell checking work.
1608
-			if (!isset($_REQUEST['xml']))
1609
-				$context['insert_after_template'] .= '
1669
+			if (!isset($_REQUEST['xml'])) {
1670
+							$context['insert_after_template'] .= '
1610 1671
 		<form name="spell_form" id="spell_form" method="post" accept-charset="' . $context['character_set'] . '" target="spellWindow" action="' . $scripturl . '?action=spellcheck">
1611 1672
 			<input type="hidden" name="spellstring" value="">
1612 1673
 		</form>';
1674
+			}
1613 1675
 		}
1614 1676
 	}
1615 1677
 
@@ -1775,10 +1837,12 @@  discard block
 block discarded – undo
1775 1837
 
1776 1838
 		// Generate a list of buttons that shouldn't be shown - this should be the fastest way to do this.
1777 1839
 		$disabled_tags = array();
1778
-		if (!empty($modSettings['disabledBBC']))
1779
-			$disabled_tags = explode(',', $modSettings['disabledBBC']);
1780
-		if (empty($modSettings['enableEmbeddedFlash']))
1781
-			$disabled_tags[] = 'flash';
1840
+		if (!empty($modSettings['disabledBBC'])) {
1841
+					$disabled_tags = explode(',', $modSettings['disabledBBC']);
1842
+		}
1843
+		if (empty($modSettings['enableEmbeddedFlash'])) {
1844
+					$disabled_tags[] = 'flash';
1845
+		}
1782 1846
 
1783 1847
 		foreach ($disabled_tags as $tag)
1784 1848
 		{
@@ -1788,9 +1852,10 @@  discard block
 block discarded – undo
1788 1852
 				$context['disabled_tags']['orderedlist'] = true;
1789 1853
 			}
1790 1854
 
1791
-			foreach ($editor_tag_map as $thisTag => $tagNameBBC)
1792
-				if ($tag === $thisTag)
1855
+			foreach ($editor_tag_map as $thisTag => $tagNameBBC) {
1856
+							if ($tag === $thisTag)
1793 1857
 					$context['disabled_tags'][$tagNameBBC] = true;
1858
+			}
1794 1859
 
1795 1860
 			$context['disabled_tags'][trim($tag)] = true;
1796 1861
 		}
@@ -1800,19 +1865,21 @@  discard block
 block discarded – undo
1800 1865
 		$context['bbc_toolbar'] = array();
1801 1866
 		foreach ($context['bbc_tags'] as $row => $tagRow)
1802 1867
 		{
1803
-			if (!isset($context['bbc_toolbar'][$row]))
1804
-				$context['bbc_toolbar'][$row] = array();
1868
+			if (!isset($context['bbc_toolbar'][$row])) {
1869
+							$context['bbc_toolbar'][$row] = array();
1870
+			}
1805 1871
 			$tagsRow = array();
1806 1872
 			foreach ($tagRow as $tag)
1807 1873
 			{
1808 1874
 				if ((!empty($tag['code'])) && empty($context['disabled_tags'][$tag['code']]))
1809 1875
 				{
1810 1876
 					$tagsRow[] = $tag['code'];
1811
-					if (isset($tag['image']))
1812
-						$bbcodes_styles .= '
1877
+					if (isset($tag['image'])) {
1878
+											$bbcodes_styles .= '
1813 1879
 			.sceditor-button-' . $tag['code'] . ' div {
1814 1880
 				background: url(\'' . $settings['default_theme_url'] . '/images/bbc/' . $tag['image'] . '.png\');
1815 1881
 			}';
1882
+					}
1816 1883
 					if (isset($tag['before']))
1817 1884
 					{
1818 1885
 						$context['bbcodes_handlers'] .= '
@@ -1826,8 +1893,7 @@  discard block
 block discarded – undo
1826 1893
 				});';
1827 1894
 					}
1828 1895
 
1829
-				}
1830
-				else
1896
+				} else
1831 1897
 				{
1832 1898
 					$context['bbc_toolbar'][$row][] = implode(',', $tagsRow);
1833 1899
 					$tagsRow = array();
@@ -1838,14 +1904,16 @@  discard block
 block discarded – undo
1838 1904
 			{
1839 1905
 				$context['bbc_toolbar'][$row][] = implode(',', $tagsRow);
1840 1906
 				$tagsRow = array();
1841
-				if (!isset($context['disabled_tags']['font']))
1842
-					$tagsRow[] = 'font';
1843
-				if (!isset($context['disabled_tags']['size']))
1844
-					$tagsRow[] = 'size';
1845
-				if (!isset($context['disabled_tags']['color']))
1846
-					$tagsRow[] = 'color';
1847
-			}
1848
-			elseif ($row == 1 && empty($modSettings['disable_wysiwyg']))
1907
+				if (!isset($context['disabled_tags']['font'])) {
1908
+									$tagsRow[] = 'font';
1909
+				}
1910
+				if (!isset($context['disabled_tags']['size'])) {
1911
+									$tagsRow[] = 'size';
1912
+				}
1913
+				if (!isset($context['disabled_tags']['color'])) {
1914
+									$tagsRow[] = 'color';
1915
+				}
1916
+			} elseif ($row == 1 && empty($modSettings['disable_wysiwyg']))
1849 1917
 			{
1850 1918
 				$tmp = array();
1851 1919
 				$tagsRow[] = 'removeformat';
@@ -1856,13 +1924,15 @@  discard block
 block discarded – undo
1856 1924
 				}
1857 1925
 			}
1858 1926
 
1859
-			if (!empty($tagsRow))
1860
-				$context['bbc_toolbar'][$row][] = implode(',', $tagsRow);
1927
+			if (!empty($tagsRow)) {
1928
+							$context['bbc_toolbar'][$row][] = implode(',', $tagsRow);
1929
+			}
1861 1930
 		}
1862
-		if (!empty($bbcodes_styles))
1863
-			$context['html_headers'] .= '
1931
+		if (!empty($bbcodes_styles)) {
1932
+					$context['html_headers'] .= '
1864 1933
 		<style>' . $bbcodes_styles . '
1865 1934
 		</style>';
1935
+		}
1866 1936
 	}
1867 1937
 
1868 1938
 	// Initialize smiley array... if not loaded before.
@@ -1874,8 +1944,8 @@  discard block
 block discarded – undo
1874 1944
 		);
1875 1945
 
1876 1946
 		// Load smileys - don't bother to run a query if we're not using the database's ones anyhow.
1877
-		if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none')
1878
-			$context['smileys']['postform'][] = array(
1947
+		if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none') {
1948
+					$context['smileys']['postform'][] = array(
1879 1949
 				'smileys' => array(
1880 1950
 					array(
1881 1951
 						'code' => ':)',
@@ -1961,7 +2031,7 @@  discard block
 block discarded – undo
1961 2031
 				),
1962 2032
 				'isLast' => true,
1963 2033
 			);
1964
-		elseif ($user_info['smiley_set'] != 'none')
2034
+		} elseif ($user_info['smiley_set'] != 'none')
1965 2035
 		{
1966 2036
 			if (($temp = cache_get_data('posting_smileys', 480)) == null)
1967 2037
 			{
@@ -1984,17 +2054,19 @@  discard block
 block discarded – undo
1984 2054
 
1985 2055
 				foreach ($context['smileys'] as $section => $smileyRows)
1986 2056
 				{
1987
-					foreach ($smileyRows as $rowIndex => $smileys)
1988
-						$context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true;
2057
+					foreach ($smileyRows as $rowIndex => $smileys) {
2058
+											$context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true;
2059
+					}
1989 2060
 
1990
-					if (!empty($smileyRows))
1991
-						$context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true;
2061
+					if (!empty($smileyRows)) {
2062
+											$context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true;
2063
+					}
1992 2064
 				}
1993 2065
 
1994 2066
 				cache_put_data('posting_smileys', $context['smileys'], 480);
2067
+			} else {
2068
+							$context['smileys'] = $temp;
1995 2069
 			}
1996
-			else
1997
-				$context['smileys'] = $temp;
1998 2070
 		}
1999 2071
 	}
2000 2072
 
@@ -2020,8 +2092,9 @@  discard block
 block discarded – undo
2020 2092
 		loadTemplate('GenericControls');
2021 2093
 
2022 2094
 		// Some javascript ma'am?
2023
-		if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual'])))
2024
-			loadJavaScriptFile('captcha.js', array(), 'smf_captcha');
2095
+		if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual']))) {
2096
+					loadJavaScriptFile('captcha.js', array(), 'smf_captcha');
2097
+		}
2025 2098
 
2026 2099
 		$context['use_graphic_library'] = in_array('gd', get_loaded_extensions());
2027 2100
 
@@ -2034,8 +2107,8 @@  discard block
 block discarded – undo
2034 2107
 	$isNew = !isset($context['controls']['verification'][$verificationOptions['id']]);
2035 2108
 
2036 2109
 	// Log this into our collection.
2037
-	if ($isNew)
2038
-		$context['controls']['verification'][$verificationOptions['id']] = array(
2110
+	if ($isNew) {
2111
+			$context['controls']['verification'][$verificationOptions['id']] = array(
2039 2112
 			'id' => $verificationOptions['id'],
2040 2113
 			'empty_field' => empty($verificationOptions['no_empty_field']),
2041 2114
 			'show_visual' => !empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual'])),
@@ -2046,13 +2119,15 @@  discard block
 block discarded – undo
2046 2119
 			'questions' => array(),
2047 2120
 			'can_recaptcha' => !empty($modSettings['recaptcha_enabled']) && !empty($modSettings['recaptcha_site_key']) && !empty($modSettings['recaptcha_secret_key']),
2048 2121
 		);
2122
+	}
2049 2123
 	$thisVerification = &$context['controls']['verification'][$verificationOptions['id']];
2050 2124
 
2051 2125
 	// Is there actually going to be anything?
2052
-	if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha']))
2053
-		return false;
2054
-	elseif (!$isNew && !$do_test)
2055
-		return true;
2126
+	if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha'])) {
2127
+			return false;
2128
+	} elseif (!$isNew && !$do_test) {
2129
+			return true;
2130
+	}
2056 2131
 
2057 2132
 	// Sanitize reCAPTCHA fields?
2058 2133
 	if ($thisVerification['can_recaptcha'])
@@ -2065,11 +2140,12 @@  discard block
 block discarded – undo
2065 2140
 	}
2066 2141
 
2067 2142
 	// Add javascript for the object.
2068
-	if ($context['controls']['verification'][$verificationOptions['id']]['show_visual'])
2069
-		$context['insert_after_template'] .= '
2143
+	if ($context['controls']['verification'][$verificationOptions['id']]['show_visual']) {
2144
+			$context['insert_after_template'] .= '
2070 2145
 			<script>
2071 2146
 				var verification' . $verificationOptions['id'] . 'Handle = new smfCaptcha("' . $thisVerification['image_href'] . '", "' . $verificationOptions['id'] . '", ' . ($context['use_graphic_library'] ? 1 : 0) . ');
2072 2147
 			</script>';
2148
+	}
2073 2149
 
2074 2150
 	// If we want questions do we have a cache of all the IDs?
2075 2151
 	if (!empty($thisVerification['number_questions']) && empty($modSettings['question_id_cache']))
@@ -2092,8 +2168,9 @@  discard block
 block discarded – undo
2092 2168
 				unset ($row['id_question']);
2093 2169
 				// Make them all lowercase. We can't directly use $smcFunc['strtolower'] with array_walk, so do it manually, eh?
2094 2170
 				$row['answers'] = smf_json_decode($row['answers'], true);
2095
-				foreach ($row['answers'] as $k => $v)
2096
-					$row['answers'][$k] = $smcFunc['strtolower']($v);
2171
+				foreach ($row['answers'] as $k => $v) {
2172
+									$row['answers'][$k] = $smcFunc['strtolower']($v);
2173
+				}
2097 2174
 
2098 2175
 				$modSettings['question_id_cache']['questions'][$id_question] = $row;
2099 2176
 				$modSettings['question_id_cache']['langs'][$row['lngfile']][] = $id_question;
@@ -2104,35 +2181,42 @@  discard block
 block discarded – undo
2104 2181
 		}
2105 2182
 	}
2106 2183
 
2107
-	if (!isset($_SESSION[$verificationOptions['id'] . '_vv']))
2108
-		$_SESSION[$verificationOptions['id'] . '_vv'] = array();
2184
+	if (!isset($_SESSION[$verificationOptions['id'] . '_vv'])) {
2185
+			$_SESSION[$verificationOptions['id'] . '_vv'] = array();
2186
+	}
2109 2187
 
2110 2188
 	// Do we need to refresh the verification?
2111
-	if (!$do_test && (!empty($_SESSION[$verificationOptions['id'] . '_vv']['did_pass']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) || $_SESSION[$verificationOptions['id'] . '_vv']['count'] > 3) && empty($verificationOptions['dont_refresh']))
2112
-		$force_refresh = true;
2113
-	else
2114
-		$force_refresh = false;
2189
+	if (!$do_test && (!empty($_SESSION[$verificationOptions['id'] . '_vv']['did_pass']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) || $_SESSION[$verificationOptions['id'] . '_vv']['count'] > 3) && empty($verificationOptions['dont_refresh'])) {
2190
+			$force_refresh = true;
2191
+	} else {
2192
+			$force_refresh = false;
2193
+	}
2115 2194
 
2116 2195
 	// This can also force a fresh, although unlikely.
2117
-	if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q'])))
2118
-		$force_refresh = true;
2196
+	if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q']))) {
2197
+			$force_refresh = true;
2198
+	}
2119 2199
 
2120 2200
 	$verification_errors = array();
2121 2201
 	// Start with any testing.
2122 2202
 	if ($do_test)
2123 2203
 	{
2124 2204
 		// This cannot happen!
2125
-		if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count']))
2126
-			fatal_lang_error('no_access', false);
2205
+		if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count'])) {
2206
+					fatal_lang_error('no_access', false);
2207
+		}
2127 2208
 		// ... nor this!
2128
-		if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q'])))
2129
-			fatal_lang_error('no_access', false);
2209
+		if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q']))) {
2210
+					fatal_lang_error('no_access', false);
2211
+		}
2130 2212
 		// Hmm, it's requested but not actually declared. This shouldn't happen.
2131
-		if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']))
2132
-			fatal_lang_error('no_access', false);
2213
+		if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) {
2214
+					fatal_lang_error('no_access', false);
2215
+		}
2133 2216
 		// While we're here, did the user do something bad?
2134
-		if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']]))
2135
-			$verification_errors[] = 'wrong_verification_answer';
2217
+		if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']])) {
2218
+					$verification_errors[] = 'wrong_verification_answer';
2219
+		}
2136 2220
 
2137 2221
 		if ($thisVerification['can_recaptcha'])
2138 2222
 		{
@@ -2143,22 +2227,25 @@  discard block
 block discarded – undo
2143 2227
 			{
2144 2228
 				$resp = $reCaptcha->verify($_POST['g-recaptcha-response'], $user_info['ip']);
2145 2229
 
2146
-				if (!$resp->isSuccess())
2147
-					$verification_errors[] = 'wrong_verification_code';
2230
+				if (!$resp->isSuccess()) {
2231
+									$verification_errors[] = 'wrong_verification_code';
2232
+				}
2233
+			} else {
2234
+							$verification_errors[] = 'wrong_verification_code';
2148 2235
 			}
2149
-			else
2150
-				$verification_errors[] = 'wrong_verification_code';
2151 2236
 		}
2152
-		if ($thisVerification['show_visual'] && (empty($_REQUEST[$verificationOptions['id'] . '_vv']['code']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['code']) || strtoupper($_REQUEST[$verificationOptions['id'] . '_vv']['code']) !== $_SESSION[$verificationOptions['id'] . '_vv']['code']))
2153
-			$verification_errors[] = 'wrong_verification_code';
2237
+		if ($thisVerification['show_visual'] && (empty($_REQUEST[$verificationOptions['id'] . '_vv']['code']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['code']) || strtoupper($_REQUEST[$verificationOptions['id'] . '_vv']['code']) !== $_SESSION[$verificationOptions['id'] . '_vv']['code'])) {
2238
+					$verification_errors[] = 'wrong_verification_code';
2239
+		}
2154 2240
 		if ($thisVerification['number_questions'])
2155 2241
 		{
2156 2242
 			$incorrectQuestions = array();
2157 2243
 			foreach ($_SESSION[$verificationOptions['id'] . '_vv']['q'] as $q)
2158 2244
 			{
2159 2245
 				// We don't have this question any more, thus no answers.
2160
-				if (!isset($modSettings['question_id_cache']['questions'][$q]))
2161
-					continue;
2246
+				if (!isset($modSettings['question_id_cache']['questions'][$q])) {
2247
+									continue;
2248
+				}
2162 2249
 				// This is quite complex. We have our question but it might have multiple answers.
2163 2250
 				// First, did they actually answer this question?
2164 2251
 				if (!isset($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) || trim($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) == '')
@@ -2170,24 +2257,28 @@  discard block
 block discarded – undo
2170 2257
 				else
2171 2258
 				{
2172 2259
 					$given_answer = trim($smcFunc['htmlspecialchars'](strtolower($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q])));
2173
-					if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers']))
2174
-						$incorrectQuestions[] = $q;
2260
+					if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers'])) {
2261
+											$incorrectQuestions[] = $q;
2262
+					}
2175 2263
 				}
2176 2264
 			}
2177 2265
 
2178
-			if (!empty($incorrectQuestions))
2179
-				$verification_errors[] = 'wrong_verification_answer';
2266
+			if (!empty($incorrectQuestions)) {
2267
+							$verification_errors[] = 'wrong_verification_answer';
2268
+			}
2180 2269
 		}
2181 2270
 	}
2182 2271
 
2183 2272
 	// Any errors means we refresh potentially.
2184 2273
 	if (!empty($verification_errors))
2185 2274
 	{
2186
-		if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors']))
2187
-			$_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0;
2275
+		if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors'])) {
2276
+					$_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0;
2277
+		}
2188 2278
 		// Too many errors?
2189
-		elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors'])
2190
-			$force_refresh = true;
2279
+		elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors']) {
2280
+					$force_refresh = true;
2281
+		}
2191 2282
 
2192 2283
 		// Keep a track of these.
2193 2284
 		$_SESSION[$verificationOptions['id'] . '_vv']['errors']++;
@@ -2220,8 +2311,9 @@  discard block
 block discarded – undo
2220 2311
 			// Are we overriding the range?
2221 2312
 			$character_range = !empty($verificationOptions['override_range']) ? $verificationOptions['override_range'] : $context['standard_captcha_range'];
2222 2313
 
2223
-			for ($i = 0; $i < 6; $i++)
2224
-				$_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)];
2314
+			for ($i = 0; $i < 6; $i++) {
2315
+							$_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)];
2316
+			}
2225 2317
 		}
2226 2318
 
2227 2319
 		// Getting some new questions?
@@ -2229,8 +2321,9 @@  discard block
 block discarded – undo
2229 2321
 		{
2230 2322
 			// Attempt to try the current page's language, followed by the user's preference, followed by the site default.
2231 2323
 			$possible_langs = array();
2232
-			if (isset($_SESSION['language']))
2233
-				$possible_langs[] = strtr($_SESSION['language'], array('-utf8' => ''));
2324
+			if (isset($_SESSION['language'])) {
2325
+							$possible_langs[] = strtr($_SESSION['language'], array('-utf8' => ''));
2326
+			}
2234 2327
 			if (!empty($user_info['language']));
2235 2328
 			$possible_langs[] = $user_info['language'];
2236 2329
 			$possible_langs[] = $language;
@@ -2249,8 +2342,7 @@  discard block
 block discarded – undo
2249 2342
 				}
2250 2343
 			}
2251 2344
 		}
2252
-	}
2253
-	else
2345
+	} else
2254 2346
 	{
2255 2347
 		// Same questions as before.
2256 2348
 		$questionIDs = !empty($_SESSION[$verificationOptions['id'] . '_vv']['q']) ? $_SESSION[$verificationOptions['id'] . '_vv']['q'] : array();
@@ -2260,8 +2352,9 @@  discard block
 block discarded – undo
2260 2352
 	// If we do have an empty field, it would be nice to hide it from legitimate users who shouldn't be populating it anyway.
2261 2353
 	if (!empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']))
2262 2354
 	{
2263
-		if (!isset($context['html_headers']))
2264
-			$context['html_headers'] = '';
2355
+		if (!isset($context['html_headers'])) {
2356
+					$context['html_headers'] = '';
2357
+		}
2265 2358
 		$context['html_headers'] .= '<style>.vv_special { display:none; }</style>';
2266 2359
 	}
2267 2360
 
@@ -2287,11 +2380,13 @@  discard block
 block discarded – undo
2287 2380
 	$_SESSION[$verificationOptions['id'] . '_vv']['count'] = empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) ? 1 : $_SESSION[$verificationOptions['id'] . '_vv']['count'] + 1;
2288 2381
 
2289 2382
 	// Return errors if we have them.
2290
-	if (!empty($verification_errors))
2291
-		return $verification_errors;
2383
+	if (!empty($verification_errors)) {
2384
+			return $verification_errors;
2385
+	}
2292 2386
 	// If we had a test that one, make a note.
2293
-	elseif ($do_test)
2294
-		$_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true;
2387
+	elseif ($do_test) {
2388
+			$_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true;
2389
+	}
2295 2390
 
2296 2391
 	// Say that everything went well chaps.
2297 2392
 	return true;
@@ -2316,8 +2411,9 @@  discard block
 block discarded – undo
2316 2411
 	call_integration_hook('integrate_autosuggest', array(&$searchTypes));
2317 2412
 
2318 2413
 	// If we're just checking the callback function is registered return true or false.
2319
-	if ($checkRegistered != null)
2320
-		return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered);
2414
+	if ($checkRegistered != null) {
2415
+			return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered);
2416
+	}
2321 2417
 
2322 2418
 	checkSession('get');
2323 2419
 	loadTemplate('Xml');
@@ -2468,24 +2564,27 @@  discard block
 block discarded – undo
2468 2564
 		foreach ($possible_versions as $ver)
2469 2565
 		{
2470 2566
 			$ver = trim($ver);
2471
-			if (strpos($ver, 'SMF') === 0)
2472
-				$versions[] = $ver;
2567
+			if (strpos($ver, 'SMF') === 0) {
2568
+							$versions[] = $ver;
2569
+			}
2473 2570
 		}
2474 2571
 	}
2475 2572
 	$smcFunc['db_free_result']($request);
2476 2573
 
2477 2574
 	// Just in case we don't have ANYthing.
2478
-	if (empty($versions))
2479
-		$versions = array('SMF 2.0');
2575
+	if (empty($versions)) {
2576
+			$versions = array('SMF 2.0');
2577
+	}
2480 2578
 
2481
-	foreach ($versions as $id => $version)
2482
-		if (strpos($version, strtoupper($_REQUEST['search'])) !== false)
2579
+	foreach ($versions as $id => $version) {
2580
+			if (strpos($version, strtoupper($_REQUEST['search'])) !== false)
2483 2581
 			$xml_data['items']['children'][] = array(
2484 2582
 				'attributes' => array(
2485 2583
 					'id' => $id,
2486 2584
 				),
2487 2585
 				'value' => $version,
2488 2586
 			);
2587
+	}
2489 2588
 
2490 2589
 	return $xml_data;
2491 2590
 }
Please login to merge, or discard this patch.
Sources/Subs-BoardIndex.php 1 patch
Braces   +60 added lines, -47 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 4
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
  * Fetches a list of boards and (optional) categories including
@@ -37,11 +38,12 @@  discard block
 block discarded – undo
37 38
 	require_once($sourcedir . '/Subs-Boards.php');
38 39
 
39 40
 	// For performance, track the latest post while going through the boards.
40
-	if (!empty($boardIndexOptions['set_latest_post']))
41
-		$latest_post = array(
41
+	if (!empty($boardIndexOptions['set_latest_post'])) {
42
+			$latest_post = array(
42 43
 			'timestamp' => 0,
43 44
 			'ref' => 0,
44 45
 		);
46
+	}
45 47
 
46 48
 	// Find all boards and categories, as well as related information.  This will be sorted by the natural order of boards and categories, which we control.
47 49
 	$result_boards = $smcFunc['db_query']('', '
@@ -74,10 +76,11 @@  discard block
 block discarded – undo
74 76
 	);
75 77
 
76 78
 	// Start with an empty array.
77
-	if ($boardIndexOptions['include_categories'])
78
-		$categories = array();
79
-	else
80
-		$this_category = array();
79
+	if ($boardIndexOptions['include_categories']) {
80
+			$categories = array();
81
+	} else {
82
+			$this_category = array();
83
+	}
81 84
 	$boards = array();
82 85
 
83 86
 	// Run through the categories and boards (or only boards)....
@@ -88,8 +91,9 @@  discard block
 block discarded – undo
88 91
 		$row_board['is_read'] = !empty($row_board['is_read']) || $ignoreThisBoard ? '1' : '0';
89 92
 
90 93
 		// Add parent boards to the $boards list later used to fetch moderators
91
-		if ($row_board['id_parent'] == $boardIndexOptions['parent_id'])
92
-			$boards[] = $row_board['id_board'];
94
+		if ($row_board['id_parent'] == $boardIndexOptions['parent_id']) {
95
+					$boards[] = $row_board['id_board'];
96
+		}
93 97
 
94 98
 		if ($boardIndexOptions['include_categories'])
95 99
 		{
@@ -111,8 +115,9 @@  discard block
 block discarded – undo
111 115
 			}
112 116
 
113 117
 			// If this board has new posts in it (and isn't the recycle bin!) then the category is new.
114
-			if (empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $row_board['id_board'])
115
-				$categories[$row_board['id_cat']]['new'] |= empty($row_board['is_read']) && $row_board['poster_name'] != '';
118
+			if (empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $row_board['id_board']) {
119
+							$categories[$row_board['id_cat']]['new'] |= empty($row_board['is_read']) && $row_board['poster_name'] != '';
120
+			}
116 121
 
117 122
 			// Avoid showing category unread link where it only has redirection boards.
118 123
 			$categories[$row_board['id_cat']]['show_unread'] = !empty($categories[$row_board['id_cat']]['show_unread']) ? 1 : !$row_board['is_redirect'];
@@ -160,14 +165,12 @@  discard block
 block discarded – undo
160 165
 				{
161 166
 					$this_category[$row_board['id_board']]['board_class'] = 'redirect';
162 167
 					$this_category[$row_board['id_board']]['board_tooltip'] = $txt['redirect_board'];
163
-				}
164
-				elseif ($this_category[$row_board['id_board']]['new'] || $context['user']['is_guest'])
168
+				} elseif ($this_category[$row_board['id_board']]['new'] || $context['user']['is_guest'])
165 169
 				{
166 170
 					// If we're showing to guests, we want to give them the idea that something interesting is going on!
167 171
 					$this_category[$row_board['id_board']]['board_class'] = 'on';
168 172
 					$this_category[$row_board['id_board']]['board_tooltip'] = $txt['new_posts'];
169
-				}
170
-				else
173
+				} else
171 174
 				{
172 175
 					$this_category[$row_board['id_board']]['board_tooltip'] = $txt['old_posts'];
173 176
 				}
@@ -218,14 +221,16 @@  discard block
 block discarded – undo
218 221
 		// Child of a child... just add it on...
219 222
 		elseif (!empty($boardIndexOptions['countChildPosts']))
220 223
 		{
221
-			if (!isset($parent_map))
222
-				$parent_map = array();
224
+			if (!isset($parent_map)) {
225
+							$parent_map = array();
226
+			}
223 227
 
224
-			if (!isset($parent_map[$row_board['id_parent']]))
225
-				foreach ($this_category as $id => $board)
228
+			if (!isset($parent_map[$row_board['id_parent']])) {
229
+							foreach ($this_category as $id => $board)
226 230
 				{
227 231
 					if (!isset($board['children'][$row_board['id_parent']]))
228 232
 						continue;
233
+			}
229 234
 
230 235
 					$parent_map[$row_board['id_parent']] = array(&$this_category[$id], &$this_category[$id]['children'][$row_board['id_parent']]);
231 236
 					$parent_map[$row_board['id_board']] = array(&$this_category[$id], &$this_category[$id]['children'][$row_board['id_parent']]);
@@ -246,8 +251,9 @@  discard block
 block discarded – undo
246 251
 			continue;
247 252
 		}
248 253
 		// Found a child of a child - skip.
249
-		else
250
-			continue;
254
+		else {
255
+					continue;
256
+		}
251 257
 
252 258
 		// Prepare the subject, and make sure it's not too long.
253 259
 		censorText($row_board['subject']);
@@ -268,12 +274,13 @@  discard block
 block discarded – undo
268 274
 			'topic' => $row_board['id_topic']
269 275
 		);
270 276
 
271
-		if (!empty($settings['avatars_on_boardIndex']))
272
-			$this_last_post['member']['avatar'] = set_avatar_data(array(
277
+		if (!empty($settings['avatars_on_boardIndex'])) {
278
+					$this_last_post['member']['avatar'] = set_avatar_data(array(
273 279
 				'avatar' => $row_board['avatar'],
274 280
 				'email' => $row_board['email_address'],
275 281
 				'filename' => !empty($row['member_filename']) ? $row_board['member_filename'] : '',
276 282
 			));
283
+		}
277 284
 
278 285
 		// Provide the href and link.
279 286
 		if ($row_board['subject'] != '')
@@ -285,8 +292,7 @@  discard block
 block discarded – undo
285 292
 			link, href, subject, start (where they should go for the first unread post.),
286 293
 			and member. (which has id, name, link, href, username in it.) */
287 294
 			$this_last_post['last_post_message'] = sprintf($txt['last_post_message'], $this_last_post['member']['link'], $this_last_post['link'], $this_last_post['time']);
288
-		}
289
-		else
295
+		} else
290 296
 		{
291 297
 			$this_last_post['href'] = '';
292 298
 			$this_last_post['link'] = $txt['not_applicable'];
@@ -294,8 +300,9 @@  discard block
 block discarded – undo
294 300
 		}
295 301
 
296 302
 		// Set the last post in the parent board.
297
-		if ($row_board['id_parent'] == $boardIndexOptions['parent_id'] || ($isChild && !empty($row_board['poster_time']) && $this_category[$row_board['id_parent']]['last_post']['timestamp'] < forum_time(true, $row_board['poster_time'])))
298
-			$this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'] = $this_last_post;
303
+		if ($row_board['id_parent'] == $boardIndexOptions['parent_id'] || ($isChild && !empty($row_board['poster_time']) && $this_category[$row_board['id_parent']]['last_post']['timestamp'] < forum_time(true, $row_board['poster_time']))) {
304
+					$this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'] = $this_last_post;
305
+		}
299 306
 		// Just in the child...?
300 307
 		if ($isChild)
301 308
 		{
@@ -305,15 +312,17 @@  discard block
 block discarded – undo
305 312
 			$this_category[$row_board['id_parent']]['children'][$row_board['id_board']]['new'] &= $row_board['poster_name'] != '';
306 313
 		}
307 314
 		// No last post for this board?  It's not new then, is it..?
308
-		elseif ($row_board['poster_name'] == '')
309
-			$this_category[$row_board['id_board']]['new'] = false;
315
+		elseif ($row_board['poster_name'] == '') {
316
+					$this_category[$row_board['id_board']]['new'] = false;
317
+		}
310 318
 
311 319
 		// Determine a global most recent topic.
312
-		if (!empty($boardIndexOptions['set_latest_post']) && !empty($row_board['poster_time']) && $row_board['poster_time'] > $latest_post['timestamp'] && !$ignoreThisBoard)
313
-			$latest_post = array(
320
+		if (!empty($boardIndexOptions['set_latest_post']) && !empty($row_board['poster_time']) && $row_board['poster_time'] > $latest_post['timestamp'] && !$ignoreThisBoard) {
321
+					$latest_post = array(
314 322
 				'timestamp' => $row_board['poster_time'],
315 323
 				'ref' => &$this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'],
316 324
 			);
325
+		}
317 326
 	}
318 327
 	$smcFunc['db_free_result']($result_boards);
319 328
 
@@ -330,8 +339,9 @@  discard block
 block discarded – undo
330 339
 				if (!empty($moderators[$board['id']]))
331 340
 				{
332 341
 					$categories[$k]['boards'][$j]['moderators'] = $moderators[$board['id']];
333
-					foreach ($moderators[$board['id']] as $moderator)
334
-						$categories[$k]['boards'][$j]['link_moderators'][] = $moderator['link'];
342
+					foreach ($moderators[$board['id']] as $moderator) {
343
+											$categories[$k]['boards'][$j]['link_moderators'][] = $moderator['link'];
344
+					}
335 345
 				}
336 346
 				if (!empty($groups[$board['id']]))
337 347
 				{
@@ -344,16 +354,16 @@  discard block
 block discarded – undo
344 354
 				}
345 355
 			}
346 356
 		}
347
-	}
348
-	else
357
+	} else
349 358
 	{
350 359
 		foreach ($this_category as $k => $board)
351 360
 		{
352 361
 			if (!empty($moderators[$board['id']]))
353 362
 			{
354 363
 				$this_category[$k]['moderators'] = $moderators[$board['id']];
355
-				foreach ($moderators[$board['id']] as $moderator)
356
-					$this_category[$k]['link_moderators'][] = $moderator['link'];
364
+				foreach ($moderators[$board['id']] as $moderator) {
365
+									$this_category[$k]['link_moderators'][] = $moderator['link'];
366
+				}
357 367
 			}
358 368
 			if (!empty($groups[$board['id']]))
359 369
 			{
@@ -367,20 +377,23 @@  discard block
 block discarded – undo
367 377
 		}
368 378
 	}
369 379
 
370
-	if ($boardIndexOptions['include_categories'])
371
-		sortCategories($categories);
372
-	else
373
-		sortBoards($this_category);
380
+	if ($boardIndexOptions['include_categories']) {
381
+			sortCategories($categories);
382
+	} else {
383
+			sortBoards($this_category);
384
+	}
374 385
 
375 386
 	// By now we should know the most recent post...if we wanna know it that is.
376
-	if (!empty($boardIndexOptions['set_latest_post']) && !empty($latest_post['ref']))
377
-		$context['latest_post'] = $latest_post['ref'];
387
+	if (!empty($boardIndexOptions['set_latest_post']) && !empty($latest_post['ref'])) {
388
+			$context['latest_post'] = $latest_post['ref'];
389
+	}
378 390
 
379 391
 	// I can't remember why but trying to make a ternary to get this all in one line is actually a Very Bad Idea.
380
-	if ($boardIndexOptions['include_categories'])
381
-		call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$categories));
382
-	else
383
-		call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$this_category));
392
+	if ($boardIndexOptions['include_categories']) {
393
+			call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$categories));
394
+	} else {
395
+			call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$this_category));
396
+	}
384 397
 
385 398
 	return $boardIndexOptions['include_categories'] ? $categories : $this_category;
386 399
 }
Please login to merge, or discard this patch.
Sources/Likes.php 1 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 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * 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/ManageScheduledTasks.php 1 patch
Braces   +54 added lines, -38 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Scheduled tasks management dispatcher. This function checks permissions and delegates
@@ -40,10 +41,11 @@  discard block
 block discarded – undo
40 41
 	);
41 42
 
42 43
 	// We need to find what's the action.
43
-	if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]))
44
-		$context['sub_action'] = $_REQUEST['sa'];
45
-	else
46
-		$context['sub_action'] = 'tasks';
44
+	if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) {
45
+			$context['sub_action'] = $_REQUEST['sa'];
46
+	} else {
47
+			$context['sub_action'] = 'tasks';
48
+	}
47 49
 
48 50
 	// Now for the lovely tabs. That we all love.
49 51
 	$context[$context['admin_menu_name']]['tab_data'] = array(
@@ -90,9 +92,10 @@  discard block
 block discarded – undo
90 92
 
91 93
 		// Enable and disable as required.
92 94
 		$enablers = array(0);
93
-		foreach ($_POST['enable_task'] as $id => $enabled)
94
-			if ($enabled)
95
+		foreach ($_POST['enable_task'] as $id => $enabled) {
96
+					if ($enabled)
95 97
 				$enablers[] = (int) $id;
98
+		}
96 99
 
97 100
 		// Do the update!
98 101
 		$smcFunc['db_query']('', '
@@ -130,8 +133,9 @@  discard block
 block discarded – undo
130 133
 
131 134
 		// Lets figure out which ones they want to run.
132 135
 		$tasks = array();
133
-		foreach ($_POST['run_task'] as $task => $dummy)
134
-			$tasks[] = (int) $task;
136
+		foreach ($_POST['run_task'] as $task => $dummy) {
137
+					$tasks[] = (int) $task;
138
+		}
135 139
 
136 140
 		// Load up the tasks.
137 141
 		$request = $smcFunc['db_query']('', '
@@ -151,36 +155,41 @@  discard block
 block discarded – undo
151 155
 		while ($row = $smcFunc['db_fetch_assoc']($request))
152 156
 		{
153 157
 			// What kind of task are we handling?
154
-			if (!empty($row['callable']))
155
-				$task_string = $row['callable'];
158
+			if (!empty($row['callable'])) {
159
+							$task_string = $row['callable'];
160
+			}
156 161
 
157 162
 			// Default SMF task or old mods?
158
-			elseif (function_exists('scheduled_' . $row['task']))
159
-				$task_string = 'scheduled_' . $row['task'];
163
+			elseif (function_exists('scheduled_' . $row['task'])) {
164
+							$task_string = 'scheduled_' . $row['task'];
165
+			}
160 166
 
161 167
 			// One last resource, the task name.
162
-			elseif (!empty($row['task']))
163
-				$task_string = $row['task'];
168
+			elseif (!empty($row['task'])) {
169
+							$task_string = $row['task'];
170
+			}
164 171
 
165 172
 			$start_time = microtime();
166 173
 			// The functions got to exist for us to use it.
167
-			if (empty($task_string))
168
-				continue;
174
+			if (empty($task_string)) {
175
+							continue;
176
+			}
169 177
 
170 178
 			// Try to stop a timeout, this would be bad...
171 179
 			@set_time_limit(300);
172
-			if (function_exists('apache_reset_timeout'))
173
-				@apache_reset_timeout();
180
+			if (function_exists('apache_reset_timeout')) {
181
+							@apache_reset_timeout();
182
+			}
174 183
 
175 184
 			// Get the callable.
176 185
 			$callable_task = call_helper($task_string, true);
177 186
 
178 187
 			// Perform the task.
179
-			if (!empty($callable_task))
180
-				$completed = call_user_func($callable_task);
181
-
182
-			else
183
-				$completed = false;
188
+			if (!empty($callable_task)) {
189
+							$completed = call_user_func($callable_task);
190
+			} else {
191
+							$completed = false;
192
+			}
184 193
 
185 194
 			// Log that we did it ;)
186 195
 			if ($completed)
@@ -197,8 +206,9 @@  discard block
 block discarded – undo
197 206
 		$smcFunc['db_free_result']($request);
198 207
 
199 208
 		// If we had any errors, push them to session so we can pick them up next time to tell the user.
200
-		if (!empty($context['scheduled_errors']))
201
-			$_SESSION['st_error'] = $context['scheduled_errors'];
209
+		if (!empty($context['scheduled_errors'])) {
210
+					$_SESSION['st_error'] = $context['scheduled_errors'];
211
+		}
202 212
 
203 213
 		redirectexit('action=admin;area=scheduledtasks;done');
204 214
 	}
@@ -370,8 +380,9 @@  discard block
 block discarded – undo
370 380
 	$context['server_time'] = timeformat(time(), false, 'server');
371 381
 
372 382
 	// Cleaning...
373
-	if (!isset($_GET['tid']))
374
-		fatal_lang_error('no_access', false);
383
+	if (!isset($_GET['tid'])) {
384
+			fatal_lang_error('no_access', false);
385
+	}
375 386
 	$_GET['tid'] = (int) $_GET['tid'];
376 387
 
377 388
 	// Saving?
@@ -387,10 +398,12 @@  discard block
 block discarded – undo
387 398
 		preg_match('~(\d{1,2}):(\d{1,2})~', $_POST['offset'], $matches);
388 399
 
389 400
 		// If a half is empty then assume zero offset!
390
-		if (!isset($matches[2]) || $matches[2] > 59)
391
-			$matches[2] = 0;
392
-		if (!isset($matches[1]) || $matches[1] > 23)
393
-			$matches[1] = 0;
401
+		if (!isset($matches[2]) || $matches[2] > 59) {
402
+					$matches[2] = 0;
403
+		}
404
+		if (!isset($matches[1]) || $matches[1] > 23) {
405
+					$matches[1] = 0;
406
+		}
394 407
 
395 408
 		// Now the offset is easy; easy peasy - except we need to offset by a few hours...
396 409
 		$offset = $matches[1] * 3600 + $matches[2] * 60 - date('Z');
@@ -400,8 +413,9 @@  discard block
 block discarded – undo
400 413
 		$unit = in_array(substr($_POST['unit'], 0, 1), array('m', 'h', 'd', 'w')) ? substr($_POST['unit'], 0, 1) : 'd';
401 414
 
402 415
 		// Don't allow one minute intervals.
403
-		if ($interval == 1 && $unit == 'm')
404
-			$interval = 2;
416
+		if ($interval == 1 && $unit == 'm') {
417
+					$interval = 2;
418
+		}
405 419
 
406 420
 		// Is it disabled?
407 421
 		$disabled = !isset($_POST['enabled']) ? 1 : 0;
@@ -439,8 +453,9 @@  discard block
 block discarded – undo
439 453
 	);
440 454
 
441 455
 	// Should never, ever, happen!
442
-	if ($smcFunc['db_num_rows']($request) == 0)
443
-		fatal_lang_error('no_access', false);
456
+	if ($smcFunc['db_num_rows']($request) == 0) {
457
+			fatal_lang_error('no_access', false);
458
+	}
444 459
 
445 460
 	while ($row = $smcFunc['db_fetch_assoc']($request))
446 461
 	{
@@ -598,13 +613,14 @@  discard block
 block discarded – undo
598 613
 		)
599 614
 	);
600 615
 	$log_entries = array();
601
-	while ($row = $smcFunc['db_fetch_assoc']($request))
602
-		$log_entries[] = array(
616
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
617
+			$log_entries[] = array(
603 618
 			'id' => $row['id_log'],
604 619
 			'name' => isset($txt['scheduled_task_' . $row['task']]) ? $txt['scheduled_task_' . $row['task']] : $row['task'],
605 620
 			'time_run' => $row['time_run'],
606 621
 			'time_taken' => $row['time_taken'],
607 622
 		);
623
+	}
608 624
 	$smcFunc['db_free_result']($request);
609 625
 
610 626
 	return $log_entries;
Please login to merge, or discard this patch.
Sources/ReportToMod.php 1 patch
Braces   +71 added lines, -51 removed lines patch added patch discarded remove patch
@@ -12,8 +12,9 @@  discard block
 block discarded – undo
12 12
  * @version 2.1 Beta 4
13 13
  */
14 14
 
15
-if (!defined('SMF'))
15
+if (!defined('SMF')) {
16 16
 	die('No direct access...');
17
+}
17 18
 
18 19
 /**
19 20
  * Report a post or profile to the moderator... ask for a comment.
@@ -35,10 +36,11 @@  discard block
 block discarded – undo
35 36
 
36 37
 	// You can't use this if it's off or you are not allowed to do it.
37 38
 	// If we don't have the ID of something to report, we'll die with a no_access error below
38
-	if (isset($_REQUEST['msg']))
39
-		isAllowedTo('report_any');
40
-	elseif (isset($_REQUEST['u']))
41
-		isAllowedTo('report_user');
39
+	if (isset($_REQUEST['msg'])) {
40
+			isAllowedTo('report_any');
41
+	} elseif (isset($_REQUEST['u'])) {
42
+			isAllowedTo('report_user');
43
+	}
42 44
 
43 45
 	// Previewing or modifying?
44 46
 	if (isset($_POST['preview']) && !isset($_POST['save']))
@@ -56,19 +58,23 @@  discard block
 block discarded – undo
56 58
 	}
57 59
 
58 60
 	// If they're posting, it should be processed by ReportToModerator2.
59
-	if ((isset($_POST[$context['session_var']]) || isset($_POST['save'])) && empty($context['post_errors']) && !isset($_POST['preview']))
60
-		ReportToModerator2();
61
+	if ((isset($_POST[$context['session_var']]) || isset($_POST['save'])) && empty($context['post_errors']) && !isset($_POST['preview'])) {
62
+			ReportToModerator2();
63
+	}
61 64
 
62 65
 	// We need a message ID or user ID to check!
63
-	if (empty($_REQUEST['msg']) && empty($_REQUEST['mid']) && empty($_REQUEST['u']))
64
-		fatal_lang_error('no_access', false);
66
+	if (empty($_REQUEST['msg']) && empty($_REQUEST['mid']) && empty($_REQUEST['u'])) {
67
+			fatal_lang_error('no_access', false);
68
+	}
65 69
 
66 70
 	// For compatibility, accept mid, but we should be using msg. (not the flavor kind!)
67
-	if (!empty($_REQUEST['msg']) || !empty($_REQUEST['mid']))
68
-		$_REQUEST['msg'] = empty($_REQUEST['msg']) ? (int) $_REQUEST['mid'] : (int) $_REQUEST['msg'];
71
+	if (!empty($_REQUEST['msg']) || !empty($_REQUEST['mid'])) {
72
+			$_REQUEST['msg'] = empty($_REQUEST['msg']) ? (int) $_REQUEST['mid'] : (int) $_REQUEST['msg'];
73
+	}
69 74
 	// msg and mid empty - assume we're reporting a user
70
-	elseif (!empty($_REQUEST['u']))
71
-		$_REQUEST['u'] = (int) $_REQUEST['u'];
75
+	elseif (!empty($_REQUEST['u'])) {
76
+			$_REQUEST['u'] = (int) $_REQUEST['u'];
77
+	}
72 78
 
73 79
 	// Set up some form values
74 80
 	$context['report_type'] = isset($_REQUEST['msg']) ? 'msg' : 'u';
@@ -89,8 +95,9 @@  discard block
 block discarded – undo
89 95
 				'id_msg' => $_REQUEST['msg'],
90 96
 			)
91 97
 		);
92
-		if ($smcFunc['db_num_rows']($result) == 0)
93
-			fatal_lang_error('no_board', false);
98
+		if ($smcFunc['db_num_rows']($result) == 0) {
99
+					fatal_lang_error('no_board', false);
100
+		}
94 101
 		list ($_REQUEST['msg'], $member, $starter) = $smcFunc['db_fetch_row']($result);
95 102
 		$smcFunc['db_free_result']($result);
96 103
 
@@ -101,8 +108,7 @@  discard block
 block discarded – undo
101 108
 
102 109
 		// The submit URL is different for users than it is for posts
103 110
 		$context['submit_url'] = $scripturl . '?action=reporttm;msg=' . $_REQUEST['msg'] . ';topic=' . $topic;
104
-	}
105
-	else
111
+	} else
106 112
 	{
107 113
 		// Check the user's ID
108 114
 		$result = $smcFunc['db_query']('', '
@@ -114,8 +120,9 @@  discard block
 block discarded – undo
114 120
 			)
115 121
 		);
116 122
 
117
-		if ($smcFunc['db_num_rows']($result) == 0)
118
-			fatal_lang_error('no_user', false);
123
+		if ($smcFunc['db_num_rows']($result) == 0) {
124
+					fatal_lang_error('no_user', false);
125
+		}
119 126
 		list($_REQUEST['u'], $display_name, $username) = $smcFunc['db_fetch_row']($result);
120 127
 
121 128
 		$context['current_user'] = $_REQUEST['u'];
@@ -170,10 +177,11 @@  discard block
 block discarded – undo
170 177
 	is_not_guest();
171 178
 
172 179
 	// You must have the proper permissions!
173
-	if (isset($_REQUEST['msg']))
174
-		isAllowedTo('report_any');
175
-	else
176
-		isAllowedTo('report_user');
180
+	if (isset($_REQUEST['msg'])) {
181
+			isAllowedTo('report_any');
182
+	} else {
183
+			isAllowedTo('report_user');
184
+	}
177 185
 
178 186
 	// Make sure they aren't spamming.
179 187
 	spamProtection('reporttm');
@@ -187,17 +195,20 @@  discard block
 block discarded – undo
187 195
 	$post_errors = array();
188 196
 
189 197
 	// Check their session.
190
-	if (checkSession('post', '', false) != '')
191
-		$post_errors[] = 'session_timeout';
198
+	if (checkSession('post', '', false) != '') {
199
+			$post_errors[] = 'session_timeout';
200
+	}
192 201
 
193 202
 	// Make sure we have a comment and it's clean.
194
-	if (!isset($_POST['comment']) || $smcFunc['htmltrim']($_POST['comment']) === '')
195
-		$post_errors[] = 'no_comment';
203
+	if (!isset($_POST['comment']) || $smcFunc['htmltrim']($_POST['comment']) === '') {
204
+			$post_errors[] = 'no_comment';
205
+	}
196 206
 
197 207
 	$poster_comment = strtr($smcFunc['htmlspecialchars']($_POST['comment']), array("\r" => '', "\t" => ''));
198 208
 
199
-	if ($smcFunc['strlen']($poster_comment) > 254)
200
-		$post_errors[] = 'post_too_long';
209
+	if ($smcFunc['strlen']($poster_comment) > 254) {
210
+			$post_errors[] = 'post_too_long';
211
+	}
201 212
 
202 213
 	// Any errors?
203 214
 	if (!empty($post_errors))
@@ -205,8 +216,9 @@  discard block
 block discarded – undo
205 216
 		loadLanguage('Errors');
206 217
 
207 218
 		$context['post_errors'] = array();
208
-		foreach ($post_errors as $post_error)
209
-			$context['post_errors'][$post_error] = $txt['error_' . $post_error];
219
+		foreach ($post_errors as $post_error) {
220
+					$context['post_errors'][$post_error] = $txt['error_' . $post_error];
221
+		}
210 222
 
211 223
 		return ReportToModerator();
212 224
 	}
@@ -215,8 +227,7 @@  discard block
 block discarded – undo
215 227
 	{
216 228
 		// Handle this elsewhere to keep things from getting too long
217 229
 		reportPost($_POST['msg'], $poster_comment);
218
-	}
219
-	else
230
+	} else
220 231
 	{
221 232
 		reportUser($_POST['u'], $poster_comment);
222 233
 	}
@@ -247,8 +258,9 @@  discard block
 block discarded – undo
247 258
 			'id_msg' => $_POST['msg'],
248 259
 		)
249 260
 	);
250
-	if ($smcFunc['db_num_rows']($request) == 0)
251
-		fatal_lang_error('no_board', false);
261
+	if ($smcFunc['db_num_rows']($request) == 0) {
262
+			fatal_lang_error('no_board', false);
263
+	}
252 264
 	$message = $smcFunc['db_fetch_assoc']($request);
253 265
 	$smcFunc['db_free_result']($request);
254 266
 
@@ -264,18 +276,20 @@  discard block
 block discarded – undo
264 276
 			'ignored' => 1,
265 277
 		)
266 278
 	);
267
-	if ($smcFunc['db_num_rows']($request) != 0)
268
-		list ($id_report, $ignore) = $smcFunc['db_fetch_row']($request);
279
+	if ($smcFunc['db_num_rows']($request) != 0) {
280
+			list ($id_report, $ignore) = $smcFunc['db_fetch_row']($request);
281
+	}
269 282
 
270 283
 	$smcFunc['db_free_result']($request);
271 284
 
272 285
 	// If we're just going to ignore these, then who gives a monkeys...
273
-	if (!empty($ignore))
274
-		redirectexit('topic=' . $topic . '.msg' . $_POST['msg'] . '#msg' . $_POST['msg']);
286
+	if (!empty($ignore)) {
287
+			redirectexit('topic=' . $topic . '.msg' . $_POST['msg'] . '#msg' . $_POST['msg']);
288
+	}
275 289
 
276 290
 	// Already reported? My god, we could be dealing with a real rogue here...
277
-	if (!empty($id_report))
278
-		$smcFunc['db_query']('', '
291
+	if (!empty($id_report)) {
292
+			$smcFunc['db_query']('', '
279 293
 			UPDATE {db_prefix}log_reported
280 294
 			SET num_reports = num_reports + 1, time_updated = {int:current_time}
281 295
 			WHERE id_report = {int:id_report}',
@@ -284,11 +298,13 @@  discard block
 block discarded – undo
284 298
 				'id_report' => $id_report,
285 299
 			)
286 300
 		);
301
+	}
287 302
 	// Otherwise, we shall make one!
288 303
 	else
289 304
 	{
290
-		if (empty($message['real_name']))
291
-			$message['real_name'] = $message['poster_name'];
305
+		if (empty($message['real_name'])) {
306
+					$message['real_name'] = $message['poster_name'];
307
+		}
292 308
 
293 309
 		$id_report = $smcFunc['db_insert']('',
294 310
 			'{db_prefix}log_reported',
@@ -367,8 +383,9 @@  discard block
 block discarded – undo
367 383
 			'id_member' => $_POST['u']
368 384
 		)
369 385
 	);
370
-	if ($smcFunc['db_num_rows']($request) == 0)
371
-		fatal_lang_error('no_user', false);
386
+	if ($smcFunc['db_num_rows']($request) == 0) {
387
+			fatal_lang_error('no_user', false);
388
+	}
372 389
 	$user = $smcFunc['db_fetch_assoc']($request);
373 390
 	$smcFunc['db_free_result']($request);
374 391
 
@@ -388,18 +405,20 @@  discard block
 block discarded – undo
388 405
 			'ignored' => 1,
389 406
 		)
390 407
 	);
391
-	if ($smcFunc['db_num_rows']($request) != 0)
392
-		list ($id_report, $ignore) = $smcFunc['db_fetch_row']($request);
408
+	if ($smcFunc['db_num_rows']($request) != 0) {
409
+			list ($id_report, $ignore) = $smcFunc['db_fetch_row']($request);
410
+	}
393 411
 
394 412
 	$smcFunc['db_free_result']($request);
395 413
 
396 414
 	// If we're just going to ignore these, then who gives a monkeys...
397
-	if (!empty($ignore))
398
-		redirectexit('action=profile;u=' . $_POST['u']);
415
+	if (!empty($ignore)) {
416
+			redirectexit('action=profile;u=' . $_POST['u']);
417
+	}
399 418
 
400 419
 	// Already reported? My god, we could be dealing with a real rogue here...
401
-	if (!empty($id_report))
402
-		$smcFunc['db_query']('', '
420
+	if (!empty($id_report)) {
421
+			$smcFunc['db_query']('', '
403 422
 			UPDATE {db_prefix}log_reported
404 423
 			SET num_reports = num_reports + 1, time_updated = {int:current_time}
405 424
 			WHERE id_report = {int:id_report}',
@@ -408,6 +427,7 @@  discard block
 block discarded – undo
408 427
 				'id_report' => $id_report,
409 428
 			)
410 429
 		);
430
+	}
411 431
 	// Otherwise, we shall make one!
412 432
 	else
413 433
 	{
Please login to merge, or discard this patch.
Sources/Memberlist.php 1 patch
Braces   +81 added lines, -63 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 4
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
  * Shows a listing of registered members.
@@ -110,8 +111,9 @@  discard block
 block discarded – undo
110 111
 
111 112
 	$context['custom_profile_fields'] = getCustFieldsMList();
112 113
 
113
-	if (!empty($context['custom_profile_fields']['columns']))
114
-		$context['columns'] += $context['custom_profile_fields']['columns'];
114
+	if (!empty($context['custom_profile_fields']['columns'])) {
115
+			$context['columns'] += $context['custom_profile_fields']['columns'];
116
+	}
115 117
 
116 118
 	$context['colspan'] = 0;
117 119
 	$context['disabled_fields'] = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array();
@@ -147,12 +149,12 @@  discard block
 block discarded – undo
147 149
 	call_integration_hook('integrate_memberlist_buttons');
148 150
 
149 151
 	// Jump to the sub action.
150
-	if (isset($subActions[$context['listing_by']]))
151
-		call_helper($subActions[$context['listing_by']][1]);
152
-
153
-	else
154
-		call_helper($subActions['all'][1]);
155
-}
152
+	if (isset($subActions[$context['listing_by']])) {
153
+			call_helper($subActions[$context['listing_by']][1]);
154
+	} else {
155
+			call_helper($subActions['all'][1]);
156
+	}
157
+	}
156 158
 
157 159
 /**
158 160
  * List all members, page by page, with sorting.
@@ -177,8 +179,9 @@  discard block
 block discarded – undo
177 179
 	if ($use_cache)
178 180
 	{
179 181
 		// Maybe there's something cached already.
180
-		if (!empty($modSettings['memberlist_cache']))
181
-			$memberlist_cache = smf_json_decode($modSettings['memberlist_cache'], true);
182
+		if (!empty($modSettings['memberlist_cache'])) {
183
+					$memberlist_cache = smf_json_decode($modSettings['memberlist_cache'], true);
184
+		}
182 185
 
183 186
 		// The chunk size for the cached index.
184 187
 		$cache_step_size = 500;
@@ -234,13 +237,15 @@  discard block
 block discarded – undo
234 237
 	}
235 238
 
236 239
 	// Set defaults for sort (real_name) and start. (0)
237
-	if (!isset($_REQUEST['sort']) || !isset($context['columns'][$_REQUEST['sort']]))
238
-		$_REQUEST['sort'] = 'real_name';
240
+	if (!isset($_REQUEST['sort']) || !isset($context['columns'][$_REQUEST['sort']])) {
241
+			$_REQUEST['sort'] = 'real_name';
242
+	}
239 243
 
240 244
 	if (!is_numeric($_REQUEST['start']))
241 245
 	{
242
-		if (preg_match('~^[^\'\\\\/]~' . ($context['utf8'] ? 'u' : ''), $smcFunc['strtolower']($_REQUEST['start']), $match) === 0)
243
-			fatal_error('Hacker?', false);
246
+		if (preg_match('~^[^\'\\\\/]~' . ($context['utf8'] ? 'u' : ''), $smcFunc['strtolower']($_REQUEST['start']), $match) === 0) {
247
+					fatal_error('Hacker?', false);
248
+		}
244 249
 
245 250
 		$_REQUEST['start'] = $match[0];
246 251
 
@@ -259,16 +264,18 @@  discard block
 block discarded – undo
259 264
 	}
260 265
 
261 266
 	$context['letter_links'] = '';
262
-	for ($i = 97; $i < 123; $i++)
263
-		$context['letter_links'] .= '<a href="' . $scripturl . '?action=mlist;sa=all;start=' . chr($i) . '#letter' . chr($i) . '">' . strtoupper(chr($i)) . '</a> ';
267
+	for ($i = 97; $i < 123; $i++) {
268
+			$context['letter_links'] .= '<a href="' . $scripturl . '?action=mlist;sa=all;start=' . chr($i) . '#letter' . chr($i) . '">' . strtoupper(chr($i)) . '</a> ';
269
+	}
264 270
 
265 271
 	// Sort out the column information.
266 272
 	foreach ($context['columns'] as $col => $column_details)
267 273
 	{
268 274
 		$context['columns'][$col]['href'] = $scripturl . '?action=mlist;sort=' . $col . ';start=0';
269 275
 
270
-		if ((!isset($_REQUEST['desc']) && $col == $_REQUEST['sort']) || ($col != $_REQUEST['sort'] && !empty($column_details['default_sort_rev'])))
271
-			$context['columns'][$col]['href'] .= ';desc';
276
+		if ((!isset($_REQUEST['desc']) && $col == $_REQUEST['sort']) || ($col != $_REQUEST['sort'] && !empty($column_details['default_sort_rev']))) {
277
+					$context['columns'][$col]['href'] .= ';desc';
278
+		}
272 279
 
273 280
 		$context['columns'][$col]['link'] = '<a href="' . $context['columns'][$col]['href'] . '" rel="nofollow">' . $context['columns'][$col]['label'] . '</a>';
274 281
 		$context['columns'][$col]['selected'] = $_REQUEST['sort'] == $col;
@@ -317,8 +324,9 @@  discard block
 block discarded – undo
317 324
 	elseif ($use_cache && $_REQUEST['sort'] === 'real_name')
318 325
 	{
319 326
 		$first_offset = floor(($memberlist_cache['num_members'] - $modSettings['defaultMaxMembers'] - $_REQUEST['start']) / $cache_step_size) * $cache_step_size;
320
-		if ($first_offset < 0)
321
-			$first_offset = 0;
327
+		if ($first_offset < 0) {
328
+					$first_offset = 0;
329
+		}
322 330
 		$second_offset = ceil(($memberlist_cache['num_members'] - $_REQUEST['start']) / $cache_step_size) * $cache_step_size;
323 331
 
324 332
 		$where = 'mem.real_name BETWEEN {string:real_name_low} AND {string:real_name_high}';
@@ -328,8 +336,9 @@  discard block
 block discarded – undo
328 336
 	}
329 337
 
330 338
 	$custom_fields_qry = '';
331
-	if (!empty($context['custom_profile_fields']['join'][$_REQUEST['sort']]))
332
-		$custom_fields_qry = $context['custom_profile_fields']['join'][$_REQUEST['sort']];
339
+	if (!empty($context['custom_profile_fields']['join'][$_REQUEST['sort']])) {
340
+			$custom_fields_qry = $context['custom_profile_fields']['join'][$_REQUEST['sort']];
341
+	}
333 342
 
334 343
 	// Select the members from the database.
335 344
 	$request = $smcFunc['db_query']('', '
@@ -399,12 +408,13 @@  discard block
 block discarded – undo
399 408
 		)
400 409
 	);
401 410
 	$context['custom_search_fields'] = array();
402
-	while ($row = $smcFunc['db_fetch_assoc']($request))
403
-		$context['custom_search_fields'][$row['col_name']] = array(
411
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
412
+			$context['custom_search_fields'][$row['col_name']] = array(
404 413
 			'colname' => $row['col_name'],
405 414
 			'name' => $row['field_name'],
406 415
 			'desc' => $row['field_desc'],
407 416
 		);
417
+	}
408 418
 	$smcFunc['db_free_result']($request);
409 419
 
410 420
 	// They're searching..
@@ -417,23 +427,27 @@  discard block
 block discarded – undo
417 427
 		$context['old_search_value'] = urlencode($_REQUEST['search']);
418 428
 
419 429
 		// No fields?  Use default...
420
-		if (empty($_POST['fields']))
421
-			$_POST['fields'] = array('name');
430
+		if (empty($_POST['fields'])) {
431
+					$_POST['fields'] = array('name');
432
+		}
422 433
 
423 434
 		// Set defaults for how the results are sorted
424
-		if (!isset($_REQUEST['sort']) || !isset($context['columns'][$_REQUEST['sort']]))
425
-			$_REQUEST['sort'] = 'real_name';
435
+		if (!isset($_REQUEST['sort']) || !isset($context['columns'][$_REQUEST['sort']])) {
436
+					$_REQUEST['sort'] = 'real_name';
437
+		}
426 438
 
427 439
 		// Build the column link / sort information.
428 440
 		foreach ($context['columns'] as $col => $column_details)
429 441
 		{
430 442
 			$context['columns'][$col]['href'] = $scripturl . '?action=mlist;sa=search;start=0;sort=' . $col;
431 443
 
432
-			if ((!isset($_REQUEST['desc']) && $col == $_REQUEST['sort']) || ($col != $_REQUEST['sort'] && !empty($column_details['default_sort_rev'])))
433
-				$context['columns'][$col]['href'] .= ';desc';
444
+			if ((!isset($_REQUEST['desc']) && $col == $_REQUEST['sort']) || ($col != $_REQUEST['sort'] && !empty($column_details['default_sort_rev']))) {
445
+							$context['columns'][$col]['href'] .= ';desc';
446
+			}
434 447
 
435
-			if (isset($_POST['search']) && isset($_POST['fields']))
436
-				$context['columns'][$col]['href'] .= ';search=' . $_POST['search'] . ';fields=' . implode(',', $_POST['fields']);
448
+			if (isset($_POST['search']) && isset($_POST['fields'])) {
449
+							$context['columns'][$col]['href'] .= ';search=' . $_POST['search'] . ';fields=' . implode(',', $_POST['fields']);
450
+			}
437 451
 
438 452
 			$context['columns'][$col]['link'] = '<a href="' . $context['columns'][$col]['href'] . '" rel="nofollow">' . $context['columns'][$col]['label'] . '</a>';
439 453
 			$context['columns'][$col]['selected'] = $_REQUEST['sort'] == $col;
@@ -456,8 +470,7 @@  discard block
 block discarded – undo
456 470
 		{
457 471
 			$fields = allowedTo('moderate_forum') ? array('member_name', 'real_name') : array('real_name');
458 472
 			$search_fields[] = 'name';
459
-		}
460
-		else
473
+		} else
461 474
 		{
462 475
 			$fields = array();
463 476
 			$search_fields = array();
@@ -482,9 +495,10 @@  discard block
 block discarded – undo
482 495
 			$search_fields[] = 'email';
483 496
 		}
484 497
 
485
-		if ($smcFunc['db_case_sensitive'])
486
-			foreach ($fields as $key => $field)
498
+		if ($smcFunc['db_case_sensitive']) {
499
+					foreach ($fields as $key => $field)
487 500
 				$fields[$key] = 'LOWER(' . $field . ')';
501
+		}
488 502
 
489 503
 		$customJoin = array();
490 504
 		$customCount = 10;
@@ -503,8 +517,9 @@  discard block
 block discarded – undo
503 517
 		}
504 518
 
505 519
 		// No search fields? That means you're trying to hack things
506
-		if (empty($search_fields))
507
-			fatal_lang_error('invalid_search_string', false);
520
+		if (empty($search_fields)) {
521
+					fatal_lang_error('invalid_search_string', false);
522
+		}
508 523
 
509 524
 		$query = $_POST['search'] == '' ? '= {string:blank_string}' : ($smcFunc['db_case_sensitive'] ? 'LIKE LOWER({string:search})' : 'LIKE {string:search}');
510 525
 
@@ -542,8 +557,7 @@  discard block
 block discarded – undo
542 557
 		);
543 558
 		printMemberListRows($request);
544 559
 		$smcFunc['db_free_result']($request);
545
-	}
546
-	else
560
+	} else
547 561
 	{
548 562
 		// These are all the possible fields.
549 563
 		$context['search_fields'] = array(
@@ -558,14 +572,14 @@  discard block
 block discarded – undo
558 572
 		{
559 573
 			unset($context['search_fields']['email']);
560 574
 			$context['search_defaults'] = array('name');
561
-		}
562
-		else
575
+		} else
563 576
 		{
564 577
 			$context['search_defaults'] = array('name', 'email');
565 578
 		}
566 579
 
567
-		foreach ($context['custom_search_fields'] as $field)
568
-			$context['search_fields']['cust_' . $field['colname']] = sprintf($txt['mlist_search_by'], $field['name']);
580
+		foreach ($context['custom_search_fields'] as $field) {
581
+					$context['search_fields']['cust_' . $field['colname']] = sprintf($txt['mlist_search_by'], $field['name']);
582
+		}
569 583
 
570 584
 		$context['sub_template'] = 'search';
571 585
 		$context['old_search'] = isset($_GET['search']) ? $_GET['search'] : (isset($_POST['search']) ? $smcFunc['htmlspecialchars']($_POST['search']) : '');
@@ -607,12 +621,14 @@  discard block
 block discarded – undo
607 621
 	$smcFunc['db_free_result']($result);
608 622
 
609 623
 	// Avoid division by zero...
610
-	if ($most_posts == 0)
611
-		$most_posts = 1;
624
+	if ($most_posts == 0) {
625
+			$most_posts = 1;
626
+	}
612 627
 
613 628
 	$members = array();
614
-	while ($row = $smcFunc['db_fetch_assoc']($request))
615
-		$members[] = $row['id_member'];
629
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
630
+			$members[] = $row['id_member'];
631
+	}
616 632
 
617 633
 	// Load all the members for display.
618 634
 	loadMemberData($members);
@@ -620,8 +636,9 @@  discard block
 block discarded – undo
620 636
 	$context['members'] = array();
621 637
 	foreach ($members as $member)
622 638
 	{
623
-		if (!loadMemberContext($member))
624
-			continue;
639
+		if (!loadMemberContext($member)) {
640
+					continue;
641
+		}
625 642
 
626 643
 		$context['members'][$member] = $memberContext[$member];
627 644
 		$context['members'][$member]['post_percent'] = round(($context['members'][$member]['real_posts'] * 100) / $most_posts);
@@ -638,20 +655,21 @@  discard block
 block discarded – undo
638 655
 					continue;
639 656
 				}
640 657
 
641
-				if ($column['bbc'] && !empty($context['members'][$member]['options'][$key]))
642
-					$context['members'][$member]['options'][$key] = strip_tags(parse_bbc($context['members'][$member]['options'][$key]));
643
-
644
-				elseif ($column['type'] == 'check')
645
-					$context['members'][$member]['options'][$key] = $context['members'][$member]['options'][$key] == 0 ? $txt['no'] : $txt['yes'];
658
+				if ($column['bbc'] && !empty($context['members'][$member]['options'][$key])) {
659
+									$context['members'][$member]['options'][$key] = strip_tags(parse_bbc($context['members'][$member]['options'][$key]));
660
+				} elseif ($column['type'] == 'check') {
661
+									$context['members'][$member]['options'][$key] = $context['members'][$member]['options'][$key] == 0 ? $txt['no'] : $txt['yes'];
662
+				}
646 663
 
647 664
 				// Enclosing the user input within some other text?
648
-				if (!empty($column['enclose']))
649
-					$context['members'][$member]['options'][$key] = strtr($column['enclose'], array(
665
+				if (!empty($column['enclose'])) {
666
+									$context['members'][$member]['options'][$key] = strtr($column['enclose'], array(
650 667
 						'{SCRIPTURL}' => $scripturl,
651 668
 						'{IMAGES_URL}' => $settings['images_url'],
652 669
 						'{DEFAULT_IMAGES_URL}' => $settings['default_images_url'],
653 670
 						'{INPUT}' => $context['members'][$member]['options'][$key],
654 671
 					));
672
+				}
655 673
 			}
656 674
 		}
657 675
 	}
@@ -692,17 +710,17 @@  discard block
 block discarded – undo
692 710
 		);
693 711
 
694 712
 		// Get the right sort method depending on the cust field type.
695
-		if ($row['field_type'] != 'check')
696
-			$cpf['columns'][$row['col_name']]['sort'] = array(
713
+		if ($row['field_type'] != 'check') {
714
+					$cpf['columns'][$row['col_name']]['sort'] = array(
697 715
 				'down' => 'LENGTH(t' . $row['col_name'] . '.value) > 0 ASC, COALESCE(t' . $row['col_name'] . '.value, \'\') DESC',
698 716
 				'up' => 'LENGTH(t' . $row['col_name'] . '.value) > 0 DESC, COALESCE(t' . $row['col_name'] . '.value, \'\') ASC'
699 717
 			);
700
-
701
-		else
702
-			$cpf['columns'][$row['col_name']]['sort'] = array(
718
+		} else {
719
+					$cpf['columns'][$row['col_name']]['sort'] = array(
703 720
 				'down' => 't' . $row['col_name'] . '.value DESC',
704 721
 				'up' => 't' . $row['col_name'] . '.value ASC'
705 722
 			);
723
+		}
706 724
 
707 725
 		$cpf['join'][$row['col_name']] = 'LEFT JOIN {db_prefix}themes AS t' . $row['col_name'] . ' ON (t' . $row['col_name'] . '.variable = {literal:' . $row['col_name'] . '} AND t' . $row['col_name'] . '.id_theme = 1 AND t' . $row['col_name'] . '.id_member = mem.id_member)';
708 726
 	}
Please login to merge, or discard this patch.
Sources/Subs-List.php 1 patch
Braces   +85 added lines, -59 removed lines patch added patch discarded remove patch
@@ -12,8 +12,9 @@  discard block
 block discarded – undo
12 12
  * @version 2.1 Beta 4
13 13
  */
14 14
 
15
-if (!defined('SMF'))
15
+if (!defined('SMF')) {
16 16
 	die('No direct access...');
17
+}
17 18
 
18 19
 /**
19 20
  * Create a new list
@@ -41,21 +42,21 @@  discard block
 block discarded – undo
41 42
 	{
42 43
 		$list_context['sort'] = array();
43 44
 		$sort = '1=1';
44
-	}
45
-	else
45
+	} else
46 46
 	{
47 47
 		$request_var_sort = isset($listOptions['request_vars']['sort']) ? $listOptions['request_vars']['sort'] : 'sort';
48 48
 		$request_var_desc = isset($listOptions['request_vars']['desc']) ? $listOptions['request_vars']['desc'] : 'desc';
49
-		if (isset($_REQUEST[$request_var_sort], $listOptions['columns'][$_REQUEST[$request_var_sort]], $listOptions['columns'][$_REQUEST[$request_var_sort]]['sort']))
50
-			$list_context['sort'] = array(
49
+		if (isset($_REQUEST[$request_var_sort], $listOptions['columns'][$_REQUEST[$request_var_sort]], $listOptions['columns'][$_REQUEST[$request_var_sort]]['sort'])) {
50
+					$list_context['sort'] = array(
51 51
 				'id' => $_REQUEST[$request_var_sort],
52 52
 				'desc' => isset($_REQUEST[$request_var_desc]) && isset($listOptions['columns'][$_REQUEST[$request_var_sort]]['sort']['reverse']),
53 53
 			);
54
-		else
55
-			$list_context['sort'] = array(
54
+		} else {
55
+					$list_context['sort'] = array(
56 56
 				'id' => $listOptions['default_sort_col'],
57 57
 				'desc' => (!empty($listOptions['default_sort_dir']) && $listOptions['default_sort_dir'] == 'desc') || (!empty($listOptions['columns'][$listOptions['default_sort_col']]['sort']['default']) && substr($listOptions['columns'][$listOptions['default_sort_col']]['sort']['default'], -4, 4) == 'desc') ? true : false,
58 58
 			);
59
+		}
59 60
 
60 61
 		// Set the database column sort.
61 62
 		$sort = $listOptions['columns'][$list_context['sort']['id']]['sort'][$list_context['sort']['desc'] ? 'reverse' : 'default'];
@@ -72,8 +73,9 @@  discard block
 block discarded – undo
72 73
 	else
73 74
 	{
74 75
 		// First get an impression of how many items to expect.
75
-		if (isset($listOptions['get_count']['file']))
76
-			require_once($listOptions['get_count']['file']);
76
+		if (isset($listOptions['get_count']['file'])) {
77
+					require_once($listOptions['get_count']['file']);
78
+		}
77 79
 
78 80
 		$call = call_helper($listOptions['get_count']['function'], true);
79 81
 		$list_context['total_num_items'] = call_user_func_array($call, empty($listOptions['get_count']['params']) ? array() : $listOptions['get_count']['params']);
@@ -83,14 +85,15 @@  discard block
 block discarded – undo
83 85
 		$list_context['items_per_page'] = $listOptions['items_per_page'];
84 86
 
85 87
 		// Then create a page index.
86
-		if ($list_context['total_num_items'] > $list_context['items_per_page'])
87
-			$list_context['page_index'] = constructPageIndex($listOptions['base_href'] . (empty($list_context['sort']) ? '' : ';' . $request_var_sort . '=' . $list_context['sort']['id'] . ($list_context['sort']['desc'] ? ';' . $request_var_desc : '')) . ($list_context['start_var_name'] != 'start' ? ';' . $list_context['start_var_name'] . '=%1$d' : ''), $list_context['start'], $list_context['total_num_items'], $list_context['items_per_page'], $list_context['start_var_name'] != 'start');
88
+		if ($list_context['total_num_items'] > $list_context['items_per_page']) {
89
+					$list_context['page_index'] = constructPageIndex($listOptions['base_href'] . (empty($list_context['sort']) ? '' : ';' . $request_var_sort . '=' . $list_context['sort']['id'] . ($list_context['sort']['desc'] ? ';' . $request_var_desc : '')) . ($list_context['start_var_name'] != 'start' ? ';' . $list_context['start_var_name'] . '=%1$d' : ''), $list_context['start'], $list_context['total_num_items'], $list_context['items_per_page'], $list_context['start_var_name'] != 'start');
90
+		}
88 91
 	}
89 92
 
90 93
 	// Prepare the headers of the table.
91 94
 	$list_context['headers'] = array();
92
-	foreach ($listOptions['columns'] as $column_id => $column)
93
-		$list_context['headers'][] = array(
95
+	foreach ($listOptions['columns'] as $column_id => $column) {
96
+			$list_context['headers'][] = array(
94 97
 			'id' => $column_id,
95 98
 			'label' => isset($column['header']['eval']) ? eval($column['header']['eval']) : (isset($column['header']['value']) ? $column['header']['value'] : ''),
96 99
 			'href' => empty($listOptions['default_sort_col']) || empty($column['sort']) ? '' : $listOptions['base_href'] . ';' . $request_var_sort . '=' . $column_id . ($column_id === $list_context['sort']['id'] && !$list_context['sort']['desc'] && isset($column['sort']['reverse']) ? ';' . $request_var_desc : '') . (empty($list_context['start']) ? '' : ';' . $list_context['start_var_name'] . '=' . $list_context['start']),
@@ -99,14 +102,16 @@  discard block
 block discarded – undo
99 102
 			'style' => isset($column['header']['style']) ? $column['header']['style'] : '',
100 103
 			'colspan' => isset($column['header']['colspan']) ? $column['header']['colspan'] : '',
101 104
 		);
105
+	}
102 106
 
103 107
 	// We know the amount of columns, might be useful for the template.
104 108
 	$list_context['num_columns'] = count($listOptions['columns']);
105 109
 	$list_context['width'] = isset($listOptions['width']) ? $listOptions['width'] : '0';
106 110
 
107 111
 	// Get the file with the function for the item list.
108
-	if (isset($listOptions['get_items']['file']))
109
-		require_once($listOptions['get_items']['file']);
112
+	if (isset($listOptions['get_items']['file'])) {
113
+			require_once($listOptions['get_items']['file']);
114
+	}
110 115
 
111 116
 	// Call the function and include which items we want and in what order.
112 117
 	$call = call_helper($listOptions['get_items']['function'], true);
@@ -123,51 +128,61 @@  discard block
 block discarded – undo
123 128
 			$cur_data = array();
124 129
 
125 130
 			// A value straight from the database?
126
-			if (isset($column['data']['db']))
127
-				$cur_data['value'] = $list_item[$column['data']['db']];
131
+			if (isset($column['data']['db'])) {
132
+							$cur_data['value'] = $list_item[$column['data']['db']];
133
+			}
128 134
 
129 135
 			// Take the value from the database and make it HTML safe.
130
-			elseif (isset($column['data']['db_htmlsafe']))
131
-				$cur_data['value'] = $smcFunc['htmlspecialchars']($list_item[$column['data']['db_htmlsafe']]);
136
+			elseif (isset($column['data']['db_htmlsafe'])) {
137
+							$cur_data['value'] = $smcFunc['htmlspecialchars']($list_item[$column['data']['db_htmlsafe']]);
138
+			}
132 139
 
133 140
 			// Using sprintf is probably the most readable way of injecting data.
134 141
 			elseif (isset($column['data']['sprintf']))
135 142
 			{
136 143
 				$params = array();
137
-				foreach ($column['data']['sprintf']['params'] as $sprintf_param => $htmlsafe)
138
-					$params[] = $htmlsafe ? $smcFunc['htmlspecialchars']($list_item[$sprintf_param]) : $list_item[$sprintf_param];
144
+				foreach ($column['data']['sprintf']['params'] as $sprintf_param => $htmlsafe) {
145
+									$params[] = $htmlsafe ? $smcFunc['htmlspecialchars']($list_item[$sprintf_param]) : $list_item[$sprintf_param];
146
+				}
139 147
 				$cur_data['value'] = vsprintf($column['data']['sprintf']['format'], $params);
140 148
 			}
141 149
 
142 150
 			// The most flexible way probably is applying a custom function.
143
-			elseif (isset($column['data']['function']))
144
-				$cur_data['value'] = call_user_func_array($column['data']['function'], array($list_item));
151
+			elseif (isset($column['data']['function'])) {
152
+							$cur_data['value'] = call_user_func_array($column['data']['function'], array($list_item));
153
+			}
145 154
 
146 155
 			// A modified value (inject the database values).
147
-			elseif (isset($column['data']['eval']))
148
-				$cur_data['value'] = eval(preg_replace('~%([a-zA-Z0-9\-_]+)%~', '$list_item[\'$1\']', $column['data']['eval']));
156
+			elseif (isset($column['data']['eval'])) {
157
+							$cur_data['value'] = eval(preg_replace('~%([a-zA-Z0-9\-_]+)%~', '$list_item[\'$1\']', $column['data']['eval']));
158
+			}
149 159
 
150 160
 			// A literal value.
151
-			elseif (isset($column['data']['value']))
152
-				$cur_data['value'] = $column['data']['value'];
161
+			elseif (isset($column['data']['value'])) {
162
+							$cur_data['value'] = $column['data']['value'];
163
+			}
153 164
 
154 165
 			// Empty value.
155
-			else
156
-				$cur_data['value'] = '';
166
+			else {
167
+							$cur_data['value'] = '';
168
+			}
157 169
 
158 170
 			// Allow for basic formatting.
159
-			if (!empty($column['data']['comma_format']))
160
-				$cur_data['value'] = comma_format($cur_data['value']);
161
-			elseif (!empty($column['data']['timeformat']))
162
-				$cur_data['value'] = timeformat($cur_data['value']);
171
+			if (!empty($column['data']['comma_format'])) {
172
+							$cur_data['value'] = comma_format($cur_data['value']);
173
+			} elseif (!empty($column['data']['timeformat'])) {
174
+							$cur_data['value'] = timeformat($cur_data['value']);
175
+			}
163 176
 
164 177
 			// Set a style class for this column?
165
-			if (isset($column['data']['class']))
166
-				$cur_data['class'] = $column['data']['class'];
178
+			if (isset($column['data']['class'])) {
179
+							$cur_data['class'] = $column['data']['class'];
180
+			}
167 181
 
168 182
 			// Fully customized styling for the cells in this column only.
169
-			if (isset($column['data']['style']))
170
-				$cur_data['style'] = $column['data']['style'];
183
+			if (isset($column['data']['style'])) {
184
+							$cur_data['style'] = $column['data']['style'];
185
+			}
171 186
 
172 187
 			// Add the data cell properties to the current row.
173 188
 			$cur_row[$column_id] = $cur_data;
@@ -176,10 +191,12 @@  discard block
 block discarded – undo
176 191
 		// Maybe we wat set a custom class for the row based on the data in the row itself
177 192
 		if (isset($listOptions['data_check']))
178 193
 		{
179
-			if (isset($listOptions['data_check']['class']))
180
-				$list_context['rows'][$item_id]['class'] = $listOptions['data_check']['class']($list_item);
181
-			if (isset($listOptions['data_check']['style']))
182
-				$list_context['rows'][$item_id]['style'] = $listOptions['data_check']['style']($list_item);
194
+			if (isset($listOptions['data_check']['class'])) {
195
+							$list_context['rows'][$item_id]['class'] = $listOptions['data_check']['class']($list_item);
196
+			}
197
+			if (isset($listOptions['data_check']['style'])) {
198
+							$list_context['rows'][$item_id]['style'] = $listOptions['data_check']['style']($list_item);
199
+			}
183 200
 		}
184 201
 
185 202
 		// Insert the row into the list.
@@ -187,34 +204,39 @@  discard block
 block discarded – undo
187 204
 	}
188 205
 
189 206
 	// The title is currently optional.
190
-	if (isset($listOptions['title']))
191
-		$list_context['title'] = $listOptions['title'];
207
+	if (isset($listOptions['title'])) {
208
+			$list_context['title'] = $listOptions['title'];
209
+	}
192 210
 
193 211
 	// In case there's a form, share it with the template context.
194 212
 	if (isset($listOptions['form']))
195 213
 	{
196 214
 		$list_context['form'] = $listOptions['form'];
197 215
 
198
-		if (!isset($list_context['form']['hidden_fields']))
199
-			$list_context['form']['hidden_fields'] = array();
216
+		if (!isset($list_context['form']['hidden_fields'])) {
217
+					$list_context['form']['hidden_fields'] = array();
218
+		}
200 219
 
201 220
 		// Always add a session check field.
202 221
 		$list_context['form']['hidden_fields'][$context['session_var']] = $context['session_id'];
203 222
 
204 223
 		// Will this do a token check?
205
-		if (isset($listOptions['form']['token']))
206
-			$list_context['form']['hidden_fields'][$context[$listOptions['form']['token'] . '_token_var']] = $context[$listOptions['form']['token'] . '_token'];
224
+		if (isset($listOptions['form']['token'])) {
225
+					$list_context['form']['hidden_fields'][$context[$listOptions['form']['token'] . '_token_var']] = $context[$listOptions['form']['token'] . '_token'];
226
+		}
207 227
 
208 228
 		// Include the starting page as hidden field?
209
-		if (!empty($list_context['form']['include_start']) && !empty($list_context['start']))
210
-			$list_context['form']['hidden_fields'][$list_context['start_var_name']] = $list_context['start'];
229
+		if (!empty($list_context['form']['include_start']) && !empty($list_context['start'])) {
230
+					$list_context['form']['hidden_fields'][$list_context['start_var_name']] = $list_context['start'];
231
+		}
211 232
 
212 233
 		// If sorting needs to be the same after submitting, add the parameter.
213 234
 		if (!empty($list_context['form']['include_sort']) && !empty($list_context['sort']))
214 235
 		{
215 236
 			$list_context['form']['hidden_fields']['sort'] = $list_context['sort']['id'];
216
-			if ($list_context['sort']['desc'])
217
-				$list_context['form']['hidden_fields']['desc'] = 1;
237
+			if ($list_context['sort']['desc']) {
238
+							$list_context['form']['hidden_fields']['desc'] = 1;
239
+			}
218 240
 		}
219 241
 	}
220 242
 
@@ -231,24 +253,28 @@  discard block
 block discarded – undo
231 253
 		$list_context['additional_rows'] = array();
232 254
 		foreach ($listOptions['additional_rows'] as $row)
233 255
 		{
234
-			if (empty($row))
235
-				continue;
256
+			if (empty($row)) {
257
+							continue;
258
+			}
236 259
 
237 260
 			// Supported row positions: top_of_list, after_title,
238 261
 			// above_column_headers, below_table_data, bottom_of_list.
239
-			if (!isset($list_context['additional_rows'][$row['position']]))
240
-				$list_context['additional_rows'][$row['position']] = array();
262
+			if (!isset($list_context['additional_rows'][$row['position']])) {
263
+							$list_context['additional_rows'][$row['position']] = array();
264
+			}
241 265
 			$list_context['additional_rows'][$row['position']][] = $row;
242 266
 		}
243 267
 	}
244 268
 
245 269
 	// Add an option for inline JavaScript.
246
-	if (isset($listOptions['javascript']))
247
-		$list_context['javascript'] = $listOptions['javascript'];
270
+	if (isset($listOptions['javascript'])) {
271
+			$list_context['javascript'] = $listOptions['javascript'];
272
+	}
248 273
 
249 274
 	// We want a menu.
250
-	if (isset($listOptions['list_menu']))
251
-		$list_context['list_menu'] = $listOptions['list_menu'];
275
+	if (isset($listOptions['list_menu'])) {
276
+			$list_context['list_menu'] = $listOptions['list_menu'];
277
+	}
252 278
 
253 279
 	// Make sure the template is loaded.
254 280
 	loadTemplate('GenericList');
Please login to merge, or discard this patch.