@@ -13,8 +13,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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)) |
@@ -61,9 +61,10 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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"> => <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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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(' ', $brd['child_level']) : '', $brd['name'], '</label></li>'; |
909 | + } |
|
879 | 910 | |
880 | 911 | echo ' |
881 | 912 | </ul>'; |
@@ -885,12 +916,14 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -18,11 +18,12 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 != \'\' && confirm(\'', $txt['quickmod_confirm'], '\');" class="button qaction"> |
@@ -340,17 +366,19 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
451 | 481 | sGoButtonLabel: "', $txt['quick_mod_go'], '" |
452 | 482 | }); |
453 | 483 | </script>'; |
484 | + } |
|
454 | 485 | |
455 | 486 | echo ' |
456 | 487 | <br class="clear"> |
@@ -15,8 +15,9 @@ discard block |
||
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 |
||
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 |
||
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('<' => '<', '>' => '>', '"' => '"')); |
@@ -61,33 +64,39 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
404 | 433 | ', $mmessage, ' |
405 | 434 | </body> |
406 | 435 | </html>'; |
436 | + } |
|
407 | 437 | |
408 | 438 | die(); |
409 | 439 | } |
@@ -425,15 +455,17 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -14,8 +14,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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); |
@@ -14,8 +14,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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'] .= ' <a href="' . $scripturl . '?topic=' . $topic . '.0;all">' . $txt['all'] . '</a> '; |
|
503 | + else { |
|
504 | + $context['page_index'] .= ' <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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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'] .= ' ' . sprintf($txt['last_edit_reason'], $output['modified']['reason']); |
|
1723 | + if (!empty($output['modified']['name']) && !empty($output['modified']['reason'])) { |
|
1724 | + $output['modified']['last_edit_text'] .= ' ' . 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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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']); |
@@ -27,9 +27,10 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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> |
@@ -13,8 +13,9 @@ discard block |
||
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 | * This is the dispatcher of smileys administration. |
@@ -91,8 +92,9 @@ discard block |
||
91 | 92 | ); |
92 | 93 | |
93 | 94 | // Some settings may not be enabled, disallow these from the tabs as appropriate. |
94 | - if (empty($modSettings['messageIcons_enable'])) |
|
95 | - $context[$context['admin_menu_name']]['tab_data']['tabs']['editicons']['disabled'] = true; |
|
95 | + if (empty($modSettings['messageIcons_enable'])) { |
|
96 | + $context[$context['admin_menu_name']]['tab_data']['tabs']['editicons']['disabled'] = true; |
|
97 | + } |
|
96 | 98 | if (empty($modSettings['smiley_enable'])) |
97 | 99 | { |
98 | 100 | $context[$context['admin_menu_name']]['tab_data']['tabs']['addsmiley']['disabled'] = true; |
@@ -125,8 +127,9 @@ discard block |
||
125 | 127 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
126 | 128 | |
127 | 129 | $smiley_context = array(); |
128 | - foreach ($smiley_sets as $i => $set) |
|
129 | - $smiley_context[$set] = $set_names[$i]; |
|
130 | + foreach ($smiley_sets as $i => $set) { |
|
131 | + $smiley_context[$set] = $set_names[$i]; |
|
132 | + } |
|
130 | 133 | |
131 | 134 | // All the settings for the page... |
132 | 135 | $config_vars = array( |
@@ -147,8 +150,9 @@ discard block |
||
147 | 150 | |
148 | 151 | call_integration_hook('integrate_modify_smiley_settings', array(&$config_vars)); |
149 | 152 | |
150 | - if ($return_config) |
|
151 | - return $config_vars; |
|
153 | + if ($return_config) { |
|
154 | + return $config_vars; |
|
155 | + } |
|
152 | 156 | |
153 | 157 | // Setup the basics of the settings template. |
154 | 158 | require_once($sourcedir . '/ManageServer.php'); |
@@ -208,8 +212,9 @@ discard block |
||
208 | 212 | foreach ($_POST['smiley_set'] as $id => $val) |
209 | 213 | { |
210 | 214 | // If this is the set you've marked as default, or the only one remaining, you can't delete it |
211 | - if ($modSettings['smiley_sets_default'] != $set_paths[$id] && count($set_paths) != 1 && isset($set_paths[$id], $set_names[$id])) |
|
212 | - unset($set_paths[$id], $set_names[$id], $set_exts[$id]); |
|
215 | + if ($modSettings['smiley_sets_default'] != $set_paths[$id] && count($set_paths) != 1 && isset($set_paths[$id], $set_names[$id])) { |
|
216 | + unset($set_paths[$id], $set_names[$id], $set_exts[$id]); |
|
217 | + } |
|
213 | 218 | } |
214 | 219 | |
215 | 220 | // Shortcut... array_merge() on a single array resets the numeric keys |
@@ -225,8 +230,9 @@ discard block |
||
225 | 230 | )); |
226 | 231 | } |
227 | 232 | // Add a new smiley set. |
228 | - elseif (!empty($_POST['add'])) |
|
229 | - $context['sub_action'] = 'modifyset'; |
|
233 | + elseif (!empty($_POST['add'])) { |
|
234 | + $context['sub_action'] = 'modifyset'; |
|
235 | + } |
|
230 | 236 | // Create or modify a smiley set. |
231 | 237 | elseif (isset($_POST['set'])) |
232 | 238 | { |
@@ -237,8 +243,9 @@ discard block |
||
237 | 243 | // Create a new smiley set. |
238 | 244 | if ($_POST['set'] == -1 && isset($_POST['smiley_sets_path'])) |
239 | 245 | { |
240 | - if (in_array($_POST['smiley_sets_path'], $set_paths)) |
|
241 | - fatal_lang_error('smiley_set_already_exists'); |
|
246 | + if (in_array($_POST['smiley_sets_path'], $set_paths)) { |
|
247 | + fatal_lang_error('smiley_set_already_exists'); |
|
248 | + } |
|
242 | 249 | |
243 | 250 | updateSettings(array( |
244 | 251 | 'smiley_sets_known' => $modSettings['smiley_sets_known'] . ',' . $_POST['smiley_sets_path'], |
@@ -251,12 +258,14 @@ discard block |
||
251 | 258 | else |
252 | 259 | { |
253 | 260 | // Make sure the smiley set exists. |
254 | - if (!isset($set_paths[$_POST['set']]) || !isset($set_names[$_POST['set']])) |
|
255 | - fatal_lang_error('smiley_set_not_found'); |
|
261 | + if (!isset($set_paths[$_POST['set']]) || !isset($set_names[$_POST['set']])) { |
|
262 | + fatal_lang_error('smiley_set_not_found'); |
|
263 | + } |
|
256 | 264 | |
257 | 265 | // Make sure the path is not yet used by another smileyset. |
258 | - if (in_array($_POST['smiley_sets_path'], $set_paths) && $_POST['smiley_sets_path'] != $set_paths[$_POST['set']]) |
|
259 | - fatal_lang_error('smiley_set_path_already_used'); |
|
266 | + if (in_array($_POST['smiley_sets_path'], $set_paths) && $_POST['smiley_sets_path'] != $set_paths[$_POST['set']]) { |
|
267 | + fatal_lang_error('smiley_set_path_already_used'); |
|
268 | + } |
|
260 | 269 | |
261 | 270 | $set_paths[$_POST['set']] = $_POST['smiley_sets_path']; |
262 | 271 | $set_exts[$_POST['set']] = $_POST['smiley_sets_ext']; |
@@ -270,8 +279,9 @@ discard block |
||
270 | 279 | } |
271 | 280 | |
272 | 281 | // The user might have checked to also import smileys. |
273 | - if (!empty($_POST['smiley_sets_import'])) |
|
274 | - ImportSmileys($_POST['smiley_sets_path']); |
|
282 | + if (!empty($_POST['smiley_sets_import'])) { |
|
283 | + ImportSmileys($_POST['smiley_sets_path']); |
|
284 | + } |
|
275 | 285 | } |
276 | 286 | cache_put_data('parsing_smileys', null, 480); |
277 | 287 | cache_put_data('posting_smileys', null, 480); |
@@ -281,14 +291,15 @@ discard block |
||
281 | 291 | $context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']); |
282 | 292 | $set_exts = explode(",", $modSettings['smiley_sets_exts']); |
283 | 293 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
284 | - foreach ($context['smiley_sets'] as $i => $set) |
|
285 | - $context['smiley_sets'][$i] = array( |
|
294 | + foreach ($context['smiley_sets'] as $i => $set) { |
|
295 | + $context['smiley_sets'][$i] = array( |
|
286 | 296 | 'id' => $i, |
287 | 297 | 'path' => $smcFunc['htmlspecialchars']($set), |
288 | 298 | 'ext' => $smcFunc['htmlspecialchars']($set_exts[$i]), |
289 | 299 | 'name' => $smcFunc['htmlspecialchars']($set_names[$i]), |
290 | 300 | 'selected' => $set == $modSettings['smiley_sets_default'] |
291 | 301 | ); |
302 | + } |
|
292 | 303 | |
293 | 304 | // Importing any smileys from an existing set? |
294 | 305 | if ($context['sub_action'] == 'import') |
@@ -299,8 +310,9 @@ discard block |
||
299 | 310 | $_GET['set'] = (int) $_GET['set']; |
300 | 311 | |
301 | 312 | // Sanity check - then import. |
302 | - if (isset($context['smiley_sets'][$_GET['set']])) |
|
303 | - ImportSmileys(un_htmlspecialchars($context['smiley_sets'][$_GET['set']]['path'])); |
|
313 | + if (isset($context['smiley_sets'][$_GET['set']])) { |
|
314 | + ImportSmileys(un_htmlspecialchars($context['smiley_sets'][$_GET['set']]['path'])); |
|
315 | + } |
|
304 | 316 | |
305 | 317 | // Force the process to continue. |
306 | 318 | $context['sub_action'] = 'modifyset'; |
@@ -310,8 +322,8 @@ discard block |
||
310 | 322 | if ($context['sub_action'] == 'modifyset') |
311 | 323 | { |
312 | 324 | $_GET['set'] = !isset($_GET['set']) ? -1 : (int) $_GET['set']; |
313 | - if ($_GET['set'] == -1 || !isset($context['smiley_sets'][$_GET['set']])) |
|
314 | - $context['current_set'] = array( |
|
325 | + if ($_GET['set'] == -1 || !isset($context['smiley_sets'][$_GET['set']])) { |
|
326 | + $context['current_set'] = array( |
|
315 | 327 | 'id' => '-1', |
316 | 328 | 'path' => '', |
317 | 329 | 'ext' => '', |
@@ -319,7 +331,7 @@ discard block |
||
319 | 331 | 'selected' => false, |
320 | 332 | 'is_new' => true, |
321 | 333 | ); |
322 | - else |
|
334 | + } else |
|
323 | 335 | { |
324 | 336 | $context['current_set'] = &$context['smiley_sets'][$_GET['set']]; |
325 | 337 | $context['current_set']['is_new'] = false; |
@@ -333,13 +345,15 @@ discard block |
||
333 | 345 | { |
334 | 346 | // strip extension before comparison |
335 | 347 | $filename = pathinfo($entry, PATHINFO_FILENAME); |
336 | - if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png', '.svg'))) |
|
337 | - $smileys[strtolower($filename)] = $filename; |
|
348 | + if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png', '.svg'))) { |
|
349 | + $smileys[strtolower($filename)] = $filename; |
|
350 | + } |
|
338 | 351 | } |
339 | 352 | $dir->close(); |
340 | 353 | |
341 | - if (empty($smileys)) |
|
342 | - fatal_lang_error('smiley_set_dir_not_found', false, array($context['current_set']['name'])); |
|
354 | + if (empty($smileys)) { |
|
355 | + fatal_lang_error('smiley_set_dir_not_found', false, array($context['current_set']['name'])); |
|
356 | + } |
|
343 | 357 | |
344 | 358 | // Exclude the smileys that are already in the database. |
345 | 359 | $request = $smcFunc['db_query']('', ' |
@@ -350,9 +364,10 @@ discard block |
||
350 | 364 | 'smiley_list' => $smileys, |
351 | 365 | ) |
352 | 366 | ); |
353 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
354 | - if (isset($smileys[strtolower($row['filename'])])) |
|
367 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
368 | + if (isset($smileys[strtolower($row['filename'])])) |
|
355 | 369 | unset($smileys[strtolower($row['filename'])]); |
370 | + } |
|
356 | 371 | $smcFunc['db_free_result']($request); |
357 | 372 | |
358 | 373 | $context['current_set']['can_import'] = count($smileys); |
@@ -367,13 +382,14 @@ discard block |
||
367 | 382 | $dir = dir($modSettings['smileys_dir']); |
368 | 383 | while ($entry = $dir->read()) |
369 | 384 | { |
370 | - if (!in_array($entry, array('.', '..')) && is_dir($modSettings['smileys_dir'] . '/' . $entry)) |
|
371 | - $context['smiley_set_dirs'][] = array( |
|
385 | + if (!in_array($entry, array('.', '..')) && is_dir($modSettings['smileys_dir'] . '/' . $entry)) { |
|
386 | + $context['smiley_set_dirs'][] = array( |
|
372 | 387 | 'id' => $entry, |
373 | 388 | 'path' => $modSettings['smileys_dir'] . '/' . $entry, |
374 | 389 | 'selectable' => $entry == $context['current_set']['path'] || !in_array($entry, explode(',', $modSettings['smiley_sets_known'])), |
375 | 390 | 'current' => $entry == $context['current_set']['path'], |
376 | 391 | ); |
392 | + } |
|
377 | 393 | } |
378 | 394 | $dir->close(); |
379 | 395 | } |
@@ -383,8 +399,9 @@ discard block |
||
383 | 399 | createToken('admin-mss', 'request'); |
384 | 400 | |
385 | 401 | // In case we need to import smileys, we need to add the token in now. |
386 | - if (isset($context['current_set']['import_url'])) |
|
387 | - $context['current_set']['import_url'] .= ';' . $context['admin-mss_token_var'] . '=' . $context['admin-mss_token']; |
|
402 | + if (isset($context['current_set']['import_url'])) { |
|
403 | + $context['current_set']['import_url'] .= ';' . $context['admin-mss_token_var'] . '=' . $context['admin-mss_token']; |
|
404 | + } |
|
388 | 405 | |
389 | 406 | $listOptions = array( |
390 | 407 | 'id' => 'smiley_set_list', |
@@ -537,24 +554,26 @@ discard block |
||
537 | 554 | $cols['ext'][] = $set_exts[$i]; |
538 | 555 | } |
539 | 556 | $sort_flag = strpos($sort, 'DESC') === false ? SORT_ASC : SORT_DESC; |
540 | - if (substr($sort, 0, 4) === 'name') |
|
541 | - array_multisort($cols['name'], $sort_flag, SORT_REGULAR, $cols['path'], $cols['selected'], $cols['id'], $cols['ext']); |
|
542 | - elseif (substr($sort, 0, 3) === 'ext') |
|
543 | - array_multisort($cols['ext'], $sort_flag, SORT_REGULAR, $cols['name'], $cols['selected'], $cols['id'], $cols['path']); |
|
544 | - elseif (substr($sort, 0, 4) === 'path') |
|
545 | - array_multisort($cols['path'], $sort_flag, SORT_REGULAR, $cols['name'], $cols['selected'], $cols['id'], $cols['ext']); |
|
546 | - else |
|
547 | - array_multisort($cols['selected'], $sort_flag, SORT_REGULAR, $cols['path'], $cols['name'], $cols['id'], $cols['ext']); |
|
557 | + if (substr($sort, 0, 4) === 'name') { |
|
558 | + array_multisort($cols['name'], $sort_flag, SORT_REGULAR, $cols['path'], $cols['selected'], $cols['id'], $cols['ext']); |
|
559 | + } elseif (substr($sort, 0, 3) === 'ext') { |
|
560 | + array_multisort($cols['ext'], $sort_flag, SORT_REGULAR, $cols['name'], $cols['selected'], $cols['id'], $cols['path']); |
|
561 | + } elseif (substr($sort, 0, 4) === 'path') { |
|
562 | + array_multisort($cols['path'], $sort_flag, SORT_REGULAR, $cols['name'], $cols['selected'], $cols['id'], $cols['ext']); |
|
563 | + } else { |
|
564 | + array_multisort($cols['selected'], $sort_flag, SORT_REGULAR, $cols['path'], $cols['name'], $cols['id'], $cols['ext']); |
|
565 | + } |
|
548 | 566 | |
549 | 567 | $smiley_sets = array(); |
550 | - foreach ($cols['id'] as $i => $id) |
|
551 | - $smiley_sets[] = array( |
|
568 | + foreach ($cols['id'] as $i => $id) { |
|
569 | + $smiley_sets[] = array( |
|
552 | 570 | 'id' => $id, |
553 | 571 | 'path' => $cols['path'][$i], |
554 | 572 | 'name' => $cols['name'][$i], |
555 | 573 | 'ext' => $cols['ext'][$i], |
556 | 574 | 'selected' => $cols['path'][$i] == $modSettings['smiley_sets_default'] |
557 | 575 | ); |
576 | + } |
|
558 | 577 | |
559 | 578 | return $smiley_sets; |
560 | 579 | } |
@@ -584,14 +603,15 @@ discard block |
||
584 | 603 | $context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']); |
585 | 604 | $set_exts = explode(',', $modSettings['smiley_sets_exts']); |
586 | 605 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
587 | - foreach ($context['smiley_sets'] as $i => $set) |
|
588 | - $context['smiley_sets'][$i] = array( |
|
606 | + foreach ($context['smiley_sets'] as $i => $set) { |
|
607 | + $context['smiley_sets'][$i] = array( |
|
589 | 608 | 'id' => $i, |
590 | 609 | 'path' => $smcFunc['htmlspecialchars']($set), |
591 | 610 | 'name' => $smcFunc['htmlspecialchars']($set_names[$i]), |
592 | 611 | 'ext' => $smcFunc['htmlspecialchars']($set_exts[$i]), |
593 | 612 | 'selected' => $set == $modSettings['smiley_sets_default'] |
594 | 613 | ); |
614 | + } |
|
595 | 615 | |
596 | 616 | // Submitting a form? |
597 | 617 | if (isset($_POST[$context['session_var']], $_POST['smiley_code'])) |
@@ -607,8 +627,9 @@ discard block |
||
607 | 627 | $_POST['smiley_filename'] = htmltrim__recursive($_POST['smiley_filename']); |
608 | 628 | |
609 | 629 | // Make sure some code was entered. |
610 | - if (empty($_POST['smiley_code'])) |
|
611 | - fatal_lang_error('smiley_has_no_code'); |
|
630 | + if (empty($_POST['smiley_code'])) { |
|
631 | + fatal_lang_error('smiley_has_no_code'); |
|
632 | + } |
|
612 | 633 | |
613 | 634 | // Check whether the new code has duplicates. It should be unique. |
614 | 635 | $request = $smcFunc['db_query']('', ' |
@@ -620,8 +641,9 @@ discard block |
||
620 | 641 | 'smiley_code' => $_POST['smiley_code'], |
621 | 642 | ) |
622 | 643 | ); |
623 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
624 | - fatal_lang_error('smiley_not_unique'); |
|
644 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
645 | + fatal_lang_error('smiley_not_unique'); |
|
646 | + } |
|
625 | 647 | $smcFunc['db_free_result']($request); |
626 | 648 | |
627 | 649 | // If we are uploading - check all the smiley sets are writable! |
@@ -630,38 +652,44 @@ discard block |
||
630 | 652 | $writeErrors = array(); |
631 | 653 | foreach ($context['smiley_sets'] as $set) |
632 | 654 | { |
633 | - if (!is_writable($context['smileys_dir'] . '/' . un_htmlspecialchars($set['path']))) |
|
634 | - $writeErrors[] = $set['path']; |
|
655 | + if (!is_writable($context['smileys_dir'] . '/' . un_htmlspecialchars($set['path']))) { |
|
656 | + $writeErrors[] = $set['path']; |
|
657 | + } |
|
658 | + } |
|
659 | + if (!empty($writeErrors)) { |
|
660 | + fatal_lang_error('smileys_upload_error_notwritable', true, array(implode(', ', $writeErrors))); |
|
635 | 661 | } |
636 | - if (!empty($writeErrors)) |
|
637 | - fatal_lang_error('smileys_upload_error_notwritable', true, array(implode(', ', $writeErrors))); |
|
638 | 662 | } |
639 | 663 | |
640 | 664 | // Uploading just one smiley for all of them? |
641 | 665 | if (isset($_POST['sameall']) && isset($_FILES['uploadSmiley']['name']) && $_FILES['uploadSmiley']['name'] != '') |
642 | 666 | { |
643 | - if (!is_uploaded_file($_FILES['uploadSmiley']['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['uploadSmiley']['tmp_name']))) |
|
644 | - fatal_lang_error('smileys_upload_error'); |
|
667 | + if (!is_uploaded_file($_FILES['uploadSmiley']['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['uploadSmiley']['tmp_name']))) { |
|
668 | + fatal_lang_error('smileys_upload_error'); |
|
669 | + } |
|
645 | 670 | |
646 | 671 | // Sorry, no spaces, dots, or anything else but letters allowed. |
647 | 672 | $_FILES['uploadSmiley']['name'] = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $_FILES['uploadSmiley']['name']); |
648 | 673 | |
649 | 674 | // We only allow image files - it's THAT simple - no messing around here... |
650 | - if (!in_array(strtolower(substr(strrchr($_FILES['uploadSmiley']['name'], '.'), 1)), $allowedTypes)) |
|
651 | - fatal_lang_error('smileys_upload_error_types', false, array(implode(', ', $allowedTypes))); |
|
675 | + if (!in_array(strtolower(substr(strrchr($_FILES['uploadSmiley']['name'], '.'), 1)), $allowedTypes)) { |
|
676 | + fatal_lang_error('smileys_upload_error_types', false, array(implode(', ', $allowedTypes))); |
|
677 | + } |
|
652 | 678 | |
653 | 679 | // We only need the filename... |
654 | 680 | $destName = basename($_FILES['uploadSmiley']['name']); |
655 | 681 | |
656 | 682 | // Make sure they aren't trying to upload a nasty file - for their own good here! |
657 | - if (in_array(strtolower($destName), $disabledFiles)) |
|
658 | - fatal_lang_error('smileys_upload_error_illegal'); |
|
683 | + if (in_array(strtolower($destName), $disabledFiles)) { |
|
684 | + fatal_lang_error('smileys_upload_error_illegal'); |
|
685 | + } |
|
659 | 686 | |
660 | 687 | // Check if the file already exists... and if not move it to EVERY smiley set directory. |
661 | 688 | $i = 0; |
662 | 689 | // Keep going until we find a set the file doesn't exist in. (or maybe it exists in all of them?) |
663 | - while (isset($context['smiley_sets'][$i]) && file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($context['smiley_sets'][$i]['path']) . '/' . $destName)) |
|
664 | - $i++; |
|
690 | + while (isset($context['smiley_sets'][$i]) && file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($context['smiley_sets'][$i]['path']) . '/' . $destName)) { |
|
691 | + $i++; |
|
692 | + } |
|
665 | 693 | |
666 | 694 | // Okay, we're going to put the smiley right here, since it's not there yet! |
667 | 695 | if (isset($context['smiley_sets'][$i]['path'])) |
@@ -676,8 +704,9 @@ discard block |
||
676 | 704 | $currentPath = $context['smileys_dir'] . '/' . un_htmlspecialchars($context['smiley_sets'][$i]['path']) . '/' . $destName; |
677 | 705 | |
678 | 706 | // The file is already there! Don't overwrite it! |
679 | - if (file_exists($currentPath)) |
|
680 | - continue; |
|
707 | + if (file_exists($currentPath)) { |
|
708 | + continue; |
|
709 | + } |
|
681 | 710 | |
682 | 711 | // Okay, so copy the first one we made to here. |
683 | 712 | copy($smileyLocation, $currentPath); |
@@ -694,13 +723,15 @@ discard block |
||
694 | 723 | $newName = ''; |
695 | 724 | foreach ($_FILES as $name => $data) |
696 | 725 | { |
697 | - if ($_FILES[$name]['name'] == '') |
|
698 | - fatal_lang_error('smileys_upload_error_blank'); |
|
726 | + if ($_FILES[$name]['name'] == '') { |
|
727 | + fatal_lang_error('smileys_upload_error_blank'); |
|
728 | + } |
|
699 | 729 | |
700 | - if (empty($newName)) |
|
701 | - $newName = basename($_FILES[$name]['name']); |
|
702 | - elseif (basename($_FILES[$name]['name']) != $newName) |
|
703 | - fatal_lang_error('smileys_upload_error_name'); |
|
730 | + if (empty($newName)) { |
|
731 | + $newName = basename($_FILES[$name]['name']); |
|
732 | + } elseif (basename($_FILES[$name]['name']) != $newName) { |
|
733 | + fatal_lang_error('smileys_upload_error_name'); |
|
734 | + } |
|
704 | 735 | } |
705 | 736 | |
706 | 737 | foreach ($context['smiley_sets'] as $i => $set) |
@@ -708,31 +739,36 @@ discard block |
||
708 | 739 | $set['name'] = un_htmlspecialchars($set['name']); |
709 | 740 | $set['path'] = un_htmlspecialchars($set['path']); |
710 | 741 | |
711 | - if (!isset($_FILES['individual_' . $set['name']]['name']) || $_FILES['individual_' . $set['name']]['name'] == '') |
|
712 | - continue; |
|
742 | + if (!isset($_FILES['individual_' . $set['name']]['name']) || $_FILES['individual_' . $set['name']]['name'] == '') { |
|
743 | + continue; |
|
744 | + } |
|
713 | 745 | |
714 | 746 | // Got one... |
715 | - if (!is_uploaded_file($_FILES['individual_' . $set['name']]['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['individual_' . $set['name']]['tmp_name']))) |
|
716 | - fatal_lang_error('smileys_upload_error'); |
|
747 | + if (!is_uploaded_file($_FILES['individual_' . $set['name']]['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['individual_' . $set['name']]['tmp_name']))) { |
|
748 | + fatal_lang_error('smileys_upload_error'); |
|
749 | + } |
|
717 | 750 | |
718 | 751 | // Sorry, no spaces, dots, or anything else but letters allowed. |
719 | 752 | $_FILES['individual_' . $set['name']]['name'] = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $_FILES['individual_' . $set['name']]['name']); |
720 | 753 | |
721 | 754 | // We only allow image files - it's THAT simple - no messing around here... |
722 | - if (!in_array(strtolower(substr(strrchr($_FILES['individual_' . $set['name']]['name'], '.'), 1)), $allowedTypes)) |
|
723 | - fatal_lang_error('smileys_upload_error_types', false, array(implode(', ', $allowedTypes))); |
|
755 | + if (!in_array(strtolower(substr(strrchr($_FILES['individual_' . $set['name']]['name'], '.'), 1)), $allowedTypes)) { |
|
756 | + fatal_lang_error('smileys_upload_error_types', false, array(implode(', ', $allowedTypes))); |
|
757 | + } |
|
724 | 758 | |
725 | 759 | // We only need the filename... |
726 | 760 | $destName = basename($_FILES['individual_' . $set['name']]['name']); |
727 | 761 | |
728 | 762 | // Make sure they aren't trying to upload a nasty file - for their own good here! |
729 | - if (in_array(strtolower($destName), $disabledFiles)) |
|
730 | - fatal_lang_error('smileys_upload_error_illegal'); |
|
763 | + if (in_array(strtolower($destName), $disabledFiles)) { |
|
764 | + fatal_lang_error('smileys_upload_error_illegal'); |
|
765 | + } |
|
731 | 766 | |
732 | 767 | // If the file exists - ignore it. |
733 | 768 | $smileyLocation = $context['smileys_dir'] . '/' . $set['path'] . '/' . $destName; |
734 | - if (file_exists($smileyLocation)) |
|
735 | - continue; |
|
769 | + if (file_exists($smileyLocation)) { |
|
770 | + continue; |
|
771 | + } |
|
736 | 772 | |
737 | 773 | // Finally - move the image! |
738 | 774 | move_uploaded_file($_FILES['individual_' . $set['name']]['tmp_name'], $smileyLocation); |
@@ -744,8 +780,9 @@ discard block |
||
744 | 780 | } |
745 | 781 | |
746 | 782 | // Also make sure a filename was given. |
747 | - if (empty($_POST['smiley_filename'])) |
|
748 | - fatal_lang_error('smiley_has_no_filename'); |
|
783 | + if (empty($_POST['smiley_filename'])) { |
|
784 | + fatal_lang_error('smiley_has_no_filename'); |
|
785 | + } |
|
749 | 786 | |
750 | 787 | // Find the position on the right. |
751 | 788 | $smiley_order = '0'; |
@@ -764,8 +801,9 @@ discard block |
||
764 | 801 | list ($smiley_order) = $smcFunc['db_fetch_row']($request); |
765 | 802 | $smcFunc['db_free_result']($request); |
766 | 803 | |
767 | - if (empty($smiley_order)) |
|
768 | - $smiley_order = '0'; |
|
804 | + if (empty($smiley_order)) { |
|
805 | + $smiley_order = '0'; |
|
806 | + } |
|
769 | 807 | } |
770 | 808 | $smcFunc['db_insert']('', |
771 | 809 | '{db_prefix}smileys', |
@@ -793,19 +831,21 @@ discard block |
||
793 | 831 | { |
794 | 832 | foreach ($context['smiley_sets'] as $smiley_set) |
795 | 833 | { |
796 | - if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']))) |
|
797 | - continue; |
|
834 | + if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']))) { |
|
835 | + continue; |
|
836 | + } |
|
798 | 837 | |
799 | 838 | $dir = dir($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path'])); |
800 | 839 | while ($entry = $dir->read()) |
801 | 840 | { |
802 | 841 | // Strip extension |
803 | 842 | $filename = pathinfo($entry, PATHINFO_FILENAME); |
804 | - if (!in_array($filename, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png', '.svg'))) |
|
805 | - $context['filenames'][strtolower($filename)] = array( |
|
843 | + if (!in_array($filename, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png', '.svg'))) { |
|
844 | + $context['filenames'][strtolower($filename)] = array( |
|
806 | 845 | 'id' => $smcFunc['htmlspecialchars']($filename), |
807 | 846 | 'selected' => false, |
808 | 847 | ); |
848 | + } |
|
809 | 849 | } |
810 | 850 | $dir->close(); |
811 | 851 | } |
@@ -843,17 +883,19 @@ discard block |
||
843 | 883 | // Changing the selected smileys? |
844 | 884 | if (isset($_POST['smiley_action']) && !empty($_POST['checked_smileys'])) |
845 | 885 | { |
846 | - foreach ($_POST['checked_smileys'] as $id => $smiley_id) |
|
847 | - $_POST['checked_smileys'][$id] = (int) $smiley_id; |
|
886 | + foreach ($_POST['checked_smileys'] as $id => $smiley_id) { |
|
887 | + $_POST['checked_smileys'][$id] = (int) $smiley_id; |
|
888 | + } |
|
848 | 889 | |
849 | - if ($_POST['smiley_action'] == 'delete') |
|
850 | - $smcFunc['db_query']('', ' |
|
890 | + if ($_POST['smiley_action'] == 'delete') { |
|
891 | + $smcFunc['db_query']('', ' |
|
851 | 892 | DELETE FROM {db_prefix}smileys |
852 | 893 | WHERE id_smiley IN ({array_int:checked_smileys})', |
853 | 894 | array( |
854 | 895 | 'checked_smileys' => $_POST['checked_smileys'], |
855 | 896 | ) |
856 | 897 | ); |
898 | + } |
|
857 | 899 | // Changing the status of the smiley? |
858 | 900 | else |
859 | 901 | { |
@@ -863,8 +905,8 @@ discard block |
||
863 | 905 | 'hidden' => 1, |
864 | 906 | 'popup' => 2 |
865 | 907 | ); |
866 | - if (isset($displayTypes[$_POST['smiley_action']])) |
|
867 | - $smcFunc['db_query']('', ' |
|
908 | + if (isset($displayTypes[$_POST['smiley_action']])) { |
|
909 | + $smcFunc['db_query']('', ' |
|
868 | 910 | UPDATE {db_prefix}smileys |
869 | 911 | SET hidden = {int:display_type} |
870 | 912 | WHERE id_smiley IN ({array_int:checked_smileys})', |
@@ -873,6 +915,7 @@ discard block |
||
873 | 915 | 'display_type' => $displayTypes[$_POST['smiley_action']], |
874 | 916 | ) |
875 | 917 | ); |
918 | + } |
|
876 | 919 | } |
877 | 920 | } |
878 | 921 | // Create/modify a smiley. |
@@ -898,12 +941,14 @@ discard block |
||
898 | 941 | $_POST['smiley_location'] = empty($_POST['smiley_location']) || $_POST['smiley_location'] > 2 || $_POST['smiley_location'] < 0 ? 0 : (int) $_POST['smiley_location']; |
899 | 942 | |
900 | 943 | // Make sure some code was entered. |
901 | - if (empty($_POST['smiley_code'])) |
|
902 | - fatal_lang_error('smiley_has_no_code'); |
|
944 | + if (empty($_POST['smiley_code'])) { |
|
945 | + fatal_lang_error('smiley_has_no_code'); |
|
946 | + } |
|
903 | 947 | |
904 | 948 | // Also make sure a filename was given. |
905 | - if (empty($_POST['smiley_filename'])) |
|
906 | - fatal_lang_error('smiley_has_no_filename'); |
|
949 | + if (empty($_POST['smiley_filename'])) { |
|
950 | + fatal_lang_error('smiley_has_no_filename'); |
|
951 | + } |
|
907 | 952 | |
908 | 953 | // Check whether the new code has duplicates. It should be unique. |
909 | 954 | $request = $smcFunc['db_query']('', ' |
@@ -917,8 +962,9 @@ discard block |
||
917 | 962 | 'smiley_code' => $_POST['smiley_code'], |
918 | 963 | ) |
919 | 964 | ); |
920 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
921 | - fatal_lang_error('smiley_not_unique'); |
|
965 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
966 | + fatal_lang_error('smiley_not_unique'); |
|
967 | + } |
|
922 | 968 | $smcFunc['db_free_result']($request); |
923 | 969 | |
924 | 970 | $smcFunc['db_query']('', ' |
@@ -948,14 +994,15 @@ discard block |
||
948 | 994 | $context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']); |
949 | 995 | $set_exts = explode(',', $modSettings['smiley_sets_exts']); |
950 | 996 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
951 | - foreach ($context['smiley_sets'] as $i => $set) |
|
952 | - $context['smiley_sets'][$i] = array( |
|
997 | + foreach ($context['smiley_sets'] as $i => $set) { |
|
998 | + $context['smiley_sets'][$i] = array( |
|
953 | 999 | 'id' => $i, |
954 | 1000 | 'path' => $smcFunc['htmlspecialchars']($set), |
955 | 1001 | 'name' => $smcFunc['htmlspecialchars']($set_names[$i]), |
956 | 1002 | 'ext' => $smcFunc['htmlspecialchars']($set_exts[$i]), |
957 | 1003 | 'selected' => $set == $modSettings['smiley_sets_default'] |
958 | 1004 | ); |
1005 | + } |
|
959 | 1006 | |
960 | 1007 | // Prepare overview of all (custom) smileys. |
961 | 1008 | if ($context['sub_action'] == 'editsmileys') |
@@ -971,9 +1018,10 @@ discard block |
||
971 | 1018 | // Create a list of options for selecting smiley sets. |
972 | 1019 | $smileyset_option_list = ' |
973 | 1020 | <select name="set" onchange="changeSet(this.options[this.selectedIndex].value);">'; |
974 | - foreach ($context['smiley_sets'] as $smiley_set) |
|
975 | - $smileyset_option_list .= ' |
|
1021 | + foreach ($context['smiley_sets'] as $smiley_set) { |
|
1022 | + $smileyset_option_list .= ' |
|
976 | 1023 | <option value="' . $smiley_set['path'] . '"' . ($modSettings['smiley_sets_default'] == $smiley_set['path'] ? ' selected' : '') . '>' . $smiley_set['name'] . '</option>'; |
1024 | + } |
|
977 | 1025 | $smileyset_option_list .= ' |
978 | 1026 | </select>'; |
979 | 1027 | |
@@ -1035,12 +1083,13 @@ discard block |
||
1035 | 1083 | 'data' => array( |
1036 | 1084 | 'function' => function ($rowData) use ($txt) |
1037 | 1085 | { |
1038 | - if (empty($rowData['hidden'])) |
|
1039 | - return $txt['smileys_location_form']; |
|
1040 | - elseif ($rowData['hidden'] == 1) |
|
1041 | - return $txt['smileys_location_hidden']; |
|
1042 | - else |
|
1043 | - return $txt['smileys_location_popup']; |
|
1086 | + if (empty($rowData['hidden'])) { |
|
1087 | + return $txt['smileys_location_form']; |
|
1088 | + } elseif ($rowData['hidden'] == 1) { |
|
1089 | + return $txt['smileys_location_hidden']; |
|
1090 | + } else { |
|
1091 | + return $txt['smileys_location_popup']; |
|
1092 | + } |
|
1044 | 1093 | }, |
1045 | 1094 | ), |
1046 | 1095 | 'sort' => array( |
@@ -1055,19 +1104,22 @@ discard block |
||
1055 | 1104 | 'data' => array( |
1056 | 1105 | 'function' => function ($rowData) use ($context, $txt, $modSettings, $smcFunc) |
1057 | 1106 | { |
1058 | - if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'])) |
|
1059 | - return $smcFunc['htmlspecialchars']($rowData['description']); |
|
1107 | + if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'])) { |
|
1108 | + return $smcFunc['htmlspecialchars']($rowData['description']); |
|
1109 | + } |
|
1060 | 1110 | |
1061 | 1111 | // Check if there are smileys missing in some sets. |
1062 | 1112 | $missing_sets = array(); |
1063 | - foreach ($context['smiley_sets'] as $smiley_set) |
|
1064 | - if (!file_exists(sprintf('%1$s/%2$s/%3$s', $modSettings['smileys_dir'], $smiley_set['path'], $rowData['filename']))) |
|
1113 | + foreach ($context['smiley_sets'] as $smiley_set) { |
|
1114 | + if (!file_exists(sprintf('%1$s/%2$s/%3$s', $modSettings['smileys_dir'], $smiley_set['path'], $rowData['filename']))) |
|
1065 | 1115 | $missing_sets[] = $smiley_set['path']; |
1116 | + } |
|
1066 | 1117 | |
1067 | 1118 | $description = $smcFunc['htmlspecialchars']($rowData['description']); |
1068 | 1119 | |
1069 | - if (!empty($missing_sets)) |
|
1070 | - $description .= sprintf('<br><span class="smalltext"><strong>%1$s:</strong> %2$s</span>', $txt['smileys_not_found_in_set'], implode(', ', $missing_sets)); |
|
1120 | + if (!empty($missing_sets)) { |
|
1121 | + $description .= sprintf('<br><span class="smalltext"><strong>%1$s:</strong> %2$s</span>', $txt['smileys_not_found_in_set'], implode(', ', $missing_sets)); |
|
1122 | + } |
|
1071 | 1123 | |
1072 | 1124 | return $description; |
1073 | 1125 | }, |
@@ -1186,14 +1238,15 @@ discard block |
||
1186 | 1238 | $context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']); |
1187 | 1239 | $set_exts = explode(',', $modSettings['smiley_sets_exts']); |
1188 | 1240 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
1189 | - foreach ($context['smiley_sets'] as $i => $set) |
|
1190 | - $context['smiley_sets'][$i] = array( |
|
1241 | + foreach ($context['smiley_sets'] as $i => $set) { |
|
1242 | + $context['smiley_sets'][$i] = array( |
|
1191 | 1243 | 'id' => $i, |
1192 | 1244 | 'path' => $smcFunc['htmlspecialchars']($set), |
1193 | 1245 | 'name' => $smcFunc['htmlspecialchars']($set_names[$i]), |
1194 | 1246 | 'ext' => $smcFunc['htmlspecialchars']($set_exts[$i]), |
1195 | 1247 | 'selected' => $set == $modSettings['smiley_sets_default'] |
1196 | 1248 | ); |
1249 | + } |
|
1197 | 1250 | |
1198 | 1251 | $context['selected_set'] = $modSettings['smiley_sets_default']; |
1199 | 1252 | |
@@ -1203,19 +1256,21 @@ discard block |
||
1203 | 1256 | { |
1204 | 1257 | foreach ($context['smiley_sets'] as $smiley_set) |
1205 | 1258 | { |
1206 | - if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']))) |
|
1207 | - continue; |
|
1259 | + if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']))) { |
|
1260 | + continue; |
|
1261 | + } |
|
1208 | 1262 | |
1209 | 1263 | $dir = dir($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path'])); |
1210 | 1264 | while ($entry = $dir->read()) |
1211 | 1265 | { |
1212 | 1266 | // Strip extension |
1213 | 1267 | $filename = pathinfo($entry, PATHINFO_FILENAME); |
1214 | - if (!in_array($filename, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png', '.svg'))) |
|
1215 | - $context['filenames'][strtolower($filename)] = array( |
|
1268 | + if (!in_array($filename, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png', '.svg'))) { |
|
1269 | + $context['filenames'][strtolower($filename)] = array( |
|
1216 | 1270 | 'id' => $smcFunc['htmlspecialchars']($filename), |
1217 | 1271 | 'selected' => false, |
1218 | 1272 | ); |
1273 | + } |
|
1219 | 1274 | } |
1220 | 1275 | $dir->close(); |
1221 | 1276 | } |
@@ -1230,8 +1285,9 @@ discard block |
||
1230 | 1285 | 'current_smiley' => (int) $_REQUEST['smiley'], |
1231 | 1286 | ) |
1232 | 1287 | ); |
1233 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
1234 | - fatal_lang_error('smiley_not_found'); |
|
1288 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
1289 | + fatal_lang_error('smiley_not_found'); |
|
1290 | + } |
|
1235 | 1291 | $context['current_smiley'] = $smcFunc['db_fetch_assoc']($request); |
1236 | 1292 | $smcFunc['db_free_result']($request); |
1237 | 1293 | |
@@ -1239,8 +1295,9 @@ discard block |
||
1239 | 1295 | $context['current_smiley']['filename'] = $smcFunc['htmlspecialchars']($context['current_smiley']['filename']); |
1240 | 1296 | $context['current_smiley']['description'] = $smcFunc['htmlspecialchars']($context['current_smiley']['description']); |
1241 | 1297 | |
1242 | - if (isset($context['filenames'][strtolower($context['current_smiley']['filename'])])) |
|
1243 | - $context['filenames'][strtolower($context['current_smiley']['filename'])]['selected'] = true; |
|
1298 | + if (isset($context['filenames'][strtolower($context['current_smiley']['filename'])])) { |
|
1299 | + $context['filenames'][strtolower($context['current_smiley']['filename'])]['selected'] = true; |
|
1300 | + } |
|
1244 | 1301 | } |
1245 | 1302 | } |
1246 | 1303 | |
@@ -1265,8 +1322,9 @@ discard block |
||
1265 | 1322 | ) |
1266 | 1323 | ); |
1267 | 1324 | $smileys = array(); |
1268 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1269 | - $smileys[] = $row; |
|
1325 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1326 | + $smileys[] = $row; |
|
1327 | + } |
|
1270 | 1328 | $smcFunc['db_free_result']($request); |
1271 | 1329 | |
1272 | 1330 | return $smileys; |
@@ -1306,8 +1364,9 @@ discard block |
||
1306 | 1364 | $_GET['location'] = empty($_GET['location']) || $_GET['location'] != 'popup' ? 0 : 2; |
1307 | 1365 | $_GET['source'] = empty($_GET['source']) ? 0 : (int) $_GET['source']; |
1308 | 1366 | |
1309 | - if (empty($_GET['source'])) |
|
1310 | - fatal_lang_error('smiley_not_found'); |
|
1367 | + if (empty($_GET['source'])) { |
|
1368 | + fatal_lang_error('smiley_not_found'); |
|
1369 | + } |
|
1311 | 1370 | |
1312 | 1371 | if (!empty($_GET['after'])) |
1313 | 1372 | { |
@@ -1323,12 +1382,12 @@ discard block |
||
1323 | 1382 | 'after_smiley' => $_GET['after'], |
1324 | 1383 | ) |
1325 | 1384 | ); |
1326 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
1327 | - fatal_lang_error('smiley_not_found'); |
|
1385 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
1386 | + fatal_lang_error('smiley_not_found'); |
|
1387 | + } |
|
1328 | 1388 | list ($smiley_row, $smiley_order, $smileyLocation) = $smcFunc['db_fetch_row']($request); |
1329 | 1389 | $smcFunc['db_free_result']($request); |
1330 | - } |
|
1331 | - else |
|
1390 | + } else |
|
1332 | 1391 | { |
1333 | 1392 | $smiley_row = (int) $_GET['row']; |
1334 | 1393 | $smiley_order = -1; |
@@ -1402,14 +1461,15 @@ discard block |
||
1402 | 1461 | $context['move_smiley'] = empty($_REQUEST['move']) ? 0 : (int) $_REQUEST['move']; |
1403 | 1462 | |
1404 | 1463 | // Make sure all rows are sequential. |
1405 | - foreach (array_keys($context['smileys']) as $location) |
|
1406 | - $context['smileys'][$location] = array( |
|
1464 | + foreach (array_keys($context['smileys']) as $location) { |
|
1465 | + $context['smileys'][$location] = array( |
|
1407 | 1466 | 'id' => $location, |
1408 | 1467 | 'title' => $location == 'postform' ? $txt['smileys_location_form'] : $txt['smileys_location_popup'], |
1409 | 1468 | 'description' => $location == 'postform' ? $txt['smileys_location_form_description'] : $txt['smileys_location_popup_description'], |
1410 | 1469 | 'last_row' => count($context['smileys'][$location]['rows']), |
1411 | 1470 | 'rows' => array_values($context['smileys'][$location]['rows']), |
1412 | 1471 | ); |
1472 | + } |
|
1413 | 1473 | |
1414 | 1474 | // Check & fix smileys that are not ordered properly in the database. |
1415 | 1475 | foreach (array_keys($context['smileys']) as $location) |
@@ -1434,8 +1494,8 @@ discard block |
||
1434 | 1494 | $context['smileys'][$location]['rows'][$id][0]['row'] = $id; |
1435 | 1495 | } |
1436 | 1496 | // Make sure the smiley order is always sequential. |
1437 | - foreach ($smiley_row as $order_id => $smiley) |
|
1438 | - if ($order_id != $smiley['order']) |
|
1497 | + foreach ($smiley_row as $order_id => $smiley) { |
|
1498 | + if ($order_id != $smiley['order']) |
|
1439 | 1499 | $smcFunc['db_query']('', ' |
1440 | 1500 | UPDATE {db_prefix}smileys |
1441 | 1501 | SET smiley_order = {int:new_order} |
@@ -1445,6 +1505,7 @@ discard block |
||
1445 | 1505 | 'current_smiley' => $smiley['id'], |
1446 | 1506 | ) |
1447 | 1507 | ); |
1508 | + } |
|
1448 | 1509 | } |
1449 | 1510 | } |
1450 | 1511 | |
@@ -1478,19 +1539,20 @@ discard block |
||
1478 | 1539 | |
1479 | 1540 | // Check that the smiley is from simplemachines.org, for now... maybe add mirroring later. |
1480 | 1541 | // @ TODO: Our current xml files serve http links. Allowing both for now until we serve https. |
1481 | - if (preg_match('~^https?://[\w_\-]+\.simplemachines\.org/~', $_REQUEST['set_gz']) == 0 || strpos($_REQUEST['set_gz'], 'dlattach') !== false) |
|
1482 | - fatal_lang_error('not_on_simplemachines'); |
|
1542 | + if (preg_match('~^https?://[\w_\-]+\.simplemachines\.org/~', $_REQUEST['set_gz']) == 0 || strpos($_REQUEST['set_gz'], 'dlattach') !== false) { |
|
1543 | + fatal_lang_error('not_on_simplemachines'); |
|
1544 | + } |
|
1483 | 1545 | |
1484 | 1546 | $destination = $packagesdir . '/' . $base_name; |
1485 | 1547 | |
1486 | - if (file_exists($destination)) |
|
1487 | - fatal_lang_error('package_upload_error_exists'); |
|
1548 | + if (file_exists($destination)) { |
|
1549 | + fatal_lang_error('package_upload_error_exists'); |
|
1550 | + } |
|
1488 | 1551 | |
1489 | 1552 | // Let's copy it to the Packages directory |
1490 | 1553 | file_put_contents($destination, fetch_web_data($_REQUEST['set_gz'])); |
1491 | 1554 | $testing = true; |
1492 | - } |
|
1493 | - elseif (isset($_REQUEST['package'])) |
|
1555 | + } elseif (isset($_REQUEST['package'])) |
|
1494 | 1556 | { |
1495 | 1557 | $base_name = basename($_REQUEST['package']); |
1496 | 1558 | $name = $smcFunc['htmlspecialchars'](strtok(basename($_REQUEST['package']), '.')); |
@@ -1499,12 +1561,14 @@ discard block |
||
1499 | 1561 | $destination = $packagesdir . '/' . basename($_REQUEST['package']); |
1500 | 1562 | } |
1501 | 1563 | |
1502 | - if (empty($destination) || !file_exists($destination)) |
|
1503 | - fatal_lang_error('package_no_file', false); |
|
1564 | + if (empty($destination) || !file_exists($destination)) { |
|
1565 | + fatal_lang_error('package_no_file', false); |
|
1566 | + } |
|
1504 | 1567 | |
1505 | 1568 | // Make sure temp directory exists and is empty. |
1506 | - if (file_exists($packagesdir . '/temp')) |
|
1507 | - deltree($packagesdir . '/temp', false); |
|
1569 | + if (file_exists($packagesdir . '/temp')) { |
|
1570 | + deltree($packagesdir . '/temp', false); |
|
1571 | + } |
|
1508 | 1572 | |
1509 | 1573 | if (!mktree($packagesdir . '/temp', 0755)) |
1510 | 1574 | { |
@@ -1516,31 +1580,37 @@ discard block |
||
1516 | 1580 | create_chmod_control(array($packagesdir . '/temp/delme.tmp'), array('destination_url' => $scripturl . '?action=admin;area=smileys;sa=install;set_gz=' . $_REQUEST['set_gz'], 'crash_on_error' => true)); |
1517 | 1581 | |
1518 | 1582 | deltree($packagesdir . '/temp', false); |
1519 | - if (!mktree($packagesdir . '/temp', 0777)) |
|
1520 | - fatal_lang_error('package_cant_download', false); |
|
1583 | + if (!mktree($packagesdir . '/temp', 0777)) { |
|
1584 | + fatal_lang_error('package_cant_download', false); |
|
1585 | + } |
|
1521 | 1586 | } |
1522 | 1587 | } |
1523 | 1588 | |
1524 | 1589 | $extracted = read_tgz_file($destination, $packagesdir . '/temp'); |
1525 | - if (!$extracted) |
|
1526 | - fatal_lang_error('packageget_unable', false, array('https://custom.simplemachines.org/mods/index.php?action=search;type=12;basic_search=' . $name)); |
|
1527 | - if ($extracted && !file_exists($packagesdir . '/temp/package-info.xml')) |
|
1528 | - foreach ($extracted as $file) |
|
1590 | + if (!$extracted) { |
|
1591 | + fatal_lang_error('packageget_unable', false, array('https://custom.simplemachines.org/mods/index.php?action=search;type=12;basic_search=' . $name)); |
|
1592 | + } |
|
1593 | + if ($extracted && !file_exists($packagesdir . '/temp/package-info.xml')) { |
|
1594 | + foreach ($extracted as $file) |
|
1529 | 1595 | if (basename($file['filename']) == 'package-info.xml') |
1530 | 1596 | { |
1531 | 1597 | $base_path = dirname($file['filename']) . '/'; |
1598 | + } |
|
1532 | 1599 | break; |
1533 | 1600 | } |
1534 | 1601 | |
1535 | - if (!isset($base_path)) |
|
1536 | - $base_path = ''; |
|
1602 | + if (!isset($base_path)) { |
|
1603 | + $base_path = ''; |
|
1604 | + } |
|
1537 | 1605 | |
1538 | - if (!file_exists($packagesdir . '/temp/' . $base_path . 'package-info.xml')) |
|
1539 | - fatal_lang_error('package_get_error_missing_xml', false); |
|
1606 | + if (!file_exists($packagesdir . '/temp/' . $base_path . 'package-info.xml')) { |
|
1607 | + fatal_lang_error('package_get_error_missing_xml', false); |
|
1608 | + } |
|
1540 | 1609 | |
1541 | 1610 | $smileyInfo = getPackageInfo($context['filename']); |
1542 | - if (!is_array($smileyInfo)) |
|
1543 | - fatal_lang_error($smileyInfo); |
|
1611 | + if (!is_array($smileyInfo)) { |
|
1612 | + fatal_lang_error($smileyInfo); |
|
1613 | + } |
|
1544 | 1614 | |
1545 | 1615 | // See if it is installed? |
1546 | 1616 | $request = $smcFunc['db_query']('', ' |
@@ -1556,8 +1626,9 @@ discard block |
||
1556 | 1626 | ) |
1557 | 1627 | ); |
1558 | 1628 | |
1559 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
1560 | - fatal_lang_error('package_installed_warning1'); |
|
1629 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
1630 | + fatal_lang_error('package_installed_warning1'); |
|
1631 | + } |
|
1561 | 1632 | |
1562 | 1633 | // Everything is fine, now it's time to do something |
1563 | 1634 | $actions = parsePackageInfo($smileyInfo['xml'], true, 'install'); |
@@ -1572,23 +1643,23 @@ discard block |
||
1572 | 1643 | if ($action['type'] == 'readme' || $action['type'] == 'license') |
1573 | 1644 | { |
1574 | 1645 | $type = 'package_' . $action['type']; |
1575 | - if (file_exists($packagesdir . '/temp/' . $base_path . $action['filename'])) |
|
1576 | - $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($packagesdir . '/temp/' . $base_path . $action['filename']), "\n\r")); |
|
1577 | - elseif (file_exists($action['filename'])) |
|
1578 | - $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($action['filename']), "\n\r")); |
|
1646 | + if (file_exists($packagesdir . '/temp/' . $base_path . $action['filename'])) { |
|
1647 | + $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($packagesdir . '/temp/' . $base_path . $action['filename']), "\n\r")); |
|
1648 | + } elseif (file_exists($action['filename'])) { |
|
1649 | + $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($action['filename']), "\n\r")); |
|
1650 | + } |
|
1579 | 1651 | |
1580 | 1652 | if (!empty($action['parse_bbc'])) |
1581 | 1653 | { |
1582 | 1654 | require_once($sourcedir . '/Subs-Post.php'); |
1583 | 1655 | preparsecode($context[$type]); |
1584 | 1656 | $context[$type] = parse_bbc($context[$type]); |
1657 | + } else { |
|
1658 | + $context[$type] = nl2br($context[$type]); |
|
1585 | 1659 | } |
1586 | - else |
|
1587 | - $context[$type] = nl2br($context[$type]); |
|
1588 | 1660 | |
1589 | 1661 | continue; |
1590 | - } |
|
1591 | - elseif ($action['type'] == 'require-dir') |
|
1662 | + } elseif ($action['type'] == 'require-dir') |
|
1592 | 1663 | { |
1593 | 1664 | // Do this one... |
1594 | 1665 | $thisAction = array( |
@@ -1607,12 +1678,12 @@ discard block |
||
1607 | 1678 | ); |
1608 | 1679 | } |
1609 | 1680 | // @todo None given? |
1610 | - if (empty($thisAction['description'])) |
|
1611 | - $thisAction['description'] = isset($action['description']) ? $action['description'] : ''; |
|
1681 | + if (empty($thisAction['description'])) { |
|
1682 | + $thisAction['description'] = isset($action['description']) ? $action['description'] : ''; |
|
1683 | + } |
|
1612 | 1684 | |
1613 | 1685 | $context['actions'][] = $thisAction; |
1614 | - } |
|
1615 | - elseif ($action['type'] == 'credits') |
|
1686 | + } elseif ($action['type'] == 'credits') |
|
1616 | 1687 | { |
1617 | 1688 | // Time to build the billboard |
1618 | 1689 | $credits_tag = array( |
@@ -1672,12 +1743,14 @@ discard block |
||
1672 | 1743 | cache_put_data('posting_smileys', null, 480); |
1673 | 1744 | } |
1674 | 1745 | |
1675 | - if (file_exists($packagesdir . '/temp')) |
|
1676 | - deltree($packagesdir . '/temp'); |
|
1746 | + if (file_exists($packagesdir . '/temp')) { |
|
1747 | + deltree($packagesdir . '/temp'); |
|
1748 | + } |
|
1677 | 1749 | |
1678 | - if (!$testing) |
|
1679 | - redirectexit('action=admin;area=smileys'); |
|
1680 | -} |
|
1750 | + if (!$testing) { |
|
1751 | + redirectexit('action=admin;area=smileys'); |
|
1752 | + } |
|
1753 | + } |
|
1681 | 1754 | |
1682 | 1755 | /** |
1683 | 1756 | * A function to import new smileys from an existing directory into the database. |
@@ -1688,16 +1761,18 @@ discard block |
||
1688 | 1761 | { |
1689 | 1762 | global $modSettings, $smcFunc; |
1690 | 1763 | |
1691 | - if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'] . '/' . $smileyPath)) |
|
1692 | - fatal_lang_error('smiley_set_unable_to_import'); |
|
1764 | + if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'] . '/' . $smileyPath)) { |
|
1765 | + fatal_lang_error('smiley_set_unable_to_import'); |
|
1766 | + } |
|
1693 | 1767 | |
1694 | 1768 | $smileys = array(); |
1695 | 1769 | $dir = dir($modSettings['smileys_dir'] . '/' . $smileyPath); |
1696 | 1770 | while ($entry = $dir->read()) |
1697 | 1771 | { |
1698 | 1772 | $filename = pathinfo($entry, PATHINFO_FILENAME); |
1699 | - if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png', '.svg'))) |
|
1700 | - $smileys[strtolower($filename)] = $filename; |
|
1773 | + if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png', '.svg'))) { |
|
1774 | + $smileys[strtolower($filename)] = $filename; |
|
1775 | + } |
|
1701 | 1776 | } |
1702 | 1777 | $dir->close(); |
1703 | 1778 | |
@@ -1710,9 +1785,10 @@ discard block |
||
1710 | 1785 | 'smiley_list' => $smileys, |
1711 | 1786 | ) |
1712 | 1787 | ); |
1713 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1714 | - if (isset($smileys[strtolower($row['filename'])])) |
|
1788 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1789 | + if (isset($smileys[strtolower($row['filename'])])) |
|
1715 | 1790 | unset($smileys[strtolower($row['filename'])]); |
1791 | + } |
|
1716 | 1792 | $smcFunc['db_free_result']($request); |
1717 | 1793 | |
1718 | 1794 | $request = $smcFunc['db_query']('', ' |
@@ -1729,9 +1805,10 @@ discard block |
||
1729 | 1805 | $smcFunc['db_free_result']($request); |
1730 | 1806 | |
1731 | 1807 | $new_smileys = array(); |
1732 | - foreach ($smileys as $smiley) |
|
1733 | - if (strlen($smiley) <= 48) |
|
1808 | + foreach ($smileys as $smiley) { |
|
1809 | + if (strlen($smiley) <= 48) |
|
1734 | 1810 | $new_smileys[] = array(':' . strtok($smiley, '.') . ':', $smiley, strtok($smiley, '.'), 0, ++$smiley_order); |
1811 | + } |
|
1735 | 1812 | |
1736 | 1813 | if (!empty($new_smileys)) |
1737 | 1814 | { |
@@ -1796,8 +1873,9 @@ discard block |
||
1796 | 1873 | if (isset($_POST['delete']) && !empty($_POST['checked_icons'])) |
1797 | 1874 | { |
1798 | 1875 | $deleteIcons = array(); |
1799 | - foreach ($_POST['checked_icons'] as $icon) |
|
1800 | - $deleteIcons[] = (int) $icon; |
|
1876 | + foreach ($_POST['checked_icons'] as $icon) { |
|
1877 | + $deleteIcons[] = (int) $icon; |
|
1878 | + } |
|
1801 | 1879 | |
1802 | 1880 | // Do the actual delete! |
1803 | 1881 | $smcFunc['db_query']('', ' |
@@ -1814,35 +1892,41 @@ discard block |
||
1814 | 1892 | $_GET['icon'] = (int) $_GET['icon']; |
1815 | 1893 | |
1816 | 1894 | // Do some preperation with the data... like check the icon exists *somewhere* |
1817 | - if (strpos($_POST['icon_filename'], '.png') !== false) |
|
1818 | - $_POST['icon_filename'] = substr($_POST['icon_filename'], 0, -4); |
|
1819 | - if (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon_filename'] . '.png')) |
|
1820 | - fatal_lang_error('icon_not_found'); |
|
1895 | + if (strpos($_POST['icon_filename'], '.png') !== false) { |
|
1896 | + $_POST['icon_filename'] = substr($_POST['icon_filename'], 0, -4); |
|
1897 | + } |
|
1898 | + if (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon_filename'] . '.png')) { |
|
1899 | + fatal_lang_error('icon_not_found'); |
|
1900 | + } |
|
1821 | 1901 | // There is a 16 character limit on message icons... |
1822 | - elseif (strlen($_POST['icon_filename']) > 16) |
|
1823 | - fatal_lang_error('icon_name_too_long'); |
|
1824 | - elseif ($_POST['icon_location'] == $_GET['icon'] && !empty($_GET['icon'])) |
|
1825 | - fatal_lang_error('icon_after_itself'); |
|
1902 | + elseif (strlen($_POST['icon_filename']) > 16) { |
|
1903 | + fatal_lang_error('icon_name_too_long'); |
|
1904 | + } elseif ($_POST['icon_location'] == $_GET['icon'] && !empty($_GET['icon'])) { |
|
1905 | + fatal_lang_error('icon_after_itself'); |
|
1906 | + } |
|
1826 | 1907 | |
1827 | 1908 | // First do the sorting... if this is an edit reduce the order of everything after it by one ;) |
1828 | 1909 | if ($_GET['icon'] != 0) |
1829 | 1910 | { |
1830 | 1911 | $oldOrder = $context['icons'][$_GET['icon']]['true_order']; |
1831 | - foreach ($context['icons'] as $id => $data) |
|
1832 | - if ($data['true_order'] > $oldOrder) |
|
1912 | + foreach ($context['icons'] as $id => $data) { |
|
1913 | + if ($data['true_order'] > $oldOrder) |
|
1833 | 1914 | $context['icons'][$id]['true_order']--; |
1915 | + } |
|
1834 | 1916 | } |
1835 | 1917 | |
1836 | 1918 | // If there are no existing icons and this is a new one, set the id to 1 (mainly for non-mysql) |
1837 | - if (empty($_GET['icon']) && empty($context['icons'])) |
|
1838 | - $_GET['icon'] = 1; |
|
1919 | + if (empty($_GET['icon']) && empty($context['icons'])) { |
|
1920 | + $_GET['icon'] = 1; |
|
1921 | + } |
|
1839 | 1922 | |
1840 | 1923 | // Get the new order. |
1841 | 1924 | $newOrder = $_POST['icon_location'] == 0 ? 0 : $context['icons'][$_POST['icon_location']]['true_order'] + 1; |
1842 | 1925 | // Do the same, but with the one that used to be after this icon, done to avoid conflict. |
1843 | - foreach ($context['icons'] as $id => $data) |
|
1844 | - if ($data['true_order'] >= $newOrder) |
|
1926 | + foreach ($context['icons'] as $id => $data) { |
|
1927 | + if ($data['true_order'] >= $newOrder) |
|
1845 | 1928 | $context['icons'][$id]['true_order']++; |
1929 | + } |
|
1846 | 1930 | |
1847 | 1931 | // Finally set the current icon's position! |
1848 | 1932 | $context['icons'][$_GET['icon']]['true_order'] = $newOrder; |
@@ -1860,8 +1944,7 @@ discard block |
||
1860 | 1944 | if ($id != 0) |
1861 | 1945 | { |
1862 | 1946 | $iconInsert[] = array($id, $icon['board_id'], $icon['title'], $icon['filename'], $icon['true_order']); |
1863 | - } |
|
1864 | - else |
|
1947 | + } else |
|
1865 | 1948 | { |
1866 | 1949 | $iconInsert_new[] = array($icon['board_id'], $icon['title'], $icon['filename'], $icon['true_order']); |
1867 | 1950 | } |
@@ -1886,8 +1969,9 @@ discard block |
||
1886 | 1969 | } |
1887 | 1970 | |
1888 | 1971 | // Unless we're adding a new thing, we'll escape |
1889 | - if (!isset($_POST['add'])) |
|
1890 | - redirectexit('action=admin;area=smileys;sa=editicons'); |
|
1972 | + if (!isset($_POST['add'])) { |
|
1973 | + redirectexit('action=admin;area=smileys;sa=editicons'); |
|
1974 | + } |
|
1891 | 1975 | } |
1892 | 1976 | |
1893 | 1977 | $context[$context['admin_menu_name']]['current_subsection'] = 'editicons'; |
@@ -1997,8 +2081,9 @@ discard block |
||
1997 | 2081 | $context['new_icon'] = !isset($_GET['icon']); |
1998 | 2082 | |
1999 | 2083 | // Get the properties of the current icon from the icon list. |
2000 | - if (!$context['new_icon']) |
|
2001 | - $context['icon'] = $context['icons'][$_GET['icon']]; |
|
2084 | + if (!$context['new_icon']) { |
|
2085 | + $context['icon'] = $context['icons'][$_GET['icon']]; |
|
2086 | + } |
|
2002 | 2087 | |
2003 | 2088 | // Get a list of boards needed for assigning this icon to a specific board. |
2004 | 2089 | $boardListOptions = array( |
@@ -2032,8 +2117,9 @@ discard block |
||
2032 | 2117 | ); |
2033 | 2118 | |
2034 | 2119 | $message_icons = array(); |
2035 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2036 | - $message_icons[] = $row; |
|
2120 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2121 | + $message_icons[] = $row; |
|
2122 | + } |
|
2037 | 2123 | $smcFunc['db_free_result']($request); |
2038 | 2124 | |
2039 | 2125 | return $message_icons; |
@@ -96,8 +96,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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) |