Completed
Branch release-2.1 (3c29ac)
by Mathias
08:54
created
Sources/Likes.php 1 patch
Braces   +106 added lines, -77 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Class Likes
@@ -108,8 +109,9 @@  discard block
 block discarded – undo
108 109
 		$this->_extra = isset($_GET['extra']) ? $_GET['extra'] : false;
109 110
 
110 111
 		// We do not want to output debug information here.
111
-		if ($this->_js)
112
-			$db_show_debug = false;
112
+		if ($this->_js) {
113
+					$db_show_debug = false;
114
+		}
113 115
 	}
114 116
 
115 117
 	/**
@@ -143,8 +145,9 @@  discard block
 block discarded – undo
143 145
 			$call = $this->_sa;
144 146
 
145 147
 			// Guest can only view likes.
146
-			if ($call != 'view')
147
-				is_not_guest();
148
+			if ($call != 'view') {
149
+							is_not_guest();
150
+			}
148 151
 
149 152
 			checkSession('get');
150 153
 
@@ -182,15 +185,17 @@  discard block
 block discarded – undo
182 185
 		global $smcFunc, $modSettings;
183 186
 
184 187
 		// This feature is currently disable.
185
-		if (empty($modSettings['enable_likes']))
186
-			return $this->_error = 'like_disable';
188
+		if (empty($modSettings['enable_likes'])) {
189
+					return $this->_error = 'like_disable';
190
+		}
187 191
 
188 192
 		// Zerothly, they did indicate some kind of content to like, right?
189 193
 		preg_match('~^([a-z0-9\-\_]{1,6})~i', $this->_type, $matches);
190 194
 		$this->_type = isset($matches[1]) ? $matches[1] : '';
191 195
 
192
-		if ($this->_type == '' || $this->_content <= 0)
193
-			return $this->_error = 'cannot_';
196
+		if ($this->_type == '' || $this->_content <= 0) {
197
+					return $this->_error = 'cannot_';
198
+		}
194 199
 
195 200
 		// First we need to verify if the user can see the type of content or not. This is set up to be extensible,
196 201
 		// so we'll check for the one type we do know about, and if it's not that, we'll defer to any hooks.
@@ -209,12 +214,14 @@  discard block
 block discarded – undo
209 214
 					'msg' => $this->_content,
210 215
 				)
211 216
 			);
212
-			if ($smcFunc['db_num_rows']($request) == 1)
213
-				list ($this->_idTopic, $topicOwner) = $smcFunc['db_fetch_row']($request);
217
+			if ($smcFunc['db_num_rows']($request) == 1) {
218
+							list ($this->_idTopic, $topicOwner) = $smcFunc['db_fetch_row']($request);
219
+			}
214 220
 
215 221
 			$smcFunc['db_free_result']($request);
216
-			if (empty($this->_idTopic))
217
-				return $this->_error = 'cannot_';
222
+			if (empty($this->_idTopic)) {
223
+							return $this->_error = 'cannot_';
224
+			}
218 225
 
219 226
 			// So we know what topic it's in and more importantly we know the user can see it.
220 227
 			// If we're not viewing, we need some info set up.
@@ -224,9 +231,7 @@  discard block
 block discarded – undo
224 231
 			$this->_validLikes['can_see'] = allowedTo('likes_view') ? true : 'cannot_view_likes';
225 232
 
226 233
 			$this->_validLikes['can_like'] = ($this->_user['id'] == $topicOwner ? 'cannot_like_content' : (allowedTo('likes_like') ? true : 'cannot_like_content'));
227
-		}
228
-
229
-		else
234
+		} else
230 235
 		{
231 236
 			// Modders: This will give you whatever the user offers up in terms of liking, e.g. $this->_type=msg, $this->_content=1
232 237
 			// When you hook this, check $this->_type first. If it is not something your mod worries about, return false.
@@ -244,8 +249,9 @@  discard block
 block discarded – undo
244 249
 					if ($result !== false)
245 250
 					{
246 251
 						// Match the type with what we already have.
247
-						if (!isset($result['type']) || $result['type'] != $this->_type)
248
-							return $this->_error = 'not_valid_like_type';
252
+						if (!isset($result['type']) || $result['type'] != $this->_type) {
253
+													return $this->_error = 'not_valid_like_type';
254
+						}
249 255
 
250 256
 						// Fill out the rest.
251 257
 						$this->_type = $result['type'];
@@ -256,17 +262,20 @@  discard block
 block discarded – undo
256 262
 				}
257 263
 			}
258 264
 
259
-			if (!$found)
260
-				return $this->_error = 'cannot_';
265
+			if (!$found) {
266
+							return $this->_error = 'cannot_';
267
+			}
261 268
 		}
262 269
 
263 270
 		// Does the user can see this?
264
-		if (isset($this->_validLikes['can_see']) && is_string($this->_validLikes['can_see']))
265
-			return $this->_error = $this->_validLikes['can_see'];
271
+		if (isset($this->_validLikes['can_see']) && is_string($this->_validLikes['can_see'])) {
272
+					return $this->_error = $this->_validLikes['can_see'];
273
+		}
266 274
 
267 275
 		// Does the user can like this? Viewing a list of likes doesn't require this permission.
268
-			if ($this->_sa != 'view' && isset($this->_validLikes['can_like']) && is_string($this->_validLikes['can_like']))
269
-				return $this->_error = $this->_validLikes['can_like'];
276
+			if ($this->_sa != 'view' && isset($this->_validLikes['can_like']) && is_string($this->_validLikes['can_like'])) {
277
+							return $this->_error = $this->_validLikes['can_like'];
278
+			}
270 279
 	}
271 280
 
272 281
 	/**
@@ -291,8 +300,9 @@  discard block
 block discarded – undo
291 300
 		);
292 301
 
293 302
 		// Are we calling this directly? if so, set a proper data for the response. Do note that __METHOD__ returns both the class name and the function name.
294
-		if ($this->_sa == __FUNCTION__)
295
-			$this->_data = __FUNCTION__;
303
+		if ($this->_sa == __FUNCTION__) {
304
+					$this->_data = __FUNCTION__;
305
+		}
296 306
 	}
297 307
 
298 308
 	/**
@@ -322,8 +332,8 @@  discard block
 block discarded – undo
322 332
 
323 333
 		// Add a background task to process sending alerts.
324 334
 		// Mod author, you can add your own background task for your own custom like event using the "integrate_issue_like" hook or your callback, both are immediately called after this.
325
-		if ($this->_type == 'msg')
326
-			$smcFunc['db_insert']('insert',
335
+		if ($this->_type == 'msg') {
336
+					$smcFunc['db_insert']('insert',
327 337
 				'{db_prefix}background_tasks',
328 338
 				array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'),
329 339
 				array('$sourcedir/tasks/Likes-Notify.php', 'Likes_Notify_Background', json_encode(array(
@@ -335,10 +345,12 @@  discard block
 block discarded – undo
335 345
 				)), 0),
336 346
 				array('id_task')
337 347
 			);
348
+		}
338 349
 
339 350
 		// Are we calling this directly? if so, set a proper data for the response. Do note that __METHOD__ returns both the class name and the function name.
340
-		if ($this->_sa == __FUNCTION__)
341
-			$this->_data = __FUNCTION__;
351
+		if ($this->_sa == __FUNCTION__) {
352
+					$this->_data = __FUNCTION__;
353
+		}
342 354
 	}
343 355
 
344 356
 	/**
@@ -364,8 +376,9 @@  discard block
 block discarded – undo
364 376
 		$smcFunc['db_free_result']($request);
365 377
 
366 378
 		// If you want to call this directly, fill out _data property too.
367
-		if ($this->_sa == __FUNCTION__)
368
-			$this->_data = $this->_numLikes;
379
+		if ($this->_sa == __FUNCTION__) {
380
+					$this->_data = $this->_numLikes;
381
+		}
369 382
 	}
370 383
 
371 384
 	/**
@@ -378,8 +391,9 @@  discard block
 block discarded – undo
378 391
 		global $smcFunc;
379 392
 
380 393
 		// Safety first!
381
-		if (empty($this->_type) || empty($this->_content))
382
-			return $this->_error = 'cannot_';
394
+		if (empty($this->_type) || empty($this->_content)) {
395
+					return $this->_error = 'cannot_';
396
+		}
383 397
 
384 398
 		// Do we already like this?
385 399
 		$request = $smcFunc['db_query']('', '
@@ -397,26 +411,28 @@  discard block
 block discarded – undo
397 411
 		$this->_alreadyLiked = (bool) $smcFunc['db_num_rows']($request) != 0;
398 412
 		$smcFunc['db_free_result']($request);
399 413
 
400
-		if ($this->_alreadyLiked)
401
-			$this->delete();
402
-
403
-		else
404
-			$this->insert();
414
+		if ($this->_alreadyLiked) {
415
+					$this->delete();
416
+		} else {
417
+					$this->insert();
418
+		}
405 419
 
406 420
 		// Now, how many people like this content now? We *could* just +1 / -1 the relevant container but that has proven to become unstable.
407 421
 		$this->_count();
408 422
 
409 423
 		// Update the likes count for messages.
410
-		if ($this->_type == 'msg')
411
-			$this->msgIssueLike();
424
+		if ($this->_type == 'msg') {
425
+					$this->msgIssueLike();
426
+		}
412 427
 
413 428
 		// Any callbacks?
414 429
 		elseif (!empty($this->_validLikes['callback']))
415 430
 		{
416 431
 			$call = call_helper($this->_validLikes['callback'], true);
417 432
 
418
-			if (!empty($call))
419
-				call_user_func_array($call, array($this));
433
+			if (!empty($call)) {
434
+							call_user_func_array($call, array($this));
435
+			}
420 436
 		}
421 437
 
422 438
 		// Sometimes there might be other things that need updating after we do this like.
@@ -425,8 +441,9 @@  discard block
 block discarded – undo
425 441
 		// Now some clean up. This is provided here for any like handlers that want to do any cache flushing.
426 442
 		// This way a like handler doesn't need to explicitly declare anything in integrate_issue_like, but do so
427 443
 		// in integrate_valid_likes where it absolutely has to exist.
428
-		if (!empty($this->_validLikes['flush_cache']))
429
-			cache_put_data($this->_validLikes['flush_cache'], null);
444
+		if (!empty($this->_validLikes['flush_cache'])) {
445
+					cache_put_data($this->_validLikes['flush_cache'], null);
446
+		}
430 447
 
431 448
 		// All done, start building the data to pass as response.
432 449
 		$this->_data = array(
@@ -450,8 +467,9 @@  discard block
 block discarded – undo
450 467
 	{
451 468
 		global $smcFunc;
452 469
 
453
-		if ($this->_type !== 'msg')
454
-			return;
470
+		if ($this->_type !== 'msg') {
471
+					return;
472
+		}
455 473
 
456 474
 		$smcFunc['db_query']('', '
457 475
 			UPDATE {db_prefix}messages
@@ -492,8 +510,9 @@  discard block
 block discarded – undo
492 510
 				'like_type' => $this->_type,
493 511
 			)
494 512
 		);
495
-		while ($row = $smcFunc['db_fetch_assoc']($request))
496
-			$context['likers'][$row['id_member']] = array('timestamp' => $row['like_time']);
513
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
514
+					$context['likers'][$row['id_member']] = array('timestamp' => $row['like_time']);
515
+		}
497 516
 
498 517
 		// Now to get member data, including avatars and so on.
499 518
 		$members = array_keys($context['likers']);
@@ -501,8 +520,9 @@  discard block
 block discarded – undo
501 520
 		if (count($loaded) != count($members))
502 521
 		{
503 522
 			$members = array_diff($members, $loaded);
504
-			foreach ($members as $not_loaded)
505
-				unset ($context['likers'][$not_loaded]);
523
+			foreach ($members as $not_loaded) {
524
+							unset ($context['likers'][$not_loaded]);
525
+			}
506 526
 		}
507 527
 
508 528
 		foreach ($context['likers'] as $liker => $dummy)
@@ -544,12 +564,14 @@  discard block
 block discarded – undo
544 564
 		global $context, $txt;
545 565
 
546 566
 		// Don't do anything if someone else has already take care of the response.
547
-		if (!$this->_setResponse)
548
-			return;
567
+		if (!$this->_setResponse) {
568
+					return;
569
+		}
549 570
 
550 571
 		// Want a json response huh?
551
-		if ($this->_validLikes['json'])
552
-			return $this->jsonResponse();
572
+		if ($this->_validLikes['json']) {
573
+					return $this->jsonResponse();
574
+		}
553 575
 
554 576
 		// Set everything up for display.
555 577
 		loadTemplate('Likes');
@@ -559,8 +581,9 @@  discard block
 block discarded – undo
559 581
 		if ($this->_error)
560 582
 		{
561 583
 			// If this is a generic error, set it up good.
562
-			if ($this->_error == 'cannot_')
563
-				$this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content';
584
+			if ($this->_error == 'cannot_') {
585
+							$this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content';
586
+			}
564 587
 
565 588
 			// Is this request coming from an ajax call?
566 589
 			if ($this->_js)
@@ -570,8 +593,9 @@  discard block
 block discarded – undo
570 593
 			}
571 594
 
572 595
 			// Nope?  then just do a redirect to whatever URL was provided.
573
-			else
574
-				redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] .';error='. $this->_error : '');
596
+			else {
597
+							redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] .';error='. $this->_error : '');
598
+			}
575 599
 
576 600
 			return;
577 601
 		}
@@ -580,8 +604,9 @@  discard block
 block discarded – undo
580 604
 		else
581 605
 		{
582 606
 			// Not an ajax request so send the user back to the previous location or the main page.
583
-			if (!$this->_js)
584
-				redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] : '');
607
+			if (!$this->_js) {
608
+							redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] : '');
609
+			}
585 610
 
586 611
 			// These fine gentlemen all share the same template.
587 612
 			$generic = array('delete', 'insert', '_count');
@@ -612,8 +637,9 @@  discard block
 block discarded – undo
612 637
 		// If there is an error, send it.
613 638
 		if ($this->_error)
614 639
 		{
615
-			if ($this->_error == 'cannot_')
616
-				$this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content';
640
+			if ($this->_error == 'cannot_') {
641
+							$this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content';
642
+			}
617 643
 
618 644
 			$print['error'] = $this->_error;
619 645
 		}
@@ -649,33 +675,36 @@  discard block
 block discarded – undo
649 675
 	<body style="background-color: #444455; color: white; font-style: italic; font-family: serif;">
650 676
 		<div style="margin-top: 12%; font-size: 1.1em; line-height: 1.4; text-align: center;">';
651 677
 
652
-	if (!isset($_GET['verse']) || ($_GET['verse'] != '2:18' && $_GET['verse'] != '22:1-2'))
653
-		$_GET['verse'] = '4:16';
678
+	if (!isset($_GET['verse']) || ($_GET['verse'] != '2:18' && $_GET['verse'] != '22:1-2')) {
679
+			$_GET['verse'] = '4:16';
680
+	}
654 681
 
655
-	if ($_GET['verse'] == '2:18')
656
-		echo '
682
+	if ($_GET['verse'] == '2:18') {
683
+			echo '
657 684
 			Woe, it was that his name wasn\'t <em>known</em>, that he came in mystery, and was recognized by none.&nbsp;And it became to be in those days <em>something</em>.&nbsp; Something not yet <em id="unknown" name="[Unknown]">unknown</em> to mankind.&nbsp; And thus what was to be known the <em>secret project</em> began into its existence.&nbsp; Henceforth the opposition was only <em>weary</em> and <em>fearful</em>, for now their match was at arms against them.';
658
-	elseif ($_GET['verse'] == '4:16')
659
-		echo '
685
+	} elseif ($_GET['verse'] == '4:16') {
686
+			echo '
660 687
 			And it came to pass that the <em>unbelievers</em> dwindled in number and saw rise of many <em>proselytizers</em>, and the opposition found fear in the face of the <em>x</em> and the <em>j</em> while those who stood with the <em>something</em> grew stronger and came together.&nbsp; Still, this was only the <em>beginning</em>, and what lay in the future was <em id="unknown" name="[Unknown]">unknown</em> to all, even those on the right side.';
661
-	elseif ($_GET['verse'] == '22:1-2')
662
-		echo '
688
+	} elseif ($_GET['verse'] == '22:1-2') {
689
+			echo '
663 690
 			<p>Now <em>behold</em>, that which was once the secret project was <em id="unknown" name="[Unknown]">unknown</em> no longer.&nbsp; Alas, it needed more than <em>only one</em>, but yet even thought otherwise.&nbsp; It became that the opposition <em>rumored</em> and lied, but still to no avail.&nbsp; Their match, though not <em>perfect</em>, had them outdone.</p>
664 691
 			<p style="margin: 2ex 1ex 0 1ex; font-size: 1.05em; line-height: 1.5; text-align: center;">Let it continue.&nbsp; <em>The end</em>.</p>';
692
+	}
665 693
 
666 694
 	echo '
667 695
 		</div>
668 696
 		<div style="margin-top: 2ex; font-size: 2em; text-align: right;">';
669 697
 
670
-	if ($_GET['verse'] == '2:18')
671
-		echo '
698
+	if ($_GET['verse'] == '2:18') {
699
+			echo '
672 700
 			from <span style="font-family: Georgia, serif;"><strong><a href="', $scripturl, '?action=about:unknown;verse=4:16" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 2:18</span>';
673
-	elseif ($_GET['verse'] == '4:16')
674
-		echo '
701
+	} elseif ($_GET['verse'] == '4:16') {
702
+			echo '
675 703
 			from <span style="font-family: Georgia, serif;"><strong><a href="', $scripturl, '?action=about:unknown;verse=22:1-2" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 4:16</span>';
676
-	elseif ($_GET['verse'] == '22:1-2')
677
-		echo '
704
+	} elseif ($_GET['verse'] == '22:1-2') {
705
+			echo '
678 706
 			from <span style="font-family: Georgia, serif;"><strong>The Book of Unknown</strong>, 22:1-2</span>';
707
+	}
679 708
 
680 709
 	echo '
681 710
 		</div>
Please login to merge, or discard this patch.
Sources/Display.php 1 patch
Braces   +335 added lines, -251 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
  * The central part of the board - topic display.
@@ -34,8 +35,9 @@  discard block
 block discarded – undo
34 35
 	global $attachments, $messages_request, $language, $smcFunc;
35 36
 
36 37
 	// What are you gonna display if these are empty?!
37
-	if (empty($topic))
38
-		fatal_lang_error('no_board', false);
38
+	if (empty($topic)) {
39
+			fatal_lang_error('no_board', false);
40
+	}
39 41
 
40 42
 	// Load the proper template.
41 43
 	loadTemplate('Display');
@@ -52,15 +54,17 @@  discard block
 block discarded – undo
52 54
 	$context['messages_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages'];
53 55
 
54 56
 	// Let's do some work on what to search index.
55
-	if (count($_GET) > 2)
56
-		foreach ($_GET as $k => $v)
57
+	if (count($_GET) > 2) {
58
+			foreach ($_GET as $k => $v)
57 59
 		{
58 60
 			if (!in_array($k, array('topic', 'board', 'start', session_name())))
59 61
 				$context['robot_no_index'] = true;
62
+	}
60 63
 		}
61 64
 
62
-	if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0))
63
-		$context['robot_no_index'] = true;
65
+	if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) {
66
+			$context['robot_no_index'] = true;
67
+	}
64 68
 
65 69
 	// Find the previous or next topic.  Make a fuss if there are no more.
66 70
 	if (isset($_REQUEST['prev_next']) && ($_REQUEST['prev_next'] == 'prev' || $_REQUEST['prev_next'] == 'next'))
@@ -172,8 +176,9 @@  discard block
 block discarded – undo
172 176
 			$topic_parameters
173 177
 	);
174 178
 
175
-	if ($smcFunc['db_num_rows']($request) == 0)
176
-		fatal_lang_error('not_a_topic', false, 404);
179
+	if ($smcFunc['db_num_rows']($request) == 0) {
180
+			fatal_lang_error('not_a_topic', false, 404);
181
+	}
177 182
 	$context['topicinfo'] = $smcFunc['db_fetch_assoc']($request);
178 183
 	$smcFunc['db_free_result']($request);
179 184
 
@@ -210,8 +215,9 @@  discard block
 block discarded – undo
210 215
 	$context['topic_unwatched'] = isset($context['topicinfo']['unwatched']) ? $context['topicinfo']['unwatched'] : 0;
211 216
 
212 217
 	// Add up unapproved replies to get real number of replies...
213
-	if ($modSettings['postmod_active'] && $approve_posts)
214
-		$context['real_num_replies'] += $context['topicinfo']['unapproved_posts'] - ($context['topicinfo']['approved'] ? 0 : 1);
218
+	if ($modSettings['postmod_active'] && $approve_posts) {
219
+			$context['real_num_replies'] += $context['topicinfo']['unapproved_posts'] - ($context['topicinfo']['approved'] ? 0 : 1);
220
+	}
215 221
 
216 222
 	// If this topic has unapproved posts, we need to work out how many posts the user can see, for page indexing.
217 223
 	if ($modSettings['postmod_active'] && $context['topicinfo']['unapproved_posts'] && !$user_info['is_guest'] && !$approve_posts)
@@ -231,11 +237,11 @@  discard block
 block discarded – undo
231 237
 		$smcFunc['db_free_result']($request);
232 238
 
233 239
 		$context['total_visible_posts'] = $context['num_replies'] + $myUnapprovedPosts + ($context['topicinfo']['approved'] ? 1 : 0);
240
+	} elseif ($user_info['is_guest']) {
241
+			$context['total_visible_posts'] = $context['num_replies'] + ($context['topicinfo']['approved'] ? 1 : 0);
242
+	} else {
243
+			$context['total_visible_posts'] = $context['num_replies'] + $context['topicinfo']['unapproved_posts'] + ($context['topicinfo']['approved'] ? 1 : 0);
234 244
 	}
235
-	elseif ($user_info['is_guest'])
236
-		$context['total_visible_posts'] = $context['num_replies'] + ($context['topicinfo']['approved'] ? 1 : 0);
237
-	else
238
-		$context['total_visible_posts'] = $context['num_replies'] + $context['topicinfo']['unapproved_posts'] + ($context['topicinfo']['approved'] ? 1 : 0);
239 245
 
240 246
 	// The start isn't a number; it's information about what to do, where to go.
241 247
 	if (!is_numeric($_REQUEST['start']))
@@ -248,8 +254,7 @@  discard block
 block discarded – undo
248 254
 			{
249 255
 				$context['start_from'] = $context['total_visible_posts'] - 1;
250 256
 				$_REQUEST['start'] = empty($options['view_newest_first']) ? $context['start_from'] : 0;
251
-			}
252
-			else
257
+			} else
253 258
 			{
254 259
 				// Find the earliest unread message in the topic. (the use of topics here is just for both tables.)
255 260
 				$request = $smcFunc['db_query']('', '
@@ -277,9 +282,9 @@  discard block
 block discarded – undo
277 282
 		if (substr($_REQUEST['start'], 0, 4) == 'from')
278 283
 		{
279 284
 			$timestamp = (int) substr($_REQUEST['start'], 4);
280
-			if ($timestamp === 0)
281
-				$_REQUEST['start'] = 0;
282
-			else
285
+			if ($timestamp === 0) {
286
+							$_REQUEST['start'] = 0;
287
+			} else
283 288
 			{
284 289
 				// Find the number of messages posted before said time...
285 290
 				$request = $smcFunc['db_query']('', '
@@ -307,11 +312,11 @@  discard block
 block discarded – undo
307 312
 		elseif (substr($_REQUEST['start'], 0, 3) == 'msg')
308 313
 		{
309 314
 			$virtual_msg = (int) substr($_REQUEST['start'], 3);
310
-			if (!$context['topicinfo']['unapproved_posts'] && $virtual_msg >= $context['topicinfo']['id_last_msg'])
311
-				$context['start_from'] = $context['total_visible_posts'] - 1;
312
-			elseif (!$context['topicinfo']['unapproved_posts'] && $virtual_msg <= $context['topicinfo']['id_first_msg'])
313
-				$context['start_from'] = 0;
314
-			else
315
+			if (!$context['topicinfo']['unapproved_posts'] && $virtual_msg >= $context['topicinfo']['id_last_msg']) {
316
+							$context['start_from'] = $context['total_visible_posts'] - 1;
317
+			} elseif (!$context['topicinfo']['unapproved_posts'] && $virtual_msg <= $context['topicinfo']['id_first_msg']) {
318
+							$context['start_from'] = 0;
319
+			} else
315 320
 			{
316 321
 				// Find the start value for that message......
317 322
 				$request = $smcFunc['db_query']('', '
@@ -394,21 +399,25 @@  discard block
 block discarded – undo
394 399
 		);
395 400
 		while ($row = $smcFunc['db_fetch_assoc']($request))
396 401
 		{
397
-			if (empty($row['id_member']))
398
-				continue;
402
+			if (empty($row['id_member'])) {
403
+							continue;
404
+			}
399 405
 
400
-			if (!empty($row['online_color']))
401
-				$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>';
402
-			else
403
-				$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
406
+			if (!empty($row['online_color'])) {
407
+							$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>';
408
+			} else {
409
+							$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
410
+			}
404 411
 
405 412
 			$is_buddy = in_array($row['id_member'], $user_info['buddies']);
406
-			if ($is_buddy)
407
-				$link = '<strong>' . $link . '</strong>';
413
+			if ($is_buddy) {
414
+							$link = '<strong>' . $link . '</strong>';
415
+			}
408 416
 
409 417
 			// Add them both to the list and to the more detailed list.
410
-			if (!empty($row['show_online']) || allowedTo('moderate_forum'))
411
-				$context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link;
418
+			if (!empty($row['show_online']) || allowedTo('moderate_forum')) {
419
+							$context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link;
420
+			}
412 421
 			$context['view_members'][$row['log_time'] . $row['member_name']] = array(
413 422
 				'id' => $row['id_member'],
414 423
 				'username' => $row['member_name'],
@@ -420,8 +429,9 @@  discard block
 block discarded – undo
420 429
 				'hidden' => empty($row['show_online']),
421 430
 			);
422 431
 
423
-			if (empty($row['show_online']))
424
-				$context['view_num_hidden']++;
432
+			if (empty($row['show_online'])) {
433
+							$context['view_num_hidden']++;
434
+			}
425 435
 		}
426 436
 
427 437
 		// The number of guests is equal to the rows minus the ones we actually used ;).
@@ -435,11 +445,13 @@  discard block
 block discarded – undo
435 445
 
436 446
 	// If all is set, but not allowed... just unset it.
437 447
 	$can_show_all = !empty($modSettings['enableAllMessages']) && $context['total_visible_posts'] > $context['messages_per_page'] && $context['total_visible_posts'] < $modSettings['enableAllMessages'];
438
-	if (isset($_REQUEST['all']) && !$can_show_all)
439
-		unset($_REQUEST['all']);
448
+	if (isset($_REQUEST['all']) && !$can_show_all) {
449
+			unset($_REQUEST['all']);
450
+	}
440 451
 	// Otherwise, it must be allowed... so pretend start was -1.
441
-	elseif (isset($_REQUEST['all']))
442
-		$_REQUEST['start'] = -1;
452
+	elseif (isset($_REQUEST['all'])) {
453
+			$_REQUEST['start'] = -1;
454
+	}
443 455
 
444 456
 	// Construct the page index, allowing for the .START method...
445 457
 	$context['page_index'] = constructPageIndex($scripturl . '?topic=' . $topic . '.%1$d', $_REQUEST['start'], $context['total_visible_posts'], $context['messages_per_page'], true);
@@ -476,8 +488,9 @@  discard block
 block discarded – undo
476 488
 			$_REQUEST['start'] = 0;
477 489
 		}
478 490
 		// They aren't using it, but the *option* is there, at least.
479
-		else
480
-			$context['page_index'] .= '&nbsp;<a href="' . $scripturl . '?topic=' . $topic . '.0;all">' . $txt['all'] . '</a> ';
491
+		else {
492
+					$context['page_index'] .= '&nbsp;<a href="' . $scripturl . '?topic=' . $topic . '.0;all">' . $txt['all'] . '</a> ';
493
+		}
481 494
 	}
482 495
 
483 496
 	// Build the link tree.
@@ -493,14 +506,16 @@  discard block
 block discarded – undo
493 506
 	if (!empty($board_info['moderators']))
494 507
 	{
495 508
 		// Add a link for each moderator...
496
-		foreach ($board_info['moderators'] as $mod)
497
-			$context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>';
509
+		foreach ($board_info['moderators'] as $mod) {
510
+					$context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>';
511
+		}
498 512
 	}
499 513
 	if (!empty($board_info['moderator_groups']))
500 514
 	{
501 515
 		// Add a link for each moderator group as well...
502
-		foreach ($board_info['moderator_groups'] as $mod_group)
503
-			$context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=viewmemberes;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>';
516
+		foreach ($board_info['moderator_groups'] as $mod_group) {
517
+					$context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=viewmemberes;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>';
518
+		}
504 519
 	}
505 520
 
506 521
 	if (!empty($context['link_moderators']))
@@ -531,9 +546,9 @@  discard block
 block discarded – undo
531 546
 	// For quick reply we need a response prefix in the default forum language.
532 547
 	if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix', 600)))
533 548
 	{
534
-		if ($language === $user_info['language'])
535
-			$context['response_prefix'] = $txt['response_prefix'];
536
-		else
549
+		if ($language === $user_info['language']) {
550
+					$context['response_prefix'] = $txt['response_prefix'];
551
+		} else
537 552
 		{
538 553
 			loadLanguage('index', $language, false);
539 554
 			$context['response_prefix'] = $txt['response_prefix'];
@@ -546,10 +561,11 @@  discard block
 block discarded – undo
546 561
 	if (allowedTo('calendar_view') && !empty($modSettings['cal_showInTopic']) && !empty($modSettings['cal_enabled']))
547 562
 	{
548 563
 		// First, try create a better time format, ignoring the "time" elements.
549
-		if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0]))
550
-			$date_string = $user_info['time_format'];
551
-		else
552
-			$date_string = $matches[0];
564
+		if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) {
565
+					$date_string = $user_info['time_format'];
566
+		} else {
567
+					$date_string = $matches[0];
568
+		}
553 569
 
554 570
 		// Any calendar information for this topic?
555 571
 		$request = $smcFunc['db_query']('', '
@@ -587,8 +603,9 @@  discard block
 block discarded – undo
587 603
 		}
588 604
 		$smcFunc['db_free_result']($request);
589 605
 
590
-		if (!empty($context['linked_calendar_events']))
591
-			$context['linked_calendar_events'][count($context['linked_calendar_events']) - 1]['is_last'] = true;
606
+		if (!empty($context['linked_calendar_events'])) {
607
+					$context['linked_calendar_events'][count($context['linked_calendar_events']) - 1]['is_last'] = true;
608
+		}
592 609
 	}
593 610
 
594 611
 	// Create the poll info if it exists.
@@ -661,20 +678,21 @@  discard block
 block discarded – undo
661 678
 				foreach ($guestinfo as $i => $guestvoted)
662 679
 				{
663 680
 					$guestvoted = explode(',', $guestvoted);
664
-					if ($guestvoted[0] == $context['topicinfo']['id_poll'])
665
-						break;
681
+					if ($guestvoted[0] == $context['topicinfo']['id_poll']) {
682
+											break;
683
+					}
666 684
 				}
667 685
 				// Has the poll been reset since guest voted?
668 686
 				if ($pollinfo['reset_poll'] > $guestvoted[1])
669 687
 				{
670 688
 					// Remove the poll info from the cookie to allow guest to vote again
671 689
 					unset($guestinfo[$i]);
672
-					if (!empty($guestinfo))
673
-						$_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo);
674
-					else
675
-						unset($_COOKIE['guest_poll_vote']);
676
-				}
677
-				else
690
+					if (!empty($guestinfo)) {
691
+											$_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo);
692
+					} else {
693
+											unset($_COOKIE['guest_poll_vote']);
694
+					}
695
+				} else
678 696
 				{
679 697
 					// What did they vote for?
680 698
 					unset($guestvoted[0], $guestvoted[1]);
@@ -788,23 +806,29 @@  discard block
 block discarded – undo
788 806
 		// Build the poll moderation button array.
789 807
 		$context['poll_buttons'] = array();
790 808
 
791
-		if ($context['allow_return_vote'])
792
-			$context['poll_buttons']['vote'] = array('text' => 'poll_return_vote', 'image' => 'poll_options.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']);
809
+		if ($context['allow_return_vote']) {
810
+					$context['poll_buttons']['vote'] = array('text' => 'poll_return_vote', 'image' => 'poll_options.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']);
811
+		}
793 812
 
794
-		if ($context['show_view_results_button'])
795
-			$context['poll_buttons']['results'] = array('text' => 'poll_results', 'image' => 'poll_results.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults');
813
+		if ($context['show_view_results_button']) {
814
+					$context['poll_buttons']['results'] = array('text' => 'poll_results', 'image' => 'poll_results.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults');
815
+		}
796 816
 
797
-		if ($context['allow_change_vote'])
798
-			$context['poll_buttons']['change_vote'] = array('text' => 'poll_change_vote', 'image' => 'poll_change_vote.png', 'url' => $scripturl . '?action=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . ';' . $context['session_var'] . '=' . $context['session_id']);
817
+		if ($context['allow_change_vote']) {
818
+					$context['poll_buttons']['change_vote'] = array('text' => 'poll_change_vote', 'image' => 'poll_change_vote.png', 'url' => $scripturl . '?action=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . ';' . $context['session_var'] . '=' . $context['session_id']);
819
+		}
799 820
 
800
-		if ($context['allow_lock_poll'])
801
-			$context['poll_buttons']['lock'] = array('text' => (!$context['poll']['is_locked'] ? 'poll_lock' : 'poll_unlock'), 'image' => 'poll_lock.png', 'url' => $scripturl . '?action=lockvoting;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
821
+		if ($context['allow_lock_poll']) {
822
+					$context['poll_buttons']['lock'] = array('text' => (!$context['poll']['is_locked'] ? 'poll_lock' : 'poll_unlock'), 'image' => 'poll_lock.png', 'url' => $scripturl . '?action=lockvoting;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
823
+		}
802 824
 
803
-		if ($context['allow_edit_poll'])
804
-			$context['poll_buttons']['edit'] = array('text' => 'poll_edit', 'image' => 'poll_edit.png', 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']);
825
+		if ($context['allow_edit_poll']) {
826
+					$context['poll_buttons']['edit'] = array('text' => 'poll_edit', 'image' => 'poll_edit.png', 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']);
827
+		}
805 828
 
806
-		if ($context['can_remove_poll'])
807
-			$context['poll_buttons']['remove_poll'] = array('text' => 'poll_remove', 'image' => 'admin_remove_poll.png', 'custom' => 'data-confirm="' . $txt['poll_remove_warn'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removepoll;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
829
+		if ($context['can_remove_poll']) {
830
+					$context['poll_buttons']['remove_poll'] = array('text' => 'poll_remove', 'image' => 'admin_remove_poll.png', 'custom' => 'data-confirm="' . $txt['poll_remove_warn'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removepoll;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
831
+		}
808 832
 
809 833
 		// Allow mods to add additional buttons here
810 834
 		call_integration_hook('integrate_poll_buttons');
@@ -845,8 +869,9 @@  discard block
 block discarded – undo
845 869
 	$all_posters = array();
846 870
 	while ($row = $smcFunc['db_fetch_assoc']($request))
847 871
 	{
848
-		if (!empty($row['id_member']))
849
-			$all_posters[$row['id_msg']] = $row['id_member'];
872
+		if (!empty($row['id_member'])) {
873
+					$all_posters[$row['id_msg']] = $row['id_member'];
874
+		}
850 875
 		$messages[] = $row['id_msg'];
851 876
 	}
852 877
 	$smcFunc['db_free_result']($request);
@@ -858,8 +883,9 @@  discard block
 block discarded – undo
858 883
 	if (!$user_info['is_guest'] && !empty($messages))
859 884
 	{
860 885
 		$mark_at_msg = max($messages);
861
-		if ($mark_at_msg >= $context['topicinfo']['id_last_msg'])
862
-			$mark_at_msg = $modSettings['maxMsgID'];
886
+		if ($mark_at_msg >= $context['topicinfo']['id_last_msg']) {
887
+					$mark_at_msg = $modSettings['maxMsgID'];
888
+		}
863 889
 		if ($mark_at_msg >= $context['topicinfo']['new_from'])
864 890
 		{
865 891
 			$smcFunc['db_insert']($context['topicinfo']['new_from'] == 0 ? 'ignore' : 'replace',
@@ -891,8 +917,9 @@  discard block
 block discarded – undo
891 917
 		while ($row = $smcFunc['db_fetch_assoc']($request))
892 918
 		{
893 919
 			// Find if this topic is marked for notification...
894
-			if (!empty($row['id_topic']))
895
-				$context['is_marked_notify'] = true;
920
+			if (!empty($row['id_topic'])) {
921
+							$context['is_marked_notify'] = true;
922
+			}
896 923
 
897 924
 			// Only do this once, but mark the notifications as "not sent yet" for next time.
898 925
 			if (!empty($row['sent']) && $do_once)
@@ -914,8 +941,9 @@  discard block
 block discarded – undo
914 941
 		}
915 942
 
916 943
 		// Have we recently cached the number of new topics in this board, and it's still a lot?
917
-		if (isset($_REQUEST['topicseen']) && isset($_SESSION['topicseen_cache'][$board]) && $_SESSION['topicseen_cache'][$board] > 5)
918
-			$_SESSION['topicseen_cache'][$board]--;
944
+		if (isset($_REQUEST['topicseen']) && isset($_SESSION['topicseen_cache'][$board]) && $_SESSION['topicseen_cache'][$board] > 5) {
945
+					$_SESSION['topicseen_cache'][$board]--;
946
+		}
919 947
 		// Mark board as seen if this is the only new topic.
920 948
 		elseif (isset($_REQUEST['topicseen']))
921 949
 		{
@@ -939,14 +967,16 @@  discard block
 block discarded – undo
939 967
 			$smcFunc['db_free_result']($request);
940 968
 
941 969
 			// If there're no real new topics in this board, mark the board as seen.
942
-			if (empty($numNewTopics))
943
-				$_REQUEST['boardseen'] = true;
944
-			else
945
-				$_SESSION['topicseen_cache'][$board] = $numNewTopics;
970
+			if (empty($numNewTopics)) {
971
+							$_REQUEST['boardseen'] = true;
972
+			} else {
973
+							$_SESSION['topicseen_cache'][$board] = $numNewTopics;
974
+			}
946 975
 		}
947 976
 		// Probably one less topic - maybe not, but even if we decrease this too fast it will only make us look more often.
948
-		elseif (isset($_SESSION['topicseen_cache'][$board]))
949
-			$_SESSION['topicseen_cache'][$board]--;
977
+		elseif (isset($_SESSION['topicseen_cache'][$board])) {
978
+					$_SESSION['topicseen_cache'][$board]--;
979
+		}
950 980
 
951 981
 		// Mark board as seen if we came using last post link from BoardIndex. (or other places...)
952 982
 		if (isset($_REQUEST['boardseen']))
@@ -1003,23 +1033,26 @@  discard block
 block discarded – undo
1003 1033
 			$temp = array();
1004 1034
 			while ($row = $smcFunc['db_fetch_assoc']($request))
1005 1035
 			{
1006
-				if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id']))
1007
-					continue;
1036
+				if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) {
1037
+									continue;
1038
+				}
1008 1039
 
1009 1040
 				$temp[$row['id_attach']] = $row;
1010 1041
 				$temp[$row['id_attach']]['topic'] = $topic;
1011 1042
 				$temp[$row['id_attach']]['board'] = $board;
1012 1043
 
1013
-				if (!isset($context['loaded_attachments'][$row['id_msg']]))
1014
-					$context['loaded_attachments'][$row['id_msg']] = array();
1044
+				if (!isset($context['loaded_attachments'][$row['id_msg']])) {
1045
+									$context['loaded_attachments'][$row['id_msg']] = array();
1046
+				}
1015 1047
 			}
1016 1048
 			$smcFunc['db_free_result']($request);
1017 1049
 
1018 1050
 			// This is better than sorting it with the query...
1019 1051
 			ksort($temp);
1020 1052
 
1021
-			foreach ($temp as $row)
1022
-				$context['loaded_attachments'][$row['id_msg']][] = $row;
1053
+			foreach ($temp as $row) {
1054
+							$context['loaded_attachments'][$row['id_msg']][] = $row;
1055
+			}
1023 1056
 		}
1024 1057
 
1025 1058
 		$msg_parameters = array(
@@ -1046,21 +1079,23 @@  discard block
 block discarded – undo
1046 1079
 		);
1047 1080
 
1048 1081
 		// And the likes
1049
-		if (!empty($modSettings['enable_likes']))
1050
-			$context['my_likes'] = $context['user']['is_guest'] ? array() : prepareLikesContext($topic);
1082
+		if (!empty($modSettings['enable_likes'])) {
1083
+					$context['my_likes'] = $context['user']['is_guest'] ? array() : prepareLikesContext($topic);
1084
+		}
1051 1085
 
1052 1086
 		// Go to the last message if the given time is beyond the time of the last message.
1053
-		if (isset($context['start_from']) && $context['start_from'] >= $context['topicinfo']['num_replies'])
1054
-			$context['start_from'] = $context['topicinfo']['num_replies'];
1087
+		if (isset($context['start_from']) && $context['start_from'] >= $context['topicinfo']['num_replies']) {
1088
+					$context['start_from'] = $context['topicinfo']['num_replies'];
1089
+		}
1055 1090
 
1056 1091
 		// Since the anchor information is needed on the top of the page we load these variables beforehand.
1057 1092
 		$context['first_message'] = isset($messages[$firstIndex]) ? $messages[$firstIndex] : $messages[0];
1058
-		if (empty($options['view_newest_first']))
1059
-			$context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['start_from'];
1060
-		else
1061
-			$context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['topicinfo']['num_replies'] - $context['start_from'];
1062
-	}
1063
-	else
1093
+		if (empty($options['view_newest_first'])) {
1094
+					$context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['start_from'];
1095
+		} else {
1096
+					$context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['topicinfo']['num_replies'] - $context['start_from'];
1097
+		}
1098
+	} else
1064 1099
 	{
1065 1100
 		$messages_request = false;
1066 1101
 		$context['first_message'] = 0;
@@ -1096,8 +1131,9 @@  discard block
 block discarded – undo
1096 1131
 		'can_see_likes' => 'likes_view',
1097 1132
 		'can_like' => 'likes_like',
1098 1133
 	);
1099
-	foreach ($common_permissions as $contextual => $perm)
1100
-		$context[$contextual] = allowedTo($perm);
1134
+	foreach ($common_permissions as $contextual => $perm) {
1135
+			$context[$contextual] = allowedTo($perm);
1136
+	}
1101 1137
 
1102 1138
 	// Permissions with _any/_own versions.  $context[YYY] => ZZZ_any/_own.
1103 1139
 	$anyown_permissions = array(
@@ -1110,8 +1146,9 @@  discard block
 block discarded – undo
1110 1146
 		'can_reply_unapproved' => 'post_unapproved_replies',
1111 1147
 		'can_view_warning' => 'profile_warning',
1112 1148
 	);
1113
-	foreach ($anyown_permissions as $contextual => $perm)
1114
-		$context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own'));
1149
+	foreach ($anyown_permissions as $contextual => $perm) {
1150
+			$context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own'));
1151
+	}
1115 1152
 
1116 1153
 	if (!$user_info['is_admin'] && !$modSettings['topic_move_any'])
1117 1154
 	{
@@ -1157,8 +1194,9 @@  discard block
 block discarded – undo
1157 1194
 	// Check if the draft functions are enabled and that they have permission to use them (for quick reply.)
1158 1195
 	$context['drafts_save'] = !empty($modSettings['drafts_post_enabled']) && allowedTo('post_draft') && $context['can_reply'];
1159 1196
 	$context['drafts_autosave'] = !empty($context['drafts_save']) && !empty($modSettings['drafts_autosave_enabled']);
1160
-	if (!empty($context['drafts_save']))
1161
-		loadLanguage('Drafts');
1197
+	if (!empty($context['drafts_save'])) {
1198
+			loadLanguage('Drafts');
1199
+	}
1162 1200
 
1163 1201
 	// When was the last time this topic was replied to?  Should we warn them about it?
1164 1202
 	if (!empty($modSettings['oldTopicDays']) && ($context['can_reply'] || $context['can_reply_unapproved']) && empty($context['topicinfo']['is_sticky']))
@@ -1219,26 +1257,31 @@  discard block
 block discarded – undo
1219 1257
 	// Message icons - customized icons are off?
1220 1258
 	$context['icons'] = getMessageIcons($board);
1221 1259
 
1222
-	if (!empty($context['icons']))
1223
-		$context['icons'][count($context['icons']) - 1]['is_last'] = true;
1260
+	if (!empty($context['icons'])) {
1261
+			$context['icons'][count($context['icons']) - 1]['is_last'] = true;
1262
+	}
1224 1263
 
1225 1264
 	// Build the normal button array.
1226 1265
 	$context['normal_buttons'] = array();
1227 1266
 
1228
-	if ($context['can_reply'])
1229
-		$context['normal_buttons']['reply'] = array('text' => 'reply', 'image' => 'reply.png', 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';last_msg=' . $context['topic_last_message'], 'active' => true);
1267
+	if ($context['can_reply']) {
1268
+			$context['normal_buttons']['reply'] = array('text' => 'reply', 'image' => 'reply.png', 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';last_msg=' . $context['topic_last_message'], 'active' => true);
1269
+	}
1230 1270
 
1231
-	if ($context['can_add_poll'])
1232
-		$context['normal_buttons']['add_poll'] = array('text' => 'add_poll', 'image' => 'add_poll.png', 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']);
1271
+	if ($context['can_add_poll']) {
1272
+			$context['normal_buttons']['add_poll'] = array('text' => 'add_poll', 'image' => 'add_poll.png', 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']);
1273
+	}
1233 1274
 
1234
-	if ($context['can_mark_unread'])
1235
-		$context['normal_buttons']['mark_unread'] = array('text' => 'mark_unread', 'image' => 'markunread.png', 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
1275
+	if ($context['can_mark_unread']) {
1276
+			$context['normal_buttons']['mark_unread'] = array('text' => 'mark_unread', 'image' => 'markunread.png', 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
1277
+	}
1236 1278
 
1237
-	if ($context['can_print'])
1238
-		$context['normal_buttons']['print'] = array('text' => 'print', 'image' => 'print.png', 'custom' => 'rel="nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0');
1279
+	if ($context['can_print']) {
1280
+			$context['normal_buttons']['print'] = array('text' => 'print', 'image' => 'print.png', 'custom' => 'rel="nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0');
1281
+	}
1239 1282
 	
1240
-	if ($context['can_set_notify'])
1241
-		$context['normal_buttons']['notify'] = array(
1283
+	if ($context['can_set_notify']) {
1284
+			$context['normal_buttons']['notify'] = array(
1242 1285
 			'text' => 'notify_topic_' . $context['topic_notification_mode'],
1243 1286
 			'sub_buttons' => array(
1244 1287
 				array(
@@ -1260,38 +1303,47 @@  discard block
 block discarded – undo
1260 1303
 				),
1261 1304
 			),
1262 1305
 		);
1306
+	}
1263 1307
 
1264 1308
 	// Build the mod button array
1265 1309
 	$context['mod_buttons'] = array();
1266 1310
 
1267
-	if ($context['can_move'])
1268
-		$context['mod_buttons']['move'] = array('text' => 'move_topic', 'image' => 'admin_move.png', 'url' => $scripturl . '?action=movetopic;current_board=' . $context['current_board'] . ';topic=' . $context['current_topic'] . '.0');
1311
+	if ($context['can_move']) {
1312
+			$context['mod_buttons']['move'] = array('text' => 'move_topic', 'image' => 'admin_move.png', 'url' => $scripturl . '?action=movetopic;current_board=' . $context['current_board'] . ';topic=' . $context['current_topic'] . '.0');
1313
+	}
1269 1314
 
1270
-	if ($context['can_delete'])
1271
-		$context['mod_buttons']['delete'] = array('text' => 'remove_topic', 'image' => 'admin_rem.png', 'custom' => 'data-confirm="' . $txt['are_sure_remove_topic'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removetopic2;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']);
1315
+	if ($context['can_delete']) {
1316
+			$context['mod_buttons']['delete'] = array('text' => 'remove_topic', 'image' => 'admin_rem.png', 'custom' => 'data-confirm="' . $txt['are_sure_remove_topic'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removetopic2;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']);
1317
+	}
1272 1318
 
1273
-	if ($context['can_lock'])
1274
-		$context['mod_buttons']['lock'] = array('text' => empty($context['is_locked']) ? 'set_lock' : 'set_unlock', 'image' => 'admin_lock.png', 'url' => $scripturl . '?action=lock;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
1319
+	if ($context['can_lock']) {
1320
+			$context['mod_buttons']['lock'] = array('text' => empty($context['is_locked']) ? 'set_lock' : 'set_unlock', 'image' => 'admin_lock.png', 'url' => $scripturl . '?action=lock;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
1321
+	}
1275 1322
 
1276
-	if ($context['can_sticky'])
1277
-		$context['mod_buttons']['sticky'] = array('text' => empty($context['is_sticky']) ? 'set_sticky' : 'set_nonsticky', 'image' => 'admin_sticky.png', 'url' => $scripturl . '?action=sticky;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
1323
+	if ($context['can_sticky']) {
1324
+			$context['mod_buttons']['sticky'] = array('text' => empty($context['is_sticky']) ? 'set_sticky' : 'set_nonsticky', 'image' => 'admin_sticky.png', 'url' => $scripturl . '?action=sticky;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
1325
+	}
1278 1326
 
1279
-	if ($context['can_merge'])
1280
-		$context['mod_buttons']['merge'] = array('text' => 'merge', 'image' => 'merge.png', 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']);
1327
+	if ($context['can_merge']) {
1328
+			$context['mod_buttons']['merge'] = array('text' => 'merge', 'image' => 'merge.png', 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']);
1329
+	}
1281 1330
 
1282
-	if ($context['calendar_post'])
1283
-		$context['mod_buttons']['calendar'] = array('text' => 'calendar_link', 'image' => 'linktocal.png', 'url' => $scripturl . '?action=post;calendar;msg=' . $context['topic_first_message'] . ';topic=' . $context['current_topic'] . '.0');
1331
+	if ($context['calendar_post']) {
1332
+			$context['mod_buttons']['calendar'] = array('text' => 'calendar_link', 'image' => 'linktocal.png', 'url' => $scripturl . '?action=post;calendar;msg=' . $context['topic_first_message'] . ';topic=' . $context['current_topic'] . '.0');
1333
+	}
1284 1334
 
1285 1335
 	// Restore topic. eh?  No monkey business.
1286
-	if ($context['can_restore_topic'])
1287
-		$context['mod_buttons']['restore_topic'] = array('text' => 'restore_topic', 'image' => '', 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']);
1336
+	if ($context['can_restore_topic']) {
1337
+			$context['mod_buttons']['restore_topic'] = array('text' => 'restore_topic', 'image' => '', 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']);
1338
+	}
1288 1339
 
1289 1340
 	// Show a message in case a recently posted message became unapproved.
1290 1341
 	$context['becomesUnapproved'] = !empty($_SESSION['becomesUnapproved']) ? true : false;
1291 1342
 
1292 1343
 	// Don't want to show this forever...
1293
-	if ($context['becomesUnapproved'])
1294
-		unset($_SESSION['becomesUnapproved']);
1344
+	if ($context['becomesUnapproved']) {
1345
+			unset($_SESSION['becomesUnapproved']);
1346
+	}
1295 1347
 
1296 1348
 	// Allow adding new mod buttons easily.
1297 1349
 	// Note: $context['normal_buttons'] and $context['mod_buttons'] are added for backward compatibility with 2.0, but are deprecated and should not be used
@@ -1300,12 +1352,14 @@  discard block
 block discarded – undo
1300 1352
 	call_integration_hook('integrate_mod_buttons', array(&$context['mod_buttons']));
1301 1353
 
1302 1354
 	// Load the drafts js file
1303
-	if ($context['drafts_autosave'])
1304
-		loadJavaScriptFile('drafts.js', array('defer' => false), 'smf_drafts');
1355
+	if ($context['drafts_autosave']) {
1356
+			loadJavaScriptFile('drafts.js', array('defer' => false), 'smf_drafts');
1357
+	}
1305 1358
 
1306 1359
 	// Spellcheck
1307
-	if ($context['show_spellchecking'])
1308
-		loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck');
1360
+	if ($context['show_spellchecking']) {
1361
+			loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck');
1362
+	}
1309 1363
 
1310 1364
 	// topic.js
1311 1365
 	loadJavaScriptFile('topic.js', array('defer' => false), 'smf_topic');
@@ -1339,16 +1393,19 @@  discard block
 block discarded – undo
1339 1393
 	static $counter = null;
1340 1394
 
1341 1395
 	// If the query returned false, bail.
1342
-	if ($messages_request == false)
1343
-		return false;
1396
+	if ($messages_request == false) {
1397
+			return false;
1398
+	}
1344 1399
 
1345 1400
 	// Remember which message this is.  (ie. reply #83)
1346
-	if ($counter === null || $reset)
1347
-		$counter = empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start'];
1401
+	if ($counter === null || $reset) {
1402
+			$counter = empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start'];
1403
+	}
1348 1404
 
1349 1405
 	// Start from the beginning...
1350
-	if ($reset)
1351
-		return @$smcFunc['db_data_seek']($messages_request, 0);
1406
+	if ($reset) {
1407
+			return @$smcFunc['db_data_seek']($messages_request, 0);
1408
+	}
1352 1409
 
1353 1410
 	// Attempt to get the next message.
1354 1411
 	$message = $smcFunc['db_fetch_assoc']($messages_request);
@@ -1362,19 +1419,21 @@  discard block
 block discarded – undo
1362 1419
 	if (empty($context['icon_sources']))
1363 1420
 	{
1364 1421
 		$context['icon_sources'] = array();
1365
-		foreach ($context['stable_icons'] as $icon)
1366
-			$context['icon_sources'][$icon] = 'images_url';
1422
+		foreach ($context['stable_icons'] as $icon) {
1423
+					$context['icon_sources'][$icon] = 'images_url';
1424
+		}
1367 1425
 	}
1368 1426
 
1369 1427
 	// Message Icon Management... check the images exist.
1370 1428
 	if (empty($modSettings['messageIconChecks_disable']))
1371 1429
 	{
1372 1430
 		// If the current icon isn't known, then we need to do something...
1373
-		if (!isset($context['icon_sources'][$message['icon']]))
1374
-			$context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url';
1431
+		if (!isset($context['icon_sources'][$message['icon']])) {
1432
+					$context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url';
1433
+		}
1434
+	} elseif (!isset($context['icon_sources'][$message['icon']])) {
1435
+			$context['icon_sources'][$message['icon']] = 'images_url';
1375 1436
 	}
1376
-	elseif (!isset($context['icon_sources'][$message['icon']]))
1377
-		$context['icon_sources'][$message['icon']] = 'images_url';
1378 1437
 
1379 1438
 	// If you're a lazy bum, you probably didn't give a subject...
1380 1439
 	$message['subject'] = $message['subject'] != '' ? $message['subject'] : $txt['no_subject'];
@@ -1399,8 +1458,7 @@  discard block
 block discarded – undo
1399 1458
 		$memberContext[$message['id_member']]['email'] = $message['poster_email'];
1400 1459
 		$memberContext[$message['id_member']]['show_email'] = allowedTo('moderate_forum');
1401 1460
 		$memberContext[$message['id_member']]['is_guest'] = true;
1402
-	}
1403
-	else
1461
+	} else
1404 1462
 	{
1405 1463
 		// Define this here to make things a bit more readable
1406 1464
 		$can_view_warning = $context['user']['can_mod'] || allowedTo('view_warning_any') || ($message['id_member'] == $user_info['id'] && allowedTo('view_warning_own'));
@@ -1423,8 +1481,9 @@  discard block
 block discarded – undo
1423 1481
 	$message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']);
1424 1482
 
1425 1483
 	// If it's in the recycle bin we need to override whatever icon we did have.
1426
-	if (!empty($board_info['recycle']))
1427
-		$message['icon'] = 'recycled';
1484
+	if (!empty($board_info['recycle'])) {
1485
+			$message['icon'] = 'recycled';
1486
+	}
1428 1487
 
1429 1488
 	require_once($sourcedir . '/Subs-Attachments.php');
1430 1489
 
@@ -1468,32 +1527,36 @@  discard block
 block discarded – undo
1468 1527
 	}
1469 1528
 
1470 1529
 	// Are likes enable?
1471
-	if (!empty($modSettings['enable_likes']))
1472
-		$output['likes'] = array(
1530
+	if (!empty($modSettings['enable_likes'])) {
1531
+			$output['likes'] = array(
1473 1532
 			'count' => $message['likes'],
1474 1533
 			'you' => in_array($message['id_msg'], $context['my_likes']),
1475 1534
 			'can_like' => !$context['user']['is_guest'] && $message['id_member'] != $context['user']['id'] && !empty($context['can_like']),
1476 1535
 		);
1536
+	}
1477 1537
 
1478 1538
 	// Is this user the message author?
1479 1539
 	$output['is_message_author'] = $message['id_member'] == $user_info['id'];
1480
-	if (!empty($output['modified']['name']))
1481
-		$output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], $output['modified']['name']);
1540
+	if (!empty($output['modified']['name'])) {
1541
+			$output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], $output['modified']['name']);
1542
+	}
1482 1543
 
1483 1544
 	// Did they give a reason for editing?
1484
-	if (!empty($output['modified']['name']) && !empty($output['modified']['reason']))
1485
-		$output['modified']['last_edit_text'] .= '&nbsp;' . sprintf($txt['last_edit_reason'], $output['modified']['reason']);
1545
+	if (!empty($output['modified']['name']) && !empty($output['modified']['reason'])) {
1546
+			$output['modified']['last_edit_text'] .= '&nbsp;' . sprintf($txt['last_edit_reason'], $output['modified']['reason']);
1547
+	}
1486 1548
 
1487 1549
 	// Any custom profile fields?
1488
-	if (!empty($memberContext[$message['id_member']]['custom_fields']))
1489
-		foreach ($memberContext[$message['id_member']]['custom_fields'] as $custom)
1550
+	if (!empty($memberContext[$message['id_member']]['custom_fields'])) {
1551
+			foreach ($memberContext[$message['id_member']]['custom_fields'] as $custom)
1490 1552
 			$output['custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom;
1553
+	}
1491 1554
 
1492
-	if (empty($options['view_newest_first']))
1493
-		$counter++;
1494
-
1495
-	else
1496
-		$counter--;
1555
+	if (empty($options['view_newest_first'])) {
1556
+			$counter++;
1557
+	} else {
1558
+			$counter--;
1559
+	}
1497 1560
 
1498 1561
 	call_integration_hook('integrate_prepare_display_context', array(&$output, &$message, $counter));
1499 1562
 
@@ -1519,21 +1582,23 @@  discard block
 block discarded – undo
1519 1582
 	$context['no_last_modified'] = true;
1520 1583
 
1521 1584
 	// Prevent a preview image from being displayed twice.
1522
-	if (isset($_GET['action']) && $_GET['action'] == 'dlattach' && isset($_GET['type']) && ($_GET['type'] == 'avatar' || $_GET['type'] == 'preview'))
1523
-		return;
1585
+	if (isset($_GET['action']) && $_GET['action'] == 'dlattach' && isset($_GET['type']) && ($_GET['type'] == 'avatar' || $_GET['type'] == 'preview')) {
1586
+			return;
1587
+	}
1524 1588
 
1525 1589
 	// Make sure some attachment was requested!
1526
-	if (!isset($_REQUEST['attach']) && !isset($_REQUEST['id']))
1527
-		fatal_lang_error('no_access', false);
1590
+	if (!isset($_REQUEST['attach']) && !isset($_REQUEST['id'])) {
1591
+			fatal_lang_error('no_access', false);
1592
+	}
1528 1593
 
1529 1594
 	$_REQUEST['attach'] = isset($_REQUEST['attach']) ? (int) $_REQUEST['attach'] : (int) $_REQUEST['id'];
1530 1595
 
1531 1596
 	// Do we have a hook wanting to use our attachment system? We use $attachRequest to prevent accidental usage of $request.
1532 1597
 	$attachRequest = null;
1533 1598
 	call_integration_hook('integrate_download_request', array(&$attachRequest));
1534
-	if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest))
1535
-		$request = $attachRequest;
1536
-	else
1599
+	if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) {
1600
+			$request = $attachRequest;
1601
+	} else
1537 1602
 	{
1538 1603
 		// This checks only the current board for $board/$topic's permissions.
1539 1604
 		isAllowedTo('view_attachments');
@@ -1554,19 +1619,21 @@  discard block
 block discarded – undo
1554 1619
 		);
1555 1620
 	}
1556 1621
 
1557
-	if ($smcFunc['db_num_rows']($request) == 0)
1558
-		fatal_lang_error('no_access', false);
1622
+	if ($smcFunc['db_num_rows']($request) == 0) {
1623
+			fatal_lang_error('no_access', false);
1624
+	}
1559 1625
 
1560 1626
 	list ($id_folder, $real_filename, $file_hash, $file_ext, $id_attach, $attachment_type, $mime_type, $is_approved, $id_member) = $smcFunc['db_fetch_row']($request);
1561 1627
 	$smcFunc['db_free_result']($request);
1562 1628
 
1563 1629
 	// If it isn't yet approved, do they have permission to view it?
1564
-	if (!$is_approved && ($id_member == 0 || $user_info['id'] != $id_member) && ($attachment_type == 0 || $attachment_type == 3))
1565
-		isAllowedTo('approve_posts');
1630
+	if (!$is_approved && ($id_member == 0 || $user_info['id'] != $id_member) && ($attachment_type == 0 || $attachment_type == 3)) {
1631
+			isAllowedTo('approve_posts');
1632
+	}
1566 1633
 
1567 1634
 	// Update the download counter (unless it's a thumbnail).
1568
-	if ($attachment_type != 3)
1569
-		$smcFunc['db_query']('attach_download_increase', '
1635
+	if ($attachment_type != 3) {
1636
+			$smcFunc['db_query']('attach_download_increase', '
1570 1637
 			UPDATE LOW_PRIORITY {db_prefix}attachments
1571 1638
 			SET downloads = downloads + 1
1572 1639
 			WHERE id_attach = {int:id_attach}',
@@ -1574,15 +1641,15 @@  discard block
 block discarded – undo
1574 1641
 				'id_attach' => $id_attach,
1575 1642
 			)
1576 1643
 		);
1644
+	}
1577 1645
 
1578 1646
 	$filename = getAttachmentFilename($real_filename, $_REQUEST['attach'], $id_folder, false, $file_hash);
1579 1647
 
1580 1648
 	// This is done to clear any output that was made before now.
1581 1649
 	ob_end_clean();
1582
-	if (!empty($modSettings['enableCompressedOutput']) && @filesize($filename) <= 4194304 && in_array($file_ext, array('txt', 'html', 'htm', 'js', 'doc', 'docx', 'rtf', 'css', 'php', 'log', 'xml', 'sql', 'c', 'java')))
1583
-		@ob_start('ob_gzhandler');
1584
-
1585
-	else
1650
+	if (!empty($modSettings['enableCompressedOutput']) && @filesize($filename) <= 4194304 && in_array($file_ext, array('txt', 'html', 'htm', 'js', 'doc', 'docx', 'rtf', 'css', 'php', 'log', 'xml', 'sql', 'c', 'java'))) {
1651
+			@ob_start('ob_gzhandler');
1652
+	} else
1586 1653
 	{
1587 1654
 		ob_start();
1588 1655
 		header('Content-Encoding: none');
@@ -1625,8 +1692,9 @@  discard block
 block discarded – undo
1625 1692
 	// Send the attachment headers.
1626 1693
 	header('Pragma: ');
1627 1694
 
1628
-	if (!isBrowser('gecko'))
1629
-		header('Content-Transfer-Encoding: binary');
1695
+	if (!isBrowser('gecko')) {
1696
+			header('Content-Transfer-Encoding: binary');
1697
+	}
1630 1698
 
1631 1699
 	header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT');
1632 1700
 	header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($filename)) . ' GMT');
@@ -1635,18 +1703,19 @@  discard block
 block discarded – undo
1635 1703
 	header('ETag: ' . $eTag);
1636 1704
 
1637 1705
 	// Make sure the mime type warrants an inline display.
1638
-	if (isset($_REQUEST['image']) && !empty($mime_type) && strpos($mime_type, 'image/') !== 0)
1639
-		unset($_REQUEST['image']);
1706
+	if (isset($_REQUEST['image']) && !empty($mime_type) && strpos($mime_type, 'image/') !== 0) {
1707
+			unset($_REQUEST['image']);
1708
+	}
1640 1709
 
1641 1710
 	// Does this have a mime type?
1642
-	elseif (!empty($mime_type) && (isset($_REQUEST['image']) || !in_array($file_ext, array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff'))))
1643
-		header('Content-Type: ' . strtr($mime_type, array('image/bmp' => 'image/x-ms-bmp')));
1644
-
1645
-	else
1711
+	elseif (!empty($mime_type) && (isset($_REQUEST['image']) || !in_array($file_ext, array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) {
1712
+			header('Content-Type: ' . strtr($mime_type, array('image/bmp' => 'image/x-ms-bmp')));
1713
+	} else
1646 1714
 	{
1647 1715
 		header('Content-Type: ' . (isBrowser('ie') || isBrowser('opera') ? 'application/octetstream' : 'application/octet-stream'));
1648
-		if (isset($_REQUEST['image']))
1649
-			unset($_REQUEST['image']);
1716
+		if (isset($_REQUEST['image'])) {
1717
+					unset($_REQUEST['image']);
1718
+		}
1650 1719
 	}
1651 1720
 
1652 1721
 	// Convert the file to UTF-8, cuz most browsers dig that.
@@ -1654,23 +1723,22 @@  discard block
 block discarded – undo
1654 1723
 	$disposition = !isset($_REQUEST['image']) ? 'attachment' : 'inline';
1655 1724
 
1656 1725
 	// Different browsers like different standards...
1657
-	if (isBrowser('firefox'))
1658
-		header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)));
1659
-
1660
-	elseif (isBrowser('opera'))
1661
-		header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"');
1662
-
1663
-	elseif (isBrowser('ie'))
1664
-		header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"');
1665
-
1666
-	else
1667
-		header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"');
1726
+	if (isBrowser('firefox')) {
1727
+			header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)));
1728
+	} elseif (isBrowser('opera')) {
1729
+			header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"');
1730
+	} elseif (isBrowser('ie')) {
1731
+			header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"');
1732
+	} else {
1733
+			header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"');
1734
+	}
1668 1735
 
1669 1736
 	// If this has an "image extension" - but isn't actually an image - then ensure it isn't cached cause of silly IE.
1670
-	if (!isset($_REQUEST['image']) && in_array($file_ext, array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff')))
1671
-		header('Cache-Control: no-cache');
1672
-	else
1673
-		header('Cache-Control: max-age=' . (525600 * 60) . ', private');
1737
+	if (!isset($_REQUEST['image']) && in_array($file_ext, array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) {
1738
+			header('Cache-Control: no-cache');
1739
+	} else {
1740
+			header('Cache-Control: max-age=' . (525600 * 60) . ', private');
1741
+	}
1674 1742
 
1675 1743
 	header('Content-Length: ' . filesize($filename));
1676 1744
 
@@ -1680,20 +1748,23 @@  discard block
 block discarded – undo
1680 1748
 	// Recode line endings for text files, if enabled.
1681 1749
 	if (!empty($modSettings['attachmentRecodeLineEndings']) && !isset($_REQUEST['image']) && in_array($file_ext, array('txt', 'css', 'htm', 'html', 'php', 'xml')))
1682 1750
 	{
1683
-		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== false)
1684
-			$callback = function ($buffer)
1751
+		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== false) {
1752
+					$callback = function ($buffer)
1685 1753
 			{
1686 1754
 				return preg_replace('~[\r]?\n~', "\r\n", $buffer);
1755
+		}
1687 1756
 			};
1688
-		elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false)
1689
-			$callback = function ($buffer)
1757
+		elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
1758
+					$callback = function ($buffer)
1690 1759
 			{
1691 1760
 				return preg_replace('~[\r]?\n~', "\r", $buffer);
1761
+		}
1692 1762
 			};
1693
-		else
1694
-			$callback = function ($buffer)
1763
+		else {
1764
+					$callback = function ($buffer)
1695 1765
 			{
1696 1766
 				return preg_replace('~[\r]?\n~', "\n", $buffer);
1767
+		}
1697 1768
 			};
1698 1769
 	}
1699 1770
 
@@ -1701,23 +1772,26 @@  discard block
 block discarded – undo
1701 1772
 	if (filesize($filename) > 4194304)
1702 1773
 	{
1703 1774
 		// Forcibly end any output buffering going on.
1704
-		while (@ob_get_level() > 0)
1705
-			@ob_end_clean();
1775
+		while (@ob_get_level() > 0) {
1776
+					@ob_end_clean();
1777
+		}
1706 1778
 
1707 1779
 		$fp = fopen($filename, 'rb');
1708 1780
 		while (!feof($fp))
1709 1781
 		{
1710
-			if (isset($callback))
1711
-				echo $callback(fread($fp, 8192));
1712
-			else
1713
-				echo fread($fp, 8192);
1782
+			if (isset($callback)) {
1783
+							echo $callback(fread($fp, 8192));
1784
+			} else {
1785
+							echo fread($fp, 8192);
1786
+			}
1714 1787
 			flush();
1715 1788
 		}
1716 1789
 		fclose($fp);
1717 1790
 	}
1718 1791
 	// On some of the less-bright hosts, readfile() is disabled.  It's just a faster, more byte safe, version of what's in the if.
1719
-	elseif (isset($callback) || @readfile($filename) === null)
1720
-		echo isset($callback) ? $callback(file_get_contents($filename)) : file_get_contents($filename);
1792
+	elseif (isset($callback) || @readfile($filename) === null) {
1793
+			echo isset($callback) ? $callback(file_get_contents($filename)) : file_get_contents($filename);
1794
+	}
1721 1795
 
1722 1796
 	obExit(false);
1723 1797
 }
@@ -1730,8 +1804,9 @@  discard block
 block discarded – undo
1730 1804
  */
1731 1805
 function approved_attach_sort($a, $b)
1732 1806
 {
1733
-	if ($a['is_approved'] == $b['is_approved'])
1734
-		return 0;
1807
+	if ($a['is_approved'] == $b['is_approved']) {
1808
+			return 0;
1809
+	}
1735 1810
 
1736 1811
 	return $a['is_approved'] > $b['is_approved'] ? -1 : 1;
1737 1812
 }
@@ -1748,16 +1823,19 @@  discard block
 block discarded – undo
1748 1823
 
1749 1824
 	require_once($sourcedir . '/RemoveTopic.php');
1750 1825
 
1751
-	if (empty($_REQUEST['msgs']))
1752
-		redirectexit('topic=' . $topic . '.' . $_REQUEST['start']);
1826
+	if (empty($_REQUEST['msgs'])) {
1827
+			redirectexit('topic=' . $topic . '.' . $_REQUEST['start']);
1828
+	}
1753 1829
 
1754 1830
 	$messages = array();
1755
-	foreach ($_REQUEST['msgs'] as $dummy)
1756
-		$messages[] = (int) $dummy;
1831
+	foreach ($_REQUEST['msgs'] as $dummy) {
1832
+			$messages[] = (int) $dummy;
1833
+	}
1757 1834
 
1758 1835
 	// We are restoring messages. We handle this in another place.
1759
-	if (isset($_REQUEST['restore_selected']))
1760
-		redirectexit('action=restoretopic;msgs=' . implode(',', $messages) . ';' . $context['session_var'] . '=' . $context['session_id']);
1836
+	if (isset($_REQUEST['restore_selected'])) {
1837
+			redirectexit('action=restoretopic;msgs=' . implode(',', $messages) . ';' . $context['session_var'] . '=' . $context['session_id']);
1838
+	}
1761 1839
 	if (isset($_REQUEST['split_selection']))
1762 1840
 	{
1763 1841
 		$request = $smcFunc['db_query']('', '
@@ -1776,8 +1854,9 @@  discard block
 block discarded – undo
1776 1854
 	}
1777 1855
 
1778 1856
 	// Allowed to delete any message?
1779
-	if (allowedTo('delete_any'))
1780
-		$allowed_all = true;
1857
+	if (allowedTo('delete_any')) {
1858
+			$allowed_all = true;
1859
+	}
1781 1860
 	// Allowed to delete replies to their messages?
1782 1861
 	elseif (allowedTo('delete_replies'))
1783 1862
 	{
@@ -1794,13 +1873,14 @@  discard block
 block discarded – undo
1794 1873
 		$smcFunc['db_free_result']($request);
1795 1874
 
1796 1875
 		$allowed_all = $starter == $user_info['id'];
1876
+	} else {
1877
+			$allowed_all = false;
1797 1878
 	}
1798
-	else
1799
-		$allowed_all = false;
1800 1879
 
1801 1880
 	// Make sure they're allowed to delete their own messages, if not any.
1802
-	if (!$allowed_all)
1803
-		isAllowedTo('delete_own');
1881
+	if (!$allowed_all) {
1882
+			isAllowedTo('delete_own');
1883
+	}
1804 1884
 
1805 1885
 	// Allowed to remove which messages?
1806 1886
 	$request = $smcFunc['db_query']('', '
@@ -1820,8 +1900,9 @@  discard block
 block discarded – undo
1820 1900
 	$messages = array();
1821 1901
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1822 1902
 	{
1823
-		if (!$allowed_all && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time())
1824
-			continue;
1903
+		if (!$allowed_all && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) {
1904
+					continue;
1905
+		}
1825 1906
 
1826 1907
 		$messages[$row['id_msg']] = array($row['subject'], $row['id_member']);
1827 1908
 	}
@@ -1844,17 +1925,20 @@  discard block
 block discarded – undo
1844 1925
 	foreach ($messages as $message => $info)
1845 1926
 	{
1846 1927
 		// Just skip the first message - if it's not the last.
1847
-		if ($message == $first_message && $message != $last_message)
1848
-			continue;
1928
+		if ($message == $first_message && $message != $last_message) {
1929
+					continue;
1930
+		}
1849 1931
 		// If the first message is going then don't bother going back to the topic as we're effectively deleting it.
1850
-		elseif ($message == $first_message)
1851
-			$topicGone = true;
1932
+		elseif ($message == $first_message) {
1933
+					$topicGone = true;
1934
+		}
1852 1935
 
1853 1936
 		removeMessage($message);
1854 1937
 
1855 1938
 		// Log this moderation action ;).
1856
-		if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id']))
1857
-			logAction('delete', array('topic' => $topic, 'subject' => $info[0], 'member' => $info[1], 'board' => $board));
1939
+		if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) {
1940
+					logAction('delete', array('topic' => $topic, 'subject' => $info[0], 'member' => $info[1], 'board' => $board));
1941
+		}
1858 1942
 	}
1859 1943
 
1860 1944
 	redirectexit(!empty($topicGone) ? 'board=' . $board : 'topic=' . $topic . '.' . $_REQUEST['start']);
Please login to merge, or discard this patch.
Themes/index.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,8 @@
 block discarded – undo
10 10
 	header('Location: ' . $boardurl);
11 11
 }
12 12
 // Can't find it... just forget it.
13
-else
13
+else {
14 14
 	exit;
15
+}
15 16
 
16 17
 ?>
17 18
\ No newline at end of file
Please login to merge, or discard this patch.
Themes/default/ManageMaintenance.template.php 1 patch
Braces   +36 added lines, -25 removed lines patch added patch discarded remove patch
@@ -18,11 +18,12 @@  discard block
 block discarded – undo
18 18
 	global $context, $txt, $scripturl, $modSettings;
19 19
 
20 20
 	// If maintenance has finished tell the user.
21
-	if (!empty($context['maintenance_finished']))
22
-		echo '
21
+	if (!empty($context['maintenance_finished'])) {
22
+			echo '
23 23
 			<div class="infobox">
24 24
 				', sprintf($txt['maintain_done'], $context['maintenance_finished']), '
25 25
 			</div>';
26
+	}
26 27
 
27 28
 	echo '
28 29
 	<div id="manage_maintenance">
@@ -107,11 +108,12 @@  discard block
 block discarded – undo
107 108
 	<div id="manage_maintenance">';
108 109
 
109 110
 	// If maintenance has finished tell the user.
110
-	if (!empty($context['maintenance_finished']))
111
-		echo '
111
+	if (!empty($context['maintenance_finished'])) {
112
+			echo '
112 113
 			<div class="infobox">
113 114
 				', sprintf($txt['maintain_done'], $context['maintenance_finished']), '
114 115
 			</div>';
116
+	}
115 117
 
116 118
 	echo '
117 119
 		<div class="cat_bar">
@@ -238,11 +240,12 @@  discard block
 block discarded – undo
238 240
 	<div id="manage_maintenance">';
239 241
 
240 242
 	// If maintenance has finished tell the user.
241
-	if (!empty($context['maintenance_finished']))
242
-	echo '
243
+	if (!empty($context['maintenance_finished'])) {
244
+		echo '
243 245
 		<div class="infobox">
244 246
 			', sprintf($txt['maintain_done'], $context['maintenance_finished']), '
245 247
 		</div>';
248
+	}
246 249
 
247 250
 	echo '
248 251
 		<div class="cat_bar">
@@ -300,9 +303,10 @@  discard block
 block discarded – undo
300 303
 				<p><a href="#membersLink" onclick="swapMembers();"><img src="', $settings['images_url'], '/selected.png" alt="+" id="membersIcon"></a> <a href="#membersLink" onclick="swapMembers();" id="membersText" style="font-weight: bold;">', $txt['maintain_members_all'], '</a></p>
301 304
 				<div style="display: none; padding: 3px" id="membersPanel">';
302 305
 
303
-	foreach ($context['membergroups'] as $group)
304
-		echo '
306
+	foreach ($context['membergroups'] as $group) {
307
+			echo '
305 308
 					<label for="groups', $group['id'], '"><input type="checkbox" name="groups[', $group['id'], ']" id="groups', $group['id'], '" checked class="input_check"> ', $group['name'], '</label><br>';
309
+	}
306 310
 
307 311
 	echo '
308 312
 				</div>
@@ -346,11 +350,12 @@  discard block
 block discarded – undo
346 350
 	global $scripturl, $txt, $context, $settings, $modSettings;
347 351
 
348 352
 	// If maintenance has finished tell the user.
349
-	if (!empty($context['maintenance_finished']))
350
-		echo '
353
+	if (!empty($context['maintenance_finished'])) {
354
+			echo '
351 355
 			<div class="infobox">
352 356
 				', sprintf($txt['maintain_done'], $context['maintenance_finished']), '
353 357
 			</div>';
358
+	}
354 359
 
355 360
 	// Bit of javascript for showing which boards to prune in an otherwise hidden list.
356 361
 	echo '
@@ -418,19 +423,21 @@  discard block
 block discarded – undo
418 423
 								<ul>';
419 424
 
420 425
 		// Display a checkbox with every board.
421
-		foreach ($category['boards'] as $board)
422
-			echo '
426
+		foreach ($category['boards'] as $board) {
427
+					echo '
423 428
 									<li style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'] * 1.5, 'em;"><label for="boards_', $board['id'], '"><input type="checkbox" name="boards[', $board['id'], ']" id="boards_', $board['id'], '" checked class="input_check">', $board['name'], '</label></li>';
429
+		}
424 430
 
425 431
 		echo '
426 432
 								</ul>
427 433
 							</fieldset>';
428 434
 
429 435
 		// Increase $i, and check if we're at the middle yet.
430
-		if (++$i == $middle)
431
-			echo '
436
+		if (++$i == $middle) {
437
+					echo '
432 438
 						</div>
433 439
 						<div class="floatright" style="width: 49%;">';
440
+		}
434 441
 	}
435 442
 
436 443
 	echo '
@@ -469,9 +476,10 @@  discard block
 block discarded – undo
469 476
 		echo '
470 477
 					<optgroup label="', $category['name'], '">';
471 478
 
472
-		foreach ($category['boards'] as $board)
473
-			echo '
479
+		foreach ($category['boards'] as $board) {
480
+					echo '
474 481
 						<option value="', $board['id'], '"> ', str_repeat('==', $board['child_level']), '=&gt;&nbsp;', $board['name'], '</option>';
482
+		}
475 483
 
476 484
 		echo '
477 485
 					</optgroup>';
@@ -489,9 +497,10 @@  discard block
 block discarded – undo
489 497
 		echo '
490 498
 					<optgroup label="', $category['name'], '">';
491 499
 
492
-		foreach ($category['boards'] as $board)
493
-			echo '
500
+		foreach ($category['boards'] as $board) {
501
+					echo '
494 502
 						<option value="', $board['id'], '"> ', str_repeat('==', $board['child_level']), '=&gt;&nbsp;', $board['name'], '</option>';
503
+		}
495 504
 
496 505
 		echo '
497 506
 					</optgroup>';
@@ -531,9 +540,10 @@  discard block
 block discarded – undo
531 540
 				', $txt['database_optimize_attempt'], '<br>';
532 541
 
533 542
 	// List each table being optimized...
534
-	foreach ($context['optimized_tables'] as $table)
535
-		echo '
543
+	foreach ($context['optimized_tables'] as $table) {
544
+			echo '
536 545
 				', sprintf($txt['database_optimizing'], $table['name'], $table['data_freed']), '<br>';
546
+	}
537 547
 
538 548
 	// How did we go?
539 549
 	echo '
@@ -590,13 +600,14 @@  discard block
 block discarded – undo
590 600
 				', implode('</li><li>', $context['exceeding_messages']), '
591 601
 				</li>
592 602
 			</ul>';
593
-		if (!empty($context['exceeding_messages_morethan']))
594
-			echo '
603
+		if (!empty($context['exceeding_messages_morethan'])) {
604
+					echo '
595 605
 			<p>', $context['exceeding_messages_morethan'], '</p>';
596
-	}
597
-	else
598
-		echo '
606
+		}
607
+	} else {
608
+			echo '
599 609
 			<p class="infobox">', $txt['convert_to_text'], '</p>';
610
+	}
600 611
 
601 612
 	echo '
602 613
 			<form action="', $scripturl, '?action=admin;area=maintain;sa=database;activity=convertmsgbody" method="post" accept-charset="', $context['character_set'], '">
Please login to merge, or discard this patch.
Themes/default/index.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,9 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Try to handle it with the upper level index.php. (it should know what to do.)
4
-if (file_exists(dirname(dirname(__FILE__)) . '/index.php'))
4
+if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) {
5 5
 	include (dirname(dirname(__FILE__)) . '/index.php');
6
-else
6
+} else {
7 7
 	exit;
8
+}
8 9
 
9 10
 ?>
10 11
\ No newline at end of file
Please login to merge, or discard this patch.
Themes/default/Reports.template.php 1 patch
Braces   +32 added lines, -24 removed lines patch added patch discarded remove patch
@@ -29,9 +29,10 @@  discard block
 block discarded – undo
29 29
 	// Go through each type of report they can run.
30 30
 	foreach ($context['report_types'] as $type)
31 31
 	{
32
-		if (isset($type['description']))
33
-			echo '
32
+		if (isset($type['description'])) {
33
+					echo '
34 34
 					<dt>', $type['description'], '</dt>';
35
+		}
35 36
 		echo '
36 37
 					<dd>
37 38
 						<input type="radio" id="rt_', $type['id'], '" name="rt" value="', $type['id'], '"', $type['is_first'] ? ' checked' : '', ' class="input_radio">
@@ -61,8 +62,9 @@  discard block
 block discarded – undo
61 62
 		</div>
62 63
 		<div id="report_buttons">';
63 64
 
64
-	if (!empty($context['report_buttons']))
65
-		template_button_strip($context['report_buttons'], 'right');
65
+	if (!empty($context['report_buttons'])) {
66
+			template_button_strip($context['report_buttons'], 'right');
67
+	}
66 68
 
67 69
 	echo '
68 70
 		</div>';
@@ -73,25 +75,27 @@  discard block
 block discarded – undo
73 75
 		echo '
74 76
 		<table class="table_grid report_results">';
75 77
 
76
-		if (!empty($table['title']))
77
-			echo '
78
+		if (!empty($table['title'])) {
79
+					echo '
78 80
 			<thead>
79 81
 				<tr class="title_bar">
80 82
 					<th scope="col" colspan="', $table['column_count'], '">', $table['title'], '</th>
81 83
 				</tr>
82 84
 			</thead>
83 85
 			<tbody>';
86
+		}
84 87
 
85 88
 		// Now do each row!
86 89
 		$row_number = 0;
87 90
 		foreach ($table['data'] as $row)
88 91
 		{
89
-			if ($row_number == 0 && !empty($table['shading']['top']))
90
-				echo '
92
+			if ($row_number == 0 && !empty($table['shading']['top'])) {
93
+							echo '
91 94
 				<tr class="windowbg table_caption">';
92
-			else
93
-				echo '
95
+			} else {
96
+							echo '
94 97
 				<tr class="', !empty($row[0]['separator']) ? 'title_bar' : 'windowbg', '">';
98
+			}
95 99
 
96 100
 			// Now do each column.
97 101
 			$column_number = 0;
@@ -109,16 +113,17 @@  discard block
 block discarded – undo
109 113
 				}
110 114
 
111 115
 				// Shaded?
112
-				if ($column_number == 0 && !empty($table['shading']['left']))
113
-					echo '
116
+				if ($column_number == 0 && !empty($table['shading']['left'])) {
117
+									echo '
114 118
 					<td class="table_caption ', $table['align']['shaded'], 'text"', $table['width']['shaded'] != 'auto' ? ' width="' . $table['width']['shaded'] . '"' : '', '>
115 119
 						', $data['v'] == $table['default_value'] ? '' : ($data['v'] . (empty($data['v']) ? '' : ':')), '
116 120
 					</td>';
117
-				else
118
-					echo '
121
+				} else {
122
+									echo '
119 123
 					<td class="smalltext centertext" ', $table['width']['normal'] != 'auto' ? ' width="' . $table['width']['normal'] . '"' : '', !empty($data['style']) ? ' style="' . $data['style'] . '"' : '', '>
120 124
 						', $data['v'], '
121 125
 					</td>';
126
+				}
122 127
 
123 128
 				$column_number++;
124 129
 			}
@@ -167,24 +172,26 @@  discard block
 block discarded – undo
167 172
 		<div style="overflow: visible;', $table['max_width'] != 'auto' ? ' width: ' . $table['max_width'] . 'px;' : '', '">
168 173
 			<table class="bordercolor">';
169 174
 
170
-		if (!empty($table['title']))
171
-			echo '
175
+		if (!empty($table['title'])) {
176
+					echo '
172 177
 				<tr class="title_bar">
173 178
 					<td colspan="', $table['column_count'], '">
174 179
 						', $table['title'], '
175 180
 					</td>
176 181
 				</tr>';
182
+		}
177 183
 
178 184
 		// Now do each row!
179 185
 		$row_number = 0;
180 186
 		foreach ($table['data'] as $row)
181 187
 		{
182
-			if ($row_number == 0 && !empty($table['shading']['top']))
183
-				echo '
188
+			if ($row_number == 0 && !empty($table['shading']['top'])) {
189
+							echo '
184 190
 				<tr class="titlebg">';
185
-			else
186
-				echo '
191
+			} else {
192
+							echo '
187 193
 				<tr class="windowbg">';
194
+			}
188 195
 
189 196
 			// Now do each column!!
190 197
 			$column_number = 0;
@@ -201,16 +208,17 @@  discard block
 block discarded – undo
201 208
 				}
202 209
 
203 210
 				// Shaded?
204
-				if ($column_number == 0 && !empty($table['shading']['left']))
205
-					echo '
211
+				if ($column_number == 0 && !empty($table['shading']['left'])) {
212
+									echo '
206 213
 					<td class="titlebg ', $table['align']['shaded'], 'text"', $table['width']['shaded'] != 'auto' ? ' width="' . $table['width']['shaded'] . '"' : '', '>
207 214
 						', $data['v'] == $table['default_value'] ? '' : ($data['v'] . (empty($data['v']) ? '' : ':')), '
208 215
 					</td>';
209
-				else
210
-					echo '
216
+				} else {
217
+									echo '
211 218
 					<td class="centertext" ', $table['width']['normal'] != 'auto' ? ' width="' . $table['width']['normal'] . '"' : '', !empty($data['style']) ? ' style="' . $data['style'] . '"' : '', '>
212 219
 						', $data['v'], '
213 220
 					</td>';
221
+				}
214 222
 
215 223
 				$column_number++;
216 224
 			}
Please login to merge, or discard this patch.
Themes/default/images/index.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,9 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Try to handle it with the upper level index.php. (it should know what to do.)
4
-if (file_exists(dirname(dirname(__FILE__)) . '/index.php'))
4
+if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) {
5 5
 	include (dirname(dirname(__FILE__)) . '/index.php');
6
-else
6
+} else {
7 7
 	exit;
8
+}
8 9
 
9 10
 ?>
10 11
\ No newline at end of file
Please login to merge, or discard this patch.
Themes/default/images/topic/index.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,9 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Try to handle it with the upper level index.php. (it should know what to do.)
4
-if (file_exists(dirname(dirname(__FILE__)) . '/index.php'))
4
+if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) {
5 5
 	include (dirname(dirname(__FILE__)) . '/index.php');
6
-else
6
+} else {
7 7
 	exit;
8
+}
8 9
 
9 10
 ?>
10 11
\ No newline at end of file
Please login to merge, or discard this patch.
Themes/default/images/icons/index.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,9 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Try to handle it with the upper level index.php. (it should know what to do.)
4
-if (file_exists(dirname(dirname(__FILE__)) . '/index.php'))
4
+if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) {
5 5
 	include (dirname(dirname(__FILE__)) . '/index.php');
6
-else
6
+} else {
7 7
 	exit;
8
+}
8 9
 
9 10
 ?>
10 11
\ No newline at end of file
Please login to merge, or discard this patch.