@@ -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! |
@@ -415,8 +439,9 @@ discard block |
||
| 415 | 439 | global $upgradeurl, $upcontext, $command_line; |
| 416 | 440 | |
| 417 | 441 | // Command line users can't be redirected. |
| 418 | - if ($command_line) |
|
| 419 | - upgradeExit(true); |
|
| 442 | + if ($command_line) { |
|
| 443 | + upgradeExit(true); |
|
| 444 | + } |
|
| 420 | 445 | |
| 421 | 446 | // Are we providing the core info? |
| 422 | 447 | if ($addForm) |
@@ -442,12 +467,14 @@ discard block |
||
| 442 | 467 | define('SMF', 1); |
| 443 | 468 | |
| 444 | 469 | // Start the session. |
| 445 | - if (@ini_get('session.save_handler') == 'user') |
|
| 446 | - @ini_set('session.save_handler', 'files'); |
|
| 470 | + if (@ini_get('session.save_handler') == 'user') { |
|
| 471 | + @ini_set('session.save_handler', 'files'); |
|
| 472 | + } |
|
| 447 | 473 | @session_start(); |
| 448 | 474 | |
| 449 | - if (empty($smcFunc)) |
|
| 450 | - $smcFunc = array(); |
|
| 475 | + if (empty($smcFunc)) { |
|
| 476 | + $smcFunc = array(); |
|
| 477 | + } |
|
| 451 | 478 | |
| 452 | 479 | // We need this for authentication and some upgrade code |
| 453 | 480 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -474,24 +501,27 @@ discard block |
||
| 474 | 501 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
| 475 | 502 | |
| 476 | 503 | // Make the connection... |
| 477 | - if (empty($db_connection)) |
|
| 478 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
|
| 479 | - else |
|
| 480 | - // If we've returned here, ping/reconnect to be safe |
|
| 504 | + if (empty($db_connection)) { |
|
| 505 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
|
| 506 | + } else { |
|
| 507 | + // If we've returned here, ping/reconnect to be safe |
|
| 481 | 508 | $smcFunc['db_ping']($db_connection); |
| 509 | + } |
|
| 482 | 510 | |
| 483 | 511 | // Oh dear god!! |
| 484 | - if ($db_connection === null) |
|
| 485 | - die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
| 512 | + if ($db_connection === null) { |
|
| 513 | + die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
| 514 | + } |
|
| 486 | 515 | |
| 487 | - if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) |
|
| 488 | - $smcFunc['db_query']('', ' |
|
| 516 | + if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) { |
|
| 517 | + $smcFunc['db_query']('', ' |
|
| 489 | 518 | SET NAMES {string:db_character_set}', |
| 490 | 519 | array( |
| 491 | 520 | 'db_error_skip' => true, |
| 492 | 521 | 'db_character_set' => $db_character_set, |
| 493 | 522 | ) |
| 494 | 523 | ); |
| 524 | + } |
|
| 495 | 525 | |
| 496 | 526 | // Load the modSettings data... |
| 497 | 527 | $request = $smcFunc['db_query']('', ' |
@@ -502,11 +532,11 @@ discard block |
||
| 502 | 532 | ) |
| 503 | 533 | ); |
| 504 | 534 | $modSettings = array(); |
| 505 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 506 | - $modSettings[$row['variable']] = $row['value']; |
|
| 535 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 536 | + $modSettings[$row['variable']] = $row['value']; |
|
| 537 | + } |
|
| 507 | 538 | $smcFunc['db_free_result']($request); |
| 508 | - } |
|
| 509 | - else |
|
| 539 | + } else |
|
| 510 | 540 | { |
| 511 | 541 | 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.'); |
| 512 | 542 | } |
@@ -520,9 +550,10 @@ discard block |
||
| 520 | 550 | cleanRequest(); |
| 521 | 551 | } |
| 522 | 552 | |
| 523 | - if (!isset($_GET['substep'])) |
|
| 524 | - $_GET['substep'] = 0; |
|
| 525 | -} |
|
| 553 | + if (!isset($_GET['substep'])) { |
|
| 554 | + $_GET['substep'] = 0; |
|
| 555 | + } |
|
| 556 | + } |
|
| 526 | 557 | |
| 527 | 558 | function initialize_inputs() |
| 528 | 559 | { |
@@ -552,8 +583,9 @@ discard block |
||
| 552 | 583 | $dh = opendir(dirname(__FILE__)); |
| 553 | 584 | while ($file = readdir($dh)) |
| 554 | 585 | { |
| 555 | - if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) |
|
| 556 | - @unlink(dirname(__FILE__) . '/' . $file); |
|
| 586 | + if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) { |
|
| 587 | + @unlink(dirname(__FILE__) . '/' . $file); |
|
| 588 | + } |
|
| 557 | 589 | } |
| 558 | 590 | closedir($dh); |
| 559 | 591 | |
@@ -582,8 +614,9 @@ discard block |
||
| 582 | 614 | $temp = 'upgrade_php?step'; |
| 583 | 615 | while (strlen($temp) > 4) |
| 584 | 616 | { |
| 585 | - if (isset($_GET[$temp])) |
|
| 586 | - unset($_GET[$temp]); |
|
| 617 | + if (isset($_GET[$temp])) { |
|
| 618 | + unset($_GET[$temp]); |
|
| 619 | + } |
|
| 587 | 620 | $temp = substr($temp, 1); |
| 588 | 621 | } |
| 589 | 622 | |
@@ -610,32 +643,39 @@ discard block |
||
| 610 | 643 | && @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $db_type . '.sql'); |
| 611 | 644 | |
| 612 | 645 | // Need legacy scripts? |
| 613 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) |
|
| 614 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
| 615 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) |
|
| 616 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
| 617 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) |
|
| 618 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
| 646 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) { |
|
| 647 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
| 648 | + } |
|
| 649 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) { |
|
| 650 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
| 651 | + } |
|
| 652 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) { |
|
| 653 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
| 654 | + } |
|
| 619 | 655 | |
| 620 | 656 | // We don't need "-utf8" files anymore... |
| 621 | 657 | $upcontext['language'] = str_ireplace('-utf8', '', $upcontext['language']); |
| 622 | 658 | |
| 623 | 659 | // This needs to exist! |
| 624 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 625 | - 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>]'); |
|
| 626 | - else |
|
| 627 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 660 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 661 | + 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>]'); |
|
| 662 | + } else { |
|
| 663 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 664 | + } |
|
| 628 | 665 | |
| 629 | - if (!$check) |
|
| 630 | - // 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. |
|
| 666 | + if (!$check) { |
|
| 667 | + // 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. |
|
| 631 | 668 | 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.'); |
| 669 | + } |
|
| 632 | 670 | |
| 633 | 671 | // Do they meet the install requirements? |
| 634 | - if (!php_version_check()) |
|
| 635 | - 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.'); |
|
| 672 | + if (!php_version_check()) { |
|
| 673 | + 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.'); |
|
| 674 | + } |
|
| 636 | 675 | |
| 637 | - if (!db_version_check()) |
|
| 638 | - 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.'); |
|
| 676 | + if (!db_version_check()) { |
|
| 677 | + 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.'); |
|
| 678 | + } |
|
| 639 | 679 | |
| 640 | 680 | // Do some checks to make sure they have proper privileges |
| 641 | 681 | db_extend('packages'); |
@@ -650,14 +690,16 @@ discard block |
||
| 650 | 690 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
| 651 | 691 | |
| 652 | 692 | // Sorry... we need CREATE, ALTER and DROP |
| 653 | - if (!$create || !$alter || !$drop) |
|
| 654 | - 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.'); |
|
| 693 | + if (!$create || !$alter || !$drop) { |
|
| 694 | + 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.'); |
|
| 695 | + } |
|
| 655 | 696 | |
| 656 | 697 | // Do a quick version spot check. |
| 657 | 698 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
| 658 | 699 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
| 659 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
| 660 | - 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.'); |
|
| 700 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
| 701 | + 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.'); |
|
| 702 | + } |
|
| 661 | 703 | |
| 662 | 704 | // What absolutely needs to be writable? |
| 663 | 705 | $writable_files = array( |
@@ -679,12 +721,13 @@ discard block |
||
| 679 | 721 | quickFileWritable($custom_av_dir); |
| 680 | 722 | |
| 681 | 723 | // Are we good now? |
| 682 | - if (!is_writable($custom_av_dir)) |
|
| 683 | - 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)); |
|
| 684 | - elseif ($need_settings_update) |
|
| 724 | + if (!is_writable($custom_av_dir)) { |
|
| 725 | + 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)); |
|
| 726 | + } elseif ($need_settings_update) |
|
| 685 | 727 | { |
| 686 | - if (!function_exists('cache_put_data')) |
|
| 687 | - require_once($sourcedir . '/Load.php'); |
|
| 728 | + if (!function_exists('cache_put_data')) { |
|
| 729 | + require_once($sourcedir . '/Load.php'); |
|
| 730 | + } |
|
| 688 | 731 | updateSettings(array('custom_avatar_dir' => $custom_av_dir)); |
| 689 | 732 | updateSettings(array('custom_avatar_url' => $custom_av_url)); |
| 690 | 733 | } |
@@ -693,28 +736,33 @@ discard block |
||
| 693 | 736 | |
| 694 | 737 | // Check the cache directory. |
| 695 | 738 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
| 696 | - if (!file_exists($cachedir_temp)) |
|
| 697 | - @mkdir($cachedir_temp); |
|
| 698 | - if (!file_exists($cachedir_temp)) |
|
| 699 | - 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.'); |
|
| 700 | - |
|
| 701 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
| 702 | - 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>.'); |
|
| 703 | - elseif (!isset($_GET['skiplang'])) |
|
| 739 | + if (!file_exists($cachedir_temp)) { |
|
| 740 | + @mkdir($cachedir_temp); |
|
| 741 | + } |
|
| 742 | + if (!file_exists($cachedir_temp)) { |
|
| 743 | + 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.'); |
|
| 744 | + } |
|
| 745 | + |
|
| 746 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
| 747 | + 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>.'); |
|
| 748 | + } elseif (!isset($_GET['skiplang'])) |
|
| 704 | 749 | { |
| 705 | 750 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
| 706 | 751 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 707 | 752 | |
| 708 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 709 | - 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>]'); |
|
| 753 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 754 | + 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>]'); |
|
| 755 | + } |
|
| 710 | 756 | } |
| 711 | 757 | |
| 712 | - if (!makeFilesWritable($writable_files)) |
|
| 713 | - return false; |
|
| 758 | + if (!makeFilesWritable($writable_files)) { |
|
| 759 | + return false; |
|
| 760 | + } |
|
| 714 | 761 | |
| 715 | 762 | // Check agreement.txt. (it may not exist, in which case $boarddir must be writable.) |
| 716 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
| 717 | - 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.'); |
|
| 763 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
| 764 | + 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.'); |
|
| 765 | + } |
|
| 718 | 766 | |
| 719 | 767 | // Upgrade the agreement. |
| 720 | 768 | elseif (isset($modSettings['agreement'])) |
@@ -725,8 +773,8 @@ discard block |
||
| 725 | 773 | } |
| 726 | 774 | |
| 727 | 775 | // We're going to check that their board dir setting is right in case they've been moving stuff around. |
| 728 | - if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) |
|
| 729 | - $upcontext['warning'] = ' |
|
| 776 | + if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) { |
|
| 777 | + $upcontext['warning'] = ' |
|
| 730 | 778 | 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> |
| 731 | 779 | <ul> |
| 732 | 780 | <li>Board Directory: ' . $boarddir . '</li> |
@@ -734,19 +782,23 @@ discard block |
||
| 734 | 782 | <li>Cache Directory: ' . $cachedir_temp . '</li> |
| 735 | 783 | </ul> |
| 736 | 784 | 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.'; |
| 785 | + } |
|
| 737 | 786 | |
| 738 | 787 | // Confirm mbstring is loaded... |
| 739 | - if (!extension_loaded('mbstring')) |
|
| 740 | - return throw_error($txt['install_no_mbstring']); |
|
| 788 | + if (!extension_loaded('mbstring')) { |
|
| 789 | + return throw_error($txt['install_no_mbstring']); |
|
| 790 | + } |
|
| 741 | 791 | |
| 742 | 792 | // Check for https stream support. |
| 743 | 793 | $supported_streams = stream_get_wrappers(); |
| 744 | - if (!in_array('https', $supported_streams)) |
|
| 745 | - $upcontext['custom_warning'] = $txt['install_no_https']; |
|
| 794 | + if (!in_array('https', $supported_streams)) { |
|
| 795 | + $upcontext['custom_warning'] = $txt['install_no_https']; |
|
| 796 | + } |
|
| 746 | 797 | |
| 747 | 798 | // Either we're logged in or we're going to present the login. |
| 748 | - if (checkLogin()) |
|
| 749 | - return true; |
|
| 799 | + if (checkLogin()) { |
|
| 800 | + return true; |
|
| 801 | + } |
|
| 750 | 802 | |
| 751 | 803 | $upcontext += createToken('login'); |
| 752 | 804 | |
@@ -760,15 +812,17 @@ discard block |
||
| 760 | 812 | global $smcFunc, $db_type, $support_js; |
| 761 | 813 | |
| 762 | 814 | // Don't bother if the security is disabled. |
| 763 | - if ($disable_security) |
|
| 764 | - return true; |
|
| 815 | + if ($disable_security) { |
|
| 816 | + return true; |
|
| 817 | + } |
|
| 765 | 818 | |
| 766 | 819 | // Are we trying to login? |
| 767 | 820 | if (isset($_POST['contbutt']) && (!empty($_POST['user']))) |
| 768 | 821 | { |
| 769 | 822 | // If we've disabled security pick a suitable name! |
| 770 | - if (empty($_POST['user'])) |
|
| 771 | - $_POST['user'] = 'Administrator'; |
|
| 823 | + if (empty($_POST['user'])) { |
|
| 824 | + $_POST['user'] = 'Administrator'; |
|
| 825 | + } |
|
| 772 | 826 | |
| 773 | 827 | // Before 2.0 these column names were different! |
| 774 | 828 | $oldDB = false; |
@@ -783,16 +837,17 @@ discard block |
||
| 783 | 837 | 'db_error_skip' => true, |
| 784 | 838 | ) |
| 785 | 839 | ); |
| 786 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 787 | - $oldDB = true; |
|
| 840 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 841 | + $oldDB = true; |
|
| 842 | + } |
|
| 788 | 843 | $smcFunc['db_free_result']($request); |
| 789 | 844 | } |
| 790 | 845 | |
| 791 | 846 | // Get what we believe to be their details. |
| 792 | 847 | if (!$disable_security) |
| 793 | 848 | { |
| 794 | - if ($oldDB) |
|
| 795 | - $request = $smcFunc['db_query']('', ' |
|
| 849 | + if ($oldDB) { |
|
| 850 | + $request = $smcFunc['db_query']('', ' |
|
| 796 | 851 | SELECT id_member, memberName AS member_name, passwd, id_group, |
| 797 | 852 | additionalGroups AS additional_groups, lngfile |
| 798 | 853 | FROM {db_prefix}members |
@@ -802,8 +857,8 @@ discard block |
||
| 802 | 857 | 'db_error_skip' => true, |
| 803 | 858 | ) |
| 804 | 859 | ); |
| 805 | - else |
|
| 806 | - $request = $smcFunc['db_query']('', ' |
|
| 860 | + } else { |
|
| 861 | + $request = $smcFunc['db_query']('', ' |
|
| 807 | 862 | SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile |
| 808 | 863 | FROM {db_prefix}members |
| 809 | 864 | WHERE member_name = {string:member_name}', |
@@ -812,6 +867,7 @@ discard block |
||
| 812 | 867 | 'db_error_skip' => true, |
| 813 | 868 | ) |
| 814 | 869 | ); |
| 870 | + } |
|
| 815 | 871 | if ($smcFunc['db_num_rows']($request) != 0) |
| 816 | 872 | { |
| 817 | 873 | list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request); |
@@ -819,16 +875,17 @@ discard block |
||
| 819 | 875 | $groups = explode(',', $addGroups); |
| 820 | 876 | $groups[] = $id_group; |
| 821 | 877 | |
| 822 | - foreach ($groups as $k => $v) |
|
| 823 | - $groups[$k] = (int) $v; |
|
| 878 | + foreach ($groups as $k => $v) { |
|
| 879 | + $groups[$k] = (int) $v; |
|
| 880 | + } |
|
| 824 | 881 | |
| 825 | 882 | $sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd'])); |
| 826 | 883 | |
| 827 | 884 | // We don't use "-utf8" anymore... |
| 828 | 885 | $user_language = str_ireplace('-utf8', '', $user_language); |
| 886 | + } else { |
|
| 887 | + $upcontext['username_incorrect'] = true; |
|
| 829 | 888 | } |
| 830 | - else |
|
| 831 | - $upcontext['username_incorrect'] = true; |
|
| 832 | 889 | $smcFunc['db_free_result']($request); |
| 833 | 890 | } |
| 834 | 891 | $upcontext['username'] = $_POST['user']; |
@@ -838,13 +895,14 @@ discard block |
||
| 838 | 895 | { |
| 839 | 896 | $upcontext['upgrade_status']['js'] = 1; |
| 840 | 897 | $support_js = 1; |
| 898 | + } else { |
|
| 899 | + $support_js = 0; |
|
| 841 | 900 | } |
| 842 | - else |
|
| 843 | - $support_js = 0; |
|
| 844 | 901 | |
| 845 | 902 | // Note down the version we are coming from. |
| 846 | - if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) |
|
| 847 | - $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
| 903 | + if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) { |
|
| 904 | + $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
| 905 | + } |
|
| 848 | 906 | |
| 849 | 907 | // Didn't get anywhere? |
| 850 | 908 | 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'])) |
@@ -878,15 +936,15 @@ discard block |
||
| 878 | 936 | 'db_error_skip' => true, |
| 879 | 937 | ) |
| 880 | 938 | ); |
| 881 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 882 | - return throw_error('You need to be an admin to perform an upgrade!'); |
|
| 939 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 940 | + return throw_error('You need to be an admin to perform an upgrade!'); |
|
| 941 | + } |
|
| 883 | 942 | $smcFunc['db_free_result']($request); |
| 884 | 943 | } |
| 885 | 944 | |
| 886 | 945 | $upcontext['user']['id'] = $id_member; |
| 887 | 946 | $upcontext['user']['name'] = $name; |
| 888 | - } |
|
| 889 | - else |
|
| 947 | + } else |
|
| 890 | 948 | { |
| 891 | 949 | $upcontext['user']['id'] = 1; |
| 892 | 950 | $upcontext['user']['name'] = 'Administrator'; |
@@ -902,11 +960,11 @@ discard block |
||
| 902 | 960 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096); |
| 903 | 961 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 904 | 962 | |
| 905 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 906 | - $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'] . '.'; |
|
| 907 | - elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) |
|
| 908 | - $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'] . '.'; |
|
| 909 | - else |
|
| 963 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 964 | + $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'] . '.'; |
|
| 965 | + } elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) { |
|
| 966 | + $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'] . '.'; |
|
| 967 | + } else |
|
| 910 | 968 | { |
| 911 | 969 | // Set this as the new language. |
| 912 | 970 | $upcontext['language'] = $user_language; |
@@ -950,8 +1008,9 @@ discard block |
||
| 950 | 1008 | unset($member_columns); |
| 951 | 1009 | |
| 952 | 1010 | // If we've not submitted then we're done. |
| 953 | - if (empty($_POST['upcont'])) |
|
| 954 | - return false; |
|
| 1011 | + if (empty($_POST['upcont'])) { |
|
| 1012 | + return false; |
|
| 1013 | + } |
|
| 955 | 1014 | |
| 956 | 1015 | // Firstly, if they're enabling SM stat collection just do it. |
| 957 | 1016 | if (!empty($_POST['stats']) && substr($boardurl, 0, 16) != 'http://localhost' && empty($modSettings['allow_sm_stats']) && empty($modSettings['enable_sm_stats'])) |
@@ -971,16 +1030,17 @@ discard block |
||
| 971 | 1030 | fwrite($fp, $out); |
| 972 | 1031 | |
| 973 | 1032 | $return_data = ''; |
| 974 | - while (!feof($fp)) |
|
| 975 | - $return_data .= fgets($fp, 128); |
|
| 1033 | + while (!feof($fp)) { |
|
| 1034 | + $return_data .= fgets($fp, 128); |
|
| 1035 | + } |
|
| 976 | 1036 | |
| 977 | 1037 | fclose($fp); |
| 978 | 1038 | |
| 979 | 1039 | // Get the unique site ID. |
| 980 | 1040 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
| 981 | 1041 | |
| 982 | - if (!empty($ID[1])) |
|
| 983 | - $smcFunc['db_insert']('replace', |
|
| 1042 | + if (!empty($ID[1])) { |
|
| 1043 | + $smcFunc['db_insert']('replace', |
|
| 984 | 1044 | $db_prefix . 'settings', |
| 985 | 1045 | array('variable' => 'string', 'value' => 'string'), |
| 986 | 1046 | array( |
@@ -989,9 +1049,9 @@ discard block |
||
| 989 | 1049 | ), |
| 990 | 1050 | array('variable') |
| 991 | 1051 | ); |
| 1052 | + } |
|
| 992 | 1053 | } |
| 993 | - } |
|
| 994 | - else |
|
| 1054 | + } else |
|
| 995 | 1055 | { |
| 996 | 1056 | $smcFunc['db_insert']('replace', |
| 997 | 1057 | $db_prefix . 'settings', |
@@ -1002,8 +1062,8 @@ discard block |
||
| 1002 | 1062 | } |
| 1003 | 1063 | } |
| 1004 | 1064 | // Don't remove stat collection unless we unchecked the box for real, not from the loop. |
| 1005 | - elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) |
|
| 1006 | - $smcFunc['db_query']('', ' |
|
| 1065 | + elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) { |
|
| 1066 | + $smcFunc['db_query']('', ' |
|
| 1007 | 1067 | DELETE FROM {db_prefix}settings |
| 1008 | 1068 | WHERE variable = {string:enable_sm_stats}', |
| 1009 | 1069 | array( |
@@ -1011,6 +1071,7 @@ discard block |
||
| 1011 | 1071 | 'db_error_skip' => true, |
| 1012 | 1072 | ) |
| 1013 | 1073 | ); |
| 1074 | + } |
|
| 1014 | 1075 | |
| 1015 | 1076 | // Deleting old karma stuff? |
| 1016 | 1077 | if (!empty($_POST['delete_karma'])) |
@@ -1025,20 +1086,22 @@ discard block |
||
| 1025 | 1086 | ); |
| 1026 | 1087 | |
| 1027 | 1088 | // Cleaning up old karma member settings. |
| 1028 | - if ($upcontext['karma_installed']['good']) |
|
| 1029 | - $smcFunc['db_query']('', ' |
|
| 1089 | + if ($upcontext['karma_installed']['good']) { |
|
| 1090 | + $smcFunc['db_query']('', ' |
|
| 1030 | 1091 | ALTER TABLE {db_prefix}members |
| 1031 | 1092 | DROP karma_good', |
| 1032 | 1093 | array() |
| 1033 | 1094 | ); |
| 1095 | + } |
|
| 1034 | 1096 | |
| 1035 | 1097 | // Does karma bad was enable? |
| 1036 | - if ($upcontext['karma_installed']['bad']) |
|
| 1037 | - $smcFunc['db_query']('', ' |
|
| 1098 | + if ($upcontext['karma_installed']['bad']) { |
|
| 1099 | + $smcFunc['db_query']('', ' |
|
| 1038 | 1100 | ALTER TABLE {db_prefix}members |
| 1039 | 1101 | DROP karma_bad', |
| 1040 | 1102 | array() |
| 1041 | 1103 | ); |
| 1104 | + } |
|
| 1042 | 1105 | |
| 1043 | 1106 | // Cleaning up old karma permissions. |
| 1044 | 1107 | $smcFunc['db_query']('', ' |
@@ -1056,32 +1119,37 @@ discard block |
||
| 1056 | 1119 | } |
| 1057 | 1120 | |
| 1058 | 1121 | // Emptying the error log? |
| 1059 | - if (!empty($_POST['empty_error'])) |
|
| 1060 | - $smcFunc['db_query']('truncate_table', ' |
|
| 1122 | + if (!empty($_POST['empty_error'])) { |
|
| 1123 | + $smcFunc['db_query']('truncate_table', ' |
|
| 1061 | 1124 | TRUNCATE {db_prefix}log_errors', |
| 1062 | 1125 | array( |
| 1063 | 1126 | ) |
| 1064 | 1127 | ); |
| 1128 | + } |
|
| 1065 | 1129 | |
| 1066 | 1130 | $changes = array(); |
| 1067 | 1131 | |
| 1068 | 1132 | // Add proxy settings. |
| 1069 | - if (!isset($GLOBALS['image_proxy_maxsize'])) |
|
| 1070 | - $changes += array( |
|
| 1133 | + if (!isset($GLOBALS['image_proxy_maxsize'])) { |
|
| 1134 | + $changes += array( |
|
| 1071 | 1135 | 'image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'', |
| 1072 | 1136 | 'image_proxy_maxsize' => 5190, |
| 1073 | 1137 | 'image_proxy_enabled' => 0, |
| 1074 | 1138 | ); |
| 1139 | + } |
|
| 1075 | 1140 | |
| 1076 | 1141 | // If $boardurl reflects https, set force_ssl |
| 1077 | - if (!function_exists('cache_put_data')) |
|
| 1078 | - require_once($sourcedir . '/Load.php'); |
|
| 1079 | - if (stripos($boardurl, 'https://') !== false) |
|
| 1080 | - updateSettings(array('force_ssl' => '2')); |
|
| 1142 | + if (!function_exists('cache_put_data')) { |
|
| 1143 | + require_once($sourcedir . '/Load.php'); |
|
| 1144 | + } |
|
| 1145 | + if (stripos($boardurl, 'https://') !== false) { |
|
| 1146 | + updateSettings(array('force_ssl' => '2')); |
|
| 1147 | + } |
|
| 1081 | 1148 | |
| 1082 | 1149 | // If we're overriding the language follow it through. |
| 1083 | - if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) |
|
| 1084 | - $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
| 1150 | + if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) { |
|
| 1151 | + $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
| 1152 | + } |
|
| 1085 | 1153 | |
| 1086 | 1154 | if (!empty($_POST['maint'])) |
| 1087 | 1155 | { |
@@ -1093,26 +1161,29 @@ discard block |
||
| 1093 | 1161 | { |
| 1094 | 1162 | $changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\''; |
| 1095 | 1163 | $changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\''; |
| 1096 | - } |
|
| 1097 | - else |
|
| 1164 | + } else |
|
| 1098 | 1165 | { |
| 1099 | 1166 | $changes['mtitle'] = '\'Upgrading the forum...\''; |
| 1100 | 1167 | $changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum. It will only be a minute ;).\''; |
| 1101 | 1168 | } |
| 1102 | 1169 | } |
| 1103 | 1170 | |
| 1104 | - if ($command_line) |
|
| 1105 | - echo ' * Updating Settings.php...'; |
|
| 1171 | + if ($command_line) { |
|
| 1172 | + echo ' * Updating Settings.php...'; |
|
| 1173 | + } |
|
| 1106 | 1174 | |
| 1107 | 1175 | // Fix some old paths. |
| 1108 | - if (substr($boarddir, 0, 1) == '.') |
|
| 1109 | - $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
| 1176 | + if (substr($boarddir, 0, 1) == '.') { |
|
| 1177 | + $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
| 1178 | + } |
|
| 1110 | 1179 | |
| 1111 | - if (substr($sourcedir, 0, 1) == '.') |
|
| 1112 | - $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
| 1180 | + if (substr($sourcedir, 0, 1) == '.') { |
|
| 1181 | + $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
| 1182 | + } |
|
| 1113 | 1183 | |
| 1114 | - if (empty($cachedir) || substr($cachedir, 0, 1) == '.') |
|
| 1115 | - $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
| 1184 | + if (empty($cachedir) || substr($cachedir, 0, 1) == '.') { |
|
| 1185 | + $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
| 1186 | + } |
|
| 1116 | 1187 | |
| 1117 | 1188 | // If they have a "host:port" setup for the host, split that into separate values |
| 1118 | 1189 | // You should never have a : in the hostname if you're not on MySQL, but better safe than sorry |
@@ -1123,32 +1194,36 @@ discard block |
||
| 1123 | 1194 | $changes['db_server'] = '\'' . $db_server . '\''; |
| 1124 | 1195 | |
| 1125 | 1196 | // Only set this if we're not using the default port |
| 1126 | - if ($db_port != ini_get('mysqli.default_port')) |
|
| 1127 | - $changes['db_port'] = (int) $db_port; |
|
| 1128 | - } |
|
| 1129 | - elseif (!empty($db_port)) |
|
| 1197 | + if ($db_port != ini_get('mysqli.default_port')) { |
|
| 1198 | + $changes['db_port'] = (int) $db_port; |
|
| 1199 | + } |
|
| 1200 | + } elseif (!empty($db_port)) |
|
| 1130 | 1201 | { |
| 1131 | 1202 | // If db_port is set and is the same as the default, set it to '' |
| 1132 | 1203 | if ($db_type == 'mysql') |
| 1133 | 1204 | { |
| 1134 | - if ($db_port == ini_get('mysqli.default_port')) |
|
| 1135 | - $changes['db_port'] = '\'\''; |
|
| 1136 | - elseif ($db_type == 'postgresql' && $db_port == 5432) |
|
| 1137 | - $changes['db_port'] = '\'\''; |
|
| 1205 | + if ($db_port == ini_get('mysqli.default_port')) { |
|
| 1206 | + $changes['db_port'] = '\'\''; |
|
| 1207 | + } elseif ($db_type == 'postgresql' && $db_port == 5432) { |
|
| 1208 | + $changes['db_port'] = '\'\''; |
|
| 1209 | + } |
|
| 1138 | 1210 | } |
| 1139 | 1211 | } |
| 1140 | 1212 | |
| 1141 | 1213 | // Maybe we haven't had this option yet? |
| 1142 | - if (empty($packagesdir)) |
|
| 1143 | - $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
| 1214 | + if (empty($packagesdir)) { |
|
| 1215 | + $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
| 1216 | + } |
|
| 1144 | 1217 | |
| 1145 | 1218 | // Add support for $tasksdir var. |
| 1146 | - if (empty($tasksdir)) |
|
| 1147 | - $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
| 1219 | + if (empty($tasksdir)) { |
|
| 1220 | + $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
| 1221 | + } |
|
| 1148 | 1222 | |
| 1149 | 1223 | // Make sure we fix the language as well. |
| 1150 | - if (stristr($language, '-utf8')) |
|
| 1151 | - $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
| 1224 | + if (stristr($language, '-utf8')) { |
|
| 1225 | + $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
| 1226 | + } |
|
| 1152 | 1227 | |
| 1153 | 1228 | // @todo Maybe change the cookie name if going to 1.1, too? |
| 1154 | 1229 | |
@@ -1156,8 +1231,9 @@ discard block |
||
| 1156 | 1231 | require_once($sourcedir . '/Subs-Admin.php'); |
| 1157 | 1232 | updateSettingsFile($changes); |
| 1158 | 1233 | |
| 1159 | - if ($command_line) |
|
| 1160 | - echo ' Successful.' . "\n"; |
|
| 1234 | + if ($command_line) { |
|
| 1235 | + echo ' Successful.' . "\n"; |
|
| 1236 | + } |
|
| 1161 | 1237 | |
| 1162 | 1238 | // Are we doing debug? |
| 1163 | 1239 | if (isset($_POST['debug'])) |
@@ -1167,8 +1243,9 @@ discard block |
||
| 1167 | 1243 | } |
| 1168 | 1244 | |
| 1169 | 1245 | // If we're not backing up then jump one. |
| 1170 | - if (empty($_POST['backup'])) |
|
| 1171 | - $upcontext['current_step']++; |
|
| 1246 | + if (empty($_POST['backup'])) { |
|
| 1247 | + $upcontext['current_step']++; |
|
| 1248 | + } |
|
| 1172 | 1249 | |
| 1173 | 1250 | // If we've got here then let's proceed to the next step! |
| 1174 | 1251 | return true; |
@@ -1183,8 +1260,9 @@ discard block |
||
| 1183 | 1260 | $upcontext['page_title'] = 'Backup Database'; |
| 1184 | 1261 | |
| 1185 | 1262 | // Done it already - js wise? |
| 1186 | - if (!empty($_POST['backup_done'])) |
|
| 1187 | - return true; |
|
| 1263 | + if (!empty($_POST['backup_done'])) { |
|
| 1264 | + return true; |
|
| 1265 | + } |
|
| 1188 | 1266 | |
| 1189 | 1267 | // Some useful stuff here. |
| 1190 | 1268 | db_extend(); |
@@ -1198,9 +1276,10 @@ discard block |
||
| 1198 | 1276 | $tables = $smcFunc['db_list_tables']($db, $filter); |
| 1199 | 1277 | |
| 1200 | 1278 | $table_names = array(); |
| 1201 | - foreach ($tables as $table) |
|
| 1202 | - if (substr($table, 0, 7) !== 'backup_') |
|
| 1279 | + foreach ($tables as $table) { |
|
| 1280 | + if (substr($table, 0, 7) !== 'backup_') |
|
| 1203 | 1281 | $table_names[] = $table; |
| 1282 | + } |
|
| 1204 | 1283 | |
| 1205 | 1284 | $upcontext['table_count'] = count($table_names); |
| 1206 | 1285 | $upcontext['cur_table_num'] = $_GET['substep']; |
@@ -1210,12 +1289,14 @@ discard block |
||
| 1210 | 1289 | $file_steps = $upcontext['table_count']; |
| 1211 | 1290 | |
| 1212 | 1291 | // What ones have we already done? |
| 1213 | - foreach ($table_names as $id => $table) |
|
| 1214 | - if ($id < $_GET['substep']) |
|
| 1292 | + foreach ($table_names as $id => $table) { |
|
| 1293 | + if ($id < $_GET['substep']) |
|
| 1215 | 1294 | $upcontext['previous_tables'][] = $table; |
| 1295 | + } |
|
| 1216 | 1296 | |
| 1217 | - if ($command_line) |
|
| 1218 | - echo 'Backing Up Tables.'; |
|
| 1297 | + if ($command_line) { |
|
| 1298 | + echo 'Backing Up Tables.'; |
|
| 1299 | + } |
|
| 1219 | 1300 | |
| 1220 | 1301 | // If we don't support javascript we backup here. |
| 1221 | 1302 | if (!$support_js || isset($_GET['xml'])) |
@@ -1234,8 +1315,9 @@ discard block |
||
| 1234 | 1315 | backupTable($table_names[$substep]); |
| 1235 | 1316 | |
| 1236 | 1317 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 1237 | - if (isset($_GET['xml'])) |
|
| 1238 | - return upgradeExit(); |
|
| 1318 | + if (isset($_GET['xml'])) { |
|
| 1319 | + return upgradeExit(); |
|
| 1320 | + } |
|
| 1239 | 1321 | } |
| 1240 | 1322 | |
| 1241 | 1323 | if ($command_line) |
@@ -1268,9 +1350,10 @@ discard block |
||
| 1268 | 1350 | |
| 1269 | 1351 | $smcFunc['db_backup_table']($table, 'backup_' . $table); |
| 1270 | 1352 | |
| 1271 | - if ($command_line) |
|
| 1272 | - echo ' done.'; |
|
| 1273 | -} |
|
| 1353 | + if ($command_line) { |
|
| 1354 | + echo ' done.'; |
|
| 1355 | + } |
|
| 1356 | + } |
|
| 1274 | 1357 | |
| 1275 | 1358 | // Step 2: Everything. |
| 1276 | 1359 | function DatabaseChanges() |
@@ -1279,8 +1362,9 @@ discard block |
||
| 1279 | 1362 | global $upcontext, $support_js, $db_type; |
| 1280 | 1363 | |
| 1281 | 1364 | // Have we just completed this? |
| 1282 | - if (!empty($_POST['database_done'])) |
|
| 1283 | - return true; |
|
| 1365 | + if (!empty($_POST['database_done'])) { |
|
| 1366 | + return true; |
|
| 1367 | + } |
|
| 1284 | 1368 | |
| 1285 | 1369 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes'; |
| 1286 | 1370 | $upcontext['page_title'] = 'Database Changes'; |
@@ -1295,15 +1379,16 @@ discard block |
||
| 1295 | 1379 | ); |
| 1296 | 1380 | |
| 1297 | 1381 | // How many files are there in total? |
| 1298 | - if (isset($_GET['filecount'])) |
|
| 1299 | - $upcontext['file_count'] = (int) $_GET['filecount']; |
|
| 1300 | - else |
|
| 1382 | + if (isset($_GET['filecount'])) { |
|
| 1383 | + $upcontext['file_count'] = (int) $_GET['filecount']; |
|
| 1384 | + } else |
|
| 1301 | 1385 | { |
| 1302 | 1386 | $upcontext['file_count'] = 0; |
| 1303 | 1387 | foreach ($files as $file) |
| 1304 | 1388 | { |
| 1305 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) |
|
| 1306 | - $upcontext['file_count']++; |
|
| 1389 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) { |
|
| 1390 | + $upcontext['file_count']++; |
|
| 1391 | + } |
|
| 1307 | 1392 | } |
| 1308 | 1393 | } |
| 1309 | 1394 | |
@@ -1313,9 +1398,9 @@ discard block |
||
| 1313 | 1398 | $upcontext['cur_file_num'] = 0; |
| 1314 | 1399 | foreach ($files as $file) |
| 1315 | 1400 | { |
| 1316 | - if ($did_not_do) |
|
| 1317 | - $did_not_do--; |
|
| 1318 | - else |
|
| 1401 | + if ($did_not_do) { |
|
| 1402 | + $did_not_do--; |
|
| 1403 | + } else |
|
| 1319 | 1404 | { |
| 1320 | 1405 | $upcontext['cur_file_num']++; |
| 1321 | 1406 | $upcontext['cur_file_name'] = $file[0]; |
@@ -1342,12 +1427,13 @@ discard block |
||
| 1342 | 1427 | // Flag to move on to the next. |
| 1343 | 1428 | $upcontext['completed_step'] = true; |
| 1344 | 1429 | // Did we complete the whole file? |
| 1345 | - if ($nextFile) |
|
| 1346 | - $upcontext['current_debug_item_num'] = -1; |
|
| 1430 | + if ($nextFile) { |
|
| 1431 | + $upcontext['current_debug_item_num'] = -1; |
|
| 1432 | + } |
|
| 1347 | 1433 | return upgradeExit(); |
| 1434 | + } elseif ($support_js) { |
|
| 1435 | + break; |
|
| 1348 | 1436 | } |
| 1349 | - elseif ($support_js) |
|
| 1350 | - break; |
|
| 1351 | 1437 | } |
| 1352 | 1438 | // Set the progress bar to be right as if we had - even if we hadn't... |
| 1353 | 1439 | $upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100; |
@@ -1372,8 +1458,9 @@ discard block |
||
| 1372 | 1458 | global $command_line, $language, $upcontext, $sourcedir, $forum_version, $user_info, $maintenance, $smcFunc, $db_type; |
| 1373 | 1459 | |
| 1374 | 1460 | // Now it's nice to have some of the basic SMF source files. |
| 1375 | - if (!isset($_GET['ssi']) && !$command_line) |
|
| 1376 | - redirectLocation('&ssi=1'); |
|
| 1461 | + if (!isset($_GET['ssi']) && !$command_line) { |
|
| 1462 | + redirectLocation('&ssi=1'); |
|
| 1463 | + } |
|
| 1377 | 1464 | |
| 1378 | 1465 | $upcontext['sub_template'] = 'upgrade_complete'; |
| 1379 | 1466 | $upcontext['page_title'] = 'Upgrade Complete'; |
@@ -1389,14 +1476,16 @@ discard block |
||
| 1389 | 1476 | // Are we in maintenance mode? |
| 1390 | 1477 | if (isset($upcontext['user']['main'])) |
| 1391 | 1478 | { |
| 1392 | - if ($command_line) |
|
| 1393 | - echo ' * '; |
|
| 1479 | + if ($command_line) { |
|
| 1480 | + echo ' * '; |
|
| 1481 | + } |
|
| 1394 | 1482 | $upcontext['removed_maintenance'] = true; |
| 1395 | 1483 | $changes['maintenance'] = $upcontext['user']['main']; |
| 1396 | 1484 | } |
| 1397 | 1485 | // Otherwise if somehow we are in 2 let's go to 1. |
| 1398 | - elseif (!empty($maintenance) && $maintenance == 2) |
|
| 1399 | - $changes['maintenance'] = 1; |
|
| 1486 | + elseif (!empty($maintenance) && $maintenance == 2) { |
|
| 1487 | + $changes['maintenance'] = 1; |
|
| 1488 | + } |
|
| 1400 | 1489 | |
| 1401 | 1490 | // Wipe this out... |
| 1402 | 1491 | $upcontext['user'] = array(); |
@@ -1411,9 +1500,9 @@ discard block |
||
| 1411 | 1500 | $upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__); |
| 1412 | 1501 | |
| 1413 | 1502 | // Now is the perfect time to fetch the SM files. |
| 1414 | - if ($command_line) |
|
| 1415 | - cli_scheduled_fetchSMfiles(); |
|
| 1416 | - else |
|
| 1503 | + if ($command_line) { |
|
| 1504 | + cli_scheduled_fetchSMfiles(); |
|
| 1505 | + } else |
|
| 1417 | 1506 | { |
| 1418 | 1507 | require_once($sourcedir . '/ScheduledTasks.php'); |
| 1419 | 1508 | $forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us. |
@@ -1421,8 +1510,9 @@ discard block |
||
| 1421 | 1510 | } |
| 1422 | 1511 | |
| 1423 | 1512 | // Log what we've done. |
| 1424 | - if (empty($user_info['id'])) |
|
| 1425 | - $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
| 1513 | + if (empty($user_info['id'])) { |
|
| 1514 | + $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
| 1515 | + } |
|
| 1426 | 1516 | |
| 1427 | 1517 | // Log the action manually, so CLI still works. |
| 1428 | 1518 | $smcFunc['db_insert']('', |
@@ -1441,8 +1531,9 @@ discard block |
||
| 1441 | 1531 | |
| 1442 | 1532 | // Save the current database version. |
| 1443 | 1533 | $server_version = $smcFunc['db_server_info'](); |
| 1444 | - if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
| 1445 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1534 | + if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
| 1535 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1536 | + } |
|
| 1446 | 1537 | |
| 1447 | 1538 | if ($command_line) |
| 1448 | 1539 | { |
@@ -1454,8 +1545,9 @@ discard block |
||
| 1454 | 1545 | |
| 1455 | 1546 | // Make sure it says we're done. |
| 1456 | 1547 | $upcontext['overall_percent'] = 100; |
| 1457 | - if (isset($upcontext['step_progress'])) |
|
| 1458 | - unset($upcontext['step_progress']); |
|
| 1548 | + if (isset($upcontext['step_progress'])) { |
|
| 1549 | + unset($upcontext['step_progress']); |
|
| 1550 | + } |
|
| 1459 | 1551 | |
| 1460 | 1552 | $_GET['substep'] = 0; |
| 1461 | 1553 | return false; |
@@ -1466,8 +1558,9 @@ discard block |
||
| 1466 | 1558 | { |
| 1467 | 1559 | global $sourcedir, $language, $forum_version, $modSettings, $smcFunc; |
| 1468 | 1560 | |
| 1469 | - if (empty($modSettings['time_format'])) |
|
| 1470 | - $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
| 1561 | + if (empty($modSettings['time_format'])) { |
|
| 1562 | + $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
| 1563 | + } |
|
| 1471 | 1564 | |
| 1472 | 1565 | // What files do we want to get |
| 1473 | 1566 | $request = $smcFunc['db_query']('', ' |
@@ -1501,8 +1594,9 @@ discard block |
||
| 1501 | 1594 | $file_data = fetch_web_data($url); |
| 1502 | 1595 | |
| 1503 | 1596 | // If we got an error - give up - the site might be down. |
| 1504 | - if ($file_data === false) |
|
| 1505 | - return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
| 1597 | + if ($file_data === false) { |
|
| 1598 | + return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
| 1599 | + } |
|
| 1506 | 1600 | |
| 1507 | 1601 | // Save the file to the database. |
| 1508 | 1602 | $smcFunc['db_query']('substring', ' |
@@ -1544,8 +1638,9 @@ discard block |
||
| 1544 | 1638 | $themeData = array(); |
| 1545 | 1639 | foreach ($values as $variable => $value) |
| 1546 | 1640 | { |
| 1547 | - if (!isset($value) || $value === null) |
|
| 1548 | - $value = 0; |
|
| 1641 | + if (!isset($value) || $value === null) { |
|
| 1642 | + $value = 0; |
|
| 1643 | + } |
|
| 1549 | 1644 | |
| 1550 | 1645 | $themeData[] = array(0, 1, $variable, $value); |
| 1551 | 1646 | } |
@@ -1574,8 +1669,9 @@ discard block |
||
| 1574 | 1669 | |
| 1575 | 1670 | foreach ($values as $variable => $value) |
| 1576 | 1671 | { |
| 1577 | - if (empty($modSettings[$value[0]])) |
|
| 1578 | - continue; |
|
| 1672 | + if (empty($modSettings[$value[0]])) { |
|
| 1673 | + continue; |
|
| 1674 | + } |
|
| 1579 | 1675 | |
| 1580 | 1676 | $smcFunc['db_query']('', ' |
| 1581 | 1677 | INSERT IGNORE INTO {db_prefix}themes |
@@ -1661,19 +1757,21 @@ discard block |
||
| 1661 | 1757 | set_error_handler( |
| 1662 | 1758 | function ($errno, $errstr, $errfile, $errline) use ($support_js) |
| 1663 | 1759 | { |
| 1664 | - if ($support_js) |
|
| 1665 | - return true; |
|
| 1666 | - else |
|
| 1667 | - echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
| 1760 | + if ($support_js) { |
|
| 1761 | + return true; |
|
| 1762 | + } else { |
|
| 1763 | + echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
| 1764 | + } |
|
| 1668 | 1765 | } |
| 1669 | 1766 | ); |
| 1670 | 1767 | |
| 1671 | 1768 | // If we're on MySQL, set {db_collation}; this approach is used throughout upgrade_2-0_mysql.php to set new tables to utf8 |
| 1672 | 1769 | // Note it is expected to be in the format: ENGINE=MyISAM{$db_collation}; |
| 1673 | - if ($db_type == 'mysql') |
|
| 1674 | - $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
| 1675 | - else |
|
| 1676 | - $db_collation = ''; |
|
| 1770 | + if ($db_type == 'mysql') { |
|
| 1771 | + $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
| 1772 | + } else { |
|
| 1773 | + $db_collation = ''; |
|
| 1774 | + } |
|
| 1677 | 1775 | |
| 1678 | 1776 | $endl = $command_line ? "\n" : '<br>' . "\n"; |
| 1679 | 1777 | |
@@ -1685,8 +1783,9 @@ discard block |
||
| 1685 | 1783 | $last_step = ''; |
| 1686 | 1784 | |
| 1687 | 1785 | // Make sure all newly created tables will have the proper characters set; this approach is used throughout upgrade_2-1_mysql.php |
| 1688 | - if (isset($db_character_set) && $db_character_set === 'utf8') |
|
| 1689 | - $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
| 1786 | + if (isset($db_character_set) && $db_character_set === 'utf8') { |
|
| 1787 | + $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
| 1788 | + } |
|
| 1690 | 1789 | |
| 1691 | 1790 | // Count the total number of steps within this file - for progress. |
| 1692 | 1791 | $file_steps = substr_count(implode('', $lines), '---#'); |
@@ -1706,15 +1805,18 @@ discard block |
||
| 1706 | 1805 | $do_current = $substep >= $_GET['substep']; |
| 1707 | 1806 | |
| 1708 | 1807 | // Get rid of any comments in the beginning of the line... |
| 1709 | - if (substr(trim($line), 0, 2) === '/*') |
|
| 1710 | - $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
| 1808 | + if (substr(trim($line), 0, 2) === '/*') { |
|
| 1809 | + $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
| 1810 | + } |
|
| 1711 | 1811 | |
| 1712 | 1812 | // Always flush. Flush, flush, flush. Flush, flush, flush, flush! FLUSH! |
| 1713 | - if ($is_debug && !$support_js && $command_line) |
|
| 1714 | - flush(); |
|
| 1813 | + if ($is_debug && !$support_js && $command_line) { |
|
| 1814 | + flush(); |
|
| 1815 | + } |
|
| 1715 | 1816 | |
| 1716 | - if (trim($line) === '') |
|
| 1717 | - continue; |
|
| 1817 | + if (trim($line) === '') { |
|
| 1818 | + continue; |
|
| 1819 | + } |
|
| 1718 | 1820 | |
| 1719 | 1821 | if (trim(substr($line, 0, 3)) === '---') |
| 1720 | 1822 | { |
@@ -1724,8 +1826,9 @@ discard block |
||
| 1724 | 1826 | if (trim($current_data) != '' && $type !== '}') |
| 1725 | 1827 | { |
| 1726 | 1828 | $upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl; |
| 1727 | - if ($command_line) |
|
| 1728 | - echo $upcontext['error_message']; |
|
| 1829 | + if ($command_line) { |
|
| 1830 | + echo $upcontext['error_message']; |
|
| 1831 | + } |
|
| 1729 | 1832 | } |
| 1730 | 1833 | |
| 1731 | 1834 | if ($type == ' ') |
@@ -1743,17 +1846,18 @@ discard block |
||
| 1743 | 1846 | if ($do_current) |
| 1744 | 1847 | { |
| 1745 | 1848 | $upcontext['actioned_items'][] = $last_step; |
| 1746 | - if ($command_line) |
|
| 1747 | - echo ' * '; |
|
| 1849 | + if ($command_line) { |
|
| 1850 | + echo ' * '; |
|
| 1851 | + } |
|
| 1748 | 1852 | } |
| 1749 | - } |
|
| 1750 | - elseif ($type == '#') |
|
| 1853 | + } elseif ($type == '#') |
|
| 1751 | 1854 | { |
| 1752 | 1855 | $upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps; |
| 1753 | 1856 | |
| 1754 | 1857 | $upcontext['current_debug_item_num']++; |
| 1755 | - if (trim($line) != '---#') |
|
| 1756 | - $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1858 | + if (trim($line) != '---#') { |
|
| 1859 | + $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1860 | + } |
|
| 1757 | 1861 | |
| 1758 | 1862 | // Have we already done something? |
| 1759 | 1863 | if (isset($_GET['xml']) && $done_something) |
@@ -1764,34 +1868,36 @@ discard block |
||
| 1764 | 1868 | |
| 1765 | 1869 | if ($do_current) |
| 1766 | 1870 | { |
| 1767 | - if (trim($line) == '---#' && $command_line) |
|
| 1768 | - echo ' done.', $endl; |
|
| 1769 | - elseif ($command_line) |
|
| 1770 | - echo ' +++ ', rtrim(substr($line, 4)); |
|
| 1771 | - elseif (trim($line) != '---#') |
|
| 1871 | + if (trim($line) == '---#' && $command_line) { |
|
| 1872 | + echo ' done.', $endl; |
|
| 1873 | + } elseif ($command_line) { |
|
| 1874 | + echo ' +++ ', rtrim(substr($line, 4)); |
|
| 1875 | + } elseif (trim($line) != '---#') |
|
| 1772 | 1876 | { |
| 1773 | - if ($is_debug) |
|
| 1774 | - $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1877 | + if ($is_debug) { |
|
| 1878 | + $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1879 | + } |
|
| 1775 | 1880 | } |
| 1776 | 1881 | } |
| 1777 | 1882 | |
| 1778 | 1883 | if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep']) |
| 1779 | 1884 | { |
| 1780 | - if ($command_line) |
|
| 1781 | - echo ' * '; |
|
| 1782 | - else |
|
| 1783 | - $upcontext['actioned_items'][] = $last_step; |
|
| 1885 | + if ($command_line) { |
|
| 1886 | + echo ' * '; |
|
| 1887 | + } else { |
|
| 1888 | + $upcontext['actioned_items'][] = $last_step; |
|
| 1889 | + } |
|
| 1784 | 1890 | } |
| 1785 | 1891 | |
| 1786 | 1892 | // Small step - only if we're actually doing stuff. |
| 1787 | - if ($do_current) |
|
| 1788 | - nextSubstep(++$substep); |
|
| 1789 | - else |
|
| 1790 | - $substep++; |
|
| 1791 | - } |
|
| 1792 | - elseif ($type == '{') |
|
| 1793 | - $current_type = 'code'; |
|
| 1794 | - elseif ($type == '}') |
|
| 1893 | + if ($do_current) { |
|
| 1894 | + nextSubstep(++$substep); |
|
| 1895 | + } else { |
|
| 1896 | + $substep++; |
|
| 1897 | + } |
|
| 1898 | + } elseif ($type == '{') { |
|
| 1899 | + $current_type = 'code'; |
|
| 1900 | + } elseif ($type == '}') |
|
| 1795 | 1901 | { |
| 1796 | 1902 | $current_type = 'sql'; |
| 1797 | 1903 | |
@@ -1804,8 +1910,9 @@ discard block |
||
| 1804 | 1910 | if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false) |
| 1805 | 1911 | { |
| 1806 | 1912 | $upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl; |
| 1807 | - if ($command_line) |
|
| 1808 | - echo $upcontext['error_message']; |
|
| 1913 | + if ($command_line) { |
|
| 1914 | + echo $upcontext['error_message']; |
|
| 1915 | + } |
|
| 1809 | 1916 | } |
| 1810 | 1917 | |
| 1811 | 1918 | // Done with code! |
@@ -1885,8 +1992,9 @@ discard block |
||
| 1885 | 1992 | $db_unbuffered = false; |
| 1886 | 1993 | |
| 1887 | 1994 | // Failure?! |
| 1888 | - if ($result !== false) |
|
| 1889 | - return $result; |
|
| 1995 | + if ($result !== false) { |
|
| 1996 | + return $result; |
|
| 1997 | + } |
|
| 1890 | 1998 | |
| 1891 | 1999 | $db_error_message = $smcFunc['db_error']($db_connection); |
| 1892 | 2000 | // If MySQL we do something more clever. |
@@ -1914,54 +2022,61 @@ discard block |
||
| 1914 | 2022 | { |
| 1915 | 2023 | mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`'); |
| 1916 | 2024 | $result = mysqli_query($db_connection, $string); |
| 1917 | - if ($result !== false) |
|
| 1918 | - return $result; |
|
| 2025 | + if ($result !== false) { |
|
| 2026 | + return $result; |
|
| 2027 | + } |
|
| 1919 | 2028 | } |
| 1920 | - } |
|
| 1921 | - elseif ($mysqli_errno == 2013) |
|
| 2029 | + } elseif ($mysqli_errno == 2013) |
|
| 1922 | 2030 | { |
| 1923 | 2031 | $db_connection = mysqli_connect($db_server, $db_user, $db_passwd); |
| 1924 | 2032 | mysqli_select_db($db_connection, $db_name); |
| 1925 | 2033 | if ($db_connection) |
| 1926 | 2034 | { |
| 1927 | 2035 | $result = mysqli_query($db_connection, $string); |
| 1928 | - if ($result !== false) |
|
| 1929 | - return $result; |
|
| 2036 | + if ($result !== false) { |
|
| 2037 | + return $result; |
|
| 2038 | + } |
|
| 1930 | 2039 | } |
| 1931 | 2040 | } |
| 1932 | 2041 | // Duplicate column name... should be okay ;). |
| 1933 | - elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) |
|
| 1934 | - return false; |
|
| 2042 | + elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) { |
|
| 2043 | + return false; |
|
| 2044 | + } |
|
| 1935 | 2045 | // Duplicate insert... make sure it's the proper type of query ;). |
| 1936 | - elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) |
|
| 1937 | - return false; |
|
| 2046 | + elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) { |
|
| 2047 | + return false; |
|
| 2048 | + } |
|
| 1938 | 2049 | // Creating an index on a non-existent column. |
| 1939 | - elseif ($mysqli_errno == 1072) |
|
| 1940 | - return false; |
|
| 1941 | - elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') |
|
| 1942 | - return false; |
|
| 2050 | + elseif ($mysqli_errno == 1072) { |
|
| 2051 | + return false; |
|
| 2052 | + } elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') { |
|
| 2053 | + return false; |
|
| 2054 | + } |
|
| 1943 | 2055 | } |
| 1944 | 2056 | // If a table already exists don't go potty. |
| 1945 | 2057 | else |
| 1946 | 2058 | { |
| 1947 | 2059 | if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U'))) |
| 1948 | 2060 | { |
| 1949 | - if (strpos($db_error_message, 'exist') !== false) |
|
| 1950 | - return true; |
|
| 1951 | - } |
|
| 1952 | - elseif (strpos(trim($string), 'INSERT ') !== false) |
|
| 2061 | + if (strpos($db_error_message, 'exist') !== false) { |
|
| 2062 | + return true; |
|
| 2063 | + } |
|
| 2064 | + } elseif (strpos(trim($string), 'INSERT ') !== false) |
|
| 1953 | 2065 | { |
| 1954 | - if (strpos($db_error_message, 'duplicate') !== false) |
|
| 1955 | - return true; |
|
| 2066 | + if (strpos($db_error_message, 'duplicate') !== false) { |
|
| 2067 | + return true; |
|
| 2068 | + } |
|
| 1956 | 2069 | } |
| 1957 | 2070 | } |
| 1958 | 2071 | |
| 1959 | 2072 | // Get the query string so we pass everything. |
| 1960 | 2073 | $query_string = ''; |
| 1961 | - foreach ($_GET as $k => $v) |
|
| 1962 | - $query_string .= ';' . $k . '=' . $v; |
|
| 1963 | - if (strlen($query_string) != 0) |
|
| 1964 | - $query_string = '?' . substr($query_string, 1); |
|
| 2074 | + foreach ($_GET as $k => $v) { |
|
| 2075 | + $query_string .= ';' . $k . '=' . $v; |
|
| 2076 | + } |
|
| 2077 | + if (strlen($query_string) != 0) { |
|
| 2078 | + $query_string = '?' . substr($query_string, 1); |
|
| 2079 | + } |
|
| 1965 | 2080 | |
| 1966 | 2081 | if ($command_line) |
| 1967 | 2082 | { |
@@ -2016,16 +2131,18 @@ discard block |
||
| 2016 | 2131 | { |
| 2017 | 2132 | $found |= 1; |
| 2018 | 2133 | // Do some checks on the data if we have it set. |
| 2019 | - if (isset($change['col_type'])) |
|
| 2020 | - $found &= $change['col_type'] === $column['type']; |
|
| 2021 | - if (isset($change['null_allowed'])) |
|
| 2022 | - $found &= $column['null'] == $change['null_allowed']; |
|
| 2023 | - if (isset($change['default'])) |
|
| 2024 | - $found &= $change['default'] === $column['default']; |
|
| 2134 | + if (isset($change['col_type'])) { |
|
| 2135 | + $found &= $change['col_type'] === $column['type']; |
|
| 2136 | + } |
|
| 2137 | + if (isset($change['null_allowed'])) { |
|
| 2138 | + $found &= $column['null'] == $change['null_allowed']; |
|
| 2139 | + } |
|
| 2140 | + if (isset($change['default'])) { |
|
| 2141 | + $found &= $change['default'] === $column['default']; |
|
| 2142 | + } |
|
| 2025 | 2143 | } |
| 2026 | 2144 | } |
| 2027 | - } |
|
| 2028 | - elseif ($change['type'] === 'index') |
|
| 2145 | + } elseif ($change['type'] === 'index') |
|
| 2029 | 2146 | { |
| 2030 | 2147 | $request = upgrade_query(' |
| 2031 | 2148 | SHOW INDEX |
@@ -2034,9 +2151,10 @@ discard block |
||
| 2034 | 2151 | { |
| 2035 | 2152 | $cur_index = array(); |
| 2036 | 2153 | |
| 2037 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2038 | - if ($row['Key_name'] === $change['name']) |
|
| 2154 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2155 | + if ($row['Key_name'] === $change['name']) |
|
| 2039 | 2156 | $cur_index[(int) $row['Seq_in_index']] = $row['Column_name']; |
| 2157 | + } |
|
| 2040 | 2158 | |
| 2041 | 2159 | ksort($cur_index, SORT_NUMERIC); |
| 2042 | 2160 | $found = array_values($cur_index) === $change['target_columns']; |
@@ -2046,14 +2164,17 @@ discard block |
||
| 2046 | 2164 | } |
| 2047 | 2165 | |
| 2048 | 2166 | // If we're trying to add and it's added, we're done. |
| 2049 | - if ($found && in_array($change['method'], array('add', 'change'))) |
|
| 2050 | - return true; |
|
| 2167 | + if ($found && in_array($change['method'], array('add', 'change'))) { |
|
| 2168 | + return true; |
|
| 2169 | + } |
|
| 2051 | 2170 | // Otherwise if we're removing and it wasn't found we're also done. |
| 2052 | - elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) |
|
| 2053 | - return true; |
|
| 2171 | + elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) { |
|
| 2172 | + return true; |
|
| 2173 | + } |
|
| 2054 | 2174 | // Otherwise is it just a test? |
| 2055 | - elseif ($is_test) |
|
| 2056 | - return false; |
|
| 2175 | + elseif ($is_test) { |
|
| 2176 | + return false; |
|
| 2177 | + } |
|
| 2057 | 2178 | |
| 2058 | 2179 | // Not found it yet? Bummer! How about we see if we're currently doing it? |
| 2059 | 2180 | $running = false; |
@@ -2064,8 +2185,9 @@ discard block |
||
| 2064 | 2185 | SHOW FULL PROCESSLIST'); |
| 2065 | 2186 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2066 | 2187 | { |
| 2067 | - if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) |
|
| 2068 | - $found = true; |
|
| 2188 | + if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) { |
|
| 2189 | + $found = true; |
|
| 2190 | + } |
|
| 2069 | 2191 | } |
| 2070 | 2192 | |
| 2071 | 2193 | // Can't find it? Then we need to run it fools! |
@@ -2077,8 +2199,9 @@ discard block |
||
| 2077 | 2199 | ALTER TABLE ' . $db_prefix . $change['table'] . ' |
| 2078 | 2200 | ' . $change['text'], true) !== false; |
| 2079 | 2201 | |
| 2080 | - if (!$success) |
|
| 2081 | - return false; |
|
| 2202 | + if (!$success) { |
|
| 2203 | + return false; |
|
| 2204 | + } |
|
| 2082 | 2205 | |
| 2083 | 2206 | // Return |
| 2084 | 2207 | $running = true; |
@@ -2120,8 +2243,9 @@ discard block |
||
| 2120 | 2243 | 'db_error_skip' => true, |
| 2121 | 2244 | ) |
| 2122 | 2245 | ); |
| 2123 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2124 | - die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
| 2246 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2247 | + die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
| 2248 | + } |
|
| 2125 | 2249 | $table_row = $smcFunc['db_fetch_assoc']($request); |
| 2126 | 2250 | $smcFunc['db_free_result']($request); |
| 2127 | 2251 | |
@@ -2143,18 +2267,19 @@ discard block |
||
| 2143 | 2267 | ) |
| 2144 | 2268 | ); |
| 2145 | 2269 | // No results? Just forget it all together. |
| 2146 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2147 | - unset($table_row['Collation']); |
|
| 2148 | - else |
|
| 2149 | - $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2270 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2271 | + unset($table_row['Collation']); |
|
| 2272 | + } else { |
|
| 2273 | + $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2274 | + } |
|
| 2150 | 2275 | $smcFunc['db_free_result']($request); |
| 2151 | 2276 | } |
| 2152 | 2277 | |
| 2153 | 2278 | if ($column_fix) |
| 2154 | 2279 | { |
| 2155 | 2280 | // Make sure there are no NULL's left. |
| 2156 | - if ($null_fix) |
|
| 2157 | - $smcFunc['db_query']('', ' |
|
| 2281 | + if ($null_fix) { |
|
| 2282 | + $smcFunc['db_query']('', ' |
|
| 2158 | 2283 | UPDATE {db_prefix}' . $change['table'] . ' |
| 2159 | 2284 | SET ' . $change['column'] . ' = {string:default} |
| 2160 | 2285 | WHERE ' . $change['column'] . ' IS NULL', |
@@ -2163,6 +2288,7 @@ discard block |
||
| 2163 | 2288 | 'db_error_skip' => true, |
| 2164 | 2289 | ) |
| 2165 | 2290 | ); |
| 2291 | + } |
|
| 2166 | 2292 | |
| 2167 | 2293 | // Do the actual alteration. |
| 2168 | 2294 | $smcFunc['db_query']('', ' |
@@ -2191,8 +2317,9 @@ discard block |
||
| 2191 | 2317 | } |
| 2192 | 2318 | |
| 2193 | 2319 | // Not a column we need to check on? |
| 2194 | - if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) |
|
| 2195 | - return; |
|
| 2320 | + if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) { |
|
| 2321 | + return; |
|
| 2322 | + } |
|
| 2196 | 2323 | |
| 2197 | 2324 | // Break it up you (six|seven). |
| 2198 | 2325 | $temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text'])); |
@@ -2211,13 +2338,13 @@ discard block |
||
| 2211 | 2338 | 'new_name' => $temp[2], |
| 2212 | 2339 | )); |
| 2213 | 2340 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
| 2214 | - if ($smcFunc['db_num_rows'] != 1) |
|
| 2215 | - return; |
|
| 2341 | + if ($smcFunc['db_num_rows'] != 1) { |
|
| 2342 | + return; |
|
| 2343 | + } |
|
| 2216 | 2344 | |
| 2217 | 2345 | list (, $current_type) = $smcFunc['db_fetch_assoc']($request); |
| 2218 | 2346 | $smcFunc['db_free_result']($request); |
| 2219 | - } |
|
| 2220 | - else |
|
| 2347 | + } else |
|
| 2221 | 2348 | { |
| 2222 | 2349 | // Do this the old fashion, sure method way. |
| 2223 | 2350 | $request = $smcFunc['db_query']('', ' |
@@ -2228,21 +2355,24 @@ discard block |
||
| 2228 | 2355 | )); |
| 2229 | 2356 | // Mayday! |
| 2230 | 2357 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
| 2231 | - if ($smcFunc['db_num_rows'] == 0) |
|
| 2232 | - return; |
|
| 2358 | + if ($smcFunc['db_num_rows'] == 0) { |
|
| 2359 | + return; |
|
| 2360 | + } |
|
| 2233 | 2361 | |
| 2234 | 2362 | // Oh where, oh where has my little field gone. Oh where can it be... |
| 2235 | - while ($row = $smcFunc['db_query']($request)) |
|
| 2236 | - if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
| 2363 | + while ($row = $smcFunc['db_query']($request)) { |
|
| 2364 | + if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
| 2237 | 2365 | { |
| 2238 | 2366 | $current_type = $row['Type']; |
| 2367 | + } |
|
| 2239 | 2368 | break; |
| 2240 | 2369 | } |
| 2241 | 2370 | } |
| 2242 | 2371 | |
| 2243 | 2372 | // If this doesn't match, the column may of been altered for a reason. |
| 2244 | - if (trim($current_type) != trim($temp[3])) |
|
| 2245 | - $temp[3] = $current_type; |
|
| 2373 | + if (trim($current_type) != trim($temp[3])) { |
|
| 2374 | + $temp[3] = $current_type; |
|
| 2375 | + } |
|
| 2246 | 2376 | |
| 2247 | 2377 | // Piece this back together. |
| 2248 | 2378 | $change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp)); |
@@ -2254,8 +2384,9 @@ discard block |
||
| 2254 | 2384 | global $start_time, $timeLimitThreshold, $command_line, $custom_warning; |
| 2255 | 2385 | global $step_progress, $is_debug, $upcontext; |
| 2256 | 2386 | |
| 2257 | - if ($_GET['substep'] < $substep) |
|
| 2258 | - $_GET['substep'] = $substep; |
|
| 2387 | + if ($_GET['substep'] < $substep) { |
|
| 2388 | + $_GET['substep'] = $substep; |
|
| 2389 | + } |
|
| 2259 | 2390 | |
| 2260 | 2391 | if ($command_line) |
| 2261 | 2392 | { |
@@ -2268,29 +2399,33 @@ discard block |
||
| 2268 | 2399 | } |
| 2269 | 2400 | |
| 2270 | 2401 | @set_time_limit(300); |
| 2271 | - if (function_exists('apache_reset_timeout')) |
|
| 2272 | - @apache_reset_timeout(); |
|
| 2402 | + if (function_exists('apache_reset_timeout')) { |
|
| 2403 | + @apache_reset_timeout(); |
|
| 2404 | + } |
|
| 2273 | 2405 | |
| 2274 | - if (time() - $start_time <= $timeLimitThreshold) |
|
| 2275 | - return; |
|
| 2406 | + if (time() - $start_time <= $timeLimitThreshold) { |
|
| 2407 | + return; |
|
| 2408 | + } |
|
| 2276 | 2409 | |
| 2277 | 2410 | // Do we have some custom step progress stuff? |
| 2278 | 2411 | if (!empty($step_progress)) |
| 2279 | 2412 | { |
| 2280 | 2413 | $upcontext['substep_progress'] = 0; |
| 2281 | 2414 | $upcontext['substep_progress_name'] = $step_progress['name']; |
| 2282 | - if ($step_progress['current'] > $step_progress['total']) |
|
| 2283 | - $upcontext['substep_progress'] = 99.9; |
|
| 2284 | - else |
|
| 2285 | - $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
| 2415 | + if ($step_progress['current'] > $step_progress['total']) { |
|
| 2416 | + $upcontext['substep_progress'] = 99.9; |
|
| 2417 | + } else { |
|
| 2418 | + $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
| 2419 | + } |
|
| 2286 | 2420 | |
| 2287 | 2421 | // Make it nicely rounded. |
| 2288 | 2422 | $upcontext['substep_progress'] = round($upcontext['substep_progress'], 1); |
| 2289 | 2423 | } |
| 2290 | 2424 | |
| 2291 | 2425 | // If this is XML we just exit right away! |
| 2292 | - if (isset($_GET['xml'])) |
|
| 2293 | - return upgradeExit(); |
|
| 2426 | + if (isset($_GET['xml'])) { |
|
| 2427 | + return upgradeExit(); |
|
| 2428 | + } |
|
| 2294 | 2429 | |
| 2295 | 2430 | // We're going to pause after this! |
| 2296 | 2431 | $upcontext['pause'] = true; |
@@ -2298,13 +2433,15 @@ discard block |
||
| 2298 | 2433 | $upcontext['query_string'] = ''; |
| 2299 | 2434 | foreach ($_GET as $k => $v) |
| 2300 | 2435 | { |
| 2301 | - if ($k != 'data' && $k != 'substep' && $k != 'step') |
|
| 2302 | - $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
| 2436 | + if ($k != 'data' && $k != 'substep' && $k != 'step') { |
|
| 2437 | + $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
| 2438 | + } |
|
| 2303 | 2439 | } |
| 2304 | 2440 | |
| 2305 | 2441 | // Custom warning? |
| 2306 | - if (!empty($custom_warning)) |
|
| 2307 | - $upcontext['custom_warning'] = $custom_warning; |
|
| 2442 | + if (!empty($custom_warning)) { |
|
| 2443 | + $upcontext['custom_warning'] = $custom_warning; |
|
| 2444 | + } |
|
| 2308 | 2445 | |
| 2309 | 2446 | upgradeExit(); |
| 2310 | 2447 | } |
@@ -2319,25 +2456,26 @@ discard block |
||
| 2319 | 2456 | ob_implicit_flush(true); |
| 2320 | 2457 | @set_time_limit(600); |
| 2321 | 2458 | |
| 2322 | - if (!isset($_SERVER['argv'])) |
|
| 2323 | - $_SERVER['argv'] = array(); |
|
| 2459 | + if (!isset($_SERVER['argv'])) { |
|
| 2460 | + $_SERVER['argv'] = array(); |
|
| 2461 | + } |
|
| 2324 | 2462 | $_GET['maint'] = 1; |
| 2325 | 2463 | |
| 2326 | 2464 | foreach ($_SERVER['argv'] as $i => $arg) |
| 2327 | 2465 | { |
| 2328 | - if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) |
|
| 2329 | - $_GET['lang'] = $match[1]; |
|
| 2330 | - elseif (preg_match('~^--path=(.+)$~', $arg) != 0) |
|
| 2331 | - continue; |
|
| 2332 | - elseif ($arg == '--no-maintenance') |
|
| 2333 | - $_GET['maint'] = 0; |
|
| 2334 | - elseif ($arg == '--debug') |
|
| 2335 | - $is_debug = true; |
|
| 2336 | - elseif ($arg == '--backup') |
|
| 2337 | - $_POST['backup'] = 1; |
|
| 2338 | - elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) |
|
| 2339 | - $_GET['conv'] = 1; |
|
| 2340 | - elseif ($i != 0) |
|
| 2466 | + if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) { |
|
| 2467 | + $_GET['lang'] = $match[1]; |
|
| 2468 | + } elseif (preg_match('~^--path=(.+)$~', $arg) != 0) { |
|
| 2469 | + continue; |
|
| 2470 | + } elseif ($arg == '--no-maintenance') { |
|
| 2471 | + $_GET['maint'] = 0; |
|
| 2472 | + } elseif ($arg == '--debug') { |
|
| 2473 | + $is_debug = true; |
|
| 2474 | + } elseif ($arg == '--backup') { |
|
| 2475 | + $_POST['backup'] = 1; |
|
| 2476 | + } elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) { |
|
| 2477 | + $_GET['conv'] = 1; |
|
| 2478 | + } elseif ($i != 0) |
|
| 2341 | 2479 | { |
| 2342 | 2480 | echo 'SMF Command-line Upgrader |
| 2343 | 2481 | Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]... |
@@ -2351,10 +2489,12 @@ discard block |
||
| 2351 | 2489 | } |
| 2352 | 2490 | } |
| 2353 | 2491 | |
| 2354 | - if (!php_version_check()) |
|
| 2355 | - print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
| 2356 | - if (!db_version_check()) |
|
| 2357 | - print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
| 2492 | + if (!php_version_check()) { |
|
| 2493 | + print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
| 2494 | + } |
|
| 2495 | + if (!db_version_check()) { |
|
| 2496 | + print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
| 2497 | + } |
|
| 2358 | 2498 | |
| 2359 | 2499 | // Do some checks to make sure they have proper privileges |
| 2360 | 2500 | db_extend('packages'); |
@@ -2369,39 +2509,45 @@ discard block |
||
| 2369 | 2509 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
| 2370 | 2510 | |
| 2371 | 2511 | // Sorry... we need CREATE, ALTER and DROP |
| 2372 | - if (!$create || !$alter || !$drop) |
|
| 2373 | - 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); |
|
| 2512 | + if (!$create || !$alter || !$drop) { |
|
| 2513 | + 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); |
|
| 2514 | + } |
|
| 2374 | 2515 | |
| 2375 | 2516 | $check = @file_exists($modSettings['theme_dir'] . '/index.template.php') |
| 2376 | 2517 | && @file_exists($sourcedir . '/QueryString.php') |
| 2377 | 2518 | && @file_exists($sourcedir . '/ManageBoards.php'); |
| 2378 | - if (!$check && !isset($modSettings['smfVersion'])) |
|
| 2379 | - print_error('Error: Some files are missing or out-of-date.', true); |
|
| 2519 | + if (!$check && !isset($modSettings['smfVersion'])) { |
|
| 2520 | + print_error('Error: Some files are missing or out-of-date.', true); |
|
| 2521 | + } |
|
| 2380 | 2522 | |
| 2381 | 2523 | // Do a quick version spot check. |
| 2382 | 2524 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
| 2383 | 2525 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
| 2384 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
| 2385 | - print_error('Error: Some files have not yet been updated properly.'); |
|
| 2526 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
| 2527 | + print_error('Error: Some files have not yet been updated properly.'); |
|
| 2528 | + } |
|
| 2386 | 2529 | |
| 2387 | 2530 | // Make sure Settings.php is writable. |
| 2388 | 2531 | quickFileWritable($boarddir . '/Settings.php'); |
| 2389 | - if (!is_writable($boarddir . '/Settings.php')) |
|
| 2390 | - print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
| 2532 | + if (!is_writable($boarddir . '/Settings.php')) { |
|
| 2533 | + print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
| 2534 | + } |
|
| 2391 | 2535 | |
| 2392 | 2536 | // Make sure Settings_bak.php is writable. |
| 2393 | 2537 | quickFileWritable($boarddir . '/Settings_bak.php'); |
| 2394 | - if (!is_writable($boarddir . '/Settings_bak.php')) |
|
| 2395 | - print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
| 2538 | + if (!is_writable($boarddir . '/Settings_bak.php')) { |
|
| 2539 | + print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
| 2540 | + } |
|
| 2396 | 2541 | |
| 2397 | 2542 | // Make sure db_last_error.php is writable. |
| 2398 | 2543 | quickFileWritable($boarddir . '/db_last_error.php'); |
| 2399 | - if (!is_writable($boarddir . '/db_last_error.php')) |
|
| 2400 | - print_error('Error: Unable to obtain write access to "db_last_error.php".'); |
|
| 2544 | + if (!is_writable($boarddir . '/db_last_error.php')) { |
|
| 2545 | + print_error('Error: Unable to obtain write access to "db_last_error.php".'); |
|
| 2546 | + } |
|
| 2401 | 2547 | |
| 2402 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
| 2403 | - print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
| 2404 | - elseif (isset($modSettings['agreement'])) |
|
| 2548 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
| 2549 | + print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
| 2550 | + } elseif (isset($modSettings['agreement'])) |
|
| 2405 | 2551 | { |
| 2406 | 2552 | $fp = fopen($boarddir . '/agreement.txt', 'w'); |
| 2407 | 2553 | fwrite($fp, $modSettings['agreement']); |
@@ -2411,31 +2557,36 @@ discard block |
||
| 2411 | 2557 | // Make sure Themes is writable. |
| 2412 | 2558 | quickFileWritable($modSettings['theme_dir']); |
| 2413 | 2559 | |
| 2414 | - if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) |
|
| 2415 | - print_error('Error: Unable to obtain write access to "Themes".'); |
|
| 2560 | + if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) { |
|
| 2561 | + print_error('Error: Unable to obtain write access to "Themes".'); |
|
| 2562 | + } |
|
| 2416 | 2563 | |
| 2417 | 2564 | // Make sure cache directory exists and is writable! |
| 2418 | 2565 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
| 2419 | - if (!file_exists($cachedir_temp)) |
|
| 2420 | - @mkdir($cachedir_temp); |
|
| 2566 | + if (!file_exists($cachedir_temp)) { |
|
| 2567 | + @mkdir($cachedir_temp); |
|
| 2568 | + } |
|
| 2421 | 2569 | |
| 2422 | 2570 | // Make sure the cache temp dir is writable. |
| 2423 | 2571 | quickFileWritable($cachedir_temp); |
| 2424 | 2572 | |
| 2425 | - if (!is_writable($cachedir_temp)) |
|
| 2426 | - print_error('Error: Unable to obtain write access to "cache".', true); |
|
| 2573 | + if (!is_writable($cachedir_temp)) { |
|
| 2574 | + print_error('Error: Unable to obtain write access to "cache".', true); |
|
| 2575 | + } |
|
| 2427 | 2576 | |
| 2428 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
| 2429 | - print_error('Error: Unable to find language files!', true); |
|
| 2430 | - else |
|
| 2577 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
| 2578 | + print_error('Error: Unable to find language files!', true); |
|
| 2579 | + } else |
|
| 2431 | 2580 | { |
| 2432 | 2581 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
| 2433 | 2582 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 2434 | 2583 | |
| 2435 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 2436 | - print_error('Error: Language files out of date.', true); |
|
| 2437 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 2438 | - print_error('Error: Install language is missing for selected language.', true); |
|
| 2584 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 2585 | + print_error('Error: Language files out of date.', true); |
|
| 2586 | + } |
|
| 2587 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 2588 | + print_error('Error: Install language is missing for selected language.', true); |
|
| 2589 | + } |
|
| 2439 | 2590 | |
| 2440 | 2591 | // Otherwise include it! |
| 2441 | 2592 | require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
@@ -2454,8 +2605,9 @@ discard block |
||
| 2454 | 2605 | global $upcontext, $db_character_set, $sourcedir, $smcFunc, $modSettings, $language, $db_prefix, $db_type, $command_line, $support_js; |
| 2455 | 2606 | |
| 2456 | 2607 | // Done it already? |
| 2457 | - if (!empty($_POST['utf8_done'])) |
|
| 2458 | - return true; |
|
| 2608 | + if (!empty($_POST['utf8_done'])) { |
|
| 2609 | + return true; |
|
| 2610 | + } |
|
| 2459 | 2611 | |
| 2460 | 2612 | // First make sure they aren't already on UTF-8 before we go anywhere... |
| 2461 | 2613 | if ($db_type == 'postgresql' || ($db_character_set === 'utf8' && !empty($modSettings['global_character_set']) && $modSettings['global_character_set'] === 'UTF-8')) |
@@ -2468,8 +2620,7 @@ discard block |
||
| 2468 | 2620 | ); |
| 2469 | 2621 | |
| 2470 | 2622 | return true; |
| 2471 | - } |
|
| 2472 | - else |
|
| 2623 | + } else |
|
| 2473 | 2624 | { |
| 2474 | 2625 | $upcontext['page_title'] = 'Converting to UTF8'; |
| 2475 | 2626 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8'; |
@@ -2513,8 +2664,9 @@ discard block |
||
| 2513 | 2664 | ) |
| 2514 | 2665 | ); |
| 2515 | 2666 | $db_charsets = array(); |
| 2516 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2517 | - $db_charsets[] = $row['Charset']; |
|
| 2667 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2668 | + $db_charsets[] = $row['Charset']; |
|
| 2669 | + } |
|
| 2518 | 2670 | |
| 2519 | 2671 | $smcFunc['db_free_result']($request); |
| 2520 | 2672 | |
@@ -2550,13 +2702,15 @@ discard block |
||
| 2550 | 2702 | // If there's a fulltext index, we need to drop it first... |
| 2551 | 2703 | if ($request !== false || $smcFunc['db_num_rows']($request) != 0) |
| 2552 | 2704 | { |
| 2553 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2554 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 2705 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2706 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 2555 | 2707 | $upcontext['fulltext_index'][] = $row['Key_name']; |
| 2708 | + } |
|
| 2556 | 2709 | $smcFunc['db_free_result']($request); |
| 2557 | 2710 | |
| 2558 | - if (isset($upcontext['fulltext_index'])) |
|
| 2559 | - $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
| 2711 | + if (isset($upcontext['fulltext_index'])) { |
|
| 2712 | + $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
| 2713 | + } |
|
| 2560 | 2714 | } |
| 2561 | 2715 | |
| 2562 | 2716 | // Drop it and make a note... |
@@ -2746,8 +2900,9 @@ discard block |
||
| 2746 | 2900 | $replace = '%field%'; |
| 2747 | 2901 | |
| 2748 | 2902 | // Build a huge REPLACE statement... |
| 2749 | - foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) |
|
| 2750 | - $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
| 2903 | + foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) { |
|
| 2904 | + $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
| 2905 | + } |
|
| 2751 | 2906 | } |
| 2752 | 2907 | |
| 2753 | 2908 | // Get a list of table names ahead of time... This makes it easier to set our substep and such |
@@ -2757,9 +2912,10 @@ discard block |
||
| 2757 | 2912 | $upcontext['table_count'] = count($queryTables); |
| 2758 | 2913 | |
| 2759 | 2914 | // What ones have we already done? |
| 2760 | - foreach ($queryTables as $id => $table) |
|
| 2761 | - if ($id < $_GET['substep']) |
|
| 2915 | + foreach ($queryTables as $id => $table) { |
|
| 2916 | + if ($id < $_GET['substep']) |
|
| 2762 | 2917 | $upcontext['previous_tables'][] = $table; |
| 2918 | + } |
|
| 2763 | 2919 | |
| 2764 | 2920 | $upcontext['cur_table_num'] = $_GET['substep']; |
| 2765 | 2921 | $upcontext['cur_table_name'] = str_replace($db_prefix, '', $queryTables[$_GET['substep']]); |
@@ -2796,8 +2952,9 @@ discard block |
||
| 2796 | 2952 | nextSubstep($substep); |
| 2797 | 2953 | |
| 2798 | 2954 | // Just to make sure it doesn't time out. |
| 2799 | - if (function_exists('apache_reset_timeout')) |
|
| 2800 | - @apache_reset_timeout(); |
|
| 2955 | + if (function_exists('apache_reset_timeout')) { |
|
| 2956 | + @apache_reset_timeout(); |
|
| 2957 | + } |
|
| 2801 | 2958 | |
| 2802 | 2959 | $table_charsets = array(); |
| 2803 | 2960 | |
@@ -2820,8 +2977,9 @@ discard block |
||
| 2820 | 2977 | |
| 2821 | 2978 | // Build structure of columns to operate on organized by charset; only operate on columns not yet utf8 |
| 2822 | 2979 | if ($charset != 'utf8') { |
| 2823 | - if (!isset($table_charsets[$charset])) |
|
| 2824 | - $table_charsets[$charset] = array(); |
|
| 2980 | + if (!isset($table_charsets[$charset])) { |
|
| 2981 | + $table_charsets[$charset] = array(); |
|
| 2982 | + } |
|
| 2825 | 2983 | |
| 2826 | 2984 | $table_charsets[$charset][] = $column_info; |
| 2827 | 2985 | } |
@@ -2862,10 +3020,11 @@ discard block |
||
| 2862 | 3020 | if (isset($translation_tables[$upcontext['charset_detected']])) |
| 2863 | 3021 | { |
| 2864 | 3022 | $update = ''; |
| 2865 | - foreach ($table_charsets as $charset => $columns) |
|
| 2866 | - foreach ($columns as $column) |
|
| 3023 | + foreach ($table_charsets as $charset => $columns) { |
|
| 3024 | + foreach ($columns as $column) |
|
| 2867 | 3025 | $update .= ' |
| 2868 | 3026 | ' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ','; |
| 3027 | + } |
|
| 2869 | 3028 | |
| 2870 | 3029 | $smcFunc['db_query']('', ' |
| 2871 | 3030 | UPDATE {raw:table_name} |
@@ -2890,8 +3049,9 @@ discard block |
||
| 2890 | 3049 | // Now do the actual conversion (if still needed). |
| 2891 | 3050 | if ($charsets[$upcontext['charset_detected']] !== 'utf8') |
| 2892 | 3051 | { |
| 2893 | - if ($command_line) |
|
| 2894 | - echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
| 3052 | + if ($command_line) { |
|
| 3053 | + echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
| 3054 | + } |
|
| 2895 | 3055 | |
| 2896 | 3056 | $smcFunc['db_query']('', ' |
| 2897 | 3057 | ALTER TABLE {raw:table_name} |
@@ -2901,12 +3061,14 @@ discard block |
||
| 2901 | 3061 | ) |
| 2902 | 3062 | ); |
| 2903 | 3063 | |
| 2904 | - if ($command_line) |
|
| 2905 | - echo " done.\n"; |
|
| 3064 | + if ($command_line) { |
|
| 3065 | + echo " done.\n"; |
|
| 3066 | + } |
|
| 2906 | 3067 | } |
| 2907 | 3068 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 2908 | - if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count']) |
|
| 2909 | - return upgradeExit(); |
|
| 3069 | + if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count']) { |
|
| 3070 | + return upgradeExit(); |
|
| 3071 | + } |
|
| 2910 | 3072 | } |
| 2911 | 3073 | |
| 2912 | 3074 | $prev_charset = empty($translation_tables[$upcontext['charset_detected']]) ? $charsets[$upcontext['charset_detected']] : $translation_tables[$upcontext['charset_detected']]; |
@@ -2935,8 +3097,8 @@ discard block |
||
| 2935 | 3097 | ); |
| 2936 | 3098 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2937 | 3099 | { |
| 2938 | - 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) |
|
| 2939 | - $smcFunc['db_query']('', ' |
|
| 3100 | + 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) { |
|
| 3101 | + $smcFunc['db_query']('', ' |
|
| 2940 | 3102 | UPDATE {db_prefix}log_actions |
| 2941 | 3103 | SET extra = {string:extra} |
| 2942 | 3104 | WHERE id_action = {int:current_action}', |
@@ -2945,6 +3107,7 @@ discard block |
||
| 2945 | 3107 | 'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4], |
| 2946 | 3108 | ) |
| 2947 | 3109 | ); |
| 3110 | + } |
|
| 2948 | 3111 | } |
| 2949 | 3112 | $smcFunc['db_free_result']($request); |
| 2950 | 3113 | |
@@ -2966,15 +3129,17 @@ discard block |
||
| 2966 | 3129 | // First thing's first - did we already do this? |
| 2967 | 3130 | if (!empty($modSettings['json_done'])) |
| 2968 | 3131 | { |
| 2969 | - if ($command_line) |
|
| 2970 | - return DeleteUpgrade(); |
|
| 2971 | - else |
|
| 2972 | - return true; |
|
| 3132 | + if ($command_line) { |
|
| 3133 | + return DeleteUpgrade(); |
|
| 3134 | + } else { |
|
| 3135 | + return true; |
|
| 3136 | + } |
|
| 2973 | 3137 | } |
| 2974 | 3138 | |
| 2975 | 3139 | // Done it already - js wise? |
| 2976 | - if (!empty($_POST['json_done'])) |
|
| 2977 | - return true; |
|
| 3140 | + if (!empty($_POST['json_done'])) { |
|
| 3141 | + return true; |
|
| 3142 | + } |
|
| 2978 | 3143 | |
| 2979 | 3144 | // List of tables affected by this function |
| 2980 | 3145 | // name => array('key', col1[,col2|true[,col3]]) |
@@ -3006,12 +3171,14 @@ discard block |
||
| 3006 | 3171 | $upcontext['cur_table_name'] = isset($keys[$_GET['substep']]) ? $keys[$_GET['substep']] : $keys[0]; |
| 3007 | 3172 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
| 3008 | 3173 | |
| 3009 | - foreach ($keys as $id => $table) |
|
| 3010 | - if ($id < $_GET['substep']) |
|
| 3174 | + foreach ($keys as $id => $table) { |
|
| 3175 | + if ($id < $_GET['substep']) |
|
| 3011 | 3176 | $upcontext['previous_tables'][] = $table; |
| 3177 | + } |
|
| 3012 | 3178 | |
| 3013 | - if ($command_line) |
|
| 3014 | - echo 'Converting data from serialize() to json_encode().'; |
|
| 3179 | + if ($command_line) { |
|
| 3180 | + echo 'Converting data from serialize() to json_encode().'; |
|
| 3181 | + } |
|
| 3015 | 3182 | |
| 3016 | 3183 | if (!$support_js || isset($_GET['xml'])) |
| 3017 | 3184 | { |
@@ -3051,8 +3218,9 @@ discard block |
||
| 3051 | 3218 | |
| 3052 | 3219 | // Loop through and fix these... |
| 3053 | 3220 | $new_settings = array(); |
| 3054 | - if ($command_line) |
|
| 3055 | - echo "\n" . 'Fixing some settings...'; |
|
| 3221 | + if ($command_line) { |
|
| 3222 | + echo "\n" . 'Fixing some settings...'; |
|
| 3223 | + } |
|
| 3056 | 3224 | |
| 3057 | 3225 | foreach ($serialized_settings as $var) |
| 3058 | 3226 | { |
@@ -3060,22 +3228,24 @@ discard block |
||
| 3060 | 3228 | { |
| 3061 | 3229 | // Attempt to unserialize the setting |
| 3062 | 3230 | $temp = @safe_unserialize($modSettings[$var]); |
| 3063 | - if (!$temp && $command_line) |
|
| 3064 | - echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
| 3065 | - elseif ($temp !== false) |
|
| 3066 | - $new_settings[$var] = json_encode($temp); |
|
| 3231 | + if (!$temp && $command_line) { |
|
| 3232 | + echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
| 3233 | + } elseif ($temp !== false) { |
|
| 3234 | + $new_settings[$var] = json_encode($temp); |
|
| 3235 | + } |
|
| 3067 | 3236 | } |
| 3068 | 3237 | } |
| 3069 | 3238 | |
| 3070 | 3239 | // Update everything at once |
| 3071 | - if (!function_exists('cache_put_data')) |
|
| 3072 | - require_once($sourcedir . '/Load.php'); |
|
| 3240 | + if (!function_exists('cache_put_data')) { |
|
| 3241 | + require_once($sourcedir . '/Load.php'); |
|
| 3242 | + } |
|
| 3073 | 3243 | updateSettings($new_settings, true); |
| 3074 | 3244 | |
| 3075 | - if ($command_line) |
|
| 3076 | - echo ' done.'; |
|
| 3077 | - } |
|
| 3078 | - elseif ($table == 'themes') |
|
| 3245 | + if ($command_line) { |
|
| 3246 | + echo ' done.'; |
|
| 3247 | + } |
|
| 3248 | + } elseif ($table == 'themes') |
|
| 3079 | 3249 | { |
| 3080 | 3250 | // Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point... |
| 3081 | 3251 | $query = $smcFunc['db_query']('', ' |
@@ -3094,10 +3264,11 @@ discard block |
||
| 3094 | 3264 | |
| 3095 | 3265 | if ($command_line) |
| 3096 | 3266 | { |
| 3097 | - if ($temp === false) |
|
| 3098 | - echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
| 3099 | - else |
|
| 3100 | - echo "\n" . 'Fixing admin preferences...'; |
|
| 3267 | + if ($temp === false) { |
|
| 3268 | + echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
| 3269 | + } else { |
|
| 3270 | + echo "\n" . 'Fixing admin preferences...'; |
|
| 3271 | + } |
|
| 3101 | 3272 | } |
| 3102 | 3273 | |
| 3103 | 3274 | if ($temp !== false) |
@@ -3119,15 +3290,15 @@ discard block |
||
| 3119 | 3290 | ) |
| 3120 | 3291 | ); |
| 3121 | 3292 | |
| 3122 | - if ($command_line) |
|
| 3123 | - echo ' done.'; |
|
| 3293 | + if ($command_line) { |
|
| 3294 | + echo ' done.'; |
|
| 3295 | + } |
|
| 3124 | 3296 | } |
| 3125 | 3297 | } |
| 3126 | 3298 | |
| 3127 | 3299 | $smcFunc['db_free_result']($query); |
| 3128 | 3300 | } |
| 3129 | - } |
|
| 3130 | - else |
|
| 3301 | + } else |
|
| 3131 | 3302 | { |
| 3132 | 3303 | // First item is always the key... |
| 3133 | 3304 | $key = $info[0]; |
@@ -3138,8 +3309,7 @@ discard block |
||
| 3138 | 3309 | { |
| 3139 | 3310 | $col_select = $info[1]; |
| 3140 | 3311 | $where = ' WHERE ' . $info[1] . ' != {empty}'; |
| 3141 | - } |
|
| 3142 | - else |
|
| 3312 | + } else |
|
| 3143 | 3313 | { |
| 3144 | 3314 | $col_select = implode(', ', $info); |
| 3145 | 3315 | } |
@@ -3172,8 +3342,7 @@ discard block |
||
| 3172 | 3342 | if ($temp === false && $command_line) |
| 3173 | 3343 | { |
| 3174 | 3344 | echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n"; |
| 3175 | - } |
|
| 3176 | - else |
|
| 3345 | + } else |
|
| 3177 | 3346 | { |
| 3178 | 3347 | $row[$col] = json_encode($temp); |
| 3179 | 3348 | |
@@ -3198,16 +3367,18 @@ discard block |
||
| 3198 | 3367 | } |
| 3199 | 3368 | } |
| 3200 | 3369 | |
| 3201 | - if ($command_line) |
|
| 3202 | - echo ' done.'; |
|
| 3370 | + if ($command_line) { |
|
| 3371 | + echo ' done.'; |
|
| 3372 | + } |
|
| 3203 | 3373 | |
| 3204 | 3374 | // Free up some memory... |
| 3205 | 3375 | $smcFunc['db_free_result']($query); |
| 3206 | 3376 | } |
| 3207 | 3377 | } |
| 3208 | 3378 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 3209 | - if (isset($_GET['xml'])) |
|
| 3210 | - return upgradeExit(); |
|
| 3379 | + if (isset($_GET['xml'])) { |
|
| 3380 | + return upgradeExit(); |
|
| 3381 | + } |
|
| 3211 | 3382 | } |
| 3212 | 3383 | |
| 3213 | 3384 | if ($command_line) |
@@ -3222,8 +3393,9 @@ discard block |
||
| 3222 | 3393 | |
| 3223 | 3394 | $_GET['substep'] = 0; |
| 3224 | 3395 | // Make sure we move on! |
| 3225 | - if ($command_line) |
|
| 3226 | - return DeleteUpgrade(); |
|
| 3396 | + if ($command_line) { |
|
| 3397 | + return DeleteUpgrade(); |
|
| 3398 | + } |
|
| 3227 | 3399 | |
| 3228 | 3400 | return true; |
| 3229 | 3401 | } |
@@ -3243,14 +3415,16 @@ discard block |
||
| 3243 | 3415 | global $upcontext, $txt, $settings; |
| 3244 | 3416 | |
| 3245 | 3417 | // Don't call me twice! |
| 3246 | - if (!empty($upcontext['chmod_called'])) |
|
| 3247 | - return; |
|
| 3418 | + if (!empty($upcontext['chmod_called'])) { |
|
| 3419 | + return; |
|
| 3420 | + } |
|
| 3248 | 3421 | |
| 3249 | 3422 | $upcontext['chmod_called'] = true; |
| 3250 | 3423 | |
| 3251 | 3424 | // Nothing? |
| 3252 | - if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) |
|
| 3253 | - return; |
|
| 3425 | + if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) { |
|
| 3426 | + return; |
|
| 3427 | + } |
|
| 3254 | 3428 | |
| 3255 | 3429 | // Was it a problem with Windows? |
| 3256 | 3430 | if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess') |
@@ -3282,11 +3456,12 @@ discard block |
||
| 3282 | 3456 | content.write(\'<div class="windowbg description">\n\t\t\t<h4>', $txt['upgrade_ftp_files'], '</h4>\n\t\t\t\'); |
| 3283 | 3457 | content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');'; |
| 3284 | 3458 | |
| 3285 | - if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') |
|
| 3286 | - echo ' |
|
| 3459 | + if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') { |
|
| 3460 | + echo ' |
|
| 3287 | 3461 | content.write(\'<hr>\n\t\t\t\'); |
| 3288 | 3462 | content.write(\'<p>', $txt['upgrade_ftp_shell'], '</p>\n\t\t\t\'); |
| 3289 | 3463 | content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');'; |
| 3464 | + } |
|
| 3290 | 3465 | |
| 3291 | 3466 | echo ' |
| 3292 | 3467 | content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\'); |
@@ -3294,17 +3469,19 @@ discard block |
||
| 3294 | 3469 | } |
| 3295 | 3470 | </script>'; |
| 3296 | 3471 | |
| 3297 | - if (!empty($upcontext['chmod']['ftp_error'])) |
|
| 3298 | - echo ' |
|
| 3472 | + if (!empty($upcontext['chmod']['ftp_error'])) { |
|
| 3473 | + echo ' |
|
| 3299 | 3474 | <div class="error_message red"> |
| 3300 | 3475 | ', $txt['upgrade_ftp_error'], '<br><br> |
| 3301 | 3476 | <code>', $upcontext['chmod']['ftp_error'], '</code> |
| 3302 | 3477 | </div> |
| 3303 | 3478 | <br>'; |
| 3479 | + } |
|
| 3304 | 3480 | |
| 3305 | - if (empty($upcontext['chmod_in_form'])) |
|
| 3306 | - echo ' |
|
| 3481 | + if (empty($upcontext['chmod_in_form'])) { |
|
| 3482 | + echo ' |
|
| 3307 | 3483 | <form action="', $upcontext['form_url'], '" method="post">'; |
| 3484 | + } |
|
| 3308 | 3485 | |
| 3309 | 3486 | echo ' |
| 3310 | 3487 | <table width="520" border="0" align="center" style="margin-bottom: 1ex;"> |
@@ -3339,10 +3516,11 @@ discard block |
||
| 3339 | 3516 | <div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['ftp_connect'], '" class="button"></div> |
| 3340 | 3517 | </div>'; |
| 3341 | 3518 | |
| 3342 | - if (empty($upcontext['chmod_in_form'])) |
|
| 3343 | - echo ' |
|
| 3519 | + if (empty($upcontext['chmod_in_form'])) { |
|
| 3520 | + echo ' |
|
| 3344 | 3521 | </form>'; |
| 3345 | -} |
|
| 3522 | + } |
|
| 3523 | + } |
|
| 3346 | 3524 | |
| 3347 | 3525 | function template_upgrade_above() |
| 3348 | 3526 | { |
@@ -3402,9 +3580,10 @@ discard block |
||
| 3402 | 3580 | <h2>', $txt['upgrade_progress'], '</h2> |
| 3403 | 3581 | <ul>'; |
| 3404 | 3582 | |
| 3405 | - foreach ($upcontext['steps'] as $num => $step) |
|
| 3406 | - echo ' |
|
| 3583 | + foreach ($upcontext['steps'] as $num => $step) { |
|
| 3584 | + echo ' |
|
| 3407 | 3585 | <li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
| 3586 | + } |
|
| 3408 | 3587 | |
| 3409 | 3588 | echo ' |
| 3410 | 3589 | </ul> |
@@ -3417,8 +3596,8 @@ discard block |
||
| 3417 | 3596 | </div> |
| 3418 | 3597 | </div>'; |
| 3419 | 3598 | |
| 3420 | - if (isset($upcontext['step_progress'])) |
|
| 3421 | - echo ' |
|
| 3599 | + if (isset($upcontext['step_progress'])) { |
|
| 3600 | + echo ' |
|
| 3422 | 3601 | <br> |
| 3423 | 3602 | <br> |
| 3424 | 3603 | <div id="progress_bar_step"> |
@@ -3427,6 +3606,7 @@ discard block |
||
| 3427 | 3606 | <span>', $txt['upgrade_step_progress'], '</span> |
| 3428 | 3607 | </div> |
| 3429 | 3608 | </div>'; |
| 3609 | + } |
|
| 3430 | 3610 | |
| 3431 | 3611 | echo ' |
| 3432 | 3612 | <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> |
@@ -3457,32 +3637,36 @@ discard block |
||
| 3457 | 3637 | { |
| 3458 | 3638 | global $upcontext, $txt; |
| 3459 | 3639 | |
| 3460 | - if (!empty($upcontext['pause'])) |
|
| 3461 | - echo ' |
|
| 3640 | + if (!empty($upcontext['pause'])) { |
|
| 3641 | + echo ' |
|
| 3462 | 3642 | <em>', $txt['upgrade_incomplete'], '.</em><br> |
| 3463 | 3643 | |
| 3464 | 3644 | <h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2> |
| 3465 | 3645 | <h3> |
| 3466 | 3646 | ', $txt['upgrade_paused_overload'], ' |
| 3467 | 3647 | </h3>'; |
| 3648 | + } |
|
| 3468 | 3649 | |
| 3469 | - if (!empty($upcontext['custom_warning'])) |
|
| 3470 | - echo ' |
|
| 3650 | + if (!empty($upcontext['custom_warning'])) { |
|
| 3651 | + echo ' |
|
| 3471 | 3652 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3472 | 3653 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3473 | 3654 | <strong style="text-decoration: underline;">', $txt['upgrade_note'], '</strong><br> |
| 3474 | 3655 | <div style="padding-left: 6ex;">', $upcontext['custom_warning'], '</div> |
| 3475 | 3656 | </div>'; |
| 3657 | + } |
|
| 3476 | 3658 | |
| 3477 | 3659 | echo ' |
| 3478 | 3660 | <div class="righttext" style="margin: 1ex;">'; |
| 3479 | 3661 | |
| 3480 | - if (!empty($upcontext['continue'])) |
|
| 3481 | - echo ' |
|
| 3662 | + if (!empty($upcontext['continue'])) { |
|
| 3663 | + echo ' |
|
| 3482 | 3664 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button">'; |
| 3483 | - if (!empty($upcontext['skip'])) |
|
| 3484 | - echo ' |
|
| 3665 | + } |
|
| 3666 | + if (!empty($upcontext['skip'])) { |
|
| 3667 | + echo ' |
|
| 3485 | 3668 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button">'; |
| 3669 | + } |
|
| 3486 | 3670 | |
| 3487 | 3671 | echo ' |
| 3488 | 3672 | </div> |
@@ -3532,11 +3716,12 @@ discard block |
||
| 3532 | 3716 | echo '<', '?xml version="1.0" encoding="UTF-8"?', '> |
| 3533 | 3717 | <smf>'; |
| 3534 | 3718 | |
| 3535 | - if (!empty($upcontext['get_data'])) |
|
| 3536 | - foreach ($upcontext['get_data'] as $k => $v) |
|
| 3719 | + if (!empty($upcontext['get_data'])) { |
|
| 3720 | + foreach ($upcontext['get_data'] as $k => $v) |
|
| 3537 | 3721 | echo ' |
| 3538 | 3722 | <get key="', $k, '">', $v, '</get>'; |
| 3539 | -} |
|
| 3723 | + } |
|
| 3724 | + } |
|
| 3540 | 3725 | |
| 3541 | 3726 | function template_xml_below() |
| 3542 | 3727 | { |
@@ -3577,8 +3762,8 @@ discard block |
||
| 3577 | 3762 | template_chmod(); |
| 3578 | 3763 | |
| 3579 | 3764 | // For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade! |
| 3580 | - if ($upcontext['is_large_forum']) |
|
| 3581 | - echo ' |
|
| 3765 | + if ($upcontext['is_large_forum']) { |
|
| 3766 | + echo ' |
|
| 3582 | 3767 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3583 | 3768 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3584 | 3769 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3586,10 +3771,11 @@ discard block |
||
| 3586 | 3771 | ', $txt['upgrade_warning_lots_data'], ' |
| 3587 | 3772 | </div> |
| 3588 | 3773 | </div>'; |
| 3774 | + } |
|
| 3589 | 3775 | |
| 3590 | 3776 | // A warning message? |
| 3591 | - if (!empty($upcontext['warning'])) |
|
| 3592 | - echo ' |
|
| 3777 | + if (!empty($upcontext['warning'])) { |
|
| 3778 | + echo ' |
|
| 3593 | 3779 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3594 | 3780 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3595 | 3781 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3597,6 +3783,7 @@ discard block |
||
| 3597 | 3783 | ', $upcontext['warning'], ' |
| 3598 | 3784 | </div> |
| 3599 | 3785 | </div>'; |
| 3786 | + } |
|
| 3600 | 3787 | |
| 3601 | 3788 | // Paths are incorrect? |
| 3602 | 3789 | echo ' |
@@ -3612,20 +3799,22 @@ discard block |
||
| 3612 | 3799 | if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600)) |
| 3613 | 3800 | { |
| 3614 | 3801 | $ago = time() - $upcontext['started']; |
| 3615 | - if ($ago < 60) |
|
| 3616 | - $ago = $ago . ' seconds'; |
|
| 3617 | - elseif ($ago < 3600) |
|
| 3618 | - $ago = (int) ($ago / 60) . ' minutes'; |
|
| 3619 | - else |
|
| 3620 | - $ago = (int) ($ago / 3600) . ' hours'; |
|
| 3802 | + if ($ago < 60) { |
|
| 3803 | + $ago = $ago . ' seconds'; |
|
| 3804 | + } elseif ($ago < 3600) { |
|
| 3805 | + $ago = (int) ($ago / 60) . ' minutes'; |
|
| 3806 | + } else { |
|
| 3807 | + $ago = (int) ($ago / 3600) . ' hours'; |
|
| 3808 | + } |
|
| 3621 | 3809 | |
| 3622 | 3810 | $active = time() - $upcontext['updated']; |
| 3623 | - if ($active < 60) |
|
| 3624 | - $updated = $active . ' seconds'; |
|
| 3625 | - elseif ($active < 3600) |
|
| 3626 | - $updated = (int) ($active / 60) . ' minutes'; |
|
| 3627 | - else |
|
| 3628 | - $updated = (int) ($active / 3600) . ' hours'; |
|
| 3811 | + if ($active < 60) { |
|
| 3812 | + $updated = $active . ' seconds'; |
|
| 3813 | + } elseif ($active < 3600) { |
|
| 3814 | + $updated = (int) ($active / 60) . ' minutes'; |
|
| 3815 | + } else { |
|
| 3816 | + $updated = (int) ($active / 3600) . ' hours'; |
|
| 3817 | + } |
|
| 3629 | 3818 | |
| 3630 | 3819 | echo ' |
| 3631 | 3820 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
@@ -3634,16 +3823,18 @@ discard block |
||
| 3634 | 3823 | <div style="padding-left: 6ex;"> |
| 3635 | 3824 | "', $upcontext['user']['name'], '" has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.'; |
| 3636 | 3825 | |
| 3637 | - if ($active < 600) |
|
| 3638 | - echo ' |
|
| 3826 | + if ($active < 600) { |
|
| 3827 | + echo ' |
|
| 3639 | 3828 | ', $txt['upgrade_run_script'], ' ', $upcontext['user']['name'],' ', $txt['upgrade_run_script2'], ''; |
| 3829 | + } |
|
| 3640 | 3830 | |
| 3641 | - if ($active > $upcontext['inactive_timeout']) |
|
| 3642 | - echo ' |
|
| 3831 | + if ($active > $upcontext['inactive_timeout']) { |
|
| 3832 | + echo ' |
|
| 3643 | 3833 | <br><br>',$txt['upgrade_run'], ''; |
| 3644 | - else |
|
| 3645 | - echo ' |
|
| 3834 | + } else { |
|
| 3835 | + echo ' |
|
| 3646 | 3836 | <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!'); |
| 3837 | + } |
|
| 3647 | 3838 | |
| 3648 | 3839 | echo ' |
| 3649 | 3840 | </div> |
@@ -3659,9 +3850,10 @@ discard block |
||
| 3659 | 3850 | <td> |
| 3660 | 3851 | <input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', '>'; |
| 3661 | 3852 | |
| 3662 | - if (!empty($upcontext['username_incorrect'])) |
|
| 3663 | - echo ' |
|
| 3853 | + if (!empty($upcontext['username_incorrect'])) { |
|
| 3854 | + echo ' |
|
| 3664 | 3855 | <div class="smalltext" style="color: red;">', $txt['upgrade_wrong_username'], '</div>'; |
| 3856 | + } |
|
| 3665 | 3857 | |
| 3666 | 3858 | echo ' |
| 3667 | 3859 | </td> |
@@ -3672,9 +3864,10 @@ discard block |
||
| 3672 | 3864 | <input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', '> |
| 3673 | 3865 | <input type="hidden" name="hash_passwrd" value="">'; |
| 3674 | 3866 | |
| 3675 | - if (!empty($upcontext['password_failed'])) |
|
| 3676 | - echo ' |
|
| 3867 | + if (!empty($upcontext['password_failed'])) { |
|
| 3868 | + echo ' |
|
| 3677 | 3869 | <div class="smalltext" style="color: red;">', $txt['upgrade_wrong_password'], '</div>'; |
| 3870 | + } |
|
| 3678 | 3871 | |
| 3679 | 3872 | echo ' |
| 3680 | 3873 | </td> |
@@ -3745,8 +3938,8 @@ discard block |
||
| 3745 | 3938 | <form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">'; |
| 3746 | 3939 | |
| 3747 | 3940 | // Warning message? |
| 3748 | - if (!empty($upcontext['upgrade_options_warning'])) |
|
| 3749 | - echo ' |
|
| 3941 | + if (!empty($upcontext['upgrade_options_warning'])) { |
|
| 3942 | + echo ' |
|
| 3750 | 3943 | <div style="margin: 1ex; padding: 1ex; border: 1px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3751 | 3944 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3752 | 3945 | <strong style="text-decoration: underline;">Warning!</strong><br> |
@@ -3754,6 +3947,7 @@ discard block |
||
| 3754 | 3947 | ', $upcontext['upgrade_options_warning'], ' |
| 3755 | 3948 | </div> |
| 3756 | 3949 | </div>'; |
| 3950 | + } |
|
| 3757 | 3951 | |
| 3758 | 3952 | echo ' |
| 3759 | 3953 | <table> |
@@ -3796,8 +3990,8 @@ discard block |
||
| 3796 | 3990 | </td> |
| 3797 | 3991 | </tr>'; |
| 3798 | 3992 | |
| 3799 | - if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) |
|
| 3800 | - echo ' |
|
| 3993 | + if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) { |
|
| 3994 | + echo ' |
|
| 3801 | 3995 | <tr valign="top"> |
| 3802 | 3996 | <td width="2%"> |
| 3803 | 3997 | <input type="checkbox" name="delete_karma" id="delete_karma" value="1"> |
@@ -3806,6 +4000,7 @@ discard block |
||
| 3806 | 4000 | <label for="delete_karma">', $txt['upgrade_delete_karma'], '</label> |
| 3807 | 4001 | </td> |
| 3808 | 4002 | </tr>'; |
| 4003 | + } |
|
| 3809 | 4004 | |
| 3810 | 4005 | echo ' |
| 3811 | 4006 | <tr valign="top"> |
@@ -3843,10 +4038,11 @@ discard block |
||
| 3843 | 4038 | </div>'; |
| 3844 | 4039 | |
| 3845 | 4040 | // Dont any tables so far? |
| 3846 | - if (!empty($upcontext['previous_tables'])) |
|
| 3847 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4041 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4042 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 3848 | 4043 | echo ' |
| 3849 | 4044 | <br>', $txt['upgrade_completed_table'], ' "', $table, '".'; |
| 4045 | + } |
|
| 3850 | 4046 | |
| 3851 | 4047 | echo ' |
| 3852 | 4048 | <h3 id="current_tab_div">', $txt['upgrade_current_table'], ' "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
@@ -3883,12 +4079,13 @@ discard block |
||
| 3883 | 4079 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 3884 | 4080 | |
| 3885 | 4081 | // If debug flood the screen. |
| 3886 | - if ($is_debug) |
|
| 3887 | - echo ' |
|
| 4082 | + if ($is_debug) { |
|
| 4083 | + echo ' |
|
| 3888 | 4084 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 3889 | 4085 | |
| 3890 | 4086 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 3891 | 4087 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4088 | + } |
|
| 3892 | 4089 | |
| 3893 | 4090 | echo ' |
| 3894 | 4091 | // Get the next update... |
@@ -3921,8 +4118,9 @@ discard block |
||
| 3921 | 4118 | { |
| 3922 | 4119 | global $upcontext, $support_js, $is_debug, $timeLimitThreshold, $txt; |
| 3923 | 4120 | |
| 3924 | - if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) |
|
| 3925 | - $is_debug = true; |
|
| 4121 | + if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) { |
|
| 4122 | + $is_debug = true; |
|
| 4123 | + } |
|
| 3926 | 4124 | |
| 3927 | 4125 | echo ' |
| 3928 | 4126 | <h3>', $txt['upgrade_db_changes'], '</h3> |
@@ -3937,8 +4135,9 @@ discard block |
||
| 3937 | 4135 | { |
| 3938 | 4136 | foreach ($upcontext['actioned_items'] as $num => $item) |
| 3939 | 4137 | { |
| 3940 | - if ($num != 0) |
|
| 3941 | - echo ' Successful!'; |
|
| 4138 | + if ($num != 0) { |
|
| 4139 | + echo ' Successful!'; |
|
| 4140 | + } |
|
| 3942 | 4141 | echo '<br>' . $item; |
| 3943 | 4142 | } |
| 3944 | 4143 | if (!empty($upcontext['changes_complete'])) |
@@ -3951,28 +4150,32 @@ discard block |
||
| 3951 | 4150 | $seconds = intval($active % 60); |
| 3952 | 4151 | |
| 3953 | 4152 | $totalTime = ''; |
| 3954 | - if ($hours > 0) |
|
| 3955 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 3956 | - if ($minutes > 0) |
|
| 3957 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 3958 | - if ($seconds > 0) |
|
| 3959 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4153 | + if ($hours > 0) { |
|
| 4154 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4155 | + } |
|
| 4156 | + if ($minutes > 0) { |
|
| 4157 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4158 | + } |
|
| 4159 | + if ($seconds > 0) { |
|
| 4160 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4161 | + } |
|
| 3960 | 4162 | } |
| 3961 | 4163 | |
| 3962 | - if ($is_debug && !empty($totalTime)) |
|
| 3963 | - echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
| 3964 | - else |
|
| 3965 | - echo ' Successful!<br><br>'; |
|
| 4164 | + if ($is_debug && !empty($totalTime)) { |
|
| 4165 | + echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
| 4166 | + } else { |
|
| 4167 | + echo ' Successful!<br><br>'; |
|
| 4168 | + } |
|
| 3966 | 4169 | |
| 3967 | 4170 | echo '<span id="commess" style="font-weight: bold;">', $txt['upgrade_db_complete'], '</span><br>'; |
| 3968 | 4171 | } |
| 3969 | - } |
|
| 3970 | - else |
|
| 4172 | + } else |
|
| 3971 | 4173 | { |
| 3972 | 4174 | // Tell them how many files we have in total. |
| 3973 | - if ($upcontext['file_count'] > 1) |
|
| 3974 | - echo ' |
|
| 4175 | + if ($upcontext['file_count'] > 1) { |
|
| 4176 | + echo ' |
|
| 3975 | 4177 | <strong id="info1">', $txt['upgrade_script'], ' <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>'; |
| 4178 | + } |
|
| 3976 | 4179 | |
| 3977 | 4180 | echo ' |
| 3978 | 4181 | <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> |
@@ -3988,19 +4191,23 @@ discard block |
||
| 3988 | 4191 | $seconds = intval($active % 60); |
| 3989 | 4192 | |
| 3990 | 4193 | $totalTime = ''; |
| 3991 | - if ($hours > 0) |
|
| 3992 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 3993 | - if ($minutes > 0) |
|
| 3994 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 3995 | - if ($seconds > 0) |
|
| 3996 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4194 | + if ($hours > 0) { |
|
| 4195 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4196 | + } |
|
| 4197 | + if ($minutes > 0) { |
|
| 4198 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4199 | + } |
|
| 4200 | + if ($seconds > 0) { |
|
| 4201 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4202 | + } |
|
| 3997 | 4203 | } |
| 3998 | 4204 | |
| 3999 | 4205 | echo ' |
| 4000 | 4206 | <br><span id="upgradeCompleted">'; |
| 4001 | 4207 | |
| 4002 | - if (!empty($totalTime)) |
|
| 4003 | - echo 'Completed in ', $totalTime, '<br>'; |
|
| 4208 | + if (!empty($totalTime)) { |
|
| 4209 | + echo 'Completed in ', $totalTime, '<br>'; |
|
| 4210 | + } |
|
| 4004 | 4211 | |
| 4005 | 4212 | echo '</span> |
| 4006 | 4213 | <div id="debug_section" style="height: 59px; overflow: auto;"> |
@@ -4037,9 +4244,10 @@ discard block |
||
| 4037 | 4244 | var getData = ""; |
| 4038 | 4245 | var debugItems = ', $upcontext['debug_items'], ';'; |
| 4039 | 4246 | |
| 4040 | - if ($is_debug) |
|
| 4041 | - echo ' |
|
| 4247 | + if ($is_debug) { |
|
| 4248 | + echo ' |
|
| 4042 | 4249 | var upgradeStartTime = ' . $upcontext['started'] . ';'; |
| 4250 | + } |
|
| 4043 | 4251 | |
| 4044 | 4252 | echo ' |
| 4045 | 4253 | function getNextItem() |
@@ -4079,9 +4287,10 @@ discard block |
||
| 4079 | 4287 | document.getElementById("error_block").style.display = ""; |
| 4080 | 4288 | setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));'; |
| 4081 | 4289 | |
| 4082 | - if ($is_debug) |
|
| 4083 | - echo ' |
|
| 4290 | + if ($is_debug) { |
|
| 4291 | + echo ' |
|
| 4084 | 4292 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
| 4293 | + } |
|
| 4085 | 4294 | |
| 4086 | 4295 | echo ' |
| 4087 | 4296 | } |
@@ -4102,9 +4311,10 @@ discard block |
||
| 4102 | 4311 | document.getElementById("error_block").style.display = ""; |
| 4103 | 4312 | setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);'; |
| 4104 | 4313 | |
| 4105 | - if ($is_debug) |
|
| 4106 | - echo ' |
|
| 4314 | + if ($is_debug) { |
|
| 4315 | + echo ' |
|
| 4107 | 4316 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
| 4317 | + } |
|
| 4108 | 4318 | |
| 4109 | 4319 | echo ' |
| 4110 | 4320 | } |
@@ -4163,8 +4373,8 @@ discard block |
||
| 4163 | 4373 | if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ') |
| 4164 | 4374 | {'; |
| 4165 | 4375 | |
| 4166 | - if ($is_debug) |
|
| 4167 | - echo ' |
|
| 4376 | + if ($is_debug) { |
|
| 4377 | + echo ' |
|
| 4168 | 4378 | document.getElementById(\'debug_section\').style.display = "none"; |
| 4169 | 4379 | |
| 4170 | 4380 | var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue); |
@@ -4182,6 +4392,7 @@ discard block |
||
| 4182 | 4392 | totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : ""); |
| 4183 | 4393 | |
| 4184 | 4394 | setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);'; |
| 4395 | + } |
|
| 4185 | 4396 | |
| 4186 | 4397 | echo ' |
| 4187 | 4398 | |
@@ -4189,9 +4400,10 @@ discard block |
||
| 4189 | 4400 | document.getElementById(\'contbutt\').disabled = 0; |
| 4190 | 4401 | document.getElementById(\'database_done\').value = 1;'; |
| 4191 | 4402 | |
| 4192 | - if ($upcontext['file_count'] > 1) |
|
| 4193 | - echo ' |
|
| 4403 | + if ($upcontext['file_count'] > 1) { |
|
| 4404 | + echo ' |
|
| 4194 | 4405 | document.getElementById(\'info1\').style.display = "none";'; |
| 4406 | + } |
|
| 4195 | 4407 | |
| 4196 | 4408 | echo ' |
| 4197 | 4409 | document.getElementById(\'info2\').style.display = "none"; |
@@ -4204,9 +4416,10 @@ discard block |
||
| 4204 | 4416 | lastItem = 0; |
| 4205 | 4417 | prevFile = curFile;'; |
| 4206 | 4418 | |
| 4207 | - if ($is_debug) |
|
| 4208 | - echo ' |
|
| 4419 | + if ($is_debug) { |
|
| 4420 | + echo ' |
|
| 4209 | 4421 | setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');'; |
| 4422 | + } |
|
| 4210 | 4423 | |
| 4211 | 4424 | echo ' |
| 4212 | 4425 | getNextItem(); |
@@ -4214,8 +4427,8 @@ discard block |
||
| 4214 | 4427 | }'; |
| 4215 | 4428 | |
| 4216 | 4429 | // If debug scroll the screen. |
| 4217 | - if ($is_debug) |
|
| 4218 | - echo ' |
|
| 4430 | + if ($is_debug) { |
|
| 4431 | + echo ' |
|
| 4219 | 4432 | if (iLastSubStepProgress == -1) |
| 4220 | 4433 | { |
| 4221 | 4434 | // Give it consistent dots. |
@@ -4234,6 +4447,7 @@ discard block |
||
| 4234 | 4447 | |
| 4235 | 4448 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4236 | 4449 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4450 | + } |
|
| 4237 | 4451 | |
| 4238 | 4452 | echo ' |
| 4239 | 4453 | // Update the page. |
@@ -4294,9 +4508,10 @@ discard block |
||
| 4294 | 4508 | }'; |
| 4295 | 4509 | |
| 4296 | 4510 | // Start things off assuming we've not errored. |
| 4297 | - if (empty($upcontext['error_message'])) |
|
| 4298 | - echo ' |
|
| 4511 | + if (empty($upcontext['error_message'])) { |
|
| 4512 | + echo ' |
|
| 4299 | 4513 | getNextItem();'; |
| 4514 | + } |
|
| 4300 | 4515 | |
| 4301 | 4516 | echo ' |
| 4302 | 4517 | //# sourceURL=dynamicScript-dbch.js |
@@ -4314,18 +4529,21 @@ discard block |
||
| 4314 | 4529 | <item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item> |
| 4315 | 4530 | <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>'; |
| 4316 | 4531 | |
| 4317 | - if (!empty($upcontext['error_message'])) |
|
| 4318 | - echo ' |
|
| 4532 | + if (!empty($upcontext['error_message'])) { |
|
| 4533 | + echo ' |
|
| 4319 | 4534 | <error>', $upcontext['error_message'], '</error>'; |
| 4535 | + } |
|
| 4320 | 4536 | |
| 4321 | - if (!empty($upcontext['error_string'])) |
|
| 4322 | - echo ' |
|
| 4537 | + if (!empty($upcontext['error_string'])) { |
|
| 4538 | + echo ' |
|
| 4323 | 4539 | <sql>', $upcontext['error_string'], '</sql>'; |
| 4540 | + } |
|
| 4324 | 4541 | |
| 4325 | - if ($is_debug) |
|
| 4326 | - echo ' |
|
| 4542 | + if ($is_debug) { |
|
| 4543 | + echo ' |
|
| 4327 | 4544 | <curtime>', time(), '</curtime>'; |
| 4328 | -} |
|
| 4545 | + } |
|
| 4546 | + } |
|
| 4329 | 4547 | |
| 4330 | 4548 | // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications.... |
| 4331 | 4549 | function template_convert_utf8() |
@@ -4344,18 +4562,20 @@ discard block |
||
| 4344 | 4562 | </div>'; |
| 4345 | 4563 | |
| 4346 | 4564 | // Done any tables so far? |
| 4347 | - if (!empty($upcontext['previous_tables'])) |
|
| 4348 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4565 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4566 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4349 | 4567 | echo ' |
| 4350 | 4568 | <br>', $txt['upgrade_completed_table'], ' "', $table, '".'; |
| 4569 | + } |
|
| 4351 | 4570 | |
| 4352 | 4571 | echo ' |
| 4353 | 4572 | <h3 id="current_tab_div">', $txt['upgrade_current_table'], ' "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3>'; |
| 4354 | 4573 | |
| 4355 | 4574 | // If we dropped their index, let's let them know |
| 4356 | - if ($upcontext['dropping_index']) |
|
| 4357 | - echo ' |
|
| 4575 | + if ($upcontext['dropping_index']) { |
|
| 4576 | + echo ' |
|
| 4358 | 4577 | <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>'; |
| 4578 | + } |
|
| 4359 | 4579 | |
| 4360 | 4580 | // Completion notification |
| 4361 | 4581 | echo ' |
@@ -4392,12 +4612,13 @@ discard block |
||
| 4392 | 4612 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4393 | 4613 | |
| 4394 | 4614 | // If debug flood the screen. |
| 4395 | - if ($is_debug) |
|
| 4396 | - echo ' |
|
| 4615 | + if ($is_debug) { |
|
| 4616 | + echo ' |
|
| 4397 | 4617 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 4398 | 4618 | |
| 4399 | 4619 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4400 | 4620 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4621 | + } |
|
| 4401 | 4622 | |
| 4402 | 4623 | echo ' |
| 4403 | 4624 | // Get the next update... |
@@ -4445,19 +4666,21 @@ discard block |
||
| 4445 | 4666 | </div>'; |
| 4446 | 4667 | |
| 4447 | 4668 | // Dont any tables so far? |
| 4448 | - if (!empty($upcontext['previous_tables'])) |
|
| 4449 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4669 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4670 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4450 | 4671 | echo ' |
| 4451 | 4672 | <br>', $txt['upgrade_completed_table'], ' "', $table, '".'; |
| 4673 | + } |
|
| 4452 | 4674 | |
| 4453 | 4675 | echo ' |
| 4454 | 4676 | <h3 id="current_tab_div">', $txt['upgrade_current_table'], ' "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
| 4455 | 4677 | <br><span id="commess" style="font-weight: bold; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">', $txt['upgrade_json_completed'], '</span>'; |
| 4456 | 4678 | |
| 4457 | 4679 | // Try to make sure substep was reset. |
| 4458 | - if ($upcontext['cur_table_num'] == $upcontext['table_count']) |
|
| 4459 | - echo ' |
|
| 4680 | + if ($upcontext['cur_table_num'] == $upcontext['table_count']) { |
|
| 4681 | + echo ' |
|
| 4460 | 4682 | <input type="hidden" name="substep" id="substep" value="0">'; |
| 4683 | + } |
|
| 4461 | 4684 | |
| 4462 | 4685 | // Continue please! |
| 4463 | 4686 | $upcontext['continue'] = $support_js ? 2 : 1; |
@@ -4490,12 +4713,13 @@ discard block |
||
| 4490 | 4713 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4491 | 4714 | |
| 4492 | 4715 | // If debug flood the screen. |
| 4493 | - if ($is_debug) |
|
| 4494 | - echo ' |
|
| 4716 | + if ($is_debug) { |
|
| 4717 | + echo ' |
|
| 4495 | 4718 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>', $txt['upgrade_completed_table'], ' "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 4496 | 4719 | |
| 4497 | 4720 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4498 | 4721 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4722 | + } |
|
| 4499 | 4723 | |
| 4500 | 4724 | echo ' |
| 4501 | 4725 | // Get the next update... |
@@ -4531,8 +4755,8 @@ discard block |
||
| 4531 | 4755 | <h3>', $txt['upgrade_done'], ' <a href="', $boardurl, '/index.php">', $txt['upgrade_done2'], '</a>. ', $txt['upgrade_done2'], '</h3> |
| 4532 | 4756 | <form action="', $boardurl, '/index.php">'; |
| 4533 | 4757 | |
| 4534 | - if (!empty($upcontext['can_delete_script'])) |
|
| 4535 | - echo ' |
|
| 4758 | + if (!empty($upcontext['can_delete_script'])) { |
|
| 4759 | + echo ' |
|
| 4536 | 4760 | <label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete(this);"> ', $txt['upgrade_delete_now'], '</label> ', $txt['upgrade_delete_server'], ' |
| 4537 | 4761 | <script> |
| 4538 | 4762 | function doTheDelete(theCheck) |
@@ -4544,6 +4768,7 @@ discard block |
||
| 4544 | 4768 | } |
| 4545 | 4769 | </script> |
| 4546 | 4770 | <img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>'; |
| 4771 | + } |
|
| 4547 | 4772 | |
| 4548 | 4773 | $active = time() - $upcontext['started']; |
| 4549 | 4774 | $hours = floor($active / 3600); |
@@ -4553,16 +4778,20 @@ discard block |
||
| 4553 | 4778 | if ($is_debug) |
| 4554 | 4779 | { |
| 4555 | 4780 | $totalTime = ''; |
| 4556 | - if ($hours > 0) |
|
| 4557 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4558 | - if ($minutes > 0) |
|
| 4559 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4560 | - if ($seconds > 0) |
|
| 4561 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4781 | + if ($hours > 0) { |
|
| 4782 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4783 | + } |
|
| 4784 | + if ($minutes > 0) { |
|
| 4785 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4786 | + } |
|
| 4787 | + if ($seconds > 0) { |
|
| 4788 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4789 | + } |
|
| 4562 | 4790 | } |
| 4563 | 4791 | |
| 4564 | - if ($is_debug && !empty($totalTime)) |
|
| 4565 | - echo '<br> ', $txt['upgrade_completed_time'], ' ', $totalTime, '<br><br>'; |
|
| 4792 | + if ($is_debug && !empty($totalTime)) { |
|
| 4793 | + echo '<br> ', $txt['upgrade_completed_time'], ' ', $totalTime, '<br><br>'; |
|
| 4794 | + } |
|
| 4566 | 4795 | |
| 4567 | 4796 | echo '<br> |
| 4568 | 4797 | ', $txt['upgrade_problems'], '<br> |
@@ -4589,8 +4818,9 @@ discard block |
||
| 4589 | 4818 | |
| 4590 | 4819 | $current_substep = $_GET['substep']; |
| 4591 | 4820 | |
| 4592 | - if (empty($_GET['a'])) |
|
| 4593 | - $_GET['a'] = 0; |
|
| 4821 | + if (empty($_GET['a'])) { |
|
| 4822 | + $_GET['a'] = 0; |
|
| 4823 | + } |
|
| 4594 | 4824 | $step_progress['name'] = 'Converting ips'; |
| 4595 | 4825 | $step_progress['current'] = $_GET['a']; |
| 4596 | 4826 | |
@@ -4633,16 +4863,19 @@ discard block |
||
| 4633 | 4863 | 'empty' => '', |
| 4634 | 4864 | 'limit' => $limit, |
| 4635 | 4865 | )); |
| 4636 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 4637 | - $arIp[] = $row[$oldCol]; |
|
| 4866 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 4867 | + $arIp[] = $row[$oldCol]; |
|
| 4868 | + } |
|
| 4638 | 4869 | $smcFunc['db_free_result']($request); |
| 4639 | 4870 | |
| 4640 | 4871 | // Special case, null ip could keep us in a loop. |
| 4641 | - if (is_null($arIp[0])) |
|
| 4642 | - unset($arIp[0]); |
|
| 4872 | + if (is_null($arIp[0])) { |
|
| 4873 | + unset($arIp[0]); |
|
| 4874 | + } |
|
| 4643 | 4875 | |
| 4644 | - if (empty($arIp)) |
|
| 4645 | - $is_done = true; |
|
| 4876 | + if (empty($arIp)) { |
|
| 4877 | + $is_done = true; |
|
| 4878 | + } |
|
| 4646 | 4879 | |
| 4647 | 4880 | $updates = array(); |
| 4648 | 4881 | $cases = array(); |
@@ -4651,16 +4884,18 @@ discard block |
||
| 4651 | 4884 | { |
| 4652 | 4885 | $arIp[$i] = trim($arIp[$i]); |
| 4653 | 4886 | |
| 4654 | - if (empty($arIp[$i])) |
|
| 4655 | - continue; |
|
| 4887 | + if (empty($arIp[$i])) { |
|
| 4888 | + continue; |
|
| 4889 | + } |
|
| 4656 | 4890 | |
| 4657 | 4891 | $updates['ip' . $i] = $arIp[$i]; |
| 4658 | 4892 | $cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}'; |
| 4659 | 4893 | |
| 4660 | 4894 | if ($setSize > 0 && $i % $setSize === 0) |
| 4661 | 4895 | { |
| 4662 | - if (count($updates) == 1) |
|
| 4663 | - continue; |
|
| 4896 | + if (count($updates) == 1) { |
|
| 4897 | + continue; |
|
| 4898 | + } |
|
| 4664 | 4899 | |
| 4665 | 4900 | $updates['whereSet'] = array_values($updates); |
| 4666 | 4901 | $smcFunc['db_query']('', ' |
@@ -4694,8 +4929,7 @@ discard block |
||
| 4694 | 4929 | 'ip' => $ip |
| 4695 | 4930 | )); |
| 4696 | 4931 | } |
| 4697 | - } |
|
| 4698 | - else |
|
| 4932 | + } else |
|
| 4699 | 4933 | { |
| 4700 | 4934 | $updates['whereSet'] = array_values($updates); |
| 4701 | 4935 | $smcFunc['db_query']('', ' |
@@ -4709,9 +4943,9 @@ discard block |
||
| 4709 | 4943 | $updates |
| 4710 | 4944 | ); |
| 4711 | 4945 | } |
| 4946 | + } else { |
|
| 4947 | + $is_done = true; |
|
| 4712 | 4948 | } |
| 4713 | - else |
|
| 4714 | - $is_done = true; |
|
| 4715 | 4949 | |
| 4716 | 4950 | $_GET['a'] += $limit; |
| 4717 | 4951 | $step_progress['current'] = $_GET['a']; |
@@ -4737,10 +4971,11 @@ discard block |
||
| 4737 | 4971 | |
| 4738 | 4972 | $columns = $smcFunc['db_list_columns']($targetTable, true); |
| 4739 | 4973 | |
| 4740 | - if (isset($columns[$column])) |
|
| 4741 | - return $columns[$column]; |
|
| 4742 | - else |
|
| 4743 | - return null; |
|
| 4744 | -} |
|
| 4974 | + if (isset($columns[$column])) { |
|
| 4975 | + return $columns[$column]; |
|
| 4976 | + } else { |
|
| 4977 | + return null; |
|
| 4978 | + } |
|
| 4979 | + } |
|
| 4745 | 4980 | |
| 4746 | 4981 | ?> |
| 4747 | 4982 | \ No newline at end of file |