@@ -3122,94 +3122,94 @@ |
||
| 3122 | 3122 | // Translation table for the character sets not native for MySQL. |
| 3123 | 3123 | $translation_tables = array( |
| 3124 | 3124 | 'windows-1255' => array( |
| 3125 | - '0x81' => '\'\'', '0x8A' => '\'\'', '0x8C' => '\'\'', |
|
| 3126 | - '0x8D' => '\'\'', '0x8E' => '\'\'', '0x8F' => '\'\'', |
|
| 3127 | - '0x90' => '\'\'', '0x9A' => '\'\'', '0x9C' => '\'\'', |
|
| 3128 | - '0x9D' => '\'\'', '0x9E' => '\'\'', '0x9F' => '\'\'', |
|
| 3129 | - '0xCA' => '\'\'', '0xD9' => '\'\'', '0xDA' => '\'\'', |
|
| 3130 | - '0xDB' => '\'\'', '0xDC' => '\'\'', '0xDD' => '\'\'', |
|
| 3131 | - '0xDE' => '\'\'', '0xDF' => '\'\'', '0xFB' => '0xD792', |
|
| 3132 | - '0xFC' => '0xE282AC', '0xFF' => '0xD6B2', '0xC2' => '0xFF', |
|
| 3133 | - '0x80' => '0xFC', '0xE2' => '0xFB', '0xA0' => '0xC2A0', |
|
| 3134 | - '0xA1' => '0xC2A1', '0xA2' => '0xC2A2', '0xA3' => '0xC2A3', |
|
| 3135 | - '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
| 3136 | - '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
| 3137 | - '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
| 3138 | - '0xAF' => '0xC2AF', '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', |
|
| 3139 | - '0xB2' => '0xC2B2', '0xB3' => '0xC2B3', '0xB4' => '0xC2B4', |
|
| 3140 | - '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
| 3141 | - '0xB8' => '0xC2B8', '0xB9' => '0xC2B9', '0xBB' => '0xC2BB', |
|
| 3142 | - '0xBC' => '0xC2BC', '0xBD' => '0xC2BD', '0xBE' => '0xC2BE', |
|
| 3143 | - '0xBF' => '0xC2BF', '0xD7' => '0xD7B3', '0xD1' => '0xD781', |
|
| 3144 | - '0xD4' => '0xD7B0', '0xD5' => '0xD7B1', '0xD6' => '0xD7B2', |
|
| 3145 | - '0xE0' => '0xD790', '0xEA' => '0xD79A', '0xEC' => '0xD79C', |
|
| 3146 | - '0xED' => '0xD79D', '0xEE' => '0xD79E', '0xEF' => '0xD79F', |
|
| 3147 | - '0xF0' => '0xD7A0', '0xF1' => '0xD7A1', '0xF2' => '0xD7A2', |
|
| 3148 | - '0xF3' => '0xD7A3', '0xF5' => '0xD7A5', '0xF6' => '0xD7A6', |
|
| 3149 | - '0xF7' => '0xD7A7', '0xF8' => '0xD7A8', '0xF9' => '0xD7A9', |
|
| 3150 | - '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
| 3151 | - '0x86' => '0xE280A0', '0x87' => '0xE280A1', '0x89' => '0xE280B0', |
|
| 3152 | - '0x8B' => '0xE280B9', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
| 3153 | - '0x95' => '0xE280A2', '0x97' => '0xE28094', '0x99' => '0xE284A2', |
|
| 3154 | - '0xC0' => '0xD6B0', '0xC1' => '0xD6B1', '0xC3' => '0xD6B3', |
|
| 3155 | - '0xC4' => '0xD6B4', '0xC5' => '0xD6B5', '0xC6' => '0xD6B6', |
|
| 3156 | - '0xC7' => '0xD6B7', '0xC8' => '0xD6B8', '0xC9' => '0xD6B9', |
|
| 3157 | - '0xCB' => '0xD6BB', '0xCC' => '0xD6BC', '0xCD' => '0xD6BD', |
|
| 3158 | - '0xCE' => '0xD6BE', '0xCF' => '0xD6BF', '0xD0' => '0xD780', |
|
| 3159 | - '0xD2' => '0xD782', '0xE3' => '0xD793', '0xE4' => '0xD794', |
|
| 3160 | - '0xE5' => '0xD795', '0xE7' => '0xD797', '0xE9' => '0xD799', |
|
| 3161 | - '0xFD' => '0xE2808E', '0xFE' => '0xE2808F', '0x92' => '0xE28099', |
|
| 3162 | - '0x83' => '0xC692', '0xD3' => '0xD783', '0x88' => '0xCB86', |
|
| 3163 | - '0x98' => '0xCB9C', '0x91' => '0xE28098', '0x96' => '0xE28093', |
|
| 3164 | - '0xBA' => '0xC3B7', '0x9B' => '0xE280BA', '0xAA' => '0xC397', |
|
| 3165 | - '0xA4' => '0xE282AA', '0xE1' => '0xD791', '0xE6' => '0xD796', |
|
| 3166 | - '0xE8' => '0xD798', '0xEB' => '0xD79B', '0xF4' => '0xD7A4', |
|
| 3125 | + '0x81' => '\'\'', '0x8A' => '\'\'', '0x8C' => '\'\'', |
|
| 3126 | + '0x8D' => '\'\'', '0x8E' => '\'\'', '0x8F' => '\'\'', |
|
| 3127 | + '0x90' => '\'\'', '0x9A' => '\'\'', '0x9C' => '\'\'', |
|
| 3128 | + '0x9D' => '\'\'', '0x9E' => '\'\'', '0x9F' => '\'\'', |
|
| 3129 | + '0xCA' => '\'\'', '0xD9' => '\'\'', '0xDA' => '\'\'', |
|
| 3130 | + '0xDB' => '\'\'', '0xDC' => '\'\'', '0xDD' => '\'\'', |
|
| 3131 | + '0xDE' => '\'\'', '0xDF' => '\'\'', '0xFB' => '0xD792', |
|
| 3132 | + '0xFC' => '0xE282AC', '0xFF' => '0xD6B2', '0xC2' => '0xFF', |
|
| 3133 | + '0x80' => '0xFC', '0xE2' => '0xFB', '0xA0' => '0xC2A0', |
|
| 3134 | + '0xA1' => '0xC2A1', '0xA2' => '0xC2A2', '0xA3' => '0xC2A3', |
|
| 3135 | + '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
| 3136 | + '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
| 3137 | + '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
| 3138 | + '0xAF' => '0xC2AF', '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', |
|
| 3139 | + '0xB2' => '0xC2B2', '0xB3' => '0xC2B3', '0xB4' => '0xC2B4', |
|
| 3140 | + '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
| 3141 | + '0xB8' => '0xC2B8', '0xB9' => '0xC2B9', '0xBB' => '0xC2BB', |
|
| 3142 | + '0xBC' => '0xC2BC', '0xBD' => '0xC2BD', '0xBE' => '0xC2BE', |
|
| 3143 | + '0xBF' => '0xC2BF', '0xD7' => '0xD7B3', '0xD1' => '0xD781', |
|
| 3144 | + '0xD4' => '0xD7B0', '0xD5' => '0xD7B1', '0xD6' => '0xD7B2', |
|
| 3145 | + '0xE0' => '0xD790', '0xEA' => '0xD79A', '0xEC' => '0xD79C', |
|
| 3146 | + '0xED' => '0xD79D', '0xEE' => '0xD79E', '0xEF' => '0xD79F', |
|
| 3147 | + '0xF0' => '0xD7A0', '0xF1' => '0xD7A1', '0xF2' => '0xD7A2', |
|
| 3148 | + '0xF3' => '0xD7A3', '0xF5' => '0xD7A5', '0xF6' => '0xD7A6', |
|
| 3149 | + '0xF7' => '0xD7A7', '0xF8' => '0xD7A8', '0xF9' => '0xD7A9', |
|
| 3150 | + '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
| 3151 | + '0x86' => '0xE280A0', '0x87' => '0xE280A1', '0x89' => '0xE280B0', |
|
| 3152 | + '0x8B' => '0xE280B9', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
| 3153 | + '0x95' => '0xE280A2', '0x97' => '0xE28094', '0x99' => '0xE284A2', |
|
| 3154 | + '0xC0' => '0xD6B0', '0xC1' => '0xD6B1', '0xC3' => '0xD6B3', |
|
| 3155 | + '0xC4' => '0xD6B4', '0xC5' => '0xD6B5', '0xC6' => '0xD6B6', |
|
| 3156 | + '0xC7' => '0xD6B7', '0xC8' => '0xD6B8', '0xC9' => '0xD6B9', |
|
| 3157 | + '0xCB' => '0xD6BB', '0xCC' => '0xD6BC', '0xCD' => '0xD6BD', |
|
| 3158 | + '0xCE' => '0xD6BE', '0xCF' => '0xD6BF', '0xD0' => '0xD780', |
|
| 3159 | + '0xD2' => '0xD782', '0xE3' => '0xD793', '0xE4' => '0xD794', |
|
| 3160 | + '0xE5' => '0xD795', '0xE7' => '0xD797', '0xE9' => '0xD799', |
|
| 3161 | + '0xFD' => '0xE2808E', '0xFE' => '0xE2808F', '0x92' => '0xE28099', |
|
| 3162 | + '0x83' => '0xC692', '0xD3' => '0xD783', '0x88' => '0xCB86', |
|
| 3163 | + '0x98' => '0xCB9C', '0x91' => '0xE28098', '0x96' => '0xE28093', |
|
| 3164 | + '0xBA' => '0xC3B7', '0x9B' => '0xE280BA', '0xAA' => '0xC397', |
|
| 3165 | + '0xA4' => '0xE282AA', '0xE1' => '0xD791', '0xE6' => '0xD796', |
|
| 3166 | + '0xE8' => '0xD798', '0xEB' => '0xD79B', '0xF4' => '0xD7A4', |
|
| 3167 | 3167 | '0xFA' => '0xD7AA', |
| 3168 | 3168 | ), |
| 3169 | 3169 | 'windows-1253' => array( |
| 3170 | - '0x81' => '\'\'', '0x88' => '\'\'', '0x8A' => '\'\'', |
|
| 3171 | - '0x8C' => '\'\'', '0x8D' => '\'\'', '0x8E' => '\'\'', |
|
| 3172 | - '0x8F' => '\'\'', '0x90' => '\'\'', '0x98' => '\'\'', |
|
| 3173 | - '0x9A' => '\'\'', '0x9C' => '\'\'', '0x9D' => '\'\'', |
|
| 3174 | - '0x9E' => '\'\'', '0x9F' => '\'\'', '0xAA' => '\'\'', |
|
| 3175 | - '0xD2' => '0xE282AC', '0xFF' => '0xCE92', '0xCE' => '0xCE9E', |
|
| 3176 | - '0xB8' => '0xCE88', '0xBA' => '0xCE8A', '0xBC' => '0xCE8C', |
|
| 3177 | - '0xBE' => '0xCE8E', '0xBF' => '0xCE8F', '0xC0' => '0xCE90', |
|
| 3178 | - '0xC8' => '0xCE98', '0xCA' => '0xCE9A', '0xCC' => '0xCE9C', |
|
| 3179 | - '0xCD' => '0xCE9D', '0xCF' => '0xCE9F', '0xDA' => '0xCEAA', |
|
| 3180 | - '0xE8' => '0xCEB8', '0xEA' => '0xCEBA', '0xEC' => '0xCEBC', |
|
| 3181 | - '0xEE' => '0xCEBE', '0xEF' => '0xCEBF', '0xC2' => '0xFF', |
|
| 3182 | - '0xBD' => '0xC2BD', '0xED' => '0xCEBD', '0xB2' => '0xC2B2', |
|
| 3183 | - '0xA0' => '0xC2A0', '0xA3' => '0xC2A3', '0xA4' => '0xC2A4', |
|
| 3184 | - '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
| 3185 | - '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
| 3186 | - '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
| 3187 | - '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', '0xB3' => '0xC2B3', |
|
| 3188 | - '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
| 3189 | - '0xBB' => '0xC2BB', '0xE2' => '0xCEB2', '0x80' => '0xD2', |
|
| 3190 | - '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
| 3191 | - '0x86' => '0xE280A0', '0xA1' => '0xCE85', '0xA2' => '0xCE86', |
|
| 3192 | - '0x87' => '0xE280A1', '0x89' => '0xE280B0', '0xB9' => '0xCE89', |
|
| 3193 | - '0x8B' => '0xE280B9', '0x91' => '0xE28098', '0x99' => '0xE284A2', |
|
| 3194 | - '0x92' => '0xE28099', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
| 3195 | - '0x95' => '0xE280A2', '0x96' => '0xE28093', '0x97' => '0xE28094', |
|
| 3196 | - '0x9B' => '0xE280BA', '0xAF' => '0xE28095', '0xB4' => '0xCE84', |
|
| 3197 | - '0xC1' => '0xCE91', '0xC3' => '0xCE93', '0xC4' => '0xCE94', |
|
| 3198 | - '0xC5' => '0xCE95', '0xC6' => '0xCE96', '0x83' => '0xC692', |
|
| 3199 | - '0xC7' => '0xCE97', '0xC9' => '0xCE99', '0xCB' => '0xCE9B', |
|
| 3200 | - '0xD0' => '0xCEA0', '0xD1' => '0xCEA1', '0xD3' => '0xCEA3', |
|
| 3201 | - '0xD4' => '0xCEA4', '0xD5' => '0xCEA5', '0xD6' => '0xCEA6', |
|
| 3202 | - '0xD7' => '0xCEA7', '0xD8' => '0xCEA8', '0xD9' => '0xCEA9', |
|
| 3203 | - '0xDB' => '0xCEAB', '0xDC' => '0xCEAC', '0xDD' => '0xCEAD', |
|
| 3204 | - '0xDE' => '0xCEAE', '0xDF' => '0xCEAF', '0xE0' => '0xCEB0', |
|
| 3205 | - '0xE1' => '0xCEB1', '0xE3' => '0xCEB3', '0xE4' => '0xCEB4', |
|
| 3206 | - '0xE5' => '0xCEB5', '0xE6' => '0xCEB6', '0xE7' => '0xCEB7', |
|
| 3207 | - '0xE9' => '0xCEB9', '0xEB' => '0xCEBB', '0xF0' => '0xCF80', |
|
| 3208 | - '0xF1' => '0xCF81', '0xF2' => '0xCF82', '0xF3' => '0xCF83', |
|
| 3209 | - '0xF4' => '0xCF84', '0xF5' => '0xCF85', '0xF6' => '0xCF86', |
|
| 3210 | - '0xF7' => '0xCF87', '0xF8' => '0xCF88', '0xF9' => '0xCF89', |
|
| 3211 | - '0xFA' => '0xCF8A', '0xFB' => '0xCF8B', '0xFC' => '0xCF8C', |
|
| 3212 | - '0xFD' => '0xCF8D', '0xFE' => '0xCF8E', |
|
| 3170 | + '0x81' => '\'\'', '0x88' => '\'\'', '0x8A' => '\'\'', |
|
| 3171 | + '0x8C' => '\'\'', '0x8D' => '\'\'', '0x8E' => '\'\'', |
|
| 3172 | + '0x8F' => '\'\'', '0x90' => '\'\'', '0x98' => '\'\'', |
|
| 3173 | + '0x9A' => '\'\'', '0x9C' => '\'\'', '0x9D' => '\'\'', |
|
| 3174 | + '0x9E' => '\'\'', '0x9F' => '\'\'', '0xAA' => '\'\'', |
|
| 3175 | + '0xD2' => '0xE282AC', '0xFF' => '0xCE92', '0xCE' => '0xCE9E', |
|
| 3176 | + '0xB8' => '0xCE88', '0xBA' => '0xCE8A', '0xBC' => '0xCE8C', |
|
| 3177 | + '0xBE' => '0xCE8E', '0xBF' => '0xCE8F', '0xC0' => '0xCE90', |
|
| 3178 | + '0xC8' => '0xCE98', '0xCA' => '0xCE9A', '0xCC' => '0xCE9C', |
|
| 3179 | + '0xCD' => '0xCE9D', '0xCF' => '0xCE9F', '0xDA' => '0xCEAA', |
|
| 3180 | + '0xE8' => '0xCEB8', '0xEA' => '0xCEBA', '0xEC' => '0xCEBC', |
|
| 3181 | + '0xEE' => '0xCEBE', '0xEF' => '0xCEBF', '0xC2' => '0xFF', |
|
| 3182 | + '0xBD' => '0xC2BD', '0xED' => '0xCEBD', '0xB2' => '0xC2B2', |
|
| 3183 | + '0xA0' => '0xC2A0', '0xA3' => '0xC2A3', '0xA4' => '0xC2A4', |
|
| 3184 | + '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
| 3185 | + '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
| 3186 | + '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
| 3187 | + '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', '0xB3' => '0xC2B3', |
|
| 3188 | + '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
| 3189 | + '0xBB' => '0xC2BB', '0xE2' => '0xCEB2', '0x80' => '0xD2', |
|
| 3190 | + '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
| 3191 | + '0x86' => '0xE280A0', '0xA1' => '0xCE85', '0xA2' => '0xCE86', |
|
| 3192 | + '0x87' => '0xE280A1', '0x89' => '0xE280B0', '0xB9' => '0xCE89', |
|
| 3193 | + '0x8B' => '0xE280B9', '0x91' => '0xE28098', '0x99' => '0xE284A2', |
|
| 3194 | + '0x92' => '0xE28099', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
| 3195 | + '0x95' => '0xE280A2', '0x96' => '0xE28093', '0x97' => '0xE28094', |
|
| 3196 | + '0x9B' => '0xE280BA', '0xAF' => '0xE28095', '0xB4' => '0xCE84', |
|
| 3197 | + '0xC1' => '0xCE91', '0xC3' => '0xCE93', '0xC4' => '0xCE94', |
|
| 3198 | + '0xC5' => '0xCE95', '0xC6' => '0xCE96', '0x83' => '0xC692', |
|
| 3199 | + '0xC7' => '0xCE97', '0xC9' => '0xCE99', '0xCB' => '0xCE9B', |
|
| 3200 | + '0xD0' => '0xCEA0', '0xD1' => '0xCEA1', '0xD3' => '0xCEA3', |
|
| 3201 | + '0xD4' => '0xCEA4', '0xD5' => '0xCEA5', '0xD6' => '0xCEA6', |
|
| 3202 | + '0xD7' => '0xCEA7', '0xD8' => '0xCEA8', '0xD9' => '0xCEA9', |
|
| 3203 | + '0xDB' => '0xCEAB', '0xDC' => '0xCEAC', '0xDD' => '0xCEAD', |
|
| 3204 | + '0xDE' => '0xCEAE', '0xDF' => '0xCEAF', '0xE0' => '0xCEB0', |
|
| 3205 | + '0xE1' => '0xCEB1', '0xE3' => '0xCEB3', '0xE4' => '0xCEB4', |
|
| 3206 | + '0xE5' => '0xCEB5', '0xE6' => '0xCEB6', '0xE7' => '0xCEB7', |
|
| 3207 | + '0xE9' => '0xCEB9', '0xEB' => '0xCEBB', '0xF0' => '0xCF80', |
|
| 3208 | + '0xF1' => '0xCF81', '0xF2' => '0xCF82', '0xF3' => '0xCF83', |
|
| 3209 | + '0xF4' => '0xCF84', '0xF5' => '0xCF85', '0xF6' => '0xCF86', |
|
| 3210 | + '0xF7' => '0xCF87', '0xF8' => '0xCF88', '0xF9' => '0xCF89', |
|
| 3211 | + '0xFA' => '0xCF8A', '0xFB' => '0xCF8B', '0xFC' => '0xCF8C', |
|
| 3212 | + '0xFD' => '0xCF8D', '0xFE' => '0xCF8E', |
|
| 3213 | 3213 | ), |
| 3214 | 3214 | ); |
| 3215 | 3215 | |
@@ -66,11 +66,14 @@ discard block |
||
| 66 | 66 | ini_set('default_socket_timeout', 900); |
| 67 | 67 | } |
| 68 | 68 | // Clean the upgrade path if this is from the client. |
| 69 | -if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) |
|
| 70 | - for ($i = 1; $i < $_SERVER['argc']; $i++) |
|
| 69 | +if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) { |
|
| 70 | + for ($i = 1; |
|
| 71 | +} |
|
| 72 | +$i < $_SERVER['argc']; $i++) |
|
| 71 | 73 | { |
| 72 | - if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) |
|
| 73 | - $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
| 74 | + if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) { |
|
| 75 | + $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
| 76 | + } |
|
| 74 | 77 | } |
| 75 | 78 | |
| 76 | 79 | // Are we from the client? |
@@ -78,9 +81,9 @@ discard block |
||
| 78 | 81 | { |
| 79 | 82 | $command_line = true; |
| 80 | 83 | $disable_security = 1; |
| 81 | -} |
|
| 82 | -else |
|
| 84 | +} else { |
|
| 83 | 85 | $command_line = false; |
| 86 | +} |
|
| 84 | 87 | |
| 85 | 88 | // Load this now just because we can. |
| 86 | 89 | require_once($upgrade_path . '/Settings.php'); |
@@ -95,10 +98,12 @@ discard block |
||
| 95 | 98 | $upcontext['user'] = unserialize(base64_decode($upgradeData)); |
| 96 | 99 | |
| 97 | 100 | // Check for sensible values. |
| 98 | - if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) |
|
| 99 | - $upcontext['user']['started'] = time(); |
|
| 100 | - if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) |
|
| 101 | - $upcontext['user']['updated'] = 0; |
|
| 101 | + if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) { |
|
| 102 | + $upcontext['user']['started'] = time(); |
|
| 103 | + } |
|
| 104 | + if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) { |
|
| 105 | + $upcontext['user']['updated'] = 0; |
|
| 106 | + } |
|
| 102 | 107 | |
| 103 | 108 | $upcontext['started'] = $upcontext['user']['started']; |
| 104 | 109 | $upcontext['updated'] = $upcontext['user']['updated']; |
@@ -161,8 +166,9 @@ discard block |
||
| 161 | 166 | { |
| 162 | 167 | $word = trim($word, '-_\''); |
| 163 | 168 | |
| 164 | - if ($word != '') |
|
| 165 | - $returned_words[] = substr($word, 0, 20); |
|
| 169 | + if ($word != '') { |
|
| 170 | + $returned_words[] = substr($word, 0, 20); |
|
| 171 | + } |
|
| 166 | 172 | } |
| 167 | 173 | |
| 168 | 174 | return array_unique($returned_words); |
@@ -189,8 +195,9 @@ discard block |
||
| 189 | 195 | { |
| 190 | 196 | function md5_hmac($data, $key) |
| 191 | 197 | { |
| 192 | - if (strlen($key) > 64) |
|
| 193 | - $key = pack('H*', md5($key)); |
|
| 198 | + if (strlen($key) > 64) { |
|
| 199 | + $key = pack('H*', md5($key)); |
|
| 200 | + } |
|
| 194 | 201 | $key = str_pad($key, 64, chr(0x00)); |
| 195 | 202 | |
| 196 | 203 | $k_ipad = $key ^ str_repeat(chr(0x36), 64); |
@@ -201,8 +208,9 @@ discard block |
||
| 201 | 208 | } |
| 202 | 209 | |
| 203 | 210 | // Don't do security check if on Yabbse |
| 204 | -if (!isset($modSettings['smfVersion'])) |
|
| 211 | +if (!isset($modSettings['smfVersion'])) { |
|
| 205 | 212 | $disable_security = true; |
| 213 | +} |
|
| 206 | 214 | |
| 207 | 215 | // This only exists if we're on SMF ;) |
| 208 | 216 | if (isset($modSettings['smfVersion'])) |
@@ -220,8 +228,9 @@ discard block |
||
| 220 | 228 | 'db_error_skip' => true, |
| 221 | 229 | ) |
| 222 | 230 | ); |
| 223 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 224 | - $modSettings[$row['variable']] = $row['value']; |
|
| 231 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 232 | + $modSettings[$row['variable']] = $row['value']; |
|
| 233 | + } |
|
| 225 | 234 | $smcFunc['db_free_result']($request); |
| 226 | 235 | } |
| 227 | 236 | |
@@ -231,10 +240,12 @@ discard block |
||
| 231 | 240 | $modSettings['theme_url'] = 'Themes/default'; |
| 232 | 241 | $modSettings['images_url'] = 'Themes/default/images'; |
| 233 | 242 | } |
| 234 | -if (!isset($settings['default_theme_url'])) |
|
| 243 | +if (!isset($settings['default_theme_url'])) { |
|
| 235 | 244 | $settings['default_theme_url'] = $modSettings['theme_url']; |
| 236 | -if (!isset($settings['default_theme_dir'])) |
|
| 245 | +} |
|
| 246 | +if (!isset($settings['default_theme_dir'])) { |
|
| 237 | 247 | $settings['default_theme_dir'] = $modSettings['theme_dir']; |
| 248 | +} |
|
| 238 | 249 | |
| 239 | 250 | $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000; |
| 240 | 251 | // Default title... |
@@ -252,13 +263,15 @@ discard block |
||
| 252 | 263 | $support_js = $upcontext['upgrade_status']['js']; |
| 253 | 264 | |
| 254 | 265 | // Only set this if the upgrader status says so. |
| 255 | - if (empty($is_debug)) |
|
| 256 | - $is_debug = $upcontext['upgrade_status']['debug']; |
|
| 266 | + if (empty($is_debug)) { |
|
| 267 | + $is_debug = $upcontext['upgrade_status']['debug']; |
|
| 268 | + } |
|
| 257 | 269 | |
| 258 | 270 | // Load the language. |
| 259 | - if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 260 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 261 | -} |
|
| 271 | + if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 272 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 273 | + } |
|
| 274 | + } |
|
| 262 | 275 | // Set the defaults. |
| 263 | 276 | else |
| 264 | 277 | { |
@@ -276,15 +289,18 @@ discard block |
||
| 276 | 289 | } |
| 277 | 290 | |
| 278 | 291 | // If this isn't the first stage see whether they are logging in and resuming. |
| 279 | -if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) |
|
| 292 | +if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) { |
|
| 280 | 293 | checkLogin(); |
| 294 | +} |
|
| 281 | 295 | |
| 282 | -if ($command_line) |
|
| 296 | +if ($command_line) { |
|
| 283 | 297 | cmdStep0(); |
| 298 | +} |
|
| 284 | 299 | |
| 285 | 300 | // Don't error if we're using xml. |
| 286 | -if (isset($_GET['xml'])) |
|
| 301 | +if (isset($_GET['xml'])) { |
|
| 287 | 302 | $upcontext['return_error'] = true; |
| 303 | +} |
|
| 288 | 304 | |
| 289 | 305 | // Loop through all the steps doing each one as required. |
| 290 | 306 | $upcontext['overall_percent'] = 0; |
@@ -305,10 +321,11 @@ discard block |
||
| 305 | 321 | } |
| 306 | 322 | |
| 307 | 323 | // Call the step and if it returns false that means pause! |
| 308 | - if (function_exists($step[2]) && $step[2]() === false) |
|
| 309 | - break; |
|
| 310 | - elseif (function_exists($step[2])) |
|
| 311 | - $upcontext['current_step']++; |
|
| 324 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
| 325 | + break; |
|
| 326 | + } elseif (function_exists($step[2])) { |
|
| 327 | + $upcontext['current_step']++; |
|
| 328 | + } |
|
| 312 | 329 | } |
| 313 | 330 | $upcontext['overall_percent'] += $step[3]; |
| 314 | 331 | } |
@@ -347,17 +364,18 @@ discard block |
||
| 347 | 364 | // This should not happen my dear... HELP ME DEVELOPERS!! |
| 348 | 365 | if (!empty($command_line)) |
| 349 | 366 | { |
| 350 | - if (function_exists('debug_print_backtrace')) |
|
| 351 | - debug_print_backtrace(); |
|
| 367 | + if (function_exists('debug_print_backtrace')) { |
|
| 368 | + debug_print_backtrace(); |
|
| 369 | + } |
|
| 352 | 370 | |
| 353 | 371 | 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.'; |
| 354 | 372 | flush(); |
| 355 | 373 | die(); |
| 356 | 374 | } |
| 357 | 375 | |
| 358 | - if (!isset($_GET['xml'])) |
|
| 359 | - template_upgrade_above(); |
|
| 360 | - else |
|
| 376 | + if (!isset($_GET['xml'])) { |
|
| 377 | + template_upgrade_above(); |
|
| 378 | + } else |
|
| 361 | 379 | { |
| 362 | 380 | header('Content-Type: text/xml; charset=UTF-8'); |
| 363 | 381 | // Sadly we need to retain the $_GET data thanks to the old upgrade scripts. |
@@ -379,21 +397,24 @@ discard block |
||
| 379 | 397 | $upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&substep=' . $_GET['substep'] . '&data=' . base64_encode(safe_serialize($upcontext['upgrade_status'])); |
| 380 | 398 | |
| 381 | 399 | // Custom stuff to pass back? |
| 382 | - if (!empty($upcontext['query_string'])) |
|
| 383 | - $upcontext['form_url'] .= $upcontext['query_string']; |
|
| 400 | + if (!empty($upcontext['query_string'])) { |
|
| 401 | + $upcontext['form_url'] .= $upcontext['query_string']; |
|
| 402 | + } |
|
| 384 | 403 | |
| 385 | 404 | call_user_func('template_' . $upcontext['sub_template']); |
| 386 | 405 | } |
| 387 | 406 | |
| 388 | 407 | // Was there an error? |
| 389 | - if (!empty($upcontext['forced_error_message'])) |
|
| 390 | - echo $upcontext['forced_error_message']; |
|
| 408 | + if (!empty($upcontext['forced_error_message'])) { |
|
| 409 | + echo $upcontext['forced_error_message']; |
|
| 410 | + } |
|
| 391 | 411 | |
| 392 | 412 | // Show the footer. |
| 393 | - if (!isset($_GET['xml'])) |
|
| 394 | - template_upgrade_below(); |
|
| 395 | - else |
|
| 396 | - template_xml_below(); |
|
| 413 | + if (!isset($_GET['xml'])) { |
|
| 414 | + template_upgrade_below(); |
|
| 415 | + } else { |
|
| 416 | + template_xml_below(); |
|
| 417 | + } |
|
| 397 | 418 | } |
| 398 | 419 | |
| 399 | 420 | |
@@ -405,15 +426,19 @@ discard block |
||
| 405 | 426 | $seconds = intval($active % 60); |
| 406 | 427 | |
| 407 | 428 | $totalTime = ''; |
| 408 | - if ($hours > 0) |
|
| 409 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 410 | - if ($minutes > 0) |
|
| 411 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 412 | - if ($seconds > 0) |
|
| 413 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 429 | + if ($hours > 0) { |
|
| 430 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 431 | + } |
|
| 432 | + if ($minutes > 0) { |
|
| 433 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 434 | + } |
|
| 435 | + if ($seconds > 0) { |
|
| 436 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 437 | + } |
|
| 414 | 438 | |
| 415 | - if (!empty($totalTime)) |
|
| 416 | - echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
| 439 | + if (!empty($totalTime)) { |
|
| 440 | + echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
| 441 | + } |
|
| 417 | 442 | } |
| 418 | 443 | |
| 419 | 444 | // Bang - gone! |
@@ -426,8 +451,9 @@ discard block |
||
| 426 | 451 | global $upgradeurl, $upcontext, $command_line; |
| 427 | 452 | |
| 428 | 453 | // Command line users can't be redirected. |
| 429 | - if ($command_line) |
|
| 430 | - upgradeExit(true); |
|
| 454 | + if ($command_line) { |
|
| 455 | + upgradeExit(true); |
|
| 456 | + } |
|
| 431 | 457 | |
| 432 | 458 | // Are we providing the core info? |
| 433 | 459 | if ($addForm) |
@@ -450,19 +476,22 @@ discard block |
||
| 450 | 476 | global $modSettings, $sourcedir, $smcFunc; |
| 451 | 477 | |
| 452 | 478 | // Do the non-SSI stuff... |
| 453 | - if (function_exists('set_magic_quotes_runtime')) |
|
| 454 | - @set_magic_quotes_runtime(0); |
|
| 479 | + if (function_exists('set_magic_quotes_runtime')) { |
|
| 480 | + @set_magic_quotes_runtime(0); |
|
| 481 | + } |
|
| 455 | 482 | |
| 456 | 483 | error_reporting(E_ALL); |
| 457 | 484 | define('SMF', 1); |
| 458 | 485 | |
| 459 | 486 | // Start the session. |
| 460 | - if (@ini_get('session.save_handler') == 'user') |
|
| 461 | - @ini_set('session.save_handler', 'files'); |
|
| 487 | + if (@ini_get('session.save_handler') == 'user') { |
|
| 488 | + @ini_set('session.save_handler', 'files'); |
|
| 489 | + } |
|
| 462 | 490 | @session_start(); |
| 463 | 491 | |
| 464 | - if (empty($smcFunc)) |
|
| 465 | - $smcFunc = array(); |
|
| 492 | + if (empty($smcFunc)) { |
|
| 493 | + $smcFunc = array(); |
|
| 494 | + } |
|
| 466 | 495 | |
| 467 | 496 | // We need this for authentication and some upgrade code |
| 468 | 497 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -475,8 +504,9 @@ discard block |
||
| 475 | 504 | initialize_inputs(); |
| 476 | 505 | |
| 477 | 506 | // Get the database going! |
| 478 | - if (empty($db_type)) |
|
| 479 | - $db_type = 'mysql'; |
|
| 507 | + if (empty($db_type)) { |
|
| 508 | + $db_type = 'mysql'; |
|
| 509 | + } |
|
| 480 | 510 | if (file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
| 481 | 511 | { |
| 482 | 512 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
@@ -485,17 +515,19 @@ discard block |
||
| 485 | 515 | $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
| 486 | 516 | |
| 487 | 517 | // Oh dear god!! |
| 488 | - if ($db_connection === null) |
|
| 489 | - die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
| 518 | + if ($db_connection === null) { |
|
| 519 | + die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
| 520 | + } |
|
| 490 | 521 | |
| 491 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) |
|
| 492 | - $smcFunc['db_query']('', ' |
|
| 522 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) { |
|
| 523 | + $smcFunc['db_query']('', ' |
|
| 493 | 524 | SET NAMES {string:db_character_set}', |
| 494 | 525 | array( |
| 495 | 526 | 'db_error_skip' => true, |
| 496 | 527 | 'db_character_set' => $db_character_set, |
| 497 | 528 | ) |
| 498 | 529 | ); |
| 530 | + } |
|
| 499 | 531 | |
| 500 | 532 | // Load the modSettings data... |
| 501 | 533 | $request = $smcFunc['db_query']('', ' |
@@ -506,11 +538,11 @@ discard block |
||
| 506 | 538 | ) |
| 507 | 539 | ); |
| 508 | 540 | $modSettings = array(); |
| 509 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 510 | - $modSettings[$row['variable']] = $row['value']; |
|
| 541 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 542 | + $modSettings[$row['variable']] = $row['value']; |
|
| 543 | + } |
|
| 511 | 544 | $smcFunc['db_free_result']($request); |
| 512 | - } |
|
| 513 | - else |
|
| 545 | + } else |
|
| 514 | 546 | { |
| 515 | 547 | 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.'); |
| 516 | 548 | } |
@@ -524,9 +556,10 @@ discard block |
||
| 524 | 556 | cleanRequest(); |
| 525 | 557 | } |
| 526 | 558 | |
| 527 | - if (!isset($_GET['substep'])) |
|
| 528 | - $_GET['substep'] = 0; |
|
| 529 | -} |
|
| 559 | + if (!isset($_GET['substep'])) { |
|
| 560 | + $_GET['substep'] = 0; |
|
| 561 | + } |
|
| 562 | + } |
|
| 530 | 563 | |
| 531 | 564 | function initialize_inputs() |
| 532 | 565 | { |
@@ -564,8 +597,9 @@ discard block |
||
| 564 | 597 | $dh = opendir(dirname(__FILE__)); |
| 565 | 598 | while ($file = readdir($dh)) |
| 566 | 599 | { |
| 567 | - if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) |
|
| 568 | - @unlink(dirname(__FILE__) . '/' . $file); |
|
| 600 | + if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) { |
|
| 601 | + @unlink(dirname(__FILE__) . '/' . $file); |
|
| 602 | + } |
|
| 569 | 603 | } |
| 570 | 604 | closedir($dh); |
| 571 | 605 | |
@@ -595,8 +629,9 @@ discard block |
||
| 595 | 629 | { |
| 596 | 630 | $upcontext['remote_files_available'] = false; |
| 597 | 631 | $test = @fsockopen('www.simplemachines.org', 80, $errno, $errstr, 1); |
| 598 | - if ($test) |
|
| 599 | - $upcontext['remote_files_available'] = true; |
|
| 632 | + if ($test) { |
|
| 633 | + $upcontext['remote_files_available'] = true; |
|
| 634 | + } |
|
| 600 | 635 | @fclose($test); |
| 601 | 636 | } |
| 602 | 637 | |
@@ -604,8 +639,9 @@ discard block |
||
| 604 | 639 | $temp = 'upgrade_php?step'; |
| 605 | 640 | while (strlen($temp) > 4) |
| 606 | 641 | { |
| 607 | - if (isset($_GET[$temp])) |
|
| 608 | - unset($_GET[$temp]); |
|
| 642 | + if (isset($_GET[$temp])) { |
|
| 643 | + unset($_GET[$temp]); |
|
| 644 | + } |
|
| 609 | 645 | $temp = substr($temp, 1); |
| 610 | 646 | } |
| 611 | 647 | |
@@ -634,29 +670,36 @@ discard block |
||
| 634 | 670 | && @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $type . '.sql'); |
| 635 | 671 | |
| 636 | 672 | // Need legacy scripts? |
| 637 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) |
|
| 638 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $type . '.sql'); |
|
| 639 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) |
|
| 640 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
| 641 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) |
|
| 642 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
| 673 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) { |
|
| 674 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $type . '.sql'); |
|
| 675 | + } |
|
| 676 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) { |
|
| 677 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
| 678 | + } |
|
| 679 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) { |
|
| 680 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
| 681 | + } |
|
| 643 | 682 | |
| 644 | 683 | // This needs to exist! |
| 645 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 646 | - 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>]'); |
|
| 647 | - else |
|
| 648 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 684 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 685 | + 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>]'); |
|
| 686 | + } else { |
|
| 687 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 688 | + } |
|
| 649 | 689 | |
| 650 | - if (!$check) |
|
| 651 | - // 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. |
|
| 690 | + if (!$check) { |
|
| 691 | + // 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. |
|
| 652 | 692 | 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.'); |
| 693 | + } |
|
| 653 | 694 | |
| 654 | 695 | // Do they meet the install requirements? |
| 655 | - if (!php_version_check()) |
|
| 656 | - return throw_error('Warning! You do not appear to have a version of PHP installed on your webserver that meets SMF\'s minimum installations requirements.<br><br>Please ask your host to upgrade.'); |
|
| 696 | + if (!php_version_check()) { |
|
| 697 | + 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.'); |
|
| 698 | + } |
|
| 657 | 699 | |
| 658 | - if (!db_version_check()) |
|
| 659 | - 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.'); |
|
| 700 | + if (!db_version_check()) { |
|
| 701 | + 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.'); |
|
| 702 | + } |
|
| 660 | 703 | |
| 661 | 704 | // Do some checks to make sure they have proper privileges |
| 662 | 705 | db_extend('packages'); |
@@ -671,14 +714,16 @@ discard block |
||
| 671 | 714 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
| 672 | 715 | |
| 673 | 716 | // Sorry... we need CREATE, ALTER and DROP |
| 674 | - if (!$create || !$alter || !$drop) |
|
| 675 | - 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.'); |
|
| 717 | + if (!$create || !$alter || !$drop) { |
|
| 718 | + 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.'); |
|
| 719 | + } |
|
| 676 | 720 | |
| 677 | 721 | // Do a quick version spot check. |
| 678 | 722 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
| 679 | 723 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
| 680 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
| 681 | - 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.'); |
|
| 724 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
| 725 | + 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.'); |
|
| 726 | + } |
|
| 682 | 727 | |
| 683 | 728 | // What absolutely needs to be writable? |
| 684 | 729 | $writable_files = array( |
@@ -700,12 +745,13 @@ discard block |
||
| 700 | 745 | quickFileWritable($custom_av_dir); |
| 701 | 746 | |
| 702 | 747 | // Are we good now? |
| 703 | - if (!is_writable($custom_av_dir)) |
|
| 704 | - 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)); |
|
| 705 | - elseif ($need_settings_update) |
|
| 748 | + if (!is_writable($custom_av_dir)) { |
|
| 749 | + 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)); |
|
| 750 | + } elseif ($need_settings_update) |
|
| 706 | 751 | { |
| 707 | - if (!function_exists('cache_put_data')) |
|
| 708 | - require_once($sourcedir . '/Load.php'); |
|
| 752 | + if (!function_exists('cache_put_data')) { |
|
| 753 | + require_once($sourcedir . '/Load.php'); |
|
| 754 | + } |
|
| 709 | 755 | updateSettings(array('custom_avatar_dir' => $custom_av_dir)); |
| 710 | 756 | updateSettings(array('custom_avatar_url' => $custom_av_url)); |
| 711 | 757 | } |
@@ -714,28 +760,33 @@ discard block |
||
| 714 | 760 | |
| 715 | 761 | // Check the cache directory. |
| 716 | 762 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
| 717 | - if (!file_exists($cachedir_temp)) |
|
| 718 | - @mkdir($cachedir_temp); |
|
| 719 | - if (!file_exists($cachedir_temp)) |
|
| 720 | - 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.'); |
|
| 721 | - |
|
| 722 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
| 723 | - 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>.'); |
|
| 724 | - elseif (!isset($_GET['skiplang'])) |
|
| 763 | + if (!file_exists($cachedir_temp)) { |
|
| 764 | + @mkdir($cachedir_temp); |
|
| 765 | + } |
|
| 766 | + if (!file_exists($cachedir_temp)) { |
|
| 767 | + 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.'); |
|
| 768 | + } |
|
| 769 | + |
|
| 770 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
| 771 | + 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>.'); |
|
| 772 | + } elseif (!isset($_GET['skiplang'])) |
|
| 725 | 773 | { |
| 726 | 774 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
| 727 | 775 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 728 | 776 | |
| 729 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 730 | - 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>]'); |
|
| 777 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 778 | + 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>]'); |
|
| 779 | + } |
|
| 731 | 780 | } |
| 732 | 781 | |
| 733 | - if (!makeFilesWritable($writable_files)) |
|
| 734 | - return false; |
|
| 782 | + if (!makeFilesWritable($writable_files)) { |
|
| 783 | + return false; |
|
| 784 | + } |
|
| 735 | 785 | |
| 736 | 786 | // Check agreement.txt. (it may not exist, in which case $boarddir must be writable.) |
| 737 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
| 738 | - 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.'); |
|
| 787 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
| 788 | + 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.'); |
|
| 789 | + } |
|
| 739 | 790 | |
| 740 | 791 | // Upgrade the agreement. |
| 741 | 792 | elseif (isset($modSettings['agreement'])) |
@@ -746,8 +797,8 @@ discard block |
||
| 746 | 797 | } |
| 747 | 798 | |
| 748 | 799 | // We're going to check that their board dir setting is right in case they've been moving stuff around. |
| 749 | - if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) |
|
| 750 | - $upcontext['warning'] = ' |
|
| 800 | + if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) { |
|
| 801 | + $upcontext['warning'] = ' |
|
| 751 | 802 | 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> |
| 752 | 803 | <ul> |
| 753 | 804 | <li>Board Directory: ' . $boarddir . '</li> |
@@ -755,10 +806,12 @@ discard block |
||
| 755 | 806 | <li>Cache Directory: ' . $cachedir_temp . '</li> |
| 756 | 807 | </ul> |
| 757 | 808 | 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="http://download.simplemachines.org/?tools">Repair Settings</a> tool from the Simple Machines website before continuing.'; |
| 809 | + } |
|
| 758 | 810 | |
| 759 | 811 | // Either we're logged in or we're going to present the login. |
| 760 | - if (checkLogin()) |
|
| 761 | - return true; |
|
| 812 | + if (checkLogin()) { |
|
| 813 | + return true; |
|
| 814 | + } |
|
| 762 | 815 | |
| 763 | 816 | $upcontext += createToken('login'); |
| 764 | 817 | |
@@ -772,15 +825,17 @@ discard block |
||
| 772 | 825 | global $smcFunc, $db_type, $support_js; |
| 773 | 826 | |
| 774 | 827 | // Don't bother if the security is disabled. |
| 775 | - if ($disable_security) |
|
| 776 | - return true; |
|
| 828 | + if ($disable_security) { |
|
| 829 | + return true; |
|
| 830 | + } |
|
| 777 | 831 | |
| 778 | 832 | // Are we trying to login? |
| 779 | 833 | if (isset($_POST['contbutt']) && (!empty($_POST['user']))) |
| 780 | 834 | { |
| 781 | 835 | // If we've disabled security pick a suitable name! |
| 782 | - if (empty($_POST['user'])) |
|
| 783 | - $_POST['user'] = 'Administrator'; |
|
| 836 | + if (empty($_POST['user'])) { |
|
| 837 | + $_POST['user'] = 'Administrator'; |
|
| 838 | + } |
|
| 784 | 839 | |
| 785 | 840 | // Before 2.0 these column names were different! |
| 786 | 841 | $oldDB = false; |
@@ -795,16 +850,17 @@ discard block |
||
| 795 | 850 | 'db_error_skip' => true, |
| 796 | 851 | ) |
| 797 | 852 | ); |
| 798 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 799 | - $oldDB = true; |
|
| 853 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 854 | + $oldDB = true; |
|
| 855 | + } |
|
| 800 | 856 | $smcFunc['db_free_result']($request); |
| 801 | 857 | } |
| 802 | 858 | |
| 803 | 859 | // Get what we believe to be their details. |
| 804 | 860 | if (!$disable_security) |
| 805 | 861 | { |
| 806 | - if ($oldDB) |
|
| 807 | - $request = $smcFunc['db_query']('', ' |
|
| 862 | + if ($oldDB) { |
|
| 863 | + $request = $smcFunc['db_query']('', ' |
|
| 808 | 864 | SELECT id_member, memberName AS member_name, passwd, id_group, |
| 809 | 865 | additionalGroups AS additional_groups, lngfile |
| 810 | 866 | FROM {db_prefix}members |
@@ -814,8 +870,8 @@ discard block |
||
| 814 | 870 | 'db_error_skip' => true, |
| 815 | 871 | ) |
| 816 | 872 | ); |
| 817 | - else |
|
| 818 | - $request = $smcFunc['db_query']('', ' |
|
| 873 | + } else { |
|
| 874 | + $request = $smcFunc['db_query']('', ' |
|
| 819 | 875 | SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile |
| 820 | 876 | FROM {db_prefix}members |
| 821 | 877 | WHERE member_name = {string:member_name}', |
@@ -824,6 +880,7 @@ discard block |
||
| 824 | 880 | 'db_error_skip' => true, |
| 825 | 881 | ) |
| 826 | 882 | ); |
| 883 | + } |
|
| 827 | 884 | if ($smcFunc['db_num_rows']($request) != 0) |
| 828 | 885 | { |
| 829 | 886 | list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request); |
@@ -831,13 +888,14 @@ discard block |
||
| 831 | 888 | $groups = explode(',', $addGroups); |
| 832 | 889 | $groups[] = $id_group; |
| 833 | 890 | |
| 834 | - foreach ($groups as $k => $v) |
|
| 835 | - $groups[$k] = (int) $v; |
|
| 891 | + foreach ($groups as $k => $v) { |
|
| 892 | + $groups[$k] = (int) $v; |
|
| 893 | + } |
|
| 836 | 894 | |
| 837 | 895 | $sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd'])); |
| 896 | + } else { |
|
| 897 | + $upcontext['username_incorrect'] = true; |
|
| 838 | 898 | } |
| 839 | - else |
|
| 840 | - $upcontext['username_incorrect'] = true; |
|
| 841 | 899 | $smcFunc['db_free_result']($request); |
| 842 | 900 | } |
| 843 | 901 | $upcontext['username'] = $_POST['user']; |
@@ -847,13 +905,14 @@ discard block |
||
| 847 | 905 | { |
| 848 | 906 | $upcontext['upgrade_status']['js'] = 1; |
| 849 | 907 | $support_js = 1; |
| 908 | + } else { |
|
| 909 | + $support_js = 0; |
|
| 850 | 910 | } |
| 851 | - else |
|
| 852 | - $support_js = 0; |
|
| 853 | 911 | |
| 854 | 912 | // Note down the version we are coming from. |
| 855 | - if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) |
|
| 856 | - $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
| 913 | + if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) { |
|
| 914 | + $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
| 915 | + } |
|
| 857 | 916 | |
| 858 | 917 | // Didn't get anywhere? |
| 859 | 918 | 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'])) |
@@ -887,15 +946,15 @@ discard block |
||
| 887 | 946 | 'db_error_skip' => true, |
| 888 | 947 | ) |
| 889 | 948 | ); |
| 890 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 891 | - return throw_error('You need to be an admin to perform an upgrade!'); |
|
| 949 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 950 | + return throw_error('You need to be an admin to perform an upgrade!'); |
|
| 951 | + } |
|
| 892 | 952 | $smcFunc['db_free_result']($request); |
| 893 | 953 | } |
| 894 | 954 | |
| 895 | 955 | $upcontext['user']['id'] = $id_member; |
| 896 | 956 | $upcontext['user']['name'] = $name; |
| 897 | - } |
|
| 898 | - else |
|
| 957 | + } else |
|
| 899 | 958 | { |
| 900 | 959 | $upcontext['user']['id'] = 1; |
| 901 | 960 | $upcontext['user']['name'] = 'Administrator'; |
@@ -911,11 +970,11 @@ discard block |
||
| 911 | 970 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096); |
| 912 | 971 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 913 | 972 | |
| 914 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 915 | - $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'] . '.'; |
|
| 916 | - elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) |
|
| 917 | - $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'] . '.'; |
|
| 918 | - else |
|
| 973 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 974 | + $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'] . '.'; |
|
| 975 | + } elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) { |
|
| 976 | + $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'] . '.'; |
|
| 977 | + } else |
|
| 919 | 978 | { |
| 920 | 979 | // Set this as the new language. |
| 921 | 980 | $upcontext['language'] = $user_language; |
@@ -959,15 +1018,17 @@ discard block |
||
| 959 | 1018 | unset($member_columns); |
| 960 | 1019 | |
| 961 | 1020 | // If we've not submitted then we're done. |
| 962 | - if (empty($_POST['upcont'])) |
|
| 963 | - return false; |
|
| 1021 | + if (empty($_POST['upcont'])) { |
|
| 1022 | + return false; |
|
| 1023 | + } |
|
| 964 | 1024 | |
| 965 | 1025 | require_once($sourcedir . '/Subs-Admin.php'); |
| 966 | 1026 | updateSettingsFile(array('image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'')); |
| 967 | 1027 | |
| 968 | 1028 | // Should we update the $db_type value? |
| 969 | - if ($upcontext['update_db_type_to_mysqli']) |
|
| 970 | - updateSettingsFile(array('db_type' => '\'mysqli\'')); |
|
| 1029 | + if ($upcontext['update_db_type_to_mysqli']) { |
|
| 1030 | + updateSettingsFile(array('db_type' => '\'mysqli\'')); |
|
| 1031 | + } |
|
| 971 | 1032 | |
| 972 | 1033 | // Firstly, if they're enabling SM stat collection just do it. |
| 973 | 1034 | if (!empty($_POST['stats']) && substr($boardurl, 0, 16) != 'http://localhost' && empty($modSettings['allow_sm_stats'])) |
@@ -982,25 +1043,26 @@ discard block |
||
| 982 | 1043 | fwrite($fp, $out); |
| 983 | 1044 | |
| 984 | 1045 | $return_data = ''; |
| 985 | - while (!feof($fp)) |
|
| 986 | - $return_data .= fgets($fp, 128); |
|
| 1046 | + while (!feof($fp)) { |
|
| 1047 | + $return_data .= fgets($fp, 128); |
|
| 1048 | + } |
|
| 987 | 1049 | |
| 988 | 1050 | fclose($fp); |
| 989 | 1051 | |
| 990 | 1052 | // Get the unique site ID. |
| 991 | 1053 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
| 992 | 1054 | |
| 993 | - if (!empty($ID[1])) |
|
| 994 | - $smcFunc['db_insert']('replace', |
|
| 1055 | + if (!empty($ID[1])) { |
|
| 1056 | + $smcFunc['db_insert']('replace', |
|
| 995 | 1057 | $db_prefix . 'settings', |
| 996 | 1058 | array('variable' => 'string', 'value' => 'string'), |
| 997 | 1059 | array('allow_sm_stats', $ID[1]), |
| 998 | 1060 | array('variable') |
| 999 | 1061 | ); |
| 1062 | + } |
|
| 1000 | 1063 | } |
| 1001 | - } |
|
| 1002 | - else |
|
| 1003 | - $smcFunc['db_query']('', ' |
|
| 1064 | + } else { |
|
| 1065 | + $smcFunc['db_query']('', ' |
|
| 1004 | 1066 | DELETE FROM {db_prefix}settings |
| 1005 | 1067 | WHERE variable = {string:allow_sm_stats}', |
| 1006 | 1068 | array( |
@@ -1008,6 +1070,7 @@ discard block |
||
| 1008 | 1070 | 'db_error_skip' => true, |
| 1009 | 1071 | ) |
| 1010 | 1072 | ); |
| 1073 | + } |
|
| 1011 | 1074 | |
| 1012 | 1075 | // Deleting old karma stuff? |
| 1013 | 1076 | if (!empty($_POST['delete_karma'])) |
@@ -1022,20 +1085,22 @@ discard block |
||
| 1022 | 1085 | ); |
| 1023 | 1086 | |
| 1024 | 1087 | // Cleaning up old karma member settings. |
| 1025 | - if ($upcontext['karma_installed']['good']) |
|
| 1026 | - $smcFunc['db_query']('', ' |
|
| 1088 | + if ($upcontext['karma_installed']['good']) { |
|
| 1089 | + $smcFunc['db_query']('', ' |
|
| 1027 | 1090 | ALTER TABLE {db_prefix}members |
| 1028 | 1091 | DROP karma_good', |
| 1029 | 1092 | array() |
| 1030 | 1093 | ); |
| 1094 | + } |
|
| 1031 | 1095 | |
| 1032 | 1096 | // Does karma bad was enable? |
| 1033 | - if ($upcontext['karma_installed']['bad']) |
|
| 1034 | - $smcFunc['db_query']('', ' |
|
| 1097 | + if ($upcontext['karma_installed']['bad']) { |
|
| 1098 | + $smcFunc['db_query']('', ' |
|
| 1035 | 1099 | ALTER TABLE {db_prefix}members |
| 1036 | 1100 | DROP karma_bad', |
| 1037 | 1101 | array() |
| 1038 | 1102 | ); |
| 1103 | + } |
|
| 1039 | 1104 | |
| 1040 | 1105 | // Cleaning up old karma permissions. |
| 1041 | 1106 | $smcFunc['db_query']('', ' |
@@ -1048,18 +1113,20 @@ discard block |
||
| 1048 | 1113 | } |
| 1049 | 1114 | |
| 1050 | 1115 | // Emptying the error log? |
| 1051 | - if (!empty($_POST['empty_error'])) |
|
| 1052 | - $smcFunc['db_query']('truncate_table', ' |
|
| 1116 | + if (!empty($_POST['empty_error'])) { |
|
| 1117 | + $smcFunc['db_query']('truncate_table', ' |
|
| 1053 | 1118 | TRUNCATE {db_prefix}log_errors', |
| 1054 | 1119 | array( |
| 1055 | 1120 | ) |
| 1056 | 1121 | ); |
| 1122 | + } |
|
| 1057 | 1123 | |
| 1058 | 1124 | $changes = array(); |
| 1059 | 1125 | |
| 1060 | 1126 | // If we're overriding the language follow it through. |
| 1061 | - if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) |
|
| 1062 | - $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
| 1127 | + if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) { |
|
| 1128 | + $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
| 1129 | + } |
|
| 1063 | 1130 | |
| 1064 | 1131 | if (!empty($_POST['maint'])) |
| 1065 | 1132 | { |
@@ -1071,37 +1138,42 @@ discard block |
||
| 1071 | 1138 | { |
| 1072 | 1139 | $changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\''; |
| 1073 | 1140 | $changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\''; |
| 1074 | - } |
|
| 1075 | - else |
|
| 1141 | + } else |
|
| 1076 | 1142 | { |
| 1077 | 1143 | $changes['mtitle'] = '\'Upgrading the forum...\''; |
| 1078 | 1144 | $changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum. It will only be a minute ;).\''; |
| 1079 | 1145 | } |
| 1080 | 1146 | } |
| 1081 | 1147 | |
| 1082 | - if ($command_line) |
|
| 1083 | - echo ' * Updating Settings.php...'; |
|
| 1148 | + if ($command_line) { |
|
| 1149 | + echo ' * Updating Settings.php...'; |
|
| 1150 | + } |
|
| 1084 | 1151 | |
| 1085 | 1152 | // Backup the current one first. |
| 1086 | 1153 | copy($boarddir . '/Settings.php', $boarddir . '/Settings_bak.php'); |
| 1087 | 1154 | |
| 1088 | 1155 | // Fix some old paths. |
| 1089 | - if (substr($boarddir, 0, 1) == '.') |
|
| 1090 | - $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
| 1156 | + if (substr($boarddir, 0, 1) == '.') { |
|
| 1157 | + $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
| 1158 | + } |
|
| 1091 | 1159 | |
| 1092 | - if (substr($sourcedir, 0, 1) == '.') |
|
| 1093 | - $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
| 1160 | + if (substr($sourcedir, 0, 1) == '.') { |
|
| 1161 | + $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
| 1162 | + } |
|
| 1094 | 1163 | |
| 1095 | - if (empty($cachedir) || substr($cachedir, 0, 1) == '.') |
|
| 1096 | - $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
| 1164 | + if (empty($cachedir) || substr($cachedir, 0, 1) == '.') { |
|
| 1165 | + $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
| 1166 | + } |
|
| 1097 | 1167 | |
| 1098 | 1168 | // Not had the database type added before? |
| 1099 | - if (empty($db_type)) |
|
| 1100 | - $changes['db_type'] = 'mysql'; |
|
| 1169 | + if (empty($db_type)) { |
|
| 1170 | + $changes['db_type'] = 'mysql'; |
|
| 1171 | + } |
|
| 1101 | 1172 | |
| 1102 | 1173 | // For now we offer a option, this may change in future versions when mysql is completely removed. |
| 1103 | - if (!empty($_POST['convertMysql']) && $db_type == 'mysql') |
|
| 1104 | - $changes['db_type'] = '\'mysqli\''; |
|
| 1174 | + if (!empty($_POST['convertMysql']) && $db_type == 'mysql') { |
|
| 1175 | + $changes['db_type'] = '\'mysqli\''; |
|
| 1176 | + } |
|
| 1105 | 1177 | |
| 1106 | 1178 | // If they have a "host:port" setup for the host, split that into separate values |
| 1107 | 1179 | // You should never have a : in the hostname if you're not on MySQL, but better safe than sorry |
@@ -1112,28 +1184,31 @@ discard block |
||
| 1112 | 1184 | $changes['db_server'] = '\'' . $db_server . '\''; |
| 1113 | 1185 | |
| 1114 | 1186 | // Only set this if we're not using the default port |
| 1115 | - if ($db_port != ini_get('mysql' . ($db_type == 'mysqli' || !empty($_POST['convertMysql']) ? 'i' : '') . '.default_port')) |
|
| 1116 | - $changes['db_port'] = (int) $db_port; |
|
| 1117 | - } |
|
| 1118 | - elseif (!empty($db_port)) |
|
| 1187 | + if ($db_port != ini_get('mysql' . ($db_type == 'mysqli' || !empty($_POST['convertMysql']) ? 'i' : '') . '.default_port')) { |
|
| 1188 | + $changes['db_port'] = (int) $db_port; |
|
| 1189 | + } |
|
| 1190 | + } elseif (!empty($db_port)) |
|
| 1119 | 1191 | { |
| 1120 | 1192 | // If db_port is set and is the same as the default, set it to '' |
| 1121 | 1193 | if ($db_type == 'mysql' || $db_type == 'mysqli') |
| 1122 | 1194 | { |
| 1123 | - if ($db_port == ini_get('mysql' . ($db_type == 'mysqli' || !empty($_POST['convertMysql']) ? 'i' : '') . '.default_port')) |
|
| 1124 | - $changes['db_port'] = '\'\''; |
|
| 1125 | - elseif ($db_type == 'postgresql' && $db_port == 5432) |
|
| 1126 | - $changes['db_port'] = '\'\''; |
|
| 1195 | + if ($db_port == ini_get('mysql' . ($db_type == 'mysqli' || !empty($_POST['convertMysql']) ? 'i' : '') . '.default_port')) { |
|
| 1196 | + $changes['db_port'] = '\'\''; |
|
| 1197 | + } elseif ($db_type == 'postgresql' && $db_port == 5432) { |
|
| 1198 | + $changes['db_port'] = '\'\''; |
|
| 1199 | + } |
|
| 1127 | 1200 | } |
| 1128 | 1201 | } |
| 1129 | 1202 | |
| 1130 | 1203 | // Maybe we haven't had this option yet? |
| 1131 | - if (empty($packagesdir)) |
|
| 1132 | - $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
| 1204 | + if (empty($packagesdir)) { |
|
| 1205 | + $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
| 1206 | + } |
|
| 1133 | 1207 | |
| 1134 | 1208 | // Add support for $tasksdir var. |
| 1135 | - if (empty($tasksdir)) |
|
| 1136 | - $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
| 1209 | + if (empty($tasksdir)) { |
|
| 1210 | + $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
| 1211 | + } |
|
| 1137 | 1212 | |
| 1138 | 1213 | // @todo Maybe change the cookie name if going to 1.1, too? |
| 1139 | 1214 | |
@@ -1178,8 +1253,7 @@ discard block |
||
| 1178 | 1253 | $found_old = true; |
| 1179 | 1254 | // Replace the old line with the new code |
| 1180 | 1255 | $settings_file = str_replace('$db_last_error = ' . $db_last_error . ';', $error_catching_header . $error_catching, $settings_file); |
| 1181 | - } |
|
| 1182 | - else |
|
| 1256 | + } else |
|
| 1183 | 1257 | { |
| 1184 | 1258 | $found_old = false; |
| 1185 | 1259 | // We want the comments as well as the code... |
@@ -1210,8 +1284,9 @@ discard block |
||
| 1210 | 1284 | fclose($file); |
| 1211 | 1285 | } |
| 1212 | 1286 | |
| 1213 | - if ($command_line) |
|
| 1214 | - echo ' Successful.' . "\n"; |
|
| 1287 | + if ($command_line) { |
|
| 1288 | + echo ' Successful.' . "\n"; |
|
| 1289 | + } |
|
| 1215 | 1290 | |
| 1216 | 1291 | // Are we doing debug? |
| 1217 | 1292 | if (isset($_POST['debug'])) |
@@ -1221,8 +1296,9 @@ discard block |
||
| 1221 | 1296 | } |
| 1222 | 1297 | |
| 1223 | 1298 | // If we're not backing up then jump one. |
| 1224 | - if (empty($_POST['backup'])) |
|
| 1225 | - $upcontext['current_step']++; |
|
| 1299 | + if (empty($_POST['backup'])) { |
|
| 1300 | + $upcontext['current_step']++; |
|
| 1301 | + } |
|
| 1226 | 1302 | |
| 1227 | 1303 | // If we've got here then let's proceed to the next step! |
| 1228 | 1304 | return true; |
@@ -1237,8 +1313,9 @@ discard block |
||
| 1237 | 1313 | $upcontext['page_title'] = 'Backup Database'; |
| 1238 | 1314 | |
| 1239 | 1315 | // Done it already - js wise? |
| 1240 | - if (!empty($_POST['backup_done'])) |
|
| 1241 | - return true; |
|
| 1316 | + if (!empty($_POST['backup_done'])) { |
|
| 1317 | + return true; |
|
| 1318 | + } |
|
| 1242 | 1319 | |
| 1243 | 1320 | // Some useful stuff here. |
| 1244 | 1321 | db_extend(); |
@@ -1252,9 +1329,10 @@ discard block |
||
| 1252 | 1329 | $tables = $smcFunc['db_list_tables']($db, $filter); |
| 1253 | 1330 | |
| 1254 | 1331 | $table_names = array(); |
| 1255 | - foreach ($tables as $table) |
|
| 1256 | - if (substr($table, 0, 7) !== 'backup_') |
|
| 1332 | + foreach ($tables as $table) { |
|
| 1333 | + if (substr($table, 0, 7) !== 'backup_') |
|
| 1257 | 1334 | $table_names[] = $table; |
| 1335 | + } |
|
| 1258 | 1336 | |
| 1259 | 1337 | $upcontext['table_count'] = count($table_names); |
| 1260 | 1338 | $upcontext['cur_table_num'] = $_GET['substep']; |
@@ -1264,12 +1342,14 @@ discard block |
||
| 1264 | 1342 | $file_steps = $upcontext['table_count']; |
| 1265 | 1343 | |
| 1266 | 1344 | // What ones have we already done? |
| 1267 | - foreach ($table_names as $id => $table) |
|
| 1268 | - if ($id < $_GET['substep']) |
|
| 1345 | + foreach ($table_names as $id => $table) { |
|
| 1346 | + if ($id < $_GET['substep']) |
|
| 1269 | 1347 | $upcontext['previous_tables'][] = $table; |
| 1348 | + } |
|
| 1270 | 1349 | |
| 1271 | - if ($command_line) |
|
| 1272 | - echo 'Backing Up Tables.'; |
|
| 1350 | + if ($command_line) { |
|
| 1351 | + echo 'Backing Up Tables.'; |
|
| 1352 | + } |
|
| 1273 | 1353 | |
| 1274 | 1354 | // If we don't support javascript we backup here. |
| 1275 | 1355 | if (!$support_js || isset($_GET['xml'])) |
@@ -1288,8 +1368,9 @@ discard block |
||
| 1288 | 1368 | backupTable($table_names[$substep]); |
| 1289 | 1369 | |
| 1290 | 1370 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 1291 | - if (isset($_GET['xml'])) |
|
| 1292 | - return upgradeExit(); |
|
| 1371 | + if (isset($_GET['xml'])) { |
|
| 1372 | + return upgradeExit(); |
|
| 1373 | + } |
|
| 1293 | 1374 | } |
| 1294 | 1375 | |
| 1295 | 1376 | if ($command_line) |
@@ -1322,9 +1403,10 @@ discard block |
||
| 1322 | 1403 | |
| 1323 | 1404 | $smcFunc['db_backup_table']($table, 'backup_' . $table); |
| 1324 | 1405 | |
| 1325 | - if ($command_line) |
|
| 1326 | - echo ' done.'; |
|
| 1327 | -} |
|
| 1406 | + if ($command_line) { |
|
| 1407 | + echo ' done.'; |
|
| 1408 | + } |
|
| 1409 | + } |
|
| 1328 | 1410 | |
| 1329 | 1411 | // Step 2: Everything. |
| 1330 | 1412 | function DatabaseChanges() |
@@ -1333,8 +1415,9 @@ discard block |
||
| 1333 | 1415 | global $upcontext, $support_js, $db_type; |
| 1334 | 1416 | |
| 1335 | 1417 | // Have we just completed this? |
| 1336 | - if (!empty($_POST['database_done'])) |
|
| 1337 | - return true; |
|
| 1418 | + if (!empty($_POST['database_done'])) { |
|
| 1419 | + return true; |
|
| 1420 | + } |
|
| 1338 | 1421 | |
| 1339 | 1422 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes'; |
| 1340 | 1423 | $upcontext['page_title'] = 'Database Changes'; |
@@ -1351,15 +1434,16 @@ discard block |
||
| 1351 | 1434 | ); |
| 1352 | 1435 | |
| 1353 | 1436 | // How many files are there in total? |
| 1354 | - if (isset($_GET['filecount'])) |
|
| 1355 | - $upcontext['file_count'] = (int) $_GET['filecount']; |
|
| 1356 | - else |
|
| 1437 | + if (isset($_GET['filecount'])) { |
|
| 1438 | + $upcontext['file_count'] = (int) $_GET['filecount']; |
|
| 1439 | + } else |
|
| 1357 | 1440 | { |
| 1358 | 1441 | $upcontext['file_count'] = 0; |
| 1359 | 1442 | foreach ($files as $file) |
| 1360 | 1443 | { |
| 1361 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) |
|
| 1362 | - $upcontext['file_count']++; |
|
| 1444 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) { |
|
| 1445 | + $upcontext['file_count']++; |
|
| 1446 | + } |
|
| 1363 | 1447 | } |
| 1364 | 1448 | } |
| 1365 | 1449 | |
@@ -1369,9 +1453,9 @@ discard block |
||
| 1369 | 1453 | $upcontext['cur_file_num'] = 0; |
| 1370 | 1454 | foreach ($files as $file) |
| 1371 | 1455 | { |
| 1372 | - if ($did_not_do) |
|
| 1373 | - $did_not_do--; |
|
| 1374 | - else |
|
| 1456 | + if ($did_not_do) { |
|
| 1457 | + $did_not_do--; |
|
| 1458 | + } else |
|
| 1375 | 1459 | { |
| 1376 | 1460 | $upcontext['cur_file_num']++; |
| 1377 | 1461 | $upcontext['cur_file_name'] = $file[0]; |
@@ -1398,12 +1482,13 @@ discard block |
||
| 1398 | 1482 | // Flag to move on to the next. |
| 1399 | 1483 | $upcontext['completed_step'] = true; |
| 1400 | 1484 | // Did we complete the whole file? |
| 1401 | - if ($nextFile) |
|
| 1402 | - $upcontext['current_debug_item_num'] = -1; |
|
| 1485 | + if ($nextFile) { |
|
| 1486 | + $upcontext['current_debug_item_num'] = -1; |
|
| 1487 | + } |
|
| 1403 | 1488 | return upgradeExit(); |
| 1489 | + } elseif ($support_js) { |
|
| 1490 | + break; |
|
| 1404 | 1491 | } |
| 1405 | - elseif ($support_js) |
|
| 1406 | - break; |
|
| 1407 | 1492 | } |
| 1408 | 1493 | // Set the progress bar to be right as if we had - even if we hadn't... |
| 1409 | 1494 | $upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100; |
@@ -1428,8 +1513,9 @@ discard block |
||
| 1428 | 1513 | global $command_line, $language, $upcontext, $boarddir, $sourcedir, $forum_version, $user_info, $maintenance, $smcFunc, $db_type; |
| 1429 | 1514 | |
| 1430 | 1515 | // Now it's nice to have some of the basic SMF source files. |
| 1431 | - if (!isset($_GET['ssi']) && !$command_line) |
|
| 1432 | - redirectLocation('&ssi=1'); |
|
| 1516 | + if (!isset($_GET['ssi']) && !$command_line) { |
|
| 1517 | + redirectLocation('&ssi=1'); |
|
| 1518 | + } |
|
| 1433 | 1519 | |
| 1434 | 1520 | $upcontext['sub_template'] = 'upgrade_complete'; |
| 1435 | 1521 | $upcontext['page_title'] = 'Upgrade Complete'; |
@@ -1445,14 +1531,16 @@ discard block |
||
| 1445 | 1531 | // Are we in maintenance mode? |
| 1446 | 1532 | if (isset($upcontext['user']['main'])) |
| 1447 | 1533 | { |
| 1448 | - if ($command_line) |
|
| 1449 | - echo ' * '; |
|
| 1534 | + if ($command_line) { |
|
| 1535 | + echo ' * '; |
|
| 1536 | + } |
|
| 1450 | 1537 | $upcontext['removed_maintenance'] = true; |
| 1451 | 1538 | $changes['maintenance'] = $upcontext['user']['main']; |
| 1452 | 1539 | } |
| 1453 | 1540 | // Otherwise if somehow we are in 2 let's go to 1. |
| 1454 | - elseif (!empty($maintenance) && $maintenance == 2) |
|
| 1455 | - $changes['maintenance'] = 1; |
|
| 1541 | + elseif (!empty($maintenance) && $maintenance == 2) { |
|
| 1542 | + $changes['maintenance'] = 1; |
|
| 1543 | + } |
|
| 1456 | 1544 | |
| 1457 | 1545 | // Wipe this out... |
| 1458 | 1546 | $upcontext['user'] = array(); |
@@ -1468,9 +1556,9 @@ discard block |
||
| 1468 | 1556 | $upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__); |
| 1469 | 1557 | |
| 1470 | 1558 | // Now is the perfect time to fetch the SM files. |
| 1471 | - if ($command_line) |
|
| 1472 | - cli_scheduled_fetchSMfiles(); |
|
| 1473 | - else |
|
| 1559 | + if ($command_line) { |
|
| 1560 | + cli_scheduled_fetchSMfiles(); |
|
| 1561 | + } else |
|
| 1474 | 1562 | { |
| 1475 | 1563 | require_once($sourcedir . '/ScheduledTasks.php'); |
| 1476 | 1564 | $forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us. |
@@ -1478,8 +1566,9 @@ discard block |
||
| 1478 | 1566 | } |
| 1479 | 1567 | |
| 1480 | 1568 | // Log what we've done. |
| 1481 | - if (empty($user_info['id'])) |
|
| 1482 | - $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
| 1569 | + if (empty($user_info['id'])) { |
|
| 1570 | + $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
| 1571 | + } |
|
| 1483 | 1572 | |
| 1484 | 1573 | // Log the action manually, so CLI still works. |
| 1485 | 1574 | $smcFunc['db_insert']('', |
@@ -1498,8 +1587,9 @@ discard block |
||
| 1498 | 1587 | |
| 1499 | 1588 | // Save the current database version. |
| 1500 | 1589 | $server_version = $smcFunc['db_server_info'](); |
| 1501 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
| 1502 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1590 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
| 1591 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1592 | + } |
|
| 1503 | 1593 | |
| 1504 | 1594 | if ($command_line) |
| 1505 | 1595 | { |
@@ -1511,8 +1601,9 @@ discard block |
||
| 1511 | 1601 | |
| 1512 | 1602 | // Make sure it says we're done. |
| 1513 | 1603 | $upcontext['overall_percent'] = 100; |
| 1514 | - if (isset($upcontext['step_progress'])) |
|
| 1515 | - unset($upcontext['step_progress']); |
|
| 1604 | + if (isset($upcontext['step_progress'])) { |
|
| 1605 | + unset($upcontext['step_progress']); |
|
| 1606 | + } |
|
| 1516 | 1607 | |
| 1517 | 1608 | $_GET['substep'] = 0; |
| 1518 | 1609 | return false; |
@@ -1523,8 +1614,9 @@ discard block |
||
| 1523 | 1614 | { |
| 1524 | 1615 | global $sourcedir, $language, $forum_version, $modSettings, $smcFunc; |
| 1525 | 1616 | |
| 1526 | - if (empty($modSettings['time_format'])) |
|
| 1527 | - $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
| 1617 | + if (empty($modSettings['time_format'])) { |
|
| 1618 | + $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
| 1619 | + } |
|
| 1528 | 1620 | |
| 1529 | 1621 | // What files do we want to get |
| 1530 | 1622 | $request = $smcFunc['db_query']('', ' |
@@ -1558,8 +1650,9 @@ discard block |
||
| 1558 | 1650 | $file_data = fetch_web_data($url); |
| 1559 | 1651 | |
| 1560 | 1652 | // If we got an error - give up - the site might be down. |
| 1561 | - if ($file_data === false) |
|
| 1562 | - return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
| 1653 | + if ($file_data === false) { |
|
| 1654 | + return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
| 1655 | + } |
|
| 1563 | 1656 | |
| 1564 | 1657 | // Save the file to the database. |
| 1565 | 1658 | $smcFunc['db_query']('substring', ' |
@@ -1601,8 +1694,9 @@ discard block |
||
| 1601 | 1694 | $themeData = array(); |
| 1602 | 1695 | foreach ($values as $variable => $value) |
| 1603 | 1696 | { |
| 1604 | - if (!isset($value) || $value === null) |
|
| 1605 | - $value = 0; |
|
| 1697 | + if (!isset($value) || $value === null) { |
|
| 1698 | + $value = 0; |
|
| 1699 | + } |
|
| 1606 | 1700 | |
| 1607 | 1701 | $themeData[] = array(0, 1, $variable, $value); |
| 1608 | 1702 | } |
@@ -1631,8 +1725,9 @@ discard block |
||
| 1631 | 1725 | |
| 1632 | 1726 | foreach ($values as $variable => $value) |
| 1633 | 1727 | { |
| 1634 | - if (empty($modSettings[$value[0]])) |
|
| 1635 | - continue; |
|
| 1728 | + if (empty($modSettings[$value[0]])) { |
|
| 1729 | + continue; |
|
| 1730 | + } |
|
| 1636 | 1731 | |
| 1637 | 1732 | $smcFunc['db_query']('', ' |
| 1638 | 1733 | INSERT IGNORE INTO {db_prefix}themes |
@@ -1665,8 +1760,9 @@ discard block |
||
| 1665 | 1760 | |
| 1666 | 1761 | $settingsArray = file($boarddir . '/Settings_bak.php'); |
| 1667 | 1762 | |
| 1668 | - if (count($settingsArray) == 1) |
|
| 1669 | - $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
| 1763 | + if (count($settingsArray) == 1) { |
|
| 1764 | + $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
| 1765 | + } |
|
| 1670 | 1766 | |
| 1671 | 1767 | for ($i = 0, $n = count($settingsArray); $i < $n; $i++) |
| 1672 | 1768 | { |
@@ -1679,9 +1775,9 @@ discard block |
||
| 1679 | 1775 | { |
| 1680 | 1776 | if (isset($settingsArray[$i]) && strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
| 1681 | 1777 | { |
| 1682 | - if ($val == '#remove#') |
|
| 1683 | - unset($settingsArray[$i]); |
|
| 1684 | - else |
|
| 1778 | + if ($val == '#remove#') { |
|
| 1779 | + unset($settingsArray[$i]); |
|
| 1780 | + } else |
|
| 1685 | 1781 | { |
| 1686 | 1782 | $comment = strstr(substr($settingsArray[$i], strpos($settingsArray[$i], ';')), '#'); |
| 1687 | 1783 | $settingsArray[$i] = '$' . $var . ' = ' . $val . ';' . ($comment != '' ? "\t\t" . $comment : "\n"); |
@@ -1693,22 +1789,25 @@ discard block |
||
| 1693 | 1789 | } |
| 1694 | 1790 | if (isset($settingsArray[$i])) |
| 1695 | 1791 | { |
| 1696 | - if (trim(substr($settingsArray[$i], 0, 2)) == '?' . '>') |
|
| 1697 | - $end = $i; |
|
| 1792 | + if (trim(substr($settingsArray[$i], 0, 2)) == '?' . '>') { |
|
| 1793 | + $end = $i; |
|
| 1794 | + } |
|
| 1698 | 1795 | } |
| 1699 | 1796 | } |
| 1700 | 1797 | |
| 1701 | 1798 | // Assume end-of-file if the end wasn't found. |
| 1702 | - if (empty($end) || $end < 10) |
|
| 1703 | - $end = count($settingsArray); |
|
| 1799 | + if (empty($end) || $end < 10) { |
|
| 1800 | + $end = count($settingsArray); |
|
| 1801 | + } |
|
| 1704 | 1802 | |
| 1705 | 1803 | if (!empty($config_vars)) |
| 1706 | 1804 | { |
| 1707 | 1805 | $settingsArray[$end++] = ''; |
| 1708 | 1806 | foreach ($config_vars as $var => $val) |
| 1709 | 1807 | { |
| 1710 | - if ($val != '#remove#') |
|
| 1711 | - $settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n"; |
|
| 1808 | + if ($val != '#remove#') { |
|
| 1809 | + $settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n"; |
|
| 1810 | + } |
|
| 1712 | 1811 | } |
| 1713 | 1812 | } |
| 1714 | 1813 | // This should be the last line and even last bytes of the file. |
@@ -1721,8 +1820,9 @@ discard block |
||
| 1721 | 1820 | $fp = fopen($boarddir . '/Settings.php', 'r+'); |
| 1722 | 1821 | for ($i = 0; $i < $end; $i++) |
| 1723 | 1822 | { |
| 1724 | - if (isset($settingsArray[$i])) |
|
| 1725 | - fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
| 1823 | + if (isset($settingsArray[$i])) { |
|
| 1824 | + fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
| 1825 | + } |
|
| 1726 | 1826 | } |
| 1727 | 1827 | fwrite($fp, rtrim($settingsArray[$i])); |
| 1728 | 1828 | fclose($fp); |
@@ -1753,8 +1853,9 @@ discard block |
||
| 1753 | 1853 | global $smcFunc; |
| 1754 | 1854 | static $member_groups = array(); |
| 1755 | 1855 | |
| 1756 | - if (!empty($member_groups)) |
|
| 1757 | - return $member_groups; |
|
| 1856 | + if (!empty($member_groups)) { |
|
| 1857 | + return $member_groups; |
|
| 1858 | + } |
|
| 1758 | 1859 | |
| 1759 | 1860 | $request = $smcFunc['db_query']('', ' |
| 1760 | 1861 | SELECT group_name, id_group |
@@ -1779,8 +1880,9 @@ discard block |
||
| 1779 | 1880 | ) |
| 1780 | 1881 | ); |
| 1781 | 1882 | } |
| 1782 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 1783 | - $member_groups[trim($row[0])] = $row[1]; |
|
| 1883 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 1884 | + $member_groups[trim($row[0])] = $row[1]; |
|
| 1885 | + } |
|
| 1784 | 1886 | $smcFunc['db_free_result']($request); |
| 1785 | 1887 | |
| 1786 | 1888 | return $member_groups; |
@@ -1833,10 +1935,11 @@ discard block |
||
| 1833 | 1935 | { |
| 1834 | 1936 | global $support_js; |
| 1835 | 1937 | |
| 1836 | - if ($support_js) |
|
| 1837 | - return true; |
|
| 1838 | - else |
|
| 1839 | - echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
| 1938 | + if ($support_js) { |
|
| 1939 | + return true; |
|
| 1940 | + } else { |
|
| 1941 | + echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
| 1942 | + } |
|
| 1840 | 1943 | } |
| 1841 | 1944 | } |
| 1842 | 1945 | |
@@ -1854,8 +1957,9 @@ discard block |
||
| 1854 | 1957 | 'db_error_skip' => true, |
| 1855 | 1958 | ) |
| 1856 | 1959 | ); |
| 1857 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 1858 | - die('Unable to find members table!'); |
|
| 1960 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 1961 | + die('Unable to find members table!'); |
|
| 1962 | + } |
|
| 1859 | 1963 | $table_status = $smcFunc['db_fetch_assoc']($request); |
| 1860 | 1964 | $smcFunc['db_free_result']($request); |
| 1861 | 1965 | |
@@ -1870,17 +1974,20 @@ discard block |
||
| 1870 | 1974 | ) |
| 1871 | 1975 | ); |
| 1872 | 1976 | // Got something? |
| 1873 | - if ($smcFunc['db_num_rows']($request) !== 0) |
|
| 1874 | - $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 1977 | + if ($smcFunc['db_num_rows']($request) !== 0) { |
|
| 1978 | + $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 1979 | + } |
|
| 1875 | 1980 | $smcFunc['db_free_result']($request); |
| 1876 | 1981 | |
| 1877 | 1982 | // Excellent! |
| 1878 | - if (!empty($collation_info['Collation']) && !empty($collation_info['Charset'])) |
|
| 1879 | - $db_collation = ' CHARACTER SET ' . $collation_info['Charset'] . ' COLLATE ' . $collation_info['Collation']; |
|
| 1983 | + if (!empty($collation_info['Collation']) && !empty($collation_info['Charset'])) { |
|
| 1984 | + $db_collation = ' CHARACTER SET ' . $collation_info['Charset'] . ' COLLATE ' . $collation_info['Collation']; |
|
| 1985 | + } |
|
| 1880 | 1986 | } |
| 1881 | 1987 | } |
| 1882 | - if (empty($db_collation)) |
|
| 1883 | - $db_collation = ''; |
|
| 1988 | + if (empty($db_collation)) { |
|
| 1989 | + $db_collation = ''; |
|
| 1990 | + } |
|
| 1884 | 1991 | |
| 1885 | 1992 | $endl = $command_line ? "\n" : '<br>' . "\n"; |
| 1886 | 1993 | |
@@ -1892,8 +1999,9 @@ discard block |
||
| 1892 | 1999 | $last_step = ''; |
| 1893 | 2000 | |
| 1894 | 2001 | // Make sure all newly created tables will have the proper characters set. |
| 1895 | - if (isset($db_character_set) && $db_character_set === 'utf8') |
|
| 1896 | - $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
| 2002 | + if (isset($db_character_set) && $db_character_set === 'utf8') { |
|
| 2003 | + $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
| 2004 | + } |
|
| 1897 | 2005 | |
| 1898 | 2006 | // Count the total number of steps within this file - for progress. |
| 1899 | 2007 | $file_steps = substr_count(implode('', $lines), '---#'); |
@@ -1913,15 +2021,18 @@ discard block |
||
| 1913 | 2021 | $do_current = $substep >= $_GET['substep']; |
| 1914 | 2022 | |
| 1915 | 2023 | // Get rid of any comments in the beginning of the line... |
| 1916 | - if (substr(trim($line), 0, 2) === '/*') |
|
| 1917 | - $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
| 2024 | + if (substr(trim($line), 0, 2) === '/*') { |
|
| 2025 | + $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
| 2026 | + } |
|
| 1918 | 2027 | |
| 1919 | 2028 | // Always flush. Flush, flush, flush. Flush, flush, flush, flush! FLUSH! |
| 1920 | - if ($is_debug && !$support_js && $command_line) |
|
| 1921 | - flush(); |
|
| 2029 | + if ($is_debug && !$support_js && $command_line) { |
|
| 2030 | + flush(); |
|
| 2031 | + } |
|
| 1922 | 2032 | |
| 1923 | - if (trim($line) === '') |
|
| 1924 | - continue; |
|
| 2033 | + if (trim($line) === '') { |
|
| 2034 | + continue; |
|
| 2035 | + } |
|
| 1925 | 2036 | |
| 1926 | 2037 | if (trim(substr($line, 0, 3)) === '---') |
| 1927 | 2038 | { |
@@ -1931,8 +2042,9 @@ discard block |
||
| 1931 | 2042 | if (trim($current_data) != '' && $type !== '}') |
| 1932 | 2043 | { |
| 1933 | 2044 | $upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl; |
| 1934 | - if ($command_line) |
|
| 1935 | - echo $upcontext['error_message']; |
|
| 2045 | + if ($command_line) { |
|
| 2046 | + echo $upcontext['error_message']; |
|
| 2047 | + } |
|
| 1936 | 2048 | } |
| 1937 | 2049 | |
| 1938 | 2050 | if ($type == ' ') |
@@ -1950,17 +2062,18 @@ discard block |
||
| 1950 | 2062 | if ($do_current) |
| 1951 | 2063 | { |
| 1952 | 2064 | $upcontext['actioned_items'][] = $last_step; |
| 1953 | - if ($command_line) |
|
| 1954 | - echo ' * '; |
|
| 2065 | + if ($command_line) { |
|
| 2066 | + echo ' * '; |
|
| 2067 | + } |
|
| 1955 | 2068 | } |
| 1956 | - } |
|
| 1957 | - elseif ($type == '#') |
|
| 2069 | + } elseif ($type == '#') |
|
| 1958 | 2070 | { |
| 1959 | 2071 | $upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps; |
| 1960 | 2072 | |
| 1961 | 2073 | $upcontext['current_debug_item_num']++; |
| 1962 | - if (trim($line) != '---#') |
|
| 1963 | - $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 2074 | + if (trim($line) != '---#') { |
|
| 2075 | + $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 2076 | + } |
|
| 1964 | 2077 | |
| 1965 | 2078 | // Have we already done something? |
| 1966 | 2079 | if (isset($_GET['xml']) && $done_something) |
@@ -1971,34 +2084,36 @@ discard block |
||
| 1971 | 2084 | |
| 1972 | 2085 | if ($do_current) |
| 1973 | 2086 | { |
| 1974 | - if (trim($line) == '---#' && $command_line) |
|
| 1975 | - echo ' done.', $endl; |
|
| 1976 | - elseif ($command_line) |
|
| 1977 | - echo ' +++ ', rtrim(substr($line, 4)); |
|
| 1978 | - elseif (trim($line) != '---#') |
|
| 2087 | + if (trim($line) == '---#' && $command_line) { |
|
| 2088 | + echo ' done.', $endl; |
|
| 2089 | + } elseif ($command_line) { |
|
| 2090 | + echo ' +++ ', rtrim(substr($line, 4)); |
|
| 2091 | + } elseif (trim($line) != '---#') |
|
| 1979 | 2092 | { |
| 1980 | - if ($is_debug) |
|
| 1981 | - $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 2093 | + if ($is_debug) { |
|
| 2094 | + $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 2095 | + } |
|
| 1982 | 2096 | } |
| 1983 | 2097 | } |
| 1984 | 2098 | |
| 1985 | 2099 | if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep']) |
| 1986 | 2100 | { |
| 1987 | - if ($command_line) |
|
| 1988 | - echo ' * '; |
|
| 1989 | - else |
|
| 1990 | - $upcontext['actioned_items'][] = $last_step; |
|
| 2101 | + if ($command_line) { |
|
| 2102 | + echo ' * '; |
|
| 2103 | + } else { |
|
| 2104 | + $upcontext['actioned_items'][] = $last_step; |
|
| 2105 | + } |
|
| 1991 | 2106 | } |
| 1992 | 2107 | |
| 1993 | 2108 | // Small step - only if we're actually doing stuff. |
| 1994 | - if ($do_current) |
|
| 1995 | - nextSubstep(++$substep); |
|
| 1996 | - else |
|
| 1997 | - $substep++; |
|
| 1998 | - } |
|
| 1999 | - elseif ($type == '{') |
|
| 2000 | - $current_type = 'code'; |
|
| 2001 | - elseif ($type == '}') |
|
| 2109 | + if ($do_current) { |
|
| 2110 | + nextSubstep(++$substep); |
|
| 2111 | + } else { |
|
| 2112 | + $substep++; |
|
| 2113 | + } |
|
| 2114 | + } elseif ($type == '{') { |
|
| 2115 | + $current_type = 'code'; |
|
| 2116 | + } elseif ($type == '}') |
|
| 2002 | 2117 | { |
| 2003 | 2118 | $current_type = 'sql'; |
| 2004 | 2119 | |
@@ -2011,8 +2126,9 @@ discard block |
||
| 2011 | 2126 | if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false) |
| 2012 | 2127 | { |
| 2013 | 2128 | $upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl; |
| 2014 | - if ($command_line) |
|
| 2015 | - echo $upcontext['error_message']; |
|
| 2129 | + if ($command_line) { |
|
| 2130 | + echo $upcontext['error_message']; |
|
| 2131 | + } |
|
| 2016 | 2132 | } |
| 2017 | 2133 | |
| 2018 | 2134 | // Done with code! |
@@ -2092,8 +2208,9 @@ discard block |
||
| 2092 | 2208 | $db_unbuffered = false; |
| 2093 | 2209 | |
| 2094 | 2210 | // Failure?! |
| 2095 | - if ($result !== false) |
|
| 2096 | - return $result; |
|
| 2211 | + if ($result !== false) { |
|
| 2212 | + return $result; |
|
| 2213 | + } |
|
| 2097 | 2214 | |
| 2098 | 2215 | $db_error_message = $smcFunc['db_error']($db_connection); |
| 2099 | 2216 | // If MySQL we do something more clever. |
@@ -2121,54 +2238,61 @@ discard block |
||
| 2121 | 2238 | { |
| 2122 | 2239 | mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`'); |
| 2123 | 2240 | $result = mysqli_query($db_connection, $string); |
| 2124 | - if ($result !== false) |
|
| 2125 | - return $result; |
|
| 2241 | + if ($result !== false) { |
|
| 2242 | + return $result; |
|
| 2243 | + } |
|
| 2126 | 2244 | } |
| 2127 | - } |
|
| 2128 | - elseif ($mysqli_errno == 2013) |
|
| 2245 | + } elseif ($mysqli_errno == 2013) |
|
| 2129 | 2246 | { |
| 2130 | 2247 | $db_connection = mysqli_connect($db_server, $db_user, $db_passwd); |
| 2131 | 2248 | mysqli_select_db($db_connection, $db_name); |
| 2132 | 2249 | if ($db_connection) |
| 2133 | 2250 | { |
| 2134 | 2251 | $result = mysqli_query($db_connection, $string); |
| 2135 | - if ($result !== false) |
|
| 2136 | - return $result; |
|
| 2252 | + if ($result !== false) { |
|
| 2253 | + return $result; |
|
| 2254 | + } |
|
| 2137 | 2255 | } |
| 2138 | 2256 | } |
| 2139 | 2257 | // Duplicate column name... should be okay ;). |
| 2140 | - elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) |
|
| 2141 | - return false; |
|
| 2258 | + elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) { |
|
| 2259 | + return false; |
|
| 2260 | + } |
|
| 2142 | 2261 | // Duplicate insert... make sure it's the proper type of query ;). |
| 2143 | - elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) |
|
| 2144 | - return false; |
|
| 2262 | + elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) { |
|
| 2263 | + return false; |
|
| 2264 | + } |
|
| 2145 | 2265 | // Creating an index on a non-existent column. |
| 2146 | - elseif ($mysqli_errno == 1072) |
|
| 2147 | - return false; |
|
| 2148 | - elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') |
|
| 2149 | - return false; |
|
| 2266 | + elseif ($mysqli_errno == 1072) { |
|
| 2267 | + return false; |
|
| 2268 | + } elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') { |
|
| 2269 | + return false; |
|
| 2270 | + } |
|
| 2150 | 2271 | } |
| 2151 | 2272 | // If a table already exists don't go potty. |
| 2152 | 2273 | else |
| 2153 | 2274 | { |
| 2154 | 2275 | if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U'))) |
| 2155 | 2276 | { |
| 2156 | - if (strpos($db_error_message, 'exist') !== false) |
|
| 2157 | - return true; |
|
| 2158 | - } |
|
| 2159 | - elseif (strpos(trim($string), 'INSERT ') !== false) |
|
| 2277 | + if (strpos($db_error_message, 'exist') !== false) { |
|
| 2278 | + return true; |
|
| 2279 | + } |
|
| 2280 | + } elseif (strpos(trim($string), 'INSERT ') !== false) |
|
| 2160 | 2281 | { |
| 2161 | - if (strpos($db_error_message, 'duplicate') !== false) |
|
| 2162 | - return true; |
|
| 2282 | + if (strpos($db_error_message, 'duplicate') !== false) { |
|
| 2283 | + return true; |
|
| 2284 | + } |
|
| 2163 | 2285 | } |
| 2164 | 2286 | } |
| 2165 | 2287 | |
| 2166 | 2288 | // Get the query string so we pass everything. |
| 2167 | 2289 | $query_string = ''; |
| 2168 | - foreach ($_GET as $k => $v) |
|
| 2169 | - $query_string .= ';' . $k . '=' . $v; |
|
| 2170 | - if (strlen($query_string) != 0) |
|
| 2171 | - $query_string = '?' . substr($query_string, 1); |
|
| 2290 | + foreach ($_GET as $k => $v) { |
|
| 2291 | + $query_string .= ';' . $k . '=' . $v; |
|
| 2292 | + } |
|
| 2293 | + if (strlen($query_string) != 0) { |
|
| 2294 | + $query_string = '?' . substr($query_string, 1); |
|
| 2295 | + } |
|
| 2172 | 2296 | |
| 2173 | 2297 | if ($command_line) |
| 2174 | 2298 | { |
@@ -2254,16 +2378,18 @@ discard block |
||
| 2254 | 2378 | { |
| 2255 | 2379 | $found |= 1; |
| 2256 | 2380 | // Do some checks on the data if we have it set. |
| 2257 | - if (isset($change['col_type'])) |
|
| 2258 | - $found &= $change['col_type'] === $column['type']; |
|
| 2259 | - if (isset($change['null_allowed'])) |
|
| 2260 | - $found &= $column['null'] == $change['null_allowed']; |
|
| 2261 | - if (isset($change['default'])) |
|
| 2262 | - $found &= $change['default'] === $column['default']; |
|
| 2381 | + if (isset($change['col_type'])) { |
|
| 2382 | + $found &= $change['col_type'] === $column['type']; |
|
| 2383 | + } |
|
| 2384 | + if (isset($change['null_allowed'])) { |
|
| 2385 | + $found &= $column['null'] == $change['null_allowed']; |
|
| 2386 | + } |
|
| 2387 | + if (isset($change['default'])) { |
|
| 2388 | + $found &= $change['default'] === $column['default']; |
|
| 2389 | + } |
|
| 2263 | 2390 | } |
| 2264 | 2391 | } |
| 2265 | - } |
|
| 2266 | - elseif ($change['type'] === 'index') |
|
| 2392 | + } elseif ($change['type'] === 'index') |
|
| 2267 | 2393 | { |
| 2268 | 2394 | $request = upgrade_query(' |
| 2269 | 2395 | SHOW INDEX |
@@ -2272,9 +2398,10 @@ discard block |
||
| 2272 | 2398 | { |
| 2273 | 2399 | $cur_index = array(); |
| 2274 | 2400 | |
| 2275 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2276 | - if ($row['Key_name'] === $change['name']) |
|
| 2401 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2402 | + if ($row['Key_name'] === $change['name']) |
|
| 2277 | 2403 | $cur_index[(int) $row['Seq_in_index']] = $row['Column_name']; |
| 2404 | + } |
|
| 2278 | 2405 | |
| 2279 | 2406 | ksort($cur_index, SORT_NUMERIC); |
| 2280 | 2407 | $found = array_values($cur_index) === $change['target_columns']; |
@@ -2284,14 +2411,17 @@ discard block |
||
| 2284 | 2411 | } |
| 2285 | 2412 | |
| 2286 | 2413 | // If we're trying to add and it's added, we're done. |
| 2287 | - if ($found && in_array($change['method'], array('add', 'change'))) |
|
| 2288 | - return true; |
|
| 2414 | + if ($found && in_array($change['method'], array('add', 'change'))) { |
|
| 2415 | + return true; |
|
| 2416 | + } |
|
| 2289 | 2417 | // Otherwise if we're removing and it wasn't found we're also done. |
| 2290 | - elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) |
|
| 2291 | - return true; |
|
| 2418 | + elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) { |
|
| 2419 | + return true; |
|
| 2420 | + } |
|
| 2292 | 2421 | // Otherwise is it just a test? |
| 2293 | - elseif ($is_test) |
|
| 2294 | - return false; |
|
| 2422 | + elseif ($is_test) { |
|
| 2423 | + return false; |
|
| 2424 | + } |
|
| 2295 | 2425 | |
| 2296 | 2426 | // Not found it yet? Bummer! How about we see if we're currently doing it? |
| 2297 | 2427 | $running = false; |
@@ -2302,8 +2432,9 @@ discard block |
||
| 2302 | 2432 | SHOW FULL PROCESSLIST'); |
| 2303 | 2433 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2304 | 2434 | { |
| 2305 | - if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) |
|
| 2306 | - $found = true; |
|
| 2435 | + if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) { |
|
| 2436 | + $found = true; |
|
| 2437 | + } |
|
| 2307 | 2438 | } |
| 2308 | 2439 | |
| 2309 | 2440 | // Can't find it? Then we need to run it fools! |
@@ -2315,8 +2446,9 @@ discard block |
||
| 2315 | 2446 | ALTER TABLE ' . $db_prefix . $change['table'] . ' |
| 2316 | 2447 | ' . $change['text'], true) !== false; |
| 2317 | 2448 | |
| 2318 | - if (!$success) |
|
| 2319 | - return false; |
|
| 2449 | + if (!$success) { |
|
| 2450 | + return false; |
|
| 2451 | + } |
|
| 2320 | 2452 | |
| 2321 | 2453 | // Return |
| 2322 | 2454 | $running = true; |
@@ -2349,8 +2481,7 @@ discard block |
||
| 2349 | 2481 | { |
| 2350 | 2482 | $column_fix = true; |
| 2351 | 2483 | $null_fix = !$change['null_allowed']; |
| 2352 | - } |
|
| 2353 | - else |
|
| 2484 | + } else |
|
| 2354 | 2485 | { |
| 2355 | 2486 | $request = $smcFunc['db_query']('', ' |
| 2356 | 2487 | SHOW FULL COLUMNS |
@@ -2361,8 +2492,9 @@ discard block |
||
| 2361 | 2492 | 'db_error_skip' => true, |
| 2362 | 2493 | ) |
| 2363 | 2494 | ); |
| 2364 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2365 | - die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
| 2495 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2496 | + die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
| 2497 | + } |
|
| 2366 | 2498 | $table_row = $smcFunc['db_fetch_assoc']($request); |
| 2367 | 2499 | $smcFunc['db_free_result']($request); |
| 2368 | 2500 | |
@@ -2384,10 +2516,11 @@ discard block |
||
| 2384 | 2516 | ) |
| 2385 | 2517 | ); |
| 2386 | 2518 | // No results? Just forget it all together. |
| 2387 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2388 | - unset($table_row['Collation']); |
|
| 2389 | - else |
|
| 2390 | - $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2519 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2520 | + unset($table_row['Collation']); |
|
| 2521 | + } else { |
|
| 2522 | + $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2523 | + } |
|
| 2391 | 2524 | $smcFunc['db_free_result']($request); |
| 2392 | 2525 | } |
| 2393 | 2526 | } |
@@ -2395,8 +2528,8 @@ discard block |
||
| 2395 | 2528 | if ($column_fix) |
| 2396 | 2529 | { |
| 2397 | 2530 | // Make sure there are no NULL's left. |
| 2398 | - if ($null_fix) |
|
| 2399 | - $smcFunc['db_query']('', ' |
|
| 2531 | + if ($null_fix) { |
|
| 2532 | + $smcFunc['db_query']('', ' |
|
| 2400 | 2533 | UPDATE {db_prefix}' . $change['table'] . ' |
| 2401 | 2534 | SET ' . $change['column'] . ' = {string:default} |
| 2402 | 2535 | WHERE ' . $change['column'] . ' IS NULL', |
@@ -2405,6 +2538,7 @@ discard block |
||
| 2405 | 2538 | 'db_error_skip' => true, |
| 2406 | 2539 | ) |
| 2407 | 2540 | ); |
| 2541 | + } |
|
| 2408 | 2542 | |
| 2409 | 2543 | // Do the actual alteration. |
| 2410 | 2544 | $smcFunc['db_query']('', ' |
@@ -2433,8 +2567,9 @@ discard block |
||
| 2433 | 2567 | } |
| 2434 | 2568 | |
| 2435 | 2569 | // Not a column we need to check on? |
| 2436 | - if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) |
|
| 2437 | - return; |
|
| 2570 | + if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) { |
|
| 2571 | + return; |
|
| 2572 | + } |
|
| 2438 | 2573 | |
| 2439 | 2574 | // Break it up you (six|seven). |
| 2440 | 2575 | $temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text'])); |
@@ -2453,13 +2588,13 @@ discard block |
||
| 2453 | 2588 | 'new_name' => $temp[2], |
| 2454 | 2589 | )); |
| 2455 | 2590 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
| 2456 | - if ($smcFunc['db_num_rows'] != 1) |
|
| 2457 | - return; |
|
| 2591 | + if ($smcFunc['db_num_rows'] != 1) { |
|
| 2592 | + return; |
|
| 2593 | + } |
|
| 2458 | 2594 | |
| 2459 | 2595 | list (, $current_type) = $smcFunc['db_fetch_assoc']($request); |
| 2460 | 2596 | $smcFunc['db_free_result']($request); |
| 2461 | - } |
|
| 2462 | - else |
|
| 2597 | + } else |
|
| 2463 | 2598 | { |
| 2464 | 2599 | // Do this the old fashion, sure method way. |
| 2465 | 2600 | $request = $smcFunc['db_query']('', ' |
@@ -2470,21 +2605,24 @@ discard block |
||
| 2470 | 2605 | )); |
| 2471 | 2606 | // Mayday! |
| 2472 | 2607 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
| 2473 | - if ($smcFunc['db_num_rows'] == 0) |
|
| 2474 | - return; |
|
| 2608 | + if ($smcFunc['db_num_rows'] == 0) { |
|
| 2609 | + return; |
|
| 2610 | + } |
|
| 2475 | 2611 | |
| 2476 | 2612 | // Oh where, oh where has my little field gone. Oh where can it be... |
| 2477 | - while ($row = $smcFunc['db_query']($request)) |
|
| 2478 | - if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
| 2613 | + while ($row = $smcFunc['db_query']($request)) { |
|
| 2614 | + if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
| 2479 | 2615 | { |
| 2480 | 2616 | $current_type = $row['Type']; |
| 2617 | + } |
|
| 2481 | 2618 | break; |
| 2482 | 2619 | } |
| 2483 | 2620 | } |
| 2484 | 2621 | |
| 2485 | 2622 | // If this doesn't match, the column may of been altered for a reason. |
| 2486 | - if (trim($current_type) != trim($temp[3])) |
|
| 2487 | - $temp[3] = $current_type; |
|
| 2623 | + if (trim($current_type) != trim($temp[3])) { |
|
| 2624 | + $temp[3] = $current_type; |
|
| 2625 | + } |
|
| 2488 | 2626 | |
| 2489 | 2627 | // Piece this back together. |
| 2490 | 2628 | $change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp)); |
@@ -2496,8 +2634,9 @@ discard block |
||
| 2496 | 2634 | global $start_time, $timeLimitThreshold, $command_line, $custom_warning; |
| 2497 | 2635 | global $step_progress, $is_debug, $upcontext; |
| 2498 | 2636 | |
| 2499 | - if ($_GET['substep'] < $substep) |
|
| 2500 | - $_GET['substep'] = $substep; |
|
| 2637 | + if ($_GET['substep'] < $substep) { |
|
| 2638 | + $_GET['substep'] = $substep; |
|
| 2639 | + } |
|
| 2501 | 2640 | |
| 2502 | 2641 | if ($command_line) |
| 2503 | 2642 | { |
@@ -2510,29 +2649,33 @@ discard block |
||
| 2510 | 2649 | } |
| 2511 | 2650 | |
| 2512 | 2651 | @set_time_limit(300); |
| 2513 | - if (function_exists('apache_reset_timeout')) |
|
| 2514 | - @apache_reset_timeout(); |
|
| 2652 | + if (function_exists('apache_reset_timeout')) { |
|
| 2653 | + @apache_reset_timeout(); |
|
| 2654 | + } |
|
| 2515 | 2655 | |
| 2516 | - if (time() - $start_time <= $timeLimitThreshold) |
|
| 2517 | - return; |
|
| 2656 | + if (time() - $start_time <= $timeLimitThreshold) { |
|
| 2657 | + return; |
|
| 2658 | + } |
|
| 2518 | 2659 | |
| 2519 | 2660 | // Do we have some custom step progress stuff? |
| 2520 | 2661 | if (!empty($step_progress)) |
| 2521 | 2662 | { |
| 2522 | 2663 | $upcontext['substep_progress'] = 0; |
| 2523 | 2664 | $upcontext['substep_progress_name'] = $step_progress['name']; |
| 2524 | - if ($step_progress['current'] > $step_progress['total']) |
|
| 2525 | - $upcontext['substep_progress'] = 99.9; |
|
| 2526 | - else |
|
| 2527 | - $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
| 2665 | + if ($step_progress['current'] > $step_progress['total']) { |
|
| 2666 | + $upcontext['substep_progress'] = 99.9; |
|
| 2667 | + } else { |
|
| 2668 | + $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
| 2669 | + } |
|
| 2528 | 2670 | |
| 2529 | 2671 | // Make it nicely rounded. |
| 2530 | 2672 | $upcontext['substep_progress'] = round($upcontext['substep_progress'], 1); |
| 2531 | 2673 | } |
| 2532 | 2674 | |
| 2533 | 2675 | // If this is XML we just exit right away! |
| 2534 | - if (isset($_GET['xml'])) |
|
| 2535 | - return upgradeExit(); |
|
| 2676 | + if (isset($_GET['xml'])) { |
|
| 2677 | + return upgradeExit(); |
|
| 2678 | + } |
|
| 2536 | 2679 | |
| 2537 | 2680 | // We're going to pause after this! |
| 2538 | 2681 | $upcontext['pause'] = true; |
@@ -2540,13 +2683,15 @@ discard block |
||
| 2540 | 2683 | $upcontext['query_string'] = ''; |
| 2541 | 2684 | foreach ($_GET as $k => $v) |
| 2542 | 2685 | { |
| 2543 | - if ($k != 'data' && $k != 'substep' && $k != 'step') |
|
| 2544 | - $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
| 2686 | + if ($k != 'data' && $k != 'substep' && $k != 'step') { |
|
| 2687 | + $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
| 2688 | + } |
|
| 2545 | 2689 | } |
| 2546 | 2690 | |
| 2547 | 2691 | // Custom warning? |
| 2548 | - if (!empty($custom_warning)) |
|
| 2549 | - $upcontext['custom_warning'] = $custom_warning; |
|
| 2692 | + if (!empty($custom_warning)) { |
|
| 2693 | + $upcontext['custom_warning'] = $custom_warning; |
|
| 2694 | + } |
|
| 2550 | 2695 | |
| 2551 | 2696 | upgradeExit(); |
| 2552 | 2697 | } |
@@ -2561,25 +2706,26 @@ discard block |
||
| 2561 | 2706 | ob_implicit_flush(true); |
| 2562 | 2707 | @set_time_limit(600); |
| 2563 | 2708 | |
| 2564 | - if (!isset($_SERVER['argv'])) |
|
| 2565 | - $_SERVER['argv'] = array(); |
|
| 2709 | + if (!isset($_SERVER['argv'])) { |
|
| 2710 | + $_SERVER['argv'] = array(); |
|
| 2711 | + } |
|
| 2566 | 2712 | $_GET['maint'] = 1; |
| 2567 | 2713 | |
| 2568 | 2714 | foreach ($_SERVER['argv'] as $i => $arg) |
| 2569 | 2715 | { |
| 2570 | - if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) |
|
| 2571 | - $_GET['lang'] = $match[1]; |
|
| 2572 | - elseif (preg_match('~^--path=(.+)$~', $arg) != 0) |
|
| 2573 | - continue; |
|
| 2574 | - elseif ($arg == '--no-maintenance') |
|
| 2575 | - $_GET['maint'] = 0; |
|
| 2576 | - elseif ($arg == '--debug') |
|
| 2577 | - $is_debug = true; |
|
| 2578 | - elseif ($arg == '--backup') |
|
| 2579 | - $_POST['backup'] = 1; |
|
| 2580 | - elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) |
|
| 2581 | - $_GET['conv'] = 1; |
|
| 2582 | - elseif ($i != 0) |
|
| 2716 | + if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) { |
|
| 2717 | + $_GET['lang'] = $match[1]; |
|
| 2718 | + } elseif (preg_match('~^--path=(.+)$~', $arg) != 0) { |
|
| 2719 | + continue; |
|
| 2720 | + } elseif ($arg == '--no-maintenance') { |
|
| 2721 | + $_GET['maint'] = 0; |
|
| 2722 | + } elseif ($arg == '--debug') { |
|
| 2723 | + $is_debug = true; |
|
| 2724 | + } elseif ($arg == '--backup') { |
|
| 2725 | + $_POST['backup'] = 1; |
|
| 2726 | + } elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) { |
|
| 2727 | + $_GET['conv'] = 1; |
|
| 2728 | + } elseif ($i != 0) |
|
| 2583 | 2729 | { |
| 2584 | 2730 | echo 'SMF Command-line Upgrader |
| 2585 | 2731 | Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]... |
@@ -2593,10 +2739,12 @@ discard block |
||
| 2593 | 2739 | } |
| 2594 | 2740 | } |
| 2595 | 2741 | |
| 2596 | - if (!php_version_check()) |
|
| 2597 | - print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
| 2598 | - if (!db_version_check()) |
|
| 2599 | - print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
| 2742 | + if (!php_version_check()) { |
|
| 2743 | + print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
| 2744 | + } |
|
| 2745 | + if (!db_version_check()) { |
|
| 2746 | + print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
| 2747 | + } |
|
| 2600 | 2748 | |
| 2601 | 2749 | // Do some checks to make sure they have proper privileges |
| 2602 | 2750 | db_extend('packages'); |
@@ -2611,34 +2759,39 @@ discard block |
||
| 2611 | 2759 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
| 2612 | 2760 | |
| 2613 | 2761 | // Sorry... we need CREATE, ALTER and DROP |
| 2614 | - if (!$create || !$alter || !$drop) |
|
| 2615 | - 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); |
|
| 2762 | + if (!$create || !$alter || !$drop) { |
|
| 2763 | + 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); |
|
| 2764 | + } |
|
| 2616 | 2765 | |
| 2617 | 2766 | $check = @file_exists($modSettings['theme_dir'] . '/index.template.php') |
| 2618 | 2767 | && @file_exists($sourcedir . '/QueryString.php') |
| 2619 | 2768 | && @file_exists($sourcedir . '/ManageBoards.php'); |
| 2620 | - if (!$check && !isset($modSettings['smfVersion'])) |
|
| 2621 | - print_error('Error: Some files are missing or out-of-date.', true); |
|
| 2769 | + if (!$check && !isset($modSettings['smfVersion'])) { |
|
| 2770 | + print_error('Error: Some files are missing or out-of-date.', true); |
|
| 2771 | + } |
|
| 2622 | 2772 | |
| 2623 | 2773 | // Do a quick version spot check. |
| 2624 | 2774 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
| 2625 | 2775 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
| 2626 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
| 2627 | - print_error('Error: Some files have not yet been updated properly.'); |
|
| 2776 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
| 2777 | + print_error('Error: Some files have not yet been updated properly.'); |
|
| 2778 | + } |
|
| 2628 | 2779 | |
| 2629 | 2780 | // Make sure Settings.php is writable. |
| 2630 | 2781 | quickFileWritable($boarddir . '/Settings.php'); |
| 2631 | - if (!is_writable($boarddir . '/Settings.php')) |
|
| 2632 | - print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
| 2782 | + if (!is_writable($boarddir . '/Settings.php')) { |
|
| 2783 | + print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
| 2784 | + } |
|
| 2633 | 2785 | |
| 2634 | 2786 | // Make sure Settings_bak.php is writable. |
| 2635 | 2787 | quickFileWritable($boarddir . '/Settings_bak.php'); |
| 2636 | - if (!is_writable($boarddir . '/Settings_bak.php')) |
|
| 2637 | - print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
| 2788 | + if (!is_writable($boarddir . '/Settings_bak.php')) { |
|
| 2789 | + print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
| 2790 | + } |
|
| 2638 | 2791 | |
| 2639 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
| 2640 | - print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
| 2641 | - elseif (isset($modSettings['agreement'])) |
|
| 2792 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
| 2793 | + print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
| 2794 | + } elseif (isset($modSettings['agreement'])) |
|
| 2642 | 2795 | { |
| 2643 | 2796 | $fp = fopen($boarddir . '/agreement.txt', 'w'); |
| 2644 | 2797 | fwrite($fp, $modSettings['agreement']); |
@@ -2648,31 +2801,36 @@ discard block |
||
| 2648 | 2801 | // Make sure Themes is writable. |
| 2649 | 2802 | quickFileWritable($modSettings['theme_dir']); |
| 2650 | 2803 | |
| 2651 | - if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) |
|
| 2652 | - print_error('Error: Unable to obtain write access to "Themes".'); |
|
| 2804 | + if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) { |
|
| 2805 | + print_error('Error: Unable to obtain write access to "Themes".'); |
|
| 2806 | + } |
|
| 2653 | 2807 | |
| 2654 | 2808 | // Make sure cache directory exists and is writable! |
| 2655 | 2809 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
| 2656 | - if (!file_exists($cachedir_temp)) |
|
| 2657 | - @mkdir($cachedir_temp); |
|
| 2810 | + if (!file_exists($cachedir_temp)) { |
|
| 2811 | + @mkdir($cachedir_temp); |
|
| 2812 | + } |
|
| 2658 | 2813 | |
| 2659 | 2814 | // Make sure the cache temp dir is writable. |
| 2660 | 2815 | quickFileWritable($cachedir_temp); |
| 2661 | 2816 | |
| 2662 | - if (!is_writable($cachedir_temp)) |
|
| 2663 | - print_error('Error: Unable to obtain write access to "cache".', true); |
|
| 2817 | + if (!is_writable($cachedir_temp)) { |
|
| 2818 | + print_error('Error: Unable to obtain write access to "cache".', true); |
|
| 2819 | + } |
|
| 2664 | 2820 | |
| 2665 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
| 2666 | - print_error('Error: Unable to find language files!', true); |
|
| 2667 | - else |
|
| 2821 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
| 2822 | + print_error('Error: Unable to find language files!', true); |
|
| 2823 | + } else |
|
| 2668 | 2824 | { |
| 2669 | 2825 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
| 2670 | 2826 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 2671 | 2827 | |
| 2672 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 2673 | - print_error('Error: Language files out of date.', true); |
|
| 2674 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 2675 | - print_error('Error: Install language is missing for selected language.', true); |
|
| 2828 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 2829 | + print_error('Error: Language files out of date.', true); |
|
| 2830 | + } |
|
| 2831 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 2832 | + print_error('Error: Install language is missing for selected language.', true); |
|
| 2833 | + } |
|
| 2676 | 2834 | |
| 2677 | 2835 | // Otherwise include it! |
| 2678 | 2836 | require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
@@ -2687,14 +2845,16 @@ discard block |
||
| 2687 | 2845 | { |
| 2688 | 2846 | static $fp = null; |
| 2689 | 2847 | |
| 2690 | - if ($fp === null) |
|
| 2691 | - $fp = fopen('php://stderr', 'wb'); |
|
| 2848 | + if ($fp === null) { |
|
| 2849 | + $fp = fopen('php://stderr', 'wb'); |
|
| 2850 | + } |
|
| 2692 | 2851 | |
| 2693 | 2852 | fwrite($fp, $message . "\n"); |
| 2694 | 2853 | |
| 2695 | - if ($fatal) |
|
| 2696 | - exit; |
|
| 2697 | -} |
|
| 2854 | + if ($fatal) { |
|
| 2855 | + exit; |
|
| 2856 | + } |
|
| 2857 | + } |
|
| 2698 | 2858 | |
| 2699 | 2859 | function throw_error($message) |
| 2700 | 2860 | { |
@@ -2711,8 +2871,9 @@ discard block |
||
| 2711 | 2871 | { |
| 2712 | 2872 | global $upcontext, $boarddir; |
| 2713 | 2873 | |
| 2714 | - if (empty($files)) |
|
| 2715 | - return true; |
|
| 2874 | + if (empty($files)) { |
|
| 2875 | + return true; |
|
| 2876 | + } |
|
| 2716 | 2877 | |
| 2717 | 2878 | $failure = false; |
| 2718 | 2879 | // On linux, it's easy - just use is_writable! |
@@ -2727,14 +2888,16 @@ discard block |
||
| 2727 | 2888 | @chmod($file, 0755); |
| 2728 | 2889 | |
| 2729 | 2890 | // Well, 755 hopefully worked... if not, try 777. |
| 2730 | - if (!is_writable($file) && !@chmod($file, 0777)) |
|
| 2731 | - $failure = true; |
|
| 2891 | + if (!is_writable($file) && !@chmod($file, 0777)) { |
|
| 2892 | + $failure = true; |
|
| 2893 | + } |
|
| 2732 | 2894 | // Otherwise remove it as it's good! |
| 2733 | - else |
|
| 2734 | - unset($files[$k]); |
|
| 2895 | + else { |
|
| 2896 | + unset($files[$k]); |
|
| 2897 | + } |
|
| 2898 | + } else { |
|
| 2899 | + unset($files[$k]); |
|
| 2735 | 2900 | } |
| 2736 | - else |
|
| 2737 | - unset($files[$k]); |
|
| 2738 | 2901 | } |
| 2739 | 2902 | } |
| 2740 | 2903 | // Windows is trickier. Let's try opening for r+... |
@@ -2745,30 +2908,35 @@ discard block |
||
| 2745 | 2908 | foreach ($files as $k => $file) |
| 2746 | 2909 | { |
| 2747 | 2910 | // Folders can't be opened for write... but the index.php in them can ;). |
| 2748 | - if (is_dir($file)) |
|
| 2749 | - $file .= '/index.php'; |
|
| 2911 | + if (is_dir($file)) { |
|
| 2912 | + $file .= '/index.php'; |
|
| 2913 | + } |
|
| 2750 | 2914 | |
| 2751 | 2915 | // Funny enough, chmod actually does do something on windows - it removes the read only attribute. |
| 2752 | 2916 | @chmod($file, 0777); |
| 2753 | 2917 | $fp = @fopen($file, 'r+'); |
| 2754 | 2918 | |
| 2755 | 2919 | // Hmm, okay, try just for write in that case... |
| 2756 | - if (!$fp) |
|
| 2757 | - $fp = @fopen($file, 'w'); |
|
| 2920 | + if (!$fp) { |
|
| 2921 | + $fp = @fopen($file, 'w'); |
|
| 2922 | + } |
|
| 2758 | 2923 | |
| 2759 | - if (!$fp) |
|
| 2760 | - $failure = true; |
|
| 2761 | - else |
|
| 2762 | - unset($files[$k]); |
|
| 2924 | + if (!$fp) { |
|
| 2925 | + $failure = true; |
|
| 2926 | + } else { |
|
| 2927 | + unset($files[$k]); |
|
| 2928 | + } |
|
| 2763 | 2929 | @fclose($fp); |
| 2764 | 2930 | } |
| 2765 | 2931 | } |
| 2766 | 2932 | |
| 2767 | - if (empty($files)) |
|
| 2768 | - return true; |
|
| 2933 | + if (empty($files)) { |
|
| 2934 | + return true; |
|
| 2935 | + } |
|
| 2769 | 2936 | |
| 2770 | - if (!isset($_SERVER)) |
|
| 2771 | - return !$failure; |
|
| 2937 | + if (!isset($_SERVER)) { |
|
| 2938 | + return !$failure; |
|
| 2939 | + } |
|
| 2772 | 2940 | |
| 2773 | 2941 | // What still needs to be done? |
| 2774 | 2942 | $upcontext['chmod']['files'] = $files; |
@@ -2819,36 +2987,40 @@ discard block |
||
| 2819 | 2987 | |
| 2820 | 2988 | if (!isset($ftp) || $ftp->error !== false) |
| 2821 | 2989 | { |
| 2822 | - if (!isset($ftp)) |
|
| 2823 | - $ftp = new ftp_connection(null); |
|
| 2990 | + if (!isset($ftp)) { |
|
| 2991 | + $ftp = new ftp_connection(null); |
|
| 2992 | + } |
|
| 2824 | 2993 | // Save the error so we can mess with listing... |
| 2825 | - elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error'])) |
|
| 2826 | - $upcontext['chmod']['ftp_error'] = $ftp->last_message === null ? '' : $ftp->last_message; |
|
| 2994 | + elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error'])) { |
|
| 2995 | + $upcontext['chmod']['ftp_error'] = $ftp->last_message === null ? '' : $ftp->last_message; |
|
| 2996 | + } |
|
| 2827 | 2997 | |
| 2828 | 2998 | list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__)); |
| 2829 | 2999 | |
| 2830 | - if ($found_path || !isset($upcontext['chmod']['path'])) |
|
| 2831 | - $upcontext['chmod']['path'] = $detect_path; |
|
| 3000 | + if ($found_path || !isset($upcontext['chmod']['path'])) { |
|
| 3001 | + $upcontext['chmod']['path'] = $detect_path; |
|
| 3002 | + } |
|
| 2832 | 3003 | |
| 2833 | - if (!isset($upcontext['chmod']['username'])) |
|
| 2834 | - $upcontext['chmod']['username'] = $username; |
|
| 3004 | + if (!isset($upcontext['chmod']['username'])) { |
|
| 3005 | + $upcontext['chmod']['username'] = $username; |
|
| 3006 | + } |
|
| 2835 | 3007 | |
| 2836 | 3008 | // Don't forget the login token. |
| 2837 | 3009 | $upcontext += createToken('login'); |
| 2838 | 3010 | |
| 2839 | 3011 | return false; |
| 2840 | - } |
|
| 2841 | - else |
|
| 3012 | + } else |
|
| 2842 | 3013 | { |
| 2843 | 3014 | // We want to do a relative path for FTP. |
| 2844 | 3015 | if (!in_array($upcontext['chmod']['path'], array('', '/'))) |
| 2845 | 3016 | { |
| 2846 | 3017 | $ftp_root = strtr($boarddir, array($upcontext['chmod']['path'] => '')); |
| 2847 | - if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/')) |
|
| 2848 | - $ftp_root = substr($ftp_root, 0, -1); |
|
| 3018 | + if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/')) { |
|
| 3019 | + $ftp_root = substr($ftp_root, 0, -1); |
|
| 3020 | + } |
|
| 3021 | + } else { |
|
| 3022 | + $ftp_root = $boarddir; |
|
| 2849 | 3023 | } |
| 2850 | - else |
|
| 2851 | - $ftp_root = $boarddir; |
|
| 2852 | 3024 | |
| 2853 | 3025 | // Save the info for next time! |
| 2854 | 3026 | $_SESSION['installer_temp_ftp'] = array( |
@@ -2862,10 +3034,12 @@ discard block |
||
| 2862 | 3034 | |
| 2863 | 3035 | foreach ($files as $k => $file) |
| 2864 | 3036 | { |
| 2865 | - if (!is_writable($file)) |
|
| 2866 | - $ftp->chmod($file, 0755); |
|
| 2867 | - if (!is_writable($file)) |
|
| 2868 | - $ftp->chmod($file, 0777); |
|
| 3037 | + if (!is_writable($file)) { |
|
| 3038 | + $ftp->chmod($file, 0755); |
|
| 3039 | + } |
|
| 3040 | + if (!is_writable($file)) { |
|
| 3041 | + $ftp->chmod($file, 0777); |
|
| 3042 | + } |
|
| 2869 | 3043 | |
| 2870 | 3044 | // Assuming that didn't work calculate the path without the boarddir. |
| 2871 | 3045 | if (!is_writable($file)) |
@@ -2874,19 +3048,23 @@ discard block |
||
| 2874 | 3048 | { |
| 2875 | 3049 | $ftp_file = strtr($file, array($_SESSION['installer_temp_ftp']['root'] => '')); |
| 2876 | 3050 | $ftp->chmod($ftp_file, 0755); |
| 2877 | - if (!is_writable($file)) |
|
| 2878 | - $ftp->chmod($ftp_file, 0777); |
|
| 3051 | + if (!is_writable($file)) { |
|
| 3052 | + $ftp->chmod($ftp_file, 0777); |
|
| 3053 | + } |
|
| 2879 | 3054 | // Sometimes an extra slash can help... |
| 2880 | 3055 | $ftp_file = '/' . $ftp_file; |
| 2881 | - if (!is_writable($file)) |
|
| 2882 | - $ftp->chmod($ftp_file, 0755); |
|
| 2883 | - if (!is_writable($file)) |
|
| 2884 | - $ftp->chmod($ftp_file, 0777); |
|
| 3056 | + if (!is_writable($file)) { |
|
| 3057 | + $ftp->chmod($ftp_file, 0755); |
|
| 3058 | + } |
|
| 3059 | + if (!is_writable($file)) { |
|
| 3060 | + $ftp->chmod($ftp_file, 0777); |
|
| 3061 | + } |
|
| 2885 | 3062 | } |
| 2886 | 3063 | } |
| 2887 | 3064 | |
| 2888 | - if (is_writable($file)) |
|
| 2889 | - unset($files[$k]); |
|
| 3065 | + if (is_writable($file)) { |
|
| 3066 | + unset($files[$k]); |
|
| 3067 | + } |
|
| 2890 | 3068 | } |
| 2891 | 3069 | |
| 2892 | 3070 | $ftp->close(); |
@@ -2896,16 +3074,18 @@ discard block |
||
| 2896 | 3074 | // What remains? |
| 2897 | 3075 | $upcontext['chmod']['files'] = $files; |
| 2898 | 3076 | |
| 2899 | - if (empty($files)) |
|
| 2900 | - return true; |
|
| 3077 | + if (empty($files)) { |
|
| 3078 | + return true; |
|
| 3079 | + } |
|
| 2901 | 3080 | |
| 2902 | 3081 | return false; |
| 2903 | 3082 | } |
| 2904 | 3083 | |
| 2905 | 3084 | function quickFileWritable($file) |
| 2906 | 3085 | { |
| 2907 | - if (is_writable($file)) |
|
| 2908 | - return true; |
|
| 3086 | + if (is_writable($file)) { |
|
| 3087 | + return true; |
|
| 3088 | + } |
|
| 2909 | 3089 | |
| 2910 | 3090 | @chmod($file, 0755); |
| 2911 | 3091 | |
@@ -2915,17 +3095,19 @@ discard block |
||
| 2915 | 3095 | foreach ($chmod_values as $val) |
| 2916 | 3096 | { |
| 2917 | 3097 | // If it's writable, break out of the loop |
| 2918 | - if (is_writable($file)) |
|
| 2919 | - break; |
|
| 2920 | - else |
|
| 2921 | - @chmod($file, $val); |
|
| 3098 | + if (is_writable($file)) { |
|
| 3099 | + break; |
|
| 3100 | + } else { |
|
| 3101 | + @chmod($file, $val); |
|
| 3102 | + } |
|
| 2922 | 3103 | } |
| 2923 | 3104 | } |
| 2924 | 3105 | function smf_strtolower($string) |
| 2925 | 3106 | { |
| 2926 | 3107 | global $sourcedir; |
| 2927 | - if (function_exists('mb_strtolower')) |
|
| 2928 | - return mb_strtolower($string, 'UTF-8'); |
|
| 3108 | + if (function_exists('mb_strtolower')) { |
|
| 3109 | + return mb_strtolower($string, 'UTF-8'); |
|
| 3110 | + } |
|
| 2929 | 3111 | require_once($sourcedir . '/Subs-Charset.php'); |
| 2930 | 3112 | return utf8_strtolower($string); |
| 2931 | 3113 | } |
@@ -2948,8 +3130,7 @@ discard block |
||
| 2948 | 3130 | ); |
| 2949 | 3131 | |
| 2950 | 3132 | return true; |
| 2951 | - } |
|
| 2952 | - else |
|
| 3133 | + } else |
|
| 2953 | 3134 | { |
| 2954 | 3135 | $upcontext['page_title'] = 'Converting to UTF8'; |
| 2955 | 3136 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8'; |
@@ -2993,8 +3174,9 @@ discard block |
||
| 2993 | 3174 | ) |
| 2994 | 3175 | ); |
| 2995 | 3176 | $db_charsets = array(); |
| 2996 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2997 | - $db_charsets[] = $row['Charset']; |
|
| 3177 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 3178 | + $db_charsets[] = $row['Charset']; |
|
| 3179 | + } |
|
| 2998 | 3180 | |
| 2999 | 3181 | $smcFunc['db_free_result']($request); |
| 3000 | 3182 | |
@@ -3030,13 +3212,15 @@ discard block |
||
| 3030 | 3212 | // If there's a fulltext index, we need to drop it first... |
| 3031 | 3213 | if ($request !== false || $smcFunc['db_num_rows']($request) != 0) |
| 3032 | 3214 | { |
| 3033 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 3034 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 3215 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 3216 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 3035 | 3217 | $upcontext['fulltext_index'][] = $row['Key_name']; |
| 3218 | + } |
|
| 3036 | 3219 | $smcFunc['db_free_result']($request); |
| 3037 | 3220 | |
| 3038 | - if (isset($upcontext['fulltext_index'])) |
|
| 3039 | - $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
| 3221 | + if (isset($upcontext['fulltext_index'])) { |
|
| 3222 | + $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
| 3223 | + } |
|
| 3040 | 3224 | } |
| 3041 | 3225 | |
| 3042 | 3226 | // Drop it and make a note... |
@@ -3226,8 +3410,9 @@ discard block |
||
| 3226 | 3410 | $replace = '%field%'; |
| 3227 | 3411 | |
| 3228 | 3412 | // Build a huge REPLACE statement... |
| 3229 | - foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) |
|
| 3230 | - $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
| 3413 | + foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) { |
|
| 3414 | + $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
| 3415 | + } |
|
| 3231 | 3416 | } |
| 3232 | 3417 | |
| 3233 | 3418 | // Get a list of table names ahead of time... This makes it easier to set our substep and such |
@@ -3260,8 +3445,9 @@ discard block |
||
| 3260 | 3445 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
| 3261 | 3446 | |
| 3262 | 3447 | // Just to make sure it doesn't time out. |
| 3263 | - if (function_exists('apache_reset_timeout')) |
|
| 3264 | - @apache_reset_timeout(); |
|
| 3448 | + if (function_exists('apache_reset_timeout')) { |
|
| 3449 | + @apache_reset_timeout(); |
|
| 3450 | + } |
|
| 3265 | 3451 | |
| 3266 | 3452 | $table_charsets = array(); |
| 3267 | 3453 | |
@@ -3282,8 +3468,9 @@ discard block |
||
| 3282 | 3468 | { |
| 3283 | 3469 | list($charset) = explode('_', $collation); |
| 3284 | 3470 | |
| 3285 | - if (!isset($table_charsets[$charset])) |
|
| 3286 | - $table_charsets[$charset] = array(); |
|
| 3471 | + if (!isset($table_charsets[$charset])) { |
|
| 3472 | + $table_charsets[$charset] = array(); |
|
| 3473 | + } |
|
| 3287 | 3474 | |
| 3288 | 3475 | $table_charsets[$charset][] = $column_info; |
| 3289 | 3476 | } |
@@ -3323,10 +3510,11 @@ discard block |
||
| 3323 | 3510 | if (isset($translation_tables[$upcontext['charset_detected']])) |
| 3324 | 3511 | { |
| 3325 | 3512 | $update = ''; |
| 3326 | - foreach ($table_charsets as $charset => $columns) |
|
| 3327 | - foreach ($columns as $column) |
|
| 3513 | + foreach ($table_charsets as $charset => $columns) { |
|
| 3514 | + foreach ($columns as $column) |
|
| 3328 | 3515 | $update .= ' |
| 3329 | 3516 | ' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ','; |
| 3517 | + } |
|
| 3330 | 3518 | |
| 3331 | 3519 | $smcFunc['db_query']('', ' |
| 3332 | 3520 | UPDATE {raw:table_name} |
@@ -3351,8 +3539,9 @@ discard block |
||
| 3351 | 3539 | // Now do the actual conversion (if still needed). |
| 3352 | 3540 | if ($charsets[$upcontext['charset_detected']] !== 'utf8') |
| 3353 | 3541 | { |
| 3354 | - if ($command_line) |
|
| 3355 | - echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
| 3542 | + if ($command_line) { |
|
| 3543 | + echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
| 3544 | + } |
|
| 3356 | 3545 | |
| 3357 | 3546 | $smcFunc['db_query']('', ' |
| 3358 | 3547 | ALTER TABLE {raw:table_name} |
@@ -3362,8 +3551,9 @@ discard block |
||
| 3362 | 3551 | ) |
| 3363 | 3552 | ); |
| 3364 | 3553 | |
| 3365 | - if ($command_line) |
|
| 3366 | - echo " done.\n"; |
|
| 3554 | + if ($command_line) { |
|
| 3555 | + echo " done.\n"; |
|
| 3556 | + } |
|
| 3367 | 3557 | } |
| 3368 | 3558 | } |
| 3369 | 3559 | |
@@ -3393,8 +3583,8 @@ discard block |
||
| 3393 | 3583 | ); |
| 3394 | 3584 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 3395 | 3585 | { |
| 3396 | - 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) |
|
| 3397 | - $smcFunc['db_query']('', ' |
|
| 3586 | + 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) { |
|
| 3587 | + $smcFunc['db_query']('', ' |
|
| 3398 | 3588 | UPDATE {db_prefix}log_actions |
| 3399 | 3589 | SET extra = {string:extra} |
| 3400 | 3590 | WHERE id_action = {int:current_action}', |
@@ -3403,6 +3593,7 @@ discard block |
||
| 3403 | 3593 | 'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4], |
| 3404 | 3594 | ) |
| 3405 | 3595 | ); |
| 3596 | + } |
|
| 3406 | 3597 | } |
| 3407 | 3598 | $smcFunc['db_free_result']($request); |
| 3408 | 3599 | |
@@ -3424,15 +3615,17 @@ discard block |
||
| 3424 | 3615 | // First thing's first - did we already do this? |
| 3425 | 3616 | if (!empty($modSettings['json_done'])) |
| 3426 | 3617 | { |
| 3427 | - if ($command_line) |
|
| 3428 | - return DeleteUpgrade(); |
|
| 3429 | - else |
|
| 3430 | - return true; |
|
| 3618 | + if ($command_line) { |
|
| 3619 | + return DeleteUpgrade(); |
|
| 3620 | + } else { |
|
| 3621 | + return true; |
|
| 3622 | + } |
|
| 3431 | 3623 | } |
| 3432 | 3624 | |
| 3433 | 3625 | // Done it already - js wise? |
| 3434 | - if (!empty($_POST['json_done'])) |
|
| 3435 | - return true; |
|
| 3626 | + if (!empty($_POST['json_done'])) { |
|
| 3627 | + return true; |
|
| 3628 | + } |
|
| 3436 | 3629 | |
| 3437 | 3630 | // List of tables affected by this function |
| 3438 | 3631 | // name => array('key', col1[,col2|true[,col3]]) |
@@ -3463,12 +3656,14 @@ discard block |
||
| 3463 | 3656 | $upcontext['cur_table_name'] = isset($keys[$_GET['substep']]) ? $keys[$_GET['substep']] : $keys[0]; |
| 3464 | 3657 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
| 3465 | 3658 | |
| 3466 | - foreach ($keys as $id => $table) |
|
| 3467 | - if ($id < $_GET['substep']) |
|
| 3659 | + foreach ($keys as $id => $table) { |
|
| 3660 | + if ($id < $_GET['substep']) |
|
| 3468 | 3661 | $upcontext['previous_tables'][] = $table; |
| 3662 | + } |
|
| 3469 | 3663 | |
| 3470 | - if ($command_line) |
|
| 3471 | - echo 'Converting data from serialize() to json_encode().'; |
|
| 3664 | + if ($command_line) { |
|
| 3665 | + echo 'Converting data from serialize() to json_encode().'; |
|
| 3666 | + } |
|
| 3472 | 3667 | |
| 3473 | 3668 | if (!$support_js || isset($_GET['xml'])) |
| 3474 | 3669 | { |
@@ -3508,8 +3703,9 @@ discard block |
||
| 3508 | 3703 | |
| 3509 | 3704 | // Loop through and fix these... |
| 3510 | 3705 | $new_settings = array(); |
| 3511 | - if ($command_line) |
|
| 3512 | - echo "\n" . 'Fixing some settings...'; |
|
| 3706 | + if ($command_line) { |
|
| 3707 | + echo "\n" . 'Fixing some settings...'; |
|
| 3708 | + } |
|
| 3513 | 3709 | |
| 3514 | 3710 | foreach ($serialized_settings as $var) |
| 3515 | 3711 | { |
@@ -3517,22 +3713,24 @@ discard block |
||
| 3517 | 3713 | { |
| 3518 | 3714 | // Attempt to unserialize the setting |
| 3519 | 3715 | $temp = @safe_unserialize($modSettings[$var]); |
| 3520 | - if (!$temp && $command_line) |
|
| 3521 | - echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
| 3522 | - elseif ($temp !== false) |
|
| 3523 | - $new_settings[$var] = json_encode($temp); |
|
| 3716 | + if (!$temp && $command_line) { |
|
| 3717 | + echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
| 3718 | + } elseif ($temp !== false) { |
|
| 3719 | + $new_settings[$var] = json_encode($temp); |
|
| 3720 | + } |
|
| 3524 | 3721 | } |
| 3525 | 3722 | } |
| 3526 | 3723 | |
| 3527 | 3724 | // Update everything at once |
| 3528 | - if (!function_exists('cache_put_data')) |
|
| 3529 | - require_once($sourcedir . '/Load.php'); |
|
| 3725 | + if (!function_exists('cache_put_data')) { |
|
| 3726 | + require_once($sourcedir . '/Load.php'); |
|
| 3727 | + } |
|
| 3530 | 3728 | updateSettings($new_settings, true); |
| 3531 | 3729 | |
| 3532 | - if ($command_line) |
|
| 3533 | - echo ' done.'; |
|
| 3534 | - } |
|
| 3535 | - elseif ($table == 'themes') |
|
| 3730 | + if ($command_line) { |
|
| 3731 | + echo ' done.'; |
|
| 3732 | + } |
|
| 3733 | + } elseif ($table == 'themes') |
|
| 3536 | 3734 | { |
| 3537 | 3735 | // Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point... |
| 3538 | 3736 | $query = $smcFunc['db_query']('', ' |
@@ -3551,10 +3749,11 @@ discard block |
||
| 3551 | 3749 | |
| 3552 | 3750 | if ($command_line) |
| 3553 | 3751 | { |
| 3554 | - if ($temp === false) |
|
| 3555 | - echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
| 3556 | - else |
|
| 3557 | - echo "\n" . 'Fixing admin preferences...'; |
|
| 3752 | + if ($temp === false) { |
|
| 3753 | + echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
| 3754 | + } else { |
|
| 3755 | + echo "\n" . 'Fixing admin preferences...'; |
|
| 3756 | + } |
|
| 3558 | 3757 | } |
| 3559 | 3758 | |
| 3560 | 3759 | if ($temp !== false) |
@@ -3574,15 +3773,15 @@ discard block |
||
| 3574 | 3773 | ) |
| 3575 | 3774 | ); |
| 3576 | 3775 | |
| 3577 | - if ($command_line) |
|
| 3578 | - echo ' done.'; |
|
| 3776 | + if ($command_line) { |
|
| 3777 | + echo ' done.'; |
|
| 3778 | + } |
|
| 3579 | 3779 | } |
| 3580 | 3780 | } |
| 3581 | 3781 | |
| 3582 | 3782 | $smcFunc['db_free_result']($query); |
| 3583 | 3783 | } |
| 3584 | - } |
|
| 3585 | - else |
|
| 3784 | + } else |
|
| 3586 | 3785 | { |
| 3587 | 3786 | // First item is always the key... |
| 3588 | 3787 | $key = $info[0]; |
@@ -3593,8 +3792,7 @@ discard block |
||
| 3593 | 3792 | { |
| 3594 | 3793 | $col_select = $info[1]; |
| 3595 | 3794 | $where = ' WHERE ' . $info[1] . ' != {empty}'; |
| 3596 | - } |
|
| 3597 | - else |
|
| 3795 | + } else |
|
| 3598 | 3796 | { |
| 3599 | 3797 | $col_select = implode(', ', $info); |
| 3600 | 3798 | } |
@@ -3627,8 +3825,7 @@ discard block |
||
| 3627 | 3825 | if ($temp === false && $command_line) |
| 3628 | 3826 | { |
| 3629 | 3827 | echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n"; |
| 3630 | - } |
|
| 3631 | - else |
|
| 3828 | + } else |
|
| 3632 | 3829 | { |
| 3633 | 3830 | $row[$col] = json_encode($temp); |
| 3634 | 3831 | |
@@ -3653,16 +3850,18 @@ discard block |
||
| 3653 | 3850 | } |
| 3654 | 3851 | } |
| 3655 | 3852 | |
| 3656 | - if ($command_line) |
|
| 3657 | - echo ' done.'; |
|
| 3853 | + if ($command_line) { |
|
| 3854 | + echo ' done.'; |
|
| 3855 | + } |
|
| 3658 | 3856 | |
| 3659 | 3857 | // Free up some memory... |
| 3660 | 3858 | $smcFunc['db_free_result']($query); |
| 3661 | 3859 | } |
| 3662 | 3860 | } |
| 3663 | 3861 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 3664 | - if (isset($_GET['xml'])) |
|
| 3665 | - return upgradeExit(); |
|
| 3862 | + if (isset($_GET['xml'])) { |
|
| 3863 | + return upgradeExit(); |
|
| 3864 | + } |
|
| 3666 | 3865 | } |
| 3667 | 3866 | |
| 3668 | 3867 | if ($command_line) |
@@ -3677,8 +3876,9 @@ discard block |
||
| 3677 | 3876 | |
| 3678 | 3877 | $_GET['substep'] = 0; |
| 3679 | 3878 | // Make sure we move on! |
| 3680 | - if ($command_line) |
|
| 3681 | - return DeleteUpgrade(); |
|
| 3879 | + if ($command_line) { |
|
| 3880 | + return DeleteUpgrade(); |
|
| 3881 | + } |
|
| 3682 | 3882 | |
| 3683 | 3883 | return true; |
| 3684 | 3884 | } |
@@ -3698,14 +3898,16 @@ discard block |
||
| 3698 | 3898 | global $upcontext, $txt, $settings; |
| 3699 | 3899 | |
| 3700 | 3900 | // Don't call me twice! |
| 3701 | - if (!empty($upcontext['chmod_called'])) |
|
| 3702 | - return; |
|
| 3901 | + if (!empty($upcontext['chmod_called'])) { |
|
| 3902 | + return; |
|
| 3903 | + } |
|
| 3703 | 3904 | |
| 3704 | 3905 | $upcontext['chmod_called'] = true; |
| 3705 | 3906 | |
| 3706 | 3907 | // Nothing? |
| 3707 | - if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) |
|
| 3708 | - return; |
|
| 3908 | + if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) { |
|
| 3909 | + return; |
|
| 3910 | + } |
|
| 3709 | 3911 | |
| 3710 | 3912 | // Was it a problem with Windows? |
| 3711 | 3913 | if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess') |
@@ -3737,11 +3939,12 @@ discard block |
||
| 3737 | 3939 | content.write(\'<div class="windowbg description">\n\t\t\t<h4>The following files needs to be made writable to continue:</h4>\n\t\t\t\'); |
| 3738 | 3940 | content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');'; |
| 3739 | 3941 | |
| 3740 | - if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') |
|
| 3741 | - echo ' |
|
| 3942 | + if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') { |
|
| 3943 | + echo ' |
|
| 3742 | 3944 | content.write(\'<hr>\n\t\t\t\'); |
| 3743 | 3945 | content.write(\'<p>If you have a shell account, the convenient below command can automatically correct permissions on these files</p>\n\t\t\t\'); |
| 3744 | 3946 | content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');'; |
| 3947 | + } |
|
| 3745 | 3948 | |
| 3746 | 3949 | echo ' |
| 3747 | 3950 | content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\'); |
@@ -3749,17 +3952,19 @@ discard block |
||
| 3749 | 3952 | } |
| 3750 | 3953 | </script>'; |
| 3751 | 3954 | |
| 3752 | - if (!empty($upcontext['chmod']['ftp_error'])) |
|
| 3753 | - echo ' |
|
| 3955 | + if (!empty($upcontext['chmod']['ftp_error'])) { |
|
| 3956 | + echo ' |
|
| 3754 | 3957 | <div class="error_message red"> |
| 3755 | 3958 | The following error was encountered when trying to connect:<br><br> |
| 3756 | 3959 | <code>', $upcontext['chmod']['ftp_error'], '</code> |
| 3757 | 3960 | </div> |
| 3758 | 3961 | <br>'; |
| 3962 | + } |
|
| 3759 | 3963 | |
| 3760 | - if (empty($upcontext['chmod_in_form'])) |
|
| 3761 | - echo ' |
|
| 3964 | + if (empty($upcontext['chmod_in_form'])) { |
|
| 3965 | + echo ' |
|
| 3762 | 3966 | <form action="', $upcontext['form_url'], '" method="post">'; |
| 3967 | + } |
|
| 3763 | 3968 | |
| 3764 | 3969 | echo ' |
| 3765 | 3970 | <table width="520" border="0" align="center" style="margin-bottom: 1ex;"> |
@@ -3794,10 +3999,11 @@ discard block |
||
| 3794 | 3999 | <div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['ftp_connect'], '" class="button_submit"></div> |
| 3795 | 4000 | </div>'; |
| 3796 | 4001 | |
| 3797 | - if (empty($upcontext['chmod_in_form'])) |
|
| 3798 | - echo ' |
|
| 4002 | + if (empty($upcontext['chmod_in_form'])) { |
|
| 4003 | + echo ' |
|
| 3799 | 4004 | </form>'; |
| 3800 | -} |
|
| 4005 | + } |
|
| 4006 | + } |
|
| 3801 | 4007 | |
| 3802 | 4008 | function template_upgrade_above() |
| 3803 | 4009 | { |
@@ -3857,9 +4063,10 @@ discard block |
||
| 3857 | 4063 | <h2>', $txt['upgrade_progress'], '</h2> |
| 3858 | 4064 | <ul>'; |
| 3859 | 4065 | |
| 3860 | - foreach ($upcontext['steps'] as $num => $step) |
|
| 3861 | - echo ' |
|
| 4066 | + foreach ($upcontext['steps'] as $num => $step) { |
|
| 4067 | + echo ' |
|
| 3862 | 4068 | <li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
| 4069 | + } |
|
| 3863 | 4070 | |
| 3864 | 4071 | echo ' |
| 3865 | 4072 | </ul> |
@@ -3872,8 +4079,8 @@ discard block |
||
| 3872 | 4079 | </div> |
| 3873 | 4080 | </div>'; |
| 3874 | 4081 | |
| 3875 | - if (isset($upcontext['step_progress'])) |
|
| 3876 | - echo ' |
|
| 4082 | + if (isset($upcontext['step_progress'])) { |
|
| 4083 | + echo ' |
|
| 3877 | 4084 | <br> |
| 3878 | 4085 | <br> |
| 3879 | 4086 | <div id="progress_bar_step"> |
@@ -3882,6 +4089,7 @@ discard block |
||
| 3882 | 4089 | <span>', $txt['upgrade_step_progress'], '</span> |
| 3883 | 4090 | </div> |
| 3884 | 4091 | </div>'; |
| 4092 | + } |
|
| 3885 | 4093 | |
| 3886 | 4094 | echo ' |
| 3887 | 4095 | <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> |
@@ -3912,32 +4120,36 @@ discard block |
||
| 3912 | 4120 | { |
| 3913 | 4121 | global $upcontext, $txt; |
| 3914 | 4122 | |
| 3915 | - if (!empty($upcontext['pause'])) |
|
| 3916 | - echo ' |
|
| 4123 | + if (!empty($upcontext['pause'])) { |
|
| 4124 | + echo ' |
|
| 3917 | 4125 | <em>', $txt['upgrade_incomplete'], '.</em><br> |
| 3918 | 4126 | |
| 3919 | 4127 | <h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2> |
| 3920 | 4128 | <h3> |
| 3921 | 4129 | ', $txt['upgrade_paused_overload'], ' |
| 3922 | 4130 | </h3>'; |
| 4131 | + } |
|
| 3923 | 4132 | |
| 3924 | - if (!empty($upcontext['custom_warning'])) |
|
| 3925 | - echo ' |
|
| 4133 | + if (!empty($upcontext['custom_warning'])) { |
|
| 4134 | + echo ' |
|
| 3926 | 4135 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3927 | 4136 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3928 | 4137 | <strong style="text-decoration: underline;">', $txt['upgrade_note'], '</strong><br> |
| 3929 | 4138 | <div style="padding-left: 6ex;">', $upcontext['custom_warning'], '</div> |
| 3930 | 4139 | </div>'; |
| 4140 | + } |
|
| 3931 | 4141 | |
| 3932 | 4142 | echo ' |
| 3933 | 4143 | <div class="righttext" style="margin: 1ex;">'; |
| 3934 | 4144 | |
| 3935 | - if (!empty($upcontext['continue'])) |
|
| 3936 | - echo ' |
|
| 4145 | + if (!empty($upcontext['continue'])) { |
|
| 4146 | + echo ' |
|
| 3937 | 4147 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button_submit">'; |
| 3938 | - if (!empty($upcontext['skip'])) |
|
| 3939 | - echo ' |
|
| 4148 | + } |
|
| 4149 | + if (!empty($upcontext['skip'])) { |
|
| 4150 | + echo ' |
|
| 3940 | 4151 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button_submit">'; |
| 4152 | + } |
|
| 3941 | 4153 | |
| 3942 | 4154 | echo ' |
| 3943 | 4155 | </div> |
@@ -3987,11 +4199,12 @@ discard block |
||
| 3987 | 4199 | echo '<', '?xml version="1.0" encoding="UTF-8"?', '> |
| 3988 | 4200 | <smf>'; |
| 3989 | 4201 | |
| 3990 | - if (!empty($upcontext['get_data'])) |
|
| 3991 | - foreach ($upcontext['get_data'] as $k => $v) |
|
| 4202 | + if (!empty($upcontext['get_data'])) { |
|
| 4203 | + foreach ($upcontext['get_data'] as $k => $v) |
|
| 3992 | 4204 | echo ' |
| 3993 | 4205 | <get key="', $k, '">', $v, '</get>'; |
| 3994 | -} |
|
| 4206 | + } |
|
| 4207 | + } |
|
| 3995 | 4208 | |
| 3996 | 4209 | function template_xml_below() |
| 3997 | 4210 | { |
@@ -4032,8 +4245,8 @@ discard block |
||
| 4032 | 4245 | template_chmod(); |
| 4033 | 4246 | |
| 4034 | 4247 | // For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade! |
| 4035 | - if ($upcontext['is_large_forum']) |
|
| 4036 | - echo ' |
|
| 4248 | + if ($upcontext['is_large_forum']) { |
|
| 4249 | + echo ' |
|
| 4037 | 4250 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 4038 | 4251 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 4039 | 4252 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -4041,10 +4254,11 @@ discard block |
||
| 4041 | 4254 | ', $txt['upgrade_warning_lots_data'], ' |
| 4042 | 4255 | </div> |
| 4043 | 4256 | </div>'; |
| 4257 | + } |
|
| 4044 | 4258 | |
| 4045 | 4259 | // A warning message? |
| 4046 | - if (!empty($upcontext['warning'])) |
|
| 4047 | - echo ' |
|
| 4260 | + if (!empty($upcontext['warning'])) { |
|
| 4261 | + echo ' |
|
| 4048 | 4262 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 4049 | 4263 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 4050 | 4264 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -4052,6 +4266,7 @@ discard block |
||
| 4052 | 4266 | ', $upcontext['warning'], ' |
| 4053 | 4267 | </div> |
| 4054 | 4268 | </div>'; |
| 4269 | + } |
|
| 4055 | 4270 | |
| 4056 | 4271 | // Paths are incorrect? |
| 4057 | 4272 | echo ' |
@@ -4067,20 +4282,22 @@ discard block |
||
| 4067 | 4282 | if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600)) |
| 4068 | 4283 | { |
| 4069 | 4284 | $ago = time() - $upcontext['started']; |
| 4070 | - if ($ago < 60) |
|
| 4071 | - $ago = $ago . ' seconds'; |
|
| 4072 | - elseif ($ago < 3600) |
|
| 4073 | - $ago = (int) ($ago / 60) . ' minutes'; |
|
| 4074 | - else |
|
| 4075 | - $ago = (int) ($ago / 3600) . ' hours'; |
|
| 4285 | + if ($ago < 60) { |
|
| 4286 | + $ago = $ago . ' seconds'; |
|
| 4287 | + } elseif ($ago < 3600) { |
|
| 4288 | + $ago = (int) ($ago / 60) . ' minutes'; |
|
| 4289 | + } else { |
|
| 4290 | + $ago = (int) ($ago / 3600) . ' hours'; |
|
| 4291 | + } |
|
| 4076 | 4292 | |
| 4077 | 4293 | $active = time() - $upcontext['updated']; |
| 4078 | - if ($active < 60) |
|
| 4079 | - $updated = $active . ' seconds'; |
|
| 4080 | - elseif ($active < 3600) |
|
| 4081 | - $updated = (int) ($active / 60) . ' minutes'; |
|
| 4082 | - else |
|
| 4083 | - $updated = (int) ($active / 3600) . ' hours'; |
|
| 4294 | + if ($active < 60) { |
|
| 4295 | + $updated = $active . ' seconds'; |
|
| 4296 | + } elseif ($active < 3600) { |
|
| 4297 | + $updated = (int) ($active / 60) . ' minutes'; |
|
| 4298 | + } else { |
|
| 4299 | + $updated = (int) ($active / 3600) . ' hours'; |
|
| 4300 | + } |
|
| 4084 | 4301 | |
| 4085 | 4302 | echo ' |
| 4086 | 4303 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
@@ -4089,16 +4306,18 @@ discard block |
||
| 4089 | 4306 | <div style="padding-left: 6ex;"> |
| 4090 | 4307 | "', $upcontext['user']['name'], '" has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.'; |
| 4091 | 4308 | |
| 4092 | - if ($active < 600) |
|
| 4093 | - echo ' |
|
| 4309 | + if ($active < 600) { |
|
| 4310 | + echo ' |
|
| 4094 | 4311 | We recommend that you do not run this script unless you are sure that ', $upcontext['user']['name'], ' has completed their upgrade.'; |
| 4312 | + } |
|
| 4095 | 4313 | |
| 4096 | - if ($active > $upcontext['inactive_timeout']) |
|
| 4097 | - echo ' |
|
| 4314 | + if ($active > $upcontext['inactive_timeout']) { |
|
| 4315 | + echo ' |
|
| 4098 | 4316 | <br><br>You can choose to either run the upgrade again from the beginning - or alternatively continue from the last step reached during the last upgrade.'; |
| 4099 | - else |
|
| 4100 | - echo ' |
|
| 4317 | + } else { |
|
| 4318 | + echo ' |
|
| 4101 | 4319 | <br><br>This upgrade script cannot be run until ', $upcontext['user']['name'], ' has been inactive for at least ', ($upcontext['inactive_timeout'] > 120 ? round($upcontext['inactive_timeout'] / 60, 1) . ' minutes!' : $upcontext['inactive_timeout'] . ' seconds!'); |
| 4320 | + } |
|
| 4102 | 4321 | |
| 4103 | 4322 | echo ' |
| 4104 | 4323 | </div> |
@@ -4114,9 +4333,10 @@ discard block |
||
| 4114 | 4333 | <td> |
| 4115 | 4334 | <input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', ' class="input_text">'; |
| 4116 | 4335 | |
| 4117 | - if (!empty($upcontext['username_incorrect'])) |
|
| 4118 | - echo ' |
|
| 4336 | + if (!empty($upcontext['username_incorrect'])) { |
|
| 4337 | + echo ' |
|
| 4119 | 4338 | <div class="smalltext" style="color: red;">Username Incorrect</div>'; |
| 4339 | + } |
|
| 4120 | 4340 | |
| 4121 | 4341 | echo ' |
| 4122 | 4342 | </td> |
@@ -4127,9 +4347,10 @@ discard block |
||
| 4127 | 4347 | <input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', ' class="input_password"> |
| 4128 | 4348 | <input type="hidden" name="hash_passwrd" value="">'; |
| 4129 | 4349 | |
| 4130 | - if (!empty($upcontext['password_failed'])) |
|
| 4131 | - echo ' |
|
| 4350 | + if (!empty($upcontext['password_failed'])) { |
|
| 4351 | + echo ' |
|
| 4132 | 4352 | <div class="smalltext" style="color: red;">Password Incorrect</div>'; |
| 4353 | + } |
|
| 4133 | 4354 | |
| 4134 | 4355 | echo ' |
| 4135 | 4356 | </td> |
@@ -4200,8 +4421,8 @@ discard block |
||
| 4200 | 4421 | <form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">'; |
| 4201 | 4422 | |
| 4202 | 4423 | // Warning message? |
| 4203 | - if (!empty($upcontext['upgrade_options_warning'])) |
|
| 4204 | - echo ' |
|
| 4424 | + if (!empty($upcontext['upgrade_options_warning'])) { |
|
| 4425 | + echo ' |
|
| 4205 | 4426 | <div style="margin: 1ex; padding: 1ex; border: 1px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 4206 | 4427 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 4207 | 4428 | <strong style="text-decoration: underline;">Warning!</strong><br> |
@@ -4209,6 +4430,7 @@ discard block |
||
| 4209 | 4430 | ', $upcontext['upgrade_options_warning'], ' |
| 4210 | 4431 | </div> |
| 4211 | 4432 | </div>'; |
| 4433 | + } |
|
| 4212 | 4434 | |
| 4213 | 4435 | echo ' |
| 4214 | 4436 | <table> |
@@ -4236,8 +4458,8 @@ discard block |
||
| 4236 | 4458 | </tr>'; |
| 4237 | 4459 | |
| 4238 | 4460 | // Offer mysql users to switch to mysqli |
| 4239 | - if ($db_type == 'mysql' && function_exists('mysqli_query')) |
|
| 4240 | - echo ' |
|
| 4461 | + if ($db_type == 'mysql' && function_exists('mysqli_query')) { |
|
| 4462 | + echo ' |
|
| 4241 | 4463 | <tr valign="top"> |
| 4242 | 4464 | <td width="2%"> |
| 4243 | 4465 | <input type="checkbox" name="convertMysql" id="convertMysql" value="1" checked class="input_check"> |
@@ -4247,6 +4469,7 @@ discard block |
||
| 4247 | 4469 | <strong class="smalltext"><a href="http://wiki.simplemachines.org/smf/Upgrading-MySQLi-Functionality" target="_blank">More information about MySQLi</a></strong><br> |
| 4248 | 4470 | </td> |
| 4249 | 4471 | </tr>'; |
| 4472 | + } |
|
| 4250 | 4473 | |
| 4251 | 4474 | echo ' |
| 4252 | 4475 | <tr valign="top"> |
@@ -4266,8 +4489,8 @@ discard block |
||
| 4266 | 4489 | </td> |
| 4267 | 4490 | </tr>'; |
| 4268 | 4491 | |
| 4269 | - if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) |
|
| 4270 | - echo ' |
|
| 4492 | + if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) { |
|
| 4493 | + echo ' |
|
| 4271 | 4494 | <tr valign="top"> |
| 4272 | 4495 | <td width="2%"> |
| 4273 | 4496 | <input type="checkbox" name="delete_karma" id="delete_karma" value="1" class="input_check"> |
@@ -4276,6 +4499,7 @@ discard block |
||
| 4276 | 4499 | <label for="delete_karma">Delete all karma settings and info from the DB</label> |
| 4277 | 4500 | </td> |
| 4278 | 4501 | </tr>'; |
| 4502 | + } |
|
| 4279 | 4503 | |
| 4280 | 4504 | echo ' |
| 4281 | 4505 | <tr valign="top"> |
@@ -4311,10 +4535,11 @@ discard block |
||
| 4311 | 4535 | <span id="debuginfo"></span>'; |
| 4312 | 4536 | |
| 4313 | 4537 | // Dont any tables so far? |
| 4314 | - if (!empty($upcontext['previous_tables'])) |
|
| 4315 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4538 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4539 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4316 | 4540 | echo ' |
| 4317 | 4541 | <br>Completed Table: "', $table, '".'; |
| 4542 | + } |
|
| 4318 | 4543 | |
| 4319 | 4544 | echo ' |
| 4320 | 4545 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
@@ -4351,12 +4576,13 @@ discard block |
||
| 4351 | 4576 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4352 | 4577 | |
| 4353 | 4578 | // If debug flood the screen. |
| 4354 | - if ($is_debug) |
|
| 4355 | - echo ' |
|
| 4579 | + if ($is_debug) { |
|
| 4580 | + echo ' |
|
| 4356 | 4581 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 4357 | 4582 | |
| 4358 | 4583 | if (document.getElementById(\'debuginfo\').scrollHeight) |
| 4359 | 4584 | document.getElementById(\'debuginfo\').scrollTop = document.getElementById(\'debuginfo\').scrollHeight;'; |
| 4585 | + } |
|
| 4360 | 4586 | |
| 4361 | 4587 | echo ' |
| 4362 | 4588 | // Get the next update... |
@@ -4388,8 +4614,9 @@ discard block |
||
| 4388 | 4614 | { |
| 4389 | 4615 | global $upcontext, $support_js, $is_debug, $timeLimitThreshold; |
| 4390 | 4616 | |
| 4391 | - if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) |
|
| 4392 | - $is_debug = true; |
|
| 4617 | + if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) { |
|
| 4618 | + $is_debug = true; |
|
| 4619 | + } |
|
| 4393 | 4620 | |
| 4394 | 4621 | echo ' |
| 4395 | 4622 | <h3>Executing database changes</h3> |
@@ -4404,8 +4631,9 @@ discard block |
||
| 4404 | 4631 | { |
| 4405 | 4632 | foreach ($upcontext['actioned_items'] as $num => $item) |
| 4406 | 4633 | { |
| 4407 | - if ($num != 0) |
|
| 4408 | - echo ' Successful!'; |
|
| 4634 | + if ($num != 0) { |
|
| 4635 | + echo ' Successful!'; |
|
| 4636 | + } |
|
| 4409 | 4637 | echo '<br>' . $item; |
| 4410 | 4638 | } |
| 4411 | 4639 | if (!empty($upcontext['changes_complete'])) |
@@ -4418,28 +4646,32 @@ discard block |
||
| 4418 | 4646 | $seconds = intval($active % 60); |
| 4419 | 4647 | |
| 4420 | 4648 | $totalTime = ''; |
| 4421 | - if ($hours > 0) |
|
| 4422 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4423 | - if ($minutes > 0) |
|
| 4424 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4425 | - if ($seconds > 0) |
|
| 4426 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4649 | + if ($hours > 0) { |
|
| 4650 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4651 | + } |
|
| 4652 | + if ($minutes > 0) { |
|
| 4653 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4654 | + } |
|
| 4655 | + if ($seconds > 0) { |
|
| 4656 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4657 | + } |
|
| 4427 | 4658 | } |
| 4428 | 4659 | |
| 4429 | - if ($is_debug && !empty($totalTime)) |
|
| 4430 | - echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
| 4431 | - else |
|
| 4432 | - echo ' Successful!<br><br>'; |
|
| 4660 | + if ($is_debug && !empty($totalTime)) { |
|
| 4661 | + echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
| 4662 | + } else { |
|
| 4663 | + echo ' Successful!<br><br>'; |
|
| 4664 | + } |
|
| 4433 | 4665 | |
| 4434 | 4666 | echo '<span id="commess" style="font-weight: bold;">1 Database Updates Complete! Click Continue to Proceed.</span><br>'; |
| 4435 | 4667 | } |
| 4436 | - } |
|
| 4437 | - else |
|
| 4668 | + } else |
|
| 4438 | 4669 | { |
| 4439 | 4670 | // Tell them how many files we have in total. |
| 4440 | - if ($upcontext['file_count'] > 1) |
|
| 4441 | - echo ' |
|
| 4671 | + if ($upcontext['file_count'] > 1) { |
|
| 4672 | + echo ' |
|
| 4442 | 4673 | <strong id="info1">Executing upgrade script <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>'; |
| 4674 | + } |
|
| 4443 | 4675 | |
| 4444 | 4676 | echo ' |
| 4445 | 4677 | <h3 id="info2"><strong>Executing:</strong> "<span id="cur_item_name">', $upcontext['current_item_name'], '</span>" (<span id="item_num">', $upcontext['current_item_num'], '</span> of <span id="total_items"><span id="item_count">', $upcontext['total_items'], '</span>', $upcontext['file_count'] > 1 ? ' - of this script' : '', ')</span></h3> |
@@ -4455,19 +4687,23 @@ discard block |
||
| 4455 | 4687 | $seconds = intval($active % 60); |
| 4456 | 4688 | |
| 4457 | 4689 | $totalTime = ''; |
| 4458 | - if ($hours > 0) |
|
| 4459 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4460 | - if ($minutes > 0) |
|
| 4461 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4462 | - if ($seconds > 0) |
|
| 4463 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4690 | + if ($hours > 0) { |
|
| 4691 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4692 | + } |
|
| 4693 | + if ($minutes > 0) { |
|
| 4694 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4695 | + } |
|
| 4696 | + if ($seconds > 0) { |
|
| 4697 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4698 | + } |
|
| 4464 | 4699 | } |
| 4465 | 4700 | |
| 4466 | 4701 | echo ' |
| 4467 | 4702 | <br><span id="upgradeCompleted">'; |
| 4468 | 4703 | |
| 4469 | - if (!empty($totalTime)) |
|
| 4470 | - echo 'Completed in ', $totalTime, '<br>'; |
|
| 4704 | + if (!empty($totalTime)) { |
|
| 4705 | + echo 'Completed in ', $totalTime, '<br>'; |
|
| 4706 | + } |
|
| 4471 | 4707 | |
| 4472 | 4708 | echo '</span> |
| 4473 | 4709 | <div id="debug_section" style="height: 200px; overflow: auto;"> |
@@ -4504,9 +4740,10 @@ discard block |
||
| 4504 | 4740 | var getData = ""; |
| 4505 | 4741 | var debugItems = ', $upcontext['debug_items'], ';'; |
| 4506 | 4742 | |
| 4507 | - if ($is_debug) |
|
| 4508 | - echo ' |
|
| 4743 | + if ($is_debug) { |
|
| 4744 | + echo ' |
|
| 4509 | 4745 | var upgradeStartTime = ' . $upcontext['started'] . ';'; |
| 4746 | + } |
|
| 4510 | 4747 | |
| 4511 | 4748 | echo ' |
| 4512 | 4749 | function getNextItem() |
@@ -4546,9 +4783,10 @@ discard block |
||
| 4546 | 4783 | document.getElementById("error_block").style.display = ""; |
| 4547 | 4784 | setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));'; |
| 4548 | 4785 | |
| 4549 | - if ($is_debug) |
|
| 4550 | - echo ' |
|
| 4786 | + if ($is_debug) { |
|
| 4787 | + echo ' |
|
| 4551 | 4788 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
| 4789 | + } |
|
| 4552 | 4790 | |
| 4553 | 4791 | echo ' |
| 4554 | 4792 | } |
@@ -4569,9 +4807,10 @@ discard block |
||
| 4569 | 4807 | document.getElementById("error_block").style.display = ""; |
| 4570 | 4808 | setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);'; |
| 4571 | 4809 | |
| 4572 | - if ($is_debug) |
|
| 4573 | - echo ' |
|
| 4810 | + if ($is_debug) { |
|
| 4811 | + echo ' |
|
| 4574 | 4812 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
| 4813 | + } |
|
| 4575 | 4814 | |
| 4576 | 4815 | echo ' |
| 4577 | 4816 | } |
@@ -4630,8 +4869,8 @@ discard block |
||
| 4630 | 4869 | if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ') |
| 4631 | 4870 | {'; |
| 4632 | 4871 | |
| 4633 | - if ($is_debug) |
|
| 4634 | - echo ' |
|
| 4872 | + if ($is_debug) { |
|
| 4873 | + echo ' |
|
| 4635 | 4874 | document.getElementById(\'debug_section\').style.display = "none"; |
| 4636 | 4875 | |
| 4637 | 4876 | var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue); |
@@ -4649,6 +4888,7 @@ discard block |
||
| 4649 | 4888 | totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : ""); |
| 4650 | 4889 | |
| 4651 | 4890 | setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);'; |
| 4891 | + } |
|
| 4652 | 4892 | |
| 4653 | 4893 | echo ' |
| 4654 | 4894 | |
@@ -4656,9 +4896,10 @@ discard block |
||
| 4656 | 4896 | document.getElementById(\'contbutt\').disabled = 0; |
| 4657 | 4897 | document.getElementById(\'database_done\').value = 1;'; |
| 4658 | 4898 | |
| 4659 | - if ($upcontext['file_count'] > 1) |
|
| 4660 | - echo ' |
|
| 4899 | + if ($upcontext['file_count'] > 1) { |
|
| 4900 | + echo ' |
|
| 4661 | 4901 | document.getElementById(\'info1\').style.display = "none";'; |
| 4902 | + } |
|
| 4662 | 4903 | |
| 4663 | 4904 | echo ' |
| 4664 | 4905 | document.getElementById(\'info2\').style.display = "none"; |
@@ -4671,9 +4912,10 @@ discard block |
||
| 4671 | 4912 | lastItem = 0; |
| 4672 | 4913 | prevFile = curFile;'; |
| 4673 | 4914 | |
| 4674 | - if ($is_debug) |
|
| 4675 | - echo ' |
|
| 4915 | + if ($is_debug) { |
|
| 4916 | + echo ' |
|
| 4676 | 4917 | setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');'; |
| 4918 | + } |
|
| 4677 | 4919 | |
| 4678 | 4920 | echo ' |
| 4679 | 4921 | getNextItem(); |
@@ -4681,8 +4923,8 @@ discard block |
||
| 4681 | 4923 | }'; |
| 4682 | 4924 | |
| 4683 | 4925 | // If debug scroll the screen. |
| 4684 | - if ($is_debug) |
|
| 4685 | - echo ' |
|
| 4926 | + if ($is_debug) { |
|
| 4927 | + echo ' |
|
| 4686 | 4928 | if (iLastSubStepProgress == -1) |
| 4687 | 4929 | { |
| 4688 | 4930 | // Give it consistent dots. |
@@ -4701,6 +4943,7 @@ discard block |
||
| 4701 | 4943 | |
| 4702 | 4944 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4703 | 4945 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4946 | + } |
|
| 4704 | 4947 | |
| 4705 | 4948 | echo ' |
| 4706 | 4949 | // Update the page. |
@@ -4761,9 +5004,10 @@ discard block |
||
| 4761 | 5004 | }'; |
| 4762 | 5005 | |
| 4763 | 5006 | // Start things off assuming we've not errored. |
| 4764 | - if (empty($upcontext['error_message'])) |
|
| 4765 | - echo ' |
|
| 5007 | + if (empty($upcontext['error_message'])) { |
|
| 5008 | + echo ' |
|
| 4766 | 5009 | getNextItem();'; |
| 5010 | + } |
|
| 4767 | 5011 | |
| 4768 | 5012 | echo ' |
| 4769 | 5013 | </script>'; |
@@ -4780,18 +5024,21 @@ discard block |
||
| 4780 | 5024 | <item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item> |
| 4781 | 5025 | <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>'; |
| 4782 | 5026 | |
| 4783 | - if (!empty($upcontext['error_message'])) |
|
| 4784 | - echo ' |
|
| 5027 | + if (!empty($upcontext['error_message'])) { |
|
| 5028 | + echo ' |
|
| 4785 | 5029 | <error>', $upcontext['error_message'], '</error>'; |
| 5030 | + } |
|
| 4786 | 5031 | |
| 4787 | - if (!empty($upcontext['error_string'])) |
|
| 4788 | - echo ' |
|
| 5032 | + if (!empty($upcontext['error_string'])) { |
|
| 5033 | + echo ' |
|
| 4789 | 5034 | <sql>', $upcontext['error_string'], '</sql>'; |
| 5035 | + } |
|
| 4790 | 5036 | |
| 4791 | - if ($is_debug) |
|
| 4792 | - echo ' |
|
| 5037 | + if ($is_debug) { |
|
| 5038 | + echo ' |
|
| 4793 | 5039 | <curtime>', time(), '</curtime>'; |
| 4794 | -} |
|
| 5040 | + } |
|
| 5041 | + } |
|
| 4795 | 5042 | |
| 4796 | 5043 | // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications.... |
| 4797 | 5044 | function template_convert_utf8() |
@@ -4808,18 +5055,20 @@ discard block |
||
| 4808 | 5055 | <span id="debuginfo"></span>'; |
| 4809 | 5056 | |
| 4810 | 5057 | // Done any tables so far? |
| 4811 | - if (!empty($upcontext['previous_tables'])) |
|
| 4812 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 5058 | + if (!empty($upcontext['previous_tables'])) { |
|
| 5059 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4813 | 5060 | echo ' |
| 4814 | 5061 | <br>Completed Table: "', $table, '".'; |
| 5062 | + } |
|
| 4815 | 5063 | |
| 4816 | 5064 | echo ' |
| 4817 | 5065 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3>'; |
| 4818 | 5066 | |
| 4819 | 5067 | // If we dropped their index, let's let them know |
| 4820 | - if ($upcontext['cur_table_num'] == $upcontext['table_count'] && $upcontext['dropping_index']) |
|
| 4821 | - echo ' |
|
| 5068 | + if ($upcontext['cur_table_num'] == $upcontext['table_count'] && $upcontext['dropping_index']) { |
|
| 5069 | + echo ' |
|
| 4822 | 5070 | <br><span style="display:inline;">Please note that your fulltext index was dropped to facilitate the conversion and will need to be recreated.</span>'; |
| 5071 | + } |
|
| 4823 | 5072 | |
| 4824 | 5073 | echo ' |
| 4825 | 5074 | <br><span id="commess" style="font-weight: bold; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">Conversion Complete! Click Continue to Proceed.</span>'; |
@@ -4855,9 +5104,10 @@ discard block |
||
| 4855 | 5104 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4856 | 5105 | |
| 4857 | 5106 | // If debug flood the screen. |
| 4858 | - if ($is_debug) |
|
| 4859 | - echo ' |
|
| 5107 | + if ($is_debug) { |
|
| 5108 | + echo ' |
|
| 4860 | 5109 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\');'; |
| 5110 | + } |
|
| 4861 | 5111 | |
| 4862 | 5112 | echo ' |
| 4863 | 5113 | // Get the next update... |
@@ -4899,19 +5149,21 @@ discard block |
||
| 4899 | 5149 | <span id="debuginfo"></span>'; |
| 4900 | 5150 | |
| 4901 | 5151 | // Dont any tables so far? |
| 4902 | - if (!empty($upcontext['previous_tables'])) |
|
| 4903 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 5152 | + if (!empty($upcontext['previous_tables'])) { |
|
| 5153 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4904 | 5154 | echo ' |
| 4905 | 5155 | <br>Completed Table: "', $table, '".'; |
| 5156 | + } |
|
| 4906 | 5157 | |
| 4907 | 5158 | echo ' |
| 4908 | 5159 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
| 4909 | 5160 | <br><span id="commess" style="font-weight: bold; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">Convert to JSON Complete! Click Continue to Proceed.</span>'; |
| 4910 | 5161 | |
| 4911 | 5162 | // Try to make sure substep was reset. |
| 4912 | - if ($upcontext['cur_table_num'] == $upcontext['table_count']) |
|
| 4913 | - echo ' |
|
| 5163 | + if ($upcontext['cur_table_num'] == $upcontext['table_count']) { |
|
| 5164 | + echo ' |
|
| 4914 | 5165 | <input type="hidden" name="substep" id="substep" value="0">'; |
| 5166 | + } |
|
| 4915 | 5167 | |
| 4916 | 5168 | // Continue please! |
| 4917 | 5169 | $upcontext['continue'] = $support_js ? 2 : 1; |
@@ -4944,9 +5196,10 @@ discard block |
||
| 4944 | 5196 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4945 | 5197 | |
| 4946 | 5198 | // If debug flood the screen. |
| 4947 | - if ($is_debug) |
|
| 4948 | - echo ' |
|
| 5199 | + if ($is_debug) { |
|
| 5200 | + echo ' |
|
| 4949 | 5201 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\');'; |
| 5202 | + } |
|
| 4950 | 5203 | |
| 4951 | 5204 | echo ' |
| 4952 | 5205 | // Get the next update... |
@@ -4981,8 +5234,8 @@ discard block |
||
| 4981 | 5234 | <h3>That wasn\'t so hard, was it? Now you are ready to use <a href="', $boardurl, '/index.php">your installation of SMF</a>. Hope you like it!</h3> |
| 4982 | 5235 | <form action="', $boardurl, '/index.php">'; |
| 4983 | 5236 | |
| 4984 | - if (!empty($upcontext['can_delete_script'])) |
|
| 4985 | - echo ' |
|
| 5237 | + if (!empty($upcontext['can_delete_script'])) { |
|
| 5238 | + echo ' |
|
| 4986 | 5239 | <label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete(this);" class="input_check"> Delete upgrade.php and its data files now</label> <em>(doesn\'t work on all servers).</em> |
| 4987 | 5240 | <script> |
| 4988 | 5241 | function doTheDelete(theCheck) |
@@ -4994,6 +5247,7 @@ discard block |
||
| 4994 | 5247 | } |
| 4995 | 5248 | </script> |
| 4996 | 5249 | <img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>'; |
| 5250 | + } |
|
| 4997 | 5251 | |
| 4998 | 5252 | $active = time() - $upcontext['started']; |
| 4999 | 5253 | $hours = floor($active / 3600); |
@@ -5003,16 +5257,20 @@ discard block |
||
| 5003 | 5257 | if ($is_debug) |
| 5004 | 5258 | { |
| 5005 | 5259 | $totalTime = ''; |
| 5006 | - if ($hours > 0) |
|
| 5007 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 5008 | - if ($minutes > 0) |
|
| 5009 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 5010 | - if ($seconds > 0) |
|
| 5011 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 5260 | + if ($hours > 0) { |
|
| 5261 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 5262 | + } |
|
| 5263 | + if ($minutes > 0) { |
|
| 5264 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 5265 | + } |
|
| 5266 | + if ($seconds > 0) { |
|
| 5267 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 5268 | + } |
|
| 5012 | 5269 | } |
| 5013 | 5270 | |
| 5014 | - if ($is_debug && !empty($totalTime)) |
|
| 5015 | - echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
| 5271 | + if ($is_debug && !empty($totalTime)) { |
|
| 5272 | + echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
| 5273 | + } |
|
| 5016 | 5274 | |
| 5017 | 5275 | echo '<br> |
| 5018 | 5276 | If you had any problems with this upgrade, or have any problems using SMF, please don\'t hesitate to <a href="http://www.simplemachines.org/community/index.php">look to us for assistance</a>.<br> |
@@ -5079,16 +5337,19 @@ discard block |
||
| 5079 | 5337 | 'empty' => '', |
| 5080 | 5338 | 'limit' => $limit, |
| 5081 | 5339 | )); |
| 5082 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 5083 | - $arIp[] = $row[$oldCol]; |
|
| 5340 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 5341 | + $arIp[] = $row[$oldCol]; |
|
| 5342 | + } |
|
| 5084 | 5343 | $smcFunc['db_free_result']($request); |
| 5085 | 5344 | |
| 5086 | 5345 | // Special case, null ip could keep us in a loop. |
| 5087 | - if (is_null($arIp[0])) |
|
| 5088 | - unset($arIp[0]); |
|
| 5346 | + if (is_null($arIp[0])) { |
|
| 5347 | + unset($arIp[0]); |
|
| 5348 | + } |
|
| 5089 | 5349 | |
| 5090 | - if (empty($arIp)) |
|
| 5091 | - $is_done = true; |
|
| 5350 | + if (empty($arIp)) { |
|
| 5351 | + $is_done = true; |
|
| 5352 | + } |
|
| 5092 | 5353 | |
| 5093 | 5354 | $updates = array(); |
| 5094 | 5355 | $cases = array(); |
@@ -5097,16 +5358,18 @@ discard block |
||
| 5097 | 5358 | { |
| 5098 | 5359 | $arIp[$i] = trim($arIp[$i]); |
| 5099 | 5360 | |
| 5100 | - if (empty($arIp[$i])) |
|
| 5101 | - continue; |
|
| 5361 | + if (empty($arIp[$i])) { |
|
| 5362 | + continue; |
|
| 5363 | + } |
|
| 5102 | 5364 | |
| 5103 | 5365 | $updates['ip' . $i] = $arIp[$i]; |
| 5104 | 5366 | $cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}'; |
| 5105 | 5367 | |
| 5106 | 5368 | if ($setSize > 0 && $i % $setSize === 0) |
| 5107 | 5369 | { |
| 5108 | - if (count($updates) == 1) |
|
| 5109 | - continue; |
|
| 5370 | + if (count($updates) == 1) { |
|
| 5371 | + continue; |
|
| 5372 | + } |
|
| 5110 | 5373 | |
| 5111 | 5374 | $updates['whereSet'] = array_values($updates); |
| 5112 | 5375 | $smcFunc['db_query']('', ' |
@@ -5140,8 +5403,7 @@ discard block |
||
| 5140 | 5403 | 'ip' => $ip |
| 5141 | 5404 | )); |
| 5142 | 5405 | } |
| 5143 | - } |
|
| 5144 | - else |
|
| 5406 | + } else |
|
| 5145 | 5407 | { |
| 5146 | 5408 | $updates['whereSet'] = array_values($updates); |
| 5147 | 5409 | $smcFunc['db_query']('', ' |
@@ -5155,9 +5417,9 @@ discard block |
||
| 5155 | 5417 | $updates |
| 5156 | 5418 | ); |
| 5157 | 5419 | } |
| 5420 | + } else { |
|
| 5421 | + $is_done = true; |
|
| 5158 | 5422 | } |
| 5159 | - else |
|
| 5160 | - $is_done = true; |
|
| 5161 | 5423 | |
| 5162 | 5424 | $_GET['a'] += $limit; |
| 5163 | 5425 | $step_progress['current'] = $_GET['a']; |