Completed
Pull Request — release-2.1 (#3835)
by Martyn
09:20
created
cache/index.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,8 @@
 block discarded – undo
12 12
 	header('Location: ' . $boardurl);
13 13
 }
14 14
 // Can't find it... just forget it.
15
-else
15
+else {
16 16
 	exit;
17
+}
17 18
 
18 19
 ?>
19 20
\ No newline at end of file
Please login to merge, or discard this patch.
attachments/index.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,8 @@
 block discarded – undo
12 12
 	header('Location: ' . $boardurl);
13 13
 }
14 14
 // Can't find it... just forget it.
15
-else
15
+else {
16 16
 	exit;
17
+}
17 18
 
18 19
 ?>
19 20
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/Subs-Editor.php 1 patch
Braces   +402 added lines, -303 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 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
  * !!!Compatibility!!!
@@ -30,8 +31,9 @@  discard block
 block discarded – undo
30 31
 {
31 32
 	global $modSettings;
32 33
 
33
-	if (!$compat_mode)
34
-		return $text;
34
+	if (!$compat_mode) {
35
+			return $text;
36
+	}
35 37
 
36 38
 	// Turn line breaks back into br's.
37 39
 	$text = strtr($text, array("\r" => '', "\n" => '<br>'));
@@ -48,8 +50,9 @@  discard block
 block discarded – undo
48 50
 			for ($i = 0, $n = count($parts); $i < $n; $i++)
49 51
 			{
50 52
 				// Value of 2 means we're inside the tag.
51
-				if ($i % 4 == 2)
52
-					$parts[$i] = strtr($parts[$i], array('[' => '&#91;', ']' => '&#93;', "'" => "'"));
53
+				if ($i % 4 == 2) {
54
+									$parts[$i] = strtr($parts[$i], array('[' => '&#91;', ']' => '&#93;', "'" => "'"));
55
+				}
53 56
 			}
54 57
 			// Put our humpty dumpty message back together again.
55 58
 			$text = implode('', $parts);
@@ -107,8 +110,9 @@  discard block
 block discarded – undo
107 110
 	$text = preg_replace('~</p>\s*(?!<)~i', '</p><br>', $text);
108 111
 
109 112
 	// Safari/webkit wraps lines in Wysiwyg in <div>'s.
110
-	if (isBrowser('webkit'))
111
-		$text = preg_replace(array('~<div(?:\s(?:[^<>]*?))?' . '>~i', '</div>'), array('<br>', ''), $text);
113
+	if (isBrowser('webkit')) {
114
+			$text = preg_replace(array('~<div(?:\s(?:[^<>]*?))?' . '>~i', '</div>'), array('<br>', ''), $text);
115
+	}
112 116
 
113 117
 	// If there's a trailing break get rid of it - Firefox tends to add one.
114 118
 	$text = preg_replace('~<br\s?/?' . '>$~i', '', $text);
@@ -123,8 +127,9 @@  discard block
 block discarded – undo
123 127
 		for ($i = 0, $n = count($parts); $i < $n; $i++)
124 128
 		{
125 129
 			// Value of 2 means we're inside the tag.
126
-			if ($i % 4 == 2)
127
-				$parts[$i] = strip_tags($parts[$i]);
130
+			if ($i % 4 == 2) {
131
+							$parts[$i] = strip_tags($parts[$i]);
132
+			}
128 133
 		}
129 134
 
130 135
 		$text = strtr(implode('', $parts), array('#smf_br_spec_grudge_cool!#' => '<br>'));
@@ -150,18 +155,19 @@  discard block
 block discarded – undo
150 155
 			{
151 156
 				$found = array_search($file, $smileysto);
152 157
 				// Note the weirdness here is to stop double spaces between smileys.
153
-				if ($found)
154
-					$matches[1][$k] = '-[]-smf_smily_start#|#' . $smcFunc['htmlspecialchars']($smileysfrom[$found]) . '-[]-smf_smily_end#|#';
155
-				else
156
-					$matches[1][$k] = '';
158
+				if ($found) {
159
+									$matches[1][$k] = '-[]-smf_smily_start#|#' . $smcFunc['htmlspecialchars']($smileysfrom[$found]) . '-[]-smf_smily_end#|#';
160
+				} else {
161
+									$matches[1][$k] = '';
162
+				}
157 163
 			}
158
-		}
159
-		else
164
+		} else
160 165
 		{
161 166
 			// Load all the smileys.
162 167
 			$names = array();
163
-			foreach ($matches[1] as $file)
164
-				$names[] = $file;
168
+			foreach ($matches[1] as $file) {
169
+							$names[] = $file;
170
+			}
165 171
 			$names = array_unique($names);
166 172
 
167 173
 			if (!empty($names))
@@ -175,13 +181,15 @@  discard block
 block discarded – undo
175 181
 					)
176 182
 				);
177 183
 				$mappings = array();
178
-				while ($row = $smcFunc['db_fetch_assoc']($request))
179
-					$mappings[$row['filename']] = $smcFunc['htmlspecialchars']($row['code']);
184
+				while ($row = $smcFunc['db_fetch_assoc']($request)) {
185
+									$mappings[$row['filename']] = $smcFunc['htmlspecialchars']($row['code']);
186
+				}
180 187
 				$smcFunc['db_free_result']($request);
181 188
 
182
-				foreach ($matches[1] as $k => $file)
183
-					if (isset($mappings[$file]))
189
+				foreach ($matches[1] as $k => $file) {
190
+									if (isset($mappings[$file]))
184 191
 						$matches[1][$k] = '-[]-smf_smily_start#|#' . $mappings[$file] . '-[]-smf_smily_end#|#';
192
+				}
185 193
 			}
186 194
 		}
187 195
 
@@ -193,8 +201,9 @@  discard block
 block discarded – undo
193 201
 	}
194 202
 
195 203
 	// Only try to buy more time if the client didn't quit.
196
-	if (connection_aborted() && $context['server']['is_apache'])
197
-		@apache_reset_timeout();
204
+	if (connection_aborted() && $context['server']['is_apache']) {
205
+			@apache_reset_timeout();
206
+	}
198 207
 
199 208
 	$parts = preg_split('~(<[A-Za-z]+\s*[^<>]*?style="?[^<>"]+"?[^<>]*?(?:/?)>|</[A-Za-z]+>)~', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
200 209
 	$replacement = '';
@@ -205,9 +214,9 @@  discard block
 block discarded – undo
205 214
 		if (preg_match('~(<([A-Za-z]+)\s*[^<>]*?)style="?([^<>"]+)"?([^<>]*?(/?)>)~', $part, $matches) === 1)
206 215
 		{
207 216
 			// If it's being closed instantly, we can't deal with it...yet.
208
-			if ($matches[5] === '/')
209
-				continue;
210
-			else
217
+			if ($matches[5] === '/') {
218
+							continue;
219
+			} else
211 220
 			{
212 221
 				// Get an array of styles that apply to this element. (The strtr is there to combat HTML generated by Word.)
213 222
 				$styles = explode(';', strtr($matches[3], array('&quot;' => '')));
@@ -223,8 +232,9 @@  discard block
 block discarded – undo
223 232
 					$clean_type_value_pair = strtolower(strtr(trim($type_value_pair), '=', ':'));
224 233
 
225 234
 					// Something like 'font-weight: bold' is expected here.
226
-					if (strpos($clean_type_value_pair, ':') === false)
227
-						continue;
235
+					if (strpos($clean_type_value_pair, ':') === false) {
236
+											continue;
237
+					}
228 238
 
229 239
 					// Capture the elements of a single style item (e.g. 'font-weight' and 'bold').
230 240
 					list ($style_type, $style_value) = explode(':', $type_value_pair);
@@ -246,8 +256,7 @@  discard block
 block discarded – undo
246 256
 							{
247 257
 								$curCloseTags .= '[/u]';
248 258
 								$replacement .= '[u]';
249
-							}
250
-							elseif ($style_value == 'line-through')
259
+							} elseif ($style_value == 'line-through')
251 260
 							{
252 261
 								$curCloseTags .= '[/s]';
253 262
 								$replacement .= '[s]';
@@ -259,13 +268,11 @@  discard block
 block discarded – undo
259 268
 							{
260 269
 								$curCloseTags .= '[/left]';
261 270
 								$replacement .= '[left]';
262
-							}
263
-							elseif ($style_value == 'center')
271
+							} elseif ($style_value == 'center')
264 272
 							{
265 273
 								$curCloseTags .= '[/center]';
266 274
 								$replacement .= '[center]';
267
-							}
268
-							elseif ($style_value == 'right')
275
+							} elseif ($style_value == 'right')
269 276
 							{
270 277
 								$curCloseTags .= '[/right]';
271 278
 								$replacement .= '[right]';
@@ -287,8 +294,9 @@  discard block
 block discarded – undo
287 294
 
288 295
 						case 'font-size':
289 296
 							// Sometimes people put decimals where decimals should not be.
290
-							if (preg_match('~(\d)+\.\d+(p[xt])~i', $style_value, $dec_matches) === 1)
291
-								$style_value = $dec_matches[1] . $dec_matches[2];
297
+							if (preg_match('~(\d)+\.\d+(p[xt])~i', $style_value, $dec_matches) === 1) {
298
+															$style_value = $dec_matches[1] . $dec_matches[2];
299
+							}
292 300
 
293 301
 							$curCloseTags .= '[/size]';
294 302
 							$replacement .= '[size=' . $style_value . ']';
@@ -296,8 +304,9 @@  discard block
 block discarded – undo
296 304
 
297 305
 						case 'font-family':
298 306
 							// Only get the first freaking font if there's a list!
299
-							if (strpos($style_value, ',') !== false)
300
-								$style_value = substr($style_value, 0, strpos($style_value, ','));
307
+							if (strpos($style_value, ',') !== false) {
308
+															$style_value = substr($style_value, 0, strpos($style_value, ','));
309
+							}
301 310
 
302 311
 							$curCloseTags .= '[/font]';
303 312
 							$replacement .= '[font=' . strtr($style_value, array("'" => '')) . ']';
@@ -306,13 +315,15 @@  discard block
 block discarded – undo
306 315
 						// This is a hack for images with dimensions embedded.
307 316
 						case 'width':
308 317
 						case 'height':
309
-							if (preg_match('~[1-9]\d*~i', $style_value, $dimension) === 1)
310
-								$extra_attr .= ' ' . $style_type . '="' . $dimension[0] . '"';
318
+							if (preg_match('~[1-9]\d*~i', $style_value, $dimension) === 1) {
319
+															$extra_attr .= ' ' . $style_type . '="' . $dimension[0] . '"';
320
+							}
311 321
 						break;
312 322
 
313 323
 						case 'list-style-type':
314
-							if (preg_match('~none|disc|circle|square|decimal|decimal-leading-zero|lower-roman|upper-roman|lower-alpha|upper-alpha|lower-greek|lower-latin|upper-latin|hebrew|armenian|georgian|cjk-ideographic|hiragana|katakana|hiragana-iroha|katakana-iroha~i', $style_value, $listType) === 1)
315
-								$extra_attr .= ' listtype="' . $listType[0] . '"';
324
+							if (preg_match('~none|disc|circle|square|decimal|decimal-leading-zero|lower-roman|upper-roman|lower-alpha|upper-alpha|lower-greek|lower-latin|upper-latin|hebrew|armenian|georgian|cjk-ideographic|hiragana|katakana|hiragana-iroha|katakana-iroha~i', $style_value, $listType) === 1) {
325
+															$extra_attr .= ' listtype="' . $listType[0] . '"';
326
+							}
316 327
 						break;
317 328
 					}
318 329
 				}
@@ -325,18 +336,17 @@  discard block
 block discarded – undo
325 336
 				}
326 337
 
327 338
 				// If there's something that still needs closing, push it to the stack.
328
-				if (!empty($curCloseTags))
329
-					array_push($stack, array(
339
+				if (!empty($curCloseTags)) {
340
+									array_push($stack, array(
330 341
 							'element' => strtolower($curElement),
331 342
 							'closeTags' => $curCloseTags
332 343
 						)
333 344
 					);
334
-				elseif (!empty($extra_attr))
335
-					$replacement .= $precedingStyle . $extra_attr . $afterStyle;
345
+				} elseif (!empty($extra_attr)) {
346
+									$replacement .= $precedingStyle . $extra_attr . $afterStyle;
347
+				}
336 348
 			}
337
-		}
338
-
339
-		elseif (preg_match('~</([A-Za-z]+)>~', $part, $matches) === 1)
349
+		} elseif (preg_match('~</([A-Za-z]+)>~', $part, $matches) === 1)
340 350
 		{
341 351
 			// Is this the element that we've been waiting for to be closed?
342 352
 			if (!empty($stack) && strtolower($matches[1]) === $stack[count($stack) - 1]['element'])
@@ -346,28 +356,32 @@  discard block
 block discarded – undo
346 356
 			}
347 357
 
348 358
 			// Must've been something else.
349
-			else
350
-				$replacement .= $part;
359
+			else {
360
+							$replacement .= $part;
361
+			}
351 362
 		}
352 363
 		// In all other cases, just add the part to the replacement.
353
-		else
354
-			$replacement .= $part;
364
+		else {
365
+					$replacement .= $part;
366
+		}
355 367
 	}
356 368
 
357 369
 	// Now put back the replacement in the text.
358 370
 	$text = $replacement;
359 371
 
360 372
 	// We are not finished yet, request more time.
361
-	if (connection_aborted() && $context['server']['is_apache'])
362
-		@apache_reset_timeout();
373
+	if (connection_aborted() && $context['server']['is_apache']) {
374
+			@apache_reset_timeout();
375
+	}
363 376
 
364 377
 	// Let's pull out any legacy alignments.
365 378
 	while (preg_match('~<([A-Za-z]+)\s+[^<>]*?(align="*(left|center|right)"*)[^<>]*?(/?)>~i', $text, $matches) === 1)
366 379
 	{
367 380
 		// Find the position in the text of this tag over again.
368 381
 		$start_pos = strpos($text, $matches[0]);
369
-		if ($start_pos === false)
370
-			break;
382
+		if ($start_pos === false) {
383
+					break;
384
+		}
371 385
 
372 386
 		// End tag?
373 387
 		if ($matches[4] != '/' && strpos($text, '</' . $matches[1] . '>', $start_pos) !== false)
@@ -382,8 +396,7 @@  discard block
 block discarded – undo
382 396
 
383 397
 			// Put the tags back into the body.
384 398
 			$text = substr($text, 0, $start_pos) . $tag . '[' . $matches[3] . ']' . $content . '[/' . $matches[3] . ']' . substr($text, $end_pos);
385
-		}
386
-		else
399
+		} else
387 400
 		{
388 401
 			// Just get rid of this evil tag.
389 402
 			$text = substr($text, 0, $start_pos) . substr($text, $start_pos + strlen($matches[0]));
@@ -396,8 +409,9 @@  discard block
 block discarded – undo
396 409
 		// Find the position of this again.
397 410
 		$start_pos = strpos($text, $matches[0]);
398 411
 		$end_pos = false;
399
-		if ($start_pos === false)
400
-			break;
412
+		if ($start_pos === false) {
413
+					break;
414
+		}
401 415
 
402 416
 		// This must have an end tag - and we must find the right one.
403 417
 		$lower_text = strtolower($text);
@@ -430,8 +444,9 @@  discard block
 block discarded – undo
430 444
 				break;
431 445
 			}
432 446
 		}
433
-		if ($end_pos === false)
434
-			break;
447
+		if ($end_pos === false) {
448
+					break;
449
+		}
435 450
 
436 451
 		// Now work out what the attributes are.
437 452
 		$attribs = fetchTagAttributes($matches[1]);
@@ -445,11 +460,11 @@  discard block
 block discarded – undo
445 460
 				$v = (int) trim($v);
446 461
 				$v = empty($v) ? 1 : $v;
447 462
 				$tags[] = array('[size=' . $sizes_equivalence[$v] . ']', '[/size]');
463
+			} elseif ($s == 'face') {
464
+							$tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]');
465
+			} elseif ($s == 'color') {
466
+							$tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]');
448 467
 			}
449
-			elseif ($s == 'face')
450
-				$tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]');
451
-			elseif ($s == 'color')
452
-				$tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]');
453 468
 		}
454 469
 
455 470
 		// As before add in our tags.
@@ -457,8 +472,9 @@  discard block
 block discarded – undo
457 472
 		foreach ($tags as $tag)
458 473
 		{
459 474
 			$before .= $tag[0];
460
-			if (isset($tag[1]))
461
-				$after = $tag[1] . $after;
475
+			if (isset($tag[1])) {
476
+							$after = $tag[1] . $after;
477
+			}
462 478
 		}
463 479
 
464 480
 		// Remove the tag so it's never checked again.
@@ -469,8 +485,9 @@  discard block
 block discarded – undo
469 485
 	}
470 486
 
471 487
 	// Almost there, just a little more time.
472
-	if (connection_aborted() && $context['server']['is_apache'])
473
-		@apache_reset_timeout();
488
+	if (connection_aborted() && $context['server']['is_apache']) {
489
+			@apache_reset_timeout();
490
+	}
474 491
 
475 492
 	if (count($parts = preg_split('~<(/?)(li|ol|ul)([^>]*)>~i', $text, null, PREG_SPLIT_DELIM_CAPTURE)) > 1)
476 493
 	{
@@ -526,12 +543,13 @@  discard block
 block discarded – undo
526 543
 						{
527 544
 							$inList = true;
528 545
 
529
-							if ($tag === 'ol')
530
-								$listType = 'decimal';
531
-							elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1)
532
-								$listType = $listTypeMapping[$match[1]];
533
-							else
534
-								$listType = null;
546
+							if ($tag === 'ol') {
547
+															$listType = 'decimal';
548
+							} elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1) {
549
+															$listType = $listTypeMapping[$match[1]];
550
+							} else {
551
+															$listType = null;
552
+							}
535 553
 
536 554
 							$listDepth++;
537 555
 
@@ -595,9 +613,7 @@  discard block
 block discarded – undo
595 613
 							$parts[$i + 1] = '';
596 614
 							$parts[$i + 2] = str_repeat("\t", $listDepth) . '[/list]';
597 615
 							$parts[$i + 3] = '';
598
-						}
599
-
600
-						else
616
+						} else
601 617
 						{
602 618
 							// We're in a list item.
603 619
 							if ($listDepth > 0)
@@ -634,9 +650,7 @@  discard block
 block discarded – undo
634 650
 							$parts[$i + 1] = '';
635 651
 							$parts[$i + 2] = '';
636 652
 							$parts[$i + 3] = '';
637
-						}
638
-
639
-						else
653
+						} else
640 654
 						{
641 655
 							// Remove the trailing breaks from the list item.
642 656
 							$parts[$i] = preg_replace('~\s*<br\s*' . '/?' . '>\s*$~', '', $parts[$i]);
@@ -674,8 +688,9 @@  discard block
 block discarded – undo
674 688
 			$text .= str_repeat("\t", $listDepth) . '[/list]';
675 689
 		}
676 690
 
677
-		for ($i = $listDepth; $i > 0; $i--)
678
-			$text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]';
691
+		for ($i = $listDepth; $i > 0; $i--) {
692
+					$text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]';
693
+		}
679 694
 
680 695
 	}
681 696
 
@@ -684,8 +699,9 @@  discard block
 block discarded – undo
684 699
 	{
685 700
 		// Find the position of the image.
686 701
 		$start_pos = strpos($text, $matches[0]);
687
-		if ($start_pos === false)
688
-			break;
702
+		if ($start_pos === false) {
703
+					break;
704
+		}
689 705
 		$end_pos = $start_pos + strlen($matches[0]);
690 706
 
691 707
 		$params = '';
@@ -695,12 +711,13 @@  discard block
 block discarded – undo
695 711
 		$attrs = fetchTagAttributes($matches[1]);
696 712
 		foreach ($attrs as $attrib => $value)
697 713
 		{
698
-			if (in_array($attrib, array('width', 'height')))
699
-				$params .= ' ' . $attrib . '=' . (int) $value;
700
-			elseif ($attrib == 'alt' && trim($value) != '')
701
-				$params .= ' alt=' . trim($value);
702
-			elseif ($attrib == 'src')
703
-				$src = trim($value);
714
+			if (in_array($attrib, array('width', 'height'))) {
715
+							$params .= ' ' . $attrib . '=' . (int) $value;
716
+			} elseif ($attrib == 'alt' && trim($value) != '') {
717
+							$params .= ' alt=' . trim($value);
718
+			} elseif ($attrib == 'src') {
719
+							$src = trim($value);
720
+			}
704 721
 		}
705 722
 
706 723
 		$tag = '';
@@ -711,10 +728,11 @@  discard block
 block discarded – undo
711 728
 			{
712 729
 				$baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']);
713 730
 
714
-				if (substr($src, 0, 1) === '/')
715
-					$src = $baseURL . $src;
716
-				else
717
-					$src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src;
731
+				if (substr($src, 0, 1) === '/') {
732
+									$src = $baseURL . $src;
733
+				} else {
734
+									$src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src;
735
+				}
718 736
 			}
719 737
 
720 738
 			$tag = '[img' . $params . ']' . $src . '[/img]';
@@ -892,20 +910,23 @@  discard block
 block discarded – undo
892 910
 		},
893 911
 	);
894 912
 
895
-	foreach ($tags as $tag => $replace)
896
-		$text = preg_replace_callback($tag, $replace, $text);
913
+	foreach ($tags as $tag => $replace) {
914
+			$text = preg_replace_callback($tag, $replace, $text);
915
+	}
897 916
 
898 917
 	// Please give us just a little more time.
899
-	if (connection_aborted() && $context['server']['is_apache'])
900
-		@apache_reset_timeout();
918
+	if (connection_aborted() && $context['server']['is_apache']) {
919
+			@apache_reset_timeout();
920
+	}
901 921
 
902 922
 	// What about URL's - the pain in the ass of the tag world.
903 923
 	while (preg_match('~<a\s+([^<>]*)>([^<>]*)</a>~i', $text, $matches) === 1)
904 924
 	{
905 925
 		// Find the position of the URL.
906 926
 		$start_pos = strpos($text, $matches[0]);
907
-		if ($start_pos === false)
908
-			break;
927
+		if ($start_pos === false) {
928
+					break;
929
+		}
909 930
 		$end_pos = $start_pos + strlen($matches[0]);
910 931
 
911 932
 		$tag_type = 'url';
@@ -919,8 +940,9 @@  discard block
 block discarded – undo
919 940
 				$href = trim($value);
920 941
 
921 942
 				// Are we dealing with an FTP link?
922
-				if (preg_match('~^ftps?://~', $href) === 1)
923
-					$tag_type = 'ftp';
943
+				if (preg_match('~^ftps?://~', $href) === 1) {
944
+									$tag_type = 'ftp';
945
+				}
924 946
 
925 947
 				// Or is this a link to an email address?
926 948
 				elseif (substr($href, 0, 7) == 'mailto:')
@@ -934,28 +956,31 @@  discard block
 block discarded – undo
934 956
 				{
935 957
 					$baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']);
936 958
 
937
-					if (substr($href, 0, 1) === '/')
938
-						$href = $baseURL . $href;
939
-					else
940
-						$href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href;
959
+					if (substr($href, 0, 1) === '/') {
960
+											$href = $baseURL . $href;
961
+					} else {
962
+											$href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href;
963
+					}
941 964
 				}
942 965
 			}
943 966
 
944 967
 			// External URL?
945 968
 			if ($attrib == 'target' && $tag_type == 'url')
946 969
 			{
947
-				if (trim($value) == '_blank')
948
-					$tag_type == 'iurl';
970
+				if (trim($value) == '_blank') {
971
+									$tag_type == 'iurl';
972
+				}
949 973
 			}
950 974
 		}
951 975
 
952 976
 		$tag = '';
953 977
 		if ($href != '')
954 978
 		{
955
-			if ($matches[2] == $href)
956
-				$tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']';
957
-			else
958
-				$tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']';
979
+			if ($matches[2] == $href) {
980
+							$tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']';
981
+			} else {
982
+							$tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']';
983
+			}
959 984
 		}
960 985
 
961 986
 		// Replace the tag
@@ -995,17 +1020,18 @@  discard block
 block discarded – undo
995 1020
 		// We're either moving from the key to the attribute or we're in a string and this is fine.
996 1021
 		if ($text[$i] == '=')
997 1022
 		{
998
-			if ($tag_state == 0)
999
-				$tag_state = 1;
1000
-			elseif ($tag_state == 2)
1001
-				$value .= '=';
1023
+			if ($tag_state == 0) {
1024
+							$tag_state = 1;
1025
+			} elseif ($tag_state == 2) {
1026
+							$value .= '=';
1027
+			}
1002 1028
 		}
1003 1029
 		// A space is either moving from an attribute back to a potential key or in a string is fine.
1004 1030
 		elseif ($text[$i] == ' ')
1005 1031
 		{
1006
-			if ($tag_state == 2)
1007
-				$value .= ' ';
1008
-			elseif ($tag_state == 1)
1032
+			if ($tag_state == 2) {
1033
+							$value .= ' ';
1034
+			} elseif ($tag_state == 1)
1009 1035
 			{
1010 1036
 				$attribs[$key] = $value;
1011 1037
 				$key = $value = '';
@@ -1016,24 +1042,27 @@  discard block
 block discarded – undo
1016 1042
 		elseif ($text[$i] == '"')
1017 1043
 		{
1018 1044
 			// Must be either going into or out of a string.
1019
-			if ($tag_state == 1)
1020
-				$tag_state = 2;
1021
-			else
1022
-				$tag_state = 1;
1045
+			if ($tag_state == 1) {
1046
+							$tag_state = 2;
1047
+			} else {
1048
+							$tag_state = 1;
1049
+			}
1023 1050
 		}
1024 1051
 		// Otherwise it's fine.
1025 1052
 		else
1026 1053
 		{
1027
-			if ($tag_state == 0)
1028
-				$key .= $text[$i];
1029
-			else
1030
-				$value .= $text[$i];
1054
+			if ($tag_state == 0) {
1055
+							$key .= $text[$i];
1056
+			} else {
1057
+							$value .= $text[$i];
1058
+			}
1031 1059
 		}
1032 1060
 	}
1033 1061
 
1034 1062
 	// Anything left?
1035
-	if ($key != '' && $value != '')
1036
-		$attribs[$key] = $value;
1063
+	if ($key != '' && $value != '') {
1064
+			$attribs[$key] = $value;
1065
+	}
1037 1066
 
1038 1067
 	return $attribs;
1039 1068
 }
@@ -1049,8 +1078,9 @@  discard block
 block discarded – undo
1049 1078
 	global $modSettings;
1050 1079
 
1051 1080
 	// Don't care about the texts that are too short.
1052
-	if (strlen($text) < 3)
1053
-		return $text;
1081
+	if (strlen($text) < 3) {
1082
+			return $text;
1083
+	}
1054 1084
 
1055 1085
 	// We are going to cycle through the BBC and keep track of tags as they arise - in order. If get to a block level tag we're going to make sure it's not in a non-block level tag!
1056 1086
 	// This will keep the order of tags that are open.
@@ -1063,8 +1093,9 @@  discard block
 block discarded – undo
1063 1093
 	$disabled = empty($modSettings['disabledBBC']) ? array() : array_flip(explode(',', strtolower($modSettings['disabledBBC'])));
1064 1094
 
1065 1095
 	// Add flash if it's disabled as embedded tag.
1066
-	if (empty($modSettings['enableEmbeddedFlash']))
1067
-		$disabled['flash'] = true;
1096
+	if (empty($modSettings['enableEmbeddedFlash'])) {
1097
+			$disabled['flash'] = true;
1098
+	}
1068 1099
 
1069 1100
 	// Get a list of all the tags that are not disabled.
1070 1101
 	$all_tags = parse_bbc(false);
@@ -1072,10 +1103,12 @@  discard block
 block discarded – undo
1072 1103
 	$self_closing_tags = array();
1073 1104
 	foreach ($all_tags as $tag)
1074 1105
 	{
1075
-		if (!isset($disabled[$tag['tag']]))
1076
-			$valid_tags[$tag['tag']] = !empty($tag['block_level']);
1077
-		if (isset($tag['type']) && $tag['type'] == 'closed')
1078
-			$self_closing_tags[] = $tag['tag'];
1106
+		if (!isset($disabled[$tag['tag']])) {
1107
+					$valid_tags[$tag['tag']] = !empty($tag['block_level']);
1108
+		}
1109
+		if (isset($tag['type']) && $tag['type'] == 'closed') {
1110
+					$self_closing_tags[] = $tag['tag'];
1111
+		}
1079 1112
 	}
1080 1113
 
1081 1114
 	// Don't worry if we're in a code/nobbc.
@@ -1105,16 +1138,19 @@  discard block
 block discarded – undo
1105 1138
 				$tagName = substr($match, $isClosingTag ? 2 : 1, -1);
1106 1139
 
1107 1140
 				// We're closing the exact same tag that we opened.
1108
-				if ($isClosingTag && $insideTag === $tagName)
1109
-					$insideTag = null;
1141
+				if ($isClosingTag && $insideTag === $tagName) {
1142
+									$insideTag = null;
1143
+				}
1110 1144
 
1111 1145
 				// We're opening a tag and we're not yet inside one either
1112
-				elseif (!$isClosingTag && $insideTag === null)
1113
-					$insideTag = $tagName;
1146
+				elseif (!$isClosingTag && $insideTag === null) {
1147
+									$insideTag = $tagName;
1148
+				}
1114 1149
 
1115 1150
 				// In all other cases, this tag must be invalid
1116
-				else
1117
-					unset($matches[$i]);
1151
+				else {
1152
+									unset($matches[$i]);
1153
+				}
1118 1154
 			}
1119 1155
 
1120 1156
 			// The next one is gonna be the other one.
@@ -1122,8 +1158,9 @@  discard block
 block discarded – undo
1122 1158
 		}
1123 1159
 
1124 1160
 		// We're still inside a tag and had no chance for closure?
1125
-		if ($insideTag !== null)
1126
-			$matches[] = '[/' . $insideTag . ']';
1161
+		if ($insideTag !== null) {
1162
+					$matches[] = '[/' . $insideTag . ']';
1163
+		}
1127 1164
 
1128 1165
 		// And a complete text string again.
1129 1166
 		$text = implode('', $matches);
@@ -1132,8 +1169,9 @@  discard block
 block discarded – undo
1132 1169
 	// Quickly remove any tags which are back to back.
1133 1170
 	$backToBackPattern = '~\\[(' . implode('|', array_diff(array_keys($valid_tags), array('td', 'anchor'))) . ')[^<>\\[\\]]*\\]\s*\\[/\\1\\]~';
1134 1171
 	$lastlen = 0;
1135
-	while (strlen($text) !== $lastlen)
1136
-		$lastlen = strlen($text = preg_replace($backToBackPattern, '', $text));
1172
+	while (strlen($text) !== $lastlen) {
1173
+			$lastlen = strlen($text = preg_replace($backToBackPattern, '', $text));
1174
+	}
1137 1175
 
1138 1176
 	// Need to sort the tags my name length.
1139 1177
 	uksort($valid_tags, 'sort_array_length');
@@ -1177,8 +1215,9 @@  discard block
 block discarded – undo
1177 1215
 			$isCompetingTag = in_array($tag, $competing_tags);
1178 1216
 
1179 1217
 			// Check if this might be one of those cleaned out tags.
1180
-			if ($tag === '')
1181
-				continue;
1218
+			if ($tag === '') {
1219
+							continue;
1220
+			}
1182 1221
 
1183 1222
 			// Special case: inside [code] blocks any code is left untouched.
1184 1223
 			elseif ($tag === 'code')
@@ -1189,8 +1228,9 @@  discard block
 block discarded – undo
1189 1228
 					$inCode = false;
1190 1229
 
1191 1230
 					// Reopen tags that were closed before the code block.
1192
-					if (!empty($inlineElements))
1193
-						$parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']';
1231
+					if (!empty($inlineElements)) {
1232
+											$parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']';
1233
+					}
1194 1234
 				}
1195 1235
 
1196 1236
 				// We're outside a coding and nobbc block and opening it.
@@ -1219,8 +1259,9 @@  discard block
 block discarded – undo
1219 1259
 					$inNoBbc = false;
1220 1260
 
1221 1261
 					// Some inline elements might've been closed that need reopening.
1222
-					if (!empty($inlineElements))
1223
-						$parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']';
1262
+					if (!empty($inlineElements)) {
1263
+											$parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']';
1264
+					}
1224 1265
 				}
1225 1266
 
1226 1267
 				// We're outside a nobbc and coding block and opening it.
@@ -1240,8 +1281,9 @@  discard block
 block discarded – undo
1240 1281
 			}
1241 1282
 
1242 1283
 			// So, we're inside one of the special blocks: ignore any tag.
1243
-			elseif ($inCode || $inNoBbc)
1244
-				continue;
1284
+			elseif ($inCode || $inNoBbc) {
1285
+							continue;
1286
+			}
1245 1287
 
1246 1288
 			// We're dealing with an opening tag.
1247 1289
 			if ($isOpeningTag)
@@ -1282,8 +1324,9 @@  discard block
 block discarded – undo
1282 1324
 							if ($parts[$j + 3] === $tag)
1283 1325
 							{
1284 1326
 								// If it's an opening tag, increase the level.
1285
-								if ($parts[$j + 2] === '')
1286
-									$curLevel++;
1327
+								if ($parts[$j + 2] === '') {
1328
+																	$curLevel++;
1329
+								}
1287 1330
 
1288 1331
 								// A closing tag, decrease the level.
1289 1332
 								else
@@ -1306,13 +1349,15 @@  discard block
 block discarded – undo
1306 1349
 					{
1307 1350
 						if ($isCompetingTag)
1308 1351
 						{
1309
-							if (!isset($competingElements[$tag]))
1310
-								$competingElements[$tag] = array();
1352
+							if (!isset($competingElements[$tag])) {
1353
+															$competingElements[$tag] = array();
1354
+							}
1311 1355
 
1312 1356
 							$competingElements[$tag][] = $parts[$i + 4];
1313 1357
 
1314
-							if (count($competingElements[$tag]) > 1)
1315
-								$parts[$i] .= '[/' . $tag . ']';
1358
+							if (count($competingElements[$tag]) > 1) {
1359
+															$parts[$i] .= '[/' . $tag . ']';
1360
+							}
1316 1361
 						}
1317 1362
 
1318 1363
 						$inlineElements[$elementContent] = $tag;
@@ -1333,15 +1378,17 @@  discard block
 block discarded – undo
1333 1378
 						$addClosingTags = array();
1334 1379
 						while ($element = array_pop($blockElements))
1335 1380
 						{
1336
-							if ($element === $tag)
1337
-								break;
1381
+							if ($element === $tag) {
1382
+															break;
1383
+							}
1338 1384
 
1339 1385
 							// Still a block tag was open not equal to this tag.
1340 1386
 							$addClosingTags[] = $element['type'];
1341 1387
 						}
1342 1388
 
1343
-						if (!empty($addClosingTags))
1344
-							$parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1];
1389
+						if (!empty($addClosingTags)) {
1390
+													$parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1];
1391
+						}
1345 1392
 
1346 1393
 						// Apparently the closing tag was not found on the stack.
1347 1394
 						if (!is_string($element) || $element !== $tag)
@@ -1351,8 +1398,7 @@  discard block
 block discarded – undo
1351 1398
 							$parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = '';
1352 1399
 							continue;
1353 1400
 						}
1354
-					}
1355
-					else
1401
+					} else
1356 1402
 					{
1357 1403
 						// Get rid of this closing tag!
1358 1404
 						$parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = '';
@@ -1381,53 +1427,62 @@  discard block
 block discarded – undo
1381 1427
 							unset($inlineElements[$tagContentToBeClosed]);
1382 1428
 
1383 1429
 							// Was this the tag we were looking for?
1384
-							if ($tagToBeClosed === $tag)
1385
-								break;
1430
+							if ($tagToBeClosed === $tag) {
1431
+															break;
1432
+							}
1386 1433
 
1387 1434
 							// Nope, close it and look further!
1388
-							else
1389
-								$parts[$i] .= '[/' . $tagToBeClosed . ']';
1435
+							else {
1436
+															$parts[$i] .= '[/' . $tagToBeClosed . ']';
1437
+							}
1390 1438
 						}
1391 1439
 
1392 1440
 						if ($isCompetingTag && !empty($competingElements[$tag]))
1393 1441
 						{
1394 1442
 							array_pop($competingElements[$tag]);
1395 1443
 
1396
-							if (count($competingElements[$tag]) > 0)
1397
-								$parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5];
1444
+							if (count($competingElements[$tag]) > 0) {
1445
+															$parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5];
1446
+							}
1398 1447
 						}
1399 1448
 					}
1400 1449
 
1401 1450
 					// Unexpected closing tag, ex-ter-mi-nate.
1402
-					else
1403
-						$parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = '';
1451
+					else {
1452
+											$parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = '';
1453
+					}
1404 1454
 				}
1405 1455
 			}
1406 1456
 		}
1407 1457
 
1408 1458
 		// Close the code tags.
1409
-		if ($inCode)
1410
-			$parts[$i] .= '[/code]';
1459
+		if ($inCode) {
1460
+					$parts[$i] .= '[/code]';
1461
+		}
1411 1462
 
1412 1463
 		// The same for nobbc tags.
1413
-		elseif ($inNoBbc)
1414
-			$parts[$i] .= '[/nobbc]';
1464
+		elseif ($inNoBbc) {
1465
+					$parts[$i] .= '[/nobbc]';
1466
+		}
1415 1467
 
1416 1468
 		// Still inline tags left unclosed? Close them now, better late than never.
1417
-		elseif (!empty($inlineElements))
1418
-			$parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']';
1469
+		elseif (!empty($inlineElements)) {
1470
+					$parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']';
1471
+		}
1419 1472
 
1420 1473
 		// Now close the block elements.
1421
-		if (!empty($blockElements))
1422
-			$parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']';
1474
+		if (!empty($blockElements)) {
1475
+					$parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']';
1476
+		}
1423 1477
 
1424 1478
 		$text = implode('', $parts);
1425 1479
 	}
1426 1480
 
1427 1481
 	// Final clean up of back to back tags.
1428 1482
 	$lastlen = 0;
1429
-	while (strlen($text) !== $lastlen)
1430
-		$lastlen = strlen($text = preg_replace($backToBackPattern, '', $text));
1483
+	while (strlen($text) !== $lastlen) {
1484
+			$lastlen = strlen($text = preg_replace($backToBackPattern, '', $text));
1485
+	}
1431 1486
 
1432 1487
 	return $text;
1433 1488
 }
@@ -1456,22 +1511,25 @@  discard block
 block discarded – undo
1456 1511
 	$context['template_layers'] = array();
1457 1512
 	// Lets make sure we aren't going to output anything nasty.
1458 1513
 	@ob_end_clean();
1459
-	if (!empty($modSettings['enableCompressedOutput']))
1460
-		@ob_start('ob_gzhandler');
1461
-	else
1462
-		@ob_start();
1514
+	if (!empty($modSettings['enableCompressedOutput'])) {
1515
+			@ob_start('ob_gzhandler');
1516
+	} else {
1517
+			@ob_start();
1518
+	}
1463 1519
 
1464 1520
 	// If we don't have any locale better avoid broken js
1465
-	if (empty($txt['lang_locale']))
1466
-		die();
1521
+	if (empty($txt['lang_locale'])) {
1522
+			die();
1523
+	}
1467 1524
 
1468 1525
 	$file_data = '(function ($) {
1469 1526
 	\'use strict\';
1470 1527
 
1471 1528
 	$.sceditor.locale[' . javaScriptEscape($txt['lang_locale']) . '] = {';
1472
-	foreach ($editortxt as $key => $val)
1473
-		$file_data .= '
1529
+	foreach ($editortxt as $key => $val) {
1530
+			$file_data .= '
1474 1531
 		' . javaScriptEscape($key) . ': ' . javaScriptEscape($val) . ',';
1532
+	}
1475 1533
 
1476 1534
 	$file_data .= '
1477 1535
 		dateFormat: "day.month.year"
@@ -1539,8 +1597,9 @@  discard block
 block discarded – undo
1539 1597
 				)
1540 1598
 			);
1541 1599
 			$icon_data = array();
1542
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1543
-				$icon_data[] = $row;
1600
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
1601
+							$icon_data[] = $row;
1602
+			}
1544 1603
 			$smcFunc['db_free_result']($request);
1545 1604
 
1546 1605
 			$icons = array();
@@ -1555,9 +1614,9 @@  discard block
 block discarded – undo
1555 1614
 			}
1556 1615
 
1557 1616
 			cache_put_data('posting_icons-' . $board_id, $icons, 480);
1617
+		} else {
1618
+					$icons = $temp;
1558 1619
 		}
1559
-		else
1560
-			$icons = $temp;
1561 1620
 	}
1562 1621
 	call_integration_hook('integrate_load_message_icons', array(&$icons));
1563 1622
 
@@ -1598,8 +1657,9 @@  discard block
 block discarded – undo
1598 1657
 	{
1599 1658
 		// Some general stuff.
1600 1659
 		$settings['smileys_url'] = $modSettings['smileys_url'] . '/' . $user_info['smiley_set'];
1601
-		if (!empty($context['drafts_autosave']))
1602
-			$context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000;
1660
+		if (!empty($context['drafts_autosave'])) {
1661
+					$context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000;
1662
+		}
1603 1663
 
1604 1664
 		// This really has some WYSIWYG stuff.
1605 1665
 		loadCSSFile('jquery.sceditor.css', array('force_current' => false, 'validate' => true), 'smf_jquery_sceditor');
@@ -1615,8 +1675,9 @@  discard block
 block discarded – undo
1615 1675
 		var bbc_quote = \'' . addcslashes($txt['quote'], "'") . '\';
1616 1676
 		var bbc_search_on = \'' . addcslashes($txt['search_on'], "'") . '\';');
1617 1677
 		// editor language file
1618
-		if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US')
1619
-			loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language');
1678
+		if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US') {
1679
+					loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language');
1680
+		}
1620 1681
 
1621 1682
 		$context['shortcuts_text'] = $txt['shortcuts' . (!empty($context['drafts_save']) ? '_drafts' : '') . (isBrowser('is_firefox') ? '_firefox' : '')];
1622 1683
 		$context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv'))));
@@ -1625,11 +1686,12 @@  discard block
 block discarded – undo
1625 1686
 			loadJavaScriptFile('spellcheck.js', array(), 'smf_spellcheck');
1626 1687
 
1627 1688
 			// Some hidden information is needed in order to make the spell checking work.
1628
-			if (!isset($_REQUEST['xml']))
1629
-				$context['insert_after_template'] .= '
1689
+			if (!isset($_REQUEST['xml'])) {
1690
+							$context['insert_after_template'] .= '
1630 1691
 		<form name="spell_form" id="spell_form" method="post" accept-charset="' . $context['character_set'] . '" target="spellWindow" action="' . $scripturl . '?action=spellcheck">
1631 1692
 			<input type="hidden" name="spellstring" value="">
1632 1693
 		</form>';
1694
+			}
1633 1695
 		}
1634 1696
 	}
1635 1697
 
@@ -1786,10 +1848,12 @@  discard block
 block discarded – undo
1786 1848
 
1787 1849
 		// Generate a list of buttons that shouldn't be shown - this should be the fastest way to do this.
1788 1850
 		$disabled_tags = array();
1789
-		if (!empty($modSettings['disabledBBC']))
1790
-			$disabled_tags = explode(',', $modSettings['disabledBBC']);
1791
-		if (empty($modSettings['enableEmbeddedFlash']))
1792
-			$disabled_tags[] = 'flash';
1851
+		if (!empty($modSettings['disabledBBC'])) {
1852
+					$disabled_tags = explode(',', $modSettings['disabledBBC']);
1853
+		}
1854
+		if (empty($modSettings['enableEmbeddedFlash'])) {
1855
+					$disabled_tags[] = 'flash';
1856
+		}
1793 1857
 
1794 1858
 		foreach ($disabled_tags as $tag)
1795 1859
 		{
@@ -1799,9 +1863,10 @@  discard block
 block discarded – undo
1799 1863
 				$context['disabled_tags']['orderedlist'] = true;
1800 1864
 			}
1801 1865
 
1802
-			foreach ($editor_tag_map as $thisTag => $tagNameBBC)
1803
-				if ($tag === $thisTag)
1866
+			foreach ($editor_tag_map as $thisTag => $tagNameBBC) {
1867
+							if ($tag === $thisTag)
1804 1868
 					$context['disabled_tags'][$tagNameBBC] = true;
1869
+			}
1805 1870
 
1806 1871
 			$context['disabled_tags'][trim($tag)] = true;
1807 1872
 		}
@@ -1811,19 +1876,21 @@  discard block
 block discarded – undo
1811 1876
 		$context['bbc_toolbar'] = array();
1812 1877
 		foreach ($context['bbc_tags'] as $row => $tagRow)
1813 1878
 		{
1814
-			if (!isset($context['bbc_toolbar'][$row]))
1815
-				$context['bbc_toolbar'][$row] = array();
1879
+			if (!isset($context['bbc_toolbar'][$row])) {
1880
+							$context['bbc_toolbar'][$row] = array();
1881
+			}
1816 1882
 			$tagsRow = array();
1817 1883
 			foreach ($tagRow as $tag)
1818 1884
 			{
1819 1885
 				if ((!empty($tag['code'])) && empty($context['disabled_tags'][$tag['code']]))
1820 1886
 				{
1821 1887
 					$tagsRow[] = $tag['code'];
1822
-					if (isset($tag['image']))
1823
-						$bbcodes_styles .= '
1888
+					if (isset($tag['image'])) {
1889
+											$bbcodes_styles .= '
1824 1890
 			.sceditor-button-' . $tag['code'] . ' div {
1825 1891
 				background: url(\'' . $settings['default_theme_url'] . '/images/bbc/' . $tag['image'] . '.png\');
1826 1892
 			}';
1893
+					}
1827 1894
 					if (isset($tag['before']))
1828 1895
 					{
1829 1896
 						$context['bbcodes_handlers'] .= '
@@ -1837,8 +1904,7 @@  discard block
 block discarded – undo
1837 1904
 				});';
1838 1905
 					}
1839 1906
 
1840
-				}
1841
-				else
1907
+				} else
1842 1908
 				{
1843 1909
 					$context['bbc_toolbar'][$row][] = implode(',', $tagsRow);
1844 1910
 					$tagsRow = array();
@@ -1849,14 +1915,16 @@  discard block
 block discarded – undo
1849 1915
 			{
1850 1916
 				$context['bbc_toolbar'][$row][] = implode(',', $tagsRow);
1851 1917
 				$tagsRow = array();
1852
-				if (!isset($context['disabled_tags']['font']))
1853
-					$tagsRow[] = 'font';
1854
-				if (!isset($context['disabled_tags']['size']))
1855
-					$tagsRow[] = 'size';
1856
-				if (!isset($context['disabled_tags']['color']))
1857
-					$tagsRow[] = 'color';
1858
-			}
1859
-			elseif ($row == 1 && empty($modSettings['disable_wysiwyg']))
1918
+				if (!isset($context['disabled_tags']['font'])) {
1919
+									$tagsRow[] = 'font';
1920
+				}
1921
+				if (!isset($context['disabled_tags']['size'])) {
1922
+									$tagsRow[] = 'size';
1923
+				}
1924
+				if (!isset($context['disabled_tags']['color'])) {
1925
+									$tagsRow[] = 'color';
1926
+				}
1927
+			} elseif ($row == 1 && empty($modSettings['disable_wysiwyg']))
1860 1928
 			{
1861 1929
 				$tmp = array();
1862 1930
 				$tagsRow[] = 'removeformat';
@@ -1867,13 +1935,15 @@  discard block
 block discarded – undo
1867 1935
 				}
1868 1936
 			}
1869 1937
 
1870
-			if (!empty($tagsRow))
1871
-				$context['bbc_toolbar'][$row][] = implode(',', $tagsRow);
1938
+			if (!empty($tagsRow)) {
1939
+							$context['bbc_toolbar'][$row][] = implode(',', $tagsRow);
1940
+			}
1872 1941
 		}
1873
-		if (!empty($bbcodes_styles))
1874
-			$context['html_headers'] .= '
1942
+		if (!empty($bbcodes_styles)) {
1943
+					$context['html_headers'] .= '
1875 1944
 		<style>' . $bbcodes_styles . '
1876 1945
 		</style>';
1946
+		}
1877 1947
 	}
1878 1948
 
1879 1949
 	// Initialize smiley array... if not loaded before.
@@ -1885,8 +1955,8 @@  discard block
 block discarded – undo
1885 1955
 		);
1886 1956
 
1887 1957
 		// Load smileys - don't bother to run a query if we're not using the database's ones anyhow.
1888
-		if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none')
1889
-			$context['smileys']['postform'][] = array(
1958
+		if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none') {
1959
+					$context['smileys']['postform'][] = array(
1890 1960
 				'smileys' => array(
1891 1961
 					array(
1892 1962
 						'code' => ':)',
@@ -1972,7 +2042,7 @@  discard block
 block discarded – undo
1972 2042
 				),
1973 2043
 				'isLast' => true,
1974 2044
 			);
1975
-		elseif ($user_info['smiley_set'] != 'none')
2045
+		} elseif ($user_info['smiley_set'] != 'none')
1976 2046
 		{
1977 2047
 			if (($temp = cache_get_data('posting_smileys', 480)) == null)
1978 2048
 			{
@@ -1995,17 +2065,19 @@  discard block
 block discarded – undo
1995 2065
 
1996 2066
 				foreach ($context['smileys'] as $section => $smileyRows)
1997 2067
 				{
1998
-					foreach ($smileyRows as $rowIndex => $smileys)
1999
-						$context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true;
2068
+					foreach ($smileyRows as $rowIndex => $smileys) {
2069
+											$context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true;
2070
+					}
2000 2071
 
2001
-					if (!empty($smileyRows))
2002
-						$context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true;
2072
+					if (!empty($smileyRows)) {
2073
+											$context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true;
2074
+					}
2003 2075
 				}
2004 2076
 
2005 2077
 				cache_put_data('posting_smileys', $context['smileys'], 480);
2078
+			} else {
2079
+							$context['smileys'] = $temp;
2006 2080
 			}
2007
-			else
2008
-				$context['smileys'] = $temp;
2009 2081
 		}
2010 2082
 	}
2011 2083
 
@@ -2031,8 +2103,9 @@  discard block
 block discarded – undo
2031 2103
 		loadTemplate('GenericControls');
2032 2104
 
2033 2105
 		// Some javascript ma'am?
2034
-		if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual'])))
2035
-			loadJavaScriptFile('captcha.js', array(), 'smf_captcha');
2106
+		if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual']))) {
2107
+					loadJavaScriptFile('captcha.js', array(), 'smf_captcha');
2108
+		}
2036 2109
 
2037 2110
 		$context['use_graphic_library'] = in_array('gd', get_loaded_extensions());
2038 2111
 
@@ -2045,8 +2118,8 @@  discard block
 block discarded – undo
2045 2118
 	$isNew = !isset($context['controls']['verification'][$verificationOptions['id']]);
2046 2119
 
2047 2120
 	// Log this into our collection.
2048
-	if ($isNew)
2049
-		$context['controls']['verification'][$verificationOptions['id']] = array(
2121
+	if ($isNew) {
2122
+			$context['controls']['verification'][$verificationOptions['id']] = array(
2050 2123
 			'id' => $verificationOptions['id'],
2051 2124
 			'empty_field' => empty($verificationOptions['no_empty_field']),
2052 2125
 			'show_visual' => !empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual'])),
@@ -2057,13 +2130,15 @@  discard block
 block discarded – undo
2057 2130
 			'questions' => array(),
2058 2131
 			'can_recaptcha' => !empty($modSettings['recaptcha_enabled']) && $modSettings['recaptcha_enabled'] == 1 && !empty($modSettings['recaptcha_site_key']) && !empty($modSettings['recaptcha_secret_key']),
2059 2132
 		);
2133
+	}
2060 2134
 	$thisVerification = &$context['controls']['verification'][$verificationOptions['id']];
2061 2135
 
2062 2136
 	// Is there actually going to be anything?
2063
-	if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha']))
2064
-		return false;
2065
-	elseif (!$isNew && !$do_test)
2066
-		return true;
2137
+	if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha'])) {
2138
+			return false;
2139
+	} elseif (!$isNew && !$do_test) {
2140
+			return true;
2141
+	}
2067 2142
 
2068 2143
 	// Sanitize reCAPTCHA fields?
2069 2144
 	if ($thisVerification['can_recaptcha'])
@@ -2076,11 +2151,12 @@  discard block
 block discarded – undo
2076 2151
 	}
2077 2152
 
2078 2153
 	// Add javascript for the object.
2079
-	if ($context['controls']['verification'][$verificationOptions['id']]['show_visual'])
2080
-		$context['insert_after_template'] .= '
2154
+	if ($context['controls']['verification'][$verificationOptions['id']]['show_visual']) {
2155
+			$context['insert_after_template'] .= '
2081 2156
 			<script>
2082 2157
 				var verification' . $verificationOptions['id'] . 'Handle = new smfCaptcha("' . $thisVerification['image_href'] . '", "' . $verificationOptions['id'] . '", ' . ($context['use_graphic_library'] ? 1 : 0) . ');
2083 2158
 			</script>';
2159
+	}
2084 2160
 
2085 2161
 	// If we want questions do we have a cache of all the IDs?
2086 2162
 	if (!empty($thisVerification['number_questions']) && empty($modSettings['question_id_cache']))
@@ -2103,8 +2179,9 @@  discard block
 block discarded – undo
2103 2179
 				unset ($row['id_question']);
2104 2180
 				// Make them all lowercase. We can't directly use $smcFunc['strtolower'] with array_walk, so do it manually, eh?
2105 2181
 				$row['answers'] = smf_json_decode($row['answers'], true);
2106
-				foreach ($row['answers'] as $k => $v)
2107
-					$row['answers'][$k] = $smcFunc['strtolower']($v);
2182
+				foreach ($row['answers'] as $k => $v) {
2183
+									$row['answers'][$k] = $smcFunc['strtolower']($v);
2184
+				}
2108 2185
 
2109 2186
 				$modSettings['question_id_cache']['questions'][$id_question] = $row;
2110 2187
 				$modSettings['question_id_cache']['langs'][$row['lngfile']][] = $id_question;
@@ -2115,35 +2192,42 @@  discard block
 block discarded – undo
2115 2192
 		}
2116 2193
 	}
2117 2194
 
2118
-	if (!isset($_SESSION[$verificationOptions['id'] . '_vv']))
2119
-		$_SESSION[$verificationOptions['id'] . '_vv'] = array();
2195
+	if (!isset($_SESSION[$verificationOptions['id'] . '_vv'])) {
2196
+			$_SESSION[$verificationOptions['id'] . '_vv'] = array();
2197
+	}
2120 2198
 
2121 2199
 	// Do we need to refresh the verification?
2122
-	if (!$do_test && (!empty($_SESSION[$verificationOptions['id'] . '_vv']['did_pass']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) || $_SESSION[$verificationOptions['id'] . '_vv']['count'] > 3) && empty($verificationOptions['dont_refresh']))
2123
-		$force_refresh = true;
2124
-	else
2125
-		$force_refresh = false;
2200
+	if (!$do_test && (!empty($_SESSION[$verificationOptions['id'] . '_vv']['did_pass']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) || $_SESSION[$verificationOptions['id'] . '_vv']['count'] > 3) && empty($verificationOptions['dont_refresh'])) {
2201
+			$force_refresh = true;
2202
+	} else {
2203
+			$force_refresh = false;
2204
+	}
2126 2205
 
2127 2206
 	// This can also force a fresh, although unlikely.
2128
-	if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q'])))
2129
-		$force_refresh = true;
2207
+	if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q']))) {
2208
+			$force_refresh = true;
2209
+	}
2130 2210
 
2131 2211
 	$verification_errors = array();
2132 2212
 	// Start with any testing.
2133 2213
 	if ($do_test)
2134 2214
 	{
2135 2215
 		// This cannot happen!
2136
-		if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count']))
2137
-			fatal_lang_error('no_access', false);
2216
+		if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count'])) {
2217
+					fatal_lang_error('no_access', false);
2218
+		}
2138 2219
 		// ... nor this!
2139
-		if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q'])))
2140
-			fatal_lang_error('no_access', false);
2220
+		if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q']))) {
2221
+					fatal_lang_error('no_access', false);
2222
+		}
2141 2223
 		// Hmm, it's requested but not actually declared. This shouldn't happen.
2142
-		if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']))
2143
-			fatal_lang_error('no_access', false);
2224
+		if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) {
2225
+					fatal_lang_error('no_access', false);
2226
+		}
2144 2227
 		// While we're here, did the user do something bad?
2145
-		if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']]))
2146
-			$verification_errors[] = 'wrong_verification_answer';
2228
+		if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']])) {
2229
+					$verification_errors[] = 'wrong_verification_answer';
2230
+		}
2147 2231
 
2148 2232
 		if ($thisVerification['can_recaptcha'])
2149 2233
 		{
@@ -2156,22 +2240,25 @@  discard block
 block discarded – undo
2156 2240
 			{
2157 2241
 				$resp = $reCaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
2158 2242
 
2159
-				if (!$resp->isSuccess())
2160
-					$verification_errors[] = 'wrong_verification_code';
2243
+				if (!$resp->isSuccess()) {
2244
+									$verification_errors[] = 'wrong_verification_code';
2245
+				}
2246
+			} else {
2247
+							$verification_errors[] = 'wrong_verification_code';
2161 2248
 			}
2162
-			else
2163
-				$verification_errors[] = 'wrong_verification_code';
2164 2249
 		}
2165
-		if ($thisVerification['show_visual'] && (empty($_REQUEST[$verificationOptions['id'] . '_vv']['code']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['code']) || strtoupper($_REQUEST[$verificationOptions['id'] . '_vv']['code']) !== $_SESSION[$verificationOptions['id'] . '_vv']['code']))
2166
-			$verification_errors[] = 'wrong_verification_code';
2250
+		if ($thisVerification['show_visual'] && (empty($_REQUEST[$verificationOptions['id'] . '_vv']['code']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['code']) || strtoupper($_REQUEST[$verificationOptions['id'] . '_vv']['code']) !== $_SESSION[$verificationOptions['id'] . '_vv']['code'])) {
2251
+					$verification_errors[] = 'wrong_verification_code';
2252
+		}
2167 2253
 		if ($thisVerification['number_questions'])
2168 2254
 		{
2169 2255
 			$incorrectQuestions = array();
2170 2256
 			foreach ($_SESSION[$verificationOptions['id'] . '_vv']['q'] as $q)
2171 2257
 			{
2172 2258
 				// We don't have this question any more, thus no answers.
2173
-				if (!isset($modSettings['question_id_cache']['questions'][$q]))
2174
-					continue;
2259
+				if (!isset($modSettings['question_id_cache']['questions'][$q])) {
2260
+									continue;
2261
+				}
2175 2262
 				// This is quite complex. We have our question but it might have multiple answers.
2176 2263
 				// First, did they actually answer this question?
2177 2264
 				if (!isset($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) || trim($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) == '')
@@ -2183,24 +2270,28 @@  discard block
 block discarded – undo
2183 2270
 				else
2184 2271
 				{
2185 2272
 					$given_answer = trim($smcFunc['htmlspecialchars'](strtolower($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q])));
2186
-					if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers']))
2187
-						$incorrectQuestions[] = $q;
2273
+					if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers'])) {
2274
+											$incorrectQuestions[] = $q;
2275
+					}
2188 2276
 				}
2189 2277
 			}
2190 2278
 
2191
-			if (!empty($incorrectQuestions))
2192
-				$verification_errors[] = 'wrong_verification_answer';
2279
+			if (!empty($incorrectQuestions)) {
2280
+							$verification_errors[] = 'wrong_verification_answer';
2281
+			}
2193 2282
 		}
2194 2283
 	}
2195 2284
 
2196 2285
 	// Any errors means we refresh potentially.
2197 2286
 	if (!empty($verification_errors))
2198 2287
 	{
2199
-		if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors']))
2200
-			$_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0;
2288
+		if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors'])) {
2289
+					$_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0;
2290
+		}
2201 2291
 		// Too many errors?
2202
-		elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors'])
2203
-			$force_refresh = true;
2292
+		elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors']) {
2293
+					$force_refresh = true;
2294
+		}
2204 2295
 
2205 2296
 		// Keep a track of these.
2206 2297
 		$_SESSION[$verificationOptions['id'] . '_vv']['errors']++;
@@ -2233,8 +2324,9 @@  discard block
 block discarded – undo
2233 2324
 			// Are we overriding the range?
2234 2325
 			$character_range = !empty($verificationOptions['override_range']) ? $verificationOptions['override_range'] : $context['standard_captcha_range'];
2235 2326
 
2236
-			for ($i = 0; $i < 6; $i++)
2237
-				$_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)];
2327
+			for ($i = 0; $i < 6; $i++) {
2328
+							$_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)];
2329
+			}
2238 2330
 		}
2239 2331
 
2240 2332
 		// Getting some new questions?
@@ -2242,8 +2334,9 @@  discard block
 block discarded – undo
2242 2334
 		{
2243 2335
 			// Attempt to try the current page's language, followed by the user's preference, followed by the site default.
2244 2336
 			$possible_langs = array();
2245
-			if (isset($_SESSION['language']))
2246
-				$possible_langs[] = strtr($_SESSION['language'], array('-utf8' => ''));
2337
+			if (isset($_SESSION['language'])) {
2338
+							$possible_langs[] = strtr($_SESSION['language'], array('-utf8' => ''));
2339
+			}
2247 2340
 			if (!empty($user_info['language']));
2248 2341
 			$possible_langs[] = $user_info['language'];
2249 2342
 			$possible_langs[] = $language;
@@ -2262,8 +2355,7 @@  discard block
 block discarded – undo
2262 2355
 				}
2263 2356
 			}
2264 2357
 		}
2265
-	}
2266
-	else
2358
+	} else
2267 2359
 	{
2268 2360
 		// Same questions as before.
2269 2361
 		$questionIDs = !empty($_SESSION[$verificationOptions['id'] . '_vv']['q']) ? $_SESSION[$verificationOptions['id'] . '_vv']['q'] : array();
@@ -2273,8 +2365,9 @@  discard block
 block discarded – undo
2273 2365
 	// If we do have an empty field, it would be nice to hide it from legitimate users who shouldn't be populating it anyway.
2274 2366
 	if (!empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']))
2275 2367
 	{
2276
-		if (!isset($context['html_headers']))
2277
-			$context['html_headers'] = '';
2368
+		if (!isset($context['html_headers'])) {
2369
+					$context['html_headers'] = '';
2370
+		}
2278 2371
 		$context['html_headers'] .= '<style>.vv_special { display:none; }</style>';
2279 2372
 	}
2280 2373
 
@@ -2300,11 +2393,13 @@  discard block
 block discarded – undo
2300 2393
 	$_SESSION[$verificationOptions['id'] . '_vv']['count'] = empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) ? 1 : $_SESSION[$verificationOptions['id'] . '_vv']['count'] + 1;
2301 2394
 
2302 2395
 	// Return errors if we have them.
2303
-	if (!empty($verification_errors))
2304
-		return $verification_errors;
2396
+	if (!empty($verification_errors)) {
2397
+			return $verification_errors;
2398
+	}
2305 2399
 	// If we had a test that one, make a note.
2306
-	elseif ($do_test)
2307
-		$_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true;
2400
+	elseif ($do_test) {
2401
+			$_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true;
2402
+	}
2308 2403
 
2309 2404
 	// Say that everything went well chaps.
2310 2405
 	return true;
@@ -2329,8 +2424,9 @@  discard block
 block discarded – undo
2329 2424
 	call_integration_hook('integrate_autosuggest', array(&$searchTypes));
2330 2425
 
2331 2426
 	// If we're just checking the callback function is registered return true or false.
2332
-	if ($checkRegistered != null)
2333
-		return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered);
2427
+	if ($checkRegistered != null) {
2428
+			return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered);
2429
+	}
2334 2430
 
2335 2431
 	checkSession('get');
2336 2432
 	loadTemplate('Xml');
@@ -2481,24 +2577,27 @@  discard block
 block discarded – undo
2481 2577
 		foreach ($possible_versions as $ver)
2482 2578
 		{
2483 2579
 			$ver = trim($ver);
2484
-			if (strpos($ver, 'SMF') === 0)
2485
-				$versions[] = $ver;
2580
+			if (strpos($ver, 'SMF') === 0) {
2581
+							$versions[] = $ver;
2582
+			}
2486 2583
 		}
2487 2584
 	}
2488 2585
 	$smcFunc['db_free_result']($request);
2489 2586
 
2490 2587
 	// Just in case we don't have ANYthing.
2491
-	if (empty($versions))
2492
-		$versions = array('SMF 2.0');
2588
+	if (empty($versions)) {
2589
+			$versions = array('SMF 2.0');
2590
+	}
2493 2591
 
2494
-	foreach ($versions as $id => $version)
2495
-		if (strpos($version, strtoupper($_REQUEST['search'])) !== false)
2592
+	foreach ($versions as $id => $version) {
2593
+			if (strpos($version, strtoupper($_REQUEST['search'])) !== false)
2496 2594
 			$xml_data['items']['children'][] = array(
2497 2595
 				'attributes' => array(
2498 2596
 					'id' => $id,
2499 2597
 				),
2500 2598
 				'value' => $version,
2501 2599
 			);
2600
+	}
2502 2601
 
2503 2602
 	return $xml_data;
2504 2603
 }
Please login to merge, or discard this patch.
Themes/default/Display.template.php 1 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" 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>';
@@ -685,22 +726,24 @@  discard block
 block discarded – undo
685 726
 							</div>';
686 727
 
687 728
 	// Ignoring this user? Hide the post.
688
-	if ($ignoring)
689
-		echo '
729
+	if ($ignoring) {
730
+			echo '
690 731
 							<div id="msg_', $message['id'], '_ignored_prompt">
691 732
 								', $txt['ignoring_user'], '
692 733
 								<a href="#" id="msg_', $message['id'], '_ignored_link" style="display: none;">', $txt['show_ignore_user_post'], '</a>
693 734
 							</div>';
735
+	}
694 736
 
695 737
 	// Show the post itself, finally!
696 738
 	echo '
697 739
 							<div class="post">';
698 740
 
699
-	if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id'])
700
-		echo '
741
+	if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id']) {
742
+			echo '
701 743
 								<div class="approve_post">
702 744
 									', $txt['post_awaiting_approval'], '
703 745
 								</div>';
746
+	}
704 747
 	echo '
705 748
 								<div class="inner" data-msgid="', $message['id'], '" id="msg_', $message['id'], '"', $ignoring ? ' style="display:none;"' : '', '>', $message['body'], '</div>
706 749
 							</div>';
@@ -717,9 +760,9 @@  discard block
 block discarded – undo
717 760
 		foreach ($message['attachment'] as $attachment)
718 761
 		{
719 762
 			// Do we want this attachment to not be showed here?
720
-			if (!empty($modSettings['dont_show_attach_under_post']) && !empty($context['show_attach_under_post'][$attachment['id']]))
721
-				continue;
722
-			elseif (!$div_output)
763
+			if (!empty($modSettings['dont_show_attach_under_post']) && !empty($context['show_attach_under_post'][$attachment['id']])) {
764
+							continue;
765
+			} elseif (!$div_output)
723 766
 			{
724 767
 				$div_output = true;
725 768
 
@@ -735,9 +778,10 @@  discard block
 block discarded – undo
735 778
 								<fieldset>
736 779
 									<legend>', $txt['attach_awaiting_approve'];
737 780
 
738
-				if ($context['can_approve'])
739
-					echo '
781
+				if ($context['can_approve']) {
782
+									echo '
740 783
 										&nbsp;[<a href="', $scripturl, '?action=attachapprove;sa=all;mid=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve_all'], '</a>]';
784
+				}
741 785
 
742 786
 				echo '
743 787
 									</legend>';
@@ -751,12 +795,13 @@  discard block
 block discarded – undo
751 795
 				echo '
752 796
 										<div class="attachments_top">';
753 797
 
754
-				if ($attachment['thumbnail']['has_thumb'])
755
-					echo '
798
+				if ($attachment['thumbnail']['has_thumb']) {
799
+									echo '
756 800
 											<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>';
757
-				else
758
-					echo '
801
+				} else {
802
+									echo '
759 803
 											<img src="' . $attachment['href'] . ';image" alt="" width="' . $attachment['width'] . '" height="' . $attachment['height'] . '" class="atc_img">';
804
+				}
760 805
 
761 806
 				echo '
762 807
 										</div>';
@@ -766,9 +811,10 @@  discard block
 block discarded – undo
766 811
 										<div class="attachments_bot">
767 812
 											<a href="' . $attachment['href'] . '"><img src="' . $settings['images_url'] . '/icons/clip.png" class="centericon" alt="*">&nbsp;' . $attachment['name'] . '</a> ';
768 813
 
769
-			if (!$attachment['is_approved'] && $context['can_approve'])
770
-				echo '
814
+			if (!$attachment['is_approved'] && $context['can_approve']) {
815
+							echo '
771 816
 											[<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>] ';
817
+			}
772 818
 			echo '
773 819
 											<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'])), '
774 820
 										</div>';
@@ -777,33 +823,38 @@  discard block
 block discarded – undo
777 823
 									</div>';
778 824
 
779 825
 			// Next attachment line ?
780
-			if (++$i % $attachments_per_line === 0)
781
-				echo '
826
+			if (++$i % $attachments_per_line === 0) {
827
+							echo '
782 828
 									<br>';
829
+			}
783 830
 		}
784 831
 
785 832
 		// If we had unapproved attachments clean up.
786
-		if ($last_approved_state == 0)
787
-			echo '
833
+		if ($last_approved_state == 0) {
834
+					echo '
788 835
 								</fieldset>';
836
+		}
789 837
 
790 838
 		// Only do this if we output a div above - otherwise it'll break things
791
-		if ($div_output)
792
-			echo '
839
+		if ($div_output) {
840
+					echo '
793 841
 							</div>';
842
+		}
794 843
 	}
795 844
 
796 845
 	// And stuff below the attachments.
797
-	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'])
798
-	echo '
846
+	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']) {
847
+		echo '
799 848
 							<div class="under_message">';
849
+	}
800 850
 
801 851
 	// Maybe they want to report this post to the moderator(s)?
802
-	if ($context['can_report_moderator'])
803
-		echo '
852
+	if ($context['can_report_moderator']) {
853
+			echo '
804 854
 								<ul class="floatright smalltext">
805 855
 									<li class="report_link"><a href="', $scripturl, '?action=reporttm;topic=', $context['current_topic'], '.', $message['counter'], ';msg=', $message['id'], '">', $txt['report_to_mod'], '</a></li>
806 856
 								</ul>';
857
+	}
807 858
 
808 859
 	// What about likes?
809 860
 	if (!empty($modSettings['enable_likes']))
@@ -844,78 +895,91 @@  discard block
 block discarded – undo
844 895
 								<ul class="quickbuttons">';
845 896
 
846 897
 		// Can they quote? if so they can select and quote as well!
847
-		if ($context['can_quote'])
848
-			echo '
898
+		if ($context['can_quote']) {
899
+					echo '
849 900
 									<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>
850 901
 									<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>';
902
+		}
851 903
 
852 904
 		// Can the user modify the contents of this post? Show the modify inline image.
853
-		if ($message['can_modify'])
854
-			echo '
905
+		if ($message['can_modify']) {
906
+					echo '
855 907
 									<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>';
908
+		}
856 909
 
857
-		if ($message['can_approve'] || $message['can_unapprove'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'])
858
-			echo '
910
+		if ($message['can_approve'] || $message['can_unapprove'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) {
911
+					echo '
859 912
 									<li class="post_options">', $txt['post_options'];
913
+		}
860 914
 
861 915
 		echo '
862 916
 										<ul>';
863 917
 
864 918
 		// Can the user modify the contents of this post?
865
-		if ($message['can_modify'])
866
-			echo '
919
+		if ($message['can_modify']) {
920
+					echo '
867 921
 											<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>';
922
+		}
868 923
 
869 924
 		// How about... even... remove it entirely?!
870
-		if ($context['can_delete'] && ($context['topic_first_message'] == $message['id']))
871
-			echo '
925
+		if ($context['can_delete'] && ($context['topic_first_message'] == $message['id'])) {
926
+					echo '
872 927
 											<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>';
873
-		elseif ($message['can_remove'] && ($context['topic_first_message'] != $message['id']))
874
-			echo '
928
+		} elseif ($message['can_remove'] && ($context['topic_first_message'] != $message['id'])) {
929
+					echo '
875 930
 											<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>';
931
+		}
876 932
 
877 933
 		// What about splitting it off the rest of the topic?
878
-		if ($context['can_split'] && !empty($context['real_num_replies']))
879
-			echo '
934
+		if ($context['can_split'] && !empty($context['real_num_replies'])) {
935
+					echo '
880 936
 											<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>';
937
+		}
881 938
 
882 939
 		// Can we issue a warning because of this post? Remember, we can't give guests warnings.
883
-		if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest'])
884
-			echo '
940
+		if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest']) {
941
+					echo '
885 942
 											<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>';
943
+		}
886 944
 
887 945
 		// Can we restore topics?
888
-		if ($context['can_restore_msg'])
889
-			echo '
946
+		if ($context['can_restore_msg']) {
947
+					echo '
890 948
 											<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>';
949
+		}
891 950
 
892 951
 		// Maybe we can approve it, maybe we should?
893
-		if ($message['can_approve'])
894
-			echo '
952
+		if ($message['can_approve']) {
953
+					echo '
895 954
 											<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>';
955
+		}
896 956
 
897 957
 		// Maybe we can unapprove it?
898
-		if ($message['can_unapprove'])
899
-			echo '
958
+		if ($message['can_unapprove']) {
959
+					echo '
900 960
 											<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>';
961
+		}
901 962
 
902 963
 		echo '
903 964
 										</ul>
904 965
 									</li>';
905 966
 
906 967
 		// Show a checkbox for quick moderation?
907
-		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove'])
908
-			echo '
968
+		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove']) {
969
+					echo '
909 970
 									<li style="display: none;" id="in_topic_mod_check_', $message['id'], '"></li>';
971
+		}
910 972
 
911
-		if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'])
912
-			echo '
973
+		if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) {
974
+					echo '
913 975
 								</ul>';
976
+		}
914 977
 	}
915 978
 
916
-	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'])
917
-	echo '
979
+	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']) {
980
+		echo '
918 981
 							</div>';
982
+	}
919 983
 
920 984
 	echo '
921 985
 						</div>
@@ -928,9 +992,10 @@  discard block
 block discarded – undo
928 992
 							<div class="custom_fields_above_signature">
929 993
 								<ul class="nolist">';
930 994
 
931
-		foreach ($message['custom_fields']['above_signature'] as $custom)
932
-			echo '
995
+		foreach ($message['custom_fields']['above_signature'] as $custom) {
996
+					echo '
933 997
 									<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
998
+		}
934 999
 
935 1000
 		echo '
936 1001
 								</ul>
@@ -938,9 +1003,10 @@  discard block
 block discarded – undo
938 1003
 	}
939 1004
 
940 1005
 	// Show the member's signature?
941
-	if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled'])
942
-		echo '
1006
+	if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) {
1007
+			echo '
943 1008
 							<div class="signature" id="msg_', $message['id'], '_signature"', $ignoring ? ' style="display:none;"' : '', '>', $message['member']['signature'], '</div>';
1009
+	}
944 1010
 
945 1011
 
946 1012
 	// Are there any custom profile fields for below the signature?
@@ -950,9 +1016,10 @@  discard block
 block discarded – undo
950 1016
 							<div class="custom_fields_below_signature">
951 1017
 								<ul class="nolist">';
952 1018
 
953
-		foreach ($message['custom_fields']['below_signature'] as $custom)
954
-			echo '
1019
+		foreach ($message['custom_fields']['below_signature'] as $custom) {
1020
+					echo '
955 1021
 									<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
1022
+		}
956 1023
 
957 1024
 		echo '
958 1025
 								</ul>
@@ -1000,8 +1067,8 @@  discard block
 block discarded – undo
1000 1067
 						<input type="hidden" name="seqnum" value="', $context['form_sequence_number'], '">';
1001 1068
 
1002 1069
 		// Guests just need more.
1003
-		if ($context['user']['is_guest'])
1004
-			echo '
1070
+		if ($context['user']['is_guest']) {
1071
+					echo '
1005 1072
 						<dl id="post_header">
1006 1073
 							<dt>
1007 1074
 								', $txt['name'], ':
@@ -1016,6 +1083,7 @@  discard block
 block discarded – undo
1016 1083
 								<input type="email" name="email" size="25" value="', $context['email'], '" tabindex="', $context['tabindex']++, '" class="input_text" required>
1017 1084
 							</dd>
1018 1085
 						</dl>';
1086
+		}
1019 1087
 
1020 1088
 		echo '
1021 1089
 						', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message'), '
@@ -1063,8 +1131,8 @@  discard block
 block discarded – undo
1063 1131
 		<br class="clear">';
1064 1132
 
1065 1133
 	// draft autosave available and the user has it enabled?
1066
-	if (!empty($context['drafts_autosave']))
1067
-		echo '
1134
+	if (!empty($context['drafts_autosave'])) {
1135
+			echo '
1068 1136
 			<script>
1069 1137
 				var oDraftAutoSave = new smf_DraftAutoSave({
1070 1138
 					sSelf: \'oDraftAutoSave\',
@@ -1076,10 +1144,12 @@  discard block
 block discarded – undo
1076 1144
 					iFreq: ', (empty($modSettings['masterAutoSaveDraftsDelay']) ? 60000 : $modSettings['masterAutoSaveDraftsDelay'] * 1000), '
1077 1145
 				});
1078 1146
 			</script>';
1147
+	}
1079 1148
 
1080
-	if ($context['show_spellchecking'])
1081
-		echo '
1149
+	if ($context['show_spellchecking']) {
1150
+			echo '
1082 1151
 			<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>';
1152
+	}
1083 1153
 
1084 1154
 	echo '
1085 1155
 				<script>
Please login to merge, or discard this patch.
Themes/default/Calendar.template.php 3 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -253,9 +253,9 @@  discard block
 block discarded – undo
253 253
 					{
254 254
 						// Sort events by start time (all day events will be listed first)
255 255
 						uasort($day['events'], function ($a, $b) {
256
-						    if ($a['start_timestamp'] == $b['start_timestamp'])
257
-						        return 0;
258
-						    return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1;
256
+							if ($a['start_timestamp'] == $b['start_timestamp'])
257
+								return 0;
258
+							return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1;
259 259
 						});
260 260
 
261 261
 						echo '
@@ -436,9 +436,9 @@  discard block
 block discarded – undo
436 436
 							{
437 437
 								// Sort events by start time (all day events will be listed first)
438 438
 								uasort($day['events'], function ($a, $b) {
439
-								    if ($a['start_timestamp'] == $b['start_timestamp'])
440
-								        return 0;
441
-								    return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1;
439
+									if ($a['start_timestamp'] == $b['start_timestamp'])
440
+										return 0;
441
+									return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1;
442 442
 								});
443 443
 
444 444
 								foreach ($day['events'] as $event)
Please login to merge, or discard this patch.
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
  * Display a list of upcoming events, birthdays, and holidays.
69 69
  *
70 70
  * @param string $grid_name The grid name
71
- * @return void|bool Returns false if the grid doesn't exist.
71
+ * @return false|null Returns false if the grid doesn't exist.
72 72
  */
73 73
 function template_show_upcoming_list($grid_name)
74 74
 {
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
  *
239 239
  * @param string $grid_name The grid name
240 240
  * @param bool $is_mini Is this a mini grid?
241
- * @return void|bool Returns false if the grid doesn't exist.
241
+ * @return false|null Returns false if the grid doesn't exist.
242 242
  */
243 243
 function template_show_month_grid($grid_name, $is_mini = false)
244 244
 {
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
  * Shows a weekly grid
524 524
  *
525 525
  * @param string $grid_name The name of the grid
526
- * @return void|bool Returns false if the grid doesn't exist
526
+ * @return false|null Returns false if the grid doesn't exist
527 527
  */
528 528
 function template_show_week_grid($grid_name)
529 529
 {
Please login to merge, or discard this patch.
Braces   +152 added lines, -116 removed lines patch added patch discarded remove patch
@@ -40,16 +40,14 @@  discard block
 block discarded – undo
40 40
 				', template_show_upcoming_list('main'), '
41 41
 			</div>
42 42
 		';
43
-	}
44
-	elseif ($context['calendar_view'] == 'view_week')
43
+	} elseif ($context['calendar_view'] == 'view_week')
45 44
 	{
46 45
 		echo '
47 46
 			<div id="main_grid">
48 47
 				', template_show_week_grid('main'), '
49 48
 			</div>
50 49
 		';
51
-	}
52
-	else
50
+	} else
53 51
 	{
54 52
 		echo '
55 53
 			<div id="main_grid">
@@ -75,8 +73,9 @@  discard block
 block discarded – undo
75 73
 	global $context, $scripturl, $txt, $modSettings;
76 74
 
77 75
 	// Bail out if we have nothing to work with
78
-	if (!isset($context['calendar_grid_' . $grid_name]))
79
-		return false;
76
+	if (!isset($context['calendar_grid_' . $grid_name])) {
77
+			return false;
78
+	}
80 79
 
81 80
 	// Protect programmer sanity
82 81
 	$calendar_data = &$context['calendar_grid_' . $grid_name];
@@ -113,11 +112,13 @@  discard block
 block discarded – undo
113 112
 					<li class="windowbg">
114 113
 						<b class="event_title">', $event['link'], '</b>';
115 114
 
116
-				if ($event['can_edit'])
117
-					echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>';
115
+				if ($event['can_edit']) {
116
+									echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>';
117
+				}
118 118
 
119
-				if ($event['can_export'])
120
-					echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>';
119
+				if ($event['can_export']) {
120
+									echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>';
121
+				}
121 122
 
122 123
 				echo '
123 124
 						<br>';
@@ -125,14 +126,14 @@  discard block
 block discarded – undo
125 126
 				if (!empty($event['allday']))
126 127
 				{
127 128
 					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>' : '';
128
-				}
129
-				else
129
+				} else
130 130
 				{
131 131
 					// Display event info relative to user's local timezone
132 132
 					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'] . '">';
133 133
 
134
-					if ($event['start_date_local'] != $event['end_date_local'])
135
-						echo trim($event['end_date_local']) . ', ';
134
+					if ($event['start_date_local'] != $event['end_date_local']) {
135
+											echo trim($event['end_date_local']) . ', ';
136
+					}
136 137
 
137 138
 					echo trim($event['end_time_local']);
138 139
 
@@ -141,23 +142,27 @@  discard block
 block discarded – undo
141 142
 					{
142 143
 						echo '</time> (<time datetime="' . $event['start_iso_gmdate'] . '">';
143 144
 
144
-						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'])
145
-							echo trim($event['start_date_orig']), ', ';
145
+						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']) {
146
+													echo trim($event['start_date_orig']), ', ';
147
+						}
146 148
 
147 149
 						echo trim($event['start_time_orig']), '</time> &ndash; <time datetime="' . $event['end_iso_gmdate'] . '">';
148 150
 
149
-						if ($event['start_date_orig'] != $event['end_date_orig'])
150
-							echo trim($event['end_date_orig']) . ', ';
151
+						if ($event['start_date_orig'] != $event['end_date_orig']) {
152
+													echo trim($event['end_date_orig']) . ', ';
153
+						}
151 154
 
152 155
 						echo trim($event['end_time_orig']), ' ', $event['tz_abbrev'], '</time>)';
153 156
 					}
154 157
 					// Event is scheduled in the user's own timezone? Let 'em know, just to avoid confusion
155
-					else
156
-						echo ' ', $event['tz_abbrev'], '</time>';
158
+					else {
159
+											echo ' ', $event['tz_abbrev'], '</time>';
160
+					}
157 161
 				}
158 162
 
159
-				if (!empty($event['location']))
160
-					echo '<br>', $event['location'];
163
+				if (!empty($event['location'])) {
164
+									echo '<br>', $event['location'];
165
+				}
161 166
 
162 167
 				echo '
163 168
 					</li>';
@@ -189,8 +194,9 @@  discard block
 block discarded – undo
189 194
 
190 195
 			$birthdays = array();
191 196
 
192
-			foreach ($date as $member)
193
-				$birthdays[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '">' . $member['name'] . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>';
197
+			foreach ($date as $member) {
198
+							$birthdays[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '">' . $member['name'] . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>';
199
+			}
194 200
 
195 201
 			echo implode(', ', $birthdays);
196 202
 
@@ -221,8 +227,9 @@  discard block
 block discarded – undo
221 227
 			$date_local = $date['date_local'];
222 228
 			unset($date['date_local']);
223 229
 
224
-			foreach ($date as $holiday)
225
-				$holidays[] = $holiday . ' (' . $date_local . ')';
230
+			foreach ($date as $holiday) {
231
+							$holidays[] = $holiday . ' (' . $date_local . ')';
232
+			}
226 233
 		}
227 234
 
228 235
 		echo implode(', ', $holidays);
@@ -245,17 +252,19 @@  discard block
 block discarded – undo
245 252
 	global $context, $settings, $txt, $scripturl, $modSettings;
246 253
 
247 254
 	// If the grid doesn't exist, no point in proceeding.
248
-	if (!isset($context['calendar_grid_' . $grid_name]))
249
-		return false;
255
+	if (!isset($context['calendar_grid_' . $grid_name])) {
256
+			return false;
257
+	}
250 258
 
251 259
 	// A handy little pointer variable.
252 260
 	$calendar_data = &$context['calendar_grid_' . $grid_name];
253 261
 
254 262
 	// Some conditions for whether or not we should show the week links *here*.
255
-	if (isset($calendar_data['show_week_links']) && ($calendar_data['show_week_links'] == 3 || (($calendar_data['show_week_links'] == 1 && $is_mini === true) || $calendar_data['show_week_links'] == 2 && $is_mini === false)))
256
-		$show_week_links = true;
257
-	else
258
-		$show_week_links = false;
263
+	if (isset($calendar_data['show_week_links']) && ($calendar_data['show_week_links'] == 3 || (($calendar_data['show_week_links'] == 1 && $is_mini === true) || $calendar_data['show_week_links'] == 2 && $is_mini === false))) {
264
+			$show_week_links = true;
265
+	} else {
266
+			$show_week_links = false;
267
+	}
259 268
 
260 269
 	// Assuming that we've not disabled it, show the title block!
261 270
 	if (empty($calendar_data['disable_title']))
@@ -294,8 +303,9 @@  discard block
 block discarded – undo
294 303
 	}
295 304
 
296 305
 	// Show the controls on main grids
297
-	if ($is_mini === false)
298
-		template_calendar_top($calendar_data);
306
+	if ($is_mini === false) {
307
+			template_calendar_top($calendar_data);
308
+	}
299 309
 
300 310
 	// Finally, the main calendar table.
301 311
 	echo '<table class="calendar_table">';
@@ -306,8 +316,9 @@  discard block
 block discarded – undo
306 316
 		echo '<tr>';
307 317
 
308 318
 		// If we're showing week links, there's an extra column ahead of the week links, so let's think ahead and be prepared!
309
-		if ($show_week_links === true)
310
-			echo '<th>&nbsp;</th>';
319
+		if ($show_week_links === true) {
320
+					echo '<th>&nbsp;</th>';
321
+		}
311 322
 
312 323
 		// Now, loop through each actual day of the week.
313 324
 		foreach ($calendar_data['week_days'] as $day)
@@ -354,27 +365,29 @@  discard block
 block discarded – undo
354 365
 				// Additional classes are given for events, holidays, and birthdays.
355 366
 				if (!empty($day['events']) && !empty($calendar_data['highlight']['events']))
356 367
 				{
357
-					if ($is_mini === true && in_array($calendar_data['highlight']['events'], array(1, 3)))
358
-						$classes[] = 'events';
359
-					elseif ($is_mini === false && in_array($calendar_data['highlight']['events'], array(2, 3)))
360
-						$classes[] = 'events';
368
+					if ($is_mini === true && in_array($calendar_data['highlight']['events'], array(1, 3))) {
369
+											$classes[] = 'events';
370
+					} elseif ($is_mini === false && in_array($calendar_data['highlight']['events'], array(2, 3))) {
371
+											$classes[] = 'events';
372
+					}
361 373
 				}
362 374
 				if (!empty($day['holidays']) && !empty($calendar_data['highlight']['holidays']))
363 375
 				{
364
-					if ($is_mini === true && in_array($calendar_data['highlight']['holidays'], array(1, 3)))
365
-						$classes[] = 'holidays';
366
-					elseif ($is_mini === false && in_array($calendar_data['highlight']['holidays'], array(2, 3)))
367
-						$classes[] = 'holidays';
376
+					if ($is_mini === true && in_array($calendar_data['highlight']['holidays'], array(1, 3))) {
377
+											$classes[] = 'holidays';
378
+					} elseif ($is_mini === false && in_array($calendar_data['highlight']['holidays'], array(2, 3))) {
379
+											$classes[] = 'holidays';
380
+					}
368 381
 				}
369 382
 				if (!empty($day['birthdays']) && !empty($calendar_data['highlight']['birthdays']))
370 383
 				{
371
-					if ($is_mini === true && in_array($calendar_data['highlight']['birthdays'], array(1, 3)))
372
-						$classes[] = 'birthdays';
373
-					elseif ($is_mini === false && in_array($calendar_data['highlight']['birthdays'], array(2, 3)))
374
-						$classes[] = 'birthdays';
384
+					if ($is_mini === true && in_array($calendar_data['highlight']['birthdays'], array(1, 3))) {
385
+											$classes[] = 'birthdays';
386
+					} elseif ($is_mini === false && in_array($calendar_data['highlight']['birthdays'], array(2, 3))) {
387
+											$classes[] = 'birthdays';
388
+					}
375 389
 				}
376
-			}
377
-			else
390
+			} else
378 391
 			{
379 392
 				// Default Classes (either compact or comfortable and disabled).
380 393
 				$classes[] = !empty($calendar_data['size']) && $calendar_data['size'] == 'small' ? 'compact' : 'comfortable';
@@ -392,17 +405,19 @@  discard block
 block discarded – undo
392 405
 				$title_prefix = !empty($day['is_first_of_month']) && $context['current_month'] == $calendar_data['current_month'] && $is_mini === false ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$calendar_data['current_month']] . ' ' : $txt['months_titles'][$calendar_data['current_month']] . ' ') : '';
393 406
 
394 407
 				// The actual day number - be it a link, or just plain old text!
395
-				if (!empty($modSettings['cal_daysaslink']) && $context['can_post'])
396
-					echo '<a href="', $scripturl, '?action=calendar;sa=post;year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="day_text">', $title_prefix, $day['day'], '</span></a>';
397
-				else
398
-					echo '<span class="day_text">', $title_prefix, $day['day'], '</span>';
408
+				if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) {
409
+									echo '<a href="', $scripturl, '?action=calendar;sa=post;year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="day_text">', $title_prefix, $day['day'], '</span></a>';
410
+				} else {
411
+									echo '<span class="day_text">', $title_prefix, $day['day'], '</span>';
412
+				}
399 413
 
400 414
 				// A lot of stuff, we're not showing on mini-calendars to conserve space.
401 415
 				if ($is_mini === false)
402 416
 				{
403 417
 					// Holidays are always fun, let's show them!
404
-					if (!empty($day['holidays']))
405
-						echo '<div class="smalltext holiday"><span>', $txt['calendar_prompt'], '</span> ', implode(', ', $day['holidays']), '</div>';
418
+					if (!empty($day['holidays'])) {
419
+											echo '<div class="smalltext holiday"><span>', $txt['calendar_prompt'], '</span> ', implode(', ', $day['holidays']), '</div>';
420
+					}
406 421
 
407 422
 					// Happy Birthday Dear, Member!
408 423
 					if (!empty($day['birthdays']))
@@ -420,14 +435,16 @@  discard block
 block discarded – undo
420 435
 							echo '<a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">', $member['name'], '</span>', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', $member['is_last'] || ($count == 10 && $use_js_hide) ? '' : ', ';
421 436
 
422 437
 							// 9...10! Let's stop there.
423
-							if ($birthday_count == 10 && $use_js_hide)
424
-								// !!TODO - Inline CSS and JavaScript should be moved.
438
+							if ($birthday_count == 10 && $use_js_hide) {
439
+															// !!TODO - Inline CSS and JavaScript should be moved.
425 440
 								echo '<span class="hidelink" id="bdhidelink_', $day['day'], '">...<br><a href="', $scripturl, '?action=calendar;month=', $calendar_data['current_month'], ';year=', $calendar_data['current_year'], ';showbd" onclick="document.getElementById(\'bdhide_', $day['day'], '\').style.display = \'\'; document.getElementById(\'bdhidelink_', $day['day'], '\').style.display = \'none\'; return false;">(', sprintf($txt['calendar_click_all'], count($day['birthdays'])), ')</a></span><span id="bdhide_', $day['day'], '" style="display: none;">, ';
441
+							}
426 442
 
427 443
 							++$birthday_count;
428 444
 						}
429
-						if ($use_js_hide)
430
-							echo '</span>';
445
+						if ($use_js_hide) {
446
+													echo '</span>';
447
+						}
431 448
 
432 449
 						echo '</div>';
433 450
 					}
@@ -437,8 +454,9 @@  discard block
 block discarded – undo
437 454
 					{
438 455
 						// Sort events by start time (all day events will be listed first)
439 456
 						uasort($day['events'], function($a, $b) {
440
-						    if ($a['start_timestamp'] == $b['start_timestamp'])
441
-						        return 0;
457
+						    if ($a['start_timestamp'] == $b['start_timestamp']) {
458
+						    						        return 0;
459
+						    }
442 460
 						    return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1;
443 461
 						});
444 462
 
@@ -454,17 +472,19 @@  discard block
 block discarded – undo
454 472
 
455 473
 							echo '<div class="event_wrapper', $event['starts_today'] == true ? ' event_starts_today' : '', $event['ends_today'] == true ? ' event_ends_today' : '', $event['allday'] == true ? ' allday' : '', $event['is_selected'] ? ' sel_event' : '', '">', $event['link'], '<br><span class="event_time', empty($event_icons_needed) ? ' floatright' : '', '">';
456 474
 
457
-							if (!empty($event['start_time_local']) && $event['starts_today'] == true)
458
-								echo trim(str_replace(':00 ', ' ', $event['start_time_local']));
459
-							elseif (!empty($event['end_time_local']) && $event['ends_today'] == true)
460
-								echo strtolower($txt['ends']), ' ', trim(str_replace(':00 ', ' ', $event['end_time_local']));
461
-							elseif (!empty($event['allday']))
462
-								echo $txt['calendar_allday'];
475
+							if (!empty($event['start_time_local']) && $event['starts_today'] == true) {
476
+															echo trim(str_replace(':00 ', ' ', $event['start_time_local']));
477
+							} elseif (!empty($event['end_time_local']) && $event['ends_today'] == true) {
478
+															echo strtolower($txt['ends']), ' ', trim(str_replace(':00 ', ' ', $event['end_time_local']));
479
+							} elseif (!empty($event['allday'])) {
480
+															echo $txt['calendar_allday'];
481
+							}
463 482
 
464 483
 							echo '</span>';
465 484
 
466
-							if (!empty($event['location']))
467
-								echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>';
485
+							if (!empty($event['location'])) {
486
+															echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>';
487
+							}
468 488
 
469 489
 							if ($event['can_edit'] || $event['can_export'])
470 490
 							{
@@ -501,10 +521,11 @@  discard block
 block discarded – undo
501 521
 			// Otherwise, assuming it's not a mini-calendar, we can show previous / next month days!
502 522
 			elseif ($is_mini === false)
503 523
 			{
504
-				if (empty($current_month_started) && !empty($context['calendar_grid_prev']))
505
-					echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_prev']['current_year'], ';month=', $context['calendar_grid_prev']['current_month'], '">', $context['calendar_grid_prev']['last_of_month'] - $calendar_data['shift']-- +1, '</a>';
506
-				elseif (!empty($current_month_started) && !empty($context['calendar_grid_next']))
507
-					echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_next']['current_year'], ';month=', $context['calendar_grid_next']['current_month'], '">', $current_month_started + 1 == $count ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$context['calendar_grid_next']['current_month']] . ' ' : $txt['months_titles'][$context['calendar_grid_next']['current_month']] . ' ') : '', $final_count++, '</a>';
524
+				if (empty($current_month_started) && !empty($context['calendar_grid_prev'])) {
525
+									echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_prev']['current_year'], ';month=', $context['calendar_grid_prev']['current_month'], '">', $context['calendar_grid_prev']['last_of_month'] - $calendar_data['shift']-- +1, '</a>';
526
+				} elseif (!empty($current_month_started) && !empty($context['calendar_grid_next'])) {
527
+									echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_next']['current_year'], ';month=', $context['calendar_grid_next']['current_month'], '">', $current_month_started + 1 == $count ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$context['calendar_grid_next']['current_month']] . ' ' : $txt['months_titles'][$context['calendar_grid_next']['current_month']] . ' ') : '', $final_count++, '</a>';
528
+				}
508 529
 			}
509 530
 
510 531
 			// Close this day and increase var count.
@@ -530,8 +551,9 @@  discard block
 block discarded – undo
530 551
 	global $context, $settings, $txt, $scripturl, $modSettings;
531 552
 
532 553
 	// We might have no reason to proceed, if the variable isn't there.
533
-	if (!isset($context['calendar_grid_' . $grid_name]))
534
-		return false;
554
+	if (!isset($context['calendar_grid_' . $grid_name])) {
555
+			return false;
556
+	}
535 557
 
536 558
 	// Handy pointer.
537 559
 	$calendar_data = &$context['calendar_grid_' . $grid_name];
@@ -567,8 +589,9 @@  discard block
 block discarded – undo
567 589
 					}
568 590
 
569 591
 					// The Month Title + Week Number...
570
-					if (!empty($calendar_data['week_title']))
571
-							echo $calendar_data['week_title'];
592
+					if (!empty($calendar_data['week_title'])) {
593
+												echo $calendar_data['week_title'];
594
+					}
572 595
 
573 596
 					echo '
574 597
 					</h3>
@@ -607,10 +630,11 @@  discard block
 block discarded – undo
607 630
 						<tr class="days_wrapper">
608 631
 							<td class="', implode(' ', $classes), ' act_day">';
609 632
 							// Should the day number be a link?
610
-							if (!empty($modSettings['cal_daysaslink']) && $context['can_post'])
611
-								echo '<a href="', $scripturl, '?action=calendar;sa=post;month=', $month_data['current_month'], ';year=', $month_data['current_year'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['days'][$day['day_of_week']], ' - ', $day['day'], '</a>';
612
-							else
613
-								echo $txt['days'][$day['day_of_week']], ' - ', $day['day'];
633
+							if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) {
634
+															echo '<a href="', $scripturl, '?action=calendar;sa=post;month=', $month_data['current_month'], ';year=', $month_data['current_year'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['days'][$day['day_of_week']], ' - ', $day['day'], '</a>';
635
+							} else {
636
+															echo $txt['days'][$day['day_of_week']], ' - ', $day['day'];
637
+							}
614 638
 
615 639
 							echo '</td>
616 640
 							<td class="', implode(' ', $classes), '', empty($day['events']) ? (' disabled' . ($context['can_post'] ? ' week_post' : '')) : ' events', ' event_col" data-css-prefix="' . $txt['events'] . ' ', (empty($day['events']) && empty($context['can_post'])) ? $txt['none'] : '', '">';
@@ -619,8 +643,9 @@  discard block
 block discarded – undo
619 643
 							{
620 644
 								// Sort events by start time (all day events will be listed first)
621 645
 								uasort($day['events'], function($a, $b) {
622
-								    if ($a['start_timestamp'] == $b['start_timestamp'])
623
-								        return 0;
646
+								    if ($a['start_timestamp'] == $b['start_timestamp']) {
647
+								    								        return 0;
648
+								    }
624 649
 								    return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1;
625 650
 								});
626 651
 
@@ -632,15 +657,17 @@  discard block
 block discarded – undo
632 657
 
633 658
 									echo $event['link'], '<br><span class="event_time', empty($event_icons_needed) ? ' floatright' : '', '">';
634 659
 
635
-									if (!empty($event['start_time_local']))
636
-										echo trim($event['start_time_local']), !empty($event['end_time_local']) ? ' &ndash; ' . trim($event['end_time_local']) : '';
637
-									else
638
-										echo $txt['calendar_allday'];
660
+									if (!empty($event['start_time_local'])) {
661
+																			echo trim($event['start_time_local']), !empty($event['end_time_local']) ? ' &ndash; ' . trim($event['end_time_local']) : '';
662
+									} else {
663
+																			echo $txt['calendar_allday'];
664
+									}
639 665
 
640 666
 									echo '</span>';
641 667
 
642
-									if (!empty($event['location']))
643
-										echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>';
668
+									if (!empty($event['location'])) {
669
+																			echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>';
670
+									}
644 671
 
645 672
 									if (!empty($event_icons_needed))
646 673
 									{
@@ -677,8 +704,7 @@  discard block
 block discarded – undo
677 704
 									</div>
678 705
 									<br class="clear">';
679 706
 								}
680
-							}
681
-							else
707
+							} else
682 708
 							{
683 709
 								if (!empty($context['can_post']))
684 710
 								{
@@ -691,8 +717,9 @@  discard block
 block discarded – undo
691 717
 							echo '</td>
692 718
 							<td class="', implode(' ', $classes), !empty($day['holidays']) ? ' holidays' : ' disabled', ' holiday_col" data-css-prefix="' . $txt['calendar_prompt'] . ' ">';
693 719
 							// Show any holidays!
694
-							if (!empty($day['holidays']))
695
-								echo implode('<br>', $day['holidays']);
720
+							if (!empty($day['holidays'])) {
721
+															echo implode('<br>', $day['holidays']);
722
+							}
696 723
 
697 724
 							echo '</td>
698 725
 							<td class="', implode(' ', $classes), '', !empty($day['birthdays']) ? ' birthdays' : ' disabled', ' birthday_col" data-css-prefix="' . $txt['birthdays'] . ' ">';
@@ -750,8 +777,7 @@  discard block
 block discarded – undo
750 777
 				<input type="text" name="end_date" id="end_date" maxlength="10" value="', $calendar_data['end_date'], '" tabindex="', $context['tabindex']++, '" class="input_text date_input end" data-type="date">
751 778
 				<input type="submit" class="button_submit" style="float:none" id="view_button" value="', $txt['view'], '">
752 779
 			</form>';
753
-	}
754
-	else
780
+	} else
755 781
 	{
756 782
 		echo'
757 783
 			<form action="', $scripturl, '?action=calendar" id="calendar_navigation" method="post" accept-charset="', $context['character_set'], '">
@@ -793,8 +819,9 @@  discard block
 block discarded – undo
793 819
 	echo '
794 820
 		<form action="', $scripturl, '?action=calendar;sa=post" method="post" name="postevent" accept-charset="', $context['character_set'], '" onsubmit="submitonce(this);smc_saveEntities(\'postevent\', [\'evtitle\']);" style="margin: 0;">';
795 821
 
796
-	if (!empty($context['event']['new']))
797
-		echo '<input type="hidden" name="eventid" value="', $context['event']['eventid'], '">';
822
+	if (!empty($context['event']['new'])) {
823
+			echo '<input type="hidden" name="eventid" value="', $context['event']['eventid'], '">';
824
+	}
798 825
 
799 826
 	// Start the main table.
800 827
 	echo '
@@ -844,9 +871,10 @@  discard block
 block discarded – undo
844 871
 		{
845 872
 			echo '
846 873
 								<optgroup label="', $category['name'], '">';
847
-			foreach ($category['boards'] as $board)
848
-				echo '
874
+			foreach ($category['boards'] as $board) {
875
+							echo '
849 876
 									<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=&gt;' : '', ' ', $board['name'], '&nbsp;</option>';
877
+			}
850 878
 			echo '
851 879
 								</optgroup>';
852 880
 		}
@@ -882,9 +910,10 @@  discard block
 block discarded – undo
882 910
 							<span class="label">', $txt['calendar_timezone'], '</span>
883 911
 							<select name="tz" id="tz"', !empty($context['event']['allday']) ? ' disabled' : '', '>';
884 912
 
885
-	foreach ($context['all_timezones'] as $tz => $tzname)
886
-		echo '
913
+	foreach ($context['all_timezones'] as $tz => $tzname) {
914
+			echo '
887 915
 								<option value="', $tz, '"', $tz == $context['event']['tz'] ? ' selected' : '', '>', $tzname, '</option>';
916
+	}
888 917
 
889 918
 	echo '
890 919
 							</select>
@@ -899,9 +928,10 @@  discard block
 block discarded – undo
899 928
 	echo '
900 929
 				<input type="submit" value="', empty($context['event']['new']) ? $txt['save'] : $txt['post'], '" class="button_submit">';
901 930
 	// Delete button?
902
-	if (empty($context['event']['new']))
903
-		echo '
931
+	if (empty($context['event']['new'])) {
932
+			echo '
904 933
 				<input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['calendar_confirm_delete'], '" class="button_submit you_sure">';
934
+	}
905 935
 
906 936
 	echo '
907 937
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -945,9 +975,10 @@  discard block
 block discarded – undo
945 975
 
946 976
 		foreach ($context['clockicons'] as $t => $v)
947 977
 		{
948
-			foreach ($v as $i)
949
-				echo '
978
+			foreach ($v as $i) {
979
+							echo '
950 980
 			icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');';
981
+			}
951 982
 		}
952 983
 
953 984
 		echo '
@@ -972,13 +1003,14 @@  discard block
 block discarded – undo
972 1003
 
973 1004
 		foreach ($context['clockicons'] as $t => $v)
974 1005
 		{
975
-			foreach ($v as $i)
976
-				echo '
1006
+			foreach ($v as $i) {
1007
+							echo '
977 1008
 			if (', $t, ' >= ', $i, ')
978 1009
 			{
979 1010
 				turnon.push("', $t, '_', $i, '");
980 1011
 				', $t, ' -= ', $i, ';
981 1012
 			}';
1013
+			}
982 1014
 		}
983 1015
 
984 1016
 		echo '
@@ -1042,9 +1074,10 @@  discard block
 block discarded – undo
1042 1074
 
1043 1075
 	foreach ($context['clockicons'] as $t => $v)
1044 1076
 	{
1045
-		foreach ($v as $i)
1046
-			echo '
1077
+		foreach ($v as $i) {
1078
+					echo '
1047 1079
 		icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');';
1080
+		}
1048 1081
 	}
1049 1082
 
1050 1083
 	echo '
@@ -1061,13 +1094,14 @@  discard block
 block discarded – undo
1061 1094
 
1062 1095
 	foreach ($context['clockicons'] as $t => $v)
1063 1096
 	{
1064
-		foreach ($v as $i)
1065
-			echo '
1097
+		foreach ($v as $i) {
1098
+					echo '
1066 1099
 		if (', $t, ' >= ', $i, ')
1067 1100
 		{
1068 1101
 			turnon.push("', $t, '_', $i, '");
1069 1102
 			', $t, ' -= ', $i, ';
1070 1103
 		}';
1104
+		}
1071 1105
 	}
1072 1106
 
1073 1107
 	echo '
@@ -1126,9 +1160,10 @@  discard block
 block discarded – undo
1126 1160
 
1127 1161
 	foreach ($context['clockicons'] as $t => $v)
1128 1162
 	{
1129
-		foreach ($v as $i)
1130
-			echo '
1163
+		foreach ($v as $i) {
1164
+					echo '
1131 1165
 		icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');';
1166
+		}
1132 1167
 	}
1133 1168
 
1134 1169
 	echo '
@@ -1149,13 +1184,14 @@  discard block
 block discarded – undo
1149 1184
 
1150 1185
 	foreach ($context['clockicons'] as $t => $v)
1151 1186
 	{
1152
-		foreach ($v as $i)
1153
-		echo '
1187
+		foreach ($v as $i) {
1188
+				echo '
1154 1189
 		if (', $t, ' >= ', $i, ')
1155 1190
 		{
1156 1191
 			turnon.push("', $t, '_', $i, '");
1157 1192
 			', $t, ' -= ', $i, ';
1158 1193
 		}';
1194
+		}
1159 1195
 	}
1160 1196
 
1161 1197
 	echo '
Please login to merge, or discard this patch.
Sources/Calendar.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -240,8 +240,8 @@
 block discarded – undo
240 240
 		$time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]);
241 241
 
242 242
 	$js_time_string = str_replace(
243
-		array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r',      '%R',  '%S', '%T',    '%X'),
244
-		array('H',  'G',  'h',  'g',  'i',  'A',  'a',  'h:i:s A', 'H:i', 's',  'H:i:s', 'H:i:s'),
243
+		array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'),
244
+		array('H', 'G', 'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'H:i:s'),
245 245
 		$time_string
246 246
 	);
247 247
 
Please login to merge, or discard this patch.
Braces   +125 added lines, -99 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
  * Show the calendar.
@@ -47,12 +48,14 @@  discard block
 block discarded – undo
47 48
 		'post' => 'CalendarPost',
48 49
 	);
49 50
 
50
-	if (isset($_GET['sa']) && isset($subActions[$_GET['sa']]))
51
-		return call_helper($subActions[$_GET['sa']]);
51
+	if (isset($_GET['sa']) && isset($subActions[$_GET['sa']])) {
52
+			return call_helper($subActions[$_GET['sa']]);
53
+	}
52 54
 
53 55
 	// You can't do anything if the calendar is off.
54
-	if (empty($modSettings['cal_enabled']))
55
-		fatal_lang_error('calendar_off', false);
56
+	if (empty($modSettings['cal_enabled'])) {
57
+			fatal_lang_error('calendar_off', false);
58
+	}
56 59
 
57 60
 	// This is gonna be needed...
58 61
 	loadTemplate('Calendar');
@@ -80,8 +83,9 @@  discard block
 block discarded – undo
80 83
 				$_REQUEST['month'] = (int) $_REQUEST['month'];
81 84
 
82 85
 				// We want month view.
83
-				if (empty($_GET['viewmonth']))
84
-					$_GET['viewmonth'] = true;
86
+				if (empty($_GET['viewmonth'])) {
87
+									$_GET['viewmonth'] = true;
88
+				}
85 89
 
86 90
 				// And we definitely don't want weekly view.
87 91
 				unset ($_GET['viewweek']);
@@ -98,22 +102,25 @@  discard block
 block discarded – undo
98 102
 	$context['page_title'] = $txt['calendar'];
99 103
 
100 104
 	// Ensure a default view is defined
101
-	if (empty($modSettings['calendar_default_view']))
102
-		$modSettings['calendar_default_view'] = 'view_list';
105
+	if (empty($modSettings['calendar_default_view'])) {
106
+			$modSettings['calendar_default_view'] = 'view_list';
107
+	}
103 108
 
104 109
 	// What view do we want?
105
-	if (isset($_GET['viewweek']))
106
-		$context['calendar_view'] = 'view_week';
107
-	elseif (isset($_GET['viewmonth']))
108
-		$context['calendar_view'] = 'view_month';
109
-	elseif (isset($_GET['viewlist']))
110
-		$context['calendar_view'] = 'view_list';
111
-	else
112
-		$context['calendar_view'] = $modSettings['calendar_default_view'];
110
+	if (isset($_GET['viewweek'])) {
111
+			$context['calendar_view'] = 'view_week';
112
+	} elseif (isset($_GET['viewmonth'])) {
113
+			$context['calendar_view'] = 'view_month';
114
+	} elseif (isset($_GET['viewlist'])) {
115
+			$context['calendar_view'] = 'view_list';
116
+	} else {
117
+			$context['calendar_view'] = $modSettings['calendar_default_view'];
118
+	}
113 119
 
114 120
 	// Don't let search engines index the non-default calendar pages
115
-	if ($context['calendar_view'] !== $modSettings['calendar_default_view'])
116
-		$context['robot_no_index'] = true;
121
+	if ($context['calendar_view'] !== $modSettings['calendar_default_view']) {
122
+			$context['robot_no_index'] = true;
123
+	}
117 124
 
118 125
 	// Get the current day of month...
119 126
 	require_once($sourcedir . '/Subs-Calendar.php');
@@ -174,16 +181,19 @@  discard block
 block discarded – undo
174 181
 	);
175 182
 
176 183
 	// Make sure the year and month are in valid ranges.
177
-	if ($curPage['month'] < 1 || $curPage['month'] > 12)
178
-		fatal_lang_error('invalid_month', false);
179
-	if ($curPage['year'] < $modSettings['cal_minyear'] || $curPage['year'] > $modSettings['cal_maxyear'])
180
-		fatal_lang_error('invalid_year', false);
184
+	if ($curPage['month'] < 1 || $curPage['month'] > 12) {
185
+			fatal_lang_error('invalid_month', false);
186
+	}
187
+	if ($curPage['year'] < $modSettings['cal_minyear'] || $curPage['year'] > $modSettings['cal_maxyear']) {
188
+			fatal_lang_error('invalid_year', false);
189
+	}
181 190
 	// If we have a day clean that too.
182 191
 	if ($context['calendar_view'] != 'view_month')
183 192
 	{
184 193
 		$isValid = checkdate($curPage['month'], $curPage['day'], $curPage['year']);
185
-		if (!$isValid)
186
-			fatal_lang_error('invalid_day', false);
194
+		if (!$isValid) {
195
+					fatal_lang_error('invalid_day', false);
196
+		}
187 197
 	}
188 198
 
189 199
 	// Load all the context information needed to show the calendar grid.
@@ -205,23 +215,26 @@  discard block
 block discarded – undo
205 215
 	);
206 216
 
207 217
 	// Load up the main view.
208
-	if ($context['calendar_view'] == 'view_list')
209
-		$context['calendar_grid_main'] = getCalendarList($curPage['start_date'], $curPage['end_date'], $calendarOptions);
210
-	elseif ($context['calendar_view'] == 'view_week')
211
-		$context['calendar_grid_main'] = getCalendarWeek($curPage['month'], $curPage['year'], $curPage['day'], $calendarOptions);
212
-	else
213
-		$context['calendar_grid_main'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions);
218
+	if ($context['calendar_view'] == 'view_list') {
219
+			$context['calendar_grid_main'] = getCalendarList($curPage['start_date'], $curPage['end_date'], $calendarOptions);
220
+	} elseif ($context['calendar_view'] == 'view_week') {
221
+			$context['calendar_grid_main'] = getCalendarWeek($curPage['month'], $curPage['year'], $curPage['day'], $calendarOptions);
222
+	} else {
223
+			$context['calendar_grid_main'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions);
224
+	}
214 225
 
215 226
 	// Load up the previous and next months.
216 227
 	$context['calendar_grid_current'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions);
217 228
 
218 229
 	// Only show previous month if it isn't pre-January of the min-year
219
-	if ($context['calendar_grid_current']['previous_calendar']['year'] > $modSettings['cal_minyear'] || $curPage['month'] != 1)
220
-		$context['calendar_grid_prev'] = getCalendarGrid($context['calendar_grid_current']['previous_calendar']['month'], $context['calendar_grid_current']['previous_calendar']['year'], $calendarOptions, true);
230
+	if ($context['calendar_grid_current']['previous_calendar']['year'] > $modSettings['cal_minyear'] || $curPage['month'] != 1) {
231
+			$context['calendar_grid_prev'] = getCalendarGrid($context['calendar_grid_current']['previous_calendar']['month'], $context['calendar_grid_current']['previous_calendar']['year'], $calendarOptions, true);
232
+	}
221 233
 
222 234
 	// Only show next month if it isn't post-December of the max-year
223
-	if ($context['calendar_grid_current']['next_calendar']['year'] < $modSettings['cal_maxyear'] || $curPage['month'] != 12)
224
-		$context['calendar_grid_next'] = getCalendarGrid($context['calendar_grid_current']['next_calendar']['month'], $context['calendar_grid_current']['next_calendar']['year'], $calendarOptions);
235
+	if ($context['calendar_grid_current']['next_calendar']['year'] < $modSettings['cal_maxyear'] || $curPage['month'] != 12) {
236
+			$context['calendar_grid_next'] = getCalendarGrid($context['calendar_grid_current']['next_calendar']['month'], $context['calendar_grid_current']['next_calendar']['year'], $calendarOptions);
237
+	}
225 238
 
226 239
 	// Basic template stuff.
227 240
 	$context['allow_calendar_event'] = allowedTo('calendar_post');
@@ -241,8 +254,9 @@  discard block
 block discarded – undo
241 254
 	$context['blocks_disabled'] = !empty($modSettings['cal_disable_prev_next']) ? 1 : 0;
242 255
 
243 256
 	// Set the page title to mention the month or week, too
244
-	if ($context['calendar_view'] != 'view_list')
245
-		$context['page_title'] .= ' - ' . ($context['calendar_view'] == 'view_week' ? $context['calendar_grid_main']['week_title'] : $txt['months'][$context['current_month']] . ' ' . $context['current_year']);
257
+	if ($context['calendar_view'] != 'view_list') {
258
+			$context['page_title'] .= ' - ' . ($context['calendar_view'] == 'view_week' ? $context['calendar_grid_main']['week_title'] : $txt['months'][$context['current_month']] . ' ' . $context['current_year']);
259
+	}
246 260
 
247 261
 	// Load up the linktree!
248 262
 	$context['linktree'][] = array(
@@ -255,17 +269,19 @@  discard block
 block discarded – undo
255 269
 		'name' => $txt['months'][$context['current_month']] . ' ' . $context['current_year']
256 270
 	);
257 271
 	// If applicable, add the current week to the linktree.
258
-	if ($context['calendar_view'] == 'view_week')
259
-		$context['linktree'][] = array(
272
+	if ($context['calendar_view'] == 'view_week') {
273
+			$context['linktree'][] = array(
260 274
 			'url' => $scripturl . '?action=calendar;viewweek;year=' . $context['current_year'] . ';month=' . $context['current_month'] . ';day=' . $context['current_day'],
261 275
 			'name' => $context['calendar_grid_main']['week_title'],
262 276
 		);
277
+	}
263 278
 
264 279
 	// Build the calendar button array.
265 280
 	$context['calendar_buttons'] = array();
266 281
 
267
-	if ($context['can_post'])
268
-		$context['calendar_buttons']['post_event'] = array('text' => 'calendar_post_event', 'image' => 'calendarpe.png', 'url' => $scripturl . '?action=calendar;sa=post;month=' . $context['current_month'] . ';year=' . $context['current_year'] . ';' . $context['session_var'] . '=' . $context['session_id']);
282
+	if ($context['can_post']) {
283
+			$context['calendar_buttons']['post_event'] = array('text' => 'calendar_post_event', 'image' => 'calendarpe.png', 'url' => $scripturl . '?action=calendar;sa=post;month=' . $context['current_month'] . ';year=' . $context['current_year'] . ';' . $context['session_var'] . '=' . $context['session_id']);
284
+	}
269 285
 
270 286
 	// Allow mods to add additional buttons here
271 287
 	call_integration_hook('integrate_calendar_buttons');
@@ -294,14 +310,16 @@  discard block
 block discarded – undo
294 310
 	require_once($sourcedir . '/Subs.php');
295 311
 
296 312
 	// Cast this for safety...
297
-	if (isset($_REQUEST['eventid']))
298
-		$_REQUEST['eventid'] = (int) $_REQUEST['eventid'];
313
+	if (isset($_REQUEST['eventid'])) {
314
+			$_REQUEST['eventid'] = (int) $_REQUEST['eventid'];
315
+	}
299 316
 
300 317
 	// We want a fairly compact version of the time, but as close as possible to the user's settings.
301
-	if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0]))
302
-		$time_string = '%k:%M';
303
-	else
304
-		$time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]);
318
+	if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) {
319
+			$time_string = '%k:%M';
320
+	} else {
321
+			$time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]);
322
+	}
305 323
 
306 324
 	$js_time_string = str_replace(
307 325
 		array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r',      '%R',  '%S', '%T',    '%X'),
@@ -315,12 +333,14 @@  discard block
 block discarded – undo
315 333
 		checkSession();
316 334
 
317 335
 		// Validate the post...
318
-		if (!isset($_POST['link_to_board']))
319
-			validateEventPost();
336
+		if (!isset($_POST['link_to_board'])) {
337
+					validateEventPost();
338
+		}
320 339
 
321 340
 		// If you're not allowed to edit any events, you have to be the poster.
322
-		if ($_REQUEST['eventid'] > 0 && !allowedTo('calendar_edit_any'))
323
-			isAllowedTo('calendar_edit_' . (!empty($user_info['id']) && getEventPoster($_REQUEST['eventid']) == $user_info['id'] ? 'own' : 'any'));
341
+		if ($_REQUEST['eventid'] > 0 && !allowedTo('calendar_edit_any')) {
342
+					isAllowedTo('calendar_edit_' . (!empty($user_info['id']) && getEventPoster($_REQUEST['eventid']) == $user_info['id'] ? 'own' : 'any'));
343
+		}
324 344
 
325 345
 		// New - and directing?
326 346
 		if (isset($_POST['link_to_board']) || empty($modSettings['cal_allow_unlinked']))
@@ -343,8 +363,9 @@  discard block
 block discarded – undo
343 363
 		}
344 364
 
345 365
 		// Deleting...
346
-		elseif (isset($_REQUEST['deleteevent']))
347
-			removeEvent($_REQUEST['eventid']);
366
+		elseif (isset($_REQUEST['deleteevent'])) {
367
+					removeEvent($_REQUEST['eventid']);
368
+		}
348 369
 
349 370
 		// ... or just update it?
350 371
 		else
@@ -366,14 +387,12 @@  discard block
 block discarded – undo
366 387
 			$d = date_parse($_POST['start_date']);
367 388
 			$year = $d['year'];
368 389
 			$month = $d['month'];
369
-		}
370
-		elseif (isset($_POST['start_datetime']))
390
+		} elseif (isset($_POST['start_datetime']))
371 391
 		{
372 392
 			$d = date_parse($_POST['start_datetime']);
373 393
 			$year = $d['year'];
374 394
 			$month = $d['month'];
375
-		}
376
-		else
395
+		} else
377 396
 		{
378 397
 			$today = getdate();
379 398
 			$year = isset($_POST['year']) ? $_POST['year'] : $today['year'];
@@ -406,13 +425,13 @@  discard block
 block discarded – undo
406 425
 		$context['event'] = array_merge($context['event'], $eventDatetimes);
407 426
 
408 427
 		$context['event']['last_day'] = (int) strftime('%d', mktime(0, 0, 0, $context['event']['month'] == 12 ? 1 : $context['event']['month'] + 1, 0, $context['event']['month'] == 12 ? $context['event']['year'] + 1 : $context['event']['year']));
409
-	}
410
-	else
428
+	} else
411 429
 	{
412 430
 		$context['event'] = getEventProperties($_REQUEST['eventid']);
413 431
 
414
-		if ($context['event'] === false)
415
-			fatal_lang_error('no_access', false);
432
+		if ($context['event'] === false) {
433
+					fatal_lang_error('no_access', false);
434
+		}
416 435
 
417 436
 		// If it has a board, then they should be editing it within the topic.
418 437
 		if (!empty($context['event']['topic']['id']) && !empty($context['event']['topic']['first_msg']))
@@ -423,10 +442,11 @@  discard block
 block discarded – undo
423 442
 		}
424 443
 
425 444
 		// Make sure the user is allowed to edit this event.
426
-		if ($context['event']['member'] != $user_info['id'])
427
-			isAllowedTo('calendar_edit_any');
428
-		elseif (!allowedTo('calendar_edit_any'))
429
-			isAllowedTo('calendar_edit_own');
445
+		if ($context['event']['member'] != $user_info['id']) {
446
+					isAllowedTo('calendar_edit_any');
447
+		} elseif (!allowedTo('calendar_edit_any')) {
448
+					isAllowedTo('calendar_edit_own');
449
+		}
430 450
 	}
431 451
 
432 452
 	// An all day event? Set up some nice defaults in case the user wants to change that
@@ -460,8 +480,7 @@  discard block
 block discarded – undo
460 480
 	{
461 481
 		// You can post new events but can't link them to anything...
462 482
 		$context['event']['categories'] = array();
463
-	}
464
-	else
483
+	} else
465 484
 	{
466 485
 		// Load the list of boards and categories in the context.
467 486
 		require_once($sourcedir . '/Subs-MessageIndex.php');
@@ -548,12 +567,14 @@  discard block
 block discarded – undo
548 567
 	global $smcFunc, $sourcedir, $forum_version, $modSettings, $webmaster_email, $mbname;
549 568
 
550 569
 	// You can't export if the calendar export feature is off.
551
-	if (empty($modSettings['cal_export']))
552
-		fatal_lang_error('calendar_export_off', false);
570
+	if (empty($modSettings['cal_export'])) {
571
+			fatal_lang_error('calendar_export_off', false);
572
+	}
553 573
 
554 574
 	// Goes without saying that this is required.
555
-	if (!isset($_REQUEST['eventid']))
556
-		fatal_lang_error('no_access', false);
575
+	if (!isset($_REQUEST['eventid'])) {
576
+			fatal_lang_error('no_access', false);
577
+	}
557 578
 
558 579
 	// This is kinda wanted.
559 580
 	require_once($sourcedir . '/Subs-Calendar.php');
@@ -561,15 +582,17 @@  discard block
 block discarded – undo
561 582
 	// Load up the event in question and check it exists.
562 583
 	$event = getEventProperties($_REQUEST['eventid']);
563 584
 
564
-	if ($event === false)
565
-		fatal_lang_error('no_access', false);
585
+	if ($event === false) {
586
+			fatal_lang_error('no_access', false);
587
+	}
566 588
 
567 589
 	// Check the title isn't too long - iCal requires some formatting if so.
568 590
 	$title = str_split($event['title'], 30);
569 591
 	foreach ($title as $id => $line)
570 592
 	{
571
-		if ($id != 0)
572
-			$title[$id] = ' ' . $title[$id];
593
+		if ($id != 0) {
594
+					$title[$id] = ' ' . $title[$id];
595
+		}
573 596
 		$title[$id] .= "\n";
574 597
 	}
575 598
 
@@ -582,8 +605,7 @@  discard block
 block discarded – undo
582 605
 	{
583 606
 		$datestart = date_format($start_date, 'Ymd\THis');
584 607
 		$dateend = date_format($end_date, 'Ymd\THis');
585
-	}
586
-	else
608
+	} else
587 609
 	{
588 610
 		$datestart = date_format($start_date, 'Ymd');
589 611
 
@@ -604,15 +626,18 @@  discard block
 block discarded – undo
604 626
 	$filecontents .= 'DTSTART' . (!empty($event['start_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $datestart . "\n";
605 627
 
606 628
 	// event has a duration
607
-	if ($event['start_iso_gmdate'] != $event['end_iso_gmdate'])
608
-		$filecontents .= 'DTEND' . (!empty($event['end_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $dateend . "\n";
629
+	if ($event['start_iso_gmdate'] != $event['end_iso_gmdate']) {
630
+			$filecontents .= 'DTEND' . (!empty($event['end_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $dateend . "\n";
631
+	}
609 632
 
610 633
 	// event has changed? advance the sequence for this UID
611
-	if ($event['sequence'] > 0)
612
-		$filecontents .= 'SEQUENCE:' . $event['sequence'] . "\n";
634
+	if ($event['sequence'] > 0) {
635
+			$filecontents .= 'SEQUENCE:' . $event['sequence'] . "\n";
636
+	}
613 637
 
614
-	if (!empty($event['location']))
615
-		$filecontents .= 'LOCATION:' . str_replace(',', '\,', $event['location']) . "\n";
638
+	if (!empty($event['location'])) {
639
+			$filecontents .= 'LOCATION:' . str_replace(',', '\,', $event['location']) . "\n";
640
+	}
616 641
 
617 642
 	$filecontents .= 'SUMMARY:' . implode('', $title);
618 643
 	$filecontents .= 'UID:' . $event['eventid'] . '@' . str_replace(' ', '-', $mbname) . "\n";
@@ -621,23 +646,26 @@  discard block
 block discarded – undo
621 646
 
622 647
 	// Send some standard headers.
623 648
 	ob_end_clean();
624
-	if (!empty($modSettings['enableCompressedOutput']))
625
-		@ob_start('ob_gzhandler');
626
-	else
627
-		ob_start();
649
+	if (!empty($modSettings['enableCompressedOutput'])) {
650
+			@ob_start('ob_gzhandler');
651
+	} else {
652
+			ob_start();
653
+	}
628 654
 
629 655
 	// Send the file headers
630 656
 	header('Pragma: ');
631 657
 	header('Cache-Control: no-cache');
632
-	if (!isBrowser('gecko'))
633
-		header('Content-Transfer-Encoding: binary');
658
+	if (!isBrowser('gecko')) {
659
+			header('Content-Transfer-Encoding: binary');
660
+	}
634 661
 	header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT');
635 662
 	header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . 'GMT');
636 663
 	header('Accept-Ranges: bytes');
637 664
 	header('Connection: close');
638 665
 	header('Content-Disposition: attachment; filename="' . $event['title'] . '.ics"');
639
-	if (empty($modSettings['enableCompressedOutput']))
640
-		header('Content-Length: ' . $smcFunc['strlen']($filecontents));
666
+	if (empty($modSettings['enableCompressedOutput'])) {
667
+			header('Content-Length: ' . $smcFunc['strlen']($filecontents));
668
+	}
641 669
 
642 670
 	// This is a calendar item!
643 671
 	header('Content-Type: text/calendar');
@@ -676,20 +704,17 @@  discard block
 block discarded – undo
676 704
 		$context['sub_template'] = 'bcd';
677 705
 		$context['linktree'][] = array('url' => $scripturl . '?action=clock;bcd', 'name' => 'BCD');
678 706
 		$context['clockicons'] = safe_unserialize(base64_decode('YTo2OntzOjI6ImgxIjthOjI6e2k6MDtpOjI7aToxO2k6MTt9czoyOiJoMiI7YTo0OntpOjA7aTo4O2k6MTtpOjQ7aToyO2k6MjtpOjM7aToxO31zOjI6Im0xIjthOjM6e2k6MDtpOjQ7aToxO2k6MjtpOjI7aToxO31zOjI6Im0yIjthOjQ6e2k6MDtpOjg7aToxO2k6NDtpOjI7aToyO2k6MztpOjE7fXM6MjoiczEiO2E6Mzp7aTowO2k6NDtpOjE7aToyO2k6MjtpOjE7fXM6MjoiczIiO2E6NDp7aTowO2k6ODtpOjE7aTo0O2k6MjtpOjI7aTozO2k6MTt9fQ=='));
679
-	}
680
-	elseif (!$omfg && !isset($_REQUEST['time']))
707
+	} elseif (!$omfg && !isset($_REQUEST['time']))
681 708
 	{
682 709
 		$context['sub_template'] = 'hms';
683 710
 		$context['linktree'][] = array('url' => $scripturl . '?action=clock', 'name' => 'Binary');
684 711
 		$context['clockicons'] = safe_unserialize(base64_decode('YTozOntzOjE6ImgiO2E6NTp7aTowO2k6MTY7aToxO2k6ODtpOjI7aTo0O2k6MztpOjI7aTo0O2k6MTt9czoxOiJtIjthOjY6e2k6MDtpOjMyO2k6MTtpOjE2O2k6MjtpOjg7aTozO2k6NDtpOjQ7aToyO2k6NTtpOjE7fXM6MToicyI7YTo2OntpOjA7aTozMjtpOjE7aToxNjtpOjI7aTo4O2k6MztpOjQ7aTo0O2k6MjtpOjU7aToxO319'));
685
-	}
686
-	elseif ($omfg)
712
+	} elseif ($omfg)
687 713
 	{
688 714
 		$context['sub_template'] = 'omfg';
689 715
 		$context['linktree'][] = array('url' => $scripturl . '?action=clock;omfg', 'name' => 'OMFG');
690 716
 		$context['clockicons'] = safe_unserialize(base64_decode('YTo2OntzOjQ6InllYXIiO2E6Nzp7aTowO2k6NjQ7aToxO2k6MzI7aToyO2k6MTY7aTozO2k6ODtpOjQ7aTo0O2k6NTtpOjI7aTo2O2k6MTt9czo1OiJtb250aCI7YTo0OntpOjA7aTo4O2k6MTtpOjQ7aToyO2k6MjtpOjM7aToxO31zOjM6ImRheSI7YTo1OntpOjA7aToxNjtpOjE7aTo4O2k6MjtpOjQ7aTozO2k6MjtpOjQ7aToxO31zOjQ6ImhvdXIiO2E6NTp7aTowO2k6MTY7aToxO2k6ODtpOjI7aTo0O2k6MztpOjI7aTo0O2k6MTt9czozOiJtaW4iO2E6Njp7aTowO2k6MzI7aToxO2k6MTY7aToyO2k6ODtpOjM7aTo0O2k6NDtpOjI7aTo1O2k6MTt9czozOiJzZWMiO2E6Njp7aTowO2k6MzI7aToxO2k6MTY7aToyO2k6ODtpOjM7aTo0O2k6NDtpOjI7aTo1O2k6MTt9fQ=='));
691
-	}
692
-	elseif (isset($_REQUEST['time']))
717
+	} elseif (isset($_REQUEST['time']))
693 718
 	{
694 719
 		$context['sub_template'] = 'thetime';
695 720
 		$time = getdate($_REQUEST['time'] == 'now' ? time() : (int) $_REQUEST['time']);
@@ -749,12 +774,13 @@  discard block
 block discarded – undo
749 774
 			),
750 775
 		);
751 776
 
752
-		foreach ($context['clockicons'] as $t => $vs)
753
-			foreach ($vs as $v => $dumb)
777
+		foreach ($context['clockicons'] as $t => $vs) {
778
+					foreach ($vs as $v => $dumb)
754 779
 			{
755 780
 				if ($$t >= $v)
756 781
 				{
757 782
 					$$t -= $v;
783
+		}
758 784
 					$context['clockicons'][$t][$v] = true;
759 785
 				}
760 786
 			}
Please login to merge, or discard this patch.
other/install.php 2 patches
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1622,8 +1622,7 @@
 block discarded – undo
1622 1622
 	updateStats('topic');
1623 1623
 
1624 1624
 	// This function is needed to do the updateStats('subject') call.
1625
-	$smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' :
1626
-		function($string){
1625
+	$smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) {
1627 1626
 			global $sourcedir;
1628 1627
 			if (function_exists('mb_strtolower'))
1629 1628
 				return mb_strtolower($string, 'UTF-8');
Please login to merge, or discard this patch.
Braces   +436 added lines, -324 removed lines patch added patch discarded remove patch
@@ -20,8 +20,9 @@  discard block
 block discarded – undo
20 20
 // ><html dir="ltr"><head><title>Error!</title></head><body>Sorry, this installer requires PHP!<div style="display: none;">
21 21
 
22 22
 // Let's pull in useful classes
23
-if (!defined('SMF'))
23
+if (!defined('SMF')) {
24 24
 	define('SMF', 1);
25
+}
25 26
 
26 27
 require_once('Sources/Class-Package.php');
27 28
 
@@ -63,12 +64,14 @@  discard block
 block discarded – undo
63 64
 			$value = preg_replace('~[^A-Za-z0-9_\$]~', '', $value);
64 65
 
65 66
 			// Is it reserved?
66
-			if ($value == 'pg_')
67
-				return $txt['error_db_prefix_reserved'];
67
+			if ($value == 'pg_') {
68
+							return $txt['error_db_prefix_reserved'];
69
+			}
68 70
 
69 71
 			// Is the prefix numeric?
70
-			if (preg_match('~^\d~', $value))
71
-				return $txt['error_db_prefix_numeric'];
72
+			if (preg_match('~^\d~', $value)) {
73
+							return $txt['error_db_prefix_numeric'];
74
+			}
72 75
 
73 76
 			return true;
74 77
 		},
@@ -115,10 +118,11 @@  discard block
 block discarded – undo
115 118
 		$incontext['skip'] = false;
116 119
 
117 120
 		// Call the step and if it returns false that means pause!
118
-		if (function_exists($step[2]) && $step[2]() === false)
119
-			break;
120
-		elseif (function_exists($step[2]))
121
-			$incontext['current_step']++;
121
+		if (function_exists($step[2]) && $step[2]() === false) {
122
+					break;
123
+		} elseif (function_exists($step[2])) {
124
+					$incontext['current_step']++;
125
+		}
122 126
 
123 127
 		// No warnings pass on.
124 128
 		$incontext['warning'] = '';
@@ -134,12 +138,14 @@  discard block
 block discarded – undo
134 138
 	global $databases, $incontext;
135 139
 
136 140
 	// Just so people using older versions of PHP aren't left in the cold.
137
-	if (!isset($_SERVER['PHP_SELF']))
138
-		$_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php';
141
+	if (!isset($_SERVER['PHP_SELF'])) {
142
+			$_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php';
143
+	}
139 144
 
140 145
 	// Turn off magic quotes runtime and enable error reporting.
141
-	if (function_exists('set_magic_quotes_runtime'))
142
-		@set_magic_quotes_runtime(0);
146
+	if (function_exists('set_magic_quotes_runtime')) {
147
+			@set_magic_quotes_runtime(0);
148
+	}
143 149
 	error_reporting(E_ALL);
144 150
 
145 151
 	// Fun.  Low PHP version...
@@ -153,21 +159,23 @@  discard block
 block discarded – undo
153 159
 	{
154 160
 		ob_start();
155 161
 
156
-		if (ini_get('session.save_handler') == 'user')
157
-			@ini_set('session.save_handler', 'files');
158
-		if (function_exists('session_start'))
159
-			@session_start();
160
-	}
161
-	else
162
+		if (ini_get('session.save_handler') == 'user') {
163
+					@ini_set('session.save_handler', 'files');
164
+		}
165
+		if (function_exists('session_start')) {
166
+					@session_start();
167
+		}
168
+	} else
162 169
 	{
163 170
 		ob_start('ob_gzhandler');
164 171
 
165
-		if (ini_get('session.save_handler') == 'user')
166
-			@ini_set('session.save_handler', 'files');
172
+		if (ini_get('session.save_handler') == 'user') {
173
+					@ini_set('session.save_handler', 'files');
174
+		}
167 175
 		session_start();
168 176
 
169
-		if (!headers_sent())
170
-			echo '<!DOCTYPE html>
177
+		if (!headers_sent()) {
178
+					echo '<!DOCTYPE html>
171 179
 <html>
172 180
 	<head>
173 181
 		<title>', htmlspecialchars($_GET['pass_string']), '</title>
@@ -176,6 +184,7 @@  discard block
 block discarded – undo
176 184
 		<strong>', htmlspecialchars($_GET['pass_string']), '</strong>
177 185
 	</body>
178 186
 </html>';
187
+		}
179 188
 		exit;
180 189
 	}
181 190
 
@@ -184,16 +193,18 @@  discard block
 block discarded – undo
184 193
 	{
185 194
 		$incontext['remote_files_available'] = false;
186 195
 		$test = @fsockopen('www.simplemachines.org', 80, $errno, $errstr, 1);
187
-		if ($test)
188
-			$incontext['remote_files_available'] = true;
196
+		if ($test) {
197
+					$incontext['remote_files_available'] = true;
198
+		}
189 199
 		@fclose($test);
190 200
 	}
191 201
 
192 202
 	// Add slashes, as long as they aren't already being added.
193
-	if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0)
194
-		foreach ($_POST as $k => $v)
203
+	if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) {
204
+			foreach ($_POST as $k => $v)
195 205
 			if (strpos($k, 'password') === false && strpos($k, 'db_passwd') === false)
196 206
 				$_POST[$k] = addslashes($v);
207
+	}
197 208
 
198 209
 	// This is really quite simple; if ?delete is on the URL, delete the installer...
199 210
 	if (isset($_GET['delete']))
@@ -214,8 +225,7 @@  discard block
 block discarded – undo
214 225
 			$ftp->close();
215 226
 
216 227
 			unset($_SESSION['installer_temp_ftp']);
217
-		}
218
-		else
228
+		} else
219 229
 		{
220 230
 			@unlink(__FILE__);
221 231
 
@@ -236,10 +246,11 @@  discard block
 block discarded – undo
236 246
 	{
237 247
 		// Get PHP's default timezone, if set
238 248
 		$ini_tz = ini_get('date.timezone');
239
-		if (!empty($ini_tz))
240
-			$timezone_id = $ini_tz;
241
-		else
242
-			$timezone_id = '';
249
+		if (!empty($ini_tz)) {
250
+					$timezone_id = $ini_tz;
251
+		} else {
252
+					$timezone_id = '';
253
+		}
243 254
 
244 255
 		// If date.timezone is unset, invalid, or just plain weird, make a best guess
245 256
 		if (!in_array($timezone_id, timezone_identifiers_list()))
@@ -269,8 +280,9 @@  discard block
 block discarded – undo
269 280
 		$dir = dir(dirname(__FILE__) . '/Themes/default/languages');
270 281
 		while ($entry = $dir->read())
271 282
 		{
272
-			if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php')
273
-				$incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12));
283
+			if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') {
284
+							$incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12));
285
+			}
274 286
 		}
275 287
 		$dir->close();
276 288
 	}
@@ -305,10 +317,11 @@  discard block
 block discarded – undo
305 317
 	}
306 318
 
307 319
 	// Override the language file?
308
-	if (isset($_GET['lang_file']))
309
-		$_SESSION['installer_temp_lang'] = $_GET['lang_file'];
310
-	elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file']))
311
-		$_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file'];
320
+	if (isset($_GET['lang_file'])) {
321
+			$_SESSION['installer_temp_lang'] = $_GET['lang_file'];
322
+	} elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) {
323
+			$_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file'];
324
+	}
312 325
 
313 326
 	// Make sure it exists, if it doesn't reset it.
314 327
 	if (!isset($_SESSION['installer_temp_lang']) || preg_match('~[^\\w_\\-.]~', $_SESSION['installer_temp_lang']) === 1 || !file_exists(dirname(__FILE__) . '/Themes/default/languages/' . $_SESSION['installer_temp_lang']))
@@ -317,8 +330,9 @@  discard block
 block discarded – undo
317 330
 		list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
318 331
 
319 332
 		// If we have english and some other language, use the other language.  We Americans hate english :P.
320
-		if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1)
321
-			list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
333
+		if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) {
334
+					list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
335
+		}
322 336
 	}
323 337
 
324 338
 	// And now include the actual language file itself.
@@ -331,15 +345,18 @@  discard block
 block discarded – undo
331 345
 	global $db_prefix, $db_connection, $sourcedir;
332 346
 	global $smcFunc, $modSettings, $db_type, $db_name, $db_user, $db_persist;
333 347
 
334
-	if (empty($sourcedir))
335
-		$sourcedir = dirname(__FILE__) . '/Sources';
348
+	if (empty($sourcedir)) {
349
+			$sourcedir = dirname(__FILE__) . '/Sources';
350
+	}
336 351
 
337 352
 	// Need this to check whether we need the database password.
338 353
 	require(dirname(__FILE__) . '/Settings.php');
339
-	if (!defined('SMF'))
340
-		define('SMF', 1);
341
-	if (empty($smcFunc))
342
-		$smcFunc = array();
354
+	if (!defined('SMF')) {
355
+			define('SMF', 1);
356
+	}
357
+	if (empty($smcFunc)) {
358
+			$smcFunc = array();
359
+	}
343 360
 
344 361
 	$modSettings['disableQueryCheck'] = true;
345 362
 
@@ -347,8 +364,9 @@  discard block
 block discarded – undo
347 364
 	if (!$db_connection)
348 365
 	{
349 366
 		require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
350
-		if (version_compare(PHP_VERSION, '5', '<'))
351
-			require_once($sourcedir . '/Subs-Compat.php');
367
+		if (version_compare(PHP_VERSION, '5', '<')) {
368
+					require_once($sourcedir . '/Subs-Compat.php');
369
+		}
352 370
 
353 371
 		$db_options = array('persist' => $db_persist);
354 372
 		$port = '';
@@ -359,19 +377,20 @@  discard block
 block discarded – undo
359 377
 			if ($db_type == 'mysql')
360 378
 			{
361 379
 				$port = ((int) $_POST['db_port'] == ini_get($db_type . 'default_port')) ? '' : (int) $_POST['db_port'];
362
-			}
363
-			elseif ($db_type == 'postgresql')
380
+			} elseif ($db_type == 'postgresql')
364 381
 			{
365 382
 				// PostgreSQL doesn't have a default port setting in php.ini, so just check against the default
366 383
 				$port = ((int) $_POST['db_port'] == 5432) ? '' : (int) $_POST['db_port'];
367 384
 			}
368 385
 		}
369 386
 
370
-		if (!empty($port))
371
-			$db_options['port'] = $port;
387
+		if (!empty($port)) {
388
+					$db_options['port'] = $port;
389
+		}
372 390
 
373
-		if (!$db_connection)
374
-			$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options);
391
+		if (!$db_connection) {
392
+					$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options);
393
+		}
375 394
 	}
376 395
 }
377 396
 
@@ -399,8 +418,9 @@  discard block
 block discarded – undo
399 418
 		// @todo REMOVE THIS!!
400 419
 		else
401 420
 		{
402
-			if (function_exists('doStep' . $_GET['step']))
403
-				call_user_func('doStep' . $_GET['step']);
421
+			if (function_exists('doStep' . $_GET['step'])) {
422
+							call_user_func('doStep' . $_GET['step']);
423
+			}
404 424
 		}
405 425
 		// Show the footer.
406 426
 		template_install_below();
@@ -418,8 +438,9 @@  discard block
 block discarded – undo
418 438
 	$incontext['sub_template'] = 'welcome_message';
419 439
 
420 440
 	// Done the submission?
421
-	if (isset($_POST['contbutt']))
422
-		return true;
441
+	if (isset($_POST['contbutt'])) {
442
+			return true;
443
+	}
423 444
 
424 445
 	// See if we think they have already installed it?
425 446
 	if (is_readable(dirname(__FILE__) . '/Settings.php'))
@@ -427,14 +448,17 @@  discard block
 block discarded – undo
427 448
 		$probably_installed = 0;
428 449
 		foreach (file(dirname(__FILE__) . '/Settings.php') as $line)
429 450
 		{
430
-			if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line))
431
-				$probably_installed++;
432
-			if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line))
433
-				$probably_installed++;
451
+			if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) {
452
+							$probably_installed++;
453
+			}
454
+			if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) {
455
+							$probably_installed++;
456
+			}
434 457
 		}
435 458
 
436
-		if ($probably_installed == 2)
437
-			$incontext['warning'] = $txt['error_already_installed'];
459
+		if ($probably_installed == 2) {
460
+					$incontext['warning'] = $txt['error_already_installed'];
461
+		}
438 462
 	}
439 463
 
440 464
 	// Is some database support even compiled in?
@@ -449,36 +473,43 @@  discard block
 block discarded – undo
449 473
 				$databases[$key]['supported'] = false;
450 474
 				$notFoundSQLFile = true;
451 475
 				$txt['error_db_script_missing'] = sprintf($txt['error_db_script_missing'], 'install_' . $GLOBALS['db_script_version'] . '_' . $type . '.sql');
476
+			} else {
477
+							$incontext['supported_databases'][] = $db;
452 478
 			}
453
-			else
454
-				$incontext['supported_databases'][] = $db;
455 479
 		}
456 480
 	}
457 481
 
458 482
 	// Check the PHP version.
459
-	if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>')))
460
-		$error = 'error_php_too_low';
483
+	if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>'))) {
484
+			$error = 'error_php_too_low';
485
+	}
461 486
 	// Make sure we have a supported database
462
-	elseif (empty($incontext['supported_databases']))
463
-		$error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing';
487
+	elseif (empty($incontext['supported_databases'])) {
488
+			$error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing';
489
+	}
464 490
 	// How about session support?  Some crazy sysadmin remove it?
465
-	elseif (!function_exists('session_start'))
466
-		$error = 'error_session_missing';
491
+	elseif (!function_exists('session_start')) {
492
+			$error = 'error_session_missing';
493
+	}
467 494
 	// Make sure they uploaded all the files.
468
-	elseif (!file_exists(dirname(__FILE__) . '/index.php'))
469
-		$error = 'error_missing_files';
495
+	elseif (!file_exists(dirname(__FILE__) . '/index.php')) {
496
+			$error = 'error_missing_files';
497
+	}
470 498
 	// Very simple check on the session.save_path for Windows.
471 499
 	// @todo Move this down later if they don't use database-driven sessions?
472
-	elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\')
473
-		$error = 'error_session_save_path';
500
+	elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') {
501
+			$error = 'error_session_save_path';
502
+	}
474 503
 
475 504
 	// Since each of the three messages would look the same, anyway...
476
-	if (isset($error))
477
-		$incontext['error'] = $txt[$error];
505
+	if (isset($error)) {
506
+			$incontext['error'] = $txt[$error];
507
+	}
478 508
 
479 509
 	// Mod_security blocks everything that smells funny. Let SMF handle security.
480
-	if (!fixModSecurity() && !isset($_GET['overmodsecurity']))
481
-		$incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again'];
510
+	if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) {
511
+			$incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again'];
512
+	}
482 513
 
483 514
 	return false;
484 515
 }
@@ -503,12 +534,14 @@  discard block
 block discarded – undo
503 534
 		'Settings_bak.php',
504 535
 	);
505 536
 
506
-	foreach ($incontext['detected_languages'] as $lang => $temp)
507
-		$extra_files[] = 'Themes/default/languages/' . $lang;
537
+	foreach ($incontext['detected_languages'] as $lang => $temp) {
538
+			$extra_files[] = 'Themes/default/languages/' . $lang;
539
+	}
508 540
 
509 541
 	// With mod_security installed, we could attempt to fix it with .htaccess.
510
-	if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules()))
511
-		$writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.';
542
+	if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) {
543
+			$writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.';
544
+	}
512 545
 
513 546
 	$failed_files = array();
514 547
 
@@ -524,12 +557,14 @@  discard block
 block discarded – undo
524 557
 				@chmod(dirname(__FILE__) . '/' . $file, 0755);
525 558
 
526 559
 				// Well, 755 hopefully worked... if not, try 777.
527
-				if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777))
528
-					$failed_files[] = $file;
560
+				if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) {
561
+									$failed_files[] = $file;
562
+				}
529 563
 			}
530 564
 		}
531
-		foreach ($extra_files as $file)
532
-			@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
565
+		foreach ($extra_files as $file) {
566
+					@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
567
+		}
533 568
 	}
534 569
 	// Windows is trickier.  Let's try opening for r+...
535 570
 	else
@@ -539,30 +574,35 @@  discard block
 block discarded – undo
539 574
 		foreach ($writable_files as $file)
540 575
 		{
541 576
 			// Folders can't be opened for write... but the index.php in them can ;)
542
-			if (is_dir(dirname(__FILE__) . '/' . $file))
543
-				$file .= '/index.php';
577
+			if (is_dir(dirname(__FILE__) . '/' . $file)) {
578
+							$file .= '/index.php';
579
+			}
544 580
 
545 581
 			// Funny enough, chmod actually does do something on windows - it removes the read only attribute.
546 582
 			@chmod(dirname(__FILE__) . '/' . $file, 0777);
547 583
 			$fp = @fopen(dirname(__FILE__) . '/' . $file, 'r+');
548 584
 
549 585
 			// Hmm, okay, try just for write in that case...
550
-			if (!is_resource($fp))
551
-				$fp = @fopen(dirname(__FILE__) . '/' . $file, 'w');
586
+			if (!is_resource($fp)) {
587
+							$fp = @fopen(dirname(__FILE__) . '/' . $file, 'w');
588
+			}
552 589
 
553
-			if (!is_resource($fp))
554
-				$failed_files[] = $file;
590
+			if (!is_resource($fp)) {
591
+							$failed_files[] = $file;
592
+			}
555 593
 
556 594
 			@fclose($fp);
557 595
 		}
558
-		foreach ($extra_files as $file)
559
-			@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
596
+		foreach ($extra_files as $file) {
597
+					@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
598
+		}
560 599
 	}
561 600
 
562 601
 	$failure = count($failed_files) >= 1;
563 602
 
564
-	if (!isset($_SERVER))
565
-		return !$failure;
603
+	if (!isset($_SERVER)) {
604
+			return !$failure;
605
+	}
566 606
 
567 607
 	// Put the list into context.
568 608
 	$incontext['failed_files'] = $failed_files;
@@ -610,19 +650,23 @@  discard block
 block discarded – undo
610 650
 
611 651
 		if (!isset($ftp) || $ftp->error !== false)
612 652
 		{
613
-			if (!isset($ftp))
614
-				$ftp = new ftp_connection(null);
653
+			if (!isset($ftp)) {
654
+							$ftp = new ftp_connection(null);
655
+			}
615 656
 			// Save the error so we can mess with listing...
616
-			elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message))
617
-				$incontext['ftp_errors'][] = $ftp->last_message;
657
+			elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) {
658
+							$incontext['ftp_errors'][] = $ftp->last_message;
659
+			}
618 660
 
619 661
 			list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__));
620 662
 
621
-			if (empty($_POST['ftp_path']) && $found_path)
622
-				$_POST['ftp_path'] = $detect_path;
663
+			if (empty($_POST['ftp_path']) && $found_path) {
664
+							$_POST['ftp_path'] = $detect_path;
665
+			}
623 666
 
624
-			if (!isset($_POST['ftp_username']))
625
-				$_POST['ftp_username'] = $username;
667
+			if (!isset($_POST['ftp_username'])) {
668
+							$_POST['ftp_username'] = $username;
669
+			}
626 670
 
627 671
 			// Set the username etc, into context.
628 672
 			$incontext['ftp'] = array(
@@ -634,8 +678,7 @@  discard block
 block discarded – undo
634 678
 			);
635 679
 
636 680
 			return false;
637
-		}
638
-		else
681
+		} else
639 682
 		{
640 683
 			$_SESSION['installer_temp_ftp'] = array(
641 684
 				'server' => $_POST['ftp_server'],
@@ -649,10 +692,12 @@  discard block
 block discarded – undo
649 692
 
650 693
 			foreach ($failed_files as $file)
651 694
 			{
652
-				if (!is_writable(dirname(__FILE__) . '/' . $file))
653
-					$ftp->chmod($file, 0755);
654
-				if (!is_writable(dirname(__FILE__) . '/' . $file))
655
-					$ftp->chmod($file, 0777);
695
+				if (!is_writable(dirname(__FILE__) . '/' . $file)) {
696
+									$ftp->chmod($file, 0755);
697
+				}
698
+				if (!is_writable(dirname(__FILE__) . '/' . $file)) {
699
+									$ftp->chmod($file, 0777);
700
+				}
656 701
 				if (!is_writable(dirname(__FILE__) . '/' . $file))
657 702
 				{
658 703
 					$failed_files_updated[] = $file;
@@ -707,15 +752,17 @@  discard block
 block discarded – undo
707 752
 
708 753
 			if (!$foundOne)
709 754
 			{
710
-				if (isset($db['default_host']))
711
-					$incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost';
755
+				if (isset($db['default_host'])) {
756
+									$incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost';
757
+				}
712 758
 				if (isset($db['default_user']))
713 759
 				{
714 760
 					$incontext['db']['user'] = ini_get($db['default_user']);
715 761
 					$incontext['db']['name'] = ini_get($db['default_user']);
716 762
 				}
717
-				if (isset($db['default_password']))
718
-					$incontext['db']['pass'] = ini_get($db['default_password']);
763
+				if (isset($db['default_password'])) {
764
+									$incontext['db']['pass'] = ini_get($db['default_password']);
765
+				}
719 766
 
720 767
 				// For simplicity and less confusion, leave the port blank by default
721 768
 				$incontext['db']['port'] = '';
@@ -734,10 +781,10 @@  discard block
 block discarded – undo
734 781
 		$incontext['db']['server'] = $_POST['db_server'];
735 782
 		$incontext['db']['prefix'] = $_POST['db_prefix'];
736 783
 
737
-		if (!empty($_POST['db_port']))
738
-			$incontext['db']['port'] = $_POST['db_port'];
739
-	}
740
-	else
784
+		if (!empty($_POST['db_port'])) {
785
+					$incontext['db']['port'] = $_POST['db_port'];
786
+		}
787
+	} else
741 788
 	{
742 789
 		$incontext['db']['prefix'] = 'smf_';
743 790
 	}
@@ -773,10 +820,11 @@  discard block
 block discarded – undo
773 820
 		if (!empty($_POST['db_port']))
774 821
 		{
775 822
 			// For MySQL, we can get the "default port" from PHP. PostgreSQL has no such option though.
776
-			if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port'))
777
-				$vars['db_port'] = (int) $_POST['db_port'];
778
-			elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432)
779
-				$vars['db_port'] = (int) $_POST['db_port'];
823
+			if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) {
824
+							$vars['db_port'] = (int) $_POST['db_port'];
825
+			} elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) {
826
+							$vars['db_port'] = (int) $_POST['db_port'];
827
+			}
780 828
 		}
781 829
 
782 830
 		// God I hope it saved!
@@ -789,8 +837,9 @@  discard block
 block discarded – undo
789 837
 		// Make sure it works.
790 838
 		require(dirname(__FILE__) . '/Settings.php');
791 839
 
792
-		if (empty($sourcedir))
793
-			$sourcedir = dirname(__FILE__) . '/Sources';
840
+		if (empty($sourcedir)) {
841
+					$sourcedir = dirname(__FILE__) . '/Sources';
842
+		}
794 843
 
795 844
 		// Better find the database file!
796 845
 		if (!file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php'))
@@ -800,18 +849,21 @@  discard block
 block discarded – undo
800 849
 		}
801 850
 
802 851
 		// Now include it for database functions!
803
-		if (!defined('SMF'))
804
-			define('SMF', 1);
852
+		if (!defined('SMF')) {
853
+					define('SMF', 1);
854
+		}
805 855
 
806 856
 		$modSettings['disableQueryCheck'] = true;
807
-		if (empty($smcFunc))
808
-			$smcFunc = array();
857
+		if (empty($smcFunc)) {
858
+					$smcFunc = array();
859
+		}
809 860
 
810 861
 			require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
811 862
 
812 863
 		// What - running PHP4? The shame!
813
-		if (version_compare(PHP_VERSION, '5', '<'))
814
-			require_once($sourcedir . '/Subs-Compat.php');
864
+		if (version_compare(PHP_VERSION, '5', '<')) {
865
+					require_once($sourcedir . '/Subs-Compat.php');
866
+		}
815 867
 
816 868
 		// Attempt a connection.
817 869
 		$needsDB = !empty($databases[$db_type]['always_has_db']);
@@ -899,12 +951,14 @@  discard block
 block discarded – undo
899 951
 	$incontext['page_title'] = $txt['install_settings'];
900 952
 
901 953
 	// Let's see if we got the database type correct.
902
-	if (isset($_POST['db_type'], $databases[$_POST['db_type']]))
903
-		$db_type = $_POST['db_type'];
954
+	if (isset($_POST['db_type'], $databases[$_POST['db_type']])) {
955
+			$db_type = $_POST['db_type'];
956
+	}
904 957
 
905 958
 	// Else we'd better be able to get the connection.
906
-	else
907
-		load_database();
959
+	else {
960
+			load_database();
961
+	}
908 962
 
909 963
 	$db_type = isset($_POST['db_type']) ? $_POST['db_type'] : $db_type;
910 964
 
@@ -924,12 +978,14 @@  discard block
 block discarded – undo
924 978
 	// Submitting?
925 979
 	if (isset($_POST['boardurl']))
926 980
 	{
927
-		if (substr($_POST['boardurl'], -10) == '/index.php')
928
-			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
929
-		elseif (substr($_POST['boardurl'], -1) == '/')
930
-			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
931
-		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://')
932
-			$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
981
+		if (substr($_POST['boardurl'], -10) == '/index.php') {
982
+					$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
983
+		} elseif (substr($_POST['boardurl'], -1) == '/') {
984
+					$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
985
+		}
986
+		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') {
987
+					$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
988
+		}
933 989
 
934 990
 		// Save these variables.
935 991
 		$vars = array(
@@ -960,10 +1016,10 @@  discard block
 block discarded – undo
960 1016
 			{
961 1017
 				$incontext['error'] = sprintf($txt['error_utf8_version'], $databases[$db_type]['utf8_version']);
962 1018
 				return false;
963
-			}
964
-			else
965
-				// Set the character set here.
1019
+			} else {
1020
+							// Set the character set here.
966 1021
 				updateSettingsFile(array('db_character_set' => 'utf8'));
1022
+			}
967 1023
 		}
968 1024
 
969 1025
 		// Good, skip on.
@@ -983,8 +1039,9 @@  discard block
 block discarded – undo
983 1039
 	$incontext['continue'] = 1;
984 1040
 
985 1041
 	// Already done?
986
-	if (isset($_POST['pop_done']))
987
-		return true;
1042
+	if (isset($_POST['pop_done'])) {
1043
+			return true;
1044
+	}
988 1045
 
989 1046
 	// Reload settings.
990 1047
 	require(dirname(__FILE__) . '/Settings.php');
@@ -1002,8 +1059,9 @@  discard block
 block discarded – undo
1002 1059
 	$modSettings = array();
1003 1060
 	if ($result !== false)
1004 1061
 	{
1005
-		while ($row = $smcFunc['db_fetch_assoc']($result))
1006
-			$modSettings[$row['variable']] = $row['value'];
1062
+		while ($row = $smcFunc['db_fetch_assoc']($result)) {
1063
+					$modSettings[$row['variable']] = $row['value'];
1064
+		}
1007 1065
 		$smcFunc['db_free_result']($result);
1008 1066
 
1009 1067
 		// Do they match?  If so, this is just a refresh so charge on!
@@ -1016,20 +1074,22 @@  discard block
 block discarded – undo
1016 1074
 	$modSettings['disableQueryCheck'] = true;
1017 1075
 
1018 1076
 	// If doing UTF8, select it. PostgreSQL requires passing it as a string...
1019
-	if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support']))
1020
-		$smcFunc['db_query']('', '
1077
+	if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) {
1078
+			$smcFunc['db_query']('', '
1021 1079
 			SET NAMES {string:utf8}',
1022 1080
 			array(
1023 1081
 				'db_error_skip' => true,
1024 1082
 				'utf8' => 'utf8',
1025 1083
 			)
1026 1084
 		);
1085
+	}
1027 1086
 
1028 1087
 	// Windows likes to leave the trailing slash, which yields to C:\path\to\SMF\/attachments...
1029
-	if (substr(__DIR__, -1) == '\\')
1030
-		$attachdir = __DIR__ . 'attachments';
1031
-	else
1032
-		$attachdir = __DIR__ . '/attachments';
1088
+	if (substr(__DIR__, -1) == '\\') {
1089
+			$attachdir = __DIR__ . 'attachments';
1090
+	} else {
1091
+			$attachdir = __DIR__ . '/attachments';
1092
+	}
1033 1093
 
1034 1094
 	$replaces = array(
1035 1095
 		'{$db_prefix}' => $db_prefix,
@@ -1046,8 +1106,9 @@  discard block
 block discarded – undo
1046 1106
 
1047 1107
 	foreach ($txt as $key => $value)
1048 1108
 	{
1049
-		if (substr($key, 0, 8) == 'default_')
1050
-			$replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value);
1109
+		if (substr($key, 0, 8) == 'default_') {
1110
+					$replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value);
1111
+		}
1051 1112
 	}
1052 1113
 	$replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], array('\\\\n' => '\\n'));
1053 1114
 
@@ -1062,8 +1123,9 @@  discard block
 block discarded – undo
1062 1123
 
1063 1124
 		while ($row = $smcFunc['db_fetch_assoc']($get_engines))
1064 1125
 		{
1065
-			if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT')
1066
-				$engines[] = $row['Engine'];
1126
+			if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') {
1127
+							$engines[] = $row['Engine'];
1128
+			}
1067 1129
 		}
1068 1130
 
1069 1131
 		// Done with this now
@@ -1087,8 +1149,7 @@  discard block
 block discarded – undo
1087 1149
 			$replaces['START TRANSACTION;'] = '';
1088 1150
 			$replaces['COMMIT;'] = '';
1089 1151
 		}
1090
-	}
1091
-	else
1152
+	} else
1092 1153
 	{
1093 1154
 		$has_innodb = false;
1094 1155
 	}
@@ -1110,21 +1171,24 @@  discard block
 block discarded – undo
1110 1171
 	foreach ($sql_lines as $count => $line)
1111 1172
 	{
1112 1173
 		// No comments allowed!
1113
-		if (substr(trim($line), 0, 1) != '#')
1114
-			$current_statement .= "\n" . rtrim($line);
1174
+		if (substr(trim($line), 0, 1) != '#') {
1175
+					$current_statement .= "\n" . rtrim($line);
1176
+		}
1115 1177
 
1116 1178
 		// Is this the end of the query string?
1117
-		if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines)))
1118
-			continue;
1179
+		if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) {
1180
+					continue;
1181
+		}
1119 1182
 
1120 1183
 		// Does this table already exist?  If so, don't insert more data into it!
1121 1184
 		if (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) != 0 && in_array($match[1], $exists))
1122 1185
 		{
1123 1186
 			preg_match_all('~\)[,;]~', $current_statement, $matches);
1124
-			if (!empty($matches[0]))
1125
-				$incontext['sql_results']['insert_dups'] += count($matches[0]);
1126
-			else
1127
-				$incontext['sql_results']['insert_dups']++;
1187
+			if (!empty($matches[0])) {
1188
+							$incontext['sql_results']['insert_dups'] += count($matches[0]);
1189
+			} else {
1190
+							$incontext['sql_results']['insert_dups']++;
1191
+			}
1128 1192
 
1129 1193
 			$current_statement = '';
1130 1194
 			continue;
@@ -1133,8 +1197,9 @@  discard block
 block discarded – undo
1133 1197
 		if ($smcFunc['db_query']('', $current_statement, array('security_override' => true, 'db_error_skip' => true), $db_connection) === false)
1134 1198
 		{
1135 1199
 			// Use the appropriate function based on the DB type
1136
-			if ($db_type == 'mysql' || $db_type == 'mysqli')
1137
-				$db_errorno = $db_type . '_errno';
1200
+			if ($db_type == 'mysql' || $db_type == 'mysqli') {
1201
+							$db_errorno = $db_type . '_errno';
1202
+			}
1138 1203
 
1139 1204
 			// Error 1050: Table already exists!
1140 1205
 			// @todo Needs to be made better!
@@ -1149,18 +1214,18 @@  discard block
 block discarded – undo
1149 1214
 				// MySQLi requires a connection object. It's optional with MySQL and Postgres
1150 1215
 				$incontext['failures'][$count] = $smcFunc['db_error']($db_connection);
1151 1216
 			}
1152
-		}
1153
-		else
1217
+		} else
1154 1218
 		{
1155
-			if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1)
1156
-				$incontext['sql_results']['tables']++;
1157
-			elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1)
1219
+			if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) {
1220
+							$incontext['sql_results']['tables']++;
1221
+			} elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1)
1158 1222
 			{
1159 1223
 				preg_match_all('~\)[,;]~', $current_statement, $matches);
1160
-				if (!empty($matches[0]))
1161
-					$incontext['sql_results']['inserts'] += count($matches[0]);
1162
-				else
1163
-					$incontext['sql_results']['inserts']++;
1224
+				if (!empty($matches[0])) {
1225
+									$incontext['sql_results']['inserts'] += count($matches[0]);
1226
+				} else {
1227
+									$incontext['sql_results']['inserts']++;
1228
+				}
1164 1229
 			}
1165 1230
 		}
1166 1231
 
@@ -1173,15 +1238,17 @@  discard block
 block discarded – undo
1173 1238
 	// Sort out the context for the SQL.
1174 1239
 	foreach ($incontext['sql_results'] as $key => $number)
1175 1240
 	{
1176
-		if ($number == 0)
1177
-			unset($incontext['sql_results'][$key]);
1178
-		else
1179
-			$incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number);
1241
+		if ($number == 0) {
1242
+					unset($incontext['sql_results'][$key]);
1243
+		} else {
1244
+					$incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number);
1245
+		}
1180 1246
 	}
1181 1247
 
1182 1248
 	// Make sure UTF will be used globally.
1183
-	if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8'])))
1184
-		$newSettings[] = array('global_character_set', 'UTF-8');
1249
+	if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8']))) {
1250
+			$newSettings[] = array('global_character_set', 'UTF-8');
1251
+	}
1185 1252
 
1186 1253
 	// Maybe we can auto-detect better cookie settings?
1187 1254
 	preg_match('~^http[s]?://([^\.]+?)([^/]*?)(/.*)?$~', $boardurl, $matches);
@@ -1192,16 +1259,20 @@  discard block
 block discarded – undo
1192 1259
 		$globalCookies = false;
1193 1260
 
1194 1261
 		// Okay... let's see.  Using a subdomain other than www.? (not a perfect check.)
1195
-		if ($matches[2] != '' && (strpos(substr($matches[2], 1), '.') === false || in_array($matches[1], array('forum', 'board', 'community', 'forums', 'support', 'chat', 'help', 'talk', 'boards', 'www'))))
1196
-			$globalCookies = true;
1262
+		if ($matches[2] != '' && (strpos(substr($matches[2], 1), '.') === false || in_array($matches[1], array('forum', 'board', 'community', 'forums', 'support', 'chat', 'help', 'talk', 'boards', 'www')))) {
1263
+					$globalCookies = true;
1264
+		}
1197 1265
 		// If there's a / in the middle of the path, or it starts with ~... we want local.
1198
-		if (isset($matches[3]) && strlen($matches[3]) > 3 && (substr($matches[3], 0, 2) == '/~' || strpos(substr($matches[3], 1), '/') !== false))
1199
-			$localCookies = true;
1266
+		if (isset($matches[3]) && strlen($matches[3]) > 3 && (substr($matches[3], 0, 2) == '/~' || strpos(substr($matches[3], 1), '/') !== false)) {
1267
+					$localCookies = true;
1268
+		}
1200 1269
 
1201
-		if ($globalCookies)
1202
-			$newSettings[] = array('globalCookies', '1');
1203
-		if ($localCookies)
1204
-			$newSettings[] = array('localCookies', '1');
1270
+		if ($globalCookies) {
1271
+					$newSettings[] = array('globalCookies', '1');
1272
+		}
1273
+		if ($localCookies) {
1274
+					$newSettings[] = array('localCookies', '1');
1275
+		}
1205 1276
 	}
1206 1277
 
1207 1278
 	// Are we allowing stat collection?
@@ -1217,32 +1288,36 @@  discard block
 block discarded – undo
1217 1288
 			fwrite($fp, $out);
1218 1289
 
1219 1290
 			$return_data = '';
1220
-			while (!feof($fp))
1221
-				$return_data .= fgets($fp, 128);
1291
+			while (!feof($fp)) {
1292
+							$return_data .= fgets($fp, 128);
1293
+			}
1222 1294
 
1223 1295
 			fclose($fp);
1224 1296
 
1225 1297
 			// Get the unique site ID.
1226 1298
 			preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID);
1227 1299
 
1228
-			if (!empty($ID[1]))
1229
-				$newSettings[] = array('allow_sm_stats', $ID[1]);
1300
+			if (!empty($ID[1])) {
1301
+							$newSettings[] = array('allow_sm_stats', $ID[1]);
1302
+			}
1230 1303
 		}
1231 1304
 	}
1232 1305
 
1233 1306
 	// Are we enabling SSL?
1234
-	if (!empty($_POST['force_ssl']))
1235
-		$newSettings[] = array('force_ssl', 2);
1307
+	if (!empty($_POST['force_ssl'])) {
1308
+			$newSettings[] = array('force_ssl', 2);
1309
+	}
1236 1310
 
1237 1311
 	// Setting a timezone is required.
1238 1312
 	if (!isset($modSettings['default_timezone']) && function_exists('date_default_timezone_set'))
1239 1313
 	{
1240 1314
 		// Get PHP's default timezone, if set
1241 1315
 		$ini_tz = ini_get('date.timezone');
1242
-		if (!empty($ini_tz))
1243
-			$timezone_id = $ini_tz;
1244
-		else
1245
-			$timezone_id = '';
1316
+		if (!empty($ini_tz)) {
1317
+					$timezone_id = $ini_tz;
1318
+		} else {
1319
+					$timezone_id = '';
1320
+		}
1246 1321
 
1247 1322
 		// If date.timezone is unset, invalid, or just plain weird, make a best guess
1248 1323
 		if (!in_array($timezone_id, timezone_identifiers_list()))
@@ -1251,8 +1326,9 @@  discard block
 block discarded – undo
1251 1326
 			$timezone_id = timezone_name_from_abbr('', $server_offset, 0);
1252 1327
 		}
1253 1328
 
1254
-		if (date_default_timezone_set($timezone_id))
1255
-			$newSettings[] = array('default_timezone', $timezone_id);
1329
+		if (date_default_timezone_set($timezone_id)) {
1330
+					$newSettings[] = array('default_timezone', $timezone_id);
1331
+		}
1256 1332
 	}
1257 1333
 
1258 1334
 	if (!empty($newSettings))
@@ -1283,16 +1359,18 @@  discard block
 block discarded – undo
1283 1359
 	}
1284 1360
 
1285 1361
 	// MySQL specific stuff
1286
-	if (substr($db_type, 0, 5) != 'mysql')
1287
-		return false;
1362
+	if (substr($db_type, 0, 5) != 'mysql') {
1363
+			return false;
1364
+	}
1288 1365
 
1289 1366
 	// Find database user privileges.
1290 1367
 	$privs = array();
1291 1368
 	$get_privs = $smcFunc['db_query']('', 'SHOW PRIVILEGES', array());
1292 1369
 	while ($row = $smcFunc['db_fetch_assoc']($get_privs))
1293 1370
 	{
1294
-		if ($row['Privilege'] == 'Alter')
1295
-			$privs[] = $row['Privilege'];
1371
+		if ($row['Privilege'] == 'Alter') {
1372
+					$privs[] = $row['Privilege'];
1373
+		}
1296 1374
 	}
1297 1375
 	$smcFunc['db_free_result']($get_privs);
1298 1376
 
@@ -1322,8 +1400,9 @@  discard block
 block discarded – undo
1322 1400
 	$incontext['continue'] = 1;
1323 1401
 
1324 1402
 	// Skipping?
1325
-	if (!empty($_POST['skip']))
1326
-		return true;
1403
+	if (!empty($_POST['skip'])) {
1404
+			return true;
1405
+	}
1327 1406
 
1328 1407
 	// Need this to check whether we need the database password.
1329 1408
 	require(dirname(__FILE__) . '/Settings.php');
@@ -1336,18 +1415,22 @@  discard block
 block discarded – undo
1336 1415
 	// We need this to properly hash the password for Admin
1337 1416
 	$smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) {
1338 1417
 			global $sourcedir;
1339
-			if (function_exists('mb_strtolower'))
1340
-				return mb_strtolower($string, 'UTF-8');
1418
+			if (function_exists('mb_strtolower')) {
1419
+							return mb_strtolower($string, 'UTF-8');
1420
+			}
1341 1421
 			require_once($sourcedir . '/Subs-Charset.php');
1342 1422
 			return utf8_strtolower($string);
1343 1423
 		};
1344 1424
 
1345
-	if (!isset($_POST['username']))
1346
-		$_POST['username'] = '';
1347
-	if (!isset($_POST['email']))
1348
-		$_POST['email'] = '';
1349
-	if (!isset($_POST['server_email']))
1350
-		$_POST['server_email'] = '';
1425
+	if (!isset($_POST['username'])) {
1426
+			$_POST['username'] = '';
1427
+	}
1428
+	if (!isset($_POST['email'])) {
1429
+			$_POST['email'] = '';
1430
+	}
1431
+	if (!isset($_POST['server_email'])) {
1432
+			$_POST['server_email'] = '';
1433
+	}
1351 1434
 
1352 1435
 	$incontext['username'] = htmlspecialchars(stripslashes($_POST['username']));
1353 1436
 	$incontext['email'] = htmlspecialchars(stripslashes($_POST['email']));
@@ -1366,8 +1449,9 @@  discard block
 block discarded – undo
1366 1449
 			'admin_group' => 1,
1367 1450
 		)
1368 1451
 	);
1369
-	if ($smcFunc['db_num_rows']($request) != 0)
1370
-		$incontext['skip'] = 1;
1452
+	if ($smcFunc['db_num_rows']($request) != 0) {
1453
+			$incontext['skip'] = 1;
1454
+	}
1371 1455
 	$smcFunc['db_free_result']($request);
1372 1456
 
1373 1457
 	// Trying to create an account?
@@ -1398,8 +1482,9 @@  discard block
 block discarded – undo
1398 1482
 		}
1399 1483
 
1400 1484
 		// Update the webmaster's email?
1401
-		if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]'))
1402
-			updateSettingsFile(array('webmaster_email' => $_POST['server_email']));
1485
+		if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) {
1486
+					updateSettingsFile(array('webmaster_email' => $_POST['server_email']));
1487
+		}
1403 1488
 
1404 1489
 		// Work out whether we're going to have dodgy characters and remove them.
1405 1490
 		$invalid_characters = preg_match('~[<>&"\'=\\\]~', $_POST['username']) != 0;
@@ -1422,32 +1507,27 @@  discard block
 block discarded – undo
1422 1507
 			$smcFunc['db_free_result']($result);
1423 1508
 
1424 1509
 			$incontext['account_existed'] = $txt['error_user_settings_taken'];
1425
-		}
1426
-		elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25)
1510
+		} elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25)
1427 1511
 		{
1428 1512
 			// Try the previous step again.
1429 1513
 			$incontext['error'] = $_POST['username'] == '' ? $txt['error_username_left_empty'] : $txt['error_username_too_long'];
1430 1514
 			return false;
1431
-		}
1432
-		elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false)
1515
+		} elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false)
1433 1516
 		{
1434 1517
 			// Try the previous step again.
1435 1518
 			$incontext['error'] = $txt['error_invalid_characters_username'];
1436 1519
 			return false;
1437
-		}
1438
-		elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255)
1520
+		} elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255)
1439 1521
 		{
1440 1522
 			// One step back, this time fill out a proper admin email address.
1441 1523
 			$incontext['error'] = sprintf($txt['error_valid_admin_email_needed'], $_POST['username']);
1442 1524
 			return false;
1443
-		}
1444
-		elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255)
1525
+		} elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255)
1445 1526
 		{
1446 1527
 			// One step back, this time fill out a proper admin email address.
1447 1528
 			$incontext['error'] = $txt['error_valid_server_email_needed'];
1448 1529
 			return false;
1449
-		}
1450
-		elseif ($_POST['username'] != '')
1530
+		} elseif ($_POST['username'] != '')
1451 1531
 		{
1452 1532
 			$incontext['member_salt'] = substr(md5(mt_rand()), 0, 4);
1453 1533
 
@@ -1513,17 +1593,19 @@  discard block
 block discarded – undo
1513 1593
 	require_once($sourcedir . '/Subs-Auth.php');
1514 1594
 
1515 1595
 	// Bring a warning over.
1516
-	if (!empty($incontext['account_existed']))
1517
-		$incontext['warning'] = $incontext['account_existed'];
1596
+	if (!empty($incontext['account_existed'])) {
1597
+			$incontext['warning'] = $incontext['account_existed'];
1598
+	}
1518 1599
 
1519
-	if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support']))
1520
-		$smcFunc['db_query']('', '
1600
+	if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) {
1601
+			$smcFunc['db_query']('', '
1521 1602
 			SET NAMES {string:db_character_set}',
1522 1603
 			array(
1523 1604
 				'db_character_set' => $db_character_set,
1524 1605
 				'db_error_skip' => true,
1525 1606
 			)
1526 1607
 		);
1608
+	}
1527 1609
 
1528 1610
 	// As track stats is by default enabled let's add some activity.
1529 1611
 	$smcFunc['db_insert']('ignore',
@@ -1544,14 +1626,16 @@  discard block
 block discarded – undo
1544 1626
 	// Only proceed if we can load the data.
1545 1627
 	if ($request)
1546 1628
 	{
1547
-		while ($row = $smcFunc['db_fetch_row']($request))
1548
-			$modSettings[$row[0]] = $row[1];
1629
+		while ($row = $smcFunc['db_fetch_row']($request)) {
1630
+					$modSettings[$row[0]] = $row[1];
1631
+		}
1549 1632
 		$smcFunc['db_free_result']($request);
1550 1633
 	}
1551 1634
 
1552 1635
 	// Automatically log them in ;)
1553
-	if (isset($incontext['member_id']) && isset($incontext['member_salt']))
1554
-		setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt']));
1636
+	if (isset($incontext['member_id']) && isset($incontext['member_salt'])) {
1637
+			setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt']));
1638
+	}
1555 1639
 
1556 1640
 	$result = $smcFunc['db_query']('', '
1557 1641
 		SELECT value
@@ -1562,13 +1646,14 @@  discard block
 block discarded – undo
1562 1646
 			'db_error_skip' => true,
1563 1647
 		)
1564 1648
 	);
1565
-	if ($smcFunc['db_num_rows']($result) != 0)
1566
-		list ($db_sessions) = $smcFunc['db_fetch_row']($result);
1649
+	if ($smcFunc['db_num_rows']($result) != 0) {
1650
+			list ($db_sessions) = $smcFunc['db_fetch_row']($result);
1651
+	}
1567 1652
 	$smcFunc['db_free_result']($result);
1568 1653
 
1569
-	if (empty($db_sessions))
1570
-		$_SESSION['admin_time'] = time();
1571
-	else
1654
+	if (empty($db_sessions)) {
1655
+			$_SESSION['admin_time'] = time();
1656
+	} else
1572 1657
 	{
1573 1658
 		$_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211);
1574 1659
 
@@ -1592,8 +1677,9 @@  discard block
 block discarded – undo
1592 1677
 	$smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' :
1593 1678
 		function($string){
1594 1679
 			global $sourcedir;
1595
-			if (function_exists('mb_strtolower'))
1596
-				return mb_strtolower($string, 'UTF-8');
1680
+			if (function_exists('mb_strtolower')) {
1681
+							return mb_strtolower($string, 'UTF-8');
1682
+			}
1597 1683
 			require_once($sourcedir . '/Subs-Charset.php');
1598 1684
 			return utf8_strtolower($string);
1599 1685
 		};
@@ -1609,8 +1695,9 @@  discard block
 block discarded – undo
1609 1695
 		)
1610 1696
 	);
1611 1697
 	$context['utf8'] = $db_character_set === 'utf8' || $txt['lang_character_set'] === 'UTF-8';
1612
-	if ($smcFunc['db_num_rows']($request) > 0)
1613
-		updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject']));
1698
+	if ($smcFunc['db_num_rows']($request) > 0) {
1699
+			updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject']));
1700
+	}
1614 1701
 	$smcFunc['db_free_result']($request);
1615 1702
 
1616 1703
 	// Now is the perfect time to fetch the SM files.
@@ -1629,8 +1716,9 @@  discard block
 block discarded – undo
1629 1716
 
1630 1717
 	// Check if we need some stupid MySQL fix.
1631 1718
 	$server_version = $smcFunc['db_server_info']();
1632
-	if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51')))
1633
-		updateSettings(array('db_mysql_group_by_fix' => '1'));
1719
+	if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) {
1720
+			updateSettings(array('db_mysql_group_by_fix' => '1'));
1721
+	}
1634 1722
 
1635 1723
 	// Some final context for the template.
1636 1724
 	$incontext['dir_still_writable'] = is_writable(dirname(__FILE__)) && substr(__FILE__, 1, 2) != ':\\';
@@ -1650,8 +1738,9 @@  discard block
 block discarded – undo
1650 1738
 	$settingsArray = file(dirname(__FILE__) . '/Settings.php');
1651 1739
 
1652 1740
 	// @todo Do we just want to read the file in clean, and split it this way always?
1653
-	if (count($settingsArray) == 1)
1654
-		$settingsArray = preg_split('~[\r\n]~', $settingsArray[0]);
1741
+	if (count($settingsArray) == 1) {
1742
+			$settingsArray = preg_split('~[\r\n]~', $settingsArray[0]);
1743
+	}
1655 1744
 
1656 1745
 	for ($i = 0, $n = count($settingsArray); $i < $n; $i++)
1657 1746
 	{
@@ -1666,19 +1755,22 @@  discard block
 block discarded – undo
1666 1755
 			continue;
1667 1756
 		}
1668 1757
 
1669
-		if (trim($settingsArray[$i]) == '?' . '>')
1670
-			$settingsArray[$i] = '';
1758
+		if (trim($settingsArray[$i]) == '?' . '>') {
1759
+					$settingsArray[$i] = '';
1760
+		}
1671 1761
 
1672 1762
 		// Don't trim or bother with it if it's not a variable.
1673
-		if (substr($settingsArray[$i], 0, 1) != '$')
1674
-			continue;
1763
+		if (substr($settingsArray[$i], 0, 1) != '$') {
1764
+					continue;
1765
+		}
1675 1766
 
1676 1767
 		$settingsArray[$i] = rtrim($settingsArray[$i]) . "\n";
1677 1768
 
1678
-		foreach ($vars as $var => $val)
1679
-			if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0)
1769
+		foreach ($vars as $var => $val) {
1770
+					if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0)
1680 1771
 			{
1681 1772
 				$comment = strstr($settingsArray[$i], '#');
1773
+		}
1682 1774
 				$settingsArray[$i] = '$' . $var . ' = \'' . $val . '\';' . ($comment != '' ? "\t\t" . $comment : "\n");
1683 1775
 				unset($vars[$var]);
1684 1776
 			}
@@ -1688,36 +1780,41 @@  discard block
 block discarded – undo
1688 1780
 	if (!empty($vars))
1689 1781
 	{
1690 1782
 		$settingsArray[$i++] = '';
1691
-		foreach ($vars as $var => $val)
1692
-			$settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n";
1783
+		foreach ($vars as $var => $val) {
1784
+					$settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n";
1785
+		}
1693 1786
 	}
1694 1787
 
1695 1788
 	// Blank out the file - done to fix a oddity with some servers.
1696 1789
 	$fp = @fopen(dirname(__FILE__) . '/Settings.php', 'w');
1697
-	if (!$fp)
1698
-		return false;
1790
+	if (!$fp) {
1791
+			return false;
1792
+	}
1699 1793
 	fclose($fp);
1700 1794
 
1701 1795
 	$fp = fopen(dirname(__FILE__) . '/Settings.php', 'r+');
1702 1796
 
1703 1797
 	// Gotta have one of these ;)
1704
-	if (trim($settingsArray[0]) != '<?php')
1705
-		fwrite($fp, "<?php\n");
1798
+	if (trim($settingsArray[0]) != '<?php') {
1799
+			fwrite($fp, "<?php\n");
1800
+	}
1706 1801
 
1707 1802
 	$lines = count($settingsArray);
1708 1803
 	for ($i = 0; $i < $lines - 1; $i++)
1709 1804
 	{
1710 1805
 		// Don't just write a bunch of blank lines.
1711
-		if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '')
1712
-			fwrite($fp, strtr($settingsArray[$i], "\r", ''));
1806
+		if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') {
1807
+					fwrite($fp, strtr($settingsArray[$i], "\r", ''));
1808
+		}
1713 1809
 	}
1714 1810
 	fwrite($fp, $settingsArray[$i] . '?' . '>');
1715 1811
 	fclose($fp);
1716 1812
 
1717 1813
 	// Even though on normal installations the filemtime should prevent this being used by the installer incorrectly
1718 1814
 	// it seems that there are times it might not. So let's MAKE it dump the cache.
1719
-	if (function_exists('opcache_invalidate'))
1720
-		opcache_invalidate(dirname(__FILE__) . '/Settings.php', true);
1815
+	if (function_exists('opcache_invalidate')) {
1816
+			opcache_invalidate(dirname(__FILE__) . '/Settings.php', true);
1817
+	}
1721 1818
 
1722 1819
 	return true;
1723 1820
 }
@@ -1742,9 +1839,9 @@  discard block
 block discarded – undo
1742 1839
 	SecFilterScanPOST Off
1743 1840
 </IfModule>';
1744 1841
 
1745
-	if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules()))
1746
-		return true;
1747
-	elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess'))
1842
+	if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) {
1843
+			return true;
1844
+	} elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess'))
1748 1845
 	{
1749 1846
 		$current_htaccess = implode('', file(dirname(__FILE__) . '/.htaccess'));
1750 1847
 
@@ -1756,29 +1853,28 @@  discard block
 block discarded – undo
1756 1853
 				fwrite($ht_handle, $htaccess_addition);
1757 1854
 				fclose($ht_handle);
1758 1855
 				return true;
1856
+			} else {
1857
+							return false;
1759 1858
 			}
1760
-			else
1761
-				return false;
1859
+		} else {
1860
+					return true;
1762 1861
 		}
1763
-		else
1764
-			return true;
1765
-	}
1766
-	elseif (file_exists(dirname(__FILE__) . '/.htaccess'))
1767
-		return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false;
1768
-	elseif (is_writable(dirname(__FILE__)))
1862
+	} elseif (file_exists(dirname(__FILE__) . '/.htaccess')) {
1863
+			return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false;
1864
+	} elseif (is_writable(dirname(__FILE__)))
1769 1865
 	{
1770 1866
 		if ($ht_handle = fopen(dirname(__FILE__) . '/.htaccess', 'w'))
1771 1867
 		{
1772 1868
 			fwrite($ht_handle, $htaccess_addition);
1773 1869
 			fclose($ht_handle);
1774 1870
 			return true;
1871
+		} else {
1872
+					return false;
1775 1873
 		}
1776
-		else
1874
+	} else {
1777 1875
 			return false;
1778 1876
 	}
1779
-	else
1780
-		return false;
1781
-}
1877
+	}
1782 1878
 
1783 1879
 function template_install_above()
1784 1880
 {
@@ -1816,9 +1912,10 @@  discard block
 block discarded – undo
1816 1912
 								<label for="installer_language">', $txt['installer_language'], ':</label>
1817 1913
 								<select id="installer_language" name="lang_file" onchange="location.href = \'', $installurl, '?lang_file=\' + this.options[this.selectedIndex].value;">';
1818 1914
 
1819
-		foreach ($incontext['detected_languages'] as $lang => $name)
1820
-			echo '
1915
+		foreach ($incontext['detected_languages'] as $lang => $name) {
1916
+					echo '
1821 1917
 									<option', isset($_SESSION['installer_temp_lang']) && $_SESSION['installer_temp_lang'] == $lang ? ' selected' : '', ' value="', $lang, '">', $name, '</option>';
1918
+		}
1822 1919
 
1823 1920
 		echo '
1824 1921
 								</select>
@@ -1838,9 +1935,10 @@  discard block
 block discarded – undo
1838 1935
 						<h2>', $txt['upgrade_progress'], '</h2>
1839 1936
 						<ul>';
1840 1937
 
1841
-	foreach ($incontext['steps'] as $num => $step)
1842
-		echo '
1938
+	foreach ($incontext['steps'] as $num => $step) {
1939
+			echo '
1843 1940
 							<li class="', $num < $incontext['current_step'] ? 'stepdone' : ($num == $incontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>';
1941
+	}
1844 1942
 
1845 1943
 	echo '
1846 1944
 						</ul>
@@ -1865,20 +1963,23 @@  discard block
 block discarded – undo
1865 1963
 		echo '
1866 1964
 								<div>';
1867 1965
 
1868
-		if (!empty($incontext['continue']))
1869
-			echo '
1966
+		if (!empty($incontext['continue'])) {
1967
+					echo '
1870 1968
 									<input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '" onclick="return submitThisOnce(this);" class="button_submit" />';
1871
-		if (!empty($incontext['skip']))
1872
-			echo '
1969
+		}
1970
+		if (!empty($incontext['skip'])) {
1971
+					echo '
1873 1972
 									<input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="return submitThisOnce(this);" class="button_submit" />';
1973
+		}
1874 1974
 		echo '
1875 1975
 								</div>';
1876 1976
 	}
1877 1977
 
1878 1978
 	// Show the closing form tag and other data only if not in the last step
1879
-	if (count($incontext['steps']) - 1 !== (int) $incontext['current_step'])
1880
-		echo '
1979
+	if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) {
1980
+			echo '
1881 1981
 							</form>';
1982
+	}
1882 1983
 
1883 1984
 	echo '
1884 1985
 						</div>
@@ -1913,13 +2014,15 @@  discard block
 block discarded – undo
1913 2014
 		</div>';
1914 2015
 
1915 2016
 	// Show the warnings, or not.
1916
-	if (template_warning_divs())
1917
-		echo '
2017
+	if (template_warning_divs()) {
2018
+			echo '
1918 2019
 		<h3>', $txt['install_all_lovely'], '</h3>';
2020
+	}
1919 2021
 
1920 2022
 	// Say we want the continue button!
1921
-	if (empty($incontext['error']))
1922
-		$incontext['continue'] = 1;
2023
+	if (empty($incontext['error'])) {
2024
+			$incontext['continue'] = 1;
2025
+	}
1923 2026
 
1924 2027
 	// For the latest version stuff.
1925 2028
 	echo '
@@ -1953,8 +2056,8 @@  discard block
 block discarded – undo
1953 2056
 	global $txt, $incontext;
1954 2057
 
1955 2058
 	// Errors are very serious..
1956
-	if (!empty($incontext['error']))
1957
-		echo '
2059
+	if (!empty($incontext['error'])) {
2060
+			echo '
1958 2061
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
1959 2062
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
1960 2063
 			<strong style="text-decoration: underline;">', $txt['upgrade_critical_error'], '</strong><br>
@@ -1962,9 +2065,10 @@  discard block
 block discarded – undo
1962 2065
 				', $incontext['error'], '
1963 2066
 			</div>
1964 2067
 		</div>';
2068
+	}
1965 2069
 	// A warning message?
1966
-	elseif (!empty($incontext['warning']))
1967
-		echo '
2070
+	elseif (!empty($incontext['warning'])) {
2071
+			echo '
1968 2072
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
1969 2073
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
1970 2074
 			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br>
@@ -1972,6 +2076,7 @@  discard block
 block discarded – undo
1972 2076
 				', $incontext['warning'], '
1973 2077
 			</div>
1974 2078
 		</div>';
2079
+	}
1975 2080
 
1976 2081
 	return empty($incontext['error']) && empty($incontext['warning']);
1977 2082
 }
@@ -1987,27 +2092,30 @@  discard block
 block discarded – undo
1987 2092
 			<li>', $incontext['failed_files']), '</li>
1988 2093
 		</ul>';
1989 2094
 
1990
-	if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux')
1991
-		echo '
2095
+	if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') {
2096
+			echo '
1992 2097
 		<hr>
1993 2098
 		<p>', $txt['chmod_linux_info'], '</p>
1994 2099
 		<tt># chmod a+w ', implode(' ' . $incontext['detected_path'] . '/', $incontext['failed_files']), '</tt>';
2100
+	}
1995 2101
 
1996 2102
 	// This is serious!
1997
-	if (!template_warning_divs())
1998
-		return;
2103
+	if (!template_warning_divs()) {
2104
+			return;
2105
+	}
1999 2106
 
2000 2107
 	echo '
2001 2108
 		<hr>
2002 2109
 		<p>', $txt['ftp_setup_info'], '</p>';
2003 2110
 
2004
-	if (!empty($incontext['ftp_errors']))
2005
-		echo '
2111
+	if (!empty($incontext['ftp_errors'])) {
2112
+			echo '
2006 2113
 		<div class="error_message">
2007 2114
 			', $txt['error_ftp_no_connect'], '<br><br>
2008 2115
 			<code>', implode('<br>', $incontext['ftp_errors']), '</code>
2009 2116
 		</div>
2010 2117
 		<br>';
2118
+	}
2011 2119
 
2012 2120
 	echo '
2013 2121
 		<form action="', $incontext['form_url'], '" method="post">
@@ -2067,17 +2175,17 @@  discard block
 block discarded – undo
2067 2175
 				<td>
2068 2176
 					<select name="db_type" id="db_type_input" onchange="toggleDBInput();">';
2069 2177
 
2070
-	foreach ($incontext['supported_databases'] as $key => $db)
2071
-			echo '
2178
+	foreach ($incontext['supported_databases'] as $key => $db) {
2179
+				echo '
2072 2180
 						<option value="', $key, '"', isset($_POST['db_type']) && $_POST['db_type'] == $key ? ' selected' : '', '>', $db['name'], '</option>';
2181
+	}
2073 2182
 
2074 2183
 	echo '
2075 2184
 					</select>
2076 2185
 					<div class="smalltext block">', $txt['db_settings_type_info'], '</div>
2077 2186
 				</td>
2078 2187
 			</tr>';
2079
-	}
2080
-	else
2188
+	} else
2081 2189
 	{
2082 2190
 		echo '
2083 2191
 			<tr style="display: none;">
@@ -2269,9 +2377,10 @@  discard block
 block discarded – undo
2269 2377
 				<div style="color: red;">', $txt['error_db_queries'], '</div>
2270 2378
 				<ul>';
2271 2379
 
2272
-		foreach ($incontext['failures'] as $line => $fail)
2273
-			echo '
2380
+		foreach ($incontext['failures'] as $line => $fail) {
2381
+					echo '
2274 2382
 						<li><strong>', $txt['error_db_queries_line'], $line + 1, ':</strong> ', nl2br(htmlspecialchars($fail)), '</li>';
2383
+		}
2275 2384
 
2276 2385
 		echo '
2277 2386
 				</ul>';
@@ -2332,15 +2441,16 @@  discard block
 block discarded – undo
2332 2441
 			</tr>
2333 2442
 		</table>';
2334 2443
 
2335
-	if ($incontext['require_db_confirm'])
2336
-		echo '
2444
+	if ($incontext['require_db_confirm']) {
2445
+			echo '
2337 2446
 		<h2>', $txt['user_settings_database'], '</h2>
2338 2447
 		<p>', $txt['user_settings_database_info'], '</p>
2339 2448
 
2340 2449
 		<div style="margin-bottom: 2ex; padding-', $txt['lang_rtl'] == false ? 'left' : 'right', ': 50px;">
2341 2450
 			<input type="password" name="password3" size="30" class="input_password" />
2342 2451
 		</div>';
2343
-}
2452
+	}
2453
+	}
2344 2454
 
2345 2455
 // Tell them it's done, and to delete.
2346 2456
 function template_delete_install()
@@ -2353,14 +2463,15 @@  discard block
 block discarded – undo
2353 2463
 	template_warning_divs();
2354 2464
 
2355 2465
 	// Install directory still writable?
2356
-	if ($incontext['dir_still_writable'])
2357
-		echo '
2466
+	if ($incontext['dir_still_writable']) {
2467
+			echo '
2358 2468
 		<em>', $txt['still_writable'], '</em><br>
2359 2469
 		<br>';
2470
+	}
2360 2471
 
2361 2472
 	// Don't show the box if it's like 99% sure it won't work :P.
2362
-	if ($incontext['probably_delete_install'])
2363
-		echo '
2473
+	if ($incontext['probably_delete_install']) {
2474
+			echo '
2364 2475
 		<div style="margin: 1ex; font-weight: bold;">
2365 2476
 			<label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete();" class="input_check" /> ', $txt['delete_installer'], !isset($_SESSION['installer_temp_ftp']) ? ' ' . $txt['delete_installer_maybe'] : '', '</label>
2366 2477
 		</div>
@@ -2376,6 +2487,7 @@  discard block
 block discarded – undo
2376 2487
 			}
2377 2488
 		</script>
2378 2489
 		<br>';
2490
+	}
2379 2491
 
2380 2492
 	echo '
2381 2493
 		', sprintf($txt['go_to_your_forum'], $boardurl . '/index.php'), '<br>
Please login to merge, or discard this patch.
index.php 2 patches
Braces   +37 added lines, -25 removed lines patch added patch discarded remove patch
@@ -25,8 +25,9 @@  discard block
 block discarded – undo
25 25
 
26 26
 // Get everything started up...
27 27
 define('SMF', 1);
28
-if (function_exists('set_magic_quotes_runtime') && strnatcmp(phpversion(), '5.3.0') < 0)
28
+if (function_exists('set_magic_quotes_runtime') && strnatcmp(phpversion(), '5.3.0') < 0) {
29 29
 	@set_magic_quotes_runtime(0);
30
+}
30 31
 error_reporting(defined('E_STRICT') ? E_ALL | E_STRICT : E_ALL);
31 32
 $time_start = microtime();
32 33
 
@@ -34,16 +35,18 @@  discard block
 block discarded – undo
34 35
 ob_start();
35 36
 
36 37
 // Do some cleaning, just in case.
37
-foreach (array('db_character_set', 'cachedir') as $variable)
38
+foreach (array('db_character_set', 'cachedir') as $variable) {
38 39
 	if (isset($GLOBALS[$variable]))
39 40
 		unset($GLOBALS[$variable], $GLOBALS[$variable]);
41
+}
40 42
 
41 43
 // Load the settings...
42 44
 require_once(dirname(__FILE__) . '/Settings.php');
43 45
 
44 46
 // Make absolutely sure the cache directory is defined.
45
-if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache'))
47
+if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) {
46 48
 	$cachedir = $boarddir . '/cache';
49
+}
47 50
 
48 51
 // Without those we can't go anywhere
49 52
 require_once($sourcedir . '/QueryString.php');
@@ -53,8 +56,9 @@  discard block
 block discarded – undo
53 56
 require_once($sourcedir . '/Load.php');
54 57
 
55 58
 // If $maintenance is set specifically to 2, then we're upgrading or something.
56
-if (!empty($maintenance) && $maintenance == 2)
59
+if (!empty($maintenance) && $maintenance == 2) {
57 60
 	display_maintenance_message();
61
+}
58 62
 
59 63
 // Create a variable to store some SMF specific functions in.
60 64
 $smcFunc = array();
@@ -69,8 +73,9 @@  discard block
 block discarded – undo
69 73
 cleanRequest();
70 74
 
71 75
 // Seed the random generator.
72
-if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69)
76
+if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) {
73 77
 	smf_seed_generator();
78
+}
74 79
 
75 80
 // Before we get carried away, are we doing a scheduled task? If so save CPU cycles by jumping out!
76 81
 if (isset($_GET['scheduled']))
@@ -90,9 +95,9 @@  discard block
 block discarded – undo
90 95
 if (!empty($modSettings['enableCompressedOutput']) && !headers_sent())
91 96
 {
92 97
 	// If zlib is being used, turn off output compression.
93
-	if (ini_get('zlib.output_compression') >= 1 || ini_get('output_handler') == 'ob_gzhandler')
94
-		$modSettings['enableCompressedOutput'] = '0';
95
-	else
98
+	if (ini_get('zlib.output_compression') >= 1 || ini_get('output_handler') == 'ob_gzhandler') {
99
+			$modSettings['enableCompressedOutput'] = '0';
100
+	} else
96 101
 	{
97 102
 		ob_end_clean();
98 103
 		ob_start('ob_gzhandler');
@@ -141,18 +146,21 @@  discard block
 block discarded – undo
141 146
 	loadPermissions();
142 147
 
143 148
 	// Attachments don't require the entire theme to be loaded.
144
-	if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach')
145
-		detectBrowser();
149
+	if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach') {
150
+			detectBrowser();
151
+	}
146 152
 	// Load the current theme.  (note that ?theme=1 will also work, may be used for guest theming.)
147
-	else
148
-		loadTheme();
153
+	else {
154
+			loadTheme();
155
+	}
149 156
 
150 157
 	// Check if the user should be disallowed access.
151 158
 	is_not_banned();
152 159
 
153 160
 	// If we are in a topic and don't have permission to approve it then duck out now.
154
-	if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest']))
155
-		fatal_lang_error('not_a_topic', false);
161
+	if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest'])) {
162
+			fatal_lang_error('not_a_topic', false);
163
+	}
156 164
 
157 165
 	$no_stat_actions = array('clock', 'dlattach', 'findmember', 'jsoption', 'likes', 'loadeditorlocale', 'modifycat', 'requestmembers', 'smstats', 'suggest', 'about:unknown', '.xml', 'xmlhttp', 'verificationcode', 'viewquery', 'viewsmfile');
158 166
 	call_integration_hook('integrate_pre_log_stats', array(&$no_stat_actions));
@@ -163,8 +171,9 @@  discard block
 block discarded – undo
163 171
 		writeLog();
164 172
 
165 173
 		// Track forum statistics and hits...?
166
-		if (!empty($modSettings['hitStats']))
167
-			trackStats(array('hits' => '+'));
174
+		if (!empty($modSettings['hitStats'])) {
175
+					trackStats(array('hits' => '+'));
176
+		}
168 177
 	}
169 178
 	unset($no_stat_actions);
170 179
 
@@ -178,13 +187,14 @@  discard block
 block discarded – undo
178 187
 			return ($_REQUEST['action'] == 'login2' ? 'Login2' : ($_REQUEST['action'] == 'logintfa' ? 'LoginTFA' : 'Logout'));
179 188
 		}
180 189
 		// Don't even try it, sonny.
181
-		else
182
-			return 'InMaintenance';
190
+		else {
191
+					return 'InMaintenance';
192
+		}
183 193
 	}
184 194
 	// If guest access is off, a guest can only do one of the very few following actions.
185
-	elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'logintfa', 'reminder', 'activate', 'help', 'helpadmin', 'smstats', 'verificationcode', 'signup', 'signup2'))))
186
-		return 'KickGuest';
187
-	elseif (empty($_REQUEST['action']))
195
+	elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'logintfa', 'reminder', 'activate', 'help', 'helpadmin', 'smstats', 'verificationcode', 'signup', 'signup2')))) {
196
+			return 'KickGuest';
197
+	} elseif (empty($_REQUEST['action']))
188 198
 	{
189 199
 		// Action and board are both empty... BoardIndex! Unless someone else wants to do something different.
190 200
 		if (empty($board) && empty($topic))
@@ -200,8 +210,9 @@  discard block
 block discarded – undo
200 210
 
201 211
 				$call = call_helper($defaultAction, true);
202 212
 
203
-				if (!empty($call))
204
-					return $call;
213
+				if (!empty($call)) {
214
+									return $call;
215
+				}
205 216
 			}
206 217
 
207 218
 			// No default action huh? then go to our good old BoardIndex.
@@ -331,8 +342,9 @@  discard block
 block discarded – undo
331 342
 
332 343
 			$call = call_helper($fallbackAction, true);
333 344
 
334
-			if (!empty($call))
335
-				return $call;
345
+			if (!empty($call)) {
346
+							return $call;
347
+			}
336 348
 		}
337 349
 
338 350
 		// No fallback action, huh?
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -104,7 +104,7 @@
 block discarded – undo
104 104
  *
105 105
  * @param string $class The fully-qualified class name.
106 106
  */
107
-spl_autoload_register(function ($class) use ($sourcedir)
107
+spl_autoload_register(function($class) use ($sourcedir)
108 108
 {
109 109
 	$classMap = array(
110 110
 		'ReCaptcha\\' => 'ReCaptcha/',
Please login to merge, or discard this patch.
Themes/default/GenericMenu.template.php 1 patch
Braces   +50 added lines, -37 removed lines patch added patch discarded remove patch
@@ -89,8 +89,9 @@  discard block
 block discarded – undo
89 89
 		foreach ($section['areas'] as $i => $area)
90 90
 		{
91 91
 			// Not supposed to be printed?
92
-			if (empty($area['label']))
93
-				continue;
92
+			if (empty($area['label'])) {
93
+							continue;
94
+			}
94 95
 
95 96
 			echo '
96 97
 								<li', !empty($area['subsections']) ? ' class="subsections"' : '', '>';
@@ -99,8 +100,9 @@  discard block
 block discarded – undo
99 100
 									<a class="', $area['icon_class'], !empty($area['selected']) ? ' chosen ' : '', '" href="', (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i), $menu_context['extra_parameters'], '">', $area['icon'], $area['label'], '</a>';
100 101
 
101 102
 			// Is this the current area, or just some area?
102
-			if (!empty($area['selected']) && empty($context['tabs']))
103
-					$context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array();
103
+			if (!empty($area['selected']) && empty($context['tabs'])) {
104
+								$context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array();
105
+			}
104 106
 
105 107
 			// Are there any subsections?
106 108
 			if (!empty($area['subsections']))
@@ -110,8 +112,9 @@  discard block
 block discarded – undo
110 112
 
111 113
 				foreach ($area['subsections'] as $sa => $sub)
112 114
 				{
113
-					if (!empty($sub['disabled']))
114
-						continue;
115
+					if (!empty($sub['disabled'])) {
116
+											continue;
117
+					}
115 118
 
116 119
 					$url = isset($sub['url']) ? $sub['url'] : (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i) . ';sa=' . $sa;
117 120
 
@@ -158,8 +161,9 @@  discard block
 block discarded – undo
158 161
 							<h3 class="catbg">';
159 162
 
160 163
 		// The function is in Admin.template.php, but since this template is used elsewhere too better check if the function is available
161
-		if (function_exists('template_admin_quick_search'))
162
-			template_admin_quick_search();
164
+		if (function_exists('template_admin_quick_search')) {
165
+					template_admin_quick_search();
166
+		}
163 167
 
164 168
 		// Exactly how many tabs do we have?
165 169
 		if (!empty($context['tabs']))
@@ -174,30 +178,36 @@  discard block
 block discarded – undo
174 178
 				}
175 179
 
176 180
 				// Did this not even exist - or do we not have a label?
177
-				if (!isset($tab_context['tabs'][$id]))
178
-					$tab_context['tabs'][$id] = array('label' => $tab['label']);
179
-				elseif (!isset($tab_context['tabs'][$id]['label']))
180
-					$tab_context['tabs'][$id]['label'] = $tab['label'];
181
+				if (!isset($tab_context['tabs'][$id])) {
182
+									$tab_context['tabs'][$id] = array('label' => $tab['label']);
183
+				} elseif (!isset($tab_context['tabs'][$id]['label'])) {
184
+									$tab_context['tabs'][$id]['label'] = $tab['label'];
185
+				}
181 186
 
182 187
 				// Has a custom URL defined in the main admin structure?
183
-				if (isset($tab['url']) && !isset($tab_context['tabs'][$id]['url']))
184
-					$tab_context['tabs'][$id]['url'] = $tab['url'];
188
+				if (isset($tab['url']) && !isset($tab_context['tabs'][$id]['url'])) {
189
+									$tab_context['tabs'][$id]['url'] = $tab['url'];
190
+				}
185 191
 
186 192
 				// Any additional paramaters for the url?
187
-				if (isset($tab['add_params']) && !isset($tab_context['tabs'][$id]['add_params']))
188
-					$tab_context['tabs'][$id]['add_params'] = $tab['add_params'];
193
+				if (isset($tab['add_params']) && !isset($tab_context['tabs'][$id]['add_params'])) {
194
+									$tab_context['tabs'][$id]['add_params'] = $tab['add_params'];
195
+				}
189 196
 
190 197
 				// Has it been deemed selected?
191
-				if (!empty($tab['is_selected']))
192
-					$tab_context['tabs'][$id]['is_selected'] = true;
198
+				if (!empty($tab['is_selected'])) {
199
+									$tab_context['tabs'][$id]['is_selected'] = true;
200
+				}
193 201
 
194 202
 				// Does it have its own help?
195
-				if (!empty($tab['help']))
196
-					$tab_context['tabs'][$id]['help'] = $tab['help'];
203
+				if (!empty($tab['help'])) {
204
+									$tab_context['tabs'][$id]['help'] = $tab['help'];
205
+				}
197 206
 
198 207
 				// Is this the last one?
199
-				if (!empty($tab['is_last']) && !isset($tab_context['override_last']))
200
-					$tab_context['tabs'][$id]['is_last'] = true;
208
+				if (!empty($tab['is_last']) && !isset($tab_context['override_last'])) {
209
+									$tab_context['tabs'][$id]['is_last'] = true;
210
+				}
201 211
 			}
202 212
 
203 213
 			// Find the selected tab
@@ -214,17 +224,18 @@  discard block
 block discarded – undo
214 224
 		// Show an icon and/or a help item?
215 225
 		if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class']) || !empty($selected_tab['icon']) || !empty($tab_context['icon']) || !empty($selected_tab['help']) || !empty($tab_context['help']))
216 226
 		{
217
-			if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class']))
218
-				echo '<span class="', !empty($selected_tab['icon_class']) ? $selected_tab['icon_class'] : $tab_context['icon_class'], ' icon"></span>';
219
-			elseif (!empty($selected_tab['icon']) || !empty($tab_context['icon']))
220
-				echo '<img src="', $settings['images_url'], '/icons/', !empty($selected_tab['icon']) ? $selected_tab['icon'] : $tab_context['icon'], '" alt="" class="icon">';
227
+			if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class'])) {
228
+							echo '<span class="', !empty($selected_tab['icon_class']) ? $selected_tab['icon_class'] : $tab_context['icon_class'], ' icon"></span>';
229
+			} elseif (!empty($selected_tab['icon']) || !empty($tab_context['icon'])) {
230
+							echo '<img src="', $settings['images_url'], '/icons/', !empty($selected_tab['icon']) ? $selected_tab['icon'] : $tab_context['icon'], '" alt="" class="icon">';
231
+			}
221 232
 
222
-			if (!empty($selected_tab['help']) || !empty($tab_context['help']))
223
-				echo '<a href="', $scripturl, '?action=helpadmin;help=', !empty($selected_tab['help']) ? $selected_tab['help'] : $tab_context['help'], '" onclick="return reqOverlayDiv(this.href);" class="help"><span class="generic_icons help" title="', $txt['help'], '"></span></a>';
233
+			if (!empty($selected_tab['help']) || !empty($tab_context['help'])) {
234
+							echo '<a href="', $scripturl, '?action=helpadmin;help=', !empty($selected_tab['help']) ? $selected_tab['help'] : $tab_context['help'], '" onclick="return reqOverlayDiv(this.href);" class="help"><span class="generic_icons help" title="', $txt['help'], '"></span></a>';
235
+			}
224 236
 
225 237
 			echo $tab_context['title'];
226
-		}
227
-		else
238
+		} else
228 239
 		{
229 240
 			echo '
230 241
 							', $tab_context['title'];
@@ -237,11 +248,12 @@  discard block
 block discarded – undo
237 248
 	}
238 249
 
239 250
 	// Shall we use the tabs? Yes, it's the only known way!
240
-	if (!empty($selected_tab['description']) || !empty($tab_context['description']))
241
-		echo '
251
+	if (!empty($selected_tab['description']) || !empty($tab_context['description'])) {
252
+			echo '
242 253
 					<p class="information">
243 254
 						', !empty($selected_tab['description']) ? $selected_tab['description'] : $tab_context['description'], '
244 255
 					</p>';
256
+	}
245 257
 
246 258
 	// Print out all the items in this tab (if any).
247 259
 	if (!empty($context['tabs']))
@@ -253,8 +265,9 @@  discard block
 block discarded – undo
253 265
 
254 266
 		foreach ($tab_context['tabs'] as $sa => $tab)
255 267
 		{
256
-			if (!empty($tab['disabled']))
257
-				continue;
268
+			if (!empty($tab['disabled'])) {
269
+							continue;
270
+			}
258 271
 
259 272
 			if (!empty($tab['is_selected']))
260 273
 			{
@@ -262,12 +275,12 @@  discard block
 block discarded – undo
262 275
 							<li>
263 276
 								<a class="active" href="', isset($tab['url']) ? $tab['url'] : $menu_context['base_url'] . ';area=' . $menu_context['current_area'] . ';sa=' . $sa, $menu_context['extra_parameters'], isset($tab['add_params']) ? $tab['add_params'] : '', '">', $tab['label'], '</a>
264 277
 							</li>';
265
-			}
266
-			else
267
-				echo '
278
+			} else {
279
+							echo '
268 280
 							<li>
269 281
 								<a href="', isset($tab['url']) ? $tab['url'] : $menu_context['base_url'] . ';area=' . $menu_context['current_area'] . ';sa=' . $sa, $menu_context['extra_parameters'], isset($tab['add_params']) ? $tab['add_params'] : '', '">', $tab['label'], '</a>
270 282
 							</li>';
283
+			}
271 284
 		}
272 285
 
273 286
 		// the end of tabs
Please login to merge, or discard this patch.