@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * 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,11 +71,11 @@ 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 | - } |
|
| 76 | - else |
|
| 78 | + } else |
|
| 77 | 79 | { |
| 78 | 80 | $context['error_search'] = false; |
| 79 | 81 | $context['to_fix'] = isset($_SESSION['repairboards_to_fix']) ? $_SESSION['repairboards_to_fix'] : array(); |
@@ -120,16 +122,19 @@ discard block |
||
| 120 | 122 | |
| 121 | 123 | // More time, I need more time! |
| 122 | 124 | @set_time_limit(600); |
| 123 | - if (function_exists('apache_reset_timeout')) |
|
| 124 | - @apache_reset_timeout(); |
|
| 125 | + if (function_exists('apache_reset_timeout')) { |
|
| 126 | + @apache_reset_timeout(); |
|
| 127 | + } |
|
| 125 | 128 | |
| 126 | 129 | // Errr, wait. How much time has this taken already? |
| 127 | - if (!$force && time() - array_sum(explode(' ', $time_start)) < 3) |
|
| 128 | - return; |
|
| 130 | + if (!$force && time() - array_sum(explode(' ', $time_start)) < 3) { |
|
| 131 | + return; |
|
| 132 | + } |
|
| 129 | 133 | |
| 130 | 134 | // Restore the query cache if interested. |
| 131 | - if (!empty($db_temp_cache)) |
|
| 132 | - $db_cache = $db_temp_cache; |
|
| 135 | + if (!empty($db_temp_cache)) { |
|
| 136 | + $db_cache = $db_temp_cache; |
|
| 137 | + } |
|
| 133 | 138 | |
| 134 | 139 | $context['continue_get_data'] = '?action=admin;area=repairboards' . (isset($_GET['fixErrors']) ? ';fixErrors' : '') . ';step=' . $_GET['step'] . ';substep=' . $_GET['substep'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
| 135 | 140 | $context['page_title'] = $txt['not_done_title']; |
@@ -138,10 +143,11 @@ discard block |
||
| 138 | 143 | $context['sub_template'] = 'not_done'; |
| 139 | 144 | |
| 140 | 145 | // Change these two if more steps are added! |
| 141 | - if (empty($max_substep)) |
|
| 142 | - $context['continue_percent'] = round(($_GET['step'] * 100) / $context['total_steps']); |
|
| 143 | - else |
|
| 144 | - $context['continue_percent'] = round((($_GET['step'] + ($_GET['substep'] / $max_substep)) * 100) / $context['total_steps']); |
|
| 146 | + if (empty($max_substep)) { |
|
| 147 | + $context['continue_percent'] = round(($_GET['step'] * 100) / $context['total_steps']); |
|
| 148 | + } else { |
|
| 149 | + $context['continue_percent'] = round((($_GET['step'] + ($_GET['substep'] / $max_substep)) * 100) / $context['total_steps']); |
|
| 150 | + } |
|
| 145 | 151 | |
| 146 | 152 | // Never more than 100%! |
| 147 | 153 | $context['continue_percent'] = min($context['continue_percent'], 100); |
@@ -612,8 +618,9 @@ discard block |
||
| 612 | 618 | $row['myid_last_msg'] = (int) $row['myid_last_msg']; |
| 613 | 619 | |
| 614 | 620 | // Not really a problem? |
| 615 | - if ($row['myid_first_msg'] == $row['myid_first_msg'] && $row['myid_first_msg'] == $row['myid_first_msg'] && $row['approved'] == $row['firstmsg_approved']) |
|
| 616 | - return false; |
|
| 621 | + if ($row['myid_first_msg'] == $row['myid_first_msg'] && $row['myid_first_msg'] == $row['myid_first_msg'] && $row['approved'] == $row['firstmsg_approved']) { |
|
| 622 | + return false; |
|
| 623 | + } |
|
| 617 | 624 | |
| 618 | 625 | $memberStartedID = (int) getMsgMemberID($row['myid_first_msg']); |
| 619 | 626 | $memberUpdatedID = (int) getMsgMemberID($row['myid_last_msg']); |
@@ -637,15 +644,19 @@ discard block |
||
| 637 | 644 | 'message_function' => function ($row) use ($txt, &$context) |
| 638 | 645 | { |
| 639 | 646 | // A pretend error? |
| 640 | - if ($row['myid_first_msg'] == $row['myid_first_msg'] && $row['myid_first_msg'] == $row['myid_first_msg'] && $row['approved'] == $row['firstmsg_approved']) |
|
| 641 | - return false; |
|
| 647 | + if ($row['myid_first_msg'] == $row['myid_first_msg'] && $row['myid_first_msg'] == $row['myid_first_msg'] && $row['approved'] == $row['firstmsg_approved']) { |
|
| 648 | + return false; |
|
| 649 | + } |
|
| 642 | 650 | |
| 643 | - if ($row['id_first_msg'] != $row['myid_first_msg']) |
|
| 644 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_1'], $row['id_topic'], $row['id_first_msg']); |
|
| 645 | - if ($row['id_last_msg'] != $row['myid_last_msg']) |
|
| 646 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_2'], $row['id_topic'], $row['id_last_msg']); |
|
| 647 | - if ($row['approved'] != $row['firstmsg_approved']) |
|
| 648 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_5'], $row['id_topic']); |
|
| 651 | + if ($row['id_first_msg'] != $row['myid_first_msg']) { |
|
| 652 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_1'], $row['id_topic'], $row['id_first_msg']); |
|
| 653 | + } |
|
| 654 | + if ($row['id_last_msg'] != $row['myid_last_msg']) { |
|
| 655 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_2'], $row['id_topic'], $row['id_last_msg']); |
|
| 656 | + } |
|
| 657 | + if ($row['approved'] != $row['firstmsg_approved']) { |
|
| 658 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_5'], $row['id_topic']); |
|
| 659 | + } |
|
| 649 | 660 | |
| 650 | 661 | return true; |
| 651 | 662 | }, |
@@ -675,8 +686,9 @@ discard block |
||
| 675 | 686 | $row['my_num_replies'] = (int) $row['my_num_replies']; |
| 676 | 687 | |
| 677 | 688 | // Not really a problem? |
| 678 | - if ($row['my_num_replies'] == $row['num_replies']) |
|
| 679 | - return false; |
|
| 689 | + if ($row['my_num_replies'] == $row['num_replies']) { |
|
| 690 | + return false; |
|
| 691 | + } |
|
| 680 | 692 | |
| 681 | 693 | $smcFunc['db_query']('', ' |
| 682 | 694 | UPDATE {db_prefix}topics |
@@ -695,11 +707,13 @@ discard block |
||
| 695 | 707 | global $txt, $context; |
| 696 | 708 | |
| 697 | 709 | // Just joking? |
| 698 | - if ($row['my_num_replies'] == $row['num_replies']) |
|
| 699 | - return false; |
|
| 710 | + if ($row['my_num_replies'] == $row['num_replies']) { |
|
| 711 | + return false; |
|
| 712 | + } |
|
| 700 | 713 | |
| 701 | - if ($row['num_replies'] != $row['my_num_replies']) |
|
| 702 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_3'], $row['id_topic'], $row['num_replies']); |
|
| 714 | + if ($row['num_replies'] != $row['my_num_replies']) { |
|
| 715 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_3'], $row['id_topic'], $row['num_replies']); |
|
| 716 | + } |
|
| 703 | 717 | |
| 704 | 718 | return true; |
| 705 | 719 | |
@@ -1290,8 +1304,9 @@ discard block |
||
| 1290 | 1304 | $inserts = array(); |
| 1291 | 1305 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 1292 | 1306 | { |
| 1293 | - foreach (text2words($row['subject']) as $word) |
|
| 1294 | - $inserts[] = array($word, $row['id_topic']); |
|
| 1307 | + foreach (text2words($row['subject']) as $word) { |
|
| 1308 | + $inserts[] = array($word, $row['id_topic']); |
|
| 1309 | + } |
|
| 1295 | 1310 | if (count($inserts) > 500) |
| 1296 | 1311 | { |
| 1297 | 1312 | $smcFunc['db_insert']('ignore', |
@@ -1305,13 +1320,14 @@ discard block |
||
| 1305 | 1320 | |
| 1306 | 1321 | } |
| 1307 | 1322 | |
| 1308 | - if (!empty($inserts)) |
|
| 1309 | - $smcFunc['db_insert']('ignore', |
|
| 1323 | + if (!empty($inserts)) { |
|
| 1324 | + $smcFunc['db_insert']('ignore', |
|
| 1310 | 1325 | '{db_prefix}log_search_subjects', |
| 1311 | 1326 | array('word' => 'string', 'id_topic' => 'int'), |
| 1312 | 1327 | $inserts, |
| 1313 | 1328 | array('word', 'id_topic') |
| 1314 | 1329 | ); |
| 1330 | + } |
|
| 1315 | 1331 | |
| 1316 | 1332 | }, |
| 1317 | 1333 | 'message_function' => function ($row) |
@@ -1581,8 +1597,9 @@ discard block |
||
| 1581 | 1597 | $current_step++; |
| 1582 | 1598 | |
| 1583 | 1599 | // Already done this? |
| 1584 | - if ($_GET['step'] > $current_step) |
|
| 1585 | - continue; |
|
| 1600 | + if ($_GET['step'] > $current_step) { |
|
| 1601 | + continue; |
|
| 1602 | + } |
|
| 1586 | 1603 | |
| 1587 | 1604 | // If we're fixing it but it ain't broke why try? |
| 1588 | 1605 | if ($do_fix && !in_array($error_type, $to_fix)) |
@@ -1611,14 +1628,16 @@ discard block |
||
| 1611 | 1628 | while (!$done) |
| 1612 | 1629 | { |
| 1613 | 1630 | // Make sure there's at least one ID to test. |
| 1614 | - if (isset($test['substeps']) && empty($step_max)) |
|
| 1615 | - break; |
|
| 1631 | + if (isset($test['substeps']) && empty($step_max)) { |
|
| 1632 | + break; |
|
| 1633 | + } |
|
| 1616 | 1634 | |
| 1617 | 1635 | // What is the testing query (Changes if we are testing or fixing) |
| 1618 | - if (!$do_fix) |
|
| 1619 | - $test_query = 'check_query'; |
|
| 1620 | - else |
|
| 1621 | - $test_query = isset($test['fix_query']) ? 'fix_query' : 'check_query'; |
|
| 1636 | + if (!$do_fix) { |
|
| 1637 | + $test_query = 'check_query'; |
|
| 1638 | + } else { |
|
| 1639 | + $test_query = isset($test['fix_query']) ? 'fix_query' : 'check_query'; |
|
| 1640 | + } |
|
| 1622 | 1641 | |
| 1623 | 1642 | // Do the test... |
| 1624 | 1643 | $request = $smcFunc['db_query']('', |
@@ -1628,10 +1647,11 @@ discard block |
||
| 1628 | 1647 | ); |
| 1629 | 1648 | |
| 1630 | 1649 | // Does it need a fix? |
| 1631 | - if (!empty($test['check_type']) && $test['check_type'] == 'count') |
|
| 1632 | - list ($needs_fix) = $smcFunc['db_fetch_row']($request); |
|
| 1633 | - else |
|
| 1634 | - $needs_fix = $smcFunc['db_num_rows']($request); |
|
| 1650 | + if (!empty($test['check_type']) && $test['check_type'] == 'count') { |
|
| 1651 | + list ($needs_fix) = $smcFunc['db_fetch_row']($request); |
|
| 1652 | + } else { |
|
| 1653 | + $needs_fix = $smcFunc['db_num_rows']($request); |
|
| 1654 | + } |
|
| 1635 | 1655 | |
| 1636 | 1656 | $total_queries++; |
| 1637 | 1657 | |
@@ -1643,8 +1663,9 @@ discard block |
||
| 1643 | 1663 | // Assume need to fix. |
| 1644 | 1664 | $found_errors = true; |
| 1645 | 1665 | |
| 1646 | - if (isset($test['message'])) |
|
| 1647 | - $context['repair_errors'][] = $txt[$test['message']]; |
|
| 1666 | + if (isset($test['message'])) { |
|
| 1667 | + $context['repair_errors'][] = $txt[$test['message']]; |
|
| 1668 | + } |
|
| 1648 | 1669 | |
| 1649 | 1670 | // One per row! |
| 1650 | 1671 | elseif (isset($test['messages'])) |
@@ -1654,10 +1675,11 @@ discard block |
||
| 1654 | 1675 | $variables = $test['messages']; |
| 1655 | 1676 | foreach ($variables as $k => $v) |
| 1656 | 1677 | { |
| 1657 | - if ($k == 0 && isset($txt[$v])) |
|
| 1658 | - $variables[$k] = $txt[$v]; |
|
| 1659 | - elseif ($k > 0 && isset($row[$v])) |
|
| 1660 | - $variables[$k] = $row[$v]; |
|
| 1678 | + if ($k == 0 && isset($txt[$v])) { |
|
| 1679 | + $variables[$k] = $txt[$v]; |
|
| 1680 | + } elseif ($k > 0 && isset($row[$v])) { |
|
| 1681 | + $variables[$k] = $row[$v]; |
|
| 1682 | + } |
|
| 1661 | 1683 | } |
| 1662 | 1684 | $context['repair_errors'][] = call_user_func_array('sprintf', $variables); |
| 1663 | 1685 | } |
@@ -1668,13 +1690,15 @@ discard block |
||
| 1668 | 1690 | { |
| 1669 | 1691 | // Find out if there are actually errors. |
| 1670 | 1692 | $found_errors = false; |
| 1671 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1672 | - $found_errors |= $test['message_function']($row); |
|
| 1693 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1694 | + $found_errors |= $test['message_function']($row); |
|
| 1695 | + } |
|
| 1673 | 1696 | } |
| 1674 | 1697 | |
| 1675 | 1698 | // Actually have something to fix? |
| 1676 | - if ($found_errors) |
|
| 1677 | - $to_fix[] = $error_type; |
|
| 1699 | + if ($found_errors) { |
|
| 1700 | + $to_fix[] = $error_type; |
|
| 1701 | + } |
|
| 1678 | 1702 | } |
| 1679 | 1703 | |
| 1680 | 1704 | // We want to fix, we need to fix - so work out what exactly to do! |
@@ -1684,8 +1708,9 @@ discard block |
||
| 1684 | 1708 | if (isset($test['fix_collect'])) |
| 1685 | 1709 | { |
| 1686 | 1710 | $ids = array(); |
| 1687 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1688 | - $ids[] = $row[$test['fix_collect']['index']]; |
|
| 1711 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1712 | + $ids[] = $row[$test['fix_collect']['index']]; |
|
| 1713 | + } |
|
| 1689 | 1714 | if (!empty($ids)) |
| 1690 | 1715 | { |
| 1691 | 1716 | // Fix it! |
@@ -1694,30 +1719,34 @@ discard block |
||
| 1694 | 1719 | } |
| 1695 | 1720 | |
| 1696 | 1721 | // Simply executing a fix it query? |
| 1697 | - elseif (isset($test['fix_it_query'])) |
|
| 1698 | - $smcFunc['db_query']('', |
|
| 1722 | + elseif (isset($test['fix_it_query'])) { |
|
| 1723 | + $smcFunc['db_query']('', |
|
| 1699 | 1724 | $test['fix_it_query'], |
| 1700 | 1725 | array( |
| 1701 | 1726 | ) |
| 1702 | 1727 | ); |
| 1728 | + } |
|
| 1703 | 1729 | |
| 1704 | 1730 | // Do we have some processing to do? |
| 1705 | 1731 | elseif (isset($test['fix_processing'])) |
| 1706 | 1732 | { |
| 1707 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1708 | - $test['fix_processing']($row); |
|
| 1733 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1734 | + $test['fix_processing']($row); |
|
| 1735 | + } |
|
| 1709 | 1736 | } |
| 1710 | 1737 | |
| 1711 | 1738 | // What about the full set of processing? |
| 1712 | - elseif (isset($test['fix_full_processing'])) |
|
| 1713 | - $test['fix_full_processing']($request); |
|
| 1739 | + elseif (isset($test['fix_full_processing'])) { |
|
| 1740 | + $test['fix_full_processing']($request); |
|
| 1741 | + } |
|
| 1714 | 1742 | |
| 1715 | 1743 | // Do we have other things we need to fix as a result? |
| 1716 | 1744 | if (!empty($test['force_fix'])) |
| 1717 | 1745 | { |
| 1718 | - foreach ($test['force_fix'] as $item) |
|
| 1719 | - if (!in_array($item, $to_fix)) |
|
| 1746 | + foreach ($test['force_fix'] as $item) { |
|
| 1747 | + if (!in_array($item, $to_fix)) |
|
| 1720 | 1748 | $to_fix[] = $item; |
| 1749 | + } |
|
| 1721 | 1750 | } |
| 1722 | 1751 | } |
| 1723 | 1752 | } |
@@ -1735,16 +1764,17 @@ discard block |
||
| 1735 | 1764 | if ($_GET['substep'] <= $step_max) |
| 1736 | 1765 | { |
| 1737 | 1766 | pauseRepairProcess($to_fix, $error_type, $step_max); |
| 1767 | + } else { |
|
| 1768 | + $done = true; |
|
| 1738 | 1769 | } |
| 1739 | - else |
|
| 1740 | - $done = true; |
|
| 1770 | + } else { |
|
| 1771 | + $done = true; |
|
| 1741 | 1772 | } |
| 1742 | - else |
|
| 1743 | - $done = true; |
|
| 1744 | 1773 | |
| 1745 | 1774 | // Don't allow more than 1000 queries at a time. |
| 1746 | - if ($total_queries >= 1000) |
|
| 1747 | - pauseRepairProcess($to_fix, $error_type, $step_max, true); |
|
| 1775 | + if ($total_queries >= 1000) { |
|
| 1776 | + pauseRepairProcess($to_fix, $error_type, $step_max, true); |
|
| 1777 | + } |
|
| 1748 | 1778 | } |
| 1749 | 1779 | |
| 1750 | 1780 | // Keep going. |
@@ -1757,8 +1787,9 @@ discard block |
||
| 1757 | 1787 | if ($do_fix) |
| 1758 | 1788 | { |
| 1759 | 1789 | $key = array_search($error_type, $to_fix); |
| 1760 | - if ($key !== false && isset($to_fix[$key])) |
|
| 1761 | - unset($to_fix[$key]); |
|
| 1790 | + if ($key !== false && isset($to_fix[$key])) { |
|
| 1791 | + unset($to_fix[$key]); |
|
| 1792 | + } |
|
| 1762 | 1793 | } |
| 1763 | 1794 | |
| 1764 | 1795 | // Are we done? |
@@ -1781,10 +1812,11 @@ discard block |
||
| 1781 | 1812 | static $createOnce = false; |
| 1782 | 1813 | |
| 1783 | 1814 | // Have we already created it? |
| 1784 | - if ($createOnce) |
|
| 1785 | - return; |
|
| 1786 | - else |
|
| 1787 | - $createOnce = true; |
|
| 1815 | + if ($createOnce) { |
|
| 1816 | + return; |
|
| 1817 | + } else { |
|
| 1818 | + $createOnce = true; |
|
| 1819 | + } |
|
| 1788 | 1820 | |
| 1789 | 1821 | // Back to the forum's default language. |
| 1790 | 1822 | loadLanguage('Admin', $language); |
@@ -1799,8 +1831,9 @@ discard block |
||
| 1799 | 1831 | 'cat_name' => $txt['salvaged_category_name'], |
| 1800 | 1832 | ) |
| 1801 | 1833 | ); |
| 1802 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
| 1803 | - list ($salvageCatID) = $smcFunc['db_fetch_row']($result); |
|
| 1834 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
| 1835 | + list ($salvageCatID) = $smcFunc['db_fetch_row']($result); |
|
| 1836 | + } |
|
| 1804 | 1837 | $smcFunc['db_free_result']($result); |
| 1805 | 1838 | |
| 1806 | 1839 | if (empty($salvageCatID)) |
@@ -1832,8 +1865,9 @@ discard block |
||
| 1832 | 1865 | 'board_name' => $txt['salvaged_board_name'], |
| 1833 | 1866 | ) |
| 1834 | 1867 | ); |
| 1835 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
| 1836 | - list ($salvageBoardID) = $smcFunc['db_fetch_row']($result); |
|
| 1868 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
| 1869 | + list ($salvageBoardID) = $smcFunc['db_fetch_row']($result); |
|
| 1870 | + } |
|
| 1837 | 1871 | $smcFunc['db_free_result']($result); |
| 1838 | 1872 | |
| 1839 | 1873 | if (empty($salvageBoardID)) |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Load the $modSettings array. |
@@ -25,13 +26,14 @@ discard block |
||
| 25 | 26 | global $cache_enable, $sourcedir, $context; |
| 26 | 27 | |
| 27 | 28 | // Most database systems have not set UTF-8 as their default input charset. |
| 28 | - if (!empty($db_character_set)) |
|
| 29 | - $smcFunc['db_query']('', ' |
|
| 29 | + if (!empty($db_character_set)) { |
|
| 30 | + $smcFunc['db_query']('', ' |
|
| 30 | 31 | SET NAMES {string:db_character_set}', |
| 31 | 32 | array( |
| 32 | 33 | 'db_character_set' => $db_character_set, |
| 33 | 34 | ) |
| 34 | 35 | ); |
| 36 | + } |
|
| 35 | 37 | |
| 36 | 38 | // We need some caching support, maybe. |
| 37 | 39 | loadCacheAccelerator(); |
@@ -46,27 +48,35 @@ discard block |
||
| 46 | 48 | ) |
| 47 | 49 | ); |
| 48 | 50 | $modSettings = array(); |
| 49 | - if (!$request) |
|
| 50 | - display_db_error(); |
|
| 51 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 52 | - $modSettings[$row[0]] = $row[1]; |
|
| 51 | + if (!$request) { |
|
| 52 | + display_db_error(); |
|
| 53 | + } |
|
| 54 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 55 | + $modSettings[$row[0]] = $row[1]; |
|
| 56 | + } |
|
| 53 | 57 | $smcFunc['db_free_result']($request); |
| 54 | 58 | |
| 55 | 59 | // Do a few things to protect against missing settings or settings with invalid values... |
| 56 | - if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) |
|
| 57 | - $modSettings['defaultMaxTopics'] = 20; |
|
| 58 | - if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) |
|
| 59 | - $modSettings['defaultMaxMessages'] = 15; |
|
| 60 | - if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) |
|
| 61 | - $modSettings['defaultMaxMembers'] = 30; |
|
| 62 | - if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999) |
|
| 63 | - $modSettings['defaultMaxListItems'] = 15; |
|
| 60 | + if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) { |
|
| 61 | + $modSettings['defaultMaxTopics'] = 20; |
|
| 62 | + } |
|
| 63 | + if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) { |
|
| 64 | + $modSettings['defaultMaxMessages'] = 15; |
|
| 65 | + } |
|
| 66 | + if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) { |
|
| 67 | + $modSettings['defaultMaxMembers'] = 30; |
|
| 68 | + } |
|
| 69 | + if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999) { |
|
| 70 | + $modSettings['defaultMaxListItems'] = 15; |
|
| 71 | + } |
|
| 64 | 72 | |
| 65 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
| 66 | - $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
| 73 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
| 74 | + $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
| 75 | + } |
|
| 67 | 76 | |
| 68 | - if (!empty($cache_enable)) |
|
| 69 | - cache_put_data('modSettings', $modSettings, 90); |
|
| 77 | + if (!empty($cache_enable)) { |
|
| 78 | + cache_put_data('modSettings', $modSettings, 90); |
|
| 79 | + } |
|
| 70 | 80 | } |
| 71 | 81 | |
| 72 | 82 | $modSettings['cache_enable'] = $cache_enable; |
@@ -86,8 +96,9 @@ discard block |
||
| 86 | 96 | }; |
| 87 | 97 | $fix_utf8mb4 = function($string) use ($utf8, $smcFunc) |
| 88 | 98 | { |
| 89 | - if (!$utf8 || $smcFunc['db_mb4']) |
|
| 90 | - return $string; |
|
| 99 | + if (!$utf8 || $smcFunc['db_mb4']) { |
|
| 100 | + return $string; |
|
| 101 | + } |
|
| 91 | 102 | |
| 92 | 103 | $i = 0; |
| 93 | 104 | $len = strlen($string); |
@@ -99,18 +110,15 @@ discard block |
||
| 99 | 110 | { |
| 100 | 111 | $new_string .= $string[$i]; |
| 101 | 112 | $i++; |
| 102 | - } |
|
| 103 | - elseif ($ord < 224) |
|
| 113 | + } elseif ($ord < 224) |
|
| 104 | 114 | { |
| 105 | 115 | $new_string .= $string[$i] . $string[$i + 1]; |
| 106 | 116 | $i += 2; |
| 107 | - } |
|
| 108 | - elseif ($ord < 240) |
|
| 117 | + } elseif ($ord < 240) |
|
| 109 | 118 | { |
| 110 | 119 | $new_string .= $string[$i] . $string[$i + 1] . $string[$i + 2]; |
| 111 | 120 | $i += 3; |
| 112 | - } |
|
| 113 | - elseif ($ord < 248) |
|
| 121 | + } elseif ($ord < 248) |
|
| 114 | 122 | { |
| 115 | 123 | // Magic happens. |
| 116 | 124 | $val = (ord($string[$i]) & 0x07) << 18; |
@@ -154,8 +162,7 @@ discard block |
||
| 154 | 162 | { |
| 155 | 163 | $result = array_search($needle, array_slice($haystack_arr, $offset)); |
| 156 | 164 | return is_int($result) ? $result + $offset : false; |
| 157 | - } |
|
| 158 | - else |
|
| 165 | + } else |
|
| 159 | 166 | { |
| 160 | 167 | $needle_arr = preg_split('~(&#' . (empty($modSettings['disableEntityCheck']) ? '\d{1,7}' : '021') . ';|"|&|<|>| |.)~' . ($utf8 ? 'u' : '') . '', $ent_check($needle), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
| 161 | 168 | $needle_size = count($needle_arr); |
@@ -164,8 +171,9 @@ discard block |
||
| 164 | 171 | while ((int) $result === $result) |
| 165 | 172 | { |
| 166 | 173 | $offset += $result; |
| 167 | - if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) |
|
| 168 | - return $offset; |
|
| 174 | + if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) { |
|
| 175 | + return $offset; |
|
| 176 | + } |
|
| 169 | 177 | $result = array_search($needle_arr[0], array_slice($haystack_arr, ++$offset)); |
| 170 | 178 | } |
| 171 | 179 | return false; |
@@ -203,8 +211,9 @@ discard block |
||
| 203 | 211 | $string = $ent_check($string); |
| 204 | 212 | preg_match('~^(' . $ent_list . '|.){' . $smcFunc['strlen'](substr($string, 0, $length)) . '}~' . ($utf8 ? 'u' : ''), $string, $matches); |
| 205 | 213 | $string = $matches[0]; |
| 206 | - while (strlen($string) > $length) |
|
| 207 | - $string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string); |
|
| 214 | + while (strlen($string) > $length) { |
|
| 215 | + $string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string); |
|
| 216 | + } |
|
| 208 | 217 | return $string; |
| 209 | 218 | }, |
| 210 | 219 | 'ucfirst' => $utf8 ? function($string) use (&$smcFunc) |
@@ -214,23 +223,25 @@ discard block |
||
| 214 | 223 | 'ucwords' => $utf8 ? function($string) use (&$smcFunc) |
| 215 | 224 | { |
| 216 | 225 | $words = preg_split('~([\s\r\n\t]+)~', $string, -1, PREG_SPLIT_DELIM_CAPTURE); |
| 217 | - for ($i = 0, $n = count($words); $i < $n; $i += 2) |
|
| 218 | - $words[$i] = $smcFunc['ucfirst']($words[$i]); |
|
| 226 | + for ($i = 0, $n = count($words); $i < $n; $i += 2) { |
|
| 227 | + $words[$i] = $smcFunc['ucfirst']($words[$i]); |
|
| 228 | + } |
|
| 219 | 229 | return implode('', $words); |
| 220 | 230 | } : 'ucwords', |
| 221 | 231 | ); |
| 222 | 232 | |
| 223 | 233 | // Setting the timezone is a requirement for some functions. |
| 224 | - if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) |
|
| 225 | - date_default_timezone_set($modSettings['default_timezone']); |
|
| 226 | - else |
|
| 234 | + if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) { |
|
| 235 | + date_default_timezone_set($modSettings['default_timezone']); |
|
| 236 | + } else |
|
| 227 | 237 | { |
| 228 | 238 | // Get PHP's default timezone, if set |
| 229 | 239 | $ini_tz = ini_get('date.timezone'); |
| 230 | - if (!empty($ini_tz)) |
|
| 231 | - $modSettings['default_timezone'] = $ini_tz; |
|
| 232 | - else |
|
| 233 | - $modSettings['default_timezone'] = ''; |
|
| 240 | + if (!empty($ini_tz)) { |
|
| 241 | + $modSettings['default_timezone'] = $ini_tz; |
|
| 242 | + } else { |
|
| 243 | + $modSettings['default_timezone'] = ''; |
|
| 244 | + } |
|
| 234 | 245 | |
| 235 | 246 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
| 236 | 247 | if (!in_array($modSettings['default_timezone'], timezone_identifiers_list())) |
@@ -248,22 +259,26 @@ discard block |
||
| 248 | 259 | if (($modSettings['load_average'] = cache_get_data('loadavg', 90)) == null) |
| 249 | 260 | { |
| 250 | 261 | $modSettings['load_average'] = @file_get_contents('/proc/loadavg'); |
| 251 | - if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) |
|
| 252 | - $modSettings['load_average'] = (float) $matches[1]; |
|
| 253 | - elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) |
|
| 254 | - $modSettings['load_average'] = (float) $matches[1]; |
|
| 255 | - else |
|
| 256 | - unset($modSettings['load_average']); |
|
| 262 | + if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) { |
|
| 263 | + $modSettings['load_average'] = (float) $matches[1]; |
|
| 264 | + } elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) { |
|
| 265 | + $modSettings['load_average'] = (float) $matches[1]; |
|
| 266 | + } else { |
|
| 267 | + unset($modSettings['load_average']); |
|
| 268 | + } |
|
| 257 | 269 | |
| 258 | - if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
|
| 259 | - cache_put_data('loadavg', $modSettings['load_average'], 90); |
|
| 270 | + if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) { |
|
| 271 | + cache_put_data('loadavg', $modSettings['load_average'], 90); |
|
| 272 | + } |
|
| 260 | 273 | } |
| 261 | 274 | |
| 262 | - if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
|
| 263 | - call_integration_hook('integrate_load_average', array($modSettings['load_average'])); |
|
| 275 | + if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) { |
|
| 276 | + call_integration_hook('integrate_load_average', array($modSettings['load_average'])); |
|
| 277 | + } |
|
| 264 | 278 | |
| 265 | - if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) |
|
| 266 | - display_loadavg_error(); |
|
| 279 | + if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) { |
|
| 280 | + display_loadavg_error(); |
|
| 281 | + } |
|
| 267 | 282 | } |
| 268 | 283 | |
| 269 | 284 | // Is post moderation alive and well? Everywhere else assumes this has been defined, so let's make sure it is. |
@@ -284,8 +299,9 @@ discard block |
||
| 284 | 299 | if (defined('SMF_INTEGRATION_SETTINGS')) |
| 285 | 300 | { |
| 286 | 301 | $integration_settings = smf_json_decode(SMF_INTEGRATION_SETTINGS, true); |
| 287 | - foreach ($integration_settings as $hook => $function) |
|
| 288 | - add_integration_function($hook, $function, '', false); |
|
| 302 | + foreach ($integration_settings as $hook => $function) { |
|
| 303 | + add_integration_function($hook, $function, '', false); |
|
| 304 | + } |
|
| 289 | 305 | } |
| 290 | 306 | |
| 291 | 307 | // Any files to pre include? |
@@ -295,8 +311,9 @@ discard block |
||
| 295 | 311 | foreach ($pre_includes as $include) |
| 296 | 312 | { |
| 297 | 313 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
| 298 | - if (file_exists($include)) |
|
| 299 | - require_once($include); |
|
| 314 | + if (file_exists($include)) { |
|
| 315 | + require_once($include); |
|
| 316 | + } |
|
| 300 | 317 | } |
| 301 | 318 | } |
| 302 | 319 | |
@@ -400,27 +417,28 @@ discard block |
||
| 400 | 417 | break; |
| 401 | 418 | } |
| 402 | 419 | } |
| 420 | + } else { |
|
| 421 | + $id_member = 0; |
|
| 403 | 422 | } |
| 404 | - else |
|
| 405 | - $id_member = 0; |
|
| 406 | 423 | |
| 407 | 424 | if (empty($id_member) && isset($_COOKIE[$cookiename])) |
| 408 | 425 | { |
| 409 | 426 | $cookie_data = smf_json_decode($_COOKIE[$cookiename], true, false); |
| 410 | 427 | |
| 411 | - if (empty($cookie_data)) |
|
| 412 | - $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
| 428 | + if (empty($cookie_data)) { |
|
| 429 | + $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
| 430 | + } |
|
| 413 | 431 | |
| 414 | 432 | list ($id_member, $password) = $cookie_data; |
| 415 | 433 | $id_member = !empty($id_member) && strlen($password) > 0 ? (int) $id_member : 0; |
| 416 | - } |
|
| 417 | - elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
| 434 | + } elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
| 418 | 435 | { |
| 419 | 436 | // @todo Perhaps we can do some more checking on this, such as on the first octet of the IP? |
| 420 | 437 | $cookie_data = smf_json_decode($_SESSION['login_' . $cookiename]); |
| 421 | 438 | |
| 422 | - if (empty($cookie_data)) |
|
| 423 | - $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
| 439 | + if (empty($cookie_data)) { |
|
| 440 | + $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
| 441 | + } |
|
| 424 | 442 | |
| 425 | 443 | list ($id_member, $password, $login_span) = $cookie_data; |
| 426 | 444 | $id_member = !empty($id_member) && strlen($password) == 128 && $login_span > time() ? (int) $id_member : 0; |
@@ -445,30 +463,34 @@ discard block |
||
| 445 | 463 | $user_settings = $smcFunc['db_fetch_assoc']($request); |
| 446 | 464 | $smcFunc['db_free_result']($request); |
| 447 | 465 | |
| 448 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false) |
|
| 449 | - $user_settings['avatar'] = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($user_settings['avatar']) . '&hash=' . md5($user_settings['avatar'] . $image_proxy_secret); |
|
| 466 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false) { |
|
| 467 | + $user_settings['avatar'] = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($user_settings['avatar']) . '&hash=' . md5($user_settings['avatar'] . $image_proxy_secret); |
|
| 468 | + } |
|
| 450 | 469 | |
| 451 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 452 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
| 470 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 471 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
| 472 | + } |
|
| 453 | 473 | } |
| 454 | 474 | |
| 455 | 475 | // Did we find 'im? If not, junk it. |
| 456 | 476 | if (!empty($user_settings)) |
| 457 | 477 | { |
| 458 | 478 | // As much as the password should be right, we can assume the integration set things up. |
| 459 | - if (!empty($already_verified) && $already_verified === true) |
|
| 460 | - $check = true; |
|
| 479 | + if (!empty($already_verified) && $already_verified === true) { |
|
| 480 | + $check = true; |
|
| 481 | + } |
|
| 461 | 482 | // SHA-512 hash should be 128 characters long. |
| 462 | - elseif (strlen($password) == 128) |
|
| 463 | - $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
| 464 | - else |
|
| 465 | - $check = false; |
|
| 483 | + elseif (strlen($password) == 128) { |
|
| 484 | + $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
| 485 | + } else { |
|
| 486 | + $check = false; |
|
| 487 | + } |
|
| 466 | 488 | |
| 467 | 489 | // Wrong password or not activated - either way, you're going nowhere. |
| 468 | 490 | $id_member = $check && ($user_settings['is_activated'] == 1 || $user_settings['is_activated'] == 11) ? (int) $user_settings['id_member'] : 0; |
| 491 | + } else { |
|
| 492 | + $id_member = 0; |
|
| 469 | 493 | } |
| 470 | - else |
|
| 471 | - $id_member = 0; |
|
| 472 | 494 | |
| 473 | 495 | // If we no longer have the member maybe they're being all hackey, stop brute force! |
| 474 | 496 | if (!$id_member) |
@@ -490,13 +512,15 @@ discard block |
||
| 490 | 512 | { |
| 491 | 513 | $tfa_data = smf_json_decode($_COOKIE[$tfacookie]); |
| 492 | 514 | |
| 493 | - if (is_null($tfa_data)) |
|
| 494 | - $tfa_data = safe_unserialize($_COOKIE[$tfacookie]); |
|
| 515 | + if (is_null($tfa_data)) { |
|
| 516 | + $tfa_data = safe_unserialize($_COOKIE[$tfacookie]); |
|
| 517 | + } |
|
| 495 | 518 | |
| 496 | 519 | list ($tfamember, $tfasecret) = $tfa_data; |
| 497 | 520 | |
| 498 | - if ((int) $tfamember != $id_member) |
|
| 499 | - $tfasecret = null; |
|
| 521 | + if ((int) $tfamember != $id_member) { |
|
| 522 | + $tfasecret = null; |
|
| 523 | + } |
|
| 500 | 524 | } |
| 501 | 525 | |
| 502 | 526 | if (empty($tfasecret) || hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']) != $tfasecret) |
@@ -516,10 +540,12 @@ discard block |
||
| 516 | 540 | // Are we forcing 2FA? Need to check if the user groups actually require 2FA |
| 517 | 541 | elseif (!empty($modSettings['tfa_mode']) && $modSettings['tfa_mode'] >= 2 && $id_member && empty($user_settings['tfa_secret'])) |
| 518 | 542 | { |
| 519 | - if ($modSettings['tfa_mode'] == 2) //only do this if we are just forcing SOME membergroups |
|
| 543 | + if ($modSettings['tfa_mode'] == 2) { |
|
| 544 | + //only do this if we are just forcing SOME membergroups |
|
| 520 | 545 | { |
| 521 | 546 | //Build an array of ALL user membergroups. |
| 522 | 547 | $full_groups = array($user_settings['id_group']); |
| 548 | + } |
|
| 523 | 549 | if (!empty($user_settings['additional_groups'])) |
| 524 | 550 | { |
| 525 | 551 | $full_groups = array_merge($full_groups, explode(',', $user_settings['additional_groups'])); |
@@ -539,15 +565,17 @@ discard block |
||
| 539 | 565 | ); |
| 540 | 566 | $row = $smcFunc['db_fetch_assoc']($request); |
| 541 | 567 | $smcFunc['db_free_result']($request); |
| 568 | + } else { |
|
| 569 | + $row['total'] = 1; |
|
| 542 | 570 | } |
| 543 | - else |
|
| 544 | - $row['total'] = 1; //simplifies logics in the next "if" |
|
| 571 | + //simplifies logics in the next "if" |
|
| 545 | 572 | |
| 546 | 573 | $area = !empty($_REQUEST['area']) ? $_REQUEST['area'] : ''; |
| 547 | 574 | $action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : ''; |
| 548 | 575 | |
| 549 | - if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) |
|
| 550 | - redirectexit('action=profile;area=tfasetup;forced'); |
|
| 576 | + if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) { |
|
| 577 | + redirectexit('action=profile;area=tfasetup;forced'); |
|
| 578 | + } |
|
| 551 | 579 | } |
| 552 | 580 | } |
| 553 | 581 | |
@@ -584,33 +612,37 @@ discard block |
||
| 584 | 612 | updateMemberData($id_member, array('id_msg_last_visit' => (int) $modSettings['maxMsgID'], 'last_login' => time(), 'member_ip' => $_SERVER['REMOTE_ADDR'], 'member_ip2' => $_SERVER['BAN_CHECK_IP'])); |
| 585 | 613 | $user_settings['last_login'] = time(); |
| 586 | 614 | |
| 587 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 588 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
| 615 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 616 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
| 617 | + } |
|
| 589 | 618 | |
| 590 | - if (!empty($modSettings['cache_enable'])) |
|
| 591 | - cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
| 619 | + if (!empty($modSettings['cache_enable'])) { |
|
| 620 | + cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
| 621 | + } |
|
| 592 | 622 | } |
| 623 | + } elseif (empty($_SESSION['id_msg_last_visit'])) { |
|
| 624 | + $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
| 593 | 625 | } |
| 594 | - elseif (empty($_SESSION['id_msg_last_visit'])) |
|
| 595 | - $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
| 596 | 626 | |
| 597 | 627 | $username = $user_settings['member_name']; |
| 598 | 628 | |
| 599 | - if (empty($user_settings['additional_groups'])) |
|
| 600 | - $user_info = array( |
|
| 629 | + if (empty($user_settings['additional_groups'])) { |
|
| 630 | + $user_info = array( |
|
| 601 | 631 | 'groups' => array($user_settings['id_group'], $user_settings['id_post_group']) |
| 602 | 632 | ); |
| 603 | - else |
|
| 604 | - $user_info = array( |
|
| 633 | + } else { |
|
| 634 | + $user_info = array( |
|
| 605 | 635 | 'groups' => array_merge( |
| 606 | 636 | array($user_settings['id_group'], $user_settings['id_post_group']), |
| 607 | 637 | explode(',', $user_settings['additional_groups']) |
| 608 | 638 | ) |
| 609 | 639 | ); |
| 640 | + } |
|
| 610 | 641 | |
| 611 | 642 | // Because history has proven that it is possible for groups to go bad - clean up in case. |
| 612 | - foreach ($user_info['groups'] as $k => $v) |
|
| 613 | - $user_info['groups'][$k] = (int) $v; |
|
| 643 | + foreach ($user_info['groups'] as $k => $v) { |
|
| 644 | + $user_info['groups'][$k] = (int) $v; |
|
| 645 | + } |
|
| 614 | 646 | |
| 615 | 647 | // This is a logged in user, so definitely not a spider. |
| 616 | 648 | $user_info['possibly_robot'] = false; |
@@ -624,8 +656,7 @@ discard block |
||
| 624 | 656 | $time_system = new DateTime('now', $tz_system); |
| 625 | 657 | $time_user = new DateTime('now', $tz_user); |
| 626 | 658 | $user_info['time_offset'] = ($tz_user->getOffset($time_user) - $tz_system->getOffset($time_system)) / 3600; |
| 627 | - } |
|
| 628 | - else |
|
| 659 | + } else |
|
| 629 | 660 | { |
| 630 | 661 | // !!! Compatibility. |
| 631 | 662 | $user_info['time_offset'] = empty($user_settings['time_offset']) ? 0 : $user_settings['time_offset']; |
@@ -639,16 +670,18 @@ discard block |
||
| 639 | 670 | $user_info = array('groups' => array(-1)); |
| 640 | 671 | $user_settings = array(); |
| 641 | 672 | |
| 642 | - if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) |
|
| 643 | - $_COOKIE[$cookiename] = ''; |
|
| 673 | + if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) { |
|
| 674 | + $_COOKIE[$cookiename] = ''; |
|
| 675 | + } |
|
| 644 | 676 | |
| 645 | 677 | // Expire the 2FA cookie |
| 646 | 678 | if (isset($_COOKIE[$cookiename . '_tfa']) && empty($context['tfa_member'])) |
| 647 | 679 | { |
| 648 | 680 | $tfa_data = smf_json_decode($_COOKIE[$cookiename . '_tfa'], true); |
| 649 | 681 | |
| 650 | - if (is_null($tfa_data)) |
|
| 651 | - $tfa_data = safe_unserialize($_COOKIE[$cookiename . '_tfa']); |
|
| 682 | + if (is_null($tfa_data)) { |
|
| 683 | + $tfa_data = safe_unserialize($_COOKIE[$cookiename . '_tfa']); |
|
| 684 | + } |
|
| 652 | 685 | |
| 653 | 686 | list ($id, $user, $exp, $state, $preserve) = $tfa_data; |
| 654 | 687 | |
@@ -660,19 +693,20 @@ discard block |
||
| 660 | 693 | } |
| 661 | 694 | |
| 662 | 695 | // Create a login token if it doesn't exist yet. |
| 663 | - if (!isset($_SESSION['token']['post-login'])) |
|
| 664 | - createToken('login'); |
|
| 665 | - else |
|
| 666 | - list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
| 696 | + if (!isset($_SESSION['token']['post-login'])) { |
|
| 697 | + createToken('login'); |
|
| 698 | + } else { |
|
| 699 | + list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
| 700 | + } |
|
| 667 | 701 | |
| 668 | 702 | // Do we perhaps think this is a search robot? Check every five minutes just in case... |
| 669 | 703 | if ((!empty($modSettings['spider_mode']) || !empty($modSettings['spider_group'])) && (!isset($_SESSION['robot_check']) || $_SESSION['robot_check'] < time() - 300)) |
| 670 | 704 | { |
| 671 | 705 | require_once($sourcedir . '/ManageSearchEngines.php'); |
| 672 | 706 | $user_info['possibly_robot'] = SpiderCheck(); |
| 707 | + } elseif (!empty($modSettings['spider_mode'])) { |
|
| 708 | + $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
| 673 | 709 | } |
| 674 | - elseif (!empty($modSettings['spider_mode'])) |
|
| 675 | - $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
| 676 | 710 | // If we haven't turned on proper spider hunts then have a guess! |
| 677 | 711 | else |
| 678 | 712 | { |
@@ -720,8 +754,9 @@ discard block |
||
| 720 | 754 | $user_info['groups'] = array_unique($user_info['groups']); |
| 721 | 755 | |
| 722 | 756 | // Make sure that the last item in the ignore boards array is valid. If the list was too long it could have an ending comma that could cause problems. |
| 723 | - if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) |
|
| 724 | - unset($user_info['ignoreboards'][$tmp]); |
|
| 757 | + if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) { |
|
| 758 | + unset($user_info['ignoreboards'][$tmp]); |
|
| 759 | + } |
|
| 725 | 760 | |
| 726 | 761 | // Allow the user to change their language. |
| 727 | 762 | if (!empty($modSettings['userLanguage'])) |
@@ -734,31 +769,36 @@ discard block |
||
| 734 | 769 | $user_info['language'] = strtr($_GET['language'], './\\:', '____'); |
| 735 | 770 | |
| 736 | 771 | // Make it permanent for members. |
| 737 | - if (!empty($user_info['id'])) |
|
| 738 | - updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
| 739 | - else |
|
| 740 | - $_SESSION['language'] = $user_info['language']; |
|
| 772 | + if (!empty($user_info['id'])) { |
|
| 773 | + updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
| 774 | + } else { |
|
| 775 | + $_SESSION['language'] = $user_info['language']; |
|
| 776 | + } |
|
| 777 | + } elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) { |
|
| 778 | + $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
| 741 | 779 | } |
| 742 | - elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) |
|
| 743 | - $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
| 744 | 780 | } |
| 745 | 781 | |
| 746 | 782 | // Just build this here, it makes it easier to change/use - administrators can see all boards. |
| 747 | - if ($user_info['is_admin']) |
|
| 748 | - $user_info['query_see_board'] = '1=1'; |
|
| 783 | + if ($user_info['is_admin']) { |
|
| 784 | + $user_info['query_see_board'] = '1=1'; |
|
| 785 | + } |
|
| 749 | 786 | // Otherwise just the groups in $user_info['groups']. |
| 750 | - else |
|
| 751 | - $user_info['query_see_board'] = '((FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $user_info['groups']) . ', b.member_groups) != 0)' . (!empty($modSettings['deny_boards_access']) ? ' AND (FIND_IN_SET(' . implode(', b.deny_member_groups) = 0 AND FIND_IN_SET(', $user_info['groups']) . ', b.deny_member_groups) = 0)' : '') . (isset($user_info['mod_cache']) ? ' OR ' . $user_info['mod_cache']['mq'] : '') . ')'; |
|
| 787 | + else { |
|
| 788 | + $user_info['query_see_board'] = '((FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $user_info['groups']) . ', b.member_groups) != 0)' . (!empty($modSettings['deny_boards_access']) ? ' AND (FIND_IN_SET(' . implode(', b.deny_member_groups) = 0 AND FIND_IN_SET(', $user_info['groups']) . ', b.deny_member_groups) = 0)' : '') . (isset($user_info['mod_cache']) ? ' OR ' . $user_info['mod_cache']['mq'] : '') . ')'; |
|
| 789 | + } |
|
| 752 | 790 | |
| 753 | 791 | // Build the list of boards they WANT to see. |
| 754 | 792 | // This will take the place of query_see_boards in certain spots, so it better include the boards they can see also |
| 755 | 793 | |
| 756 | 794 | // If they aren't ignoring any boards then they want to see all the boards they can see |
| 757 | - if (empty($user_info['ignoreboards'])) |
|
| 758 | - $user_info['query_wanna_see_board'] = $user_info['query_see_board']; |
|
| 795 | + if (empty($user_info['ignoreboards'])) { |
|
| 796 | + $user_info['query_wanna_see_board'] = $user_info['query_see_board']; |
|
| 797 | + } |
|
| 759 | 798 | // Ok I guess they don't want to see all the boards |
| 760 | - else |
|
| 761 | - $user_info['query_wanna_see_board'] = '(' . $user_info['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $user_info['ignoreboards']) . '))'; |
|
| 799 | + else { |
|
| 800 | + $user_info['query_wanna_see_board'] = '(' . $user_info['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $user_info['ignoreboards']) . '))'; |
|
| 801 | + } |
|
| 762 | 802 | |
| 763 | 803 | call_integration_hook('integrate_user_info'); |
| 764 | 804 | } |
@@ -816,9 +856,9 @@ discard block |
||
| 816 | 856 | } |
| 817 | 857 | |
| 818 | 858 | // Remember redirection is the key to avoiding fallout from your bosses. |
| 819 | - if (!empty($topic)) |
|
| 820 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
| 821 | - else |
|
| 859 | + if (!empty($topic)) { |
|
| 860 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
| 861 | + } else |
|
| 822 | 862 | { |
| 823 | 863 | loadPermissions(); |
| 824 | 864 | loadTheme(); |
@@ -836,10 +876,11 @@ discard block |
||
| 836 | 876 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
| 837 | 877 | { |
| 838 | 878 | // @todo SLOW? |
| 839 | - if (!empty($topic)) |
|
| 840 | - $temp = cache_get_data('topic_board-' . $topic, 120); |
|
| 841 | - else |
|
| 842 | - $temp = cache_get_data('board-' . $board, 120); |
|
| 879 | + if (!empty($topic)) { |
|
| 880 | + $temp = cache_get_data('topic_board-' . $topic, 120); |
|
| 881 | + } else { |
|
| 882 | + $temp = cache_get_data('board-' . $board, 120); |
|
| 883 | + } |
|
| 843 | 884 | |
| 844 | 885 | if (!empty($temp)) |
| 845 | 886 | { |
@@ -877,8 +918,9 @@ discard block |
||
| 877 | 918 | $row = $smcFunc['db_fetch_assoc']($request); |
| 878 | 919 | |
| 879 | 920 | // Set the current board. |
| 880 | - if (!empty($row['id_board'])) |
|
| 881 | - $board = $row['id_board']; |
|
| 921 | + if (!empty($row['id_board'])) { |
|
| 922 | + $board = $row['id_board']; |
|
| 923 | + } |
|
| 882 | 924 | |
| 883 | 925 | // Basic operating information. (globals... :/) |
| 884 | 926 | $board_info = array( |
@@ -914,21 +956,23 @@ discard block |
||
| 914 | 956 | |
| 915 | 957 | do |
| 916 | 958 | { |
| 917 | - if (!empty($row['id_moderator'])) |
|
| 918 | - $board_info['moderators'][$row['id_moderator']] = array( |
|
| 959 | + if (!empty($row['id_moderator'])) { |
|
| 960 | + $board_info['moderators'][$row['id_moderator']] = array( |
|
| 919 | 961 | 'id' => $row['id_moderator'], |
| 920 | 962 | 'name' => $row['real_name'], |
| 921 | 963 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
| 922 | 964 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
| 923 | 965 | ); |
| 966 | + } |
|
| 924 | 967 | |
| 925 | - if (!empty($row['id_moderator_group'])) |
|
| 926 | - $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
| 968 | + if (!empty($row['id_moderator_group'])) { |
|
| 969 | + $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
| 927 | 970 | 'id' => $row['id_moderator_group'], |
| 928 | 971 | 'name' => $row['group_name'], |
| 929 | 972 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
| 930 | 973 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
| 931 | 974 | ); |
| 975 | + } |
|
| 932 | 976 | } |
| 933 | 977 | while ($row = $smcFunc['db_fetch_assoc']($request)); |
| 934 | 978 | |
@@ -960,12 +1004,12 @@ discard block |
||
| 960 | 1004 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
| 961 | 1005 | { |
| 962 | 1006 | // @todo SLOW? |
| 963 | - if (!empty($topic)) |
|
| 964 | - cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
| 1007 | + if (!empty($topic)) { |
|
| 1008 | + cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
| 1009 | + } |
|
| 965 | 1010 | cache_put_data('board-' . $board, $board_info, 120); |
| 966 | 1011 | } |
| 967 | - } |
|
| 968 | - else |
|
| 1012 | + } else |
|
| 969 | 1013 | { |
| 970 | 1014 | // Otherwise the topic is invalid, there are no moderators, etc. |
| 971 | 1015 | $board_info = array( |
@@ -979,8 +1023,9 @@ discard block |
||
| 979 | 1023 | $smcFunc['db_free_result']($request); |
| 980 | 1024 | } |
| 981 | 1025 | |
| 982 | - if (!empty($topic)) |
|
| 983 | - $_GET['board'] = (int) $board; |
|
| 1026 | + if (!empty($topic)) { |
|
| 1027 | + $_GET['board'] = (int) $board; |
|
| 1028 | + } |
|
| 984 | 1029 | |
| 985 | 1030 | if (!empty($board)) |
| 986 | 1031 | { |
@@ -990,10 +1035,12 @@ discard block |
||
| 990 | 1035 | // Now check if the user is a moderator. |
| 991 | 1036 | $user_info['is_mod'] = isset($board_info['moderators'][$user_info['id']]) || count(array_intersect($user_info['groups'], $moderator_groups)) != 0; |
| 992 | 1037 | |
| 993 | - if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) |
|
| 994 | - $board_info['error'] = 'access'; |
|
| 995 | - if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) |
|
| 996 | - $board_info['error'] = 'access'; |
|
| 1038 | + if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) { |
|
| 1039 | + $board_info['error'] = 'access'; |
|
| 1040 | + } |
|
| 1041 | + if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) { |
|
| 1042 | + $board_info['error'] = 'access'; |
|
| 1043 | + } |
|
| 997 | 1044 | |
| 998 | 1045 | // Build up the linktree. |
| 999 | 1046 | $context['linktree'] = array_merge( |
@@ -1016,8 +1063,9 @@ discard block |
||
| 1016 | 1063 | $context['current_board'] = $board; |
| 1017 | 1064 | |
| 1018 | 1065 | // No posting in redirection boards! |
| 1019 | - if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) |
|
| 1020 | - $board_info['error'] == 'post_in_redirect'; |
|
| 1066 | + if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) { |
|
| 1067 | + $board_info['error'] == 'post_in_redirect'; |
|
| 1068 | + } |
|
| 1021 | 1069 | |
| 1022 | 1070 | // Hacker... you can't see this topic, I'll tell you that. (but moderators can!) |
| 1023 | 1071 | if (!empty($board_info['error']) && (!empty($modSettings['deny_boards_access']) || $board_info['error'] != 'access' || !$user_info['is_mod'])) |
@@ -1043,24 +1091,23 @@ discard block |
||
| 1043 | 1091 | ob_end_clean(); |
| 1044 | 1092 | header('HTTP/1.1 403 Forbidden'); |
| 1045 | 1093 | die; |
| 1046 | - } |
|
| 1047 | - elseif ($board_info['error'] == 'post_in_redirect') |
|
| 1094 | + } elseif ($board_info['error'] == 'post_in_redirect') |
|
| 1048 | 1095 | { |
| 1049 | 1096 | // Slightly different error message here... |
| 1050 | 1097 | fatal_lang_error('cannot_post_redirect', false); |
| 1051 | - } |
|
| 1052 | - elseif ($user_info['is_guest']) |
|
| 1098 | + } elseif ($user_info['is_guest']) |
|
| 1053 | 1099 | { |
| 1054 | 1100 | loadLanguage('Errors'); |
| 1055 | 1101 | is_not_guest($txt['topic_gone']); |
| 1102 | + } else { |
|
| 1103 | + fatal_lang_error('topic_gone', false); |
|
| 1056 | 1104 | } |
| 1057 | - else |
|
| 1058 | - fatal_lang_error('topic_gone', false); |
|
| 1059 | 1105 | } |
| 1060 | 1106 | |
| 1061 | - if ($user_info['is_mod']) |
|
| 1062 | - $user_info['groups'][] = 3; |
|
| 1063 | -} |
|
| 1107 | + if ($user_info['is_mod']) { |
|
| 1108 | + $user_info['groups'][] = 3; |
|
| 1109 | + } |
|
| 1110 | + } |
|
| 1064 | 1111 | |
| 1065 | 1112 | /** |
| 1066 | 1113 | * Load this user's permissions. |
@@ -1081,8 +1128,9 @@ discard block |
||
| 1081 | 1128 | asort($cache_groups); |
| 1082 | 1129 | $cache_groups = implode(',', $cache_groups); |
| 1083 | 1130 | // If it's a spider then cache it different. |
| 1084 | - if ($user_info['possibly_robot']) |
|
| 1085 | - $cache_groups .= '-spider'; |
|
| 1131 | + if ($user_info['possibly_robot']) { |
|
| 1132 | + $cache_groups .= '-spider'; |
|
| 1133 | + } |
|
| 1086 | 1134 | |
| 1087 | 1135 | if ($modSettings['cache_enable'] >= 2 && !empty($board) && ($temp = cache_get_data('permissions:' . $cache_groups . ':' . $board, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
| 1088 | 1136 | { |
@@ -1090,9 +1138,9 @@ discard block |
||
| 1090 | 1138 | banPermissions(); |
| 1091 | 1139 | |
| 1092 | 1140 | return; |
| 1141 | + } elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) { |
|
| 1142 | + list ($user_info['permissions'], $removals) = $temp; |
|
| 1093 | 1143 | } |
| 1094 | - elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
|
| 1095 | - list ($user_info['permissions'], $removals) = $temp; |
|
| 1096 | 1144 | } |
| 1097 | 1145 | |
| 1098 | 1146 | // If it is detected as a robot, and we are restricting permissions as a special group - then implement this. |
@@ -1114,23 +1162,26 @@ discard block |
||
| 1114 | 1162 | $removals = array(); |
| 1115 | 1163 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1116 | 1164 | { |
| 1117 | - if (empty($row['add_deny'])) |
|
| 1118 | - $removals[] = $row['permission']; |
|
| 1119 | - else |
|
| 1120 | - $user_info['permissions'][] = $row['permission']; |
|
| 1165 | + if (empty($row['add_deny'])) { |
|
| 1166 | + $removals[] = $row['permission']; |
|
| 1167 | + } else { |
|
| 1168 | + $user_info['permissions'][] = $row['permission']; |
|
| 1169 | + } |
|
| 1121 | 1170 | } |
| 1122 | 1171 | $smcFunc['db_free_result']($request); |
| 1123 | 1172 | |
| 1124 | - if (isset($cache_groups)) |
|
| 1125 | - cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
| 1173 | + if (isset($cache_groups)) { |
|
| 1174 | + cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
| 1175 | + } |
|
| 1126 | 1176 | } |
| 1127 | 1177 | |
| 1128 | 1178 | // Get the board permissions. |
| 1129 | 1179 | if (!empty($board)) |
| 1130 | 1180 | { |
| 1131 | 1181 | // Make sure the board (if any) has been loaded by loadBoard(). |
| 1132 | - if (!isset($board_info['profile'])) |
|
| 1133 | - fatal_lang_error('no_board'); |
|
| 1182 | + if (!isset($board_info['profile'])) { |
|
| 1183 | + fatal_lang_error('no_board'); |
|
| 1184 | + } |
|
| 1134 | 1185 | |
| 1135 | 1186 | $request = $smcFunc['db_query']('', ' |
| 1136 | 1187 | SELECT permission, add_deny |
@@ -1146,20 +1197,23 @@ discard block |
||
| 1146 | 1197 | ); |
| 1147 | 1198 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1148 | 1199 | { |
| 1149 | - if (empty($row['add_deny'])) |
|
| 1150 | - $removals[] = $row['permission']; |
|
| 1151 | - else |
|
| 1152 | - $user_info['permissions'][] = $row['permission']; |
|
| 1200 | + if (empty($row['add_deny'])) { |
|
| 1201 | + $removals[] = $row['permission']; |
|
| 1202 | + } else { |
|
| 1203 | + $user_info['permissions'][] = $row['permission']; |
|
| 1204 | + } |
|
| 1153 | 1205 | } |
| 1154 | 1206 | $smcFunc['db_free_result']($request); |
| 1155 | 1207 | } |
| 1156 | 1208 | |
| 1157 | 1209 | // Remove all the permissions they shouldn't have ;). |
| 1158 | - if (!empty($modSettings['permission_enable_deny'])) |
|
| 1159 | - $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
| 1210 | + if (!empty($modSettings['permission_enable_deny'])) { |
|
| 1211 | + $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
| 1212 | + } |
|
| 1160 | 1213 | |
| 1161 | - if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) |
|
| 1162 | - cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
| 1214 | + if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) { |
|
| 1215 | + cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
| 1216 | + } |
|
| 1163 | 1217 | |
| 1164 | 1218 | // Banned? Watch, don't touch.. |
| 1165 | 1219 | banPermissions(); |
@@ -1171,17 +1225,18 @@ discard block |
||
| 1171 | 1225 | { |
| 1172 | 1226 | require_once($sourcedir . '/Subs-Auth.php'); |
| 1173 | 1227 | rebuildModCache(); |
| 1228 | + } else { |
|
| 1229 | + $user_info['mod_cache'] = $_SESSION['mc']; |
|
| 1174 | 1230 | } |
| 1175 | - else |
|
| 1176 | - $user_info['mod_cache'] = $_SESSION['mc']; |
|
| 1177 | 1231 | |
| 1178 | 1232 | // This is a useful phantom permission added to the current user, and only the current user while they are logged in. |
| 1179 | 1233 | // For example this drastically simplifies certain changes to the profile area. |
| 1180 | 1234 | $user_info['permissions'][] = 'is_not_guest'; |
| 1181 | 1235 | // And now some backwards compatibility stuff for mods and whatnot that aren't expecting the new permissions. |
| 1182 | 1236 | $user_info['permissions'][] = 'profile_view_own'; |
| 1183 | - if (in_array('profile_view', $user_info['permissions'])) |
|
| 1184 | - $user_info['permissions'][] = 'profile_view_any'; |
|
| 1237 | + if (in_array('profile_view', $user_info['permissions'])) { |
|
| 1238 | + $user_info['permissions'][] = 'profile_view_any'; |
|
| 1239 | + } |
|
| 1185 | 1240 | } |
| 1186 | 1241 | } |
| 1187 | 1242 | |
@@ -1199,8 +1254,9 @@ discard block |
||
| 1199 | 1254 | global $image_proxy_enabled, $image_proxy_secret, $boardurl; |
| 1200 | 1255 | |
| 1201 | 1256 | // Can't just look for no users :P. |
| 1202 | - if (empty($users)) |
|
| 1203 | - return array(); |
|
| 1257 | + if (empty($users)) { |
|
| 1258 | + return array(); |
|
| 1259 | + } |
|
| 1204 | 1260 | |
| 1205 | 1261 | // Pass the set value |
| 1206 | 1262 | $context['loadMemberContext_set'] = $set; |
@@ -1215,8 +1271,9 @@ discard block |
||
| 1215 | 1271 | for ($i = 0, $n = count($users); $i < $n; $i++) |
| 1216 | 1272 | { |
| 1217 | 1273 | $data = cache_get_data('member_data-' . $set . '-' . $users[$i], 240); |
| 1218 | - if ($data == null) |
|
| 1219 | - continue; |
|
| 1274 | + if ($data == null) { |
|
| 1275 | + continue; |
|
| 1276 | + } |
|
| 1220 | 1277 | |
| 1221 | 1278 | $loaded_ids[] = $data['id_member']; |
| 1222 | 1279 | $user_profile[$data['id_member']] = $data; |
@@ -1283,13 +1340,16 @@ discard block |
||
| 1283 | 1340 | $row['avatar_original'] = $row['avatar']; |
| 1284 | 1341 | |
| 1285 | 1342 | // Take care of proxying avatar if required, do this here for maximum reach |
| 1286 | - if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false) |
|
| 1287 | - $row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret); |
|
| 1343 | + if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false) { |
|
| 1344 | + $row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret); |
|
| 1345 | + } |
|
| 1288 | 1346 | |
| 1289 | - if (isset($row['member_ip'])) |
|
| 1290 | - $row['member_ip'] = inet_dtop($row['member_ip']); |
|
| 1291 | - if (isset($row['member_ip2'])) |
|
| 1292 | - $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
| 1347 | + if (isset($row['member_ip'])) { |
|
| 1348 | + $row['member_ip'] = inet_dtop($row['member_ip']); |
|
| 1349 | + } |
|
| 1350 | + if (isset($row['member_ip2'])) { |
|
| 1351 | + $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
| 1352 | + } |
|
| 1293 | 1353 | $new_loaded_ids[] = $row['id_member']; |
| 1294 | 1354 | $loaded_ids[] = $row['id_member']; |
| 1295 | 1355 | $row['options'] = array(); |
@@ -1308,8 +1368,9 @@ discard block |
||
| 1308 | 1368 | 'loaded_ids' => $new_loaded_ids, |
| 1309 | 1369 | ) |
| 1310 | 1370 | ); |
| 1311 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1312 | - $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
| 1371 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1372 | + $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
| 1373 | + } |
|
| 1313 | 1374 | $smcFunc['db_free_result']($request); |
| 1314 | 1375 | } |
| 1315 | 1376 | |
@@ -1320,10 +1381,11 @@ discard block |
||
| 1320 | 1381 | { |
| 1321 | 1382 | foreach ($loaded_ids as $a_member) |
| 1322 | 1383 | { |
| 1323 | - if (!empty($user_profile[$a_member]['additional_groups'])) |
|
| 1324 | - $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
| 1325 | - else |
|
| 1326 | - $groups = array($user_profile[$a_member]['id_group']); |
|
| 1384 | + if (!empty($user_profile[$a_member]['additional_groups'])) { |
|
| 1385 | + $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
| 1386 | + } else { |
|
| 1387 | + $groups = array($user_profile[$a_member]['id_group']); |
|
| 1388 | + } |
|
| 1327 | 1389 | |
| 1328 | 1390 | $temp = array_intersect($groups, array_keys($board_info['moderator_groups'])); |
| 1329 | 1391 | |
@@ -1336,8 +1398,9 @@ discard block |
||
| 1336 | 1398 | |
| 1337 | 1399 | if (!empty($new_loaded_ids) && !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) |
| 1338 | 1400 | { |
| 1339 | - for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) |
|
| 1340 | - cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
| 1401 | + for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) { |
|
| 1402 | + cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
| 1403 | + } |
|
| 1341 | 1404 | } |
| 1342 | 1405 | |
| 1343 | 1406 | // Are we loading any moderators? If so, fix their group data... |
@@ -1363,14 +1426,17 @@ discard block |
||
| 1363 | 1426 | foreach ($temp_mods as $id) |
| 1364 | 1427 | { |
| 1365 | 1428 | // By popular demand, don't show admins or global moderators as moderators. |
| 1366 | - if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) |
|
| 1367 | - $user_profile[$id]['member_group'] = $row['member_group']; |
|
| 1429 | + if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) { |
|
| 1430 | + $user_profile[$id]['member_group'] = $row['member_group']; |
|
| 1431 | + } |
|
| 1368 | 1432 | |
| 1369 | 1433 | // If the Moderator group has no color or icons, but their group does... don't overwrite. |
| 1370 | - if (!empty($row['icons'])) |
|
| 1371 | - $user_profile[$id]['icons'] = $row['icons']; |
|
| 1372 | - if (!empty($row['member_group_color'])) |
|
| 1373 | - $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
| 1434 | + if (!empty($row['icons'])) { |
|
| 1435 | + $user_profile[$id]['icons'] = $row['icons']; |
|
| 1436 | + } |
|
| 1437 | + if (!empty($row['member_group_color'])) { |
|
| 1438 | + $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
| 1439 | + } |
|
| 1374 | 1440 | } |
| 1375 | 1441 | } |
| 1376 | 1442 | |
@@ -1392,12 +1458,14 @@ discard block |
||
| 1392 | 1458 | static $loadedLanguages = array(); |
| 1393 | 1459 | |
| 1394 | 1460 | // If this person's data is already loaded, skip it. |
| 1395 | - if (isset($dataLoaded[$user])) |
|
| 1396 | - return true; |
|
| 1461 | + if (isset($dataLoaded[$user])) { |
|
| 1462 | + return true; |
|
| 1463 | + } |
|
| 1397 | 1464 | |
| 1398 | 1465 | // We can't load guests or members not loaded by loadMemberData()! |
| 1399 | - if ($user == 0) |
|
| 1400 | - return false; |
|
| 1466 | + if ($user == 0) { |
|
| 1467 | + return false; |
|
| 1468 | + } |
|
| 1401 | 1469 | if (!isset($user_profile[$user])) |
| 1402 | 1470 | { |
| 1403 | 1471 | trigger_error('loadMemberContext(): member id ' . $user . ' not previously loaded by loadMemberData()', E_USER_WARNING); |
@@ -1423,12 +1491,16 @@ discard block |
||
| 1423 | 1491 | $buddy_list = !empty($profile['buddy_list']) ? explode(',', $profile['buddy_list']) : array(); |
| 1424 | 1492 | |
| 1425 | 1493 | //We need a little fallback for the membergroup icons. If it doesn't exist in the current theme, fallback to default theme |
| 1426 | - if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) //icon is set and exists |
|
| 1494 | + if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) { |
|
| 1495 | + //icon is set and exists |
|
| 1427 | 1496 | $group_icon_url = $settings['images_url'] . '/membericons/' . $profile['icons'][1]; |
| 1428 | - elseif (isset($profile['icons'][1])) //icon is set and doesn't exist, fallback to default |
|
| 1497 | + } elseif (isset($profile['icons'][1])) { |
|
| 1498 | + //icon is set and doesn't exist, fallback to default |
|
| 1429 | 1499 | $group_icon_url = $settings['default_images_url'] . '/membericons/' . $profile['icons'][1]; |
| 1430 | - else //not set, bye bye |
|
| 1500 | + } else { |
|
| 1501 | + //not set, bye bye |
|
| 1431 | 1502 | $group_icon_url = ''; |
| 1503 | + } |
|
| 1432 | 1504 | |
| 1433 | 1505 | // These minimal values are always loaded |
| 1434 | 1506 | $memberContext[$user] = array( |
@@ -1447,8 +1519,9 @@ discard block |
||
| 1447 | 1519 | if ($context['loadMemberContext_set'] != 'minimal') |
| 1448 | 1520 | { |
| 1449 | 1521 | // Go the extra mile and load the user's native language name. |
| 1450 | - if (empty($loadedLanguages)) |
|
| 1451 | - $loadedLanguages = getLanguages(); |
|
| 1522 | + if (empty($loadedLanguages)) { |
|
| 1523 | + $loadedLanguages = getLanguages(); |
|
| 1524 | + } |
|
| 1452 | 1525 | |
| 1453 | 1526 | $memberContext[$user] += array( |
| 1454 | 1527 | 'username_color' => '<span ' . (!empty($profile['member_group_color']) ? 'style="color:' . $profile['member_group_color'] . ';"' : '') . '>' . $profile['member_name'] . '</span>', |
@@ -1502,31 +1575,33 @@ discard block |
||
| 1502 | 1575 | { |
| 1503 | 1576 | if (!empty($modSettings['gravatarOverride']) || (!empty($modSettings['gravatarEnabled']) && stristr($profile['avatar'], 'gravatar://'))) |
| 1504 | 1577 | { |
| 1505 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) |
|
| 1506 | - $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
| 1507 | - else |
|
| 1508 | - $image = get_gravatar_url($profile['email_address']); |
|
| 1509 | - } |
|
| 1510 | - else |
|
| 1578 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) { |
|
| 1579 | + $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
| 1580 | + } else { |
|
| 1581 | + $image = get_gravatar_url($profile['email_address']); |
|
| 1582 | + } |
|
| 1583 | + } else |
|
| 1511 | 1584 | { |
| 1512 | 1585 | // So it's stored in the member table? |
| 1513 | 1586 | if (!empty($profile['avatar'])) |
| 1514 | 1587 | { |
| 1515 | 1588 | $image = (stristr($profile['avatar'], 'http://') || stristr($profile['avatar'], 'https://')) ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar']; |
| 1589 | + } elseif (!empty($profile['filename'])) { |
|
| 1590 | + $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
| 1516 | 1591 | } |
| 1517 | - elseif (!empty($profile['filename'])) |
|
| 1518 | - $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
| 1519 | 1592 | // Right... no avatar...use the default one |
| 1520 | - else |
|
| 1521 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
| 1593 | + else { |
|
| 1594 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
| 1595 | + } |
|
| 1522 | 1596 | } |
| 1523 | - if (!empty($image)) |
|
| 1524 | - $memberContext[$user]['avatar'] = array( |
|
| 1597 | + if (!empty($image)) { |
|
| 1598 | + $memberContext[$user]['avatar'] = array( |
|
| 1525 | 1599 | 'name' => $profile['avatar'], |
| 1526 | 1600 | 'image' => '<img class="avatar" src="' . $image . '" alt="avatar_' . $profile['member_name'] . '">', |
| 1527 | 1601 | 'href' => $image, |
| 1528 | 1602 | 'url' => $image, |
| 1529 | 1603 | ); |
| 1604 | + } |
|
| 1530 | 1605 | } |
| 1531 | 1606 | |
| 1532 | 1607 | // Are we also loading the members custom fields into context? |
@@ -1534,35 +1609,41 @@ discard block |
||
| 1534 | 1609 | { |
| 1535 | 1610 | $memberContext[$user]['custom_fields'] = array(); |
| 1536 | 1611 | |
| 1537 | - if (!isset($context['display_fields'])) |
|
| 1538 | - $context['display_fields'] = smf_json_decode($modSettings['displayFields'], true); |
|
| 1612 | + if (!isset($context['display_fields'])) { |
|
| 1613 | + $context['display_fields'] = smf_json_decode($modSettings['displayFields'], true); |
|
| 1614 | + } |
|
| 1539 | 1615 | |
| 1540 | 1616 | foreach ($context['display_fields'] as $custom) |
| 1541 | 1617 | { |
| 1542 | - if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) |
|
| 1543 | - continue; |
|
| 1618 | + if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) { |
|
| 1619 | + continue; |
|
| 1620 | + } |
|
| 1544 | 1621 | |
| 1545 | 1622 | $value = $profile['options'][$custom['col_name']]; |
| 1546 | 1623 | |
| 1547 | 1624 | // Don't show the "disabled" option for the "gender" field. |
| 1548 | - if ($custom['col_name'] == 'cust_gender' && $value == 'Disabled') |
|
| 1549 | - continue; |
|
| 1625 | + if ($custom['col_name'] == 'cust_gender' && $value == 'Disabled') { |
|
| 1626 | + continue; |
|
| 1627 | + } |
|
| 1550 | 1628 | |
| 1551 | 1629 | // BBC? |
| 1552 | - if ($custom['bbc']) |
|
| 1553 | - $value = parse_bbc($value); |
|
| 1630 | + if ($custom['bbc']) { |
|
| 1631 | + $value = parse_bbc($value); |
|
| 1632 | + } |
|
| 1554 | 1633 | // ... or checkbox? |
| 1555 | - elseif (isset($custom['type']) && $custom['type'] == 'check') |
|
| 1556 | - $value = $value ? $txt['yes'] : $txt['no']; |
|
| 1634 | + elseif (isset($custom['type']) && $custom['type'] == 'check') { |
|
| 1635 | + $value = $value ? $txt['yes'] : $txt['no']; |
|
| 1636 | + } |
|
| 1557 | 1637 | |
| 1558 | 1638 | // Enclosing the user input within some other text? |
| 1559 | - if (!empty($custom['enclose'])) |
|
| 1560 | - $value = strtr($custom['enclose'], array( |
|
| 1639 | + if (!empty($custom['enclose'])) { |
|
| 1640 | + $value = strtr($custom['enclose'], array( |
|
| 1561 | 1641 | '{SCRIPTURL}' => $scripturl, |
| 1562 | 1642 | '{IMAGES_URL}' => $settings['images_url'], |
| 1563 | 1643 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
| 1564 | 1644 | '{INPUT}' => $value, |
| 1565 | 1645 | )); |
| 1646 | + } |
|
| 1566 | 1647 | |
| 1567 | 1648 | $memberContext[$user]['custom_fields'][] = array( |
| 1568 | 1649 | 'title' => !empty($custom['title']) ? $custom['title'] : $custom['col_name'], |
@@ -1589,8 +1670,9 @@ discard block |
||
| 1589 | 1670 | global $smcFunc, $txt, $scripturl, $settings; |
| 1590 | 1671 | |
| 1591 | 1672 | // Do not waste my time... |
| 1592 | - if (empty($users) || empty($params)) |
|
| 1593 | - return false; |
|
| 1673 | + if (empty($users) || empty($params)) { |
|
| 1674 | + return false; |
|
| 1675 | + } |
|
| 1594 | 1676 | |
| 1595 | 1677 | // Make sure it's an array. |
| 1596 | 1678 | $users = !is_array($users) ? array($users) : array_unique($users); |
@@ -1614,31 +1696,36 @@ discard block |
||
| 1614 | 1696 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1615 | 1697 | { |
| 1616 | 1698 | // BBC? |
| 1617 | - if (!empty($row['bbc'])) |
|
| 1618 | - $row['value'] = parse_bbc($row['value']); |
|
| 1699 | + if (!empty($row['bbc'])) { |
|
| 1700 | + $row['value'] = parse_bbc($row['value']); |
|
| 1701 | + } |
|
| 1619 | 1702 | |
| 1620 | 1703 | // ... or checkbox? |
| 1621 | - elseif (isset($row['type']) && $row['type'] == 'check') |
|
| 1622 | - $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
| 1704 | + elseif (isset($row['type']) && $row['type'] == 'check') { |
|
| 1705 | + $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
| 1706 | + } |
|
| 1623 | 1707 | |
| 1624 | 1708 | // Enclosing the user input within some other text? |
| 1625 | - if (!empty($row['enclose'])) |
|
| 1626 | - $row['value'] = strtr($row['enclose'], array( |
|
| 1709 | + if (!empty($row['enclose'])) { |
|
| 1710 | + $row['value'] = strtr($row['enclose'], array( |
|
| 1627 | 1711 | '{SCRIPTURL}' => $scripturl, |
| 1628 | 1712 | '{IMAGES_URL}' => $settings['images_url'], |
| 1629 | 1713 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
| 1630 | 1714 | '{INPUT}' => un_htmlspecialchars($row['value']), |
| 1631 | 1715 | )); |
| 1716 | + } |
|
| 1632 | 1717 | |
| 1633 | 1718 | // Send a simple array if there is just 1 param |
| 1634 | - if (count($params) == 1) |
|
| 1635 | - $return[$row['id_member']] = $row; |
|
| 1719 | + if (count($params) == 1) { |
|
| 1720 | + $return[$row['id_member']] = $row; |
|
| 1721 | + } |
|
| 1636 | 1722 | |
| 1637 | 1723 | // More than 1? knock yourself out... |
| 1638 | 1724 | else |
| 1639 | 1725 | { |
| 1640 | - if (!isset($return[$row['id_member']])) |
|
| 1641 | - $return[$row['id_member']] = array(); |
|
| 1726 | + if (!isset($return[$row['id_member']])) { |
|
| 1727 | + $return[$row['id_member']] = array(); |
|
| 1728 | + } |
|
| 1642 | 1729 | |
| 1643 | 1730 | $return[$row['id_member']][$row['variable']] = $row; |
| 1644 | 1731 | } |
@@ -1672,8 +1759,9 @@ discard block |
||
| 1672 | 1759 | global $context; |
| 1673 | 1760 | |
| 1674 | 1761 | // Don't know any browser! |
| 1675 | - if (empty($context['browser'])) |
|
| 1676 | - detectBrowser(); |
|
| 1762 | + if (empty($context['browser'])) { |
|
| 1763 | + detectBrowser(); |
|
| 1764 | + } |
|
| 1677 | 1765 | |
| 1678 | 1766 | return !empty($context['browser'][$browser]) || !empty($context['browser']['is_' . $browser]) ? true : false; |
| 1679 | 1767 | } |
@@ -1691,8 +1779,9 @@ discard block |
||
| 1691 | 1779 | global $context, $settings, $options, $sourcedir, $ssi_theme, $smcFunc, $language, $board, $image_proxy_enabled; |
| 1692 | 1780 | |
| 1693 | 1781 | // The theme was specified by parameter. |
| 1694 | - if (!empty($id_theme)) |
|
| 1695 | - $id_theme = (int) $id_theme; |
|
| 1782 | + if (!empty($id_theme)) { |
|
| 1783 | + $id_theme = (int) $id_theme; |
|
| 1784 | + } |
|
| 1696 | 1785 | // The theme was specified by REQUEST. |
| 1697 | 1786 | elseif (!empty($_REQUEST['theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
| 1698 | 1787 | { |
@@ -1700,51 +1789,58 @@ discard block |
||
| 1700 | 1789 | $_SESSION['id_theme'] = $id_theme; |
| 1701 | 1790 | } |
| 1702 | 1791 | // The theme was specified by REQUEST... previously. |
| 1703 | - elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
|
| 1704 | - $id_theme = (int) $_SESSION['id_theme']; |
|
| 1792 | + elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) { |
|
| 1793 | + $id_theme = (int) $_SESSION['id_theme']; |
|
| 1794 | + } |
|
| 1705 | 1795 | // The theme is just the user's choice. (might use ?board=1;theme=0 to force board theme.) |
| 1706 | - elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) |
|
| 1707 | - $id_theme = $user_info['theme']; |
|
| 1796 | + elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) { |
|
| 1797 | + $id_theme = $user_info['theme']; |
|
| 1798 | + } |
|
| 1708 | 1799 | // The theme was specified by the board. |
| 1709 | - elseif (!empty($board_info['theme'])) |
|
| 1710 | - $id_theme = $board_info['theme']; |
|
| 1800 | + elseif (!empty($board_info['theme'])) { |
|
| 1801 | + $id_theme = $board_info['theme']; |
|
| 1802 | + } |
|
| 1711 | 1803 | // The theme is the forum's default. |
| 1712 | - else |
|
| 1713 | - $id_theme = $modSettings['theme_guests']; |
|
| 1804 | + else { |
|
| 1805 | + $id_theme = $modSettings['theme_guests']; |
|
| 1806 | + } |
|
| 1714 | 1807 | |
| 1715 | 1808 | // Verify the id_theme... no foul play. |
| 1716 | 1809 | // Always allow the board specific theme, if they are overriding. |
| 1717 | - if (!empty($board_info['theme']) && $board_info['override_theme']) |
|
| 1718 | - $id_theme = $board_info['theme']; |
|
| 1810 | + if (!empty($board_info['theme']) && $board_info['override_theme']) { |
|
| 1811 | + $id_theme = $board_info['theme']; |
|
| 1812 | + } |
|
| 1719 | 1813 | // If they have specified a particular theme to use with SSI allow it to be used. |
| 1720 | - elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) |
|
| 1721 | - $id_theme = (int) $id_theme; |
|
| 1722 | - elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
| 1814 | + elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) { |
|
| 1815 | + $id_theme = (int) $id_theme; |
|
| 1816 | + } elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
| 1723 | 1817 | { |
| 1724 | 1818 | $themes = explode(',', $modSettings['enableThemes']); |
| 1725 | - if (!in_array($id_theme, $themes)) |
|
| 1726 | - $id_theme = $modSettings['theme_guests']; |
|
| 1727 | - else |
|
| 1819 | + if (!in_array($id_theme, $themes)) { |
|
| 1820 | + $id_theme = $modSettings['theme_guests']; |
|
| 1821 | + } else { |
|
| 1822 | + $id_theme = (int) $id_theme; |
|
| 1823 | + } |
|
| 1824 | + } else { |
|
| 1728 | 1825 | $id_theme = (int) $id_theme; |
| 1729 | 1826 | } |
| 1730 | - else |
|
| 1731 | - $id_theme = (int) $id_theme; |
|
| 1732 | 1827 | |
| 1733 | 1828 | $member = empty($user_info['id']) ? -1 : $user_info['id']; |
| 1734 | 1829 | |
| 1735 | 1830 | // Disable image proxy if we don't have SSL enabled |
| 1736 | - if (empty($modSettings['force_ssl']) || $modSettings['force_ssl'] < 2) |
|
| 1737 | - $image_proxy_enabled = false; |
|
| 1831 | + if (empty($modSettings['force_ssl']) || $modSettings['force_ssl'] < 2) { |
|
| 1832 | + $image_proxy_enabled = false; |
|
| 1833 | + } |
|
| 1738 | 1834 | |
| 1739 | 1835 | if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && ($temp = cache_get_data('theme_settings-' . $id_theme . ':' . $member, 60)) != null && time() - 60 > $modSettings['settings_updated']) |
| 1740 | 1836 | { |
| 1741 | 1837 | $themeData = $temp; |
| 1742 | 1838 | $flag = true; |
| 1839 | + } elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) { |
|
| 1840 | + $themeData = $temp + array($member => array()); |
|
| 1841 | + } else { |
|
| 1842 | + $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
| 1743 | 1843 | } |
| 1744 | - elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) |
|
| 1745 | - $themeData = $temp + array($member => array()); |
|
| 1746 | - else |
|
| 1747 | - $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
| 1748 | 1844 | |
| 1749 | 1845 | if (empty($flag)) |
| 1750 | 1846 | { |
@@ -1763,31 +1859,37 @@ discard block |
||
| 1763 | 1859 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 1764 | 1860 | { |
| 1765 | 1861 | // There are just things we shouldn't be able to change as members. |
| 1766 | - if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url'))) |
|
| 1767 | - continue; |
|
| 1862 | + if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url'))) { |
|
| 1863 | + continue; |
|
| 1864 | + } |
|
| 1768 | 1865 | |
| 1769 | 1866 | // If this is the theme_dir of the default theme, store it. |
| 1770 | - if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) |
|
| 1771 | - $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
| 1867 | + if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) { |
|
| 1868 | + $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
| 1869 | + } |
|
| 1772 | 1870 | |
| 1773 | 1871 | // If this isn't set yet, is a theme option, or is not the default theme.. |
| 1774 | - if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') |
|
| 1775 | - $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
| 1872 | + if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') { |
|
| 1873 | + $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
| 1874 | + } |
|
| 1776 | 1875 | } |
| 1777 | 1876 | $smcFunc['db_free_result']($result); |
| 1778 | 1877 | |
| 1779 | - if (!empty($themeData[-1])) |
|
| 1780 | - foreach ($themeData[-1] as $k => $v) |
|
| 1878 | + if (!empty($themeData[-1])) { |
|
| 1879 | + foreach ($themeData[-1] as $k => $v) |
|
| 1781 | 1880 | { |
| 1782 | 1881 | if (!isset($themeData[$member][$k])) |
| 1783 | 1882 | $themeData[$member][$k] = $v; |
| 1883 | + } |
|
| 1784 | 1884 | } |
| 1785 | 1885 | |
| 1786 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 1787 | - cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
| 1886 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 1887 | + cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
| 1888 | + } |
|
| 1788 | 1889 | // Only if we didn't already load that part of the cache... |
| 1789 | - elseif (!isset($temp)) |
|
| 1790 | - cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
| 1890 | + elseif (!isset($temp)) { |
|
| 1891 | + cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
| 1892 | + } |
|
| 1791 | 1893 | } |
| 1792 | 1894 | |
| 1793 | 1895 | $settings = $themeData[0]; |
@@ -1804,20 +1906,24 @@ discard block |
||
| 1804 | 1906 | $settings['template_dirs'][] = $settings['theme_dir']; |
| 1805 | 1907 | |
| 1806 | 1908 | // Based on theme (if there is one). |
| 1807 | - if (!empty($settings['base_theme_dir'])) |
|
| 1808 | - $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
| 1909 | + if (!empty($settings['base_theme_dir'])) { |
|
| 1910 | + $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
| 1911 | + } |
|
| 1809 | 1912 | |
| 1810 | 1913 | // Lastly the default theme. |
| 1811 | - if ($settings['theme_dir'] != $settings['default_theme_dir']) |
|
| 1812 | - $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
| 1914 | + if ($settings['theme_dir'] != $settings['default_theme_dir']) { |
|
| 1915 | + $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
| 1916 | + } |
|
| 1813 | 1917 | |
| 1814 | - if (!$initialize) |
|
| 1815 | - return; |
|
| 1918 | + if (!$initialize) { |
|
| 1919 | + return; |
|
| 1920 | + } |
|
| 1816 | 1921 | |
| 1817 | 1922 | // Check to see if we're forcing SSL |
| 1818 | 1923 | if (!empty($modSettings['force_ssl']) && $modSettings['force_ssl'] == 2 && empty($maintenance) && |
| 1819 | - (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') && SMF != 'SSI') |
|
| 1820 | - redirectexit(strtr($_SERVER['REQUEST_URL'], array('http://' => 'https://'))); |
|
| 1924 | + (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') && SMF != 'SSI') { |
|
| 1925 | + redirectexit(strtr($_SERVER['REQUEST_URL'], array('http://' => 'https://'))); |
|
| 1926 | + } |
|
| 1821 | 1927 | |
| 1822 | 1928 | // Check to see if they're accessing it from the wrong place. |
| 1823 | 1929 | if (isset($_SERVER['HTTP_HOST']) || isset($_SERVER['SERVER_NAME'])) |
@@ -1825,8 +1931,9 @@ discard block |
||
| 1825 | 1931 | $detected_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https://' : 'http://'; |
| 1826 | 1932 | $detected_url .= empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST']; |
| 1827 | 1933 | $temp = preg_replace('~/' . basename($scripturl) . '(/.+)?$~', '', strtr(dirname($_SERVER['PHP_SELF']), '\\', '/')); |
| 1828 | - if ($temp != '/') |
|
| 1829 | - $detected_url .= $temp; |
|
| 1934 | + if ($temp != '/') { |
|
| 1935 | + $detected_url .= $temp; |
|
| 1936 | + } |
|
| 1830 | 1937 | } |
| 1831 | 1938 | if (isset($detected_url) && $detected_url != $boardurl) |
| 1832 | 1939 | { |
@@ -1838,8 +1945,9 @@ discard block |
||
| 1838 | 1945 | foreach ($aliases as $alias) |
| 1839 | 1946 | { |
| 1840 | 1947 | // Rip off all the boring parts, spaces, etc. |
| 1841 | - if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) |
|
| 1842 | - $do_fix = true; |
|
| 1948 | + if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) { |
|
| 1949 | + $do_fix = true; |
|
| 1950 | + } |
|
| 1843 | 1951 | } |
| 1844 | 1952 | } |
| 1845 | 1953 | |
@@ -1847,20 +1955,22 @@ discard block |
||
| 1847 | 1955 | if (empty($do_fix) && strtr($detected_url, array('://' => '://www.')) == $boardurl && (empty($_GET) || count($_GET) == 1) && SMF != 'SSI') |
| 1848 | 1956 | { |
| 1849 | 1957 | // Okay, this seems weird, but we don't want an endless loop - this will make $_GET not empty ;). |
| 1850 | - if (empty($_GET)) |
|
| 1851 | - redirectexit('wwwRedirect'); |
|
| 1852 | - else |
|
| 1958 | + if (empty($_GET)) { |
|
| 1959 | + redirectexit('wwwRedirect'); |
|
| 1960 | + } else |
|
| 1853 | 1961 | { |
| 1854 | 1962 | list ($k, $v) = each($_GET); |
| 1855 | 1963 | |
| 1856 | - if ($k != 'wwwRedirect') |
|
| 1857 | - redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
| 1964 | + if ($k != 'wwwRedirect') { |
|
| 1965 | + redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
| 1966 | + } |
|
| 1858 | 1967 | } |
| 1859 | 1968 | } |
| 1860 | 1969 | |
| 1861 | 1970 | // #3 is just a check for SSL... |
| 1862 | - if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) |
|
| 1863 | - $do_fix = true; |
|
| 1971 | + if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) { |
|
| 1972 | + $do_fix = true; |
|
| 1973 | + } |
|
| 1864 | 1974 | |
| 1865 | 1975 | // Okay, #4 - perhaps it's an IP address? We're gonna want to use that one, then. (assuming it's the IP or something...) |
| 1866 | 1976 | if (!empty($do_fix) || preg_match('~^http[s]?://(?:[\d\.:]+|\[[\d:]+\](?::\d+)?)(?:$|/)~', $detected_url) == 1) |
@@ -1894,8 +2004,9 @@ discard block |
||
| 1894 | 2004 | $board_info['moderators'][$k]['link'] = strtr($dummy['link'], array('"' . $oldurl => '"' . $boardurl)); |
| 1895 | 2005 | } |
| 1896 | 2006 | } |
| 1897 | - foreach ($context['linktree'] as $k => $dummy) |
|
| 1898 | - $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
| 2007 | + foreach ($context['linktree'] as $k => $dummy) { |
|
| 2008 | + $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
| 2009 | + } |
|
| 1899 | 2010 | } |
| 1900 | 2011 | } |
| 1901 | 2012 | // Set up the contextual user array. |
@@ -1914,16 +2025,16 @@ discard block |
||
| 1914 | 2025 | 'email' => $user_info['email'], |
| 1915 | 2026 | 'ignoreusers' => $user_info['ignoreusers'], |
| 1916 | 2027 | ); |
| 1917 | - if (!$context['user']['is_guest']) |
|
| 1918 | - $context['user']['name'] = $user_info['name']; |
|
| 1919 | - elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) |
|
| 1920 | - $context['user']['name'] = $txt['guest_title']; |
|
| 2028 | + if (!$context['user']['is_guest']) { |
|
| 2029 | + $context['user']['name'] = $user_info['name']; |
|
| 2030 | + } elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) { |
|
| 2031 | + $context['user']['name'] = $txt['guest_title']; |
|
| 2032 | + } |
|
| 1921 | 2033 | |
| 1922 | 2034 | // Determine the current smiley set. |
| 1923 | 2035 | $user_info['smiley_set'] = (!in_array($user_info['smiley_set'], explode(',', $modSettings['smiley_sets_known'])) && $user_info['smiley_set'] != 'none') || empty($modSettings['smiley_sets_enable']) ? (!empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default']) : $user_info['smiley_set']; |
| 1924 | 2036 | $context['user']['smiley_set'] = $user_info['smiley_set']; |
| 1925 | - } |
|
| 1926 | - else |
|
| 2037 | + } else |
|
| 1927 | 2038 | { |
| 1928 | 2039 | $context['user'] = array( |
| 1929 | 2040 | 'id' => -1, |
@@ -1939,18 +2050,24 @@ discard block |
||
| 1939 | 2050 | } |
| 1940 | 2051 | |
| 1941 | 2052 | // Some basic information... |
| 1942 | - if (!isset($context['html_headers'])) |
|
| 1943 | - $context['html_headers'] = ''; |
|
| 1944 | - if (!isset($context['javascript_files'])) |
|
| 1945 | - $context['javascript_files'] = array(); |
|
| 1946 | - if (!isset($context['css_files'])) |
|
| 1947 | - $context['css_files'] = array(); |
|
| 1948 | - if (!isset($context['css_header'])) |
|
| 1949 | - $context['css_header'] = array(); |
|
| 1950 | - if (!isset($context['javascript_inline'])) |
|
| 1951 | - $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
| 1952 | - if (!isset($context['javascript_vars'])) |
|
| 1953 | - $context['javascript_vars'] = array(); |
|
| 2053 | + if (!isset($context['html_headers'])) { |
|
| 2054 | + $context['html_headers'] = ''; |
|
| 2055 | + } |
|
| 2056 | + if (!isset($context['javascript_files'])) { |
|
| 2057 | + $context['javascript_files'] = array(); |
|
| 2058 | + } |
|
| 2059 | + if (!isset($context['css_files'])) { |
|
| 2060 | + $context['css_files'] = array(); |
|
| 2061 | + } |
|
| 2062 | + if (!isset($context['css_header'])) { |
|
| 2063 | + $context['css_header'] = array(); |
|
| 2064 | + } |
|
| 2065 | + if (!isset($context['javascript_inline'])) { |
|
| 2066 | + $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
| 2067 | + } |
|
| 2068 | + if (!isset($context['javascript_vars'])) { |
|
| 2069 | + $context['javascript_vars'] = array(); |
|
| 2070 | + } |
|
| 1954 | 2071 | |
| 1955 | 2072 | $context['login_url'] = (!empty($modSettings['force_ssl']) && $modSettings['force_ssl'] < 2 ? strtr($scripturl, array('http://' => 'https://')) : $scripturl) . '?action=login2'; |
| 1956 | 2073 | $context['menu_separator'] = !empty($settings['use_image_buttons']) ? ' ' : ' | '; |
@@ -1962,8 +2079,9 @@ discard block |
||
| 1962 | 2079 | $context['current_action'] = isset($_REQUEST['action']) ? $smcFunc['htmlspecialchars']($_REQUEST['action']) : null; |
| 1963 | 2080 | $context['current_subaction'] = isset($_REQUEST['sa']) ? $_REQUEST['sa'] : null; |
| 1964 | 2081 | $context['can_register'] = empty($modSettings['registration_method']) || $modSettings['registration_method'] != 3; |
| 1965 | - if (isset($modSettings['load_average'])) |
|
| 1966 | - $context['load_average'] = $modSettings['load_average']; |
|
| 2082 | + if (isset($modSettings['load_average'])) { |
|
| 2083 | + $context['load_average'] = $modSettings['load_average']; |
|
| 2084 | + } |
|
| 1967 | 2085 | |
| 1968 | 2086 | // Detect the browser. This is separated out because it's also used in attachment downloads |
| 1969 | 2087 | detectBrowser(); |
@@ -1977,8 +2095,9 @@ discard block |
||
| 1977 | 2095 | // This allows sticking some HTML on the page output - useful for controls. |
| 1978 | 2096 | $context['insert_after_template'] = ''; |
| 1979 | 2097 | |
| 1980 | - if (!isset($txt)) |
|
| 1981 | - $txt = array(); |
|
| 2098 | + if (!isset($txt)) { |
|
| 2099 | + $txt = array(); |
|
| 2100 | + } |
|
| 1982 | 2101 | |
| 1983 | 2102 | $simpleActions = array( |
| 1984 | 2103 | 'findmember', |
@@ -2024,9 +2143,10 @@ discard block |
||
| 2024 | 2143 | |
| 2025 | 2144 | // See if theres any extra param to check. |
| 2026 | 2145 | $requiresXML = false; |
| 2027 | - foreach ($extraParams as $key => $extra) |
|
| 2028 | - if (isset($_REQUEST[$extra])) |
|
| 2146 | + foreach ($extraParams as $key => $extra) { |
|
| 2147 | + if (isset($_REQUEST[$extra])) |
|
| 2029 | 2148 | $requiresXML = true; |
| 2149 | + } |
|
| 2030 | 2150 | |
| 2031 | 2151 | // Output is fully XML, so no need for the index template. |
| 2032 | 2152 | if (isset($_REQUEST['xml']) && (in_array($context['current_action'], $xmlActions) || $requiresXML)) |
@@ -2041,37 +2161,39 @@ discard block |
||
| 2041 | 2161 | { |
| 2042 | 2162 | loadLanguage('index+Modifications'); |
| 2043 | 2163 | $context['template_layers'] = array(); |
| 2044 | - } |
|
| 2045 | - |
|
| 2046 | - else |
|
| 2164 | + } else |
|
| 2047 | 2165 | { |
| 2048 | 2166 | // Custom templates to load, or just default? |
| 2049 | - if (isset($settings['theme_templates'])) |
|
| 2050 | - $templates = explode(',', $settings['theme_templates']); |
|
| 2051 | - else |
|
| 2052 | - $templates = array('index'); |
|
| 2167 | + if (isset($settings['theme_templates'])) { |
|
| 2168 | + $templates = explode(',', $settings['theme_templates']); |
|
| 2169 | + } else { |
|
| 2170 | + $templates = array('index'); |
|
| 2171 | + } |
|
| 2053 | 2172 | |
| 2054 | 2173 | // Load each template... |
| 2055 | - foreach ($templates as $template) |
|
| 2056 | - loadTemplate($template); |
|
| 2174 | + foreach ($templates as $template) { |
|
| 2175 | + loadTemplate($template); |
|
| 2176 | + } |
|
| 2057 | 2177 | |
| 2058 | 2178 | // ...and attempt to load their associated language files. |
| 2059 | 2179 | $required_files = implode('+', array_merge($templates, array('Modifications'))); |
| 2060 | 2180 | loadLanguage($required_files, '', false); |
| 2061 | 2181 | |
| 2062 | 2182 | // Custom template layers? |
| 2063 | - if (isset($settings['theme_layers'])) |
|
| 2064 | - $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
| 2065 | - else |
|
| 2066 | - $context['template_layers'] = array('html', 'body'); |
|
| 2183 | + if (isset($settings['theme_layers'])) { |
|
| 2184 | + $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
| 2185 | + } else { |
|
| 2186 | + $context['template_layers'] = array('html', 'body'); |
|
| 2187 | + } |
|
| 2067 | 2188 | } |
| 2068 | 2189 | |
| 2069 | 2190 | // Initialize the theme. |
| 2070 | 2191 | loadSubTemplate('init', 'ignore'); |
| 2071 | 2192 | |
| 2072 | 2193 | // Allow overriding the board wide time/number formats. |
| 2073 | - if (empty($user_settings['time_format']) && !empty($txt['time_format'])) |
|
| 2074 | - $user_info['time_format'] = $txt['time_format']; |
|
| 2194 | + if (empty($user_settings['time_format']) && !empty($txt['time_format'])) { |
|
| 2195 | + $user_info['time_format'] = $txt['time_format']; |
|
| 2196 | + } |
|
| 2075 | 2197 | |
| 2076 | 2198 | // Set the character set from the template. |
| 2077 | 2199 | $context['character_set'] = empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']; |
@@ -2079,12 +2201,14 @@ discard block |
||
| 2079 | 2201 | $context['right_to_left'] = !empty($txt['lang_rtl']); |
| 2080 | 2202 | |
| 2081 | 2203 | // Guests may still need a name. |
| 2082 | - if ($context['user']['is_guest'] && empty($context['user']['name'])) |
|
| 2083 | - $context['user']['name'] = $txt['guest_title']; |
|
| 2204 | + if ($context['user']['is_guest'] && empty($context['user']['name'])) { |
|
| 2205 | + $context['user']['name'] = $txt['guest_title']; |
|
| 2206 | + } |
|
| 2084 | 2207 | |
| 2085 | 2208 | // Any theme-related strings that need to be loaded? |
| 2086 | - if (!empty($settings['require_theme_strings'])) |
|
| 2087 | - loadLanguage('ThemeStrings', '', false); |
|
| 2209 | + if (!empty($settings['require_theme_strings'])) { |
|
| 2210 | + loadLanguage('ThemeStrings', '', false); |
|
| 2211 | + } |
|
| 2088 | 2212 | |
| 2089 | 2213 | // Make a special URL for the language. |
| 2090 | 2214 | $settings['lang_images_url'] = $settings['images_url'] . '/' . (!empty($txt['image_lang']) ? $txt['image_lang'] : $user_info['language']); |
@@ -2095,8 +2219,9 @@ discard block |
||
| 2095 | 2219 | // Here is my luvly Responsive CSS |
| 2096 | 2220 | loadCSSFile('responsive.css', array('force_current' => false, 'validate' => true, 'minimize' => true), 'smf_responsive'); |
| 2097 | 2221 | |
| 2098 | - if ($context['right_to_left']) |
|
| 2099 | - loadCSSFile('rtl.css', array(), 'smf_rtl'); |
|
| 2222 | + if ($context['right_to_left']) { |
|
| 2223 | + loadCSSFile('rtl.css', array(), 'smf_rtl'); |
|
| 2224 | + } |
|
| 2100 | 2225 | |
| 2101 | 2226 | // We allow theme variants, because we're cool. |
| 2102 | 2227 | $context['theme_variant'] = ''; |
@@ -2104,14 +2229,17 @@ discard block |
||
| 2104 | 2229 | if (!empty($settings['theme_variants'])) |
| 2105 | 2230 | { |
| 2106 | 2231 | // Overriding - for previews and that ilk. |
| 2107 | - if (!empty($_REQUEST['variant'])) |
|
| 2108 | - $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
| 2232 | + if (!empty($_REQUEST['variant'])) { |
|
| 2233 | + $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
| 2234 | + } |
|
| 2109 | 2235 | // User selection? |
| 2110 | - if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) |
|
| 2111 | - $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
| 2236 | + if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) { |
|
| 2237 | + $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
| 2238 | + } |
|
| 2112 | 2239 | // If not a user variant, select the default. |
| 2113 | - if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) |
|
| 2114 | - $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
| 2240 | + if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) { |
|
| 2241 | + $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
| 2242 | + } |
|
| 2115 | 2243 | |
| 2116 | 2244 | // Do this to keep things easier in the templates. |
| 2117 | 2245 | $context['theme_variant'] = '_' . $context['theme_variant']; |
@@ -2120,20 +2248,23 @@ discard block |
||
| 2120 | 2248 | if (!empty($context['theme_variant'])) |
| 2121 | 2249 | { |
| 2122 | 2250 | loadCSSFile('index' . $context['theme_variant'] . '.css', array(), 'smf_index' . $context['theme_variant']); |
| 2123 | - if ($context['right_to_left']) |
|
| 2124 | - loadCSSFile('rtl' . $context['theme_variant'] . '.css', array(), 'smf_rtl' . $context['theme_variant']); |
|
| 2251 | + if ($context['right_to_left']) { |
|
| 2252 | + loadCSSFile('rtl' . $context['theme_variant'] . '.css', array(), 'smf_rtl' . $context['theme_variant']); |
|
| 2253 | + } |
|
| 2125 | 2254 | } |
| 2126 | 2255 | } |
| 2127 | 2256 | |
| 2128 | 2257 | // Let's be compatible with old themes! |
| 2129 | - if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) |
|
| 2130 | - $context['template_layers'] = array('main'); |
|
| 2258 | + if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) { |
|
| 2259 | + $context['template_layers'] = array('main'); |
|
| 2260 | + } |
|
| 2131 | 2261 | |
| 2132 | 2262 | $context['tabindex'] = 1; |
| 2133 | 2263 | |
| 2134 | 2264 | // Compatibility. |
| 2135 | - if (!isset($settings['theme_version'])) |
|
| 2136 | - $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
| 2265 | + if (!isset($settings['theme_version'])) { |
|
| 2266 | + $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
| 2267 | + } |
|
| 2137 | 2268 | |
| 2138 | 2269 | // Default JS variables for use in every theme |
| 2139 | 2270 | $context['javascript_vars'] = array( |
@@ -2152,18 +2283,18 @@ discard block |
||
| 2152 | 2283 | ); |
| 2153 | 2284 | |
| 2154 | 2285 | // Add the JQuery library to the list of files to load. |
| 2155 | - if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') |
|
| 2156 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
| 2157 | - |
|
| 2158 | - elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') |
|
| 2159 | - loadJavaScriptFile('jquery-3.1.1.min.js', array('seed' => false), 'smf_jquery'); |
|
| 2160 | - |
|
| 2161 | - elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') |
|
| 2162 | - loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery'); |
|
| 2286 | + if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') { |
|
| 2287 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
| 2288 | + } elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') { |
|
| 2289 | + loadJavaScriptFile('jquery-3.1.1.min.js', array('seed' => false), 'smf_jquery'); |
|
| 2290 | + } elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') { |
|
| 2291 | + loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery'); |
|
| 2292 | + } |
|
| 2163 | 2293 | |
| 2164 | 2294 | // Auto loading? template_javascript() will take care of the local half of this. |
| 2165 | - else |
|
| 2166 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
| 2295 | + else { |
|
| 2296 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
| 2297 | + } |
|
| 2167 | 2298 | |
| 2168 | 2299 | // Queue our JQuery plugins! |
| 2169 | 2300 | loadJavaScriptFile('smf_jquery_plugins.js', array('minimize' => true), 'smf_jquery_plugins'); |
@@ -2186,12 +2317,12 @@ discard block |
||
| 2186 | 2317 | require_once($sourcedir . '/ScheduledTasks.php'); |
| 2187 | 2318 | |
| 2188 | 2319 | // What to do, what to do?! |
| 2189 | - if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) |
|
| 2190 | - AutoTask(); |
|
| 2191 | - else |
|
| 2192 | - ReduceMailQueue(); |
|
| 2193 | - } |
|
| 2194 | - else |
|
| 2320 | + if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) { |
|
| 2321 | + AutoTask(); |
|
| 2322 | + } else { |
|
| 2323 | + ReduceMailQueue(); |
|
| 2324 | + } |
|
| 2325 | + } else |
|
| 2195 | 2326 | { |
| 2196 | 2327 | $type = empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time() ? 'task' : 'mailq'; |
| 2197 | 2328 | $ts = $type == 'mailq' ? $modSettings['mail_next_send'] : $modSettings['next_task_time']; |
@@ -2242,8 +2373,9 @@ discard block |
||
| 2242 | 2373 | foreach ($theme_includes as $include) |
| 2243 | 2374 | { |
| 2244 | 2375 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
| 2245 | - if (file_exists($include)) |
|
| 2246 | - require_once($include); |
|
| 2376 | + if (file_exists($include)) { |
|
| 2377 | + require_once($include); |
|
| 2378 | + } |
|
| 2247 | 2379 | } |
| 2248 | 2380 | } |
| 2249 | 2381 | |
@@ -2273,16 +2405,19 @@ discard block |
||
| 2273 | 2405 | // Do any style sheets first, cause we're easy with those. |
| 2274 | 2406 | if (!empty($style_sheets)) |
| 2275 | 2407 | { |
| 2276 | - if (!is_array($style_sheets)) |
|
| 2277 | - $style_sheets = array($style_sheets); |
|
| 2408 | + if (!is_array($style_sheets)) { |
|
| 2409 | + $style_sheets = array($style_sheets); |
|
| 2410 | + } |
|
| 2278 | 2411 | |
| 2279 | - foreach ($style_sheets as $sheet) |
|
| 2280 | - loadCSSFile($sheet . '.css', array(), $sheet); |
|
| 2412 | + foreach ($style_sheets as $sheet) { |
|
| 2413 | + loadCSSFile($sheet . '.css', array(), $sheet); |
|
| 2414 | + } |
|
| 2281 | 2415 | } |
| 2282 | 2416 | |
| 2283 | 2417 | // No template to load? |
| 2284 | - if ($template_name === false) |
|
| 2285 | - return true; |
|
| 2418 | + if ($template_name === false) { |
|
| 2419 | + return true; |
|
| 2420 | + } |
|
| 2286 | 2421 | |
| 2287 | 2422 | $loaded = false; |
| 2288 | 2423 | foreach ($settings['template_dirs'] as $template_dir) |
@@ -2297,12 +2432,14 @@ discard block |
||
| 2297 | 2432 | |
| 2298 | 2433 | if ($loaded) |
| 2299 | 2434 | { |
| 2300 | - if ($db_show_debug === true) |
|
| 2301 | - $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
| 2435 | + if ($db_show_debug === true) { |
|
| 2436 | + $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
| 2437 | + } |
|
| 2302 | 2438 | |
| 2303 | 2439 | // If they have specified an initialization function for this template, go ahead and call it now. |
| 2304 | - if (function_exists('template_' . $template_name . '_init')) |
|
| 2305 | - call_user_func('template_' . $template_name . '_init'); |
|
| 2440 | + if (function_exists('template_' . $template_name . '_init')) { |
|
| 2441 | + call_user_func('template_' . $template_name . '_init'); |
|
| 2442 | + } |
|
| 2306 | 2443 | } |
| 2307 | 2444 | // Hmmm... doesn't exist?! I don't suppose the directory is wrong, is it? |
| 2308 | 2445 | elseif (!file_exists($settings['default_theme_dir']) && file_exists($boarddir . '/Themes/default')) |
@@ -2322,13 +2459,14 @@ discard block |
||
| 2322 | 2459 | loadTemplate($template_name); |
| 2323 | 2460 | } |
| 2324 | 2461 | // Cause an error otherwise. |
| 2325 | - elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) |
|
| 2326 | - fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
| 2327 | - elseif ($fatal) |
|
| 2328 | - die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template')); |
|
| 2329 | - else |
|
| 2330 | - return false; |
|
| 2331 | -} |
|
| 2462 | + elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) { |
|
| 2463 | + fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
| 2464 | + } elseif ($fatal) { |
|
| 2465 | + die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template')); |
|
| 2466 | + } else { |
|
| 2467 | + return false; |
|
| 2468 | + } |
|
| 2469 | + } |
|
| 2332 | 2470 | |
| 2333 | 2471 | /** |
| 2334 | 2472 | * Load a sub-template. |
@@ -2346,17 +2484,19 @@ discard block |
||
| 2346 | 2484 | { |
| 2347 | 2485 | global $context, $txt, $db_show_debug; |
| 2348 | 2486 | |
| 2349 | - if ($db_show_debug === true) |
|
| 2350 | - $context['debug']['sub_templates'][] = $sub_template_name; |
|
| 2487 | + if ($db_show_debug === true) { |
|
| 2488 | + $context['debug']['sub_templates'][] = $sub_template_name; |
|
| 2489 | + } |
|
| 2351 | 2490 | |
| 2352 | 2491 | // Figure out what the template function is named. |
| 2353 | 2492 | $theme_function = 'template_' . $sub_template_name; |
| 2354 | - if (function_exists($theme_function)) |
|
| 2355 | - $theme_function(); |
|
| 2356 | - elseif ($fatal === false) |
|
| 2357 | - fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
| 2358 | - elseif ($fatal !== 'ignore') |
|
| 2359 | - die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name), 'template')); |
|
| 2493 | + if (function_exists($theme_function)) { |
|
| 2494 | + $theme_function(); |
|
| 2495 | + } elseif ($fatal === false) { |
|
| 2496 | + fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
| 2497 | + } elseif ($fatal !== 'ignore') { |
|
| 2498 | + die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name), 'template')); |
|
| 2499 | + } |
|
| 2360 | 2500 | |
| 2361 | 2501 | // Are we showing debugging for templates? Just make sure not to do it before the doctype... |
| 2362 | 2502 | if (allowedTo('admin_forum') && isset($_REQUEST['debug']) && !in_array($sub_template_name, array('init', 'main_below')) && ob_get_length() > 0 && !isset($_REQUEST['xml'])) |
@@ -2393,8 +2533,9 @@ discard block |
||
| 2393 | 2533 | $params['validate'] = isset($params['validate']) ? $params['validate'] : true; |
| 2394 | 2534 | |
| 2395 | 2535 | // If this is an external file, automatically set this to false. |
| 2396 | - if (!empty($params['external'])) |
|
| 2397 | - $params['minimize'] = false; |
|
| 2536 | + if (!empty($params['external'])) { |
|
| 2537 | + $params['minimize'] = false; |
|
| 2538 | + } |
|
| 2398 | 2539 | |
| 2399 | 2540 | // Account for shorthand like admin.css?alp21 filenames |
| 2400 | 2541 | $has_seed = strpos($fileName, '.css?'); |
@@ -2411,13 +2552,10 @@ discard block |
||
| 2411 | 2552 | { |
| 2412 | 2553 | $fileUrl = $settings['default_theme_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2413 | 2554 | $filePath = $settings['default_theme_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2555 | + } else { |
|
| 2556 | + $fileUrl = false; |
|
| 2414 | 2557 | } |
| 2415 | - |
|
| 2416 | - else |
|
| 2417 | - $fileUrl = false; |
|
| 2418 | - } |
|
| 2419 | - |
|
| 2420 | - else |
|
| 2558 | + } else |
|
| 2421 | 2559 | { |
| 2422 | 2560 | $fileUrl = $settings[$themeRef . '_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2423 | 2561 | $filePath = $settings[$themeRef . '_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2432,12 +2570,14 @@ discard block |
||
| 2432 | 2570 | } |
| 2433 | 2571 | |
| 2434 | 2572 | // Add it to the array for use in the template |
| 2435 | - if (!empty($fileName)) |
|
| 2436 | - $context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
| 2573 | + if (!empty($fileName)) { |
|
| 2574 | + $context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
| 2575 | + } |
|
| 2437 | 2576 | |
| 2438 | - if (!empty($context['right_to_left']) && !empty($params['rtl'])) |
|
| 2439 | - loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
| 2440 | -} |
|
| 2577 | + if (!empty($context['right_to_left']) && !empty($params['rtl'])) { |
|
| 2578 | + loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
| 2579 | + } |
|
| 2580 | + } |
|
| 2441 | 2581 | |
| 2442 | 2582 | /** |
| 2443 | 2583 | * Add a block of inline css code to be executed later |
@@ -2454,8 +2594,9 @@ discard block |
||
| 2454 | 2594 | global $context; |
| 2455 | 2595 | |
| 2456 | 2596 | // Gotta add something... |
| 2457 | - if (empty($css)) |
|
| 2458 | - return false; |
|
| 2597 | + if (empty($css)) { |
|
| 2598 | + return false; |
|
| 2599 | + } |
|
| 2459 | 2600 | |
| 2460 | 2601 | $context['css_header'][] = $css; |
| 2461 | 2602 | } |
@@ -2490,8 +2631,9 @@ discard block |
||
| 2490 | 2631 | $params['validate'] = isset($params['validate']) ? $params['validate'] : true; |
| 2491 | 2632 | |
| 2492 | 2633 | // If this is an external file, automatically set this to false. |
| 2493 | - if (!empty($params['external'])) |
|
| 2494 | - $params['minimize'] = false; |
|
| 2634 | + if (!empty($params['external'])) { |
|
| 2635 | + $params['minimize'] = false; |
|
| 2636 | + } |
|
| 2495 | 2637 | |
| 2496 | 2638 | // Account for shorthand like admin.js?alp21 filenames |
| 2497 | 2639 | $has_seed = strpos($fileName, '.js?'); |
@@ -2508,16 +2650,12 @@ discard block |
||
| 2508 | 2650 | { |
| 2509 | 2651 | $fileUrl = $settings['default_theme_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2510 | 2652 | $filePath = $settings['default_theme_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2511 | - } |
|
| 2512 | - |
|
| 2513 | - else |
|
| 2653 | + } else |
|
| 2514 | 2654 | { |
| 2515 | 2655 | $fileUrl = false; |
| 2516 | 2656 | $filePath = false; |
| 2517 | 2657 | } |
| 2518 | - } |
|
| 2519 | - |
|
| 2520 | - else |
|
| 2658 | + } else |
|
| 2521 | 2659 | { |
| 2522 | 2660 | $fileUrl = $settings[$themeRef . '_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2523 | 2661 | $filePath = $settings[$themeRef . '_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2532,9 +2670,10 @@ discard block |
||
| 2532 | 2670 | } |
| 2533 | 2671 | |
| 2534 | 2672 | // Add it to the array for use in the template |
| 2535 | - if (!empty($fileName)) |
|
| 2536 | - $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
| 2537 | -} |
|
| 2673 | + if (!empty($fileName)) { |
|
| 2674 | + $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
| 2675 | + } |
|
| 2676 | + } |
|
| 2538 | 2677 | |
| 2539 | 2678 | /** |
| 2540 | 2679 | * Add a Javascript variable for output later (for feeding text strings and similar to JS) |
@@ -2548,9 +2687,10 @@ discard block |
||
| 2548 | 2687 | { |
| 2549 | 2688 | global $context; |
| 2550 | 2689 | |
| 2551 | - if (!empty($key) && (!empty($value) || $value === '0')) |
|
| 2552 | - $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
| 2553 | -} |
|
| 2690 | + if (!empty($key) && (!empty($value) || $value === '0')) { |
|
| 2691 | + $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
| 2692 | + } |
|
| 2693 | + } |
|
| 2554 | 2694 | |
| 2555 | 2695 | /** |
| 2556 | 2696 | * Add a block of inline Javascript code to be executed later |
@@ -2567,8 +2707,9 @@ discard block |
||
| 2567 | 2707 | { |
| 2568 | 2708 | global $context; |
| 2569 | 2709 | |
| 2570 | - if (empty($javascript)) |
|
| 2571 | - return false; |
|
| 2710 | + if (empty($javascript)) { |
|
| 2711 | + return false; |
|
| 2712 | + } |
|
| 2572 | 2713 | |
| 2573 | 2714 | $context['javascript_inline'][($defer === true ? 'defer' : 'standard')][] = $javascript; |
| 2574 | 2715 | } |
@@ -2589,15 +2730,18 @@ discard block |
||
| 2589 | 2730 | static $already_loaded = array(); |
| 2590 | 2731 | |
| 2591 | 2732 | // Default to the user's language. |
| 2592 | - if ($lang == '') |
|
| 2593 | - $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
| 2733 | + if ($lang == '') { |
|
| 2734 | + $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
| 2735 | + } |
|
| 2594 | 2736 | |
| 2595 | 2737 | // Do we want the English version of language file as fallback? |
| 2596 | - if (empty($modSettings['disable_language_fallback']) && $lang != 'english') |
|
| 2597 | - loadLanguage($template_name, 'english', false); |
|
| 2738 | + if (empty($modSettings['disable_language_fallback']) && $lang != 'english') { |
|
| 2739 | + loadLanguage($template_name, 'english', false); |
|
| 2740 | + } |
|
| 2598 | 2741 | |
| 2599 | - if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) |
|
| 2600 | - return $lang; |
|
| 2742 | + if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) { |
|
| 2743 | + return $lang; |
|
| 2744 | + } |
|
| 2601 | 2745 | |
| 2602 | 2746 | // Make sure we have $settings - if not we're in trouble and need to find it! |
| 2603 | 2747 | if (empty($settings['default_theme_dir'])) |
@@ -2608,8 +2752,9 @@ discard block |
||
| 2608 | 2752 | |
| 2609 | 2753 | // What theme are we in? |
| 2610 | 2754 | $theme_name = basename($settings['theme_url']); |
| 2611 | - if (empty($theme_name)) |
|
| 2612 | - $theme_name = 'unknown'; |
|
| 2755 | + if (empty($theme_name)) { |
|
| 2756 | + $theme_name = 'unknown'; |
|
| 2757 | + } |
|
| 2613 | 2758 | |
| 2614 | 2759 | // For each file open it up and write it out! |
| 2615 | 2760 | foreach (explode('+', $template_name) as $template) |
@@ -2651,8 +2796,9 @@ discard block |
||
| 2651 | 2796 | $found = true; |
| 2652 | 2797 | |
| 2653 | 2798 | // setlocale is required for basename() & pathinfo() to work properly on the selected language |
| 2654 | - if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) |
|
| 2655 | - setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']); |
|
| 2799 | + if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) { |
|
| 2800 | + setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']); |
|
| 2801 | + } |
|
| 2656 | 2802 | |
| 2657 | 2803 | break; |
| 2658 | 2804 | } |
@@ -2692,8 +2838,9 @@ discard block |
||
| 2692 | 2838 | } |
| 2693 | 2839 | |
| 2694 | 2840 | // Keep track of what we're up to soldier. |
| 2695 | - if ($db_show_debug === true) |
|
| 2696 | - $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
| 2841 | + if ($db_show_debug === true) { |
|
| 2842 | + $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
| 2843 | + } |
|
| 2697 | 2844 | |
| 2698 | 2845 | // Remember what we have loaded, and in which language. |
| 2699 | 2846 | $already_loaded[$template_name] = $lang; |
@@ -2739,8 +2886,9 @@ discard block |
||
| 2739 | 2886 | ) |
| 2740 | 2887 | ); |
| 2741 | 2888 | // In the EXTREMELY unlikely event this happens, give an error message. |
| 2742 | - if ($smcFunc['db_num_rows']($result) == 0) |
|
| 2743 | - fatal_lang_error('parent_not_found', 'critical'); |
|
| 2889 | + if ($smcFunc['db_num_rows']($result) == 0) { |
|
| 2890 | + fatal_lang_error('parent_not_found', 'critical'); |
|
| 2891 | + } |
|
| 2744 | 2892 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 2745 | 2893 | { |
| 2746 | 2894 | if (!isset($boards[$row['id_board']])) |
@@ -2757,8 +2905,8 @@ discard block |
||
| 2757 | 2905 | ); |
| 2758 | 2906 | } |
| 2759 | 2907 | // If a moderator exists for this board, add that moderator for all children too. |
| 2760 | - if (!empty($row['id_moderator'])) |
|
| 2761 | - foreach ($boards as $id => $dummy) |
|
| 2908 | + if (!empty($row['id_moderator'])) { |
|
| 2909 | + foreach ($boards as $id => $dummy) |
|
| 2762 | 2910 | { |
| 2763 | 2911 | $boards[$id]['moderators'][$row['id_moderator']] = array( |
| 2764 | 2912 | 'id' => $row['id_moderator'], |
@@ -2766,11 +2914,12 @@ discard block |
||
| 2766 | 2914 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
| 2767 | 2915 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
| 2768 | 2916 | ); |
| 2917 | + } |
|
| 2769 | 2918 | } |
| 2770 | 2919 | |
| 2771 | 2920 | // If a moderator group exists for this board, add that moderator group for all children too |
| 2772 | - if (!empty($row['id_moderator_group'])) |
|
| 2773 | - foreach ($boards as $id => $dummy) |
|
| 2921 | + if (!empty($row['id_moderator_group'])) { |
|
| 2922 | + foreach ($boards as $id => $dummy) |
|
| 2774 | 2923 | { |
| 2775 | 2924 | $boards[$id]['moderator_groups'][$row['id_moderator_group']] = array( |
| 2776 | 2925 | 'id' => $row['id_moderator_group'], |
@@ -2778,6 +2927,7 @@ discard block |
||
| 2778 | 2927 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
| 2779 | 2928 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
| 2780 | 2929 | ); |
| 2930 | + } |
|
| 2781 | 2931 | } |
| 2782 | 2932 | } |
| 2783 | 2933 | $smcFunc['db_free_result']($result); |
@@ -2804,23 +2954,27 @@ discard block |
||
| 2804 | 2954 | if (!$use_cache || ($context['languages'] = cache_get_data('known_languages', !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600)) == null) |
| 2805 | 2955 | { |
| 2806 | 2956 | // If we don't have our ucwords function defined yet, let's load the settings data. |
| 2807 | - if (empty($smcFunc['ucwords'])) |
|
| 2808 | - reloadSettings(); |
|
| 2957 | + if (empty($smcFunc['ucwords'])) { |
|
| 2958 | + reloadSettings(); |
|
| 2959 | + } |
|
| 2809 | 2960 | |
| 2810 | 2961 | // If we don't have our theme information yet, let's get it. |
| 2811 | - if (empty($settings['default_theme_dir'])) |
|
| 2812 | - loadTheme(0, false); |
|
| 2962 | + if (empty($settings['default_theme_dir'])) { |
|
| 2963 | + loadTheme(0, false); |
|
| 2964 | + } |
|
| 2813 | 2965 | |
| 2814 | 2966 | // Default language directories to try. |
| 2815 | 2967 | $language_directories = array( |
| 2816 | 2968 | $settings['default_theme_dir'] . '/languages', |
| 2817 | 2969 | ); |
| 2818 | - if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) |
|
| 2819 | - $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
| 2970 | + if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) { |
|
| 2971 | + $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
| 2972 | + } |
|
| 2820 | 2973 | |
| 2821 | 2974 | // We possibly have a base theme directory. |
| 2822 | - if (!empty($settings['base_theme_dir'])) |
|
| 2823 | - $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
| 2975 | + if (!empty($settings['base_theme_dir'])) { |
|
| 2976 | + $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
| 2977 | + } |
|
| 2824 | 2978 | |
| 2825 | 2979 | // Remove any duplicates. |
| 2826 | 2980 | $language_directories = array_unique($language_directories); |
@@ -2834,20 +2988,21 @@ discard block |
||
| 2834 | 2988 | foreach ($language_directories as $language_dir) |
| 2835 | 2989 | { |
| 2836 | 2990 | // Can't look in here... doesn't exist! |
| 2837 | - if (!file_exists($language_dir)) |
|
| 2838 | - continue; |
|
| 2991 | + if (!file_exists($language_dir)) { |
|
| 2992 | + continue; |
|
| 2993 | + } |
|
| 2839 | 2994 | |
| 2840 | 2995 | $dir = dir($language_dir); |
| 2841 | 2996 | while ($entry = $dir->read()) |
| 2842 | 2997 | { |
| 2843 | 2998 | // Look for the index language file... For good measure skip any "index.language-utf8.php" files |
| 2844 | - if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) |
|
| 2845 | - continue; |
|
| 2846 | - |
|
| 2847 | - if (!empty($langList) && !empty($langList[$matches[1]])) |
|
| 2848 | - $langName = $langList[$matches[1]]; |
|
| 2999 | + if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) { |
|
| 3000 | + continue; |
|
| 3001 | + } |
|
| 2849 | 3002 | |
| 2850 | - else |
|
| 3003 | + if (!empty($langList) && !empty($langList[$matches[1]])) { |
|
| 3004 | + $langName = $langList[$matches[1]]; |
|
| 3005 | + } else |
|
| 2851 | 3006 | { |
| 2852 | 3007 | $langName = $smcFunc['ucwords'](strtr($matches[1], array('_' => ' '))); |
| 2853 | 3008 | |
@@ -2888,12 +3043,14 @@ discard block |
||
| 2888 | 3043 | } |
| 2889 | 3044 | |
| 2890 | 3045 | // Do we need to store the lang list? |
| 2891 | - if (empty($langList)) |
|
| 2892 | - updateSettings(array('langList' => json_encode($catchLang))); |
|
| 3046 | + if (empty($langList)) { |
|
| 3047 | + updateSettings(array('langList' => json_encode($catchLang))); |
|
| 3048 | + } |
|
| 2893 | 3049 | |
| 2894 | 3050 | // Let's cash in on this deal. |
| 2895 | - if (!empty($modSettings['cache_enable'])) |
|
| 2896 | - cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
| 3051 | + if (!empty($modSettings['cache_enable'])) { |
|
| 3052 | + cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
| 3053 | + } |
|
| 2897 | 3054 | } |
| 2898 | 3055 | |
| 2899 | 3056 | return $context['languages']; |
@@ -2916,8 +3073,9 @@ discard block |
||
| 2916 | 3073 | global $modSettings, $options, $txt; |
| 2917 | 3074 | static $censor_vulgar = null, $censor_proper; |
| 2918 | 3075 | |
| 2919 | - if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') |
|
| 2920 | - return $text; |
|
| 3076 | + if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') { |
|
| 3077 | + return $text; |
|
| 3078 | + } |
|
| 2921 | 3079 | |
| 2922 | 3080 | // If they haven't yet been loaded, load them. |
| 2923 | 3081 | if ($censor_vulgar == null) |
@@ -2945,9 +3103,9 @@ discard block |
||
| 2945 | 3103 | { |
| 2946 | 3104 | $func = !empty($modSettings['censorIgnoreCase']) ? 'str_ireplace' : 'str_replace'; |
| 2947 | 3105 | $text = $func($censor_vulgar, $censor_proper, $text); |
| 3106 | + } else { |
|
| 3107 | + $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
| 2948 | 3108 | } |
| 2949 | - else |
|
| 2950 | - $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
| 2951 | 3109 | |
| 2952 | 3110 | return $text; |
| 2953 | 3111 | } |
@@ -2973,38 +3131,42 @@ discard block |
||
| 2973 | 3131 | @ini_set('track_errors', '1'); |
| 2974 | 3132 | |
| 2975 | 3133 | // Don't include the file more than once, if $once is true. |
| 2976 | - if ($once && in_array($filename, $templates)) |
|
| 2977 | - return; |
|
| 3134 | + if ($once && in_array($filename, $templates)) { |
|
| 3135 | + return; |
|
| 3136 | + } |
|
| 2978 | 3137 | // Add this file to the include list, whether $once is true or not. |
| 2979 | - else |
|
| 2980 | - $templates[] = $filename; |
|
| 3138 | + else { |
|
| 3139 | + $templates[] = $filename; |
|
| 3140 | + } |
|
| 2981 | 3141 | |
| 2982 | 3142 | // Are we going to use eval? |
| 2983 | 3143 | if (empty($modSettings['disableTemplateEval'])) |
| 2984 | 3144 | { |
| 2985 | 3145 | $file_found = file_exists($filename) && eval('?' . '>' . rtrim(file_get_contents($filename))) !== false; |
| 2986 | 3146 | $settings['current_include_filename'] = $filename; |
| 2987 | - } |
|
| 2988 | - else |
|
| 3147 | + } else |
|
| 2989 | 3148 | { |
| 2990 | 3149 | $file_found = file_exists($filename); |
| 2991 | 3150 | |
| 2992 | - if ($once && $file_found) |
|
| 2993 | - require_once($filename); |
|
| 2994 | - elseif ($file_found) |
|
| 2995 | - require($filename); |
|
| 3151 | + if ($once && $file_found) { |
|
| 3152 | + require_once($filename); |
|
| 3153 | + } elseif ($file_found) { |
|
| 3154 | + require($filename); |
|
| 3155 | + } |
|
| 2996 | 3156 | } |
| 2997 | 3157 | |
| 2998 | 3158 | if ($file_found !== true) |
| 2999 | 3159 | { |
| 3000 | 3160 | ob_end_clean(); |
| 3001 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
| 3002 | - @ob_start('ob_gzhandler'); |
|
| 3003 | - else |
|
| 3004 | - ob_start(); |
|
| 3161 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
| 3162 | + @ob_start('ob_gzhandler'); |
|
| 3163 | + } else { |
|
| 3164 | + ob_start(); |
|
| 3165 | + } |
|
| 3005 | 3166 | |
| 3006 | - if (isset($_GET['debug'])) |
|
| 3007 | - header('Content-Type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 3167 | + if (isset($_GET['debug'])) { |
|
| 3168 | + header('Content-Type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 3169 | + } |
|
| 3008 | 3170 | |
| 3009 | 3171 | // Don't cache error pages!! |
| 3010 | 3172 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
@@ -3023,12 +3185,13 @@ discard block |
||
| 3023 | 3185 | echo '<!DOCTYPE html> |
| 3024 | 3186 | <html', !empty($context['right_to_left']) ? ' dir="rtl"' : '', '> |
| 3025 | 3187 | <head>'; |
| 3026 | - if (isset($context['character_set'])) |
|
| 3027 | - echo ' |
|
| 3188 | + if (isset($context['character_set'])) { |
|
| 3189 | + echo ' |
|
| 3028 | 3190 | <meta charset="', $context['character_set'], '">'; |
| 3191 | + } |
|
| 3029 | 3192 | |
| 3030 | - if (!empty($maintenance) && !allowedTo('admin_forum')) |
|
| 3031 | - echo ' |
|
| 3193 | + if (!empty($maintenance) && !allowedTo('admin_forum')) { |
|
| 3194 | + echo ' |
|
| 3032 | 3195 | <title>', $mtitle, '</title> |
| 3033 | 3196 | </head> |
| 3034 | 3197 | <body> |
@@ -3036,8 +3199,8 @@ discard block |
||
| 3036 | 3199 | ', $mmessage, ' |
| 3037 | 3200 | </body> |
| 3038 | 3201 | </html>'; |
| 3039 | - elseif (!allowedTo('admin_forum')) |
|
| 3040 | - echo ' |
|
| 3202 | + } elseif (!allowedTo('admin_forum')) { |
|
| 3203 | + echo ' |
|
| 3041 | 3204 | <title>', $txt['template_parse_error'], '</title> |
| 3042 | 3205 | </head> |
| 3043 | 3206 | <body> |
@@ -3045,15 +3208,17 @@ discard block |
||
| 3045 | 3208 | ', $txt['template_parse_error_message'], ' |
| 3046 | 3209 | </body> |
| 3047 | 3210 | </html>'; |
| 3048 | - else |
|
| 3211 | + } else |
|
| 3049 | 3212 | { |
| 3050 | 3213 | require_once($sourcedir . '/Subs-Package.php'); |
| 3051 | 3214 | |
| 3052 | 3215 | $error = fetch_web_data($boardurl . strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
| 3053 | - if (empty($error) && ini_get('track_errors') && !empty($php_errormsg)) |
|
| 3054 | - $error = $php_errormsg; |
|
| 3055 | - if (empty($error)) |
|
| 3056 | - $error = $txt['template_parse_errmsg']; |
|
| 3216 | + if (empty($error) && ini_get('track_errors') && !empty($php_errormsg)) { |
|
| 3217 | + $error = $php_errormsg; |
|
| 3218 | + } |
|
| 3219 | + if (empty($error)) { |
|
| 3220 | + $error = $txt['template_parse_errmsg']; |
|
| 3221 | + } |
|
| 3057 | 3222 | |
| 3058 | 3223 | $error = strtr($error, array('<b>' => '<strong>', '</b>' => '</strong>')); |
| 3059 | 3224 | |
@@ -3064,11 +3229,12 @@ discard block |
||
| 3064 | 3229 | <h3>', $txt['template_parse_error'], '</h3> |
| 3065 | 3230 | ', sprintf($txt['template_parse_error_details'], strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
| 3066 | 3231 | |
| 3067 | - if (!empty($error)) |
|
| 3068 | - echo ' |
|
| 3232 | + if (!empty($error)) { |
|
| 3233 | + echo ' |
|
| 3069 | 3234 | <hr> |
| 3070 | 3235 | |
| 3071 | 3236 | <div style="margin: 0 20px;"><pre>', strtr(strtr($error, array('<strong>' . $boarddir => '<strong>...', '<strong>' . strtr($boarddir, '\\', '/') => '<strong>...')), '\\', '/'), '</pre></div>'; |
| 3237 | + } |
|
| 3072 | 3238 | |
| 3073 | 3239 | // I know, I know... this is VERY COMPLICATED. Still, it's good. |
| 3074 | 3240 | if (preg_match('~ <strong>(\d+)</strong><br( /)?' . '>$~i', $error, $match) != 0) |
@@ -3078,10 +3244,11 @@ discard block |
||
| 3078 | 3244 | $data2 = preg_split('~\<br( /)?\>~', $data2); |
| 3079 | 3245 | |
| 3080 | 3246 | // Fix the PHP code stuff... |
| 3081 | - if (!isBrowser('gecko')) |
|
| 3082 | - $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
| 3083 | - else |
|
| 3084 | - $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
| 3247 | + if (!isBrowser('gecko')) { |
|
| 3248 | + $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
| 3249 | + } else { |
|
| 3250 | + $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
| 3251 | + } |
|
| 3085 | 3252 | |
| 3086 | 3253 | // Now we get to work around a bug in PHP where it doesn't escape <br>s! |
| 3087 | 3254 | $j = -1; |
@@ -3089,8 +3256,9 @@ discard block |
||
| 3089 | 3256 | { |
| 3090 | 3257 | $j++; |
| 3091 | 3258 | |
| 3092 | - if (substr_count($line, '<br>') == 0) |
|
| 3093 | - continue; |
|
| 3259 | + if (substr_count($line, '<br>') == 0) { |
|
| 3260 | + continue; |
|
| 3261 | + } |
|
| 3094 | 3262 | |
| 3095 | 3263 | $n = substr_count($line, '<br>'); |
| 3096 | 3264 | for ($i = 0; $i < $n; $i++) |
@@ -3109,38 +3277,42 @@ discard block |
||
| 3109 | 3277 | // Figure out what the color coding was before... |
| 3110 | 3278 | $line = max($match[1] - 9, 1); |
| 3111 | 3279 | $last_line = ''; |
| 3112 | - for ($line2 = $line - 1; $line2 > 1; $line2--) |
|
| 3113 | - if (strpos($data2[$line2], '<') !== false) |
|
| 3280 | + for ($line2 = $line - 1; $line2 > 1; $line2--) { |
|
| 3281 | + if (strpos($data2[$line2], '<') !== false) |
|
| 3114 | 3282 | { |
| 3115 | 3283 | if (preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line2], $color_match) != 0) |
| 3116 | 3284 | $last_line = $color_match[1]; |
| 3285 | + } |
|
| 3117 | 3286 | break; |
| 3118 | 3287 | } |
| 3119 | 3288 | |
| 3120 | 3289 | // Show the relevant lines... |
| 3121 | 3290 | for ($n = min($match[1] + 4, count($data2) + 1); $line <= $n; $line++) |
| 3122 | 3291 | { |
| 3123 | - if ($line == $match[1]) |
|
| 3124 | - echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
| 3292 | + if ($line == $match[1]) { |
|
| 3293 | + echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
| 3294 | + } |
|
| 3125 | 3295 | |
| 3126 | 3296 | echo '<span style="color: black;">', sprintf('%' . strlen($n) . 's', $line), ':</span> '; |
| 3127 | - if (isset($data2[$line]) && $data2[$line] != '') |
|
| 3128 | - echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
| 3297 | + if (isset($data2[$line]) && $data2[$line] != '') { |
|
| 3298 | + echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
| 3299 | + } |
|
| 3129 | 3300 | |
| 3130 | 3301 | if (isset($data2[$line]) && preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line], $color_match) != 0) |
| 3131 | 3302 | { |
| 3132 | 3303 | $last_line = $color_match[1]; |
| 3133 | 3304 | echo '</', substr($last_line, 1, 4), '>'; |
| 3305 | + } elseif ($last_line != '' && strpos($data2[$line], '<') !== false) { |
|
| 3306 | + $last_line = ''; |
|
| 3307 | + } elseif ($last_line != '' && $data2[$line] != '') { |
|
| 3308 | + echo '</', substr($last_line, 1, 4), '>'; |
|
| 3134 | 3309 | } |
| 3135 | - elseif ($last_line != '' && strpos($data2[$line], '<') !== false) |
|
| 3136 | - $last_line = ''; |
|
| 3137 | - elseif ($last_line != '' && $data2[$line] != '') |
|
| 3138 | - echo '</', substr($last_line, 1, 4), '>'; |
|
| 3139 | 3310 | |
| 3140 | - if ($line == $match[1]) |
|
| 3141 | - echo '</pre></div><pre style="margin: 0;">'; |
|
| 3142 | - else |
|
| 3143 | - echo "\n"; |
|
| 3311 | + if ($line == $match[1]) { |
|
| 3312 | + echo '</pre></div><pre style="margin: 0;">'; |
|
| 3313 | + } else { |
|
| 3314 | + echo "\n"; |
|
| 3315 | + } |
|
| 3144 | 3316 | } |
| 3145 | 3317 | |
| 3146 | 3318 | echo '</pre></div>'; |
@@ -3164,8 +3336,9 @@ discard block |
||
| 3164 | 3336 | global $db_type, $db_name, $ssi_db_user, $ssi_db_passwd, $sourcedir, $db_prefix, $db_port; |
| 3165 | 3337 | |
| 3166 | 3338 | // Figure out what type of database we are using. |
| 3167 | - if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
|
| 3168 | - $db_type = 'mysql'; |
|
| 3339 | + if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) { |
|
| 3340 | + $db_type = 'mysql'; |
|
| 3341 | + } |
|
| 3169 | 3342 | |
| 3170 | 3343 | // Load the file for the database. |
| 3171 | 3344 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
@@ -3173,8 +3346,9 @@ discard block |
||
| 3173 | 3346 | $db_options = array(); |
| 3174 | 3347 | |
| 3175 | 3348 | // Add in the port if needed |
| 3176 | - if (!empty($db_port)) |
|
| 3177 | - $db_options['port'] = $db_port; |
|
| 3349 | + if (!empty($db_port)) { |
|
| 3350 | + $db_options['port'] = $db_port; |
|
| 3351 | + } |
|
| 3178 | 3352 | |
| 3179 | 3353 | // If we are in SSI try them first, but don't worry if it doesn't work, we have the normal username and password we can use. |
| 3180 | 3354 | if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd)) |
@@ -3193,13 +3367,15 @@ discard block |
||
| 3193 | 3367 | } |
| 3194 | 3368 | |
| 3195 | 3369 | // Safe guard here, if there isn't a valid connection lets put a stop to it. |
| 3196 | - if (!$db_connection) |
|
| 3197 | - display_db_error(); |
|
| 3370 | + if (!$db_connection) { |
|
| 3371 | + display_db_error(); |
|
| 3372 | + } |
|
| 3198 | 3373 | |
| 3199 | 3374 | // If in SSI mode fix up the prefix. |
| 3200 | - if (SMF == 'SSI') |
|
| 3201 | - db_fix_prefix($db_prefix, $db_name); |
|
| 3202 | -} |
|
| 3375 | + if (SMF == 'SSI') { |
|
| 3376 | + db_fix_prefix($db_prefix, $db_name); |
|
| 3377 | + } |
|
| 3378 | + } |
|
| 3203 | 3379 | |
| 3204 | 3380 | /** |
| 3205 | 3381 | * Try to load up a supported caching method. This is saved in $cacheAPI if we are not overriding it. |
@@ -3213,10 +3389,11 @@ discard block |
||
| 3213 | 3389 | global $sourcedir, $cacheAPI, $cache_accelerator; |
| 3214 | 3390 | |
| 3215 | 3391 | // Not overriding this and we have a cacheAPI, send it back. |
| 3216 | - if (empty($overrideCache) && is_object($cacheAPI)) |
|
| 3217 | - return $cacheAPI; |
|
| 3218 | - elseif (is_null($cacheAPI)) |
|
| 3219 | - $cacheAPI = false; |
|
| 3392 | + if (empty($overrideCache) && is_object($cacheAPI)) { |
|
| 3393 | + return $cacheAPI; |
|
| 3394 | + } elseif (is_null($cacheAPI)) { |
|
| 3395 | + $cacheAPI = false; |
|
| 3396 | + } |
|
| 3220 | 3397 | |
| 3221 | 3398 | // Make sure our class is in session. |
| 3222 | 3399 | require_once($sourcedir . '/Class-CacheAPI.php'); |
@@ -3237,8 +3414,9 @@ discard block |
||
| 3237 | 3414 | if (!$testAPI->isSupported()) |
| 3238 | 3415 | { |
| 3239 | 3416 | // Can we save ourselves? |
| 3240 | - if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') |
|
| 3241 | - return loadCacheAccelerator(null, false); |
|
| 3417 | + if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') { |
|
| 3418 | + return loadCacheAccelerator(null, false); |
|
| 3419 | + } |
|
| 3242 | 3420 | return false; |
| 3243 | 3421 | } |
| 3244 | 3422 | |
@@ -3250,9 +3428,9 @@ discard block |
||
| 3250 | 3428 | { |
| 3251 | 3429 | $cacheAPI = $testAPI; |
| 3252 | 3430 | return $cacheAPI; |
| 3431 | + } else { |
|
| 3432 | + return $testAPI; |
|
| 3253 | 3433 | } |
| 3254 | - else |
|
| 3255 | - return $testAPI; |
|
| 3256 | 3434 | } |
| 3257 | 3435 | } |
| 3258 | 3436 | |
@@ -3272,8 +3450,9 @@ discard block |
||
| 3272 | 3450 | |
| 3273 | 3451 | // @todo Why are we doing this if caching is disabled? |
| 3274 | 3452 | |
| 3275 | - if (function_exists('call_integration_hook')) |
|
| 3276 | - call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
| 3453 | + if (function_exists('call_integration_hook')) { |
|
| 3454 | + call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
| 3455 | + } |
|
| 3277 | 3456 | |
| 3278 | 3457 | /* Refresh the cache if either: |
| 3279 | 3458 | 1. Caching is disabled. |
@@ -3287,16 +3466,19 @@ discard block |
||
| 3287 | 3466 | require_once($sourcedir . '/' . $file); |
| 3288 | 3467 | $cache_block = call_user_func_array($function, $params); |
| 3289 | 3468 | |
| 3290 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) |
|
| 3291 | - cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
| 3469 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) { |
|
| 3470 | + cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
| 3471 | + } |
|
| 3292 | 3472 | } |
| 3293 | 3473 | |
| 3294 | 3474 | // Some cached data may need a freshening up after retrieval. |
| 3295 | - if (!empty($cache_block['post_retri_eval'])) |
|
| 3296 | - eval($cache_block['post_retri_eval']); |
|
| 3475 | + if (!empty($cache_block['post_retri_eval'])) { |
|
| 3476 | + eval($cache_block['post_retri_eval']); |
|
| 3477 | + } |
|
| 3297 | 3478 | |
| 3298 | - if (function_exists('call_integration_hook')) |
|
| 3299 | - call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
| 3479 | + if (function_exists('call_integration_hook')) { |
|
| 3480 | + call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
| 3481 | + } |
|
| 3300 | 3482 | |
| 3301 | 3483 | return $cache_block['data']; |
| 3302 | 3484 | } |
@@ -3323,8 +3505,9 @@ discard block |
||
| 3323 | 3505 | global $cache_enable, $cacheAPI; |
| 3324 | 3506 | global $cache_hits, $cache_count, $db_show_debug; |
| 3325 | 3507 | |
| 3326 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
| 3327 | - return; |
|
| 3508 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
| 3509 | + return; |
|
| 3510 | + } |
|
| 3328 | 3511 | |
| 3329 | 3512 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
| 3330 | 3513 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3337,12 +3520,14 @@ discard block |
||
| 3337 | 3520 | $value = $value === null ? null : json_encode($value); |
| 3338 | 3521 | $cacheAPI->putData($key, $value, $ttl); |
| 3339 | 3522 | |
| 3340 | - if (function_exists('call_integration_hook')) |
|
| 3341 | - call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
| 3523 | + if (function_exists('call_integration_hook')) { |
|
| 3524 | + call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
| 3525 | + } |
|
| 3342 | 3526 | |
| 3343 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
| 3344 | - $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
| 3345 | -} |
|
| 3527 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
| 3528 | + $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
| 3529 | + } |
|
| 3530 | + } |
|
| 3346 | 3531 | |
| 3347 | 3532 | /** |
| 3348 | 3533 | * Gets the value from the cache specified by key, so long as it is not older than ttl seconds. |
@@ -3358,8 +3543,9 @@ discard block |
||
| 3358 | 3543 | global $cache_enable, $cacheAPI; |
| 3359 | 3544 | global $cache_hits, $cache_count, $cache_misses, $cache_count_misses, $db_show_debug; |
| 3360 | 3545 | |
| 3361 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
| 3362 | - return; |
|
| 3546 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
| 3547 | + return; |
|
| 3548 | + } |
|
| 3363 | 3549 | |
| 3364 | 3550 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
| 3365 | 3551 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3379,16 +3565,18 @@ discard block |
||
| 3379 | 3565 | |
| 3380 | 3566 | if (empty($value)) |
| 3381 | 3567 | { |
| 3382 | - if (!is_array($cache_misses)) |
|
| 3383 | - $cache_misses = array(); |
|
| 3568 | + if (!is_array($cache_misses)) { |
|
| 3569 | + $cache_misses = array(); |
|
| 3570 | + } |
|
| 3384 | 3571 | |
| 3385 | 3572 | $cache_count_misses = isset($cache_count_misses) ? $cache_count_misses + 1 : 1; |
| 3386 | 3573 | $cache_misses[$cache_count_misses] = array('k' => $original_key, 'd' => 'get'); |
| 3387 | 3574 | } |
| 3388 | 3575 | } |
| 3389 | 3576 | |
| 3390 | - if (function_exists('call_integration_hook') && isset($value)) |
|
| 3391 | - call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
| 3577 | + if (function_exists('call_integration_hook') && isset($value)) { |
|
| 3578 | + call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
| 3579 | + } |
|
| 3392 | 3580 | |
| 3393 | 3581 | return empty($value) ? null : smf_json_decode($value, true); |
| 3394 | 3582 | } |
@@ -3410,8 +3598,9 @@ discard block |
||
| 3410 | 3598 | global $cacheAPI; |
| 3411 | 3599 | |
| 3412 | 3600 | // If we can't get to the API, can't do this. |
| 3413 | - if (empty($cacheAPI)) |
|
| 3414 | - return; |
|
| 3601 | + if (empty($cacheAPI)) { |
|
| 3602 | + return; |
|
| 3603 | + } |
|
| 3415 | 3604 | |
| 3416 | 3605 | // Ask the API to do the heavy lifting. cleanCache also calls invalidateCache to be sure. |
| 3417 | 3606 | $cacheAPI->cleanCache($type); |
@@ -3436,8 +3625,9 @@ discard block |
||
| 3436 | 3625 | global $modSettings, $boardurl, $smcFunc, $image_proxy_enabled, $image_proxy_secret; |
| 3437 | 3626 | |
| 3438 | 3627 | // Come on! |
| 3439 | - if (empty($data)) |
|
| 3440 | - return array(); |
|
| 3628 | + if (empty($data)) { |
|
| 3629 | + return array(); |
|
| 3630 | + } |
|
| 3441 | 3631 | |
| 3442 | 3632 | // Set a nice default var. |
| 3443 | 3633 | $image = ''; |
@@ -3445,11 +3635,11 @@ discard block |
||
| 3445 | 3635 | // Gravatar has been set as mandatory! |
| 3446 | 3636 | if (!empty($modSettings['gravatarOverride'])) |
| 3447 | 3637 | { |
| 3448 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) |
|
| 3449 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
| 3450 | - |
|
| 3451 | - else if (!empty($data['email'])) |
|
| 3452 | - $image = get_gravatar_url($data['email']); |
|
| 3638 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) { |
|
| 3639 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
| 3640 | + } else if (!empty($data['email'])) { |
|
| 3641 | + $image = get_gravatar_url($data['email']); |
|
| 3642 | + } |
|
| 3453 | 3643 | } |
| 3454 | 3644 | |
| 3455 | 3645 | // Look if the user has a gravatar field or has set an external url as avatar. |
@@ -3461,54 +3651,60 @@ discard block |
||
| 3461 | 3651 | // Gravatar. |
| 3462 | 3652 | if (stristr($data['avatar'], 'gravatar://')) |
| 3463 | 3653 | { |
| 3464 | - if ($data['avatar'] == 'gravatar://') |
|
| 3465 | - $image = get_gravatar_url($data['email']); |
|
| 3466 | - |
|
| 3467 | - elseif (!empty($modSettings['gravatarAllowExtraEmail'])) |
|
| 3468 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
| 3654 | + if ($data['avatar'] == 'gravatar://') { |
|
| 3655 | + $image = get_gravatar_url($data['email']); |
|
| 3656 | + } elseif (!empty($modSettings['gravatarAllowExtraEmail'])) { |
|
| 3657 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
| 3658 | + } |
|
| 3469 | 3659 | } |
| 3470 | 3660 | |
| 3471 | 3661 | // External url. |
| 3472 | 3662 | else |
| 3473 | 3663 | { |
| 3474 | 3664 | // Using ssl? |
| 3475 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false) |
|
| 3476 | - $image = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($data['avatar']) . '&hash=' . md5($data['avatar'] . $image_proxy_secret); |
|
| 3665 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false) { |
|
| 3666 | + $image = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($data['avatar']) . '&hash=' . md5($data['avatar'] . $image_proxy_secret); |
|
| 3667 | + } |
|
| 3477 | 3668 | |
| 3478 | 3669 | // Just a plain external url. |
| 3479 | - else |
|
| 3480 | - $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
| 3670 | + else { |
|
| 3671 | + $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
| 3672 | + } |
|
| 3481 | 3673 | } |
| 3482 | 3674 | } |
| 3483 | 3675 | |
| 3484 | 3676 | // Perhaps this user has an attachment as avatar... |
| 3485 | - else if (!empty($data['filename'])) |
|
| 3486 | - $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
| 3677 | + else if (!empty($data['filename'])) { |
|
| 3678 | + $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
| 3679 | + } |
|
| 3487 | 3680 | |
| 3488 | 3681 | // Right... no avatar... use our default image. |
| 3489 | - else |
|
| 3490 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
| 3682 | + else { |
|
| 3683 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
| 3684 | + } |
|
| 3491 | 3685 | } |
| 3492 | 3686 | |
| 3493 | 3687 | call_integration_hook('integrate_set_avatar_data', array(&$image, &$data)); |
| 3494 | 3688 | |
| 3495 | 3689 | // At this point in time $image has to be filled unless you chose to force gravatar and the user doesn't have the needed data to retrieve it... thus a check for !empty() is still needed. |
| 3496 | - if (!empty($image)) |
|
| 3497 | - return array( |
|
| 3690 | + if (!empty($image)) { |
|
| 3691 | + return array( |
|
| 3498 | 3692 | 'name' => !empty($data['avatar']) ? $data['avatar'] : '', |
| 3499 | 3693 | 'image' => '<img class="avatar" src="' . $image . '" />', |
| 3500 | 3694 | 'href' => $image, |
| 3501 | 3695 | 'url' => $image, |
| 3502 | 3696 | ); |
| 3697 | + } |
|
| 3503 | 3698 | |
| 3504 | 3699 | // Fallback to make life easier for everyone... |
| 3505 | - else |
|
| 3506 | - return array( |
|
| 3700 | + else { |
|
| 3701 | + return array( |
|
| 3507 | 3702 | 'name' => '', |
| 3508 | 3703 | 'image' => '', |
| 3509 | 3704 | 'href' => '', |
| 3510 | 3705 | 'url' => '', |
| 3511 | 3706 | ); |
| 3512 | -} |
|
| 3707 | + } |
|
| 3708 | + } |
|
| 3513 | 3709 | |
| 3514 | 3710 | ?> |
| 3515 | 3711 | \ No newline at end of file |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 3 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('Hacking attempt...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Our Cache API class |
@@ -27,8 +28,9 @@ discard block |
||
| 27 | 28 | { |
| 28 | 29 | $supported = function_exists('apcu_fetch') && function_exists('apcu_store'); |
| 29 | 30 | |
| 30 | - if ($test) |
|
| 31 | - return $supported; |
|
| 31 | + if ($test) { |
|
| 32 | + return $supported; |
|
| 33 | + } |
|
| 32 | 34 | return parent::isSupported() && $supported; |
| 33 | 35 | } |
| 34 | 36 | |
@@ -50,10 +52,11 @@ discard block |
||
| 50 | 52 | $key = $this->prefix . strtr($key, ':/', '-_'); |
| 51 | 53 | |
| 52 | 54 | // An extended key is needed to counteract a bug in APC. |
| 53 | - if ($value === null) |
|
| 54 | - return apcu_delete($key . 'smf'); |
|
| 55 | - else |
|
| 56 | - return apcu_store($key . 'smf', $value, $ttl); |
|
| 55 | + if ($value === null) { |
|
| 56 | + return apcu_delete($key . 'smf'); |
|
| 57 | + } else { |
|
| 58 | + return apcu_store($key . 'smf', $value, $ttl); |
|
| 59 | + } |
|
| 57 | 60 | } |
| 58 | 61 | |
| 59 | 62 | /** |
@@ -18,10 +18,10 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class Birthday_Notify_Background extends SMF_BackgroundTask |
| 20 | 20 | { |
| 21 | - /** |
|
| 22 | - * This executes the task. It loads up the birthdays, figures out the greeting, etc. |
|
| 23 | - * @return bool Always returns true |
|
| 24 | - */ |
|
| 21 | + /** |
|
| 22 | + * This executes the task. It loads up the birthdays, figures out the greeting, etc. |
|
| 23 | + * @return bool Always returns true |
|
| 24 | + */ |
|
| 25 | 25 | public function execute() |
| 26 | 26 | { |
| 27 | 27 | global $txt, $smcFunc, $txtBirthdayEmails, $modSettings, $sourcedir; |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * This function allows to move a topic, making sure to ask the moderator |
@@ -32,8 +33,9 @@ discard block |
||
| 32 | 33 | { |
| 33 | 34 | global $txt, $board, $topic, $user_info, $context, $language, $scripturl, $smcFunc, $modSettings, $sourcedir; |
| 34 | 35 | |
| 35 | - if (empty($topic)) |
|
| 36 | - fatal_lang_error('no_access', false); |
|
| 36 | + if (empty($topic)) { |
|
| 37 | + fatal_lang_error('no_access', false); |
|
| 38 | + } |
|
| 37 | 39 | |
| 38 | 40 | $request = $smcFunc['db_query']('', ' |
| 39 | 41 | SELECT t.id_member_started, ms.subject, t.approved |
@@ -49,8 +51,9 @@ discard block |
||
| 49 | 51 | $smcFunc['db_free_result']($request); |
| 50 | 52 | |
| 51 | 53 | // Can they see it - if not approved? |
| 52 | - if ($modSettings['postmod_active'] && !$context['is_approved']) |
|
| 53 | - isAllowedTo('approve_posts'); |
|
| 54 | + if ($modSettings['postmod_active'] && !$context['is_approved']) { |
|
| 55 | + isAllowedTo('approve_posts'); |
|
| 56 | + } |
|
| 54 | 57 | |
| 55 | 58 | // Permission check! |
| 56 | 59 | // @todo |
@@ -59,9 +62,9 @@ discard block |
||
| 59 | 62 | if ($id_member_started == $user_info['id']) |
| 60 | 63 | { |
| 61 | 64 | isAllowedTo('move_own'); |
| 65 | + } else { |
|
| 66 | + isAllowedTo('move_any'); |
|
| 62 | 67 | } |
| 63 | - else |
|
| 64 | - isAllowedTo('move_any'); |
|
| 65 | 68 | } |
| 66 | 69 | |
| 67 | 70 | $context['move_any'] = $user_info['is_admin'] || $modSettings['topic_move_any']; |
@@ -83,11 +86,13 @@ discard block |
||
| 83 | 86 | 'not_redirection' => true, |
| 84 | 87 | ); |
| 85 | 88 | |
| 86 | - if (!empty($_SESSION['move_to_topic']) && $_SESSION['move_to_topic'] != $board) |
|
| 87 | - $options['selected_board'] = $_SESSION['move_to_topic']; |
|
| 89 | + if (!empty($_SESSION['move_to_topic']) && $_SESSION['move_to_topic'] != $board) { |
|
| 90 | + $options['selected_board'] = $_SESSION['move_to_topic']; |
|
| 91 | + } |
|
| 88 | 92 | |
| 89 | - if (!$context['move_any']) |
|
| 90 | - $options['included_boards'] = $boards; |
|
| 93 | + if (!$context['move_any']) { |
|
| 94 | + $options['included_boards'] = $boards; |
|
| 95 | + } |
|
| 91 | 96 | |
| 92 | 97 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
| 93 | 98 | $context['categories'] = getBoardList($options); |
@@ -138,12 +143,14 @@ discard block |
||
| 138 | 143 | global $txt, $topic, $scripturl, $sourcedir, $context; |
| 139 | 144 | global $board, $language, $user_info, $smcFunc; |
| 140 | 145 | |
| 141 | - if (empty($topic)) |
|
| 142 | - fatal_lang_error('no_access', false); |
|
| 146 | + if (empty($topic)) { |
|
| 147 | + fatal_lang_error('no_access', false); |
|
| 148 | + } |
|
| 143 | 149 | |
| 144 | 150 | // You can't choose to have a redirection topic and use an empty reason. |
| 145 | - if (isset($_POST['postRedirect']) && (!isset($_POST['reason']) || trim($_POST['reason']) == '')) |
|
| 146 | - fatal_lang_error('movetopic_no_reason', false); |
|
| 151 | + if (isset($_POST['postRedirect']) && (!isset($_POST['reason']) || trim($_POST['reason']) == '')) { |
|
| 152 | + fatal_lang_error('movetopic_no_reason', false); |
|
| 153 | + } |
|
| 147 | 154 | |
| 148 | 155 | moveTopicConcurrence(); |
| 149 | 156 | |
@@ -163,16 +170,18 @@ discard block |
||
| 163 | 170 | $smcFunc['db_free_result']($request); |
| 164 | 171 | |
| 165 | 172 | // Can they see it? |
| 166 | - if (!$context['is_approved']) |
|
| 167 | - isAllowedTo('approve_posts'); |
|
| 173 | + if (!$context['is_approved']) { |
|
| 174 | + isAllowedTo('approve_posts'); |
|
| 175 | + } |
|
| 168 | 176 | |
| 169 | 177 | // Can they move topics on this board? |
| 170 | 178 | if (!allowedTo('move_any')) |
| 171 | 179 | { |
| 172 | - if ($id_member_started == $user_info['id']) |
|
| 173 | - isAllowedTo('move_own'); |
|
| 174 | - else |
|
| 175 | - isAllowedTo('move_any'); |
|
| 180 | + if ($id_member_started == $user_info['id']) { |
|
| 181 | + isAllowedTo('move_own'); |
|
| 182 | + } else { |
|
| 183 | + isAllowedTo('move_any'); |
|
| 184 | + } |
|
| 176 | 185 | } |
| 177 | 186 | |
| 178 | 187 | checkSession(); |
@@ -197,8 +206,9 @@ discard block |
||
| 197 | 206 | 'blank_redirect' => '', |
| 198 | 207 | ) |
| 199 | 208 | ); |
| 200 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 201 | - fatal_lang_error('no_board'); |
|
| 209 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 210 | + fatal_lang_error('no_board'); |
|
| 211 | + } |
|
| 202 | 212 | list ($pcounter, $board_name, $subject) = $smcFunc['db_fetch_row']($request); |
| 203 | 213 | $smcFunc['db_free_result']($request); |
| 204 | 214 | |
@@ -210,8 +220,9 @@ discard block |
||
| 210 | 220 | { |
| 211 | 221 | $_POST['custom_subject'] = strtr($smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['custom_subject'])), array("\r" => '', "\n" => '', "\t" => '')); |
| 212 | 222 | // Keep checking the length. |
| 213 | - if ($smcFunc['strlen']($_POST['custom_subject']) > 100) |
|
| 214 | - $_POST['custom_subject'] = $smcFunc['substr']($_POST['custom_subject'], 0, 100); |
|
| 223 | + if ($smcFunc['strlen']($_POST['custom_subject']) > 100) { |
|
| 224 | + $_POST['custom_subject'] = $smcFunc['substr']($_POST['custom_subject'], 0, 100); |
|
| 225 | + } |
|
| 215 | 226 | |
| 216 | 227 | // If it's still valid move onwards and upwards. |
| 217 | 228 | if ($_POST['custom_subject'] != '') |
@@ -221,9 +232,9 @@ discard block |
||
| 221 | 232 | // Get a response prefix, but in the forum's default language. |
| 222 | 233 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
| 223 | 234 | { |
| 224 | - if ($language === $user_info['language']) |
|
| 225 | - $context['response_prefix'] = $txt['response_prefix']; |
|
| 226 | - else |
|
| 235 | + if ($language === $user_info['language']) { |
|
| 236 | + $context['response_prefix'] = $txt['response_prefix']; |
|
| 237 | + } else |
|
| 227 | 238 | { |
| 228 | 239 | loadLanguage('index', $language, false); |
| 229 | 240 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -263,8 +274,9 @@ discard block |
||
| 263 | 274 | if (isset($_POST['postRedirect'])) |
| 264 | 275 | { |
| 265 | 276 | // Should be in the boardwide language. |
| 266 | - if ($user_info['language'] != $language) |
|
| 267 | - loadLanguage('index', $language); |
|
| 277 | + if ($user_info['language'] != $language) { |
|
| 278 | + loadLanguage('index', $language); |
|
| 279 | + } |
|
| 268 | 280 | |
| 269 | 281 | $_POST['reason'] = $smcFunc['htmlspecialchars']($_POST['reason'], ENT_QUOTES); |
| 270 | 282 | preparsecode($_POST['reason']); |
@@ -328,8 +340,9 @@ discard block |
||
| 328 | 340 | $posters = array(); |
| 329 | 341 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 330 | 342 | { |
| 331 | - if (!isset($posters[$row['id_member']])) |
|
| 332 | - $posters[$row['id_member']] = 0; |
|
| 343 | + if (!isset($posters[$row['id_member']])) { |
|
| 344 | + $posters[$row['id_member']] = 0; |
|
| 345 | + } |
|
| 333 | 346 | |
| 334 | 347 | $posters[$row['id_member']]++; |
| 335 | 348 | } |
@@ -338,11 +351,13 @@ discard block |
||
| 338 | 351 | foreach ($posters as $id_member => $posts) |
| 339 | 352 | { |
| 340 | 353 | // The board we're moving from counted posts, but not to. |
| 341 | - if (empty($pcounter_from)) |
|
| 342 | - updateMemberData($id_member, array('posts' => 'posts - ' . $posts)); |
|
| 354 | + if (empty($pcounter_from)) { |
|
| 355 | + updateMemberData($id_member, array('posts' => 'posts - ' . $posts)); |
|
| 356 | + } |
|
| 343 | 357 | // The reverse: from didn't, to did. |
| 344 | - else |
|
| 345 | - updateMemberData($id_member, array('posts' => 'posts + ' . $posts)); |
|
| 358 | + else { |
|
| 359 | + updateMemberData($id_member, array('posts' => 'posts + ' . $posts)); |
|
| 360 | + } |
|
| 346 | 361 | } |
| 347 | 362 | } |
| 348 | 363 | |
@@ -350,17 +365,19 @@ discard block |
||
| 350 | 365 | moveTopics($topic, $_POST['toboard']); |
| 351 | 366 | |
| 352 | 367 | // Log that they moved this topic. |
| 353 | - if (!allowedTo('move_own') || $id_member_started != $user_info['id']) |
|
| 354 | - logAction('move', array('topic' => $topic, 'board_from' => $board, 'board_to' => $_POST['toboard'])); |
|
| 368 | + if (!allowedTo('move_own') || $id_member_started != $user_info['id']) { |
|
| 369 | + logAction('move', array('topic' => $topic, 'board_from' => $board, 'board_to' => $_POST['toboard'])); |
|
| 370 | + } |
|
| 355 | 371 | // Notify people that this topic has been moved? |
| 356 | 372 | sendNotifications($topic, 'move'); |
| 357 | 373 | |
| 358 | 374 | // Why not go back to the original board in case they want to keep moving? |
| 359 | - if (!isset($_REQUEST['goback'])) |
|
| 360 | - redirectexit('board=' . $board . '.0'); |
|
| 361 | - else |
|
| 362 | - redirectexit('topic=' . $topic . '.0'); |
|
| 363 | -} |
|
| 375 | + if (!isset($_REQUEST['goback'])) { |
|
| 376 | + redirectexit('board=' . $board . '.0'); |
|
| 377 | + } else { |
|
| 378 | + redirectexit('topic=' . $topic . '.0'); |
|
| 379 | + } |
|
| 380 | + } |
|
| 364 | 381 | |
| 365 | 382 | /** |
| 366 | 383 | * Moves one or more topics to a specific board. (doesn't check permissions.) |
@@ -376,18 +393,21 @@ discard block |
||
| 376 | 393 | global $sourcedir, $user_info, $modSettings, $smcFunc; |
| 377 | 394 | |
| 378 | 395 | // Empty array? |
| 379 | - if (empty($topics)) |
|
| 380 | - return; |
|
| 396 | + if (empty($topics)) { |
|
| 397 | + return; |
|
| 398 | + } |
|
| 381 | 399 | |
| 382 | 400 | // Only a single topic. |
| 383 | - if (is_numeric($topics)) |
|
| 384 | - $topics = array($topics); |
|
| 401 | + if (is_numeric($topics)) { |
|
| 402 | + $topics = array($topics); |
|
| 403 | + } |
|
| 385 | 404 | |
| 386 | 405 | $fromBoards = array(); |
| 387 | 406 | |
| 388 | 407 | // Destination board empty or equal to 0? |
| 389 | - if (empty($toBoard)) |
|
| 390 | - return; |
|
| 408 | + if (empty($toBoard)) { |
|
| 409 | + return; |
|
| 410 | + } |
|
| 391 | 411 | |
| 392 | 412 | // Are we moving to the recycle board? |
| 393 | 413 | $isRecycleDest = !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] == $toBoard; |
@@ -395,8 +415,9 @@ discard block |
||
| 395 | 415 | // Callback for search APIs to do their thing |
| 396 | 416 | require_once($sourcedir . '/Search.php'); |
| 397 | 417 | $searchAPI = findSearchAPI(); |
| 398 | - if ($searchAPI->supportsMethod('topicsMoved')) |
|
| 399 | - $searchAPI->topicsMoved($topics, $toBoard); |
|
| 418 | + if ($searchAPI->supportsMethod('topicsMoved')) { |
|
| 419 | + $searchAPI->topicsMoved($topics, $toBoard); |
|
| 420 | + } |
|
| 400 | 421 | |
| 401 | 422 | // Determine the source boards... |
| 402 | 423 | $request = $smcFunc['db_query']('', ' |
@@ -410,8 +431,9 @@ discard block |
||
| 410 | 431 | ) |
| 411 | 432 | ); |
| 412 | 433 | // Num of rows = 0 -> no topics found. Num of rows > 1 -> topics are on multiple boards. |
| 413 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 414 | - return; |
|
| 434 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 435 | + return; |
|
| 436 | + } |
|
| 415 | 437 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 416 | 438 | { |
| 417 | 439 | if (!isset($fromBoards[$row['id_board']]['num_posts'])) |
@@ -429,10 +451,11 @@ discard block |
||
| 429 | 451 | $fromBoards[$row['id_board']]['unapproved_posts'] += $row['unapproved_posts']; |
| 430 | 452 | |
| 431 | 453 | // Add the topics to the right type. |
| 432 | - if ($row['approved']) |
|
| 433 | - $fromBoards[$row['id_board']]['num_topics'] += $row['num_topics']; |
|
| 434 | - else |
|
| 435 | - $fromBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics']; |
|
| 454 | + if ($row['approved']) { |
|
| 455 | + $fromBoards[$row['id_board']]['num_topics'] += $row['num_topics']; |
|
| 456 | + } else { |
|
| 457 | + $fromBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics']; |
|
| 458 | + } |
|
| 436 | 459 | } |
| 437 | 460 | $smcFunc['db_free_result']($request); |
| 438 | 461 | |
@@ -558,13 +581,14 @@ discard block |
||
| 558 | 581 | ) |
| 559 | 582 | ); |
| 560 | 583 | $approval_msgs = array(); |
| 561 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 562 | - $approval_msgs[] = $row['id_msg']; |
|
| 584 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 585 | + $approval_msgs[] = $row['id_msg']; |
|
| 586 | + } |
|
| 563 | 587 | $smcFunc['db_free_result']($request); |
| 564 | 588 | |
| 565 | 589 | // Empty the approval queue for these, as we're going to approve them next. |
| 566 | - if (!empty($approval_msgs)) |
|
| 567 | - $smcFunc['db_query']('', ' |
|
| 590 | + if (!empty($approval_msgs)) { |
|
| 591 | + $smcFunc['db_query']('', ' |
|
| 568 | 592 | DELETE FROM {db_prefix}approval_queue |
| 569 | 593 | WHERE id_msg IN ({array_int:message_list}) |
| 570 | 594 | AND id_attach = {int:id_attach}', |
@@ -573,6 +597,7 @@ discard block |
||
| 573 | 597 | 'id_attach' => 0, |
| 574 | 598 | ) |
| 575 | 599 | ); |
| 600 | + } |
|
| 576 | 601 | |
| 577 | 602 | // Get all the current max and mins. |
| 578 | 603 | $request = $smcFunc['db_query']('', ' |
@@ -606,8 +631,8 @@ discard block |
||
| 606 | 631 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 607 | 632 | { |
| 608 | 633 | // If not, update. |
| 609 | - if ($row['first_msg'] != $topicMaxMin[$row['id_topic']]['min'] || $row['last_msg'] != $topicMaxMin[$row['id_topic']]['max']) |
|
| 610 | - $smcFunc['db_query']('', ' |
|
| 634 | + if ($row['first_msg'] != $topicMaxMin[$row['id_topic']]['min'] || $row['last_msg'] != $topicMaxMin[$row['id_topic']]['max']) { |
|
| 635 | + $smcFunc['db_query']('', ' |
|
| 611 | 636 | UPDATE {db_prefix}topics |
| 612 | 637 | SET id_first_msg = {int:first_msg}, id_last_msg = {int:last_msg} |
| 613 | 638 | WHERE id_topic = {int:selected_topic}', |
@@ -617,6 +642,7 @@ discard block |
||
| 617 | 642 | 'selected_topic' => $row['id_topic'], |
| 618 | 643 | ) |
| 619 | 644 | ); |
| 645 | + } |
|
| 620 | 646 | } |
| 621 | 647 | $smcFunc['db_free_result']($request); |
| 622 | 648 | } |
@@ -675,9 +701,10 @@ discard block |
||
| 675 | 701 | } |
| 676 | 702 | |
| 677 | 703 | // Update the cache? |
| 678 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) |
|
| 679 | - foreach ($topics as $topic_id) |
|
| 704 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) { |
|
| 705 | + foreach ($topics as $topic_id) |
|
| 680 | 706 | cache_put_data('topic_board-' . $topic_id, null, 120); |
| 707 | + } |
|
| 681 | 708 | |
| 682 | 709 | require_once($sourcedir . '/Subs-Post.php'); |
| 683 | 710 | |
@@ -701,15 +728,17 @@ discard block |
||
| 701 | 728 | { |
| 702 | 729 | global $board, $topic, $smcFunc, $scripturl; |
| 703 | 730 | |
| 704 | - if (isset($_GET['current_board'])) |
|
| 705 | - $move_from = (int) $_GET['current_board']; |
|
| 731 | + if (isset($_GET['current_board'])) { |
|
| 732 | + $move_from = (int) $_GET['current_board']; |
|
| 733 | + } |
|
| 706 | 734 | |
| 707 | - if (empty($move_from) || empty($board) || empty($topic)) |
|
| 708 | - return true; |
|
| 735 | + if (empty($move_from) || empty($board) || empty($topic)) { |
|
| 736 | + return true; |
|
| 737 | + } |
|
| 709 | 738 | |
| 710 | - if ($move_from == $board) |
|
| 711 | - return true; |
|
| 712 | - else |
|
| 739 | + if ($move_from == $board) { |
|
| 740 | + return true; |
|
| 741 | + } else |
|
| 713 | 742 | { |
| 714 | 743 | $request = $smcFunc['db_query']('', ' |
| 715 | 744 | SELECT m.subject, b.name |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * 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'); |
@@ -207,8 +211,9 @@ discard block |
||
| 207 | 211 | foreach ($_POST['smiley_set'] as $id => $val) |
| 208 | 212 | { |
| 209 | 213 | // If this is the set you've marked as default, or the only one remaining, you can't delete it |
| 210 | - if ($modSettings['smiley_sets_default'] != $set_paths[$id] && count($set_paths) != 1 && isset($set_paths[$id], $set_names[$id])) |
|
| 211 | - unset($set_paths[$id], $set_names[$id]); |
|
| 214 | + if ($modSettings['smiley_sets_default'] != $set_paths[$id] && count($set_paths) != 1 && isset($set_paths[$id], $set_names[$id])) { |
|
| 215 | + unset($set_paths[$id], $set_names[$id]); |
|
| 216 | + } |
|
| 212 | 217 | } |
| 213 | 218 | |
| 214 | 219 | // Shortcut... array_merge() on a single array resets the numeric keys |
@@ -222,8 +227,9 @@ discard block |
||
| 222 | 227 | )); |
| 223 | 228 | } |
| 224 | 229 | // Add a new smiley set. |
| 225 | - elseif (!empty($_POST['add'])) |
|
| 226 | - $context['sub_action'] = 'modifyset'; |
|
| 230 | + elseif (!empty($_POST['add'])) { |
|
| 231 | + $context['sub_action'] = 'modifyset'; |
|
| 232 | + } |
|
| 227 | 233 | // Create or modify a smiley set. |
| 228 | 234 | elseif (isset($_POST['set'])) |
| 229 | 235 | { |
@@ -233,8 +239,9 @@ discard block |
||
| 233 | 239 | // Create a new smiley set. |
| 234 | 240 | if ($_POST['set'] == -1 && isset($_POST['smiley_sets_path'])) |
| 235 | 241 | { |
| 236 | - if (in_array($_POST['smiley_sets_path'], $set_paths)) |
|
| 237 | - fatal_lang_error('smiley_set_already_exists'); |
|
| 242 | + if (in_array($_POST['smiley_sets_path'], $set_paths)) { |
|
| 243 | + fatal_lang_error('smiley_set_already_exists'); |
|
| 244 | + } |
|
| 238 | 245 | |
| 239 | 246 | updateSettings(array( |
| 240 | 247 | 'smiley_sets_known' => $modSettings['smiley_sets_known'] . ',' . $_POST['smiley_sets_path'], |
@@ -246,12 +253,14 @@ discard block |
||
| 246 | 253 | else |
| 247 | 254 | { |
| 248 | 255 | // Make sure the smiley set exists. |
| 249 | - if (!isset($set_paths[$_POST['set']]) || !isset($set_names[$_POST['set']])) |
|
| 250 | - fatal_lang_error('smiley_set_not_found'); |
|
| 256 | + if (!isset($set_paths[$_POST['set']]) || !isset($set_names[$_POST['set']])) { |
|
| 257 | + fatal_lang_error('smiley_set_not_found'); |
|
| 258 | + } |
|
| 251 | 259 | |
| 252 | 260 | // Make sure the path is not yet used by another smileyset. |
| 253 | - if (in_array($_POST['smiley_sets_path'], $set_paths) && $_POST['smiley_sets_path'] != $set_paths[$_POST['set']]) |
|
| 254 | - fatal_lang_error('smiley_set_path_already_used'); |
|
| 261 | + if (in_array($_POST['smiley_sets_path'], $set_paths) && $_POST['smiley_sets_path'] != $set_paths[$_POST['set']]) { |
|
| 262 | + fatal_lang_error('smiley_set_path_already_used'); |
|
| 263 | + } |
|
| 255 | 264 | |
| 256 | 265 | $set_paths[$_POST['set']] = $_POST['smiley_sets_path']; |
| 257 | 266 | $set_names[$_POST['set']] = $_POST['smiley_sets_name']; |
@@ -263,8 +272,9 @@ discard block |
||
| 263 | 272 | } |
| 264 | 273 | |
| 265 | 274 | // The user might have checked to also import smileys. |
| 266 | - if (!empty($_POST['smiley_sets_import'])) |
|
| 267 | - ImportSmileys($_POST['smiley_sets_path']); |
|
| 275 | + if (!empty($_POST['smiley_sets_import'])) { |
|
| 276 | + ImportSmileys($_POST['smiley_sets_path']); |
|
| 277 | + } |
|
| 268 | 278 | } |
| 269 | 279 | cache_put_data('parsing_smileys', null, 480); |
| 270 | 280 | cache_put_data('posting_smileys', null, 480); |
@@ -273,13 +283,14 @@ discard block |
||
| 273 | 283 | // Load all available smileysets... |
| 274 | 284 | $context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']); |
| 275 | 285 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
| 276 | - foreach ($context['smiley_sets'] as $i => $set) |
|
| 277 | - $context['smiley_sets'][$i] = array( |
|
| 286 | + foreach ($context['smiley_sets'] as $i => $set) { |
|
| 287 | + $context['smiley_sets'][$i] = array( |
|
| 278 | 288 | 'id' => $i, |
| 279 | 289 | 'path' => $smcFunc['htmlspecialchars']($set), |
| 280 | 290 | 'name' => $smcFunc['htmlspecialchars']($set_names[$i]), |
| 281 | 291 | 'selected' => $set == $modSettings['smiley_sets_default'] |
| 282 | 292 | ); |
| 293 | + } |
|
| 283 | 294 | |
| 284 | 295 | // Importing any smileys from an existing set? |
| 285 | 296 | if ($context['sub_action'] == 'import') |
@@ -290,8 +301,9 @@ discard block |
||
| 290 | 301 | $_GET['set'] = (int) $_GET['set']; |
| 291 | 302 | |
| 292 | 303 | // Sanity check - then import. |
| 293 | - if (isset($context['smiley_sets'][$_GET['set']])) |
|
| 294 | - ImportSmileys(un_htmlspecialchars($context['smiley_sets'][$_GET['set']]['path'])); |
|
| 304 | + if (isset($context['smiley_sets'][$_GET['set']])) { |
|
| 305 | + ImportSmileys(un_htmlspecialchars($context['smiley_sets'][$_GET['set']]['path'])); |
|
| 306 | + } |
|
| 295 | 307 | |
| 296 | 308 | // Force the process to continue. |
| 297 | 309 | $context['sub_action'] = 'modifyset'; |
@@ -301,15 +313,15 @@ discard block |
||
| 301 | 313 | if ($context['sub_action'] == 'modifyset') |
| 302 | 314 | { |
| 303 | 315 | $_GET['set'] = !isset($_GET['set']) ? -1 : (int) $_GET['set']; |
| 304 | - if ($_GET['set'] == -1 || !isset($context['smiley_sets'][$_GET['set']])) |
|
| 305 | - $context['current_set'] = array( |
|
| 316 | + if ($_GET['set'] == -1 || !isset($context['smiley_sets'][$_GET['set']])) { |
|
| 317 | + $context['current_set'] = array( |
|
| 306 | 318 | 'id' => '-1', |
| 307 | 319 | 'path' => '', |
| 308 | 320 | 'name' => '', |
| 309 | 321 | 'selected' => false, |
| 310 | 322 | 'is_new' => true, |
| 311 | 323 | ); |
| 312 | - else |
|
| 324 | + } else |
|
| 313 | 325 | { |
| 314 | 326 | $context['current_set'] = &$context['smiley_sets'][$_GET['set']]; |
| 315 | 327 | $context['current_set']['is_new'] = false; |
@@ -321,13 +333,15 @@ discard block |
||
| 321 | 333 | $dir = dir($modSettings['smileys_dir'] . '/' . $context['current_set']['path']); |
| 322 | 334 | while ($entry = $dir->read()) |
| 323 | 335 | { |
| 324 | - if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) |
|
| 325 | - $smileys[strtolower($entry)] = $entry; |
|
| 336 | + if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) { |
|
| 337 | + $smileys[strtolower($entry)] = $entry; |
|
| 338 | + } |
|
| 326 | 339 | } |
| 327 | 340 | $dir->close(); |
| 328 | 341 | |
| 329 | - if (empty($smileys)) |
|
| 330 | - fatal_lang_error('smiley_set_dir_not_found', false, array($context['current_set']['name'])); |
|
| 342 | + if (empty($smileys)) { |
|
| 343 | + fatal_lang_error('smiley_set_dir_not_found', false, array($context['current_set']['name'])); |
|
| 344 | + } |
|
| 331 | 345 | |
| 332 | 346 | // Exclude the smileys that are already in the database. |
| 333 | 347 | $request = $smcFunc['db_query']('', ' |
@@ -338,9 +352,10 @@ discard block |
||
| 338 | 352 | 'smiley_list' => $smileys, |
| 339 | 353 | ) |
| 340 | 354 | ); |
| 341 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 342 | - if (isset($smileys[strtolower($row['filename'])])) |
|
| 355 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 356 | + if (isset($smileys[strtolower($row['filename'])])) |
|
| 343 | 357 | unset($smileys[strtolower($row['filename'])]); |
| 358 | + } |
|
| 344 | 359 | $smcFunc['db_free_result']($request); |
| 345 | 360 | |
| 346 | 361 | $context['current_set']['can_import'] = count($smileys); |
@@ -355,13 +370,14 @@ discard block |
||
| 355 | 370 | $dir = dir($modSettings['smileys_dir']); |
| 356 | 371 | while ($entry = $dir->read()) |
| 357 | 372 | { |
| 358 | - if (!in_array($entry, array('.', '..')) && is_dir($modSettings['smileys_dir'] . '/' . $entry)) |
|
| 359 | - $context['smiley_set_dirs'][] = array( |
|
| 373 | + if (!in_array($entry, array('.', '..')) && is_dir($modSettings['smileys_dir'] . '/' . $entry)) { |
|
| 374 | + $context['smiley_set_dirs'][] = array( |
|
| 360 | 375 | 'id' => $entry, |
| 361 | 376 | 'path' => $modSettings['smileys_dir'] . '/' . $entry, |
| 362 | 377 | 'selectable' => $entry == $context['current_set']['path'] || !in_array($entry, explode(',', $modSettings['smiley_sets_known'])), |
| 363 | 378 | 'current' => $entry == $context['current_set']['path'], |
| 364 | 379 | ); |
| 380 | + } |
|
| 365 | 381 | } |
| 366 | 382 | $dir->close(); |
| 367 | 383 | } |
@@ -371,8 +387,9 @@ discard block |
||
| 371 | 387 | createToken('admin-mss', 'request'); |
| 372 | 388 | |
| 373 | 389 | // In case we need to import smileys, we need to add the token in now. |
| 374 | - if (isset($context['current_set']['import_url'])) |
|
| 375 | - $context['current_set']['import_url'] .= ';' . $context['admin-mss_token_var'] . '=' . $context['admin-mss_token']; |
|
| 390 | + if (isset($context['current_set']['import_url'])) { |
|
| 391 | + $context['current_set']['import_url'] .= ';' . $context['admin-mss_token_var'] . '=' . $context['admin-mss_token']; |
|
| 392 | + } |
|
| 376 | 393 | |
| 377 | 394 | $listOptions = array( |
| 378 | 395 | 'id' => 'smiley_set_list', |
@@ -510,21 +527,23 @@ discard block |
||
| 510 | 527 | $cols['name'][] = $set_names[$i]; |
| 511 | 528 | } |
| 512 | 529 | $sort_flag = strpos($sort, 'DESC') === false ? SORT_ASC : SORT_DESC; |
| 513 | - if (substr($sort, 0, 4) === 'name') |
|
| 514 | - array_multisort($cols['name'], $sort_flag, SORT_REGULAR, $cols['path'], $cols['selected'], $cols['id']); |
|
| 515 | - elseif (substr($sort, 0, 4) === 'path') |
|
| 516 | - array_multisort($cols['path'], $sort_flag, SORT_REGULAR, $cols['name'], $cols['selected'], $cols['id']); |
|
| 517 | - else |
|
| 518 | - array_multisort($cols['selected'], $sort_flag, SORT_REGULAR, $cols['path'], $cols['name'], $cols['id']); |
|
| 530 | + if (substr($sort, 0, 4) === 'name') { |
|
| 531 | + array_multisort($cols['name'], $sort_flag, SORT_REGULAR, $cols['path'], $cols['selected'], $cols['id']); |
|
| 532 | + } elseif (substr($sort, 0, 4) === 'path') { |
|
| 533 | + array_multisort($cols['path'], $sort_flag, SORT_REGULAR, $cols['name'], $cols['selected'], $cols['id']); |
|
| 534 | + } else { |
|
| 535 | + array_multisort($cols['selected'], $sort_flag, SORT_REGULAR, $cols['path'], $cols['name'], $cols['id']); |
|
| 536 | + } |
|
| 519 | 537 | |
| 520 | 538 | $smiley_sets = array(); |
| 521 | - foreach ($cols['id'] as $i => $id) |
|
| 522 | - $smiley_sets[] = array( |
|
| 539 | + foreach ($cols['id'] as $i => $id) { |
|
| 540 | + $smiley_sets[] = array( |
|
| 523 | 541 | 'id' => $id, |
| 524 | 542 | 'path' => $cols['path'][$i], |
| 525 | 543 | 'name' => $cols['name'][$i], |
| 526 | 544 | 'selected' => $cols['path'][$i] == $modSettings['smiley_sets_default'] |
| 527 | 545 | ); |
| 546 | + } |
|
| 528 | 547 | |
| 529 | 548 | return $smiley_sets; |
| 530 | 549 | } |
@@ -553,13 +572,14 @@ discard block |
||
| 553 | 572 | $context['smileys_dir_found'] = is_dir($context['smileys_dir']); |
| 554 | 573 | $context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']); |
| 555 | 574 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
| 556 | - foreach ($context['smiley_sets'] as $i => $set) |
|
| 557 | - $context['smiley_sets'][$i] = array( |
|
| 575 | + foreach ($context['smiley_sets'] as $i => $set) { |
|
| 576 | + $context['smiley_sets'][$i] = array( |
|
| 558 | 577 | 'id' => $i, |
| 559 | 578 | 'path' => $smcFunc['htmlspecialchars']($set), |
| 560 | 579 | 'name' => $smcFunc['htmlspecialchars']($set_names[$i]), |
| 561 | 580 | 'selected' => $set == $modSettings['smiley_sets_default'] |
| 562 | 581 | ); |
| 582 | + } |
|
| 563 | 583 | |
| 564 | 584 | // Submitting a form? |
| 565 | 585 | if (isset($_POST[$context['session_var']], $_POST['smiley_code'])) |
@@ -575,8 +595,9 @@ discard block |
||
| 575 | 595 | $_POST['smiley_filename'] = htmltrim__recursive($_POST['smiley_filename']); |
| 576 | 596 | |
| 577 | 597 | // Make sure some code was entered. |
| 578 | - if (empty($_POST['smiley_code'])) |
|
| 579 | - fatal_lang_error('smiley_has_no_code'); |
|
| 598 | + if (empty($_POST['smiley_code'])) { |
|
| 599 | + fatal_lang_error('smiley_has_no_code'); |
|
| 600 | + } |
|
| 580 | 601 | |
| 581 | 602 | // Check whether the new code has duplicates. It should be unique. |
| 582 | 603 | $request = $smcFunc['db_query']('', ' |
@@ -588,8 +609,9 @@ discard block |
||
| 588 | 609 | 'smiley_code' => $_POST['smiley_code'], |
| 589 | 610 | ) |
| 590 | 611 | ); |
| 591 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
| 592 | - fatal_lang_error('smiley_not_unique'); |
|
| 612 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
| 613 | + fatal_lang_error('smiley_not_unique'); |
|
| 614 | + } |
|
| 593 | 615 | $smcFunc['db_free_result']($request); |
| 594 | 616 | |
| 595 | 617 | // If we are uploading - check all the smiley sets are writable! |
@@ -598,38 +620,44 @@ discard block |
||
| 598 | 620 | $writeErrors = array(); |
| 599 | 621 | foreach ($context['smiley_sets'] as $set) |
| 600 | 622 | { |
| 601 | - if (!is_writable($context['smileys_dir'] . '/' . un_htmlspecialchars($set['path']))) |
|
| 602 | - $writeErrors[] = $set['path']; |
|
| 623 | + if (!is_writable($context['smileys_dir'] . '/' . un_htmlspecialchars($set['path']))) { |
|
| 624 | + $writeErrors[] = $set['path']; |
|
| 625 | + } |
|
| 626 | + } |
|
| 627 | + if (!empty($writeErrors)) { |
|
| 628 | + fatal_lang_error('smileys_upload_error_notwritable', true, array(implode(', ', $writeErrors))); |
|
| 603 | 629 | } |
| 604 | - if (!empty($writeErrors)) |
|
| 605 | - fatal_lang_error('smileys_upload_error_notwritable', true, array(implode(', ', $writeErrors))); |
|
| 606 | 630 | } |
| 607 | 631 | |
| 608 | 632 | // Uploading just one smiley for all of them? |
| 609 | 633 | if (isset($_POST['sameall']) && isset($_FILES['uploadSmiley']['name']) && $_FILES['uploadSmiley']['name'] != '') |
| 610 | 634 | { |
| 611 | - if (!is_uploaded_file($_FILES['uploadSmiley']['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['uploadSmiley']['tmp_name']))) |
|
| 612 | - fatal_lang_error('smileys_upload_error'); |
|
| 635 | + if (!is_uploaded_file($_FILES['uploadSmiley']['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['uploadSmiley']['tmp_name']))) { |
|
| 636 | + fatal_lang_error('smileys_upload_error'); |
|
| 637 | + } |
|
| 613 | 638 | |
| 614 | 639 | // Sorry, no spaces, dots, or anything else but letters allowed. |
| 615 | 640 | $_FILES['uploadSmiley']['name'] = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $_FILES['uploadSmiley']['name']); |
| 616 | 641 | |
| 617 | 642 | // We only allow image files - it's THAT simple - no messing around here... |
| 618 | - if (!in_array(strtolower(substr(strrchr($_FILES['uploadSmiley']['name'], '.'), 1)), $allowedTypes)) |
|
| 619 | - fatal_lang_error('smileys_upload_error_types', false, array(implode(', ', $allowedTypes))); |
|
| 643 | + if (!in_array(strtolower(substr(strrchr($_FILES['uploadSmiley']['name'], '.'), 1)), $allowedTypes)) { |
|
| 644 | + fatal_lang_error('smileys_upload_error_types', false, array(implode(', ', $allowedTypes))); |
|
| 645 | + } |
|
| 620 | 646 | |
| 621 | 647 | // We only need the filename... |
| 622 | 648 | $destName = basename($_FILES['uploadSmiley']['name']); |
| 623 | 649 | |
| 624 | 650 | // Make sure they aren't trying to upload a nasty file - for their own good here! |
| 625 | - if (in_array(strtolower($destName), $disabledFiles)) |
|
| 626 | - fatal_lang_error('smileys_upload_error_illegal'); |
|
| 651 | + if (in_array(strtolower($destName), $disabledFiles)) { |
|
| 652 | + fatal_lang_error('smileys_upload_error_illegal'); |
|
| 653 | + } |
|
| 627 | 654 | |
| 628 | 655 | // Check if the file already exists... and if not move it to EVERY smiley set directory. |
| 629 | 656 | $i = 0; |
| 630 | 657 | // Keep going until we find a set the file doesn't exist in. (or maybe it exists in all of them?) |
| 631 | - while (isset($context['smiley_sets'][$i]) && file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($context['smiley_sets'][$i]['path']) . '/' . $destName)) |
|
| 632 | - $i++; |
|
| 658 | + while (isset($context['smiley_sets'][$i]) && file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($context['smiley_sets'][$i]['path']) . '/' . $destName)) { |
|
| 659 | + $i++; |
|
| 660 | + } |
|
| 633 | 661 | |
| 634 | 662 | // Okay, we're going to put the smiley right here, since it's not there yet! |
| 635 | 663 | if (isset($context['smiley_sets'][$i]['path'])) |
@@ -644,8 +672,9 @@ discard block |
||
| 644 | 672 | $currentPath = $context['smileys_dir'] . '/' . un_htmlspecialchars($context['smiley_sets'][$i]['path']) . '/' . $destName; |
| 645 | 673 | |
| 646 | 674 | // The file is already there! Don't overwrite it! |
| 647 | - if (file_exists($currentPath)) |
|
| 648 | - continue; |
|
| 675 | + if (file_exists($currentPath)) { |
|
| 676 | + continue; |
|
| 677 | + } |
|
| 649 | 678 | |
| 650 | 679 | // Okay, so copy the first one we made to here. |
| 651 | 680 | copy($smileyLocation, $currentPath); |
@@ -662,13 +691,15 @@ discard block |
||
| 662 | 691 | $newName = ''; |
| 663 | 692 | foreach ($_FILES as $name => $data) |
| 664 | 693 | { |
| 665 | - if ($_FILES[$name]['name'] == '') |
|
| 666 | - fatal_lang_error('smileys_upload_error_blank'); |
|
| 694 | + if ($_FILES[$name]['name'] == '') { |
|
| 695 | + fatal_lang_error('smileys_upload_error_blank'); |
|
| 696 | + } |
|
| 667 | 697 | |
| 668 | - if (empty($newName)) |
|
| 669 | - $newName = basename($_FILES[$name]['name']); |
|
| 670 | - elseif (basename($_FILES[$name]['name']) != $newName) |
|
| 671 | - fatal_lang_error('smileys_upload_error_name'); |
|
| 698 | + if (empty($newName)) { |
|
| 699 | + $newName = basename($_FILES[$name]['name']); |
|
| 700 | + } elseif (basename($_FILES[$name]['name']) != $newName) { |
|
| 701 | + fatal_lang_error('smileys_upload_error_name'); |
|
| 702 | + } |
|
| 672 | 703 | } |
| 673 | 704 | |
| 674 | 705 | foreach ($context['smiley_sets'] as $i => $set) |
@@ -676,31 +707,36 @@ discard block |
||
| 676 | 707 | $set['name'] = un_htmlspecialchars($set['name']); |
| 677 | 708 | $set['path'] = un_htmlspecialchars($set['path']); |
| 678 | 709 | |
| 679 | - if (!isset($_FILES['individual_' . $set['name']]['name']) || $_FILES['individual_' . $set['name']]['name'] == '') |
|
| 680 | - continue; |
|
| 710 | + if (!isset($_FILES['individual_' . $set['name']]['name']) || $_FILES['individual_' . $set['name']]['name'] == '') { |
|
| 711 | + continue; |
|
| 712 | + } |
|
| 681 | 713 | |
| 682 | 714 | // Got one... |
| 683 | - if (!is_uploaded_file($_FILES['individual_' . $set['name']]['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['individual_' . $set['name']]['tmp_name']))) |
|
| 684 | - fatal_lang_error('smileys_upload_error'); |
|
| 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'); |
|
| 717 | + } |
|
| 685 | 718 | |
| 686 | 719 | // Sorry, no spaces, dots, or anything else but letters allowed. |
| 687 | 720 | $_FILES['individual_' . $set['name']]['name'] = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $_FILES['individual_' . $set['name']]['name']); |
| 688 | 721 | |
| 689 | 722 | // We only allow image files - it's THAT simple - no messing around here... |
| 690 | - if (!in_array(strtolower(substr(strrchr($_FILES['individual_' . $set['name']]['name'], '.'), 1)), $allowedTypes)) |
|
| 691 | - fatal_lang_error('smileys_upload_error_types', false, array(implode(', ', $allowedTypes))); |
|
| 723 | + if (!in_array(strtolower(substr(strrchr($_FILES['individual_' . $set['name']]['name'], '.'), 1)), $allowedTypes)) { |
|
| 724 | + fatal_lang_error('smileys_upload_error_types', false, array(implode(', ', $allowedTypes))); |
|
| 725 | + } |
|
| 692 | 726 | |
| 693 | 727 | // We only need the filename... |
| 694 | 728 | $destName = basename($_FILES['individual_' . $set['name']]['name']); |
| 695 | 729 | |
| 696 | 730 | // Make sure they aren't trying to upload a nasty file - for their own good here! |
| 697 | - if (in_array(strtolower($destName), $disabledFiles)) |
|
| 698 | - fatal_lang_error('smileys_upload_error_illegal'); |
|
| 731 | + if (in_array(strtolower($destName), $disabledFiles)) { |
|
| 732 | + fatal_lang_error('smileys_upload_error_illegal'); |
|
| 733 | + } |
|
| 699 | 734 | |
| 700 | 735 | // If the file exists - ignore it. |
| 701 | 736 | $smileyLocation = $context['smileys_dir'] . '/' . $set['path'] . '/' . $destName; |
| 702 | - if (file_exists($smileyLocation)) |
|
| 703 | - continue; |
|
| 737 | + if (file_exists($smileyLocation)) { |
|
| 738 | + continue; |
|
| 739 | + } |
|
| 704 | 740 | |
| 705 | 741 | // Finally - move the image! |
| 706 | 742 | move_uploaded_file($_FILES['individual_' . $set['name']]['tmp_name'], $smileyLocation); |
@@ -712,8 +748,9 @@ discard block |
||
| 712 | 748 | } |
| 713 | 749 | |
| 714 | 750 | // Also make sure a filename was given. |
| 715 | - if (empty($_POST['smiley_filename'])) |
|
| 716 | - fatal_lang_error('smiley_has_no_filename'); |
|
| 751 | + if (empty($_POST['smiley_filename'])) { |
|
| 752 | + fatal_lang_error('smiley_has_no_filename'); |
|
| 753 | + } |
|
| 717 | 754 | |
| 718 | 755 | // Find the position on the right. |
| 719 | 756 | $smiley_order = '0'; |
@@ -732,8 +769,9 @@ discard block |
||
| 732 | 769 | list ($smiley_order) = $smcFunc['db_fetch_row']($request); |
| 733 | 770 | $smcFunc['db_free_result']($request); |
| 734 | 771 | |
| 735 | - if (empty($smiley_order)) |
|
| 736 | - $smiley_order = '0'; |
|
| 772 | + if (empty($smiley_order)) { |
|
| 773 | + $smiley_order = '0'; |
|
| 774 | + } |
|
| 737 | 775 | } |
| 738 | 776 | $smcFunc['db_insert']('', |
| 739 | 777 | '{db_prefix}smileys', |
@@ -761,17 +799,19 @@ discard block |
||
| 761 | 799 | { |
| 762 | 800 | foreach ($context['smiley_sets'] as $smiley_set) |
| 763 | 801 | { |
| 764 | - if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']))) |
|
| 765 | - continue; |
|
| 802 | + if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']))) { |
|
| 803 | + continue; |
|
| 804 | + } |
|
| 766 | 805 | |
| 767 | 806 | $dir = dir($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path'])); |
| 768 | 807 | while ($entry = $dir->read()) |
| 769 | 808 | { |
| 770 | - if (!in_array($entry, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) |
|
| 771 | - $context['filenames'][strtolower($entry)] = array( |
|
| 809 | + if (!in_array($entry, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) { |
|
| 810 | + $context['filenames'][strtolower($entry)] = array( |
|
| 772 | 811 | 'id' => $smcFunc['htmlspecialchars']($entry), |
| 773 | 812 | 'selected' => false, |
| 774 | 813 | ); |
| 814 | + } |
|
| 775 | 815 | } |
| 776 | 816 | $dir->close(); |
| 777 | 817 | } |
@@ -809,17 +849,19 @@ discard block |
||
| 809 | 849 | // Changing the selected smileys? |
| 810 | 850 | if (isset($_POST['smiley_action']) && !empty($_POST['checked_smileys'])) |
| 811 | 851 | { |
| 812 | - foreach ($_POST['checked_smileys'] as $id => $smiley_id) |
|
| 813 | - $_POST['checked_smileys'][$id] = (int) $smiley_id; |
|
| 852 | + foreach ($_POST['checked_smileys'] as $id => $smiley_id) { |
|
| 853 | + $_POST['checked_smileys'][$id] = (int) $smiley_id; |
|
| 854 | + } |
|
| 814 | 855 | |
| 815 | - if ($_POST['smiley_action'] == 'delete') |
|
| 816 | - $smcFunc['db_query']('', ' |
|
| 856 | + if ($_POST['smiley_action'] == 'delete') { |
|
| 857 | + $smcFunc['db_query']('', ' |
|
| 817 | 858 | DELETE FROM {db_prefix}smileys |
| 818 | 859 | WHERE id_smiley IN ({array_int:checked_smileys})', |
| 819 | 860 | array( |
| 820 | 861 | 'checked_smileys' => $_POST['checked_smileys'], |
| 821 | 862 | ) |
| 822 | 863 | ); |
| 864 | + } |
|
| 823 | 865 | // Changing the status of the smiley? |
| 824 | 866 | else |
| 825 | 867 | { |
@@ -829,8 +871,8 @@ discard block |
||
| 829 | 871 | 'hidden' => 1, |
| 830 | 872 | 'popup' => 2 |
| 831 | 873 | ); |
| 832 | - if (isset($displayTypes[$_POST['smiley_action']])) |
|
| 833 | - $smcFunc['db_query']('', ' |
|
| 874 | + if (isset($displayTypes[$_POST['smiley_action']])) { |
|
| 875 | + $smcFunc['db_query']('', ' |
|
| 834 | 876 | UPDATE {db_prefix}smileys |
| 835 | 877 | SET hidden = {int:display_type} |
| 836 | 878 | WHERE id_smiley IN ({array_int:checked_smileys})', |
@@ -839,6 +881,7 @@ discard block |
||
| 839 | 881 | 'display_type' => $displayTypes[$_POST['smiley_action']], |
| 840 | 882 | ) |
| 841 | 883 | ); |
| 884 | + } |
|
| 842 | 885 | } |
| 843 | 886 | } |
| 844 | 887 | // Create/modify a smiley. |
@@ -864,12 +907,14 @@ discard block |
||
| 864 | 907 | $_POST['smiley_location'] = empty($_POST['smiley_location']) || $_POST['smiley_location'] > 2 || $_POST['smiley_location'] < 0 ? 0 : (int) $_POST['smiley_location']; |
| 865 | 908 | |
| 866 | 909 | // Make sure some code was entered. |
| 867 | - if (empty($_POST['smiley_code'])) |
|
| 868 | - fatal_lang_error('smiley_has_no_code'); |
|
| 910 | + if (empty($_POST['smiley_code'])) { |
|
| 911 | + fatal_lang_error('smiley_has_no_code'); |
|
| 912 | + } |
|
| 869 | 913 | |
| 870 | 914 | // Also make sure a filename was given. |
| 871 | - if (empty($_POST['smiley_filename'])) |
|
| 872 | - fatal_lang_error('smiley_has_no_filename'); |
|
| 915 | + if (empty($_POST['smiley_filename'])) { |
|
| 916 | + fatal_lang_error('smiley_has_no_filename'); |
|
| 917 | + } |
|
| 873 | 918 | |
| 874 | 919 | // Check whether the new code has duplicates. It should be unique. |
| 875 | 920 | $request = $smcFunc['db_query']('', ' |
@@ -883,8 +928,9 @@ discard block |
||
| 883 | 928 | 'smiley_code' => $_POST['smiley_code'], |
| 884 | 929 | ) |
| 885 | 930 | ); |
| 886 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
| 887 | - fatal_lang_error('smiley_not_unique'); |
|
| 931 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
| 932 | + fatal_lang_error('smiley_not_unique'); |
|
| 933 | + } |
|
| 888 | 934 | $smcFunc['db_free_result']($request); |
| 889 | 935 | |
| 890 | 936 | $smcFunc['db_query']('', ' |
@@ -913,13 +959,14 @@ discard block |
||
| 913 | 959 | // Load all known smiley sets. |
| 914 | 960 | $context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']); |
| 915 | 961 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
| 916 | - foreach ($context['smiley_sets'] as $i => $set) |
|
| 917 | - $context['smiley_sets'][$i] = array( |
|
| 962 | + foreach ($context['smiley_sets'] as $i => $set) { |
|
| 963 | + $context['smiley_sets'][$i] = array( |
|
| 918 | 964 | 'id' => $i, |
| 919 | 965 | 'path' => $smcFunc['htmlspecialchars']($set), |
| 920 | 966 | 'name' => $smcFunc['htmlspecialchars']($set_names[$i]), |
| 921 | 967 | 'selected' => $set == $modSettings['smiley_sets_default'] |
| 922 | 968 | ); |
| 969 | + } |
|
| 923 | 970 | |
| 924 | 971 | // Prepare overview of all (custom) smileys. |
| 925 | 972 | if ($context['sub_action'] == 'editsmileys') |
@@ -935,9 +982,10 @@ discard block |
||
| 935 | 982 | // Create a list of options for selecting smiley sets. |
| 936 | 983 | $smileyset_option_list = ' |
| 937 | 984 | <select name="set" onchange="changeSet(this.options[this.selectedIndex].value);">'; |
| 938 | - foreach ($context['smiley_sets'] as $smiley_set) |
|
| 939 | - $smileyset_option_list .= ' |
|
| 985 | + foreach ($context['smiley_sets'] as $smiley_set) { |
|
| 986 | + $smileyset_option_list .= ' |
|
| 940 | 987 | <option value="' . $smiley_set['path'] . '"' . ($modSettings['smiley_sets_default'] == $smiley_set['path'] ? ' selected' : '') . '>' . $smiley_set['name'] . '</option>'; |
| 988 | + } |
|
| 941 | 989 | $smileyset_option_list .= ' |
| 942 | 990 | </select>'; |
| 943 | 991 | |
@@ -999,12 +1047,13 @@ discard block |
||
| 999 | 1047 | 'data' => array( |
| 1000 | 1048 | 'function' => function ($rowData) use ($txt) |
| 1001 | 1049 | { |
| 1002 | - if (empty($rowData['hidden'])) |
|
| 1003 | - return $txt['smileys_location_form']; |
|
| 1004 | - elseif ($rowData['hidden'] == 1) |
|
| 1005 | - return $txt['smileys_location_hidden']; |
|
| 1006 | - else |
|
| 1007 | - return $txt['smileys_location_popup']; |
|
| 1050 | + if (empty($rowData['hidden'])) { |
|
| 1051 | + return $txt['smileys_location_form']; |
|
| 1052 | + } elseif ($rowData['hidden'] == 1) { |
|
| 1053 | + return $txt['smileys_location_hidden']; |
|
| 1054 | + } else { |
|
| 1055 | + return $txt['smileys_location_popup']; |
|
| 1056 | + } |
|
| 1008 | 1057 | }, |
| 1009 | 1058 | ), |
| 1010 | 1059 | 'sort' => array( |
@@ -1019,19 +1068,22 @@ discard block |
||
| 1019 | 1068 | 'data' => array( |
| 1020 | 1069 | 'function' => function ($rowData) use ($context, $txt, $modSettings, $smcFunc) |
| 1021 | 1070 | { |
| 1022 | - if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'])) |
|
| 1023 | - return $smcFunc['htmlspecialchars']($rowData['description']); |
|
| 1071 | + if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'])) { |
|
| 1072 | + return $smcFunc['htmlspecialchars']($rowData['description']); |
|
| 1073 | + } |
|
| 1024 | 1074 | |
| 1025 | 1075 | // Check if there are smileys missing in some sets. |
| 1026 | 1076 | $missing_sets = array(); |
| 1027 | - foreach ($context['smiley_sets'] as $smiley_set) |
|
| 1028 | - if (!file_exists(sprintf('%1$s/%2$s/%3$s', $modSettings['smileys_dir'], $smiley_set['path'], $rowData['filename']))) |
|
| 1077 | + foreach ($context['smiley_sets'] as $smiley_set) { |
|
| 1078 | + if (!file_exists(sprintf('%1$s/%2$s/%3$s', $modSettings['smileys_dir'], $smiley_set['path'], $rowData['filename']))) |
|
| 1029 | 1079 | $missing_sets[] = $smiley_set['path']; |
| 1080 | + } |
|
| 1030 | 1081 | |
| 1031 | 1082 | $description = $smcFunc['htmlspecialchars']($rowData['description']); |
| 1032 | 1083 | |
| 1033 | - if (!empty($missing_sets)) |
|
| 1034 | - $description .= sprintf('<br><span class="smalltext"><strong>%1$s:</strong> %2$s</span>', $txt['smileys_not_found_in_set'], implode(', ', $missing_sets)); |
|
| 1084 | + if (!empty($missing_sets)) { |
|
| 1085 | + $description .= sprintf('<br><span class="smalltext"><strong>%1$s:</strong> %2$s</span>', $txt['smileys_not_found_in_set'], implode(', ', $missing_sets)); |
|
| 1086 | + } |
|
| 1035 | 1087 | |
| 1036 | 1088 | return $description; |
| 1037 | 1089 | }, |
@@ -1147,13 +1199,14 @@ discard block |
||
| 1147 | 1199 | $context['smileys_dir_found'] = is_dir($context['smileys_dir']); |
| 1148 | 1200 | $context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']); |
| 1149 | 1201 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
| 1150 | - foreach ($context['smiley_sets'] as $i => $set) |
|
| 1151 | - $context['smiley_sets'][$i] = array( |
|
| 1202 | + foreach ($context['smiley_sets'] as $i => $set) { |
|
| 1203 | + $context['smiley_sets'][$i] = array( |
|
| 1152 | 1204 | 'id' => $i, |
| 1153 | 1205 | 'path' => $smcFunc['htmlspecialchars']($set), |
| 1154 | 1206 | 'name' => $smcFunc['htmlspecialchars']($set_names[$i]), |
| 1155 | 1207 | 'selected' => $set == $modSettings['smiley_sets_default'] |
| 1156 | 1208 | ); |
| 1209 | + } |
|
| 1157 | 1210 | |
| 1158 | 1211 | $context['selected_set'] = $modSettings['smiley_sets_default']; |
| 1159 | 1212 | |
@@ -1163,17 +1216,19 @@ discard block |
||
| 1163 | 1216 | { |
| 1164 | 1217 | foreach ($context['smiley_sets'] as $smiley_set) |
| 1165 | 1218 | { |
| 1166 | - if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']))) |
|
| 1167 | - continue; |
|
| 1219 | + if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']))) { |
|
| 1220 | + continue; |
|
| 1221 | + } |
|
| 1168 | 1222 | |
| 1169 | 1223 | $dir = dir($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path'])); |
| 1170 | 1224 | while ($entry = $dir->read()) |
| 1171 | 1225 | { |
| 1172 | - if (!in_array($entry, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) |
|
| 1173 | - $context['filenames'][strtolower($entry)] = array( |
|
| 1226 | + if (!in_array($entry, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) { |
|
| 1227 | + $context['filenames'][strtolower($entry)] = array( |
|
| 1174 | 1228 | 'id' => $smcFunc['htmlspecialchars']($entry), |
| 1175 | 1229 | 'selected' => false, |
| 1176 | 1230 | ); |
| 1231 | + } |
|
| 1177 | 1232 | } |
| 1178 | 1233 | $dir->close(); |
| 1179 | 1234 | } |
@@ -1188,8 +1243,9 @@ discard block |
||
| 1188 | 1243 | 'current_smiley' => (int) $_REQUEST['smiley'], |
| 1189 | 1244 | ) |
| 1190 | 1245 | ); |
| 1191 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
| 1192 | - fatal_lang_error('smiley_not_found'); |
|
| 1246 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
| 1247 | + fatal_lang_error('smiley_not_found'); |
|
| 1248 | + } |
|
| 1193 | 1249 | $context['current_smiley'] = $smcFunc['db_fetch_assoc']($request); |
| 1194 | 1250 | $smcFunc['db_free_result']($request); |
| 1195 | 1251 | |
@@ -1197,8 +1253,9 @@ discard block |
||
| 1197 | 1253 | $context['current_smiley']['filename'] = $smcFunc['htmlspecialchars']($context['current_smiley']['filename']); |
| 1198 | 1254 | $context['current_smiley']['description'] = $smcFunc['htmlspecialchars']($context['current_smiley']['description']); |
| 1199 | 1255 | |
| 1200 | - if (isset($context['filenames'][strtolower($context['current_smiley']['filename'])])) |
|
| 1201 | - $context['filenames'][strtolower($context['current_smiley']['filename'])]['selected'] = true; |
|
| 1256 | + if (isset($context['filenames'][strtolower($context['current_smiley']['filename'])])) { |
|
| 1257 | + $context['filenames'][strtolower($context['current_smiley']['filename'])]['selected'] = true; |
|
| 1258 | + } |
|
| 1202 | 1259 | } |
| 1203 | 1260 | } |
| 1204 | 1261 | |
@@ -1223,8 +1280,9 @@ discard block |
||
| 1223 | 1280 | ) |
| 1224 | 1281 | ); |
| 1225 | 1282 | $smileys = array(); |
| 1226 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1227 | - $smileys[] = $row; |
|
| 1283 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1284 | + $smileys[] = $row; |
|
| 1285 | + } |
|
| 1228 | 1286 | $smcFunc['db_free_result']($request); |
| 1229 | 1287 | |
| 1230 | 1288 | return $smileys; |
@@ -1264,8 +1322,9 @@ discard block |
||
| 1264 | 1322 | $_GET['location'] = empty($_GET['location']) || $_GET['location'] != 'popup' ? 0 : 2; |
| 1265 | 1323 | $_GET['source'] = empty($_GET['source']) ? 0 : (int) $_GET['source']; |
| 1266 | 1324 | |
| 1267 | - if (empty($_GET['source'])) |
|
| 1268 | - fatal_lang_error('smiley_not_found'); |
|
| 1325 | + if (empty($_GET['source'])) { |
|
| 1326 | + fatal_lang_error('smiley_not_found'); |
|
| 1327 | + } |
|
| 1269 | 1328 | |
| 1270 | 1329 | if (!empty($_GET['after'])) |
| 1271 | 1330 | { |
@@ -1281,12 +1340,12 @@ discard block |
||
| 1281 | 1340 | 'after_smiley' => $_GET['after'], |
| 1282 | 1341 | ) |
| 1283 | 1342 | ); |
| 1284 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
| 1285 | - fatal_lang_error('smiley_not_found'); |
|
| 1343 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
| 1344 | + fatal_lang_error('smiley_not_found'); |
|
| 1345 | + } |
|
| 1286 | 1346 | list ($smiley_row, $smiley_order, $smileyLocation) = $smcFunc['db_fetch_row']($request); |
| 1287 | 1347 | $smcFunc['db_free_result']($request); |
| 1288 | - } |
|
| 1289 | - else |
|
| 1348 | + } else |
|
| 1290 | 1349 | { |
| 1291 | 1350 | $smiley_row = (int) $_GET['row']; |
| 1292 | 1351 | $smiley_order = -1; |
@@ -1360,14 +1419,15 @@ discard block |
||
| 1360 | 1419 | $context['move_smiley'] = empty($_REQUEST['move']) ? 0 : (int) $_REQUEST['move']; |
| 1361 | 1420 | |
| 1362 | 1421 | // Make sure all rows are sequential. |
| 1363 | - foreach (array_keys($context['smileys']) as $location) |
|
| 1364 | - $context['smileys'][$location] = array( |
|
| 1422 | + foreach (array_keys($context['smileys']) as $location) { |
|
| 1423 | + $context['smileys'][$location] = array( |
|
| 1365 | 1424 | 'id' => $location, |
| 1366 | 1425 | 'title' => $location == 'postform' ? $txt['smileys_location_form'] : $txt['smileys_location_popup'], |
| 1367 | 1426 | 'description' => $location == 'postform' ? $txt['smileys_location_form_description'] : $txt['smileys_location_popup_description'], |
| 1368 | 1427 | 'last_row' => count($context['smileys'][$location]['rows']), |
| 1369 | 1428 | 'rows' => array_values($context['smileys'][$location]['rows']), |
| 1370 | 1429 | ); |
| 1430 | + } |
|
| 1371 | 1431 | |
| 1372 | 1432 | // Check & fix smileys that are not ordered properly in the database. |
| 1373 | 1433 | foreach (array_keys($context['smileys']) as $location) |
@@ -1392,8 +1452,8 @@ discard block |
||
| 1392 | 1452 | $context['smileys'][$location]['rows'][$id][0]['row'] = $id; |
| 1393 | 1453 | } |
| 1394 | 1454 | // Make sure the smiley order is always sequential. |
| 1395 | - foreach ($smiley_row as $order_id => $smiley) |
|
| 1396 | - if ($order_id != $smiley['order']) |
|
| 1455 | + foreach ($smiley_row as $order_id => $smiley) { |
|
| 1456 | + if ($order_id != $smiley['order']) |
|
| 1397 | 1457 | $smcFunc['db_query']('', ' |
| 1398 | 1458 | UPDATE {db_prefix}smileys |
| 1399 | 1459 | SET smiley_order = {int:new_order} |
@@ -1403,6 +1463,7 @@ discard block |
||
| 1403 | 1463 | 'current_smiley' => $smiley['id'], |
| 1404 | 1464 | ) |
| 1405 | 1465 | ); |
| 1466 | + } |
|
| 1406 | 1467 | } |
| 1407 | 1468 | } |
| 1408 | 1469 | |
@@ -1436,19 +1497,20 @@ discard block |
||
| 1436 | 1497 | |
| 1437 | 1498 | // Check that the smiley is from simplemachines.org, for now... maybe add mirroring later. |
| 1438 | 1499 | // @ TODO: Our current xml files serve http links. Allowing both for now until we serve https. |
| 1439 | - if (preg_match('~^https?://[\w_\-]+\.simplemachines\.org/~', $_REQUEST['set_gz']) == 0 || strpos($_REQUEST['set_gz'], 'dlattach') !== false) |
|
| 1440 | - fatal_lang_error('not_on_simplemachines'); |
|
| 1500 | + if (preg_match('~^https?://[\w_\-]+\.simplemachines\.org/~', $_REQUEST['set_gz']) == 0 || strpos($_REQUEST['set_gz'], 'dlattach') !== false) { |
|
| 1501 | + fatal_lang_error('not_on_simplemachines'); |
|
| 1502 | + } |
|
| 1441 | 1503 | |
| 1442 | 1504 | $destination = $packagesdir . '/' . $base_name; |
| 1443 | 1505 | |
| 1444 | - if (file_exists($destination)) |
|
| 1445 | - fatal_lang_error('package_upload_error_exists'); |
|
| 1506 | + if (file_exists($destination)) { |
|
| 1507 | + fatal_lang_error('package_upload_error_exists'); |
|
| 1508 | + } |
|
| 1446 | 1509 | |
| 1447 | 1510 | // Let's copy it to the Packages directory |
| 1448 | 1511 | file_put_contents($destination, fetch_web_data($_REQUEST['set_gz'])); |
| 1449 | 1512 | $testing = true; |
| 1450 | - } |
|
| 1451 | - elseif (isset($_REQUEST['package'])) |
|
| 1513 | + } elseif (isset($_REQUEST['package'])) |
|
| 1452 | 1514 | { |
| 1453 | 1515 | $base_name = basename($_REQUEST['package']); |
| 1454 | 1516 | $name = $smcFunc['htmlspecialchars'](strtok(basename($_REQUEST['package']), '.')); |
@@ -1457,12 +1519,14 @@ discard block |
||
| 1457 | 1519 | $destination = $packagesdir . '/' . basename($_REQUEST['package']); |
| 1458 | 1520 | } |
| 1459 | 1521 | |
| 1460 | - if (empty($destination) || !file_exists($destination)) |
|
| 1461 | - fatal_lang_error('package_no_file', false); |
|
| 1522 | + if (empty($destination) || !file_exists($destination)) { |
|
| 1523 | + fatal_lang_error('package_no_file', false); |
|
| 1524 | + } |
|
| 1462 | 1525 | |
| 1463 | 1526 | // Make sure temp directory exists and is empty. |
| 1464 | - if (file_exists($packagesdir . '/temp')) |
|
| 1465 | - deltree($packagesdir . '/temp', false); |
|
| 1527 | + if (file_exists($packagesdir . '/temp')) { |
|
| 1528 | + deltree($packagesdir . '/temp', false); |
|
| 1529 | + } |
|
| 1466 | 1530 | |
| 1467 | 1531 | if (!mktree($packagesdir . '/temp', 0755)) |
| 1468 | 1532 | { |
@@ -1474,31 +1538,37 @@ discard block |
||
| 1474 | 1538 | 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)); |
| 1475 | 1539 | |
| 1476 | 1540 | deltree($packagesdir . '/temp', false); |
| 1477 | - if (!mktree($packagesdir . '/temp', 0777)) |
|
| 1478 | - fatal_lang_error('package_cant_download', false); |
|
| 1541 | + if (!mktree($packagesdir . '/temp', 0777)) { |
|
| 1542 | + fatal_lang_error('package_cant_download', false); |
|
| 1543 | + } |
|
| 1479 | 1544 | } |
| 1480 | 1545 | } |
| 1481 | 1546 | |
| 1482 | 1547 | $extracted = read_tgz_file($destination, $packagesdir . '/temp'); |
| 1483 | - if (!$extracted) |
|
| 1484 | - fatal_lang_error('packageget_unable', false, array('https://custom.simplemachines.org/mods/index.php?action=search;type=12;basic_search=' . $name)); |
|
| 1485 | - if ($extracted && !file_exists($packagesdir . '/temp/package-info.xml')) |
|
| 1486 | - foreach ($extracted as $file) |
|
| 1548 | + if (!$extracted) { |
|
| 1549 | + fatal_lang_error('packageget_unable', false, array('https://custom.simplemachines.org/mods/index.php?action=search;type=12;basic_search=' . $name)); |
|
| 1550 | + } |
|
| 1551 | + if ($extracted && !file_exists($packagesdir . '/temp/package-info.xml')) { |
|
| 1552 | + foreach ($extracted as $file) |
|
| 1487 | 1553 | if (basename($file['filename']) == 'package-info.xml') |
| 1488 | 1554 | { |
| 1489 | 1555 | $base_path = dirname($file['filename']) . '/'; |
| 1556 | + } |
|
| 1490 | 1557 | break; |
| 1491 | 1558 | } |
| 1492 | 1559 | |
| 1493 | - if (!isset($base_path)) |
|
| 1494 | - $base_path = ''; |
|
| 1560 | + if (!isset($base_path)) { |
|
| 1561 | + $base_path = ''; |
|
| 1562 | + } |
|
| 1495 | 1563 | |
| 1496 | - if (!file_exists($packagesdir . '/temp/' . $base_path . 'package-info.xml')) |
|
| 1497 | - fatal_lang_error('package_get_error_missing_xml', false); |
|
| 1564 | + if (!file_exists($packagesdir . '/temp/' . $base_path . 'package-info.xml')) { |
|
| 1565 | + fatal_lang_error('package_get_error_missing_xml', false); |
|
| 1566 | + } |
|
| 1498 | 1567 | |
| 1499 | 1568 | $smileyInfo = getPackageInfo($context['filename']); |
| 1500 | - if (!is_array($smileyInfo)) |
|
| 1501 | - fatal_lang_error($smileyInfo); |
|
| 1569 | + if (!is_array($smileyInfo)) { |
|
| 1570 | + fatal_lang_error($smileyInfo); |
|
| 1571 | + } |
|
| 1502 | 1572 | |
| 1503 | 1573 | // See if it is installed? |
| 1504 | 1574 | $request = $smcFunc['db_query']('', ' |
@@ -1514,8 +1584,9 @@ discard block |
||
| 1514 | 1584 | ) |
| 1515 | 1585 | ); |
| 1516 | 1586 | |
| 1517 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
| 1518 | - fatal_lang_error('package_installed_warning1'); |
|
| 1587 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
| 1588 | + fatal_lang_error('package_installed_warning1'); |
|
| 1589 | + } |
|
| 1519 | 1590 | |
| 1520 | 1591 | // Everything is fine, now it's time to do something |
| 1521 | 1592 | $actions = parsePackageInfo($smileyInfo['xml'], true, 'install'); |
@@ -1530,23 +1601,23 @@ discard block |
||
| 1530 | 1601 | if ($action['type'] == 'readme' || $action['type'] == 'license') |
| 1531 | 1602 | { |
| 1532 | 1603 | $type = 'package_' . $action['type']; |
| 1533 | - if (file_exists($packagesdir . '/temp/' . $base_path . $action['filename'])) |
|
| 1534 | - $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($packagesdir . '/temp/' . $base_path . $action['filename']), "\n\r")); |
|
| 1535 | - elseif (file_exists($action['filename'])) |
|
| 1536 | - $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($action['filename']), "\n\r")); |
|
| 1604 | + if (file_exists($packagesdir . '/temp/' . $base_path . $action['filename'])) { |
|
| 1605 | + $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($packagesdir . '/temp/' . $base_path . $action['filename']), "\n\r")); |
|
| 1606 | + } elseif (file_exists($action['filename'])) { |
|
| 1607 | + $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($action['filename']), "\n\r")); |
|
| 1608 | + } |
|
| 1537 | 1609 | |
| 1538 | 1610 | if (!empty($action['parse_bbc'])) |
| 1539 | 1611 | { |
| 1540 | 1612 | require_once($sourcedir . '/Subs-Post.php'); |
| 1541 | 1613 | preparsecode($context[$type]); |
| 1542 | 1614 | $context[$type] = parse_bbc($context[$type]); |
| 1615 | + } else { |
|
| 1616 | + $context[$type] = nl2br($context[$type]); |
|
| 1543 | 1617 | } |
| 1544 | - else |
|
| 1545 | - $context[$type] = nl2br($context[$type]); |
|
| 1546 | 1618 | |
| 1547 | 1619 | continue; |
| 1548 | - } |
|
| 1549 | - elseif ($action['type'] == 'require-dir') |
|
| 1620 | + } elseif ($action['type'] == 'require-dir') |
|
| 1550 | 1621 | { |
| 1551 | 1622 | // Do this one... |
| 1552 | 1623 | $thisAction = array( |
@@ -1565,12 +1636,12 @@ discard block |
||
| 1565 | 1636 | ); |
| 1566 | 1637 | } |
| 1567 | 1638 | // @todo None given? |
| 1568 | - if (empty($thisAction['description'])) |
|
| 1569 | - $thisAction['description'] = isset($action['description']) ? $action['description'] : ''; |
|
| 1639 | + if (empty($thisAction['description'])) { |
|
| 1640 | + $thisAction['description'] = isset($action['description']) ? $action['description'] : ''; |
|
| 1641 | + } |
|
| 1570 | 1642 | |
| 1571 | 1643 | $context['actions'][] = $thisAction; |
| 1572 | - } |
|
| 1573 | - elseif ($action['type'] == 'credits') |
|
| 1644 | + } elseif ($action['type'] == 'credits') |
|
| 1574 | 1645 | { |
| 1575 | 1646 | // Time to build the billboard |
| 1576 | 1647 | $credits_tag = array( |
@@ -1630,12 +1701,14 @@ discard block |
||
| 1630 | 1701 | cache_put_data('posting_smileys', null, 480); |
| 1631 | 1702 | } |
| 1632 | 1703 | |
| 1633 | - if (file_exists($packagesdir . '/temp')) |
|
| 1634 | - deltree($packagesdir . '/temp'); |
|
| 1704 | + if (file_exists($packagesdir . '/temp')) { |
|
| 1705 | + deltree($packagesdir . '/temp'); |
|
| 1706 | + } |
|
| 1635 | 1707 | |
| 1636 | - if (!$testing) |
|
| 1637 | - redirectexit('action=admin;area=smileys'); |
|
| 1638 | -} |
|
| 1708 | + if (!$testing) { |
|
| 1709 | + redirectexit('action=admin;area=smileys'); |
|
| 1710 | + } |
|
| 1711 | + } |
|
| 1639 | 1712 | |
| 1640 | 1713 | /** |
| 1641 | 1714 | * A function to import new smileys from an existing directory into the database. |
@@ -1646,15 +1719,17 @@ discard block |
||
| 1646 | 1719 | { |
| 1647 | 1720 | global $modSettings, $smcFunc; |
| 1648 | 1721 | |
| 1649 | - if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'] . '/' . $smileyPath)) |
|
| 1650 | - fatal_lang_error('smiley_set_unable_to_import'); |
|
| 1722 | + if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'] . '/' . $smileyPath)) { |
|
| 1723 | + fatal_lang_error('smiley_set_unable_to_import'); |
|
| 1724 | + } |
|
| 1651 | 1725 | |
| 1652 | 1726 | $smileys = array(); |
| 1653 | 1727 | $dir = dir($modSettings['smileys_dir'] . '/' . $smileyPath); |
| 1654 | 1728 | while ($entry = $dir->read()) |
| 1655 | 1729 | { |
| 1656 | - if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) |
|
| 1657 | - $smileys[strtolower($entry)] = $entry; |
|
| 1730 | + if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) { |
|
| 1731 | + $smileys[strtolower($entry)] = $entry; |
|
| 1732 | + } |
|
| 1658 | 1733 | } |
| 1659 | 1734 | $dir->close(); |
| 1660 | 1735 | |
@@ -1667,9 +1742,10 @@ discard block |
||
| 1667 | 1742 | 'smiley_list' => $smileys, |
| 1668 | 1743 | ) |
| 1669 | 1744 | ); |
| 1670 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1671 | - if (isset($smileys[strtolower($row['filename'])])) |
|
| 1745 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1746 | + if (isset($smileys[strtolower($row['filename'])])) |
|
| 1672 | 1747 | unset($smileys[strtolower($row['filename'])]); |
| 1748 | + } |
|
| 1673 | 1749 | $smcFunc['db_free_result']($request); |
| 1674 | 1750 | |
| 1675 | 1751 | $request = $smcFunc['db_query']('', ' |
@@ -1686,9 +1762,10 @@ discard block |
||
| 1686 | 1762 | $smcFunc['db_free_result']($request); |
| 1687 | 1763 | |
| 1688 | 1764 | $new_smileys = array(); |
| 1689 | - foreach ($smileys as $smiley) |
|
| 1690 | - if (strlen($smiley) <= 48) |
|
| 1765 | + foreach ($smileys as $smiley) { |
|
| 1766 | + if (strlen($smiley) <= 48) |
|
| 1691 | 1767 | $new_smileys[] = array(':' . strtok($smiley, '.') . ':', $smiley, strtok($smiley, '.'), 0, ++$smiley_order); |
| 1768 | + } |
|
| 1692 | 1769 | |
| 1693 | 1770 | if (!empty($new_smileys)) |
| 1694 | 1771 | { |
@@ -1753,8 +1830,9 @@ discard block |
||
| 1753 | 1830 | if (isset($_POST['delete']) && !empty($_POST['checked_icons'])) |
| 1754 | 1831 | { |
| 1755 | 1832 | $deleteIcons = array(); |
| 1756 | - foreach ($_POST['checked_icons'] as $icon) |
|
| 1757 | - $deleteIcons[] = (int) $icon; |
|
| 1833 | + foreach ($_POST['checked_icons'] as $icon) { |
|
| 1834 | + $deleteIcons[] = (int) $icon; |
|
| 1835 | + } |
|
| 1758 | 1836 | |
| 1759 | 1837 | // Do the actual delete! |
| 1760 | 1838 | $smcFunc['db_query']('', ' |
@@ -1771,35 +1849,41 @@ discard block |
||
| 1771 | 1849 | $_GET['icon'] = (int) $_GET['icon']; |
| 1772 | 1850 | |
| 1773 | 1851 | // Do some preperation with the data... like check the icon exists *somewhere* |
| 1774 | - if (strpos($_POST['icon_filename'], '.png') !== false) |
|
| 1775 | - $_POST['icon_filename'] = substr($_POST['icon_filename'], 0, -4); |
|
| 1776 | - if (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon_filename'] . '.png')) |
|
| 1777 | - fatal_lang_error('icon_not_found'); |
|
| 1852 | + if (strpos($_POST['icon_filename'], '.png') !== false) { |
|
| 1853 | + $_POST['icon_filename'] = substr($_POST['icon_filename'], 0, -4); |
|
| 1854 | + } |
|
| 1855 | + if (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon_filename'] . '.png')) { |
|
| 1856 | + fatal_lang_error('icon_not_found'); |
|
| 1857 | + } |
|
| 1778 | 1858 | // There is a 16 character limit on message icons... |
| 1779 | - elseif (strlen($_POST['icon_filename']) > 16) |
|
| 1780 | - fatal_lang_error('icon_name_too_long'); |
|
| 1781 | - elseif ($_POST['icon_location'] == $_GET['icon'] && !empty($_GET['icon'])) |
|
| 1782 | - fatal_lang_error('icon_after_itself'); |
|
| 1859 | + elseif (strlen($_POST['icon_filename']) > 16) { |
|
| 1860 | + fatal_lang_error('icon_name_too_long'); |
|
| 1861 | + } elseif ($_POST['icon_location'] == $_GET['icon'] && !empty($_GET['icon'])) { |
|
| 1862 | + fatal_lang_error('icon_after_itself'); |
|
| 1863 | + } |
|
| 1783 | 1864 | |
| 1784 | 1865 | // First do the sorting... if this is an edit reduce the order of everything after it by one ;) |
| 1785 | 1866 | if ($_GET['icon'] != 0) |
| 1786 | 1867 | { |
| 1787 | 1868 | $oldOrder = $context['icons'][$_GET['icon']]['true_order']; |
| 1788 | - foreach ($context['icons'] as $id => $data) |
|
| 1789 | - if ($data['true_order'] > $oldOrder) |
|
| 1869 | + foreach ($context['icons'] as $id => $data) { |
|
| 1870 | + if ($data['true_order'] > $oldOrder) |
|
| 1790 | 1871 | $context['icons'][$id]['true_order']--; |
| 1872 | + } |
|
| 1791 | 1873 | } |
| 1792 | 1874 | |
| 1793 | 1875 | // If there are no existing icons and this is a new one, set the id to 1 (mainly for non-mysql) |
| 1794 | - if (empty($_GET['icon']) && empty($context['icons'])) |
|
| 1795 | - $_GET['icon'] = 1; |
|
| 1876 | + if (empty($_GET['icon']) && empty($context['icons'])) { |
|
| 1877 | + $_GET['icon'] = 1; |
|
| 1878 | + } |
|
| 1796 | 1879 | |
| 1797 | 1880 | // Get the new order. |
| 1798 | 1881 | $newOrder = $_POST['icon_location'] == 0 ? 0 : $context['icons'][$_POST['icon_location']]['true_order'] + 1; |
| 1799 | 1882 | // Do the same, but with the one that used to be after this icon, done to avoid conflict. |
| 1800 | - foreach ($context['icons'] as $id => $data) |
|
| 1801 | - if ($data['true_order'] >= $newOrder) |
|
| 1883 | + foreach ($context['icons'] as $id => $data) { |
|
| 1884 | + if ($data['true_order'] >= $newOrder) |
|
| 1802 | 1885 | $context['icons'][$id]['true_order']++; |
| 1886 | + } |
|
| 1803 | 1887 | |
| 1804 | 1888 | // Finally set the current icon's position! |
| 1805 | 1889 | $context['icons'][$_GET['icon']]['true_order'] = $newOrder; |
@@ -1817,8 +1901,7 @@ discard block |
||
| 1817 | 1901 | if ($id != 0) |
| 1818 | 1902 | { |
| 1819 | 1903 | $iconInsert[] = array($id, $icon['board_id'], $icon['title'], $icon['filename'], $icon['true_order']); |
| 1820 | - } |
|
| 1821 | - else |
|
| 1904 | + } else |
|
| 1822 | 1905 | { |
| 1823 | 1906 | $iconInsert_new[] = array($icon['board_id'], $icon['title'], $icon['filename'], $icon['true_order']); |
| 1824 | 1907 | } |
@@ -1843,8 +1926,9 @@ discard block |
||
| 1843 | 1926 | } |
| 1844 | 1927 | |
| 1845 | 1928 | // Unless we're adding a new thing, we'll escape |
| 1846 | - if (!isset($_POST['add'])) |
|
| 1847 | - redirectexit('action=admin;area=smileys;sa=editicons'); |
|
| 1929 | + if (!isset($_POST['add'])) { |
|
| 1930 | + redirectexit('action=admin;area=smileys;sa=editicons'); |
|
| 1931 | + } |
|
| 1848 | 1932 | } |
| 1849 | 1933 | |
| 1850 | 1934 | $context[$context['admin_menu_name']]['current_subsection'] = 'editicons'; |
@@ -1954,8 +2038,9 @@ discard block |
||
| 1954 | 2038 | $context['new_icon'] = !isset($_GET['icon']); |
| 1955 | 2039 | |
| 1956 | 2040 | // Get the properties of the current icon from the icon list. |
| 1957 | - if (!$context['new_icon']) |
|
| 1958 | - $context['icon'] = $context['icons'][$_GET['icon']]; |
|
| 2041 | + if (!$context['new_icon']) { |
|
| 2042 | + $context['icon'] = $context['icons'][$_GET['icon']]; |
|
| 2043 | + } |
|
| 1959 | 2044 | |
| 1960 | 2045 | // Get a list of boards needed for assigning this icon to a specific board. |
| 1961 | 2046 | $boardListOptions = array( |
@@ -1989,8 +2074,9 @@ discard block |
||
| 1989 | 2074 | ); |
| 1990 | 2075 | |
| 1991 | 2076 | $message_icons = array(); |
| 1992 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1993 | - $message_icons[] = $row; |
|
| 2077 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2078 | + $message_icons[] = $row; |
|
| 2079 | + } |
|
| 1994 | 2080 | $smcFunc['db_free_result']($request); |
| 1995 | 2081 | |
| 1996 | 2082 | return $message_icons; |
@@ -75,8 +75,9 @@ discard block |
||
| 75 | 75 | $upcontext['inactive_timeout'] = 10; |
| 76 | 76 | |
| 77 | 77 | // The helper is crucial. Include it first thing. |
| 78 | -if (!file_exists($upgrade_path . '/upgrade-helper.php')) |
|
| 78 | +if (!file_exists($upgrade_path . '/upgrade-helper.php')) { |
|
| 79 | 79 | die('upgrade-helper.php not found where it was expected: ' . $upgrade_path . '/upgrade-helper.php! Make sure you have uploaded ALL files from the upgrade package. The upgrader cannot continue.'); |
| 80 | +} |
|
| 80 | 81 | |
| 81 | 82 | require_once($upgrade_path . '/upgrade-helper.php'); |
| 82 | 83 | |
@@ -100,11 +101,14 @@ discard block |
||
| 100 | 101 | ini_set('default_socket_timeout', 900); |
| 101 | 102 | } |
| 102 | 103 | // Clean the upgrade path if this is from the client. |
| 103 | -if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) |
|
| 104 | - for ($i = 1; $i < $_SERVER['argc']; $i++) |
|
| 104 | +if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) { |
|
| 105 | + for ($i = 1; |
|
| 106 | +} |
|
| 107 | +$i < $_SERVER['argc']; $i++) |
|
| 105 | 108 | { |
| 106 | - if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) |
|
| 107 | - $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
| 109 | + if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) { |
|
| 110 | + $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
| 111 | + } |
|
| 108 | 112 | } |
| 109 | 113 | |
| 110 | 114 | // Are we from the client? |
@@ -112,16 +116,17 @@ discard block |
||
| 112 | 116 | { |
| 113 | 117 | $command_line = true; |
| 114 | 118 | $disable_security = true; |
| 115 | -} |
|
| 116 | -else |
|
| 119 | +} else { |
|
| 117 | 120 | $command_line = false; |
| 121 | +} |
|
| 118 | 122 | |
| 119 | 123 | // Load this now just because we can. |
| 120 | 124 | require_once($upgrade_path . '/Settings.php'); |
| 121 | 125 | |
| 122 | 126 | // We don't use "-utf8" anymore... Tweak the entry that may have been loaded by Settings.php |
| 123 | -if (isset($language)) |
|
| 127 | +if (isset($language)) { |
|
| 124 | 128 | $language = str_ireplace('-utf8', '', $language); |
| 129 | +} |
|
| 125 | 130 | |
| 126 | 131 | // Are we logged in? |
| 127 | 132 | if (isset($upgradeData)) |
@@ -129,10 +134,12 @@ discard block |
||
| 129 | 134 | $upcontext['user'] = json_decode(base64_decode($upgradeData), true); |
| 130 | 135 | |
| 131 | 136 | // Check for sensible values. |
| 132 | - if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) |
|
| 133 | - $upcontext['user']['started'] = time(); |
|
| 134 | - if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) |
|
| 135 | - $upcontext['user']['updated'] = 0; |
|
| 137 | + if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) { |
|
| 138 | + $upcontext['user']['started'] = time(); |
|
| 139 | + } |
|
| 140 | + if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) { |
|
| 141 | + $upcontext['user']['updated'] = 0; |
|
| 142 | + } |
|
| 136 | 143 | |
| 137 | 144 | $upcontext['started'] = $upcontext['user']['started']; |
| 138 | 145 | $upcontext['updated'] = $upcontext['user']['updated']; |
@@ -190,8 +197,9 @@ discard block |
||
| 190 | 197 | 'db_error_skip' => true, |
| 191 | 198 | ) |
| 192 | 199 | ); |
| 193 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 194 | - $modSettings[$row['variable']] = $row['value']; |
|
| 200 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 201 | + $modSettings[$row['variable']] = $row['value']; |
|
| 202 | + } |
|
| 195 | 203 | $smcFunc['db_free_result']($request); |
| 196 | 204 | } |
| 197 | 205 | |
@@ -201,10 +209,12 @@ discard block |
||
| 201 | 209 | $modSettings['theme_url'] = 'Themes/default'; |
| 202 | 210 | $modSettings['images_url'] = 'Themes/default/images'; |
| 203 | 211 | } |
| 204 | -if (!isset($settings['default_theme_url'])) |
|
| 212 | +if (!isset($settings['default_theme_url'])) { |
|
| 205 | 213 | $settings['default_theme_url'] = $modSettings['theme_url']; |
| 206 | -if (!isset($settings['default_theme_dir'])) |
|
| 214 | +} |
|
| 215 | +if (!isset($settings['default_theme_dir'])) { |
|
| 207 | 216 | $settings['default_theme_dir'] = $modSettings['theme_dir']; |
| 217 | +} |
|
| 208 | 218 | |
| 209 | 219 | $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000; |
| 210 | 220 | // Default title... |
@@ -222,13 +232,15 @@ discard block |
||
| 222 | 232 | $support_js = $upcontext['upgrade_status']['js']; |
| 223 | 233 | |
| 224 | 234 | // Only set this if the upgrader status says so. |
| 225 | - if (empty($is_debug)) |
|
| 226 | - $is_debug = $upcontext['upgrade_status']['debug']; |
|
| 235 | + if (empty($is_debug)) { |
|
| 236 | + $is_debug = $upcontext['upgrade_status']['debug']; |
|
| 237 | + } |
|
| 227 | 238 | |
| 228 | 239 | // Load the language. |
| 229 | - if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 230 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 231 | -} |
|
| 240 | + if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 241 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 242 | + } |
|
| 243 | + } |
|
| 232 | 244 | // Set the defaults. |
| 233 | 245 | else |
| 234 | 246 | { |
@@ -246,15 +258,18 @@ discard block |
||
| 246 | 258 | } |
| 247 | 259 | |
| 248 | 260 | // If this isn't the first stage see whether they are logging in and resuming. |
| 249 | -if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) |
|
| 261 | +if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) { |
|
| 250 | 262 | checkLogin(); |
| 263 | +} |
|
| 251 | 264 | |
| 252 | -if ($command_line) |
|
| 265 | +if ($command_line) { |
|
| 253 | 266 | cmdStep0(); |
| 267 | +} |
|
| 254 | 268 | |
| 255 | 269 | // Don't error if we're using xml. |
| 256 | -if (isset($_GET['xml'])) |
|
| 270 | +if (isset($_GET['xml'])) { |
|
| 257 | 271 | $upcontext['return_error'] = true; |
| 272 | +} |
|
| 258 | 273 | |
| 259 | 274 | // Loop through all the steps doing each one as required. |
| 260 | 275 | $upcontext['overall_percent'] = 0; |
@@ -275,9 +290,9 @@ discard block |
||
| 275 | 290 | } |
| 276 | 291 | |
| 277 | 292 | // Call the step and if it returns false that means pause! |
| 278 | - if (function_exists($step[2]) && $step[2]() === false) |
|
| 279 | - break; |
|
| 280 | - elseif (function_exists($step[2])) { |
|
| 293 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
| 294 | + break; |
|
| 295 | + } elseif (function_exists($step[2])) { |
|
| 281 | 296 | //Start each new step with this unset, so the 'normal' template is called first |
| 282 | 297 | unset($_GET['xml']); |
| 283 | 298 | $_GET['substep'] = 0; |
@@ -321,17 +336,18 @@ discard block |
||
| 321 | 336 | // This should not happen my dear... HELP ME DEVELOPERS!! |
| 322 | 337 | if (!empty($command_line)) |
| 323 | 338 | { |
| 324 | - if (function_exists('debug_print_backtrace')) |
|
| 325 | - debug_print_backtrace(); |
|
| 339 | + if (function_exists('debug_print_backtrace')) { |
|
| 340 | + debug_print_backtrace(); |
|
| 341 | + } |
|
| 326 | 342 | |
| 327 | 343 | echo "\n" . 'Error: Unexpected call to use the ' . (isset($upcontext['sub_template']) ? $upcontext['sub_template'] : '') . ' template. Please copy and paste all the text above and visit the SMF support forum to tell the Developers that they\'ve made a boo boo; they\'ll get you up and running again.'; |
| 328 | 344 | flush(); |
| 329 | 345 | die(); |
| 330 | 346 | } |
| 331 | 347 | |
| 332 | - if (!isset($_GET['xml'])) |
|
| 333 | - template_upgrade_above(); |
|
| 334 | - else |
|
| 348 | + if (!isset($_GET['xml'])) { |
|
| 349 | + template_upgrade_above(); |
|
| 350 | + } else |
|
| 335 | 351 | { |
| 336 | 352 | header('Content-Type: text/xml; charset=UTF-8'); |
| 337 | 353 | // Sadly we need to retain the $_GET data thanks to the old upgrade scripts. |
@@ -353,25 +369,29 @@ discard block |
||
| 353 | 369 | $upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&substep=' . $_GET['substep'] . '&data=' . base64_encode(json_encode($upcontext['upgrade_status'])); |
| 354 | 370 | |
| 355 | 371 | // Custom stuff to pass back? |
| 356 | - if (!empty($upcontext['query_string'])) |
|
| 357 | - $upcontext['form_url'] .= $upcontext['query_string']; |
|
| 372 | + if (!empty($upcontext['query_string'])) { |
|
| 373 | + $upcontext['form_url'] .= $upcontext['query_string']; |
|
| 374 | + } |
|
| 358 | 375 | |
| 359 | 376 | // Call the appropriate subtemplate |
| 360 | - if (is_callable('template_' . $upcontext['sub_template'])) |
|
| 361 | - call_user_func('template_' . $upcontext['sub_template']); |
|
| 362 | - else |
|
| 363 | - die('Upgrade aborted! Invalid template: template_' . $upcontext['sub_template']); |
|
| 377 | + if (is_callable('template_' . $upcontext['sub_template'])) { |
|
| 378 | + call_user_func('template_' . $upcontext['sub_template']); |
|
| 379 | + } else { |
|
| 380 | + die('Upgrade aborted! Invalid template: template_' . $upcontext['sub_template']); |
|
| 381 | + } |
|
| 364 | 382 | } |
| 365 | 383 | |
| 366 | 384 | // Was there an error? |
| 367 | - if (!empty($upcontext['forced_error_message'])) |
|
| 368 | - echo $upcontext['forced_error_message']; |
|
| 385 | + if (!empty($upcontext['forced_error_message'])) { |
|
| 386 | + echo $upcontext['forced_error_message']; |
|
| 387 | + } |
|
| 369 | 388 | |
| 370 | 389 | // Show the footer. |
| 371 | - if (!isset($_GET['xml'])) |
|
| 372 | - template_upgrade_below(); |
|
| 373 | - else |
|
| 374 | - template_xml_below(); |
|
| 390 | + if (!isset($_GET['xml'])) { |
|
| 391 | + template_upgrade_below(); |
|
| 392 | + } else { |
|
| 393 | + template_xml_below(); |
|
| 394 | + } |
|
| 375 | 395 | } |
| 376 | 396 | |
| 377 | 397 | |
@@ -383,15 +403,19 @@ discard block |
||
| 383 | 403 | $seconds = intval($active % 60); |
| 384 | 404 | |
| 385 | 405 | $totalTime = ''; |
| 386 | - if ($hours > 0) |
|
| 387 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 388 | - if ($minutes > 0) |
|
| 389 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 390 | - if ($seconds > 0) |
|
| 391 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 406 | + if ($hours > 0) { |
|
| 407 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 408 | + } |
|
| 409 | + if ($minutes > 0) { |
|
| 410 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 411 | + } |
|
| 412 | + if ($seconds > 0) { |
|
| 413 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 414 | + } |
|
| 392 | 415 | |
| 393 | - if (!empty($totalTime)) |
|
| 394 | - echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
| 416 | + if (!empty($totalTime)) { |
|
| 417 | + echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
| 418 | + } |
|
| 395 | 419 | } |
| 396 | 420 | |
| 397 | 421 | // Bang - gone! |
@@ -404,8 +428,9 @@ discard block |
||
| 404 | 428 | global $upgradeurl, $upcontext, $command_line; |
| 405 | 429 | |
| 406 | 430 | // Command line users can't be redirected. |
| 407 | - if ($command_line) |
|
| 408 | - upgradeExit(true); |
|
| 431 | + if ($command_line) { |
|
| 432 | + upgradeExit(true); |
|
| 433 | + } |
|
| 409 | 434 | |
| 410 | 435 | // Are we providing the core info? |
| 411 | 436 | if ($addForm) |
@@ -431,12 +456,14 @@ discard block |
||
| 431 | 456 | define('SMF', 1); |
| 432 | 457 | |
| 433 | 458 | // Start the session. |
| 434 | - if (@ini_get('session.save_handler') == 'user') |
|
| 435 | - @ini_set('session.save_handler', 'files'); |
|
| 459 | + if (@ini_get('session.save_handler') == 'user') { |
|
| 460 | + @ini_set('session.save_handler', 'files'); |
|
| 461 | + } |
|
| 436 | 462 | @session_start(); |
| 437 | 463 | |
| 438 | - if (empty($smcFunc)) |
|
| 439 | - $smcFunc = array(); |
|
| 464 | + if (empty($smcFunc)) { |
|
| 465 | + $smcFunc = array(); |
|
| 466 | + } |
|
| 440 | 467 | |
| 441 | 468 | // We need this for authentication and some upgrade code |
| 442 | 469 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -448,32 +475,36 @@ discard block |
||
| 448 | 475 | initialize_inputs(); |
| 449 | 476 | |
| 450 | 477 | // Get the database going! |
| 451 | - if (empty($db_type) || $db_type == 'mysqli') |
|
| 452 | - $db_type = 'mysql'; |
|
| 478 | + if (empty($db_type) || $db_type == 'mysqli') { |
|
| 479 | + $db_type = 'mysql'; |
|
| 480 | + } |
|
| 453 | 481 | |
| 454 | 482 | if (file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
| 455 | 483 | { |
| 456 | 484 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
| 457 | 485 | |
| 458 | 486 | // Make the connection... |
| 459 | - if (empty($db_connection)) |
|
| 460 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
|
| 461 | - else |
|
| 462 | - // If we've returned here, ping/reconnect to be safe |
|
| 487 | + if (empty($db_connection)) { |
|
| 488 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
|
| 489 | + } else { |
|
| 490 | + // If we've returned here, ping/reconnect to be safe |
|
| 463 | 491 | $smcFunc['db_ping']($db_connection); |
| 492 | + } |
|
| 464 | 493 | |
| 465 | 494 | // Oh dear god!! |
| 466 | - if ($db_connection === null) |
|
| 467 | - die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
| 495 | + if ($db_connection === null) { |
|
| 496 | + die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
| 497 | + } |
|
| 468 | 498 | |
| 469 | - if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) |
|
| 470 | - $smcFunc['db_query']('', ' |
|
| 499 | + if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) { |
|
| 500 | + $smcFunc['db_query']('', ' |
|
| 471 | 501 | SET NAMES {string:db_character_set}', |
| 472 | 502 | array( |
| 473 | 503 | 'db_error_skip' => true, |
| 474 | 504 | 'db_character_set' => $db_character_set, |
| 475 | 505 | ) |
| 476 | 506 | ); |
| 507 | + } |
|
| 477 | 508 | |
| 478 | 509 | // Load the modSettings data... |
| 479 | 510 | $request = $smcFunc['db_query']('', ' |
@@ -484,11 +515,11 @@ discard block |
||
| 484 | 515 | ) |
| 485 | 516 | ); |
| 486 | 517 | $modSettings = array(); |
| 487 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 488 | - $modSettings[$row['variable']] = $row['value']; |
|
| 518 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 519 | + $modSettings[$row['variable']] = $row['value']; |
|
| 520 | + } |
|
| 489 | 521 | $smcFunc['db_free_result']($request); |
| 490 | - } |
|
| 491 | - else |
|
| 522 | + } else |
|
| 492 | 523 | { |
| 493 | 524 | return throw_error('Cannot find ' . $sourcedir . '/Subs-Db-' . $db_type . '.php' . '. Please check you have uploaded all source files and have the correct paths set.'); |
| 494 | 525 | } |
@@ -502,9 +533,10 @@ discard block |
||
| 502 | 533 | cleanRequest(); |
| 503 | 534 | } |
| 504 | 535 | |
| 505 | - if (!isset($_GET['substep'])) |
|
| 506 | - $_GET['substep'] = 0; |
|
| 507 | -} |
|
| 536 | + if (!isset($_GET['substep'])) { |
|
| 537 | + $_GET['substep'] = 0; |
|
| 538 | + } |
|
| 539 | + } |
|
| 508 | 540 | |
| 509 | 541 | function initialize_inputs() |
| 510 | 542 | { |
@@ -534,8 +566,9 @@ discard block |
||
| 534 | 566 | $dh = opendir(dirname(__FILE__)); |
| 535 | 567 | while ($file = readdir($dh)) |
| 536 | 568 | { |
| 537 | - if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) |
|
| 538 | - @unlink(dirname(__FILE__) . '/' . $file); |
|
| 569 | + if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) { |
|
| 570 | + @unlink(dirname(__FILE__) . '/' . $file); |
|
| 571 | + } |
|
| 539 | 572 | } |
| 540 | 573 | closedir($dh); |
| 541 | 574 | |
@@ -564,8 +597,9 @@ discard block |
||
| 564 | 597 | $temp = 'upgrade_php?step'; |
| 565 | 598 | while (strlen($temp) > 4) |
| 566 | 599 | { |
| 567 | - if (isset($_GET[$temp])) |
|
| 568 | - unset($_GET[$temp]); |
|
| 600 | + if (isset($_GET[$temp])) { |
|
| 601 | + unset($_GET[$temp]); |
|
| 602 | + } |
|
| 569 | 603 | $temp = substr($temp, 1); |
| 570 | 604 | } |
| 571 | 605 | |
@@ -592,32 +626,39 @@ discard block |
||
| 592 | 626 | && @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $db_type . '.sql'); |
| 593 | 627 | |
| 594 | 628 | // Need legacy scripts? |
| 595 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) |
|
| 596 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
| 597 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) |
|
| 598 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
| 599 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) |
|
| 600 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
| 629 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) { |
|
| 630 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
| 631 | + } |
|
| 632 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) { |
|
| 633 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
| 634 | + } |
|
| 635 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) { |
|
| 636 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
| 637 | + } |
|
| 601 | 638 | |
| 602 | 639 | // We don't need "-utf8" files anymore... |
| 603 | 640 | $upcontext['language'] = str_ireplace('-utf8', '', $upcontext['language']); |
| 604 | 641 | |
| 605 | 642 | // This needs to exist! |
| 606 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 607 | - return throw_error('The upgrader could not find the "Install" language file for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
| 608 | - else |
|
| 609 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 643 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 644 | + return throw_error('The upgrader could not find the "Install" language file for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
| 645 | + } else { |
|
| 646 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 647 | + } |
|
| 610 | 648 | |
| 611 | - if (!$check) |
|
| 612 | - // Don't tell them what files exactly because it's a spot check - just like teachers don't tell which problems they are spot checking, that's dumb. |
|
| 649 | + if (!$check) { |
|
| 650 | + // Don't tell them what files exactly because it's a spot check - just like teachers don't tell which problems they are spot checking, that's dumb. |
|
| 613 | 651 | return throw_error('The upgrader was unable to find some crucial files.<br><br>Please make sure you uploaded all of the files included in the package, including the Themes, Sources, and other directories.'); |
| 652 | + } |
|
| 614 | 653 | |
| 615 | 654 | // Do they meet the install requirements? |
| 616 | - if (!php_version_check()) |
|
| 617 | - return throw_error('Warning! You do not appear to have a version of PHP installed on your webserver that meets SMF\'s minimum installations requirements.<br><br>Please ask your host to upgrade.'); |
|
| 655 | + if (!php_version_check()) { |
|
| 656 | + return throw_error('Warning! You do not appear to have a version of PHP installed on your webserver that meets SMF\'s minimum installations requirements.<br><br>Please ask your host to upgrade.'); |
|
| 657 | + } |
|
| 618 | 658 | |
| 619 | - if (!db_version_check()) |
|
| 620 | - return throw_error('Your ' . $databases[$db_type]['name'] . ' version does not meet the minimum requirements of SMF.<br><br>Please ask your host to upgrade.'); |
|
| 659 | + if (!db_version_check()) { |
|
| 660 | + return throw_error('Your ' . $databases[$db_type]['name'] . ' version does not meet the minimum requirements of SMF.<br><br>Please ask your host to upgrade.'); |
|
| 661 | + } |
|
| 621 | 662 | |
| 622 | 663 | // Do some checks to make sure they have proper privileges |
| 623 | 664 | db_extend('packages'); |
@@ -632,14 +673,16 @@ discard block |
||
| 632 | 673 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
| 633 | 674 | |
| 634 | 675 | // Sorry... we need CREATE, ALTER and DROP |
| 635 | - if (!$create || !$alter || !$drop) |
|
| 636 | - return throw_error('The ' . $databases[$db_type]['name'] . ' user you have set in Settings.php does not have proper privileges.<br><br>Please ask your host to give this user the ALTER, CREATE, and DROP privileges.'); |
|
| 676 | + if (!$create || !$alter || !$drop) { |
|
| 677 | + return throw_error('The ' . $databases[$db_type]['name'] . ' user you have set in Settings.php does not have proper privileges.<br><br>Please ask your host to give this user the ALTER, CREATE, and DROP privileges.'); |
|
| 678 | + } |
|
| 637 | 679 | |
| 638 | 680 | // Do a quick version spot check. |
| 639 | 681 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
| 640 | 682 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
| 641 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
| 642 | - return throw_error('The upgrader found some old or outdated files.<br><br>Please make certain you uploaded the new versions of all the files included in the package.'); |
|
| 683 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
| 684 | + return throw_error('The upgrader found some old or outdated files.<br><br>Please make certain you uploaded the new versions of all the files included in the package.'); |
|
| 685 | + } |
|
| 643 | 686 | |
| 644 | 687 | // What absolutely needs to be writable? |
| 645 | 688 | $writable_files = array( |
@@ -661,12 +704,13 @@ discard block |
||
| 661 | 704 | quickFileWritable($custom_av_dir); |
| 662 | 705 | |
| 663 | 706 | // Are we good now? |
| 664 | - if (!is_writable($custom_av_dir)) |
|
| 665 | - return throw_error(sprintf('The directory: %1$s has to be writable to continue the upgrade. Please make sure permissions are correctly set to allow this.', $custom_av_dir)); |
|
| 666 | - elseif ($need_settings_update) |
|
| 707 | + if (!is_writable($custom_av_dir)) { |
|
| 708 | + return throw_error(sprintf('The directory: %1$s has to be writable to continue the upgrade. Please make sure permissions are correctly set to allow this.', $custom_av_dir)); |
|
| 709 | + } elseif ($need_settings_update) |
|
| 667 | 710 | { |
| 668 | - if (!function_exists('cache_put_data')) |
|
| 669 | - require_once($sourcedir . '/Load.php'); |
|
| 711 | + if (!function_exists('cache_put_data')) { |
|
| 712 | + require_once($sourcedir . '/Load.php'); |
|
| 713 | + } |
|
| 670 | 714 | updateSettings(array('custom_avatar_dir' => $custom_av_dir)); |
| 671 | 715 | updateSettings(array('custom_avatar_url' => $custom_av_url)); |
| 672 | 716 | } |
@@ -675,28 +719,33 @@ discard block |
||
| 675 | 719 | |
| 676 | 720 | // Check the cache directory. |
| 677 | 721 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
| 678 | - if (!file_exists($cachedir_temp)) |
|
| 679 | - @mkdir($cachedir_temp); |
|
| 680 | - if (!file_exists($cachedir_temp)) |
|
| 681 | - return throw_error('The cache directory could not be found.<br><br>Please make sure you have a directory called "cache" in your forum directory before continuing.'); |
|
| 682 | - |
|
| 683 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
| 684 | - return throw_error('The upgrader was unable to find language files for the language specified in Settings.php.<br>SMF will not work without the primary language files installed.<br><br>Please either install them, or <a href="' . $upgradeurl . '?step=0;lang=english">use english instead</a>.'); |
|
| 685 | - elseif (!isset($_GET['skiplang'])) |
|
| 722 | + if (!file_exists($cachedir_temp)) { |
|
| 723 | + @mkdir($cachedir_temp); |
|
| 724 | + } |
|
| 725 | + if (!file_exists($cachedir_temp)) { |
|
| 726 | + return throw_error('The cache directory could not be found.<br><br>Please make sure you have a directory called "cache" in your forum directory before continuing.'); |
|
| 727 | + } |
|
| 728 | + |
|
| 729 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
| 730 | + return throw_error('The upgrader was unable to find language files for the language specified in Settings.php.<br>SMF will not work without the primary language files installed.<br><br>Please either install them, or <a href="' . $upgradeurl . '?step=0;lang=english">use english instead</a>.'); |
|
| 731 | + } elseif (!isset($_GET['skiplang'])) |
|
| 686 | 732 | { |
| 687 | 733 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
| 688 | 734 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 689 | 735 | |
| 690 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 691 | - return throw_error('The upgrader found some old or outdated language files, for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded the new versions of all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?skiplang">SKIP</a>] [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
| 736 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 737 | + return throw_error('The upgrader found some old or outdated language files, for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded the new versions of all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?skiplang">SKIP</a>] [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
| 738 | + } |
|
| 692 | 739 | } |
| 693 | 740 | |
| 694 | - if (!makeFilesWritable($writable_files)) |
|
| 695 | - return false; |
|
| 741 | + if (!makeFilesWritable($writable_files)) { |
|
| 742 | + return false; |
|
| 743 | + } |
|
| 696 | 744 | |
| 697 | 745 | // Check agreement.txt. (it may not exist, in which case $boarddir must be writable.) |
| 698 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
| 699 | - return throw_error('The upgrader was unable to obtain write access to agreement.txt.<br><br>If you are using a linux or unix based server, please ensure that the file is chmod\'d to 777, or if it does not exist that the directory this upgrader is in is 777.<br>If your server is running Windows, please ensure that the internet guest account has the proper permissions on it or its folder.'); |
|
| 746 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
| 747 | + return throw_error('The upgrader was unable to obtain write access to agreement.txt.<br><br>If you are using a linux or unix based server, please ensure that the file is chmod\'d to 777, or if it does not exist that the directory this upgrader is in is 777.<br>If your server is running Windows, please ensure that the internet guest account has the proper permissions on it or its folder.'); |
|
| 748 | + } |
|
| 700 | 749 | |
| 701 | 750 | // Upgrade the agreement. |
| 702 | 751 | elseif (isset($modSettings['agreement'])) |
@@ -707,8 +756,8 @@ discard block |
||
| 707 | 756 | } |
| 708 | 757 | |
| 709 | 758 | // We're going to check that their board dir setting is right in case they've been moving stuff around. |
| 710 | - if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) |
|
| 711 | - $upcontext['warning'] = ' |
|
| 759 | + if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) { |
|
| 760 | + $upcontext['warning'] = ' |
|
| 712 | 761 | It looks as if your board directory settings <em>might</em> be incorrect. Your board directory is currently set to "' . $boarddir . '" but should probably be "' . dirname(__FILE__) . '". Settings.php currently lists your paths as:<br> |
| 713 | 762 | <ul> |
| 714 | 763 | <li>Board Directory: ' . $boarddir . '</li> |
@@ -716,10 +765,12 @@ discard block |
||
| 716 | 765 | <li>Cache Directory: ' . $cachedir_temp . '</li> |
| 717 | 766 | </ul> |
| 718 | 767 | If these seem incorrect please open Settings.php in a text editor before proceeding with this upgrade. If they are incorrect due to you moving your forum to a new location please download and execute the <a href="https://download.simplemachines.org/?tools">Repair Settings</a> tool from the Simple Machines website before continuing.'; |
| 768 | + } |
|
| 719 | 769 | |
| 720 | 770 | // Either we're logged in or we're going to present the login. |
| 721 | - if (checkLogin()) |
|
| 722 | - return true; |
|
| 771 | + if (checkLogin()) { |
|
| 772 | + return true; |
|
| 773 | + } |
|
| 723 | 774 | |
| 724 | 775 | $upcontext += createToken('login'); |
| 725 | 776 | |
@@ -733,15 +784,17 @@ discard block |
||
| 733 | 784 | global $smcFunc, $db_type, $support_js; |
| 734 | 785 | |
| 735 | 786 | // Don't bother if the security is disabled. |
| 736 | - if ($disable_security) |
|
| 737 | - return true; |
|
| 787 | + if ($disable_security) { |
|
| 788 | + return true; |
|
| 789 | + } |
|
| 738 | 790 | |
| 739 | 791 | // Are we trying to login? |
| 740 | 792 | if (isset($_POST['contbutt']) && (!empty($_POST['user']))) |
| 741 | 793 | { |
| 742 | 794 | // If we've disabled security pick a suitable name! |
| 743 | - if (empty($_POST['user'])) |
|
| 744 | - $_POST['user'] = 'Administrator'; |
|
| 795 | + if (empty($_POST['user'])) { |
|
| 796 | + $_POST['user'] = 'Administrator'; |
|
| 797 | + } |
|
| 745 | 798 | |
| 746 | 799 | // Before 2.0 these column names were different! |
| 747 | 800 | $oldDB = false; |
@@ -756,16 +809,17 @@ discard block |
||
| 756 | 809 | 'db_error_skip' => true, |
| 757 | 810 | ) |
| 758 | 811 | ); |
| 759 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 760 | - $oldDB = true; |
|
| 812 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 813 | + $oldDB = true; |
|
| 814 | + } |
|
| 761 | 815 | $smcFunc['db_free_result']($request); |
| 762 | 816 | } |
| 763 | 817 | |
| 764 | 818 | // Get what we believe to be their details. |
| 765 | 819 | if (!$disable_security) |
| 766 | 820 | { |
| 767 | - if ($oldDB) |
|
| 768 | - $request = $smcFunc['db_query']('', ' |
|
| 821 | + if ($oldDB) { |
|
| 822 | + $request = $smcFunc['db_query']('', ' |
|
| 769 | 823 | SELECT id_member, memberName AS member_name, passwd, id_group, |
| 770 | 824 | additionalGroups AS additional_groups, lngfile |
| 771 | 825 | FROM {db_prefix}members |
@@ -775,8 +829,8 @@ discard block |
||
| 775 | 829 | 'db_error_skip' => true, |
| 776 | 830 | ) |
| 777 | 831 | ); |
| 778 | - else |
|
| 779 | - $request = $smcFunc['db_query']('', ' |
|
| 832 | + } else { |
|
| 833 | + $request = $smcFunc['db_query']('', ' |
|
| 780 | 834 | SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile |
| 781 | 835 | FROM {db_prefix}members |
| 782 | 836 | WHERE member_name = {string:member_name}', |
@@ -785,6 +839,7 @@ discard block |
||
| 785 | 839 | 'db_error_skip' => true, |
| 786 | 840 | ) |
| 787 | 841 | ); |
| 842 | + } |
|
| 788 | 843 | if ($smcFunc['db_num_rows']($request) != 0) |
| 789 | 844 | { |
| 790 | 845 | list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request); |
@@ -792,16 +847,17 @@ discard block |
||
| 792 | 847 | $groups = explode(',', $addGroups); |
| 793 | 848 | $groups[] = $id_group; |
| 794 | 849 | |
| 795 | - foreach ($groups as $k => $v) |
|
| 796 | - $groups[$k] = (int) $v; |
|
| 850 | + foreach ($groups as $k => $v) { |
|
| 851 | + $groups[$k] = (int) $v; |
|
| 852 | + } |
|
| 797 | 853 | |
| 798 | 854 | $sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd'])); |
| 799 | 855 | |
| 800 | 856 | // We don't use "-utf8" anymore... |
| 801 | 857 | $user_language = str_ireplace('-utf8', '', $user_language); |
| 858 | + } else { |
|
| 859 | + $upcontext['username_incorrect'] = true; |
|
| 802 | 860 | } |
| 803 | - else |
|
| 804 | - $upcontext['username_incorrect'] = true; |
|
| 805 | 861 | $smcFunc['db_free_result']($request); |
| 806 | 862 | } |
| 807 | 863 | $upcontext['username'] = $_POST['user']; |
@@ -811,13 +867,14 @@ discard block |
||
| 811 | 867 | { |
| 812 | 868 | $upcontext['upgrade_status']['js'] = 1; |
| 813 | 869 | $support_js = 1; |
| 870 | + } else { |
|
| 871 | + $support_js = 0; |
|
| 814 | 872 | } |
| 815 | - else |
|
| 816 | - $support_js = 0; |
|
| 817 | 873 | |
| 818 | 874 | // Note down the version we are coming from. |
| 819 | - if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) |
|
| 820 | - $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
| 875 | + if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) { |
|
| 876 | + $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
| 877 | + } |
|
| 821 | 878 | |
| 822 | 879 | // Didn't get anywhere? |
| 823 | 880 | if (!$disable_security && (empty($sha_passwd) || (!empty($password) ? $password : '') != $sha_passwd) && !hash_verify_password((!empty($name) ? $name : ''), $_REQUEST['passwrd'], (!empty($password) ? $password : '')) && empty($upcontext['username_incorrect'])) |
@@ -851,15 +908,15 @@ discard block |
||
| 851 | 908 | 'db_error_skip' => true, |
| 852 | 909 | ) |
| 853 | 910 | ); |
| 854 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 855 | - return throw_error('You need to be an admin to perform an upgrade!'); |
|
| 911 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 912 | + return throw_error('You need to be an admin to perform an upgrade!'); |
|
| 913 | + } |
|
| 856 | 914 | $smcFunc['db_free_result']($request); |
| 857 | 915 | } |
| 858 | 916 | |
| 859 | 917 | $upcontext['user']['id'] = $id_member; |
| 860 | 918 | $upcontext['user']['name'] = $name; |
| 861 | - } |
|
| 862 | - else |
|
| 919 | + } else |
|
| 863 | 920 | { |
| 864 | 921 | $upcontext['user']['id'] = 1; |
| 865 | 922 | $upcontext['user']['name'] = 'Administrator'; |
@@ -875,11 +932,11 @@ discard block |
||
| 875 | 932 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096); |
| 876 | 933 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 877 | 934 | |
| 878 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 879 | - $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been updated to the latest version. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
| 880 | - elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) |
|
| 881 | - $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been uploaded/updated as the "Install" language file is missing. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
| 882 | - else |
|
| 935 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 936 | + $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been updated to the latest version. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
| 937 | + } elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) { |
|
| 938 | + $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been uploaded/updated as the "Install" language file is missing. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
| 939 | + } else |
|
| 883 | 940 | { |
| 884 | 941 | // Set this as the new language. |
| 885 | 942 | $upcontext['language'] = $user_language; |
@@ -923,8 +980,9 @@ discard block |
||
| 923 | 980 | unset($member_columns); |
| 924 | 981 | |
| 925 | 982 | // If we've not submitted then we're done. |
| 926 | - if (empty($_POST['upcont'])) |
|
| 927 | - return false; |
|
| 983 | + if (empty($_POST['upcont'])) { |
|
| 984 | + return false; |
|
| 985 | + } |
|
| 928 | 986 | |
| 929 | 987 | // Firstly, if they're enabling SM stat collection just do it. |
| 930 | 988 | if (!empty($_POST['stats']) && (substr($boardurl, 0, 16) != 'http://localhost' || substr($boardurl, 0, 16) != 'https://localhost') && empty($modSettings['allow_sm_stats'])) |
@@ -939,25 +997,26 @@ discard block |
||
| 939 | 997 | fwrite($fp, $out); |
| 940 | 998 | |
| 941 | 999 | $return_data = ''; |
| 942 | - while (!feof($fp)) |
|
| 943 | - $return_data .= fgets($fp, 128); |
|
| 1000 | + while (!feof($fp)) { |
|
| 1001 | + $return_data .= fgets($fp, 128); |
|
| 1002 | + } |
|
| 944 | 1003 | |
| 945 | 1004 | fclose($fp); |
| 946 | 1005 | |
| 947 | 1006 | // Get the unique site ID. |
| 948 | 1007 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
| 949 | 1008 | |
| 950 | - if (!empty($ID[1])) |
|
| 951 | - $smcFunc['db_insert']('replace', |
|
| 1009 | + if (!empty($ID[1])) { |
|
| 1010 | + $smcFunc['db_insert']('replace', |
|
| 952 | 1011 | $db_prefix . 'settings', |
| 953 | 1012 | array('variable' => 'string', 'value' => 'string'), |
| 954 | 1013 | array('allow_sm_stats', $ID[1]), |
| 955 | 1014 | array('variable') |
| 956 | 1015 | ); |
| 1016 | + } |
|
| 957 | 1017 | } |
| 958 | - } |
|
| 959 | - else |
|
| 960 | - $smcFunc['db_query']('', ' |
|
| 1018 | + } else { |
|
| 1019 | + $smcFunc['db_query']('', ' |
|
| 961 | 1020 | DELETE FROM {db_prefix}settings |
| 962 | 1021 | WHERE variable = {string:allow_sm_stats}', |
| 963 | 1022 | array( |
@@ -965,6 +1024,7 @@ discard block |
||
| 965 | 1024 | 'db_error_skip' => true, |
| 966 | 1025 | ) |
| 967 | 1026 | ); |
| 1027 | + } |
|
| 968 | 1028 | |
| 969 | 1029 | // Deleting old karma stuff? |
| 970 | 1030 | if (!empty($_POST['delete_karma'])) |
@@ -979,20 +1039,22 @@ discard block |
||
| 979 | 1039 | ); |
| 980 | 1040 | |
| 981 | 1041 | // Cleaning up old karma member settings. |
| 982 | - if ($upcontext['karma_installed']['good']) |
|
| 983 | - $smcFunc['db_query']('', ' |
|
| 1042 | + if ($upcontext['karma_installed']['good']) { |
|
| 1043 | + $smcFunc['db_query']('', ' |
|
| 984 | 1044 | ALTER TABLE {db_prefix}members |
| 985 | 1045 | DROP karma_good', |
| 986 | 1046 | array() |
| 987 | 1047 | ); |
| 1048 | + } |
|
| 988 | 1049 | |
| 989 | 1050 | // Does karma bad was enable? |
| 990 | - if ($upcontext['karma_installed']['bad']) |
|
| 991 | - $smcFunc['db_query']('', ' |
|
| 1051 | + if ($upcontext['karma_installed']['bad']) { |
|
| 1052 | + $smcFunc['db_query']('', ' |
|
| 992 | 1053 | ALTER TABLE {db_prefix}members |
| 993 | 1054 | DROP karma_bad', |
| 994 | 1055 | array() |
| 995 | 1056 | ); |
| 1057 | + } |
|
| 996 | 1058 | |
| 997 | 1059 | // Cleaning up old karma permissions. |
| 998 | 1060 | $smcFunc['db_query']('', ' |
@@ -1005,26 +1067,29 @@ discard block |
||
| 1005 | 1067 | } |
| 1006 | 1068 | |
| 1007 | 1069 | // Emptying the error log? |
| 1008 | - if (!empty($_POST['empty_error'])) |
|
| 1009 | - $smcFunc['db_query']('truncate_table', ' |
|
| 1070 | + if (!empty($_POST['empty_error'])) { |
|
| 1071 | + $smcFunc['db_query']('truncate_table', ' |
|
| 1010 | 1072 | TRUNCATE {db_prefix}log_errors', |
| 1011 | 1073 | array( |
| 1012 | 1074 | ) |
| 1013 | 1075 | ); |
| 1076 | + } |
|
| 1014 | 1077 | |
| 1015 | 1078 | $changes = array(); |
| 1016 | 1079 | |
| 1017 | 1080 | // Add proxy settings. |
| 1018 | - if (!isset($GLOBALS['image_proxy_maxsize'])) |
|
| 1019 | - $changes += array( |
|
| 1081 | + if (!isset($GLOBALS['image_proxy_maxsize'])) { |
|
| 1082 | + $changes += array( |
|
| 1020 | 1083 | 'image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'', |
| 1021 | 1084 | 'image_proxy_maxsize' => 5190, |
| 1022 | 1085 | 'image_proxy_enabled' => 0, |
| 1023 | 1086 | ); |
| 1087 | + } |
|
| 1024 | 1088 | |
| 1025 | 1089 | // If we're overriding the language follow it through. |
| 1026 | - if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) |
|
| 1027 | - $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
| 1090 | + if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) { |
|
| 1091 | + $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
| 1092 | + } |
|
| 1028 | 1093 | |
| 1029 | 1094 | if (!empty($_POST['maint'])) |
| 1030 | 1095 | { |
@@ -1036,30 +1101,34 @@ discard block |
||
| 1036 | 1101 | { |
| 1037 | 1102 | $changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\''; |
| 1038 | 1103 | $changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\''; |
| 1039 | - } |
|
| 1040 | - else |
|
| 1104 | + } else |
|
| 1041 | 1105 | { |
| 1042 | 1106 | $changes['mtitle'] = '\'Upgrading the forum...\''; |
| 1043 | 1107 | $changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum. It will only be a minute ;).\''; |
| 1044 | 1108 | } |
| 1045 | 1109 | } |
| 1046 | 1110 | |
| 1047 | - if ($command_line) |
|
| 1048 | - echo ' * Updating Settings.php...'; |
|
| 1111 | + if ($command_line) { |
|
| 1112 | + echo ' * Updating Settings.php...'; |
|
| 1113 | + } |
|
| 1049 | 1114 | |
| 1050 | 1115 | // Fix some old paths. |
| 1051 | - if (substr($boarddir, 0, 1) == '.') |
|
| 1052 | - $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
| 1116 | + if (substr($boarddir, 0, 1) == '.') { |
|
| 1117 | + $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
| 1118 | + } |
|
| 1053 | 1119 | |
| 1054 | - if (substr($sourcedir, 0, 1) == '.') |
|
| 1055 | - $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
| 1120 | + if (substr($sourcedir, 0, 1) == '.') { |
|
| 1121 | + $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
| 1122 | + } |
|
| 1056 | 1123 | |
| 1057 | - if (empty($cachedir) || substr($cachedir, 0, 1) == '.') |
|
| 1058 | - $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
| 1124 | + if (empty($cachedir) || substr($cachedir, 0, 1) == '.') { |
|
| 1125 | + $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
| 1126 | + } |
|
| 1059 | 1127 | |
| 1060 | 1128 | // Not had the database type added before? |
| 1061 | - if (empty($db_type)) |
|
| 1062 | - $changes['db_type'] = 'mysql'; |
|
| 1129 | + if (empty($db_type)) { |
|
| 1130 | + $changes['db_type'] = 'mysql'; |
|
| 1131 | + } |
|
| 1063 | 1132 | |
| 1064 | 1133 | // If they have a "host:port" setup for the host, split that into separate values |
| 1065 | 1134 | // You should never have a : in the hostname if you're not on MySQL, but better safe than sorry |
@@ -1070,32 +1139,36 @@ discard block |
||
| 1070 | 1139 | $changes['db_server'] = '\'' . $db_server . '\''; |
| 1071 | 1140 | |
| 1072 | 1141 | // Only set this if we're not using the default port |
| 1073 | - if ($db_port != ini_get('mysqli.default_port')) |
|
| 1074 | - $changes['db_port'] = (int) $db_port; |
|
| 1075 | - } |
|
| 1076 | - elseif (!empty($db_port)) |
|
| 1142 | + if ($db_port != ini_get('mysqli.default_port')) { |
|
| 1143 | + $changes['db_port'] = (int) $db_port; |
|
| 1144 | + } |
|
| 1145 | + } elseif (!empty($db_port)) |
|
| 1077 | 1146 | { |
| 1078 | 1147 | // If db_port is set and is the same as the default, set it to '' |
| 1079 | 1148 | if ($db_type == 'mysql') |
| 1080 | 1149 | { |
| 1081 | - if ($db_port == ini_get('mysqli.default_port')) |
|
| 1082 | - $changes['db_port'] = '\'\''; |
|
| 1083 | - elseif ($db_type == 'postgresql' && $db_port == 5432) |
|
| 1084 | - $changes['db_port'] = '\'\''; |
|
| 1150 | + if ($db_port == ini_get('mysqli.default_port')) { |
|
| 1151 | + $changes['db_port'] = '\'\''; |
|
| 1152 | + } elseif ($db_type == 'postgresql' && $db_port == 5432) { |
|
| 1153 | + $changes['db_port'] = '\'\''; |
|
| 1154 | + } |
|
| 1085 | 1155 | } |
| 1086 | 1156 | } |
| 1087 | 1157 | |
| 1088 | 1158 | // Maybe we haven't had this option yet? |
| 1089 | - if (empty($packagesdir)) |
|
| 1090 | - $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
| 1159 | + if (empty($packagesdir)) { |
|
| 1160 | + $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
| 1161 | + } |
|
| 1091 | 1162 | |
| 1092 | 1163 | // Add support for $tasksdir var. |
| 1093 | - if (empty($tasksdir)) |
|
| 1094 | - $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
| 1164 | + if (empty($tasksdir)) { |
|
| 1165 | + $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
| 1166 | + } |
|
| 1095 | 1167 | |
| 1096 | 1168 | // Make sure we fix the language as well. |
| 1097 | - if (stristr($language, '-utf8')) |
|
| 1098 | - $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
| 1169 | + if (stristr($language, '-utf8')) { |
|
| 1170 | + $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
| 1171 | + } |
|
| 1099 | 1172 | |
| 1100 | 1173 | // @todo Maybe change the cookie name if going to 1.1, too? |
| 1101 | 1174 | |
@@ -1103,8 +1176,9 @@ discard block |
||
| 1103 | 1176 | require_once($sourcedir . '/Subs-Admin.php'); |
| 1104 | 1177 | updateSettingsFile($changes); |
| 1105 | 1178 | |
| 1106 | - if ($command_line) |
|
| 1107 | - echo ' Successful.' . "\n"; |
|
| 1179 | + if ($command_line) { |
|
| 1180 | + echo ' Successful.' . "\n"; |
|
| 1181 | + } |
|
| 1108 | 1182 | |
| 1109 | 1183 | // Are we doing debug? |
| 1110 | 1184 | if (isset($_POST['debug'])) |
@@ -1114,8 +1188,9 @@ discard block |
||
| 1114 | 1188 | } |
| 1115 | 1189 | |
| 1116 | 1190 | // If we're not backing up then jump one. |
| 1117 | - if (empty($_POST['backup'])) |
|
| 1118 | - $upcontext['current_step']++; |
|
| 1191 | + if (empty($_POST['backup'])) { |
|
| 1192 | + $upcontext['current_step']++; |
|
| 1193 | + } |
|
| 1119 | 1194 | |
| 1120 | 1195 | // If we've got here then let's proceed to the next step! |
| 1121 | 1196 | return true; |
@@ -1130,8 +1205,9 @@ discard block |
||
| 1130 | 1205 | $upcontext['page_title'] = 'Backup Database'; |
| 1131 | 1206 | |
| 1132 | 1207 | // Done it already - js wise? |
| 1133 | - if (!empty($_POST['backup_done'])) |
|
| 1134 | - return true; |
|
| 1208 | + if (!empty($_POST['backup_done'])) { |
|
| 1209 | + return true; |
|
| 1210 | + } |
|
| 1135 | 1211 | |
| 1136 | 1212 | // Some useful stuff here. |
| 1137 | 1213 | db_extend(); |
@@ -1145,9 +1221,10 @@ discard block |
||
| 1145 | 1221 | $tables = $smcFunc['db_list_tables']($db, $filter); |
| 1146 | 1222 | |
| 1147 | 1223 | $table_names = array(); |
| 1148 | - foreach ($tables as $table) |
|
| 1149 | - if (substr($table, 0, 7) !== 'backup_') |
|
| 1224 | + foreach ($tables as $table) { |
|
| 1225 | + if (substr($table, 0, 7) !== 'backup_') |
|
| 1150 | 1226 | $table_names[] = $table; |
| 1227 | + } |
|
| 1151 | 1228 | |
| 1152 | 1229 | $upcontext['table_count'] = count($table_names); |
| 1153 | 1230 | $upcontext['cur_table_num'] = $_GET['substep']; |
@@ -1157,12 +1234,14 @@ discard block |
||
| 1157 | 1234 | $file_steps = $upcontext['table_count']; |
| 1158 | 1235 | |
| 1159 | 1236 | // What ones have we already done? |
| 1160 | - foreach ($table_names as $id => $table) |
|
| 1161 | - if ($id < $_GET['substep']) |
|
| 1237 | + foreach ($table_names as $id => $table) { |
|
| 1238 | + if ($id < $_GET['substep']) |
|
| 1162 | 1239 | $upcontext['previous_tables'][] = $table; |
| 1240 | + } |
|
| 1163 | 1241 | |
| 1164 | - if ($command_line) |
|
| 1165 | - echo 'Backing Up Tables.'; |
|
| 1242 | + if ($command_line) { |
|
| 1243 | + echo 'Backing Up Tables.'; |
|
| 1244 | + } |
|
| 1166 | 1245 | |
| 1167 | 1246 | // If we don't support javascript we backup here. |
| 1168 | 1247 | if (!$support_js || isset($_GET['xml'])) |
@@ -1181,8 +1260,9 @@ discard block |
||
| 1181 | 1260 | backupTable($table_names[$substep]); |
| 1182 | 1261 | |
| 1183 | 1262 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 1184 | - if (isset($_GET['xml'])) |
|
| 1185 | - return upgradeExit(); |
|
| 1263 | + if (isset($_GET['xml'])) { |
|
| 1264 | + return upgradeExit(); |
|
| 1265 | + } |
|
| 1186 | 1266 | } |
| 1187 | 1267 | |
| 1188 | 1268 | if ($command_line) |
@@ -1215,9 +1295,10 @@ discard block |
||
| 1215 | 1295 | |
| 1216 | 1296 | $smcFunc['db_backup_table']($table, 'backup_' . $table); |
| 1217 | 1297 | |
| 1218 | - if ($command_line) |
|
| 1219 | - echo ' done.'; |
|
| 1220 | -} |
|
| 1298 | + if ($command_line) { |
|
| 1299 | + echo ' done.'; |
|
| 1300 | + } |
|
| 1301 | + } |
|
| 1221 | 1302 | |
| 1222 | 1303 | // Step 2: Everything. |
| 1223 | 1304 | function DatabaseChanges() |
@@ -1226,8 +1307,9 @@ discard block |
||
| 1226 | 1307 | global $upcontext, $support_js, $db_type; |
| 1227 | 1308 | |
| 1228 | 1309 | // Have we just completed this? |
| 1229 | - if (!empty($_POST['database_done'])) |
|
| 1230 | - return true; |
|
| 1310 | + if (!empty($_POST['database_done'])) { |
|
| 1311 | + return true; |
|
| 1312 | + } |
|
| 1231 | 1313 | |
| 1232 | 1314 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes'; |
| 1233 | 1315 | $upcontext['page_title'] = 'Database Changes'; |
@@ -1242,15 +1324,16 @@ discard block |
||
| 1242 | 1324 | ); |
| 1243 | 1325 | |
| 1244 | 1326 | // How many files are there in total? |
| 1245 | - if (isset($_GET['filecount'])) |
|
| 1246 | - $upcontext['file_count'] = (int) $_GET['filecount']; |
|
| 1247 | - else |
|
| 1327 | + if (isset($_GET['filecount'])) { |
|
| 1328 | + $upcontext['file_count'] = (int) $_GET['filecount']; |
|
| 1329 | + } else |
|
| 1248 | 1330 | { |
| 1249 | 1331 | $upcontext['file_count'] = 0; |
| 1250 | 1332 | foreach ($files as $file) |
| 1251 | 1333 | { |
| 1252 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) |
|
| 1253 | - $upcontext['file_count']++; |
|
| 1334 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) { |
|
| 1335 | + $upcontext['file_count']++; |
|
| 1336 | + } |
|
| 1254 | 1337 | } |
| 1255 | 1338 | } |
| 1256 | 1339 | |
@@ -1260,9 +1343,9 @@ discard block |
||
| 1260 | 1343 | $upcontext['cur_file_num'] = 0; |
| 1261 | 1344 | foreach ($files as $file) |
| 1262 | 1345 | { |
| 1263 | - if ($did_not_do) |
|
| 1264 | - $did_not_do--; |
|
| 1265 | - else |
|
| 1346 | + if ($did_not_do) { |
|
| 1347 | + $did_not_do--; |
|
| 1348 | + } else |
|
| 1266 | 1349 | { |
| 1267 | 1350 | $upcontext['cur_file_num']++; |
| 1268 | 1351 | $upcontext['cur_file_name'] = $file[0]; |
@@ -1289,12 +1372,13 @@ discard block |
||
| 1289 | 1372 | // Flag to move on to the next. |
| 1290 | 1373 | $upcontext['completed_step'] = true; |
| 1291 | 1374 | // Did we complete the whole file? |
| 1292 | - if ($nextFile) |
|
| 1293 | - $upcontext['current_debug_item_num'] = -1; |
|
| 1375 | + if ($nextFile) { |
|
| 1376 | + $upcontext['current_debug_item_num'] = -1; |
|
| 1377 | + } |
|
| 1294 | 1378 | return upgradeExit(); |
| 1379 | + } elseif ($support_js) { |
|
| 1380 | + break; |
|
| 1295 | 1381 | } |
| 1296 | - elseif ($support_js) |
|
| 1297 | - break; |
|
| 1298 | 1382 | } |
| 1299 | 1383 | // Set the progress bar to be right as if we had - even if we hadn't... |
| 1300 | 1384 | $upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100; |
@@ -1319,8 +1403,9 @@ discard block |
||
| 1319 | 1403 | global $command_line, $language, $upcontext, $sourcedir, $forum_version, $user_info, $maintenance, $smcFunc, $db_type; |
| 1320 | 1404 | |
| 1321 | 1405 | // Now it's nice to have some of the basic SMF source files. |
| 1322 | - if (!isset($_GET['ssi']) && !$command_line) |
|
| 1323 | - redirectLocation('&ssi=1'); |
|
| 1406 | + if (!isset($_GET['ssi']) && !$command_line) { |
|
| 1407 | + redirectLocation('&ssi=1'); |
|
| 1408 | + } |
|
| 1324 | 1409 | |
| 1325 | 1410 | $upcontext['sub_template'] = 'upgrade_complete'; |
| 1326 | 1411 | $upcontext['page_title'] = 'Upgrade Complete'; |
@@ -1336,14 +1421,16 @@ discard block |
||
| 1336 | 1421 | // Are we in maintenance mode? |
| 1337 | 1422 | if (isset($upcontext['user']['main'])) |
| 1338 | 1423 | { |
| 1339 | - if ($command_line) |
|
| 1340 | - echo ' * '; |
|
| 1424 | + if ($command_line) { |
|
| 1425 | + echo ' * '; |
|
| 1426 | + } |
|
| 1341 | 1427 | $upcontext['removed_maintenance'] = true; |
| 1342 | 1428 | $changes['maintenance'] = $upcontext['user']['main']; |
| 1343 | 1429 | } |
| 1344 | 1430 | // Otherwise if somehow we are in 2 let's go to 1. |
| 1345 | - elseif (!empty($maintenance) && $maintenance == 2) |
|
| 1346 | - $changes['maintenance'] = 1; |
|
| 1431 | + elseif (!empty($maintenance) && $maintenance == 2) { |
|
| 1432 | + $changes['maintenance'] = 1; |
|
| 1433 | + } |
|
| 1347 | 1434 | |
| 1348 | 1435 | // Wipe this out... |
| 1349 | 1436 | $upcontext['user'] = array(); |
@@ -1358,9 +1445,9 @@ discard block |
||
| 1358 | 1445 | $upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__); |
| 1359 | 1446 | |
| 1360 | 1447 | // Now is the perfect time to fetch the SM files. |
| 1361 | - if ($command_line) |
|
| 1362 | - cli_scheduled_fetchSMfiles(); |
|
| 1363 | - else |
|
| 1448 | + if ($command_line) { |
|
| 1449 | + cli_scheduled_fetchSMfiles(); |
|
| 1450 | + } else |
|
| 1364 | 1451 | { |
| 1365 | 1452 | require_once($sourcedir . '/ScheduledTasks.php'); |
| 1366 | 1453 | $forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us. |
@@ -1368,8 +1455,9 @@ discard block |
||
| 1368 | 1455 | } |
| 1369 | 1456 | |
| 1370 | 1457 | // Log what we've done. |
| 1371 | - if (empty($user_info['id'])) |
|
| 1372 | - $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
| 1458 | + if (empty($user_info['id'])) { |
|
| 1459 | + $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
| 1460 | + } |
|
| 1373 | 1461 | |
| 1374 | 1462 | // Log the action manually, so CLI still works. |
| 1375 | 1463 | $smcFunc['db_insert']('', |
@@ -1388,8 +1476,9 @@ discard block |
||
| 1388 | 1476 | |
| 1389 | 1477 | // Save the current database version. |
| 1390 | 1478 | $server_version = $smcFunc['db_server_info'](); |
| 1391 | - if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
| 1392 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1479 | + if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
| 1480 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1481 | + } |
|
| 1393 | 1482 | |
| 1394 | 1483 | if ($command_line) |
| 1395 | 1484 | { |
@@ -1401,8 +1490,9 @@ discard block |
||
| 1401 | 1490 | |
| 1402 | 1491 | // Make sure it says we're done. |
| 1403 | 1492 | $upcontext['overall_percent'] = 100; |
| 1404 | - if (isset($upcontext['step_progress'])) |
|
| 1405 | - unset($upcontext['step_progress']); |
|
| 1493 | + if (isset($upcontext['step_progress'])) { |
|
| 1494 | + unset($upcontext['step_progress']); |
|
| 1495 | + } |
|
| 1406 | 1496 | |
| 1407 | 1497 | $_GET['substep'] = 0; |
| 1408 | 1498 | return false; |
@@ -1413,8 +1503,9 @@ discard block |
||
| 1413 | 1503 | { |
| 1414 | 1504 | global $sourcedir, $language, $forum_version, $modSettings, $smcFunc; |
| 1415 | 1505 | |
| 1416 | - if (empty($modSettings['time_format'])) |
|
| 1417 | - $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
| 1506 | + if (empty($modSettings['time_format'])) { |
|
| 1507 | + $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
| 1508 | + } |
|
| 1418 | 1509 | |
| 1419 | 1510 | // What files do we want to get |
| 1420 | 1511 | $request = $smcFunc['db_query']('', ' |
@@ -1448,8 +1539,9 @@ discard block |
||
| 1448 | 1539 | $file_data = fetch_web_data($url); |
| 1449 | 1540 | |
| 1450 | 1541 | // If we got an error - give up - the site might be down. |
| 1451 | - if ($file_data === false) |
|
| 1452 | - return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
| 1542 | + if ($file_data === false) { |
|
| 1543 | + return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
| 1544 | + } |
|
| 1453 | 1545 | |
| 1454 | 1546 | // Save the file to the database. |
| 1455 | 1547 | $smcFunc['db_query']('substring', ' |
@@ -1491,8 +1583,9 @@ discard block |
||
| 1491 | 1583 | $themeData = array(); |
| 1492 | 1584 | foreach ($values as $variable => $value) |
| 1493 | 1585 | { |
| 1494 | - if (!isset($value) || $value === null) |
|
| 1495 | - $value = 0; |
|
| 1586 | + if (!isset($value) || $value === null) { |
|
| 1587 | + $value = 0; |
|
| 1588 | + } |
|
| 1496 | 1589 | |
| 1497 | 1590 | $themeData[] = array(0, 1, $variable, $value); |
| 1498 | 1591 | } |
@@ -1521,8 +1614,9 @@ discard block |
||
| 1521 | 1614 | |
| 1522 | 1615 | foreach ($values as $variable => $value) |
| 1523 | 1616 | { |
| 1524 | - if (empty($modSettings[$value[0]])) |
|
| 1525 | - continue; |
|
| 1617 | + if (empty($modSettings[$value[0]])) { |
|
| 1618 | + continue; |
|
| 1619 | + } |
|
| 1526 | 1620 | |
| 1527 | 1621 | $smcFunc['db_query']('', ' |
| 1528 | 1622 | INSERT IGNORE INTO {db_prefix}themes |
@@ -1608,19 +1702,21 @@ discard block |
||
| 1608 | 1702 | set_error_handler( |
| 1609 | 1703 | function ($errno, $errstr, $errfile, $errline) use ($support_js) |
| 1610 | 1704 | { |
| 1611 | - if ($support_js) |
|
| 1612 | - return true; |
|
| 1613 | - else |
|
| 1614 | - echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
| 1705 | + if ($support_js) { |
|
| 1706 | + return true; |
|
| 1707 | + } else { |
|
| 1708 | + echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
| 1709 | + } |
|
| 1615 | 1710 | } |
| 1616 | 1711 | ); |
| 1617 | 1712 | |
| 1618 | 1713 | // If we're on MySQL, set {db_collation}; this approach is used throughout upgrade_2-0_mysql.php to set new tables to utf8 |
| 1619 | 1714 | // Note it is expected to be in the format: ENGINE=MyISAM{$db_collation}; |
| 1620 | - if ($db_type == 'mysql') |
|
| 1621 | - $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
| 1622 | - else |
|
| 1623 | - $db_collation = ''; |
|
| 1715 | + if ($db_type == 'mysql') { |
|
| 1716 | + $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
| 1717 | + } else { |
|
| 1718 | + $db_collation = ''; |
|
| 1719 | + } |
|
| 1624 | 1720 | |
| 1625 | 1721 | $endl = $command_line ? "\n" : '<br>' . "\n"; |
| 1626 | 1722 | |
@@ -1632,8 +1728,9 @@ discard block |
||
| 1632 | 1728 | $last_step = ''; |
| 1633 | 1729 | |
| 1634 | 1730 | // Make sure all newly created tables will have the proper characters set; this approach is used throughout upgrade_2-1_mysql.php |
| 1635 | - if (isset($db_character_set) && $db_character_set === 'utf8') |
|
| 1636 | - $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
| 1731 | + if (isset($db_character_set) && $db_character_set === 'utf8') { |
|
| 1732 | + $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
| 1733 | + } |
|
| 1637 | 1734 | |
| 1638 | 1735 | // Count the total number of steps within this file - for progress. |
| 1639 | 1736 | $file_steps = substr_count(implode('', $lines), '---#'); |
@@ -1653,15 +1750,18 @@ discard block |
||
| 1653 | 1750 | $do_current = $substep >= $_GET['substep']; |
| 1654 | 1751 | |
| 1655 | 1752 | // Get rid of any comments in the beginning of the line... |
| 1656 | - if (substr(trim($line), 0, 2) === '/*') |
|
| 1657 | - $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
| 1753 | + if (substr(trim($line), 0, 2) === '/*') { |
|
| 1754 | + $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
| 1755 | + } |
|
| 1658 | 1756 | |
| 1659 | 1757 | // Always flush. Flush, flush, flush. Flush, flush, flush, flush! FLUSH! |
| 1660 | - if ($is_debug && !$support_js && $command_line) |
|
| 1661 | - flush(); |
|
| 1758 | + if ($is_debug && !$support_js && $command_line) { |
|
| 1759 | + flush(); |
|
| 1760 | + } |
|
| 1662 | 1761 | |
| 1663 | - if (trim($line) === '') |
|
| 1664 | - continue; |
|
| 1762 | + if (trim($line) === '') { |
|
| 1763 | + continue; |
|
| 1764 | + } |
|
| 1665 | 1765 | |
| 1666 | 1766 | if (trim(substr($line, 0, 3)) === '---') |
| 1667 | 1767 | { |
@@ -1671,8 +1771,9 @@ discard block |
||
| 1671 | 1771 | if (trim($current_data) != '' && $type !== '}') |
| 1672 | 1772 | { |
| 1673 | 1773 | $upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl; |
| 1674 | - if ($command_line) |
|
| 1675 | - echo $upcontext['error_message']; |
|
| 1774 | + if ($command_line) { |
|
| 1775 | + echo $upcontext['error_message']; |
|
| 1776 | + } |
|
| 1676 | 1777 | } |
| 1677 | 1778 | |
| 1678 | 1779 | if ($type == ' ') |
@@ -1690,17 +1791,18 @@ discard block |
||
| 1690 | 1791 | if ($do_current) |
| 1691 | 1792 | { |
| 1692 | 1793 | $upcontext['actioned_items'][] = $last_step; |
| 1693 | - if ($command_line) |
|
| 1694 | - echo ' * '; |
|
| 1794 | + if ($command_line) { |
|
| 1795 | + echo ' * '; |
|
| 1796 | + } |
|
| 1695 | 1797 | } |
| 1696 | - } |
|
| 1697 | - elseif ($type == '#') |
|
| 1798 | + } elseif ($type == '#') |
|
| 1698 | 1799 | { |
| 1699 | 1800 | $upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps; |
| 1700 | 1801 | |
| 1701 | 1802 | $upcontext['current_debug_item_num']++; |
| 1702 | - if (trim($line) != '---#') |
|
| 1703 | - $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1803 | + if (trim($line) != '---#') { |
|
| 1804 | + $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1805 | + } |
|
| 1704 | 1806 | |
| 1705 | 1807 | // Have we already done something? |
| 1706 | 1808 | if (isset($_GET['xml']) && $done_something) |
@@ -1711,34 +1813,36 @@ discard block |
||
| 1711 | 1813 | |
| 1712 | 1814 | if ($do_current) |
| 1713 | 1815 | { |
| 1714 | - if (trim($line) == '---#' && $command_line) |
|
| 1715 | - echo ' done.', $endl; |
|
| 1716 | - elseif ($command_line) |
|
| 1717 | - echo ' +++ ', rtrim(substr($line, 4)); |
|
| 1718 | - elseif (trim($line) != '---#') |
|
| 1816 | + if (trim($line) == '---#' && $command_line) { |
|
| 1817 | + echo ' done.', $endl; |
|
| 1818 | + } elseif ($command_line) { |
|
| 1819 | + echo ' +++ ', rtrim(substr($line, 4)); |
|
| 1820 | + } elseif (trim($line) != '---#') |
|
| 1719 | 1821 | { |
| 1720 | - if ($is_debug) |
|
| 1721 | - $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1822 | + if ($is_debug) { |
|
| 1823 | + $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1824 | + } |
|
| 1722 | 1825 | } |
| 1723 | 1826 | } |
| 1724 | 1827 | |
| 1725 | 1828 | if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep']) |
| 1726 | 1829 | { |
| 1727 | - if ($command_line) |
|
| 1728 | - echo ' * '; |
|
| 1729 | - else |
|
| 1730 | - $upcontext['actioned_items'][] = $last_step; |
|
| 1830 | + if ($command_line) { |
|
| 1831 | + echo ' * '; |
|
| 1832 | + } else { |
|
| 1833 | + $upcontext['actioned_items'][] = $last_step; |
|
| 1834 | + } |
|
| 1731 | 1835 | } |
| 1732 | 1836 | |
| 1733 | 1837 | // Small step - only if we're actually doing stuff. |
| 1734 | - if ($do_current) |
|
| 1735 | - nextSubstep(++$substep); |
|
| 1736 | - else |
|
| 1737 | - $substep++; |
|
| 1738 | - } |
|
| 1739 | - elseif ($type == '{') |
|
| 1740 | - $current_type = 'code'; |
|
| 1741 | - elseif ($type == '}') |
|
| 1838 | + if ($do_current) { |
|
| 1839 | + nextSubstep(++$substep); |
|
| 1840 | + } else { |
|
| 1841 | + $substep++; |
|
| 1842 | + } |
|
| 1843 | + } elseif ($type == '{') { |
|
| 1844 | + $current_type = 'code'; |
|
| 1845 | + } elseif ($type == '}') |
|
| 1742 | 1846 | { |
| 1743 | 1847 | $current_type = 'sql'; |
| 1744 | 1848 | |
@@ -1751,8 +1855,9 @@ discard block |
||
| 1751 | 1855 | if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false) |
| 1752 | 1856 | { |
| 1753 | 1857 | $upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl; |
| 1754 | - if ($command_line) |
|
| 1755 | - echo $upcontext['error_message']; |
|
| 1858 | + if ($command_line) { |
|
| 1859 | + echo $upcontext['error_message']; |
|
| 1860 | + } |
|
| 1756 | 1861 | } |
| 1757 | 1862 | |
| 1758 | 1863 | // Done with code! |
@@ -1832,8 +1937,9 @@ discard block |
||
| 1832 | 1937 | $db_unbuffered = false; |
| 1833 | 1938 | |
| 1834 | 1939 | // Failure?! |
| 1835 | - if ($result !== false) |
|
| 1836 | - return $result; |
|
| 1940 | + if ($result !== false) { |
|
| 1941 | + return $result; |
|
| 1942 | + } |
|
| 1837 | 1943 | |
| 1838 | 1944 | $db_error_message = $smcFunc['db_error']($db_connection); |
| 1839 | 1945 | // If MySQL we do something more clever. |
@@ -1861,54 +1967,61 @@ discard block |
||
| 1861 | 1967 | { |
| 1862 | 1968 | mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`'); |
| 1863 | 1969 | $result = mysqli_query($db_connection, $string); |
| 1864 | - if ($result !== false) |
|
| 1865 | - return $result; |
|
| 1970 | + if ($result !== false) { |
|
| 1971 | + return $result; |
|
| 1972 | + } |
|
| 1866 | 1973 | } |
| 1867 | - } |
|
| 1868 | - elseif ($mysqli_errno == 2013) |
|
| 1974 | + } elseif ($mysqli_errno == 2013) |
|
| 1869 | 1975 | { |
| 1870 | 1976 | $db_connection = mysqli_connect($db_server, $db_user, $db_passwd); |
| 1871 | 1977 | mysqli_select_db($db_connection, $db_name); |
| 1872 | 1978 | if ($db_connection) |
| 1873 | 1979 | { |
| 1874 | 1980 | $result = mysqli_query($db_connection, $string); |
| 1875 | - if ($result !== false) |
|
| 1876 | - return $result; |
|
| 1981 | + if ($result !== false) { |
|
| 1982 | + return $result; |
|
| 1983 | + } |
|
| 1877 | 1984 | } |
| 1878 | 1985 | } |
| 1879 | 1986 | // Duplicate column name... should be okay ;). |
| 1880 | - elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) |
|
| 1881 | - return false; |
|
| 1987 | + elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) { |
|
| 1988 | + return false; |
|
| 1989 | + } |
|
| 1882 | 1990 | // Duplicate insert... make sure it's the proper type of query ;). |
| 1883 | - elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) |
|
| 1884 | - return false; |
|
| 1991 | + elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) { |
|
| 1992 | + return false; |
|
| 1993 | + } |
|
| 1885 | 1994 | // Creating an index on a non-existent column. |
| 1886 | - elseif ($mysqli_errno == 1072) |
|
| 1887 | - return false; |
|
| 1888 | - elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') |
|
| 1889 | - return false; |
|
| 1995 | + elseif ($mysqli_errno == 1072) { |
|
| 1996 | + return false; |
|
| 1997 | + } elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') { |
|
| 1998 | + return false; |
|
| 1999 | + } |
|
| 1890 | 2000 | } |
| 1891 | 2001 | // If a table already exists don't go potty. |
| 1892 | 2002 | else |
| 1893 | 2003 | { |
| 1894 | 2004 | if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U'))) |
| 1895 | 2005 | { |
| 1896 | - if (strpos($db_error_message, 'exist') !== false) |
|
| 1897 | - return true; |
|
| 1898 | - } |
|
| 1899 | - elseif (strpos(trim($string), 'INSERT ') !== false) |
|
| 2006 | + if (strpos($db_error_message, 'exist') !== false) { |
|
| 2007 | + return true; |
|
| 2008 | + } |
|
| 2009 | + } elseif (strpos(trim($string), 'INSERT ') !== false) |
|
| 1900 | 2010 | { |
| 1901 | - if (strpos($db_error_message, 'duplicate') !== false) |
|
| 1902 | - return true; |
|
| 2011 | + if (strpos($db_error_message, 'duplicate') !== false) { |
|
| 2012 | + return true; |
|
| 2013 | + } |
|
| 1903 | 2014 | } |
| 1904 | 2015 | } |
| 1905 | 2016 | |
| 1906 | 2017 | // Get the query string so we pass everything. |
| 1907 | 2018 | $query_string = ''; |
| 1908 | - foreach ($_GET as $k => $v) |
|
| 1909 | - $query_string .= ';' . $k . '=' . $v; |
|
| 1910 | - if (strlen($query_string) != 0) |
|
| 1911 | - $query_string = '?' . substr($query_string, 1); |
|
| 2019 | + foreach ($_GET as $k => $v) { |
|
| 2020 | + $query_string .= ';' . $k . '=' . $v; |
|
| 2021 | + } |
|
| 2022 | + if (strlen($query_string) != 0) { |
|
| 2023 | + $query_string = '?' . substr($query_string, 1); |
|
| 2024 | + } |
|
| 1912 | 2025 | |
| 1913 | 2026 | if ($command_line) |
| 1914 | 2027 | { |
@@ -1963,16 +2076,18 @@ discard block |
||
| 1963 | 2076 | { |
| 1964 | 2077 | $found |= 1; |
| 1965 | 2078 | // Do some checks on the data if we have it set. |
| 1966 | - if (isset($change['col_type'])) |
|
| 1967 | - $found &= $change['col_type'] === $column['type']; |
|
| 1968 | - if (isset($change['null_allowed'])) |
|
| 1969 | - $found &= $column['null'] == $change['null_allowed']; |
|
| 1970 | - if (isset($change['default'])) |
|
| 1971 | - $found &= $change['default'] === $column['default']; |
|
| 2079 | + if (isset($change['col_type'])) { |
|
| 2080 | + $found &= $change['col_type'] === $column['type']; |
|
| 2081 | + } |
|
| 2082 | + if (isset($change['null_allowed'])) { |
|
| 2083 | + $found &= $column['null'] == $change['null_allowed']; |
|
| 2084 | + } |
|
| 2085 | + if (isset($change['default'])) { |
|
| 2086 | + $found &= $change['default'] === $column['default']; |
|
| 2087 | + } |
|
| 1972 | 2088 | } |
| 1973 | 2089 | } |
| 1974 | - } |
|
| 1975 | - elseif ($change['type'] === 'index') |
|
| 2090 | + } elseif ($change['type'] === 'index') |
|
| 1976 | 2091 | { |
| 1977 | 2092 | $request = upgrade_query(' |
| 1978 | 2093 | SHOW INDEX |
@@ -1981,9 +2096,10 @@ discard block |
||
| 1981 | 2096 | { |
| 1982 | 2097 | $cur_index = array(); |
| 1983 | 2098 | |
| 1984 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1985 | - if ($row['Key_name'] === $change['name']) |
|
| 2099 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2100 | + if ($row['Key_name'] === $change['name']) |
|
| 1986 | 2101 | $cur_index[(int) $row['Seq_in_index']] = $row['Column_name']; |
| 2102 | + } |
|
| 1987 | 2103 | |
| 1988 | 2104 | ksort($cur_index, SORT_NUMERIC); |
| 1989 | 2105 | $found = array_values($cur_index) === $change['target_columns']; |
@@ -1993,14 +2109,17 @@ discard block |
||
| 1993 | 2109 | } |
| 1994 | 2110 | |
| 1995 | 2111 | // If we're trying to add and it's added, we're done. |
| 1996 | - if ($found && in_array($change['method'], array('add', 'change'))) |
|
| 1997 | - return true; |
|
| 2112 | + if ($found && in_array($change['method'], array('add', 'change'))) { |
|
| 2113 | + return true; |
|
| 2114 | + } |
|
| 1998 | 2115 | // Otherwise if we're removing and it wasn't found we're also done. |
| 1999 | - elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) |
|
| 2000 | - return true; |
|
| 2116 | + elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) { |
|
| 2117 | + return true; |
|
| 2118 | + } |
|
| 2001 | 2119 | // Otherwise is it just a test? |
| 2002 | - elseif ($is_test) |
|
| 2003 | - return false; |
|
| 2120 | + elseif ($is_test) { |
|
| 2121 | + return false; |
|
| 2122 | + } |
|
| 2004 | 2123 | |
| 2005 | 2124 | // Not found it yet? Bummer! How about we see if we're currently doing it? |
| 2006 | 2125 | $running = false; |
@@ -2011,8 +2130,9 @@ discard block |
||
| 2011 | 2130 | SHOW FULL PROCESSLIST'); |
| 2012 | 2131 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2013 | 2132 | { |
| 2014 | - if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) |
|
| 2015 | - $found = true; |
|
| 2133 | + if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) { |
|
| 2134 | + $found = true; |
|
| 2135 | + } |
|
| 2016 | 2136 | } |
| 2017 | 2137 | |
| 2018 | 2138 | // Can't find it? Then we need to run it fools! |
@@ -2024,8 +2144,9 @@ discard block |
||
| 2024 | 2144 | ALTER TABLE ' . $db_prefix . $change['table'] . ' |
| 2025 | 2145 | ' . $change['text'], true) !== false; |
| 2026 | 2146 | |
| 2027 | - if (!$success) |
|
| 2028 | - return false; |
|
| 2147 | + if (!$success) { |
|
| 2148 | + return false; |
|
| 2149 | + } |
|
| 2029 | 2150 | |
| 2030 | 2151 | // Return |
| 2031 | 2152 | $running = true; |
@@ -2067,8 +2188,9 @@ discard block |
||
| 2067 | 2188 | 'db_error_skip' => true, |
| 2068 | 2189 | ) |
| 2069 | 2190 | ); |
| 2070 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2071 | - die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
| 2191 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2192 | + die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
| 2193 | + } |
|
| 2072 | 2194 | $table_row = $smcFunc['db_fetch_assoc']($request); |
| 2073 | 2195 | $smcFunc['db_free_result']($request); |
| 2074 | 2196 | |
@@ -2090,18 +2212,19 @@ discard block |
||
| 2090 | 2212 | ) |
| 2091 | 2213 | ); |
| 2092 | 2214 | // No results? Just forget it all together. |
| 2093 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2094 | - unset($table_row['Collation']); |
|
| 2095 | - else |
|
| 2096 | - $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2215 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2216 | + unset($table_row['Collation']); |
|
| 2217 | + } else { |
|
| 2218 | + $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2219 | + } |
|
| 2097 | 2220 | $smcFunc['db_free_result']($request); |
| 2098 | 2221 | } |
| 2099 | 2222 | |
| 2100 | 2223 | if ($column_fix) |
| 2101 | 2224 | { |
| 2102 | 2225 | // Make sure there are no NULL's left. |
| 2103 | - if ($null_fix) |
|
| 2104 | - $smcFunc['db_query']('', ' |
|
| 2226 | + if ($null_fix) { |
|
| 2227 | + $smcFunc['db_query']('', ' |
|
| 2105 | 2228 | UPDATE {db_prefix}' . $change['table'] . ' |
| 2106 | 2229 | SET ' . $change['column'] . ' = {string:default} |
| 2107 | 2230 | WHERE ' . $change['column'] . ' IS NULL', |
@@ -2110,6 +2233,7 @@ discard block |
||
| 2110 | 2233 | 'db_error_skip' => true, |
| 2111 | 2234 | ) |
| 2112 | 2235 | ); |
| 2236 | + } |
|
| 2113 | 2237 | |
| 2114 | 2238 | // Do the actual alteration. |
| 2115 | 2239 | $smcFunc['db_query']('', ' |
@@ -2138,8 +2262,9 @@ discard block |
||
| 2138 | 2262 | } |
| 2139 | 2263 | |
| 2140 | 2264 | // Not a column we need to check on? |
| 2141 | - if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) |
|
| 2142 | - return; |
|
| 2265 | + if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) { |
|
| 2266 | + return; |
|
| 2267 | + } |
|
| 2143 | 2268 | |
| 2144 | 2269 | // Break it up you (six|seven). |
| 2145 | 2270 | $temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text'])); |
@@ -2158,13 +2283,13 @@ discard block |
||
| 2158 | 2283 | 'new_name' => $temp[2], |
| 2159 | 2284 | )); |
| 2160 | 2285 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
| 2161 | - if ($smcFunc['db_num_rows'] != 1) |
|
| 2162 | - return; |
|
| 2286 | + if ($smcFunc['db_num_rows'] != 1) { |
|
| 2287 | + return; |
|
| 2288 | + } |
|
| 2163 | 2289 | |
| 2164 | 2290 | list (, $current_type) = $smcFunc['db_fetch_assoc']($request); |
| 2165 | 2291 | $smcFunc['db_free_result']($request); |
| 2166 | - } |
|
| 2167 | - else |
|
| 2292 | + } else |
|
| 2168 | 2293 | { |
| 2169 | 2294 | // Do this the old fashion, sure method way. |
| 2170 | 2295 | $request = $smcFunc['db_query']('', ' |
@@ -2175,21 +2300,24 @@ discard block |
||
| 2175 | 2300 | )); |
| 2176 | 2301 | // Mayday! |
| 2177 | 2302 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
| 2178 | - if ($smcFunc['db_num_rows'] == 0) |
|
| 2179 | - return; |
|
| 2303 | + if ($smcFunc['db_num_rows'] == 0) { |
|
| 2304 | + return; |
|
| 2305 | + } |
|
| 2180 | 2306 | |
| 2181 | 2307 | // Oh where, oh where has my little field gone. Oh where can it be... |
| 2182 | - while ($row = $smcFunc['db_query']($request)) |
|
| 2183 | - if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
| 2308 | + while ($row = $smcFunc['db_query']($request)) { |
|
| 2309 | + if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
| 2184 | 2310 | { |
| 2185 | 2311 | $current_type = $row['Type']; |
| 2312 | + } |
|
| 2186 | 2313 | break; |
| 2187 | 2314 | } |
| 2188 | 2315 | } |
| 2189 | 2316 | |
| 2190 | 2317 | // If this doesn't match, the column may of been altered for a reason. |
| 2191 | - if (trim($current_type) != trim($temp[3])) |
|
| 2192 | - $temp[3] = $current_type; |
|
| 2318 | + if (trim($current_type) != trim($temp[3])) { |
|
| 2319 | + $temp[3] = $current_type; |
|
| 2320 | + } |
|
| 2193 | 2321 | |
| 2194 | 2322 | // Piece this back together. |
| 2195 | 2323 | $change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp)); |
@@ -2201,8 +2329,9 @@ discard block |
||
| 2201 | 2329 | global $start_time, $timeLimitThreshold, $command_line, $custom_warning; |
| 2202 | 2330 | global $step_progress, $is_debug, $upcontext; |
| 2203 | 2331 | |
| 2204 | - if ($_GET['substep'] < $substep) |
|
| 2205 | - $_GET['substep'] = $substep; |
|
| 2332 | + if ($_GET['substep'] < $substep) { |
|
| 2333 | + $_GET['substep'] = $substep; |
|
| 2334 | + } |
|
| 2206 | 2335 | |
| 2207 | 2336 | if ($command_line) |
| 2208 | 2337 | { |
@@ -2215,29 +2344,33 @@ discard block |
||
| 2215 | 2344 | } |
| 2216 | 2345 | |
| 2217 | 2346 | @set_time_limit(300); |
| 2218 | - if (function_exists('apache_reset_timeout')) |
|
| 2219 | - @apache_reset_timeout(); |
|
| 2347 | + if (function_exists('apache_reset_timeout')) { |
|
| 2348 | + @apache_reset_timeout(); |
|
| 2349 | + } |
|
| 2220 | 2350 | |
| 2221 | - if (time() - $start_time <= $timeLimitThreshold) |
|
| 2222 | - return; |
|
| 2351 | + if (time() - $start_time <= $timeLimitThreshold) { |
|
| 2352 | + return; |
|
| 2353 | + } |
|
| 2223 | 2354 | |
| 2224 | 2355 | // Do we have some custom step progress stuff? |
| 2225 | 2356 | if (!empty($step_progress)) |
| 2226 | 2357 | { |
| 2227 | 2358 | $upcontext['substep_progress'] = 0; |
| 2228 | 2359 | $upcontext['substep_progress_name'] = $step_progress['name']; |
| 2229 | - if ($step_progress['current'] > $step_progress['total']) |
|
| 2230 | - $upcontext['substep_progress'] = 99.9; |
|
| 2231 | - else |
|
| 2232 | - $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
| 2360 | + if ($step_progress['current'] > $step_progress['total']) { |
|
| 2361 | + $upcontext['substep_progress'] = 99.9; |
|
| 2362 | + } else { |
|
| 2363 | + $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
| 2364 | + } |
|
| 2233 | 2365 | |
| 2234 | 2366 | // Make it nicely rounded. |
| 2235 | 2367 | $upcontext['substep_progress'] = round($upcontext['substep_progress'], 1); |
| 2236 | 2368 | } |
| 2237 | 2369 | |
| 2238 | 2370 | // If this is XML we just exit right away! |
| 2239 | - if (isset($_GET['xml'])) |
|
| 2240 | - return upgradeExit(); |
|
| 2371 | + if (isset($_GET['xml'])) { |
|
| 2372 | + return upgradeExit(); |
|
| 2373 | + } |
|
| 2241 | 2374 | |
| 2242 | 2375 | // We're going to pause after this! |
| 2243 | 2376 | $upcontext['pause'] = true; |
@@ -2245,13 +2378,15 @@ discard block |
||
| 2245 | 2378 | $upcontext['query_string'] = ''; |
| 2246 | 2379 | foreach ($_GET as $k => $v) |
| 2247 | 2380 | { |
| 2248 | - if ($k != 'data' && $k != 'substep' && $k != 'step') |
|
| 2249 | - $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
| 2381 | + if ($k != 'data' && $k != 'substep' && $k != 'step') { |
|
| 2382 | + $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
| 2383 | + } |
|
| 2250 | 2384 | } |
| 2251 | 2385 | |
| 2252 | 2386 | // Custom warning? |
| 2253 | - if (!empty($custom_warning)) |
|
| 2254 | - $upcontext['custom_warning'] = $custom_warning; |
|
| 2387 | + if (!empty($custom_warning)) { |
|
| 2388 | + $upcontext['custom_warning'] = $custom_warning; |
|
| 2389 | + } |
|
| 2255 | 2390 | |
| 2256 | 2391 | upgradeExit(); |
| 2257 | 2392 | } |
@@ -2266,25 +2401,26 @@ discard block |
||
| 2266 | 2401 | ob_implicit_flush(true); |
| 2267 | 2402 | @set_time_limit(600); |
| 2268 | 2403 | |
| 2269 | - if (!isset($_SERVER['argv'])) |
|
| 2270 | - $_SERVER['argv'] = array(); |
|
| 2404 | + if (!isset($_SERVER['argv'])) { |
|
| 2405 | + $_SERVER['argv'] = array(); |
|
| 2406 | + } |
|
| 2271 | 2407 | $_GET['maint'] = 1; |
| 2272 | 2408 | |
| 2273 | 2409 | foreach ($_SERVER['argv'] as $i => $arg) |
| 2274 | 2410 | { |
| 2275 | - if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) |
|
| 2276 | - $_GET['lang'] = $match[1]; |
|
| 2277 | - elseif (preg_match('~^--path=(.+)$~', $arg) != 0) |
|
| 2278 | - continue; |
|
| 2279 | - elseif ($arg == '--no-maintenance') |
|
| 2280 | - $_GET['maint'] = 0; |
|
| 2281 | - elseif ($arg == '--debug') |
|
| 2282 | - $is_debug = true; |
|
| 2283 | - elseif ($arg == '--backup') |
|
| 2284 | - $_POST['backup'] = 1; |
|
| 2285 | - elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) |
|
| 2286 | - $_GET['conv'] = 1; |
|
| 2287 | - elseif ($i != 0) |
|
| 2411 | + if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) { |
|
| 2412 | + $_GET['lang'] = $match[1]; |
|
| 2413 | + } elseif (preg_match('~^--path=(.+)$~', $arg) != 0) { |
|
| 2414 | + continue; |
|
| 2415 | + } elseif ($arg == '--no-maintenance') { |
|
| 2416 | + $_GET['maint'] = 0; |
|
| 2417 | + } elseif ($arg == '--debug') { |
|
| 2418 | + $is_debug = true; |
|
| 2419 | + } elseif ($arg == '--backup') { |
|
| 2420 | + $_POST['backup'] = 1; |
|
| 2421 | + } elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) { |
|
| 2422 | + $_GET['conv'] = 1; |
|
| 2423 | + } elseif ($i != 0) |
|
| 2288 | 2424 | { |
| 2289 | 2425 | echo 'SMF Command-line Upgrader |
| 2290 | 2426 | Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]... |
@@ -2298,10 +2434,12 @@ discard block |
||
| 2298 | 2434 | } |
| 2299 | 2435 | } |
| 2300 | 2436 | |
| 2301 | - if (!php_version_check()) |
|
| 2302 | - print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
| 2303 | - if (!db_version_check()) |
|
| 2304 | - print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
| 2437 | + if (!php_version_check()) { |
|
| 2438 | + print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
| 2439 | + } |
|
| 2440 | + if (!db_version_check()) { |
|
| 2441 | + print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
| 2442 | + } |
|
| 2305 | 2443 | |
| 2306 | 2444 | // Do some checks to make sure they have proper privileges |
| 2307 | 2445 | db_extend('packages'); |
@@ -2316,34 +2454,39 @@ discard block |
||
| 2316 | 2454 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
| 2317 | 2455 | |
| 2318 | 2456 | // Sorry... we need CREATE, ALTER and DROP |
| 2319 | - if (!$create || !$alter || !$drop) |
|
| 2320 | - print_error("The " . $databases[$db_type]['name'] . " user you have set in Settings.php does not have proper privileges.\n\nPlease ask your host to give this user the ALTER, CREATE, and DROP privileges.", true); |
|
| 2457 | + if (!$create || !$alter || !$drop) { |
|
| 2458 | + print_error("The " . $databases[$db_type]['name'] . " user you have set in Settings.php does not have proper privileges.\n\nPlease ask your host to give this user the ALTER, CREATE, and DROP privileges.", true); |
|
| 2459 | + } |
|
| 2321 | 2460 | |
| 2322 | 2461 | $check = @file_exists($modSettings['theme_dir'] . '/index.template.php') |
| 2323 | 2462 | && @file_exists($sourcedir . '/QueryString.php') |
| 2324 | 2463 | && @file_exists($sourcedir . '/ManageBoards.php'); |
| 2325 | - if (!$check && !isset($modSettings['smfVersion'])) |
|
| 2326 | - print_error('Error: Some files are missing or out-of-date.', true); |
|
| 2464 | + if (!$check && !isset($modSettings['smfVersion'])) { |
|
| 2465 | + print_error('Error: Some files are missing or out-of-date.', true); |
|
| 2466 | + } |
|
| 2327 | 2467 | |
| 2328 | 2468 | // Do a quick version spot check. |
| 2329 | 2469 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
| 2330 | 2470 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
| 2331 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
| 2332 | - print_error('Error: Some files have not yet been updated properly.'); |
|
| 2471 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
| 2472 | + print_error('Error: Some files have not yet been updated properly.'); |
|
| 2473 | + } |
|
| 2333 | 2474 | |
| 2334 | 2475 | // Make sure Settings.php is writable. |
| 2335 | 2476 | quickFileWritable($boarddir . '/Settings.php'); |
| 2336 | - if (!is_writable($boarddir . '/Settings.php')) |
|
| 2337 | - print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
| 2477 | + if (!is_writable($boarddir . '/Settings.php')) { |
|
| 2478 | + print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
| 2479 | + } |
|
| 2338 | 2480 | |
| 2339 | 2481 | // Make sure Settings_bak.php is writable. |
| 2340 | 2482 | quickFileWritable($boarddir . '/Settings_bak.php'); |
| 2341 | - if (!is_writable($boarddir . '/Settings_bak.php')) |
|
| 2342 | - print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
| 2483 | + if (!is_writable($boarddir . '/Settings_bak.php')) { |
|
| 2484 | + print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
| 2485 | + } |
|
| 2343 | 2486 | |
| 2344 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
| 2345 | - print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
| 2346 | - elseif (isset($modSettings['agreement'])) |
|
| 2487 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
| 2488 | + print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
| 2489 | + } elseif (isset($modSettings['agreement'])) |
|
| 2347 | 2490 | { |
| 2348 | 2491 | $fp = fopen($boarddir . '/agreement.txt', 'w'); |
| 2349 | 2492 | fwrite($fp, $modSettings['agreement']); |
@@ -2353,31 +2496,36 @@ discard block |
||
| 2353 | 2496 | // Make sure Themes is writable. |
| 2354 | 2497 | quickFileWritable($modSettings['theme_dir']); |
| 2355 | 2498 | |
| 2356 | - if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) |
|
| 2357 | - print_error('Error: Unable to obtain write access to "Themes".'); |
|
| 2499 | + if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) { |
|
| 2500 | + print_error('Error: Unable to obtain write access to "Themes".'); |
|
| 2501 | + } |
|
| 2358 | 2502 | |
| 2359 | 2503 | // Make sure cache directory exists and is writable! |
| 2360 | 2504 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
| 2361 | - if (!file_exists($cachedir_temp)) |
|
| 2362 | - @mkdir($cachedir_temp); |
|
| 2505 | + if (!file_exists($cachedir_temp)) { |
|
| 2506 | + @mkdir($cachedir_temp); |
|
| 2507 | + } |
|
| 2363 | 2508 | |
| 2364 | 2509 | // Make sure the cache temp dir is writable. |
| 2365 | 2510 | quickFileWritable($cachedir_temp); |
| 2366 | 2511 | |
| 2367 | - if (!is_writable($cachedir_temp)) |
|
| 2368 | - print_error('Error: Unable to obtain write access to "cache".', true); |
|
| 2512 | + if (!is_writable($cachedir_temp)) { |
|
| 2513 | + print_error('Error: Unable to obtain write access to "cache".', true); |
|
| 2514 | + } |
|
| 2369 | 2515 | |
| 2370 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
| 2371 | - print_error('Error: Unable to find language files!', true); |
|
| 2372 | - else |
|
| 2516 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
| 2517 | + print_error('Error: Unable to find language files!', true); |
|
| 2518 | + } else |
|
| 2373 | 2519 | { |
| 2374 | 2520 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
| 2375 | 2521 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 2376 | 2522 | |
| 2377 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 2378 | - print_error('Error: Language files out of date.', true); |
|
| 2379 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 2380 | - print_error('Error: Install language is missing for selected language.', true); |
|
| 2523 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 2524 | + print_error('Error: Language files out of date.', true); |
|
| 2525 | + } |
|
| 2526 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 2527 | + print_error('Error: Install language is missing for selected language.', true); |
|
| 2528 | + } |
|
| 2381 | 2529 | |
| 2382 | 2530 | // Otherwise include it! |
| 2383 | 2531 | require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
@@ -2396,8 +2544,9 @@ discard block |
||
| 2396 | 2544 | global $upcontext, $db_character_set, $sourcedir, $smcFunc, $modSettings, $language, $db_prefix, $db_type, $command_line, $support_js; |
| 2397 | 2545 | |
| 2398 | 2546 | // Done it already? |
| 2399 | - if (!empty($_POST['utf8_done'])) |
|
| 2400 | - return true; |
|
| 2547 | + if (!empty($_POST['utf8_done'])) { |
|
| 2548 | + return true; |
|
| 2549 | + } |
|
| 2401 | 2550 | |
| 2402 | 2551 | // First make sure they aren't already on UTF-8 before we go anywhere... |
| 2403 | 2552 | if ($db_type == 'postgresql' || ($db_character_set === 'utf8' && !empty($modSettings['global_character_set']) && $modSettings['global_character_set'] === 'UTF-8')) |
@@ -2410,8 +2559,7 @@ discard block |
||
| 2410 | 2559 | ); |
| 2411 | 2560 | |
| 2412 | 2561 | return true; |
| 2413 | - } |
|
| 2414 | - else |
|
| 2562 | + } else |
|
| 2415 | 2563 | { |
| 2416 | 2564 | $upcontext['page_title'] = 'Converting to UTF8'; |
| 2417 | 2565 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8'; |
@@ -2455,8 +2603,9 @@ discard block |
||
| 2455 | 2603 | ) |
| 2456 | 2604 | ); |
| 2457 | 2605 | $db_charsets = array(); |
| 2458 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2459 | - $db_charsets[] = $row['Charset']; |
|
| 2606 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2607 | + $db_charsets[] = $row['Charset']; |
|
| 2608 | + } |
|
| 2460 | 2609 | |
| 2461 | 2610 | $smcFunc['db_free_result']($request); |
| 2462 | 2611 | |
@@ -2492,13 +2641,15 @@ discard block |
||
| 2492 | 2641 | // If there's a fulltext index, we need to drop it first... |
| 2493 | 2642 | if ($request !== false || $smcFunc['db_num_rows']($request) != 0) |
| 2494 | 2643 | { |
| 2495 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2496 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 2644 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2645 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 2497 | 2646 | $upcontext['fulltext_index'][] = $row['Key_name']; |
| 2647 | + } |
|
| 2498 | 2648 | $smcFunc['db_free_result']($request); |
| 2499 | 2649 | |
| 2500 | - if (isset($upcontext['fulltext_index'])) |
|
| 2501 | - $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
| 2650 | + if (isset($upcontext['fulltext_index'])) { |
|
| 2651 | + $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
| 2652 | + } |
|
| 2502 | 2653 | } |
| 2503 | 2654 | |
| 2504 | 2655 | // Drop it and make a note... |
@@ -2688,8 +2839,9 @@ discard block |
||
| 2688 | 2839 | $replace = '%field%'; |
| 2689 | 2840 | |
| 2690 | 2841 | // Build a huge REPLACE statement... |
| 2691 | - foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) |
|
| 2692 | - $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
| 2842 | + foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) { |
|
| 2843 | + $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
| 2844 | + } |
|
| 2693 | 2845 | } |
| 2694 | 2846 | |
| 2695 | 2847 | // Get a list of table names ahead of time... This makes it easier to set our substep and such |
@@ -2699,9 +2851,10 @@ discard block |
||
| 2699 | 2851 | $upcontext['table_count'] = count($queryTables); |
| 2700 | 2852 | |
| 2701 | 2853 | // What ones have we already done? |
| 2702 | - foreach ($queryTables as $id => $table) |
|
| 2703 | - if ($id < $_GET['substep']) |
|
| 2854 | + foreach ($queryTables as $id => $table) { |
|
| 2855 | + if ($id < $_GET['substep']) |
|
| 2704 | 2856 | $upcontext['previous_tables'][] = $table; |
| 2857 | + } |
|
| 2705 | 2858 | |
| 2706 | 2859 | $upcontext['cur_table_num'] = $_GET['substep']; |
| 2707 | 2860 | $upcontext['cur_table_name'] = str_replace($db_prefix, '', $queryTables[$_GET['substep']]); |
@@ -2738,8 +2891,9 @@ discard block |
||
| 2738 | 2891 | nextSubstep($substep); |
| 2739 | 2892 | |
| 2740 | 2893 | // Just to make sure it doesn't time out. |
| 2741 | - if (function_exists('apache_reset_timeout')) |
|
| 2742 | - @apache_reset_timeout(); |
|
| 2894 | + if (function_exists('apache_reset_timeout')) { |
|
| 2895 | + @apache_reset_timeout(); |
|
| 2896 | + } |
|
| 2743 | 2897 | |
| 2744 | 2898 | $table_charsets = array(); |
| 2745 | 2899 | |
@@ -2760,8 +2914,9 @@ discard block |
||
| 2760 | 2914 | { |
| 2761 | 2915 | list($charset) = explode('_', $collation); |
| 2762 | 2916 | |
| 2763 | - if (!isset($table_charsets[$charset])) |
|
| 2764 | - $table_charsets[$charset] = array(); |
|
| 2917 | + if (!isset($table_charsets[$charset])) { |
|
| 2918 | + $table_charsets[$charset] = array(); |
|
| 2919 | + } |
|
| 2765 | 2920 | |
| 2766 | 2921 | $table_charsets[$charset][] = $column_info; |
| 2767 | 2922 | } |
@@ -2801,10 +2956,11 @@ discard block |
||
| 2801 | 2956 | if (isset($translation_tables[$upcontext['charset_detected']])) |
| 2802 | 2957 | { |
| 2803 | 2958 | $update = ''; |
| 2804 | - foreach ($table_charsets as $charset => $columns) |
|
| 2805 | - foreach ($columns as $column) |
|
| 2959 | + foreach ($table_charsets as $charset => $columns) { |
|
| 2960 | + foreach ($columns as $column) |
|
| 2806 | 2961 | $update .= ' |
| 2807 | 2962 | ' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ','; |
| 2963 | + } |
|
| 2808 | 2964 | |
| 2809 | 2965 | $smcFunc['db_query']('', ' |
| 2810 | 2966 | UPDATE {raw:table_name} |
@@ -2829,8 +2985,9 @@ discard block |
||
| 2829 | 2985 | // Now do the actual conversion (if still needed). |
| 2830 | 2986 | if ($charsets[$upcontext['charset_detected']] !== 'utf8') |
| 2831 | 2987 | { |
| 2832 | - if ($command_line) |
|
| 2833 | - echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
| 2988 | + if ($command_line) { |
|
| 2989 | + echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
| 2990 | + } |
|
| 2834 | 2991 | |
| 2835 | 2992 | $smcFunc['db_query']('', ' |
| 2836 | 2993 | ALTER TABLE {raw:table_name} |
@@ -2840,12 +2997,14 @@ discard block |
||
| 2840 | 2997 | ) |
| 2841 | 2998 | ); |
| 2842 | 2999 | |
| 2843 | - if ($command_line) |
|
| 2844 | - echo " done.\n"; |
|
| 3000 | + if ($command_line) { |
|
| 3001 | + echo " done.\n"; |
|
| 3002 | + } |
|
| 2845 | 3003 | } |
| 2846 | 3004 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 2847 | - if (isset($_GET['xml'])) |
|
| 2848 | - return upgradeExit(); |
|
| 3005 | + if (isset($_GET['xml'])) { |
|
| 3006 | + return upgradeExit(); |
|
| 3007 | + } |
|
| 2849 | 3008 | } |
| 2850 | 3009 | |
| 2851 | 3010 | $prev_charset = empty($translation_tables[$upcontext['charset_detected']]) ? $charsets[$upcontext['charset_detected']] : $translation_tables[$upcontext['charset_detected']]; |
@@ -2874,8 +3033,8 @@ discard block |
||
| 2874 | 3033 | ); |
| 2875 | 3034 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2876 | 3035 | { |
| 2877 | - if (@safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) |
|
| 2878 | - $smcFunc['db_query']('', ' |
|
| 3036 | + if (@safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) { |
|
| 3037 | + $smcFunc['db_query']('', ' |
|
| 2879 | 3038 | UPDATE {db_prefix}log_actions |
| 2880 | 3039 | SET extra = {string:extra} |
| 2881 | 3040 | WHERE id_action = {int:current_action}', |
@@ -2884,6 +3043,7 @@ discard block |
||
| 2884 | 3043 | 'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4], |
| 2885 | 3044 | ) |
| 2886 | 3045 | ); |
| 3046 | + } |
|
| 2887 | 3047 | } |
| 2888 | 3048 | $smcFunc['db_free_result']($request); |
| 2889 | 3049 | |
@@ -2905,15 +3065,17 @@ discard block |
||
| 2905 | 3065 | // First thing's first - did we already do this? |
| 2906 | 3066 | if (!empty($modSettings['json_done'])) |
| 2907 | 3067 | { |
| 2908 | - if ($command_line) |
|
| 2909 | - return DeleteUpgrade(); |
|
| 2910 | - else |
|
| 2911 | - return true; |
|
| 3068 | + if ($command_line) { |
|
| 3069 | + return DeleteUpgrade(); |
|
| 3070 | + } else { |
|
| 3071 | + return true; |
|
| 3072 | + } |
|
| 2912 | 3073 | } |
| 2913 | 3074 | |
| 2914 | 3075 | // Done it already - js wise? |
| 2915 | - if (!empty($_POST['json_done'])) |
|
| 2916 | - return true; |
|
| 3076 | + if (!empty($_POST['json_done'])) { |
|
| 3077 | + return true; |
|
| 3078 | + } |
|
| 2917 | 3079 | |
| 2918 | 3080 | // List of tables affected by this function |
| 2919 | 3081 | // name => array('key', col1[,col2|true[,col3]]) |
@@ -2945,12 +3107,14 @@ discard block |
||
| 2945 | 3107 | $upcontext['cur_table_name'] = isset($keys[$_GET['substep']]) ? $keys[$_GET['substep']] : $keys[0]; |
| 2946 | 3108 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
| 2947 | 3109 | |
| 2948 | - foreach ($keys as $id => $table) |
|
| 2949 | - if ($id < $_GET['substep']) |
|
| 3110 | + foreach ($keys as $id => $table) { |
|
| 3111 | + if ($id < $_GET['substep']) |
|
| 2950 | 3112 | $upcontext['previous_tables'][] = $table; |
| 3113 | + } |
|
| 2951 | 3114 | |
| 2952 | - if ($command_line) |
|
| 2953 | - echo 'Converting data from serialize() to json_encode().'; |
|
| 3115 | + if ($command_line) { |
|
| 3116 | + echo 'Converting data from serialize() to json_encode().'; |
|
| 3117 | + } |
|
| 2954 | 3118 | |
| 2955 | 3119 | if (!$support_js || isset($_GET['xml'])) |
| 2956 | 3120 | { |
@@ -2990,8 +3154,9 @@ discard block |
||
| 2990 | 3154 | |
| 2991 | 3155 | // Loop through and fix these... |
| 2992 | 3156 | $new_settings = array(); |
| 2993 | - if ($command_line) |
|
| 2994 | - echo "\n" . 'Fixing some settings...'; |
|
| 3157 | + if ($command_line) { |
|
| 3158 | + echo "\n" . 'Fixing some settings...'; |
|
| 3159 | + } |
|
| 2995 | 3160 | |
| 2996 | 3161 | foreach ($serialized_settings as $var) |
| 2997 | 3162 | { |
@@ -2999,22 +3164,24 @@ discard block |
||
| 2999 | 3164 | { |
| 3000 | 3165 | // Attempt to unserialize the setting |
| 3001 | 3166 | $temp = @safe_unserialize($modSettings[$var]); |
| 3002 | - if (!$temp && $command_line) |
|
| 3003 | - echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
| 3004 | - elseif ($temp !== false) |
|
| 3005 | - $new_settings[$var] = json_encode($temp); |
|
| 3167 | + if (!$temp && $command_line) { |
|
| 3168 | + echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
| 3169 | + } elseif ($temp !== false) { |
|
| 3170 | + $new_settings[$var] = json_encode($temp); |
|
| 3171 | + } |
|
| 3006 | 3172 | } |
| 3007 | 3173 | } |
| 3008 | 3174 | |
| 3009 | 3175 | // Update everything at once |
| 3010 | - if (!function_exists('cache_put_data')) |
|
| 3011 | - require_once($sourcedir . '/Load.php'); |
|
| 3176 | + if (!function_exists('cache_put_data')) { |
|
| 3177 | + require_once($sourcedir . '/Load.php'); |
|
| 3178 | + } |
|
| 3012 | 3179 | updateSettings($new_settings, true); |
| 3013 | 3180 | |
| 3014 | - if ($command_line) |
|
| 3015 | - echo ' done.'; |
|
| 3016 | - } |
|
| 3017 | - elseif ($table == 'themes') |
|
| 3181 | + if ($command_line) { |
|
| 3182 | + echo ' done.'; |
|
| 3183 | + } |
|
| 3184 | + } elseif ($table == 'themes') |
|
| 3018 | 3185 | { |
| 3019 | 3186 | // Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point... |
| 3020 | 3187 | $query = $smcFunc['db_query']('', ' |
@@ -3033,10 +3200,11 @@ discard block |
||
| 3033 | 3200 | |
| 3034 | 3201 | if ($command_line) |
| 3035 | 3202 | { |
| 3036 | - if ($temp === false) |
|
| 3037 | - echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
| 3038 | - else |
|
| 3039 | - echo "\n" . 'Fixing admin preferences...'; |
|
| 3203 | + if ($temp === false) { |
|
| 3204 | + echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
| 3205 | + } else { |
|
| 3206 | + echo "\n" . 'Fixing admin preferences...'; |
|
| 3207 | + } |
|
| 3040 | 3208 | } |
| 3041 | 3209 | |
| 3042 | 3210 | if ($temp !== false) |
@@ -3058,15 +3226,15 @@ discard block |
||
| 3058 | 3226 | ) |
| 3059 | 3227 | ); |
| 3060 | 3228 | |
| 3061 | - if ($command_line) |
|
| 3062 | - echo ' done.'; |
|
| 3229 | + if ($command_line) { |
|
| 3230 | + echo ' done.'; |
|
| 3231 | + } |
|
| 3063 | 3232 | } |
| 3064 | 3233 | } |
| 3065 | 3234 | |
| 3066 | 3235 | $smcFunc['db_free_result']($query); |
| 3067 | 3236 | } |
| 3068 | - } |
|
| 3069 | - else |
|
| 3237 | + } else |
|
| 3070 | 3238 | { |
| 3071 | 3239 | // First item is always the key... |
| 3072 | 3240 | $key = $info[0]; |
@@ -3077,8 +3245,7 @@ discard block |
||
| 3077 | 3245 | { |
| 3078 | 3246 | $col_select = $info[1]; |
| 3079 | 3247 | $where = ' WHERE ' . $info[1] . ' != {empty}'; |
| 3080 | - } |
|
| 3081 | - else |
|
| 3248 | + } else |
|
| 3082 | 3249 | { |
| 3083 | 3250 | $col_select = implode(', ', $info); |
| 3084 | 3251 | } |
@@ -3111,8 +3278,7 @@ discard block |
||
| 3111 | 3278 | if ($temp === false && $command_line) |
| 3112 | 3279 | { |
| 3113 | 3280 | echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n"; |
| 3114 | - } |
|
| 3115 | - else |
|
| 3281 | + } else |
|
| 3116 | 3282 | { |
| 3117 | 3283 | $row[$col] = json_encode($temp); |
| 3118 | 3284 | |
@@ -3137,16 +3303,18 @@ discard block |
||
| 3137 | 3303 | } |
| 3138 | 3304 | } |
| 3139 | 3305 | |
| 3140 | - if ($command_line) |
|
| 3141 | - echo ' done.'; |
|
| 3306 | + if ($command_line) { |
|
| 3307 | + echo ' done.'; |
|
| 3308 | + } |
|
| 3142 | 3309 | |
| 3143 | 3310 | // Free up some memory... |
| 3144 | 3311 | $smcFunc['db_free_result']($query); |
| 3145 | 3312 | } |
| 3146 | 3313 | } |
| 3147 | 3314 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 3148 | - if (isset($_GET['xml'])) |
|
| 3149 | - return upgradeExit(); |
|
| 3315 | + if (isset($_GET['xml'])) { |
|
| 3316 | + return upgradeExit(); |
|
| 3317 | + } |
|
| 3150 | 3318 | } |
| 3151 | 3319 | |
| 3152 | 3320 | if ($command_line) |
@@ -3161,8 +3329,9 @@ discard block |
||
| 3161 | 3329 | |
| 3162 | 3330 | $_GET['substep'] = 0; |
| 3163 | 3331 | // Make sure we move on! |
| 3164 | - if ($command_line) |
|
| 3165 | - return DeleteUpgrade(); |
|
| 3332 | + if ($command_line) { |
|
| 3333 | + return DeleteUpgrade(); |
|
| 3334 | + } |
|
| 3166 | 3335 | |
| 3167 | 3336 | return true; |
| 3168 | 3337 | } |
@@ -3182,14 +3351,16 @@ discard block |
||
| 3182 | 3351 | global $upcontext, $txt, $settings; |
| 3183 | 3352 | |
| 3184 | 3353 | // Don't call me twice! |
| 3185 | - if (!empty($upcontext['chmod_called'])) |
|
| 3186 | - return; |
|
| 3354 | + if (!empty($upcontext['chmod_called'])) { |
|
| 3355 | + return; |
|
| 3356 | + } |
|
| 3187 | 3357 | |
| 3188 | 3358 | $upcontext['chmod_called'] = true; |
| 3189 | 3359 | |
| 3190 | 3360 | // Nothing? |
| 3191 | - if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) |
|
| 3192 | - return; |
|
| 3361 | + if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) { |
|
| 3362 | + return; |
|
| 3363 | + } |
|
| 3193 | 3364 | |
| 3194 | 3365 | // Was it a problem with Windows? |
| 3195 | 3366 | if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess') |
@@ -3221,11 +3392,12 @@ discard block |
||
| 3221 | 3392 | content.write(\'<div class="windowbg description">\n\t\t\t<h4>The following files needs to be made writable to continue:</h4>\n\t\t\t\'); |
| 3222 | 3393 | content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');'; |
| 3223 | 3394 | |
| 3224 | - if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') |
|
| 3225 | - echo ' |
|
| 3395 | + if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') { |
|
| 3396 | + echo ' |
|
| 3226 | 3397 | content.write(\'<hr>\n\t\t\t\'); |
| 3227 | 3398 | content.write(\'<p>If you have a shell account, the convenient below command can automatically correct permissions on these files</p>\n\t\t\t\'); |
| 3228 | 3399 | content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');'; |
| 3400 | + } |
|
| 3229 | 3401 | |
| 3230 | 3402 | echo ' |
| 3231 | 3403 | content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\'); |
@@ -3233,17 +3405,19 @@ discard block |
||
| 3233 | 3405 | } |
| 3234 | 3406 | </script>'; |
| 3235 | 3407 | |
| 3236 | - if (!empty($upcontext['chmod']['ftp_error'])) |
|
| 3237 | - echo ' |
|
| 3408 | + if (!empty($upcontext['chmod']['ftp_error'])) { |
|
| 3409 | + echo ' |
|
| 3238 | 3410 | <div class="error_message red"> |
| 3239 | 3411 | The following error was encountered when trying to connect:<br><br> |
| 3240 | 3412 | <code>', $upcontext['chmod']['ftp_error'], '</code> |
| 3241 | 3413 | </div> |
| 3242 | 3414 | <br>'; |
| 3415 | + } |
|
| 3243 | 3416 | |
| 3244 | - if (empty($upcontext['chmod_in_form'])) |
|
| 3245 | - echo ' |
|
| 3417 | + if (empty($upcontext['chmod_in_form'])) { |
|
| 3418 | + echo ' |
|
| 3246 | 3419 | <form action="', $upcontext['form_url'], '" method="post">'; |
| 3420 | + } |
|
| 3247 | 3421 | |
| 3248 | 3422 | echo ' |
| 3249 | 3423 | <table width="520" border="0" align="center" style="margin-bottom: 1ex;"> |
@@ -3278,10 +3452,11 @@ discard block |
||
| 3278 | 3452 | <div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['ftp_connect'], '" class="button_submit"></div> |
| 3279 | 3453 | </div>'; |
| 3280 | 3454 | |
| 3281 | - if (empty($upcontext['chmod_in_form'])) |
|
| 3282 | - echo ' |
|
| 3455 | + if (empty($upcontext['chmod_in_form'])) { |
|
| 3456 | + echo ' |
|
| 3283 | 3457 | </form>'; |
| 3284 | -} |
|
| 3458 | + } |
|
| 3459 | + } |
|
| 3285 | 3460 | |
| 3286 | 3461 | function template_upgrade_above() |
| 3287 | 3462 | { |
@@ -3341,9 +3516,10 @@ discard block |
||
| 3341 | 3516 | <h2>', $txt['upgrade_progress'], '</h2> |
| 3342 | 3517 | <ul>'; |
| 3343 | 3518 | |
| 3344 | - foreach ($upcontext['steps'] as $num => $step) |
|
| 3345 | - echo ' |
|
| 3519 | + foreach ($upcontext['steps'] as $num => $step) { |
|
| 3520 | + echo ' |
|
| 3346 | 3521 | <li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
| 3522 | + } |
|
| 3347 | 3523 | |
| 3348 | 3524 | echo ' |
| 3349 | 3525 | </ul> |
@@ -3356,8 +3532,8 @@ discard block |
||
| 3356 | 3532 | </div> |
| 3357 | 3533 | </div>'; |
| 3358 | 3534 | |
| 3359 | - if (isset($upcontext['step_progress'])) |
|
| 3360 | - echo ' |
|
| 3535 | + if (isset($upcontext['step_progress'])) { |
|
| 3536 | + echo ' |
|
| 3361 | 3537 | <br> |
| 3362 | 3538 | <br> |
| 3363 | 3539 | <div id="progress_bar_step"> |
@@ -3366,6 +3542,7 @@ discard block |
||
| 3366 | 3542 | <span>', $txt['upgrade_step_progress'], '</span> |
| 3367 | 3543 | </div> |
| 3368 | 3544 | </div>'; |
| 3545 | + } |
|
| 3369 | 3546 | |
| 3370 | 3547 | echo ' |
| 3371 | 3548 | <div id="substep_bar_div" class="smalltext" style="float: left;width: 50%;margin-top: 0.6em;display: ', isset($upcontext['substep_progress']) ? '' : 'none', ';">', isset($upcontext['substep_progress_name']) ? trim(strtr($upcontext['substep_progress_name'], array('.' => ''))) : '', ':</div> |
@@ -3396,32 +3573,36 @@ discard block |
||
| 3396 | 3573 | { |
| 3397 | 3574 | global $upcontext, $txt; |
| 3398 | 3575 | |
| 3399 | - if (!empty($upcontext['pause'])) |
|
| 3400 | - echo ' |
|
| 3576 | + if (!empty($upcontext['pause'])) { |
|
| 3577 | + echo ' |
|
| 3401 | 3578 | <em>', $txt['upgrade_incomplete'], '.</em><br> |
| 3402 | 3579 | |
| 3403 | 3580 | <h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2> |
| 3404 | 3581 | <h3> |
| 3405 | 3582 | ', $txt['upgrade_paused_overload'], ' |
| 3406 | 3583 | </h3>'; |
| 3584 | + } |
|
| 3407 | 3585 | |
| 3408 | - if (!empty($upcontext['custom_warning'])) |
|
| 3409 | - echo ' |
|
| 3586 | + if (!empty($upcontext['custom_warning'])) { |
|
| 3587 | + echo ' |
|
| 3410 | 3588 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3411 | 3589 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3412 | 3590 | <strong style="text-decoration: underline;">', $txt['upgrade_note'], '</strong><br> |
| 3413 | 3591 | <div style="padding-left: 6ex;">', $upcontext['custom_warning'], '</div> |
| 3414 | 3592 | </div>'; |
| 3593 | + } |
|
| 3415 | 3594 | |
| 3416 | 3595 | echo ' |
| 3417 | 3596 | <div class="righttext" style="margin: 1ex;">'; |
| 3418 | 3597 | |
| 3419 | - if (!empty($upcontext['continue'])) |
|
| 3420 | - echo ' |
|
| 3598 | + if (!empty($upcontext['continue'])) { |
|
| 3599 | + echo ' |
|
| 3421 | 3600 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button_submit">'; |
| 3422 | - if (!empty($upcontext['skip'])) |
|
| 3423 | - echo ' |
|
| 3601 | + } |
|
| 3602 | + if (!empty($upcontext['skip'])) { |
|
| 3603 | + echo ' |
|
| 3424 | 3604 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button_submit">'; |
| 3605 | + } |
|
| 3425 | 3606 | |
| 3426 | 3607 | echo ' |
| 3427 | 3608 | </div> |
@@ -3471,11 +3652,12 @@ discard block |
||
| 3471 | 3652 | echo '<', '?xml version="1.0" encoding="UTF-8"?', '> |
| 3472 | 3653 | <smf>'; |
| 3473 | 3654 | |
| 3474 | - if (!empty($upcontext['get_data'])) |
|
| 3475 | - foreach ($upcontext['get_data'] as $k => $v) |
|
| 3655 | + if (!empty($upcontext['get_data'])) { |
|
| 3656 | + foreach ($upcontext['get_data'] as $k => $v) |
|
| 3476 | 3657 | echo ' |
| 3477 | 3658 | <get key="', $k, '">', $v, '</get>'; |
| 3478 | -} |
|
| 3659 | + } |
|
| 3660 | + } |
|
| 3479 | 3661 | |
| 3480 | 3662 | function template_xml_below() |
| 3481 | 3663 | { |
@@ -3516,8 +3698,8 @@ discard block |
||
| 3516 | 3698 | template_chmod(); |
| 3517 | 3699 | |
| 3518 | 3700 | // For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade! |
| 3519 | - if ($upcontext['is_large_forum']) |
|
| 3520 | - echo ' |
|
| 3701 | + if ($upcontext['is_large_forum']) { |
|
| 3702 | + echo ' |
|
| 3521 | 3703 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3522 | 3704 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3523 | 3705 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3525,10 +3707,11 @@ discard block |
||
| 3525 | 3707 | ', $txt['upgrade_warning_lots_data'], ' |
| 3526 | 3708 | </div> |
| 3527 | 3709 | </div>'; |
| 3710 | + } |
|
| 3528 | 3711 | |
| 3529 | 3712 | // A warning message? |
| 3530 | - if (!empty($upcontext['warning'])) |
|
| 3531 | - echo ' |
|
| 3713 | + if (!empty($upcontext['warning'])) { |
|
| 3714 | + echo ' |
|
| 3532 | 3715 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3533 | 3716 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3534 | 3717 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3536,6 +3719,7 @@ discard block |
||
| 3536 | 3719 | ', $upcontext['warning'], ' |
| 3537 | 3720 | </div> |
| 3538 | 3721 | </div>'; |
| 3722 | + } |
|
| 3539 | 3723 | |
| 3540 | 3724 | // Paths are incorrect? |
| 3541 | 3725 | echo ' |
@@ -3551,20 +3735,22 @@ discard block |
||
| 3551 | 3735 | if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600)) |
| 3552 | 3736 | { |
| 3553 | 3737 | $ago = time() - $upcontext['started']; |
| 3554 | - if ($ago < 60) |
|
| 3555 | - $ago = $ago . ' seconds'; |
|
| 3556 | - elseif ($ago < 3600) |
|
| 3557 | - $ago = (int) ($ago / 60) . ' minutes'; |
|
| 3558 | - else |
|
| 3559 | - $ago = (int) ($ago / 3600) . ' hours'; |
|
| 3738 | + if ($ago < 60) { |
|
| 3739 | + $ago = $ago . ' seconds'; |
|
| 3740 | + } elseif ($ago < 3600) { |
|
| 3741 | + $ago = (int) ($ago / 60) . ' minutes'; |
|
| 3742 | + } else { |
|
| 3743 | + $ago = (int) ($ago / 3600) . ' hours'; |
|
| 3744 | + } |
|
| 3560 | 3745 | |
| 3561 | 3746 | $active = time() - $upcontext['updated']; |
| 3562 | - if ($active < 60) |
|
| 3563 | - $updated = $active . ' seconds'; |
|
| 3564 | - elseif ($active < 3600) |
|
| 3565 | - $updated = (int) ($active / 60) . ' minutes'; |
|
| 3566 | - else |
|
| 3567 | - $updated = (int) ($active / 3600) . ' hours'; |
|
| 3747 | + if ($active < 60) { |
|
| 3748 | + $updated = $active . ' seconds'; |
|
| 3749 | + } elseif ($active < 3600) { |
|
| 3750 | + $updated = (int) ($active / 60) . ' minutes'; |
|
| 3751 | + } else { |
|
| 3752 | + $updated = (int) ($active / 3600) . ' hours'; |
|
| 3753 | + } |
|
| 3568 | 3754 | |
| 3569 | 3755 | echo ' |
| 3570 | 3756 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
@@ -3573,16 +3759,18 @@ discard block |
||
| 3573 | 3759 | <div style="padding-left: 6ex;"> |
| 3574 | 3760 | "', $upcontext['user']['name'], '" has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.'; |
| 3575 | 3761 | |
| 3576 | - if ($active < 600) |
|
| 3577 | - echo ' |
|
| 3762 | + if ($active < 600) { |
|
| 3763 | + echo ' |
|
| 3578 | 3764 | We recommend that you do not run this script unless you are sure that ', $upcontext['user']['name'], ' has completed their upgrade.'; |
| 3765 | + } |
|
| 3579 | 3766 | |
| 3580 | - if ($active > $upcontext['inactive_timeout']) |
|
| 3581 | - echo ' |
|
| 3767 | + if ($active > $upcontext['inactive_timeout']) { |
|
| 3768 | + echo ' |
|
| 3582 | 3769 | <br><br>You can choose to either run the upgrade again from the beginning - or alternatively continue from the last step reached during the last upgrade.'; |
| 3583 | - else |
|
| 3584 | - echo ' |
|
| 3770 | + } else { |
|
| 3771 | + echo ' |
|
| 3585 | 3772 | <br><br>This upgrade script cannot be run until ', $upcontext['user']['name'], ' has been inactive for at least ', ($upcontext['inactive_timeout'] > 120 ? round($upcontext['inactive_timeout'] / 60, 1) . ' minutes!' : $upcontext['inactive_timeout'] . ' seconds!'); |
| 3773 | + } |
|
| 3586 | 3774 | |
| 3587 | 3775 | echo ' |
| 3588 | 3776 | </div> |
@@ -3598,9 +3786,10 @@ discard block |
||
| 3598 | 3786 | <td> |
| 3599 | 3787 | <input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', ' class="input_text">'; |
| 3600 | 3788 | |
| 3601 | - if (!empty($upcontext['username_incorrect'])) |
|
| 3602 | - echo ' |
|
| 3789 | + if (!empty($upcontext['username_incorrect'])) { |
|
| 3790 | + echo ' |
|
| 3603 | 3791 | <div class="smalltext" style="color: red;">Username Incorrect</div>'; |
| 3792 | + } |
|
| 3604 | 3793 | |
| 3605 | 3794 | echo ' |
| 3606 | 3795 | </td> |
@@ -3611,9 +3800,10 @@ discard block |
||
| 3611 | 3800 | <input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', ' class="input_password"> |
| 3612 | 3801 | <input type="hidden" name="hash_passwrd" value="">'; |
| 3613 | 3802 | |
| 3614 | - if (!empty($upcontext['password_failed'])) |
|
| 3615 | - echo ' |
|
| 3803 | + if (!empty($upcontext['password_failed'])) { |
|
| 3804 | + echo ' |
|
| 3616 | 3805 | <div class="smalltext" style="color: red;">Password Incorrect</div>'; |
| 3806 | + } |
|
| 3617 | 3807 | |
| 3618 | 3808 | echo ' |
| 3619 | 3809 | </td> |
@@ -3684,8 +3874,8 @@ discard block |
||
| 3684 | 3874 | <form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">'; |
| 3685 | 3875 | |
| 3686 | 3876 | // Warning message? |
| 3687 | - if (!empty($upcontext['upgrade_options_warning'])) |
|
| 3688 | - echo ' |
|
| 3877 | + if (!empty($upcontext['upgrade_options_warning'])) { |
|
| 3878 | + echo ' |
|
| 3689 | 3879 | <div style="margin: 1ex; padding: 1ex; border: 1px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3690 | 3880 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3691 | 3881 | <strong style="text-decoration: underline;">Warning!</strong><br> |
@@ -3693,6 +3883,7 @@ discard block |
||
| 3693 | 3883 | ', $upcontext['upgrade_options_warning'], ' |
| 3694 | 3884 | </div> |
| 3695 | 3885 | </div>'; |
| 3886 | + } |
|
| 3696 | 3887 | |
| 3697 | 3888 | echo ' |
| 3698 | 3889 | <table> |
@@ -3735,8 +3926,8 @@ discard block |
||
| 3735 | 3926 | </td> |
| 3736 | 3927 | </tr>'; |
| 3737 | 3928 | |
| 3738 | - if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) |
|
| 3739 | - echo ' |
|
| 3929 | + if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) { |
|
| 3930 | + echo ' |
|
| 3740 | 3931 | <tr valign="top"> |
| 3741 | 3932 | <td width="2%"> |
| 3742 | 3933 | <input type="checkbox" name="delete_karma" id="delete_karma" value="1" class="input_check"> |
@@ -3745,6 +3936,7 @@ discard block |
||
| 3745 | 3936 | <label for="delete_karma">Delete all karma settings and info from the DB</label> |
| 3746 | 3937 | </td> |
| 3747 | 3938 | </tr>'; |
| 3939 | + } |
|
| 3748 | 3940 | |
| 3749 | 3941 | echo ' |
| 3750 | 3942 | <tr valign="top"> |
@@ -3782,10 +3974,11 @@ discard block |
||
| 3782 | 3974 | </div>'; |
| 3783 | 3975 | |
| 3784 | 3976 | // Dont any tables so far? |
| 3785 | - if (!empty($upcontext['previous_tables'])) |
|
| 3786 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 3977 | + if (!empty($upcontext['previous_tables'])) { |
|
| 3978 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 3787 | 3979 | echo ' |
| 3788 | 3980 | <br>Completed Table: "', $table, '".'; |
| 3981 | + } |
|
| 3789 | 3982 | |
| 3790 | 3983 | echo ' |
| 3791 | 3984 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
@@ -3822,12 +4015,13 @@ discard block |
||
| 3822 | 4015 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 3823 | 4016 | |
| 3824 | 4017 | // If debug flood the screen. |
| 3825 | - if ($is_debug) |
|
| 3826 | - echo ' |
|
| 4018 | + if ($is_debug) { |
|
| 4019 | + echo ' |
|
| 3827 | 4020 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 3828 | 4021 | |
| 3829 | 4022 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 3830 | 4023 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4024 | + } |
|
| 3831 | 4025 | |
| 3832 | 4026 | echo ' |
| 3833 | 4027 | // Get the next update... |
@@ -3860,8 +4054,9 @@ discard block |
||
| 3860 | 4054 | { |
| 3861 | 4055 | global $upcontext, $support_js, $is_debug, $timeLimitThreshold; |
| 3862 | 4056 | |
| 3863 | - if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) |
|
| 3864 | - $is_debug = true; |
|
| 4057 | + if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) { |
|
| 4058 | + $is_debug = true; |
|
| 4059 | + } |
|
| 3865 | 4060 | |
| 3866 | 4061 | echo ' |
| 3867 | 4062 | <h3>Executing database changes</h3> |
@@ -3876,8 +4071,9 @@ discard block |
||
| 3876 | 4071 | { |
| 3877 | 4072 | foreach ($upcontext['actioned_items'] as $num => $item) |
| 3878 | 4073 | { |
| 3879 | - if ($num != 0) |
|
| 3880 | - echo ' Successful!'; |
|
| 4074 | + if ($num != 0) { |
|
| 4075 | + echo ' Successful!'; |
|
| 4076 | + } |
|
| 3881 | 4077 | echo '<br>' . $item; |
| 3882 | 4078 | } |
| 3883 | 4079 | if (!empty($upcontext['changes_complete'])) |
@@ -3890,28 +4086,32 @@ discard block |
||
| 3890 | 4086 | $seconds = intval($active % 60); |
| 3891 | 4087 | |
| 3892 | 4088 | $totalTime = ''; |
| 3893 | - if ($hours > 0) |
|
| 3894 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 3895 | - if ($minutes > 0) |
|
| 3896 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 3897 | - if ($seconds > 0) |
|
| 3898 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4089 | + if ($hours > 0) { |
|
| 4090 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4091 | + } |
|
| 4092 | + if ($minutes > 0) { |
|
| 4093 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4094 | + } |
|
| 4095 | + if ($seconds > 0) { |
|
| 4096 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4097 | + } |
|
| 3899 | 4098 | } |
| 3900 | 4099 | |
| 3901 | - if ($is_debug && !empty($totalTime)) |
|
| 3902 | - echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
| 3903 | - else |
|
| 3904 | - echo ' Successful!<br><br>'; |
|
| 4100 | + if ($is_debug && !empty($totalTime)) { |
|
| 4101 | + echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
| 4102 | + } else { |
|
| 4103 | + echo ' Successful!<br><br>'; |
|
| 4104 | + } |
|
| 3905 | 4105 | |
| 3906 | 4106 | echo '<span id="commess" style="font-weight: bold;">1 Database Updates Complete! Click Continue to Proceed.</span><br>'; |
| 3907 | 4107 | } |
| 3908 | - } |
|
| 3909 | - else |
|
| 4108 | + } else |
|
| 3910 | 4109 | { |
| 3911 | 4110 | // Tell them how many files we have in total. |
| 3912 | - if ($upcontext['file_count'] > 1) |
|
| 3913 | - echo ' |
|
| 4111 | + if ($upcontext['file_count'] > 1) { |
|
| 4112 | + echo ' |
|
| 3914 | 4113 | <strong id="info1">Executing upgrade script <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>'; |
| 4114 | + } |
|
| 3915 | 4115 | |
| 3916 | 4116 | echo ' |
| 3917 | 4117 | <h3 id="info2"><strong>Executing:</strong> "<span id="cur_item_name">', $upcontext['current_item_name'], '</span>" (<span id="item_num">', $upcontext['current_item_num'], '</span> of <span id="total_items"><span id="item_count">', $upcontext['total_items'], '</span>', $upcontext['file_count'] > 1 ? ' - of this script' : '', ')</span></h3> |
@@ -3927,19 +4127,23 @@ discard block |
||
| 3927 | 4127 | $seconds = intval($active % 60); |
| 3928 | 4128 | |
| 3929 | 4129 | $totalTime = ''; |
| 3930 | - if ($hours > 0) |
|
| 3931 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 3932 | - if ($minutes > 0) |
|
| 3933 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 3934 | - if ($seconds > 0) |
|
| 3935 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4130 | + if ($hours > 0) { |
|
| 4131 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4132 | + } |
|
| 4133 | + if ($minutes > 0) { |
|
| 4134 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4135 | + } |
|
| 4136 | + if ($seconds > 0) { |
|
| 4137 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4138 | + } |
|
| 3936 | 4139 | } |
| 3937 | 4140 | |
| 3938 | 4141 | echo ' |
| 3939 | 4142 | <br><span id="upgradeCompleted">'; |
| 3940 | 4143 | |
| 3941 | - if (!empty($totalTime)) |
|
| 3942 | - echo 'Completed in ', $totalTime, '<br>'; |
|
| 4144 | + if (!empty($totalTime)) { |
|
| 4145 | + echo 'Completed in ', $totalTime, '<br>'; |
|
| 4146 | + } |
|
| 3943 | 4147 | |
| 3944 | 4148 | echo '</span> |
| 3945 | 4149 | <div id="debug_section" style="height: 59px; overflow: auto;"> |
@@ -3976,9 +4180,10 @@ discard block |
||
| 3976 | 4180 | var getData = ""; |
| 3977 | 4181 | var debugItems = ', $upcontext['debug_items'], ';'; |
| 3978 | 4182 | |
| 3979 | - if ($is_debug) |
|
| 3980 | - echo ' |
|
| 4183 | + if ($is_debug) { |
|
| 4184 | + echo ' |
|
| 3981 | 4185 | var upgradeStartTime = ' . $upcontext['started'] . ';'; |
| 4186 | + } |
|
| 3982 | 4187 | |
| 3983 | 4188 | echo ' |
| 3984 | 4189 | function getNextItem() |
@@ -4018,9 +4223,10 @@ discard block |
||
| 4018 | 4223 | document.getElementById("error_block").style.display = ""; |
| 4019 | 4224 | setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));'; |
| 4020 | 4225 | |
| 4021 | - if ($is_debug) |
|
| 4022 | - echo ' |
|
| 4226 | + if ($is_debug) { |
|
| 4227 | + echo ' |
|
| 4023 | 4228 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
| 4229 | + } |
|
| 4024 | 4230 | |
| 4025 | 4231 | echo ' |
| 4026 | 4232 | } |
@@ -4041,9 +4247,10 @@ discard block |
||
| 4041 | 4247 | document.getElementById("error_block").style.display = ""; |
| 4042 | 4248 | setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);'; |
| 4043 | 4249 | |
| 4044 | - if ($is_debug) |
|
| 4045 | - echo ' |
|
| 4250 | + if ($is_debug) { |
|
| 4251 | + echo ' |
|
| 4046 | 4252 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
| 4253 | + } |
|
| 4047 | 4254 | |
| 4048 | 4255 | echo ' |
| 4049 | 4256 | } |
@@ -4102,8 +4309,8 @@ discard block |
||
| 4102 | 4309 | if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ') |
| 4103 | 4310 | {'; |
| 4104 | 4311 | |
| 4105 | - if ($is_debug) |
|
| 4106 | - echo ' |
|
| 4312 | + if ($is_debug) { |
|
| 4313 | + echo ' |
|
| 4107 | 4314 | document.getElementById(\'debug_section\').style.display = "none"; |
| 4108 | 4315 | |
| 4109 | 4316 | var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue); |
@@ -4121,6 +4328,7 @@ discard block |
||
| 4121 | 4328 | totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : ""); |
| 4122 | 4329 | |
| 4123 | 4330 | setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);'; |
| 4331 | + } |
|
| 4124 | 4332 | |
| 4125 | 4333 | echo ' |
| 4126 | 4334 | |
@@ -4128,9 +4336,10 @@ discard block |
||
| 4128 | 4336 | document.getElementById(\'contbutt\').disabled = 0; |
| 4129 | 4337 | document.getElementById(\'database_done\').value = 1;'; |
| 4130 | 4338 | |
| 4131 | - if ($upcontext['file_count'] > 1) |
|
| 4132 | - echo ' |
|
| 4339 | + if ($upcontext['file_count'] > 1) { |
|
| 4340 | + echo ' |
|
| 4133 | 4341 | document.getElementById(\'info1\').style.display = "none";'; |
| 4342 | + } |
|
| 4134 | 4343 | |
| 4135 | 4344 | echo ' |
| 4136 | 4345 | document.getElementById(\'info2\').style.display = "none"; |
@@ -4143,9 +4352,10 @@ discard block |
||
| 4143 | 4352 | lastItem = 0; |
| 4144 | 4353 | prevFile = curFile;'; |
| 4145 | 4354 | |
| 4146 | - if ($is_debug) |
|
| 4147 | - echo ' |
|
| 4355 | + if ($is_debug) { |
|
| 4356 | + echo ' |
|
| 4148 | 4357 | setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');'; |
| 4358 | + } |
|
| 4149 | 4359 | |
| 4150 | 4360 | echo ' |
| 4151 | 4361 | getNextItem(); |
@@ -4153,8 +4363,8 @@ discard block |
||
| 4153 | 4363 | }'; |
| 4154 | 4364 | |
| 4155 | 4365 | // If debug scroll the screen. |
| 4156 | - if ($is_debug) |
|
| 4157 | - echo ' |
|
| 4366 | + if ($is_debug) { |
|
| 4367 | + echo ' |
|
| 4158 | 4368 | if (iLastSubStepProgress == -1) |
| 4159 | 4369 | { |
| 4160 | 4370 | // Give it consistent dots. |
@@ -4173,6 +4383,7 @@ discard block |
||
| 4173 | 4383 | |
| 4174 | 4384 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4175 | 4385 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4386 | + } |
|
| 4176 | 4387 | |
| 4177 | 4388 | echo ' |
| 4178 | 4389 | // Update the page. |
@@ -4233,9 +4444,10 @@ discard block |
||
| 4233 | 4444 | }'; |
| 4234 | 4445 | |
| 4235 | 4446 | // Start things off assuming we've not errored. |
| 4236 | - if (empty($upcontext['error_message'])) |
|
| 4237 | - echo ' |
|
| 4447 | + if (empty($upcontext['error_message'])) { |
|
| 4448 | + echo ' |
|
| 4238 | 4449 | getNextItem();'; |
| 4450 | + } |
|
| 4239 | 4451 | |
| 4240 | 4452 | echo ' |
| 4241 | 4453 | //# sourceURL=dynamicScript-dbch.js |
@@ -4253,18 +4465,21 @@ discard block |
||
| 4253 | 4465 | <item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item> |
| 4254 | 4466 | <debug num="', $upcontext['current_debug_item_num'], '" percent="', isset($upcontext['substep_progress']) ? $upcontext['substep_progress'] : '-1', '" complete="', empty($upcontext['completed_step']) ? 0 : 1, '">', $upcontext['current_debug_item_name'], '</debug>'; |
| 4255 | 4467 | |
| 4256 | - if (!empty($upcontext['error_message'])) |
|
| 4257 | - echo ' |
|
| 4468 | + if (!empty($upcontext['error_message'])) { |
|
| 4469 | + echo ' |
|
| 4258 | 4470 | <error>', $upcontext['error_message'], '</error>'; |
| 4471 | + } |
|
| 4259 | 4472 | |
| 4260 | - if (!empty($upcontext['error_string'])) |
|
| 4261 | - echo ' |
|
| 4473 | + if (!empty($upcontext['error_string'])) { |
|
| 4474 | + echo ' |
|
| 4262 | 4475 | <sql>', $upcontext['error_string'], '</sql>'; |
| 4476 | + } |
|
| 4263 | 4477 | |
| 4264 | - if ($is_debug) |
|
| 4265 | - echo ' |
|
| 4478 | + if ($is_debug) { |
|
| 4479 | + echo ' |
|
| 4266 | 4480 | <curtime>', time(), '</curtime>'; |
| 4267 | -} |
|
| 4481 | + } |
|
| 4482 | + } |
|
| 4268 | 4483 | |
| 4269 | 4484 | // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications.... |
| 4270 | 4485 | function template_convert_utf8() |
@@ -4283,18 +4498,20 @@ discard block |
||
| 4283 | 4498 | </div>'; |
| 4284 | 4499 | |
| 4285 | 4500 | // Done any tables so far? |
| 4286 | - if (!empty($upcontext['previous_tables'])) |
|
| 4287 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4501 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4502 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4288 | 4503 | echo ' |
| 4289 | 4504 | <br>Completed Table: "', $table, '".'; |
| 4505 | + } |
|
| 4290 | 4506 | |
| 4291 | 4507 | echo ' |
| 4292 | 4508 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3>'; |
| 4293 | 4509 | |
| 4294 | 4510 | // If we dropped their index, let's let them know |
| 4295 | - if ($upcontext['cur_table_num'] == $upcontext['table_count'] && $upcontext['dropping_index']) |
|
| 4296 | - echo ' |
|
| 4511 | + if ($upcontext['cur_table_num'] == $upcontext['table_count'] && $upcontext['dropping_index']) { |
|
| 4512 | + echo ' |
|
| 4297 | 4513 | <br><span style="display:inline;">Please note that your fulltext index was dropped to facilitate the conversion and will need to be recreated.</span>'; |
| 4514 | + } |
|
| 4298 | 4515 | |
| 4299 | 4516 | echo ' |
| 4300 | 4517 | <br><span id="commess" style="font-weight: bold; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">Conversion Complete! Click Continue to Proceed.</span>'; |
@@ -4330,12 +4547,13 @@ discard block |
||
| 4330 | 4547 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4331 | 4548 | |
| 4332 | 4549 | // If debug flood the screen. |
| 4333 | - if ($is_debug) |
|
| 4334 | - echo ' |
|
| 4550 | + if ($is_debug) { |
|
| 4551 | + echo ' |
|
| 4335 | 4552 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 4336 | 4553 | |
| 4337 | 4554 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4338 | 4555 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4556 | + } |
|
| 4339 | 4557 | |
| 4340 | 4558 | echo ' |
| 4341 | 4559 | // Get the next update... |
@@ -4380,19 +4598,21 @@ discard block |
||
| 4380 | 4598 | </div>'; |
| 4381 | 4599 | |
| 4382 | 4600 | // Dont any tables so far? |
| 4383 | - if (!empty($upcontext['previous_tables'])) |
|
| 4384 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4601 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4602 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4385 | 4603 | echo ' |
| 4386 | 4604 | <br>Completed Table: "', $table, '".'; |
| 4605 | + } |
|
| 4387 | 4606 | |
| 4388 | 4607 | echo ' |
| 4389 | 4608 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
| 4390 | 4609 | <br><span id="commess" style="font-weight: bold; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">Convert to JSON Complete! Click Continue to Proceed.</span>'; |
| 4391 | 4610 | |
| 4392 | 4611 | // Try to make sure substep was reset. |
| 4393 | - if ($upcontext['cur_table_num'] == $upcontext['table_count']) |
|
| 4394 | - echo ' |
|
| 4612 | + if ($upcontext['cur_table_num'] == $upcontext['table_count']) { |
|
| 4613 | + echo ' |
|
| 4395 | 4614 | <input type="hidden" name="substep" id="substep" value="0">'; |
| 4615 | + } |
|
| 4396 | 4616 | |
| 4397 | 4617 | // Continue please! |
| 4398 | 4618 | $upcontext['continue'] = $support_js ? 2 : 1; |
@@ -4425,12 +4645,13 @@ discard block |
||
| 4425 | 4645 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4426 | 4646 | |
| 4427 | 4647 | // If debug flood the screen. |
| 4428 | - if ($is_debug) |
|
| 4429 | - echo ' |
|
| 4648 | + if ($is_debug) { |
|
| 4649 | + echo ' |
|
| 4430 | 4650 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 4431 | 4651 | |
| 4432 | 4652 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4433 | 4653 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4654 | + } |
|
| 4434 | 4655 | |
| 4435 | 4656 | echo ' |
| 4436 | 4657 | // Get the next update... |
@@ -4466,8 +4687,8 @@ discard block |
||
| 4466 | 4687 | <h3>That wasn\'t so hard, was it? Now you are ready to use <a href="', $boardurl, '/index.php">your installation of SMF</a>. Hope you like it!</h3> |
| 4467 | 4688 | <form action="', $boardurl, '/index.php">'; |
| 4468 | 4689 | |
| 4469 | - if (!empty($upcontext['can_delete_script'])) |
|
| 4470 | - echo ' |
|
| 4690 | + if (!empty($upcontext['can_delete_script'])) { |
|
| 4691 | + echo ' |
|
| 4471 | 4692 | <label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete(this);" class="input_check"> Delete upgrade.php and its data files now</label> <em>(doesn\'t work on all servers).</em> |
| 4472 | 4693 | <script> |
| 4473 | 4694 | function doTheDelete(theCheck) |
@@ -4479,6 +4700,7 @@ discard block |
||
| 4479 | 4700 | } |
| 4480 | 4701 | </script> |
| 4481 | 4702 | <img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>'; |
| 4703 | + } |
|
| 4482 | 4704 | |
| 4483 | 4705 | $active = time() - $upcontext['started']; |
| 4484 | 4706 | $hours = floor($active / 3600); |
@@ -4488,16 +4710,20 @@ discard block |
||
| 4488 | 4710 | if ($is_debug) |
| 4489 | 4711 | { |
| 4490 | 4712 | $totalTime = ''; |
| 4491 | - if ($hours > 0) |
|
| 4492 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4493 | - if ($minutes > 0) |
|
| 4494 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4495 | - if ($seconds > 0) |
|
| 4496 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4713 | + if ($hours > 0) { |
|
| 4714 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4715 | + } |
|
| 4716 | + if ($minutes > 0) { |
|
| 4717 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4718 | + } |
|
| 4719 | + if ($seconds > 0) { |
|
| 4720 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4721 | + } |
|
| 4497 | 4722 | } |
| 4498 | 4723 | |
| 4499 | - if ($is_debug && !empty($totalTime)) |
|
| 4500 | - echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
| 4724 | + if ($is_debug && !empty($totalTime)) { |
|
| 4725 | + echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
| 4726 | + } |
|
| 4501 | 4727 | |
| 4502 | 4728 | echo '<br> |
| 4503 | 4729 | If you had any problems with this upgrade, or have any problems using SMF, please don\'t hesitate to <a href="https://www.simplemachines.org/community/index.php">look to us for assistance</a>.<br> |
@@ -4524,8 +4750,9 @@ discard block |
||
| 4524 | 4750 | |
| 4525 | 4751 | $current_substep = $_GET['substep']; |
| 4526 | 4752 | |
| 4527 | - if (empty($_GET['a'])) |
|
| 4528 | - $_GET['a'] = 0; |
|
| 4753 | + if (empty($_GET['a'])) { |
|
| 4754 | + $_GET['a'] = 0; |
|
| 4755 | + } |
|
| 4529 | 4756 | $step_progress['name'] = 'Converting ips'; |
| 4530 | 4757 | $step_progress['current'] = $_GET['a']; |
| 4531 | 4758 | |
@@ -4568,16 +4795,19 @@ discard block |
||
| 4568 | 4795 | 'empty' => '', |
| 4569 | 4796 | 'limit' => $limit, |
| 4570 | 4797 | )); |
| 4571 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 4572 | - $arIp[] = $row[$oldCol]; |
|
| 4798 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 4799 | + $arIp[] = $row[$oldCol]; |
|
| 4800 | + } |
|
| 4573 | 4801 | $smcFunc['db_free_result']($request); |
| 4574 | 4802 | |
| 4575 | 4803 | // Special case, null ip could keep us in a loop. |
| 4576 | - if (is_null($arIp[0])) |
|
| 4577 | - unset($arIp[0]); |
|
| 4804 | + if (is_null($arIp[0])) { |
|
| 4805 | + unset($arIp[0]); |
|
| 4806 | + } |
|
| 4578 | 4807 | |
| 4579 | - if (empty($arIp)) |
|
| 4580 | - $is_done = true; |
|
| 4808 | + if (empty($arIp)) { |
|
| 4809 | + $is_done = true; |
|
| 4810 | + } |
|
| 4581 | 4811 | |
| 4582 | 4812 | $updates = array(); |
| 4583 | 4813 | $cases = array(); |
@@ -4586,16 +4816,18 @@ discard block |
||
| 4586 | 4816 | { |
| 4587 | 4817 | $arIp[$i] = trim($arIp[$i]); |
| 4588 | 4818 | |
| 4589 | - if (empty($arIp[$i])) |
|
| 4590 | - continue; |
|
| 4819 | + if (empty($arIp[$i])) { |
|
| 4820 | + continue; |
|
| 4821 | + } |
|
| 4591 | 4822 | |
| 4592 | 4823 | $updates['ip' . $i] = $arIp[$i]; |
| 4593 | 4824 | $cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}'; |
| 4594 | 4825 | |
| 4595 | 4826 | if ($setSize > 0 && $i % $setSize === 0) |
| 4596 | 4827 | { |
| 4597 | - if (count($updates) == 1) |
|
| 4598 | - continue; |
|
| 4828 | + if (count($updates) == 1) { |
|
| 4829 | + continue; |
|
| 4830 | + } |
|
| 4599 | 4831 | |
| 4600 | 4832 | $updates['whereSet'] = array_values($updates); |
| 4601 | 4833 | $smcFunc['db_query']('', ' |
@@ -4629,8 +4861,7 @@ discard block |
||
| 4629 | 4861 | 'ip' => $ip |
| 4630 | 4862 | )); |
| 4631 | 4863 | } |
| 4632 | - } |
|
| 4633 | - else |
|
| 4864 | + } else |
|
| 4634 | 4865 | { |
| 4635 | 4866 | $updates['whereSet'] = array_values($updates); |
| 4636 | 4867 | $smcFunc['db_query']('', ' |
@@ -4644,9 +4875,9 @@ discard block |
||
| 4644 | 4875 | $updates |
| 4645 | 4876 | ); |
| 4646 | 4877 | } |
| 4878 | + } else { |
|
| 4879 | + $is_done = true; |
|
| 4647 | 4880 | } |
| 4648 | - else |
|
| 4649 | - $is_done = true; |
|
| 4650 | 4881 | |
| 4651 | 4882 | $_GET['a'] += $limit; |
| 4652 | 4883 | $step_progress['current'] = $_GET['a']; |
@@ -4672,10 +4903,11 @@ discard block |
||
| 4672 | 4903 | |
| 4673 | 4904 | $columns = $smcFunc['db_list_columns']($targetTable, true); |
| 4674 | 4905 | |
| 4675 | - if (isset($columns[$column])) |
|
| 4676 | - return $columns[$column]; |
|
| 4677 | - else |
|
| 4678 | - return null; |
|
| 4679 | -} |
|
| 4906 | + if (isset($columns[$column])) { |
|
| 4907 | + return $columns[$column]; |
|
| 4908 | + } else { |
|
| 4909 | + return null; |
|
| 4910 | + } |
|
| 4911 | + } |
|
| 4680 | 4912 | |
| 4681 | 4913 | ?> |
| 4682 | 4914 | \ No newline at end of file |
@@ -40,16 +40,14 @@ discard block |
||
| 40 | 40 | ', template_show_upcoming_list('main'), ' |
| 41 | 41 | </div> |
| 42 | 42 | '; |
| 43 | - } |
|
| 44 | - elseif ($context['calendar_view'] == 'view_week') |
|
| 43 | + } elseif ($context['calendar_view'] == 'view_week') |
|
| 45 | 44 | { |
| 46 | 45 | echo ' |
| 47 | 46 | <div id="main_grid"> |
| 48 | 47 | ', template_show_week_grid('main'), ' |
| 49 | 48 | </div> |
| 50 | 49 | '; |
| 51 | - } |
|
| 52 | - else |
|
| 50 | + } else |
|
| 53 | 51 | { |
| 54 | 52 | echo ' |
| 55 | 53 | <div id="main_grid"> |
@@ -75,8 +73,9 @@ discard block |
||
| 75 | 73 | global $context, $scripturl, $txt; |
| 76 | 74 | |
| 77 | 75 | // Bail out if we have nothing to work with |
| 78 | - if (!isset($context['calendar_grid_' . $grid_name])) |
|
| 79 | - return false; |
|
| 76 | + if (!isset($context['calendar_grid_' . $grid_name])) { |
|
| 77 | + return false; |
|
| 78 | + } |
|
| 80 | 79 | |
| 81 | 80 | // Protect programmer sanity |
| 82 | 81 | $calendar_data = &$context['calendar_grid_' . $grid_name]; |
@@ -113,11 +112,13 @@ discard block |
||
| 113 | 112 | <li class="windowbg"> |
| 114 | 113 | <b class="event_title">', $event['link'], '</b>'; |
| 115 | 114 | |
| 116 | - if ($event['can_edit']) |
|
| 117 | - echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>'; |
|
| 115 | + if ($event['can_edit']) { |
|
| 116 | + echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>'; |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | - if ($event['can_export']) |
|
| 120 | - echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>'; |
|
| 119 | + if ($event['can_export']) { |
|
| 120 | + echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>'; |
|
| 121 | + } |
|
| 121 | 122 | |
| 122 | 123 | echo ' |
| 123 | 124 | <br>'; |
@@ -125,14 +126,14 @@ discard block |
||
| 125 | 126 | if (!empty($event['allday'])) |
| 126 | 127 | { |
| 127 | 128 | echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), '</time>', ($event['start_date'] != $event['end_date']) ? ' – <time datetime="' . $event['end_iso_gmdate'] . '">' . trim($event['end_date_local']) . '</time>' : ''; |
| 128 | - } |
|
| 129 | - else |
|
| 129 | + } else |
|
| 130 | 130 | { |
| 131 | 131 | // Display event info relative to user's local timezone |
| 132 | 132 | echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), ', ', trim($event['start_time_local']), '</time> – <time datetime="' . $event['end_iso_gmdate'] . '">'; |
| 133 | 133 | |
| 134 | - if ($event['start_date_local'] != $event['end_date_local']) |
|
| 135 | - echo trim($event['end_date_local']) . ', '; |
|
| 134 | + if ($event['start_date_local'] != $event['end_date_local']) { |
|
| 135 | + echo trim($event['end_date_local']) . ', '; |
|
| 136 | + } |
|
| 136 | 137 | |
| 137 | 138 | echo trim($event['end_time_local']); |
| 138 | 139 | |
@@ -141,23 +142,27 @@ discard block |
||
| 141 | 142 | { |
| 142 | 143 | echo '</time> (<time datetime="' . $event['start_iso_gmdate'] . '">'; |
| 143 | 144 | |
| 144 | - if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) |
|
| 145 | - echo trim($event['start_date_orig']), ', '; |
|
| 145 | + if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) { |
|
| 146 | + echo trim($event['start_date_orig']), ', '; |
|
| 147 | + } |
|
| 146 | 148 | |
| 147 | 149 | echo trim($event['start_time_orig']), '</time> – <time datetime="' . $event['end_iso_gmdate'] . '">'; |
| 148 | 150 | |
| 149 | - if ($event['start_date_orig'] != $event['end_date_orig']) |
|
| 150 | - echo trim($event['end_date_orig']) . ', '; |
|
| 151 | + if ($event['start_date_orig'] != $event['end_date_orig']) { |
|
| 152 | + echo trim($event['end_date_orig']) . ', '; |
|
| 153 | + } |
|
| 151 | 154 | |
| 152 | 155 | echo trim($event['end_time_orig']), ' ', $event['tz_abbrev'], '</time>)'; |
| 153 | 156 | } |
| 154 | 157 | // Event is scheduled in the user's own timezone? Let 'em know, just to avoid confusion |
| 155 | - else |
|
| 156 | - echo ' ', $event['tz_abbrev'], '</time>'; |
|
| 158 | + else { |
|
| 159 | + echo ' ', $event['tz_abbrev'], '</time>'; |
|
| 160 | + } |
|
| 157 | 161 | } |
| 158 | 162 | |
| 159 | - if (!empty($event['location'])) |
|
| 160 | - echo '<br>', $event['location']; |
|
| 163 | + if (!empty($event['location'])) { |
|
| 164 | + echo '<br>', $event['location']; |
|
| 165 | + } |
|
| 161 | 166 | |
| 162 | 167 | echo ' |
| 163 | 168 | </li>'; |
@@ -189,8 +194,9 @@ discard block |
||
| 189 | 194 | |
| 190 | 195 | $birthdays = array(); |
| 191 | 196 | |
| 192 | - foreach ($date as $member) |
|
| 193 | - $birthdays[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '">' . $member['name'] . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>'; |
|
| 197 | + foreach ($date as $member) { |
|
| 198 | + $birthdays[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '">' . $member['name'] . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>'; |
|
| 199 | + } |
|
| 194 | 200 | |
| 195 | 201 | echo implode(', ', $birthdays); |
| 196 | 202 | |
@@ -221,8 +227,9 @@ discard block |
||
| 221 | 227 | $date_local = $date['date_local']; |
| 222 | 228 | unset($date['date_local']); |
| 223 | 229 | |
| 224 | - foreach ($date as $holiday) |
|
| 225 | - $holidays[] = $holiday . ' (' . $date_local . ')'; |
|
| 230 | + foreach ($date as $holiday) { |
|
| 231 | + $holidays[] = $holiday . ' (' . $date_local . ')'; |
|
| 232 | + } |
|
| 226 | 233 | } |
| 227 | 234 | |
| 228 | 235 | echo implode(', ', $holidays); |
@@ -245,17 +252,19 @@ discard block |
||
| 245 | 252 | global $context, $txt, $scripturl, $modSettings; |
| 246 | 253 | |
| 247 | 254 | // If the grid doesn't exist, no point in proceeding. |
| 248 | - if (!isset($context['calendar_grid_' . $grid_name])) |
|
| 249 | - return false; |
|
| 255 | + if (!isset($context['calendar_grid_' . $grid_name])) { |
|
| 256 | + return false; |
|
| 257 | + } |
|
| 250 | 258 | |
| 251 | 259 | // A handy little pointer variable. |
| 252 | 260 | $calendar_data = &$context['calendar_grid_' . $grid_name]; |
| 253 | 261 | |
| 254 | 262 | // Some conditions for whether or not we should show the week links *here*. |
| 255 | - if (isset($calendar_data['show_week_links']) && ($calendar_data['show_week_links'] == 3 || (($calendar_data['show_week_links'] == 1 && $is_mini === true) || $calendar_data['show_week_links'] == 2 && $is_mini === false))) |
|
| 256 | - $show_week_links = true; |
|
| 257 | - else |
|
| 258 | - $show_week_links = false; |
|
| 263 | + if (isset($calendar_data['show_week_links']) && ($calendar_data['show_week_links'] == 3 || (($calendar_data['show_week_links'] == 1 && $is_mini === true) || $calendar_data['show_week_links'] == 2 && $is_mini === false))) { |
|
| 264 | + $show_week_links = true; |
|
| 265 | + } else { |
|
| 266 | + $show_week_links = false; |
|
| 267 | + } |
|
| 259 | 268 | |
| 260 | 269 | // Assuming that we've not disabled it, show the title block! |
| 261 | 270 | if (empty($calendar_data['disable_title'])) |
@@ -294,8 +303,9 @@ discard block |
||
| 294 | 303 | } |
| 295 | 304 | |
| 296 | 305 | // Show the controls on main grids |
| 297 | - if ($is_mini === false) |
|
| 298 | - template_calendar_top($calendar_data); |
|
| 306 | + if ($is_mini === false) { |
|
| 307 | + template_calendar_top($calendar_data); |
|
| 308 | + } |
|
| 299 | 309 | |
| 300 | 310 | // Finally, the main calendar table. |
| 301 | 311 | echo '<table class="calendar_table">'; |
@@ -306,8 +316,9 @@ discard block |
||
| 306 | 316 | echo '<tr>'; |
| 307 | 317 | |
| 308 | 318 | // If we're showing week links, there's an extra column ahead of the week links, so let's think ahead and be prepared! |
| 309 | - if ($show_week_links === true) |
|
| 310 | - echo '<th> </th>'; |
|
| 319 | + if ($show_week_links === true) { |
|
| 320 | + echo '<th> </th>'; |
|
| 321 | + } |
|
| 311 | 322 | |
| 312 | 323 | // Now, loop through each actual day of the week. |
| 313 | 324 | foreach ($calendar_data['week_days'] as $day) |
@@ -354,27 +365,29 @@ discard block |
||
| 354 | 365 | // Additional classes are given for events, holidays, and birthdays. |
| 355 | 366 | if (!empty($day['events']) && !empty($calendar_data['highlight']['events'])) |
| 356 | 367 | { |
| 357 | - if ($is_mini === true && in_array($calendar_data['highlight']['events'], array(1, 3))) |
|
| 358 | - $classes[] = 'events'; |
|
| 359 | - elseif ($is_mini === false && in_array($calendar_data['highlight']['events'], array(2, 3))) |
|
| 360 | - $classes[] = 'events'; |
|
| 368 | + if ($is_mini === true && in_array($calendar_data['highlight']['events'], array(1, 3))) { |
|
| 369 | + $classes[] = 'events'; |
|
| 370 | + } elseif ($is_mini === false && in_array($calendar_data['highlight']['events'], array(2, 3))) { |
|
| 371 | + $classes[] = 'events'; |
|
| 372 | + } |
|
| 361 | 373 | } |
| 362 | 374 | if (!empty($day['holidays']) && !empty($calendar_data['highlight']['holidays'])) |
| 363 | 375 | { |
| 364 | - if ($is_mini === true && in_array($calendar_data['highlight']['holidays'], array(1, 3))) |
|
| 365 | - $classes[] = 'holidays'; |
|
| 366 | - elseif ($is_mini === false && in_array($calendar_data['highlight']['holidays'], array(2, 3))) |
|
| 367 | - $classes[] = 'holidays'; |
|
| 376 | + if ($is_mini === true && in_array($calendar_data['highlight']['holidays'], array(1, 3))) { |
|
| 377 | + $classes[] = 'holidays'; |
|
| 378 | + } elseif ($is_mini === false && in_array($calendar_data['highlight']['holidays'], array(2, 3))) { |
|
| 379 | + $classes[] = 'holidays'; |
|
| 380 | + } |
|
| 368 | 381 | } |
| 369 | 382 | if (!empty($day['birthdays']) && !empty($calendar_data['highlight']['birthdays'])) |
| 370 | 383 | { |
| 371 | - if ($is_mini === true && in_array($calendar_data['highlight']['birthdays'], array(1, 3))) |
|
| 372 | - $classes[] = 'birthdays'; |
|
| 373 | - elseif ($is_mini === false && in_array($calendar_data['highlight']['birthdays'], array(2, 3))) |
|
| 374 | - $classes[] = 'birthdays'; |
|
| 384 | + if ($is_mini === true && in_array($calendar_data['highlight']['birthdays'], array(1, 3))) { |
|
| 385 | + $classes[] = 'birthdays'; |
|
| 386 | + } elseif ($is_mini === false && in_array($calendar_data['highlight']['birthdays'], array(2, 3))) { |
|
| 387 | + $classes[] = 'birthdays'; |
|
| 388 | + } |
|
| 375 | 389 | } |
| 376 | - } |
|
| 377 | - else |
|
| 390 | + } else |
|
| 378 | 391 | { |
| 379 | 392 | // Default Classes (either compact or comfortable and disabled). |
| 380 | 393 | $classes[] = !empty($calendar_data['size']) && $calendar_data['size'] == 'small' ? 'compact' : 'comfortable'; |
@@ -392,17 +405,19 @@ discard block |
||
| 392 | 405 | $title_prefix = !empty($day['is_first_of_month']) && $context['current_month'] == $calendar_data['current_month'] && $is_mini === false ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$calendar_data['current_month']] . ' ' : $txt['months_titles'][$calendar_data['current_month']] . ' ') : ''; |
| 393 | 406 | |
| 394 | 407 | // The actual day number - be it a link, or just plain old text! |
| 395 | - if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) |
|
| 396 | - echo '<a href="', $scripturl, '?action=calendar;sa=post;year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="day_text">', $title_prefix, $day['day'], '</span></a>'; |
|
| 397 | - else |
|
| 398 | - echo '<span class="day_text">', $title_prefix, $day['day'], '</span>'; |
|
| 408 | + if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) { |
|
| 409 | + echo '<a href="', $scripturl, '?action=calendar;sa=post;year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="day_text">', $title_prefix, $day['day'], '</span></a>'; |
|
| 410 | + } else { |
|
| 411 | + echo '<span class="day_text">', $title_prefix, $day['day'], '</span>'; |
|
| 412 | + } |
|
| 399 | 413 | |
| 400 | 414 | // A lot of stuff, we're not showing on mini-calendars to conserve space. |
| 401 | 415 | if ($is_mini === false) |
| 402 | 416 | { |
| 403 | 417 | // Holidays are always fun, let's show them! |
| 404 | - if (!empty($day['holidays'])) |
|
| 405 | - echo '<div class="smalltext holiday"><span>', $txt['calendar_prompt'], '</span> ', implode(', ', $day['holidays']), '</div>'; |
|
| 418 | + if (!empty($day['holidays'])) { |
|
| 419 | + echo '<div class="smalltext holiday"><span>', $txt['calendar_prompt'], '</span> ', implode(', ', $day['holidays']), '</div>'; |
|
| 420 | + } |
|
| 406 | 421 | |
| 407 | 422 | // Happy Birthday Dear, Member! |
| 408 | 423 | if (!empty($day['birthdays'])) |
@@ -420,14 +435,16 @@ discard block |
||
| 420 | 435 | echo '<a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">', $member['name'], '</span>', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', $member['is_last'] || ($count == 10 && $use_js_hide) ? '' : ', '; |
| 421 | 436 | |
| 422 | 437 | // 9...10! Let's stop there. |
| 423 | - if ($birthday_count == 10 && $use_js_hide) |
|
| 424 | - // !!TODO - Inline CSS and JavaScript should be moved. |
|
| 438 | + if ($birthday_count == 10 && $use_js_hide) { |
|
| 439 | + // !!TODO - Inline CSS and JavaScript should be moved. |
|
| 425 | 440 | echo '<span class="hidelink" id="bdhidelink_', $day['day'], '">...<br><a href="', $scripturl, '?action=calendar;month=', $calendar_data['current_month'], ';year=', $calendar_data['current_year'], ';showbd" onclick="document.getElementById(\'bdhide_', $day['day'], '\').style.display = \'\'; document.getElementById(\'bdhidelink_', $day['day'], '\').style.display = \'none\'; return false;">(', sprintf($txt['calendar_click_all'], count($day['birthdays'])), ')</a></span><span id="bdhide_', $day['day'], '" style="display: none;">, '; |
| 441 | + } |
|
| 426 | 442 | |
| 427 | 443 | ++$birthday_count; |
| 428 | 444 | } |
| 429 | - if ($use_js_hide) |
|
| 430 | - echo '</span>'; |
|
| 445 | + if ($use_js_hide) { |
|
| 446 | + echo '</span>'; |
|
| 447 | + } |
|
| 431 | 448 | |
| 432 | 449 | echo '</div>'; |
| 433 | 450 | } |
@@ -437,8 +454,9 @@ discard block |
||
| 437 | 454 | { |
| 438 | 455 | // Sort events by start time (all day events will be listed first) |
| 439 | 456 | uasort($day['events'], function($a, $b) { |
| 440 | - if ($a['start_timestamp'] == $b['start_timestamp']) |
|
| 441 | - return 0; |
|
| 457 | + if ($a['start_timestamp'] == $b['start_timestamp']) { |
|
| 458 | + return 0; |
|
| 459 | + } |
|
| 442 | 460 | return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1; |
| 443 | 461 | }); |
| 444 | 462 | |
@@ -454,17 +472,19 @@ discard block |
||
| 454 | 472 | |
| 455 | 473 | echo '<div class="event_wrapper', $event['starts_today'] == true ? ' event_starts_today' : '', $event['ends_today'] == true ? ' event_ends_today' : '', $event['allday'] == true ? ' allday' : '', $event['is_selected'] ? ' sel_event' : '', '">', $event['link'], '<br><span class="event_time', empty($event_icons_needed) ? ' floatright' : '', '">'; |
| 456 | 474 | |
| 457 | - if (!empty($event['start_time_local']) && $event['starts_today'] == true) |
|
| 458 | - echo trim(str_replace(':00 ', ' ', $event['start_time_local'])); |
|
| 459 | - elseif (!empty($event['end_time_local']) && $event['ends_today'] == true) |
|
| 460 | - echo strtolower($txt['ends']), ' ', trim(str_replace(':00 ', ' ', $event['end_time_local'])); |
|
| 461 | - elseif (!empty($event['allday'])) |
|
| 462 | - echo $txt['calendar_allday']; |
|
| 475 | + if (!empty($event['start_time_local']) && $event['starts_today'] == true) { |
|
| 476 | + echo trim(str_replace(':00 ', ' ', $event['start_time_local'])); |
|
| 477 | + } elseif (!empty($event['end_time_local']) && $event['ends_today'] == true) { |
|
| 478 | + echo strtolower($txt['ends']), ' ', trim(str_replace(':00 ', ' ', $event['end_time_local'])); |
|
| 479 | + } elseif (!empty($event['allday'])) { |
|
| 480 | + echo $txt['calendar_allday']; |
|
| 481 | + } |
|
| 463 | 482 | |
| 464 | 483 | echo '</span>'; |
| 465 | 484 | |
| 466 | - if (!empty($event['location'])) |
|
| 467 | - echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>'; |
|
| 485 | + if (!empty($event['location'])) { |
|
| 486 | + echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>'; |
|
| 487 | + } |
|
| 468 | 488 | |
| 469 | 489 | if ($event['can_edit'] || $event['can_export']) |
| 470 | 490 | { |
@@ -501,10 +521,11 @@ discard block |
||
| 501 | 521 | // Otherwise, assuming it's not a mini-calendar, we can show previous / next month days! |
| 502 | 522 | elseif ($is_mini === false) |
| 503 | 523 | { |
| 504 | - if (empty($current_month_started) && !empty($context['calendar_grid_prev'])) |
|
| 505 | - echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_prev']['current_year'], ';month=', $context['calendar_grid_prev']['current_month'], '">', $context['calendar_grid_prev']['last_of_month'] - $calendar_data['shift']-- +1, '</a>'; |
|
| 506 | - elseif (!empty($current_month_started) && !empty($context['calendar_grid_next'])) |
|
| 507 | - echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_next']['current_year'], ';month=', $context['calendar_grid_next']['current_month'], '">', $current_month_started + 1 == $count ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$context['calendar_grid_next']['current_month']] . ' ' : $txt['months_titles'][$context['calendar_grid_next']['current_month']] . ' ') : '', $final_count++, '</a>'; |
|
| 524 | + if (empty($current_month_started) && !empty($context['calendar_grid_prev'])) { |
|
| 525 | + echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_prev']['current_year'], ';month=', $context['calendar_grid_prev']['current_month'], '">', $context['calendar_grid_prev']['last_of_month'] - $calendar_data['shift']-- +1, '</a>'; |
|
| 526 | + } elseif (!empty($current_month_started) && !empty($context['calendar_grid_next'])) { |
|
| 527 | + echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_next']['current_year'], ';month=', $context['calendar_grid_next']['current_month'], '">', $current_month_started + 1 == $count ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$context['calendar_grid_next']['current_month']] . ' ' : $txt['months_titles'][$context['calendar_grid_next']['current_month']] . ' ') : '', $final_count++, '</a>'; |
|
| 528 | + } |
|
| 508 | 529 | } |
| 509 | 530 | |
| 510 | 531 | // Close this day and increase var count. |
@@ -530,8 +551,9 @@ discard block |
||
| 530 | 551 | global $context, $txt, $scripturl, $modSettings; |
| 531 | 552 | |
| 532 | 553 | // We might have no reason to proceed, if the variable isn't there. |
| 533 | - if (!isset($context['calendar_grid_' . $grid_name])) |
|
| 534 | - return false; |
|
| 554 | + if (!isset($context['calendar_grid_' . $grid_name])) { |
|
| 555 | + return false; |
|
| 556 | + } |
|
| 535 | 557 | |
| 536 | 558 | // Handy pointer. |
| 537 | 559 | $calendar_data = &$context['calendar_grid_' . $grid_name]; |
@@ -566,8 +588,9 @@ discard block |
||
| 566 | 588 | } |
| 567 | 589 | |
| 568 | 590 | // The Month Title + Week Number... |
| 569 | - if (!empty($calendar_data['week_title'])) |
|
| 570 | - echo $calendar_data['week_title']; |
|
| 591 | + if (!empty($calendar_data['week_title'])) { |
|
| 592 | + echo $calendar_data['week_title']; |
|
| 593 | + } |
|
| 571 | 594 | |
| 572 | 595 | echo ' |
| 573 | 596 | </h3> |
@@ -606,10 +629,11 @@ discard block |
||
| 606 | 629 | <tr class="days_wrapper"> |
| 607 | 630 | <td class="', implode(' ', $classes), ' act_day">'; |
| 608 | 631 | // Should the day number be a link? |
| 609 | - if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) |
|
| 610 | - echo '<a href="', $scripturl, '?action=calendar;sa=post;month=', $month_data['current_month'], ';year=', $month_data['current_year'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['days'][$day['day_of_week']], ' - ', $day['day'], '</a>'; |
|
| 611 | - else |
|
| 612 | - echo $txt['days'][$day['day_of_week']], ' - ', $day['day']; |
|
| 632 | + if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) { |
|
| 633 | + echo '<a href="', $scripturl, '?action=calendar;sa=post;month=', $month_data['current_month'], ';year=', $month_data['current_year'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['days'][$day['day_of_week']], ' - ', $day['day'], '</a>'; |
|
| 634 | + } else { |
|
| 635 | + echo $txt['days'][$day['day_of_week']], ' - ', $day['day']; |
|
| 636 | + } |
|
| 613 | 637 | |
| 614 | 638 | echo '</td> |
| 615 | 639 | <td class="', implode(' ', $classes), '', empty($day['events']) ? (' disabled' . ($context['can_post'] ? ' week_post' : '')) : ' events', ' event_col" data-css-prefix="' . $txt['events'] . ' ', (empty($day['events']) && empty($context['can_post'])) ? $txt['none'] : '', '">'; |
@@ -618,8 +642,9 @@ discard block |
||
| 618 | 642 | { |
| 619 | 643 | // Sort events by start time (all day events will be listed first) |
| 620 | 644 | uasort($day['events'], function($a, $b) { |
| 621 | - if ($a['start_timestamp'] == $b['start_timestamp']) |
|
| 622 | - return 0; |
|
| 645 | + if ($a['start_timestamp'] == $b['start_timestamp']) { |
|
| 646 | + return 0; |
|
| 647 | + } |
|
| 623 | 648 | return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1; |
| 624 | 649 | }); |
| 625 | 650 | |
@@ -631,15 +656,17 @@ discard block |
||
| 631 | 656 | |
| 632 | 657 | echo $event['link'], '<br><span class="event_time', empty($event_icons_needed) ? ' floatright' : '', '">'; |
| 633 | 658 | |
| 634 | - if (!empty($event['start_time_local'])) |
|
| 635 | - echo trim($event['start_time_local']), !empty($event['end_time_local']) ? ' – ' . trim($event['end_time_local']) : ''; |
|
| 636 | - else |
|
| 637 | - echo $txt['calendar_allday']; |
|
| 659 | + if (!empty($event['start_time_local'])) { |
|
| 660 | + echo trim($event['start_time_local']), !empty($event['end_time_local']) ? ' – ' . trim($event['end_time_local']) : ''; |
|
| 661 | + } else { |
|
| 662 | + echo $txt['calendar_allday']; |
|
| 663 | + } |
|
| 638 | 664 | |
| 639 | 665 | echo '</span>'; |
| 640 | 666 | |
| 641 | - if (!empty($event['location'])) |
|
| 642 | - echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>'; |
|
| 667 | + if (!empty($event['location'])) { |
|
| 668 | + echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>'; |
|
| 669 | + } |
|
| 643 | 670 | |
| 644 | 671 | if (!empty($event_icons_needed)) |
| 645 | 672 | { |
@@ -676,8 +703,7 @@ discard block |
||
| 676 | 703 | </div> |
| 677 | 704 | <br class="clear">'; |
| 678 | 705 | } |
| 679 | - } |
|
| 680 | - else |
|
| 706 | + } else |
|
| 681 | 707 | { |
| 682 | 708 | if (!empty($context['can_post'])) |
| 683 | 709 | { |
@@ -690,8 +716,9 @@ discard block |
||
| 690 | 716 | echo '</td> |
| 691 | 717 | <td class="', implode(' ', $classes), !empty($day['holidays']) ? ' holidays' : ' disabled', ' holiday_col" data-css-prefix="' . $txt['calendar_prompt'] . ' ">'; |
| 692 | 718 | // Show any holidays! |
| 693 | - if (!empty($day['holidays'])) |
|
| 694 | - echo implode('<br>', $day['holidays']); |
|
| 719 | + if (!empty($day['holidays'])) { |
|
| 720 | + echo implode('<br>', $day['holidays']); |
|
| 721 | + } |
|
| 695 | 722 | |
| 696 | 723 | echo '</td> |
| 697 | 724 | <td class="', implode(' ', $classes), '', !empty($day['birthdays']) ? ' birthdays' : ' disabled', ' birthday_col" data-css-prefix="' . $txt['birthdays'] . ' ">'; |
@@ -749,8 +776,7 @@ discard block |
||
| 749 | 776 | <input type="text" name="end_date" id="end_date" maxlength="10" value="', $calendar_data['end_date'], '" tabindex="', $context['tabindex']++, '" class="input_text date_input end" data-type="date"> |
| 750 | 777 | <input type="submit" class="button_submit" style="float:none" id="view_button" value="', $txt['view'], '"> |
| 751 | 778 | </form>'; |
| 752 | - } |
|
| 753 | - else |
|
| 779 | + } else |
|
| 754 | 780 | { |
| 755 | 781 | echo' |
| 756 | 782 | <form action="', $scripturl, '?action=calendar" id="calendar_navigation" method="post" accept-charset="', $context['character_set'], '"> |
@@ -792,8 +818,9 @@ discard block |
||
| 792 | 818 | echo ' |
| 793 | 819 | <form action="', $scripturl, '?action=calendar;sa=post" method="post" name="postevent" accept-charset="', $context['character_set'], '" onsubmit="submitonce(this);smc_saveEntities(\'postevent\', [\'evtitle\']);" style="margin: 0;">'; |
| 794 | 820 | |
| 795 | - if (!empty($context['event']['new'])) |
|
| 796 | - echo '<input type="hidden" name="eventid" value="', $context['event']['eventid'], '">'; |
|
| 821 | + if (!empty($context['event']['new'])) { |
|
| 822 | + echo '<input type="hidden" name="eventid" value="', $context['event']['eventid'], '">'; |
|
| 823 | + } |
|
| 797 | 824 | |
| 798 | 825 | // Start the main table. |
| 799 | 826 | echo ' |
@@ -843,9 +870,10 @@ discard block |
||
| 843 | 870 | { |
| 844 | 871 | echo ' |
| 845 | 872 | <optgroup label="', $category['name'], '">'; |
| 846 | - foreach ($category['boards'] as $board) |
|
| 847 | - echo ' |
|
| 873 | + foreach ($category['boards'] as $board) { |
|
| 874 | + echo ' |
|
| 848 | 875 | <option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=>' : '', ' ', $board['name'], ' </option>'; |
| 876 | + } |
|
| 849 | 877 | echo ' |
| 850 | 878 | </optgroup>'; |
| 851 | 879 | } |
@@ -881,9 +909,10 @@ discard block |
||
| 881 | 909 | <span class="label">', $txt['calendar_timezone'], '</span> |
| 882 | 910 | <select name="tz" id="tz"', !empty($context['event']['allday']) ? ' disabled' : '', '>'; |
| 883 | 911 | |
| 884 | - foreach ($context['all_timezones'] as $tz => $tzname) |
|
| 885 | - echo ' |
|
| 912 | + foreach ($context['all_timezones'] as $tz => $tzname) { |
|
| 913 | + echo ' |
|
| 886 | 914 | <option value="', $tz, '"', $tz == $context['event']['tz'] ? ' selected' : '', '>', $tzname, '</option>'; |
| 915 | + } |
|
| 887 | 916 | |
| 888 | 917 | echo ' |
| 889 | 918 | </select> |
@@ -898,9 +927,10 @@ discard block |
||
| 898 | 927 | echo ' |
| 899 | 928 | <input type="submit" value="', empty($context['event']['new']) ? $txt['save'] : $txt['post'], '" class="button_submit">'; |
| 900 | 929 | // Delete button? |
| 901 | - if (empty($context['event']['new'])) |
|
| 902 | - echo ' |
|
| 930 | + if (empty($context['event']['new'])) { |
|
| 931 | + echo ' |
|
| 903 | 932 | <input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['calendar_confirm_delete'], '" class="button_submit you_sure">'; |
| 933 | + } |
|
| 904 | 934 | |
| 905 | 935 | echo ' |
| 906 | 936 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -944,9 +974,10 @@ discard block |
||
| 944 | 974 | |
| 945 | 975 | foreach ($context['clockicons'] as $t => $v) |
| 946 | 976 | { |
| 947 | - foreach ($v as $i) |
|
| 948 | - echo ' |
|
| 977 | + foreach ($v as $i) { |
|
| 978 | + echo ' |
|
| 949 | 979 | icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');'; |
| 980 | + } |
|
| 950 | 981 | } |
| 951 | 982 | |
| 952 | 983 | echo ' |
@@ -971,13 +1002,14 @@ discard block |
||
| 971 | 1002 | |
| 972 | 1003 | foreach ($context['clockicons'] as $t => $v) |
| 973 | 1004 | { |
| 974 | - foreach ($v as $i) |
|
| 975 | - echo ' |
|
| 1005 | + foreach ($v as $i) { |
|
| 1006 | + echo ' |
|
| 976 | 1007 | if (', $t, ' >= ', $i, ') |
| 977 | 1008 | { |
| 978 | 1009 | turnon.push("', $t, '_', $i, '"); |
| 979 | 1010 | ', $t, ' -= ', $i, '; |
| 980 | 1011 | }'; |
| 1012 | + } |
|
| 981 | 1013 | } |
| 982 | 1014 | |
| 983 | 1015 | echo ' |
@@ -1041,9 +1073,10 @@ discard block |
||
| 1041 | 1073 | |
| 1042 | 1074 | foreach ($context['clockicons'] as $t => $v) |
| 1043 | 1075 | { |
| 1044 | - foreach ($v as $i) |
|
| 1045 | - echo ' |
|
| 1076 | + foreach ($v as $i) { |
|
| 1077 | + echo ' |
|
| 1046 | 1078 | icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');'; |
| 1079 | + } |
|
| 1047 | 1080 | } |
| 1048 | 1081 | |
| 1049 | 1082 | echo ' |
@@ -1060,13 +1093,14 @@ discard block |
||
| 1060 | 1093 | |
| 1061 | 1094 | foreach ($context['clockicons'] as $t => $v) |
| 1062 | 1095 | { |
| 1063 | - foreach ($v as $i) |
|
| 1064 | - echo ' |
|
| 1096 | + foreach ($v as $i) { |
|
| 1097 | + echo ' |
|
| 1065 | 1098 | if (', $t, ' >= ', $i, ') |
| 1066 | 1099 | { |
| 1067 | 1100 | turnon.push("', $t, '_', $i, '"); |
| 1068 | 1101 | ', $t, ' -= ', $i, '; |
| 1069 | 1102 | }'; |
| 1103 | + } |
|
| 1070 | 1104 | } |
| 1071 | 1105 | |
| 1072 | 1106 | echo ' |
@@ -1125,9 +1159,10 @@ discard block |
||
| 1125 | 1159 | |
| 1126 | 1160 | foreach ($context['clockicons'] as $t => $v) |
| 1127 | 1161 | { |
| 1128 | - foreach ($v as $i) |
|
| 1129 | - echo ' |
|
| 1162 | + foreach ($v as $i) { |
|
| 1163 | + echo ' |
|
| 1130 | 1164 | icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');'; |
| 1165 | + } |
|
| 1131 | 1166 | } |
| 1132 | 1167 | |
| 1133 | 1168 | echo ' |
@@ -1148,13 +1183,14 @@ discard block |
||
| 1148 | 1183 | |
| 1149 | 1184 | foreach ($context['clockicons'] as $t => $v) |
| 1150 | 1185 | { |
| 1151 | - foreach ($v as $i) |
|
| 1152 | - echo ' |
|
| 1186 | + foreach ($v as $i) { |
|
| 1187 | + echo ' |
|
| 1153 | 1188 | if (', $t, ' >= ', $i, ') |
| 1154 | 1189 | { |
| 1155 | 1190 | turnon.push("', $t, '_', $i, '"); |
| 1156 | 1191 | ', $t, ' -= ', $i, '; |
| 1157 | 1192 | }'; |
| 1193 | + } |
|
| 1158 | 1194 | } |
| 1159 | 1195 | |
| 1160 | 1196 | echo ' |
@@ -64,9 +64,10 @@ discard block |
||
| 64 | 64 | <strong>', $txt['administrators'], ':</strong> |
| 65 | 65 | ', implode(', ', $context['administrators']); |
| 66 | 66 | // If we have lots of admins... don't show them all. |
| 67 | - if (!empty($context['more_admins_link'])) |
|
| 68 | - echo ' |
|
| 67 | + if (!empty($context['more_admins_link'])) { |
|
| 68 | + echo ' |
|
| 69 | 69 | (', $context['more_admins_link'], ')'; |
| 70 | + } |
|
| 70 | 71 | |
| 71 | 72 | echo ' |
| 72 | 73 | </div> |
@@ -83,16 +84,18 @@ discard block |
||
| 83 | 84 | foreach ($area['areas'] as $item_id => $item) |
| 84 | 85 | { |
| 85 | 86 | // No point showing the 'home' page here, we're already on it! |
| 86 | - if ($area_id == 'forum' && $item_id == 'index') |
|
| 87 | - continue; |
|
| 87 | + if ($area_id == 'forum' && $item_id == 'index') { |
|
| 88 | + continue; |
|
| 89 | + } |
|
| 88 | 90 | |
| 89 | 91 | $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'] : ''); |
| 90 | - if (!empty($item['icon_file'])) |
|
| 91 | - echo ' |
|
| 92 | + if (!empty($item['icon_file'])) { |
|
| 93 | + echo ' |
|
| 92 | 94 | <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>'; |
| 93 | - else |
|
| 94 | - echo ' |
|
| 95 | + } else { |
|
| 96 | + echo ' |
|
| 95 | 97 | <a href="', $url, '"><span class="large_', $item['icon_class'], !empty($item['inactive']) ? ' inactive' : '', '"></span>', $item['label'], '</a>'; |
| 98 | + } |
|
| 96 | 99 | } |
| 97 | 100 | |
| 98 | 101 | echo ' |
@@ -103,10 +106,11 @@ discard block |
||
| 103 | 106 | </div>'; |
| 104 | 107 | |
| 105 | 108 | // The below functions include all the scripts needed from the simplemachines.org site. The language and format are passed for internationalization. |
| 106 | - if (empty($modSettings['disable_smf_js'])) |
|
| 107 | - echo ' |
|
| 109 | + if (empty($modSettings['disable_smf_js'])) { |
|
| 110 | + echo ' |
|
| 108 | 111 | <script src="', $scripturl, '?action=viewsmfile;filename=current-version.js"></script> |
| 109 | 112 | <script src="', $scripturl, '?action=viewsmfile;filename=latest-news.js"></script>'; |
| 113 | + } |
|
| 110 | 114 | |
| 111 | 115 | // This sets the announcements and current versions themselves ;). |
| 112 | 116 | echo ' |
@@ -185,9 +189,10 @@ discard block |
||
| 185 | 189 | <em>', $version['version'], '</em>'; |
| 186 | 190 | |
| 187 | 191 | // more details for this item, show them a link |
| 188 | - if ($context['can_admin'] && isset($version['more'])) |
|
| 189 | - echo |
|
| 192 | + if ($context['can_admin'] && isset($version['more'])) { |
|
| 193 | + echo |
|
| 190 | 194 | ' <a href="', $scripturl, $version['more'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['version_check_more'], '</a>'; |
| 195 | + } |
|
| 191 | 196 | echo ' |
| 192 | 197 | <br>'; |
| 193 | 198 | } |
@@ -218,20 +223,22 @@ discard block |
||
| 218 | 223 | |
| 219 | 224 | foreach ($context['credits'] as $section) |
| 220 | 225 | { |
| 221 | - if (isset($section['pretext'])) |
|
| 222 | - echo ' |
|
| 226 | + if (isset($section['pretext'])) { |
|
| 227 | + echo ' |
|
| 223 | 228 | <p>', $section['pretext'], '</p><hr>'; |
| 229 | + } |
|
| 224 | 230 | |
| 225 | 231 | echo ' |
| 226 | 232 | <dl>'; |
| 227 | 233 | |
| 228 | 234 | foreach ($section['groups'] as $group) |
| 229 | 235 | { |
| 230 | - if (isset($group['title'])) |
|
| 231 | - echo ' |
|
| 236 | + if (isset($group['title'])) { |
|
| 237 | + echo ' |
|
| 232 | 238 | <dt> |
| 233 | 239 | <strong>', $group['title'], ':</strong> |
| 234 | 240 | </dt>'; |
| 241 | + } |
|
| 235 | 242 | |
| 236 | 243 | echo ' |
| 237 | 244 | <dd>', implode(', ', $group['members']), '</dd>'; |
@@ -240,10 +247,11 @@ discard block |
||
| 240 | 247 | echo ' |
| 241 | 248 | </dl>'; |
| 242 | 249 | |
| 243 | - if (isset($section['posttext'])) |
|
| 244 | - echo ' |
|
| 250 | + if (isset($section['posttext'])) { |
|
| 251 | + echo ' |
|
| 245 | 252 | <hr> |
| 246 | 253 | <p>', $section['posttext'], '</p>'; |
| 254 | + } |
|
| 247 | 255 | } |
| 248 | 256 | |
| 249 | 257 | echo ' |
@@ -259,9 +267,10 @@ discard block |
||
| 259 | 267 | smfSupportVersions.forum = "', $context['forum_version'], '";'; |
| 260 | 268 | |
| 261 | 269 | // Don't worry, none of this is logged, it's just used to give information that might be of use. |
| 262 | - foreach ($context['current_versions'] as $variable => $version) |
|
| 263 | - echo ' |
|
| 270 | + foreach ($context['current_versions'] as $variable => $version) { |
|
| 271 | + echo ' |
|
| 264 | 272 | smfSupportVersions.', $variable, ' = "', $version['version'], '";'; |
| 273 | + } |
|
| 265 | 274 | |
| 266 | 275 | // Now we just have to include the script and wait ;). |
| 267 | 276 | echo ' |
@@ -358,8 +367,8 @@ discard block |
||
| 358 | 367 | <tbody>'; |
| 359 | 368 | |
| 360 | 369 | // Loop through every source file displaying its version - using javascript. |
| 361 | - foreach ($context['file_versions'] as $filename => $version) |
|
| 362 | - echo ' |
|
| 370 | + foreach ($context['file_versions'] as $filename => $version) { |
|
| 371 | + echo ' |
|
| 363 | 372 | <tr class="windowbg"> |
| 364 | 373 | <td class="half_table"> |
| 365 | 374 | ', $filename, ' |
@@ -371,6 +380,7 @@ discard block |
||
| 371 | 380 | <em id="currentSources', $filename, '">??</em> |
| 372 | 381 | </td> |
| 373 | 382 | </tr>'; |
| 383 | + } |
|
| 374 | 384 | |
| 375 | 385 | // Default template files. |
| 376 | 386 | echo ' |
@@ -396,8 +406,8 @@ discard block |
||
| 396 | 406 | <table id="Default" class="table_grid"> |
| 397 | 407 | <tbody>'; |
| 398 | 408 | |
| 399 | - foreach ($context['default_template_versions'] as $filename => $version) |
|
| 400 | - echo ' |
|
| 409 | + foreach ($context['default_template_versions'] as $filename => $version) { |
|
| 410 | + echo ' |
|
| 401 | 411 | <tr class="windowbg"> |
| 402 | 412 | <td class="half_table"> |
| 403 | 413 | ', $filename, ' |
@@ -409,6 +419,7 @@ discard block |
||
| 409 | 419 | <em id="currentDefault', $filename, '">??</em> |
| 410 | 420 | </td> |
| 411 | 421 | </tr>'; |
| 422 | + } |
|
| 412 | 423 | |
| 413 | 424 | // Now the language files... |
| 414 | 425 | echo ' |
@@ -436,8 +447,8 @@ discard block |
||
| 436 | 447 | |
| 437 | 448 | foreach ($context['default_language_versions'] as $language => $files) |
| 438 | 449 | { |
| 439 | - foreach ($files as $filename => $version) |
|
| 440 | - echo ' |
|
| 450 | + foreach ($files as $filename => $version) { |
|
| 451 | + echo ' |
|
| 441 | 452 | <tr class="windowbg"> |
| 442 | 453 | <td class="half_table"> |
| 443 | 454 | ', $filename, '.<em>', $language, '</em>.php |
@@ -449,6 +460,7 @@ discard block |
||
| 449 | 460 | <em id="current', $filename, '.', $language, '">??</em> |
| 450 | 461 | </td> |
| 451 | 462 | </tr>'; |
| 463 | + } |
|
| 452 | 464 | } |
| 453 | 465 | |
| 454 | 466 | echo ' |
@@ -478,8 +490,8 @@ discard block |
||
| 478 | 490 | <table id="Templates" class="table_grid"> |
| 479 | 491 | <tbody>'; |
| 480 | 492 | |
| 481 | - foreach ($context['template_versions'] as $filename => $version) |
|
| 482 | - echo ' |
|
| 493 | + foreach ($context['template_versions'] as $filename => $version) { |
|
| 494 | + echo ' |
|
| 483 | 495 | <tr class="windowbg"> |
| 484 | 496 | <td class="half_table"> |
| 485 | 497 | ', $filename, ' |
@@ -491,6 +503,7 @@ discard block |
||
| 491 | 503 | <em id="currentTemplates', $filename, '">??</em> |
| 492 | 504 | </td> |
| 493 | 505 | </tr>'; |
| 506 | + } |
|
| 494 | 507 | |
| 495 | 508 | echo ' |
| 496 | 509 | </tbody> |
@@ -520,8 +533,8 @@ discard block |
||
| 520 | 533 | <table id="Tasks" class="table_grid"> |
| 521 | 534 | <tbody>'; |
| 522 | 535 | |
| 523 | - foreach ($context['tasks_versions'] as $filename => $version) |
|
| 524 | - echo ' |
|
| 536 | + foreach ($context['tasks_versions'] as $filename => $version) { |
|
| 537 | + echo ' |
|
| 525 | 538 | <tr class="windowbg"> |
| 526 | 539 | <td class="half_table"> |
| 527 | 540 | ', $filename, ' |
@@ -533,6 +546,7 @@ discard block |
||
| 533 | 546 | <em id="currentTasks', $filename, '">??</em> |
| 534 | 547 | </td> |
| 535 | 548 | </tr>'; |
| 549 | + } |
|
| 536 | 550 | |
| 537 | 551 | echo ' |
| 538 | 552 | </tbody> |
@@ -574,9 +588,10 @@ discard block |
||
| 574 | 588 | { |
| 575 | 589 | global $context, $scripturl, $txt, $modSettings; |
| 576 | 590 | |
| 577 | - if (!empty($context['saved_successful'])) |
|
| 578 | - echo ' |
|
| 591 | + if (!empty($context['saved_successful'])) { |
|
| 592 | + echo ' |
|
| 579 | 593 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
| 594 | + } |
|
| 580 | 595 | |
| 581 | 596 | // First section is for adding/removing words from the censored list. |
| 582 | 597 | echo ' |
@@ -591,11 +606,12 @@ discard block |
||
| 591 | 606 | <p>', $txt['admin_censored_where'], '</p>'; |
| 592 | 607 | |
| 593 | 608 | // Show text boxes for censoring [bad ] => [good ]. |
| 594 | - foreach ($context['censored_words'] as $vulgar => $proper) |
|
| 595 | - echo ' |
|
| 609 | + foreach ($context['censored_words'] as $vulgar => $proper) { |
|
| 610 | + echo ' |
|
| 596 | 611 | <div class="block"> |
| 597 | 612 | <input type="text" name="censor_vulgar[]" value="', $vulgar, '" size="30"> => <input type="text" name="censor_proper[]" value="', $proper, '" size="30"> |
| 598 | 613 | </div>'; |
| 614 | + } |
|
| 599 | 615 | |
| 600 | 616 | // Now provide a way to censor more words. |
| 601 | 617 | echo ' |
@@ -669,19 +685,21 @@ discard block |
||
| 669 | 685 | <div class="windowbg2 noup"> |
| 670 | 686 | ', $txt['not_done_reason']; |
| 671 | 687 | |
| 672 | - if (!empty($context['continue_percent'])) |
|
| 673 | - echo ' |
|
| 688 | + if (!empty($context['continue_percent'])) { |
|
| 689 | + echo ' |
|
| 674 | 690 | <div class="progress_bar"> |
| 675 | 691 | <div class="full_bar">', $context['continue_percent'], '%</div> |
| 676 | 692 | <div class="green_percent" style="width: ', $context['continue_percent'], '%;"> </div> |
| 677 | 693 | </div>'; |
| 694 | + } |
|
| 678 | 695 | |
| 679 | - if (!empty($context['substep_enabled'])) |
|
| 680 | - echo ' |
|
| 696 | + if (!empty($context['substep_enabled'])) { |
|
| 697 | + echo ' |
|
| 681 | 698 | <div class="progress_bar"> |
| 682 | 699 | <div class="full_bar">', $context['substep_title'], ' (', $context['substep_continue_percent'], '%)</div> |
| 683 | 700 | <div class="blue_percent" style="width: ', $context['substep_continue_percent'], '%;"> </div> |
| 684 | 701 | </div>'; |
| 702 | + } |
|
| 685 | 703 | |
| 686 | 704 | echo ' |
| 687 | 705 | <form action="', $scripturl, $context['continue_get_data'], '" method="post" accept-charset="', $context['character_set'], '" name="autoSubmit" id="autoSubmit"> |
@@ -716,35 +734,40 @@ discard block |
||
| 716 | 734 | { |
| 717 | 735 | global $context, $txt, $scripturl; |
| 718 | 736 | |
| 719 | - if (!empty($context['saved_successful'])) |
|
| 720 | - echo ' |
|
| 737 | + if (!empty($context['saved_successful'])) { |
|
| 738 | + echo ' |
|
| 721 | 739 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
| 722 | - elseif (!empty($context['saved_failed'])) |
|
| 723 | - echo ' |
|
| 740 | + } elseif (!empty($context['saved_failed'])) { |
|
| 741 | + echo ' |
|
| 724 | 742 | <div class="errorbox">', sprintf($txt['settings_not_saved'], $context['saved_failed']), '</div>'; |
| 743 | + } |
|
| 725 | 744 | |
| 726 | - if (!empty($context['settings_pre_javascript'])) |
|
| 727 | - echo ' |
|
| 745 | + if (!empty($context['settings_pre_javascript'])) { |
|
| 746 | + echo ' |
|
| 728 | 747 | <script>', $context['settings_pre_javascript'], '</script>'; |
| 748 | + } |
|
| 729 | 749 | |
| 730 | - if (!empty($context['settings_insert_above'])) |
|
| 731 | - echo $context['settings_insert_above']; |
|
| 750 | + if (!empty($context['settings_insert_above'])) { |
|
| 751 | + echo $context['settings_insert_above']; |
|
| 752 | + } |
|
| 732 | 753 | |
| 733 | 754 | echo ' |
| 734 | 755 | <div id="admincenter"> |
| 735 | 756 | <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'] . '"' : '', '>'; |
| 736 | 757 | |
| 737 | 758 | // Is there a custom title? |
| 738 | - if (isset($context['settings_title'])) |
|
| 739 | - echo ' |
|
| 759 | + if (isset($context['settings_title'])) { |
|
| 760 | + echo ' |
|
| 740 | 761 | <div class="cat_bar"> |
| 741 | 762 | <h3 class="catbg">', $context['settings_title'], '</h3> |
| 742 | 763 | </div>'; |
| 764 | + } |
|
| 743 | 765 | |
| 744 | 766 | // Have we got a message to display? |
| 745 | - if (!empty($context['settings_message'])) |
|
| 746 | - echo ' |
|
| 767 | + if (!empty($context['settings_message'])) { |
|
| 768 | + echo ' |
|
| 747 | 769 | <div class="information">', $context['settings_message'], '</div>'; |
| 770 | + } |
|
| 748 | 771 | |
| 749 | 772 | // Now actually loop through all the variables. |
| 750 | 773 | $is_open = false; |
@@ -797,8 +820,9 @@ discard block |
||
| 797 | 820 | // Hang about? Are you pulling my leg - a callback?! |
| 798 | 821 | if (is_array($config_var) && $config_var['type'] == 'callback') |
| 799 | 822 | { |
| 800 | - if (function_exists('template_callback_' . $config_var['name'])) |
|
| 801 | - call_user_func('template_callback_' . $config_var['name']); |
|
| 823 | + if (function_exists('template_callback_' . $config_var['name'])) { |
|
| 824 | + call_user_func('template_callback_' . $config_var['name']); |
|
| 825 | + } |
|
| 802 | 826 | |
| 803 | 827 | continue; |
| 804 | 828 | } |
@@ -828,9 +852,10 @@ discard block |
||
| 828 | 852 | $text_types = array('color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'); |
| 829 | 853 | |
| 830 | 854 | // Show the [?] button. |
| 831 | - if ($config_var['help']) |
|
| 832 | - echo ' |
|
| 855 | + if ($config_var['help']) { |
|
| 856 | + echo ' |
|
| 833 | 857 | <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> '; |
| 858 | + } |
|
| 834 | 859 | |
| 835 | 860 | echo ' |
| 836 | 861 | <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> |
@@ -839,22 +864,25 @@ discard block |
||
| 839 | 864 | $config_var['preinput']; |
| 840 | 865 | |
| 841 | 866 | // Show a check box. |
| 842 | - if ($config_var['type'] == 'check') |
|
| 843 | - echo ' |
|
| 867 | + if ($config_var['type'] == 'check') { |
|
| 868 | + echo ' |
|
| 844 | 869 | <input type="checkbox"', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '"', ($config_var['value'] ? ' checked' : ''), ' value="1" class="input_check">'; |
| 870 | + } |
|
| 845 | 871 | // Escape (via htmlspecialchars.) the text box. |
| 846 | - elseif ($config_var['type'] == 'password') |
|
| 847 | - echo ' |
|
| 872 | + elseif ($config_var['type'] == 'password') { |
|
| 873 | + echo ' |
|
| 848 | 874 | <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;" class="input_password"><br> |
| 849 | 875 | <input type="password" disabled id="', $config_var['name'], '" name="', $config_var['name'], '[1]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), ' class="input_password">'; |
| 876 | + } |
|
| 850 | 877 | // Show a selection box. |
| 851 | 878 | elseif ($config_var['type'] == 'select') |
| 852 | 879 | { |
| 853 | 880 | echo ' |
| 854 | 881 | <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'] . '"' : ''), '>'; |
| 855 | - foreach ($config_var['data'] as $option) |
|
| 856 | - echo ' |
|
| 882 | + foreach ($config_var['data'] as $option) { |
|
| 883 | + echo ' |
|
| 857 | 884 | <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>'; |
| 885 | + } |
|
| 858 | 886 | echo ' |
| 859 | 887 | </select>'; |
| 860 | 888 | } |
@@ -868,15 +896,17 @@ discard block |
||
| 868 | 896 | <legend class="board_selector"><a href="#">', $txt['select_boards_from_list'], '</a></legend>'; |
| 869 | 897 | foreach ($context['board_list'] as $id_cat => $cat) |
| 870 | 898 | { |
| 871 | - if (!$first) |
|
| 872 | - echo ' |
|
| 899 | + if (!$first) { |
|
| 900 | + echo ' |
|
| 873 | 901 | <hr>'; |
| 902 | + } |
|
| 874 | 903 | echo ' |
| 875 | 904 | <strong>', $cat['name'], '</strong> |
| 876 | 905 | <ul>'; |
| 877 | - foreach ($cat['boards'] as $id_board => $brd) |
|
| 878 | - echo ' |
|
| 906 | + foreach ($cat['boards'] as $id_board => $brd) { |
|
| 907 | + echo ' |
|
| 879 | 908 | <li><label><input type="checkbox" name="', $config_var['name'], '[', $brd['id'], ']" value="1" class="input_check"', in_array($brd['id'], $config_var['value']) ? ' checked' : '', '> ', $brd['child_level'] > 0 ? str_repeat(' ', $brd['child_level']) : '', $brd['name'], '</label></li>'; |
| 909 | + } |
|
| 880 | 910 | |
| 881 | 911 | echo ' |
| 882 | 912 | </ul>'; |
@@ -886,12 +916,14 @@ discard block |
||
| 886 | 916 | </fieldset>'; |
| 887 | 917 | } |
| 888 | 918 | // Text area? |
| 889 | - elseif ($config_var['type'] == 'large_text') |
|
| 890 | - echo ' |
|
| 919 | + elseif ($config_var['type'] == 'large_text') { |
|
| 920 | + echo ' |
|
| 891 | 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 | + } |
|
| 892 | 923 | // Permission group? |
| 893 | - elseif ($config_var['type'] == 'permissions') |
|
| 894 | - theme_inline_permissions($config_var['name']); |
|
| 924 | + elseif ($config_var['type'] == 'permissions') { |
|
| 925 | + theme_inline_permissions($config_var['name']); |
|
| 926 | + } |
|
| 895 | 927 | // BBC selection? |
| 896 | 928 | elseif ($config_var['type'] == 'bbc') |
| 897 | 929 | { |
@@ -902,20 +934,22 @@ discard block |
||
| 902 | 934 | |
| 903 | 935 | foreach ($context['bbc_columns'] as $bbcColumn) |
| 904 | 936 | { |
| 905 | - foreach ($bbcColumn as $bbcTag) |
|
| 906 | - echo ' |
|
| 937 | + foreach ($bbcColumn as $bbcTag) { |
|
| 938 | + echo ' |
|
| 907 | 939 | <li class="list_bbc floatleft"> |
| 908 | 940 | <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' : '', ' class="input_check"> <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 | 941 | </li>'; |
| 942 | + } |
|
| 910 | 943 | } |
| 911 | 944 | echo ' </ul> |
| 912 | 945 | <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' : '', ' class="input_check"> <label for="bbc_', $config_var['name'], '_select_all"><em>', $txt['bbcTagsToUse_select_all'], '</em></label> |
| 913 | 946 | </fieldset>'; |
| 914 | 947 | } |
| 915 | 948 | // A simple message? |
| 916 | - elseif ($config_var['type'] == 'var_message') |
|
| 917 | - echo ' |
|
| 949 | + elseif ($config_var['type'] == 'var_message') { |
|
| 950 | + echo ' |
|
| 918 | 951 | <div', !empty($config_var['name']) ? ' id="' . $config_var['name'] . '"' : '', '>', $config_var['var_message'], '</div>'; |
| 952 | + } |
|
| 919 | 953 | // Assume it must be a text box |
| 920 | 954 | else |
| 921 | 955 | { |
@@ -940,63 +974,70 @@ discard block |
||
| 940 | 974 | ' . $config_var['postinput'] : '', |
| 941 | 975 | '</dd>'; |
| 942 | 976 | } |
| 943 | - } |
|
| 944 | - |
|
| 945 | - else |
|
| 977 | + } else |
|
| 946 | 978 | { |
| 947 | 979 | // Just show a separator. |
| 948 | - if ($config_var == '') |
|
| 949 | - echo ' |
|
| 980 | + if ($config_var == '') { |
|
| 981 | + echo ' |
|
| 950 | 982 | </dl> |
| 951 | 983 | <hr> |
| 952 | 984 | <dl class="settings">'; |
| 953 | - else |
|
| 954 | - echo ' |
|
| 985 | + } else { |
|
| 986 | + echo ' |
|
| 955 | 987 | <dd> |
| 956 | 988 | <strong>' . $config_var . '</strong> |
| 957 | 989 | </dd>'; |
| 990 | + } |
|
| 958 | 991 | } |
| 959 | 992 | } |
| 960 | 993 | |
| 961 | - if ($is_open) |
|
| 962 | - echo ' |
|
| 994 | + if ($is_open) { |
|
| 995 | + echo ' |
|
| 963 | 996 | </dl>'; |
| 997 | + } |
|
| 964 | 998 | |
| 965 | - if (empty($context['settings_save_dont_show'])) |
|
| 966 | - echo ' |
|
| 999 | + if (empty($context['settings_save_dont_show'])) { |
|
| 1000 | + echo ' |
|
| 967 | 1001 | <input type="submit" value="', $txt['save'], '"', (!empty($context['save_disabled']) ? ' disabled' : ''), (!empty($context['settings_save_onclick']) ? ' onclick="' . $context['settings_save_onclick'] . '"' : ''), ' class="button_submit">'; |
| 1002 | + } |
|
| 968 | 1003 | |
| 969 | - if ($is_open) |
|
| 970 | - echo ' |
|
| 1004 | + if ($is_open) { |
|
| 1005 | + echo ' |
|
| 971 | 1006 | </div>'; |
| 1007 | + } |
|
| 972 | 1008 | |
| 973 | 1009 | |
| 974 | 1010 | // At least one token has to be used! |
| 975 | - if (isset($context['admin-ssc_token'])) |
|
| 976 | - echo ' |
|
| 1011 | + if (isset($context['admin-ssc_token'])) { |
|
| 1012 | + echo ' |
|
| 977 | 1013 | <input type="hidden" name="', $context['admin-ssc_token_var'], '" value="', $context['admin-ssc_token'], '">'; |
| 1014 | + } |
|
| 978 | 1015 | |
| 979 | - if (isset($context['admin-dbsc_token'])) |
|
| 980 | - echo ' |
|
| 1016 | + if (isset($context['admin-dbsc_token'])) { |
|
| 1017 | + echo ' |
|
| 981 | 1018 | <input type="hidden" name="', $context['admin-dbsc_token_var'], '" value="', $context['admin-dbsc_token'], '">'; |
| 1019 | + } |
|
| 982 | 1020 | |
| 983 | - if (isset($context['admin-mp_token'])) |
|
| 984 | - echo ' |
|
| 1021 | + if (isset($context['admin-mp_token'])) { |
|
| 1022 | + echo ' |
|
| 985 | 1023 | <input type="hidden" name="', $context['admin-mp_token_var'], '" value="', $context['admin-mp_token'], '">'; |
| 1024 | + } |
|
| 986 | 1025 | |
| 987 | 1026 | echo ' |
| 988 | 1027 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 989 | 1028 | </form> |
| 990 | 1029 | </div>'; |
| 991 | 1030 | |
| 992 | - if (!empty($context['settings_post_javascript'])) |
|
| 993 | - echo ' |
|
| 1031 | + if (!empty($context['settings_post_javascript'])) { |
|
| 1032 | + echo ' |
|
| 994 | 1033 | <script> |
| 995 | 1034 | ', $context['settings_post_javascript'], ' |
| 996 | 1035 | </script>'; |
| 1036 | + } |
|
| 997 | 1037 | |
| 998 | - if (!empty($context['settings_insert_below'])) |
|
| 999 | - echo $context['settings_insert_below']; |
|
| 1038 | + if (!empty($context['settings_insert_below'])) { |
|
| 1039 | + echo $context['settings_insert_below']; |
|
| 1040 | + } |
|
| 1000 | 1041 | |
| 1001 | 1042 | // We may have added a board listing. If we did, we need to make it work. |
| 1002 | 1043 | addInlineJavascript(' |
@@ -1019,9 +1060,10 @@ discard block |
||
| 1019 | 1060 | { |
| 1020 | 1061 | global $context, $txt; |
| 1021 | 1062 | |
| 1022 | - if (!empty($context['saved_successful'])) |
|
| 1023 | - echo ' |
|
| 1063 | + if (!empty($context['saved_successful'])) { |
|
| 1064 | + echo ' |
|
| 1024 | 1065 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
| 1066 | + } |
|
| 1025 | 1067 | |
| 1026 | 1068 | // Standard fields. |
| 1027 | 1069 | template_show_list('standard_profile_fields'); |
@@ -1053,11 +1095,12 @@ discard block |
||
| 1053 | 1095 | if (isset($_GET['msg'])) |
| 1054 | 1096 | { |
| 1055 | 1097 | loadLanguage('Errors'); |
| 1056 | - if (isset($txt['custom_option_' . $_GET['msg']])) |
|
| 1057 | - echo ' |
|
| 1098 | + if (isset($txt['custom_option_' . $_GET['msg']])) { |
|
| 1099 | + echo ' |
|
| 1058 | 1100 | <div class="errorbox">', |
| 1059 | 1101 | $txt['custom_option_' . $_GET['msg']], ' |
| 1060 | 1102 | </div>'; |
| 1103 | + } |
|
| 1061 | 1104 | } |
| 1062 | 1105 | |
| 1063 | 1106 | echo ' |
@@ -1123,9 +1166,10 @@ discard block |
||
| 1123 | 1166 | <dd> |
| 1124 | 1167 | <select name="placement" id="placement">'; |
| 1125 | 1168 | |
| 1126 | - foreach ($context['cust_profile_fields_placement'] as $order => $name) |
|
| 1127 | - echo ' |
|
| 1169 | + foreach ($context['cust_profile_fields_placement'] as $order => $name) { |
|
| 1170 | + echo ' |
|
| 1128 | 1171 | <option value="', $order, '"', $context['field']['placement'] == $order ? ' selected' : '', '>', $txt['custom_profile_placement_' . $name], '</option>'; |
| 1172 | + } |
|
| 1129 | 1173 | |
| 1130 | 1174 | echo ' |
| 1131 | 1175 | </select> |
@@ -1148,9 +1192,10 @@ discard block |
||
| 1148 | 1192 | </dt> |
| 1149 | 1193 | <dd> |
| 1150 | 1194 | <select name="field_type" id="field_type" onchange="updateInputBoxes();">'; |
| 1151 | - foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type) |
|
| 1152 | - echo ' |
|
| 1195 | + foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type) { |
|
| 1196 | + echo ' |
|
| 1153 | 1197 | <option value="', $field_type, '"', $context['field']['type'] == $field_type ? ' selected' : '', '>', $txt['custom_profile_type_' . $field_type], '</option>'; |
| 1198 | + } |
|
| 1154 | 1199 | |
| 1155 | 1200 | echo ' |
| 1156 | 1201 | </select> |
@@ -1251,9 +1296,10 @@ discard block |
||
| 1251 | 1296 | </fieldset> |
| 1252 | 1297 | <input type="submit" name="save" value="', $txt['save'], '" class="button_submit">'; |
| 1253 | 1298 | |
| 1254 | - if ($context['fid']) |
|
| 1255 | - echo ' |
|
| 1299 | + if ($context['fid']) { |
|
| 1300 | + echo ' |
|
| 1256 | 1301 | <input type="submit" name="delete" value="', $txt['delete'], '" data-confirm="', $txt['custom_edit_delete_sure'], '" class="button_submit you_sure">'; |
| 1302 | + } |
|
| 1257 | 1303 | |
| 1258 | 1304 | echo ' |
| 1259 | 1305 | </div> |
@@ -1296,8 +1342,7 @@ discard block |
||
| 1296 | 1342 | { |
| 1297 | 1343 | echo ' |
| 1298 | 1344 | <p class="centertext"><strong>', $txt['admin_search_results_none'], '</strong></p>'; |
| 1299 | - } |
|
| 1300 | - else |
|
| 1345 | + } else |
|
| 1301 | 1346 | { |
| 1302 | 1347 | echo ' |
| 1303 | 1348 | <ol class="search_results">'; |
@@ -1323,9 +1368,10 @@ discard block |
||
| 1323 | 1368 | <li> |
| 1324 | 1369 | <a href="', $result['url'], '"><strong>', $result['name'], '</strong></a> [', isset($txt['admin_search_section_' . $result['type']]) ? $txt['admin_search_section_' . $result['type']] : $result['type'], ']'; |
| 1325 | 1370 | |
| 1326 | - if ($result['help']) |
|
| 1327 | - echo ' |
|
| 1371 | + if ($result['help']) { |
|
| 1372 | + echo ' |
|
| 1328 | 1373 | <p class="double_height">', $result['help'], '</p>'; |
| 1374 | + } |
|
| 1329 | 1375 | |
| 1330 | 1376 | echo ' |
| 1331 | 1377 | </li>'; |
@@ -1365,18 +1411,20 @@ discard block |
||
| 1365 | 1411 | <strong>', $txt['setup_verification_answer'], '</strong> |
| 1366 | 1412 | </dd>'; |
| 1367 | 1413 | |
| 1368 | - if (!empty($context['qa_by_lang'][$lang_id])) |
|
| 1369 | - foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
| 1414 | + if (!empty($context['qa_by_lang'][$lang_id])) { |
|
| 1415 | + foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
| 1370 | 1416 | { |
| 1371 | 1417 | $question = $context['question_answers'][$q_id]; |
| 1418 | + } |
|
| 1372 | 1419 | echo ' |
| 1373 | 1420 | <dt> |
| 1374 | 1421 | <input type="text" name="question[', $lang_id, '][', $q_id, ']" value="', $question['question'], '" size="50" class="input_text verification_question"> |
| 1375 | 1422 | </dt> |
| 1376 | 1423 | <dd>'; |
| 1377 | - foreach ($question['answers'] as $answer) |
|
| 1378 | - echo ' |
|
| 1424 | + foreach ($question['answers'] as $answer) { |
|
| 1425 | + echo ' |
|
| 1379 | 1426 | <input type="text" name="answer[', $lang_id, '][', $q_id, '][]" value="', $answer, '" size="50" class="input_text verification_answer">'; |
| 1427 | + } |
|
| 1380 | 1428 | |
| 1381 | 1429 | echo ' |
| 1382 | 1430 | <div class="qa_add_answer"><a href="javascript:void(0);" onclick="return addAnswer(this);">[ ', $txt['setup_verification_add_answer'], ' ]</a></div> |
@@ -1415,11 +1463,12 @@ discard block |
||
| 1415 | 1463 | ', $txt['errors_found'], ': |
| 1416 | 1464 | <ul>'; |
| 1417 | 1465 | |
| 1418 | - foreach ($context['repair_errors'] as $error) |
|
| 1419 | - echo ' |
|
| 1466 | + foreach ($context['repair_errors'] as $error) { |
|
| 1467 | + echo ' |
|
| 1420 | 1468 | <li> |
| 1421 | 1469 | ', $error, ' |
| 1422 | 1470 | </li>'; |
| 1471 | + } |
|
| 1423 | 1472 | |
| 1424 | 1473 | echo ' |
| 1425 | 1474 | </ul> |
@@ -1429,16 +1478,15 @@ discard block |
||
| 1429 | 1478 | <p class="padding"> |
| 1430 | 1479 | <strong><a href="', $scripturl, '?action=admin;area=repairboards;fixErrors;', $context['session_var'], '=', $context['session_id'], '">', $txt['yes'], '</a> - <a href="', $scripturl, '?action=admin;area=maintain">', $txt['no'], '</a></strong> |
| 1431 | 1480 | </p>'; |
| 1432 | - } |
|
| 1433 | - else |
|
| 1434 | - echo ' |
|
| 1481 | + } else { |
|
| 1482 | + echo ' |
|
| 1435 | 1483 | <p>', $txt['maintain_no_errors'], '</p> |
| 1436 | 1484 | <p class="padding"> |
| 1437 | 1485 | <a href="', $scripturl, '?action=admin;area=maintain;sa=routine">', $txt['maintain_return'], '</a> |
| 1438 | 1486 | </p>'; |
| 1487 | + } |
|
| 1439 | 1488 | |
| 1440 | - } |
|
| 1441 | - else |
|
| 1489 | + } else |
|
| 1442 | 1490 | { |
| 1443 | 1491 | if (!empty($context['redirect_to_recount'])) |
| 1444 | 1492 | { |
@@ -1450,8 +1498,7 @@ discard block |
||
| 1450 | 1498 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 1451 | 1499 | <input type="submit" name="recount" id="recount_now" value="', $txt['errors_recount_now'], '"> |
| 1452 | 1500 | </form>'; |
| 1453 | - } |
|
| 1454 | - else |
|
| 1501 | + } else |
|
| 1455 | 1502 | { |
| 1456 | 1503 | echo ' |
| 1457 | 1504 | <p>', $txt['errors_fixed'], '</p> |
@@ -1603,8 +1650,8 @@ discard block |
||
| 1603 | 1650 | function template_admin_quick_search() |
| 1604 | 1651 | { |
| 1605 | 1652 | global $context, $txt; |
| 1606 | - if ($context['user']['is_admin']) |
|
| 1607 | - echo ' |
|
| 1653 | + if ($context['user']['is_admin']) { |
|
| 1654 | + echo ' |
|
| 1608 | 1655 | <span class="floatright admin_search"> |
| 1609 | 1656 | <span class="generic_icons filter centericon"></span> |
| 1610 | 1657 | <input type="search" name="search_term" value="', $txt['admin_search'], '" onclick="if (this.value == \'', $txt['admin_search'], '\') this.value = \'\';" class="input_text"> |
@@ -1615,6 +1662,7 @@ discard block |
||
| 1615 | 1662 | </select> |
| 1616 | 1663 | <input type="submit" name="search_go" id="search_go" value="', $txt['admin_search_go'], '" class="button_submit"> |
| 1617 | 1664 | </span>'; |
| 1618 | -} |
|
| 1665 | + } |
|
| 1666 | + } |
|
| 1619 | 1667 | |
| 1620 | 1668 | ?> |
| 1621 | 1669 | \ No newline at end of file |