Completed
Pull Request — release-2.1 (#4221)
by Rick
13:35 queued 03:37
created
Sources/MessageIndex.php 1 patch
Braces   +264 added lines, -197 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 4
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * Show the list of topics in this board, along with any child boards.
@@ -56,8 +57,9 @@  discard block
 block discarded – undo
56 57
 
57 58
 	$context['name'] = $board_info['name'];
58 59
 	$context['description'] = $board_info['description'];
59
-	if (!empty($board_info['description']))
60
-		$context['meta_description'] = strip_tags($board_info['description']);
60
+	if (!empty($board_info['description'])) {
61
+			$context['meta_description'] = strip_tags($board_info['description']);
62
+	}
61 63
 
62 64
 	// How many topics do we have in total?
63 65
 	$board_info['total_topics'] = allowedTo('approve_posts') ? $board_info['num_topics'] + $board_info['unapproved_topics'] : $board_info['num_topics'] + $board_info['unapproved_user_topics'];
@@ -73,12 +75,14 @@  discard block
 block discarded – undo
73 75
 		$session_name = session_name();
74 76
 		foreach ($_GET as $k => $v)
75 77
 		{
76
-			if (!in_array($k, array('board', 'start', $session_name)))
77
-				$context['robot_no_index'] = true;
78
+			if (!in_array($k, array('board', 'start', $session_name))) {
79
+							$context['robot_no_index'] = true;
80
+			}
78 81
 		}
79 82
 	}
80
-	if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0))
81
-		$context['robot_no_index'] = true;
83
+	if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) {
84
+			$context['robot_no_index'] = true;
85
+	}
82 86
 
83 87
 	// If we can view unapproved messages and there are some build up a list.
84 88
 	if (allowedTo('approve_posts') && ($board_info['unapproved_topics'] || $board_info['unapproved_posts']))
@@ -89,14 +93,16 @@  discard block
 block discarded – undo
89 93
 	}
90 94
 
91 95
 	// We only know these.
92
-	if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post')))
93
-		$_REQUEST['sort'] = 'last_post';
96
+	if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post'))) {
97
+			$_REQUEST['sort'] = 'last_post';
98
+	}
94 99
 
95 100
 	// Make sure the starting place makes sense and construct the page index.
96
-	if (isset($_REQUEST['sort']))
97
-		$context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $maxindex, true);
98
-	else
99
-		$context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $maxindex, true);
101
+	if (isset($_REQUEST['sort'])) {
102
+			$context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $maxindex, true);
103
+	} else {
104
+			$context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $maxindex, true);
105
+	}
100 106
 	$context['start'] = &$_REQUEST['start'];
101 107
 
102 108
 	// Set a canonical URL for this page.
@@ -132,14 +138,16 @@  discard block
 block discarded – undo
132 138
 	$context['link_moderators'] = array();
133 139
 	if (!empty($board_info['moderators']))
134 140
 	{
135
-		foreach ($board_info['moderators'] as $mod)
136
-			$context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>';
141
+		foreach ($board_info['moderators'] as $mod) {
142
+					$context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>';
143
+		}
137 144
 	}
138 145
 	if (!empty($board_info['moderator_groups']))
139 146
 	{
140 147
 		// By default just tack the moderator groups onto the end of the members
141
-		foreach ($board_info['moderator_groups'] as $mod_group)
142
-			$context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>';
148
+		foreach ($board_info['moderator_groups'] as $mod_group) {
149
+					$context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>';
150
+		}
143 151
 	}
144 152
 
145 153
 	// Now we tack the info onto the end of the linktree
@@ -191,20 +199,24 @@  discard block
 block discarded – undo
191 199
 		);
192 200
 		while ($row = $smcFunc['db_fetch_assoc']($request))
193 201
 		{
194
-			if (empty($row['id_member']))
195
-				continue;
202
+			if (empty($row['id_member'])) {
203
+							continue;
204
+			}
196 205
 
197
-			if (!empty($row['online_color']))
198
-				$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>';
199
-			else
200
-				$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
206
+			if (!empty($row['online_color'])) {
207
+							$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>';
208
+			} else {
209
+							$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
210
+			}
201 211
 
202 212
 			$is_buddy = in_array($row['id_member'], $user_info['buddies']);
203
-			if ($is_buddy)
204
-				$link = '<strong>' . $link . '</strong>';
213
+			if ($is_buddy) {
214
+							$link = '<strong>' . $link . '</strong>';
215
+			}
205 216
 
206
-			if (!empty($row['show_online']) || allowedTo('moderate_forum'))
207
-				$context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link;
217
+			if (!empty($row['show_online']) || allowedTo('moderate_forum')) {
218
+							$context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link;
219
+			}
208 220
 			// @todo why are we filling this array of data that are just counted (twice) and discarded? ???
209 221
 			$context['view_members'][$row['log_time'] . $row['member_name']] = array(
210 222
 				'id' => $row['id_member'],
@@ -217,8 +229,9 @@  discard block
 block discarded – undo
217 229
 				'hidden' => empty($row['show_online']),
218 230
 			);
219 231
 
220
-			if (empty($row['show_online']))
221
-				$context['view_num_hidden']++;
232
+			if (empty($row['show_online'])) {
233
+							$context['view_num_hidden']++;
234
+			}
222 235
 		}
223 236
 		$context['view_num_guests'] = $smcFunc['db_num_rows']($request) - count($context['view_members']);
224 237
 		$smcFunc['db_free_result']($request);
@@ -257,8 +270,9 @@  discard block
 block discarded – undo
257 270
 	$context['sort_direction'] = $ascending ? 'up' : 'down';
258 271
 	$txt['starter'] = $txt['started_by'];
259 272
 
260
-	foreach ($sort_methods as $key => $val)
261
-		$context['topics_headers'][$key] = '<a href="' . $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=' . $key . ($context['sort_by'] == $key && $context['sort_direction'] == 'up' ? ';desc' : '') . '">' . $txt[$key] . ($context['sort_by'] == $key ? '<span class="sort sort_' . $context['sort_direction'] . '"></span>' : '') . '</a>';
273
+	foreach ($sort_methods as $key => $val) {
274
+			$context['topics_headers'][$key] = '<a href="' . $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=' . $key . ($context['sort_by'] == $key && $context['sort_direction'] == 'up' ? ';desc' : '') . '">' . $txt[$key] . ($context['sort_by'] == $key ? '<span class="sort sort_' . $context['sort_direction'] . '"></span>' : '') . '</a>';
275
+	}
262 276
 
263 277
 	// Calculate the fastest way to get the topics.
264 278
 	$start = (int) $_REQUEST['start'];
@@ -268,14 +282,15 @@  discard block
 block discarded – undo
268 282
 		$fake_ascending = true;
269 283
 		$maxindex = $board_info['total_topics'] < $start + $maxindex + 1 ? $board_info['total_topics'] - $start : $maxindex;
270 284
 		$start = $board_info['total_topics'] < $start + $maxindex + 1 ? 0 : $board_info['total_topics'] - $start - $maxindex;
285
+	} else {
286
+			$fake_ascending = false;
271 287
 	}
272
-	else
273
-		$fake_ascending = false;
274 288
 
275 289
 	// Setup the default topic icons...
276 290
 	$context['icon_sources'] = array();
277
-	foreach ($context['stable_icons'] as $icon)
278
-		$context['icon_sources'][$icon] = 'images_url';
291
+	foreach ($context['stable_icons'] as $icon) {
292
+			$context['icon_sources'][$icon] = 'images_url';
293
+	}
279 294
 
280 295
 	$topic_ids = array();
281 296
 	$context['topics'] = array();
@@ -306,8 +321,9 @@  discard block
 block discarded – undo
306 321
 			)
307 322
 		);
308 323
 		$topic_ids = array();
309
-		while ($row = $smcFunc['db_fetch_assoc']($request))
310
-			$topic_ids[] = $row['id_topic'];
324
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
325
+					$topic_ids[] = $row['id_topic'];
326
+		}
311 327
 	}
312 328
 
313 329
 	// Grab the appropriate topic information...
@@ -363,11 +379,13 @@  discard block
 block discarded – undo
363 379
 		// Begin 'printing' the message index for current board.
364 380
 		while ($row = $smcFunc['db_fetch_assoc']($result))
365 381
 		{
366
-			if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0')
367
-				continue;
382
+			if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') {
383
+							continue;
384
+			}
368 385
 
369
-			if (!$pre_query)
370
-				$topic_ids[] = $row['id_topic'];
386
+			if (!$pre_query) {
387
+							$topic_ids[] = $row['id_topic'];
388
+			}
371 389
 
372 390
 			// Reference the main color class.
373 391
 			$colorClass = 'windowbg';
@@ -377,8 +395,9 @@  discard block
 block discarded – undo
377 395
 			{
378 396
 				// Limit them to $modSettings['preview_characters'] characters
379 397
 				$row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br>' => '&#10;')));
380
-				if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters'])
381
-					$row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...';
398
+				if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters']) {
399
+									$row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...';
400
+				}
382 401
 
383 402
 				// Censor the subject and message preview.
384 403
 				censorText($row['first_subject']);
@@ -389,27 +408,27 @@  discard block
 block discarded – undo
389 408
 				{
390 409
 					$row['last_subject'] = $row['first_subject'];
391 410
 					$row['last_body'] = $row['first_body'];
392
-				}
393
-				else
411
+				} else
394 412
 				{
395 413
 					$row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => '&#10;')));
396
-					if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters'])
397
-						$row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...';
414
+					if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters']) {
415
+											$row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...';
416
+					}
398 417
 
399 418
 					censorText($row['last_subject']);
400 419
 					censorText($row['last_body']);
401 420
 				}
402
-			}
403
-			else
421
+			} else
404 422
 			{
405 423
 				$row['first_body'] = '';
406 424
 				$row['last_body'] = '';
407 425
 				censorText($row['first_subject']);
408 426
 
409
-				if ($row['id_first_msg'] == $row['id_last_msg'])
410
-					$row['last_subject'] = $row['first_subject'];
411
-				else
412
-					censorText($row['last_subject']);
427
+				if ($row['id_first_msg'] == $row['id_last_msg']) {
428
+									$row['last_subject'] = $row['first_subject'];
429
+				} else {
430
+									censorText($row['last_subject']);
431
+				}
413 432
 			}
414 433
 
415 434
 			// Decide how many pages the topic should have.
@@ -420,42 +439,50 @@  discard block
 block discarded – undo
420 439
 				$pages = constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $row['num_replies'] + 1, $context['messages_per_page'], true, false);
421 440
 
422 441
 				// If we can use all, show all.
423
-				if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages'])
424
-					$pages .= ' &nbsp;<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>';
442
+				if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages']) {
443
+									$pages .= ' &nbsp;<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>';
444
+				}
445
+			} else {
446
+							$pages = '';
425 447
 			}
426
-			else
427
-				$pages = '';
428 448
 
429 449
 			// We need to check the topic icons exist...
430 450
 			if (!empty($modSettings['messageIconChecks_enable']))
431 451
 			{
432
-				if (!isset($context['icon_sources'][$row['first_icon']]))
433
-					$context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url';
434
-				if (!isset($context['icon_sources'][$row['last_icon']]))
435
-					$context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url';
436
-			}
437
-			else
452
+				if (!isset($context['icon_sources'][$row['first_icon']])) {
453
+									$context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url';
454
+				}
455
+				if (!isset($context['icon_sources'][$row['last_icon']])) {
456
+									$context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url';
457
+				}
458
+			} else
438 459
 			{
439
-				if (!isset($context['icon_sources'][$row['first_icon']]))
440
-					$context['icon_sources'][$row['first_icon']] = 'images_url';
441
-				if (!isset($context['icon_sources'][$row['last_icon']]))
442
-					$context['icon_sources'][$row['last_icon']] = 'images_url';
460
+				if (!isset($context['icon_sources'][$row['first_icon']])) {
461
+									$context['icon_sources'][$row['first_icon']] = 'images_url';
462
+				}
463
+				if (!isset($context['icon_sources'][$row['last_icon']])) {
464
+									$context['icon_sources'][$row['last_icon']] = 'images_url';
465
+				}
443 466
 			}
444 467
 
445
-			if (!empty($board_info['recycle']))
446
-				$row['first_icon'] = 'recycled';
468
+			if (!empty($board_info['recycle'])) {
469
+							$row['first_icon'] = 'recycled';
470
+			}
447 471
 
448 472
 			// Is this topic pending approval, or does it have any posts pending approval?
449
-			if ($context['can_approve_posts'] && $row['unapproved_posts'])
450
-				$colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost');
473
+			if ($context['can_approve_posts'] && $row['unapproved_posts']) {
474
+							$colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost');
475
+			}
451 476
 
452 477
 			// Sticky topics should get a different color, too.
453
-			if ($row['is_sticky'])
454
-				$colorClass .= ' sticky';
478
+			if ($row['is_sticky']) {
479
+							$colorClass .= ' sticky';
480
+			}
455 481
 
456 482
 			// Locked topics get special treatment as well.
457
-			if ($row['locked'])
458
-				$colorClass .= ' locked';
483
+			if ($row['locked']) {
484
+							$colorClass .= ' locked';
485
+			}
459 486
 
460 487
 			// 'Print' the topic info.
461 488
 			$context['topics'][$row['id_topic']] = array_merge($row, array(
@@ -536,8 +563,9 @@  discard block
 block discarded – undo
536 563
 		$smcFunc['db_free_result']($result);
537 564
 
538 565
 		// Fix the sequence of topics if they were retrieved in the wrong order. (for speed reasons...)
539
-		if ($fake_ascending)
540
-			$context['topics'] = array_reverse($context['topics'], true);
566
+		if ($fake_ascending) {
567
+					$context['topics'] = array_reverse($context['topics'], true);
568
+		}
541 569
 
542 570
 		if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest'] && !empty($topic_ids))
543 571
 		{
@@ -554,8 +582,9 @@  discard block
 block discarded – undo
554 582
 					'limit' => count($topic_ids),
555 583
 				)
556 584
 			);
557
-			while ($row = $smcFunc['db_fetch_assoc']($result))
558
-				$context['topics'][$row['id_topic']]['is_posted_in'] = true;
585
+			while ($row = $smcFunc['db_fetch_assoc']($result)) {
586
+							$context['topics'][$row['id_topic']]['is_posted_in'] = true;
587
+			}
559 588
 			$smcFunc['db_free_result']($result);
560 589
 		}
561 590
 	}
@@ -580,9 +609,9 @@  discard block
 block discarded – undo
580 609
 		// Can we restore topics?
581 610
 		$context['can_restore'] = allowedTo('move_any') && !empty($board_info['recycle']);
582 611
 
583
-		if ($user_info['is_admin'] || $modSettings['topic_move_any'])
584
-			$context['can_move_any'] = true;
585
-		else
612
+		if ($user_info['is_admin'] || $modSettings['topic_move_any']) {
613
+					$context['can_move_any'] = true;
614
+		} else
586 615
 		{
587 616
 			// We'll use this in a minute
588 617
 			$boards_allowed = boardsAllowedTo('post_new');
@@ -609,11 +638,13 @@  discard block
 block discarded – undo
609 638
 		}
610 639
 
611 640
 		// Can we use quick moderation checkboxes?
612
-		if ($options['display_quick_mod'] == 1)
613
-			$context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore'];
641
+		if ($options['display_quick_mod'] == 1) {
642
+					$context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore'];
643
+		}
614 644
 		// Or the icons?
615
-		else
616
-			$context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'];
645
+		else {
646
+					$context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'];
647
+		}
617 648
 	}
618 649
 
619 650
 	if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1)
@@ -647,13 +678,15 @@  discard block
 block discarded – undo
647 678
 			);
648 679
 
649 680
 			// We've seen all these boards now!
650
-			foreach ($board_info['parent_boards'] as $k => $dummy)
651
-				if (isset($_SESSION['topicseen_cache'][$k]))
681
+			foreach ($board_info['parent_boards'] as $k => $dummy) {
682
+							if (isset($_SESSION['topicseen_cache'][$k]))
652 683
 					unset($_SESSION['topicseen_cache'][$k]);
684
+			}
653 685
 		}
654 686
 
655
-		if (isset($_SESSION['topicseen_cache'][$board]))
656
-			unset($_SESSION['topicseen_cache'][$board]);
687
+		if (isset($_SESSION['topicseen_cache'][$board])) {
688
+					unset($_SESSION['topicseen_cache'][$board]);
689
+		}
657 690
 
658 691
 		$request = $smcFunc['db_query']('', '
659 692
 			SELECT id_topic, id_board, sent
@@ -674,8 +707,9 @@  discard block
 block discarded – undo
674 707
 				$context['is_marked_notify'] = true;
675 708
 				$board_sent = $row['sent'];
676 709
 			}
677
-			if (!empty($row['id_topic']))
678
-				$context['topics'][$row['id_topic']]['is_watched'] = true;
710
+			if (!empty($row['id_topic'])) {
711
+							$context['topics'][$row['id_topic']]['is_watched'] = true;
712
+			}
679 713
 		}
680 714
 		$smcFunc['db_free_result']($request);
681 715
 
@@ -699,8 +733,7 @@  discard block
 block discarded – undo
699 733
 		$pref = !empty($pref[$user_info['id']]) ? $pref[$user_info['id']] : array();
700 734
 		$pref = isset($pref['board_notify_' . $board]) ? $pref['board_notify_' . $board] : (!empty($pref['board_notify']) ? $pref['board_notify'] : 0);
701 735
 		$context['board_notification_mode'] = !$context['is_marked_notify'] ? 1 : ($pref & 0x02 ? 3 : ($pref & 0x01 ? 2 : 1));
702
-	}
703
-	else
736
+	} else
704 737
 	{
705 738
 		$context['is_marked_notify'] = false;
706 739
 		$context['board_notification_mode'] = 1;
@@ -713,23 +746,27 @@  discard block
 block discarded – undo
713 746
 	$context['becomesUnapproved'] = !empty($_SESSION['becomesUnapproved']) ? true : false;
714 747
 
715 748
 	// Don't want to show this forever...
716
-	if ($context['becomesUnapproved'])
717
-		unset($_SESSION['becomesUnapproved']);
749
+	if ($context['becomesUnapproved']) {
750
+			unset($_SESSION['becomesUnapproved']);
751
+	}
718 752
 
719 753
 	// Build the message index button array.
720 754
 	$context['normal_buttons'] = array();
721 755
 
722
-	if ($context['can_post_new'])
723
-		$context['normal_buttons']['new_topic'] = array('text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true);
756
+	if ($context['can_post_new']) {
757
+			$context['normal_buttons']['new_topic'] = array('text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true);
758
+	}
724 759
 
725
-	if ($context['can_post_poll'])
726
-		$context['normal_buttons']['post_poll'] = array('text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll');
760
+	if ($context['can_post_poll']) {
761
+			$context['normal_buttons']['post_poll'] = array('text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll');
762
+	}
727 763
 
728
-	if (!$context['user']['is_logged'])
729
-		$context['normal_buttons']['markread'] = array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']);
764
+	if (!$context['user']['is_logged']) {
765
+			$context['normal_buttons']['markread'] = array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']);
766
+	}
730 767
 
731
-	if ($context['can_mark_notify'])
732
-		$context['normal_buttons']['notify'] = array(
768
+	if ($context['can_mark_notify']) {
769
+			$context['normal_buttons']['notify'] = array(
733 770
 			'lang' => true,
734 771
 			'text' => 'notify_board_' . $context['board_notification_mode'],
735 772
 			'sub_buttons' => array(
@@ -747,6 +784,7 @@  discard block
 block discarded – undo
747 784
 				),
748 785
 			),
749 786
 		);
787
+	}
750 788
 
751 789
 	// Javascript for inline editing.
752 790
 	loadJavaScriptFile('topic.js', array('defer' => false), 'smf_topic');
@@ -768,18 +806,21 @@  discard block
 block discarded – undo
768 806
 	checkSession('request');
769 807
 
770 808
 	// Lets go straight to the restore area.
771
-	if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics']))
772
-		redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']);
809
+	if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics'])) {
810
+			redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']);
811
+	}
773 812
 
774
-	if (isset($_SESSION['topicseen_cache']))
775
-		$_SESSION['topicseen_cache'] = array();
813
+	if (isset($_SESSION['topicseen_cache'])) {
814
+			$_SESSION['topicseen_cache'] = array();
815
+	}
776 816
 
777 817
 	// This is going to be needed to send off the notifications and for updateLastMessages().
778 818
 	require_once($sourcedir . '/Subs-Post.php');
779 819
 
780 820
 	// Remember the last board they moved things to.
781
-	if (isset($_REQUEST['move_to']))
782
-		$_SESSION['move_to_topic'] = $_REQUEST['move_to'];
821
+	if (isset($_REQUEST['move_to'])) {
822
+			$_SESSION['move_to_topic'] = $_REQUEST['move_to'];
823
+	}
783 824
 
784 825
 	// Only a few possible actions.
785 826
 	$possibleActions = array();
@@ -799,8 +840,7 @@  discard block
 block discarded – undo
799 840
 		);
800 841
 
801 842
 		$redirect_url = 'board=' . $board . '.' . $_REQUEST['start'];
802
-	}
803
-	else
843
+	} else
804 844
 	{
805 845
 		/**
806 846
 		 * @todo Ugly. There's no getting around this, is there?
@@ -818,8 +858,7 @@  discard block
 block discarded – undo
818 858
 		if (!empty($board))
819 859
 		{
820 860
 			$boards_can['post_new'] = array_diff(boardsAllowedTo('post_new'), array($board));
821
-		}
822
-		else
861
+		} else
823 862
 		{
824 863
 			$boards_can['post_new'] = boardsAllowedTo('post_new');
825 864
 		}
@@ -830,55 +869,67 @@  discard block
 block discarded – undo
830 869
 		}
831 870
 	}
832 871
 
833
-	if (!$user_info['is_guest'])
834
-		$possibleActions[] = 'markread';
835
-	if (!empty($boards_can['make_sticky']))
836
-		$possibleActions[] = 'sticky';
837
-	if (!empty($boards_can['move_any']) || !empty($boards_can['move_own']))
838
-		$possibleActions[] = 'move';
839
-	if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own']))
840
-		$possibleActions[] = 'remove';
841
-	if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own']))
842
-		$possibleActions[] = 'lock';
843
-	if (!empty($boards_can['merge_any']))
844
-		$possibleActions[] = 'merge';
845
-	if (!empty($boards_can['approve_posts']))
846
-		$possibleActions[] = 'approve';
872
+	if (!$user_info['is_guest']) {
873
+			$possibleActions[] = 'markread';
874
+	}
875
+	if (!empty($boards_can['make_sticky'])) {
876
+			$possibleActions[] = 'sticky';
877
+	}
878
+	if (!empty($boards_can['move_any']) || !empty($boards_can['move_own'])) {
879
+			$possibleActions[] = 'move';
880
+	}
881
+	if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own'])) {
882
+			$possibleActions[] = 'remove';
883
+	}
884
+	if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own'])) {
885
+			$possibleActions[] = 'lock';
886
+	}
887
+	if (!empty($boards_can['merge_any'])) {
888
+			$possibleActions[] = 'merge';
889
+	}
890
+	if (!empty($boards_can['approve_posts'])) {
891
+			$possibleActions[] = 'approve';
892
+	}
847 893
 
848 894
 	// Two methods: $_REQUEST['actions'] (id_topic => action), and $_REQUEST['topics'] and $_REQUEST['qaction'].
849 895
 	// (if action is 'move', $_REQUEST['move_to'] or $_REQUEST['move_tos'][$topic] is used.)
850 896
 	if (!empty($_REQUEST['topics']))
851 897
 	{
852 898
 		// If the action isn't valid, just quit now.
853
-		if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions))
854
-			redirectexit($redirect_url);
899
+		if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions)) {
900
+					redirectexit($redirect_url);
901
+		}
855 902
 
856 903
 		// Merge requires all topics as one parameter and can be done at once.
857 904
 		if ($_REQUEST['qaction'] == 'merge')
858 905
 		{
859 906
 			// Merge requires at least two topics.
860
-			if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2)
861
-				redirectexit($redirect_url);
907
+			if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2) {
908
+							redirectexit($redirect_url);
909
+			}
862 910
 
863 911
 			require_once($sourcedir . '/SplitTopics.php');
864 912
 			return MergeExecute($_REQUEST['topics']);
865 913
 		}
866 914
 
867 915
 		// Just convert to the other method, to make it easier.
868
-		foreach ($_REQUEST['topics'] as $topic)
869
-			$_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction'];
916
+		foreach ($_REQUEST['topics'] as $topic) {
917
+					$_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction'];
918
+		}
870 919
 	}
871 920
 
872 921
 	// Weird... how'd you get here?
873
-	if (empty($_REQUEST['actions']))
874
-		redirectexit($redirect_url);
922
+	if (empty($_REQUEST['actions'])) {
923
+			redirectexit($redirect_url);
924
+	}
875 925
 
876 926
 	// Validate each action.
877 927
 	$temp = array();
878 928
 	foreach ($_REQUEST['actions'] as $topic => $action)
879 929
 	{
880
-		if (in_array($action, $possibleActions))
881
-			$temp[(int) $topic] = $action;
930
+		if (in_array($action, $possibleActions)) {
931
+					$temp[(int) $topic] = $action;
932
+		}
882 933
 	}
883 934
 	$_REQUEST['actions'] = $temp;
884 935
 
@@ -899,27 +950,31 @@  discard block
 block discarded – undo
899 950
 		{
900 951
 			if (!empty($board))
901 952
 			{
902
-				if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts')))
903
-					unset($_REQUEST['actions'][$row['id_topic']]);
904
-			}
905
-			else
953
+				if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts'))) {
954
+									unset($_REQUEST['actions'][$row['id_topic']]);
955
+				}
956
+			} else
906 957
 			{
907 958
 				// Don't allow them to act on unapproved posts they can't see...
908
-				if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts']))
909
-					unset($_REQUEST['actions'][$row['id_topic']]);
959
+				if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])) {
960
+									unset($_REQUEST['actions'][$row['id_topic']]);
961
+				}
910 962
 				// Goodness, this is fun.  We need to validate the action.
911
-				elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky']))
912
-					unset($_REQUEST['actions'][$row['id_topic']]);
913
-				elseif ($_REQUEST['actions'][$row['id_topic']] == 'move' && !in_array(0, $boards_can['move_any']) && !in_array($row['id_board'], $boards_can['move_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['move_own']) && !in_array($row['id_board'], $boards_can['move_own']))))
914
-					unset($_REQUEST['actions'][$row['id_topic']]);
915
-				elseif ($_REQUEST['actions'][$row['id_topic']] == 'remove' && !in_array(0, $boards_can['remove_any']) && !in_array($row['id_board'], $boards_can['remove_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['remove_own']) && !in_array($row['id_board'], $boards_can['remove_own']))))
916
-					unset($_REQUEST['actions'][$row['id_topic']]);
963
+				elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky'])) {
964
+									unset($_REQUEST['actions'][$row['id_topic']]);
965
+				} elseif ($_REQUEST['actions'][$row['id_topic']] == 'move' && !in_array(0, $boards_can['move_any']) && !in_array($row['id_board'], $boards_can['move_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['move_own']) && !in_array($row['id_board'], $boards_can['move_own'])))) {
966
+									unset($_REQUEST['actions'][$row['id_topic']]);
967
+				} elseif ($_REQUEST['actions'][$row['id_topic']] == 'remove' && !in_array(0, $boards_can['remove_any']) && !in_array($row['id_board'], $boards_can['remove_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['remove_own']) && !in_array($row['id_board'], $boards_can['remove_own'])))) {
968
+									unset($_REQUEST['actions'][$row['id_topic']]);
969
+				}
917 970
 				// @todo $locked is not set, what are you trying to do? (taking the change it is supposed to be $row['locked'])
918
-				elseif ($_REQUEST['actions'][$row['id_topic']] == 'lock' && !in_array(0, $boards_can['lock_any']) && !in_array($row['id_board'], $boards_can['lock_any']) && ($row['id_member_started'] != $user_info['id'] || $row['locked'] == 1 || (!in_array(0, $boards_can['lock_own']) && !in_array($row['id_board'], $boards_can['lock_own']))))
919
-					unset($_REQUEST['actions'][$row['id_topic']]);
971
+				elseif ($_REQUEST['actions'][$row['id_topic']] == 'lock' && !in_array(0, $boards_can['lock_any']) && !in_array($row['id_board'], $boards_can['lock_any']) && ($row['id_member_started'] != $user_info['id'] || $row['locked'] == 1 || (!in_array(0, $boards_can['lock_own']) && !in_array($row['id_board'], $boards_can['lock_own'])))) {
972
+									unset($_REQUEST['actions'][$row['id_topic']]);
973
+				}
920 974
 				// If the topic is approved then you need permission to approve the posts within.
921
-				elseif ($_REQUEST['actions'][$row['id_topic']] == 'approve' && (!$row['unapproved_posts'] || (!in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts']))))
922
-					unset($_REQUEST['actions'][$row['id_topic']]);
975
+				elseif ($_REQUEST['actions'][$row['id_topic']] == 'approve' && (!$row['unapproved_posts'] || (!in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])))) {
976
+									unset($_REQUEST['actions'][$row['id_topic']]);
977
+				}
923 978
 			}
924 979
 		}
925 980
 		$smcFunc['db_free_result']($request);
@@ -937,11 +992,11 @@  discard block
 block discarded – undo
937 992
 	{
938 993
 		$topic = (int) $topic;
939 994
 
940
-		if ($action == 'markread')
941
-			$markCache[] = $topic;
942
-		elseif ($action == 'sticky')
943
-			$stickyCache[] = $topic;
944
-		elseif ($action == 'move')
995
+		if ($action == 'markread') {
996
+					$markCache[] = $topic;
997
+		} elseif ($action == 'sticky') {
998
+					$stickyCache[] = $topic;
999
+		} elseif ($action == 'move')
945 1000
 		{
946 1001
 			require_once($sourcedir . '/MoveTopic.php');
947 1002
 			moveTopicConcurrence();
@@ -949,23 +1004,25 @@  discard block
 block discarded – undo
949 1004
 			// $moveCache[0] is the topic, $moveCache[1] is the board to move to.
950 1005
 			$moveCache[1][$topic] = (int) (isset($_REQUEST['move_tos'][$topic]) ? $_REQUEST['move_tos'][$topic] : $_REQUEST['move_to']);
951 1006
 
952
-			if (empty($moveCache[1][$topic]))
953
-				continue;
1007
+			if (empty($moveCache[1][$topic])) {
1008
+							continue;
1009
+			}
954 1010
 
955 1011
 			$moveCache[0][] = $topic;
1012
+		} elseif ($action == 'remove') {
1013
+					$removeCache[] = $topic;
1014
+		} elseif ($action == 'lock') {
1015
+					$lockCache[] = $topic;
1016
+		} elseif ($action == 'approve') {
1017
+					$approveCache[] = $topic;
956 1018
 		}
957
-		elseif ($action == 'remove')
958
-			$removeCache[] = $topic;
959
-		elseif ($action == 'lock')
960
-			$lockCache[] = $topic;
961
-		elseif ($action == 'approve')
962
-			$approveCache[] = $topic;
963 1019
 	}
964 1020
 
965
-	if (empty($board))
966
-		$affectedBoards = array();
967
-	else
968
-		$affectedBoards = array($board => array(0, 0));
1021
+	if (empty($board)) {
1022
+			$affectedBoards = array();
1023
+	} else {
1024
+			$affectedBoards = array($board => array(0, 0));
1025
+	}
969 1026
 
970 1027
 	// Do all the stickies...
971 1028
 	if (!empty($stickyCache))
@@ -1025,14 +1082,16 @@  discard block
 block discarded – undo
1025 1082
 		{
1026 1083
 			$to = $moveCache[1][$row['id_topic']];
1027 1084
 
1028
-			if (empty($to))
1029
-				continue;
1085
+			if (empty($to)) {
1086
+							continue;
1087
+			}
1030 1088
 
1031 1089
 			// Does this topic's board count the posts or not?
1032 1090
 			$countPosts[$row['id_topic']] = empty($row['count_posts']);
1033 1091
 
1034
-			if (!isset($moveTos[$to]))
1035
-				$moveTos[$to] = array();
1092
+			if (!isset($moveTos[$to])) {
1093
+							$moveTos[$to] = array();
1094
+			}
1036 1095
 
1037 1096
 			$moveTos[$to][] = $row['id_topic'];
1038 1097
 
@@ -1046,8 +1105,9 @@  discard block
 block discarded – undo
1046 1105
 		require_once($sourcedir . '/MoveTopic.php');
1047 1106
 
1048 1107
 		// Do the actual moves...
1049
-		foreach ($moveTos as $to => $topics)
1050
-			moveTopics($topics, $to);
1108
+		foreach ($moveTos as $to => $topics) {
1109
+					moveTopics($topics, $to);
1110
+		}
1051 1111
 
1052 1112
 		// Does the post counts need to be updated?
1053 1113
 		if (!empty($moveTos))
@@ -1096,20 +1156,23 @@  discard block
 block discarded – undo
1096 1156
 
1097 1157
 				while ($row = $smcFunc['db_fetch_assoc']($request))
1098 1158
 				{
1099
-					if (!isset($members[$row['id_member']]))
1100
-						$members[$row['id_member']] = 0;
1159
+					if (!isset($members[$row['id_member']])) {
1160
+											$members[$row['id_member']] = 0;
1161
+					}
1101 1162
 
1102
-					if ($topicRecounts[$row['id_topic']] === '+')
1103
-						$members[$row['id_member']] += 1;
1104
-					else
1105
-						$members[$row['id_member']] -= 1;
1163
+					if ($topicRecounts[$row['id_topic']] === '+') {
1164
+											$members[$row['id_member']] += 1;
1165
+					} else {
1166
+											$members[$row['id_member']] -= 1;
1167
+					}
1106 1168
 				}
1107 1169
 
1108 1170
 				$smcFunc['db_free_result']($request);
1109 1171
 
1110 1172
 				// And now update them member's post counts
1111
-				foreach ($members as $id_member => $post_adj)
1112
-					updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj));
1173
+				foreach ($members as $id_member => $post_adj) {
1174
+									updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj));
1175
+				}
1113 1176
 
1114 1177
 			}
1115 1178
 		}
@@ -1189,8 +1252,9 @@  discard block
 block discarded – undo
1189 1252
 			approveTopics($approveCache);
1190 1253
 
1191 1254
 			// Time for some logging!
1192
-			foreach ($approveCache as $topic)
1193
-				logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic]));
1255
+			foreach ($approveCache as $topic) {
1256
+							logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic]));
1257
+			}
1194 1258
 		}
1195 1259
 	}
1196 1260
 
@@ -1225,8 +1289,7 @@  discard block
 block discarded – undo
1225 1289
 				$lockStatus[$row['id_topic']] = empty($row['locked']);
1226 1290
 			}
1227 1291
 			$smcFunc['db_free_result']($result);
1228
-		}
1229
-		else
1292
+		} else
1230 1293
 		{
1231 1294
 			$result = $smcFunc['db_query']('', '
1232 1295
 				SELECT id_topic, locked, id_board
@@ -1276,13 +1339,15 @@  discard block
 block discarded – undo
1276 1339
 			)
1277 1340
 		);
1278 1341
 		$logged_topics = array();
1279
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1280
-			$logged_topics[$row['id_topic']] = $row['unwatched'];
1342
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1343
+					$logged_topics[$row['id_topic']] = $row['unwatched'];
1344
+		}
1281 1345
 		$smcFunc['db_free_result']($request);
1282 1346
 
1283 1347
 		$markArray = array();
1284
-		foreach ($markCache as $topic)
1285
-			$markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0));
1348
+		foreach ($markCache as $topic) {
1349
+					$markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0));
1350
+		}
1286 1351
 
1287 1352
 		$smcFunc['db_insert']('replace',
1288 1353
 			'{db_prefix}log_topics',
@@ -1295,8 +1360,9 @@  discard block
 block discarded – undo
1295 1360
 	foreach ($moveCache as $topic)
1296 1361
 	{
1297 1362
 		// Didn't actually move anything!
1298
-		if (!isset($topic[0]))
1299
-			break;
1363
+		if (!isset($topic[0])) {
1364
+					break;
1365
+		}
1300 1366
 
1301 1367
 		logAction('move', array('topic' => $topic[0], 'board_from' => $topic[1], 'board_to' => $topic[2]));
1302 1368
 		sendNotifications($topic[0], 'move');
@@ -1318,8 +1384,9 @@  discard block
 block discarded – undo
1318 1384
 		'calendar_updated' => time(),
1319 1385
 	));
1320 1386
 
1321
-	if (!empty($affectedBoards))
1322
-		updateLastMessages(array_keys($affectedBoards));
1387
+	if (!empty($affectedBoards)) {
1388
+			updateLastMessages(array_keys($affectedBoards));
1389
+	}
1323 1390
 
1324 1391
 	redirectexit($redirect_url);
1325 1392
 }
Please login to merge, or discard this patch.
Sources/Session.php 1 patch
Braces   +31 added lines, -21 removed lines patch added patch discarded remove patch
@@ -17,8 +17,9 @@  discard block
 block discarded – undo
17 17
  * @version 2.1 Beta 4
18 18
  */
19 19
 
20
-if (!defined('SMF'))
20
+if (!defined('SMF')) {
21 21
 	die('No direct access...');
22
+}
22 23
 
23 24
 /**
24 25
  * Attempt to start the session, unless it already has been.
@@ -38,8 +39,9 @@  discard block
 block discarded – undo
38 39
 	{
39 40
 		$parsed_url = parse_url($boardurl);
40 41
 
41
-		if (preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1)
42
-			@ini_set('session.cookie_domain', '.' . $parts[1]);
42
+		if (preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1) {
43
+					@ini_set('session.cookie_domain', '.' . $parts[1]);
44
+		}
43 45
 	}
44 46
 	// @todo Set the session cookie path?
45 47
 
@@ -47,8 +49,9 @@  discard block
 block discarded – undo
47 49
 	if ((ini_get('session.auto_start') == 1 && !empty($modSettings['databaseSession_enable'])) || session_id() == '')
48 50
 	{
49 51
 		// Attempt to end the already-started session.
50
-		if (ini_get('session.auto_start') == 1)
51
-			session_write_close();
52
+		if (ini_get('session.auto_start') == 1) {
53
+					session_write_close();
54
+		}
52 55
 
53 56
 		// This is here to stop people from using bad junky PHPSESSIDs.
54 57
 		if (isset($_REQUEST[session_name()]) && preg_match('~^[A-Za-z0-9,-]{16,64}$~', $_REQUEST[session_name()]) == 0 && !isset($_COOKIE[session_name()]))
@@ -65,19 +68,21 @@  discard block
 block discarded – undo
65 68
 			@ini_set('session.serialize_handler', 'php');
66 69
 			session_set_save_handler('sessionOpen', 'sessionClose', 'sessionRead', 'sessionWrite', 'sessionDestroy', 'sessionGC');
67 70
 			@ini_set('session.gc_probability', '1');
71
+		} elseif (ini_get('session.gc_maxlifetime') <= 1440 && !empty($modSettings['databaseSession_lifetime'])) {
72
+					@ini_set('session.gc_maxlifetime', max($modSettings['databaseSession_lifetime'], 60));
68 73
 		}
69
-		elseif (ini_get('session.gc_maxlifetime') <= 1440 && !empty($modSettings['databaseSession_lifetime']))
70
-			@ini_set('session.gc_maxlifetime', max($modSettings['databaseSession_lifetime'], 60));
71 74
 
72 75
 		// Use cache setting sessions?
73
-		if (empty($modSettings['databaseSession_enable']) && !empty($modSettings['cache_enable']) && php_sapi_name() != 'cli')
74
-			call_integration_hook('integrate_session_handlers');
76
+		if (empty($modSettings['databaseSession_enable']) && !empty($modSettings['cache_enable']) && php_sapi_name() != 'cli') {
77
+					call_integration_hook('integrate_session_handlers');
78
+		}
75 79
 
76 80
 		session_start();
77 81
 
78 82
 		// Change it so the cache settings are a little looser than default.
79
-		if (!empty($modSettings['databaseSession_loose']))
80
-			header('Cache-Control: private');
83
+		if (!empty($modSettings['databaseSession_loose'])) {
84
+					header('Cache-Control: private');
85
+		}
81 86
 	}
82 87
 
83 88
 	// Set the randomly generated code.
@@ -123,8 +128,9 @@  discard block
 block discarded – undo
123 128
 {
124 129
 	global $smcFunc;
125 130
 
126
-	if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0)
127
-		return '';
131
+	if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) {
132
+			return '';
133
+	}
128 134
 
129 135
 	// Look for it in the database.
130 136
 	$result = $smcFunc['db_query']('', '
@@ -153,8 +159,9 @@  discard block
 block discarded – undo
153 159
 {
154 160
 	global $smcFunc;
155 161
 
156
-	if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0)
157
-		return false;
162
+	if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) {
163
+			return false;
164
+	}
158 165
 
159 166
 	// First try to update an existing row...
160 167
 	$smcFunc['db_query']('', '
@@ -169,13 +176,14 @@  discard block
 block discarded – undo
169 176
 	);
170 177
 
171 178
 	// If that didn't work, try inserting a new one.
172
-	if ($smcFunc['db_affected_rows']() == 0)
173
-		$smcFunc['db_insert']('ignore',
179
+	if ($smcFunc['db_affected_rows']() == 0) {
180
+			$smcFunc['db_insert']('ignore',
174 181
 			'{db_prefix}sessions',
175 182
 			array('session_id' => 'string', 'data' => 'string', 'last_update' => 'int'),
176 183
 			array($session_id, $data, time()),
177 184
 			array('session_id')
178 185
 		);
186
+	}
179 187
 
180 188
 	return ($smcFunc['db_affected_rows']() == 0 ? false : true);
181 189
 }
@@ -190,8 +198,9 @@  discard block
 block discarded – undo
190 198
 {
191 199
 	global $smcFunc;
192 200
 
193
-	if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0)
194
-		return false;
201
+	if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) {
202
+			return false;
203
+	}
195 204
 
196 205
 	// Just delete the row...
197 206
 	$smcFunc['db_query']('', '
@@ -217,8 +226,9 @@  discard block
 block discarded – undo
217 226
 	global $modSettings, $smcFunc;
218 227
 
219 228
 	// Just set to the default or lower?  Ignore it for a higher value. (hopefully)
220
-	if (!empty($modSettings['databaseSession_lifetime']) && ($max_lifetime <= 1440 || $modSettings['databaseSession_lifetime'] > $max_lifetime))
221
-		$max_lifetime = max($modSettings['databaseSession_lifetime'], 60);
229
+	if (!empty($modSettings['databaseSession_lifetime']) && ($max_lifetime <= 1440 || $modSettings['databaseSession_lifetime'] > $max_lifetime)) {
230
+			$max_lifetime = max($modSettings['databaseSession_lifetime'], 60);
231
+	}
222 232
 
223 233
 	// Clean up after yerself ;).
224 234
 	$smcFunc['db_query']('', '
Please login to merge, or discard this patch.
Sources/Poll.php 1 patch
Braces   +163 added lines, -119 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 4
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * Allow the user to vote.
@@ -51,8 +52,9 @@  discard block
 block discarded – undo
51 52
 			'not_guest' => 0,
52 53
 		)
53 54
 	);
54
-	if ($smcFunc['db_num_rows']($request) == 0)
55
-		fatal_lang_error('poll_error', false);
55
+	if ($smcFunc['db_num_rows']($request) == 0) {
56
+			fatal_lang_error('poll_error', false);
57
+	}
56 58
 	$row = $smcFunc['db_fetch_assoc']($request);
57 59
 	$smcFunc['db_free_result']($request);
58 60
 
@@ -60,8 +62,9 @@  discard block
 block discarded – undo
60 62
 	if ($user_info['is_guest'])
61 63
 	{
62 64
 		// Guest voting disabled?
63
-		if (!$row['guest_vote'])
64
-			fatal_lang_error('guest_vote_disabled');
65
+		if (!$row['guest_vote']) {
66
+					fatal_lang_error('guest_vote_disabled');
67
+		}
65 68
 		// Guest already voted?
66 69
 		elseif (!empty($_COOKIE['guest_poll_vote']) && preg_match('~^[0-9,;]+$~', $_COOKIE['guest_poll_vote']) && strpos($_COOKIE['guest_poll_vote'], ';' . $row['id_poll'] . ',') !== false)
67 70
 		{
@@ -71,32 +74,36 @@  discard block
 block discarded – undo
71 74
 			foreach ($guestinfo as $i => $guestvoted)
72 75
 			{
73 76
 				$guestvoted = explode(',', $guestvoted);
74
-				if ($guestvoted[0] == $row['id_poll'])
75
-					break;
77
+				if ($guestvoted[0] == $row['id_poll']) {
78
+									break;
79
+				}
76 80
 			}
77 81
 			// Has the poll been reset since guest voted?
78 82
 			if ($row['reset_poll'] > $guestvoted[1])
79 83
 			{
80 84
 				// Remove the poll info from the cookie to allow guest to vote again
81 85
 				unset($guestinfo[$i]);
82
-				if (!empty($guestinfo))
83
-					$_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo);
84
-				else
85
-					unset($_COOKIE['guest_poll_vote']);
86
+				if (!empty($guestinfo)) {
87
+									$_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo);
88
+				} else {
89
+									unset($_COOKIE['guest_poll_vote']);
90
+				}
91
+			} else {
92
+							fatal_lang_error('poll_error', false);
86 93
 			}
87
-			else
88
-				fatal_lang_error('poll_error', false);
89 94
 			unset($guestinfo, $guestvoted, $i);
90 95
 		}
91 96
 	}
92 97
 
93 98
 	// Is voting locked or has it expired?
94
-	if (!empty($row['voting_locked']) || (!empty($row['expire_time']) && time() > $row['expire_time']))
95
-		fatal_lang_error('poll_error', false);
99
+	if (!empty($row['voting_locked']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) {
100
+			fatal_lang_error('poll_error', false);
101
+	}
96 102
 
97 103
 	// If they have already voted and aren't allowed to change their vote - hence they are outta here!
98
-	if (!$user_info['is_guest'] && $row['selected'] != -1 && empty($row['change_vote']))
99
-		fatal_lang_error('poll_error', false);
104
+	if (!$user_info['is_guest'] && $row['selected'] != -1 && empty($row['change_vote'])) {
105
+			fatal_lang_error('poll_error', false);
106
+	}
100 107
 	// Otherwise if they can change their vote yet they haven't sent any options... remove their vote and redirect.
101 108
 	elseif (!empty($row['change_vote']) && !$user_info['is_guest'] && empty($_POST['options']))
102 109
 	{
@@ -114,8 +121,9 @@  discard block
 block discarded – undo
114 121
 				'id_poll' => $row['id_poll'],
115 122
 			)
116 123
 		);
117
-		while ($choice = $smcFunc['db_fetch_row']($request))
118
-			$pollOptions[] = $choice[0];
124
+		while ($choice = $smcFunc['db_fetch_row']($request)) {
125
+					$pollOptions[] = $choice[0];
126
+		}
119 127
 		$smcFunc['db_free_result']($request);
120 128
 
121 129
 		// Just skip it if they had voted for nothing before.
@@ -148,19 +156,22 @@  discard block
 block discarded – undo
148 156
 		}
149 157
 
150 158
 		// Redirect back to the topic so the user can vote again!
151
-		if (empty($_POST['options']))
152
-			redirectexit('topic=' . $topic . '.' . $_REQUEST['start']);
159
+		if (empty($_POST['options'])) {
160
+					redirectexit('topic=' . $topic . '.' . $_REQUEST['start']);
161
+		}
153 162
 	}
154 163
 
155 164
 	checkSession('request');
156 165
 
157 166
 	// Make sure the option(s) are valid.
158
-	if (empty($_POST['options']))
159
-		fatal_lang_error('didnt_select_vote', false);
167
+	if (empty($_POST['options'])) {
168
+			fatal_lang_error('didnt_select_vote', false);
169
+	}
160 170
 
161 171
 	// Too many options checked!
162
-	if (count($_REQUEST['options']) > $row['max_votes'])
163
-		fatal_lang_error('poll_too_many_votes', false, array($row['max_votes']));
172
+	if (count($_REQUEST['options']) > $row['max_votes']) {
173
+			fatal_lang_error('poll_too_many_votes', false, array($row['max_votes']));
174
+	}
164 175
 
165 176
 	$pollOptions = array();
166 177
 	$inserts = array();
@@ -250,24 +261,30 @@  discard block
 block discarded – undo
250 261
 	list ($memberID, $pollID, $voting_locked) = $smcFunc['db_fetch_row']($request);
251 262
 
252 263
 	// If the user _can_ modify the poll....
253
-	if (!allowedTo('poll_lock_any'))
254
-		isAllowedTo('poll_lock_' . ($user_info['id'] == $memberID ? 'own' : 'any'));
264
+	if (!allowedTo('poll_lock_any')) {
265
+			isAllowedTo('poll_lock_' . ($user_info['id'] == $memberID ? 'own' : 'any'));
266
+	}
255 267
 
256 268
 	// It's been locked by a non-moderator.
257
-	if ($voting_locked == '1')
258
-		$voting_locked = '0';
269
+	if ($voting_locked == '1') {
270
+			$voting_locked = '0';
271
+	}
259 272
 	// Locked by a moderator, and this is a moderator.
260
-	elseif ($voting_locked == '2' && allowedTo('moderate_board'))
261
-		$voting_locked = '0';
273
+	elseif ($voting_locked == '2' && allowedTo('moderate_board')) {
274
+			$voting_locked = '0';
275
+	}
262 276
 	// Sorry, a moderator locked it.
263
-	elseif ($voting_locked == '2' && !allowedTo('moderate_board'))
264
-		fatal_lang_error('locked_by_admin', 'user');
277
+	elseif ($voting_locked == '2' && !allowedTo('moderate_board')) {
278
+			fatal_lang_error('locked_by_admin', 'user');
279
+	}
265 280
 	// A moderator *is* locking it.
266
-	elseif ($voting_locked == '0' && allowedTo('moderate_board'))
267
-		$voting_locked = '2';
281
+	elseif ($voting_locked == '0' && allowedTo('moderate_board')) {
282
+			$voting_locked = '2';
283
+	}
268 284
 	// Well, it's gonna be locked one way or another otherwise...
269
-	else
270
-		$voting_locked = '1';
285
+	else {
286
+			$voting_locked = '1';
287
+	}
271 288
 
272 289
 	// Lock!  *Poof* - no one can vote.
273 290
 	$smcFunc['db_query']('', '
@@ -302,8 +319,9 @@  discard block
 block discarded – undo
302 319
 {
303 320
 	global $txt, $user_info, $context, $topic, $board, $smcFunc, $sourcedir, $scripturl;
304 321
 
305
-	if (empty($topic))
306
-		fatal_lang_error('no_access', false);
322
+	if (empty($topic)) {
323
+			fatal_lang_error('no_access', false);
324
+	}
307 325
 
308 326
 	loadLanguage('Post');
309 327
 	loadTemplate('Poll');
@@ -327,24 +345,28 @@  discard block
 block discarded – undo
327 345
 	);
328 346
 
329 347
 	// Assume the the topic exists, right?
330
-	if ($smcFunc['db_num_rows']($request) == 0)
331
-		fatal_lang_error('no_board');
348
+	if ($smcFunc['db_num_rows']($request) == 0) {
349
+			fatal_lang_error('no_board');
350
+	}
332 351
 	// Get the poll information.
333 352
 	$pollinfo = $smcFunc['db_fetch_assoc']($request);
334 353
 	$smcFunc['db_free_result']($request);
335 354
 
336 355
 	// If we are adding a new poll - make sure that there isn't already a poll there.
337
-	if (!$context['is_edit'] && !empty($pollinfo['id_poll']))
338
-		fatal_lang_error('poll_already_exists');
356
+	if (!$context['is_edit'] && !empty($pollinfo['id_poll'])) {
357
+			fatal_lang_error('poll_already_exists');
358
+	}
339 359
 	// Otherwise, if we're editing it, it does exist I assume?
340
-	elseif ($context['is_edit'] && empty($pollinfo['id_poll']))
341
-		fatal_lang_error('poll_not_found');
360
+	elseif ($context['is_edit'] && empty($pollinfo['id_poll'])) {
361
+			fatal_lang_error('poll_not_found');
362
+	}
342 363
 
343 364
 	// Can you do this?
344
-	if ($context['is_edit'] && !allowedTo('poll_edit_any'))
345
-		isAllowedTo('poll_edit_' . ($user_info['id'] == $pollinfo['id_member_started'] || ($pollinfo['poll_starter'] != 0 && $user_info['id'] == $pollinfo['poll_starter']) ? 'own' : 'any'));
346
-	elseif (!$context['is_edit'] && !allowedTo('poll_add_any'))
347
-		isAllowedTo('poll_add_' . ($user_info['id'] == $pollinfo['id_member_started'] ? 'own' : 'any'));
365
+	if ($context['is_edit'] && !allowedTo('poll_edit_any')) {
366
+			isAllowedTo('poll_edit_' . ($user_info['id'] == $pollinfo['id_member_started'] || ($pollinfo['poll_starter'] != 0 && $user_info['id'] == $pollinfo['poll_starter']) ? 'own' : 'any'));
367
+	} elseif (!$context['is_edit'] && !allowedTo('poll_add_any')) {
368
+			isAllowedTo('poll_add_' . ($user_info['id'] == $pollinfo['id_member_started'] ? 'own' : 'any'));
369
+	}
348 370
 	$context['can_moderate_poll'] = isset($_REQUEST['add']) ? true : allowedTo('poll_edit_' . ($user_info['id'] == $pollinfo['id_member_started'] || ($pollinfo['poll_starter'] != 0 && $user_info['id'] == $pollinfo['poll_starter']) ? 'own' : 'any'));
349 371
 
350 372
 	// Do we enable guest voting?
@@ -386,12 +408,14 @@  discard block
 block discarded – undo
386 408
 			while ($row = $smcFunc['db_fetch_assoc']($request))
387 409
 			{
388 410
 				// Get the highest id so we can add more without reusing.
389
-				if ($row['id_choice'] >= $last_id)
390
-					$last_id = $row['id_choice'] + 1;
411
+				if ($row['id_choice'] >= $last_id) {
412
+									$last_id = $row['id_choice'] + 1;
413
+				}
391 414
 
392 415
 				// They cleared this by either omitting it or emptying it.
393
-				if (!isset($_POST['options'][$row['id_choice']]) || $_POST['options'][$row['id_choice']] == '')
394
-					continue;
416
+				if (!isset($_POST['options'][$row['id_choice']]) || $_POST['options'][$row['id_choice']] == '') {
417
+									continue;
418
+				}
395 419
 
396 420
 				censorText($row['label']);
397 421
 
@@ -409,9 +433,10 @@  discard block
 block discarded – undo
409 433
 
410 434
 		// Work out how many options we have, so we get the 'is_last' field right...
411 435
 		$totalPostOptions = 0;
412
-		foreach ($_POST['options'] as $id => $label)
413
-			if ($label != '')
436
+		foreach ($_POST['options'] as $id => $label) {
437
+					if ($label != '')
414 438
 				$totalPostOptions++;
439
+		}
415 440
 
416 441
 		$count = 1;
417 442
 		// If an option exists, update it.  If it is new, add it - but don't reuse ids!
@@ -420,30 +445,32 @@  discard block
 block discarded – undo
420 445
 			$label = $smcFunc['htmlspecialchars']($label);
421 446
 			censorText($label);
422 447
 
423
-			if (isset($context['choices'][$id]))
424
-				$context['choices'][$id]['label'] = $label;
425
-			elseif ($label != '')
426
-				$context['choices'][] = array(
448
+			if (isset($context['choices'][$id])) {
449
+							$context['choices'][$id]['label'] = $label;
450
+			} elseif ($label != '') {
451
+							$context['choices'][] = array(
427 452
 					'id' => $last_id++,
428 453
 					'number' => $number++,
429 454
 					'label' => $label,
430 455
 					'votes' => -1,
431 456
 					'is_last' => $count++ == $totalPostOptions && $totalPostOptions > 1 ? true : false,
432 457
 				);
458
+			}
433 459
 		}
434 460
 
435 461
 		// Make sure we have two choices for sure!
436 462
 		if ($totalPostOptions < 2)
437 463
 		{
438 464
 			// Need two?
439
-			if ($totalPostOptions == 0)
440
-				$context['choices'][] = array(
465
+			if ($totalPostOptions == 0) {
466
+							$context['choices'][] = array(
441 467
 					'id' => $last_id++,
442 468
 					'number' => $number++,
443 469
 					'label' => '',
444 470
 					'votes' => -1,
445 471
 					'is_last' => false
446 472
 				);
473
+			}
447 474
 			$poll_errors[] = 'poll_few';
448 475
 		}
449 476
 
@@ -458,12 +485,14 @@  discard block
 block discarded – undo
458 485
 
459 486
 		$context['last_choice_id'] = $last_id;
460 487
 
461
-		if ($context['can_moderate_poll'])
462
-			$context['poll']['expiration'] = $_POST['poll_expire'];
488
+		if ($context['can_moderate_poll']) {
489
+					$context['poll']['expiration'] = $_POST['poll_expire'];
490
+		}
463 491
 
464 492
 		// Check the question/option count for errors.
465
-		if (trim($_POST['question']) == '' && empty($context['poll_error']))
466
-			$poll_errors[] = 'no_question';
493
+		if (trim($_POST['question']) == '' && empty($context['poll_error'])) {
494
+					$poll_errors[] = 'no_question';
495
+		}
467 496
 
468 497
 		// No check is needed, since nothing is really posted.
469 498
 		checkSubmitOnce('free');
@@ -480,8 +509,7 @@  discard block
 block discarded – undo
480 509
 				$context['poll_error']['messages'][] = $txt['error_' . $poll_error];
481 510
 			}
482 511
 		}
483
-	}
484
-	else
512
+	} else
485 513
 	{
486 514
 		// Basic theme info...
487 515
 		$context['poll'] = array(
@@ -596,18 +624,22 @@  discard block
 block discarded – undo
596 624
 	global $user_info, $smcFunc, $sourcedir;
597 625
 
598 626
 	// Sneaking off, are we?
599
-	if (empty($_POST))
600
-		redirectexit('action=editpoll;topic=' . $topic . '.0');
627
+	if (empty($_POST)) {
628
+			redirectexit('action=editpoll;topic=' . $topic . '.0');
629
+	}
601 630
 
602
-	if (checkSession('post', '', false) != '')
603
-		$poll_errors[] = 'session_timeout';
631
+	if (checkSession('post', '', false) != '') {
632
+			$poll_errors[] = 'session_timeout';
633
+	}
604 634
 
605
-	if (isset($_POST['preview']))
606
-		return EditPoll();
635
+	if (isset($_POST['preview'])) {
636
+			return EditPoll();
637
+	}
607 638
 
608 639
 	// HACKERS (!!) can't edit :P.
609
-	if (empty($topic))
610
-		fatal_lang_error('no_access', false);
640
+	if (empty($topic)) {
641
+			fatal_lang_error('no_access', false);
642
+	}
611 643
 
612 644
 	// Is this a new poll, or editing an existing?
613 645
 	$isEdit = isset($_REQUEST['add']) ? 0 : 1;
@@ -623,23 +655,27 @@  discard block
 block discarded – undo
623 655
 			'current_topic' => $topic,
624 656
 		)
625 657
 	);
626
-	if ($smcFunc['db_num_rows']($request) == 0)
627
-		fatal_lang_error('no_board');
658
+	if ($smcFunc['db_num_rows']($request) == 0) {
659
+			fatal_lang_error('no_board');
660
+	}
628 661
 	$bcinfo = $smcFunc['db_fetch_assoc']($request);
629 662
 	$smcFunc['db_free_result']($request);
630 663
 
631 664
 	// Check their adding/editing is valid.
632
-	if (!$isEdit && !empty($bcinfo['id_poll']))
633
-		fatal_lang_error('poll_already_exists');
665
+	if (!$isEdit && !empty($bcinfo['id_poll'])) {
666
+			fatal_lang_error('poll_already_exists');
667
+	}
634 668
 	// Are we editing a poll which doesn't exist?
635
-	elseif ($isEdit && empty($bcinfo['id_poll']))
636
-		fatal_lang_error('poll_not_found');
669
+	elseif ($isEdit && empty($bcinfo['id_poll'])) {
670
+			fatal_lang_error('poll_not_found');
671
+	}
637 672
 
638 673
 	// Check if they have the power to add or edit the poll.
639
-	if ($isEdit && !allowedTo('poll_edit_any'))
640
-		isAllowedTo('poll_edit_' . ($user_info['id'] == $bcinfo['id_member_started'] || ($bcinfo['poll_starter'] != 0 && $user_info['id'] == $bcinfo['poll_starter']) ? 'own' : 'any'));
641
-	elseif (!$isEdit && !allowedTo('poll_add_any'))
642
-		isAllowedTo('poll_add_' . ($user_info['id'] == $bcinfo['id_member_started'] ? 'own' : 'any'));
674
+	if ($isEdit && !allowedTo('poll_edit_any')) {
675
+			isAllowedTo('poll_edit_' . ($user_info['id'] == $bcinfo['id_member_started'] || ($bcinfo['poll_starter'] != 0 && $user_info['id'] == $bcinfo['poll_starter']) ? 'own' : 'any'));
676
+	} elseif (!$isEdit && !allowedTo('poll_add_any')) {
677
+			isAllowedTo('poll_add_' . ($user_info['id'] == $bcinfo['id_member_started'] ? 'own' : 'any'));
678
+	}
643 679
 
644 680
 	$optionCount = 0;
645 681
 	$idCount = 0;
@@ -652,14 +688,16 @@  discard block
 block discarded – undo
652 688
 			$idCount = max($idCount, $k);
653 689
 		}
654 690
 	}
655
-	if ($optionCount < 2)
656
-		$poll_errors[] = 'poll_few';
657
-	elseif ($optionCount > 256 || $idCount > 255)
658
-		$poll_errors[] = 'poll_many';
691
+	if ($optionCount < 2) {
692
+			$poll_errors[] = 'poll_few';
693
+	} elseif ($optionCount > 256 || $idCount > 255) {
694
+			$poll_errors[] = 'poll_many';
695
+	}
659 696
 
660 697
 	// Also - ensure they are not removing the question.
661
-	if (trim($_POST['question']) == '')
662
-		$poll_errors[] = 'no_question';
698
+	if (trim($_POST['question']) == '') {
699
+			$poll_errors[] = 'no_question';
700
+	}
663 701
 
664 702
 	// Got any errors to report?
665 703
 	if (!empty($poll_errors))
@@ -695,8 +733,9 @@  discard block
 block discarded – undo
695 733
 	{
696 734
 		require_once($sourcedir . '/Subs-Members.php');
697 735
 		$allowedGroups = groupsAllowedTo('poll_vote', $board);
698
-		if (!in_array(-1, $allowedGroups['allowed']))
699
-			$_POST['poll_guest_vote'] = 0;
736
+		if (!in_array(-1, $allowedGroups['allowed'])) {
737
+					$_POST['poll_guest_vote'] = 0;
738
+		}
700 739
 	}
701 740
 
702 741
 	// Ensure that the number options allowed makes sense, and the expiration date is valid.
@@ -704,17 +743,19 @@  discard block
 block discarded – undo
704 743
 	{
705 744
 		$_POST['poll_expire'] = $_POST['poll_expire'] > 9999 ? 9999 : ($_POST['poll_expire'] < 0 ? 0 : $_POST['poll_expire']);
706 745
 
707
-		if (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2)
708
-			$_POST['poll_hide'] = 1;
709
-		elseif (!$isEdit || $_POST['poll_expire'] != ceil($bcinfo['expire_time'] <= time() ? -1 : ($bcinfo['expire_time'] - time()) / (3600 * 24)))
710
-			$_POST['poll_expire'] = empty($_POST['poll_expire']) ? '0' : time() + $_POST['poll_expire'] * 3600 * 24;
711
-		else
712
-			$_POST['poll_expire'] = $bcinfo['expire_time'];
746
+		if (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) {
747
+					$_POST['poll_hide'] = 1;
748
+		} elseif (!$isEdit || $_POST['poll_expire'] != ceil($bcinfo['expire_time'] <= time() ? -1 : ($bcinfo['expire_time'] - time()) / (3600 * 24))) {
749
+					$_POST['poll_expire'] = empty($_POST['poll_expire']) ? '0' : time() + $_POST['poll_expire'] * 3600 * 24;
750
+		} else {
751
+					$_POST['poll_expire'] = $bcinfo['expire_time'];
752
+		}
713 753
 
714
-		if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0)
715
-			$_POST['poll_max_votes'] = 1;
716
-		else
717
-			$_POST['poll_max_votes'] = (int) $_POST['poll_max_votes'];
754
+		if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) {
755
+					$_POST['poll_max_votes'] = 1;
756
+		} else {
757
+					$_POST['poll_max_votes'] = (int) $_POST['poll_max_votes'];
758
+		}
718 759
 	}
719 760
 
720 761
 	// If we're editing, let's commit the changes.
@@ -779,8 +820,9 @@  discard block
 block discarded – undo
779 820
 		)
780 821
 	);
781 822
 	$choices = array();
782
-	while ($row = $smcFunc['db_fetch_assoc']($request))
783
-		$choices[] = $row['id_choice'];
823
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
824
+			$choices[] = $row['id_choice'];
825
+	}
784 826
 	$smcFunc['db_free_result']($request);
785 827
 
786 828
 	$delete_options = array();
@@ -793,8 +835,9 @@  discard block
 block discarded – undo
793 835
 		if (trim($option) == '')
794 836
 		{
795 837
 			// They want it deleted.  Bye.
796
-			if (in_array($k, $choices))
797
-				$delete_options[] = $k;
838
+			if (in_array($k, $choices)) {
839
+							$delete_options[] = $k;
840
+			}
798 841
 
799 842
 			// Skip the rest...
800 843
 			continue;
@@ -804,8 +847,8 @@  discard block
 block discarded – undo
804 847
 		$option = $smcFunc['htmlspecialchars']($option);
805 848
 
806 849
 		// If it's already there, update it.  If it's not... add it.
807
-		if (in_array($k, $choices))
808
-			$smcFunc['db_query']('', '
850
+		if (in_array($k, $choices)) {
851
+					$smcFunc['db_query']('', '
809 852
 				UPDATE {db_prefix}poll_choices
810 853
 				SET label = {string:option_name}
811 854
 				WHERE id_poll = {int:id_poll}
@@ -816,8 +859,8 @@  discard block
 block discarded – undo
816 859
 					'option_name' => $option,
817 860
 				)
818 861
 			);
819
-		else
820
-			$smcFunc['db_insert']('',
862
+		} else {
863
+					$smcFunc['db_insert']('',
821 864
 				'{db_prefix}poll_choices',
822 865
 				array(
823 866
 					'id_poll' => 'int', 'id_choice' => 'int', 'label' => 'string-255', 'votes' => 'int',
@@ -827,6 +870,7 @@  discard block
 block discarded – undo
827 870
 				),
828 871
 				array()
829 872
 			);
873
+		}
830 874
 	}
831 875
 
832 876
 	// I'm sorry, but... well, no one was choosing you.  Poor options, I'll put you out of your misery.
@@ -892,13 +936,11 @@  discard block
 block discarded – undo
892 936
 	{
893 937
 		// Added a poll
894 938
 		logAction('add_poll', array('topic' => $topic));
895
-	}
896
-	elseif (isset($_REQUEST['deletevotes']))
939
+	} elseif (isset($_REQUEST['deletevotes']))
897 940
 	{
898 941
 		// Reset votes
899 942
 		logAction('reset_poll', array('topic' => $topic));
900
-	}
901
-	else
943
+	} else
902 944
 	{
903 945
 		// Something else
904 946
 		logAction('editpoll', array('topic' => $topic));
@@ -921,8 +963,9 @@  discard block
 block discarded – undo
921 963
 	global $topic, $user_info, $smcFunc;
922 964
 
923 965
 	// Make sure the topic is not empty.
924
-	if (empty($topic))
925
-		fatal_lang_error('no_access', false);
966
+	if (empty($topic)) {
967
+			fatal_lang_error('no_access', false);
968
+	}
926 969
 
927 970
 	// Verify the session.
928 971
 	checkSession('get');
@@ -940,8 +983,9 @@  discard block
 block discarded – undo
940 983
 				'current_topic' => $topic,
941 984
 			)
942 985
 		);
943
-		if ($smcFunc['db_num_rows']($request) == 0)
944
-			fatal_lang_error('no_access', false);
986
+		if ($smcFunc['db_num_rows']($request) == 0) {
987
+					fatal_lang_error('no_access', false);
988
+		}
945 989
 		list ($topicStarter, $pollStarter) = $smcFunc['db_fetch_row']($request);
946 990
 		$smcFunc['db_free_result']($request);
947 991
 
Please login to merge, or discard this patch.
Sources/Groups.php 1 patch
Braces   +80 added lines, -59 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Entry point function, permission checks, admin bars, etc.
@@ -99,27 +100,27 @@  discard block
 block discarded – undo
99 100
 					'function' => function($rowData) use ($scripturl)
100 101
 					{
101 102
 						// Since the moderator group has no explicit members, no link is needed.
102
-						if ($rowData['id_group'] == 3)
103
-							$group_name = $rowData['group_name'];
104
-						else
103
+						if ($rowData['id_group'] == 3) {
104
+													$group_name = $rowData['group_name'];
105
+						} else
105 106
 						{
106 107
 							$color_style = empty($rowData['online_color']) ? '' : sprintf(' style="color: %1$s;"', $rowData['online_color']);
107 108
 
108 109
 							if (allowedTo('manage_membergroups'))
109 110
 							{
110 111
 								$group_name = sprintf('<a href="%1$s?action=admin;area=membergroups;sa=members;group=%2$d"%3$s>%4$s</a>', $scripturl, $rowData['id_group'], $color_style, $rowData['group_name']);
111
-							}
112
-							else
112
+							} else
113 113
 							{
114 114
 								$group_name = sprintf('<a href="%1$s?action=groups;sa=members;group=%2$d"%3$s>%4$s</a>', $scripturl, $rowData['id_group'], $color_style, $rowData['group_name']);
115 115
 							}
116 116
 						}
117 117
 
118 118
 						// Add a help option for moderator and administrator.
119
-						if ($rowData['id_group'] == 1)
120
-							$group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_administrator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl);
121
-						elseif ($rowData['id_group'] == 3)
122
-							$group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_moderator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl);
119
+						if ($rowData['id_group'] == 1) {
120
+													$group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_administrator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl);
121
+						} elseif ($rowData['id_group'] == 3) {
122
+													$group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_moderator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl);
123
+						}
123 124
 
124 125
 						return $group_name;
125 126
 					},
@@ -198,8 +199,9 @@  discard block
 block discarded – undo
198 199
 	$_REQUEST['group'] = isset($_REQUEST['group']) ? (int) $_REQUEST['group'] : 0;
199 200
 
200 201
 	// No browsing of guests, membergroup 0 or moderators.
201
-	if (in_array($_REQUEST['group'], array(-1, 0, 3)))
202
-		fatal_lang_error('membergroup_does_not_exist', false);
202
+	if (in_array($_REQUEST['group'], array(-1, 0, 3))) {
203
+			fatal_lang_error('membergroup_does_not_exist', false);
204
+	}
203 205
 
204 206
 	// Load up the group details.
205 207
 	$request = $smcFunc['db_query']('', '
@@ -214,8 +216,9 @@  discard block
 block discarded – undo
214 216
 		)
215 217
 	);
216 218
 	// Doesn't exist?
217
-	if ($smcFunc['db_num_rows']($request) == 0)
218
-		fatal_lang_error('membergroup_does_not_exist', false);
219
+	if ($smcFunc['db_num_rows']($request) == 0) {
220
+			fatal_lang_error('membergroup_does_not_exist', false);
221
+	}
219 222
 	$context['group'] = $smcFunc['db_fetch_assoc']($request);
220 223
 	$smcFunc['db_free_result']($request);
221 224
 
@@ -248,21 +251,25 @@  discard block
 block discarded – undo
248 251
 			'name' => $row['real_name']
249 252
 		);
250 253
 
251
-		if ($user_info['id'] == $row['id_member'] && $context['group']['group_type'] != 1)
252
-			$context['group']['can_moderate'] = true;
254
+		if ($user_info['id'] == $row['id_member'] && $context['group']['group_type'] != 1) {
255
+					$context['group']['can_moderate'] = true;
256
+		}
253 257
 	}
254 258
 	$smcFunc['db_free_result']($request);
255 259
 
256 260
 	// If this group is hidden then it can only "exists" if the user can moderate it!
257
-	if ($context['group']['hidden'] && !$context['group']['can_moderate'])
258
-		fatal_lang_error('membergroup_does_not_exist', false);
261
+	if ($context['group']['hidden'] && !$context['group']['can_moderate']) {
262
+			fatal_lang_error('membergroup_does_not_exist', false);
263
+	}
259 264
 
260 265
 	// You can only assign membership if you are the moderator and/or can manage groups!
261
-	if (!$context['group']['can_moderate'])
262
-		$context['group']['assignable'] = 0;
266
+	if (!$context['group']['can_moderate']) {
267
+			$context['group']['assignable'] = 0;
268
+	}
263 269
 	// Non-admins cannot assign admins.
264
-	elseif ($context['group']['id'] == 1 && !allowedTo('admin_forum'))
265
-		$context['group']['assignable'] = 0;
270
+	elseif ($context['group']['id'] == 1 && !allowedTo('admin_forum')) {
271
+			$context['group']['assignable'] = 0;
272
+	}
266 273
 
267 274
 	// Removing member from group?
268 275
 	if (isset($_POST['remove']) && !empty($_REQUEST['rem']) && is_array($_REQUEST['rem']) && $context['group']['assignable'])
@@ -271,8 +278,9 @@  discard block
 block discarded – undo
271 278
 		validateToken('mod-mgm');
272 279
 
273 280
 		// Make sure we're dealing with integers only.
274
-		foreach ($_REQUEST['rem'] as $key => $group)
275
-			$_REQUEST['rem'][$key] = (int) $group;
281
+		foreach ($_REQUEST['rem'] as $key => $group) {
282
+					$_REQUEST['rem'][$key] = (int) $group;
283
+		}
276 284
 
277 285
 		require_once($sourcedir . '/Subs-Membergroups.php');
278 286
 		removeMembersFromGroups($_REQUEST['rem'], $_REQUEST['group'], true);
@@ -295,16 +303,18 @@  discard block
 block discarded – undo
295 303
 		{
296 304
 			$member_names[$index] = trim($smcFunc['strtolower']($member_names[$index]));
297 305
 
298
-			if (strlen($member_names[$index]) == 0)
299
-				unset($member_names[$index]);
306
+			if (strlen($member_names[$index]) == 0) {
307
+							unset($member_names[$index]);
308
+			}
300 309
 		}
301 310
 
302 311
 		// Any passed by ID?
303 312
 		$member_ids = array();
304
-		if (!empty($_REQUEST['member_add']))
305
-			foreach ($_REQUEST['member_add'] as $id)
313
+		if (!empty($_REQUEST['member_add'])) {
314
+					foreach ($_REQUEST['member_add'] as $id)
306 315
 				if ($id > 0)
307 316
 					$member_ids[] = (int) $id;
317
+		}
308 318
 
309 319
 		// Construct the query pelements.
310 320
 		if (!empty($member_ids))
@@ -332,8 +342,9 @@  discard block
 block discarded – undo
332 342
 					'id_group' => $_REQUEST['group'],
333 343
 				))
334 344
 			);
335
-			while ($row = $smcFunc['db_fetch_assoc']($request))
336
-				$members[] = $row['id_member'];
345
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
346
+							$members[] = $row['id_member'];
347
+			}
337 348
 			$smcFunc['db_free_result']($request);
338 349
 		}
339 350
 
@@ -372,10 +383,11 @@  discard block
 block discarded – undo
372 383
 	$context['sort_direction'] = isset($_REQUEST['desc']) ? 'down' : 'up';
373 384
 
374 385
 	// The where on the query is interesting. Non-moderators should only see people who are in this group as primary.
375
-	if ($context['group']['can_moderate'])
376
-		$where = $context['group']['is_post_group'] ? 'id_post_group = {int:group}' : 'id_group = {int:group} OR FIND_IN_SET({int:group}, additional_groups) != 0';
377
-	else
378
-		$where = $context['group']['is_post_group'] ? 'id_post_group = {int:group}' : 'id_group = {int:group}';
386
+	if ($context['group']['can_moderate']) {
387
+			$where = $context['group']['is_post_group'] ? 'id_post_group = {int:group}' : 'id_group = {int:group} OR FIND_IN_SET({int:group}, additional_groups) != 0';
388
+	} else {
389
+			$where = $context['group']['is_post_group'] ? 'id_post_group = {int:group}' : 'id_group = {int:group}';
390
+	}
379 391
 
380 392
 	// Count members of the group.
381 393
 	$request = $smcFunc['db_query']('', '
@@ -416,8 +428,9 @@  discard block
 block discarded – undo
416 428
 		$last_online = empty($row['last_login']) ? $txt['never'] : timeformat($row['last_login']);
417 429
 
418 430
 		// Italicize the online note if they aren't activated.
419
-		if ($row['is_activated'] % 10 != 1)
420
-			$last_online = '<em title="' . $txt['not_activated'] . '">' . $last_online . '</em>';
431
+		if ($row['is_activated'] % 10 != 1) {
432
+					$last_online = '<em title="' . $txt['not_activated'] . '">' . $last_online . '</em>';
433
+		}
421 434
 
422 435
 		$context['members'][] = array(
423 436
 			'id' => $row['id_member'],
@@ -437,9 +450,10 @@  discard block
 block discarded – undo
437 450
 	$context['page_title'] = $txt['membergroups_members_title'] . ': ' . $context['group']['name'];
438 451
 	createToken('mod-mgm');
439 452
 
440
-	if ($context['group']['assignable'])
441
-		loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest');
442
-}
453
+	if ($context['group']['assignable']) {
454
+			loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest');
455
+	}
456
+	}
443 457
 
444 458
 /**
445 459
  * Show and manage all group requests.
@@ -453,16 +467,18 @@  discard block
 block discarded – undo
453 467
 	$context['sub_template'] = 'show_list';
454 468
 
455 469
 	// Verify we can be here.
456
-	if ($user_info['mod_cache']['gq'] == '0=1')
457
-		isAllowedTo('manage_membergroups');
470
+	if ($user_info['mod_cache']['gq'] == '0=1') {
471
+			isAllowedTo('manage_membergroups');
472
+	}
458 473
 
459 474
 	// Normally, we act normally...
460 475
 	$where = ($user_info['mod_cache']['gq'] == '1=1' || $user_info['mod_cache']['gq'] == '0=1' ? $user_info['mod_cache']['gq'] : 'lgr.' . $user_info['mod_cache']['gq']);
461 476
 
462
-	if (isset($_GET['closed']))
463
-		$where .= ' AND lgr.status != {int:status_open}';
464
-	else
465
-		$where .= ' AND lgr.status = {int:status_open}';
477
+	if (isset($_GET['closed'])) {
478
+			$where .= ' AND lgr.status != {int:status_open}';
479
+	} else {
480
+			$where .= ' AND lgr.status = {int:status_open}';
481
+	}
466 482
 
467 483
 	$where_parameters = array(
468 484
 		'status_open' => 0,
@@ -475,8 +491,9 @@  discard block
 block discarded – undo
475 491
 		validateToken('mod-gr');
476 492
 
477 493
 		// Clean the values.
478
-		foreach ($_POST['groupr'] as $k => $request)
479
-			$_POST['groupr'][$k] = (int) $request;
494
+		foreach ($_POST['groupr'] as $k => $request) {
495
+					$_POST['groupr'][$k] = (int) $request;
496
+		}
480 497
 
481 498
 		$log_changes = array();
482 499
 
@@ -513,8 +530,8 @@  discard block
 block discarded – undo
513 530
 			$request_list = array();
514 531
 			while ($row = $smcFunc['db_fetch_assoc']($request))
515 532
 			{
516
-				if (!isset($log_changes[$row['id_request']]))
517
-					$log_changes[$row['id_request']] = array(
533
+				if (!isset($log_changes[$row['id_request']])) {
534
+									$log_changes[$row['id_request']] = array(
518 535
 						'id_request' => $row['id_request'],
519 536
 						'status' => $_POST['req_action'] == 'approve' ? 1 : 2, // 1 = approved, 2 = rejected
520 537
 						'id_member_acted' => $user_info['id'],
@@ -522,6 +539,7 @@  discard block
 block discarded – undo
522 539
 						'time_acted' => time(),
523 540
 						'act_reason' => $_POST['req_action'] != 'approve' && !empty($_POST['groupreason']) && !empty($_POST['groupreason'][$row['id_request']]) ? $smcFunc['htmlspecialchars']($_POST['groupreason'][$row['id_request']], ENT_QUOTES) : '',
524 541
 					);
542
+				}
525 543
 				$request_list[] = $row['id_request'];
526 544
 			}
527 545
 			$smcFunc['db_free_result']($request);
@@ -744,21 +762,24 @@  discard block
 block discarded – undo
744 762
 	$group_requests = array();
745 763
 	while ($row = $smcFunc['db_fetch_assoc']($request))
746 764
 	{
747
-		if (empty($row['reason']))
748
-			$reason = '<em>(' . $txt['mc_groupr_no_reason'] . ')</em>';
749
-		else
750
-			$reason = censorText($row['reason']);
765
+		if (empty($row['reason'])) {
766
+					$reason = '<em>(' . $txt['mc_groupr_no_reason'] . ')</em>';
767
+		} else {
768
+					$reason = censorText($row['reason']);
769
+		}
751 770
 
752 771
 		if (isset($_GET['closed']))
753 772
 		{
754
-			if ($row['status'] == 1)
755
-				$reason .= '<br><br><strong>' . $txt['mc_groupr_approved'] . '</strong>';
756
-			elseif ($row['status'] == 2)
757
-				$reason .= '<br><br><strong>' . $txt['mc_groupr_rejected'] . '</strong>';
773
+			if ($row['status'] == 1) {
774
+							$reason .= '<br><br><strong>' . $txt['mc_groupr_approved'] . '</strong>';
775
+			} elseif ($row['status'] == 2) {
776
+							$reason .= '<br><br><strong>' . $txt['mc_groupr_rejected'] . '</strong>';
777
+			}
758 778
 
759 779
 				$reason .= ' (' . timeformat($row['time_acted']) . ')';
760
-			if (!empty($row['act_reason']))
761
-				$reason .= '<br><br>' . censorText($row['act_reason']);
780
+			if (!empty($row['act_reason'])) {
781
+							$reason .= '<br><br>' . censorText($row['act_reason']);
782
+			}
762 783
 		}
763 784
 
764 785
 		$group_requests[] = array(
Please login to merge, or discard this patch.
Sources/ManageNews.php 1 patch
Braces   +140 added lines, -102 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * The news dispatcher; doesn't do anything, just delegates.
@@ -67,8 +68,9 @@  discard block
 block discarded – undo
67 68
 	);
68 69
 
69 70
 	// Force the right area...
70
-	if (substr($_REQUEST['sa'], 0, 7) == 'mailing')
71
-		$context[$context['admin_menu_name']]['current_subsection'] = 'mailingmembers';
71
+	if (substr($_REQUEST['sa'], 0, 7) == 'mailing') {
72
+			$context[$context['admin_menu_name']]['current_subsection'] = 'mailingmembers';
73
+	}
72 74
 
73 75
 	call_helper($subActions[$_REQUEST['sa']][0]);
74 76
 }
@@ -99,9 +101,10 @@  discard block
 block discarded – undo
99 101
 		$temp_news = explode("\n", $modSettings['news']);
100 102
 
101 103
 		// Remove the items that were selected.
102
-		foreach ($temp_news as $i => $news)
103
-			if (in_array($i, $_POST['remove']))
104
+		foreach ($temp_news as $i => $news) {
105
+					if (in_array($i, $_POST['remove']))
104 106
 				unset($temp_news[$i]);
107
+		}
105 108
 
106 109
 		// Update the database.
107 110
 		updateSettings(array('news' => implode("\n", $temp_news)));
@@ -117,9 +120,9 @@  discard block
 block discarded – undo
117 120
 
118 121
 		foreach ($_POST['news'] as $i => $news)
119 122
 		{
120
-			if (trim($news) == '')
121
-				unset($_POST['news'][$i]);
122
-			else
123
+			if (trim($news) == '') {
124
+							unset($_POST['news'][$i]);
125
+			} else
123 126
 			{
124 127
 				$_POST['news'][$i] = $smcFunc['htmlspecialchars']($_POST['news'][$i], ENT_QUOTES);
125 128
 				preparsecode($_POST['news'][$i]);
@@ -154,11 +157,12 @@  discard block
 block discarded – undo
154 157
 				'data' => array(
155 158
 					'function' => function($news)
156 159
 					{
157
-						if (is_numeric($news['id']))
158
-							return '<textarea id="data_' . $news['id'] . '" rows="3" cols="50" name="news[]" class="padding block">' . $news['unparsed'] . '</textarea>
160
+						if (is_numeric($news['id'])) {
161
+													return '<textarea id="data_' . $news['id'] . '" rows="3" cols="50" name="news[]" class="padding block">' . $news['unparsed'] . '</textarea>
159 162
 							<div class="floatleft" id="preview_' . $news['id'] . '"></div>';
160
-						else
161
-							return $news['unparsed'];
163
+						} else {
164
+													return $news['unparsed'];
165
+						}
162 166
 					},
163 167
 					'style' => 'width: 50%;',
164 168
 				),
@@ -183,10 +187,11 @@  discard block
 block discarded – undo
183 187
 				'data' => array(
184 188
 					'function' => function($news)
185 189
 					{
186
-						if (is_numeric($news['id']))
187
-							return '<input type="checkbox" name="remove[]" value="' . $news['id'] . '" class="input_check">';
188
-						else
189
-							return '';
190
+						if (is_numeric($news['id'])) {
191
+													return '<input type="checkbox" name="remove[]" value="' . $news['id'] . '" class="input_check">';
192
+						} else {
193
+													return '';
194
+						}
190 195
 					},
191 196
 					'class' => 'centercol',
192 197
 				),
@@ -280,12 +285,13 @@  discard block
 block discarded – undo
280 285
 
281 286
 	$admin_current_news = array();
282 287
 	// Ready the current news.
283
-	foreach (explode("\n", $modSettings['news']) as $id => $line)
284
-		$admin_current_news[$id] = array(
288
+	foreach (explode("\n", $modSettings['news']) as $id => $line) {
289
+			$admin_current_news[$id] = array(
285 290
 			'id' => $id,
286 291
 			'unparsed' => un_preparsecode($line),
287 292
 			'parsed' => preg_replace('~<([/]?)form[^>]*?[>]*>~i', '<em class="smalltext">&lt;$1form&gt;</em>', parse_bbc($line)),
288 293
 		);
294
+	}
289 295
 
290 296
 	$admin_current_news['last'] = array(
291 297
 		'id' => 'last',
@@ -352,10 +358,11 @@  discard block
 block discarded – undo
352 358
 			'member_count' => 0,
353 359
 		);
354 360
 
355
-		if ($row['min_posts'] == -1)
356
-			$normalGroups[$row['id_group']] = $row['id_group'];
357
-		else
358
-			$postGroups[$row['id_group']] = $row['id_group'];
361
+		if ($row['min_posts'] == -1) {
362
+					$normalGroups[$row['id_group']] = $row['id_group'];
363
+		} else {
364
+					$postGroups[$row['id_group']] = $row['id_group'];
365
+		}
359 366
 	}
360 367
 	$smcFunc['db_free_result']($request);
361 368
 
@@ -371,8 +378,9 @@  discard block
 block discarded – undo
371 378
 				'post_group_list' => $postGroups,
372 379
 			)
373 380
 		);
374
-		while ($row = $smcFunc['db_fetch_assoc']($query))
375
-			$context['groups'][$row['id_group']]['member_count'] += $row['member_count'];
381
+		while ($row = $smcFunc['db_fetch_assoc']($query)) {
382
+					$context['groups'][$row['id_group']]['member_count'] += $row['member_count'];
383
+		}
376 384
 		$smcFunc['db_free_result']($query);
377 385
 	}
378 386
 
@@ -388,8 +396,9 @@  discard block
 block discarded – undo
388 396
 				'normal_group_list' => $normalGroups,
389 397
 			)
390 398
 		);
391
-		while ($row = $smcFunc['db_fetch_assoc']($query))
392
-			$context['groups'][$row['id_group']]['member_count'] += $row['member_count'];
399
+		while ($row = $smcFunc['db_fetch_assoc']($query)) {
400
+					$context['groups'][$row['id_group']]['member_count'] += $row['member_count'];
401
+		}
393 402
 		$smcFunc['db_free_result']($query);
394 403
 
395 404
 		// Also do those who have it as an additional membergroup - this ones more yucky...
@@ -406,8 +415,9 @@  discard block
 block discarded – undo
406 415
 				'blank_string' => '',
407 416
 			)
408 417
 		);
409
-		while ($row = $smcFunc['db_fetch_assoc']($query))
410
-			$context['groups'][$row['id_group']]['member_count'] += $row['member_count'];
418
+		while ($row = $smcFunc['db_fetch_assoc']($query)) {
419
+					$context['groups'][$row['id_group']]['member_count'] += $row['member_count'];
420
+		}
411 421
 		$smcFunc['db_free_result']($query);
412 422
 	}
413 423
 
@@ -458,10 +468,11 @@  discard block
 block discarded – undo
458 468
 	{
459 469
 		$context[$key] = !empty($_REQUEST[$post]) ? $_REQUEST[$post] : '';
460 470
 
461
-		if (empty($context[$key]) && empty($_REQUEST['xml']))
462
-			$context['post_error']['messages'][] = $txt['error_no_' . $post];
463
-		elseif (!empty($_REQUEST['xml']))
464
-			continue;
471
+		if (empty($context[$key]) && empty($_REQUEST['xml'])) {
472
+					$context['post_error']['messages'][] = $txt['error_no_' . $post];
473
+		} elseif (!empty($_REQUEST['xml'])) {
474
+					continue;
475
+		}
465 476
 
466 477
 		preparsecode($context[$key]);
467 478
 		if ($html)
@@ -540,10 +551,12 @@  discard block
 block discarded – undo
540 551
 
541 552
 	// Start by finding any members!
542 553
 	$toClean = array();
543
-	if (!empty($_POST['members']))
544
-		$toClean[] = 'members';
545
-	if (!empty($_POST['exclude_members']))
546
-		$toClean[] = 'exclude_members';
554
+	if (!empty($_POST['members'])) {
555
+			$toClean[] = 'members';
556
+	}
557
+	if (!empty($_POST['exclude_members'])) {
558
+			$toClean[] = 'exclude_members';
559
+	}
547 560
 	if (!empty($toClean))
548 561
 	{
549 562
 		require_once($sourcedir . '/Subs-Auth.php');
@@ -555,11 +568,13 @@  discard block
 block discarded – undo
555 568
 			preg_match_all('~"([^"]+)"~', $_POST[$type], $matches);
556 569
 			$_POST[$type] = array_unique(array_merge($matches[1], explode(',', preg_replace('~"[^"]+"~', '', $_POST[$type]))));
557 570
 
558
-			foreach ($_POST[$type] as $index => $member)
559
-				if (strlen(trim($member)) > 0)
571
+			foreach ($_POST[$type] as $index => $member) {
572
+							if (strlen(trim($member)) > 0)
560 573
 					$_POST[$type][$index] = $smcFunc['htmlspecialchars']($smcFunc['strtolower'](trim($member)));
561
-				else
562
-					unset($_POST[$type][$index]);
574
+			}
575
+				else {
576
+									unset($_POST[$type][$index]);
577
+				}
563 578
 
564 579
 			// Find the members
565 580
 			$_POST[$type] = implode(',', array_keys(findMembers($_POST[$type])));
@@ -569,16 +584,18 @@  discard block
 block discarded – undo
569 584
 	if (isset($_POST['member_list']) && is_array($_POST['member_list']))
570 585
 	{
571 586
 		$members = array();
572
-		foreach ($_POST['member_list'] as $member_id)
573
-			$members[] = (int) $member_id;
587
+		foreach ($_POST['member_list'] as $member_id) {
588
+					$members[] = (int) $member_id;
589
+		}
574 590
 		$_POST['members'] = implode(',', $members);
575 591
 	}
576 592
 
577 593
 	if (isset($_POST['exclude_member_list']) && is_array($_POST['exclude_member_list']))
578 594
 	{
579 595
 		$members = array();
580
-		foreach ($_POST['exclude_member_list'] as $member_id)
581
-			$members[] = (int) $member_id;
596
+		foreach ($_POST['exclude_member_list'] as $member_id) {
597
+					$members[] = (int) $member_id;
598
+		}
582 599
 		$_POST['exclude_members'] = implode(',', $members);
583 600
 	}
584 601
 
@@ -602,8 +619,9 @@  discard block
 block discarded – undo
602 619
 			'current_time' => time(),
603 620
 		)
604 621
 	);
605
-	while ($row = $smcFunc['db_fetch_assoc']($request))
606
-		$context['recipients']['exclude_members'][] = $row['id_member'];
622
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
623
+			$context['recipients']['exclude_members'][] = $row['id_member'];
624
+	}
607 625
 	$smcFunc['db_free_result']($request);
608 626
 
609 627
 	$request = $smcFunc['db_query']('', '
@@ -638,8 +656,9 @@  discard block
 block discarded – undo
638 656
 			WHERE email_address IN(' . implode(', ', $condition_array) . ')',
639 657
 			$condition_array_params
640 658
 		);
641
-		while ($row = $smcFunc['db_fetch_assoc']($request))
642
-			$context['recipients']['exclude_members'][] = $row['id_member'];
659
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
660
+					$context['recipients']['exclude_members'][] = $row['id_member'];
661
+		}
643 662
 		$smcFunc['db_free_result']($request);
644 663
 	}
645 664
 
@@ -657,10 +676,11 @@  discard block
 block discarded – undo
657 676
 		);
658 677
 		while ($row = $smcFunc['db_fetch_assoc']($request))
659 678
 		{
660
-			if (in_array(3, $context['recipients']))
661
-				$context['recipients']['exclude_members'][] = $row['identifier'];
662
-			else
663
-				$context['recipients']['members'][] = $row['identifier'];
679
+			if (in_array(3, $context['recipients'])) {
680
+							$context['recipients']['exclude_members'][] = $row['identifier'];
681
+			} else {
682
+							$context['recipients']['members'][] = $row['identifier'];
683
+			}
664 684
 		}
665 685
 		$smcFunc['db_free_result']($request);
666 686
 	}
@@ -707,8 +727,9 @@  discard block
 block discarded – undo
707 727
 	$num_at_once = 1000;
708 728
 
709 729
 	// If by PM's I suggest we half the above number.
710
-	if (!empty($_POST['send_pm']))
711
-		$num_at_once /= 2;
730
+	if (!empty($_POST['send_pm'])) {
731
+			$num_at_once /= 2;
732
+	}
712 733
 
713 734
 	checkSession();
714 735
 
@@ -731,8 +752,7 @@  discard block
 block discarded – undo
731 752
 		);
732 753
 		list ($context['total_members']) = $smcFunc['db_fetch_row']($request);
733 754
 		$smcFunc['db_free_result']($request);
734
-	}
735
-	else
755
+	} else
736 756
 	{
737 757
 		$context['total_members'] = (int) $_REQUEST['total_members'];
738 758
 	}
@@ -750,32 +770,35 @@  discard block
 block discarded – undo
750 770
 	if (!empty($_POST['exclude_members']))
751 771
 	{
752 772
 		$members = explode(',', $_POST['exclude_members']);
753
-		foreach ($members as $member)
754
-			if ($member >= $context['start'])
773
+		foreach ($members as $member) {
774
+					if ($member >= $context['start'])
755 775
 				$context['recipients']['exclude_members'][] = (int) $member;
776
+		}
756 777
 	}
757 778
 
758 779
 	// What about members we *must* do?
759 780
 	if (!empty($_POST['members']))
760 781
 	{
761 782
 		$members = explode(',', $_POST['members']);
762
-		foreach ($members as $member)
763
-			if ($member >= $context['start'])
783
+		foreach ($members as $member) {
784
+					if ($member >= $context['start'])
764 785
 				$context['recipients']['members'][] = (int) $member;
786
+		}
765 787
 	}
766 788
 	// Cleaning groups is simple - although deal with both checkbox and commas.
767 789
 	if (isset($_POST['groups']))
768 790
 	{
769 791
 		if (is_array($_POST['groups']))
770 792
 		{
771
-			foreach ($_POST['groups'] as $group => $dummy)
772
-				$context['recipients']['groups'][] = (int) $group;
773
-		}
774
-		else
793
+			foreach ($_POST['groups'] as $group => $dummy) {
794
+							$context['recipients']['groups'][] = (int) $group;
795
+			}
796
+		} else
775 797
 		{
776 798
 			$groups = explode(',', $_POST['groups']);
777
-			foreach ($groups as $group)
778
-				$context['recipients']['groups'][] = (int) $group;
799
+			foreach ($groups as $group) {
800
+							$context['recipients']['groups'][] = (int) $group;
801
+			}
779 802
 		}
780 803
 	}
781 804
 	// Same for excluded groups
@@ -783,15 +806,17 @@  discard block
 block discarded – undo
783 806
 	{
784 807
 		if (is_array($_POST['exclude_groups']))
785 808
 		{
786
-			foreach ($_POST['exclude_groups'] as $group => $dummy)
787
-				$context['recipients']['exclude_groups'][] = (int) $group;
809
+			foreach ($_POST['exclude_groups'] as $group => $dummy) {
810
+							$context['recipients']['exclude_groups'][] = (int) $group;
811
+			}
788 812
 		}
789 813
 		// Ignore an empty string - we don't want to exclude "Regular Members" unless it's specifically selected
790 814
 		elseif ($_POST['exclude_groups'] != '')
791 815
 		{
792 816
 			$groups = explode(',', $_POST['exclude_groups']);
793
-			foreach ($groups as $group)
794
-				$context['recipients']['exclude_groups'][] = (int) $group;
817
+			foreach ($groups as $group) {
818
+							$context['recipients']['exclude_groups'][] = (int) $group;
819
+			}
795 820
 		}
796 821
 	}
797 822
 	// Finally - emails!
@@ -801,14 +826,16 @@  discard block
 block discarded – undo
801 826
 		foreach ($addressed as $curmem)
802 827
 		{
803 828
 			$curmem = trim($curmem);
804
-			if ($curmem != '' && filter_var($curmem, FILTER_VALIDATE_EMAIL))
805
-				$context['recipients']['emails'][$curmem] = $curmem;
829
+			if ($curmem != '' && filter_var($curmem, FILTER_VALIDATE_EMAIL)) {
830
+							$context['recipients']['emails'][$curmem] = $curmem;
831
+			}
806 832
 		}
807 833
 	}
808 834
 
809 835
 	// If we're only cleaning drop out here.
810
-	if ($clean_only)
811
-		return;
836
+	if ($clean_only) {
837
+			return;
838
+	}
812 839
 
813 840
 	require_once($sourcedir . '/Subs-Post.php');
814 841
 
@@ -824,16 +851,18 @@  discard block
 block discarded – undo
824 851
 	if (!$context['send_pm'] && !empty($_POST['send_html']))
825 852
 	{
826 853
 		// Prepare the message for HTML.
827
-		if (!empty($_POST['parse_html']))
828
-			$_POST['message'] = str_replace(array("\n", '  '), array('<br>' . "\n", '&nbsp; '), $_POST['message']);
854
+		if (!empty($_POST['parse_html'])) {
855
+					$_POST['message'] = str_replace(array("\n", '  '), array('<br>' . "\n", '&nbsp; '), $_POST['message']);
856
+		}
829 857
 
830 858
 		// This is here to prevent spam filters from tagging this as spam.
831 859
 		if (preg_match('~\<html~i', $_POST['message']) == 0)
832 860
 		{
833
-			if (preg_match('~\<body~i', $_POST['message']) == 0)
834
-				$_POST['message'] = '<html><head><title>' . $_POST['subject'] . '</title></head>' . "\n" . '<body>' . $_POST['message'] . '</body></html>';
835
-			else
836
-				$_POST['message'] = '<html>' . $_POST['message'] . '</html>';
861
+			if (preg_match('~\<body~i', $_POST['message']) == 0) {
862
+							$_POST['message'] = '<html><head><title>' . $_POST['subject'] . '</title></head>' . "\n" . '<body>' . $_POST['message'] . '</body></html>';
863
+			} else {
864
+							$_POST['message'] = '<html>' . $_POST['message'] . '</html>';
865
+			}
837 866
 		}
838 867
 	}
839 868
 
@@ -887,15 +916,17 @@  discard block
 block discarded – undo
887 916
 	foreach ($context['recipients']['emails'] as $k => $email)
888 917
 	{
889 918
 		// Done as many as we can?
890
-		if ($i >= $num_at_once)
891
-			break;
919
+		if ($i >= $num_at_once) {
920
+					break;
921
+		}
892 922
 
893 923
 		// Don't sent it twice!
894 924
 		unset($context['recipients']['emails'][$k]);
895 925
 
896 926
 		// Dammit - can't PM emails!
897
-		if ($context['send_pm'])
898
-			continue;
927
+		if ($context['send_pm']) {
928
+					continue;
929
+		}
899 930
 
900 931
 		$to_member = array(
901 932
 			$email,
@@ -929,8 +960,9 @@  discard block
 block discarded – undo
929 960
 					$queryBuild[] = 'mem.id_post_group = {int:group_' . $group . '}';
930 961
 				}
931 962
 			}
932
-			if (!empty($queryBuild))
933
-			$sendQuery .= implode(' OR ', $queryBuild);
963
+			if (!empty($queryBuild)) {
964
+						$sendQuery .= implode(' OR ', $queryBuild);
965
+			}
934 966
 		}
935 967
 		if (!empty($context['recipients']['members']))
936 968
 		{
@@ -949,8 +981,9 @@  discard block
 block discarded – undo
949 981
 		}
950 982
 
951 983
 		// Anything to exclude?
952
-		if (!empty($context['recipients']['exclude_groups']) && in_array(0, $context['recipients']['exclude_groups']))
953
-			$sendQuery .= ' AND mem.id_group != {int:regular_group}';
984
+		if (!empty($context['recipients']['exclude_groups']) && in_array(0, $context['recipients']['exclude_groups'])) {
985
+					$sendQuery .= ' AND mem.id_group != {int:regular_group}';
986
+		}
954 987
 		if (!empty($context['recipients']['exclude_members']))
955 988
 		{
956 989
 			$sendQuery .= ' AND mem.id_member NOT IN ({array_int:exclude_members})';
@@ -986,21 +1019,24 @@  discard block
 block discarded – undo
986 1019
 		foreach ($rows as $row)
987 1020
 		{
988 1021
 			// Force them to have it?
989
-			if (empty($context['email_force']) && empty($prefs[$row['id_member']]['announcements']))
990
-				continue;
1022
+			if (empty($context['email_force']) && empty($prefs[$row['id_member']]['announcements'])) {
1023
+							continue;
1024
+			}
991 1025
 
992 1026
 			// What groups are we looking at here?
993
-			if (empty($row['additional_groups']))
994
-				$groups = array($row['id_group'], $row['id_post_group']);
995
-			else
996
-				$groups = array_merge(
1027
+			if (empty($row['additional_groups'])) {
1028
+							$groups = array($row['id_group'], $row['id_post_group']);
1029
+			} else {
1030
+							$groups = array_merge(
997 1031
 					array($row['id_group'], $row['id_post_group']),
998 1032
 					explode(',', $row['additional_groups'])
999 1033
 				);
1034
+			}
1000 1035
 
1001 1036
 			// Excluded groups?
1002
-			if (array_intersect($groups, $context['recipients']['exclude_groups']))
1003
-				continue;
1037
+			if (array_intersect($groups, $context['recipients']['exclude_groups'])) {
1038
+							continue;
1039
+			}
1004 1040
 
1005 1041
 			// We might need this
1006 1042
 			$cleanMemberName = empty($_POST['send_html']) || $context['send_pm'] ? un_htmlspecialchars($row['real_name']) : $row['real_name'];
@@ -1023,10 +1059,11 @@  discard block
 block discarded – undo
1023 1059
 				), $_POST['subject']);
1024 1060
 
1025 1061
 			// Send the actual email - or a PM!
1026
-			if (!$context['send_pm'])
1027
-				sendmail($row['email_address'], $subject, $message, null, 'news', !empty($_POST['send_html']), 5);
1028
-			else
1029
-				sendpm(array('to' => array($row['id_member']), 'bcc' => array()), $subject, $message);
1062
+			if (!$context['send_pm']) {
1063
+							sendmail($row['email_address'], $subject, $message, null, 'news', !empty($_POST['send_html']), 5);
1064
+			} else {
1065
+							sendpm(array('to' => array($row['id_member']), 'bcc' => array()), $subject, $message);
1066
+			}
1030 1067
 		}
1031 1068
 	}
1032 1069
 
@@ -1076,8 +1113,9 @@  discard block
 block discarded – undo
1076 1113
 
1077 1114
 	call_integration_hook('integrate_modify_news_settings', array(&$config_vars));
1078 1115
 
1079
-	if ($return_config)
1080
-		return $config_vars;
1116
+	if ($return_config) {
1117
+			return $config_vars;
1118
+	}
1081 1119
 
1082 1120
 	$context['page_title'] = $txt['admin_edit_news'] . ' - ' . $txt['settings'];
1083 1121
 	$context['sub_template'] = 'show_settings';
Please login to merge, or discard this patch.
Sources/Subs-MessageIndex.php 1 patch
Braces   +13 added lines, -10 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
  * @version 2.1 Beta 4
12 12
  */
13 13
 
14
-if (!defined('SMF'))
14
+if (!defined('SMF')) {
15 15
 	die('No direct access...');
16
+}
16 17
 
17 18
 /**
18 19
  * Generates the query to determine the list of available boards for a user
@@ -25,8 +26,9 @@  discard block
 block discarded – undo
25 26
 {
26 27
 	global $smcFunc, $sourcedir;
27 28
 
28
-	if (isset($boardListOptions['excluded_boards']) && isset($boardListOptions['included_boards']))
29
-		trigger_error('getBoardList(): Setting both excluded_boards and included_boards is not allowed.', E_USER_ERROR);
29
+	if (isset($boardListOptions['excluded_boards']) && isset($boardListOptions['included_boards'])) {
30
+			trigger_error('getBoardList(): Setting both excluded_boards and included_boards is not allowed.', E_USER_ERROR);
31
+	}
30 32
 
31 33
 	$where = array();
32 34
 	$where_parameters = array();
@@ -42,11 +44,11 @@  discard block
 block discarded – undo
42 44
 		$where_parameters['included_boards'] = $boardListOptions['included_boards'];
43 45
 	}
44 46
 
45
-	if (!empty($boardListOptions['ignore_boards']))
46
-		$where[] = '{query_wanna_see_board}';
47
-
48
-	elseif (!empty($boardListOptions['use_permissions']))
49
-		$where[] = '{query_see_board}';
47
+	if (!empty($boardListOptions['ignore_boards'])) {
48
+			$where[] = '{query_wanna_see_board}';
49
+	} elseif (!empty($boardListOptions['use_permissions'])) {
50
+			$where[] = '{query_see_board}';
51
+	}
50 52
 
51 53
 	if (!empty($boardListOptions['not_redirection']))
52 54
 	{
@@ -68,12 +70,13 @@  discard block
 block discarded – undo
68 70
 	{
69 71
 		while ($row = $smcFunc['db_fetch_assoc']($request))
70 72
 		{
71
-			if (!isset($return_value[$row['id_cat']]))
72
-				$return_value[$row['id_cat']] = array(
73
+			if (!isset($return_value[$row['id_cat']])) {
74
+							$return_value[$row['id_cat']] = array(
73 75
 					'id' => $row['id_cat'],
74 76
 					'name' => $row['cat_name'],
75 77
 					'boards' => array(),
76 78
 				);
79
+			}
77 80
 
78 81
 			$return_value[$row['id_cat']]['boards'][$row['id_board']] = array(
79 82
 				'id' => $row['id_board'],
Please login to merge, or discard this patch.
Sources/Class-CacheAPI.php 1 patch
Braces   +13 added lines, -9 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
  * @version 2.1 Beta 4
12 12
  */
13 13
 
14
-if (!defined('SMF'))
14
+if (!defined('SMF')) {
15 15
 	die('Hacking attempt...');
16
+}
16 17
 
17 18
 /**
18 19
  * Interface cache_api_interface
@@ -183,8 +184,9 @@  discard block
 block discarded – undo
183 184
 	{
184 185
 		global $cache_enable;
185 186
 
186
-		if ($test)
187
-			return true;
187
+		if ($test) {
188
+					return true;
189
+		}
188 190
 		return !empty($cache_enable);
189 191
 	}
190 192
 
@@ -203,10 +205,11 @@  discard block
 block discarded – undo
203 205
 		global $boardurl, $cachedir;
204 206
 
205 207
 		// Set the default if no prefix was specified.
206
-		if (empty($prefix))
207
-			$this->prefix = md5($boardurl . filemtime($cachedir . '/' . 'index.php')) . '-SMF-';
208
-		else
209
-			$this->prefix = $prefix;
208
+		if (empty($prefix)) {
209
+					$this->prefix = md5($boardurl . filemtime($cachedir . '/' . 'index.php')) . '-SMF-';
210
+		} else {
211
+					$this->prefix = $prefix;
212
+		}
210 213
 
211 214
 		return true;
212 215
 	}
@@ -269,8 +272,9 @@  discard block
 block discarded – undo
269 272
 
270 273
 		// Invalidate cache, to be sure!
271 274
 		// ... as long as index.php can be modified, anyway.
272
-		if (is_writable($cachedir . '/' . 'index.php'))
273
-			@touch($cachedir . '/' . 'index.php');
275
+		if (is_writable($cachedir . '/' . 'index.php')) {
276
+					@touch($cachedir . '/' . 'index.php');
277
+		}
274 278
 
275 279
 		return true;
276 280
 	}
Please login to merge, or discard this patch.
Sources/DbSearch-mysql.php 1 patch
Braces   +13 added lines, -10 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  *  Add the file functions to the $smcFunc array.
@@ -23,14 +24,15 @@  discard block
 block discarded – undo
23 24
 {
24 25
 	global $smcFunc;
25 26
 
26
-	if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_query')
27
-		$smcFunc += array(
27
+	if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_query') {
28
+			$smcFunc += array(
28 29
 			'db_search_query' => 'smf_db_query',
29 30
 			'db_search_support' => 'smf_db_search_support',
30 31
 			'db_create_word_search' => 'smf_db_create_word_search',
31 32
 			'db_support_ignore' => true,
32 33
 		);
33
-}
34
+	}
35
+	}
34 36
 
35 37
 /**
36 38
  * This function will tell you whether this database type supports this search type.
@@ -54,12 +56,13 @@  discard block
 block discarded – undo
54 56
 {
55 57
 	global $smcFunc;
56 58
 
57
-	if ($size == 'small')
58
-		$size = 'smallint(5)';
59
-	elseif ($size == 'medium')
60
-		$size = 'mediumint(8)';
61
-	else
62
-		$size = 'int(10)';
59
+	if ($size == 'small') {
60
+			$size = 'smallint(5)';
61
+	} elseif ($size == 'medium') {
62
+			$size = 'mediumint(8)';
63
+	} else {
64
+			$size = 'int(10)';
65
+	}
63 66
 
64 67
 	$smcFunc['db_query']('', '
65 68
 		CREATE TABLE {db_prefix}log_search_words (
Please login to merge, or discard this patch.
Sources/ManageMail.php 1 patch
Braces   +26 added lines, -18 removed lines patch added patch discarded remove patch
@@ -15,8 +15,9 @@  discard block
 block discarded – undo
15 15
  * @version 2.1 Beta 4
16 16
  */
17 17
 
18
-if (!defined('SMF'))
18
+if (!defined('SMF')) {
19 19
 	die('No direct access...');
20
+}
20 21
 
21 22
 /**
22 23
  * Main dispatcher. This function checks permissions and passes control through to the relevant section.
@@ -245,8 +246,9 @@  discard block
 block discarded – undo
245 246
 	while ($row = $smcFunc['db_fetch_assoc']($request))
246 247
 	{
247 248
 		// Private PM/email subjects and similar shouldn't be shown in the mailbox area.
248
-		if (!empty($row['private']))
249
-			$row['subject'] = $txt['personal_message'];
249
+		if (!empty($row['private'])) {
250
+					$row['subject'] = $txt['personal_message'];
251
+		}
250 252
 
251 253
 		$mails[] = $row;
252 254
 	}
@@ -300,8 +302,9 @@  discard block
 block discarded – undo
300 302
 		$element = substr($key, strrpos($key, '_') + 1);
301 303
 		$processedBirthdayEmails[$index][$element] = $value;
302 304
 	}
303
-	foreach ($processedBirthdayEmails as $index => $dummy)
304
-		$emails[$index] = $index;
305
+	foreach ($processedBirthdayEmails as $index => $dummy) {
306
+			$emails[$index] = $index;
307
+	}
305 308
 
306 309
 	$config_vars = array(
307 310
 			// Mail queue stuff, this rocks ;)
@@ -322,8 +325,9 @@  discard block
 block discarded – undo
322 325
 
323 326
 	call_integration_hook('integrate_modify_mail_settings', array(&$config_vars));
324 327
 
325
-	if ($return_config)
326
-		return $config_vars;
328
+	if ($return_config) {
329
+			return $config_vars;
330
+	}
327 331
 
328 332
 	// Saving?
329 333
 	if (isset($_GET['save']))
@@ -398,9 +402,9 @@  discard block
 block discarded – undo
398 402
 		);
399 403
 		list ($_GET['te']) = $smcFunc['db_fetch_row']($request);
400 404
 		$smcFunc['db_free_result']($request);
405
+	} else {
406
+			$_GET['te'] = (int) $_GET['te'];
401 407
 	}
402
-	else
403
-		$_GET['te'] = (int) $_GET['te'];
404 408
 
405 409
 	$_GET['sent'] = isset($_GET['sent']) ? (int) $_GET['sent'] : 0;
406 410
 
@@ -424,12 +428,14 @@  discard block
 block discarded – undo
424 428
 
425 429
 	// Try get more time...
426 430
 	@set_time_limit(600);
427
-	if (function_exists('apache_reset_timeout'))
428
-		@apache_reset_timeout();
431
+	if (function_exists('apache_reset_timeout')) {
432
+			@apache_reset_timeout();
433
+	}
429 434
 
430 435
 	// Have we already used our maximum time?
431
-	if (time() - array_sum(explode(' ', $time_start)) < 5)
432
-		return;
436
+	if (time() - array_sum(explode(' ', $time_start)) < 5) {
437
+			return;
438
+	}
433 439
 
434 440
 	$context['continue_get_data'] = '?action=admin;area=mailqueue;sa=clear;te=' . $_GET['te'] . ';sent=' . $_GET['sent'] . ';' . $context['session_var'] . '=' . $context['session_id'];
435 441
 	$context['page_title'] = $txt['not_done_title'];
@@ -459,8 +465,9 @@  discard block
 block discarded – undo
459 465
 {
460 466
 	global $txt;
461 467
 
462
-	if ($time_diff < 0)
463
-		$time_diff = 0;
468
+	if ($time_diff < 0) {
469
+			$time_diff = 0;
470
+	}
464 471
 
465 472
 	// Just do a bit of an if fest...
466 473
 	if ($time_diff > 86400)
@@ -481,8 +488,9 @@  discard block
 block discarded – undo
481 488
 		return sprintf($minutes == 1 ? $txt['mq_minute'] : $txt['mq_minutes'], $minutes);
482 489
 	}
483 490
 	// Otherwise must be second
484
-	else
485
-		return sprintf($time_diff == 1 ? $txt['mq_second'] : $txt['mq_seconds'], $time_diff);
486
-}
491
+	else {
492
+			return sprintf($time_diff == 1 ? $txt['mq_second'] : $txt['mq_seconds'], $time_diff);
493
+	}
494
+	}
487 495
 
488 496
 ?>
489 497
\ No newline at end of file
Please login to merge, or discard this patch.