Completed
Pull Request — release-2.1 (#4029)
by Mert
09:24 queued 21s
created
Sources/Subs-Db-mysql.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -255,8 +255,8 @@  discard block
 block discarded – undo
255 255
 		
256 256
 		case 'datetime':
257 257
 			if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1)
258
-				return 'str_to_date('.
259
-					sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5] ,$datetime_matches[6]).
258
+				return 'str_to_date(' .
259
+					sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5], $datetime_matches[6]) .
260 260
 					',\'%Y-%m-%d %h:%i:%s\')';
261 261
 			else
262 262
 				smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
@@ -823,7 +823,7 @@  discard block
 block discarded – undo
823 823
 		$connection
824 824
 	);
825 825
 	
826
-	if(!empty($keys) && (count($keys) > 0) && $method == '' && $returnmode > 0)
826
+	if (!empty($keys) && (count($keys) > 0) && $method == '' && $returnmode > 0)
827 827
 	{
828 828
 		if ($returnmode == 1)
829 829
 			$return_var = smf_db_insert_id($table, $keys[0]) + count($insertRows) - 1;
@@ -832,7 +832,7 @@  discard block
 block discarded – undo
832 832
 			$return_var = array();
833 833
 			$count = count($insertRows);
834 834
 			$start = smf_db_insert_id($table, $keys[0]);
835
-			for ($i = 0; $i < $count; $i++ )
835
+			for ($i = 0; $i < $count; $i++)
836 836
 				$return_var[] = $start + $i;
837 837
 		}
838 838
 		return $return_var;
Please login to merge, or discard this patch.
Braces   +257 added lines, -189 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  *  Maps the implementations in this file (smf_db_function_name)
@@ -33,8 +34,8 @@  discard block
 block discarded – undo
33 34
 	global $smcFunc, $mysql_set_mode;
34 35
 
35 36
 	// Map some database specific functions, only do this once.
36
-	if (!isset($smcFunc['db_fetch_assoc']))
37
-		$smcFunc += array(
37
+	if (!isset($smcFunc['db_fetch_assoc'])) {
38
+			$smcFunc += array(
38 39
 			'db_query'                  => 'smf_db_query',
39 40
 			'db_quote'                  => 'smf_db_quote',
40 41
 			'db_fetch_assoc'            => 'mysqli_fetch_assoc',
@@ -59,9 +60,11 @@  discard block
 block discarded – undo
59 60
 			'db_is_resource'            => 'smf_is_resource',
60 61
 			'db_mb4'                    => false,
61 62
 		);
63
+	}
62 64
 
63
-	if (!empty($db_options['persist']))
64
-		$db_server = 'p:' . $db_server;
65
+	if (!empty($db_options['persist'])) {
66
+			$db_server = 'p:' . $db_server;
67
+	}
65 68
 
66 69
 	$connection = mysqli_init();
67 70
 	
@@ -70,31 +73,35 @@  discard block
 block discarded – undo
70 73
 	$success = false;
71 74
 	
72 75
 	if ($connection) {
73
-		if (!empty($db_options['port']))
74
-			$success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', $db_options['port'], null, $flags);
75
-		else
76
-			$success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', 0, null, $flags);
76
+		if (!empty($db_options['port'])) {
77
+					$success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', $db_options['port'], null, $flags);
78
+		} else {
79
+					$success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', 0, null, $flags);
80
+		}
77 81
 	}
78 82
 
79 83
 	// Something's wrong, show an error if its fatal (which we assume it is)
80 84
 	if ($success === false)
81 85
 	{
82
-		if (!empty($db_options['non_fatal']))
83
-			return null;
84
-		else
85
-			display_db_error();
86
+		if (!empty($db_options['non_fatal'])) {
87
+					return null;
88
+		} else {
89
+					display_db_error();
90
+		}
86 91
 	}
87 92
 
88 93
 	// Select the database, unless told not to
89
-	if (empty($db_options['dont_select_db']) && !@mysqli_select_db($connection, $db_name) && empty($db_options['non_fatal']))
90
-		display_db_error();
94
+	if (empty($db_options['dont_select_db']) && !@mysqli_select_db($connection, $db_name) && empty($db_options['non_fatal'])) {
95
+			display_db_error();
96
+	}
91 97
 
92 98
 	// This makes it possible to have SMF automatically change the sql_mode and autocommit if needed.
93
-	if (isset($mysql_set_mode) && $mysql_set_mode === true)
94
-		$smcFunc['db_query']('', 'SET sql_mode = \'\', AUTOCOMMIT = 1',
99
+	if (isset($mysql_set_mode) && $mysql_set_mode === true) {
100
+			$smcFunc['db_query']('', 'SET sql_mode = \'\', AUTOCOMMIT = 1',
95 101
 		array(),
96 102
 		false
97 103
 	);
104
+	}
98 105
 
99 106
 	return $connection;
100 107
 }
@@ -165,37 +172,46 @@  discard block
 block discarded – undo
165 172
 	global $db_callback, $user_info, $db_prefix, $smcFunc;
166 173
 
167 174
 	list ($values, $connection) = $db_callback;
168
-	if (!is_object($connection))
169
-		display_db_error();
175
+	if (!is_object($connection)) {
176
+			display_db_error();
177
+	}
170 178
 
171
-	if ($matches[1] === 'db_prefix')
172
-		return $db_prefix;
179
+	if ($matches[1] === 'db_prefix') {
180
+			return $db_prefix;
181
+	}
173 182
 
174
-	if ($matches[1] === 'query_see_board')
175
-		return $user_info['query_see_board'];
183
+	if ($matches[1] === 'query_see_board') {
184
+			return $user_info['query_see_board'];
185
+	}
176 186
 
177
-	if ($matches[1] === 'query_wanna_see_board')
178
-		return $user_info['query_wanna_see_board'];
187
+	if ($matches[1] === 'query_wanna_see_board') {
188
+			return $user_info['query_wanna_see_board'];
189
+	}
179 190
 
180
-	if ($matches[1] === 'empty')
181
-		return '\'\'';
191
+	if ($matches[1] === 'empty') {
192
+			return '\'\'';
193
+	}
182 194
 
183
-	if (!isset($matches[2]))
184
-		smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__);
195
+	if (!isset($matches[2])) {
196
+			smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__);
197
+	}
185 198
 
186
-	if ($matches[1] === 'literal')
187
-		return '\'' . mysqli_real_escape_string($connection, $matches[2]) . '\'';
199
+	if ($matches[1] === 'literal') {
200
+			return '\'' . mysqli_real_escape_string($connection, $matches[2]) . '\'';
201
+	}
188 202
 
189
-	if (!isset($values[$matches[2]]))
190
-		smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__);
203
+	if (!isset($values[$matches[2]])) {
204
+			smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__);
205
+	}
191 206
 
192 207
 	$replacement = $values[$matches[2]];
193 208
 
194 209
 	switch ($matches[1])
195 210
 	{
196 211
 		case 'int':
197
-			if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement)
198
-				smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
212
+			if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) {
213
+							smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
214
+			}
199 215
 			return (string) (int) $replacement;
200 216
 		break;
201 217
 
@@ -207,65 +223,73 @@  discard block
 block discarded – undo
207 223
 		case 'array_int':
208 224
 			if (is_array($replacement))
209 225
 			{
210
-				if (empty($replacement))
211
-					smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
226
+				if (empty($replacement)) {
227
+									smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
228
+				}
212 229
 
213 230
 				foreach ($replacement as $key => $value)
214 231
 				{
215
-					if (!is_numeric($value) || (string) $value !== (string) (int) $value)
216
-						smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
232
+					if (!is_numeric($value) || (string) $value !== (string) (int) $value) {
233
+											smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
234
+					}
217 235
 
218 236
 					$replacement[$key] = (string) (int) $value;
219 237
 				}
220 238
 
221 239
 				return implode(', ', $replacement);
240
+			} else {
241
+							smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
222 242
 			}
223
-			else
224
-				smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
225 243
 
226 244
 		break;
227 245
 
228 246
 		case 'array_string':
229 247
 			if (is_array($replacement))
230 248
 			{
231
-				if (empty($replacement))
232
-					smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
249
+				if (empty($replacement)) {
250
+									smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
251
+				}
233 252
 
234
-				foreach ($replacement as $key => $value)
235
-					$replacement[$key] = sprintf('\'%1$s\'', mysqli_real_escape_string($connection, $value));
253
+				foreach ($replacement as $key => $value) {
254
+									$replacement[$key] = sprintf('\'%1$s\'', mysqli_real_escape_string($connection, $value));
255
+				}
236 256
 
237 257
 				return implode(', ', $replacement);
258
+			} else {
259
+							smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
238 260
 			}
239
-			else
240
-				smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
241 261
 		break;
242 262
 
243 263
 		case 'date':
244
-			if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1)
245
-				return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]);
246
-			else
247
-				smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
264
+			if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) {
265
+							return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]);
266
+			} else {
267
+							smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
268
+			}
248 269
 		break;
249 270
 
250 271
 		case 'time':
251
-			if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1)
252
-				return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]);
253
-			else
254
-				smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
272
+			if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) {
273
+							return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]);
274
+			} else {
275
+							smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
276
+			}
255 277
 		break;
256 278
 		
257 279
 		case 'datetime':
258
-			if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1)
259
-				return 'str_to_date('.
280
+			if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1) {
281
+							return 'str_to_date('.
260 282
 					sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5] ,$datetime_matches[6]).
261 283
 					',\'%Y-%m-%d %h:%i:%s\')';
262
-			else
263
-				smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
284
+			} else {
285
+							smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
286
+			}
264 287
 		break;
265 288
 
266 289
 		case 'float':
267
-			if (!is_numeric($replacement))
268
-				smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
290
+			if (!is_numeric($replacement)) {
291
+							smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
292
+			}
269 293
 			return (string) (float) $replacement;
270 294
 		break;
271 295
 
@@ -279,32 +303,37 @@  discard block
 block discarded – undo
279 303
 		break;
280 304
 
281 305
 		case 'inet':
282
-			if ($replacement == 'null' || $replacement == '')
283
-				return 'null';
284
-			if (!isValidIP($replacement))
285
-				smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
306
+			if ($replacement == 'null' || $replacement == '') {
307
+							return 'null';
308
+			}
309
+			if (!isValidIP($replacement)) {
310
+							smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
311
+			}
286 312
 			//we don't use the native support of mysql > 5.6.2
287 313
 			return sprintf('unhex(\'%1$s\')', bin2hex(inet_pton($replacement)));
288 314
 
289 315
 		case 'array_inet':
290 316
 			if (is_array($replacement))
291 317
 			{
292
-				if (empty($replacement))
293
-					smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
318
+				if (empty($replacement)) {
319
+									smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
320
+				}
294 321
 
295 322
 				foreach ($replacement as $key => $value)
296 323
 				{
297
-					if ($replacement == 'null' || $replacement == '')
298
-						$replacement[$key] = 'null';
299
-					if (!isValidIP($value))
300
-						smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
324
+					if ($replacement == 'null' || $replacement == '') {
325
+											$replacement[$key] = 'null';
326
+					}
327
+					if (!isValidIP($value)) {
328
+											smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
329
+					}
301 330
 					$replacement[$key] = sprintf('unhex(\'%1$s\')', bin2hex(inet_pton($value)));
302 331
 				}
303 332
 
304 333
 				return implode(', ', $replacement);
334
+			} else {
335
+							smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
305 336
 			}
306
-			else
307
-				smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
308 337
 		break;
309 338
 
310 339
 		default:
@@ -380,22 +409,25 @@  discard block
 block discarded – undo
380 409
 		// Are we in SSI mode?  If so try that username and password first
381 410
 		if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd))
382 411
 		{
383
-			if (empty($db_persist))
384
-				$db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd);
385
-			else
386
-				$db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd);
412
+			if (empty($db_persist)) {
413
+							$db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd);
414
+			} else {
415
+							$db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd);
416
+			}
387 417
 		}
388 418
 		// Fall back to the regular username and password if need be
389 419
 		if (!$db_connection)
390 420
 		{
391
-			if (empty($db_persist))
392
-				$db_connection = @mysqli_connect($db_server, $db_user, $db_passwd);
393
-			else
394
-				$db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd);
421
+			if (empty($db_persist)) {
422
+							$db_connection = @mysqli_connect($db_server, $db_user, $db_passwd);
423
+			} else {
424
+							$db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd);
425
+			}
395 426
 		}
396 427
 
397
-		if (!$db_connection || !@mysqli_select_db($db_connection, $db_name))
398
-			$db_connection = false;
428
+		if (!$db_connection || !@mysqli_select_db($db_connection, $db_name)) {
429
+					$db_connection = false;
430
+		}
399 431
 
400 432
 		$connection = $db_connection;
401 433
 	}
@@ -403,18 +435,20 @@  discard block
 block discarded – undo
403 435
 	// One more query....
404 436
 	$db_count = !isset($db_count) ? 1 : $db_count + 1;
405 437
 
406
-	if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override']))
407
-		smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__);
438
+	if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) {
439
+			smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__);
440
+	}
408 441
 
409 442
 	// Use "ORDER BY null" to prevent Mysql doing filesorts for Group By clauses without an Order By
410 443
 	if (strpos($db_string, 'GROUP BY') !== false && strpos($db_string, 'ORDER BY') === false && preg_match('~^\s+SELECT~i', $db_string))
411 444
 	{
412 445
 		// Add before LIMIT
413
-		if ($pos = strpos($db_string, 'LIMIT '))
414
-			$db_string = substr($db_string, 0, $pos) . "\t\t\tORDER BY null\n" . substr($db_string, $pos, strlen($db_string));
415
-		else
416
-			// Append it.
446
+		if ($pos = strpos($db_string, 'LIMIT ')) {
447
+					$db_string = substr($db_string, 0, $pos) . "\t\t\tORDER BY null\n" . substr($db_string, $pos, strlen($db_string));
448
+		} else {
449
+					// Append it.
417 450
 			$db_string .= "\n\t\t\tORDER BY null";
451
+		}
418 452
 	}
419 453
 
420 454
 	if (empty($db_values['security_override']) && (!empty($db_values) || strpos($db_string, '{db_prefix}') !== false))
@@ -436,8 +470,9 @@  discard block
 block discarded – undo
436 470
 		list ($file, $line) = smf_db_error_backtrace('', '', 'return', __FILE__, __LINE__);
437 471
 
438 472
 		// Initialize $db_cache if not already initialized.
439
-		if (!isset($db_cache))
440
-			$db_cache = array();
473
+		if (!isset($db_cache)) {
474
+					$db_cache = array();
475
+		}
441 476
 
442 477
 		if (!empty($_SESSION['debug_redirect']))
443 478
 		{
@@ -463,17 +498,18 @@  discard block
 block discarded – undo
463 498
 		while (true)
464 499
 		{
465 500
 			$pos = strpos($db_string, '\'', $pos + 1);
466
-			if ($pos === false)
467
-				break;
501
+			if ($pos === false) {
502
+							break;
503
+			}
468 504
 			$clean .= substr($db_string, $old_pos, $pos - $old_pos);
469 505
 
470 506
 			while (true)
471 507
 			{
472 508
 				$pos1 = strpos($db_string, '\'', $pos + 1);
473 509
 				$pos2 = strpos($db_string, '\\', $pos + 1);
474
-				if ($pos1 === false)
475
-					break;
476
-				elseif ($pos2 === false || $pos2 > $pos1)
510
+				if ($pos1 === false) {
511
+									break;
512
+				} elseif ($pos2 === false || $pos2 > $pos1)
477 513
 				{
478 514
 					$pos = $pos1;
479 515
 					break;
@@ -489,29 +525,35 @@  discard block
 block discarded – undo
489 525
 		$clean = trim(strtolower(preg_replace($allowed_comments_from, $allowed_comments_to, $clean)));
490 526
 
491 527
 		// Comments?  We don't use comments in our queries, we leave 'em outside!
492
-		if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false)
493
-			$fail = true;
528
+		if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) {
529
+					$fail = true;
530
+		}
494 531
 		// Trying to change passwords, slow us down, or something?
495
-		elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0)
496
-			$fail = true;
497
-		elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0)
498
-			$fail = true;
532
+		elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) {
533
+					$fail = true;
534
+		} elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) {
535
+					$fail = true;
536
+		}
499 537
 
500
-		if (!empty($fail) && function_exists('log_error'))
501
-			smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__);
538
+		if (!empty($fail) && function_exists('log_error')) {
539
+					smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__);
540
+		}
502 541
 	}
503 542
 
504
-	if (empty($db_unbuffered))
505
-		$ret = @mysqli_query($connection, $db_string);
506
-	else
507
-		$ret = @mysqli_query($connection, $db_string, MYSQLI_USE_RESULT);
543
+	if (empty($db_unbuffered)) {
544
+			$ret = @mysqli_query($connection, $db_string);
545
+	} else {
546
+			$ret = @mysqli_query($connection, $db_string, MYSQLI_USE_RESULT);
547
+	}
508 548
 
509
-	if ($ret === false && empty($db_values['db_error_skip']))
510
-		$ret = smf_db_error($db_string, $connection);
549
+	if ($ret === false && empty($db_values['db_error_skip'])) {
550
+			$ret = smf_db_error($db_string, $connection);
551
+	}
511 552
 
512 553
 	// Debugging.
513
-	if (isset($db_show_debug) && $db_show_debug === true)
514
-		$db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));
554
+	if (isset($db_show_debug) && $db_show_debug === true) {
555
+			$db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));
556
+	}
515 557
 
516 558
 	return $ret;
517 559
 }
@@ -558,12 +600,13 @@  discard block
 block discarded – undo
558 600
 	// Decide which connection to use
559 601
 	$connection = $connection === null ? $db_connection : $connection;
560 602
 
561
-	if ($type == 'begin')
562
-		return @mysqli_query($connection, 'BEGIN');
563
-	elseif ($type == 'rollback')
564
-		return @mysqli_query($connection, 'ROLLBACK');
565
-	elseif ($type == 'commit')
566
-		return @mysqli_query($connection, 'COMMIT');
603
+	if ($type == 'begin') {
604
+			return @mysqli_query($connection, 'BEGIN');
605
+	} elseif ($type == 'rollback') {
606
+			return @mysqli_query($connection, 'ROLLBACK');
607
+	} elseif ($type == 'commit') {
608
+			return @mysqli_query($connection, 'COMMIT');
609
+	}
567 610
 
568 611
 	return false;
569 612
 }
@@ -603,8 +646,9 @@  discard block
 block discarded – undo
603 646
 	//    2013: Lost connection to server during query.
604 647
 
605 648
 	// Log the error.
606
-	if ($query_errno != 1213 && $query_errno != 1205 && function_exists('log_error'))
607
-		log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n$db_string" : ''), 'database', $file, $line);
649
+	if ($query_errno != 1213 && $query_errno != 1205 && function_exists('log_error')) {
650
+			log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n$db_string" : ''), 'database', $file, $line);
651
+	}
608 652
 
609 653
 	// Database error auto fixing ;).
610 654
 	if (function_exists('cache_get_data') && (!isset($modSettings['autoFixDatabase']) || $modSettings['autoFixDatabase'] == '1'))
@@ -613,8 +657,9 @@  discard block
 block discarded – undo
613 657
 		$old_cache = @$modSettings['cache_enable'];
614 658
 		$modSettings['cache_enable'] = '1';
615 659
 
616
-		if (($temp = cache_get_data('db_last_error', 600)) !== null)
617
-			$db_last_error = max(@$db_last_error, $temp);
660
+		if (($temp = cache_get_data('db_last_error', 600)) !== null) {
661
+					$db_last_error = max(@$db_last_error, $temp);
662
+		}
618 663
 
619 664
 		if (@$db_last_error < time() - 3600 * 24 * 3)
620 665
 		{
@@ -630,8 +675,9 @@  discard block
 block discarded – undo
630 675
 					foreach ($tables as $table)
631 676
 					{
632 677
 						// Now, it's still theoretically possible this could be an injection.  So backtick it!
633
-						if (trim($table) != '')
634
-							$fix_tables[] = '`' . strtr(trim($table), array('`' => '')) . '`';
678
+						if (trim($table) != '') {
679
+													$fix_tables[] = '`' . strtr(trim($table), array('`' => '')) . '`';
680
+						}
635 681
 					}
636 682
 				}
637 683
 
@@ -640,8 +686,9 @@  discard block
 block discarded – undo
640 686
 			// Table crashed.  Let's try to fix it.
641 687
 			elseif ($query_errno == 1016)
642 688
 			{
643
-				if (preg_match('~\'([^\.\']+)~', $query_error, $match) != 0)
644
-					$fix_tables = array('`' . $match[1] . '`');
689
+				if (preg_match('~\'([^\.\']+)~', $query_error, $match) != 0) {
690
+									$fix_tables = array('`' . $match[1] . '`');
691
+				}
645 692
 			}
646 693
 			// Indexes crashed.  Should be easy to fix!
647 694
 			elseif ($query_errno == 1034 || $query_errno == 1035)
@@ -660,13 +707,15 @@  discard block
 block discarded – undo
660 707
 
661 708
 			// Make a note of the REPAIR...
662 709
 			cache_put_data('db_last_error', time(), 600);
663
-			if (($temp = cache_get_data('db_last_error', 600)) === null)
664
-				updateSettingsFile(array('db_last_error' => time()));
710
+			if (($temp = cache_get_data('db_last_error', 600)) === null) {
711
+							updateSettingsFile(array('db_last_error' => time()));
712
+			}
665 713
 
666 714
 			// Attempt to find and repair the broken table.
667
-			foreach ($fix_tables as $table)
668
-				$smcFunc['db_query']('', "
715
+			foreach ($fix_tables as $table) {
716
+							$smcFunc['db_query']('', "
669 717
 					REPAIR TABLE $table", false, false);
718
+			}
670 719
 
671 720
 			// And send off an email!
672 721
 			sendmail($webmaster_email, $txt['database_error'], $txt['tried_to_repair'], null, 'dberror');
@@ -675,11 +724,12 @@  discard block
 block discarded – undo
675 724
 
676 725
 			// Try the query again...?
677 726
 			$ret = $smcFunc['db_query']('', $db_string, false, false);
678
-			if ($ret !== false)
679
-				return $ret;
727
+			if ($ret !== false) {
728
+							return $ret;
729
+			}
730
+		} else {
731
+					$modSettings['cache_enable'] = $old_cache;
680 732
 		}
681
-		else
682
-			$modSettings['cache_enable'] = $old_cache;
683 733
 
684 734
 		// Check for the "lost connection" or "deadlock found" errors - and try it just one more time.
685 735
 		if (in_array($query_errno, array(1205, 1213, 2006, 2013)))
@@ -689,22 +739,25 @@  discard block
 block discarded – undo
689 739
 				// Are we in SSI mode?  If so try that username and password first
690 740
 				if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd))
691 741
 				{
692
-					if (empty($db_persist))
693
-						$db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd);
694
-					else
695
-						$db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd);
742
+					if (empty($db_persist)) {
743
+											$db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd);
744
+					} else {
745
+											$db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd);
746
+					}
696 747
 				}
697 748
 				// Fall back to the regular username and password if need be
698 749
 				if (!$db_connection)
699 750
 				{
700
-					if (empty($db_persist))
701
-						$db_connection = @mysqli_connect($db_server, $db_user, $db_passwd);
702
-					else
703
-						$db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd);
751
+					if (empty($db_persist)) {
752
+											$db_connection = @mysqli_connect($db_server, $db_user, $db_passwd);
753
+					} else {
754
+											$db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd);
755
+					}
704 756
 				}
705 757
 
706
-				if (!$db_connection || !@mysqli_select_db($db_connection, $db_name))
707
-					$db_connection = false;
758
+				if (!$db_connection || !@mysqli_select_db($db_connection, $db_name)) {
759
+									$db_connection = false;
760
+				}
708 761
 			}
709 762
 
710 763
 			if ($db_connection)
@@ -715,24 +768,27 @@  discard block
 block discarded – undo
715 768
 					$ret = $smcFunc['db_query']('', $db_string, false, false);
716 769
 
717 770
 					$new_errno = mysqli_errno($db_connection);
718
-					if ($ret !== false || in_array($new_errno, array(1205, 1213)))
719
-						break;
771
+					if ($ret !== false || in_array($new_errno, array(1205, 1213))) {
772
+											break;
773
+					}
720 774
 				}
721 775
 
722 776
 				// If it failed again, shucks to be you... we're not trying it over and over.
723
-				if ($ret !== false)
724
-					return $ret;
777
+				if ($ret !== false) {
778
+									return $ret;
779
+				}
725 780
 			}
726 781
 		}
727 782
 		// Are they out of space, perhaps?
728 783
 		elseif ($query_errno == 1030 && (strpos($query_error, ' -1 ') !== false || strpos($query_error, ' 28 ') !== false || strpos($query_error, ' 12 ') !== false))
729 784
 		{
730
-			if (!isset($txt))
731
-				$query_error .= ' - check database storage space.';
732
-			else
785
+			if (!isset($txt)) {
786
+							$query_error .= ' - check database storage space.';
787
+			} else
733 788
 			{
734
-				if (!isset($txt['mysql_error_space']))
735
-					loadLanguage('Errors');
789
+				if (!isset($txt['mysql_error_space'])) {
790
+									loadLanguage('Errors');
791
+				}
736 792
 
737 793
 				$query_error .= !isset($txt['mysql_error_space']) ? ' - check database storage space.' : $txt['mysql_error_space'];
738 794
 			}
@@ -740,15 +796,17 @@  discard block
 block discarded – undo
740 796
 	}
741 797
 
742 798
 	// Nothing's defined yet... just die with it.
743
-	if (empty($context) || empty($txt))
744
-		die($query_error);
799
+	if (empty($context) || empty($txt)) {
800
+			die($query_error);
801
+	}
745 802
 
746 803
 	// Show an error message, if possible.
747 804
 	$context['error_title'] = $txt['database_error'];
748
-	if (allowedTo('admin_forum'))
749
-		$context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line;
750
-	else
751
-		$context['error_message'] = $txt['try_again'];
805
+	if (allowedTo('admin_forum')) {
806
+			$context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line;
807
+	} else {
808
+			$context['error_message'] = $txt['try_again'];
809
+	}
752 810
 
753 811
 	if (allowedTo('admin_forum') && isset($db_show_debug) && $db_show_debug === true)
754 812
 	{
@@ -778,25 +836,28 @@  discard block
 block discarded – undo
778 836
 	$connection = $connection === null ? $db_connection : $connection;
779 837
 
780 838
 	// With nothing to insert, simply return.
781
-	if (empty($data))
782
-		return;
839
+	if (empty($data)) {
840
+			return;
841
+	}
783 842
 
784 843
 	// Replace the prefix holder with the actual prefix.
785 844
 	$table = str_replace('{db_prefix}', $db_prefix, $table);
786 845
 
787 846
 	// Inserting data as a single row can be done as a single array.
788
-	if (!is_array($data[array_rand($data)]))
789
-		$data = array($data);
847
+	if (!is_array($data[array_rand($data)])) {
848
+			$data = array($data);
849
+	}
790 850
 
791 851
 	// Create the mold for a single row insert.
792 852
 	$insertData = '(';
793 853
 	foreach ($columns as $columnName => $type)
794 854
 	{
795 855
 		// Are we restricting the length?
796
-		if (strpos($type, 'string-') !== false)
797
-			$insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName);
798
-		else
799
-			$insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName);
856
+		if (strpos($type, 'string-') !== false) {
857
+					$insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName);
858
+		} else {
859
+					$insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName);
860
+		}
800 861
 	}
801 862
 	$insertData = substr($insertData, 0, -2) . ')';
802 863
 
@@ -805,8 +866,9 @@  discard block
 block discarded – undo
805 866
 
806 867
 	// Here's where the variables are injected to the query.
807 868
 	$insertRows = array();
808
-	foreach ($data as $dataRow)
809
-		$insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection);
869
+	foreach ($data as $dataRow) {
870
+			$insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection);
871
+	}
810 872
 
811 873
 	// Determine the method of insertion.
812 874
 	$queryTitle = $method == 'replace' ? 'REPLACE' : ($method == 'ignore' ? 'INSERT IGNORE' : 'INSERT');
@@ -826,15 +888,16 @@  discard block
 block discarded – undo
826 888
 	
827 889
 	if(!empty($keys) && (count($keys) > 0) && $method == '' && $returnmode > 0)
828 890
 	{
829
-		if ($returnmode == 1)
830
-			$return_var = smf_db_insert_id($table, $keys[0]) + count($insertRows) - 1;
831
-		else if ($returnmode == 2)
891
+		if ($returnmode == 1) {
892
+					$return_var = smf_db_insert_id($table, $keys[0]) + count($insertRows) - 1;
893
+		} else if ($returnmode == 2)
832 894
 		{
833 895
 			$return_var = array();
834 896
 			$count = count($insertRows);
835 897
 			$start = smf_db_insert_id($table, $keys[0]);
836
-			for ($i = 0; $i < $count; $i++ )
837
-				$return_var[] = $start + $i;
898
+			for ($i = 0; $i < $count; $i++ ) {
899
+							$return_var[] = $start + $i;
900
+			}
838 901
 		}
839 902
 		return $return_var;
840 903
 	}
@@ -852,8 +915,9 @@  discard block
 block discarded – undo
852 915
  */
853 916
 function smf_db_error_backtrace($error_message, $log_message = '', $error_type = false, $file = null, $line = null)
854 917
 {
855
-	if (empty($log_message))
856
-		$log_message = $error_message;
918
+	if (empty($log_message)) {
919
+			$log_message = $error_message;
920
+	}
857 921
 
858 922
 	foreach (debug_backtrace() as $step)
859 923
 	{
@@ -872,12 +936,14 @@  discard block
 block discarded – undo
872 936
 	}
873 937
 
874 938
 	// A special case - we want the file and line numbers for debugging.
875
-	if ($error_type == 'return')
876
-		return array($file, $line);
939
+	if ($error_type == 'return') {
940
+			return array($file, $line);
941
+	}
877 942
 
878 943
 	// Is always a critical error.
879
-	if (function_exists('log_error'))
880
-		log_error($log_message, 'critical', $file, $line);
944
+	if (function_exists('log_error')) {
945
+			log_error($log_message, 'critical', $file, $line);
946
+	}
881 947
 
882 948
 	if (function_exists('fatal_error'))
883 949
 	{
@@ -885,12 +951,12 @@  discard block
 block discarded – undo
885 951
 
886 952
 		// Cannot continue...
887 953
 		exit;
954
+	} elseif ($error_type) {
955
+			trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type);
956
+	} else {
957
+			trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''));
958
+	}
888 959
 	}
889
-	elseif ($error_type)
890
-		trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type);
891
-	else
892
-		trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''));
893
-}
894 960
 
895 961
 /**
896 962
  * Escape the LIKE wildcards so that they match the character and not the wildcard.
@@ -907,10 +973,11 @@  discard block
 block discarded – undo
907 973
 		'\\' => '\\\\',
908 974
 	);
909 975
 
910
-	if ($translate_human_wildcards)
911
-		$replacements += array(
976
+	if ($translate_human_wildcards) {
977
+			$replacements += array(
912 978
 			'*' => '%',
913 979
 		);
980
+	}
914 981
 
915 982
 	return strtr($string, $replacements);
916 983
 }
@@ -924,8 +991,9 @@  discard block
 block discarded – undo
924 991
  */
925 992
 function smf_is_resource($result)
926 993
 {
927
-	if ($result instanceof mysqli_result)
928
-		return true;
994
+	if ($result instanceof mysqli_result) {
995
+			return true;
996
+	}
929 997
 
930 998
 	return false;
931 999
 }
Please login to merge, or discard this patch.
Sources/tasks/CreatePost-Notify.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 class CreatePost_Notify_Background extends SMF_BackgroundTask
19 19
 {
20 20
 	/**
21
-     * This handles notifications when a new post is created - new topic, reply, quotes and mentions.
21
+	 * This handles notifications when a new post is created - new topic, reply, quotes and mentions.
22 22
 	 * @return bool Always returns true
23 23
 	 */
24 24
 	public function execute()
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 
107 107
 			// Don't send a notification if the watching member ignored the member who made the action.
108 108
 			if (!empty($data['pm_ignore_list']) && in_array($data['id_member_updated'], explode(',', $data['pm_ignore_list'])))
109
-			    continue;
109
+				continue;
110 110
 			if (!in_array($type, array('reply', 'topic')) && $notify_types == 2 && $member != $data['id_member_started'])
111 111
 				continue;
112 112
 			elseif (in_array($type, array('reply', 'topic')) && $member == $posterOptions['id'])
Please login to merge, or discard this patch.
Braces   +62 added lines, -46 removed lines patch added patch discarded remove patch
@@ -73,8 +73,9 @@  discard block
 block discarded – undo
73 73
 		while ($row = $smcFunc['db_fetch_assoc']($request))
74 74
 		{
75 75
 			$groups = array_merge(array($row['id_group'], $row['id_post_group']), (empty($row['additional_groups']) ? array() : explode(',', $row['additional_groups'])));
76
-			if (!in_array(1, $groups) && count(array_intersect($groups, explode(',', $row['member_groups']))) == 0)
77
-				continue;
76
+			if (!in_array(1, $groups) && count(array_intersect($groups, explode(',', $row['member_groups']))) == 0) {
77
+							continue;
78
+			}
78 79
 
79 80
 			$members[] = $row['id_member'];
80 81
 			$watched[$row['id_member']] = $row;
@@ -82,8 +83,9 @@  discard block
 block discarded – undo
82 83
 
83 84
 		$smcFunc['db_free_result']($request);
84 85
 
85
-		if (empty($members))
86
-			return true;
86
+		if (empty($members)) {
87
+					return true;
88
+		}
87 89
 
88 90
 		$members = array_unique($members);
89 91
 		$prefs = getNotifyPrefs($members, '', true);
@@ -105,20 +107,23 @@  discard block
 block discarded – undo
105 107
 			$notify_types = !empty($prefs[$member]['msg_notify_type']) ? $prefs[$member]['msg_notify_type'] : 1;
106 108
 
107 109
 			// Don't send a notification if the watching member ignored the member who made the action.
108
-			if (!empty($data['pm_ignore_list']) && in_array($data['id_member_updated'], explode(',', $data['pm_ignore_list'])))
109
-			    continue;
110
-			if (!in_array($type, array('reply', 'topic')) && $notify_types == 2 && $member != $data['id_member_started'])
111
-				continue;
112
-			elseif (in_array($type, array('reply', 'topic')) && $member == $posterOptions['id'])
113
-				continue;
114
-			elseif (!in_array($type, array('reply', 'topic')) && $notify_types == 3)
115
-				continue;
116
-			elseif ($notify_types == 4)
117
-				continue;
110
+			if (!empty($data['pm_ignore_list']) && in_array($data['id_member_updated'], explode(',', $data['pm_ignore_list']))) {
111
+						    continue;
112
+			}
113
+			if (!in_array($type, array('reply', 'topic')) && $notify_types == 2 && $member != $data['id_member_started']) {
114
+							continue;
115
+			} elseif (in_array($type, array('reply', 'topic')) && $member == $posterOptions['id']) {
116
+							continue;
117
+			} elseif (!in_array($type, array('reply', 'topic')) && $notify_types == 3) {
118
+							continue;
119
+			} elseif ($notify_types == 4) {
120
+							continue;
121
+			}
118 122
 
119 123
 			if ($frequency > 2 || (!empty($frequency) && $data['sent']) || in_array($member, $done_members)
120
-				|| (!empty($this->_details['members_only']) && !in_array($member, $this->_details['members_only'])))
121
-				continue;
124
+				|| (!empty($this->_details['members_only']) && !in_array($member, $this->_details['members_only']))) {
125
+							continue;
126
+			}
122 127
 
123 128
 			// Watched topic?
124 129
 			if (!empty($data['id_topic']) && $type != 'topic' && !empty($prefs[$member]))
@@ -128,10 +133,12 @@  discard block
 block discarded – undo
128 133
 
129 134
 				if ($type == 'reply')
130 135
 				{
131
-					if (!empty($prefs[$member]['msg_receive_body']))
132
-						$message_type .= '_body';
133
-					if (!empty($frequency))
134
-						$message_type .= '_once';
136
+					if (!empty($prefs[$member]['msg_receive_body'])) {
137
+											$message_type .= '_body';
138
+					}
139
+					if (!empty($frequency)) {
140
+											$message_type .= '_once';
141
+					}
135 142
 				}
136 143
 
137 144
 				$content_type = 'topic';
@@ -144,12 +151,14 @@  discard block
 block discarded – undo
144 151
 				$content_type = 'board';
145 152
 
146 153
 				$message_type = !empty($frequency) ? 'notify_boards_once' : 'notify_boards';
147
-				if (!empty($prefs[$member]['msg_receive_body']))
148
-					$message_type .= '_body';
154
+				if (!empty($prefs[$member]['msg_receive_body'])) {
155
+									$message_type .= '_body';
156
+				}
149 157
 			}
150 158
 			// If neither of the above, this might be a redundent row due to the OR clause in our SQL query, skip
151
-			else
152
-				continue;
159
+			else {
160
+							continue;
161
+			}
153 162
 
154 163
 			if ($pref & 0x02)
155 164
 			{
@@ -212,14 +221,15 @@  discard block
 block discarded – undo
212 221
 		);
213 222
 
214 223
 		// Insert the alerts if any
215
-		if (!empty($alert_rows))
216
-			$smcFunc['db_insert']('',
224
+		if (!empty($alert_rows)) {
225
+					$smcFunc['db_insert']('',
217 226
 				'{db_prefix}user_alerts',
218 227
 				array('alert_time' => 'int', 'id_member' => 'int', 'id_member_started' => 'int', 'member_name' => 'string',
219 228
 					'content_type' => 'string', 'content_id' => 'int', 'content_action' => 'string', 'is_read' => 'int', 'extra' => 'string'),
220 229
 				$alert_rows,
221 230
 				array()
222 231
 			);
232
+		}
223 233
 
224 234
 		return true;
225 235
 	}
@@ -230,8 +240,9 @@  discard block
 block discarded – undo
230 240
 
231 241
 		foreach ($quotedMembers as $id => $member)
232 242
 		{
233
-			if (!isset($prefs[$id]) || $id == $posterOptions['id'] || empty($prefs[$id]['msg_quote']))
234
-				continue;
243
+			if (!isset($prefs[$id]) || $id == $posterOptions['id'] || empty($prefs[$id]['msg_quote'])) {
244
+							continue;
245
+			}
235 246
 
236 247
 			$done_members[] = $id;
237 248
 
@@ -283,32 +294,35 @@  discard block
 block discarded – undo
283 294
 		{
284 295
 			if (preg_match('/\[quote(.*)?\]/i', $block, $matches))
285 296
 			{
286
-				if ($quote_level == 0)
287
-					$message .= '[quote' . $matches[1] . ']';
297
+				if ($quote_level == 0) {
298
+									$message .= '[quote' . $matches[1] . ']';
299
+				}
288 300
 				$quote_level++;
289
-			}
290
-			elseif (preg_match('/\[\/quote\]/i', $block))
301
+			} elseif (preg_match('/\[\/quote\]/i', $block))
291 302
 			{
292
-				if ($quote_level <= 1)
293
-					$message .= '[/quote]';
303
+				if ($quote_level <= 1) {
304
+									$message .= '[/quote]';
305
+				}
294 306
 				if ($quote_level >= 1)
295 307
 				{
296 308
 					$quote_level--;
297 309
 					$message .= "\n";
298 310
 				}
311
+			} elseif ($quote_level <= 1) {
312
+							$message .= $block;
299 313
 			}
300
-			elseif ($quote_level <= 1)
301
-				$message .= $block;
302 314
 		}
303 315
 
304 316
 		preg_match_all('/\[quote.*?link=msg=([0-9]+).*?\]/i', $message, $matches);
305 317
 
306 318
 		$id_msgs = $matches[1];
307
-		foreach ($id_msgs as $k => $id_msg)
308
-			$id_msgs[$k] = (int) $id_msg;
319
+		foreach ($id_msgs as $k => $id_msg) {
320
+					$id_msgs[$k] = (int) $id_msg;
321
+		}
309 322
 
310
-		if (empty($id_msgs))
311
-			return array();
323
+		if (empty($id_msgs)) {
324
+					return array();
325
+		}
312 326
 
313 327
 		// Get the messages
314 328
 		$request = $smcFunc['db_query']('', '
@@ -326,8 +340,9 @@  discard block
 block discarded – undo
326 340
 		$members = array();
327 341
 		while ($row = $smcFunc['db_fetch_assoc']($request))
328 342
 		{
329
-			if ($posterOptions['id'] == $row['id_member'])
330
-				continue;
343
+			if ($posterOptions['id'] == $row['id_member']) {
344
+							continue;
345
+			}
331 346
 
332 347
 			$members[$row['id_member']] = $row;
333 348
 		}
@@ -341,10 +356,11 @@  discard block
 block discarded – undo
341 356
 
342 357
 		foreach ($members as $id => $member)
343 358
 		{
344
-			if (!empty($prefs[$id]['msg_mention']))
345
-				$done_members[] = $id;
346
-			else
347
-				continue;
359
+			if (!empty($prefs[$id]['msg_mention'])) {
360
+							$done_members[] = $id;
361
+			} else {
362
+							continue;
363
+			}
348 364
 
349 365
 			// Alerts' emails are always instant
350 366
 			if ($prefs[$id]['msg_mention'] & 0x02)
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 3
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * 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/Subs-Calendar.php 1 patch
Braces   +221 added lines, -161 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Get all birthdays within the given time range.
@@ -60,8 +61,7 @@  discard block
 block discarded – undo
60 61
 				'max_year' => $year_high,
61 62
 			)
62 63
 		);
63
-	}
64
-	else
64
+	} else
65 65
 	{
66 66
 		$result = $smcFunc['db_query']('birthday_array', '
67 67
 			SELECT id_member, real_name, YEAR(birthdate) AS birth_year, birthdate
@@ -91,10 +91,11 @@  discard block
 block discarded – undo
91 91
 	$bday = array();
92 92
 	while ($row = $smcFunc['db_fetch_assoc']($result))
93 93
 	{
94
-		if ($year_low != $year_high)
95
-			$age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low;
96
-		else
97
-			$age_year = $year_low;
94
+		if ($year_low != $year_high) {
95
+					$age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low;
96
+		} else {
97
+					$age_year = $year_low;
98
+		}
98 99
 
99 100
 		$bday[$age_year . substr($row['birthdate'], 4)][] = array(
100 101
 			'id' => $row['id_member'],
@@ -108,8 +109,9 @@  discard block
 block discarded – undo
108 109
 	ksort($bday);
109 110
 
110 111
 	// Set is_last, so the themes know when to stop placing separators.
111
-	foreach ($bday as $mday => $array)
112
-		$bday[$mday][count($array) - 1]['is_last'] = true;
112
+	foreach ($bday as $mday => $array) {
113
+			$bday[$mday][count($array) - 1]['is_last'] = true;
114
+	}
113 115
 
114 116
 	return $bday;
115 117
 }
@@ -157,8 +159,9 @@  discard block
 block discarded – undo
157 159
 	while ($row = $smcFunc['db_fetch_assoc']($result))
158 160
 	{
159 161
 		// If the attached topic is not approved then for the moment pretend it doesn't exist
160
-		if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved'])
161
-			continue;
162
+		if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) {
163
+					continue;
164
+		}
162 165
 
163 166
 		// Force a censor of the title - as often these are used by others.
164 167
 		censorText($row['title'], $use_permissions ? false : true);
@@ -167,8 +170,9 @@  discard block
 block discarded – undo
167 170
 		list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row);
168 171
 
169 172
 		// Sanity check
170
-		if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count']))
171
-			continue;
173
+		if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) {
174
+					continue;
175
+		}
172 176
 
173 177
 		// Get set up for the loop
174 178
 		$start_object = date_create($row['start_date'] . (!$allday ? ' ' . $row['start_time'] : ''), timezone_open($tz));
@@ -232,8 +236,8 @@  discard block
 block discarded – undo
232 236
 			);
233 237
 
234 238
 			// If we're using permissions (calendar pages?) then just ouput normal contextual style information.
235
-			if ($use_permissions)
236
-				$events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array(
239
+			if ($use_permissions) {
240
+							$events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array(
237 241
 					'href' => $row['id_board'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0',
238 242
 					'link' => $row['id_board'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>',
239 243
 					'can_edit' => allowedTo('calendar_edit_any') || ($row['id_member'] == $user_info['id'] && allowedTo('calendar_edit_own')),
@@ -241,9 +245,10 @@  discard block
 block discarded – undo
241 245
 					'can_export' => !empty($modSettings['cal_export']) ? true : false,
242 246
 					'export_href' => $scripturl . '?action=calendar;sa=ical;eventid=' . $row['id_event'] . ';' . $context['session_var'] . '=' . $context['session_id'],
243 247
 				));
248
+			}
244 249
 			// Otherwise, this is going to be cached and the VIEWER'S permissions should apply... just put together some info.
245
-			else
246
-				$events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array(
250
+			else {
251
+							$events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array(
247 252
 					'href' => $row['id_topic'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0',
248 253
 					'link' => $row['id_topic'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>',
249 254
 					'can_edit' => false,
@@ -253,6 +258,7 @@  discard block
 block discarded – undo
253 258
 					'poster' => $row['id_member'],
254 259
 					'allowed_groups' => explode(',', $row['member_groups']),
255 260
 				));
261
+			}
256 262
 
257 263
 			date_add($cal_date, date_interval_create_from_date_string('1 day'));
258 264
 		}
@@ -262,8 +268,9 @@  discard block
 block discarded – undo
262 268
 	// If we're doing normal contextual data, go through and make things clear to the templates ;).
263 269
 	if ($use_permissions)
264 270
 	{
265
-		foreach ($events as $mday => $array)
266
-			$events[$mday][count($array) - 1]['is_last'] = true;
271
+		foreach ($events as $mday => $array) {
272
+					$events[$mday][count($array) - 1]['is_last'] = true;
273
+		}
267 274
 	}
268 275
 
269 276
 	ksort($events);
@@ -283,11 +290,12 @@  discard block
 block discarded – undo
283 290
 	global $smcFunc;
284 291
 
285 292
 	// Get the lowest and highest dates for "all years".
286
-	if (substr($low_date, 0, 4) != substr($high_date, 0, 4))
287
-		$allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec}
293
+	if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) {
294
+			$allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec}
288 295
 			OR event_date BETWEEN {date:all_year_jan} AND {date:all_year_high}';
289
-	else
290
-		$allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}';
296
+	} else {
297
+			$allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}';
298
+	}
291 299
 
292 300
 	// Find some holidays... ;).
293 301
 	$result = $smcFunc['db_query']('', '
@@ -307,10 +315,11 @@  discard block
 block discarded – undo
307 315
 	$holidays = array();
308 316
 	while ($row = $smcFunc['db_fetch_assoc']($result))
309 317
 	{
310
-		if (substr($low_date, 0, 4) != substr($high_date, 0, 4))
311
-			$event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4);
312
-		else
313
-			$event_year = substr($low_date, 0, 4);
318
+		if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) {
319
+					$event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4);
320
+		} else {
321
+					$event_year = substr($low_date, 0, 4);
322
+		}
314 323
 
315 324
 		$holidays[$event_year . substr($row['event_date'], 4)][] = $row['title'];
316 325
 	}
@@ -336,10 +345,12 @@  discard block
 block discarded – undo
336 345
 	isAllowedTo('calendar_post');
337 346
 
338 347
 	// No board?  No topic?!?
339
-	if (empty($board))
340
-		fatal_lang_error('missing_board_id', false);
341
-	if (empty($topic))
342
-		fatal_lang_error('missing_topic_id', false);
348
+	if (empty($board)) {
349
+			fatal_lang_error('missing_board_id', false);
350
+	}
351
+	if (empty($topic)) {
352
+			fatal_lang_error('missing_topic_id', false);
353
+	}
343 354
 
344 355
 	// Administrator, Moderator, or owner.  Period.
345 356
 	if (!allowedTo('admin_forum') && !allowedTo('moderate_board'))
@@ -357,12 +368,14 @@  discard block
 block discarded – undo
357 368
 		if ($row = $smcFunc['db_fetch_assoc']($result))
358 369
 		{
359 370
 			// Not the owner of the topic.
360
-			if ($row['id_member_started'] != $user_info['id'])
361
-				fatal_lang_error('not_your_topic', 'user');
371
+			if ($row['id_member_started'] != $user_info['id']) {
372
+							fatal_lang_error('not_your_topic', 'user');
373
+			}
362 374
 		}
363 375
 		// Topic/Board doesn't exist.....
364
-		else
365
-			fatal_lang_error('calendar_no_topic', 'general');
376
+		else {
377
+					fatal_lang_error('calendar_no_topic', 'general');
378
+		}
366 379
 		$smcFunc['db_free_result']($result);
367 380
 	}
368 381
 }
@@ -450,14 +463,16 @@  discard block
 block discarded – undo
450 463
 	if (!empty($calendarOptions['start_day']))
451 464
 	{
452 465
 		$nShift -= $calendarOptions['start_day'];
453
-		if ($nShift < 0)
454
-			$nShift = 7 + $nShift;
466
+		if ($nShift < 0) {
467
+					$nShift = 7 + $nShift;
468
+		}
455 469
 	}
456 470
 
457 471
 	// Number of rows required to fit the month.
458 472
 	$nRows = floor(($month_info['last_day']['day_of_month'] + $nShift) / 7);
459
-	if (($month_info['last_day']['day_of_month'] + $nShift) % 7)
460
-		$nRows++;
473
+	if (($month_info['last_day']['day_of_month'] + $nShift) % 7) {
474
+			$nRows++;
475
+	}
461 476
 
462 477
 	// Fetch the arrays for birthdays, posted events, and holidays.
463 478
 	$bday = $calendarOptions['show_birthdays'] ? getBirthdayRange($month_info['first_day']['date'], $month_info['last_day']['date']) : array();
@@ -470,8 +485,9 @@  discard block
 block discarded – undo
470 485
 	{
471 486
 		$calendarGrid['week_days'][] = $count;
472 487
 		$count++;
473
-		if ($count == 7)
474
-			$count = 0;
488
+		if ($count == 7) {
489
+					$count = 0;
490
+		}
475 491
 	}
476 492
 
477 493
 	// Iterate through each week.
@@ -488,8 +504,9 @@  discard block
 block discarded – undo
488 504
 		{
489 505
 			$nDay = ($nRow * 7) + $nCol - $nShift + 1;
490 506
 
491
-			if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month'])
492
-				$nDay = 0;
507
+			if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) {
508
+							$nDay = 0;
509
+			}
493 510
 
494 511
 			$date = sprintf('%04d-%02d-%02d', $year, $month, $nDay);
495 512
 
@@ -507,8 +524,9 @@  discard block
 block discarded – undo
507 524
 	}
508 525
 
509 526
 	// What is the last day of the month?
510
-	if ($is_previous === true)
511
-		$calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month'];
527
+	if ($is_previous === true) {
528
+			$calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month'];
529
+	}
512 530
 
513 531
 	// We'll use the shift in the template.
514 532
 	$calendarGrid['shift'] = $nShift;
@@ -542,8 +560,9 @@  discard block
 block discarded – undo
542 560
 	{
543 561
 		// Here we offset accordingly to get things to the real start of a week.
544 562
 		$date_diff = $day_of_week - $calendarOptions['start_day'];
545
-		if ($date_diff < 0)
546
-			$date_diff += 7;
563
+		if ($date_diff < 0) {
564
+					$date_diff += 7;
565
+		}
547 566
 		$new_timestamp = mktime(0, 0, 0, $month, $day, $year) - $date_diff * 86400;
548 567
 		$day = (int) strftime('%d', $new_timestamp);
549 568
 		$month = (int) strftime('%m', $new_timestamp);
@@ -673,18 +692,20 @@  discard block
 block discarded – undo
673 692
 	{
674 693
 		foreach ($date_events as $event_key => $event_val)
675 694
 		{
676
-			if (in_array($event_val['id'], $temp))
677
-				unset($calendarGrid['events'][$date][$event_key]);
678
-			else
679
-				$temp[] = $event_val['id'];
695
+			if (in_array($event_val['id'], $temp)) {
696
+							unset($calendarGrid['events'][$date][$event_key]);
697
+			} else {
698
+							$temp[] = $event_val['id'];
699
+			}
680 700
 		}
681 701
 	}
682 702
 
683 703
 	// Give birthdays and holidays a friendly format, without the year
684
-	if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0]))
685
-		$date_format = '%b %d';
686
-	else
687
-		$date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]);
704
+	if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) {
705
+			$date_format = '%b %d';
706
+	} else {
707
+			$date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]);
708
+	}
688 709
 
689 710
 	foreach (array('birthdays', 'holidays') as $type)
690 711
 	{
@@ -792,8 +813,9 @@  discard block
 block discarded – undo
792 813
 	// Holidays between now and now + days.
793 814
 	for ($i = $now; $i < $now + $days_for_index; $i += 86400)
794 815
 	{
795
-		if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)]))
796
-			$return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]);
816
+		if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)])) {
817
+					$return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]);
818
+		}
797 819
 	}
798 820
 
799 821
 	// Happy Birthday, guys and gals!
@@ -802,8 +824,9 @@  discard block
 block discarded – undo
802 824
 		$loop_date = strftime('%Y-%m-%d', $i);
803 825
 		if (isset($cached_data['birthdays'][$loop_date]))
804 826
 		{
805
-			foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy)
806
-				$cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date'];
827
+			foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) {
828
+							$cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date'];
829
+			}
807 830
 			$return_data['calendar_birthdays'] = array_merge($return_data['calendar_birthdays'], $cached_data['birthdays'][$loop_date]);
808 831
 		}
809 832
 	}
@@ -815,8 +838,9 @@  discard block
 block discarded – undo
815 838
 		$loop_date = strftime('%Y-%m-%d', $i);
816 839
 
817 840
 		// No events today? Check the next day.
818
-		if (empty($cached_data['events'][$loop_date]))
819
-			continue;
841
+		if (empty($cached_data['events'][$loop_date])) {
842
+					continue;
843
+		}
820 844
 
821 845
 		// Loop through all events to add a few last-minute values.
822 846
 		foreach ($cached_data['events'][$loop_date] as $ev => $event)
@@ -829,9 +853,9 @@  discard block
 block discarded – undo
829 853
 			{
830 854
 				unset($cached_data['events'][$loop_date][$ev]);
831 855
 				continue;
856
+			} else {
857
+							$duplicates[$this_event['topic'] . $this_event['title']] = true;
832 858
 			}
833
-			else
834
-				$duplicates[$this_event['topic'] . $this_event['title']] = true;
835 859
 
836 860
 			// Might be set to true afterwards, depending on the permissions.
837 861
 			$this_event['can_edit'] = false;
@@ -839,15 +863,18 @@  discard block
 block discarded – undo
839 863
 			$this_event['date'] = $loop_date;
840 864
 		}
841 865
 
842
-		if (!empty($cached_data['events'][$loop_date]))
843
-			$return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]);
866
+		if (!empty($cached_data['events'][$loop_date])) {
867
+					$return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]);
868
+		}
844 869
 	}
845 870
 
846 871
 	// Mark the last item so that a list separator can be used in the template.
847
-	for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++)
848
-		$return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]);
849
-	for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++)
850
-		$return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]);
872
+	for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) {
873
+			$return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]);
874
+	}
875
+	for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) {
876
+			$return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]);
877
+	}
851 878
 
852 879
 	return array(
853 880
 		'data' => $return_data,
@@ -895,37 +922,46 @@  discard block
 block discarded – undo
895 922
 		if (isset($_POST['start_date']))
896 923
 		{
897 924
 			$d = date_parse($_POST['start_date']);
898
-			if (!empty($d['error_count']) || !empty($d['warning_count']))
899
-				fatal_lang_error('invalid_date', false);
900
-			if (empty($d['year']))
901
-				fatal_lang_error('event_year_missing', false);
902
-			if (empty($d['month']))
903
-				fatal_lang_error('event_month_missing', false);
904
-		}
905
-		elseif (isset($_POST['start_datetime']))
925
+			if (!empty($d['error_count']) || !empty($d['warning_count'])) {
926
+							fatal_lang_error('invalid_date', false);
927
+			}
928
+			if (empty($d['year'])) {
929
+							fatal_lang_error('event_year_missing', false);
930
+			}
931
+			if (empty($d['month'])) {
932
+							fatal_lang_error('event_month_missing', false);
933
+			}
934
+		} elseif (isset($_POST['start_datetime']))
906 935
 		{
907 936
 			$d = date_parse($_POST['start_datetime']);
908
-			if (!empty($d['error_count']) || !empty($d['warning_count']))
909
-				fatal_lang_error('invalid_date', false);
910
-			if (empty($d['year']))
911
-				fatal_lang_error('event_year_missing', false);
912
-			if (empty($d['month']))
913
-				fatal_lang_error('event_month_missing', false);
937
+			if (!empty($d['error_count']) || !empty($d['warning_count'])) {
938
+							fatal_lang_error('invalid_date', false);
939
+			}
940
+			if (empty($d['year'])) {
941
+							fatal_lang_error('event_year_missing', false);
942
+			}
943
+			if (empty($d['month'])) {
944
+							fatal_lang_error('event_month_missing', false);
945
+			}
914 946
 		}
915 947
 		// The 2.0 way
916 948
 		else
917 949
 		{
918 950
 			// No month?  No year?
919
-			if (!isset($_POST['month']))
920
-				fatal_lang_error('event_month_missing', false);
921
-			if (!isset($_POST['year']))
922
-				fatal_lang_error('event_year_missing', false);
951
+			if (!isset($_POST['month'])) {
952
+							fatal_lang_error('event_month_missing', false);
953
+			}
954
+			if (!isset($_POST['year'])) {
955
+							fatal_lang_error('event_year_missing', false);
956
+			}
923 957
 
924 958
 			// Check the month and year...
925
-			if ($_POST['month'] < 1 || $_POST['month'] > 12)
926
-				fatal_lang_error('invalid_month', false);
927
-			if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear'])
928
-				fatal_lang_error('invalid_year', false);
959
+			if ($_POST['month'] < 1 || $_POST['month'] > 12) {
960
+							fatal_lang_error('invalid_month', false);
961
+			}
962
+			if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear']) {
963
+							fatal_lang_error('invalid_year', false);
964
+			}
929 965
 		}
930 966
 	}
931 967
 
@@ -935,8 +971,9 @@  discard block
 block discarded – undo
935 971
 	// If they want to us to calculate an end date, make sure it will fit in an acceptable range.
936 972
 	if (isset($_POST['span']))
937 973
 	{
938
-		if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan']))
939
-			fatal_lang_error('invalid_days_numb', false);
974
+		if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan'])) {
975
+					fatal_lang_error('invalid_days_numb', false);
976
+		}
940 977
 	}
941 978
 
942 979
 	// There is no need to validate the following values if we are just deleting the event.
@@ -946,24 +983,29 @@  discard block
 block discarded – undo
946 983
 		if (empty($_POST['start_date']) && empty($_POST['start_datetime']))
947 984
 		{
948 985
 			// No day?
949
-			if (!isset($_POST['day']))
950
-				fatal_lang_error('event_day_missing', false);
986
+			if (!isset($_POST['day'])) {
987
+							fatal_lang_error('event_day_missing', false);
988
+			}
951 989
 
952 990
 			// Bad day?
953
-			if (!checkdate($_POST['month'], $_POST['day'], $_POST['year']))
954
-				fatal_lang_error('invalid_date', false);
991
+			if (!checkdate($_POST['month'], $_POST['day'], $_POST['year'])) {
992
+							fatal_lang_error('invalid_date', false);
993
+			}
955 994
 		}
956 995
 
957
-		if (!isset($_POST['evtitle']) && !isset($_POST['subject']))
958
-			fatal_lang_error('event_title_missing', false);
959
-		elseif (!isset($_POST['evtitle']))
960
-			$_POST['evtitle'] = $_POST['subject'];
996
+		if (!isset($_POST['evtitle']) && !isset($_POST['subject'])) {
997
+					fatal_lang_error('event_title_missing', false);
998
+		} elseif (!isset($_POST['evtitle'])) {
999
+					$_POST['evtitle'] = $_POST['subject'];
1000
+		}
961 1001
 
962 1002
 		// No title?
963
-		if ($smcFunc['htmltrim']($_POST['evtitle']) === '')
964
-			fatal_lang_error('no_event_title', false);
965
-		if ($smcFunc['strlen']($_POST['evtitle']) > 100)
966
-			$_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100);
1003
+		if ($smcFunc['htmltrim']($_POST['evtitle']) === '') {
1004
+					fatal_lang_error('no_event_title', false);
1005
+		}
1006
+		if ($smcFunc['strlen']($_POST['evtitle']) > 100) {
1007
+					$_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100);
1008
+		}
967 1009
 		$_POST['evtitle'] = str_replace(';', '', $_POST['evtitle']);
968 1010
 	}
969 1011
 }
@@ -990,8 +1032,9 @@  discard block
 block discarded – undo
990 1032
 	);
991 1033
 
992 1034
 	// No results, return false.
993
-	if ($smcFunc['db_num_rows'] === 0)
994
-		return false;
1035
+	if ($smcFunc['db_num_rows'] === 0) {
1036
+			return false;
1037
+	}
995 1038
 
996 1039
 	// Grab the results and return.
997 1040
 	list ($poster) = $smcFunc['db_fetch_row']($request);
@@ -1125,8 +1168,9 @@  discard block
 block discarded – undo
1125 1168
 	call_integration_hook('integrate_modify_event', array($event_id, &$eventOptions, &$event_columns, &$event_parameters));
1126 1169
 
1127 1170
 	$column_clauses = array();
1128
-	foreach ($event_columns as $col => $crit)
1129
-		$column_clauses[] = $col . ' = ' . $crit;
1171
+	foreach ($event_columns as $col => $crit) {
1172
+			$column_clauses[] = $col . ' = ' . $crit;
1173
+	}
1130 1174
 
1131 1175
 	$smcFunc['db_query']('', '
1132 1176
 		UPDATE {db_prefix}calendar
@@ -1211,8 +1255,9 @@  discard block
 block discarded – undo
1211 1255
 	);
1212 1256
 
1213 1257
 	// If nothing returned, we are in poo, poo.
1214
-	if ($smcFunc['db_num_rows']($request) === 0)
1215
-		return false;
1258
+	if ($smcFunc['db_num_rows']($request) === 0) {
1259
+			return false;
1260
+	}
1216 1261
 
1217 1262
 	$row = $smcFunc['db_fetch_assoc']($request);
1218 1263
 	$smcFunc['db_free_result']($request);
@@ -1220,8 +1265,9 @@  discard block
 block discarded – undo
1220 1265
 	list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row);
1221 1266
 
1222 1267
 	// Sanity check
1223
-	if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count']))
1224
-		return false;
1268
+	if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) {
1269
+			return false;
1270
+	}
1225 1271
 
1226 1272
 	$return_value = array(
1227 1273
 		'boards' => array(),
@@ -1358,24 +1404,27 @@  discard block
 block discarded – undo
1358 1404
 
1359 1405
 	// Set $span, in case we need it
1360 1406
 	$span = isset($eventOptions['span']) ? $eventOptions['span'] : (isset($_POST['span']) ? $_POST['span'] : 0);
1361
-	if ($span > 0)
1362
-		$span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1;
1407
+	if ($span > 0) {
1408
+			$span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1;
1409
+	}
1363 1410
 
1364 1411
 	// Define the timezone for this event, falling back to the default if not provided
1365
-	if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC)))
1366
-		$tz = $eventOptions['tz'];
1367
-	elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC)))
1368
-		$tz = $_POST['tz'];
1369
-	else
1370
-		$tz = getUserTimezone();
1412
+	if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) {
1413
+			$tz = $eventOptions['tz'];
1414
+	} elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) {
1415
+			$tz = $_POST['tz'];
1416
+	} else {
1417
+			$tz = getUserTimezone();
1418
+	}
1371 1419
 
1372 1420
 	// Is this supposed to be an all day event, or should it have specific start and end times?
1373
-	if (isset($eventOptions['allday']))
1374
-		$allday = $eventOptions['allday'];
1375
-	elseif (empty($_POST['allday']))
1376
-		$allday = false;
1377
-	else
1378
-		$allday = true;
1421
+	if (isset($eventOptions['allday'])) {
1422
+			$allday = $eventOptions['allday'];
1423
+	} elseif (empty($_POST['allday'])) {
1424
+			$allday = false;
1425
+	} else {
1426
+			$allday = true;
1427
+	}
1379 1428
 
1380 1429
 	// Input might come as individual parameters...
1381 1430
 	$start_year = isset($eventOptions['year']) ? $eventOptions['year'] : (isset($_POST['year']) ? $_POST['year'] : null);
@@ -1402,10 +1451,12 @@  discard block
 block discarded – undo
1402 1451
 	$end_time_string = isset($eventOptions['end_time']) ? $eventOptions['end_time'] : (isset($_POST['end_time']) ? $_POST['end_time'] : null);
1403 1452
 
1404 1453
 	// If the date and time were given in separate strings, combine them
1405
-	if (empty($start_string) && isset($start_date_string))
1406
-		$start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : '');
1407
-	if (empty($end_string) && isset($end_date_string))
1408
-		$end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : '');
1454
+	if (empty($start_string) && isset($start_date_string)) {
1455
+			$start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : '');
1456
+	}
1457
+	if (empty($end_string) && isset($end_date_string)) {
1458
+			$end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : '');
1459
+	}
1409 1460
 
1410 1461
 	// If some form of string input was given, override individually defined options with it
1411 1462
 	if (isset($start_string))
@@ -1496,10 +1547,11 @@  discard block
 block discarded – undo
1496 1547
 	if ($start_object >= $end_object)
1497 1548
 	{
1498 1549
 		$end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz);
1499
-		if ($span > 0)
1500
-			date_add($end_object, date_interval_create_from_date_string($span . ' days'));
1501
-		else
1502
-			date_add($end_object, date_interval_create_from_date_string('1 hour'));
1550
+		if ($span > 0) {
1551
+					date_add($end_object, date_interval_create_from_date_string($span . ' days'));
1552
+		} else {
1553
+					date_add($end_object, date_interval_create_from_date_string('1 hour'));
1554
+		}
1503 1555
 	}
1504 1556
 
1505 1557
 	// Is $end_object too late?
@@ -1512,9 +1564,9 @@  discard block
 block discarded – undo
1512 1564
 			{
1513 1565
 				$end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz);
1514 1566
 				date_add($end_object, date_interval_create_from_date_string($modSettings['cal_maxspan'] . ' days'));
1567
+			} else {
1568
+							$end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz);
1515 1569
 			}
1516
-			else
1517
-				$end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz);
1518 1570
 		}
1519 1571
 	}
1520 1572
 
@@ -1527,8 +1579,7 @@  discard block
 block discarded – undo
1527 1579
 		$start_time = null;
1528 1580
 		$end_time = null;
1529 1581
 		$tz = null;
1530
-	}
1531
-	else
1582
+	} else
1532 1583
 	{
1533 1584
 		$start_time = date_format($start_object, 'H:i:s');
1534 1585
 		$end_time = date_format($end_object, 'H:i:s');
@@ -1549,16 +1600,18 @@  discard block
 block discarded – undo
1549 1600
 	require_once($sourcedir . '/Subs.php');
1550 1601
 
1551 1602
 	// First, try to create a better date format, ignoring the "time" elements.
1552
-	if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0]))
1553
-		$date_format = '%F';
1554
-	else
1555
-		$date_format = $matches[0];
1603
+	if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) {
1604
+			$date_format = '%F';
1605
+	} else {
1606
+			$date_format = $matches[0];
1607
+	}
1556 1608
 
1557 1609
 	// We want a fairly compact version of the time, but as close as possible to the user's settings.
1558
-	if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0]))
1559
-		$time_format = '%k:%M';
1560
-	else
1561
-		$time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]);
1610
+	if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) {
1611
+			$time_format = '%k:%M';
1612
+	} else {
1613
+			$time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]);
1614
+	}
1562 1615
 
1563 1616
 	// Should this be an all day event?
1564 1617
 	$allday = (empty($row['start_time']) || empty($row['end_time']) || empty($row['timezone']) || !in_array($row['timezone'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) ? true : false;
@@ -1567,8 +1620,9 @@  discard block
 block discarded – undo
1567 1620
 	$span = 1 + date_interval_format(date_diff(date_create($row['start_date']), date_create($row['end_date'])), '%d');
1568 1621
 
1569 1622
 	// We need to have a defined timezone in the steps below
1570
-	if (empty($row['timezone']))
1571
-		$row['timezone'] = getUserTimezone();
1623
+	if (empty($row['timezone'])) {
1624
+			$row['timezone'] = getUserTimezone();
1625
+	}
1572 1626
 
1573 1627
 	// Get most of the standard date information for the start and end datetimes
1574 1628
 	$start = date_parse($row['start_date'] . (!$allday ? ' ' . $row['start_time'] : ''));
@@ -1612,8 +1666,9 @@  discard block
 block discarded – undo
1612 1666
 		$tz_location = timezone_location_get(timezone_open($row['timezone']));
1613 1667
 
1614 1668
 		// Kazakstan
1615
-		if ($tz_location['country_code'] == 'KZ')
1616
-			$tz_abbrev = str_replace(array('+05', '+06'), array('AQTT', 'ALMT'), $tz_abbrev);
1669
+		if ($tz_location['country_code'] == 'KZ') {
1670
+					$tz_abbrev = str_replace(array('+05', '+06'), array('AQTT', 'ALMT'), $tz_abbrev);
1671
+		}
1617 1672
 
1618 1673
 		// Russia likes to experiment with time zones
1619 1674
 		if ($tz_location['country_code'] == 'RU')
@@ -1624,8 +1679,9 @@  discard block
 block discarded – undo
1624 1679
 		}
1625 1680
 
1626 1681
 		// Still no good? We'll just mark it as a UTC offset
1627
-		if (strspn($tz_abbrev, '+-') > 0)
1628
-			$tz_abbrev = 'UTC' . $tz_abbrev;
1682
+		if (strspn($tz_abbrev, '+-') > 0) {
1683
+					$tz_abbrev = 'UTC' . $tz_abbrev;
1684
+		}
1629 1685
 	}
1630 1686
 
1631 1687
 	return array($start, $end, $allday, $span, $tz, $tz_abbrev);
@@ -1642,8 +1698,9 @@  discard block
 block discarded – undo
1642 1698
 	global $smcFunc, $context, $sourcedir, $user_info, $modSettings;
1643 1699
 	static $member_cache = array();
1644 1700
 
1645
-	if (is_null($id_member) && $user_info['is_guest'] == false)
1646
-		$id_member = $context['user']['id'];
1701
+	if (is_null($id_member) && $user_info['is_guest'] == false) {
1702
+			$id_member = $context['user']['id'];
1703
+	}
1647 1704
 	
1648 1705
 	//check if the cache got the data
1649 1706
 	if (isset($id_member) && isset($member_cache[$id_member]))
@@ -1665,11 +1722,13 @@  discard block
 block discarded – undo
1665 1722
 		$smcFunc['db_free_result']($request);
1666 1723
 	}
1667 1724
 
1668
-	if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC)))
1669
-		$timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get();
1725
+	if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) {
1726
+			$timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get();
1727
+	}
1670 1728
 
1671
-	if (isset($id_member))
1672
-		$member_cache[$id_member] = $timezone;
1729
+	if (isset($id_member)) {
1730
+			$member_cache[$id_member] = $timezone;
1731
+	}
1673 1732
 	
1674 1733
 	return $timezone;
1675 1734
 }
@@ -1698,8 +1757,9 @@  discard block
 block discarded – undo
1698 1757
 		)
1699 1758
 	);
1700 1759
 	$holidays = array();
1701
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1702
-		$holidays[] = $row;
1760
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1761
+			$holidays[] = $row;
1762
+	}
1703 1763
 	$smcFunc['db_free_result']($request);
1704 1764
 
1705 1765
 	return $holidays;
Please login to merge, or discard this patch.
Sources/tasks/Likes-Notify.php 1 patch
Braces   +19 added lines, -14 removed lines patch added patch discarded remove patch
@@ -51,30 +51,33 @@  discard block
 block discarded – undo
51 51
 				$ignored_members = explode(',', $row['pm_ignore_list']);
52 52
 
53 53
 				// If the user is in group 1 anywhere, they can see everything anyway.
54
-				if (in_array(1, $groups) || count(array_intersect($allowed, $groups)) != 0)
55
-					$author = $row['id_member'];
54
+				if (in_array(1, $groups) || count(array_intersect($allowed, $groups)) != 0) {
55
+									$author = $row['id_member'];
56
+				}
56 57
 			}
57 58
 			$smcFunc['db_free_result']($request);
58
-		}
59
-		else
59
+		} else
60 60
 		{
61 61
 			// This isn't something we know natively how to support. Call the hooks, if they're dealing with it, return false, otherwise return the user id.
62 62
 			$hook_results = call_integration_hook('integrate_find_like_author', array($this->_details['content_type'], $this->_details['content_id']));
63
-			foreach ($hook_results as $result)
64
-				if (!empty($result))
63
+			foreach ($hook_results as $result) {
64
+							if (!empty($result))
65 65
 				{
66 66
 					$author = $result;
67
+			}
67 68
 					break;
68 69
 				}
69 70
 		}
70 71
 
71 72
 		// If we didn't have a member... leave.
72
-		if (empty($author))
73
-			return true;
73
+		if (empty($author)) {
74
+					return true;
75
+		}
74 76
 
75 77
 		// If the person who sent the notification is the person whose content it is, do nothing.
76
-		if ($author == $this->_details['sender_id'])
77
-			return true;
78
+		if ($author == $this->_details['sender_id']) {
79
+					return true;
80
+		}
78 81
 
79 82
 		// If the person who sent the notification is on this person's ignore list, do nothing.
80 83
 		if (!empty($ignored_members) && in_array($this->_details['sender_id'], $ignored_members)) {
@@ -88,8 +91,9 @@  discard block
 block discarded – undo
88 91
 		// As a result, the value should really just be non empty.
89 92
 
90 93
 		// Check the value. If no value or it's empty, they didn't want alerts, oh well.
91
-		if (empty($prefs[$author][$this->_details['content_type'] . '_like']))
92
-			return true;
94
+		if (empty($prefs[$author][$this->_details['content_type'] . '_like'])) {
95
+					return true;
96
+		}
93 97
 
94 98
 		// Don't spam the alerts: if there is an existing unread alert of the
95 99
 		// requested type for the target user from the sender, don't make a new one.
@@ -109,8 +113,9 @@  discard block
 block discarded – undo
109 113
 			)
110 114
 		);
111 115
 
112
-		if ($smcFunc['db_num_rows']($request) > 0)
113
-			return true;
116
+		if ($smcFunc['db_num_rows']($request) > 0) {
117
+					return true;
118
+		}
114 119
 		$smcFunc['db_free_result']($request);
115 120
 
116 121
 		// Issue, update, move on.
Please login to merge, or discard this patch.
Themes/default/Display.template.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -670,7 +670,7 @@
 block discarded – undo
670 670
 	// Show "<< Last Edit: Time by Person >>" if this post was edited. But we need the div even if it wasn't modified!
671 671
 	// Because we insert into it through AJAX and we don't want to stop themers moving it around if they so wish so they can put it where they want it.
672 672
 	echo '
673
-									<span class="smalltext modified floatright', !empty($modSettings['show_modify']) && !empty($message['modified']['name']) ? ' mvisible' : '','" id="modified_', $message['id'], '">';
673
+									<span class="smalltext modified floatright', !empty($modSettings['show_modify']) && !empty($message['modified']['name']) ? ' mvisible' : '', '" id="modified_', $message['id'], '">';
674 674
 
675 675
 	if (!empty($modSettings['show_modify']) && !empty($message['modified']['name']))
676 676
 		echo
Please login to merge, or discard this patch.
Braces   +221 added lines, -151 removed lines patch added patch discarded remove patch
@@ -51,11 +51,13 @@  discard block
 block discarded – undo
51 51
 				<p>';
52 52
 
53 53
 		// Show just numbers...?
54
-		if ($settings['display_who_viewing'] == 1)
55
-				echo count($context['view_members']), ' ', count($context['view_members']) == 1 ? $txt['who_member'] : $txt['members'];
54
+		if ($settings['display_who_viewing'] == 1) {
55
+						echo count($context['view_members']), ' ', count($context['view_members']) == 1 ? $txt['who_member'] : $txt['members'];
56
+		}
56 57
 		// Or show the actual people viewing the topic?
57
-		else
58
-			echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . ((empty($context['view_num_hidden']) || $context['can_moderate_forum']) ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')');
58
+		else {
59
+					echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . ((empty($context['view_num_hidden']) || $context['can_moderate_forum']) ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')');
60
+		}
59 61
 
60 62
 		// Now show how many guests are here too.
61 63
 		echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['guest'] : $txt['guests'], $txt['who_viewing_topic'], '
@@ -93,10 +95,11 @@  discard block
 block discarded – undo
93 95
 						<dt class="', $option['voted_this'] ? ' voted' : '', '">', $option['option'], '</dt>
94 96
 						<dd class="statsbar', $option['voted_this'] ? ' voted' : '', '">';
95 97
 
96
-				if ($context['allow_results_view'])
97
-					echo '
98
+				if ($context['allow_results_view']) {
99
+									echo '
98 100
 							', $option['bar_ndt'], '
99 101
 							<span class="percentage">', $option['votes'], ' (', $option['percent'], '%)</span>';
102
+				}
100 103
 
101 104
 				echo '
102 105
 						</dd>';
@@ -105,9 +108,10 @@  discard block
 block discarded – undo
105 108
 			echo '
106 109
 					</dl>';
107 110
 
108
-			if ($context['allow_results_view'])
109
-				echo '
111
+			if ($context['allow_results_view']) {
112
+							echo '
110 113
 						<p><strong>', $txt['poll_total_voters'], ':</strong> ', $context['poll']['total_votes'], '</p>';
114
+			}
111 115
 		}
112 116
 		// They are allowed to vote! Go to it!
113 117
 		else
@@ -116,17 +120,19 @@  discard block
 block discarded – undo
116 120
 						<form action="', $scripturl, '?action=vote;topic=', $context['current_topic'], '.', $context['start'], ';poll=', $context['poll']['id'], '" method="post" accept-charset="', $context['character_set'], '">';
117 121
 
118 122
 			// Show a warning if they are allowed more than one option.
119
-			if ($context['poll']['allowed_warning'])
120
-				echo '
123
+			if ($context['poll']['allowed_warning']) {
124
+							echo '
121 125
 							<p class="smallpadding">', $context['poll']['allowed_warning'], '</p>';
126
+			}
122 127
 
123 128
 			echo '
124 129
 							<ul class="options">';
125 130
 
126 131
 			// Show each option with its button - a radio likely.
127
-			foreach ($context['poll']['options'] as $option)
128
-				echo '
132
+			foreach ($context['poll']['options'] as $option) {
133
+							echo '
129 134
 								<li>', $option['vote_button'], ' <label for="', $option['id'], '">', $option['option'], '</label></li>';
135
+			}
130 136
 
131 137
 			echo '
132 138
 							</ul>
@@ -138,9 +144,10 @@  discard block
 block discarded – undo
138 144
 		}
139 145
 
140 146
 		// Is the clock ticking?
141
-		if (!empty($context['poll']['expire_time']))
142
-			echo '
147
+		if (!empty($context['poll']['expire_time'])) {
148
+					echo '
143 149
 						<p><strong>', ($context['poll']['is_expired'] ? $txt['poll_expired_on'] : $txt['poll_expires_on']), ':</strong> ', $context['poll']['expire_time'], '</p>';
150
+		}
144 151
 
145 152
 		echo '
146 153
 					</div>
@@ -170,11 +177,13 @@  discard block
 block discarded – undo
170 177
 					<li>
171 178
 						<b class="event_title"><a href="', $scripturl, '?action=calendar;event=', $event['id'], '">', $event['title'], '</a></b>';
172 179
 
173
-			if ($event['can_edit'])
174
-				echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>';
180
+			if ($event['can_edit']) {
181
+							echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>';
182
+			}
175 183
 
176
-			if ($event['can_export'])
177
-				echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>';
184
+			if ($event['can_export']) {
185
+							echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>';
186
+			}
178 187
 
179 188
 			echo '
180 189
 						<br>';
@@ -182,14 +191,14 @@  discard block
 block discarded – undo
182 191
 			if (!empty($event['allday']))
183 192
 			{
184 193
 				echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), '</time>', ($event['start_date'] != $event['end_date']) ? ' &ndash; <time datetime="' . $event['end_iso_gmdate'] . '">' . trim($event['end_date_local']) . '</time>' : '';
185
-			}
186
-			else
194
+			} else
187 195
 			{
188 196
 				// Display event info relative to user's local timezone
189 197
 				echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), ', ', trim($event['start_time_local']), '</time> &ndash; <time datetime="' . $event['end_iso_gmdate'] . '">';
190 198
 
191
-				if ($event['start_date_local'] != $event['end_date_local'])
192
-					echo trim($event['end_date_local']) . ', ';
199
+				if ($event['start_date_local'] != $event['end_date_local']) {
200
+									echo trim($event['end_date_local']) . ', ';
201
+				}
193 202
 
194 203
 				echo trim($event['end_time_local']);
195 204
 
@@ -198,23 +207,27 @@  discard block
 block discarded – undo
198 207
 				{
199 208
 					echo '</time> (<time datetime="' . $event['start_iso_gmdate'] . '">';
200 209
 
201
-					if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig'])
202
-						echo trim($event['start_date_orig']), ', ';
210
+					if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) {
211
+											echo trim($event['start_date_orig']), ', ';
212
+					}
203 213
 
204 214
 					echo trim($event['start_time_orig']), '</time> &ndash; <time datetime="' . $event['end_iso_gmdate'] . '">';
205 215
 
206
-					if ($event['start_date_orig'] != $event['end_date_orig'])
207
-						echo trim($event['end_date_orig']) . ', ';
216
+					if ($event['start_date_orig'] != $event['end_date_orig']) {
217
+											echo trim($event['end_date_orig']) . ', ';
218
+					}
208 219
 
209 220
 					echo trim($event['end_time_orig']), ' ', $event['tz_abbrev'], '</time>)';
210 221
 				}
211 222
 				// Event is scheduled in the user's own timezone? Let 'em know, just to avoid confusion
212
-				else
213
-					echo ' ', $event['tz_abbrev'], '</time>';
223
+				else {
224
+									echo ' ', $event['tz_abbrev'], '</time>';
225
+				}
214 226
 			}
215 227
 
216
-			if (!empty($event['location']))
217
-				echo '<br>', $event['location'];
228
+			if (!empty($event['location'])) {
229
+							echo '<br>', $event['location'];
230
+			}
218 231
 
219 232
 			echo '
220 233
 					</li>';
@@ -252,8 +265,9 @@  discard block
 block discarded – undo
252 265
 	$context['removableMessageIDs'] = array();
253 266
 
254 267
 	// Get all the messages...
255
-	while ($message = $context['get_message']())
256
-		template_single_post($message);
268
+	while ($message = $context['get_message']()) {
269
+			template_single_post($message);
270
+	}
257 271
 
258 272
 	echo '
259 273
 				</form>
@@ -290,8 +304,9 @@  discard block
 block discarded – undo
290 304
 			<div id="display_jump_to">&nbsp;</div>';
291 305
 
292 306
 	// Show quickreply
293
-	if ($context['can_reply'])
294
-	template_quickreply();
307
+	if ($context['can_reply']) {
308
+		template_quickreply();
309
+	}
295 310
 
296 311
 	// User action pop on mobile screen (or actually small screen), this uses responsive css does not check mobile device.
297 312
 	echo '
@@ -304,8 +319,8 @@  discard block
 block discarded – undo
304 319
 			</div>';
305 320
 
306 321
 	// Show the moderation button & pop only if user can moderate
307
-	if ($context['can_moderate_forum'] || $context['user']['is_mod'])
308
-		echo '
322
+	if ($context['can_moderate_forum'] || $context['user']['is_mod']) {
323
+			echo '
309 324
 			<div id="mobile_moderation" class="popup_container">
310 325
 				<div class="popup_window description">
311 326
 					<div class="popup_heading">', $txt['mobile_moderation'], '
@@ -315,6 +330,7 @@  discard block
 block discarded – undo
315 330
 					</div>
316 331
 				</div>
317 332
 			</div>';
333
+	}
318 334
 
319 335
 		echo '
320 336
 				<script>';
@@ -438,9 +454,10 @@  discard block
 block discarded – undo
438 454
 						});
439 455
 					}';
440 456
 
441
-	if (!empty($context['ignoredMsgs']))
442
-		echo '
457
+	if (!empty($context['ignoredMsgs'])) {
458
+			echo '
443 459
 					ignore_toggles([', implode(', ', $context['ignoredMsgs']), '], ', JavaScriptEscape($txt['show_ignore_user_post']), ');';
460
+	}
444 461
 
445 462
 	echo '
446 463
 				</script>';
@@ -457,8 +474,9 @@  discard block
 block discarded – undo
457 474
 
458 475
 	$ignoring = false;
459 476
 
460
-	if ($message['can_remove'])
461
-		$context['removableMessageIDs'][] = $message['id'];
477
+	if ($message['can_remove']) {
478
+			$context['removableMessageIDs'][] = $message['id'];
479
+	}
462 480
 
463 481
 	// Are we ignoring this message?
464 482
 	if (!empty($message['is_ignored']))
@@ -484,9 +502,10 @@  discard block
 block discarded – undo
484 502
 							<div class="custom_fields_above_member">
485 503
 								<ul class="nolist">';
486 504
 
487
-		foreach ($message['custom_fields']['above_member'] as $custom)
488
-			echo '
505
+		foreach ($message['custom_fields']['above_member'] as $custom) {
506
+					echo '
489 507
 									<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
508
+		}
490 509
 
491 510
 		echo '
492 511
 								</ul>
@@ -497,9 +516,10 @@  discard block
 block discarded – undo
497 516
 									<h4>';
498 517
 
499 518
 	// Show online and offline buttons?
500
-	if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest'])
501
-		echo '
519
+	if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) {
520
+			echo '
502 521
 								', $context['can_send_pm'] ? '<a href="' . $message['member']['online']['href'] . '" title="' . $message['member']['online']['label'] . '">' : '', '<span class="' . ($message['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $message['member']['online']['text'] . '"></span>', $context['can_send_pm'] ? '</a>' : '';
522
+	}
503 523
 
504 524
 
505 525
 	// Show a link to the member's profile.
@@ -512,51 +532,59 @@  discard block
 block discarded – undo
512 532
 
513 533
 
514 534
 	// Show the user's avatar.
515
-	if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image']))
516
-		echo '
535
+	if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) {
536
+			echo '
517 537
 								<li class="avatar">
518 538
 									<a href="', $message['member']['href'], '">', $message['member']['avatar']['image'], '</a>
519 539
 								</li>';
540
+	}
520 541
 
521 542
 	// Are there any custom fields below the avatar?
522
-	if (!empty($message['custom_fields']['below_avatar']))
523
-		foreach ($message['custom_fields']['below_avatar'] as $custom)
543
+	if (!empty($message['custom_fields']['below_avatar'])) {
544
+			foreach ($message['custom_fields']['below_avatar'] as $custom)
524 545
 			echo '
525 546
 								<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
547
+	}
526 548
 
527 549
 	// Show the post group icons, but not for guests.
528
-	if (!$message['member']['is_guest'])
529
-		echo '
550
+	if (!$message['member']['is_guest']) {
551
+			echo '
530 552
 								<li class="icons">', $message['member']['group_icons'], '</li>';
553
+	}
531 554
 
532 555
 	// Show the member's primary group (like 'Administrator') if they have one.
533
-	if (!empty($message['member']['group']))
534
-		echo '
556
+	if (!empty($message['member']['group'])) {
557
+			echo '
535 558
 								<li class="membergroup">', $message['member']['group'], '</li>';
559
+	}
536 560
 
537 561
 	// Show the member's custom title, if they have one.
538
-	if (!empty($message['member']['title']))
539
-		echo '
562
+	if (!empty($message['member']['title'])) {
563
+			echo '
540 564
 								<li class="title">', $message['member']['title'], '</li>';
565
+	}
541 566
 
542 567
 	// Don't show these things for guests.
543 568
 	if (!$message['member']['is_guest'])
544 569
 	{
545 570
 
546 571
 		// Show the post group if and only if they have no other group or the option is on, and they are in a post group.
547
-		if ((empty($modSettings['hide_post_group']) || empty($message['member']['group'])) && !empty($message['member']['post_group']))
548
-			echo '
572
+		if ((empty($modSettings['hide_post_group']) || empty($message['member']['group'])) && !empty($message['member']['post_group'])) {
573
+					echo '
549 574
 								<li class="postgroup">', $message['member']['post_group'], '</li>';
575
+		}
550 576
 
551 577
 		// Show how many posts they have made.
552
-		if (!isset($context['disabled_fields']['posts']))
553
-			echo '
578
+		if (!isset($context['disabled_fields']['posts'])) {
579
+					echo '
554 580
 								<li class="postcount">', $txt['member_postcount'], ': ', $message['member']['posts'], '</li>';
581
+		}
555 582
 
556 583
 		// Show their personal text?
557
-		if (!empty($modSettings['show_blurb']) && !empty($message['member']['blurb']))
558
-			echo '
584
+		if (!empty($modSettings['show_blurb']) && !empty($message['member']['blurb'])) {
585
+					echo '
559 586
 								<li class="blurb">', $message['member']['blurb'], '</li>';
587
+		}
560 588
 
561 589
 		// Any custom fields to show as icons?
562 590
 		if (!empty($message['custom_fields']['icons']))
@@ -565,9 +593,10 @@  discard block
 block discarded – undo
565 593
 								<li class="im_icons">
566 594
 									<ol>';
567 595
 
568
-			foreach ($message['custom_fields']['icons'] as $custom)
569
-				echo '
596
+			foreach ($message['custom_fields']['icons'] as $custom) {
597
+							echo '
570 598
 										<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
599
+			}
571 600
 
572 601
 			echo '
573 602
 									</ol>
@@ -582,19 +611,22 @@  discard block
 block discarded – undo
582 611
 									<ol class="profile_icons">';
583 612
 
584 613
 			// Don't show an icon if they haven't specified a website.
585
-			if (!empty($message['member']['website']['url']) && !isset($context['disabled_fields']['website']))
586
-				echo '
614
+			if (!empty($message['member']['website']['url']) && !isset($context['disabled_fields']['website'])) {
615
+							echo '
587 616
 										<li><a href="', $message['member']['website']['url'], '" title="' . $message['member']['website']['title'] . '" target="_blank" class="new_win">', ($settings['use_image_buttons'] ? '<span class="generic_icons www centericon" title="' . $message['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>';
617
+			}
588 618
 
589 619
 			// Since we know this person isn't a guest, you *can* message them.
590
-			if ($context['can_send_pm'])
591
-				echo '
620
+			if ($context['can_send_pm']) {
621
+							echo '
592 622
 										<li><a href="', $scripturl, '?action=pm;sa=send;u=', $message['member']['id'], '" title="', $message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline'], '">', $settings['use_image_buttons'] ? '<span class="generic_icons im_' . ($message['member']['online']['is_online'] ? 'on' : 'off') . ' centericon" title="' . ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']) . '"></span> ' : ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']), '</a></li>';
623
+			}
593 624
 
594 625
 			// Show the email if necessary
595
-			if (!empty($message['member']['email']) && $message['member']['show_email'])
596
-				echo '
626
+			if (!empty($message['member']['email']) && $message['member']['show_email']) {
627
+							echo '
597 628
 										<li class="email"><a href="mailto:' . $message['member']['email'] . '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>';
629
+			}
598 630
 
599 631
 				echo '
600 632
 									</ol>
@@ -602,48 +634,56 @@  discard block
 block discarded – undo
602 634
 		}
603 635
 
604 636
 		// Any custom fields for standard placement?
605
-		if (!empty($message['custom_fields']['standard']))
606
-			foreach ($message['custom_fields']['standard'] as $custom)
637
+		if (!empty($message['custom_fields']['standard'])) {
638
+					foreach ($message['custom_fields']['standard'] as $custom)
607 639
 				echo '
608 640
 								<li class="custom ', $custom['col_name'], '">', $custom['title'], ': ', $custom['value'], '</li>';
641
+		}
609 642
 
610 643
 	}
611 644
 	// Otherwise, show the guest's email.
612
-	elseif (!empty($message['member']['email']) && $message['member']['show_email'])
613
-		echo '
645
+	elseif (!empty($message['member']['email']) && $message['member']['show_email']) {
646
+			echo '
614 647
 								<li class="email"><a href="mailto:' . $message['member']['email'] . '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>';
648
+	}
615 649
 
616 650
 	// Show the IP to this user for this post - because you can moderate?
617
-	if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip']))
618
-		echo '
651
+	if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) {
652
+			echo '
619 653
 								<li class="poster_ip"><a href="', $scripturl, '?action=', !empty($message['member']['is_guest']) ? 'trackip' : 'profile;area=tracking;sa=ip;u=' . $message['member']['id'], ';searchip=', $message['member']['ip'], '">', $message['member']['ip'], '</a> <a href="', $scripturl, '?action=helpadmin;help=see_admin_ip" onclick="return reqOverlayDiv(this.href);" class="help">(?)</a></li>';
654
+	}
620 655
 
621 656
 	// Or, should we show it because this is you?
622
-	elseif ($message['can_see_ip'])
623
-		echo '
657
+	elseif ($message['can_see_ip']) {
658
+			echo '
624 659
 								<li class="poster_ip"><a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $message['member']['ip'], '</a></li>';
660
+	}
625 661
 
626 662
 	// Okay, are you at least logged in? Then we can show something about why IPs are logged...
627
-	elseif (!$context['user']['is_guest'])
628
-		echo '
663
+	elseif (!$context['user']['is_guest']) {
664
+			echo '
629 665
 								<li class="poster_ip"><a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $txt['logged'], '</a></li>';
666
+	}
630 667
 
631 668
 	// Otherwise, you see NOTHING!
632
-	else
633
-		echo '
669
+	else {
670
+			echo '
634 671
 								<li class="poster_ip">', $txt['logged'], '</li>';
672
+	}
635 673
 
636 674
 	// Are we showing the warning status?
637 675
 	// Don't show these things for guests.
638
-	if (!$message['member']['is_guest'] && $message['member']['can_see_warning'])
639
-		echo '
676
+	if (!$message['member']['is_guest'] && $message['member']['can_see_warning']) {
677
+			echo '
640 678
 								<li class="warning">', $context['can_issue_warning'] ? '<a href="' . $scripturl . '?action=profile;area=issuewarning;u=' . $message['member']['id'] . '">' : '', '<span class="generic_icons warning_', $message['member']['warning_status'], '"></span> ', $context['can_issue_warning'] ? '</a>' : '', '<span class="warn_', $message['member']['warning_status'], '">', $txt['warn_' . $message['member']['warning_status']], '</span></li>';
679
+	}
641 680
 
642 681
 	// Are there any custom fields to show at the bottom of the poster info?
643
-	if (!empty($message['custom_fields']['bottom_poster']))
644
-		foreach ($message['custom_fields']['bottom_poster'] as $custom)
682
+	if (!empty($message['custom_fields']['bottom_poster'])) {
683
+			foreach ($message['custom_fields']['bottom_poster'] as $custom)
645 684
 			echo '
646 685
 									<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
686
+	}
647 687
 
648 688
 	// Poster info ends.
649 689
 	echo '
@@ -672,9 +712,10 @@  discard block
 block discarded – undo
672 712
 	echo '
673 713
 									<span class="smalltext modified floatright', !empty($modSettings['show_modify']) && !empty($message['modified']['name']) ? ' mvisible' : '','" id="modified_', $message['id'], '">';
674 714
 
675
-	if (!empty($modSettings['show_modify']) && !empty($message['modified']['name']))
676
-		echo
715
+	if (!empty($modSettings['show_modify']) && !empty($message['modified']['name'])) {
716
+			echo
677 717
 										$message['modified']['last_edit_text'];
718
+	}
678 719
 
679 720
 	echo '
680 721
 									</span>
@@ -683,22 +724,24 @@  discard block
 block discarded – undo
683 724
 							</div>';
684 725
 
685 726
 	// Ignoring this user? Hide the post.
686
-	if ($ignoring)
687
-		echo '
727
+	if ($ignoring) {
728
+			echo '
688 729
 							<div id="msg_', $message['id'], '_ignored_prompt">
689 730
 								', $txt['ignoring_user'], '
690 731
 								<a href="#" id="msg_', $message['id'], '_ignored_link" style="display: none;">', $txt['show_ignore_user_post'], '</a>
691 732
 							</div>';
733
+	}
692 734
 
693 735
 	// Show the post itself, finally!
694 736
 	echo '
695 737
 							<div class="post">';
696 738
 
697
-	if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id'])
698
-		echo '
739
+	if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id']) {
740
+			echo '
699 741
 								<div class="approve_post">
700 742
 									', $txt['post_awaiting_approval'], '
701 743
 								</div>';
744
+	}
702 745
 	echo '
703 746
 								<div class="inner" data-msgid="', $message['id'], '" id="msg_', $message['id'], '"', $ignoring ? ' style="display:none;"' : '', '>', $message['body'], '</div>
704 747
 							</div>';
@@ -715,9 +758,9 @@  discard block
 block discarded – undo
715 758
 		foreach ($message['attachment'] as $attachment)
716 759
 		{
717 760
 			// Do we want this attachment to not be showed here?
718
-			if (!empty($modSettings['dont_show_attach_under_post']) && !empty($context['show_attach_under_post'][$attachment['id']]))
719
-				continue;
720
-			elseif (!$div_output)
761
+			if (!empty($modSettings['dont_show_attach_under_post']) && !empty($context['show_attach_under_post'][$attachment['id']])) {
762
+							continue;
763
+			} elseif (!$div_output)
721 764
 			{
722 765
 				$div_output = true;
723 766
 
@@ -733,9 +776,10 @@  discard block
 block discarded – undo
733 776
 								<fieldset>
734 777
 									<legend>', $txt['attach_awaiting_approve'];
735 778
 
736
-				if ($context['can_approve'])
737
-					echo '
779
+				if ($context['can_approve']) {
780
+									echo '
738 781
 										&nbsp;[<a href="', $scripturl, '?action=attachapprove;sa=all;mid=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve_all'], '</a>]';
782
+				}
739 783
 
740 784
 				echo '
741 785
 									</legend>';
@@ -749,12 +793,13 @@  discard block
 block discarded – undo
749 793
 				echo '
750 794
 										<div class="attachments_top">';
751 795
 
752
-				if ($attachment['thumbnail']['has_thumb'])
753
-					echo '
796
+				if ($attachment['thumbnail']['has_thumb']) {
797
+									echo '
754 798
 											<a href="', $attachment['href'], ';image" id="link_', $attachment['id'], '" onclick="', $attachment['thumbnail']['javascript'], '"><img src="', $attachment['thumbnail']['href'], '" alt="" id="thumb_', $attachment['id'], '" class="atc_img"></a>';
755
-				else
756
-					echo '
799
+				} else {
800
+									echo '
757 801
 											<img src="' . $attachment['href'] . ';image" alt="" width="' . $attachment['width'] . '" height="' . $attachment['height'] . '" class="atc_img">';
802
+				}
758 803
 
759 804
 				echo '
760 805
 										</div>';
@@ -764,9 +809,10 @@  discard block
 block discarded – undo
764 809
 										<div class="attachments_bot">
765 810
 											<a href="' . $attachment['href'] . '"><img src="' . $settings['images_url'] . '/icons/clip.png" class="centericon" alt="*">&nbsp;' . $attachment['name'] . '</a> ';
766 811
 
767
-			if (!$attachment['is_approved'] && $context['can_approve'])
768
-				echo '
812
+			if (!$attachment['is_approved'] && $context['can_approve']) {
813
+							echo '
769 814
 											[<a href="', $scripturl, '?action=attachapprove;sa=approve;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve'], '</a>]&nbsp;|&nbsp;[<a href="', $scripturl, '?action=attachapprove;sa=reject;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['delete'], '</a>] ';
815
+			}
770 816
 			echo '
771 817
 											<br>', $attachment['size'], ($attachment['is_image'] ? ', ' . $attachment['real_width'] . 'x' . $attachment['real_height'] . '<br>' . sprintf($txt['attach_viewed'], $attachment['downloads']) : '<br>' . sprintf($txt['attach_downloaded'], $attachment['downloads'])), '
772 818
 										</div>';
@@ -775,33 +821,38 @@  discard block
 block discarded – undo
775 821
 									</div>';
776 822
 
777 823
 			// Next attachment line ?
778
-			if (++$i % $attachments_per_line === 0)
779
-				echo '
824
+			if (++$i % $attachments_per_line === 0) {
825
+							echo '
780 826
 									<br>';
827
+			}
781 828
 		}
782 829
 
783 830
 		// If we had unapproved attachments clean up.
784
-		if ($last_approved_state == 0)
785
-			echo '
831
+		if ($last_approved_state == 0) {
832
+					echo '
786 833
 								</fieldset>';
834
+		}
787 835
 
788 836
 		// Only do this if we output a div above - otherwise it'll break things
789
-		if ($div_output)
790
-			echo '
837
+		if ($div_output) {
838
+					echo '
791 839
 							</div>';
840
+		}
792 841
 	}
793 842
 
794 843
 	// And stuff below the attachments.
795
-	if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote'])
796
-	echo '
844
+	if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) {
845
+		echo '
797 846
 							<div class="under_message">';
847
+	}
798 848
 
799 849
 	// Maybe they want to report this post to the moderator(s)?
800
-	if ($context['can_report_moderator'])
801
-		echo '
850
+	if ($context['can_report_moderator']) {
851
+			echo '
802 852
 								<ul class="floatright smalltext">
803 853
 									<li class="report_link"><a href="', $scripturl, '?action=reporttm;topic=', $context['current_topic'], '.', $message['counter'], ';msg=', $message['id'], '">', $txt['report_to_mod'], '</a></li>
804 854
 								</ul>';
855
+	}
805 856
 
806 857
 	// What about likes?
807 858
 	if (!empty($modSettings['enable_likes']))
@@ -842,78 +893,91 @@  discard block
 block discarded – undo
842 893
 								<ul class="quickbuttons">';
843 894
 
844 895
 		// Can they quote? if so they can select and quote as well!
845
-		if ($context['can_quote'])
846
-			echo '
896
+		if ($context['can_quote']) {
897
+					echo '
847 898
 									<li><a href="', $scripturl, '?action=post;quote=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], ';last_msg=', $context['topic_last_message'], '" onclick="return oQuickReply.quote(', $message['id'], ');"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>
848 899
 									<li style="display:none;" id="quoteSelected_', $message['id'], '"><a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'], '</a></li>';
900
+		}
849 901
 
850 902
 		// Can the user modify the contents of this post? Show the modify inline image.
851
-		if ($message['can_modify'])
852
-			echo '
903
+		if ($message['can_modify']) {
904
+					echo '
853 905
 									<li class="quick_edit"><a title="', $txt['modify_msg'], '" class="modifybutton" id="modify_button_', $message['id'], '" onclick="oQuickModify.modifyMsg(\'', $message['id'], '\', \'', !empty($modSettings['toggle_subject']), '\')"><span class="generic_icons quick_edit_button"></span>', $txt['quick_edit'], '</a></li>';
906
+		}
854 907
 
855
-		if ($message['can_approve'] || $message['can_unapprove'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'])
856
-			echo '
908
+		if ($message['can_approve'] || $message['can_unapprove'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) {
909
+					echo '
857 910
 									<li class="post_options">', $txt['post_options'];
911
+		}
858 912
 
859 913
 		echo '
860 914
 										<ul>';
861 915
 
862 916
 		// Can the user modify the contents of this post?
863
-		if ($message['can_modify'])
864
-			echo '
917
+		if ($message['can_modify']) {
918
+					echo '
865 919
 											<li><a href="', $scripturl, '?action=post;msg=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], '"><span class="generic_icons modify_button"></span>', $txt['modify'], '</a></li>';
920
+		}
866 921
 
867 922
 		// How about... even... remove it entirely?!
868
-		if ($context['can_delete'] && ($context['topic_first_message'] == $message['id']))
869
-			echo '
923
+		if ($context['can_delete'] && ($context['topic_first_message'] == $message['id'])) {
924
+					echo '
870 925
 											<li><a href="', $scripturl, '?action=removetopic2;topic=', $context['current_topic'], '.', $context['start'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['are_sure_remove_topic'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove_topic'], '</a></li>';
871
-		elseif ($message['can_remove'] && ($context['topic_first_message'] != $message['id']))
872
-			echo '
926
+		} elseif ($message['can_remove'] && ($context['topic_first_message'] != $message['id'])) {
927
+					echo '
873 928
 											<li><a href="', $scripturl, '?action=deletemsg;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message_question'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>';
929
+		}
874 930
 
875 931
 		// What about splitting it off the rest of the topic?
876
-		if ($context['can_split'] && !empty($context['real_num_replies']))
877
-			echo '
932
+		if ($context['can_split'] && !empty($context['real_num_replies'])) {
933
+					echo '
878 934
 											<li><a href="', $scripturl, '?action=splittopics;topic=', $context['current_topic'], '.0;at=', $message['id'], '"><span class="generic_icons split_button"></span>', $txt['split'], '</a></li>';
935
+		}
879 936
 
880 937
 		// Can we issue a warning because of this post? Remember, we can't give guests warnings.
881
-		if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest'])
882
-			echo '
938
+		if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest']) {
939
+					echo '
883 940
 											<li><a href="', $scripturl, '?action=profile;area=issuewarning;u=', $message['member']['id'], ';msg=', $message['id'], '"><span class="generic_icons warn_button"></span>', $txt['issue_warning'], '</a></li>';
941
+		}
884 942
 
885 943
 		// Can we restore topics?
886
-		if ($context['can_restore_msg'])
887
-			echo '
944
+		if ($context['can_restore_msg']) {
945
+					echo '
888 946
 											<li><a href="', $scripturl, '?action=restoretopic;msgs=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons restore_button"></span>', $txt['restore_message'], '</a></li>';
947
+		}
889 948
 
890 949
 		// Maybe we can approve it, maybe we should?
891
-		if ($message['can_approve'])
892
-			echo '
950
+		if ($message['can_approve']) {
951
+					echo '
893 952
 											<li><a href="', $scripturl, '?action=moderate;area=postmod;sa=approve;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons approve_button"></span>', $txt['approve'], '</a></li>';
953
+		}
894 954
 
895 955
 		// Maybe we can unapprove it?
896
-		if ($message['can_unapprove'])
897
-			echo '
956
+		if ($message['can_unapprove']) {
957
+					echo '
898 958
 											<li><a href="', $scripturl, '?action=moderate;area=postmod;sa=approve;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons unapprove_button"></span>', $txt['unapprove'], '</a></li>';
959
+		}
899 960
 
900 961
 		echo '
901 962
 										</ul>
902 963
 									</li>';
903 964
 
904 965
 		// Show a checkbox for quick moderation?
905
-		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove'])
906
-			echo '
966
+		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove']) {
967
+					echo '
907 968
 									<li style="display: none;" id="in_topic_mod_check_', $message['id'], '"></li>';
969
+		}
908 970
 
909
-		if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'])
910
-			echo '
971
+		if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) {
972
+					echo '
911 973
 								</ul>';
974
+		}
912 975
 	}
913 976
 
914
-	if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote'])
915
-	echo '
977
+	if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) {
978
+		echo '
916 979
 							</div>';
980
+	}
917 981
 
918 982
 	echo '
919 983
 						</div>
@@ -926,9 +990,10 @@  discard block
 block discarded – undo
926 990
 							<div class="custom_fields_above_signature">
927 991
 								<ul class="nolist">';
928 992
 
929
-		foreach ($message['custom_fields']['above_signature'] as $custom)
930
-			echo '
993
+		foreach ($message['custom_fields']['above_signature'] as $custom) {
994
+					echo '
931 995
 									<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
996
+		}
932 997
 
933 998
 		echo '
934 999
 								</ul>
@@ -936,9 +1001,10 @@  discard block
 block discarded – undo
936 1001
 	}
937 1002
 
938 1003
 	// Show the member's signature?
939
-	if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled'])
940
-		echo '
1004
+	if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) {
1005
+			echo '
941 1006
 							<div class="signature" id="msg_', $message['id'], '_signature"', $ignoring ? ' style="display:none;"' : '', '>', $message['member']['signature'], '</div>';
1007
+	}
942 1008
 
943 1009
 
944 1010
 	// Are there any custom profile fields for below the signature?
@@ -948,9 +1014,10 @@  discard block
 block discarded – undo
948 1014
 							<div class="custom_fields_below_signature">
949 1015
 								<ul class="nolist">';
950 1016
 
951
-		foreach ($message['custom_fields']['below_signature'] as $custom)
952
-			echo '
1017
+		foreach ($message['custom_fields']['below_signature'] as $custom) {
1018
+					echo '
953 1019
 									<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
1020
+		}
954 1021
 
955 1022
 		echo '
956 1023
 								</ul>
@@ -998,8 +1065,8 @@  discard block
 block discarded – undo
998 1065
 						<input type="hidden" name="seqnum" value="', $context['form_sequence_number'], '">';
999 1066
 
1000 1067
 		// Guests just need more.
1001
-		if ($context['user']['is_guest'])
1002
-			echo '
1068
+		if ($context['user']['is_guest']) {
1069
+					echo '
1003 1070
 						<dl id="post_header">
1004 1071
 							<dt>
1005 1072
 								', $txt['name'], ':
@@ -1014,6 +1081,7 @@  discard block
 block discarded – undo
1014 1081
 								<input type="email" name="email" size="25" value="', $context['email'], '" tabindex="', $context['tabindex']++, '" class="input_text" required>
1015 1082
 							</dd>
1016 1083
 						</dl>';
1084
+		}
1017 1085
 
1018 1086
 		echo '
1019 1087
 						', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message'), '
@@ -1061,8 +1129,8 @@  discard block
 block discarded – undo
1061 1129
 		<br class="clear">';
1062 1130
 
1063 1131
 	// draft autosave available and the user has it enabled?
1064
-	if (!empty($context['drafts_autosave']))
1065
-		echo '
1132
+	if (!empty($context['drafts_autosave'])) {
1133
+			echo '
1066 1134
 			<script>
1067 1135
 				var oDraftAutoSave = new smf_DraftAutoSave({
1068 1136
 					sSelf: \'oDraftAutoSave\',
@@ -1074,10 +1142,12 @@  discard block
 block discarded – undo
1074 1142
 					iFreq: ', (empty($modSettings['masterAutoSaveDraftsDelay']) ? 60000 : $modSettings['masterAutoSaveDraftsDelay'] * 1000), '
1075 1143
 				});
1076 1144
 			</script>';
1145
+	}
1077 1146
 
1078
-	if ($context['show_spellchecking'])
1079
-		echo '
1147
+	if ($context['show_spellchecking']) {
1148
+			echo '
1080 1149
 			<form action="', $scripturl, '?action=spellcheck" method="post" accept-charset="', $context['character_set'], '" name="spell_form" id="spell_form" target="spellWindow"><input type="hidden" name="spellstring" value=""></form>';
1150
+	}
1081 1151
 
1082 1152
 	echo '
1083 1153
 				<script>
Please login to merge, or discard this patch.