Completed
Push — release-2.1 ( cfdc59...af3d3b )
by Jeremy
12:06 queued 05:35
created
Sources/RepairBoards.php 1 patch
Braces   +119 added lines, -85 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
  * Finds or repairs errors in the database to fix possible problems.
@@ -50,8 +51,9 @@  discard block
 block discarded – undo
50 51
 	);
51 52
 
52 53
 	// Start displaying errors without fixing them.
53
-	if (isset($_GET['fixErrors']))
54
-		checkSession('get');
54
+	if (isset($_GET['fixErrors'])) {
55
+			checkSession('get');
56
+	}
55 57
 
56 58
 	// Will want this.
57 59
 	loadForumTests();
@@ -69,14 +71,14 @@  discard block
 block discarded – undo
69 71
 			$_SESSION['repairboards_to_fix'] = $context['to_fix'];
70 72
 			$_SESSION['repairboards_to_fix2'] = null;
71 73
 
72
-			if (empty($context['repair_errors']))
73
-				$context['repair_errors'][] = '???';
74
+			if (empty($context['repair_errors'])) {
75
+							$context['repair_errors'][] = '???';
76
+			}
74 77
 		}
75 78
 
76 79
 		// Need a token here.
77 80
 		createToken('admin-repairboards', 'request');
78
-	}
79
-	else
81
+	} else
80 82
 	{
81 83
 		// Validate the token, create a new one and tell the not done template.
82 84
 		validateToken('admin-repairboards', 'request');
@@ -134,16 +136,19 @@  discard block
 block discarded – undo
134 136
 
135 137
 	// More time, I need more time!
136 138
 	@set_time_limit(600);
137
-	if (function_exists('apache_reset_timeout'))
138
-		@apache_reset_timeout();
139
+	if (function_exists('apache_reset_timeout')) {
140
+			@apache_reset_timeout();
141
+	}
139 142
 
140 143
 	// Errr, wait.  How much time has this taken already?
141
-	if (!$force && (time() - $time_start) < 3)
142
-		return;
144
+	if (!$force && (time() - $time_start) < 3) {
145
+			return;
146
+	}
143 147
 
144 148
 	// Restore the query cache if interested.
145
-	if (!empty($db_temp_cache))
146
-		$db_cache = $db_temp_cache;
149
+	if (!empty($db_temp_cache)) {
150
+			$db_cache = $db_temp_cache;
151
+	}
147 152
 
148 153
 	$context['continue_get_data'] = '?action=admin;area=repairboards' . (isset($_GET['fixErrors']) ? ';fixErrors' : '') . ';step=' . $_GET['step'] . ';substep=' . $_GET['substep'] . ';' . $context['session_var'] . '=' . $context['session_id'];
149 154
 	$context['page_title'] = $txt['not_done_title'];
@@ -152,10 +157,11 @@  discard block
 block discarded – undo
152 157
 	$context['sub_template'] = 'not_done';
153 158
 
154 159
 	// Change these two if more steps are added!
155
-	if (empty($max_substep))
156
-		$context['continue_percent'] = round(($_GET['step'] * 100) / $context['total_steps']);
157
-	else
158
-		$context['continue_percent'] = round((($_GET['step'] + ($_GET['substep'] / $max_substep)) * 100) / $context['total_steps']);
160
+	if (empty($max_substep)) {
161
+			$context['continue_percent'] = round(($_GET['step'] * 100) / $context['total_steps']);
162
+	} else {
163
+			$context['continue_percent'] = round((($_GET['step'] + ($_GET['substep'] / $max_substep)) * 100) / $context['total_steps']);
164
+	}
159 165
 
160 166
 	// Never more than 100%!
161 167
 	$context['continue_percent'] = min($context['continue_percent'], 100);
@@ -624,8 +630,9 @@  discard block
 block discarded – undo
624 630
 				$row['myid_last_msg'] = (int) $row['myid_last_msg'];
625 631
 
626 632
 				// Not really a problem?
627
-				if ($row['id_first_msg'] == $row['myid_first_msg'] && $row['id_last_msg'] == $row['myid_last_msg'] && $row['approved'] == $row['firstmsg_approved'])
628
-					return false;
633
+				if ($row['id_first_msg'] == $row['myid_first_msg'] && $row['id_last_msg'] == $row['myid_last_msg'] && $row['approved'] == $row['firstmsg_approved']) {
634
+									return false;
635
+				}
629 636
 
630 637
 				$memberStartedID = (int) getMsgMemberID($row['myid_first_msg']);
631 638
 				$memberUpdatedID = (int) getMsgMemberID($row['myid_last_msg']);
@@ -649,15 +656,19 @@  discard block
 block discarded – undo
649 656
 			'message_function' => function ($row) use ($txt, &$context)
650 657
 			{
651 658
 				// A pretend error?
652
-				if ($row['id_first_msg'] == $row['myid_first_msg'] && $row['id_last_msg'] == $row['myid_last_msg'] && $row['approved'] == $row['firstmsg_approved'])
653
-					return false;
659
+				if ($row['id_first_msg'] == $row['myid_first_msg'] && $row['id_last_msg'] == $row['myid_last_msg'] && $row['approved'] == $row['firstmsg_approved']) {
660
+									return false;
661
+				}
654 662
 
655
-				if ($row['id_first_msg'] != $row['myid_first_msg'])
656
-					$context['repair_errors'][] = sprintf($txt['repair_stats_topics_1'], $row['id_topic'], $row['id_first_msg']);
657
-				if ($row['id_last_msg'] != $row['myid_last_msg'])
658
-					$context['repair_errors'][] = sprintf($txt['repair_stats_topics_2'], $row['id_topic'], $row['id_last_msg']);
659
-				if ($row['approved'] != $row['firstmsg_approved'])
660
-					$context['repair_errors'][] = sprintf($txt['repair_stats_topics_5'], $row['id_topic']);
663
+				if ($row['id_first_msg'] != $row['myid_first_msg']) {
664
+									$context['repair_errors'][] = sprintf($txt['repair_stats_topics_1'], $row['id_topic'], $row['id_first_msg']);
665
+				}
666
+				if ($row['id_last_msg'] != $row['myid_last_msg']) {
667
+									$context['repair_errors'][] = sprintf($txt['repair_stats_topics_2'], $row['id_topic'], $row['id_last_msg']);
668
+				}
669
+				if ($row['approved'] != $row['firstmsg_approved']) {
670
+									$context['repair_errors'][] = sprintf($txt['repair_stats_topics_5'], $row['id_topic']);
671
+				}
661 672
 
662 673
 				return true;
663 674
 			},
@@ -686,8 +697,9 @@  discard block
 block discarded – undo
686 697
 				$row['my_num_replies'] = (int) $row['my_num_replies'];
687 698
 
688 699
 				// Not really a problem?
689
-				if ($row['my_num_replies'] == $row['num_replies'])
690
-					return false;
700
+				if ($row['my_num_replies'] == $row['num_replies']) {
701
+									return false;
702
+				}
691 703
 
692 704
 				$smcFunc['db_query']('', '
693 705
 					UPDATE {db_prefix}topics
@@ -704,11 +716,13 @@  discard block
 block discarded – undo
704 716
 				global $txt, $context;
705 717
 
706 718
 				// Just joking?
707
-				if ($row['my_num_replies'] == $row['num_replies'])
708
-					return false;
719
+				if ($row['my_num_replies'] == $row['num_replies']) {
720
+									return false;
721
+				}
709 722
 
710
-				if ($row['num_replies'] != $row['my_num_replies'])
711
-					$context['repair_errors'][] = sprintf($txt['repair_stats_topics_3'], $row['id_topic'], $row['num_replies']);
723
+				if ($row['num_replies'] != $row['my_num_replies']) {
724
+									$context['repair_errors'][] = sprintf($txt['repair_stats_topics_3'], $row['id_topic'], $row['num_replies']);
725
+				}
712 726
 
713 727
 				return true;
714 728
 			},
@@ -1280,8 +1294,9 @@  discard block
 block discarded – undo
1280 1294
 				$inserts = array();
1281 1295
 				while ($row = $smcFunc['db_fetch_assoc']($result))
1282 1296
 				{
1283
-					foreach (text2words($row['subject']) as $word)
1284
-						$inserts[] = array($word, $row['id_topic']);
1297
+					foreach (text2words($row['subject']) as $word) {
1298
+											$inserts[] = array($word, $row['id_topic']);
1299
+					}
1285 1300
 					if (count($inserts) > 500)
1286 1301
 					{
1287 1302
 						$smcFunc['db_insert']('ignore',
@@ -1294,13 +1309,14 @@  discard block
 block discarded – undo
1294 1309
 					}
1295 1310
 				}
1296 1311
 
1297
-				if (!empty($inserts))
1298
-					$smcFunc['db_insert']('ignore',
1312
+				if (!empty($inserts)) {
1313
+									$smcFunc['db_insert']('ignore',
1299 1314
 						'{db_prefix}log_search_subjects',
1300 1315
 						array('word' => 'string', 'id_topic' => 'int'),
1301 1316
 						$inserts,
1302 1317
 						array('word', 'id_topic')
1303 1318
 					);
1319
+				}
1304 1320
 			},
1305 1321
 			'message_function' => function ($row)
1306 1322
 			{
@@ -1559,8 +1575,9 @@  discard block
 block discarded – undo
1559 1575
 		$current_step++;
1560 1576
 
1561 1577
 		// Already done this?
1562
-		if ($_GET['step'] > $current_step)
1563
-			continue;
1578
+		if ($_GET['step'] > $current_step) {
1579
+					continue;
1580
+		}
1564 1581
 
1565 1582
 		// If we're fixing it but it ain't broke why try?
1566 1583
 		if ($do_fix && !in_array($error_type, $to_fix))
@@ -1589,14 +1606,16 @@  discard block
 block discarded – undo
1589 1606
 		while (!$done)
1590 1607
 		{
1591 1608
 			// Make sure there's at least one ID to test.
1592
-			if (isset($test['substeps']) && empty($step_max))
1593
-				break;
1609
+			if (isset($test['substeps']) && empty($step_max)) {
1610
+							break;
1611
+			}
1594 1612
 
1595 1613
 			// What is the testing query (Changes if we are testing or fixing)
1596
-			if (!$do_fix)
1597
-				$test_query = 'check_query';
1598
-			else
1599
-				$test_query = isset($test['fix_query']) ? 'fix_query' : 'check_query';
1614
+			if (!$do_fix) {
1615
+							$test_query = 'check_query';
1616
+			} else {
1617
+							$test_query = isset($test['fix_query']) ? 'fix_query' : 'check_query';
1618
+			}
1600 1619
 
1601 1620
 			// Do the test...
1602 1621
 			$request = $smcFunc['db_query']('',
@@ -1606,10 +1625,11 @@  discard block
 block discarded – undo
1606 1625
 			);
1607 1626
 
1608 1627
 			// Does it need a fix?
1609
-			if (!empty($test['check_type']) && $test['check_type'] == 'count')
1610
-				list ($needs_fix) = $smcFunc['db_fetch_row']($request);
1611
-			else
1612
-				$needs_fix = $smcFunc['db_num_rows']($request);
1628
+			if (!empty($test['check_type']) && $test['check_type'] == 'count') {
1629
+							list ($needs_fix) = $smcFunc['db_fetch_row']($request);
1630
+			} else {
1631
+							$needs_fix = $smcFunc['db_num_rows']($request);
1632
+			}
1613 1633
 
1614 1634
 			$total_queries++;
1615 1635
 
@@ -1621,8 +1641,9 @@  discard block
 block discarded – undo
1621 1641
 					// Assume need to fix.
1622 1642
 					$found_errors = true;
1623 1643
 
1624
-					if (isset($test['message']))
1625
-						$context['repair_errors'][] = $txt[$test['message']];
1644
+					if (isset($test['message'])) {
1645
+											$context['repair_errors'][] = $txt[$test['message']];
1646
+					}
1626 1647
 
1627 1648
 					// One per row!
1628 1649
 					elseif (isset($test['messages']))
@@ -1632,10 +1653,11 @@  discard block
 block discarded – undo
1632 1653
 							$variables = $test['messages'];
1633 1654
 							foreach ($variables as $k => $v)
1634 1655
 							{
1635
-								if ($k == 0 && isset($txt[$v]))
1636
-									$variables[$k] = $txt[$v];
1637
-								elseif ($k > 0 && isset($row[$v]))
1638
-									$variables[$k] = $row[$v];
1656
+								if ($k == 0 && isset($txt[$v])) {
1657
+																	$variables[$k] = $txt[$v];
1658
+								} elseif ($k > 0 && isset($row[$v])) {
1659
+																	$variables[$k] = $row[$v];
1660
+								}
1639 1661
 							}
1640 1662
 							$context['repair_errors'][] = call_user_func_array('sprintf', $variables);
1641 1663
 						}
@@ -1646,13 +1668,15 @@  discard block
 block discarded – undo
1646 1668
 					{
1647 1669
 						// Find out if there are actually errors.
1648 1670
 						$found_errors = false;
1649
-						while ($row = $smcFunc['db_fetch_assoc']($request))
1650
-							$found_errors |= $test['message_function']($row);
1671
+						while ($row = $smcFunc['db_fetch_assoc']($request)) {
1672
+													$found_errors |= $test['message_function']($row);
1673
+						}
1651 1674
 					}
1652 1675
 
1653 1676
 					// Actually have something to fix?
1654
-					if ($found_errors)
1655
-						$to_fix[] = $error_type;
1677
+					if ($found_errors) {
1678
+											$to_fix[] = $error_type;
1679
+					}
1656 1680
 				}
1657 1681
 
1658 1682
 				// We want to fix, we need to fix - so work out what exactly to do!
@@ -1662,8 +1686,9 @@  discard block
 block discarded – undo
1662 1686
 					if (isset($test['fix_collect']))
1663 1687
 					{
1664 1688
 						$ids = array();
1665
-						while ($row = $smcFunc['db_fetch_assoc']($request))
1666
-							$ids[] = $row[$test['fix_collect']['index']];
1689
+						while ($row = $smcFunc['db_fetch_assoc']($request)) {
1690
+													$ids[] = $row[$test['fix_collect']['index']];
1691
+						}
1667 1692
 						if (!empty($ids))
1668 1693
 						{
1669 1694
 							// Fix it!
@@ -1672,30 +1697,34 @@  discard block
 block discarded – undo
1672 1697
 					}
1673 1698
 
1674 1699
 					// Simply executing a fix it query?
1675
-					elseif (isset($test['fix_it_query']))
1676
-						$smcFunc['db_query']('',
1700
+					elseif (isset($test['fix_it_query'])) {
1701
+											$smcFunc['db_query']('',
1677 1702
 							$test['fix_it_query'],
1678 1703
 							array(
1679 1704
 							)
1680 1705
 						);
1706
+					}
1681 1707
 
1682 1708
 					// Do we have some processing to do?
1683 1709
 					elseif (isset($test['fix_processing']))
1684 1710
 					{
1685
-						while ($row = $smcFunc['db_fetch_assoc']($request))
1686
-							$test['fix_processing']($row);
1711
+						while ($row = $smcFunc['db_fetch_assoc']($request)) {
1712
+													$test['fix_processing']($row);
1713
+						}
1687 1714
 					}
1688 1715
 
1689 1716
 					// What about the full set of processing?
1690
-					elseif (isset($test['fix_full_processing']))
1691
-						$test['fix_full_processing']($request);
1717
+					elseif (isset($test['fix_full_processing'])) {
1718
+											$test['fix_full_processing']($request);
1719
+					}
1692 1720
 
1693 1721
 					// Do we have other things we need to fix as a result?
1694 1722
 					if (!empty($test['force_fix']))
1695 1723
 					{
1696
-						foreach ($test['force_fix'] as $item)
1697
-							if (!in_array($item, $to_fix))
1724
+						foreach ($test['force_fix'] as $item) {
1725
+													if (!in_array($item, $to_fix))
1698 1726
 								$to_fix[] = $item;
1727
+						}
1699 1728
 					}
1700 1729
 				}
1701 1730
 			}
@@ -1713,16 +1742,17 @@  discard block
 block discarded – undo
1713 1742
 				if ($_GET['substep'] <= $step_max)
1714 1743
 				{
1715 1744
 					pauseRepairProcess($to_fix, $error_type, $step_max);
1745
+				} else {
1746
+									$done = true;
1716 1747
 				}
1717
-				else
1718
-					$done = true;
1748
+			} else {
1749
+							$done = true;
1719 1750
 			}
1720
-			else
1721
-				$done = true;
1722 1751
 
1723 1752
 			// Don't allow more than 1000 queries at a time.
1724
-			if ($total_queries >= 1000)
1725
-				pauseRepairProcess($to_fix, $error_type, $step_max, true);
1753
+			if ($total_queries >= 1000) {
1754
+							pauseRepairProcess($to_fix, $error_type, $step_max, true);
1755
+			}
1726 1756
 		}
1727 1757
 
1728 1758
 		// Keep going.
@@ -1735,8 +1765,9 @@  discard block
 block discarded – undo
1735 1765
 		if ($do_fix)
1736 1766
 		{
1737 1767
 			$key = array_search($error_type, $to_fix);
1738
-			if ($key !== false && isset($to_fix[$key]))
1739
-				unset($to_fix[$key]);
1768
+			if ($key !== false && isset($to_fix[$key])) {
1769
+							unset($to_fix[$key]);
1770
+			}
1740 1771
 		}
1741 1772
 
1742 1773
 		// Are we done?
@@ -1759,10 +1790,11 @@  discard block
 block discarded – undo
1759 1790
 	static $createOnce = false;
1760 1791
 
1761 1792
 	// Have we already created it?
1762
-	if ($createOnce)
1763
-		return;
1764
-	else
1765
-		$createOnce = true;
1793
+	if ($createOnce) {
1794
+			return;
1795
+	} else {
1796
+			$createOnce = true;
1797
+	}
1766 1798
 
1767 1799
 	// Back to the forum's default language.
1768 1800
 	loadLanguage('Admin', $language);
@@ -1777,8 +1809,9 @@  discard block
 block discarded – undo
1777 1809
 			'cat_name' => $txt['salvaged_category_name'],
1778 1810
 		)
1779 1811
 	);
1780
-	if ($smcFunc['db_num_rows']($result) != 0)
1781
-		list ($salvageCatID) = $smcFunc['db_fetch_row']($result);
1812
+	if ($smcFunc['db_num_rows']($result) != 0) {
1813
+			list ($salvageCatID) = $smcFunc['db_fetch_row']($result);
1814
+	}
1782 1815
 	$smcFunc['db_free_result']($result);
1783 1816
 
1784 1817
 	if (empty($salvageCatID))
@@ -1810,8 +1843,9 @@  discard block
 block discarded – undo
1810 1843
 			'board_name' => $txt['salvaged_board_name'],
1811 1844
 		)
1812 1845
 	);
1813
-	if ($smcFunc['db_num_rows']($result) != 0)
1814
-		list ($salvageBoardID) = $smcFunc['db_fetch_row']($result);
1846
+	if ($smcFunc['db_num_rows']($result) != 0) {
1847
+			list ($salvageBoardID) = $smcFunc['db_fetch_row']($result);
1848
+	}
1815 1849
 	$smcFunc['db_free_result']($result);
1816 1850
 
1817 1851
 	if (empty($salvageBoardID))
Please login to merge, or discard this patch.
Themes/default/Admin.template.php 1 patch
Braces   +182 added lines, -130 removed lines patch added patch discarded remove patch
@@ -61,9 +61,10 @@  discard block
 block discarded – undo
61 61
 										', implode(', ', $context['administrators']);
62 62
 
63 63
 	// If we have lots of admins... don't show them all.
64
-	if (!empty($context['more_admins_link']))
65
-		echo '
64
+	if (!empty($context['more_admins_link'])) {
65
+			echo '
66 66
 										(', $context['more_admins_link'], ')';
67
+	}
67 68
 
68 69
 	echo '
69 70
 									</div><!-- #version_details -->
@@ -80,17 +81,19 @@  discard block
 block discarded – undo
80 81
 		foreach ($area['areas'] as $item_id => $item)
81 82
 		{
82 83
 			// No point showing the 'home' page here, we're already on it!
83
-			if ($area_id == 'forum' && $item_id == 'index')
84
-				continue;
84
+			if ($area_id == 'forum' && $item_id == 'index') {
85
+							continue;
86
+			}
85 87
 
86 88
 			$url = isset($item['url']) ? $item['url'] : $scripturl . '?action=admin;area=' . $item_id . (!empty($context[$context['admin_menu_name']]['extra_parameters']) ? $context[$context['admin_menu_name']]['extra_parameters'] : '');
87 89
 
88
-			if (!empty($item['icon_file']))
89
-				echo '
90
+			if (!empty($item['icon_file'])) {
91
+							echo '
90 92
 							<a href="', $url, '" class="admin_group', !empty($item['inactive']) ? ' inactive' : '', '"><img class="large_admin_menu_icon_file" src="', $item['icon_file'], '" alt="">', $item['label'], '</a>';
91
-			else
92
-				echo '
93
+			} else {
94
+							echo '
93 95
 							<a href="', $url, '"><span class="large_', $item['icon_class'], !empty($item['inactive']) ? ' inactive' : '', '"></span>', $item['label'], '</a>';
96
+			}
94 97
 		}
95 98
 
96 99
 		echo '
@@ -98,10 +101,11 @@  discard block
 block discarded – undo
98 101
 	}
99 102
 
100 103
 	// The below functions include all the scripts needed from the simplemachines.org site. The language and format are passed for internationalization.
101
-	if (empty($modSettings['disable_smf_js']))
102
-		echo '
104
+	if (empty($modSettings['disable_smf_js'])) {
105
+			echo '
103 106
 					<script src="', $scripturl, '?action=viewsmfile;filename=current-version.js"></script>
104 107
 					<script src="', $scripturl, '?action=viewsmfile;filename=latest-news.js"></script>';
108
+	}
105 109
 
106 110
 	// This sets the announcements and current versions themselves ;).
107 111
 	echo '
@@ -178,9 +182,10 @@  discard block
 block discarded – undo
178 182
 							<em>', $version['version'], '</em>';
179 183
 
180 184
 		// more details for this item, show them a link
181
-		if ($context['can_admin'] && isset($version['more']))
182
-			echo
185
+		if ($context['can_admin'] && isset($version['more'])) {
186
+					echo
183 187
 							' <a href="', $scripturl, $version['more'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['version_check_more'], '</a>';
188
+		}
184 189
 		echo '
185 190
 							<br>';
186 191
 	}
@@ -211,21 +216,23 @@  discard block
 block discarded – undo
211 216
 
212 217
 	foreach ($context['credits'] as $section)
213 218
 	{
214
-		if (isset($section['pretext']))
215
-			echo '
219
+		if (isset($section['pretext'])) {
220
+					echo '
216 221
 							<p>', $section['pretext'], '</p>
217 222
 							<hr>';
223
+		}
218 224
 
219 225
 		echo '
220 226
 							<dl>';
221 227
 
222 228
 		foreach ($section['groups'] as $group)
223 229
 		{
224
-			if (isset($group['title']))
225
-				echo '
230
+			if (isset($group['title'])) {
231
+							echo '
226 232
 								<dt>
227 233
 									<strong>', $group['title'], ':</strong>
228 234
 								</dt>';
235
+			}
229 236
 
230 237
 			echo '
231 238
 								<dd>', implode(', ', $group['members']), '</dd>';
@@ -234,10 +241,11 @@  discard block
 block discarded – undo
234 241
 		echo '
235 242
 							</dl>';
236 243
 
237
-		if (isset($section['posttext']))
238
-			echo '
244
+		if (isset($section['posttext'])) {
245
+					echo '
239 246
 							<hr>
240 247
 							<p>', $section['posttext'], '</p>';
248
+		}
241 249
 	}
242 250
 
243 251
 	echo '
@@ -252,9 +260,10 @@  discard block
 block discarded – undo
252 260
 						smfSupportVersions.forum = "', $context['forum_version'], '";';
253 261
 
254 262
 	// Don't worry, none of this is logged, it's just used to give information that might be of use.
255
-	foreach ($context['current_versions'] as $variable => $version)
256
-		echo '
263
+	foreach ($context['current_versions'] as $variable => $version) {
264
+			echo '
257 265
 						smfSupportVersions.', $variable, ' = "', $version['version'], '";';
266
+	}
258 267
 
259 268
 	// Now we just have to include the script and wait ;).
260 269
 	echo '
@@ -350,8 +359,8 @@  discard block
 block discarded – undo
350 359
 								<tbody>';
351 360
 
352 361
 	// Loop through every source file displaying its version - using javascript.
353
-	foreach ($context['file_versions'] as $filename => $version)
354
-		echo '
362
+	foreach ($context['file_versions'] as $filename => $version) {
363
+			echo '
355 364
 									<tr class="windowbg">
356 365
 										<td class="half_table">
357 366
 											', $filename, '
@@ -363,6 +372,7 @@  discard block
 block discarded – undo
363 372
 											<em id="currentSources', $filename, '">??</em>
364 373
 										</td>
365 374
 									</tr>';
375
+	}
366 376
 
367 377
 	// Default template files.
368 378
 	echo '
@@ -388,8 +398,8 @@  discard block
 block discarded – undo
388 398
 							<table id="Default" class="table_grid">
389 399
 								<tbody>';
390 400
 
391
-	foreach ($context['default_template_versions'] as $filename => $version)
392
-		echo '
401
+	foreach ($context['default_template_versions'] as $filename => $version) {
402
+			echo '
393 403
 									<tr class="windowbg">
394 404
 										<td class="half_table">
395 405
 											', $filename, '
@@ -401,6 +411,7 @@  discard block
 block discarded – undo
401 411
 											<em id="currentDefault', $filename, '">??</em>
402 412
 										</td>
403 413
 									</tr>';
414
+	}
404 415
 
405 416
 	// Now the language files...
406 417
 	echo '
@@ -428,8 +439,8 @@  discard block
 block discarded – undo
428 439
 
429 440
 	foreach ($context['default_language_versions'] as $language => $files)
430 441
 	{
431
-		foreach ($files as $filename => $version)
432
-			echo '
442
+		foreach ($files as $filename => $version) {
443
+					echo '
433 444
 									<tr class="windowbg">
434 445
 										<td class="half_table">
435 446
 											', $filename, '.<em>', $language, '</em>.php
@@ -441,6 +452,7 @@  discard block
 block discarded – undo
441 452
 											<em id="current', $filename, '.', $language, '">??</em>
442 453
 										</td>
443 454
 									</tr>';
455
+		}
444 456
 	}
445 457
 
446 458
 	echo '
@@ -470,8 +482,8 @@  discard block
 block discarded – undo
470 482
 							<table id="Templates" class="table_grid">
471 483
 								<tbody>';
472 484
 
473
-		foreach ($context['template_versions'] as $filename => $version)
474
-			echo '
485
+		foreach ($context['template_versions'] as $filename => $version) {
486
+					echo '
475 487
 									<tr class="windowbg">
476 488
 										<td class="half_table">
477 489
 											', $filename, '
@@ -483,6 +495,7 @@  discard block
 block discarded – undo
483 495
 											<em id="currentTemplates', $filename, '">??</em>
484 496
 										</td>
485 497
 									</tr>';
498
+		}
486 499
 
487 500
 		echo '
488 501
 								</tbody>
@@ -512,8 +525,8 @@  discard block
 block discarded – undo
512 525
 							<table id="Tasks" class="table_grid">
513 526
 								<tbody>';
514 527
 
515
-		foreach ($context['tasks_versions'] as $filename => $version)
516
-			echo '
528
+		foreach ($context['tasks_versions'] as $filename => $version) {
529
+					echo '
517 530
 									<tr class="windowbg">
518 531
 										<td class="half_table">
519 532
 											', $filename, '
@@ -525,6 +538,7 @@  discard block
 block discarded – undo
525 538
 											<em id="currentTasks', $filename, '">??</em>
526 539
 										</td>
527 540
 									</tr>';
541
+		}
528 542
 
529 543
 		echo '
530 544
 								</tbody>
@@ -565,9 +579,10 @@  discard block
 block discarded – undo
565 579
 {
566 580
 	global $context, $scripturl, $txt, $modSettings;
567 581
 
568
-	if (!empty($context['saved_successful']))
569
-		echo '
582
+	if (!empty($context['saved_successful'])) {
583
+			echo '
570 584
 					<div class="infobox">', $txt['settings_saved'], '</div>';
585
+	}
571 586
 
572 587
 	// First section is for adding/removing words from the censored list.
573 588
 	echo '
@@ -581,11 +596,12 @@  discard block
 block discarded – undo
581 596
 								<p>', $txt['admin_censored_where'], '</p>';
582 597
 
583 598
 	// Show text boxes for censoring [bad   ] => [good  ].
584
-	foreach ($context['censored_words'] as $vulgar => $proper)
585
-		echo '
599
+	foreach ($context['censored_words'] as $vulgar => $proper) {
600
+			echo '
586 601
 								<div class="block">
587 602
 									<input type="text" name="censor_vulgar[]" value="', $vulgar, '" size="30"> =&gt; <input type="text" name="censor_proper[]" value="', $proper, '" size="30">
588 603
 								</div>';
604
+	}
589 605
 
590 606
 	// Now provide a way to censor more words.
591 607
 	echo '
@@ -658,27 +674,30 @@  discard block
 block discarded – undo
658 674
 						<div class="windowbg">
659 675
 							', $txt['not_done_reason'];
660 676
 
661
-	if (!empty($context['continue_percent']))
662
-		echo '
677
+	if (!empty($context['continue_percent'])) {
678
+			echo '
663 679
 							<div class="progress_bar">
664 680
 								<span>', $context['continue_percent'], '%</span>
665 681
 								<div class="bar" style="width: ', $context['continue_percent'], '%;"></div>
666 682
 							</div>';
683
+	}
667 684
 
668
-	if (!empty($context['substep_enabled']))
669
-		echo '
685
+	if (!empty($context['substep_enabled'])) {
686
+			echo '
670 687
 							<div class="progress_bar progress_blue">
671 688
 								<span>', $context['substep_title'], ' (', $context['substep_continue_percent'], '%)</span>
672 689
 								<div class="bar" style="width: ', $context['substep_continue_percent'], '%;"></div>
673 690
 							</div>';
691
+	}
674 692
 
675 693
 	echo '
676 694
 							<form action="', $scripturl, $context['continue_get_data'], '" method="post" accept-charset="', $context['character_set'], '" name="autoSubmit" id="autoSubmit">';
677 695
 
678 696
 	// Do we have a token?
679
-	if (isset($context['not_done_token']) && isset($context[$context['not_done_token'] . '_token'], $context[$context['not_done_token'] . '_token_var']))
680
-		echo '
697
+	if (isset($context['not_done_token']) && isset($context[$context['not_done_token'] . '_token'], $context[$context['not_done_token'] . '_token_var'])) {
698
+			echo '
681 699
 							<input type="hidden" name="', $context[$context['not_done_token'] . '_token_var'], '" value="', $context[$context['not_done_token'] . '_token'], '">';
700
+	}
682 701
 
683 702
 	echo '
684 703
 								<input type="submit" name="cont" value="', $txt['not_done_continue'], '" class="button">
@@ -711,34 +730,39 @@  discard block
 block discarded – undo
711 730
 {
712 731
 	global $context, $txt, $scripturl;
713 732
 
714
-	if (!empty($context['saved_successful']))
715
-		echo '
733
+	if (!empty($context['saved_successful'])) {
734
+			echo '
716 735
 					<div class="infobox">', $txt['settings_saved'], '</div>';
717
-	elseif (!empty($context['saved_failed']))
718
-		echo '
736
+	} elseif (!empty($context['saved_failed'])) {
737
+			echo '
719 738
 					<div class="errorbox">', sprintf($txt['settings_not_saved'], $context['saved_failed']), '</div>';
739
+	}
720 740
 
721
-	if (!empty($context['settings_pre_javascript']))
722
-		echo '
741
+	if (!empty($context['settings_pre_javascript'])) {
742
+			echo '
723 743
 					<script>', $context['settings_pre_javascript'], '</script>';
744
+	}
724 745
 
725
-	if (!empty($context['settings_insert_above']))
726
-		echo $context['settings_insert_above'];
746
+	if (!empty($context['settings_insert_above'])) {
747
+			echo $context['settings_insert_above'];
748
+	}
727 749
 
728 750
 	echo '
729 751
 						<form id="admin_form_wrapper" action="', $context['post_url'], '" method="post" accept-charset="', $context['character_set'], '"', !empty($context['force_form_onsubmit']) ? ' onsubmit="' . $context['force_form_onsubmit'] . '"' : '', '>';
730 752
 
731 753
 	// Is there a custom title?
732
-	if (isset($context['settings_title']))
733
-		echo '
754
+	if (isset($context['settings_title'])) {
755
+			echo '
734 756
 							<div class="cat_bar">
735 757
 								<h3 class="catbg">', $context['settings_title'], '</h3>
736 758
 							</div>';
759
+	}
737 760
 
738 761
 	// Have we got a message to display?
739
-	if (!empty($context['settings_message']))
740
-		echo '
762
+	if (!empty($context['settings_message'])) {
763
+			echo '
741 764
 							<div class="information">', $context['settings_message'], '</div>';
765
+	}
742 766
 
743 767
 	// Now actually loop through all the variables.
744 768
 	$is_open = false;
@@ -791,8 +815,9 @@  discard block
 block discarded – undo
791 815
 		// Hang about? Are you pulling my leg - a callback?!
792 816
 		if (is_array($config_var) && $config_var['type'] == 'callback')
793 817
 		{
794
-			if (function_exists('template_callback_' . $config_var['name']))
795
-				call_user_func('template_callback_' . $config_var['name']);
818
+			if (function_exists('template_callback_' . $config_var['name'])) {
819
+							call_user_func('template_callback_' . $config_var['name']);
820
+			}
796 821
 
797 822
 			continue;
798 823
 		}
@@ -822,9 +847,10 @@  discard block
 block discarded – undo
822 847
 				$text_types = array('color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time');
823 848
 
824 849
 				// Show the [?] button.
825
-				if ($config_var['help'])
826
-					echo '
850
+				if ($config_var['help']) {
851
+									echo '
827 852
 										<a id="setting_', $config_var['name'], '_help" href="', $scripturl, '?action=helpadmin;help=', $config_var['help'], '" onclick="return reqOverlayDiv(this.href);"><span class="generic_icons help" title="', $txt['help'], '"></span></a> ';
853
+				}
828 854
 
829 855
 				echo '
830 856
 										<a id="setting_', $config_var['name'], '"></a> <span', ($config_var['disabled'] ? ' style="color: #777777;"' : ($config_var['invalid'] ? ' class="error"' : '')), '><label for="', $config_var['name'], '">', $config_var['label'], '</label>', $subtext, ($config_var['type'] == 'password' ? '<br><em>' . $txt['admin_confirm_password'] . '</em>' : ''), '</span>
@@ -833,23 +859,26 @@  discard block
 block discarded – undo
833 859
 										$config_var['preinput'];
834 860
 
835 861
 				// Show a check box.
836
-				if ($config_var['type'] == 'check')
837
-					echo '
862
+				if ($config_var['type'] == 'check') {
863
+									echo '
838 864
 										<input type="checkbox"', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '"', ($config_var['value'] ? ' checked' : ''), ' value="1">';
865
+				}
839 866
 				// Escape (via htmlspecialchars.) the text box.
840
-				elseif ($config_var['type'] == 'password')
841
-					echo '
867
+				elseif ($config_var['type'] == 'password') {
868
+									echo '
842 869
 										<input type="password"', $disabled, $javascript, ' name="', $config_var['name'], '[0]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), ' value="*#fakepass#*" onfocus="this.value = \'\'; this.form.', $config_var['name'], '.disabled = false;"><br>
843 870
 										<input type="password" disabled id="', $config_var['name'], '" name="', $config_var['name'], '[1]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), '>';
871
+				}
844 872
 				// Show a selection box.
845 873
 				elseif ($config_var['type'] == 'select')
846 874
 				{
847 875
 					echo '
848 876
 										<select name="', $config_var['name'], '" id="', $config_var['name'], '" ', $javascript, $disabled, (!empty($config_var['multiple']) ? ' multiple="multiple"' : ''), (!empty($config_var['multiple']) && !empty($config_var['size']) ? ' size="' . $config_var['size'] . '"' : ''), '>';
849 877
 
850
-					foreach ($config_var['data'] as $option)
851
-						echo '
878
+					foreach ($config_var['data'] as $option) {
879
+											echo '
852 880
 											<option value="', $option[0], '"', (!empty($config_var['value']) && ($option[0] == $config_var['value'] || (!empty($config_var['multiple']) && in_array($option[0], $config_var['value']))) ? ' selected' : ''), '>', $option[1], '</option>';
881
+					}
853 882
 					echo '
854 883
 										</select>';
855 884
 				}
@@ -866,16 +895,18 @@  discard block
 block discarded – undo
866 895
 
867 896
 					foreach ($context['board_list'] as $id_cat => $cat)
868 897
 					{
869
-						if (!$first)
870
-							echo '
898
+						if (!$first) {
899
+													echo '
871 900
 											<hr>';
901
+						}
872 902
 						echo '
873 903
 											<strong>', $cat['name'], '</strong>
874 904
 											<ul>';
875 905
 
876
-						foreach ($cat['boards'] as $id_board => $brd)
877
-							echo '
906
+						foreach ($cat['boards'] as $id_board => $brd) {
907
+													echo '
878 908
 												<li><label><input type="checkbox" name="', $config_var['name'], '[', $brd['id'], ']" value="1"', in_array($brd['id'], $config_var['value']) ? ' checked' : '', '> ', $brd['child_level'] > 0 ? str_repeat('&nbsp; &nbsp;', $brd['child_level']) : '', $brd['name'], '</label></li>';
909
+						}
879 910
 
880 911
 						echo '
881 912
 											</ul>';
@@ -885,12 +916,14 @@  discard block
 block discarded – undo
885 916
 										</fieldset>';
886 917
 				}
887 918
 				// Text area?
888
-				elseif ($config_var['type'] == 'large_text')
889
-					echo '
919
+				elseif ($config_var['type'] == 'large_text') {
920
+									echo '
890 921
 										<textarea rows="', (!empty($config_var['size']) ? $config_var['size'] : (!empty($config_var['rows']) ? $config_var['rows'] : 4)), '" cols="', (!empty($config_var['cols']) ? $config_var['cols'] : 30), '" ', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '">', $config_var['value'], '</textarea>';
922
+				}
891 923
 				// Permission group?
892
-				elseif ($config_var['type'] == 'permissions')
893
-					theme_inline_permissions($config_var['name']);
924
+				elseif ($config_var['type'] == 'permissions') {
925
+									theme_inline_permissions($config_var['name']);
926
+				}
894 927
 
895 928
 				// BBC selection?
896 929
 				elseif ($config_var['type'] == 'bbc')
@@ -902,22 +935,24 @@  discard block
 block discarded – undo
902 935
 
903 936
 					foreach ($context['bbc_columns'] as $bbcColumn)
904 937
 					{
905
-						foreach ($bbcColumn as $bbcTag)
906
-							echo '
938
+						foreach ($bbcColumn as $bbcTag) {
939
+													echo '
907 940
 												<li class="list_bbc floatleft">
908 941
 													<input type="checkbox" name="', $config_var['name'], '_enabledTags[]" id="tag_', $config_var['name'], '_', $bbcTag['tag'], '" value="', $bbcTag['tag'], '"', !in_array($bbcTag['tag'], $context['bbc_sections'][$config_var['name']]['disabled']) ? ' checked' : '', '> <label for="tag_', $config_var['name'], '_', $bbcTag['tag'], '">', $bbcTag['tag'], '</label>', $bbcTag['show_help'] ? ' (<a href="' . $scripturl . '?action=helpadmin;help=tag_' . $bbcTag['tag'] . '" onclick="return reqOverlayDiv(this.href);">?</a>)' : '', '
909 942
 												</li>';
943
+						}
910 944
 					}
911 945
 					echo '					</ul>
912 946
 											<input type="checkbox" id="bbc_', $config_var['name'], '_select_all" onclick="invertAll(this, this.form, \'', $config_var['name'], '_enabledTags\');"', $context['bbc_sections'][$config_var['name']]['all_selected'] ? ' checked' : '', '> <label for="bbc_', $config_var['name'], '_select_all"><em>', $txt['bbcTagsToUse_select_all'], '</em></label>
913 947
 										</fieldset>';
914 948
 				}
915 949
 				// A simple message?
916
-				elseif ($config_var['type'] == 'var_message')
917
-					echo '
950
+				elseif ($config_var['type'] == 'var_message') {
951
+									echo '
918 952
 										<div', !empty($config_var['name']) ? ' id="' . $config_var['name'] . '"' : '', '>
919 953
 											', $config_var['var_message'], '
920 954
 										</div>';
955
+				}
921 956
 				// Assume it must be a text box
922 957
 				else
923 958
 				{
@@ -942,61 +977,69 @@  discard block
 block discarded – undo
942 977
 											' . $config_var['postinput'] : '','
943 978
 									</dd>';
944 979
 			}
945
-		}
946
-		else
980
+		} else
947 981
 		{
948 982
 			// Just show a separator.
949
-			if ($config_var == '')
950
-				echo '
983
+			if ($config_var == '') {
984
+							echo '
951 985
 								</dl>
952 986
 								<hr>
953 987
 								<dl class="settings">';
954
-			else
955
-				echo '
988
+			} else {
989
+							echo '
956 990
 									<dd>
957 991
 										<strong>' . $config_var . '</strong>
958 992
 									</dd>';
993
+			}
959 994
 		}
960 995
 	}
961 996
 
962
-	if ($is_open)
963
-		echo '
997
+	if ($is_open) {
998
+			echo '
964 999
 								</dl>';
1000
+	}
965 1001
 
966
-	if (empty($context['settings_save_dont_show']))
967
-		echo '
1002
+	if (empty($context['settings_save_dont_show'])) {
1003
+			echo '
968 1004
 								<input type="submit" value="', $txt['save'], '"', (!empty($context['save_disabled']) ? ' disabled' : ''), (!empty($context['settings_save_onclick']) ? ' onclick="' . $context['settings_save_onclick'] . '"' : ''), ' class="button">';
1005
+	}
969 1006
 
970
-	if ($is_open)
971
-		echo '
1007
+	if ($is_open) {
1008
+			echo '
972 1009
 							</div><!-- .windowbg -->';
1010
+	}
973 1011
 
974 1012
 
975 1013
 	// At least one token has to be used!
976
-	if (isset($context['admin-ssc_token']))
977
-		echo '
1014
+	if (isset($context['admin-ssc_token'])) {
1015
+			echo '
978 1016
 							<input type="hidden" name="', $context['admin-ssc_token_var'], '" value="', $context['admin-ssc_token'], '">';
1017
+	}
979 1018
 
980
-	if (isset($context['admin-dbsc_token']))
981
-		echo '
1019
+	if (isset($context['admin-dbsc_token'])) {
1020
+			echo '
982 1021
 							<input type="hidden" name="', $context['admin-dbsc_token_var'], '" value="', $context['admin-dbsc_token'], '">';
1022
+	}
983 1023
 
984
-	if (isset($context['admin-mp_token']))
985
-		echo '
1024
+	if (isset($context['admin-mp_token'])) {
1025
+			echo '
986 1026
 							<input type="hidden" name="', $context['admin-mp_token_var'], '" value="', $context['admin-mp_token'], '">';
1027
+	}
987 1028
 
988 1029
 	echo '
989 1030
 							<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
990 1031
 						</form>';
991 1032
 
992
-	if (!empty($context['settings_post_javascript']))
993
-		echo '
1033
+	if (!empty($context['settings_post_javascript'])) {
1034
+			echo '
994 1035
 					<script>
995 1036
 						', $context['settings_post_javascript'], '
996 1037
 					</script>';
1038
+	}
997 1039
 
998
-	if (!empty($context['settings_insert_below']))
999
-		echo $context['settings_insert_below'];
1040
+	if (!empty($context['settings_insert_below'])) {
1041
+			echo $context['settings_insert_below'];
1042
+	}
1000 1043
 
1001 1044
 	// We may have added a board listing. If we did, we need to make it work.
1002 1045
 	addInlineJavascript('
@@ -1019,9 +1062,10 @@  discard block
 block discarded – undo
1019 1062
 {
1020 1063
 	global $context, $txt;
1021 1064
 
1022
-	if (!empty($context['saved_successful']))
1023
-		echo '
1065
+	if (!empty($context['saved_successful'])) {
1066
+			echo '
1024 1067
 					<div class="infobox">', $txt['settings_saved'], '</div>';
1068
+	}
1025 1069
 
1026 1070
 	// Standard fields.
1027 1071
 	template_show_list('standard_profile_fields');
@@ -1055,11 +1099,12 @@  discard block
 block discarded – undo
1055 1099
 	{
1056 1100
 		loadLanguage('Errors');
1057 1101
 
1058
-		if (isset($txt['custom_option_' . $_GET['msg']]))
1059
-			echo '
1102
+		if (isset($txt['custom_option_' . $_GET['msg']])) {
1103
+					echo '
1060 1104
 					<div class="errorbox">',
1061 1105
 						$txt['custom_option_' . $_GET['msg']], '
1062 1106
 					</div>';
1107
+		}
1063 1108
 	}
1064 1109
 
1065 1110
 	echo '
@@ -1125,9 +1170,10 @@  discard block
 block discarded – undo
1125 1170
 										<dd>
1126 1171
 											<select name="placement" id="placement">';
1127 1172
 
1128
-	foreach ($context['cust_profile_fields_placement'] as $order => $name)
1129
-		echo '
1173
+	foreach ($context['cust_profile_fields_placement'] as $order => $name) {
1174
+			echo '
1130 1175
 												<option value="', $order, '"', $context['field']['placement'] == $order ? ' selected' : '', '>', $txt['custom_profile_placement_' . $name], '</option>';
1176
+	}
1131 1177
 
1132 1178
 	echo '
1133 1179
 											</select>
@@ -1151,9 +1197,10 @@  discard block
 block discarded – undo
1151 1197
 										<dd>
1152 1198
 											<select name="field_type" id="field_type" onchange="updateInputBoxes();">';
1153 1199
 
1154
-	foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type)
1155
-		echo '
1200
+	foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type) {
1201
+			echo '
1156 1202
 												<option value="', $field_type, '"', $context['field']['type'] == $field_type ? ' selected' : '', '>', $txt['custom_profile_type_' . $field_type], '</option>';
1203
+	}
1157 1204
 
1158 1205
 	echo '
1159 1206
 											</select>
@@ -1185,9 +1232,10 @@  discard block
 block discarded – undo
1185 1232
 										</dt>
1186 1233
 										<dd id="options_dd">';
1187 1234
 
1188
-	foreach ($context['field']['options'] as $k => $option)
1189
-		echo '
1235
+	foreach ($context['field']['options'] as $k => $option) {
1236
+			echo '
1190 1237
 											', $k == 0 ? '' : '<br>', '<input type="radio" name="default_select" value="', $k, '"', $context['field']['default_select'] == $option ? ' checked' : '', '><input type="text" name="select_option[', $k, ']" value="', $option, '">';
1238
+	}
1191 1239
 
1192 1240
 	echo '
1193 1241
 											<span id="addopt"></span>
@@ -1251,9 +1299,10 @@  discard block
 block discarded – undo
1251 1299
 								</fieldset>
1252 1300
 								<input type="submit" name="save" value="', $txt['save'], '" class="button">';
1253 1301
 
1254
-	if ($context['fid'])
1255
-		echo '
1302
+	if ($context['fid']) {
1303
+			echo '
1256 1304
 								<input type="submit" name="delete" value="', $txt['delete'], '" data-confirm="', $txt['custom_edit_delete_sure'], '" class="button you_sure">';
1305
+	}
1257 1306
 
1258 1307
 	echo '
1259 1308
 							</div><!-- .windowbg -->
@@ -1299,8 +1348,7 @@  discard block
 block discarded – undo
1299 1348
 							<p class="centertext">
1300 1349
 								<strong>', $txt['admin_search_results_none'], '</strong>
1301 1350
 							</p>';
1302
-	}
1303
-	else
1351
+	} else
1304 1352
 	{
1305 1353
 		echo '
1306 1354
 							<ol class="search_results">';
@@ -1327,9 +1375,10 @@  discard block
 block discarded – undo
1327 1375
 								<li>
1328 1376
 									<a href="', $result['url'], '"><strong>', $result['name'], '</strong></a> [', isset($txt['admin_search_section_' . $result['type']]) ? $txt['admin_search_section_' . $result['type']] : $result['type'], ']';
1329 1377
 
1330
-				if ($result['help'])
1331
-					echo '
1378
+				if ($result['help']) {
1379
+									echo '
1332 1380
 									<p class="double_height">', $result['help'], '</p>';
1381
+				}
1333 1382
 
1334 1383
 				echo '
1335 1384
 								</li>';
@@ -1369,10 +1418,11 @@  discard block
 block discarded – undo
1369 1418
 									<strong>', $txt['setup_verification_answer'], '</strong>
1370 1419
 								</dd>';
1371 1420
 
1372
-		if (!empty($context['qa_by_lang'][$lang_id]))
1373
-			foreach ($context['qa_by_lang'][$lang_id] as $q_id)
1421
+		if (!empty($context['qa_by_lang'][$lang_id])) {
1422
+					foreach ($context['qa_by_lang'][$lang_id] as $q_id)
1374 1423
 			{
1375 1424
 				$question = $context['question_answers'][$q_id];
1425
+		}
1376 1426
 
1377 1427
 				echo '
1378 1428
 								<dt>
@@ -1380,9 +1430,10 @@  discard block
 block discarded – undo
1380 1430
 								</dt>
1381 1431
 								<dd>';
1382 1432
 
1383
-				foreach ($question['answers'] as $answer)
1384
-					echo '
1433
+				foreach ($question['answers'] as $answer) {
1434
+									echo '
1385 1435
 									<input type="text" name="answer[', $lang_id, '][', $q_id, '][]" value="', $answer, '" size="50" class="verification_answer">';
1436
+				}
1386 1437
 
1387 1438
 				echo '
1388 1439
 									<div class="qa_add_answer"><a href="javascript:void(0);">[ ', $txt['setup_verification_add_answer'], ' ]</a></div>
@@ -1420,11 +1471,12 @@  discard block
 block discarded – undo
1420 1471
 							', $txt['errors_found'], ':
1421 1472
 							<ul>';
1422 1473
 
1423
-			foreach ($context['repair_errors'] as $error)
1424
-				echo '
1474
+			foreach ($context['repair_errors'] as $error) {
1475
+							echo '
1425 1476
 								<li>
1426 1477
 									', $error, '
1427 1478
 								</li>';
1479
+			}
1428 1480
 
1429 1481
 			echo '
1430 1482
 							</ul>
@@ -1434,15 +1486,14 @@  discard block
 block discarded – undo
1434 1486
 							<p class="padding">
1435 1487
 								<strong><a href="', $scripturl, '?action=admin;area=repairboards;fixErrors;', $context['session_var'], '=', $context['session_id'], ';', $context['admin-repairboards_token_var'], '=', $context['admin-repairboards_token'], '">', $txt['yes'], '</a> - <a href="', $scripturl, '?action=admin;area=maintain">', $txt['no'], '</a></strong>
1436 1488
 							</p>';
1437
-		}
1438
-		else
1439
-			echo '
1489
+		} else {
1490
+					echo '
1440 1491
 							<p>', $txt['maintain_no_errors'], '</p>
1441 1492
 							<p class="padding">
1442 1493
 								<a href="', $scripturl, '?action=admin;area=maintain;sa=routine">', $txt['maintain_return'], '</a>
1443 1494
 							</p>';
1444
-	}
1445
-	else
1495
+		}
1496
+	} else
1446 1497
 	{
1447 1498
 		if (!empty($context['redirect_to_recount']))
1448 1499
 		{
@@ -1455,8 +1506,7 @@  discard block
 block discarded – undo
1455 1506
 								<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1456 1507
 								<input type="submit" name="recount" id="recount_now" value="', $txt['errors_recount_now'], '">
1457 1508
 							</form>';
1458
-		}
1459
-		else
1509
+		} else
1460 1510
 		{
1461 1511
 			echo '
1462 1512
 							<p>', $txt['errors_fixed'], '</p>
@@ -1546,9 +1596,10 @@  discard block
 block discarded – undo
1546 1596
 								<tr class="windowbg">
1547 1597
 									<td class="equal_table">', $key, '</td>';
1548 1598
 
1549
-				foreach ($setting as $key_lm => $value)
1550
-					echo '
1599
+				foreach ($setting as $key_lm => $value) {
1600
+									echo '
1551 1601
 									<td class="equal_table">', $value, '</td>';
1602
+				}
1552 1603
 
1553 1604
 				echo '
1554 1605
 								</tr>';
@@ -1608,8 +1659,8 @@  discard block
 block discarded – undo
1608 1659
 {
1609 1660
 	global $context, $txt;
1610 1661
 
1611
-	if ($context['user']['is_admin'])
1612
-		echo '
1662
+	if ($context['user']['is_admin']) {
1663
+			echo '
1613 1664
 								<span class="floatright admin_search">
1614 1665
 									<span class="generic_icons filter centericon"></span>
1615 1666
 									<input type="search" name="search_term" placeholder="', $txt['admin_search'], '">
@@ -1620,6 +1671,7 @@  discard block
 block discarded – undo
1620 1671
 									</select>
1621 1672
 									<input type="submit" name="search_go" id="search_go" value="', $txt['admin_search_go'], '" class="button">
1622 1673
 								</span>';
1623
-}
1674
+	}
1675
+	}
1624 1676
 
1625 1677
 ?>
1626 1678
\ No newline at end of file
Please login to merge, or discard this patch.
Themes/default/MessageIndex.template.php 1 patch
Braces   +103 added lines, -72 removed lines patch added patch discarded remove patch
@@ -18,11 +18,12 @@  discard block
 block discarded – undo
18 18
 	global $context, $settings, $options, $scripturl, $modSettings, $txt;
19 19
 
20 20
 	// Let them know why their message became unapproved.
21
-	if ($context['becomesUnapproved'])
22
-		echo '
21
+	if ($context['becomesUnapproved']) {
22
+			echo '
23 23
 	<div class="noticebox">
24 24
 		', $txt['post_becomesUnapproved'], '
25 25
 	</div>';
26
+	}
26 27
 
27 28
 	if (!empty($context['boards']) && (!empty($options['show_children']) || $context['start'] == 0))
28 29
 	{
@@ -46,17 +47,19 @@  discard block
 block discarded – undo
46 47
 				</a>';
47 48
 
48 49
 			// Has it outstanding posts for approval?
49
-			if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics']))
50
-				echo '
50
+			if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) {
51
+							echo '
51 52
 				<a href="', $scripturl, '?action=moderate;area=postmod;sa=', ($board['unapproved_topics'] > 0 ? 'topics' : 'posts'), ';brd=', $board['id'], ';', $context['session_var'], '=', $context['session_id'], '" title="', sprintf($txt['unapproved_posts'], $board['unapproved_topics'], $board['unapproved_posts']), '" class="moderation_link">(!)</a>';
53
+			}
52 54
 
53 55
 			echo '
54 56
 				<p class="board_description">', $board['description'], '</p>';
55 57
 
56 58
 			// Show the "Moderators: ". Each has name, href, link, and id. (but we're gonna use link_moderators.)
57
-			if (!empty($board['moderators']) || !empty($board['moderator_groups']))
58
-				echo '
59
+			if (!empty($board['moderators']) || !empty($board['moderator_groups'])) {
60
+							echo '
59 61
 				<p class="moderators">', count($board['link_moderators']) === 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $board['link_moderators']), '</p>';
62
+			}
60 63
 
61 64
 			// Show some basic information about the number of posts, etc.
62 65
 			echo '
@@ -67,9 +70,10 @@  discard block
 block discarded – undo
67 70
 			</div>
68 71
 			<div class="lastpost ', !empty($board['last_post']['id']) ? 'lpr_border' : 'hidden', '">';
69 72
 
70
-			if (!empty($board['last_post']['id']))
71
-				echo '
73
+			if (!empty($board['last_post']['id'])) {
74
+							echo '
72 75
 				<p>', $board['last_post']['last_post_message'], '</p>';
76
+			}
73 77
 
74 78
 			echo '
75 79
 			</div>';
@@ -83,14 +87,16 @@  discard block
 block discarded – undo
83 87
 					id, name, description, new (is it new?), topics (#), posts (#), href, link, and last_post. */
84 88
 				foreach ($board['children'] as $child)
85 89
 				{
86
-					if (!$child['is_redirect'])
87
-						$child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')" class="new_posts">' . $txt['new'] . '</a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>';
88
-					else
89
-						$child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . '">' . $child['name'] . '</a>';
90
+					if (!$child['is_redirect']) {
91
+											$child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')" class="new_posts">' . $txt['new'] . '</a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>';
92
+					} else {
93
+											$child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . '">' . $child['name'] . '</a>';
94
+					}
90 95
 
91 96
 					// Has it posts awaiting approval?
92
-					if ($child['can_approve_posts'] && ($child['unapproved_posts'] | $child['unapproved_topics']))
93
-						$child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>';
97
+					if ($child['can_approve_posts'] && ($child['unapproved_posts'] | $child['unapproved_topics'])) {
98
+											$child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>';
99
+					}
94 100
 
95 101
 					$children[] = $child['new'] ? '<span class="strong">' . $child['link'] . '</span>' : '<span>' . $child['link'] . '</span>';
96 102
 				}
@@ -112,11 +118,12 @@  discard block
 block discarded – undo
112 118
 	if (!$context['no_topic_listing'])
113 119
 	{
114 120
 		// Mobile action buttons (top)
115
-		if (!empty($context['normal_buttons']))
116
-		echo '
121
+		if (!empty($context['normal_buttons'])) {
122
+				echo '
117 123
 	<div class="mobile_buttons floatright">
118 124
 		<a class="button mobile_act">', $txt['mobile_action'], '</a>
119 125
 	</div>';
126
+		}
120 127
 
121 128
 		echo '
122 129
 	<div class="pagesection">
@@ -135,13 +142,15 @@  discard block
 block discarded – undo
135 142
 		<h3>', $context['name'], '</h3>
136 143
 		<p>';
137 144
 
138
-			if ($context['description'] != '')
139
-				echo '
145
+			if ($context['description'] != '') {
146
+							echo '
140 147
 			', $context['description'];
148
+			}
141 149
 
142
-			if (!empty($context['moderators']))
143
-				echo '
150
+			if (!empty($context['moderators'])) {
151
+							echo '
144 152
 			', count($context['moderators']) === 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $context['link_moderators']), '.';
153
+			}
145 154
 
146 155
 			echo '
147 156
 		</p>
@@ -149,9 +158,10 @@  discard block
 block discarded – undo
149 158
 		}
150 159
 
151 160
 		// If Quick Moderation is enabled start the form.
152
-		if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics']))
153
-			echo '
161
+		if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) {
162
+					echo '
154 163
 	<form action="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], '" method="post" accept-charset="', $context['character_set'], '" class="clear" name="quickModForm" id="quickModForm">';
164
+		}
155 165
 
156 166
 		echo '
157 167
 		<div id="messageindex">';
@@ -161,11 +171,11 @@  discard block
 block discarded – undo
161 171
 			echo '
162 172
 			<div class="information">';
163 173
 
164
-			if ($settings['display_who_viewing'] == 1)
165
-				echo count($context['view_members']), ' ', count($context['view_members']) === 1 ? $txt['who_member'] : $txt['members'];
166
-
167
-			else
168
-				echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . (empty($context['view_num_hidden']) || $context['can_moderate_forum'] ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')');
174
+			if ($settings['display_who_viewing'] == 1) {
175
+							echo count($context['view_members']), ' ', count($context['view_members']) === 1 ? $txt['who_member'] : $txt['members'];
176
+			} else {
177
+							echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . (empty($context['view_num_hidden']) || $context['can_moderate_forum'] ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')');
178
+			}
169 179
 			echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['guest'] : $txt['guests'], $txt['who_viewing_board'];
170 180
 
171 181
 		echo '
@@ -185,32 +195,36 @@  discard block
 block discarded – undo
185 195
 				<div class="lastpost">', $context['topics_headers']['last_post'], '</div>';
186 196
 
187 197
 			// Show a "select all" box for quick moderation?
188
-			if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1)
189
-				echo '
198
+			if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) {
199
+							echo '
190 200
 				<div class="moderation">
191 201
 					<input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');">
192 202
 				</div>';
203
+			}
193 204
 
194 205
 			// If it's on in "image" mode, don't show anything but the column.
195
-			elseif (!empty($context['can_quick_mod']))
196
-				echo '
206
+			elseif (!empty($context['can_quick_mod'])) {
207
+							echo '
197 208
 				<div class="moderation"></div>';
209
+			}
198 210
 		}
199 211
 
200 212
 		// No topics... just say, "sorry bub".
201
-		else
202
-			echo '
213
+		else {
214
+					echo '
203 215
 				<h3 class="titlebg">', $txt['topic_alert_none'], '</h3>';
216
+		}
204 217
 
205 218
 		echo '
206 219
 			</div><!-- #topic_header -->';
207 220
 
208 221
 		// If this person can approve items and we have some awaiting approval tell them.
209
-		if (!empty($context['unapproved_posts_message']))
210
-			echo '
222
+		if (!empty($context['unapproved_posts_message'])) {
223
+					echo '
211 224
 			<div class="information">
212 225
 				<span class="alert">!</span> ', $context['unapproved_posts_message'], '
213 226
 			</div>';
227
+		}
214 228
 
215 229
 		// Contain the topic list
216 230
 		echo '
@@ -231,25 +245,30 @@  discard block
 block discarded – undo
231 245
 			echo '
232 246
 							<div class="icons floatright">';
233 247
 
234
-			if ($topic['is_watched'])
235
-				echo '
248
+			if ($topic['is_watched']) {
249
+							echo '
236 250
 								<span class="generic_icons watch" title="', $txt['watching_this_topic'], '"></span>';
251
+			}
237 252
 
238
-			if ($topic['is_locked'])
239
-				echo '
253
+			if ($topic['is_locked']) {
254
+							echo '
240 255
 								<span class="generic_icons lock"></span>';
256
+			}
241 257
 
242
-			if ($topic['is_sticky'])
243
-				echo '
258
+			if ($topic['is_sticky']) {
259
+							echo '
244 260
 								<span class="generic_icons sticky"></span>';
261
+			}
245 262
 
246
-			if ($topic['is_redirect'])
247
-				echo '
263
+			if ($topic['is_redirect']) {
264
+							echo '
248 265
 								<span class="generic_icons move"></span>';
266
+			}
249 267
 
250
-			if ($topic['is_poll'])
251
-				echo '
268
+			if ($topic['is_poll']) {
269
+							echo '
252 270
 								<span class="generic_icons poll"></span>';
271
+			}
253 272
 
254 273
 			echo '
255 274
 							</div>';
@@ -281,26 +300,31 @@  discard block
 block discarded – undo
281 300
 				echo '
282 301
 					<div class="moderation">';
283 302
 
284
-				if ($options['display_quick_mod'] == 1)
285
-					echo '
303
+				if ($options['display_quick_mod'] == 1) {
304
+									echo '
286 305
 						<input type="checkbox" name="topics[]" value="', $topic['id'], '">';
287
-				else
306
+				} else
288 307
 				{
289 308
 					// Check permissions on each and show only the ones they are allowed to use.
290
-					if ($topic['quick_mod']['remove'])
291
-						echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=remove;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons delete" title="', $txt['remove_topic'], '"></span></a>';
309
+					if ($topic['quick_mod']['remove']) {
310
+											echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=remove;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons delete" title="', $txt['remove_topic'], '"></span></a>';
311
+					}
292 312
 
293
-					if ($topic['quick_mod']['lock'])
294
-						echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=lock;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons lock" title="', $topic['is_locked'] ? $txt['set_unlock'] : $txt['set_lock'], '"></span></a>';
313
+					if ($topic['quick_mod']['lock']) {
314
+											echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=lock;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons lock" title="', $topic['is_locked'] ? $txt['set_unlock'] : $txt['set_lock'], '"></span></a>';
315
+					}
295 316
 
296
-					if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove'])
297
-						echo '<br>';
317
+					if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) {
318
+											echo '<br>';
319
+					}
298 320
 
299
-					if ($topic['quick_mod']['sticky'])
300
-						echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=sticky;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons sticky" title="', $topic['is_sticky'] ? $txt['set_nonsticky'] : $txt['set_sticky'], '"></span></a>';
321
+					if ($topic['quick_mod']['sticky']) {
322
+											echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=sticky;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons sticky" title="', $topic['is_sticky'] ? $txt['set_nonsticky'] : $txt['set_sticky'], '"></span></a>';
323
+					}
301 324
 
302
-					if ($topic['quick_mod']['move'])
303
-						echo '<a href="', $scripturl, '?action=movetopic;current_board=', $context['current_board'], ';board=', $context['current_board'], '.', $context['start'], ';topic=', $topic['id'], '.0"><span class="generic_icons move" title="', $txt['move_topic'], '"></span></a>';
325
+					if ($topic['quick_mod']['move']) {
326
+											echo '<a href="', $scripturl, '?action=movetopic;current_board=', $context['current_board'], ';board=', $context['current_board'], '.', $context['start'], ';topic=', $topic['id'], '.0"><span class="generic_icons move" title="', $txt['move_topic'], '"></span></a>';
327
+					}
304 328
 				}
305 329
 				echo '
306 330
 					</div><!-- .moderation -->';
@@ -318,18 +342,20 @@  discard block
 block discarded – undo
318 342
 				<select class="qaction" name="qaction"', $context['can_move'] ? ' onchange="this.form.move_to.disabled = (this.options[this.selectedIndex].value != \'move\');"' : '', '>
319 343
 					<option value="">--------</option>';
320 344
 
321
-			foreach ($context['qmod_actions'] as $qmod_action)
322
-				if ($context['can_' . $qmod_action])
345
+			foreach ($context['qmod_actions'] as $qmod_action) {
346
+							if ($context['can_' . $qmod_action])
323 347
 					echo '
324 348
 					<option value="' . $qmod_action . '">' . $txt['quick_mod_' . $qmod_action] . '</option>';
349
+			}
325 350
 
326 351
 			echo '
327 352
 				</select>';
328 353
 
329 354
 			// Show a list of boards they can move the topic to.
330
-			if ($context['can_move'])
331
-				echo '
355
+			if ($context['can_move']) {
356
+							echo '
332 357
 				<span id="quick_mod_jump_to"></span>';
358
+			}
333 359
 
334 360
 			echo '
335 361
 				<input type="submit" value="', $txt['quick_mod_go'], '" onclick="return document.forms.quickModForm.qaction.value != \'\' &amp;&amp; confirm(\'', $txt['quickmod_confirm'], '\');" class="button qaction">
@@ -340,17 +366,19 @@  discard block
 block discarded – undo
340 366
 		</div><!-- #messageindex -->';
341 367
 
342 368
 		// Finish off the form - again.
343
-		if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics']))
344
-			echo '
369
+		if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) {
370
+					echo '
345 371
 		<input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '">
346 372
 	</form>';
373
+		}
347 374
 
348 375
 		// Mobile action buttons (bottom)
349
-		if (!empty($context['normal_buttons']))
350
-		echo '
376
+		if (!empty($context['normal_buttons'])) {
377
+				echo '
351 378
 	<div class="mobile_buttons floatright">
352 379
 		<a class="button mobile_act">', $txt['mobile_action'], '</a>
353 380
 	</div>';
381
+		}
354 382
 
355 383
 		echo '
356 384
 	<div class="pagesection">
@@ -366,8 +394,8 @@  discard block
 block discarded – undo
366 394
 	// Show breadcrumbs at the bottom too.
367 395
 	theme_linktree();
368 396
 
369
-	if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move'])
370
-		echo '
397
+	if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) {
398
+			echo '
371 399
 	<script>
372 400
 		if (typeof(window.XMLHttpRequest) != "undefined")
373 401
 			aJumpTo[aJumpTo.length] = new JumpTo({
@@ -386,6 +414,7 @@  discard block
 block discarded – undo
386 414
 				sCustomName: "move_to"
387 415
 			});
388 416
 	</script>';
417
+	}
389 418
 
390 419
 	// Javascript for inline editing.
391 420
 	echo '
@@ -422,8 +451,8 @@  discard block
 block discarded – undo
422 451
 		<div class="information">
423 452
 			<p class="floatright" id="message_index_jump_to"></p>';
424 453
 
425
-	if (empty($context['no_topic_listing']))
426
-		echo '
454
+	if (empty($context['no_topic_listing'])) {
455
+			echo '
427 456
 			<p class="floatleft">', !empty($modSettings['enableParticipation']) && $context['user']['is_logged'] ? '
428 457
 				<img src="' . $settings['images_url'] . '/icons/profile_sm.png" alt="" class="centericon"> ' . $txt['participation_caption'] . '<br>' : '', '
429 458
 				'. ($modSettings['pollMode'] == '1' ? '<span class="generic_icons poll centericon"></span> ' . $txt['poll'] : '') . '<br>
@@ -433,9 +462,10 @@  discard block
 block discarded – undo
433 462
 				<span class="generic_icons lock centericon"></span> ' . $txt['locked_topic'] . '<br>
434 463
 				<span class="generic_icons sticky centericon"></span> ' . $txt['sticky_topic'] . '<br>
435 464
 			</p>';
465
+	}
436 466
 
437
-	if (!empty($context['jump_to']))
438
-		echo '
467
+	if (!empty($context['jump_to'])) {
468
+			echo '
439 469
 			<script>
440 470
 				if (typeof(window.XMLHttpRequest) != "undefined")
441 471
 					aJumpTo[aJumpTo.length] = new JumpTo({
@@ -451,6 +481,7 @@  discard block
 block discarded – undo
451 481
 						sGoButtonLabel: "', $txt['quick_mod_go'], '"
452 482
 					});
453 483
 			</script>';
484
+	}
454 485
 
455 486
 	echo '
456 487
 			<br class="clear">
Please login to merge, or discard this patch.
Sources/Subs-Post.php 1 patch
Braces   +526 added lines, -393 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
  * Takes a message and parses it, returning nothing.
@@ -31,8 +32,9 @@  discard block
 block discarded – undo
31 32
 	global $user_info, $modSettings, $context, $sourcedir;
32 33
 
33 34
 	// This line makes all languages *theoretically* work even with the wrong charset ;).
34
-	if (empty($context['utf8']))
35
-		$message = preg_replace('~&amp;#(\d{4,5}|[2-9]\d{2,4}|1[2-9]\d);~', '&#$1;', $message);
35
+	if (empty($context['utf8'])) {
36
+			$message = preg_replace('~&amp;#(\d{4,5}|[2-9]\d{2,4}|1[2-9]\d);~', '&#$1;', $message);
37
+	}
36 38
 
37 39
 	// Clean up after nobbc ;).
38 40
 	$message = preg_replace_callback('~\[nobbc\](.+?)\[/nobbc\]~is', function($a)
@@ -47,17 +49,19 @@  discard block
 block discarded – undo
47 49
 	$message = preg_replace('~\.{100,}~', '...', $message);
48 50
 
49 51
 	// Trim off trailing quotes - these often happen by accident.
50
-	while (substr($message, -7) == '[quote]')
51
-		$message = substr($message, 0, -7);
52
-	while (substr($message, 0, 8) == '[/quote]')
53
-		$message = substr($message, 8);
52
+	while (substr($message, -7) == '[quote]') {
53
+			$message = substr($message, 0, -7);
54
+	}
55
+	while (substr($message, 0, 8) == '[/quote]') {
56
+			$message = substr($message, 8);
57
+	}
54 58
 
55 59
 	// Find all code blocks, work out whether we'd be parsing them, then ensure they are all closed.
56 60
 	$in_tag = false;
57 61
 	$had_tag = false;
58 62
 	$codeopen = 0;
59
-	if (preg_match_all('~(\[(/)*code(?:=[^\]]+)?\])~is', $message, $matches))
60
-		foreach ($matches[0] as $index => $dummy)
63
+	if (preg_match_all('~(\[(/)*code(?:=[^\]]+)?\])~is', $message, $matches)) {
64
+			foreach ($matches[0] as $index => $dummy)
61 65
 		{
62 66
 			// Closing?
63 67
 			if (!empty($matches[2][$index]))
@@ -65,6 +69,7 @@  discard block
 block discarded – undo
65 69
 				// If it's closing and we're not in a tag we need to open it...
66 70
 				if (!$in_tag)
67 71
 					$codeopen = true;
72
+	}
68 73
 				// Either way we ain't in one any more.
69 74
 				$in_tag = false;
70 75
 			}
@@ -73,17 +78,20 @@  discard block
 block discarded – undo
73 78
 			{
74 79
 				$had_tag = true;
75 80
 				// If we're in a tag don't do nought!
76
-				if (!$in_tag)
77
-					$in_tag = true;
81
+				if (!$in_tag) {
82
+									$in_tag = true;
83
+				}
78 84
 			}
79 85
 		}
80 86
 
81 87
 	// If we have an open tag, close it.
82
-	if ($in_tag)
83
-		$message .= '[/code]';
88
+	if ($in_tag) {
89
+			$message .= '[/code]';
90
+	}
84 91
 	// Open any ones that need to be open, only if we've never had a tag.
85
-	if ($codeopen && !$had_tag)
86
-		$message = '[code]' . $message;
92
+	if ($codeopen && !$had_tag) {
93
+			$message = '[code]' . $message;
94
+	}
87 95
 
88 96
 	// Replace code BBC with placeholders. We'll restore them at the end.
89 97
 	$parts = preg_split('~(\[/code\]|\[code(?:=[^\]]+)?\])~i', $message, -1, PREG_SPLIT_DELIM_CAPTURE);
@@ -108,23 +116,26 @@  discard block
 block discarded – undo
108 116
 	fixTags($message);
109 117
 
110 118
 	// Replace /me.+?\n with [me=name]dsf[/me]\n.
111
-	if (strpos($user_info['name'], '[') !== false || strpos($user_info['name'], ']') !== false || strpos($user_info['name'], '\'') !== false || strpos($user_info['name'], '"') !== false)
112
-		$message = preg_replace('~(\A|\n)/me(?: |&nbsp;)([^\n]*)(?:\z)?~i', '$1[me=&quot;' . $user_info['name'] . '&quot;]$2[/me]', $message);
113
-	else
114
-		$message = preg_replace('~(\A|\n)/me(?: |&nbsp;)([^\n]*)(?:\z)?~i', '$1[me=' . $user_info['name'] . ']$2[/me]', $message);
119
+	if (strpos($user_info['name'], '[') !== false || strpos($user_info['name'], ']') !== false || strpos($user_info['name'], '\'') !== false || strpos($user_info['name'], '"') !== false) {
120
+			$message = preg_replace('~(\A|\n)/me(?: |&nbsp;)([^\n]*)(?:\z)?~i', '$1[me=&quot;' . $user_info['name'] . '&quot;]$2[/me]', $message);
121
+	} else {
122
+			$message = preg_replace('~(\A|\n)/me(?: |&nbsp;)([^\n]*)(?:\z)?~i', '$1[me=' . $user_info['name'] . ']$2[/me]', $message);
123
+	}
115 124
 
116 125
 	if (!$previewing && strpos($message, '[html]') !== false)
117 126
 	{
118
-		if (allowedTo('admin_forum'))
119
-			$message = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) {
127
+		if (allowedTo('admin_forum')) {
128
+					$message = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) {
120 129
 				return '[html]' . strtr(un_htmlspecialchars($m[1]), array("\n" => '&#13;', '  ' => ' &#32;', '[' => '&#91;', ']' => '&#93;')) . '[/html]';
130
+		}
121 131
 			}, $message);
122 132
 
123 133
 		// We should edit them out, or else if an admin edits the message they will get shown...
124 134
 		else
125 135
 		{
126
-			while (strpos($message, '[html]') !== false)
127
-				$message = preg_replace('~\[[/]?html\]~i', '', $message);
136
+			while (strpos($message, '[html]') !== false) {
137
+							$message = preg_replace('~\[[/]?html\]~i', '', $message);
138
+			}
128 139
 		}
129 140
 	}
130 141
 
@@ -146,10 +157,12 @@  discard block
 block discarded – undo
146 157
 
147 158
 	$list_open = substr_count($message, '[list]') + substr_count($message, '[list ');
148 159
 	$list_close = substr_count($message, '[/list]');
149
-	if ($list_close - $list_open > 0)
150
-		$message = str_repeat('[list]', $list_close - $list_open) . $message;
151
-	if ($list_open - $list_close > 0)
152
-		$message = $message . str_repeat('[/list]', $list_open - $list_close);
160
+	if ($list_close - $list_open > 0) {
161
+			$message = str_repeat('[list]', $list_close - $list_open) . $message;
162
+	}
163
+	if ($list_open - $list_close > 0) {
164
+			$message = $message . str_repeat('[/list]', $list_open - $list_close);
165
+	}
153 166
 
154 167
 	$mistake_fixes = array(
155 168
 		// Find [table]s not followed by [tr].
@@ -198,8 +211,9 @@  discard block
 block discarded – undo
198 211
 	);
199 212
 
200 213
 	// Fix up some use of tables without [tr]s, etc. (it has to be done more than once to catch it all.)
201
-	for ($j = 0; $j < 3; $j++)
202
-		$message = preg_replace(array_keys($mistake_fixes), $mistake_fixes, $message);
214
+	for ($j = 0; $j < 3; $j++) {
215
+			$message = preg_replace(array_keys($mistake_fixes), $mistake_fixes, $message);
216
+	}
203 217
 
204 218
 	// Remove empty bbc from the sections outside the code tags
205 219
 	$allowedEmpty = array(
@@ -210,24 +224,28 @@  discard block
 block discarded – undo
210 224
 	require_once($sourcedir . '/Subs.php');
211 225
 
212 226
 	$alltags = array();
213
-	foreach (($codes = parse_bbc(false)) as $code)
214
-		if (!in_array($code['tag'], $allowedEmpty))
227
+	foreach (($codes = parse_bbc(false)) as $code) {
228
+			if (!in_array($code['tag'], $allowedEmpty))
215 229
 			$alltags[] = $code['tag'];
230
+	}
216 231
 
217 232
 	$alltags_regex = '\b' . implode("\b|\b", array_unique($alltags)) . '\b';
218 233
 
219
-	while (preg_match('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', $message))
220
-		$message = preg_replace('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', '', $message);
234
+	while (preg_match('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', $message)) {
235
+			$message = preg_replace('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', '', $message);
236
+	}
221 237
 
222 238
 	// Restore code blocks
223
-	if (!empty($code_tags))
224
-		$message = str_replace(array_keys($code_tags), array_values($code_tags), $message);
239
+	if (!empty($code_tags)) {
240
+			$message = str_replace(array_keys($code_tags), array_values($code_tags), $message);
241
+	}
225 242
 
226 243
 	// Restore white space entities
227
-	if (!$previewing)
228
-		$message = strtr($message, array('  ' => '&nbsp; ', "\n" => '<br>', $context['utf8'] ? "\xC2\xA0" : "\xA0" => '&nbsp;'));
229
-	else
230
-		$message = strtr($message, array('  ' => '&nbsp; ', $context['utf8'] ? "\xC2\xA0" : "\xA0" => '&nbsp;'));
244
+	if (!$previewing) {
245
+			$message = strtr($message, array('  ' => '&nbsp; ', "\n" => '<br>', $context['utf8'] ? "\xC2\xA0" : "\xA0" => '&nbsp;'));
246
+	} else {
247
+			$message = strtr($message, array('  ' => '&nbsp; ', $context['utf8'] ? "\xC2\xA0" : "\xA0" => '&nbsp;'));
248
+	}
231 249
 
232 250
 	// Now let's quickly clean up things that will slow our parser (which are common in posted code.)
233 251
 	$message = strtr($message, array('[]' => '&#91;]', '[&#039;' => '&#91;&#039;'));
@@ -270,8 +288,9 @@  discard block
 block discarded – undo
270 288
 		return "[time]" . timeformat("$m[1]", false) . "[/time]";
271 289
 	}, $message);
272 290
 
273
-	if (!empty($code_tags))
274
-		$message = str_replace(array_keys($code_tags), array_values($code_tags), $message);
291
+	if (!empty($code_tags)) {
292
+			$message = str_replace(array_keys($code_tags), array_values($code_tags), $message);
293
+	}
275 294
 
276 295
 	// Change breaks back to \n's and &nsbp; back to spaces.
277 296
 	return preg_replace('~<br( /)?' . '>~', "\n", str_replace('&nbsp;', ' ', $message));
@@ -352,8 +371,9 @@  discard block
 block discarded – undo
352 371
 	);
353 372
 
354 373
 	// Fix each type of tag.
355
-	foreach ($fixArray as $param)
356
-		fixTag($message, $param['tag'], $param['protocols'], $param['embeddedUrl'], $param['hasEqualSign'], !empty($param['hasExtra']));
374
+	foreach ($fixArray as $param) {
375
+			fixTag($message, $param['tag'], $param['protocols'], $param['embeddedUrl'], $param['hasEqualSign'], !empty($param['hasExtra']));
376
+	}
357 377
 
358 378
 	// Now fix possible security problems with images loading links automatically...
359 379
 	$message = preg_replace_callback('~(\[img.*?\])(.+?)\[/img\]~is', function($m)
@@ -378,10 +398,11 @@  discard block
 block discarded – undo
378 398
 {
379 399
 	global $boardurl, $scripturl;
380 400
 
381
-	if (preg_match('~^([^:]+://[^/]+)~', $boardurl, $match) != 0)
382
-		$domain_url = $match[1];
383
-	else
384
-		$domain_url = $boardurl . '/';
401
+	if (preg_match('~^([^:]+://[^/]+)~', $boardurl, $match) != 0) {
402
+			$domain_url = $match[1];
403
+	} else {
404
+			$domain_url = $boardurl . '/';
405
+	}
385 406
 
386 407
 	$replaces = array();
387 408
 
@@ -389,11 +410,11 @@  discard block
 block discarded – undo
389 410
 	{
390 411
 		$quoted = preg_match('~\[(' . $myTag . ')=&quot;~', $message);
391 412
 		preg_match_all('~\[(' . $myTag . ')=' . ($quoted ? '&quot;(.*?)&quot;' : '([^\]]*?)') . '\](?:(.+?)\[/(' . $myTag . ')\])?~is', $message, $matches);
413
+	} elseif ($hasEqualSign) {
414
+			preg_match_all('~\[(' . $myTag . ')=([^\]]*?)\](?:(.+?)\[/(' . $myTag . ')\])?~is', $message, $matches);
415
+	} else {
416
+			preg_match_all('~\[(' . $myTag . ($hasExtra ? '(?:[^\]]*?)' : '') . ')\](.+?)\[/(' . $myTag . ')\]~is', $message, $matches);
392 417
 	}
393
-	elseif ($hasEqualSign)
394
-		preg_match_all('~\[(' . $myTag . ')=([^\]]*?)\](?:(.+?)\[/(' . $myTag . ')\])?~is', $message, $matches);
395
-	else
396
-		preg_match_all('~\[(' . $myTag . ($hasExtra ? '(?:[^\]]*?)' : '') . ')\](.+?)\[/(' . $myTag . ')\]~is', $message, $matches);
397 418
 
398 419
 	foreach ($matches[0] as $k => $dummy)
399 420
 	{
@@ -406,49 +427,53 @@  discard block
 block discarded – undo
406 427
 		foreach ($protocols as $protocol)
407 428
 		{
408 429
 			$found = strncasecmp($replace, $protocol . '://', strlen($protocol) + 3) === 0;
409
-			if ($found)
410
-				break;
430
+			if ($found) {
431
+							break;
432
+			}
411 433
 		}
412 434
 
413 435
 		if (!$found && $protocols[0] == 'http')
414 436
 		{
415
-			if (substr($replace, 0, 1) == '/' && substr($replace, 0, 2) != '//')
416
-				$replace = $domain_url . $replace;
417
-			elseif (substr($replace, 0, 1) == '?')
418
-				$replace = $scripturl . $replace;
419
-			elseif (substr($replace, 0, 1) == '#' && $embeddedUrl)
437
+			if (substr($replace, 0, 1) == '/' && substr($replace, 0, 2) != '//') {
438
+							$replace = $domain_url . $replace;
439
+			} elseif (substr($replace, 0, 1) == '?') {
440
+							$replace = $scripturl . $replace;
441
+			} elseif (substr($replace, 0, 1) == '#' && $embeddedUrl)
420 442
 			{
421 443
 				$replace = '#' . preg_replace('~[^A-Za-z0-9_\-#]~', '', substr($replace, 1));
422 444
 				$this_tag = 'iurl';
423 445
 				$this_close = 'iurl';
446
+			} elseif (substr($replace, 0, 2) != '//') {
447
+							$replace = $protocols[0] . '://' . $replace;
424 448
 			}
425
-			elseif (substr($replace, 0, 2) != '//')
426
-				$replace = $protocols[0] . '://' . $replace;
427
-		}
428
-		elseif (!$found && $protocols[0] == 'ftp')
429
-			$replace = $protocols[0] . '://' . preg_replace('~^(?!ftps?)[^:]+://~', '', $replace);
430
-		elseif (!$found)
431
-			$replace = $protocols[0] . '://' . $replace;
432
-
433
-		if ($hasEqualSign && $embeddedUrl)
434
-			$replaces[$matches[0][$k]] = '[' . $this_tag . '=&quot;' . $replace . '&quot;]' . (empty($matches[4][$k]) ? '' : $matches[3][$k] . '[/' . $this_close . ']');
435
-		elseif ($hasEqualSign)
436
-			$replaces['[' . $matches[1][$k] . '=' . $matches[2][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']';
437
-		elseif ($embeddedUrl)
438
-			$replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']' . $matches[2][$k] . '[/' . $this_close . ']';
439
-		else
440
-			$replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . ']' . $replace . '[/' . $this_close . ']';
449
+		} elseif (!$found && $protocols[0] == 'ftp') {
450
+					$replace = $protocols[0] . '://' . preg_replace('~^(?!ftps?)[^:]+://~', '', $replace);
451
+		} elseif (!$found) {
452
+					$replace = $protocols[0] . '://' . $replace;
453
+		}
454
+
455
+		if ($hasEqualSign && $embeddedUrl) {
456
+					$replaces[$matches[0][$k]] = '[' . $this_tag . '=&quot;' . $replace . '&quot;]' . (empty($matches[4][$k]) ? '' : $matches[3][$k] . '[/' . $this_close . ']');
457
+		} elseif ($hasEqualSign) {
458
+					$replaces['[' . $matches[1][$k] . '=' . $matches[2][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']';
459
+		} elseif ($embeddedUrl) {
460
+					$replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']' . $matches[2][$k] . '[/' . $this_close . ']';
461
+		} else {
462
+					$replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . ']' . $replace . '[/' . $this_close . ']';
463
+		}
441 464
 	}
442 465
 
443 466
 	foreach ($replaces as $k => $v)
444 467
 	{
445
-		if ($k == $v)
446
-			unset($replaces[$k]);
468
+		if ($k == $v) {
469
+					unset($replaces[$k]);
470
+		}
447 471
 	}
448 472
 
449
-	if (!empty($replaces))
450
-		$message = strtr($message, $replaces);
451
-}
473
+	if (!empty($replaces)) {
474
+			$message = strtr($message, $replaces);
475
+	}
476
+	}
452 477
 
453 478
 /**
454 479
  * This function sends an email to the specified recipient(s).
@@ -492,8 +517,9 @@  discard block
 block discarded – undo
492 517
 	}
493 518
 
494 519
 	// Nothing left? Nothing else to do
495
-	if (empty($to_array))
496
-		return true;
520
+	if (empty($to_array)) {
521
+			return true;
522
+	}
497 523
 
498 524
 	// Once upon a time, Hotmail could not interpret non-ASCII mails.
499 525
 	// In honour of those days, it's still called the 'hotmail fix'.
@@ -510,15 +536,17 @@  discard block
 block discarded – undo
510 536
 		}
511 537
 
512 538
 		// Call this function recursively for the hotmail addresses.
513
-		if (!empty($hotmail_to))
514
-			$mail_result = sendmail($hotmail_to, $subject, $message, $from, $message_id, $send_html, $priority, true, $is_private);
539
+		if (!empty($hotmail_to)) {
540
+					$mail_result = sendmail($hotmail_to, $subject, $message, $from, $message_id, $send_html, $priority, true, $is_private);
541
+		}
515 542
 
516 543
 		// The remaining addresses no longer need the fix.
517 544
 		$hotmail_fix = false;
518 545
 
519 546
 		// No other addresses left? Return instantly.
520
-		if (empty($to_array))
521
-			return $mail_result;
547
+		if (empty($to_array)) {
548
+					return $mail_result;
549
+		}
522 550
 	}
523 551
 
524 552
 	// Get rid of entities.
@@ -543,13 +571,15 @@  discard block
 block discarded – undo
543 571
 	$headers .= 'Return-Path: ' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . $line_break;
544 572
 	$headers .= 'Date: ' . gmdate('D, d M Y H:i:s') . ' -0000' . $line_break;
545 573
 
546
-	if ($message_id !== null && empty($modSettings['mail_no_message_id']))
547
-		$headers .= 'Message-ID: <' . md5($scripturl . microtime()) . '-' . $message_id . strstr(empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from'], '@') . '>' . $line_break;
574
+	if ($message_id !== null && empty($modSettings['mail_no_message_id'])) {
575
+			$headers .= 'Message-ID: <' . md5($scripturl . microtime()) . '-' . $message_id . strstr(empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from'], '@') . '>' . $line_break;
576
+	}
548 577
 	$headers .= 'X-Mailer: SMF' . $line_break;
549 578
 
550 579
 	// Pass this to the integration before we start modifying the output -- it'll make it easier later.
551
-	if (in_array(false, call_integration_hook('integrate_outgoing_email', array(&$subject, &$message, &$headers, &$to_array)), true))
552
-		return false;
580
+	if (in_array(false, call_integration_hook('integrate_outgoing_email', array(&$subject, &$message, &$headers, &$to_array)), true)) {
581
+			return false;
582
+	}
553 583
 
554 584
 	// Save the original message...
555 585
 	$orig_message = $message;
@@ -598,17 +628,19 @@  discard block
 block discarded – undo
598 628
 	}
599 629
 
600 630
 	// Are we using the mail queue, if so this is where we butt in...
601
-	if ($priority != 0)
602
-		return AddMailQueue(false, $to_array, $subject, $message, $headers, $send_html, $priority, $is_private);
631
+	if ($priority != 0) {
632
+			return AddMailQueue(false, $to_array, $subject, $message, $headers, $send_html, $priority, $is_private);
633
+	}
603 634
 
604 635
 	// If it's a priority mail, send it now - note though that this should NOT be used for sending many at once.
605 636
 	elseif (!empty($modSettings['mail_limit']))
606 637
 	{
607 638
 		list ($last_mail_time, $mails_this_minute) = @explode('|', $modSettings['mail_recent']);
608
-		if (empty($mails_this_minute) || time() > $last_mail_time + 60)
609
-			$new_queue_stat = time() . '|' . 1;
610
-		else
611
-			$new_queue_stat = $last_mail_time . '|' . ((int) $mails_this_minute + 1);
639
+		if (empty($mails_this_minute) || time() > $last_mail_time + 60) {
640
+					$new_queue_stat = time() . '|' . 1;
641
+		} else {
642
+					$new_queue_stat = $last_mail_time . '|' . ((int) $mails_this_minute + 1);
643
+		}
612 644
 
613 645
 		updateSettings(array('mail_recent' => $new_queue_stat));
614 646
 	}
@@ -642,8 +674,7 @@  discard block
 block discarded – undo
642 674
 					log_error(sprintf($txt['mail_send_unable'], $to));
643 675
 					$mail_result = false;
644 676
 				}
645
-			}
646
-			catch(ErrorException $e)
677
+			} catch(ErrorException $e)
647 678
 			{
648 679
 				log_error($e->getMessage(), 'general', $e->getFile(), $e->getLine());
649 680
 				log_error(sprintf($txt['mail_send_unable'], $to));
@@ -653,12 +684,13 @@  discard block
 block discarded – undo
653 684
 
654 685
 			// Wait, wait, I'm still sending here!
655 686
 			@set_time_limit(300);
656
-			if (function_exists('apache_reset_timeout'))
657
-				@apache_reset_timeout();
687
+			if (function_exists('apache_reset_timeout')) {
688
+							@apache_reset_timeout();
689
+			}
658 690
 		}
691
+	} else {
692
+			$mail_result = $mail_result && smtp_mail($to_array, $subject, $message, $headers);
659 693
 	}
660
-	else
661
-		$mail_result = $mail_result && smtp_mail($to_array, $subject, $message, $headers);
662 694
 
663 695
 	// Everything go smoothly?
664 696
 	return $mail_result;
@@ -684,8 +716,9 @@  discard block
 block discarded – undo
684 716
 	static $cur_insert = array();
685 717
 	static $cur_insert_len = 0;
686 718
 
687
-	if ($cur_insert_len == 0)
688
-		$cur_insert = array();
719
+	if ($cur_insert_len == 0) {
720
+			$cur_insert = array();
721
+	}
689 722
 
690 723
 	// If we're flushing, make the final inserts - also if we're near the MySQL length limit!
691 724
 	if (($flush || $cur_insert_len > 800000) && !empty($cur_insert))
@@ -760,8 +793,9 @@  discard block
 block discarded – undo
760 793
 	}
761 794
 
762 795
 	// If they are using SSI there is a good chance obExit will never be called.  So lets be nice and flush it for them.
763
-	if (SMF === 'SSI' || SMF === 'BACKGROUND')
764
-		return AddMailQueue(true);
796
+	if (SMF === 'SSI' || SMF === 'BACKGROUND') {
797
+			return AddMailQueue(true);
798
+	}
765 799
 
766 800
 	return true;
767 801
 }
@@ -792,23 +826,26 @@  discard block
 block discarded – undo
792 826
 		'sent' => array()
793 827
 	);
794 828
 
795
-	if ($from === null)
796
-		$from = array(
829
+	if ($from === null) {
830
+			$from = array(
797 831
 			'id' => $user_info['id'],
798 832
 			'name' => $user_info['name'],
799 833
 			'username' => $user_info['username']
800 834
 		);
835
+	}
801 836
 
802 837
 	// This is the one that will go in their inbox.
803 838
 	$htmlmessage = $smcFunc['htmlspecialchars']($message, ENT_QUOTES);
804 839
 	preparsecode($htmlmessage);
805 840
 	$htmlsubject = strtr($smcFunc['htmlspecialchars']($subject), array("\r" => '', "\n" => '', "\t" => ''));
806
-	if ($smcFunc['strlen']($htmlsubject) > 100)
807
-		$htmlsubject = $smcFunc['substr']($htmlsubject, 0, 100);
841
+	if ($smcFunc['strlen']($htmlsubject) > 100) {
842
+			$htmlsubject = $smcFunc['substr']($htmlsubject, 0, 100);
843
+	}
808 844
 
809 845
 	// Make sure is an array
810
-	if (!is_array($recipients))
811
-		$recipients = array($recipients);
846
+	if (!is_array($recipients)) {
847
+			$recipients = array($recipients);
848
+	}
812 849
 
813 850
 	// Integrated PMs
814 851
 	call_integration_hook('integrate_personal_message', array(&$recipients, &$from, &$subject, &$message));
@@ -836,21 +873,23 @@  discard block
 block discarded – undo
836 873
 				'usernames' => array_keys($usernames),
837 874
 			)
838 875
 		);
839
-		while ($row = $smcFunc['db_fetch_assoc']($request))
840
-			if (isset($usernames[$smcFunc['strtolower']($row['member_name'])]))
876
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
877
+					if (isset($usernames[$smcFunc['strtolower']($row['member_name'])]))
841 878
 				$usernames[$smcFunc['strtolower']($row['member_name'])] = $row['id_member'];
879
+		}
842 880
 		$smcFunc['db_free_result']($request);
843 881
 
844 882
 		// Replace the usernames with IDs. Drop usernames that couldn't be found.
845
-		foreach ($recipients as $rec_type => $rec)
846
-			foreach ($rec as $id => $member)
883
+		foreach ($recipients as $rec_type => $rec) {
884
+					foreach ($rec as $id => $member)
847 885
 			{
848 886
 				if (is_numeric($recipients[$rec_type][$id]))
849 887
 					continue;
888
+		}
850 889
 
851
-				if (!empty($usernames[$member]))
852
-					$recipients[$rec_type][$id] = $usernames[$member];
853
-				else
890
+				if (!empty($usernames[$member])) {
891
+									$recipients[$rec_type][$id] = $usernames[$member];
892
+				} else
854 893
 				{
855 894
 					$log['failed'][$id] = sprintf($txt['pm_error_user_not_found'], $recipients[$rec_type][$id]);
856 895
 					unset($recipients[$rec_type][$id]);
@@ -888,8 +927,9 @@  discard block
 block discarded – undo
888 927
 		$delete = false;
889 928
 		foreach ($criteria as $criterium)
890 929
 		{
891
-			if (($criterium['t'] == 'mid' && $criterium['v'] == $from['id']) || ($criterium['t'] == 'gid' && in_array($criterium['v'], $user_info['groups'])) || ($criterium['t'] == 'sub' && strpos($subject, $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($message, $criterium['v']) !== false))
892
-				$delete = true;
930
+			if (($criterium['t'] == 'mid' && $criterium['v'] == $from['id']) || ($criterium['t'] == 'gid' && in_array($criterium['v'], $user_info['groups'])) || ($criterium['t'] == 'sub' && strpos($subject, $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($message, $criterium['v']) !== false)) {
931
+							$delete = true;
932
+			}
893 933
 			// If we're adding and one criteria don't match then we stop!
894 934
 			elseif (!$row['is_or'])
895 935
 			{
@@ -897,8 +937,9 @@  discard block
 block discarded – undo
897 937
 				break;
898 938
 			}
899 939
 		}
900
-		if ($delete)
901
-			$deletes[$row['id_member']] = 1;
940
+		if ($delete) {
941
+					$deletes[$row['id_member']] = 1;
942
+		}
902 943
 	}
903 944
 	$smcFunc['db_free_result']($request);
904 945
 
@@ -913,8 +954,9 @@  discard block
 block discarded – undo
913 954
 			array(
914 955
 			)
915 956
 		);
916
-		while ($row = $smcFunc['db_fetch_assoc']($request))
917
-			$message_limit_cache[$row['id_group']] = $row['max_messages'];
957
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
958
+					$message_limit_cache[$row['id_group']] = $row['max_messages'];
959
+		}
918 960
 		$smcFunc['db_free_result']($request);
919 961
 	}
920 962
 
@@ -922,8 +964,9 @@  discard block
 block discarded – undo
922 964
 	require_once($sourcedir . '/Subs-Members.php');
923 965
 	$pmReadGroups = groupsAllowedTo('pm_read');
924 966
 
925
-	if (empty($modSettings['permission_enable_deny']))
926
-		$pmReadGroups['denied'] = array();
967
+	if (empty($modSettings['permission_enable_deny'])) {
968
+			$pmReadGroups['denied'] = array();
969
+	}
927 970
 
928 971
 	// Load their alert preferences
929 972
 	require_once($sourcedir . '/Subs-Notify.php');
@@ -955,8 +998,9 @@  discard block
 block discarded – undo
955 998
 	while ($row = $smcFunc['db_fetch_assoc']($request))
956 999
 	{
957 1000
 		// Don't do anything for members to be deleted!
958
-		if (isset($deletes[$row['id_member']]))
959
-			continue;
1001
+		if (isset($deletes[$row['id_member']])) {
1002
+					continue;
1003
+		}
960 1004
 
961 1005
 		// Load the preferences for this member (if any)
962 1006
 		$prefs = !empty($notifyPrefs[$row['id_member']]) ? $notifyPrefs[$row['id_member']] : array();
@@ -977,8 +1021,9 @@  discard block
 block discarded – undo
977 1021
 		{
978 1022
 			foreach ($groups as $id)
979 1023
 			{
980
-				if (isset($message_limit_cache[$id]) && $message_limit != 0 && $message_limit < $message_limit_cache[$id])
981
-					$message_limit = $message_limit_cache[$id];
1024
+				if (isset($message_limit_cache[$id]) && $message_limit != 0 && $message_limit < $message_limit_cache[$id]) {
1025
+									$message_limit = $message_limit_cache[$id];
1026
+				}
982 1027
 			}
983 1028
 
984 1029
 			if ($message_limit > 0 && $message_limit <= $row['instant_messages'])
@@ -1026,8 +1071,9 @@  discard block
 block discarded – undo
1026 1071
 	$smcFunc['db_free_result']($request);
1027 1072
 
1028 1073
 	// Only 'send' the message if there are any recipients left.
1029
-	if (empty($all_to))
1030
-		return $log;
1074
+	if (empty($all_to)) {
1075
+			return $log;
1076
+	}
1031 1077
 
1032 1078
 	// Insert the message itself and then grab the last insert id.
1033 1079
 	$id_pm = $smcFunc['db_insert']('',
@@ -1048,8 +1094,8 @@  discard block
 block discarded – undo
1048 1094
 	if (!empty($id_pm))
1049 1095
 	{
1050 1096
 		// If this is new we need to set it part of it's own conversation.
1051
-		if (empty($pm_head))
1052
-			$smcFunc['db_query']('', '
1097
+		if (empty($pm_head)) {
1098
+					$smcFunc['db_query']('', '
1053 1099
 				UPDATE {db_prefix}personal_messages
1054 1100
 				SET id_pm_head = {int:id_pm_head}
1055 1101
 				WHERE id_pm = {int:id_pm_head}',
@@ -1057,6 +1103,7 @@  discard block
 block discarded – undo
1057 1103
 					'id_pm_head' => $id_pm,
1058 1104
 				)
1059 1105
 			);
1106
+		}
1060 1107
 
1061 1108
 		// Some people think manually deleting personal_messages is fun... it's not. We protect against it though :)
1062 1109
 		$smcFunc['db_query']('', '
@@ -1072,8 +1119,9 @@  discard block
 block discarded – undo
1072 1119
 		foreach ($all_to as $to)
1073 1120
 		{
1074 1121
 			$insertRows[] = array($id_pm, $to, in_array($to, $recipients['bcc']) ? 1 : 0, isset($deletes[$to]) ? 1 : 0, 1);
1075
-			if (!in_array($to, $recipients['bcc']))
1076
-				$to_list[] = $to;
1122
+			if (!in_array($to, $recipients['bcc'])) {
1123
+							$to_list[] = $to;
1124
+			}
1077 1125
 		}
1078 1126
 
1079 1127
 		$smcFunc['db_insert']('insert',
@@ -1091,9 +1139,9 @@  discard block
 block discarded – undo
1091 1139
 	{
1092 1140
 		censorText($message);
1093 1141
 		$message = trim(un_htmlspecialchars(strip_tags(strtr(parse_bbc($smcFunc['htmlspecialchars']($message), false), array('<br>' => "\n", '</div>' => "\n", '</li>' => "\n", '&#91;' => '[', '&#93;' => ']')))));
1142
+	} else {
1143
+			$message = '';
1094 1144
 	}
1095
-	else
1096
-		$message = '';
1097 1145
 
1098 1146
 	$to_names = array();
1099 1147
 	if (count($to_list) > 1)
@@ -1106,8 +1154,9 @@  discard block
 block discarded – undo
1106 1154
 				'to_members' => $to_list,
1107 1155
 			)
1108 1156
 		);
1109
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1110
-			$to_names[] = un_htmlspecialchars($row['real_name']);
1157
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1158
+					$to_names[] = un_htmlspecialchars($row['real_name']);
1159
+		}
1111 1160
 		$smcFunc['db_free_result']($request);
1112 1161
 	}
1113 1162
 	$replacements = array(
@@ -1135,11 +1184,13 @@  discard block
 block discarded – undo
1135 1184
 	loadLanguage('index+PersonalMessage');
1136 1185
 
1137 1186
 	// Add one to their unread and read message counts.
1138
-	foreach ($all_to as $k => $id)
1139
-		if (isset($deletes[$id]))
1187
+	foreach ($all_to as $k => $id) {
1188
+			if (isset($deletes[$id]))
1140 1189
 			unset($all_to[$k]);
1141
-	if (!empty($all_to))
1142
-		updateMemberData($all_to, array('instant_messages' => '+', 'unread_messages' => '+', 'new_pm' => 1));
1190
+	}
1191
+	if (!empty($all_to)) {
1192
+			updateMemberData($all_to, array('instant_messages' => '+', 'unread_messages' => '+', 'new_pm' => 1));
1193
+	}
1143 1194
 
1144 1195
 	return $log;
1145 1196
 }
@@ -1169,15 +1220,17 @@  discard block
 block discarded – undo
1169 1220
 		// Let's, for now, assume there are only &#021;'ish characters.
1170 1221
 		$simple = true;
1171 1222
 
1172
-		foreach ($matches[1] as $entity)
1173
-			if ($entity > 128)
1223
+		foreach ($matches[1] as $entity) {
1224
+					if ($entity > 128)
1174 1225
 				$simple = false;
1226
+		}
1175 1227
 		unset($matches);
1176 1228
 
1177
-		if ($simple)
1178
-			$string = preg_replace_callback('~&#(\d{3,8});~', function($m)
1229
+		if ($simple) {
1230
+					$string = preg_replace_callback('~&#(\d{3,8});~', function($m)
1179 1231
 			{
1180 1232
 				return chr("$m[1]");
1233
+		}
1181 1234
 			}, $string);
1182 1235
 		else
1183 1236
 		{
@@ -1185,8 +1238,9 @@  discard block
 block discarded – undo
1185 1238
 			if (!$context['utf8'] && function_exists('iconv'))
1186 1239
 			{
1187 1240
 				$newstring = @iconv($context['character_set'], 'UTF-8', $string);
1188
-				if ($newstring)
1189
-					$string = $newstring;
1241
+				if ($newstring) {
1242
+									$string = $newstring;
1243
+				}
1190 1244
 			}
1191 1245
 
1192 1246
 			$string = preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $string);
@@ -1202,23 +1256,25 @@  discard block
 block discarded – undo
1202 1256
 		if (!$context['utf8'] && function_exists('iconv'))
1203 1257
 		{
1204 1258
 			$newstring = @iconv($context['character_set'], 'UTF-8', $string);
1205
-			if ($newstring)
1206
-				$string = $newstring;
1259
+			if ($newstring) {
1260
+							$string = $newstring;
1261
+			}
1207 1262
 		}
1208 1263
 
1209 1264
 		$entityConvert = function($m)
1210 1265
 		{
1211 1266
 			$c = $m[1];
1212
-			if (strlen($c) === 1 && ord($c[0]) <= 0x7F)
1213
-				return $c;
1214
-			elseif (strlen($c) === 2 && ord($c[0]) >= 0xC0 && ord($c[0]) <= 0xDF)
1215
-				return "&#" . (((ord($c[0]) ^ 0xC0) << 6) + (ord($c[1]) ^ 0x80)) . ";";
1216
-			elseif (strlen($c) === 3 && ord($c[0]) >= 0xE0 && ord($c[0]) <= 0xEF)
1217
-				return "&#" . (((ord($c[0]) ^ 0xE0) << 12) + ((ord($c[1]) ^ 0x80) << 6) + (ord($c[2]) ^ 0x80)) . ";";
1218
-			elseif (strlen($c) === 4 && ord($c[0]) >= 0xF0 && ord($c[0]) <= 0xF7)
1219
-				return "&#" . (((ord($c[0]) ^ 0xF0) << 18) + ((ord($c[1]) ^ 0x80) << 12) + ((ord($c[2]) ^ 0x80) << 6) + (ord($c[3]) ^ 0x80)) . ";";
1220
-			else
1221
-				return "";
1267
+			if (strlen($c) === 1 && ord($c[0]) <= 0x7F) {
1268
+							return $c;
1269
+			} elseif (strlen($c) === 2 && ord($c[0]) >= 0xC0 && ord($c[0]) <= 0xDF) {
1270
+							return "&#" . (((ord($c[0]) ^ 0xC0) << 6) + (ord($c[1]) ^ 0x80)) . ";";
1271
+			} elseif (strlen($c) === 3 && ord($c[0]) >= 0xE0 && ord($c[0]) <= 0xEF) {
1272
+							return "&#" . (((ord($c[0]) ^ 0xE0) << 12) + ((ord($c[1]) ^ 0x80) << 6) + (ord($c[2]) ^ 0x80)) . ";";
1273
+			} elseif (strlen($c) === 4 && ord($c[0]) >= 0xF0 && ord($c[0]) <= 0xF7) {
1274
+							return "&#" . (((ord($c[0]) ^ 0xF0) << 18) + ((ord($c[1]) ^ 0x80) << 12) + ((ord($c[2]) ^ 0x80) << 6) + (ord($c[3]) ^ 0x80)) . ";";
1275
+			} else {
1276
+							return "";
1277
+			}
1222 1278
 		};
1223 1279
 
1224 1280
 		// Convert all 'special' characters to HTML entities.
@@ -1232,19 +1288,20 @@  discard block
 block discarded – undo
1232 1288
 		$string = base64_encode($string);
1233 1289
 
1234 1290
 		// Show the characterset and the transfer-encoding for header strings.
1235
-		if ($with_charset)
1236
-			$string = '=?' . $charset . '?B?' . $string . '?=';
1291
+		if ($with_charset) {
1292
+					$string = '=?' . $charset . '?B?' . $string . '?=';
1293
+		}
1237 1294
 
1238 1295
 		// Break it up in lines (mail body).
1239
-		else
1240
-			$string = chunk_split($string, 76, $line_break);
1296
+		else {
1297
+					$string = chunk_split($string, 76, $line_break);
1298
+		}
1241 1299
 
1242 1300
 		return array($charset, $string, 'base64');
1301
+	} else {
1302
+			return array($charset, $string, '7bit');
1303
+	}
1243 1304
 	}
1244
-
1245
-	else
1246
-		return array($charset, $string, '7bit');
1247
-}
1248 1305
 
1249 1306
 /**
1250 1307
  * Sends mail, like mail() but over SMTP.
@@ -1268,8 +1325,9 @@  discard block
 block discarded – undo
1268 1325
 	if ($modSettings['mail_type'] == 3 && $modSettings['smtp_username'] != '' && $modSettings['smtp_password'] != '')
1269 1326
 	{
1270 1327
 		$socket = fsockopen($modSettings['smtp_host'], 110, $errno, $errstr, 2);
1271
-		if (!$socket && (substr($modSettings['smtp_host'], 0, 5) == 'smtp.' || substr($modSettings['smtp_host'], 0, 11) == 'ssl://smtp.'))
1272
-			$socket = fsockopen(strtr($modSettings['smtp_host'], array('smtp.' => 'pop.')), 110, $errno, $errstr, 2);
1328
+		if (!$socket && (substr($modSettings['smtp_host'], 0, 5) == 'smtp.' || substr($modSettings['smtp_host'], 0, 11) == 'ssl://smtp.')) {
1329
+					$socket = fsockopen(strtr($modSettings['smtp_host'], array('smtp.' => 'pop.')), 110, $errno, $errstr, 2);
1330
+		}
1273 1331
 
1274 1332
 		if ($socket)
1275 1333
 		{
@@ -1291,11 +1349,13 @@  discard block
 block discarded – undo
1291 1349
 		if (substr($modSettings['smtp_host'], 0, 4) == 'ssl:' && (empty($modSettings['smtp_port']) || $modSettings['smtp_port'] == 25))
1292 1350
 		{
1293 1351
 			// ssl:hostname can cause fsocketopen to fail with a lookup failure, ensure it exists for this test.
1294
-			if (substr($modSettings['smtp_host'], 0, 6) != 'ssl://')
1295
-				$modSettings['smtp_host'] = str_replace('ssl:', 'ss://', $modSettings['smtp_host']);
1352
+			if (substr($modSettings['smtp_host'], 0, 6) != 'ssl://') {
1353
+							$modSettings['smtp_host'] = str_replace('ssl:', 'ss://', $modSettings['smtp_host']);
1354
+			}
1296 1355
 
1297
-			if ($socket = fsockopen($modSettings['smtp_host'], 465, $errno, $errstr, 3))
1298
-				log_error($txt['smtp_port_ssl']);
1356
+			if ($socket = fsockopen($modSettings['smtp_host'], 465, $errno, $errstr, 3)) {
1357
+							log_error($txt['smtp_port_ssl']);
1358
+			}
1299 1359
 		}
1300 1360
 
1301 1361
 		// Unable to connect!  Don't show any error message, but just log one and try to continue anyway.
@@ -1307,20 +1367,23 @@  discard block
 block discarded – undo
1307 1367
 	}
1308 1368
 
1309 1369
 	// Wait for a response of 220, without "-" continuer.
1310
-	if (!server_parse(null, $socket, '220'))
1311
-		return false;
1370
+	if (!server_parse(null, $socket, '220')) {
1371
+			return false;
1372
+	}
1312 1373
 
1313 1374
 	// Try and determine the servers name, fall back to the mail servers if not found
1314 1375
 	$helo = false;
1315
-	if (function_exists('gethostname') && gethostname() !== false)
1316
-		$helo = gethostname();
1317
-	elseif (function_exists('php_uname'))
1318
-		$helo = php_uname('n');
1319
-	elseif (array_key_exists('SERVER_NAME', $_SERVER) && !empty($_SERVER['SERVER_NAME']))
1320
-		$helo = $_SERVER['SERVER_NAME'];
1376
+	if (function_exists('gethostname') && gethostname() !== false) {
1377
+			$helo = gethostname();
1378
+	} elseif (function_exists('php_uname')) {
1379
+			$helo = php_uname('n');
1380
+	} elseif (array_key_exists('SERVER_NAME', $_SERVER) && !empty($_SERVER['SERVER_NAME'])) {
1381
+			$helo = $_SERVER['SERVER_NAME'];
1382
+	}
1321 1383
 
1322
-	if (empty($helo))
1323
-		$helo = $modSettings['smtp_host'];
1384
+	if (empty($helo)) {
1385
+			$helo = $modSettings['smtp_host'];
1386
+	}
1324 1387
 
1325 1388
 	// SMTP = 1, SMTP - STARTTLS = 2
1326 1389
 	if (in_array($modSettings['mail_type'], array(1, 2)) && $modSettings['smtp_username'] != '' && $modSettings['smtp_password'] != '')
@@ -1332,8 +1395,9 @@  discard block
 block discarded – undo
1332 1395
 			if ($modSettings['mail_type'] == 2 && preg_match("~250( |-)STARTTLS~mi", $response))
1333 1396
 			{
1334 1397
 				// Send STARTTLS to enable encryption
1335
-				if (!server_parse('STARTTLS', $socket, '220'))
1336
-					return false;
1398
+				if (!server_parse('STARTTLS', $socket, '220')) {
1399
+									return false;
1400
+				}
1337 1401
 				// Enable the encryption
1338 1402
 				// php 5.6+ fix
1339 1403
 				$crypto_method = STREAM_CRYPTO_METHOD_TLS_CLIENT;
@@ -1344,30 +1408,35 @@  discard block
 block discarded – undo
1344 1408
 					$crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT;
1345 1409
 				}
1346 1410
 
1347
-				if (!@stream_socket_enable_crypto($socket, true, $crypto_method))
1348
-					return false;
1411
+				if (!@stream_socket_enable_crypto($socket, true, $crypto_method)) {
1412
+									return false;
1413
+				}
1349 1414
 				// Send the EHLO command again
1350
-				if (!server_parse('EHLO ' . $helo, $socket, null) == '250')
1351
-					return false;
1415
+				if (!server_parse('EHLO ' . $helo, $socket, null) == '250') {
1416
+									return false;
1417
+				}
1352 1418
 			}
1353 1419
 
1354
-			if (!server_parse('AUTH LOGIN', $socket, '334'))
1355
-				return false;
1420
+			if (!server_parse('AUTH LOGIN', $socket, '334')) {
1421
+							return false;
1422
+			}
1356 1423
 			// Send the username and password, encoded.
1357
-			if (!server_parse(base64_encode($modSettings['smtp_username']), $socket, '334'))
1358
-				return false;
1424
+			if (!server_parse(base64_encode($modSettings['smtp_username']), $socket, '334')) {
1425
+							return false;
1426
+			}
1359 1427
 			// The password is already encoded ;)
1360
-			if (!server_parse($modSettings['smtp_password'], $socket, '235'))
1361
-				return false;
1428
+			if (!server_parse($modSettings['smtp_password'], $socket, '235')) {
1429
+							return false;
1430
+			}
1431
+		} elseif (!server_parse('HELO ' . $helo, $socket, '250')) {
1432
+					return false;
1362 1433
 		}
1363
-		elseif (!server_parse('HELO ' . $helo, $socket, '250'))
1364
-			return false;
1365
-	}
1366
-	else
1434
+	} else
1367 1435
 	{
1368 1436
 		// Just say "helo".
1369
-		if (!server_parse('HELO ' . $helo, $socket, '250'))
1370
-			return false;
1437
+		if (!server_parse('HELO ' . $helo, $socket, '250')) {
1438
+					return false;
1439
+		}
1371 1440
 	}
1372 1441
 
1373 1442
 	// Fix the message for any lines beginning with a period! (the first is ignored, you see.)
@@ -1380,31 +1449,38 @@  discard block
 block discarded – undo
1380 1449
 		// Reset the connection to send another email.
1381 1450
 		if ($i != 0)
1382 1451
 		{
1383
-			if (!server_parse('RSET', $socket, '250'))
1384
-				return false;
1452
+			if (!server_parse('RSET', $socket, '250')) {
1453
+							return false;
1454
+			}
1385 1455
 		}
1386 1456
 
1387 1457
 		// From, to, and then start the data...
1388
-		if (!server_parse('MAIL FROM: <' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . '>', $socket, '250'))
1389
-			return false;
1390
-		if (!server_parse('RCPT TO: <' . $mail_to . '>', $socket, '250'))
1391
-			return false;
1392
-		if (!server_parse('DATA', $socket, '354'))
1393
-			return false;
1458
+		if (!server_parse('MAIL FROM: <' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . '>', $socket, '250')) {
1459
+					return false;
1460
+		}
1461
+		if (!server_parse('RCPT TO: <' . $mail_to . '>', $socket, '250')) {
1462
+					return false;
1463
+		}
1464
+		if (!server_parse('DATA', $socket, '354')) {
1465
+					return false;
1466
+		}
1394 1467
 		fputs($socket, 'Subject: ' . $subject . "\r\n");
1395
-		if (strlen($mail_to) > 0)
1396
-			fputs($socket, 'To: <' . $mail_to . '>' . "\r\n");
1468
+		if (strlen($mail_to) > 0) {
1469
+					fputs($socket, 'To: <' . $mail_to . '>' . "\r\n");
1470
+		}
1397 1471
 		fputs($socket, $headers . "\r\n\r\n");
1398 1472
 		fputs($socket, $message . "\r\n");
1399 1473
 
1400 1474
 		// Send a ., or in other words "end of data".
1401
-		if (!server_parse('.', $socket, '250'))
1402
-			return false;
1475
+		if (!server_parse('.', $socket, '250')) {
1476
+					return false;
1477
+		}
1403 1478
 
1404 1479
 		// Almost done, almost done... don't stop me just yet!
1405 1480
 		@set_time_limit(300);
1406
-		if (function_exists('apache_reset_timeout'))
1407
-			@apache_reset_timeout();
1481
+		if (function_exists('apache_reset_timeout')) {
1482
+					@apache_reset_timeout();
1483
+		}
1408 1484
 	}
1409 1485
 	fputs($socket, 'QUIT' . "\r\n");
1410 1486
 	fclose($socket);
@@ -1428,8 +1504,9 @@  discard block
 block discarded – undo
1428 1504
 {
1429 1505
 	global $txt;
1430 1506
 
1431
-	if ($message !== null)
1432
-		fputs($socket, $message . "\r\n");
1507
+	if ($message !== null) {
1508
+			fputs($socket, $message . "\r\n");
1509
+	}
1433 1510
 
1434 1511
 	// No response yet.
1435 1512
 	$server_response = '';
@@ -1445,8 +1522,9 @@  discard block
 block discarded – undo
1445 1522
 		$response .= $server_response;
1446 1523
 	}
1447 1524
 
1448
-	if ($code === null)
1449
-		return substr($server_response, 0, 3);
1525
+	if ($code === null) {
1526
+			return substr($server_response, 0, 3);
1527
+	}
1450 1528
 
1451 1529
 	if (substr($server_response, 0, 3) != $code)
1452 1530
 	{
@@ -1476,8 +1554,9 @@  discard block
 block discarded – undo
1476 1554
 	// Create a pspell or enchant dictionary resource
1477 1555
 	$dict = spell_init();
1478 1556
 
1479
-	if (!isset($_POST['spellstring']) || !$dict)
1480
-		die;
1557
+	if (!isset($_POST['spellstring']) || !$dict) {
1558
+			die;
1559
+	}
1481 1560
 
1482 1561
 	// Construct a bit of Javascript code.
1483 1562
 	$context['spell_js'] = '
@@ -1495,8 +1574,9 @@  discard block
 block discarded – undo
1495 1574
 		$check_word = explode('|', $alphas[$i]);
1496 1575
 
1497 1576
 		// If the word is a known word, or spelled right...
1498
-		if (in_array($smcFunc['strtolower']($check_word[0]), $known_words) || spell_check($dict, $check_word[0]) || !isset($check_word[2]))
1499
-			continue;
1577
+		if (in_array($smcFunc['strtolower']($check_word[0]), $known_words) || spell_check($dict, $check_word[0]) || !isset($check_word[2])) {
1578
+					continue;
1579
+		}
1500 1580
 
1501 1581
 		// Find the word, and move up the "last occurrence" to here.
1502 1582
 		$found_words = true;
@@ -1510,20 +1590,23 @@  discard block
 block discarded – undo
1510 1590
 		if (!empty($suggestions))
1511 1591
 		{
1512 1592
 			// But first check they aren't going to be censored - no naughty words!
1513
-			foreach ($suggestions as $k => $word)
1514
-				if ($suggestions[$k] != censorText($word))
1593
+			foreach ($suggestions as $k => $word) {
1594
+							if ($suggestions[$k] != censorText($word))
1515 1595
 					unset($suggestions[$k]);
1596
+			}
1516 1597
 
1517
-			if (!empty($suggestions))
1518
-				$context['spell_js'] .= '"' . implode('", "', $suggestions) . '"';
1598
+			if (!empty($suggestions)) {
1599
+							$context['spell_js'] .= '"' . implode('", "', $suggestions) . '"';
1600
+			}
1519 1601
 		}
1520 1602
 
1521 1603
 		$context['spell_js'] .= ']),';
1522 1604
 	}
1523 1605
 
1524 1606
 	// If words were found, take off the last comma.
1525
-	if ($found_words)
1526
-		$context['spell_js'] = substr($context['spell_js'], 0, -1);
1607
+	if ($found_words) {
1608
+			$context['spell_js'] = substr($context['spell_js'], 0, -1);
1609
+	}
1527 1610
 
1528 1611
 	$context['spell_js'] .= '
1529 1612
 		);';
@@ -1558,11 +1641,13 @@  discard block
 block discarded – undo
1558 1641
 	global $user_info, $smcFunc;
1559 1642
 
1560 1643
 	// Can't do it if there's no topics.
1561
-	if (empty($topics))
1562
-		return;
1644
+	if (empty($topics)) {
1645
+			return;
1646
+	}
1563 1647
 	// It must be an array - it must!
1564
-	if (!is_array($topics))
1565
-		$topics = array($topics);
1648
+	if (!is_array($topics)) {
1649
+			$topics = array($topics);
1650
+	}
1566 1651
 
1567 1652
 	// Get the subject and body...
1568 1653
 	$result = $smcFunc['db_query']('', '
@@ -1610,14 +1695,15 @@  discard block
 block discarded – undo
1610 1695
 	}
1611 1696
 	$smcFunc['db_free_result']($result);
1612 1697
 
1613
-	if (!empty($task_rows))
1614
-		$smcFunc['db_insert']('',
1698
+	if (!empty($task_rows)) {
1699
+			$smcFunc['db_insert']('',
1615 1700
 			'{db_prefix}background_tasks',
1616 1701
 			array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'),
1617 1702
 			$task_rows,
1618 1703
 			array('id_task')
1619 1704
 		);
1620
-}
1705
+	}
1706
+	}
1621 1707
 
1622 1708
 /**
1623 1709
  * Create a post, either as new topic (id_topic = 0) or in an existing one.
@@ -1655,9 +1741,9 @@  discard block
 block discarded – undo
1655 1741
 	$msgOptions['send_notifications'] = isset($msgOptions['send_notifications']) ? (bool) $msgOptions['send_notifications'] : true;
1656 1742
 
1657 1743
 	// We need to know if the topic is approved. If we're told that's great - if not find out.
1658
-	if (!$modSettings['postmod_active'])
1659
-		$topicOptions['is_approved'] = true;
1660
-	elseif (!empty($topicOptions['id']) && !isset($topicOptions['is_approved']))
1744
+	if (!$modSettings['postmod_active']) {
1745
+			$topicOptions['is_approved'] = true;
1746
+	} elseif (!empty($topicOptions['id']) && !isset($topicOptions['is_approved']))
1661 1747
 	{
1662 1748
 		$request = $smcFunc['db_query']('', '
1663 1749
 			SELECT approved
@@ -1680,8 +1766,7 @@  discard block
 block discarded – undo
1680 1766
 			$posterOptions['id'] = 0;
1681 1767
 			$posterOptions['name'] = $txt['guest_title'];
1682 1768
 			$posterOptions['email'] = '';
1683
-		}
1684
-		elseif ($posterOptions['id'] != $user_info['id'])
1769
+		} elseif ($posterOptions['id'] != $user_info['id'])
1685 1770
 		{
1686 1771
 			$request = $smcFunc['db_query']('', '
1687 1772
 				SELECT member_name, email_address
@@ -1699,12 +1784,11 @@  discard block
 block discarded – undo
1699 1784
 				$posterOptions['id'] = 0;
1700 1785
 				$posterOptions['name'] = $txt['guest_title'];
1701 1786
 				$posterOptions['email'] = '';
1787
+			} else {
1788
+							list ($posterOptions['name'], $posterOptions['email']) = $smcFunc['db_fetch_row']($request);
1702 1789
 			}
1703
-			else
1704
-				list ($posterOptions['name'], $posterOptions['email']) = $smcFunc['db_fetch_row']($request);
1705 1790
 			$smcFunc['db_free_result']($request);
1706
-		}
1707
-		else
1791
+		} else
1708 1792
 		{
1709 1793
 			$posterOptions['name'] = $user_info['name'];
1710 1794
 			$posterOptions['email'] = $user_info['email'];
@@ -1714,8 +1798,9 @@  discard block
 block discarded – undo
1714 1798
 	if (!empty($modSettings['enable_mentions']))
1715 1799
 	{
1716 1800
 		$msgOptions['mentioned_members'] = Mentions::getMentionedMembers($msgOptions['body']);
1717
-		if (!empty($msgOptions['mentioned_members']))
1718
-			$msgOptions['body'] = Mentions::getBody($msgOptions['body'], $msgOptions['mentioned_members']);
1801
+		if (!empty($msgOptions['mentioned_members'])) {
1802
+					$msgOptions['body'] = Mentions::getBody($msgOptions['body'], $msgOptions['mentioned_members']);
1803
+		}
1719 1804
 	}
1720 1805
 
1721 1806
 	// It's do or die time: forget any user aborts!
@@ -1748,12 +1833,13 @@  discard block
 block discarded – undo
1748 1833
 	);
1749 1834
 
1750 1835
 	// Something went wrong creating the message...
1751
-	if (empty($msgOptions['id']))
1752
-		return false;
1836
+	if (empty($msgOptions['id'])) {
1837
+			return false;
1838
+	}
1753 1839
 
1754 1840
 	// Fix the attachments.
1755
-	if (!empty($msgOptions['attachments']))
1756
-		$smcFunc['db_query']('', '
1841
+	if (!empty($msgOptions['attachments'])) {
1842
+			$smcFunc['db_query']('', '
1757 1843
 			UPDATE {db_prefix}attachments
1758 1844
 			SET id_msg = {int:id_msg}
1759 1845
 			WHERE id_attach IN ({array_int:attachment_list})',
@@ -1762,6 +1848,7 @@  discard block
 block discarded – undo
1762 1848
 				'id_msg' => $msgOptions['id'],
1763 1849
 			)
1764 1850
 		);
1851
+	}
1765 1852
 
1766 1853
 	// What if we want to export new posts out to a CMS?
1767 1854
 	call_integration_hook('integrate_after_create_post', array($msgOptions, $topicOptions, $posterOptions, $message_columns, $message_parameters));
@@ -1838,20 +1925,23 @@  discard block
 block discarded – undo
1838 1925
 			'id_topic' => $topicOptions['id'],
1839 1926
 			'counter_increment' => 1,
1840 1927
 		);
1841
-		if ($msgOptions['approved'])
1842
-			$topics_columns = array(
1928
+		if ($msgOptions['approved']) {
1929
+					$topics_columns = array(
1843 1930
 				'id_member_updated = {int:poster_id}',
1844 1931
 				'id_last_msg = {int:id_msg}',
1845 1932
 				'num_replies = num_replies + {int:counter_increment}',
1846 1933
 			);
1847
-		else
1848
-			$topics_columns = array(
1934
+		} else {
1935
+					$topics_columns = array(
1849 1936
 				'unapproved_posts = unapproved_posts + {int:counter_increment}',
1850 1937
 			);
1851
-		if ($topicOptions['lock_mode'] !== null)
1852
-			$topics_columns[] = 'locked = {int:locked}';
1853
-		if ($topicOptions['sticky_mode'] !== null)
1854
-			$topics_columns[] = 'is_sticky = {int:is_sticky}';
1938
+		}
1939
+		if ($topicOptions['lock_mode'] !== null) {
1940
+					$topics_columns[] = 'locked = {int:locked}';
1941
+		}
1942
+		if ($topicOptions['sticky_mode'] !== null) {
1943
+					$topics_columns[] = 'is_sticky = {int:is_sticky}';
1944
+		}
1855 1945
 
1856 1946
 		call_integration_hook('integrate_modify_topic', array(&$topics_columns, &$update_parameters, &$msgOptions, &$topicOptions, &$posterOptions));
1857 1947
 
@@ -1880,8 +1970,8 @@  discard block
 block discarded – undo
1880 1970
 	);
1881 1971
 
1882 1972
 	// Increase the number of posts and topics on the board.
1883
-	if ($msgOptions['approved'])
1884
-		$smcFunc['db_query']('', '
1973
+	if ($msgOptions['approved']) {
1974
+			$smcFunc['db_query']('', '
1885 1975
 			UPDATE {db_prefix}boards
1886 1976
 			SET num_posts = num_posts + 1' . ($new_topic ? ', num_topics = num_topics + 1' : '') . '
1887 1977
 			WHERE id_board = {int:id_board}',
@@ -1889,7 +1979,7 @@  discard block
 block discarded – undo
1889 1979
 				'id_board' => $topicOptions['board'],
1890 1980
 			)
1891 1981
 		);
1892
-	else
1982
+	} else
1893 1983
 	{
1894 1984
 		$smcFunc['db_query']('', '
1895 1985
 			UPDATE {db_prefix}boards
@@ -1959,8 +2049,8 @@  discard block
 block discarded – undo
1959 2049
 		}
1960 2050
 	}
1961 2051
 
1962
-	if ($msgOptions['approved'] && empty($topicOptions['is_approved']))
1963
-		$smcFunc['db_insert']('',
2052
+	if ($msgOptions['approved'] && empty($topicOptions['is_approved'])) {
2053
+			$smcFunc['db_insert']('',
1964 2054
 			'{db_prefix}background_tasks',
1965 2055
 			array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'),
1966 2056
 			array(
@@ -1972,19 +2062,22 @@  discard block
 block discarded – undo
1972 2062
 			),
1973 2063
 			array('id_task')
1974 2064
 		);
2065
+	}
1975 2066
 
1976 2067
 	// If there's a custom search index, it may need updating...
1977 2068
 	require_once($sourcedir . '/Search.php');
1978 2069
 	$searchAPI = findSearchAPI();
1979
-	if (is_callable(array($searchAPI, 'postCreated')))
1980
-		$searchAPI->postCreated($msgOptions, $topicOptions, $posterOptions);
2070
+	if (is_callable(array($searchAPI, 'postCreated'))) {
2071
+			$searchAPI->postCreated($msgOptions, $topicOptions, $posterOptions);
2072
+	}
1981 2073
 
1982 2074
 	// Increase the post counter for the user that created the post.
1983 2075
 	if (!empty($posterOptions['update_post_count']) && !empty($posterOptions['id']) && $msgOptions['approved'])
1984 2076
 	{
1985 2077
 		// Are you the one that happened to create this post?
1986
-		if ($user_info['id'] == $posterOptions['id'])
1987
-			$user_info['posts']++;
2078
+		if ($user_info['id'] == $posterOptions['id']) {
2079
+					$user_info['posts']++;
2080
+		}
1988 2081
 		updateMemberData($posterOptions['id'], array('posts' => '+'));
1989 2082
 	}
1990 2083
 
@@ -1992,19 +2085,21 @@  discard block
 block discarded – undo
1992 2085
 	$_SESSION['last_read_topic'] = 0;
1993 2086
 
1994 2087
 	// Better safe than sorry.
1995
-	if (isset($_SESSION['topicseen_cache'][$topicOptions['board']]))
1996
-		$_SESSION['topicseen_cache'][$topicOptions['board']]--;
2088
+	if (isset($_SESSION['topicseen_cache'][$topicOptions['board']])) {
2089
+			$_SESSION['topicseen_cache'][$topicOptions['board']]--;
2090
+	}
1997 2091
 
1998 2092
 	// Update all the stats so everyone knows about this new topic and message.
1999 2093
 	updateStats('message', true, $msgOptions['id']);
2000 2094
 
2001 2095
 	// Update the last message on the board assuming it's approved AND the topic is.
2002
-	if ($msgOptions['approved'])
2003
-		updateLastMessages($topicOptions['board'], $new_topic || !empty($topicOptions['is_approved']) ? $msgOptions['id'] : 0);
2096
+	if ($msgOptions['approved']) {
2097
+			updateLastMessages($topicOptions['board'], $new_topic || !empty($topicOptions['is_approved']) ? $msgOptions['id'] : 0);
2098
+	}
2004 2099
 
2005 2100
 	// Queue createPost background notification
2006
-	if ($msgOptions['send_notifications'] && $msgOptions['approved'])
2007
-		$smcFunc['db_insert']('',
2101
+	if ($msgOptions['send_notifications'] && $msgOptions['approved']) {
2102
+			$smcFunc['db_insert']('',
2008 2103
 			'{db_prefix}background_tasks',
2009 2104
 			array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'),
2010 2105
 			array('$sourcedir/tasks/CreatePost-Notify.php', 'CreatePost_Notify_Background', $smcFunc['json_encode'](array(
@@ -2015,6 +2110,7 @@  discard block
 block discarded – undo
2015 2110
 			)), 0),
2016 2111
 			array('id_task')
2017 2112
 		);
2113
+	}
2018 2114
 
2019 2115
 	// Alright, done now... we can abort now, I guess... at least this much is done.
2020 2116
 	ignore_user_abort($previous_ignore_user_abort);
@@ -2041,14 +2137,18 @@  discard block
 block discarded – undo
2041 2137
 
2042 2138
 	// This is longer than it has to be, but makes it so we only set/change what we have to.
2043 2139
 	$messages_columns = array();
2044
-	if (isset($posterOptions['name']))
2045
-		$messages_columns['poster_name'] = $posterOptions['name'];
2046
-	if (isset($posterOptions['email']))
2047
-		$messages_columns['poster_email'] = $posterOptions['email'];
2048
-	if (isset($msgOptions['icon']))
2049
-		$messages_columns['icon'] = $msgOptions['icon'];
2050
-	if (isset($msgOptions['subject']))
2051
-		$messages_columns['subject'] = $msgOptions['subject'];
2140
+	if (isset($posterOptions['name'])) {
2141
+			$messages_columns['poster_name'] = $posterOptions['name'];
2142
+	}
2143
+	if (isset($posterOptions['email'])) {
2144
+			$messages_columns['poster_email'] = $posterOptions['email'];
2145
+	}
2146
+	if (isset($msgOptions['icon'])) {
2147
+			$messages_columns['icon'] = $msgOptions['icon'];
2148
+	}
2149
+	if (isset($msgOptions['subject'])) {
2150
+			$messages_columns['subject'] = $msgOptions['subject'];
2151
+	}
2052 2152
 	if (isset($msgOptions['body']))
2053 2153
 	{
2054 2154
 		$messages_columns['body'] = $msgOptions['body'];
@@ -2075,8 +2175,9 @@  discard block
 block discarded – undo
2075 2175
 		$messages_columns['modified_reason'] = $msgOptions['modify_reason'];
2076 2176
 		$messages_columns['id_msg_modified'] = $modSettings['maxMsgID'];
2077 2177
 	}
2078
-	if (isset($msgOptions['smileys_enabled']))
2079
-		$messages_columns['smileys_enabled'] = empty($msgOptions['smileys_enabled']) ? 0 : 1;
2178
+	if (isset($msgOptions['smileys_enabled'])) {
2179
+			$messages_columns['smileys_enabled'] = empty($msgOptions['smileys_enabled']) ? 0 : 1;
2180
+	}
2080 2181
 
2081 2182
 	// Which columns need to be ints?
2082 2183
 	$messageInts = array('modified_time', 'id_msg_modified', 'smileys_enabled');
@@ -2087,8 +2188,9 @@  discard block
 block discarded – undo
2087 2188
 	// Update search api
2088 2189
 	require_once($sourcedir . '/Search.php');
2089 2190
 	$searchAPI = findSearchAPI();
2090
-	if ($searchAPI->supportsMethod('postRemoved'))
2091
-		$searchAPI->postRemoved($msgOptions['id']);
2191
+	if ($searchAPI->supportsMethod('postRemoved')) {
2192
+			$searchAPI->postRemoved($msgOptions['id']);
2193
+	}
2092 2194
 
2093 2195
 	if (!empty($modSettings['enable_mentions']) && isset($msgOptions['body']))
2094 2196
 	{
@@ -2100,23 +2202,27 @@  discard block
 block discarded – undo
2100 2202
 		{
2101 2203
 			preg_match_all('/\[member\=([0-9]+)\]([^\[]*)\[\/member\]/U', $msgOptions['old_body'], $match);
2102 2204
 
2103
-			if (isset($match[1]) && isset($match[2]) && is_array($match[1]) && is_array($match[2]))
2104
-				foreach ($match[1] as $i => $oldID)
2205
+			if (isset($match[1]) && isset($match[2]) && is_array($match[1]) && is_array($match[2])) {
2206
+							foreach ($match[1] as $i => $oldID)
2105 2207
 					$oldmentions[$oldID] = array('id' => $oldID, 'real_name' => $match[2][$i]);
2208
+			}
2106 2209
 
2107
-			if (empty($modSettings['search_custom_index_config']))
2108
-				unset($msgOptions['old_body']);
2210
+			if (empty($modSettings['search_custom_index_config'])) {
2211
+							unset($msgOptions['old_body']);
2212
+			}
2109 2213
 		}
2110 2214
 
2111 2215
 		$mentions = Mentions::getMentionedMembers($msgOptions['body']);
2112 2216
 		$messages_columns['body'] = $msgOptions['body'] = Mentions::getBody($msgOptions['body'], $mentions);
2113 2217
 
2114 2218
 		// Remove the poster.
2115
-		if (isset($mentions[$user_info['id']]))
2116
-			unset($mentions[$user_info['id']]);
2219
+		if (isset($mentions[$user_info['id']])) {
2220
+					unset($mentions[$user_info['id']]);
2221
+		}
2117 2222
 
2118
-		if (isset($oldmentions[$user_info['id']]))
2119
-			unset($oldmentions[$user_info['id']]);
2223
+		if (isset($oldmentions[$user_info['id']])) {
2224
+					unset($oldmentions[$user_info['id']]);
2225
+		}
2120 2226
 
2121 2227
 		if (is_array($mentions) && is_array($oldmentions) && count(array_diff_key($mentions, $oldmentions)) > 0 && count($mentions) > count($oldmentions))
2122 2228
 		{
@@ -2146,8 +2252,9 @@  discard block
 block discarded – undo
2146 2252
 	}
2147 2253
 
2148 2254
 	// Nothing to do?
2149
-	if (empty($messages_columns))
2150
-		return true;
2255
+	if (empty($messages_columns)) {
2256
+			return true;
2257
+	}
2151 2258
 
2152 2259
 	// Change the post.
2153 2260
 	$smcFunc['db_query']('', '
@@ -2208,8 +2315,9 @@  discard block
 block discarded – undo
2208 2315
 	// If there's a custom search index, it needs to be modified...
2209 2316
 	require_once($sourcedir . '/Search.php');
2210 2317
 	$searchAPI = findSearchAPI();
2211
-	if (is_callable(array($searchAPI, 'postModified')))
2212
-		$searchAPI->postModified($msgOptions, $topicOptions, $posterOptions);
2318
+	if (is_callable(array($searchAPI, 'postModified'))) {
2319
+			$searchAPI->postModified($msgOptions, $topicOptions, $posterOptions);
2320
+	}
2213 2321
 
2214 2322
 	if (isset($msgOptions['subject']))
2215 2323
 	{
@@ -2223,14 +2331,16 @@  discard block
 block discarded – undo
2223 2331
 				'id_first_msg' => $msgOptions['id'],
2224 2332
 			)
2225 2333
 		);
2226
-		if ($smcFunc['db_num_rows']($request) == 1)
2227
-			updateStats('subject', $topicOptions['id'], $msgOptions['subject']);
2334
+		if ($smcFunc['db_num_rows']($request) == 1) {
2335
+					updateStats('subject', $topicOptions['id'], $msgOptions['subject']);
2336
+		}
2228 2337
 		$smcFunc['db_free_result']($request);
2229 2338
 	}
2230 2339
 
2231 2340
 	// Finally, if we are setting the approved state we need to do much more work :(
2232
-	if ($modSettings['postmod_active'] && isset($msgOptions['approved']))
2233
-		approvePosts($msgOptions['id'], $msgOptions['approved']);
2341
+	if ($modSettings['postmod_active'] && isset($msgOptions['approved'])) {
2342
+			approvePosts($msgOptions['id'], $msgOptions['approved']);
2343
+	}
2234 2344
 
2235 2345
 	return true;
2236 2346
 }
@@ -2247,11 +2357,13 @@  discard block
 block discarded – undo
2247 2357
 {
2248 2358
 	global $smcFunc;
2249 2359
 
2250
-	if (!is_array($msgs))
2251
-		$msgs = array($msgs);
2360
+	if (!is_array($msgs)) {
2361
+			$msgs = array($msgs);
2362
+	}
2252 2363
 
2253
-	if (empty($msgs))
2254
-		return false;
2364
+	if (empty($msgs)) {
2365
+			return false;
2366
+	}
2255 2367
 
2256 2368
 	// May as well start at the beginning, working out *what* we need to change.
2257 2369
 	$request = $smcFunc['db_query']('', '
@@ -2283,20 +2395,22 @@  discard block
 block discarded – undo
2283 2395
 		$topics[] = $row['id_topic'];
2284 2396
 
2285 2397
 		// Ensure our change array exists already.
2286
-		if (!isset($topic_changes[$row['id_topic']]))
2287
-			$topic_changes[$row['id_topic']] = array(
2398
+		if (!isset($topic_changes[$row['id_topic']])) {
2399
+					$topic_changes[$row['id_topic']] = array(
2288 2400
 				'id_last_msg' => $row['id_last_msg'],
2289 2401
 				'approved' => $row['topic_approved'],
2290 2402
 				'replies' => 0,
2291 2403
 				'unapproved_posts' => 0,
2292 2404
 			);
2293
-		if (!isset($board_changes[$row['id_board']]))
2294
-			$board_changes[$row['id_board']] = array(
2405
+		}
2406
+		if (!isset($board_changes[$row['id_board']])) {
2407
+					$board_changes[$row['id_board']] = array(
2295 2408
 				'posts' => 0,
2296 2409
 				'topics' => 0,
2297 2410
 				'unapproved_posts' => 0,
2298 2411
 				'unapproved_topics' => 0,
2299 2412
 			);
2413
+		}
2300 2414
 
2301 2415
 		// If it's the first message then the topic state changes!
2302 2416
 		if ($row['id_msg'] == $row['id_first_msg'])
@@ -2317,14 +2431,13 @@  discard block
 block discarded – undo
2317 2431
 				'poster' => $row['id_member'],
2318 2432
 				'new_topic' => true,
2319 2433
 			);
2320
-		}
2321
-		else
2434
+		} else
2322 2435
 		{
2323 2436
 			$topic_changes[$row['id_topic']]['replies'] += $approve ? 1 : -1;
2324 2437
 
2325 2438
 			// This will be a post... but don't notify unless it's not followed by approved ones.
2326
-			if ($row['id_msg'] > $row['id_last_msg'])
2327
-				$notification_posts[$row['id_topic']] = array(
2439
+			if ($row['id_msg'] > $row['id_last_msg']) {
2440
+							$notification_posts[$row['id_topic']] = array(
2328 2441
 					'id' => $row['id_msg'],
2329 2442
 					'body' => $row['body'],
2330 2443
 					'subject' => $row['subject'],
@@ -2335,28 +2448,33 @@  discard block
 block discarded – undo
2335 2448
 					'new_topic' => false,
2336 2449
 					'msg' => $row['id_msg'],
2337 2450
 				);
2451
+			}
2338 2452
 		}
2339 2453
 
2340 2454
 		// If this is being approved and id_msg is higher than the current id_last_msg then it changes.
2341
-		if ($approve && $row['id_msg'] > $topic_changes[$row['id_topic']]['id_last_msg'])
2342
-			$topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_msg'];
2455
+		if ($approve && $row['id_msg'] > $topic_changes[$row['id_topic']]['id_last_msg']) {
2456
+					$topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_msg'];
2457
+		}
2343 2458
 		// If this is being unapproved, and it's equal to the id_last_msg we need to find a new one!
2344
-		elseif (!$approve)
2345
-			// Default to the first message and then we'll override in a bit ;)
2459
+		elseif (!$approve) {
2460
+					// Default to the first message and then we'll override in a bit ;)
2346 2461
 			$topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_first_msg'];
2462
+		}
2347 2463
 
2348 2464
 		$topic_changes[$row['id_topic']]['unapproved_posts'] += $approve ? -1 : 1;
2349 2465
 		$board_changes[$row['id_board']]['unapproved_posts'] += $approve ? -1 : 1;
2350 2466
 		$board_changes[$row['id_board']]['posts'] += $approve ? 1 : -1;
2351 2467
 
2352 2468
 		// Post count for the user?
2353
-		if ($row['id_member'] && empty($row['count_posts']))
2354
-			$member_post_changes[$row['id_member']] = isset($member_post_changes[$row['id_member']]) ? $member_post_changes[$row['id_member']] + 1 : 1;
2469
+		if ($row['id_member'] && empty($row['count_posts'])) {
2470
+					$member_post_changes[$row['id_member']] = isset($member_post_changes[$row['id_member']]) ? $member_post_changes[$row['id_member']] + 1 : 1;
2471
+		}
2355 2472
 	}
2356 2473
 	$smcFunc['db_free_result']($request);
2357 2474
 
2358
-	if (empty($msgs))
2359
-		return;
2475
+	if (empty($msgs)) {
2476
+			return;
2477
+	}
2360 2478
 
2361 2479
 	// Now we have the differences make the changes, first the easy one.
2362 2480
 	$smcFunc['db_query']('', '
@@ -2383,14 +2501,15 @@  discard block
 block discarded – undo
2383 2501
 				'approved' => 1,
2384 2502
 			)
2385 2503
 		);
2386
-		while ($row = $smcFunc['db_fetch_assoc']($request))
2387
-			$topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_last_msg'];
2504
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
2505
+					$topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_last_msg'];
2506
+		}
2388 2507
 		$smcFunc['db_free_result']($request);
2389 2508
 	}
2390 2509
 
2391 2510
 	// ... next the topics...
2392
-	foreach ($topic_changes as $id => $changes)
2393
-		$smcFunc['db_query']('', '
2511
+	foreach ($topic_changes as $id => $changes) {
2512
+			$smcFunc['db_query']('', '
2394 2513
 			UPDATE {db_prefix}topics
2395 2514
 			SET approved = {int:approved}, unapproved_posts = unapproved_posts + {int:unapproved_posts},
2396 2515
 				num_replies = num_replies + {int:num_replies}, id_last_msg = {int:id_last_msg}
@@ -2403,10 +2522,11 @@  discard block
 block discarded – undo
2403 2522
 				'id_topic' => $id,
2404 2523
 			)
2405 2524
 		);
2525
+	}
2406 2526
 
2407 2527
 	// ... finally the boards...
2408
-	foreach ($board_changes as $id => $changes)
2409
-		$smcFunc['db_query']('', '
2528
+	foreach ($board_changes as $id => $changes) {
2529
+			$smcFunc['db_query']('', '
2410 2530
 			UPDATE {db_prefix}boards
2411 2531
 			SET num_posts = num_posts + {int:num_posts}, unapproved_posts = unapproved_posts + {int:unapproved_posts},
2412 2532
 				num_topics = num_topics + {int:num_topics}, unapproved_topics = unapproved_topics + {int:unapproved_topics}
@@ -2419,13 +2539,14 @@  discard block
 block discarded – undo
2419 2539
 				'id_board' => $id,
2420 2540
 			)
2421 2541
 		);
2542
+	}
2422 2543
 
2423 2544
 	// Finally, least importantly, notifications!
2424 2545
 	if ($approve)
2425 2546
 	{
2426 2547
 		$task_rows = array();
2427
-		foreach (array_merge($notification_topics, $notification_posts) as $topic)
2428
-			$task_rows[] = array(
2548
+		foreach (array_merge($notification_topics, $notification_posts) as $topic) {
2549
+					$task_rows[] = array(
2429 2550
 				'$sourcedir/tasks/CreatePost-Notify.php', 'CreatePost_Notify_Background', $smcFunc['json_encode'](array(
2430 2551
 					'msgOptions' => array(
2431 2552
 						'id' => $topic['msg'],
@@ -2443,14 +2564,16 @@  discard block
 block discarded – undo
2443 2564
 					'type' => $topic['new_topic'] ? 'topic' : 'reply',
2444 2565
 				)), 0
2445 2566
 			);
2567
+		}
2446 2568
 
2447
-		if ($notify)
2448
-			$smcFunc['db_insert']('',
2569
+		if ($notify) {
2570
+					$smcFunc['db_insert']('',
2449 2571
 				'{db_prefix}background_tasks',
2450 2572
 				array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'),
2451 2573
 				$task_rows,
2452 2574
 				array('id_task')
2453 2575
 			);
2576
+		}
2454 2577
 
2455 2578
 		$smcFunc['db_query']('', '
2456 2579
 			DELETE FROM {db_prefix}approval_queue
@@ -2466,8 +2589,9 @@  discard block
 block discarded – undo
2466 2589
 	else
2467 2590
 	{
2468 2591
 		$msgInserts = array();
2469
-		foreach ($msgs as $msg)
2470
-			$msgInserts[] = array($msg);
2592
+		foreach ($msgs as $msg) {
2593
+					$msgInserts[] = array($msg);
2594
+		}
2471 2595
 
2472 2596
 		$smcFunc['db_insert']('ignore',
2473 2597
 			'{db_prefix}approval_queue',
@@ -2481,9 +2605,10 @@  discard block
 block discarded – undo
2481 2605
 	updateLastMessages(array_keys($board_changes));
2482 2606
 
2483 2607
 	// Post count for the members?
2484
-	if (!empty($member_post_changes))
2485
-		foreach ($member_post_changes as $id_member => $count_change)
2608
+	if (!empty($member_post_changes)) {
2609
+			foreach ($member_post_changes as $id_member => $count_change)
2486 2610
 			updateMemberData($id_member, array('posts' => 'posts ' . ($approve ? '+' : '-') . ' ' . $count_change));
2611
+	}
2487 2612
 
2488 2613
 	return true;
2489 2614
 }
@@ -2500,11 +2625,13 @@  discard block
 block discarded – undo
2500 2625
 {
2501 2626
 	global $smcFunc;
2502 2627
 
2503
-	if (!is_array($topics))
2504
-		$topics = array($topics);
2628
+	if (!is_array($topics)) {
2629
+			$topics = array($topics);
2630
+	}
2505 2631
 
2506
-	if (empty($topics))
2507
-		return false;
2632
+	if (empty($topics)) {
2633
+			return false;
2634
+	}
2508 2635
 
2509 2636
 	$approve_type = $approve ? 0 : 1;
2510 2637
 
@@ -2520,8 +2647,9 @@  discard block
 block discarded – undo
2520 2647
 		)
2521 2648
 	);
2522 2649
 	$msgs = array();
2523
-	while ($row = $smcFunc['db_fetch_assoc']($request))
2524
-		$msgs[] = $row['id_msg'];
2650
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
2651
+			$msgs[] = $row['id_msg'];
2652
+	}
2525 2653
 	$smcFunc['db_free_result']($request);
2526 2654
 
2527 2655
 	return approvePosts($msgs, $approve);
@@ -2544,11 +2672,13 @@  discard block
 block discarded – undo
2544 2672
 	global $board_info, $board, $smcFunc;
2545 2673
 
2546 2674
 	// Please - let's be sane.
2547
-	if (empty($setboards))
2548
-		return false;
2675
+	if (empty($setboards)) {
2676
+			return false;
2677
+	}
2549 2678
 
2550
-	if (!is_array($setboards))
2551
-		$setboards = array($setboards);
2679
+	if (!is_array($setboards)) {
2680
+			$setboards = array($setboards);
2681
+	}
2552 2682
 
2553 2683
 	// If we don't know the id_msg we need to find it.
2554 2684
 	if (!$id_msg)
@@ -2566,15 +2696,16 @@  discard block
 block discarded – undo
2566 2696
 			)
2567 2697
 		);
2568 2698
 		$lastMsg = array();
2569
-		while ($row = $smcFunc['db_fetch_assoc']($request))
2570
-			$lastMsg[$row['id_board']] = $row['id_msg'];
2699
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
2700
+					$lastMsg[$row['id_board']] = $row['id_msg'];
2701
+		}
2571 2702
 		$smcFunc['db_free_result']($request);
2572
-	}
2573
-	else
2703
+	} else
2574 2704
 	{
2575 2705
 		// Just to note - there should only be one board passed if we are doing this.
2576
-		foreach ($setboards as $id_board)
2577
-			$lastMsg[$id_board] = $id_msg;
2706
+		foreach ($setboards as $id_board) {
2707
+					$lastMsg[$id_board] = $id_msg;
2708
+		}
2578 2709
 	}
2579 2710
 
2580 2711
 	$parent_boards = array();
@@ -2589,10 +2720,11 @@  discard block
 block discarded – undo
2589 2720
 			$lastModified[$id_board] = 0;
2590 2721
 		}
2591 2722
 
2592
-		if (!empty($board) && $id_board == $board)
2593
-			$parents = $board_info['parent_boards'];
2594
-		else
2595
-			$parents = getBoardParents($id_board);
2723
+		if (!empty($board) && $id_board == $board) {
2724
+					$parents = $board_info['parent_boards'];
2725
+		} else {
2726
+					$parents = getBoardParents($id_board);
2727
+		}
2596 2728
 
2597 2729
 		// Ignore any parents on the top child level.
2598 2730
 		// @todo Why?
@@ -2601,10 +2733,11 @@  discard block
 block discarded – undo
2601 2733
 			if ($parent['level'] != 0)
2602 2734
 			{
2603 2735
 				// If we're already doing this one as a board, is this a higher last modified?
2604
-				if (isset($lastModified[$id]) && $lastModified[$id_board] > $lastModified[$id])
2605
-					$lastModified[$id] = $lastModified[$id_board];
2606
-				elseif (!isset($lastModified[$id]) && (!isset($parent_boards[$id]) || $parent_boards[$id] < $lastModified[$id_board]))
2607
-					$parent_boards[$id] = $lastModified[$id_board];
2736
+				if (isset($lastModified[$id]) && $lastModified[$id_board] > $lastModified[$id]) {
2737
+									$lastModified[$id] = $lastModified[$id_board];
2738
+				} elseif (!isset($lastModified[$id]) && (!isset($parent_boards[$id]) || $parent_boards[$id] < $lastModified[$id_board])) {
2739
+									$parent_boards[$id] = $lastModified[$id_board];
2740
+				}
2608 2741
 			}
2609 2742
 		}
2610 2743
 	}
@@ -2617,23 +2750,24 @@  discard block
 block discarded – undo
2617 2750
 	// Finally, to save on queries make the changes...
2618 2751
 	foreach ($parent_boards as $id => $msg)
2619 2752
 	{
2620
-		if (!isset($parent_updates[$msg]))
2621
-			$parent_updates[$msg] = array($id);
2622
-		else
2623
-			$parent_updates[$msg][] = $id;
2753
+		if (!isset($parent_updates[$msg])) {
2754
+					$parent_updates[$msg] = array($id);
2755
+		} else {
2756
+					$parent_updates[$msg][] = $id;
2757
+		}
2624 2758
 	}
2625 2759
 
2626 2760
 	foreach ($lastMsg as $id => $msg)
2627 2761
 	{
2628
-		if (!isset($board_updates[$msg . '-' . $lastModified[$id]]))
2629
-			$board_updates[$msg . '-' . $lastModified[$id]] = array(
2762
+		if (!isset($board_updates[$msg . '-' . $lastModified[$id]])) {
2763
+					$board_updates[$msg . '-' . $lastModified[$id]] = array(
2630 2764
 				'id' => $msg,
2631 2765
 				'updated' => $lastModified[$id],
2632 2766
 				'boards' => array($id)
2633 2767
 			);
2634
-
2635
-		else
2636
-			$board_updates[$msg . '-' . $lastModified[$id]]['boards'][] = $id;
2768
+		} else {
2769
+					$board_updates[$msg . '-' . $lastModified[$id]]['boards'][] = $id;
2770
+		}
2637 2771
 	}
2638 2772
 
2639 2773
 	// Now commit the changes!
@@ -2725,11 +2859,13 @@  discard block
 block discarded – undo
2725 2859
 	global $txt, $mbname, $scripturl, $settings;
2726 2860
 
2727 2861
 	// First things first, load up the email templates language file, if we need to.
2728
-	if ($loadLang)
2729
-		loadLanguage('EmailTemplates', $lang);
2862
+	if ($loadLang) {
2863
+			loadLanguage('EmailTemplates', $lang);
2864
+	}
2730 2865
 
2731
-	if (!isset($txt[$template . '_subject']) || !isset($txt[$template . '_body']))
2732
-		fatal_lang_error('email_no_template', 'template', array($template));
2866
+	if (!isset($txt[$template . '_subject']) || !isset($txt[$template . '_body'])) {
2867
+			fatal_lang_error('email_no_template', 'template', array($template));
2868
+	}
2733 2869
 
2734 2870
 	$ret = array(
2735 2871
 		'subject' => $txt[$template . '_subject'],
@@ -2779,17 +2915,18 @@  discard block
 block discarded – undo
2779 2915
 function user_info_callback($matches)
2780 2916
 {
2781 2917
 	global $user_info;
2782
-	if (empty($matches[1]))
2783
-		return '';
2918
+	if (empty($matches[1])) {
2919
+			return '';
2920
+	}
2784 2921
 
2785 2922
 	$use_ref = true;
2786 2923
 	$ref = &$user_info;
2787 2924
 
2788 2925
 	foreach (explode('.', $matches[1]) as $index)
2789 2926
 	{
2790
-		if ($use_ref && isset($ref[$index]))
2791
-			$ref = &$ref[$index];
2792
-		else
2927
+		if ($use_ref && isset($ref[$index])) {
2928
+					$ref = &$ref[$index];
2929
+		} else
2793 2930
 		{
2794 2931
 			$use_ref = false;
2795 2932
 			break;
@@ -2826,8 +2963,7 @@  discard block
 block discarded – undo
2826 2963
 		if (!empty($lang_locale) && enchant_broker_dict_exists($context['enchant_broker'], $lang_locale))
2827 2964
 		{
2828 2965
 			$enchant_link = enchant_broker_request_dict($context['enchant_broker'], $lang_locale);
2829
-		}
2830
-		elseif (enchant_broker_dict_exists($context['enchant_broker'], $txt['lang_dictionary']))
2966
+		} elseif (enchant_broker_dict_exists($context['enchant_broker'], $txt['lang_dictionary']))
2831 2967
 		{
2832 2968
 			$enchant_link = enchant_broker_request_dict($context['enchant_broker'], $txt['lang_dictionary']);
2833 2969
 		}
@@ -2837,8 +2973,7 @@  discard block
 block discarded – undo
2837 2973
 		{
2838 2974
 			$context['provider'] = 'enchant';
2839 2975
 			return $enchant_link;
2840
-		}
2841
-		else
2976
+		} else
2842 2977
 		{
2843 2978
 			// Free up any resources used...
2844 2979
 			@enchant_broker_free($context['enchant_broker']);
@@ -2859,8 +2994,9 @@  discard block
 block discarded – undo
2859 2994
 		$pspell_link = pspell_new($txt['lang_dictionary'], $txt['lang_spelling'], '', strtr($context['character_set'], array('iso-' => 'iso', 'ISO-' => 'iso')), PSPELL_FAST | PSPELL_RUN_TOGETHER);
2860 2995
 
2861 2996
 		// Most people don't have anything but English installed... So we use English as a last resort.
2862
-		if (!$pspell_link)
2863
-			$pspell_link = pspell_new('en', '', '', '', PSPELL_FAST | PSPELL_RUN_TOGETHER);
2997
+		if (!$pspell_link) {
2998
+					$pspell_link = pspell_new('en', '', '', '', PSPELL_FAST | PSPELL_RUN_TOGETHER);
2999
+		}
2864 3000
 
2865 3001
 		error_reporting($old);
2866 3002
 		ob_end_clean();
@@ -2900,8 +3036,7 @@  discard block
 block discarded – undo
2900 3036
 			$word = iconv($txt['lang_character_set'], 'UTF-8', $word);
2901 3037
 		}
2902 3038
 		return enchant_dict_check($dict, $word);
2903
-	}
2904
-	elseif ($context['provider'] == 'pspell')
3039
+	} elseif ($context['provider'] == 'pspell')
2905 3040
 	{
2906 3041
 		return pspell_check($dict, $word);
2907 3042
 	}
@@ -2937,13 +3072,11 @@  discard block
 block discarded – undo
2937 3072
 			}
2938 3073
 
2939 3074
 			return $suggestions;
2940
-		}
2941
-		else
3075
+		} else
2942 3076
 		{
2943 3077
 			return enchant_dict_suggest($dict, $word);
2944 3078
 		}
2945
-	}
2946
-	elseif ($context['provider'] == 'pspell')
3079
+	} elseif ($context['provider'] == 'pspell')
2947 3080
 	{
2948 3081
 		return pspell_suggest($dict, $word);
2949 3082
 	}
Please login to merge, or discard this patch.
Sources/Errors.php 1 patch
Braces   +127 added lines, -90 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
  * Log an error, if the error logging is enabled.
@@ -39,10 +40,11 @@  discard block
 block discarded – undo
39 40
 	$error_call++;
40 41
 
41 42
 	// Collect a backtrace
42
-	if (!isset($db_show_debug) || $db_show_debug === false)
43
-		$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
44
-	else
45
-		$backtrace = debug_backtrace();
43
+	if (!isset($db_show_debug) || $db_show_debug === false) {
44
+			$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
45
+	} else {
46
+			$backtrace = debug_backtrace();
47
+	}
46 48
 
47 49
 	// are we in a loop?
48 50
 	if($error_call > 2)
@@ -52,8 +54,9 @@  discard block
 block discarded – undo
52 54
 	}
53 55
 
54 56
 	// Check if error logging is actually on.
55
-	if (empty($modSettings['enableErrorLogging']))
56
-		return $error_message;
57
+	if (empty($modSettings['enableErrorLogging'])) {
58
+			return $error_message;
59
+	}
57 60
 
58 61
 	// Basically, htmlspecialchars it minus &. (for entities!)
59 62
 	$error_message = strtr($error_message, array('<' => '&lt;', '>' => '&gt;', '"' => '&quot;'));
@@ -61,33 +64,39 @@  discard block
 block discarded – undo
61 64
 
62 65
 	// Add a file and line to the error message?
63 66
 	// Don't use the actual txt entries for file and line but instead use %1$s for file and %2$s for line
64
-	if ($file == null)
65
-		$file = '';
66
-	else
67
-		// Window style slashes don't play well, lets convert them to the unix style.
67
+	if ($file == null) {
68
+			$file = '';
69
+	} else {
70
+			// Window style slashes don't play well, lets convert them to the unix style.
68 71
 		$file = str_replace('\\', '/', $file);
72
+	}
69 73
 
70
-	if ($line == null)
71
-		$line = 0;
72
-	else
73
-		$line = (int) $line;
74
+	if ($line == null) {
75
+			$line = 0;
76
+	} else {
77
+			$line = (int) $line;
78
+	}
74 79
 
75 80
 	// Just in case there's no id_member or IP set yet.
76
-	if (empty($user_info['id']))
77
-		$user_info['id'] = 0;
78
-	if (empty($user_info['ip']))
79
-		$user_info['ip'] = '';
81
+	if (empty($user_info['id'])) {
82
+			$user_info['id'] = 0;
83
+	}
84
+	if (empty($user_info['ip'])) {
85
+			$user_info['ip'] = '';
86
+	}
80 87
 
81 88
 	// Find the best query string we can...
82 89
 	$query_string = empty($_SERVER['QUERY_STRING']) ? (empty($_SERVER['REQUEST_URL']) ? '' : str_replace($scripturl, '', $_SERVER['REQUEST_URL'])) : $_SERVER['QUERY_STRING'];
83 90
 
84 91
 	// Don't log the session hash in the url twice, it's a waste.
85
-	if (!empty($smcFunc['htmlspecialchars']))
86
-		$query_string = $smcFunc['htmlspecialchars']((SMF == 'SSI' || SMF == 'BACKGROUND' ? '' : '?') . preg_replace(array('~;sesc=[^&;]+~', '~' . session_name() . '=' . session_id() . '[&;]~'), array(';sesc', ''), $query_string));
92
+	if (!empty($smcFunc['htmlspecialchars'])) {
93
+			$query_string = $smcFunc['htmlspecialchars']((SMF == 'SSI' || SMF == 'BACKGROUND' ? '' : '?') . preg_replace(array('~;sesc=[^&;]+~', '~' . session_name() . '=' . session_id() . '[&;]~'), array(';sesc', ''), $query_string));
94
+	}
87 95
 
88 96
 	// Just so we know what board error messages are from.
89
-	if (isset($_POST['board']) && !isset($_GET['board']))
90
-		$query_string .= ($query_string == '' ? 'board=' : ';board=') . $_POST['board'];
97
+	if (isset($_POST['board']) && !isset($_GET['board'])) {
98
+			$query_string .= ($query_string == '' ? 'board=' : ';board=') . $_POST['board'];
99
+	}
91 100
 
92 101
 	// What types of categories do we have?
93 102
 	$known_error_types = array(
@@ -140,9 +149,9 @@  discard block
 block discarded – undo
140 149
 
141 150
 			list($context['num_errors']) = $smcFunc['db_fetch_row']($query);
142 151
 			$smcFunc['db_free_result']($query);
152
+		} else {
153
+					$context['num_errors']++;
143 154
 		}
144
-		else
145
-			$context['num_errors']++;
146 155
 	}
147 156
 
148 157
 	// reset error call
@@ -164,12 +173,14 @@  discard block
 block discarded – undo
164 173
 	global $txt;
165 174
 
166 175
 	// Send the appropriate HTTP status header - set this to 0 or false if you don't want to send one at all
167
-	if (!empty($status))
168
-		send_http_status($status);
176
+	if (!empty($status)) {
177
+			send_http_status($status);
178
+	}
169 179
 
170 180
 	// We don't have $txt yet, but that's okay...
171
-	if (empty($txt))
172
-		die($error);
181
+	if (empty($txt)) {
182
+			die($error);
183
+	}
173 184
 
174 185
 	log_error_online($error, false);
175 186
 	setup_fatal_error_context($log ? log_error($error, $log) : $error);
@@ -196,8 +207,9 @@  discard block
 block discarded – undo
196 207
 	static $fatal_error_called = false;
197 208
 
198 209
 	// Send the status header - set this to 0 or false if you don't want to send one at all
199
-	if (!empty($status))
200
-		send_http_status($status);
210
+	if (!empty($status)) {
211
+			send_http_status($status);
212
+	}
201 213
 
202 214
 	// Try to load a theme if we don't have one.
203 215
 	if (empty($context['theme_loaded']) && empty($fatal_error_called))
@@ -207,8 +219,9 @@  discard block
 block discarded – undo
207 219
 	}
208 220
 
209 221
 	// If we have no theme stuff we can't have the language file...
210
-	if (empty($context['theme_loaded']))
211
-		die($error);
222
+	if (empty($context['theme_loaded'])) {
223
+			die($error);
224
+	}
212 225
 
213 226
 	$reload_lang_file = true;
214 227
 	// Log the error in the forum's language, but don't waste the time if we aren't logging
@@ -244,8 +257,9 @@  discard block
 block discarded – undo
244 257
 	global $settings, $modSettings, $db_show_debug;
245 258
 
246 259
 	// Ignore errors if we're ignoring them or they are strict notices from PHP 5
247
-	if (error_reporting() == 0)
248
-		return;
260
+	if (error_reporting() == 0) {
261
+			return;
262
+	}
249 263
 
250 264
 	if (strpos($file, 'eval()') !== false && !empty($settings['current_include_filename']))
251 265
 	{
@@ -253,19 +267,22 @@  discard block
 block discarded – undo
253 267
 		$count = count($array);
254 268
 		for ($i = 0; $i < $count; $i++)
255 269
 		{
256
-			if ($array[$i]['function'] != 'loadSubTemplate')
257
-				continue;
270
+			if ($array[$i]['function'] != 'loadSubTemplate') {
271
+							continue;
272
+			}
258 273
 
259 274
 			// This is a bug in PHP, with eval, it seems!
260
-			if (empty($array[$i]['args']))
261
-				$i++;
275
+			if (empty($array[$i]['args'])) {
276
+							$i++;
277
+			}
262 278
 			break;
263 279
 		}
264 280
 
265
-		if (isset($array[$i]) && !empty($array[$i]['args']))
266
-			$file = realpath($settings['current_include_filename']) . ' (' . $array[$i]['args'][0] . ' sub template - eval?)';
267
-		else
268
-			$file = realpath($settings['current_include_filename']) . ' (eval?)';
281
+		if (isset($array[$i]) && !empty($array[$i]['args'])) {
282
+					$file = realpath($settings['current_include_filename']) . ' (' . $array[$i]['args'][0] . ' sub template - eval?)';
283
+		} else {
284
+					$file = realpath($settings['current_include_filename']) . ' (eval?)';
285
+		}
269 286
 	}
270 287
 
271 288
 	if (isset($db_show_debug) && $db_show_debug === true)
@@ -274,8 +291,9 @@  discard block
 block discarded – undo
274 291
 		if ($error_level % 255 != E_ERROR)
275 292
 		{
276 293
 			$temporary = ob_get_contents();
277
-			if (substr($temporary, -2) == '="')
278
-				echo '"';
294
+			if (substr($temporary, -2) == '="') {
295
+							echo '"';
296
+			}
279 297
 		}
280 298
 
281 299
 		// Debugging!  This should look like a PHP error message.
@@ -291,23 +309,27 @@  discard block
 block discarded – undo
291 309
 	call_integration_hook('integrate_output_error', array($message, $error_type, $error_level, $file, $line));
292 310
 
293 311
 	// Dying on these errors only causes MORE problems (blank pages!)
294
-	if ($file == 'Unknown')
295
-		return;
312
+	if ($file == 'Unknown') {
313
+			return;
314
+	}
296 315
 
297 316
 	// If this is an E_ERROR or E_USER_ERROR.... die.  Violently so.
298
-	if ($error_level % 255 == E_ERROR)
299
-		obExit(false);
300
-	else
301
-		return;
317
+	if ($error_level % 255 == E_ERROR) {
318
+			obExit(false);
319
+	} else {
320
+			return;
321
+	}
302 322
 
303 323
 	// If this is an E_ERROR, E_USER_ERROR, E_WARNING, or E_USER_WARNING.... die.  Violently so.
304
-	if ($error_level % 255 == E_ERROR || $error_level % 255 == E_WARNING)
305
-		fatal_error(allowedTo('admin_forum') ? $message : $error_string, false);
324
+	if ($error_level % 255 == E_ERROR || $error_level % 255 == E_WARNING) {
325
+			fatal_error(allowedTo('admin_forum') ? $message : $error_string, false);
326
+	}
306 327
 
307 328
 	// We should NEVER get to this point.  Any fatal error MUST quit, or very bad things can happen.
308
-	if ($error_level % 255 == E_ERROR)
309
-		die('No direct access...');
310
-}
329
+	if ($error_level % 255 == E_ERROR) {
330
+			die('No direct access...');
331
+	}
332
+	}
311 333
 
312 334
 /**
313 335
  * It is called by {@link fatal_error()} and {@link fatal_lang_error()}.
@@ -323,24 +345,28 @@  discard block
 block discarded – undo
323 345
 
324 346
 	// Attempt to prevent a recursive loop.
325 347
 	++$level;
326
-	if ($level > 1)
327
-		return false;
348
+	if ($level > 1) {
349
+			return false;
350
+	}
328 351
 
329 352
 	// Maybe they came from dlattach or similar?
330
-	if (SMF != 'SSI' && SMF != 'BACKGROUND' && empty($context['theme_loaded']))
331
-		loadTheme();
353
+	if (SMF != 'SSI' && SMF != 'BACKGROUND' && empty($context['theme_loaded'])) {
354
+			loadTheme();
355
+	}
332 356
 
333 357
 	// Don't bother indexing errors mate...
334 358
 	$context['robot_no_index'] = true;
335 359
 
336
-	if (!isset($context['error_title']))
337
-		$context['error_title'] = $txt['error_occured'];
360
+	if (!isset($context['error_title'])) {
361
+			$context['error_title'] = $txt['error_occured'];
362
+	}
338 363
 	$context['error_message'] = isset($context['error_message']) ? $context['error_message'] : $error_message;
339 364
 
340 365
 	$context['error_code'] = isset($error_code) ? 'id="' . $error_code . '" ' : '';
341 366
 
342
-	if (empty($context['page_title']))
343
-		$context['page_title'] = $context['error_title'];
367
+	if (empty($context['page_title'])) {
368
+			$context['page_title'] = $context['error_title'];
369
+	}
344 370
 
345 371
 	loadTemplate('Errors');
346 372
 	$context['sub_template'] = 'fatal_error';
@@ -348,23 +374,26 @@  discard block
 block discarded – undo
348 374
 	// If this is SSI, what do they want us to do?
349 375
 	if (SMF == 'SSI')
350 376
 	{
351
-		if (!empty($ssi_on_error_method) && $ssi_on_error_method !== true && is_callable($ssi_on_error_method))
352
-			$ssi_on_error_method();
353
-		elseif (empty($ssi_on_error_method) || $ssi_on_error_method !== true)
354
-			loadSubTemplate('fatal_error');
377
+		if (!empty($ssi_on_error_method) && $ssi_on_error_method !== true && is_callable($ssi_on_error_method)) {
378
+					$ssi_on_error_method();
379
+		} elseif (empty($ssi_on_error_method) || $ssi_on_error_method !== true) {
380
+					loadSubTemplate('fatal_error');
381
+		}
355 382
 
356 383
 		// No layers?
357
-		if (empty($ssi_on_error_method) || $ssi_on_error_method !== true)
358
-			exit;
384
+		if (empty($ssi_on_error_method) || $ssi_on_error_method !== true) {
385
+					exit;
386
+		}
359 387
 	}
360 388
 	// Alternatively from the cron call?
361 389
 	elseif (SMF == 'BACKGROUND')
362 390
 	{
363 391
 		// We can't rely on even having language files available.
364
-		if (defined('FROM_CLI') && FROM_CLI)
365
-			echo 'cron error: ', $context['error_message'];
366
-		else
367
-			echo 'An error occurred. More information may be available in your logs.';
392
+		if (defined('FROM_CLI') && FROM_CLI) {
393
+					echo 'cron error: ', $context['error_message'];
394
+		} else {
395
+					echo 'An error occurred. More information may be available in your logs.';
396
+		}
368 397
 		exit;
369 398
 	}
370 399
 
@@ -392,8 +421,8 @@  discard block
 block discarded – undo
392 421
 
393 422
 	set_fatal_error_headers();
394 423
 
395
-	if (!empty($maintenance))
396
-		echo '<!DOCTYPE html>
424
+	if (!empty($maintenance)) {
425
+			echo '<!DOCTYPE html>
397 426
 <html>
398 427
 	<head>
399 428
 		<meta name="robots" content="noindex">
@@ -404,6 +433,7 @@  discard block
 block discarded – undo
404 433
 		', $mmessage, '
405 434
 	</body>
406 435
 </html>';
436
+	}
407 437
 
408 438
 	die();
409 439
 }
@@ -425,15 +455,17 @@  discard block
 block discarded – undo
425 455
 	// For our purposes, we're gonna want this on if at all possible.
426 456
 	$modSettings['cache_enable'] = '1';
427 457
 
428
-	if (($temp = cache_get_data('db_last_error', 600)) !== null)
429
-		$db_last_error = max($db_last_error, $temp);
458
+	if (($temp = cache_get_data('db_last_error', 600)) !== null) {
459
+			$db_last_error = max($db_last_error, $temp);
460
+	}
430 461
 
431 462
 	if ($db_last_error < time() - 3600 * 24 * 3 && empty($maintenance) && !empty($db_error_send))
432 463
 	{
433 464
 		// Avoid writing to the Settings.php file if at all possible; use shared memory instead.
434 465
 		cache_put_data('db_last_error', time(), 600);
435
-		if (($temp = cache_get_data('db_last_error', 600)) === null)
436
-			logLastDatabaseError();
466
+		if (($temp = cache_get_data('db_last_error', 600)) === null) {
467
+					logLastDatabaseError();
468
+		}
437 469
 
438 470
 		// Language files aren't loaded yet :(.
439 471
 		$db_error = @$smcFunc['db_error']($db_connection);
@@ -490,8 +522,9 @@  discard block
 block discarded – undo
490 522
  */
491 523
 function set_fatal_error_headers()
492 524
 {
493
-	if (headers_sent())
494
-		return;
525
+	if (headers_sent()) {
526
+			return;
527
+	}
495 528
 
496 529
 	// Don't cache this page!
497 530
 	header('expires: Mon, 26 Jul 1997 05:00:00 GMT');
@@ -517,12 +550,14 @@  discard block
 block discarded – undo
517 550
 	global $smcFunc, $user_info, $modSettings;
518 551
 
519 552
 	// Don't bother if Who's Online is disabled.
520
-	if (empty($modSettings['who_enabled']))
521
-		return;
553
+	if (empty($modSettings['who_enabled'])) {
554
+			return;
555
+	}
522 556
 
523 557
 	// Maybe they came from SSI or similar where sessions are not recorded?
524
-	if (SMF == 'SSI' || SMF == 'BACKGROUND')
525
-		return;
558
+	if (SMF == 'SSI' || SMF == 'BACKGROUND') {
559
+			return;
560
+	}
526 561
 
527 562
 	$session_id = !empty($user_info['is_guest']) ? 'ip' . $user_info['ip'] : session_id();
528 563
 
@@ -548,11 +583,13 @@  discard block
 block discarded – undo
548 583
 		$url = $smcFunc['json_decode']($url, true);
549 584
 		$url['error'] = $error;
550 585
 		// Url field got a max length of 1024 in db
551
-		if (strlen($url['error']) > 500)
552
-			$url['error'] = substr($url['error'],0,500);
586
+		if (strlen($url['error']) > 500) {
587
+					$url['error'] = substr($url['error'],0,500);
588
+		}
553 589
 
554
-		if (!empty($sprintf))
555
-			$url['error_params'] = $sprintf;
590
+		if (!empty($sprintf)) {
591
+					$url['error_params'] = $sprintf;
592
+		}
556 593
 
557 594
 		$smcFunc['db_query']('', '
558 595
 			UPDATE {db_prefix}log_online
Please login to merge, or discard this patch.
Sources/Security.php 1 patch
Braces   +255 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
  * Check if the user is who he/she says he is
@@ -42,12 +43,14 @@  discard block
 block discarded – undo
42 43
 	$refreshTime = isset($_GET['xml']) ? 4200 : 3600;
43 44
 
44 45
 	// Is the security option off?
45
-	if (!empty($modSettings['securityDisable' . ($type != 'admin' ? '_' . $type : '')]))
46
-		return;
46
+	if (!empty($modSettings['securityDisable' . ($type != 'admin' ? '_' . $type : '')])) {
47
+			return;
48
+	}
47 49
 
48 50
 	// Or are they already logged in?, Moderator or admin session is need for this area
49
-	if ((!empty($_SESSION[$type . '_time']) && $_SESSION[$type . '_time'] + $refreshTime >= time()) || (!empty($_SESSION['admin_time']) && $_SESSION['admin_time'] + $refreshTime >= time()))
50
-		return;
51
+	if ((!empty($_SESSION[$type . '_time']) && $_SESSION[$type . '_time'] + $refreshTime >= time()) || (!empty($_SESSION['admin_time']) && $_SESSION['admin_time'] + $refreshTime >= time())) {
52
+			return;
53
+	}
51 54
 
52 55
 	require_once($sourcedir . '/Subs-Auth.php');
53 56
 
@@ -55,8 +58,9 @@  discard block
 block discarded – undo
55 58
 	if (isset($_POST[$type . '_pass']))
56 59
 	{
57 60
 		// Check to ensure we're forcing SSL for authentication
58
-		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn())
59
-			fatal_lang_error('login_ssl_required');
61
+		if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) {
62
+					fatal_lang_error('login_ssl_required');
63
+		}
60 64
 
61 65
 		checkSession();
62 66
 
@@ -72,17 +76,19 @@  discard block
 block discarded – undo
72 76
 	}
73 77
 
74 78
 	// Better be sure to remember the real referer
75
-	if (empty($_SESSION['request_referer']))
76
-		$_SESSION['request_referer'] = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array();
77
-	elseif (empty($_POST))
78
-		unset($_SESSION['request_referer']);
79
+	if (empty($_SESSION['request_referer'])) {
80
+			$_SESSION['request_referer'] = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array();
81
+	} elseif (empty($_POST)) {
82
+			unset($_SESSION['request_referer']);
83
+	}
79 84
 
80 85
 	// Need to type in a password for that, man.
81
-	if (!isset($_GET['xml']))
82
-		adminLogin($type);
83
-	else
84
-		return 'session_verify_fail';
85
-}
86
+	if (!isset($_GET['xml'])) {
87
+			adminLogin($type);
88
+	} else {
89
+			return 'session_verify_fail';
90
+	}
91
+	}
86 92
 
87 93
 /**
88 94
  * Require a user who is logged in. (not a guest.)
@@ -96,25 +102,30 @@  discard block
 block discarded – undo
96 102
 	global $user_info, $txt, $context, $scripturl, $modSettings;
97 103
 
98 104
 	// Luckily, this person isn't a guest.
99
-	if (!$user_info['is_guest'])
100
-		return;
105
+	if (!$user_info['is_guest']) {
106
+			return;
107
+	}
101 108
 
102 109
 	// Log what they were trying to do didn't work)
103
-	if (!empty($modSettings['who_enabled']))
104
-		$_GET['error'] = 'guest_login';
110
+	if (!empty($modSettings['who_enabled'])) {
111
+			$_GET['error'] = 'guest_login';
112
+	}
105 113
 	writeLog(true);
106 114
 
107 115
 	// Just die.
108
-	if (isset($_REQUEST['xml']))
109
-		obExit(false);
116
+	if (isset($_REQUEST['xml'])) {
117
+			obExit(false);
118
+	}
110 119
 
111 120
 	// Attempt to detect if they came from dlattach.
112
-	if (SMF != 'SSI' && empty($context['theme_loaded']))
113
-		loadTheme();
121
+	if (SMF != 'SSI' && empty($context['theme_loaded'])) {
122
+			loadTheme();
123
+	}
114 124
 
115 125
 	// Never redirect to an attachment
116
-	if (strpos($_SERVER['REQUEST_URL'], 'dlattach') === false)
117
-		$_SESSION['login_url'] = $_SERVER['REQUEST_URL'];
126
+	if (strpos($_SERVER['REQUEST_URL'], 'dlattach') === false) {
127
+			$_SESSION['login_url'] = $_SERVER['REQUEST_URL'];
128
+	}
118 129
 
119 130
 	// Load the Login template and language file.
120 131
 	loadLanguage('Login');
@@ -124,8 +135,7 @@  discard block
 block discarded – undo
124 135
 	{
125 136
 		$_SESSION['login_url'] = $scripturl . '?' . $_SERVER['QUERY_STRING'];
126 137
 		redirectexit('action=login');
127
-	}
128
-	else
138
+	} else
129 139
 	{
130 140
 		loadTemplate('Login');
131 141
 		$context['sub_template'] = 'kick_guest';
@@ -155,8 +165,9 @@  discard block
 block discarded – undo
155 165
 	global $sourcedir, $cookiename, $user_settings, $smcFunc;
156 166
 
157 167
 	// You cannot be banned if you are an admin - doesn't help if you log out.
158
-	if ($user_info['is_admin'])
159
-		return;
168
+	if ($user_info['is_admin']) {
169
+			return;
170
+	}
160 171
 
161 172
 	// Only check the ban every so often. (to reduce load.)
162 173
 	if ($forceCheck || !isset($_SESSION['ban']) || empty($modSettings['banLastUpdated']) || ($_SESSION['ban']['last_checked'] < $modSettings['banLastUpdated']) || $_SESSION['ban']['id_member'] != $user_info['id'] || $_SESSION['ban']['ip'] != $user_info['ip'] || $_SESSION['ban']['ip2'] != $user_info['ip2'] || (isset($user_info['email'], $_SESSION['ban']['email']) && $_SESSION['ban']['email'] != $user_info['email']))
@@ -177,8 +188,9 @@  discard block
 block discarded – undo
177 188
 		// Check both IP addresses.
178 189
 		foreach (array('ip', 'ip2') as $ip_number)
179 190
 		{
180
-			if ($ip_number == 'ip2' && $user_info['ip2'] == $user_info['ip'])
181
-				continue;
191
+			if ($ip_number == 'ip2' && $user_info['ip2'] == $user_info['ip']) {
192
+							continue;
193
+			}
182 194
 			$ban_query[] = ' {inet:' . $ip_number . '} BETWEEN bi.ip_low and bi.ip_high';
183 195
 			$ban_query_vars[$ip_number] = $user_info[$ip_number];
184 196
 			// IP was valid, maybe there's also a hostname...
@@ -228,24 +240,28 @@  discard block
 block discarded – undo
228 240
 			// Store every type of ban that applies to you in your session.
229 241
 			while ($row = $smcFunc['db_fetch_assoc']($request))
230 242
 			{
231
-				foreach ($restrictions as $restriction)
232
-					if (!empty($row[$restriction]))
243
+				foreach ($restrictions as $restriction) {
244
+									if (!empty($row[$restriction]))
233 245
 					{
234 246
 						$_SESSION['ban'][$restriction]['reason'] = $row['reason'];
247
+				}
235 248
 						$_SESSION['ban'][$restriction]['ids'][] = $row['id_ban'];
236
-						if (!isset($_SESSION['ban']['expire_time']) || ($_SESSION['ban']['expire_time'] != 0 && ($row['expire_time'] == 0 || $row['expire_time'] > $_SESSION['ban']['expire_time'])))
237
-							$_SESSION['ban']['expire_time'] = $row['expire_time'];
249
+						if (!isset($_SESSION['ban']['expire_time']) || ($_SESSION['ban']['expire_time'] != 0 && ($row['expire_time'] == 0 || $row['expire_time'] > $_SESSION['ban']['expire_time']))) {
250
+													$_SESSION['ban']['expire_time'] = $row['expire_time'];
251
+						}
238 252
 
239
-						if (!$user_info['is_guest'] && $restriction == 'cannot_access' && ($row['id_member'] == $user_info['id'] || $row['email_address'] == $user_info['email']))
240
-							$flag_is_activated = true;
253
+						if (!$user_info['is_guest'] && $restriction == 'cannot_access' && ($row['id_member'] == $user_info['id'] || $row['email_address'] == $user_info['email'])) {
254
+													$flag_is_activated = true;
255
+						}
241 256
 					}
242 257
 			}
243 258
 			$smcFunc['db_free_result']($request);
244 259
 		}
245 260
 
246 261
 		// Mark the cannot_access and cannot_post bans as being 'hit'.
247
-		if (isset($_SESSION['ban']['cannot_access']) || isset($_SESSION['ban']['cannot_post']) || isset($_SESSION['ban']['cannot_login']))
248
-			log_ban(array_merge(isset($_SESSION['ban']['cannot_access']) ? $_SESSION['ban']['cannot_access']['ids'] : array(), isset($_SESSION['ban']['cannot_post']) ? $_SESSION['ban']['cannot_post']['ids'] : array(), isset($_SESSION['ban']['cannot_login']) ? $_SESSION['ban']['cannot_login']['ids'] : array()));
262
+		if (isset($_SESSION['ban']['cannot_access']) || isset($_SESSION['ban']['cannot_post']) || isset($_SESSION['ban']['cannot_login'])) {
263
+					log_ban(array_merge(isset($_SESSION['ban']['cannot_access']) ? $_SESSION['ban']['cannot_access']['ids'] : array(), isset($_SESSION['ban']['cannot_post']) ? $_SESSION['ban']['cannot_post']['ids'] : array(), isset($_SESSION['ban']['cannot_login']) ? $_SESSION['ban']['cannot_login']['ids'] : array()));
264
+		}
249 265
 
250 266
 		// If for whatever reason the is_activated flag seems wrong, do a little work to clear it up.
251 267
 		if ($user_info['id'] && (($user_settings['is_activated'] >= 10 && !$flag_is_activated)
@@ -260,8 +276,9 @@  discard block
 block discarded – undo
260 276
 	if (!isset($_SESSION['ban']['cannot_access']) && !empty($_COOKIE[$cookiename . '_']))
261 277
 	{
262 278
 		$bans = explode(',', $_COOKIE[$cookiename . '_']);
263
-		foreach ($bans as $key => $value)
264
-			$bans[$key] = (int) $value;
279
+		foreach ($bans as $key => $value) {
280
+					$bans[$key] = (int) $value;
281
+		}
265 282
 		$request = $smcFunc['db_query']('', '
266 283
 			SELECT bi.id_ban, bg.reason, COALESCE(bg.expire_time, 0) AS expire_time
267 284
 			FROM {db_prefix}ban_items AS bi
@@ -298,14 +315,15 @@  discard block
 block discarded – undo
298 315
 	if (isset($_SESSION['ban']['cannot_access']))
299 316
 	{
300 317
 		// We don't wanna see you!
301
-		if (!$user_info['is_guest'])
302
-			$smcFunc['db_query']('', '
318
+		if (!$user_info['is_guest']) {
319
+					$smcFunc['db_query']('', '
303 320
 				DELETE FROM {db_prefix}log_online
304 321
 				WHERE id_member = {int:current_member}',
305 322
 				array(
306 323
 					'current_member' => $user_info['id'],
307 324
 				)
308 325
 			);
326
+		}
309 327
 
310 328
 		// 'Log' the user out.  Can't have any funny business... (save the name!)
311 329
 		$old_name = isset($user_info['name']) && $user_info['name'] != '' ? $user_info['name'] : $txt['guest_title'];
@@ -391,9 +409,10 @@  discard block
 block discarded – undo
391 409
 	}
392 410
 
393 411
 	// Fix up the banning permissions.
394
-	if (isset($user_info['permissions']))
395
-		banPermissions();
396
-}
412
+	if (isset($user_info['permissions'])) {
413
+			banPermissions();
414
+	}
415
+	}
397 416
 
398 417
 /**
399 418
  * Fix permissions according to ban status.
@@ -404,8 +423,9 @@  discard block
 block discarded – undo
404 423
 	global $user_info, $sourcedir, $modSettings, $context;
405 424
 
406 425
 	// Somehow they got here, at least take away all permissions...
407
-	if (isset($_SESSION['ban']['cannot_access']))
408
-		$user_info['permissions'] = array();
426
+	if (isset($_SESSION['ban']['cannot_access'])) {
427
+			$user_info['permissions'] = array();
428
+	}
409 429
 	// Okay, well, you can watch, but don't touch a thing.
410 430
 	elseif (isset($_SESSION['ban']['cannot_post']) || (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $user_info['warning']))
411 431
 	{
@@ -447,19 +467,20 @@  discard block
 block discarded – undo
447 467
 		call_integration_hook('integrate_warn_permissions', array(&$permission_change));
448 468
 		foreach ($permission_change as $old => $new)
449 469
 		{
450
-			if (!in_array($old, $user_info['permissions']))
451
-				unset($permission_change[$old]);
452
-			else
453
-				$user_info['permissions'][] = $new;
470
+			if (!in_array($old, $user_info['permissions'])) {
471
+							unset($permission_change[$old]);
472
+			} else {
473
+							$user_info['permissions'][] = $new;
474
+			}
454 475
 		}
455 476
 		$user_info['permissions'] = array_diff($user_info['permissions'], array_keys($permission_change));
456 477
 	}
457 478
 
458 479
 	// @todo Find a better place to call this? Needs to be after permissions loaded!
459 480
 	// Finally, some bits we cache in the session because it saves queries.
460
-	if (isset($_SESSION['mc']) && $_SESSION['mc']['time'] > $modSettings['settings_updated'] && $_SESSION['mc']['id'] == $user_info['id'])
461
-		$user_info['mod_cache'] = $_SESSION['mc'];
462
-	else
481
+	if (isset($_SESSION['mc']) && $_SESSION['mc']['time'] > $modSettings['settings_updated'] && $_SESSION['mc']['id'] == $user_info['id']) {
482
+			$user_info['mod_cache'] = $_SESSION['mc'];
483
+	} else
463 484
 	{
464 485
 		require_once($sourcedir . '/Subs-Auth.php');
465 486
 		rebuildModCache();
@@ -470,14 +491,12 @@  discard block
 block discarded – undo
470 491
 	{
471 492
 		$context['open_mod_reports'] = $_SESSION['rc']['reports'];
472 493
 		$context['open_member_reports'] = $_SESSION['rc']['member_reports'];
473
-	}
474
-	elseif ($_SESSION['mc']['bq'] != '0=1')
494
+	} elseif ($_SESSION['mc']['bq'] != '0=1')
475 495
 	{
476 496
 		require_once($sourcedir . '/Subs-ReportedContent.php');
477 497
 		$context['open_mod_reports'] = recountOpenReports('posts');
478 498
 		$context['open_member_reports'] = recountOpenReports('members');
479
-	}
480
-	else
499
+	} else
481 500
 	{
482 501
 		$context['open_mod_reports'] = 0;
483 502
 		$context['open_member_reports'] = 0;
@@ -497,8 +516,9 @@  discard block
 block discarded – undo
497 516
 	global $user_info, $smcFunc;
498 517
 
499 518
 	// Don't log web accelerators, it's very confusing...
500
-	if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch')
501
-		return;
519
+	if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') {
520
+			return;
521
+	}
502 522
 
503 523
 	$smcFunc['db_insert']('',
504 524
 		'{db_prefix}log_banned',
@@ -508,8 +528,8 @@  discard block
 block discarded – undo
508 528
 	);
509 529
 
510 530
 	// One extra point for these bans.
511
-	if (!empty($ban_ids))
512
-		$smcFunc['db_query']('', '
531
+	if (!empty($ban_ids)) {
532
+			$smcFunc['db_query']('', '
513 533
 			UPDATE {db_prefix}ban_items
514 534
 			SET hits = hits + 1
515 535
 			WHERE id_ban IN ({array_int:ban_ids})',
@@ -517,7 +537,8 @@  discard block
 block discarded – undo
517 537
 				'ban_ids' => $ban_ids,
518 538
 			)
519 539
 		);
520
-}
540
+	}
541
+	}
521 542
 
522 543
 /**
523 544
  * Checks if a given email address might be banned.
@@ -533,8 +554,9 @@  discard block
 block discarded – undo
533 554
 	global $txt, $smcFunc;
534 555
 
535 556
 	// Can't ban an empty email
536
-	if (empty($email) || trim($email) == '')
537
-		return;
557
+	if (empty($email) || trim($email) == '') {
558
+			return;
559
+	}
538 560
 
539 561
 	// Let's start with the bans based on your IP/hostname/memberID...
540 562
 	$ban_ids = isset($_SESSION['ban'][$restriction]) ? $_SESSION['ban'][$restriction]['ids'] : array();
@@ -607,16 +629,18 @@  discard block
 block discarded – undo
607 629
 	if ($type == 'post')
608 630
 	{
609 631
 		$check = isset($_POST[$_SESSION['session_var']]) ? $_POST[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_POST['sc']) ? $_POST['sc'] : null);
610
-		if ($check !== $sc)
611
-			$error = 'session_timeout';
632
+		if ($check !== $sc) {
633
+					$error = 'session_timeout';
634
+		}
612 635
 	}
613 636
 
614 637
 	// How about $_GET['sesc']?
615 638
 	elseif ($type == 'get')
616 639
 	{
617 640
 		$check = isset($_GET[$_SESSION['session_var']]) ? $_GET[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_GET['sesc']) ? $_GET['sesc'] : null);
618
-		if ($check !== $sc)
619
-			$error = 'session_verify_fail';
641
+		if ($check !== $sc) {
642
+					$error = 'session_verify_fail';
643
+		}
620 644
 	}
621 645
 
622 646
 	// Or can it be in either?
@@ -624,13 +648,15 @@  discard block
 block discarded – undo
624 648
 	{
625 649
 		$check = isset($_GET[$_SESSION['session_var']]) ? $_GET[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_GET['sesc']) ? $_GET['sesc'] : (isset($_POST[$_SESSION['session_var']]) ? $_POST[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_POST['sc']) ? $_POST['sc'] : null)));
626 650
 
627
-		if ($check !== $sc)
628
-			$error = 'session_verify_fail';
651
+		if ($check !== $sc) {
652
+					$error = 'session_verify_fail';
653
+		}
629 654
 	}
630 655
 
631 656
 	// Verify that they aren't changing user agents on us - that could be bad.
632
-	if ((!isset($_SESSION['USER_AGENT']) || $_SESSION['USER_AGENT'] != $_SERVER['HTTP_USER_AGENT']) && empty($modSettings['disableCheckUA']))
633
-		$error = 'session_verify_fail';
657
+	if ((!isset($_SESSION['USER_AGENT']) || $_SESSION['USER_AGENT'] != $_SERVER['HTTP_USER_AGENT']) && empty($modSettings['disableCheckUA'])) {
658
+			$error = 'session_verify_fail';
659
+	}
634 660
 
635 661
 	// Make sure a page with session check requirement is not being prefetched.
636 662
 	if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch')
@@ -641,30 +667,35 @@  discard block
 block discarded – undo
641 667
 	}
642 668
 
643 669
 	// Check the referring site - it should be the same server at least!
644
-	if (isset($_SESSION['request_referer']))
645
-		$referrer = $_SESSION['request_referer'];
646
-	else
647
-		$referrer = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array();
670
+	if (isset($_SESSION['request_referer'])) {
671
+			$referrer = $_SESSION['request_referer'];
672
+	} else {
673
+			$referrer = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array();
674
+	}
648 675
 	if (!empty($referrer['host']))
649 676
 	{
650
-		if (strpos($_SERVER['HTTP_HOST'], ':') !== false)
651
-			$real_host = substr($_SERVER['HTTP_HOST'], 0, strpos($_SERVER['HTTP_HOST'], ':'));
652
-		else
653
-			$real_host = $_SERVER['HTTP_HOST'];
677
+		if (strpos($_SERVER['HTTP_HOST'], ':') !== false) {
678
+					$real_host = substr($_SERVER['HTTP_HOST'], 0, strpos($_SERVER['HTTP_HOST'], ':'));
679
+		} else {
680
+					$real_host = $_SERVER['HTTP_HOST'];
681
+		}
654 682
 
655 683
 		$parsed_url = parse_url($boardurl);
656 684
 
657 685
 		// Are global cookies on?  If so, let's check them ;).
658 686
 		if (!empty($modSettings['globalCookies']))
659 687
 		{
660
-			if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $parsed_url['host'], $parts) == 1)
661
-				$parsed_url['host'] = $parts[1];
688
+			if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $parsed_url['host'], $parts) == 1) {
689
+							$parsed_url['host'] = $parts[1];
690
+			}
662 691
 
663
-			if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $referrer['host'], $parts) == 1)
664
-				$referrer['host'] = $parts[1];
692
+			if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $referrer['host'], $parts) == 1) {
693
+							$referrer['host'] = $parts[1];
694
+			}
665 695
 
666
-			if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $real_host, $parts) == 1)
667
-				$real_host = $parts[1];
696
+			if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $real_host, $parts) == 1) {
697
+							$real_host = $parts[1];
698
+			}
668 699
 		}
669 700
 
670 701
 		// Okay: referrer must either match parsed_url or real_host.
@@ -682,12 +713,14 @@  discard block
 block discarded – undo
682 713
 		$log_error = true;
683 714
 	}
684 715
 
685
-	if (strtolower($_SERVER['HTTP_USER_AGENT']) == 'hacker')
686
-		fatal_error('Sound the alarm!  It\'s a hacker!  Close the castle gates!!', false);
716
+	if (strtolower($_SERVER['HTTP_USER_AGENT']) == 'hacker') {
717
+			fatal_error('Sound the alarm!  It\'s a hacker!  Close the castle gates!!', false);
718
+	}
687 719
 
688 720
 	// Everything is ok, return an empty string.
689
-	if (!isset($error))
690
-		return '';
721
+	if (!isset($error)) {
722
+			return '';
723
+	}
691 724
 	// A session error occurred, show the error.
692 725
 	elseif ($is_fatal)
693 726
 	{
@@ -696,13 +729,14 @@  discard block
 block discarded – undo
696 729
 			ob_end_clean();
697 730
 			send_http_status(403, 'Forbidden - Session timeout');
698 731
 			die;
732
+		} else {
733
+					fatal_lang_error($error, isset($log_error) ? 'user' : false);
699 734
 		}
700
-		else
701
-			fatal_lang_error($error, isset($log_error) ? 'user' : false);
702 735
 	}
703 736
 	// A session error occurred, return the error to the calling function.
704
-	else
705
-		return $error;
737
+	else {
738
+			return $error;
739
+	}
706 740
 
707 741
 	// We really should never fall through here, for very important reasons.  Let's make sure.
708 742
 	trigger_error('Hacking attempt...', E_USER_ERROR);
@@ -718,10 +752,9 @@  discard block
 block discarded – undo
718 752
 {
719 753
 	global $modSettings;
720 754
 
721
-	if (isset($_GET['confirm']) && isset($_SESSION['confirm_' . $action]) && md5($_GET['confirm'] . $_SERVER['HTTP_USER_AGENT']) == $_SESSION['confirm_' . $action])
722
-		return true;
723
-
724
-	else
755
+	if (isset($_GET['confirm']) && isset($_SESSION['confirm_' . $action]) && md5($_GET['confirm'] . $_SERVER['HTTP_USER_AGENT']) == $_SESSION['confirm_' . $action]) {
756
+			return true;
757
+	} else
725 758
 	{
726 759
 		$token = md5(mt_rand() . session_id() . (string) microtime() . $modSettings['rand_seed']);
727 760
 		$_SESSION['confirm_' . $action] = md5($token . $_SERVER['HTTP_USER_AGENT']);
@@ -772,9 +805,9 @@  discard block
 block discarded – undo
772 805
 			$return = $_SESSION['token'][$type . '-' . $action][3];
773 806
 			unset($_SESSION['token'][$type . '-' . $action]);
774 807
 			return $return;
808
+		} else {
809
+					return '';
775 810
 		}
776
-		else
777
-			return '';
778 811
 	}
779 812
 
780 813
 	// This nasty piece of code validates a token.
@@ -805,12 +838,14 @@  discard block
 block discarded – undo
805 838
 		fatal_lang_error('token_verify_fail', false);
806 839
 	}
807 840
 	// Remove this token as its useless
808
-	else
809
-		unset($_SESSION['token'][$type . '-' . $action]);
841
+	else {
842
+			unset($_SESSION['token'][$type . '-' . $action]);
843
+	}
810 844
 
811 845
 	// Randomly check if we should remove some older tokens.
812
-	if (mt_rand(0, 138) == 23)
813
-		cleanTokens();
846
+	if (mt_rand(0, 138) == 23) {
847
+			cleanTokens();
848
+	}
814 849
 
815 850
 	return false;
816 851
 }
@@ -825,14 +860,16 @@  discard block
 block discarded – undo
825 860
 function cleanTokens($complete = false)
826 861
 {
827 862
 	// We appreciate cleaning up after yourselves.
828
-	if (!isset($_SESSION['token']))
829
-		return;
863
+	if (!isset($_SESSION['token'])) {
864
+			return;
865
+	}
830 866
 
831 867
 	// Clean up tokens, trying to give enough time still.
832
-	foreach ($_SESSION['token'] as $key => $data)
833
-		if ($data[2] + 10800 < time() || $complete)
868
+	foreach ($_SESSION['token'] as $key => $data) {
869
+			if ($data[2] + 10800 < time() || $complete)
834 870
 			unset($_SESSION['token'][$key]);
835
-}
871
+	}
872
+	}
836 873
 
837 874
 /**
838 875
  * Check whether a form has been submitted twice.
@@ -850,37 +887,40 @@  discard block
 block discarded – undo
850 887
 {
851 888
 	global $context;
852 889
 
853
-	if (!isset($_SESSION['forms']))
854
-		$_SESSION['forms'] = array();
890
+	if (!isset($_SESSION['forms'])) {
891
+			$_SESSION['forms'] = array();
892
+	}
855 893
 
856 894
 	// Register a form number and store it in the session stack. (use this on the page that has the form.)
857 895
 	if ($action == 'register')
858 896
 	{
859 897
 		$context['form_sequence_number'] = 0;
860
-		while (empty($context['form_sequence_number']) || in_array($context['form_sequence_number'], $_SESSION['forms']))
861
-			$context['form_sequence_number'] = mt_rand(1, 16000000);
898
+		while (empty($context['form_sequence_number']) || in_array($context['form_sequence_number'], $_SESSION['forms'])) {
899
+					$context['form_sequence_number'] = mt_rand(1, 16000000);
900
+		}
862 901
 	}
863 902
 	// Check whether the submitted number can be found in the session.
864 903
 	elseif ($action == 'check')
865 904
 	{
866
-		if (!isset($_REQUEST['seqnum']))
867
-			return true;
868
-		elseif (!in_array($_REQUEST['seqnum'], $_SESSION['forms']))
905
+		if (!isset($_REQUEST['seqnum'])) {
906
+					return true;
907
+		} elseif (!in_array($_REQUEST['seqnum'], $_SESSION['forms']))
869 908
 		{
870 909
 			$_SESSION['forms'][] = (int) $_REQUEST['seqnum'];
871 910
 			return true;
911
+		} elseif ($is_fatal) {
912
+					fatal_lang_error('error_form_already_submitted', false);
913
+		} else {
914
+					return false;
872 915
 		}
873
-		elseif ($is_fatal)
874
-			fatal_lang_error('error_form_already_submitted', false);
875
-		else
876
-			return false;
877 916
 	}
878 917
 	// Don't check, just free the stack number.
879
-	elseif ($action == 'free' && isset($_REQUEST['seqnum']) && in_array($_REQUEST['seqnum'], $_SESSION['forms']))
880
-		$_SESSION['forms'] = array_diff($_SESSION['forms'], array($_REQUEST['seqnum']));
881
-	elseif ($action != 'free')
882
-		trigger_error('checkSubmitOnce(): Invalid action \'' . $action . '\'', E_USER_WARNING);
883
-}
918
+	elseif ($action == 'free' && isset($_REQUEST['seqnum']) && in_array($_REQUEST['seqnum'], $_SESSION['forms'])) {
919
+			$_SESSION['forms'] = array_diff($_SESSION['forms'], array($_REQUEST['seqnum']));
920
+	} elseif ($action != 'free') {
921
+			trigger_error('checkSubmitOnce(): Invalid action \'' . $action . '\'', E_USER_WARNING);
922
+	}
923
+	}
884 924
 
885 925
 /**
886 926
  * Check the user's permissions.
@@ -899,16 +939,19 @@  discard block
 block discarded – undo
899 939
 	global $user_info, $smcFunc;
900 940
 
901 941
 	// You're always allowed to do nothing. (unless you're a working man, MR. LAZY :P!)
902
-	if (empty($permission))
903
-		return true;
942
+	if (empty($permission)) {
943
+			return true;
944
+	}
904 945
 
905 946
 	// You're never allowed to do something if your data hasn't been loaded yet!
906
-	if (empty($user_info))
907
-		return false;
947
+	if (empty($user_info)) {
948
+			return false;
949
+	}
908 950
 
909 951
 	// Administrators are supermen :P.
910
-	if ($user_info['is_admin'])
911
-		return true;
952
+	if ($user_info['is_admin']) {
953
+			return true;
954
+	}
912 955
 
913 956
 	// Let's ensure this is an array.
914 957
 	$permission = (array) $permission;
@@ -916,14 +959,16 @@  discard block
 block discarded – undo
916 959
 	// Are we checking the _current_ board, or some other boards?
917 960
 	if ($boards === null)
918 961
 	{
919
-		if (count(array_intersect($permission, $user_info['permissions'])) != 0)
920
-			return true;
962
+		if (count(array_intersect($permission, $user_info['permissions'])) != 0) {
963
+					return true;
964
+		}
921 965
 		// You aren't allowed, by default.
922
-		else
923
-			return false;
966
+		else {
967
+					return false;
968
+		}
969
+	} elseif (!is_array($boards)) {
970
+			$boards = array($boards);
924 971
 	}
925
-	elseif (!is_array($boards))
926
-		$boards = array($boards);
927 972
 
928 973
 	$request = $smcFunc['db_query']('', '
929 974
 		SELECT MIN(bp.add_deny) AS add_deny
@@ -951,20 +996,23 @@  discard block
 block discarded – undo
951 996
 		while ($row = $smcFunc['db_fetch_assoc']($request))
952 997
 		{
953 998
 			$result = !empty($row['add_deny']);
954
-			if ($result == true)
955
-				break;
999
+			if ($result == true) {
1000
+							break;
1001
+			}
956 1002
 		}
957 1003
 		$smcFunc['db_free_result']($request);
958 1004
 		return $result;
959 1005
 	}
960 1006
 
961 1007
 	// Make sure they can do it on all of the boards.
962
-	if ($smcFunc['db_num_rows']($request) != count($boards))
963
-		return false;
1008
+	if ($smcFunc['db_num_rows']($request) != count($boards)) {
1009
+			return false;
1010
+	}
964 1011
 
965 1012
 	$result = true;
966
-	while ($row = $smcFunc['db_fetch_assoc']($request))
967
-		$result &= !empty($row['add_deny']);
1013
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1014
+			$result &= !empty($row['add_deny']);
1015
+	}
968 1016
 	$smcFunc['db_free_result']($request);
969 1017
 
970 1018
 	// If the query returned 1, they can do it... otherwise, they can't.
@@ -1031,9 +1079,10 @@  discard block
 block discarded – undo
1031 1079
 
1032 1080
 	// If you're doing something on behalf of some "heavy" permissions, validate your session.
1033 1081
 	// (take out the heavy permissions, and if you can't do anything but those, you need a validated session.)
1034
-	if (!allowedTo(array_diff($permission, $heavy_permissions), $boards))
1035
-		validateSession();
1036
-}
1082
+	if (!allowedTo(array_diff($permission, $heavy_permissions), $boards)) {
1083
+			validateSession();
1084
+	}
1085
+	}
1037 1086
 
1038 1087
 /**
1039 1088
  * Return the boards a user has a certain (board) permission on. (array(0) if all.)
@@ -1064,13 +1113,14 @@  discard block
 block discarded – undo
1064 1113
 	// Administrators are all powerful, sorry.
1065 1114
 	if ($user_info['is_admin'])
1066 1115
 	{
1067
-		if ($simple)
1068
-			return array(0);
1069
-		else
1116
+		if ($simple) {
1117
+					return array(0);
1118
+		} else
1070 1119
 		{
1071 1120
 			$boards = array();
1072
-			foreach ($permissions as $permission)
1073
-				$boards[$permission] = array(0);
1121
+			foreach ($permissions as $permission) {
1122
+							$boards[$permission] = array(0);
1123
+			}
1074 1124
 
1075 1125
 			return $boards;
1076 1126
 		}
@@ -1102,31 +1152,32 @@  discard block
 block discarded – undo
1102 1152
 	{
1103 1153
 		if ($simple)
1104 1154
 		{
1105
-			if (empty($row['add_deny']))
1106
-				$deny_boards[] = $row['id_board'];
1107
-			else
1108
-				$boards[] = $row['id_board'];
1109
-		}
1110
-		else
1155
+			if (empty($row['add_deny'])) {
1156
+							$deny_boards[] = $row['id_board'];
1157
+			} else {
1158
+							$boards[] = $row['id_board'];
1159
+			}
1160
+		} else
1111 1161
 		{
1112
-			if (empty($row['add_deny']))
1113
-				$deny_boards[$row['permission']][] = $row['id_board'];
1114
-			else
1115
-				$boards[$row['permission']][] = $row['id_board'];
1162
+			if (empty($row['add_deny'])) {
1163
+							$deny_boards[$row['permission']][] = $row['id_board'];
1164
+			} else {
1165
+							$boards[$row['permission']][] = $row['id_board'];
1166
+			}
1116 1167
 		}
1117 1168
 	}
1118 1169
 	$smcFunc['db_free_result']($request);
1119 1170
 
1120
-	if ($simple)
1121
-		$boards = array_unique(array_values(array_diff($boards, $deny_boards)));
1122
-	else
1171
+	if ($simple) {
1172
+			$boards = array_unique(array_values(array_diff($boards, $deny_boards)));
1173
+	} else
1123 1174
 	{
1124 1175
 		foreach ($permissions as $permission)
1125 1176
 		{
1126 1177
 			// never had it to start with
1127
-			if (empty($boards[$permission]))
1128
-				$boards[$permission] = array();
1129
-			else
1178
+			if (empty($boards[$permission])) {
1179
+							$boards[$permission] = array();
1180
+			} else
1130 1181
 			{
1131 1182
 				// Or it may have been removed
1132 1183
 				$deny_boards[$permission] = isset($deny_boards[$permission]) ? $deny_boards[$permission] : array();
@@ -1162,10 +1213,11 @@  discard block
 block discarded – undo
1162 1213
 
1163 1214
 
1164 1215
 	// Moderators are free...
1165
-	if (!allowedTo('moderate_board'))
1166
-		$timeLimit = isset($timeOverrides[$error_type]) ? $timeOverrides[$error_type] : $modSettings['spamWaitTime'];
1167
-	else
1168
-		$timeLimit = 2;
1216
+	if (!allowedTo('moderate_board')) {
1217
+			$timeLimit = isset($timeOverrides[$error_type]) ? $timeOverrides[$error_type] : $modSettings['spamWaitTime'];
1218
+	} else {
1219
+			$timeLimit = 2;
1220
+	}
1169 1221
 
1170 1222
 	call_integration_hook('integrate_spam_protection', array(&$timeOverrides, &$timeLimit));
1171 1223
 
@@ -1192,8 +1244,9 @@  discard block
 block discarded – undo
1192 1244
 	if ($smcFunc['db_affected_rows']() != 1)
1193 1245
 	{
1194 1246
 		// Spammer!  You only have to wait a *few* seconds!
1195
-		if (!$only_return_result)
1196
-			fatal_lang_error($error_type . '_WaitTime_broken', false, array($timeLimit));
1247
+		if (!$only_return_result) {
1248
+					fatal_lang_error($error_type . '_WaitTime_broken', false, array($timeLimit));
1249
+		}
1197 1250
 
1198 1251
 		return true;
1199 1252
 	}
@@ -1211,11 +1264,13 @@  discard block
 block discarded – undo
1211 1264
  */
1212 1265
 function secureDirectory($path, $attachments = false)
1213 1266
 {
1214
-	if (empty($path))
1215
-		return 'empty_path';
1267
+	if (empty($path)) {
1268
+			return 'empty_path';
1269
+	}
1216 1270
 
1217
-	if (!is_writable($path))
1218
-		return 'path_not_writable';
1271
+	if (!is_writable($path)) {
1272
+			return 'path_not_writable';
1273
+	}
1219 1274
 
1220 1275
 	$directoryname = basename($path);
1221 1276
 
@@ -1227,9 +1282,9 @@  discard block
 block discarded – undo
1227 1282
 
1228 1283
 RemoveHandler .php .php3 .phtml .cgi .fcgi .pl .fpl .shtml';
1229 1284
 
1230
-	if (file_exists($path . '/.htaccess'))
1231
-		$errors[] = 'htaccess_exists';
1232
-	else
1285
+	if (file_exists($path . '/.htaccess')) {
1286
+			$errors[] = 'htaccess_exists';
1287
+	} else
1233 1288
 	{
1234 1289
 		$fh = @fopen($path . '/.htaccess', 'w');
1235 1290
 		if ($fh)
@@ -1242,9 +1297,9 @@  discard block
 block discarded – undo
1242 1297
 		$errors[] = 'htaccess_cannot_create_file';
1243 1298
 	}
1244 1299
 
1245
-	if (file_exists($path . '/index.php'))
1246
-		$errors[] = 'index-php_exists';
1247
-	else
1300
+	if (file_exists($path . '/index.php')) {
1301
+			$errors[] = 'index-php_exists';
1302
+	} else
1248 1303
 	{
1249 1304
 		$fh = @fopen($path . '/index.php', 'w');
1250 1305
 		if ($fh)
@@ -1272,11 +1327,12 @@  discard block
 block discarded – undo
1272 1327
 		$errors[] = 'index-php_cannot_create_file';
1273 1328
 	}
1274 1329
 
1275
-	if (!empty($errors))
1276
-		return $errors;
1277
-	else
1278
-		return true;
1279
-}
1330
+	if (!empty($errors)) {
1331
+			return $errors;
1332
+	} else {
1333
+			return true;
1334
+	}
1335
+	}
1280 1336
 
1281 1337
 /**
1282 1338
 * This sets the X-Frame-Options header.
@@ -1289,14 +1345,16 @@  discard block
 block discarded – undo
1289 1345
 	global $modSettings;
1290 1346
 
1291 1347
 	$option = 'SAMEORIGIN';
1292
-	if (is_null($override) && !empty($modSettings['frame_security']))
1293
-		$option = $modSettings['frame_security'];
1294
-	elseif (in_array($override, array('SAMEORIGIN', 'DENY')))
1295
-		$option = $override;
1348
+	if (is_null($override) && !empty($modSettings['frame_security'])) {
1349
+			$option = $modSettings['frame_security'];
1350
+	} elseif (in_array($override, array('SAMEORIGIN', 'DENY'))) {
1351
+			$option = $override;
1352
+	}
1296 1353
 
1297 1354
 	// Don't bother setting the header if we have disabled it.
1298
-	if ($option == 'DISABLE')
1299
-		return;
1355
+	if ($option == 'DISABLE') {
1356
+			return;
1357
+	}
1300 1358
 
1301 1359
 	// Finally set it.
1302 1360
 	header('x-frame-options: ' . $option);
Please login to merge, or discard this patch.
Sources/Display.php 1 patch
Braces   +298 added lines, -219 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
  * The central part of the board - topic display.
@@ -34,8 +35,9 @@  discard block
 block discarded – undo
34 35
 	global $messages_request, $language, $smcFunc;
35 36
 
36 37
 	// What are you gonna display if these are empty?!
37
-	if (empty($topic))
38
-		fatal_lang_error('no_board', false);
38
+	if (empty($topic)) {
39
+			fatal_lang_error('no_board', false);
40
+	}
39 41
 
40 42
 	// Load the proper template.
41 43
 	loadTemplate('Display');
@@ -52,15 +54,17 @@  discard block
 block discarded – undo
52 54
 	$context['messages_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages'];
53 55
 
54 56
 	// Let's do some work on what to search index.
55
-	if (count($_GET) > 2)
56
-		foreach ($_GET as $k => $v)
57
+	if (count($_GET) > 2) {
58
+			foreach ($_GET as $k => $v)
57 59
 		{
58 60
 			if (!in_array($k, array('topic', 'board', 'start', session_name())))
59 61
 				$context['robot_no_index'] = true;
62
+	}
60 63
 		}
61 64
 
62
-	if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0))
63
-		$context['robot_no_index'] = true;
65
+	if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) {
66
+			$context['robot_no_index'] = true;
67
+	}
64 68
 
65 69
 	// Find the previous or next topic.  Make a fuss if there are no more.
66 70
 	if (isset($_REQUEST['prev_next']) && ($_REQUEST['prev_next'] == 'prev' || $_REQUEST['prev_next'] == 'next'))
@@ -172,8 +176,9 @@  discard block
 block discarded – undo
172 176
 			$topic_parameters
173 177
 	);
174 178
 
175
-	if ($smcFunc['db_num_rows']($request) == 0)
176
-		fatal_lang_error('not_a_topic', false, 404);
179
+	if ($smcFunc['db_num_rows']($request) == 0) {
180
+			fatal_lang_error('not_a_topic', false, 404);
181
+	}
177 182
 	$context['topicinfo'] = $smcFunc['db_fetch_assoc']($request);
178 183
 	$smcFunc['db_free_result']($request);
179 184
 
@@ -210,8 +215,9 @@  discard block
 block discarded – undo
210 215
 	$context['topic_unwatched'] = isset($context['topicinfo']['unwatched']) ? $context['topicinfo']['unwatched'] : 0;
211 216
 
212 217
 	// Add up unapproved replies to get real number of replies...
213
-	if ($modSettings['postmod_active'] && $approve_posts)
214
-		$context['real_num_replies'] += $context['topicinfo']['unapproved_posts'] - ($context['topicinfo']['approved'] ? 0 : 1);
218
+	if ($modSettings['postmod_active'] && $approve_posts) {
219
+			$context['real_num_replies'] += $context['topicinfo']['unapproved_posts'] - ($context['topicinfo']['approved'] ? 0 : 1);
220
+	}
215 221
 
216 222
 	// If this topic has unapproved posts, we need to work out how many posts the user can see, for page indexing.
217 223
 	if ($modSettings['postmod_active'] && $context['topicinfo']['unapproved_posts'] && !$user_info['is_guest'] && !$approve_posts)
@@ -231,11 +237,11 @@  discard block
 block discarded – undo
231 237
 		$smcFunc['db_free_result']($request);
232 238
 
233 239
 		$context['total_visible_posts'] = $context['num_replies'] + $myUnapprovedPosts + ($context['topicinfo']['approved'] ? 1 : 0);
240
+	} elseif ($user_info['is_guest']) {
241
+			$context['total_visible_posts'] = $context['num_replies'] + ($context['topicinfo']['approved'] ? 1 : 0);
242
+	} else {
243
+			$context['total_visible_posts'] = $context['num_replies'] + $context['topicinfo']['unapproved_posts'] + ($context['topicinfo']['approved'] ? 1 : 0);
234 244
 	}
235
-	elseif ($user_info['is_guest'])
236
-		$context['total_visible_posts'] = $context['num_replies'] + ($context['topicinfo']['approved'] ? 1 : 0);
237
-	else
238
-		$context['total_visible_posts'] = $context['num_replies'] + $context['topicinfo']['unapproved_posts'] + ($context['topicinfo']['approved'] ? 1 : 0);
239 245
 
240 246
 	// The start isn't a number; it's information about what to do, where to go.
241 247
 	if (!is_numeric($_REQUEST['start']))
@@ -248,8 +254,7 @@  discard block
 block discarded – undo
248 254
 			{
249 255
 				$context['start_from'] = $context['total_visible_posts'] - 1;
250 256
 				$_REQUEST['start'] = empty($options['view_newest_first']) ? $context['start_from'] : 0;
251
-			}
252
-			else
257
+			} else
253 258
 			{
254 259
 				// Find the earliest unread message in the topic. (the use of topics here is just for both tables.)
255 260
 				$request = $smcFunc['db_query']('', '
@@ -277,9 +282,9 @@  discard block
 block discarded – undo
277 282
 		if (substr($_REQUEST['start'], 0, 4) == 'from')
278 283
 		{
279 284
 			$timestamp = (int) substr($_REQUEST['start'], 4);
280
-			if ($timestamp === 0)
281
-				$_REQUEST['start'] = 0;
282
-			else
285
+			if ($timestamp === 0) {
286
+							$_REQUEST['start'] = 0;
287
+			} else
283 288
 			{
284 289
 				// Find the number of messages posted before said time...
285 290
 				$request = $smcFunc['db_query']('', '
@@ -307,11 +312,11 @@  discard block
 block discarded – undo
307 312
 		elseif (substr($_REQUEST['start'], 0, 3) == 'msg')
308 313
 		{
309 314
 			$virtual_msg = (int) substr($_REQUEST['start'], 3);
310
-			if (!$context['topicinfo']['unapproved_posts'] && $virtual_msg >= $context['topicinfo']['id_last_msg'])
311
-				$context['start_from'] = $context['total_visible_posts'] - 1;
312
-			elseif (!$context['topicinfo']['unapproved_posts'] && $virtual_msg <= $context['topicinfo']['id_first_msg'])
313
-				$context['start_from'] = 0;
314
-			else
315
+			if (!$context['topicinfo']['unapproved_posts'] && $virtual_msg >= $context['topicinfo']['id_last_msg']) {
316
+							$context['start_from'] = $context['total_visible_posts'] - 1;
317
+			} elseif (!$context['topicinfo']['unapproved_posts'] && $virtual_msg <= $context['topicinfo']['id_first_msg']) {
318
+							$context['start_from'] = 0;
319
+			} else
315 320
 			{
316 321
 				// Find the start value for that message......
317 322
 				$request = $smcFunc['db_query']('', '
@@ -365,9 +370,10 @@  discard block
 block discarded – undo
365 370
 		list ($sig_limits, $sig_bbc) = explode(':', $modSettings['signature_settings']);
366 371
 		$sig_limits = explode(',', $sig_limits);
367 372
 
368
-		if (!empty($sig_limits[5]) || !empty($sig_limits[6]))
369
-			addInlineCss('
373
+		if (!empty($sig_limits[5]) || !empty($sig_limits[6])) {
374
+					addInlineCss('
370 375
 	.signature img { ' . (!empty($sig_limits[5]) ? 'max-width: ' . (int) $sig_limits[5] . 'px; ' : '') . (!empty($sig_limits[6]) ? 'max-height: ' . (int) $sig_limits[6] . 'px; ' : '') . '}');
376
+		}
371 377
 	}
372 378
 
373 379
 	// Censor the title...
@@ -405,21 +411,25 @@  discard block
 block discarded – undo
405 411
 		);
406 412
 		while ($row = $smcFunc['db_fetch_assoc']($request))
407 413
 		{
408
-			if (empty($row['id_member']))
409
-				continue;
414
+			if (empty($row['id_member'])) {
415
+							continue;
416
+			}
410 417
 
411
-			if (!empty($row['online_color']))
412
-				$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>';
413
-			else
414
-				$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
418
+			if (!empty($row['online_color'])) {
419
+							$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>';
420
+			} else {
421
+							$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
422
+			}
415 423
 
416 424
 			$is_buddy = in_array($row['id_member'], $user_info['buddies']);
417
-			if ($is_buddy)
418
-				$link = '<strong>' . $link . '</strong>';
425
+			if ($is_buddy) {
426
+							$link = '<strong>' . $link . '</strong>';
427
+			}
419 428
 
420 429
 			// Add them both to the list and to the more detailed list.
421
-			if (!empty($row['show_online']) || allowedTo('moderate_forum'))
422
-				$context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link;
430
+			if (!empty($row['show_online']) || allowedTo('moderate_forum')) {
431
+							$context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link;
432
+			}
423 433
 			$context['view_members'][$row['log_time'] . $row['member_name']] = array(
424 434
 				'id' => $row['id_member'],
425 435
 				'username' => $row['member_name'],
@@ -431,8 +441,9 @@  discard block
 block discarded – undo
431 441
 				'hidden' => empty($row['show_online']),
432 442
 			);
433 443
 
434
-			if (empty($row['show_online']))
435
-				$context['view_num_hidden']++;
444
+			if (empty($row['show_online'])) {
445
+							$context['view_num_hidden']++;
446
+			}
436 447
 		}
437 448
 
438 449
 		// The number of guests is equal to the rows minus the ones we actually used ;).
@@ -446,11 +457,13 @@  discard block
 block discarded – undo
446 457
 
447 458
 	// If all is set, but not allowed... just unset it.
448 459
 	$can_show_all = !empty($modSettings['enableAllMessages']) && $context['total_visible_posts'] > $context['messages_per_page'] && $context['total_visible_posts'] < $modSettings['enableAllMessages'];
449
-	if (isset($_REQUEST['all']) && !$can_show_all)
450
-		unset($_REQUEST['all']);
460
+	if (isset($_REQUEST['all']) && !$can_show_all) {
461
+			unset($_REQUEST['all']);
462
+	}
451 463
 	// Otherwise, it must be allowed... so pretend start was -1.
452
-	elseif (isset($_REQUEST['all']))
453
-		$_REQUEST['start'] = -1;
464
+	elseif (isset($_REQUEST['all'])) {
465
+			$_REQUEST['start'] = -1;
466
+	}
454 467
 
455 468
 	// Construct the page index, allowing for the .START method...
456 469
 	$context['page_index'] = constructPageIndex($scripturl . '?topic=' . $topic . '.%1$d', $_REQUEST['start'], $context['total_visible_posts'], $context['messages_per_page'], true);
@@ -487,8 +500,9 @@  discard block
 block discarded – undo
487 500
 			$_REQUEST['start'] = 0;
488 501
 		}
489 502
 		// They aren't using it, but the *option* is there, at least.
490
-		else
491
-			$context['page_index'] .= '&nbsp;<a href="' . $scripturl . '?topic=' . $topic . '.0;all">' . $txt['all'] . '</a> ';
503
+		else {
504
+					$context['page_index'] .= '&nbsp;<a href="' . $scripturl . '?topic=' . $topic . '.0;all">' . $txt['all'] . '</a> ';
505
+		}
492 506
 	}
493 507
 
494 508
 	// Build the link tree.
@@ -504,14 +518,16 @@  discard block
 block discarded – undo
504 518
 	if (!empty($board_info['moderators']))
505 519
 	{
506 520
 		// Add a link for each moderator...
507
-		foreach ($board_info['moderators'] as $mod)
508
-			$context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>';
521
+		foreach ($board_info['moderators'] as $mod) {
522
+					$context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>';
523
+		}
509 524
 	}
510 525
 	if (!empty($board_info['moderator_groups']))
511 526
 	{
512 527
 		// Add a link for each moderator group as well...
513
-		foreach ($board_info['moderator_groups'] as $mod_group)
514
-			$context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=viewmemberes;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>';
528
+		foreach ($board_info['moderator_groups'] as $mod_group) {
529
+					$context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=viewmemberes;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>';
530
+		}
515 531
 	}
516 532
 
517 533
 	if (!empty($context['link_moderators']))
@@ -542,9 +558,9 @@  discard block
 block discarded – undo
542 558
 	// For quick reply we need a response prefix in the default forum language.
543 559
 	if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix', 600)))
544 560
 	{
545
-		if ($language === $user_info['language'])
546
-			$context['response_prefix'] = $txt['response_prefix'];
547
-		else
561
+		if ($language === $user_info['language']) {
562
+					$context['response_prefix'] = $txt['response_prefix'];
563
+		} else
548 564
 		{
549 565
 			loadLanguage('index', $language, false);
550 566
 			$context['response_prefix'] = $txt['response_prefix'];
@@ -576,8 +592,9 @@  discard block
 block discarded – undo
576 592
 			list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row);
577 593
 
578 594
 			// Sanity check
579
-			if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count']))
580
-				continue;
595
+			if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) {
596
+							continue;
597
+			}
581 598
 
582 599
 			$linked_calendar_event = array(
583 600
 				'id' => $row['id_event'],
@@ -626,8 +643,9 @@  discard block
 block discarded – undo
626 643
 		}
627 644
 		$smcFunc['db_free_result']($request);
628 645
 
629
-		if (!empty($context['linked_calendar_events']))
630
-			$context['linked_calendar_events'][count($context['linked_calendar_events']) - 1]['is_last'] = true;
646
+		if (!empty($context['linked_calendar_events'])) {
647
+					$context['linked_calendar_events'][count($context['linked_calendar_events']) - 1]['is_last'] = true;
648
+		}
631 649
 	}
632 650
 
633 651
 	// Create the poll info if it exists.
@@ -651,9 +669,9 @@  discard block
 block discarded – undo
651 669
 	}
652 670
 
653 671
 	// Create the poll info if it exists and is valid.
654
-	if ($context['is_poll'] && empty($pollinfo))
655
-		$context['is_poll'] = false;
656
-	elseif ($context['is_poll'])
672
+	if ($context['is_poll'] && empty($pollinfo)) {
673
+			$context['is_poll'] = false;
674
+	} elseif ($context['is_poll'])
657 675
 	{
658 676
 		$request = $smcFunc['db_query']('', '
659 677
 			SELECT COUNT(DISTINCT id_member) AS total
@@ -696,8 +714,9 @@  discard block
 block discarded – undo
696 714
 		$smcFunc['db_free_result']($request);
697 715
 
698 716
 		// Got we multi choice?
699
-		if ($pollinfo['max_votes'] > 1)
700
-			$realtotal = $pollinfo['total'];
717
+		if ($pollinfo['max_votes'] > 1) {
718
+					$realtotal = $pollinfo['total'];
719
+		}
701 720
 
702 721
 		// If this is a guest we need to do our best to work out if they have voted, and what they voted for.
703 722
 		if ($user_info['is_guest'] && $pollinfo['guest_vote'] && allowedTo('poll_vote'))
@@ -710,20 +729,21 @@  discard block
 block discarded – undo
710 729
 				foreach ($guestinfo as $i => $guestvoted)
711 730
 				{
712 731
 					$guestvoted = explode(',', $guestvoted);
713
-					if ($guestvoted[0] == $context['topicinfo']['id_poll'])
714
-						break;
732
+					if ($guestvoted[0] == $context['topicinfo']['id_poll']) {
733
+											break;
734
+					}
715 735
 				}
716 736
 				// Has the poll been reset since guest voted?
717 737
 				if ($pollinfo['reset_poll'] > $guestvoted[1])
718 738
 				{
719 739
 					// Remove the poll info from the cookie to allow guest to vote again
720 740
 					unset($guestinfo[$i]);
721
-					if (!empty($guestinfo))
722
-						$_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo);
723
-					else
724
-						unset($_COOKIE['guest_poll_vote']);
725
-				}
726
-				else
741
+					if (!empty($guestinfo)) {
742
+											$_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo);
743
+					} else {
744
+											unset($_COOKIE['guest_poll_vote']);
745
+					}
746
+				} else
727 747
 				{
728 748
 					// What did they vote for?
729 749
 					unset($guestvoted[0], $guestvoted[1]);
@@ -837,23 +857,29 @@  discard block
 block discarded – undo
837 857
 		// Build the poll moderation button array.
838 858
 		$context['poll_buttons'] = array();
839 859
 
840
-		if ($context['allow_return_vote'])
841
-			$context['poll_buttons']['vote'] = array('text' => 'poll_return_vote', 'image' => 'poll_options.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']);
860
+		if ($context['allow_return_vote']) {
861
+					$context['poll_buttons']['vote'] = array('text' => 'poll_return_vote', 'image' => 'poll_options.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']);
862
+		}
842 863
 
843
-		if ($context['show_view_results_button'])
844
-			$context['poll_buttons']['results'] = array('text' => 'poll_results', 'image' => 'poll_results.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults');
864
+		if ($context['show_view_results_button']) {
865
+					$context['poll_buttons']['results'] = array('text' => 'poll_results', 'image' => 'poll_results.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults');
866
+		}
845 867
 
846
-		if ($context['allow_change_vote'])
847
-			$context['poll_buttons']['change_vote'] = array('text' => 'poll_change_vote', 'image' => 'poll_change_vote.png', 'url' => $scripturl . '?action=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . ';' . $context['session_var'] . '=' . $context['session_id']);
868
+		if ($context['allow_change_vote']) {
869
+					$context['poll_buttons']['change_vote'] = array('text' => 'poll_change_vote', 'image' => 'poll_change_vote.png', 'url' => $scripturl . '?action=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . ';' . $context['session_var'] . '=' . $context['session_id']);
870
+		}
848 871
 
849
-		if ($context['allow_lock_poll'])
850
-			$context['poll_buttons']['lock'] = array('text' => (!$context['poll']['is_locked'] ? 'poll_lock' : 'poll_unlock'), 'image' => 'poll_lock.png', 'url' => $scripturl . '?action=lockvoting;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
872
+		if ($context['allow_lock_poll']) {
873
+					$context['poll_buttons']['lock'] = array('text' => (!$context['poll']['is_locked'] ? 'poll_lock' : 'poll_unlock'), 'image' => 'poll_lock.png', 'url' => $scripturl . '?action=lockvoting;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
874
+		}
851 875
 
852
-		if ($context['allow_edit_poll'])
853
-			$context['poll_buttons']['edit'] = array('text' => 'poll_edit', 'image' => 'poll_edit.png', 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']);
876
+		if ($context['allow_edit_poll']) {
877
+					$context['poll_buttons']['edit'] = array('text' => 'poll_edit', 'image' => 'poll_edit.png', 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']);
878
+		}
854 879
 
855
-		if ($context['can_remove_poll'])
856
-			$context['poll_buttons']['remove_poll'] = array('text' => 'poll_remove', 'image' => 'admin_remove_poll.png', 'custom' => 'data-confirm="' . $txt['poll_remove_warn'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removepoll;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
880
+		if ($context['can_remove_poll']) {
881
+					$context['poll_buttons']['remove_poll'] = array('text' => 'poll_remove', 'image' => 'admin_remove_poll.png', 'custom' => 'data-confirm="' . $txt['poll_remove_warn'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removepoll;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
882
+		}
857 883
 
858 884
 		// Allow mods to add additional buttons here
859 885
 		call_integration_hook('integrate_poll_buttons');
@@ -889,9 +915,9 @@  discard block
 block discarded – undo
889 915
 	{
890 916
 		$start_char = 'C';
891 917
 		$page_id = $ascending ? $context['topicinfo']['id_first_msg'] : $context['topicinfo']['id_last_msg'];
918
+	} else {
919
+			$start_char = null;
892 920
 	}
893
-	else
894
-		$start_char = null;
895 921
 
896 922
 	$limit = $context['messages_per_page'];
897 923
 
@@ -905,17 +931,17 @@  discard block
 block discarded – undo
905 931
 		{
906 932
 			$ascending_seek = true;
907 933
 			$page_operator = $ascending ? '>=' : '<=';
908
-		}
909
-		else
934
+		} else
910 935
 		{
911 936
 			$ascending_seek = false;
912 937
 			$page_operator = $ascending ? '<=' : '>=';
913 938
 		}
914 939
 
915
-		if ($start_char === 'C')
916
-			$limit_seek = $limit;
917
-		else
918
-			$limit_seek  = $limit + 1;
940
+		if ($start_char === 'C') {
941
+					$limit_seek = $limit;
942
+		} else {
943
+					$limit_seek  = $limit + 1;
944
+		}
919 945
 
920 946
 		$request = $smcFunc['db_query']('', '
921 947
 			SELECT id_msg, id_member, approved
@@ -938,21 +964,23 @@  discard block
 block discarded – undo
938 964
 		$found_msg = false;
939 965
 
940 966
 		// Fallback
941
-		if ($smcFunc['db_num_rows']($request) < 1)
942
-			unset($start_char);
943
-		else
967
+		if ($smcFunc['db_num_rows']($request) < 1) {
968
+					unset($start_char);
969
+		} else
944 970
 		{
945 971
 			while ($row = $smcFunc['db_fetch_assoc']($request))
946 972
 			{
947 973
 				// Check if the start msg is in our result
948
-				if ($row['id_msg'] == $page_id)
949
-					$found_msg = true;
974
+				if ($row['id_msg'] == $page_id) {
975
+									$found_msg = true;
976
+				}
950 977
 
951 978
 				// Skip the the start msg if we not in mode C
952 979
 				if ($start_char === 'C' || $row['id_msg'] != $page_id)
953 980
 				{
954
-					if (!empty($row['id_member']))
955
-						$all_posters[$row['id_msg']] = $row['id_member'];
981
+					if (!empty($row['id_member'])) {
982
+											$all_posters[$row['id_msg']] = $row['id_member'];
983
+					}
956 984
 
957 985
 					$messages[] = $row['id_msg'];
958 986
 				}
@@ -968,8 +996,9 @@  discard block
 block discarded – undo
968 996
 		}
969 997
 
970 998
 		// Before Page bring in the right order
971
-		if (!empty($start_char) && $start_char === 'L')
972
-			krsort($messages);
999
+		if (!empty($start_char) && $start_char === 'L') {
1000
+					krsort($messages);
1001
+		}
973 1002
 	}
974 1003
 
975 1004
 	// Jump to page
@@ -1004,14 +1033,16 @@  discard block
 block discarded – undo
1004 1033
 
1005 1034
 		while ($row = $smcFunc['db_fetch_assoc']($request))
1006 1035
 		{
1007
-			if (!empty($row['id_member']))
1008
-				$all_posters[$row['id_msg']] = $row['id_member'];
1036
+			if (!empty($row['id_member'])) {
1037
+							$all_posters[$row['id_msg']] = $row['id_member'];
1038
+			}
1009 1039
 			$messages[] = $row['id_msg'];
1010 1040
 		}
1011 1041
 
1012 1042
 		// Sort the messages into the correct display order
1013
-		if (!$ascending)
1014
-			sort($messages);
1043
+		if (!$ascending) {
1044
+					sort($messages);
1045
+		}
1015 1046
 	}
1016 1047
 
1017 1048
 	// Remember the paging data for next time
@@ -1031,8 +1062,9 @@  discard block
 block discarded – undo
1031 1062
 	if (!$user_info['is_guest'] && !empty($messages))
1032 1063
 	{
1033 1064
 		$mark_at_msg = max($messages);
1034
-		if ($mark_at_msg >= $context['topicinfo']['id_last_msg'])
1035
-			$mark_at_msg = $modSettings['maxMsgID'];
1065
+		if ($mark_at_msg >= $context['topicinfo']['id_last_msg']) {
1066
+					$mark_at_msg = $modSettings['maxMsgID'];
1067
+		}
1036 1068
 		if ($mark_at_msg >= $context['topicinfo']['new_from'])
1037 1069
 		{
1038 1070
 			$smcFunc['db_insert']($context['topicinfo']['new_from'] == 0 ? 'ignore' : 'replace',
@@ -1064,8 +1096,9 @@  discard block
 block discarded – undo
1064 1096
 		while ($row = $smcFunc['db_fetch_assoc']($request))
1065 1097
 		{
1066 1098
 			// Find if this topic is marked for notification...
1067
-			if (!empty($row['id_topic']))
1068
-				$context['is_marked_notify'] = true;
1099
+			if (!empty($row['id_topic'])) {
1100
+							$context['is_marked_notify'] = true;
1101
+			}
1069 1102
 
1070 1103
 			// Only do this once, but mark the notifications as "not sent yet" for next time.
1071 1104
 			if (!empty($row['sent']) && $do_once)
@@ -1087,8 +1120,9 @@  discard block
 block discarded – undo
1087 1120
 		}
1088 1121
 
1089 1122
 		// Have we recently cached the number of new topics in this board, and it's still a lot?
1090
-		if (isset($_REQUEST['topicseen']) && isset($_SESSION['topicseen_cache'][$board]) && $_SESSION['topicseen_cache'][$board] > 5)
1091
-			$_SESSION['topicseen_cache'][$board]--;
1123
+		if (isset($_REQUEST['topicseen']) && isset($_SESSION['topicseen_cache'][$board]) && $_SESSION['topicseen_cache'][$board] > 5) {
1124
+					$_SESSION['topicseen_cache'][$board]--;
1125
+		}
1092 1126
 		// Mark board as seen if this is the only new topic.
1093 1127
 		elseif (isset($_REQUEST['topicseen']))
1094 1128
 		{
@@ -1112,14 +1146,16 @@  discard block
 block discarded – undo
1112 1146
 			$smcFunc['db_free_result']($request);
1113 1147
 
1114 1148
 			// If there're no real new topics in this board, mark the board as seen.
1115
-			if (empty($numNewTopics))
1116
-				$_REQUEST['boardseen'] = true;
1117
-			else
1118
-				$_SESSION['topicseen_cache'][$board] = $numNewTopics;
1149
+			if (empty($numNewTopics)) {
1150
+							$_REQUEST['boardseen'] = true;
1151
+			} else {
1152
+							$_SESSION['topicseen_cache'][$board] = $numNewTopics;
1153
+			}
1119 1154
 		}
1120 1155
 		// Probably one less topic - maybe not, but even if we decrease this too fast it will only make us look more often.
1121
-		elseif (isset($_SESSION['topicseen_cache'][$board]))
1122
-			$_SESSION['topicseen_cache'][$board]--;
1156
+		elseif (isset($_SESSION['topicseen_cache'][$board])) {
1157
+					$_SESSION['topicseen_cache'][$board]--;
1158
+		}
1123 1159
 
1124 1160
 		// Mark board as seen if we came using last post link from BoardIndex. (or other places...)
1125 1161
 		if (isset($_REQUEST['boardseen']))
@@ -1176,23 +1212,26 @@  discard block
 block discarded – undo
1176 1212
 			$temp = array();
1177 1213
 			while ($row = $smcFunc['db_fetch_assoc']($request))
1178 1214
 			{
1179
-				if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id']))
1180
-					continue;
1215
+				if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) {
1216
+									continue;
1217
+				}
1181 1218
 
1182 1219
 				$temp[$row['id_attach']] = $row;
1183 1220
 				$temp[$row['id_attach']]['topic'] = $topic;
1184 1221
 				$temp[$row['id_attach']]['board'] = $board;
1185 1222
 
1186
-				if (!isset($context['loaded_attachments'][$row['id_msg']]))
1187
-					$context['loaded_attachments'][$row['id_msg']] = array();
1223
+				if (!isset($context['loaded_attachments'][$row['id_msg']])) {
1224
+									$context['loaded_attachments'][$row['id_msg']] = array();
1225
+				}
1188 1226
 			}
1189 1227
 			$smcFunc['db_free_result']($request);
1190 1228
 
1191 1229
 			// This is better than sorting it with the query...
1192 1230
 			ksort($temp);
1193 1231
 
1194
-			foreach ($temp as $row)
1195
-				$context['loaded_attachments'][$row['id_msg']][] = $row;
1232
+			foreach ($temp as $row) {
1233
+							$context['loaded_attachments'][$row['id_msg']][] = $row;
1234
+			}
1196 1235
 		}
1197 1236
 
1198 1237
 		$msg_parameters = array(
@@ -1219,21 +1258,23 @@  discard block
 block discarded – undo
1219 1258
 		);
1220 1259
 
1221 1260
 		// And the likes
1222
-		if (!empty($modSettings['enable_likes']))
1223
-			$context['my_likes'] = $context['user']['is_guest'] ? array() : prepareLikesContext($topic);
1261
+		if (!empty($modSettings['enable_likes'])) {
1262
+					$context['my_likes'] = $context['user']['is_guest'] ? array() : prepareLikesContext($topic);
1263
+		}
1224 1264
 
1225 1265
 		// Go to the last message if the given time is beyond the time of the last message.
1226
-		if (isset($context['start_from']) && $context['start_from'] >= $context['topicinfo']['num_replies'])
1227
-			$context['start_from'] = $context['topicinfo']['num_replies'];
1266
+		if (isset($context['start_from']) && $context['start_from'] >= $context['topicinfo']['num_replies']) {
1267
+					$context['start_from'] = $context['topicinfo']['num_replies'];
1268
+		}
1228 1269
 
1229 1270
 		// Since the anchor information is needed on the top of the page we load these variables beforehand.
1230 1271
 		$context['first_message'] = isset($messages[$firstIndex]) ? $messages[$firstIndex] : $messages[0];
1231
-		if (empty($options['view_newest_first']))
1232
-			$context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['start_from'];
1233
-		else
1234
-			$context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['topicinfo']['num_replies'] - $context['start_from'];
1235
-	}
1236
-	else
1272
+		if (empty($options['view_newest_first'])) {
1273
+					$context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['start_from'];
1274
+		} else {
1275
+					$context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['topicinfo']['num_replies'] - $context['start_from'];
1276
+		}
1277
+	} else
1237 1278
 	{
1238 1279
 		$messages_request = false;
1239 1280
 		$context['first_message'] = 0;
@@ -1268,8 +1309,9 @@  discard block
 block discarded – undo
1268 1309
 		'can_restore_msg' => 'move_any',
1269 1310
 		'can_like' => 'likes_like',
1270 1311
 	);
1271
-	foreach ($common_permissions as $contextual => $perm)
1272
-		$context[$contextual] = allowedTo($perm);
1312
+	foreach ($common_permissions as $contextual => $perm) {
1313
+			$context[$contextual] = allowedTo($perm);
1314
+	}
1273 1315
 
1274 1316
 	// Permissions with _any/_own versions.  $context[YYY] => ZZZ_any/_own.
1275 1317
 	$anyown_permissions = array(
@@ -1282,8 +1324,9 @@  discard block
 block discarded – undo
1282 1324
 		'can_reply_unapproved' => 'post_unapproved_replies',
1283 1325
 		'can_view_warning' => 'profile_warning',
1284 1326
 	);
1285
-	foreach ($anyown_permissions as $contextual => $perm)
1286
-		$context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own'));
1327
+	foreach ($anyown_permissions as $contextual => $perm) {
1328
+			$context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own'));
1329
+	}
1287 1330
 
1288 1331
 	if (!$user_info['is_admin'] && $context['can_move'] && !$modSettings['topic_move_any'])
1289 1332
 	{
@@ -1329,8 +1372,9 @@  discard block
 block discarded – undo
1329 1372
 	// Check if the draft functions are enabled and that they have permission to use them (for quick reply.)
1330 1373
 	$context['drafts_save'] = !empty($modSettings['drafts_post_enabled']) && allowedTo('post_draft') && $context['can_reply'];
1331 1374
 	$context['drafts_autosave'] = !empty($context['drafts_save']) && !empty($modSettings['drafts_autosave_enabled']);
1332
-	if (!empty($context['drafts_save']))
1333
-		loadLanguage('Drafts');
1375
+	if (!empty($context['drafts_save'])) {
1376
+			loadLanguage('Drafts');
1377
+	}
1334 1378
 
1335 1379
 	// When was the last time this topic was replied to?  Should we warn them about it?
1336 1380
 	if (!empty($modSettings['oldTopicDays']) && ($context['can_reply'] || $context['can_reply_unapproved']) && empty($context['topicinfo']['is_sticky']))
@@ -1391,26 +1435,31 @@  discard block
 block discarded – undo
1391 1435
 	// Message icons - customized icons are off?
1392 1436
 	$context['icons'] = getMessageIcons($board);
1393 1437
 
1394
-	if (!empty($context['icons']))
1395
-		$context['icons'][count($context['icons']) - 1]['is_last'] = true;
1438
+	if (!empty($context['icons'])) {
1439
+			$context['icons'][count($context['icons']) - 1]['is_last'] = true;
1440
+	}
1396 1441
 
1397 1442
 	// Build the normal button array.
1398 1443
 	$context['normal_buttons'] = array();
1399 1444
 
1400
-	if ($context['can_reply'])
1401
-		$context['normal_buttons']['reply'] = array('text' => 'reply', 'image' => 'reply.png', 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';last_msg=' . $context['topic_last_message'], 'active' => true);
1445
+	if ($context['can_reply']) {
1446
+			$context['normal_buttons']['reply'] = array('text' => 'reply', 'image' => 'reply.png', 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';last_msg=' . $context['topic_last_message'], 'active' => true);
1447
+	}
1402 1448
 
1403
-	if ($context['can_add_poll'])
1404
-		$context['normal_buttons']['add_poll'] = array('text' => 'add_poll', 'image' => 'add_poll.png', 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']);
1449
+	if ($context['can_add_poll']) {
1450
+			$context['normal_buttons']['add_poll'] = array('text' => 'add_poll', 'image' => 'add_poll.png', 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']);
1451
+	}
1405 1452
 
1406
-	if ($context['can_mark_unread'])
1407
-		$context['normal_buttons']['mark_unread'] = array('text' => 'mark_unread', 'image' => 'markunread.png', 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
1453
+	if ($context['can_mark_unread']) {
1454
+			$context['normal_buttons']['mark_unread'] = array('text' => 'mark_unread', 'image' => 'markunread.png', 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
1455
+	}
1408 1456
 
1409
-	if ($context['can_print'])
1410
-		$context['normal_buttons']['print'] = array('text' => 'print', 'image' => 'print.png', 'custom' => 'rel="nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0');
1457
+	if ($context['can_print']) {
1458
+			$context['normal_buttons']['print'] = array('text' => 'print', 'image' => 'print.png', 'custom' => 'rel="nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0');
1459
+	}
1411 1460
 
1412
-	if ($context['can_set_notify'])
1413
-		$context['normal_buttons']['notify'] = array(
1461
+	if ($context['can_set_notify']) {
1462
+			$context['normal_buttons']['notify'] = array(
1414 1463
 			'text' => 'notify_topic_' . $context['topic_notification_mode'],
1415 1464
 			'sub_buttons' => array(
1416 1465
 				array(
@@ -1432,38 +1481,47 @@  discard block
 block discarded – undo
1432 1481
 				),
1433 1482
 			),
1434 1483
 		);
1484
+	}
1435 1485
 
1436 1486
 	// Build the mod button array
1437 1487
 	$context['mod_buttons'] = array();
1438 1488
 
1439
-	if ($context['can_move'])
1440
-		$context['mod_buttons']['move'] = array('text' => 'move_topic', 'image' => 'admin_move.png', 'url' => $scripturl . '?action=movetopic;current_board=' . $context['current_board'] . ';topic=' . $context['current_topic'] . '.0');
1489
+	if ($context['can_move']) {
1490
+			$context['mod_buttons']['move'] = array('text' => 'move_topic', 'image' => 'admin_move.png', 'url' => $scripturl . '?action=movetopic;current_board=' . $context['current_board'] . ';topic=' . $context['current_topic'] . '.0');
1491
+	}
1441 1492
 
1442
-	if ($context['can_delete'])
1443
-		$context['mod_buttons']['delete'] = array('text' => 'remove_topic', 'image' => 'admin_rem.png', 'custom' => 'data-confirm="' . $txt['are_sure_remove_topic'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removetopic2;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']);
1493
+	if ($context['can_delete']) {
1494
+			$context['mod_buttons']['delete'] = array('text' => 'remove_topic', 'image' => 'admin_rem.png', 'custom' => 'data-confirm="' . $txt['are_sure_remove_topic'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removetopic2;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']);
1495
+	}
1444 1496
 
1445
-	if ($context['can_lock'])
1446
-		$context['mod_buttons']['lock'] = array('text' => empty($context['is_locked']) ? 'set_lock' : 'set_unlock', 'image' => 'admin_lock.png', 'url' => $scripturl . '?action=lock;topic=' . $context['current_topic'] . '.' . $context['start'] . ';sa=' . ($context['is_locked'] ? 'unlock' : 'lock') . ';' . $context['session_var'] . '=' . $context['session_id']);
1497
+	if ($context['can_lock']) {
1498
+			$context['mod_buttons']['lock'] = array('text' => empty($context['is_locked']) ? 'set_lock' : 'set_unlock', 'image' => 'admin_lock.png', 'url' => $scripturl . '?action=lock;topic=' . $context['current_topic'] . '.' . $context['start'] . ';sa=' . ($context['is_locked'] ? 'unlock' : 'lock') . ';' . $context['session_var'] . '=' . $context['session_id']);
1499
+	}
1447 1500
 
1448
-	if ($context['can_sticky'])
1449
-		$context['mod_buttons']['sticky'] = array('text' => empty($context['is_sticky']) ? 'set_sticky' : 'set_nonsticky', 'image' => 'admin_sticky.png', 'url' => $scripturl . '?action=sticky;topic=' . $context['current_topic'] . '.' . $context['start'] . ';sa=' . ($context['is_sticky'] ? 'nonsticky' : 'sticky') . ';' . $context['session_var'] . '=' . $context['session_id']);
1501
+	if ($context['can_sticky']) {
1502
+			$context['mod_buttons']['sticky'] = array('text' => empty($context['is_sticky']) ? 'set_sticky' : 'set_nonsticky', 'image' => 'admin_sticky.png', 'url' => $scripturl . '?action=sticky;topic=' . $context['current_topic'] . '.' . $context['start'] . ';sa=' . ($context['is_sticky'] ? 'nonsticky' : 'sticky') . ';' . $context['session_var'] . '=' . $context['session_id']);
1503
+	}
1450 1504
 
1451
-	if ($context['can_merge'])
1452
-		$context['mod_buttons']['merge'] = array('text' => 'merge', 'image' => 'merge.png', 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']);
1505
+	if ($context['can_merge']) {
1506
+			$context['mod_buttons']['merge'] = array('text' => 'merge', 'image' => 'merge.png', 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']);
1507
+	}
1453 1508
 
1454
-	if ($context['calendar_post'])
1455
-		$context['mod_buttons']['calendar'] = array('text' => 'calendar_link', 'image' => 'linktocal.png', 'url' => $scripturl . '?action=post;calendar;msg=' . $context['topic_first_message'] . ';topic=' . $context['current_topic'] . '.0');
1509
+	if ($context['calendar_post']) {
1510
+			$context['mod_buttons']['calendar'] = array('text' => 'calendar_link', 'image' => 'linktocal.png', 'url' => $scripturl . '?action=post;calendar;msg=' . $context['topic_first_message'] . ';topic=' . $context['current_topic'] . '.0');
1511
+	}
1456 1512
 
1457 1513
 	// Restore topic. eh?  No monkey business.
1458
-	if ($context['can_restore_topic'])
1459
-		$context['mod_buttons']['restore_topic'] = array('text' => 'restore_topic', 'image' => '', 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']);
1514
+	if ($context['can_restore_topic']) {
1515
+			$context['mod_buttons']['restore_topic'] = array('text' => 'restore_topic', 'image' => '', 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']);
1516
+	}
1460 1517
 
1461 1518
 	// Show a message in case a recently posted message became unapproved.
1462 1519
 	$context['becomesUnapproved'] = !empty($_SESSION['becomesUnapproved']) ? true : false;
1463 1520
 
1464 1521
 	// Don't want to show this forever...
1465
-	if ($context['becomesUnapproved'])
1466
-		unset($_SESSION['becomesUnapproved']);
1522
+	if ($context['becomesUnapproved']) {
1523
+			unset($_SESSION['becomesUnapproved']);
1524
+	}
1467 1525
 
1468 1526
 	// Allow adding new mod buttons easily.
1469 1527
 	// Note: $context['normal_buttons'] and $context['mod_buttons'] are added for backward compatibility with 2.0, but are deprecated and should not be used
@@ -1472,12 +1530,14 @@  discard block
 block discarded – undo
1472 1530
 	call_integration_hook('integrate_mod_buttons', array(&$context['mod_buttons']));
1473 1531
 
1474 1532
 	// Load the drafts js file
1475
-	if ($context['drafts_autosave'])
1476
-		loadJavaScriptFile('drafts.js', array('defer' => false, 'minimize' => true), 'smf_drafts');
1533
+	if ($context['drafts_autosave']) {
1534
+			loadJavaScriptFile('drafts.js', array('defer' => false, 'minimize' => true), 'smf_drafts');
1535
+	}
1477 1536
 
1478 1537
 	// Spellcheck
1479
-	if ($context['show_spellchecking'])
1480
-		loadJavaScriptFile('spellcheck.js', array('defer' => false, 'minimize' => true), 'smf_spellcheck');
1538
+	if ($context['show_spellchecking']) {
1539
+			loadJavaScriptFile('spellcheck.js', array('defer' => false, 'minimize' => true), 'smf_spellcheck');
1540
+	}
1481 1541
 
1482 1542
 	// topic.js
1483 1543
 	loadJavaScriptFile('topic.js', array('defer' => false, 'minimize' => true), 'smf_topic');
@@ -1511,16 +1571,19 @@  discard block
 block discarded – undo
1511 1571
 	static $counter = null;
1512 1572
 
1513 1573
 	// If the query returned false, bail.
1514
-	if ($messages_request == false)
1515
-		return false;
1574
+	if ($messages_request == false) {
1575
+			return false;
1576
+	}
1516 1577
 
1517 1578
 	// Remember which message this is.  (ie. reply #83)
1518
-	if ($counter === null || $reset)
1519
-		$counter = empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start'];
1579
+	if ($counter === null || $reset) {
1580
+			$counter = empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start'];
1581
+	}
1520 1582
 
1521 1583
 	// Start from the beginning...
1522
-	if ($reset)
1523
-		return @$smcFunc['db_data_seek']($messages_request, 0);
1584
+	if ($reset) {
1585
+			return @$smcFunc['db_data_seek']($messages_request, 0);
1586
+	}
1524 1587
 
1525 1588
 	// Attempt to get the next message.
1526 1589
 	$message = $smcFunc['db_fetch_assoc']($messages_request);
@@ -1534,19 +1597,21 @@  discard block
 block discarded – undo
1534 1597
 	if (empty($context['icon_sources']))
1535 1598
 	{
1536 1599
 		$context['icon_sources'] = array();
1537
-		foreach ($context['stable_icons'] as $icon)
1538
-			$context['icon_sources'][$icon] = 'images_url';
1600
+		foreach ($context['stable_icons'] as $icon) {
1601
+					$context['icon_sources'][$icon] = 'images_url';
1602
+		}
1539 1603
 	}
1540 1604
 
1541 1605
 	// Message Icon Management... check the images exist.
1542 1606
 	if (empty($modSettings['messageIconChecks_disable']))
1543 1607
 	{
1544 1608
 		// If the current icon isn't known, then we need to do something...
1545
-		if (!isset($context['icon_sources'][$message['icon']]))
1546
-			$context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url';
1609
+		if (!isset($context['icon_sources'][$message['icon']])) {
1610
+					$context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url';
1611
+		}
1612
+	} elseif (!isset($context['icon_sources'][$message['icon']])) {
1613
+			$context['icon_sources'][$message['icon']] = 'images_url';
1547 1614
 	}
1548
-	elseif (!isset($context['icon_sources'][$message['icon']]))
1549
-		$context['icon_sources'][$message['icon']] = 'images_url';
1550 1615
 
1551 1616
 	// If you're a lazy bum, you probably didn't give a subject...
1552 1617
 	$message['subject'] = $message['subject'] != '' ? $message['subject'] : $txt['no_subject'];
@@ -1571,8 +1636,7 @@  discard block
 block discarded – undo
1571 1636
 		$memberContext[$message['id_member']]['email'] = $message['poster_email'];
1572 1637
 		$memberContext[$message['id_member']]['show_email'] = allowedTo('moderate_forum');
1573 1638
 		$memberContext[$message['id_member']]['is_guest'] = true;
1574
-	}
1575
-	else
1639
+	} else
1576 1640
 	{
1577 1641
 		// Define this here to make things a bit more readable
1578 1642
 		$can_view_warning = $context['user']['can_mod'] || allowedTo('view_warning_any') || ($message['id_member'] == $user_info['id'] && allowedTo('view_warning_own'));
@@ -1595,8 +1659,9 @@  discard block
 block discarded – undo
1595 1659
 	$message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']);
1596 1660
 
1597 1661
 	// If it's in the recycle bin we need to override whatever icon we did have.
1598
-	if (!empty($board_info['recycle']))
1599
-		$message['icon'] = 'recycled';
1662
+	if (!empty($board_info['recycle'])) {
1663
+			$message['icon'] = 'recycled';
1664
+	}
1600 1665
 
1601 1666
 	require_once($sourcedir . '/Subs-Attachments.php');
1602 1667
 
@@ -1640,32 +1705,36 @@  discard block
 block discarded – undo
1640 1705
 	}
1641 1706
 
1642 1707
 	// Are likes enable?
1643
-	if (!empty($modSettings['enable_likes']))
1644
-		$output['likes'] = array(
1708
+	if (!empty($modSettings['enable_likes'])) {
1709
+			$output['likes'] = array(
1645 1710
 			'count' => $message['likes'],
1646 1711
 			'you' => in_array($message['id_msg'], $context['my_likes']),
1647 1712
 			'can_like' => !$context['user']['is_guest'] && $message['id_member'] != $context['user']['id'] && !empty($context['can_like']),
1648 1713
 		);
1714
+	}
1649 1715
 
1650 1716
 	// Is this user the message author?
1651 1717
 	$output['is_message_author'] = $message['id_member'] == $user_info['id'];
1652
-	if (!empty($output['modified']['name']))
1653
-		$output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], $output['modified']['name']);
1718
+	if (!empty($output['modified']['name'])) {
1719
+			$output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], $output['modified']['name']);
1720
+	}
1654 1721
 
1655 1722
 	// Did they give a reason for editing?
1656
-	if (!empty($output['modified']['name']) && !empty($output['modified']['reason']))
1657
-		$output['modified']['last_edit_text'] .= '&nbsp;' . sprintf($txt['last_edit_reason'], $output['modified']['reason']);
1723
+	if (!empty($output['modified']['name']) && !empty($output['modified']['reason'])) {
1724
+			$output['modified']['last_edit_text'] .= '&nbsp;' . sprintf($txt['last_edit_reason'], $output['modified']['reason']);
1725
+	}
1658 1726
 
1659 1727
 	// Any custom profile fields?
1660
-	if (!empty($memberContext[$message['id_member']]['custom_fields']))
1661
-		foreach ($memberContext[$message['id_member']]['custom_fields'] as $custom)
1728
+	if (!empty($memberContext[$message['id_member']]['custom_fields'])) {
1729
+			foreach ($memberContext[$message['id_member']]['custom_fields'] as $custom)
1662 1730
 			$output['custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom;
1731
+	}
1663 1732
 
1664
-	if (empty($options['view_newest_first']))
1665
-		$counter++;
1666
-
1667
-	else
1668
-		$counter--;
1733
+	if (empty($options['view_newest_first'])) {
1734
+			$counter++;
1735
+	} else {
1736
+			$counter--;
1737
+	}
1669 1738
 
1670 1739
 	call_integration_hook('integrate_prepare_display_context', array(&$output, &$message, $counter));
1671 1740
 
@@ -1691,8 +1760,9 @@  discard block
 block discarded – undo
1691 1760
  */
1692 1761
 function approved_attach_sort($a, $b)
1693 1762
 {
1694
-	if ($a['is_approved'] == $b['is_approved'])
1695
-		return 0;
1763
+	if ($a['is_approved'] == $b['is_approved']) {
1764
+			return 0;
1765
+	}
1696 1766
 
1697 1767
 	return $a['is_approved'] > $b['is_approved'] ? -1 : 1;
1698 1768
 }
@@ -1709,16 +1779,19 @@  discard block
 block discarded – undo
1709 1779
 
1710 1780
 	require_once($sourcedir . '/RemoveTopic.php');
1711 1781
 
1712
-	if (empty($_REQUEST['msgs']))
1713
-		redirectexit('topic=' . $topic . '.' . $_REQUEST['start']);
1782
+	if (empty($_REQUEST['msgs'])) {
1783
+			redirectexit('topic=' . $topic . '.' . $_REQUEST['start']);
1784
+	}
1714 1785
 
1715 1786
 	$messages = array();
1716
-	foreach ($_REQUEST['msgs'] as $dummy)
1717
-		$messages[] = (int) $dummy;
1787
+	foreach ($_REQUEST['msgs'] as $dummy) {
1788
+			$messages[] = (int) $dummy;
1789
+	}
1718 1790
 
1719 1791
 	// We are restoring messages. We handle this in another place.
1720
-	if (isset($_REQUEST['restore_selected']))
1721
-		redirectexit('action=restoretopic;msgs=' . implode(',', $messages) . ';' . $context['session_var'] . '=' . $context['session_id']);
1792
+	if (isset($_REQUEST['restore_selected'])) {
1793
+			redirectexit('action=restoretopic;msgs=' . implode(',', $messages) . ';' . $context['session_var'] . '=' . $context['session_id']);
1794
+	}
1722 1795
 	if (isset($_REQUEST['split_selection']))
1723 1796
 	{
1724 1797
 		$request = $smcFunc['db_query']('', '
@@ -1737,8 +1810,9 @@  discard block
 block discarded – undo
1737 1810
 	}
1738 1811
 
1739 1812
 	// Allowed to delete any message?
1740
-	if (allowedTo('delete_any'))
1741
-		$allowed_all = true;
1813
+	if (allowedTo('delete_any')) {
1814
+			$allowed_all = true;
1815
+	}
1742 1816
 	// Allowed to delete replies to their messages?
1743 1817
 	elseif (allowedTo('delete_replies'))
1744 1818
 	{
@@ -1755,13 +1829,14 @@  discard block
 block discarded – undo
1755 1829
 		$smcFunc['db_free_result']($request);
1756 1830
 
1757 1831
 		$allowed_all = $starter == $user_info['id'];
1832
+	} else {
1833
+			$allowed_all = false;
1758 1834
 	}
1759
-	else
1760
-		$allowed_all = false;
1761 1835
 
1762 1836
 	// Make sure they're allowed to delete their own messages, if not any.
1763
-	if (!$allowed_all)
1764
-		isAllowedTo('delete_own');
1837
+	if (!$allowed_all) {
1838
+			isAllowedTo('delete_own');
1839
+	}
1765 1840
 
1766 1841
 	// Allowed to remove which messages?
1767 1842
 	$request = $smcFunc['db_query']('', '
@@ -1781,8 +1856,9 @@  discard block
 block discarded – undo
1781 1856
 	$messages = array();
1782 1857
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1783 1858
 	{
1784
-		if (!$allowed_all && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time())
1785
-			continue;
1859
+		if (!$allowed_all && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) {
1860
+					continue;
1861
+		}
1786 1862
 
1787 1863
 		$messages[$row['id_msg']] = array($row['subject'], $row['id_member']);
1788 1864
 	}
@@ -1805,17 +1881,20 @@  discard block
 block discarded – undo
1805 1881
 	foreach ($messages as $message => $info)
1806 1882
 	{
1807 1883
 		// Just skip the first message - if it's not the last.
1808
-		if ($message == $first_message && $message != $last_message)
1809
-			continue;
1884
+		if ($message == $first_message && $message != $last_message) {
1885
+					continue;
1886
+		}
1810 1887
 		// If the first message is going then don't bother going back to the topic as we're effectively deleting it.
1811
-		elseif ($message == $first_message)
1812
-			$topicGone = true;
1888
+		elseif ($message == $first_message) {
1889
+					$topicGone = true;
1890
+		}
1813 1891
 
1814 1892
 		removeMessage($message);
1815 1893
 
1816 1894
 		// Log this moderation action ;).
1817
-		if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id']))
1818
-			logAction('delete', array('topic' => $topic, 'subject' => $info[0], 'member' => $info[1], 'board' => $board));
1895
+		if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) {
1896
+					logAction('delete', array('topic' => $topic, 'subject' => $info[0], 'member' => $info[1], 'board' => $board));
1897
+		}
1819 1898
 	}
1820 1899
 
1821 1900
 	redirectexit(!empty($topicGone) ? 'board=' . $board : 'topic=' . $topic . '.' . $_REQUEST['start']);
Please login to merge, or discard this patch.
Themes/default/Memberlist.template.php 1 patch
Braces   +30 added lines, -20 removed lines patch added patch discarded remove patch
@@ -27,9 +27,10 @@  discard block
 block discarded – undo
27 27
 			<h3 class="catbg">
28 28
 				<span class="floatleft">', $txt['members_list'], '</span>';
29 29
 
30
-	if (!isset($context['old_search']))
31
-		echo '
30
+	if (!isset($context['old_search'])) {
31
+			echo '
32 32
 				<span class="floatright">', $context['letter_links'], '</span>';
33
+	}
33 34
 	echo '
34 35
 			</h3>
35 36
 		</div>';
@@ -44,20 +45,23 @@  discard block
 block discarded – undo
44 45
 	foreach ($context['columns'] as $key => $column)
45 46
 	{
46 47
 		// @TODO maybe find something nicer?
47
-		if ($key == 'email_address' && !$context['can_send_email'])
48
-			continue;
48
+		if ($key == 'email_address' && !$context['can_send_email']) {
49
+					continue;
50
+		}
49 51
 
50 52
 		// This is a selected column, so underline it or some such.
51
-		if ($column['selected'])
52
-			echo '
53
+		if ($column['selected']) {
54
+					echo '
53 55
 						<th scope="col" class="', $key, isset($column['class']) ? ' ' . $column['class'] : '', ' selected" style="width: auto;"' . (isset($column['colspan']) ? ' colspan="' . $column['colspan'] . '"' : '') . '>
54 56
 							<a href="' . $column['href'] . '" rel="nofollow">' . $column['label'] . '</a><span class="generic_icons sort_' . $context['sort_direction'] . '"></span></th>';
57
+		}
55 58
 
56 59
 		// This is just some column... show the link and be done with it.
57
-		else
58
-			echo '
60
+		else {
61
+					echo '
59 62
 						<th scope="col" class="', $key, isset($column['class']) ? ' ' . $column['class'] : '', '"', isset($column['width']) ? ' style="width: ' . $column['width'] . '"' : '', isset($column['colspan']) ? ' colspan="' . $column['colspan'] . '"' : '', '>
60 63
 						', $column['link'], '</th>';
64
+		}
61 65
 	}
62 66
 
63 67
 	echo '
@@ -77,9 +81,10 @@  discard block
 block discarded – undo
77 81
 						</td>
78 82
 						<td class="real_name lefttext">', $member['link'], '</td>';
79 83
 
80
-			if (!isset($context['disabled_fields']['website']))
81
-				echo '
84
+			if (!isset($context['disabled_fields']['website'])) {
85
+							echo '
82 86
 						<td class="website_url centertext">', $member['website']['url'] != '' ? '<a href="' . $member['website']['url'] . '" target="_blank" rel="noopener"><span class="generic_icons www" title="' . $member['website']['title'] . '"></span></a>' : '', '</td>';
87
+			}
83 88
 
84 89
 			// Group and date.
85 90
 			echo '
@@ -91,33 +96,36 @@  discard block
 block discarded – undo
91 96
 				echo '
92 97
 						<td class="post_count centertext">';
93 98
 
94
-				if (!empty($member['post_percent']))
95
-					echo '
99
+				if (!empty($member['post_percent'])) {
100
+									echo '
96 101
 							<div class="generic_bar">
97 102
 								<div class="bar" style="width: ', $member['post_percent'], '%;"></div>
98 103
 								<span>', $member['posts'], '</span>
99 104
 							</div>';
105
+				}
100 106
 
101 107
 				echo '
102 108
 						</td>';
103 109
 			}
104 110
 
105 111
 			// Show custom fields marked to be shown here
106
-			if (!empty($context['custom_profile_fields']['columns']))
107
-				foreach ($context['custom_profile_fields']['columns'] as $key => $column)
112
+			if (!empty($context['custom_profile_fields']['columns'])) {
113
+							foreach ($context['custom_profile_fields']['columns'] as $key => $column)
108 114
 					echo '
109 115
 						<td class="' , $key , ' centertext">', $member['options'][$key], '</td>';
116
+			}
110 117
 
111 118
 			echo '
112 119
 					</tr>';
113 120
 		}
114 121
 	}
115 122
 	// No members?
116
-	else
117
-		echo '
123
+	else {
124
+			echo '
118 125
 					<tr>
119 126
 						<td colspan="', $context['colspan'], '" class="windowbg">', $txt['search_no_results'], '</td>
120 127
 					</tr>';
128
+	}
121 129
 
122 130
 	echo '
123 131
 				</tbody>
@@ -130,11 +138,12 @@  discard block
 block discarded – undo
130 138
 			<div class="pagelinks floatleft">', $context['page_index'], '</div>';
131 139
 
132 140
 	// If it is displaying the result of a search show a "search again" link to edit their criteria.
133
-	if (isset($context['old_search']))
134
-		echo '
141
+	if (isset($context['old_search'])) {
142
+			echo '
135 143
 			<div class="buttonlist floatright">
136 144
 				<a class="button" href="', $scripturl, '?action=mlist;sa=search;search=', $context['old_search_value'], '">', $txt['mlist_search_again'], '</a>
137 145
 			</div>';
146
+	}
138 147
 	echo '
139 148
 		</div>
140 149
 	</div><!-- #memberlist -->';
@@ -174,12 +183,13 @@  discard block
 block discarded – undo
174 183
 					<dd>
175 184
 						<ul>';
176 185
 
177
-	foreach ($context['search_fields'] as $id => $title)
178
-		echo '
186
+	foreach ($context['search_fields'] as $id => $title) {
187
+			echo '
179 188
 							<li>
180 189
 								<input type="checkbox" name="fields[]" id="fields-', $id, '" value="', $id, '"', in_array($id, $context['search_defaults']) ? ' checked' : '', '>
181 190
 								<label for="fields-', $id, '">', $title, '</label>
182 191
 							</li>';
192
+	}
183 193
 
184 194
 	echo '
185 195
 						</ul>
Please login to merge, or discard this patch.
Sources/tasks/CreatePost-Notify.php 1 patch
Braces   +74 added lines, -54 removed lines patch added patch discarded remove patch
@@ -96,8 +96,9 @@  discard block
 block discarded – undo
96 96
 		while ($row = $smcFunc['db_fetch_assoc']($request))
97 97
 		{
98 98
 			$groups = array_merge(array($row['id_group'], $row['id_post_group']), (empty($row['additional_groups']) ? array() : explode(',', $row['additional_groups'])));
99
-			if (!in_array(1, $groups) && count(array_intersect($groups, explode(',', $row['member_groups']))) == 0)
100
-				continue;
99
+			if (!in_array(1, $groups) && count(array_intersect($groups, explode(',', $row['member_groups']))) == 0) {
100
+							continue;
101
+			}
101 102
 
102 103
 			$members[] = $row['id_member'];
103 104
 			$watched[$row['id_member']] = $row;
@@ -105,8 +106,9 @@  discard block
 block discarded – undo
105 106
 
106 107
 		$smcFunc['db_free_result']($request);
107 108
 
108
-		if (empty($members))
109
-			return true;
109
+		if (empty($members)) {
110
+					return true;
111
+		}
110 112
 
111 113
 		$members = array_unique($members);
112 114
 		$prefs = getNotifyPrefs($members, '', true);
@@ -122,8 +124,9 @@  discard block
 block discarded – undo
122 124
 		self::handleQuoteNotifications($msgOptions, $posterOptions, $quotedMembers, $prefs, $done_members, $alert_rows);
123 125
 
124 126
 		// Save ourselves a bit of work in the big loop below
125
-		foreach ($done_members as $done_member)
126
-			unset($watched[$done_member]);
127
+		foreach ($done_members as $done_member) {
128
+					unset($watched[$done_member]);
129
+		}
127 130
 
128 131
 		// Handle rest of the notifications for watched topics and boards
129 132
 		foreach ($watched as $member => $data)
@@ -132,26 +135,31 @@  discard block
 block discarded – undo
132 135
 			$notify_types = !empty($prefs[$member]['msg_notify_type']) ? $prefs[$member]['msg_notify_type'] : self::NOTIFY_TYPE_REPLY_AND_MODIFY;
133 136
 
134 137
 			// Don't send a notification if the watching member ignored the member who made the action.
135
-			if (!empty($data['pm_ignore_list']) && in_array($data['id_member_updated'], explode(',', $data['pm_ignore_list'])))
136
-				continue;
137
-			if (!in_array($type, array('reply', 'topic')) && $notify_types == self::NOTIFY_TYPE_REPLY_AND_TOPIC_START_FOLLOWING && $member != $data['id_member_started'])
138
-				continue;
139
-			elseif (in_array($type, array('reply', 'topic')) && $member == $posterOptions['id'])
140
-				continue;
141
-			elseif (!in_array($type, array('reply', 'topic')) && $notify_types == self::NOTIFY_TYPE_ONLY_REPLIES)
142
-				continue;
143
-			elseif ($notify_types == self::NOTIFY_TYPE_NOTHING)
144
-				continue;
138
+			if (!empty($data['pm_ignore_list']) && in_array($data['id_member_updated'], explode(',', $data['pm_ignore_list']))) {
139
+							continue;
140
+			}
141
+			if (!in_array($type, array('reply', 'topic')) && $notify_types == self::NOTIFY_TYPE_REPLY_AND_TOPIC_START_FOLLOWING && $member != $data['id_member_started']) {
142
+							continue;
143
+			} elseif (in_array($type, array('reply', 'topic')) && $member == $posterOptions['id']) {
144
+							continue;
145
+			} elseif (!in_array($type, array('reply', 'topic')) && $notify_types == self::NOTIFY_TYPE_ONLY_REPLIES) {
146
+							continue;
147
+			} elseif ($notify_types == self::NOTIFY_TYPE_NOTHING) {
148
+							continue;
149
+			}
145 150
 
146 151
 			// Don't send a notification if they don't want any...
147
-			if (in_array($frequency, array(self::FREQUENCY_NOTHING, self::FREQUENCY_DAILY_DIGEST, self::FREQUENCY_WEEKLY_DIGEST)))
148
-				continue;
152
+			if (in_array($frequency, array(self::FREQUENCY_NOTHING, self::FREQUENCY_DAILY_DIGEST, self::FREQUENCY_WEEKLY_DIGEST))) {
153
+							continue;
154
+			}
149 155
 			// ... or if we already sent one and they don't want more...
150
-			elseif ($frequency === self::FREQUENCY_FIRST_UNREAD_MSG && $data['sent'])
151
-				continue;
156
+			elseif ($frequency === self::FREQUENCY_FIRST_UNREAD_MSG && $data['sent']) {
157
+							continue;
158
+			}
152 159
 			// ... or if they aren't on the bouncer's list.
153
-			elseif (!empty($this->_details['members_only']) && !in_array($member, $this->_details['members_only']))
154
-				continue;
160
+			elseif (!empty($this->_details['members_only']) && !in_array($member, $this->_details['members_only'])) {
161
+							continue;
162
+			}
155 163
 
156 164
 			// Watched topic?
157 165
 			if (!empty($data['id_topic']) && $type != 'topic' && !empty($prefs[$member]))
@@ -161,10 +169,12 @@  discard block
 block discarded – undo
161 169
 
162 170
 				if ($type == 'reply')
163 171
 				{
164
-					if (!empty($prefs[$member]['msg_receive_body']))
165
-						$message_type .= '_body';
166
-					if (!empty($frequency))
167
-						$message_type .= '_once';
172
+					if (!empty($prefs[$member]['msg_receive_body'])) {
173
+											$message_type .= '_body';
174
+					}
175
+					if (!empty($frequency)) {
176
+											$message_type .= '_once';
177
+					}
168 178
 				}
169 179
 
170 180
 				$content_type = 'topic';
@@ -177,12 +187,14 @@  discard block
 block discarded – undo
177 187
 				$content_type = 'board';
178 188
 
179 189
 				$message_type = !empty($frequency) ? 'notify_boards_once' : 'notify_boards';
180
-				if (!empty($prefs[$member]['msg_receive_body']))
181
-					$message_type .= '_body';
190
+				if (!empty($prefs[$member]['msg_receive_body'])) {
191
+									$message_type .= '_body';
192
+				}
182 193
 			}
183 194
 			// If neither of the above, this might be a redundent row due to the OR clause in our SQL query, skip
184
-			else
185
-				continue;
195
+			else {
196
+							continue;
197
+			}
186 198
 
187 199
 			// Bitwise check: Receiving a email notification?
188 200
 			if ($pref & self::RECEIVE_NOTIFY_EMAIL)
@@ -199,8 +211,9 @@  discard block
 block discarded – undo
199 211
 				$mail_result = sendmail($data['email_address'], $emaildata['subject'], $emaildata['body'], null, 'm' . $topicOptions['id'], $emaildata['is_html']);
200 212
 
201 213
 				// We failed, don't trigger a alert as we don't have a way to attempt to resend just the email currently.
202
-				if ($mail_result === false)
203
-					continue;
214
+				if ($mail_result === false) {
215
+									continue;
216
+				}
204 217
 			}
205 218
 
206 219
 			// Bitwise check: Receiving a alert?
@@ -251,14 +264,15 @@  discard block
 block discarded – undo
251 264
 		);
252 265
 
253 266
 		// Insert the alerts if any
254
-		if (!empty($alert_rows))
255
-			$smcFunc['db_insert']('',
267
+		if (!empty($alert_rows)) {
268
+					$smcFunc['db_insert']('',
256 269
 				'{db_prefix}user_alerts',
257 270
 				array('alert_time' => 'int', 'id_member' => 'int', 'id_member_started' => 'int', 'member_name' => 'string',
258 271
 					'content_type' => 'string', 'content_id' => 'int', 'content_action' => 'string', 'is_read' => 'int', 'extra' => 'string'),
259 272
 				$alert_rows,
260 273
 				array()
261 274
 			);
275
+		}
262 276
 
263 277
 		return true;
264 278
 	}
@@ -269,8 +283,9 @@  discard block
 block discarded – undo
269 283
 
270 284
 		foreach ($quotedMembers as $id => $member)
271 285
 		{
272
-			if (!isset($prefs[$id]) || $id == $posterOptions['id'] || empty($prefs[$id]['msg_quote']))
273
-				continue;
286
+			if (!isset($prefs[$id]) || $id == $posterOptions['id'] || empty($prefs[$id]['msg_quote'])) {
287
+							continue;
288
+			}
274 289
 
275 290
 			$done_members[] = $id;
276 291
 
@@ -324,32 +339,35 @@  discard block
 block discarded – undo
324 339
 		{
325 340
 			if (preg_match('/\[quote(.*)?\]/i', $block, $matches))
326 341
 			{
327
-				if ($quote_level == 0)
328
-					$message .= '[quote' . $matches[1] . ']';
342
+				if ($quote_level == 0) {
343
+									$message .= '[quote' . $matches[1] . ']';
344
+				}
329 345
 				$quote_level++;
330
-			}
331
-			elseif (preg_match('/\[\/quote\]/i', $block))
346
+			} elseif (preg_match('/\[\/quote\]/i', $block))
332 347
 			{
333
-				if ($quote_level <= 1)
334
-					$message .= '[/quote]';
348
+				if ($quote_level <= 1) {
349
+									$message .= '[/quote]';
350
+				}
335 351
 				if ($quote_level >= 1)
336 352
 				{
337 353
 					$quote_level--;
338 354
 					$message .= "\n";
339 355
 				}
356
+			} elseif ($quote_level <= 1) {
357
+							$message .= $block;
340 358
 			}
341
-			elseif ($quote_level <= 1)
342
-				$message .= $block;
343 359
 		}
344 360
 
345 361
 		preg_match_all('/\[quote.*?link=msg=([0-9]+).*?\]/i', $message, $matches);
346 362
 
347 363
 		$id_msgs = $matches[1];
348
-		foreach ($id_msgs as $k => $id_msg)
349
-			$id_msgs[$k] = (int) $id_msg;
364
+		foreach ($id_msgs as $k => $id_msg) {
365
+					$id_msgs[$k] = (int) $id_msg;
366
+		}
350 367
 
351
-		if (empty($id_msgs))
352
-			return array();
368
+		if (empty($id_msgs)) {
369
+					return array();
370
+		}
353 371
 
354 372
 		// Get the messages
355 373
 		$request = $smcFunc['db_query']('', '
@@ -367,8 +385,9 @@  discard block
 block discarded – undo
367 385
 		$members = array();
368 386
 		while ($row = $smcFunc['db_fetch_assoc']($request))
369 387
 		{
370
-			if ($posterOptions['id'] == $row['id_member'])
371
-				continue;
388
+			if ($posterOptions['id'] == $row['id_member']) {
389
+							continue;
390
+			}
372 391
 
373 392
 			$members[$row['id_member']] = $row;
374 393
 		}
@@ -382,10 +401,11 @@  discard block
 block discarded – undo
382 401
 
383 402
 		foreach ($members as $id => $member)
384 403
 		{
385
-			if (!empty($prefs[$id]['msg_mention']))
386
-				$done_members[] = $id;
387
-			else
388
-				continue;
404
+			if (!empty($prefs[$id]['msg_mention'])) {
405
+							$done_members[] = $id;
406
+			} else {
407
+							continue;
408
+			}
389 409
 
390 410
 			// Alerts' emails are always instant
391 411
 			if ($prefs[$id]['msg_mention'] & self::RECEIVE_NOTIFY_EMAIL)
Please login to merge, or discard this patch.