@@ -841,13 +841,13 @@ discard block |
||
| 841 | 841 | // We're going to check that their board dir setting is right in case they've been moving stuff around. |
| 842 | 842 | if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) |
| 843 | 843 | $upcontext['warning'] = ' |
| 844 | - '. sprintf($txt['upgrade_boarddir_settings'], $boarddir, dirname(__FILE__)) .'<br> |
|
| 844 | + '. sprintf($txt['upgrade_boarddir_settings'], $boarddir, dirname(__FILE__)) . '<br> |
|
| 845 | 845 | <ul> |
| 846 | - <li>'. $txt['upgrade_boarddir'] .' ' . $boarddir . '</li> |
|
| 847 | - <li>'. $txt['upgrade_sourcedir'] .' ' . $boarddir . '</li> |
|
| 848 | - <li>'. $txt['upgrade_cachedir'] .' ' . $cachedir_temp . '</li> |
|
| 846 | + <li>'. $txt['upgrade_boarddir'] . ' ' . $boarddir . '</li> |
|
| 847 | + <li>'. $txt['upgrade_sourcedir'] . ' ' . $boarddir . '</li> |
|
| 848 | + <li>'. $txt['upgrade_cachedir'] . ' ' . $cachedir_temp . '</li> |
|
| 849 | 849 | </ul> |
| 850 | - '. $txt['upgrade_incorrect_settings'] .''; |
|
| 850 | + '. $txt['upgrade_incorrect_settings'] . ''; |
|
| 851 | 851 | |
| 852 | 852 | // Confirm mbstring is loaded... |
| 853 | 853 | if (!extension_loaded('mbstring')) |
@@ -1781,7 +1781,7 @@ discard block |
||
| 1781 | 1781 | |
| 1782 | 1782 | // Our custom error handler - does nothing but does stop public errors from XML! |
| 1783 | 1783 | set_error_handler( |
| 1784 | - function ($errno, $errstr, $errfile, $errline) use ($support_js) |
|
| 1784 | + function($errno, $errstr, $errfile, $errline) use ($support_js) |
|
| 1785 | 1785 | { |
| 1786 | 1786 | if ($support_js) |
| 1787 | 1787 | return true; |
@@ -2109,13 +2109,13 @@ discard block |
||
| 2109 | 2109 | |
| 2110 | 2110 | // Otherwise we have to display this somewhere appropriate if possible. |
| 2111 | 2111 | $upcontext['forced_error_message'] = ' |
| 2112 | - <strong>'. $txt['upgrade_unsuccessful'] .'</strong><br> |
|
| 2112 | + <strong>'. $txt['upgrade_unsuccessful'] . '</strong><br> |
|
| 2113 | 2113 | |
| 2114 | 2114 | <div style="margin: 2ex;"> |
| 2115 | - '. $txt['upgrade_thisquery'] .' |
|
| 2115 | + '. $txt['upgrade_thisquery'] . ' |
|
| 2116 | 2116 | <blockquote><pre>' . nl2br(htmlspecialchars(trim($string))) . ';</pre></blockquote> |
| 2117 | 2117 | |
| 2118 | - '. $txt['upgrade_causerror'] .' |
|
| 2118 | + '. $txt['upgrade_causerror'] . ' |
|
| 2119 | 2119 | <blockquote>' . nl2br(htmlspecialchars($db_error_message)) . '</blockquote> |
| 2120 | 2120 | </div> |
| 2121 | 2121 | |
@@ -2780,94 +2780,94 @@ discard block |
||
| 2780 | 2780 | // Translation table for the character sets not native for MySQL. |
| 2781 | 2781 | $translation_tables = array( |
| 2782 | 2782 | 'windows-1255' => array( |
| 2783 | - '0x81' => '\'\'', '0x8A' => '\'\'', '0x8C' => '\'\'', |
|
| 2784 | - '0x8D' => '\'\'', '0x8E' => '\'\'', '0x8F' => '\'\'', |
|
| 2785 | - '0x90' => '\'\'', '0x9A' => '\'\'', '0x9C' => '\'\'', |
|
| 2786 | - '0x9D' => '\'\'', '0x9E' => '\'\'', '0x9F' => '\'\'', |
|
| 2787 | - '0xCA' => '\'\'', '0xD9' => '\'\'', '0xDA' => '\'\'', |
|
| 2788 | - '0xDB' => '\'\'', '0xDC' => '\'\'', '0xDD' => '\'\'', |
|
| 2789 | - '0xDE' => '\'\'', '0xDF' => '\'\'', '0xFB' => '0xD792', |
|
| 2790 | - '0xFC' => '0xE282AC', '0xFF' => '0xD6B2', '0xC2' => '0xFF', |
|
| 2791 | - '0x80' => '0xFC', '0xE2' => '0xFB', '0xA0' => '0xC2A0', |
|
| 2792 | - '0xA1' => '0xC2A1', '0xA2' => '0xC2A2', '0xA3' => '0xC2A3', |
|
| 2793 | - '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
| 2794 | - '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
| 2795 | - '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
| 2796 | - '0xAF' => '0xC2AF', '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', |
|
| 2797 | - '0xB2' => '0xC2B2', '0xB3' => '0xC2B3', '0xB4' => '0xC2B4', |
|
| 2798 | - '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
| 2799 | - '0xB8' => '0xC2B8', '0xB9' => '0xC2B9', '0xBB' => '0xC2BB', |
|
| 2800 | - '0xBC' => '0xC2BC', '0xBD' => '0xC2BD', '0xBE' => '0xC2BE', |
|
| 2801 | - '0xBF' => '0xC2BF', '0xD7' => '0xD7B3', '0xD1' => '0xD781', |
|
| 2802 | - '0xD4' => '0xD7B0', '0xD5' => '0xD7B1', '0xD6' => '0xD7B2', |
|
| 2803 | - '0xE0' => '0xD790', '0xEA' => '0xD79A', '0xEC' => '0xD79C', |
|
| 2804 | - '0xED' => '0xD79D', '0xEE' => '0xD79E', '0xEF' => '0xD79F', |
|
| 2805 | - '0xF0' => '0xD7A0', '0xF1' => '0xD7A1', '0xF2' => '0xD7A2', |
|
| 2806 | - '0xF3' => '0xD7A3', '0xF5' => '0xD7A5', '0xF6' => '0xD7A6', |
|
| 2807 | - '0xF7' => '0xD7A7', '0xF8' => '0xD7A8', '0xF9' => '0xD7A9', |
|
| 2808 | - '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
| 2809 | - '0x86' => '0xE280A0', '0x87' => '0xE280A1', '0x89' => '0xE280B0', |
|
| 2810 | - '0x8B' => '0xE280B9', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
| 2811 | - '0x95' => '0xE280A2', '0x97' => '0xE28094', '0x99' => '0xE284A2', |
|
| 2812 | - '0xC0' => '0xD6B0', '0xC1' => '0xD6B1', '0xC3' => '0xD6B3', |
|
| 2813 | - '0xC4' => '0xD6B4', '0xC5' => '0xD6B5', '0xC6' => '0xD6B6', |
|
| 2814 | - '0xC7' => '0xD6B7', '0xC8' => '0xD6B8', '0xC9' => '0xD6B9', |
|
| 2815 | - '0xCB' => '0xD6BB', '0xCC' => '0xD6BC', '0xCD' => '0xD6BD', |
|
| 2816 | - '0xCE' => '0xD6BE', '0xCF' => '0xD6BF', '0xD0' => '0xD780', |
|
| 2817 | - '0xD2' => '0xD782', '0xE3' => '0xD793', '0xE4' => '0xD794', |
|
| 2818 | - '0xE5' => '0xD795', '0xE7' => '0xD797', '0xE9' => '0xD799', |
|
| 2819 | - '0xFD' => '0xE2808E', '0xFE' => '0xE2808F', '0x92' => '0xE28099', |
|
| 2820 | - '0x83' => '0xC692', '0xD3' => '0xD783', '0x88' => '0xCB86', |
|
| 2821 | - '0x98' => '0xCB9C', '0x91' => '0xE28098', '0x96' => '0xE28093', |
|
| 2822 | - '0xBA' => '0xC3B7', '0x9B' => '0xE280BA', '0xAA' => '0xC397', |
|
| 2823 | - '0xA4' => '0xE282AA', '0xE1' => '0xD791', '0xE6' => '0xD796', |
|
| 2824 | - '0xE8' => '0xD798', '0xEB' => '0xD79B', '0xF4' => '0xD7A4', |
|
| 2783 | + '0x81' => '\'\'', '0x8A' => '\'\'', '0x8C' => '\'\'', |
|
| 2784 | + '0x8D' => '\'\'', '0x8E' => '\'\'', '0x8F' => '\'\'', |
|
| 2785 | + '0x90' => '\'\'', '0x9A' => '\'\'', '0x9C' => '\'\'', |
|
| 2786 | + '0x9D' => '\'\'', '0x9E' => '\'\'', '0x9F' => '\'\'', |
|
| 2787 | + '0xCA' => '\'\'', '0xD9' => '\'\'', '0xDA' => '\'\'', |
|
| 2788 | + '0xDB' => '\'\'', '0xDC' => '\'\'', '0xDD' => '\'\'', |
|
| 2789 | + '0xDE' => '\'\'', '0xDF' => '\'\'', '0xFB' => '0xD792', |
|
| 2790 | + '0xFC' => '0xE282AC', '0xFF' => '0xD6B2', '0xC2' => '0xFF', |
|
| 2791 | + '0x80' => '0xFC', '0xE2' => '0xFB', '0xA0' => '0xC2A0', |
|
| 2792 | + '0xA1' => '0xC2A1', '0xA2' => '0xC2A2', '0xA3' => '0xC2A3', |
|
| 2793 | + '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
| 2794 | + '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
| 2795 | + '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
| 2796 | + '0xAF' => '0xC2AF', '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', |
|
| 2797 | + '0xB2' => '0xC2B2', '0xB3' => '0xC2B3', '0xB4' => '0xC2B4', |
|
| 2798 | + '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
| 2799 | + '0xB8' => '0xC2B8', '0xB9' => '0xC2B9', '0xBB' => '0xC2BB', |
|
| 2800 | + '0xBC' => '0xC2BC', '0xBD' => '0xC2BD', '0xBE' => '0xC2BE', |
|
| 2801 | + '0xBF' => '0xC2BF', '0xD7' => '0xD7B3', '0xD1' => '0xD781', |
|
| 2802 | + '0xD4' => '0xD7B0', '0xD5' => '0xD7B1', '0xD6' => '0xD7B2', |
|
| 2803 | + '0xE0' => '0xD790', '0xEA' => '0xD79A', '0xEC' => '0xD79C', |
|
| 2804 | + '0xED' => '0xD79D', '0xEE' => '0xD79E', '0xEF' => '0xD79F', |
|
| 2805 | + '0xF0' => '0xD7A0', '0xF1' => '0xD7A1', '0xF2' => '0xD7A2', |
|
| 2806 | + '0xF3' => '0xD7A3', '0xF5' => '0xD7A5', '0xF6' => '0xD7A6', |
|
| 2807 | + '0xF7' => '0xD7A7', '0xF8' => '0xD7A8', '0xF9' => '0xD7A9', |
|
| 2808 | + '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
| 2809 | + '0x86' => '0xE280A0', '0x87' => '0xE280A1', '0x89' => '0xE280B0', |
|
| 2810 | + '0x8B' => '0xE280B9', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
| 2811 | + '0x95' => '0xE280A2', '0x97' => '0xE28094', '0x99' => '0xE284A2', |
|
| 2812 | + '0xC0' => '0xD6B0', '0xC1' => '0xD6B1', '0xC3' => '0xD6B3', |
|
| 2813 | + '0xC4' => '0xD6B4', '0xC5' => '0xD6B5', '0xC6' => '0xD6B6', |
|
| 2814 | + '0xC7' => '0xD6B7', '0xC8' => '0xD6B8', '0xC9' => '0xD6B9', |
|
| 2815 | + '0xCB' => '0xD6BB', '0xCC' => '0xD6BC', '0xCD' => '0xD6BD', |
|
| 2816 | + '0xCE' => '0xD6BE', '0xCF' => '0xD6BF', '0xD0' => '0xD780', |
|
| 2817 | + '0xD2' => '0xD782', '0xE3' => '0xD793', '0xE4' => '0xD794', |
|
| 2818 | + '0xE5' => '0xD795', '0xE7' => '0xD797', '0xE9' => '0xD799', |
|
| 2819 | + '0xFD' => '0xE2808E', '0xFE' => '0xE2808F', '0x92' => '0xE28099', |
|
| 2820 | + '0x83' => '0xC692', '0xD3' => '0xD783', '0x88' => '0xCB86', |
|
| 2821 | + '0x98' => '0xCB9C', '0x91' => '0xE28098', '0x96' => '0xE28093', |
|
| 2822 | + '0xBA' => '0xC3B7', '0x9B' => '0xE280BA', '0xAA' => '0xC397', |
|
| 2823 | + '0xA4' => '0xE282AA', '0xE1' => '0xD791', '0xE6' => '0xD796', |
|
| 2824 | + '0xE8' => '0xD798', '0xEB' => '0xD79B', '0xF4' => '0xD7A4', |
|
| 2825 | 2825 | '0xFA' => '0xD7AA', |
| 2826 | 2826 | ), |
| 2827 | 2827 | 'windows-1253' => array( |
| 2828 | - '0x81' => '\'\'', '0x88' => '\'\'', '0x8A' => '\'\'', |
|
| 2829 | - '0x8C' => '\'\'', '0x8D' => '\'\'', '0x8E' => '\'\'', |
|
| 2830 | - '0x8F' => '\'\'', '0x90' => '\'\'', '0x98' => '\'\'', |
|
| 2831 | - '0x9A' => '\'\'', '0x9C' => '\'\'', '0x9D' => '\'\'', |
|
| 2832 | - '0x9E' => '\'\'', '0x9F' => '\'\'', '0xAA' => '\'\'', |
|
| 2833 | - '0xD2' => '0xE282AC', '0xFF' => '0xCE92', '0xCE' => '0xCE9E', |
|
| 2834 | - '0xB8' => '0xCE88', '0xBA' => '0xCE8A', '0xBC' => '0xCE8C', |
|
| 2835 | - '0xBE' => '0xCE8E', '0xBF' => '0xCE8F', '0xC0' => '0xCE90', |
|
| 2836 | - '0xC8' => '0xCE98', '0xCA' => '0xCE9A', '0xCC' => '0xCE9C', |
|
| 2837 | - '0xCD' => '0xCE9D', '0xCF' => '0xCE9F', '0xDA' => '0xCEAA', |
|
| 2838 | - '0xE8' => '0xCEB8', '0xEA' => '0xCEBA', '0xEC' => '0xCEBC', |
|
| 2839 | - '0xEE' => '0xCEBE', '0xEF' => '0xCEBF', '0xC2' => '0xFF', |
|
| 2840 | - '0xBD' => '0xC2BD', '0xED' => '0xCEBD', '0xB2' => '0xC2B2', |
|
| 2841 | - '0xA0' => '0xC2A0', '0xA3' => '0xC2A3', '0xA4' => '0xC2A4', |
|
| 2842 | - '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
| 2843 | - '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
| 2844 | - '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
| 2845 | - '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', '0xB3' => '0xC2B3', |
|
| 2846 | - '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
| 2847 | - '0xBB' => '0xC2BB', '0xE2' => '0xCEB2', '0x80' => '0xD2', |
|
| 2848 | - '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
| 2849 | - '0x86' => '0xE280A0', '0xA1' => '0xCE85', '0xA2' => '0xCE86', |
|
| 2850 | - '0x87' => '0xE280A1', '0x89' => '0xE280B0', '0xB9' => '0xCE89', |
|
| 2851 | - '0x8B' => '0xE280B9', '0x91' => '0xE28098', '0x99' => '0xE284A2', |
|
| 2852 | - '0x92' => '0xE28099', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
| 2853 | - '0x95' => '0xE280A2', '0x96' => '0xE28093', '0x97' => '0xE28094', |
|
| 2854 | - '0x9B' => '0xE280BA', '0xAF' => '0xE28095', '0xB4' => '0xCE84', |
|
| 2855 | - '0xC1' => '0xCE91', '0xC3' => '0xCE93', '0xC4' => '0xCE94', |
|
| 2856 | - '0xC5' => '0xCE95', '0xC6' => '0xCE96', '0x83' => '0xC692', |
|
| 2857 | - '0xC7' => '0xCE97', '0xC9' => '0xCE99', '0xCB' => '0xCE9B', |
|
| 2858 | - '0xD0' => '0xCEA0', '0xD1' => '0xCEA1', '0xD3' => '0xCEA3', |
|
| 2859 | - '0xD4' => '0xCEA4', '0xD5' => '0xCEA5', '0xD6' => '0xCEA6', |
|
| 2860 | - '0xD7' => '0xCEA7', '0xD8' => '0xCEA8', '0xD9' => '0xCEA9', |
|
| 2861 | - '0xDB' => '0xCEAB', '0xDC' => '0xCEAC', '0xDD' => '0xCEAD', |
|
| 2862 | - '0xDE' => '0xCEAE', '0xDF' => '0xCEAF', '0xE0' => '0xCEB0', |
|
| 2863 | - '0xE1' => '0xCEB1', '0xE3' => '0xCEB3', '0xE4' => '0xCEB4', |
|
| 2864 | - '0xE5' => '0xCEB5', '0xE6' => '0xCEB6', '0xE7' => '0xCEB7', |
|
| 2865 | - '0xE9' => '0xCEB9', '0xEB' => '0xCEBB', '0xF0' => '0xCF80', |
|
| 2866 | - '0xF1' => '0xCF81', '0xF2' => '0xCF82', '0xF3' => '0xCF83', |
|
| 2867 | - '0xF4' => '0xCF84', '0xF5' => '0xCF85', '0xF6' => '0xCF86', |
|
| 2868 | - '0xF7' => '0xCF87', '0xF8' => '0xCF88', '0xF9' => '0xCF89', |
|
| 2869 | - '0xFA' => '0xCF8A', '0xFB' => '0xCF8B', '0xFC' => '0xCF8C', |
|
| 2870 | - '0xFD' => '0xCF8D', '0xFE' => '0xCF8E', |
|
| 2828 | + '0x81' => '\'\'', '0x88' => '\'\'', '0x8A' => '\'\'', |
|
| 2829 | + '0x8C' => '\'\'', '0x8D' => '\'\'', '0x8E' => '\'\'', |
|
| 2830 | + '0x8F' => '\'\'', '0x90' => '\'\'', '0x98' => '\'\'', |
|
| 2831 | + '0x9A' => '\'\'', '0x9C' => '\'\'', '0x9D' => '\'\'', |
|
| 2832 | + '0x9E' => '\'\'', '0x9F' => '\'\'', '0xAA' => '\'\'', |
|
| 2833 | + '0xD2' => '0xE282AC', '0xFF' => '0xCE92', '0xCE' => '0xCE9E', |
|
| 2834 | + '0xB8' => '0xCE88', '0xBA' => '0xCE8A', '0xBC' => '0xCE8C', |
|
| 2835 | + '0xBE' => '0xCE8E', '0xBF' => '0xCE8F', '0xC0' => '0xCE90', |
|
| 2836 | + '0xC8' => '0xCE98', '0xCA' => '0xCE9A', '0xCC' => '0xCE9C', |
|
| 2837 | + '0xCD' => '0xCE9D', '0xCF' => '0xCE9F', '0xDA' => '0xCEAA', |
|
| 2838 | + '0xE8' => '0xCEB8', '0xEA' => '0xCEBA', '0xEC' => '0xCEBC', |
|
| 2839 | + '0xEE' => '0xCEBE', '0xEF' => '0xCEBF', '0xC2' => '0xFF', |
|
| 2840 | + '0xBD' => '0xC2BD', '0xED' => '0xCEBD', '0xB2' => '0xC2B2', |
|
| 2841 | + '0xA0' => '0xC2A0', '0xA3' => '0xC2A3', '0xA4' => '0xC2A4', |
|
| 2842 | + '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
| 2843 | + '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
| 2844 | + '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
| 2845 | + '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', '0xB3' => '0xC2B3', |
|
| 2846 | + '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
| 2847 | + '0xBB' => '0xC2BB', '0xE2' => '0xCEB2', '0x80' => '0xD2', |
|
| 2848 | + '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
| 2849 | + '0x86' => '0xE280A0', '0xA1' => '0xCE85', '0xA2' => '0xCE86', |
|
| 2850 | + '0x87' => '0xE280A1', '0x89' => '0xE280B0', '0xB9' => '0xCE89', |
|
| 2851 | + '0x8B' => '0xE280B9', '0x91' => '0xE28098', '0x99' => '0xE284A2', |
|
| 2852 | + '0x92' => '0xE28099', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
| 2853 | + '0x95' => '0xE280A2', '0x96' => '0xE28093', '0x97' => '0xE28094', |
|
| 2854 | + '0x9B' => '0xE280BA', '0xAF' => '0xE28095', '0xB4' => '0xCE84', |
|
| 2855 | + '0xC1' => '0xCE91', '0xC3' => '0xCE93', '0xC4' => '0xCE94', |
|
| 2856 | + '0xC5' => '0xCE95', '0xC6' => '0xCE96', '0x83' => '0xC692', |
|
| 2857 | + '0xC7' => '0xCE97', '0xC9' => '0xCE99', '0xCB' => '0xCE9B', |
|
| 2858 | + '0xD0' => '0xCEA0', '0xD1' => '0xCEA1', '0xD3' => '0xCEA3', |
|
| 2859 | + '0xD4' => '0xCEA4', '0xD5' => '0xCEA5', '0xD6' => '0xCEA6', |
|
| 2860 | + '0xD7' => '0xCEA7', '0xD8' => '0xCEA8', '0xD9' => '0xCEA9', |
|
| 2861 | + '0xDB' => '0xCEAB', '0xDC' => '0xCEAC', '0xDD' => '0xCEAD', |
|
| 2862 | + '0xDE' => '0xCEAE', '0xDF' => '0xCEAF', '0xE0' => '0xCEB0', |
|
| 2863 | + '0xE1' => '0xCEB1', '0xE3' => '0xCEB3', '0xE4' => '0xCEB4', |
|
| 2864 | + '0xE5' => '0xCEB5', '0xE6' => '0xCEB6', '0xE7' => '0xCEB7', |
|
| 2865 | + '0xE9' => '0xCEB9', '0xEB' => '0xCEBB', '0xF0' => '0xCF80', |
|
| 2866 | + '0xF1' => '0xCF81', '0xF2' => '0xCF82', '0xF3' => '0xCF83', |
|
| 2867 | + '0xF4' => '0xCF84', '0xF5' => '0xCF85', '0xF6' => '0xCF86', |
|
| 2868 | + '0xF7' => '0xCF87', '0xF8' => '0xCF88', '0xF9' => '0xCF89', |
|
| 2869 | + '0xFA' => '0xCF8A', '0xFB' => '0xCF8B', '0xFC' => '0xCF8C', |
|
| 2870 | + '0xFD' => '0xCF8D', '0xFE' => '0xCF8E', |
|
| 2871 | 2871 | ), |
| 2872 | 2872 | ); |
| 2873 | 2873 | |
@@ -3081,7 +3081,7 @@ discard block |
||
| 3081 | 3081 | |
| 3082 | 3082 | if ($upcontext['dropping_index'] && $command_line) |
| 3083 | 3083 | { |
| 3084 | - echo "\n" . '', $txt['upgrade_fulltext_error'] ,''; |
|
| 3084 | + echo "\n" . '', $txt['upgrade_fulltext_error'], ''; |
|
| 3085 | 3085 | flush(); |
| 3086 | 3086 | } |
| 3087 | 3087 | } |
@@ -3425,7 +3425,7 @@ discard block |
||
| 3425 | 3425 | { |
| 3426 | 3426 | echo ' |
| 3427 | 3427 | <div class="error"> |
| 3428 | - <p>', $txt['upgrade_writable_files'] ,'</p> |
|
| 3428 | + <p>', $txt['upgrade_writable_files'], '</p> |
|
| 3429 | 3429 | <ul class="error_content"> |
| 3430 | 3430 | <li>' . implode('</li> |
| 3431 | 3431 | <li>', $upcontext['chmod']['files']) . '</li> |
@@ -3791,12 +3791,12 @@ discard block |
||
| 3791 | 3791 | <div class="errorbox"> |
| 3792 | 3792 | <h3>', $txt['upgrade_warning'], '</h3> |
| 3793 | 3793 | <p>', sprintf($txt['upgrade_time_user'], $upcontext['user']['name']), '</p> |
| 3794 | - <p>', sprintf($txt[$agoTxt], $ago_seconds, $ago_minutes, $ago_hours), '</p> |
|
| 3794 | + <p>', sprintf($txt[$agoTxt], $ago_seconds, $ago_minutes, $ago_hours), '</p> |
|
| 3795 | 3795 | <p>', sprintf($txt[$updatedTxt], $updated_seconds, $updated_minutes, $updated_hours), '</p>'; |
| 3796 | 3796 | |
| 3797 | 3797 | if ($updated < 600) |
| 3798 | 3798 | echo ' |
| 3799 | - <p>', $txt['upgrade_run_script'], ' ', $upcontext['user']['name'],' ', $txt['upgrade_run_script2'], '</p>'; |
|
| 3799 | + <p>', $txt['upgrade_run_script'], ' ', $upcontext['user']['name'], ' ', $txt['upgrade_run_script2'], '</p>'; |
|
| 3800 | 3800 | |
| 3801 | 3801 | if ($updated > $upcontext['inactive_timeout']) |
| 3802 | 3802 | echo ' |
@@ -3905,7 +3905,7 @@ discard block |
||
| 3905 | 3905 | if (!empty($upcontext['upgrade_options_warning'])) |
| 3906 | 3906 | echo ' |
| 3907 | 3907 | <div class="errorbox"> |
| 3908 | - <h3>', $txt['upgrade_warning'] ,'</h3> |
|
| 3908 | + <h3>', $txt['upgrade_warning'], '</h3> |
|
| 3909 | 3909 | ', $upcontext['upgrade_options_warning'], ' |
| 3910 | 3910 | </div>'; |
| 3911 | 3911 | |
@@ -3969,7 +3969,7 @@ discard block |
||
| 3969 | 3969 | echo ' |
| 3970 | 3970 | <form action="', $upcontext['form_url'], '" name="upform" id="upform" method="post"> |
| 3971 | 3971 | <input type="hidden" name="backup_done" id="backup_done" value="0"> |
| 3972 | - <strong>', sprintf($txt['upgrade_completedtables_outof'], $upcontext['cur_table_num'], $upcontext['table_count']) ,'</strong> |
|
| 3972 | + <strong>', sprintf($txt['upgrade_completedtables_outof'], $upcontext['cur_table_num'], $upcontext['table_count']), '</strong> |
|
| 3973 | 3973 | <div id="debug_section"> |
| 3974 | 3974 | <span id="debuginfo"></span> |
| 3975 | 3975 | </div>'; |
@@ -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 | |
@@ -107,11 +108,14 @@ discard block |
||
| 107 | 108 | ini_set('default_socket_timeout', 900); |
| 108 | 109 | } |
| 109 | 110 | // Clean the upgrade path if this is from the client. |
| 110 | -if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) |
|
| 111 | - for ($i = 1; $i < $_SERVER['argc']; $i++) |
|
| 111 | +if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) { |
|
| 112 | + for ($i = 1; |
|
| 113 | +} |
|
| 114 | +$i < $_SERVER['argc']; $i++) |
|
| 112 | 115 | { |
| 113 | - if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) |
|
| 114 | - $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
| 116 | + if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) { |
|
| 117 | + $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
| 118 | + } |
|
| 115 | 119 | } |
| 116 | 120 | |
| 117 | 121 | // Are we from the client? |
@@ -119,16 +123,17 @@ discard block |
||
| 119 | 123 | { |
| 120 | 124 | $command_line = true; |
| 121 | 125 | $disable_security = true; |
| 122 | -} |
|
| 123 | -else |
|
| 126 | +} else { |
|
| 124 | 127 | $command_line = false; |
| 128 | +} |
|
| 125 | 129 | |
| 126 | 130 | // Load this now just because we can. |
| 127 | 131 | require_once($upgrade_path . '/Settings.php'); |
| 128 | 132 | |
| 129 | 133 | // We don't use "-utf8" anymore... Tweak the entry that may have been loaded by Settings.php |
| 130 | -if (isset($language)) |
|
| 134 | +if (isset($language)) { |
|
| 131 | 135 | $language = str_ireplace('-utf8', '', $language); |
| 136 | +} |
|
| 132 | 137 | |
| 133 | 138 | // Are we logged in? |
| 134 | 139 | if (isset($upgradeData)) |
@@ -136,10 +141,12 @@ discard block |
||
| 136 | 141 | $upcontext['user'] = json_decode(base64_decode($upgradeData), true); |
| 137 | 142 | |
| 138 | 143 | // Check for sensible values. |
| 139 | - if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) |
|
| 140 | - $upcontext['user']['started'] = time(); |
|
| 141 | - if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) |
|
| 142 | - $upcontext['user']['updated'] = 0; |
|
| 144 | + if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) { |
|
| 145 | + $upcontext['user']['started'] = time(); |
|
| 146 | + } |
|
| 147 | + if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) { |
|
| 148 | + $upcontext['user']['updated'] = 0; |
|
| 149 | + } |
|
| 143 | 150 | |
| 144 | 151 | $upcontext['started'] = $upcontext['user']['started']; |
| 145 | 152 | $upcontext['updated'] = $upcontext['user']['updated']; |
@@ -204,8 +211,9 @@ discard block |
||
| 204 | 211 | 'db_error_skip' => true, |
| 205 | 212 | ) |
| 206 | 213 | ); |
| 207 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 208 | - $modSettings[$row['variable']] = $row['value']; |
|
| 214 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 215 | + $modSettings[$row['variable']] = $row['value']; |
|
| 216 | + } |
|
| 209 | 217 | $smcFunc['db_free_result']($request); |
| 210 | 218 | } |
| 211 | 219 | |
@@ -215,14 +223,17 @@ discard block |
||
| 215 | 223 | $modSettings['theme_url'] = 'Themes/default'; |
| 216 | 224 | $modSettings['images_url'] = 'Themes/default/images'; |
| 217 | 225 | } |
| 218 | -if (!isset($settings['default_theme_url'])) |
|
| 226 | +if (!isset($settings['default_theme_url'])) { |
|
| 219 | 227 | $settings['default_theme_url'] = $modSettings['theme_url']; |
| 220 | -if (!isset($settings['default_theme_dir'])) |
|
| 228 | +} |
|
| 229 | +if (!isset($settings['default_theme_dir'])) { |
|
| 221 | 230 | $settings['default_theme_dir'] = $modSettings['theme_dir']; |
| 231 | +} |
|
| 222 | 232 | |
| 223 | 233 | // This is needed in case someone invokes the upgrader using https when upgrading an http forum |
| 224 | -if (httpsOn()) |
|
| 234 | +if (httpsOn()) { |
|
| 225 | 235 | $settings['default_theme_url'] = strtr($settings['default_theme_url'], array('http://' => 'https://')); |
| 236 | +} |
|
| 226 | 237 | |
| 227 | 238 | $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000; |
| 228 | 239 | // Default title... |
@@ -240,13 +251,15 @@ discard block |
||
| 240 | 251 | $support_js = $upcontext['upgrade_status']['js']; |
| 241 | 252 | |
| 242 | 253 | // Only set this if the upgrader status says so. |
| 243 | - if (empty($is_debug)) |
|
| 244 | - $is_debug = $upcontext['upgrade_status']['debug']; |
|
| 254 | + if (empty($is_debug)) { |
|
| 255 | + $is_debug = $upcontext['upgrade_status']['debug']; |
|
| 256 | + } |
|
| 245 | 257 | |
| 246 | 258 | // Load the language. |
| 247 | - if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 248 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 249 | -} |
|
| 259 | + if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 260 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 261 | + } |
|
| 262 | + } |
|
| 250 | 263 | // Set the defaults. |
| 251 | 264 | else |
| 252 | 265 | { |
@@ -264,15 +277,18 @@ discard block |
||
| 264 | 277 | } |
| 265 | 278 | |
| 266 | 279 | // If this isn't the first stage see whether they are logging in and resuming. |
| 267 | -if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) |
|
| 280 | +if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) { |
|
| 268 | 281 | checkLogin(); |
| 282 | +} |
|
| 269 | 283 | |
| 270 | -if ($command_line) |
|
| 284 | +if ($command_line) { |
|
| 271 | 285 | cmdStep0(); |
| 286 | +} |
|
| 272 | 287 | |
| 273 | 288 | // Don't error if we're using xml. |
| 274 | -if (isset($_GET['xml'])) |
|
| 289 | +if (isset($_GET['xml'])) { |
|
| 275 | 290 | $upcontext['return_error'] = true; |
| 291 | +} |
|
| 276 | 292 | |
| 277 | 293 | // Loop through all the steps doing each one as required. |
| 278 | 294 | $upcontext['overall_percent'] = 0; |
@@ -293,9 +309,9 @@ discard block |
||
| 293 | 309 | } |
| 294 | 310 | |
| 295 | 311 | // Call the step and if it returns false that means pause! |
| 296 | - if (function_exists($step[2]) && $step[2]() === false) |
|
| 297 | - break; |
|
| 298 | - elseif (function_exists($step[2])) { |
|
| 312 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
| 313 | + break; |
|
| 314 | + } elseif (function_exists($step[2])) { |
|
| 299 | 315 | //Start each new step with this unset, so the 'normal' template is called first |
| 300 | 316 | unset($_GET['xml']); |
| 301 | 317 | //Clear out warnings at the start of each step |
@@ -341,17 +357,18 @@ discard block |
||
| 341 | 357 | // This should not happen my dear... HELP ME DEVELOPERS!! |
| 342 | 358 | if (!empty($command_line)) |
| 343 | 359 | { |
| 344 | - if (function_exists('debug_print_backtrace')) |
|
| 345 | - debug_print_backtrace(); |
|
| 360 | + if (function_exists('debug_print_backtrace')) { |
|
| 361 | + debug_print_backtrace(); |
|
| 362 | + } |
|
| 346 | 363 | |
| 347 | 364 | 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.'; |
| 348 | 365 | flush(); |
| 349 | 366 | die(); |
| 350 | 367 | } |
| 351 | 368 | |
| 352 | - if (!isset($_GET['xml'])) |
|
| 353 | - template_upgrade_above(); |
|
| 354 | - else |
|
| 369 | + if (!isset($_GET['xml'])) { |
|
| 370 | + template_upgrade_above(); |
|
| 371 | + } else |
|
| 355 | 372 | { |
| 356 | 373 | header('content-type: text/xml; charset=UTF-8'); |
| 357 | 374 | // Sadly we need to retain the $_GET data thanks to the old upgrade scripts. |
@@ -373,25 +390,29 @@ discard block |
||
| 373 | 390 | $upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&substep=' . $_GET['substep'] . '&data=' . base64_encode(json_encode($upcontext['upgrade_status'])); |
| 374 | 391 | |
| 375 | 392 | // Custom stuff to pass back? |
| 376 | - if (!empty($upcontext['query_string'])) |
|
| 377 | - $upcontext['form_url'] .= $upcontext['query_string']; |
|
| 393 | + if (!empty($upcontext['query_string'])) { |
|
| 394 | + $upcontext['form_url'] .= $upcontext['query_string']; |
|
| 395 | + } |
|
| 378 | 396 | |
| 379 | 397 | // Call the appropriate subtemplate |
| 380 | - if (is_callable('template_' . $upcontext['sub_template'])) |
|
| 381 | - call_user_func('template_' . $upcontext['sub_template']); |
|
| 382 | - else |
|
| 383 | - die('Upgrade aborted! Invalid template: template_' . $upcontext['sub_template']); |
|
| 398 | + if (is_callable('template_' . $upcontext['sub_template'])) { |
|
| 399 | + call_user_func('template_' . $upcontext['sub_template']); |
|
| 400 | + } else { |
|
| 401 | + die('Upgrade aborted! Invalid template: template_' . $upcontext['sub_template']); |
|
| 402 | + } |
|
| 384 | 403 | } |
| 385 | 404 | |
| 386 | 405 | // Was there an error? |
| 387 | - if (!empty($upcontext['forced_error_message'])) |
|
| 388 | - echo $upcontext['forced_error_message']; |
|
| 406 | + if (!empty($upcontext['forced_error_message'])) { |
|
| 407 | + echo $upcontext['forced_error_message']; |
|
| 408 | + } |
|
| 389 | 409 | |
| 390 | 410 | // Show the footer. |
| 391 | - if (!isset($_GET['xml'])) |
|
| 392 | - template_upgrade_below(); |
|
| 393 | - else |
|
| 394 | - template_xml_below(); |
|
| 411 | + if (!isset($_GET['xml'])) { |
|
| 412 | + template_upgrade_below(); |
|
| 413 | + } else { |
|
| 414 | + template_xml_below(); |
|
| 415 | + } |
|
| 395 | 416 | } |
| 396 | 417 | |
| 397 | 418 | // Show the upgrade time for CLI when we are completely done, if in debug mode. |
@@ -403,12 +424,13 @@ discard block |
||
| 403 | 424 | $seconds = intval($active % 60); |
| 404 | 425 | |
| 405 | 426 | $totalTime = ''; |
| 406 | - if ($hours > 0) |
|
| 407 | - echo "\n" . '', sprintf($txt['upgrade_completed_time_hms'], $hours, $minutes, $seconds), '' . "\n"; |
|
| 408 | - elseif ($minutes > 0) |
|
| 409 | - echo "\n" . '', sprintf($txt['upgrade_completed_time_ms'], $minutes, $seconds), '' . "\n"; |
|
| 410 | - elseif ($seconds > 0) |
|
| 411 | - echo "\n" . '', sprintf($txt['upgrade_completed_time_s'], $seconds), '' . "\n"; |
|
| 427 | + if ($hours > 0) { |
|
| 428 | + echo "\n" . '', sprintf($txt['upgrade_completed_time_hms'], $hours, $minutes, $seconds), '' . "\n"; |
|
| 429 | + } elseif ($minutes > 0) { |
|
| 430 | + echo "\n" . '', sprintf($txt['upgrade_completed_time_ms'], $minutes, $seconds), '' . "\n"; |
|
| 431 | + } elseif ($seconds > 0) { |
|
| 432 | + echo "\n" . '', sprintf($txt['upgrade_completed_time_s'], $seconds), '' . "\n"; |
|
| 433 | + } |
|
| 412 | 434 | } |
| 413 | 435 | |
| 414 | 436 | // Bang - gone! |
@@ -429,8 +451,9 @@ discard block |
||
| 429 | 451 | $dir = dir(dirname(__FILE__) . '/Themes/default/languages'); |
| 430 | 452 | while ($entry = $dir->read()) |
| 431 | 453 | { |
| 432 | - if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') |
|
| 433 | - $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
| 454 | + if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') { |
|
| 455 | + $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
| 456 | + } |
|
| 434 | 457 | } |
| 435 | 458 | $dir->close(); |
| 436 | 459 | } |
@@ -474,10 +497,11 @@ discard block |
||
| 474 | 497 | } |
| 475 | 498 | |
| 476 | 499 | // Override the language file? |
| 477 | - if (isset($_GET['lang_file'])) |
|
| 478 | - $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
| 479 | - elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) |
|
| 480 | - $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
| 500 | + if (isset($_GET['lang_file'])) { |
|
| 501 | + $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
| 502 | + } elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) { |
|
| 503 | + $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
| 504 | + } |
|
| 481 | 505 | |
| 482 | 506 | // Make sure it exists, if it doesn't reset it. |
| 483 | 507 | if (!isset($_SESSION['installer_temp_lang']) || preg_match('~[^\\w_\\-.]~', $_SESSION['installer_temp_lang']) === 1 || !file_exists(dirname(__FILE__) . '/Themes/default/languages/' . $_SESSION['installer_temp_lang'])) |
@@ -486,12 +510,14 @@ discard block |
||
| 486 | 510 | list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
| 487 | 511 | |
| 488 | 512 | // If we have english and some other language, use the other language. We Americans hate english :P. |
| 489 | - if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) |
|
| 490 | - list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
| 513 | + if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) { |
|
| 514 | + list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
| 515 | + } |
|
| 491 | 516 | |
| 492 | 517 | // For backup we load the english at first -> second language overwrite the english one |
| 493 | - if (count($incontext['detected_languages']) > 1) |
|
| 494 | - require_once(dirname(__FILE__) . '/Themes/default/languages/Install.english.php'); |
|
| 518 | + if (count($incontext['detected_languages']) > 1) { |
|
| 519 | + require_once(dirname(__FILE__) . '/Themes/default/languages/Install.english.php'); |
|
| 520 | + } |
|
| 495 | 521 | } |
| 496 | 522 | |
| 497 | 523 | // And now include the actual language file itself. |
@@ -499,11 +525,12 @@ discard block |
||
| 499 | 525 | |
| 500 | 526 | // Which language did we load? Assume that he likes his language. |
| 501 | 527 | preg_match('~^Install\.(.+[^-utf8])\.php$~', $_SESSION['installer_temp_lang'], $matches); |
| 502 | - if (empty($matches[1])) |
|
| 503 | - $matches = [ |
|
| 528 | + if (empty($matches[1])) { |
|
| 529 | + $matches = [ |
|
| 504 | 530 | 0 => 'nothing', |
| 505 | 531 | 1 => 'english', |
| 506 | 532 | ]; |
| 533 | + } |
|
| 507 | 534 | $user_info['language'] = $matches[1]; |
| 508 | 535 | } |
| 509 | 536 | |
@@ -513,8 +540,9 @@ discard block |
||
| 513 | 540 | global $upgradeurl, $upcontext, $command_line; |
| 514 | 541 | |
| 515 | 542 | // Command line users can't be redirected. |
| 516 | - if ($command_line) |
|
| 517 | - upgradeExit(true); |
|
| 543 | + if ($command_line) { |
|
| 544 | + upgradeExit(true); |
|
| 545 | + } |
|
| 518 | 546 | |
| 519 | 547 | // Are we providing the core info? |
| 520 | 548 | if ($addForm) |
@@ -540,12 +568,14 @@ discard block |
||
| 540 | 568 | define('SMF', 1); |
| 541 | 569 | |
| 542 | 570 | // Start the session. |
| 543 | - if (@ini_get('session.save_handler') == 'user') |
|
| 544 | - @ini_set('session.save_handler', 'files'); |
|
| 571 | + if (@ini_get('session.save_handler') == 'user') { |
|
| 572 | + @ini_set('session.save_handler', 'files'); |
|
| 573 | + } |
|
| 545 | 574 | @session_start(); |
| 546 | 575 | |
| 547 | - if (empty($smcFunc)) |
|
| 548 | - $smcFunc = array(); |
|
| 576 | + if (empty($smcFunc)) { |
|
| 577 | + $smcFunc = array(); |
|
| 578 | + } |
|
| 549 | 579 | |
| 550 | 580 | // We need this for authentication and some upgrade code |
| 551 | 581 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -576,30 +606,34 @@ discard block |
||
| 576 | 606 | { |
| 577 | 607 | $options = array('non_fatal' => true); |
| 578 | 608 | // Add in the port if needed |
| 579 | - if (!empty($db_port)) |
|
| 580 | - $options['port'] = $db_port; |
|
| 609 | + if (!empty($db_port)) { |
|
| 610 | + $options['port'] = $db_port; |
|
| 611 | + } |
|
| 581 | 612 | |
| 582 | - if (!empty($db_mb4)) |
|
| 583 | - $options['db_mb4'] = $db_mb4; |
|
| 613 | + if (!empty($db_mb4)) { |
|
| 614 | + $options['db_mb4'] = $db_mb4; |
|
| 615 | + } |
|
| 584 | 616 | |
| 585 | 617 | $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $options); |
| 586 | - } |
|
| 587 | - else |
|
| 588 | - // If we've returned here, ping/reconnect to be safe |
|
| 618 | + } else { |
|
| 619 | + // If we've returned here, ping/reconnect to be safe |
|
| 589 | 620 | $smcFunc['db_ping']($db_connection); |
| 621 | + } |
|
| 590 | 622 | |
| 591 | 623 | // Oh dear god!! |
| 592 | - if ($db_connection === null) |
|
| 593 | - die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
| 624 | + if ($db_connection === null) { |
|
| 625 | + die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
| 626 | + } |
|
| 594 | 627 | |
| 595 | - if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) |
|
| 596 | - $smcFunc['db_query']('', ' |
|
| 628 | + if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) { |
|
| 629 | + $smcFunc['db_query']('', ' |
|
| 597 | 630 | SET NAMES {string:db_character_set}', |
| 598 | 631 | array( |
| 599 | 632 | 'db_error_skip' => true, |
| 600 | 633 | 'db_character_set' => $db_character_set, |
| 601 | 634 | ) |
| 602 | 635 | ); |
| 636 | + } |
|
| 603 | 637 | |
| 604 | 638 | // Load the modSettings data... |
| 605 | 639 | $request = $smcFunc['db_query']('', ' |
@@ -610,11 +644,11 @@ discard block |
||
| 610 | 644 | ) |
| 611 | 645 | ); |
| 612 | 646 | $modSettings = array(); |
| 613 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 614 | - $modSettings[$row['variable']] = $row['value']; |
|
| 647 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 648 | + $modSettings[$row['variable']] = $row['value']; |
|
| 649 | + } |
|
| 615 | 650 | $smcFunc['db_free_result']($request); |
| 616 | - } |
|
| 617 | - else |
|
| 651 | + } else |
|
| 618 | 652 | { |
| 619 | 653 | 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.'); |
| 620 | 654 | } |
@@ -628,9 +662,10 @@ discard block |
||
| 628 | 662 | cleanRequest(); |
| 629 | 663 | } |
| 630 | 664 | |
| 631 | - if (!isset($_GET['substep'])) |
|
| 632 | - $_GET['substep'] = 0; |
|
| 633 | -} |
|
| 665 | + if (!isset($_GET['substep'])) { |
|
| 666 | + $_GET['substep'] = 0; |
|
| 667 | + } |
|
| 668 | + } |
|
| 634 | 669 | |
| 635 | 670 | function initialize_inputs() |
| 636 | 671 | { |
@@ -660,8 +695,9 @@ discard block |
||
| 660 | 695 | $dh = opendir(dirname(__FILE__)); |
| 661 | 696 | while ($file = readdir($dh)) |
| 662 | 697 | { |
| 663 | - if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) |
|
| 664 | - @unlink(dirname(__FILE__) . '/' . $file); |
|
| 698 | + if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) { |
|
| 699 | + @unlink(dirname(__FILE__) . '/' . $file); |
|
| 700 | + } |
|
| 665 | 701 | } |
| 666 | 702 | closedir($dh); |
| 667 | 703 | |
@@ -690,8 +726,9 @@ discard block |
||
| 690 | 726 | $temp = 'upgrade_php?step'; |
| 691 | 727 | while (strlen($temp) > 4) |
| 692 | 728 | { |
| 693 | - if (isset($_GET[$temp])) |
|
| 694 | - unset($_GET[$temp]); |
|
| 729 | + if (isset($_GET[$temp])) { |
|
| 730 | + unset($_GET[$temp]); |
|
| 731 | + } |
|
| 695 | 732 | $temp = substr($temp, 1); |
| 696 | 733 | } |
| 697 | 734 | |
@@ -718,32 +755,39 @@ discard block |
||
| 718 | 755 | && @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $db_type . '.sql'); |
| 719 | 756 | |
| 720 | 757 | // Need legacy scripts? |
| 721 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) |
|
| 722 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
| 723 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) |
|
| 724 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
| 725 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) |
|
| 726 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
| 758 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) { |
|
| 759 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
| 760 | + } |
|
| 761 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) { |
|
| 762 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
| 763 | + } |
|
| 764 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) { |
|
| 765 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
| 766 | + } |
|
| 727 | 767 | |
| 728 | 768 | // We don't need "-utf8" files anymore... |
| 729 | 769 | $upcontext['language'] = str_ireplace('-utf8', '', $upcontext['language']); |
| 730 | 770 | |
| 731 | 771 | // This needs to exist! |
| 732 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 733 | - 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>]'); |
|
| 734 | - else |
|
| 735 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 772 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 773 | + 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>]'); |
|
| 774 | + } else { |
|
| 775 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 776 | + } |
|
| 736 | 777 | |
| 737 | - if (!$check) |
|
| 738 | - // 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. |
|
| 778 | + if (!$check) { |
|
| 779 | + // 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. |
|
| 739 | 780 | 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.'); |
| 781 | + } |
|
| 740 | 782 | |
| 741 | 783 | // Do they meet the install requirements? |
| 742 | - if (!php_version_check()) |
|
| 743 | - 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.'); |
|
| 784 | + if (!php_version_check()) { |
|
| 785 | + 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.'); |
|
| 786 | + } |
|
| 744 | 787 | |
| 745 | - if (!db_version_check()) |
|
| 746 | - 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.'); |
|
| 788 | + if (!db_version_check()) { |
|
| 789 | + 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.'); |
|
| 790 | + } |
|
| 747 | 791 | |
| 748 | 792 | // Do some checks to make sure they have proper privileges |
| 749 | 793 | db_extend('packages'); |
@@ -758,14 +802,16 @@ discard block |
||
| 758 | 802 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
| 759 | 803 | |
| 760 | 804 | // Sorry... we need CREATE, ALTER and DROP |
| 761 | - if (!$create || !$alter || !$drop) |
|
| 762 | - 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.'); |
|
| 805 | + if (!$create || !$alter || !$drop) { |
|
| 806 | + 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.'); |
|
| 807 | + } |
|
| 763 | 808 | |
| 764 | 809 | // Do a quick version spot check. |
| 765 | 810 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
| 766 | 811 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
| 767 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
| 768 | - 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.'); |
|
| 812 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
| 813 | + 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.'); |
|
| 814 | + } |
|
| 769 | 815 | |
| 770 | 816 | // What absolutely needs to be writable? |
| 771 | 817 | $writable_files = array( |
@@ -774,12 +820,13 @@ discard block |
||
| 774 | 820 | ); |
| 775 | 821 | |
| 776 | 822 | // Only check for minified writable files if we have it enabled or not set. |
| 777 | - if (!empty($modSettings['minimize_files']) || !isset($modSettings['minimize_files'])) |
|
| 778 | - $writable_files += array( |
|
| 823 | + if (!empty($modSettings['minimize_files']) || !isset($modSettings['minimize_files'])) { |
|
| 824 | + $writable_files += array( |
|
| 779 | 825 | $modSettings['theme_dir'] . '/css/minified.css', |
| 780 | 826 | $modSettings['theme_dir'] . '/scripts/minified.js', |
| 781 | 827 | $modSettings['theme_dir'] . '/scripts/minified_deferred.js', |
| 782 | 828 | ); |
| 829 | + } |
|
| 783 | 830 | |
| 784 | 831 | // Do we need to add this setting? |
| 785 | 832 | $need_settings_update = empty($modSettings['custom_avatar_dir']); |
@@ -791,12 +838,13 @@ discard block |
||
| 791 | 838 | quickFileWritable($custom_av_dir); |
| 792 | 839 | |
| 793 | 840 | // Are we good now? |
| 794 | - if (!is_writable($custom_av_dir)) |
|
| 795 | - 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)); |
|
| 796 | - elseif ($need_settings_update) |
|
| 841 | + if (!is_writable($custom_av_dir)) { |
|
| 842 | + 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)); |
|
| 843 | + } elseif ($need_settings_update) |
|
| 797 | 844 | { |
| 798 | - if (!function_exists('cache_put_data')) |
|
| 799 | - require_once($sourcedir . '/Load.php'); |
|
| 845 | + if (!function_exists('cache_put_data')) { |
|
| 846 | + require_once($sourcedir . '/Load.php'); |
|
| 847 | + } |
|
| 800 | 848 | |
| 801 | 849 | updateSettings(array('custom_avatar_dir' => $custom_av_dir)); |
| 802 | 850 | updateSettings(array('custom_avatar_url' => $custom_av_url)); |
@@ -806,29 +854,34 @@ discard block |
||
| 806 | 854 | |
| 807 | 855 | // Check the cache directory. |
| 808 | 856 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
| 809 | - if (!file_exists($cachedir_temp)) |
|
| 810 | - @mkdir($cachedir_temp); |
|
| 857 | + if (!file_exists($cachedir_temp)) { |
|
| 858 | + @mkdir($cachedir_temp); |
|
| 859 | + } |
|
| 811 | 860 | |
| 812 | - if (!file_exists($cachedir_temp)) |
|
| 813 | - 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.'); |
|
| 861 | + if (!file_exists($cachedir_temp)) { |
|
| 862 | + 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.'); |
|
| 863 | + } |
|
| 814 | 864 | |
| 815 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
| 816 | - 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>.'); |
|
| 817 | - elseif (!isset($_GET['skiplang'])) |
|
| 865 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
| 866 | + 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>.'); |
|
| 867 | + } elseif (!isset($_GET['skiplang'])) |
|
| 818 | 868 | { |
| 819 | 869 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
| 820 | 870 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 821 | 871 | |
| 822 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 823 | - 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>]'); |
|
| 872 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 873 | + 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>]'); |
|
| 874 | + } |
|
| 824 | 875 | } |
| 825 | 876 | |
| 826 | - if (!makeFilesWritable($writable_files)) |
|
| 827 | - return false; |
|
| 877 | + if (!makeFilesWritable($writable_files)) { |
|
| 878 | + return false; |
|
| 879 | + } |
|
| 828 | 880 | |
| 829 | 881 | // Check agreement.txt. (it may not exist, in which case $boarddir must be writable.) |
| 830 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
| 831 | - 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.'); |
|
| 882 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
| 883 | + 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.'); |
|
| 884 | + } |
|
| 832 | 885 | |
| 833 | 886 | // Upgrade the agreement. |
| 834 | 887 | elseif (isset($modSettings['agreement'])) |
@@ -839,8 +892,8 @@ discard block |
||
| 839 | 892 | } |
| 840 | 893 | |
| 841 | 894 | // We're going to check that their board dir setting is right in case they've been moving stuff around. |
| 842 | - if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) |
|
| 843 | - $upcontext['warning'] = ' |
|
| 895 | + if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) { |
|
| 896 | + $upcontext['warning'] = ' |
|
| 844 | 897 | '. sprintf($txt['upgrade_boarddir_settings'], $boarddir, dirname(__FILE__)) .'<br> |
| 845 | 898 | <ul> |
| 846 | 899 | <li>'. $txt['upgrade_boarddir'] .' ' . $boarddir . '</li> |
@@ -848,19 +901,23 @@ discard block |
||
| 848 | 901 | <li>'. $txt['upgrade_cachedir'] .' ' . $cachedir_temp . '</li> |
| 849 | 902 | </ul> |
| 850 | 903 | '. $txt['upgrade_incorrect_settings'] .''; |
| 904 | + } |
|
| 851 | 905 | |
| 852 | 906 | // Confirm mbstring is loaded... |
| 853 | - if (!extension_loaded('mbstring')) |
|
| 854 | - return throw_error($txt['install_no_mbstring']); |
|
| 907 | + if (!extension_loaded('mbstring')) { |
|
| 908 | + return throw_error($txt['install_no_mbstring']); |
|
| 909 | + } |
|
| 855 | 910 | |
| 856 | 911 | // Check for https stream support. |
| 857 | 912 | $supported_streams = stream_get_wrappers(); |
| 858 | - if (!in_array('https', $supported_streams)) |
|
| 859 | - $upcontext['custom_warning'] = $txt['install_no_https']; |
|
| 913 | + if (!in_array('https', $supported_streams)) { |
|
| 914 | + $upcontext['custom_warning'] = $txt['install_no_https']; |
|
| 915 | + } |
|
| 860 | 916 | |
| 861 | 917 | // Either we're logged in or we're going to present the login. |
| 862 | - if (checkLogin()) |
|
| 863 | - return true; |
|
| 918 | + if (checkLogin()) { |
|
| 919 | + return true; |
|
| 920 | + } |
|
| 864 | 921 | |
| 865 | 922 | $upcontext += createToken('login'); |
| 866 | 923 | |
@@ -874,15 +931,17 @@ discard block |
||
| 874 | 931 | global $smcFunc, $db_type, $support_js; |
| 875 | 932 | |
| 876 | 933 | // Don't bother if the security is disabled. |
| 877 | - if ($disable_security) |
|
| 878 | - return true; |
|
| 934 | + if ($disable_security) { |
|
| 935 | + return true; |
|
| 936 | + } |
|
| 879 | 937 | |
| 880 | 938 | // Are we trying to login? |
| 881 | 939 | if (isset($_POST['contbutt']) && (!empty($_POST['user']))) |
| 882 | 940 | { |
| 883 | 941 | // If we've disabled security pick a suitable name! |
| 884 | - if (empty($_POST['user'])) |
|
| 885 | - $_POST['user'] = 'Administrator'; |
|
| 942 | + if (empty($_POST['user'])) { |
|
| 943 | + $_POST['user'] = 'Administrator'; |
|
| 944 | + } |
|
| 886 | 945 | |
| 887 | 946 | // Before 2.0 these column names were different! |
| 888 | 947 | $oldDB = false; |
@@ -897,16 +956,17 @@ discard block |
||
| 897 | 956 | 'db_error_skip' => true, |
| 898 | 957 | ) |
| 899 | 958 | ); |
| 900 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 901 | - $oldDB = true; |
|
| 959 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 960 | + $oldDB = true; |
|
| 961 | + } |
|
| 902 | 962 | $smcFunc['db_free_result']($request); |
| 903 | 963 | } |
| 904 | 964 | |
| 905 | 965 | // Get what we believe to be their details. |
| 906 | 966 | if (!$disable_security) |
| 907 | 967 | { |
| 908 | - if ($oldDB) |
|
| 909 | - $request = $smcFunc['db_query']('', ' |
|
| 968 | + if ($oldDB) { |
|
| 969 | + $request = $smcFunc['db_query']('', ' |
|
| 910 | 970 | SELECT id_member, memberName AS member_name, passwd, id_group, |
| 911 | 971 | additionalGroups AS additional_groups, lngfile |
| 912 | 972 | FROM {db_prefix}members |
@@ -916,8 +976,8 @@ discard block |
||
| 916 | 976 | 'db_error_skip' => true, |
| 917 | 977 | ) |
| 918 | 978 | ); |
| 919 | - else |
|
| 920 | - $request = $smcFunc['db_query']('', ' |
|
| 979 | + } else { |
|
| 980 | + $request = $smcFunc['db_query']('', ' |
|
| 921 | 981 | SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile |
| 922 | 982 | FROM {db_prefix}members |
| 923 | 983 | WHERE member_name = {string:member_name}', |
@@ -926,6 +986,7 @@ discard block |
||
| 926 | 986 | 'db_error_skip' => true, |
| 927 | 987 | ) |
| 928 | 988 | ); |
| 989 | + } |
|
| 929 | 990 | if ($smcFunc['db_num_rows']($request) != 0) |
| 930 | 991 | { |
| 931 | 992 | list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request); |
@@ -933,16 +994,17 @@ discard block |
||
| 933 | 994 | $groups = explode(',', $addGroups); |
| 934 | 995 | $groups[] = $id_group; |
| 935 | 996 | |
| 936 | - foreach ($groups as $k => $v) |
|
| 937 | - $groups[$k] = (int) $v; |
|
| 997 | + foreach ($groups as $k => $v) { |
|
| 998 | + $groups[$k] = (int) $v; |
|
| 999 | + } |
|
| 938 | 1000 | |
| 939 | 1001 | $sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd'])); |
| 940 | 1002 | |
| 941 | 1003 | // We don't use "-utf8" anymore... |
| 942 | 1004 | $user_language = str_ireplace('-utf8', '', $user_language); |
| 1005 | + } else { |
|
| 1006 | + $upcontext['username_incorrect'] = true; |
|
| 943 | 1007 | } |
| 944 | - else |
|
| 945 | - $upcontext['username_incorrect'] = true; |
|
| 946 | 1008 | |
| 947 | 1009 | $smcFunc['db_free_result']($request); |
| 948 | 1010 | } |
@@ -953,13 +1015,14 @@ discard block |
||
| 953 | 1015 | { |
| 954 | 1016 | $upcontext['upgrade_status']['js'] = 1; |
| 955 | 1017 | $support_js = 1; |
| 1018 | + } else { |
|
| 1019 | + $support_js = 0; |
|
| 956 | 1020 | } |
| 957 | - else |
|
| 958 | - $support_js = 0; |
|
| 959 | 1021 | |
| 960 | 1022 | // Note down the version we are coming from. |
| 961 | - if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) |
|
| 962 | - $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
| 1023 | + if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) { |
|
| 1024 | + $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
| 1025 | + } |
|
| 963 | 1026 | |
| 964 | 1027 | // Didn't get anywhere? |
| 965 | 1028 | 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'])) |
@@ -993,15 +1056,15 @@ discard block |
||
| 993 | 1056 | 'db_error_skip' => true, |
| 994 | 1057 | ) |
| 995 | 1058 | ); |
| 996 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 997 | - return throw_error('You need to be an admin to perform an upgrade!'); |
|
| 1059 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1060 | + return throw_error('You need to be an admin to perform an upgrade!'); |
|
| 1061 | + } |
|
| 998 | 1062 | $smcFunc['db_free_result']($request); |
| 999 | 1063 | } |
| 1000 | 1064 | |
| 1001 | 1065 | $upcontext['user']['id'] = $id_member; |
| 1002 | 1066 | $upcontext['user']['name'] = $name; |
| 1003 | - } |
|
| 1004 | - else |
|
| 1067 | + } else |
|
| 1005 | 1068 | { |
| 1006 | 1069 | $upcontext['user']['id'] = 1; |
| 1007 | 1070 | $upcontext['user']['name'] = 'Administrator'; |
@@ -1017,11 +1080,11 @@ discard block |
||
| 1017 | 1080 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096); |
| 1018 | 1081 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 1019 | 1082 | |
| 1020 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 1021 | - $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'] . '.'; |
|
| 1022 | - elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) |
|
| 1023 | - $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'] . '.'; |
|
| 1024 | - else |
|
| 1083 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 1084 | + $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'] . '.'; |
|
| 1085 | + } elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) { |
|
| 1086 | + $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'] . '.'; |
|
| 1087 | + } else |
|
| 1025 | 1088 | { |
| 1026 | 1089 | // Set this as the new language. |
| 1027 | 1090 | $upcontext['language'] = $user_language; |
@@ -1065,8 +1128,9 @@ discard block |
||
| 1065 | 1128 | unset($member_columns); |
| 1066 | 1129 | |
| 1067 | 1130 | // If we've not submitted then we're done. |
| 1068 | - if (empty($_POST['upcont'])) |
|
| 1069 | - return false; |
|
| 1131 | + if (empty($_POST['upcont'])) { |
|
| 1132 | + return false; |
|
| 1133 | + } |
|
| 1070 | 1134 | |
| 1071 | 1135 | // Firstly, if they're enabling SM stat collection just do it. |
| 1072 | 1136 | if (!empty($_POST['stats']) && substr($boardurl, 0, 16) != 'http://localhost' && empty($modSettings['allow_sm_stats']) && empty($modSettings['enable_sm_stats'])) |
@@ -1086,16 +1150,17 @@ discard block |
||
| 1086 | 1150 | fwrite($fp, $out); |
| 1087 | 1151 | |
| 1088 | 1152 | $return_data = ''; |
| 1089 | - while (!feof($fp)) |
|
| 1090 | - $return_data .= fgets($fp, 128); |
|
| 1153 | + while (!feof($fp)) { |
|
| 1154 | + $return_data .= fgets($fp, 128); |
|
| 1155 | + } |
|
| 1091 | 1156 | |
| 1092 | 1157 | fclose($fp); |
| 1093 | 1158 | |
| 1094 | 1159 | // Get the unique site ID. |
| 1095 | 1160 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
| 1096 | 1161 | |
| 1097 | - if (!empty($ID[1])) |
|
| 1098 | - $smcFunc['db_insert']('replace', |
|
| 1162 | + if (!empty($ID[1])) { |
|
| 1163 | + $smcFunc['db_insert']('replace', |
|
| 1099 | 1164 | $db_prefix . 'settings', |
| 1100 | 1165 | array('variable' => 'string', 'value' => 'string'), |
| 1101 | 1166 | array( |
@@ -1104,9 +1169,9 @@ discard block |
||
| 1104 | 1169 | ), |
| 1105 | 1170 | array('variable') |
| 1106 | 1171 | ); |
| 1172 | + } |
|
| 1107 | 1173 | } |
| 1108 | - } |
|
| 1109 | - else |
|
| 1174 | + } else |
|
| 1110 | 1175 | { |
| 1111 | 1176 | $smcFunc['db_insert']('replace', |
| 1112 | 1177 | $db_prefix . 'settings', |
@@ -1117,8 +1182,8 @@ discard block |
||
| 1117 | 1182 | } |
| 1118 | 1183 | } |
| 1119 | 1184 | // Don't remove stat collection unless we unchecked the box for real, not from the loop. |
| 1120 | - elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) |
|
| 1121 | - $smcFunc['db_query']('', ' |
|
| 1185 | + elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) { |
|
| 1186 | + $smcFunc['db_query']('', ' |
|
| 1122 | 1187 | DELETE FROM {db_prefix}settings |
| 1123 | 1188 | WHERE variable = {string:enable_sm_stats}', |
| 1124 | 1189 | array( |
@@ -1126,6 +1191,7 @@ discard block |
||
| 1126 | 1191 | 'db_error_skip' => true, |
| 1127 | 1192 | ) |
| 1128 | 1193 | ); |
| 1194 | + } |
|
| 1129 | 1195 | |
| 1130 | 1196 | // Deleting old karma stuff? |
| 1131 | 1197 | if (!empty($_POST['delete_karma'])) |
@@ -1140,20 +1206,22 @@ discard block |
||
| 1140 | 1206 | ); |
| 1141 | 1207 | |
| 1142 | 1208 | // Cleaning up old karma member settings. |
| 1143 | - if ($upcontext['karma_installed']['good']) |
|
| 1144 | - $smcFunc['db_query']('', ' |
|
| 1209 | + if ($upcontext['karma_installed']['good']) { |
|
| 1210 | + $smcFunc['db_query']('', ' |
|
| 1145 | 1211 | ALTER TABLE {db_prefix}members |
| 1146 | 1212 | DROP karma_good', |
| 1147 | 1213 | array() |
| 1148 | 1214 | ); |
| 1215 | + } |
|
| 1149 | 1216 | |
| 1150 | 1217 | // Does karma bad was enable? |
| 1151 | - if ($upcontext['karma_installed']['bad']) |
|
| 1152 | - $smcFunc['db_query']('', ' |
|
| 1218 | + if ($upcontext['karma_installed']['bad']) { |
|
| 1219 | + $smcFunc['db_query']('', ' |
|
| 1153 | 1220 | ALTER TABLE {db_prefix}members |
| 1154 | 1221 | DROP karma_bad', |
| 1155 | 1222 | array() |
| 1156 | 1223 | ); |
| 1224 | + } |
|
| 1157 | 1225 | |
| 1158 | 1226 | // Cleaning up old karma permissions. |
| 1159 | 1227 | $smcFunc['db_query']('', ' |
@@ -1171,32 +1239,37 @@ discard block |
||
| 1171 | 1239 | } |
| 1172 | 1240 | |
| 1173 | 1241 | // Emptying the error log? |
| 1174 | - if (!empty($_POST['empty_error'])) |
|
| 1175 | - $smcFunc['db_query']('truncate_table', ' |
|
| 1242 | + if (!empty($_POST['empty_error'])) { |
|
| 1243 | + $smcFunc['db_query']('truncate_table', ' |
|
| 1176 | 1244 | TRUNCATE {db_prefix}log_errors', |
| 1177 | 1245 | array( |
| 1178 | 1246 | ) |
| 1179 | 1247 | ); |
| 1248 | + } |
|
| 1180 | 1249 | |
| 1181 | 1250 | $changes = array(); |
| 1182 | 1251 | |
| 1183 | 1252 | // Add proxy settings. |
| 1184 | - if (!isset($GLOBALS['image_proxy_maxsize'])) |
|
| 1185 | - $changes += array( |
|
| 1253 | + if (!isset($GLOBALS['image_proxy_maxsize'])) { |
|
| 1254 | + $changes += array( |
|
| 1186 | 1255 | 'image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'', |
| 1187 | 1256 | 'image_proxy_maxsize' => 5190, |
| 1188 | 1257 | 'image_proxy_enabled' => 0, |
| 1189 | 1258 | ); |
| 1259 | + } |
|
| 1190 | 1260 | |
| 1191 | 1261 | // If $boardurl reflects https, set force_ssl |
| 1192 | - if (!function_exists('cache_put_data')) |
|
| 1193 | - require_once($sourcedir . '/Load.php'); |
|
| 1194 | - if (stripos($boardurl, 'https://') !== false) |
|
| 1195 | - updateSettings(array('force_ssl' => '1')); |
|
| 1262 | + if (!function_exists('cache_put_data')) { |
|
| 1263 | + require_once($sourcedir . '/Load.php'); |
|
| 1264 | + } |
|
| 1265 | + if (stripos($boardurl, 'https://') !== false) { |
|
| 1266 | + updateSettings(array('force_ssl' => '1')); |
|
| 1267 | + } |
|
| 1196 | 1268 | |
| 1197 | 1269 | // If we're overriding the language follow it through. |
| 1198 | - if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) |
|
| 1199 | - $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
| 1270 | + if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) { |
|
| 1271 | + $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
| 1272 | + } |
|
| 1200 | 1273 | |
| 1201 | 1274 | if (!empty($_POST['maint'])) |
| 1202 | 1275 | { |
@@ -1208,26 +1281,29 @@ discard block |
||
| 1208 | 1281 | { |
| 1209 | 1282 | $changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\''; |
| 1210 | 1283 | $changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\''; |
| 1211 | - } |
|
| 1212 | - else |
|
| 1284 | + } else |
|
| 1213 | 1285 | { |
| 1214 | 1286 | $changes['mtitle'] = '\'Upgrading the forum...\''; |
| 1215 | 1287 | $changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum. It will only be a minute ;).\''; |
| 1216 | 1288 | } |
| 1217 | 1289 | } |
| 1218 | 1290 | |
| 1219 | - if ($command_line) |
|
| 1220 | - echo ' * Updating Settings.php...'; |
|
| 1291 | + if ($command_line) { |
|
| 1292 | + echo ' * Updating Settings.php...'; |
|
| 1293 | + } |
|
| 1221 | 1294 | |
| 1222 | 1295 | // Fix some old paths. |
| 1223 | - if (substr($boarddir, 0, 1) == '.') |
|
| 1224 | - $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
| 1296 | + if (substr($boarddir, 0, 1) == '.') { |
|
| 1297 | + $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
| 1298 | + } |
|
| 1225 | 1299 | |
| 1226 | - if (substr($sourcedir, 0, 1) == '.') |
|
| 1227 | - $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
| 1300 | + if (substr($sourcedir, 0, 1) == '.') { |
|
| 1301 | + $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
| 1302 | + } |
|
| 1228 | 1303 | |
| 1229 | - if (empty($cachedir) || substr($cachedir, 0, 1) == '.') |
|
| 1230 | - $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
| 1304 | + if (empty($cachedir) || substr($cachedir, 0, 1) == '.') { |
|
| 1305 | + $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
| 1306 | + } |
|
| 1231 | 1307 | |
| 1232 | 1308 | // If they have a "host:port" setup for the host, split that into separate values |
| 1233 | 1309 | // You should never have a : in the hostname if you're not on MySQL, but better safe than sorry |
@@ -1238,32 +1314,36 @@ discard block |
||
| 1238 | 1314 | $changes['db_server'] = '\'' . $db_server . '\''; |
| 1239 | 1315 | |
| 1240 | 1316 | // Only set this if we're not using the default port |
| 1241 | - if ($db_port != ini_get('mysqli.default_port')) |
|
| 1242 | - $changes['db_port'] = (int) $db_port; |
|
| 1243 | - } |
|
| 1244 | - elseif (!empty($db_port)) |
|
| 1317 | + if ($db_port != ini_get('mysqli.default_port')) { |
|
| 1318 | + $changes['db_port'] = (int) $db_port; |
|
| 1319 | + } |
|
| 1320 | + } elseif (!empty($db_port)) |
|
| 1245 | 1321 | { |
| 1246 | 1322 | // If db_port is set and is the same as the default, set it to '' |
| 1247 | 1323 | if ($db_type == 'mysql') |
| 1248 | 1324 | { |
| 1249 | - if ($db_port == ini_get('mysqli.default_port')) |
|
| 1250 | - $changes['db_port'] = '\'\''; |
|
| 1251 | - elseif ($db_type == 'postgresql' && $db_port == 5432) |
|
| 1252 | - $changes['db_port'] = '\'\''; |
|
| 1325 | + if ($db_port == ini_get('mysqli.default_port')) { |
|
| 1326 | + $changes['db_port'] = '\'\''; |
|
| 1327 | + } elseif ($db_type == 'postgresql' && $db_port == 5432) { |
|
| 1328 | + $changes['db_port'] = '\'\''; |
|
| 1329 | + } |
|
| 1253 | 1330 | } |
| 1254 | 1331 | } |
| 1255 | 1332 | |
| 1256 | 1333 | // Maybe we haven't had this option yet? |
| 1257 | - if (empty($packagesdir)) |
|
| 1258 | - $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
| 1334 | + if (empty($packagesdir)) { |
|
| 1335 | + $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
| 1336 | + } |
|
| 1259 | 1337 | |
| 1260 | 1338 | // Add support for $tasksdir var. |
| 1261 | - if (empty($tasksdir)) |
|
| 1262 | - $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
| 1339 | + if (empty($tasksdir)) { |
|
| 1340 | + $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
| 1341 | + } |
|
| 1263 | 1342 | |
| 1264 | 1343 | // Make sure we fix the language as well. |
| 1265 | - if (stristr($language, '-utf8')) |
|
| 1266 | - $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
| 1344 | + if (stristr($language, '-utf8')) { |
|
| 1345 | + $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
| 1346 | + } |
|
| 1267 | 1347 | |
| 1268 | 1348 | // @todo Maybe change the cookie name if going to 1.1, too? |
| 1269 | 1349 | |
@@ -1274,8 +1354,9 @@ discard block |
||
| 1274 | 1354 | // Tell Settings.php to store db_last_error.php in the cache |
| 1275 | 1355 | move_db_last_error_to_cachedir(); |
| 1276 | 1356 | |
| 1277 | - if ($command_line) |
|
| 1278 | - echo ' Successful.' . "\n"; |
|
| 1357 | + if ($command_line) { |
|
| 1358 | + echo ' Successful.' . "\n"; |
|
| 1359 | + } |
|
| 1279 | 1360 | |
| 1280 | 1361 | // Are we doing debug? |
| 1281 | 1362 | if (isset($_POST['debug'])) |
@@ -1285,8 +1366,9 @@ discard block |
||
| 1285 | 1366 | } |
| 1286 | 1367 | |
| 1287 | 1368 | // If we're not backing up then jump one. |
| 1288 | - if (empty($_POST['backup'])) |
|
| 1289 | - $upcontext['current_step']++; |
|
| 1369 | + if (empty($_POST['backup'])) { |
|
| 1370 | + $upcontext['current_step']++; |
|
| 1371 | + } |
|
| 1290 | 1372 | |
| 1291 | 1373 | // If we've got here then let's proceed to the next step! |
| 1292 | 1374 | return true; |
@@ -1301,8 +1383,9 @@ discard block |
||
| 1301 | 1383 | $upcontext['page_title'] = $txt['backup_database']; |
| 1302 | 1384 | |
| 1303 | 1385 | // Done it already - js wise? |
| 1304 | - if (!empty($_POST['backup_done'])) |
|
| 1305 | - return true; |
|
| 1386 | + if (!empty($_POST['backup_done'])) { |
|
| 1387 | + return true; |
|
| 1388 | + } |
|
| 1306 | 1389 | |
| 1307 | 1390 | // Some useful stuff here. |
| 1308 | 1391 | db_extend(); |
@@ -1316,9 +1399,10 @@ discard block |
||
| 1316 | 1399 | $tables = $smcFunc['db_list_tables']($db, $filter); |
| 1317 | 1400 | |
| 1318 | 1401 | $table_names = array(); |
| 1319 | - foreach ($tables as $table) |
|
| 1320 | - if (substr($table, 0, 7) !== 'backup_') |
|
| 1402 | + foreach ($tables as $table) { |
|
| 1403 | + if (substr($table, 0, 7) !== 'backup_') |
|
| 1321 | 1404 | $table_names[] = $table; |
| 1405 | + } |
|
| 1322 | 1406 | |
| 1323 | 1407 | $upcontext['table_count'] = count($table_names); |
| 1324 | 1408 | $upcontext['cur_table_num'] = $_GET['substep']; |
@@ -1328,12 +1412,14 @@ discard block |
||
| 1328 | 1412 | $file_steps = $upcontext['table_count']; |
| 1329 | 1413 | |
| 1330 | 1414 | // What ones have we already done? |
| 1331 | - foreach ($table_names as $id => $table) |
|
| 1332 | - if ($id < $_GET['substep']) |
|
| 1415 | + foreach ($table_names as $id => $table) { |
|
| 1416 | + if ($id < $_GET['substep']) |
|
| 1333 | 1417 | $upcontext['previous_tables'][] = $table; |
| 1418 | + } |
|
| 1334 | 1419 | |
| 1335 | - if ($command_line) |
|
| 1336 | - echo 'Backing Up Tables.'; |
|
| 1420 | + if ($command_line) { |
|
| 1421 | + echo 'Backing Up Tables.'; |
|
| 1422 | + } |
|
| 1337 | 1423 | |
| 1338 | 1424 | // If we don't support javascript we backup here. |
| 1339 | 1425 | if (!$support_js || isset($_GET['xml'])) |
@@ -1352,8 +1438,9 @@ discard block |
||
| 1352 | 1438 | backupTable($table_names[$substep]); |
| 1353 | 1439 | |
| 1354 | 1440 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 1355 | - if (isset($_GET['xml'])) |
|
| 1356 | - return upgradeExit(); |
|
| 1441 | + if (isset($_GET['xml'])) { |
|
| 1442 | + return upgradeExit(); |
|
| 1443 | + } |
|
| 1357 | 1444 | } |
| 1358 | 1445 | |
| 1359 | 1446 | if ($command_line) |
@@ -1386,9 +1473,10 @@ discard block |
||
| 1386 | 1473 | |
| 1387 | 1474 | $smcFunc['db_backup_table']($table, 'backup_' . $table); |
| 1388 | 1475 | |
| 1389 | - if ($command_line) |
|
| 1390 | - echo ' done.'; |
|
| 1391 | -} |
|
| 1476 | + if ($command_line) { |
|
| 1477 | + echo ' done.'; |
|
| 1478 | + } |
|
| 1479 | + } |
|
| 1392 | 1480 | |
| 1393 | 1481 | // Step 2: Everything. |
| 1394 | 1482 | function DatabaseChanges() |
@@ -1397,8 +1485,9 @@ discard block |
||
| 1397 | 1485 | global $upcontext, $support_js, $db_type; |
| 1398 | 1486 | |
| 1399 | 1487 | // Have we just completed this? |
| 1400 | - if (!empty($_POST['database_done'])) |
|
| 1401 | - return true; |
|
| 1488 | + if (!empty($_POST['database_done'])) { |
|
| 1489 | + return true; |
|
| 1490 | + } |
|
| 1402 | 1491 | |
| 1403 | 1492 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes'; |
| 1404 | 1493 | $upcontext['page_title'] = $txt['database_changes']; |
@@ -1413,15 +1502,16 @@ discard block |
||
| 1413 | 1502 | ); |
| 1414 | 1503 | |
| 1415 | 1504 | // How many files are there in total? |
| 1416 | - if (isset($_GET['filecount'])) |
|
| 1417 | - $upcontext['file_count'] = (int) $_GET['filecount']; |
|
| 1418 | - else |
|
| 1505 | + if (isset($_GET['filecount'])) { |
|
| 1506 | + $upcontext['file_count'] = (int) $_GET['filecount']; |
|
| 1507 | + } else |
|
| 1419 | 1508 | { |
| 1420 | 1509 | $upcontext['file_count'] = 0; |
| 1421 | 1510 | foreach ($files as $file) |
| 1422 | 1511 | { |
| 1423 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) |
|
| 1424 | - $upcontext['file_count']++; |
|
| 1512 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) { |
|
| 1513 | + $upcontext['file_count']++; |
|
| 1514 | + } |
|
| 1425 | 1515 | } |
| 1426 | 1516 | } |
| 1427 | 1517 | |
@@ -1431,9 +1521,9 @@ discard block |
||
| 1431 | 1521 | $upcontext['cur_file_num'] = 0; |
| 1432 | 1522 | foreach ($files as $file) |
| 1433 | 1523 | { |
| 1434 | - if ($did_not_do) |
|
| 1435 | - $did_not_do--; |
|
| 1436 | - else |
|
| 1524 | + if ($did_not_do) { |
|
| 1525 | + $did_not_do--; |
|
| 1526 | + } else |
|
| 1437 | 1527 | { |
| 1438 | 1528 | $upcontext['cur_file_num']++; |
| 1439 | 1529 | $upcontext['cur_file_name'] = $file[0]; |
@@ -1460,12 +1550,13 @@ discard block |
||
| 1460 | 1550 | // Flag to move on to the next. |
| 1461 | 1551 | $upcontext['completed_step'] = true; |
| 1462 | 1552 | // Did we complete the whole file? |
| 1463 | - if ($nextFile) |
|
| 1464 | - $upcontext['current_debug_item_num'] = -1; |
|
| 1553 | + if ($nextFile) { |
|
| 1554 | + $upcontext['current_debug_item_num'] = -1; |
|
| 1555 | + } |
|
| 1465 | 1556 | return upgradeExit(); |
| 1557 | + } elseif ($support_js) { |
|
| 1558 | + break; |
|
| 1466 | 1559 | } |
| 1467 | - elseif ($support_js) |
|
| 1468 | - break; |
|
| 1469 | 1560 | } |
| 1470 | 1561 | // Set the progress bar to be right as if we had - even if we hadn't... |
| 1471 | 1562 | $upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100; |
@@ -1491,8 +1582,9 @@ discard block |
||
| 1491 | 1582 | global $user_info, $maintenance, $smcFunc, $db_type, $txt, $settings; |
| 1492 | 1583 | |
| 1493 | 1584 | // Now it's nice to have some of the basic SMF source files. |
| 1494 | - if (!isset($_GET['ssi']) && !$command_line) |
|
| 1495 | - redirectLocation('&ssi=1'); |
|
| 1585 | + if (!isset($_GET['ssi']) && !$command_line) { |
|
| 1586 | + redirectLocation('&ssi=1'); |
|
| 1587 | + } |
|
| 1496 | 1588 | |
| 1497 | 1589 | $upcontext['sub_template'] = 'upgrade_complete'; |
| 1498 | 1590 | $upcontext['page_title'] = $txt['upgrade_complete']; |
@@ -1508,14 +1600,16 @@ discard block |
||
| 1508 | 1600 | // Are we in maintenance mode? |
| 1509 | 1601 | if (isset($upcontext['user']['main'])) |
| 1510 | 1602 | { |
| 1511 | - if ($command_line) |
|
| 1512 | - echo ' * '; |
|
| 1603 | + if ($command_line) { |
|
| 1604 | + echo ' * '; |
|
| 1605 | + } |
|
| 1513 | 1606 | $upcontext['removed_maintenance'] = true; |
| 1514 | 1607 | $changes['maintenance'] = $upcontext['user']['main']; |
| 1515 | 1608 | } |
| 1516 | 1609 | // Otherwise if somehow we are in 2 let's go to 1. |
| 1517 | - elseif (!empty($maintenance) && $maintenance == 2) |
|
| 1518 | - $changes['maintenance'] = 1; |
|
| 1610 | + elseif (!empty($maintenance) && $maintenance == 2) { |
|
| 1611 | + $changes['maintenance'] = 1; |
|
| 1612 | + } |
|
| 1519 | 1613 | |
| 1520 | 1614 | // Wipe this out... |
| 1521 | 1615 | $upcontext['user'] = array(); |
@@ -1530,21 +1624,23 @@ discard block |
||
| 1530 | 1624 | $upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__); |
| 1531 | 1625 | |
| 1532 | 1626 | // Now is the perfect time to fetch the SM files. |
| 1533 | - if ($command_line) |
|
| 1534 | - cli_scheduled_fetchSMfiles(); |
|
| 1535 | - else |
|
| 1627 | + if ($command_line) { |
|
| 1628 | + cli_scheduled_fetchSMfiles(); |
|
| 1629 | + } else |
|
| 1536 | 1630 | { |
| 1537 | 1631 | require_once($sourcedir . '/ScheduledTasks.php'); |
| 1538 | 1632 | $forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us. |
| 1539 | 1633 | scheduled_fetchSMfiles(); // Now go get those files! |
| 1540 | 1634 | // This is needed in case someone invokes the upgrader using https when upgrading an http forum |
| 1541 | - if (httpsOn()) |
|
| 1542 | - $settings['default_theme_url'] = strtr($settings['default_theme_url'], array('http://' => 'https://')); |
|
| 1635 | + if (httpsOn()) { |
|
| 1636 | + $settings['default_theme_url'] = strtr($settings['default_theme_url'], array('http://' => 'https://')); |
|
| 1637 | + } |
|
| 1543 | 1638 | } |
| 1544 | 1639 | |
| 1545 | 1640 | // Log what we've done. |
| 1546 | - if (empty($user_info['id'])) |
|
| 1547 | - $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
| 1641 | + if (empty($user_info['id'])) { |
|
| 1642 | + $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
| 1643 | + } |
|
| 1548 | 1644 | |
| 1549 | 1645 | // Log the action manually, so CLI still works. |
| 1550 | 1646 | $smcFunc['db_insert']('', |
@@ -1563,8 +1659,9 @@ discard block |
||
| 1563 | 1659 | |
| 1564 | 1660 | // Save the current database version. |
| 1565 | 1661 | $server_version = $smcFunc['db_server_info'](); |
| 1566 | - if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
| 1567 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1662 | + if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
| 1663 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1664 | + } |
|
| 1568 | 1665 | |
| 1569 | 1666 | if ($command_line) |
| 1570 | 1667 | { |
@@ -1576,8 +1673,9 @@ discard block |
||
| 1576 | 1673 | |
| 1577 | 1674 | // Make sure it says we're done. |
| 1578 | 1675 | $upcontext['overall_percent'] = 100; |
| 1579 | - if (isset($upcontext['step_progress'])) |
|
| 1580 | - unset($upcontext['step_progress']); |
|
| 1676 | + if (isset($upcontext['step_progress'])) { |
|
| 1677 | + unset($upcontext['step_progress']); |
|
| 1678 | + } |
|
| 1581 | 1679 | |
| 1582 | 1680 | $_GET['substep'] = 0; |
| 1583 | 1681 | return false; |
@@ -1588,8 +1686,9 @@ discard block |
||
| 1588 | 1686 | { |
| 1589 | 1687 | global $sourcedir, $language, $forum_version, $modSettings, $smcFunc; |
| 1590 | 1688 | |
| 1591 | - if (empty($modSettings['time_format'])) |
|
| 1592 | - $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
| 1689 | + if (empty($modSettings['time_format'])) { |
|
| 1690 | + $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
| 1691 | + } |
|
| 1593 | 1692 | |
| 1594 | 1693 | // What files do we want to get |
| 1595 | 1694 | $request = $smcFunc['db_query']('', ' |
@@ -1623,8 +1722,9 @@ discard block |
||
| 1623 | 1722 | $file_data = fetch_web_data($url); |
| 1624 | 1723 | |
| 1625 | 1724 | // If we got an error - give up - the site might be down. |
| 1626 | - if ($file_data === false) |
|
| 1627 | - return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
| 1725 | + if ($file_data === false) { |
|
| 1726 | + return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
| 1727 | + } |
|
| 1628 | 1728 | |
| 1629 | 1729 | // Save the file to the database. |
| 1630 | 1730 | $smcFunc['db_query']('substring', ' |
@@ -1666,8 +1766,9 @@ discard block |
||
| 1666 | 1766 | $themeData = array(); |
| 1667 | 1767 | foreach ($values as $variable => $value) |
| 1668 | 1768 | { |
| 1669 | - if (!isset($value) || $value === null) |
|
| 1670 | - $value = 0; |
|
| 1769 | + if (!isset($value) || $value === null) { |
|
| 1770 | + $value = 0; |
|
| 1771 | + } |
|
| 1671 | 1772 | |
| 1672 | 1773 | $themeData[] = array(0, 1, $variable, $value); |
| 1673 | 1774 | } |
@@ -1696,8 +1797,9 @@ discard block |
||
| 1696 | 1797 | |
| 1697 | 1798 | foreach ($values as $variable => $value) |
| 1698 | 1799 | { |
| 1699 | - if (empty($modSettings[$value[0]])) |
|
| 1700 | - continue; |
|
| 1800 | + if (empty($modSettings[$value[0]])) { |
|
| 1801 | + continue; |
|
| 1802 | + } |
|
| 1701 | 1803 | |
| 1702 | 1804 | $smcFunc['db_query']('', ' |
| 1703 | 1805 | INSERT IGNORE INTO {db_prefix}themes |
@@ -1783,19 +1885,21 @@ discard block |
||
| 1783 | 1885 | set_error_handler( |
| 1784 | 1886 | function ($errno, $errstr, $errfile, $errline) use ($support_js) |
| 1785 | 1887 | { |
| 1786 | - if ($support_js) |
|
| 1787 | - return true; |
|
| 1788 | - else |
|
| 1789 | - echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
| 1888 | + if ($support_js) { |
|
| 1889 | + return true; |
|
| 1890 | + } else { |
|
| 1891 | + echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
| 1892 | + } |
|
| 1790 | 1893 | } |
| 1791 | 1894 | ); |
| 1792 | 1895 | |
| 1793 | 1896 | // If we're on MySQL, set {db_collation}; this approach is used throughout upgrade_2-0_mysql.php to set new tables to utf8 |
| 1794 | 1897 | // Note it is expected to be in the format: ENGINE=MyISAM{$db_collation}; |
| 1795 | - if ($db_type == 'mysql') |
|
| 1796 | - $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
| 1797 | - else |
|
| 1798 | - $db_collation = ''; |
|
| 1898 | + if ($db_type == 'mysql') { |
|
| 1899 | + $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
| 1900 | + } else { |
|
| 1901 | + $db_collation = ''; |
|
| 1902 | + } |
|
| 1799 | 1903 | |
| 1800 | 1904 | $endl = $command_line ? "\n" : '<br>' . "\n"; |
| 1801 | 1905 | |
@@ -1807,8 +1911,9 @@ discard block |
||
| 1807 | 1911 | $last_step = ''; |
| 1808 | 1912 | |
| 1809 | 1913 | // Make sure all newly created tables will have the proper characters set; this approach is used throughout upgrade_2-1_mysql.php |
| 1810 | - if (isset($db_character_set) && $db_character_set === 'utf8') |
|
| 1811 | - $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
| 1914 | + if (isset($db_character_set) && $db_character_set === 'utf8') { |
|
| 1915 | + $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
| 1916 | + } |
|
| 1812 | 1917 | |
| 1813 | 1918 | // Count the total number of steps within this file - for progress. |
| 1814 | 1919 | $file_steps = substr_count(implode('', $lines), '---#'); |
@@ -1828,15 +1933,18 @@ discard block |
||
| 1828 | 1933 | $do_current = $substep >= $_GET['substep']; |
| 1829 | 1934 | |
| 1830 | 1935 | // Get rid of any comments in the beginning of the line... |
| 1831 | - if (substr(trim($line), 0, 2) === '/*') |
|
| 1832 | - $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
| 1936 | + if (substr(trim($line), 0, 2) === '/*') { |
|
| 1937 | + $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
| 1938 | + } |
|
| 1833 | 1939 | |
| 1834 | 1940 | // Always flush. Flush, flush, flush. Flush, flush, flush, flush! FLUSH! |
| 1835 | - if ($is_debug && !$support_js && $command_line) |
|
| 1836 | - flush(); |
|
| 1941 | + if ($is_debug && !$support_js && $command_line) { |
|
| 1942 | + flush(); |
|
| 1943 | + } |
|
| 1837 | 1944 | |
| 1838 | - if (trim($line) === '') |
|
| 1839 | - continue; |
|
| 1945 | + if (trim($line) === '') { |
|
| 1946 | + continue; |
|
| 1947 | + } |
|
| 1840 | 1948 | |
| 1841 | 1949 | if (trim(substr($line, 0, 3)) === '---') |
| 1842 | 1950 | { |
@@ -1846,8 +1954,9 @@ discard block |
||
| 1846 | 1954 | if (trim($current_data) != '' && $type !== '}') |
| 1847 | 1955 | { |
| 1848 | 1956 | $upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl; |
| 1849 | - if ($command_line) |
|
| 1850 | - echo $upcontext['error_message']; |
|
| 1957 | + if ($command_line) { |
|
| 1958 | + echo $upcontext['error_message']; |
|
| 1959 | + } |
|
| 1851 | 1960 | } |
| 1852 | 1961 | |
| 1853 | 1962 | if ($type == ' ') |
@@ -1865,17 +1974,18 @@ discard block |
||
| 1865 | 1974 | if ($do_current) |
| 1866 | 1975 | { |
| 1867 | 1976 | $upcontext['actioned_items'][] = $last_step; |
| 1868 | - if ($command_line) |
|
| 1869 | - echo ' * '; |
|
| 1977 | + if ($command_line) { |
|
| 1978 | + echo ' * '; |
|
| 1979 | + } |
|
| 1870 | 1980 | } |
| 1871 | - } |
|
| 1872 | - elseif ($type == '#') |
|
| 1981 | + } elseif ($type == '#') |
|
| 1873 | 1982 | { |
| 1874 | 1983 | $upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps; |
| 1875 | 1984 | |
| 1876 | 1985 | $upcontext['current_debug_item_num']++; |
| 1877 | - if (trim($line) != '---#') |
|
| 1878 | - $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1986 | + if (trim($line) != '---#') { |
|
| 1987 | + $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1988 | + } |
|
| 1879 | 1989 | |
| 1880 | 1990 | // Have we already done something? |
| 1881 | 1991 | if (isset($_GET['xml']) && $done_something) |
@@ -1886,34 +1996,36 @@ discard block |
||
| 1886 | 1996 | |
| 1887 | 1997 | if ($do_current) |
| 1888 | 1998 | { |
| 1889 | - if (trim($line) == '---#' && $command_line) |
|
| 1890 | - echo ' done.', $endl; |
|
| 1891 | - elseif ($command_line) |
|
| 1892 | - echo ' +++ ', rtrim(substr($line, 4)); |
|
| 1893 | - elseif (trim($line) != '---#') |
|
| 1999 | + if (trim($line) == '---#' && $command_line) { |
|
| 2000 | + echo ' done.', $endl; |
|
| 2001 | + } elseif ($command_line) { |
|
| 2002 | + echo ' +++ ', rtrim(substr($line, 4)); |
|
| 2003 | + } elseif (trim($line) != '---#') |
|
| 1894 | 2004 | { |
| 1895 | - if ($is_debug) |
|
| 1896 | - $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 2005 | + if ($is_debug) { |
|
| 2006 | + $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 2007 | + } |
|
| 1897 | 2008 | } |
| 1898 | 2009 | } |
| 1899 | 2010 | |
| 1900 | 2011 | if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep']) |
| 1901 | 2012 | { |
| 1902 | - if ($command_line) |
|
| 1903 | - echo ' * '; |
|
| 1904 | - else |
|
| 1905 | - $upcontext['actioned_items'][] = $last_step; |
|
| 2013 | + if ($command_line) { |
|
| 2014 | + echo ' * '; |
|
| 2015 | + } else { |
|
| 2016 | + $upcontext['actioned_items'][] = $last_step; |
|
| 2017 | + } |
|
| 1906 | 2018 | } |
| 1907 | 2019 | |
| 1908 | 2020 | // Small step - only if we're actually doing stuff. |
| 1909 | - if ($do_current) |
|
| 1910 | - nextSubstep(++$substep); |
|
| 1911 | - else |
|
| 1912 | - $substep++; |
|
| 1913 | - } |
|
| 1914 | - elseif ($type == '{') |
|
| 1915 | - $current_type = 'code'; |
|
| 1916 | - elseif ($type == '}') |
|
| 2021 | + if ($do_current) { |
|
| 2022 | + nextSubstep(++$substep); |
|
| 2023 | + } else { |
|
| 2024 | + $substep++; |
|
| 2025 | + } |
|
| 2026 | + } elseif ($type == '{') { |
|
| 2027 | + $current_type = 'code'; |
|
| 2028 | + } elseif ($type == '}') |
|
| 1917 | 2029 | { |
| 1918 | 2030 | $current_type = 'sql'; |
| 1919 | 2031 | |
@@ -1926,8 +2038,9 @@ discard block |
||
| 1926 | 2038 | if (eval('global $db_prefix, $modSettings, $smcFunc, $txt; ' . $current_data) === false) |
| 1927 | 2039 | { |
| 1928 | 2040 | $upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl; |
| 1929 | - if ($command_line) |
|
| 1930 | - echo $upcontext['error_message']; |
|
| 2041 | + if ($command_line) { |
|
| 2042 | + echo $upcontext['error_message']; |
|
| 2043 | + } |
|
| 1931 | 2044 | } |
| 1932 | 2045 | |
| 1933 | 2046 | // Done with code! |
@@ -2015,8 +2128,9 @@ discard block |
||
| 2015 | 2128 | $db_unbuffered = false; |
| 2016 | 2129 | |
| 2017 | 2130 | // Failure?! |
| 2018 | - if ($result !== false) |
|
| 2019 | - return $result; |
|
| 2131 | + if ($result !== false) { |
|
| 2132 | + return $result; |
|
| 2133 | + } |
|
| 2020 | 2134 | |
| 2021 | 2135 | $db_error_message = $smcFunc['db_error']($db_connection); |
| 2022 | 2136 | // If MySQL we do something more clever. |
@@ -2044,54 +2158,61 @@ discard block |
||
| 2044 | 2158 | { |
| 2045 | 2159 | mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`'); |
| 2046 | 2160 | $result = mysqli_query($db_connection, $string); |
| 2047 | - if ($result !== false) |
|
| 2048 | - return $result; |
|
| 2161 | + if ($result !== false) { |
|
| 2162 | + return $result; |
|
| 2163 | + } |
|
| 2049 | 2164 | } |
| 2050 | - } |
|
| 2051 | - elseif ($mysqli_errno == 2013) |
|
| 2165 | + } elseif ($mysqli_errno == 2013) |
|
| 2052 | 2166 | { |
| 2053 | 2167 | $db_connection = mysqli_connect($db_server, $db_user, $db_passwd); |
| 2054 | 2168 | mysqli_select_db($db_connection, $db_name); |
| 2055 | 2169 | if ($db_connection) |
| 2056 | 2170 | { |
| 2057 | 2171 | $result = mysqli_query($db_connection, $string); |
| 2058 | - if ($result !== false) |
|
| 2059 | - return $result; |
|
| 2172 | + if ($result !== false) { |
|
| 2173 | + return $result; |
|
| 2174 | + } |
|
| 2060 | 2175 | } |
| 2061 | 2176 | } |
| 2062 | 2177 | // Duplicate column name... should be okay ;). |
| 2063 | - elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) |
|
| 2064 | - return false; |
|
| 2178 | + elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) { |
|
| 2179 | + return false; |
|
| 2180 | + } |
|
| 2065 | 2181 | // Duplicate insert... make sure it's the proper type of query ;). |
| 2066 | - elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) |
|
| 2067 | - return false; |
|
| 2182 | + elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) { |
|
| 2183 | + return false; |
|
| 2184 | + } |
|
| 2068 | 2185 | // Creating an index on a non-existent column. |
| 2069 | - elseif ($mysqli_errno == 1072) |
|
| 2070 | - return false; |
|
| 2071 | - elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') |
|
| 2072 | - return false; |
|
| 2186 | + elseif ($mysqli_errno == 1072) { |
|
| 2187 | + return false; |
|
| 2188 | + } elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') { |
|
| 2189 | + return false; |
|
| 2190 | + } |
|
| 2073 | 2191 | } |
| 2074 | 2192 | // If a table already exists don't go potty. |
| 2075 | 2193 | else |
| 2076 | 2194 | { |
| 2077 | 2195 | if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U'))) |
| 2078 | 2196 | { |
| 2079 | - if (strpos($db_error_message, 'exist') !== false) |
|
| 2080 | - return true; |
|
| 2081 | - } |
|
| 2082 | - elseif (strpos(trim($string), 'INSERT ') !== false) |
|
| 2197 | + if (strpos($db_error_message, 'exist') !== false) { |
|
| 2198 | + return true; |
|
| 2199 | + } |
|
| 2200 | + } elseif (strpos(trim($string), 'INSERT ') !== false) |
|
| 2083 | 2201 | { |
| 2084 | - if (strpos($db_error_message, 'duplicate') !== false || $ignore_insert_error) |
|
| 2085 | - return true; |
|
| 2202 | + if (strpos($db_error_message, 'duplicate') !== false || $ignore_insert_error) { |
|
| 2203 | + return true; |
|
| 2204 | + } |
|
| 2086 | 2205 | } |
| 2087 | 2206 | } |
| 2088 | 2207 | |
| 2089 | 2208 | // Get the query string so we pass everything. |
| 2090 | 2209 | $query_string = ''; |
| 2091 | - foreach ($_GET as $k => $v) |
|
| 2092 | - $query_string .= ';' . $k . '=' . $v; |
|
| 2093 | - if (strlen($query_string) != 0) |
|
| 2094 | - $query_string = '?' . substr($query_string, 1); |
|
| 2210 | + foreach ($_GET as $k => $v) { |
|
| 2211 | + $query_string .= ';' . $k . '=' . $v; |
|
| 2212 | + } |
|
| 2213 | + if (strlen($query_string) != 0) { |
|
| 2214 | + $query_string = '?' . substr($query_string, 1); |
|
| 2215 | + } |
|
| 2095 | 2216 | |
| 2096 | 2217 | if ($command_line) |
| 2097 | 2218 | { |
@@ -2146,16 +2267,18 @@ discard block |
||
| 2146 | 2267 | { |
| 2147 | 2268 | $found |= 1; |
| 2148 | 2269 | // Do some checks on the data if we have it set. |
| 2149 | - if (isset($change['col_type'])) |
|
| 2150 | - $found &= $change['col_type'] === $column['type']; |
|
| 2151 | - if (isset($change['null_allowed'])) |
|
| 2152 | - $found &= $column['null'] == $change['null_allowed']; |
|
| 2153 | - if (isset($change['default'])) |
|
| 2154 | - $found &= $change['default'] === $column['default']; |
|
| 2270 | + if (isset($change['col_type'])) { |
|
| 2271 | + $found &= $change['col_type'] === $column['type']; |
|
| 2272 | + } |
|
| 2273 | + if (isset($change['null_allowed'])) { |
|
| 2274 | + $found &= $column['null'] == $change['null_allowed']; |
|
| 2275 | + } |
|
| 2276 | + if (isset($change['default'])) { |
|
| 2277 | + $found &= $change['default'] === $column['default']; |
|
| 2278 | + } |
|
| 2155 | 2279 | } |
| 2156 | 2280 | } |
| 2157 | - } |
|
| 2158 | - elseif ($change['type'] === 'index') |
|
| 2281 | + } elseif ($change['type'] === 'index') |
|
| 2159 | 2282 | { |
| 2160 | 2283 | $request = upgrade_query(' |
| 2161 | 2284 | SHOW INDEX |
@@ -2164,9 +2287,10 @@ discard block |
||
| 2164 | 2287 | { |
| 2165 | 2288 | $cur_index = array(); |
| 2166 | 2289 | |
| 2167 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2168 | - if ($row['Key_name'] === $change['name']) |
|
| 2290 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2291 | + if ($row['Key_name'] === $change['name']) |
|
| 2169 | 2292 | $cur_index[(int) $row['Seq_in_index']] = $row['Column_name']; |
| 2293 | + } |
|
| 2170 | 2294 | |
| 2171 | 2295 | ksort($cur_index, SORT_NUMERIC); |
| 2172 | 2296 | $found = array_values($cur_index) === $change['target_columns']; |
@@ -2176,14 +2300,17 @@ discard block |
||
| 2176 | 2300 | } |
| 2177 | 2301 | |
| 2178 | 2302 | // If we're trying to add and it's added, we're done. |
| 2179 | - if ($found && in_array($change['method'], array('add', 'change'))) |
|
| 2180 | - return true; |
|
| 2303 | + if ($found && in_array($change['method'], array('add', 'change'))) { |
|
| 2304 | + return true; |
|
| 2305 | + } |
|
| 2181 | 2306 | // Otherwise if we're removing and it wasn't found we're also done. |
| 2182 | - elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) |
|
| 2183 | - return true; |
|
| 2307 | + elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) { |
|
| 2308 | + return true; |
|
| 2309 | + } |
|
| 2184 | 2310 | // Otherwise is it just a test? |
| 2185 | - elseif ($is_test) |
|
| 2186 | - return false; |
|
| 2311 | + elseif ($is_test) { |
|
| 2312 | + return false; |
|
| 2313 | + } |
|
| 2187 | 2314 | |
| 2188 | 2315 | // Not found it yet? Bummer! How about we see if we're currently doing it? |
| 2189 | 2316 | $running = false; |
@@ -2194,8 +2321,9 @@ discard block |
||
| 2194 | 2321 | SHOW FULL PROCESSLIST'); |
| 2195 | 2322 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2196 | 2323 | { |
| 2197 | - if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) |
|
| 2198 | - $found = true; |
|
| 2324 | + if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) { |
|
| 2325 | + $found = true; |
|
| 2326 | + } |
|
| 2199 | 2327 | } |
| 2200 | 2328 | |
| 2201 | 2329 | // Can't find it? Then we need to run it fools! |
@@ -2207,8 +2335,9 @@ discard block |
||
| 2207 | 2335 | ALTER TABLE ' . $db_prefix . $change['table'] . ' |
| 2208 | 2336 | ' . $change['text'], true) !== false; |
| 2209 | 2337 | |
| 2210 | - if (!$success) |
|
| 2211 | - return false; |
|
| 2338 | + if (!$success) { |
|
| 2339 | + return false; |
|
| 2340 | + } |
|
| 2212 | 2341 | |
| 2213 | 2342 | // Return |
| 2214 | 2343 | $running = true; |
@@ -2250,8 +2379,9 @@ discard block |
||
| 2250 | 2379 | 'db_error_skip' => true, |
| 2251 | 2380 | ) |
| 2252 | 2381 | ); |
| 2253 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2254 | - die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
| 2382 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2383 | + die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
| 2384 | + } |
|
| 2255 | 2385 | $table_row = $smcFunc['db_fetch_assoc']($request); |
| 2256 | 2386 | $smcFunc['db_free_result']($request); |
| 2257 | 2387 | |
@@ -2273,18 +2403,19 @@ discard block |
||
| 2273 | 2403 | ) |
| 2274 | 2404 | ); |
| 2275 | 2405 | // No results? Just forget it all together. |
| 2276 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2277 | - unset($table_row['Collation']); |
|
| 2278 | - else |
|
| 2279 | - $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2406 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2407 | + unset($table_row['Collation']); |
|
| 2408 | + } else { |
|
| 2409 | + $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2410 | + } |
|
| 2280 | 2411 | $smcFunc['db_free_result']($request); |
| 2281 | 2412 | } |
| 2282 | 2413 | |
| 2283 | 2414 | if ($column_fix) |
| 2284 | 2415 | { |
| 2285 | 2416 | // Make sure there are no NULL's left. |
| 2286 | - if ($null_fix) |
|
| 2287 | - $smcFunc['db_query']('', ' |
|
| 2417 | + if ($null_fix) { |
|
| 2418 | + $smcFunc['db_query']('', ' |
|
| 2288 | 2419 | UPDATE {db_prefix}' . $change['table'] . ' |
| 2289 | 2420 | SET ' . $change['column'] . ' = {string:default} |
| 2290 | 2421 | WHERE ' . $change['column'] . ' IS NULL', |
@@ -2293,6 +2424,7 @@ discard block |
||
| 2293 | 2424 | 'db_error_skip' => true, |
| 2294 | 2425 | ) |
| 2295 | 2426 | ); |
| 2427 | + } |
|
| 2296 | 2428 | |
| 2297 | 2429 | // Do the actual alteration. |
| 2298 | 2430 | $smcFunc['db_query']('', ' |
@@ -2321,8 +2453,9 @@ discard block |
||
| 2321 | 2453 | } |
| 2322 | 2454 | |
| 2323 | 2455 | // Not a column we need to check on? |
| 2324 | - if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) |
|
| 2325 | - return; |
|
| 2456 | + if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) { |
|
| 2457 | + return; |
|
| 2458 | + } |
|
| 2326 | 2459 | |
| 2327 | 2460 | // Break it up you (six|seven). |
| 2328 | 2461 | $temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text'])); |
@@ -2341,13 +2474,13 @@ discard block |
||
| 2341 | 2474 | 'new_name' => $temp[2], |
| 2342 | 2475 | )); |
| 2343 | 2476 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
| 2344 | - if ($smcFunc['db_num_rows'] != 1) |
|
| 2345 | - return; |
|
| 2477 | + if ($smcFunc['db_num_rows'] != 1) { |
|
| 2478 | + return; |
|
| 2479 | + } |
|
| 2346 | 2480 | |
| 2347 | 2481 | list (, $current_type) = $smcFunc['db_fetch_assoc']($request); |
| 2348 | 2482 | $smcFunc['db_free_result']($request); |
| 2349 | - } |
|
| 2350 | - else |
|
| 2483 | + } else |
|
| 2351 | 2484 | { |
| 2352 | 2485 | // Do this the old fashion, sure method way. |
| 2353 | 2486 | $request = $smcFunc['db_query']('', ' |
@@ -2358,21 +2491,24 @@ discard block |
||
| 2358 | 2491 | )); |
| 2359 | 2492 | // Mayday! |
| 2360 | 2493 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
| 2361 | - if ($smcFunc['db_num_rows'] == 0) |
|
| 2362 | - return; |
|
| 2494 | + if ($smcFunc['db_num_rows'] == 0) { |
|
| 2495 | + return; |
|
| 2496 | + } |
|
| 2363 | 2497 | |
| 2364 | 2498 | // Oh where, oh where has my little field gone. Oh where can it be... |
| 2365 | - while ($row = $smcFunc['db_query']($request)) |
|
| 2366 | - if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
| 2499 | + while ($row = $smcFunc['db_query']($request)) { |
|
| 2500 | + if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
| 2367 | 2501 | { |
| 2368 | 2502 | $current_type = $row['Type']; |
| 2503 | + } |
|
| 2369 | 2504 | break; |
| 2370 | 2505 | } |
| 2371 | 2506 | } |
| 2372 | 2507 | |
| 2373 | 2508 | // If this doesn't match, the column may of been altered for a reason. |
| 2374 | - if (trim($current_type) != trim($temp[3])) |
|
| 2375 | - $temp[3] = $current_type; |
|
| 2509 | + if (trim($current_type) != trim($temp[3])) { |
|
| 2510 | + $temp[3] = $current_type; |
|
| 2511 | + } |
|
| 2376 | 2512 | |
| 2377 | 2513 | // Piece this back together. |
| 2378 | 2514 | $change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp)); |
@@ -2384,8 +2520,9 @@ discard block |
||
| 2384 | 2520 | global $start_time, $timeLimitThreshold, $command_line, $custom_warning; |
| 2385 | 2521 | global $step_progress, $is_debug, $upcontext; |
| 2386 | 2522 | |
| 2387 | - if ($_GET['substep'] < $substep) |
|
| 2388 | - $_GET['substep'] = $substep; |
|
| 2523 | + if ($_GET['substep'] < $substep) { |
|
| 2524 | + $_GET['substep'] = $substep; |
|
| 2525 | + } |
|
| 2389 | 2526 | |
| 2390 | 2527 | if ($command_line) |
| 2391 | 2528 | { |
@@ -2398,29 +2535,33 @@ discard block |
||
| 2398 | 2535 | } |
| 2399 | 2536 | |
| 2400 | 2537 | @set_time_limit(300); |
| 2401 | - if (function_exists('apache_reset_timeout')) |
|
| 2402 | - @apache_reset_timeout(); |
|
| 2538 | + if (function_exists('apache_reset_timeout')) { |
|
| 2539 | + @apache_reset_timeout(); |
|
| 2540 | + } |
|
| 2403 | 2541 | |
| 2404 | - if (time() - $start_time <= $timeLimitThreshold) |
|
| 2405 | - return; |
|
| 2542 | + if (time() - $start_time <= $timeLimitThreshold) { |
|
| 2543 | + return; |
|
| 2544 | + } |
|
| 2406 | 2545 | |
| 2407 | 2546 | // Do we have some custom step progress stuff? |
| 2408 | 2547 | if (!empty($step_progress)) |
| 2409 | 2548 | { |
| 2410 | 2549 | $upcontext['substep_progress'] = 0; |
| 2411 | 2550 | $upcontext['substep_progress_name'] = $step_progress['name']; |
| 2412 | - if ($step_progress['current'] > $step_progress['total']) |
|
| 2413 | - $upcontext['substep_progress'] = 99.9; |
|
| 2414 | - else |
|
| 2415 | - $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
| 2551 | + if ($step_progress['current'] > $step_progress['total']) { |
|
| 2552 | + $upcontext['substep_progress'] = 99.9; |
|
| 2553 | + } else { |
|
| 2554 | + $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
| 2555 | + } |
|
| 2416 | 2556 | |
| 2417 | 2557 | // Make it nicely rounded. |
| 2418 | 2558 | $upcontext['substep_progress'] = round($upcontext['substep_progress'], 1); |
| 2419 | 2559 | } |
| 2420 | 2560 | |
| 2421 | 2561 | // If this is XML we just exit right away! |
| 2422 | - if (isset($_GET['xml'])) |
|
| 2423 | - return upgradeExit(); |
|
| 2562 | + if (isset($_GET['xml'])) { |
|
| 2563 | + return upgradeExit(); |
|
| 2564 | + } |
|
| 2424 | 2565 | |
| 2425 | 2566 | // We're going to pause after this! |
| 2426 | 2567 | $upcontext['pause'] = true; |
@@ -2428,13 +2569,15 @@ discard block |
||
| 2428 | 2569 | $upcontext['query_string'] = ''; |
| 2429 | 2570 | foreach ($_GET as $k => $v) |
| 2430 | 2571 | { |
| 2431 | - if ($k != 'data' && $k != 'substep' && $k != 'step') |
|
| 2432 | - $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
| 2572 | + if ($k != 'data' && $k != 'substep' && $k != 'step') { |
|
| 2573 | + $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
| 2574 | + } |
|
| 2433 | 2575 | } |
| 2434 | 2576 | |
| 2435 | 2577 | // Custom warning? |
| 2436 | - if (!empty($custom_warning)) |
|
| 2437 | - $upcontext['custom_warning'] = $custom_warning; |
|
| 2578 | + if (!empty($custom_warning)) { |
|
| 2579 | + $upcontext['custom_warning'] = $custom_warning; |
|
| 2580 | + } |
|
| 2438 | 2581 | |
| 2439 | 2582 | upgradeExit(); |
| 2440 | 2583 | } |
@@ -2449,25 +2592,26 @@ discard block |
||
| 2449 | 2592 | ob_implicit_flush(true); |
| 2450 | 2593 | @set_time_limit(600); |
| 2451 | 2594 | |
| 2452 | - if (!isset($_SERVER['argv'])) |
|
| 2453 | - $_SERVER['argv'] = array(); |
|
| 2595 | + if (!isset($_SERVER['argv'])) { |
|
| 2596 | + $_SERVER['argv'] = array(); |
|
| 2597 | + } |
|
| 2454 | 2598 | $_GET['maint'] = 1; |
| 2455 | 2599 | |
| 2456 | 2600 | foreach ($_SERVER['argv'] as $i => $arg) |
| 2457 | 2601 | { |
| 2458 | - if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) |
|
| 2459 | - $_GET['lang'] = $match[1]; |
|
| 2460 | - elseif (preg_match('~^--path=(.+)$~', $arg) != 0) |
|
| 2461 | - continue; |
|
| 2462 | - elseif ($arg == '--no-maintenance') |
|
| 2463 | - $_GET['maint'] = 0; |
|
| 2464 | - elseif ($arg == '--debug') |
|
| 2465 | - $is_debug = true; |
|
| 2466 | - elseif ($arg == '--backup') |
|
| 2467 | - $_POST['backup'] = 1; |
|
| 2468 | - elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) |
|
| 2469 | - $_GET['conv'] = 1; |
|
| 2470 | - elseif ($i != 0) |
|
| 2602 | + if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) { |
|
| 2603 | + $_GET['lang'] = $match[1]; |
|
| 2604 | + } elseif (preg_match('~^--path=(.+)$~', $arg) != 0) { |
|
| 2605 | + continue; |
|
| 2606 | + } elseif ($arg == '--no-maintenance') { |
|
| 2607 | + $_GET['maint'] = 0; |
|
| 2608 | + } elseif ($arg == '--debug') { |
|
| 2609 | + $is_debug = true; |
|
| 2610 | + } elseif ($arg == '--backup') { |
|
| 2611 | + $_POST['backup'] = 1; |
|
| 2612 | + } elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) { |
|
| 2613 | + $_GET['conv'] = 1; |
|
| 2614 | + } elseif ($i != 0) |
|
| 2471 | 2615 | { |
| 2472 | 2616 | echo 'SMF Command-line Upgrader |
| 2473 | 2617 | Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]... |
@@ -2481,10 +2625,12 @@ discard block |
||
| 2481 | 2625 | } |
| 2482 | 2626 | } |
| 2483 | 2627 | |
| 2484 | - if (!php_version_check()) |
|
| 2485 | - print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
| 2486 | - if (!db_version_check()) |
|
| 2487 | - print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
| 2628 | + if (!php_version_check()) { |
|
| 2629 | + print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
| 2630 | + } |
|
| 2631 | + if (!db_version_check()) { |
|
| 2632 | + print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
| 2633 | + } |
|
| 2488 | 2634 | |
| 2489 | 2635 | // Do some checks to make sure they have proper privileges |
| 2490 | 2636 | db_extend('packages'); |
@@ -2499,34 +2645,39 @@ discard block |
||
| 2499 | 2645 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
| 2500 | 2646 | |
| 2501 | 2647 | // Sorry... we need CREATE, ALTER and DROP |
| 2502 | - if (!$create || !$alter || !$drop) |
|
| 2503 | - 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); |
|
| 2648 | + if (!$create || !$alter || !$drop) { |
|
| 2649 | + 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); |
|
| 2650 | + } |
|
| 2504 | 2651 | |
| 2505 | 2652 | $check = @file_exists($modSettings['theme_dir'] . '/index.template.php') |
| 2506 | 2653 | && @file_exists($sourcedir . '/QueryString.php') |
| 2507 | 2654 | && @file_exists($sourcedir . '/ManageBoards.php'); |
| 2508 | - if (!$check && !isset($modSettings['smfVersion'])) |
|
| 2509 | - print_error('Error: Some files are missing or out-of-date.', true); |
|
| 2655 | + if (!$check && !isset($modSettings['smfVersion'])) { |
|
| 2656 | + print_error('Error: Some files are missing or out-of-date.', true); |
|
| 2657 | + } |
|
| 2510 | 2658 | |
| 2511 | 2659 | // Do a quick version spot check. |
| 2512 | 2660 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
| 2513 | 2661 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
| 2514 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
| 2515 | - print_error('Error: Some files have not yet been updated properly.'); |
|
| 2662 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
| 2663 | + print_error('Error: Some files have not yet been updated properly.'); |
|
| 2664 | + } |
|
| 2516 | 2665 | |
| 2517 | 2666 | // Make sure Settings.php is writable. |
| 2518 | 2667 | quickFileWritable($boarddir . '/Settings.php'); |
| 2519 | - if (!is_writable($boarddir . '/Settings.php')) |
|
| 2520 | - print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
| 2668 | + if (!is_writable($boarddir . '/Settings.php')) { |
|
| 2669 | + print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
| 2670 | + } |
|
| 2521 | 2671 | |
| 2522 | 2672 | // Make sure Settings_bak.php is writable. |
| 2523 | 2673 | quickFileWritable($boarddir . '/Settings_bak.php'); |
| 2524 | - if (!is_writable($boarddir . '/Settings_bak.php')) |
|
| 2525 | - print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
| 2674 | + if (!is_writable($boarddir . '/Settings_bak.php')) { |
|
| 2675 | + print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
| 2676 | + } |
|
| 2526 | 2677 | |
| 2527 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
| 2528 | - print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
| 2529 | - elseif (isset($modSettings['agreement'])) |
|
| 2678 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
| 2679 | + print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
| 2680 | + } elseif (isset($modSettings['agreement'])) |
|
| 2530 | 2681 | { |
| 2531 | 2682 | $fp = fopen($boarddir . '/agreement.txt', 'w'); |
| 2532 | 2683 | fwrite($fp, $modSettings['agreement']); |
@@ -2536,36 +2687,42 @@ discard block |
||
| 2536 | 2687 | // Make sure Themes is writable. |
| 2537 | 2688 | quickFileWritable($modSettings['theme_dir']); |
| 2538 | 2689 | |
| 2539 | - if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) |
|
| 2540 | - print_error('Error: Unable to obtain write access to "Themes".'); |
|
| 2690 | + if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) { |
|
| 2691 | + print_error('Error: Unable to obtain write access to "Themes".'); |
|
| 2692 | + } |
|
| 2541 | 2693 | |
| 2542 | 2694 | // Make sure cache directory exists and is writable! |
| 2543 | 2695 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
| 2544 | - if (!file_exists($cachedir_temp)) |
|
| 2545 | - @mkdir($cachedir_temp); |
|
| 2696 | + if (!file_exists($cachedir_temp)) { |
|
| 2697 | + @mkdir($cachedir_temp); |
|
| 2698 | + } |
|
| 2546 | 2699 | |
| 2547 | 2700 | // Make sure the cache temp dir is writable. |
| 2548 | 2701 | quickFileWritable($cachedir_temp); |
| 2549 | 2702 | |
| 2550 | - if (!is_writable($cachedir_temp)) |
|
| 2551 | - print_error('Error: Unable to obtain write access to "cache".', true); |
|
| 2703 | + if (!is_writable($cachedir_temp)) { |
|
| 2704 | + print_error('Error: Unable to obtain write access to "cache".', true); |
|
| 2705 | + } |
|
| 2552 | 2706 | |
| 2553 | 2707 | // Make sure db_last_error.php is writable. |
| 2554 | 2708 | quickFileWritable($cachedir_temp . '/db_last_error.php'); |
| 2555 | - if (!is_writable($cachedir_temp . '/db_last_error.php')) |
|
| 2556 | - print_error('Error: Unable to obtain write access to "db_last_error.php".'); |
|
| 2709 | + if (!is_writable($cachedir_temp . '/db_last_error.php')) { |
|
| 2710 | + print_error('Error: Unable to obtain write access to "db_last_error.php".'); |
|
| 2711 | + } |
|
| 2557 | 2712 | |
| 2558 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
| 2559 | - print_error('Error: Unable to find language files!', true); |
|
| 2560 | - else |
|
| 2713 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
| 2714 | + print_error('Error: Unable to find language files!', true); |
|
| 2715 | + } else |
|
| 2561 | 2716 | { |
| 2562 | 2717 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
| 2563 | 2718 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 2564 | 2719 | |
| 2565 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 2566 | - print_error('Error: Language files out of date.', true); |
|
| 2567 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 2568 | - print_error('Error: Install language is missing for selected language.', true); |
|
| 2720 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 2721 | + print_error('Error: Language files out of date.', true); |
|
| 2722 | + } |
|
| 2723 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 2724 | + print_error('Error: Install language is missing for selected language.', true); |
|
| 2725 | + } |
|
| 2569 | 2726 | |
| 2570 | 2727 | // Otherwise include it! |
| 2571 | 2728 | require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
@@ -2585,8 +2742,9 @@ discard block |
||
| 2585 | 2742 | global $db_prefix, $db_type, $command_line, $support_js, $txt; |
| 2586 | 2743 | |
| 2587 | 2744 | // Done it already? |
| 2588 | - if (!empty($_POST['utf8_done'])) |
|
| 2589 | - return true; |
|
| 2745 | + if (!empty($_POST['utf8_done'])) { |
|
| 2746 | + return true; |
|
| 2747 | + } |
|
| 2590 | 2748 | |
| 2591 | 2749 | // First make sure they aren't already on UTF-8 before we go anywhere... |
| 2592 | 2750 | if ($db_type == 'postgresql' || ($db_character_set === 'utf8' && !empty($modSettings['global_character_set']) && $modSettings['global_character_set'] === 'UTF-8')) |
@@ -2599,8 +2757,7 @@ discard block |
||
| 2599 | 2757 | ); |
| 2600 | 2758 | |
| 2601 | 2759 | return true; |
| 2602 | - } |
|
| 2603 | - else |
|
| 2760 | + } else |
|
| 2604 | 2761 | { |
| 2605 | 2762 | $upcontext['page_title'] = $txt['converting_utf8']; |
| 2606 | 2763 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8'; |
@@ -2644,8 +2801,9 @@ discard block |
||
| 2644 | 2801 | ) |
| 2645 | 2802 | ); |
| 2646 | 2803 | $db_charsets = array(); |
| 2647 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2648 | - $db_charsets[] = $row['Charset']; |
|
| 2804 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2805 | + $db_charsets[] = $row['Charset']; |
|
| 2806 | + } |
|
| 2649 | 2807 | |
| 2650 | 2808 | $smcFunc['db_free_result']($request); |
| 2651 | 2809 | |
@@ -2681,13 +2839,15 @@ discard block |
||
| 2681 | 2839 | // If there's a fulltext index, we need to drop it first... |
| 2682 | 2840 | if ($request !== false || $smcFunc['db_num_rows']($request) != 0) |
| 2683 | 2841 | { |
| 2684 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2685 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 2842 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2843 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 2686 | 2844 | $upcontext['fulltext_index'][] = $row['Key_name']; |
| 2845 | + } |
|
| 2687 | 2846 | $smcFunc['db_free_result']($request); |
| 2688 | 2847 | |
| 2689 | - if (isset($upcontext['fulltext_index'])) |
|
| 2690 | - $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
| 2848 | + if (isset($upcontext['fulltext_index'])) { |
|
| 2849 | + $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
| 2850 | + } |
|
| 2691 | 2851 | } |
| 2692 | 2852 | |
| 2693 | 2853 | // Drop it and make a note... |
@@ -2877,8 +3037,9 @@ discard block |
||
| 2877 | 3037 | $replace = '%field%'; |
| 2878 | 3038 | |
| 2879 | 3039 | // Build a huge REPLACE statement... |
| 2880 | - foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) |
|
| 2881 | - $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
| 3040 | + foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) { |
|
| 3041 | + $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
| 3042 | + } |
|
| 2882 | 3043 | } |
| 2883 | 3044 | |
| 2884 | 3045 | // Get a list of table names ahead of time... This makes it easier to set our substep and such |
@@ -2888,9 +3049,10 @@ discard block |
||
| 2888 | 3049 | $upcontext['table_count'] = count($queryTables); |
| 2889 | 3050 | |
| 2890 | 3051 | // What ones have we already done? |
| 2891 | - foreach ($queryTables as $id => $table) |
|
| 2892 | - if ($id < $_GET['substep']) |
|
| 3052 | + foreach ($queryTables as $id => $table) { |
|
| 3053 | + if ($id < $_GET['substep']) |
|
| 2893 | 3054 | $upcontext['previous_tables'][] = $table; |
| 3055 | + } |
|
| 2894 | 3056 | |
| 2895 | 3057 | $upcontext['cur_table_num'] = $_GET['substep']; |
| 2896 | 3058 | $upcontext['cur_table_name'] = str_replace($db_prefix, '', $queryTables[$_GET['substep']]); |
@@ -2927,8 +3089,9 @@ discard block |
||
| 2927 | 3089 | nextSubstep($substep); |
| 2928 | 3090 | |
| 2929 | 3091 | // Just to make sure it doesn't time out. |
| 2930 | - if (function_exists('apache_reset_timeout')) |
|
| 2931 | - @apache_reset_timeout(); |
|
| 3092 | + if (function_exists('apache_reset_timeout')) { |
|
| 3093 | + @apache_reset_timeout(); |
|
| 3094 | + } |
|
| 2932 | 3095 | |
| 2933 | 3096 | $table_charsets = array(); |
| 2934 | 3097 | |
@@ -2951,8 +3114,9 @@ discard block |
||
| 2951 | 3114 | |
| 2952 | 3115 | // Build structure of columns to operate on organized by charset; only operate on columns not yet utf8 |
| 2953 | 3116 | if ($charset != 'utf8') { |
| 2954 | - if (!isset($table_charsets[$charset])) |
|
| 2955 | - $table_charsets[$charset] = array(); |
|
| 3117 | + if (!isset($table_charsets[$charset])) { |
|
| 3118 | + $table_charsets[$charset] = array(); |
|
| 3119 | + } |
|
| 2956 | 3120 | |
| 2957 | 3121 | $table_charsets[$charset][] = $column_info; |
| 2958 | 3122 | } |
@@ -2993,10 +3157,11 @@ discard block |
||
| 2993 | 3157 | if (isset($translation_tables[$upcontext['charset_detected']])) |
| 2994 | 3158 | { |
| 2995 | 3159 | $update = ''; |
| 2996 | - foreach ($table_charsets as $charset => $columns) |
|
| 2997 | - foreach ($columns as $column) |
|
| 3160 | + foreach ($table_charsets as $charset => $columns) { |
|
| 3161 | + foreach ($columns as $column) |
|
| 2998 | 3162 | $update .= ' |
| 2999 | 3163 | ' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ','; |
| 3164 | + } |
|
| 3000 | 3165 | |
| 3001 | 3166 | $smcFunc['db_query']('', ' |
| 3002 | 3167 | UPDATE {raw:table_name} |
@@ -3021,8 +3186,9 @@ discard block |
||
| 3021 | 3186 | // Now do the actual conversion (if still needed). |
| 3022 | 3187 | if ($charsets[$upcontext['charset_detected']] !== 'utf8') |
| 3023 | 3188 | { |
| 3024 | - if ($command_line) |
|
| 3025 | - echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
| 3189 | + if ($command_line) { |
|
| 3190 | + echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
| 3191 | + } |
|
| 3026 | 3192 | |
| 3027 | 3193 | $smcFunc['db_query']('', ' |
| 3028 | 3194 | ALTER TABLE {raw:table_name} |
@@ -3032,12 +3198,14 @@ discard block |
||
| 3032 | 3198 | ) |
| 3033 | 3199 | ); |
| 3034 | 3200 | |
| 3035 | - if ($command_line) |
|
| 3036 | - echo " done.\n"; |
|
| 3201 | + if ($command_line) { |
|
| 3202 | + echo " done.\n"; |
|
| 3203 | + } |
|
| 3037 | 3204 | } |
| 3038 | 3205 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 3039 | - if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count']) |
|
| 3040 | - return upgradeExit(); |
|
| 3206 | + if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count']) { |
|
| 3207 | + return upgradeExit(); |
|
| 3208 | + } |
|
| 3041 | 3209 | } |
| 3042 | 3210 | |
| 3043 | 3211 | $prev_charset = empty($translation_tables[$upcontext['charset_detected']]) ? $charsets[$upcontext['charset_detected']] : $translation_tables[$upcontext['charset_detected']]; |
@@ -3066,8 +3234,8 @@ discard block |
||
| 3066 | 3234 | ); |
| 3067 | 3235 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 3068 | 3236 | { |
| 3069 | - 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) |
|
| 3070 | - $smcFunc['db_query']('', ' |
|
| 3237 | + 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) { |
|
| 3238 | + $smcFunc['db_query']('', ' |
|
| 3071 | 3239 | UPDATE {db_prefix}log_actions |
| 3072 | 3240 | SET extra = {string:extra} |
| 3073 | 3241 | WHERE id_action = {int:current_action}', |
@@ -3076,6 +3244,7 @@ discard block |
||
| 3076 | 3244 | 'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4], |
| 3077 | 3245 | ) |
| 3078 | 3246 | ); |
| 3247 | + } |
|
| 3079 | 3248 | } |
| 3080 | 3249 | $smcFunc['db_free_result']($request); |
| 3081 | 3250 | |
@@ -3097,15 +3266,17 @@ discard block |
||
| 3097 | 3266 | // First thing's first - did we already do this? |
| 3098 | 3267 | if (!empty($modSettings['json_done'])) |
| 3099 | 3268 | { |
| 3100 | - if ($command_line) |
|
| 3101 | - return DeleteUpgrade(); |
|
| 3102 | - else |
|
| 3103 | - return true; |
|
| 3269 | + if ($command_line) { |
|
| 3270 | + return DeleteUpgrade(); |
|
| 3271 | + } else { |
|
| 3272 | + return true; |
|
| 3273 | + } |
|
| 3104 | 3274 | } |
| 3105 | 3275 | |
| 3106 | 3276 | // Done it already - js wise? |
| 3107 | - if (!empty($_POST['json_done'])) |
|
| 3108 | - return true; |
|
| 3277 | + if (!empty($_POST['json_done'])) { |
|
| 3278 | + return true; |
|
| 3279 | + } |
|
| 3109 | 3280 | |
| 3110 | 3281 | // List of tables affected by this function |
| 3111 | 3282 | // name => array('key', col1[,col2|true[,col3]]) |
@@ -3137,12 +3308,14 @@ discard block |
||
| 3137 | 3308 | $upcontext['cur_table_name'] = isset($keys[$_GET['substep']]) ? $keys[$_GET['substep']] : $keys[0]; |
| 3138 | 3309 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
| 3139 | 3310 | |
| 3140 | - foreach ($keys as $id => $table) |
|
| 3141 | - if ($id < $_GET['substep']) |
|
| 3311 | + foreach ($keys as $id => $table) { |
|
| 3312 | + if ($id < $_GET['substep']) |
|
| 3142 | 3313 | $upcontext['previous_tables'][] = $table; |
| 3314 | + } |
|
| 3143 | 3315 | |
| 3144 | - if ($command_line) |
|
| 3145 | - echo 'Converting data from serialize() to json_encode().'; |
|
| 3316 | + if ($command_line) { |
|
| 3317 | + echo 'Converting data from serialize() to json_encode().'; |
|
| 3318 | + } |
|
| 3146 | 3319 | |
| 3147 | 3320 | if (!$support_js || isset($_GET['xml'])) |
| 3148 | 3321 | { |
@@ -3182,8 +3355,9 @@ discard block |
||
| 3182 | 3355 | |
| 3183 | 3356 | // Loop through and fix these... |
| 3184 | 3357 | $new_settings = array(); |
| 3185 | - if ($command_line) |
|
| 3186 | - echo "\n" . 'Fixing some settings...'; |
|
| 3358 | + if ($command_line) { |
|
| 3359 | + echo "\n" . 'Fixing some settings...'; |
|
| 3360 | + } |
|
| 3187 | 3361 | |
| 3188 | 3362 | foreach ($serialized_settings as $var) |
| 3189 | 3363 | { |
@@ -3191,22 +3365,24 @@ discard block |
||
| 3191 | 3365 | { |
| 3192 | 3366 | // Attempt to unserialize the setting |
| 3193 | 3367 | $temp = @safe_unserialize($modSettings[$var]); |
| 3194 | - if (!$temp && $command_line) |
|
| 3195 | - echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
| 3196 | - elseif ($temp !== false) |
|
| 3197 | - $new_settings[$var] = json_encode($temp); |
|
| 3368 | + if (!$temp && $command_line) { |
|
| 3369 | + echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
| 3370 | + } elseif ($temp !== false) { |
|
| 3371 | + $new_settings[$var] = json_encode($temp); |
|
| 3372 | + } |
|
| 3198 | 3373 | } |
| 3199 | 3374 | } |
| 3200 | 3375 | |
| 3201 | 3376 | // Update everything at once |
| 3202 | - if (!function_exists('cache_put_data')) |
|
| 3203 | - require_once($sourcedir . '/Load.php'); |
|
| 3377 | + if (!function_exists('cache_put_data')) { |
|
| 3378 | + require_once($sourcedir . '/Load.php'); |
|
| 3379 | + } |
|
| 3204 | 3380 | updateSettings($new_settings, true); |
| 3205 | 3381 | |
| 3206 | - if ($command_line) |
|
| 3207 | - echo ' done.'; |
|
| 3208 | - } |
|
| 3209 | - elseif ($table == 'themes') |
|
| 3382 | + if ($command_line) { |
|
| 3383 | + echo ' done.'; |
|
| 3384 | + } |
|
| 3385 | + } elseif ($table == 'themes') |
|
| 3210 | 3386 | { |
| 3211 | 3387 | // Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point... |
| 3212 | 3388 | $query = $smcFunc['db_query']('', ' |
@@ -3225,10 +3401,11 @@ discard block |
||
| 3225 | 3401 | |
| 3226 | 3402 | if ($command_line) |
| 3227 | 3403 | { |
| 3228 | - if ($temp === false) |
|
| 3229 | - echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
| 3230 | - else |
|
| 3231 | - echo "\n" . 'Fixing admin preferences...'; |
|
| 3404 | + if ($temp === false) { |
|
| 3405 | + echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
| 3406 | + } else { |
|
| 3407 | + echo "\n" . 'Fixing admin preferences...'; |
|
| 3408 | + } |
|
| 3232 | 3409 | } |
| 3233 | 3410 | |
| 3234 | 3411 | if ($temp !== false) |
@@ -3250,15 +3427,15 @@ discard block |
||
| 3250 | 3427 | ) |
| 3251 | 3428 | ); |
| 3252 | 3429 | |
| 3253 | - if ($command_line) |
|
| 3254 | - echo ' done.'; |
|
| 3430 | + if ($command_line) { |
|
| 3431 | + echo ' done.'; |
|
| 3432 | + } |
|
| 3255 | 3433 | } |
| 3256 | 3434 | } |
| 3257 | 3435 | |
| 3258 | 3436 | $smcFunc['db_free_result']($query); |
| 3259 | 3437 | } |
| 3260 | - } |
|
| 3261 | - else |
|
| 3438 | + } else |
|
| 3262 | 3439 | { |
| 3263 | 3440 | // First item is always the key... |
| 3264 | 3441 | $key = $info[0]; |
@@ -3269,8 +3446,7 @@ discard block |
||
| 3269 | 3446 | { |
| 3270 | 3447 | $col_select = $info[1]; |
| 3271 | 3448 | $where = ' WHERE ' . $info[1] . ' != {empty}'; |
| 3272 | - } |
|
| 3273 | - else |
|
| 3449 | + } else |
|
| 3274 | 3450 | { |
| 3275 | 3451 | $col_select = implode(', ', $info); |
| 3276 | 3452 | } |
@@ -3303,8 +3479,7 @@ discard block |
||
| 3303 | 3479 | if ($temp === false && $command_line) |
| 3304 | 3480 | { |
| 3305 | 3481 | echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n"; |
| 3306 | - } |
|
| 3307 | - else |
|
| 3482 | + } else |
|
| 3308 | 3483 | { |
| 3309 | 3484 | $row[$col] = json_encode($temp); |
| 3310 | 3485 | |
@@ -3329,16 +3504,18 @@ discard block |
||
| 3329 | 3504 | } |
| 3330 | 3505 | } |
| 3331 | 3506 | |
| 3332 | - if ($command_line) |
|
| 3333 | - echo ' done.'; |
|
| 3507 | + if ($command_line) { |
|
| 3508 | + echo ' done.'; |
|
| 3509 | + } |
|
| 3334 | 3510 | |
| 3335 | 3511 | // Free up some memory... |
| 3336 | 3512 | $smcFunc['db_free_result']($query); |
| 3337 | 3513 | } |
| 3338 | 3514 | } |
| 3339 | 3515 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 3340 | - if (isset($_GET['xml'])) |
|
| 3341 | - return upgradeExit(); |
|
| 3516 | + if (isset($_GET['xml'])) { |
|
| 3517 | + return upgradeExit(); |
|
| 3518 | + } |
|
| 3342 | 3519 | } |
| 3343 | 3520 | |
| 3344 | 3521 | if ($command_line) |
@@ -3353,8 +3530,9 @@ discard block |
||
| 3353 | 3530 | |
| 3354 | 3531 | $_GET['substep'] = 0; |
| 3355 | 3532 | // Make sure we move on! |
| 3356 | - if ($command_line) |
|
| 3357 | - return DeleteUpgrade(); |
|
| 3533 | + if ($command_line) { |
|
| 3534 | + return DeleteUpgrade(); |
|
| 3535 | + } |
|
| 3358 | 3536 | |
| 3359 | 3537 | return true; |
| 3360 | 3538 | } |
@@ -3411,14 +3589,16 @@ discard block |
||
| 3411 | 3589 | global $upcontext, $txt, $settings; |
| 3412 | 3590 | |
| 3413 | 3591 | // Don't call me twice! |
| 3414 | - if (!empty($upcontext['chmod_called'])) |
|
| 3415 | - return; |
|
| 3592 | + if (!empty($upcontext['chmod_called'])) { |
|
| 3593 | + return; |
|
| 3594 | + } |
|
| 3416 | 3595 | |
| 3417 | 3596 | $upcontext['chmod_called'] = true; |
| 3418 | 3597 | |
| 3419 | 3598 | // Nothing? |
| 3420 | - if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) |
|
| 3421 | - return; |
|
| 3599 | + if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) { |
|
| 3600 | + return; |
|
| 3601 | + } |
|
| 3422 | 3602 | |
| 3423 | 3603 | // Was it a problem with Windows? |
| 3424 | 3604 | if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess') |
@@ -3450,11 +3630,12 @@ discard block |
||
| 3450 | 3630 | content.write(\'<div class="windowbg description">\n\t\t\t<h4>', $txt['upgrade_ftp_files'], '</h4>\n\t\t\t\'); |
| 3451 | 3631 | content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');'; |
| 3452 | 3632 | |
| 3453 | - if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') |
|
| 3454 | - echo ' |
|
| 3633 | + if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') { |
|
| 3634 | + echo ' |
|
| 3455 | 3635 | content.write(\'<hr>\n\t\t\t\'); |
| 3456 | 3636 | content.write(\'<p>', $txt['upgrade_ftp_shell'], '</p>\n\t\t\t\'); |
| 3457 | 3637 | content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');'; |
| 3638 | + } |
|
| 3458 | 3639 | |
| 3459 | 3640 | echo ' |
| 3460 | 3641 | content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\'); |
@@ -3462,16 +3643,18 @@ discard block |
||
| 3462 | 3643 | } |
| 3463 | 3644 | </script>'; |
| 3464 | 3645 | |
| 3465 | - if (!empty($upcontext['chmod']['ftp_error'])) |
|
| 3466 | - echo ' |
|
| 3646 | + if (!empty($upcontext['chmod']['ftp_error'])) { |
|
| 3647 | + echo ' |
|
| 3467 | 3648 | <div class="error_message red"> |
| 3468 | 3649 | <p>', $txt['upgrade_ftp_error'], '<p> |
| 3469 | 3650 | <code>', $upcontext['chmod']['ftp_error'], '</code> |
| 3470 | 3651 | </div>'; |
| 3652 | + } |
|
| 3471 | 3653 | |
| 3472 | - if (empty($upcontext['chmod_in_form'])) |
|
| 3473 | - echo ' |
|
| 3654 | + if (empty($upcontext['chmod_in_form'])) { |
|
| 3655 | + echo ' |
|
| 3474 | 3656 | <form action="', $upcontext['form_url'], '" method="post">'; |
| 3657 | + } |
|
| 3475 | 3658 | |
| 3476 | 3659 | echo ' |
| 3477 | 3660 | <dl class="settings"> |
@@ -3513,9 +3696,10 @@ discard block |
||
| 3513 | 3696 | <input type="submit" value="', $txt['ftp_connect'], '" class="button"> |
| 3514 | 3697 | </div>'; |
| 3515 | 3698 | |
| 3516 | - if (empty($upcontext['chmod_in_form'])) |
|
| 3517 | - echo ' |
|
| 3699 | + if (empty($upcontext['chmod_in_form'])) { |
|
| 3700 | + echo ' |
|
| 3518 | 3701 | </form>'; |
| 3702 | + } |
|
| 3519 | 3703 | |
| 3520 | 3704 | echo ' |
| 3521 | 3705 | </div><!-- .panel -->'; |
@@ -3579,9 +3763,10 @@ discard block |
||
| 3579 | 3763 | <h2>', $txt['upgrade_progress'], '</h2> |
| 3580 | 3764 | <ul>'; |
| 3581 | 3765 | |
| 3582 | - foreach ($upcontext['steps'] as $num => $step) |
|
| 3583 | - echo ' |
|
| 3766 | + foreach ($upcontext['steps'] as $num => $step) { |
|
| 3767 | + echo ' |
|
| 3584 | 3768 | <li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
| 3769 | + } |
|
| 3585 | 3770 | |
| 3586 | 3771 | echo ' |
| 3587 | 3772 | </ul> |
@@ -3594,13 +3779,14 @@ discard block |
||
| 3594 | 3779 | <span id="overall_text">', $upcontext['overall_percent'], '%</span> |
| 3595 | 3780 | </div>'; |
| 3596 | 3781 | |
| 3597 | - if (isset($upcontext['step_progress'])) |
|
| 3598 | - echo ' |
|
| 3782 | + if (isset($upcontext['step_progress'])) { |
|
| 3783 | + echo ' |
|
| 3599 | 3784 | <div id="progress_bar_step" class="progress_bar progress_yellow"> |
| 3600 | 3785 | <h3>', $txt['upgrade_step_progress'], '</h3> |
| 3601 | 3786 | <div id="step_progress" class="bar" style="width: ', $upcontext['step_progress'], '%;"></div> |
| 3602 | 3787 | <span id="step_text">', $upcontext['step_progress'], '%</span> |
| 3603 | 3788 | </div>'; |
| 3789 | + } |
|
| 3604 | 3790 | |
| 3605 | 3791 | echo ' |
| 3606 | 3792 | <div id="substep_bar_div" class="progress_bar" style="display: ', isset($upcontext['substep_progress']) ? '' : 'none', ';"> |
@@ -3631,31 +3817,35 @@ discard block |
||
| 3631 | 3817 | { |
| 3632 | 3818 | global $upcontext, $txt; |
| 3633 | 3819 | |
| 3634 | - if (!empty($upcontext['pause'])) |
|
| 3635 | - echo ' |
|
| 3820 | + if (!empty($upcontext['pause'])) { |
|
| 3821 | + echo ' |
|
| 3636 | 3822 | <em>', $txt['upgrade_incomplete'], '.</em><br> |
| 3637 | 3823 | |
| 3638 | 3824 | <h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2> |
| 3639 | 3825 | <h3> |
| 3640 | 3826 | ', $txt['upgrade_paused_overload'], ' |
| 3641 | 3827 | </h3>'; |
| 3828 | + } |
|
| 3642 | 3829 | |
| 3643 | - if (!empty($upcontext['custom_warning'])) |
|
| 3644 | - echo ' |
|
| 3830 | + if (!empty($upcontext['custom_warning'])) { |
|
| 3831 | + echo ' |
|
| 3645 | 3832 | <div class="errorbox"> |
| 3646 | 3833 | <h3>', $txt['upgrade_note'], '</h3> |
| 3647 | 3834 | ', $upcontext['custom_warning'], ' |
| 3648 | 3835 | </div>'; |
| 3836 | + } |
|
| 3649 | 3837 | |
| 3650 | 3838 | echo ' |
| 3651 | 3839 | <div class="righttext" style="margin: 1ex;">'; |
| 3652 | 3840 | |
| 3653 | - if (!empty($upcontext['continue'])) |
|
| 3654 | - echo ' |
|
| 3841 | + if (!empty($upcontext['continue'])) { |
|
| 3842 | + echo ' |
|
| 3655 | 3843 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button">'; |
| 3656 | - if (!empty($upcontext['skip'])) |
|
| 3657 | - echo ' |
|
| 3844 | + } |
|
| 3845 | + if (!empty($upcontext['skip'])) { |
|
| 3846 | + echo ' |
|
| 3658 | 3847 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button">'; |
| 3848 | + } |
|
| 3659 | 3849 | |
| 3660 | 3850 | echo ' |
| 3661 | 3851 | </div> |
@@ -3706,11 +3896,12 @@ discard block |
||
| 3706 | 3896 | echo '<', '?xml version="1.0" encoding="UTF-8"?', '> |
| 3707 | 3897 | <smf>'; |
| 3708 | 3898 | |
| 3709 | - if (!empty($upcontext['get_data'])) |
|
| 3710 | - foreach ($upcontext['get_data'] as $k => $v) |
|
| 3899 | + if (!empty($upcontext['get_data'])) { |
|
| 3900 | + foreach ($upcontext['get_data'] as $k => $v) |
|
| 3711 | 3901 | echo ' |
| 3712 | 3902 | <get key="', $k, '">', $v, '</get>'; |
| 3713 | -} |
|
| 3903 | + } |
|
| 3904 | + } |
|
| 3714 | 3905 | |
| 3715 | 3906 | function template_xml_below() |
| 3716 | 3907 | { |
@@ -3750,20 +3941,22 @@ discard block |
||
| 3750 | 3941 | template_chmod(); |
| 3751 | 3942 | |
| 3752 | 3943 | // For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade! |
| 3753 | - if ($upcontext['is_large_forum']) |
|
| 3754 | - echo ' |
|
| 3944 | + if ($upcontext['is_large_forum']) { |
|
| 3945 | + echo ' |
|
| 3755 | 3946 | <div class="errorbox"> |
| 3756 | 3947 | <h3>', $txt['upgrade_warning'], '</h3> |
| 3757 | 3948 | ', $txt['upgrade_warning_lots_data'], ' |
| 3758 | 3949 | </div>'; |
| 3950 | + } |
|
| 3759 | 3951 | |
| 3760 | 3952 | // A warning message? |
| 3761 | - if (!empty($upcontext['warning'])) |
|
| 3762 | - echo ' |
|
| 3953 | + if (!empty($upcontext['warning'])) { |
|
| 3954 | + echo ' |
|
| 3763 | 3955 | <div class="errorbox"> |
| 3764 | 3956 | <h3>', $txt['upgrade_warning'], '</h3> |
| 3765 | 3957 | ', $upcontext['warning'], ' |
| 3766 | 3958 | </div>'; |
| 3959 | + } |
|
| 3767 | 3960 | |
| 3768 | 3961 | // Paths are incorrect? |
| 3769 | 3962 | echo ' |
@@ -3794,16 +3987,18 @@ discard block |
||
| 3794 | 3987 | <p>', sprintf($txt[$agoTxt], $ago_seconds, $ago_minutes, $ago_hours), '</p> |
| 3795 | 3988 | <p>', sprintf($txt[$updatedTxt], $updated_seconds, $updated_minutes, $updated_hours), '</p>'; |
| 3796 | 3989 | |
| 3797 | - if ($updated < 600) |
|
| 3798 | - echo ' |
|
| 3990 | + if ($updated < 600) { |
|
| 3991 | + echo ' |
|
| 3799 | 3992 | <p>', $txt['upgrade_run_script'], ' ', $upcontext['user']['name'],' ', $txt['upgrade_run_script2'], '</p>'; |
| 3993 | + } |
|
| 3800 | 3994 | |
| 3801 | - if ($updated > $upcontext['inactive_timeout']) |
|
| 3802 | - echo ' |
|
| 3995 | + if ($updated > $upcontext['inactive_timeout']) { |
|
| 3996 | + echo ' |
|
| 3803 | 3997 | <p>',$txt['upgrade_run'], '</p>'; |
| 3804 | - else |
|
| 3805 | - echo ' |
|
| 3998 | + } else { |
|
| 3999 | + echo ' |
|
| 3806 | 4000 | <p>', $txt['upgrade_script_timeout'], ' ', $upcontext['user']['name'], ' ', $txt['upgrade_script_timeout2'], ' ', ($upcontext['inactive_timeout'] > 120 ? round($upcontext['inactive_timeout'] / 60, 1) . ' minutes!' : $upcontext['inactive_timeout'] . ' seconds!'), '</p>'; |
| 4001 | + } |
|
| 3807 | 4002 | |
| 3808 | 4003 | echo ' |
| 3809 | 4004 | </div>'; |
@@ -3819,9 +4014,10 @@ discard block |
||
| 3819 | 4014 | <dd> |
| 3820 | 4015 | <input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', '>'; |
| 3821 | 4016 | |
| 3822 | - if (!empty($upcontext['username_incorrect'])) |
|
| 3823 | - echo ' |
|
| 4017 | + if (!empty($upcontext['username_incorrect'])) { |
|
| 4018 | + echo ' |
|
| 3824 | 4019 | <div class="smalltext red">', $txt['upgrade_wrong_username'], '</div>'; |
| 4020 | + } |
|
| 3825 | 4021 | |
| 3826 | 4022 | echo ' |
| 3827 | 4023 | </dd> |
@@ -3832,9 +4028,10 @@ discard block |
||
| 3832 | 4028 | <input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', '> |
| 3833 | 4029 | <input type="hidden" name="hash_passwrd" value="">'; |
| 3834 | 4030 | |
| 3835 | - if (!empty($upcontext['password_failed'])) |
|
| 3836 | - echo ' |
|
| 4031 | + if (!empty($upcontext['password_failed'])) { |
|
| 4032 | + echo ' |
|
| 3837 | 4033 | <div class="smalltext red">', $txt['upgrade_wrong_password'], '</div>'; |
| 4034 | + } |
|
| 3838 | 4035 | |
| 3839 | 4036 | echo ' |
| 3840 | 4037 | </dd>'; |
@@ -3902,12 +4099,13 @@ discard block |
||
| 3902 | 4099 | <form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">'; |
| 3903 | 4100 | |
| 3904 | 4101 | // Warning message? |
| 3905 | - if (!empty($upcontext['upgrade_options_warning'])) |
|
| 3906 | - echo ' |
|
| 4102 | + if (!empty($upcontext['upgrade_options_warning'])) { |
|
| 4103 | + echo ' |
|
| 3907 | 4104 | <div class="errorbox"> |
| 3908 | 4105 | <h3>', $txt['upgrade_warning'] ,'</h3> |
| 3909 | 4106 | ', $upcontext['upgrade_options_warning'], ' |
| 3910 | 4107 | </div>'; |
| 4108 | + } |
|
| 3911 | 4109 | |
| 3912 | 4110 | echo ' |
| 3913 | 4111 | <ul class="upgrade_settings"> |
@@ -3936,12 +4134,13 @@ discard block |
||
| 3936 | 4134 | <label for="empty_error">', $txt['upgrade_empty_errlog'], '</label> |
| 3937 | 4135 | </li>'; |
| 3938 | 4136 | |
| 3939 | - if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) |
|
| 3940 | - echo ' |
|
| 4137 | + if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) { |
|
| 4138 | + echo ' |
|
| 3941 | 4139 | <li> |
| 3942 | 4140 | <input type="checkbox" name="delete_karma" id="delete_karma" value="1"> |
| 3943 | 4141 | <label for="delete_karma">', $txt['upgrade_delete_karma'], '</label> |
| 3944 | 4142 | </li>'; |
| 4143 | + } |
|
| 3945 | 4144 | |
| 3946 | 4145 | echo ' |
| 3947 | 4146 | <li> |
@@ -3975,10 +4174,11 @@ discard block |
||
| 3975 | 4174 | </div>'; |
| 3976 | 4175 | |
| 3977 | 4176 | // Dont any tables so far? |
| 3978 | - if (!empty($upcontext['previous_tables'])) |
|
| 3979 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4177 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4178 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 3980 | 4179 | echo ' |
| 3981 | 4180 | <br>', $txt['upgrade_completed_table'], ' "', $table, '".'; |
| 4181 | + } |
|
| 3982 | 4182 | |
| 3983 | 4183 | echo ' |
| 3984 | 4184 | <h3 id="current_tab"> |
@@ -4017,12 +4217,13 @@ discard block |
||
| 4017 | 4217 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4018 | 4218 | |
| 4019 | 4219 | // If debug flood the screen. |
| 4020 | - if ($is_debug) |
|
| 4021 | - echo ' |
|
| 4220 | + if ($is_debug) { |
|
| 4221 | + echo ' |
|
| 4022 | 4222 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 4023 | 4223 | |
| 4024 | 4224 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4025 | 4225 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4226 | + } |
|
| 4026 | 4227 | |
| 4027 | 4228 | echo ' |
| 4028 | 4229 | // Get the next update... |
@@ -4055,8 +4256,9 @@ discard block |
||
| 4055 | 4256 | { |
| 4056 | 4257 | global $upcontext, $support_js, $is_debug, $timeLimitThreshold, $txt; |
| 4057 | 4258 | |
| 4058 | - if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) |
|
| 4059 | - $is_debug = true; |
|
| 4259 | + if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) { |
|
| 4260 | + $is_debug = true; |
|
| 4261 | + } |
|
| 4060 | 4262 | |
| 4061 | 4263 | echo ' |
| 4062 | 4264 | <h3>', $txt['upgrade_db_changes'], '</h3> |
@@ -4071,8 +4273,9 @@ discard block |
||
| 4071 | 4273 | { |
| 4072 | 4274 | foreach ($upcontext['actioned_items'] as $num => $item) |
| 4073 | 4275 | { |
| 4074 | - if ($num != 0) |
|
| 4075 | - echo ' Successful!'; |
|
| 4276 | + if ($num != 0) { |
|
| 4277 | + echo ' Successful!'; |
|
| 4278 | + } |
|
| 4076 | 4279 | echo '<br>' . $item; |
| 4077 | 4280 | } |
| 4078 | 4281 | |
@@ -4087,20 +4290,20 @@ discard block |
||
| 4087 | 4290 | $seconds = intval($active % 60); |
| 4088 | 4291 | |
| 4089 | 4292 | echo '', sprintf($txt['upgrade_success_time_db'], $seconds, $minutes, $hours), '<br>'; |
| 4293 | + } else { |
|
| 4294 | + echo '', $txt['upgrade_success'], '<br>'; |
|
| 4090 | 4295 | } |
| 4091 | - else |
|
| 4092 | - echo '', $txt['upgrade_success'], '<br>'; |
|
| 4093 | 4296 | |
| 4094 | 4297 | echo ' |
| 4095 | 4298 | <p id="commess">', $txt['upgrade_db_complete'], '</p>'; |
| 4096 | 4299 | } |
| 4097 | - } |
|
| 4098 | - else |
|
| 4300 | + } else |
|
| 4099 | 4301 | { |
| 4100 | 4302 | // Tell them how many files we have in total. |
| 4101 | - if ($upcontext['file_count'] > 1) |
|
| 4102 | - echo ' |
|
| 4303 | + if ($upcontext['file_count'] > 1) { |
|
| 4304 | + echo ' |
|
| 4103 | 4305 | <strong id="info1">', $txt['upgrade_script'], ' <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>'; |
| 4306 | + } |
|
| 4104 | 4307 | |
| 4105 | 4308 | echo ' |
| 4106 | 4309 | <h3 id="info2"> |
@@ -4120,10 +4323,10 @@ discard block |
||
| 4120 | 4323 | |
| 4121 | 4324 | echo ' |
| 4122 | 4325 | <p id="upgradeCompleted">', sprintf($txt['upgrade_success_time_db'], $seconds, $minutes, $hours), '</p>'; |
| 4123 | - } |
|
| 4124 | - else |
|
| 4125 | - echo ' |
|
| 4326 | + } else { |
|
| 4327 | + echo ' |
|
| 4126 | 4328 | <p id="upgradeCompleted"></p>'; |
| 4329 | + } |
|
| 4127 | 4330 | |
| 4128 | 4331 | echo ' |
| 4129 | 4332 | <div id="debug_section"> |
@@ -4159,9 +4362,10 @@ discard block |
||
| 4159 | 4362 | var getData = ""; |
| 4160 | 4363 | var debugItems = ', $upcontext['debug_items'], ';'; |
| 4161 | 4364 | |
| 4162 | - if ($is_debug) |
|
| 4163 | - echo ' |
|
| 4365 | + if ($is_debug) { |
|
| 4366 | + echo ' |
|
| 4164 | 4367 | var upgradeStartTime = ' . $upcontext['started'] . ';'; |
| 4368 | + } |
|
| 4165 | 4369 | |
| 4166 | 4370 | echo ' |
| 4167 | 4371 | function getNextItem() |
@@ -4201,9 +4405,10 @@ discard block |
||
| 4201 | 4405 | document.getElementById("error_block").style.display = ""; |
| 4202 | 4406 | setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));'; |
| 4203 | 4407 | |
| 4204 | - if ($is_debug) |
|
| 4205 | - echo ' |
|
| 4408 | + if ($is_debug) { |
|
| 4409 | + echo ' |
|
| 4206 | 4410 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span class="red">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
| 4411 | + } |
|
| 4207 | 4412 | |
| 4208 | 4413 | echo ' |
| 4209 | 4414 | } |
@@ -4224,9 +4429,10 @@ discard block |
||
| 4224 | 4429 | document.getElementById("error_block").style.display = ""; |
| 4225 | 4430 | setInnerHTML(document.getElementById("error_message"), "', $txt['upgrade_loop'], '" + sDebugName);'; |
| 4226 | 4431 | |
| 4227 | - if ($is_debug) |
|
| 4228 | - echo ' |
|
| 4432 | + if ($is_debug) { |
|
| 4433 | + echo ' |
|
| 4229 | 4434 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span class="red">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
| 4435 | + } |
|
| 4230 | 4436 | |
| 4231 | 4437 | echo ' |
| 4232 | 4438 | } |
@@ -4284,8 +4490,8 @@ discard block |
||
| 4284 | 4490 | {'; |
| 4285 | 4491 | |
| 4286 | 4492 | // Database Changes, tell us how much time we spen to do this. If this gets updated via JS. |
| 4287 | - if ($is_debug) |
|
| 4288 | - echo ' |
|
| 4493 | + if ($is_debug) { |
|
| 4494 | + echo ' |
|
| 4289 | 4495 | document.getElementById(\'debug_section\').style.display = "none"; |
| 4290 | 4496 | |
| 4291 | 4497 | var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue); |
@@ -4300,6 +4506,7 @@ discard block |
||
| 4300 | 4506 | completedTxt = completedTxt.replace("%1$d", diffSeconds).replace("%2$d", diffMinutes).replace("%3$d", diffHours); |
| 4301 | 4507 | console.log(completedTxt, upgradeFinishedTime, diffTime, diffHours, diffMinutes, diffSeconds); |
| 4302 | 4508 | setInnerHTML(document.getElementById("upgradeCompleted"), completedTxt);'; |
| 4509 | + } |
|
| 4303 | 4510 | |
| 4304 | 4511 | echo ' |
| 4305 | 4512 | |
@@ -4307,9 +4514,10 @@ discard block |
||
| 4307 | 4514 | document.getElementById(\'contbutt\').disabled = 0; |
| 4308 | 4515 | document.getElementById(\'database_done\').value = 1;'; |
| 4309 | 4516 | |
| 4310 | - if ($upcontext['file_count'] > 1) |
|
| 4311 | - echo ' |
|
| 4517 | + if ($upcontext['file_count'] > 1) { |
|
| 4518 | + echo ' |
|
| 4312 | 4519 | document.getElementById(\'info1\').style.display = "none";'; |
| 4520 | + } |
|
| 4313 | 4521 | |
| 4314 | 4522 | echo ' |
| 4315 | 4523 | document.getElementById(\'info2\').style.display = "none"; |
@@ -4322,9 +4530,10 @@ discard block |
||
| 4322 | 4530 | lastItem = 0; |
| 4323 | 4531 | prevFile = curFile;'; |
| 4324 | 4532 | |
| 4325 | - if ($is_debug) |
|
| 4326 | - echo ' |
|
| 4533 | + if ($is_debug) { |
|
| 4534 | + echo ' |
|
| 4327 | 4535 | setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');'; |
| 4536 | + } |
|
| 4328 | 4537 | |
| 4329 | 4538 | echo ' |
| 4330 | 4539 | getNextItem(); |
@@ -4332,8 +4541,8 @@ discard block |
||
| 4332 | 4541 | }'; |
| 4333 | 4542 | |
| 4334 | 4543 | // If debug scroll the screen. |
| 4335 | - if ($is_debug) |
|
| 4336 | - echo ' |
|
| 4544 | + if ($is_debug) { |
|
| 4545 | + echo ' |
|
| 4337 | 4546 | if (iLastSubStepProgress == -1) |
| 4338 | 4547 | { |
| 4339 | 4548 | // Give it consistent dots. |
@@ -4352,6 +4561,7 @@ discard block |
||
| 4352 | 4561 | |
| 4353 | 4562 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4354 | 4563 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4564 | + } |
|
| 4355 | 4565 | |
| 4356 | 4566 | echo ' |
| 4357 | 4567 | // Update the page. |
@@ -4412,9 +4622,10 @@ discard block |
||
| 4412 | 4622 | }'; |
| 4413 | 4623 | |
| 4414 | 4624 | // Start things off assuming we've not errored. |
| 4415 | - if (empty($upcontext['error_message'])) |
|
| 4416 | - echo ' |
|
| 4625 | + if (empty($upcontext['error_message'])) { |
|
| 4626 | + echo ' |
|
| 4417 | 4627 | getNextItem();'; |
| 4628 | + } |
|
| 4418 | 4629 | |
| 4419 | 4630 | echo ' |
| 4420 | 4631 | //# sourceURL=dynamicScript-dbch.js |
@@ -4432,18 +4643,21 @@ discard block |
||
| 4432 | 4643 | <item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item> |
| 4433 | 4644 | <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>'; |
| 4434 | 4645 | |
| 4435 | - if (!empty($upcontext['error_message'])) |
|
| 4436 | - echo ' |
|
| 4646 | + if (!empty($upcontext['error_message'])) { |
|
| 4647 | + echo ' |
|
| 4437 | 4648 | <error>', $upcontext['error_message'], '</error>'; |
| 4649 | + } |
|
| 4438 | 4650 | |
| 4439 | - if (!empty($upcontext['error_string'])) |
|
| 4440 | - echo ' |
|
| 4651 | + if (!empty($upcontext['error_string'])) { |
|
| 4652 | + echo ' |
|
| 4441 | 4653 | <sql>', $upcontext['error_string'], '</sql>'; |
| 4654 | + } |
|
| 4442 | 4655 | |
| 4443 | - if ($is_debug) |
|
| 4444 | - echo ' |
|
| 4656 | + if ($is_debug) { |
|
| 4657 | + echo ' |
|
| 4445 | 4658 | <curtime>', time(), '</curtime>'; |
| 4446 | -} |
|
| 4659 | + } |
|
| 4660 | + } |
|
| 4447 | 4661 | |
| 4448 | 4662 | // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications.... |
| 4449 | 4663 | function template_convert_utf8() |
@@ -4460,10 +4674,11 @@ discard block |
||
| 4460 | 4674 | </div>'; |
| 4461 | 4675 | |
| 4462 | 4676 | // Done any tables so far? |
| 4463 | - if (!empty($upcontext['previous_tables'])) |
|
| 4464 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4677 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4678 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4465 | 4679 | echo ' |
| 4466 | 4680 | <br>', $txt['upgrade_completed_table'], ' "', $table, '".'; |
| 4681 | + } |
|
| 4467 | 4682 | |
| 4468 | 4683 | echo ' |
| 4469 | 4684 | <h3 id="current_tab"> |
@@ -4471,9 +4686,10 @@ discard block |
||
| 4471 | 4686 | </h3>'; |
| 4472 | 4687 | |
| 4473 | 4688 | // If we dropped their index, let's let them know |
| 4474 | - if ($upcontext['dropping_index']) |
|
| 4475 | - echo ' |
|
| 4689 | + if ($upcontext['dropping_index']) { |
|
| 4690 | + echo ' |
|
| 4476 | 4691 | <p id="indexmsg" style="font-weight: bold; font-style: italic; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">', $txt['upgrade_fulltext'], '</p>'; |
| 4692 | + } |
|
| 4477 | 4693 | |
| 4478 | 4694 | // Completion notification |
| 4479 | 4695 | echo ' |
@@ -4510,12 +4726,13 @@ discard block |
||
| 4510 | 4726 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4511 | 4727 | |
| 4512 | 4728 | // If debug flood the screen. |
| 4513 | - if ($is_debug) |
|
| 4514 | - echo ' |
|
| 4729 | + if ($is_debug) { |
|
| 4730 | + echo ' |
|
| 4515 | 4731 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 4516 | 4732 | |
| 4517 | 4733 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4518 | 4734 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4735 | + } |
|
| 4519 | 4736 | |
| 4520 | 4737 | echo ' |
| 4521 | 4738 | // Get the next update... |
@@ -4561,10 +4778,11 @@ discard block |
||
| 4561 | 4778 | </div>'; |
| 4562 | 4779 | |
| 4563 | 4780 | // Dont any tables so far? |
| 4564 | - if (!empty($upcontext['previous_tables'])) |
|
| 4565 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4781 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4782 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4566 | 4783 | echo ' |
| 4567 | 4784 | <br>', $txt['upgrade_completed_table'], ' "', $table, '".'; |
| 4785 | + } |
|
| 4568 | 4786 | |
| 4569 | 4787 | echo ' |
| 4570 | 4788 | <h3 id="current_tab"> |
@@ -4573,9 +4791,10 @@ discard block |
||
| 4573 | 4791 | <p id="commess" style="display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">', $txt['upgrade_json_completed'], '</p>'; |
| 4574 | 4792 | |
| 4575 | 4793 | // Try to make sure substep was reset. |
| 4576 | - if ($upcontext['cur_table_num'] == $upcontext['table_count']) |
|
| 4577 | - echo ' |
|
| 4794 | + if ($upcontext['cur_table_num'] == $upcontext['table_count']) { |
|
| 4795 | + echo ' |
|
| 4578 | 4796 | <input type="hidden" name="substep" id="substep" value="0">'; |
| 4797 | + } |
|
| 4579 | 4798 | |
| 4580 | 4799 | // Continue please! |
| 4581 | 4800 | $upcontext['continue'] = $support_js ? 2 : 1; |
@@ -4608,12 +4827,13 @@ discard block |
||
| 4608 | 4827 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4609 | 4828 | |
| 4610 | 4829 | // If debug flood the screen. |
| 4611 | - if ($is_debug) |
|
| 4612 | - echo ' |
|
| 4830 | + if ($is_debug) { |
|
| 4831 | + echo ' |
|
| 4613 | 4832 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>', $txt['upgrade_completed_table'], ' "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 4614 | 4833 | |
| 4615 | 4834 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4616 | 4835 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4836 | + } |
|
| 4617 | 4837 | |
| 4618 | 4838 | echo ' |
| 4619 | 4839 | // Get the next update... |
@@ -4649,8 +4869,8 @@ discard block |
||
| 4649 | 4869 | <h3>', $txt['upgrade_done'], ' <a href="', $boardurl, '/index.php">', $txt['upgrade_done2'], '</a>. ', $txt['upgrade_done3'], '</h3> |
| 4650 | 4870 | <form action="', $boardurl, '/index.php">'; |
| 4651 | 4871 | |
| 4652 | - if (!empty($upcontext['can_delete_script'])) |
|
| 4653 | - echo ' |
|
| 4872 | + if (!empty($upcontext['can_delete_script'])) { |
|
| 4873 | + echo ' |
|
| 4654 | 4874 | <label> |
| 4655 | 4875 | <input type="checkbox" id="delete_self" onclick="doTheDelete(this);"> ', $txt['upgrade_delete_now'], ' |
| 4656 | 4876 | </label> |
@@ -4664,6 +4884,7 @@ discard block |
||
| 4664 | 4884 | } |
| 4665 | 4885 | </script> |
| 4666 | 4886 | <img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>'; |
| 4887 | + } |
|
| 4667 | 4888 | |
| 4668 | 4889 | // Show Upgrade time in debug mode when we completed the upgrade process totatly |
| 4669 | 4890 | if ($is_debug) |
@@ -4673,12 +4894,13 @@ discard block |
||
| 4673 | 4894 | $minutes = intval(($active / 60) % 60); |
| 4674 | 4895 | $seconds = intval($active % 60); |
| 4675 | 4896 | |
| 4676 | - if ($hours > 0) |
|
| 4677 | - echo '', sprintf($txt['upgrade_completed_time_hms'], $seconds, $minutes, $hours), ''; |
|
| 4678 | - elseif ($minutes > 0) |
|
| 4679 | - echo '', sprintf($txt['upgrade_completed_time_ms'], $seconds, $minutes), ''; |
|
| 4680 | - elseif ($seconds > 0) |
|
| 4681 | - echo '', sprintf($txt['upgrade_completed_time_s'], $seconds), ''; |
|
| 4897 | + if ($hours > 0) { |
|
| 4898 | + echo '', sprintf($txt['upgrade_completed_time_hms'], $seconds, $minutes, $hours), ''; |
|
| 4899 | + } elseif ($minutes > 0) { |
|
| 4900 | + echo '', sprintf($txt['upgrade_completed_time_ms'], $seconds, $minutes), ''; |
|
| 4901 | + } elseif ($seconds > 0) { |
|
| 4902 | + echo '', sprintf($txt['upgrade_completed_time_s'], $seconds), ''; |
|
| 4903 | + } |
|
| 4682 | 4904 | } |
| 4683 | 4905 | |
| 4684 | 4906 | echo ' |
@@ -4708,8 +4930,9 @@ discard block |
||
| 4708 | 4930 | |
| 4709 | 4931 | $current_substep = $_GET['substep']; |
| 4710 | 4932 | |
| 4711 | - if (empty($_GET['a'])) |
|
| 4712 | - $_GET['a'] = 0; |
|
| 4933 | + if (empty($_GET['a'])) { |
|
| 4934 | + $_GET['a'] = 0; |
|
| 4935 | + } |
|
| 4713 | 4936 | $step_progress['name'] = 'Converting ips'; |
| 4714 | 4937 | $step_progress['current'] = $_GET['a']; |
| 4715 | 4938 | |
@@ -4752,16 +4975,19 @@ discard block |
||
| 4752 | 4975 | 'empty' => '', |
| 4753 | 4976 | 'limit' => $limit, |
| 4754 | 4977 | )); |
| 4755 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 4756 | - $arIp[] = $row[$oldCol]; |
|
| 4978 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 4979 | + $arIp[] = $row[$oldCol]; |
|
| 4980 | + } |
|
| 4757 | 4981 | $smcFunc['db_free_result']($request); |
| 4758 | 4982 | |
| 4759 | 4983 | // Special case, null ip could keep us in a loop. |
| 4760 | - if (is_null($arIp[0])) |
|
| 4761 | - unset($arIp[0]); |
|
| 4984 | + if (is_null($arIp[0])) { |
|
| 4985 | + unset($arIp[0]); |
|
| 4986 | + } |
|
| 4762 | 4987 | |
| 4763 | - if (empty($arIp)) |
|
| 4764 | - $is_done = true; |
|
| 4988 | + if (empty($arIp)) { |
|
| 4989 | + $is_done = true; |
|
| 4990 | + } |
|
| 4765 | 4991 | |
| 4766 | 4992 | $updates = array(); |
| 4767 | 4993 | $cases = array(); |
@@ -4770,16 +4996,18 @@ discard block |
||
| 4770 | 4996 | { |
| 4771 | 4997 | $arIp[$i] = trim($arIp[$i]); |
| 4772 | 4998 | |
| 4773 | - if (empty($arIp[$i])) |
|
| 4774 | - continue; |
|
| 4999 | + if (empty($arIp[$i])) { |
|
| 5000 | + continue; |
|
| 5001 | + } |
|
| 4775 | 5002 | |
| 4776 | 5003 | $updates['ip' . $i] = $arIp[$i]; |
| 4777 | 5004 | $cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}'; |
| 4778 | 5005 | |
| 4779 | 5006 | if ($setSize > 0 && $i % $setSize === 0) |
| 4780 | 5007 | { |
| 4781 | - if (count($updates) == 1) |
|
| 4782 | - continue; |
|
| 5008 | + if (count($updates) == 1) { |
|
| 5009 | + continue; |
|
| 5010 | + } |
|
| 4783 | 5011 | |
| 4784 | 5012 | $updates['whereSet'] = array_values($updates); |
| 4785 | 5013 | $smcFunc['db_query']('', ' |
@@ -4813,8 +5041,7 @@ discard block |
||
| 4813 | 5041 | 'ip' => $ip |
| 4814 | 5042 | )); |
| 4815 | 5043 | } |
| 4816 | - } |
|
| 4817 | - else |
|
| 5044 | + } else |
|
| 4818 | 5045 | { |
| 4819 | 5046 | $updates['whereSet'] = array_values($updates); |
| 4820 | 5047 | $smcFunc['db_query']('', ' |
@@ -4828,9 +5055,9 @@ discard block |
||
| 4828 | 5055 | $updates |
| 4829 | 5056 | ); |
| 4830 | 5057 | } |
| 5058 | + } else { |
|
| 5059 | + $is_done = true; |
|
| 4831 | 5060 | } |
| 4832 | - else |
|
| 4833 | - $is_done = true; |
|
| 4834 | 5061 | |
| 4835 | 5062 | $_GET['a'] += $limit; |
| 4836 | 5063 | $step_progress['current'] = $_GET['a']; |
@@ -4856,10 +5083,11 @@ discard block |
||
| 4856 | 5083 | |
| 4857 | 5084 | $columns = $smcFunc['db_list_columns']($targetTable, true); |
| 4858 | 5085 | |
| 4859 | - if (isset($columns[$column])) |
|
| 4860 | - return $columns[$column]; |
|
| 4861 | - else |
|
| 4862 | - return null; |
|
| 4863 | -} |
|
| 5086 | + if (isset($columns[$column])) { |
|
| 5087 | + return $columns[$column]; |
|
| 5088 | + } else { |
|
| 5089 | + return null; |
|
| 5090 | + } |
|
| 5091 | + } |
|
| 4864 | 5092 | |
| 4865 | 5093 | ?> |
| 4866 | 5094 | \ No newline at end of file |