@@ -1661,7 +1661,7 @@ discard block |
||
1661 | 1661 | |
1662 | 1662 | // Our custom error handler - does nothing but does stop public errors from XML! |
1663 | 1663 | set_error_handler( |
1664 | - function ($errno, $errstr, $errfile, $errline) use ($support_js) |
|
1664 | + function($errno, $errstr, $errfile, $errline) use ($support_js) |
|
1665 | 1665 | { |
1666 | 1666 | if ($support_js) |
1667 | 1667 | return true; |
@@ -2651,94 +2651,94 @@ discard block |
||
2651 | 2651 | // Translation table for the character sets not native for MySQL. |
2652 | 2652 | $translation_tables = array( |
2653 | 2653 | 'windows-1255' => array( |
2654 | - '0x81' => '\'\'', '0x8A' => '\'\'', '0x8C' => '\'\'', |
|
2655 | - '0x8D' => '\'\'', '0x8E' => '\'\'', '0x8F' => '\'\'', |
|
2656 | - '0x90' => '\'\'', '0x9A' => '\'\'', '0x9C' => '\'\'', |
|
2657 | - '0x9D' => '\'\'', '0x9E' => '\'\'', '0x9F' => '\'\'', |
|
2658 | - '0xCA' => '\'\'', '0xD9' => '\'\'', '0xDA' => '\'\'', |
|
2659 | - '0xDB' => '\'\'', '0xDC' => '\'\'', '0xDD' => '\'\'', |
|
2660 | - '0xDE' => '\'\'', '0xDF' => '\'\'', '0xFB' => '0xD792', |
|
2661 | - '0xFC' => '0xE282AC', '0xFF' => '0xD6B2', '0xC2' => '0xFF', |
|
2662 | - '0x80' => '0xFC', '0xE2' => '0xFB', '0xA0' => '0xC2A0', |
|
2663 | - '0xA1' => '0xC2A1', '0xA2' => '0xC2A2', '0xA3' => '0xC2A3', |
|
2664 | - '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
2665 | - '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
2666 | - '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
2667 | - '0xAF' => '0xC2AF', '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', |
|
2668 | - '0xB2' => '0xC2B2', '0xB3' => '0xC2B3', '0xB4' => '0xC2B4', |
|
2669 | - '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
2670 | - '0xB8' => '0xC2B8', '0xB9' => '0xC2B9', '0xBB' => '0xC2BB', |
|
2671 | - '0xBC' => '0xC2BC', '0xBD' => '0xC2BD', '0xBE' => '0xC2BE', |
|
2672 | - '0xBF' => '0xC2BF', '0xD7' => '0xD7B3', '0xD1' => '0xD781', |
|
2673 | - '0xD4' => '0xD7B0', '0xD5' => '0xD7B1', '0xD6' => '0xD7B2', |
|
2674 | - '0xE0' => '0xD790', '0xEA' => '0xD79A', '0xEC' => '0xD79C', |
|
2675 | - '0xED' => '0xD79D', '0xEE' => '0xD79E', '0xEF' => '0xD79F', |
|
2676 | - '0xF0' => '0xD7A0', '0xF1' => '0xD7A1', '0xF2' => '0xD7A2', |
|
2677 | - '0xF3' => '0xD7A3', '0xF5' => '0xD7A5', '0xF6' => '0xD7A6', |
|
2678 | - '0xF7' => '0xD7A7', '0xF8' => '0xD7A8', '0xF9' => '0xD7A9', |
|
2679 | - '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
2680 | - '0x86' => '0xE280A0', '0x87' => '0xE280A1', '0x89' => '0xE280B0', |
|
2681 | - '0x8B' => '0xE280B9', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
2682 | - '0x95' => '0xE280A2', '0x97' => '0xE28094', '0x99' => '0xE284A2', |
|
2683 | - '0xC0' => '0xD6B0', '0xC1' => '0xD6B1', '0xC3' => '0xD6B3', |
|
2684 | - '0xC4' => '0xD6B4', '0xC5' => '0xD6B5', '0xC6' => '0xD6B6', |
|
2685 | - '0xC7' => '0xD6B7', '0xC8' => '0xD6B8', '0xC9' => '0xD6B9', |
|
2686 | - '0xCB' => '0xD6BB', '0xCC' => '0xD6BC', '0xCD' => '0xD6BD', |
|
2687 | - '0xCE' => '0xD6BE', '0xCF' => '0xD6BF', '0xD0' => '0xD780', |
|
2688 | - '0xD2' => '0xD782', '0xE3' => '0xD793', '0xE4' => '0xD794', |
|
2689 | - '0xE5' => '0xD795', '0xE7' => '0xD797', '0xE9' => '0xD799', |
|
2690 | - '0xFD' => '0xE2808E', '0xFE' => '0xE2808F', '0x92' => '0xE28099', |
|
2691 | - '0x83' => '0xC692', '0xD3' => '0xD783', '0x88' => '0xCB86', |
|
2692 | - '0x98' => '0xCB9C', '0x91' => '0xE28098', '0x96' => '0xE28093', |
|
2693 | - '0xBA' => '0xC3B7', '0x9B' => '0xE280BA', '0xAA' => '0xC397', |
|
2694 | - '0xA4' => '0xE282AA', '0xE1' => '0xD791', '0xE6' => '0xD796', |
|
2695 | - '0xE8' => '0xD798', '0xEB' => '0xD79B', '0xF4' => '0xD7A4', |
|
2654 | + '0x81' => '\'\'', '0x8A' => '\'\'', '0x8C' => '\'\'', |
|
2655 | + '0x8D' => '\'\'', '0x8E' => '\'\'', '0x8F' => '\'\'', |
|
2656 | + '0x90' => '\'\'', '0x9A' => '\'\'', '0x9C' => '\'\'', |
|
2657 | + '0x9D' => '\'\'', '0x9E' => '\'\'', '0x9F' => '\'\'', |
|
2658 | + '0xCA' => '\'\'', '0xD9' => '\'\'', '0xDA' => '\'\'', |
|
2659 | + '0xDB' => '\'\'', '0xDC' => '\'\'', '0xDD' => '\'\'', |
|
2660 | + '0xDE' => '\'\'', '0xDF' => '\'\'', '0xFB' => '0xD792', |
|
2661 | + '0xFC' => '0xE282AC', '0xFF' => '0xD6B2', '0xC2' => '0xFF', |
|
2662 | + '0x80' => '0xFC', '0xE2' => '0xFB', '0xA0' => '0xC2A0', |
|
2663 | + '0xA1' => '0xC2A1', '0xA2' => '0xC2A2', '0xA3' => '0xC2A3', |
|
2664 | + '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
2665 | + '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
2666 | + '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
2667 | + '0xAF' => '0xC2AF', '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', |
|
2668 | + '0xB2' => '0xC2B2', '0xB3' => '0xC2B3', '0xB4' => '0xC2B4', |
|
2669 | + '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
2670 | + '0xB8' => '0xC2B8', '0xB9' => '0xC2B9', '0xBB' => '0xC2BB', |
|
2671 | + '0xBC' => '0xC2BC', '0xBD' => '0xC2BD', '0xBE' => '0xC2BE', |
|
2672 | + '0xBF' => '0xC2BF', '0xD7' => '0xD7B3', '0xD1' => '0xD781', |
|
2673 | + '0xD4' => '0xD7B0', '0xD5' => '0xD7B1', '0xD6' => '0xD7B2', |
|
2674 | + '0xE0' => '0xD790', '0xEA' => '0xD79A', '0xEC' => '0xD79C', |
|
2675 | + '0xED' => '0xD79D', '0xEE' => '0xD79E', '0xEF' => '0xD79F', |
|
2676 | + '0xF0' => '0xD7A0', '0xF1' => '0xD7A1', '0xF2' => '0xD7A2', |
|
2677 | + '0xF3' => '0xD7A3', '0xF5' => '0xD7A5', '0xF6' => '0xD7A6', |
|
2678 | + '0xF7' => '0xD7A7', '0xF8' => '0xD7A8', '0xF9' => '0xD7A9', |
|
2679 | + '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
2680 | + '0x86' => '0xE280A0', '0x87' => '0xE280A1', '0x89' => '0xE280B0', |
|
2681 | + '0x8B' => '0xE280B9', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
2682 | + '0x95' => '0xE280A2', '0x97' => '0xE28094', '0x99' => '0xE284A2', |
|
2683 | + '0xC0' => '0xD6B0', '0xC1' => '0xD6B1', '0xC3' => '0xD6B3', |
|
2684 | + '0xC4' => '0xD6B4', '0xC5' => '0xD6B5', '0xC6' => '0xD6B6', |
|
2685 | + '0xC7' => '0xD6B7', '0xC8' => '0xD6B8', '0xC9' => '0xD6B9', |
|
2686 | + '0xCB' => '0xD6BB', '0xCC' => '0xD6BC', '0xCD' => '0xD6BD', |
|
2687 | + '0xCE' => '0xD6BE', '0xCF' => '0xD6BF', '0xD0' => '0xD780', |
|
2688 | + '0xD2' => '0xD782', '0xE3' => '0xD793', '0xE4' => '0xD794', |
|
2689 | + '0xE5' => '0xD795', '0xE7' => '0xD797', '0xE9' => '0xD799', |
|
2690 | + '0xFD' => '0xE2808E', '0xFE' => '0xE2808F', '0x92' => '0xE28099', |
|
2691 | + '0x83' => '0xC692', '0xD3' => '0xD783', '0x88' => '0xCB86', |
|
2692 | + '0x98' => '0xCB9C', '0x91' => '0xE28098', '0x96' => '0xE28093', |
|
2693 | + '0xBA' => '0xC3B7', '0x9B' => '0xE280BA', '0xAA' => '0xC397', |
|
2694 | + '0xA4' => '0xE282AA', '0xE1' => '0xD791', '0xE6' => '0xD796', |
|
2695 | + '0xE8' => '0xD798', '0xEB' => '0xD79B', '0xF4' => '0xD7A4', |
|
2696 | 2696 | '0xFA' => '0xD7AA', |
2697 | 2697 | ), |
2698 | 2698 | 'windows-1253' => array( |
2699 | - '0x81' => '\'\'', '0x88' => '\'\'', '0x8A' => '\'\'', |
|
2700 | - '0x8C' => '\'\'', '0x8D' => '\'\'', '0x8E' => '\'\'', |
|
2701 | - '0x8F' => '\'\'', '0x90' => '\'\'', '0x98' => '\'\'', |
|
2702 | - '0x9A' => '\'\'', '0x9C' => '\'\'', '0x9D' => '\'\'', |
|
2703 | - '0x9E' => '\'\'', '0x9F' => '\'\'', '0xAA' => '\'\'', |
|
2704 | - '0xD2' => '0xE282AC', '0xFF' => '0xCE92', '0xCE' => '0xCE9E', |
|
2705 | - '0xB8' => '0xCE88', '0xBA' => '0xCE8A', '0xBC' => '0xCE8C', |
|
2706 | - '0xBE' => '0xCE8E', '0xBF' => '0xCE8F', '0xC0' => '0xCE90', |
|
2707 | - '0xC8' => '0xCE98', '0xCA' => '0xCE9A', '0xCC' => '0xCE9C', |
|
2708 | - '0xCD' => '0xCE9D', '0xCF' => '0xCE9F', '0xDA' => '0xCEAA', |
|
2709 | - '0xE8' => '0xCEB8', '0xEA' => '0xCEBA', '0xEC' => '0xCEBC', |
|
2710 | - '0xEE' => '0xCEBE', '0xEF' => '0xCEBF', '0xC2' => '0xFF', |
|
2711 | - '0xBD' => '0xC2BD', '0xED' => '0xCEBD', '0xB2' => '0xC2B2', |
|
2712 | - '0xA0' => '0xC2A0', '0xA3' => '0xC2A3', '0xA4' => '0xC2A4', |
|
2713 | - '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
2714 | - '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
2715 | - '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
2716 | - '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', '0xB3' => '0xC2B3', |
|
2717 | - '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
2718 | - '0xBB' => '0xC2BB', '0xE2' => '0xCEB2', '0x80' => '0xD2', |
|
2719 | - '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
2720 | - '0x86' => '0xE280A0', '0xA1' => '0xCE85', '0xA2' => '0xCE86', |
|
2721 | - '0x87' => '0xE280A1', '0x89' => '0xE280B0', '0xB9' => '0xCE89', |
|
2722 | - '0x8B' => '0xE280B9', '0x91' => '0xE28098', '0x99' => '0xE284A2', |
|
2723 | - '0x92' => '0xE28099', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
2724 | - '0x95' => '0xE280A2', '0x96' => '0xE28093', '0x97' => '0xE28094', |
|
2725 | - '0x9B' => '0xE280BA', '0xAF' => '0xE28095', '0xB4' => '0xCE84', |
|
2726 | - '0xC1' => '0xCE91', '0xC3' => '0xCE93', '0xC4' => '0xCE94', |
|
2727 | - '0xC5' => '0xCE95', '0xC6' => '0xCE96', '0x83' => '0xC692', |
|
2728 | - '0xC7' => '0xCE97', '0xC9' => '0xCE99', '0xCB' => '0xCE9B', |
|
2729 | - '0xD0' => '0xCEA0', '0xD1' => '0xCEA1', '0xD3' => '0xCEA3', |
|
2730 | - '0xD4' => '0xCEA4', '0xD5' => '0xCEA5', '0xD6' => '0xCEA6', |
|
2731 | - '0xD7' => '0xCEA7', '0xD8' => '0xCEA8', '0xD9' => '0xCEA9', |
|
2732 | - '0xDB' => '0xCEAB', '0xDC' => '0xCEAC', '0xDD' => '0xCEAD', |
|
2733 | - '0xDE' => '0xCEAE', '0xDF' => '0xCEAF', '0xE0' => '0xCEB0', |
|
2734 | - '0xE1' => '0xCEB1', '0xE3' => '0xCEB3', '0xE4' => '0xCEB4', |
|
2735 | - '0xE5' => '0xCEB5', '0xE6' => '0xCEB6', '0xE7' => '0xCEB7', |
|
2736 | - '0xE9' => '0xCEB9', '0xEB' => '0xCEBB', '0xF0' => '0xCF80', |
|
2737 | - '0xF1' => '0xCF81', '0xF2' => '0xCF82', '0xF3' => '0xCF83', |
|
2738 | - '0xF4' => '0xCF84', '0xF5' => '0xCF85', '0xF6' => '0xCF86', |
|
2739 | - '0xF7' => '0xCF87', '0xF8' => '0xCF88', '0xF9' => '0xCF89', |
|
2740 | - '0xFA' => '0xCF8A', '0xFB' => '0xCF8B', '0xFC' => '0xCF8C', |
|
2741 | - '0xFD' => '0xCF8D', '0xFE' => '0xCF8E', |
|
2699 | + '0x81' => '\'\'', '0x88' => '\'\'', '0x8A' => '\'\'', |
|
2700 | + '0x8C' => '\'\'', '0x8D' => '\'\'', '0x8E' => '\'\'', |
|
2701 | + '0x8F' => '\'\'', '0x90' => '\'\'', '0x98' => '\'\'', |
|
2702 | + '0x9A' => '\'\'', '0x9C' => '\'\'', '0x9D' => '\'\'', |
|
2703 | + '0x9E' => '\'\'', '0x9F' => '\'\'', '0xAA' => '\'\'', |
|
2704 | + '0xD2' => '0xE282AC', '0xFF' => '0xCE92', '0xCE' => '0xCE9E', |
|
2705 | + '0xB8' => '0xCE88', '0xBA' => '0xCE8A', '0xBC' => '0xCE8C', |
|
2706 | + '0xBE' => '0xCE8E', '0xBF' => '0xCE8F', '0xC0' => '0xCE90', |
|
2707 | + '0xC8' => '0xCE98', '0xCA' => '0xCE9A', '0xCC' => '0xCE9C', |
|
2708 | + '0xCD' => '0xCE9D', '0xCF' => '0xCE9F', '0xDA' => '0xCEAA', |
|
2709 | + '0xE8' => '0xCEB8', '0xEA' => '0xCEBA', '0xEC' => '0xCEBC', |
|
2710 | + '0xEE' => '0xCEBE', '0xEF' => '0xCEBF', '0xC2' => '0xFF', |
|
2711 | + '0xBD' => '0xC2BD', '0xED' => '0xCEBD', '0xB2' => '0xC2B2', |
|
2712 | + '0xA0' => '0xC2A0', '0xA3' => '0xC2A3', '0xA4' => '0xC2A4', |
|
2713 | + '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
2714 | + '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
2715 | + '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
2716 | + '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', '0xB3' => '0xC2B3', |
|
2717 | + '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
2718 | + '0xBB' => '0xC2BB', '0xE2' => '0xCEB2', '0x80' => '0xD2', |
|
2719 | + '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
2720 | + '0x86' => '0xE280A0', '0xA1' => '0xCE85', '0xA2' => '0xCE86', |
|
2721 | + '0x87' => '0xE280A1', '0x89' => '0xE280B0', '0xB9' => '0xCE89', |
|
2722 | + '0x8B' => '0xE280B9', '0x91' => '0xE28098', '0x99' => '0xE284A2', |
|
2723 | + '0x92' => '0xE28099', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
2724 | + '0x95' => '0xE280A2', '0x96' => '0xE28093', '0x97' => '0xE28094', |
|
2725 | + '0x9B' => '0xE280BA', '0xAF' => '0xE28095', '0xB4' => '0xCE84', |
|
2726 | + '0xC1' => '0xCE91', '0xC3' => '0xCE93', '0xC4' => '0xCE94', |
|
2727 | + '0xC5' => '0xCE95', '0xC6' => '0xCE96', '0x83' => '0xC692', |
|
2728 | + '0xC7' => '0xCE97', '0xC9' => '0xCE99', '0xCB' => '0xCE9B', |
|
2729 | + '0xD0' => '0xCEA0', '0xD1' => '0xCEA1', '0xD3' => '0xCEA3', |
|
2730 | + '0xD4' => '0xCEA4', '0xD5' => '0xCEA5', '0xD6' => '0xCEA6', |
|
2731 | + '0xD7' => '0xCEA7', '0xD8' => '0xCEA8', '0xD9' => '0xCEA9', |
|
2732 | + '0xDB' => '0xCEAB', '0xDC' => '0xCEAC', '0xDD' => '0xCEAD', |
|
2733 | + '0xDE' => '0xCEAE', '0xDF' => '0xCEAF', '0xE0' => '0xCEB0', |
|
2734 | + '0xE1' => '0xCEB1', '0xE3' => '0xCEB3', '0xE4' => '0xCEB4', |
|
2735 | + '0xE5' => '0xCEB5', '0xE6' => '0xCEB6', '0xE7' => '0xCEB7', |
|
2736 | + '0xE9' => '0xCEB9', '0xEB' => '0xCEBB', '0xF0' => '0xCF80', |
|
2737 | + '0xF1' => '0xCF81', '0xF2' => '0xCF82', '0xF3' => '0xCF83', |
|
2738 | + '0xF4' => '0xCF84', '0xF5' => '0xCF85', '0xF6' => '0xCF86', |
|
2739 | + '0xF7' => '0xCF87', '0xF8' => '0xCF88', '0xF9' => '0xCF89', |
|
2740 | + '0xFA' => '0xCF8A', '0xFB' => '0xCF8B', '0xFC' => '0xCF8C', |
|
2741 | + '0xFD' => '0xCF8D', '0xFE' => '0xCF8E', |
|
2742 | 2742 | ), |
2743 | 2743 | ); |
2744 | 2744 | |
@@ -3638,7 +3638,7 @@ discard block |
||
3638 | 3638 | |
3639 | 3639 | if ($active < 600) |
3640 | 3640 | echo ' |
3641 | - ', $txt['upgrade_run_script'], ' ', $upcontext['user']['name'],' ', $txt['upgrade_run_script2'], ''; |
|
3641 | + ', $txt['upgrade_run_script'], ' ', $upcontext['user']['name'], ' ', $txt['upgrade_run_script2'], ''; |
|
3642 | 3642 | |
3643 | 3643 | if ($active > $upcontext['inactive_timeout']) |
3644 | 3644 | echo ' |
@@ -3840,7 +3840,7 @@ discard block |
||
3840 | 3840 | <form action="', $upcontext['form_url'], '" name="upform" id="upform" method="post"> |
3841 | 3841 | <input type="hidden" name="backup_done" id="backup_done" value="0"> |
3842 | 3842 | <strong>Completed <span id="tab_done">', $upcontext['cur_table_num'], '</span> out of ', $upcontext['table_count'], ' tables.</strong> |
3843 | - <div id="debug_section" style="height: ', ($is_debug ? '115' : '12') , 'px; overflow: auto;"> |
|
3843 | + <div id="debug_section" style="height: ', ($is_debug ? '115' : '12'), 'px; overflow: auto;"> |
|
3844 | 3844 | <span id="debuginfo"></span> |
3845 | 3845 | </div>'; |
3846 | 3846 | |
@@ -4341,7 +4341,7 @@ discard block |
||
4341 | 4341 | <form action="', $upcontext['form_url'], '" name="upform" id="upform" method="post"> |
4342 | 4342 | <input type="hidden" name="utf8_done" id="utf8_done" value="0"> |
4343 | 4343 | <strong>', $txt['upgrade_completed'], ' <span id="tab_done">', $upcontext['cur_table_num'], '</span> ', $txt['upgrade_outof'], ' ', $upcontext['table_count'], ' ', $txt['upgrade_tables'], '</strong> |
4344 | - <div id="debug_section" style="height: ', ($is_debug ? '97' : '12') , 'px; overflow: auto;"> |
|
4344 | + <div id="debug_section" style="height: ', ($is_debug ? '97' : '12'), 'px; overflow: auto;"> |
|
4345 | 4345 | <span id="debuginfo"></span> |
4346 | 4346 | </div>'; |
4347 | 4347 | |
@@ -4442,7 +4442,7 @@ discard block |
||
4442 | 4442 | <form action="', $upcontext['form_url'], '" name="upform" id="upform" method="post"> |
4443 | 4443 | <input type="hidden" name="json_done" id="json_done" value="0"> |
4444 | 4444 | <strong>', $txt['upgrade_completed'], ' <span id="tab_done">', $upcontext['cur_table_num'], '</span> ', $txt['upgrade_outof'], ' ', $upcontext['table_count'], ' ', $txt['upgrade_tables'], '</strong> |
4445 | - <div id="debug_section" style="height: ', ($is_debug ? '115' : '12') , 'px; overflow: auto;"> |
|
4445 | + <div id="debug_section" style="height: ', ($is_debug ? '115' : '12'), 'px; overflow: auto;"> |
|
4446 | 4446 | <span id="debuginfo"></span> |
4447 | 4447 | </div>'; |
4448 | 4448 |
@@ -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 | |
@@ -102,11 +103,14 @@ discard block |
||
102 | 103 | ini_set('default_socket_timeout', 900); |
103 | 104 | } |
104 | 105 | // Clean the upgrade path if this is from the client. |
105 | -if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) |
|
106 | - for ($i = 1; $i < $_SERVER['argc']; $i++) |
|
106 | +if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) { |
|
107 | + for ($i = 1; |
|
108 | +} |
|
109 | +$i < $_SERVER['argc']; $i++) |
|
107 | 110 | { |
108 | - if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) |
|
109 | - $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
111 | + if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) { |
|
112 | + $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
113 | + } |
|
110 | 114 | } |
111 | 115 | |
112 | 116 | // Are we from the client? |
@@ -114,16 +118,17 @@ discard block |
||
114 | 118 | { |
115 | 119 | $command_line = true; |
116 | 120 | $disable_security = true; |
117 | -} |
|
118 | -else |
|
121 | +} else { |
|
119 | 122 | $command_line = false; |
123 | +} |
|
120 | 124 | |
121 | 125 | // Load this now just because we can. |
122 | 126 | require_once($upgrade_path . '/Settings.php'); |
123 | 127 | |
124 | 128 | // We don't use "-utf8" anymore... Tweak the entry that may have been loaded by Settings.php |
125 | -if (isset($language)) |
|
129 | +if (isset($language)) { |
|
126 | 130 | $language = str_ireplace('-utf8', '', $language); |
131 | +} |
|
127 | 132 | |
128 | 133 | // Are we logged in? |
129 | 134 | if (isset($upgradeData)) |
@@ -131,10 +136,12 @@ discard block |
||
131 | 136 | $upcontext['user'] = json_decode(base64_decode($upgradeData), true); |
132 | 137 | |
133 | 138 | // Check for sensible values. |
134 | - if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) |
|
135 | - $upcontext['user']['started'] = time(); |
|
136 | - if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) |
|
137 | - $upcontext['user']['updated'] = 0; |
|
139 | + if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) { |
|
140 | + $upcontext['user']['started'] = time(); |
|
141 | + } |
|
142 | + if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) { |
|
143 | + $upcontext['user']['updated'] = 0; |
|
144 | + } |
|
138 | 145 | |
139 | 146 | $upcontext['started'] = $upcontext['user']['started']; |
140 | 147 | $upcontext['updated'] = $upcontext['user']['updated']; |
@@ -199,8 +206,9 @@ discard block |
||
199 | 206 | 'db_error_skip' => true, |
200 | 207 | ) |
201 | 208 | ); |
202 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
203 | - $modSettings[$row['variable']] = $row['value']; |
|
209 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
210 | + $modSettings[$row['variable']] = $row['value']; |
|
211 | + } |
|
204 | 212 | $smcFunc['db_free_result']($request); |
205 | 213 | } |
206 | 214 | |
@@ -210,10 +218,12 @@ discard block |
||
210 | 218 | $modSettings['theme_url'] = 'Themes/default'; |
211 | 219 | $modSettings['images_url'] = 'Themes/default/images'; |
212 | 220 | } |
213 | -if (!isset($settings['default_theme_url'])) |
|
221 | +if (!isset($settings['default_theme_url'])) { |
|
214 | 222 | $settings['default_theme_url'] = $modSettings['theme_url']; |
215 | -if (!isset($settings['default_theme_dir'])) |
|
223 | +} |
|
224 | +if (!isset($settings['default_theme_dir'])) { |
|
216 | 225 | $settings['default_theme_dir'] = $modSettings['theme_dir']; |
226 | +} |
|
217 | 227 | |
218 | 228 | $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000; |
219 | 229 | // Default title... |
@@ -231,13 +241,15 @@ discard block |
||
231 | 241 | $support_js = $upcontext['upgrade_status']['js']; |
232 | 242 | |
233 | 243 | // Only set this if the upgrader status says so. |
234 | - if (empty($is_debug)) |
|
235 | - $is_debug = $upcontext['upgrade_status']['debug']; |
|
244 | + if (empty($is_debug)) { |
|
245 | + $is_debug = $upcontext['upgrade_status']['debug']; |
|
246 | + } |
|
236 | 247 | |
237 | 248 | // Load the language. |
238 | - if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
239 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
240 | -} |
|
249 | + if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
250 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
251 | + } |
|
252 | + } |
|
241 | 253 | // Set the defaults. |
242 | 254 | else |
243 | 255 | { |
@@ -255,15 +267,18 @@ discard block |
||
255 | 267 | } |
256 | 268 | |
257 | 269 | // If this isn't the first stage see whether they are logging in and resuming. |
258 | -if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) |
|
270 | +if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) { |
|
259 | 271 | checkLogin(); |
272 | +} |
|
260 | 273 | |
261 | -if ($command_line) |
|
274 | +if ($command_line) { |
|
262 | 275 | cmdStep0(); |
276 | +} |
|
263 | 277 | |
264 | 278 | // Don't error if we're using xml. |
265 | -if (isset($_GET['xml'])) |
|
279 | +if (isset($_GET['xml'])) { |
|
266 | 280 | $upcontext['return_error'] = true; |
281 | +} |
|
267 | 282 | |
268 | 283 | // Loop through all the steps doing each one as required. |
269 | 284 | $upcontext['overall_percent'] = 0; |
@@ -284,9 +299,9 @@ discard block |
||
284 | 299 | } |
285 | 300 | |
286 | 301 | // Call the step and if it returns false that means pause! |
287 | - if (function_exists($step[2]) && $step[2]() === false) |
|
288 | - break; |
|
289 | - elseif (function_exists($step[2])) { |
|
302 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
303 | + break; |
|
304 | + } elseif (function_exists($step[2])) { |
|
290 | 305 | //Start each new step with this unset, so the 'normal' template is called first |
291 | 306 | unset($_GET['xml']); |
292 | 307 | //Clear out warnings at the start of each step |
@@ -332,17 +347,18 @@ discard block |
||
332 | 347 | // This should not happen my dear... HELP ME DEVELOPERS!! |
333 | 348 | if (!empty($command_line)) |
334 | 349 | { |
335 | - if (function_exists('debug_print_backtrace')) |
|
336 | - debug_print_backtrace(); |
|
350 | + if (function_exists('debug_print_backtrace')) { |
|
351 | + debug_print_backtrace(); |
|
352 | + } |
|
337 | 353 | |
338 | 354 | 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.'; |
339 | 355 | flush(); |
340 | 356 | die(); |
341 | 357 | } |
342 | 358 | |
343 | - if (!isset($_GET['xml'])) |
|
344 | - template_upgrade_above(); |
|
345 | - else |
|
359 | + if (!isset($_GET['xml'])) { |
|
360 | + template_upgrade_above(); |
|
361 | + } else |
|
346 | 362 | { |
347 | 363 | header('Content-Type: text/xml; charset=UTF-8'); |
348 | 364 | // Sadly we need to retain the $_GET data thanks to the old upgrade scripts. |
@@ -364,25 +380,29 @@ discard block |
||
364 | 380 | $upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&substep=' . $_GET['substep'] . '&data=' . base64_encode(json_encode($upcontext['upgrade_status'])); |
365 | 381 | |
366 | 382 | // Custom stuff to pass back? |
367 | - if (!empty($upcontext['query_string'])) |
|
368 | - $upcontext['form_url'] .= $upcontext['query_string']; |
|
383 | + if (!empty($upcontext['query_string'])) { |
|
384 | + $upcontext['form_url'] .= $upcontext['query_string']; |
|
385 | + } |
|
369 | 386 | |
370 | 387 | // Call the appropriate subtemplate |
371 | - if (is_callable('template_' . $upcontext['sub_template'])) |
|
372 | - call_user_func('template_' . $upcontext['sub_template']); |
|
373 | - else |
|
374 | - die('Upgrade aborted! Invalid template: template_' . $upcontext['sub_template']); |
|
388 | + if (is_callable('template_' . $upcontext['sub_template'])) { |
|
389 | + call_user_func('template_' . $upcontext['sub_template']); |
|
390 | + } else { |
|
391 | + die('Upgrade aborted! Invalid template: template_' . $upcontext['sub_template']); |
|
392 | + } |
|
375 | 393 | } |
376 | 394 | |
377 | 395 | // Was there an error? |
378 | - if (!empty($upcontext['forced_error_message'])) |
|
379 | - echo $upcontext['forced_error_message']; |
|
396 | + if (!empty($upcontext['forced_error_message'])) { |
|
397 | + echo $upcontext['forced_error_message']; |
|
398 | + } |
|
380 | 399 | |
381 | 400 | // Show the footer. |
382 | - if (!isset($_GET['xml'])) |
|
383 | - template_upgrade_below(); |
|
384 | - else |
|
385 | - template_xml_below(); |
|
401 | + if (!isset($_GET['xml'])) { |
|
402 | + template_upgrade_below(); |
|
403 | + } else { |
|
404 | + template_xml_below(); |
|
405 | + } |
|
386 | 406 | } |
387 | 407 | |
388 | 408 | |
@@ -394,15 +414,19 @@ discard block |
||
394 | 414 | $seconds = intval($active % 60); |
395 | 415 | |
396 | 416 | $totalTime = ''; |
397 | - if ($hours > 0) |
|
398 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
399 | - if ($minutes > 0) |
|
400 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
401 | - if ($seconds > 0) |
|
402 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
417 | + if ($hours > 0) { |
|
418 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
419 | + } |
|
420 | + if ($minutes > 0) { |
|
421 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
422 | + } |
|
423 | + if ($seconds > 0) { |
|
424 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
425 | + } |
|
403 | 426 | |
404 | - if (!empty($totalTime)) |
|
405 | - echo "\n" . '', $txt['upgrade_completed_time'], ' ' . $totalTime . "\n"; |
|
427 | + if (!empty($totalTime)) { |
|
428 | + echo "\n" . '', $txt['upgrade_completed_time'], ' ' . $totalTime . "\n"; |
|
429 | + } |
|
406 | 430 | } |
407 | 431 | |
408 | 432 | // Bang - gone! |
@@ -422,8 +446,9 @@ discard block |
||
422 | 446 | $dir = dir(dirname(__FILE__) . '/Themes/default/languages'); |
423 | 447 | while ($entry = $dir->read()) |
424 | 448 | { |
425 | - if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') |
|
426 | - $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
449 | + if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') { |
|
450 | + $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
451 | + } |
|
427 | 452 | } |
428 | 453 | $dir->close(); |
429 | 454 | } |
@@ -463,8 +488,9 @@ discard block |
||
463 | 488 | global $upgradeurl, $upcontext, $command_line; |
464 | 489 | |
465 | 490 | // Command line users can't be redirected. |
466 | - if ($command_line) |
|
467 | - upgradeExit(true); |
|
491 | + if ($command_line) { |
|
492 | + upgradeExit(true); |
|
493 | + } |
|
468 | 494 | |
469 | 495 | // Are we providing the core info? |
470 | 496 | if ($addForm) |
@@ -490,12 +516,14 @@ discard block |
||
490 | 516 | define('SMF', 1); |
491 | 517 | |
492 | 518 | // Start the session. |
493 | - if (@ini_get('session.save_handler') == 'user') |
|
494 | - @ini_set('session.save_handler', 'files'); |
|
519 | + if (@ini_get('session.save_handler') == 'user') { |
|
520 | + @ini_set('session.save_handler', 'files'); |
|
521 | + } |
|
495 | 522 | @session_start(); |
496 | 523 | |
497 | - if (empty($smcFunc)) |
|
498 | - $smcFunc = array(); |
|
524 | + if (empty($smcFunc)) { |
|
525 | + $smcFunc = array(); |
|
526 | + } |
|
499 | 527 | |
500 | 528 | // We need this for authentication and some upgrade code |
501 | 529 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -522,24 +550,27 @@ discard block |
||
522 | 550 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
523 | 551 | |
524 | 552 | // Make the connection... |
525 | - if (empty($db_connection)) |
|
526 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
|
527 | - else |
|
528 | - // If we've returned here, ping/reconnect to be safe |
|
553 | + if (empty($db_connection)) { |
|
554 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
|
555 | + } else { |
|
556 | + // If we've returned here, ping/reconnect to be safe |
|
529 | 557 | $smcFunc['db_ping']($db_connection); |
558 | + } |
|
530 | 559 | |
531 | 560 | // Oh dear god!! |
532 | - if ($db_connection === null) |
|
533 | - die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
561 | + if ($db_connection === null) { |
|
562 | + die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
563 | + } |
|
534 | 564 | |
535 | - if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) |
|
536 | - $smcFunc['db_query']('', ' |
|
565 | + if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) { |
|
566 | + $smcFunc['db_query']('', ' |
|
537 | 567 | SET NAMES {string:db_character_set}', |
538 | 568 | array( |
539 | 569 | 'db_error_skip' => true, |
540 | 570 | 'db_character_set' => $db_character_set, |
541 | 571 | ) |
542 | 572 | ); |
573 | + } |
|
543 | 574 | |
544 | 575 | // Load the modSettings data... |
545 | 576 | $request = $smcFunc['db_query']('', ' |
@@ -550,11 +581,11 @@ discard block |
||
550 | 581 | ) |
551 | 582 | ); |
552 | 583 | $modSettings = array(); |
553 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
554 | - $modSettings[$row['variable']] = $row['value']; |
|
584 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
585 | + $modSettings[$row['variable']] = $row['value']; |
|
586 | + } |
|
555 | 587 | $smcFunc['db_free_result']($request); |
556 | - } |
|
557 | - else |
|
588 | + } else |
|
558 | 589 | { |
559 | 590 | 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.'); |
560 | 591 | } |
@@ -568,9 +599,10 @@ discard block |
||
568 | 599 | cleanRequest(); |
569 | 600 | } |
570 | 601 | |
571 | - if (!isset($_GET['substep'])) |
|
572 | - $_GET['substep'] = 0; |
|
573 | -} |
|
602 | + if (!isset($_GET['substep'])) { |
|
603 | + $_GET['substep'] = 0; |
|
604 | + } |
|
605 | + } |
|
574 | 606 | |
575 | 607 | function initialize_inputs() |
576 | 608 | { |
@@ -600,8 +632,9 @@ discard block |
||
600 | 632 | $dh = opendir(dirname(__FILE__)); |
601 | 633 | while ($file = readdir($dh)) |
602 | 634 | { |
603 | - if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) |
|
604 | - @unlink(dirname(__FILE__) . '/' . $file); |
|
635 | + if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) { |
|
636 | + @unlink(dirname(__FILE__) . '/' . $file); |
|
637 | + } |
|
605 | 638 | } |
606 | 639 | closedir($dh); |
607 | 640 | |
@@ -630,8 +663,9 @@ discard block |
||
630 | 663 | $temp = 'upgrade_php?step'; |
631 | 664 | while (strlen($temp) > 4) |
632 | 665 | { |
633 | - if (isset($_GET[$temp])) |
|
634 | - unset($_GET[$temp]); |
|
666 | + if (isset($_GET[$temp])) { |
|
667 | + unset($_GET[$temp]); |
|
668 | + } |
|
635 | 669 | $temp = substr($temp, 1); |
636 | 670 | } |
637 | 671 | |
@@ -658,32 +692,39 @@ discard block |
||
658 | 692 | && @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $db_type . '.sql'); |
659 | 693 | |
660 | 694 | // Need legacy scripts? |
661 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) |
|
662 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
663 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) |
|
664 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
665 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) |
|
666 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
695 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) { |
|
696 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
697 | + } |
|
698 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) { |
|
699 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
700 | + } |
|
701 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) { |
|
702 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
703 | + } |
|
667 | 704 | |
668 | 705 | // We don't need "-utf8" files anymore... |
669 | 706 | $upcontext['language'] = str_ireplace('-utf8', '', $upcontext['language']); |
670 | 707 | |
671 | 708 | // This needs to exist! |
672 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
673 | - 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>]'); |
|
674 | - else |
|
675 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
709 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
710 | + 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>]'); |
|
711 | + } else { |
|
712 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
713 | + } |
|
676 | 714 | |
677 | - if (!$check) |
|
678 | - // 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. |
|
715 | + if (!$check) { |
|
716 | + // 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. |
|
679 | 717 | 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.'); |
718 | + } |
|
680 | 719 | |
681 | 720 | // Do they meet the install requirements? |
682 | - if (!php_version_check()) |
|
683 | - 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.'); |
|
721 | + if (!php_version_check()) { |
|
722 | + 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.'); |
|
723 | + } |
|
684 | 724 | |
685 | - if (!db_version_check()) |
|
686 | - 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.'); |
|
725 | + if (!db_version_check()) { |
|
726 | + 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.'); |
|
727 | + } |
|
687 | 728 | |
688 | 729 | // Do some checks to make sure they have proper privileges |
689 | 730 | db_extend('packages'); |
@@ -698,14 +739,16 @@ discard block |
||
698 | 739 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
699 | 740 | |
700 | 741 | // Sorry... we need CREATE, ALTER and DROP |
701 | - if (!$create || !$alter || !$drop) |
|
702 | - 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.'); |
|
742 | + if (!$create || !$alter || !$drop) { |
|
743 | + 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.'); |
|
744 | + } |
|
703 | 745 | |
704 | 746 | // Do a quick version spot check. |
705 | 747 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
706 | 748 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
707 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
708 | - 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.'); |
|
749 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
750 | + 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.'); |
|
751 | + } |
|
709 | 752 | |
710 | 753 | // What absolutely needs to be writable? |
711 | 754 | $writable_files = array( |
@@ -727,12 +770,13 @@ discard block |
||
727 | 770 | quickFileWritable($custom_av_dir); |
728 | 771 | |
729 | 772 | // Are we good now? |
730 | - if (!is_writable($custom_av_dir)) |
|
731 | - 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)); |
|
732 | - elseif ($need_settings_update) |
|
773 | + if (!is_writable($custom_av_dir)) { |
|
774 | + 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)); |
|
775 | + } elseif ($need_settings_update) |
|
733 | 776 | { |
734 | - if (!function_exists('cache_put_data')) |
|
735 | - require_once($sourcedir . '/Load.php'); |
|
777 | + if (!function_exists('cache_put_data')) { |
|
778 | + require_once($sourcedir . '/Load.php'); |
|
779 | + } |
|
736 | 780 | updateSettings(array('custom_avatar_dir' => $custom_av_dir)); |
737 | 781 | updateSettings(array('custom_avatar_url' => $custom_av_url)); |
738 | 782 | } |
@@ -741,28 +785,33 @@ discard block |
||
741 | 785 | |
742 | 786 | // Check the cache directory. |
743 | 787 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
744 | - if (!file_exists($cachedir_temp)) |
|
745 | - @mkdir($cachedir_temp); |
|
746 | - if (!file_exists($cachedir_temp)) |
|
747 | - 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.'); |
|
748 | - |
|
749 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
750 | - 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>.'); |
|
751 | - elseif (!isset($_GET['skiplang'])) |
|
788 | + if (!file_exists($cachedir_temp)) { |
|
789 | + @mkdir($cachedir_temp); |
|
790 | + } |
|
791 | + if (!file_exists($cachedir_temp)) { |
|
792 | + 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.'); |
|
793 | + } |
|
794 | + |
|
795 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
796 | + 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>.'); |
|
797 | + } elseif (!isset($_GET['skiplang'])) |
|
752 | 798 | { |
753 | 799 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
754 | 800 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
755 | 801 | |
756 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
757 | - 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>]'); |
|
802 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
803 | + 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>]'); |
|
804 | + } |
|
758 | 805 | } |
759 | 806 | |
760 | - if (!makeFilesWritable($writable_files)) |
|
761 | - return false; |
|
807 | + if (!makeFilesWritable($writable_files)) { |
|
808 | + return false; |
|
809 | + } |
|
762 | 810 | |
763 | 811 | // Check agreement.txt. (it may not exist, in which case $boarddir must be writable.) |
764 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
765 | - 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.'); |
|
812 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
813 | + 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.'); |
|
814 | + } |
|
766 | 815 | |
767 | 816 | // Upgrade the agreement. |
768 | 817 | elseif (isset($modSettings['agreement'])) |
@@ -773,8 +822,8 @@ discard block |
||
773 | 822 | } |
774 | 823 | |
775 | 824 | // We're going to check that their board dir setting is right in case they've been moving stuff around. |
776 | - if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) |
|
777 | - $upcontext['warning'] = ' |
|
825 | + if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) { |
|
826 | + $upcontext['warning'] = ' |
|
778 | 827 | 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> |
779 | 828 | <ul> |
780 | 829 | <li>Board Directory: ' . $boarddir . '</li> |
@@ -782,19 +831,23 @@ discard block |
||
782 | 831 | <li>Cache Directory: ' . $cachedir_temp . '</li> |
783 | 832 | </ul> |
784 | 833 | 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.'; |
834 | + } |
|
785 | 835 | |
786 | 836 | // Confirm mbstring is loaded... |
787 | - if (!extension_loaded('mbstring')) |
|
788 | - return throw_error($txt['install_no_mbstring']); |
|
837 | + if (!extension_loaded('mbstring')) { |
|
838 | + return throw_error($txt['install_no_mbstring']); |
|
839 | + } |
|
789 | 840 | |
790 | 841 | // Check for https stream support. |
791 | 842 | $supported_streams = stream_get_wrappers(); |
792 | - if (!in_array('https', $supported_streams)) |
|
793 | - $upcontext['custom_warning'] = $txt['install_no_https']; |
|
843 | + if (!in_array('https', $supported_streams)) { |
|
844 | + $upcontext['custom_warning'] = $txt['install_no_https']; |
|
845 | + } |
|
794 | 846 | |
795 | 847 | // Either we're logged in or we're going to present the login. |
796 | - if (checkLogin()) |
|
797 | - return true; |
|
848 | + if (checkLogin()) { |
|
849 | + return true; |
|
850 | + } |
|
798 | 851 | |
799 | 852 | $upcontext += createToken('login'); |
800 | 853 | |
@@ -808,15 +861,17 @@ discard block |
||
808 | 861 | global $smcFunc, $db_type, $support_js; |
809 | 862 | |
810 | 863 | // Don't bother if the security is disabled. |
811 | - if ($disable_security) |
|
812 | - return true; |
|
864 | + if ($disable_security) { |
|
865 | + return true; |
|
866 | + } |
|
813 | 867 | |
814 | 868 | // Are we trying to login? |
815 | 869 | if (isset($_POST['contbutt']) && (!empty($_POST['user']))) |
816 | 870 | { |
817 | 871 | // If we've disabled security pick a suitable name! |
818 | - if (empty($_POST['user'])) |
|
819 | - $_POST['user'] = 'Administrator'; |
|
872 | + if (empty($_POST['user'])) { |
|
873 | + $_POST['user'] = 'Administrator'; |
|
874 | + } |
|
820 | 875 | |
821 | 876 | // Before 2.0 these column names were different! |
822 | 877 | $oldDB = false; |
@@ -831,16 +886,17 @@ discard block |
||
831 | 886 | 'db_error_skip' => true, |
832 | 887 | ) |
833 | 888 | ); |
834 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
835 | - $oldDB = true; |
|
889 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
890 | + $oldDB = true; |
|
891 | + } |
|
836 | 892 | $smcFunc['db_free_result']($request); |
837 | 893 | } |
838 | 894 | |
839 | 895 | // Get what we believe to be their details. |
840 | 896 | if (!$disable_security) |
841 | 897 | { |
842 | - if ($oldDB) |
|
843 | - $request = $smcFunc['db_query']('', ' |
|
898 | + if ($oldDB) { |
|
899 | + $request = $smcFunc['db_query']('', ' |
|
844 | 900 | SELECT id_member, memberName AS member_name, passwd, id_group, |
845 | 901 | additionalGroups AS additional_groups, lngfile |
846 | 902 | FROM {db_prefix}members |
@@ -850,8 +906,8 @@ discard block |
||
850 | 906 | 'db_error_skip' => true, |
851 | 907 | ) |
852 | 908 | ); |
853 | - else |
|
854 | - $request = $smcFunc['db_query']('', ' |
|
909 | + } else { |
|
910 | + $request = $smcFunc['db_query']('', ' |
|
855 | 911 | SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile |
856 | 912 | FROM {db_prefix}members |
857 | 913 | WHERE member_name = {string:member_name}', |
@@ -860,6 +916,7 @@ discard block |
||
860 | 916 | 'db_error_skip' => true, |
861 | 917 | ) |
862 | 918 | ); |
919 | + } |
|
863 | 920 | if ($smcFunc['db_num_rows']($request) != 0) |
864 | 921 | { |
865 | 922 | list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request); |
@@ -867,16 +924,17 @@ discard block |
||
867 | 924 | $groups = explode(',', $addGroups); |
868 | 925 | $groups[] = $id_group; |
869 | 926 | |
870 | - foreach ($groups as $k => $v) |
|
871 | - $groups[$k] = (int) $v; |
|
927 | + foreach ($groups as $k => $v) { |
|
928 | + $groups[$k] = (int) $v; |
|
929 | + } |
|
872 | 930 | |
873 | 931 | $sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd'])); |
874 | 932 | |
875 | 933 | // We don't use "-utf8" anymore... |
876 | 934 | $user_language = str_ireplace('-utf8', '', $user_language); |
935 | + } else { |
|
936 | + $upcontext['username_incorrect'] = true; |
|
877 | 937 | } |
878 | - else |
|
879 | - $upcontext['username_incorrect'] = true; |
|
880 | 938 | $smcFunc['db_free_result']($request); |
881 | 939 | } |
882 | 940 | $upcontext['username'] = $_POST['user']; |
@@ -886,13 +944,14 @@ discard block |
||
886 | 944 | { |
887 | 945 | $upcontext['upgrade_status']['js'] = 1; |
888 | 946 | $support_js = 1; |
947 | + } else { |
|
948 | + $support_js = 0; |
|
889 | 949 | } |
890 | - else |
|
891 | - $support_js = 0; |
|
892 | 950 | |
893 | 951 | // Note down the version we are coming from. |
894 | - if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) |
|
895 | - $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
952 | + if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) { |
|
953 | + $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
954 | + } |
|
896 | 955 | |
897 | 956 | // Didn't get anywhere? |
898 | 957 | 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'])) |
@@ -926,15 +985,15 @@ discard block |
||
926 | 985 | 'db_error_skip' => true, |
927 | 986 | ) |
928 | 987 | ); |
929 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
930 | - return throw_error('You need to be an admin to perform an upgrade!'); |
|
988 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
989 | + return throw_error('You need to be an admin to perform an upgrade!'); |
|
990 | + } |
|
931 | 991 | $smcFunc['db_free_result']($request); |
932 | 992 | } |
933 | 993 | |
934 | 994 | $upcontext['user']['id'] = $id_member; |
935 | 995 | $upcontext['user']['name'] = $name; |
936 | - } |
|
937 | - else |
|
996 | + } else |
|
938 | 997 | { |
939 | 998 | $upcontext['user']['id'] = 1; |
940 | 999 | $upcontext['user']['name'] = 'Administrator'; |
@@ -950,11 +1009,11 @@ discard block |
||
950 | 1009 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096); |
951 | 1010 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
952 | 1011 | |
953 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
954 | - $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'] . '.'; |
|
955 | - elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) |
|
956 | - $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'] . '.'; |
|
957 | - else |
|
1012 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
1013 | + $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'] . '.'; |
|
1014 | + } elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) { |
|
1015 | + $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'] . '.'; |
|
1016 | + } else |
|
958 | 1017 | { |
959 | 1018 | // Set this as the new language. |
960 | 1019 | $upcontext['language'] = $user_language; |
@@ -998,8 +1057,9 @@ discard block |
||
998 | 1057 | unset($member_columns); |
999 | 1058 | |
1000 | 1059 | // If we've not submitted then we're done. |
1001 | - if (empty($_POST['upcont'])) |
|
1002 | - return false; |
|
1060 | + if (empty($_POST['upcont'])) { |
|
1061 | + return false; |
|
1062 | + } |
|
1003 | 1063 | |
1004 | 1064 | // Firstly, if they're enabling SM stat collection just do it. |
1005 | 1065 | if (!empty($_POST['stats']) && substr($boardurl, 0, 16) != 'http://localhost' && empty($modSettings['allow_sm_stats']) && empty($modSettings['enable_sm_stats'])) |
@@ -1019,16 +1079,17 @@ discard block |
||
1019 | 1079 | fwrite($fp, $out); |
1020 | 1080 | |
1021 | 1081 | $return_data = ''; |
1022 | - while (!feof($fp)) |
|
1023 | - $return_data .= fgets($fp, 128); |
|
1082 | + while (!feof($fp)) { |
|
1083 | + $return_data .= fgets($fp, 128); |
|
1084 | + } |
|
1024 | 1085 | |
1025 | 1086 | fclose($fp); |
1026 | 1087 | |
1027 | 1088 | // Get the unique site ID. |
1028 | 1089 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
1029 | 1090 | |
1030 | - if (!empty($ID[1])) |
|
1031 | - $smcFunc['db_insert']('replace', |
|
1091 | + if (!empty($ID[1])) { |
|
1092 | + $smcFunc['db_insert']('replace', |
|
1032 | 1093 | $db_prefix . 'settings', |
1033 | 1094 | array('variable' => 'string', 'value' => 'string'), |
1034 | 1095 | array( |
@@ -1037,9 +1098,9 @@ discard block |
||
1037 | 1098 | ), |
1038 | 1099 | array('variable') |
1039 | 1100 | ); |
1101 | + } |
|
1040 | 1102 | } |
1041 | - } |
|
1042 | - else |
|
1103 | + } else |
|
1043 | 1104 | { |
1044 | 1105 | $smcFunc['db_insert']('replace', |
1045 | 1106 | $db_prefix . 'settings', |
@@ -1050,8 +1111,8 @@ discard block |
||
1050 | 1111 | } |
1051 | 1112 | } |
1052 | 1113 | // Don't remove stat collection unless we unchecked the box for real, not from the loop. |
1053 | - elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) |
|
1054 | - $smcFunc['db_query']('', ' |
|
1114 | + elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) { |
|
1115 | + $smcFunc['db_query']('', ' |
|
1055 | 1116 | DELETE FROM {db_prefix}settings |
1056 | 1117 | WHERE variable = {string:enable_sm_stats}', |
1057 | 1118 | array( |
@@ -1059,6 +1120,7 @@ discard block |
||
1059 | 1120 | 'db_error_skip' => true, |
1060 | 1121 | ) |
1061 | 1122 | ); |
1123 | + } |
|
1062 | 1124 | |
1063 | 1125 | // Deleting old karma stuff? |
1064 | 1126 | if (!empty($_POST['delete_karma'])) |
@@ -1073,20 +1135,22 @@ discard block |
||
1073 | 1135 | ); |
1074 | 1136 | |
1075 | 1137 | // Cleaning up old karma member settings. |
1076 | - if ($upcontext['karma_installed']['good']) |
|
1077 | - $smcFunc['db_query']('', ' |
|
1138 | + if ($upcontext['karma_installed']['good']) { |
|
1139 | + $smcFunc['db_query']('', ' |
|
1078 | 1140 | ALTER TABLE {db_prefix}members |
1079 | 1141 | DROP karma_good', |
1080 | 1142 | array() |
1081 | 1143 | ); |
1144 | + } |
|
1082 | 1145 | |
1083 | 1146 | // Does karma bad was enable? |
1084 | - if ($upcontext['karma_installed']['bad']) |
|
1085 | - $smcFunc['db_query']('', ' |
|
1147 | + if ($upcontext['karma_installed']['bad']) { |
|
1148 | + $smcFunc['db_query']('', ' |
|
1086 | 1149 | ALTER TABLE {db_prefix}members |
1087 | 1150 | DROP karma_bad', |
1088 | 1151 | array() |
1089 | 1152 | ); |
1153 | + } |
|
1090 | 1154 | |
1091 | 1155 | // Cleaning up old karma permissions. |
1092 | 1156 | $smcFunc['db_query']('', ' |
@@ -1104,32 +1168,37 @@ discard block |
||
1104 | 1168 | } |
1105 | 1169 | |
1106 | 1170 | // Emptying the error log? |
1107 | - if (!empty($_POST['empty_error'])) |
|
1108 | - $smcFunc['db_query']('truncate_table', ' |
|
1171 | + if (!empty($_POST['empty_error'])) { |
|
1172 | + $smcFunc['db_query']('truncate_table', ' |
|
1109 | 1173 | TRUNCATE {db_prefix}log_errors', |
1110 | 1174 | array( |
1111 | 1175 | ) |
1112 | 1176 | ); |
1177 | + } |
|
1113 | 1178 | |
1114 | 1179 | $changes = array(); |
1115 | 1180 | |
1116 | 1181 | // Add proxy settings. |
1117 | - if (!isset($GLOBALS['image_proxy_maxsize'])) |
|
1118 | - $changes += array( |
|
1182 | + if (!isset($GLOBALS['image_proxy_maxsize'])) { |
|
1183 | + $changes += array( |
|
1119 | 1184 | 'image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'', |
1120 | 1185 | 'image_proxy_maxsize' => 5190, |
1121 | 1186 | 'image_proxy_enabled' => 0, |
1122 | 1187 | ); |
1188 | + } |
|
1123 | 1189 | |
1124 | 1190 | // If $boardurl reflects https, set force_ssl |
1125 | - if (!function_exists('cache_put_data')) |
|
1126 | - require_once($sourcedir . '/Load.php'); |
|
1127 | - if (stripos($boardurl, 'https://') !== false) |
|
1128 | - updateSettings(array('force_ssl' => '2')); |
|
1191 | + if (!function_exists('cache_put_data')) { |
|
1192 | + require_once($sourcedir . '/Load.php'); |
|
1193 | + } |
|
1194 | + if (stripos($boardurl, 'https://') !== false) { |
|
1195 | + updateSettings(array('force_ssl' => '2')); |
|
1196 | + } |
|
1129 | 1197 | |
1130 | 1198 | // If we're overriding the language follow it through. |
1131 | - if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) |
|
1132 | - $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
1199 | + if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) { |
|
1200 | + $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
1201 | + } |
|
1133 | 1202 | |
1134 | 1203 | if (!empty($_POST['maint'])) |
1135 | 1204 | { |
@@ -1141,26 +1210,29 @@ discard block |
||
1141 | 1210 | { |
1142 | 1211 | $changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\''; |
1143 | 1212 | $changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\''; |
1144 | - } |
|
1145 | - else |
|
1213 | + } else |
|
1146 | 1214 | { |
1147 | 1215 | $changes['mtitle'] = '\'Upgrading the forum...\''; |
1148 | 1216 | $changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum. It will only be a minute ;).\''; |
1149 | 1217 | } |
1150 | 1218 | } |
1151 | 1219 | |
1152 | - if ($command_line) |
|
1153 | - echo ' * Updating Settings.php...'; |
|
1220 | + if ($command_line) { |
|
1221 | + echo ' * Updating Settings.php...'; |
|
1222 | + } |
|
1154 | 1223 | |
1155 | 1224 | // Fix some old paths. |
1156 | - if (substr($boarddir, 0, 1) == '.') |
|
1157 | - $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
1225 | + if (substr($boarddir, 0, 1) == '.') { |
|
1226 | + $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
1227 | + } |
|
1158 | 1228 | |
1159 | - if (substr($sourcedir, 0, 1) == '.') |
|
1160 | - $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
1229 | + if (substr($sourcedir, 0, 1) == '.') { |
|
1230 | + $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
1231 | + } |
|
1161 | 1232 | |
1162 | - if (empty($cachedir) || substr($cachedir, 0, 1) == '.') |
|
1163 | - $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
1233 | + if (empty($cachedir) || substr($cachedir, 0, 1) == '.') { |
|
1234 | + $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
1235 | + } |
|
1164 | 1236 | |
1165 | 1237 | // If they have a "host:port" setup for the host, split that into separate values |
1166 | 1238 | // You should never have a : in the hostname if you're not on MySQL, but better safe than sorry |
@@ -1171,32 +1243,36 @@ discard block |
||
1171 | 1243 | $changes['db_server'] = '\'' . $db_server . '\''; |
1172 | 1244 | |
1173 | 1245 | // Only set this if we're not using the default port |
1174 | - if ($db_port != ini_get('mysqli.default_port')) |
|
1175 | - $changes['db_port'] = (int) $db_port; |
|
1176 | - } |
|
1177 | - elseif (!empty($db_port)) |
|
1246 | + if ($db_port != ini_get('mysqli.default_port')) { |
|
1247 | + $changes['db_port'] = (int) $db_port; |
|
1248 | + } |
|
1249 | + } elseif (!empty($db_port)) |
|
1178 | 1250 | { |
1179 | 1251 | // If db_port is set and is the same as the default, set it to '' |
1180 | 1252 | if ($db_type == 'mysql') |
1181 | 1253 | { |
1182 | - if ($db_port == ini_get('mysqli.default_port')) |
|
1183 | - $changes['db_port'] = '\'\''; |
|
1184 | - elseif ($db_type == 'postgresql' && $db_port == 5432) |
|
1185 | - $changes['db_port'] = '\'\''; |
|
1254 | + if ($db_port == ini_get('mysqli.default_port')) { |
|
1255 | + $changes['db_port'] = '\'\''; |
|
1256 | + } elseif ($db_type == 'postgresql' && $db_port == 5432) { |
|
1257 | + $changes['db_port'] = '\'\''; |
|
1258 | + } |
|
1186 | 1259 | } |
1187 | 1260 | } |
1188 | 1261 | |
1189 | 1262 | // Maybe we haven't had this option yet? |
1190 | - if (empty($packagesdir)) |
|
1191 | - $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
1263 | + if (empty($packagesdir)) { |
|
1264 | + $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
1265 | + } |
|
1192 | 1266 | |
1193 | 1267 | // Add support for $tasksdir var. |
1194 | - if (empty($tasksdir)) |
|
1195 | - $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
1268 | + if (empty($tasksdir)) { |
|
1269 | + $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
1270 | + } |
|
1196 | 1271 | |
1197 | 1272 | // Make sure we fix the language as well. |
1198 | - if (stristr($language, '-utf8')) |
|
1199 | - $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
1273 | + if (stristr($language, '-utf8')) { |
|
1274 | + $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
1275 | + } |
|
1200 | 1276 | |
1201 | 1277 | // @todo Maybe change the cookie name if going to 1.1, too? |
1202 | 1278 | |
@@ -1204,8 +1280,9 @@ discard block |
||
1204 | 1280 | require_once($sourcedir . '/Subs-Admin.php'); |
1205 | 1281 | updateSettingsFile($changes); |
1206 | 1282 | |
1207 | - if ($command_line) |
|
1208 | - echo ' Successful.' . "\n"; |
|
1283 | + if ($command_line) { |
|
1284 | + echo ' Successful.' . "\n"; |
|
1285 | + } |
|
1209 | 1286 | |
1210 | 1287 | // Are we doing debug? |
1211 | 1288 | if (isset($_POST['debug'])) |
@@ -1215,8 +1292,9 @@ discard block |
||
1215 | 1292 | } |
1216 | 1293 | |
1217 | 1294 | // If we're not backing up then jump one. |
1218 | - if (empty($_POST['backup'])) |
|
1219 | - $upcontext['current_step']++; |
|
1295 | + if (empty($_POST['backup'])) { |
|
1296 | + $upcontext['current_step']++; |
|
1297 | + } |
|
1220 | 1298 | |
1221 | 1299 | // If we've got here then let's proceed to the next step! |
1222 | 1300 | return true; |
@@ -1231,8 +1309,9 @@ discard block |
||
1231 | 1309 | $upcontext['page_title'] = 'Backup Database'; |
1232 | 1310 | |
1233 | 1311 | // Done it already - js wise? |
1234 | - if (!empty($_POST['backup_done'])) |
|
1235 | - return true; |
|
1312 | + if (!empty($_POST['backup_done'])) { |
|
1313 | + return true; |
|
1314 | + } |
|
1236 | 1315 | |
1237 | 1316 | // Some useful stuff here. |
1238 | 1317 | db_extend(); |
@@ -1246,9 +1325,10 @@ discard block |
||
1246 | 1325 | $tables = $smcFunc['db_list_tables']($db, $filter); |
1247 | 1326 | |
1248 | 1327 | $table_names = array(); |
1249 | - foreach ($tables as $table) |
|
1250 | - if (substr($table, 0, 7) !== 'backup_') |
|
1328 | + foreach ($tables as $table) { |
|
1329 | + if (substr($table, 0, 7) !== 'backup_') |
|
1251 | 1330 | $table_names[] = $table; |
1331 | + } |
|
1252 | 1332 | |
1253 | 1333 | $upcontext['table_count'] = count($table_names); |
1254 | 1334 | $upcontext['cur_table_num'] = $_GET['substep']; |
@@ -1258,12 +1338,14 @@ discard block |
||
1258 | 1338 | $file_steps = $upcontext['table_count']; |
1259 | 1339 | |
1260 | 1340 | // What ones have we already done? |
1261 | - foreach ($table_names as $id => $table) |
|
1262 | - if ($id < $_GET['substep']) |
|
1341 | + foreach ($table_names as $id => $table) { |
|
1342 | + if ($id < $_GET['substep']) |
|
1263 | 1343 | $upcontext['previous_tables'][] = $table; |
1344 | + } |
|
1264 | 1345 | |
1265 | - if ($command_line) |
|
1266 | - echo 'Backing Up Tables.'; |
|
1346 | + if ($command_line) { |
|
1347 | + echo 'Backing Up Tables.'; |
|
1348 | + } |
|
1267 | 1349 | |
1268 | 1350 | // If we don't support javascript we backup here. |
1269 | 1351 | if (!$support_js || isset($_GET['xml'])) |
@@ -1282,8 +1364,9 @@ discard block |
||
1282 | 1364 | backupTable($table_names[$substep]); |
1283 | 1365 | |
1284 | 1366 | // If this is XML to keep it nice for the user do one table at a time anyway! |
1285 | - if (isset($_GET['xml'])) |
|
1286 | - return upgradeExit(); |
|
1367 | + if (isset($_GET['xml'])) { |
|
1368 | + return upgradeExit(); |
|
1369 | + } |
|
1287 | 1370 | } |
1288 | 1371 | |
1289 | 1372 | if ($command_line) |
@@ -1316,9 +1399,10 @@ discard block |
||
1316 | 1399 | |
1317 | 1400 | $smcFunc['db_backup_table']($table, 'backup_' . $table); |
1318 | 1401 | |
1319 | - if ($command_line) |
|
1320 | - echo ' done.'; |
|
1321 | -} |
|
1402 | + if ($command_line) { |
|
1403 | + echo ' done.'; |
|
1404 | + } |
|
1405 | + } |
|
1322 | 1406 | |
1323 | 1407 | // Step 2: Everything. |
1324 | 1408 | function DatabaseChanges() |
@@ -1327,8 +1411,9 @@ discard block |
||
1327 | 1411 | global $upcontext, $support_js, $db_type; |
1328 | 1412 | |
1329 | 1413 | // Have we just completed this? |
1330 | - if (!empty($_POST['database_done'])) |
|
1331 | - return true; |
|
1414 | + if (!empty($_POST['database_done'])) { |
|
1415 | + return true; |
|
1416 | + } |
|
1332 | 1417 | |
1333 | 1418 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes'; |
1334 | 1419 | $upcontext['page_title'] = 'Database Changes'; |
@@ -1343,15 +1428,16 @@ discard block |
||
1343 | 1428 | ); |
1344 | 1429 | |
1345 | 1430 | // How many files are there in total? |
1346 | - if (isset($_GET['filecount'])) |
|
1347 | - $upcontext['file_count'] = (int) $_GET['filecount']; |
|
1348 | - else |
|
1431 | + if (isset($_GET['filecount'])) { |
|
1432 | + $upcontext['file_count'] = (int) $_GET['filecount']; |
|
1433 | + } else |
|
1349 | 1434 | { |
1350 | 1435 | $upcontext['file_count'] = 0; |
1351 | 1436 | foreach ($files as $file) |
1352 | 1437 | { |
1353 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) |
|
1354 | - $upcontext['file_count']++; |
|
1438 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) { |
|
1439 | + $upcontext['file_count']++; |
|
1440 | + } |
|
1355 | 1441 | } |
1356 | 1442 | } |
1357 | 1443 | |
@@ -1361,9 +1447,9 @@ discard block |
||
1361 | 1447 | $upcontext['cur_file_num'] = 0; |
1362 | 1448 | foreach ($files as $file) |
1363 | 1449 | { |
1364 | - if ($did_not_do) |
|
1365 | - $did_not_do--; |
|
1366 | - else |
|
1450 | + if ($did_not_do) { |
|
1451 | + $did_not_do--; |
|
1452 | + } else |
|
1367 | 1453 | { |
1368 | 1454 | $upcontext['cur_file_num']++; |
1369 | 1455 | $upcontext['cur_file_name'] = $file[0]; |
@@ -1390,12 +1476,13 @@ discard block |
||
1390 | 1476 | // Flag to move on to the next. |
1391 | 1477 | $upcontext['completed_step'] = true; |
1392 | 1478 | // Did we complete the whole file? |
1393 | - if ($nextFile) |
|
1394 | - $upcontext['current_debug_item_num'] = -1; |
|
1479 | + if ($nextFile) { |
|
1480 | + $upcontext['current_debug_item_num'] = -1; |
|
1481 | + } |
|
1395 | 1482 | return upgradeExit(); |
1483 | + } elseif ($support_js) { |
|
1484 | + break; |
|
1396 | 1485 | } |
1397 | - elseif ($support_js) |
|
1398 | - break; |
|
1399 | 1486 | } |
1400 | 1487 | // Set the progress bar to be right as if we had - even if we hadn't... |
1401 | 1488 | $upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100; |
@@ -1420,8 +1507,9 @@ discard block |
||
1420 | 1507 | global $command_line, $language, $upcontext, $sourcedir, $forum_version, $user_info, $maintenance, $smcFunc, $db_type; |
1421 | 1508 | |
1422 | 1509 | // Now it's nice to have some of the basic SMF source files. |
1423 | - if (!isset($_GET['ssi']) && !$command_line) |
|
1424 | - redirectLocation('&ssi=1'); |
|
1510 | + if (!isset($_GET['ssi']) && !$command_line) { |
|
1511 | + redirectLocation('&ssi=1'); |
|
1512 | + } |
|
1425 | 1513 | |
1426 | 1514 | $upcontext['sub_template'] = 'upgrade_complete'; |
1427 | 1515 | $upcontext['page_title'] = 'Upgrade Complete'; |
@@ -1437,14 +1525,16 @@ discard block |
||
1437 | 1525 | // Are we in maintenance mode? |
1438 | 1526 | if (isset($upcontext['user']['main'])) |
1439 | 1527 | { |
1440 | - if ($command_line) |
|
1441 | - echo ' * '; |
|
1528 | + if ($command_line) { |
|
1529 | + echo ' * '; |
|
1530 | + } |
|
1442 | 1531 | $upcontext['removed_maintenance'] = true; |
1443 | 1532 | $changes['maintenance'] = $upcontext['user']['main']; |
1444 | 1533 | } |
1445 | 1534 | // Otherwise if somehow we are in 2 let's go to 1. |
1446 | - elseif (!empty($maintenance) && $maintenance == 2) |
|
1447 | - $changes['maintenance'] = 1; |
|
1535 | + elseif (!empty($maintenance) && $maintenance == 2) { |
|
1536 | + $changes['maintenance'] = 1; |
|
1537 | + } |
|
1448 | 1538 | |
1449 | 1539 | // Wipe this out... |
1450 | 1540 | $upcontext['user'] = array(); |
@@ -1459,9 +1549,9 @@ discard block |
||
1459 | 1549 | $upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__); |
1460 | 1550 | |
1461 | 1551 | // Now is the perfect time to fetch the SM files. |
1462 | - if ($command_line) |
|
1463 | - cli_scheduled_fetchSMfiles(); |
|
1464 | - else |
|
1552 | + if ($command_line) { |
|
1553 | + cli_scheduled_fetchSMfiles(); |
|
1554 | + } else |
|
1465 | 1555 | { |
1466 | 1556 | require_once($sourcedir . '/ScheduledTasks.php'); |
1467 | 1557 | $forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us. |
@@ -1469,8 +1559,9 @@ discard block |
||
1469 | 1559 | } |
1470 | 1560 | |
1471 | 1561 | // Log what we've done. |
1472 | - if (empty($user_info['id'])) |
|
1473 | - $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
1562 | + if (empty($user_info['id'])) { |
|
1563 | + $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
1564 | + } |
|
1474 | 1565 | |
1475 | 1566 | // Log the action manually, so CLI still works. |
1476 | 1567 | $smcFunc['db_insert']('', |
@@ -1489,8 +1580,9 @@ discard block |
||
1489 | 1580 | |
1490 | 1581 | // Save the current database version. |
1491 | 1582 | $server_version = $smcFunc['db_server_info'](); |
1492 | - if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
1493 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1583 | + if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
1584 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1585 | + } |
|
1494 | 1586 | |
1495 | 1587 | if ($command_line) |
1496 | 1588 | { |
@@ -1502,8 +1594,9 @@ discard block |
||
1502 | 1594 | |
1503 | 1595 | // Make sure it says we're done. |
1504 | 1596 | $upcontext['overall_percent'] = 100; |
1505 | - if (isset($upcontext['step_progress'])) |
|
1506 | - unset($upcontext['step_progress']); |
|
1597 | + if (isset($upcontext['step_progress'])) { |
|
1598 | + unset($upcontext['step_progress']); |
|
1599 | + } |
|
1507 | 1600 | |
1508 | 1601 | $_GET['substep'] = 0; |
1509 | 1602 | return false; |
@@ -1514,8 +1607,9 @@ discard block |
||
1514 | 1607 | { |
1515 | 1608 | global $sourcedir, $language, $forum_version, $modSettings, $smcFunc; |
1516 | 1609 | |
1517 | - if (empty($modSettings['time_format'])) |
|
1518 | - $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
1610 | + if (empty($modSettings['time_format'])) { |
|
1611 | + $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
1612 | + } |
|
1519 | 1613 | |
1520 | 1614 | // What files do we want to get |
1521 | 1615 | $request = $smcFunc['db_query']('', ' |
@@ -1549,8 +1643,9 @@ discard block |
||
1549 | 1643 | $file_data = fetch_web_data($url); |
1550 | 1644 | |
1551 | 1645 | // If we got an error - give up - the site might be down. |
1552 | - if ($file_data === false) |
|
1553 | - return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
1646 | + if ($file_data === false) { |
|
1647 | + return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
1648 | + } |
|
1554 | 1649 | |
1555 | 1650 | // Save the file to the database. |
1556 | 1651 | $smcFunc['db_query']('substring', ' |
@@ -1592,8 +1687,9 @@ discard block |
||
1592 | 1687 | $themeData = array(); |
1593 | 1688 | foreach ($values as $variable => $value) |
1594 | 1689 | { |
1595 | - if (!isset($value) || $value === null) |
|
1596 | - $value = 0; |
|
1690 | + if (!isset($value) || $value === null) { |
|
1691 | + $value = 0; |
|
1692 | + } |
|
1597 | 1693 | |
1598 | 1694 | $themeData[] = array(0, 1, $variable, $value); |
1599 | 1695 | } |
@@ -1622,8 +1718,9 @@ discard block |
||
1622 | 1718 | |
1623 | 1719 | foreach ($values as $variable => $value) |
1624 | 1720 | { |
1625 | - if (empty($modSettings[$value[0]])) |
|
1626 | - continue; |
|
1721 | + if (empty($modSettings[$value[0]])) { |
|
1722 | + continue; |
|
1723 | + } |
|
1627 | 1724 | |
1628 | 1725 | $smcFunc['db_query']('', ' |
1629 | 1726 | INSERT IGNORE INTO {db_prefix}themes |
@@ -1709,19 +1806,21 @@ discard block |
||
1709 | 1806 | set_error_handler( |
1710 | 1807 | function ($errno, $errstr, $errfile, $errline) use ($support_js) |
1711 | 1808 | { |
1712 | - if ($support_js) |
|
1713 | - return true; |
|
1714 | - else |
|
1715 | - echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
1809 | + if ($support_js) { |
|
1810 | + return true; |
|
1811 | + } else { |
|
1812 | + echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
1813 | + } |
|
1716 | 1814 | } |
1717 | 1815 | ); |
1718 | 1816 | |
1719 | 1817 | // If we're on MySQL, set {db_collation}; this approach is used throughout upgrade_2-0_mysql.php to set new tables to utf8 |
1720 | 1818 | // Note it is expected to be in the format: ENGINE=MyISAM{$db_collation}; |
1721 | - if ($db_type == 'mysql') |
|
1722 | - $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
1723 | - else |
|
1724 | - $db_collation = ''; |
|
1819 | + if ($db_type == 'mysql') { |
|
1820 | + $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
1821 | + } else { |
|
1822 | + $db_collation = ''; |
|
1823 | + } |
|
1725 | 1824 | |
1726 | 1825 | $endl = $command_line ? "\n" : '<br>' . "\n"; |
1727 | 1826 | |
@@ -1733,8 +1832,9 @@ discard block |
||
1733 | 1832 | $last_step = ''; |
1734 | 1833 | |
1735 | 1834 | // Make sure all newly created tables will have the proper characters set; this approach is used throughout upgrade_2-1_mysql.php |
1736 | - if (isset($db_character_set) && $db_character_set === 'utf8') |
|
1737 | - $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
1835 | + if (isset($db_character_set) && $db_character_set === 'utf8') { |
|
1836 | + $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
1837 | + } |
|
1738 | 1838 | |
1739 | 1839 | // Count the total number of steps within this file - for progress. |
1740 | 1840 | $file_steps = substr_count(implode('', $lines), '---#'); |
@@ -1754,15 +1854,18 @@ discard block |
||
1754 | 1854 | $do_current = $substep >= $_GET['substep']; |
1755 | 1855 | |
1756 | 1856 | // Get rid of any comments in the beginning of the line... |
1757 | - if (substr(trim($line), 0, 2) === '/*') |
|
1758 | - $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
1857 | + if (substr(trim($line), 0, 2) === '/*') { |
|
1858 | + $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
1859 | + } |
|
1759 | 1860 | |
1760 | 1861 | // Always flush. Flush, flush, flush. Flush, flush, flush, flush! FLUSH! |
1761 | - if ($is_debug && !$support_js && $command_line) |
|
1762 | - flush(); |
|
1862 | + if ($is_debug && !$support_js && $command_line) { |
|
1863 | + flush(); |
|
1864 | + } |
|
1763 | 1865 | |
1764 | - if (trim($line) === '') |
|
1765 | - continue; |
|
1866 | + if (trim($line) === '') { |
|
1867 | + continue; |
|
1868 | + } |
|
1766 | 1869 | |
1767 | 1870 | if (trim(substr($line, 0, 3)) === '---') |
1768 | 1871 | { |
@@ -1772,8 +1875,9 @@ discard block |
||
1772 | 1875 | if (trim($current_data) != '' && $type !== '}') |
1773 | 1876 | { |
1774 | 1877 | $upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl; |
1775 | - if ($command_line) |
|
1776 | - echo $upcontext['error_message']; |
|
1878 | + if ($command_line) { |
|
1879 | + echo $upcontext['error_message']; |
|
1880 | + } |
|
1777 | 1881 | } |
1778 | 1882 | |
1779 | 1883 | if ($type == ' ') |
@@ -1791,17 +1895,18 @@ discard block |
||
1791 | 1895 | if ($do_current) |
1792 | 1896 | { |
1793 | 1897 | $upcontext['actioned_items'][] = $last_step; |
1794 | - if ($command_line) |
|
1795 | - echo ' * '; |
|
1898 | + if ($command_line) { |
|
1899 | + echo ' * '; |
|
1900 | + } |
|
1796 | 1901 | } |
1797 | - } |
|
1798 | - elseif ($type == '#') |
|
1902 | + } elseif ($type == '#') |
|
1799 | 1903 | { |
1800 | 1904 | $upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps; |
1801 | 1905 | |
1802 | 1906 | $upcontext['current_debug_item_num']++; |
1803 | - if (trim($line) != '---#') |
|
1804 | - $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
1907 | + if (trim($line) != '---#') { |
|
1908 | + $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
1909 | + } |
|
1805 | 1910 | |
1806 | 1911 | // Have we already done something? |
1807 | 1912 | if (isset($_GET['xml']) && $done_something) |
@@ -1812,34 +1917,36 @@ discard block |
||
1812 | 1917 | |
1813 | 1918 | if ($do_current) |
1814 | 1919 | { |
1815 | - if (trim($line) == '---#' && $command_line) |
|
1816 | - echo ' done.', $endl; |
|
1817 | - elseif ($command_line) |
|
1818 | - echo ' +++ ', rtrim(substr($line, 4)); |
|
1819 | - elseif (trim($line) != '---#') |
|
1920 | + if (trim($line) == '---#' && $command_line) { |
|
1921 | + echo ' done.', $endl; |
|
1922 | + } elseif ($command_line) { |
|
1923 | + echo ' +++ ', rtrim(substr($line, 4)); |
|
1924 | + } elseif (trim($line) != '---#') |
|
1820 | 1925 | { |
1821 | - if ($is_debug) |
|
1822 | - $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
1926 | + if ($is_debug) { |
|
1927 | + $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
1928 | + } |
|
1823 | 1929 | } |
1824 | 1930 | } |
1825 | 1931 | |
1826 | 1932 | if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep']) |
1827 | 1933 | { |
1828 | - if ($command_line) |
|
1829 | - echo ' * '; |
|
1830 | - else |
|
1831 | - $upcontext['actioned_items'][] = $last_step; |
|
1934 | + if ($command_line) { |
|
1935 | + echo ' * '; |
|
1936 | + } else { |
|
1937 | + $upcontext['actioned_items'][] = $last_step; |
|
1938 | + } |
|
1832 | 1939 | } |
1833 | 1940 | |
1834 | 1941 | // Small step - only if we're actually doing stuff. |
1835 | - if ($do_current) |
|
1836 | - nextSubstep(++$substep); |
|
1837 | - else |
|
1838 | - $substep++; |
|
1839 | - } |
|
1840 | - elseif ($type == '{') |
|
1841 | - $current_type = 'code'; |
|
1842 | - elseif ($type == '}') |
|
1942 | + if ($do_current) { |
|
1943 | + nextSubstep(++$substep); |
|
1944 | + } else { |
|
1945 | + $substep++; |
|
1946 | + } |
|
1947 | + } elseif ($type == '{') { |
|
1948 | + $current_type = 'code'; |
|
1949 | + } elseif ($type == '}') |
|
1843 | 1950 | { |
1844 | 1951 | $current_type = 'sql'; |
1845 | 1952 | |
@@ -1852,8 +1959,9 @@ discard block |
||
1852 | 1959 | if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false) |
1853 | 1960 | { |
1854 | 1961 | $upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl; |
1855 | - if ($command_line) |
|
1856 | - echo $upcontext['error_message']; |
|
1962 | + if ($command_line) { |
|
1963 | + echo $upcontext['error_message']; |
|
1964 | + } |
|
1857 | 1965 | } |
1858 | 1966 | |
1859 | 1967 | // Done with code! |
@@ -1933,8 +2041,9 @@ discard block |
||
1933 | 2041 | $db_unbuffered = false; |
1934 | 2042 | |
1935 | 2043 | // Failure?! |
1936 | - if ($result !== false) |
|
1937 | - return $result; |
|
2044 | + if ($result !== false) { |
|
2045 | + return $result; |
|
2046 | + } |
|
1938 | 2047 | |
1939 | 2048 | $db_error_message = $smcFunc['db_error']($db_connection); |
1940 | 2049 | // If MySQL we do something more clever. |
@@ -1962,54 +2071,61 @@ discard block |
||
1962 | 2071 | { |
1963 | 2072 | mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`'); |
1964 | 2073 | $result = mysqli_query($db_connection, $string); |
1965 | - if ($result !== false) |
|
1966 | - return $result; |
|
2074 | + if ($result !== false) { |
|
2075 | + return $result; |
|
2076 | + } |
|
1967 | 2077 | } |
1968 | - } |
|
1969 | - elseif ($mysqli_errno == 2013) |
|
2078 | + } elseif ($mysqli_errno == 2013) |
|
1970 | 2079 | { |
1971 | 2080 | $db_connection = mysqli_connect($db_server, $db_user, $db_passwd); |
1972 | 2081 | mysqli_select_db($db_connection, $db_name); |
1973 | 2082 | if ($db_connection) |
1974 | 2083 | { |
1975 | 2084 | $result = mysqli_query($db_connection, $string); |
1976 | - if ($result !== false) |
|
1977 | - return $result; |
|
2085 | + if ($result !== false) { |
|
2086 | + return $result; |
|
2087 | + } |
|
1978 | 2088 | } |
1979 | 2089 | } |
1980 | 2090 | // Duplicate column name... should be okay ;). |
1981 | - elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) |
|
1982 | - return false; |
|
2091 | + elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) { |
|
2092 | + return false; |
|
2093 | + } |
|
1983 | 2094 | // Duplicate insert... make sure it's the proper type of query ;). |
1984 | - elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) |
|
1985 | - return false; |
|
2095 | + elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) { |
|
2096 | + return false; |
|
2097 | + } |
|
1986 | 2098 | // Creating an index on a non-existent column. |
1987 | - elseif ($mysqli_errno == 1072) |
|
1988 | - return false; |
|
1989 | - elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') |
|
1990 | - return false; |
|
2099 | + elseif ($mysqli_errno == 1072) { |
|
2100 | + return false; |
|
2101 | + } elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') { |
|
2102 | + return false; |
|
2103 | + } |
|
1991 | 2104 | } |
1992 | 2105 | // If a table already exists don't go potty. |
1993 | 2106 | else |
1994 | 2107 | { |
1995 | 2108 | if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U'))) |
1996 | 2109 | { |
1997 | - if (strpos($db_error_message, 'exist') !== false) |
|
1998 | - return true; |
|
1999 | - } |
|
2000 | - elseif (strpos(trim($string), 'INSERT ') !== false) |
|
2110 | + if (strpos($db_error_message, 'exist') !== false) { |
|
2111 | + return true; |
|
2112 | + } |
|
2113 | + } elseif (strpos(trim($string), 'INSERT ') !== false) |
|
2001 | 2114 | { |
2002 | - if (strpos($db_error_message, 'duplicate') !== false) |
|
2003 | - return true; |
|
2115 | + if (strpos($db_error_message, 'duplicate') !== false) { |
|
2116 | + return true; |
|
2117 | + } |
|
2004 | 2118 | } |
2005 | 2119 | } |
2006 | 2120 | |
2007 | 2121 | // Get the query string so we pass everything. |
2008 | 2122 | $query_string = ''; |
2009 | - foreach ($_GET as $k => $v) |
|
2010 | - $query_string .= ';' . $k . '=' . $v; |
|
2011 | - if (strlen($query_string) != 0) |
|
2012 | - $query_string = '?' . substr($query_string, 1); |
|
2123 | + foreach ($_GET as $k => $v) { |
|
2124 | + $query_string .= ';' . $k . '=' . $v; |
|
2125 | + } |
|
2126 | + if (strlen($query_string) != 0) { |
|
2127 | + $query_string = '?' . substr($query_string, 1); |
|
2128 | + } |
|
2013 | 2129 | |
2014 | 2130 | if ($command_line) |
2015 | 2131 | { |
@@ -2064,16 +2180,18 @@ discard block |
||
2064 | 2180 | { |
2065 | 2181 | $found |= 1; |
2066 | 2182 | // Do some checks on the data if we have it set. |
2067 | - if (isset($change['col_type'])) |
|
2068 | - $found &= $change['col_type'] === $column['type']; |
|
2069 | - if (isset($change['null_allowed'])) |
|
2070 | - $found &= $column['null'] == $change['null_allowed']; |
|
2071 | - if (isset($change['default'])) |
|
2072 | - $found &= $change['default'] === $column['default']; |
|
2183 | + if (isset($change['col_type'])) { |
|
2184 | + $found &= $change['col_type'] === $column['type']; |
|
2185 | + } |
|
2186 | + if (isset($change['null_allowed'])) { |
|
2187 | + $found &= $column['null'] == $change['null_allowed']; |
|
2188 | + } |
|
2189 | + if (isset($change['default'])) { |
|
2190 | + $found &= $change['default'] === $column['default']; |
|
2191 | + } |
|
2073 | 2192 | } |
2074 | 2193 | } |
2075 | - } |
|
2076 | - elseif ($change['type'] === 'index') |
|
2194 | + } elseif ($change['type'] === 'index') |
|
2077 | 2195 | { |
2078 | 2196 | $request = upgrade_query(' |
2079 | 2197 | SHOW INDEX |
@@ -2082,9 +2200,10 @@ discard block |
||
2082 | 2200 | { |
2083 | 2201 | $cur_index = array(); |
2084 | 2202 | |
2085 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2086 | - if ($row['Key_name'] === $change['name']) |
|
2203 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2204 | + if ($row['Key_name'] === $change['name']) |
|
2087 | 2205 | $cur_index[(int) $row['Seq_in_index']] = $row['Column_name']; |
2206 | + } |
|
2088 | 2207 | |
2089 | 2208 | ksort($cur_index, SORT_NUMERIC); |
2090 | 2209 | $found = array_values($cur_index) === $change['target_columns']; |
@@ -2094,14 +2213,17 @@ discard block |
||
2094 | 2213 | } |
2095 | 2214 | |
2096 | 2215 | // If we're trying to add and it's added, we're done. |
2097 | - if ($found && in_array($change['method'], array('add', 'change'))) |
|
2098 | - return true; |
|
2216 | + if ($found && in_array($change['method'], array('add', 'change'))) { |
|
2217 | + return true; |
|
2218 | + } |
|
2099 | 2219 | // Otherwise if we're removing and it wasn't found we're also done. |
2100 | - elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) |
|
2101 | - return true; |
|
2220 | + elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) { |
|
2221 | + return true; |
|
2222 | + } |
|
2102 | 2223 | // Otherwise is it just a test? |
2103 | - elseif ($is_test) |
|
2104 | - return false; |
|
2224 | + elseif ($is_test) { |
|
2225 | + return false; |
|
2226 | + } |
|
2105 | 2227 | |
2106 | 2228 | // Not found it yet? Bummer! How about we see if we're currently doing it? |
2107 | 2229 | $running = false; |
@@ -2112,8 +2234,9 @@ discard block |
||
2112 | 2234 | SHOW FULL PROCESSLIST'); |
2113 | 2235 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2114 | 2236 | { |
2115 | - if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) |
|
2116 | - $found = true; |
|
2237 | + if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) { |
|
2238 | + $found = true; |
|
2239 | + } |
|
2117 | 2240 | } |
2118 | 2241 | |
2119 | 2242 | // Can't find it? Then we need to run it fools! |
@@ -2125,8 +2248,9 @@ discard block |
||
2125 | 2248 | ALTER TABLE ' . $db_prefix . $change['table'] . ' |
2126 | 2249 | ' . $change['text'], true) !== false; |
2127 | 2250 | |
2128 | - if (!$success) |
|
2129 | - return false; |
|
2251 | + if (!$success) { |
|
2252 | + return false; |
|
2253 | + } |
|
2130 | 2254 | |
2131 | 2255 | // Return |
2132 | 2256 | $running = true; |
@@ -2168,8 +2292,9 @@ discard block |
||
2168 | 2292 | 'db_error_skip' => true, |
2169 | 2293 | ) |
2170 | 2294 | ); |
2171 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
2172 | - die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
2295 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
2296 | + die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
2297 | + } |
|
2173 | 2298 | $table_row = $smcFunc['db_fetch_assoc']($request); |
2174 | 2299 | $smcFunc['db_free_result']($request); |
2175 | 2300 | |
@@ -2191,18 +2316,19 @@ discard block |
||
2191 | 2316 | ) |
2192 | 2317 | ); |
2193 | 2318 | // No results? Just forget it all together. |
2194 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
2195 | - unset($table_row['Collation']); |
|
2196 | - else |
|
2197 | - $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
2319 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
2320 | + unset($table_row['Collation']); |
|
2321 | + } else { |
|
2322 | + $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
2323 | + } |
|
2198 | 2324 | $smcFunc['db_free_result']($request); |
2199 | 2325 | } |
2200 | 2326 | |
2201 | 2327 | if ($column_fix) |
2202 | 2328 | { |
2203 | 2329 | // Make sure there are no NULL's left. |
2204 | - if ($null_fix) |
|
2205 | - $smcFunc['db_query']('', ' |
|
2330 | + if ($null_fix) { |
|
2331 | + $smcFunc['db_query']('', ' |
|
2206 | 2332 | UPDATE {db_prefix}' . $change['table'] . ' |
2207 | 2333 | SET ' . $change['column'] . ' = {string:default} |
2208 | 2334 | WHERE ' . $change['column'] . ' IS NULL', |
@@ -2211,6 +2337,7 @@ discard block |
||
2211 | 2337 | 'db_error_skip' => true, |
2212 | 2338 | ) |
2213 | 2339 | ); |
2340 | + } |
|
2214 | 2341 | |
2215 | 2342 | // Do the actual alteration. |
2216 | 2343 | $smcFunc['db_query']('', ' |
@@ -2239,8 +2366,9 @@ discard block |
||
2239 | 2366 | } |
2240 | 2367 | |
2241 | 2368 | // Not a column we need to check on? |
2242 | - if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) |
|
2243 | - return; |
|
2369 | + if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) { |
|
2370 | + return; |
|
2371 | + } |
|
2244 | 2372 | |
2245 | 2373 | // Break it up you (six|seven). |
2246 | 2374 | $temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text'])); |
@@ -2259,13 +2387,13 @@ discard block |
||
2259 | 2387 | 'new_name' => $temp[2], |
2260 | 2388 | )); |
2261 | 2389 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
2262 | - if ($smcFunc['db_num_rows'] != 1) |
|
2263 | - return; |
|
2390 | + if ($smcFunc['db_num_rows'] != 1) { |
|
2391 | + return; |
|
2392 | + } |
|
2264 | 2393 | |
2265 | 2394 | list (, $current_type) = $smcFunc['db_fetch_assoc']($request); |
2266 | 2395 | $smcFunc['db_free_result']($request); |
2267 | - } |
|
2268 | - else |
|
2396 | + } else |
|
2269 | 2397 | { |
2270 | 2398 | // Do this the old fashion, sure method way. |
2271 | 2399 | $request = $smcFunc['db_query']('', ' |
@@ -2276,21 +2404,24 @@ discard block |
||
2276 | 2404 | )); |
2277 | 2405 | // Mayday! |
2278 | 2406 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
2279 | - if ($smcFunc['db_num_rows'] == 0) |
|
2280 | - return; |
|
2407 | + if ($smcFunc['db_num_rows'] == 0) { |
|
2408 | + return; |
|
2409 | + } |
|
2281 | 2410 | |
2282 | 2411 | // Oh where, oh where has my little field gone. Oh where can it be... |
2283 | - while ($row = $smcFunc['db_query']($request)) |
|
2284 | - if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
2412 | + while ($row = $smcFunc['db_query']($request)) { |
|
2413 | + if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
2285 | 2414 | { |
2286 | 2415 | $current_type = $row['Type']; |
2416 | + } |
|
2287 | 2417 | break; |
2288 | 2418 | } |
2289 | 2419 | } |
2290 | 2420 | |
2291 | 2421 | // If this doesn't match, the column may of been altered for a reason. |
2292 | - if (trim($current_type) != trim($temp[3])) |
|
2293 | - $temp[3] = $current_type; |
|
2422 | + if (trim($current_type) != trim($temp[3])) { |
|
2423 | + $temp[3] = $current_type; |
|
2424 | + } |
|
2294 | 2425 | |
2295 | 2426 | // Piece this back together. |
2296 | 2427 | $change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp)); |
@@ -2302,8 +2433,9 @@ discard block |
||
2302 | 2433 | global $start_time, $timeLimitThreshold, $command_line, $custom_warning; |
2303 | 2434 | global $step_progress, $is_debug, $upcontext; |
2304 | 2435 | |
2305 | - if ($_GET['substep'] < $substep) |
|
2306 | - $_GET['substep'] = $substep; |
|
2436 | + if ($_GET['substep'] < $substep) { |
|
2437 | + $_GET['substep'] = $substep; |
|
2438 | + } |
|
2307 | 2439 | |
2308 | 2440 | if ($command_line) |
2309 | 2441 | { |
@@ -2316,29 +2448,33 @@ discard block |
||
2316 | 2448 | } |
2317 | 2449 | |
2318 | 2450 | @set_time_limit(300); |
2319 | - if (function_exists('apache_reset_timeout')) |
|
2320 | - @apache_reset_timeout(); |
|
2451 | + if (function_exists('apache_reset_timeout')) { |
|
2452 | + @apache_reset_timeout(); |
|
2453 | + } |
|
2321 | 2454 | |
2322 | - if (time() - $start_time <= $timeLimitThreshold) |
|
2323 | - return; |
|
2455 | + if (time() - $start_time <= $timeLimitThreshold) { |
|
2456 | + return; |
|
2457 | + } |
|
2324 | 2458 | |
2325 | 2459 | // Do we have some custom step progress stuff? |
2326 | 2460 | if (!empty($step_progress)) |
2327 | 2461 | { |
2328 | 2462 | $upcontext['substep_progress'] = 0; |
2329 | 2463 | $upcontext['substep_progress_name'] = $step_progress['name']; |
2330 | - if ($step_progress['current'] > $step_progress['total']) |
|
2331 | - $upcontext['substep_progress'] = 99.9; |
|
2332 | - else |
|
2333 | - $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
2464 | + if ($step_progress['current'] > $step_progress['total']) { |
|
2465 | + $upcontext['substep_progress'] = 99.9; |
|
2466 | + } else { |
|
2467 | + $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
2468 | + } |
|
2334 | 2469 | |
2335 | 2470 | // Make it nicely rounded. |
2336 | 2471 | $upcontext['substep_progress'] = round($upcontext['substep_progress'], 1); |
2337 | 2472 | } |
2338 | 2473 | |
2339 | 2474 | // If this is XML we just exit right away! |
2340 | - if (isset($_GET['xml'])) |
|
2341 | - return upgradeExit(); |
|
2475 | + if (isset($_GET['xml'])) { |
|
2476 | + return upgradeExit(); |
|
2477 | + } |
|
2342 | 2478 | |
2343 | 2479 | // We're going to pause after this! |
2344 | 2480 | $upcontext['pause'] = true; |
@@ -2346,13 +2482,15 @@ discard block |
||
2346 | 2482 | $upcontext['query_string'] = ''; |
2347 | 2483 | foreach ($_GET as $k => $v) |
2348 | 2484 | { |
2349 | - if ($k != 'data' && $k != 'substep' && $k != 'step') |
|
2350 | - $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
2485 | + if ($k != 'data' && $k != 'substep' && $k != 'step') { |
|
2486 | + $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
2487 | + } |
|
2351 | 2488 | } |
2352 | 2489 | |
2353 | 2490 | // Custom warning? |
2354 | - if (!empty($custom_warning)) |
|
2355 | - $upcontext['custom_warning'] = $custom_warning; |
|
2491 | + if (!empty($custom_warning)) { |
|
2492 | + $upcontext['custom_warning'] = $custom_warning; |
|
2493 | + } |
|
2356 | 2494 | |
2357 | 2495 | upgradeExit(); |
2358 | 2496 | } |
@@ -2367,25 +2505,26 @@ discard block |
||
2367 | 2505 | ob_implicit_flush(true); |
2368 | 2506 | @set_time_limit(600); |
2369 | 2507 | |
2370 | - if (!isset($_SERVER['argv'])) |
|
2371 | - $_SERVER['argv'] = array(); |
|
2508 | + if (!isset($_SERVER['argv'])) { |
|
2509 | + $_SERVER['argv'] = array(); |
|
2510 | + } |
|
2372 | 2511 | $_GET['maint'] = 1; |
2373 | 2512 | |
2374 | 2513 | foreach ($_SERVER['argv'] as $i => $arg) |
2375 | 2514 | { |
2376 | - if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) |
|
2377 | - $_GET['lang'] = $match[1]; |
|
2378 | - elseif (preg_match('~^--path=(.+)$~', $arg) != 0) |
|
2379 | - continue; |
|
2380 | - elseif ($arg == '--no-maintenance') |
|
2381 | - $_GET['maint'] = 0; |
|
2382 | - elseif ($arg == '--debug') |
|
2383 | - $is_debug = true; |
|
2384 | - elseif ($arg == '--backup') |
|
2385 | - $_POST['backup'] = 1; |
|
2386 | - elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) |
|
2387 | - $_GET['conv'] = 1; |
|
2388 | - elseif ($i != 0) |
|
2515 | + if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) { |
|
2516 | + $_GET['lang'] = $match[1]; |
|
2517 | + } elseif (preg_match('~^--path=(.+)$~', $arg) != 0) { |
|
2518 | + continue; |
|
2519 | + } elseif ($arg == '--no-maintenance') { |
|
2520 | + $_GET['maint'] = 0; |
|
2521 | + } elseif ($arg == '--debug') { |
|
2522 | + $is_debug = true; |
|
2523 | + } elseif ($arg == '--backup') { |
|
2524 | + $_POST['backup'] = 1; |
|
2525 | + } elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) { |
|
2526 | + $_GET['conv'] = 1; |
|
2527 | + } elseif ($i != 0) |
|
2389 | 2528 | { |
2390 | 2529 | echo 'SMF Command-line Upgrader |
2391 | 2530 | Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]... |
@@ -2399,10 +2538,12 @@ discard block |
||
2399 | 2538 | } |
2400 | 2539 | } |
2401 | 2540 | |
2402 | - if (!php_version_check()) |
|
2403 | - print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
2404 | - if (!db_version_check()) |
|
2405 | - print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
2541 | + if (!php_version_check()) { |
|
2542 | + print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
2543 | + } |
|
2544 | + if (!db_version_check()) { |
|
2545 | + print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
2546 | + } |
|
2406 | 2547 | |
2407 | 2548 | // Do some checks to make sure they have proper privileges |
2408 | 2549 | db_extend('packages'); |
@@ -2417,39 +2558,45 @@ discard block |
||
2417 | 2558 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
2418 | 2559 | |
2419 | 2560 | // Sorry... we need CREATE, ALTER and DROP |
2420 | - if (!$create || !$alter || !$drop) |
|
2421 | - 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); |
|
2561 | + if (!$create || !$alter || !$drop) { |
|
2562 | + 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); |
|
2563 | + } |
|
2422 | 2564 | |
2423 | 2565 | $check = @file_exists($modSettings['theme_dir'] . '/index.template.php') |
2424 | 2566 | && @file_exists($sourcedir . '/QueryString.php') |
2425 | 2567 | && @file_exists($sourcedir . '/ManageBoards.php'); |
2426 | - if (!$check && !isset($modSettings['smfVersion'])) |
|
2427 | - print_error('Error: Some files are missing or out-of-date.', true); |
|
2568 | + if (!$check && !isset($modSettings['smfVersion'])) { |
|
2569 | + print_error('Error: Some files are missing or out-of-date.', true); |
|
2570 | + } |
|
2428 | 2571 | |
2429 | 2572 | // Do a quick version spot check. |
2430 | 2573 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
2431 | 2574 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
2432 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
2433 | - print_error('Error: Some files have not yet been updated properly.'); |
|
2575 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
2576 | + print_error('Error: Some files have not yet been updated properly.'); |
|
2577 | + } |
|
2434 | 2578 | |
2435 | 2579 | // Make sure Settings.php is writable. |
2436 | 2580 | quickFileWritable($boarddir . '/Settings.php'); |
2437 | - if (!is_writable($boarddir . '/Settings.php')) |
|
2438 | - print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
2581 | + if (!is_writable($boarddir . '/Settings.php')) { |
|
2582 | + print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
2583 | + } |
|
2439 | 2584 | |
2440 | 2585 | // Make sure Settings_bak.php is writable. |
2441 | 2586 | quickFileWritable($boarddir . '/Settings_bak.php'); |
2442 | - if (!is_writable($boarddir . '/Settings_bak.php')) |
|
2443 | - print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
2587 | + if (!is_writable($boarddir . '/Settings_bak.php')) { |
|
2588 | + print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
2589 | + } |
|
2444 | 2590 | |
2445 | 2591 | // Make sure db_last_error.php is writable. |
2446 | 2592 | quickFileWritable($boarddir . '/db_last_error.php'); |
2447 | - if (!is_writable($boarddir . '/db_last_error.php')) |
|
2448 | - print_error('Error: Unable to obtain write access to "db_last_error.php".'); |
|
2593 | + if (!is_writable($boarddir . '/db_last_error.php')) { |
|
2594 | + print_error('Error: Unable to obtain write access to "db_last_error.php".'); |
|
2595 | + } |
|
2449 | 2596 | |
2450 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
2451 | - print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
2452 | - elseif (isset($modSettings['agreement'])) |
|
2597 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
2598 | + print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
2599 | + } elseif (isset($modSettings['agreement'])) |
|
2453 | 2600 | { |
2454 | 2601 | $fp = fopen($boarddir . '/agreement.txt', 'w'); |
2455 | 2602 | fwrite($fp, $modSettings['agreement']); |
@@ -2459,31 +2606,36 @@ discard block |
||
2459 | 2606 | // Make sure Themes is writable. |
2460 | 2607 | quickFileWritable($modSettings['theme_dir']); |
2461 | 2608 | |
2462 | - if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) |
|
2463 | - print_error('Error: Unable to obtain write access to "Themes".'); |
|
2609 | + if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) { |
|
2610 | + print_error('Error: Unable to obtain write access to "Themes".'); |
|
2611 | + } |
|
2464 | 2612 | |
2465 | 2613 | // Make sure cache directory exists and is writable! |
2466 | 2614 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
2467 | - if (!file_exists($cachedir_temp)) |
|
2468 | - @mkdir($cachedir_temp); |
|
2615 | + if (!file_exists($cachedir_temp)) { |
|
2616 | + @mkdir($cachedir_temp); |
|
2617 | + } |
|
2469 | 2618 | |
2470 | 2619 | // Make sure the cache temp dir is writable. |
2471 | 2620 | quickFileWritable($cachedir_temp); |
2472 | 2621 | |
2473 | - if (!is_writable($cachedir_temp)) |
|
2474 | - print_error('Error: Unable to obtain write access to "cache".', true); |
|
2622 | + if (!is_writable($cachedir_temp)) { |
|
2623 | + print_error('Error: Unable to obtain write access to "cache".', true); |
|
2624 | + } |
|
2475 | 2625 | |
2476 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
2477 | - print_error('Error: Unable to find language files!', true); |
|
2478 | - else |
|
2626 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
2627 | + print_error('Error: Unable to find language files!', true); |
|
2628 | + } else |
|
2479 | 2629 | { |
2480 | 2630 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
2481 | 2631 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
2482 | 2632 | |
2483 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
2484 | - print_error('Error: Language files out of date.', true); |
|
2485 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
2486 | - print_error('Error: Install language is missing for selected language.', true); |
|
2633 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
2634 | + print_error('Error: Language files out of date.', true); |
|
2635 | + } |
|
2636 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
2637 | + print_error('Error: Install language is missing for selected language.', true); |
|
2638 | + } |
|
2487 | 2639 | |
2488 | 2640 | // Otherwise include it! |
2489 | 2641 | require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
@@ -2502,8 +2654,9 @@ discard block |
||
2502 | 2654 | global $upcontext, $db_character_set, $sourcedir, $smcFunc, $modSettings, $language, $db_prefix, $db_type, $command_line, $support_js; |
2503 | 2655 | |
2504 | 2656 | // Done it already? |
2505 | - if (!empty($_POST['utf8_done'])) |
|
2506 | - return true; |
|
2657 | + if (!empty($_POST['utf8_done'])) { |
|
2658 | + return true; |
|
2659 | + } |
|
2507 | 2660 | |
2508 | 2661 | // First make sure they aren't already on UTF-8 before we go anywhere... |
2509 | 2662 | if ($db_type == 'postgresql' || ($db_character_set === 'utf8' && !empty($modSettings['global_character_set']) && $modSettings['global_character_set'] === 'UTF-8')) |
@@ -2516,8 +2669,7 @@ discard block |
||
2516 | 2669 | ); |
2517 | 2670 | |
2518 | 2671 | return true; |
2519 | - } |
|
2520 | - else |
|
2672 | + } else |
|
2521 | 2673 | { |
2522 | 2674 | $upcontext['page_title'] = 'Converting to UTF8'; |
2523 | 2675 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8'; |
@@ -2561,8 +2713,9 @@ discard block |
||
2561 | 2713 | ) |
2562 | 2714 | ); |
2563 | 2715 | $db_charsets = array(); |
2564 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2565 | - $db_charsets[] = $row['Charset']; |
|
2716 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2717 | + $db_charsets[] = $row['Charset']; |
|
2718 | + } |
|
2566 | 2719 | |
2567 | 2720 | $smcFunc['db_free_result']($request); |
2568 | 2721 | |
@@ -2598,13 +2751,15 @@ discard block |
||
2598 | 2751 | // If there's a fulltext index, we need to drop it first... |
2599 | 2752 | if ($request !== false || $smcFunc['db_num_rows']($request) != 0) |
2600 | 2753 | { |
2601 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2602 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
2754 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2755 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
2603 | 2756 | $upcontext['fulltext_index'][] = $row['Key_name']; |
2757 | + } |
|
2604 | 2758 | $smcFunc['db_free_result']($request); |
2605 | 2759 | |
2606 | - if (isset($upcontext['fulltext_index'])) |
|
2607 | - $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
2760 | + if (isset($upcontext['fulltext_index'])) { |
|
2761 | + $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
2762 | + } |
|
2608 | 2763 | } |
2609 | 2764 | |
2610 | 2765 | // Drop it and make a note... |
@@ -2794,8 +2949,9 @@ discard block |
||
2794 | 2949 | $replace = '%field%'; |
2795 | 2950 | |
2796 | 2951 | // Build a huge REPLACE statement... |
2797 | - foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) |
|
2798 | - $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
2952 | + foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) { |
|
2953 | + $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
2954 | + } |
|
2799 | 2955 | } |
2800 | 2956 | |
2801 | 2957 | // Get a list of table names ahead of time... This makes it easier to set our substep and such |
@@ -2805,9 +2961,10 @@ discard block |
||
2805 | 2961 | $upcontext['table_count'] = count($queryTables); |
2806 | 2962 | |
2807 | 2963 | // What ones have we already done? |
2808 | - foreach ($queryTables as $id => $table) |
|
2809 | - if ($id < $_GET['substep']) |
|
2964 | + foreach ($queryTables as $id => $table) { |
|
2965 | + if ($id < $_GET['substep']) |
|
2810 | 2966 | $upcontext['previous_tables'][] = $table; |
2967 | + } |
|
2811 | 2968 | |
2812 | 2969 | $upcontext['cur_table_num'] = $_GET['substep']; |
2813 | 2970 | $upcontext['cur_table_name'] = str_replace($db_prefix, '', $queryTables[$_GET['substep']]); |
@@ -2844,8 +3001,9 @@ discard block |
||
2844 | 3001 | nextSubstep($substep); |
2845 | 3002 | |
2846 | 3003 | // Just to make sure it doesn't time out. |
2847 | - if (function_exists('apache_reset_timeout')) |
|
2848 | - @apache_reset_timeout(); |
|
3004 | + if (function_exists('apache_reset_timeout')) { |
|
3005 | + @apache_reset_timeout(); |
|
3006 | + } |
|
2849 | 3007 | |
2850 | 3008 | $table_charsets = array(); |
2851 | 3009 | |
@@ -2868,8 +3026,9 @@ discard block |
||
2868 | 3026 | |
2869 | 3027 | // Build structure of columns to operate on organized by charset; only operate on columns not yet utf8 |
2870 | 3028 | if ($charset != 'utf8') { |
2871 | - if (!isset($table_charsets[$charset])) |
|
2872 | - $table_charsets[$charset] = array(); |
|
3029 | + if (!isset($table_charsets[$charset])) { |
|
3030 | + $table_charsets[$charset] = array(); |
|
3031 | + } |
|
2873 | 3032 | |
2874 | 3033 | $table_charsets[$charset][] = $column_info; |
2875 | 3034 | } |
@@ -2910,10 +3069,11 @@ discard block |
||
2910 | 3069 | if (isset($translation_tables[$upcontext['charset_detected']])) |
2911 | 3070 | { |
2912 | 3071 | $update = ''; |
2913 | - foreach ($table_charsets as $charset => $columns) |
|
2914 | - foreach ($columns as $column) |
|
3072 | + foreach ($table_charsets as $charset => $columns) { |
|
3073 | + foreach ($columns as $column) |
|
2915 | 3074 | $update .= ' |
2916 | 3075 | ' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ','; |
3076 | + } |
|
2917 | 3077 | |
2918 | 3078 | $smcFunc['db_query']('', ' |
2919 | 3079 | UPDATE {raw:table_name} |
@@ -2938,8 +3098,9 @@ discard block |
||
2938 | 3098 | // Now do the actual conversion (if still needed). |
2939 | 3099 | if ($charsets[$upcontext['charset_detected']] !== 'utf8') |
2940 | 3100 | { |
2941 | - if ($command_line) |
|
2942 | - echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
3101 | + if ($command_line) { |
|
3102 | + echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
3103 | + } |
|
2943 | 3104 | |
2944 | 3105 | $smcFunc['db_query']('', ' |
2945 | 3106 | ALTER TABLE {raw:table_name} |
@@ -2949,12 +3110,14 @@ discard block |
||
2949 | 3110 | ) |
2950 | 3111 | ); |
2951 | 3112 | |
2952 | - if ($command_line) |
|
2953 | - echo " done.\n"; |
|
3113 | + if ($command_line) { |
|
3114 | + echo " done.\n"; |
|
3115 | + } |
|
2954 | 3116 | } |
2955 | 3117 | // If this is XML to keep it nice for the user do one table at a time anyway! |
2956 | - if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count']) |
|
2957 | - return upgradeExit(); |
|
3118 | + if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count']) { |
|
3119 | + return upgradeExit(); |
|
3120 | + } |
|
2958 | 3121 | } |
2959 | 3122 | |
2960 | 3123 | $prev_charset = empty($translation_tables[$upcontext['charset_detected']]) ? $charsets[$upcontext['charset_detected']] : $translation_tables[$upcontext['charset_detected']]; |
@@ -2983,8 +3146,8 @@ discard block |
||
2983 | 3146 | ); |
2984 | 3147 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2985 | 3148 | { |
2986 | - 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) |
|
2987 | - $smcFunc['db_query']('', ' |
|
3149 | + 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) { |
|
3150 | + $smcFunc['db_query']('', ' |
|
2988 | 3151 | UPDATE {db_prefix}log_actions |
2989 | 3152 | SET extra = {string:extra} |
2990 | 3153 | WHERE id_action = {int:current_action}', |
@@ -2993,6 +3156,7 @@ discard block |
||
2993 | 3156 | 'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4], |
2994 | 3157 | ) |
2995 | 3158 | ); |
3159 | + } |
|
2996 | 3160 | } |
2997 | 3161 | $smcFunc['db_free_result']($request); |
2998 | 3162 | |
@@ -3014,15 +3178,17 @@ discard block |
||
3014 | 3178 | // First thing's first - did we already do this? |
3015 | 3179 | if (!empty($modSettings['json_done'])) |
3016 | 3180 | { |
3017 | - if ($command_line) |
|
3018 | - return DeleteUpgrade(); |
|
3019 | - else |
|
3020 | - return true; |
|
3181 | + if ($command_line) { |
|
3182 | + return DeleteUpgrade(); |
|
3183 | + } else { |
|
3184 | + return true; |
|
3185 | + } |
|
3021 | 3186 | } |
3022 | 3187 | |
3023 | 3188 | // Done it already - js wise? |
3024 | - if (!empty($_POST['json_done'])) |
|
3025 | - return true; |
|
3189 | + if (!empty($_POST['json_done'])) { |
|
3190 | + return true; |
|
3191 | + } |
|
3026 | 3192 | |
3027 | 3193 | // List of tables affected by this function |
3028 | 3194 | // name => array('key', col1[,col2|true[,col3]]) |
@@ -3054,12 +3220,14 @@ discard block |
||
3054 | 3220 | $upcontext['cur_table_name'] = isset($keys[$_GET['substep']]) ? $keys[$_GET['substep']] : $keys[0]; |
3055 | 3221 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
3056 | 3222 | |
3057 | - foreach ($keys as $id => $table) |
|
3058 | - if ($id < $_GET['substep']) |
|
3223 | + foreach ($keys as $id => $table) { |
|
3224 | + if ($id < $_GET['substep']) |
|
3059 | 3225 | $upcontext['previous_tables'][] = $table; |
3226 | + } |
|
3060 | 3227 | |
3061 | - if ($command_line) |
|
3062 | - echo 'Converting data from serialize() to json_encode().'; |
|
3228 | + if ($command_line) { |
|
3229 | + echo 'Converting data from serialize() to json_encode().'; |
|
3230 | + } |
|
3063 | 3231 | |
3064 | 3232 | if (!$support_js || isset($_GET['xml'])) |
3065 | 3233 | { |
@@ -3099,8 +3267,9 @@ discard block |
||
3099 | 3267 | |
3100 | 3268 | // Loop through and fix these... |
3101 | 3269 | $new_settings = array(); |
3102 | - if ($command_line) |
|
3103 | - echo "\n" . 'Fixing some settings...'; |
|
3270 | + if ($command_line) { |
|
3271 | + echo "\n" . 'Fixing some settings...'; |
|
3272 | + } |
|
3104 | 3273 | |
3105 | 3274 | foreach ($serialized_settings as $var) |
3106 | 3275 | { |
@@ -3108,22 +3277,24 @@ discard block |
||
3108 | 3277 | { |
3109 | 3278 | // Attempt to unserialize the setting |
3110 | 3279 | $temp = @safe_unserialize($modSettings[$var]); |
3111 | - if (!$temp && $command_line) |
|
3112 | - echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
3113 | - elseif ($temp !== false) |
|
3114 | - $new_settings[$var] = json_encode($temp); |
|
3280 | + if (!$temp && $command_line) { |
|
3281 | + echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
3282 | + } elseif ($temp !== false) { |
|
3283 | + $new_settings[$var] = json_encode($temp); |
|
3284 | + } |
|
3115 | 3285 | } |
3116 | 3286 | } |
3117 | 3287 | |
3118 | 3288 | // Update everything at once |
3119 | - if (!function_exists('cache_put_data')) |
|
3120 | - require_once($sourcedir . '/Load.php'); |
|
3289 | + if (!function_exists('cache_put_data')) { |
|
3290 | + require_once($sourcedir . '/Load.php'); |
|
3291 | + } |
|
3121 | 3292 | updateSettings($new_settings, true); |
3122 | 3293 | |
3123 | - if ($command_line) |
|
3124 | - echo ' done.'; |
|
3125 | - } |
|
3126 | - elseif ($table == 'themes') |
|
3294 | + if ($command_line) { |
|
3295 | + echo ' done.'; |
|
3296 | + } |
|
3297 | + } elseif ($table == 'themes') |
|
3127 | 3298 | { |
3128 | 3299 | // Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point... |
3129 | 3300 | $query = $smcFunc['db_query']('', ' |
@@ -3142,10 +3313,11 @@ discard block |
||
3142 | 3313 | |
3143 | 3314 | if ($command_line) |
3144 | 3315 | { |
3145 | - if ($temp === false) |
|
3146 | - echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
3147 | - else |
|
3148 | - echo "\n" . 'Fixing admin preferences...'; |
|
3316 | + if ($temp === false) { |
|
3317 | + echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
3318 | + } else { |
|
3319 | + echo "\n" . 'Fixing admin preferences...'; |
|
3320 | + } |
|
3149 | 3321 | } |
3150 | 3322 | |
3151 | 3323 | if ($temp !== false) |
@@ -3167,15 +3339,15 @@ discard block |
||
3167 | 3339 | ) |
3168 | 3340 | ); |
3169 | 3341 | |
3170 | - if ($command_line) |
|
3171 | - echo ' done.'; |
|
3342 | + if ($command_line) { |
|
3343 | + echo ' done.'; |
|
3344 | + } |
|
3172 | 3345 | } |
3173 | 3346 | } |
3174 | 3347 | |
3175 | 3348 | $smcFunc['db_free_result']($query); |
3176 | 3349 | } |
3177 | - } |
|
3178 | - else |
|
3350 | + } else |
|
3179 | 3351 | { |
3180 | 3352 | // First item is always the key... |
3181 | 3353 | $key = $info[0]; |
@@ -3186,8 +3358,7 @@ discard block |
||
3186 | 3358 | { |
3187 | 3359 | $col_select = $info[1]; |
3188 | 3360 | $where = ' WHERE ' . $info[1] . ' != {empty}'; |
3189 | - } |
|
3190 | - else |
|
3361 | + } else |
|
3191 | 3362 | { |
3192 | 3363 | $col_select = implode(', ', $info); |
3193 | 3364 | } |
@@ -3220,8 +3391,7 @@ discard block |
||
3220 | 3391 | if ($temp === false && $command_line) |
3221 | 3392 | { |
3222 | 3393 | echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n"; |
3223 | - } |
|
3224 | - else |
|
3394 | + } else |
|
3225 | 3395 | { |
3226 | 3396 | $row[$col] = json_encode($temp); |
3227 | 3397 | |
@@ -3246,16 +3416,18 @@ discard block |
||
3246 | 3416 | } |
3247 | 3417 | } |
3248 | 3418 | |
3249 | - if ($command_line) |
|
3250 | - echo ' done.'; |
|
3419 | + if ($command_line) { |
|
3420 | + echo ' done.'; |
|
3421 | + } |
|
3251 | 3422 | |
3252 | 3423 | // Free up some memory... |
3253 | 3424 | $smcFunc['db_free_result']($query); |
3254 | 3425 | } |
3255 | 3426 | } |
3256 | 3427 | // If this is XML to keep it nice for the user do one table at a time anyway! |
3257 | - if (isset($_GET['xml'])) |
|
3258 | - return upgradeExit(); |
|
3428 | + if (isset($_GET['xml'])) { |
|
3429 | + return upgradeExit(); |
|
3430 | + } |
|
3259 | 3431 | } |
3260 | 3432 | |
3261 | 3433 | if ($command_line) |
@@ -3270,8 +3442,9 @@ discard block |
||
3270 | 3442 | |
3271 | 3443 | $_GET['substep'] = 0; |
3272 | 3444 | // Make sure we move on! |
3273 | - if ($command_line) |
|
3274 | - return DeleteUpgrade(); |
|
3445 | + if ($command_line) { |
|
3446 | + return DeleteUpgrade(); |
|
3447 | + } |
|
3275 | 3448 | |
3276 | 3449 | return true; |
3277 | 3450 | } |
@@ -3291,14 +3464,16 @@ discard block |
||
3291 | 3464 | global $upcontext, $txt, $settings; |
3292 | 3465 | |
3293 | 3466 | // Don't call me twice! |
3294 | - if (!empty($upcontext['chmod_called'])) |
|
3295 | - return; |
|
3467 | + if (!empty($upcontext['chmod_called'])) { |
|
3468 | + return; |
|
3469 | + } |
|
3296 | 3470 | |
3297 | 3471 | $upcontext['chmod_called'] = true; |
3298 | 3472 | |
3299 | 3473 | // Nothing? |
3300 | - if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) |
|
3301 | - return; |
|
3474 | + if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) { |
|
3475 | + return; |
|
3476 | + } |
|
3302 | 3477 | |
3303 | 3478 | // Was it a problem with Windows? |
3304 | 3479 | if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess') |
@@ -3330,11 +3505,12 @@ discard block |
||
3330 | 3505 | content.write(\'<div class="windowbg description">\n\t\t\t<h4>', $txt['upgrade_ftp_files'], '</h4>\n\t\t\t\'); |
3331 | 3506 | content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');'; |
3332 | 3507 | |
3333 | - if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') |
|
3334 | - echo ' |
|
3508 | + if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') { |
|
3509 | + echo ' |
|
3335 | 3510 | content.write(\'<hr>\n\t\t\t\'); |
3336 | 3511 | content.write(\'<p>', $txt['upgrade_ftp_shell'], '</p>\n\t\t\t\'); |
3337 | 3512 | content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');'; |
3513 | + } |
|
3338 | 3514 | |
3339 | 3515 | echo ' |
3340 | 3516 | content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\'); |
@@ -3342,17 +3518,19 @@ discard block |
||
3342 | 3518 | } |
3343 | 3519 | </script>'; |
3344 | 3520 | |
3345 | - if (!empty($upcontext['chmod']['ftp_error'])) |
|
3346 | - echo ' |
|
3521 | + if (!empty($upcontext['chmod']['ftp_error'])) { |
|
3522 | + echo ' |
|
3347 | 3523 | <div class="error_message red"> |
3348 | 3524 | ', $txt['upgrade_ftp_error'], '<br><br> |
3349 | 3525 | <code>', $upcontext['chmod']['ftp_error'], '</code> |
3350 | 3526 | </div> |
3351 | 3527 | <br>'; |
3528 | + } |
|
3352 | 3529 | |
3353 | - if (empty($upcontext['chmod_in_form'])) |
|
3354 | - echo ' |
|
3530 | + if (empty($upcontext['chmod_in_form'])) { |
|
3531 | + echo ' |
|
3355 | 3532 | <form action="', $upcontext['form_url'], '" method="post">'; |
3533 | + } |
|
3356 | 3534 | |
3357 | 3535 | echo ' |
3358 | 3536 | <table width="520" border="0" align="center" style="margin-bottom: 1ex;"> |
@@ -3387,10 +3565,11 @@ discard block |
||
3387 | 3565 | <div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['ftp_connect'], '" class="button"></div> |
3388 | 3566 | </div>'; |
3389 | 3567 | |
3390 | - if (empty($upcontext['chmod_in_form'])) |
|
3391 | - echo ' |
|
3568 | + if (empty($upcontext['chmod_in_form'])) { |
|
3569 | + echo ' |
|
3392 | 3570 | </form>'; |
3393 | -} |
|
3571 | + } |
|
3572 | + } |
|
3394 | 3573 | |
3395 | 3574 | function template_upgrade_above() |
3396 | 3575 | { |
@@ -3450,9 +3629,10 @@ discard block |
||
3450 | 3629 | <h2>', $txt['upgrade_progress'], '</h2> |
3451 | 3630 | <ul>'; |
3452 | 3631 | |
3453 | - foreach ($upcontext['steps'] as $num => $step) |
|
3454 | - echo ' |
|
3632 | + foreach ($upcontext['steps'] as $num => $step) { |
|
3633 | + echo ' |
|
3455 | 3634 | <li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
3635 | + } |
|
3456 | 3636 | |
3457 | 3637 | echo ' |
3458 | 3638 | </ul> |
@@ -3465,8 +3645,8 @@ discard block |
||
3465 | 3645 | </div> |
3466 | 3646 | </div>'; |
3467 | 3647 | |
3468 | - if (isset($upcontext['step_progress'])) |
|
3469 | - echo ' |
|
3648 | + if (isset($upcontext['step_progress'])) { |
|
3649 | + echo ' |
|
3470 | 3650 | <br> |
3471 | 3651 | <br> |
3472 | 3652 | <div id="progress_bar_step"> |
@@ -3475,6 +3655,7 @@ discard block |
||
3475 | 3655 | <span>', $txt['upgrade_step_progress'], '</span> |
3476 | 3656 | </div> |
3477 | 3657 | </div>'; |
3658 | + } |
|
3478 | 3659 | |
3479 | 3660 | echo ' |
3480 | 3661 | <div id="substep_bar_div" class="smalltext" style="float: left;width: 50%;margin-top: 0.6em;display: ', isset($upcontext['substep_progress']) ? '' : 'none', ';">', isset($upcontext['substep_progress_name']) ? trim(strtr($upcontext['substep_progress_name'], array('.' => ''))) : '', ':</div> |
@@ -3505,32 +3686,36 @@ discard block |
||
3505 | 3686 | { |
3506 | 3687 | global $upcontext, $txt; |
3507 | 3688 | |
3508 | - if (!empty($upcontext['pause'])) |
|
3509 | - echo ' |
|
3689 | + if (!empty($upcontext['pause'])) { |
|
3690 | + echo ' |
|
3510 | 3691 | <em>', $txt['upgrade_incomplete'], '.</em><br> |
3511 | 3692 | |
3512 | 3693 | <h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2> |
3513 | 3694 | <h3> |
3514 | 3695 | ', $txt['upgrade_paused_overload'], ' |
3515 | 3696 | </h3>'; |
3697 | + } |
|
3516 | 3698 | |
3517 | - if (!empty($upcontext['custom_warning'])) |
|
3518 | - echo ' |
|
3699 | + if (!empty($upcontext['custom_warning'])) { |
|
3700 | + echo ' |
|
3519 | 3701 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
3520 | 3702 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
3521 | 3703 | <strong style="text-decoration: underline;">', $txt['upgrade_note'], '</strong><br> |
3522 | 3704 | <div style="padding-left: 6ex;">', $upcontext['custom_warning'], '</div> |
3523 | 3705 | </div>'; |
3706 | + } |
|
3524 | 3707 | |
3525 | 3708 | echo ' |
3526 | 3709 | <div class="righttext" style="margin: 1ex;">'; |
3527 | 3710 | |
3528 | - if (!empty($upcontext['continue'])) |
|
3529 | - echo ' |
|
3711 | + if (!empty($upcontext['continue'])) { |
|
3712 | + echo ' |
|
3530 | 3713 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button">'; |
3531 | - if (!empty($upcontext['skip'])) |
|
3532 | - echo ' |
|
3714 | + } |
|
3715 | + if (!empty($upcontext['skip'])) { |
|
3716 | + echo ' |
|
3533 | 3717 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button">'; |
3718 | + } |
|
3534 | 3719 | |
3535 | 3720 | echo ' |
3536 | 3721 | </div> |
@@ -3580,11 +3765,12 @@ discard block |
||
3580 | 3765 | echo '<', '?xml version="1.0" encoding="UTF-8"?', '> |
3581 | 3766 | <smf>'; |
3582 | 3767 | |
3583 | - if (!empty($upcontext['get_data'])) |
|
3584 | - foreach ($upcontext['get_data'] as $k => $v) |
|
3768 | + if (!empty($upcontext['get_data'])) { |
|
3769 | + foreach ($upcontext['get_data'] as $k => $v) |
|
3585 | 3770 | echo ' |
3586 | 3771 | <get key="', $k, '">', $v, '</get>'; |
3587 | -} |
|
3772 | + } |
|
3773 | + } |
|
3588 | 3774 | |
3589 | 3775 | function template_xml_below() |
3590 | 3776 | { |
@@ -3625,8 +3811,8 @@ discard block |
||
3625 | 3811 | template_chmod(); |
3626 | 3812 | |
3627 | 3813 | // For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade! |
3628 | - if ($upcontext['is_large_forum']) |
|
3629 | - echo ' |
|
3814 | + if ($upcontext['is_large_forum']) { |
|
3815 | + echo ' |
|
3630 | 3816 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
3631 | 3817 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
3632 | 3818 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3634,10 +3820,11 @@ discard block |
||
3634 | 3820 | ', $txt['upgrade_warning_lots_data'], ' |
3635 | 3821 | </div> |
3636 | 3822 | </div>'; |
3823 | + } |
|
3637 | 3824 | |
3638 | 3825 | // A warning message? |
3639 | - if (!empty($upcontext['warning'])) |
|
3640 | - echo ' |
|
3826 | + if (!empty($upcontext['warning'])) { |
|
3827 | + echo ' |
|
3641 | 3828 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
3642 | 3829 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
3643 | 3830 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3645,6 +3832,7 @@ discard block |
||
3645 | 3832 | ', $upcontext['warning'], ' |
3646 | 3833 | </div> |
3647 | 3834 | </div>'; |
3835 | + } |
|
3648 | 3836 | |
3649 | 3837 | // Paths are incorrect? |
3650 | 3838 | echo ' |
@@ -3660,20 +3848,22 @@ discard block |
||
3660 | 3848 | if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600)) |
3661 | 3849 | { |
3662 | 3850 | $ago = time() - $upcontext['started']; |
3663 | - if ($ago < 60) |
|
3664 | - $ago = $ago . ' seconds'; |
|
3665 | - elseif ($ago < 3600) |
|
3666 | - $ago = (int) ($ago / 60) . ' minutes'; |
|
3667 | - else |
|
3668 | - $ago = (int) ($ago / 3600) . ' hours'; |
|
3851 | + if ($ago < 60) { |
|
3852 | + $ago = $ago . ' seconds'; |
|
3853 | + } elseif ($ago < 3600) { |
|
3854 | + $ago = (int) ($ago / 60) . ' minutes'; |
|
3855 | + } else { |
|
3856 | + $ago = (int) ($ago / 3600) . ' hours'; |
|
3857 | + } |
|
3669 | 3858 | |
3670 | 3859 | $active = time() - $upcontext['updated']; |
3671 | - if ($active < 60) |
|
3672 | - $updated = $active . ' seconds'; |
|
3673 | - elseif ($active < 3600) |
|
3674 | - $updated = (int) ($active / 60) . ' minutes'; |
|
3675 | - else |
|
3676 | - $updated = (int) ($active / 3600) . ' hours'; |
|
3860 | + if ($active < 60) { |
|
3861 | + $updated = $active . ' seconds'; |
|
3862 | + } elseif ($active < 3600) { |
|
3863 | + $updated = (int) ($active / 60) . ' minutes'; |
|
3864 | + } else { |
|
3865 | + $updated = (int) ($active / 3600) . ' hours'; |
|
3866 | + } |
|
3677 | 3867 | |
3678 | 3868 | echo ' |
3679 | 3869 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
@@ -3682,16 +3872,18 @@ discard block |
||
3682 | 3872 | <div style="padding-left: 6ex;"> |
3683 | 3873 | "', $upcontext['user']['name'], '" has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.'; |
3684 | 3874 | |
3685 | - if ($active < 600) |
|
3686 | - echo ' |
|
3875 | + if ($active < 600) { |
|
3876 | + echo ' |
|
3687 | 3877 | ', $txt['upgrade_run_script'], ' ', $upcontext['user']['name'],' ', $txt['upgrade_run_script2'], ''; |
3878 | + } |
|
3688 | 3879 | |
3689 | - if ($active > $upcontext['inactive_timeout']) |
|
3690 | - echo ' |
|
3880 | + if ($active > $upcontext['inactive_timeout']) { |
|
3881 | + echo ' |
|
3691 | 3882 | <br><br>',$txt['upgrade_run'], ''; |
3692 | - else |
|
3693 | - echo ' |
|
3883 | + } else { |
|
3884 | + echo ' |
|
3694 | 3885 | <br><br>', $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!'); |
3886 | + } |
|
3695 | 3887 | |
3696 | 3888 | echo ' |
3697 | 3889 | </div> |
@@ -3707,9 +3899,10 @@ discard block |
||
3707 | 3899 | <td> |
3708 | 3900 | <input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', '>'; |
3709 | 3901 | |
3710 | - if (!empty($upcontext['username_incorrect'])) |
|
3711 | - echo ' |
|
3902 | + if (!empty($upcontext['username_incorrect'])) { |
|
3903 | + echo ' |
|
3712 | 3904 | <div class="smalltext" style="color: red;">', $txt['upgrade_wrong_username'], '</div>'; |
3905 | + } |
|
3713 | 3906 | |
3714 | 3907 | echo ' |
3715 | 3908 | </td> |
@@ -3720,9 +3913,10 @@ discard block |
||
3720 | 3913 | <input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', '> |
3721 | 3914 | <input type="hidden" name="hash_passwrd" value="">'; |
3722 | 3915 | |
3723 | - if (!empty($upcontext['password_failed'])) |
|
3724 | - echo ' |
|
3916 | + if (!empty($upcontext['password_failed'])) { |
|
3917 | + echo ' |
|
3725 | 3918 | <div class="smalltext" style="color: red;">', $txt['upgrade_wrong_password'], '</div>'; |
3919 | + } |
|
3726 | 3920 | |
3727 | 3921 | echo ' |
3728 | 3922 | </td> |
@@ -3793,8 +3987,8 @@ discard block |
||
3793 | 3987 | <form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">'; |
3794 | 3988 | |
3795 | 3989 | // Warning message? |
3796 | - if (!empty($upcontext['upgrade_options_warning'])) |
|
3797 | - echo ' |
|
3990 | + if (!empty($upcontext['upgrade_options_warning'])) { |
|
3991 | + echo ' |
|
3798 | 3992 | <div style="margin: 1ex; padding: 1ex; border: 1px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
3799 | 3993 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
3800 | 3994 | <strong style="text-decoration: underline;">Warning!</strong><br> |
@@ -3802,6 +3996,7 @@ discard block |
||
3802 | 3996 | ', $upcontext['upgrade_options_warning'], ' |
3803 | 3997 | </div> |
3804 | 3998 | </div>'; |
3999 | + } |
|
3805 | 4000 | |
3806 | 4001 | echo ' |
3807 | 4002 | <table> |
@@ -3844,8 +4039,8 @@ discard block |
||
3844 | 4039 | </td> |
3845 | 4040 | </tr>'; |
3846 | 4041 | |
3847 | - if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) |
|
3848 | - echo ' |
|
4042 | + if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) { |
|
4043 | + echo ' |
|
3849 | 4044 | <tr valign="top"> |
3850 | 4045 | <td width="2%"> |
3851 | 4046 | <input type="checkbox" name="delete_karma" id="delete_karma" value="1"> |
@@ -3854,6 +4049,7 @@ discard block |
||
3854 | 4049 | <label for="delete_karma">', $txt['upgrade_delete_karma'], '</label> |
3855 | 4050 | </td> |
3856 | 4051 | </tr>'; |
4052 | + } |
|
3857 | 4053 | |
3858 | 4054 | echo ' |
3859 | 4055 | <tr valign="top"> |
@@ -3891,10 +4087,11 @@ discard block |
||
3891 | 4087 | </div>'; |
3892 | 4088 | |
3893 | 4089 | // Dont any tables so far? |
3894 | - if (!empty($upcontext['previous_tables'])) |
|
3895 | - foreach ($upcontext['previous_tables'] as $table) |
|
4090 | + if (!empty($upcontext['previous_tables'])) { |
|
4091 | + foreach ($upcontext['previous_tables'] as $table) |
|
3896 | 4092 | echo ' |
3897 | 4093 | <br>', $txt['upgrade_completed_table'], ' "', $table, '".'; |
4094 | + } |
|
3898 | 4095 | |
3899 | 4096 | echo ' |
3900 | 4097 | <h3 id="current_tab_div">', $txt['upgrade_current_table'], ' "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
@@ -3931,12 +4128,13 @@ discard block |
||
3931 | 4128 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
3932 | 4129 | |
3933 | 4130 | // If debug flood the screen. |
3934 | - if ($is_debug) |
|
3935 | - echo ' |
|
4131 | + if ($is_debug) { |
|
4132 | + echo ' |
|
3936 | 4133 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
3937 | 4134 | |
3938 | 4135 | if (document.getElementById(\'debug_section\').scrollHeight) |
3939 | 4136 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
4137 | + } |
|
3940 | 4138 | |
3941 | 4139 | echo ' |
3942 | 4140 | // Get the next update... |
@@ -3969,8 +4167,9 @@ discard block |
||
3969 | 4167 | { |
3970 | 4168 | global $upcontext, $support_js, $is_debug, $timeLimitThreshold, $txt; |
3971 | 4169 | |
3972 | - if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) |
|
3973 | - $is_debug = true; |
|
4170 | + if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) { |
|
4171 | + $is_debug = true; |
|
4172 | + } |
|
3974 | 4173 | |
3975 | 4174 | echo ' |
3976 | 4175 | <h3>', $txt['upgrade_db_changes'], '</h3> |
@@ -3985,8 +4184,9 @@ discard block |
||
3985 | 4184 | { |
3986 | 4185 | foreach ($upcontext['actioned_items'] as $num => $item) |
3987 | 4186 | { |
3988 | - if ($num != 0) |
|
3989 | - echo ' Successful!'; |
|
4187 | + if ($num != 0) { |
|
4188 | + echo ' Successful!'; |
|
4189 | + } |
|
3990 | 4190 | echo '<br>' . $item; |
3991 | 4191 | } |
3992 | 4192 | if (!empty($upcontext['changes_complete'])) |
@@ -3999,28 +4199,32 @@ discard block |
||
3999 | 4199 | $seconds = intval($active % 60); |
4000 | 4200 | |
4001 | 4201 | $totalTime = ''; |
4002 | - if ($hours > 0) |
|
4003 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4004 | - if ($minutes > 0) |
|
4005 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4006 | - if ($seconds > 0) |
|
4007 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4202 | + if ($hours > 0) { |
|
4203 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4204 | + } |
|
4205 | + if ($minutes > 0) { |
|
4206 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4207 | + } |
|
4208 | + if ($seconds > 0) { |
|
4209 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4210 | + } |
|
4008 | 4211 | } |
4009 | 4212 | |
4010 | - if ($is_debug && !empty($totalTime)) |
|
4011 | - echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
4012 | - else |
|
4013 | - echo ' Successful!<br><br>'; |
|
4213 | + if ($is_debug && !empty($totalTime)) { |
|
4214 | + echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
4215 | + } else { |
|
4216 | + echo ' Successful!<br><br>'; |
|
4217 | + } |
|
4014 | 4218 | |
4015 | 4219 | echo '<span id="commess" style="font-weight: bold;">', $txt['upgrade_db_complete'], '</span><br>'; |
4016 | 4220 | } |
4017 | - } |
|
4018 | - else |
|
4221 | + } else |
|
4019 | 4222 | { |
4020 | 4223 | // Tell them how many files we have in total. |
4021 | - if ($upcontext['file_count'] > 1) |
|
4022 | - echo ' |
|
4224 | + if ($upcontext['file_count'] > 1) { |
|
4225 | + echo ' |
|
4023 | 4226 | <strong id="info1">', $txt['upgrade_script'], ' <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>'; |
4227 | + } |
|
4024 | 4228 | |
4025 | 4229 | echo ' |
4026 | 4230 | <h3 id="info2"><strong>', $txt['upgrade_executing'], '</strong> "<span id="cur_item_name">', $upcontext['current_item_name'], '</span>" (<span id="item_num">', $upcontext['current_item_num'], '</span> ', $txt['upgrade_of'], ' <span id="total_items"><span id="item_count">', $upcontext['total_items'], '</span>', $upcontext['file_count'] > 1 ? ' - of this script' : '', ')</span></h3> |
@@ -4036,19 +4240,23 @@ discard block |
||
4036 | 4240 | $seconds = intval($active % 60); |
4037 | 4241 | |
4038 | 4242 | $totalTime = ''; |
4039 | - if ($hours > 0) |
|
4040 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4041 | - if ($minutes > 0) |
|
4042 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4043 | - if ($seconds > 0) |
|
4044 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4243 | + if ($hours > 0) { |
|
4244 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4245 | + } |
|
4246 | + if ($minutes > 0) { |
|
4247 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4248 | + } |
|
4249 | + if ($seconds > 0) { |
|
4250 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4251 | + } |
|
4045 | 4252 | } |
4046 | 4253 | |
4047 | 4254 | echo ' |
4048 | 4255 | <br><span id="upgradeCompleted">'; |
4049 | 4256 | |
4050 | - if (!empty($totalTime)) |
|
4051 | - echo 'Completed in ', $totalTime, '<br>'; |
|
4257 | + if (!empty($totalTime)) { |
|
4258 | + echo 'Completed in ', $totalTime, '<br>'; |
|
4259 | + } |
|
4052 | 4260 | |
4053 | 4261 | echo '</span> |
4054 | 4262 | <div id="debug_section" style="height: 59px; overflow: auto;"> |
@@ -4085,9 +4293,10 @@ discard block |
||
4085 | 4293 | var getData = ""; |
4086 | 4294 | var debugItems = ', $upcontext['debug_items'], ';'; |
4087 | 4295 | |
4088 | - if ($is_debug) |
|
4089 | - echo ' |
|
4296 | + if ($is_debug) { |
|
4297 | + echo ' |
|
4090 | 4298 | var upgradeStartTime = ' . $upcontext['started'] . ';'; |
4299 | + } |
|
4091 | 4300 | |
4092 | 4301 | echo ' |
4093 | 4302 | function getNextItem() |
@@ -4127,9 +4336,10 @@ discard block |
||
4127 | 4336 | document.getElementById("error_block").style.display = ""; |
4128 | 4337 | setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));'; |
4129 | 4338 | |
4130 | - if ($is_debug) |
|
4131 | - echo ' |
|
4339 | + if ($is_debug) { |
|
4340 | + echo ' |
|
4132 | 4341 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
4342 | + } |
|
4133 | 4343 | |
4134 | 4344 | echo ' |
4135 | 4345 | } |
@@ -4150,9 +4360,10 @@ discard block |
||
4150 | 4360 | document.getElementById("error_block").style.display = ""; |
4151 | 4361 | setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);'; |
4152 | 4362 | |
4153 | - if ($is_debug) |
|
4154 | - echo ' |
|
4363 | + if ($is_debug) { |
|
4364 | + echo ' |
|
4155 | 4365 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
4366 | + } |
|
4156 | 4367 | |
4157 | 4368 | echo ' |
4158 | 4369 | } |
@@ -4211,8 +4422,8 @@ discard block |
||
4211 | 4422 | if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ') |
4212 | 4423 | {'; |
4213 | 4424 | |
4214 | - if ($is_debug) |
|
4215 | - echo ' |
|
4425 | + if ($is_debug) { |
|
4426 | + echo ' |
|
4216 | 4427 | document.getElementById(\'debug_section\').style.display = "none"; |
4217 | 4428 | |
4218 | 4429 | var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue); |
@@ -4230,6 +4441,7 @@ discard block |
||
4230 | 4441 | totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : ""); |
4231 | 4442 | |
4232 | 4443 | setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);'; |
4444 | + } |
|
4233 | 4445 | |
4234 | 4446 | echo ' |
4235 | 4447 | |
@@ -4237,9 +4449,10 @@ discard block |
||
4237 | 4449 | document.getElementById(\'contbutt\').disabled = 0; |
4238 | 4450 | document.getElementById(\'database_done\').value = 1;'; |
4239 | 4451 | |
4240 | - if ($upcontext['file_count'] > 1) |
|
4241 | - echo ' |
|
4452 | + if ($upcontext['file_count'] > 1) { |
|
4453 | + echo ' |
|
4242 | 4454 | document.getElementById(\'info1\').style.display = "none";'; |
4455 | + } |
|
4243 | 4456 | |
4244 | 4457 | echo ' |
4245 | 4458 | document.getElementById(\'info2\').style.display = "none"; |
@@ -4252,9 +4465,10 @@ discard block |
||
4252 | 4465 | lastItem = 0; |
4253 | 4466 | prevFile = curFile;'; |
4254 | 4467 | |
4255 | - if ($is_debug) |
|
4256 | - echo ' |
|
4468 | + if ($is_debug) { |
|
4469 | + echo ' |
|
4257 | 4470 | setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');'; |
4471 | + } |
|
4258 | 4472 | |
4259 | 4473 | echo ' |
4260 | 4474 | getNextItem(); |
@@ -4262,8 +4476,8 @@ discard block |
||
4262 | 4476 | }'; |
4263 | 4477 | |
4264 | 4478 | // If debug scroll the screen. |
4265 | - if ($is_debug) |
|
4266 | - echo ' |
|
4479 | + if ($is_debug) { |
|
4480 | + echo ' |
|
4267 | 4481 | if (iLastSubStepProgress == -1) |
4268 | 4482 | { |
4269 | 4483 | // Give it consistent dots. |
@@ -4282,6 +4496,7 @@ discard block |
||
4282 | 4496 | |
4283 | 4497 | if (document.getElementById(\'debug_section\').scrollHeight) |
4284 | 4498 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
4499 | + } |
|
4285 | 4500 | |
4286 | 4501 | echo ' |
4287 | 4502 | // Update the page. |
@@ -4342,9 +4557,10 @@ discard block |
||
4342 | 4557 | }'; |
4343 | 4558 | |
4344 | 4559 | // Start things off assuming we've not errored. |
4345 | - if (empty($upcontext['error_message'])) |
|
4346 | - echo ' |
|
4560 | + if (empty($upcontext['error_message'])) { |
|
4561 | + echo ' |
|
4347 | 4562 | getNextItem();'; |
4563 | + } |
|
4348 | 4564 | |
4349 | 4565 | echo ' |
4350 | 4566 | //# sourceURL=dynamicScript-dbch.js |
@@ -4362,18 +4578,21 @@ discard block |
||
4362 | 4578 | <item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item> |
4363 | 4579 | <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>'; |
4364 | 4580 | |
4365 | - if (!empty($upcontext['error_message'])) |
|
4366 | - echo ' |
|
4581 | + if (!empty($upcontext['error_message'])) { |
|
4582 | + echo ' |
|
4367 | 4583 | <error>', $upcontext['error_message'], '</error>'; |
4584 | + } |
|
4368 | 4585 | |
4369 | - if (!empty($upcontext['error_string'])) |
|
4370 | - echo ' |
|
4586 | + if (!empty($upcontext['error_string'])) { |
|
4587 | + echo ' |
|
4371 | 4588 | <sql>', $upcontext['error_string'], '</sql>'; |
4589 | + } |
|
4372 | 4590 | |
4373 | - if ($is_debug) |
|
4374 | - echo ' |
|
4591 | + if ($is_debug) { |
|
4592 | + echo ' |
|
4375 | 4593 | <curtime>', time(), '</curtime>'; |
4376 | -} |
|
4594 | + } |
|
4595 | + } |
|
4377 | 4596 | |
4378 | 4597 | // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications.... |
4379 | 4598 | function template_convert_utf8() |
@@ -4392,18 +4611,20 @@ discard block |
||
4392 | 4611 | </div>'; |
4393 | 4612 | |
4394 | 4613 | // Done any tables so far? |
4395 | - if (!empty($upcontext['previous_tables'])) |
|
4396 | - foreach ($upcontext['previous_tables'] as $table) |
|
4614 | + if (!empty($upcontext['previous_tables'])) { |
|
4615 | + foreach ($upcontext['previous_tables'] as $table) |
|
4397 | 4616 | echo ' |
4398 | 4617 | <br>', $txt['upgrade_completed_table'], ' "', $table, '".'; |
4618 | + } |
|
4399 | 4619 | |
4400 | 4620 | echo ' |
4401 | 4621 | <h3 id="current_tab_div">', $txt['upgrade_current_table'], ' "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3>'; |
4402 | 4622 | |
4403 | 4623 | // If we dropped their index, let's let them know |
4404 | - if ($upcontext['dropping_index']) |
|
4405 | - echo ' |
|
4624 | + if ($upcontext['dropping_index']) { |
|
4625 | + echo ' |
|
4406 | 4626 | <br><span id="indexmsg" style="font-weight: bold; font-style: italic; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">', $txt['upgrade_fulltext'], '</span>'; |
4627 | + } |
|
4407 | 4628 | |
4408 | 4629 | // Completion notification |
4409 | 4630 | echo ' |
@@ -4440,12 +4661,13 @@ discard block |
||
4440 | 4661 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
4441 | 4662 | |
4442 | 4663 | // If debug flood the screen. |
4443 | - if ($is_debug) |
|
4444 | - echo ' |
|
4664 | + if ($is_debug) { |
|
4665 | + echo ' |
|
4445 | 4666 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
4446 | 4667 | |
4447 | 4668 | if (document.getElementById(\'debug_section\').scrollHeight) |
4448 | 4669 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
4670 | + } |
|
4449 | 4671 | |
4450 | 4672 | echo ' |
4451 | 4673 | // Get the next update... |
@@ -4493,19 +4715,21 @@ discard block |
||
4493 | 4715 | </div>'; |
4494 | 4716 | |
4495 | 4717 | // Dont any tables so far? |
4496 | - if (!empty($upcontext['previous_tables'])) |
|
4497 | - foreach ($upcontext['previous_tables'] as $table) |
|
4718 | + if (!empty($upcontext['previous_tables'])) { |
|
4719 | + foreach ($upcontext['previous_tables'] as $table) |
|
4498 | 4720 | echo ' |
4499 | 4721 | <br>', $txt['upgrade_completed_table'], ' "', $table, '".'; |
4722 | + } |
|
4500 | 4723 | |
4501 | 4724 | echo ' |
4502 | 4725 | <h3 id="current_tab_div">', $txt['upgrade_current_table'], ' "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
4503 | 4726 | <br><span id="commess" style="font-weight: bold; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">', $txt['upgrade_json_completed'], '</span>'; |
4504 | 4727 | |
4505 | 4728 | // Try to make sure substep was reset. |
4506 | - if ($upcontext['cur_table_num'] == $upcontext['table_count']) |
|
4507 | - echo ' |
|
4729 | + if ($upcontext['cur_table_num'] == $upcontext['table_count']) { |
|
4730 | + echo ' |
|
4508 | 4731 | <input type="hidden" name="substep" id="substep" value="0">'; |
4732 | + } |
|
4509 | 4733 | |
4510 | 4734 | // Continue please! |
4511 | 4735 | $upcontext['continue'] = $support_js ? 2 : 1; |
@@ -4538,12 +4762,13 @@ discard block |
||
4538 | 4762 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
4539 | 4763 | |
4540 | 4764 | // If debug flood the screen. |
4541 | - if ($is_debug) |
|
4542 | - echo ' |
|
4765 | + if ($is_debug) { |
|
4766 | + echo ' |
|
4543 | 4767 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>', $txt['upgrade_completed_table'], ' "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
4544 | 4768 | |
4545 | 4769 | if (document.getElementById(\'debug_section\').scrollHeight) |
4546 | 4770 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
4771 | + } |
|
4547 | 4772 | |
4548 | 4773 | echo ' |
4549 | 4774 | // Get the next update... |
@@ -4579,8 +4804,8 @@ discard block |
||
4579 | 4804 | <h3>', $txt['upgrade_done'], ' <a href="', $boardurl, '/index.php">', $txt['upgrade_done2'], '</a>. ', $txt['upgrade_done3'], '</h3> |
4580 | 4805 | <form action="', $boardurl, '/index.php">'; |
4581 | 4806 | |
4582 | - if (!empty($upcontext['can_delete_script'])) |
|
4583 | - echo ' |
|
4807 | + if (!empty($upcontext['can_delete_script'])) { |
|
4808 | + echo ' |
|
4584 | 4809 | <label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete(this);"> ', $txt['upgrade_delete_now'], '</label> ', $txt['upgrade_delete_server'], ' |
4585 | 4810 | <script> |
4586 | 4811 | function doTheDelete(theCheck) |
@@ -4592,6 +4817,7 @@ discard block |
||
4592 | 4817 | } |
4593 | 4818 | </script> |
4594 | 4819 | <img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>'; |
4820 | + } |
|
4595 | 4821 | |
4596 | 4822 | $active = time() - $upcontext['started']; |
4597 | 4823 | $hours = floor($active / 3600); |
@@ -4601,16 +4827,20 @@ discard block |
||
4601 | 4827 | if ($is_debug) |
4602 | 4828 | { |
4603 | 4829 | $totalTime = ''; |
4604 | - if ($hours > 0) |
|
4605 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4606 | - if ($minutes > 0) |
|
4607 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4608 | - if ($seconds > 0) |
|
4609 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4830 | + if ($hours > 0) { |
|
4831 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4832 | + } |
|
4833 | + if ($minutes > 0) { |
|
4834 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4835 | + } |
|
4836 | + if ($seconds > 0) { |
|
4837 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4838 | + } |
|
4610 | 4839 | } |
4611 | 4840 | |
4612 | - if ($is_debug && !empty($totalTime)) |
|
4613 | - echo '<br> ', $txt['upgrade_completed_time'], ' ', $totalTime, '<br><br>'; |
|
4841 | + if ($is_debug && !empty($totalTime)) { |
|
4842 | + echo '<br> ', $txt['upgrade_completed_time'], ' ', $totalTime, '<br><br>'; |
|
4843 | + } |
|
4614 | 4844 | |
4615 | 4845 | echo '<br> |
4616 | 4846 | ', $txt['upgrade_problems'], '<br> |
@@ -4637,8 +4867,9 @@ discard block |
||
4637 | 4867 | |
4638 | 4868 | $current_substep = $_GET['substep']; |
4639 | 4869 | |
4640 | - if (empty($_GET['a'])) |
|
4641 | - $_GET['a'] = 0; |
|
4870 | + if (empty($_GET['a'])) { |
|
4871 | + $_GET['a'] = 0; |
|
4872 | + } |
|
4642 | 4873 | $step_progress['name'] = 'Converting ips'; |
4643 | 4874 | $step_progress['current'] = $_GET['a']; |
4644 | 4875 | |
@@ -4681,16 +4912,19 @@ discard block |
||
4681 | 4912 | 'empty' => '', |
4682 | 4913 | 'limit' => $limit, |
4683 | 4914 | )); |
4684 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
4685 | - $arIp[] = $row[$oldCol]; |
|
4915 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
4916 | + $arIp[] = $row[$oldCol]; |
|
4917 | + } |
|
4686 | 4918 | $smcFunc['db_free_result']($request); |
4687 | 4919 | |
4688 | 4920 | // Special case, null ip could keep us in a loop. |
4689 | - if (is_null($arIp[0])) |
|
4690 | - unset($arIp[0]); |
|
4921 | + if (is_null($arIp[0])) { |
|
4922 | + unset($arIp[0]); |
|
4923 | + } |
|
4691 | 4924 | |
4692 | - if (empty($arIp)) |
|
4693 | - $is_done = true; |
|
4925 | + if (empty($arIp)) { |
|
4926 | + $is_done = true; |
|
4927 | + } |
|
4694 | 4928 | |
4695 | 4929 | $updates = array(); |
4696 | 4930 | $cases = array(); |
@@ -4699,16 +4933,18 @@ discard block |
||
4699 | 4933 | { |
4700 | 4934 | $arIp[$i] = trim($arIp[$i]); |
4701 | 4935 | |
4702 | - if (empty($arIp[$i])) |
|
4703 | - continue; |
|
4936 | + if (empty($arIp[$i])) { |
|
4937 | + continue; |
|
4938 | + } |
|
4704 | 4939 | |
4705 | 4940 | $updates['ip' . $i] = $arIp[$i]; |
4706 | 4941 | $cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}'; |
4707 | 4942 | |
4708 | 4943 | if ($setSize > 0 && $i % $setSize === 0) |
4709 | 4944 | { |
4710 | - if (count($updates) == 1) |
|
4711 | - continue; |
|
4945 | + if (count($updates) == 1) { |
|
4946 | + continue; |
|
4947 | + } |
|
4712 | 4948 | |
4713 | 4949 | $updates['whereSet'] = array_values($updates); |
4714 | 4950 | $smcFunc['db_query']('', ' |
@@ -4742,8 +4978,7 @@ discard block |
||
4742 | 4978 | 'ip' => $ip |
4743 | 4979 | )); |
4744 | 4980 | } |
4745 | - } |
|
4746 | - else |
|
4981 | + } else |
|
4747 | 4982 | { |
4748 | 4983 | $updates['whereSet'] = array_values($updates); |
4749 | 4984 | $smcFunc['db_query']('', ' |
@@ -4757,9 +4992,9 @@ discard block |
||
4757 | 4992 | $updates |
4758 | 4993 | ); |
4759 | 4994 | } |
4995 | + } else { |
|
4996 | + $is_done = true; |
|
4760 | 4997 | } |
4761 | - else |
|
4762 | - $is_done = true; |
|
4763 | 4998 | |
4764 | 4999 | $_GET['a'] += $limit; |
4765 | 5000 | $step_progress['current'] = $_GET['a']; |
@@ -4785,10 +5020,11 @@ discard block |
||
4785 | 5020 | |
4786 | 5021 | $columns = $smcFunc['db_list_columns']($targetTable, true); |
4787 | 5022 | |
4788 | - if (isset($columns[$column])) |
|
4789 | - return $columns[$column]; |
|
4790 | - else |
|
4791 | - return null; |
|
4792 | -} |
|
5023 | + if (isset($columns[$column])) { |
|
5024 | + return $columns[$column]; |
|
5025 | + } else { |
|
5026 | + return null; |
|
5027 | + } |
|
5028 | + } |
|
4793 | 5029 | |
4794 | 5030 | ?> |
4795 | 5031 | \ No newline at end of file |