@@ -1777,7 +1777,7 @@ discard block |
||
| 1777 | 1777 | |
| 1778 | 1778 | // Our custom error handler - does nothing but does stop public errors from XML! |
| 1779 | 1779 | set_error_handler( |
| 1780 | - function ($errno, $errstr, $errfile, $errline) use ($support_js) |
|
| 1780 | + function($errno, $errstr, $errfile, $errline) use ($support_js) |
|
| 1781 | 1781 | { |
| 1782 | 1782 | if ($support_js) |
| 1783 | 1783 | return true; |
@@ -2776,94 +2776,94 @@ discard block |
||
| 2776 | 2776 | // Translation table for the character sets not native for MySQL. |
| 2777 | 2777 | $translation_tables = array( |
| 2778 | 2778 | 'windows-1255' => array( |
| 2779 | - '0x81' => '\'\'', '0x8A' => '\'\'', '0x8C' => '\'\'', |
|
| 2780 | - '0x8D' => '\'\'', '0x8E' => '\'\'', '0x8F' => '\'\'', |
|
| 2781 | - '0x90' => '\'\'', '0x9A' => '\'\'', '0x9C' => '\'\'', |
|
| 2782 | - '0x9D' => '\'\'', '0x9E' => '\'\'', '0x9F' => '\'\'', |
|
| 2783 | - '0xCA' => '\'\'', '0xD9' => '\'\'', '0xDA' => '\'\'', |
|
| 2784 | - '0xDB' => '\'\'', '0xDC' => '\'\'', '0xDD' => '\'\'', |
|
| 2785 | - '0xDE' => '\'\'', '0xDF' => '\'\'', '0xFB' => '0xD792', |
|
| 2786 | - '0xFC' => '0xE282AC', '0xFF' => '0xD6B2', '0xC2' => '0xFF', |
|
| 2787 | - '0x80' => '0xFC', '0xE2' => '0xFB', '0xA0' => '0xC2A0', |
|
| 2788 | - '0xA1' => '0xC2A1', '0xA2' => '0xC2A2', '0xA3' => '0xC2A3', |
|
| 2789 | - '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
| 2790 | - '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
| 2791 | - '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
| 2792 | - '0xAF' => '0xC2AF', '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', |
|
| 2793 | - '0xB2' => '0xC2B2', '0xB3' => '0xC2B3', '0xB4' => '0xC2B4', |
|
| 2794 | - '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
| 2795 | - '0xB8' => '0xC2B8', '0xB9' => '0xC2B9', '0xBB' => '0xC2BB', |
|
| 2796 | - '0xBC' => '0xC2BC', '0xBD' => '0xC2BD', '0xBE' => '0xC2BE', |
|
| 2797 | - '0xBF' => '0xC2BF', '0xD7' => '0xD7B3', '0xD1' => '0xD781', |
|
| 2798 | - '0xD4' => '0xD7B0', '0xD5' => '0xD7B1', '0xD6' => '0xD7B2', |
|
| 2799 | - '0xE0' => '0xD790', '0xEA' => '0xD79A', '0xEC' => '0xD79C', |
|
| 2800 | - '0xED' => '0xD79D', '0xEE' => '0xD79E', '0xEF' => '0xD79F', |
|
| 2801 | - '0xF0' => '0xD7A0', '0xF1' => '0xD7A1', '0xF2' => '0xD7A2', |
|
| 2802 | - '0xF3' => '0xD7A3', '0xF5' => '0xD7A5', '0xF6' => '0xD7A6', |
|
| 2803 | - '0xF7' => '0xD7A7', '0xF8' => '0xD7A8', '0xF9' => '0xD7A9', |
|
| 2804 | - '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
| 2805 | - '0x86' => '0xE280A0', '0x87' => '0xE280A1', '0x89' => '0xE280B0', |
|
| 2806 | - '0x8B' => '0xE280B9', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
| 2807 | - '0x95' => '0xE280A2', '0x97' => '0xE28094', '0x99' => '0xE284A2', |
|
| 2808 | - '0xC0' => '0xD6B0', '0xC1' => '0xD6B1', '0xC3' => '0xD6B3', |
|
| 2809 | - '0xC4' => '0xD6B4', '0xC5' => '0xD6B5', '0xC6' => '0xD6B6', |
|
| 2810 | - '0xC7' => '0xD6B7', '0xC8' => '0xD6B8', '0xC9' => '0xD6B9', |
|
| 2811 | - '0xCB' => '0xD6BB', '0xCC' => '0xD6BC', '0xCD' => '0xD6BD', |
|
| 2812 | - '0xCE' => '0xD6BE', '0xCF' => '0xD6BF', '0xD0' => '0xD780', |
|
| 2813 | - '0xD2' => '0xD782', '0xE3' => '0xD793', '0xE4' => '0xD794', |
|
| 2814 | - '0xE5' => '0xD795', '0xE7' => '0xD797', '0xE9' => '0xD799', |
|
| 2815 | - '0xFD' => '0xE2808E', '0xFE' => '0xE2808F', '0x92' => '0xE28099', |
|
| 2816 | - '0x83' => '0xC692', '0xD3' => '0xD783', '0x88' => '0xCB86', |
|
| 2817 | - '0x98' => '0xCB9C', '0x91' => '0xE28098', '0x96' => '0xE28093', |
|
| 2818 | - '0xBA' => '0xC3B7', '0x9B' => '0xE280BA', '0xAA' => '0xC397', |
|
| 2819 | - '0xA4' => '0xE282AA', '0xE1' => '0xD791', '0xE6' => '0xD796', |
|
| 2820 | - '0xE8' => '0xD798', '0xEB' => '0xD79B', '0xF4' => '0xD7A4', |
|
| 2779 | + '0x81' => '\'\'', '0x8A' => '\'\'', '0x8C' => '\'\'', |
|
| 2780 | + '0x8D' => '\'\'', '0x8E' => '\'\'', '0x8F' => '\'\'', |
|
| 2781 | + '0x90' => '\'\'', '0x9A' => '\'\'', '0x9C' => '\'\'', |
|
| 2782 | + '0x9D' => '\'\'', '0x9E' => '\'\'', '0x9F' => '\'\'', |
|
| 2783 | + '0xCA' => '\'\'', '0xD9' => '\'\'', '0xDA' => '\'\'', |
|
| 2784 | + '0xDB' => '\'\'', '0xDC' => '\'\'', '0xDD' => '\'\'', |
|
| 2785 | + '0xDE' => '\'\'', '0xDF' => '\'\'', '0xFB' => '0xD792', |
|
| 2786 | + '0xFC' => '0xE282AC', '0xFF' => '0xD6B2', '0xC2' => '0xFF', |
|
| 2787 | + '0x80' => '0xFC', '0xE2' => '0xFB', '0xA0' => '0xC2A0', |
|
| 2788 | + '0xA1' => '0xC2A1', '0xA2' => '0xC2A2', '0xA3' => '0xC2A3', |
|
| 2789 | + '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
| 2790 | + '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
| 2791 | + '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
| 2792 | + '0xAF' => '0xC2AF', '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', |
|
| 2793 | + '0xB2' => '0xC2B2', '0xB3' => '0xC2B3', '0xB4' => '0xC2B4', |
|
| 2794 | + '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
| 2795 | + '0xB8' => '0xC2B8', '0xB9' => '0xC2B9', '0xBB' => '0xC2BB', |
|
| 2796 | + '0xBC' => '0xC2BC', '0xBD' => '0xC2BD', '0xBE' => '0xC2BE', |
|
| 2797 | + '0xBF' => '0xC2BF', '0xD7' => '0xD7B3', '0xD1' => '0xD781', |
|
| 2798 | + '0xD4' => '0xD7B0', '0xD5' => '0xD7B1', '0xD6' => '0xD7B2', |
|
| 2799 | + '0xE0' => '0xD790', '0xEA' => '0xD79A', '0xEC' => '0xD79C', |
|
| 2800 | + '0xED' => '0xD79D', '0xEE' => '0xD79E', '0xEF' => '0xD79F', |
|
| 2801 | + '0xF0' => '0xD7A0', '0xF1' => '0xD7A1', '0xF2' => '0xD7A2', |
|
| 2802 | + '0xF3' => '0xD7A3', '0xF5' => '0xD7A5', '0xF6' => '0xD7A6', |
|
| 2803 | + '0xF7' => '0xD7A7', '0xF8' => '0xD7A8', '0xF9' => '0xD7A9', |
|
| 2804 | + '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
| 2805 | + '0x86' => '0xE280A0', '0x87' => '0xE280A1', '0x89' => '0xE280B0', |
|
| 2806 | + '0x8B' => '0xE280B9', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
| 2807 | + '0x95' => '0xE280A2', '0x97' => '0xE28094', '0x99' => '0xE284A2', |
|
| 2808 | + '0xC0' => '0xD6B0', '0xC1' => '0xD6B1', '0xC3' => '0xD6B3', |
|
| 2809 | + '0xC4' => '0xD6B4', '0xC5' => '0xD6B5', '0xC6' => '0xD6B6', |
|
| 2810 | + '0xC7' => '0xD6B7', '0xC8' => '0xD6B8', '0xC9' => '0xD6B9', |
|
| 2811 | + '0xCB' => '0xD6BB', '0xCC' => '0xD6BC', '0xCD' => '0xD6BD', |
|
| 2812 | + '0xCE' => '0xD6BE', '0xCF' => '0xD6BF', '0xD0' => '0xD780', |
|
| 2813 | + '0xD2' => '0xD782', '0xE3' => '0xD793', '0xE4' => '0xD794', |
|
| 2814 | + '0xE5' => '0xD795', '0xE7' => '0xD797', '0xE9' => '0xD799', |
|
| 2815 | + '0xFD' => '0xE2808E', '0xFE' => '0xE2808F', '0x92' => '0xE28099', |
|
| 2816 | + '0x83' => '0xC692', '0xD3' => '0xD783', '0x88' => '0xCB86', |
|
| 2817 | + '0x98' => '0xCB9C', '0x91' => '0xE28098', '0x96' => '0xE28093', |
|
| 2818 | + '0xBA' => '0xC3B7', '0x9B' => '0xE280BA', '0xAA' => '0xC397', |
|
| 2819 | + '0xA4' => '0xE282AA', '0xE1' => '0xD791', '0xE6' => '0xD796', |
|
| 2820 | + '0xE8' => '0xD798', '0xEB' => '0xD79B', '0xF4' => '0xD7A4', |
|
| 2821 | 2821 | '0xFA' => '0xD7AA', |
| 2822 | 2822 | ), |
| 2823 | 2823 | 'windows-1253' => array( |
| 2824 | - '0x81' => '\'\'', '0x88' => '\'\'', '0x8A' => '\'\'', |
|
| 2825 | - '0x8C' => '\'\'', '0x8D' => '\'\'', '0x8E' => '\'\'', |
|
| 2826 | - '0x8F' => '\'\'', '0x90' => '\'\'', '0x98' => '\'\'', |
|
| 2827 | - '0x9A' => '\'\'', '0x9C' => '\'\'', '0x9D' => '\'\'', |
|
| 2828 | - '0x9E' => '\'\'', '0x9F' => '\'\'', '0xAA' => '\'\'', |
|
| 2829 | - '0xD2' => '0xE282AC', '0xFF' => '0xCE92', '0xCE' => '0xCE9E', |
|
| 2830 | - '0xB8' => '0xCE88', '0xBA' => '0xCE8A', '0xBC' => '0xCE8C', |
|
| 2831 | - '0xBE' => '0xCE8E', '0xBF' => '0xCE8F', '0xC0' => '0xCE90', |
|
| 2832 | - '0xC8' => '0xCE98', '0xCA' => '0xCE9A', '0xCC' => '0xCE9C', |
|
| 2833 | - '0xCD' => '0xCE9D', '0xCF' => '0xCE9F', '0xDA' => '0xCEAA', |
|
| 2834 | - '0xE8' => '0xCEB8', '0xEA' => '0xCEBA', '0xEC' => '0xCEBC', |
|
| 2835 | - '0xEE' => '0xCEBE', '0xEF' => '0xCEBF', '0xC2' => '0xFF', |
|
| 2836 | - '0xBD' => '0xC2BD', '0xED' => '0xCEBD', '0xB2' => '0xC2B2', |
|
| 2837 | - '0xA0' => '0xC2A0', '0xA3' => '0xC2A3', '0xA4' => '0xC2A4', |
|
| 2838 | - '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
| 2839 | - '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
| 2840 | - '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
| 2841 | - '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', '0xB3' => '0xC2B3', |
|
| 2842 | - '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
| 2843 | - '0xBB' => '0xC2BB', '0xE2' => '0xCEB2', '0x80' => '0xD2', |
|
| 2844 | - '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
| 2845 | - '0x86' => '0xE280A0', '0xA1' => '0xCE85', '0xA2' => '0xCE86', |
|
| 2846 | - '0x87' => '0xE280A1', '0x89' => '0xE280B0', '0xB9' => '0xCE89', |
|
| 2847 | - '0x8B' => '0xE280B9', '0x91' => '0xE28098', '0x99' => '0xE284A2', |
|
| 2848 | - '0x92' => '0xE28099', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
| 2849 | - '0x95' => '0xE280A2', '0x96' => '0xE28093', '0x97' => '0xE28094', |
|
| 2850 | - '0x9B' => '0xE280BA', '0xAF' => '0xE28095', '0xB4' => '0xCE84', |
|
| 2851 | - '0xC1' => '0xCE91', '0xC3' => '0xCE93', '0xC4' => '0xCE94', |
|
| 2852 | - '0xC5' => '0xCE95', '0xC6' => '0xCE96', '0x83' => '0xC692', |
|
| 2853 | - '0xC7' => '0xCE97', '0xC9' => '0xCE99', '0xCB' => '0xCE9B', |
|
| 2854 | - '0xD0' => '0xCEA0', '0xD1' => '0xCEA1', '0xD3' => '0xCEA3', |
|
| 2855 | - '0xD4' => '0xCEA4', '0xD5' => '0xCEA5', '0xD6' => '0xCEA6', |
|
| 2856 | - '0xD7' => '0xCEA7', '0xD8' => '0xCEA8', '0xD9' => '0xCEA9', |
|
| 2857 | - '0xDB' => '0xCEAB', '0xDC' => '0xCEAC', '0xDD' => '0xCEAD', |
|
| 2858 | - '0xDE' => '0xCEAE', '0xDF' => '0xCEAF', '0xE0' => '0xCEB0', |
|
| 2859 | - '0xE1' => '0xCEB1', '0xE3' => '0xCEB3', '0xE4' => '0xCEB4', |
|
| 2860 | - '0xE5' => '0xCEB5', '0xE6' => '0xCEB6', '0xE7' => '0xCEB7', |
|
| 2861 | - '0xE9' => '0xCEB9', '0xEB' => '0xCEBB', '0xF0' => '0xCF80', |
|
| 2862 | - '0xF1' => '0xCF81', '0xF2' => '0xCF82', '0xF3' => '0xCF83', |
|
| 2863 | - '0xF4' => '0xCF84', '0xF5' => '0xCF85', '0xF6' => '0xCF86', |
|
| 2864 | - '0xF7' => '0xCF87', '0xF8' => '0xCF88', '0xF9' => '0xCF89', |
|
| 2865 | - '0xFA' => '0xCF8A', '0xFB' => '0xCF8B', '0xFC' => '0xCF8C', |
|
| 2866 | - '0xFD' => '0xCF8D', '0xFE' => '0xCF8E', |
|
| 2824 | + '0x81' => '\'\'', '0x88' => '\'\'', '0x8A' => '\'\'', |
|
| 2825 | + '0x8C' => '\'\'', '0x8D' => '\'\'', '0x8E' => '\'\'', |
|
| 2826 | + '0x8F' => '\'\'', '0x90' => '\'\'', '0x98' => '\'\'', |
|
| 2827 | + '0x9A' => '\'\'', '0x9C' => '\'\'', '0x9D' => '\'\'', |
|
| 2828 | + '0x9E' => '\'\'', '0x9F' => '\'\'', '0xAA' => '\'\'', |
|
| 2829 | + '0xD2' => '0xE282AC', '0xFF' => '0xCE92', '0xCE' => '0xCE9E', |
|
| 2830 | + '0xB8' => '0xCE88', '0xBA' => '0xCE8A', '0xBC' => '0xCE8C', |
|
| 2831 | + '0xBE' => '0xCE8E', '0xBF' => '0xCE8F', '0xC0' => '0xCE90', |
|
| 2832 | + '0xC8' => '0xCE98', '0xCA' => '0xCE9A', '0xCC' => '0xCE9C', |
|
| 2833 | + '0xCD' => '0xCE9D', '0xCF' => '0xCE9F', '0xDA' => '0xCEAA', |
|
| 2834 | + '0xE8' => '0xCEB8', '0xEA' => '0xCEBA', '0xEC' => '0xCEBC', |
|
| 2835 | + '0xEE' => '0xCEBE', '0xEF' => '0xCEBF', '0xC2' => '0xFF', |
|
| 2836 | + '0xBD' => '0xC2BD', '0xED' => '0xCEBD', '0xB2' => '0xC2B2', |
|
| 2837 | + '0xA0' => '0xC2A0', '0xA3' => '0xC2A3', '0xA4' => '0xC2A4', |
|
| 2838 | + '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
| 2839 | + '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
| 2840 | + '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
| 2841 | + '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', '0xB3' => '0xC2B3', |
|
| 2842 | + '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
| 2843 | + '0xBB' => '0xC2BB', '0xE2' => '0xCEB2', '0x80' => '0xD2', |
|
| 2844 | + '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
| 2845 | + '0x86' => '0xE280A0', '0xA1' => '0xCE85', '0xA2' => '0xCE86', |
|
| 2846 | + '0x87' => '0xE280A1', '0x89' => '0xE280B0', '0xB9' => '0xCE89', |
|
| 2847 | + '0x8B' => '0xE280B9', '0x91' => '0xE28098', '0x99' => '0xE284A2', |
|
| 2848 | + '0x92' => '0xE28099', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
| 2849 | + '0x95' => '0xE280A2', '0x96' => '0xE28093', '0x97' => '0xE28094', |
|
| 2850 | + '0x9B' => '0xE280BA', '0xAF' => '0xE28095', '0xB4' => '0xCE84', |
|
| 2851 | + '0xC1' => '0xCE91', '0xC3' => '0xCE93', '0xC4' => '0xCE94', |
|
| 2852 | + '0xC5' => '0xCE95', '0xC6' => '0xCE96', '0x83' => '0xC692', |
|
| 2853 | + '0xC7' => '0xCE97', '0xC9' => '0xCE99', '0xCB' => '0xCE9B', |
|
| 2854 | + '0xD0' => '0xCEA0', '0xD1' => '0xCEA1', '0xD3' => '0xCEA3', |
|
| 2855 | + '0xD4' => '0xCEA4', '0xD5' => '0xCEA5', '0xD6' => '0xCEA6', |
|
| 2856 | + '0xD7' => '0xCEA7', '0xD8' => '0xCEA8', '0xD9' => '0xCEA9', |
|
| 2857 | + '0xDB' => '0xCEAB', '0xDC' => '0xCEAC', '0xDD' => '0xCEAD', |
|
| 2858 | + '0xDE' => '0xCEAE', '0xDF' => '0xCEAF', '0xE0' => '0xCEB0', |
|
| 2859 | + '0xE1' => '0xCEB1', '0xE3' => '0xCEB3', '0xE4' => '0xCEB4', |
|
| 2860 | + '0xE5' => '0xCEB5', '0xE6' => '0xCEB6', '0xE7' => '0xCEB7', |
|
| 2861 | + '0xE9' => '0xCEB9', '0xEB' => '0xCEBB', '0xF0' => '0xCF80', |
|
| 2862 | + '0xF1' => '0xCF81', '0xF2' => '0xCF82', '0xF3' => '0xCF83', |
|
| 2863 | + '0xF4' => '0xCF84', '0xF5' => '0xCF85', '0xF6' => '0xCF86', |
|
| 2864 | + '0xF7' => '0xCF87', '0xF8' => '0xCF88', '0xF9' => '0xCF89', |
|
| 2865 | + '0xFA' => '0xCF8A', '0xFB' => '0xCF8B', '0xFC' => '0xCF8C', |
|
| 2866 | + '0xFD' => '0xCF8D', '0xFE' => '0xCF8E', |
|
| 2867 | 2867 | ), |
| 2868 | 2868 | ); |
| 2869 | 2869 | |
@@ -3794,7 +3794,7 @@ discard block |
||
| 3794 | 3794 | |
| 3795 | 3795 | if ($active < 600) |
| 3796 | 3796 | echo ' |
| 3797 | - <p>', $txt['upgrade_run_script'], ' ', $upcontext['user']['name'],' ', $txt['upgrade_run_script2'], '</p>'; |
|
| 3797 | + <p>', $txt['upgrade_run_script'], ' ', $upcontext['user']['name'], ' ', $txt['upgrade_run_script2'], '</p>'; |
|
| 3798 | 3798 | |
| 3799 | 3799 | if ($active > $upcontext['inactive_timeout']) |
| 3800 | 3800 | echo ' |
@@ -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 | |
@@ -403,15 +424,19 @@ discard block |
||
| 403 | 424 | $seconds = intval($active % 60); |
| 404 | 425 | |
| 405 | 426 | $totalTime = ''; |
| 406 | - if ($hours > 0) |
|
| 407 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 408 | - if ($minutes > 0) |
|
| 409 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 410 | - if ($seconds > 0) |
|
| 411 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 427 | + if ($hours > 0) { |
|
| 428 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 429 | + } |
|
| 430 | + if ($minutes > 0) { |
|
| 431 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 432 | + } |
|
| 433 | + if ($seconds > 0) { |
|
| 434 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 435 | + } |
|
| 412 | 436 | |
| 413 | - if (!empty($totalTime)) |
|
| 414 | - echo "\n" . '', $txt['upgrade_completed_time'], ' ' . $totalTime . "\n"; |
|
| 437 | + if (!empty($totalTime)) { |
|
| 438 | + echo "\n" . '', $txt['upgrade_completed_time'], ' ' . $totalTime . "\n"; |
|
| 439 | + } |
|
| 415 | 440 | } |
| 416 | 441 | |
| 417 | 442 | // Bang - gone! |
@@ -432,8 +457,9 @@ discard block |
||
| 432 | 457 | $dir = dir(dirname(__FILE__) . '/Themes/default/languages'); |
| 433 | 458 | while ($entry = $dir->read()) |
| 434 | 459 | { |
| 435 | - if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') |
|
| 436 | - $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
| 460 | + if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') { |
|
| 461 | + $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
| 462 | + } |
|
| 437 | 463 | } |
| 438 | 464 | $dir->close(); |
| 439 | 465 | } |
@@ -480,10 +506,11 @@ discard block |
||
| 480 | 506 | } |
| 481 | 507 | |
| 482 | 508 | // Override the language file? |
| 483 | - if (isset($_GET['lang_file'])) |
|
| 484 | - $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
| 485 | - elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) |
|
| 486 | - $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
| 509 | + if (isset($_GET['lang_file'])) { |
|
| 510 | + $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
| 511 | + } elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) { |
|
| 512 | + $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
| 513 | + } |
|
| 487 | 514 | |
| 488 | 515 | // Make sure it exists, if it doesn't reset it. |
| 489 | 516 | 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'])) |
@@ -492,12 +519,14 @@ discard block |
||
| 492 | 519 | list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
| 493 | 520 | |
| 494 | 521 | // If we have english and some other language, use the other language. We Americans hate english :P. |
| 495 | - if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) |
|
| 496 | - list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
| 522 | + if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) { |
|
| 523 | + list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
| 524 | + } |
|
| 497 | 525 | |
| 498 | 526 | // For backup we load the english at first -> second language overwrite the english one |
| 499 | - if (count($incontext['detected_languages']) > 1) |
|
| 500 | - require_once(dirname(__FILE__) . '/Themes/default/languages/Install.english.php'); |
|
| 527 | + if (count($incontext['detected_languages']) > 1) { |
|
| 528 | + require_once(dirname(__FILE__) . '/Themes/default/languages/Install.english.php'); |
|
| 529 | + } |
|
| 501 | 530 | } |
| 502 | 531 | |
| 503 | 532 | // And now include the actual language file itself. |
@@ -505,11 +534,12 @@ discard block |
||
| 505 | 534 | |
| 506 | 535 | // Which language did we load? Assume that he likes his language. |
| 507 | 536 | preg_match('~^Install\.(.+[^-utf8])\.php$~', $_SESSION['installer_temp_lang'], $matches); |
| 508 | - if (empty($matches[1])) |
|
| 509 | - $matches = [ |
|
| 537 | + if (empty($matches[1])) { |
|
| 538 | + $matches = [ |
|
| 510 | 539 | 0 => 'nothing', |
| 511 | 540 | 1 => 'english', |
| 512 | 541 | ]; |
| 542 | + } |
|
| 513 | 543 | $user_info['language'] = $matches[1]; |
| 514 | 544 | } |
| 515 | 545 | |
@@ -519,8 +549,9 @@ discard block |
||
| 519 | 549 | global $upgradeurl, $upcontext, $command_line; |
| 520 | 550 | |
| 521 | 551 | // Command line users can't be redirected. |
| 522 | - if ($command_line) |
|
| 523 | - upgradeExit(true); |
|
| 552 | + if ($command_line) { |
|
| 553 | + upgradeExit(true); |
|
| 554 | + } |
|
| 524 | 555 | |
| 525 | 556 | // Are we providing the core info? |
| 526 | 557 | if ($addForm) |
@@ -546,12 +577,14 @@ discard block |
||
| 546 | 577 | define('SMF', 1); |
| 547 | 578 | |
| 548 | 579 | // Start the session. |
| 549 | - if (@ini_get('session.save_handler') == 'user') |
|
| 550 | - @ini_set('session.save_handler', 'files'); |
|
| 580 | + if (@ini_get('session.save_handler') == 'user') { |
|
| 581 | + @ini_set('session.save_handler', 'files'); |
|
| 582 | + } |
|
| 551 | 583 | @session_start(); |
| 552 | 584 | |
| 553 | - if (empty($smcFunc)) |
|
| 554 | - $smcFunc = array(); |
|
| 585 | + if (empty($smcFunc)) { |
|
| 586 | + $smcFunc = array(); |
|
| 587 | + } |
|
| 555 | 588 | |
| 556 | 589 | // We need this for authentication and some upgrade code |
| 557 | 590 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -578,24 +611,27 @@ discard block |
||
| 578 | 611 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
| 579 | 612 | |
| 580 | 613 | // Make the connection... |
| 581 | - if (empty($db_connection)) |
|
| 582 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
|
| 583 | - else |
|
| 584 | - // If we've returned here, ping/reconnect to be safe |
|
| 614 | + if (empty($db_connection)) { |
|
| 615 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
|
| 616 | + } else { |
|
| 617 | + // If we've returned here, ping/reconnect to be safe |
|
| 585 | 618 | $smcFunc['db_ping']($db_connection); |
| 619 | + } |
|
| 586 | 620 | |
| 587 | 621 | // Oh dear god!! |
| 588 | - if ($db_connection === null) |
|
| 589 | - die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
| 622 | + if ($db_connection === null) { |
|
| 623 | + die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
| 624 | + } |
|
| 590 | 625 | |
| 591 | - if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) |
|
| 592 | - $smcFunc['db_query']('', ' |
|
| 626 | + if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) { |
|
| 627 | + $smcFunc['db_query']('', ' |
|
| 593 | 628 | SET NAMES {string:db_character_set}', |
| 594 | 629 | array( |
| 595 | 630 | 'db_error_skip' => true, |
| 596 | 631 | 'db_character_set' => $db_character_set, |
| 597 | 632 | ) |
| 598 | 633 | ); |
| 634 | + } |
|
| 599 | 635 | |
| 600 | 636 | // Load the modSettings data... |
| 601 | 637 | $request = $smcFunc['db_query']('', ' |
@@ -606,11 +642,11 @@ discard block |
||
| 606 | 642 | ) |
| 607 | 643 | ); |
| 608 | 644 | $modSettings = array(); |
| 609 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 610 | - $modSettings[$row['variable']] = $row['value']; |
|
| 645 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 646 | + $modSettings[$row['variable']] = $row['value']; |
|
| 647 | + } |
|
| 611 | 648 | $smcFunc['db_free_result']($request); |
| 612 | - } |
|
| 613 | - else |
|
| 649 | + } else |
|
| 614 | 650 | { |
| 615 | 651 | 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.'); |
| 616 | 652 | } |
@@ -624,9 +660,10 @@ discard block |
||
| 624 | 660 | cleanRequest(); |
| 625 | 661 | } |
| 626 | 662 | |
| 627 | - if (!isset($_GET['substep'])) |
|
| 628 | - $_GET['substep'] = 0; |
|
| 629 | -} |
|
| 663 | + if (!isset($_GET['substep'])) { |
|
| 664 | + $_GET['substep'] = 0; |
|
| 665 | + } |
|
| 666 | + } |
|
| 630 | 667 | |
| 631 | 668 | function initialize_inputs() |
| 632 | 669 | { |
@@ -656,8 +693,9 @@ discard block |
||
| 656 | 693 | $dh = opendir(dirname(__FILE__)); |
| 657 | 694 | while ($file = readdir($dh)) |
| 658 | 695 | { |
| 659 | - if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) |
|
| 660 | - @unlink(dirname(__FILE__) . '/' . $file); |
|
| 696 | + if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) { |
|
| 697 | + @unlink(dirname(__FILE__) . '/' . $file); |
|
| 698 | + } |
|
| 661 | 699 | } |
| 662 | 700 | closedir($dh); |
| 663 | 701 | |
@@ -686,8 +724,9 @@ discard block |
||
| 686 | 724 | $temp = 'upgrade_php?step'; |
| 687 | 725 | while (strlen($temp) > 4) |
| 688 | 726 | { |
| 689 | - if (isset($_GET[$temp])) |
|
| 690 | - unset($_GET[$temp]); |
|
| 727 | + if (isset($_GET[$temp])) { |
|
| 728 | + unset($_GET[$temp]); |
|
| 729 | + } |
|
| 691 | 730 | $temp = substr($temp, 1); |
| 692 | 731 | } |
| 693 | 732 | |
@@ -714,32 +753,39 @@ discard block |
||
| 714 | 753 | && @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $db_type . '.sql'); |
| 715 | 754 | |
| 716 | 755 | // Need legacy scripts? |
| 717 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) |
|
| 718 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
| 719 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) |
|
| 720 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
| 721 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) |
|
| 722 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
| 756 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) { |
|
| 757 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
| 758 | + } |
|
| 759 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) { |
|
| 760 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
| 761 | + } |
|
| 762 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) { |
|
| 763 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
| 764 | + } |
|
| 723 | 765 | |
| 724 | 766 | // We don't need "-utf8" files anymore... |
| 725 | 767 | $upcontext['language'] = str_ireplace('-utf8', '', $upcontext['language']); |
| 726 | 768 | |
| 727 | 769 | // This needs to exist! |
| 728 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 729 | - 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>]'); |
|
| 730 | - else |
|
| 731 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 770 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 771 | + 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>]'); |
|
| 772 | + } else { |
|
| 773 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 774 | + } |
|
| 732 | 775 | |
| 733 | - if (!$check) |
|
| 734 | - // 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. |
|
| 776 | + if (!$check) { |
|
| 777 | + // 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. |
|
| 735 | 778 | 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.'); |
| 779 | + } |
|
| 736 | 780 | |
| 737 | 781 | // Do they meet the install requirements? |
| 738 | - if (!php_version_check()) |
|
| 739 | - 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.'); |
|
| 782 | + if (!php_version_check()) { |
|
| 783 | + 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 | + } |
|
| 740 | 785 | |
| 741 | - if (!db_version_check()) |
|
| 742 | - 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.'); |
|
| 786 | + if (!db_version_check()) { |
|
| 787 | + 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 | + } |
|
| 743 | 789 | |
| 744 | 790 | // Do some checks to make sure they have proper privileges |
| 745 | 791 | db_extend('packages'); |
@@ -754,14 +800,16 @@ discard block |
||
| 754 | 800 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
| 755 | 801 | |
| 756 | 802 | // Sorry... we need CREATE, ALTER and DROP |
| 757 | - if (!$create || !$alter || !$drop) |
|
| 758 | - 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.'); |
|
| 803 | + if (!$create || !$alter || !$drop) { |
|
| 804 | + 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 | + } |
|
| 759 | 806 | |
| 760 | 807 | // Do a quick version spot check. |
| 761 | 808 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
| 762 | 809 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
| 763 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
| 764 | - 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.'); |
|
| 810 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
| 811 | + 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 | + } |
|
| 765 | 813 | |
| 766 | 814 | // What absolutely needs to be writable? |
| 767 | 815 | $writable_files = array( |
@@ -770,12 +818,13 @@ discard block |
||
| 770 | 818 | ); |
| 771 | 819 | |
| 772 | 820 | // Only check for minified writable files if we have it enabled or not set. |
| 773 | - if (!empty($modSettings['minimize_files']) || !isset($modSettings['minimize_files'])) |
|
| 774 | - $writable_files += array( |
|
| 821 | + if (!empty($modSettings['minimize_files']) || !isset($modSettings['minimize_files'])) { |
|
| 822 | + $writable_files += array( |
|
| 775 | 823 | $modSettings['theme_dir'] . '/css/minified.css', |
| 776 | 824 | $modSettings['theme_dir'] . '/scripts/minified.js', |
| 777 | 825 | $modSettings['theme_dir'] . '/scripts/minified_deferred.js', |
| 778 | 826 | ); |
| 827 | + } |
|
| 779 | 828 | |
| 780 | 829 | // Do we need to add this setting? |
| 781 | 830 | $need_settings_update = empty($modSettings['custom_avatar_dir']); |
@@ -787,12 +836,13 @@ discard block |
||
| 787 | 836 | quickFileWritable($custom_av_dir); |
| 788 | 837 | |
| 789 | 838 | // Are we good now? |
| 790 | - if (!is_writable($custom_av_dir)) |
|
| 791 | - 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)); |
|
| 792 | - elseif ($need_settings_update) |
|
| 839 | + if (!is_writable($custom_av_dir)) { |
|
| 840 | + 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)); |
|
| 841 | + } elseif ($need_settings_update) |
|
| 793 | 842 | { |
| 794 | - if (!function_exists('cache_put_data')) |
|
| 795 | - require_once($sourcedir . '/Load.php'); |
|
| 843 | + if (!function_exists('cache_put_data')) { |
|
| 844 | + require_once($sourcedir . '/Load.php'); |
|
| 845 | + } |
|
| 796 | 846 | |
| 797 | 847 | updateSettings(array('custom_avatar_dir' => $custom_av_dir)); |
| 798 | 848 | updateSettings(array('custom_avatar_url' => $custom_av_url)); |
@@ -802,29 +852,34 @@ discard block |
||
| 802 | 852 | |
| 803 | 853 | // Check the cache directory. |
| 804 | 854 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
| 805 | - if (!file_exists($cachedir_temp)) |
|
| 806 | - @mkdir($cachedir_temp); |
|
| 855 | + if (!file_exists($cachedir_temp)) { |
|
| 856 | + @mkdir($cachedir_temp); |
|
| 857 | + } |
|
| 807 | 858 | |
| 808 | - if (!file_exists($cachedir_temp)) |
|
| 809 | - 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.'); |
|
| 859 | + if (!file_exists($cachedir_temp)) { |
|
| 860 | + 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 | + } |
|
| 810 | 862 | |
| 811 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
| 812 | - 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>.'); |
|
| 813 | - elseif (!isset($_GET['skiplang'])) |
|
| 863 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
| 864 | + 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>.'); |
|
| 865 | + } elseif (!isset($_GET['skiplang'])) |
|
| 814 | 866 | { |
| 815 | 867 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
| 816 | 868 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 817 | 869 | |
| 818 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 819 | - 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>]'); |
|
| 870 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 871 | + 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 | + } |
|
| 820 | 873 | } |
| 821 | 874 | |
| 822 | - if (!makeFilesWritable($writable_files)) |
|
| 823 | - return false; |
|
| 875 | + if (!makeFilesWritable($writable_files)) { |
|
| 876 | + return false; |
|
| 877 | + } |
|
| 824 | 878 | |
| 825 | 879 | // Check agreement.txt. (it may not exist, in which case $boarddir must be writable.) |
| 826 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
| 827 | - 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.'); |
|
| 880 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
| 881 | + 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 | + } |
|
| 828 | 883 | |
| 829 | 884 | // Upgrade the agreement. |
| 830 | 885 | elseif (isset($modSettings['agreement'])) |
@@ -835,8 +890,8 @@ discard block |
||
| 835 | 890 | } |
| 836 | 891 | |
| 837 | 892 | // We're going to check that their board dir setting is right in case they've been moving stuff around. |
| 838 | - if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) |
|
| 839 | - $upcontext['warning'] = ' |
|
| 893 | + if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) { |
|
| 894 | + $upcontext['warning'] = ' |
|
| 840 | 895 | It looks as if your board directory settings <em>might</em> be incorrect. Your board directory is currently set to "' . $boarddir . '" but should probably be "' . dirname(__FILE__) . '". Settings.php currently lists your paths as:<br> |
| 841 | 896 | <ul> |
| 842 | 897 | <li>Board Directory: ' . $boarddir . '</li> |
@@ -844,19 +899,23 @@ discard block |
||
| 844 | 899 | <li>Cache Directory: ' . $cachedir_temp . '</li> |
| 845 | 900 | </ul> |
| 846 | 901 | If these seem incorrect please open Settings.php in a text editor before proceeding with this upgrade. If they are incorrect due to you moving your forum to a new location please download and execute the <a href="https://download.simplemachines.org/?tools">Repair Settings</a> tool from the Simple Machines website before continuing.'; |
| 902 | + } |
|
| 847 | 903 | |
| 848 | 904 | // Confirm mbstring is loaded... |
| 849 | - if (!extension_loaded('mbstring')) |
|
| 850 | - return throw_error($txt['install_no_mbstring']); |
|
| 905 | + if (!extension_loaded('mbstring')) { |
|
| 906 | + return throw_error($txt['install_no_mbstring']); |
|
| 907 | + } |
|
| 851 | 908 | |
| 852 | 909 | // Check for https stream support. |
| 853 | 910 | $supported_streams = stream_get_wrappers(); |
| 854 | - if (!in_array('https', $supported_streams)) |
|
| 855 | - $upcontext['custom_warning'] = $txt['install_no_https']; |
|
| 911 | + if (!in_array('https', $supported_streams)) { |
|
| 912 | + $upcontext['custom_warning'] = $txt['install_no_https']; |
|
| 913 | + } |
|
| 856 | 914 | |
| 857 | 915 | // Either we're logged in or we're going to present the login. |
| 858 | - if (checkLogin()) |
|
| 859 | - return true; |
|
| 916 | + if (checkLogin()) { |
|
| 917 | + return true; |
|
| 918 | + } |
|
| 860 | 919 | |
| 861 | 920 | $upcontext += createToken('login'); |
| 862 | 921 | |
@@ -870,15 +929,17 @@ discard block |
||
| 870 | 929 | global $smcFunc, $db_type, $support_js; |
| 871 | 930 | |
| 872 | 931 | // Don't bother if the security is disabled. |
| 873 | - if ($disable_security) |
|
| 874 | - return true; |
|
| 932 | + if ($disable_security) { |
|
| 933 | + return true; |
|
| 934 | + } |
|
| 875 | 935 | |
| 876 | 936 | // Are we trying to login? |
| 877 | 937 | if (isset($_POST['contbutt']) && (!empty($_POST['user']))) |
| 878 | 938 | { |
| 879 | 939 | // If we've disabled security pick a suitable name! |
| 880 | - if (empty($_POST['user'])) |
|
| 881 | - $_POST['user'] = 'Administrator'; |
|
| 940 | + if (empty($_POST['user'])) { |
|
| 941 | + $_POST['user'] = 'Administrator'; |
|
| 942 | + } |
|
| 882 | 943 | |
| 883 | 944 | // Before 2.0 these column names were different! |
| 884 | 945 | $oldDB = false; |
@@ -893,16 +954,17 @@ discard block |
||
| 893 | 954 | 'db_error_skip' => true, |
| 894 | 955 | ) |
| 895 | 956 | ); |
| 896 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 897 | - $oldDB = true; |
|
| 957 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 958 | + $oldDB = true; |
|
| 959 | + } |
|
| 898 | 960 | $smcFunc['db_free_result']($request); |
| 899 | 961 | } |
| 900 | 962 | |
| 901 | 963 | // Get what we believe to be their details. |
| 902 | 964 | if (!$disable_security) |
| 903 | 965 | { |
| 904 | - if ($oldDB) |
|
| 905 | - $request = $smcFunc['db_query']('', ' |
|
| 966 | + if ($oldDB) { |
|
| 967 | + $request = $smcFunc['db_query']('', ' |
|
| 906 | 968 | SELECT id_member, memberName AS member_name, passwd, id_group, |
| 907 | 969 | additionalGroups AS additional_groups, lngfile |
| 908 | 970 | FROM {db_prefix}members |
@@ -912,8 +974,8 @@ discard block |
||
| 912 | 974 | 'db_error_skip' => true, |
| 913 | 975 | ) |
| 914 | 976 | ); |
| 915 | - else |
|
| 916 | - $request = $smcFunc['db_query']('', ' |
|
| 977 | + } else { |
|
| 978 | + $request = $smcFunc['db_query']('', ' |
|
| 917 | 979 | SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile |
| 918 | 980 | FROM {db_prefix}members |
| 919 | 981 | WHERE member_name = {string:member_name}', |
@@ -922,6 +984,7 @@ discard block |
||
| 922 | 984 | 'db_error_skip' => true, |
| 923 | 985 | ) |
| 924 | 986 | ); |
| 987 | + } |
|
| 925 | 988 | if ($smcFunc['db_num_rows']($request) != 0) |
| 926 | 989 | { |
| 927 | 990 | list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request); |
@@ -929,16 +992,17 @@ discard block |
||
| 929 | 992 | $groups = explode(',', $addGroups); |
| 930 | 993 | $groups[] = $id_group; |
| 931 | 994 | |
| 932 | - foreach ($groups as $k => $v) |
|
| 933 | - $groups[$k] = (int) $v; |
|
| 995 | + foreach ($groups as $k => $v) { |
|
| 996 | + $groups[$k] = (int) $v; |
|
| 997 | + } |
|
| 934 | 998 | |
| 935 | 999 | $sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd'])); |
| 936 | 1000 | |
| 937 | 1001 | // We don't use "-utf8" anymore... |
| 938 | 1002 | $user_language = str_ireplace('-utf8', '', $user_language); |
| 1003 | + } else { |
|
| 1004 | + $upcontext['username_incorrect'] = true; |
|
| 939 | 1005 | } |
| 940 | - else |
|
| 941 | - $upcontext['username_incorrect'] = true; |
|
| 942 | 1006 | |
| 943 | 1007 | $smcFunc['db_free_result']($request); |
| 944 | 1008 | } |
@@ -949,13 +1013,14 @@ discard block |
||
| 949 | 1013 | { |
| 950 | 1014 | $upcontext['upgrade_status']['js'] = 1; |
| 951 | 1015 | $support_js = 1; |
| 1016 | + } else { |
|
| 1017 | + $support_js = 0; |
|
| 952 | 1018 | } |
| 953 | - else |
|
| 954 | - $support_js = 0; |
|
| 955 | 1019 | |
| 956 | 1020 | // Note down the version we are coming from. |
| 957 | - if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) |
|
| 958 | - $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
| 1021 | + if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) { |
|
| 1022 | + $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
| 1023 | + } |
|
| 959 | 1024 | |
| 960 | 1025 | // Didn't get anywhere? |
| 961 | 1026 | 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'])) |
@@ -989,15 +1054,15 @@ discard block |
||
| 989 | 1054 | 'db_error_skip' => true, |
| 990 | 1055 | ) |
| 991 | 1056 | ); |
| 992 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 993 | - return throw_error('You need to be an admin to perform an upgrade!'); |
|
| 1057 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1058 | + return throw_error('You need to be an admin to perform an upgrade!'); |
|
| 1059 | + } |
|
| 994 | 1060 | $smcFunc['db_free_result']($request); |
| 995 | 1061 | } |
| 996 | 1062 | |
| 997 | 1063 | $upcontext['user']['id'] = $id_member; |
| 998 | 1064 | $upcontext['user']['name'] = $name; |
| 999 | - } |
|
| 1000 | - else |
|
| 1065 | + } else |
|
| 1001 | 1066 | { |
| 1002 | 1067 | $upcontext['user']['id'] = 1; |
| 1003 | 1068 | $upcontext['user']['name'] = 'Administrator'; |
@@ -1013,11 +1078,11 @@ discard block |
||
| 1013 | 1078 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096); |
| 1014 | 1079 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 1015 | 1080 | |
| 1016 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 1017 | - $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'] . '.'; |
|
| 1018 | - elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) |
|
| 1019 | - $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'] . '.'; |
|
| 1020 | - else |
|
| 1081 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 1082 | + $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'] . '.'; |
|
| 1083 | + } elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) { |
|
| 1084 | + $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'] . '.'; |
|
| 1085 | + } else |
|
| 1021 | 1086 | { |
| 1022 | 1087 | // Set this as the new language. |
| 1023 | 1088 | $upcontext['language'] = $user_language; |
@@ -1061,8 +1126,9 @@ discard block |
||
| 1061 | 1126 | unset($member_columns); |
| 1062 | 1127 | |
| 1063 | 1128 | // If we've not submitted then we're done. |
| 1064 | - if (empty($_POST['upcont'])) |
|
| 1065 | - return false; |
|
| 1129 | + if (empty($_POST['upcont'])) { |
|
| 1130 | + return false; |
|
| 1131 | + } |
|
| 1066 | 1132 | |
| 1067 | 1133 | // Firstly, if they're enabling SM stat collection just do it. |
| 1068 | 1134 | if (!empty($_POST['stats']) && substr($boardurl, 0, 16) != 'http://localhost' && empty($modSettings['allow_sm_stats']) && empty($modSettings['enable_sm_stats'])) |
@@ -1082,16 +1148,17 @@ discard block |
||
| 1082 | 1148 | fwrite($fp, $out); |
| 1083 | 1149 | |
| 1084 | 1150 | $return_data = ''; |
| 1085 | - while (!feof($fp)) |
|
| 1086 | - $return_data .= fgets($fp, 128); |
|
| 1151 | + while (!feof($fp)) { |
|
| 1152 | + $return_data .= fgets($fp, 128); |
|
| 1153 | + } |
|
| 1087 | 1154 | |
| 1088 | 1155 | fclose($fp); |
| 1089 | 1156 | |
| 1090 | 1157 | // Get the unique site ID. |
| 1091 | 1158 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
| 1092 | 1159 | |
| 1093 | - if (!empty($ID[1])) |
|
| 1094 | - $smcFunc['db_insert']('replace', |
|
| 1160 | + if (!empty($ID[1])) { |
|
| 1161 | + $smcFunc['db_insert']('replace', |
|
| 1095 | 1162 | $db_prefix . 'settings', |
| 1096 | 1163 | array('variable' => 'string', 'value' => 'string'), |
| 1097 | 1164 | array( |
@@ -1100,9 +1167,9 @@ discard block |
||
| 1100 | 1167 | ), |
| 1101 | 1168 | array('variable') |
| 1102 | 1169 | ); |
| 1170 | + } |
|
| 1103 | 1171 | } |
| 1104 | - } |
|
| 1105 | - else |
|
| 1172 | + } else |
|
| 1106 | 1173 | { |
| 1107 | 1174 | $smcFunc['db_insert']('replace', |
| 1108 | 1175 | $db_prefix . 'settings', |
@@ -1113,8 +1180,8 @@ discard block |
||
| 1113 | 1180 | } |
| 1114 | 1181 | } |
| 1115 | 1182 | // Don't remove stat collection unless we unchecked the box for real, not from the loop. |
| 1116 | - elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) |
|
| 1117 | - $smcFunc['db_query']('', ' |
|
| 1183 | + elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) { |
|
| 1184 | + $smcFunc['db_query']('', ' |
|
| 1118 | 1185 | DELETE FROM {db_prefix}settings |
| 1119 | 1186 | WHERE variable = {string:enable_sm_stats}', |
| 1120 | 1187 | array( |
@@ -1122,6 +1189,7 @@ discard block |
||
| 1122 | 1189 | 'db_error_skip' => true, |
| 1123 | 1190 | ) |
| 1124 | 1191 | ); |
| 1192 | + } |
|
| 1125 | 1193 | |
| 1126 | 1194 | // Deleting old karma stuff? |
| 1127 | 1195 | if (!empty($_POST['delete_karma'])) |
@@ -1136,20 +1204,22 @@ discard block |
||
| 1136 | 1204 | ); |
| 1137 | 1205 | |
| 1138 | 1206 | // Cleaning up old karma member settings. |
| 1139 | - if ($upcontext['karma_installed']['good']) |
|
| 1140 | - $smcFunc['db_query']('', ' |
|
| 1207 | + if ($upcontext['karma_installed']['good']) { |
|
| 1208 | + $smcFunc['db_query']('', ' |
|
| 1141 | 1209 | ALTER TABLE {db_prefix}members |
| 1142 | 1210 | DROP karma_good', |
| 1143 | 1211 | array() |
| 1144 | 1212 | ); |
| 1213 | + } |
|
| 1145 | 1214 | |
| 1146 | 1215 | // Does karma bad was enable? |
| 1147 | - if ($upcontext['karma_installed']['bad']) |
|
| 1148 | - $smcFunc['db_query']('', ' |
|
| 1216 | + if ($upcontext['karma_installed']['bad']) { |
|
| 1217 | + $smcFunc['db_query']('', ' |
|
| 1149 | 1218 | ALTER TABLE {db_prefix}members |
| 1150 | 1219 | DROP karma_bad', |
| 1151 | 1220 | array() |
| 1152 | 1221 | ); |
| 1222 | + } |
|
| 1153 | 1223 | |
| 1154 | 1224 | // Cleaning up old karma permissions. |
| 1155 | 1225 | $smcFunc['db_query']('', ' |
@@ -1167,32 +1237,37 @@ discard block |
||
| 1167 | 1237 | } |
| 1168 | 1238 | |
| 1169 | 1239 | // Emptying the error log? |
| 1170 | - if (!empty($_POST['empty_error'])) |
|
| 1171 | - $smcFunc['db_query']('truncate_table', ' |
|
| 1240 | + if (!empty($_POST['empty_error'])) { |
|
| 1241 | + $smcFunc['db_query']('truncate_table', ' |
|
| 1172 | 1242 | TRUNCATE {db_prefix}log_errors', |
| 1173 | 1243 | array( |
| 1174 | 1244 | ) |
| 1175 | 1245 | ); |
| 1246 | + } |
|
| 1176 | 1247 | |
| 1177 | 1248 | $changes = array(); |
| 1178 | 1249 | |
| 1179 | 1250 | // Add proxy settings. |
| 1180 | - if (!isset($GLOBALS['image_proxy_maxsize'])) |
|
| 1181 | - $changes += array( |
|
| 1251 | + if (!isset($GLOBALS['image_proxy_maxsize'])) { |
|
| 1252 | + $changes += array( |
|
| 1182 | 1253 | 'image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'', |
| 1183 | 1254 | 'image_proxy_maxsize' => 5190, |
| 1184 | 1255 | 'image_proxy_enabled' => 0, |
| 1185 | 1256 | ); |
| 1257 | + } |
|
| 1186 | 1258 | |
| 1187 | 1259 | // If $boardurl reflects https, set force_ssl |
| 1188 | - if (!function_exists('cache_put_data')) |
|
| 1189 | - require_once($sourcedir . '/Load.php'); |
|
| 1190 | - if (stripos($boardurl, 'https://') !== false) |
|
| 1191 | - updateSettings(array('force_ssl' => '1')); |
|
| 1260 | + if (!function_exists('cache_put_data')) { |
|
| 1261 | + require_once($sourcedir . '/Load.php'); |
|
| 1262 | + } |
|
| 1263 | + if (stripos($boardurl, 'https://') !== false) { |
|
| 1264 | + updateSettings(array('force_ssl' => '1')); |
|
| 1265 | + } |
|
| 1192 | 1266 | |
| 1193 | 1267 | // If we're overriding the language follow it through. |
| 1194 | - if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) |
|
| 1195 | - $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
| 1268 | + if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) { |
|
| 1269 | + $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
| 1270 | + } |
|
| 1196 | 1271 | |
| 1197 | 1272 | if (!empty($_POST['maint'])) |
| 1198 | 1273 | { |
@@ -1204,26 +1279,29 @@ discard block |
||
| 1204 | 1279 | { |
| 1205 | 1280 | $changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\''; |
| 1206 | 1281 | $changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\''; |
| 1207 | - } |
|
| 1208 | - else |
|
| 1282 | + } else |
|
| 1209 | 1283 | { |
| 1210 | 1284 | $changes['mtitle'] = '\'Upgrading the forum...\''; |
| 1211 | 1285 | $changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum. It will only be a minute ;).\''; |
| 1212 | 1286 | } |
| 1213 | 1287 | } |
| 1214 | 1288 | |
| 1215 | - if ($command_line) |
|
| 1216 | - echo ' * Updating Settings.php...'; |
|
| 1289 | + if ($command_line) { |
|
| 1290 | + echo ' * Updating Settings.php...'; |
|
| 1291 | + } |
|
| 1217 | 1292 | |
| 1218 | 1293 | // Fix some old paths. |
| 1219 | - if (substr($boarddir, 0, 1) == '.') |
|
| 1220 | - $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
| 1294 | + if (substr($boarddir, 0, 1) == '.') { |
|
| 1295 | + $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
| 1296 | + } |
|
| 1221 | 1297 | |
| 1222 | - if (substr($sourcedir, 0, 1) == '.') |
|
| 1223 | - $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
| 1298 | + if (substr($sourcedir, 0, 1) == '.') { |
|
| 1299 | + $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
| 1300 | + } |
|
| 1224 | 1301 | |
| 1225 | - if (empty($cachedir) || substr($cachedir, 0, 1) == '.') |
|
| 1226 | - $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
| 1302 | + if (empty($cachedir) || substr($cachedir, 0, 1) == '.') { |
|
| 1303 | + $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
| 1304 | + } |
|
| 1227 | 1305 | |
| 1228 | 1306 | // If they have a "host:port" setup for the host, split that into separate values |
| 1229 | 1307 | // You should never have a : in the hostname if you're not on MySQL, but better safe than sorry |
@@ -1234,32 +1312,36 @@ discard block |
||
| 1234 | 1312 | $changes['db_server'] = '\'' . $db_server . '\''; |
| 1235 | 1313 | |
| 1236 | 1314 | // Only set this if we're not using the default port |
| 1237 | - if ($db_port != ini_get('mysqli.default_port')) |
|
| 1238 | - $changes['db_port'] = (int) $db_port; |
|
| 1239 | - } |
|
| 1240 | - elseif (!empty($db_port)) |
|
| 1315 | + if ($db_port != ini_get('mysqli.default_port')) { |
|
| 1316 | + $changes['db_port'] = (int) $db_port; |
|
| 1317 | + } |
|
| 1318 | + } elseif (!empty($db_port)) |
|
| 1241 | 1319 | { |
| 1242 | 1320 | // If db_port is set and is the same as the default, set it to '' |
| 1243 | 1321 | if ($db_type == 'mysql') |
| 1244 | 1322 | { |
| 1245 | - if ($db_port == ini_get('mysqli.default_port')) |
|
| 1246 | - $changes['db_port'] = '\'\''; |
|
| 1247 | - elseif ($db_type == 'postgresql' && $db_port == 5432) |
|
| 1248 | - $changes['db_port'] = '\'\''; |
|
| 1323 | + if ($db_port == ini_get('mysqli.default_port')) { |
|
| 1324 | + $changes['db_port'] = '\'\''; |
|
| 1325 | + } elseif ($db_type == 'postgresql' && $db_port == 5432) { |
|
| 1326 | + $changes['db_port'] = '\'\''; |
|
| 1327 | + } |
|
| 1249 | 1328 | } |
| 1250 | 1329 | } |
| 1251 | 1330 | |
| 1252 | 1331 | // Maybe we haven't had this option yet? |
| 1253 | - if (empty($packagesdir)) |
|
| 1254 | - $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
| 1332 | + if (empty($packagesdir)) { |
|
| 1333 | + $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
| 1334 | + } |
|
| 1255 | 1335 | |
| 1256 | 1336 | // Add support for $tasksdir var. |
| 1257 | - if (empty($tasksdir)) |
|
| 1258 | - $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
| 1337 | + if (empty($tasksdir)) { |
|
| 1338 | + $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
| 1339 | + } |
|
| 1259 | 1340 | |
| 1260 | 1341 | // Make sure we fix the language as well. |
| 1261 | - if (stristr($language, '-utf8')) |
|
| 1262 | - $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
| 1342 | + if (stristr($language, '-utf8')) { |
|
| 1343 | + $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
| 1344 | + } |
|
| 1263 | 1345 | |
| 1264 | 1346 | // @todo Maybe change the cookie name if going to 1.1, too? |
| 1265 | 1347 | |
@@ -1270,8 +1352,9 @@ discard block |
||
| 1270 | 1352 | // Tell Settings.php to store db_last_error.php in the cache |
| 1271 | 1353 | move_db_last_error_to_cachedir(); |
| 1272 | 1354 | |
| 1273 | - if ($command_line) |
|
| 1274 | - echo ' Successful.' . "\n"; |
|
| 1355 | + if ($command_line) { |
|
| 1356 | + echo ' Successful.' . "\n"; |
|
| 1357 | + } |
|
| 1275 | 1358 | |
| 1276 | 1359 | // Are we doing debug? |
| 1277 | 1360 | if (isset($_POST['debug'])) |
@@ -1281,8 +1364,9 @@ discard block |
||
| 1281 | 1364 | } |
| 1282 | 1365 | |
| 1283 | 1366 | // If we're not backing up then jump one. |
| 1284 | - if (empty($_POST['backup'])) |
|
| 1285 | - $upcontext['current_step']++; |
|
| 1367 | + if (empty($_POST['backup'])) { |
|
| 1368 | + $upcontext['current_step']++; |
|
| 1369 | + } |
|
| 1286 | 1370 | |
| 1287 | 1371 | // If we've got here then let's proceed to the next step! |
| 1288 | 1372 | return true; |
@@ -1297,8 +1381,9 @@ discard block |
||
| 1297 | 1381 | $upcontext['page_title'] = $txt['backup_database']; |
| 1298 | 1382 | |
| 1299 | 1383 | // Done it already - js wise? |
| 1300 | - if (!empty($_POST['backup_done'])) |
|
| 1301 | - return true; |
|
| 1384 | + if (!empty($_POST['backup_done'])) { |
|
| 1385 | + return true; |
|
| 1386 | + } |
|
| 1302 | 1387 | |
| 1303 | 1388 | // Some useful stuff here. |
| 1304 | 1389 | db_extend(); |
@@ -1312,9 +1397,10 @@ discard block |
||
| 1312 | 1397 | $tables = $smcFunc['db_list_tables']($db, $filter); |
| 1313 | 1398 | |
| 1314 | 1399 | $table_names = array(); |
| 1315 | - foreach ($tables as $table) |
|
| 1316 | - if (substr($table, 0, 7) !== 'backup_') |
|
| 1400 | + foreach ($tables as $table) { |
|
| 1401 | + if (substr($table, 0, 7) !== 'backup_') |
|
| 1317 | 1402 | $table_names[] = $table; |
| 1403 | + } |
|
| 1318 | 1404 | |
| 1319 | 1405 | $upcontext['table_count'] = count($table_names); |
| 1320 | 1406 | $upcontext['cur_table_num'] = $_GET['substep']; |
@@ -1324,12 +1410,14 @@ discard block |
||
| 1324 | 1410 | $file_steps = $upcontext['table_count']; |
| 1325 | 1411 | |
| 1326 | 1412 | // What ones have we already done? |
| 1327 | - foreach ($table_names as $id => $table) |
|
| 1328 | - if ($id < $_GET['substep']) |
|
| 1413 | + foreach ($table_names as $id => $table) { |
|
| 1414 | + if ($id < $_GET['substep']) |
|
| 1329 | 1415 | $upcontext['previous_tables'][] = $table; |
| 1416 | + } |
|
| 1330 | 1417 | |
| 1331 | - if ($command_line) |
|
| 1332 | - echo 'Backing Up Tables.'; |
|
| 1418 | + if ($command_line) { |
|
| 1419 | + echo 'Backing Up Tables.'; |
|
| 1420 | + } |
|
| 1333 | 1421 | |
| 1334 | 1422 | // If we don't support javascript we backup here. |
| 1335 | 1423 | if (!$support_js || isset($_GET['xml'])) |
@@ -1348,8 +1436,9 @@ discard block |
||
| 1348 | 1436 | backupTable($table_names[$substep]); |
| 1349 | 1437 | |
| 1350 | 1438 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 1351 | - if (isset($_GET['xml'])) |
|
| 1352 | - return upgradeExit(); |
|
| 1439 | + if (isset($_GET['xml'])) { |
|
| 1440 | + return upgradeExit(); |
|
| 1441 | + } |
|
| 1353 | 1442 | } |
| 1354 | 1443 | |
| 1355 | 1444 | if ($command_line) |
@@ -1382,9 +1471,10 @@ discard block |
||
| 1382 | 1471 | |
| 1383 | 1472 | $smcFunc['db_backup_table']($table, 'backup_' . $table); |
| 1384 | 1473 | |
| 1385 | - if ($command_line) |
|
| 1386 | - echo ' done.'; |
|
| 1387 | -} |
|
| 1474 | + if ($command_line) { |
|
| 1475 | + echo ' done.'; |
|
| 1476 | + } |
|
| 1477 | + } |
|
| 1388 | 1478 | |
| 1389 | 1479 | // Step 2: Everything. |
| 1390 | 1480 | function DatabaseChanges() |
@@ -1393,8 +1483,9 @@ discard block |
||
| 1393 | 1483 | global $upcontext, $support_js, $db_type; |
| 1394 | 1484 | |
| 1395 | 1485 | // Have we just completed this? |
| 1396 | - if (!empty($_POST['database_done'])) |
|
| 1397 | - return true; |
|
| 1486 | + if (!empty($_POST['database_done'])) { |
|
| 1487 | + return true; |
|
| 1488 | + } |
|
| 1398 | 1489 | |
| 1399 | 1490 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes'; |
| 1400 | 1491 | $upcontext['page_title'] = $txt['database_changes']; |
@@ -1409,15 +1500,16 @@ discard block |
||
| 1409 | 1500 | ); |
| 1410 | 1501 | |
| 1411 | 1502 | // How many files are there in total? |
| 1412 | - if (isset($_GET['filecount'])) |
|
| 1413 | - $upcontext['file_count'] = (int) $_GET['filecount']; |
|
| 1414 | - else |
|
| 1503 | + if (isset($_GET['filecount'])) { |
|
| 1504 | + $upcontext['file_count'] = (int) $_GET['filecount']; |
|
| 1505 | + } else |
|
| 1415 | 1506 | { |
| 1416 | 1507 | $upcontext['file_count'] = 0; |
| 1417 | 1508 | foreach ($files as $file) |
| 1418 | 1509 | { |
| 1419 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) |
|
| 1420 | - $upcontext['file_count']++; |
|
| 1510 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) { |
|
| 1511 | + $upcontext['file_count']++; |
|
| 1512 | + } |
|
| 1421 | 1513 | } |
| 1422 | 1514 | } |
| 1423 | 1515 | |
@@ -1427,9 +1519,9 @@ discard block |
||
| 1427 | 1519 | $upcontext['cur_file_num'] = 0; |
| 1428 | 1520 | foreach ($files as $file) |
| 1429 | 1521 | { |
| 1430 | - if ($did_not_do) |
|
| 1431 | - $did_not_do--; |
|
| 1432 | - else |
|
| 1522 | + if ($did_not_do) { |
|
| 1523 | + $did_not_do--; |
|
| 1524 | + } else |
|
| 1433 | 1525 | { |
| 1434 | 1526 | $upcontext['cur_file_num']++; |
| 1435 | 1527 | $upcontext['cur_file_name'] = $file[0]; |
@@ -1456,12 +1548,13 @@ discard block |
||
| 1456 | 1548 | // Flag to move on to the next. |
| 1457 | 1549 | $upcontext['completed_step'] = true; |
| 1458 | 1550 | // Did we complete the whole file? |
| 1459 | - if ($nextFile) |
|
| 1460 | - $upcontext['current_debug_item_num'] = -1; |
|
| 1551 | + if ($nextFile) { |
|
| 1552 | + $upcontext['current_debug_item_num'] = -1; |
|
| 1553 | + } |
|
| 1461 | 1554 | return upgradeExit(); |
| 1555 | + } elseif ($support_js) { |
|
| 1556 | + break; |
|
| 1462 | 1557 | } |
| 1463 | - elseif ($support_js) |
|
| 1464 | - break; |
|
| 1465 | 1558 | } |
| 1466 | 1559 | // Set the progress bar to be right as if we had - even if we hadn't... |
| 1467 | 1560 | $upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100; |
@@ -1487,8 +1580,9 @@ discard block |
||
| 1487 | 1580 | global $user_info, $maintenance, $smcFunc, $db_type, $txt, $settings; |
| 1488 | 1581 | |
| 1489 | 1582 | // Now it's nice to have some of the basic SMF source files. |
| 1490 | - if (!isset($_GET['ssi']) && !$command_line) |
|
| 1491 | - redirectLocation('&ssi=1'); |
|
| 1583 | + if (!isset($_GET['ssi']) && !$command_line) { |
|
| 1584 | + redirectLocation('&ssi=1'); |
|
| 1585 | + } |
|
| 1492 | 1586 | |
| 1493 | 1587 | $upcontext['sub_template'] = 'upgrade_complete'; |
| 1494 | 1588 | $upcontext['page_title'] = $txt['upgrade_complete']; |
@@ -1504,14 +1598,16 @@ discard block |
||
| 1504 | 1598 | // Are we in maintenance mode? |
| 1505 | 1599 | if (isset($upcontext['user']['main'])) |
| 1506 | 1600 | { |
| 1507 | - if ($command_line) |
|
| 1508 | - echo ' * '; |
|
| 1601 | + if ($command_line) { |
|
| 1602 | + echo ' * '; |
|
| 1603 | + } |
|
| 1509 | 1604 | $upcontext['removed_maintenance'] = true; |
| 1510 | 1605 | $changes['maintenance'] = $upcontext['user']['main']; |
| 1511 | 1606 | } |
| 1512 | 1607 | // Otherwise if somehow we are in 2 let's go to 1. |
| 1513 | - elseif (!empty($maintenance) && $maintenance == 2) |
|
| 1514 | - $changes['maintenance'] = 1; |
|
| 1608 | + elseif (!empty($maintenance) && $maintenance == 2) { |
|
| 1609 | + $changes['maintenance'] = 1; |
|
| 1610 | + } |
|
| 1515 | 1611 | |
| 1516 | 1612 | // Wipe this out... |
| 1517 | 1613 | $upcontext['user'] = array(); |
@@ -1526,21 +1622,23 @@ discard block |
||
| 1526 | 1622 | $upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__); |
| 1527 | 1623 | |
| 1528 | 1624 | // Now is the perfect time to fetch the SM files. |
| 1529 | - if ($command_line) |
|
| 1530 | - cli_scheduled_fetchSMfiles(); |
|
| 1531 | - else |
|
| 1625 | + if ($command_line) { |
|
| 1626 | + cli_scheduled_fetchSMfiles(); |
|
| 1627 | + } else |
|
| 1532 | 1628 | { |
| 1533 | 1629 | require_once($sourcedir . '/ScheduledTasks.php'); |
| 1534 | 1630 | $forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us. |
| 1535 | 1631 | scheduled_fetchSMfiles(); // Now go get those files! |
| 1536 | 1632 | // This is needed in case someone invokes the upgrader using https when upgrading an http forum |
| 1537 | - if (httpsOn()) |
|
| 1538 | - $settings['default_theme_url'] = strtr($settings['default_theme_url'], array('http://' => 'https://')); |
|
| 1633 | + if (httpsOn()) { |
|
| 1634 | + $settings['default_theme_url'] = strtr($settings['default_theme_url'], array('http://' => 'https://')); |
|
| 1635 | + } |
|
| 1539 | 1636 | } |
| 1540 | 1637 | |
| 1541 | 1638 | // Log what we've done. |
| 1542 | - if (empty($user_info['id'])) |
|
| 1543 | - $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
| 1639 | + if (empty($user_info['id'])) { |
|
| 1640 | + $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
| 1641 | + } |
|
| 1544 | 1642 | |
| 1545 | 1643 | // Log the action manually, so CLI still works. |
| 1546 | 1644 | $smcFunc['db_insert']('', |
@@ -1559,8 +1657,9 @@ discard block |
||
| 1559 | 1657 | |
| 1560 | 1658 | // Save the current database version. |
| 1561 | 1659 | $server_version = $smcFunc['db_server_info'](); |
| 1562 | - if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
| 1563 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1660 | + if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
| 1661 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1662 | + } |
|
| 1564 | 1663 | |
| 1565 | 1664 | if ($command_line) |
| 1566 | 1665 | { |
@@ -1572,8 +1671,9 @@ discard block |
||
| 1572 | 1671 | |
| 1573 | 1672 | // Make sure it says we're done. |
| 1574 | 1673 | $upcontext['overall_percent'] = 100; |
| 1575 | - if (isset($upcontext['step_progress'])) |
|
| 1576 | - unset($upcontext['step_progress']); |
|
| 1674 | + if (isset($upcontext['step_progress'])) { |
|
| 1675 | + unset($upcontext['step_progress']); |
|
| 1676 | + } |
|
| 1577 | 1677 | |
| 1578 | 1678 | $_GET['substep'] = 0; |
| 1579 | 1679 | return false; |
@@ -1584,8 +1684,9 @@ discard block |
||
| 1584 | 1684 | { |
| 1585 | 1685 | global $sourcedir, $language, $forum_version, $modSettings, $smcFunc; |
| 1586 | 1686 | |
| 1587 | - if (empty($modSettings['time_format'])) |
|
| 1588 | - $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
| 1687 | + if (empty($modSettings['time_format'])) { |
|
| 1688 | + $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
| 1689 | + } |
|
| 1589 | 1690 | |
| 1590 | 1691 | // What files do we want to get |
| 1591 | 1692 | $request = $smcFunc['db_query']('', ' |
@@ -1619,8 +1720,9 @@ discard block |
||
| 1619 | 1720 | $file_data = fetch_web_data($url); |
| 1620 | 1721 | |
| 1621 | 1722 | // If we got an error - give up - the site might be down. |
| 1622 | - if ($file_data === false) |
|
| 1623 | - return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
| 1723 | + if ($file_data === false) { |
|
| 1724 | + return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
| 1725 | + } |
|
| 1624 | 1726 | |
| 1625 | 1727 | // Save the file to the database. |
| 1626 | 1728 | $smcFunc['db_query']('substring', ' |
@@ -1662,8 +1764,9 @@ discard block |
||
| 1662 | 1764 | $themeData = array(); |
| 1663 | 1765 | foreach ($values as $variable => $value) |
| 1664 | 1766 | { |
| 1665 | - if (!isset($value) || $value === null) |
|
| 1666 | - $value = 0; |
|
| 1767 | + if (!isset($value) || $value === null) { |
|
| 1768 | + $value = 0; |
|
| 1769 | + } |
|
| 1667 | 1770 | |
| 1668 | 1771 | $themeData[] = array(0, 1, $variable, $value); |
| 1669 | 1772 | } |
@@ -1692,8 +1795,9 @@ discard block |
||
| 1692 | 1795 | |
| 1693 | 1796 | foreach ($values as $variable => $value) |
| 1694 | 1797 | { |
| 1695 | - if (empty($modSettings[$value[0]])) |
|
| 1696 | - continue; |
|
| 1798 | + if (empty($modSettings[$value[0]])) { |
|
| 1799 | + continue; |
|
| 1800 | + } |
|
| 1697 | 1801 | |
| 1698 | 1802 | $smcFunc['db_query']('', ' |
| 1699 | 1803 | INSERT IGNORE INTO {db_prefix}themes |
@@ -1779,19 +1883,21 @@ discard block |
||
| 1779 | 1883 | set_error_handler( |
| 1780 | 1884 | function ($errno, $errstr, $errfile, $errline) use ($support_js) |
| 1781 | 1885 | { |
| 1782 | - if ($support_js) |
|
| 1783 | - return true; |
|
| 1784 | - else |
|
| 1785 | - echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
| 1886 | + if ($support_js) { |
|
| 1887 | + return true; |
|
| 1888 | + } else { |
|
| 1889 | + echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
| 1890 | + } |
|
| 1786 | 1891 | } |
| 1787 | 1892 | ); |
| 1788 | 1893 | |
| 1789 | 1894 | // If we're on MySQL, set {db_collation}; this approach is used throughout upgrade_2-0_mysql.php to set new tables to utf8 |
| 1790 | 1895 | // Note it is expected to be in the format: ENGINE=MyISAM{$db_collation}; |
| 1791 | - if ($db_type == 'mysql') |
|
| 1792 | - $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
| 1793 | - else |
|
| 1794 | - $db_collation = ''; |
|
| 1896 | + if ($db_type == 'mysql') { |
|
| 1897 | + $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
| 1898 | + } else { |
|
| 1899 | + $db_collation = ''; |
|
| 1900 | + } |
|
| 1795 | 1901 | |
| 1796 | 1902 | $endl = $command_line ? "\n" : '<br>' . "\n"; |
| 1797 | 1903 | |
@@ -1803,8 +1909,9 @@ discard block |
||
| 1803 | 1909 | $last_step = ''; |
| 1804 | 1910 | |
| 1805 | 1911 | // Make sure all newly created tables will have the proper characters set; this approach is used throughout upgrade_2-1_mysql.php |
| 1806 | - if (isset($db_character_set) && $db_character_set === 'utf8') |
|
| 1807 | - $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
| 1912 | + if (isset($db_character_set) && $db_character_set === 'utf8') { |
|
| 1913 | + $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
| 1914 | + } |
|
| 1808 | 1915 | |
| 1809 | 1916 | // Count the total number of steps within this file - for progress. |
| 1810 | 1917 | $file_steps = substr_count(implode('', $lines), '---#'); |
@@ -1824,15 +1931,18 @@ discard block |
||
| 1824 | 1931 | $do_current = $substep >= $_GET['substep']; |
| 1825 | 1932 | |
| 1826 | 1933 | // Get rid of any comments in the beginning of the line... |
| 1827 | - if (substr(trim($line), 0, 2) === '/*') |
|
| 1828 | - $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
| 1934 | + if (substr(trim($line), 0, 2) === '/*') { |
|
| 1935 | + $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
| 1936 | + } |
|
| 1829 | 1937 | |
| 1830 | 1938 | // Always flush. Flush, flush, flush. Flush, flush, flush, flush! FLUSH! |
| 1831 | - if ($is_debug && !$support_js && $command_line) |
|
| 1832 | - flush(); |
|
| 1939 | + if ($is_debug && !$support_js && $command_line) { |
|
| 1940 | + flush(); |
|
| 1941 | + } |
|
| 1833 | 1942 | |
| 1834 | - if (trim($line) === '') |
|
| 1835 | - continue; |
|
| 1943 | + if (trim($line) === '') { |
|
| 1944 | + continue; |
|
| 1945 | + } |
|
| 1836 | 1946 | |
| 1837 | 1947 | if (trim(substr($line, 0, 3)) === '---') |
| 1838 | 1948 | { |
@@ -1842,8 +1952,9 @@ discard block |
||
| 1842 | 1952 | if (trim($current_data) != '' && $type !== '}') |
| 1843 | 1953 | { |
| 1844 | 1954 | $upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl; |
| 1845 | - if ($command_line) |
|
| 1846 | - echo $upcontext['error_message']; |
|
| 1955 | + if ($command_line) { |
|
| 1956 | + echo $upcontext['error_message']; |
|
| 1957 | + } |
|
| 1847 | 1958 | } |
| 1848 | 1959 | |
| 1849 | 1960 | if ($type == ' ') |
@@ -1861,17 +1972,18 @@ discard block |
||
| 1861 | 1972 | if ($do_current) |
| 1862 | 1973 | { |
| 1863 | 1974 | $upcontext['actioned_items'][] = $last_step; |
| 1864 | - if ($command_line) |
|
| 1865 | - echo ' * '; |
|
| 1975 | + if ($command_line) { |
|
| 1976 | + echo ' * '; |
|
| 1977 | + } |
|
| 1866 | 1978 | } |
| 1867 | - } |
|
| 1868 | - elseif ($type == '#') |
|
| 1979 | + } elseif ($type == '#') |
|
| 1869 | 1980 | { |
| 1870 | 1981 | $upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps; |
| 1871 | 1982 | |
| 1872 | 1983 | $upcontext['current_debug_item_num']++; |
| 1873 | - if (trim($line) != '---#') |
|
| 1874 | - $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1984 | + if (trim($line) != '---#') { |
|
| 1985 | + $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1986 | + } |
|
| 1875 | 1987 | |
| 1876 | 1988 | // Have we already done something? |
| 1877 | 1989 | if (isset($_GET['xml']) && $done_something) |
@@ -1882,34 +1994,36 @@ discard block |
||
| 1882 | 1994 | |
| 1883 | 1995 | if ($do_current) |
| 1884 | 1996 | { |
| 1885 | - if (trim($line) == '---#' && $command_line) |
|
| 1886 | - echo ' done.', $endl; |
|
| 1887 | - elseif ($command_line) |
|
| 1888 | - echo ' +++ ', rtrim(substr($line, 4)); |
|
| 1889 | - elseif (trim($line) != '---#') |
|
| 1997 | + if (trim($line) == '---#' && $command_line) { |
|
| 1998 | + echo ' done.', $endl; |
|
| 1999 | + } elseif ($command_line) { |
|
| 2000 | + echo ' +++ ', rtrim(substr($line, 4)); |
|
| 2001 | + } elseif (trim($line) != '---#') |
|
| 1890 | 2002 | { |
| 1891 | - if ($is_debug) |
|
| 1892 | - $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 2003 | + if ($is_debug) { |
|
| 2004 | + $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 2005 | + } |
|
| 1893 | 2006 | } |
| 1894 | 2007 | } |
| 1895 | 2008 | |
| 1896 | 2009 | if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep']) |
| 1897 | 2010 | { |
| 1898 | - if ($command_line) |
|
| 1899 | - echo ' * '; |
|
| 1900 | - else |
|
| 1901 | - $upcontext['actioned_items'][] = $last_step; |
|
| 2011 | + if ($command_line) { |
|
| 2012 | + echo ' * '; |
|
| 2013 | + } else { |
|
| 2014 | + $upcontext['actioned_items'][] = $last_step; |
|
| 2015 | + } |
|
| 1902 | 2016 | } |
| 1903 | 2017 | |
| 1904 | 2018 | // Small step - only if we're actually doing stuff. |
| 1905 | - if ($do_current) |
|
| 1906 | - nextSubstep(++$substep); |
|
| 1907 | - else |
|
| 1908 | - $substep++; |
|
| 1909 | - } |
|
| 1910 | - elseif ($type == '{') |
|
| 1911 | - $current_type = 'code'; |
|
| 1912 | - elseif ($type == '}') |
|
| 2019 | + if ($do_current) { |
|
| 2020 | + nextSubstep(++$substep); |
|
| 2021 | + } else { |
|
| 2022 | + $substep++; |
|
| 2023 | + } |
|
| 2024 | + } elseif ($type == '{') { |
|
| 2025 | + $current_type = 'code'; |
|
| 2026 | + } elseif ($type == '}') |
|
| 1913 | 2027 | { |
| 1914 | 2028 | $current_type = 'sql'; |
| 1915 | 2029 | |
@@ -1922,8 +2036,9 @@ discard block |
||
| 1922 | 2036 | if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false) |
| 1923 | 2037 | { |
| 1924 | 2038 | $upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl; |
| 1925 | - if ($command_line) |
|
| 1926 | - echo $upcontext['error_message']; |
|
| 2039 | + if ($command_line) { |
|
| 2040 | + echo $upcontext['error_message']; |
|
| 2041 | + } |
|
| 1927 | 2042 | } |
| 1928 | 2043 | |
| 1929 | 2044 | // Done with code! |
@@ -2011,8 +2126,9 @@ discard block |
||
| 2011 | 2126 | $db_unbuffered = false; |
| 2012 | 2127 | |
| 2013 | 2128 | // Failure?! |
| 2014 | - if ($result !== false) |
|
| 2015 | - return $result; |
|
| 2129 | + if ($result !== false) { |
|
| 2130 | + return $result; |
|
| 2131 | + } |
|
| 2016 | 2132 | |
| 2017 | 2133 | $db_error_message = $smcFunc['db_error']($db_connection); |
| 2018 | 2134 | // If MySQL we do something more clever. |
@@ -2040,54 +2156,61 @@ discard block |
||
| 2040 | 2156 | { |
| 2041 | 2157 | mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`'); |
| 2042 | 2158 | $result = mysqli_query($db_connection, $string); |
| 2043 | - if ($result !== false) |
|
| 2044 | - return $result; |
|
| 2159 | + if ($result !== false) { |
|
| 2160 | + return $result; |
|
| 2161 | + } |
|
| 2045 | 2162 | } |
| 2046 | - } |
|
| 2047 | - elseif ($mysqli_errno == 2013) |
|
| 2163 | + } elseif ($mysqli_errno == 2013) |
|
| 2048 | 2164 | { |
| 2049 | 2165 | $db_connection = mysqli_connect($db_server, $db_user, $db_passwd); |
| 2050 | 2166 | mysqli_select_db($db_connection, $db_name); |
| 2051 | 2167 | if ($db_connection) |
| 2052 | 2168 | { |
| 2053 | 2169 | $result = mysqli_query($db_connection, $string); |
| 2054 | - if ($result !== false) |
|
| 2055 | - return $result; |
|
| 2170 | + if ($result !== false) { |
|
| 2171 | + return $result; |
|
| 2172 | + } |
|
| 2056 | 2173 | } |
| 2057 | 2174 | } |
| 2058 | 2175 | // Duplicate column name... should be okay ;). |
| 2059 | - elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) |
|
| 2060 | - return false; |
|
| 2176 | + elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) { |
|
| 2177 | + return false; |
|
| 2178 | + } |
|
| 2061 | 2179 | // Duplicate insert... make sure it's the proper type of query ;). |
| 2062 | - elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) |
|
| 2063 | - return false; |
|
| 2180 | + elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) { |
|
| 2181 | + return false; |
|
| 2182 | + } |
|
| 2064 | 2183 | // Creating an index on a non-existent column. |
| 2065 | - elseif ($mysqli_errno == 1072) |
|
| 2066 | - return false; |
|
| 2067 | - elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') |
|
| 2068 | - return false; |
|
| 2184 | + elseif ($mysqli_errno == 1072) { |
|
| 2185 | + return false; |
|
| 2186 | + } elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') { |
|
| 2187 | + return false; |
|
| 2188 | + } |
|
| 2069 | 2189 | } |
| 2070 | 2190 | // If a table already exists don't go potty. |
| 2071 | 2191 | else |
| 2072 | 2192 | { |
| 2073 | 2193 | if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U'))) |
| 2074 | 2194 | { |
| 2075 | - if (strpos($db_error_message, 'exist') !== false) |
|
| 2076 | - return true; |
|
| 2077 | - } |
|
| 2078 | - elseif (strpos(trim($string), 'INSERT ') !== false) |
|
| 2195 | + if (strpos($db_error_message, 'exist') !== false) { |
|
| 2196 | + return true; |
|
| 2197 | + } |
|
| 2198 | + } elseif (strpos(trim($string), 'INSERT ') !== false) |
|
| 2079 | 2199 | { |
| 2080 | - if (strpos($db_error_message, 'duplicate') !== false || $ignore_insert_error) |
|
| 2081 | - return true; |
|
| 2200 | + if (strpos($db_error_message, 'duplicate') !== false || $ignore_insert_error) { |
|
| 2201 | + return true; |
|
| 2202 | + } |
|
| 2082 | 2203 | } |
| 2083 | 2204 | } |
| 2084 | 2205 | |
| 2085 | 2206 | // Get the query string so we pass everything. |
| 2086 | 2207 | $query_string = ''; |
| 2087 | - foreach ($_GET as $k => $v) |
|
| 2088 | - $query_string .= ';' . $k . '=' . $v; |
|
| 2089 | - if (strlen($query_string) != 0) |
|
| 2090 | - $query_string = '?' . substr($query_string, 1); |
|
| 2208 | + foreach ($_GET as $k => $v) { |
|
| 2209 | + $query_string .= ';' . $k . '=' . $v; |
|
| 2210 | + } |
|
| 2211 | + if (strlen($query_string) != 0) { |
|
| 2212 | + $query_string = '?' . substr($query_string, 1); |
|
| 2213 | + } |
|
| 2091 | 2214 | |
| 2092 | 2215 | if ($command_line) |
| 2093 | 2216 | { |
@@ -2142,16 +2265,18 @@ discard block |
||
| 2142 | 2265 | { |
| 2143 | 2266 | $found |= 1; |
| 2144 | 2267 | // Do some checks on the data if we have it set. |
| 2145 | - if (isset($change['col_type'])) |
|
| 2146 | - $found &= $change['col_type'] === $column['type']; |
|
| 2147 | - if (isset($change['null_allowed'])) |
|
| 2148 | - $found &= $column['null'] == $change['null_allowed']; |
|
| 2149 | - if (isset($change['default'])) |
|
| 2150 | - $found &= $change['default'] === $column['default']; |
|
| 2268 | + if (isset($change['col_type'])) { |
|
| 2269 | + $found &= $change['col_type'] === $column['type']; |
|
| 2270 | + } |
|
| 2271 | + if (isset($change['null_allowed'])) { |
|
| 2272 | + $found &= $column['null'] == $change['null_allowed']; |
|
| 2273 | + } |
|
| 2274 | + if (isset($change['default'])) { |
|
| 2275 | + $found &= $change['default'] === $column['default']; |
|
| 2276 | + } |
|
| 2151 | 2277 | } |
| 2152 | 2278 | } |
| 2153 | - } |
|
| 2154 | - elseif ($change['type'] === 'index') |
|
| 2279 | + } elseif ($change['type'] === 'index') |
|
| 2155 | 2280 | { |
| 2156 | 2281 | $request = upgrade_query(' |
| 2157 | 2282 | SHOW INDEX |
@@ -2160,9 +2285,10 @@ discard block |
||
| 2160 | 2285 | { |
| 2161 | 2286 | $cur_index = array(); |
| 2162 | 2287 | |
| 2163 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2164 | - if ($row['Key_name'] === $change['name']) |
|
| 2288 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2289 | + if ($row['Key_name'] === $change['name']) |
|
| 2165 | 2290 | $cur_index[(int) $row['Seq_in_index']] = $row['Column_name']; |
| 2291 | + } |
|
| 2166 | 2292 | |
| 2167 | 2293 | ksort($cur_index, SORT_NUMERIC); |
| 2168 | 2294 | $found = array_values($cur_index) === $change['target_columns']; |
@@ -2172,14 +2298,17 @@ discard block |
||
| 2172 | 2298 | } |
| 2173 | 2299 | |
| 2174 | 2300 | // If we're trying to add and it's added, we're done. |
| 2175 | - if ($found && in_array($change['method'], array('add', 'change'))) |
|
| 2176 | - return true; |
|
| 2301 | + if ($found && in_array($change['method'], array('add', 'change'))) { |
|
| 2302 | + return true; |
|
| 2303 | + } |
|
| 2177 | 2304 | // Otherwise if we're removing and it wasn't found we're also done. |
| 2178 | - elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) |
|
| 2179 | - return true; |
|
| 2305 | + elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) { |
|
| 2306 | + return true; |
|
| 2307 | + } |
|
| 2180 | 2308 | // Otherwise is it just a test? |
| 2181 | - elseif ($is_test) |
|
| 2182 | - return false; |
|
| 2309 | + elseif ($is_test) { |
|
| 2310 | + return false; |
|
| 2311 | + } |
|
| 2183 | 2312 | |
| 2184 | 2313 | // Not found it yet? Bummer! How about we see if we're currently doing it? |
| 2185 | 2314 | $running = false; |
@@ -2190,8 +2319,9 @@ discard block |
||
| 2190 | 2319 | SHOW FULL PROCESSLIST'); |
| 2191 | 2320 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2192 | 2321 | { |
| 2193 | - if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) |
|
| 2194 | - $found = true; |
|
| 2322 | + if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) { |
|
| 2323 | + $found = true; |
|
| 2324 | + } |
|
| 2195 | 2325 | } |
| 2196 | 2326 | |
| 2197 | 2327 | // Can't find it? Then we need to run it fools! |
@@ -2203,8 +2333,9 @@ discard block |
||
| 2203 | 2333 | ALTER TABLE ' . $db_prefix . $change['table'] . ' |
| 2204 | 2334 | ' . $change['text'], true) !== false; |
| 2205 | 2335 | |
| 2206 | - if (!$success) |
|
| 2207 | - return false; |
|
| 2336 | + if (!$success) { |
|
| 2337 | + return false; |
|
| 2338 | + } |
|
| 2208 | 2339 | |
| 2209 | 2340 | // Return |
| 2210 | 2341 | $running = true; |
@@ -2246,8 +2377,9 @@ discard block |
||
| 2246 | 2377 | 'db_error_skip' => true, |
| 2247 | 2378 | ) |
| 2248 | 2379 | ); |
| 2249 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2250 | - die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
| 2380 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2381 | + die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
| 2382 | + } |
|
| 2251 | 2383 | $table_row = $smcFunc['db_fetch_assoc']($request); |
| 2252 | 2384 | $smcFunc['db_free_result']($request); |
| 2253 | 2385 | |
@@ -2269,18 +2401,19 @@ discard block |
||
| 2269 | 2401 | ) |
| 2270 | 2402 | ); |
| 2271 | 2403 | // No results? Just forget it all together. |
| 2272 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2273 | - unset($table_row['Collation']); |
|
| 2274 | - else |
|
| 2275 | - $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2404 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2405 | + unset($table_row['Collation']); |
|
| 2406 | + } else { |
|
| 2407 | + $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2408 | + } |
|
| 2276 | 2409 | $smcFunc['db_free_result']($request); |
| 2277 | 2410 | } |
| 2278 | 2411 | |
| 2279 | 2412 | if ($column_fix) |
| 2280 | 2413 | { |
| 2281 | 2414 | // Make sure there are no NULL's left. |
| 2282 | - if ($null_fix) |
|
| 2283 | - $smcFunc['db_query']('', ' |
|
| 2415 | + if ($null_fix) { |
|
| 2416 | + $smcFunc['db_query']('', ' |
|
| 2284 | 2417 | UPDATE {db_prefix}' . $change['table'] . ' |
| 2285 | 2418 | SET ' . $change['column'] . ' = {string:default} |
| 2286 | 2419 | WHERE ' . $change['column'] . ' IS NULL', |
@@ -2289,6 +2422,7 @@ discard block |
||
| 2289 | 2422 | 'db_error_skip' => true, |
| 2290 | 2423 | ) |
| 2291 | 2424 | ); |
| 2425 | + } |
|
| 2292 | 2426 | |
| 2293 | 2427 | // Do the actual alteration. |
| 2294 | 2428 | $smcFunc['db_query']('', ' |
@@ -2317,8 +2451,9 @@ discard block |
||
| 2317 | 2451 | } |
| 2318 | 2452 | |
| 2319 | 2453 | // Not a column we need to check on? |
| 2320 | - if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) |
|
| 2321 | - return; |
|
| 2454 | + if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) { |
|
| 2455 | + return; |
|
| 2456 | + } |
|
| 2322 | 2457 | |
| 2323 | 2458 | // Break it up you (six|seven). |
| 2324 | 2459 | $temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text'])); |
@@ -2337,13 +2472,13 @@ discard block |
||
| 2337 | 2472 | 'new_name' => $temp[2], |
| 2338 | 2473 | )); |
| 2339 | 2474 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
| 2340 | - if ($smcFunc['db_num_rows'] != 1) |
|
| 2341 | - return; |
|
| 2475 | + if ($smcFunc['db_num_rows'] != 1) { |
|
| 2476 | + return; |
|
| 2477 | + } |
|
| 2342 | 2478 | |
| 2343 | 2479 | list (, $current_type) = $smcFunc['db_fetch_assoc']($request); |
| 2344 | 2480 | $smcFunc['db_free_result']($request); |
| 2345 | - } |
|
| 2346 | - else |
|
| 2481 | + } else |
|
| 2347 | 2482 | { |
| 2348 | 2483 | // Do this the old fashion, sure method way. |
| 2349 | 2484 | $request = $smcFunc['db_query']('', ' |
@@ -2354,21 +2489,24 @@ discard block |
||
| 2354 | 2489 | )); |
| 2355 | 2490 | // Mayday! |
| 2356 | 2491 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
| 2357 | - if ($smcFunc['db_num_rows'] == 0) |
|
| 2358 | - return; |
|
| 2492 | + if ($smcFunc['db_num_rows'] == 0) { |
|
| 2493 | + return; |
|
| 2494 | + } |
|
| 2359 | 2495 | |
| 2360 | 2496 | // Oh where, oh where has my little field gone. Oh where can it be... |
| 2361 | - while ($row = $smcFunc['db_query']($request)) |
|
| 2362 | - if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
| 2497 | + while ($row = $smcFunc['db_query']($request)) { |
|
| 2498 | + if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
| 2363 | 2499 | { |
| 2364 | 2500 | $current_type = $row['Type']; |
| 2501 | + } |
|
| 2365 | 2502 | break; |
| 2366 | 2503 | } |
| 2367 | 2504 | } |
| 2368 | 2505 | |
| 2369 | 2506 | // If this doesn't match, the column may of been altered for a reason. |
| 2370 | - if (trim($current_type) != trim($temp[3])) |
|
| 2371 | - $temp[3] = $current_type; |
|
| 2507 | + if (trim($current_type) != trim($temp[3])) { |
|
| 2508 | + $temp[3] = $current_type; |
|
| 2509 | + } |
|
| 2372 | 2510 | |
| 2373 | 2511 | // Piece this back together. |
| 2374 | 2512 | $change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp)); |
@@ -2380,8 +2518,9 @@ discard block |
||
| 2380 | 2518 | global $start_time, $timeLimitThreshold, $command_line, $custom_warning; |
| 2381 | 2519 | global $step_progress, $is_debug, $upcontext; |
| 2382 | 2520 | |
| 2383 | - if ($_GET['substep'] < $substep) |
|
| 2384 | - $_GET['substep'] = $substep; |
|
| 2521 | + if ($_GET['substep'] < $substep) { |
|
| 2522 | + $_GET['substep'] = $substep; |
|
| 2523 | + } |
|
| 2385 | 2524 | |
| 2386 | 2525 | if ($command_line) |
| 2387 | 2526 | { |
@@ -2394,29 +2533,33 @@ discard block |
||
| 2394 | 2533 | } |
| 2395 | 2534 | |
| 2396 | 2535 | @set_time_limit(300); |
| 2397 | - if (function_exists('apache_reset_timeout')) |
|
| 2398 | - @apache_reset_timeout(); |
|
| 2536 | + if (function_exists('apache_reset_timeout')) { |
|
| 2537 | + @apache_reset_timeout(); |
|
| 2538 | + } |
|
| 2399 | 2539 | |
| 2400 | - if (time() - $start_time <= $timeLimitThreshold) |
|
| 2401 | - return; |
|
| 2540 | + if (time() - $start_time <= $timeLimitThreshold) { |
|
| 2541 | + return; |
|
| 2542 | + } |
|
| 2402 | 2543 | |
| 2403 | 2544 | // Do we have some custom step progress stuff? |
| 2404 | 2545 | if (!empty($step_progress)) |
| 2405 | 2546 | { |
| 2406 | 2547 | $upcontext['substep_progress'] = 0; |
| 2407 | 2548 | $upcontext['substep_progress_name'] = $step_progress['name']; |
| 2408 | - if ($step_progress['current'] > $step_progress['total']) |
|
| 2409 | - $upcontext['substep_progress'] = 99.9; |
|
| 2410 | - else |
|
| 2411 | - $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
| 2549 | + if ($step_progress['current'] > $step_progress['total']) { |
|
| 2550 | + $upcontext['substep_progress'] = 99.9; |
|
| 2551 | + } else { |
|
| 2552 | + $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
| 2553 | + } |
|
| 2412 | 2554 | |
| 2413 | 2555 | // Make it nicely rounded. |
| 2414 | 2556 | $upcontext['substep_progress'] = round($upcontext['substep_progress'], 1); |
| 2415 | 2557 | } |
| 2416 | 2558 | |
| 2417 | 2559 | // If this is XML we just exit right away! |
| 2418 | - if (isset($_GET['xml'])) |
|
| 2419 | - return upgradeExit(); |
|
| 2560 | + if (isset($_GET['xml'])) { |
|
| 2561 | + return upgradeExit(); |
|
| 2562 | + } |
|
| 2420 | 2563 | |
| 2421 | 2564 | // We're going to pause after this! |
| 2422 | 2565 | $upcontext['pause'] = true; |
@@ -2424,13 +2567,15 @@ discard block |
||
| 2424 | 2567 | $upcontext['query_string'] = ''; |
| 2425 | 2568 | foreach ($_GET as $k => $v) |
| 2426 | 2569 | { |
| 2427 | - if ($k != 'data' && $k != 'substep' && $k != 'step') |
|
| 2428 | - $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
| 2570 | + if ($k != 'data' && $k != 'substep' && $k != 'step') { |
|
| 2571 | + $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
| 2572 | + } |
|
| 2429 | 2573 | } |
| 2430 | 2574 | |
| 2431 | 2575 | // Custom warning? |
| 2432 | - if (!empty($custom_warning)) |
|
| 2433 | - $upcontext['custom_warning'] = $custom_warning; |
|
| 2576 | + if (!empty($custom_warning)) { |
|
| 2577 | + $upcontext['custom_warning'] = $custom_warning; |
|
| 2578 | + } |
|
| 2434 | 2579 | |
| 2435 | 2580 | upgradeExit(); |
| 2436 | 2581 | } |
@@ -2445,25 +2590,26 @@ discard block |
||
| 2445 | 2590 | ob_implicit_flush(true); |
| 2446 | 2591 | @set_time_limit(600); |
| 2447 | 2592 | |
| 2448 | - if (!isset($_SERVER['argv'])) |
|
| 2449 | - $_SERVER['argv'] = array(); |
|
| 2593 | + if (!isset($_SERVER['argv'])) { |
|
| 2594 | + $_SERVER['argv'] = array(); |
|
| 2595 | + } |
|
| 2450 | 2596 | $_GET['maint'] = 1; |
| 2451 | 2597 | |
| 2452 | 2598 | foreach ($_SERVER['argv'] as $i => $arg) |
| 2453 | 2599 | { |
| 2454 | - if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) |
|
| 2455 | - $_GET['lang'] = $match[1]; |
|
| 2456 | - elseif (preg_match('~^--path=(.+)$~', $arg) != 0) |
|
| 2457 | - continue; |
|
| 2458 | - elseif ($arg == '--no-maintenance') |
|
| 2459 | - $_GET['maint'] = 0; |
|
| 2460 | - elseif ($arg == '--debug') |
|
| 2461 | - $is_debug = true; |
|
| 2462 | - elseif ($arg == '--backup') |
|
| 2463 | - $_POST['backup'] = 1; |
|
| 2464 | - elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) |
|
| 2465 | - $_GET['conv'] = 1; |
|
| 2466 | - elseif ($i != 0) |
|
| 2600 | + if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) { |
|
| 2601 | + $_GET['lang'] = $match[1]; |
|
| 2602 | + } elseif (preg_match('~^--path=(.+)$~', $arg) != 0) { |
|
| 2603 | + continue; |
|
| 2604 | + } elseif ($arg == '--no-maintenance') { |
|
| 2605 | + $_GET['maint'] = 0; |
|
| 2606 | + } elseif ($arg == '--debug') { |
|
| 2607 | + $is_debug = true; |
|
| 2608 | + } elseif ($arg == '--backup') { |
|
| 2609 | + $_POST['backup'] = 1; |
|
| 2610 | + } elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) { |
|
| 2611 | + $_GET['conv'] = 1; |
|
| 2612 | + } elseif ($i != 0) |
|
| 2467 | 2613 | { |
| 2468 | 2614 | echo 'SMF Command-line Upgrader |
| 2469 | 2615 | Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]... |
@@ -2477,10 +2623,12 @@ discard block |
||
| 2477 | 2623 | } |
| 2478 | 2624 | } |
| 2479 | 2625 | |
| 2480 | - if (!php_version_check()) |
|
| 2481 | - print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
| 2482 | - if (!db_version_check()) |
|
| 2483 | - print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
| 2626 | + if (!php_version_check()) { |
|
| 2627 | + print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
| 2628 | + } |
|
| 2629 | + if (!db_version_check()) { |
|
| 2630 | + print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
| 2631 | + } |
|
| 2484 | 2632 | |
| 2485 | 2633 | // Do some checks to make sure they have proper privileges |
| 2486 | 2634 | db_extend('packages'); |
@@ -2495,34 +2643,39 @@ discard block |
||
| 2495 | 2643 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
| 2496 | 2644 | |
| 2497 | 2645 | // Sorry... we need CREATE, ALTER and DROP |
| 2498 | - if (!$create || !$alter || !$drop) |
|
| 2499 | - 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); |
|
| 2646 | + if (!$create || !$alter || !$drop) { |
|
| 2647 | + 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 | + } |
|
| 2500 | 2649 | |
| 2501 | 2650 | $check = @file_exists($modSettings['theme_dir'] . '/index.template.php') |
| 2502 | 2651 | && @file_exists($sourcedir . '/QueryString.php') |
| 2503 | 2652 | && @file_exists($sourcedir . '/ManageBoards.php'); |
| 2504 | - if (!$check && !isset($modSettings['smfVersion'])) |
|
| 2505 | - print_error('Error: Some files are missing or out-of-date.', true); |
|
| 2653 | + if (!$check && !isset($modSettings['smfVersion'])) { |
|
| 2654 | + print_error('Error: Some files are missing or out-of-date.', true); |
|
| 2655 | + } |
|
| 2506 | 2656 | |
| 2507 | 2657 | // Do a quick version spot check. |
| 2508 | 2658 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
| 2509 | 2659 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
| 2510 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
| 2511 | - print_error('Error: Some files have not yet been updated properly.'); |
|
| 2660 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
| 2661 | + print_error('Error: Some files have not yet been updated properly.'); |
|
| 2662 | + } |
|
| 2512 | 2663 | |
| 2513 | 2664 | // Make sure Settings.php is writable. |
| 2514 | 2665 | quickFileWritable($boarddir . '/Settings.php'); |
| 2515 | - if (!is_writable($boarddir . '/Settings.php')) |
|
| 2516 | - print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
| 2666 | + if (!is_writable($boarddir . '/Settings.php')) { |
|
| 2667 | + print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
| 2668 | + } |
|
| 2517 | 2669 | |
| 2518 | 2670 | // Make sure Settings_bak.php is writable. |
| 2519 | 2671 | quickFileWritable($boarddir . '/Settings_bak.php'); |
| 2520 | - if (!is_writable($boarddir . '/Settings_bak.php')) |
|
| 2521 | - print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
| 2672 | + if (!is_writable($boarddir . '/Settings_bak.php')) { |
|
| 2673 | + print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
| 2674 | + } |
|
| 2522 | 2675 | |
| 2523 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
| 2524 | - print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
| 2525 | - elseif (isset($modSettings['agreement'])) |
|
| 2676 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
| 2677 | + print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
| 2678 | + } elseif (isset($modSettings['agreement'])) |
|
| 2526 | 2679 | { |
| 2527 | 2680 | $fp = fopen($boarddir . '/agreement.txt', 'w'); |
| 2528 | 2681 | fwrite($fp, $modSettings['agreement']); |
@@ -2532,36 +2685,42 @@ discard block |
||
| 2532 | 2685 | // Make sure Themes is writable. |
| 2533 | 2686 | quickFileWritable($modSettings['theme_dir']); |
| 2534 | 2687 | |
| 2535 | - if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) |
|
| 2536 | - print_error('Error: Unable to obtain write access to "Themes".'); |
|
| 2688 | + if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) { |
|
| 2689 | + print_error('Error: Unable to obtain write access to "Themes".'); |
|
| 2690 | + } |
|
| 2537 | 2691 | |
| 2538 | 2692 | // Make sure cache directory exists and is writable! |
| 2539 | 2693 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
| 2540 | - if (!file_exists($cachedir_temp)) |
|
| 2541 | - @mkdir($cachedir_temp); |
|
| 2694 | + if (!file_exists($cachedir_temp)) { |
|
| 2695 | + @mkdir($cachedir_temp); |
|
| 2696 | + } |
|
| 2542 | 2697 | |
| 2543 | 2698 | // Make sure the cache temp dir is writable. |
| 2544 | 2699 | quickFileWritable($cachedir_temp); |
| 2545 | 2700 | |
| 2546 | - if (!is_writable($cachedir_temp)) |
|
| 2547 | - print_error('Error: Unable to obtain write access to "cache".', true); |
|
| 2701 | + if (!is_writable($cachedir_temp)) { |
|
| 2702 | + print_error('Error: Unable to obtain write access to "cache".', true); |
|
| 2703 | + } |
|
| 2548 | 2704 | |
| 2549 | 2705 | // Make sure db_last_error.php is writable. |
| 2550 | 2706 | quickFileWritable($cachedir_temp . '/db_last_error.php'); |
| 2551 | - if (!is_writable($cachedir_temp . '/db_last_error.php')) |
|
| 2552 | - print_error('Error: Unable to obtain write access to "db_last_error.php".'); |
|
| 2707 | + if (!is_writable($cachedir_temp . '/db_last_error.php')) { |
|
| 2708 | + print_error('Error: Unable to obtain write access to "db_last_error.php".'); |
|
| 2709 | + } |
|
| 2553 | 2710 | |
| 2554 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
| 2555 | - print_error('Error: Unable to find language files!', true); |
|
| 2556 | - else |
|
| 2711 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
| 2712 | + print_error('Error: Unable to find language files!', true); |
|
| 2713 | + } else |
|
| 2557 | 2714 | { |
| 2558 | 2715 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
| 2559 | 2716 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 2560 | 2717 | |
| 2561 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 2562 | - print_error('Error: Language files out of date.', true); |
|
| 2563 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 2564 | - print_error('Error: Install language is missing for selected language.', true); |
|
| 2718 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 2719 | + print_error('Error: Language files out of date.', true); |
|
| 2720 | + } |
|
| 2721 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 2722 | + print_error('Error: Install language is missing for selected language.', true); |
|
| 2723 | + } |
|
| 2565 | 2724 | |
| 2566 | 2725 | // Otherwise include it! |
| 2567 | 2726 | require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
@@ -2581,8 +2740,9 @@ discard block |
||
| 2581 | 2740 | global $db_prefix, $db_type, $command_line, $support_js, $txt; |
| 2582 | 2741 | |
| 2583 | 2742 | // Done it already? |
| 2584 | - if (!empty($_POST['utf8_done'])) |
|
| 2585 | - return true; |
|
| 2743 | + if (!empty($_POST['utf8_done'])) { |
|
| 2744 | + return true; |
|
| 2745 | + } |
|
| 2586 | 2746 | |
| 2587 | 2747 | // First make sure they aren't already on UTF-8 before we go anywhere... |
| 2588 | 2748 | if ($db_type == 'postgresql' || ($db_character_set === 'utf8' && !empty($modSettings['global_character_set']) && $modSettings['global_character_set'] === 'UTF-8')) |
@@ -2595,8 +2755,7 @@ discard block |
||
| 2595 | 2755 | ); |
| 2596 | 2756 | |
| 2597 | 2757 | return true; |
| 2598 | - } |
|
| 2599 | - else |
|
| 2758 | + } else |
|
| 2600 | 2759 | { |
| 2601 | 2760 | $upcontext['page_title'] = $txt['converting_utf8']; |
| 2602 | 2761 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8'; |
@@ -2640,8 +2799,9 @@ discard block |
||
| 2640 | 2799 | ) |
| 2641 | 2800 | ); |
| 2642 | 2801 | $db_charsets = array(); |
| 2643 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2644 | - $db_charsets[] = $row['Charset']; |
|
| 2802 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2803 | + $db_charsets[] = $row['Charset']; |
|
| 2804 | + } |
|
| 2645 | 2805 | |
| 2646 | 2806 | $smcFunc['db_free_result']($request); |
| 2647 | 2807 | |
@@ -2677,13 +2837,15 @@ discard block |
||
| 2677 | 2837 | // If there's a fulltext index, we need to drop it first... |
| 2678 | 2838 | if ($request !== false || $smcFunc['db_num_rows']($request) != 0) |
| 2679 | 2839 | { |
| 2680 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2681 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 2840 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2841 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 2682 | 2842 | $upcontext['fulltext_index'][] = $row['Key_name']; |
| 2843 | + } |
|
| 2683 | 2844 | $smcFunc['db_free_result']($request); |
| 2684 | 2845 | |
| 2685 | - if (isset($upcontext['fulltext_index'])) |
|
| 2686 | - $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
| 2846 | + if (isset($upcontext['fulltext_index'])) { |
|
| 2847 | + $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
| 2848 | + } |
|
| 2687 | 2849 | } |
| 2688 | 2850 | |
| 2689 | 2851 | // Drop it and make a note... |
@@ -2873,8 +3035,9 @@ discard block |
||
| 2873 | 3035 | $replace = '%field%'; |
| 2874 | 3036 | |
| 2875 | 3037 | // Build a huge REPLACE statement... |
| 2876 | - foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) |
|
| 2877 | - $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
| 3038 | + foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) { |
|
| 3039 | + $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
| 3040 | + } |
|
| 2878 | 3041 | } |
| 2879 | 3042 | |
| 2880 | 3043 | // Get a list of table names ahead of time... This makes it easier to set our substep and such |
@@ -2884,9 +3047,10 @@ discard block |
||
| 2884 | 3047 | $upcontext['table_count'] = count($queryTables); |
| 2885 | 3048 | |
| 2886 | 3049 | // What ones have we already done? |
| 2887 | - foreach ($queryTables as $id => $table) |
|
| 2888 | - if ($id < $_GET['substep']) |
|
| 3050 | + foreach ($queryTables as $id => $table) { |
|
| 3051 | + if ($id < $_GET['substep']) |
|
| 2889 | 3052 | $upcontext['previous_tables'][] = $table; |
| 3053 | + } |
|
| 2890 | 3054 | |
| 2891 | 3055 | $upcontext['cur_table_num'] = $_GET['substep']; |
| 2892 | 3056 | $upcontext['cur_table_name'] = str_replace($db_prefix, '', $queryTables[$_GET['substep']]); |
@@ -2923,8 +3087,9 @@ discard block |
||
| 2923 | 3087 | nextSubstep($substep); |
| 2924 | 3088 | |
| 2925 | 3089 | // Just to make sure it doesn't time out. |
| 2926 | - if (function_exists('apache_reset_timeout')) |
|
| 2927 | - @apache_reset_timeout(); |
|
| 3090 | + if (function_exists('apache_reset_timeout')) { |
|
| 3091 | + @apache_reset_timeout(); |
|
| 3092 | + } |
|
| 2928 | 3093 | |
| 2929 | 3094 | $table_charsets = array(); |
| 2930 | 3095 | |
@@ -2947,8 +3112,9 @@ discard block |
||
| 2947 | 3112 | |
| 2948 | 3113 | // Build structure of columns to operate on organized by charset; only operate on columns not yet utf8 |
| 2949 | 3114 | if ($charset != 'utf8') { |
| 2950 | - if (!isset($table_charsets[$charset])) |
|
| 2951 | - $table_charsets[$charset] = array(); |
|
| 3115 | + if (!isset($table_charsets[$charset])) { |
|
| 3116 | + $table_charsets[$charset] = array(); |
|
| 3117 | + } |
|
| 2952 | 3118 | |
| 2953 | 3119 | $table_charsets[$charset][] = $column_info; |
| 2954 | 3120 | } |
@@ -2989,10 +3155,11 @@ discard block |
||
| 2989 | 3155 | if (isset($translation_tables[$upcontext['charset_detected']])) |
| 2990 | 3156 | { |
| 2991 | 3157 | $update = ''; |
| 2992 | - foreach ($table_charsets as $charset => $columns) |
|
| 2993 | - foreach ($columns as $column) |
|
| 3158 | + foreach ($table_charsets as $charset => $columns) { |
|
| 3159 | + foreach ($columns as $column) |
|
| 2994 | 3160 | $update .= ' |
| 2995 | 3161 | ' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ','; |
| 3162 | + } |
|
| 2996 | 3163 | |
| 2997 | 3164 | $smcFunc['db_query']('', ' |
| 2998 | 3165 | UPDATE {raw:table_name} |
@@ -3017,8 +3184,9 @@ discard block |
||
| 3017 | 3184 | // Now do the actual conversion (if still needed). |
| 3018 | 3185 | if ($charsets[$upcontext['charset_detected']] !== 'utf8') |
| 3019 | 3186 | { |
| 3020 | - if ($command_line) |
|
| 3021 | - echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
| 3187 | + if ($command_line) { |
|
| 3188 | + echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
| 3189 | + } |
|
| 3022 | 3190 | |
| 3023 | 3191 | $smcFunc['db_query']('', ' |
| 3024 | 3192 | ALTER TABLE {raw:table_name} |
@@ -3028,12 +3196,14 @@ discard block |
||
| 3028 | 3196 | ) |
| 3029 | 3197 | ); |
| 3030 | 3198 | |
| 3031 | - if ($command_line) |
|
| 3032 | - echo " done.\n"; |
|
| 3199 | + if ($command_line) { |
|
| 3200 | + echo " done.\n"; |
|
| 3201 | + } |
|
| 3033 | 3202 | } |
| 3034 | 3203 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 3035 | - if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count']) |
|
| 3036 | - return upgradeExit(); |
|
| 3204 | + if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count']) { |
|
| 3205 | + return upgradeExit(); |
|
| 3206 | + } |
|
| 3037 | 3207 | } |
| 3038 | 3208 | |
| 3039 | 3209 | $prev_charset = empty($translation_tables[$upcontext['charset_detected']]) ? $charsets[$upcontext['charset_detected']] : $translation_tables[$upcontext['charset_detected']]; |
@@ -3062,8 +3232,8 @@ discard block |
||
| 3062 | 3232 | ); |
| 3063 | 3233 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 3064 | 3234 | { |
| 3065 | - 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) |
|
| 3066 | - $smcFunc['db_query']('', ' |
|
| 3235 | + 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) { |
|
| 3236 | + $smcFunc['db_query']('', ' |
|
| 3067 | 3237 | UPDATE {db_prefix}log_actions |
| 3068 | 3238 | SET extra = {string:extra} |
| 3069 | 3239 | WHERE id_action = {int:current_action}', |
@@ -3072,6 +3242,7 @@ discard block |
||
| 3072 | 3242 | 'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4], |
| 3073 | 3243 | ) |
| 3074 | 3244 | ); |
| 3245 | + } |
|
| 3075 | 3246 | } |
| 3076 | 3247 | $smcFunc['db_free_result']($request); |
| 3077 | 3248 | |
@@ -3093,15 +3264,17 @@ discard block |
||
| 3093 | 3264 | // First thing's first - did we already do this? |
| 3094 | 3265 | if (!empty($modSettings['json_done'])) |
| 3095 | 3266 | { |
| 3096 | - if ($command_line) |
|
| 3097 | - return DeleteUpgrade(); |
|
| 3098 | - else |
|
| 3099 | - return true; |
|
| 3267 | + if ($command_line) { |
|
| 3268 | + return DeleteUpgrade(); |
|
| 3269 | + } else { |
|
| 3270 | + return true; |
|
| 3271 | + } |
|
| 3100 | 3272 | } |
| 3101 | 3273 | |
| 3102 | 3274 | // Done it already - js wise? |
| 3103 | - if (!empty($_POST['json_done'])) |
|
| 3104 | - return true; |
|
| 3275 | + if (!empty($_POST['json_done'])) { |
|
| 3276 | + return true; |
|
| 3277 | + } |
|
| 3105 | 3278 | |
| 3106 | 3279 | // List of tables affected by this function |
| 3107 | 3280 | // name => array('key', col1[,col2|true[,col3]]) |
@@ -3133,12 +3306,14 @@ discard block |
||
| 3133 | 3306 | $upcontext['cur_table_name'] = isset($keys[$_GET['substep']]) ? $keys[$_GET['substep']] : $keys[0]; |
| 3134 | 3307 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
| 3135 | 3308 | |
| 3136 | - foreach ($keys as $id => $table) |
|
| 3137 | - if ($id < $_GET['substep']) |
|
| 3309 | + foreach ($keys as $id => $table) { |
|
| 3310 | + if ($id < $_GET['substep']) |
|
| 3138 | 3311 | $upcontext['previous_tables'][] = $table; |
| 3312 | + } |
|
| 3139 | 3313 | |
| 3140 | - if ($command_line) |
|
| 3141 | - echo 'Converting data from serialize() to json_encode().'; |
|
| 3314 | + if ($command_line) { |
|
| 3315 | + echo 'Converting data from serialize() to json_encode().'; |
|
| 3316 | + } |
|
| 3142 | 3317 | |
| 3143 | 3318 | if (!$support_js || isset($_GET['xml'])) |
| 3144 | 3319 | { |
@@ -3178,8 +3353,9 @@ discard block |
||
| 3178 | 3353 | |
| 3179 | 3354 | // Loop through and fix these... |
| 3180 | 3355 | $new_settings = array(); |
| 3181 | - if ($command_line) |
|
| 3182 | - echo "\n" . 'Fixing some settings...'; |
|
| 3356 | + if ($command_line) { |
|
| 3357 | + echo "\n" . 'Fixing some settings...'; |
|
| 3358 | + } |
|
| 3183 | 3359 | |
| 3184 | 3360 | foreach ($serialized_settings as $var) |
| 3185 | 3361 | { |
@@ -3187,22 +3363,24 @@ discard block |
||
| 3187 | 3363 | { |
| 3188 | 3364 | // Attempt to unserialize the setting |
| 3189 | 3365 | $temp = @safe_unserialize($modSettings[$var]); |
| 3190 | - if (!$temp && $command_line) |
|
| 3191 | - echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
| 3192 | - elseif ($temp !== false) |
|
| 3193 | - $new_settings[$var] = json_encode($temp); |
|
| 3366 | + if (!$temp && $command_line) { |
|
| 3367 | + echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
| 3368 | + } elseif ($temp !== false) { |
|
| 3369 | + $new_settings[$var] = json_encode($temp); |
|
| 3370 | + } |
|
| 3194 | 3371 | } |
| 3195 | 3372 | } |
| 3196 | 3373 | |
| 3197 | 3374 | // Update everything at once |
| 3198 | - if (!function_exists('cache_put_data')) |
|
| 3199 | - require_once($sourcedir . '/Load.php'); |
|
| 3375 | + if (!function_exists('cache_put_data')) { |
|
| 3376 | + require_once($sourcedir . '/Load.php'); |
|
| 3377 | + } |
|
| 3200 | 3378 | updateSettings($new_settings, true); |
| 3201 | 3379 | |
| 3202 | - if ($command_line) |
|
| 3203 | - echo ' done.'; |
|
| 3204 | - } |
|
| 3205 | - elseif ($table == 'themes') |
|
| 3380 | + if ($command_line) { |
|
| 3381 | + echo ' done.'; |
|
| 3382 | + } |
|
| 3383 | + } elseif ($table == 'themes') |
|
| 3206 | 3384 | { |
| 3207 | 3385 | // Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point... |
| 3208 | 3386 | $query = $smcFunc['db_query']('', ' |
@@ -3221,10 +3399,11 @@ discard block |
||
| 3221 | 3399 | |
| 3222 | 3400 | if ($command_line) |
| 3223 | 3401 | { |
| 3224 | - if ($temp === false) |
|
| 3225 | - echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
| 3226 | - else |
|
| 3227 | - echo "\n" . 'Fixing admin preferences...'; |
|
| 3402 | + if ($temp === false) { |
|
| 3403 | + echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
| 3404 | + } else { |
|
| 3405 | + echo "\n" . 'Fixing admin preferences...'; |
|
| 3406 | + } |
|
| 3228 | 3407 | } |
| 3229 | 3408 | |
| 3230 | 3409 | if ($temp !== false) |
@@ -3246,15 +3425,15 @@ discard block |
||
| 3246 | 3425 | ) |
| 3247 | 3426 | ); |
| 3248 | 3427 | |
| 3249 | - if ($command_line) |
|
| 3250 | - echo ' done.'; |
|
| 3428 | + if ($command_line) { |
|
| 3429 | + echo ' done.'; |
|
| 3430 | + } |
|
| 3251 | 3431 | } |
| 3252 | 3432 | } |
| 3253 | 3433 | |
| 3254 | 3434 | $smcFunc['db_free_result']($query); |
| 3255 | 3435 | } |
| 3256 | - } |
|
| 3257 | - else |
|
| 3436 | + } else |
|
| 3258 | 3437 | { |
| 3259 | 3438 | // First item is always the key... |
| 3260 | 3439 | $key = $info[0]; |
@@ -3265,8 +3444,7 @@ discard block |
||
| 3265 | 3444 | { |
| 3266 | 3445 | $col_select = $info[1]; |
| 3267 | 3446 | $where = ' WHERE ' . $info[1] . ' != {empty}'; |
| 3268 | - } |
|
| 3269 | - else |
|
| 3447 | + } else |
|
| 3270 | 3448 | { |
| 3271 | 3449 | $col_select = implode(', ', $info); |
| 3272 | 3450 | } |
@@ -3299,8 +3477,7 @@ discard block |
||
| 3299 | 3477 | if ($temp === false && $command_line) |
| 3300 | 3478 | { |
| 3301 | 3479 | echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n"; |
| 3302 | - } |
|
| 3303 | - else |
|
| 3480 | + } else |
|
| 3304 | 3481 | { |
| 3305 | 3482 | $row[$col] = json_encode($temp); |
| 3306 | 3483 | |
@@ -3325,16 +3502,18 @@ discard block |
||
| 3325 | 3502 | } |
| 3326 | 3503 | } |
| 3327 | 3504 | |
| 3328 | - if ($command_line) |
|
| 3329 | - echo ' done.'; |
|
| 3505 | + if ($command_line) { |
|
| 3506 | + echo ' done.'; |
|
| 3507 | + } |
|
| 3330 | 3508 | |
| 3331 | 3509 | // Free up some memory... |
| 3332 | 3510 | $smcFunc['db_free_result']($query); |
| 3333 | 3511 | } |
| 3334 | 3512 | } |
| 3335 | 3513 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 3336 | - if (isset($_GET['xml'])) |
|
| 3337 | - return upgradeExit(); |
|
| 3514 | + if (isset($_GET['xml'])) { |
|
| 3515 | + return upgradeExit(); |
|
| 3516 | + } |
|
| 3338 | 3517 | } |
| 3339 | 3518 | |
| 3340 | 3519 | if ($command_line) |
@@ -3349,8 +3528,9 @@ discard block |
||
| 3349 | 3528 | |
| 3350 | 3529 | $_GET['substep'] = 0; |
| 3351 | 3530 | // Make sure we move on! |
| 3352 | - if ($command_line) |
|
| 3353 | - return DeleteUpgrade(); |
|
| 3531 | + if ($command_line) { |
|
| 3532 | + return DeleteUpgrade(); |
|
| 3533 | + } |
|
| 3354 | 3534 | |
| 3355 | 3535 | return true; |
| 3356 | 3536 | } |
@@ -3407,14 +3587,16 @@ discard block |
||
| 3407 | 3587 | global $upcontext, $txt, $settings; |
| 3408 | 3588 | |
| 3409 | 3589 | // Don't call me twice! |
| 3410 | - if (!empty($upcontext['chmod_called'])) |
|
| 3411 | - return; |
|
| 3590 | + if (!empty($upcontext['chmod_called'])) { |
|
| 3591 | + return; |
|
| 3592 | + } |
|
| 3412 | 3593 | |
| 3413 | 3594 | $upcontext['chmod_called'] = true; |
| 3414 | 3595 | |
| 3415 | 3596 | // Nothing? |
| 3416 | - if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) |
|
| 3417 | - return; |
|
| 3597 | + if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) { |
|
| 3598 | + return; |
|
| 3599 | + } |
|
| 3418 | 3600 | |
| 3419 | 3601 | // Was it a problem with Windows? |
| 3420 | 3602 | if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess') |
@@ -3446,11 +3628,12 @@ discard block |
||
| 3446 | 3628 | content.write(\'<div class="windowbg description">\n\t\t\t<h4>', $txt['upgrade_ftp_files'], '</h4>\n\t\t\t\'); |
| 3447 | 3629 | content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');'; |
| 3448 | 3630 | |
| 3449 | - if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') |
|
| 3450 | - echo ' |
|
| 3631 | + if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') { |
|
| 3632 | + echo ' |
|
| 3451 | 3633 | content.write(\'<hr>\n\t\t\t\'); |
| 3452 | 3634 | content.write(\'<p>', $txt['upgrade_ftp_shell'], '</p>\n\t\t\t\'); |
| 3453 | 3635 | content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');'; |
| 3636 | + } |
|
| 3454 | 3637 | |
| 3455 | 3638 | echo ' |
| 3456 | 3639 | content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\'); |
@@ -3458,16 +3641,18 @@ discard block |
||
| 3458 | 3641 | } |
| 3459 | 3642 | </script>'; |
| 3460 | 3643 | |
| 3461 | - if (!empty($upcontext['chmod']['ftp_error'])) |
|
| 3462 | - echo ' |
|
| 3644 | + if (!empty($upcontext['chmod']['ftp_error'])) { |
|
| 3645 | + echo ' |
|
| 3463 | 3646 | <div class="error_message red"> |
| 3464 | 3647 | <p>', $txt['upgrade_ftp_error'], '<p> |
| 3465 | 3648 | <code>', $upcontext['chmod']['ftp_error'], '</code> |
| 3466 | 3649 | </div>'; |
| 3650 | + } |
|
| 3467 | 3651 | |
| 3468 | - if (empty($upcontext['chmod_in_form'])) |
|
| 3469 | - echo ' |
|
| 3652 | + if (empty($upcontext['chmod_in_form'])) { |
|
| 3653 | + echo ' |
|
| 3470 | 3654 | <form action="', $upcontext['form_url'], '" method="post">'; |
| 3655 | + } |
|
| 3471 | 3656 | |
| 3472 | 3657 | echo ' |
| 3473 | 3658 | <dl class="settings"> |
@@ -3509,9 +3694,10 @@ discard block |
||
| 3509 | 3694 | <input type="submit" value="', $txt['ftp_connect'], '" class="button"> |
| 3510 | 3695 | </div>'; |
| 3511 | 3696 | |
| 3512 | - if (empty($upcontext['chmod_in_form'])) |
|
| 3513 | - echo ' |
|
| 3697 | + if (empty($upcontext['chmod_in_form'])) { |
|
| 3698 | + echo ' |
|
| 3514 | 3699 | </form>'; |
| 3700 | + } |
|
| 3515 | 3701 | |
| 3516 | 3702 | echo ' |
| 3517 | 3703 | </div><!-- .panel -->'; |
@@ -3575,9 +3761,10 @@ discard block |
||
| 3575 | 3761 | <h2>', $txt['upgrade_progress'], '</h2> |
| 3576 | 3762 | <ul>'; |
| 3577 | 3763 | |
| 3578 | - foreach ($upcontext['steps'] as $num => $step) |
|
| 3579 | - echo ' |
|
| 3764 | + foreach ($upcontext['steps'] as $num => $step) { |
|
| 3765 | + echo ' |
|
| 3580 | 3766 | <li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
| 3767 | + } |
|
| 3581 | 3768 | |
| 3582 | 3769 | echo ' |
| 3583 | 3770 | </ul> |
@@ -3590,13 +3777,14 @@ discard block |
||
| 3590 | 3777 | <span id="overall_text">', $upcontext['overall_percent'], '%</span> |
| 3591 | 3778 | </div>'; |
| 3592 | 3779 | |
| 3593 | - if (isset($upcontext['step_progress'])) |
|
| 3594 | - echo ' |
|
| 3780 | + if (isset($upcontext['step_progress'])) { |
|
| 3781 | + echo ' |
|
| 3595 | 3782 | <div id="progress_bar_step" class="progress_bar progress_yellow"> |
| 3596 | 3783 | <h3>', $txt['upgrade_step_progress'], '</h3> |
| 3597 | 3784 | <div id="step_progress" class="bar" style="width: ', $upcontext['step_progress'], '%;"></div> |
| 3598 | 3785 | <span id="step_text">', $upcontext['step_progress'], '%</span> |
| 3599 | 3786 | </div>'; |
| 3787 | + } |
|
| 3600 | 3788 | |
| 3601 | 3789 | echo ' |
| 3602 | 3790 | <h3>', isset($upcontext['substep_progress_name']) ? trim(strtr($upcontext['substep_progress_name'], array('.' => ''))) : '', '</h3> |
@@ -3627,31 +3815,35 @@ discard block |
||
| 3627 | 3815 | { |
| 3628 | 3816 | global $upcontext, $txt; |
| 3629 | 3817 | |
| 3630 | - if (!empty($upcontext['pause'])) |
|
| 3631 | - echo ' |
|
| 3818 | + if (!empty($upcontext['pause'])) { |
|
| 3819 | + echo ' |
|
| 3632 | 3820 | <em>', $txt['upgrade_incomplete'], '.</em><br> |
| 3633 | 3821 | |
| 3634 | 3822 | <h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2> |
| 3635 | 3823 | <h3> |
| 3636 | 3824 | ', $txt['upgrade_paused_overload'], ' |
| 3637 | 3825 | </h3>'; |
| 3826 | + } |
|
| 3638 | 3827 | |
| 3639 | - if (!empty($upcontext['custom_warning'])) |
|
| 3640 | - echo ' |
|
| 3828 | + if (!empty($upcontext['custom_warning'])) { |
|
| 3829 | + echo ' |
|
| 3641 | 3830 | <div class="errorbox"> |
| 3642 | 3831 | <h3>', $txt['upgrade_note'], '</h3> |
| 3643 | 3832 | ', $upcontext['custom_warning'], ' |
| 3644 | 3833 | </div>'; |
| 3834 | + } |
|
| 3645 | 3835 | |
| 3646 | 3836 | echo ' |
| 3647 | 3837 | <div class="righttext" style="margin: 1ex;">'; |
| 3648 | 3838 | |
| 3649 | - if (!empty($upcontext['continue'])) |
|
| 3650 | - echo ' |
|
| 3839 | + if (!empty($upcontext['continue'])) { |
|
| 3840 | + echo ' |
|
| 3651 | 3841 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button">'; |
| 3652 | - if (!empty($upcontext['skip'])) |
|
| 3653 | - echo ' |
|
| 3842 | + } |
|
| 3843 | + if (!empty($upcontext['skip'])) { |
|
| 3844 | + echo ' |
|
| 3654 | 3845 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button">'; |
| 3846 | + } |
|
| 3655 | 3847 | |
| 3656 | 3848 | echo ' |
| 3657 | 3849 | </div> |
@@ -3702,11 +3894,12 @@ discard block |
||
| 3702 | 3894 | echo '<', '?xml version="1.0" encoding="UTF-8"?', '> |
| 3703 | 3895 | <smf>'; |
| 3704 | 3896 | |
| 3705 | - if (!empty($upcontext['get_data'])) |
|
| 3706 | - foreach ($upcontext['get_data'] as $k => $v) |
|
| 3897 | + if (!empty($upcontext['get_data'])) { |
|
| 3898 | + foreach ($upcontext['get_data'] as $k => $v) |
|
| 3707 | 3899 | echo ' |
| 3708 | 3900 | <get key="', $k, '">', $v, '</get>'; |
| 3709 | -} |
|
| 3901 | + } |
|
| 3902 | + } |
|
| 3710 | 3903 | |
| 3711 | 3904 | function template_xml_below() |
| 3712 | 3905 | { |
@@ -3746,20 +3939,22 @@ discard block |
||
| 3746 | 3939 | template_chmod(); |
| 3747 | 3940 | |
| 3748 | 3941 | // For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade! |
| 3749 | - if ($upcontext['is_large_forum']) |
|
| 3750 | - echo ' |
|
| 3942 | + if ($upcontext['is_large_forum']) { |
|
| 3943 | + echo ' |
|
| 3751 | 3944 | <div class="errorbox"> |
| 3752 | 3945 | <h3>', $txt['upgrade_warning'], '</h3> |
| 3753 | 3946 | ', $txt['upgrade_warning_lots_data'], ' |
| 3754 | 3947 | </div>'; |
| 3948 | + } |
|
| 3755 | 3949 | |
| 3756 | 3950 | // A warning message? |
| 3757 | - if (!empty($upcontext['warning'])) |
|
| 3758 | - echo ' |
|
| 3951 | + if (!empty($upcontext['warning'])) { |
|
| 3952 | + echo ' |
|
| 3759 | 3953 | <div class="errorbox"> |
| 3760 | 3954 | <h3>', $txt['upgrade_warning'], '</h3> |
| 3761 | 3955 | ', $upcontext['warning'], ' |
| 3762 | 3956 | </div>'; |
| 3957 | + } |
|
| 3763 | 3958 | |
| 3764 | 3959 | // Paths are incorrect? |
| 3765 | 3960 | echo ' |
@@ -3772,36 +3967,40 @@ discard block |
||
| 3772 | 3967 | if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600)) |
| 3773 | 3968 | { |
| 3774 | 3969 | $ago = time() - $upcontext['started']; |
| 3775 | - if ($ago < 60) |
|
| 3776 | - $ago = $ago . ' seconds'; |
|
| 3777 | - elseif ($ago < 3600) |
|
| 3778 | - $ago = (int) ($ago / 60) . ' minutes'; |
|
| 3779 | - else |
|
| 3780 | - $ago = (int) ($ago / 3600) . ' hours'; |
|
| 3970 | + if ($ago < 60) { |
|
| 3971 | + $ago = $ago . ' seconds'; |
|
| 3972 | + } elseif ($ago < 3600) { |
|
| 3973 | + $ago = (int) ($ago / 60) . ' minutes'; |
|
| 3974 | + } else { |
|
| 3975 | + $ago = (int) ($ago / 3600) . ' hours'; |
|
| 3976 | + } |
|
| 3781 | 3977 | |
| 3782 | 3978 | $active = time() - $upcontext['updated']; |
| 3783 | - if ($active < 60) |
|
| 3784 | - $updated = $active . ' seconds'; |
|
| 3785 | - elseif ($active < 3600) |
|
| 3786 | - $updated = (int) ($active / 60) . ' minutes'; |
|
| 3787 | - else |
|
| 3788 | - $updated = (int) ($active / 3600) . ' hours'; |
|
| 3979 | + if ($active < 60) { |
|
| 3980 | + $updated = $active . ' seconds'; |
|
| 3981 | + } elseif ($active < 3600) { |
|
| 3982 | + $updated = (int) ($active / 60) . ' minutes'; |
|
| 3983 | + } else { |
|
| 3984 | + $updated = (int) ($active / 3600) . ' hours'; |
|
| 3985 | + } |
|
| 3789 | 3986 | |
| 3790 | 3987 | echo ' |
| 3791 | 3988 | <div class="errorbox"> |
| 3792 | 3989 | <h3>', $txt['upgrade_warning'], '</h3> |
| 3793 | 3990 | <p>"', $upcontext['user']['name'], '" has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.</p>'; |
| 3794 | 3991 | |
| 3795 | - if ($active < 600) |
|
| 3796 | - echo ' |
|
| 3992 | + if ($active < 600) { |
|
| 3993 | + echo ' |
|
| 3797 | 3994 | <p>', $txt['upgrade_run_script'], ' ', $upcontext['user']['name'],' ', $txt['upgrade_run_script2'], '</p>'; |
| 3995 | + } |
|
| 3798 | 3996 | |
| 3799 | - if ($active > $upcontext['inactive_timeout']) |
|
| 3800 | - echo ' |
|
| 3997 | + if ($active > $upcontext['inactive_timeout']) { |
|
| 3998 | + echo ' |
|
| 3801 | 3999 | <p>',$txt['upgrade_run'], '</p>'; |
| 3802 | - else |
|
| 3803 | - echo ' |
|
| 4000 | + } else { |
|
| 4001 | + echo ' |
|
| 3804 | 4002 | <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>'; |
| 4003 | + } |
|
| 3805 | 4004 | |
| 3806 | 4005 | echo ' |
| 3807 | 4006 | </div>'; |
@@ -3817,9 +4016,10 @@ discard block |
||
| 3817 | 4016 | <dd> |
| 3818 | 4017 | <input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', '>'; |
| 3819 | 4018 | |
| 3820 | - if (!empty($upcontext['username_incorrect'])) |
|
| 3821 | - echo ' |
|
| 4019 | + if (!empty($upcontext['username_incorrect'])) { |
|
| 4020 | + echo ' |
|
| 3822 | 4021 | <div class="smalltext red">', $txt['upgrade_wrong_username'], '</div>'; |
| 4022 | + } |
|
| 3823 | 4023 | |
| 3824 | 4024 | echo ' |
| 3825 | 4025 | </dd> |
@@ -3830,9 +4030,10 @@ discard block |
||
| 3830 | 4030 | <input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', '> |
| 3831 | 4031 | <input type="hidden" name="hash_passwrd" value="">'; |
| 3832 | 4032 | |
| 3833 | - if (!empty($upcontext['password_failed'])) |
|
| 3834 | - echo ' |
|
| 4033 | + if (!empty($upcontext['password_failed'])) { |
|
| 4034 | + echo ' |
|
| 3835 | 4035 | <div class="smalltext red">', $txt['upgrade_wrong_password'], '</div>'; |
| 4036 | + } |
|
| 3836 | 4037 | |
| 3837 | 4038 | echo ' |
| 3838 | 4039 | </dd>'; |
@@ -3900,12 +4101,13 @@ discard block |
||
| 3900 | 4101 | <form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">'; |
| 3901 | 4102 | |
| 3902 | 4103 | // Warning message? |
| 3903 | - if (!empty($upcontext['upgrade_options_warning'])) |
|
| 3904 | - echo ' |
|
| 4104 | + if (!empty($upcontext['upgrade_options_warning'])) { |
|
| 4105 | + echo ' |
|
| 3905 | 4106 | <div class="errorbox"> |
| 3906 | 4107 | <h3>Warning!</h3> |
| 3907 | 4108 | ', $upcontext['upgrade_options_warning'], ' |
| 3908 | 4109 | </div>'; |
| 4110 | + } |
|
| 3909 | 4111 | |
| 3910 | 4112 | echo ' |
| 3911 | 4113 | <ul class="upgrade_settings"> |
@@ -3934,12 +4136,13 @@ discard block |
||
| 3934 | 4136 | <label for="empty_error">', $txt['upgrade_empty_errlog'], '</label> |
| 3935 | 4137 | </li>'; |
| 3936 | 4138 | |
| 3937 | - if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) |
|
| 3938 | - echo ' |
|
| 4139 | + if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) { |
|
| 4140 | + echo ' |
|
| 3939 | 4141 | <li> |
| 3940 | 4142 | <input type="checkbox" name="delete_karma" id="delete_karma" value="1"> |
| 3941 | 4143 | <label for="delete_karma">', $txt['upgrade_delete_karma'], '</label> |
| 3942 | 4144 | </li>'; |
| 4145 | + } |
|
| 3943 | 4146 | |
| 3944 | 4147 | echo ' |
| 3945 | 4148 | <li> |
@@ -3973,10 +4176,11 @@ discard block |
||
| 3973 | 4176 | </div>'; |
| 3974 | 4177 | |
| 3975 | 4178 | // Dont any tables so far? |
| 3976 | - if (!empty($upcontext['previous_tables'])) |
|
| 3977 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4179 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4180 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 3978 | 4181 | echo ' |
| 3979 | 4182 | <br>', $txt['upgrade_completed_table'], ' "', $table, '".'; |
| 4183 | + } |
|
| 3980 | 4184 | |
| 3981 | 4185 | echo ' |
| 3982 | 4186 | <h3 id="current_tab"> |
@@ -4015,12 +4219,13 @@ discard block |
||
| 4015 | 4219 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4016 | 4220 | |
| 4017 | 4221 | // If debug flood the screen. |
| 4018 | - if ($is_debug) |
|
| 4019 | - echo ' |
|
| 4222 | + if ($is_debug) { |
|
| 4223 | + echo ' |
|
| 4020 | 4224 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 4021 | 4225 | |
| 4022 | 4226 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4023 | 4227 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4228 | + } |
|
| 4024 | 4229 | |
| 4025 | 4230 | echo ' |
| 4026 | 4231 | // Get the next update... |
@@ -4053,8 +4258,9 @@ discard block |
||
| 4053 | 4258 | { |
| 4054 | 4259 | global $upcontext, $support_js, $is_debug, $timeLimitThreshold, $txt; |
| 4055 | 4260 | |
| 4056 | - if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) |
|
| 4057 | - $is_debug = true; |
|
| 4261 | + if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) { |
|
| 4262 | + $is_debug = true; |
|
| 4263 | + } |
|
| 4058 | 4264 | |
| 4059 | 4265 | echo ' |
| 4060 | 4266 | <h3>', $txt['upgrade_db_changes'], '</h3> |
@@ -4069,8 +4275,9 @@ discard block |
||
| 4069 | 4275 | { |
| 4070 | 4276 | foreach ($upcontext['actioned_items'] as $num => $item) |
| 4071 | 4277 | { |
| 4072 | - if ($num != 0) |
|
| 4073 | - echo ' Successful!'; |
|
| 4278 | + if ($num != 0) { |
|
| 4279 | + echo ' Successful!'; |
|
| 4280 | + } |
|
| 4074 | 4281 | echo '<br>' . $item; |
| 4075 | 4282 | } |
| 4076 | 4283 | if (!empty($upcontext['changes_complete'])) |
@@ -4083,29 +4290,33 @@ discard block |
||
| 4083 | 4290 | $seconds = intval($active % 60); |
| 4084 | 4291 | |
| 4085 | 4292 | $totalTime = ''; |
| 4086 | - if ($hours > 0) |
|
| 4087 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4088 | - if ($minutes > 0) |
|
| 4089 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4090 | - if ($seconds > 0) |
|
| 4091 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4293 | + if ($hours > 0) { |
|
| 4294 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4295 | + } |
|
| 4296 | + if ($minutes > 0) { |
|
| 4297 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4298 | + } |
|
| 4299 | + if ($seconds > 0) { |
|
| 4300 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4301 | + } |
|
| 4092 | 4302 | } |
| 4093 | 4303 | |
| 4094 | - if ($is_debug && !empty($totalTime)) |
|
| 4095 | - echo ' Successful! Completed in ', $totalTime, '<br>'; |
|
| 4096 | - else |
|
| 4097 | - echo ' Successful!<br>'; |
|
| 4304 | + if ($is_debug && !empty($totalTime)) { |
|
| 4305 | + echo ' Successful! Completed in ', $totalTime, '<br>'; |
|
| 4306 | + } else { |
|
| 4307 | + echo ' Successful!<br>'; |
|
| 4308 | + } |
|
| 4098 | 4309 | |
| 4099 | 4310 | echo ' |
| 4100 | 4311 | <p id="commess">', $txt['upgrade_db_complete'], '</p>'; |
| 4101 | 4312 | } |
| 4102 | - } |
|
| 4103 | - else |
|
| 4313 | + } else |
|
| 4104 | 4314 | { |
| 4105 | 4315 | // Tell them how many files we have in total. |
| 4106 | - if ($upcontext['file_count'] > 1) |
|
| 4107 | - echo ' |
|
| 4316 | + if ($upcontext['file_count'] > 1) { |
|
| 4317 | + echo ' |
|
| 4108 | 4318 | <strong id="info1">', $txt['upgrade_script'], ' <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>'; |
| 4319 | + } |
|
| 4109 | 4320 | |
| 4110 | 4321 | echo ' |
| 4111 | 4322 | <h3 id="info2"> |
@@ -4123,19 +4334,23 @@ discard block |
||
| 4123 | 4334 | $seconds = intval($active % 60); |
| 4124 | 4335 | |
| 4125 | 4336 | $totalTime = ''; |
| 4126 | - if ($hours > 0) |
|
| 4127 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4128 | - if ($minutes > 0) |
|
| 4129 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4130 | - if ($seconds > 0) |
|
| 4131 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4337 | + if ($hours > 0) { |
|
| 4338 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4339 | + } |
|
| 4340 | + if ($minutes > 0) { |
|
| 4341 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4342 | + } |
|
| 4343 | + if ($seconds > 0) { |
|
| 4344 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4345 | + } |
|
| 4132 | 4346 | } |
| 4133 | 4347 | |
| 4134 | 4348 | echo ' |
| 4135 | 4349 | <p id="upgradeCompleted">'; |
| 4136 | 4350 | |
| 4137 | - if (!empty($totalTime)) |
|
| 4138 | - echo 'Completed in ', $totalTime, ''; |
|
| 4351 | + if (!empty($totalTime)) { |
|
| 4352 | + echo 'Completed in ', $totalTime, ''; |
|
| 4353 | + } |
|
| 4139 | 4354 | |
| 4140 | 4355 | echo ' |
| 4141 | 4356 | </p> |
@@ -4172,9 +4387,10 @@ discard block |
||
| 4172 | 4387 | var getData = ""; |
| 4173 | 4388 | var debugItems = ', $upcontext['debug_items'], ';'; |
| 4174 | 4389 | |
| 4175 | - if ($is_debug) |
|
| 4176 | - echo ' |
|
| 4390 | + if ($is_debug) { |
|
| 4391 | + echo ' |
|
| 4177 | 4392 | var upgradeStartTime = ' . $upcontext['started'] . ';'; |
| 4393 | + } |
|
| 4178 | 4394 | |
| 4179 | 4395 | echo ' |
| 4180 | 4396 | function getNextItem() |
@@ -4214,9 +4430,10 @@ discard block |
||
| 4214 | 4430 | document.getElementById("error_block").style.display = ""; |
| 4215 | 4431 | setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));'; |
| 4216 | 4432 | |
| 4217 | - if ($is_debug) |
|
| 4218 | - echo ' |
|
| 4433 | + if ($is_debug) { |
|
| 4434 | + echo ' |
|
| 4219 | 4435 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span class="red">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
| 4436 | + } |
|
| 4220 | 4437 | |
| 4221 | 4438 | echo ' |
| 4222 | 4439 | } |
@@ -4237,9 +4454,10 @@ discard block |
||
| 4237 | 4454 | document.getElementById("error_block").style.display = ""; |
| 4238 | 4455 | setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);'; |
| 4239 | 4456 | |
| 4240 | - if ($is_debug) |
|
| 4241 | - echo ' |
|
| 4457 | + if ($is_debug) { |
|
| 4458 | + echo ' |
|
| 4242 | 4459 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span class="red">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
| 4460 | + } |
|
| 4243 | 4461 | |
| 4244 | 4462 | echo ' |
| 4245 | 4463 | } |
@@ -4296,8 +4514,8 @@ discard block |
||
| 4296 | 4514 | if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ') |
| 4297 | 4515 | {'; |
| 4298 | 4516 | |
| 4299 | - if ($is_debug) |
|
| 4300 | - echo ' |
|
| 4517 | + if ($is_debug) { |
|
| 4518 | + echo ' |
|
| 4301 | 4519 | document.getElementById(\'debug_section\').style.display = "none"; |
| 4302 | 4520 | |
| 4303 | 4521 | var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue); |
@@ -4315,6 +4533,7 @@ discard block |
||
| 4315 | 4533 | totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : ""); |
| 4316 | 4534 | |
| 4317 | 4535 | setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);'; |
| 4536 | + } |
|
| 4318 | 4537 | |
| 4319 | 4538 | echo ' |
| 4320 | 4539 | |
@@ -4322,9 +4541,10 @@ discard block |
||
| 4322 | 4541 | document.getElementById(\'contbutt\').disabled = 0; |
| 4323 | 4542 | document.getElementById(\'database_done\').value = 1;'; |
| 4324 | 4543 | |
| 4325 | - if ($upcontext['file_count'] > 1) |
|
| 4326 | - echo ' |
|
| 4544 | + if ($upcontext['file_count'] > 1) { |
|
| 4545 | + echo ' |
|
| 4327 | 4546 | document.getElementById(\'info1\').style.display = "none";'; |
| 4547 | + } |
|
| 4328 | 4548 | |
| 4329 | 4549 | echo ' |
| 4330 | 4550 | document.getElementById(\'info2\').style.display = "none"; |
@@ -4337,9 +4557,10 @@ discard block |
||
| 4337 | 4557 | lastItem = 0; |
| 4338 | 4558 | prevFile = curFile;'; |
| 4339 | 4559 | |
| 4340 | - if ($is_debug) |
|
| 4341 | - echo ' |
|
| 4560 | + if ($is_debug) { |
|
| 4561 | + echo ' |
|
| 4342 | 4562 | setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');'; |
| 4563 | + } |
|
| 4343 | 4564 | |
| 4344 | 4565 | echo ' |
| 4345 | 4566 | getNextItem(); |
@@ -4347,8 +4568,8 @@ discard block |
||
| 4347 | 4568 | }'; |
| 4348 | 4569 | |
| 4349 | 4570 | // If debug scroll the screen. |
| 4350 | - if ($is_debug) |
|
| 4351 | - echo ' |
|
| 4571 | + if ($is_debug) { |
|
| 4572 | + echo ' |
|
| 4352 | 4573 | if (iLastSubStepProgress == -1) |
| 4353 | 4574 | { |
| 4354 | 4575 | // Give it consistent dots. |
@@ -4367,6 +4588,7 @@ discard block |
||
| 4367 | 4588 | |
| 4368 | 4589 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4369 | 4590 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4591 | + } |
|
| 4370 | 4592 | |
| 4371 | 4593 | echo ' |
| 4372 | 4594 | // Update the page. |
@@ -4427,9 +4649,10 @@ discard block |
||
| 4427 | 4649 | }'; |
| 4428 | 4650 | |
| 4429 | 4651 | // Start things off assuming we've not errored. |
| 4430 | - if (empty($upcontext['error_message'])) |
|
| 4431 | - echo ' |
|
| 4652 | + if (empty($upcontext['error_message'])) { |
|
| 4653 | + echo ' |
|
| 4432 | 4654 | getNextItem();'; |
| 4655 | + } |
|
| 4433 | 4656 | |
| 4434 | 4657 | echo ' |
| 4435 | 4658 | //# sourceURL=dynamicScript-dbch.js |
@@ -4447,18 +4670,21 @@ discard block |
||
| 4447 | 4670 | <item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item> |
| 4448 | 4671 | <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>'; |
| 4449 | 4672 | |
| 4450 | - if (!empty($upcontext['error_message'])) |
|
| 4451 | - echo ' |
|
| 4673 | + if (!empty($upcontext['error_message'])) { |
|
| 4674 | + echo ' |
|
| 4452 | 4675 | <error>', $upcontext['error_message'], '</error>'; |
| 4676 | + } |
|
| 4453 | 4677 | |
| 4454 | - if (!empty($upcontext['error_string'])) |
|
| 4455 | - echo ' |
|
| 4678 | + if (!empty($upcontext['error_string'])) { |
|
| 4679 | + echo ' |
|
| 4456 | 4680 | <sql>', $upcontext['error_string'], '</sql>'; |
| 4681 | + } |
|
| 4457 | 4682 | |
| 4458 | - if ($is_debug) |
|
| 4459 | - echo ' |
|
| 4683 | + if ($is_debug) { |
|
| 4684 | + echo ' |
|
| 4460 | 4685 | <curtime>', time(), '</curtime>'; |
| 4461 | -} |
|
| 4686 | + } |
|
| 4687 | + } |
|
| 4462 | 4688 | |
| 4463 | 4689 | // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications.... |
| 4464 | 4690 | function template_convert_utf8() |
@@ -4475,10 +4701,11 @@ discard block |
||
| 4475 | 4701 | </div>'; |
| 4476 | 4702 | |
| 4477 | 4703 | // Done any tables so far? |
| 4478 | - if (!empty($upcontext['previous_tables'])) |
|
| 4479 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4704 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4705 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4480 | 4706 | echo ' |
| 4481 | 4707 | <br>', $txt['upgrade_completed_table'], ' "', $table, '".'; |
| 4708 | + } |
|
| 4482 | 4709 | |
| 4483 | 4710 | echo ' |
| 4484 | 4711 | <h3 id="current_tab"> |
@@ -4486,9 +4713,10 @@ discard block |
||
| 4486 | 4713 | </h3>'; |
| 4487 | 4714 | |
| 4488 | 4715 | // If we dropped their index, let's let them know |
| 4489 | - if ($upcontext['dropping_index']) |
|
| 4490 | - echo ' |
|
| 4716 | + if ($upcontext['dropping_index']) { |
|
| 4717 | + echo ' |
|
| 4491 | 4718 | <p id="indexmsg" style="font-weight: bold; font-style: italic; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">', $txt['upgrade_fulltext'], '</p>'; |
| 4719 | + } |
|
| 4492 | 4720 | |
| 4493 | 4721 | // Completion notification |
| 4494 | 4722 | echo ' |
@@ -4525,12 +4753,13 @@ discard block |
||
| 4525 | 4753 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4526 | 4754 | |
| 4527 | 4755 | // If debug flood the screen. |
| 4528 | - if ($is_debug) |
|
| 4529 | - echo ' |
|
| 4756 | + if ($is_debug) { |
|
| 4757 | + echo ' |
|
| 4530 | 4758 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 4531 | 4759 | |
| 4532 | 4760 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4533 | 4761 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4762 | + } |
|
| 4534 | 4763 | |
| 4535 | 4764 | echo ' |
| 4536 | 4765 | // Get the next update... |
@@ -4576,10 +4805,11 @@ discard block |
||
| 4576 | 4805 | </div>'; |
| 4577 | 4806 | |
| 4578 | 4807 | // Dont any tables so far? |
| 4579 | - if (!empty($upcontext['previous_tables'])) |
|
| 4580 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4808 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4809 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4581 | 4810 | echo ' |
| 4582 | 4811 | <br>', $txt['upgrade_completed_table'], ' "', $table, '".'; |
| 4812 | + } |
|
| 4583 | 4813 | |
| 4584 | 4814 | echo ' |
| 4585 | 4815 | <h3 id="current_tab"> |
@@ -4588,9 +4818,10 @@ discard block |
||
| 4588 | 4818 | <p id="commess" style="display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">', $txt['upgrade_json_completed'], '</p>'; |
| 4589 | 4819 | |
| 4590 | 4820 | // Try to make sure substep was reset. |
| 4591 | - if ($upcontext['cur_table_num'] == $upcontext['table_count']) |
|
| 4592 | - echo ' |
|
| 4821 | + if ($upcontext['cur_table_num'] == $upcontext['table_count']) { |
|
| 4822 | + echo ' |
|
| 4593 | 4823 | <input type="hidden" name="substep" id="substep" value="0">'; |
| 4824 | + } |
|
| 4594 | 4825 | |
| 4595 | 4826 | // Continue please! |
| 4596 | 4827 | $upcontext['continue'] = $support_js ? 2 : 1; |
@@ -4623,12 +4854,13 @@ discard block |
||
| 4623 | 4854 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4624 | 4855 | |
| 4625 | 4856 | // If debug flood the screen. |
| 4626 | - if ($is_debug) |
|
| 4627 | - echo ' |
|
| 4857 | + if ($is_debug) { |
|
| 4858 | + echo ' |
|
| 4628 | 4859 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>', $txt['upgrade_completed_table'], ' "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 4629 | 4860 | |
| 4630 | 4861 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4631 | 4862 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4863 | + } |
|
| 4632 | 4864 | |
| 4633 | 4865 | echo ' |
| 4634 | 4866 | // Get the next update... |
@@ -4664,8 +4896,8 @@ discard block |
||
| 4664 | 4896 | <h3>', $txt['upgrade_done'], ' <a href="', $boardurl, '/index.php">', $txt['upgrade_done2'], '</a>. ', $txt['upgrade_done3'], '</h3> |
| 4665 | 4897 | <form action="', $boardurl, '/index.php">'; |
| 4666 | 4898 | |
| 4667 | - if (!empty($upcontext['can_delete_script'])) |
|
| 4668 | - echo ' |
|
| 4899 | + if (!empty($upcontext['can_delete_script'])) { |
|
| 4900 | + echo ' |
|
| 4669 | 4901 | <label> |
| 4670 | 4902 | <input type="checkbox" id="delete_self" onclick="doTheDelete(this);"> ', $txt['upgrade_delete_now'], ' |
| 4671 | 4903 | </label> |
@@ -4679,6 +4911,7 @@ discard block |
||
| 4679 | 4911 | } |
| 4680 | 4912 | </script> |
| 4681 | 4913 | <img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>'; |
| 4914 | + } |
|
| 4682 | 4915 | |
| 4683 | 4916 | $active = time() - $upcontext['started']; |
| 4684 | 4917 | $hours = floor($active / 3600); |
@@ -4688,17 +4921,21 @@ discard block |
||
| 4688 | 4921 | if ($is_debug) |
| 4689 | 4922 | { |
| 4690 | 4923 | $totalTime = ''; |
| 4691 | - if ($hours > 0) |
|
| 4692 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4693 | - if ($minutes > 0) |
|
| 4694 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4695 | - if ($seconds > 0) |
|
| 4696 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4924 | + if ($hours > 0) { |
|
| 4925 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4926 | + } |
|
| 4927 | + if ($minutes > 0) { |
|
| 4928 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4929 | + } |
|
| 4930 | + if ($seconds > 0) { |
|
| 4931 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4932 | + } |
|
| 4697 | 4933 | } |
| 4698 | 4934 | |
| 4699 | - if ($is_debug && !empty($totalTime)) |
|
| 4700 | - echo ' |
|
| 4935 | + if ($is_debug && !empty($totalTime)) { |
|
| 4936 | + echo ' |
|
| 4701 | 4937 | <p> ', $txt['upgrade_completed_time'], ' ', $totalTime, '</p>'; |
| 4938 | + } |
|
| 4702 | 4939 | |
| 4703 | 4940 | echo ' |
| 4704 | 4941 | <p> |
@@ -4727,8 +4964,9 @@ discard block |
||
| 4727 | 4964 | |
| 4728 | 4965 | $current_substep = $_GET['substep']; |
| 4729 | 4966 | |
| 4730 | - if (empty($_GET['a'])) |
|
| 4731 | - $_GET['a'] = 0; |
|
| 4967 | + if (empty($_GET['a'])) { |
|
| 4968 | + $_GET['a'] = 0; |
|
| 4969 | + } |
|
| 4732 | 4970 | $step_progress['name'] = 'Converting ips'; |
| 4733 | 4971 | $step_progress['current'] = $_GET['a']; |
| 4734 | 4972 | |
@@ -4771,16 +5009,19 @@ discard block |
||
| 4771 | 5009 | 'empty' => '', |
| 4772 | 5010 | 'limit' => $limit, |
| 4773 | 5011 | )); |
| 4774 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 4775 | - $arIp[] = $row[$oldCol]; |
|
| 5012 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 5013 | + $arIp[] = $row[$oldCol]; |
|
| 5014 | + } |
|
| 4776 | 5015 | $smcFunc['db_free_result']($request); |
| 4777 | 5016 | |
| 4778 | 5017 | // Special case, null ip could keep us in a loop. |
| 4779 | - if (is_null($arIp[0])) |
|
| 4780 | - unset($arIp[0]); |
|
| 5018 | + if (is_null($arIp[0])) { |
|
| 5019 | + unset($arIp[0]); |
|
| 5020 | + } |
|
| 4781 | 5021 | |
| 4782 | - if (empty($arIp)) |
|
| 4783 | - $is_done = true; |
|
| 5022 | + if (empty($arIp)) { |
|
| 5023 | + $is_done = true; |
|
| 5024 | + } |
|
| 4784 | 5025 | |
| 4785 | 5026 | $updates = array(); |
| 4786 | 5027 | $cases = array(); |
@@ -4789,16 +5030,18 @@ discard block |
||
| 4789 | 5030 | { |
| 4790 | 5031 | $arIp[$i] = trim($arIp[$i]); |
| 4791 | 5032 | |
| 4792 | - if (empty($arIp[$i])) |
|
| 4793 | - continue; |
|
| 5033 | + if (empty($arIp[$i])) { |
|
| 5034 | + continue; |
|
| 5035 | + } |
|
| 4794 | 5036 | |
| 4795 | 5037 | $updates['ip' . $i] = $arIp[$i]; |
| 4796 | 5038 | $cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}'; |
| 4797 | 5039 | |
| 4798 | 5040 | if ($setSize > 0 && $i % $setSize === 0) |
| 4799 | 5041 | { |
| 4800 | - if (count($updates) == 1) |
|
| 4801 | - continue; |
|
| 5042 | + if (count($updates) == 1) { |
|
| 5043 | + continue; |
|
| 5044 | + } |
|
| 4802 | 5045 | |
| 4803 | 5046 | $updates['whereSet'] = array_values($updates); |
| 4804 | 5047 | $smcFunc['db_query']('', ' |
@@ -4832,8 +5075,7 @@ discard block |
||
| 4832 | 5075 | 'ip' => $ip |
| 4833 | 5076 | )); |
| 4834 | 5077 | } |
| 4835 | - } |
|
| 4836 | - else |
|
| 5078 | + } else |
|
| 4837 | 5079 | { |
| 4838 | 5080 | $updates['whereSet'] = array_values($updates); |
| 4839 | 5081 | $smcFunc['db_query']('', ' |
@@ -4847,9 +5089,9 @@ discard block |
||
| 4847 | 5089 | $updates |
| 4848 | 5090 | ); |
| 4849 | 5091 | } |
| 5092 | + } else { |
|
| 5093 | + $is_done = true; |
|
| 4850 | 5094 | } |
| 4851 | - else |
|
| 4852 | - $is_done = true; |
|
| 4853 | 5095 | |
| 4854 | 5096 | $_GET['a'] += $limit; |
| 4855 | 5097 | $step_progress['current'] = $_GET['a']; |
@@ -4875,10 +5117,11 @@ discard block |
||
| 4875 | 5117 | |
| 4876 | 5118 | $columns = $smcFunc['db_list_columns']($targetTable, true); |
| 4877 | 5119 | |
| 4878 | - if (isset($columns[$column])) |
|
| 4879 | - return $columns[$column]; |
|
| 4880 | - else |
|
| 4881 | - return null; |
|
| 4882 | -} |
|
| 5120 | + if (isset($columns[$column])) { |
|
| 5121 | + return $columns[$column]; |
|
| 5122 | + } else { |
|
| 5123 | + return null; |
|
| 5124 | + } |
|
| 5125 | + } |
|
| 4883 | 5126 | |
| 4884 | 5127 | ?> |
| 4885 | 5128 | \ No newline at end of file |
@@ -20,8 +20,9 @@ discard block |
||
| 20 | 20 | // ><html dir="ltr"><head><title>Error!</title></head><body>Sorry, this installer requires PHP!<div style="display: none;"> |
| 21 | 21 | |
| 22 | 22 | // Let's pull in useful classes |
| 23 | -if (!defined('SMF')) |
|
| 23 | +if (!defined('SMF')) { |
|
| 24 | 24 | define('SMF', 1); |
| 25 | +} |
|
| 25 | 26 | |
| 26 | 27 | require_once('Sources/Class-Package.php'); |
| 27 | 28 | |
@@ -63,10 +64,11 @@ discard block |
||
| 63 | 64 | |
| 64 | 65 | list ($charcode) = pg_fetch_row($request); |
| 65 | 66 | |
| 66 | - if ($charcode == 'UTF8') |
|
| 67 | - return true; |
|
| 68 | - else |
|
| 69 | - return false; |
|
| 67 | + if ($charcode == 'UTF8') { |
|
| 68 | + return true; |
|
| 69 | + } else { |
|
| 70 | + return false; |
|
| 71 | + } |
|
| 70 | 72 | }, |
| 71 | 73 | 'utf8_version' => '8.0', |
| 72 | 74 | 'utf8_version_check' => '$request = pg_query(\'SELECT version()\'); list ($version) = pg_fetch_row($request); list($pgl, $version) = explode(" ", $version); return $version;', |
@@ -76,12 +78,14 @@ discard block |
||
| 76 | 78 | $value = preg_replace('~[^A-Za-z0-9_\$]~', '', $value); |
| 77 | 79 | |
| 78 | 80 | // Is it reserved? |
| 79 | - if ($value == 'pg_') |
|
| 80 | - return $txt['error_db_prefix_reserved']; |
|
| 81 | + if ($value == 'pg_') { |
|
| 82 | + return $txt['error_db_prefix_reserved']; |
|
| 83 | + } |
|
| 81 | 84 | |
| 82 | 85 | // Is the prefix numeric? |
| 83 | - if (preg_match('~^\d~', $value)) |
|
| 84 | - return $txt['error_db_prefix_numeric']; |
|
| 86 | + if (preg_match('~^\d~', $value)) { |
|
| 87 | + return $txt['error_db_prefix_numeric']; |
|
| 88 | + } |
|
| 85 | 89 | |
| 86 | 90 | return true; |
| 87 | 91 | }, |
@@ -128,10 +132,11 @@ discard block |
||
| 128 | 132 | $incontext['skip'] = false; |
| 129 | 133 | |
| 130 | 134 | // Call the step and if it returns false that means pause! |
| 131 | - if (function_exists($step[2]) && $step[2]() === false) |
|
| 132 | - break; |
|
| 133 | - elseif (function_exists($step[2])) |
|
| 134 | - $incontext['current_step']++; |
|
| 135 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
| 136 | + break; |
|
| 137 | + } elseif (function_exists($step[2])) { |
|
| 138 | + $incontext['current_step']++; |
|
| 139 | + } |
|
| 135 | 140 | |
| 136 | 141 | // No warnings pass on. |
| 137 | 142 | $incontext['warning'] = ''; |
@@ -147,8 +152,9 @@ discard block |
||
| 147 | 152 | global $databases; |
| 148 | 153 | |
| 149 | 154 | // Just so people using older versions of PHP aren't left in the cold. |
| 150 | - if (!isset($_SERVER['PHP_SELF'])) |
|
| 151 | - $_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php'; |
|
| 155 | + if (!isset($_SERVER['PHP_SELF'])) { |
|
| 156 | + $_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php'; |
|
| 157 | + } |
|
| 152 | 158 | |
| 153 | 159 | // Enable error reporting for fatal errors. |
| 154 | 160 | error_reporting(E_ERROR | E_PARSE); |
@@ -164,21 +170,23 @@ discard block |
||
| 164 | 170 | { |
| 165 | 171 | ob_start(); |
| 166 | 172 | |
| 167 | - if (ini_get('session.save_handler') == 'user') |
|
| 168 | - @ini_set('session.save_handler', 'files'); |
|
| 169 | - if (function_exists('session_start')) |
|
| 170 | - @session_start(); |
|
| 171 | - } |
|
| 172 | - else |
|
| 173 | + if (ini_get('session.save_handler') == 'user') { |
|
| 174 | + @ini_set('session.save_handler', 'files'); |
|
| 175 | + } |
|
| 176 | + if (function_exists('session_start')) { |
|
| 177 | + @session_start(); |
|
| 178 | + } |
|
| 179 | + } else |
|
| 173 | 180 | { |
| 174 | 181 | ob_start('ob_gzhandler'); |
| 175 | 182 | |
| 176 | - if (ini_get('session.save_handler') == 'user') |
|
| 177 | - @ini_set('session.save_handler', 'files'); |
|
| 183 | + if (ini_get('session.save_handler') == 'user') { |
|
| 184 | + @ini_set('session.save_handler', 'files'); |
|
| 185 | + } |
|
| 178 | 186 | session_start(); |
| 179 | 187 | |
| 180 | - if (!headers_sent()) |
|
| 181 | - echo '<!DOCTYPE html> |
|
| 188 | + if (!headers_sent()) { |
|
| 189 | + echo '<!DOCTYPE html> |
|
| 182 | 190 | <html> |
| 183 | 191 | <head> |
| 184 | 192 | <title>', htmlspecialchars($_GET['pass_string']), '</title> |
@@ -187,14 +195,16 @@ discard block |
||
| 187 | 195 | <strong>', htmlspecialchars($_GET['pass_string']), '</strong> |
| 188 | 196 | </body> |
| 189 | 197 | </html>'; |
| 198 | + } |
|
| 190 | 199 | exit; |
| 191 | 200 | } |
| 192 | 201 | |
| 193 | 202 | // Add slashes, as long as they aren't already being added. |
| 194 | - if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) |
|
| 195 | - foreach ($_POST as $k => $v) |
|
| 203 | + if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) { |
|
| 204 | + foreach ($_POST as $k => $v) |
|
| 196 | 205 | if (strpos($k, 'password') === false && strpos($k, 'db_passwd') === false) |
| 197 | 206 | $_POST[$k] = addslashes($v); |
| 207 | + } |
|
| 198 | 208 | |
| 199 | 209 | // This is really quite simple; if ?delete is on the URL, delete the installer... |
| 200 | 210 | if (isset($_GET['delete'])) |
@@ -215,8 +225,7 @@ discard block |
||
| 215 | 225 | $ftp->close(); |
| 216 | 226 | |
| 217 | 227 | unset($_SESSION['installer_temp_ftp']); |
| 218 | - } |
|
| 219 | - else |
|
| 228 | + } else |
|
| 220 | 229 | { |
| 221 | 230 | @unlink(__FILE__); |
| 222 | 231 | |
@@ -230,10 +239,11 @@ discard block |
||
| 230 | 239 | // Now just redirect to a blank.png... |
| 231 | 240 | $secure = false; |
| 232 | 241 | |
| 233 | - if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') |
|
| 234 | - $secure = true; |
|
| 235 | - elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') |
|
| 236 | - $secure = true; |
|
| 242 | + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { |
|
| 243 | + $secure = true; |
|
| 244 | + } elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') { |
|
| 245 | + $secure = true; |
|
| 246 | + } |
|
| 237 | 247 | |
| 238 | 248 | header('location: http' . ($secure ? 's' : '') . '://' . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT']) . dirname($_SERVER['PHP_SELF']) . '/Themes/default/images/blank.png'); |
| 239 | 249 | exit; |
@@ -244,10 +254,11 @@ discard block |
||
| 244 | 254 | { |
| 245 | 255 | // Get PHP's default timezone, if set |
| 246 | 256 | $ini_tz = ini_get('date.timezone'); |
| 247 | - if (!empty($ini_tz)) |
|
| 248 | - $timezone_id = $ini_tz; |
|
| 249 | - else |
|
| 250 | - $timezone_id = ''; |
|
| 257 | + if (!empty($ini_tz)) { |
|
| 258 | + $timezone_id = $ini_tz; |
|
| 259 | + } else { |
|
| 260 | + $timezone_id = ''; |
|
| 261 | + } |
|
| 251 | 262 | |
| 252 | 263 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
| 253 | 264 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -277,8 +288,9 @@ discard block |
||
| 277 | 288 | $dir = dir(dirname(__FILE__) . '/Themes/default/languages'); |
| 278 | 289 | while ($entry = $dir->read()) |
| 279 | 290 | { |
| 280 | - if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') |
|
| 281 | - $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
| 291 | + if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') { |
|
| 292 | + $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
| 293 | + } |
|
| 282 | 294 | } |
| 283 | 295 | $dir->close(); |
| 284 | 296 | } |
@@ -325,10 +337,11 @@ discard block |
||
| 325 | 337 | } |
| 326 | 338 | |
| 327 | 339 | // Override the language file? |
| 328 | - if (isset($_GET['lang_file'])) |
|
| 329 | - $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
| 330 | - elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) |
|
| 331 | - $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
| 340 | + if (isset($_GET['lang_file'])) { |
|
| 341 | + $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
| 342 | + } elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) { |
|
| 343 | + $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
| 344 | + } |
|
| 332 | 345 | |
| 333 | 346 | // Make sure it exists, if it doesn't reset it. |
| 334 | 347 | 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'])) |
@@ -337,8 +350,9 @@ discard block |
||
| 337 | 350 | list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
| 338 | 351 | |
| 339 | 352 | // If we have english and some other language, use the other language. We Americans hate english :P. |
| 340 | - if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) |
|
| 341 | - list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
| 353 | + if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) { |
|
| 354 | + list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
| 355 | + } |
|
| 342 | 356 | } |
| 343 | 357 | |
| 344 | 358 | // And now include the actual language file itself. |
@@ -355,15 +369,18 @@ discard block |
||
| 355 | 369 | global $db_prefix, $db_connection, $sourcedir, $smcFunc, $modSettings; |
| 356 | 370 | global $db_server, $db_passwd, $db_type, $db_name, $db_user, $db_persist; |
| 357 | 371 | |
| 358 | - if (empty($sourcedir)) |
|
| 359 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 372 | + if (empty($sourcedir)) { |
|
| 373 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 374 | + } |
|
| 360 | 375 | |
| 361 | 376 | // Need this to check whether we need the database password. |
| 362 | 377 | require(dirname(__FILE__) . '/Settings.php'); |
| 363 | - if (!defined('SMF')) |
|
| 364 | - define('SMF', 1); |
|
| 365 | - if (empty($smcFunc)) |
|
| 366 | - $smcFunc = array(); |
|
| 378 | + if (!defined('SMF')) { |
|
| 379 | + define('SMF', 1); |
|
| 380 | + } |
|
| 381 | + if (empty($smcFunc)) { |
|
| 382 | + $smcFunc = array(); |
|
| 383 | + } |
|
| 367 | 384 | |
| 368 | 385 | $modSettings['disableQueryCheck'] = true; |
| 369 | 386 | |
@@ -371,8 +388,9 @@ discard block |
||
| 371 | 388 | if (!$db_connection) |
| 372 | 389 | { |
| 373 | 390 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
| 374 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
| 375 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
| 391 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
| 392 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
| 393 | + } |
|
| 376 | 394 | |
| 377 | 395 | $db_options = array('persist' => $db_persist); |
| 378 | 396 | $port = ''; |
@@ -383,19 +401,20 @@ discard block |
||
| 383 | 401 | if ($db_type == 'mysql') |
| 384 | 402 | { |
| 385 | 403 | $port = ((int) $_POST['db_port'] == ini_get($db_type . 'default_port')) ? '' : (int) $_POST['db_port']; |
| 386 | - } |
|
| 387 | - elseif ($db_type == 'postgresql') |
|
| 404 | + } elseif ($db_type == 'postgresql') |
|
| 388 | 405 | { |
| 389 | 406 | // PostgreSQL doesn't have a default port setting in php.ini, so just check against the default |
| 390 | 407 | $port = ((int) $_POST['db_port'] == 5432) ? '' : (int) $_POST['db_port']; |
| 391 | 408 | } |
| 392 | 409 | } |
| 393 | 410 | |
| 394 | - if (!empty($port)) |
|
| 395 | - $db_options['port'] = $port; |
|
| 411 | + if (!empty($port)) { |
|
| 412 | + $db_options['port'] = $port; |
|
| 413 | + } |
|
| 396 | 414 | |
| 397 | - if (!$db_connection) |
|
| 398 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options); |
|
| 415 | + if (!$db_connection) { |
|
| 416 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options); |
|
| 417 | + } |
|
| 399 | 418 | } |
| 400 | 419 | } |
| 401 | 420 | |
@@ -423,8 +442,9 @@ discard block |
||
| 423 | 442 | // @todo REMOVE THIS!! |
| 424 | 443 | else |
| 425 | 444 | { |
| 426 | - if (function_exists('doStep' . $_GET['step'])) |
|
| 427 | - call_user_func('doStep' . $_GET['step']); |
|
| 445 | + if (function_exists('doStep' . $_GET['step'])) { |
|
| 446 | + call_user_func('doStep' . $_GET['step']); |
|
| 447 | + } |
|
| 428 | 448 | } |
| 429 | 449 | // Show the footer. |
| 430 | 450 | template_install_below(); |
@@ -442,8 +462,9 @@ discard block |
||
| 442 | 462 | $incontext['sub_template'] = 'welcome_message'; |
| 443 | 463 | |
| 444 | 464 | // Done the submission? |
| 445 | - if (isset($_POST['contbutt'])) |
|
| 446 | - return true; |
|
| 465 | + if (isset($_POST['contbutt'])) { |
|
| 466 | + return true; |
|
| 467 | + } |
|
| 447 | 468 | |
| 448 | 469 | // See if we think they have already installed it? |
| 449 | 470 | if (is_readable(dirname(__FILE__) . '/Settings.php')) |
@@ -451,14 +472,17 @@ discard block |
||
| 451 | 472 | $probably_installed = 0; |
| 452 | 473 | foreach (file(dirname(__FILE__) . '/Settings.php') as $line) |
| 453 | 474 | { |
| 454 | - if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) |
|
| 455 | - $probably_installed++; |
|
| 456 | - if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) |
|
| 457 | - $probably_installed++; |
|
| 475 | + if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) { |
|
| 476 | + $probably_installed++; |
|
| 477 | + } |
|
| 478 | + if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) { |
|
| 479 | + $probably_installed++; |
|
| 480 | + } |
|
| 458 | 481 | } |
| 459 | 482 | |
| 460 | - if ($probably_installed == 2) |
|
| 461 | - $incontext['warning'] = $txt['error_already_installed']; |
|
| 483 | + if ($probably_installed == 2) { |
|
| 484 | + $incontext['warning'] = $txt['error_already_installed']; |
|
| 485 | + } |
|
| 462 | 486 | } |
| 463 | 487 | |
| 464 | 488 | // Is some database support even compiled in? |
@@ -473,45 +497,54 @@ discard block |
||
| 473 | 497 | $databases[$key]['supported'] = false; |
| 474 | 498 | $notFoundSQLFile = true; |
| 475 | 499 | $txt['error_db_script_missing'] = sprintf($txt['error_db_script_missing'], 'install_' . $GLOBALS['db_script_version'] . '_' . $type . '.sql'); |
| 500 | + } else { |
|
| 501 | + $incontext['supported_databases'][] = $db; |
|
| 476 | 502 | } |
| 477 | - else |
|
| 478 | - $incontext['supported_databases'][] = $db; |
|
| 479 | 503 | } |
| 480 | 504 | } |
| 481 | 505 | |
| 482 | 506 | // Check the PHP version. |
| 483 | - if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>='))) |
|
| 484 | - $error = 'error_php_too_low'; |
|
| 507 | + if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>='))) { |
|
| 508 | + $error = 'error_php_too_low'; |
|
| 509 | + } |
|
| 485 | 510 | // Make sure we have a supported database |
| 486 | - elseif (empty($incontext['supported_databases'])) |
|
| 487 | - $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
| 511 | + elseif (empty($incontext['supported_databases'])) { |
|
| 512 | + $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
| 513 | + } |
|
| 488 | 514 | // How about session support? Some crazy sysadmin remove it? |
| 489 | - elseif (!function_exists('session_start')) |
|
| 490 | - $error = 'error_session_missing'; |
|
| 515 | + elseif (!function_exists('session_start')) { |
|
| 516 | + $error = 'error_session_missing'; |
|
| 517 | + } |
|
| 491 | 518 | // Make sure they uploaded all the files. |
| 492 | - elseif (!file_exists(dirname(__FILE__) . '/index.php')) |
|
| 493 | - $error = 'error_missing_files'; |
|
| 519 | + elseif (!file_exists(dirname(__FILE__) . '/index.php')) { |
|
| 520 | + $error = 'error_missing_files'; |
|
| 521 | + } |
|
| 494 | 522 | // Very simple check on the session.save_path for Windows. |
| 495 | 523 | // @todo Move this down later if they don't use database-driven sessions? |
| 496 | - elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') |
|
| 497 | - $error = 'error_session_save_path'; |
|
| 524 | + elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') { |
|
| 525 | + $error = 'error_session_save_path'; |
|
| 526 | + } |
|
| 498 | 527 | |
| 499 | 528 | // Since each of the three messages would look the same, anyway... |
| 500 | - if (isset($error)) |
|
| 501 | - $incontext['error'] = $txt[$error]; |
|
| 529 | + if (isset($error)) { |
|
| 530 | + $incontext['error'] = $txt[$error]; |
|
| 531 | + } |
|
| 502 | 532 | |
| 503 | 533 | // Mod_security blocks everything that smells funny. Let SMF handle security. |
| 504 | - if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) |
|
| 505 | - $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
| 534 | + if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) { |
|
| 535 | + $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
| 536 | + } |
|
| 506 | 537 | |
| 507 | 538 | // Confirm mbstring is loaded... |
| 508 | - if (!extension_loaded('mbstring')) |
|
| 509 | - $incontext['error'] = $txt['install_no_mbstring']; |
|
| 539 | + if (!extension_loaded('mbstring')) { |
|
| 540 | + $incontext['error'] = $txt['install_no_mbstring']; |
|
| 541 | + } |
|
| 510 | 542 | |
| 511 | 543 | // Check for https stream support. |
| 512 | 544 | $supported_streams = stream_get_wrappers(); |
| 513 | - if (!in_array('https', $supported_streams)) |
|
| 514 | - $incontext['warning'] = $txt['install_no_https']; |
|
| 545 | + if (!in_array('https', $supported_streams)) { |
|
| 546 | + $incontext['warning'] = $txt['install_no_https']; |
|
| 547 | + } |
|
| 515 | 548 | |
| 516 | 549 | return false; |
| 517 | 550 | } |
@@ -536,12 +569,14 @@ discard block |
||
| 536 | 569 | 'Settings_bak.php', |
| 537 | 570 | ); |
| 538 | 571 | |
| 539 | - foreach ($incontext['detected_languages'] as $lang => $temp) |
|
| 540 | - $extra_files[] = 'Themes/default/languages/' . $lang; |
|
| 572 | + foreach ($incontext['detected_languages'] as $lang => $temp) { |
|
| 573 | + $extra_files[] = 'Themes/default/languages/' . $lang; |
|
| 574 | + } |
|
| 541 | 575 | |
| 542 | 576 | // With mod_security installed, we could attempt to fix it with .htaccess. |
| 543 | - if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) |
|
| 544 | - $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
| 577 | + if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) { |
|
| 578 | + $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
| 579 | + } |
|
| 545 | 580 | |
| 546 | 581 | $failed_files = array(); |
| 547 | 582 | |
@@ -553,20 +588,23 @@ discard block |
||
| 553 | 588 | foreach ($writable_files as $file) |
| 554 | 589 | { |
| 555 | 590 | // Some files won't exist, try to address up front |
| 556 | - if (!file_exists(dirname(__FILE__) . '/' . $file)) |
|
| 557 | - @touch(dirname(__FILE__) . '/' . $file); |
|
| 591 | + if (!file_exists(dirname(__FILE__) . '/' . $file)) { |
|
| 592 | + @touch(dirname(__FILE__) . '/' . $file); |
|
| 593 | + } |
|
| 558 | 594 | // NOW do the writable check... |
| 559 | 595 | if (!is_writable(dirname(__FILE__) . '/' . $file)) |
| 560 | 596 | { |
| 561 | 597 | @chmod(dirname(__FILE__) . '/' . $file, 0755); |
| 562 | 598 | |
| 563 | 599 | // Well, 755 hopefully worked... if not, try 777. |
| 564 | - if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) |
|
| 565 | - $failed_files[] = $file; |
|
| 600 | + if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) { |
|
| 601 | + $failed_files[] = $file; |
|
| 602 | + } |
|
| 566 | 603 | } |
| 567 | 604 | } |
| 568 | - foreach ($extra_files as $file) |
|
| 569 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 605 | + foreach ($extra_files as $file) { |
|
| 606 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 607 | + } |
|
| 570 | 608 | } |
| 571 | 609 | // Windows is trickier. Let's try opening for r+... |
| 572 | 610 | else |
@@ -576,30 +614,35 @@ discard block |
||
| 576 | 614 | foreach ($writable_files as $file) |
| 577 | 615 | { |
| 578 | 616 | // Folders can't be opened for write... but the index.php in them can ;) |
| 579 | - if (is_dir(dirname(__FILE__) . '/' . $file)) |
|
| 580 | - $file .= '/index.php'; |
|
| 617 | + if (is_dir(dirname(__FILE__) . '/' . $file)) { |
|
| 618 | + $file .= '/index.php'; |
|
| 619 | + } |
|
| 581 | 620 | |
| 582 | 621 | // Funny enough, chmod actually does do something on windows - it removes the read only attribute. |
| 583 | 622 | @chmod(dirname(__FILE__) . '/' . $file, 0777); |
| 584 | 623 | $fp = @fopen(dirname(__FILE__) . '/' . $file, 'r+'); |
| 585 | 624 | |
| 586 | 625 | // Hmm, okay, try just for write in that case... |
| 587 | - if (!is_resource($fp)) |
|
| 588 | - $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
| 626 | + if (!is_resource($fp)) { |
|
| 627 | + $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
| 628 | + } |
|
| 589 | 629 | |
| 590 | - if (!is_resource($fp)) |
|
| 591 | - $failed_files[] = $file; |
|
| 630 | + if (!is_resource($fp)) { |
|
| 631 | + $failed_files[] = $file; |
|
| 632 | + } |
|
| 592 | 633 | |
| 593 | 634 | @fclose($fp); |
| 594 | 635 | } |
| 595 | - foreach ($extra_files as $file) |
|
| 596 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 636 | + foreach ($extra_files as $file) { |
|
| 637 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 638 | + } |
|
| 597 | 639 | } |
| 598 | 640 | |
| 599 | 641 | $failure = count($failed_files) >= 1; |
| 600 | 642 | |
| 601 | - if (!isset($_SERVER)) |
|
| 602 | - return !$failure; |
|
| 643 | + if (!isset($_SERVER)) { |
|
| 644 | + return !$failure; |
|
| 645 | + } |
|
| 603 | 646 | |
| 604 | 647 | // Put the list into context. |
| 605 | 648 | $incontext['failed_files'] = $failed_files; |
@@ -647,19 +690,23 @@ discard block |
||
| 647 | 690 | |
| 648 | 691 | if (!isset($ftp) || $ftp->error !== false) |
| 649 | 692 | { |
| 650 | - if (!isset($ftp)) |
|
| 651 | - $ftp = new ftp_connection(null); |
|
| 693 | + if (!isset($ftp)) { |
|
| 694 | + $ftp = new ftp_connection(null); |
|
| 695 | + } |
|
| 652 | 696 | // Save the error so we can mess with listing... |
| 653 | - elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) |
|
| 654 | - $incontext['ftp_errors'][] = $ftp->last_message; |
|
| 697 | + elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) { |
|
| 698 | + $incontext['ftp_errors'][] = $ftp->last_message; |
|
| 699 | + } |
|
| 655 | 700 | |
| 656 | 701 | list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__)); |
| 657 | 702 | |
| 658 | - if (empty($_POST['ftp_path']) && $found_path) |
|
| 659 | - $_POST['ftp_path'] = $detect_path; |
|
| 703 | + if (empty($_POST['ftp_path']) && $found_path) { |
|
| 704 | + $_POST['ftp_path'] = $detect_path; |
|
| 705 | + } |
|
| 660 | 706 | |
| 661 | - if (!isset($_POST['ftp_username'])) |
|
| 662 | - $_POST['ftp_username'] = $username; |
|
| 707 | + if (!isset($_POST['ftp_username'])) { |
|
| 708 | + $_POST['ftp_username'] = $username; |
|
| 709 | + } |
|
| 663 | 710 | |
| 664 | 711 | // Set the username etc, into context. |
| 665 | 712 | $incontext['ftp'] = array( |
@@ -671,8 +718,7 @@ discard block |
||
| 671 | 718 | ); |
| 672 | 719 | |
| 673 | 720 | return false; |
| 674 | - } |
|
| 675 | - else |
|
| 721 | + } else |
|
| 676 | 722 | { |
| 677 | 723 | $_SESSION['installer_temp_ftp'] = array( |
| 678 | 724 | 'server' => $_POST['ftp_server'], |
@@ -686,10 +732,12 @@ discard block |
||
| 686 | 732 | |
| 687 | 733 | foreach ($failed_files as $file) |
| 688 | 734 | { |
| 689 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
| 690 | - $ftp->chmod($file, 0755); |
|
| 691 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
| 692 | - $ftp->chmod($file, 0777); |
|
| 735 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
| 736 | + $ftp->chmod($file, 0755); |
|
| 737 | + } |
|
| 738 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
| 739 | + $ftp->chmod($file, 0777); |
|
| 740 | + } |
|
| 693 | 741 | if (!is_writable(dirname(__FILE__) . '/' . $file)) |
| 694 | 742 | { |
| 695 | 743 | $failed_files_updated[] = $file; |
@@ -745,15 +793,17 @@ discard block |
||
| 745 | 793 | |
| 746 | 794 | if (!$foundOne) |
| 747 | 795 | { |
| 748 | - if (isset($db['default_host'])) |
|
| 749 | - $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
| 796 | + if (isset($db['default_host'])) { |
|
| 797 | + $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
| 798 | + } |
|
| 750 | 799 | if (isset($db['default_user'])) |
| 751 | 800 | { |
| 752 | 801 | $incontext['db']['user'] = ini_get($db['default_user']); |
| 753 | 802 | $incontext['db']['name'] = ini_get($db['default_user']); |
| 754 | 803 | } |
| 755 | - if (isset($db['default_password'])) |
|
| 756 | - $incontext['db']['pass'] = ini_get($db['default_password']); |
|
| 804 | + if (isset($db['default_password'])) { |
|
| 805 | + $incontext['db']['pass'] = ini_get($db['default_password']); |
|
| 806 | + } |
|
| 757 | 807 | |
| 758 | 808 | // For simplicity and less confusion, leave the port blank by default |
| 759 | 809 | $incontext['db']['port'] = ''; |
@@ -772,10 +822,10 @@ discard block |
||
| 772 | 822 | $incontext['db']['server'] = $_POST['db_server']; |
| 773 | 823 | $incontext['db']['prefix'] = $_POST['db_prefix']; |
| 774 | 824 | |
| 775 | - if (!empty($_POST['db_port'])) |
|
| 776 | - $incontext['db']['port'] = $_POST['db_port']; |
|
| 777 | - } |
|
| 778 | - else |
|
| 825 | + if (!empty($_POST['db_port'])) { |
|
| 826 | + $incontext['db']['port'] = $_POST['db_port']; |
|
| 827 | + } |
|
| 828 | + } else |
|
| 779 | 829 | { |
| 780 | 830 | $incontext['db']['prefix'] = 'smf_'; |
| 781 | 831 | } |
@@ -811,10 +861,11 @@ discard block |
||
| 811 | 861 | if (!empty($_POST['db_port'])) |
| 812 | 862 | { |
| 813 | 863 | // For MySQL, we can get the "default port" from PHP. PostgreSQL has no such option though. |
| 814 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) |
|
| 815 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
| 816 | - elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) |
|
| 817 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
| 864 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) { |
|
| 865 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
| 866 | + } elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) { |
|
| 867 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
| 868 | + } |
|
| 818 | 869 | } |
| 819 | 870 | |
| 820 | 871 | // God I hope it saved! |
@@ -827,8 +878,9 @@ discard block |
||
| 827 | 878 | // Make sure it works. |
| 828 | 879 | require(dirname(__FILE__) . '/Settings.php'); |
| 829 | 880 | |
| 830 | - if (empty($sourcedir)) |
|
| 831 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 881 | + if (empty($sourcedir)) { |
|
| 882 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 883 | + } |
|
| 832 | 884 | |
| 833 | 885 | // Better find the database file! |
| 834 | 886 | if (!file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
@@ -838,18 +890,21 @@ discard block |
||
| 838 | 890 | } |
| 839 | 891 | |
| 840 | 892 | // Now include it for database functions! |
| 841 | - if (!defined('SMF')) |
|
| 842 | - define('SMF', 1); |
|
| 893 | + if (!defined('SMF')) { |
|
| 894 | + define('SMF', 1); |
|
| 895 | + } |
|
| 843 | 896 | |
| 844 | 897 | $modSettings['disableQueryCheck'] = true; |
| 845 | - if (empty($smcFunc)) |
|
| 846 | - $smcFunc = array(); |
|
| 898 | + if (empty($smcFunc)) { |
|
| 899 | + $smcFunc = array(); |
|
| 900 | + } |
|
| 847 | 901 | |
| 848 | 902 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
| 849 | 903 | |
| 850 | 904 | // What - running PHP4? The shame! |
| 851 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
| 852 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
| 905 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
| 906 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
| 907 | + } |
|
| 853 | 908 | |
| 854 | 909 | // Attempt a connection. |
| 855 | 910 | $needsDB = !empty($databases[$db_type]['always_has_db']); |
@@ -937,12 +992,14 @@ discard block |
||
| 937 | 992 | $incontext['page_title'] = $txt['install_settings']; |
| 938 | 993 | |
| 939 | 994 | // Let's see if we got the database type correct. |
| 940 | - if (isset($_POST['db_type'], $databases[$_POST['db_type']])) |
|
| 941 | - $db_type = $_POST['db_type']; |
|
| 995 | + if (isset($_POST['db_type'], $databases[$_POST['db_type']])) { |
|
| 996 | + $db_type = $_POST['db_type']; |
|
| 997 | + } |
|
| 942 | 998 | |
| 943 | 999 | // Else we'd better be able to get the connection. |
| 944 | - else |
|
| 945 | - load_database(); |
|
| 1000 | + else { |
|
| 1001 | + load_database(); |
|
| 1002 | + } |
|
| 946 | 1003 | |
| 947 | 1004 | $db_type = isset($_POST['db_type']) ? $_POST['db_type'] : $db_type; |
| 948 | 1005 | |
@@ -951,10 +1008,11 @@ discard block |
||
| 951 | 1008 | |
| 952 | 1009 | $secure = false; |
| 953 | 1010 | |
| 954 | - if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') |
|
| 955 | - $secure = true; |
|
| 956 | - elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') |
|
| 957 | - $secure = true; |
|
| 1011 | + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { |
|
| 1012 | + $secure = true; |
|
| 1013 | + } elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') { |
|
| 1014 | + $secure = true; |
|
| 1015 | + } |
|
| 958 | 1016 | |
| 959 | 1017 | // Now, to put what we've learned together... and add a path. |
| 960 | 1018 | $incontext['detected_url'] = 'http' . ($secure ? 's' : '') . '://' . $host . substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/')); |
@@ -986,18 +1044,21 @@ discard block |
||
| 986 | 1044 | // Submitting? |
| 987 | 1045 | if (isset($_POST['boardurl'])) |
| 988 | 1046 | { |
| 989 | - if (substr($_POST['boardurl'], -10) == '/index.php') |
|
| 990 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
| 991 | - elseif (substr($_POST['boardurl'], -1) == '/') |
|
| 992 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
| 993 | - if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') |
|
| 994 | - $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
| 1047 | + if (substr($_POST['boardurl'], -10) == '/index.php') { |
|
| 1048 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
| 1049 | + } elseif (substr($_POST['boardurl'], -1) == '/') { |
|
| 1050 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
| 1051 | + } |
|
| 1052 | + if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') { |
|
| 1053 | + $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
| 1054 | + } |
|
| 995 | 1055 | |
| 996 | 1056 | //Make sure boardurl is aligned with ssl setting |
| 997 | - if (empty($_POST['force_ssl'])) |
|
| 998 | - $_POST['boardurl'] = strtr($_POST['boardurl'], array('https://' => 'http://')); |
|
| 999 | - else |
|
| 1000 | - $_POST['boardurl'] = strtr($_POST['boardurl'], array('http://' => 'https://')); |
|
| 1057 | + if (empty($_POST['force_ssl'])) { |
|
| 1058 | + $_POST['boardurl'] = strtr($_POST['boardurl'], array('https://' => 'http://')); |
|
| 1059 | + } else { |
|
| 1060 | + $_POST['boardurl'] = strtr($_POST['boardurl'], array('http://' => 'https://')); |
|
| 1061 | + } |
|
| 1001 | 1062 | |
| 1002 | 1063 | // Save these variables. |
| 1003 | 1064 | $vars = array( |
@@ -1036,10 +1097,10 @@ discard block |
||
| 1036 | 1097 | { |
| 1037 | 1098 | $incontext['error'] = sprintf($txt['error_utf8_version'], $databases[$db_type]['utf8_version']); |
| 1038 | 1099 | return false; |
| 1039 | - } |
|
| 1040 | - else |
|
| 1041 | - // Set the character set here. |
|
| 1100 | + } else { |
|
| 1101 | + // Set the character set here. |
|
| 1042 | 1102 | updateSettingsFile(array('db_character_set' => 'utf8')); |
| 1103 | + } |
|
| 1043 | 1104 | } |
| 1044 | 1105 | |
| 1045 | 1106 | // Good, skip on. |
@@ -1059,8 +1120,9 @@ discard block |
||
| 1059 | 1120 | $incontext['continue'] = 1; |
| 1060 | 1121 | |
| 1061 | 1122 | // Already done? |
| 1062 | - if (isset($_POST['pop_done'])) |
|
| 1063 | - return true; |
|
| 1123 | + if (isset($_POST['pop_done'])) { |
|
| 1124 | + return true; |
|
| 1125 | + } |
|
| 1064 | 1126 | |
| 1065 | 1127 | // Reload settings. |
| 1066 | 1128 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1078,8 +1140,9 @@ discard block |
||
| 1078 | 1140 | $modSettings = array(); |
| 1079 | 1141 | if ($result !== false) |
| 1080 | 1142 | { |
| 1081 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 1082 | - $modSettings[$row['variable']] = $row['value']; |
|
| 1143 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 1144 | + $modSettings[$row['variable']] = $row['value']; |
|
| 1145 | + } |
|
| 1083 | 1146 | $smcFunc['db_free_result']($result); |
| 1084 | 1147 | |
| 1085 | 1148 | // Do they match? If so, this is just a refresh so charge on! |
@@ -1092,20 +1155,22 @@ discard block |
||
| 1092 | 1155 | $modSettings['disableQueryCheck'] = true; |
| 1093 | 1156 | |
| 1094 | 1157 | // If doing UTF8, select it. PostgreSQL requires passing it as a string... |
| 1095 | - if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) |
|
| 1096 | - $smcFunc['db_query']('', ' |
|
| 1158 | + if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) { |
|
| 1159 | + $smcFunc['db_query']('', ' |
|
| 1097 | 1160 | SET NAMES {string:utf8}', |
| 1098 | 1161 | array( |
| 1099 | 1162 | 'db_error_skip' => true, |
| 1100 | 1163 | 'utf8' => 'utf8', |
| 1101 | 1164 | ) |
| 1102 | 1165 | ); |
| 1166 | + } |
|
| 1103 | 1167 | |
| 1104 | 1168 | // Windows likes to leave the trailing slash, which yields to C:\path\to\SMF\/attachments... |
| 1105 | - if (substr(__DIR__, -1) == '\\') |
|
| 1106 | - $attachdir = __DIR__ . 'attachments'; |
|
| 1107 | - else |
|
| 1108 | - $attachdir = __DIR__ . '/attachments'; |
|
| 1169 | + if (substr(__DIR__, -1) == '\\') { |
|
| 1170 | + $attachdir = __DIR__ . 'attachments'; |
|
| 1171 | + } else { |
|
| 1172 | + $attachdir = __DIR__ . '/attachments'; |
|
| 1173 | + } |
|
| 1109 | 1174 | |
| 1110 | 1175 | $replaces = array( |
| 1111 | 1176 | '{$db_prefix}' => $db_prefix, |
@@ -1122,8 +1187,9 @@ discard block |
||
| 1122 | 1187 | |
| 1123 | 1188 | foreach ($txt as $key => $value) |
| 1124 | 1189 | { |
| 1125 | - if (substr($key, 0, 8) == 'default_') |
|
| 1126 | - $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
| 1190 | + if (substr($key, 0, 8) == 'default_') { |
|
| 1191 | + $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
| 1192 | + } |
|
| 1127 | 1193 | } |
| 1128 | 1194 | $replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], array('\\\\n' => '\\n')); |
| 1129 | 1195 | |
@@ -1138,8 +1204,9 @@ discard block |
||
| 1138 | 1204 | |
| 1139 | 1205 | while ($row = $smcFunc['db_fetch_assoc']($get_engines)) |
| 1140 | 1206 | { |
| 1141 | - if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') |
|
| 1142 | - $engines[] = $row['Engine']; |
|
| 1207 | + if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') { |
|
| 1208 | + $engines[] = $row['Engine']; |
|
| 1209 | + } |
|
| 1143 | 1210 | } |
| 1144 | 1211 | |
| 1145 | 1212 | // Done with this now |
@@ -1163,8 +1230,7 @@ discard block |
||
| 1163 | 1230 | $replaces['START TRANSACTION;'] = ''; |
| 1164 | 1231 | $replaces['COMMIT;'] = ''; |
| 1165 | 1232 | } |
| 1166 | - } |
|
| 1167 | - else |
|
| 1233 | + } else |
|
| 1168 | 1234 | { |
| 1169 | 1235 | $has_innodb = false; |
| 1170 | 1236 | } |
@@ -1186,21 +1252,24 @@ discard block |
||
| 1186 | 1252 | foreach ($sql_lines as $count => $line) |
| 1187 | 1253 | { |
| 1188 | 1254 | // No comments allowed! |
| 1189 | - if (substr(trim($line), 0, 1) != '#') |
|
| 1190 | - $current_statement .= "\n" . rtrim($line); |
|
| 1255 | + if (substr(trim($line), 0, 1) != '#') { |
|
| 1256 | + $current_statement .= "\n" . rtrim($line); |
|
| 1257 | + } |
|
| 1191 | 1258 | |
| 1192 | 1259 | // Is this the end of the query string? |
| 1193 | - if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) |
|
| 1194 | - continue; |
|
| 1260 | + if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) { |
|
| 1261 | + continue; |
|
| 1262 | + } |
|
| 1195 | 1263 | |
| 1196 | 1264 | // Does this table already exist? If so, don't insert more data into it! |
| 1197 | 1265 | if (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) != 0 && in_array($match[1], $exists)) |
| 1198 | 1266 | { |
| 1199 | 1267 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
| 1200 | - if (!empty($matches[0])) |
|
| 1201 | - $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
| 1202 | - else |
|
| 1203 | - $incontext['sql_results']['insert_dups']++; |
|
| 1268 | + if (!empty($matches[0])) { |
|
| 1269 | + $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
| 1270 | + } else { |
|
| 1271 | + $incontext['sql_results']['insert_dups']++; |
|
| 1272 | + } |
|
| 1204 | 1273 | |
| 1205 | 1274 | $current_statement = ''; |
| 1206 | 1275 | continue; |
@@ -1209,8 +1278,9 @@ discard block |
||
| 1209 | 1278 | if ($smcFunc['db_query']('', $current_statement, array('security_override' => true, 'db_error_skip' => true), $db_connection) === false) |
| 1210 | 1279 | { |
| 1211 | 1280 | // Use the appropriate function based on the DB type |
| 1212 | - if ($db_type == 'mysql' || $db_type == 'mysqli') |
|
| 1213 | - $db_errorno = $db_type . '_errno'; |
|
| 1281 | + if ($db_type == 'mysql' || $db_type == 'mysqli') { |
|
| 1282 | + $db_errorno = $db_type . '_errno'; |
|
| 1283 | + } |
|
| 1214 | 1284 | |
| 1215 | 1285 | // Error 1050: Table already exists! |
| 1216 | 1286 | // @todo Needs to be made better! |
@@ -1225,18 +1295,18 @@ discard block |
||
| 1225 | 1295 | // MySQLi requires a connection object. It's optional with MySQL and Postgres |
| 1226 | 1296 | $incontext['failures'][$count] = $smcFunc['db_error']($db_connection); |
| 1227 | 1297 | } |
| 1228 | - } |
|
| 1229 | - else |
|
| 1298 | + } else |
|
| 1230 | 1299 | { |
| 1231 | - if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
| 1232 | - $incontext['sql_results']['tables']++; |
|
| 1233 | - elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
| 1300 | + if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) { |
|
| 1301 | + $incontext['sql_results']['tables']++; |
|
| 1302 | + } elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
| 1234 | 1303 | { |
| 1235 | 1304 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
| 1236 | - if (!empty($matches[0])) |
|
| 1237 | - $incontext['sql_results']['inserts'] += count($matches[0]); |
|
| 1238 | - else |
|
| 1239 | - $incontext['sql_results']['inserts']++; |
|
| 1305 | + if (!empty($matches[0])) { |
|
| 1306 | + $incontext['sql_results']['inserts'] += count($matches[0]); |
|
| 1307 | + } else { |
|
| 1308 | + $incontext['sql_results']['inserts']++; |
|
| 1309 | + } |
|
| 1240 | 1310 | } |
| 1241 | 1311 | } |
| 1242 | 1312 | |
@@ -1249,15 +1319,17 @@ discard block |
||
| 1249 | 1319 | // Sort out the context for the SQL. |
| 1250 | 1320 | foreach ($incontext['sql_results'] as $key => $number) |
| 1251 | 1321 | { |
| 1252 | - if ($number == 0) |
|
| 1253 | - unset($incontext['sql_results'][$key]); |
|
| 1254 | - else |
|
| 1255 | - $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
| 1322 | + if ($number == 0) { |
|
| 1323 | + unset($incontext['sql_results'][$key]); |
|
| 1324 | + } else { |
|
| 1325 | + $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
| 1326 | + } |
|
| 1256 | 1327 | } |
| 1257 | 1328 | |
| 1258 | 1329 | // Make sure UTF will be used globally. |
| 1259 | - if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8']))) |
|
| 1260 | - $newSettings[] = array('global_character_set', 'UTF-8'); |
|
| 1330 | + if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8']))) { |
|
| 1331 | + $newSettings[] = array('global_character_set', 'UTF-8'); |
|
| 1332 | + } |
|
| 1261 | 1333 | |
| 1262 | 1334 | // Auto-detect local & global cookie settings |
| 1263 | 1335 | $url_parts = parse_url($boardurl); |
@@ -1286,15 +1358,19 @@ discard block |
||
| 1286 | 1358 | |
| 1287 | 1359 | // Look for subfolder, if found, set localCookie |
| 1288 | 1360 | // Checking for len > 1 ensures you don't have just a slash... |
| 1289 | - if (!empty($url_parts['path']) && strlen($url_parts['path']) > 1) |
|
| 1290 | - $localCookies = '1'; |
|
| 1361 | + if (!empty($url_parts['path']) && strlen($url_parts['path']) > 1) { |
|
| 1362 | + $localCookies = '1'; |
|
| 1363 | + } |
|
| 1291 | 1364 | |
| 1292 | - if (isset($globalCookies)) |
|
| 1293 | - $newSettings[] = array('globalCookies', $globalCookies); |
|
| 1294 | - if (isset($globalCookiesDomain)) |
|
| 1295 | - $newSettings[] = array('globalCookiesDomain', $globalCookiesDomain); |
|
| 1296 | - if (isset($localCookies)) |
|
| 1297 | - $newSettings[] = array('localCookies', $localCookies); |
|
| 1365 | + if (isset($globalCookies)) { |
|
| 1366 | + $newSettings[] = array('globalCookies', $globalCookies); |
|
| 1367 | + } |
|
| 1368 | + if (isset($globalCookiesDomain)) { |
|
| 1369 | + $newSettings[] = array('globalCookiesDomain', $globalCookiesDomain); |
|
| 1370 | + } |
|
| 1371 | + if (isset($localCookies)) { |
|
| 1372 | + $newSettings[] = array('localCookies', $localCookies); |
|
| 1373 | + } |
|
| 1298 | 1374 | } |
| 1299 | 1375 | |
| 1300 | 1376 | // Are we allowing stat collection? |
@@ -1312,16 +1388,17 @@ discard block |
||
| 1312 | 1388 | fwrite($fp, $out); |
| 1313 | 1389 | |
| 1314 | 1390 | $return_data = ''; |
| 1315 | - while (!feof($fp)) |
|
| 1316 | - $return_data .= fgets($fp, 128); |
|
| 1391 | + while (!feof($fp)) { |
|
| 1392 | + $return_data .= fgets($fp, 128); |
|
| 1393 | + } |
|
| 1317 | 1394 | |
| 1318 | 1395 | fclose($fp); |
| 1319 | 1396 | |
| 1320 | 1397 | // Get the unique site ID. |
| 1321 | 1398 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
| 1322 | 1399 | |
| 1323 | - if (!empty($ID[1])) |
|
| 1324 | - $smcFunc['db_insert']('replace', |
|
| 1400 | + if (!empty($ID[1])) { |
|
| 1401 | + $smcFunc['db_insert']('replace', |
|
| 1325 | 1402 | $db_prefix . 'settings', |
| 1326 | 1403 | array('variable' => 'string', 'value' => 'string'), |
| 1327 | 1404 | array( |
@@ -1330,11 +1407,12 @@ discard block |
||
| 1330 | 1407 | ), |
| 1331 | 1408 | array('variable') |
| 1332 | 1409 | ); |
| 1410 | + } |
|
| 1333 | 1411 | } |
| 1334 | 1412 | } |
| 1335 | 1413 | // Don't remove stat collection unless we unchecked the box for real, not from the loop. |
| 1336 | - elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) |
|
| 1337 | - $smcFunc['db_query']('', ' |
|
| 1414 | + elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) { |
|
| 1415 | + $smcFunc['db_query']('', ' |
|
| 1338 | 1416 | DELETE FROM {db_prefix}settings |
| 1339 | 1417 | WHERE variable = {string:enable_sm_stats}', |
| 1340 | 1418 | array( |
@@ -1342,20 +1420,23 @@ discard block |
||
| 1342 | 1420 | 'db_error_skip' => true, |
| 1343 | 1421 | ) |
| 1344 | 1422 | ); |
| 1423 | + } |
|
| 1345 | 1424 | |
| 1346 | 1425 | // Are we enabling SSL? |
| 1347 | - if (!empty($_POST['force_ssl'])) |
|
| 1348 | - $newSettings[] = array('force_ssl', 1); |
|
| 1426 | + if (!empty($_POST['force_ssl'])) { |
|
| 1427 | + $newSettings[] = array('force_ssl', 1); |
|
| 1428 | + } |
|
| 1349 | 1429 | |
| 1350 | 1430 | // Setting a timezone is required. |
| 1351 | 1431 | if (!isset($modSettings['default_timezone']) && function_exists('date_default_timezone_set')) |
| 1352 | 1432 | { |
| 1353 | 1433 | // Get PHP's default timezone, if set |
| 1354 | 1434 | $ini_tz = ini_get('date.timezone'); |
| 1355 | - if (!empty($ini_tz)) |
|
| 1356 | - $timezone_id = $ini_tz; |
|
| 1357 | - else |
|
| 1358 | - $timezone_id = ''; |
|
| 1435 | + if (!empty($ini_tz)) { |
|
| 1436 | + $timezone_id = $ini_tz; |
|
| 1437 | + } else { |
|
| 1438 | + $timezone_id = ''; |
|
| 1439 | + } |
|
| 1359 | 1440 | |
| 1360 | 1441 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
| 1361 | 1442 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -1364,8 +1445,9 @@ discard block |
||
| 1364 | 1445 | $timezone_id = timezone_name_from_abbr('', $server_offset, 0); |
| 1365 | 1446 | } |
| 1366 | 1447 | |
| 1367 | - if (date_default_timezone_set($timezone_id)) |
|
| 1368 | - $newSettings[] = array('default_timezone', $timezone_id); |
|
| 1448 | + if (date_default_timezone_set($timezone_id)) { |
|
| 1449 | + $newSettings[] = array('default_timezone', $timezone_id); |
|
| 1450 | + } |
|
| 1369 | 1451 | } |
| 1370 | 1452 | |
| 1371 | 1453 | if (!empty($newSettings)) |
@@ -1396,16 +1478,18 @@ discard block |
||
| 1396 | 1478 | } |
| 1397 | 1479 | |
| 1398 | 1480 | // MySQL specific stuff |
| 1399 | - if (substr($db_type, 0, 5) != 'mysql') |
|
| 1400 | - return false; |
|
| 1481 | + if (substr($db_type, 0, 5) != 'mysql') { |
|
| 1482 | + return false; |
|
| 1483 | + } |
|
| 1401 | 1484 | |
| 1402 | 1485 | // Find database user privileges. |
| 1403 | 1486 | $privs = array(); |
| 1404 | 1487 | $get_privs = $smcFunc['db_query']('', 'SHOW PRIVILEGES', array()); |
| 1405 | 1488 | while ($row = $smcFunc['db_fetch_assoc']($get_privs)) |
| 1406 | 1489 | { |
| 1407 | - if ($row['Privilege'] == 'Alter') |
|
| 1408 | - $privs[] = $row['Privilege']; |
|
| 1490 | + if ($row['Privilege'] == 'Alter') { |
|
| 1491 | + $privs[] = $row['Privilege']; |
|
| 1492 | + } |
|
| 1409 | 1493 | } |
| 1410 | 1494 | $smcFunc['db_free_result']($get_privs); |
| 1411 | 1495 | |
@@ -1435,8 +1519,9 @@ discard block |
||
| 1435 | 1519 | $incontext['continue'] = 1; |
| 1436 | 1520 | |
| 1437 | 1521 | // Skipping? |
| 1438 | - if (!empty($_POST['skip'])) |
|
| 1439 | - return true; |
|
| 1522 | + if (!empty($_POST['skip'])) { |
|
| 1523 | + return true; |
|
| 1524 | + } |
|
| 1440 | 1525 | |
| 1441 | 1526 | // Need this to check whether we need the database password. |
| 1442 | 1527 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1453,18 +1538,22 @@ discard block |
||
| 1453 | 1538 | // We need this to properly hash the password for Admin |
| 1454 | 1539 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) { |
| 1455 | 1540 | global $sourcedir; |
| 1456 | - if (function_exists('mb_strtolower')) |
|
| 1457 | - return mb_strtolower($string, 'UTF-8'); |
|
| 1541 | + if (function_exists('mb_strtolower')) { |
|
| 1542 | + return mb_strtolower($string, 'UTF-8'); |
|
| 1543 | + } |
|
| 1458 | 1544 | require_once($sourcedir . '/Subs-Charset.php'); |
| 1459 | 1545 | return utf8_strtolower($string); |
| 1460 | 1546 | }; |
| 1461 | 1547 | |
| 1462 | - if (!isset($_POST['username'])) |
|
| 1463 | - $_POST['username'] = ''; |
|
| 1464 | - if (!isset($_POST['email'])) |
|
| 1465 | - $_POST['email'] = ''; |
|
| 1466 | - if (!isset($_POST['server_email'])) |
|
| 1467 | - $_POST['server_email'] = ''; |
|
| 1548 | + if (!isset($_POST['username'])) { |
|
| 1549 | + $_POST['username'] = ''; |
|
| 1550 | + } |
|
| 1551 | + if (!isset($_POST['email'])) { |
|
| 1552 | + $_POST['email'] = ''; |
|
| 1553 | + } |
|
| 1554 | + if (!isset($_POST['server_email'])) { |
|
| 1555 | + $_POST['server_email'] = ''; |
|
| 1556 | + } |
|
| 1468 | 1557 | |
| 1469 | 1558 | $incontext['username'] = htmlspecialchars(stripslashes($_POST['username'])); |
| 1470 | 1559 | $incontext['email'] = htmlspecialchars(stripslashes($_POST['email'])); |
@@ -1483,8 +1572,9 @@ discard block |
||
| 1483 | 1572 | 'admin_group' => 1, |
| 1484 | 1573 | ) |
| 1485 | 1574 | ); |
| 1486 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 1487 | - $incontext['skip'] = 1; |
|
| 1575 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 1576 | + $incontext['skip'] = 1; |
|
| 1577 | + } |
|
| 1488 | 1578 | $smcFunc['db_free_result']($request); |
| 1489 | 1579 | |
| 1490 | 1580 | // Trying to create an account? |
@@ -1515,8 +1605,9 @@ discard block |
||
| 1515 | 1605 | } |
| 1516 | 1606 | |
| 1517 | 1607 | // Update the webmaster's email? |
| 1518 | - if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) |
|
| 1519 | - updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
| 1608 | + if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) { |
|
| 1609 | + updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
| 1610 | + } |
|
| 1520 | 1611 | |
| 1521 | 1612 | // Work out whether we're going to have dodgy characters and remove them. |
| 1522 | 1613 | $invalid_characters = preg_match('~[<>&"\'=\\\]~', $_POST['username']) != 0; |
@@ -1539,32 +1630,27 @@ discard block |
||
| 1539 | 1630 | $smcFunc['db_free_result']($result); |
| 1540 | 1631 | |
| 1541 | 1632 | $incontext['account_existed'] = $txt['error_user_settings_taken']; |
| 1542 | - } |
|
| 1543 | - elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
| 1633 | + } elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
| 1544 | 1634 | { |
| 1545 | 1635 | // Try the previous step again. |
| 1546 | 1636 | $incontext['error'] = $_POST['username'] == '' ? $txt['error_username_left_empty'] : $txt['error_username_too_long']; |
| 1547 | 1637 | return false; |
| 1548 | - } |
|
| 1549 | - elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
| 1638 | + } elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
| 1550 | 1639 | { |
| 1551 | 1640 | // Try the previous step again. |
| 1552 | 1641 | $incontext['error'] = $txt['error_invalid_characters_username']; |
| 1553 | 1642 | return false; |
| 1554 | - } |
|
| 1555 | - elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
| 1643 | + } elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
| 1556 | 1644 | { |
| 1557 | 1645 | // One step back, this time fill out a proper admin email address. |
| 1558 | 1646 | $incontext['error'] = sprintf($txt['error_valid_admin_email_needed'], $_POST['username']); |
| 1559 | 1647 | return false; |
| 1560 | - } |
|
| 1561 | - elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
| 1648 | + } elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
| 1562 | 1649 | { |
| 1563 | 1650 | // One step back, this time fill out a proper admin email address. |
| 1564 | 1651 | $incontext['error'] = $txt['error_valid_server_email_needed']; |
| 1565 | 1652 | return false; |
| 1566 | - } |
|
| 1567 | - elseif ($_POST['username'] != '') |
|
| 1653 | + } elseif ($_POST['username'] != '') |
|
| 1568 | 1654 | { |
| 1569 | 1655 | $incontext['member_salt'] = substr(md5(mt_rand()), 0, 4); |
| 1570 | 1656 | |
@@ -1632,17 +1718,19 @@ discard block |
||
| 1632 | 1718 | reloadSettings(); |
| 1633 | 1719 | |
| 1634 | 1720 | // Bring a warning over. |
| 1635 | - if (!empty($incontext['account_existed'])) |
|
| 1636 | - $incontext['warning'] = $incontext['account_existed']; |
|
| 1721 | + if (!empty($incontext['account_existed'])) { |
|
| 1722 | + $incontext['warning'] = $incontext['account_existed']; |
|
| 1723 | + } |
|
| 1637 | 1724 | |
| 1638 | - if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) |
|
| 1639 | - $smcFunc['db_query']('', ' |
|
| 1725 | + if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) { |
|
| 1726 | + $smcFunc['db_query']('', ' |
|
| 1640 | 1727 | SET NAMES {string:db_character_set}', |
| 1641 | 1728 | array( |
| 1642 | 1729 | 'db_character_set' => $db_character_set, |
| 1643 | 1730 | 'db_error_skip' => true, |
| 1644 | 1731 | ) |
| 1645 | 1732 | ); |
| 1733 | + } |
|
| 1646 | 1734 | |
| 1647 | 1735 | // As track stats is by default enabled let's add some activity. |
| 1648 | 1736 | $smcFunc['db_insert']('ignore', |
@@ -1663,14 +1751,16 @@ discard block |
||
| 1663 | 1751 | // Only proceed if we can load the data. |
| 1664 | 1752 | if ($request) |
| 1665 | 1753 | { |
| 1666 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 1667 | - $modSettings[$row[0]] = $row[1]; |
|
| 1754 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 1755 | + $modSettings[$row[0]] = $row[1]; |
|
| 1756 | + } |
|
| 1668 | 1757 | $smcFunc['db_free_result']($request); |
| 1669 | 1758 | } |
| 1670 | 1759 | |
| 1671 | 1760 | // Automatically log them in ;) |
| 1672 | - if (isset($incontext['member_id']) && isset($incontext['member_salt'])) |
|
| 1673 | - setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
| 1761 | + if (isset($incontext['member_id']) && isset($incontext['member_salt'])) { |
|
| 1762 | + setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
| 1763 | + } |
|
| 1674 | 1764 | |
| 1675 | 1765 | $result = $smcFunc['db_query']('', ' |
| 1676 | 1766 | SELECT value |
@@ -1681,13 +1771,14 @@ discard block |
||
| 1681 | 1771 | 'db_error_skip' => true, |
| 1682 | 1772 | ) |
| 1683 | 1773 | ); |
| 1684 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
| 1685 | - list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
| 1774 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
| 1775 | + list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
| 1776 | + } |
|
| 1686 | 1777 | $smcFunc['db_free_result']($result); |
| 1687 | 1778 | |
| 1688 | - if (empty($db_sessions)) |
|
| 1689 | - $_SESSION['admin_time'] = time(); |
|
| 1690 | - else |
|
| 1779 | + if (empty($db_sessions)) { |
|
| 1780 | + $_SESSION['admin_time'] = time(); |
|
| 1781 | + } else |
|
| 1691 | 1782 | { |
| 1692 | 1783 | $_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211); |
| 1693 | 1784 | |
@@ -1711,8 +1802,9 @@ discard block |
||
| 1711 | 1802 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : |
| 1712 | 1803 | function($string){ |
| 1713 | 1804 | global $sourcedir; |
| 1714 | - if (function_exists('mb_strtolower')) |
|
| 1715 | - return mb_strtolower($string, 'UTF-8'); |
|
| 1805 | + if (function_exists('mb_strtolower')) { |
|
| 1806 | + return mb_strtolower($string, 'UTF-8'); |
|
| 1807 | + } |
|
| 1716 | 1808 | require_once($sourcedir . '/Subs-Charset.php'); |
| 1717 | 1809 | return utf8_strtolower($string); |
| 1718 | 1810 | }; |
@@ -1728,8 +1820,9 @@ discard block |
||
| 1728 | 1820 | ) |
| 1729 | 1821 | ); |
| 1730 | 1822 | $context['utf8'] = $db_character_set === 'utf8' || $txt['lang_character_set'] === 'UTF-8'; |
| 1731 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
| 1732 | - updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
| 1823 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
| 1824 | + updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
| 1825 | + } |
|
| 1733 | 1826 | $smcFunc['db_free_result']($request); |
| 1734 | 1827 | |
| 1735 | 1828 | // Now is the perfect time to fetch the SM files. |
@@ -1748,8 +1841,9 @@ discard block |
||
| 1748 | 1841 | |
| 1749 | 1842 | // Check if we need some stupid MySQL fix. |
| 1750 | 1843 | $server_version = $smcFunc['db_server_info'](); |
| 1751 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
| 1752 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1844 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
| 1845 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1846 | + } |
|
| 1753 | 1847 | |
| 1754 | 1848 | // Some final context for the template. |
| 1755 | 1849 | $incontext['dir_still_writable'] = is_writable(dirname(__FILE__)) && substr(__FILE__, 1, 2) != ':\\'; |
@@ -1769,8 +1863,9 @@ discard block |
||
| 1769 | 1863 | $settingsArray = file(dirname(__FILE__) . '/Settings.php'); |
| 1770 | 1864 | |
| 1771 | 1865 | // @todo Do we just want to read the file in clean, and split it this way always? |
| 1772 | - if (count($settingsArray) == 1) |
|
| 1773 | - $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
| 1866 | + if (count($settingsArray) == 1) { |
|
| 1867 | + $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
| 1868 | + } |
|
| 1774 | 1869 | |
| 1775 | 1870 | for ($i = 0, $n = count($settingsArray); $i < $n; $i++) |
| 1776 | 1871 | { |
@@ -1778,25 +1873,29 @@ discard block |
||
| 1778 | 1873 | if (trim($settingsArray[$i]) == 'if (file_exists(dirname(__FILE__) . \'/install.php\'))' && trim($settingsArray[$i + 1]) == '{' && trim($settingsArray[$i + 9]) == '}') |
| 1779 | 1874 | { |
| 1780 | 1875 | // Set the ten lines to nothing. |
| 1781 | - for ($j=0; $j < 10; $j++) |
|
| 1782 | - $settingsArray[$i++] = ''; |
|
| 1876 | + for ($j=0; $j < 10; $j++) { |
|
| 1877 | + $settingsArray[$i++] = ''; |
|
| 1878 | + } |
|
| 1783 | 1879 | |
| 1784 | 1880 | continue; |
| 1785 | 1881 | } |
| 1786 | 1882 | |
| 1787 | - if (trim($settingsArray[$i]) == '?' . '>') |
|
| 1788 | - $settingsArray[$i] = ''; |
|
| 1883 | + if (trim($settingsArray[$i]) == '?' . '>') { |
|
| 1884 | + $settingsArray[$i] = ''; |
|
| 1885 | + } |
|
| 1789 | 1886 | |
| 1790 | 1887 | // Don't trim or bother with it if it's not a variable. |
| 1791 | - if (substr($settingsArray[$i], 0, 1) != '$') |
|
| 1792 | - continue; |
|
| 1888 | + if (substr($settingsArray[$i], 0, 1) != '$') { |
|
| 1889 | + continue; |
|
| 1890 | + } |
|
| 1793 | 1891 | |
| 1794 | 1892 | $settingsArray[$i] = rtrim($settingsArray[$i]) . "\n"; |
| 1795 | 1893 | |
| 1796 | - foreach ($vars as $var => $val) |
|
| 1797 | - if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
| 1894 | + foreach ($vars as $var => $val) { |
|
| 1895 | + if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
| 1798 | 1896 | { |
| 1799 | 1897 | $comment = strstr($settingsArray[$i], '#'); |
| 1898 | + } |
|
| 1800 | 1899 | $settingsArray[$i] = '$' . $var . ' = \'' . $val . '\';' . ($comment != '' ? "\t\t" . $comment : "\n"); |
| 1801 | 1900 | unset($vars[$var]); |
| 1802 | 1901 | } |
@@ -1806,36 +1905,41 @@ discard block |
||
| 1806 | 1905 | if (!empty($vars)) |
| 1807 | 1906 | { |
| 1808 | 1907 | $settingsArray[$i++] = ''; |
| 1809 | - foreach ($vars as $var => $val) |
|
| 1810 | - $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
| 1908 | + foreach ($vars as $var => $val) { |
|
| 1909 | + $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
| 1910 | + } |
|
| 1811 | 1911 | } |
| 1812 | 1912 | |
| 1813 | 1913 | // Blank out the file - done to fix a oddity with some servers. |
| 1814 | 1914 | $fp = @fopen(dirname(__FILE__) . '/Settings.php', 'w'); |
| 1815 | - if (!$fp) |
|
| 1816 | - return false; |
|
| 1915 | + if (!$fp) { |
|
| 1916 | + return false; |
|
| 1917 | + } |
|
| 1817 | 1918 | fclose($fp); |
| 1818 | 1919 | |
| 1819 | 1920 | $fp = fopen(dirname(__FILE__) . '/Settings.php', 'r+'); |
| 1820 | 1921 | |
| 1821 | 1922 | // Gotta have one of these ;) |
| 1822 | - if (trim($settingsArray[0]) != '<?php') |
|
| 1823 | - fwrite($fp, "<?php\n"); |
|
| 1923 | + if (trim($settingsArray[0]) != '<?php') { |
|
| 1924 | + fwrite($fp, "<?php\n"); |
|
| 1925 | + } |
|
| 1824 | 1926 | |
| 1825 | 1927 | $lines = count($settingsArray); |
| 1826 | 1928 | for ($i = 0; $i < $lines - 1; $i++) |
| 1827 | 1929 | { |
| 1828 | 1930 | // Don't just write a bunch of blank lines. |
| 1829 | - if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') |
|
| 1830 | - fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
| 1931 | + if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') { |
|
| 1932 | + fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
| 1933 | + } |
|
| 1831 | 1934 | } |
| 1832 | 1935 | fwrite($fp, $settingsArray[$i] . '?' . '>'); |
| 1833 | 1936 | fclose($fp); |
| 1834 | 1937 | |
| 1835 | 1938 | // Even though on normal installations the filemtime should prevent this being used by the installer incorrectly |
| 1836 | 1939 | // it seems that there are times it might not. So let's MAKE it dump the cache. |
| 1837 | - if (function_exists('opcache_invalidate')) |
|
| 1838 | - opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
| 1940 | + if (function_exists('opcache_invalidate')) { |
|
| 1941 | + opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
| 1942 | + } |
|
| 1839 | 1943 | |
| 1840 | 1944 | return true; |
| 1841 | 1945 | } |
@@ -1845,10 +1949,11 @@ discard block |
||
| 1845 | 1949 | global $cachedir; |
| 1846 | 1950 | |
| 1847 | 1951 | // Write out the db_last_error file with the error timestamp |
| 1848 | - if (!empty($cachedir) && is_writable($cachedir)) |
|
| 1849 | - file_put_contents($cachedir . '/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>'); |
|
| 1850 | - else |
|
| 1851 | - file_put_contents(dirname(__FILE__) . '/cache/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>'); |
|
| 1952 | + if (!empty($cachedir) && is_writable($cachedir)) { |
|
| 1953 | + file_put_contents($cachedir . '/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>'); |
|
| 1954 | + } else { |
|
| 1955 | + file_put_contents(dirname(__FILE__) . '/cache/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>'); |
|
| 1956 | + } |
|
| 1852 | 1957 | |
| 1853 | 1958 | return true; |
| 1854 | 1959 | } |
@@ -1865,9 +1970,9 @@ discard block |
||
| 1865 | 1970 | SecFilterScanPOST Off |
| 1866 | 1971 | </IfModule>'; |
| 1867 | 1972 | |
| 1868 | - if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) |
|
| 1869 | - return true; |
|
| 1870 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
| 1973 | + if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) { |
|
| 1974 | + return true; |
|
| 1975 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
| 1871 | 1976 | { |
| 1872 | 1977 | $current_htaccess = implode('', file(dirname(__FILE__) . '/.htaccess')); |
| 1873 | 1978 | |
@@ -1879,29 +1984,28 @@ discard block |
||
| 1879 | 1984 | fwrite($ht_handle, $htaccess_addition); |
| 1880 | 1985 | fclose($ht_handle); |
| 1881 | 1986 | return true; |
| 1987 | + } else { |
|
| 1988 | + return false; |
|
| 1882 | 1989 | } |
| 1883 | - else |
|
| 1884 | - return false; |
|
| 1990 | + } else { |
|
| 1991 | + return true; |
|
| 1885 | 1992 | } |
| 1886 | - else |
|
| 1887 | - return true; |
|
| 1888 | - } |
|
| 1889 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess')) |
|
| 1890 | - return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
| 1891 | - elseif (is_writable(dirname(__FILE__))) |
|
| 1993 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess')) { |
|
| 1994 | + return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
| 1995 | + } elseif (is_writable(dirname(__FILE__))) |
|
| 1892 | 1996 | { |
| 1893 | 1997 | if ($ht_handle = fopen(dirname(__FILE__) . '/.htaccess', 'w')) |
| 1894 | 1998 | { |
| 1895 | 1999 | fwrite($ht_handle, $htaccess_addition); |
| 1896 | 2000 | fclose($ht_handle); |
| 1897 | 2001 | return true; |
| 2002 | + } else { |
|
| 2003 | + return false; |
|
| 1898 | 2004 | } |
| 1899 | - else |
|
| 2005 | + } else { |
|
| 1900 | 2006 | return false; |
| 1901 | 2007 | } |
| 1902 | - else |
|
| 1903 | - return false; |
|
| 1904 | -} |
|
| 2008 | + } |
|
| 1905 | 2009 | |
| 1906 | 2010 | function template_install_above() |
| 1907 | 2011 | { |
@@ -1940,9 +2044,10 @@ discard block |
||
| 1940 | 2044 | <label for="installer_language">', $txt['installer_language'], ':</label> |
| 1941 | 2045 | <select id="installer_language" name="lang_file" onchange="location.href = \'', $installurl, '?lang_file=\' + this.options[this.selectedIndex].value;">'; |
| 1942 | 2046 | |
| 1943 | - foreach ($incontext['detected_languages'] as $lang => $name) |
|
| 1944 | - echo ' |
|
| 2047 | + foreach ($incontext['detected_languages'] as $lang => $name) { |
|
| 2048 | + echo ' |
|
| 1945 | 2049 | <option', isset($_SESSION['installer_temp_lang']) && $_SESSION['installer_temp_lang'] == $lang ? ' selected' : '', ' value="', $lang, '">', $name, '</option>'; |
| 2050 | + } |
|
| 1946 | 2051 | |
| 1947 | 2052 | echo ' |
| 1948 | 2053 | </select> |
@@ -1962,9 +2067,10 @@ discard block |
||
| 1962 | 2067 | <h2>', $txt['upgrade_progress'], '</h2> |
| 1963 | 2068 | <ul>'; |
| 1964 | 2069 | |
| 1965 | - foreach ($incontext['steps'] as $num => $step) |
|
| 1966 | - echo ' |
|
| 2070 | + foreach ($incontext['steps'] as $num => $step) { |
|
| 2071 | + echo ' |
|
| 1967 | 2072 | <li class="', $num < $incontext['current_step'] ? 'stepdone' : ($num == $incontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
| 2073 | + } |
|
| 1968 | 2074 | |
| 1969 | 2075 | echo ' |
| 1970 | 2076 | </ul> |
@@ -1990,20 +2096,23 @@ discard block |
||
| 1990 | 2096 | echo ' |
| 1991 | 2097 | <div class="floatright">'; |
| 1992 | 2098 | |
| 1993 | - if (!empty($incontext['continue'])) |
|
| 1994 | - echo ' |
|
| 2099 | + if (!empty($incontext['continue'])) { |
|
| 2100 | + echo ' |
|
| 1995 | 2101 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '" onclick="return submitThisOnce(this);" class="button">'; |
| 1996 | - if (!empty($incontext['skip'])) |
|
| 1997 | - echo ' |
|
| 2102 | + } |
|
| 2103 | + if (!empty($incontext['skip'])) { |
|
| 2104 | + echo ' |
|
| 1998 | 2105 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="return submitThisOnce(this);" class="button">'; |
| 2106 | + } |
|
| 1999 | 2107 | echo ' |
| 2000 | 2108 | </div>'; |
| 2001 | 2109 | } |
| 2002 | 2110 | |
| 2003 | 2111 | // Show the closing form tag and other data only if not in the last step |
| 2004 | - if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) |
|
| 2005 | - echo ' |
|
| 2112 | + if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) { |
|
| 2113 | + echo ' |
|
| 2006 | 2114 | </form>'; |
| 2115 | + } |
|
| 2007 | 2116 | |
| 2008 | 2117 | echo ' |
| 2009 | 2118 | </div><!-- .panel --> |
@@ -2036,13 +2145,15 @@ discard block |
||
| 2036 | 2145 | </div>'; |
| 2037 | 2146 | |
| 2038 | 2147 | // Show the warnings, or not. |
| 2039 | - if (template_warning_divs()) |
|
| 2040 | - echo ' |
|
| 2148 | + if (template_warning_divs()) { |
|
| 2149 | + echo ' |
|
| 2041 | 2150 | <h3>', $txt['install_all_lovely'], '</h3>'; |
| 2151 | + } |
|
| 2042 | 2152 | |
| 2043 | 2153 | // Say we want the continue button! |
| 2044 | - if (empty($incontext['error'])) |
|
| 2045 | - $incontext['continue'] = 1; |
|
| 2154 | + if (empty($incontext['error'])) { |
|
| 2155 | + $incontext['continue'] = 1; |
|
| 2156 | + } |
|
| 2046 | 2157 | |
| 2047 | 2158 | // For the latest version stuff. |
| 2048 | 2159 | echo ' |
@@ -2076,19 +2187,21 @@ discard block |
||
| 2076 | 2187 | global $txt, $incontext; |
| 2077 | 2188 | |
| 2078 | 2189 | // Errors are very serious.. |
| 2079 | - if (!empty($incontext['error'])) |
|
| 2080 | - echo ' |
|
| 2190 | + if (!empty($incontext['error'])) { |
|
| 2191 | + echo ' |
|
| 2081 | 2192 | <div class="errorbox"> |
| 2082 | 2193 | <h3>', $txt['upgrade_critical_error'], '</h3> |
| 2083 | 2194 | ', $incontext['error'], ' |
| 2084 | 2195 | </div>'; |
| 2196 | + } |
|
| 2085 | 2197 | // A warning message? |
| 2086 | - elseif (!empty($incontext['warning'])) |
|
| 2087 | - echo ' |
|
| 2198 | + elseif (!empty($incontext['warning'])) { |
|
| 2199 | + echo ' |
|
| 2088 | 2200 | <div class="errorbox"> |
| 2089 | 2201 | <h3>', $txt['upgrade_warning'], '</h3> |
| 2090 | 2202 | ', $incontext['warning'], ' |
| 2091 | 2203 | </div>'; |
| 2204 | + } |
|
| 2092 | 2205 | |
| 2093 | 2206 | return empty($incontext['error']) && empty($incontext['warning']); |
| 2094 | 2207 | } |
@@ -2104,26 +2217,29 @@ discard block |
||
| 2104 | 2217 | <li>', $incontext['failed_files']), '</li> |
| 2105 | 2218 | </ul>'; |
| 2106 | 2219 | |
| 2107 | - if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') |
|
| 2108 | - echo ' |
|
| 2220 | + if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') { |
|
| 2221 | + echo ' |
|
| 2109 | 2222 | <hr> |
| 2110 | 2223 | <p>', $txt['chmod_linux_info'], '</p> |
| 2111 | 2224 | <tt># chmod a+w ', implode(' ' . $incontext['detected_path'] . '/', $incontext['failed_files']), '</tt>'; |
| 2225 | + } |
|
| 2112 | 2226 | |
| 2113 | 2227 | // This is serious! |
| 2114 | - if (!template_warning_divs()) |
|
| 2115 | - return; |
|
| 2228 | + if (!template_warning_divs()) { |
|
| 2229 | + return; |
|
| 2230 | + } |
|
| 2116 | 2231 | |
| 2117 | 2232 | echo ' |
| 2118 | 2233 | <hr> |
| 2119 | 2234 | <p>', $txt['ftp_setup_info'], '</p>'; |
| 2120 | 2235 | |
| 2121 | - if (!empty($incontext['ftp_errors'])) |
|
| 2122 | - echo ' |
|
| 2236 | + if (!empty($incontext['ftp_errors'])) { |
|
| 2237 | + echo ' |
|
| 2123 | 2238 | <div class="error_message"> |
| 2124 | 2239 | ', $txt['error_ftp_no_connect'], '<br><br> |
| 2125 | 2240 | <code>', implode('<br>', $incontext['ftp_errors']), '</code> |
| 2126 | 2241 | </div>'; |
| 2242 | + } |
|
| 2127 | 2243 | |
| 2128 | 2244 | echo ' |
| 2129 | 2245 | <form action="', $incontext['form_url'], '" method="post"> |
@@ -2192,16 +2308,16 @@ discard block |
||
| 2192 | 2308 | <dd> |
| 2193 | 2309 | <select name="db_type" id="db_type_input" onchange="toggleDBInput();">'; |
| 2194 | 2310 | |
| 2195 | - foreach ($incontext['supported_databases'] as $key => $db) |
|
| 2196 | - echo ' |
|
| 2311 | + foreach ($incontext['supported_databases'] as $key => $db) { |
|
| 2312 | + echo ' |
|
| 2197 | 2313 | <option value="', $key, '"', isset($_POST['db_type']) && $_POST['db_type'] == $key ? ' selected' : '', '>', $db['name'], '</option>'; |
| 2314 | + } |
|
| 2198 | 2315 | |
| 2199 | 2316 | echo ' |
| 2200 | 2317 | </select> |
| 2201 | 2318 | <div class="smalltext">', $txt['db_settings_type_info'], '</div> |
| 2202 | 2319 | </dd>'; |
| 2203 | - } |
|
| 2204 | - else |
|
| 2320 | + } else |
|
| 2205 | 2321 | { |
| 2206 | 2322 | echo ' |
| 2207 | 2323 | <dd> |
@@ -2376,9 +2492,10 @@ discard block |
||
| 2376 | 2492 | <div class="red">', $txt['error_db_queries'], '</div> |
| 2377 | 2493 | <ul>'; |
| 2378 | 2494 | |
| 2379 | - foreach ($incontext['failures'] as $line => $fail) |
|
| 2380 | - echo ' |
|
| 2495 | + foreach ($incontext['failures'] as $line => $fail) { |
|
| 2496 | + echo ' |
|
| 2381 | 2497 | <li><strong>', $txt['error_db_queries_line'], $line + 1, ':</strong> ', nl2br(htmlspecialchars($fail)), '</li>'; |
| 2498 | + } |
|
| 2382 | 2499 | |
| 2383 | 2500 | echo ' |
| 2384 | 2501 | </ul>'; |
@@ -2443,15 +2560,16 @@ discard block |
||
| 2443 | 2560 | </dd> |
| 2444 | 2561 | </dl>'; |
| 2445 | 2562 | |
| 2446 | - if ($incontext['require_db_confirm']) |
|
| 2447 | - echo ' |
|
| 2563 | + if ($incontext['require_db_confirm']) { |
|
| 2564 | + echo ' |
|
| 2448 | 2565 | <h2>', $txt['user_settings_database'], '</h2> |
| 2449 | 2566 | <p>', $txt['user_settings_database_info'], '</p> |
| 2450 | 2567 | |
| 2451 | 2568 | <div class="lefttext"> |
| 2452 | 2569 | <input type="password" name="password3" size="30"> |
| 2453 | 2570 | </div>'; |
| 2454 | -} |
|
| 2571 | + } |
|
| 2572 | + } |
|
| 2455 | 2573 | |
| 2456 | 2574 | // Tell them it's done, and to delete. |
| 2457 | 2575 | function template_delete_install() |
@@ -2464,13 +2582,14 @@ discard block |
||
| 2464 | 2582 | template_warning_divs(); |
| 2465 | 2583 | |
| 2466 | 2584 | // Install directory still writable? |
| 2467 | - if ($incontext['dir_still_writable']) |
|
| 2468 | - echo ' |
|
| 2585 | + if ($incontext['dir_still_writable']) { |
|
| 2586 | + echo ' |
|
| 2469 | 2587 | <p><em>', $txt['still_writable'], '</em></p>'; |
| 2588 | + } |
|
| 2470 | 2589 | |
| 2471 | 2590 | // Don't show the box if it's like 99% sure it won't work :P. |
| 2472 | - if ($incontext['probably_delete_install']) |
|
| 2473 | - echo ' |
|
| 2591 | + if ($incontext['probably_delete_install']) { |
|
| 2592 | + echo ' |
|
| 2474 | 2593 | <label> |
| 2475 | 2594 | <input type="checkbox" id="delete_self" onclick="doTheDelete();"> |
| 2476 | 2595 | <strong>', $txt['delete_installer'], !isset($_SESSION['installer_temp_ftp']) ? ' ' . $txt['delete_installer_maybe'] : '', '</strong> |
@@ -2486,6 +2605,7 @@ discard block |
||
| 2486 | 2605 | theCheck.disabled = true; |
| 2487 | 2606 | } |
| 2488 | 2607 | </script>'; |
| 2608 | + } |
|
| 2489 | 2609 | |
| 2490 | 2610 | echo ' |
| 2491 | 2611 | <p>', sprintf($txt['go_to_your_forum'], $boardurl . '/index.php'), '</p> |